peaks-loop 4.1.18 → 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 (168) hide show
  1. package/.claude-plugin/marketplace.json +2 -2
  2. package/CHANGELOG.md +126 -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 +26 -18
  14. package/dist/cli/commands/core/skill-generated-config-notice.d.ts +5 -0
  15. package/dist/cli/commands/core/skill-generated-config-notice.js +42 -8
  16. package/dist/cli/commands/core/skill-presence-commands.js +42 -74
  17. package/dist/cli/commands/core/skill-presence-set-command.d.ts +11 -0
  18. package/dist/cli/commands/core/skill-presence-set-command.js +175 -0
  19. package/dist/cli/commands/core/standards-init-command.js +44 -8
  20. package/dist/cli/commands/core/standards-migrate-command.js +5 -4
  21. package/dist/cli/commands/dispatch-dag-runners.d.ts +1 -0
  22. package/dist/cli/commands/dispatch-dag-runners.js +11 -1
  23. package/dist/cli/commands/dispatch-detached-branch.js +19 -1
  24. package/dist/cli/commands/mut-commands-helpers.d.ts +72 -5
  25. package/dist/cli/commands/mut-commands-helpers.js +197 -4
  26. package/dist/cli/commands/mut-commands.d.ts +9 -1
  27. package/dist/cli/commands/mut-commands.js +82 -154
  28. package/dist/cli/commands/preferences-commands.js +27 -2
  29. package/dist/cli/commands/scan-scope-helpers.js +2 -2
  30. package/dist/services/24h-mode/auto-engage.d.ts +11 -3
  31. package/dist/services/24h-mode/auto-engage.js +14 -6
  32. package/dist/services/artifacts/artifact-templates.js +10 -0
  33. package/dist/services/artifacts/backcompat-acceptance.d.ts +8 -1
  34. package/dist/services/artifacts/backcompat-acceptance.js +8 -7
  35. package/dist/services/artifacts/rd-transition-gates.d.ts +32 -5
  36. package/dist/services/artifacts/rd-transition-gates.js +96 -19
  37. package/dist/services/artifacts/request-artifact-service.js +6 -6
  38. package/dist/services/audit/enforcers/lint-output-style.js +14 -2
  39. package/dist/services/audit/enforcers/root-scratch-artifacts.d.ts +46 -0
  40. package/dist/services/audit/enforcers/root-scratch-artifacts.js +97 -0
  41. package/dist/services/audit/static-service.js +4 -4
  42. package/dist/services/code/auto-compact-history.d.ts +6 -1
  43. package/dist/services/code/auto-compact-history.js +6 -1
  44. package/dist/services/code/auto-compact-modes.d.ts +60 -14
  45. package/dist/services/code/auto-compact-modes.js +75 -20
  46. package/dist/services/code/auto-compact-profile.d.ts +23 -0
  47. package/dist/services/code/auto-compact-profile.js +51 -0
  48. package/dist/services/compact-history/compact-history-service.d.ts +6 -1
  49. package/dist/services/compact-history/compact-history-service.js +5 -1
  50. package/dist/services/context/auto-compact-types.d.ts +7 -5
  51. package/dist/services/doctor/doctor-service/checks/l3-runtime-root-census.d.ts +37 -0
  52. package/dist/services/doctor/doctor-service/checks/l3-runtime-root-census.js +100 -0
  53. package/dist/services/doctor/doctor-service/checks/skill-reference-parity.d.ts +11 -3
  54. package/dist/services/doctor/doctor-service/checks/skill-reference-parity.js +48 -29
  55. package/dist/services/doctor/doctor-service/plugin-registry.js +2 -0
  56. package/dist/services/hooks/hook-payload-cwd.d.ts +11 -4
  57. package/dist/services/hooks/hook-payload-cwd.js +11 -4
  58. package/dist/services/hooks/presence-marker-detector.d.ts +3 -0
  59. package/dist/services/hooks/presence-marker-detector.js +21 -19
  60. package/dist/services/ide/adapters/claude-code-adapter.js +6 -8
  61. package/dist/services/ide/adapters/codex-adapter.js +23 -7
  62. package/dist/services/ide/adapters/cursor-adapter.js +23 -7
  63. package/dist/services/mode/mode-status-service.d.ts +26 -27
  64. package/dist/services/mode/mode-status-service.js +36 -60
  65. package/dist/services/preferences/preferences-types.d.ts +30 -0
  66. package/dist/services/preferences/preferences-types.js +13 -0
  67. package/dist/services/scan/acceptance-coverage-service.d.ts +14 -11
  68. package/dist/services/scan/acceptance-coverage-service.js +157 -52
  69. package/dist/services/scan/rid-change-claims.d.ts +15 -0
  70. package/dist/services/scan/rid-change-claims.js +116 -0
  71. package/dist/services/skills/presence-caller-id.d.ts +51 -0
  72. package/dist/services/skills/presence-caller-id.js +43 -0
  73. package/dist/services/skills/presence-gate.d.ts +65 -0
  74. package/dist/services/skills/presence-gate.js +113 -0
  75. package/dist/services/skills/presence-lease-resolver.d.ts +63 -0
  76. package/dist/services/skills/presence-lease-resolver.js +114 -0
  77. package/dist/services/skills/presence-lease-selection.d.ts +91 -0
  78. package/dist/services/skills/presence-lease-selection.js +135 -0
  79. package/dist/services/skills/presence-lease-service.d.ts +3 -11
  80. package/dist/services/skills/presence-lease-service.js +34 -87
  81. package/dist/services/skills/presence-lease-store.d.ts +33 -0
  82. package/dist/services/skills/presence-lease-store.js +94 -0
  83. package/dist/services/skills/presence-lease-types.d.ts +31 -0
  84. package/dist/services/skills/presence-lease-types.js +27 -0
  85. package/dist/services/skills/presence-role.d.ts +35 -0
  86. package/dist/services/skills/presence-role.js +72 -0
  87. package/dist/services/skills/skill-presence-service.d.ts +39 -9
  88. package/dist/services/skills/skill-presence-service.js +143 -174
  89. package/dist/services/skills/skill-presence-write.d.ts +60 -0
  90. package/dist/services/skills/skill-presence-write.js +74 -0
  91. package/dist/services/skills/skill-statusline-service.js +7 -7
  92. package/dist/services/standards/ide-aware-standards-service.d.ts +35 -23
  93. package/dist/services/standards/ide-aware-standards-service.js +45 -20
  94. package/dist/services/standards/migrate-claude-rules-service.d.ts +6 -0
  95. package/dist/services/standards/migrate-claude-rules-service.js +18 -0
  96. package/dist/services/standards/migrate-service.d.ts +1 -1
  97. package/dist/services/standards/migrate-service.js +27 -7
  98. package/dist/services/standards/project-scripts.d.ts +25 -0
  99. package/dist/services/standards/project-scripts.js +116 -0
  100. package/dist/services/standards/project-standards-service.d.ts +23 -15
  101. package/dist/services/standards/project-standards-service.js +176 -243
  102. package/dist/services/standards/standards-constitution.d.ts +89 -0
  103. package/dist/services/standards/standards-constitution.js +199 -0
  104. package/dist/services/standards/standards-files.d.ts +37 -0
  105. package/dist/services/standards/standards-files.js +138 -0
  106. package/dist/services/standards/standards-pointer.d.ts +73 -0
  107. package/dist/services/standards/standards-pointer.js +98 -0
  108. package/dist/services/standards/standards-render-agents.d.ts +34 -0
  109. package/dist/services/standards/standards-render-agents.js +149 -0
  110. package/dist/services/standards/standards-render-common.d.ts +38 -1
  111. package/dist/services/standards/standards-render-common.js +44 -7
  112. package/dist/services/standards/standards-render.d.ts +1 -3
  113. package/dist/services/standards/standards-render.js +6 -87
  114. package/dist/services/workflow/workflow-graph-ensure.d.ts +77 -0
  115. package/dist/services/workflow/workflow-graph-ensure.js +97 -0
  116. package/dist/services/workflow/workflow-presence-lifecycle.js +21 -6
  117. package/dist/services/workspace/generated-artifacts-content.d.ts +46 -0
  118. package/dist/services/workspace/generated-artifacts-content.js +167 -0
  119. package/dist/services/workspace/generated-artifacts-stamp.d.ts +36 -13
  120. package/dist/services/workspace/generated-artifacts-stamp.js +37 -15
  121. package/dist/services/workspace/runtime-layout.d.ts +64 -0
  122. package/dist/services/workspace/runtime-layout.js +62 -0
  123. package/output-styles/peaks-skill-swarm.md +18 -2
  124. package/package.json +8 -9
  125. package/schemas/doctor-report.schema.json +1 -1
  126. package/skills/bee/peaks-perf-audit/SKILL.md +3 -1
  127. package/skills/bee/peaks-prd/SKILL.md +5 -3
  128. package/skills/bee/peaks-qa/SKILL.md +4 -2
  129. package/skills/bee/peaks-qa/references/qa-skill-presence.md +1 -1
  130. package/skills/bee/peaks-qa/references/qa-standards-preflight.md +3 -1
  131. package/skills/bee/peaks-qa/references/qa-sub-agent-dispatch.md +2 -2
  132. package/skills/bee/peaks-rd/SKILL.md +4 -2
  133. package/skills/bee/peaks-rd/references/artifact-and-standards-output.md +1 -1
  134. package/skills/bee/peaks-rd/references/rd-runbook.md +11 -2
  135. package/skills/bee/peaks-rd/references/rd-standards-preflight.md +3 -1
  136. package/skills/bee/peaks-rd/references/rd-sub-agent-dispatch.md +4 -4
  137. package/skills/bee/peaks-rd/references/rd-transition-gates.md +49 -5
  138. package/skills/bee/peaks-rd/references/skill-presence-and-title.md +1 -1
  139. package/skills/bee/peaks-reviewer/SKILL.md +3 -1
  140. package/skills/bee/peaks-sc/SKILL.md +4 -2
  141. package/skills/bee/peaks-security-audit/SKILL.md +3 -1
  142. package/skills/bee/peaks-txt/SKILL.md +5 -3
  143. package/skills/bee/peaks-ui/SKILL.md +6 -4
  144. package/skills/peaks-audit/SKILL.md +3 -1
  145. package/skills/peaks-code/SKILL.md +3 -1
  146. package/skills/peaks-code/references/a2a-artifact-mapping.md +3 -3
  147. package/skills/peaks-code/references/completion-handoff.md +1 -1
  148. package/skills/peaks-code/references/local-artifact-workspace.md +10 -11
  149. package/skills/peaks-code/references/micro-cycle.md +2 -2
  150. package/skills/peaks-code/references/mode-selection-with-stale-presence.md +3 -3
  151. package/skills/peaks-code/references/runbook.md +4 -4
  152. package/skills/peaks-code/references/skill-presence-and-title.md +4 -2
  153. package/skills/peaks-code/references/standards-preflight.md +7 -6
  154. package/skills/peaks-code/references/sub-agent-dispatch.md +1 -1
  155. package/skills/peaks-code/references/swarm-dispatch-contract.md +5 -5
  156. package/skills/peaks-code/references/workflow-gates-and-types.md +37 -11
  157. package/skills/peaks-content/SKILL.md +3 -1
  158. package/skills/peaks-doctor/SKILL.md +3 -1
  159. package/skills/peaks-final-review/SKILL.md +3 -1
  160. package/skills/peaks-ide/SKILL.md +3 -1
  161. package/skills/peaks-issue-fix-orchestrator/SKILL.md +5 -3
  162. package/skills/peaks-race-code/SKILL.md +3 -1
  163. package/skills/peaks-resume/SKILL.md +3 -1
  164. package/skills/peaks-slice-decompose/SKILL.md +3 -1
  165. package/skills/peaks-solo/SKILL.md +3 -1
  166. package/skills/peaks-sop/SKILL.md +4 -2
  167. package/skills/peaks-status/SKILL.md +3 -1
  168. package/skills/peaks-test/SKILL.md +3 -1
