peaks-loop-mut 0.1.52 → 0.1.55

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 (34) hide show
  1. package/dist/index.d.ts +3 -3
  2. package/dist/index.d.ts.map +1 -1
  3. package/dist/index.js +3 -3
  4. package/dist/services/agent/ecc-materialize.d.ts +32 -0
  5. package/dist/services/agent/ecc-materialize.d.ts.map +1 -0
  6. package/dist/services/agent/ecc-materialize.js +76 -0
  7. package/dist/services/agent/ecc-materialized-readers.d.ts +49 -0
  8. package/dist/services/agent/ecc-materialized-readers.d.ts.map +1 -0
  9. package/dist/services/agent/ecc-materialized-readers.js +169 -0
  10. package/dist/services/agent/ecc-package-service.d.ts +38 -0
  11. package/dist/services/agent/ecc-package-service.d.ts.map +1 -0
  12. package/dist/services/agent/ecc-package-service.js +41 -0
  13. package/dist/services/agent/ecc-package-source.d.ts +97 -0
  14. package/dist/services/agent/ecc-package-source.d.ts.map +1 -0
  15. package/dist/services/agent/ecc-package-source.js +130 -0
  16. package/dist/services/mut/assert-scanner.d.ts.map +1 -1
  17. package/dist/services/mut/assert-scanner.js +8 -4
  18. package/dist/services/mut/index.d.ts +3 -3
  19. package/dist/services/mut/index.d.ts.map +1 -1
  20. package/dist/services/mut/index.js +2 -2
  21. package/dist/services/mut/mut-runner.js +4 -4
  22. package/dist/services/mut/production-stryker.d.ts.map +1 -1
  23. package/dist/services/mut/production-stryker.js +17 -13
  24. package/dist/services/mut/report-builder.d.ts.map +1 -1
  25. package/dist/services/mut/report-builder.js +6 -6
  26. package/dist/services/mut/report-loader.d.ts.map +1 -1
  27. package/dist/services/mut/report-loader.js +2 -1
  28. package/dist/services/mut/thresholds.js +4 -4
  29. package/dist/services/mut/types.d.ts.map +1 -1
  30. package/dist/services/mut/types.js +14 -10
  31. package/package.json +2 -1
  32. package/dist/services/agent/ecc-cache-service.d.ts +0 -172
  33. package/dist/services/agent/ecc-cache-service.d.ts.map +0 -1
  34. package/dist/services/agent/ecc-cache-service.js +0 -735
package/dist/index.d.ts CHANGED
@@ -3,13 +3,13 @@
3
3
  *
4
4
  * Re-exports the two slices this package owns:
5
5
  * 1. services/mut (mutation testing + assertion scanning + report)
6
- * 2. services/agent/ecc-cache-service (ECC tarball cache)
6
+ * 2. services/agent/ecc-package-service (ECC agents from the npm dependency)
7
7
  *
8
8
  * Main peaks-loop package consumes these via `workspace:*` deps:
9
9
  *
10
10
  * import { loadMutReport } from 'peaks-loop-mut';
11
- * import { cleanupStaleCache } from 'peaks-loop-mut/services/agent/ecc-cache-service';
11
+ * import { installEccAgents } from 'peaks-loop-mut/services/agent/ecc-package-service';
12
12
  */
13
13
  export * from './services/mut/index.js';
14
- export { setCacheDirPermissions, downloadToCache, readCacheManifest, listCachedAgents, readAgentSkill, cleanupStaleCache, resolveEccMaterializedDir, resolveEccMaterializedManifestPath, materializeEccAgents, readEccMaterializeManifest, listMaterializedAgents, hasMaterializedEccAgents, resolveMaterializedAgentName, readMaterializedAgent, ECC_REPO_OWNER, ECC_REPO_NAME, type CacheManifest, type DownloadResult, type EccMaterializeManifest, } from './services/agent/ecc-cache-service.js';
14
+ export { installEccAgents, materializeEccAgents, readEccMaterializeManifest, listMaterializedAgents, hasMaterializedEccAgents, resolveMaterializedAgentName, readMaterializedAgent, listEccAgents, ECC_PACKAGE_NAME, ECC_MATERIALIZE_VERSION, EccSourceError, isSafeAgentName, resolveEccAgentsDir, resolveEccMaterializedDir, resolveEccMaterializedManifestPath, resolveEccPackageRoot, type EccInstallResult, type EccMaterializeManifest, type EccSourceFailure } from './services/agent/ecc-package-service.js';
15
15
  //# sourceMappingURL=index.d.ts.map
