micode 0.2.0 → 0.3.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,7 +3,11 @@
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 → Research → Plan → Implement workflow.
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 → Research → Plan → Implement → Review
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
- ### 2. Research
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
- Output: `thoughts/shared/research/YYYY-MM-DD-{topic}.md`
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
- ### 4. Implement
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
- - **Executor** orchestrates the implement review cycle automatically
66
- - Spawns Implementer → waits → spawns Reviewer → loops if changes requested
67
- - Maximum 3 cycles before escalating to human
68
- - Commit with descriptive messages when approved
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
- ### 5. Handoff
165
+ ### 4. Handoff
71
166
 
72
167
  Save/resume session state for continuity:
73
168
 
package/dist/index.js CHANGED
@@ -16,6 +16,7 @@ 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.
@@ -699,93 +700,149 @@ Check correctness and style. Be specific. Run code, don't just read.
699
700
 
700
701
  // src/agents/executor.ts
701
702
  var executorAgent = {
702
- description: "Executes plan then reviews - orchestrates implementer and reviewer",
703
+ description: "Executes plan task-by-task with parallel execution where possible",
703
704
  mode: "subagent",
704
705
  model: "anthropic/claude-opus-4-5",
705
706
  temperature: 0.2,
706
707
  prompt: `<purpose>
707
- Execute the plan completely: implement then review.
708
- You orchestrate the implementer and reviewer subagents.
708
+ Execute plan tasks with maximum parallelism.
709
+ Each task gets its own implementer \u2192 reviewer cycle.
710
+ Detect and parallelize independent tasks.
709
711
  </purpose>
710
712
 
711
713
  <workflow>
712
- <step>Spawn implementer with the plan</step>
713
- <step>Wait for implementer to complete</step>
714
- <step>Spawn reviewer to check the implementation</step>
715
- <step>If reviewer requests changes: spawn implementer again with fixes</step>
716
- <step>Repeat until reviewer approves or issues are blocking</step>
717
- <step>Report final status</step>
714
+ <step>Parse plan to extract individual tasks</step>
715
+ <step>Analyze task dependencies to build execution graph</step>
716
+ <step>Group tasks into parallel batches (independent tasks run together)</step>
717
+ <step>For each batch: spawn implementer \u2192 reviewer per task IN PARALLEL</step>
718
+ <step>Wait for batch to complete before starting dependent batch</step>
719
+ <step>Aggregate results and report</step>
718
720
  </workflow>
719
721
 
722
+ <dependency-analysis>
723
+ Tasks are INDEPENDENT (can parallelize) when:
724
+ - They modify different files
725
+ - They don't depend on each other's output
726
+ - They don't share state
727
+
728
+ Tasks are DEPENDENT (must be sequential) when:
729
+ - Task B modifies a file that Task A creates
730
+ - Task B imports/uses something Task A defines
731
+ - Task B's test relies on Task A's implementation
732
+ - Plan explicitly states ordering
733
+
734
+ When uncertain, assume DEPENDENT (safer).
735
+ </dependency-analysis>
736
+
737
+ <execution-pattern>
738
+ Example: 9 tasks where tasks 1-3 are independent, 4-6 depend on 1-3, 7-9 depend on 4-6
739
+
740
+ Batch 1 (parallel):
741
+ - Spawn implementer for task 1 \u2192 reviewer
742
+ - Spawn implementer for task 2 \u2192 reviewer
743
+ - Spawn implementer for task 3 \u2192 reviewer
744
+ [Wait for all to complete]
745
+
746
+ Batch 2 (parallel):
747
+ - Spawn implementer for task 4 \u2192 reviewer
748
+ - Spawn implementer for task 5 \u2192 reviewer
749
+ - Spawn implementer for task 6 \u2192 reviewer
750
+ [Wait for all to complete]
751
+
752
+ Batch 3 (parallel):
753
+ - Spawn implementer for task 7 \u2192 reviewer
754
+ - Spawn implementer for task 8 \u2192 reviewer
755
+ - Spawn implementer for task 9 \u2192 reviewer
756
+ [Wait for all to complete]
757
+ </execution-pattern>
758
+
720
759
  <available-subagents>
721
- <subagent name="implementer" spawn="sequential">
722
- Executes implementation tasks from a plan.
723
- Input: The plan or specific tasks to implement.
724
- Output: List of changes made and verification results.
760
+ <subagent name="implementer" spawn="parallel-per-task">
761
+ Executes ONE task from the plan.
762
+ Input: Single task with context (which files, what to do).
763
+ Output: Changes made and verification results for that task.
725
764
  </subagent>
726
- <subagent name="reviewer" spawn="sequential">
727
- Reviews implementation for correctness and style.
728
- Input: Implicitly reviews current state against plan.
729
- Output: APPROVED or CHANGES REQUESTED with specific issues.
765
+ <subagent name="reviewer" spawn="parallel-per-task">
766
+ Reviews ONE task's implementation.
767
+ Input: Single task's changes against its requirements.
768
+ Output: APPROVED or CHANGES REQUESTED for that task.
730
769
  </subagent>
731
770
  </available-subagents>
732
771
 
772
+ <per-task-cycle>
773
+ For each task:
774
+ 1. Spawn implementer with task details
775
+ 2. Wait for implementer to complete
776
+ 3. Spawn reviewer to check that task
777
+ 4. If reviewer requests changes: re-spawn implementer for fixes
778
+ 5. Max 3 cycles per task before marking as blocked
779
+ 6. Report task status: DONE / BLOCKED
780
+ </per-task-cycle>
781
+
782
+ <parallel-spawning>
783
+ Within a batch, spawn ALL implementers in a SINGLE message:
784
+
785
+ Example for batch with tasks 1, 2, 3:
786
+ - In ONE message, spawn:
787
+ - implementer: "Execute task 1: [details]"
788
+ - implementer: "Execute task 2: [details]"
789
+ - implementer: "Execute task 3: [details]"
790
+
791
+ Then after all complete, in ONE message spawn:
792
+ - reviewer: "Review task 1 implementation"
793
+ - reviewer: "Review task 2 implementation"
794
+ - reviewer: "Review task 3 implementation"
795
+ </parallel-spawning>
796
+
733
797
  <rules>
734
- <rule>ALWAYS spawn reviewer after implementer completes</rule>
735
- <rule>Never skip the review step</rule>
736
- <rule>If reviewer finds issues, spawn implementer to fix them</rule>
737
- <rule>Maximum 3 implement-review cycles before escalating</rule>
738
- <rule>Report blocking issues immediately - don't loop forever</rule>
798
+ <rule>Parse ALL tasks from plan before starting execution</rule>
799
+ <rule>ALWAYS analyze dependencies before parallelizing</rule>
800
+ <rule>Spawn parallel tasks in SINGLE message for true parallelism</rule>
801
+ <rule>Wait for entire batch before starting next batch</rule>
802
+ <rule>Each task gets its own implement \u2192 review cycle</rule>
803
+ <rule>Max 3 review cycles per task</rule>
804
+ <rule>Continue with other tasks if one is blocked</rule>
739
805
  </rules>
740
806
 
741
- <on-reviewer-approved>
742
- Report success with summary of changes and verification status.
743
- </on-reviewer-approved>
744
-
745
- <on-reviewer-requests-changes>
746
- <action>Parse the specific issues from reviewer output</action>
747
- <action>Spawn implementer with the list of issues to fix</action>
748
- <action>After implementer completes, spawn reviewer again</action>
749
- <rule>Track cycle count - max 3 cycles</rule>
750
- </on-reviewer-requests-changes>
751
-
752
- <on-max-cycles-reached>
753
- <action>Report that implementation could not satisfy review after 3 attempts</action>
754
- <action>Include all outstanding issues from last review</action>
755
- <action>Request human guidance</action>
756
- </on-max-cycles-reached>
757
-
758
807
  <output-format>
759
808
  <template>
760
809
  ## Execution Complete
761
810
 
762
- **Status**: APPROVED / NEEDS HUMAN REVIEW
811
+ **Plan**: [plan file path]
812
+ **Total tasks**: [N]
813
+ **Batches**: [M] (based on dependency analysis)
763
814
 
764
- **Cycles**: [N] implement-review cycles
815
+ ### Dependency Analysis
816
+ - Batch 1 (parallel): Tasks 1, 2, 3 - independent, no shared files
817
+ - Batch 2 (parallel): Tasks 4, 5 - depend on batch 1
818
+ - Batch 3 (sequential): Task 6 - depends on task 5 specifically
765
819
 
766
- ### Implementation Summary
767
- [From implementer output]
768
- - \`file:line\` - [what changed]
820
+ ### Results
769
821
 
770
- ### Review Summary
771
- [From reviewer output]
772
- - Status: [APPROVED / issues remaining]
773
- - [Any outstanding issues]
822
+ | Task | Status | Cycles | Notes |
823
+ |------|--------|--------|-------|
824
+ | 1 | \u2705 DONE | 1 | |
825
+ | 2 | \u2705 DONE | 2 | Fixed type error on cycle 2 |
826
+ | 3 | \u274C BLOCKED | 3 | Could not resolve: [issue] |
827
+ | ... | | | |
774
828
 
775
- ### Verification
776
- - [x] Tests pass
777
- - [x] Types check
778
- - [x] Review approved
829
+ ### Summary
830
+ - Completed: [X]/[N] tasks
831
+ - Blocked: [Y] tasks need human intervention
779
832
 
780
- **Next**: [Ready to commit / Needs human decision on: X]
833
+ ### Blocked Tasks (if any)
834
+ **Task 3**: [description of blocker and last reviewer feedback]
835
+
836
+ **Next**: [Ready to commit / Needs human decision on blocked tasks]
781
837
  </template>
782
838
  </output-format>
783
839
 
784
840
  <never-do>
785
- <forbidden>Never skip the review step</forbidden>
786
- <forbidden>Never report success without reviewer approval</forbidden>
787
- <forbidden>Never loop more than 3 times without escalating</forbidden>
788
- <forbidden>Never ignore reviewer feedback</forbidden>
841
+ <forbidden>Never skip dependency analysis</forbidden>
842
+ <forbidden>Never spawn dependent tasks in parallel</forbidden>
843
+ <forbidden>Never skip reviewer for any task</forbidden>
844
+ <forbidden>Never continue past 3 cycles for a single task</forbidden>
845
+ <forbidden>Never report success if any task is blocked</forbidden>
789
846
  </never-do>`
790
847
  };