@@ -1,6 +1,8 @@
1
1
  import { addJsonOption, getErrorMessage, printResult } from '../cli-helpers.js';
2
2
  import { fail } from 'peaks-loop-shared/result';
3
3
  import { runAutoCompact } from '../../services/code/auto-compact-orchestrator.js';
4
+ import { normalizeAutoCompactMode } from '../../services/code/auto-compact-modes.js';
5
+ import { resolveAutoCompactProfile } from '../../services/code/auto-compact-profile.js';
4
6
  import { probeInFlightBatch } from '../../services/workflow/workflow-inflight-probe.js';
5
7
  import { readDispatchLedgerFacts } from '../../services/dispatch/dispatch-ledger-reader.js';
6
8
  import { readActiveSid } from './code-runtime-session.js';
@@ -17,11 +19,13 @@ const AUTO_COMPACT_DESCRIPTION = 'v2.13.0 AC-4: zero-human-intervention auto-com
17
19
  'command acts on. This command is also fired by the installed ' +
18
20
  'PreToolUse hook, which passes `--project .` — without that argument ' +
19
21
  'the hook could never run at all. rid-027 ' +
20
- 'adds `--mode <mode>`: `standard` (0.85/0.95) or `partial` (0.70/0.85 ' +
21
- 'for 24h long-run mode).';
22
+ 'adds `--mode <mode>`: `standard` (pre-compact 0.85 / red-line 0.95) ' +
23
+ 'or `eager` (pre-compact 0.70 / red-line 0.85 — fires earlier than ' +
24
+ '`standard`). With no `--mode`, the project setting `autoCompactProfile` ' +
25
+ 'decides (default `standard`).';
22
26
  /** The invalid-`--mode` branch, lifted verbatim out of the action body. */
