@vpxa/aikit 0.1.358 → 0.1.360

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 (51) hide show
  1. package/package.json +1 -1
  2. package/packages/analyzers/dist/index.d.ts +1 -1
  3. package/packages/cli/dist/index.js +19 -19
  4. package/packages/cli/dist/init-C_WzeMTD.js +7 -0
  5. package/packages/cli/dist/{templates-Bu7dZtk_.js → templates-DUUaYk_d.js} +13 -12
  6. package/packages/core/dist/index.d.ts +43 -2
  7. package/packages/core/dist/index.js +1 -1
  8. package/packages/present/dist/annotation-layer.js +10 -10
  9. package/packages/server/dist/bin.js +1 -1
  10. package/packages/server/dist/index.js +1 -1
  11. package/packages/server/dist/observations-CfglxBMB.js +6 -0
  12. package/packages/server/dist/observations-CrQU_HVm.js +5 -0
  13. package/packages/server/dist/prelude-CNOjd5qt.js +2 -0
  14. package/packages/server/dist/prelude-Dki25eYn.js +1 -0
  15. package/packages/server/dist/sampling-B8NwOv_z.js +1 -0
  16. package/packages/server/dist/sampling-DOOgTH1B.js +2 -0
  17. package/packages/server/dist/{server-D5eu57oU.js → server-C2n9kQMF.js} +178 -183
  18. package/packages/server/dist/{server-D7gZ4K_H.js → server-CizTllz1.js} +178 -183
  19. package/packages/server/dist/{server-http-AarbD3gm.js → server-http-BaMUtb5Y.js} +1 -1
  20. package/packages/server/dist/{server-http-wnYmWFkC.js → server-http-Dd2uCMBi.js} +1 -1
  21. package/packages/server/dist/{server-stdio-BWoMqXU8.js → server-stdio-B5rk-PAI.js} +1 -1
  22. package/packages/server/dist/{server-stdio-CBGO6XiO.js → server-stdio-CtR4QNT3.js} +1 -1
  23. package/packages/tools/dist/index.js +69 -69
  24. package/scaffold/AUTOMATION-BOUNDARY-ANALYSIS.md +78 -0
  25. package/scaffold/dist/adapters/_shared.mjs +7 -6
  26. package/scaffold/dist/adapters/claude-code.mjs +7 -7
  27. package/scaffold/dist/adapters/claude-desktop.mjs +7 -0
  28. package/scaffold/dist/adapters/gemini.mjs +6 -6
  29. package/scaffold/dist/adapters/hermes.mjs +5 -5
  30. package/scaffold/dist/adapters/hooks.mjs +1 -1
  31. package/scaffold/dist/adapters/opencode.mjs +7 -7
  32. package/scaffold/dist/definitions/exec-hooks.mjs +1 -1
  33. package/scaffold/dist/definitions/platform-capabilities.mjs +1 -0
  34. package/scaffold/dist/definitions/protocols.mjs +7 -6
  35. package/scaffold/dist/definitions/skills/aikit.mjs +4 -4
  36. package/scaffold/general/hooks/scripts/_runtime.mjs +87 -15
  37. package/scaffold/general/hooks/scripts/freshness-signal.mjs +196 -0
  38. package/scaffold/general/hooks/scripts/privacy-guard.mjs +19 -6
  39. package/scaffold/general/hooks/scripts/scope-guard.mjs +160 -0
  40. package/scaffold/general/hooks/scripts/scout-guard.mjs +18 -14
  41. package/packages/cli/dist/init-CWLiK7bC.js +0 -7
  42. package/packages/server/dist/prelude-DetbWo8R.js +0 -1
  43. package/packages/server/dist/prelude-hfAEi93R.js +0 -2
  44. package/packages/server/dist/sampling-CWjnUevo.js +0 -2
  45. package/packages/server/dist/sampling-CnE3owSt.js +0 -1
  46. package/scaffold/general/hooks/scripts/post-edit-check.mjs +0 -36
  47. package/scaffold/general/hooks/scripts/pre-compact-save.mjs +0 -13
  48. package/scaffold/general/hooks/scripts/session-init.mjs +0 -85
  49. package/scaffold/general/hooks/scripts/session-learn.mjs +0 -53
  50. package/scaffold/general/hooks/scripts/session-observer.mjs +0 -77
  51. package/scaffold/general/hooks/scripts/subagent-context.mjs +0 -59
