agentleFS
stoneforge-aistoneforge-ai/stoneforge/AGENTS.md

stoneforge

AGENTS.md190 starsChanged 10 months agoApache-2.0View on GitHub

Context and instructions for AI coding agents working on the Stoneforge repository.

  • Where files are headingNew AGENTS.md files have more rules about keeping secrets out of the code, and fewer about checking a change actually works.

    Of the AGENTS.md files we read, the 11,773 first seen in the last six months, against the older ones: the kind of rule that gained most share, and the kind that lost most. About files like this in general, not this one, and an estimate, since a kind is a pattern in the words.

  • In this repository2 other files it gives its agents.

The file

We split this AGENTS.md into the rules it gives an agent

11 rules. About 0 are common, 3 are distinctive, and 8 are very specific to this project.

  • ≈0

    Common · estimate

    Many files like this have a rule of this kind.

  • ≈3

    Distinctive · estimate

    This author's own choices. Worth a look.

  • 8

    Very specific

    Tied to their project's names, files or tools. Probably skip.

  • Common
  • Distinctive
  • Very specific
  1. Very specific:

    blocked is computed: - Never set status: 'blocked' directly.

    line 152
  2. Very specific:

    FTS not indexed on import: - After sf import, run sf document reindex to rebuild search index

    line 158
  3. Very specific:

    Use branded types: ElementId, EntityId, DocumentId, ChannelId, WorkflowId

    line 201
  4. Very specific:

    Use asEntityId(), asElementId() casts only at trust boundaries

    line 203
  5. Very specific:

    All mutations through QuarryAPI - never modify SQLite directly

    line 207
  6. Very specific:

    Run bun test <path> for specific tests

    line 215
  7. Very specific:

    Use StoneforgeError with appropriate ErrorCode

    line 220
  8. Distinctive:

    When your changes affect documented behavior (APIs, config, workflows, architecture):

    line 248
  9. Distinctive:

    Create commits after completing features, refactors, or significant changes

    line 260
  10. Distinctive:

    Only commit files you changed

    line 261
  11. Very specific:

    Use conventional commit format: feat:, fix:, chore:, docs:

    line 262

≈ “Common” is an estimate: at least 1 in 5 of the 16,595 AGENTS.md files we read have a rule of the same kind, not the same words. “Very specific” is our guess from the words: it names a file, a command, a setting or the project itself.

Keep what fits and drop the rest. Your version, ready for your agents.
Files
AGENTS.md

AGENTS.md

Context and instructions for AI coding agents working on the Stoneforge repository.

How to Find Documentation

  1. This file — Quick task-to-file mappings below
  2. Documentation Directory — Full index of all workspace docs: sf show el-30yb
  3. Category Index — Browse by category: sf show el-og6v
  4. Full-text search — Find any doc by topic: sf document search "your topic"

Quick Start

Backend Tasks

I need...Key FilesReference Doc
Add an API endpointapps/quarry-server/src/index.ts, apps/smithy-server/src/routes/sf show el-5z1q
Add a core typepackages/core/src/types/sf show el-6c3s
Work with dependenciespackages/quarry/src/services/dependency.tssf show el-200z
Add an orchestrator servicepackages/smithy/src/services/sf show el-50ia
Use the CLIpackages/quarry/src/cli/commands/sf show el-59tr
Use the QuarryAPIpackages/quarry/src/api/quarry-api.tssf show el-kflh
Use the OrchestratorAPIpackages/smithy/src/api/orchestrator-api.tssf show el-3qg2
Customize agent prompts.stoneforge/prompts/sf show el-32rb
Configure identitypackages/quarry/src/systems/identity.tssf show el-2jw5
Understand event sourcingpackages/core/src/types/event.tssf show el-58k3
Configure the systempackages/quarry/src/config/sf show el-z1sj

Frontend Tasks

I need...Key FilesReference Doc
Modify a smithy-web pageapps/smithy-web/src/routes/{page}/sf show el-4b3q
Modify a quarry-web pageapps/quarry-web/src/routes/{page}/sf show el-4iiz
Add a new frontend routeapps/{app}/src/router.tsxsf show el-232d
Modify shared UI componentspackages/ui/src/sf show el-2hk5
Add a React componentapps/{app}/src/components/sf show el-3gg7
Work with API hooks (smithy)apps/smithy-web/src/api/hooks/sf show el-4b3q
Work with API hooks (quarry)apps/quarry-web/src/api/hooks/sf show el-4iiz
Understand frontend architecture—sf show el-935d

Repository Structure

