@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
|
@@ -23,7 +23,18 @@
|
|
|
23
23
|
* nearDuplicate(a, b) two statements that say the same thing in other
|
|
24
24
|
* words: TF-IDF cosine at or above the threshold, the
|
|
25
25
|
* same numbers, the same negations and mostly the
|
|
26
|
-
* same word order ("
|
|
26
|
+
* same word order ("Keychain over UserDefaults" is
|
|
27
|
+
* not "UserDefaults over Keychain")
|
|
28
|
+
* shingleSimilarity(a, b) Jaccard overlap of adjacent word pairs, 0 unless
|
|
29
|
+
* both carry the same numbers and negations and
|
|
30
|
+
* three or more words; the cross-repository
|
|
31
|
+
* promotion measure (PROMOTION_SIMILARITY). Both
|
|
32
|
+
* read words of any script, fold every English "not"
|
|
33
|
+
* form and apostrophe, and treat a Turkish verb that
|
|
34
|
+
* differs only by its negative -me/-ma as a negation
|
|
35
|
+
* globalRowId(row) the `G:` id of a global ledger row
|
|
36
|
+
* GLOBAL_LEDGER_SLUG the folder under ~/.claude/memory/multi-agent/ that
|
|
37
|
+
* holds the global ledger; no repository writes it
|
|
27
38
|
*
|
|
28
39
|
* Zero dependencies.
|
|
29
40
|
*
|
|
@@ -36,7 +47,6 @@ import { prefsPath, readPrefsFile } from "../lib/prefs-value.mjs";
|
|
|
36
47
|
const CORROBORATION = 2;
|
|
37
48
|
const NEAR_DUP = 0.9;
|
|
38
49
|
const ORDER_OVERLAP = 0.5;
|
|
39
|
-
const NEGATIONS = /\b(not|never|no|none|without|except|only|avoid|don't|do not)\b/gi;
|
|
40
50
|
|
|
41
51
|
/** The preferences, `{}` when there are none, `null` when they exist but cannot be read. */
|
|
42
52
|
function prefs(env) {
|
|
@@ -45,13 +55,23 @@ function prefs(env) {
|
|
|
45
55
|
return r.status === "ok" ? r.prefs : null;
|
|
46
56
|
}
|
|
47
57
|
|
|
48
|
-
|
|
49
|
-
export
|
|
50
|
-
|
|
58
|
+
export const GLOBAL_LEDGER_SLUG = "_global";
|
|
59
|
+
export const PROMOTION_SIMILARITY = 0.5;
|
|
60
|
+
|
|
61
|
+
const foldedStatement = (row) =>
|
|
62
|
+
String(row?.statement || "")
|
|
51
63
|
.toLowerCase()
|
|
52
64
|
.replace(/\s+/g, " ")
|
|
53
65
|
.trim();
|
|
54
|
-
|
|
66
|
+
|
|
67
|
+
/** Stable id of a ledger row: its kind and its whitespace-folded statement. */
|
|
68
|
+
export function ledgerRowId(row) {
|
|
69
|
+
return shortId("L", row?.kind, foldedStatement(row));
|
|
70
|
+
}
|
|
71
|
+
|
|
72
|
+
/** Stable id of a global ledger row, from the same fields as `ledgerRowId`. */
|
|
73
|
+
export function globalRowId(row) {
|
|
74
|
+
return shortId("G", row?.kind, foldedStatement(row));
|
|
55
75
|
}
|
|
56
76
|
|
|
57
77
|
/** A ledger id in its stored form, or null when `raw` is not one. */
|
|
@@ -144,12 +164,149 @@ export function standing(feedback, now = Date.now()) {
|
|
|
144
164
|
}
|
|
145
165
|
|
|
146
166
|
const numbersIn = (s) => (String(s).match(/\d+(?:\.\d+)?/g) || []).sort().join(",");
|
|
167
|
+
|
|
168
|
+
// Words that negate on their own. Every English "not" form, contracted or
|
|
169
|
+
// not, folds to "not", so "Don't" and "Do not" read alike. Turkish verbal
|
|
170
|
+
// negation sits inside the verb and is compared word by word
|
|
171
|
+
// (turkishNegationPair); its free-standing words are listed here.
|
|
172
|
+
const NEGATORS = new Set([
|
|
173
|
+
"not",
|
|
174
|
+
"never",
|
|
175
|
+
"no",
|
|
176
|
+
"none",
|
|
177
|
+
"without",
|
|
178
|
+
"except",
|
|
179
|
+
"only",
|
|
180
|
+
"avoid",
|
|
181
|
+
"değil",
|
|
182
|
+
"asla",
|
|
183
|
+
"hiç",
|
|
184
|
+
"hiçbir",
|
|
185
|
+
"yok",
|
|
186
|
+
]);
|
|
187
|
+
const NOT_FORMS = new Set([
|
|
188
|
+
"cannot",
|
|
189
|
+
"dont",
|
|
190
|
+
"doesnt",
|
|
191
|
+
"didnt",
|
|
192
|
+
"cant",
|
|
193
|
+
"wont",
|
|
194
|
+
"isnt",
|
|
195
|
+
"arent",
|
|
196
|
+
"wasnt",
|
|
197
|
+
"werent",
|
|
198
|
+
"shouldnt",
|
|
199
|
+
"wouldnt",
|
|
200
|
+
"couldnt",
|
|
201
|
+
"mustnt",
|
|
202
|
+
"neednt",
|
|
203
|
+
"hasnt",
|
|
204
|
+
"havent",
|
|
205
|
+
"hadnt",
|
|
206
|
+
"aint",
|
|
207
|
+
]);
|
|
208
|
+
|
|
209
|
+
/** Lower-cased words of any script, apostrophes folded to one form and kept inside a word. */
|
|
210
|
+
const plainWords = (s) =>
|
|
211
|
+
String(s)
|
|
212
|
+
.normalize("NFC")
|
|
213
|
+
.toLowerCase()
|
|
214
|
+
.replace(/[\u2018\u2019\u02bc\u2032\u00b4`]/g, "'")
|
|
215
|
+
.match(/[\p{L}\p{N}]+(?:'[\p{L}]+)*/gu) || [];
|
|
216
|
+
|
|
147
217
|
const negationsIn = (s) =>
|
|
148
|
-
(
|
|
149
|
-
.map((w) => w.
|
|
218
|
+
plainWords(s)
|
|
219
|
+
.map((w) => (w.endsWith("n't") || NOT_FORMS.has(w) ? "not" : w))
|
|
220
|
+
.filter((w) => NEGATORS.has(w))
|
|
150
221
|
.sort()
|
|
151
222
|
.join(",");
|
|
152
223
|
|
|
224
|
+
// What may follow the negative -me/-ma of a Turkish verb: the necessitative,
|
|
225
|
+
// past, reported past, future, infinitive, conditional and imperative suffixes.
|
|
226
|
+
const TR_AFTER_NEGATIVE = /^(?:meli|malı|d[ıiuü]|m[ıiuü]ş|y[ae]c[ae]k|m[ae]k|s[ae]|s[ıiuü]n)/;
|
|
227
|
+
const TR_VOWEL = "aeıioöuü";
|
|
228
|
+
const TR_HIGH = "ıiuü";
|
|
229
|
+
|
|
230
|
+
/**
|
|
231
|
+
* The positive forms a Turkish word would have if it carries the negative
|
|
232
|
+
* morpheme: "engellenmemeli" -> "engellenmeli", "kullanmıyor" -> "kullanıyor",
|
|
233
|
+
* "kullanılmayacak" -> "kullanılacak", "yazmaz" -> "yazar", "kullanmayın" ->
|
|
234
|
+
* "kullanın", "kullanmayan" -> "kullanan". The vowel of a past, reported
|
|
235
|
+
* past, imperative or second-person suffix follows the stem once the
|
|
236
|
+
* negative is gone ("kurmadı" -> "kurdu", "görmemiş" -> "görmüş", "olmasın"
|
|
237
|
+
* -> "olsun"), so all four high vowels are generated. A stem under two
|
|
238
|
+
* letters is not read, so a short word that merely contains "ma" is left alone.
|
|
239
|
+
*/
|
|
240
|
+
function turkishPositives(word) {
|
|
241
|
+
const out = new Set();
|
|
242
|
+
for (let i = 2; i + 2 <= word.length; i++) {
|
|
243
|
+
if (word[i] !== "m") continue;
|
|
244
|
+
const stem = word.slice(0, i);
|
|
245
|
+
const v = word[i + 1];
|
|
246
|
+
const rest = word.slice(i + 2);
|
|
247
|
+
if (v === "e" || v === "a") {
|
|
248
|
+
if (TR_AFTER_NEGATIVE.test(rest)) out.add(stem + rest);
|
|
249
|
+
if (/^[dt][ıiuü]/.test(rest)) {
|
|
250
|
+
for (const c of "dt") for (const h of TR_HIGH) out.add(`${stem}${c}${h}${rest.slice(2)}`);
|
|
251
|
+
}
|
|
252
|
+
if (/^m[ıiuü]ş/.test(rest)) {
|
|
253
|
+
for (const h of TR_HIGH) out.add(`${stem}m${h}ş${rest.slice(3)}`);
|
|
254
|
+
}
|
|
255
|
+
if (/^s[ıiuü]n/.test(rest)) {
|
|
256
|
+
for (const h of TR_HIGH) out.add(`${stem}s${h}n${rest.slice(3)}`);
|
|
257
|
+
}
|
|
258
|
+
if (/^y[ıiuü]n/.test(rest)) {
|
|
259
|
+
for (const h of TR_HIGH) {
|
|
260
|
+
out.add(`${stem}${h}n${rest.slice(3)}`);
|
|
261
|
+
out.add(`${stem}y${h}n${rest.slice(3)}`);
|
|
262
|
+
}
|
|
263
|
+
}
|
|
264
|
+
if (/^y[ae]n/.test(rest)) {
|
|
265
|
+
out.add(stem + rest.slice(1));
|
|
266
|
+
out.add(stem + rest);
|
|
267
|
+
}
|
|
268
|
+
if (/^y[ae]c[ae]k/.test(rest)) out.add(stem + rest.slice(1));
|
|
269
|
+
if (rest.startsWith("z")) {
|
|
270
|
+
out.add(`${stem}r${rest.slice(1)}`);
|
|
271
|
+
for (const w of TR_VOWEL) out.add(`${stem}${w}r${rest.slice(1)}`);
|
|
272
|
+
}
|
|
273
|
+
}
|
|
274
|
+
if ("ıiuü".includes(v) && rest.startsWith("yor")) {
|
|
275
|
+
out.add(`${stem}${v}${rest}`);
|
|
276
|
+
out.add(stem + rest);
|
|
277
|
+
}
|
|
278
|
+
}
|
|
279
|
+
return out;
|
|
280
|
+
}
|
|
281
|
+
|
|
282
|
+
/** Two Turkish words that differ only by the verb's negative morpheme. */
|
|
283
|
+
function turkishNegationPair(a, b) {
|
|
284
|
+
return turkishPositives(a).has(b) || turkishPositives(b).has(a);
|
|
285
|
+
}
|
|
286
|
+
|
|
287
|
+
/** Does any word only one side holds negate a word only the other side holds? */
|
|
288
|
+
function oppositeWords(wordsA, wordsB) {
|
|
289
|
+
const inB = new Set(wordsB);
|
|
290
|
+
const inA = new Set(wordsA);
|
|
291
|
+
const onlyA = wordsA.filter((w) => !inB.has(w));
|
|
292
|
+
const onlyB = wordsB.filter((w) => !inA.has(w));
|
|
293
|
+
return onlyA.some((a) => onlyB.some((b) => turkishNegationPair(a, b)));
|
|
294
|
+
}
|
|
295
|
+
|
|
296
|
+
/**
|
|
297
|
+
* Whether two statements can say the same thing at all: the same numbers,
|
|
298
|
+
* the same negating words, and no Turkish verb that one side negates.
|
|
299
|
+
*/
|
|
300
|
+
function sameClaimShape(a, b) {
|
|
301
|
+
return a.numbers === b.numbers && a.negations === b.negations && !oppositeWords(a.plain, b.plain);
|
|
302
|
+
}
|
|
303
|
+
|
|
304
|
+
const claimShape = (text) => ({
|
|
305
|
+
numbers: numbersIn(text),
|
|
306
|
+
negations: negationsIn(text),
|
|
307
|
+
plain: plainWords(text),
|
|
308
|
+
});
|
|
309
|
+
|
|
153
310
|
/** Inverse document frequencies over a corpus of token lists. */
|
|
154
311
|
function idf(corpus) {
|
|
155
312
|
const df = new Map();
|
|
@@ -185,6 +342,50 @@ function orderOverlap(a, b) {
|
|
|
185
342
|
return shared / (pa.size + pb.size - shared);
|
|
186
343
|
}
|
|
187
344
|
|
|
345
|
+
/**
|
|
346
|
+
* What `shingleSimilarity` compares, computed once per statement so a
|
|
347
|
+
* pairwise pass over many repositories does not re-tokenize.
|
|
348
|
+
*
|
|
349
|
+
* @param {string} text
|
|
350
|
+
* @returns {{shingles: Set<string>, numbers: string, negations: string, plain: string[], words: number}}
|
|
351
|
+
*/
|
|
352
|
+
export function shingleProfile(text) {
|
|
353
|
+
const words = tokens(text, { unicode: true });
|
|
354
|
+
return {
|
|
355
|
+
shingles: new Set(words.slice(1).map((t, i) => `${words[i]} ${t}`)),
|
|
356
|
+
...claimShape(text),
|
|
357
|
+
words: words.length,
|
|
358
|
+
};
|
|
359
|
+
}
|
|
360
|
+
|
|
361
|
+
/**
|
|
362
|
+
* Similarity of two statements as the Jaccard overlap of their adjacent word
|
|
363
|
+
* pairs (2-shingles over the stemmed, stop-word-free tokens of any script).
|
|
364
|
+
*
|
|
365
|
+
* Pairs rather than single words because word order carries the claim:
|
|
366
|
+
* "prefer KeychainStore over UserDefaults" and "prefer UserDefaults over
|
|
367
|
+
* KeychainStore" share every word and few pairs. Words under three letters
|
|
368
|
+
* are not tokens, so they carry no order. A statement under three words is
|
|
369
|
+
* too generic to stand as evidence, and two statements whose numbers or
|
|
370
|
+
* negations differ say different things however many words they share, so
|
|
371
|
+
* each of those scores 0. A negation is a negating word in any contraction or
|
|
372
|
+
* apostrophe, or a Turkish verb that differs only by its negative -me/-ma.
|
|
373
|
+
*
|
|
374
|
+
* @param {string|ReturnType<typeof shingleProfile>} a
|
|
375
|
+
* @param {string|ReturnType<typeof shingleProfile>} b
|
|
376
|
+
* @returns {number} 0..1
|
|
377
|
+
*/
|
|
378
|
+
export function shingleSimilarity(a, b) {
|
|
379
|
+
const pa = typeof a === "string" ? shingleProfile(a) : a;
|
|
380
|
+
const pb = typeof b === "string" ? shingleProfile(b) : b;
|
|
381
|
+
if (pa.words < 3 || pb.words < 3) return 0;
|
|
382
|
+
if (!sameClaimShape(pa, pb)) return 0;
|
|
383
|
+
let shared = 0;
|
|
384
|
+
for (const s of pa.shingles) if (pb.shingles.has(s)) shared++;
|
|
385
|
+
const union = pa.shingles.size + pb.shingles.size - shared;
|
|
386
|
+
return union ? shared / union : 0;
|
|
387
|
+
}
|
|
388
|
+
|
|
188
389
|
/**
|
|
189
390
|
* The existing statement `candidate` repeats in other words, or null.
|
|
190
391
|
*
|
|
@@ -192,16 +393,14 @@ function orderOverlap(a, b) {
|
|
|
192
393
|
* @param {string[]} existing statements of the same kind
|
|
193
394
|
*/
|
|
194
395
|
export function nearDuplicate(candidate, existing) {
|
|
195
|
-
const c = tokens(candidate);
|
|
396
|
+
const c = tokens(candidate, { unicode: true });
|
|
196
397
|
if (c.length < 3) return null;
|
|
197
|
-
const docs = existing.map((s) => tokens(s));
|
|
398
|
+
const docs = existing.map((s) => tokens(s, { unicode: true }));
|
|
198
399
|
const weight = idf([...docs, c]);
|
|
199
400
|
const vc = tfidf(c, weight);
|
|
200
|
-
const
|
|
201
|
-
const negs = negationsIn(candidate);
|
|
401
|
+
const shape = claimShape(candidate);
|
|
202
402
|
for (let i = 0; i < existing.length; i++) {
|
|
203
|
-
if (
|
|
204
|
-
if (negationsIn(existing[i]) !== negs) continue;
|
|
403
|
+
if (!sameClaimShape(shape, claimShape(existing[i]))) continue;
|
|
205
404
|
if (orderOverlap(c, docs[i]) < ORDER_OVERLAP) continue;
|
|
206
405
|
if (cosine(vc, tfidf(docs[i], weight)) >= NEAR_DUP) return existing[i];
|
|
207
406
|
}
|