peaks-loop 4.1.17 → 4.1.19

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 (205) hide show
  1. package/.claude-plugin/marketplace.json +2 -2
  2. package/CHANGELOG.md +269 -0
  3. package/README-en.md +6 -0
  4. package/README.md +5 -0
  5. package/contracts/test-style-contract.md +14 -5
  6. package/dist/cli/commands/audit-red-lines-runners.js +6 -1
  7. package/dist/cli/commands/best-practice-scan-collision.d.ts +42 -0
  8. package/dist/cli/commands/best-practice-scan-collision.js +115 -0
  9. package/dist/cli/commands/best-practice-scan-command.d.ts +5 -0
  10. package/dist/cli/commands/best-practice-scan-command.js +9 -18
  11. package/dist/cli/commands/best-practice-scan-helpers.d.ts +12 -6
  12. package/dist/cli/commands/best-practice-scan-helpers.js +37 -17
  13. package/dist/cli/commands/code-auto-compact-command.js +71 -40
  14. package/dist/cli/commands/code-auto-compact-deferral.d.ts +34 -0
  15. package/dist/cli/commands/code-auto-compact-deferral.js +59 -0
  16. package/dist/cli/commands/code-gate-command.d.ts +4 -4
  17. package/dist/cli/commands/code-gate-command.js +4 -4
  18. package/dist/cli/commands/core/skill-generated-config-notice.d.ts +5 -0
  19. package/dist/cli/commands/core/skill-generated-config-notice.js +42 -8
  20. package/dist/cli/commands/core/skill-presence-commands.js +42 -74
  21. package/dist/cli/commands/core/skill-presence-set-command.d.ts +11 -0
  22. package/dist/cli/commands/core/skill-presence-set-command.js +175 -0
  23. package/dist/cli/commands/core/skill-registry-commands.js +32 -0
  24. package/dist/cli/commands/core/skill-store-report.d.ts +8 -0
  25. package/dist/cli/commands/core/skill-store-report.js +79 -0
  26. package/dist/cli/commands/core/standards-init-command.js +44 -8
  27. package/dist/cli/commands/core/standards-migrate-command.js +5 -4
  28. package/dist/cli/commands/dispatch-dag-runners.d.ts +1 -0
  29. package/dist/cli/commands/dispatch-dag-runners.js +11 -1
  30. package/dist/cli/commands/dispatch-detached-branch.js +19 -1
  31. package/dist/cli/commands/dispatch-prompt-composition.js +7 -2
  32. package/dist/cli/commands/dispatch-scratch-path-block.d.ts +73 -0
  33. package/dist/cli/commands/dispatch-scratch-path-block.js +131 -0
  34. package/dist/cli/commands/hooks-commands.js +36 -7
  35. package/dist/cli/commands/hooks-uninstall-command.js +5 -5
  36. package/dist/cli/commands/mut-commands-helpers.d.ts +72 -5
  37. package/dist/cli/commands/mut-commands-helpers.js +197 -4
  38. package/dist/cli/commands/mut-commands.d.ts +9 -1
  39. package/dist/cli/commands/mut-commands.js +82 -154
  40. package/dist/cli/commands/preferences-commands.js +27 -2
  41. package/dist/cli/commands/scan-scope-helpers.js +2 -2
  42. package/dist/services/24h-mode/auto-engage.d.ts +11 -3
  43. package/dist/services/24h-mode/auto-engage.js +14 -6
  44. package/dist/services/artifacts/artifact-templates.js +10 -0
  45. package/dist/services/artifacts/backcompat-acceptance.d.ts +8 -1
  46. package/dist/services/artifacts/backcompat-acceptance.js +8 -7
  47. package/dist/services/artifacts/rd-transition-gates.d.ts +32 -5
  48. package/dist/services/artifacts/rd-transition-gates.js +96 -19
  49. package/dist/services/artifacts/request-artifact-service.js +6 -6
  50. package/dist/services/audit/enforcers/lint-output-style.js +14 -2
  51. package/dist/services/audit/enforcers/root-scratch-artifacts.d.ts +46 -0
  52. package/dist/services/audit/enforcers/root-scratch-artifacts.js +97 -0
  53. package/dist/services/audit/static-service.js +4 -4
  54. package/dist/services/code/auto-compact-history.d.ts +6 -1
  55. package/dist/services/code/auto-compact-history.js +6 -1
  56. package/dist/services/code/auto-compact-modes.d.ts +60 -14
  57. package/dist/services/code/auto-compact-modes.js +75 -20
  58. package/dist/services/code/auto-compact-orchestrator.js +7 -5
  59. package/dist/services/code/auto-compact-profile.d.ts +23 -0
  60. package/dist/services/code/auto-compact-profile.js +51 -0
  61. package/dist/services/code/auto-compact-run-types.d.ts +8 -4
  62. package/dist/services/compact-history/compact-history-service.d.ts +6 -1
  63. package/dist/services/compact-history/compact-history-service.js +5 -1
  64. package/dist/services/context/auto-compact-types.d.ts +7 -5
  65. package/dist/services/dispatch/dispatch-ledger-reader.d.ts +13 -0
  66. package/dist/services/dispatch/dispatch-ledger-reader.js +164 -0
  67. package/dist/services/doctor/doctor-service/checks/canonical-store-version.d.ts +57 -0
  68. package/dist/services/doctor/doctor-service/checks/canonical-store-version.js +190 -0
  69. package/dist/services/doctor/doctor-service/checks/l3-runtime-root-census.d.ts +37 -0
  70. package/dist/services/doctor/doctor-service/checks/l3-runtime-root-census.js +100 -0
  71. package/dist/services/doctor/doctor-service/checks/skill-reference-parity.d.ts +11 -3
  72. package/dist/services/doctor/doctor-service/checks/skill-reference-parity.js +48 -29
  73. package/dist/services/doctor/doctor-service/plugin-registry.js +4 -0
  74. package/dist/services/doctor/doctor-service/types.d.ts +12 -0
  75. package/dist/services/hooks/hook-payload-cwd.d.ts +11 -4
  76. package/dist/services/hooks/hook-payload-cwd.js +11 -4
  77. package/dist/services/hooks/pre-tool-code-gate.d.ts +4 -4
  78. package/dist/services/hooks/pre-tool-code-gate.js +4 -4
  79. package/dist/services/hooks/presence-marker-detector.d.ts +3 -0
  80. package/dist/services/hooks/presence-marker-detector.js +21 -19
  81. package/dist/services/ide/adapters/claude-code-adapter.js +6 -8
  82. package/dist/services/ide/adapters/codex-adapter.js +23 -7
  83. package/dist/services/ide/adapters/cursor-adapter.js +23 -7
  84. package/dist/services/mode/mode-status-service.d.ts +26 -27
  85. package/dist/services/mode/mode-status-service.js +36 -60
  86. package/dist/services/preferences/preferences-types.d.ts +30 -0
  87. package/dist/services/preferences/preferences-types.js +13 -0
  88. package/dist/services/scan/acceptance-coverage-service.d.ts +14 -11
  89. package/dist/services/scan/acceptance-coverage-service.js +157 -52
  90. package/dist/services/scan/rid-change-claims.d.ts +15 -0
  91. package/dist/services/scan/rid-change-claims.js +116 -0
  92. package/dist/services/session/getSessionDir.d.ts +13 -0
  93. package/dist/services/session/getSessionDir.js +7 -1
  94. package/dist/services/skills/hooks-settings-types.d.ts +17 -21
  95. package/dist/services/skills/presence-caller-id.d.ts +51 -0
  96. package/dist/services/skills/presence-caller-id.js +43 -0
  97. package/dist/services/skills/presence-gate.d.ts +65 -0
  98. package/dist/services/skills/presence-gate.js +113 -0
  99. package/dist/services/skills/presence-lease-resolver.d.ts +63 -0
  100. package/dist/services/skills/presence-lease-resolver.js +114 -0
  101. package/dist/services/skills/presence-lease-selection.d.ts +91 -0
  102. package/dist/services/skills/presence-lease-selection.js +135 -0
  103. package/dist/services/skills/presence-lease-service.d.ts +3 -11
  104. package/dist/services/skills/presence-lease-service.js +34 -87
  105. package/dist/services/skills/presence-lease-store.d.ts +33 -0
  106. package/dist/services/skills/presence-lease-store.js +94 -0
  107. package/dist/services/skills/presence-lease-types.d.ts +31 -0
  108. package/dist/services/skills/presence-lease-types.js +27 -0
  109. package/dist/services/skills/presence-role.d.ts +35 -0
  110. package/dist/services/skills/presence-role.js +72 -0
  111. package/dist/services/skills/skill-presence-service.d.ts +39 -9
  112. package/dist/services/skills/skill-presence-service.js +143 -174
  113. package/dist/services/skills/skill-presence-write.d.ts +60 -0
  114. package/dist/services/skills/skill-presence-write.js +74 -0
  115. package/dist/services/skills/skill-statusline-service.js +7 -7
  116. package/dist/services/skills/sync-service-support.d.ts +27 -0
  117. package/dist/services/skills/sync-service.js +1 -0
  118. package/dist/services/standards/ide-aware-standards-service.d.ts +35 -23
  119. package/dist/services/standards/ide-aware-standards-service.js +45 -20
  120. package/dist/services/standards/migrate-claude-rules-service.d.ts +6 -0
  121. package/dist/services/standards/migrate-claude-rules-service.js +18 -0
  122. package/dist/services/standards/migrate-service.d.ts +1 -1
  123. package/dist/services/standards/migrate-service.js +27 -7
  124. package/dist/services/standards/project-scripts.d.ts +25 -0
  125. package/dist/services/standards/project-scripts.js +116 -0
  126. package/dist/services/standards/project-standards-service.d.ts +23 -15
  127. package/dist/services/standards/project-standards-service.js +176 -243
  128. package/dist/services/standards/standards-constitution.d.ts +89 -0
  129. package/dist/services/standards/standards-constitution.js +199 -0
  130. package/dist/services/standards/standards-files.d.ts +37 -0
  131. package/dist/services/standards/standards-files.js +138 -0
  132. package/dist/services/standards/standards-pointer.d.ts +73 -0
  133. package/dist/services/standards/standards-pointer.js +98 -0
  134. package/dist/services/standards/standards-render-agents.d.ts +34 -0
  135. package/dist/services/standards/standards-render-agents.js +149 -0
  136. package/dist/services/standards/standards-render-common.d.ts +38 -1
  137. package/dist/services/standards/standards-render-common.js +44 -7
  138. package/dist/services/standards/standards-render.d.ts +1 -3
  139. package/dist/services/standards/standards-render.js +6 -87
  140. package/dist/services/workflow/workflow-graph-ensure.d.ts +77 -0
  141. package/dist/services/workflow/workflow-graph-ensure.js +97 -0
  142. package/dist/services/workflow/workflow-inflight-probe.d.ts +68 -31
  143. package/dist/services/workflow/workflow-inflight-probe.js +163 -75
  144. package/dist/services/workflow/workflow-presence-lifecycle.js +21 -6
  145. package/dist/services/workspace/generated-artifacts-content.d.ts +46 -0
  146. package/dist/services/workspace/generated-artifacts-content.js +167 -0
  147. package/dist/services/workspace/generated-artifacts-stamp.d.ts +36 -13
  148. package/dist/services/workspace/generated-artifacts-stamp.js +37 -15
  149. package/dist/services/workspace/runtime-layout.d.ts +64 -0
  150. package/dist/services/workspace/runtime-layout.js +62 -0
  151. package/output-styles/peaks-skill-swarm.md +18 -2
  152. package/package.json +10 -9
  153. package/schemas/doctor-report.schema.json +1 -1
  154. package/scripts/canonical-store-fs.mjs +112 -0
  155. package/scripts/canonical-store-link.mjs +13 -22
  156. package/scripts/canonical-store-marker.mjs +241 -0
  157. package/scripts/canonical-store.mjs +119 -141
  158. package/scripts/install-skills-bundles.mjs +56 -13
  159. package/scripts/install-skills-fs.mjs +73 -0
  160. package/scripts/install-skills-output-styles.mjs +8 -2
  161. package/scripts/install-skills-report.mjs +19 -0
  162. package/scripts/install-skills.mjs +9 -0
  163. package/skills/bee/peaks-perf-audit/SKILL.md +3 -1
  164. package/skills/bee/peaks-prd/SKILL.md +5 -3
  165. package/skills/bee/peaks-qa/SKILL.md +4 -2
  166. package/skills/bee/peaks-qa/references/qa-skill-presence.md +1 -1
  167. package/skills/bee/peaks-qa/references/qa-standards-preflight.md +3 -1
  168. package/skills/bee/peaks-qa/references/qa-sub-agent-dispatch.md +2 -2
  169. package/skills/bee/peaks-rd/SKILL.md +4 -2
  170. package/skills/bee/peaks-rd/references/artifact-and-standards-output.md +1 -1
  171. package/skills/bee/peaks-rd/references/rd-runbook.md +11 -2
  172. package/skills/bee/peaks-rd/references/rd-standards-preflight.md +3 -1
  173. package/skills/bee/peaks-rd/references/rd-sub-agent-dispatch.md +24 -5
  174. package/skills/bee/peaks-rd/references/rd-transition-gates.md +49 -5
  175. package/skills/bee/peaks-rd/references/skill-presence-and-title.md +1 -1
  176. package/skills/bee/peaks-reviewer/SKILL.md +3 -1
  177. package/skills/bee/peaks-sc/SKILL.md +4 -2
  178. package/skills/bee/peaks-security-audit/SKILL.md +3 -1
  179. package/skills/bee/peaks-txt/SKILL.md +5 -3
  180. package/skills/bee/peaks-ui/SKILL.md +6 -4
  181. package/skills/peaks-audit/SKILL.md +3 -1
  182. package/skills/peaks-code/SKILL.md +4 -2
  183. package/skills/peaks-code/references/a2a-artifact-mapping.md +3 -3
  184. package/skills/peaks-code/references/completion-handoff.md +1 -1
  185. package/skills/peaks-code/references/local-artifact-workspace.md +10 -11
  186. package/skills/peaks-code/references/micro-cycle.md +2 -2
  187. package/skills/peaks-code/references/mode-selection-with-stale-presence.md +3 -3
  188. package/skills/peaks-code/references/runbook.md +4 -4
  189. package/skills/peaks-code/references/skill-presence-and-title.md +4 -2
  190. package/skills/peaks-code/references/standards-preflight.md +7 -6
  191. package/skills/peaks-code/references/sub-agent-dispatch.md +1 -1
  192. package/skills/peaks-code/references/swarm-dispatch-contract.md +5 -5
  193. package/skills/peaks-code/references/workflow-gates-and-types.md +37 -11
  194. package/skills/peaks-content/SKILL.md +3 -1
  195. package/skills/peaks-doctor/SKILL.md +3 -1
  196. package/skills/peaks-final-review/SKILL.md +3 -1
  197. package/skills/peaks-ide/SKILL.md +3 -1
  198. package/skills/peaks-issue-fix-orchestrator/SKILL.md +5 -3
  199. package/skills/peaks-race-code/SKILL.md +9 -4
  200. package/skills/peaks-resume/SKILL.md +3 -1
  201. package/skills/peaks-slice-decompose/SKILL.md +3 -1
  202. package/skills/peaks-solo/SKILL.md +3 -1
  203. package/skills/peaks-sop/SKILL.md +4 -2
  204. package/skills/peaks-status/SKILL.md +3 -1
  205. package/skills/peaks-test/SKILL.md +3 -1