23
27
  function reportInvalidAutoCompactMode(io, modeName, json) {
24
- printResult(io, fail('code.auto-compact', 'AUTO_COMPACT_INVALID_MODE', `Invalid --mode '${modeName}'. Valid values: standard | partial.`, null, ['Re-run with --mode standard or --mode partial.']), json);
28
+ printResult(io, fail('code.auto-compact', 'AUTO_COMPACT_INVALID_MODE', `Invalid --mode '${modeName}'. Valid values: standard | eager. The legacy alias 'partial' is also accepted and means 'eager'.`, null, ['Re-run with --mode standard or --mode eager.']), json);
25
29
  process.exitCode = 1;
26
30
  }
27
31
  /**
@@ -67,11 +71,12 @@ function buildAutoCompactInput(opts, modeName, capture) {
67
71
  : {}),
68
72
  force: opts.force === true,
69
73
  bypassRedLine: opts.bypassRedLine === true,
70
- // Forward the FLAG verbatim — `undefined` when the user named no
71
- // mode — so the orchestrator's fallback to the presence-derived
72
- // mode can actually run. Forwarding the validated `modeName` is
73
- // what disabled 24h → partial.
74
- mode: opts.mode === undefined ? undefined : modeName
74
+ // The profile is resolved ONCE, by the resolver, and handed down
75
+ // explicitly: the CLI flag beats the project setting, and the project
76
+ // setting beats the default. The orchestrator's own fallback reads the
77
+ // same resolver, so the two cannot disagree about which profile is in
78
+ // force.
79
+ mode: modeName
75
80
  };
76
81
  }
77
82
  /** The catch branch, lifted verbatim out of the action body. */
