peaks-loop 4.0.51 → 4.0.52

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 (61) hide show
  1. package/CHANGELOG.md +20 -0
  2. package/README-en.md +1 -1
  3. package/README.md +1 -1
  4. package/dist/cli/commands/baseline-commands.js +11 -1
  5. package/dist/cli/commands/codegraph-command-runtime.d.ts +28 -0
  6. package/dist/cli/commands/codegraph-command-runtime.js +72 -0
  7. package/dist/cli/commands/codegraph-commands.d.ts +2 -11
  8. package/dist/cli/commands/codegraph-commands.js +173 -228
  9. package/dist/cli/commands/codegraph-status-command.d.ts +22 -0
  10. package/dist/cli/commands/codegraph-status-command.js +299 -0
  11. package/dist/cli/commands/core/memory-command.js +6 -2
  12. package/dist/cli/commands/job-commands.js +121 -30
  13. package/dist/cli/commands/project-commands.js +13 -3
  14. package/dist/cli/commands/request-commands.js +19 -8
  15. package/dist/cli/commands/slice-commands.js +2 -2
  16. package/dist/services/artifacts/artifact-prerequisites.js +23 -1
  17. package/dist/services/codegraph/codegraph-autorefresh.d.ts +16 -0
  18. package/dist/services/codegraph/codegraph-autorefresh.js +51 -5
  19. package/dist/services/codegraph/codegraph-config-repair-writer.d.ts +88 -0
  20. package/dist/services/codegraph/codegraph-config-repair-writer.js +322 -0
  21. package/dist/services/codegraph/codegraph-exclude-integrity.d.ts +20 -2
  22. package/dist/services/codegraph/codegraph-exclude-integrity.js +24 -3
  23. package/dist/services/codegraph/codegraph-exclude-reconciler.d.ts +23 -2
  24. package/dist/services/codegraph/codegraph-exclude-reconciler.js +123 -12
  25. package/dist/services/codegraph/codegraph-exclude-repair.d.ts +109 -55
  26. package/dist/services/codegraph/codegraph-exclude-repair.js +249 -195
  27. package/dist/services/codegraph/codegraph-include-reconciler.d.ts +10 -0
  28. package/dist/services/codegraph/codegraph-include-reconciler.js +160 -0
  29. package/dist/services/codegraph/codegraph-index-integrity.d.ts +268 -0
  30. package/dist/services/codegraph/codegraph-index-integrity.js +471 -0
  31. package/dist/services/codegraph/codegraph-service.d.ts +54 -0
  32. package/dist/services/codegraph/codegraph-service.js +84 -1
  33. package/dist/services/doctor/doctor-service/checks/codegraph-exclude-integrity.js +19 -4
  34. package/dist/services/doctor/doctor-service/checks/codegraph-index-integrity.d.ts +54 -0
  35. package/dist/services/doctor/doctor-service/checks/codegraph-index-integrity.js +151 -0
  36. package/dist/services/doctor/doctor-service/checks/l3-orphan-sessions.js +10 -10
  37. package/dist/services/doctor/doctor-service/plugin-registry.js +2 -0
  38. package/dist/services/doctor/doctor-service/types.d.ts +25 -0
  39. package/dist/services/memory/project-memory-service/index/kind-dispatch.js +48 -13
  40. package/dist/services/memory/project-memory-service/index.d.ts +5 -3
  41. package/dist/services/memory/project-memory-service/index.js +2 -2
  42. package/dist/services/memory/project-memory-service/parsers/frontmatter.d.ts +15 -1
  43. package/dist/services/memory/project-memory-service/parsers/frontmatter.js +34 -6
  44. package/dist/services/memory/project-memory-service/parsers/markdown-pure.d.ts +27 -1
  45. package/dist/services/memory/project-memory-service/parsers/markdown-pure.js +92 -7
  46. package/dist/services/memory/project-memory-service/types.d.ts +86 -0
  47. package/dist/services/slice/slice-check-types.d.ts +1 -1
  48. package/dist/services/workspace/runtime-layout.d.ts +91 -0
  49. package/dist/services/workspace/runtime-layout.js +148 -0
  50. package/dist/services/workspace/workspace-claude-settings-materializer.js +14 -0
  51. package/package.json +6 -6
  52. package/scripts/clean-dist.mjs +15 -3
  53. package/scripts/sync-version.mjs +26 -4
  54. package/skills/bee/peaks-prd/SKILL.md +1 -1
  55. package/skills/bee/peaks-qa/references/qa-skill-presence.md +1 -1
  56. package/skills/bee/peaks-rd/references/skill-presence-and-title.md +1 -1
  57. package/skills/bee/peaks-sc/SKILL.md +1 -1
  58. package/skills/bee/peaks-txt/SKILL.md +3 -3
  59. package/skills/peaks-code/SKILL.md +1 -1
  60. package/skills/peaks-code/references/project-memory-loading.md +19 -1
  61. package/skills/peaks-code/references/step-11-memory-sediment.md +1 -1
