@vpxa/aikit 0.1.376 → 0.1.378

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 (29) hide show
  1. package/package.json +1 -1
  2. package/packages/browser/dist/index.js +1 -1
  3. package/packages/claude-desktop/dist/manifest.json +1 -1
  4. package/packages/cli/dist/index.js +3 -3
  5. package/packages/cli/dist/{init-CAIdybTd.js → init-gDbVIWiP.js} +1 -1
  6. package/packages/cli/dist/{templates-3q6NnbZs.js → templates-BPC4t5yz.js} +1 -1
  7. package/packages/server/dist/bin.js +1 -1
  8. package/packages/server/dist/index.js +1 -1
  9. package/packages/server/dist/prelude-C4z3H1li.js +1 -0
  10. package/packages/server/dist/prelude-WsqQzR-u.js +2 -0
  11. package/packages/server/dist/sampling-Bpwc-4Jr.js +2 -0
  12. package/packages/server/dist/sampling-CfLD3fM_.js +1 -0
  13. package/packages/server/dist/{server-DXaS0WHj.js → server-D2a5Rjgk.js} +3 -3
  14. package/packages/server/dist/{server-http-DRzlfsfi.js → server-http-B841uX1k.js} +1 -1
  15. package/packages/server/dist/{server-http-CzGU0eC_.js → server-http-tZxvg5ke.js} +1 -1
  16. package/packages/server/dist/{server-C9E6Pzil.js → server-jZ_r6xLb.js} +3 -3
  17. package/packages/server/dist/{server-stdio-BZKwJhem.js → server-stdio-B22xZT0d.js} +1 -1
  18. package/packages/server/dist/{server-stdio-jG91afRD.js → server-stdio-DpGfc6DI.js} +1 -1
  19. package/scaffold/dist/adapters/claude-code.mjs +7 -7
  20. package/scaffold/dist/definitions/bodies.mjs +10 -0
  21. package/scaffold/dist/definitions/exec-hooks.mjs +1 -1
  22. package/scaffold/dist/definitions/skills/present.mjs +3 -3
  23. package/scaffold/general/hooks/scripts/bash-guard.mjs +76 -0
  24. package/scaffold/general/hooks/scripts/read-size-guard.mjs +61 -0
  25. package/scaffold/general/hooks/scripts/session-reminder.mjs +108 -26
  26. package/packages/server/dist/prelude-BuHOjkbS.js +0 -2
  27. package/packages/server/dist/prelude-C2-WkGrE.js +0 -1
  28. package/packages/server/dist/sampling-CGl_ysKF.js +0 -1
  29. package/packages/server/dist/sampling-DZSZqYyG.js +0 -2
@@ -1,15 +1,19 @@
1
1
  #!/usr/bin/env node
