peaks-loop-mut 0.1.51 → 0.1.53

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 (43) hide show
  1. package/dist/index.d.ts +1 -1
  2. package/dist/index.d.ts.map +1 -1
  3. package/dist/index.js +1 -1
  4. package/dist/services/agent/ecc-archive-safety.d.ts +25 -0
  5. package/dist/services/agent/ecc-archive-safety.d.ts.map +1 -0
  6. package/dist/services/agent/ecc-archive-safety.js +131 -0
  7. package/dist/services/agent/ecc-cache-cleanup.d.ts +26 -0
  8. package/dist/services/agent/ecc-cache-cleanup.d.ts.map +1 -0
  9. package/dist/services/agent/ecc-cache-cleanup.js +90 -0
  10. package/dist/services/agent/ecc-cache-config.d.ts +66 -0
  11. package/dist/services/agent/ecc-cache-config.d.ts.map +1 -0
  12. package/dist/services/agent/ecc-cache-config.js +72 -0
  13. package/dist/services/agent/ecc-cache-manifest.d.ts +22 -0
  14. package/dist/services/agent/ecc-cache-manifest.d.ts.map +1 -0
  15. package/dist/services/agent/ecc-cache-manifest.js +136 -0
  16. package/dist/services/agent/ecc-cache-service.d.ts +6 -113
  17. package/dist/services/agent/ecc-cache-service.d.ts.map +1 -1
  18. package/dist/services/agent/ecc-cache-service.js +28 -645
  19. package/dist/services/agent/ecc-fetch.d.ts +31 -0
  20. package/dist/services/agent/ecc-fetch.d.ts.map +1 -0
  21. package/dist/services/agent/ecc-fetch.js +95 -0
  22. package/dist/services/agent/ecc-materialize.d.ts +35 -0
  23. package/dist/services/agent/ecc-materialize.d.ts.map +1 -0
  24. package/dist/services/agent/ecc-materialize.js +110 -0
  25. package/dist/services/agent/ecc-materialized-readers.d.ts +31 -0
  26. package/dist/services/agent/ecc-materialized-readers.d.ts.map +1 -0
  27. package/dist/services/agent/ecc-materialized-readers.js +107 -0
  28. package/dist/services/mut/assert-scanner.d.ts.map +1 -1
  29. package/dist/services/mut/assert-scanner.js +8 -4
  30. package/dist/services/mut/index.d.ts +3 -3
  31. package/dist/services/mut/index.d.ts.map +1 -1
  32. package/dist/services/mut/index.js +2 -2
  33. package/dist/services/mut/mut-runner.js +4 -4
  34. package/dist/services/mut/production-stryker.d.ts.map +1 -1
  35. package/dist/services/mut/production-stryker.js +17 -13
  36. package/dist/services/mut/report-builder.d.ts.map +1 -1
  37. package/dist/services/mut/report-builder.js +6 -6
  38. package/dist/services/mut/report-loader.d.ts.map +1 -1
  39. package/dist/services/mut/report-loader.js +2 -1
  40. package/dist/services/mut/thresholds.js +4 -4
  41. package/dist/services/mut/types.d.ts.map +1 -1
  42. package/dist/services/mut/types.js +14 -10
  43. package/package.json +1 -1
