@shobyde/boaz 0.0.0-stage → 0.8.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.
Files changed (163) hide show
  1. package/LICENSE +21 -0
  2. package/README.md +402 -2
  3. package/dist/build/codes.d.ts +16 -0
  4. package/dist/build/codes.d.ts.map +1 -0
  5. package/dist/build/codes.js +72 -0
  6. package/dist/build/codes.js.map +1 -0
  7. package/dist/build/extract.d.ts +45 -0
  8. package/dist/build/extract.d.ts.map +1 -0
  9. package/dist/build/extract.js +484 -0
  10. package/dist/build/extract.js.map +1 -0
  11. package/dist/build/glob.d.ts +11 -0
  12. package/dist/build/glob.d.ts.map +1 -0
  13. package/dist/build/glob.js +88 -0
  14. package/dist/build/glob.js.map +1 -0
  15. package/dist/build/index.d.ts +7 -0
  16. package/dist/build/index.d.ts.map +1 -0
  17. package/dist/build/index.js +4 -0
  18. package/dist/build/index.js.map +1 -0
  19. package/dist/build/probes.d.ts +41 -0
  20. package/dist/build/probes.d.ts.map +1 -0
  21. package/dist/build/probes.js +134 -0
  22. package/dist/build/probes.js.map +1 -0
  23. package/dist/build/report.d.ts +11 -0
  24. package/dist/build/report.d.ts.map +1 -0
  25. package/dist/build/report.js +39 -0
  26. package/dist/build/report.js.map +1 -0
  27. package/dist/cli/audit.d.ts +15 -0
  28. package/dist/cli/audit.d.ts.map +1 -0
  29. package/dist/cli/audit.js +68 -0
  30. package/dist/cli/audit.js.map +1 -0
  31. package/dist/cli/bench.d.ts +7 -0
  32. package/dist/cli/bench.d.ts.map +1 -0
  33. package/dist/cli/bench.js +147 -0
  34. package/dist/cli/bench.js.map +1 -0
  35. package/dist/cli/harness.d.ts +45 -0
  36. package/dist/cli/harness.d.ts.map +1 -0
  37. package/dist/cli/harness.js +90 -0
  38. package/dist/cli/harness.js.map +1 -0
  39. package/dist/cli/index.d.ts +3 -0
  40. package/dist/cli/index.d.ts.map +1 -0
  41. package/dist/cli/index.js +404 -0
  42. package/dist/cli/index.js.map +1 -0
  43. package/dist/cli/probes.d.ts +20 -0
  44. package/dist/cli/probes.d.ts.map +1 -0
  45. package/dist/cli/probes.js +27 -0
  46. package/dist/cli/probes.js.map +1 -0
  47. package/dist/cli/skill-template.d.ts +2 -0
  48. package/dist/cli/skill-template.d.ts.map +1 -0
  49. package/dist/cli/skill-template.js +254 -0
  50. package/dist/cli/skill-template.js.map +1 -0
  51. package/dist/core/actions.d.ts +67 -0
  52. package/dist/core/actions.d.ts.map +1 -0
  53. package/dist/core/actions.js +357 -0
  54. package/dist/core/actions.js.map +1 -0
  55. package/dist/core/define.d.ts +25 -0
  56. package/dist/core/define.d.ts.map +1 -0
  57. package/dist/core/define.js +76 -0
  58. package/dist/core/define.js.map +1 -0
  59. package/dist/core/execute.d.ts +75 -0
  60. package/dist/core/execute.d.ts.map +1 -0
  61. package/dist/core/execute.js +145 -0
  62. package/dist/core/execute.js.map +1 -0
  63. package/dist/core/index.d.ts +35 -0
  64. package/dist/core/index.d.ts.map +1 -0
  65. package/dist/core/index.js +20 -0
  66. package/dist/core/index.js.map +1 -0
  67. package/dist/core/lemmas.d.ts +32 -0
  68. package/dist/core/lemmas.d.ts.map +1 -0
  69. package/dist/core/lemmas.js +80 -0
  70. package/dist/core/lemmas.js.map +1 -0
  71. package/dist/core/lexical-engine.d.ts +18 -0
  72. package/dist/core/lexical-engine.d.ts.map +1 -0
  73. package/dist/core/lexical-engine.js +296 -0
  74. package/dist/core/lexical-engine.js.map +1 -0
  75. package/dist/core/loop.d.ts +51 -0
  76. package/dist/core/loop.d.ts.map +1 -0
  77. package/dist/core/loop.js +432 -0
  78. package/dist/core/loop.js.map +1 -0
  79. package/dist/core/mcp.d.ts +119 -0
  80. package/dist/core/mcp.d.ts.map +1 -0
  81. package/dist/core/mcp.js +253 -0
  82. package/dist/core/mcp.js.map +1 -0
  83. package/dist/core/memory.d.ts +106 -0
  84. package/dist/core/memory.d.ts.map +1 -0
  85. package/dist/core/memory.js +185 -0
  86. package/dist/core/memory.js.map +1 -0
  87. package/dist/core/plan.d.ts +83 -0
  88. package/dist/core/plan.d.ts.map +1 -0
  89. package/dist/core/plan.js +258 -0
  90. package/dist/core/plan.js.map +1 -0
  91. package/dist/core/preferences.d.ts +54 -0
  92. package/dist/core/preferences.d.ts.map +1 -0
  93. package/dist/core/preferences.js +83 -0
  94. package/dist/core/preferences.js.map +1 -0
  95. package/dist/core/prompt.d.ts +23 -0
  96. package/dist/core/prompt.d.ts.map +1 -0
  97. package/dist/core/prompt.js +76 -0
  98. package/dist/core/prompt.js.map +1 -0
  99. package/dist/core/question.d.ts +96 -0
  100. package/dist/core/question.d.ts.map +1 -0
  101. package/dist/core/question.js +501 -0
  102. package/dist/core/question.js.map +1 -0
  103. package/dist/core/registry.d.ts +33 -0
  104. package/dist/core/registry.d.ts.map +1 -0
  105. package/dist/core/registry.js +72 -0
  106. package/dist/core/registry.js.map +1 -0
  107. package/dist/core/retriever.d.ts +48 -0
  108. package/dist/core/retriever.d.ts.map +1 -0
  109. package/dist/core/retriever.js +123 -0
  110. package/dist/core/retriever.js.map +1 -0
  111. package/dist/core/schema.d.ts +27 -0
  112. package/dist/core/schema.d.ts.map +1 -0
  113. package/dist/core/schema.js +231 -0
  114. package/dist/core/schema.js.map +1 -0
  115. package/dist/core/skill.d.ts +105 -0
  116. package/dist/core/skill.d.ts.map +1 -0
  117. package/dist/core/skill.js +205 -0
  118. package/dist/core/skill.js.map +1 -0
  119. package/dist/core/summarise.d.ts +52 -0
  120. package/dist/core/summarise.d.ts.map +1 -0
  121. package/dist/core/summarise.js +146 -0
  122. package/dist/core/summarise.js.map +1 -0
  123. package/dist/core/tools.d.ts +21 -0
  124. package/dist/core/tools.d.ts.map +1 -0
  125. package/dist/core/tools.js +120 -0
  126. package/dist/core/tools.js.map +1 -0
  127. package/dist/core/types.d.ts +199 -0
  128. package/dist/core/types.d.ts.map +1 -0
  129. package/dist/core/types.js +5 -0
  130. package/dist/core/types.js.map +1 -0
  131. package/dist/dom/index.d.ts +22 -0
  132. package/dist/dom/index.d.ts.map +1 -0
  133. package/dist/dom/index.js +94 -0
  134. package/dist/dom/index.js.map +1 -0
  135. package/dist/extract/index.d.ts +36 -0
  136. package/dist/extract/index.d.ts.map +1 -0
  137. package/dist/extract/index.js +86 -0
  138. package/dist/extract/index.js.map +1 -0
  139. package/dist/react/index.d.ts +52 -0
  140. package/dist/react/index.d.ts.map +1 -0
  141. package/dist/react/index.js +131 -0
  142. package/dist/react/index.js.map +1 -0
  143. package/dist/rules/engine.d.ts +152 -0
  144. package/dist/rules/engine.d.ts.map +1 -0
  145. package/dist/rules/engine.js +364 -0
  146. package/dist/rules/engine.js.map +1 -0
  147. package/dist/rules/facts.d.ts +63 -0
  148. package/dist/rules/facts.d.ts.map +1 -0
  149. package/dist/rules/facts.js +115 -0
  150. package/dist/rules/facts.js.map +1 -0
  151. package/dist/rules/index.d.ts +10 -0
  152. package/dist/rules/index.d.ts.map +1 -0
  153. package/dist/rules/index.js +5 -0
  154. package/dist/rules/index.js.map +1 -0
  155. package/dist/rules/knowledge.d.ts +78 -0
  156. package/dist/rules/knowledge.d.ts.map +1 -0
  157. package/dist/rules/knowledge.js +254 -0
  158. package/dist/rules/knowledge.js.map +1 -0
  159. package/dist/vite/index.d.ts +26 -0
  160. package/dist/vite/index.d.ts.map +1 -0
  161. package/dist/vite/index.js +112 -0
  162. package/dist/vite/index.js.map +1 -0
  163. package/package.json +108 -4