2
2
  /**
3
- * session-reminder — SessionStart hook that injects the orchestrator
4
- * skill protocol at every session start.
3
+ * session-reminder — SessionStart hook that injects tool routing rules,
4
+ * mandatory first actions, and skill protocols at every session start.
5
5
  *
6
- * Reads ~/.claude/skills/orchestrator/SKILL.md, strips YAML frontmatter,
7
- * and injects the "Delegate, never implement" protocol as additionalContext.
8
- * Falls back to inline essentials if skill file is unavailable.
6
+ * All agents now include mcp__aikit__* tools in their tools: frontmatter
7
+ * alongside native tools (Bash, Edit, Read, Task, etc.).
9
8
  *
10
- * The orchestrator agent file already references the aikit skill — this
11
- * hook reinforces the orchestrator-specific delegation protocol that the
12
- * model is most likely to skip.
9
+ * Reads ~/.claude/skills/orchestrator/SKILL.md and ~/.claude/skills/aikit/SKILL.md,
10
+ * strips YAML frontmatter, and injects:
11
+ * - FORBIDDEN TOOL SUBSTITUTIONS (grep/find/ls MCP tools)
12
+ * - MANDATORY FIRST ACTIONS (flow status, status with prelude, onboard)
13
+ * - Orchestrator delegation protocol (from skill file or inline fallback)
14
+ * - AI Kit tool routing essentials (from aikit skill file)
15
+ *
16
+ * Falls back to inline essentials if skill files are unavailable.
13
17
  *
14
18
  * @category signal
15
19
  * @event SessionStart
@@ -20,25 +24,59 @@ import { homedir } from 'node:os';
20
24
  import { resolve } from 'node:path';
21
25
  import { createHook } from './_runtime.mjs';
22
26
 
27
+ /**
28
+ * Read a skill SKILL.md file and return its body (YAML frontmatter stripped).
29
+ * Returns null if the file is missing or unreadable.
30
+ */
31
+ function readSkillBody(skillName) {
32
+ const skillPath = resolve(homedir(), '.claude', 'skills', skillName, 'SKILL.md');
33
+ try {
34
+ const raw = readFileSync(skillPath, 'utf-8');
35
+ const body = raw.replace(/^---[\s\S]*?---\n*/, '').trim();
36
+ return body || null;
37
+ } catch {
38
+ return null;
39
+ }
40
+ }
41
+
23
42
  createHook(
24
43
  () => {
25
- const skillPath = resolve(homedir(), '.claude', 'skills', 'orchestrator', 'SKILL.md');
26
- let extracted = '';
27
-
28
- try {
29
- const raw = readFileSync(skillPath, 'utf-8');
30
- // Strip YAML frontmatter (everything between first two ---)
31
- const body = raw.replace(/^---[\s\S]*?---\n*/, '').trim();
32
- if (body) extracted = body;
33
- } catch {
34
- // fallback inline instructions below
35
- }
44
+ const orchestratorBody = readSkillBody('orchestrator');
45
+ const aikitBody = readSkillBody('aikit');
36
46
 
37
- const content =
38
- extracted ||
39
- [
40
- '# Orchestrator Protocol — MANDATORY',
41
- '',
47
+ const parts = [];
48
+
49
+ // ── FORBIDDEN TOOL SUBSTITUTIONS ──
50
+ parts.push(
51
+ '── FORBIDDEN TOOL SUBSTITUTIONS (enforced) ──',
52
+ 'These shell commands waste context on codebase exploration. Use MCP tools instead:',
53
+ '',
54
+ '| Shell pattern | Use MCP tool instead |',
55
+ '|---|---|',
56
+ '| grep, find, rg | mcp__aikit__search or mcp__aikit__find |',
57
+ '| cat (large files) | mcp__aikit__file_summary |',
58
+ '| ls (code exploration) | mcp__aikit__find({ glob }) or mcp__aikit__search |',
59
+ '| tsc, biome CLI | mcp__aikit__check |',
60
+ '| npx vitest | mcp__aikit__test_run |',
61
+ '| read_file (understanding) | mcp__aikit__file_summary({ tier: T2, query }) |',
62
+ '',
63
+ 'read_file is ONLY for exact edit lines after compressed tools identify the target.',
64
+ '',
65
+ '── MANDATORY FIRST ACTIONS (session start) ──',
66
+ 'Execute these MCP calls before ANY other work:',
67
+ "1. mcp__aikit__flow({ action: 'status' }) — check active flow state",
68
+ '2. mcp__aikit__status({ includePrelude: true }) — load L0 workspace context',
69
+ '3. If workspaceCore is null → mcp__aikit__onboard({ path: "." }) first, then status again',
70
+ '',
71
+ );
72
+
73
+ // ── Delegation Protocol ──
74
+ if (orchestratorBody) {
75
+ parts.push('── Delegation Protocol ──');
76
+ parts.push(orchestratorBody);
77
+ } else {
78
+ parts.push(
79
+ '── Delegation Protocol (fallback) ──',
42
80
  'YOU MUST FOLLOW THIS PROTOCOL ON EVERY TASK. You are an orchestrator, not an implementer.',
43
81
  '',
44
82
  '**RULE 1 — Decompose everything.** Every task gets a TODO list in your first response. Break it into independent, parallelizable subtasks.',
@@ -55,9 +93,53 @@ createHook(
55
93
  '',
56
94
  '**Exceptions (ONLY these):** ≤5 lines trivial, fixing sub-agent output, no sub-agent available.',
57
95
  'When in doubt, delegate. When unsure, spawn an extra sub-agent.',
58
- ].join('\n');
96
+ );
97
+ }
98
+
99
+ // ── AI Kit Tool Routing ──
100
+ if (aikitBody) {
101
+ // Extract key sections: Session Loop, Retrieval Ladder, Context Reuse
102
+ const sections = aikitBody.split('\n## ');
103
+ const keySections = [
104
+ 'Session Loop',
105
+ 'Retrieval Ladder',
106
+ 'Context Reuse',
107
+ 'Patterns',
108
+ 'Memory Discipline',
109
+ ];
110
+ const extracted = sections.filter((s) => {
111
+ const header = s
112
+ .split('\n')[0]
113
+ .trim()
114
+ .replace(/^#+\s*/, '');
115
+ return keySections.some((k) => header.startsWith(k));
116
+ });
117
+ if (extracted.length > 0) {
118
+ parts.push('── AI Kit Tool Routing ──');
119
+ parts.push(extracted.join('\n\n'));
120
+ }
121
+ } else {
122
+ parts.push(
123
+ '── AI Kit Tool Routing (fallback) ──',
124
+ '',
125
+ '| Need | Use |',
126
+ '|---|---|',
127
+ '| L0 workspace context | status({ includePrelude: true }) |',
128
+ '| Search code | search({ query }) |',
129
+ '| Find files | find({ glob }) |',
130
+ '| File summary / exploration | file_summary({ files, tier: T2 }) |',
131
+ '| Symbol definition | symbol({ name }) |',
132
+ '| Type/lint check | check({}) |',
133
+ '| Run tests | test_run({}) |',
134
+ '| Call/data flow | trace({ start, direction }) |',
135
+ '| Impact analysis | blast_radius({ files }) |',
136
+ '| Module graph | graph({ action: neighbors, node_id }) |',
137
+ '',
138
+ 'Prefer compressed MCP tools over raw read_file. read_file is only for editing.',
139
+ );
140
+ }
59
141
 
60
- return { additionalContext: `── Orchestrator Protocol ──\n${content}` };
142
+ return { additionalContext: parts.join('\n') };
61
143
  },
62
144
  { event: 'SessionStart' },
63
145
  );
@@ -1,2 +0,0 @@
1
- #!/usr/bin/env node
2
- import{n as e,t}from"./server-DXaS0WHj.js";export{t as buildPreludeInjection,e as generatePrelude};
@@ -1 +0,0 @@
1
- import{n as e,t}from"./server-C9E6Pzil.js";export{t as buildPreludeInjection,e as generatePrelude};
@@ -1 +0,0 @@
1
- import{r as e}from"./server-C9E6Pzil.js";export{e as createSamplingClient};
@@ -1,2 +0,0 @@
1
- #!/usr/bin/env node
2
- import{r as e}from"./server-DXaS0WHj.js";export{e as createSamplingClient};