@@ -1,5 +1,5 @@
1
- import { getSessionId } from '../session/session-manager.js';
2
- import { listPresenceLeases } from '../skills/presence-lease-service.js';
1
+ import { resolvePresenceLease } from '../skills/presence-lease-resolver.js';
2
+ import { readPresenceGate } from '../skills/presence-gate.js';
3
3
  /**
4
4
  *
5
5
  * Background: the consumer-facing CLAUDE.md template (rendered by
@@ -43,25 +43,23 @@ export const PRESENCE_MARKER_WARNING = [
43
43
  ];
44
44
  /**
45
45
  * Slice 4.0.11 statusline-sid-scoped-lease C: read the canonical
46
- * sid-scoped lease projection. Returns the in-flight lease with the
47
- * most recent `lastHeartbeat`, or null when no leases exist for the
48
- * bound session. Picked the most-recent-in-flight lease (mirrors the
49
- * statusline `callerId === null` back-compat path).
46
+ * sid-scoped lease projection.
47
+ *
48
+ * Slice 4.0.17 (presence cross-session): the read goes through
49
+ * the SAME resolver the `peaks skill presence` CLI uses — the lease that
50
+ * is eligible across EVERY session tree, not just the bound one. The
51
+ * two readers must not disagree: the CLI says "peaks-code is running"
52
+ * and the hook says "no presence" is not a state a user can act on.
53
+ *
54
+ * Returns the freshest eligible lease (freshest `lastHeartbeat` wins,
55
+ * with a total tie-break), or null when no tree holds one.
50
56
  */