@@ -1 +1 @@
1
- {"version":3,"file":"index.d.ts","sourceRoot":"","sources":["../src/index.ts"],"names":[],"mappings":"AAAA;;;;;;;;;;;GAWG;AAEH,cAAc,yBAAyB,CAAC;AAExC,OAAO,EACL,sBAAsB,EACtB,eAAe,EACf,iBAAiB,EACjB,gBAAgB,EAChB,cAAc,EACd,iBAAiB,EACjB,yBAAyB,EACzB,kCAAkC,EAClC,oBAAoB,EACpB,0BAA0B,EAC1B,sBAAsB,EACtB,wBAAwB,EACxB,4BAA4B,EAC5B,qBAAqB,EACrB,cAAc,EACd,aAAa,EACb,KAAK,aAAa,EAClB,KAAK,cAAc,EACnB,KAAK,sBAAsB,GAC5B,MAAM,uCAAuC,CAAC"}
1
+ {"version":3,"file":"index.d.ts","sourceRoot":"","sources":["../src/index.ts"],"names":[],"mappings":"AAAA;;;;;;;;;;;GAWG;AAEH,cAAc,yBAAyB,CAAC;AAExC,OAAO,EACL,gBAAgB,EAChB,oBAAoB,EACpB,0BAA0B,EAC1B,sBAAsB,EACtB,wBAAwB,EACxB,4BAA4B,EAC5B,qBAAqB,EACrB,aAAa,EACb,gBAAgB,EAChB,uBAAuB,EACvB,cAAc,EACd,eAAe,EACf,mBAAmB,EACnB,yBAAyB,EACzB,kCAAkC,EAClC,qBAAqB,EACrB,KAAK,gBAAgB,EACrB,KAAK,sBAAsB,EAC3B,KAAK,gBAAgB,EACtB,MAAM,yCAAyC,CAAC"}
package/dist/index.js CHANGED
@@ -3,12 +3,12 @@
3
3
  *
4
4
  * Re-exports the two slices this package owns:
5
5
  * 1. services/mut (mutation testing + assertion scanning + report)
6
- * 2. services/agent/ecc-cache-service (ECC tarball cache)
6
+ * 2. services/agent/ecc-package-service (ECC agents from the npm dependency)
7
7
  *
8
8
  * Main peaks-loop package consumes these via `workspace:*` deps:
9
9
  *
10
10
  * import { loadMutReport } from 'peaks-loop-mut';
11
- * import { cleanupStaleCache } from 'peaks-loop-mut/services/agent/ecc-cache-service';
11
+ * import { installEccAgents } from 'peaks-loop-mut/services/agent/ecc-package-service';
12
12
  */
13
13
  export * from './services/mut/index.js';