@@ -0,0 +1,31 @@
1
+ /**
2
+ * ECC network layer — release JSON fetch, SHA resolution and the D-010
3
+ * tarball download chain (tarball_url -> release asset -> PRD asset URL),
4
+ * including the accept-header rules that keep the API tarball alive.
5
+ *
6
+ * Split verbatim out of `ecc-cache-service.ts` (wave 11 slice A,
7
+ * 2026-10-03); no behaviour changed.
8
+ */
9
+ /**
10
+ * Best-effort fetch of the upstream release JSON. Returns the
11
+ * parsed body, or null on any network/parse error. Used as the
12
+ * D-010 fallback path.
13
+ */
14
+ declare function fetchReleaseJson(apiBase: string): Promise<{
15
+ tag_name?: string;
16
+ tarball_url?: string;
17
+ assets?: {
18
+ name: string;
19
+ browser_download_url: string;
20
+ }[];
21
+ } | null>;
22
+ /**
23
+ * Resolve a 40-char commit SHA for `tag`. Prefers the GitHub
24
+ * releases API (which dereferences annotated tags to commit SHA
25
+ * via `target_commitish`). Falls back to the tag name if the
26
+ * upstream returns a non-SHA-shaped identifier (older tags).
27
+ */
28
+ declare function resolveCommitSha(ref: string): Promise<string | null>;
29
+ declare function downloadTarball(ref: string, sha: string, outDir: string): Promise<string[]>;
30
+ export { fetchReleaseJson, resolveCommitSha, downloadTarball };
31
+ //# sourceMappingURL=ecc-fetch.d.ts.map
@@ -0,0 +1 @@
1
+ {"version":3,"file":"ecc-fetch.d.ts","sourceRoot":"","sources":["../../../src/services/agent/ecc-fetch.ts"],"names":[],"mappings":"AAAA;;;;;;;GAOG;AAUH;;;;GAIG;AACH,iBAAe,gBAAgB,CAAC,OAAO,EAAE,MAAM,GAAG,OAAO,CAAC;IACxD,QAAQ,CAAC,EAAE,MAAM,CAAC;IAClB,WAAW,CAAC,EAAE,MAAM,CAAC;IACrB,MAAM,CAAC,EAAE;QAAE,IAAI,EAAE,MAAM,CAAC;QAAC,oBAAoB,EAAE,MAAM,CAAA;KAAE,EAAE,CAAC;CAC3D,GAAG,IAAI,CAAC,CAcR;AAED;;;;;GAKG;AACH,iBAAe,gBAAgB,CAAC,GAAG,EAAE,MAAM,GAAG,OAAO,CAAC,MAAM,GAAG,IAAI,CAAC,CAMnE;AAuBD,iBAAe,eAAe,CAAC,GAAG,EAAE,MAAM,EAAE,GAAG,EAAE,MAAM,EAAE,MAAM,EAAE,MAAM,GAAG,OAAO,CAAC,MAAM,EAAE,CAAC,CAmC1F;AAGD,OAAO,EAAE,gBAAgB,EAAE,gBAAgB,EAAE,eAAe,EAAE,CAAC"}
@@ -0,0 +1,95 @@
1
+ /**
2
+ * ECC network layer — release JSON fetch, SHA resolution and the D-010
3
+ * tarball download chain (tarball_url -> release asset -> PRD asset URL),
4
+ * including the accept-header rules that keep the API tarball alive.
5
+ *
6
+ * Split verbatim out of `ecc-cache-service.ts` (wave 11 slice A,
7
+ * 2026-10-03); no behaviour changed.
8
+ */
9
+ import { ECC_REPO_OWNER, ECC_REPO_NAME, ECC_TARBALL_BASENAME, GITHUB_API_ACCEPT } from './ecc-cache-config.js';
10
+ import { extractAgentsFromTarGz } from './ecc-archive-safety.js';
11
+ /**
12
+ * Best-effort fetch of the upstream release JSON. Returns the
13
+ * parsed body, or null on any network/parse error. Used as the
14
+ * D-010 fallback path.
15
+ */
16
+ async function fetchReleaseJson(apiBase) {
17
+ try {
18
+ const res = await fetch(apiBase, {
19
+ headers: { accept: 'application/vnd.github+json', 'user-agent': 'peaks-loop' }
20
+ });
21
+ if (!res.ok)
22
+ return null;
23
+ return (await res.json());
24
+ }
25
+ catch {
26
+ return null;
27
+ }
28
+ }
29
+ /**
30
+ * Resolve a 40-char commit SHA for `tag`. Prefers the GitHub
31
+ * releases API (which dereferences annotated tags to commit SHA
32
+ * via `target_commitish`). Falls back to the tag name if the
33
+ * upstream returns a non-SHA-shaped identifier (older tags).
34
+ */
35
+ async function resolveCommitSha(ref) {
36
+ const apiBase = `https://api.github.com/repos/${ECC_REPO_OWNER}/${ECC_REPO_NAME}/releases/tags/${encodeURIComponent(ref)}`;
37
+ const release = await fetchReleaseJson(apiBase);
38
+ const tagName = release?.tag_name ?? ref;
39
+ if (/^[0-9a-f]{40}$/.test(tagName))
40
+ return tagName;
41
+ return tagName;
42
+ }
43
+ /**
44
+ * Binary fetch with an explicit, overridable `accept`.
45
+ *
46
+ * Do NOT default to `application/octet-stream`: GitHub's
47
+ * `api.github.com/.../tarball/<ref>` endpoint rejects it with 415.
48
+ * Omitting `accept` entirely is fine for release-asset / codeload
49
+ * URLs, which always serve the bytes.
50
+ */
51
+ async function fetchBuffer(url, accept) {
52
+ try {
53
+ const headers = { 'user-agent': 'peaks-loop' };
54
+ if (accept !== undefined)
55
+ headers.accept = accept;
56
+ const res = await fetch(url, { headers });
57
+ if (!res.ok)
58
+ return null;
59
+ const ab = await res.arrayBuffer();
60
+ return new Uint8Array(ab);
61
+ }
62
+ catch {
63
+ return null;
64
+ }
65
+ }
66
+ async function downloadTarball(ref, sha, outDir) {
67
+ // D-010 order (2026-09-09): tarball_url -> release asset -> PRD URL.
68
+ // See the module header for why each step exists and which one works.
69
+ let buffer = null;
70
+ const release = await fetchReleaseJson(`https://api.github.com/repos/${ECC_REPO_OWNER}/${ECC_REPO_NAME}/releases/tags/${encodeURIComponent(ref)}`);
71
+ // 1. API tarball. Requires the GitHub JSON accept header (octet-stream 415s).
72
+ const tarballUrl = release?.tarball_url;
73
+ if (typeof tarballUrl === 'string' && tarballUrl.length > 0) {
74
+ buffer = await fetchBuffer(tarballUrl, GITHUB_API_ACCEPT);
75
+ }
76
+ // 2. Release asset, if this release happens to ship one.
77
+ if (buffer === null && Array.isArray(release?.assets)) {
78
+ const asset = release.assets.find((a) => a.name === ECC_TARBALL_BASENAME) ??
79
+ release.assets.find((a) => a.name === `${ECC_REPO_NAME}-universal-${ref}.tgz`) ??
80
+ release.assets.find((a) => a.name.endsWith('.tgz') || a.name.endsWith('.tar.gz'));
81
+ if (asset)
82
+ buffer = await fetchBuffer(asset.browser_download_url);
83
+ }
84
+ // 3. PRD asset URL — last resort, dead upstream today.
85
+ if (buffer === null) {
86
+ const prdUrl = `https://github.com/${ECC_REPO_OWNER}/${ECC_REPO_NAME}/releases/download/${encodeURIComponent(ref)}/${ECC_TARBALL_BASENAME}`;
87
+ buffer = await fetchBuffer(prdUrl);
88
+ }
89
+ if (buffer === null) {
90
+ throw new Error('fetch-failed');
91
+ }
92
+ return extractAgentsFromTarGz(buffer, outDir);
93
+ }
94
+ // Cross-module glue: private inside ecc-cache-service.ts before the split.
95
+ export { fetchReleaseJson, resolveCommitSha, downloadTarball };
@@ -0,0 +1,35 @@
1
+ /**
2
+ * The materialize write path — `materializeEccAgents` copies the active
3
+ * cache's `agents/*.md` into the peaks-owned stable dir, and
4
+ * `materializeBestEffort` wraps it for the download path.
5
+ *
6
+ * Split verbatim out of `ecc-cache-service.ts` (wave 11 slice A,
7
+ * 2026-10-03); no behaviour changed.
8
+ */
9
+ /**
10
+ * Refresh the plugin-free copy after a successful download. Swallows every
11
+ * error: `peaks ecc install` succeeds even when the materialize step cannot
12
+ * write (read-only home, disk full, ...) — the caller falls back to inline
13
+ * review in that case.
14
+ */
15
+ declare function materializeBestEffort(cacheDir: string): void;
16
+ /**
17
+ * Copy the active cache's `agents/*.md` into a stable, peaks-owned
18
+ * directory (`~/.peaks/agents/ecc/` by default) and write a small
19
+ * manifest. Fail-soft: an empty/missing cache yields
20
+ * `{ sha: null, materialized: [] }` and never throws — `peaks ecc install`
21
+ * must not fail because materialization did.
22
+ *
23
+ * `targetDir` is the ONLY write root (plus `mkdirSync` on it). Nothing in
24
+ * this function can reach `~/.claude/`.
25
+ */
26
+ export declare function materializeEccAgents({ cacheDir, targetDir }?: {
27
+ cacheDir?: string;
28
+ targetDir?: string;
29
+ }): {
30
+ targetDir: string;
31
+ sha: string | null;
32
+ materialized: string[];
33
+ };
34
+ export { materializeBestEffort };
35
+ //# sourceMappingURL=ecc-materialize.d.ts.map
@@ -0,0 +1 @@
1
+ {"version":3,"file":"ecc-materialize.d.ts","sourceRoot":"","sources":["../../../src/services/agent/ecc-materialize.ts"],"names":[],"mappings":"AAAA;;;;;;;GAOG;AAgBH;;;;;GAKG;AACH,iBAAS,qBAAqB,CAAC,QAAQ,EAAE,MAAM,GAAG,IAAI,CAMrD;AAED;;;;;;;;;GASG;AACH,wBAAgB,oBAAoB,CAAC,EACnC,QAAQ,EACR,SAAS,EACV,GAAE;IAAE,QAAQ,CAAC,EAAE,MAAM,CAAC;IAAC,SAAS,CAAC,EAAE,MAAM,CAAA;CAAO,GAAG;IAClD,SAAS,EAAE,MAAM,CAAC;IAClB,GAAG,EAAE,MAAM,GAAG,IAAI,CAAC;IACnB,YAAY,EAAE,MAAM,EAAE,CAAC;CACxB,CAsEA;AAGD,OAAO,EAAE,qBAAqB,EAAE,CAAC"}
@@ -0,0 +1,110 @@
1
+ /**
2
+ * The materialize write path — `materializeEccAgents` copies the active
3
+ * cache's `agents/*.md` into the peaks-owned stable dir, and
4
+ * `materializeBestEffort` wraps it for the download path.
5
+ *
6
+ * Split verbatim out of `ecc-cache-service.ts` (wave 11 slice A,
7
+ * 2026-10-03); no behaviour changed.
8
+ */
9
+ import { existsSync, mkdirSync, readdirSync, readFileSync, rmSync, writeFileSync } from 'node:fs';
10
+ import { join } from 'node:path';
11
+ import { ECC_MATERIALIZE_VERSION, resolveEccMaterializedDir, resolveEccMaterializedManifestPath, resolveAgentsDir, setCacheDirPermissions } from './ecc-cache-config.js';
12
+ import { readManifestAt } from './ecc-cache-manifest.js';
13
+ import { isSafeAgentName } from './ecc-archive-safety.js';
14
+ /**
15
+ * Refresh the plugin-free copy after a successful download. Swallows every
16
+ * error: `peaks ecc install` succeeds even when the materialize step cannot
17
+ * write (read-only home, disk full, ...) — the caller falls back to inline
18
+ * review in that case.
19
+ */
20
+ function materializeBestEffort(cacheDir) {
21
+ try {
22
+ materializeEccAgents({ cacheDir });
23
+ }
24
+ catch {
25
+ /* best-effort */
26
+ }
27
+ }
28
+ /**
29
+ * Copy the active cache's `agents/*.md` into a stable, peaks-owned
30
+ * directory (`~/.peaks/agents/ecc/` by default) and write a small
31
+ * manifest. Fail-soft: an empty/missing cache yields
32
+ * `{ sha: null, materialized: [] }` and never throws — `peaks ecc install`
33
+ * must not fail because materialization did.
34
+ *
35
+ * `targetDir` is the ONLY write root (plus `mkdirSync` on it). Nothing in
36
+ * this function can reach `~/.claude/`.
37
+ */
38
+ export function materializeEccAgents({ cacheDir, targetDir } = {}) {
39
+ const resolvedTarget = targetDir ?? resolveEccMaterializedDir();
40
+ const manifest = readManifestAt(cacheDir);
41
+ if (manifest === null) {
42
+ return { targetDir: resolvedTarget, sha: null, materialized: [] };
43
+ }
44
+ const agentsDir = resolveAgentsDir(manifest.sha, cacheDir);
45
+ if (!existsSync(agentsDir)) {
46
+ return { targetDir: resolvedTarget, sha: null, materialized: [] };
47
+ }
48
+ let entries;
49
+ try {
50
+ entries = readdirSync(agentsDir);
51
+ }
52
+ catch {
53
+ return { targetDir: resolvedTarget, sha: null, materialized: [] };
54
+ }
55
+ try {
56
+ if (!existsSync(resolvedTarget))
57
+ mkdirSync(resolvedTarget, { recursive: true });
58
+ setCacheDirPermissions(resolvedTarget);
59
+ }
60
+ catch {
61
+ return { targetDir: resolvedTarget, sha: null, materialized: [] };
62
+ }
63
+ const materialized = [];
64
+ for (const file of entries) {
65
+ if (!file.endsWith('.md'))
66
+ continue;
67
+ const name = file.replace(/\.md$/i, '');
68
+ if (!isSafeAgentName(name))
69
+ continue;
70
+ try {
71
+ const body = readFileSync(join(agentsDir, file), 'utf8');
72
+ writeFileSync(join(resolvedTarget, `${name}.md`), body);
73
+ materialized.push(name);
74
+ }
75
+ catch {
76
+ /* fail-soft per agent */
77
+ }
78
+ }
79
+ materialized.sort();
80
+ // Prune stale copies so `readMaterializedAgent` cannot serve an agent
81
+ // the active cache no longer ships.
82
+ try {
83
+ for (const existing of readdirSync(resolvedTarget)) {
84
+ if (!existing.endsWith('.md'))
85
+ continue;
86
+ const name = existing.replace(/\.md$/i, '');
87
+ if (!materialized.includes(name)) {
88
+ rmSync(join(resolvedTarget, existing), { force: true });
89
+ }
90
+ }
91
+ }
92
+ catch {
93
+ /* fail-soft */
94
+ }
95
+ const nextManifest = {
96
+ version: ECC_MATERIALIZE_VERSION,
97
+ sha: manifest.sha,
98
+ materializedAt: new Date().toISOString(),
99
+ agents: materialized
100
+ };
101
+ try {
102
+ writeFileSync(resolveEccMaterializedManifestPath(resolvedTarget), JSON.stringify(nextManifest, null, 2));
103
+ }
104
+ catch {
105
+ /* fail-soft */
106
+ }
107
+ return { targetDir: resolvedTarget, sha: manifest.sha, materialized };
108
+ }
109
+ // Cross-module glue: private inside ecc-cache-service.ts before the split.
110
+ export { materializeBestEffort };
@@ -0,0 +1,31 @@
1
+ /**
2
+ * Readers for the plugin-free materialized ECC agents.
3
+ *
4
+ * Split verbatim out of `ecc-cache-service.ts` (wave 11 slice A,
5
+ * 2026-10-03); no behaviour changed. The section banner below is the
6
+ * original in-file divider of the materialize layer, kept verbatim.
7
+ */
8
+ import { type EccMaterializeManifest } from './ecc-cache-config.js';
9
+ export declare function readEccMaterializeManifest(dirOverride?: string): EccMaterializeManifest | null;
10
+ export declare function listMaterializedAgents(dirOverride?: string): string[];
11
+ export declare function hasMaterializedEccAgents(dirOverride?: string): boolean;
12
+ /**
13
+ * Resolve the materialized ECC agent name for a logical role.
14
+ *
15
+ * Upstream ECC names its agents `<lang>-reviewer` (`code-reviewer.md`),
16
+ * NOT `code-review.md` — so no caller may hardcode a single filename.
17
+ * Resolution order (deterministic; `listMaterializedAgents` is sorted):
18
+ * 1. the caller's explicit candidates, in declared priority order
19
+ * (e.g. `['code-reviewer', 'code-review']` — real upstream name
20
+ * first, legacy/forward-compat second);
21
+ * 2. a fallback over the materialized list: the exact
22
+ * `<stem>-reviewer`, else the first `<stem>-*` whose name contains
23
+ * `reviewer`, where `stem` is the candidate minus a `-reviewer`
24
+ * suffix (`code-reviewer` -> `code`).
25
+ *
26
+ * Returns `null` when nothing matches — the caller degrades to inline
27
+ * review instead of dispatching a non-existent agent.
28
+ */
29
+ export declare function resolveMaterializedAgentName(candidates: readonly string[], dirOverride?: string): string | null;
30
+ export declare function readMaterializedAgent(name: string, dirOverride?: string): string | null;
31
+ //# sourceMappingURL=ecc-materialized-readers.d.ts.map
@@ -0,0 +1 @@
1
+ {"version":3,"file":"ecc-materialized-readers.d.ts","sourceRoot":"","sources":["../../../src/services/agent/ecc-materialized-readers.ts"],"names":[],"mappings":"AAAA;;;;;;GAMG;AAKH,OAAO,EAGL,KAAK,sBAAsB,EAC5B,MAAM,uBAAuB,CAAC;AAe/B,wBAAgB,0BAA0B,CAAC,WAAW,CAAC,EAAE,MAAM,GAAG,sBAAsB,GAAG,IAAI,CAiB9F;AAED,wBAAgB,sBAAsB,CAAC,WAAW,CAAC,EAAE,MAAM,GAAG,MAAM,EAAE,CAYrE;AAED,wBAAgB,wBAAwB,CAAC,WAAW,CAAC,EAAE,MAAM,GAAG,OAAO,CAEtE;AAED;;;;;;;;;;;;;;;;GAgBG;AACH,wBAAgB,4BAA4B,CAC1C,UAAU,EAAE,SAAS,MAAM,EAAE,EAC7B,WAAW,CAAC,EAAE,MAAM,GACnB,MAAM,GAAG,IAAI,CAmBf;AAED,wBAAgB,qBAAqB,CAAC,IAAI,EAAE,MAAM,EAAE,WAAW,CAAC,EAAE,MAAM,GAAG,MAAM,GAAG,IAAI,CASvF"}
@@ -0,0 +1,107 @@
1
+ /**
2
+ * Readers for the plugin-free materialized ECC agents.
3
+ *
4
+ * Split verbatim out of `ecc-cache-service.ts` (wave 11 slice A,
5
+ * 2026-10-03); no behaviour changed. The section banner below is the
6
+ * original in-file divider of the materialize layer, kept verbatim.
7
+ */
8
+ import { existsSync, readdirSync, readFileSync } from 'node:fs';
9
+ import { join } from 'node:path';
10
+ import { resolveEccMaterializedDir, resolveEccMaterializedManifestPath } from './ecc-cache-config.js';
11
+ import { isSafeAgentName } from './ecc-archive-safety.js';
12
+ // ---------------------------------------------------------------------
13
+ // Plugin-free materialize layer (Slice A of 2026-09-09-ecc-dynamic)
14
+ //
15
+ // `peaks ecc install` downloads ECC `agents/*.md` into the sha cache, but
16
+ // that path is plugin-independent only in storage — the RD fan-out still
17
+ // needed `Agent({subagent_type: 'everything-claude-code:code-review'})` (old retired id),
18
+ // which requires the ECC Claude Code plugin. Materializing a normalized
19
+ // copy under `~/.peaks/agents/ecc/` gives the RD loop a plugin-free read
20
+ // target so a fresh machine without the ECC plugin can still run the
21
+ // review via a generic sub-agent.
22
+ // ---------------------------------------------------------------------
23
+ export function readEccMaterializeManifest(dirOverride) {
24
+ const path = resolveEccMaterializedManifestPath(dirOverride);
25
+ if (!existsSync(path))
26
+ return null;
27
+ try {
28
+ const parsed = JSON.parse(readFileSync(path, 'utf8'));
29
+ if (typeof parsed.version === 'string' &&
30
+ typeof parsed.sha === 'string' &&
31
+ typeof parsed.materializedAt === 'string' &&
32
+ Array.isArray(parsed.agents)) {
33
+ return parsed;
34
+ }
35
+ return null;
36
+ }
37
+ catch {
38
+ return null;
39
+ }
40
+ }
41
+ export function listMaterializedAgents(dirOverride) {
42
+ const dir = dirOverride ?? resolveEccMaterializedDir();
43
+ if (!existsSync(dir))
44
+ return [];
45
+ try {
46
+ return readdirSync(dir)
47
+ .filter((f) => f.endsWith('.md'))
48
+ .map((f) => f.replace(/\.md$/i, ''))
49
+ .filter((name) => isSafeAgentName(name))
50
+ .sort();
51
+ }
52
+ catch {
53
+ return [];
54
+ }
55
+ }
56
+ export function hasMaterializedEccAgents(dirOverride) {
57
+ return listMaterializedAgents(dirOverride).length > 0;
58
+ }
59
+ /**
60
+ * Resolve the materialized ECC agent name for a logical role.
61
+ *
62
+ * Upstream ECC names its agents `<lang>-reviewer` (`code-reviewer.md`),
63
+ * NOT `code-review.md` — so no caller may hardcode a single filename.
64
+ * Resolution order (deterministic; `listMaterializedAgents` is sorted):
65
+ * 1. the caller's explicit candidates, in declared priority order
66
+ * (e.g. `['code-reviewer', 'code-review']` — real upstream name
67
+ * first, legacy/forward-compat second);
68
+ * 2. a fallback over the materialized list: the exact
69
+ * `<stem>-reviewer`, else the first `<stem>-*` whose name contains
70
+ * `reviewer`, where `stem` is the candidate minus a `-reviewer`
71
+ * suffix (`code-reviewer` -> `code`).
72
+ *
73
+ * Returns `null` when nothing matches — the caller degrades to inline
74
+ * review instead of dispatching a non-existent agent.
75
+ */
76
+ export function resolveMaterializedAgentName(candidates, dirOverride) {
77
+ const available = listMaterializedAgents(dirOverride);
78
+ if (available.length === 0)
79
+ return null;
80
+ for (const candidate of candidates) {
81
+ if (available.includes(candidate))
82
+ return candidate;
83
+ }
84
+ for (const candidate of candidates) {
85
+ const stem = candidate.replace(/-reviewer$/, '');
86
+ const exact = available.find((name) => name === `${stem}-reviewer`);
87
+ if (exact !== undefined)
88
+ return exact;
89
+ const reviewerish = available.find((name) => name.startsWith(`${stem}-`) && name.includes('reviewer'));
90
+ if (reviewerish !== undefined)
91
+ return reviewerish;
92
+ }
93
+ return null;
94
+ }
95
+ export function readMaterializedAgent(name, dirOverride) {
96
+ if (!isSafeAgentName(name))
97
+ return null;
98
+ const file = join(dirOverride ?? resolveEccMaterializedDir(), `${name}.md`);
99
+ if (!existsSync(file))
100
+ return null;
101
+ try {
102
+ return readFileSync(file, 'utf8');
103
+ }
104
+ catch {
105
+ return null;
106
+ }
107
+ }
@@ -1 +1 @@
1
- {"version":3,"file":"assert-scanner.d.ts","sourceRoot":"","sources":["../../../src/services/mut/assert-scanner.ts"],"names":[],"mappings":"AAiBA,OAAO,KAAK,EACV,gBAAgB,EACjB,MAAM,YAAY,CAAC;AAepB,MAAM,WAAW,SAAS;IACxB,QAAQ,CAAC,OAAO,EAAE,MAAM,CAAC;IACzB,QAAQ,CAAC,SAAS,EAAE,aAAa,CAAC,MAAM,CAAC,CAAC;CAC3C;AA6BD,wBAAsB,cAAc,CAAC,KAAK,EAAE,SAAS,GAAG,OAAO,CAAC,gBAAgB,CAAC,CAqEhF"}
1
+ {"version":3,"file":"assert-scanner.d.ts","sourceRoot":"","sources":["../../../src/services/mut/assert-scanner.ts"],"names":[],"mappings":"AAiBA,OAAO,KAAK,EAAE,gBAAgB,EAA8C,MAAM,YAAY,CAAC;AAe/F,MAAM,WAAW,SAAS;IACxB,QAAQ,CAAC,OAAO,EAAE,MAAM,CAAC;IACzB,QAAQ,CAAC,SAAS,EAAE,aAAa,CAAC,MAAM,CAAC,CAAC;CAC3C;AA6BD,wBAAsB,cAAc,CAAC,KAAK,EAAE,SAAS,GAAG,OAAO,CAAC,gBAAgB,CAAC,CAyEhF"}
@@ -18,7 +18,7 @@ import { join } from 'node:path';
18
18
  const WEAK_PATTERNS = [
19
19
  { pattern: 'toBeDefined', regex: /\.toBeDefined\s*\(\s*\)/g },
20
20
  { pattern: 'toBeTruthy', regex: /\.toBeTruthy\s*\(\s*\)/g },
21
- { pattern: 'expect-anything', regex: /expect\.anything\s*\(\s*\)/g },
21
+ { pattern: 'expect-anything', regex: /expect\.anything\s*\(\s*\)/g }
22
22
  // Self-equality patterns require matched-pair parsing; handled below.
23
23
  ];
