micode 0.2.1 → 0.3.1
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 +109 -14
- package/dist/index.js +35 -8
- package/dist/tools/ast-grep/index.d.ts +8 -0
- package/package.json +1 -1
package/README.md
CHANGED
|
@@ -3,7 +3,11 @@
|
|
|
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 →
|
|
6
|
+
OpenCode plugin with a structured Brainstorm → Plan → Implement workflow.
|
|
7
|
+
|
|
8
|
+
|
|
9
|
+
https://github.com/user-attachments/assets/85236ad3-e78a-4ff7-a840-620f6ea2f512
|
|
10
|
+
|
|
7
11
|
|
|
8
12
|
## Installation
|
|
9
13
|
|
|
@@ -17,12 +21,26 @@ Add to `~/.config/opencode/opencode.json`:
|
|
|
17
21
|
|
|
18
22
|
**AI-assisted install:** Share [INSTALL_CLAUDE.md](./INSTALL_CLAUDE.md) with your AI assistant for guided setup.
|
|
19
23
|
|
|
24
|
+
## Getting Started
|
|
25
|
+
|
|
26
|
+
**Important:** Run `/init` first to generate project documentation:
|
|
27
|
+
|
|
28
|
+
```
|
|
29
|
+
/init
|
|
30
|
+
```
|
|
31
|
+
|
|
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.
|
|
33
|
+
|
|
20
34
|
## Workflow
|
|
21
35
|
|
|
22
36
|
```
|
|
23
|
-
Brainstorm →
|
|
37
|
+
Brainstorm → Plan → Implement
|
|
38
|
+
↓ ↓ ↓
|
|
39
|
+
research research executor
|
|
24
40
|
```
|
|
25
41
|
|
|
42
|
+
Research subagents (codebase-locator, codebase-analyzer, pattern-finder) are spawned within brainstorm and plan phases - not as a separate step.
|
|
43
|
+
|
|
26
44
|
### 1. Brainstorm
|
|
27
45
|
|
|
28
46
|
Refine rough ideas into fully-formed designs through collaborative questioning.
|
|
@@ -30,11 +48,10 @@ Refine rough ideas into fully-formed designs through collaborative questioning.
|
|
|
30
48
|
- One question at a time
|
|
31
49
|
- 2-3 approaches with trade-offs
|
|
32
50
|
- Section-by-section validation
|
|
51
|
+
- Spawns research subagents to understand codebase
|
|
33
52
|
- Output: `thoughts/shared/designs/YYYY-MM-DD-{topic}-design.md`
|
|
34
53
|
|
|
35
|
-
|
|
36
|
-
|
|
37
|
-
Parallel codebase investigation using specialized subagents:
|
|
54
|
+
**Research subagents** (spawned in parallel):
|
|
38
55
|
|
|
39
56
|
| Subagent | Purpose |
|
|
40
57
|
|----------|---------|
|
|
@@ -42,19 +59,18 @@ Parallel codebase investigation using specialized subagents:
|
|
|
42
59
|
| `codebase-analyzer` | Explain HOW code works (with file:line refs) |
|
|
43
60
|
| `pattern-finder` | Find existing patterns to follow |
|
|
44
61
|
|
|
45
|
-
|
|
46
|
-
|
|
47
|
-
### 3. Plan
|
|
62
|
+
### 2. Plan
|
|
48
63
|
|
|
49
64
|
Transform validated designs into comprehensive implementation plans.
|
|
50
65
|
|
|
66
|
+
- Spawns research subagents for exact paths, signatures, patterns
|
|
51
67
|
- Bite-sized tasks (2-5 minutes each)
|
|
52
68
|
- Exact file paths, complete code examples
|
|
53
69
|
- TDD workflow: failing test → verify fail → implement → verify pass → commit
|
|
54
70
|
- Get human approval before implementing
|
|
55
71
|
- Output: `thoughts/shared/plans/YYYY-MM-DD-{topic}.md`
|
|
56
72
|
|
|
57
|
-
###
|
|
73
|
+
### 3. Implement
|
|
58
74
|
|
|
59
75
|
Execute plan in git worktree for isolation:
|
|
60
76
|
|
|
@@ -62,12 +78,91 @@ Execute plan in git worktree for isolation:
|
|
|
62
78
|
git worktree add ../{feature} -b feature/{feature}
|
|
63
79
|
```
|
|
64
80
|
|
|
65
|
-
|
|
66
|
-
|
|
67
|
-
|
|
68
|
-
|
|
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
|
|
135
|
+
|
|
136
|
+
#### Example Output
|
|
137
|
+
|
|
138
|
+
```
|
|
139
|
+
## Execution Complete
|
|
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
|
|
163
|
+
```
|
|
69
164
|
|
|
70
|
-
###
|
|
165
|
+
### 4. Handoff
|
|
71
166
|
|
|
72
167
|
Save/resume session state for continuity:
|
|
73
168
|
|
package/dist/index.js
CHANGED
|
@@ -16,16 +16,18 @@ var brainstormerAgent = {
|
|
|
16
16
|
mode: "primary",
|
|
17
17
|
model: "anthropic/claude-opus-4-5",
|
|
18
18
|
temperature: 0.7,
|
|
19
|
+
tools: { ask: true },
|
|
19
20
|
prompt: `<purpose>
|
|
20
21
|
Turn ideas into fully formed designs through natural collaborative dialogue.
|
|
21
22
|
This is DESIGN ONLY. The planner agent handles detailed implementation plans.
|
|
22
23
|
</purpose>
|
|
23
24
|
|
|
24
25
|
<critical-rules>
|
|
26
|
+
<rule>ASK TOOL: Use the ask tool for EVERY question to the user. Never ask in plain text.</rule>
|
|
25
27
|
<rule>NO CODE: Never write code. Never provide code examples. Design only.</rule>
|
|
26
28
|
<rule>SUBAGENTS: Spawn multiple in parallel for codebase analysis.</rule>
|
|
27
29
|
<rule>TOOLS (grep, read, etc.): Do NOT use directly - use subagents instead.</rule>
|
|
28
|
-
<rule>
|
|
30
|
+
<rule>ONE QUESTION AT A TIME: Ask one question, wait for response before continuing.</rule>
|
|
29
31
|
</critical-rules>
|
|
30
32
|
|
|
31
33
|
<available-subagents>
|
|
@@ -52,8 +54,8 @@ This is DESIGN ONLY. The planner agent handles detailed implementation plans.
|
|
|
52
54
|
- codebase-analyzer: "Analyze existing [related feature]"
|
|
53
55
|
- pattern-finder: "Find patterns for [similar functionality]"
|
|
54
56
|
</spawn-example>
|
|
55
|
-
<rule>
|
|
56
|
-
<rule>
|
|
57
|
+
<rule>Use the ask tool for EVERY question - never plain text</rule>
|
|
58
|
+
<rule>Always provide MULTIPLE CHOICE options in the ask tool</rule>
|
|
57
59
|
<focus>purpose, constraints, success criteria</focus>
|
|
58
60
|
</phase>
|
|
59
61
|
|
|
@@ -89,8 +91,9 @@ This is DESIGN ONLY. The planner agent handles detailed implementation plans.
|
|
|
89
91
|
<principle name="design-only">NO CODE. Describe components, not implementations. Planner writes code.</principle>
|
|
90
92
|
<principle name="subagents-first">ALWAYS use subagents for code analysis, NEVER tools directly</principle>
|
|
91
93
|
<principle name="parallel-spawn">Spawn multiple subagents in a SINGLE message</principle>
|
|
92
|
-
<principle name="
|
|
93
|
-
<principle name="
|
|
94
|
+
<principle name="ask-tool-always">ALWAYS use the ask tool for questions - never plain text</principle>
|
|
95
|
+
<principle name="one-question">Ask ONE question at a time via ask tool. Wait for answer.</principle>
|
|
96
|
+
<principle name="multiple-choice">Present 3-5 options in ask tool questions</principle>
|
|
94
97
|
<principle name="yagni">Remove unnecessary features from ALL designs</principle>
|
|
95
98
|
<principle name="explore-alternatives">ALWAYS propose 2-3 approaches before settling</principle>
|
|
96
99
|
<principle name="incremental-validation">Present in sections, validate each before proceeding</principle>
|
|
@@ -1000,6 +1003,10 @@ If you want exception to ANY rule, STOP and get explicit permission first.
|
|
|
1000
1003
|
Breaking the letter or spirit of the rules is failure.
|
|
1001
1004
|
</rule>
|
|
1002
1005
|
|
|
1006
|
+
<rule priority="critical">
|
|
1007
|
+
ALWAYS use the ask tool when you need user input. Never ask questions in plain text.
|
|
1008
|
+
</rule>
|
|
1009
|
+
|
|
1003
1010
|
<values>
|
|
1004
1011
|
<value>Honesty. If you lie, you'll be replaced.</value>
|
|
1005
1012
|
<value>Do it right, not fast. Never skip steps or take shortcuts.</value>
|
|
@@ -1015,7 +1022,8 @@ Breaking the letter or spirit of the rules is failure.
|
|
|
1015
1022
|
<rule>If uncomfortable pushing back, say "Strange things are afoot at the Circle K"</rule>
|
|
1016
1023
|
<rule>STOP and ask for clarification rather than making assumptions</rule>
|
|
1017
1024
|
<rule>STOP and ask for help when human input would be valuable</rule>
|
|
1018
|
-
<rule>
|
|
1025
|
+
<rule>ALWAYS use the ask tool when asking questions - never plain text</rule>
|
|
1026
|
+
<rule>Provide multiple-choice options in the ask tool whenever possible</rule>
|
|
1019
1027
|
</relationship>
|
|
1020
1028
|
|
|
1021
1029
|
<proactiveness>
|
|
@@ -1098,7 +1106,8 @@ var primaryAgent = {
|
|
|
1098
1106
|
budgetTokens: 32000
|
|
1099
1107
|
},
|
|
1100
1108
|
maxTokens: 64000,
|
|
1101
|
-
prompt: PROMPT
|
|
1109
|
+
prompt: PROMPT,
|
|
1110
|
+
tools: { ask: true }
|
|
1102
1111
|
};
|
|
1103
1112
|
var PRIMARY_AGENT_NAME = process.env.OPENCODE_AGENT_NAME || "Commander";
|
|
1104
1113
|
|
|
@@ -1324,7 +1333,7 @@ var agents = {
|
|
|
1324
1333
|
};
|
|
1325
1334
|
|
|
1326
1335
|
// src/tools/ast-grep/index.ts
|
|
1327
|
-
var {spawn } = globalThis.Bun;
|
|
1336
|
+
var {spawn, which } = globalThis.Bun;
|
|
1328
1337
|
|
|
1329
1338
|
// node_modules/zod/v4/classic/external.js
|
|
1330
1339
|
var exports_external = {};
|
|
@@ -13648,6 +13657,20 @@ function tool(input) {
|
|
|
13648
13657
|
tool.schema = exports_external;
|
|
13649
13658
|
|
|
13650
13659
|
// src/tools/ast-grep/index.ts
|
|
13660
|
+
async function checkAstGrepAvailable() {
|
|
13661
|
+
const sgPath = which("sg");
|
|
13662
|
+
if (sgPath) {
|
|
13663
|
+
return { available: true };
|
|
13664
|
+
}
|
|
13665
|
+
return {
|
|
13666
|
+
available: false,
|
|
13667
|
+
message: `ast-grep CLI (sg) not found. AST-aware search/replace will not work.
|
|
13668
|
+
` + `Install with one of:
|
|
13669
|
+
` + ` npm install -g @ast-grep/cli
|
|
13670
|
+
` + ` cargo install ast-grep --locked
|
|
13671
|
+
` + " brew install ast-grep"
|
|
13672
|
+
};
|
|
13673
|
+
}
|
|
13651
13674
|
var LANGUAGES = [
|
|
13652
13675
|
"c",
|
|
13653
13676
|
"cpp",
|
|
@@ -15321,6 +15344,10 @@ var MCP_SERVERS = {
|
|
|
15321
15344
|
}
|
|
15322
15345
|
};
|
|
15323
15346
|
var OpenCodeConfigPlugin = async (ctx) => {
|
|
15347
|
+
const astGrepStatus = await checkAstGrepAvailable();
|
|
15348
|
+
if (!astGrepStatus.available) {
|
|
15349
|
+
console.warn(`[micode] ${astGrepStatus.message}`);
|
|
15350
|
+
}
|
|
15324
15351
|
const thinkModeState = new Map;
|
|
15325
15352
|
const autoCompactHook = createAutoCompactHook(ctx);
|
|
15326
15353
|
const contextInjectorHook = createContextInjectorHook(ctx);
|
|
@@ -1,3 +1,11 @@
|
|
|
1
|
+
/**
|
|
2
|
+
* Check if ast-grep CLI (sg) is available on the system.
|
|
3
|
+
* Returns installation instructions if not found.
|
|
4
|
+
*/
|
|
5
|
+
export declare function checkAstGrepAvailable(): Promise<{
|
|
6
|
+
available: boolean;
|
|
7
|
+
message?: string;
|
|
8
|
+
}>;
|
|
1
9
|
export declare const ast_grep_search: {
|
|
2
10
|
description: string;
|
|
3
11
|
args: {
|