peaks-loop 4.1.4 → 4.1.5
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 +7 -2
- package/CHANGELOG.md +112 -0
- package/README-en.md +1 -1
- package/README.md +1 -1
- package/dist/cli/cli-helpers.d.ts +20 -0
- package/dist/cli/cli-helpers.js +34 -0
- package/dist/cli/commands/_register.js +2 -0
- package/dist/cli/commands/code-commands.d.ts +6 -4
- package/dist/cli/commands/code-commands.js +6 -4
- package/dist/cli/commands/code-gate-command.d.ts +5 -5
- package/dist/cli/commands/code-gate-command.js +49 -9
- package/dist/cli/commands/code-mode-gate-plan-command.d.ts +1 -1
- package/dist/cli/commands/code-mode-gate-plan-command.js +2 -2
- package/dist/cli/commands/core/memory-extract-command.js +10 -5
- package/dist/cli/commands/dispatch-cli-invocation-check.d.ts +108 -0
- package/dist/cli/commands/dispatch-cli-invocation-check.js +87 -0
- package/dist/cli/commands/dispatch-cli-invocation-scan.d.ts +66 -0
- package/dist/cli/commands/dispatch-cli-invocation-scan.js +162 -0
- package/dist/cli/commands/dispatch-commands.js +12 -5
- package/dist/cli/commands/dispatch-preflight.js +46 -0
- package/dist/cli/commands/dispatch-prompt-composition.d.ts +6 -0
- package/dist/cli/commands/dispatch-prompt-composition.js +29 -7
- package/dist/cli/commands/doc-commands.js +1 -1
- package/dist/cli/commands/feedback-commands-helpers.js +1 -1
- package/dist/cli/commands/final-review-prepare-command.js +22 -1
- package/dist/cli/commands/gate-commands-enforce.js +3 -3
- package/dist/cli/commands/hook-handle.js +41 -20
- package/dist/cli/commands/lint-commands.js +3 -1
- package/dist/cli/commands/loop-eval-capture-index.js +2 -4
- package/dist/cli/commands/perf-audit-commands.js +15 -5
- package/dist/cli/commands/project-commands.js +9 -6
- package/dist/cli/commands/race-commands.d.ts +15 -0
- package/dist/cli/commands/race-commands.js +65 -0
- package/dist/cli/commands/race-pilot-gate-record-command.d.ts +3 -0
- package/dist/cli/commands/race-pilot-gate-record-command.js +81 -0
- package/dist/cli/commands/request-command-options.d.ts +8 -0
- package/dist/cli/commands/request-commands.js +2 -0
- package/dist/cli/commands/request-init-command.js +67 -12
- package/dist/cli/commands/request-retag-command.d.ts +3 -0
- package/dist/cli/commands/request-retag-command.js +50 -0
- package/dist/cli/commands/request-show-command.d.ts +8 -0
- package/dist/cli/commands/request-show-command.js +14 -1
- package/dist/cli/commands/request-transition-command.js +12 -4
- package/dist/cli/commands/request-transition-failures.d.ts +14 -0
- package/dist/cli/commands/request-transition-failures.js +45 -3
- package/dist/cli/commands/scan-scope-commands.js +2 -2
- package/dist/cli/commands/security-audit-commands.js +26 -6
- package/dist/cli/commands/worktree-lease-gc-command.js +1 -1
- package/dist/services/artifacts/artifact-contract-block.d.ts +53 -0
- package/dist/services/artifacts/artifact-contract-block.js +212 -0
- package/dist/services/artifacts/artifact-prerequisites.d.ts +27 -19
- package/dist/services/artifacts/artifact-prerequisites.js +63 -133
- package/dist/services/artifacts/artifact-templates.d.ts +1 -1
- package/dist/services/artifacts/artifact-templates.js +17 -10
- package/dist/services/artifacts/prerequisite-checks.d.ts +87 -0
- package/dist/services/artifacts/prerequisite-checks.js +198 -0
- package/dist/services/artifacts/prerequisite-transition-event.d.ts +20 -0
- package/dist/services/artifacts/prerequisite-transition-event.js +27 -0
- package/dist/services/artifacts/request-artifact-metadata.d.ts +31 -0
- package/dist/services/artifacts/request-artifact-metadata.js +44 -0
- package/dist/services/artifacts/request-artifact-service.d.ts +5 -0
- package/dist/services/artifacts/request-artifact-service.js +23 -51
- package/dist/services/artifacts/request-artifact-state-helpers.d.ts +12 -0
- package/dist/services/artifacts/request-artifact-state-helpers.js +28 -4
- package/dist/services/artifacts/request-retag-service.d.ts +68 -0
- package/dist/services/artifacts/request-retag-service.js +125 -0
- package/dist/services/artifacts/request-state-order.d.ts +38 -0
- package/dist/services/artifacts/request-state-order.js +99 -0
- package/dist/services/artifacts/request-type-demand.d.ts +44 -0
- package/dist/services/artifacts/request-type-demand.js +71 -0
- package/dist/services/audit/audit-goal-service.d.ts +7 -0
- package/dist/services/audit/enforcers/active-skill-resolver.d.ts +18 -0
- package/dist/services/audit/enforcers/active-skill-resolver.js +48 -1
- package/dist/services/audit/enforcers/code-ban.d.ts +11 -2
- package/dist/services/audit/enforcers/code-ban.js +21 -1
- package/dist/services/audit/red-line-catalog-p2-a-bee-runtime.d.ts +17 -0
- package/dist/services/audit/red-line-catalog-p2-a-bee-runtime.js +24 -7
- package/dist/services/audit-independent/handoff-missing-refusal.d.ts +26 -0
- package/dist/services/audit-independent/handoff-missing-refusal.js +109 -0
- package/dist/services/audit-independent/handoff-readers.d.ts +37 -0
- package/dist/services/audit-independent/handoff-readers.js +81 -0
- package/dist/services/audit-independent/index.d.ts +6 -1
- package/dist/services/audit-independent/index.js +6 -1
- package/dist/services/audit-independent/judged-declaration-build.d.ts +48 -0
- package/dist/services/audit-independent/judged-declaration-build.js +73 -0
- package/dist/services/audit-independent/judged-declaration-check.d.ts +79 -0
- package/dist/services/audit-independent/judged-declaration-check.js +155 -0
- package/dist/services/audit-independent/judged-declaration.d.ts +94 -0
- package/dist/services/audit-independent/judged-declaration.js +218 -0
- package/dist/services/audit-independent/perf-audit-service.js +12 -14
- package/dist/services/audit-independent/security-audit-artifact.d.ts +28 -0
- package/dist/services/audit-independent/security-audit-artifact.js +90 -0
- package/dist/services/audit-independent/security-audit-service.d.ts +6 -53
- package/dist/services/audit-independent/security-audit-service.js +34 -178
- package/dist/services/capability-guard-runner/contracts/J05.js +60 -14
- package/dist/services/codegraph/codegraph-index-integrity.js +2 -0
- package/dist/services/context/build-dispatch-system-prompt.d.ts +3 -3
- package/dist/services/context/build-dispatch-system-prompt.js +7 -7
- package/dist/services/context/collector.js +5 -1
- package/dist/services/dispatch/active-dispatch-index.d.ts +36 -0
- package/dist/services/dispatch/active-dispatch-index.js +118 -0
- package/dist/services/dispatch/batch-counter.js +1 -2
- package/dist/services/dispatch/dispatch-record-writer.d.ts +29 -16
- package/dist/services/dispatch/dispatch-record-writer.js +58 -100
- package/dist/services/dispatch/dispatch-sub-agent.js +1 -1
- package/dist/services/dispatch/karpathy-block.d.ts +55 -0
- package/dist/services/dispatch/karpathy-block.js +101 -0
- package/dist/services/dispatch/ledger-reaper.d.ts +80 -0
- package/dist/services/dispatch/ledger-reaper.js +131 -0
- package/dist/services/evidence/evidence-generator.js +15 -8
- package/dist/services/feedback/feedback-promotion-service.d.ts +8 -11
- package/dist/services/feedback/feedback-promotion-service.js +30 -35
- package/dist/services/feedback/promotion-artifact-json-evidence.d.ts +18 -0
- package/dist/services/feedback/promotion-artifact-missing.d.ts +22 -0
- package/dist/services/feedback/promotion-artifact-missing.js +63 -0
- package/dist/services/final-review/final-review-contract.d.ts +95 -4
- package/dist/services/final-review/final-review-contract.js +64 -0
- package/dist/services/final-review/final-review-delivery.d.ts +13 -0
- package/dist/services/final-review/final-review-delivery.js +26 -12
- package/dist/services/final-review/final-review-evidence-collect.js +8 -53
- package/dist/services/final-review/final-review-evidence-records.d.ts +21 -0
- package/dist/services/final-review/final-review-evidence-records.js +67 -0
- package/dist/services/final-review/final-review-evidence-sources.d.ts +22 -0
- package/dist/services/final-review/final-review-evidence-sources.js +28 -4
- package/dist/services/final-review/final-review-prompt.js +19 -6
- package/dist/services/final-review/final-review-runner.js +5 -0
- package/dist/services/final-review/final-review-service.d.ts +2 -2
- package/dist/services/final-review/index.d.ts +1 -1
- package/dist/services/final-review/pre-post-diff.d.ts +2 -75
- package/dist/services/final-review/pre-post-diff.js +60 -59
- package/dist/services/hooks/pre-tool-code-gate.d.ts +7 -1
- package/dist/services/hooks/pre-tool-code-gate.js +21 -2
- package/dist/services/hooks/worktree-authorization-gate.js +6 -31
- package/dist/services/hooks/worktree-refusal-messages.d.ts +74 -0
- package/dist/services/hooks/worktree-refusal-messages.js +102 -0
- package/dist/services/lint/eslint-runner-support.d.ts +1 -1
- package/dist/services/lint/eslint-runner-support.js +2 -1
- package/dist/services/lint/eslint-runner-types.d.ts +8 -0
- package/dist/services/lint/eslint-runner.js +17 -4
- package/dist/services/llm/anthropic-runner.js +24 -7
- package/dist/services/loop/loop-observability.d.ts +39 -0
- package/dist/services/loop/loop-observability.js +55 -0
- package/dist/services/loop/monotonic-guard.js +6 -9
- package/dist/services/loop/monotonic-runner.js +8 -7
- package/dist/services/loop/run-driver.js +18 -22
- package/dist/services/memory/project-memory-service/index/kind-dispatch.js +14 -1
- package/dist/services/memory/project-memory-service/index/project-memory-plan-exec.js +13 -2
- package/dist/services/memory/project-memory-service/index.d.ts +2 -2
- package/dist/services/memory/project-memory-service/index.js +1 -1
- package/dist/services/memory/project-memory-service/parsers/frontmatter-parse.d.ts +36 -0
- package/dist/services/memory/project-memory-service/parsers/frontmatter-parse.js +48 -2
- package/dist/services/memory/project-memory-service/parsers/markdown-pure.d.ts +23 -1
- package/dist/services/memory/project-memory-service/parsers/markdown-pure.js +37 -0
- package/dist/services/memory/project-memory-service/types.d.ts +32 -0
- package/dist/services/observability/observability-service.d.ts +7 -0
- package/dist/services/observability/observability-service.js +2 -1
- package/dist/services/prd/gate-evidence-derivation.d.ts +4 -3
- package/dist/services/prd/gate-evidence-derivation.js +4 -3
- package/dist/services/qa/bdd-test-style-verifier.js +22 -8
- package/dist/services/race/gate2-evaluator.d.ts +58 -0
- package/dist/services/race/gate2-evaluator.js +111 -0
- package/dist/services/race/gate2-policy.d.ts +17 -0
- package/dist/services/race/gate2-policy.js +31 -0
- package/dist/services/race/lane-phase.d.ts +19 -0
- package/dist/services/race/lane-phase.js +113 -0
- package/dist/services/race/pilot-gate-store.d.ts +67 -0
- package/dist/services/race/pilot-gate-store.js +227 -0
- package/dist/services/scan/file-size-baseline.d.ts +26 -0
- package/dist/services/scan/file-size-baseline.js +150 -0
- package/dist/services/scan/file-size-scan.d.ts +42 -3
- package/dist/services/scan/file-size-scan.js +58 -42
- package/dist/services/scan/type-sanity-service.js +13 -3
- package/dist/services/skill/resume-detector.js +3 -3
- package/dist/services/skills/hooks-codegate-superpowers.d.ts +5 -6
- package/dist/services/skills/hooks-codegate-superpowers.js +7 -8
- package/dist/services/skills/hooks-settings-service.d.ts +1 -1
- package/dist/services/skills/hooks-settings-service.js +1 -1
- package/dist/services/skills/presence-lease-order.d.ts +13 -0
- package/dist/services/skills/presence-lease-order.js +24 -0
- package/dist/services/skills/skill-conformance-service.js +1 -0
- package/dist/services/skills/skill-statusline-service.js +4 -7
- package/dist/services/slice/slice-check-service.js +8 -8
- package/dist/services/workflow/pipeline-verify-gate-support.js +2 -1
- package/dist/services/workflow/pipeline-verify-service.js +1 -1
- package/dist/services/workflow/workflow-skip-service.d.ts +0 -20
- package/dist/services/workflow/workflow-skip-service.js +3 -4
- package/dist/services/workspace/claude-settings-retirements.d.ts +54 -0
- package/dist/services/workspace/claude-settings-retirements.js +112 -0
- package/dist/services/workspace/claude-settings-template-merge.d.ts +35 -15
- package/dist/services/workspace/claude-settings-template-merge.js +33 -53
- package/dist/services/workspace/claude-settings-template.d.ts +62 -12
- package/dist/services/workspace/claude-settings-template.js +58 -58
- package/dist/services/workspace/migrate-1-4-1-service.js +3 -0
- package/dist/services/workspace/reconcile-service.js +0 -1
- package/dist/shared/incrementing-number.d.ts +10 -0
- package/dist/shared/incrementing-number.js +27 -0
- package/package.json +5 -5
- package/skills/bee/peaks-perf-audit/SKILL.md +1 -1
- package/skills/bee/peaks-prd/SKILL.md +1 -1
- package/skills/bee/peaks-qa/SKILL.md +1 -1
- package/skills/bee/peaks-qa/references/qa-sub-agent-dispatch.md +2 -2
- package/skills/bee/peaks-qa/references/qa-transition-gates.md +1 -1
- package/skills/bee/peaks-rd/SKILL.md +2 -2
- package/skills/bee/peaks-rd/references/rd-fanout-contracts.md +1 -1
- package/skills/bee/peaks-rd/references/rd-sub-agent-dispatch.md +8 -4
- package/skills/bee/peaks-rd/references/rd-transition-gates.md +3 -3
- package/skills/bee/peaks-rd/references/v2-12-fanout-collapse.md +2 -2
- package/skills/bee/peaks-rd/references/writing-handoff-frontmatter.md +1 -1
- package/skills/bee/peaks-reviewer/SKILL.md +1 -1
- package/skills/bee/peaks-sc/SKILL.md +1 -1
- package/skills/bee/peaks-security-audit/SKILL.md +10 -2
- package/skills/bee/peaks-txt/SKILL.md +4 -3
- package/skills/bee/peaks-ui/SKILL.md +3 -3
- package/skills/peaks-audit/SKILL.md +29 -1
- package/skills/peaks-code/SKILL.md +5 -2
- package/skills/peaks-code/references/fast-lane-norm.md +42 -0
- package/skills/peaks-code/references/fast-mode.md +3 -2
- package/skills/peaks-code/references/local-artifact-workspace.md +3 -3
- package/skills/peaks-code/references/micro-cycle.md +3 -3
- package/skills/peaks-code/references/resume-detection.md +1 -1
- package/skills/peaks-code/references/runbook.md +12 -6
- package/skills/peaks-code/references/step-11-memory-sediment.md +4 -0
- package/skills/peaks-code/references/sub-agent-dispatch.md +1 -1
- package/skills/peaks-code/references/swarm-dispatch-contract.md +40 -16
- package/skills/peaks-code/references/workflow-gates-and-types.md +6 -6
- package/skills/peaks-code/references/worktree-governance.md +4 -4
- package/skills/peaks-content/SKILL.md +1 -1
- package/skills/peaks-doctor/SKILL.md +1 -1
- package/skills/peaks-final-review/SKILL.md +31 -11
- package/skills/peaks-ide/SKILL.md +1 -1
- package/skills/peaks-issue-fix-orchestrator/SKILL.md +1 -1
- package/skills/peaks-race-code/SKILL.md +185 -0
- package/skills/peaks-resume/SKILL.md +1 -1
- package/skills/peaks-slice-decompose/SKILL.md +1 -1
- package/skills/peaks-solo/SKILL.md +1 -1
- package/skills/peaks-sop/SKILL.md +1 -1
- package/skills/peaks-status/SKILL.md +1 -1
- package/skills/peaks-test/SKILL.md +7 -4
- package/dist/services/audit/enforcers/lint-peaks-skill-runtime.d.ts +0 -23
- package/dist/services/audit/enforcers/lint-peaks-skill-runtime.js +0 -64
|
@@ -0,0 +1,150 @@
|
|
|
1
|
+
// src/services/scan/file-size-baseline.ts
|
|
2
|
+
//
|
|
3
|
+
// The git side of the diff-scoped file-size scan: WHICH files changed against a
|
|
4
|
+
// base ref, and HOW BIG each was at that ref. Together they make the scan a
|
|
5
|
+
// RATCHET — a file that is over its cap but no larger than its own state at that
|
|
6
|
+
// ref is accepted, and only growth past the cap is refused. Same rule as the
|
|
7
|
+
// commit gate's "a file you touch may not be WORSE than it was"
|
|
8
|
+
// (`.husky/peaks-gate.mjs`).
|
|
9
|
+
//
|
|
10
|
+
// FAIL-CLOSED ON BOTH GIT READS. The enumeration and the size probe both name
|
|
11
|
+
// their failure instead of swallowing it: a ratchet whose input list can
|
|
12
|
+
// silently become empty is not a ratchet, and `catch { return [] }` cannot tell
|
|
13
|
+
// "git refused to enumerate" from "nothing changed".
|
|
14
|
+
//
|
|
15
|
+
// RENAMES ARE JUDGED, NOT DROPPED. A rename is enumerated as `R` and compared
|
|
16
|
+
// against the OLD path's size at `baseRef`, so a pure rename passes and a
|
|
17
|
+
// rename that grows is refused naming the growth. The `--diff-filter=AM`
|
|
18
|
+
// spelling this replaced excluded `R` by accident — a file could grow past its
|
|
19
|
+
// cap and stay invisible to the scan simply by being renamed in the same
|
|
20
|
+
// commit.
|
|
21
|
+
//
|
|
22
|
+
// KNOWN, RECORDED, NOT FIXED — a DELETION is invisible: `D` entries are dropped
|
|
23
|
+
// before the measurement, and that is left as it is because a deletion cannot
|
|
24
|
+
// grow. It is a documentation matter, not a hole in the ratchet.
|
|
25
|
+
//
|
|
26
|
+
// KNOWN, RECORDED, NOT FIXED — subprocess cost is `2 + 2K` git spawns, where K
|
|
27
|
+
// is the changed files that are OVER their cap (one `cat-file -e` plus one
|
|
28
|
+
// `show` each, inside the scan's `lines > cap` branch; the 2 are the
|
|
29
|
+
// enumerations above). It is linear in OVER-CAP changed files, not in changed
|
|
30
|
+
// files: 10 changed with 0 over spawns 2, with 2 over spawns 6, with 5 over
|
|
31
|
+
// spawns 12; 40 changed with 3 over spawns 8 and with 40 over spawns 82. At
|
|
32
|
+
// roughly 58 ms per process on the measured host that is 0.8 s at K=5 and 4.7 s
|
|
33
|
+
// at K=40, paid once per slice on a human-run command with two call sites.
|
|
34
|
+
// Batching every baseline read through one `git cat-file --batch` on stdin is
|
|
35
|
+
// the known fix if the many-over-cap case ever becomes real; it is not
|
|
36
|
+
// warranted at these numbers.
|
|
37
|
+
//
|
|
38
|
+
// Split out of `file-size-scan.ts`. That file was 237 raw lines at the split
|
|
39
|
+
// (not "at its cap"): the point is that this logic did not fit under 300 there,
|
|
40
|
+
// and the scan now depends on this module rather than on a hand-rolled list.
|
|
41
|
+
// This module's own name matches the `file-size` pattern the walk-based
|
|
42
|
+
// policy-wiring rule (`policyWiringFindings` in
|
|
43
|
+
// `tests/unit/standards/_file-size-cap-scan.ts`, asserted by
|
|
44
|
+
// `tests/unit/standards/file-size-cap.test.ts`) requires to import
|
|
45
|
+
// `file-size-policy.ts`; that test's literal fixtures name `file-size-scan.ts`,
|
|
46
|
+
// not this file.
|
|
47
|
+
import { execFileSync, spawnSync } from 'node:child_process';
|
|
48
|
+
import { countRawLines, normalizePolicyPath } from './file-size-policy.js';
|
|
49
|
+
/** A git read the scan needs could not be completed. Thrown, never returned:
|
|
50
|
+
* the alternative is an empty file list that reads as "nothing changed". */
|
|
51
|
+
export class GitReadFailedError extends Error {
|
|
52
|
+
code = 'FILE_SIZE_GIT_READ_FAILED';
|
|
53
|
+
constructor(what, projectRoot, detail) {
|
|
54
|
+
super(`File-size scan refused: ${what} could not be read from git in ${projectRoot} ` +
|
|
55
|
+
`(${detail}). A git failure is not "nothing changed"; fix the ref/path, or pass ` +
|
|
56
|
+
'a `baseRef` that resolves.');
|
|
57
|
+
this.name = 'GitReadFailedError';
|
|
58
|
+
}
|
|
59
|
+
}
|
|
60
|
+
function gitLines(projectRoot, args) {
|
|
61
|
+
let raw;
|
|
62
|
+
try {
|
|
63
|
+
raw = execFileSync('git', ['-C', projectRoot, ...args], {
|
|
64
|
+
encoding: 'utf8',
|
|
65
|
+
windowsHide: true
|
|
66
|
+
});
|
|
67
|
+
}
|
|
68
|
+
catch (error) {
|
|
69
|
+
const detail = error instanceof Error ? (error.message.split('\n')[0] ?? '') : String(error);
|
|
70
|
+
throw new GitReadFailedError(`\`git ${args.join(' ')}\``, projectRoot, detail);
|
|
71
|
+
}
|
|
72
|
+
return raw
|
|
73
|
+
.split(/\r?\n/)
|
|
74
|
+
.map((line) => line.trim())
|
|
75
|
+
.filter(Boolean);
|
|
76
|
+
}
|
|
77
|
+
/**
|
|
78
|
+
* The caller's list, intersected with what git reports — or the whole change set when
|
|
79
|
+
* the caller named none. Compared in the policy's POSIX spelling, because a
|
|
80
|
+
* Windows-native caller path and a git-reported one spell the same file differently.
|
|
81
|
+
*
|
|
82
|
+
* INTERSECTION, NOT POPULATION. The commit hook is handed the STAGED paths by
|
|
83
|
+
* lint-staged, so it knows its set and the set is narrower than the working tree: a
|
|
84
|
+
* modification nobody staged is not part of that commit, and measuring it would block
|
|
85
|
+
* the commit over a file it was never asked about. A named path git does not report as
|
|
86
|
+
* changed is therefore skipped, never measured — this narrows; it cannot widen.
|
|
87
|
+
*/
|
|
88
|
+
function restrictedTo(all, only) {
|
|
89
|
+
if (only === undefined)
|
|
90
|
+
return [...all];
|
|
91
|
+
const wanted = new Set(only.map(normalizePolicyPath));
|
|
92
|
+
return all.filter((file) => wanted.has(normalizePolicyPath(file)));
|
|
93
|
+
}
|
|
94
|
+
/**
|
|
95
|
+
* The changed-file population the scan measures, as `git diff --name-status`
|
|
96
|
+
* reports it. `A`/`M` keep their path; `R`/`C` keep the TARGET path and record
|
|
97
|
+
* the source, so the rename is judged against the size the file had before it
|
|
98
|
+
* moved; `D` is dropped. A git failure here THROWS rather than returning `[]`.
|
|
99
|
+
*
|
|
100
|
+
* `only` is the caller's own list, when it has one — see `restrictedTo`.
|
|
101
|
+
*/
|
|
102
|
+
export function readChangedFiles(projectRoot, baseRef, only) {
|
|
103
|
+
const paths = [];
|
|
104
|
+
const renameSources = new Map();
|
|
105
|
+
for (const line of gitLines(projectRoot, ['diff', '--name-status', baseRef])) {
|
|
106
|
+
const [status, first, second] = line.split('\t');
|
|
107
|
+
if (status === undefined || first === undefined)
|
|
108
|
+
continue;
|
|
109
|
+
if ((status.startsWith('R') || status.startsWith('C')) && second !== undefined) {
|
|
110
|
+
paths.push(second);
|
|
111
|
+
renameSources.set(second, first);
|
|
112
|
+
}
|
|
113
|
+
else if (status.startsWith('A') || status.startsWith('M')) {
|
|
114
|
+
paths.push(first);
|
|
115
|
+
}
|
|
116
|
+
}
|
|
117
|
+
const untracked = gitLines(projectRoot, ['ls-files', '--others', '--exclude-standard']);
|
|
118
|
+
const allPaths = Array.from(new Set([...paths, ...untracked]));
|
|
119
|
+
return {
|
|
120
|
+
paths: restrictedTo(allPaths, only),
|
|
121
|
+
baselinePathFor: (file) => renameSources.get(file) ?? file
|
|
122
|
+
};
|
|
123
|
+
}
|
|
124
|
+
/**
|
|
125
|
+
* Whether `git cat-file -e` could resolve `<baseRef>:<file>`, i.e. whether the
|
|
126
|
+
* probe EXITED ZERO. What a non-zero exit actually measures is wider than "the
|
|
127
|
+
* ref has no such path": a bad or unreadable ref (a misspelled name, or `HEAD~1`
|
|
128
|
+
* on a root commit) and any other git failure exit non-zero too and are read
|
|
129
|
+
* identically. That conflation is fail-closed — no baseline means
|
|
130
|
+
* `previousLines: null`, which the scan reads as "created over the cap" and
|
|
131
|
+
* refuses. Stated so the next reader does not take the narrow reading.
|
|
132
|
+
*/
|
|
133
|
+
function pathExistsAtRef(projectRoot, baseRef, file) {
|
|
134
|
+
const probe = spawnSync('git', ['-C', projectRoot, 'cat-file', '-e', `${baseRef}:${file}`], {
|
|
135
|
+
stdio: 'ignore',
|
|
136
|
+
windowsHide: true
|
|
137
|
+
});
|
|
138
|
+
return probe.status === 0;
|
|
139
|
+
}
|
|
140
|
+
/** The file's raw-line count AT `baseRef`, or `null` when the ref has no such
|
|
141
|
+
* path — i.e. the change ADDED the file and it is over the cap by creation. */
|
|
142
|
+
export function readBaseLineCount(projectRoot, baseRef, file) {
|
|
143
|
+
if (!pathExistsAtRef(projectRoot, baseRef, file)) {
|
|
144
|
+
return null;
|
|
145
|
+
}
|
|
146
|
+
return countRawLines(execFileSync('git', ['-C', projectRoot, 'show', `${baseRef}:${file}`], {
|
|
147
|
+
encoding: 'utf8',
|
|
148
|
+
windowsHide: true
|
|
149
|
+
}));
|
|
150
|
+
}
|
|
@@ -29,6 +29,17 @@ export type FileSizeViolation = {
|
|
|
29
29
|
/** The cap this file was measured against, resolved per path by the policy
|
|
30
30
|
* module (300 raw lines; 500 under root `tests/`), or the caller's override. */
|
|
31
31
|
cap: number;
|
|
32
|
+
/**
|
|
33
|
+
* The file's raw-line count at `baseRef`, or `null` when the file did not
|
|
34
|
+
* exist there — i.e. THIS change CREATED it over the cap.
|
|
35
|
+
*
|
|
36
|
+
* A changed file that is over its cap but NOT larger than its own state at
|
|
37
|
+
* `baseRef` is not a violation: the whole-tree `fileSizeOverCap` ratchet
|
|
38
|
+
* already accepts it as a standing quantity, so touching it must stay legal.
|
|
39
|
+
* Only growth travels here — including growth that a rename carried along,
|
|
40
|
+
* which is measured against the pre-rename path.
|
|
41
|
+
*/
|
|
42
|
+
previousLines: number | null;
|
|
32
43
|
};
|
|
33
44
|
export type FileSizeScanResult = {
|
|
34
45
|
ok: boolean;
|
|
@@ -41,10 +52,17 @@ export type FileSizeScanResult = {
|
|
|
41
52
|
* records). Reported so the exemption is auditable rather than a silent
|
|
42
53
|
* skip. */
|
|
43
54
|
exemptFiles: string[];
|
|
44
|
-
/** Files that appeared in `git diff` but no longer exist on disk
|
|
45
|
-
*
|
|
46
|
-
* ENOENT; now they are reported here as informational data. */
|
|
55
|
+
/** Files that appeared in `git diff` but no longer exist on disk. Pre-#015
|
|
56
|
+
* the scan crashed on these via ENOENT; now they are reported, not counted. */
|
|
47
57
|
deletedFiles: string[];
|
|
58
|
+
/**
|
|
59
|
+
* Changed files that ARE over their cap right now but this change did not
|
|
60
|
+
* enlarge (they were already that large at `baseRef`, or larger). They
|
|
61
|
+
* are NOT violations — the ratchet accepts them — but they are named here
|
|
62
|
+
* rather than dropped, so "0 violations" cannot mean "nothing was over the
|
|
63
|
+
* cap"; the same reason `exemptFiles` and `outOfScopeFiles` exist.
|
|
64
|
+
*/
|
|
65
|
+
acceptedOverCapFiles: string[];
|
|
48
66
|
/** Changed files the file-size policy does not measure at all: outside its
|
|
49
67
|
* four scope directories, or with an extension it does not count. Reported
|
|
50
68
|
* rather than silently skipped, for the same reason `exemptFiles` is.
|
|
@@ -74,5 +92,26 @@ export type FileSizeScanOptions = {
|
|
|
74
92
|
* the policy is the default, this option only overrides it.
|
|
75
93
|
*/
|
|
76
94
|
threshold?: number;
|
|
95
|
+
/**
|
|
96
|
+
* The caller's own list, when it has one — the commit hook is handed the STAGED
|
|
97
|
+
* paths by lint-staged. It RESTRICTS the git change set (a path git does not
|
|
98
|
+
* report as changed is skipped, never measured) and never widens it; omitted,
|
|
99
|
+
* git alone decides the population.
|
|
100
|
+
*/
|
|
101
|
+
files?: readonly string[];
|
|
77
102
|
};
|
|
103
|
+
/**
|
|
104
|
+
* The diff-scoped scan, judged as a RATCHET: a changed file is a violation only
|
|
105
|
+
* when THIS change enlarged it — it grew past its cap, or was created over it.
|
|
106
|
+
* A file that is over its cap but no larger than its own state at `baseRef`
|
|
107
|
+
* passes, because the baseline already carries it as an accepted over-cap
|
|
108
|
+
* quantity (`ceilings.fileSizeOverCap`) and `request transition rd →
|
|
109
|
+
* implemented` refusing to touch any of those files is the contradiction that
|
|
110
|
+
* blocked two consecutive slices. A rename is judged against the size the file
|
|
111
|
+
* had before it moved, so moving a file is not itself growth.
|
|
112
|
+
*
|
|
113
|
+
* THROWS `GitReadFailedError` when git cannot enumerate the changed files (an
|
|
114
|
+
* unresolvable `baseRef`, a non-repo path) — an empty list must mean "nothing
|
|
115
|
+
* changed", never "the read failed". `readChangedFiles` owns that refusal.
|
|
116
|
+
*/
|
|
78
117
|
export declare function scanFileSize(options: FileSizeScanOptions): FileSizeScanResult;
|
|
@@ -1,7 +1,7 @@
|
|
|
1
|
-
import { execFileSync } from 'node:child_process';
|
|
2
1
|
import { existsSync, readFileSync, statSync } from 'node:fs';
|
|
3
2
|
import { join } from 'node:path';
|
|
4
3
|
import { countRawLines, fileSizeCapFor, isPolicyMeasuredFile } from './file-size-policy.js';
|
|
4
|
+
import { readBaseLineCount, readChangedFiles } from './file-size-baseline.js';
|
|
5
5
|
/**
|
|
6
6
|
* Paths exempt from the file-size cap. The cap is Karpathy's "Simplicity
|
|
7
7
|
* First": it exists to make a human *simplify* an over-long file. A path is
|
|
@@ -59,30 +59,37 @@ export function isSizeCapExempt(file) {
|
|
|
59
59
|
const normalized = file.replace(/\\/g, '/');
|
|
60
60
|
return SIZE_CAP_EXEMPT_PATTERNS.some((pattern) => exemptPatternToRegExp(pattern).test(normalized));
|
|
61
61
|
}
|
|
62
|
-
function
|
|
62
|
+
function countLines(filePath) {
|
|
63
|
+
return countRawLines(readFileSync(filePath, 'utf8'));
|
|
64
|
+
}
|
|
65
|
+
/**
|
|
66
|
+
* Pre-#015: `readFileSync` threw ENOENT for a path in `git diff` that no longer
|
|
67
|
+
* exists on disk, aborting the whole `request transition rd → implemented` flow.
|
|
68
|
+
* A deleted path has no lines to count, so it is reported in `deletedFiles` and
|
|
69
|
+
* skipped. `readChangedFiles` already excludes `--diff-filter=D`.
|
|
70
|
+
*/
|
|
71
|
+
function classifyPath(absolute) {
|
|
72
|
+
if (existsSync(absolute))
|
|
73
|
+
return 'present';
|
|
63
74
|
try {
|
|
64
|
-
|
|
65
|
-
// (--diff-filter=D) are intentionally excluded: they have no on-disk
|
|
66
|
-
// body to count, and a refactor that deletes large files is exactly
|
|
67
|
-
// when the gate should NOT block. Slice #015 fix.
|
|
68
|
-
const trackedRaw = execFileSync('git', ['-C', projectRoot, 'diff', '--name-only', '--diff-filter=AM', baseRef], { encoding: 'utf8', windowsHide: true });
|
|
69
|
-
const tracked = trackedRaw
|
|
70
|
-
.split(/\r?\n/)
|
|
71
|
-
.map((line) => line.trim())
|
|
72
|
-
.filter(Boolean);
|
|
73
|
-
const untrackedRaw = execFileSync('git', ['-C', projectRoot, 'ls-files', '--others', '--exclude-standard'], { encoding: 'utf8', windowsHide: true });
|
|
74
|
-
const untracked = untrackedRaw
|
|
75
|
-
.split(/\r?\n/)
|
|
76
|
-
.map((line) => line.trim())
|
|
77
|
-
.filter(Boolean);
|
|
78
|
-
return Array.from(new Set([...tracked, ...untracked]));
|
|
75
|
+
return statSync(absolute).isFile() ? 'present' : 'not-a-file';
|
|
79
76
|
}
|
|
80
77
|
catch {
|
|
81
|
-
return
|
|
78
|
+
return 'deleted';
|
|
82
79
|
}
|
|
83
80
|
}
|
|
84
|
-
|
|
85
|
-
|
|
81
|
+
/**
|
|
82
|
+
* A file over its cap is a violation only when THIS change enlarged it. One
|
|
83
|
+
* already that large at `baseRef` — or larger — is the accepted quantity the
|
|
84
|
+
* whole-tree `fileSizeOverCap` row counts, so touching it passes; growth past
|
|
85
|
+
* the cap, or creation over it, is refused. `baselinePath` is the path the size
|
|
86
|
+
* is read from: the file itself, or its pre-rename name when it moved.
|
|
87
|
+
*/
|
|
88
|
+
function overCapVerdict(projectRoot, baseRef, baselinePath, lines) {
|
|
89
|
+
const previousLines = readBaseLineCount(projectRoot, baseRef, baselinePath);
|
|
90
|
+
if (previousLines !== null && lines <= previousLines)
|
|
91
|
+
return { regressed: false };
|
|
92
|
+
return { regressed: true, previousLines };
|
|
86
93
|
}
|
|
87
94
|
/**
|
|
88
95
|
* The number a changed file is measured against, or `null` when the policy has no
|
|
@@ -104,43 +111,43 @@ function policyCapFor(file, override) {
|
|
|
104
111
|
return override;
|
|
105
112
|
return isPolicyMeasuredFile(file) ? fileSizeCapFor(file) : null;
|
|
106
113
|
}
|
|
114
|
+
/**
|
|
115
|
+
* The diff-scoped scan, judged as a RATCHET: a changed file is a violation only
|
|
116
|
+
* when THIS change enlarged it — it grew past its cap, or was created over it.
|
|
117
|
+
* A file that is over its cap but no larger than its own state at `baseRef`
|
|
118
|
+
* passes, because the baseline already carries it as an accepted over-cap
|
|
119
|
+
* quantity (`ceilings.fileSizeOverCap`) and `request transition rd →
|
|
120
|
+
* implemented` refusing to touch any of those files is the contradiction that
|
|
121
|
+
* blocked two consecutive slices. A rename is judged against the size the file
|
|
122
|
+
* had before it moved, so moving a file is not itself growth.
|
|
123
|
+
*
|
|
124
|
+
* THROWS `GitReadFailedError` when git cannot enumerate the changed files (an
|
|
125
|
+
* unresolvable `baseRef`, a non-repo path) — an empty list must mean "nothing
|
|
126
|
+
* changed", never "the read failed". `readChangedFiles` owns that refusal.
|
|
127
|
+
*/
|
|
107
128
|
export function scanFileSize(options) {
|
|
108
129
|
const baseRef = options.baseRef ?? 'HEAD';
|
|
109
130
|
// `null` here means "the policy decides, per file" — the cap is a property of
|
|
110
131
|
// the path (300 raw lines; 500 under root `tests/`), not of the run.
|
|
111
132
|
const override = options.threshold ?? null;
|
|
112
|
-
const
|
|
133
|
+
const changed = readChangedFiles(options.projectRoot, baseRef, options.files);
|
|
113
134
|
const violations = [];
|
|
114
135
|
const deletedFiles = [];
|
|
115
136
|
const exemptFiles = [];
|
|
137
|
+
const acceptedOverCapFiles = [];
|
|
116
138
|
const outOfScopeFiles = [];
|
|
117
139
|
let checkedFiles = 0;
|
|
118
|
-
for (const file of
|
|
140
|
+
for (const file of changed.paths) {
|
|
119
141
|
if (isSizeCapExempt(file)) {
|
|
120
142
|
exemptFiles.push(file);
|
|
121
143
|
continue;
|
|
122
144
|
}
|
|
123
145
|
const absolute = join(options.projectRoot, file);
|
|
124
|
-
|
|
125
|
-
|
|
126
|
-
|
|
127
|
-
// `peaks request transition rd → implemented` flow with
|
|
128
|
-
// `code: PREREQUISITES_MISSING`. Now we skip missing paths — a
|
|
129
|
-
// deleted file has no lines to count. Belt-and-braces: the
|
|
130
|
-
// `getChangedFiles` filter above already excludes `--diff-filter=D`,
|
|
131
|
-
// but a manually-passed `baseRef` (tests) or a path that was
|
|
132
|
-
// untracked-then-deleted still flows through here, so the
|
|
133
|
-
// existsSync guard stays as a second line of defense.
|
|
134
|
-
if (!existsSync(absolute)) {
|
|
135
|
-
try {
|
|
136
|
-
const st = statSync(absolute);
|
|
137
|
-
if (!st.isFile())
|
|
138
|
-
continue;
|
|
139
|
-
}
|
|
140
|
-
catch {
|
|
146
|
+
const pathVerdict = classifyPath(absolute);
|
|
147
|
+
if (pathVerdict !== 'present') {
|
|
148
|
+
if (pathVerdict === 'deleted')
|
|
141
149
|
deletedFiles.push(file);
|
|
142
|
-
|
|
143
|
-
}
|
|
150
|
+
continue;
|
|
144
151
|
}
|
|
145
152
|
// The cap is decided BEFORE the file is counted, because for a path outside the
|
|
146
153
|
// policy there is no cap to decide: it is reported in `outOfScopeFiles` instead
|
|
@@ -154,7 +161,15 @@ export function scanFileSize(options) {
|
|
|
154
161
|
checkedFiles += 1;
|
|
155
162
|
const lines = countLines(absolute);
|
|
156
163
|
if (lines > cap) {
|
|
157
|
-
|
|
164
|
+
// A renamed file is measured against the size it had BEFORE the move.
|
|
165
|
+
const baselinePath = changed.baselinePathFor(file);
|
|
166
|
+
const verdict = overCapVerdict(options.projectRoot, baseRef, baselinePath, lines);
|
|
167
|
+
if (verdict.regressed) {
|
|
168
|
+
violations.push({ file, lines, cap, previousLines: verdict.previousLines });
|
|
169
|
+
}
|
|
170
|
+
else {
|
|
171
|
+
acceptedOverCapFiles.push(file);
|
|
172
|
+
}
|
|
158
173
|
}
|
|
159
174
|
}
|
|
160
175
|
return {
|
|
@@ -163,6 +178,7 @@ export function scanFileSize(options) {
|
|
|
163
178
|
checkedFiles,
|
|
164
179
|
exemptFiles,
|
|
165
180
|
deletedFiles,
|
|
181
|
+
acceptedOverCapFiles,
|
|
166
182
|
outOfScopeFiles,
|
|
167
183
|
violations
|
|
168
184
|
};
|
|
@@ -75,6 +75,18 @@ const CONFIG_NAMES = new Set([
|
|
|
75
75
|
'nx.json'
|
|
76
76
|
]);
|
|
77
77
|
const CONFIG_EXTENSIONS = new Set(['.toml', '.ini', '.cfg', '.env']);
|
|
78
|
+
/**
|
|
79
|
+
* Directory conventions that make every file beneath them a test file. Anchored
|
|
80
|
+
* to WHOLE PATH SEGMENTS, never substrings: `src/services/test-cache/` is an
|
|
81
|
+
* ordinary source directory whose name merely begins with the word, and a
|
|
82
|
+
* word-boundary test cannot tell the two apart — `\b` is satisfied by `-`, so
|
|
83
|
+
* `\btest\b` fired inside `test-cache`. The five words are the five the
|
|
84
|
+
* substring test was reaching for, matched exactly; `cross-pass-edge-static-scan-support.ts`
|
|
85
|
+
* already anchors them the same way.
|
|
86
|
+
*/
|
|
87
|
+
const TEST_DIR_RE = /(^|[\\/])(?:test|tests|__tests__|__mocks__|spec)[\\/]/;
|
|
88
|
+
/** The filename convention — the file itself declares it is a test. */
|
|
89
|
+
const TEST_FILENAME_RE = /\.(test|spec)\.[a-z]+$/i;
|
|
78
90
|
function classifyFile(filePath) {
|
|
79
91
|
const name = basename(filePath);
|
|
80
92
|
const ext = extname(filePath).toLowerCase();
|
|
@@ -92,9 +104,7 @@ function classifyFile(filePath) {
|
|
|
92
104
|
return 'config';
|
|
93
105
|
if (DOCS_EXTENSIONS.has(ext))
|
|
94
106
|
return 'docs';
|
|
95
|
-
|
|
96
|
-
if (/\b(?:tests?|__tests__|__mocks__|spec)\b/.test(filePath) ||
|
|
97
|
-
/\.(test|spec)\.[a-z]+$/i.test(name))
|
|
107
|
+
if (TEST_DIR_RE.test(filePath) || TEST_FILENAME_RE.test(name))
|
|
98
108
|
return 'test';
|
|
99
109
|
if (SOURCE_EXTENSIONS.has(ext))
|
|
100
110
|
return 'source';
|
|
@@ -192,15 +192,15 @@ function classifyTerminalGates(sessionDir, ctx) {
|
|
|
192
192
|
// RD qa-handoff → deepest gate is C. If the review artifacts are
|
|
193
193
|
// missing the state is inconsistent; fall back to rd-review-fanout.
|
|
194
194
|
if (ctx.primaryRd !== null && ctx.primaryRd.state === 'qa-handoff') {
|
|
195
|
-
// the pre-rid names behind it
|
|
196
|
-
// resolves
|
|
197
|
-
// never ran, not that it wrote to a name this reader does not know.
|
|
195
|
+
// the pre-rid names behind it, in the same order the transition gate
|
|
196
|
+
// resolves: an inconsistent-looking slice here means the fan-out never ran.
|
|
198
197
|
const rid = ridOf(ctx.primaryRd.filename);
|
|
199
198
|
const missing = [];
|
|
200
199
|
const codeReviewCandidates = [`rd/code-review-${rid}.md`, 'rd/code-review.md'];
|
|
201
200
|
const securityCandidates = [
|
|
202
201
|
`audit/security-${rid}.md`,
|
|
203
202
|
'audit/security.md',
|
|
203
|
+
`rd/security-review-${rid}.md`,
|
|
204
204
|
'rd/security-review.md'
|
|
205
205
|
];
|
|
206
206
|
if (!codeReviewCandidates.some((rel) => existsSync(join(sessionDir, rel)))) {
|
|
@@ -12,6 +12,7 @@ export declare const HOOK_ENFORCE_SENTINEL = "peaks gate enforce";
|
|
|
12
12
|
*/
|
|
13
13
|
interface ResolvedHookSpec {
|
|
14
14
|
readonly hookEnforceCommand: string;
|
|
15
|
+
readonly hookCodeGateCommand: string;
|
|
15
16
|
readonly hookEnforceSentinel: string;
|
|
16
17
|
readonly hookEnforceMatcher: string;
|
|
17
18
|
readonly hookEnforceEvent: string;
|
|
@@ -73,16 +74,14 @@ export type PeaksHookEntry = {
|
|
|
73
74
|
shell?: string;
|
|
74
75
|
};
|
|
75
76
|
/**
|
|
76
|
-
*
|
|
77
|
-
*
|
|
78
|
-
*
|
|
79
|
-
*
|
|
80
|
-
* encodes the same logic for non-Node harnesses.
|
|
77
|
+
* The code-gate entry's CLI adapter is `src/cli/commands/code-gate-command.ts`,
|
|
78
|
+
* its decision logic is `src/services/hooks/pre-tool-code-gate.ts`, and the
|
|
79
|
+
* shell-script sibling `src/services/hooks/pre-tool-code-gate.sh` encodes the
|
|
80
|
+
* same logic for non-Node harnesses.
|
|
81
81
|
*/
|
|
82
82
|
export declare const HOOK_CODE_GATE_SENTINEL = "peaks code-gate";
|
|
83
83
|
export declare const HOOK_CODE_GATE_MATCHER = "Edit|Write|MultiEdit";
|
|
84
84
|
export declare const HOOK_CODE_GATE_EVENT = "PreToolUse";
|
|
85
|
-
export declare const HOOK_CODE_GATE_COMMAND = "peaks code-gate --json";
|
|
86
85
|
export declare function resolveHookEntries(ide: IdeId, _skipProgress?: boolean): PeaksHookEntry[];
|
|
87
86
|
export declare function resolveLegacySentinels(ide: IdeId): ReadonlyArray<string>;
|
|
88
87
|
/**
|
|
@@ -85,6 +85,7 @@ export function resolveHookSpec(ide) {
|
|
|
85
85
|
const jsonFlag = isClaudeCode ? ' --json' : '';
|
|
86
86
|
return {
|
|
87
87
|
hookEnforceCommand: `${spec.command} --project "\${${adapter.envVar}}"${jsonFlag}`,
|
|
88
|
+
hookCodeGateCommand: `peaks code-gate --project "\${${adapter.envVar}}"${jsonFlag}`,
|
|
88
89
|
hookEnforceSentinel: spec.sentinel,
|
|
89
90
|
hookEnforceMatcher: adapter.toolMatcher,
|
|
90
91
|
hookEnforceEvent: adapter.hookEvent,
|
|
@@ -97,16 +98,14 @@ export function resolveHookSpec(ide) {
|
|
|
97
98
|
};
|
|
98
99
|
}
|
|
99
100
|
/**
|
|
100
|
-
*
|
|
101
|
-
*
|
|
102
|
-
*
|
|
103
|
-
*
|
|
104
|
-
* encodes the same logic for non-Node harnesses.
|
|
101
|
+
* The code-gate entry's CLI adapter is `src/cli/commands/code-gate-command.ts`,
|
|
102
|
+
* its decision logic is `src/services/hooks/pre-tool-code-gate.ts`, and the
|
|
103
|
+
* shell-script sibling `src/services/hooks/pre-tool-code-gate.sh` encodes the
|
|
104
|
+
* same logic for non-Node harnesses.
|
|
105
105
|
*/
|
|
106
106
|
export const HOOK_CODE_GATE_SENTINEL = 'peaks code-gate';
|
|
107
107
|
export const HOOK_CODE_GATE_MATCHER = 'Edit|Write|MultiEdit';
|
|
108
108
|
export const HOOK_CODE_GATE_EVENT = 'PreToolUse';
|
|
109
|
-
export const HOOK_CODE_GATE_COMMAND = `peaks code-gate --json`;
|
|
110
109
|
/**
|
|
111
110
|
* The read-only MCP surface as a hook entry: the same command under the
|
|
112
111
|
* adapter's MCP matcher, or `undefined` for a harness that declares no MCP
|
|
@@ -195,13 +194,13 @@ export function resolveHookEntries(ide, _skipProgress = false) {
|
|
|
195
194
|
event: HOOK_WORKSPACE_INIT_EVENT
|
|
196
195
|
});
|
|
197
196
|
// Edit|Write|MultiEdit matcher. Vendor-neutral command
|
|
198
|
-
// (`peaks code-gate
|
|
197
|
+
// (`peaks code-gate`); the CLI adapter lives in
|
|
199
198
|
// `src/cli/commands/code-gate-command.ts` and the underlying
|
|
200
199
|
// decision logic is in `src/services/hooks/pre-tool-code-gate.ts`.
|
|
201
200
|
entries.push({
|
|
202
201
|
sentinel: HOOK_CODE_GATE_SENTINEL,
|
|
203
202
|
matcher: HOOK_CODE_GATE_MATCHER,
|
|
204
|
-
command:
|
|
203
|
+
command: spec.hookCodeGateCommand,
|
|
205
204
|
event: HOOK_CODE_GATE_EVENT
|
|
206
205
|
});
|
|
207
206
|
// rid 2026-09-13-a2-post-compact-reinject: the post-compaction
|
|
@@ -1,6 +1,6 @@
|
|
|
1
1
|
import type { HookScope } from '../ide/shared/safe-path.js';
|
|
2
2
|
import { type PeaksHookEntry } from './hooks-codegate-superpowers.js';
|
|
3
|
-
export { HOOK_ENFORCE_SENTINEL, HOOK_CODE_GATE_SENTINEL, HOOK_CODE_GATE_MATCHER, HOOK_CODE_GATE_EVENT,
|
|
3
|
+
export { HOOK_ENFORCE_SENTINEL, HOOK_CODE_GATE_SENTINEL, HOOK_CODE_GATE_MATCHER, HOOK_CODE_GATE_EVENT, SUPERPOWERS_DENIED_SKILLS, type PeaksHookEntry } from './hooks-codegate-superpowers.js';
|
|
4
4
|
/**
|
|
5
5
|
* Install (and remove) the Peaks-managed hooks in an IDE's settings.json.
|
|
6
6
|
*
|
|
@@ -3,7 +3,7 @@ import { homedir } from 'node:os';
|
|
|
3
3
|
import { atomicWriteJson } from '../ide/shared/atomic-json.js';
|
|
4
4
|
import { getAdapter } from '../ide/ide-registry.js';
|
|
5
5
|
import { resolveHookSpec, resolveHookEntries, hasHookSpec, resolveLegacySentinels, hasExternalGateExemptions, withExternalGateExemptions } from './hooks-codegate-superpowers.js';
|
|
6
|
-
export { HOOK_ENFORCE_SENTINEL, HOOK_CODE_GATE_SENTINEL, HOOK_CODE_GATE_MATCHER, HOOK_CODE_GATE_EVENT,
|
|
6
|
+
export { HOOK_ENFORCE_SENTINEL, HOOK_CODE_GATE_SENTINEL, HOOK_CODE_GATE_MATCHER, HOOK_CODE_GATE_EVENT, SUPERPOWERS_DENIED_SKILLS } from './hooks-codegate-superpowers.js';
|
|
7
7
|
export { readInstalledEntriesFromSettings } from './hooks-settings-read-installed.js';
|
|
8
8
|
export { TRIGGER_PHRASES, listSuperpowersDenyEntries, withSuperpowersSkillDenylist, withTriggeredDenyList, withoutSuperpowersSkillDenylist, withoutTriggeredDenyList } from './hooks-settings-deny-list.js';
|
|
9
9
|
import { assertSafeSettingsPathCompat, resolveLocalSettingsPath, resolveSettingsRoot } from './hooks-settings-paths.js';
|
|
@@ -0,0 +1,13 @@
|
|
|
1
|
+
import type { SkillPresenceLease } from './presence-lease-types.js';
|
|
2
|
+
/**
|
|
3
|
+
* Most recent lease first: `lastHeartbeat` desc, `startedAt` desc as the
|
|
4
|
+
* tie-break.
|
|
5
|
+
*
|
|
6
|
+
* The tie-break is not decorative. Nothing refreshes the on-disk heartbeat
|
|
7
|
+
* today — no caller runs `setPresenceLease` on a cadence — so `lastHeartbeat`
|
|
8
|
+
* frequently equals `startedAt`, and two leases written in the same millisecond
|
|
9
|
+
* tie on heartbeat alone. That tie then falls through to `Array.prototype.sort`
|
|
10
|
+
* stability, i.e. `readdirSync` order, which is the input this ordering exists
|
|
11
|
+
* to stop depending on.
|
|
12
|
+
*/
|
|
13
|
+
export declare function comparePresenceLeases(a: SkillPresenceLease, b: SkillPresenceLease): number;
|
|
@@ -0,0 +1,24 @@
|
|
|
1
|
+
// Shared ordering for a peaks session's presence leases.
|
|
2
|
+
//
|
|
3
|
+
// Lives on its own because the three readers that need it — the resolver, the
|
|
4
|
+
// statusline projection, and the per-caller legacy read — sit in three modules
|
|
5
|
+
// and none of them owns the other. They used to order the same lease set three
|
|
6
|
+
// ways (two by heartbeat alone, one with a tie-break), so they could name
|
|
7
|
+
// different leases as "who is driving".
|
|
8
|
+
/**
|
|
9
|
+
* Most recent lease first: `lastHeartbeat` desc, `startedAt` desc as the
|
|
10
|
+
* tie-break.
|
|
11
|
+
*
|
|
12
|
+
* The tie-break is not decorative. Nothing refreshes the on-disk heartbeat
|
|
13
|
+
* today — no caller runs `setPresenceLease` on a cadence — so `lastHeartbeat`
|
|
14
|
+
* frequently equals `startedAt`, and two leases written in the same millisecond
|
|
15
|
+
* tie on heartbeat alone. That tie then falls through to `Array.prototype.sort`
|
|
16
|
+
* stability, i.e. `readdirSync` order, which is the input this ordering exists
|
|
17
|
+
* to stop depending on.
|
|
18
|
+
*/
|
|
19
|
+
export function comparePresenceLeases(a, b) {
|
|
20
|
+
const byHeartbeat = (b.lastHeartbeat ?? '').localeCompare(a.lastHeartbeat ?? '');
|
|
21
|
+
if (byHeartbeat !== 0)
|
|
22
|
+
return byHeartbeat;
|
|
23
|
+
return (b.startedAt ?? '').localeCompare(a.startedAt ?? '');
|
|
24
|
+
}
|
|
@@ -1,6 +1,7 @@
|
|
|
1
1
|
import { findProjectRoot } from '../config/config-safety.js';
|
|
2
2
|
import { getSessionIdCanonical } from '../session/session-manager.js';
|
|
3
3
|
import { resolveActiveSkillForCaller } from '../audit/enforcers/active-skill-resolver.js';
|
|
4
|
+
import { comparePresenceLeases } from './presence-lease-order.js';
|
|
4
5
|
import { listPresenceLeases } from './presence-lease-service.js';
|
|
5
6
|
import { read24hOverlay, readActiveLeaf, readCompactState, resolveCallerId, resolveCwdFromStdin } from './skill-statusline-model.js';
|
|
6
7
|
export { parseStatusLineStdin, read24hOverlay } from './skill-statusline-model.js';
|
|
@@ -101,13 +102,9 @@ function readPresenceReadOnly(projectRoot, callerId) {
|
|
|
101
102
|
if (inFlight.length === 0) {
|
|
102
103
|
return { presence: null, invalid: false };
|
|
103
104
|
}
|
|
104
|
-
// Most recent wins
|
|
105
|
-
|
|
106
|
-
|
|
107
|
-
if (hb !== 0)
|
|
108
|
-
return hb;
|
|
109
|
-
return b.startedAt.localeCompare(a.startedAt);
|
|
110
|
-
});
|
|
105
|
+
// Most recent wins, through the shared comparator so every reader of one
|
|
106
|
+
// lease set names the same lease.
|
|
107
|
+
const sorted = inFlight.slice().sort(comparePresenceLeases);
|
|
111
108
|
const latest = sorted[0];
|
|
112
109
|
if (latest === undefined || typeof latest.skill !== 'string' || latest.skill.length === 0) {
|
|
113
110
|
return { presence: null, invalid: false };
|
|
@@ -243,22 +243,22 @@ async function runUnitTests(projectRoot, runTests) {
|
|
|
243
243
|
}
|
|
244
244
|
};
|
|
245
245
|
}
|
|
246
|
-
//
|
|
247
|
-
//
|
|
248
|
-
// in, so this boundary gate and the transition gate agree on which file is
|
|
249
|
-
// a slice's evidence. `<rid>` is substituted at probe time.
|
|
246
|
+
// Candidate order is canonical-first, then the back-compat tiers, mirroring
|
|
247
|
+
// `artifact-prerequisites.ts` (v2.12.0 moved security + perf to audit skills).
|
|
250
248
|
const REVIEW_FILES = [
|
|
251
249
|
{
|
|
252
250
|
name: 'code-review',
|
|
253
251
|
paths: ['rd/code-review-<rid>.md', 'rd/code-review.md'],
|
|
254
252
|
label: 'code-review'
|
|
255
253
|
},
|
|
256
|
-
// v2.12.0 collapse: security + perf moved to standalone audit skills.
|
|
257
|
-
// OR the v2.11.x legacy path during the 1-minor-release back-compat
|
|
258
|
-
// window (v2.13.0 hard-deletes the legacy paths — see CHANGELOG [2.12.0]).
|
|
259
254
|
{
|
|
260
255
|
name: 'security-review',
|
|
261
|
-
paths: [
|
|
256
|
+
paths: [
|
|
257
|
+
'audit/security-<rid>.md',
|
|
258
|
+
'audit/security.md',
|
|
259
|
+
'rd/security-review-<rid>.md',
|
|
260
|
+
'rd/security-review.md'
|
|
261
|
+
],
|
|
262
262
|
label: 'security-review'
|
|
263
263
|
},
|
|
264
264
|
{
|
|
@@ -8,7 +8,8 @@
|
|
|
8
8
|
*/
|
|
9
9
|
import { existsSync, readFileSync } from 'node:fs';
|
|
10
10
|
import { join } from 'node:path';
|
|
11
|
-
import { getPrerequisitesFor
|
|
11
|
+
import { getPrerequisitesFor } from '../artifacts/artifact-prerequisites.js';
|
|
12
|
+
import { prerequisiteBodyViolations } from '../artifacts/prerequisite-checks.js';
|
|
12
13
|
import { showRequestArtifact } from '../artifacts/request-artifact-service.js';
|
|
13
14
|
import { readArtifactState } from '../artifacts/request-artifact-state-helpers.js';
|
|
14
15
|
export function extractState(markdown) {
|