@@ -99,14 +104,17 @@ function deferralDetail(result, probe) {
99
104
  /** The action body, lifted to a module-level function so both it and the registrar fit in 50 lines. */
100
105
  async function runAutoCompactAction(opts, io) {
101
106
  try {
102
- const { isValidMode } = await import('../../services/code/auto-compact-modes.js');
103
- const modeName = opts.mode ?? 'standard';
104
- if (!isValidMode(modeName)) {
105
- reportInvalidAutoCompactMode(io, modeName, opts.json);
107
+ // `--mode` is normalized ONCE, here: the legacy alias `partial` becomes
108
+ // `eager` before anything is stored, reported or logged, so the alias
109
+ // never reaches the runtime state.
110
+ const cliMode = opts.mode === undefined ? null : normalizeAutoCompactMode(opts.mode);
111
+ if (opts.mode !== undefined && cliMode === null) {
112
+ reportInvalidAutoCompactMode(io, opts.mode, opts.json);
106
113
  return;
107
114
  }
115
+ const selection = resolveAutoCompactProfile({ projectRoot: opts.project, cliMode });
108
116
  const capture = { last: null };
109
- const result = await runAutoCompact(buildAutoCompactInput(opts, modeName, capture));
117
+ const result = await runAutoCompact(buildAutoCompactInput(opts, selection.profile, capture));
110
118
  const code = result.code;
111
119
  const exitOk = result.ok || code === 'AUTO_COMPACT_SKIP' || code === 'AUTO_COMPACT_WAIT';
112
120
  // Adapt AutoCompactResult → ResultEnvelope so printResult's
@@ -139,9 +147,9 @@ export function registerCodeAutoCompactCommand(code, io) {
139
147
  // advertising it, not to change its meaning.
140
148
  .option('--bypass-red-line', 'no-op: the 95% red line no longer gates dispatch, so there is nothing to bypass (accepted for backward compatibility)')
141
149
  // No commander default here, deliberately. A declared default makes
142
- // `opts.mode` permanently defined, which defeats the orchestrator's
143
- // `input.mode ?? resolveAutoCompactMode(projectRoot)` fallback and
144
- // silently disables "24h mode auto-selects partial" — the help text
145
- // below promises it. Absence must stay absent.
146
- .option('--mode <mode>', 'auto-compact mode (standard | partial). Default: standard. 24h mode auto-selects partial.')).action((opts) => runAutoCompactAction(opts, io));
150
+ // `opts.mode` permanently defined, which would defeat the resolver's
151
+ // "project setting → default" fallback — the help text below promises
152
+ // that the project setting decides when no `--mode` is named.
153
+ // Absence must stay absent.
154
+ .option('--mode <mode>', 'auto-compact mode for THIS call: standard | eager (the legacy alias `partial` is accepted and means `eager`). Default: the project setting `autoCompactProfile`, else standard.')).action((opts) => runAutoCompactAction(opts, io));
147
155
  }
@@ -34,6 +34,11 @@ export declare function canonicalizeProjectOption(project: string | undefined):
34
34
  * The field is additive and present only when stale, so no existing consumer
35
35
  * of the envelope changes shape. `null` projectRoot means the caller had no
36
36
  * project to inspect — skipped, not assumed stale.
37
+ *
38
+ * WHAT THE WARNING SAYS. It names the FILE that no longer matches and WHAT
39
+ * about it, because "the version numbers differ" does not tell a reader which
40
+ * file to open. The remedy (`peaks workspace init`) is in the message: the
41
+ * reader is an LLM that must be able to act without guessing a command.
37
42
  */
38
43
  export declare function generatedConfigNotice(projectRoot: string | undefined): {
39
44
  field: Record<string, unknown>;
@@ -48,6 +48,11 @@ export function canonicalizeProjectOption(project) {
48
48
  * The field is additive and present only when stale, so no existing consumer
49
49
  * of the envelope changes shape. `null` projectRoot means the caller had no
50
50
  * project to inspect — skipped, not assumed stale.
51
+ *
52
+ * WHAT THE WARNING SAYS. It names the FILE that no longer matches and WHAT
53
+ * about it, because "the version numbers differ" does not tell a reader which
54
+ * file to open. The remedy (`peaks workspace init`) is in the message: the
55
+ * reader is an LLM that must be able to act without guessing a command.
51
56
  */
52
57
  export function generatedConfigNotice(projectRoot) {
53
58
  if (projectRoot === undefined)
@@ -55,21 +60,50 @@ export function generatedConfigNotice(projectRoot) {
55
60
  const staleness = detectStaleGeneratedArtifacts(projectRoot);
56
61
  if (!staleness.stale)
57
62
  return { field: {}, warnings: [] };
58
- const onDiskVersion = staleness.onDisk?.packageVersion ?? '(unstamped)';
59
63
  return {
60
64
  field: {
61
65
  generatedArtifacts: {
62
66
  stale: true,
63
67
  reasons: staleness.reasons,
64
68
  onDiskPackageVersion: staleness.onDisk?.packageVersion ?? null,
65
- installedPackageVersion: staleness.expected.packageVersion
69
+ installedPackageVersion: staleness.expected.packageVersion,
70
+ drift: staleness.drift
66
71
  }
67
72
  },
68
- warnings: [
69
- `Generated config at '${projectRoot}' was produced by peaks-loop ${onDiskVersion} ` +
70
- `but ${staleness.expected.packageVersion} is installed (${staleness.reasons.join(', ')}). ` +
71
- `Re-run \`peaks workspace init\` ` +
72
- `to regenerate .claude/settings.local.json and the offline template copy.`
73
- ]
73
+ warnings: [stalenessWarning(projectRoot, staleness)]
74
74
  };
75
75
  }
76
+ /**
77
+ * The one sentence the reader gets.
78
+ *
79
+ * The drift detail is appended only when there IS one: a verdict driven by the
80
+ * stamp alone (`unstamped`, `stamp-unreadable`, `template-changed`) has no
81
+ * file to point at, and inventing one would be a claim about a file nobody
82
+ * compared.
83
+ *
84
+ * The details are GROUPED per artifact, so a file that differs in two ways is
85
+ * named once with both of its differences — a warning that repeats the same
86
+ * path twice reads as two files.
87
+ */
88
+ function stalenessWarning(projectRoot, staleness) {
89
+ const onDiskVersion = staleness.onDisk?.packageVersion ?? '(unstamped)';
90
+ const head = `Generated config at '${projectRoot}' was produced by peaks-loop ${onDiskVersion} ` +
91
+ `but ${staleness.expected.packageVersion} is installed (${staleness.reasons.join(', ')}). ` +
92
+ `Re-run \`peaks workspace init\` ` +
93
+ `to regenerate .claude/settings.local.json and the offline template copy.`;
94
+ if (staleness.drift.length === 0)
95
+ return head;
96
+ return `${head} Inconsistent: ${groupDriftDetails(staleness.drift)}.`;
97
+ }
98
+ /** The drift details, one clause per artifact. */
99
+ function groupDriftDetails(drift) {
100
+ const grouped = new Map();
101
+ for (const entry of drift) {
102
+ const details = grouped.get(entry.artifact) ?? [];
103
+ details.push(entry.detail);
104
+ grouped.set(entry.artifact, details);
105
+ }
106
+ return [...grouped.entries()]
107
+ .map(([artifact, details]) => `${artifact}: ${details.join('; ')}`)
108
+ .join(' | ');
109
+ }
@@ -1,30 +1,35 @@
1
- import { setSkillPresence, getSkillPresence, isSkillPresenceMode, checkStalePresence } from '../../../services/skills/skill-presence-service.js';
1
+ import { getSkillPresence, checkStalePresence } from '../../../services/skills/skill-presence-service.js';
2
+ import { diagnosePresence, resolveProjectRoot } from '../../../services/skills/presence-lease-resolver.js';
2
3
  import { findProjectRoot } from '../../../services/config/config-safety.js';
3
- import { getSessionId, setSessionMeta } from '../../../services/session/session-manager.js';
4
- import { resolveCallerProjection } from '../../../services/session/resolve-caller-id.js';
5
- import { fail, ok } from 'peaks-loop-shared/result';
4
+ import { ok } from 'peaks-loop-shared/result';
6
5
  import { addJsonOption, printResult } from '../../cli-helpers.js';
7
6
  import { canonicalizeProjectOption, generatedConfigNotice } from './skill-generated-config-notice.js';
8
7
  import { contextVerdict } from './skill-context-verdict.js';
8
+ import { registerSkillPresenceSetCommand } from './skill-presence-set-command.js';
9
9
  const PRESENCE_DESCRIPTION = 'Show the currently active Peaks skill (alias: presence:get)';
10
10
  const PRESENCE_CHECK_STALE_HELP = 'slice 002 (v2.15.0): also report whether the recorded outer session id still matches the current one. Default false (back-compat).';
11
11
  const PRESENCE_PROJECT_HELP = 'project root (default: cwd)';
12
- const PRESENCE_SET_DESCRIPTION = 'Set the currently active Peaks skill for session-wide visibility. Slice 4.0.8: requires a bound session and an adapter-resolved caller id (fail-closed); raw unlink is rejected.';
13
- const PRESENCE_SET_MODE_HELP = 'execution mode';
14
- const PRESENCE_SET_GATE_HELP = 'current gate';
15
- const PRESENCE_SET_PROJECT_HELP = 'project root path (auto-detected from cwd when omitted)';
16
12
  function presenceActiveData(presence, parts) {
17
13
  return {
18
14
  active: true,
19
15
  ...presence,
16
+ gate: readGateField(presence.gate),
20
17
  ...(parts.verdict.context !== null ? { context: parts.verdict.context } : {}),
21
18
  ...parts.generatedConfig.field
22
19
  };
23
20
  }
21
+ /**
22
+ * The gate cell of the status header. `null` when the active lease records
23
+ * no gate (a lease written before the gate was persisted).
24
+ */
25
+ function readGateField(value) {
26
+ return typeof value === 'string' && value.length > 0 ? value : null;
27
+ }
24
28
  function presenceStaleData(presence, staleness, parts) {
25
29
  return {
26
30
  active: true,
27
31
  ...presence,
32
+ gate: readGateField(presence.gate),
28
33
  stale: staleness.stale,
29
34
  staleReason: staleness.reason,
30
35
  currentOuterSessionId: staleness.currentOuterSessionId,
@@ -33,91 +38,54 @@ function presenceStaleData(presence, staleness, parts) {
33
38
  ...parts.generatedConfig.field
34
39
  };
35
40
  }
41
+ /**
42
+ * The INACTIVE envelope. Without `--check-stale` it stays exactly
43
+ * `{ active: false }` — an optimistic default is not allowed. With it, the
44
+ * caller asked "why is nothing active?", so the diagnostic is attached.
45
+ */
46
+ function presenceInactiveData(generatedConfig, diagnostic) {
47
+ return {
48
+ active: false,
49
+ stale: true,
50
+ staleReason: 'no-presence',
51
+ presenceInactive: {
52
+ reason: diagnostic.reason,
53
+ leaseCount: diagnostic.leaseCount,
54
+ terminalCount: diagnostic.terminalCount,
55
+ staleCount: diagnostic.staleCount,
56
+ eligibleCount: diagnostic.eligibleCount
57
+ },
58
+ ...generatedConfig.field
59
+ };
60
+ }
36
61
  function runSkillPresence(options, io) {
37
62
  const projectOption = canonicalizeProjectOption(options.project);
38
63
  const generatedConfig = generatedConfigNotice(projectOption ?? findProjectRoot(process.cwd()) ?? process.cwd());
39
64
  const presence = getSkillPresence(projectOption);
40
65
  if (presence === null) {
41
- printResult(io, ok('skill.presence', { active: false, ...generatedConfig.field }, generatedConfig.warnings), options.json);
66
+ // Without `--check-stale` the envelope stays exactly `{ active: false }`.
67
+ const data = options.checkStale === true
68
+ ? presenceInactiveData(generatedConfig, diagnosePresence(resolveProjectRoot(projectOption)))
69
+ : { active: false, ...generatedConfig.field };
70
+ printResult(io, ok('skill.presence', data, generatedConfig.warnings), options.json);
42
71
  return;
43
72
  }
44
73
  // Loop-hygiene verdict: attached to every ACTIVE read, so the
45
- // zero-pause contract travels with the one call every skill already
46
- // makes — in every mode and every consumer project.
74
+ // zero-pause contract travels with the one call every skill makes.
47
75
  const verdict = contextVerdict(projectOption ?? process.cwd());
48
76
  const parts = { verdict, generatedConfig };
49
- // `--check-stale` lets callers (peaks-code Step 1, statusline) get both
50
- // pieces of info from a single CLI invocation. The presence is returned
51
- // UNCHANGED — it is a read-only flag, not a clear.
77
+ // `--check-stale` gives both pieces of info in one invocation; the
78
+ // presence itself is returned UNCHANGED — it is a read-only flag.
52
79
  const data = options.checkStale === true
53
80
  ? presenceStaleData(presence, checkStalePresence({ projectRootOverride: projectOption }), parts)
54
81
  : presenceActiveData(presence, parts);
55
82
  printResult(io, ok('skill.presence', data, generatedConfig.warnings, verdict.nextActions), options.json);
56
83
  }
57
- function printInvalidMode(io, options, name) {
58
- printResult(io, fail('skill.presence:set', 'INVALID_MODE', `Invalid mode: ${options.mode} (expected one of: full-auto, assisted, strict, 24h)`, { name, mode: options.mode }, ['Use a valid mode: full-auto, assisted, strict, or 24h']), options.json);
59
- process.exitCode = 1;
60
- }
61
- function printSessionNotBound(io, options, name, projectRoot) {
62
- printResult(io, fail('skill.presence:set', 'PEAKS_SESSION_NOT_BOUND', 'No canonical peaks session is bound for this project (RD §3 D1).', { projectRoot, name }, ['Run `peaks workspace init --project <p>` first, then re-run `peaks skill presence:set`.']), options.json);
63
- process.exitCode = 1;
64
- }
65
- function printCallerNotResolved(io, options, target, err) {
66
- const message = err instanceof Error ? err.message : String(err);
67
- printResult(io, fail('skill.presence:set', 'PEAKS_CALLER_NOT_RESOLVED', `Active IDE adapter could not resolve a callerId (RD §3 D1): ${message}`, target, [
68
- 'Ensure the active IDE is detected by `peaks` and the IDE session variable is set.',
69
- 'Or set PEAKS_CALLER_ID=<id> in the environment for scripted usage.'
70
- ]), options.json);
71
- process.exitCode = 1;
72
- }
73
- function runSkillPresenceSet(name, options, io) {
74
- const projectOption = canonicalizeProjectOption(options.project);
75
- const projectRoot = projectOption ?? findProjectRoot(process.cwd()) ?? process.cwd();
76
- if (options.mode !== undefined && !isSkillPresenceMode(options.mode)) {
77
- printInvalidMode(io, options, name);
78
- return;
79
- }
80
- // Slice 4.0.8 (D1 + D2): `presence:set` is fail-closed. We refuse
81
- // any write when (a) no peaks session is bound, or (b) the active
82
- // IDE adapter cannot resolve a valid callerId. Both failures
83
- // surface BEFORE any filesystem write. The legacy
84
- // `setSkillPresence` wrapper is kept as a compat shim for tests
85
- // and CLI flows that intentionally do not need a session — but
86
- // production CLI traffic must go through this gate.
87
- const boundSessionId = getSessionId(projectRoot);
88
- if (boundSessionId === null) {
89
- printSessionNotBound(io, options, name, projectRoot);
90
- return;
91
- }
92
- try {
93
- resolveCallerProjection({ projectRoot });
94
- }
95
- catch (err) {
96
- printCallerNotResolved(io, options, { name, projectRoot }, err);
97
- return;
98
- }
99
- const presence = setSkillPresence(name, options.mode, options.gate, projectOption);
100
- // Session metadata is updated when a session is bound (read-only
101
- // path: `getSessionId`). We do not auto-spawn a session.
102
- if (boundSessionId !== null) {
103
- setSessionMeta(projectRoot, boundSessionId, {
104
- skill: name,
105
- ...(options.mode ? { mode: options.mode } : {}),
106
- ...(options.gate ? { gate: options.gate } : {})
107
- });
108
- }
109
- printResult(io, ok('skill.presence:set', { active: true, ...presence }), options.json);
110
- }
111
84
  export function registerSkillPresenceCommands(skill, io) {
112
85
  addJsonOption(skill
113
86
  .command('presence')
114
87
  .description(PRESENCE_DESCRIPTION)
115
88
  .option('--check-stale', PRESENCE_CHECK_STALE_HELP)
116
89
  .option('--project <path>', PRESENCE_PROJECT_HELP)).action((options) => runSkillPresence(options, io));
117
- addJsonOption(skill
118
- .command('presence:set <name>')
119
- .description(PRESENCE_SET_DESCRIPTION)
120
- .option('--mode <mode>', PRESENCE_SET_MODE_HELP)
121
- .option('--gate <gate>', PRESENCE_SET_GATE_HELP)
122
- .option('--project <path>', PRESENCE_SET_PROJECT_HELP)).action((name, options) => runSkillPresenceSet(name, options, io));
90
+ registerSkillPresenceSetCommand(skill, io);
123
91
  }
@@ -0,0 +1,11 @@
1
+ import type { Command } from 'commander';
2
+ import { type ProgramIO } from '../../cli-helpers.js';
3
+ export type PresenceSetOptions = {
4
+ mode?: string;
5
+ gate?: string;
6
+ project?: string;
7
+ callerId?: string;
8
+ json?: boolean;
9
+ };
10
+ export declare function runSkillPresenceSet(name: string, options: PresenceSetOptions, io: ProgramIO): Promise<void>;
11
+ export declare function registerSkillPresenceSetCommand(skill: Command, io: ProgramIO): void;
@@ -0,0 +1,175 @@
1
+ import { setSkillPresence, isSkillPresenceMode } from '../../../services/skills/skill-presence-service.js';
2
+ import { resolvePresenceCallerId } from '../../../services/skills/presence-caller-id.js';
3
+ import { MAX_PRESENCE_GATE_LENGTH, normalizePresenceGate } from '../../../services/skills/presence-gate.js';
4
+ import { canonicalizeProjectOption } from './skill-generated-config-notice.js';
5
+ import { findProjectRoot } from '../../../services/config/config-safety.js';
6
+ import { getSessionId, setSessionMeta } from '../../../services/session/session-manager.js';
7
+ import { fail, getErrorMessage, ok } from 'peaks-loop-shared/result';
8
+ import { addJsonOption, printResult } from '../../cli-helpers.js';
9
+ const PRESENCE_SET_DESCRIPTION = 'Set the currently active Peaks skill for session-wide visibility. Slice 4.0.8: requires a bound session and a resolved caller id (fail-closed); raw unlink is rejected.';
10
+ const PRESENCE_SET_MODE_HELP = 'execution mode';
11
+ const PRESENCE_SET_GATE_HELP = 'current gate';
12
+ const PRESENCE_SET_PROJECT_HELP = 'project root path (auto-detected from cwd when omitted)';
13
+ const PRESENCE_SET_CALLER_ID_HELP = 'caller id for this invocation (priority: --caller-id flag > PEAKS_CALLER_ID env > active IDE adapter); must match ^[a-zA-Z0-9._-]{1,200}$';
14
+ // The `request init` exit code for a caller id that was supplied but does
15
+ // not match the D1 regex (EX_DATAERR). 64 is the "nothing usable" code.
16
+ const CALLER_ID_INVALID_EXIT_CODE = 65;
17
+ const CALLER_ID_UNRESOLVED_EXIT_CODE = 1;
18
+ /**
19
+ * The code a FAILED canonical write is reported under. It is the code
20
+ * `peaks workflow init` already uses for the same write (graph + lease +
21
+ * index), so the two commands report one failure one way. A typed
22
+ * `PEAKS_*` code the service already raised (e.g. `PEAKS_GRAPH_LOCK_HELD`)
23
+ * is kept as-is; a raw filesystem error (ENOTDIR, EACCES, ...) is reported
24
+ * as the write failure it is.
25
+ */
26
+ const PRESENCE_WRITE_FAILED_CODE = 'PEAKS_GRAPH_WRITE_FAILED';
27
+ function printInvalidMode(io, options, name) {
28
+ printResult(io, fail('skill.presence:set', 'INVALID_MODE', `Invalid mode: ${options.mode} (expected one of: full-auto, assisted, strict, 24h)`, { name, mode: options.mode }, ['Use a valid mode: full-auto, assisted, strict, or 24h']), options.json);
29
+ process.exitCode = 1;
30
+ }
31
+ function printInvalidGate(io, options, name) {
32
+ printResult(io, fail('skill.presence:set', 'INVALID_GATE', `Invalid gate: ${options.gate} (expected a non-empty gate value of at most ${MAX_PRESENCE_GATE_LENGTH} characters, without control characters)`, { name, gate: options.gate }, ['Use a short gate value such as `startup`, `qa-validation` or `swarm-fan-out`.']), options.json);
33
+ process.exitCode = 1;
34
+ }
35
+ function printSessionNotBound(io, options, name, projectRoot) {
36
+ printResult(io, fail('skill.presence:set', 'PEAKS_SESSION_NOT_BOUND', 'No canonical peaks session is bound for this project (RD §3 D1).', { projectRoot, name }, ['Run `peaks workspace init --project <p>` first, then re-run `peaks skill presence:set`.']), options.json);
37
+ process.exitCode = 1;
38
+ }
39
+ /**
40
+ * The caller-id refusal. `CALLER_ID_INVALID` is a shape mismatch — a value
41
+ * was supplied but does not match the D1 regex. `PEAKS_CALLER_NOT_RESOLVED`
42
+ * means nothing could be resolved at all. Both are fail-closed: no lease is
43
+ * written.
44
+ */
45
+ function printCallerFailure(io, options, target, failure) {
46
+ const invalid = failure.code === 'CALLER_ID_INVALID';
47
+ printResult(io, fail('skill.presence:set', failure.code, invalid ? failure.message : `Could not resolve a callerId: ${failure.message}`, target, invalid
48
+ ? [
49
+ 'Use a caller id matching ^[a-zA-Z0-9._-]{1,200}$ (letters, digits, dot, underscore, hyphen).'
50
+ ]
51
+ : [
52
+ 'Pass --caller-id <id>, or set PEAKS_CALLER_ID=<id> in the environment for scripted usage.'
53
+ ]), options.json);
54
+ process.exitCode = invalid ? CALLER_ID_INVALID_EXIT_CODE : CALLER_ID_UNRESOLVED_EXIT_CODE;
55
+ }
56
+ /**
57
+ * The mode and the gate are checked BEFORE any write. The gate is persisted
58
+ * with the lease (it is the middle cell of the status header); unknown but
59
+ * well-formed gate values are accepted on purpose — the gate vocabulary is
60
+ * open (see `presence-gate.ts`).
61
+ */
62
+ function validateSetFields(io, options, name) {
63
+ if (options.mode !== undefined && !isSkillPresenceMode(options.mode)) {
64
+ printInvalidMode(io, options, name);
65
+ return false;
66
+ }
67
+ if (options.gate !== undefined) {
68
+ try {
69
+ normalizePresenceGate(options.gate);
70
+ }
71
+ catch {
72
+ printInvalidGate(io, options, name);
73
+ return false;
74
+ }
75
+ }
76
+ return true;
77
+ }
78
+ /**
79
+ * Resolve the caller id, or print the refusal and return null. The
80
+ * `--caller-id` flag and `PEAKS_CALLER_ID` are the vendor-neutral escape
81
+ * hatches; the active IDE adapter is the fallback. The priority chain
82
+ * lives in `resolve-caller-id.ts` and is not restated here.
83
+ */
84
+ function resolveSetCallerId(io, options, target) {
85
+ const resolved = resolvePresenceCallerId({
86
+ projectRoot: target.projectRoot,
87
+ ...(options.callerId !== undefined ? { flagValue: options.callerId } : {})
88
+ });
89
+ if (resolved.ok)
90
+ return resolved.callerId;
91
+ printCallerFailure(io, options, target, resolved);
92
+ return null;
93
+ }
94
+ /**
95
+ * The error code a failed canonical write is reported under. A typed
96
+ * `PEAKS_*` code the service already raised is kept, so a graph lock
97
+ * (`PEAKS_GRAPH_LOCK_HELD`) does not read as a generic write failure; a raw
98
+ * filesystem error is reported as the write failure it is.
99
+ */
100
+ function presenceWriteFailureCode(error) {
101
+ const code = error.code;
102
+ return typeof code === 'string' && code.startsWith('PEAKS_') ? code : PRESENCE_WRITE_FAILED_CODE;
103
+ }
104
+ /**
105
+ * The canonical write FAILED — the graph the lease names could not be
106
+ * built, or the lease itself could not be written. The command FAILS here:
107
+ * a presence that was not written is not a presence that was set, and
108
+ * reporting success would leave the operator believing the skill is active
109
+ * when no lease exists.
110
+ *
111
+ * This branch is distinct from the two refusals above it: those are
112
+ * "nothing was even attempted" (no session bound, no caller id), this one
113
+ * is "the write was attempted and failed". The codes say which.
114
+ */
115
+ function printWriteFailure(io, options, target, error) {
116
+ printResult(io, fail('skill.presence:set', presenceWriteFailureCode(error), `Could not write the canonical presence lease (graph + lease): ${getErrorMessage(error)}`, { name: target.name, projectRoot: target.projectRoot }, [
117
+ 'Check that the session runtime directory is writable, then re-run `peaks skill presence:set`.'
118
+ ]), options.json);
119
+ process.exitCode = 1;
120
+ }
121
+ export async function runSkillPresenceSet(name, options, io) {
122
+ const projectOption = canonicalizeProjectOption(options.project);
123
+ const projectRoot = projectOption ?? findProjectRoot(process.cwd()) ?? process.cwd();
124
+ if (!validateSetFields(io, options, name))
125
+ return;
126
+ // `presence:set` is fail-closed. We refuse any write when (a) no peaks
127
+ // session is bound, or (b) no callerId could be resolved — both BEFORE
128
+ // any filesystem write. The escape hatch for (b) is vendor-neutral:
129
+ // `--caller-id` / PEAKS_CALLER_ID beat the IDE adapter, so a host that
130
+ // is not Claude Code can still build a lease.
131
+ const boundSessionId = getSessionId(projectRoot);
132
+ if (boundSessionId === null) {
133
+ printSessionNotBound(io, options, name, projectRoot);
134
+ return;
135
+ }
136
+ const callerId = resolveSetCallerId(io, options, { name, projectRoot });
137
+ if (callerId === null)
138
+ return;
139
+ // The canonical write is AWAITED: the command has to know whether the
140
+ // lease (and the graph it names) actually landed BEFORE it reports
141
+ // success. A failure here is reported as a failure.
142
+ let presence;
143
+ try {
144
+ presence = await setSkillPresence(name, options.mode, options.gate, {
145
+ projectRootOverride: projectOption,
146
+ callerIdOverride: callerId
147
+ });
148
+ }
149
+ catch (error) {
150
+ printWriteFailure(io, options, { name, projectRoot }, error);
151
+ return;
152
+ }
153
+ // Session metadata is updated when a session is bound (read-only path:
154
+ // `getSessionId`). We do not auto-spawn a session. The resolved callerId
155
+ // is recorded as the session's outer-session id so a later read can tell
156
+ // the recorded presence belongs to this caller.
157
+ if (boundSessionId !== null) {
158
+ setSessionMeta(projectRoot, boundSessionId, {
159
+ skill: name,
160
+ ...(options.mode ? { mode: options.mode } : {}),
161
+ ...(options.gate ? { gate: options.gate } : {}),
162
+ outerSessionId: callerId
163
+ });
164
+ }
165
+ printResult(io, ok('skill.presence:set', { active: true, ...presence }), options.json);
166
+ }
167
+ export function registerSkillPresenceSetCommand(skill, io) {
168
+ addJsonOption(skill
169
+ .command('presence:set <name>')
170
+ .description(PRESENCE_SET_DESCRIPTION)
171
+ .option('--mode <mode>', PRESENCE_SET_MODE_HELP)
172
+ .option('--gate <gate>', PRESENCE_SET_GATE_HELP)
173
+ .option('--caller-id <id>', PRESENCE_SET_CALLER_ID_HELP)
174
+ .option('--project <path>', PRESENCE_SET_PROJECT_HELP)).action((name, options) => runSkillPresenceSet(name, options, io));
175
+ }
@@ -1,22 +1,44 @@
1
1
  import { summarizeProjectStandardsInitResult, summarizeProjectStandardsUpdateResult } from '../../../services/standards/project-standards-service.js';
2
2
  import { executeProjectStandardsInitIdeAware, executeProjectStandardsUpdateIdeAware } from '../../../services/standards/ide-aware-standards-service.js';
3
+ import { listAdapterIds } from '../../../services/ide/ide-registry.js';
3
4
  import { fail, ok } from 'peaks-loop-shared/result';
4
5
  import { addJsonOption, getErrorMessage, printResult } from '../../cli-helpers.js';
6
+ /**
7
+ * The registered IDE ids `--ide` accepts.
8
+ *
9
+ * Read from the registry rather than re-typed here: a hand-written list of
10
+ * ids is a second copy of the registry, and the copy that shipped with this
11
+ * command was missing `hermes`, `openclaw` and `zcode` — so `--ide zcode`
12
+ * used to reach `getAdapter()` and throw instead of being accepted.
13
+ */
14
+ const SUPPORTED_IDE_IDS = listAdapterIds();
5
15
  /** The five flags `init` and `update` share, in registration order. */
6
16
  function withWriteFlags(cmd, applyHelp) {
7
17
  return cmd
8
18
  .requiredOption('--project <path>', 'target project root')
9
19
  .option('--language <language>', 'standards language pack')
10
- .option('--ide <id>', 'override IDE detection (e.g. claude-code, trae)')
20
+ .option('--ide <id>', `override IDE detection; the IDE's standards profile decides which instruction files are written (${SUPPORTED_IDE_IDS.join(' | ')})`)
11
21
  .option('--dry-run', 'preview writes without changing files')
12
22
  .option('--apply', applyHelp);
13
23
  }
24
+ /**
25
+ * The `--ide` value, validated against the registry.
26
+ *
27
+ * `null` means "not a registered IDE" — the caller refuses with a
28
+ * structured envelope instead of letting the value reach `getAdapter()`,
29
+ * where an unknown id throws an unhandled error.
30
+ */
31
+ function resolveIdeId(value) {
32
+ if (value === undefined)
33
+ return null;
34
+ return SUPPORTED_IDE_IDS.find((id) => id === value) ?? null;
35
+ }
14
36
  /** The ide-aware request both verbs build from the same flag set. */
15
- function buildIdeAwareRequest(options) {
37
+ function buildIdeAwareRequest(options, ideId) {
16
38
  return {
17
39
  projectRoot: options.project,
18
40
  ...(options.language !== undefined ? { language: options.language } : {}),
19
- ...(options.ide !== undefined ? { ideId: options.ide } : {}),
41
+ ...(ideId !== null ? { ideId } : {}),
20
42
  apply: options.apply === true
21
43
  };
22
44
  }
@@ -28,6 +50,14 @@ function refuseConflictingFlags(io, options, refusal) {
28
50
  process.exitCode = 1;
29
51
  return true;
30
52
  }
53
+ /** Refuse an `--ide` value no adapter is registered under. */
54
+ function refuseUnknownIde(io, options, command, ideId) {
55
+ if (options.ide === undefined || ideId !== null)
56
+ return false;
57
+ printResult(io, fail(command, 'UNKNOWN_IDE', `Unknown IDE '${options.ide}'.`, { ide: options.ide, supportedIdeIds: SUPPORTED_IDE_IDS }, [`Pass one of: ${SUPPORTED_IDE_IDS.join(', ')}.`]), options.json);
58
+ process.exitCode = 1;
59
+ return true;
60
+ }
31
61
  function runStandardsInit(io, options) {
32
62
  const refused = refuseConflictingFlags(io, options, {
33
63
  command: 'standards.init',
@@ -38,8 +68,11 @@ function runStandardsInit(io, options) {
38
68
  });
39
69
  if (refused)
40
70
  return;
71
+ const ideId = resolveIdeId(options.ide);
72
+ if (refuseUnknownIde(io, options, 'standards.init', ideId))
73
+ return;
41
74
  try {
42
- const result = executeProjectStandardsInitIdeAware(buildIdeAwareRequest(options));
75
+ const result = executeProjectStandardsInitIdeAware(buildIdeAwareRequest(options, ideId));
43
76
  printResult(io, ok('standards.init', summarizeProjectStandardsInitResult(result)), options.json);
44
77
  }
45
78
  catch (error) {
@@ -59,8 +92,11 @@ function runStandardsUpdate(io, options) {
59
92
  });
60
93
  if (refused)
61
94
  return;
95
+ const ideId = resolveIdeId(options.ide);
96
+ if (refuseUnknownIde(io, options, 'standards.update', ideId))
97
+ return;
62
98
  try {
63
- const result = executeProjectStandardsUpdateIdeAware(buildIdeAwareRequest(options));
99
+ const result = executeProjectStandardsUpdateIdeAware(buildIdeAwareRequest(options, ideId));
64
100
  const summary = summarizeProjectStandardsUpdateResult(result);
65
101
  const response = summary.reviewSuggestions.length > 0
66
102
  ? fail('standards.update', 'STANDARDS_UPDATE_REVIEW_REQUIRED', 'Standards update requires manual review', summary, summary.reviewSuggestions)
@@ -72,7 +108,7 @@ function runStandardsUpdate(io, options) {
72
108
  }
73
109
  catch (error) {
74
110
  printResult(io, fail('standards.update', 'STANDARDS_UPDATE_FAILED', getErrorMessage(error), {}, [
75
- 'Check the project path, CLAUDE.md contents, and existing .claude/rules directory before retrying'
111
+ 'Check the project path, AGENTS.md contents, and existing .claude/rules directory before retrying'
76
112
  ]), options.json);
77
113
  process.exitCode = 1;
78
114
  }
@@ -80,8 +116,8 @@ function runStandardsUpdate(io, options) {
80
116
  export function registerStandardsInitCommands(standards, io) {
81
117
  addJsonOption(withWriteFlags(standards
82
118
  .command('init')
83
- .description('Initialize project-local coding standards for Peaks skill preflight'), 'write missing standards into the target project')).action((options) => runStandardsInit(io, options));
119
+ .description('Initialize project-local coding standards for Peaks skill preflight (AGENTS.md body + the CLAUDE.md pointer that imports it)'), 'write missing standards into the target project')).action((options) => runStandardsInit(io, options));
84
120
  addJsonOption(withWriteFlags(standards
85
121
  .command('update')
86
- .description('Append managed standards metadata to an existing CLAUDE.md without rewriting the body'), 'append managed metadata to the target project')).action((options) => runStandardsUpdate(io, options));
122
+ .description('Append managed standards metadata to the existing AGENTS.md / CLAUDE.md without rewriting their bodies'), 'append managed metadata to the target project')).action((options) => runStandardsUpdate(io, options));
87
123
  }