791
848
 
@@ -1042,7 +1099,8 @@ var primaryAgent = {
1042
1099
  budgetTokens: 32000
1043
1100
  },
1044
1101
  maxTokens: 64000,
1045
- prompt: PROMPT
1102
+ prompt: PROMPT,
1103
+ tools: { ask: true }
1046
1104
  };
1047
1105
  var PRIMARY_AGENT_NAME = process.env.OPENCODE_AGENT_NAME || "Commander";
1048
1106
 
@@ -1268,7 +1326,7 @@ var agents = {
1268
1326
  };
1269
1327
 
1270
1328
  // src/tools/ast-grep/index.ts
1271
- var {spawn } = globalThis.Bun;
1329
+ var {spawn, which } = globalThis.Bun;
1272
1330
 
1273
1331
  // node_modules/zod/v4/classic/external.js
1274
1332
  var exports_external = {};
@@ -13592,6 +13650,20 @@ function tool(input) {
13592
13650
  tool.schema = exports_external;
13593
13651
 
13594
13652
  // src/tools/ast-grep/index.ts
13653
+ async function checkAstGrepAvailable() {
13654
+ const sgPath = which("sg");
13655
+ if (sgPath) {
13656
+ return { available: true };
13657
+ }
13658
+ return {
13659
+ available: false,
13660
+ message: `ast-grep CLI (sg) not found. AST-aware search/replace will not work.
13661
+ ` + `Install with one of:
13662
+ ` + ` npm install -g @ast-grep/cli
13663
+ ` + ` cargo install ast-grep --locked
13664
+ ` + " brew install ast-grep"
13665
+ };
13666
+ }
13595
13667
  var LANGUAGES = [
13596
13668
  "c",
13597
13669
  "cpp",
@@ -15265,6 +15337,10 @@ var MCP_SERVERS = {
15265
15337
  }
15266
15338
  };
15267
15339
  var OpenCodeConfigPlugin = async (ctx) => {
15340
+ const astGrepStatus = await checkAstGrepAvailable();
15341
+ if (!astGrepStatus.available) {
15342
+ console.warn(`[micode] ${astGrepStatus.message}`);
15343
+ }
15268
15344
  const thinkModeState = new Map;
15269
15345
  const autoCompactHook = createAutoCompactHook(ctx);
15270
15346
  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: {
package/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "micode",
3
- "version": "0.2.0",
3
+ "version": "0.3.0",
4
4
  "description": "OpenCode plugin with Brainstorm-Research-Plan-Implement workflow",
5
5
  "main": "dist/index.js",
6
6
  "types": "dist/index.d.ts",