Skip to content
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
Show all changes
17 commits
Select commit Hold shift + click to select a range
7b4e0db
refactor(agents): remove handoff agent files and exports
vtemian Dec 30, 2025
a90416c
refactor(commander): remove handoff agent references from prompt
vtemian Dec 30, 2025
1b3a6e5
refactor(auto-clear-ledger): remove handoff-creator spawn
vtemian Dec 30, 2025
55a605e
refactor(artifact-auto-index): remove handoff pattern and parsing
vtemian Dec 30, 2025
d8f16e8
refactor(schema): remove handoff tables, add file ops columns to ledgers
vtemian Dec 30, 2025
6b6831f
refactor(artifact-index): remove handoff indexing, add file ops to le…
vtemian Dec 30, 2025
8633b83
refactor(artifact-search): remove handoff from type enum
vtemian Dec 30, 2025
f68fc0e
test(artifact-index): remove handoff test, add file ops test
vtemian Dec 30, 2025
b9e9a95
docs: remove handoff references from README
vtemian Dec 30, 2025
b62447b
feat(file-ops-tracker): add hook to track file read/write/edit operat…
vtemian Dec 30, 2025
86bbba6
feat(index): register file-ops-tracker hook
vtemian Dec 30, 2025
bed1a64
feat(ledger-creator): update prompt for iterative updates and file ops
vtemian Dec 30, 2025
813b763
feat(auto-clear-ledger): pass file ops and previous ledger to ledger-…
vtemian Dec 30, 2025
6be2e08
feat(artifact-auto-index): parse file operations from new ledger format
vtemian Dec 30, 2025
e7ae087
fix: prevent file ops loss on session creation failure
vtemian Dec 30, 2025
5e7f953
fix: only clear file ops when ledger-creator successfully completes
vtemian Dec 30, 2025
af987ac
docs: update README with structured compaction features
vtemian Dec 30, 2025
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
68 changes: 42 additions & 26 deletions README.md
Original file line number Diff line number Diff line change
Expand Up @@ -135,29 +135,55 @@ Each task gets its own implement→review loop:

### 4. Session Continuity

Maintain context across long sessions and context clears with the ledger system:
Maintain context across long sessions and context clears with structured compaction:

#### Ledger System

