micode 0.1.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.
@@ -0,0 +1,175 @@
1
+ # micode Installation Guide for LLMs
2
+
3
+ This document guides AI assistants through the micode plugin installation process.
4
+
5
+ ## Step 0: Ask User About Setup
6
+
7
+ micode uses Claude Opus 4.5 for its primary agents (Commander, Brainstormer, project-initializer). Ask the user:
8
+
9
+ ### Question 1: Claude Subscription
10
+
11
+ > Do you have a Claude Pro/Max subscription?
12
+
13
+ **If YES:**
14
+ - Add ToDo: "Setup Claude Pro/Max Auth"
15
+ - Ask follow-up: "Are you on max20 (20x mode)?"
16
+ - If max20: Full Claude Opus 4.5 available for all agents
17
+ - If not max20: Consider using lighter models for subagents
18
+
19
+ **If NO:**
20
+ - Inform user: "micode works best with Claude Opus 4.5. Without Claude, you'll need to configure alternative models."
21
+ - Create `~/.config/opencode/micode.json`:
22
+ ```json
23
+ {
24
+ "agents": {
25
+ "Commander": { "model": "opencode/big-pickle" },
26
+ "Brainstormer": { "model": "opencode/big-pickle" },
27
+ "project-initializer": { "model": "opencode/big-pickle" }
28
+ }
29
+ }
30
+ ```
31
+
32
+ ## Step 1: Verify OpenCode Installation
33
+
34
+ ```bash
35
+ if command -v opencode &> /dev/null; then
36
+ echo "OpenCode $(opencode --version) is installed"
37
+ else
38
+ echo "OpenCode is not installed. Please install it first."
39
+ echo "Ref: https://opencode.ai/docs"
40
+ fi
41
+ ```
42
+
43
+ If OpenCode isn't installed, guide user to https://opencode.ai/docs or spawn a subagent to handle installation.
44
+
45
+ ## Step 2: Configure micode Plugin
46
+
47
+ ### Check for existing config
48
+
49
+ ```bash
50
+ if [ -f ~/.config/opencode/opencode.jsonc ]; then
51
+ echo "Found opencode.jsonc - edit this file"
52
+ elif [ -f ~/.config/opencode/opencode.json ]; then
53
+ echo "Found opencode.json - edit this file"
54
+ else
55
+ echo "No config found - will create new one"
56
+ fi
57
+ ```
58
+
59
+ ### Add micode to plugins
60
+
61
+ **If config exists:**
62
+ ```bash
63
+ if command -v jq &> /dev/null; then
64
+ jq '.plugin = ((.plugin // []) + ["micode"] | unique)' \
65
+ ~/.config/opencode/opencode.json > /tmp/oc.json && \
66
+ mv /tmp/oc.json ~/.config/opencode/opencode.json
67
+ else
68
+ echo "Please add \"micode\" to the plugin array in ~/.config/opencode/opencode.json"
69
+ fi
70
+ ```
71
+
72
+ **If no config exists:**
73
+ ```bash
74
+ mkdir -p ~/.config/opencode
75
+ echo '{"plugin":["micode"]}' > ~/.config/opencode/opencode.json
76
+ ```
77
+
78
+ ## Step 3: Verify Setup
79
+
80
+ ```bash
81
+ opencode --version # Should be 1.0.132 or higher
82
+ cat ~/.config/opencode/opencode.json # Should contain "micode" in plugin array
83
+ ```
84
+
85
+ ## Step 4: Configure Authentication
86
+
87
+ ### Anthropic (Claude) - Recommended
88
+
89
+ ```bash
90
+ opencode auth login
91
+ # Interactive Terminal: Provider: Select Anthropic
92
+ # Interactive Terminal: Login method: Select Claude Pro/Max
93
+ # Guide user through OAuth flow in browser
94
+ # Wait for completion
95
+ # Verify success
96
+ ```
97
+
98
+ ## Step 5: Verify Everything Works
99
+
100
+ 1. Run `opencode` in terminal
101
+ 2. Check that Commander agent is available
102
+ 3. Try `/init` command to test project-initializer
103
+
104
+ ## Step 6: Congratulate User
105
+
106
+ Say to user:
107
+
108
+ > Congratulations! 🎉 You have successfully set up micode!
109
+ >
110
+ > **What you can do now:**
111
+ > - Use **Commander** as your main orchestrator
112
+ > - Use **Brainstormer** for design exploration
113
+ > - Run `/init` to generate ARCHITECTURE.md and CODE_STYLE.md
114
+ >
115
+ > **Workflow:** Brainstorm → Research → Plan → Implement → Review
116
+ >
117
+ > Type `opencode` in your terminal to start!
118
+
119
+ ## Step 7: Ask for a Star
120
+
121
+ After everything is set up and working:
122
+
123
+ > "If you found this helpful, would you like to star the repository? It helps the project grow! ⭐"
124
+
125
+ **Only if user explicitly agrees:**
126
+ ```bash
127
+ gh repo star vtemian/micode
128
+ ```
129
+
130
+ Never run this automatically without consent.
131
+
132
+ ---
133
+
134
+ ## Quick Reference
135
+
136
+ ### Available Agents
137
+
138
+ | Agent | Model | Purpose |
139
+ |-------|-------|---------|
140
+ | Commander | claude-opus-4-5 | Main orchestrator |
141
+ | Brainstormer | claude-opus-4-5 | Design exploration |
142
+ | project-initializer | claude-opus-4-5 | Generate docs |
143
+ | codebase-locator | - | Find files |
144
+ | codebase-analyzer | - | Analyze code |
145
+ | pattern-finder | - | Find patterns |
146
+ | implementer | - | Execute tasks |
147
+ | reviewer | - | Review code |
148
+
149
+ ### Available Commands
150
+
151
+ | Command | Description |
152
+ |---------|-------------|
153
+ | `/init` | Initialize project with ARCHITECTURE.md and CODE_STYLE.md |
154
+
155
+ ### Available Tools
156
+
157
+ | Tool | Description |
158
+ |------|-------------|
159
+ | `ast_grep_search` | AST-aware code search |
160
+ | `ast_grep_replace` | AST-aware code replace |
161
+ | `look_at` | Screenshot analysis |
162
+ | `background_task` | Run tasks in background |
163
+
164
+ ### Model Override
165
+
166
+ To use different models, create `~/.config/opencode/micode.json`:
167
+
168
+ ```json
169
+ {
170
+ "agents": {
171
+ "Commander": { "model": "your-preferred-model" },
172
+ "Brainstormer": { "model": "your-preferred-model" }
173
+ }
174
+ }
175
+ ```
package/README.md ADDED
@@ -0,0 +1,192 @@
1
+ # micode
2
+
3
+ [![CI](https://github.com/vtemian/micode/actions/workflows/ci.yml/badge.svg)](https://github.com/vtemian/micode/actions/workflows/ci.yml)
4
+ [![npm version](https://badge.fury.io/js/micode.svg)](https://www.npmjs.com/package/micode)
5
+
6
+ OpenCode plugin with a structured Brainstorm → Research → Plan → Implement workflow.
7
+
8
+ ## Installation
9
+
10
+ Add to `~/.config/opencode/opencode.json`:
11
+
12
+ ```json
13
+ {
14
+ "plugin": ["micode"]
15
+ }
16
+ ```
17
+
18
+ **AI-assisted install:** Share [INSTALL_CLAUDE.md](./INSTALL_CLAUDE.md) with your AI assistant for guided setup.
19
+
20
+ ## Workflow
21
+
22
+ ```
23
+ Brainstorm → Research → Plan → Implement → Review
24
+ ```
25
+
26
+ ### 1. Brainstorm
27
+
28
+ Refine rough ideas into fully-formed designs through collaborative questioning.
29
+
30
+ - One question at a time
31
+ - 2-3 approaches with trade-offs
32
+ - Section-by-section validation
33
+ - Output: `thoughts/shared/designs/YYYY-MM-DD-{topic}-design.md`
34
+
35
+ ### 2. Research
36
+
37
+ Parallel codebase investigation using specialized subagents:
38
+
39
+ | Subagent | Purpose |
40
+ |----------|---------|
41
+ | `codebase-locator` | Find WHERE files live (paths, no content) |
42
+ | `codebase-analyzer` | Explain HOW code works (with file:line refs) |
43
+ | `pattern-finder` | Find existing patterns to follow |
44
+
45
+ Output: `thoughts/shared/research/YYYY-MM-DD-{topic}.md`
46
+
47
+ ### 3. Plan
48
+
49
+ Create implementation plan with phases and verification steps.
50
+
51
+ - Get human approval before implementing
52
+ - Output: `thoughts/shared/plans/YYYY-MM-DD-{topic}.md`
53
+
54
+ ### 4. Implement
55
+
56
+ Execute plan in git worktree for isolation:
57
+
58
+ ```bash
59
+ git worktree add ../{feature} -b feature/{feature}
60
+ ```
61
+
62
+ - Implementer + Reviewer work per phase
63
+ - Commit with descriptive messages
64
+ - Merge when complete
65
+
66
+ ### 5. Handoff
67
+
68
+ Save/resume session state for continuity:
69
+
70
+ - `handoff-creator`: Save current session
71
+ - `handoff-resumer`: Resume from handoff
72
+ - Output: `thoughts/shared/handoffs/`
73
+
74
+ ## Commands
75
+
76
+ | Command | Description |
77
+ |---------|-------------|
78
+ | `/init` | Initialize project with ARCHITECTURE.md and CODE_STYLE.md |
79
+
80
+ ## Agents
81
+
82
+ | Agent | Mode | Model | Purpose |
83
+ |-------|------|-------|---------|
84
+ | Commander | primary | claude-opus-4-5 | Orchestrator, delegates to specialists |
85
+ | Brainstormer | primary | claude-opus-4-5 | Design exploration through questioning |
86
+ | project-initializer | subagent | claude-opus-4-5 | Generate ARCHITECTURE.md and CODE_STYLE.md |
87
+ | codebase-locator | subagent | - | Find file locations |
88
+ | codebase-analyzer | subagent | - | Deep code analysis |
89
+ | pattern-finder | subagent | - | Find existing patterns |
90
+ | implementer | subagent | - | Execute implementation |
91
+ | reviewer | subagent | - | Review correctness |
92
+ | handoff-creator | subagent | - | Save session state |
93
+ | handoff-resumer | subagent | - | Resume from handoff |
94
+
95
+ ## Tools
96
+
97
+ | Tool | Description |
98
+ |------|-------------|
99
+ | `ast_grep_search` | AST-aware code pattern search |
100
+ | `ast_grep_replace` | AST-aware code pattern replacement |
101
+ | `look_at` | Screenshot analysis |
102
+ | `background_task` | Run long-running tasks in background |
103
+ | `check_background_task` | Check background task status |
104
+
105
+ ## Hooks
106
+
107
+ | Hook | Description |
108
+ |------|-------------|
109
+ | Think Mode | Keywords like "think hard" enable 32k token thinking budget |
110
+ | Auto-Compact | Summarizes session when hitting token limits |
111
+ | Preemptive Compaction | Warns before context exhaustion |
112
+ | Context Injector | Injects ARCHITECTURE.md, CODE_STYLE.md, .cursorrules |
113
+ | Token-Aware Truncation | Truncates large tool outputs |
114
+ | Context Window Monitor | Tracks token usage |
115
+ | Comment Checker | Validates edit tool comments |
116
+ | Session Recovery | Recovers from crashes |
117
+
118
+ ## MCP Servers
119
+
120
+ | Server | Description |
121
+ |--------|-------------|
122
+ | context7 | Documentation lookup |
123
+
124
+ ## Structure
125
+
126
+ ```
127
+ micode/
128
+ ├── src/
129
+ │ ├── agents/ # Agent definitions
130
+ │ ├── tools/ # ast-grep, look-at, background-task
131
+ │ ├── hooks/ # Session management hooks
132
+ │ └── index.ts # Plugin entry
133
+ ├── dist/ # Built plugin
134
+ └── thoughts/ # Artifacts (gitignored)
135
+ └── shared/
136
+ ├── designs/ # Brainstorm outputs
137
+ ├── research/ # Research documents
138
+ ├── plans/ # Implementation plans
139
+ └── handoffs/ # Session handoffs
140
+ ```
141
+
142
+ ## Development
143
+
144
+ ### From source
145
+
146
+ ```bash
147
+ git clone git@github.com:vtemian/micode.git ~/.micode
148
+ cd ~/.micode
149
+ bun install
150
+ bun run build
151
+ ```
152
+
153
+ Then use local path in config:
154
+ ```json
155
+ {
156
+ "plugin": ["~/.micode/dist/index.js"]
157
+ }
158
+ ```
159
+
160
+ ### Commands
161
+
162
+ ```bash
163
+ bun install # Install dependencies
164
+ bun run build # Build plugin
165
+ bun run typecheck # Type check
166
+ ```
167
+
168
+ ### Release
169
+
170
+ Releases are automated via GitHub Actions. To publish a new version:
171
+
172
+ ```bash
173
+ npm version patch # or minor, major
174
+ git push --follow-tags
175
+ ```
176
+
177
+ This triggers the release workflow which publishes to npm.
178
+
179
+ **Manual publish** (first time or if needed):
180
+ ```bash
181
+ npm login
182
+ npm publish
183
+ ```
184
+
185
+ ## Philosophy
186
+
187
+ 1. **Brainstorm first** - Refine ideas before coding
188
+ 2. **Research before implementing** - Understand the codebase
189
+ 3. **Plan with human buy-in** - Get approval before coding
190
+ 4. **Parallel investigation** - Spawn multiple subagents for speed
191
+ 5. **Isolated implementation** - Use git worktrees for features
192
+ 6. **Continuous verification** - Implementer + Reviewer per phase
@@ -0,0 +1,2 @@
1
+ import type { AgentConfig } from "@opencode-ai/sdk";
2
+ export declare const brainstormerAgent: AgentConfig;
@@ -0,0 +1,2 @@
1
+ import type { AgentConfig } from "@opencode-ai/sdk";
2
+ export declare const codebaseAnalyzerAgent: AgentConfig;
@@ -0,0 +1,2 @@
1
+ import type { AgentConfig } from "@opencode-ai/sdk";
2
+ export declare const codebaseLocatorAgent: AgentConfig;
@@ -0,0 +1,3 @@
1
+ import type { AgentConfig } from "@opencode-ai/sdk";
2
+ export declare const primaryAgent: AgentConfig;
3
+ export declare const PRIMARY_AGENT_NAME: string;
@@ -0,0 +1,2 @@
1
+ import type { AgentConfig } from "@opencode-ai/sdk";
2
+ export declare const handoffCreatorAgent: AgentConfig;
@@ -0,0 +1,2 @@
1
+ import type { AgentConfig } from "@opencode-ai/sdk";
2
+ export declare const handoffResumerAgent: AgentConfig;
@@ -0,0 +1,2 @@
1
+ import type { AgentConfig } from "@opencode-ai/sdk";
2
+ export declare const implementerAgent: AgentConfig;
@@ -0,0 +1,13 @@
1
+ import type { AgentConfig } from "@opencode-ai/sdk";
2
+ import { brainstormerAgent } from "./brainstormer";
3
+ import { codebaseLocatorAgent } from "./codebase-locator";
4
+ import { codebaseAnalyzerAgent } from "./codebase-analyzer";
5
+ import { patternFinderAgent } from "./pattern-finder";
6
+ import { implementerAgent } from "./implementer";
7
+ import { reviewerAgent } from "./reviewer";
8
+ import { handoffCreatorAgent } from "./handoff-creator";
9
+ import { handoffResumerAgent } from "./handoff-resumer";
10
+ import { primaryAgent, PRIMARY_AGENT_NAME } from "./commander";
11
+ import { projectInitializerAgent } from "./project-initializer";
12
+ export declare const agents: Record<string, AgentConfig>;
13
+ export { primaryAgent, PRIMARY_AGENT_NAME, brainstormerAgent, codebaseLocatorAgent, codebaseAnalyzerAgent, patternFinderAgent, implementerAgent, reviewerAgent, handoffCreatorAgent, handoffResumerAgent, projectInitializerAgent, };
@@ -0,0 +1,2 @@
1
+ import type { AgentConfig } from "@opencode-ai/sdk";
2
+ export declare const patternFinderAgent: AgentConfig;
@@ -0,0 +1,2 @@
1
+ import type { AgentConfig } from "@opencode-ai/sdk";
2
+ export declare const projectInitializerAgent: AgentConfig;
@@ -0,0 +1,2 @@
1
+ import type { AgentConfig } from "@opencode-ai/sdk";
2
+ export declare const reviewerAgent: AgentConfig;
@@ -0,0 +1,9 @@
1
+ import type { PluginInput } from "@opencode-ai/plugin";
2
+ export declare function createAutoCompactHook(ctx: PluginInput): {
3
+ event: ({ event }: {
4
+ event: {
5
+ type: string;
6
+ properties?: unknown;
7
+ };
8
+ }) => Promise<void>;
9
+ };
@@ -0,0 +1,9 @@
1
+ import type { PluginInput } from "@opencode-ai/plugin";
2
+ export declare function createCommentCheckerHook(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,15 @@
1
+ import type { PluginInput } from "@opencode-ai/plugin";
2
+ export declare function createContextInjectorHook(ctx: PluginInput): {
3
+ "chat.params": (_input: {
4
+ sessionID: string;
5
+ }, output: {
6
+ options?: Record<string, unknown>;
7
+ system?: string;
8
+ }) => Promise<void>;
9
+ "tool.execute.after": (input: {
10
+ tool: string;
11
+ args?: Record<string, unknown>;
12
+ }, output: {
13
+ output?: string;
14
+ }) => Promise<void>;
15
+ };
@@ -0,0 +1,15 @@
1
+ import type { PluginInput } from "@opencode-ai/plugin";
2
+ export declare function createContextWindowMonitorHook(ctx: PluginInput): {
3
+ "chat.params": (input: {
4
+ sessionID: string;
5
+ }, output: {
6
+ system?: string;
7
+ options?: Record<string, unknown>;
8
+ }) => Promise<void>;
9
+ event: ({ event }: {
10
+ event: {
11
+ type: string;
12
+ properties?: unknown;
13
+ };
14
+ }) => Promise<void>;
15
+ };
@@ -0,0 +1,9 @@
1
+ import type { PluginInput } from "@opencode-ai/plugin";
2
+ export declare function createPreemptiveCompactionHook(ctx: PluginInput): {
3
+ event: ({ event }: {
4
+ event: {
5
+ type: string;
6
+ properties?: unknown;
7
+ };
8
+ }) => Promise<void>;
9
+ };
@@ -0,0 +1,9 @@
1
+ import type { PluginInput } from "@opencode-ai/plugin";
2
+ export declare function createSessionRecoveryHook(ctx: PluginInput): {
3
+ event: ({ event }: {
4
+ event: {
5
+ type: string;
6
+ properties?: unknown;
7
+ };
8
+ }) => Promise<void>;
9
+ };
@@ -0,0 +1,15 @@
1
+ import type { PluginInput } from "@opencode-ai/plugin";
2
+ export declare function createTokenAwareTruncationHook(ctx: PluginInput): {
3
+ event: ({ event }: {
4
+ event: {
5
+ type: string;
6
+ properties?: unknown;
7
+ };
8
+ }) => Promise<void>;
9
+ "tool.execute.after": (input: {
10
+ name: string;
11
+ sessionID: string;
12
+ }, output: {
13
+ output?: string;
14
+ }) => Promise<void>;
15
+ };
@@ -0,0 +1,3 @@
1
+ import type { Plugin } from "@opencode-ai/plugin";
2
+ declare const OpenCodeConfigPlugin: Plugin;
3
+ export default OpenCodeConfigPlugin;