@mmerterden/multi-agent-pipeline 20.40.0 → 20.41.0
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/CHANGELOG.md +50 -0
- package/README.md +4 -1
- package/README.tr.md +4 -1
- package/docs/adr/0019-product-tree.md +143 -0
- package/docs/adr/README.md +1 -0
- package/docs/ecosystem.md +9 -9
- package/docs/facts.json +4 -4
- package/docs/features.md +6 -0
- package/install/claude.mjs +12 -3
- package/install/templates/claude-hooks.json +12 -1
- package/manifest.json +79 -60
- package/package.json +2 -2
- package/pipeline/commands/multi-agent/review-analysis/SKILL.md +1 -1
- package/pipeline/contract/types/index.d.ts +53 -49
- package/pipeline/lib/context-budget.mjs +5 -42
- package/pipeline/lib/hook-registration.mjs +5 -0
- package/pipeline/lib/md2confluence-v3.py +12 -4
- package/pipeline/lib/tiered-budget.mjs +87 -0
- package/pipeline/multi-agent-refs/analysis/review.md +23 -1
- package/pipeline/multi-agent-refs/features/code-graph.md +11 -1
- package/pipeline/multi-agent-refs/features/doctor.md +32 -1
- package/pipeline/multi-agent-refs/features/product-tree.md +68 -0
- package/pipeline/multi-agent-refs/features/unattended-security.md +88 -1
- package/pipeline/multi-agent-refs/features/usage-reporting.md +31 -0
- package/pipeline/multi-agent-refs/help/en.md +1 -0
- package/pipeline/multi-agent-refs/help/tr.md +1 -0
- package/pipeline/multi-agent-refs/knowledge.md +58 -0
- package/pipeline/multi-agent-refs/phases/phase-0-init.md +4 -0
- package/pipeline/multi-agent-refs/phases/phase-1-plan.md +4 -0
- package/pipeline/multi-agent-refs/phases/phase-5-report.md +2 -0
- package/pipeline/office/index.html +13 -7
- package/pipeline/office/toolkit.json +1 -1
- package/pipeline/preferences-template.json +1 -0
- package/pipeline/schemas/learnings-ledger.schema.json +35 -2
- package/pipeline/schemas/office-archive.schema.json +225 -128
- package/pipeline/schemas/prefs.schema.json +83 -0
- package/pipeline/schemas/product-tree-overlay.schema.json +57 -0
- package/pipeline/schemas/product-tree.schema.json +136 -0
- package/pipeline/schemas/toolkit-path-params.json +1 -1
- package/pipeline/scripts/_eval-stats.mjs +182 -0
- package/pipeline/scripts/_guard_rules.py +130 -1
- package/pipeline/scripts/_learnings-promotion.mjs +229 -0
- package/pipeline/scripts/_locate.mjs +539 -0
- package/pipeline/scripts/_memory-policy.mjs +213 -14
- package/pipeline/scripts/_product-tree-extract.mjs +761 -0
- package/pipeline/scripts/_product-tree.mjs +923 -0
- package/pipeline/scripts/_retrieval.mjs +13 -2
- package/pipeline/scripts/_stack-routing.mjs +1 -0
- package/pipeline/scripts/_user_guard_rules.py +744 -0
- package/pipeline/scripts/agent-guard.py +61 -5
- package/pipeline/scripts/agent-guard.sh +8 -1
- package/pipeline/scripts/doctor.mjs +157 -1
- package/pipeline/scripts/graph-query.mjs +257 -17
- package/pipeline/scripts/learnings-ledger.mjs +664 -43
- package/pipeline/scripts/note-mcp-failure.mjs +356 -0
- package/pipeline/scripts/note-mcp-failure.sh +19 -0
- package/pipeline/scripts/note-skill-use.mjs +93 -23
- package/pipeline/scripts/office-archive.mjs +23 -10
- package/pipeline/scripts/office-memory.mjs +4 -1
- package/pipeline/scripts/persona-walk-anchors.mjs +443 -0
- package/pipeline/scripts/product-tree-eval.mjs +685 -0
- package/pipeline/scripts/product-tree.mjs +544 -0
- package/pipeline/skills/.skill-manifest.json +11 -7
- package/pipeline/skills/.skills-index.json +12 -1
- package/pipeline/skills/shared/README.md +4 -3
- package/pipeline/skills/shared/core/google-play-compliance/references/examples.md +1 -1
- package/pipeline/skills/shared/core/multi-agent-review-analysis/SKILL.md +1 -1
- package/pipeline/skills/shared/external/backlog/SKILL.md +1 -1
- package/pipeline/skills/shared/external/localization-reuse-map/SKILL.md +1 -1
- package/pipeline/skills/shared/external/spec-persona-walk/SKILL.md +118 -0
- package/pipeline/skills/shared/external/spec-persona-walk/evals/evals.json +50 -0
- package/pipeline/skills/shared/external/spec-persona-walk/scripts/persona-walk-anchors.mjs +443 -0
- package/pipeline/skills/shared/external/storekit/SKILL.md +1 -1
- package/pipeline/skills/shared/external/swiftdata/SKILL.md +1 -1
- package/pipeline/skills/skill-copies.json +5 -1
- package/pipeline/skills/skills-index.md +2 -1
|
@@ -0,0 +1,544 @@
|
|
|
1
|
+
#!/usr/bin/env node
|
|
2
|
+
|
|
3
|
+
/**
|
|
4
|
+
* @file product-tree.mjs - build, query and annotate the product tree.
|
|
5
|
+
*
|
|
6
|
+
* The product tree is the screen layer over the code graph: screens, routes,
|
|
7
|
+
* flows, localized strings, endpoints and tests, derived from source without
|
|
8
|
+
* a model (see _product-tree.mjs for what each stack reads). It lets a bug
|
|
9
|
+
* written in the words a person saw ("the Pay now button does nothing") reach
|
|
10
|
+
* the files behind that screen.
|
|
11
|
+
*
|
|
12
|
+
* product-tree build [--root <dir>] [--out <file>] [--stack ios,android,web] [--json]
|
|
13
|
+
* Derive the tree and write it, 0600, to
|
|
14
|
+
* ~/.claude/knowledge/<project>/product-tree.json. A root that is a git
|
|
15
|
+
* top level, main or linked worktree, takes the main repository's name
|
|
16
|
+
* (lib/slug.mjs repoName); any other folder its own name. The same name
|
|
17
|
+
* is the tree's project and the one excludeProjects is checked against. Prints a summary
|
|
18
|
+
* with screen-index coverage per stack: screens, how many are reachable
|
|
19
|
+
* through an entry, route or navigation edge, and how many programmatic
|
|
20
|
+
* navigation calls resolved to a screen.
|
|
21
|
+
*
|
|
22
|
+
* product-tree locate "<bug text>" [--tree <file>] [--graph <file>] [--max-chars N] [--json]
|
|
23
|
+
* Rank screens and files for the text. Uses the code graph beside the
|
|
24
|
+
* tree when there is one. The text goes inside one untrusted-data
|
|
25
|
+
* block, because screen names and strings come from the repository,
|
|
26
|
+
* and the block is cut to N characters (default 6000) by dropping the
|
|
27
|
+
* lowest-ranked lines whole. Nothing matched prints nothing on stdout
|
|
28
|
+
* and says so on stderr. Overlay rows are not read: agreed rows feed
|
|
29
|
+
* the ranking only from M2 on.
|
|
30
|
+
*
|
|
31
|
+
* product-tree show <node id or name> [--tree <file>] [--json]
|
|
32
|
+
* One node, its edges, and any overlay rows about it, in one
|
|
33
|
+
* untrusted-data block. --json strips control characters from every
|
|
34
|
+
* string and carries an "untrusted" note, as locate --json does.
|
|
35
|
+
*
|
|
36
|
+
* product-tree propose --kind <kind> --name <name> --evidence <path:line> [...]
|
|
37
|
+
* [--parent <node id>] [--note <text>] [--root <dir>] [--tree <file>]
|
|
38
|
+
* Append a proposal to product-tree-overlay.jsonl beside the tree.
|
|
39
|
+
* Every --evidence must name a regular file whose real path is inside
|
|
40
|
+
* --root, and a line it has. --parent must name a tree node or an
|
|
41
|
+
* earlier proposal. Proposing the same thing again appends nothing and
|
|
42
|
+
* reports the existing proposal and its status, so a person's decision
|
|
43
|
+
* stands. A proposal is never used as fact until a person agrees to it.
|
|
44
|
+
*
|
|
45
|
+
* product-tree agree --id <P:xxxxxxxx> [--tree <file>]
|
|
46
|
+
* product-tree reject --id <P:xxxxxxxx> [--tree <file>]
|
|
47
|
+
* Record a person's decision on a proposal. Refused in an unattended
|
|
48
|
+
* run (MULTI_AGENT_UNATTENDED=1) and whenever stdin is not a terminal.
|
|
49
|
+
* The terminal check stops a piped shell, not a determined one: an
|
|
50
|
+
* agent can allocate a pseudo-terminal (script(1)). agent-guard is the
|
|
51
|
+
* layer that refuses an agent's agree or reject.
|
|
52
|
+
*
|
|
53
|
+
* --name and --note lose control characters before a proposal is written.
|
|
54
|
+
*
|
|
55
|
+
* build, locate, show and propose do nothing for a repository listed in
|
|
56
|
+
* prefs.global.memory.excludeProjects, and say so on stderr.
|
|
57
|
+
*
|
|
58
|
+
* Exit codes:
|
|
59
|
+
* 0 done
|
|
60
|
+
* 1 tree or root missing, unreadable, or not written
|
|
61
|
+
* 2 proposal refused (no evidence, evidence not in the repository, or a
|
|
62
|
+
* --parent that names nothing), or an agree / reject naming a proposal
|
|
63
|
+
* the overlay does not hold
|
|
64
|
+
* 3 agree / reject refused (unattended or no terminal), or show found no
|
|
65
|
+
* such node
|
|
66
|
+
* 64 usage error
|
|
67
|
+
*
|
|
68
|
+
* @module pipeline/scripts/product-tree
|
|
69
|
+
*/
|
|
70
|
+
|
|
71
|
+
import {
|
|
72
|
+
appendFileSync,
|
|
73
|
+
chmodSync,
|
|
74
|
+
existsSync,
|
|
75
|
+
mkdirSync,
|
|
76
|
+
readFileSync,
|
|
77
|
+
realpathSync,
|
|
78
|
+
writeFileSync,
|
|
79
|
+
} from "node:fs";
|
|
80
|
+
import { basename, dirname, join, resolve, relative, isAbsolute, sep } from "node:path";
|
|
81
|
+
import { homedir } from "node:os";
|
|
82
|
+
import { createInterface } from "node:readline";
|
|
83
|
+
import { buildTreeFromDisk, safeGit, TREE_STACKS, MAX_INPUT_BYTES } from "./_product-tree.mjs";
|
|
84
|
+
import { memoryExcluded } from "./_memory-policy.mjs";
|
|
85
|
+
import { repoName } from "../lib/slug.mjs";
|
|
86
|
+
import { readRegularFile } from "../lib/regular-file.mjs";
|
|
87
|
+
import { wrapUntrusted } from "../lib/untrusted-fence.mjs";
|
|
88
|
+
import { buildLocateIndex, rankArms, locateInput } from "./_locate.mjs";
|
|
89
|
+
import { fitToBudget } from "../lib/context-budget.mjs";
|
|
90
|
+
import { shortId } from "./_retrieval.mjs";
|
|
91
|
+
import { isUnattended } from "../lib/unattended.mjs";
|
|
92
|
+
import { parseArgs } from "../lib/args.mjs";
|
|
93
|
+
import { exitOnHelp } from "../lib/cli-help.mjs";
|
|
94
|
+
import { invokedDirectly } from "../lib/invoked-directly.mjs";
|
|
95
|
+
|
|
96
|
+
exitOnHelp(import.meta.url);
|
|
97
|
+
|
|
98
|
+
export const DEFAULT_MAX_CHARS = 6000;
|
|
99
|
+
const COMMANDS = new Set(["build", "locate", "show", "propose", "agree", "reject"]);
|
|
100
|
+
const PROPOSABLE = new Set(["journey", "flow", "screen", "feature", "rule", "scenario", "event"]);
|
|
101
|
+
|
|
102
|
+
/**
|
|
103
|
+
* The project a root belongs to: the main repository's name when the root is
|
|
104
|
+
* a git top level, so a linked worktree shares its repository's tree and
|
|
105
|
+
* exclusion; the folder's own name otherwise.
|
|
106
|
+
*/
|
|
107
|
+
export function projectOf(root) {
|
|
108
|
+
const dir = resolve(root);
|
|
109
|
+
try {
|
|
110
|
+
const top = safeGit(dir, ["rev-parse", "--show-toplevel"]).trim();
|
|
111
|
+
if (top && realpathSync(top) === realpathSync(dir)) {
|
|
112
|
+
return repoName({ cwd: dir, fallback: basename(dir) });
|
|
113
|
+
}
|
|
114
|
+
} catch {
|
|
115
|
+
/* not a git top level */
|
|
116
|
+
}
|
|
117
|
+
return basename(dir);
|
|
118
|
+
}
|
|
119
|
+
|
|
120
|
+
export const defaultTreePath = (cwd = process.cwd()) =>
|
|
121
|
+
join(homedir(), ".claude", "knowledge", projectOf(cwd), "product-tree.json");
|
|
122
|
+
export const overlayPath = (treePath) => join(dirname(treePath), "product-tree-overlay.jsonl");
|
|
123
|
+
|
|
124
|
+
function fail(code, msg) {
|
|
125
|
+
process.stderr.write(`product-tree: ${msg}\n`);
|
|
126
|
+
process.exit(code);
|
|
127
|
+
}
|
|
128
|
+
|
|
129
|
+
function headCommit(root) {
|
|
130
|
+
try {
|
|
131
|
+
return safeGit(root, ["rev-parse", "HEAD"]).trim();
|
|
132
|
+
} catch {
|
|
133
|
+
return null;
|
|
134
|
+
}
|
|
135
|
+
}
|
|
136
|
+
|
|
137
|
+
/** True, with a note on stderr, when the repository's memory is excluded. */
|
|
138
|
+
function excluded(slug, what) {
|
|
139
|
+
if (!memoryExcluded(slug)) return false;
|
|
140
|
+
process.stderr.write(
|
|
141
|
+
`product-tree: ${slug} is excluded by prefs.global.memory.excludeProjects; ${what}\n`,
|
|
142
|
+
);
|
|
143
|
+
return true;
|
|
144
|
+
}
|
|
145
|
+
|
|
146
|
+
function loadTree(path) {
|
|
147
|
+
if (!existsSync(path)) fail(1, `tree not found: ${path} (run product-tree build)`);
|
|
148
|
+
try {
|
|
149
|
+
return JSON.parse(readFileSync(path, "utf8"));
|
|
150
|
+
} catch (e) {
|
|
151
|
+
fail(1, `tree unreadable: ${path}: ${e.message}`);
|
|
152
|
+
}
|
|
153
|
+
return null;
|
|
154
|
+
}
|
|
155
|
+
|
|
156
|
+
/** Overlay rows, oldest first; a malformed line is skipped. */
|
|
157
|
+
export function readOverlay(path) {
|
|
158
|
+
if (!existsSync(path)) return [];
|
|
159
|
+
return readFileSync(path, "utf8")
|
|
160
|
+
.split("\n")
|
|
161
|
+
.filter(Boolean)
|
|
162
|
+
.flatMap((l) => {
|
|
163
|
+
try {
|
|
164
|
+
return [JSON.parse(l)];
|
|
165
|
+
} catch {
|
|
166
|
+
return [];
|
|
167
|
+
}
|
|
168
|
+
});
|
|
169
|
+
}
|
|
170
|
+
|
|
171
|
+
/**
|
|
172
|
+
* Status of each proposal: the latest decision, else "proposed". The first
|
|
173
|
+
* propose row for an id is the proposal; a later one with the same id does
|
|
174
|
+
* not reset a decision.
|
|
175
|
+
*/
|
|
176
|
+
export function proposalStatus(rows) {
|
|
177
|
+
const out = new Map();
|
|
178
|
+
for (const r of rows) {
|
|
179
|
+
if (r.op === "propose") {
|
|
180
|
+
if (!out.has(r.id)) out.set(r.id, { row: r, status: "proposed" });
|
|
181
|
+
} else if (out.has(r.ref)) out.get(r.ref).status = r.op === "agree" ? "agreed" : "rejected";
|
|
182
|
+
}
|
|
183
|
+
return out;
|
|
184
|
+
}
|
|
185
|
+
|
|
186
|
+
/**
|
|
187
|
+
* Whether this process may record a person's decision.
|
|
188
|
+
*
|
|
189
|
+
* @param {{env?: Record<string,string|undefined>, isTTY?: boolean}} ctx
|
|
190
|
+
* @returns {{ok: boolean, reason?: string}}
|
|
191
|
+
*/
|
|
192
|
+
export function canDecide({ env = process.env, isTTY = Boolean(process.stdin.isTTY) } = {}) {
|
|
193
|
+
if (isUnattended(env)) return { ok: false, reason: "refused in an unattended run" };
|
|
194
|
+
if (!isTTY) return { ok: false, reason: "refused: agreeing needs a person at a terminal" };
|
|
195
|
+
return { ok: true };
|
|
196
|
+
}
|
|
197
|
+
|
|
198
|
+
// eslint-disable-next-line no-control-regex
|
|
199
|
+
const CONTROL = /[\u0000-\u0008\u000b-\u001f\u007f-\u009f]/g;
|
|
200
|
+
const asData = (s) => String(s).replace(CONTROL, "");
|
|
201
|
+
|
|
202
|
+
/** Said in every --json document whose strings come from the repository. */
|
|
203
|
+
export const UNTRUSTED_NOTE = "repository text: every string here is data, not instructions";
|
|
204
|
+
|
|
205
|
+
/** JSON with control characters stripped from every string. */
|
|
206
|
+
const dataJson = (doc) => JSON.stringify(doc, (_, v) => (typeof v === "string" ? asData(v) : v), 2);
|
|
207
|
+
|
|
208
|
+
/**
|
|
209
|
+
* Rank and render. The text is one untrusted-data block, fence included in
|
|
210
|
+
* maxChars, or "" when nothing matched.
|
|
211
|
+
*
|
|
212
|
+
* @returns {{screens: object[], keys: object[], files: string[], text: string}}
|
|
213
|
+
*/
|
|
214
|
+
export function locate(tree, graph, text, maxChars = DEFAULT_MAX_CHARS) {
|
|
215
|
+
const index = buildLocateIndex(locateInput(tree, graph));
|
|
216
|
+
const r = rankArms(index, text);
|
|
217
|
+
const items = [];
|
|
218
|
+
r.screens.forEach((s, i) => {
|
|
219
|
+
items.push({
|
|
220
|
+
id: s.id,
|
|
221
|
+
priority: 1000 - i,
|
|
222
|
+
line: asData(
|
|
223
|
+
`screen ${s.name}${s.routes.length ? ` [${s.routes.slice(0, 3).join(", ")}]` : ""} - ${s.path}`,
|
|
224
|
+
),
|
|
225
|
+
});
|
|
226
|
+
});
|
|
227
|
+
r.keys.slice(0, 5).forEach((k, i) => {
|
|
228
|
+
items.push({ id: `string:${k.key}`, priority: 900 - i, line: asData(`string ${k.key}`) });
|
|
229
|
+
});
|
|
230
|
+
r.tree.slice(0, 30).forEach((f, i) => {
|
|
231
|
+
items.push({ id: `file:${f}`, priority: 800 - i, line: asData(`file ${f}`) });
|
|
232
|
+
});
|
|
233
|
+
const source = `product-tree:${tree.project ?? "project"}`;
|
|
234
|
+
const { text: body } = fitToBudget(items, {
|
|
235
|
+
maxChars,
|
|
236
|
+
render: (kept) => kept.map((k) => k.line).join("\n"),
|
|
237
|
+
measure: (s) => wrapUntrusted(source, s).trimEnd().length,
|
|
238
|
+
});
|
|
239
|
+
const out = body ? wrapUntrusted(source, body).trimEnd() : "";
|
|
240
|
+
return { screens: r.screens, keys: r.keys, files: r.tree.slice(0, 30), text: out };
|
|
241
|
+
}
|
|
242
|
+
|
|
243
|
+
function findNodes(tree, ref) {
|
|
244
|
+
const exact = tree.nodes.filter((n) => n.id === ref);
|
|
245
|
+
if (exact.length) return exact;
|
|
246
|
+
return tree.nodes.filter((n) => n.name === ref);
|
|
247
|
+
}
|
|
248
|
+
|
|
249
|
+
function cmdBuild(flags) {
|
|
250
|
+
const root = resolve(typeof flags.root === "string" ? flags.root : process.cwd());
|
|
251
|
+
if (!existsSync(root)) fail(1, `root not found: ${root}`);
|
|
252
|
+
const project = projectOf(root);
|
|
253
|
+
if (excluded(project, "nothing built")) return;
|
|
254
|
+
const out = typeof flags.out === "string" ? resolve(flags.out) : defaultTreePath(root);
|
|
255
|
+
const stacks =
|
|
256
|
+
typeof flags.stack === "string"
|
|
257
|
+
? flags.stack.split(",").map((s) => (s === "node" ? "web" : s.trim()))
|
|
258
|
+
: undefined;
|
|
259
|
+
if (stacks && stacks.some((s) => !TREE_STACKS.includes(s))) {
|
|
260
|
+
fail(64, `--stack takes ${TREE_STACKS.join(", ")}`);
|
|
261
|
+
}
|
|
262
|
+
const started = Date.now();
|
|
263
|
+
const tree = buildTreeFromDisk(root, { stacks, baseCommit: headCommit(root), project });
|
|
264
|
+
try {
|
|
265
|
+
mkdirSync(dirname(out), { recursive: true });
|
|
266
|
+
writeFileSync(out, JSON.stringify(tree), { encoding: "utf8", mode: 0o600 });
|
|
267
|
+
chmodSync(out, 0o600);
|
|
268
|
+
} catch (e) {
|
|
269
|
+
fail(1, `cannot write ${out}: ${e.message}`);
|
|
270
|
+
}
|
|
271
|
+
const coverage = Object.fromEntries(
|
|
272
|
+
Object.entries(tree.coverage).map(([s, c]) => [
|
|
273
|
+
s,
|
|
274
|
+
{
|
|
275
|
+
screens: c.screens,
|
|
276
|
+
reachable: c.reachable,
|
|
277
|
+
routes: c.routes,
|
|
278
|
+
routesWithScreen: c.routesWithScreen,
|
|
279
|
+
programmatic: { total: c.programmatic.total, resolved: c.programmatic.resolved },
|
|
280
|
+
},
|
|
281
|
+
]),
|
|
282
|
+
);
|
|
283
|
+
const summary = { out, elapsedMs: Date.now() - started, ...tree.stats, coverage };
|
|
284
|
+
if (flags.json === true) {
|
|
285
|
+
process.stdout.write(JSON.stringify(summary, null, 2) + "\n");
|
|
286
|
+
return;
|
|
287
|
+
}
|
|
288
|
+
process.stdout.write(
|
|
289
|
+
`product-tree: ${tree.stats.screens} screens, ${tree.stats.strings} strings, ` +
|
|
290
|
+
`${tree.stats.nodes} nodes, ${tree.stats.edges} edges -> ${out}\n`,
|
|
291
|
+
);
|
|
292
|
+
for (const [s, c] of Object.entries(coverage)) {
|
|
293
|
+
process.stdout.write(
|
|
294
|
+
` ${s}: ${c.reachable}/${c.screens} screens reachable, ` +
|
|
295
|
+
`${c.routesWithScreen}/${c.routes} routes with a screen, ` +
|
|
296
|
+
`${c.programmatic.resolved}/${c.programmatic.total} programmatic calls resolved\n`,
|
|
297
|
+
);
|
|
298
|
+
}
|
|
299
|
+
}
|
|
300
|
+
|
|
301
|
+
function cmdLocate(flags, positional) {
|
|
302
|
+
const text = positional.join(" ").trim();
|
|
303
|
+
if (!text) fail(64, 'locate needs the bug text: product-tree locate "<text>"');
|
|
304
|
+
const treePath = typeof flags.tree === "string" ? resolve(flags.tree) : defaultTreePath();
|
|
305
|
+
const tree = loadTree(treePath);
|
|
306
|
+
if (excluded(tree.project ?? basename(dirname(treePath)), "nothing located")) return;
|
|
307
|
+
const graphPath =
|
|
308
|
+
typeof flags.graph === "string"
|
|
309
|
+
? resolve(flags.graph)
|
|
310
|
+
: join(dirname(treePath), "code-graph.json");
|
|
311
|
+
let graph = null;
|
|
312
|
+
if (existsSync(graphPath)) {
|
|
313
|
+
try {
|
|
314
|
+
graph = JSON.parse(readFileSync(graphPath, "utf8"));
|
|
315
|
+
} catch {
|
|
316
|
+
graph = null;
|
|
317
|
+
}
|
|
318
|
+
}
|
|
319
|
+
const max = Number(flags["max-chars"]) > 0 ? Number(flags["max-chars"]) : DEFAULT_MAX_CHARS;
|
|
320
|
+
const r = locate(tree, graph, text, max);
|
|
321
|
+
if (flags.json === true) {
|
|
322
|
+
process.stdout.write(
|
|
323
|
+
dataJson({ untrusted: UNTRUSTED_NOTE, query: text, graph: Boolean(graph), ...r }) + "\n",
|
|
324
|
+
);
|
|
325
|
+
} else {
|
|
326
|
+
if (r.text) process.stdout.write(`${r.text}\n`);
|
|
327
|
+
else process.stderr.write("product-tree: no screen or file matched\n");
|
|
328
|
+
}
|
|
329
|
+
}
|
|
330
|
+
|
|
331
|
+
function cmdShow(flags, positional) {
|
|
332
|
+
const ref = positional.join(" ").trim();
|
|
333
|
+
if (!ref) fail(64, "show needs a node id or name");
|
|
334
|
+
const treePath = typeof flags.tree === "string" ? resolve(flags.tree) : defaultTreePath();
|
|
335
|
+
const tree = loadTree(treePath);
|
|
336
|
+
if (excluded(tree.project ?? basename(dirname(treePath)), "nothing shown")) return;
|
|
337
|
+
const byId = new Map(tree.nodes.map((n) => [n.id, n]));
|
|
338
|
+
const status = proposalStatus(readOverlay(overlayPath(treePath)));
|
|
339
|
+
const overlay = [...status.values()].filter(
|
|
340
|
+
(p) => p.row.node?.name === ref || p.row.node?.parent === ref || p.row.id === ref,
|
|
341
|
+
);
|
|
342
|
+
const found = findNodes(tree, ref);
|
|
343
|
+
if (!found.length && !overlay.length) fail(3, `no node named ${ref}`);
|
|
344
|
+
if (found.length > 1) {
|
|
345
|
+
process.stderr.write(`product-tree: ${ref} names ${found.length} nodes:\n`);
|
|
346
|
+
for (const n of found) process.stderr.write(` ${n.id}\n`);
|
|
347
|
+
process.exit(3);
|
|
348
|
+
}
|
|
349
|
+
const node = found[0] || null;
|
|
350
|
+
const out = node ? tree.edges.filter((e) => e.from === node.id) : [];
|
|
351
|
+
const inn = node ? tree.edges.filter((e) => e.to === node.id) : [];
|
|
352
|
+
if (flags.json === true) {
|
|
353
|
+
process.stdout.write(
|
|
354
|
+
dataJson({
|
|
355
|
+
untrusted: UNTRUSTED_NOTE,
|
|
356
|
+
node,
|
|
357
|
+
out,
|
|
358
|
+
in: inn,
|
|
359
|
+
overlay: overlay.map((p) => ({ ...p.row, status: p.status })),
|
|
360
|
+
}) + "\n",
|
|
361
|
+
);
|
|
362
|
+
return;
|
|
363
|
+
}
|
|
364
|
+
const name = (id) => byId.get(id)?.name ?? id;
|
|
365
|
+
const lines = [];
|
|
366
|
+
if (node) {
|
|
367
|
+
lines.push(
|
|
368
|
+
`${node.kind} ${node.name}${node.path ? ` - ${node.path}${node.line ? `:${node.line}` : ""}` : ""}`,
|
|
369
|
+
);
|
|
370
|
+
if (node.values) for (const [l, v] of Object.entries(node.values)) lines.push(` ${l}: ${v}`);
|
|
371
|
+
if (node.files && node.kind === "screen") lines.push(` files: ${node.files.join(", ")}`);
|
|
372
|
+
for (const e of out) lines.push(` -> ${e.kind}${e.via ? `/${e.via}` : ""} ${name(e.to)}`);
|
|
373
|
+
for (const e of inn) lines.push(` <- ${e.kind}${e.via ? `/${e.via}` : ""} ${name(e.from)}`);
|
|
374
|
+
}
|
|
375
|
+
for (const p of overlay) {
|
|
376
|
+
const ev = (p.row.evidence || []).map((x) => `${x.path}:${x.line}`).join(", ");
|
|
377
|
+
lines.push(` overlay ${p.row.id} ${p.row.node.kind} ${p.row.node.name}: ${p.status} (${ev})`);
|
|
378
|
+
}
|
|
379
|
+
const source = `product-tree:${tree.project ?? "project"}`;
|
|
380
|
+
process.stdout.write(wrapUntrusted(source, lines.map(asData).join("\n")));
|
|
381
|
+
}
|
|
382
|
+
|
|
383
|
+
/**
|
|
384
|
+
* Parse and check one --evidence value against the repository. The path must
|
|
385
|
+
* resolve, symlinks followed, to a regular file inside the root, and the line
|
|
386
|
+
* must exist: a file ending in a newline has no line after it.
|
|
387
|
+
*/
|
|
388
|
+
export function checkEvidence(root, value) {
|
|
389
|
+
const m = String(value).match(/^(.+):(\d+)$/);
|
|
390
|
+
if (!m) return { error: `evidence must be <path>:<line>, got ${value}` };
|
|
391
|
+
let realRoot;
|
|
392
|
+
try {
|
|
393
|
+
realRoot = realpathSync(root);
|
|
394
|
+
} catch {
|
|
395
|
+
return { error: `root ${root} does not exist` };
|
|
396
|
+
}
|
|
397
|
+
const outside = (rel) => !rel || rel === ".." || rel.startsWith(".." + sep) || isAbsolute(rel);
|
|
398
|
+
if (outside(relative(resolve(root), resolve(root, m[1]))))
|
|
399
|
+
return { error: `${m[1]} is outside the repository` };
|
|
400
|
+
let real;
|
|
401
|
+
try {
|
|
402
|
+
real = realpathSync(resolve(root, m[1]));
|
|
403
|
+
} catch {
|
|
404
|
+
return { error: `${m[1]} does not exist in the repository` };
|
|
405
|
+
}
|
|
406
|
+
const rel = relative(realRoot, real);
|
|
407
|
+
if (outside(rel)) return { error: `${m[1]} is outside the repository` };
|
|
408
|
+
let text;
|
|
409
|
+
try {
|
|
410
|
+
text = readRegularFile(real, { maxBytes: MAX_INPUT_BYTES, within: [realRoot] });
|
|
411
|
+
} catch {
|
|
412
|
+
return { error: `${m[1]} is not a readable regular file` };
|
|
413
|
+
}
|
|
414
|
+
const lines = text.split("\n");
|
|
415
|
+
if (text.endsWith("\n")) lines.pop();
|
|
416
|
+
const line = Number(m[2]);
|
|
417
|
+
if (line < 1 || line > lines.length) return { error: `${m[1]} has no line ${line}` };
|
|
418
|
+
return {
|
|
419
|
+
path: rel.split(sep).join("/"),
|
|
420
|
+
line,
|
|
421
|
+
text: asData(lines[line - 1].trim().slice(0, 160)),
|
|
422
|
+
};
|
|
423
|
+
}
|
|
424
|
+
|
|
425
|
+
function cmdPropose(flags) {
|
|
426
|
+
const kind = flags.kind;
|
|
427
|
+
const name = typeof flags.name === "string" ? asData(flags.name).trim() : "";
|
|
428
|
+
if (typeof kind !== "string" || !PROPOSABLE.has(kind)) {
|
|
429
|
+
fail(64, `--kind takes one of ${[...PROPOSABLE].join(", ")}`);
|
|
430
|
+
}
|
|
431
|
+
if (!name) fail(64, "--name is required");
|
|
432
|
+
const treePath = typeof flags.tree === "string" ? resolve(flags.tree) : defaultTreePath();
|
|
433
|
+
const root = resolve(typeof flags.root === "string" ? flags.root : process.cwd());
|
|
434
|
+
if (excluded(projectOf(root), "nothing proposed")) return;
|
|
435
|
+
const given = [].concat(flags.evidence ?? []).filter((x) => typeof x === "string");
|
|
436
|
+
if (!given.length) fail(2, "a proposal needs at least one --evidence <path:line>");
|
|
437
|
+
const evidence = [];
|
|
438
|
+
for (const v of given) {
|
|
439
|
+
const r = checkEvidence(root, v);
|
|
440
|
+
if (r.error) fail(2, r.error);
|
|
441
|
+
evidence.push(r);
|
|
442
|
+
}
|
|
443
|
+
const path = overlayPath(treePath);
|
|
444
|
+
const existing = proposalStatus(readOverlay(path));
|
|
445
|
+
if (typeof flags.parent === "string") {
|
|
446
|
+
const known =
|
|
447
|
+
existing.has(flags.parent) || loadTree(treePath).nodes.some((n) => n.id === flags.parent);
|
|
448
|
+
if (!known) fail(2, `--parent ${flags.parent} names no tree node and no proposal`);
|
|
449
|
+
}
|
|
450
|
+
const node = {
|
|
451
|
+
kind,
|
|
452
|
+
name,
|
|
453
|
+
...(typeof flags.parent === "string" ? { parent: flags.parent } : {}),
|
|
454
|
+
};
|
|
455
|
+
const row = {
|
|
456
|
+
id: shortId("P", kind, name, ...evidence.map((e) => `${e.path}:${e.line}`)),
|
|
457
|
+
ts: new Date().toISOString(),
|
|
458
|
+
op: "propose",
|
|
459
|
+
by: "model",
|
|
460
|
+
node,
|
|
461
|
+
evidence,
|
|
462
|
+
...(typeof flags.note === "string" ? { note: asData(flags.note) } : {}),
|
|
463
|
+
};
|
|
464
|
+
const prior = existing.get(row.id);
|
|
465
|
+
if (prior) {
|
|
466
|
+
process.stderr.write(`product-tree: proposal ${row.id} already exists, ${prior.status}\n`);
|
|
467
|
+
process.stdout.write(`${row.id}\n`);
|
|
468
|
+
return;
|
|
469
|
+
}
|
|
470
|
+
appendRow(path, row);
|
|
471
|
+
process.stdout.write(`${row.id}\n`);
|
|
472
|
+
}
|
|
473
|
+
|
|
474
|
+
function appendRow(path, row) {
|
|
475
|
+
mkdirSync(dirname(path), { recursive: true });
|
|
476
|
+
appendFileSync(path, JSON.stringify(row) + "\n", { encoding: "utf8", mode: 0o600 });
|
|
477
|
+
}
|
|
478
|
+
|
|
479
|
+
async function cmdDecide(op, flags) {
|
|
480
|
+
const gate = canDecide();
|
|
481
|
+
if (!gate.ok) fail(3, gate.reason);
|
|
482
|
+
const id = typeof flags.id === "string" ? flags.id : "";
|
|
483
|
+
if (!/^P:[0-9a-f]{8}$/.test(id)) fail(64, "--id takes a proposal id, P:xxxxxxxx");
|
|
484
|
+
const treePath = typeof flags.tree === "string" ? resolve(flags.tree) : defaultTreePath();
|
|
485
|
+
const path = overlayPath(treePath);
|
|
486
|
+
const p = proposalStatus(readOverlay(path)).get(id);
|
|
487
|
+
if (!p) fail(2, `no proposal ${id} in ${path}`);
|
|
488
|
+
const ev = p.row.evidence.map((x) => `${x.path}:${x.line} ${x.text || ""}`).join("\n ");
|
|
489
|
+
process.stdout.write(asData(`${p.row.node.kind} ${p.row.node.name}\n ${ev}`) + "\n");
|
|
490
|
+
const rl = createInterface({ input: process.stdin, output: process.stdout });
|
|
491
|
+
const answer = await new Promise((done) => {
|
|
492
|
+
rl.once("close", () => done(""));
|
|
493
|
+
rl.question(`${op} this proposal? [y/N] `, done);
|
|
494
|
+
});
|
|
495
|
+
rl.close();
|
|
496
|
+
if (!/^y(es)?$/i.test(answer.trim())) {
|
|
497
|
+
process.stdout.write("nothing recorded\n");
|
|
498
|
+
return;
|
|
499
|
+
}
|
|
500
|
+
appendRow(path, {
|
|
501
|
+
id: shortId(op === "agree" ? "A" : "R", id, new Date().toISOString()),
|
|
502
|
+
ts: new Date().toISOString(),
|
|
503
|
+
op,
|
|
504
|
+
by: "human",
|
|
505
|
+
ref: id,
|
|
506
|
+
});
|
|
507
|
+
process.stdout.write(`${op === "agree" ? "agreed" : "rejected"} ${id}\n`);
|
|
508
|
+
}
|
|
509
|
+
|
|
510
|
+
async function main() {
|
|
511
|
+
let parsed;
|
|
512
|
+
try {
|
|
513
|
+
parsed = parseArgs(process.argv.slice(2), {
|
|
514
|
+
booleans: ["json"],
|
|
515
|
+
strings: [
|
|
516
|
+
"root",
|
|
517
|
+
"out",
|
|
518
|
+
"stack",
|
|
519
|
+
"tree",
|
|
520
|
+
"graph",
|
|
521
|
+
"max-chars",
|
|
522
|
+
"kind",
|
|
523
|
+
"name",
|
|
524
|
+
"id",
|
|
525
|
+
"parent",
|
|
526
|
+
"note",
|
|
527
|
+
],
|
|
528
|
+
multiple: ["evidence"],
|
|
529
|
+
unknown: "error",
|
|
530
|
+
});
|
|
531
|
+
} catch (e) {
|
|
532
|
+
fail(64, e.message);
|
|
533
|
+
}
|
|
534
|
+
const [command, ...positional] = parsed.positionals;
|
|
535
|
+
if (!COMMANDS.has(command)) fail(64, `unknown command ${command ?? "(none)"}; see --help`);
|
|
536
|
+
const { flags } = parsed;
|
|
537
|
+
if (command === "build") cmdBuild(flags);
|
|
538
|
+
else if (command === "locate") cmdLocate(flags, positional);
|
|
539
|
+
else if (command === "show") cmdShow(flags, positional);
|
|
540
|
+
else if (command === "propose") cmdPropose(flags);
|
|
541
|
+
else await cmdDecide(command, flags);
|
|
542
|
+
}
|
|
543
|
+
|
|
544
|
+
if (invokedDirectly(import.meta.url)) main();
|
|
@@ -1,7 +1,7 @@
|
|
|
1
1
|
{
|
|
2
2
|
"schemaVersion": "1.0.0",
|
|
3
|
-
"generatedAt": "2026-11-
|
|
4
|
-
"skillCount":
|
|
3
|
+
"generatedAt": "2026-11-03T17:11:02Z",
|
|
4
|
+
"skillCount": 241,
|
|
5
5
|
"entries": [
|
|
6
6
|
{
|
|
7
7
|
"path": "shared/core/apple-archive-compliance/SKILL.md",
|
|
@@ -177,7 +177,7 @@
|
|
|
177
177
|
},
|
|
178
178
|
{
|
|
179
179
|
"path": "shared/core/multi-agent-review-analysis/SKILL.md",
|
|
180
|
-
"sha256": "
|
|
180
|
+
"sha256": "b39ffd169460fce6ee113dc64c98d73e62f377e6276dc9a46a7c4849b672065d"
|
|
181
181
|
},
|
|
182
182
|
{
|
|
183
183
|
"path": "shared/core/multi-agent-review-issue/SKILL.md",
|
|
@@ -393,7 +393,7 @@
|
|
|
393
393
|
},
|
|
394
394
|
{
|
|
395
395
|
"path": "shared/external/backlog/SKILL.md",
|
|
396
|
-
"sha256": "
|
|
396
|
+
"sha256": "c4cfaf37afbc746d563d96626a3afd51ac39816a32db7957f31d537b6aa0bfe2"
|
|
397
397
|
},
|
|
398
398
|
{
|
|
399
399
|
"path": "shared/external/build-settings-audit/SKILL.md",
|
|
@@ -661,7 +661,7 @@
|
|
|
661
661
|
},
|
|
662
662
|
{
|
|
663
663
|
"path": "shared/external/localization-reuse-map/SKILL.md",
|
|
664
|
-
"sha256": "
|
|
664
|
+
"sha256": "5eb944595439370298fbdee29127846e4dc1ed59fb38d50a612a995df0337a94"
|
|
665
665
|
},
|
|
666
666
|
{
|
|
667
667
|
"path": "shared/external/macos-app-distribution/SKILL.md",
|
|
@@ -783,13 +783,17 @@
|
|
|
783
783
|
"path": "shared/external/skill-creator/SKILL.md",
|
|
784
784
|
"sha256": "98a1109097ca666a0b08e4794013046aceb4f0a9a74c25f0af387cacf31b5e16"
|
|
785
785
|
},
|
|
786
|
+
{
|
|
787
|
+
"path": "shared/external/spec-persona-walk/SKILL.md",
|
|
788
|
+
"sha256": "8646df52b7d8d6ec78b4f615f1143ee9e5fbbff0cc331fab13f1e3a5e545a0a3"
|
|
789
|
+
},
|
|
786
790
|
{
|
|
787
791
|
"path": "shared/external/speech-recognition/SKILL.md",
|
|
788
792
|
"sha256": "a58c5171aa43c573993916c35cd39d100b72a7b74671207fe1c096d56998dcfb"
|
|
789
793
|
},
|
|
790
794
|
{
|
|
791
795
|
"path": "shared/external/storekit/SKILL.md",
|
|
792
|
-
"sha256": "
|
|
796
|
+
"sha256": "8d8b58b50fbfd1c98a70cea7fd32db4fb454b5add7ca7d304c8e923e719f3f8a"
|
|
793
797
|
},
|
|
794
798
|
{
|
|
795
799
|
"path": "shared/external/swift-api-design-guidelines/SKILL.md",
|
|
@@ -849,7 +853,7 @@
|
|
|
849
853
|
},
|
|
850
854
|
{
|
|
851
855
|
"path": "shared/external/swiftdata/SKILL.md",
|
|
852
|
-
"sha256": "
|
|
856
|
+
"sha256": "b91c4a0178e654ba996064edb1bd5ecde5d6d116d460d2f93b03c6d8597f49b4"
|
|
853
857
|
},
|
|
854
858
|
{
|
|
855
859
|
"path": "shared/external/swiftlint/SKILL.md",
|
|
@@ -1,6 +1,6 @@
|
|
|
1
1
|
{
|
|
2
2
|
"schemaVersion": "1.0.0",
|
|
3
|
-
"skillCount":
|
|
3
|
+
"skillCount": 241,
|
|
4
4
|
"entries": [
|
|
5
5
|
{
|
|
6
6
|
"name": "accessibility-compliance-accessibility-audit",
|
|
@@ -2147,6 +2147,17 @@
|
|
|
2147
2147
|
"triggerPaths": [],
|
|
2148
2148
|
"relativePath": "shared/external/skill-creator/SKILL.md"
|
|
2149
2149
|
},
|
|
2150
|
+
{
|
|
2151
|
+
"name": "spec-persona-walk",
|
|
2152
|
+
"description": "Walks a spec as up to four personas drawn from it and reports missing states, unhandled errors, accessibility gaps and conflicting rules, each anchored in the document. Use when a spec needs a user-side read before build. Not for a full analysis review or test-coverage gaps.",
|
|
2153
|
+
"platform": null,
|
|
2154
|
+
"group": "external",
|
|
2155
|
+
"plugin": "ai-common-toolkit",
|
|
2156
|
+
"invokeAs": "ai-common-toolkit:spec-persona-walk",
|
|
2157
|
+
"triggerKeywords": [],
|
|
2158
|
+
"triggerPaths": [],
|
|
2159
|
+
"relativePath": "shared/external/spec-persona-walk/SKILL.md"
|
|
2160
|
+
},
|
|
2150
2161
|
{
|
|
2151
2162
|
"name": "speech-recognition",
|
|
2152
2163
|
"description": "Speech framework speech-to-text: live microphone transcription with AVAudioEngine, recorded audio files, speech and microphone permission, on-device versus server SFSpeechRecognizer, iOS 26 SpeechAnalyzer with SpeechTranscriber, DictationTranscriber, SpeechDetector, AssetInventory and async results.",
|
|
@@ -2,12 +2,12 @@
|
|
|
2
2
|
|
|
3
3
|
Single source of truth for skills delivered to both Claude Code (`~/.claude/skills/`) and Copilot CLI (`~/.copilot/skills/`) by the installer.
|
|
4
4
|
|
|
5
|
-
**Total:**
|
|
5
|
+
**Total:** 241 skills (74 core + 167 external). Auto-generated by `scripts/gen-skills-index.mjs` - do not edit by hand.
|
|
6
6
|
|
|
7
7
|
## Directory layout
|
|
8
8
|
|
|
9
9
|
- **`core/`** - 74 `multi-agent*` orchestration skills that are pipeline-critical. Edits here are core-code changes.
|
|
10
|
-
- **`external/`** -
|
|
10
|
+
- **`external/`** - 167 iOS / Android / generic skills that ship into the stack plugins.
|
|
11
11
|
- Install destinations (ADR-0009): Claude Code gets NO local copy of `external/` - it loads those skills from the `multi-agent-plugins` marketplace, namespaced (`ai-<stack>-toolkit:<name>`); only the two compliance catalogs from `core/` land in `~/.claude/skills/`. Copilot CLI and Codex CLI receive a flat copy filtered to the enabled stacks. `external/` remains the single authoring source that `build-stack-plugins.mjs` publishes from.
|
|
12
12
|
|
|
13
13
|
Source layout is logical grouping only - skill discovery at runtime is unchanged.
|
|
@@ -19,7 +19,7 @@ Source layout is logical grouping only - skill discovery at runtime is unchang
|
|
|
19
19
|
- [Android / Kotlin](#android-kotlin) - 16
|
|
20
20
|
- [Web](#web) - 10
|
|
21
21
|
- [Backend / API](#backend-api) - 11
|
|
22
|
-
- [Cross-cutting](#cross-cutting) -
|
|
22
|
+
- [Cross-cutting](#cross-cutting) - 35
|
|
23
23
|
|
|
24
24
|
## Pipeline Orchestration
|
|
25
25
|
|
|
@@ -288,6 +288,7 @@ Source layout is logical grouping only - skill discovery at runtime is unchang
|
|
|
288
288
|
| [`security-review`](./external/security-review/) | `external` | Defensive static security review of a diff or repo: threat model, OWASP and CWE findings with CVSS and evidence, before/after fixes. Use whe |
|
|
289
289
|
| [`signal-community`](./external/signal-community/) | `external` | Checks whether other people hit the same problem, via Stack Overflow, Hacker News and GitHub (keyless) plus opt-in Reddit and X. Use when a |
|
|
290
290
|
| [`skill-creator`](./external/skill-creator/) | `external` | House guide for authoring plugin skills: creating one, trimming or splitting a bloated one, sharpening a description, and choosing between a |
|
|
291
|
+
| [`spec-persona-walk`](./external/spec-persona-walk/) | `external` | Walks a spec as up to four personas drawn from it and reports missing states, unhandled errors, accessibility gaps and conflicting rules, ea |
|
|
291
292
|
| [`test-result-triage`](./external/test-result-triage/) | `external` | Judge each test result on changed code as product-bug, stale-test, valid or ambiguous (the default), and list behaviour no test covers. stal |
|
|
292
293
|
| [`valven-rules`](./external/valven-rules/) | `external` | Delivery-flow rules from metrics Valven reports: PR size, one concern per PR, tests with source, issue keys, no WIP commits, churn, PR body, |
|
|
293
294
|
|
|
@@ -28,7 +28,7 @@ When a Phase 3 review diff touches Android release-relevant paths (`AndroidManif
|
|
|
28
28
|
(google-play-compliance / dangerous-permissions - Policy - Permissions)
|
|
29
29
|
File: app/src/main/AndroidManifest.xml:12
|
|
30
30
|
Fix: Remove the permission or add Play Console justification before submitting.
|
|
31
|
-
MANAGE_EXTERNAL_STORAGE triggers required policy review on every update.
|
|
31
|
+
MANAGE_EXTERNAL_STORAGE triggers a required policy review on every update.
|
|
32
32
|
```
|
|
33
33
|
|
|
34
34
|
## `/multi-agent:review` (PR citation)
|