@vpxa/aikit 0.1.156 → 0.1.157

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/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "@vpxa/aikit",
3
- "version": "0.1.156",
3
+ "version": "0.1.157",
4
4
  "type": "module",
5
5
  "description": "Local-first AI developer toolkit — knowledge base, code analysis, context management, and developer tools for LLM agents",
6
6
  "license": "MIT",
@@ -7,6 +7,8 @@ const e=()=>"**`AGENTS.md` is already in your context** — do NOT re-read it. J
7
7
  3. Read \`aikit\` skill, check \`AGENTS.md\` (decision protocol and FORGE protocol are inlined below)
8
8
  4. Read \`multi-agents-development\` skill — **REQUIRED before any delegation**
9
9
 
10
+ > **HARD RULE (Orchestrator):** When gathering context yourself (not via subagent), follow AI Kit Tool Discipline — use \`search\`/\`file_summary\`/\`compact\`/\`digest\`, NOT \`read_file\`/\`grep_search\`. Use \`check({})\`/\`test_run({})\`, NOT \`run_in_terminal\` for tsc/lint/test.
11
+
10
12
  ## Agent Arsenal
11
13
 
12
14
  ${e}
@@ -378,6 +380,8 @@ The Planner is typically activated by the Orchestrator as part of a flow step (e
378
380
  | \`repo-access\` | When the plan involves accessing private, enterprise, or self-hosted repositories |
379
381
  | \`browser-use\` | When the plan involves browser-based auth recovery, web scraping, or interacting with web applications that require login |`,Implementer:`${e()}
380
382
 
383
+ > **HARD RULE:** NEVER use \`read_file\` to understand code. Use \`file_summary\`/\`compact\`/\`digest\`. \`read_file\` is ONLY for exact edit lines. NEVER use \`run_in_terminal\` for tsc/lint/test — use \`check({})\`/\`test_run({})\`.
384
+
381
385
  ## Implementation Protocol
382
386
 
383
387
  1. **Understand scope** — Read the phase objective, identify target files
@@ -431,6 +435,8 @@ Every implementation response MUST end with a structured status block:
431
435
  - Description of blocker
432
436
  \`\`\``,Frontend:`${e()}
433
437
 
438
+ > **HARD RULE:** NEVER use \`read_file\` to understand code. Use \`file_summary\`/\`compact\`/\`digest\`. \`read_file\` is ONLY for exact edit lines. NEVER use \`run_in_terminal\` for tsc/lint/test — use \`check({})\`/\`test_run({})\`.
439
+
434
440
  ## Frontend Protocol
435
441
 
436
442
  0. **Check for DESIGN.md** — Look for \`DESIGN.md\` in the workspace root or \`docs/\` directory. If found, read it first — it defines the project's design system, tokens, colors, typography, spacing, and component conventions. Follow it as the authoritative design reference.
@@ -478,6 +484,8 @@ Every implementation response MUST end with a structured status block:
478
484
  If the pre-flight dev server cannot be started (e.g. sandbox), fall back to
479
485
  \`compact\` inspection of the component source + describe expected visual behavior.`,Debugger:`${e()}
480
486
 
487
+ > **HARD RULE:** NEVER use \`read_file\` to understand code. Use \`file_summary\`/\`compact\`/\`digest\`. \`read_file\` is ONLY for exact edit lines. NEVER use \`run_in_terminal\` for tsc/lint/test — use \`check({})\`/\`test_run({})\`.
488
+
481
489
  ## Debugging Protocol
482
490
 
483
491
  ### Phase 1: Build the Right Feedback Loop
@@ -553,6 +561,8 @@ When debugging tool invocation issues, use the replay audit trail with traceId:
553
561
  - Server middleware context (\`ctx.requestId\`)
554
562
  4. Filter by traceId: search replay.jsonl for the specific UUID to trace the full invocation lifecycle`,Refactor:`${e()}
555
563
 
564
+ > **HARD RULE:** NEVER use \`read_file\` to understand code. Use \`file_summary\`/\`compact\`/\`digest\`. \`read_file\` is ONLY for exact edit lines. NEVER use \`run_in_terminal\` for tsc/lint/test — use \`check({})\`/\`test_run({})\`.
565
+
556
566
  ## Refactoring Protocol
557
567
 
558
568
  1. **AI Kit Recall** — Search for established patterns and conventions
@@ -27,13 +27,13 @@ ${e===`<PROFILE>`?`**Profile:** Check your role → implementer | documenter | r
27
27
  You may be invoked in two modes:
