@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.
Files changed (76) hide show
  1. package/CHANGELOG.md +50 -0
  2. package/README.md +4 -1
  3. package/README.tr.md +4 -1
  4. package/docs/adr/0019-product-tree.md +143 -0
  5. package/docs/adr/README.md +1 -0
  6. package/docs/ecosystem.md +9 -9
  7. package/docs/facts.json +4 -4
  8. package/docs/features.md +6 -0
  9. package/install/claude.mjs +12 -3
  10. package/install/templates/claude-hooks.json +12 -1
  11. package/manifest.json +79 -60
  12. package/package.json +2 -2
  13. package/pipeline/commands/multi-agent/review-analysis/SKILL.md +1 -1
  14. package/pipeline/contract/types/index.d.ts +53 -49
  15. package/pipeline/lib/context-budget.mjs +5 -42
  16. package/pipeline/lib/hook-registration.mjs +5 -0
  17. package/pipeline/lib/md2confluence-v3.py +12 -4
  18. package/pipeline/lib/tiered-budget.mjs +87 -0
  19. package/pipeline/multi-agent-refs/analysis/review.md +23 -1
  20. package/pipeline/multi-agent-refs/features/code-graph.md +11 -1
  21. package/pipeline/multi-agent-refs/features/doctor.md +32 -1
  22. package/pipeline/multi-agent-refs/features/product-tree.md +68 -0
  23. package/pipeline/multi-agent-refs/features/unattended-security.md +88 -1
  24. package/pipeline/multi-agent-refs/features/usage-reporting.md +31 -0
  25. package/pipeline/multi-agent-refs/help/en.md +1 -0
  26. package/pipeline/multi-agent-refs/help/tr.md +1 -0
  27. package/pipeline/multi-agent-refs/knowledge.md +58 -0
  28. package/pipeline/multi-agent-refs/phases/phase-0-init.md +4 -0
  29. package/pipeline/multi-agent-refs/phases/phase-1-plan.md +4 -0
  30. package/pipeline/multi-agent-refs/phases/phase-5-report.md +2 -0
  31. package/pipeline/office/index.html +13 -7
  32. package/pipeline/office/toolkit.json +1 -1
  33. package/pipeline/preferences-template.json +1 -0
  34. package/pipeline/schemas/learnings-ledger.schema.json +35 -2
  35. package/pipeline/schemas/office-archive.schema.json +225 -128
  36. package/pipeline/schemas/prefs.schema.json +83 -0
  37. package/pipeline/schemas/product-tree-overlay.schema.json +57 -0
  38. package/pipeline/schemas/product-tree.schema.json +136 -0
  39. package/pipeline/schemas/toolkit-path-params.json +1 -1
  40. package/pipeline/scripts/_eval-stats.mjs +182 -0
  41. package/pipeline/scripts/_guard_rules.py +130 -1
  42. package/pipeline/scripts/_learnings-promotion.mjs +229 -0
  43. package/pipeline/scripts/_locate.mjs +539 -0
  44. package/pipeline/scripts/_memory-policy.mjs +213 -14
  45. package/pipeline/scripts/_product-tree-extract.mjs +761 -0
  46. package/pipeline/scripts/_product-tree.mjs +923 -0
  47. package/pipeline/scripts/_retrieval.mjs +13 -2
  48. package/pipeline/scripts/_stack-routing.mjs +1 -0
  49. package/pipeline/scripts/_user_guard_rules.py +744 -0
  50. package/pipeline/scripts/agent-guard.py +61 -5
  51. package/pipeline/scripts/agent-guard.sh +8 -1
  52. package/pipeline/scripts/doctor.mjs +157 -1
  53. package/pipeline/scripts/graph-query.mjs +257 -17
  54. package/pipeline/scripts/learnings-ledger.mjs +664 -43
  55. package/pipeline/scripts/note-mcp-failure.mjs +356 -0
  56. package/pipeline/scripts/note-mcp-failure.sh +19 -0
  57. package/pipeline/scripts/note-skill-use.mjs +93 -23
  58. package/pipeline/scripts/office-archive.mjs +23 -10
  59. package/pipeline/scripts/office-memory.mjs +4 -1
  60. package/pipeline/scripts/persona-walk-anchors.mjs +443 -0
  61. package/pipeline/scripts/product-tree-eval.mjs +685 -0
  62. package/pipeline/scripts/product-tree.mjs +544 -0
  63. package/pipeline/skills/.skill-manifest.json +11 -7
  64. package/pipeline/skills/.skills-index.json +12 -1
  65. package/pipeline/skills/shared/README.md +4 -3
  66. package/pipeline/skills/shared/core/google-play-compliance/references/examples.md +1 -1
  67. package/pipeline/skills/shared/core/multi-agent-review-analysis/SKILL.md +1 -1
  68. package/pipeline/skills/shared/external/backlog/SKILL.md +1 -1
  69. package/pipeline/skills/shared/external/localization-reuse-map/SKILL.md +1 -1
  70. package/pipeline/skills/shared/external/spec-persona-walk/SKILL.md +118 -0
  71. package/pipeline/skills/shared/external/spec-persona-walk/evals/evals.json +50 -0
  72. package/pipeline/skills/shared/external/spec-persona-walk/scripts/persona-walk-anchors.mjs +443 -0
  73. package/pipeline/skills/shared/external/storekit/SKILL.md +1 -1
  74. package/pipeline/skills/shared/external/swiftdata/SKILL.md +1 -1
  75. package/pipeline/skills/skill-copies.json +5 -1
  76. package/pipeline/skills/skills-index.md +2 -1