24
24
  const TO_EQUAL_SELF = /\.toEqual\s*\(\s*([a-zA-Z_$][\w$]*)\s*\)/g;
@@ -73,7 +73,9 @@ export async function scanAssertions(input) {
73
73
  // toEqual-self: needs receiver extraction.
74
74
  const eqSelf = [...content.matchAll(TO_EQUAL_SELF)];
75
75
  for (const m of eqSelf) {
76
- const receiverMatch = content.slice(0, m.index ?? 0).match(/expect\s*\(\s*([a-zA-Z_$][\w$]*)\s*\)/g);
76
+ const receiverMatch = content
77
+ .slice(0, m.index ?? 0)
78
+ .match(/expect\s*\(\s*([a-zA-Z_$][\w$]*)\s*\)/g);
77
79
  if (receiverMatch && receiverMatch.length > 0) {
78
80
  const lastReceiver = receiverMatch[receiverMatch.length - 1];
79
81
  const receiverName = lastReceiver?.match(/expect\s*\(\s*([a-zA-Z_$][\w$]*)\s*\)/)?.[1];
@@ -89,7 +91,9 @@ export async function scanAssertions(input) {
89
91
  // toBe-self: same pattern.
90
92
  const beSelf = [...content.matchAll(TO_BE_SELF)];
91
93
  for (const m of beSelf) {
92
- const receiverMatch = content.slice(0, m.index ?? 0).match(/expect\s*\(\s*([a-zA-Z_$][\w$]*)\s*\)/g);
94
+ const receiverMatch = content
95
+ .slice(0, m.index ?? 0)
96
+ .match(/expect\s*\(\s*([a-zA-Z_$][\w$]*)\s*\)/g);
93
97
  if (receiverMatch && receiverMatch.length > 0) {
94
98
  const lastReceiver = receiverMatch[receiverMatch.length - 1];
95
99
  const receiverName = lastReceiver?.match(/expect\s*\(\s*([a-zA-Z_$][\w$]*)\s*\)/)?.[1];
@@ -111,6 +115,6 @@ export async function scanAssertions(input) {
111
115
  totalAssertions: total,
112
116
  weakAssertions: weak,
113
117
  weakRate: total === 0 ? 0 : weak / total,
114
- weakPatterns,
118
+ weakPatterns
115
119
  };
116
120
  }
@@ -1,9 +1,9 @@
1
1
  export { MutReportSchema } from './types.js';
2
2
  export { scanAssertions, type ScanInput } from './assert-scanner.js';
3
- export { runMutation, type RunMutationInput, type RunMutationOutput, type StrykerInvoker, type StrykerRawResult, } from './mut-runner.js';
3
+ export { runMutation, type RunMutationInput, type RunMutationOutput, type StrykerInvoker, type StrykerRawResult } from './mut-runner.js';
4
4
  export { createProductionStrykerInvoker } from './production-stryker.js';
5
5
  export { buildMutReport, type BuildMutInput } from './report-builder.js';
6
6
  export { loadMutReport, mutReportPath, MUT_REPORT_RELATIVE_PATH } from './report-loader.js';
7
- export { DEFAULT_THRESHOLDS, evaluateThresholds, type Thresholds, type ThresholdEvaluation, type ThresholdViolation, type ThresholdViolationKind, } from './thresholds.js';
8
- export type { MutReportJson, MutationReport, AssertionsReport, WeakPattern, WeakPatternCount, Followup, } from './types.js';
7
+ export { DEFAULT_THRESHOLDS, evaluateThresholds, type Thresholds, type ThresholdEvaluation, type ThresholdViolation, type ThresholdViolationKind } from './thresholds.js';
8
+ export type { MutReportJson, MutationReport, AssertionsReport, WeakPattern, WeakPatternCount, Followup } from './types.js';
9
9
  //# sourceMappingURL=index.d.ts.map
@@ -1 +1 @@
1
- {"version":3,"file":"index.d.ts","sourceRoot":"","sources":["../../../src/services/mut/index.ts"],"names":[],"mappings":"AAAA,OAAO,EAAE,eAAe,EAAE,MAAM,YAAY,CAAC;AAC7C,OAAO,EAAE,cAAc,EAAE,KAAK,SAAS,EAAE,MAAM,qBAAqB,CAAC;AACrE,OAAO,EACL,WAAW,EACX,KAAK,gBAAgB,EACrB,KAAK,iBAAiB,EACtB,KAAK,cAAc,EACnB,KAAK,gBAAgB,GACtB,MAAM,iBAAiB,CAAC;AACzB,OAAO,EAAE,8BAA8B,EAAE,MAAM,yBAAyB,CAAC;AACzE,OAAO,EAAE,cAAc,EAAE,KAAK,aAAa,EAAE,MAAM,qBAAqB,CAAC;AACzE,OAAO,EAAE,aAAa,EAAE,aAAa,EAAE,wBAAwB,EAAE,MAAM,oBAAoB,CAAC;AAC5F,OAAO,EACL,kBAAkB,EAClB,kBAAkB,EAClB,KAAK,UAAU,EACf,KAAK,mBAAmB,EACxB,KAAK,kBAAkB,EACvB,KAAK,sBAAsB,GAC5B,MAAM,iBAAiB,CAAC;AACzB,YAAY,EACV,aAAa,EAAE,cAAc,EAAE,gBAAgB,EAC/C,WAAW,EAAE,gBAAgB,EAAE,QAAQ,GACxC,MAAM,YAAY,CAAC"}
1
+ {"version":3,"file":"index.d.ts","sourceRoot":"","sources":["../../../src/services/mut/index.ts"],"names":[],"mappings":"AAAA,OAAO,EAAE,eAAe,EAAE,MAAM,YAAY,CAAC;AAC7C,OAAO,EAAE,cAAc,EAAE,KAAK,SAAS,EAAE,MAAM,qBAAqB,CAAC;AACrE,OAAO,EACL,WAAW,EACX,KAAK,gBAAgB,EACrB,KAAK,iBAAiB,EACtB,KAAK,cAAc,EACnB,KAAK,gBAAgB,EACtB,MAAM,iBAAiB,CAAC;AACzB,OAAO,EAAE,8BAA8B,EAAE,MAAM,yBAAyB,CAAC;AACzE,OAAO,EAAE,cAAc,EAAE,KAAK,aAAa,EAAE,MAAM,qBAAqB,CAAC;AACzE,OAAO,EAAE,aAAa,EAAE,aAAa,EAAE,wBAAwB,EAAE,MAAM,oBAAoB,CAAC;AAC5F,OAAO,EACL,kBAAkB,EAClB,kBAAkB,EAClB,KAAK,UAAU,EACf,KAAK,mBAAmB,EACxB,KAAK,kBAAkB,EACvB,KAAK,sBAAsB,EAC5B,MAAM,iBAAiB,CAAC;AACzB,YAAY,EACV,aAAa,EACb,cAAc,EACd,gBAAgB,EAChB,WAAW,EACX,gBAAgB,EAChB,QAAQ,EACT,MAAM,YAAY,CAAC"}
@@ -1,7 +1,7 @@
1
1
  export { MutReportSchema } from './types.js';
2
2
  export { scanAssertions } from './assert-scanner.js';
3
- export { runMutation, } from './mut-runner.js';
3
+ export { runMutation } from './mut-runner.js';
4
4
  export { createProductionStrykerInvoker } from './production-stryker.js';
5
5
  export { buildMutReport } from './report-builder.js';
6
6
  export { loadMutReport, mutReportPath, MUT_REPORT_RELATIVE_PATH } from './report-loader.js';
7
- export { DEFAULT_THRESHOLDS, evaluateThresholds, } from './thresholds.js';
7
+ export { DEFAULT_THRESHOLDS, evaluateThresholds } from './thresholds.js';
@@ -3,7 +3,7 @@ export async function runMutation(input) {
3
3
  try {
4
4
  raw = await input.invokeStryker({
5
5
  project: input.project,
6
- testFiles: input.testFiles,
6
+ testFiles: input.testFiles
7
7
  });
8
8
  }
9
9
  catch (err) {
@@ -22,8 +22,8 @@ export async function runMutation(input) {
22
22
  byFile: raw.perFile.map((f) => ({
23
23
  file: f.file,
24
24
  killRate: f.killRate,
25
- survived: f.survived,
26
- })),
27
- },
25
+ survived: f.survived
26
+ }))
27
+ }
28
28
  };
29
29
  }
@@ -1 +1 @@
1
- {"version":3,"file":"production-stryker.d.ts","sourceRoot":"","sources":["../../../src/services/mut/production-stryker.ts"],"names":[],"mappings":"AAMA,OAAO,KAAK,EAAE,cAAc,EAAoB,MAAM,iBAAiB,CAAC;AAcxE,wBAAgB,8BAA8B,IAAI,cAAc,CAY/D"}
1
+ {"version":3,"file":"production-stryker.d.ts","sourceRoot":"","sources":["../../../src/services/mut/production-stryker.ts"],"names":[],"mappings":"AAMA,OAAO,KAAK,EAAE,cAAc,EAAoB,MAAM,iBAAiB,CAAC;AAsBxE,wBAAgB,8BAA8B,IAAI,cAAc,CAY/D"}
@@ -18,17 +18,7 @@ export function createProductionStrykerInvoker() {
18
18
  };
19
19
  }