The **continuity ledger** captures essential session state:
The **continuity ledger** serves as both session state and compaction summary. Based on [Factory.ai's structured compaction research](https://factory.ai/blog/context-compression), which found that structured summarization with deterministic file tracking retains more useful context.

```
/ledger
```

Creates/updates `thoughts/ledgers/CONTINUITY_{session-name}.md` with:
- Goal and constraints
- Key decisions with rationale
- Current state (Done/Now/Next)
- Working set (branch, key files)

**Auto-injection:** When starting a session, the most recent ledger is automatically injected into the system prompt.
```markdown
# Session: {name}
Updated: {timestamp}

## Goal
## Constraints
## Progress
### Done
- [x] {Completed items}
### In Progress
- [ ] {Current work}
### Blocked
- {Issues, if any}
## Key Decisions
- **{Decision}**: {Rationale}
## Next Steps
1. {Ordered list}
## File Operations
### Read
- `{paths read since last compaction}`
### Modified
- `{paths written/edited since last compaction}`
## Critical Context
- {Data, examples, references needed to continue}
```

**Key features:**

- **Iterative merging** - Updates preserve existing information, adding new progress rather than regenerating from scratch
- **Deterministic file tracking** - Read/write/edit operations tracked automatically via tool call interception, not LLM extraction
- **Auto-injection** - Most recent ledger injected into system prompt on session start

**Auto-clear:** At 80% context usage, the system automatically:
1. Updates the ledger
2. Creates a handoff document
1. Captures file operations tracked since last clear
2. Updates ledger with current state (iterative merge with previous)
3. Clears the session
4. Injects the ledger into the fresh context
4. Injects the updated ledger into fresh context

#### Artifact Search

Expand All @@ -170,26 +196,17 @@ Search past work to find relevant precedent:

Searches across:
- Ledgers (`thoughts/ledgers/`)
- Handoffs (`thoughts/shared/handoffs/`)
- Plans (`thoughts/shared/plans/`)

**Auto-indexing:** Artifacts are automatically indexed when created.

#### Handoff

Save/resume session state for continuity:

- `handoff-creator`: Save current session (reads ledger for context)
- `handoff-resumer`: Resume from handoff
- Output: `thoughts/shared/handoffs/`

## Commands

| Command | Description |
|---------|-------------|
| `/init` | Initialize project with ARCHITECTURE.md and CODE_STYLE.md |
| `/ledger` | Create or update continuity ledger for session state |
| `/search` | Search past handoffs, plans, and ledgers |
| `/search` | Search past plans and ledgers |

## Agents

Expand All @@ -207,8 +224,6 @@ Save/resume session state for continuity:
| reviewer | subagent | claude-opus-4-5 | Review correctness and style |
| ledger-creator | subagent | claude-sonnet | Create/update continuity ledgers |
| artifact-searcher | subagent | claude-sonnet | Search past work for precedent |
| handoff-creator | subagent | claude-opus-4-5 | Save session state |
| handoff-resumer | subagent | claude-opus-4-5 | Resume from handoff |

## Tools

Expand All @@ -217,7 +232,7 @@ Save/resume session state for continuity:
| `ast_grep_search` | AST-aware code pattern search |
| `ast_grep_replace` | AST-aware code pattern replacement |
| `look_at` | Extract file structure for large files |
| `artifact_search` | Search past handoffs, plans, and ledgers |
| `artifact_search` | Search past plans and ledgers |
| `background_task` | Run long-running tasks in background |
| `background_output` | Check background task status/output |
| `background_cancel` | Cancel background tasks |
Expand All @@ -229,7 +244,8 @@ Save/resume session state for continuity:
|------|-------------|
| Think Mode | Keywords like "think hard" enable 32k token thinking budget |
| Ledger Loader | Injects continuity ledger into system prompt |
| Auto-Clear Ledger | At 80% context, saves ledger + handoff and clears session |
| Auto-Clear Ledger | At 80% context, saves ledger with file ops and clears session |
| File Ops Tracker | Tracks read/write/edit tool calls for deterministic file operation logging |
| Artifact Auto-Index | Indexes artifacts when written to thoughts/ directories |
| Auto-Compact | Summarizes session when hitting token limits |
| Context Injector | Injects ARCHITECTURE.md, CODE_STYLE.md, .cursorrules |
Expand Down Expand Up @@ -276,8 +292,7 @@ micode/
├── ledgers/ # Continuity ledgers
└── shared/
├── designs/ # Brainstorm outputs
├── plans/ # Implementation plans
└── handoffs/ # Session handoffs
└── plans/ # Implementation plans
```

## Development
Expand Down Expand Up @@ -341,3 +356,4 @@ Built on techniques from:

- **[oh-my-opencode](https://github.com/code-yeongyu/oh-my-opencode)** - OpenCode plugin architecture, agent orchestration patterns, and trusted publishing setup
- **[HumanLayer ACE-FCA](https://github.com/humanlayer/12-factor-agents)** - Advanced Context Engineering for Coding Agents, structured workflows, and the research → plan → implement methodology
- **[Factory.ai Context Compression](https://factory.ai/blog/context-compression)** - Structured compaction research showing that anchored iterative summarization with deterministic file tracking outperforms generic compression
9 changes: 4 additions & 5 deletions src/agents/commander.ts
Original file line number Diff line number Diff line change
Expand Up @@ -76,9 +76,9 @@ Just do it - including obvious follow-up actions.
<rule>Reference plan file in commit body</rule>
</phase>

<phase name="handoff">
<agent name="handoff-creator">Save session state</agent>
<agent name="handoff-resumer">Resume from handoff</agent>
<phase name="ledger" trigger="context getting full or session ending">
<action>System auto-updates ledger at 80% context usage</action>
<output>thoughts/ledgers/CONTINUITY_{session-name}.md</output>
</phase>
</workflow>

Expand All @@ -89,8 +89,7 @@ Just do it - including obvious follow-up actions.
<agent name="pattern-finder" mode="subagent" purpose="Find existing patterns"/>
<agent name="planner" mode="subagent" purpose="Create detailed implementation plans"/>
<agent name="executor" mode="subagent" purpose="Execute plan (runs implementer then reviewer automatically)"/>
<agent name="handoff-creator" mode="subagent" purpose="Create handoff docs"/>
<agent name="handoff-resumer" mode="subagent" purpose="Resume from handoffs"/>
<agent name="ledger-creator" mode="subagent" purpose="Create/update continuity ledgers"/>
<parallelization>
<safe>locator, analyzer, pattern-finder</safe>
<sequential>planner then executor</sequential>
Expand Down
73 changes: 0 additions & 73 deletions src/agents/handoff-creator.ts

This file was deleted.

80 changes: 0 additions & 80 deletions src/agents/handoff-resumer.ts

This file was deleted.

6 changes: 0 additions & 6 deletions src/agents/index.ts
Original file line number Diff line number Diff line change
Expand Up @@ -7,8 +7,6 @@ import { plannerAgent } from "./planner";
import { implementerAgent } from "./implementer";
import { reviewerAgent } from "./reviewer";
import { executorAgent } from "./executor";
import { handoffCreatorAgent } from "./handoff-creator";
import { handoffResumerAgent } from "./handoff-resumer";
import { primaryAgent, PRIMARY_AGENT_NAME } from "./commander";
import { projectInitializerAgent } from "./project-initializer";
import { ledgerCreatorAgent } from "./ledger-creator";
Expand All @@ -24,8 +22,6 @@ export const agents: Record<string, AgentConfig> = {
implementer: implementerAgent,
reviewer: reviewerAgent,
executor: executorAgent,
"handoff-creator": handoffCreatorAgent,
"handoff-resumer": handoffResumerAgent,
"project-initializer": projectInitializerAgent,
"ledger-creator": ledgerCreatorAgent,
"artifact-searcher": artifactSearcherAgent,
Expand All @@ -42,8 +38,6 @@ export {
implementerAgent,
reviewerAgent,
executorAgent,
handoffCreatorAgent,
handoffResumerAgent,
projectInitializerAgent,
ledgerCreatorAgent,
artifactSearcherAgent,
Expand Down
Loading