@@ -0,0 +1,136 @@
1
+ {
2
+ "$schema": "https://json-schema.org/draft/2020-12/schema",
3
+ "$id": "https://github.com/mmerterden/multi-agent-pipeline/schemas/product-tree.schema.json",
4
+ "title": "Product tree",
5
+ "description": "The screen layer over the code graph, derived without a model by product-tree.mjs build: screens, routes, flows, localized strings, endpoints and tests, joined by navigation, string use, endpoint calls and test references. One file per project under ~/.claude/knowledge/<project>/product-tree.json, written 0600 and never shipped. Human-agreed additions live beside it in the append-only product-tree-overlay.jsonl.",
6
+ "type": "object",
7
+ "required": [
8
+ "schemaVersion",
9
+ "project",
10
+ "stacks",
11
+ "generatedAt",
12
+ "coverage",
13
+ "stats",
14
+ "nodes",
15
+ "edges"
16
+ ],
17
+ "additionalProperties": false,
18
+ "properties": {
19
+ "schemaVersion": { "enum": ["1.0.0"] },
20
+ "project": { "type": "string", "minLength": 1 },
21
+ "stacks": {
22
+ "type": "array",
23
+ "items": { "enum": ["ios", "android", "web"] },
24
+ "uniqueItems": true
25
+ },
26
+ "baseCommit": {
27
+ "type": ["string", "null"],
28
+ "description": "git HEAD the tree was built from; null outside a work tree."
29
+ },
30
+ "generatedAt": { "type": "string" },
31
+ "coverage": {
32
+ "type": "object",
33
+ "description": "Screen-index coverage per stack. reachable counts screens with an inbound entry, route, navigation or presentation edge; programmatic counts navigation calls whose destination is computed in code, and how many of them resolved to a screen.",
34
+ "propertyNames": { "enum": ["ios", "android", "web"] },
35
+ "additionalProperties": {
36
+ "type": "object",
37
+ "required": ["screens", "reachable", "routes", "routesWithScreen", "programmatic"],
38
+ "additionalProperties": false,
39
+ "properties": {
40
+ "screens": { "type": "integer", "minimum": 0 },
41
+ "reachable": { "type": "integer", "minimum": 0 },
42
+ "routes": { "type": "integer", "minimum": 0 },
43
+ "routesWithScreen": { "type": "integer", "minimum": 0 },
44
+ "programmatic": {
45
+ "type": "object",
46
+ "required": ["total", "resolved", "unresolved"],
47
+ "additionalProperties": false,
48
+ "properties": {
49
+ "total": { "type": "integer", "minimum": 0 },
50
+ "resolved": { "type": "integer", "minimum": 0 },
51
+ "unresolved": {
52
+ "type": "array",
53
+ "maxItems": 50,
54
+ "items": {
55
+ "type": "object",
56
+ "required": ["path", "line", "text"],
57
+ "additionalProperties": false,
58
+ "properties": {
59
+ "path": { "type": "string" },
60
+ "line": { "type": "integer", "minimum": 1 },
61
+ "text": { "type": "string" }
62
+ }
63
+ }
64
+ }
65
+ }
66
+ }
67
+ }
68
+ }
69
+ },
70
+ "stats": {
71
+ "type": "object",
72
+ "required": ["nodes", "edges", "screens", "strings"],
73
+ "additionalProperties": false,
74
+ "properties": {
75
+ "nodes": { "type": "integer", "minimum": 0 },
76
+ "edges": { "type": "integer", "minimum": 0 },
77
+ "screens": { "type": "integer", "minimum": 0 },
78
+ "strings": { "type": "integer", "minimum": 0 }
79
+ }
80
+ },
81
+ "nodes": {
82
+ "type": "array",
83
+ "items": {
84
+ "type": "object",
85
+ "required": ["id", "kind", "name"],
86
+ "additionalProperties": false,
87
+ "properties": {
88
+ "id": { "type": "string", "minLength": 1 },
89
+ "kind": { "enum": ["app", "screen", "route", "flow", "string", "endpoint", "test"] },
90
+ "name": { "type": "string" },
91
+ "stack": { "enum": ["ios", "android", "web"] },
92
+ "path": { "type": "string" },
93
+ "line": { "type": "integer", "minimum": 0 },
94
+ "values": {
95
+ "type": "object",
96
+ "description": "string nodes: locale -> value.",
97
+ "additionalProperties": { "type": "string" }
98
+ },
99
+ "files": {
100
+ "type": "array",
101
+ "description": "screen nodes: the files the screen owns, its own first. string nodes: the files that reference the key.",
102
+ "items": { "type": "string" }
103
+ }
104
+ }
105
+ }
106
+ },
107
+ "edges": {
108
+ "type": "array",
109
+ "items": {
110
+ "type": "object",
111
+ "required": ["from", "to", "kind"],
112
+ "additionalProperties": false,
113
+ "properties": {
114
+ "from": { "type": "string" },
115
+ "to": { "type": "string" },
116
+ "kind": {
117
+ "enum": ["entry", "shows", "navigates", "presents", "uses-string", "calls", "tests"]
118
+ },
119
+ "via": {
120
+ "enum": [
121
+ "link",
122
+ "link-value",
123
+ "destination",
124
+ "sheet",
125
+ "cover",
126
+ "root",
127
+ "tab",
128
+ "hosting",
129
+ "programmatic"
130
+ ]
131
+ }
132
+ }
133
+ }
134
+ }
135
+ }
136
+ }
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "$comment": "Generated by pipeline/scripts/gen-toolkit-path-params.mjs from multi-agent-toolkit-mcp tool-manifest.json; do not edit. Per toolkit tool: the parameters it writes to and the filesystem paths it reads, both confined by scripts/unattended_policy.py.",
3
- "toolkitVersion": "3.30.1",
3
+ "toolkitVersion": "3.31.0",
4
4
  "tools": {
5
5
  "agent_query_output": {
6
6
  "writes": [],
@@ -0,0 +1,182 @@
1
+ /**
2
+ * @file _eval-stats.mjs - ranking metrics and paired significance tests for
3
+ * product-tree-eval.mjs.
4
+ *
5
+ * Two arms answer the same bugs, so every comparison here is paired: McNemar's
6
+ * exact test on the per-bug hit / miss outcome, and a bootstrap that resamples
7
+ * bugs (not arms) for the confidence interval of the difference. The exact
8
+ * test is used rather than the chi-square approximation because a repo
9
+ * contributes tens of bugs, and the approximation is poor when the discordant
10
+ * count is small.
11
+ *
12
+ * The bootstrap takes a seed, so a report reproduces byte for byte.
13
+ *
14
+ * Zero dependencies.
15
+ *
16
+ * @module pipeline/scripts/_eval-stats
17
+ */
18
+
19
+ /**
20
+ * n choose k, exact for the sizes an evaluation reaches.
21
+ *
22
+ * @param {number} n
23
+ * @param {number} k
24
+ * @returns {number}
25
+ */
26
+ export function binomial(n, k) {
27
+ if (k < 0 || k > n) return 0;
28
+ const m = Math.min(k, n - k);
29
+ let r = 1;
30
+ for (let i = 1; i <= m; i++) r = (r * (n - m + i)) / i;
31
+ return Math.round(r);
32
+ }
33
+
34
+ /**
35
+ * Two-sided exact McNemar p-value.
36
+ *
37
+ * The binomial tail is summed in log space: 2^n and n choose k overflow a
38
+ * double past about 1023 discordant pairs.
39
+ *
40
+ * @param {number} b bugs the first arm hit and the second missed
41
+ * @param {number} c bugs the second arm hit and the first missed
42
+ * @returns {number} p in [0, 1]
43
+ */
44
+ export function mcnemarExact(b, c) {
45
+ const n = b + c;
46
+ if (n === 0) return 1;
47
+ const lo = Math.min(b, c);
48
+ const logs = [0];
49
+ for (let i = 1; i <= lo; i++) logs.push(logs[i - 1] + Math.log(n - i + 1) - Math.log(i));
50
+ const top = Math.max(...logs);
51
+ const sum = logs.reduce((s, l) => s + Math.exp(l - top), 0);
52
+ const logP = Math.log(2) + top + Math.log(sum) - n * Math.log(2);
53
+ return Math.min(1, Math.exp(logP));
54
+ }
55
+
56
+ /**
57
+ * Deterministic uniform generator (mulberry32).
58
+ *
59
+ * @param {number} seed
60
+ * @returns {() => number} values in [0, 1)
61
+ */
62
+ export function seededRandom(seed) {
63
+ let a = seed >>> 0;
64
+ return () => {
65
+ a = (a + 0x6d2b79f5) >>> 0;
66
+ let t = a;
67
+ t = Math.imul(t ^ (t >>> 15), t | 1);
68
+ t ^= t + Math.imul(t ^ (t >>> 7), t | 61);
69
+ return ((t ^ (t >>> 14)) >>> 0) / 4294967296;
70
+ };
71
+ }
72
+
73
+ const mean = (xs) => xs.reduce((s, x) => s + x, 0) / xs.length;
74
+
75
+ function percentile(sorted, q) {
76
+ const i = Math.min(sorted.length - 1, Math.max(0, Math.floor(q * sorted.length)));
77
+ return sorted[i];
78
+ }
79
+
80
+ /**
81
+ * Percentile bootstrap interval of the mean.
82
+ *
83
+ * @param {number[]} values
84
+ * @param {{iterations?: number, seed?: number, alpha?: number}} [opts]
85
+ * @returns {{mean: number|null, low: number|null, high: number|null}}
86
+ */
87
+ export function bootstrapCI(values, { iterations = 2000, seed = 1, alpha = 0.05 } = {}) {
88
+ if (!values.length) return { mean: null, low: null, high: null };
89
+ const rand = seededRandom(seed);
90
+ const n = values.length;
91
+ const means = new Array(iterations);
92
+ for (let it = 0; it < iterations; it++) {
93
+ let s = 0;
94
+ for (let i = 0; i < n; i++) s += values[Math.floor(rand() * n)];
95
+ means[it] = s / n;
96
+ }
97
+ means.sort((x, y) => x - y);
98
+ return {
99
+ mean: mean(values),
100
+ low: percentile(means, alpha / 2),
101
+ high: percentile(means, 1 - alpha / 2),
102
+ };
103
+ }
104
+
105
+ /**
106
+ * Bootstrap interval of mean(b - a) over paired observations.
107
+ *
108
+ * @param {number[]} a
109
+ * @param {number[]} b same length as a, same bugs in the same order
110
+ * @param {{iterations?: number, seed?: number, alpha?: number}} [opts]
111
+ */
112
+ export function pairedBootstrapDiff(a, b, opts = {}) {
113
+ if (a.length !== b.length) throw new Error("paired samples differ in length");
114
+ return bootstrapCI(
115
+ a.map((x, i) => b[i] - x),
116
+ opts,
117
+ );
118
+ }
119
+
120
+ /**
121
+ * Per-bug ranking metrics.
122
+ *
123
+ * hit@k is 1 when any changed file is in the top k (Acc@k once averaged);
124
+ * recall@k is the share of changed files in the top k; rr is 1 / rank of the
125
+ * first changed file, 0 when none is ranked.
126
+ *
127
+ * @param {string[]} ranked candidate files, best first
128
+ * @param {string[]} truth files the fix changed
129
+ * @param {number[]} ks
130
+ */
131
+ export function rankingMetrics(ranked, truth, ks) {
132
+ const want = new Set(truth);
133
+ const hit = {};
134
+ const recall = {};
135
+ let first = 0;
136
+ for (let i = 0; i < ranked.length; i++) {
137
+ if (want.has(ranked[i])) {
138
+ first = i + 1;
139
+ break;
140
+ }
141
+ }
142
+ for (const k of ks) {
143
+ const top = ranked.slice(0, k);
144
+ const found = top.filter((f) => want.has(f)).length;
145
+ hit[k] = found > 0 ? 1 : 0;
146
+ recall[k] = want.size ? found / want.size : 0;
147
+ }
148
+ return { hit, recall, rr: first ? 1 / first : 0 };
149
+ }
150
+
151
+ /**
152
+ * Mean of per-bug metrics.
153
+ *
154
+ * @param {Array<ReturnType<typeof rankingMetrics>>} rows
155
+ * @param {number[]} ks
156
+ */
157
+ export function aggregateMetrics(rows, ks) {
158
+ const acc = {};
159
+ const recall = {};
160
+ for (const k of ks) {
161
+ acc[k] = rows.length ? mean(rows.map((r) => r.hit[k])) : null;
162
+ recall[k] = rows.length ? mean(rows.map((r) => r.recall[k])) : null;
163
+ }
164
+ return { n: rows.length, acc, recall, mrr: rows.length ? mean(rows.map((r) => r.rr)) : null };
165
+ }
166
+
167
+ /**
168
+ * The go / no-go rule: the lift is large enough, it is significant, and no
169
+ * repository got worse.
170
+ *
171
+ * @param {{liftPoints: number, p: number, regressedRepos: string[], minLiftPoints: number, alpha: number}} r
172
+ * @returns {{go: boolean, reasons: string[]}}
173
+ */
174
+ export function verdict({ liftPoints, p, regressedRepos, minLiftPoints, alpha }) {
175
+ const reasons = [];
176
+ if (!(liftPoints >= minLiftPoints)) {
177
+ reasons.push(`recall@10 lift ${liftPoints.toFixed(1)} points is below ${minLiftPoints}`);
178
+ }
179
+ if (!(p < alpha)) reasons.push(`McNemar p=${p.toFixed(4)} is not below ${alpha}`);
180
+ if (regressedRepos.length) reasons.push(`regressed: ${regressedRepos.join(", ")}`);
181
+ return { go: reasons.length === 0, reasons };
182
+ }
@@ -609,10 +609,139 @@ def _cleanup_ask(argv):
609
609
  return f"{name} deletes run logs or worktrees for good; the user confirms each clean-up"
610
610
 
611
611
 
612
+ PRODUCT_TREE_OVERLAY_NAME = "product-tree-overlay.jsonl"
613
+
614
+ PRODUCT_TREE_OVERLAY_WRITE = re.compile(
615
+ r"(?:>>?|\btee\b[^;&|]*?)\s*['\"]?[^\s;&|'\"]*product-tree-overlay\.jsonl",
616
+ re.I,
617
+ )
618
+
619
+ # product-tree.mjs flags that take the next token as their value; every other
620
+ # flag stands alone, so the token after it can be the subcommand.
621
+ PRODUCT_TREE_VALUE_FLAGS = {
622
+ "--tree", "--root", "--out", "--graph", "--stack", "--max-chars",
623
+ "--kind", "--name", "--id", "--parent", "--note",
624
+ }
625
+
626
+ PRODUCT_TREE_DECISIONS = ("agree", "reject")
627
+
628
+ SCRIPT_RUNNERS = {"node", "nodejs", "bun", "deno", "tsx", "ts-node"}
629
+
630
+ # Commands that only read a file they name; naming the overlay to one of them
631
+ # writes nothing.
632
+ OVERLAY_READERS = {
633
+ "cat", "head", "tail", "less", "more", "wc", "grep", "egrep", "fgrep", "rg",
634
+ "jq", "ls", "stat", "file", "diff", "cmp", "shasum", "sha256sum", "md5", "md5sum",
635
+ }
636
+
637
+
638
+ def _names_overlay(tok, cwd=None):
639
+ """True when a token names the overlay: its casefolded text holds the
640
+ overlay's name, or it is a path whose real target is the overlay."""
641
+ folded = tok.casefold()
642
+ if PRODUCT_TREE_OVERLAY_NAME in folded:
643
+ return True
644
+ if tok.startswith("-") or not tok or len(tok) > 4096:
645
+ return False
646
+ path = tok.split("=", 1)[1] if re.match(r"^[a-z]+=", tok) else tok
647
+ path = os.path.expanduser(path)
648
+ try:
649
+ real = os.path.realpath(os.path.join(cwd or os.getcwd(), path))
650
+ except (OSError, ValueError):
651
+ return False
652
+ return os.path.basename(real).casefold() == PRODUCT_TREE_OVERLAY_NAME
653
+
654
+
655
+ def _product_tree_decision(argv):
656
+ """The decision a product-tree invocation records, or None. A token named
657
+ product-tree.mjs is followed past its flags to the subcommand; a variable
658
+ there could expand to either decision. Any script run through node and
659
+ friends, or a .mjs/.js file run directly, that carries an agree or reject
660
+ token is treated the same, which covers a copy of the script under
661
+ another name."""
662
+ for i, tok in enumerate(argv):
663
+ base = os.path.basename(tok)
664
+ if base == "product-tree.mjs":
665
+ rest = argv[i + 1:]
666
+ j = 0
667
+ while j < len(rest) and rest[j].startswith("-"):
668
+ flag = rest[j].split("=", 1)[0]
669
+ j += 2 if flag in PRODUCT_TREE_VALUE_FLAGS and "=" not in rest[j] else 1
670
+ if j < len(rest) and (rest[j] in PRODUCT_TREE_DECISIONS or rest[j].startswith("$")):
671
+ return rest[j] if rest[j] in PRODUCT_TREE_DECISIONS else "agree or reject"
672
+ if base in SCRIPT_RUNNERS or re.search(r"\.(?:mjs|cjs|js)$", base):
673
+ for later in argv[i + 1:]:
674
+ if later in PRODUCT_TREE_DECISIONS:
675
+ return later
676
+ return None
677
+
678
+
679
+ def _product_tree_ask(argv, seg, cwd=None):
680
+ """An agree or reject on a product-tree proposal, or a direct write to its
681
+ overlay, records a person's decision. The script's own terminal check does
682
+ not hold against an agent that allocates a pseudo-terminal, so the person
683
+ confirms it here. Any command that names the overlay, by a casefolded
684
+ name or through a symlink, asks unless it only reads it."""
685
+ decision = _product_tree_decision(argv)
686
+ if decision:
687
+ return (
688
+ f"product-tree.mjs {decision} records a person's decision on the product tree; "
689
+ "the user runs it or confirms it"
690
+ )
691
+ overlay_write = (
692
+ "this writes the product tree overlay directly; only product-tree.mjs propose writes "
693
+ "it, and a decision is the user's"
694
+ )
695
+ if PRODUCT_TREE_OVERLAY_WRITE.search(seg):
696
+ return overlay_write
697
+ for m in re.finditer(r">>?\s*['\"]?([^\s;&|'\"<>]+)", seg):
698
+ if _names_overlay(m.group(1), cwd):
699
+ return overlay_write
700
+ if argv and os.path.basename(argv[0]) not in OVERLAY_READERS:
701
+ if any(_names_overlay(t, cwd) for t in argv[1:]):
702
+ return overlay_write
703
+ return None
704
+
705
+
706
+ def _learnings_ask(argv):
707
+ """promote --accept, promote --retract and feedback on a G: id write the
708
+ global learnings ledger or hide a global learning, a person's decision.
709
+ learnings-ledger.mjs asks y/N on a terminal, but a pseudo-terminal answers
710
+ that prompt as well as a person does, so the user confirms it here."""
711
+ for i, tok in enumerate(argv):
712
+ if os.path.basename(tok) != "learnings-ledger.mjs":
713
+ continue
714
+ rest = argv[i + 1:]
715
+ if not rest:
716
+ return None
717
+ flags = [a.split("=", 1)[0] for a in rest[1:]]
718
+ if rest[0] == "promote" and ("--accept" in flags or "--retract" in flags):
719
+ what = "promote --accept" if "--accept" in flags else "promote --retract"
720
+ elif rest[0] == "feedback":
721
+ ids = _flag_values(rest[1:], {"--id"}, None)
722
+ if not any(str(v).strip("[]").upper().startswith(("G:", "$")) for v in ids):
723
+ return None
724
+ what = "feedback on a G: id"
725
+ else:
726
+ return None
727
+ return (
728
+ f"learnings-ledger.mjs {what} changes a global learning every repository reads; "
729
+ "the user runs it or confirms it"
730
+ )
731
+ return None
732
+
733
+
612
734
  def ask_reason(toks, seg, cwd=None):
613
735
  """Why a person should confirm this segment, or None."""
614
736
  _, argv = command_word(toks)
615
- return _gh_ask(argv, cwd) or _jira_ask(argv, seg) or _shared_ask(argv, seg) or _cleanup_ask(argv)
737
+ return (
738
+ _gh_ask(argv, cwd)
739
+ or _jira_ask(argv, seg)
740
+ or _shared_ask(argv, seg)
741
+ or _cleanup_ask(argv)
742
+ or _product_tree_ask(argv, seg, cwd)
743
+ or _learnings_ask(argv)
744
+ )
616
745
 
617
746
 
618
747
  GH_TEXT_SUBS = {