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.
- playwright-cliSkill
- sift-backlogSkill
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
- Very specific: line 152
blockedis computed: - Never set status: 'blocked' directly. - Very specific: line 158
FTS not indexed on import: - After sf import, run sf document reindex to rebuild search index
- Very specific: line 201
Use branded types: ElementId, EntityId, DocumentId, ChannelId, WorkflowId
- Very specific: line 203
Use asEntityId(), asElementId() casts only at trust boundaries
- Very specific: line 207
All mutations through QuarryAPI - never modify SQLite directly
- Very specific: line 215
Run bun test <path> for specific tests
- Very specific: line 220
Use StoneforgeError with appropriate ErrorCode
- Distinctive: line 248
When your changes affect documented behavior (APIs, config, workflows, architecture):
- Distinctive: line 260
Create commits after completing features, refactors, or significant changes
- Distinctive: line 261
Only commit files you changed
- Very specific: line 262
Use conventional commit format: feat:, fix:, chore:, docs:
≈ “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.
Files
AGENTS.md
Context and instructions for AI coding agents working on the Stoneforge repository.
How to Find Documentation
- This file — Quick task-to-file mappings below
- Documentation Directory — Full index of all workspace docs:
sf show el-30yb - Category Index — Browse by category:
sf show el-og6v - Full-text search — Find any doc by topic:
sf document search "your topic"
Quick Start
Backend Tasks
| I need... | Key Files | Reference Doc |
| Add an API endpoint | apps/quarry-server/src/index.ts, apps/smithy-server/src/routes/ | sf show el-5z1q |
| Add a core type | packages/core/src/types/ | sf show el-6c3s |
| Work with dependencies | packages/quarry/src/services/dependency.ts | sf show el-200z |
| Add an orchestrator service | packages/smithy/src/services/ | sf show el-50ia |
| Use the CLI | packages/quarry/src/cli/commands/ | sf show el-59tr |
| Use the QuarryAPI | packages/quarry/src/api/quarry-api.ts | sf show el-kflh |
| Use the OrchestratorAPI | packages/smithy/src/api/orchestrator-api.ts | sf show el-3qg2 |
| Customize agent prompts | .stoneforge/prompts/ | sf show el-32rb |
| Configure identity | packages/quarry/src/systems/identity.ts | sf show el-2jw5 |
| Understand event sourcing | packages/core/src/types/event.ts | sf show el-58k3 |
| Configure the system | packages/quarry/src/config/ | sf show el-z1sj |
Frontend Tasks
| I need... | Key Files | Reference Doc |
| Modify a smithy-web page | apps/smithy-web/src/routes/{page}/ | sf show el-4b3q |
| Modify a quarry-web page | apps/quarry-web/src/routes/{page}/ | sf show el-4iiz |
| Add a new frontend route | apps/{app}/src/router.tsx | sf show el-232d |
| Modify shared UI components | packages/ui/src/ | sf show el-2hk5 |
| Add a React component | apps/{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 blockedstatus 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 modeCLI 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 statsRunning 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:
blockedis computed - Never setstatus: 'blocked'directly; it's derived from dependenciesblocksdirection -sf dependency add --type=blocks A Bmeans A is blocked BY B (B completes first)- Messages need
contentRef-sendDirectMessage()requires aDocumentId, not raw text sortByEffectivePriority()mutates - Returns same array reference, modifies in place- SQLite is cache - JSONL is the source of truth; SQLite can be rebuilt
- No auto cycle detection -
api.addDependency()doesn't check cycles; useDependencyService.detectCycle() - FTS not indexed on import - After
sf import, runsf document reindexto rebuild search index relates-tois bidirectional - Query both directions:getDependencies()ANDgetDependents()- Closed/tombstone always wins - In merge conflicts, these statuses take precedence
- Server ports - Platform: 3456, Orchestrator: 3457 (not 3000)
Navigation Quick Reference
| I want to... | Key Files |
| Add a new core type | packages/core/src/types/ |
| Add an API endpoint | apps/quarry-server/src/index.ts |
| Add a React component | packages/ui/src/components/ |
| Work with dependencies | packages/quarry/src/services/dependency.ts |
| Understand task status | packages/core/src/types/task.ts |
| Configure identity/signing | packages/quarry/src/systems/identity.ts |
| Work with the Orchestrator API | packages/smithy/src/api/orchestrator-api.ts |
| Customize agent prompts | .stoneforge/prompts/ |
| Debug sync issues | packages/quarry/src/sync/service.ts |
| Add a CLI command | packages/quarry/src/cli/commands/ |
| Modify the Activity page | apps/smithy-web/src/routes/activity/, apps/smithy-web/src/components/activity/ |
| Modify the Agents page | apps/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 page | apps/quarry-web/src/routes/entities/ |
| Modify the Dependency Graph | apps/quarry-web/src/routes/dependency-graph/ |
| Modify the Workspaces page | apps/smithy-web/src/routes/workspaces/, apps/smithy-web/src/components/workspace/, apps/smithy-web/src/components/terminal/ |
| Modify the Editor | apps/smithy-web/src/routes/editor/, apps/smithy-web/src/components/editor/ |
| Modify the Messages page | apps/smithy-web/src/routes/messages/ or apps/quarry-web/src/routes/messages/ |
| Modify the Documents page | apps/smithy-web/src/routes/documents/ or apps/quarry-web/src/routes/documents/ |
| Modify the Merge Requests page | apps/smithy-web/src/routes/merge-requests/, apps/smithy-web/src/components/merge-request/ |
| Modify the Plans page | apps/smithy-web/src/routes/plans/ or apps/quarry-web/src/routes/plans/ |
| Modify the Workflows page | apps/smithy-web/src/routes/workflows/ or apps/quarry-web/src/routes/workflows/ |
| Modify the Settings page | apps/smithy-web/src/routes/settings/ or apps/quarry-web/src/routes/settings/ |
| Modify the Metrics page | apps/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.tsnext to*.ts - Integration tests use real SQLite (
:memory:or temp files) - Run
bun test <path>for specific tests - See
sf show el-50x1for test runner conventions (Bun vs Vitest)
Error Handling
- Use
StoneforgeErrorwith appropriateErrorCode - 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 fixesKey Services:
OrchestratorAPI- Agent registration and managementDispatchService- Task assignment with inbox notificationsSpawnerService- 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):
- Search for relevant docs:
sf document search "topic" - Update existing workspace documents:
sf document update <doc-id> --content "..." - Create new docs for undocumented knowledge:
sf document create --title "..." --content "..." --category reference --type markdown - Update the Documentation Directory (
sf show el-30yb) when you create or significantly modify documents - 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:
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
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.

