peaks-loop-mut 0.1.53 → 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 +24 -27
  5. package/dist/services/agent/ecc-materialize.d.ts.map +1 -1
  6. package/dist/services/agent/ecc-materialize.js +43 -77
  7. package/dist/services/agent/ecc-materialized-readers.d.ts +23 -5
  8. package/dist/services/agent/ecc-materialized-readers.d.ts.map +1 -1
  9. package/dist/services/agent/ecc-materialized-readers.js +80 -18
  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/package.json +2 -1
  17. package/dist/services/agent/ecc-archive-safety.d.ts +0 -25
  18. package/dist/services/agent/ecc-archive-safety.d.ts.map +0 -1
  19. package/dist/services/agent/ecc-archive-safety.js +0 -131
  20. package/dist/services/agent/ecc-cache-cleanup.d.ts +0 -26
  21. package/dist/services/agent/ecc-cache-cleanup.d.ts.map +0 -1
  22. package/dist/services/agent/ecc-cache-cleanup.js +0 -90
  23. package/dist/services/agent/ecc-cache-config.d.ts +0 -66
  24. package/dist/services/agent/ecc-cache-config.d.ts.map +0 -1
  25. package/dist/services/agent/ecc-cache-config.js +0 -72
  26. package/dist/services/agent/ecc-cache-manifest.d.ts +0 -22
  27. package/dist/services/agent/ecc-cache-manifest.d.ts.map +0 -1
  28. package/dist/services/agent/ecc-cache-manifest.js +0 -136
  29. package/dist/services/agent/ecc-cache-service.d.ts +0 -65
  30. package/dist/services/agent/ecc-cache-service.d.ts.map +0 -1
  31. package/dist/services/agent/ecc-cache-service.js +0 -118
  32. package/dist/services/agent/ecc-fetch.d.ts +0 -31
  33. package/dist/services/agent/ecc-fetch.d.ts.map +0 -1
  34. package/dist/services/agent/ecc-fetch.js +0 -95
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,EAC5B,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';
@@ -1,35 +1,32 @@
1
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.
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
5
  *
6
- * Split verbatim out of `ecc-cache-service.ts` (wave 11 slice A,
7
- * 2026-10-03); no behaviour changed.
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.
8
12
  */
13
+ import { type EccInstallResult } from './ecc-package-source.js';
9
14
  /**
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.
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/`.
22
19
  *
23
- * `targetDir` is the ONLY write root (plus `mkdirSync` on it). Nothing in
24
- * this function can reach `~/.claude/`.
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.
25
27
  */
26
- export declare function materializeEccAgents({ cacheDir, targetDir }?: {
27
- cacheDir?: string;
28
+ export declare function materializeEccAgents({ sourceDir, targetDir }?: {
29
+ sourceDir?: string;
28
30
  targetDir?: string;
29
- }): {
30
- targetDir: string;
31
- sha: string | null;
32
- materialized: string[];
33
- };
34
- export { materializeBestEffort };
31
+ }): EccInstallResult;
35
32
  //# sourceMappingURL=ecc-materialize.d.ts.map
@@ -1 +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"}
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"}
@@ -1,65 +1,39 @@
1
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.
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
5
  *
6
- * Split verbatim out of `ecc-cache-service.ts` (wave 11 slice A,
7
- * 2026-10-03); no behaviour changed.
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.
8
12
  */
9
13
  import { existsSync, mkdirSync, readdirSync, readFileSync, rmSync, writeFileSync } from 'node:fs';
10
14
  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';
15
+ import { ECC_MATERIALIZE_VERSION, isSafeAgentName, readEccPackageVersion, resolveEccAgentsDir, resolveEccMaterializedDir, resolveEccMaterializedManifestPath, setPeaksDirPermissions } from './ecc-package-source.js';
14
16
  /**
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.
17
+ * Refresh the plugin-free copy from the package.
34
18
  *
35
- * `targetDir` is the ONLY write root (plus `mkdirSync` on it). Nothing in
36
- * this function can reach `~/.claude/`.
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.
37
29
  */