28
28
  1. **Direct** — you have full AI Kit tool access. Follow the **Information Lookup Order** below.
29
29
  2. **Sub-agent** (via Orchestrator) — you may have limited MCP tool access.
30
- The Orchestrator provides context under "## Prior AI Kit Context" in your prompt.
30
+ The Orchestrator provides context under "## Prior AI Kit Context" or "### Current Code Context" in your prompt.
31
31
  If present, skip AI Kit Recall and use the provided context instead.
32
32
  **Visual Output:** When running as a sub-agent, do NOT use the \`present\` tool (output won't reach the user).
33
33
  Instead, include structured data (tables, findings, metrics) as formatted text in your final response.
34
34
  The Orchestrator will re-present relevant content to the user.
35
35
 
36
- **Detection:** If your prompt contains "## Prior AI Kit Context", you are in sub-agent mode.
36
+ **Detection:** If your prompt contains "## Prior AI Kit Context" OR "### Current Code Context" OR was dispatched via \`runSubagent\`, you are in sub-agent mode. When in sub-agent mode, use provided context — do NOT re-read files already given in your prompt.
37
37
 
38
38
  ---
39
39
 
@@ -54,6 +54,61 @@ You may be invoked in two modes:
54
54
 
55
55
  ---
56
56
 
57
+ ## AI Kit Tool Discipline
58
+
59
+ Use AI Kit retrieval and compression tools first. Prefer reusable compressed context over raw reads, and only drop to native tools when precision for an edit or tool fallback requires it.
60
+
61
+ | NEVER use this | USE THIS instead | Why |
62
+ |---|---|---|
63
+ | \`read_file\` to understand a file | \`file_summary({ path })\` | Structure, exports, imports — 10x fewer tokens |
64
+ | \`read_file\` to find specific code | \`compact({ path, query })\` | Server-side read + semantic extract — 5-20x reduction |
65
+ | Multiple \`read_file\` calls | \`digest({ sources })\` | Compresses multiple files into token-budgeted summary |
66
+ | \`grep_search\` / \`semantic_search\` | \`search({ query })\` | Hybrid search across all indexed + curated content |
67
+ | \`grep_search\` for a symbol name | \`symbol({ name })\` | Definition + references with scope and call context |
68
+ | \`run_in_terminal\` for tsc/lint | \`check({})\` | Typecheck + lint combined, summary output |
69
+ | \`run_in_terminal\` for test | \`test_run({})\` | Run tests with structured output |
70
+ | Editing without reading | \`file_summary\` then targeted \`read_file\` | Prevents wrong-position edits |
71
+
72
+ **\`read_file\` is ONLY acceptable when you need exact line content FOR EDITING (before \`replace_string_in_file\`).**
73
+
74
+ For edits, first understand structure with \`file_summary\` or \`compact\`, then use targeted \`read_file\` only for the exact region.
75
+ Never patch from search snippets or assumptions alone.
76
+
77
+ ## compact() Failure Recovery
78
+
79
+ If \`compact()\` returns <200 bytes or empty content, the file is NOT indexed. Follow this fallback:
80
+
81
+ 1. **Do NOT retry** compact on the same file — it will fail again
82
+ 2. **Use \`read_file\`** with a LARGE range (e.g., \`startLine: 1, endLine: 9999\`) — NEVER chunk into small ranges
83
+ 3. **Use \`stash()\`** to cache findings from unindexed files — context pressure causes re-reads
84
+ 4. **Check \`status()\`** to see which paths are indexed before calling compact
85
+
86
+ **Anti-patterns to avoid:**
87
+ - Retrying compact 3x on same unindexed file (wastes 3 tool calls)
88
+ - Falling back to read_file in small chunks (10-50 lines) — each chunk costs ~3K prompt tokens in overhead
89
+ - Re-reading the same file later because you forgot the content — use stash() to cache
90
+
91
+ *Why:* these tools reduce token cost, shrink duplicate reads, and lower the odds of wrong-file or wrong-position edits while preserving reusable context.
92
+
93
+ ---
94
+
95
+ ## Context Caching (MANDATORY for multi-step tasks)
96
+
97
+ After your first \`file_summary\` or \`compact\` call on a file, cache the result:
98
+ \`\`\`
99
+ stash({ action: 'set', key: 'ctx:<filename>', value: '<summary result>' })
100
+ \`\`\`
101
+
102
+ Before reading the same file again, check the cache:
103
+ \`\`\`
104
+ stash({ action: 'get', key: 'ctx:<filename>' })
105
+ \`\`\`
106
+
107
+ If cached → use it. If not → call \`file_summary\`/\`compact\` and cache.
108
+ **NEVER \`read_file\` the same file twice** without checking stash first.
109
+
110
+ ---
111
+
57
112
 
58
113
  ## Domain Skills
59
114
 
@@ -262,44 +317,6 @@ For outdated AI Kit entries → \`knowledge({ action: "update", path, content, r
262
317
 
263
318
  ---
264
319
 
265
- ## AI Kit Tool Discipline
266
-
267
- Use AI Kit retrieval and compression tools first. Prefer reusable compressed context over raw reads, and only drop to native tools when precision for an edit or tool fallback requires it.
268
-
269
- | NEVER use this | USE THIS instead | Why |
270
- |---|---|---|
271
- | \`read_file\` to understand a file | \`file_summary({ path })\` | Structure, exports, imports — 10x fewer tokens |
272
- | \`read_file\` to find specific code | \`compact({ path, query })\` | Server-side read + semantic extract — 5-20x reduction |
273
- | Multiple \`read_file\` calls | \`digest({ sources })\` | Compresses multiple files into token-budgeted summary |
274
- | \`grep_search\` / \`semantic_search\` | \`search({ query })\` | Hybrid search across all indexed + curated content |
275
- | \`grep_search\` for a symbol name | \`symbol({ name })\` | Definition + references with scope and call context |
276
- | \`run_in_terminal\` for tsc/lint | \`check({})\` | Typecheck + lint combined, summary output |
277
- | \`run_in_terminal\` for test | \`test_run({})\` | Run tests with structured output |
278
- | Editing without reading | \`file_summary\` then targeted \`read_file\` | Prevents wrong-position edits |
279
-
280
- **\`read_file\` is ONLY acceptable when you need exact line content FOR EDITING (before \`replace_string_in_file\`).**
281
-
282
- For edits, first understand structure with \`file_summary\` or \`compact\`, then use targeted \`read_file\` only for the exact region.
283
- Never patch from search snippets or assumptions alone.
284
-
285
- ## compact() Failure Recovery
286
-
287
- If \`compact()\` returns <200 bytes or empty content, the file is NOT indexed. Follow this fallback:
288
-
289
- 1. **Do NOT retry** compact on the same file — it will fail again
290
- 2. **Use \`read_file\`** with a LARGE range (e.g., \`startLine: 1, endLine: 9999\`) — NEVER chunk into small ranges
291
- 3. **Use \`stash()\`** to cache findings from unindexed files — context pressure causes re-reads
292
- 4. **Check \`status()\`** to see which paths are indexed before calling compact
293
-
294
- **Anti-patterns to avoid:**
295
- - Retrying compact 3x on same unindexed file (wastes 3 tool calls)
296
- - Falling back to read_file in small chunks (10-50 lines) — each chunk costs ~3K prompt tokens in overhead
297
- - Re-reading the same file later because you forgot the content — use stash() to cache
298
-
299
- *Why:* these tools reduce token cost, shrink duplicate reads, and lower the odds of wrong-file or wrong-position edits while preserving reusable context.
300
-
301
- ---
302
-
303
320
  ## Guidelines
304
321
 
305
322
  Behavioral guidelines to reduce common LLM coding mistakes. Apply when writing, reviewing, or refactoring code.