14
- export { setCacheDirPermissions, downloadToCache, readCacheManifest, listCachedAgents, readAgentSkill, cleanupStaleCache, resolveEccMaterializedDir, resolveEccMaterializedManifestPath, materializeEccAgents, readEccMaterializeManifest, listMaterializedAgents, hasMaterializedEccAgents, resolveMaterializedAgentName, readMaterializedAgent, ECC_REPO_OWNER, ECC_REPO_NAME, } from './services/agent/ecc-cache-service.js';
14
+ export { installEccAgents, materializeEccAgents, readEccMaterializeManifest, listMaterializedAgents, hasMaterializedEccAgents, resolveMaterializedAgentName, readMaterializedAgent, listEccAgents, ECC_PACKAGE_NAME, ECC_MATERIALIZE_VERSION, EccSourceError, isSafeAgentName, resolveEccAgentsDir, resolveEccMaterializedDir, resolveEccMaterializedManifestPath, resolveEccPackageRoot } from './services/agent/ecc-package-service.js';
@@ -0,0 +1,32 @@
1
+ /**
2
+ * The materialize write path — copy `ecc-universal`'s `agents/*.md` into the
3
+ * peaks-owned stable dir the LLM reads, and prune what upstream no longer
4
+ * ships.
5
+ *
6
+ * The source used to be `~/.peaks/cache/ecc-<sha>/agents/`, populated by a
7
+ * network download; it is now the installed package directory (see
8
+ * `ecc-package-source.ts` for why). The target, the per-file failure policy,
9
+ * and the prune step are unchanged: the dir is a read contract for the RD
10
+ * fan-out and for `~/.peaks/agents/ecc/<name>.md` in the skill docs, so a stale
11
+ * copy is a wrong answer rather than an untidy one.
12
+ */
13
+ import { type EccInstallResult } from './ecc-package-source.js';
14
+ /**
15
+ * Refresh the plugin-free copy from the package.
16
+ *
17
+ * `targetDir` is the ONLY write root (plus `mkdirSync` on it). Nothing in this
18
+ * function can reach `~/.claude/`.
19
+ *
20
+ * Fail-soft by policy, and the policy is per file: a single unreadable agent
21
+ * skips that agent and the rest land, because a partial review roster is useful
22
+ * while an exception here would stop `peaks ecc install` for a reason the user
23
+ * cannot act on. What is NOT swallowed is the absence of the package itself —
24
+ * `resolveEccAgentsDir` throws `EccSourceError` and the caller renders the
25
+ * reinstall instruction, because "ECC is not installed" pretending to be "ECC
26
+ * installed 0 agents" is the failure mode this whole layer was built to avoid.
27
+ */
28
+ export declare function materializeEccAgents({ sourceDir, targetDir }?: {
29
+ sourceDir?: string;
30
+ targetDir?: string;
31
+ }): EccInstallResult;
32
+ //# 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;;;;;;;;;;;GAWG;AAKH,OAAO,EAQL,KAAK,gBAAgB,EAEtB,MAAM,yBAAyB,CAAC;AAEjC;;;;;;;;;;;;;GAaG;AACH,wBAAgB,oBAAoB,CAAC,EACnC,SAAS,EACT,SAAS,EACV,GAAE;IAAE,SAAS,CAAC,EAAE,MAAM,CAAC;IAAC,SAAS,CAAC,EAAE,MAAM,CAAA;CAAO,GAAG,gBAAgB,CAiDpE"}
@@ -0,0 +1,76 @@
1
+ /**
2
+ * The materialize write path — copy `ecc-universal`'s `agents/*.md` into the
3
+ * peaks-owned stable dir the LLM reads, and prune what upstream no longer
4
+ * ships.
5
+ *
6
+ * The source used to be `~/.peaks/cache/ecc-<sha>/agents/`, populated by a
7
+ * network download; it is now the installed package directory (see
8
+ * `ecc-package-source.ts` for why). The target, the per-file failure policy,
9
+ * and the prune step are unchanged: the dir is a read contract for the RD
10
+ * fan-out and for `~/.peaks/agents/ecc/<name>.md` in the skill docs, so a stale
11
+ * copy is a wrong answer rather than an untidy one.
12
+ */
13
+ import { existsSync, mkdirSync, readdirSync, readFileSync, rmSync, writeFileSync } from 'node:fs';
14
+ import { join } from 'node:path';
15
+ import { ECC_MATERIALIZE_VERSION, isSafeAgentName, readEccPackageVersion, resolveEccAgentsDir, resolveEccMaterializedDir, resolveEccMaterializedManifestPath, setPeaksDirPermissions } from './ecc-package-source.js';
16
+ /**
17
+ * Refresh the plugin-free copy from the package.
18
+ *
19
+ * `targetDir` is the ONLY write root (plus `mkdirSync` on it). Nothing in this
20
+ * function can reach `~/.claude/`.
21
+ *
22
+ * Fail-soft by policy, and the policy is per file: a single unreadable agent
23
+ * skips that agent and the rest land, because a partial review roster is useful
24
+ * while an exception here would stop `peaks ecc install` for a reason the user
25
+ * cannot act on. What is NOT swallowed is the absence of the package itself —
26
+ * `resolveEccAgentsDir` throws `EccSourceError` and the caller renders the
27
+ * reinstall instruction, because "ECC is not installed" pretending to be "ECC
28
+ * installed 0 agents" is the failure mode this whole layer was built to avoid.
29
+ */
30
+ export function materializeEccAgents({ sourceDir, targetDir } = {}) {
31
+ const agentsDir = sourceDir ?? resolveEccAgentsDir();
32
+ const resolvedTarget = targetDir ?? resolveEccMaterializedDir();
33
+ const entries = readdirSync(agentsDir);
34
+ if (!existsSync(resolvedTarget))
35
+ mkdirSync(resolvedTarget, { recursive: true });
36
+ setPeaksDirPermissions(resolvedTarget);
37
+ const materialized = [];
38
+ for (const file of entries) {
39
+ if (!file.endsWith('.md'))
40
+ continue;
41
+ const name = file.replace(/\.md$/i, '');
42
+ if (!isSafeAgentName(name))
43
+ continue;
44
+ try {
45
+ const body = readFileSync(join(agentsDir, file), 'utf8');
46
+ writeFileSync(join(resolvedTarget, `${name}.md`), body);
47
+ materialized.push(name);
48
+ }
49
+ catch {
50
+ /* fail-soft per agent */
51
+ }
52
+ }
53
+ materialized.sort();
54
+ // Prune stale copies so `readMaterializedAgent` cannot serve an agent this
55
+ // package version no longer ships.
56
+ for (const existing of readdirSync(resolvedTarget)) {
57
+ if (!existing.endsWith('.md'))
58
+ continue;
59
+ const name = existing.replace(/\.md$/i, '');
60
+ if (!materialized.includes(name)) {
61
+ rmSync(join(resolvedTarget, existing), { force: true });
62
+ }
63
+ }
64
+ const manifest = {
65
+ version: ECC_MATERIALIZE_VERSION,
66
+ packageVersion: readEccPackageVersion(),
67
+ materializedAt: new Date().toISOString(),
68
+ agents: materialized
69
+ };
70
+ writeFileSync(resolveEccMaterializedManifestPath(resolvedTarget), JSON.stringify(manifest, null, 2));
71
+ return {
72
+ targetDir: resolvedTarget,
73
+ packageVersion: manifest.packageVersion,
74
+ materialized
75
+ };
76
+ }
@@ -0,0 +1,49 @@
1
+ /**
2
+ * Readers for the plugin-free materialized ECC agents — the path the LLM and
3
+ * Gate B3 open.
4
+ *
5
+ * `~/.peaks/agents/ecc/` is the contract: `peaks ecc ls|show|status` render it,
6
+ * `ecc-bridge.ts` resolves `code-reviewer` from it, and
7
+ * `skills/bee/peaks-rd/references/parallel-review-fanout.md` tells the RD loop to
8
+ * read `<resolved-name>.md` there by hand. It is written by
9
+ * `materializeEccAgents` from the installed `ecc-universal` package.
10
+ *
11
+ * The D-009 fallback lives here now (it used to sit with the cache manifest): an
12
+ * agent whose frontmatter will not parse is listed from its filename plus its
13
+ * first non-empty line (the line below the fence when a fence exists, the
14
+ * file's own first line when it does not), with ONE warning across the process,
15
+ * because a malformed descriptor upstream must not erase the roster the user can
16
+ * still dispatch.
17
+ */
18
+ import { type EccMaterializeManifest } from './ecc-package-source.js';
19
+ export declare function readEccMaterializeManifest(dirOverride?: string): EccMaterializeManifest | null;
20
+ export declare function listMaterializedAgents(dirOverride?: string): string[];
21
+ export declare function hasMaterializedEccAgents(dirOverride?: string): boolean;
22
+ /**
23
+ * Resolve the materialized ECC agent name for a logical role.
24
+ *
25
+ * Upstream ECC names its agents `<lang>-reviewer` (`code-reviewer.md`),
26
+ * NOT `code-review.md` — so no caller may hardcode a single filename.
27
+ * Resolution order (deterministic; `listMaterializedAgents` is sorted):
28
+ * 1. the caller's explicit candidates, in declared priority order
29
+ * (e.g. `['code-reviewer', 'code-review']` — real upstream name
30
+ * first, legacy/forward-compat second);
31
+ * 2. a fallback over the materialized list: the exact
32
+ * `<stem>-reviewer`, else the first `<stem>-*` whose name contains
33
+ * `reviewer`, where `stem` is the candidate minus a `-reviewer`
34
+ * suffix (`code-reviewer` -> `code`).
35
+ *
36
+ * Returns `null` when nothing matches — the caller degrades to inline
37
+ * review instead of dispatching a non-existent agent.
38
+ */
39
+ export declare function resolveMaterializedAgentName(candidates: readonly string[], dirOverride?: string): string | null;
40
+ export declare function readMaterializedAgent(name: string, dirOverride?: string): string | null;
41
+ /**
42
+ * List the materialized agents with their declared name and description — the
43
+ * `peaks ecc ls` row shape.
44
+ */
45
+ export declare function listEccAgents(dirOverride?: string): Array<{
46
+ name: string;
47
+ description: string;
48
+ }>;
49
+ //# 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;;;;;;;;;;;;;;;;GAgBG;AAMH,OAAO,EAIL,KAAK,sBAAsB,EAC5B,MAAM,yBAAyB,CAAC;AAEjC,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;AAsCD;;;GAGG;AACH,wBAAgB,aAAa,CAAC,WAAW,CAAC,EAAE,MAAM,GAAG,KAAK,CAAC;IAAE,IAAI,EAAE,MAAM,CAAC;IAAC,WAAW,EAAE,MAAM,CAAA;CAAE,CAAC,CAuBhG"}
@@ -0,0 +1,169 @@
1
+ /**
2
+ * Readers for the plugin-free materialized ECC agents — the path the LLM and
3
+ * Gate B3 open.
4
+ *
5
+ * `~/.peaks/agents/ecc/` is the contract: `peaks ecc ls|show|status` render it,
6
+ * `ecc-bridge.ts` resolves `code-reviewer` from it, and
7
+ * `skills/bee/peaks-rd/references/parallel-review-fanout.md` tells the RD loop to
8
+ * read `<resolved-name>.md` there by hand. It is written by
9
+ * `materializeEccAgents` from the installed `ecc-universal` package.
10
+ *
11
+ * The D-009 fallback lives here now (it used to sit with the cache manifest): an
12
+ * agent whose frontmatter will not parse is listed from its filename plus its
13
+ * first non-empty line (the line below the fence when a fence exists, the
14
+ * file's own first line when it does not), with ONE warning across the process,
15
+ * because a malformed descriptor upstream must not erase the roster the user can
16
+ * still dispatch.
17
+ */
18
+ import { existsSync, readdirSync, readFileSync } from 'node:fs';
19
+ import { join } from 'node:path';
20
+ import { parseFrontmatter } from '../../shared/frontmatter.js';
21
+ import { isSafeAgentName, resolveEccMaterializedDir, resolveEccMaterializedManifestPath } from './ecc-package-source.js';
22
+ export function readEccMaterializeManifest(dirOverride) {
23
+ const path = resolveEccMaterializedManifestPath(dirOverride);
24
+ if (!existsSync(path))
25
+ return null;
26
+ try {
27
+ const parsed = JSON.parse(readFileSync(path, 'utf8'));
28
+ if (typeof parsed.version === 'string' &&
29
+ typeof parsed.packageVersion === 'string' &&
30
+ typeof parsed.materializedAt === 'string' &&
31
+ Array.isArray(parsed.agents)) {
32
+ return parsed;
33
+ }
34
+ return null;
35
+ }
36
+ catch {
37
+ return null;
38
+ }
39
+ }
40
+ export function listMaterializedAgents(dirOverride) {
41
+ const dir = dirOverride ?? resolveEccMaterializedDir();
42
+ if (!existsSync(dir))
43
+ return [];
44
+ try {
45
+ return readdirSync(dir)
46
+ .filter((f) => f.endsWith('.md'))
47
+ .map((f) => f.replace(/\.md$/i, ''))
48
+ .filter((name) => isSafeAgentName(name))
49
+ .sort();
50
+ }
51
+ catch {
52
+ return [];
53
+ }
54
+ }
55
+ export function hasMaterializedEccAgents(dirOverride) {
56
+ return listMaterializedAgents(dirOverride).length > 0;
57
+ }
58
+ /**
59
+ * Resolve the materialized ECC agent name for a logical role.
60
+ *
61
+ * Upstream ECC names its agents `<lang>-reviewer` (`code-reviewer.md`),
62
+ * NOT `code-review.md` — so no caller may hardcode a single filename.
63
+ * Resolution order (deterministic; `listMaterializedAgents` is sorted):
64
+ * 1. the caller's explicit candidates, in declared priority order
65
+ * (e.g. `['code-reviewer', 'code-review']` — real upstream name
66
+ * first, legacy/forward-compat second);
67
+ * 2. a fallback over the materialized list: the exact
68
+ * `<stem>-reviewer`, else the first `<stem>-*` whose name contains
69
+ * `reviewer`, where `stem` is the candidate minus a `-reviewer`
70
+ * suffix (`code-reviewer` -> `code`).
71
+ *
72
+ * Returns `null` when nothing matches — the caller degrades to inline
73
+ * review instead of dispatching a non-existent agent.
74
+ */
75
+ export function resolveMaterializedAgentName(candidates, dirOverride) {
76
+ const available = listMaterializedAgents(dirOverride);
77
+ if (available.length === 0)
78
+ return null;
79
+ for (const candidate of candidates) {
80
+ if (available.includes(candidate))
81
+ return candidate;
82
+ }
83
+ for (const candidate of candidates) {
84
+ const stem = candidate.replace(/-reviewer$/, '');
85
+ const exact = available.find((name) => name === `${stem}-reviewer`);
86
+ if (exact !== undefined)
87
+ return exact;
88
+ const reviewerish = available.find((name) => name.startsWith(`${stem}-`) && name.includes('reviewer'));
89
+ if (reviewerish !== undefined)
90
+ return reviewerish;
91
+ }
92
+ return null;
93
+ }
94
+ export function readMaterializedAgent(name, dirOverride) {
95
+ if (!isSafeAgentName(name))
96
+ return null;
97
+ const file = join(dirOverride ?? resolveEccMaterializedDir(), `${name}.md`);
98
+ if (!existsSync(file))
99
+ return null;
100
+ try {
101
+ return readFileSync(file, 'utf8');
102
+ }
103
+ catch {
104
+ return null;
105
+ }
106
+ }
107
+ let warnedAboutFallback = false;
108
+ /** First non-empty line BELOW the frontmatter fence; with no fence at all, the
109
+ * first non-empty line, truncated for a listing. */
110
+ function firstBodyLine(dir, fileName) {
111
+ let description = '';
112
+ let seenClosing = false;
113
+ let inFrontmatter = false;
114
+ try {
115
+ const body = readFileSync(join(dir, fileName), 'utf8');
116
+ for (const raw of body.split(/\r?\n/)) {
117
+ const line = raw.trim();
118
+ if (line.length === 0)
119
+ continue;
120
+ if (!seenClosing) {
121
+ if (!inFrontmatter && line === '---') {
122
+ inFrontmatter = true;
123
+ continue;
124
+ }
125
+ if (inFrontmatter && line === '---') {
126
+ seenClosing = true;
127
+ continue;
128
+ }
129
+ // No fence in the file: this line IS prose, and it is the only
130
+ // description a reader can get from it.
131
+ description = line;
132
+ break;
133
+ }
134
+ description = line;
135
+ break;
136
+ }
137
+ }
138
+ catch {
139
+ /* best-effort */
140
+ }
141
+ return description.length > 80 ? `${description.slice(0, 77)}...` : description;
142
+ }
143
+ /**
144
+ * List the materialized agents with their declared name and description — the
145
+ * `peaks ecc ls` row shape.
146
+ */
147
+ export function listEccAgents(dirOverride) {
148
+ const dir = dirOverride ?? resolveEccMaterializedDir();
149
+ const out = [];
150
+ for (const file of listMaterializedAgents(dir).map((name) => `${name}.md`)) {
151
+ let meta;
152
+ try {
153
+ const fm = parseFrontmatter(readFileSync(join(dir, file), 'utf8'));
154
+ meta = { name: fm.name, description: fm.description };
155
+ }
156
+ catch {
157
+ // D-009: name from filename, description from the first body line.
158
+ const base = file.replace(/\.md$/i, '');
159
+ meta = { name: base, description: firstBodyLine(dir, file) };
160
+ if (!warnedAboutFallback) {
161
+ warnedAboutFallback = true;
162
+ process.stderr.write(`warning: ECC agent "${base}" has malformed frontmatter; ` +
163
+ 'falling back to filename + first body line\n');
164
+ }
165
+ }
166
+ out.push(meta);
167
+ }
168
+ return out;
169
+ }
@@ -0,0 +1,38 @@
1
+ /**
2
+ * `peaks ecc` service — ECC agent definitions, read from the
3
+ * `ecc-universal` npm dependency.
4
+ *
5
+ * Facade for the split modules beside it. It keeps one job: hand the CLI and the
6
+ * dispatch layer a stable view of the agents, and state plainly when ECC is not
7
+ * present. There is no download, no cache manifest, no sha-keyed directory and no
8
+ * TTL sweep in this design — a dependency is already on disk. Where each concern
9
+ * went:
10
+ *
11
+ * - `ecc-fetch.ts` (GitHub release JSON + codeload tarball) — deleted. Its
12
+ * premise, "`affaan-m/ECC` is not on npm", was false.
13
+ * - `ecc-archive-safety.ts` (tar entry allowlist, symlink/`..`/device refusal)
14
+ * — deleted. Nothing is unpacked from an archive anymore; the filename
15
+ * whitelist that guarded the write target survives as `isSafeAgentName`.
16
+ * - `ecc-cache-manifest.ts` (`ecc-installed.json`, the active-sha pointer) —
17
+ * deleted; the only manifest left is the materialize manifest, which records
18
+ * the package version.
19
+ * - `ecc-cache-cleanup.ts` and the retention leg that called it (7-day sweep of
20
+ * `~/.peaks/cache/ecc-<sha>/`) — deleted. There is no cache to expire.
21
+ *
22
+ * No subprocess is spawned and no network request is made by any code path here.
23
+ */
24
+ import { type EccInstallResult } from './ecc-package-source.js';
25
+ /**
26
+ * Land the plugin-free copy of the bundled ECC agents.
27
+ *
28
+ * Idempotent: it re-copies from the package and rewrites the manifest, so
29
+ * `peaks ecc install` after a peaks-loop upgrade picks up the new agent set and
30
+ * prunes what the new version dropped. Throws `EccSourceError` when the
31
+ * dependency is missing — the caller renders that as a reinstall instruction,
32
+ * which is the only action a user can actually take.
33
+ */
34
+ export declare function installEccAgents(): EccInstallResult;
35
+ export { ECC_PACKAGE_NAME, ECC_MATERIALIZE_VERSION, EccSourceError, isSafeAgentName, readEccPackageVersion, resolveEccAgentsDir, resolveEccMaterializedDir, resolveEccMaterializedManifestPath, resolveEccPackageRoot, type EccInstallResult, type EccMaterializeManifest, type EccSourceFailure } from './ecc-package-source.js';
36
+ export { materializeEccAgents } from './ecc-materialize.js';
37
+ export { readEccMaterializeManifest, listMaterializedAgents, hasMaterializedEccAgents, resolveMaterializedAgentName, readMaterializedAgent, listEccAgents } from './ecc-materialized-readers.js';
38
+ //# sourceMappingURL=ecc-package-service.d.ts.map
@@ -0,0 +1 @@
1
+ {"version":3,"file":"ecc-package-service.d.ts","sourceRoot":"","sources":["../../../src/services/agent/ecc-package-service.ts"],"names":[],"mappings":"AAAA;;;;;;;;;;;;;;;;;;;;;;GAsBG;AAEH,OAAO,EAAuB,KAAK,gBAAgB,EAAE,MAAM,yBAAyB,CAAC;AAGrF;;;;;;;;GAQG;AACH,wBAAgB,gBAAgB,IAAI,gBAAgB,CAGnD;AAED,OAAO,EACL,gBAAgB,EAChB,uBAAuB,EACvB,cAAc,EACd,eAAe,EACf,qBAAqB,EACrB,mBAAmB,EACnB,yBAAyB,EACzB,kCAAkC,EAClC,qBAAqB,EACrB,KAAK,gBAAgB,EACrB,KAAK,sBAAsB,EAC3B,KAAK,gBAAgB,EACtB,MAAM,yBAAyB,CAAC;AACjC,OAAO,EAAE,oBAAoB,EAAE,MAAM,sBAAsB,CAAC;AAC5D,OAAO,EACL,0BAA0B,EAC1B,sBAAsB,EACtB,wBAAwB,EACxB,4BAA4B,EAC5B,qBAAqB,EACrB,aAAa,EACd,MAAM,+BAA+B,CAAC"}
@@ -0,0 +1,41 @@
1
+ /**
2
+ * `peaks ecc` service — ECC agent definitions, read from the
3
+ * `ecc-universal` npm dependency.
4
+ *
5
+ * Facade for the split modules beside it. It keeps one job: hand the CLI and the
6
+ * dispatch layer a stable view of the agents, and state plainly when ECC is not
7
+ * present. There is no download, no cache manifest, no sha-keyed directory and no
8
+ * TTL sweep in this design — a dependency is already on disk. Where each concern
9
+ * went:
10
+ *
11
+ * - `ecc-fetch.ts` (GitHub release JSON + codeload tarball) — deleted. Its
12
+ * premise, "`affaan-m/ECC` is not on npm", was false.
13
+ * - `ecc-archive-safety.ts` (tar entry allowlist, symlink/`..`/device refusal)
14
+ * — deleted. Nothing is unpacked from an archive anymore; the filename
15
+ * whitelist that guarded the write target survives as `isSafeAgentName`.
16
+ * - `ecc-cache-manifest.ts` (`ecc-installed.json`, the active-sha pointer) —
17
+ * deleted; the only manifest left is the materialize manifest, which records
18
+ * the package version.
19
+ * - `ecc-cache-cleanup.ts` and the retention leg that called it (7-day sweep of
20
+ * `~/.peaks/cache/ecc-<sha>/`) — deleted. There is no cache to expire.
21
+ *
22
+ * No subprocess is spawned and no network request is made by any code path here.
23
+ */
24
+ import { resolveEccAgentsDir } from './ecc-package-source.js';
25
+ import { materializeEccAgents } from './ecc-materialize.js';
26
+ /**
27
+ * Land the plugin-free copy of the bundled ECC agents.
28
+ *
29
+ * Idempotent: it re-copies from the package and rewrites the manifest, so
30
+ * `peaks ecc install` after a peaks-loop upgrade picks up the new agent set and
31
+ * prunes what the new version dropped. Throws `EccSourceError` when the
32
+ * dependency is missing — the caller renders that as a reinstall instruction,
33
+ * which is the only action a user can actually take.
34
+ */
35
+ export function installEccAgents() {
36
+ resolveEccAgentsDir();
37
+ return materializeEccAgents();
38
+ }
39
+ export { ECC_PACKAGE_NAME, ECC_MATERIALIZE_VERSION, EccSourceError, isSafeAgentName, readEccPackageVersion, resolveEccAgentsDir, resolveEccMaterializedDir, resolveEccMaterializedManifestPath, resolveEccPackageRoot } from './ecc-package-source.js';
40
+ export { materializeEccAgents } from './ecc-materialize.js';
41
+ export { readEccMaterializeManifest, listMaterializedAgents, hasMaterializedEccAgents, resolveMaterializedAgentName, readMaterializedAgent, listEccAgents } from './ecc-materialized-readers.js';
@@ -0,0 +1,97 @@
1
+ /**
2
+ * Where ECC's agent definitions come from: the installed `ecc-universal`
3
+ * npm package.
4
+ *
5
+ * THIS REPLACED A NETWORK ACQUISITION LAYER. Until 2026-10-04 peaks-loop
6
+ * downloaded ECC at runtime — `api.github.com/repos/affaan-m/ECC/releases/latest`
7
+ * → `codeload` tarball → selective extract into `~/.peaks/cache/ecc-<sha>/`
8
+ * — guarded by a tarball-safety module, a cache manifest, a sha-directory
9
+ * cleanup sweep and a log-retention leg that swept it. Every one of those
10
+ * existed to make up for a premise that turned out to be false: three places in
11
+ * this repository asserted that `affaan-m/ECC` was NOT on npm
12
+ * (`src/services/audit/static-service.ts`, `CHANGELOG.md:1630`,
13
+ * `src/services/code-review/ecc-bridge.ts`), and `ecc-universal` IS that
14
+ * repository — `npm view ecc-universal repository.url` answers
15
+ * `git+https://github.com/affaan-m/ECC.git`. A dependency ships its own files,
16
+ * so there is nothing left to fetch, verify, extract, cache or sweep.
17
+ *
18
+ * WHAT REMAINS AND WHY: `ecc-universal` is a normal dependency of
19
+ * `peaks-loop-mut`, its `agents/*.md` are read here, and the plugin-free copy
20
+ * under `~/.peaks/agents/ecc/` (see `ecc-materialize.ts`) is kept because that
21
+ * path is what the RD fan-out and Gate B3 read, what the skill docs tell the LLM
22
+ * to open, and it survives a peaks-loop upgrade that changes the version-pinned
23
+ * path below.
24
+ *
25
+ * The resolved path is version-PINNED under pnpm
26
+ * (`.../.pnpm/ecc-universal@2.2.3/node_modules/ecc-universal`), which is exactly
27
+ * why it is not a stable read target for a human opening a path by hand — hence
28
+ * materialize, and hence this module never hands out its own directory except to
29
+ * the copy step.
30
+ */
31
+ export declare const ECC_PACKAGE_NAME = "ecc-universal";
32
+ export declare const ECC_AGENTS_SUBDIR = "agents";
33
+ /** Manifest shape for the plugin-free copy. */
34
+ export declare const ECC_MATERIALIZE_VERSION = "2";
35
+ /**
36
+ * Why ECC cannot be read. `not-installed` means the dependency is missing from
37
+ * the installation (a broken or partial `npm i`); `no-agents-dir` means the
38
+ * package is there but does not ship what this layer reads. Both are stated as
39
+ * distinct because the remedy differs: reinstall peaks-loop versus pin a
40
+ * different ECC version.
41
+ */
42
+ export type EccSourceFailure = 'not-installed' | 'no-agents-dir';
43
+ export declare class EccSourceError extends Error {
44
+ readonly failure: EccSourceFailure;
45
+ constructor(failure: EccSourceFailure, detail: string);
46
+ }
47
+ /**
48
+ * The package root, resolved through Node's own algorithm rather than a
49
+ * hand-built `node_modules` path.
50
+ *
51
+ * `require.resolve('ecc-universal/package.json')` is the join point: it honors
52
+ * the pnpm store layout, an npm flat install, a global install of peaks-loop,
53
+ * and a linked workspace alike. A hardcoded `../../node_modules/ecc-universal`
54
+ * would resolve in exactly one of those and fail in the others with an error
55
+ * that looks like "ECC is not installed".
56
+ */
57
+ export declare function resolveEccPackageRoot(): string;
58
+ /** The `version` the package declares — the identity a materialized copy records. */
59
+ export declare function readEccPackageVersion(root?: string): string;
60
+ /** `<package>/agents` — the flat `*.md` definitions the LLM consumes. */
61
+ export declare function resolveEccAgentsDir(root?: string): string;
62
+ /**
63
+ * Plugin-free materialize target: `~/.peaks/agents/ecc/`.
64
+ *
65
+ * Deliberately NOT under `~/.claude/` — peaks-loop must never write into the
66
+ * user's Claude Code tree (user direction 2026-09-09). The LLM reads
67
+ * `<target>/<agent-name>.md` directly when the ECC Claude Code plugin is
68
+ * absent, then dispatches a generic sub-agent with that body.
69
+ */
70
+ export declare function resolveEccMaterializedDir(): string;
71
+ export declare function resolveEccMaterializedManifestPath(dirOverride?: string): string;
72
+ /**
73
+ * Agent names are used to build filenames, so the whitelist is the escape
74
+ * check. Kept as a positive allowlist rather than a denylist: anything outside
75
+ * `^[a-z][a-z0-9-]*$` never reaches a path, whatever upstream adds later.
76
+ */
77
+ export declare function isSafeAgentName(name: string): boolean;
78
+ /**
79
+ * Best-effort chmod 0o700 on POSIX; no-op on Windows (NTFS uses ACLs, not POSIX
80
+ * mode bits). Errors are swallowed with WARN so a permissions failure never
81
+ * blocks the CLI — the files are public agent definitions, not secrets.
82
+ */
83
+ export declare function setPeaksDirPermissions(dir: string): void;
84
+ export type EccMaterializeManifest = {
85
+ version: string;
86
+ /** The `ecc-universal` version the copy came from. This field replaced
87
+ * `sha`, which named a git commit no longer involved. */
88
+ packageVersion: string;
89
+ materializedAt: string;
90
+ agents: string[];
91
+ };
92
+ export type EccInstallResult = {
93
+ targetDir: string;
94
+ packageVersion: string;
95
+ materialized: string[];
96
+ };
97
+ //# sourceMappingURL=ecc-package-source.d.ts.map
@@ -0,0 +1 @@
1
+ {"version":3,"file":"ecc-package-source.d.ts","sourceRoot":"","sources":["../../../src/services/agent/ecc-package-source.ts"],"names":[],"mappings":"AAAA;;;;;;;;;;;;;;;;;;;;;;;;;;;;;GA6BG;AAOH,eAAO,MAAM,gBAAgB,kBAAkB,CAAC;AAChD,eAAO,MAAM,iBAAiB,WAAW,CAAC;AAE1C,+CAA+C;AAC/C,eAAO,MAAM,uBAAuB,MAAM,CAAC;AAE3C;;;;;;GAMG;AACH,MAAM,MAAM,gBAAgB,GAAG,eAAe,GAAG,eAAe,CAAC;AAEjE,qBAAa,cAAe,SAAQ,KAAK;IACvC,QAAQ,CAAC,OAAO,EAAE,gBAAgB,CAAC;gBAEvB,OAAO,EAAE,gBAAgB,EAAE,MAAM,EAAE,MAAM;CAKtD;AAED;;;;;;;;;GASG;AACH,wBAAgB,qBAAqB,IAAI,MAAM,CAa9C;AAED,qFAAqF;AACrF,wBAAgB,qBAAqB,CAAC,IAAI,GAAE,MAAgC,GAAG,MAAM,CASpF;AAED,yEAAyE;AACzE,wBAAgB,mBAAmB,CAAC,IAAI,GAAE,MAAgC,GAAG,MAAM,CASlF;AAED;;;;;;;GAOG;AACH,wBAAgB,yBAAyB,IAAI,MAAM,CAElD;AAED,wBAAgB,kCAAkC,CAAC,WAAW,CAAC,EAAE,MAAM,GAAG,MAAM,CAE/E;AAED;;;;GAIG;AACH,wBAAgB,eAAe,CAAC,IAAI,EAAE,MAAM,GAAG,OAAO,CAErD;AAUD;;;;GAIG;AACH,wBAAgB,sBAAsB,CAAC,GAAG,EAAE,MAAM,GAAG,IAAI,CAOxD;AAED,MAAM,MAAM,sBAAsB,GAAG;IACnC,OAAO,EAAE,MAAM,CAAC;IAChB;8DAC0D;IAC1D,cAAc,EAAE,MAAM,CAAC;IACvB,cAAc,EAAE,MAAM,CAAC;IACvB,MAAM,EAAE,MAAM,EAAE,CAAC;CAClB,CAAC;AAEF,MAAM,MAAM,gBAAgB,GAAG;IAC7B,SAAS,EAAE,MAAM,CAAC;IAClB,cAAc,EAAE,MAAM,CAAC;IACvB,YAAY,EAAE,MAAM,EAAE,CAAC;CACxB,CAAC"}