38
- export function materializeEccAgents({ cacheDir, targetDir } = {}) {
30
+ export function materializeEccAgents({ sourceDir, targetDir } = {}) {
31
+ const agentsDir = sourceDir ?? resolveEccAgentsDir();
39
32
  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
- }
33
+ const entries = readdirSync(agentsDir);
34
+ if (!existsSync(resolvedTarget))
35
+ mkdirSync(resolvedTarget, { recursive: true });
36
+ setPeaksDirPermissions(resolvedTarget);
63
37
  const materialized = [];
64
38
  for (const file of entries) {
65
39
  if (!file.endsWith('.md'))
@@ -77,34 +51,26 @@ export function materializeEccAgents({ cacheDir, targetDir } = {}) {
77
51
  }
78
52
  }
79
53
  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
- }
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 });
90
62
  }
91
63
  }
92
- catch {
93
- /* fail-soft */
94
- }
95
- const nextManifest = {
64
+ const manifest = {
96
65
  version: ECC_MATERIALIZE_VERSION,
97
- sha: manifest.sha,
66
+ packageVersion: readEccPackageVersion(),
98
67
  materializedAt: new Date().toISOString(),
99
68
  agents: materialized
100
69
  };
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 };
70
+ writeFileSync(resolveEccMaterializedManifestPath(resolvedTarget), JSON.stringify(manifest, null, 2));
71
+ return {
72
+ targetDir: resolvedTarget,
73
+ packageVersion: manifest.packageVersion,
74
+ materialized
75
+ };
108
76
  }
109
- // Cross-module glue: private inside ecc-cache-service.ts before the split.
110
- export { materializeBestEffort };
@@ -1,11 +1,21 @@
1
1
  /**
2
- * Readers for the plugin-free materialized ECC agents.
2
+ * Readers for the plugin-free materialized ECC agents — the path the LLM and
3
+ * Gate B3 open.
3
4
  *
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.
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.
7
17
  */
8
- import { type EccMaterializeManifest } from './ecc-cache-config.js';
18
+ import { type EccMaterializeManifest } from './ecc-package-source.js';
9
19
  export declare function readEccMaterializeManifest(dirOverride?: string): EccMaterializeManifest | null;
10
20
  export declare function listMaterializedAgents(dirOverride?: string): string[];
11
21
  export declare function hasMaterializedEccAgents(dirOverride?: string): boolean;
@@ -28,4 +38,12 @@ export declare function hasMaterializedEccAgents(dirOverride?: string): boolean;
28
38
  */
29
39
  export declare function resolveMaterializedAgentName(candidates: readonly string[], dirOverride?: string): string | null;
30
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
+ }>;
31
49
  //# sourceMappingURL=ecc-materialized-readers.d.ts.map
@@ -1 +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"}
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"}
@@ -1,25 +1,24 @@
1
1
  /**
2
- * Readers for the plugin-free materialized ECC agents.
2
+ * Readers for the plugin-free materialized ECC agents — the path the LLM and
3
+ * Gate B3 open.
3
4
  *
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.
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.
7
17
  */
8
18
  import { existsSync, readdirSync, readFileSync } from 'node:fs';
9
19
  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
- // ---------------------------------------------------------------------
20
+ import { parseFrontmatter } from '../../shared/frontmatter.js';
21
+ import { isSafeAgentName, resolveEccMaterializedDir, resolveEccMaterializedManifestPath } from './ecc-package-source.js';
23
22
  export function readEccMaterializeManifest(dirOverride) {
24
23
  const path = resolveEccMaterializedManifestPath(dirOverride);
25
24
  if (!existsSync(path))
@@ -27,7 +26,7 @@ export function readEccMaterializeManifest(dirOverride) {
27
26
  try {
28
27
  const parsed = JSON.parse(readFileSync(path, 'utf8'));
29
28
  if (typeof parsed.version === 'string' &&
30
- typeof parsed.sha === 'string' &&
29
+ typeof parsed.packageVersion === 'string' &&
31
30
  typeof parsed.materializedAt === 'string' &&
32
31
  Array.isArray(parsed.agents)) {
33
32
  return parsed;
@@ -105,3 +104,66 @@ export function readMaterializedAgent(name, dirOverride) {
105
104
  return null;
106
105
  }
107
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"}