opencodekit 0.21.8 → 0.21.10

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.
Files changed (34) hide show
  1. package/dist/index.js +1 -1
  2. package/dist/template/.opencode/.template-manifest.json +0 -3
  3. package/dist/template/.opencode/AGENTS.md +1 -13
  4. package/dist/template/.opencode/agent/build.md +1 -1
  5. package/dist/template/.opencode/agent/explore.md +15 -15
  6. package/dist/template/.opencode/agent/general.md +2 -2
  7. package/dist/template/.opencode/agent/plan.md +3 -3
  8. package/dist/template/.opencode/agent/review.md +2 -2
  9. package/dist/template/.opencode/agent/scout.md +34 -15
  10. package/dist/template/.opencode/command/design.md +4 -4
  11. package/dist/template/.opencode/command/init-context.md +7 -7
  12. package/dist/template/.opencode/command/review-codebase.md +1 -1
  13. package/dist/template/.opencode/command/ship.md +1 -1
  14. package/dist/template/.opencode/dcp.jsonc +18 -46
  15. package/dist/template/.opencode/memory/project/user.md +1 -2
  16. package/dist/template/.opencode/opencode.json +10 -332
  17. package/dist/template/.opencode/plugin/lib/capture.ts +1 -1
  18. package/dist/template/.opencode/plugin/lib/db/schema.ts +102 -9
  19. package/dist/template/.opencode/plugin/lib/memory-db.ts +41 -17
  20. package/dist/template/.opencode/plugin/lib/operation-log.ts +1 -0
  21. package/dist/template/.opencode/plugin/sessions.ts +37 -8
  22. package/dist/template/.opencode/skill/agent-evals/SKILL.md +1 -1
  23. package/dist/template/.opencode/skill/code-search-patterns/SKILL.md +49 -78
  24. package/dist/template/.opencode/skill/context-initialization/SKILL.md +5 -5
  25. package/dist/template/.opencode/skill/rtk-command-compression/SKILL.md +1 -1
  26. package/dist/template/.opencode/tool/context7.ts +1 -1
  27. package/dist/template/.opencode/tool/grepsearch.ts +1 -1
  28. package/package.json +2 -2
  29. package/dist/template/.opencode/memory.db +0 -0
  30. package/dist/template/.opencode/memory.db-shm +0 -0
  31. package/dist/template/.opencode/memory.db-wal +0 -0
  32. package/dist/template/.opencode/opencode.json.tui-migration.bak +0 -1380
  33. package/dist/template/.opencode/plugin/notification.ts.bak +0 -64
  34. package/dist/template/.opencode/pnpm-lock.yaml +0 -287
@@ -6,16 +6,42 @@
6
6
  * - find_sessions: Multi-word AND search with relevance ranking
7
7
  * - read_session: Full transcript with keyword filtering
8
8
  *
9
- * Requires Bun runtime (uses bun:sqlite for zero-dep DB access).
9
+ * Uses Node's built-in node:sqlite module for zero-dep DB access.
10
10
  */
11
11
 
12
- import { Database } from "bun:sqlite";
13
12
  import { spawnSync } from "node:child_process";
13
+ import { createRequire } from "node:module";
14
14
  import { join } from "node:path";
15
15
  import type { Plugin } from "@opencode-ai/plugin";
16
16
  import { tool } from "@opencode-ai/plugin/tool";
17
17
 
18
- // --- Configuration ---
18
+ type SqlParam = string | number | bigint | null | Uint8Array;
19
+ type StatementSyncLike = {
20
+ get(...params: SqlParam[]): unknown;
21
+ all(...params: SqlParam[]): unknown[];
22
+ };
23
+ type DatabaseSyncLike = {
24
+ prepare(sql: string): StatementSyncLike;
25
+ close(): void;
26
+ };
27
+ type DatabaseSyncConstructor = new (
28
+ dbPath: string,
29
+ options?: { readOnly?: boolean; timeout?: number },
30
+ ) => DatabaseSyncLike;
31
+
32
+ const require = createRequire(import.meta.url);
33
+ let DatabaseSyncCtor: DatabaseSyncConstructor | null = null;
34
+
35
+ function getDatabaseSyncConstructor(): DatabaseSyncConstructor {
36
+ if (!DatabaseSyncCtor) {
37
+ const sqlite = require("node:sqlite") as {
38
+ DatabaseSync: DatabaseSyncConstructor;
39
+ };
40
+ DatabaseSyncCtor = sqlite.DatabaseSync;
41
+ }
42
+ return DatabaseSyncCtor;
43
+ }
44
+
19
45
 
