opencodekit 0.14.6 → 0.15.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 +2 -2
- package/dist/index.js +435 -57
- package/dist/template/.opencode/.env.example +1 -0
- package/dist/template/.opencode/AGENTS.md +13 -24
- package/dist/template/.opencode/README.md +8 -119
- package/dist/template/.opencode/agent/explore.md +2 -3
- package/dist/template/.opencode/agent/general.md +56 -0
- package/dist/template/.opencode/agent/plan.md +54 -0
- package/dist/template/.opencode/agent/scout.md +15 -5
- package/dist/template/.opencode/command/analyze-project.md +2 -2
- package/dist/template/.opencode/command/brainstorm.md +1 -1
- package/dist/template/.opencode/command/design-audit.md +4 -5
- package/dist/template/.opencode/command/design.md +4 -13
- package/dist/template/.opencode/command/generate-pattern.md +2 -9
- package/dist/template/.opencode/command/implement.md +4 -4
- package/dist/template/.opencode/command/init.md +1 -1
- package/dist/template/.opencode/command/new-feature.md +2 -3
- package/dist/template/.opencode/command/plan.md +1 -1
- package/dist/template/.opencode/command/pr.md +0 -1
- package/dist/template/.opencode/command/research.md +20 -6
- package/dist/template/.opencode/command/restore-image.md +1 -9
- package/dist/template/.opencode/command/revert-feature.md +1 -1
- package/dist/template/.opencode/command/review-codebase.md +4 -4
- package/dist/template/.opencode/command/status.md +1 -2
- package/dist/template/.opencode/command/summarize.md +1 -2
- package/dist/template/.opencode/command/triage.md +4 -32
- package/dist/template/.opencode/dcp.jsonc +68 -68
- package/dist/template/.opencode/memory/_templates/README.md +35 -0
- package/dist/template/.opencode/memory/_templates/project/architecture.md +60 -0
- package/dist/template/.opencode/memory/_templates/project/commands.md +72 -0
- package/dist/template/.opencode/memory/_templates/project/conventions.md +68 -0
- package/dist/template/.opencode/memory/_templates/project/gotchas.md +41 -0
- package/dist/template/.opencode/memory/beads-workflow.md +30 -29
- package/dist/template/.opencode/memory/project/architecture.md +31 -50
- package/dist/template/.opencode/memory/project/commands.md +41 -22
- package/dist/template/.opencode/memory/project/conventions.md +39 -177
- package/dist/template/.opencode/memory/project/gotchas.md +21 -177
- package/dist/template/.opencode/memory/user.example.md +5 -0
- package/dist/template/.opencode/opencode.json +628 -579
- package/dist/template/.opencode/package.json +18 -21
- package/dist/template/.opencode/plugin/compaction.ts +79 -85
- package/dist/template/.opencode/plugin/env-ctx.ts +19 -19
- package/dist/template/.opencode/plugin/lib/notify.ts +41 -45
- package/dist/template/.opencode/plugin/lsp.ts +197 -200
- package/dist/template/.opencode/plugin/memory.ts +14 -112
- package/dist/template/.opencode/plugin/package.json +5 -5
- package/dist/template/.opencode/plugin/sessions.ts +1 -1
- package/dist/template/.opencode/plugin/skill-mcp.ts +486 -521
- package/dist/template/.opencode/plugin/truncator.ts +47 -50
- package/dist/template/.opencode/plugin/tsconfig.json +14 -14
- package/dist/template/.opencode/skill/chrome-devtools/mcp.json +17 -17
- package/dist/template/.opencode/skill/condition-based-waiting/SKILL.md +17 -12
- package/dist/template/.opencode/skill/condition-based-waiting/example.ts +63 -69
- package/dist/template/.opencode/skill/defense-in-depth/SKILL.md +14 -8
- package/dist/template/.opencode/skill/dispatching-parallel-agents/SKILL.md +14 -3
- package/dist/template/.opencode/skill/playwright/mcp.json +14 -14
- package/dist/template/.opencode/skill/receiving-code-review/SKILL.md +21 -8
- package/dist/template/.opencode/skill/requesting-code-review/review.md +14 -0
- package/dist/template/.opencode/skill/root-cause-tracing/SKILL.md +18 -4
- package/dist/template/.opencode/skill/source-code-research/SKILL.md +9 -7
- package/dist/template/.opencode/skill/test-driven-development/SKILL.md +49 -32
- package/dist/template/.opencode/skill/testing-anti-patterns/SKILL.md +40 -22
- package/dist/template/.opencode/skill/testing-skills-with-subagents/SKILL.md +46 -26
- package/dist/template/.opencode/skill/tool-priority/SKILL.md +117 -44
- package/dist/template/.opencode/skill/v0/SKILL.md +1 -7
- package/dist/template/.opencode/skill/verification-before-completion/SKILL.md +27 -19
- package/dist/template/.opencode/skill/writing-skills/anthropic-best-practices.md +171 -148
- package/dist/template/.opencode/skill/writing-skills/persuasion-principles.md +39 -6
- package/dist/template/.opencode/tool/memory-read.ts +44 -56
- package/dist/template/.opencode/tool/memory-search.ts +8 -291
- package/dist/template/.opencode/tool/memory-update.ts +47 -51
- package/dist/template/.opencode/tool/observation.ts +6 -180
- package/dist/template/.opencode/tsconfig.json +19 -19
- package/package.json +19 -15
- package/dist/template/.opencode/.background-tasks.json +0 -114
- package/dist/template/.opencode/.ralph-state.json +0 -12
- package/dist/template/.opencode/agent/build.md +0 -327
- package/dist/template/.opencode/agent/ninja.md +0 -351
- package/dist/template/.opencode/agent/planner.md +0 -281
- package/dist/template/.opencode/agent/rush.md +0 -223
- package/dist/template/.opencode/memory/handoffs/README.md +0 -83
- package/dist/template/.opencode/memory/observations/.gitkeep +0 -0
- package/dist/template/.opencode/memory/observations/2026-01-09-pattern-ampcode-mcp-json-includetools-pattern.md +0 -42
- package/dist/template/.opencode/memory/vector_db/memories.lance/_transactions/0-0d25ba80-ba3b-4209-9046-b45d6093b4da.txn +0 -0
- package/dist/template/.opencode/memory/vector_db/memories.lance/_versions/1.manifest +0 -0
- package/dist/template/.opencode/memory/vector_db/memories.lance/data/1111100101010101011010004a9ef34df6b29f36a9a53a2892.lance +0 -0
- package/dist/template/.opencode/tool/ast-grep.ts +0 -245
- package/dist/template/.opencode/tool/background.ts +0 -509
- package/dist/template/.opencode/tool/bd-inbox.ts +0 -110
- package/dist/template/.opencode/tool/bd-msg.ts +0 -62
- package/dist/template/.opencode/tool/bd-release.ts +0 -71
- package/dist/template/.opencode/tool/bd-reserve.ts +0 -121
- package/dist/template/.opencode/tool/memory-embed.ts +0 -183
- package/dist/template/.opencode/tool/memory-index.ts +0 -769
- package/dist/template/.opencode/tool/repo-map.ts +0 -451
|
@@ -1,245 +0,0 @@
|
|
|
1
|
-
/**
|
|
2
|
-
* AST-Grep Tool for OpenCode
|
|
3
|
-
* Semantic code search and replace using ast-grep - smarter than regex
|
|
4
|
-
*
|
|
5
|
-
* Inspired by oh-my-opencode's AST-Grep integration
|
|
6
|
-
* Requires: npm install -g @ast-grep/cli (or brew install ast-grep)
|
|
7
|
-
*/
|
|
8
|
-
|
|
9
|
-
import { exec } from "node:child_process";
|
|
10
|
-
import { promisify } from "node:util";
|
|
11
|
-
import { tool } from "@opencode-ai/plugin";
|
|
12
|
-
|
|
13
|
-
const execAsync = promisify(exec);
|
|
14
|
-
|
|
15
|
-
async function checkAstGrep(): Promise<boolean> {
|
|
16
|
-
try {
|
|
17
|
-
await execAsync("sg --version");
|
|
18
|
-
return true;
|
|
19
|
-
} catch {
|
|
20
|
-
return false;
|
|
21
|
-
}
|
|
22
|
-
}
|
|
23
|
-
|
|
24
|
-
export const astGrepSearch = tool({
|
|
25
|
-
description: `Semantic code search using AST patterns - smarter than regex.
|
|
26
|
-
Searches for code patterns structurally, ignoring formatting differences.
|
|
27
|
-
|
|
28
|
-
Examples:
|
|
29
|
-
- Find all console.log calls: "console.log($$$)"
|
|
30
|
-
- Find async functions: "async function $NAME($$$) { $$$ }"
|
|
31
|
-
- Find React useState: "const [$STATE, $SETTER] = useState($$$)"
|
|
32
|
-
- Find try-catch blocks: "try { $$$ } catch ($ERR) { $$$ }"
|
|
33
|
-
|
|
34
|
-
Pattern syntax:
|
|
35
|
-
- $NAME: matches any single AST node (identifier, expression, etc)
|
|
36
|
-
- $$$: matches zero or more nodes (for arguments, statements, etc)
|
|
37
|
-
- Literal code: matches exactly that code structure`,
|
|
38
|
-
|
|
39
|
-
args: {
|
|
40
|
-
pattern: tool.schema.string().describe("AST pattern to search for"),
|
|
41
|
-
path: tool.schema
|
|
42
|
-
.string()
|
|
43
|
-
.optional()
|
|
44
|
-
.describe("Directory or file to search (default: current directory)"),
|
|
45
|
-
language: tool.schema
|
|
46
|
-
.string()
|
|
47
|
-
.optional()
|
|
48
|
-
.describe(
|
|
49
|
-
"Language: typescript, javascript, python, rust, go, java, etc.",
|
|
50
|
-
),
|
|
51
|
-
json: tool.schema
|
|
52
|
-
.boolean()
|
|
53
|
-
.optional()
|
|
54
|
-
.describe("Output as JSON (default: false)"),
|
|
55
|
-
},
|
|
56
|
-
|
|
57
|
-
async execute(args) {
|
|
58
|
-
const hasAstGrep = await checkAstGrep();
|
|
59
|
-
if (!hasAstGrep) {
|
|
60
|
-
return `Error: ast-grep (sg) not installed.
|
|
61
|
-
|
|
62
|
-
Install via:
|
|
63
|
-
npm install -g @ast-grep/cli
|
|
64
|
-
# or
|
|
65
|
-
brew install ast-grep
|
|
66
|
-
# or
|
|
67
|
-
cargo install ast-grep`;
|
|
68
|
-
}
|
|
69
|
-
|
|
70
|
-
const searchPath = args.path || ".";
|
|
71
|
-
const outputFormat = args.json ? "--json" : "";
|
|
72
|
-
|
|
73
|
-
// Build command - escape pattern for shell
|
|
74
|
-
const escapedPattern = args.pattern.replace(/'/g, "'\"'\"'");
|
|
75
|
-
let cmd = `sg --pattern '${escapedPattern}'`;
|
|
76
|
-
|
|
77
|
-
if (args.language) {
|
|
78
|
-
cmd += ` --lang ${args.language}`;
|
|
79
|
-
}
|
|
80
|
-
|
|
81
|
-
if (outputFormat) {
|
|
82
|
-
cmd += ` ${outputFormat}`;
|
|
83
|
-
}
|
|
84
|
-
|
|
85
|
-
cmd += ` ${searchPath}`;
|
|
86
|
-
|
|
87
|
-
try {
|
|
88
|
-
const { stdout, stderr } = await execAsync(cmd, {
|
|
89
|
-
maxBuffer: 10 * 1024 * 1024, // 10MB buffer
|
|
90
|
-
timeout: 60000, // 60s timeout
|
|
91
|
-
});
|
|
92
|
-
|
|
93
|
-
if (stderr && !stdout) {
|
|
94
|
-
return `Warning: ${stderr}`;
|
|
95
|
-
}
|
|
96
|
-
|
|
97
|
-
if (!stdout.trim()) {
|
|
98
|
-
return `No matches found for pattern: ${args.pattern}`;
|
|
99
|
-
}
|
|
100
|
-
|
|
101
|
-
// Count matches
|
|
102
|
-
const lines = stdout.trim().split("\n");
|
|
103
|
-
let matchCount: number;
|
|
104
|
-
if (args.json) {
|
|
105
|
-
try {
|
|
106
|
-
matchCount = JSON.parse(stdout).length;
|
|
107
|
-
} catch {
|
|
108
|
-
matchCount = lines.length;
|
|
109
|
-
}
|
|
110
|
-
} else {
|
|
111
|
-
matchCount = lines.filter((l) => l.includes(":")).length;
|
|
112
|
-
}
|
|
113
|
-
|
|
114
|
-
return `Found ${matchCount} matches:\n\n${stdout}`;
|
|
115
|
-
} catch (error) {
|
|
116
|
-
const err = error as { message?: string; stderr?: string };
|
|
117
|
-
if (err.stderr?.includes("no files found")) {
|
|
118
|
-
return `No files found for language: ${args.language || "auto-detected"}`;
|
|
119
|
-
}
|
|
120
|
-
return `Error: ${err.message || err.stderr || "Unknown error"}`;
|
|
121
|
-
}
|
|
122
|
-
},
|
|
123
|
-
});
|
|
124
|
-
|
|
125
|
-
export const astGrepReplace = tool({
|
|
126
|
-
description: `Semantic code replacement using AST patterns - safe refactoring.
|
|
127
|
-
Replaces code patterns structurally, preserving formatting where possible.
|
|
128
|
-
|
|
129
|
-
Examples:
|
|
130
|
-
- Rename function: pattern="oldFunc($$$)" rewrite="newFunc($$$)"
|
|
131
|
-
- Add await: pattern="fetch($URL)" rewrite="await fetch($URL)"
|
|
132
|
-
- Wrap in try-catch: pattern="$EXPR" rewrite="try { $EXPR } catch (e) { console.error(e) }"
|
|
133
|
-
|
|
134
|
-
Use $NAME in rewrite to reference captured nodes from pattern.`,
|
|
135
|
-
|
|
136
|
-
args: {
|
|
137
|
-
pattern: tool.schema.string().describe("AST pattern to match"),
|
|
138
|
-
rewrite: tool.schema.string().describe("Replacement pattern"),
|
|
139
|
-
path: tool.schema
|
|
140
|
-
.string()
|
|
141
|
-
.optional()
|
|
142
|
-
.describe("Directory or file to modify (default: current directory)"),
|
|
143
|
-
language: tool.schema
|
|
144
|
-
.string()
|
|
145
|
-
.optional()
|
|
146
|
-
.describe(
|
|
147
|
-
"Language: typescript, javascript, python, rust, go, java, etc.",
|
|
148
|
-
),
|
|
149
|
-
dryRun: tool.schema
|
|
150
|
-
.boolean()
|
|
151
|
-
.optional()
|
|
152
|
-
.describe("Preview changes without applying (default: true)"),
|
|
153
|
-
},
|
|
154
|
-
|
|
155
|
-
async execute(args) {
|
|
156
|
-
const hasAstGrep = await checkAstGrep();
|
|
157
|
-
if (!hasAstGrep) {
|
|
158
|
-
return `Error: ast-grep (sg) not installed.
|
|
159
|
-
|
|
160
|
-
Install via:
|
|
161
|
-
npm install -g @ast-grep/cli
|
|
162
|
-
# or
|
|
163
|
-
brew install ast-grep`;
|
|
164
|
-
}
|
|
165
|
-
|
|
166
|
-
const searchPath = args.path || ".";
|
|
167
|
-
const dryRun = args.dryRun !== false; // Default to dry run for safety
|
|
168
|
-
|
|
169
|
-
// Build command - escape patterns for shell
|
|
170
|
-
const escapedPattern = args.pattern.replace(/'/g, "'\"'\"'");
|
|
171
|
-
const escapedRewrite = args.rewrite.replace(/'/g, "'\"'\"'");
|
|
172
|
-
let cmd = `sg --pattern '${escapedPattern}' --rewrite '${escapedRewrite}'`;
|
|
173
|
-
|
|
174
|
-
if (args.language) {
|
|
175
|
-
cmd += ` --lang ${args.language}`;
|
|
176
|
-
}
|
|
177
|
-
|
|
178
|
-
if (dryRun) {
|
|
179
|
-
cmd += " --json"; // Use JSON output for dry run preview
|
|
180
|
-
} else {
|
|
181
|
-
cmd += " --update-all"; // Actually apply changes
|
|
182
|
-
}
|
|
183
|
-
|
|
184
|
-
cmd += ` ${searchPath}`;
|
|
185
|
-
|
|
186
|
-
try {
|
|
187
|
-
const { stdout, stderr } = await execAsync(cmd, {
|
|
188
|
-
maxBuffer: 10 * 1024 * 1024,
|
|
189
|
-
timeout: 120000, // 2 min for replacements
|
|
190
|
-
});
|
|
191
|
-
|
|
192
|
-
if (stderr && !stdout) {
|
|
193
|
-
return `Warning: ${stderr}`;
|
|
194
|
-
}
|
|
195
|
-
|
|
196
|
-
if (!stdout.trim()) {
|
|
197
|
-
return `No matches found for pattern: ${args.pattern}`;
|
|
198
|
-
}
|
|
199
|
-
|
|
200
|
-
if (dryRun) {
|
|
201
|
-
// Parse and format dry run output
|
|
202
|
-
try {
|
|
203
|
-
const matches = JSON.parse(stdout) as Array<{
|
|
204
|
-
file?: string;
|
|
205
|
-
range?: { start?: { line?: number } };
|
|
206
|
-
text?: string;
|
|
207
|
-
replacement?: string;
|
|
208
|
-
}>;
|
|
209
|
-
const count = matches.length;
|
|
210
|
-
|
|
211
|
-
let preview = `## Dry Run: ${count} potential replacement(s)\n\n`;
|
|
212
|
-
preview += `Pattern: \`${args.pattern}\`\n`;
|
|
213
|
-
preview += `Rewrite: \`${args.rewrite}\`\n\n`;
|
|
214
|
-
|
|
215
|
-
for (const match of matches.slice(0, 10)) {
|
|
216
|
-
preview += `### ${match.file || "unknown"}:${match.range?.start?.line || "?"}\n`;
|
|
217
|
-
preview += "```\n";
|
|
218
|
-
preview += `- ${match.text || ""}\n`;
|
|
219
|
-
preview += `+ ${match.replacement || args.rewrite}\n`;
|
|
220
|
-
preview += "```\n\n";
|
|
221
|
-
}
|
|
222
|
-
|
|
223
|
-
if (count > 10) {
|
|
224
|
-
preview += `... and ${count - 10} more matches\n`;
|
|
225
|
-
}
|
|
226
|
-
|
|
227
|
-
preview += "\n**To apply:** Run again with dryRun: false";
|
|
228
|
-
return preview;
|
|
229
|
-
} catch {
|
|
230
|
-
return `Dry run preview:\n${stdout}`;
|
|
231
|
-
}
|
|
232
|
-
}
|
|
233
|
-
|
|
234
|
-
// Actual replacement
|
|
235
|
-
const lines = stdout.trim().split("\n");
|
|
236
|
-
return `Applied ${lines.length} replacement(s):\n\n${stdout}`;
|
|
237
|
-
} catch (error) {
|
|
238
|
-
const err = error as { message?: string; stderr?: string };
|
|
239
|
-
return `Error: ${err.message || err.stderr || "Unknown error"}`;
|
|
240
|
-
}
|
|
241
|
-
},
|
|
242
|
-
});
|
|
243
|
-
|
|
244
|
-
// Default export for single-tool registration
|
|
245
|
-
export default astGrepSearch;
|