51
57
  function readCanonicalLease(projectRoot) {
52
- const sessionId = getSessionId(projectRoot);
53
- if (sessionId === null)
54
- return null;
55
- const leases = listPresenceLeases(projectRoot, sessionId);
56
- const inFlight = leases.filter((l) => l.status === 'running' || l.status === 'preparing');
57
- if (inFlight.length === 0)
58
- return null;
59
- // Sort by lastHeartbeat desc, return the freshest.
60
- inFlight.sort((a, b) => b.lastHeartbeat.localeCompare(a.lastHeartbeat));
61
- const freshest = inFlight[0];
62
- if (freshest === undefined)
58
+ const selection = resolvePresenceLease(projectRoot);
59
+ if (selection === null)
63
60
  return null;
64
- return { skill: freshest.skill };
61
+ const gate = readPresenceGate(selection.lease.gate);
62
+ return { skill: selection.lease.skill, ...(gate !== undefined ? { gate } : {}) };
65
63
  }
66
64
  /**
67
65
  * Slice 4.0.11 statusline-sid-scoped-lease C: the deprecated
@@ -100,6 +98,7 @@ export function detectPresenceMarker(input) {
100
98
  if (presence === null) {
101
99
  return { active: false, markerFound: false };
102
100
  }
101
+ const gateField = presence.gate !== undefined ? { gate: presence.gate } : {};
103
102
  const brokenGraph = tryDetectBrokenGraph(project);
104
103
  const markerFound = messageHasMarker(message);
105
104
  if (markerFound) {
@@ -107,16 +106,18 @@ export function detectPresenceMarker(input) {
107
106
  return {
108
107
  active: true,
109
108
  skill: presence.skill,
109
+ ...gateField,
110
110
  markerFound: true,
111
111
  warning: `Peaks presence active but graph is broken (${brokenGraph}); run \`peaks workspace reconcile\` to repair.`
112
112
  };
113
113
  }
114
- return { active: true, skill: presence.skill, markerFound: true };
114
+ return { active: true, skill: presence.skill, ...gateField, markerFound: true };
115
115
  }
116
116
  if (brokenGraph !== null) {
117
117
  return {
118
118
  active: true,
119
119
  skill: presence.skill,
120
+ ...gateField,
120
121
  markerFound: false,
121
122
  warning: `Peaks presence active but graph is broken (${brokenGraph}); run \`peaks workspace reconcile\` to repair.`
122
123
  };
@@ -124,6 +125,7 @@ export function detectPresenceMarker(input) {
124
125
  return {
125
126
  active: true,
126
127
  skill: presence.skill,
128
+ ...gateField,
127
129
  markerFound: false,
128
130
  warning: PRESENCE_MARKER_WARNING[0]
129
131
  };
@@ -530,20 +530,18 @@ export const CLAUDE_CODE_ADAPTER = {
530
530
  resolveTranscriptPath: (outerSessionId) => resolveClaudeTranscriptPath(outerSessionId)
531
531
  },
532
532
  // Slice #011: standards profile. Claude Code reads its constitution at
533
- // CLAUDE.md + module-level rules under .claude/rules/**. The values mirror
534
- // the hardcoded paths in `src/services/standards/project-standards-service.ts`
535
- // (line 147 = '.claude', line 417/421 = 'CLAUDE.md' + '.claude/rules/...')
536
- // and the postinstall target in `scripts/install-skills.mjs` (line 427 =
537
- // '~/.claude/skills'). Filling the profile here makes the dispatch layer
538
- // route to the SAME paths, so byte-stability on `peaks standards init` for
539
- // Claude Code projects is preserved.
533
+ // CLAUDE.md and its module-level rules under .claude/rules/**. The
534
+ // `rootFile` value is what the standards writer branches on: a
535
+ // `CLAUDE.md` root means the writer emits the shared cross-tool body
536
+ // (AGENTS.md) AND a CLAUDE.md pointer that imports it, because Claude
537
+ // Code reads CLAUDE.md, not AGENTS.md, unless it is configured to.
540
538
  standardsProfile: {
541
539
  rootFile: 'CLAUDE.md',
542
540
  rulesDir: '.claude/rules',
543
541
  rulesFileGlob: '**/*.md',