packages/
├── core/              # @stoneforge/core - types, errors, ID generation
├── storage/           # @stoneforge/storage - SQLite backends (Bun, Node, Browser)
├── quarry/            # @stoneforge/quarry - QuarryAPI, services, sync, CLI
├── ui/                # @stoneforge/ui - React components, hooks, design tokens
├── shared-routes/     # @stoneforge/shared-routes - HTTP route factories
└── smithy/            # @stoneforge/smithy - agent orchestration

apps/
├── quarry-server/     # Platform HTTP + WebSocket (port 3456)
├── quarry-web/        # Platform React SPA (port 5173)
├── smithy-server/     # Orchestrator API (port 3457)
├── smithy-web/        # Orchestrator dashboard (port 5174)
├── docs/              # @stoneforge/docs - Astro documentation site
└── website/           # @stoneforge/website - Public website

.stoneforge/            # Project data (config.yaml, sync/, prompts/, uploads/)

Package Dependency Graph

@stoneforge/core           (shared types, no dependencies)
       ↓
@stoneforge/storage        (SQLite backends)
       ↓
@stoneforge/shared-routes  (HTTP route factories)
       ↓
@stoneforge/quarry         (API, services, sync, CLI)
       ↓
@stoneforge/smithy         (agent orchestration)

@stoneforge/ui             (React components, hooks — depends on core, shared-routes)

Core Concepts

Element Types

  • Core Types: Task, Message, Document, Entity
  • Collection Types: Plan, Workflow, Playbook, Channel, Library, Team
  • All inherit from Element (id, type, timestamps, tags, metadata, createdBy)

Dual Storage Model

  • SQLite: Fast queries, indexes, FTS - the cache
  • JSONL: Git-tracked, append-only - the source of truth

Dependencies

  • Blocking types: blocks, awaits, parent-child - affect task status
  • Non-blocking: relates-to, mentions, references - informational only
  • blocked status is computed from dependencies, never set directly

Agent Roles (Orchestrator)

  • Director: Owns task backlog, spawns workers, makes strategic decisions
  • Worker: Executes assigned tasks (ephemeral or persistent)
  • Steward: Handles code merges, documentation scanning and fixes

Development Workflow

Build & Test

bun install           # Install dependencies
bun run build         # Build all packages
bun test              # Run test suite
bun test --watch      # Watch mode

CLI Usage

sf task ready         # List ready tasks
sf task blocked       # List blocked tasks
sf show <id>          # Show element details
sf task create --title "..." --priority 3 --type feature
sf dependency add --type=blocks <blocked-id> <blocker-id>
sf task close <id> --reason "..."
sf stats              # View progress stats

Running Apps

bun run --filter @stoneforge/quarry-server dev       # Platform server (port 3456)
bun run --filter @stoneforge/quarry-web dev          # Platform web (port 5173)
bun run --filter @stoneforge/smithy-server dev  # Orchestrator (port 3457)
bun run --filter @stoneforge/smithy-web dev     # Orchestrator UI (port 5174)

Critical Gotchas

See sf show el-49ra for the complete list. Top 10 for agents:

  1. blocked is computed - Never set status: 'blocked' directly; it's derived from dependencies
  2. blocks direction - sf dependency add --type=blocks A B means A is blocked BY B (B completes first)
  3. Messages need contentRef - sendDirectMessage() requires a DocumentId, not raw text
  4. sortByEffectivePriority() mutates - Returns same array reference, modifies in place
  5. SQLite is cache - JSONL is the source of truth; SQLite can be rebuilt
  6. No auto cycle detection - api.addDependency() doesn't check cycles; use DependencyService.detectCycle()
  7. FTS not indexed on import - After sf import, run sf document reindex to rebuild search index
  8. relates-to is bidirectional - Query both directions: getDependencies() AND getDependents()
  9. Closed/tombstone always wins - In merge conflicts, these statuses take precedence
  10. Server ports - Platform: 3456, Orchestrator: 3457 (not 3000)

Navigation Quick Reference

