@holmes-lab/holmes-kit 0.32.0 → 0.34.0
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/CHANGELOG.md +88 -0
- package/README.md +3 -1
- package/dist/.build-id +1 -1
- package/dist/holmes/cli/autonomy.js +15 -1
- package/dist/holmes/guardrail/impact-gate.js +50 -1
- package/dist/holmes/guardrail/risk-classifier.js +218 -6
- package/dist/holmes/hooks/pre-tool-use.d.ts +12 -0
- package/dist/holmes/hooks/pre-tool-use.js +55 -2
- package/dist/holmes/mcp/handlers/adoption.d.ts +17 -3
- package/dist/holmes/mcp/handlers/adoption.js +70 -2
- package/dist/holmes/mcp/handlers/graph-operations.js +6 -1
- package/dist/holmes/mcp/handlers/maintenance-analysis.js +9 -16
- package/dist/holmes/mcp/handlers/phase-queries.d.ts +30 -2
- package/dist/holmes/mcp/handlers/phase-queries.js +5 -1
- package/dist/holmes/mcp/handlers/review-evidence.d.ts +44 -1
- package/dist/holmes/mcp/handlers/review-evidence.js +48 -2
- package/dist/holmes/mcp/handlers/spec-approval.d.ts +10 -0
- package/dist/holmes/mcp/handlers/spec-approval.js +16 -1
- package/dist/holmes/mcp/handlers/spec-queries.d.ts +1 -9
- package/dist/holmes/mcp/handlers/spec-queries.js +40 -15
- package/dist/holmes/mcp/handlers.d.ts +43 -14
- package/dist/holmes/mcp/maintenance-analyze.js +64 -6
- package/dist/holmes/mcp/supervisor.d.ts +8 -0
- package/dist/holmes/mcp/supervisor.js +32 -2
- package/dist/holmes/mcp/tool-schemas.js +26 -5
- package/dist/holmes/reverse/scan.d.ts +6 -0
- package/dist/holmes/reverse/scan.js +4 -2
- package/dist/holmes/review/requirement-triage.d.ts +6 -0
- package/dist/holmes/review/requirement-triage.js +78 -9
- package/dist/holmes/review/test-outcomes.d.ts +53 -1
- package/dist/holmes/review/test-outcomes.js +156 -8
- package/dist/holmes/semantic/unreadable-paths.d.ts +30 -0
- package/dist/holmes/semantic/unreadable-paths.js +104 -0
- package/package.json +1 -1
- package/playbooks/author-slice/PLAYBOOK.md +1 -1
- package/playbooks/promote-slice/PLAYBOOK.md +1 -1
package/CHANGELOG.md
CHANGED
|
@@ -5,6 +5,94 @@ All notable changes to this project will be documented in this file.
|
|
|
5
5
|
The format is based on [Keep a Changelog](https://keepachangelog.com/en/1.1.0/),
|
|
6
6
|
and this project adheres to [Semantic Versioning](https://semver.org/spec/v2.0.0.html).
|
|
7
7
|
<!-- @implements A-SPEC-209 -->
|
|
8
|
+
## [0.34.0] - 2026-10-01
|
|
9
|
+
|
|
10
|
+
### Added
|
|
11
|
+
|
|
12
|
+
- **A docs-only commit inherits the release test-lane receipt** (A-SPEC-748). The publish gate binds its test
|
|
13
|
+
receipt to HEAD, so a one-line README fix after the release lane cost a second full serial suite (~35 min).
|
|
14
|
+
`node scripts/verify-release.js --inherit-release-test-lane` records a receipt for HEAD by running only the
|
|
15
|
+
required docs tests, when every change since the last full lane is `README.md` or an unshipped file under
|
|
16
|
+
`docs/`. It names the full receipt it stands on; the publish check re-reads that receipt (24 h limit) and
|
|
17
|
+
recomputes the diff with git — a path list written in the receipt is never trusted. `CHANGELOG.md`, shipped
|
|
18
|
+
docs, `package.json`, source, playbooks — any of them changed means the full lane, as before.
|
|
19
|
+
|
|
20
|
+
### Changed
|
|
21
|
+
|
|
22
|
+
- **Read-only shell commands over `.ax` are reads** (A-SPEC-747). 28 of 79 refused `.ax` commands in four sessions
|
|
23
|
+
only read, and each filed an approval request no one would decide. The gate now splits a command at operators
|
|
24
|
+
outside quotes and substitutions (`grep "a\|b" F` is one clause), judges every command substitution's body by the
|
|
25
|
+
same rule (so `echo "$(sh -c …)"` over `.ax` is newly refused), and knows `cd` (to a literal target), `pwd`,
|
|
26
|
+
`sleep`, `seq`, `pgrep`, clock-reading `date`, `git -C`/`--no-pager` and `while`/`until` loops of reads. Measured:
|
|
27
|
+
read over-blocks 18/29 → 1/29 (the remaining one is the remote-code rule), write probes still 32/32 refused.
|
|
28
|
+
- **`sed -i` is judged by the files it edits, not by its script** (A-SPEC-747). A `sed -i` over a file outside the
|
|
29
|
+
project was refused as a project code write because its script mentioned a `.ts` name.
|
|
30
|
+
- **`requirement_triage` judges a lineage approved by its documents, not their count** (A-SPEC-713.4). Only
|
|
31
|
+
lineages of exactly four documents counted as approved: 62 of 672 fully approved lineages here (8 of 671 in a
|
|
32
|
+
second corpus) have sub-slices or retired documents and could never be `fulfilled`, and four approved documents
|
|
33
|
+
without a T-SPEC counted as approved.
|
|
34
|
+
|
|
35
|
+
### Fixed
|
|
36
|
+
|
|
37
|
+
- **The autoreload MCP launcher exits when its client goes away** (A-SPEC-666.1). With `HOLMES_MCP_AUTORELOAD`,
|
|
38
|
+
the supervisor listened to stdin data only; when the client (a restarted Codex app-server daemon, observed) went
|
|
39
|
+
away, the launcher and its server child ran on with PPID 1 for hours. On stdin end or close it now closes the
|
|
40
|
+
child's input (a request forwarded just before is still read) and kills it after a 2 s grace, never restarting it.
|
|
41
|
+
- **A deep-link scan test no longer fails under a loaded parallel run** (A-SPEC-734.2, correcting A-SPEC-734.1, whose
|
|
42
|
+
counted call — `readdirSync` — stayed at 313 with the memo removed and so could not catch it). The 5 s wall-clock bound
|
|
43
|
+
(3.3 s alone, 13.8 s under load) is replaced by the property it guarded — the per-ancestor `.git` probe runs once
|
|
44
|
+
per directory (608–909 calls; 602,608 with the memo removed).
|
|
45
|
+
|
|
46
|
+
## [0.33.0] - 2026-10-01
|
|
47
|
+
|
|
48
|
+
### Changed
|
|
49
|
+
|
|
50
|
+
- **`spec_list`, `review_status` and `reverse_scan` answer with compressed defaults** (A-SPEC-746). On this
|
|
51
|
+
repository their default responses were 202,608, 96,407 and 123,552 characters — past the client's
|
|
52
|
+
tool-result limit. They now compress rather than cut: `review_status` merges review-needed signals per spec
|
|
53
|
+
and drops the from/to digests (every spec still listed, 11,043 characters); `reverse_scan` counts the test
|
|
54
|
+
matches the clusters already carry, writes paths relative to their cluster, groups unmatched tests by
|
|
55
|
+
directory and folds clusters that are already fully anchored (19,846); `spec_list` answers counts, the specs
|
|
56
|
+
that are not approved, and a cursor page (15,864), and `spec_list({ ids })` answers one row (224). Anything
|
|
57
|
+
still left out is counted with a note; `detail: "full"` (or paging) returns the previous answer. Playbooks
|
|
58
|
+
check a spec's existence with `spec_list({ ids })`.
|
|
59
|
+
- **`requirement_triage` confirms a lineage only when it mentions every code identifier the request names**
|
|
60
|
+
(A-SPEC-713.2). A request about `spec_list`/`review_status` was answered `fulfilled` by the `phase_status`
|
|
61
|
+
lineage, whose REQ puts other tools out of scope, and intake then refused the new requirement. Where the top
|
|
62
|
+
lineage never mentions (outside its Out of Scope text) a snake_case, camelCase, path or file name the request
|
|
63
|
+
names, the verdict is `ambiguous` with `identifiers-outside-lineage:<ids>`.
|
|
64
|
+
- **`requirement_triage` never confirms a lineage on a single channel** (A-SPEC-713.3). With no vector on any
|
|
65
|
+
candidate (no semantic layer, or a cold one), the lexical top alone answered `existing-change` for 47 of 60
|
|
66
|
+
requirements that were new at the time — and intake refuses a new REQ after `existing-change`. Such a run is
|
|
67
|
+
now `ambiguous` (`single-channel`); the lexical order stays visible. Two agreeing channels decide as before.
|
|
68
|
+
- **`spec_approve` answers a blocked spec with its blockers before choosing an approval channel**
|
|
69
|
+
(A-SPEC-551.2). An invalid `breaking_change` grade graded `hitl`, went to the owner's approval queue, and the
|
|
70
|
+
refusal named the approval channel instead of the blocker. When no channel already covers the act, the
|
|
71
|
+
`approval_status` blockers come back first and nothing is elicited or queued.
|
|
72
|
+
|
|
73
|
+
### Fixed
|
|
74
|
+
|
|
75
|
+
- **`holmes-kit autonomy off` no longer says OFF while autonomous approval is still on** (A-SPEC-553.2). With
|
|
76
|
+
`HOLMES_AUTONOMOUS_APPROVAL` in `.mcp.json` (the project default), `autonomy status` answered OFF while the
|
|
77
|
+
server sealed specs autonomously, and `autonomy off` removed only the session marker yet answered "OFF — every
|
|
78
|
+
spec approval is human again". Both now read the same project default as the server and the session banner:
|
|
79
|
+
`status` reports it and how to turn it off, and `off` exits 1 and says the project default keeps autonomy on.
|
|
80
|
+
- **The pre-edit evidence gate finds the analysis the session persisted** (A-SPEC-278.1). `HOLMES_EVIDENCE` is
|
|
81
|
+
an environment variable a session cannot set, so every edit right after `maintenance_analyze({ persist: true })`
|
|
82
|
+
warned `no-analysis`. Without a declared digest the gate reads the newest of the 64 most recent persisted
|
|
83
|
+
analyses taken at the current HEAD whose prediction names the target (regular files only, 2 MiB bound).
|
|
84
|
+
- **`maintenance_analyze` no longer treats every Korean or Japanese request as about every unreadable file**
|
|
85
|
+
(A-SPEC-741.1). A request with a non-ASCII letter made each unreadable language (`.sh`, …) a classification
|
|
86
|
+
gap, so a Korean corpus was `ambiguous` 60/60. The request's ASCII words are now compared with the paths (a
|
|
87
|
+
leading commit type word such as `feat:` is not; its scope is), Korean/Japanese language names count, and on
|
|
88
|
+
the cloud tier the rest is compared by meaning with unreadable path vectors the reindex / Stop-hook warm
|
|
89
|
+
prepares (below `gemini-embedding-001`'s measured 0.65 → outside the change). No vector, no tier, a model
|
|
90
|
+
without a threshold (local bge-m3), or no ASCII word keeps the language relevant. Replay: 60/60 → 14/60 on
|
|
91
|
+
the Korean corpus with the top candidate unchanged; the test scope is unchanged.
|
|
92
|
+
- **The field report's deny-reason cardinality guard allows 96 keys** (A-SPEC-578.8). New gate wording took this
|
|
93
|
+
repository's ledger to 65 distinct keys against a cap of 64; every key was read and none carried a command,
|
|
94
|
+
path or value. A leak is still thousands of keys.
|
|
95
|
+
|
|
8
96
|
## [0.32.0] - 2026-09-30
|
|
9
97
|
|
|
10
98
|
### Changed
|
package/README.md
CHANGED
|
@@ -23,6 +23,8 @@ Measured at `173b99650442` (specs `sha256:215f84d4e9f4`) — reproduce with `hol
|
|
|
23
23
|
|
|
24
24
|
### 🛡️ Currently Supported Features (Production Features)
|
|
25
25
|
|
|
26
|
+
- 📖 **Reading `.ax` from the shell is a read, and a docs fix does not re-run the whole release suite** *(new in 0.34.0)*: the gate splits shell commands at operators outside quotes and substitutions, judges every command substitution it would run, and knows literal `cd`, `pwd`, `sleep`, `seq`, `pgrep`, clock-reading `date`, `git -C` and `while`/`until` loops — so `grep "a\|b" .ax/…`, `f=$(find .ax/specs …)` or `until grep -q … .ax/…; do sleep 20; done` no longer file an approval request, while every write form is still refused (and `echo "$(sh -c …)"` now is). `sed -i` is judged by the files it edits, not by the words in its script. After a full release lane, `node scripts/verify-release.js --inherit-release-test-lane` lets a commit that changes only `README.md` or unshipped `docs/` files publish on the full lane's receipt by running just the docs tests; the publish check recomputes that diff with git. `requirement_triage` counts a lineage with sub-slices as approved, and an autoreload MCP launcher exits when its client goes away.
|
|
27
|
+
- 🗜️ **Large answers are compressed, not cut, and new requirements are not blocked by a guess** *(new in 0.33.0)*: `spec_list`, `review_status` and `reverse_scan` answer by default with a compressed view — duplicates removed, digests dropped, what needs action first, anything left out counted with a note — and `detail: "full"` (or paging, or `spec_list({ ids })` for one spec) gives the complete answer. `requirement_triage` confirms a lineage only when both of its channels agree and the lineage mentions every code identifier the request names, so a requirement next to a finished one, or on an install without a semantic layer, can still be admitted. `maintenance_analyze` judges a Korean or Japanese request against unreadable files by its words and, on the cloud tier, by meaning; the pre-edit gate finds the analysis the session persisted; `spec_approve` names a spec's blockers instead of queueing an approval nobody could use; and `holmes-kit autonomy status`/`off` read the project default in `.mcp.json`, so `off` never claims OFF while autonomous approval is still on.
|
|
26
28
|
- 🔎 **The analysis tools decide on evidence about the request, and say what they could not decide** *(new in 0.32.0)*: measured on two repositories by point-in-time replay, `maintenance_analyze` had answered `ambiguous` for every request because a shell script anywhere in the tree counted against it — the classification now counts an unreadable language only when the change touches it, while the test scope stays as conservative as before (relaxing it too let narrowed scopes miss the commit's own tests). `confidence` carries `confidenceCalibrated: false`; persisted evidence records why a scope was `full` and `maintenance_calibration` reports how often each cause occurred; candidate specs come in relevance order. `requirement_triage` answers in summaries by default (`detail: "full"` for document text), counts semantic coverage over documents that can have a vector, and gives `existing-change`/`fulfilled` only when its lexical and semantic channels agree on the first-ranked lineage — a lineage the request cites is listed first but a citation is not evidence — otherwise `ambiguous`, which leaves a new requirement possible.
|
|
27
29
|
- 🚦 **The gate only ever denies** *(changed in 0.31.0)*: an action Holmes does not deny is left to your harness's own permission flow — Claude Code and Codex get no permission decision, Antigravity gets `ask` (or `allow` for a read inside the workspace that git does not ignore). Earlier versions answered `allow`, which Claude Code treats as "bypassing permission prompt", so anything the shell model missed ran unconfirmed. In Claude Code's default mode you now see its confirmations again, as without Holmes.
|
|
28
30
|
- 🪝 **The Codex gate loads again on codex-cli 0.155** *(new in 0.31.0)*: plugin hooks were removed upstream, so `init --agent codex` wires the Holmes PreToolUse and Stop kernels into the user-level `$CODEX_HOME/hooks.json`, keeps every hook it does not own, and `--remove` takes away only its own groups. Codex runs a user hook only after you trust it once with `/hooks`; Holmes never forges that trust, and `doctor` says so instead of claiming enforcement.
|
|
@@ -287,7 +289,7 @@ flowchart LR
|
|
|
287
289
|
| `holmes-kit init --dry-run` | Preview files and configuration changes without writing |
|
|
288
290
|
| `holmes-kit autonomy status` | Show the current autonomous-approval posture (project default + session envelope) |
|
|
289
291
|
| `holmes-kit autonomy on --for 2h` | Self-drive low-risk specs for this session only (expiring; needs a TTY or `HOLMES_APPROVAL`) |
|
|
290
|
-
| `holmes-kit autonomy off` | End session autonomy immediately |
|
|
292
|
+
| `holmes-kit autonomy off` | End session autonomy immediately; if the project default in `.mcp.json` still keeps autonomy on, it says so and exits 1 instead of claiming OFF |
|
|
291
293
|
| `holmes-kit semantic-setup` | Download and verify the local `bge-m3` model (retry/recovery; shared across projects) |
|
|
292
294
|
| `holmes-kit semantic-check` | Verify local inference **offline**, without downloading anything |
|
|
293
295
|
| `holmes-kit semantic-key set` | Store the cloud-tier key outside the tree (stdin only, never argv) |
|
package/dist/.build-id
CHANGED
|
@@ -1 +1 @@
|
|
|
1
|
-
|
|
1
|
+
d1018322-muosc0k6
|
|
@@ -35,11 +35,13 @@ var __importStar = (this && this.__importStar) || (function () {
|
|
|
35
35
|
Object.defineProperty(exports, "__esModule", { value: true });
|
|
36
36
|
exports.parseForMinutes = parseForMinutes;
|
|
37
37
|
exports.runAutonomy = runAutonomy;
|
|
38
|
-
// @implements A-SPEC-553.1
|
|
38
|
+
// @implements A-SPEC-553.1, A-SPEC-553.2
|
|
39
39
|
const fs = __importStar(require("node:fs"));
|
|
40
40
|
const path = __importStar(require("node:path"));
|
|
41
41
|
const risk_gate_1 = require("../guardrail/risk-gate");
|
|
42
42
|
const autonomy_1 = require("../governance/autonomy");
|
|
43
|
+
const PROJECT_DEFAULT_ON = 'autonomous spec approval: ON (project default, .mcp.json) — governance-critical still ask you. '
|
|
44
|
+
+ 'Turn it off by removing HOLMES_AUTONOMOUS_APPROVAL from .mcp.json (or holmes-kit init --no-autonomy).';
|
|
43
45
|
const ledger_store_1 = require("../governance/ledger-store");
|
|
44
46
|
const provenance_chain_1 = require("../governance/provenance-chain");
|
|
45
47
|
/** `--for` accepts `2h` / `90m` / a bare number of hours. Minutes, capped at 7 days (like grants);
|
|
@@ -69,6 +71,11 @@ function runAutonomy(root, sub, forStr, io) {
|
|
|
69
71
|
const envOn = typeof env[autonomy_1.AUTONOMY_ENV] === 'string' && env[autonomy_1.AUTONOMY_ENV] !== '';
|
|
70
72
|
if (envOn)
|
|
71
73
|
return { ok: true, exitCode: 0, message: 'autonomous spec approval: ON (project default, .mcp.json) — governance-critical still ask you' };
|
|
74
|
+
// @implements A-SPEC-553.2 — the same project default the server and the session banner read
|
|
75
|
+
// (A-SPEC-560.2). The CLI read only the shell environment, which never carries .mcp.json's env, and
|
|
76
|
+
// answered OFF while the server sealed specs autonomously.
|
|
77
|
+
if ((0, autonomy_1.projectDefaultAutonomy)(root))
|
|
78
|
+
return { ok: true, exitCode: 0, message: PROJECT_DEFAULT_ON };
|
|
72
79
|
if ((0, autonomy_1.sessionAutonomyActive)(root, io.now)) {
|
|
73
80
|
let expires = '';
|
|
74
81
|
try {
|
|
@@ -112,6 +119,13 @@ function runAutonomy(root, sub, forStr, io) {
|
|
|
112
119
|
}
|
|
113
120
|
catch { /* audit is best-effort; the marker is gone either way */ }
|
|
114
121
|
}
|
|
122
|
+
// @implements A-SPEC-553.2 — the emergency control never reports a de-escalation that did not happen
|
|
123
|
+
// (A-SPEC-558.1): with the project default (or the environment switch) still on, autonomy is still ON.
|
|
124
|
+
const envStillOn = typeof env[autonomy_1.AUTONOMY_ENV] === 'string' && env[autonomy_1.AUTONOMY_ENV] !== '';
|
|
125
|
+
if (envStillOn || (0, autonomy_1.projectDefaultAutonomy)(root)) {
|
|
126
|
+
return { ok: false, exitCode: 1, message: 'session autonomy ended, but autonomous spec approval is still ON: the project default in .mcp.json '
|
|
127
|
+
+ '(HOLMES_AUTONOMOUS_APPROVAL) keeps it on — remove it from .mcp.json (or holmes-kit init --no-autonomy) to turn it off.' };
|
|
128
|
+
}
|
|
115
129
|
return { ok: true, exitCode: 0, message: 'autonomous spec approval: OFF — every spec approval is human again' };
|
|
116
130
|
}
|
|
117
131
|
if (sub === 'on') {
|
|
@@ -37,7 +37,7 @@ exports.isLowRiskTarget = isLowRiskTarget;
|
|
|
37
37
|
exports.evaluateEditEvidence = evaluateEditEvidence;
|
|
38
38
|
exports.preEditEvidenceDecision = preEditEvidenceDecision;
|
|
39
39
|
exports.loadEditEvidence = loadEditEvidence;
|
|
40
|
-
// @implements A-SPEC-279
|
|
40
|
+
// @implements A-SPEC-279, A-SPEC-278.1
|
|
41
41
|
// @implements A-SPEC-278
|
|
42
42
|
// @implements A-SPEC-277
|
|
43
43
|
// @implements A-SPEC-276
|
|
@@ -244,6 +244,52 @@ function preEditEvidenceDecision(verdict, mode) {
|
|
|
244
244
|
? { permissionDecision: 'deny', permissionDecisionReason: reason }
|
|
245
245
|
: { permissionDecision: 'allow', permissionDecisionReason: reason };
|
|
246
246
|
}
|
|
247
|
+
const PERSISTED_SCAN_LIMIT = 64;
|
|
248
|
+
const PERSISTED_MAX_BYTES = 2 * 1024 * 1024;
|
|
249
|
+
/**
|
|
250
|
+
* @implements A-SPEC-278.1 — with no declared digest (HOLMES_EVIDENCE is an environment variable a session
|
|
251
|
+
* cannot set), the analysis `maintenance_analyze({ persist: true })` wrote is found here: the newest of the
|
|
252
|
+
* 64 most recently written artifacts that was taken at the current HEAD and names the target in its
|
|
253
|
+
* prediction. The directory is a protected governance path a session cannot write, so this admits only
|
|
254
|
+
* what the tool persisted. Links and non-regular files are skipped (`lstat`), and so is anything over
|
|
255
|
+
* 2 MiB — bounded reads, the same discipline as every other state file the gate reads.
|
|
256
|
+
*/
|
|
257
|
+
function newestPersistedAnalysis(projectRoot, target, currentHead) {
|
|
258
|
+
const dir = path.join(projectRoot, '.ax', 'evidence', 'maintenance');
|
|
259
|
+
let entries = [];
|
|
260
|
+
try {
|
|
261
|
+
entries = fs.readdirSync(dir).filter((n) => n.endsWith('.json')).flatMap((n) => {
|
|
262
|
+
const file = path.join(dir, n);
|
|
263
|
+
try {
|
|
264
|
+
const st = fs.lstatSync(file);
|
|
265
|
+
return st.isFile() && st.size <= PERSISTED_MAX_BYTES ? [{ file, mtime: st.mtimeMs }] : [];
|
|
266
|
+
}
|
|
267
|
+
catch {
|
|
268
|
+
return [];
|
|
269
|
+
}
|
|
270
|
+
});
|
|
271
|
+
}
|
|
272
|
+
catch {
|
|
273
|
+
return null;
|
|
274
|
+
}
|
|
275
|
+
let best = null;
|
|
276
|
+
for (const { file } of entries.sort((a, b) => b.mtime - a.mtime).slice(0, PERSISTED_SCAN_LIMIT)) {
|
|
277
|
+
let candidate;
|
|
278
|
+
try {
|
|
279
|
+
candidate = JSON.parse(fs.readFileSync(file, 'utf8'));
|
|
280
|
+
}
|
|
281
|
+
catch {
|
|
282
|
+
continue;
|
|
283
|
+
}
|
|
284
|
+
if (candidate?.graphBasis?.head !== currentHead)
|
|
285
|
+
continue;
|
|
286
|
+
if (!Array.isArray(candidate?.predicted?.files) || !candidate.predicted.files.includes(target))
|
|
287
|
+
continue;
|
|
288
|
+
if (best === null || String(candidate.recordedAt ?? '') > String(best.recordedAt ?? ''))
|
|
289
|
+
best = candidate;
|
|
290
|
+
}
|
|
291
|
+
return best;
|
|
292
|
+
}
|
|
247
293
|
/**
|
|
248
294
|
* @implements A-SPEC-278
|
|
249
295
|
* The I/O adapter, kept apart from the pure core on purpose: everything above this line is decided
|
|
@@ -268,6 +314,9 @@ function loadEditEvidence(projectRoot, target, digest, currentHead) {
|
|
|
268
314
|
}
|
|
269
315
|
}
|
|
270
316
|
}
|
|
317
|
+
else {
|
|
318
|
+
artifact = newestPersistedAnalysis(projectRoot, rel, currentHead);
|
|
319
|
+
}
|
|
271
320
|
let currentTargetDigest = null;
|
|
272
321
|
try {
|
|
273
322
|
const resolved = path.resolve(projectRoot, rel);
|
|
@@ -42,7 +42,7 @@ exports.classifyArchitectureReversal = classifyArchitectureReversal;
|
|
|
42
42
|
exports.classifySecret = classifySecret;
|
|
43
43
|
exports.classifyBlastRadius = classifyBlastRadius;
|
|
44
44
|
exports.assessRisk = assessRisk;
|
|
45
|
-
// @implements A-SPEC-125.1, A-SPEC-627, A-SPEC-728, A-SPEC-737
|
|
45
|
+
// @implements A-SPEC-125.1, A-SPEC-627, A-SPEC-728, A-SPEC-737, A-SPEC-747
|
|
46
46
|
const fs = __importStar(require("node:fs"));
|
|
47
47
|
const path = __importStar(require("node:path"));
|
|
48
48
|
const risk_types_1 = require("./risk-types");
|
|
@@ -651,6 +651,8 @@ const READ_ONLY_SHELL = new Set([
|
|
|
651
651
|
'cat', 'grep', 'rg', 'ls', 'find', 'head', 'tail', 'wc', 'diff', 'awk', 'sort', 'uniq',
|
|
652
652
|
'less', 'more', 'file', 'stat', 'du', 'cut', 'tr', 'column', 'jq', 'basename', 'dirname',
|
|
653
653
|
'realpath', 'echo', 'printf', 'true', 'test',
|
|
654
|
+
// @implements A-SPEC-747 — measured in the refused reads: none of these writes a file.
|
|
655
|
+
'cd', 'pwd', 'sleep', 'seq', 'pgrep',
|
|
654
656
|
]);
|
|
655
657
|
/** `git` subcommands that only read. `commit`/`checkout`/`add` are not among them. */
|
|
656
658
|
const READ_ONLY_GIT = new Set([
|
|
@@ -692,11 +694,175 @@ function sedInPlaceFlag(t) {
|
|
|
692
694
|
* hide behind a pipe (`cat SPEC | tee OTHER`).
|
|
693
695
|
*/
|
|
694
696
|
function splitShellClauses(cmd) {
|
|
695
|
-
|
|
696
|
-
|
|
697
|
+
// @implements A-SPEC-747 — operators inside quotes or a substitution are text, not separators: `grep "a\|b" F`
|
|
698
|
+
// was judged as the clause `b" F`, which is no known read (17 of 28 measured reads refused). An unclosed quote
|
|
699
|
+
// keeps the quote-blind split — when the reader is unsure it cuts more, never less.
|
|
700
|
+
const pieces = splitUnquoted(cmd) ?? cmd.split(/\|\||&&|;|\||\n/);
|
|
701
|
+
return pieces
|
|
697
702
|
.map((c) => c.replace(/^[\s(]+/, '').trim())
|
|
698
703
|
.filter((c) => c.length > 0);
|
|
699
704
|
}
|
|
705
|
+
/**
|
|
706
|
+
* @implements A-SPEC-747 — split at `||`, `&&`, `;`, `|` and newline outside single quotes, double quotes, a backslash
|
|
707
|
+
* escape, `$(…)`, `<(…)`, `>(…)` and backticks. `null` when a quote or substitution is left open.
|
|
708
|
+
*/
|
|
709
|
+
function splitUnquoted(cmd) {
|
|
710
|
+
const out = [];
|
|
711
|
+
let cur = '';
|
|
712
|
+
let quote = null;
|
|
713
|
+
let depth = 0;
|
|
714
|
+
let tick = false;
|
|
715
|
+
for (let i = 0; i < cmd.length; i++) {
|
|
716
|
+
const ch = cmd[i];
|
|
717
|
+
if (quote === "'") {
|
|
718
|
+
cur += ch;
|
|
719
|
+
if (ch === "'")
|
|
720
|
+
quote = null;
|
|
721
|
+
continue;
|
|
722
|
+
}
|
|
723
|
+
if (ch === '\\' && i + 1 < cmd.length) {
|
|
724
|
+
cur += ch + cmd[i + 1];
|
|
725
|
+
i++;
|
|
726
|
+
continue;
|
|
727
|
+
}
|
|
728
|
+
if (ch === '`') {
|
|
729
|
+
tick = !tick;
|
|
730
|
+
cur += ch;
|
|
731
|
+
continue;
|
|
732
|
+
}
|
|
733
|
+
if ((ch === '$' || ch === '<' || ch === '>') && cmd[i + 1] === '(') {
|
|
734
|
+
depth++;
|
|
735
|
+
cur += ch + '(';
|
|
736
|
+
i++;
|
|
737
|
+
continue;
|
|
738
|
+
}
|
|
739
|
+
if (depth > 0 && ch === ')') {
|
|
740
|
+
depth--;
|
|
741
|
+
cur += ch;
|
|
742
|
+
continue;
|
|
743
|
+
}
|
|
744
|
+
if (quote === '"') {
|
|
745
|
+
cur += ch;
|
|
746
|
+
if (ch === '"')
|
|
747
|
+
quote = null;
|
|
748
|
+
continue;
|
|
749
|
+
}
|
|
750
|
+
if (ch === '"' || ch === "'") {
|
|
751
|
+
quote = ch;
|
|
752
|
+
cur += ch;
|
|
753
|
+
continue;
|
|
754
|
+
}
|
|
755
|
+
if (depth === 0 && !tick) {
|
|
756
|
+
if (ch === '\n' || ch === ';') {
|
|
757
|
+
out.push(cur);
|
|
758
|
+
cur = '';
|
|
759
|
+
continue;
|
|
760
|
+
}
|
|
761
|
+
if (ch === '|') {
|
|
762
|
+
if (cmd[i + 1] === '|')
|
|
763
|
+
i++;
|
|
764
|
+
out.push(cur);
|
|
765
|
+
cur = '';
|
|
766
|
+
continue;
|
|
767
|
+
}
|
|
768
|
+
if (ch === '&' && cmd[i + 1] === '&') {
|
|
769
|
+
i++;
|
|
770
|
+
out.push(cur);
|
|
771
|
+
cur = '';
|
|
772
|
+
continue;
|
|
773
|
+
}
|
|
774
|
+
}
|
|
775
|
+
cur += ch;
|
|
776
|
+
}
|
|
777
|
+
if (quote !== null || depth !== 0 || tick)
|
|
778
|
+
return null;
|
|
779
|
+
out.push(cur);
|
|
780
|
+
return out;
|
|
781
|
+
}
|
|
782
|
+
/** @implements A-SPEC-747 — how deep command substitutions are followed before a clause stops counting as a read. */
|
|
783
|
+
const MAX_SUBSTITUTION_DEPTH = 4;
|
|
784
|
+
/**
|
|
785
|
+
* @implements A-SPEC-747 — the command substitutions a clause runs (`$(…)`, backticks, `<(…)`; also inside double
|
|
786
|
+
* quotes, where they still run) and the clause with each replaced by a placeholder word. `null` when one is left
|
|
787
|
+
* open, or for `>(…)` (a process the output is written into).
|
|
788
|
+
*/
|
|
789
|
+
function substitutionsOf(clause) {
|
|
790
|
+
const bodies = [];
|
|
791
|
+
let rest = '';
|
|
792
|
+
let single = false;
|
|
793
|
+
for (let i = 0; i < clause.length; i++) {
|
|
794
|
+
const ch = clause[i];
|
|
795
|
+
if (single) {
|
|
796
|
+
rest += ch;
|
|
797
|
+
if (ch === "'")
|
|
798
|
+
single = false;
|
|
799
|
+
continue;
|
|
800
|
+
}
|
|
801
|
+
if (ch === '\\' && i + 1 < clause.length) {
|
|
802
|
+
rest += ch + clause[i + 1];
|
|
803
|
+
i++;
|
|
804
|
+
continue;
|
|
805
|
+
}
|
|
806
|
+
if (ch === "'") {
|
|
807
|
+
single = true;
|
|
808
|
+
rest += ch;
|
|
809
|
+
continue;
|
|
810
|
+
}
|
|
811
|
+
if (ch === '>' && clause[i + 1] === '(')
|
|
812
|
+
return null;
|
|
813
|
+
if ((ch === '$' || ch === '<') && clause[i + 1] === '(') {
|
|
814
|
+
let depth = 1;
|
|
815
|
+
let j = i + 2;
|
|
816
|
+
for (; j < clause.length && depth > 0; j++) {
|
|
817
|
+
if (clause[j] === '(')
|
|
818
|
+
depth++;
|
|
819
|
+
else if (clause[j] === ')')
|
|
820
|
+
depth--;
|
|
821
|
+
}
|
|
822
|
+
if (depth !== 0)
|
|
823
|
+
return null;
|
|
824
|
+
bodies.push(clause.slice(i + 2, j - 1));
|
|
825
|
+
rest += 'x';
|
|
826
|
+
i = j - 1;
|
|
827
|
+
continue;
|
|
828
|
+
}
|
|
829
|
+
if (ch === '`') {
|
|
830
|
+
const end = clause.indexOf('`', i + 1);
|
|
831
|
+
if (end < 0)
|
|
832
|
+
return null;
|
|
833
|
+
bodies.push(clause.slice(i + 1, end));
|
|
834
|
+
rest += 'x';
|
|
835
|
+
i = end;
|
|
836
|
+
continue;
|
|
837
|
+
}
|
|
838
|
+
rest += ch;
|
|
839
|
+
}
|
|
840
|
+
return { bodies, rest };
|
|
841
|
+
}
|
|
842
|
+
/**
|
|
843
|
+
* @implements A-SPEC-747 — a clause is a read when every substitution it runs is all reads (judged by the same rule,
|
|
844
|
+
* at most MAX_SUBSTITUTION_DEPTH deep) and the clause itself, with each substitution a placeholder, is a read. Before
|
|
845
|
+
* this, `echo "$(sh -c …)"` over .ax read as `echo` — the substitution was never judged.
|
|
846
|
+
*/
|
|
847
|
+
function clauseIsRead(clause, isRead, depth = 0) {
|
|
848
|
+
// A `cd` whose target is computed (a substitution, variable or glob) is not a read: the rules after it cannot know
|
|
849
|
+
// where relative paths land, and treating it as a read let `cd "$(printf '.%s' ax)"; echo x >& ./ledger/…` through
|
|
850
|
+
// (A-SPEC-728 round 27 pin — measured while building this slice). Only a certain cd moves on as a read.
|
|
851
|
+
if (/^cd(?:\s|$)/.test(clause) && /[$`*?[{]/.test(clause))
|
|
852
|
+
return false;
|
|
853
|
+
const subs = substitutionsOf(clause);
|
|
854
|
+
if (subs === null)
|
|
855
|
+
return false;
|
|
856
|
+
if (subs.bodies.length > 0) {
|
|
857
|
+
if (depth >= MAX_SUBSTITUTION_DEPTH)
|
|
858
|
+
return false;
|
|
859
|
+
for (const body of subs.bodies) {
|
|
860
|
+
if (!clausesAreReads(splitShellClauses(body), (c) => clauseIsRead(c, isRead, depth + 1)))
|
|
861
|
+
return false;
|
|
862
|
+
}
|
|
863
|
+
}
|
|
864
|
+
return isRead(subs.rest.trim());
|
|
865
|
+
}
|
|
700
866
|
/**
|
|
701
867
|
* Is this single clause known to only read?
|
|
702
868
|
*
|
|
@@ -717,8 +883,10 @@ function isReadOnlyShellClause(clause) {
|
|
|
717
883
|
let assigned = 0;
|
|
718
884
|
while (assigned < tokens.length && /^[A-Za-z_][A-Za-z0-9_]*=/.test(tokens[assigned]))
|
|
719
885
|
assigned++;
|
|
886
|
+
// @implements A-SPEC-747 — an assignment-only clause runs nothing itself: `f=$(find …)` is a read when its
|
|
887
|
+
// substitution is (clauseIsRead judges the body and hands this rule the placeholder `f=x`).
|
|
720
888
|
if (assigned > 0)
|
|
721
|
-
return assigned
|
|
889
|
+
return assigned === tokens.length || isReadOnlyShellClause(tokens.slice(assigned).join(' '));
|
|
722
890
|
const name = tokens[0].replace(/^.*\//, ''); // /usr/bin/grep -> grep
|
|
723
891
|
// @implements A-SPEC-737 — each of these read commands has a form that writes a named file, and
|
|
724
892
|
// the gate allowed all of them onto .ax/specs (measured through the built hook).
|
|
@@ -750,8 +918,29 @@ function isReadOnlyShellClause(clause) {
|
|
|
750
918
|
return k < tokens.length && isReadOnlyShellClause(tokens.slice(k).join(' '));
|
|
751
919
|
}
|
|
752
920
|
if (name === 'git') {
|
|
753
|
-
|
|
921
|
+
// @implements A-SPEC-747 — `-C <dir>` (repeatable) and `--no-pager` come before the sub-command; any other global
|
|
922
|
+
// option is not a read (`-c core.fsmonitor=…` runs a program on `status`, `--git-dir`/`--work-tree` retarget it).
|
|
923
|
+
let k = 1;
|
|
924
|
+
while (k < tokens.length && tokens[k].startsWith('-')) {
|
|
925
|
+
if (tokens[k] === '-C') {
|
|
926
|
+
k += 2;
|
|
927
|
+
continue;
|
|
928
|
+
}
|
|
929
|
+
if (tokens[k] === '--no-pager') {
|
|
930
|
+
k++;
|
|
931
|
+
continue;
|
|
932
|
+
}
|
|
933
|
+
return false;
|
|
934
|
+
}
|
|
935
|
+
// The sub-command is read by its last path part: the per-segment flattening prefixes every word after a moved
|
|
936
|
+
// base (`git status` → `git <dir>/status`), which read as no known sub-command (measured on a census read). A real
|
|
937
|
+
// git given a path-shaped sub-command only fails, and a write sub-command is not a read under any prefix.
|
|
938
|
+
const sub = k < tokens.length ? tokens[k].replace(/^.*\//, '') : '';
|
|
939
|
+
return sub !== '' && READ_ONLY_GIT.has(sub) && !rest.some((t) => t.startsWith('--output'));
|
|
754
940
|
}
|
|
941
|
+
// @implements A-SPEC-747 — `date` reads unless it sets the clock (`-s`, `--set`, or an operand that is not a `+FORMAT`).
|
|
942
|
+
if (name === 'date')
|
|
943
|
+
return !rest.some((t) => t === '-s' || longOption(t, 'set', 2) || !(t.startsWith('-') || t.startsWith('+')));
|
|
755
944
|
// @implements A-SPEC-737 (round 2) — sed `w`/`s///w`, awk `> FILENAME`/`-i inplace`, perl open(),
|
|
756
945
|
// rg --pre and `sort -o<path>` all wrote into .ax/specs while allowed as reads. A programmable
|
|
757
946
|
// reader is a read only in a recognisable read form, judged on quote-aware words.
|
|
@@ -1227,6 +1416,16 @@ function clausesAreReads(clauses, isRead) {
|
|
|
1227
1416
|
inLoop = true;
|
|
1228
1417
|
continue;
|
|
1229
1418
|
}
|
|
1419
|
+
// @implements A-SPEC-747 — `while COND` / `until COND` open a loop like `for`; the condition must itself be a read
|
|
1420
|
+
// (no substitution, no output redirect) and the body keeps the `for` rules.
|
|
1421
|
+
const loopHead = /^(?:while|until)\s+(.*)$/s.exec(c);
|
|
1422
|
+
if (loopHead) {
|
|
1423
|
+
const cond = loopHead[1].trim();
|
|
1424
|
+
if (inLoop || SUBSTITUTION_RE.test(cond) || OUTPUT_REDIRECT_RE.test(cond) || !isRead(cond))
|
|
1425
|
+
return false;
|
|
1426
|
+
inLoop = true;
|
|
1427
|
+
continue;
|
|
1428
|
+
}
|
|
1230
1429
|
if (inLoop && /^done$/.test(c)) {
|
|
1231
1430
|
inLoop = false;
|
|
1232
1431
|
continue;
|
|
@@ -1288,7 +1487,20 @@ function shellWritesProtectedAx(ncmd) {
|
|
|
1288
1487
|
// @implements A-SPEC-227 — the ledger exemption is cancelled here, not inside the restore check,
|
|
1289
1488
|
// because it is a property of the TARGET rather than of the command shape.
|
|
1290
1489
|
const restoreAllowed = !LEDGER_PATH_RE.test(ncmd);
|
|
1291
|
-
|
|
1490
|
+
// @implements A-SPEC-747 — each clause's substitutions are judged first (clauseIsRead).
|
|
1491
|
+
const isRead = (c) => isReadOnlyShellClause(c) || (restoreAllowed && isIndexRestoreClause(c));
|
|
1492
|
+
// After a `cd`, an output redirect into a file is not a read: the redirect rule reads a target token that starts right
|
|
1493
|
+
// after `>`, so `>& path` and `>| path` (a `&` or `|` first) are never seen, and `cd .ax; echo x >& ledger/…` passed once
|
|
1494
|
+
// `cd` became a read (measured while building this slice). Before A-SPEC-747 every command with a `cd` was refused, so
|
|
1495
|
+
// this keeps that shape exactly as refused as it was.
|
|
1496
|
+
let sawCd = false;
|
|
1497
|
+
return !clausesAreReads(splitShellClauses(ncmd), (c) => {
|
|
1498
|
+
if (/^cd(?:\s|$)/.test(c))
|
|
1499
|
+
sawCd = true;
|
|
1500
|
+
else if (sawCd && OUTPUT_REDIRECT_RE.test(c))
|
|
1501
|
+
return false;
|
|
1502
|
+
return clauseIsRead(c, isRead);
|
|
1503
|
+
});
|
|
1292
1504
|
}
|
|
1293
1505
|
/**
|
|
1294
1506
|
* @implements A-SPEC-125.1
|
|
@@ -11,6 +11,18 @@ export declare function resolveRmSignals(command: string, cwd: string, projectRo
|
|
|
11
11
|
* malformed input as absent) is testable at the layer that owns it.
|
|
12
12
|
*/
|
|
13
13
|
export declare function readApprovalFromEnv(): Approval | undefined;
|
|
14
|
+
/**
|
|
15
|
+
* @implements A-SPEC-732 (round 5) — the command as a shell would resolve its words: quotes and
|
|
16
|
+
* backslash escapes removed, `.`/`..` path segments resolved, case folded (macOS paths are
|
|
17
|
+
* case-insensitive). Measured allowed before: `dist/holmes/mcp/./server.js`, `dist/holmes/../holmes/
|
|
18
|
+
* mcp/server.js`, `DIST/…`, a quoted command word, `holmes\-mcp`. Linear: one pass per word.
|
|
19
|
+
*/
|
|
20
|
+
/**
|
|
21
|
+
* @implements A-SPEC-747 — the files a `sed` with an in-place flag writes: its non-option operands, minus the script.
|
|
22
|
+
* The script is the first non-option operand unless `-e`/`--expression`/`-f`/`--file` supplied it; BSD's `-i ''` takes
|
|
23
|
+
* the empty word as its suffix. Words are read quote-aware; an operand that is only a glob or a variable still counts.
|
|
24
|
+
*/
|
|
25
|
+
export declare function sedInPlaceFiles(text: string): string[];
|
|
14
26
|
/**
|
|
15
27
|
* @implements A-SPEC-732 (round 2) — the PreToolUse output. For `approval_commit` an unobjected call
|
|
16
28
|
* carries no decision: an `allow` would pre-empt the harness's own sensitive-tool confirmation, the
|
|
@@ -36,6 +36,7 @@ Object.defineProperty(exports, "__esModule", { value: true });
|
|
|
36
36
|
exports.DEFAULT_SPECS_DIR = void 0;
|
|
37
37
|
exports.resolveRmSignals = resolveRmSignals;
|
|
38
38
|
exports.readApprovalFromEnv = readApprovalFromEnv;
|
|
39
|
+
exports.sedInPlaceFiles = sedInPlaceFiles;
|
|
39
40
|
exports.hookOutputFor = hookOutputFor;
|
|
40
41
|
exports.dumpsEnvInCommandPosition = dumpsEnvInCommandPosition;
|
|
41
42
|
exports.normalizeHookInput = normalizeHookInput;
|
|
@@ -46,7 +47,7 @@ exports.gateErrorDecision = gateErrorDecision;
|
|
|
46
47
|
exports.wiredSpecsDir = wiredSpecsDir;
|
|
47
48
|
exports.evaluateHook = evaluateHook;
|
|
48
49
|
exports.readSpecsSync = readSpecsSync;
|
|
49
|
-
// @implements A-SPEC-278, A-SPEC-733, A-SPEC-734
|
|
50
|
+
// @implements A-SPEC-278, A-SPEC-733, A-SPEC-734, A-SPEC-747
|
|
50
51
|
// @implements A-SPEC-549.3 — the hook's deny reasons are English here; hooks-english.test.ts drives
|
|
51
52
|
// evaluateHook in this file to prove it.
|
|
52
53
|
// @implements A-SPEC-643
|
|
@@ -386,6 +387,52 @@ const LOCAL_SERVER_RUN = /(?:^|[\s;&|(])(?:exec\s+)?(?:node|nodejs|bun|deno|tsx|
|
|
|
386
387
|
* case-insensitive). Measured allowed before: `dist/holmes/mcp/./server.js`, `dist/holmes/../holmes/
|
|
387
388
|
* mcp/server.js`, `DIST/…`, a quoted command word, `holmes\-mcp`. Linear: one pass per word.
|
|
388
389
|
*/
|
|
390
|
+
/**
|
|
391
|
+
* @implements A-SPEC-747 — the files a `sed` with an in-place flag writes: its non-option operands, minus the script.
|
|
392
|
+
* The script is the first non-option operand unless `-e`/`--expression`/`-f`/`--file` supplied it; BSD's `-i ''` takes
|
|
393
|
+
* the empty word as its suffix. Words are read quote-aware; an operand that is only a glob or a variable still counts.
|
|
394
|
+
*/
|
|
395
|
+
function sedInPlaceFiles(text) {
|
|
396
|
+
const toks = text.match(/"[^"]*"|'[^']*'|\S+/g) ?? [];
|
|
397
|
+
const unq = (t) => t.replace(/^(['"])(.*)\1$/s, '$2');
|
|
398
|
+
const files = [];
|
|
399
|
+
for (let i = 0; i < toks.length; i++) {
|
|
400
|
+
if (!/(^|\/)g?sed$/.test(unq(toks[i])))
|
|
401
|
+
continue;
|
|
402
|
+
const args = [];
|
|
403
|
+
let j = i + 1;
|
|
404
|
+
for (; j < toks.length && !/^(?:\|\|?|&&?|;)$/.test(toks[j]) && !/^[0-9]*[<>]/.test(toks[j]); j++)
|
|
405
|
+
args.push(toks[j]);
|
|
406
|
+
i = j - 1;
|
|
407
|
+
const inPlace = args.some((a) => /^--in-place(=|$)/.test(unq(a)) || /^-[^-]*[iI]/.test(unq(a)));
|
|
408
|
+
if (!inPlace)
|
|
409
|
+
continue;
|
|
410
|
+
let scriptGiven = false;
|
|
411
|
+
const operands = [];
|
|
412
|
+
for (let k = 0; k < args.length; k++) {
|
|
413
|
+
const a = args[k];
|
|
414
|
+
const u = unq(a);
|
|
415
|
+
if (u === '-e' || u === '--expression' || u === '-f' || u === '--file') {
|
|
416
|
+
scriptGiven = true;
|
|
417
|
+
k++;
|
|
418
|
+
continue;
|
|
419
|
+
}
|
|
420
|
+
if (/^--(?:expression|file)=/.test(u)) {
|
|
421
|
+
scriptGiven = true;
|
|
422
|
+
continue;
|
|
423
|
+
}
|
|
424
|
+
if ((u === '-i' || u === '-I') && (args[k + 1] === "''" || args[k + 1] === '""')) {
|
|
425
|
+
k++;
|
|
426
|
+
continue;
|
|
427
|
+
}
|
|
428
|
+
if (u.startsWith('-') && u.length > 1)
|
|
429
|
+
continue;
|
|
430
|
+
operands.push(u);
|
|
431
|
+
}
|
|
432
|
+
files.push(...(scriptGiven ? operands : operands.slice(1)));
|
|
433
|
+
}
|
|
434
|
+
return files;
|
|
435
|
+
}
|
|
389
436
|
function normalizedCommand(command) {
|
|
390
437
|
return command.replace(/\\(.)/g, '$1').replace(/["']/g, '').toLowerCase().split(/(\s+)/).map((word) => {
|
|
391
438
|
if (!word.includes('/'))
|
|
@@ -1415,12 +1462,18 @@ function evaluateHook(input, specsDir, opts) {
|
|
|
1415
1462
|
// @implements A-SPEC-463 — same quoted-space fix as the config rule; `EXT_TAIL` is the
|
|
1416
1463
|
// extension part and `pathAlt` supplies the prefix and the quoting alternatives.
|
|
1417
1464
|
const EXT_TAIL = `\\.${CODE_EXT}`;
|
|
1465
|
+
const CODE_TAIL_RE_SED = new RegExp(`${EXT_TAIL}$`);
|
|
1418
1466
|
const candidates = [];
|
|
1419
1467
|
const CODE_REDIRECT = new RegExp(`(?:>{1,2}|\\btee\\b(?:\\s+-a)?\\s)\\s*${pathAlt(EXT_TAIL)}`, 'g');
|
|
1420
1468
|
for (const seg of segments) {
|
|
1421
1469
|
collectSeg(seg, CODE_REDIRECT, candidates);
|
|
1422
1470
|
collectPaths(seg, /\btouch\s+/, EXT_TAIL, candidates);
|
|
1423
|
-
|
|
1471
|
+
// @implements A-SPEC-747 — only sed's FILE operands are written; its script is not. Every code-named word of a
|
|
1472
|
+
// `sed -i` segment was a candidate, so `sed -i '' 's#a.test.ts#src/x.ts#' <outside>/notes.md` was denied as a
|
|
1473
|
+
// project code write (measured 2026-10-01).
|
|
1474
|
+
for (const raw of sedInPlaceFiles(seg.text))
|
|
1475
|
+
if (CODE_TAIL_RE_SED.test(raw))
|
|
1476
|
+
candidates.push({ raw, base: seg.base });
|
|
1424
1477
|
}
|
|
1425
1478
|
// @implements A-SPEC-449 — the copy/move family. The CONFIG rule has carried it since
|
|
1426
1479
|
// A-SPEC-191 §28 ("a gate that names one syntax for an act is a gate over that syntax, not
|