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,13 +1,13 @@
|
|
|
1
1
|
{
|
|
2
2
|
"metadata": {
|
|
3
3
|
"pluginRoot": ".",
|
|
4
|
-
"version": "4.1.
|
|
4
|
+
"version": "4.1.8"
|
|
5
5
|
},
|
|
6
6
|
"plugins": [
|
|
7
7
|
{
|
|
8
8
|
"name": "peaks-loop",
|
|
9
9
|
"description": "Loop Engineering CLI — workflow primitive / loop guards / evaluators / slice orchestration",
|
|
10
|
-
"version": "4.1.
|
|
10
|
+
"version": "4.1.8",
|
|
11
11
|
"author": {
|
|
12
12
|
"name": "SquabbyZ"
|
|
13
13
|
},
|
package/CHANGELOG.md
CHANGED
|
@@ -1,5 +1,52 @@
|
|
|
1
1
|
# Changelog
|
|
2
2
|
|
|
3
|
+
## 4.1.8 — 2026-10-19(24h backlog 清扫:25 个切片,棱镜与证据链收紧,测试判定重新成为代码属性)
|
|
4
|
+
|
|
5
|
+
**版本级别**: 未发布区间 `v4.1.7..HEAD` 共 **57 个 commit**(**5 feat / 14 fix / 2 refactor / 3 test / 1 ci / 31 docs / 1 memory**)。取 **patch**,依维护者 2026-07-22 的常设规则"默认版本新增采用最小的版本位"。本版**无破坏性 CLI 变更**;有两处刻意的行为收紧(`config` 请求的 security review 现在按 rid 分文件;reviewer 的 `schemaPath` 缺失会在 provider 调用前拒绝),升级路径均已覆盖。
|
|
6
|
+
|
|
7
|
+
### 1. 证据链与前置条件(`4f15ccaf`、`3ad4aef4`、`bd559bc4`、`2468133e`、`fbb98dc9`)
|
|
8
|
+
|
|
9
|
+
- **缺失与存在但不合法被区分**:前置条件检查现在返回 `absent` / `body` 两种 kind,`LINT_GATE_FAILED` 点名具体 artifact 与行号,不再让"文件不存在"和"文件在但内容不合规"共用一句报错。
|
|
10
|
+
- **`- type:` / `- state:` 在作者时校验**:角色感知的取值校验,缺失 `- state:` 行也会被 lint 抓住;`request init` 写出裸 token,`feature (…)` 这类括注不再能通过。
|
|
11
|
+
- **`getSessionDir` 真正执行单段契约**:`a/b` 不再被当作合法 session id,34 个调用点不受影响。
|
|
12
|
+
- **`rd/security-review.md` / `rd/third-party-review.md` 按 rid 分文件**:两个切片在同一次会话中不再互相覆盖;裸路径保留为 back-compat legacy 层。
|
|
13
|
+
|
|
14
|
+
### 2. Third-party reviewer(`64238afa`、`bedfb7af`、`e5f839cb`)
|
|
15
|
+
|
|
16
|
+
- `skip` 不再伪装成 `passed: true`;`peaks reviewer config` 有完整的 flag 驱动面,`status` 区分未配置 / provider 不足 / 已配置。
|
|
17
|
+
- `THIRD_PARTY_REVIEW` 解析 `rd/third-party-review-<rid>.md`;producer 在第一次 `mkdir` 前用 `REQUEST_ID_PATTERN` 校验 rid;commit-leg 接受清单按 declared 路径键控,并接受该行自己的 legacy 层作为同 `until` 的别名——v4.1.7 播种的旧清单不会被升级打断。
|
|
18
|
+
- `distinctFromKarpathy` 两侧都把 `skipped`/空视为"无可比 family";`schemaPath` 变为真正读取项:绝对路径 → 项目副本 → 包内副本,全部缺失时在调用 provider 前以 `SCHEMA_MISSING` 拒绝并列出所有候选,`status` 报告获胜路径与来源。
|
|
19
|
+
|
|
20
|
+
### 3. Lint 与策略(`f4809134`、`6b733390`、`cd3f5637`)
|
|
21
|
+
|
|
22
|
+
- eslint 的 dot-directory 不再静默跳过;`peaks lint --config` 与 `lint baseline --baseline-file` 的读/写路径一致;空作用域有显式 `EMPTY_SCOPE` 而非静默零。baseline 只减不增的棘轮保持,三个切片期间曾两次拒绝上涨。
|
|
23
|
+
|
|
24
|
+
### 4. Dispatch / job(`8fec96be`、`ad3a72a2`、`aee3532d`)
|
|
25
|
+
|
|
26
|
+
- `--isolation container` 恢复真实退出码与 JSON envelope(`child.unref()` 推迟到 `close`)。
|
|
27
|
+
- `job subagent-cleanup` 只在真正收尾了 ledger 行时报告 `cleaned:true`。
|
|
28
|
+
- `--from-dag` 校验每个节点的 role。
|
|
29
|
+
|
|
30
|
+
### 5. Release 与模板(`59867889`、`41073d7a`)
|
|
31
|
+
|
|
32
|
+
- `readReleaseState` 对未知 stage 失败关闭。
|
|
33
|
+
- QA 模板在 `openspec/changes/` 缺失时渲染 `- N/A — …`,不再把无法填写的 `<id>` 段交给 QA 再因未填而拒绝;目录存在时保持原文。
|
|
34
|
+
|
|
35
|
+
### 6. 测试判定成为代码属性(`b6174b8c`)
|
|
36
|
+
|
|
37
|
+
- **daemon spawn lock 的真实 bug**:`writeFileSync({flag:'wx'})` 是先建后写,并发读者把零字节 body 当 stale,删除活锁后各自起一个 daemon。现在"年轻且不可读"视为持有,回收是原子 quarantine rename + moved-body + own-create 校验,还原用 `COPYFILE_EXCL`,release 不删不属于自己的年轻锁。
|
|
38
|
+
- 六个负载敏感测试:四个按文件超时、walker 只排除自己的临时 fixture 树、`staged-size-leg` 的判定改为 `judgeChangeSet`(非空但全在策略外的变更集与干净树同义),并带 synthetic 输入与 throwing control——回退修复在干净 checkout 上也会变红。
|
|
39
|
+
|
|
40
|
+
### 7. CI(`ec477874`)
|
|
41
|
+
|
|
42
|
+
- `ci.yml` 的七个 job 全部设置 `timeout-minutes`(20–60),不再继承 GitHub 的 360 分钟默认。
|
|
43
|
+
|
|
44
|
+
### 8. 文档与记忆(`df379817`、`83373f67`、`15ba24bd`、`92b17867`、`664de2b5`)
|
|
45
|
+
|
|
46
|
+
- `docs/superpowers/**` 的历史计划文档显式豁免引用完整性;`.peaks/memory/` 的 36 个指针类 / 47 处机械修复(skill 迁移、mut 包抽取、`integration/` 缩写)。
|
|
47
|
+
- security-audit SKILL 写明 `--judged` 循环的终止条件(先冻结 `src/`、审计最后、修复后只重跑一次、其余记为 accepted residual)。
|
|
48
|
+
- backlog 增加 `## Decision record — 2026-10-19`:meta 层保持冻结、体积债只维持 ratchet、integration 不进入默认配置、覆盖率地板等首个全绿 CI、中文 README 为权威;其余残余逐条写明接受理由。
|
|
49
|
+
|
|
3
50
|
## 4.1.7 — 2026-10-18(提交腿硬门、契约表派生、过期债棘轮,以及 canonical store 与 IDE skill 树的漂移检查)
|
|
4
51
|
|
|
5
52
|
**版本级别**: 未发布区间 `v4.1.6..HEAD` 共 **5 个 commit**(**1 feat / 2 refactor / 1 chore / 1 docs**)。取 **patch**,依维护者 2026-07-22 的常设规则"默认版本新增采用最小的版本位"。
|
|
@@ -30,7 +30,24 @@ import { buildDagSuccessEnvelope } from './dispatch-dag-envelope.js';
|
|
|
30
30
|
import { emitDagFailure } from './dispatch-dag-failure.js';
|
|
31
31
|
import { assertGraphNodesMapped, loadDagRuntime, readDagOrFail, resolveDagIds, topologicalLevelsOrFail } from './dispatch-dag-preflight.js';
|
|
32
32
|
import { makeCliRunner, makeNoopWriter, planFirstLevelWaves, resolveDagDispatcher } from './dispatch-dag-runners.js';
|
|
33
|
+
import { RECOMMENDED_ROLES, validateRole } from './sub-agent-shared.js';
|
|
33
34
|
export async function runDispatchFromDag(role, options, asJson, io) {
|
|
35
|
+
// Backlog §2.1: the warm path refuses an invalid role in `preflightDispatch`,
|
|
36
|
+
// but this branch returns before it ever runs. Validate here, before the DAG
|
|
37
|
+
// file is opened, so both paths share one rule and no DAG work can start.
|
|
38
|
+
const validation = validateRole(role);
|
|
39
|
+
if (validation !== null) {
|
|
40
|
+
emitDagFailure(io, asJson, {
|
|
41
|
+
role,
|
|
42
|
+
code: 'INVALID_ROLE',
|
|
43
|
+
message: validation,
|
|
44
|
+
nextActions: [
|
|
45
|
+
'Use a non-empty role string with no control characters.',
|
|
46
|
+
`Recommended: ${RECOMMENDED_ROLES}.`
|
|
47
|
+
]
|
|
48
|
+
});
|
|
49
|
+
return;
|
|
50
|
+
}
|
|
34
51
|
if (!options.fromDag)
|
|
35
52
|
return;
|
|
36
53
|
const scope = { role, asJson, io };
|
|
@@ -11,12 +11,12 @@
|
|
|
11
11
|
// `tests/unit/standards/gratuitous-async-guard.test.ts`, which keys its 14-site
|
|
12
12
|
// set on `file | declaration text`.
|
|
13
13
|
import { Command } from 'commander';
|
|
14
|
-
import { ok } from 'peaks-loop-shared/result';
|
|
14
|
+
import { fail, ok } from 'peaks-loop-shared/result';
|
|
15
15
|
import { addJsonOption, printResult } from '../cli-helpers.js';
|
|
16
16
|
import { JobStateStore } from '../../services/job/job-state-store.js';
|
|
17
17
|
import { JobRotation } from '../../services/job/job-rotation.js';
|
|
18
18
|
import { SubAgentJobWrapper } from '../../services/job/subagent-job-wrapper.js';
|
|
19
|
-
import { asJson } from './job-command-shared.js';
|
|
19
|
+
import { asJson, failResult } from './job-command-shared.js';
|
|
20
20
|
import { SESSION_ID_HELP, resolveJobStateRoot } from './job-state-root.js';
|
|
21
21
|
import { registerJobInitStatusCommands } from './job-init-status-commands.js';
|
|
22
22
|
import { registerJobCheckpointCommands } from './job-checkpoint-commands.js';
|
|
@@ -48,15 +48,25 @@ function registerJobSubagentCleanupCommand(job, io) {
|
|
|
48
48
|
.command('subagent-cleanup')
|
|
49
49
|
.requiredOption('--job-id <jid>')
|
|
50
50
|
.requiredOption('--batch-id <bid>')
|
|
51
|
-
.option('--force')
|
|
51
|
+
.option('--force', 'clean ledger rows whose status is not queued')
|
|
52
52
|
.option('--session-id <sid>', SESSION_ID_HELP)
|
|
53
53
|
.option('--project <repo>')).action(async (opts) => {
|
|
54
|
-
const
|
|
54
|
+
const { rootDir, sessionId, projectRoot } = resolveJobStateRoot(opts, opts.jobId);
|
|
55
|
+
const wrapper = new SubAgentJobWrapper(new JobStateStore(rootDir), () => Promise.resolve({ batchId: opts.batchId }));
|
|
55
56
|
const r = await wrapper.cleanup({
|
|
56
57
|
jobId: opts.jobId,
|
|
57
58
|
batchId: opts.batchId,
|
|
58
|
-
force: !!opts.force
|
|
59
|
+
force: !!opts.force,
|
|
60
|
+
projectRoot,
|
|
61
|
+
sessionId
|
|
59
62
|
});
|
|
63
|
+
if (!r.cleaned) {
|
|
64
|
+
failResult(io, fail('subagent-cleanup', 'BATCH_NOT_CLEANED', `No queued ledger entry for batch ${opts.batchId} in session ${sessionId}; nothing was cleaned.`, r, [
|
|
65
|
+
`The ledger is .peaks/_sub_agents/${sessionId}/active-dispatches.json — check --batch-id.`,
|
|
66
|
+
...(r.skipped.length > 0 ? ['Rows in a non-queued status need --force.'] : [])
|
|
67
|
+
]), opts);
|
|
68
|
+
return;
|
|
69
|
+
}
|
|
60
70
|
printResult(io, ok('subagent-cleanup', r), asJson(opts));
|
|
61
71
|
});
|
|
62
72
|
}
|
|
@@ -0,0 +1,15 @@
|
|
|
1
|
+
import { type EslintRunResult } from '../../services/lint/eslint-runner.js';
|
|
2
|
+
import { type ProgramIO } from '../cli-helpers.js';
|
|
3
|
+
export type LintBaselineOptions = {
|
|
4
|
+
scope?: string;
|
|
5
|
+
config?: string;
|
|
6
|
+
timeoutMs?: string;
|
|
7
|
+
json?: boolean;
|
|
8
|
+
baselineFile?: string;
|
|
9
|
+
allowEmpty?: boolean;
|
|
10
|
+
};
|
|
11
|
+
export declare function writeBaselineJson(projectRoot: string, baselineFile: string, result: EslintRunResult): {
|
|
12
|
+
path: string;
|
|
13
|
+
violations: number;
|
|
14
|
+
};
|
|
15
|
+
export declare function emitBaseline(io: ProgramIO, options: LintBaselineOptions, timeoutMs: number | undefined): void;
|
|
@@ -0,0 +1,64 @@
|
|
|
1
|
+
/**
|
|
2
|
+
* `peaks lint baseline` writer — split out of `lint-commands.ts` for the
|
|
3
|
+
* 300-raw-line cap. Writes the project baseline and refuses to write one from a
|
|
4
|
+
* run that examined nothing (backlog §2.41).
|
|
5
|
+
*/
|
|
6
|
+
import { mkdirSync, writeFileSync } from 'node:fs';
|
|
7
|
+
import { dirname, join } from 'node:path';
|
|
8
|
+
import { fail, ok } from 'peaks-loop-shared/result';
|
|
9
|
+
import { CLI_VERSION } from 'peaks-loop-shared/version';
|
|
10
|
+
import { repoRelativeKey } from '../../shared/path-utils.js';
|
|
11
|
+
import { resolveProjectRoot, runEslint } from '../../services/lint/eslint-runner.js';
|
|
12
|
+
import { printResult } from '../cli-helpers.js';
|
|
13
|
+
export function writeBaselineJson(projectRoot, baselineFile, result) {
|
|
14
|
+
const fullPath = join(projectRoot, baselineFile);
|
|
15
|
+
mkdirSync(dirname(fullPath), { recursive: true });
|
|
16
|
+
// Write the SAME key the reader matches on. Writing ESLint's absolute
|
|
17
|
+
// `filePath` here is what re-rooted the file on whichever machine ran the
|
|
18
|
+
// command, so the next checkout inherited keys it could not match.
|
|
19
|
+
const violations = result.findings.map((f) => ({
|
|
20
|
+
ruleId: f.ruleId,
|
|
21
|
+
file: repoRelativeKey(f.filePath, projectRoot),
|
|
22
|
+
line: f.line,
|
|
23
|
+
severity: f.severity,
|
|
24
|
+
message: f.message
|
|
25
|
+
}));
|
|
26
|
+
const payload = {
|
|
27
|
+
version: 1,
|
|
28
|
+
generatedAt: new Date().toISOString(),
|
|
29
|
+
toolVersion: `peaks-loop-${CLI_VERSION}`,
|
|
30
|
+
violations
|
|
31
|
+
};
|
|
32
|
+
writeFileSync(fullPath, JSON.stringify(payload, null, 2), 'utf8');
|
|
33
|
+
return { path: fullPath, violations: violations.length };
|
|
34
|
+
}
|
|
35
|
+
export function emitBaseline(io, options, timeoutMs) {
|
|
36
|
+
const cwd = process.cwd();
|
|
37
|
+
// The flag governs BOTH sides: the runner subtracts the named file below,
|
|
38
|
+
// and `writeBaselineJson` writes back to it.
|
|
39
|
+
const baselineFile = options.baselineFile ?? '.peaks/lint/baseline.json';
|
|
40
|
+
const result = runEslint({
|
|
41
|
+
cwd,
|
|
42
|
+
diffOnly: false,
|
|
43
|
+
baselineFile,
|
|
44
|
+
...(options.scope !== undefined ? { scope: options.scope } : {}),
|
|
45
|
+
...(options.config !== undefined ? { configPath: options.config } : {}),
|
|
46
|
+
...(options.allowEmpty === true ? { allowEmpty: true } : {}),
|
|
47
|
+
...(timeoutMs !== undefined ? { timeoutMs } : {})
|
|
48
|
+
});
|
|
49
|
+
// §2.41: an empty population must never erase every recorded violation.
|
|
50
|
+
if (result.state !== 'ok' && result.state !== 'baseline-missing') {
|
|
51
|
+
printResult(io, fail('code.lint.baseline', result.state.toUpperCase().replace(/-/g, '_'), `peaks code lint baseline state: ${result.state}${result.reason === undefined ? '' : ` — ${result.reason}`}`, { ...result }, ['Nothing was written; the existing baseline is unchanged.']), options.json);
|
|
52
|
+
return;
|
|
53
|
+
}
|
|
54
|
+
const written = writeBaselineJson(resolveProjectRoot(cwd), baselineFile, result);
|
|
55
|
+
printResult(io, ok('code.lint.baseline', {
|
|
56
|
+
state: result.state,
|
|
57
|
+
findings: result.findings.length,
|
|
58
|
+
checkedFiles: result.checkedFiles,
|
|
59
|
+
ignoredFiles: result.ignoredFiles,
|
|
60
|
+
...written
|
|
61
|
+
}, [], [
|
|
62
|
+
'Commit baseline.json (or .gitignore it). Peaks-Loop ships its own baseline as a reference fixture.'
|
|
63
|
+
]), options.json);
|
|
64
|
+
}
|
|
@@ -2,10 +2,9 @@ import { mkdirSync, writeFileSync } from 'node:fs';
|
|
|
2
2
|
import { dirname, join } from 'node:path';
|
|
3
3
|
import { addJsonOption, getErrorMessage, printResult } from '../cli-helpers.js';
|
|
4
4
|
import { fail, ok } from 'peaks-loop-shared/result';
|
|
5
|
-
import { CLI_VERSION } from 'peaks-loop-shared/version';
|
|
6
|
-
import { repoRelativeKey } from '../../shared/path-utils.js';
|
|
7
5
|
import { detectEslint } from '../../services/lint/detect-eslint.js';
|
|
8
|
-
import {
|
|
6
|
+
import { runEslint } from '../../services/lint/eslint-runner.js';
|
|
7
|
+
import { emitBaseline } from './lint-baseline-command.js';
|
|
9
8
|
function parseTimeoutMs(value) {
|
|
10
9
|
if (value === undefined)
|
|
11
10
|
return undefined;
|
|
@@ -15,28 +14,6 @@ function parseTimeoutMs(value) {
|
|
|
15
14
|
}
|
|
16
15
|
return parsed;
|
|
17
16
|
}
|
|
18
|
-
function writeBaselineJson(projectRoot, baselineFile, result) {
|
|
19
|
-
const fullPath = join(projectRoot, baselineFile);
|
|
20
|
-
mkdirSync(dirname(fullPath), { recursive: true });
|
|
21
|
-
// Write the SAME key the reader matches on. Writing ESLint's absolute
|
|
22
|
-
// `filePath` here is what re-rooted the file on whichever machine ran
|
|
23
|
-
// the command, so the next checkout inherited keys it could not match.
|
|
24
|
-
const violations = result.findings.map((f) => ({
|
|
25
|
-
ruleId: f.ruleId,
|
|
26
|
-
file: repoRelativeKey(f.filePath, projectRoot),
|
|
27
|
-
line: f.line,
|
|
28
|
-
severity: f.severity,
|
|
29
|
-
message: f.message
|
|
30
|
-
}));
|
|
31
|
-
const payload = {
|
|
32
|
-
version: 1,
|
|
33
|
-
generatedAt: new Date().toISOString(),
|
|
34
|
-
toolVersion: `peaks-loop-${CLI_VERSION}`,
|
|
35
|
-
violations
|
|
36
|
-
};
|
|
37
|
-
writeFileSync(fullPath, JSON.stringify(payload, null, 2), 'utf8');
|
|
38
|
-
return { path: fullPath, violations: violations.length };
|
|
39
|
-
}
|
|
40
17
|
function writeRedLineSummary(cwd, result) {
|
|
41
18
|
const fullPath = join(cwd, '.peaks/memory/lint-redline-summary.md');
|
|
42
19
|
mkdirSync(dirname(fullPath), { recursive: true });
|
|
@@ -69,6 +46,24 @@ function writeRedLineSummary(cwd, result) {
|
|
|
69
46
|
writeFileSync(fullPath, lines.join('\n'), 'utf8');
|
|
70
47
|
return { path: fullPath, ruleIds: result.redLine.map((r) => r.ruleId) };
|
|
71
48
|
}
|
|
49
|
+
function checkRunOptions(options, cwd, timeoutMs) {
|
|
50
|
+
return {
|
|
51
|
+
cwd,
|
|
52
|
+
...(options.scope !== undefined ? { scope: options.scope } : {}),
|
|
53
|
+
...(options.config !== undefined ? { configPath: options.config } : {}),
|
|
54
|
+
...(options.baselineFile !== undefined ? { baselineFile: options.baselineFile } : {}),
|
|
55
|
+
...(options.allowEmpty === true ? { allowEmpty: true } : {}),
|
|
56
|
+
...(timeoutMs !== undefined ? { timeoutMs } : {})
|
|
57
|
+
};
|
|
58
|
+
}
|
|
59
|
+
/** §2.41: an opted-in empty population still warns instead of reading green. */
|
|
60
|
+
function populationWarnings(result) {
|
|
61
|
+
if (result.checkedFiles !== 0)
|
|
62
|
+
return [];
|
|
63
|
+
return [
|
|
64
|
+
'checkedFiles=0 — the requested scope examined no files, so its finding count says nothing (--allow-empty opted in).'
|
|
65
|
+
];
|
|
66
|
+
}
|
|
72
67
|
export function registerLintCommands(program, io) {
|
|
73
68
|
const lint = program
|
|
74
69
|
.command('lint')
|
|
@@ -92,7 +87,8 @@ export function registerLintCommands(program, io) {
|
|
|
92
87
|
.option('--config <path>', 'explicit ESLint config path')
|
|
93
88
|
.option('--timeout-ms <ms>', 'subprocess timeout in milliseconds (default 60000)')
|
|
94
89
|
.option('--baseline-file <path>', 'baseline JSON path (default .peaks/lint/baseline.json)')
|
|
95
|
-
.option('--red-line', 'also write .peaks/memory/lint-redline-summary.md')
|
|
90
|
+
.option('--red-line', 'also write .peaks/memory/lint-redline-summary.md')
|
|
91
|
+
.option('--allow-empty', 'accept a scope that examined 0 files instead of refusing it')).action((options) => {
|
|
96
92
|
let timeoutMs;
|
|
97
93
|
try {
|
|
98
94
|
timeoutMs = parseTimeoutMs(options.timeoutMs);
|
|
@@ -102,20 +98,13 @@ export function registerLintCommands(program, io) {
|
|
|
102
98
|
return;
|
|
103
99
|
}
|
|
104
100
|
const cwd = process.cwd();
|
|
105
|
-
const
|
|
106
|
-
cwd,
|
|
107
|
-
...(options.scope !== undefined ? { scope: options.scope } : {}),
|
|
108
|
-
...(options.configPath !== undefined ? { configPath: options.configPath } : {}),
|
|
109
|
-
...(options.baselineFile !== undefined ? { baselineFile: options.baselineFile } : {}),
|
|
110
|
-
...(timeoutMs !== undefined ? { timeoutMs } : {})
|
|
111
|
-
};
|
|
112
|
-
const result = runEslint(runOptions);
|
|
101
|
+
const result = runEslint(checkRunOptions(options, cwd, timeoutMs));
|
|
113
102
|
const extras = {};
|
|
114
103
|
if (options.redLine === true) {
|
|
115
104
|
extras.redLineSummary = writeRedLineSummary(cwd, result);
|
|
116
105
|
}
|
|
117
106
|
const envelope = result.state === 'ok' || result.state === 'baseline-missing'
|
|
118
|
-
? ok('code.lint', { ...result, ...extras },
|
|
107
|
+
? ok('code.lint', { ...result, ...extras }, populationWarnings(result), [])
|
|
119
108
|
: fail('code.lint', result.state.toUpperCase().replace(/-/g, '_'), `peaks code lint state: ${result.state}${result.reason === undefined ? '' : ` — ${result.reason}`}`, { ...result, ...extras }, [
|
|
120
109
|
'The reason above names which condition fired; a spawn timeout wants a larger --timeout-ms.'
|
|
121
110
|
]);
|
|
@@ -127,7 +116,8 @@ export function registerLintCommands(program, io) {
|
|
|
127
116
|
.option('--scope <path>', 'lint scope (default: project root)')
|
|
128
117
|
.option('--config <path>', 'explicit ESLint config path')
|
|
129
118
|
.option('--timeout-ms <ms>', 'subprocess timeout in milliseconds (default 60000)')
|
|
130
|
-
.option('--baseline-file <path>', 'baseline JSON
|
|
119
|
+
.option('--baseline-file <path>', 'baseline JSON path, read for existing waivers and written with the scan (default .peaks/lint/baseline.json)')
|
|
120
|
+
.option('--allow-empty', 'accept a scope that examined 0 files instead of refusing it')).action((options) => {
|
|
131
121
|
let timeoutMs;
|
|
132
122
|
try {
|
|
133
123
|
timeoutMs = parseTimeoutMs(options.timeoutMs);
|
|
@@ -136,20 +126,6 @@ export function registerLintCommands(program, io) {
|
|
|
136
126
|
printResult(io, fail('code.lint.baseline', 'INVALID_TIMEOUT', getErrorMessage(error), { state: 'execution-failed' }, ['Re-run with --timeout-ms <positive integer>.']), options.json);
|
|
137
127
|
return;
|
|
138
128
|
}
|
|
139
|
-
|
|
140
|
-
const runOptions = {
|
|
141
|
-
cwd,
|
|
142
|
-
diffOnly: false,
|
|
143
|
-
...(options.scope !== undefined ? { scope: options.scope } : {}),
|
|
144
|
-
...(options.configPath !== undefined ? { configPath: options.configPath } : {}),
|
|
145
|
-
...(timeoutMs !== undefined ? { timeoutMs } : {})
|
|
146
|
-
};
|
|
147
|
-
const result = runEslint(runOptions);
|
|
148
|
-
const baselineFile = options.baselineFile ?? '.peaks/lint/baseline.json';
|
|
149
|
-
const written = writeBaselineJson(resolveProjectRoot(cwd), baselineFile, result);
|
|
150
|
-
const envelope = ok('code.lint.baseline', { state: result.state, findings: result.findings.length, ...written }, [], [
|
|
151
|
-
'Commit baseline.json (or .gitignore it). Peak-loop ships its own baseline as a reference fixture.'
|
|
152
|
-
]);
|
|
153
|
-
printResult(io, envelope, options.json);
|
|
129
|
+
emitBaseline(io, options, timeoutMs);
|
|
154
130
|
});
|
|
155
131
|
}
|
|
@@ -49,6 +49,12 @@ export type RequestLintOptions = {
|
|
|
49
49
|
sessionId?: string;
|
|
50
50
|
json?: boolean;
|
|
51
51
|
};
|
|
52
|
+
export type RequestMarkQaInitiatedOptions = {
|
|
53
|
+
project: string;
|
|
54
|
+
/** Restrict the artifact lookup to one session; omitted, the artifact's own session is used. */
|
|
55
|
+
sessionId?: string;
|
|
56
|
+
json?: boolean;
|
|
57
|
+
};
|
|
52
58
|
export type RequestRepairStatusOptions = {
|
|
53
59
|
project: string;
|
|
54
60
|
sessionId?: string;
|
|
@@ -1,4 +1,5 @@
|
|
|
1
1
|
import { registerRequestInitCommand } from './request-init-command.js';
|
|
2
|
+
import { registerRequestMarkQaInitiatedCommand } from './request-mark-qa-initiated-command.js';
|
|
2
3
|
import { registerRequestListCommand } from './request-list-command.js';
|
|
3
4
|
import { registerRequestShowCommand } from './request-show-command.js';
|
|
4
5
|
import { registerRequestRetagCommand } from './request-retag-command.js';
|
|
@@ -12,6 +13,7 @@ const REQUEST_DESCRIPTION = 'Manage per-request Peaks role artifacts (PRD / UI /
|
|
|
12
13
|
export function registerRequestCommands(program, io) {
|
|
13
14
|
const request = program.command('request').description(REQUEST_DESCRIPTION);
|
|
14
15
|
registerRequestInitCommand(request, io);
|
|
16
|
+
registerRequestMarkQaInitiatedCommand(request, io);
|
|
15
17
|
registerRequestListCommand(request, io);
|
|
16
18
|
registerRequestShowCommand(request, io);
|
|
17
19
|
registerRequestRetagCommand(request, io);
|
|
@@ -0,0 +1,80 @@
|
|
|
1
|
+
import { fail, ok } from 'peaks-loop-shared/result';
|
|
2
|
+
import { markQaInitiated } from '../../services/artifacts/qa-initiated-marker.js';
|
|
3
|
+
import { showRequestArtifact } from '../../services/artifacts/request-artifact-service.js';
|
|
4
|
+
import { isUnsafePathInput } from '../../shared/path-safety.js';
|
|
5
|
+
import { addJsonOption, getErrorMessage, printResult } from '../cli-helpers.js';
|
|
6
|
+
const MARK_DESCRIPTION = 'Create the qa/.initiated marker for a session whose QA request artifact already exists. Idempotent: a second call changes nothing, and the request artifact is never touched.';
|
|
7
|
+
const MARK_REQUEST_ID_HELP = 'request id of the existing QA artifact';
|
|
8
|
+
const MARK_PROJECT_HELP = 'target project root';
|
|
9
|
+
const MARK_SESSION_HELP = 'restrict the artifact lookup to a specific session id';
|
|
10
|
+
function failMark(io, json, failure) {
|
|
11
|
+
printResult(io, fail('request.mark-qa-initiated', failure.code, failure.message, failure.data, failure.nextActions), json);
|
|
12
|
+
process.exitCode = 1;
|
|
13
|
+
}
|
|
14
|
+
/**
|
|
15
|
+
* The artifact is the anchor: the marker lands in THAT artifact's session, so
|
|
16
|
+
* a caller who omits `--session-id` cannot mark a different session by
|
|
17
|
+
* accident. A missing artifact refuses rather than writing the marker, because
|
|
18
|
+
* then nothing records that QA was ever invoked.
|
|
19
|
+
*/
|
|
20
|
+
async function findQaArtifact(requestId, options) {
|
|
21
|
+
const showOptions = {
|
|
22
|
+
projectRoot: options.project,
|
|
23
|
+
role: 'qa',
|
|
24
|
+
requestId
|
|
25
|
+
};
|
|
26
|
+
if (options.sessionId !== undefined)
|
|
27
|
+
showOptions.sessionId = options.sessionId;
|
|
28
|
+
return await showRequestArtifact(showOptions);
|
|
29
|
+
}
|
|
30
|
+
function artifactMissingFailure(requestId, options) {
|
|
31
|
+
return {
|
|
32
|
+
code: 'QA_ARTIFACT_MISSING',
|
|
33
|
+
message: `No QA request artifact found for requestId=${requestId}; the marker records that the artifact already exists`,
|
|
34
|
+
data: { requestId },
|
|
35
|
+
nextActions: [
|
|
36
|
+
`Run \`peaks request init --role qa --id ${requestId} --project ${options.project} --apply\` to create the artifact and the marker together`
|
|
37
|
+
]
|
|
38
|
+
};
|
|
39
|
+
}
|
|
40
|
+
async function runRequestMarkQaInitiated(requestId, options, io) {
|
|
41
|
+
try {
|
|
42
|
+
if (options.sessionId !== undefined && isUnsafePathInput(options.sessionId)) {
|
|
43
|
+
failMark(io, options.json, {
|
|
44
|
+
code: 'INVALID_SESSION_ID',
|
|
45
|
+
message: `Invalid session id: ${options.sessionId} (must be a single path segment)`,
|
|
46
|
+
data: { provided: options.sessionId },
|
|
47
|
+
nextActions: ['Pass a session id that is a single path segment']
|
|
48
|
+
});
|
|
49
|
+
return;
|
|
50
|
+
}
|
|
51
|
+
const artifact = await findQaArtifact(requestId, options);
|
|
52
|
+
if (artifact === null) {
|
|
53
|
+
failMark(io, options.json, artifactMissingFailure(requestId, options));
|
|
54
|
+
return;
|
|
55
|
+
}
|
|
56
|
+
const result = await markQaInitiated({
|
|
57
|
+
projectRoot: options.project,
|
|
58
|
+
sessionId: artifact.sessionId
|
|
59
|
+
});
|
|
60
|
+
printResult(io, ok('request.mark-qa-initiated', { requestId, sessionId: artifact.sessionId, path: result.path, created: result.created }, [], result.created ? [] : [`qa/.initiated already existed at ${result.path}; nothing changed`]), options.json);
|
|
61
|
+
}
|
|
62
|
+
catch (error) {
|
|
63
|
+
failMark(io, options.json, {
|
|
64
|
+
code: 'REQUEST_MARK_QA_INITIATED_FAILED',
|
|
65
|
+
message: getErrorMessage(error),
|
|
66
|
+
data: { requestId },
|
|
67
|
+
nextActions: [
|
|
68
|
+
'Verify the project path, session id, and the existing QA artifact before retrying'
|
|
69
|
+
]
|
|
70
|
+
});
|
|
71
|
+
}
|
|
72
|
+
}
|
|
73
|
+
export function registerRequestMarkQaInitiatedCommand(request, io) {
|
|
74
|
+
addJsonOption(request
|
|
75
|
+
.command('mark-qa-initiated')
|
|
76
|
+
.description(MARK_DESCRIPTION)
|
|
77
|
+
.argument('<request-id>', MARK_REQUEST_ID_HELP)
|
|
78
|
+
.requiredOption('--project <path>', MARK_PROJECT_HELP)
|
|
79
|
+
.option('--session-id <session>', MARK_SESSION_HELP)).action((requestId, options) => runRequestMarkQaInitiated(requestId, options, io));
|
|
80
|
+
}
|
|
@@ -56,6 +56,7 @@ function reportLintGateFailure(io, options, error) {
|
|
|
56
56
|
printResult(io, fail('request.transition', error.code, error.message, {
|
|
57
57
|
role: error.role,
|
|
58
58
|
newState: error.newState,
|
|
59
|
+
path: error.path,
|
|
59
60
|
errorCount: error.errorCount,
|
|
60
61
|
findings: error.findings
|
|
61
62
|
}, [
|
|
@@ -1,13 +1,13 @@
|
|
|
1
1
|
/**
|
|
2
|
-
* `peaks reviewer run
|
|
3
|
-
*
|
|
2
|
+
* `peaks reviewer run|status` — CLI surface for the G4 third-party reviewer.
|
|
3
|
+
* `peaks reviewer config` lives in reviewer-config-commands.ts (file-size cap).
|
|
4
4
|
*
|
|
5
|
-
* peaks reviewer run
|
|
6
|
-
* peaks reviewer status [--json]
|
|
5
|
+
* peaks reviewer run --rid <rid> [--write] [--session-id <id>] [--project <path>] [--json]
|
|
6
|
+
* peaks reviewer status [--project <path>] [--json]
|
|
7
7
|
*
|
|
8
8
|
* The CLI never silently prompts for API keys. When `~/.peaks/config.json`
|
|
9
|
-
* has no `reviewer` section,
|
|
10
|
-
* and
|
|
9
|
+
* has no usable `reviewer` section, `run` emits the skip envelope (which is
|
|
10
|
+
* NOT a pass) and exits 0, consistent with fallbackOnError=skip.
|
|
11
11
|
*/
|
|
12
12
|
import type { Command } from 'commander';
|
|
13
13
|
import { type ProgramIO } from '../cli-helpers.js';
|