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.
- package/.claude-plugin/marketplace.json +2 -2
- package/CHANGELOG.md +126 -0
- package/README-en.md +6 -0
- package/README.md +5 -0
- package/contracts/test-style-contract.md +14 -5
- package/dist/cli/commands/audit-red-lines-runners.js +6 -1
- package/dist/cli/commands/best-practice-scan-collision.d.ts +42 -0
- package/dist/cli/commands/best-practice-scan-collision.js +115 -0
- package/dist/cli/commands/best-practice-scan-command.d.ts +5 -0
- package/dist/cli/commands/best-practice-scan-command.js +9 -18
- package/dist/cli/commands/best-practice-scan-helpers.d.ts +12 -6
- package/dist/cli/commands/best-practice-scan-helpers.js +37 -17
- package/dist/cli/commands/code-auto-compact-command.js +26 -18
- package/dist/cli/commands/core/skill-generated-config-notice.d.ts +5 -0
- package/dist/cli/commands/core/skill-generated-config-notice.js +42 -8
- package/dist/cli/commands/core/skill-presence-commands.js +42 -74
- package/dist/cli/commands/core/skill-presence-set-command.d.ts +11 -0
- package/dist/cli/commands/core/skill-presence-set-command.js +175 -0
- package/dist/cli/commands/core/standards-init-command.js +44 -8
- package/dist/cli/commands/core/standards-migrate-command.js +5 -4
- package/dist/cli/commands/dispatch-dag-runners.d.ts +1 -0
- package/dist/cli/commands/dispatch-dag-runners.js +11 -1
- package/dist/cli/commands/dispatch-detached-branch.js +19 -1
- package/dist/cli/commands/mut-commands-helpers.d.ts +72 -5
- package/dist/cli/commands/mut-commands-helpers.js +197 -4
- package/dist/cli/commands/mut-commands.d.ts +9 -1
- package/dist/cli/commands/mut-commands.js +82 -154
- package/dist/cli/commands/preferences-commands.js +27 -2
- package/dist/cli/commands/scan-scope-helpers.js +2 -2
- package/dist/services/24h-mode/auto-engage.d.ts +11 -3
- package/dist/services/24h-mode/auto-engage.js +14 -6
- package/dist/services/artifacts/artifact-templates.js +10 -0
- package/dist/services/artifacts/backcompat-acceptance.d.ts +8 -1
- package/dist/services/artifacts/backcompat-acceptance.js +8 -7
- package/dist/services/artifacts/rd-transition-gates.d.ts +32 -5
- package/dist/services/artifacts/rd-transition-gates.js +96 -19
- package/dist/services/artifacts/request-artifact-service.js +6 -6
- package/dist/services/audit/enforcers/lint-output-style.js +14 -2
- package/dist/services/audit/enforcers/root-scratch-artifacts.d.ts +46 -0
- package/dist/services/audit/enforcers/root-scratch-artifacts.js +97 -0
- package/dist/services/audit/static-service.js +4 -4
- package/dist/services/code/auto-compact-history.d.ts +6 -1
- package/dist/services/code/auto-compact-history.js +6 -1
- package/dist/services/code/auto-compact-modes.d.ts +60 -14
- package/dist/services/code/auto-compact-modes.js +75 -20
- package/dist/services/code/auto-compact-profile.d.ts +23 -0
- package/dist/services/code/auto-compact-profile.js +51 -0
- package/dist/services/compact-history/compact-history-service.d.ts +6 -1
- package/dist/services/compact-history/compact-history-service.js +5 -1
- package/dist/services/context/auto-compact-types.d.ts +7 -5
- package/dist/services/doctor/doctor-service/checks/l3-runtime-root-census.d.ts +37 -0
- package/dist/services/doctor/doctor-service/checks/l3-runtime-root-census.js +100 -0
- package/dist/services/doctor/doctor-service/checks/skill-reference-parity.d.ts +11 -3
- package/dist/services/doctor/doctor-service/checks/skill-reference-parity.js +48 -29
- package/dist/services/doctor/doctor-service/plugin-registry.js +2 -0
- package/dist/services/hooks/hook-payload-cwd.d.ts +11 -4
- package/dist/services/hooks/hook-payload-cwd.js +11 -4
- package/dist/services/hooks/presence-marker-detector.d.ts +3 -0
- package/dist/services/hooks/presence-marker-detector.js +21 -19
- package/dist/services/ide/adapters/claude-code-adapter.js +6 -8
- package/dist/services/ide/adapters/codex-adapter.js +23 -7
- package/dist/services/ide/adapters/cursor-adapter.js +23 -7
- package/dist/services/mode/mode-status-service.d.ts +26 -27
- package/dist/services/mode/mode-status-service.js +36 -60
- package/dist/services/preferences/preferences-types.d.ts +30 -0
- package/dist/services/preferences/preferences-types.js +13 -0
- package/dist/services/scan/acceptance-coverage-service.d.ts +14 -11
- package/dist/services/scan/acceptance-coverage-service.js +157 -52
- package/dist/services/scan/rid-change-claims.d.ts +15 -0
- package/dist/services/scan/rid-change-claims.js +116 -0
- package/dist/services/skills/presence-caller-id.d.ts +51 -0
- package/dist/services/skills/presence-caller-id.js +43 -0
- package/dist/services/skills/presence-gate.d.ts +65 -0
- package/dist/services/skills/presence-gate.js +113 -0
- package/dist/services/skills/presence-lease-resolver.d.ts +63 -0
- package/dist/services/skills/presence-lease-resolver.js +114 -0
- package/dist/services/skills/presence-lease-selection.d.ts +91 -0
- package/dist/services/skills/presence-lease-selection.js +135 -0
- package/dist/services/skills/presence-lease-service.d.ts +3 -11
- package/dist/services/skills/presence-lease-service.js +34 -87
- package/dist/services/skills/presence-lease-store.d.ts +33 -0
- package/dist/services/skills/presence-lease-store.js +94 -0
- package/dist/services/skills/presence-lease-types.d.ts +31 -0
- package/dist/services/skills/presence-lease-types.js +27 -0
- package/dist/services/skills/presence-role.d.ts +35 -0
- package/dist/services/skills/presence-role.js +72 -0
- package/dist/services/skills/skill-presence-service.d.ts +39 -9
- package/dist/services/skills/skill-presence-service.js +143 -174
- package/dist/services/skills/skill-presence-write.d.ts +60 -0
- package/dist/services/skills/skill-presence-write.js +74 -0
- package/dist/services/skills/skill-statusline-service.js +7 -7
- package/dist/services/standards/ide-aware-standards-service.d.ts +35 -23
- package/dist/services/standards/ide-aware-standards-service.js +45 -20
- package/dist/services/standards/migrate-claude-rules-service.d.ts +6 -0
- package/dist/services/standards/migrate-claude-rules-service.js +18 -0
- package/dist/services/standards/migrate-service.d.ts +1 -1
- package/dist/services/standards/migrate-service.js +27 -7
- package/dist/services/standards/project-scripts.d.ts +25 -0
- package/dist/services/standards/project-scripts.js +116 -0
- package/dist/services/standards/project-standards-service.d.ts +23 -15
- package/dist/services/standards/project-standards-service.js +176 -243
- package/dist/services/standards/standards-constitution.d.ts +89 -0
- package/dist/services/standards/standards-constitution.js +199 -0
- package/dist/services/standards/standards-files.d.ts +37 -0
- package/dist/services/standards/standards-files.js +138 -0
- package/dist/services/standards/standards-pointer.d.ts +73 -0
- package/dist/services/standards/standards-pointer.js +98 -0
- package/dist/services/standards/standards-render-agents.d.ts +34 -0
- package/dist/services/standards/standards-render-agents.js +149 -0
- package/dist/services/standards/standards-render-common.d.ts +38 -1
- package/dist/services/standards/standards-render-common.js +44 -7
- package/dist/services/standards/standards-render.d.ts +1 -3
- package/dist/services/standards/standards-render.js +6 -87
- package/dist/services/workflow/workflow-graph-ensure.d.ts +77 -0
- package/dist/services/workflow/workflow-graph-ensure.js +97 -0
- package/dist/services/workflow/workflow-presence-lifecycle.js +21 -6
- package/dist/services/workspace/generated-artifacts-content.d.ts +46 -0
- package/dist/services/workspace/generated-artifacts-content.js +167 -0
- package/dist/services/workspace/generated-artifacts-stamp.d.ts +36 -13
- package/dist/services/workspace/generated-artifacts-stamp.js +37 -15
- package/dist/services/workspace/runtime-layout.d.ts +64 -0
- package/dist/services/workspace/runtime-layout.js +62 -0
- package/output-styles/peaks-skill-swarm.md +18 -2
- package/package.json +8 -9
- package/schemas/doctor-report.schema.json +1 -1
- package/skills/bee/peaks-perf-audit/SKILL.md +3 -1
- package/skills/bee/peaks-prd/SKILL.md +5 -3
- package/skills/bee/peaks-qa/SKILL.md +4 -2
- package/skills/bee/peaks-qa/references/qa-skill-presence.md +1 -1
- package/skills/bee/peaks-qa/references/qa-standards-preflight.md +3 -1
- package/skills/bee/peaks-qa/references/qa-sub-agent-dispatch.md +2 -2
- package/skills/bee/peaks-rd/SKILL.md +4 -2
- package/skills/bee/peaks-rd/references/artifact-and-standards-output.md +1 -1
- package/skills/bee/peaks-rd/references/rd-runbook.md +11 -2
- package/skills/bee/peaks-rd/references/rd-standards-preflight.md +3 -1
- package/skills/bee/peaks-rd/references/rd-sub-agent-dispatch.md +4 -4
- package/skills/bee/peaks-rd/references/rd-transition-gates.md +49 -5
- package/skills/bee/peaks-rd/references/skill-presence-and-title.md +1 -1
- package/skills/bee/peaks-reviewer/SKILL.md +3 -1
- package/skills/bee/peaks-sc/SKILL.md +4 -2
- package/skills/bee/peaks-security-audit/SKILL.md +3 -1
- package/skills/bee/peaks-txt/SKILL.md +5 -3
- package/skills/bee/peaks-ui/SKILL.md +6 -4
- package/skills/peaks-audit/SKILL.md +3 -1
- package/skills/peaks-code/SKILL.md +3 -1
- package/skills/peaks-code/references/a2a-artifact-mapping.md +3 -3
- package/skills/peaks-code/references/completion-handoff.md +1 -1
- package/skills/peaks-code/references/local-artifact-workspace.md +10 -11
- package/skills/peaks-code/references/micro-cycle.md +2 -2
- package/skills/peaks-code/references/mode-selection-with-stale-presence.md +3 -3
- package/skills/peaks-code/references/runbook.md +4 -4
- package/skills/peaks-code/references/skill-presence-and-title.md +4 -2
- package/skills/peaks-code/references/standards-preflight.md +7 -6
- package/skills/peaks-code/references/sub-agent-dispatch.md +1 -1
- package/skills/peaks-code/references/swarm-dispatch-contract.md +5 -5
- package/skills/peaks-code/references/workflow-gates-and-types.md +37 -11
- package/skills/peaks-content/SKILL.md +3 -1
- package/skills/peaks-doctor/SKILL.md +3 -1
- package/skills/peaks-final-review/SKILL.md +3 -1
- package/skills/peaks-ide/SKILL.md +3 -1
- package/skills/peaks-issue-fix-orchestrator/SKILL.md +5 -3
- package/skills/peaks-race-code/SKILL.md +3 -1
- package/skills/peaks-resume/SKILL.md +3 -1
- package/skills/peaks-slice-decompose/SKILL.md +3 -1
- package/skills/peaks-solo/SKILL.md +3 -1
- package/skills/peaks-sop/SKILL.md +4 -2
- package/skills/peaks-status/SKILL.md +3 -1
- package/skills/peaks-test/SKILL.md +3 -1
|
@@ -12,11 +12,17 @@
|
|
|
12
12
|
* that chains back to TACT.sig via the `inputSig` field.
|
|
13
13
|
* - KISS: keep the public surface narrow — run / mutants / asserts /
|
|
14
14
|
* report. The CLI is a thin orchestrator over the service layer.
|
|
15
|
+
*
|
|
16
|
+
* The three subcommands that drive the mutation pipeline (`run`, `mutants`,
|
|
17
|
+
* `asserts`) live in `mut-commands-helpers.ts`; this file assembles them
|
|
18
|
+
* and owns `report` — a pure reader of an already-written file. The split
|
|
19
|
+
* keeps `createMutCommands` inside the `max-lines-per-function` budget
|
|
20
|
+
* (50 code lines); it measured 209 before the split.
|
|
15
21
|
*/
|
|
16
22
|
import { readFile } from 'node:fs/promises';
|
|
17
23
|
import { Command } from 'commander';
|
|
18
|
-
import {
|
|
19
|
-
import {
|
|
24
|
+
import { createProductionStrykerInvoker, MutReportSchema } from 'peaks-loop-mut';
|
|
25
|
+
import { buildMutAssertsCommand, buildMutMutantsCommand, buildMutRunCommand, DEFAULT_MUT_IO } from './mut-commands-helpers.js';
|
|
20
26
|
/**
|
|
21
27
|
* Construct the `peaks mut` family as a standalone Commander command.
|
|
22
28
|
* Returns the parent `mut` Command so callers can attach it under any
|
|
@@ -24,170 +30,92 @@ import { emitSummary, emptyAssertions, emptyMutation } from './mut-commands-help
|
|
|
24
30
|
* directly by the unit tests).
|
|
25
31
|
*/
|
|
26
32
|
export function createMutCommands(opts) {
|
|
33
|
+
const io = opts.io ?? DEFAULT_MUT_IO;
|
|
27
34
|
const mut = new Command('mut').description('peaks-mut: mutation testing + assertion validity scan (spec §4.2 / §7)');
|
|
28
|
-
mut
|
|
29
|
-
|
|
30
|
-
|
|
31
|
-
|
|
32
|
-
|
|
33
|
-
|
|
34
|
-
|
|
35
|
-
|
|
36
|
-
|
|
37
|
-
|
|
38
|
-
|
|
39
|
-
|
|
40
|
-
|
|
41
|
-
|
|
42
|
-
|
|
43
|
-
|
|
44
|
-
|
|
45
|
-
|
|
46
|
-
|
|
47
|
-
|
|
48
|
-
|
|
49
|
-
|
|
50
|
-
|
|
51
|
-
assertions
|
|
52
|
-
});
|
|
53
|
-
emitSummary(a.json, {
|
|
54
|
-
ok: true,
|
|
55
|
-
sha256: report.sha256,
|
|
56
|
-
passed: report.thresholds.passed,
|
|
57
|
-
path: a.out
|
|
58
|
-
});
|
|
59
|
-
if (!report.thresholds.passed) {
|
|
60
|
-
// H6: CLI裁决 — threshold breach is a non-zero exit so callers
|
|
61
|
-
// (peaks-rd, peaks-qa, CI) can block on it without parsing
|
|
62
|
-
// stdout.
|
|
63
|
-
process.exitCode = 1;
|
|
64
|
-
}
|
|
65
|
-
});
|
|
66
|
-
mut
|
|
67
|
-
.command('mutants')
|
|
68
|
-
.description('Run Stryker only; write a stub-assertions mut-report.json. One-axis: --session-id required.')
|
|
69
|
-
.requiredOption('--project <path>', 'project root')
|
|
70
|
-
.requiredOption('--test-files <files...>', 'test files to mutate against')
|
|
71
|
-
.requiredOption('--input-sig <hex>', 'TACT.sig')
|
|
72
|
-
.requiredOption('--session-id <sid>', 'session id')
|
|
73
|
-
.requiredOption('--out <path>', 'output path for mut-report.json')
|
|
74
|
-
.option('--json', 'machine-readable output', false)
|
|
75
|
-
.action(async (a) => {
|
|
76
|
-
const { mutation } = await runMutation({
|
|
77
|
-
project: a.project,
|
|
78
|
-
testFiles: a.testFiles,
|
|
79
|
-
invokeStryker: opts.invokeStryker
|
|
80
|
-
});
|
|
81
|
-
const report = await buildMutReport({
|
|
82
|
-
inputSig: a.inputSig,
|
|
83
|
-
out: a.out,
|
|
84
|
-
mutation,
|
|
85
|
-
assertions: emptyAssertions()
|
|
86
|
-
});
|
|
87
|
-
emitSummary(a.json, {
|
|
88
|
-
ok: true,
|
|
89
|
-
sha256: report.sha256,
|
|
90
|
-
passed: report.thresholds.passed,
|
|
91
|
-
path: a.out
|
|
92
|
-
});
|
|
93
|
-
if (!report.thresholds.passed) {
|
|
94
|
-
process.exitCode = 1;
|
|
95
|
-
}
|
|
96
|
-
});
|
|
97
|
-
mut
|
|
98
|
-
.command('asserts')
|
|
99
|
-
.description('Run the assertion scan only; write a mut-report.json with empty mutation block. One-axis: --session-id required.')
|
|
100
|
-
.requiredOption('--project <path>', 'project root')
|
|
101
|
-
.requiredOption('--test-files <files...>', 'test files to scan')
|
|
102
|
-
.requiredOption('--input-sig <hex>', 'TACT.sig')
|
|
103
|
-
.requiredOption('--session-id <sid>', 'session id')
|
|
104
|
-
.requiredOption('--out <path>', 'output path for mut-report.json')
|
|
105
|
-
.option('--json', 'machine-readable output', false)
|
|
106
|
-
.action(async (a) => {
|
|
107
|
-
const assertions = await scanAssertions({
|
|
108
|
-
project: a.project,
|
|
109
|
-
testFiles: a.testFiles
|
|
110
|
-
});
|
|
111
|
-
const report = await buildMutReport({
|
|
112
|
-
inputSig: a.inputSig,
|
|
113
|
-
out: a.out,
|
|
114
|
-
mutation: emptyMutation(),
|
|
115
|
-
assertions
|
|
116
|
-
});
|
|
117
|
-
emitSummary(a.json, {
|
|
118
|
-
ok: true,
|
|
119
|
-
sha256: report.sha256,
|
|
120
|
-
passed: report.thresholds.passed,
|
|
121
|
-
path: a.out
|
|
122
|
-
});
|
|
123
|
-
if (!report.thresholds.passed) {
|
|
124
|
-
process.exitCode = 1;
|
|
125
|
-
}
|
|
126
|
-
});
|
|
127
|
-
mut
|
|
128
|
-
.command('report')
|
|
35
|
+
mut.addCommand(buildMutRunCommand(opts.invokeStryker, io));
|
|
36
|
+
mut.addCommand(buildMutMutantsCommand(opts.invokeStryker, io));
|
|
37
|
+
mut.addCommand(buildMutAssertsCommand(io));
|
|
38
|
+
mut.addCommand(buildMutReportCommand(io));
|
|
39
|
+
return mut;
|
|
40
|
+
}
|
|
41
|
+
/**
|
|
42
|
+
* Program-level wiring: attach the `peaks mut` family to the root
|
|
43
|
+
* program with the production Stryker invoker. Tests should use
|
|
44
|
+
* `createMutCommands({ invokeStryker })` instead so the heavy
|
|
45
|
+
* @stryker-mutator/core runtime stays out of the unit-test path.
|
|
46
|
+
*/
|
|
47
|
+
export function registerMutCommands(program, io) {
|
|
48
|
+
const invokeStryker = createProductionStrykerInvoker();
|
|
49
|
+
program.addCommand(createMutCommands({ invokeStryker, io }));
|
|
50
|
+
}
|
|
51
|
+
/**
|
|
52
|
+
* `peaks mut report` — re-read a previously-written mut-report.json (no
|
|
53
|
+
* Stryker / scan invocation). One-axis: --session-id required for the
|
|
54
|
+
* audit trail.
|
|
55
|
+
*/
|
|
56
|
+
export function buildMutReportCommand(io) {
|
|
57
|
+
return new Command('report')
|
|
129
58
|
.description('Re-read a previously-written mut-report.json (no Stryker / scan invocation). One-axis: --session-id required for the audit trail.')
|
|
130
59
|
.requiredOption('--in <path>', 'input mut-report.json path')
|
|
131
60
|
.requiredOption('--session-id <sid>', 'session id')
|
|
132
61
|
.option('--json', 'machine-readable output', false)
|
|
133
62
|
.action(async (a) => {
|
|
134
|
-
const
|
|
135
|
-
|
|
136
|
-
|
|
137
|
-
|
|
138
|
-
}
|
|
139
|
-
catch (err) {
|
|
140
|
-
process.stderr.write(`INVALID_JSON: ${err instanceof Error ? err.message : String(err)}\n`);
|
|
141
|
-
process.exitCode = 2;
|
|
63
|
+
const read = await readMutReportForDisplay(a.in);
|
|
64
|
+
if (!read.ok) {
|
|
65
|
+
io.stderr(read.message);
|
|
66
|
+
process.exitCode = read.exitCode;
|
|
142
67
|
return;
|
|
143
68
|
}
|
|
144
|
-
|
|
145
|
-
if (!
|
|
146
|
-
process.stderr.write(`INVALID: ${parsed.error.message}\n`);
|
|
147
|
-
process.exitCode = 2;
|
|
148
|
-
return;
|
|
149
|
-
}
|
|
150
|
-
const r = parsed.data;
|
|
151
|
-
const summary = {
|
|
152
|
-
mutation: {
|
|
153
|
-
tool: r.mutation.tool,
|
|
154
|
-
killRate: r.mutation.killRate
|
|
155
|
-
},
|
|
156
|
-
assertions: {
|
|
157
|
-
total: r.assertions.totalAssertions,
|
|
158
|
-
weak: r.assertions.weakAssertions,
|
|
159
|
-
weakRate: r.assertions.weakRate
|
|
160
|
-
},
|
|
161
|
-
thresholds: { passed: r.thresholds.passed },
|
|
162
|
-
followups: r.followups.length,
|
|
163
|
-
sha256: r.sha256,
|
|
164
|
-
sessionId: a.sessionId
|
|
165
|
-
};
|
|
166
|
-
if (a.json) {
|
|
167
|
-
process.stdout.write(JSON.stringify(summary) + '\n');
|
|
168
|
-
}
|
|
169
|
-
else {
|
|
170
|
-
process.stdout.write([
|
|
171
|
-
`mutation: tool=${r.mutation.tool} killRate=${(r.mutation.killRate * 100).toFixed(1)}%`,
|
|
172
|
-
`assertions: total=${r.assertions.totalAssertions} weak=${r.assertions.weakAssertions} rate=${(r.assertions.weakRate * 100).toFixed(1)}%`,
|
|
173
|
-
`thresholds: passed=${r.thresholds.passed}`,
|
|
174
|
-
`followups: ${r.followups.length}`,
|
|
175
|
-
`sha256: ${r.sha256}`
|
|
176
|
-
].join('\n') + '\n');
|
|
177
|
-
}
|
|
178
|
-
if (!r.thresholds.passed) {
|
|
69
|
+
renderMutReportSummary(io, read.report, a.sessionId, a.json);
|
|
70
|
+
if (!read.report.thresholds.passed) {
|
|
179
71
|
process.exitCode = 1;
|
|
180
72
|
}
|
|
181
73
|
});
|
|
182
|
-
return mut;
|
|
183
74
|
}
|
|
184
75
|
/**
|
|
185
|
-
*
|
|
186
|
-
*
|
|
187
|
-
*
|
|
188
|
-
* @stryker-mutator/core runtime stays out of the unit-test path.
|
|
76
|
+
* Read + validate a mut-report.json. A malformed file is a display
|
|
77
|
+
* failure (exit code 2), not a crash — the original `report` subcommand
|
|
78
|
+
* behaved that way and the behavior is preserved.
|
|
189
79
|
*/
|
|
190
|
-
|
|
191
|
-
const
|
|
192
|
-
|
|
80
|
+
async function readMutReportForDisplay(inPath) {
|
|
81
|
+
const raw = await readFile(inPath, 'utf8');
|
|
82
|
+
let parsedJson;
|
|
83
|
+
try {
|
|
84
|
+
parsedJson = JSON.parse(raw);
|
|
85
|
+
}
|
|
86
|
+
catch (err) {
|
|
87
|
+
const detail = err instanceof Error ? err.message : String(err);
|
|
88
|
+
return { ok: false, exitCode: 2, message: `INVALID_JSON: ${detail}` };
|
|
89
|
+
}
|
|
90
|
+
const parsed = MutReportSchema.safeParse(parsedJson);
|
|
91
|
+
if (!parsed.success) {
|
|
92
|
+
return { ok: false, exitCode: 2, message: `INVALID: ${parsed.error.message}` };
|
|
93
|
+
}
|
|
94
|
+
return { ok: true, report: parsed.data };
|
|
95
|
+
}
|
|
96
|
+
/** Render the report summary as one JSON line or a human-readable block. */
|
|
97
|
+
function renderMutReportSummary(io, report, sessionId, json) {
|
|
98
|
+
const summary = {
|
|
99
|
+
mutation: { tool: report.mutation.tool, killRate: report.mutation.killRate },
|
|
100
|
+
assertions: {
|
|
101
|
+
total: report.assertions.totalAssertions,
|
|
102
|
+
weak: report.assertions.weakAssertions,
|
|
103
|
+
weakRate: report.assertions.weakRate
|
|
104
|
+
},
|
|
105
|
+
thresholds: { passed: report.thresholds.passed },
|
|
106
|
+
followups: report.followups.length,
|
|
107
|
+
sha256: report.sha256,
|
|
108
|
+
sessionId
|
|
109
|
+
};
|
|
110
|
+
if (json) {
|
|
111
|
+
io.stdout(JSON.stringify(summary));
|
|
112
|
+
return;
|
|
113
|
+
}
|
|
114
|
+
io.stdout([
|
|
115
|
+
`mutation: tool=${report.mutation.tool} killRate=${(report.mutation.killRate * 100).toFixed(1)}%`,
|
|
116
|
+
`assertions: total=${report.assertions.totalAssertions} weak=${report.assertions.weakAssertions} rate=${(report.assertions.weakRate * 100).toFixed(1)}%`,
|
|
117
|
+
`thresholds: passed=${report.thresholds.passed}`,
|
|
118
|
+
`followups: ${report.followups.length}`,
|
|
119
|
+
`sha256: ${report.sha256}`
|
|
120
|
+
].join('\n'));
|
|
193
121
|
}
|
|
@@ -1,6 +1,8 @@
|
|
|
1
1
|
import { existsSync, mkdirSync, readFileSync, renameSync, writeFileSync } from 'node:fs';
|
|
2
2
|
import { dirname } from 'node:path';
|
|
3
3
|
import { loadPreferences, migratePreferences, preferencesPath, savePreferences } from '../../services/preferences/preferences-service.js';
|
|
4
|
+
import { AUTO_COMPACT_PROFILE_VALUES, isAutoCompactProfile } from '../../services/preferences/preferences-types.js';
|
|
5
|
+
import { normalizeAutoCompactMode } from '../../services/code/auto-compact-modes.js';
|
|
4
6
|
const ALLOWED_KEYS = new Set([
|
|
5
7
|
'economyMode',
|
|
6
8
|
'swarmMode',
|
|
@@ -9,7 +11,8 @@ const ALLOWED_KEYS = new Set([
|
|
|
9
11
|
'classifyConservatism',
|
|
10
12
|
'classifyRules',
|
|
11
13
|
'swarmSpeculative',
|
|
12
|
-
'loopAutonomousEnabled'
|
|
14
|
+
'loopAutonomousEnabled',
|
|
15
|
+
'autoCompactProfile'
|
|
13
16
|
]);
|
|
14
17
|
/**
|
|
15
18
|
* Stable, sorted list of allowed preference keys. Used in error messages
|
|
@@ -31,6 +34,28 @@ const ALLOWED_KEYS_LIST = Array.from(ALLOWED_KEYS).sort();
|
|
|
31
34
|
function unknownKeyError(key) {
|
|
32
35
|
return new Error(`PREFERENCES_KEY_UNKNOWN: ${key}. Allowed keys: ${ALLOWED_KEYS_LIST.join(', ')}.`);
|
|
33
36
|
}
|
|
37
|
+
/**
|
|
38
|
+
* The value guard for `autoCompactProfile`.
|
|
39
|
+
*
|
|
40
|
+
* An illegal value is REJECTED with the legal ones named — it is never
|
|
41
|
+
* silently coerced to the default, because a silently-coerced profile is a
|
|
42
|
+
* cadence the operator did not ask for and cannot see.
|
|
43
|
+
*
|
|
44
|
+
* The legacy alias `partial` is accepted here too and stored in its
|
|
45
|
+
* canonical form (`eager`), so the file on disk only ever carries a
|
|
46
|
+
* canonical profile.
|
|
47
|
+
*/
|
|
48
|
+
function normalizeAutoCompactProfileValue(key, value) {
|
|
49
|
+
if (key !== 'autoCompactProfile')
|
|
50
|
+
return value;
|
|
51
|
+
if (isAutoCompactProfile(value))
|
|
52
|
+
return value;
|
|
53
|
+
const alias = typeof value === 'string' ? normalizeAutoCompactMode(value) : null;
|
|
54
|
+
if (alias === null) {
|
|
55
|
+
throw new Error(`PREFERENCES_VALUE_INVALID: autoCompactProfile must be one of ${AUTO_COMPACT_PROFILE_VALUES.join(' | ')} (got ${JSON.stringify(value)}).`);
|
|
56
|
+
}
|
|
57
|
+
return alias;
|
|
58
|
+
}
|
|
34
59
|
export function registerPreferencesCommands(program) {
|
|
35
60
|
const prefs = program
|
|
36
61
|
.command('preferences')
|
|
@@ -101,7 +126,7 @@ export function registerPreferencesCommands(program) {
|
|
|
101
126
|
// Not valid JSON — keep the raw string.
|
|
102
127
|
}
|
|
103
128
|
const merged = savePreferences(opts.project, {
|
|
104
|
-
[opts.key]: parsed
|
|
129
|
+
[opts.key]: normalizeAutoCompactProfileValue(opts.key, parsed)
|
|
105
130
|
});
|
|
106
131
|
const envelope = {
|
|
107
132
|
ok: true,
|
|
@@ -23,11 +23,11 @@ export function acceptanceCoverageNextActions(result) {
|
|
|
23
23
|
export function printAcceptanceCoverageLookupFailure(io, options, result) {
|
|
24
24
|
const code = result.kind === 'prd-not-found' ? 'PRD_NOT_FOUND' : 'TEST_CASES_NOT_FOUND';
|
|
25
25
|
const message = result.kind === 'prd-not-found'
|
|
26
|
-
?
|
|
26
|
+
? result.message
|
|
27
27
|
: `QA test-cases file not found at ${result.expectedPath}`;
|
|
28
28
|
printResult(io, fail('scan.acceptance-coverage', code, message, { requestId: options.rid }, [
|
|
29
29
|
result.kind === 'prd-not-found'
|
|
30
|
-
? '
|
|
30
|
+
? 'Produce the PRD for this slice: `peaks request init --role prd --id <rid> --apply --type <type>` writes prd/requests/<rid>.md, and a handoff capsule at prd/handoff-<rid>.md is read as the fallback.'
|
|
31
31
|
: 'Generate qa/test-cases/<rid>.md before running this check.'
|
|
32
32
|
]), options.json);
|
|
33
33
|
process.exitCode = 1;
|
|
@@ -44,9 +44,17 @@ export declare function applyAutoEngagePresenceMode(input: {
|
|
|
44
44
|
* Slice H3 (rid=h3-24h-threshold-not-wired): `no-in-flight-lease` is
|
|
45
45
|
* the common case in practice — entering `24H_ACTIVE` before any skill
|
|
46
46
|
* workflow has a lease — and it used to be reported only inside
|
|
47
|
-
* `data.presenceMode`, where nothing read it.
|
|
48
|
-
*
|
|
49
|
-
*
|
|
47
|
+
* `data.presenceMode`, where nothing read it.
|
|
48
|
+
*
|
|
49
|
+
* WHAT THIS ADVISORY SAYS ABOUT THE COMPACTION PROFILE: nothing that
|
|
50
|
+
* contradicts the product. The auto-compact profile is a PUBLIC choice
|
|
51
|
+
* (`autoCompactProfile` in `.peaks/preferences.json`, or an explicit
|
|
52
|
+
* `--mode`), and the 24h state machine does not derive it — so the
|
|
53
|
+
* advisory reports the PRESENCE MODE, and says that the profile is the
|
|
54
|
+
* project's own setting. The claim it must not make is that the
|
|
55
|
+
* thresholds "are still derived from the 24h state machine": that turned
|
|
56
|
+
* false the moment the profile became a public, explicitly settable
|
|
57
|
+
* choice, and the wording below states the truth instead.
|
|
50
58
|
*
|
|
51
59
|
* `nextActions` address the LLM driver (it runs the CLI on the user's
|
|
52
60
|
* behalf); they never ask the user to type a verb.
|
|
@@ -51,9 +51,17 @@ export function applyAutoEngagePresenceMode(input) {
|
|
|
51
51
|
* Slice H3 (rid=h3-24h-threshold-not-wired): `no-in-flight-lease` is
|
|
52
52
|
* the common case in practice — entering `24H_ACTIVE` before any skill
|
|
53
53
|
* workflow has a lease — and it used to be reported only inside
|
|
54
|
-
* `data.presenceMode`, where nothing read it.
|
|
55
|
-
*
|
|
56
|
-
*
|
|
54
|
+
* `data.presenceMode`, where nothing read it.
|
|
55
|
+
*
|
|
56
|
+
* WHAT THIS ADVISORY SAYS ABOUT THE COMPACTION PROFILE: nothing that
|
|
57
|
+
* contradicts the product. The auto-compact profile is a PUBLIC choice
|
|
58
|
+
* (`autoCompactProfile` in `.peaks/preferences.json`, or an explicit
|
|
59
|
+
* `--mode`), and the 24h state machine does not derive it — so the
|
|
60
|
+
* advisory reports the PRESENCE MODE, and says that the profile is the
|
|
61
|
+
* project's own setting. The claim it must not make is that the
|
|
62
|
+
* thresholds "are still derived from the 24h state machine": that turned
|
|
63
|
+
* false the moment the profile became a public, explicitly settable
|
|
64
|
+
* choice, and the wording below states the truth instead.
|
|
57
65
|
*
|
|
58
66
|
* `nextActions` address the LLM driver (it runs the CLI on the user's
|
|
59
67
|
* behalf); they never ask the user to type a verb.
|
|
@@ -64,16 +72,16 @@ export function presenceModeAdvisory(result) {
|
|
|
64
72
|
if (result.reason === 'no-in-flight-lease') {
|
|
65
73
|
return {
|
|
66
74
|
warnings: [
|
|
67
|
-
'The `24h` presence mode was NOT recorded: no in-flight presence lease to stamp (`no-in-flight-lease`).
|
|
75
|
+
'The `24h` presence mode was NOT recorded: no in-flight presence lease to stamp (`no-in-flight-lease`). The auto-compact profile is NOT derived from the 24h state machine — it is the project setting `autoCompactProfile`; the mode gate and statusline will NOT see `24h`.'
|
|
68
76
|
],
|
|
69
77
|
nextActions: [
|
|
70
|
-
'Do NOT report that the
|
|
78
|
+
'Do NOT report that the compaction profile changed — the 24h mode does not decide it, and the project setting `autoCompactProfile` still governs it. If the mode gate / statusline also need to see `24h`, start the skill workflow first and then re-run `peaks session 24h-mode transition --state 24H_ACTIVE` yourself. Do not ask the user to run it.'
|
|
71
79
|
]
|
|
72
80
|
};
|
|
73
81
|
}
|
|
74
82
|
return {
|
|
75
83
|
warnings: [
|
|
76
|
-
`The \`24h\` presence mode was NOT recorded (\`${result.reason}\`).
|
|
84
|
+
`The \`24h\` presence mode was NOT recorded (\`${result.reason}\`). The auto-compact profile is NOT derived from the 24h state machine — it is the project setting \`autoCompactProfile\`; the mode gate and statusline will NOT see \`24h\`.`
|
|
77
85
|
],
|
|
78
86
|
nextActions: []
|
|
79
87
|
};
|
|
@@ -92,6 +92,16 @@ function renderRdTemplate(requestId, _sessionId, sessionId, timestamp, requestTy
|
|
|
92
92
|
${renderTypeLine(requestType)}
|
|
93
93
|
` +
|
|
94
94
|
RD_TEMPLATE_BODY +
|
|
95
|
+
// The rid's OWN changed paths, one per line, machine-readable. The
|
|
96
|
+
// declared-type rule judges THIS set instead of the whole working tree
|
|
97
|
+
// (which blamed a docs rid for another slice's src change), and the
|
|
98
|
+
// `<path>` placeholder is what the body lint refuses while it is unfilled —
|
|
99
|
+
// so an RD that never declared its paths cannot leave `draft`.
|
|
100
|
+
`## Changed paths
|
|
101
|
+
|
|
102
|
+
changedPath: <path>
|
|
103
|
+
|
|
104
|
+
` +
|
|
95
105
|
`## Handoff
|
|
96
106
|
|
|
97
107
|
- to peaks-qa: ${formatHandoffPath(sessionId, 'qa', requestId)}
|
|
@@ -33,7 +33,14 @@ import type { RequestType } from './artifact-prerequisites.js';
|
|
|
33
33
|
* accepted. `reviewBy` is DERIVED at seed time from the installed release, so a
|
|
34
34
|
* project initialized on a release boundary receives a current list rather
|
|
35
35
|
* than an already-expired one; it is bounded by the same two-minor cap the gate
|
|
36
|
-
* enforces.
|
|
36
|
+
* enforces.
|
|
37
|
+
*
|
|
38
|
+
* THE `mut/mut-report.json` WINDOW IS NOT SEEDED (retired 2026-10-24). Its
|
|
39
|
+
* stated reason was FALSE — `peaks tact read` is a registered command and
|
|
40
|
+
* `peaks mut run` produces a real mutation report — so accepting the absence
|
|
41
|
+
* would hand every new project a debt that does not exist. The WINDOW is
|
|
42
|
+
* untouched (`artifact-prerequisites.ts` still carries `backCompat: true`, so a
|
|
43
|
+
* missing report is still a soft pass); only the ACCEPTANCE of it is retired. */
|
|
37
44
|
export declare function backcompatAcceptanceSeed(installedVersion?: string): string;
|
|
38
45
|
/**
|
|
39
46
|
* Seed the tracked acceptance list for a project that has none. Idempotent: an
|
|
@@ -50,19 +50,20 @@ const REVIEW_CAP_MINORS = 2;
|
|
|
50
50
|
* accepted. `reviewBy` is DERIVED at seed time from the installed release, so a
|
|
51
51
|
* project initialized on a release boundary receives a current list rather
|
|
52
52
|
* than an already-expired one; it is bounded by the same two-minor cap the gate
|
|
53
|
-
* enforces.
|
|
53
|
+
* enforces.
|
|
54
|
+
*
|
|
55
|
+
* THE `mut/mut-report.json` WINDOW IS NOT SEEDED (retired 2026-10-24). Its
|
|
56
|
+
* stated reason was FALSE — `peaks tact read` is a registered command and
|
|
57
|
+
* `peaks mut run` produces a real mutation report — so accepting the absence
|
|
58
|
+
* would hand every new project a debt that does not exist. The WINDOW is
|
|
59
|
+
* untouched (`artifact-prerequisites.ts` still carries `backCompat: true`, so a
|
|
60
|
+
* missing report is still a soft pass); only the ACCEPTANCE of it is retired. */
|
|
54
61
|
export function backcompatAcceptanceSeed(installedVersion = CLI_VERSION) {
|
|
55
62
|
const reviewBy = reviewCapFor(installedVersion);
|
|
56
63
|
return JSON.stringify({
|
|
57
64
|
version: 1,
|
|
58
65
|
note: "Expired backCompat windows accepted for the commit leg. The LLM edits this file on the user's behalf (the user only speaks or picks); adding an entry is a reviewed diff and reviewBy is enforced against a two-minor cap.",
|
|
59
66
|
accepted: [
|
|
60
|
-
{
|
|
61
|
-
path: 'mut/mut-report.json',
|
|
62
|
-
until: 'v2.14.0',
|
|
63
|
-
reason: 'No producer in this build: peaks mut * requires --input-sig (TACT.sig), and peaks tact read is not a registered command (backlog §9.2).',
|
|
64
|
-
reviewBy
|
|
65
|
-
},
|
|
66
67
|
{
|
|
67
68
|
path: 'rd/third-party-review-<rid>.md',
|
|
68
69
|
until: 'v2.15.0',
|
|
@@ -10,17 +10,42 @@
|
|
|
10
10
|
* sources included), while the size scan measures the A/M/R/untracked subset.
|
|
11
11
|
* `qa-handoff` / `handed-off` run only the type rule (two git spawns); the size
|
|
12
12
|
* ratchet keeps the single state it has always judged.
|
|
13
|
+
*
|
|
14
|
+
* THE TYPE RULE IS SCOPED TO THE RID — WITH AN ANTI-LIE FALLBACK. A rid
|
|
15
|
+
* declares the paths it touched in its own artifact's `## Changed paths`
|
|
16
|
+
* section, and the rule judges THAT set instead of the whole working tree: the
|
|
17
|
+
* old judgement blamed a docs rid for another slice's `src/**` change, because
|
|
18
|
+
* it read the working tree rather than the request.
|
|
19
|
+
*
|
|
20
|
+
* SCOPING ALONE WOULD BE AN ESCAPE HATCH ("this rid did not change it" would
|
|
21
|
+
* pass anything), so the fallback runs beside it: a product-source change in the
|
|
22
|
+
* working tree that NO rid claimed is still refused. The fallback only runs
|
|
23
|
+
* when EVERY rid artifact in the session declares its paths — an incomplete
|
|
24
|
+
* table cannot prove "nobody claimed it", and guessing there would blame one
|
|
25
|
+
* slice for another's change. When it does not run, the returned note says so:
|
|
26
|
+
* a silently skipped check is indistinguishable from a passing one.
|
|
13
27
|
*/
|
|
14
28
|
import type { RequestType } from './artifact-prerequisites.js';
|
|
15
|
-
import { type
|
|
29
|
+
import { type RequestArtifactState } from './request-artifact-state-helpers.js';
|
|
16
30
|
export type RdGatePhase = 'implemented' | 'qa-handoff' | 'handed-off';
|
|
31
|
+
/**
|
|
32
|
+
* True for the three states the RD gates judge. A type PREDICATE, so a caller
|
|
33
|
+
* that filters on it keeps the narrowed state — the old inline `||` chain did
|
|
34
|
+
* the same narrowing, and losing it would make the phase un-assignable.
|
|
35
|
+
*/
|
|
36
|
+
export declare function isRdGatePhase(state: RequestArtifactState): state is RdGatePhase;
|
|
37
|
+
/** The three ways the declared-type rule can refuse. */
|
|
38
|
+
export type RdGateViolationKind = 'source-touched' | 'source-unclaimed' | 'diff-unavailable';
|
|
39
|
+
export type RdGateViolation = {
|
|
40
|
+
ok: false;
|
|
41
|
+
kind: RdGateViolationKind;
|
|
42
|
+
message: string;
|
|
43
|
+
};
|
|
17
44
|
export declare class TypeCorroborationViolationError extends Error {
|
|
18
45
|
readonly code = "TYPE_CORROBORATION_VIOLATION";
|
|
19
46
|
readonly declaredType: RequestType;
|
|
20
|
-
readonly kind:
|
|
21
|
-
constructor(declaredType: RequestType, verdict:
|
|
22
|
-
ok: false;
|
|
23
|
-
}>);
|
|
47
|
+
readonly kind: RdGateViolationKind;
|
|
48
|
+
constructor(declaredType: RequestType, verdict: RdGateViolation);
|
|
24
49
|
}
|
|
25
50
|
/** Written into the artifact when `--allow-incomplete` skips a gate that COULD
|
|
26
51
|
* have judged this type: a silent bypass is indistinguishable from a pass. */
|
|
@@ -30,4 +55,6 @@ export declare function runRdTransitionGates(options: {
|
|
|
30
55
|
declaredType: RequestType;
|
|
31
56
|
allowIncomplete: boolean;
|
|
32
57
|
phase: RdGatePhase;
|
|
58
|
+
requestId: string;
|
|
59
|
+
sessionId: string;
|
|
33
60
|
}): string | null;
|