micode 0.3.1 → 0.3.3
This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
- package/README.md +69 -42
- package/dist/agents/artifact-searcher.d.ts +2 -0
- package/dist/agents/index.d.ts +3 -1
- package/dist/agents/ledger-creator.d.ts +2 -0
- package/dist/config-loader.d.ts +20 -0
- package/dist/hooks/artifact-auto-index.d.ts +9 -0
- package/dist/hooks/auto-clear-ledger.d.ts +11 -0
- package/dist/hooks/comment-checker.d.ts +1 -1
- package/dist/hooks/ledger-loader.d.ts +16 -0
- package/dist/index.js +915 -195
- package/dist/tools/artifact-index/index.d.ts +47 -0
- package/dist/tools/artifact-search.d.ts +18 -0
- package/package.json +9 -3
package/README.md
CHANGED
|
@@ -3,7 +3,7 @@
|
|
|
3
3
|
[](https://github.com/vtemian/micode/actions/workflows/ci.yml)
|
|
4
4
|
[](https://www.npmjs.com/package/micode)
|
|
5
5
|
|
|
6
|
-
OpenCode plugin with a structured Brainstorm → Plan → Implement workflow.
|
|
6
|
+
OpenCode plugin with a structured Brainstorm → Plan → Implement workflow and session continuity.
|
|
7
7
|
|
|
8
8
|
|
|
9
9
|
https://github.com/user-attachments/assets/85236ad3-e78a-4ff7-a840-620f6ea2f512
|
|
@@ -133,40 +133,53 @@ Each task gets its own implement→review loop:
|
|
|
133
133
|
3. If changes requested → re-spawn implementer (max 3 cycles)
|
|
134
134
|
4. Mark as DONE or BLOCKED
|
|
135
135
|
|
|
136
|
-
|
|
136
|
+
### 4. Session Continuity
|
|
137
|
+
|
|
138
|
+
Maintain context across long sessions and context clears with the ledger system:
|
|
139
|
+
|
|
140
|
+
#### Ledger System
|
|
141
|
+
|
|
142
|
+
The **continuity ledger** captures essential session state:
|
|
137
143
|
|
|
138
144
|
```
|
|
139
|
-
|
|
140
|
-
|
|
141
|
-
**Plan**: thoughts/shared/plans/2024-01-15-auth-feature.md
|
|
142
|
-
**Total tasks**: 6
|
|
143
|
-
**Batches**: 2
|
|
144
|
-
|
|
145
|
-
### Dependency Analysis
|
|
146
|
-
- Batch 1 (parallel): Tasks 1, 2, 3 - independent, no shared files
|
|
147
|
-
- Batch 2 (parallel): Tasks 4, 5, 6 - depend on batch 1
|
|
148
|
-
|
|
149
|
-
### Results
|
|
150
|
-
|
|
151
|
-
| Task | Status | Cycles | Notes |
|
|
152
|
-
|------|--------|--------|-------|
|
|
153
|
-
| 1 | ✅ DONE | 1 | |
|
|
154
|
-
| 2 | ✅ DONE | 2 | Fixed type error |
|
|
155
|
-
| 3 | ✅ DONE | 1 | |
|
|
156
|
-
| 4 | ✅ DONE | 1 | |
|
|
157
|
-
| 5 | ❌ BLOCKED | 3 | Test assertion failing |
|
|
158
|
-
| 6 | ✅ DONE | 1 | |
|
|
159
|
-
|
|
160
|
-
### Summary
|
|
161
|
-
- Completed: 5/6 tasks
|
|
162
|
-
- Blocked: 1 task needs human intervention
|
|
145
|
+
/ledger
|
|
163
146
|
```
|
|
164
147
|
|
|
165
|
-
|
|
148
|
+
Creates/updates `thoughts/ledgers/CONTINUITY_{session-name}.md` with:
|
|
149
|
+
- Goal and constraints
|
|
150
|
+
- Key decisions with rationale
|
|
151
|
+
- Current state (Done/Now/Next)
|
|
152
|
+
- Working set (branch, key files)
|
|
153
|
+
|
|
154
|
+
**Auto-injection:** When starting a session, the most recent ledger is automatically injected into the system prompt.
|
|
155
|
+
|
|
156
|
+
**Auto-clear:** At 80% context usage, the system automatically:
|
|
157
|
+
1. Updates the ledger
|
|
158
|
+
2. Creates a handoff document
|
|
159
|
+
3. Clears the session
|
|
160
|
+
4. Injects the ledger into the fresh context
|
|
161
|
+
|
|
162
|
+
#### Artifact Search
|
|
163
|
+
|
|
164
|
+
Search past work to find relevant precedent:
|
|
165
|
+
|
|
166
|
+
```
|
|
167
|
+
/search oauth authentication
|
|
168
|
+
/search JWT tokens
|
|
169
|
+
```
|
|
170
|
+
|
|
171
|
+
Searches across:
|
|
172
|
+
- Ledgers (`thoughts/ledgers/`)
|
|
173
|
+
- Handoffs (`thoughts/shared/handoffs/`)
|
|
174
|
+
- Plans (`thoughts/shared/plans/`)
|
|
175
|
+
|
|
176
|
+
**Auto-indexing:** Artifacts are automatically indexed when created.
|
|
177
|
+
|
|
178
|
+
#### Handoff
|
|
166
179
|
|
|
167
180
|
Save/resume session state for continuity:
|
|
168
181
|
|
|
169
|
-
- `handoff-creator`: Save current session
|
|
182
|
+
- `handoff-creator`: Save current session (reads ledger for context)
|
|
170
183
|
- `handoff-resumer`: Resume from handoff
|
|
171
184
|
- Output: `thoughts/shared/handoffs/`
|
|
172
185
|
|
|
@@ -175,6 +188,8 @@ Save/resume session state for continuity:
|
|
|
175
188
|
| Command | Description |
|
|
176
189
|
|---------|-------------|
|
|
177
190
|
| `/init` | Initialize project with ARCHITECTURE.md and CODE_STYLE.md |
|
|
191
|
+
| `/ledger` | Create or update continuity ledger for session state |
|
|
192
|
+
| `/search` | Search past handoffs, plans, and ledgers |
|
|
178
193
|
|
|
179
194
|
## Agents
|
|
180
195
|
|
|
@@ -183,15 +198,17 @@ Save/resume session state for continuity:
|
|
|
183
198
|
| Commander | primary | claude-opus-4-5 | Orchestrator, delegates to specialists |
|
|
184
199
|
| Brainstormer | primary | claude-opus-4-5 | Design exploration through questioning |
|
|
185
200
|
| project-initializer | subagent | claude-opus-4-5 | Generate ARCHITECTURE.md and CODE_STYLE.md |
|
|
186
|
-
| codebase-locator | subagent | - | Find file locations |
|
|
187
|
-
| codebase-analyzer | subagent | - | Deep code analysis |
|
|
188
|
-
| pattern-finder | subagent | - | Find existing patterns |
|
|
201
|
+
| codebase-locator | subagent | claude-sonnet | Find file locations |
|
|
202
|
+
| codebase-analyzer | subagent | claude-sonnet | Deep code analysis |
|
|
203
|
+
| pattern-finder | subagent | claude-sonnet | Find existing patterns |
|
|
189
204
|
| planner | subagent | claude-opus-4-5 | Create detailed implementation plans |
|
|
190
205
|
| executor | subagent | claude-opus-4-5 | Orchestrate implement → review cycle |
|
|
191
206
|
| implementer | subagent | claude-opus-4-5 | Execute implementation tasks |
|
|
192
207
|
| reviewer | subagent | claude-opus-4-5 | Review correctness and style |
|
|
193
|
-
|
|
|
194
|
-
|
|
|
208
|
+
| ledger-creator | subagent | claude-sonnet | Create/update continuity ledgers |
|
|
209
|
+
| artifact-searcher | subagent | claude-sonnet | Search past work for precedent |
|
|
210
|
+
| handoff-creator | subagent | claude-opus-4-5 | Save session state |
|
|
211
|
+
| handoff-resumer | subagent | claude-opus-4-5 | Resume from handoff |
|
|
195
212
|
|
|
196
213
|
## Tools
|
|
197
214
|
|
|
@@ -199,17 +216,22 @@ Save/resume session state for continuity:
|
|
|
199
216
|
|------|-------------|
|
|
200
217
|
| `ast_grep_search` | AST-aware code pattern search |
|
|
201
218
|
| `ast_grep_replace` | AST-aware code pattern replacement |
|
|
202
|
-
| `look_at` |
|
|
219
|
+
| `look_at` | Extract file structure for large files |
|
|
220
|
+
| `artifact_search` | Search past handoffs, plans, and ledgers |
|
|
203
221
|
| `background_task` | Run long-running tasks in background |
|
|
204
|
-
| `
|
|
222
|
+
| `background_output` | Check background task status/output |
|
|
223
|
+
| `background_cancel` | Cancel background tasks |
|
|
224
|
+
| `background_list` | List all background tasks |
|
|
205
225
|
|
|
206
226
|
## Hooks
|
|
207
227
|
|
|
208
228
|
| Hook | Description |
|
|
209
229
|
|------|-------------|
|
|
210
230
|
| Think Mode | Keywords like "think hard" enable 32k token thinking budget |
|
|
231
|
+
| Ledger Loader | Injects continuity ledger into system prompt |
|
|
232
|
+
| Auto-Clear Ledger | At 80% context, saves ledger + handoff and clears session |
|
|
233
|
+
| Artifact Auto-Index | Indexes artifacts when written to thoughts/ directories |
|
|
211
234
|
| Auto-Compact | Summarizes session when hitting token limits |
|
|
212
|
-
| Preemptive Compaction | Warns before context exhaustion |
|
|
213
235
|
| Context Injector | Injects ARCHITECTURE.md, CODE_STYLE.md, .cursorrules |
|
|
214
236
|
| Token-Aware Truncation | Truncates large tool outputs |
|
|
215
237
|
| Context Window Monitor | Tracks token usage |
|
|
@@ -234,9 +256,11 @@ This enables subagents to work autonomously without getting stuck on permission
|
|
|
234
256
|
|
|
235
257
|
## MCP Servers
|
|
236
258
|
|
|
237
|
-
| Server | Description |
|
|
238
|
-
|
|
239
|
-
| context7 | Documentation lookup |
|
|
259
|
+
| Server | Description | Activation |
|
|
260
|
+
|--------|-------------|------------|
|
|
261
|
+
| context7 | Documentation lookup | Always enabled |
|
|
262
|
+
| perplexity | Web search | Set `PERPLEXITY_API_KEY` |
|
|
263
|
+
| firecrawl | Web crawling | Set `FIRECRAWL_API_KEY` |
|
|
240
264
|
|
|
241
265
|
## Structure
|
|
242
266
|
|
|
@@ -244,14 +268,14 @@ This enables subagents to work autonomously without getting stuck on permission
|
|
|
244
268
|
micode/
|
|
245
269
|
├── src/
|
|
246
270
|
│ ├── agents/ # Agent definitions
|
|
247
|
-
│ ├── tools/ # ast-grep, look-at, background-task
|
|
271
|
+
│ ├── tools/ # ast-grep, look-at, artifact-search, background-task
|
|
248
272
|
│ ├── hooks/ # Session management hooks
|
|
249
273
|
│ └── index.ts # Plugin entry
|
|
250
274
|
├── dist/ # Built plugin
|
|
251
275
|
└── thoughts/ # Artifacts (gitignored)
|
|
276
|
+
├── ledgers/ # Continuity ledgers
|
|
252
277
|
└── shared/
|
|
253
278
|
├── designs/ # Brainstorm outputs
|
|
254
|
-
├── research/ # Research documents
|
|
255
279
|
├── plans/ # Implementation plans
|
|
256
280
|
└── handoffs/ # Session handoffs
|
|
257
281
|
```
|
|
@@ -270,7 +294,7 @@ bun run build
|
|
|
270
294
|
Then use local path in config:
|
|
271
295
|
```json
|
|
272
296
|
{
|
|
273
|
-
"plugin": ["~/.micode
|
|
297
|
+
"plugin": ["~/.micode"]
|
|
274
298
|
}
|
|
275
299
|
```
|
|
276
300
|
|
|
@@ -280,6 +304,8 @@ Then use local path in config:
|
|
|
280
304
|
bun install # Install dependencies
|
|
281
305
|
bun run build # Build plugin
|
|
282
306
|
bun run typecheck # Type check
|
|
307
|
+
bun test # Run tests
|
|
308
|
+
bun test --watch # Run tests in watch mode
|
|
283
309
|
```
|
|
284
310
|
|
|
285
311
|
### Release
|
|
@@ -307,6 +333,7 @@ npm publish
|
|
|
307
333
|
4. **Parallel investigation** - Spawn multiple subagents for speed
|
|
308
334
|
5. **Isolated implementation** - Use git worktrees for features
|
|
309
335
|
6. **Continuous verification** - Implementer + Reviewer per phase
|
|
336
|
+
7. **Session continuity** - Never lose context across clears
|
|
310
337
|
|
|
311
338
|
## Inspiration
|
|
312
339
|
|
package/dist/agents/index.d.ts
CHANGED
|
@@ -11,5 +11,7 @@ import { handoffCreatorAgent } from "./handoff-creator";
|
|
|
11
11
|
import { handoffResumerAgent } from "./handoff-resumer";
|
|
12
12
|
import { primaryAgent, PRIMARY_AGENT_NAME } from "./commander";
|
|
13
13
|
import { projectInitializerAgent } from "./project-initializer";
|
|
14
|
+
import { ledgerCreatorAgent } from "./ledger-creator";
|
|
15
|
+
import { artifactSearcherAgent } from "./artifact-searcher";
|
|
14
16
|
export declare const agents: Record<string, AgentConfig>;
|
|
15
|
-
export { primaryAgent, PRIMARY_AGENT_NAME, brainstormerAgent, codebaseLocatorAgent, codebaseAnalyzerAgent, patternFinderAgent, plannerAgent, implementerAgent, reviewerAgent, executorAgent, handoffCreatorAgent, handoffResumerAgent, projectInitializerAgent, };
|
|
17
|
+
export { primaryAgent, PRIMARY_AGENT_NAME, brainstormerAgent, codebaseLocatorAgent, codebaseAnalyzerAgent, patternFinderAgent, plannerAgent, implementerAgent, reviewerAgent, executorAgent, handoffCreatorAgent, handoffResumerAgent, projectInitializerAgent, ledgerCreatorAgent, artifactSearcherAgent, };
|
|
@@ -0,0 +1,20 @@
|
|
|
1
|
+
import type { AgentConfig } from "@opencode-ai/sdk";
|
|
2
|
+
export interface AgentOverride {
|
|
3
|
+
model?: string;
|
|
4
|
+
temperature?: number;
|
|
5
|
+
maxTokens?: number;
|
|
6
|
+
}
|
|
7
|
+
export interface MicodeConfig {
|
|
8
|
+
agents?: Record<string, AgentOverride>;
|
|
9
|
+
}
|
|
10
|
+
/**
|
|
11
|
+
* Load micode.json from ~/.config/opencode/micode.json
|
|
12
|
+
* Returns null if file doesn't exist or is invalid JSON
|
|
13
|
+
* @param configDir - Optional override for config directory (for testing)
|
|
14
|
+
*/
|
|
15
|
+
export declare function loadMicodeConfig(configDir?: string): Promise<MicodeConfig | null>;
|
|
16
|
+
/**
|
|
17
|
+
* Merge user config overrides into plugin agent configs
|
|
18
|
+
* User overrides take precedence for safe properties only
|
|
19
|
+
*/
|
|
20
|
+
export declare function mergeAgentConfigs(pluginAgents: Record<string, AgentConfig>, userConfig: MicodeConfig | null): Record<string, AgentConfig>;
|
|
@@ -0,0 +1,9 @@
|
|
|
1
|
+
import type { PluginInput } from "@opencode-ai/plugin";
|
|
2
|
+
export declare function createArtifactAutoIndexHook(_ctx: PluginInput): {
|
|
3
|
+
"tool.execute.after": (input: {
|
|
4
|
+
tool: string;
|
|
5
|
+
args?: Record<string, unknown>;
|
|
6
|
+
}, _output: {
|
|
7
|
+
output?: string;
|
|
8
|
+
}) => Promise<void>;
|
|
9
|
+
};
|
|
@@ -0,0 +1,11 @@
|
|
|
1
|
+
import type { PluginInput } from "@opencode-ai/plugin";
|
|
2
|
+
export declare const DEFAULT_THRESHOLD = 0.8;
|
|
3
|
+
export declare const CLEAR_COOLDOWN_MS = 60000;
|
|
4
|
+
export declare function createAutoClearLedgerHook(ctx: PluginInput): {
|
|
5
|
+
event: ({ event }: {
|
|
6
|
+
event: {
|
|
7
|
+
type: string;
|
|
8
|
+
properties?: unknown;
|
|
9
|
+
};
|
|
10
|
+
}) => Promise<void>;
|
|
11
|
+
};
|
|
@@ -1,5 +1,5 @@
|
|
|
1
1
|
import type { PluginInput } from "@opencode-ai/plugin";
|
|
2
|
-
export declare function createCommentCheckerHook(
|
|
2
|
+
export declare function createCommentCheckerHook(_ctx: PluginInput): {
|
|
3
3
|
"tool.execute.after": (input: {
|
|
4
4
|
tool: string;
|
|
5
5
|
args?: Record<string, unknown>;
|
|
@@ -0,0 +1,16 @@
|
|
|
1
|
+
import type { PluginInput } from "@opencode-ai/plugin";
|
|
2
|
+
export interface LedgerInfo {
|
|
3
|
+
sessionName: string;
|
|
4
|
+
filePath: string;
|
|
5
|
+
content: string;
|
|
6
|
+
}
|
|
7
|
+
export declare function findCurrentLedger(directory: string): Promise<LedgerInfo | null>;
|
|
8
|
+
export declare function formatLedgerInjection(ledger: LedgerInfo): string;
|
|
9
|
+
export declare function createLedgerLoaderHook(ctx: PluginInput): {
|
|
10
|
+
"chat.params": (_input: {
|
|
11
|
+
sessionID: string;
|
|
12
|
+
}, output: {
|
|
13
|
+
options?: Record<string, unknown>;
|
|
14
|
+
system?: string;
|
|
15
|
+
}) => Promise<void>;
|
|
16
|
+
};
|