20
20
  function normalize(mutants, project) {
21
- let mutantsKilled = 0;
22
- let mutantsSurvived = 0;
23
- let mutantsTimeout = 0;
24
- for (const m of mutants) {
25
- if (m.status === 'Killed')
26
- mutantsKilled++;
27
- else if (m.status === 'Survived')
28
- mutantsSurvived++;
29
- else if (m.status === 'Timeout')
30
- mutantsTimeout++;
31
- }
21
+ const { mutantsKilled, mutantsSurvived, mutantsTimeout } = countStatuses(mutants);
32
22
  // Bucket mutants by fileName to populate perFile. deriveFollowups iterates
33
23
  // m.byFile to emit per-file followups (e.g. low_kill_rate) — leaving this
34
24
  // empty (as v0 did) silently swallowed those followups in production.
@@ -53,7 +43,7 @@ function normalize(mutants, project) {
53
43
  bucket.survivedEntries.push({
54
44
  line: m.location.start.line + 1, // Stryker is 0-based; reports are 1-based.
55
45
  mutation: m.replacement,
56
- survivedBecause: m.statusReason ?? '',
46
+ survivedBecause: m.statusReason ?? ''
57
47
  });
58
48
  }
59
49
  }
@@ -70,6 +60,20 @@ function normalize(mutants, project) {
70
60
  mutantsKilled,
71
61
  mutantsSurvived,
72
62
  mutantsTimeout,
73
- perFile,
63
+ perFile
74
64
  };