544
542
  autoLoaded: true,
545
543
  format: 'markdown',
546
- migrationHint: 'Standards live at CLAUDE.md + .claude/rules/** for Claude Code.'
544
+ migrationHint: 'Standards live at AGENTS.md (body) + CLAUDE.md (pointer) for Claude Code.'
547
545
  },
548
546
  // Slice #011: skill install profile. The postinstall script symlinks
549
547
  // bundled skills to `~/.claude/skills` and writes output-styles to
@@ -102,12 +102,28 @@ export const CODEX_ADAPTER = {
102
102
  const err = new Error('PEAKS_CALLER_NOT_RESOLVED: Codex vendor signal reserved');
103
103
  err.code = 'PEAKS_CALLER_NOT_RESOLVED';
104
104
  throw err;
105
+ },
106
+ // Standards profile: Codex CLI reads `AGENTS.md` natively — it is one of
107
+ // the tools the AGENTS.md standard (OpenAI's AGENTS.md, now under the
108
+ // Linux Foundation's Agentic AI Foundation) is adopted by. So the shared
109
+ // cross-tool body IS Codex's project-instructions file, and no CLAUDE.md
110
+ // pointer is needed next to it.
111
+ //
112
+ // `rulesDir` stays `null`: where Codex looks for MODULE-level rules is
113
+ // still unverified (see slice #013+ for the real-install dogfood), so the
114
+ // profile claims only the root file.
115
+ standardsProfile: {
116
+ rootFile: 'AGENTS.md',
117
+ rulesDir: null,
118
+ rulesFileGlob: '**/*.md',
119
+ autoLoaded: true,
120
+ format: 'markdown',
121
+ migrationHint: 'Codex reads AGENTS.md directly; no CLAUDE.md pointer is written.'
105
122
  }