@@ -1,68 +1,79 @@
1
1
  import { type CodegraphProcessRunner } from './codegraph-service.js';
2
- /** Suffix of the byte-exact pre-repair copy kept next to the config. */
3
- export declare const CODEGRAPH_CONFIG_BACKUP_SUFFIX = ".bak";
4
- export type CodegraphExcludeRepairPlan = {
5
- /** True when at least one rule would actually be dropped. */
6
- readonly changed: boolean;
7
- /** The `exclude` array after the removal. */
8
- readonly exclude: readonly string[];
9
- /** Rules actually present in `exclude` and dropped, in config order. */
10
- readonly removedRules: readonly string[];
11
- };
12
- /**
13
- * Pure: given the current `exclude` list and the rules to drop, return
14
- * the new list. No fs, no clock, no serialization.
15
- *
16
- * A rule named in `rulesToRemove` but absent from `exclude` is NOT
17
- * invented — the result is a subset of the input, so a caller can
18
- * never add a rule by accident. Removing an already-absent rule is a
19
- * no-op, which is what makes the whole repair idempotent: feeding the
20
- * repaired list back in yields `changed: false`.
21
- */
22
- export declare function repairCodegraphExclude(input: {
23
- readonly exclude: readonly string[];
24
- readonly rulesToRemove: readonly string[];
25
- }): CodegraphExcludeRepairPlan;
26
- export type CodegraphExcludeRepairOutcome = {
27
- readonly applied: false;
28
- readonly reason: 'no-rules-to-remove';
29
- readonly removedRules: readonly string[];
30
- } | {
31
- readonly applied: true;
32
- readonly configPath: string;
33
- readonly backupPath: string;
34
- readonly removedRules: readonly string[];
35
- readonly excludeCountBefore: number;
36
- readonly excludeCountAfter: number;
37
- };
38
- /**
39
- * Apply the repair to `<projectRoot>/.codegraph/config.json`.
40
- *
41
- * No-op (and no write, no mtime change, no backup) when
42
- * `rulesToRemove` is empty. Otherwise: back up the original bytes to
43
- * `config.json.bak`, then rewrite the file with `exclude` reduced by
44
- * exactly the rules that were both requested and present.
45
- *
46
- * Throws only on real fs/parse failures — the caller decides whether
47
- * that is fatal (`repair-exclude` → non-zero exit) or a surfaced
48
- * warning (`init` → keep going, the init itself already succeeded).
49
- */
50
- export declare function applyCodegraphExcludeRepair(projectRoot: string, rulesToRemove: readonly string[]): CodegraphExcludeRepairOutcome;
2
+ import { applyCodegraphConfigRepair, CODEGRAPH_CONFIG_BACKUP_SUFFIX, repairCodegraphExclude, repairCodegraphInclude, type CodegraphConfigRepairOutcome, type CodegraphConfigRepairPlan, type CodegraphExcludeRepairPlan } from './codegraph-config-repair-writer.js';
3
+ export { applyCodegraphConfigRepair, CODEGRAPH_CONFIG_BACKUP_SUFFIX, repairCodegraphExclude, repairCodegraphInclude };
4
+ export type { CodegraphConfigRepairOutcome, CodegraphConfigRepairPlan, CodegraphExcludeRepairPlan };
51
5
  export type CodegraphExcludeRepairReport = {
52
6
  /** True when the config was actually rewritten. */
53
7
  readonly applied: boolean;
54
8
  /** Rules dropped from `exclude`. */
55
9
  readonly rulesRemoved: readonly string[];
10
+ /**
11
+ * Patterns appended to `include` (slice-002). Always a subset of the
12
+ * include reconciler's candidates that were not already admitted.
13
+ */
14
+ readonly includePatternsAdded: readonly string[];
56
15
  /** Distinct tracked source files the dropped rules had been hiding. */
57
16
  readonly filesRecovered: number;
58
- /** Tracked files the config's `include` filter admits at all. */
17
+ /**
18
+ * Distinct tracked source files the WIDENED `include` list newly admits —
19
+ * the INCLUDE axis' counterpart of `filesRecovered`, and a DIFFERENT
20
+ * number on purpose.
21
+ *
22
+ * `filesRecovered` counts the exclude axis only. Before this field
23
+ * existed, `appliedRepairNote` printed `filesRecovered` inside a sentence
24
+ * whose subject was both axes, so the measured run that added 5 include
25
+ * patterns for 31 tracked `.mjs`/`.cjs` files reported "removed 0 exclude
26
+ * rule(s), recovering 0 tracked source file(s)" — a true statement about
27
+ * one axis read as a verdict on both (defect A1 of
28
+ * `2026-09-17-codegraph-msg-and-refresh`).
29
+ *
30
+ * It is a measured DELTA, not a re-report of an absolute count:
31
+ * `includeAdmittedAfter` minus the same admission measurement taken over
32
+ * the ON-DISK include list. Reporting `includeAdmittedAfter` itself as
33
+ * "recovered" would be the tautology slice-002 removed from the
34
+ * coverage ratio (an absolute count says nothing about what changed).
35
+ *
36
+ * Zero by construction when the include plan did not change — the
37
+ * normalized list IS the on-disk list then — which is also why the extra
38
+ * admission pass is gated on `includePlan.changed`: the no-op path (every
39
+ * automatic seam, every re-run) pays nothing for it, unlike the pass
40
+ * slice-002 removed (that one ran on ALL seams, including no-ops).
41
+ */
42
+ readonly includeFilesRecovered: number;
43
+ /**
44
+ * Tracked files the normalized `include` list admits — the NUMERATOR of
45
+ * the coverage ratio. Identical to
46
+ * `reconcileCodegraphExclude`'s `trackedSourceCount` for the normalized
47
+ * list, so it costs no second filtering pass.
48
+ */
49
+ readonly includeAdmittedAfter: number;
50
+ /**
51
+ * Tracked files upstream's extractor would ingest (any supported
52
+ * extension) — the DENOMINATOR, and the same quantity the index axis
53
+ * reports under this same field name (`CodegraphIndexIntegrityReport`).
54
+ *
55
+ * It is measured independently of `includeAdmittedAfter` (an extension
56
+ * decision per tracked file, not a glob match), so the two CAN differ and
57
+ * the ratio can report a shortfall. The field used to be fed from the
58
+ * reconciler's admitted count, i.e. the numerator again, which made every
59
+ * "N of N" the consumers printed a tautology.
60
+ */
59
61
  readonly trackedSourceCount: number;
60
- /** Absolute path of the rewritten config (empty when nothing was written). */
62
+ /**
63
+ * Absolute path of the rewritten config. Empty when nothing was written
64
+ * AND the reads failed (there is no config to name).
65
+ */
61
66
  readonly configPath: string;
62
67
  /** Byte-exact rollback copy (null when nothing was written). */
63
68
  readonly backupPath: string | null;
64
69
  /** True when the post-repair `codegraph index` finished successfully. */
65
70
  readonly reindexed: boolean;
71
+ /**
72
+ * True when the follow-up index was run with upstream's `--force`, i.e.
73
+ * as a full rebuild that drops rows for files that no longer exist. An
74
+ * incremental index cannot do that — see `CodegraphExcludeRepairOptions`.
75
+ */
76
+ readonly forcedRebuild: boolean;
66
77
  /**
67
78
  * Non-null when the step could not run to completion (no git repo,
68
79
  * missing config, malformed config, upstream index failure, …).
@@ -80,13 +91,56 @@ export type CodegraphExcludeRepairOptions = {
80
91
  * step: the pre-dispatch preflight and the post-slice autorefresh
81
92
  * both call `init` → `index`, and an index is expensive enough
82
93
  * (5-30 s on this repo) that a fresh init must not pay for it twice.
94
+ *
95
+ * When `'force'`, run `codegraph index --force` instead: upstream's
96
+ * `--force` is `clear()` + full re-index, and it is the ONLY documented
97
+ * way to drop rows for files deleted in an earlier commit. Verified in
98
+ * the installed upstream source (0.7.10):
99
+ *
100
+ * - `dist/bin/codegraph.js` → `index --force` calls `cg.clear()` then
101
+ * `cg.indexAll()`;
102
+ * - `dist/db/queries.js` `clear()` deletes unresolved_refs, edges,
103
+ * nodes and files;
104
+ * - plain `indexAll()` (`dist/extraction/index.js`) scans and upserts
105
+ * every file but never removes a row, so an incremental index keeps
106
+ * rows for paths that are gone;
107
+ * - `codegraph sync` DOES delete them, but only for the deletions
108
+ * `git status --porcelain` reports in the WORKING TREE. Measured on
109
+ * this repo: all four dead rows are committed deletions, invisible to
110
+ * `git status`, so `sync` would purge none of them.
111
+ *
112
+ * Cost note. The PARSE half of the old claim here was exactly true and
113
+ * is kept: plain `indexAll()` already re-reads and re-parses EVERY file
114
+ * (its only skip is `maxFileSize`). The PRICE half was wrong and is
115
+ * corrected to the perf audit's measurements, because it is the sentence
116
+ * a future reader would quote: `storeExtractionResult`
117
+ * (`dist/extraction/index.js`) hash-skips all WRITES for unchanged files
118
+ * in a plain `index`, so `--force` additionally pays a full re-insert of
119
+ * every node and edge after `clear()`. Executed with the real binary on a
120
+ * 2,100-file fixture, paired 5 runs: plain median 3,810 ms vs forced
121
+ * 5,400 ms = +1,590 ms (+42 %), positive 5/5; on a copy of this repo's db,
122
+ * `clear()` alone is 414/462/537 ms while clear+reinsert is 2.7-6.2 s.
123
+ * "Forced" is a real cost, not a rounding error.
124
+ *
125
+ * That does NOT change the policy: the reason the automatic seams do not
126
+ * force is policy, not cost. The advisory-by-default decision (user option
127
+ * C) exists so that upgrading peaks-loop cannot change a downstream
128
+ * project's cost profile, and purging dead rows is the caller's explicit
129
+ * request instead.
83
130
  */
84
- readonly reindex?: boolean;
131
+ readonly reindex?: boolean | 'force';
85
132
  };
86
133
  /**
87
- * Reconcile `projectRoot`'s exclude list, drop the rules that block
88
- * tracked source files, and rebuild the index so the recovered files
89
- * actually land in it.
134
+ * Reconcile `projectRoot`'s config against its tracked files — normalize
135
+ * `include`, then drop the `exclude` rules that block tracked source files
136
+ * — and rebuild the index so the recovered files actually land in it.
137
+ *
138
+ * ORDER IS LOAD-BEARING. `exclude` is reconciled against the NORMALIZED
139
+ * include list, never the on-disk one: an `exclude` rule that blocks only a
140
+ * file `include` drops reconciles clean today and starts biting the moment
141
+ * `include` is widened, so reconciling before normalizing would let this
142
+ * run report success over a config it had just made worse. See the module
143
+ * header.
90
144
  *
91
145
  * This is the ONE shared "after upstream init" self-heal: the CLI's
92
146
  * fresh `peaks codegraph init`, the pre-dispatch preflight and the