75
65
  }
66
+ function countStatuses(mutants) {
67
+ let mutantsKilled = 0;
68
+ let mutantsSurvived = 0;
69
+ let mutantsTimeout = 0;
70
+ for (const m of mutants) {
71
+ if (m.status === 'Killed')
72
+ mutantsKilled++;
73
+ else if (m.status === 'Survived')
74
+ mutantsSurvived++;
75
+ else if (m.status === 'Timeout')
76
+ mutantsTimeout++;
77
+ }
78
+ return { mutantsKilled, mutantsSurvived, mutantsTimeout };
79
+ }
@@ -1 +1 @@
1
- {"version":3,"file":"report-builder.d.ts","sourceRoot":"","sources":["../../../src/services/mut/report-builder.ts"],"names":[],"mappings":"AAcA,OAAO,EAEL,KAAK,gBAAgB,EAErB,KAAK,cAAc,EACnB,KAAK,aAAa,EACnB,MAAM,YAAY,CAAC;AACpB,OAAO,EAGL,KAAK,UAAU,EAChB,MAAM,iBAAiB,CAAC;AAEzB,MAAM,WAAW,aAAa;IAC5B,QAAQ,CAAC,QAAQ,EAAE,cAAc,CAAC;IAClC,QAAQ,CAAC,UAAU,EAAE,gBAAgB,CAAC;IACtC,QAAQ,CAAC,QAAQ,EAAE,MAAM,CAAC;IAC1B,QAAQ,CAAC,GAAG,EAAE,MAAM,CAAC;IACrB,QAAQ,CAAC,UAAU,CAAC,EAAE,UAAU,CAAC;IACjC,QAAQ,CAAC,GAAG,CAAC,EAAE,MAAM,IAAI,CAAC;CAC3B;AAuED,wBAAsB,cAAc,CAAC,KAAK,EAAE,aAAa,GAAG,OAAO,CAAC,aAAa,CAAC,CAuCjF"}
1
+ {"version":3,"file":"report-builder.d.ts","sourceRoot":"","sources":["../../../src/services/mut/report-builder.ts"],"names":[],"mappings":"AAcA,OAAO,EAEL,KAAK,gBAAgB,EAErB,KAAK,cAAc,EACnB,KAAK,aAAa,EACnB,MAAM,YAAY,CAAC;AACpB,OAAO,EAA0C,KAAK,UAAU,EAAE,MAAM,iBAAiB,CAAC;AAE1F,MAAM,WAAW,aAAa;IAC5B,QAAQ,CAAC,QAAQ,EAAE,cAAc,CAAC;IAClC,QAAQ,CAAC,UAAU,EAAE,gBAAgB,CAAC;IACtC,QAAQ,CAAC,QAAQ,EAAE,MAAM,CAAC;IAC1B,QAAQ,CAAC,GAAG,EAAE,MAAM,CAAC;IACrB,QAAQ,CAAC,UAAU,CAAC,EAAE,UAAU,CAAC;IACjC,QAAQ,CAAC,GAAG,CAAC,EAAE,MAAM,IAAI,CAAC;CAC3B;AAuED,wBAAsB,cAAc,CAAC,KAAK,EAAE,aAAa,GAAG,OAAO,CAAC,aAAa,CAAC,CAuCjF"}
@@ -12,8 +12,8 @@
12
12
  import { createHash } from 'node:crypto';