106
- // Standards: UNVERIFIED — see slice #013+ (Codex real-install dogfood for
107
- // the `standardsProfile` and `skillInstall` fields). Until then, `peaks
108
- // standards init` on a Codex-detected project falls back to the Claude
109
- // Code path (CLAUDE.md + .claude/rules/**) with a stderr warning, and the
110
- // postinstall script writes skills + output-styles to the legacy
111
- // `~/.claude/{skills,output-styles}` paths with a stderr warning. Users
112
- // who want Codex-specific paths must move the files manually.
123
+ // Standards: the ROOT file is verified above (AGENTS.md); the `rulesDir`
124
+ // and `skillInstall` fields remain UNVERIFIED pending slice #013+
125
+ // (Codex real-install dogfood). Until then the postinstall script writes
126
+ // skills + output-styles to the legacy `~/.claude/{skills,output-styles}`
127
+ // paths with a stderr warning. Users who want Codex-specific paths must
128
+ // move the files manually.
113
129
  };
@@ -71,13 +71,29 @@ export const CURSOR_ADAPTER = {
71
71
  // that can host peaks statusline output, so opt in to the capability.
72
72
  statusline: true
73
73
  },
74
- // Standards: UNVERIFIED — see slice #012+ (Cursor real-install dogfood for
75
- // the `standardsProfile` and `skillInstall` fields). Until then, `peaks
76
- // standards init` on a Cursor-detected project falls back to the Claude
77
- // Code path (CLAUDE.md + .claude/rules/**) with a stderr warning, and the
78
- // postinstall script writes skills + output-styles to the legacy
79
- // `~/.claude/{skills,output-styles}` paths with a stderr warning. Users
80
- // who want Cursor-specific paths must move the files manually.
74
+ // Standards profile: Cursor reads `AGENTS.md` natively — it is one of the
75
+ // tools the AGENTS.md standard (OpenAI's AGENTS.md, now under the Linux
76
+ // Foundation's Agentic AI Foundation) is adopted by. So the shared
77
+ // cross-tool body IS Cursor's project-instructions file, and no CLAUDE.md
78
+ // pointer is needed next to it.
79
+ //
80
+ // `rulesDir` stays `null`: where Cursor looks for MODULE-level rules is
81
+ // still unverified (see slice #012+ for the real-install dogfood), so the
82
+ // profile claims only the root file.
83
+ standardsProfile: {
84
+ rootFile: 'AGENTS.md',
85
+ rulesDir: null,
86
+ rulesFileGlob: '**/*.md',
87
+ autoLoaded: true,
88
+ format: 'markdown',
89
+ migrationHint: 'Cursor reads AGENTS.md directly; no CLAUDE.md pointer is written.'
90
+ },
91
+ // Standards: the ROOT file is verified above (AGENTS.md); the `rulesDir`
92
+ // and `skillInstall` fields remain UNVERIFIED pending slice #012+
93
+ // (Cursor real-install dogfood). Until then the postinstall script writes
94
+ // skills + output-styles to the legacy `~/.claude/{skills,output-styles}`
95
+ // paths with a stderr warning. Users who want Cursor-specific paths must
96
+ // move the files manually.
81
97
  // Slice 4.0.8 RD §5: Cursor vendor signal is unverified; reserve-only resolver.
