micode 0.5.2 → 0.7.0

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 CHANGED
@@ -3,33 +3,19 @@
3
3
  [![CI](https://github.com/vtemian/micode/actions/workflows/ci.yml/badge.svg)](https://github.com/vtemian/micode/actions/workflows/ci.yml)
4
4
  [![npm version](https://badge.fury.io/js/micode.svg)](https://www.npmjs.com/package/micode)
5
5
 
6
- OpenCode plugin with a structured Brainstorm → Plan → Implement workflow and session continuity.
7
-
6
+ OpenCode plugin with structured Brainstorm → Plan → Implement workflow and session continuity.
8
7
 
9
8
  https://github.com/user-attachments/assets/85236ad3-e78a-4ff7-a840-620f6ea2f512
10
9
 
11
-
12
- ## Installation
10
+ ## Quick Start
13
11
 
14
12
  Add to `~/.config/opencode/opencode.json`:
15
13
 
16
14
  ```json
17
- {
18
- "plugin": ["micode"]
19
- }
20
- ```
21
-
22
- **AI-assisted install:** Share [INSTALL_CLAUDE.md](./INSTALL_CLAUDE.md) with your AI assistant for guided setup.
23
-
24
- ## Getting Started
25
-
26
- **Important:** Run `/init` first to generate project documentation:
27
-
28
- ```
29
- /init
15
+ { "plugin": ["micode"] }
30
16
  ```
31
17
 
32
- This creates `ARCHITECTURE.md` and `CODE_STYLE.md` which agents reference during brainstorming, planning, and implementation. Without these files, agents lack context about your codebase patterns.
18
+ Then run `/init` to generate `ARCHITECTURE.md` and `CODE_STYLE.md`.
33
19
 
34
20
  ## Workflow
35
21
 
@@ -39,191 +25,42 @@ Brainstorm → Plan → Implement
39
25
  research research executor
40
26
  ```
41
27
 
42
- Research subagents (codebase-locator, codebase-analyzer, pattern-finder) are spawned within brainstorm and plan phases - not as a separate step.
43
-
44
- ### 1. Brainstorm
45
-
46
- Refine rough ideas into fully-formed designs through collaborative questioning.
47
-
48
- - One question at a time
49
- - 2-3 approaches with trade-offs
50
- - Section-by-section validation
51
- - Spawns research subagents to understand codebase
52
- - Output: `thoughts/shared/designs/YYYY-MM-DD-{topic}-design.md`
53
-
54
- **Research subagents** (spawned in parallel):
55
-
56
- | Subagent | Purpose |
57
- |----------|---------|
58
- | `codebase-locator` | Find WHERE files live (paths, no content) |
59
- | `codebase-analyzer` | Explain HOW code works (with file:line refs) |
60
- | `pattern-finder` | Find existing patterns to follow |
61
-
62
- ### 2. Plan
63
-
64
- Transform validated designs into comprehensive implementation plans.
65
-
66
- - Spawns research subagents for exact paths, signatures, patterns
67
- - Bite-sized tasks (2-5 minutes each)
68
- - Exact file paths, complete code examples
69
- - TDD workflow: failing test → verify fail → implement → verify pass → commit
70
- - Get human approval before implementing
71
- - Output: `thoughts/shared/plans/YYYY-MM-DD-{topic}.md`
72
-
73
- ### 3. Implement
74
-
75
- Execute plan in git worktree for isolation:
76
-
77
- ```bash
78
- git worktree add ../{feature} -b feature/{feature}
79
- ```
80
-
81
- The **Executor** orchestrates task execution with intelligent parallelization:
82
-
83
- #### How It Works
84
-
85
- 1. **Parse** - Extract individual tasks from the plan
86
- 2. **Analyze** - Build dependency graph between tasks
87
- 3. **Batch** - Group independent tasks for parallel execution
88
- 4. **Execute** - Run implementer→reviewer cycle per task
89
- 5. **Aggregate** - Collect results and report status
90
-
91
- #### Dependency Analysis
92
-
93
- Tasks are grouped into batches based on their dependencies:
94
-
95
- ```
96
- Independent tasks (can parallelize):
97
- - Modify different files
98
- - Don't depend on each other's output
99
- - Don't share state
100
-
101
- Dependent tasks (must be sequential):
102
- - Task B modifies a file Task A creates
103
- - Task B imports something Task A defines
104
- - Task B's test relies on Task A's implementation
105
- ```
106
-
107
- #### Parallel Execution
108
-
109
- Within a batch, all tasks run concurrently by spawning multiple subagents in a single message:
110
-
111
- ```
112
- Plan with 6 tasks:
113
- ├── Batch 1 (parallel): Tasks 1, 2, 3 → independent, different files
114
- │ ├── implementer: task 1 ─┐
115
- │ ├── implementer: task 2 ─┼─ spawn in ONE message
116
- │ └── implementer: task 3 ─┘
117
- │ [wait for all]
118
- │ ├── reviewer: task 1 ─┐
119
- │ ├── reviewer: task 2 ─┼─ spawn in ONE message
120
- │ └── reviewer: task 3 ─┘
121
- │ [wait for all]
122
-
123
- └── Batch 2 (parallel): Tasks 4, 5, 6 → depend on batch 1
124
- └── [same pattern]
125
- ```
126
-
127
- #### Per-Task Cycle
128
-
129
- Each task gets its own implement→review loop:
130
-
131
- 1. Spawn implementer with task details
132
- 2. Spawn reviewer to check implementation
133
- 3. If changes requested → re-spawn implementer (max 3 cycles)
134
- 4. Mark as DONE or BLOCKED
28
+ ### Brainstorm
29
+ Refine ideas into designs through collaborative questioning. Fires research subagents in parallel. Output: `thoughts/shared/designs/YYYY-MM-DD-{topic}-design.md`
135
30
 
136
- ### 4. Session Continuity
31
+ ### Plan
32
+ Transform designs into implementation plans with bite-sized tasks (2-5 min each), exact file paths, and TDD workflow. Output: `thoughts/shared/plans/YYYY-MM-DD-{topic}.md`
137
33
 
138
- Maintain context across long sessions and context clears with structured compaction:
34
+ ### Implement
35
+ Execute in git worktree for isolation. The **Executor** orchestrates implementer→reviewer cycles with parallel execution via fire-and-check pattern.
139
36
 
140
- #### Ledger System
141
-
142
- 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.
143
-
144
- ```
145
- /ledger
146
- ```
147
-
148
- Creates/updates `thoughts/ledgers/CONTINUITY_{session-name}.md` with:
149
-
150
- ```markdown
151
- # Session: {name}
152
- Updated: {timestamp}
153
-
154
- ## Goal
155
- ## Constraints
156
- ## Progress
157
- ### Done
158
- - [x] {Completed items}
159
- ### In Progress
160
- - [ ] {Current work}
161
- ### Blocked
162
- - {Issues, if any}
163
- ## Key Decisions
164
- - **{Decision}**: {Rationale}
165
- ## Next Steps
166
- 1. {Ordered list}
167
- ## File Operations
168
- ### Read
169
- - `{paths read since last compaction}`
170
- ### Modified
171
- - `{paths written/edited since last compaction}`
172
- ## Critical Context
173
- - {Data, examples, references needed to continue}
174
- ```
175
-
176
- **Key features:**
177
-
178
- - **Iterative merging** - Updates preserve existing information, adding new progress rather than regenerating from scratch
179
- - **Deterministic file tracking** - Read/write/edit operations tracked automatically via tool call interception, not LLM extraction
180
- - **Auto-injection** - Most recent ledger injected into system prompt on session start
181
-
182
- **Auto-clear:** At 80% context usage, the system automatically:
183
- 1. Captures file operations tracked since last clear
184
- 2. Updates ledger with current state (iterative merge with previous)
185
- 3. Clears the session
186
- 4. Injects the updated ledger into fresh context
187
-
188
- #### Artifact Search
189
-
190
- Search past work to find relevant precedent:
191
-
192
- ```
193
- /search oauth authentication
194
- /search JWT tokens
195
- ```
196
-
197
- Searches across:
198
- - Ledgers (`thoughts/ledgers/`)
199
- - Plans (`thoughts/shared/plans/`)
200
-
201
- **Auto-indexing:** Artifacts are automatically indexed when created.
37
+ ### Session Continuity
38
+ Maintain context across sessions with structured compaction. Run `/ledger` to create/update `thoughts/ledgers/CONTINUITY_{session}.md`. Auto-clears at 60% context usage.
202
39
 
203
40
  ## Commands
204
41
 
205
42
  | Command | Description |
206
43
  |---------|-------------|
207
- | `/init` | Initialize project with ARCHITECTURE.md and CODE_STYLE.md |
208
- | `/ledger` | Create or update continuity ledger for session state |
44
+ | `/init` | Initialize project docs |
45
+ | `/ledger` | Create/update continuity ledger |
209
46
  | `/search` | Search past plans and ledgers |
210
47
 
211
48
  ## Agents
212
49
 
213
- | Agent | Mode | Model | Purpose |
214
- |-------|------|-------|---------|
215
- | commander | primary | claude-opus-4-5 | Orchestrator, delegates to specialists |
216
- | brainstormer | primary | claude-opus-4-5 | Design exploration through questioning |
217
- | project-initializer | subagent | claude-opus-4-5 | Generate ARCHITECTURE.md and CODE_STYLE.md |
218
- | codebase-locator | subagent | claude-sonnet | Find file locations |
219
- | codebase-analyzer | subagent | claude-sonnet | Deep code analysis |
220
- | pattern-finder | subagent | claude-sonnet | Find existing patterns |
221
- | planner | subagent | claude-opus-4-5 | Create detailed implementation plans |
222
- | executor | subagent | claude-opus-4-5 | Orchestrate implement review cycle |
223
- | implementer | subagent | claude-opus-4-5 | Execute implementation tasks |
224
- | reviewer | subagent | claude-opus-4-5 | Review correctness and style |
225
- | ledger-creator | subagent | claude-sonnet | Create/update continuity ledgers |
226
- | artifact-searcher | subagent | claude-sonnet | Search past work for precedent |
50
+ | Agent | Purpose |
51
+ |-------|---------|
52
+ | commander | Orchestrator |
53
+ | brainstormer | Design exploration |
54
+ | planner | Implementation plans |
55
+ | executor | Orchestrate implement→review |
56
+ | implementer | Execute tasks |
57
+ | reviewer | Check correctness |
58
+ | codebase-locator | Find file locations |
59
+ | codebase-analyzer | Deep code analysis |
60
+ | pattern-finder | Find existing patterns |
61
+ | project-initializer | Generate project docs |
62
+ | ledger-creator | Continuity ledgers |
63
+ | artifact-searcher | Search past work |
227
64
 
228
65
  ## Tools
229
66
 
@@ -231,129 +68,67 @@ Searches across:
231
68
  |------|-------------|
232
69
  | `ast_grep_search` | AST-aware code pattern search |
233
70
  | `ast_grep_replace` | AST-aware code pattern replacement |
234
- | `look_at` | Extract file structure for large files |
235
- | `artifact_search` | Search past plans and ledgers |
236
- | `background_task` | Run long-running tasks in background |
237
- | `background_output` | Check background task status/output |
238
- | `background_cancel` | Cancel background tasks |
239
- | `background_list` | List all background tasks |
71
+ | `look_at` | Extract file structure |
72
+ | `artifact_search` | Search past plans/ledgers |
73
+ | `btca_ask` | Query library source code |
74
+ | `background_task` | Fire subagent in background |
75
+ | `background_list` | List tasks and status |
76
+ | `background_output` | Get task results |
77
+ | `background_cancel` | Cancel task(s) |
78
+ | `pty_spawn` | Start background terminal session |
79
+ | `pty_write` | Send input to PTY |
80
+ | `pty_read` | Read PTY output |
81
+ | `pty_list` | List PTY sessions |
82
+ | `pty_kill` | Terminate PTY |
83
+
84
+ ### Background Tasks vs PTY
85
+
86
+ | System | Purpose | Use Case |
87
+ |--------|---------|----------|
88
+ | `background_task` | Async AI subagents | Research, implementation, reviews |
89
+ | `pty_spawn` | Async bash processes | Dev servers, watch modes, REPLs |
240
90
 
241
91
  ## Hooks
242
92
 
243
- | Hook | Description |
244
- |------|-------------|
245
- | Think Mode | Keywords like "think hard" enable 32k token thinking budget |
246
- | Ledger Loader | Injects continuity ledger into system prompt |
247
- | Auto-Clear Ledger | At 80% context, saves ledger with file ops and clears session |
248
- | File Ops Tracker | Tracks read/write/edit tool calls for deterministic file operation logging |
249
- | Artifact Auto-Index | Indexes artifacts when written to thoughts/ directories |
250
- | Auto-Compact | Summarizes session when hitting token limits |
251
- | Context Injector | Injects ARCHITECTURE.md, CODE_STYLE.md, .cursorrules |
252
- | Token-Aware Truncation | Truncates large tool outputs |
253
- | Context Window Monitor | Tracks token usage |
254
- | Comment Checker | Validates edit tool comments |
255
- | Session Recovery | Recovers from crashes |
256
-
257
- ## Permissions
258
-
259
- All permissions are set to `allow` globally - no prompts for tool usage:
260
-
261
- ```typescript
262
- config.permission = {
263
- edit: "allow",
264
- bash: "allow",
265
- webfetch: "allow",
266
- doom_loop: "allow",
267
- external_directory: "allow",
268
- };
269
- ```
270
-
271
- This enables subagents to work autonomously without getting stuck on permission prompts.
272
-
273
- ## MCP Servers
274
-
275
- | Server | Description | Activation |
276
- |--------|-------------|------------|
277
- | context7 | Documentation lookup | Always enabled |
278
- | perplexity | Web search | Set `PERPLEXITY_API_KEY` |
279
- | firecrawl | Web crawling | Set `FIRECRAWL_API_KEY` |
280
-
281
- ## Structure
282
-
283
- ```
284
- micode/
285
- ├── src/
286
- │ ├── agents/ # Agent definitions
287
- │ ├── tools/ # ast-grep, look-at, artifact-search, background-task
288
- │ ├── hooks/ # Session management hooks
289
- │ └── index.ts # Plugin entry
290
- ├── dist/ # Built plugin
291
- └── thoughts/ # Artifacts (gitignored)
292
- ├── ledgers/ # Continuity ledgers
293
- └── shared/
294
- ├── designs/ # Brainstorm outputs
295
- └── plans/ # Implementation plans
296
- ```
93
+ - **Think Mode** - Keywords like "think hard" enable 32k token thinking budget
94
+ - **Ledger Loader** - Injects continuity ledger into system prompt
95
+ - **Auto-Clear Ledger** - At 60% context, saves ledger and clears session
96
+ - **File Ops Tracker** - Tracks read/write/edit for deterministic logging
97
+ - **Artifact Auto-Index** - Indexes artifacts in thoughts/ directories
98
+ - **Context Injector** - Injects ARCHITECTURE.md, CODE_STYLE.md
99
+ - **Token-Aware Truncation** - Truncates large tool outputs
297
100
 
298
101
  ## Development
299
102
 
300
- ### From source
301
-
302
103
  ```bash
303
104
  git clone git@github.com:vtemian/micode.git ~/.micode
304
- cd ~/.micode
305
- bun install
306
- bun run build
105
+ cd ~/.micode && bun install && bun run build
307
106
  ```
308
107
 
309
- Then use local path in config:
310
108
  ```json
311
- {
312
- "plugin": ["~/.micode"]
313
- }
314
- ```
315
-
316
- ### Commands
317
-
318
- ```bash
319
- bun install # Install dependencies
320
- bun run build # Build plugin
321
- bun run typecheck # Type check
322
- bun test # Run tests
323
- bun test --watch # Run tests in watch mode
109
+ // Use local path
110
+ { "plugin": ["~/.micode"] }
324
111
  ```
325
112
 
326
113
  ### Release
327
114
 
328
- Releases are automated via GitHub Actions. To publish a new version:
329
-
330
115
  ```bash
331
116
  npm version patch # or minor, major
332
117
  git push --follow-tags
333
118
  ```
334
119
 
335
- This triggers the release workflow which publishes to npm.
336
-
337
- **Manual publish** (first time or if needed):
338
- ```bash
339
- npm login
340
- npm publish
341
- ```
342
-
343
120
  ## Philosophy
344
121
 
345
122
  1. **Brainstorm first** - Refine ideas before coding
346
123
  2. **Research before implementing** - Understand the codebase
347
124
  3. **Plan with human buy-in** - Get approval before coding
348
- 4. **Parallel investigation** - Spawn multiple subagents for speed
349
- 5. **Isolated implementation** - Use git worktrees for features
350
- 6. **Continuous verification** - Implementer + Reviewer per phase
351
- 7. **Session continuity** - Never lose context across clears
125
+ 4. **Parallel investigation** - Spawn multiple subagents
126
+ 5. **Isolated implementation** - Use git worktrees
127
+ 6. **Continuous verification** - Implementer + Reviewer per task
128
+ 7. **Session continuity** - Never lose context
352
129
 
353
130
  ## Inspiration
354
131
 
355
- Built on techniques from:
356
-
357
- - **[oh-my-opencode](https://github.com/code-yeongyu/oh-my-opencode)** - OpenCode plugin architecture, agent orchestration patterns, and trusted publishing setup
358
- - **[HumanLayer ACE-FCA](https://github.com/humanlayer/12-factor-agents)** - Advanced Context Engineering for Coding Agents, structured workflows, and the research → plan → implement methodology
359
- - **[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
132
+ - [oh-my-opencode](https://github.com/code-yeongyu/oh-my-opencode) - Plugin architecture
133
+ - [HumanLayer ACE-FCA](https://github.com/humanlayer/12-factor-agents) - Structured workflows
134
+ - [Factory.ai](https://factory.ai/blog/context-compression) - Structured compaction research
@@ -1,5 +1,5 @@
1
1
  import type { PluginInput } from "@opencode-ai/plugin";
2
- export declare const DEFAULT_THRESHOLD = 0.8;
2
+ export declare const DEFAULT_THRESHOLD = 0.6;
3
3
  export declare const CLEAR_COOLDOWN_MS = 60000;
4
4
  export declare function createAutoClearLedgerHook(ctx: PluginInput): {
5
5
  event: ({ event }: {