peaks-loop 4.1.7 → 4.1.8
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 +47 -0
- package/config/eslint/tsconfig.lint.json +1 -0
- package/dist/cli/commands/dispatch-from-dag.js +17 -0
- package/dist/cli/commands/job-commands.js +15 -5
- package/dist/cli/commands/lint-baseline-command.d.ts +15 -0
- package/dist/cli/commands/lint-baseline-command.js +64 -0
- package/dist/cli/commands/lint-commands.js +27 -51
- package/dist/cli/commands/request-command-options.d.ts +6 -0
- package/dist/cli/commands/request-commands.js +2 -0
- package/dist/cli/commands/request-mark-qa-initiated-command.d.ts +3 -0
- package/dist/cli/commands/request-mark-qa-initiated-command.js +80 -0
- package/dist/cli/commands/request-transition-failures.js +1 -0
- package/dist/cli/commands/reviewer-commands.d.ts +6 -6
- package/dist/cli/commands/reviewer-commands.js +154 -56
- package/dist/cli/commands/reviewer-config-commands.d.ts +9 -0
- package/dist/cli/commands/reviewer-config-commands.js +133 -0
- package/dist/services/artifacts/artifact-lint-service.js +102 -27
- package/dist/services/artifacts/artifact-prerequisites.d.ts +1 -0
- package/dist/services/artifacts/artifact-prerequisites.js +13 -13
- package/dist/services/artifacts/artifact-template-bodies.d.ts +7 -1
- package/dist/services/artifacts/artifact-template-bodies.js +14 -3
- package/dist/services/artifacts/artifact-templates.d.ts +6 -1
- package/dist/services/artifacts/artifact-templates.js +8 -5
- package/dist/services/artifacts/backcompat-acceptance.js +7 -5
- package/dist/services/artifacts/prerequisite-checks.d.ts +34 -9
- package/dist/services/artifacts/prerequisite-checks.js +28 -9
- package/dist/services/artifacts/qa-initiated-marker.d.ts +24 -0
- package/dist/services/artifacts/qa-initiated-marker.js +36 -0
- package/dist/services/artifacts/request-artifact-metadata.d.ts +9 -0
- package/dist/services/artifacts/request-artifact-metadata.js +9 -0
- package/dist/services/artifacts/request-artifact-service.js +6 -10
- package/dist/services/artifacts/request-artifact-state-helpers.d.ts +2 -1
- package/dist/services/artifacts/request-artifact-state-helpers.js +6 -3
- package/dist/services/dispatch/isolation-lease.d.ts +3 -2
- package/dist/services/dispatch/isolation-lease.js +15 -6
- package/dist/services/job/subagent-job-wrapper.d.ts +20 -7
- package/dist/services/job/subagent-job-wrapper.js +53 -5
- package/dist/services/lint/eslint-report.d.ts +19 -0
- package/dist/services/lint/eslint-report.js +60 -0
- package/dist/services/lint/eslint-runner-support.d.ts +18 -1
- package/dist/services/lint/eslint-runner-support.js +35 -2
- package/dist/services/lint/eslint-runner-types.d.ts +21 -1
- package/dist/services/lint/eslint-runner.js +43 -33
- package/dist/services/prd/gate-evidence-derivation.d.ts +2 -4
- package/dist/services/prd/gate-evidence-derivation.js +3 -1
- package/dist/services/qa/bdd-test-style-contract.d.ts +17 -0
- package/dist/services/qa/bdd-test-style-contract.js +41 -0
- package/dist/services/qa/bdd-test-style-verifier.d.ts +9 -6
- package/dist/services/qa/bdd-test-style-verifier.js +24 -37
- package/dist/services/rd/reviewer-dispatch-policy.d.ts +18 -14
- package/dist/services/rd/reviewer-dispatch-policy.js +14 -11
- package/dist/services/release/release-state.js +20 -5
- package/dist/services/reviewer/model-family.js +1 -1
- package/dist/services/reviewer/reviewer-artifacts.d.ts +12 -0
- package/dist/services/reviewer/reviewer-artifacts.js +67 -0
- package/dist/services/reviewer/reviewer-config-write.d.ts +18 -0
- package/dist/services/reviewer/reviewer-config-write.js +71 -0
- package/dist/services/reviewer/reviewer-config.d.ts +33 -5
- package/dist/services/reviewer/reviewer-config.js +102 -46
- package/dist/services/reviewer/reviewer-envelopes.d.ts +8 -0
- package/dist/services/reviewer/reviewer-envelopes.js +53 -0
- package/dist/services/reviewer/reviewer-service.d.ts +7 -4
- package/dist/services/reviewer/reviewer-service.js +46 -52
- package/dist/services/reviewer/reviewer-types.d.ts +9 -1
- package/dist/services/session/getSessionDir.js +16 -7
- package/dist/services/web/daemon-registry.d.ts +6 -4
- package/dist/services/web/daemon-registry.js +92 -17
- package/package.json +5 -5
- package/schemas/reviewer-envelope.schema.json +1 -1
- package/skills/bee/peaks-reviewer/SKILL.md +20 -4
- package/skills/bee/peaks-reviewer/references/reviewer-schema.md +12 -7
- package/skills/bee/peaks-security-audit/SKILL.md +20 -0
|
@@ -1,64 +1,162 @@
|
|
|
1
|
-
import { runReviewer
|
|
2
|
-
import { loadReviewerConfig } from '../../services/reviewer/reviewer-config.js';
|
|
1
|
+
import { runReviewer } from '../../services/reviewer/reviewer-service.js';
|
|
2
|
+
import { defaultReviewerConfigPath, loadReviewerConfig, MIN_REVIEWER_PROVIDERS, resolveReviewerSchema } from '../../services/reviewer/reviewer-config.js';
|
|
3
|
+
import { DISPATCHABLE_PROVIDER_NAMES } from '../../services/reviewer/reviewer-config-write.js';
|
|
4
|
+
import { writeReviewerArtifacts } from '../../services/reviewer/reviewer-artifacts.js';
|
|
3
5
|
import { deriveModelFamily } from '../../services/reviewer/model-family.js';
|
|
4
|
-
import {
|
|
6
|
+
import { resolveCanonicalProjectRoot } from '../../services/config/config-service.js';
|
|
7
|
+
import { readActiveSid } from './code-runtime-session.js';
|
|
8
|
+
import { registerReviewerConfigCommand } from './reviewer-config-commands.js';
|
|
9
|
+
import { addJsonOption, getErrorMessage, printResult } from '../cli-helpers.js';
|
|
5
10
|
import { fail, ok } from 'peaks-loop-shared/result';
|
|
6
|
-
|
|
7
|
-
|
|
8
|
-
|
|
9
|
-
|
|
10
|
-
|
|
11
|
-
|
|
12
|
-
|
|
13
|
-
|
|
14
|
-
|
|
15
|
-
|
|
16
|
-
|
|
17
|
-
|
|
18
|
-
|
|
19
|
-
|
|
20
|
-
|
|
21
|
-
|
|
22
|
-
|
|
23
|
-
|
|
24
|
-
|
|
25
|
-
|
|
26
|
-
|
|
27
|
-
|
|
28
|
-
|
|
29
|
-
|
|
30
|
-
};
|
|
31
|
-
printResult(io, ok('reviewer.run', { envelope, reason: status.reason }), options.json === true);
|
|
11
|
+
function isJson(options) {
|
|
12
|
+
return options.json === true;
|
|
13
|
+
}
|
|
14
|
+
function printRunFailure(io, options, code, message, nextActions) {
|
|
15
|
+
printResult(io, fail('reviewer.run', code, message, null, nextActions), isJson(options));
|
|
16
|
+
}
|
|
17
|
+
async function handleRun(options, io) {
|
|
18
|
+
const rid = options.rid ?? '';
|
|
19
|
+
if (rid.length === 0) {
|
|
20
|
+
printRunFailure(io, options, 'MISSING_RID', '--rid is required', []);
|
|
21
|
+
process.exitCode = 2;
|
|
22
|
+
return;
|
|
23
|
+
}
|
|
24
|
+
const projectRoot = resolveCanonicalProjectRoot(options.project ?? process.cwd());
|
|
25
|
+
const result = await runReviewer({
|
|
26
|
+
rid,
|
|
27
|
+
context: `rid=${rid}`,
|
|
28
|
+
projectRoot,
|
|
29
|
+
...(options.config !== undefined ? { configPath: options.config } : {})
|
|
30
|
+
});
|
|
31
|
+
if (!result.ok) {
|
|
32
|
+
if (result.reason === 'schema-missing') {
|
|
33
|
+
printRunFailure(io, options, 'SCHEMA_MISSING', `Reviewer schema not found; searched: ${(result.schemaCandidates ?? []).join(', ')}`, ['Fix the reviewer config schemaPath or place the schema at one of the searched paths.']);
|
|
34
|
+
process.exitCode = 1;
|
|
32
35
|
return;
|
|
33
36
|
}
|
|
34
|
-
|
|
35
|
-
|
|
36
|
-
|
|
37
|
-
|
|
37
|
+
printConfigSkip(result, options, io);
|
|
38
|
+
return;
|
|
39
|
+
}
|
|
40
|
+
if (options.write !== true) {
|
|
41
|
+
printResult(io, ok('reviewer.run', { envelope: result.envelope }), isJson(options));
|
|
42
|
+
return;
|
|
43
|
+
}
|
|
44
|
+
if (result.skipped) {
|
|
45
|
+
printResult(io, ok('reviewer.run', {
|
|
46
|
+
envelope: result.envelope,
|
|
47
|
+
written: false,
|
|
48
|
+
writeSkippedReason: result.envelope.reason
|
|
49
|
+
}), isJson(options));
|
|
50
|
+
return;
|
|
51
|
+
}
|
|
52
|
+
writeArtifacts(result.envelope, rid, { projectRoot, options }, io);
|
|
53
|
+
}
|
|
54
|
+
function printConfigSkip(result, options, io) {
|
|
55
|
+
const data = options.write === true
|
|
56
|
+
? {
|
|
57
|
+
envelope: result.envelope,
|
|
58
|
+
reason: result.reason,
|
|
59
|
+
written: false,
|
|
60
|
+
writeSkippedReason: result.envelope.reason
|
|
38
61
|
}
|
|
39
|
-
|
|
40
|
-
|
|
62
|
+
: { envelope: result.envelope, reason: result.reason };
|
|
63
|
+
printResult(io, ok('reviewer.run', data, [], [
|
|
64
|
+
`Configure the reviewer with: peaks reviewer config --provider <name:model> --provider <name:model>`
|
|
65
|
+
]), isJson(options));
|
|
66
|
+
}
|
|
67
|
+
function writeArtifacts(envelope, rid, context, io) {
|
|
68
|
+
const { projectRoot, options } = context;
|
|
69
|
+
const sessionId = options.sessionId ?? readActiveSid(projectRoot) ?? '';
|
|
70
|
+
if (sessionId.length === 0) {
|
|
71
|
+
printResult(io, fail('reviewer.run', 'MISSING_SESSION_ID', '--write needs an active session id; pass --session-id <id>', { envelope }, ['Re-run with --session-id <sessionId>']), isJson(options));
|
|
72
|
+
process.exitCode = 1;
|
|
73
|
+
return;
|
|
74
|
+
}
|
|
75
|
+
try {
|
|
76
|
+
printResult(io, ok('reviewer.run', {
|
|
77
|
+
envelope,
|
|
78
|
+
written: true,
|
|
79
|
+
artifacts: writeReviewerArtifacts({ projectRoot, sessionId, rid, envelope })
|
|
80
|
+
}), isJson(options));
|
|
81
|
+
}
|
|
82
|
+
catch (error) {
|
|
83
|
+
printResult(io, fail('reviewer.run', 'ARTIFACT_WRITE_FAILED', getErrorMessage(error), { envelope }), isJson(options));
|
|
84
|
+
process.exitCode = 1;
|
|
85
|
+
}
|
|
86
|
+
}
|
|
87
|
+
function registerRunCommand(reviewer, io) {
|
|
88
|
+
addJsonOption(reviewer
|
|
89
|
+
.command('run')
|
|
90
|
+
.description('Run the configured third-party reviewer on a slice.')
|
|
91
|
+
.option('--rid <rid>', 'request id (slice) to review')
|
|
92
|
+
.option('--write', 'write rd/third-party-review-<rid>.md + .json under the session runtime')
|
|
93
|
+
.option('--session-id <id>', 'session id for --write (defaults to the active session)')
|
|
94
|
+
.option('--project <path>', 'project root for schema resolution and --write (promotes to the git root)')
|
|
95
|
+
.option('--config <path>', 'reviewer config path (defaults to ~/.peaks/config.json)')).action((options) => handleRun(options, io));
|
|
96
|
+
}
|
|
97
|
+
function unconfiguredData(status, path) {
|
|
98
|
+
return {
|
|
99
|
+
configured: false,
|
|
100
|
+
state: status.reason === 'insufficient-providers' ? 'insufficient-providers' : 'no-section',
|
|
101
|
+
reason: status.reason,
|
|
102
|
+
configPath: path,
|
|
103
|
+
providerCount: status.providerCount,
|
|
104
|
+
requiredProviders: status.requiredProviders
|
|
105
|
+
};
|
|
106
|
+
}
|
|
107
|
+
function unconfiguredActions(status, path) {
|
|
108
|
+
const first = status.reason === 'insufficient-providers'
|
|
109
|
+
? `Only ${String(status.providerCount)} valid provider(s); at least ${String(status.requiredProviders)} are required. Add one with: peaks reviewer config --provider <name:model>`
|
|
110
|
+
: `No reviewer section at ${path}. Write one with: peaks reviewer config --provider <name:model> --provider <name:model>`;
|
|
111
|
+
return [first, `Accepted providers: ${DISPATCHABLE_PROVIDER_NAMES.join(', ')}.`];
|
|
112
|
+
}
|
|
113
|
+
function configuredData(config, path, projectRoot) {
|
|
114
|
+
const families = config.providers.map((p) => ({
|
|
115
|
+
name: p.name,
|
|
116
|
+
model: p.model,
|
|
117
|
+
modelFamily: deriveModelFamily(p.model).modelFamily
|
|
118
|
+
}));
|
|
119
|
+
const schema = resolveReviewerSchema(projectRoot, config.schemaPath);
|
|
120
|
+
return {
|
|
121
|
+
configured: true,
|
|
122
|
+
state: 'configured',
|
|
123
|
+
configPath: path,
|
|
124
|
+
providerCount: families.length,
|
|
125
|
+
requiredProviders: MIN_REVIEWER_PROVIDERS,
|
|
126
|
+
selection: config.selection,
|
|
127
|
+
requireDistinctModelFamily: config.requireDistinctModelFamily,
|
|
128
|
+
fallbackOnError: config.fallbackOnError,
|
|
129
|
+
schemaPath: config.schemaPath,
|
|
130
|
+
schemaPathExists: schema.ok,
|
|
131
|
+
schemaPathSource: schema.ok ? schema.source : null,
|
|
132
|
+
schemaPathResolved: schema.ok ? schema.path : null,
|
|
133
|
+
rdProviderName: config.rdProviderName,
|
|
134
|
+
providers: families
|
|
135
|
+
};
|
|
136
|
+
}
|
|
137
|
+
function handleStatus(options, io) {
|
|
138
|
+
const path = options.config ?? defaultReviewerConfigPath();
|
|
139
|
+
// Same promotion as `run`: the diagnostic must agree with the run decision.
|
|
140
|
+
const projectRoot = resolveCanonicalProjectRoot(options.project ?? process.cwd());
|
|
141
|
+
const status = loadReviewerConfig(options.config !== undefined ? { path } : {});
|
|
142
|
+
if (!status.ok) {
|
|
143
|
+
printResult(io, ok('reviewer.status', unconfiguredData(status, path), [], unconfiguredActions(status, path)), isJson(options));
|
|
144
|
+
return;
|
|
145
|
+
}
|
|
146
|
+
printResult(io, ok('reviewer.status', configuredData(status.config, path, projectRoot)), isJson(options));
|
|
147
|
+
}
|
|
148
|
+
function registerStatusCommand(reviewer, io) {
|
|
41
149
|
addJsonOption(reviewer
|
|
42
150
|
.command('status')
|
|
43
|
-
.description('Show whether the reviewer is configured and which selection mode + provider families are active.')
|
|
44
|
-
|
|
45
|
-
|
|
46
|
-
|
|
47
|
-
|
|
48
|
-
|
|
49
|
-
|
|
50
|
-
|
|
51
|
-
|
|
52
|
-
|
|
53
|
-
|
|
54
|
-
printResult(io, ok('reviewer.status', {
|
|
55
|
-
configured: true,
|
|
56
|
-
selection: status.config.selection,
|
|
57
|
-
requireDistinctModelFamily: status.config.requireDistinctModelFamily,
|
|
58
|
-
fallbackOnError: status.config.fallbackOnError,
|
|
59
|
-
schemaPath: status.config.schemaPath,
|
|
60
|
-
rdProviderName: status.config.rdProviderName,
|
|
61
|
-
providers: families
|
|
62
|
-
}), options.json === true);
|
|
63
|
-
});
|
|
151
|
+
.description('Show whether the reviewer is configured and which selection mode + provider families are active.')
|
|
152
|
+
.option('--config <path>', 'reviewer config path (defaults to ~/.peaks/config.json)')
|
|
153
|
+
.option('--project <path>', 'project root for schema resolution (promotes to the git root)')).action((options) => handleStatus(options, io));
|
|
154
|
+
}
|
|
155
|
+
export function registerReviewerCommands(program, io) {
|
|
156
|
+
const reviewer = program
|
|
157
|
+
.command('reviewer')
|
|
158
|
+
.description('Third-party reviewer (v2.14.0 G4 anti-fake-green) — runs an out-of-band model on the slice and emits a schema-validated ReviewerEnvelope.');
|
|
159
|
+
registerReviewerConfigCommand(reviewer, io);
|
|
160
|
+
registerRunCommand(reviewer, io);
|
|
161
|
+
registerStatusCommand(reviewer, io);
|
|
64
162
|
}
|
|
@@ -0,0 +1,9 @@
|
|
|
1
|
+
/**
|
|
2
|
+
* `peaks reviewer config` — write the `reviewer` section on the user's behalf.
|
|
3
|
+
* Split out of reviewer-commands.ts for the 300-line file-size cap.
|
|
4
|
+
*
|
|
5
|
+
* The LLM runs this; the user never hand-authors JSON (backlog §7.10 ①).
|
|
6
|
+
*/
|
|
7
|
+
import type { Command } from 'commander';
|
|
8
|
+
import { type ProgramIO } from '../cli-helpers.js';
|
|
9
|
+
export declare function registerReviewerConfigCommand(reviewer: Command, io: ProgramIO): void;
|
|
@@ -0,0 +1,133 @@
|
|
|
1
|
+
import { defaultReviewerConfigPath, loadReviewerConfig, MIN_REVIEWER_PROVIDERS } from '../../services/reviewer/reviewer-config.js';
|
|
2
|
+
import { DISPATCHABLE_PROVIDER_NAMES, parseProviderSpec, validateReviewerSection, writeReviewerConfig } from '../../services/reviewer/reviewer-config-write.js';
|
|
3
|
+
import { addJsonOption, printResult } from '../cli-helpers.js';
|
|
4
|
+
import { fail, ok } from 'peaks-loop-shared/result';
|
|
5
|
+
const SELECTIONS = ['round-robin', 'hash', 'random'];
|
|
6
|
+
const FALLBACKS = ['skip', 'error'];
|
|
7
|
+
function collect(value, previous) {
|
|
8
|
+
return [...previous, value];
|
|
9
|
+
}
|
|
10
|
+
function isSelection(value) {
|
|
11
|
+
return SELECTIONS.includes(value);
|
|
12
|
+
}
|
|
13
|
+
function isFallback(value) {
|
|
14
|
+
return FALLBACKS.includes(value);
|
|
15
|
+
}
|
|
16
|
+
/** `undefined` when the flag was absent; `null` when it is not a boolean. */
|
|
17
|
+
function parseBooleanFlag(value) {
|
|
18
|
+
if (value === undefined)
|
|
19
|
+
return undefined;
|
|
20
|
+
if (value === 'true')
|
|
21
|
+
return true;
|
|
22
|
+
if (value === 'false')
|
|
23
|
+
return false;
|
|
24
|
+
return null;
|
|
25
|
+
}
|
|
26
|
+
function parseProviderFlags(options) {
|
|
27
|
+
const providers = [];
|
|
28
|
+
for (const spec of options.provider ?? []) {
|
|
29
|
+
const parsed = parseProviderSpec(spec);
|
|
30
|
+
if (parsed === null) {
|
|
31
|
+
return {
|
|
32
|
+
code: 'INVALID_PROVIDER_SPEC',
|
|
33
|
+
message: `--provider expects <name:model>; got "${spec}"`,
|
|
34
|
+
nextActions: [`Accepted providers: ${DISPATCHABLE_PROVIDER_NAMES.join(', ')}`]
|
|
35
|
+
};
|
|
36
|
+
}
|
|
37
|
+
providers.push(parsed);
|
|
38
|
+
}
|
|
39
|
+
return { providers };
|
|
40
|
+
}
|
|
41
|
+
function parseModeFlags(options, status) {
|
|
42
|
+
const selection = options.selection ?? (status.ok ? status.config.selection : 'round-robin');
|
|
43
|
+
if (!isSelection(selection)) {
|
|
44
|
+
return {
|
|
45
|
+
code: 'INVALID_SELECTION',
|
|
46
|
+
message: `--selection must be one of ${SELECTIONS.join(', ')}`,
|
|
47
|
+
nextActions: []
|
|
48
|
+
};
|
|
49
|
+
}
|
|
50
|
+
const fallbackOnError = options.fallbackOnError ?? (status.ok ? status.config.fallbackOnError : 'skip');
|
|
51
|
+
if (!isFallback(fallbackOnError)) {
|
|
52
|
+
return {
|
|
53
|
+
code: 'INVALID_FALLBACK',
|
|
54
|
+
message: `--fallback-on-error must be one of ${FALLBACKS.join(', ')}`,
|
|
55
|
+
nextActions: []
|
|
56
|
+
};
|
|
57
|
+
}
|
|
58
|
+
const distinct = parseBooleanFlag(options.requireDistinctModelFamily);
|
|
59
|
+
if (distinct === null) {
|
|
60
|
+
return {
|
|
61
|
+
code: 'INVALID_DISTINCT_FLAG',
|
|
62
|
+
message: '--require-distinct-model-family must be true or false',
|
|
63
|
+
nextActions: []
|
|
64
|
+
};
|
|
65
|
+
}
|
|
66
|
+
return {
|
|
67
|
+
selection,
|
|
68
|
+
fallbackOnError,
|
|
69
|
+
requireDistinctModelFamily: distinct ?? (status.ok ? status.config.requireDistinctModelFamily : true)
|
|
70
|
+
};
|
|
71
|
+
}
|
|
72
|
+
function buildSection(options, status, providers, modes) {
|
|
73
|
+
return {
|
|
74
|
+
providers: providers.length > 0 ? providers : status.ok ? [...status.config.providers] : [],
|
|
75
|
+
selection: modes.selection,
|
|
76
|
+
rdProviderName: options.rdProviderName ?? (status.ok ? status.config.rdProviderName : null),
|
|
77
|
+
requireDistinctModelFamily: modes.requireDistinctModelFamily,
|
|
78
|
+
fallbackOnError: modes.fallbackOnError,
|
|
79
|
+
schemaPath: options.schemaPath ??
|
|
80
|
+
(status.ok ? status.config.schemaPath : 'schemas/reviewer-envelope.schema.json')
|
|
81
|
+
};
|
|
82
|
+
}
|
|
83
|
+
function printConfigFailure(io, options, failure, exitCode) {
|
|
84
|
+
printResult(io, fail('reviewer.config', failure.code, failure.message, null, failure.nextActions), options.json === true);
|
|
85
|
+
process.exitCode = exitCode;
|
|
86
|
+
}
|
|
87
|
+
function invalidSectionFailure(message) {
|
|
88
|
+
return {
|
|
89
|
+
code: 'REVIEWER_CONFIG_INVALID',
|
|
90
|
+
message,
|
|
91
|
+
nextActions: [
|
|
92
|
+
'Add providers with: peaks reviewer config --provider <name:model> --provider <name:model>'
|
|
93
|
+
]
|
|
94
|
+
};
|
|
95
|
+
}
|
|
96
|
+
function handleConfigAction(options, io) {
|
|
97
|
+
const path = options.config ?? defaultReviewerConfigPath();
|
|
98
|
+
const status = loadReviewerConfig(options.config !== undefined ? { path } : {});
|
|
99
|
+
const providersResult = parseProviderFlags(options);
|
|
100
|
+
if ('code' in providersResult) {
|
|
101
|
+
printConfigFailure(io, options, providersResult, 2);
|
|
102
|
+
return;
|
|
103
|
+
}
|
|
104
|
+
const modes = parseModeFlags(options, status);
|
|
105
|
+
if ('code' in modes) {
|
|
106
|
+
printConfigFailure(io, options, modes, 2);
|
|
107
|
+
return;
|
|
108
|
+
}
|
|
109
|
+
const section = buildSection(options, status, providersResult.providers, modes);
|
|
110
|
+
const invalid = validateReviewerSection(section);
|
|
111
|
+
if (invalid !== null) {
|
|
112
|
+
printConfigFailure(io, options, invalidSectionFailure(invalid), 2);
|
|
113
|
+
return;
|
|
114
|
+
}
|
|
115
|
+
const written = writeReviewerConfig(section, options.config !== undefined ? { path } : {});
|
|
116
|
+
if (!written.ok) {
|
|
117
|
+
printConfigFailure(io, options, { code: 'REVIEWER_CONFIG_UNREADABLE', message: written.message, nextActions: [] }, 1);
|
|
118
|
+
return;
|
|
119
|
+
}
|
|
120
|
+
printResult(io, ok('reviewer.config', { path: written.path, reviewer: section }, [], ['Run `peaks reviewer status` to confirm the section is active.']), options.json === true);
|
|
121
|
+
}
|
|
122
|
+
export function registerReviewerConfigCommand(reviewer, io) {
|
|
123
|
+
addJsonOption(reviewer
|
|
124
|
+
.command('config')
|
|
125
|
+
.description('Write the `reviewer` section to the user config without hand-authoring JSON (LLM-driven).')
|
|
126
|
+
.option('--provider <name:model>', `provider entry, repeatable; at least ${MIN_REVIEWER_PROVIDERS} required (accepted: ${DISPATCHABLE_PROVIDER_NAMES.join(', ')})`, collect, [])
|
|
127
|
+
.option('--selection <mode>', 'round-robin | hash | random')
|
|
128
|
+
.option('--require-distinct-model-family <true|false>', 'require a family distinct from the RD model')
|
|
129
|
+
.option('--fallback-on-error <mode>', 'skip | error')
|
|
130
|
+
.option('--rd-provider-name <name>', 'name of the RD-side provider, if any')
|
|
131
|
+
.option('--schema-path <path>', 'path to the ReviewerEnvelope schema')
|
|
132
|
+
.option('--config <path>', 'reviewer config path (defaults to ~/.peaks/config.json)')).action((options) => handleConfigAction(options, io));
|
|
133
|
+
}
|
|
@@ -1,4 +1,6 @@
|
|
|
1
1
|
import { showRequestArtifact } from './request-artifact-service.js';
|
|
2
|
+
import { isRequestType, VALID_REQUEST_TYPES } from './artifact-prerequisites.js';
|
|
3
|
+
import { allowedStatesForRole, locateArtifactState } from './request-artifact-state-helpers.js';
|
|
2
4
|
const RULES = [
|
|
3
5
|
{
|
|
4
6
|
test: (line) => /<[A-Za-z][^>]*>/.test(line.trim()) && !/^\s*-?\s*linked-/i.test(line),
|
|
@@ -27,7 +29,6 @@ const ALLOWLIST_PATTERNS = [
|
|
|
27
29
|
/^\s*```/, // code fences
|
|
28
30
|
/^\s*-\s*last update:/i, // metadata
|
|
29
31
|
/^\s*-\s*created:/i,
|
|
30
|
-
/^\s*-\s*state:/i,
|
|
31
32
|
/^\s*-\s*type:\s*(feature|bugfix|refactor|docs|config|chore)\s*$/i,
|
|
32
33
|
/^\s*-\s*session:\s*[a-z0-9-]+/i,
|
|
33
34
|
/^\s*-\s*transition note/i // bypass / repair notes are not placeholders
|
|
@@ -44,26 +45,77 @@ function isAllowlisted(line) {
|
|
|
44
45
|
function stripInlineCode(line) {
|
|
45
46
|
return line.replace(/`[^`]*`/g, '');
|
|
46
47
|
}
|
|
47
|
-
|
|
48
|
-
|
|
49
|
-
|
|
50
|
-
|
|
51
|
-
|
|
52
|
-
|
|
53
|
-
|
|
54
|
-
|
|
48
|
+
/**
|
|
49
|
+
* The reader's own `- type:` locator: `extractMetadata` trims every line before
|
|
50
|
+
* matching, and takes everything after `type:`. `- state:` is matched at column
|
|
51
|
+
* 0, exactly as `locateArtifactState` does. Both are "handled" whether the value
|
|
52
|
+
* is valid or not, so the placeholder rules never fire on the same line.
|
|
53
|
+
*/
|
|
54
|
+
const METADATA_TYPE_RE = /^-\s*type:\s*(.+?)\s*$/;
|
|
55
|
+
const METADATA_STATE_RE = /^-\s*state:\s*(.+?)\s*$/;
|
|
56
|
+
function checkMetadataLine(rawLine, role) {
|
|
57
|
+
const typeMatch = METADATA_TYPE_RE.exec(rawLine.trim());
|
|
58
|
+
if (typeMatch?.[1] !== undefined) {
|
|
59
|
+
const value = typeMatch[1];
|
|
60
|
+
return {
|
|
61
|
+
handled: true,
|
|
62
|
+
reason: isRequestType(value)
|
|
63
|
+
? null
|
|
64
|
+
: `Invalid - type: "${value}" — expected one of: ${VALID_REQUEST_TYPES.join(', ')}`
|
|
65
|
+
};
|
|
55
66
|
}
|
|
56
|
-
const
|
|
57
|
-
if (
|
|
67
|
+
const stateMatch = METADATA_STATE_RE.exec(rawLine);
|
|
68
|
+
if (stateMatch?.[1] !== undefined) {
|
|
69
|
+
const value = stateMatch[1];
|
|
70
|
+
const allowed = allowedStatesForRole(role);
|
|
71
|
+
return {
|
|
72
|
+
handled: true,
|
|
73
|
+
reason: allowed.includes(value)
|
|
74
|
+
? null
|
|
75
|
+
: `Invalid - state: "${value}" for role ${role} — expected one of: ${allowed.join(', ')}`
|
|
76
|
+
};
|
|
77
|
+
}
|
|
78
|
+
return { handled: false };
|
|
79
|
+
}
|
|
80
|
+
/** The finding a metadata line produces, or `undefined` when the line is not metadata. */
|
|
81
|
+
function metadataFinding(rawLine, role, line) {
|
|
82
|
+
const metadata = checkMetadataLine(rawLine, role);
|
|
83
|
+
if (!metadata.handled)
|
|
84
|
+
return undefined;
|
|
85
|
+
if (metadata.reason === null)
|
|
86
|
+
return null;
|
|
87
|
+
return { line, text: rawLine.trim(), reason: metadata.reason, severity: 'error' };
|
|
88
|
+
}
|
|
89
|
+
/**
|
|
90
|
+
* The finding for an artifact with NO `- state:` line, or null when the reader
|
|
91
|
+
* can locate one. The locator is the reader's own (`locateArtifactState`), so
|
|
92
|
+
* this check agrees with the transition's fail-closed `STATE_ORDER_UNREADABLE`
|
|
93
|
+
* instead of only with the per-line spelling rule in `checkMetadataLine`.
|
|
94
|
+
*/
|
|
95
|
+
function missingStateFinding(lines, role) {
|
|
96
|
+
if (locateArtifactState(lines).stateLineIndex !== -1)
|
|
58
97
|
return null;
|
|
98
|
+
const allowed = allowedStatesForRole(role);
|
|
99
|
+
return {
|
|
100
|
+
line: 1,
|
|
101
|
+
text: '(no - state: line)',
|
|
102
|
+
reason: `Missing - state: line for role ${role} — expected one of: ${allowed.join(', ')}`,
|
|
103
|
+
severity: 'error'
|
|
104
|
+
};
|
|
105
|
+
}
|
|
106
|
+
/** The first placeholder rule this line violates, or null when it violates none. */
|
|
107
|
+
function firstRule(rawLine) {
|
|
108
|
+
const testLine = stripInlineCode(rawLine);
|
|
109
|
+
for (const rule of RULES) {
|
|
110
|
+
if (rule.test(testLine))
|
|
111
|
+
return rule;
|
|
59
112
|
}
|
|
60
|
-
|
|
113
|
+
return null;
|
|
114
|
+
}
|
|
115
|
+
function scanLines(lines, role) {
|
|
61
116
|
const findings = [];
|
|
62
117
|
let insideFence = false;
|
|
63
|
-
for (
|
|
64
|
-
const rawLine = lines[index];
|
|
65
|
-
if (rawLine === undefined)
|
|
66
|
-
continue;
|
|
118
|
+
for (const [index, rawLine] of lines.entries()) {
|
|
67
119
|
// Fenced code blocks hold literal examples, not prose to fill; skip their
|
|
68
120
|
// contents entirely (the fence delimiters themselves toggle the state).
|
|
69
121
|
if (/^\s*```/.test(rawLine)) {
|
|
@@ -72,21 +124,44 @@ export async function lintRequestArtifact(options) {
|
|
|
72
124
|
}
|
|
73
125
|
if (insideFence)
|
|
74
126
|
continue;
|
|
127
|
+
const metadata = metadataFinding(rawLine, role, index + 1);
|
|
128
|
+
if (metadata !== undefined) {
|
|
129
|
+
if (metadata !== null)
|
|
130
|
+
findings.push(metadata);
|
|
131
|
+
continue;
|
|
132
|
+
}
|
|
75
133
|
if (isAllowlisted(rawLine))
|
|
76
134
|
continue;
|
|
77
|
-
const
|
|
78
|
-
|
|
79
|
-
|
|
80
|
-
|
|
81
|
-
|
|
82
|
-
|
|
83
|
-
|
|
84
|
-
|
|
85
|
-
});
|
|
86
|
-
break;
|
|
87
|
-
}
|
|
135
|
+
const rule = firstRule(rawLine);
|
|
136
|
+
if (rule !== null) {
|
|
137
|
+
findings.push({
|
|
138
|
+
line: index + 1,
|
|
139
|
+
text: rawLine.trim(),
|
|
140
|
+
reason: rule.reason,
|
|
141
|
+
severity: rule.severity
|
|
142
|
+
});
|
|
88
143
|
}
|
|
89
144
|
}
|
|
145
|
+
return findings;
|
|
146
|
+
}
|
|
147
|
+
export async function lintRequestArtifact(options) {
|
|
148
|
+
const showOptions = {
|
|
149
|
+
projectRoot: options.projectRoot,
|
|
150
|
+
role: options.role,
|
|
151
|
+
requestId: options.requestId
|
|
152
|
+
};
|
|
153
|
+
if (options.sessionId !== undefined) {
|
|
154
|
+
showOptions.sessionId = options.sessionId;
|
|
155
|
+
}
|
|
156
|
+
const artifact = await showRequestArtifact(showOptions);
|
|
157
|
+
if (artifact === null) {
|
|
158
|
+
return null;
|
|
159
|
+
}
|
|
160
|
+
const lines = artifact.content.split(/\r?\n/);
|
|
161
|
+
const findings = scanLines(lines, options.role);
|
|
162
|
+
const missingState = missingStateFinding(lines, options.role);
|
|
163
|
+
if (missingState !== null)
|
|
164
|
+
findings.unshift(missingState);
|
|
90
165
|
const hasError = findings.some((finding) => finding.severity === 'error');
|
|
91
166
|
return {
|
|
92
167
|
ok: !hasError,
|
|
@@ -179,16 +179,16 @@ const KARPATHY_REVIEW = {
|
|
|
179
179
|
// to KARPATHY_REVIEW. The body MUST carry the literal substring
|
|
180
180
|
// `third-party-review` so a stub file with an empty envelope cannot
|
|
181
181
|
// pass the gate. The full envelope lives at the JSON sibling path
|
|
182
|
-
// (`rd/third-party-review
|
|
183
|
-
// companion. The body
|
|
184
|
-
//
|
|
185
|
-
// `
|
|
186
|
-
//
|
|
187
|
-
//
|
|
188
|
-
// and the transition still passes (A4.3 fallbackOnError=skip).
|
|
182
|
+
// (`rd/third-party-review-<rid>.json`); this MD file is the human-readable
|
|
183
|
+
// companion. The body declares a `modelFamily` that the gate diffs against
|
|
184
|
+
// the karpathy review's: equality fails the build. When `~/.peaks/config.json`
|
|
185
|
+
// lacks a `reviewer.providers` section, the prereq is auto-marked `skipped:
|
|
186
|
+
// no-reviewer-config` and the transition still passes (A4.3 fallbackOnError=skip).
|
|
187
|
+
// The bare pre-rid path is the legacy tier, so sessions already on disk pass.
|
|
189
188
|
const THIRD_PARTY_REVIEW = {
|
|
190
|
-
relativePath: 'rd/third-party-review
|
|
191
|
-
|
|
189
|
+
relativePath: 'rd/third-party-review-<rid>.md',
|
|
190
|
+
legacyRelativePath: 'rd/third-party-review.md',
|
|
191
|
+
description: 'v2.14.0 G4 third-party reviewer (peaks-reviewer skill) — must declare a `modelFamily` distinct from the karpathy-reviewer modelFamily (AC-4.4). Skipped when `~/.peaks/config.json` lacks `reviewer.providers` (>=2 entries); the prereq then resolves to a soft warning (`no-reviewer-config`) rather than a hard failure. The JSON sibling at `rd/third-party-review-<rid>.json` carries the schema-validated ReviewerEnvelope (no free-form LLM JSON); the rid is part of both filenames so two slices in one session do not collide, and the bare location is accepted as the legacy tier. v2.14.0 ships as a soft-warning prereq (1-minor-release back-compat window); v2.15.0 will hard-fail when the file is absent AND `reviewer.providers` is configured.',
|
|
192
192
|
mustContain: ['third-party-review', 'modelFamily'],
|
|
193
193
|
backCompat: true,
|
|
194
194
|
backCompatUntil: 'v2.15.0'
|
|
@@ -378,13 +378,13 @@ export async function checkPrerequisites(options) {
|
|
|
378
378
|
warnings.push(softWarning);
|
|
379
379
|
continue;
|
|
380
380
|
}
|
|
381
|
-
missing.push({ path: relative, description: prerequisite.description });
|
|
381
|
+
missing.push({ kind: 'absent', path: relative, description: prerequisite.description });
|
|
382
382
|
continue;
|
|
383
383
|
}
|
|
384
384
|
// Read handed over as a thunk: the no-body-contract guard lives with the check.
|
|
385
385
|
const bodyViolations = await bodyViolationsIfDeclared(prerequisite, () => readFile(absolute, 'utf8'));
|
|
386
386
|
for (const description of bodyViolations) {
|
|
387
|
-
missing.push({ path: relative, description });
|
|
387
|
+
missing.push({ kind: 'body', path: relative, description });
|
|
388
388
|
}
|
|
389
389
|
}
|
|
390
390
|
// own `gateEvidence` DECLARATION must be true — every path it names must
|
|
@@ -424,12 +424,12 @@ export async function checkPrerequisites(options) {
|
|
|
424
424
|
// artifact with no declaration is refused here, not waved through — a
|
|
425
425
|
// deleted section is the shed this arm exists to close.
|
|
426
426
|
const { describeJudgedRefusal, verifyJudgedDeclaration } = await import('../audit-independent/judged-declaration-check.js');
|
|
427
|
-
for (const
|
|
427
|
+
for (const gap of verifyJudgedDeclaration({
|
|
428
428
|
projectRoot: options.projectRoot,
|
|
429
429
|
sessionId: options.sessionId,
|
|
430
430
|
requestId: options.requestId
|
|
431
431
|
}).refusals) {
|
|
432
|
-
missing.push({ path:
|
|
432
|
+
missing.push({ kind: 'body', path: gap.artifact, description: describeJudgedRefusal(gap) });
|
|
433
433
|
}
|
|
434
434
|
}
|
|
435
435
|
const result = { ok: missing.length === 0, missing, warnings };
|
|
@@ -8,5 +8,11 @@
|
|
|
8
8
|
export declare const PRD_TEMPLATE_BODY = "## Goals\n\n- ...\n\n## Non-goals\n\n- ...\n\n## Preserved behavior\n\n- ...\n\n## Acceptance criteria\n\n- ... (browser-verifiable when frontend is in scope)\n\n## Frontend delta (only when target is frontend)\n\n- pages / routes / components / states / permissions / data deps / edge cases\n- \u5F85\u8054\u8C03\u6001: ...\n- API contracts pending: ...\n\n## Risks and open questions\n\n- ...\n\n";
|
|
9
9
|
export declare const UI_TEMPLATE_BODY = "## Affected surfaces\n\n- pages / routes / components / modals / states (loading, empty, error, hover, focus, active, responsive)\n- explicit out-of-scope surfaces (do not modify)\n\n## UX flow and page states\n\n- entry points, primary flow, secondary flows, exit points\n- state machine per surface when state transitions matter\n\n## Visual constraints\n\n- typography pair: ...\n- palette: ...\n- density and motion intensity dials: ...\n- rejected generic patterns\n\n## Interaction constraints\n\n- keyboard, focus order, ARIA roles, gesture support, accessibility minima\n\n## UI regression seeds\n\n- list of visible regressions QA must check against the prior state\n\n## Browser evidence\n\n- sanitized observations only \u2014 no login URLs, cookies, headers, tokens, storage state, browser traces, or screenshots/logs with PII / SSO / MFA material\n\n";
|
|
10
10
|
export declare const RD_TEMPLATE_BODY = "## Red-line scope\n\n- in-scope files / routes / API paths / data models\n- explicit out-of-scope surfaces (do not modify, mock, delete, or replace)\n\n## Standards preflight\n\n- peaks standards init/update --project <path> --dry-run output paths and status\n- planned application: apply | review-only | blocked\n\n## OpenSpec linkage (when openspec/ exists)\n\n- change-id: <openspec change id>\n- entry validate: peaks openspec validate <change-id> data.valid status\n- to-rd projection: peaks openspec to-rd <change-id> artifact path\n- exit validate (after implementation): status\n\n## Coverage status\n\n- current total UT coverage: <percent>\n- new/changed code coverage: <percent>\n- gate verdict: pass | legacy-accepted | blocked\n\n## Slice contract\n\n- slice id, functional boundary, pre-refactor behavior, target structure, unit-test requirements, acceptance checks, rollback plan, commit boundary\n\n## Implementation evidence\n\n- diff paths, test commands + outputs, code review findings + fixes, security review findings + fixes, dry-run output\n\n## MCP usage (when external docs lookup was used)\n\n- capabilityId / tool / sanitized args\n- artifact path of stored result\n- no secrets, no full network bodies\n\n";
|
|
11
|
-
|
|
11
|
+
/**
|
|
12
|
+
* QA body. The OpenSpec exit gate is conditional: when the target repository
|
|
13
|
+
* has no `openspec/changes/`, the prompt form's `<id>` tokens are unfillable
|
|
14
|
+
* and a pristine artifact fails lint before QA can start. The N/A form records
|
|
15
|
+
* the same fact without a placeholder. Every other section is unconditional.
|
|
16
|
+
*/
|
|
17
|
+
export declare function renderQaTemplateBody(hasOpenspecChanges: boolean): string;
|
|
12
18
|
export declare const SC_TEMPLATE_BODY = "## Change impact\n\n- modules / files / routes / data models touched\n- blast radius: local | cross-cutting | release-critical\n- rollback strategy\n\n## Commit boundaries\n\n- one commit per OpenSpec heading (when openspec/ exists)\n- otherwise: list of slice ids \u2192 commit message + scope\n\n## Artifact retention\n\n- prd artifact: ...\n- rd artifact: ...\n- qa artifact: ...\n- ui artifact: ... (when UI involved)\n- coverage evidence: ...\n- code review evidence: ...\n\n## Sync / authorization\n\n";
|