20
46
  const SEARCH_CONFIG = {
21
47
  roles: ["user", "assistant"],
@@ -66,13 +92,16 @@ const resolveDbPath = (): string => {
66
92
  /** Resolved once at module load — no per-request resolution cost. */
67
93
  const DEFAULT_DB_PATH = resolveDbPath();
68
94
 
69
- const openReadonlyDb = (): { db: Database | null; error: string | null } => {
95
+ const openReadonlyDb = (): {
96
+ db: DatabaseSyncLike | null;
97
+ error: string | null;
98
+ } => {
70
99
  try {
100
+ const DatabaseSync = getDatabaseSyncConstructor();
71
101
  return {
72
- db: new Database(DEFAULT_DB_PATH, {
73
- readonly: true,
74
- create: false,
75
- strict: true,
102
+ db: new DatabaseSync(DEFAULT_DB_PATH, {
103
+ readOnly: true,
104
+ timeout: 5000,
76
105
  }),
77
106
  error: null,
78
107
  };
@@ -124,7 +124,7 @@ A single run can be lucky. For a skill you're seriously evaluating:
124
124
  | Anti-pattern avoidance | `grep` for the banned pattern → expect 0 |
125
125
  | Required output shape | JSON schema validation, presence of required sections |
126
126
  | Code correctness | run the code, run its tests, check exit code |
127
- | Behavior change | call site count via `tilth_search`, file existence, line counts |
127
+ | Behavior change | call site count via `srcwalk callers`, file existence, line counts |
128
128
  | UI / visual | Playwright screenshot + pixel diff against expected, or DOM query |
129
129
  | Refusal / safety | grep for forbidden phrases or correct refusal pattern |
130
130
 
@@ -1,6 +1,6 @@
1
1
  ---
2
2
  name: code-search-patterns
3
- description: Use when navigating unfamiliar code with search-first patterns, combining built-in/LSP navigation with tilth MCP (main agent) and tilth CLI (subagents)
3
+ description: Use when navigating unfamiliar code with search-first patterns, combining built-in/LSP navigation with srcwalk CLI
4
4
  version: 1.0.0
5
5
  tags: [workflow, code-quality, context, subagent]
6
6
  dependencies: []
@@ -8,10 +8,10 @@ dependencies: []
8
8
 
9
9
  # Code Search Patterns
10
10
 
11
- Unified navigation skill for fast, low-waste code understanding across both execution modes:
11
+ Unified navigation skill for fast, low-waste code understanding:
12
12
 
13
- - **Main agent**: built-in tools + LSP + tilth MCP
14
- - **Subagents**: Bash + `npx -y tilth` CLI
13
+ - **Main agent**: built-in tools + LSP + srcwalk CLI
14
+ - **Subagents**: Bash + `srcwalk` CLI
15
15
 
16
16
  This skill merges practical navigation heuristics with concrete tool usage so you can locate behavior, trace impact, and edit safely with fewer calls.
17
17
 
@@ -42,7 +42,7 @@ Start with symbol/content search to find exact locations, then read only the nee
42
42
  - **Good**: `search -> targeted read`
43
43
  - **Avoid**: `read many files -> search later`
44
44
 
45
- Use LSP (`findReferences`, `outgoingCalls`) or tilth search first; read deep only after narrowing scope.
45
+ Use LSP (`findReferences`, `outgoingCalls`) or srcwalk search first; read deep only after narrowing scope.
46
46
 
47
47
  ### 2) Multi-Symbol Search
48
48
 
@@ -65,7 +65,7 @@ Re-read only when you need:
65
65
  Before renaming/removing/changing signatures, inspect downstream impact first.
66
66
 
67
67
  - LSP: `findReferences`, `incomingCalls`
68
- - tilth: `tilth_tilth_deps` or `--deps`
68
+ - srcwalk: `srcwalk impact <symbol>` or `srcwalk callers <symbol>`
69
69
 
70
70
  Then apply edits from dependents inward.
71
71
 
@@ -74,7 +74,7 @@ Then apply edits from dependents inward.
74
74
  Prefer nearby package/module scope first.
75
75
 
76
76
  - built-in search: constrain `path`
77
- - tilth: pass `scope` / `context`
77
+ - srcwalk: pass `--scope <dir>` to restrict the scan area
78
78
 
79
79
  Locality reduces irrelevant matches and token churn.
80
80
 
@@ -83,7 +83,7 @@ Locality reduces irrelevant matches and token churn.
83
83
  For large files, inspect structure first (symbols/outline), then read only target sections.
84
84
 
85
85
  - LSP: `documentSymbol`
86
- - tilth read: smart outline by default, then section drill-in
86
+ - srcwalk read: smart outline by default, then section drill-in
87
87
 
88
88
  ### 7) Follow Call Chain, Not File Tree
89
89
 
@@ -91,34 +91,18 @@ Start at entry behavior and walk calls (`definition -> outgoing -> next definiti
91
91
 
92
92
  This exposes real execution flow with fewer reads.
93
93
 
94
- ## tilth MCP (Main Agent)
94
+ ## srcwalk CLI
95
95
 
96
- Use MCP variants when available in the main agent session:
97
-
98
- - `tilth_tilth_search`
99
- - `tilth_tilth_read`
100
- - `tilth_tilth_files`
101
- - `tilth_tilth_deps`
102
-
103
- ### Built-in/LSP vs tilth MCP (when to choose which)
104
-
105
- | Need | Built-in / LSP | Prefer tilth MCP when | Why tilth helps |
106
- | ----------------------- | -------------------------------------- | ----------------------------------------------------------- | ----------------------------------- |
107
- | Find symbols/usages | `grep` / `lsp.findReferences` | You want definitions + usages + expanded source in one call | Reduces search+read round trips |
108
- | Read file content | `read` | File is large or you only need structure first | Smart outline + section targeting |
109
- | List candidate files | `glob` | You want quick glob results with token-aware relevance | Faster triage for large directories |
110
- | Pre-change impact check | `lsp.incomingCalls` + manual follow-up | You need import + dependent view before breaking change | Single blast-radius view via deps |
111
-
112
- Guideline: if tilth MCP is active, use it as default for navigation; fall back to built-in/LSP when you need language-server-specific semantics or exact editor-position operations.
113
-
114
- ## tilth CLI (Subagents)
115
-
116
- ### Why this exists
117
-
118
- Subagents typically cannot call MCP tools directly. They can still use tilth through Bash:
96
+ `srcwalk` is available to all agents (main agent and subagents) via Bash. It combines grep + tree-sitter AST into one CLI tool.
119
97
 
120
98
  ```bash
121
- npx -y tilth <query> [flags]
99
+ srcwalk guide # Print agent routing policy (run once per session)
100
+ srcwalk find <symbol> # Symbol search (definitions + usages)
101
+ srcwalk <file> # Smart file read (outline for large files)
102
+ srcwalk map # Codebase structural overview
103
+ srcwalk files '<glob>' # Find files by pattern
104
+ srcwalk callers <sym> # Reverse call graph
105
+ srcwalk impact <sym> # Blast-radius heuristic
122
106
  ```
123
107
 
124
108
  ### Auto-detection
@@ -127,103 +111,90 @@ npx -y tilth <query> [flags]
127
111
  | --------------------------------- | ------------------------------------ |
128
112
  | Existing file path (`src/foo.ts`) | Read file (smart outline/full) |
129
113
  | Identifier (`initCommand`) | Symbol search (definitions + usages) |
130
- | Glob (`*.test.ts`) | List files |
131
- | Plain text / phrase | Content search |
132
-
133
- Use `--kind` to force a specific mode when needed.
114
+ | `find <symbol>` | Explicit symbol search |
115
+ | `files <glob>` | File discovery |
134
116
 
135
117
  ### Core operations
136
118
 
137
119
  #### 1) Read file
138
120
 
139
121
  ```bash
140
- npx -y tilth src/index.ts
141
- npx -y tilth src/index.ts --full
142
- npx -y tilth src/index.ts --section 45-89
122
+ srcwalk src/index.ts
123
+ srcwalk src/index.ts --full
124
+ srcwalk src/index.ts --section 45-89
143
125
  ```
144
126
 
145
127
  #### 2) Search symbols
146
128
 
147
129
  ```bash
148
- npx -y tilth initCommand --scope src/
149
- npx -y tilth "initCommand,detectMode" --scope src/
130
+ srcwalk find initCommand --scope src/
131
+ srcwalk find "initCommand,detectMode" --scope src/
150
132
  ```
151
133
 
152
134
  #### 3) Search text/regex
153
135
 
154
136
  ```bash
155
- npx -y tilth --kind content "TODO" --scope src/
156
- npx -y tilth --kind regex "/TODO.*fix/" --scope src/
137
+ srcwalk find "TODO" --scope src/
138
+ srcwalk find "/TODO.*fix/" --scope src/
157
139
  ```
158
140
 
159
141
  #### 4) Find callers
160
142
 
161
143
  ```bash
162
- npx -y tilth --kind callers initCommand --scope src/
144
+ srcwalk callers initCommand --scope src/
163
145
  ```
164
146
 
165
147
  #### 5) List files
166
148
 
167
149
  ```bash
168
- npx -y tilth "*.test.ts" --scope src/
150
+ srcwalk files "*.test.ts" --scope src/
169
151
  ```
170
152
 
171
- #### 6) Blast radius / deps
153
+ #### 6) Blast radius
172
154
 
173
155
  ```bash
174
- npx -y tilth --deps src/commands/init.ts --scope src/
156
+ srcwalk impact initCommand --scope src/
157
+ srcwalk callers initCommand --scope src/
175
158
  ```
176
159
 
177
160
  #### 7) Codebase map
178
161
 
179
162
  ```bash
180
- npx -y tilth --map --scope src/
163
+ srcwalk map --scope src/
181
164
  ```
182
165
 
183
166
  ### Useful flags
184
167
 
185
- | Flag | Purpose | Example |
186
- | ----------------- | ------------------------------ | ---------------------------- | ------------------- | ----------------- | ---------------- |
187
- | `--scope <dir>` | Restrict scan area | `--scope src/commands/` |
188
- | `--section <range | heading>` | Targeted file slice | `--section 120-180` |
189
- | `--full` | Force full file output | `--full` |
190
- | `--budget <n>` | Limit output size | `--budget 2000` |
191
- | `--json` | Machine-readable output | `--json` |
192
- | `--map` | Structural project skeleton | `--map --scope src/` |
193
- | `--kind <symbol | content | regex | callers>` | Force search mode | `--kind callers` |
194
- | `--deps <file>` | Import/dependent blast radius | `--deps src/utils/errors.ts` |
195
- | `--expand <n>` | Expand top matches with source | `--expand 3` |
196
-
197
- ### MCP vs CLI
198
-
199
- | Capability | MCP (main agent) | CLI (subagents) |
200
- | ---------------------------- | -------------------------------------------------- | ------------------------------------------ |
201
- | Access mode | Tool call | Bash command |
202
- | Session dedup/context carry | Yes | No |
203
- | Hash-anchored edit flow | Yes (via MCP edit tools) | No |
204
- | Symbol/content/regex/callers | Yes | Yes |
205
- | Deps/blast-radius | Yes | Yes |
206
- | Codebase map | Limited by toolset | Yes (`--map`) |
207
- | Best for | Interactive main-agent navigation + edit workflows | Subagent discovery/exploration without MCP |
168
+ | Flag | Purpose | Example |
169
+ | ----------------------- | --------------------------------------------- | ----------------------------------- |
170
+ | `--scope <dir>` | Restrict scan area | `--scope src/commands/` |
171
+ | `--section <range\|sym>` | Targeted file slice (line range or symbol) | `--section 120-180`, `--section fn` |
172
+ | `--full` | Force full file output (no outline) | `--full` |
173
+ | `--budget <n>` | Limit output token size | `--budget 2000` |
174
+ | `--json` | Machine-readable output | `--json` |
175
+ | `--filter <qualifiers>` | Filter find results by field:value | `--filter kind:fn` |
176
+ | `--glob <pattern>` | File pattern filter within find | `--glob "*.ts"` |
177
+ | `--expand[=<n>]` | Inline source for top N matches | `--expand 3` |
178
+ | `--depth <n>` | Depth for callers/callees traversal | `--depth 2` |
208
179
 
209
180
  ### Example subagent dispatch
210
181
 
211
182
  ```ts
212
183
  task({
213
184
  subagent_type: "general",
214
- prompt: `Use tilth CLI via Bash for navigation.
185
+ prompt: `Use srcwalk via Bash for navigation.
215
186
 
216
187
  1) Locate symbol and usages:
217
- npx -y tilth initCommand --scope src/
188
+ srcwalk find initCommand --scope src/
218
189
 
219
190
  2) Find callers:
220
- npx -y tilth --kind callers initCommand --scope src/
191
+ srcwalk callers initCommand --scope src/
221
192
 
222
193
  3) Check blast radius before edits:
223
- npx -y tilth --deps src/commands/init.ts --scope src/
194
+ srcwalk impact initCommand --scope src/
224
195
 
225
196
  4) Read only the relevant section:
226
- npx -y tilth src/commands/init.ts --section 500-620
197
+ srcwalk src/commands/init.ts --section 500-620
227
198
 
228
199
  Then implement the requested change with minimal file edits.`,
229
200
  });
@@ -249,5 +220,5 @@ Target heuristic: understand a symbol and its direct impact in **≤3 calls** wh
249
220
  | Serially tracing one function at a time | Multi-symbol search + callers/deps |
250
221
  | Ignoring blast radius before API/signature edits | Run references/incoming/deps first |
251
222
  | Unscoped repository-wide search | Use `path`/`--scope` to localize |
252
- | Using CLI defaults when mode is ambiguous | Force with `--kind` |
223
+ | Using CLI defaults when mode is ambiguous | Use explicit subcommand (`find`, `files`, `callers`) or `--filter kind:<label>` |
253
224
  | Overusing `--full` on large files | Outline first, then `--section` |
@@ -21,9 +21,9 @@ dependencies: []
21
21
 
22
22
  ### 1. Verify Templates
23
23
 
24
- ```typescript
25
- tilth_tilth_files({ pattern: "*.md", scope: ".opencode/memory/_templates" });
26
- // Required templates: project.md, roadmap.md, state.md
24
+ ```bash
25
+ srcwalk files "*.md" --scope .opencode/memory/_templates
26
+ # Required templates: project.md, roadmap.md, state.md
27
27
  ```
28
28
 
29
29
  Stop if missing.
@@ -62,8 +62,8 @@ Skip if `--skip-questions` flag set.
62
62
 
63
63
  ### 4. Verify
64
64
 
65
- ```typescript
66
- tilth_tilth_files({ pattern: "*.md", scope: ".opencode/memory/project" });
65
+ ```bash
66
+ srcwalk files "*.md" --scope .opencode/memory/project
67
67
  ```
68
68
 
69
69
  Report created files with their injection status (auto-injected vs on-demand).
@@ -22,7 +22,7 @@ Core rule: **opt in explicitly, verify rewrites, preserve raw evidence when corr
22
22
 
23
23
  ## When NOT to Use
24
24
 
25
- - Code inspection or editing: prefer `tilth_tilth_read`, `tilth_tilth_search`, LSP, Read, Grep, and Edit.
25
+ - Code inspection or editing: prefer `srcwalk find`/`srcwalk <path>`, LSP, Read, Grep, and Edit.
26
26
  - Full verification evidence is required and compressed summaries would hide diagnostics.
27
27
  - The user has not approved installing binaries, changing global OpenCode config, or adding plugins.
28
28
 
@@ -28,7 +28,7 @@ WHEN: Looking up library APIs, checking function signatures, finding usage examp
28
28
  SKIP: Searching your own codebase (use grep/LSP), general web research (use websearch).
29
29
 
30
30
  Common mistakes:
31
- - DON'T search for internal project code (use grep/tilth instead)
31
+ - DON'T search for internal project code (use grep/srcwalk instead)
32
32
  - DON'T guess library versions — always resolve first, then query
33
33
  - DON'T use for general web research (use websearch instead)
34
34
 
@@ -18,7 +18,7 @@ export default tool({
18
18
  description: `Search real-world code examples from GitHub repositories via grep.app. Replaces asking "how do others use X?" — use this for finding production patterns and real-world API usage.
19
19
 
20
20
  WHEN: Implementing unfamiliar APIs, looking for production patterns, understanding library integrations.
21
- SKIP: Searching your own codebase (use grep/tilth), looking up docs (use context7), general research (use websearch).
21
+ SKIP: Searching your own codebase (use grep/srcwalk), looking up docs (use context7), general research (use websearch).
22
22
 
23
23
  Common mistakes:
24
24
  - DON'T search for keywords like "react tutorial" — search for literal code: "useState("
package/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "opencodekit",
3
- "version": "0.21.8",
3
+ "version": "0.21.10",
4
4
  "description": "CLI tool for bootstrapping and managing OpenCodeKit projects",
5
5
  "keywords": [
6
6
  "agents",
@@ -34,7 +34,7 @@
34
34
  },
35
35
  "scripts": {
36
36
  "dev": "tsx src/index.ts",
37
- "build": "tsdown && mkdir -p dist/template && rsync -av --exclude=node_modules --exclude=dist --exclude=.git --exclude=coverage --exclude=.next --exclude=.turbo --exclude=logs --exclude=package-lock.json .opencode/ dist/template/.opencode/",
37
+ "build": "tsdown && mkdir -p dist/template && rsync -av --exclude=node_modules --exclude=dist --exclude=.git --exclude=coverage --exclude=.next --exclude=.turbo --exclude=logs --exclude=package-lock.json --exclude='plugin/*.bak' --exclude=memory.db --exclude=memory.db-shm --exclude=memory.db-wal --exclude='memory.db.corrupt.*' --exclude=memory-recovery.log .opencode/ dist/template/.opencode/",
38
38
  "typecheck": "tsgo --noEmit",
39
39
  "test": "vitest run",
40
40
  "test:watch": "vitest",
Binary file