13
13
  import { mkdir, rename, unlink, writeFile } from 'node:fs/promises';
14
14
  import { dirname } from 'node:path';
15
- import { MutReportSchema, } from './types.js';
16
- import { DEFAULT_THRESHOLDS, evaluateThresholds, } from './thresholds.js';
15
+ import { MutReportSchema } from './types.js';
16
+ import { DEFAULT_THRESHOLDS, evaluateThresholds } from './thresholds.js';
17
17
  function deriveFollowups(m, a, t) {
18
18
  const out = [];
19
19
  if (m.killRate < t.mutationKillRateMin) {
@@ -23,7 +23,7 @@ function deriveFollowups(m, a, t) {
23
23
  file: f.file,
24
24
  issue: 'low_kill_rate',
25
25
  severity: 'soft',
26
- suggestion: `Add tests for ${f.survived.length} survived mutants in ${f.file}`,
26
+ suggestion: `Add tests for ${f.survived.length} survived mutants in ${f.file}`
27
27
  });
28
28
  }
29
29
  }
@@ -36,7 +36,7 @@ function deriveFollowups(m, a, t) {
36
36
  file: exampleFile,
37
37
  issue: 'high_weak_assertions',
38
38
  severity: 'hard',
39
- suggestion: `Replace ${p.count} weak assertions of type "${p.pattern}" with concrete value checks`,
39
+ suggestion: `Replace ${p.count} weak assertions of type "${p.pattern}" with concrete value checks`
40
40
  });