82
98
  resolveCallerId: (env) => {
83
99
  const e = env ?? process.env;
@@ -20,7 +20,8 @@
20
20
  */
21
21
  import { type SkillPresenceMode } from '../skills/skill-presence-service.js';
22
22
  import type { State24hSnapshot } from '../24h-mode/state.js';
23
- import { type AutoCompactMode } from '../code/auto-compact-modes.js';
23
+ import { type AutoCompactProfile } from '../code/auto-compact-modes.js';
24
+ import { type AutoCompactProfileSource } from '../code/auto-compact-profile.js';
24
25
  export interface ResolvedPresenceMode {
25
26
  readonly mode: SkillPresenceMode | null;
26
27
  readonly skill: string | null;
@@ -43,8 +44,14 @@ export interface ModeStatus {
43
44
  readonly h24State: State24hSnapshot | null;
44
45
  /** Job-mode flag from `job-shape.json` (`false` when undecided / unreadable). */
45
46
  readonly jobMode: boolean;
46
- /** Resolved auto-compact profile: `partial` iff the mode is `24h`. */
47
- readonly autoCompactProfile: AutoCompactMode;
47
+ /**
48
+ * The resolved auto-compact profile: `standard` or `eager`. It is a PUBLIC
49
+ * choice — the project setting `autoCompactProfile` or an explicit
50
+ * `--mode`, never the 24h state machine.
51
+ */
52
+ readonly autoCompactProfile: AutoCompactProfile;
53
+ /** Where that profile came from, so the answer is diagnosable. */
54
+ readonly autoCompactProfileSource: AutoCompactProfileSource;
48
55
  /** Thresholds backing `autoCompactProfile` (display aid). */
49
56
  readonly autoCompactThresholds: {
50
57
  readonly autoFire: number;
@@ -58,35 +65,27 @@ export interface ModeStatus {
58
65
  */
59
66
  export declare function resolvePresenceMode(projectRoot: string): ResolvedPresenceMode;
60
67
  /**
61
- * Resolve the auto-compact profile: `partial` (earlier thresholds for
62
- * long-run sessions) or `standard`.
68
+ * Resolve the auto-compact profile: `standard` (the v2.13.0 zero-pause
69
+ * contract thresholds) or `eager` (the earlier-firing thresholds).
63
70
  *
64
- * Two sources answer "is this a 24h long run?", and EITHER is enough:
71
+ * The profile is a PUBLIC choice, resolved in one order:
65
72
  *
66
- * 1. the PRESENCE MODE is `24h` — the autonomy level the user (or
67
- * the T3/T4 auto-engage) selected; or
68
- * 2. the 24h STATE MACHINE is engaged (`24H_ACTIVE` /
69
- * `WAITING_USER`) — the durable, session-scoped record.
73
+ * 1. an explicit `--mode` on this invocation (one call, one override)
74
+ * 2. the project setting `autoCompactProfile`
75
+ * 3. the default `'standard'`
70
76
  *
71
- * Why both (slice H3, rid=h3-24h-threshold-not-wired): source 1 alone
72
- * is not reliable. The mode lives on a per-caller, per-workflow
73
- * presence lease, and `applyAutoEngagePresenceMode` can only stamp
74
- * leases that are already in flight — entering `24H_ACTIVE` with no
75
- * in-flight lease fails closed as `{ applied: false, reason:
76
- * 'no-in-flight-lease' }`. A fresh lease is also written without a
77
- * mode (`workflow-presence-lifecycle.initWorkflow`), so a successful
78
- * stamp does not survive the next skill workflow either. The observed
79
- * consequence was a `24H_ACTIVE` session resolving to `standard` and
80
- * auto-compacting LATER than a plain session, the opposite of the
81
- * documented contract.
77
+ * The 24h mode does NOT take part. It used to: the profile was derived from
78
+ * the presence mode and from the 24h state machine, which made the
79
+ * compaction cadence a private property of one mode — a 24h session
80
+ * compacted earlier than a plain one without anybody asking for it. A
81
+ * project that wants to compact earlier now says so with
82
+ * `peaks preferences set --key autoCompactProfile --value eager`, and
83
+ * nothing changes under it silently.
82
84
  *
83
- * The union is a superset of both the pre-2026-09-09 mapping (state
84
- * mode): keep partial while the mode says `24h` even in
85
- * `WAITING_USER`, and keep it when only the state machine knows.
86
- * Nothing that resolved to `partial` before resolves to `standard`
87
- * now; a project with no 24h run is byte-identical to before.
85
+ * The resolution itself lives in `services/code/auto-compact-profile.ts`;
86
+ * this function keeps the name and the arity every existing caller uses.
88
87
  */
89
- export declare function resolveAutoCompactProfile(projectRoot: string): AutoCompactMode;
88
+ export declare function resolveAutoCompactProfile(projectRoot: string): AutoCompactProfile;
90
89
  /**
91
90
  * Assemble the full stacked status. `sessionId` defaults to the
92
91
  * canonical binding when omitted.
@@ -26,6 +26,7 @@ import { getCurrentSessionId } from '../skills/skill-presence-service.js';
26
26
  import { read24hState } from '../24h-mode/store.js';
27
27
  import { readJobShapeDecision } from '../code/job-shape-decision.js';
28
28
  import { AUTO_COMPACT_THRESHOLDS } from '../code/auto-compact-modes.js';
29
+ import { resolveAutoCompactProfile as resolveProfileSelection } from '../code/auto-compact-profile.js';
29
30
  /**
30
31
  * Read the active presence mode via the canonical lease projection.
31
32
  * Never throws.
@@ -45,64 +46,39 @@ export function resolvePresenceMode(projectRoot) {
45
46
  }
46
47
  }
47
48
  /**
48
- * The 24h state-machine states in which the long run is ENGAGED.
49
+ * Resolve the auto-compact profile: `standard` (the v2.13.0 zero-pause
50
+ * contract thresholds) or `eager` (the earlier-firing thresholds).
49
51
  *
50
- * `24H_ACTIVE` is the run itself; `WAITING_USER` is a pause *inside*
51
- * it (the run is still on — the user just has to answer). `BRAINSTORM`
52
- * / `USER_CONFIRM` precede the run, `HANDOFF` ends it, `IDLE` means it
53
- * never started.
54
- */
55
- const ENGAGED_24H_STATES = new Set(['24H_ACTIVE', 'WAITING_USER']);
56
- /**
57
- * Fail-soft read of the bound session's 24h state machine: `true` when
58
- * the long run is engaged. Every degradation (no session, missing or
59
- * malformed snapshot) reads as `false` so a non-24h project is
60
- * untouched by this signal.
61
- */
62
- function is24hRunEngaged(projectRoot) {
63
- try {
64
- const sessionId = getCurrentSessionId(projectRoot);
65
- if (sessionId === null)
66
- return false;
67
- return ENGAGED_24H_STATES.has(read24hState(projectRoot, sessionId).state);
68
- }
69
- catch {
70
- return false;
71
- }
72
- }
73
- /**
74
- * Resolve the auto-compact profile: `partial` (earlier thresholds for
75
- * long-run sessions) or `standard`.
52
+ * The profile is a PUBLIC choice, resolved in one order:
76
53
  *
77
- * Two sources answer "is this a 24h long run?", and EITHER is enough:
54
+ * 1. an explicit `--mode` on this invocation (one call, one override)
55
+ * 2. the project setting `autoCompactProfile`
56
+ * 3. the default `'standard'`
78
57
  *
79
- * 1. the PRESENCE MODE is `24h` — the autonomy level the user (or
80
- * the T3/T4 auto-engage) selected; or
81
- * 2. the 24h STATE MACHINE is engaged (`24H_ACTIVE` /
82
- * `WAITING_USER`) — the durable, session-scoped record.
58
+ * The 24h mode does NOT take part. It used to: the profile was derived from
59
+ * the presence mode and from the 24h state machine, which made the
60
+ * compaction cadence a private property of one mode — a 24h session
61
+ * compacted earlier than a plain one without anybody asking for it. A
62
+ * project that wants to compact earlier now says so with
63
+ * `peaks preferences set --key autoCompactProfile --value eager`, and
64
+ * nothing changes under it silently.
83
65
  *
84
- * Why both (slice H3, rid=h3-24h-threshold-not-wired): source 1 alone
85
- * is not reliable. The mode lives on a per-caller, per-workflow
86
- * presence lease, and `applyAutoEngagePresenceMode` can only stamp
87
- * leases that are already in flight — entering `24H_ACTIVE` with no
88
- * in-flight lease fails closed as `{ applied: false, reason:
89
- * 'no-in-flight-lease' }`. A fresh lease is also written without a
90
- * mode (`workflow-presence-lifecycle.initWorkflow`), so a successful
91
- * stamp does not survive the next skill workflow either. The observed
92
- * consequence was a `24H_ACTIVE` session resolving to `standard` and
93
- * auto-compacting LATER than a plain session, the opposite of the
94
- * documented contract.
95
- *
96
- * The union is a superset of both the pre-2026-09-09 mapping (state
97
- * mode): keep partial while the mode says `24h` even in
98
- * `WAITING_USER`, and keep it when only the state machine knows.
99
- * Nothing that resolved to `partial` before resolves to `standard`
100
- * now; a project with no 24h run is byte-identical to before.
66
+ * The resolution itself lives in `services/code/auto-compact-profile.ts`;
67
+ * this function keeps the name and the arity every existing caller uses.
101
68
  */
102
69
  export function resolveAutoCompactProfile(projectRoot) {
103
- if (resolvePresenceMode(projectRoot).mode === '24h')
104
- return 'partial';
105
- return is24hRunEngaged(projectRoot) ? 'partial' : 'standard';
70
+ return resolveProfile(projectRoot).profile;
71
+ }
72
+ /**
73
+ * The single place this module resolves the auto-compact profile.
74
+ *
75
+ * Both public entry points — `resolveAutoCompactProfile` and
76
+ * `resolveModeStatus` — go through it, so the profile the status command
77
+ * reports and the profile the services apply come from ONE call and cannot
78
+ * disagree.
79
+ */
80
+ function resolveProfile(projectRoot) {
81
+ return resolveProfileSelection({ projectRoot });
106
82
  }
107
83
  /**
108
84
  * Assemble the full stacked status. `sessionId` defaults to the
@@ -139,12 +115,11 @@ export function resolveModeStatus(input) {
139
115
  jobMode = false;
140
116
  }
141
117
  }
142
- // Delegate rather than re-derive `is24h ? 'partial' : 'standard'`: the
143
- // profile has a second source (the 24h state machine), and a local
144
- // copy of the old one-source rule would make `peaks code mode status`
145
- // advertise a different profile than the one `peaks code
146
- // auto-compact` actually applies.
147
- const autoCompactProfile = resolveAutoCompactProfile(projectRoot);
118
+ // Delegate rather than re-derive the profile: the resolution order lives
119
+ // in one place (`services/code/auto-compact-profile.ts`), and a local
120
+ // copy of the rule would make `peaks code mode status` advertise a
121
+ // different profile than the one `peaks code auto-compact` applies.
122
+ const profile = resolveProfile(projectRoot);
148
123
  return {
149
124
  mode: presence.mode,
150
125
  skill: presence.skill,
@@ -152,7 +127,8 @@ export function resolveModeStatus(input) {
152
127
  is24h,
153
128
  h24State,
154
129
  jobMode,
155
- autoCompactProfile,
156
- autoCompactThresholds: AUTO_COMPACT_THRESHOLDS[autoCompactProfile]
130
+ autoCompactProfile: profile.profile,
131
+ autoCompactProfileSource: profile.source,
132
+ autoCompactThresholds: AUTO_COMPACT_THRESHOLDS[profile.profile]
157
133
  };
158
134
  }
@@ -21,6 +21,26 @@ export type UaPromptDecision = 'unset' | 'skip-this-session' | 'skip-forever';
21
21
  * - 'lax' — always downgrade to previous level (faster, riskier)
22
22
  */
23
23
  export type ClassifyConservatism = 'default' | 'strict' | 'lax';
24
+ /**
25
+ * The auto-compact profile a project can pin.
26
+ *
27
+ * PUBLIC: any project, in any mode, can choose the compaction cadence. The
28
+ * profile is a THRESHOLD choice — `eager` fires earlier than `standard` —
29
+ * and it is set with
30
+ * `peaks preferences set --key autoCompactProfile --value eager`.
31
+ *
32
+ * The value set is closed on purpose: an unknown value is rejected at write
33
+ * time with the legal ones named, rather than stored and read back as
34
+ * something else.
35
+ */
36
+ export type AutoCompactProfilePreference = 'standard' | 'eager';
37
+ /** The legal `autoCompactProfile` values, in the order the error message lists them. */
38
+ export declare const AUTO_COMPACT_PROFILE_VALUES: readonly AutoCompactProfilePreference[];
39
+ /**
40
+ * The `isFanoutMode` paradigm for the auto-compact profile: one guard, one
41
+ * closed set, so a caller never has to re-spell the legal values.
42
+ */
43
+ export declare function isAutoCompactProfile(value: unknown): value is AutoCompactProfilePreference;
24
44
  export interface ClassifyRuleOverrides {
25
45
  /** File count threshold above which a task is promoted to 'feature' */
26
46
  readonly feature_threshold_files?: number;
@@ -86,6 +106,16 @@ export interface ProjectPreferences {
86
106
  readonly classifyConservatism: ClassifyConservatism;
87
107
  readonly classifyRules: ClassifyRuleOverrides;
88
108
  readonly swarmSpeculative: SwarmSpeculativePreferences;
109
+ /**
110
+ * The auto-compact profile this project pins: `standard` (the v2.13.0
111
+ * zero-pause contract thresholds) or `eager` (fires earlier).
112
+ *
113
+ * OPTIONAL on purpose. The field is additive, so an existing
114
+ * `.peaks/preferences.json` that does not carry it keeps loading — the
115
+ * schema version is unchanged, and a file without the key resolves to the
116
+ * default profile rather than to a load error.
117
+ */
118
+ readonly autoCompactProfile?: AutoCompactProfilePreference;
89
119
  /** Loop Autonomous (L4 14.5) toggle. Default: false — never auto-enable. */
90
120
  readonly loopAutonomousEnabled: boolean;
91
121
  /**
@@ -5,6 +5,18 @@
5
5
  *
6
6
  */
7
7
  export const PREFERENCES_SCHEMA_VERSION = '2.0.0';
8
+ /** The legal `autoCompactProfile` values, in the order the error message lists them. */
9
+ export const AUTO_COMPACT_PROFILE_VALUES = [
10
+ 'standard',
11
+ 'eager'
12
+ ];
13
+ /**
14
+ * The `isFanoutMode` paradigm for the auto-compact profile: one guard, one
15
+ * closed set, so a caller never has to re-spell the legal values.
16
+ */
17
+ export function isAutoCompactProfile(value) {
18
+ return (typeof value === 'string' && AUTO_COMPACT_PROFILE_VALUES.includes(value));
19
+ }
8
20
  export const FANOUT_MODES = ['fan-out'];
9
21
  /**
10
22
  * narrowed the closed set from `['fan-out','serial']` to `['fan-out']`
@@ -26,6 +38,7 @@ export const DEFAULT_PREFERENCES = {
26
38
  feature_threshold_lines: 100,
27
39
  runtime_clean_grace_hours: 24
28
40
  },
41
+ autoCompactProfile: 'standard',
29
42
  swarmSpeculative: {
30
43
  enabled: true,
31
44
  maxConcurrent: 3,
@@ -1,7 +1,9 @@
1
+ export type CriteriaSource = 'declared' | 'section' | 'both';
1
2
  export type AcceptanceItem = {
2
3
  id: string;
3
4
  text: string;
4
5
  line: number;
6
+ source: CriteriaSource;
5
7
  };
6
8
  export type TestCase = {
7
9
  title: string;
@@ -13,6 +15,18 @@ export type CoverageEntry = {
13
15
  acceptanceText: string;
14
16
  testCases: string[];
15
17
  };
18
+ export type AcceptanceCoverageOptions = {
19
+ projectRoot: string;
20
+ requestId: string;
21
+ sessionId?: string;
22
+ };
23
+ export type AcceptanceCoverageError = {
24
+ kind: 'prd-not-found';
25
+ message: string;
26
+ } | {
27
+ kind: 'test-cases-not-found';
28
+ expectedPath: string;
29
+ };
16
30
  export type AcceptanceCoverageReport = {
17
31
  ok: boolean;
18
32
  prdPath: string;
@@ -27,16 +41,5 @@ export type AcceptanceCoverageReport = {
27
41
  reference: string;
28
42
  }>;
29
43
  };
30
- export type AcceptanceCoverageOptions = {
31
- projectRoot: string;
32
- requestId: string;
33
- sessionId?: string;
34
- };
35
- export type AcceptanceCoverageError = {
36
- kind: 'prd-not-found';
37
- } | {
38
- kind: 'test-cases-not-found';
39
- expectedPath: string;
40
- };
41
44
  export declare function getAcceptanceCoverage(options: AcceptanceCoverageOptions): Promise<AcceptanceCoverageReport | AcceptanceCoverageError>;
42
45
  export declare function isAcceptanceCoverageError(value: AcceptanceCoverageReport | AcceptanceCoverageError): value is AcceptanceCoverageError;