@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,229 @@
|
|
|
1
|
+
/**
|
|
2
|
+
* @file _learnings-promotion.mjs - which per-repository learnings recur
|
|
3
|
+
* across repositories, as candidates for one global learning.
|
|
4
|
+
*
|
|
5
|
+
* eligibleEntries(slug, rows, feedbackById)
|
|
6
|
+
* the rows of one ledger that may stand as evidence:
|
|
7
|
+
* high confidence, not superseded, and never marked
|
|
8
|
+
* dead_end or corrected
|
|
9
|
+
* promotionCandidates(entries, globalRows, opts)
|
|
10
|
+
* entries of the same kind from two or more
|
|
11
|
+
* repositories whose statements score at or above the
|
|
12
|
+
* threshold pairwise (shingleSimilarity), one entry per
|
|
13
|
+
* repository per candidate, each tagged with the global
|
|
14
|
+
* row that already covers it, if any
|
|
15
|
+
* globalVisible(globalRow, slug, localRows)
|
|
16
|
+
* whether a global row belongs in this repository's
|
|
17
|
+
* brief and profile
|
|
18
|
+
*
|
|
19
|
+
* Pure: the caller reads the ledgers, decides which repositories are excluded
|
|
20
|
+
* from memory, and writes. Zero dependencies.
|
|
21
|
+
*
|
|
22
|
+
* @module pipeline/scripts/_learnings-promotion
|
|
23
|
+
*/
|
|
24
|
+
|
|
25
|
+
import { shortId } from "./_retrieval.mjs";
|
|
26
|
+
import {
|
|
27
|
+
PROMOTION_SIMILARITY,
|
|
28
|
+
globalRowId,
|
|
29
|
+
ledgerRowId,
|
|
30
|
+
shingleProfile,
|
|
31
|
+
shingleSimilarity,
|
|
32
|
+
supersededBy,
|
|
33
|
+
} from "./_memory-policy.mjs";
|
|
34
|
+
|
|
35
|
+
const round = (n) => Math.round(n * 1000) / 1000;
|
|
36
|
+
const cmp = (a, b) => (a < b ? -1 : a > b ? 1 : 0);
|
|
37
|
+
|
|
38
|
+
/**
|
|
39
|
+
* A promotion asks more of an entry than a brief does: one dead end or one
|
|
40
|
+
* correction is enough to keep it out, because the global ledger reaches
|
|
41
|
+
* every other repository and is never rewritten.
|
|
42
|
+
*
|
|
43
|
+
* @param {string} slug
|
|
44
|
+
* @param {object[]} rows ledger rows in file order
|
|
45
|
+
* @param {Map<string, Array<{outcome: string}>>} feedbackById
|
|
46
|
+
*/
|
|
47
|
+
export function eligibleEntries(slug, rows, feedbackById) {
|
|
48
|
+
const by = supersededBy(rows);
|
|
49
|
+
const seen = new Set();
|
|
50
|
+
const out = [];
|
|
51
|
+
rows.forEach((r, i) => {
|
|
52
|
+
if (!r || typeof r.statement !== "string" || typeof r.kind !== "string") return;
|
|
53
|
+
if (by[i] !== null || r.confidence !== "high") return;
|
|
54
|
+
const id = ledgerRowId(r);
|
|
55
|
+
if (seen.has(id)) return;
|
|
56
|
+
const outcomes = feedbackById.get(id) ?? [];
|
|
57
|
+
if (outcomes.some((f) => f.outcome === "dead_end" || f.outcome === "corrected")) return;
|
|
58
|
+
seen.add(id);
|
|
59
|
+
out.push({ repo: slug, id, row: r, order: i, profile: shingleProfile(r.statement) });
|
|
60
|
+
});
|
|
61
|
+
return out;
|
|
62
|
+
}
|
|
63
|
+
|
|
64
|
+
const keyOf = (e) => `${e.repo}\u0000${e.id}`;
|
|
65
|
+
|
|
66
|
+
/** Lowest pairwise score inside a group of entries. */
|
|
67
|
+
function weakest(members, score) {
|
|
68
|
+
let low = 1;
|
|
69
|
+
for (let i = 0; i < members.length; i++)
|
|
70
|
+
for (let j = i + 1; j < members.length; j++) low = Math.min(low, score(members[i], members[j]));
|
|
71
|
+
return low;
|
|
72
|
+
}
|
|
73
|
+
|
|
74
|
+
/** Does `extra` join `group` without repeating a repository or a weak pair? */
|
|
75
|
+
function fits(group, extra, score, threshold) {
|
|
76
|
+
const repos = new Set(group.map((e) => e.repo));
|
|
77
|
+
if (extra.some((e) => repos.has(e.repo))) return false;
|
|
78
|
+
return group.every((g) => extra.every((e) => score(g, e) >= threshold));
|
|
79
|
+
}
|
|
80
|
+
|
|
81
|
+
/** The global row that already holds this group's learning, or null. */
|
|
82
|
+
function coveredBy(group, globals, threshold) {
|
|
83
|
+
const members = new Set(group.map((e) => `${e.repo}\u0000${e.id}`));
|
|
84
|
+
for (const g of globals) {
|
|
85
|
+
if (g.row.kind !== group[0].row.kind) continue;
|
|
86
|
+
const sources = Array.isArray(g.row.promoted_from?.sources) ? g.row.promoted_from.sources : [];
|
|
87
|
+
if (sources.some((s) => members.has(`${s?.repo}\u0000${s?.id}`))) return g.id;
|
|
88
|
+
if (group.some((e) => shingleSimilarity(g.profile, e.profile) >= threshold)) return g.id;
|
|
89
|
+
}
|
|
90
|
+
return null;
|
|
91
|
+
}
|
|
92
|
+
|
|
93
|
+
/**
|
|
94
|
+
* Candidates for promotion.
|
|
95
|
+
*
|
|
96
|
+
* Pairs from different repositories are joined strongest first. A group grows
|
|
97
|
+
* only while every pair inside it stays at or above the threshold and no
|
|
98
|
+
* repository appears twice, so a chain of loosely similar statements never
|
|
99
|
+
* collapses into one learning that no two of its members actually share.
|
|
100
|
+
*
|
|
101
|
+
* The candidate id is derived from its members, so an approval binds to the
|
|
102
|
+
* evidence it was shown: when a repository joins or leaves, the id changes and
|
|
103
|
+
* the earlier approval no longer applies.
|
|
104
|
+
*
|
|
105
|
+
* @param {ReturnType<typeof eligibleEntries>} entries
|
|
106
|
+
* @param {object[]} globalRows rows of the global ledger
|
|
107
|
+
* @param {{threshold?: number}} [opts]
|
|
108
|
+
*/
|
|
109
|
+
export function promotionCandidates(
|
|
110
|
+
entries,
|
|
111
|
+
globalRows,
|
|
112
|
+
{ threshold = PROMOTION_SIMILARITY } = {},
|
|
113
|
+
) {
|
|
114
|
+
const cache = new Map();
|
|
115
|
+
const score = (a, b) => {
|
|
116
|
+
const k = keyOf(a) < keyOf(b) ? `${keyOf(a)}|${keyOf(b)}` : `${keyOf(b)}|${keyOf(a)}`;
|
|
117
|
+
if (!cache.has(k)) cache.set(k, shingleSimilarity(a.profile, b.profile));
|
|
118
|
+
return cache.get(k);
|
|
119
|
+
};
|
|
120
|
+
const ordered = entries.slice().sort((a, b) => cmp(a.repo, b.repo) || a.order - b.order);
|
|
121
|
+
const pairs = [];
|
|
122
|
+
for (let i = 0; i < ordered.length; i++)
|
|
123
|
+
for (let j = i + 1; j < ordered.length; j++) {
|
|
124
|
+
const a = ordered[i];
|
|
125
|
+
const b = ordered[j];
|
|
126
|
+
if (a.repo === b.repo || a.row.kind !== b.row.kind) continue;
|
|
127
|
+
const s = score(a, b);
|
|
128
|
+
if (s >= threshold) pairs.push({ a, b, s, i, j });
|
|
129
|
+
}
|
|
130
|
+
pairs.sort((x, y) => y.s - x.s || x.i - y.i || x.j - y.j);
|
|
131
|
+
|
|
132
|
+
const groupOf = new Map();
|
|
133
|
+
const groups = [];
|
|
134
|
+
for (const { a, b } of pairs) {
|
|
135
|
+
const ga = groupOf.get(keyOf(a));
|
|
136
|
+
const gb = groupOf.get(keyOf(b));
|
|
137
|
+
if (!ga && !gb) {
|
|
138
|
+
const g = [a, b];
|
|
139
|
+
groups.push(g);
|
|
140
|
+
groupOf.set(keyOf(a), g);
|
|
141
|
+
groupOf.set(keyOf(b), g);
|
|
142
|
+
} else if (ga && !gb) {
|
|
143
|
+
if (fits(ga, [b], score, threshold)) {
|
|
144
|
+
ga.push(b);
|
|
145
|
+
groupOf.set(keyOf(b), ga);
|
|
146
|
+
}
|
|
147
|
+
} else if (!ga && gb) {
|
|
148
|
+
if (fits(gb, [a], score, threshold)) {
|
|
149
|
+
gb.push(a);
|
|
150
|
+
groupOf.set(keyOf(a), gb);
|
|
151
|
+
}
|
|
152
|
+
} else if (ga !== gb && fits(ga, gb, score, threshold)) {
|
|
153
|
+
for (const e of gb) {
|
|
154
|
+
ga.push(e);
|
|
155
|
+
groupOf.set(keyOf(e), ga);
|
|
156
|
+
}
|
|
157
|
+
gb.length = 0;
|
|
158
|
+
}
|
|
159
|
+
}
|
|
160
|
+
|
|
161
|
+
const globals = globalRows
|
|
162
|
+
.filter((r) => r && typeof r.statement === "string" && typeof r.kind === "string")
|
|
163
|
+
.map((r) => ({ id: globalRowId(r), row: r, profile: shingleProfile(r.statement) }));
|
|
164
|
+
|
|
165
|
+
return groups
|
|
166
|
+
.filter((g) => g.length >= 2)
|
|
167
|
+
.map((g) => {
|
|
168
|
+
const members = g.slice().sort((x, y) => cmp(x.repo, y.repo) || x.order - y.order);
|
|
169
|
+
const lowest = (e) => Math.min(...members.filter((m) => m !== e).map((m) => score(e, m)));
|
|
170
|
+
const mean = (e) =>
|
|
171
|
+
members.filter((m) => m !== e).reduce((s, m) => s + score(e, m), 0) / (members.length - 1);
|
|
172
|
+
const representative = members
|
|
173
|
+
.slice()
|
|
174
|
+
.sort(
|
|
175
|
+
(x, y) =>
|
|
176
|
+
mean(y) - mean(x) ||
|
|
177
|
+
cmp(String(x.row.ts ?? ""), String(y.row.ts ?? "")) ||
|
|
178
|
+
cmp(x.repo, y.repo),
|
|
179
|
+
)[0];
|
|
180
|
+
return {
|
|
181
|
+
id: shortId(
|
|
182
|
+
"P",
|
|
183
|
+
representative.row.kind,
|
|
184
|
+
members.map((e) => `${e.repo}/${e.id}`).join(" "),
|
|
185
|
+
),
|
|
186
|
+
kind: representative.row.kind,
|
|
187
|
+
statement: representative.row.statement,
|
|
188
|
+
representative,
|
|
189
|
+
similarity: round(weakest(members, score)),
|
|
190
|
+
repos: [...new Set(members.map((e) => e.repo))],
|
|
191
|
+
evidence: members.map((e) => ({
|
|
192
|
+
repo: e.repo,
|
|
193
|
+
id: e.id,
|
|
194
|
+
statement: e.row.statement,
|
|
195
|
+
score: round(lowest(e)),
|
|
196
|
+
})),
|
|
197
|
+
global: coveredBy(members, globals, threshold),
|
|
198
|
+
};
|
|
199
|
+
})
|
|
200
|
+
.sort((x, y) => y.similarity - x.similarity || cmp(x.id, y.id));
|
|
201
|
+
}
|
|
202
|
+
|
|
203
|
+
/**
|
|
204
|
+
* A global row is shown in a repository unless the repository is one of its
|
|
205
|
+
* sources (its own entry, or the entry that replaced it, already says what
|
|
206
|
+
* holds there) or already carries a current entry of the same kind that says
|
|
207
|
+
* the same thing.
|
|
208
|
+
*
|
|
209
|
+
* @param {object} globalRow
|
|
210
|
+
* @param {string} slug
|
|
211
|
+
* @param {object[]} localRows the repository's current rows
|
|
212
|
+
*/
|
|
213
|
+
export function globalVisible(
|
|
214
|
+
globalRow,
|
|
215
|
+
slug,
|
|
216
|
+
localRows,
|
|
217
|
+
{ threshold = PROMOTION_SIMILARITY } = {},
|
|
218
|
+
) {
|
|
219
|
+
const sources = Array.isArray(globalRow?.promoted_from?.sources)
|
|
220
|
+
? globalRow.promoted_from.sources
|
|
221
|
+
: [];
|
|
222
|
+
if (sources.some((s) => s?.repo === slug)) return false;
|
|
223
|
+
const p = shingleProfile(String(globalRow?.statement ?? ""));
|
|
224
|
+
return !localRows.some(
|
|
225
|
+
(r) =>
|
|
226
|
+
r.kind === globalRow.kind &&
|
|
227
|
+
shingleSimilarity(p, shingleProfile(String(r.statement ?? ""))) >= threshold,
|
|
228
|
+
);
|
|
229
|
+
}
|