41
41
  }
42
42
  }
@@ -89,9 +89,9 @@ export async function buildMutReport(input) {
89
89
  thresholds: {
90
90
  mutationKillRateMin: thresholds.mutationKillRateMin,
91
91
  weakAssertionRateMax: thresholds.weakAssertionRateMax,
92
- passed: evalResult.passed,
92
+ passed: evalResult.passed
93
93
  },
94
- followups,
94
+ followups
95
95
  };
96
96
  const sha256 = computeMutSig(partial);
97
97
  const final = { ...partial, sha256 };
@@ -1 +1 @@
1
- {"version":3,"file":"report-loader.d.ts","sourceRoot":"","sources":["../../../src/services/mut/report-loader.ts"],"names":[],"mappings":"AAoBA,OAAO,EAAmB,KAAK,aAAa,EAAE,MAAM,YAAY,CAAC;AAEjE,eAAO,MAAM,wBAAwB,wBAAwB,CAAC;AAE9D;;;;;;;;;;;;;GAaG;AACH,wBAAgB,aAAa,CAAC,SAAS,EAAE,MAAM,GAAG,MAAM,CAEvD;AAED;;;;;;;;;;;;GAYG;AACH,wBAAsB,aAAa,CAAC,SAAS,EAAE,MAAM,GAAG,OAAO,CAAC,aAAa,GAAG,IAAI,CAAC,CA8BpF"}
1
+ {"version":3,"file":"report-loader.d.ts","sourceRoot":"","sources":["../../../src/services/mut/report-loader.ts"],"names":[],"mappings":"AAoBA,OAAO,EAAmB,KAAK,aAAa,EAAE,MAAM,YAAY,CAAC;AAEjE,eAAO,MAAM,wBAAwB,wBAAwB,CAAC;AAE9D;;;;;;;;;;;;;GAaG;AACH,wBAAgB,aAAa,CAAC,SAAS,EAAE,MAAM,GAAG,MAAM,CAEvD;AAED;;;;;;;;;;;;GAYG;AACH,wBAAsB,aAAa,CAAC,SAAS,EAAE,MAAM,GAAG,OAAO,CAAC,aAAa,GAAG,IAAI,CAAC,CA+BpF"}
@@ -56,7 +56,8 @@ export async function loadMutReport(sessionId) {
56
56
  try {
57
57
  raw = await readFile(path, 'utf8');
58
58
  }
59
- catch { // TODO(g2): legacy silent catch — grace: 1 minor release (v2.14.0)
59
+ catch {
60
+ // TODO(g2): legacy silent catch — grace: 1 minor release (v2.14.0)
60
61
  // ENOENT or permission denied — both treated as "not run".
61
62
  return null;
62
63
  }