@@ -0,0 +1,90 @@
1
+ // Runs an app's own engine, the way its UI would.
2
+ //
3
+ // The module the app points at exports `createEngine()` (and optionally the
4
+ // capabilities and answer rules it was built from). That keeps the harness out
5
+ // of the app's business: no imports are guessed, no config is reimplemented.
6
+ import path from 'node:path';
7
+ import { pathToFileURL } from 'node:url';
8
+ import { parseModelOutput } from '../core/index.js';
9
+ export async function loadAgentModule(file) {
10
+ const url = pathToFileURL(path.resolve(file)).href;
11
+ const loaded = (await import(url));
12
+ if (typeof loaded.createEngine !== 'function') {
13
+ throw new Error(`${file}: export a createEngine() that returns the engine your UI uses ` +
14
+ '(see "Proving it works" in the docs)');
15
+ }
16
+ return {
17
+ createEngine: loaded.createEngine,
18
+ ...(loaded.runCapability ? { runCapability: loaded.runCapability } : {}),
19
+ ...(loaded.answers ? { answers: loaded.answers } : {}),
20
+ ...(loaded.capabilities ? { capabilities: loaded.capabilities } : {}),
21
+ };
22
+ }
23
+ export async function ask(engine, question, run) {
24
+ const messages = [{ role: 'user', content: question }];
25
+ let observations;
26
+ let text = '';
27
+ const calls = [];
28
+ let plannedBy;
29
+ let composedBy;
30
+ for (let turn = 0; turn < 2; turn += 1) {
31
+ const request = {
32
+ messages,
33
+ tools: [],
34
+ ...(observations ? { observations } : {}),
35
+ };
36
+ const completion = await engine.complete(request);
37
+ text = typeof completion.text === 'string' ? completion.text : String(completion.text ?? '');
38
+ const parsed = parseModelOutput(text);
39
+ const planned = engine.memory?.planned;
40
+ if (planned?.ruleId && !plannedBy)
41
+ plannedBy = planned.ruleId;
42
+ const inference = (completion.steps ?? []).find((step) => step.type === 'inference');
43
+ if (inference?.capabilityId)
44
+ composedBy = inference.capabilityId;
45
+ if (parsed.kind !== 'tool')
46
+ break;
47
+ calls.push({ id: parsed.capabilityId ?? '', args: parsed.args ?? {} });
48
+ if (!run)
49
+ break;
50
+ // The UI would run this capability and hand the result back; do the same so
51
+ // a rule that reasons over a tool produces the sentence, not the call.
52
+ const result = await run(parsed.capabilityId ?? '', parsed.args ?? {});
53
+ observations = { ...(observations ?? {}), [parsed.capabilityId ?? '']: result };
54
+ }
55
+ const [first] = calls;
56
+ return {
57
+ text,
58
+ ...(first ? { toolId: first.id, args: first.args } : {}),
59
+ isCall: calls.length > 0,
60
+ calls,
61
+ ...(plannedBy ? { plannedBy } : {}),
62
+ ...(composedBy ? { composedBy } : {}),
63
+ };
64
+ }
65
+ /**
66
+ * A rule that runs a capability before answering shows up as a tool call. When
67
+ * the app exports its rules, an expectation written as the rule id is satisfied
68
+ * by the call its step declares.
69
+ */
70
+ export function ruleForCall(answers, toolId, expect) {
71
+ if (!answers?.length)
72
+ return undefined;
73
+ return answers.find((rule) => rule.id === expect && (rule.steps ?? []).some((step) => step.capabilityId === toolId))?.id;
74
+ }
75
+ /** Runs the capability an expectation names, if the app exposed it. */
76
+ export function findCapability(capabilities, id) {
77
+ return capabilities?.find((capability) => capability.id === id);
78
+ }
79
+ /**
80
+ * A knowledge capability is answered by quoting its text, so the reply names it:
81
+ * first line of the declared paragraph, compared on a fixed prefix.
82
+ */
83
+ export function knowledgeSource(capabilities, text) {
84
+ const seen = text.trim().toLowerCase();
85
+ return capabilities?.find((capability) => {
86
+ const knowledge = capability.knowledge?.trim().toLowerCase();
87
+ return knowledge && knowledge.length > 20 && seen.startsWith(knowledge.slice(0, 40));
88
+ })?.id;
89
+ }
90
+ //# sourceMappingURL=harness.js.map
@@ -0,0 +1 @@
1
+ {"version":3,"file":"harness.js","sourceRoot":"","sources":["../../src/cli/harness.ts"],"names":[],"mappings":"AAAA,kDAAkD;AAClD,EAAE;AACF,4EAA4E;AAC5E,+EAA+E;AAC/E,6EAA6E;AAC7E,OAAO,IAAI,MAAM,WAAW,CAAC;AAC7B,OAAO,EAAE,aAAa,EAAE,MAAM,UAAU,CAAC;AACzC,OAAO,EAAE,gBAAgB,EAAE,MAAM,kBAAkB,CAAC;AAkCpD,MAAM,CAAC,KAAK,UAAU,eAAe,CAAC,IAAY;IAChD,MAAM,GAAG,GAAG,aAAa,CAAC,IAAI,CAAC,OAAO,CAAC,IAAI,CAAC,CAAC,CAAC,IAAI,CAAC;IACnD,MAAM,MAAM,GAAG,CAAC,MAAM,MAAM,CAAC,GAAG,CAAC,CAAyB,CAAC;IAC3D,IAAI,OAAO,MAAM,CAAC,YAAY,KAAK,UAAU,EAAE,CAAC;QAC9C,MAAM,IAAI,KAAK,CACb,GAAG,IAAI,iEAAiE;YACtE,sCAAsC,CACzC,CAAC;IACJ,CAAC;IACD,OAAO;QACL,YAAY,EAAE,MAAM,CAAC,Y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;IACvF,CAAC,CAAC,EAAE,EAAE,CAAC;AACT,CAAC"}
@@ -0,0 +1,3 @@
1
+ #!/usr/bin/env node
2
+ export {};
3
+ //# sourceMappingURL=index.d.ts.map
@@ -0,0 +1 @@
1
+ {"version":3,"file":"index.d.ts","sourceRoot":"","sources":["../../src/cli/index.ts"],"names":[],"mappings":""}
@@ -0,0 +1,404 @@
1
+ #!/usr/bin/env node
2
+ import fs from 'node:fs/promises';
3
+ import path from 'node:path';
4
+ import { fileURLToPath } from 'node:url';
5
+ import { buildManifest, extractCapabilities } from '../build/extract.js';
6
+ import { formatDiagnostic, formatSummary, printCodes } from '../build/report.js';
7
+ import { BOAZ_SKILL_MD } from './skill-template.js';
8
+ import { runAudit } from './audit.js';
9
+ import { runBench } from './bench.js';
10
+ import { generateProbes, serializeProbes } from '../build/probes.js';
11
+ const HELP = `boaz — declarative UI capabilities for an in-browser assistant
12
+
13
+ Usage
14
+ boaz verify [dir] [--strict] [--json] [--include <glob>] [--exclude <glob>]
15
+ boaz manifest [dir] [--out <file>] [--check] [--include <glob>]
16
+ boaz codes [CODE]
17
+ boaz audit --probes <file> --module <file> [--json] [--quiet]
18
+ boaz bench --probes <file> --module <file> [--json <out>] [--samples]
19
+ boaz probes [dir] [--generate] [--out <file>] [--manifest <file>] [--force]
20
+ boaz init [dir] --skill [--force]
21
+ boaz verify --self-check <fixtures-dir>
22
+
23
+ Commands
24
+ verify Scan source for defineCapability() declarations and report problems.
25
+ Exit 1 when an error is found, or any warning with --strict.
26
+ manifest Write agent-manifest.json (deterministic: sorted by id, no timestamp).
27
+ --check compares against the file on disk instead of writing.
28
+ codes Print the diagnostic code table, or the detail for one code.
29
+ audit Ask every probe and check it reaches the capability or rule it names.
30
+ Exit 1 on any miss, so it can gate a pull request.
31
+ bench Score the copy: fidelity, paraphrase similarity, opener variety,
32
+ length spread, stability. Probes with the same "intent" are the
33
+ paraphrases of one question.
34
+ probes Turn a manifest into a starting probe file: one question per
35
+ capability title and keyword, plus the phrases that more than one
36
+ capability claims, which no probe can honestly assert.
37
+ init Install the repository skill that keeps capabilities in sync and
38
+ shows how to test what they answer.
39
+
40
+ Options
41
+ --include <glob> Source glob, relative to dir. Repeatable. Default src/**/*.{ts,tsx,js,jsx}
42
+ --exclude <glob> Exclude glob. Repeatable.
43
+ --json Machine-readable output for verify.
44
+ --strict Treat warnings as failures.
45
+ --self-check <dir> Run every fixture in <dir> and compare against expected-codes.json.
46
+ `;
47
+ function parseArgs(argv) {
48
+ const flags = new Map();
49
+ const positionals = [];
50
+ const takesValue = new Set(['include', 'exclude', 'out', 'self-check', 'probes', 'module', 'json', 'manifest']);
51
+ const setFlag = (key, value) => {
52
+ if (Array.isArray(value) || value === true) {
53
+ flags.set(key, value);
54
+ return;
55
+ }
56
+ const existing = flags.get(key);
57
+ if (typeof existing === 'string')
58
+ flags.set(key, [existing, value]);
59
+ else if (Array.isArray(existing))
60
+ existing.push(value);
61
+ else
62
+ flags.set(key, value);
63
+ };
64
+ for (let i = 0; i < argv.length; i += 1) {
65
+ const token = argv[i];
66
+ if (token === undefined)
67
+ continue;
68
+ if (token.startsWith('--')) {
69
+ const name = token.slice(2);
70
+ const [key, inline] = name.split('=');
71
+ if (inline !== undefined) {
72
+ setFlag(key ?? name, inline);
73
+ }
74
+ else if (key && takesValue.has(key)) {
75
+ const value = argv[i + 1];
76
+ if (value === undefined)
77
+ throw new Error(`--${key} needs a value`);
78
+ setFlag(key, value);
79
+ i += 1;
80
+ }
81
+ else if (key) {
82
+ setFlag(key, true);
83
+ }
84
+ }
85
+ else if (token.startsWith('-') && token.length > 1) {
86
+ setFlag(token.slice(1), true);
87
+ }
88
+ else {
89
+ positionals.push(token);
90
+ }
91
+ }
92
+ return { command: positionals.shift() ?? 'help', positionals, flags };
93
+ }
94
+ function multi(flags, key) {
95
+ const value = flags.get(key);
96
+ if (typeof value === 'string')
97
+ return [value];
98
+ if (Array.isArray(value))
99
+ return value;
100
+ return [];
101
+ }
102
+ function single(flags, key) {
103
+ const values = multi(flags, key);
104
+ return values[values.length - 1];
105
+ }
106
+ function hasColor() {
107
+ return Boolean(process.stdout.isTTY) && !process.env.NO_COLOR;
108
+ }
109
+ async function readVersion() {
110
+ try {
111
+ const here = path.dirname(fileURLToPath(import.meta.url));
112
+ const pkg = JSON.parse(await fs.readFile(path.resolve(here, '../../package.json'), 'utf8'));
113
+ return pkg.version ?? '0.0.0';
114
+ }
115
+ catch {
116
+ return '0.0.0';
117
+ }
118
+ }
119
+ async function runExtract(dir, flags) {
120
+ const include = multi(flags, 'include');
121
+ const exclude = multi(flags, 'exclude');
122
+ return extractCapabilities({
123
+ root: path.resolve(dir),
124
+ include: include.length > 0 ? include : ['src/**/*.{ts,tsx,js,jsx}'],
125
+ ...(exclude.length > 0 ? { exclude } : {}),
126
+ });
127
+ }
128
+ async function commandVerify(args) {
129
+ const selfCheckDir = single(args.flags, 'self-check');
130
+ if (selfCheckDir) {
131
+ return runSelfCheck(selfCheckDir);
132
+ }
133
+ const strict = args.flags.has('strict');
134
+ const json = args.flags.has('json');
135
+ const dir = args.positionals[0] ?? '.';
136
+ const result = await runExtract(dir, args.flags);
137
+ const errors = result.diagnostics.filter((d) => d.severity === 'error');
138
+ const warnings = result.diagnostics.filter((d) => d.severity === 'warning');
139
+ if (json) {
140
+ process.stdout.write(`${JSON.stringify({
141
+ ok: errors.length === 0 && (!strict || warnings.length === 0),
142
+ errorCount: errors.length,
143
+ warningCount: warnings.length,
144
+ capabilityCount: result.capabilities.length,
145
+ routeCount: result.routes.length,
146
+ files: result.files,
147
+ diagnostics: result.diagnostics,
148
+ }, null, 2)}\n`);
149
+ return errors.length === 0 && (!strict || warnings.length === 0) ? 0 : 1;
150
+ }
151
+ const color = hasColor();
152
+ for (const diagnostic of result.diagnostics) {
153
+ process.stdout.write(`${formatDiagnostic(diagnostic, { color })}\n`);
154
+ }
155
+ if (result.diagnostics.length > 0)
156
+ process.stdout.write('\n');
157
+ process.stdout.write(`${formatSummary(result, { color })}\n`);
158
+ const failed = errors.length > 0 || (strict && warnings.length > 0);
159
+ if (failed) {
160
+ process.stdout.write(`\nRun \`boaz codes\` to see what each code means.\n`);
161
+ return 1;
162
+ }
163
+ return 0;
164
+ }
165
+ async function commandManifest(args) {
166
+ const dir = args.positionals[0] ?? '.';
167
+ const result = await runExtract(dir, args.flags);
168
+ const manifest = buildManifest(result.capabilities);
169
+ const serialized = `${JSON.stringify(manifest, null, 2)}\n`;
170
+ const outFlag = single(args.flags, 'out');
171
+ const outPath = path.resolve(outFlag ?? path.join(dir, 'agent-manifest.json'));
172
+ if (args.flags.has('check')) {
173
+ let existing = '';
174
+ try {
175
+ existing = await fs.readFile(outPath, 'utf8');
176
+ }
177
+ catch {
178
+ process.stdout.write(`missing ${outPath}; run \`boaz manifest\`\n`);
179
+ return 1;
180
+ }
181
+ if (existing !== serialized) {
182
+ process.stdout.write(`${outPath} is out of date; re-run \`boaz manifest\`\n`);
183
+ return 1;
184
+ }
185
+ process.stdout.write(`${outPath} is up to date (${manifest.capabilities.length} capabilities)\n`);
186
+ return 0;
187
+ }
188
+ await fs.writeFile(outPath, serialized);
189
+ process.stdout.write(`wrote ${outPath} (${manifest.capabilities.length} capabilities, ${serialized.length} bytes)\n`);
190
+ if (result.diagnostics.some((d) => d.severity === 'error')) {
191
+ process.stdout.write('warning: manifest written despite errors; run `boaz verify`\n');
192
+ return 1;
193
+ }
194
+ return 0;
195
+ }
196
+ async function loadFixtures(root) {
197
+ const entries = await fs.readdir(root, { withFileTypes: true });
198
+ const fixtures = [];
199
+ for (const entry of entries) {
200
+ if (!entry.isDirectory())
201
+ continue;
202
+ const dir = path.join(root, entry.name);
203
+ let expected = [];
204
+ try {
205
+ const raw = JSON.parse(await fs.readFile(path.join(dir, 'expected-codes.json'), 'utf8'));
206
+ expected = (raw.codes ?? []).slice().sort();
207
+ }
208
+ catch {
209
+ continue;
210
+ }
211
+ fixtures.push({ name: entry.name, dir, expected });
212
+ }
213
+ return fixtures.sort((a, b) => a.name.localeCompare(b.name));
214
+ }
215
+ /**
216
+ * Each fixture declares the codes it must provoke. A rule that stops firing,
217
+ * or starts firing on clean code, fails here — which is the only thing that
218
+ * keeps a warning table honest.
219
+ */
220
+ async function runSelfCheck(root) {
221
+ const fixtures = await loadFixtures(path.resolve(root));
222
+ if (fixtures.length === 0) {
223
+ process.stdout.write(`no fixtures with expected-codes.json under ${root}\n`);
224
+ return 1;
225
+ }
226
+ const color = hasColor();
227
+ const paint = (text, code) => (color ? `\u001b[${code}m${text}\u001b[0m` : text);
228
+ let failures = 0;
229
+ for (const fixture of fixtures) {
230
+ const result = await extractCapabilities({
231
+ root: fixture.dir,
232
+ include: ['src/**/*.{ts,tsx}'],
233
+ });
234
+ const got = [...new Set(result.diagnostics.map((d) => d.code))].sort();
235
+ const missing = fixture.expected.filter((code) => !got.includes(code));
236
+ const unexpected = got.filter((code) => !fixture.expected.includes(code));
237
+ const ok = missing.length === 0 && unexpected.length === 0;
238
+ if (!ok)
239
+ failures += 1;
240
+ const shown = (codes) => (codes.length ? codes.join(', ') : '—');
241
+ process.stdout.write(`${ok ? paint('PASS', '32') : paint('FAIL', '31')} ${fixture.name.padEnd(24)} expected ${shown(fixture.expected)}\n`);
242
+ if (!ok) {
243
+ process.stdout.write(` got ${shown(got)}\n`);
244
+ if (missing.length)
245
+ process.stdout.write(` missing ${missing.join(', ')}\n`);
246
+ if (unexpected.length)
247
+ process.stdout.write(` unexpected ${unexpected.join(', ')}\n`);
248
+ for (const diagnostic of result.diagnostics) {
249
+ process.stdout.write(` ${formatDiagnostic(diagnostic, { color })}\n`);
250
+ }
251
+ }
252
+ }
253
+ process.stdout.write(`\n${fixtures.length - failures}/${fixtures.length} fixtures matched their expected codes\n`);
254
+ return failures === 0 ? 0 : 1;
255
+ }
256
+ async function commandInit(args) {
257
+ const dir = path.resolve(args.positionals[0] ?? '.');
258
+ if (!args.flags.has('skill')) {
259
+ process.stdout.write('init: pass --skill to write .agent/skills/boaz-capabilities.md\n');
260
+ return 1;
261
+ }
262
+ const target = path.join(dir, '.agent/skills/boaz-capabilities.md');
263
+ const exists = await fs
264
+ .access(target)
265
+ .then(() => true)
266
+ .catch(() => false);
267
+ if (exists && !args.flags.has('force')) {
268
+ process.stdout.write(`${target} already exists; pass --force to overwrite\n`);
269
+ return 1;
270
+ }
271
+ await fs.mkdir(path.dirname(target), { recursive: true });
272
+ await fs.writeFile(target, BOAZ_SKILL_MD);
273
+ process.stdout.write(`wrote ${target}\n`);
274
+ process.stdout.write('Next: point your agent loader (AGENTS.md, .cursor/rules, CLAUDE.md) at that file.\n');
275
+ return 0;
276
+ }
277
+ async function commandProbes(args) {
278
+ if (!args.flags.has('generate')) {
279
+ process.stderr.write('probes: pass --generate to write a starting probe file from the manifest\n');
280
+ return 1;
281
+ }
282
+ const dir = path.resolve(args.positionals[0] ?? '.');
283
+ const manifestPath = path.resolve(single(args.flags, 'manifest') ?? path.join(dir, 'agent-manifest.json'));
284
+ let manifest;
285
+ try {
286
+ manifest = JSON.parse(await fs.readFile(manifestPath, 'utf8'));
287
+ }
288
+ catch (error) {
289
+ process.stderr.write(`probes: cannot read ${manifestPath} (${error.message})\n`);
290
+ return 2;
291
+ }
292
+ if (!Array.isArray(manifest.capabilities)) {
293
+ process.stderr.write(`probes: ${manifestPath} has no capabilities array; run \`boaz manifest\` first\n`);
294
+ return 2;
295
+ }
296
+ const outPath = path.resolve(single(args.flags, 'out') ?? path.join(path.dirname(manifestPath), 'probes.generated.json'));
297
+ const exists = await fs
298
+ .access(outPath)
299
+ .then(() => true)
300
+ .catch(() => false);
301
+ if (exists && !args.flags.has('force')) {
302
+ process.stderr.write(`probes: ${outPath} exists; pass --force to overwrite\n`);
303
+ return 1;
304
+ }
305
+ const result = generateProbes(manifest, {
306
+ ...(args.flags.has('keywords-only') ? { titles: false } : {}),
307
+ ...(args.flags.has('titles-only') ? { keywords: false } : {}),
308
+ });
309
+ await fs.writeFile(outPath, serializeProbes(result));
310
+ const capabilityCount = manifest.capabilities.length;
311
+ process.stdout.write(`wrote ${outPath}: ${result.questions.length} probes covering ` +
312
+ `${capabilityCount - result.uncovered.length} of ${capabilityCount} capabilities\n`);
313
+ if (result.collisions.length) {
314
+ process.stdout.write(`\n${result.collisions.length} phrase(s) claim more than one capability:\n`);
315
+ for (const collision of result.collisions) {
316
+ process.stdout.write(` ${collision.source.padEnd(7)} "${collision.phrase}" — ${collision.claimants.join(', ')}\n`);
317
+ }
318
+ process.stdout.write(' A shared phrase is a routing coin flip: give one of them a phrase of its own.\n');
319
+ }
320
+ if (result.uncovered.length) {
321
+ process.stdout.write(`\n${result.uncovered.length} capability/capabilities with no probe:\n`);
322
+ for (const gap of result.uncovered)
323
+ process.stdout.write(` ${gap.id} — ${gap.reason}\n`);
324
+ }
325
+ process.stdout.write(`\nNext: boaz audit --probes ${outPath} --module <agent-setup.mjs>\n`);
326
+ return 0;
327
+ }
328
+ async function main() {
329
+ let args;
330
+ try {
331
+ args = parseArgs(process.argv.slice(2));
332
+ }
333
+ catch (error) {
334
+ process.stderr.write(`${error.message}\n\n${HELP}`);
335
+ return 2;
336
+ }
337
+ switch (args.command) {
338
+ case 'verify':
339
+ return commandVerify(args);
340
+ case 'manifest':
341
+ return commandManifest(args);
342
+ case 'codes': {
343
+ const code = args.positionals[0];
344
+ if (code) {
345
+ const entry = printCodes()
346
+ .split('\n\n')
347
+ .find((block) => block.startsWith(code));
348
+ process.stdout.write(`${entry ?? `unknown code ${code}`}\n`);
349
+ return entry ? 0 : 1;
350
+ }
351
+ process.stdout.write(`${printCodes()}\n`);
352
+ return 0;
353
+ }
354
+ case 'audit': {
355
+ const probes = single(args.flags, 'probes');
356
+ const module = single(args.flags, 'module');
357
+ if (!probes || !module) {
358
+ process.stderr.write('audit: --probes <file> and --module <file> are required\n');
359
+ return 2;
360
+ }
361
+ return runAudit({
362
+ probes,
363
+ module,
364
+ ...(args.flags.has('json') ? { json: true } : {}),
365
+ ...(args.flags.has('quiet') ? { quiet: true } : {}),
366
+ });
367
+ }
368
+ case 'bench': {
369
+ const probes = single(args.flags, 'probes');
370
+ const module = single(args.flags, 'module');
371
+ if (!probes || !module) {
372
+ process.stderr.write('bench: --probes <file> and --module <file> are required\n');
373
+ return 2;
374
+ }
375
+ const json = single(args.flags, 'json');
376
+ return runBench({
377
+ probes,
378
+ module,
379
+ ...(json ? { json } : {}),
380
+ ...(args.flags.has('samples') ? { samples: true } : {}),
381
+ });
382
+ }
383
+ case 'probes':
384
+ return commandProbes(args);
385
+ case 'init':
386
+ return commandInit(args);
387
+ case 'version':
388
+ process.stdout.write(`${await readVersion()}\n`);
389
+ return 0;
390
+ case 'help':
391
+ process.stdout.write(HELP);
392
+ return 0;
393
+ default:
394
+ process.stderr.write(`unknown command "${args.command}"\n\n${HELP}`);
395
+ return 2;
396
+ }
397
+ }
398
+ main().then((code) => {
399
+ process.exitCode = code;
400
+ }, (error) => {
401
+ process.stderr.write(`${error instanceof Error ? error.stack ?? error.message : String(error)}\n`);
402
+ process.exitCode = 2;
403
+ });
404
+ //# sourceMappingURL=index.js.map
@@ -0,0 +1 @@
1
+ {"version":3,"file":"index.js","sourceRoot":"","sources":["../../src/cli/index.ts"],"names":[],"mappings":";AACA,OAAO,EAAE,MAAM,kBAAkB,CAAC;AAClC,OAAO,IAAI,MAAM,WAAW,CAAC;AAC7B,OAAO,EAAE,aAAa,EAAE,MAAM,UAAU,CAAC;AACzC,OAAO,EAAE,aAAa,EAAE,mBAAmB,EAAsB,MAAM,qBAAqB,CAAC;AAC7F,OAAO,EAAE,gBAAgB,EAAE,aAAa,EAAE,UAAU,EAAE,MAAM,oBAAoB,CAAC;AACjF,OAAO,EAAE,aAAa,EAAE,MAAM,qBAAqB,CAAC;AACpD,OAAO,EAAE,QAAQ,EAAE,MAAM,YAAY,CAAC;AACtC,OAAO,EAAE,QAAQ,EAAE,MAAM,YAAY,CAAC;AACtC,OAAO,EAAE,cAAc,EAAE,eAAe,EAAE,MAAM,oBAAoB,CAAC;AAUrE,MAAM,IAAI,GAAG;;;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WAAW,EAAE,IAAI,CAAC,CAAC;YACjD,OAAO,CAAC,CAAC;QACX,KAAK,MAAM;YACT,OAAO,CAAC,MAAM,CAAC,KAAK,CAAC,IAAI,CAAC,CAAC;YAC3B,OAAO,CAAC,CAAC;QACX;YACE,OAAO,CAAC,MAAM,CAAC,KAAK,CAAC,oBAAoB,IAAI,CAAC,OAAO,QAAQ,IAAI,EAAE,CAAC,CAAC;YACrE,OAAO,CAAC,CAAC;IACb,CAAC;AACH,CAAC;AAED,IAAI,EAAE,CAAC,IAAI,CACT,CAAC,IAAI,EAAE,EAAE;IACP,OAAO,CAAC,QAAQ,GAAG,IAAI,CAAC;AAC1B,CAAC,EACD,CAAC,KAAc,EAAE,EAAE;IACjB,OAAO,CAAC,MAAM,CAAC,KAAK,CAAC,GAAG,KAAK,YAAY,KAAK,CAAC,CAAC,CAAC,KAAK,CAAC,KAAK,IAAI,KAAK,CAAC,OAAO,CAAC,CAAC,CAAC,MAAM,CAAC,KAAK,CAAC,IAAI,CAAC,CAAC;IACnG,OAAO,CAAC,QAAQ,GAAG,CAAC,CAAC;AACvB,CAAC,CACF,CAAC"}
@@ -0,0 +1,20 @@
1
+ export interface Probe {
2
+ /** What the visitor types. */
3
+ question: string;
4
+ /**
5
+ * The capability or answer rule that should handle it. Grouped intents share
6
+ * one expectation ("projects.using").
7
+ */
8
+ expect?: string;
9
+ /** Arguments the capability must be called with, when they are not inferable. */
10
+ args?: Record<string, unknown>;
11
+ /** Facts a correct answer must contain. Used by bench; audit ignores it. */
12
+ must?: string[];
13
+ /** Groups paraphrases of one question for the bench (e.g. "projects.using"). */
14
+ intent?: string;
15
+ }
16
+ export interface ProbeFile {
17
+ questions: Probe[];
18
+ }
19
+ export declare function loadProbes(file: string): Promise<Probe[]>;
20
+ //# sourceMappingURL=probes.d.ts.map
@@ -0,0 +1 @@
1
+ {"version":3,"file":"probes.d.ts","sourceRoot":"","sources":["../../src/cli/probes.ts"],"names":[],"mappings":"AAMA,MAAM,WAAW,KAAK;IACpB,8BAA8B;IAC9B,QAAQ,EAAE,MAAM,CAAC;IACjB;;;OAGG;IACH,MAAM,CAAC,EAAE,MAAM,CAAC;IAChB,iFAAiF;IACjF,IAAI,CAAC,EAAE,MAAM,CAAC,MAAM,EAAE,OAAO,CAAC,CAAC;IAC/B,4EAA4E;IAC5E,IAAI,CAAC,EAAE,MAAM,EAAE,CAAC;IAChB,gFAAgF;IAChF,MAAM,CAAC,EAAE,MAAM,CAAC;CACjB;AAED,MAAM,WAAW,SAAS;IACxB,SAAS,EAAE,KAAK,EAAE,CAAC;CACpB;AAED,wBAAsB,UAAU,CAAC,IAAI,EAAE,MAAM,GAAG,OAAO,CAAC,KAAK,EAAE,CAAC,CAoB/D"}
@@ -0,0 +1,27 @@
1
+ // Probe files: the questions an app promises its assistant can answer.
2
+ //
3
+ // A probe is one question plus what a correct answer looks like. The audit
4
+ // command checks *where* it goes; the bench command checks *how* it reads.
5
+ import fs from 'node:fs/promises';
6
+ export async function loadProbes(file) {
7
+ const raw = await fs.readFile(file, 'utf8');
8
+ const parsed = JSON.parse(raw);
9
+ const questions = Array.isArray(parsed) ? parsed : parsed.questions;
10
+ if (!Array.isArray(questions) || questions.length === 0) {
11
+ throw new Error(`${file}: expected { "questions": [...] } or a non-empty array`);
12
+ }
13
+ const probes = questions.map((probe, index) => {
14
+ if (!probe || typeof probe.question !== 'string' || !probe.question.trim()) {
15
+ throw new Error(`${file}: question ${index + 1} needs a "question" string`);
16
+ }
17
+ return {
18
+ question: probe.question.trim(),
19
+ ...(probe.expect ? { expect: probe.expect } : {}),
20
+ ...(probe.args ? { args: probe.args } : {}),
21
+ ...(probe.must ? { must: probe.must.map(String) } : {}),
22
+ ...(probe.intent ? { intent: probe.intent } : {}),
23
+ };
24
+ });
25
+ return probes;
26
+ }
27
+ //# sourceMappingURL=probes.js.map
@@ -0,0 +1 @@
1
+ {"version":3,"file":"probes.js","sourceRoot":"","sources":["../../src/cli/probes.ts"],"names":[],"mappings":"AAAA,u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YAC3C,GAAG,CAAC,KAAK,CAAC,IAAI,CAAC,CAAC,CAAC,EAAE,IAAI,EAAE,KAAK,CAAC,IAAI,CAAC,GAAG,CAAC,MAAM,CAAC,EAAE,CAAC,CAAC,CAAC,EAAE,CAAC;YACvD,GAAG,CAAC,KAAK,CAAC,MAAM,CAAC,CAAC,CAAC,EAAE,MAAM,EAAE,KAAK,CAAC,MAAM,EAAE,CAAC,CAAC,CAAC,EAAE,CAAC;SAClD,CAAC;IACJ,CAAC,CAAC,CAAC;IACH,OAAO,MAAM,CAAC;AAChB,CAAC"}
@@ -0,0 +1,2 @@
1
+ export declare const BOAZ_SKILL_MD = "---\nname: boaz-capabilities\ndescription: Use when adding or changing a route, control, answer rule, or reply copy in an app with the boaz assistant. Declares capabilities, then proves the answers are routed and readable.\n---\n\n# boaz: capabilities, answers and proof\n\nThis repository ships an in-browser assistant (`boaz`). It has no model:\nit answers from the build-time capability manifest, from facts and rules your app\ndeclares, and from the page text. It cannot read your source and it cannot see\nthe DOM. A feature without a capability declaration is invisible to it, and a\nquestion no rule claims gets a keyword guess.\n\n## When this skill applies\n\nAny time you:\n\n- add a route, page, tab, or deep-linked view;\n- add or change a modal, wizard, filter, sort, or bulk action;\n- rename a user-visible control or change what it does;\n- add an answer rule (a sentence computed from app data);\n- change any reply copy the assistant says;\n- delete a screen, action or rule.\n\n## 1. Declare what exists\n\nEvery user-reachable destination gets a `route` capability. Every mutating or\nstateful control gets an `action`. Live state the assistant should read before\nacting gets a `query`. A fixed paragraph it should quote gets a `knowledge`.\n\nDeclare it in a `capabilities.ts` next to the feature, not in a central file.\nCentral files rot; co-located ones get updated with the feature.\n\n```ts\nimport { defineCapability } from '@shobyde/boaz/core';\n\nexport const openInvoices = defineCapability({\n id: 'billing.open_invoices',\n kind: 'route',\n title: 'Billing & invoices',\n description:\n 'Takes the visitor to the billing page where they can change plan, update the payment card, or download past invoices as PDF.',\n keywords: ['invoice', 'receipt', 'payment', 'card', 'subscription', 'plan'],\n route: '/settings/billing',\n});\n```\n\n**Metadata that decides retrieval** (the description is the search text):\n\n- **id**: `<area>.<verb_or_noun>`, lowercase, never reused for something else.\n The conversation refers to ids.\n- **title**: what a visitor would call it. \"Download invoices\", not\n `InvoiceTableToolbar`.\n- **description**: start from the visitor's goal \u2014 \"Use when the visitor\n wants to\u2026\". If it lacks the words a visitor types, the capability is\n unfindable.\n- **keywords**: synonyms and plural forms. Cheap; add them.\n- **route**: where its UI lives, even for actions.\n- **paramsSchema**: strict JSON Schema, `additionalProperties: false`, enums over\n free strings.\n\n**Confirmation** (`requiresConfirmation: true`) is for deletes, spends, sends,\nand anything hard to undo. Not for navigation, filtering, or opening a dialog.\n\n## 2. Decide who answers: capability, rule, or knowledge\n\nThe engine tries, in order: an answer rule, then the keyword engine over the\ncapabilities, then nothing.\n\n| the visitor says | it should be |\n| --- | --- |\n| \"open billing\", \"filter invoices to overdue\" | a `route`/`action` capability |\n| \"which invoices are overdue?\" | a `query` capability, or an answer rule if it joins data |\n| \"what is your refund policy?\" | a `knowledge` capability |\n| \"which projects use Python?\" (a join over rows) | an **answer rule** |\n| \"what does he do?\" (a phrasing with no content words) | an **answer rule** with `match` |\n\nRules live in your app, not the library. The library owns retrieval, inference\nand the order of operations; you own the facts.\n\n```ts\nexport const answers = [\n {\n id: 'projects.using',\n title: 'Which projects use a technology',\n keywords: ['which projects use', 'written in', 'uses'],\n goal: 'projects_using(?P)',\n steps: [{ capabilityId: 'projects.list', toFacts: projectFacts }],\n // Needs the visitor to name a technology: no subject, no call.\n explain: ({ terms, solutions }) => `Matched ${terms[0]} against ${solutions.length} projects`,\n compose: ({ solutions, terms }) => phraseProjectsUsing(solutions, terms[0]),\n },\n];\n```\n\nRule options that matter:\n\n- **`steps`** run a capability first; the result becomes facts for the goal.\n- **`requiresSubject`** \u2014 a rule that joins `asked(?T)` waits until the question\n names a value to look up; a listing rule (\"which invoices are overdue\") runs\n whenever it matches. Set `false` to opt out entirely.\n- **`constants`** on the engine: values a tool will return, declared up front, so\n \"what's built with python?\" is recognised before the tool has run.\n- **`match(query)`** \u2014 an explicit trigger for phrasings keyword matching cannot\n see, because they tokenize to nothing (\"what does he do?\").\n- **`threshold`** \u2014 raise it when two rules share vocabulary.\n\n**Controller verbs are the app's.** A question starting with show / open / go /\ntake / read / expand / copy / download / print / visit / browse / scroll / jump /\nnavigate / see is handled by a capability, not by an answer rule. Apps with their\nown commands extend the list instead of fighting it:\n\n```ts\ncreateRulesEngine({ ..., controllerVerbs: ['filter', 'sort', 'apply', 'clear'] });\n```\n\n**Enums are literal.** A capability is called with the enum value that appeared in\nthe question, so \"show only the unpaid invoices\" cannot fill `status: overdue`.\nInclude the visitor's word in the enum and normalise it in the handler.\n\n## 3. Write the copy like writing\n\nOne intent should not have one sentence. Key the construction on the question\nform (count-first for \"how many\", entity-first for \"which\"), and pick a\nrealisation from a hash of the question, so paraphrases differ while a repeated\nquestion stays identical \u2014 a visitor can quote what they saw.\n\n```ts\nconst pick = (list, key) => list[hash(key) % list.length];\n\nif (/how many|how much/i.test(query)) return pick([`${n} projects: ${names}.`, ...], query);\nreturn pick([`${names} \u2014 ${n} of them.`, `Everything public: ${names}.`, ...], query);\n```\n\nThree rules that keep this honest:\n\n- **One intent per rule.** Two rules that read the same tool will fight over any\n shared keyword (\"built\"), and the loser hijacks the question.\n- **Facts first, flourish never.** Every realisation must carry every required\n fact; a stylish wrong answer is a bug.\n- **Never invent a claim to sound human.** Extra sentences must come from data\n (\"each has engineering notes\"), not from adjectives.\n\n## 4. Prove it works\n\n`verify` proves the declarations are sound. These two commands prove the\nassistant is actually useful, and they are the ones to run before you call a\ntask done.\n\n**Probe file** \u2014 the questions you promise to answer, grouped into intents:\n\n```json\n{\n \"questions\": [\n { \"question\": \"which projects use python?\", \"expect\": \"projects.using\", \"intent\": \"projects.using\", \"must\": [\"Readback\", \"Groundglass\"] },\n { \"question\": \"what's built with python?\", \"expect\": \"projects.using\", \"intent\": \"projects.using\", \"must\": [\"Readback\", \"Groundglass\"] },\n { \"question\": \"open the newest article\", \"expect\": \"blog.open_newest\" },\n { \"question\": \"show the hobnob card\", \"expect\": \"projects.card\", \"args\": { \"project\": \"hobnob\" } }\n ]\n}\n```\n\nFour paraphrases per intent is enough to expose a template. `must` is what a\ncorrect answer contains; `args` is what the capability must be called with. Only\nintents with a `must` list are scored \u2014 a route or action has no copy to compare.\n\n**Setup module** \u2014 the harness asks *your* engine, not a reimplementation:\n\n```js\n// agent-setup.mjs\nimport manifest from './agent-manifest.json' with { type: 'json' };\nimport { createRulesEngine } from '@shobyde/boaz/rules';\n\nexport const capabilities = manifest.capabilities;\nexport const answers = /* your rules */ [];\n\n// Without this, a rule that reads a tool answers with the tool call, not a sentence.\nexport const runCapability = async (id, args) =>\n handlers[id] ? handlers[id](args) : {};\n\nexport function createEngine() {\n return createRulesEngine({ knowledge, answers, capabilities, constants });\n}\n```\n\n**Run them:**\n\n```bash\nnpx boaz audit --probes agent-probes.json --module agent-setup.mjs\nnpx boaz bench --probes agent-probes.json --module agent-setup.mjs --samples\n```\n\n- `audit` prints one line per miss \u2014 expected id, what actually ran \u2014 and exits 1.\n Put it in CI. Add a probe for every capability you declare, in a visitor's words.\n It reports the engine's own plan: a rule that asked for a capability is named,\n a keyword match on the same capability is not. Rules that reply in prose are\n checked by `bench` through their `must` facts.\n- `bench` scores the copy per intent: **fidelity** (required facts present),\n **similarity** between paraphrases with the facts masked, **openers**, **spread**,\n **ttr**, **stable** (same question twice). Exit 1 when a fact goes missing or an\n answer wobbles.\n\nReading the numbers:\n\n| number | means |\n| --- | --- |\n| similarity 1.00 | every phrasing returned the identical sentence \u2014 a template |\n| similarity \u2248 0.5 | the wording follows the question |\n| similarity < 0.25 | check `--samples`: the topics may be drifting |\n| fidelity 100% | no paraphrase lost a fact; anything less is a bug, not style |\n| stable NO | the same question answered differently \u2014 drop the randomness |\n\nThen read the samples. The numbers say the answers stopped repeating; they cannot\nsay the answers read well.\n\n**No probe file yet?** Generate a starting one from the manifest:\n\n```bash\nnpx boaz probes --generate --manifest dist/agent-manifest.json\n```\n\nIt writes `probes.generated.json` with one question per capability title and\nkeyword, each already expecting the capability it came from, and prints two\nlists worth reading: phrases that two capabilities in the same query class both\nclaim (no probe can assert a coin flip; give one of them a phrase of its own),\nand capabilities with no probe (a capability that requires arguments cannot be\nprobed from a phrase alone, so write that one by hand with `args`). Edit the\nphrasing to match how your visitors actually talk, then run `audit`. A miss on a\ngenerated probe usually means the manifest still claims a phrasing that an\nanswer rule took over.\n\n## Done means\n\n```bash\nnpx boaz verify\nnpx boaz audit --probes agent-probes.json --module agent-setup.mjs\nnpx boaz bench --probes agent-probes.json --module agent-setup.mjs\n```\n\nAll three exit 0. If a new route is intentionally invisible to the assistant, say\nso in the pull request instead of leaving an unexplained CAP008.\n\n## Failure modes this catches\n\n| symptom | cause | fix |\n| --- | --- | --- |\n| \"I'm not sure\" for a supported thing | no capability description contains the visitor's words | rewrite the description, add keywords |\n| a question runs the wrong action | two capabilities share a noun; no verb to separate them | give each its own verb and phrase |\n| a bare noun answer (\"No stack lists much.\") | a rule matched on a quantifier | keep rules to question-shaped phrases |\n| every phrasing answers identically | one `compose` string per intent | construction on the question, realisation on the hash |\n| a phrasing with no content words is ignored | it tokenizes to nothing | `match(query)` on the rule |\n| a tool is called for a question with nothing to look up | `requiresSubject` default | name it `false` for listing rules |\n";
2
+ //# sourceMappingURL=skill-template.d.ts.map
@@ -0,0 +1 @@
1
+ {"version":3,"file":"skill-template.d.ts","sourceRoot":"","sources":["../../src/cli/skill-template.ts"],"names":[],"mappings":"AAAA,eAAO,MAAM,aAAa,izWA4PzB,CAAC"}