@@ -1,53 +0,0 @@
1
- #!/usr/bin/env node
2
- /**
3
- * session-learn — Stop event hook for autonomous learning.
4
- *
5
- * Fires at session end. Nudges agent to process buffered observations
6
- * before context is lost. Cleans up buffer if too small for analysis.
7
- *
8
- * @tier efficiency
9
- * @event Stop
10
- * @scope user
11
- */
12
- import fs from 'node:fs';
13
- import os from 'node:os';
14
- import path from 'node:path';
15
- import process from 'node:process';
16
- import { createHook } from './_runtime.mjs';
17
-
18
- const bufferPath = path.join(os.tmpdir(), `aikit-obs-${process.ppid}.jsonl`);
19
- const MIN_OBSERVATIONS = 10;
20
-
21
- const getLineCount = (filePath) => {
22
- try {
23
- return fs.readFileSync(filePath, 'utf8').split('\n').filter(Boolean).length;
24
- } catch {
25
- return 0;
26
- }
27
- };
28
-
29
- const cleanup = () => {
30
- try {
31
- fs.unlinkSync(bufferPath);
32
- } catch {}
33
- };
34
-
35
- /** Nudges end-of-session lesson extraction and cleans up small buffers. */
36
- export const sessionLearn = async (context) => {
37
- if (context.event !== 'Stop') return { decision: 'allow' };
38
-
39
- const count = getLineCount(bufferPath);
40
- if (count < MIN_OBSERVATIONS) {
41
- cleanup();
42
- return { decision: 'allow' };
43
- }
44
-
45
- return {
46
- additionalContext: [
47
- `[Observer] Session ending with ${count} observations buffered.`,
48
- 'Run knowledge({ action: "lesson", subAction: "auto-observe" }) to extract learning patterns.',
49
- ].join(' '),
50
- };
51
- };
52
-
53
- createHook(sessionLearn);
@@ -1,77 +0,0 @@
1
- #!/usr/bin/env node
2
- /**
3
- * session-observer — PostToolUse hook for autonomous learning.
4
- *
5
- * Captures tool usage observations to a JSONL buffer for later pattern analysis.
6
- * Fire-and-forget writes (<5ms). Nudges agent when batch threshold reached.
7
- *
8
- * @tier efficiency
9
- * @event PostToolUse
10
- * @scope user
11
- */
12
- import fs from 'node:fs';
13
- import os from 'node:os';
14
- import path from 'node:path';
15
- import process from 'node:process';
16
- import { createHook } from './_runtime.mjs';
17
-
18
- const bufferPath = path.join(os.tmpdir(), `aikit-obs-${process.ppid}.jsonl`);
19
- const BATCH_THRESHOLD = 20;
20
- const EXCLUDE = new Set([
21
- 'knowledge',
22
- 'replay',
23
- 'stash',
24
- 'checkpoint',
25
- 'session_digest',
26
- 'reindex',
27
- 'status',
28
- 'flow',
29
- 'evidence_map',
30
- 'present',
31
- ]);
32
-
33
- const countLines = (filePath) => {
34
- try {
35
- return fs.readFileSync(filePath, 'utf8').split('\n').filter(Boolean).length;
36
- } catch {
37
- return 0;
38
- }
39
- };
40
-
41
- const summarize = (input, maxLen = 200) => {
42
- if (!input) return '';
43
- const value = typeof input === 'string' ? input : JSON.stringify(input);
44
- return value.length > maxLen ? `${value.slice(0, maxLen)}...` : value;
45
- };
46
-
47
- /** Captures tool-use observations and nudges lesson extraction at batch thresholds. */
48
- export const sessionObserver = async (context) => {
49
- if (context.event !== 'PostToolUse') return { decision: 'allow' };
50
- const toolBase = context.toolName.replace(/^mcp_aikit_/, '');
51
- if (EXCLUDE.has(toolBase)) return { decision: 'allow' };
52
-
53
- const entry = JSON.stringify({
54
- ts: Date.now(),
55
- tool: context.toolName,
56
- input: summarize(context.toolInput),
57
- files: context.filePaths.slice(0, 5),
58
- });
59
-
60
- try {
61
- fs.appendFileSync(bufferPath, `${entry}\n`);
62
- } catch {}
63
-
64
- const count = countLines(bufferPath);
65
- if (count > 0 && count >= BATCH_THRESHOLD && count % BATCH_THRESHOLD === 0) {
66
- return {
67
- additionalContext: [
68
- `[Observer] ${count} tool calls captured this session.`,
69
- 'Consider: knowledge({ action: "lesson", subAction: "auto-observe" })',
70
- ].join(' '),
71
- };
72
- }
73
-
74
- return { decision: 'allow' };
75
- };
76
-
77
- createHook(sessionObserver);
@@ -1,59 +0,0 @@
1
- #!/usr/bin/env node
2
- import fs from 'node:fs';
3
- import path from 'node:path';
4
- import { createHook } from './_runtime.mjs';
5
-
6
- const readJson = (cwd, name) => {
7
- try {
8
- return JSON.parse(fs.readFileSync(path.join(cwd, name), 'utf8'));
9
- } catch {
10
- return null;
11
- }
12
- };
13
- const truncate = (value, limit) =>
14
- String(value ?? '')
15
- .replace(/\s+/g, ' ')
16
- .trim()
17
- .slice(0, limit);
18
- const detectStack = (manifest, pkg) => {
19
- const explicit = manifest?.stack ?? manifest?.techStack ?? manifest?.project?.stack;
20
- if (explicit) return Array.isArray(explicit) ? explicit.join(', ') : String(explicit);
21
- const deps = { ...pkg?.dependencies, ...pkg?.devDependencies };
22
- const found = [];
23
- if (pkg) found.push('Node.js');
24
- if (deps.react) found.push('React');
25
- if (deps.vue) found.push('Vue');
26
- if (deps.next) found.push('Next.js');
27
- if (deps.express) found.push('Express');
28
- if (deps.fastify) found.push('Fastify');
29
- if (deps['@nestjs/core']) found.push('NestJS');
30
- return found.join(', ');
31
- };
32
-
33
- /** Injects compact project metadata into every subagent start. */
34
- export const subagentContext = async (context) => {
35
- if (context.event !== 'SubagentStart') return { decision: 'allow' };
36
- const manifest = readJson(context.cwd, '.aikit-scaffold.json');
37
- const pkg = readJson(context.cwd, 'package.json');
38
- if (!manifest && !pkg) return { decision: 'allow' };
39
- const conventions =
40
- manifest?.conventions ?? manifest?.keyConventions ?? manifest?.project?.conventions;
41
- const conventionText = Array.isArray(conventions)
42
- ? conventions.slice(0, 3).join('; ')
43
- : conventions;
44
- const name = truncate(pkg?.name ?? manifest?.name ?? path.basename(context.cwd), 60);
45
- const description = truncate(
46
- pkg?.description ?? manifest?.description ?? manifest?.project?.description,
47
- 120,
48
- );
49
- const stack = truncate(detectStack(manifest, pkg) || 'unknown', 80);
50
- const contextText = [
51
- `Project: ${name}${description ? ` — ${description}` : ''}`,
52
- `Stack: ${stack}`,
53
- `Conventions: ${truncate(conventionText || 'Reuse existing scaffold patterns.', 120)}`,
54
- 'Use aikit search/file_summary — NOT raw read_file for understanding code.',
55
- ].join('\n');
56
- return { additionalContext: contextText };
57
- };
58
-
59
- createHook(subagentContext);