I want to...Key Files
Add a new core typepackages/core/src/types/
Add an API endpointapps/quarry-server/src/index.ts
Add a React componentpackages/ui/src/components/
Work with dependenciespackages/quarry/src/services/dependency.ts
Understand task statuspackages/core/src/types/task.ts
Configure identity/signingpackages/quarry/src/systems/identity.ts
Work with the Orchestrator APIpackages/smithy/src/api/orchestrator-api.ts
Customize agent prompts.stoneforge/prompts/
Debug sync issuespackages/quarry/src/sync/service.ts
Add a CLI commandpackages/quarry/src/cli/commands/
Modify the Activity pageapps/smithy-web/src/routes/activity/, apps/smithy-web/src/components/activity/
Modify the Agents pageapps/smithy-web/src/routes/agents/, apps/smithy-web/src/components/agent/
Modify the Tasks page (smithy)apps/smithy-web/src/routes/tasks/, apps/smithy-web/src/components/task/
Modify the Dashboard (quarry)apps/quarry-web/src/routes/dashboard/
Modify the Entity pageapps/quarry-web/src/routes/entities/
Modify the Dependency Graphapps/quarry-web/src/routes/dependency-graph/
Modify the Workspaces pageapps/smithy-web/src/routes/workspaces/, apps/smithy-web/src/components/workspace/, apps/smithy-web/src/components/terminal/
Modify the Editorapps/smithy-web/src/routes/editor/, apps/smithy-web/src/components/editor/
Modify the Messages pageapps/smithy-web/src/routes/messages/ or apps/quarry-web/src/routes/messages/
Modify the Documents pageapps/smithy-web/src/routes/documents/ or apps/quarry-web/src/routes/documents/
Modify the Merge Requests pageapps/smithy-web/src/routes/merge-requests/, apps/smithy-web/src/components/merge-request/
Modify the Plans pageapps/smithy-web/src/routes/plans/ or apps/quarry-web/src/routes/plans/
Modify the Workflows pageapps/smithy-web/src/routes/workflows/ or apps/quarry-web/src/routes/workflows/
Modify the Settings pageapps/smithy-web/src/routes/settings/ or apps/quarry-web/src/routes/settings/
Modify the Metrics pageapps/smithy-web/src/routes/metrics/

Implementation Guidelines

Type Safety

  • Use branded types: ElementId, EntityId, DocumentId, ChannelId, WorkflowId
  • Implement type guards: isTask(), isElement(), etc.
  • Use asEntityId(), asElementId() casts only at trust boundaries

Storage Operations

  • All mutations through QuarryAPI - never modify SQLite directly
  • Dirty tracking marks elements for incremental export
  • Content hashing enables merge conflict detection

Testing

  • Tests colocated with source: *.test.ts next to *.ts
  • Integration tests use real SQLite (:memory: or temp files)
  • Run bun test <path> for specific tests
  • See sf show el-50x1 for test runner conventions (Bun vs Vitest)

Error Handling

  • Use StoneforgeError with appropriate ErrorCode
  • CLI formats errors based on output mode (standard, verbose, quiet)

Agent Orchestration Overview

The orchestrator manages AI agent lifecycles for multi-agent task execution:

Director → creates tasks, assigns priorities → dispatches to Workers
Workers  → execute tasks in git worktrees → update status, handoff
Stewards → merge completed work, documentation scanning and fixes

Key Services:

  • OrchestratorAPI - Agent registration and management
  • DispatchService - Task assignment with inbox notifications
  • SpawnerService - Process spawning, headless/interactive modes (packages/smithy/src/runtime/spawner.ts)
  • SessionManager - Agent session lifecycle tracking (packages/smithy/src/runtime/session-manager.ts)

Prompts: Built-in prompts in packages/smithy/src/prompts/, override with .stoneforge/prompts/


Keeping Docs Updated

When your changes affect documented behavior (APIs, config, workflows, architecture):

  1. Search for relevant docs: sf document search "topic"
  2. Update existing workspace documents: sf document update <doc-id> --content "..."
  3. Create new docs for undocumented knowledge: sf document create --title "..." --content "..." --category reference --type markdown
  4. Update the Documentation Directory (sf show el-30yb) when you create or significantly modify documents
  5. Add to the Documentation library (sf docs add <doc-id>) so the document is discoverable

Commit Guidelines

  • Create commits after completing features, refactors, or significant changes
  • Only commit files you changed
  • Use conventional commit format: feat:, fix:, chore:, docs:

Download now (ZIP)

Does it work?

Reviews from people and from AI agents that ran it: what they used it for, and whether it worked.

No reviews yet

People and AI agents can review whether this works in practice. Say what you used it for, and whether it worked.

  • It worked
  • Partly
  • It didn't
What did you use it for? e.g. Reviewing pull requests in a Rails app

Using an agent? It can post a review for you after it has run the file: the MCP tool registry_write, action report. How to connect one.

Your trail

Files you open will collect here, so you can find them again.

Open two or more, and you can remix the rules you like from each into one list. Kept in this browser only.

Now do this for your own.

Bring your CLAUDE.md, AGENTS.md or skills. agentleFS shows which of your rules are common, which are yours and which only fit one project, and keeps one version your agents read everywhere.