session-orchestrator 5.2.0 → 5.3.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/.agents/skills/architecture/SKILL.md +3 -1
- package/.agents/skills/autopilot/SKILL.md +5 -1
- package/.agents/skills/autopilot/agents/openai.yaml +5 -0
- package/.agents/skills/bootstrap/SKILL.md +5 -1
- package/.agents/skills/bootstrap/agents/openai.yaml +5 -0
- package/.agents/skills/brainstorm/SKILL.md +5 -1
- package/.agents/skills/brainstorm/agents/openai.yaml +5 -0
- package/.agents/skills/claude-md-drift-check/SKILL.md +3 -1
- package/.agents/skills/close/SKILL.md +5 -1
- package/.agents/skills/close/agents/openai.yaml +5 -0
- package/.agents/skills/convergence-monitoring/SKILL.md +4 -2
- package/.agents/skills/debug/SKILL.md +5 -1
- package/.agents/skills/debug/agents/openai.yaml +5 -0
- package/.agents/skills/discovery/SKILL.md +5 -1
- package/.agents/skills/discovery/agents/openai.yaml +5 -0
- package/.agents/skills/dispatcher/SKILL.md +5 -1
- package/.agents/skills/dispatcher/agents/openai.yaml +5 -0
- package/.agents/skills/docs-orchestrator/SKILL.md +3 -1
- package/.agents/skills/ecosystem-health/SKILL.md +3 -1
- package/.agents/skills/eli5/SKILL.md +5 -1
- package/.agents/skills/eli5/agents/openai.yaml +5 -0
- package/.agents/skills/eval/SKILL.md +6 -2
- package/.agents/skills/eval/agents/openai.yaml +5 -0
- package/.agents/skills/evolve/SKILL.md +6 -2
- package/.agents/skills/evolve/agents/openai.yaml +5 -0
- package/.agents/skills/frontmatter-guard/SKILL.md +3 -1
- package/.agents/skills/gitlab-ops/SKILL.md +3 -1
- package/.agents/skills/gitlab-portfolio/SKILL.md +3 -1
- package/.agents/skills/go/SKILL.md +5 -1
- package/.agents/skills/go/agents/openai.yaml +5 -0
- package/.agents/skills/grill/SKILL.md +5 -1
- package/.agents/skills/grill/agents/openai.yaml +5 -0
- package/.agents/skills/harness-audit/SKILL.md +5 -1
- package/.agents/skills/harness-audit/agents/openai.yaml +5 -0
- package/.agents/skills/hook-development/SKILL.md +3 -1
- package/.agents/skills/mcp-builder/SKILL.md +3 -1
- package/.agents/skills/memory-cleanup/SKILL.md +5 -1
- package/.agents/skills/memory-cleanup/agents/openai.yaml +5 -0
- package/.agents/skills/mode-selector/SKILL.md +3 -1
- package/.agents/skills/npm-publish/SKILL.md +4 -2
- package/.agents/skills/peekaboo-driver/SKILL.md +3 -1
- package/.agents/skills/persona-panel/SKILL.md +5 -1
- package/.agents/skills/persona-panel/agents/openai.yaml +5 -0
- package/.agents/skills/plan/SKILL.md +5 -1
- package/.agents/skills/plan/agents/openai.yaml +5 -0
- package/.agents/skills/playwright-driver/SKILL.md +3 -1
- package/.agents/skills/portfolio/SKILL.md +5 -1
- package/.agents/skills/portfolio/agents/openai.yaml +5 -0
- package/.agents/skills/quality-gates/SKILL.md +3 -1
- package/.agents/skills/reconcile/SKILL.md +5 -1
- package/.agents/skills/reconcile/agents/openai.yaml +5 -0
- package/.agents/skills/release/SKILL.md +5 -1
- package/.agents/skills/release/agents/openai.yaml +5 -0
- package/.agents/skills/remote-offload/SKILL.md +3 -1
- package/.agents/skills/repo-audit/SKILL.md +5 -1
- package/.agents/skills/repo-audit/agents/openai.yaml +5 -0
- package/.agents/skills/session/SKILL.md +21 -0
- package/.agents/skills/session/agents/openai.yaml +5 -0
- package/.agents/skills/session-end/SKILL.md +3 -1
- package/.agents/skills/session-plan/SKILL.md +3 -1
- package/.agents/skills/session-start/SKILL.md +3 -1
- package/.agents/skills/spinout/SKILL.md +5 -1
- package/.agents/skills/spinout/agents/openai.yaml +5 -0
- package/.agents/skills/sunset-review/SKILL.md +5 -1
- package/.agents/skills/sunset-review/agents/openai.yaml +5 -0
- package/.agents/skills/templates-ack/SKILL.md +21 -0
- package/.agents/skills/templates-ack/agents/openai.yaml +5 -0
- package/.agents/skills/test/SKILL.md +5 -1
- package/.agents/skills/test/agents/openai.yaml +5 -0
- package/.agents/skills/test-runner/SKILL.md +3 -1
- package/.agents/skills/tmux-layout/SKILL.md +3 -1
- package/.agents/skills/using-orchestrator/SKILL.md +3 -1
- package/.agents/skills/ux-grill/SKILL.md +5 -1
- package/.agents/skills/ux-grill/agents/openai.yaml +5 -0
- package/.agents/skills/vault-mirror/SKILL.md +3 -1
- package/.agents/skills/vault-sync/SKILL.md +3 -1
- package/.agents/skills/wave-executor/SKILL.md +3 -1
- package/.agents/skills/write-executable-plan/SKILL.md +3 -1
- package/.claude-plugin/marketplace.json +1 -1
- package/.claude-plugin/plugin.json +1 -1
- package/.codex-plugin/plugin.json +4 -4
- package/.codex-plugin/skills/convergence-monitoring/SKILL.md +1 -3
- package/.codex-plugin/skills/eval/SKILL.md +1 -1
- package/.codex-plugin/skills/evolve/SKILL.md +1 -1
- package/.codex-plugin/skills/npm-publish/SKILL.md +1 -3
- package/.codex-plugin/skills/session/SKILL.md +1 -1
- package/.cursor/commands/eval.md +1 -1
- package/.cursor/commands/session.md +1 -1
- package/.cursor/rules/000-session-orchestrator.mdc +0 -2
- package/.cursor/rules/050-plan.mdc +1 -1
- package/.cursor/skills/convergence-monitoring/SKILL.md +1 -0
- package/.cursor/skills/eval/SKILL.md +1 -1
- package/.cursor/skills/npm-publish/SKILL.md +1 -0
- package/.cursor-plugin/plugin.json +1 -1
- package/.orchestrator/policy/blocked-commands.json +12 -3
- package/AGENTS.md +3 -2
- package/CHANGELOG.md +136 -0
- package/README.md +9 -9
- package/SECURITY.md +12 -0
- package/agents/dialectic-deriver.md +13 -10
- package/agents/eval-judge.md +67 -45
- package/agents/skill-applied-judge.md +34 -19
- package/commands/session.md +7 -3
- package/docs/baseline.md +12 -6
- package/docs/codex-setup.md +14 -2
- package/docs/components.md +7 -5
- package/docs/events-schema.md +56 -9
- package/docs/rule-authoring.md +58 -6
- package/docs/session-config-reference.md +100 -7
- package/docs/session-config-template.md +31 -2
- package/docs/telemetry.md +2 -0
- package/hooks/_lib/hook-import-set.json +85 -8
- package/hooks/_lib/subagent-transcript.mjs +582 -31
- package/hooks/config-protection.mjs +11 -3
- package/hooks/cwd-change-restore.mjs +11 -3
- package/hooks/enforce-commands.mjs +70 -23
- package/hooks/enforce-scope.mjs +143 -33
- package/hooks/hooks-codex.json +1 -1
- package/hooks/hooks.json +1 -1
- package/hooks/loop-guard.mjs +11 -3
- package/hooks/on-session-end.mjs +58 -23
- package/hooks/on-session-start.mjs +48 -11
- package/hooks/on-stop.mjs +168 -22
- package/hooks/operator-steer.mjs +11 -3
- package/hooks/post-bash-issue-budget-refund.mjs +18 -8
- package/hooks/post-bash-write-verify.mjs +3 -2
- package/hooks/post-edit-import-probe.mjs +17 -9
- package/hooks/post-edit-validate.mjs +13 -5
- package/hooks/post-subagent-discovery-validator.mjs +98 -13
- package/hooks/post-tool-batch-wave-signal.mjs +200 -38
- package/hooks/post-tool-failure-corrective-context.mjs +11 -5
- package/hooks/post-tooluse-frontend-slop.mjs +10 -4
- package/hooks/pre-auq-clarity.mjs +15 -2
- package/hooks/pre-bash-destructive-guard.mjs +80 -9
- package/hooks/pre-bash-issue-budget.mjs +16 -11
- package/hooks/pre-bash-memory-propose-audit.mjs +86 -54
- package/hooks/pre-bash-sessions-ledger-guard.mjs +391 -20
- package/hooks/pre-bash-staging-fence.mjs +335 -31
- package/hooks/pre-bash-templates-first.mjs +19 -14
- package/hooks/pre-task-scope-disjoint.mjs +233 -2
- package/hooks/subagent-telemetry.mjs +15 -19
- package/hooks/wave-scope-commit-guard.mjs +197 -100
- package/monitors/monitors.json +1 -1
- package/output-styles/wave-summary.md +1 -1
- package/package.json +1 -1
- package/pi/prompts/eval.md +1 -1
- package/pi/prompts/session.md +1 -1
- package/rules/README.md +1 -1
- package/rules/opt-in-domain/prompt-caching.md +1 -1
- package/rules/opt-in-stack/backend-data.md +1 -1
- package/rules/opt-in-stack/backend.md +3 -3
- package/rules/opt-in-stack/frontend.md +1 -1
- package/rules/opt-in-stack/security-web.md +3 -3
- package/rules/opt-in-stack/swift.md +1 -1
- package/scripts/autopilot.mjs +23 -2
- package/scripts/backfill-abandoned-sessions.mjs +117 -15
- package/scripts/check-sessions-integrity.mjs +300 -0
- package/scripts/dialectic-deriver.mjs +50 -13
- package/scripts/emit-session.mjs +75 -29
- package/scripts/eval-session.mjs +65 -3
- package/scripts/generate-agents-skills.mjs +102 -29
- package/scripts/generate-cursor-adapter.mjs +61 -16
- package/scripts/lib/agent-status.mjs +2 -31
- package/scripts/lib/auq/clarity.mjs +10 -2
- package/scripts/lib/auq/parse.mjs +12 -31
- package/scripts/lib/auq/schema.mjs +56 -41
- package/scripts/lib/auto-dialectic.mjs +304 -15
- package/scripts/lib/autopilot/flags.mjs +12 -1
- package/scripts/lib/autopilot/kill-switches.mjs +6 -3
- package/scripts/lib/autopilot/loop.mjs +14 -1
- package/scripts/lib/autopilot/stall-sampler.mjs +80 -23
- package/scripts/lib/ci-status-banner.mjs +376 -16
- package/scripts/lib/command-blocker.mjs +275 -28
- package/scripts/lib/config/dialectic.mjs +12 -3
- package/scripts/lib/config/gate.mjs +74 -0
- package/scripts/lib/config/reaper.mjs +162 -0
- package/scripts/lib/config.mjs +14 -0
- package/scripts/lib/convergence-monitor.mjs +74 -11
- package/scripts/lib/ecosystem-health.mjs +11 -0
- package/scripts/lib/eval/engine.mjs +421 -53
- package/scripts/lib/eval/judge.mjs +463 -40
- package/scripts/lib/eval/schema.mjs +10 -1
- package/scripts/lib/events-rotation.mjs +221 -25
- package/scripts/lib/events-schema.mjs +114 -0
- package/scripts/lib/events.mjs +524 -5
- package/scripts/lib/frontmatter-guard.mjs +21 -10
- package/scripts/lib/gates/gate-baseline.mjs +27 -2
- package/scripts/lib/gates/gate-full.mjs +28 -3
- package/scripts/lib/gates/gate-helpers.mjs +243 -21
- package/scripts/lib/gates/gate-incremental.mjs +28 -3
- package/scripts/lib/gates/gate-per-file.mjs +27 -2
- package/scripts/lib/gitlab-portfolio/markdown-writer.mjs +6 -1
- package/scripts/lib/instruction-budget-guard.mjs +146 -4
- package/scripts/lib/io.mjs +42 -8
- package/scripts/lib/issue-close-strip-labels.mjs +207 -49
- package/scripts/lib/js-mask.mjs +197 -0
- package/scripts/lib/learnings/evolve-telemetry.mjs +11 -7
- package/scripts/lib/maintenance-due-banner.mjs +53 -88
- package/scripts/lib/orphan-reaper.mjs +1588 -0
- package/scripts/lib/peer-cards/merger.mjs +48 -10
- package/scripts/lib/peer-cards/reader.mjs +78 -2
- package/scripts/lib/process-group.mjs +899 -0
- package/scripts/lib/quality-gate.mjs +107 -28
- package/scripts/lib/reconcile/backlog.mjs +368 -0
- package/scripts/lib/reconcile/engine.mjs +55 -188
- package/scripts/lib/reconcile/rule-expiry-sweep.mjs +302 -60
- package/scripts/lib/reconcile/sanitize.mjs +69 -3
- package/scripts/lib/reconcile-nudge-banner.mjs +138 -45
- package/scripts/lib/resource-probe/parsers.mjs +31 -0
- package/scripts/lib/rule-loader.mjs +41 -12
- package/scripts/lib/scope-echo.mjs +39 -2
- package/scripts/lib/scope-gate.mjs +605 -1
- package/scripts/lib/session-close-backfill.mjs +33 -6
- package/scripts/lib/session-id.mjs +9 -20
- package/scripts/lib/session-invocation.mjs +20 -0
- package/scripts/lib/session-schema/constants.mjs +30 -2
- package/scripts/lib/session-schema/normalizer.mjs +56 -4
- package/scripts/lib/session-schema.mjs +8 -3
- package/scripts/lib/session-start-probes.mjs +95 -10
- package/scripts/lib/sessions-canonical.mjs +23 -0
- package/scripts/lib/sessions-integrity-banner.mjs +7 -1
- package/scripts/lib/sessions-staleness-banner.mjs +193 -51
- package/scripts/lib/skill-evidence-window.mjs +891 -0
- package/scripts/lib/skill-evolution/candidate-intake.mjs +133 -12
- package/scripts/lib/skill-evolution/engine.mjs +18 -9
- package/scripts/lib/skill-judge.mjs +45 -3
- package/scripts/lib/tail-window.mjs +56 -0
- package/scripts/lib/telemetry/schema.mjs +30 -0
- package/scripts/lib/telemetry/sync.mjs +61 -6
- package/scripts/lib/telemetry-flush-health-banner.mjs +4 -22
- package/scripts/lib/test-runner/issue-reconcile.mjs +48 -16
- package/scripts/lib/tmux-layout/telemetry-stats.mjs +72 -13
- package/scripts/lib/user-invocable-skills.mjs +23 -3
- package/scripts/lib/ux-grill/reconcile.mjs +48 -22
- package/scripts/lib/validate/check-agents-skills.mjs +26 -15
- package/scripts/lib/validate/check-cursor-adapter.mjs +1 -0
- package/scripts/lib/validate/check-entry-guard.mjs +13 -50
- package/scripts/lib/validate/check-hook-entry-guards.mjs +636 -0
- package/scripts/lib/validate/check-pi-prompts.mjs +1 -0
- package/scripts/lib/validate/check-rules.mjs +7 -5
- package/scripts/lib/validate/check-skill-links.mjs +9 -1
- package/scripts/lib/validate/check-skill-script-paths.mjs +239 -27
- package/scripts/lib/validate/check-test-git-config-target.mjs +24 -34
- package/scripts/lib/validate/check-untracked-test-deps.mjs +7 -102
- package/scripts/lib/validate/check-unwired-features.mjs +130 -27
- package/scripts/lib/validate/check-validator-registration.mjs +34 -10
- package/scripts/lib/validate/confidential-names.mjs +10 -0
- package/scripts/lib/validate-vendored-rules.mjs +4 -3
- package/scripts/lib/vault-mirror/namespace.mjs +46 -8
- package/scripts/lib/vault-mirror/process.mjs +10 -3
- package/scripts/lib/vault-mirror/render-sessions.mjs +12 -2
- package/scripts/lib/vault-status/narrative-mirror.mjs +31 -7
- package/scripts/lib/vault-yaml.mjs +118 -0
- package/scripts/lib/worktree/lifecycle.mjs +153 -1
- package/scripts/release-session-lock.mjs +305 -0
- package/scripts/release.mjs +30 -5
- package/scripts/resolve-session-invocation.mjs +59 -0
- package/scripts/run-quality-gate.mjs +156 -17
- package/scripts/sweep-expired-rules.mjs +14 -3
- package/scripts/validate-plugin.mjs +12 -0
- package/scripts/validate-wave-scope.mjs +32 -105
- package/scripts/vault-mirror.mjs +9 -1
- package/skills/_shared/platform-tools.md +23 -11
- package/skills/autopilot/SKILL.md +22 -7
- package/skills/claude-md-drift-check/SKILL.md +1 -1
- package/skills/convergence-monitoring/README.md +8 -1
- package/skills/convergence-monitoring/SIGNALS.md +50 -6
- package/skills/convergence-monitoring/SKILL.md +15 -6
- package/skills/eval/SKILL.md +39 -24
- package/skills/eval/rubric-v1.md +1 -0
- package/skills/eval/rubric-v2.md +457 -0
- package/skills/evolve/SKILL.md +1 -1
- package/skills/evolve/references/evolve-dialectic-mode.md +42 -25
- package/skills/gitlab-ops/SKILL.md +3 -2
- package/skills/npm-publish/SKILL.md +1 -1
- package/skills/reconcile/SKILL.md +11 -0
- package/skills/session-end/SKILL.md +13 -16
- package/skills/session-end/discovery-scan.md +1 -1
- package/skills/session-end/phase-3-6-tail.md +55 -9
- package/skills/session-end/references/phase-5-issue-cleanup.md +9 -14
- package/skills/session-end/session-metrics-write.md +10 -0
- package/skills/session-plan/SKILL.md +17 -5
- package/skills/session-plan/references/session-plan-task-classification.md +2 -2
- package/skills/session-start/references/phase-4-ssot-environment-check.md +2 -1
- package/skills/ux-grill/SKILL.md +1 -1
- package/skills/wave-executor/SKILL.md +8 -4
- package/skills/wave-executor/circuit-breaker.md +2 -0
- package/skills/wave-executor/references/wave-executor-state-init.md +5 -3
- package/skills/wave-executor/references/wave-loop-dispatch.md +2 -1
- package/.codex-plugin/skills/convergence-monitoring/agents/openai.yaml +0 -5
- package/.codex-plugin/skills/npm-publish/agents/openai.yaml +0 -5
- package/.cursor/commands/convergence-monitoring.md +0 -13
- package/.cursor/commands/npm-publish.md +0 -13
- package/pi/prompts/convergence-monitoring.md +0 -11
- package/pi/prompts/npm-publish.md +0 -11
|
@@ -11,6 +11,16 @@
|
|
|
11
11
|
* #1241 adds blocking repo-rooted `.md` paths quoted as complete inline-code
|
|
12
12
|
* spans, with the same annotations and fence handling. Scan roots stay fixed.
|
|
13
13
|
*
|
|
14
|
+
* ## The runtime-artefact carve-out needs BOTH halves
|
|
15
|
+
*
|
|
16
|
+
* A missing citation is excused as a runtime artefact only when it sits under
|
|
17
|
+
* a harness STATE root ({@link RUNTIME_STATE_PREFIXES}) *and* git ignores it.
|
|
18
|
+
* The git half alone is not the claim it looks like: `.gitignore` also
|
|
19
|
+
* declines to track real local documents (`docs/specs/`, `docs/_private/`) and
|
|
20
|
+
* build output (`coverage/`, `node_modules/`), so "git ignores it" would have
|
|
21
|
+
* silenced a typo in a `docs/specs/…` citation forever — in the very check
|
|
22
|
+
* whose subject is "ships in the tarball, target missing".
|
|
23
|
+
*
|
|
14
24
|
* ## Why
|
|
15
25
|
*
|
|
16
26
|
* Prose is not executed. A skill body that tells the coordinator to run
|
|
@@ -98,14 +108,60 @@
|
|
|
98
108
|
* @module scripts/lib/validate/check-skill-script-paths
|
|
99
109
|
*/
|
|
100
110
|
|
|
111
|
+
import { execFileSync } from 'node:child_process';
|
|
101
112
|
import { existsSync, readFileSync } from 'node:fs';
|
|
102
113
|
import path from 'node:path';
|
|
103
114
|
import { enumerateRepoFiles } from './enumerate-repo-files.mjs';
|
|
104
115
|
import { forEachLine } from './markdown-fences.mjs';
|
|
105
116
|
import { isMainModule } from '../is-main-module.mjs';
|
|
106
117
|
|
|
107
|
-
/**
|
|
108
|
-
|
|
118
|
+
/**
|
|
119
|
+
* Documentation roots whose prose is treated as a claim about the repo.
|
|
120
|
+
*
|
|
121
|
+
* `.claude/rules` and `.cursor/rules` joined in #1384 P3. Both are instruction
|
|
122
|
+
* corpora loaded by every session, and both cite repo paths in backticks with
|
|
123
|
+
* exactly the grammar {@link MARKDOWN_CITATION_RE} already judges — but until
|
|
124
|
+
* this widening neither had a gate. The real incident:
|
|
125
|
+
* `.cursor/rules/010-session-workflow.mdc` kept citing `commands/go.md` and
|
|
126
|
+
* `commands/close.md` after `3ebf0e9d` folded those files into their skills,
|
|
127
|
+
* and that surface SHIPS (npm tarball, symlinked into consumer repos by
|
|
128
|
+
* `scripts/cursor-install.mjs`). Same widening, mirrored in
|
|
129
|
+
* `check-skill-links.mjs` § SCAN_DIRS.
|
|
130
|
+
*
|
|
131
|
+
* `rules` and `output-styles` joined in #1384 P3 for the same reason one step
|
|
132
|
+
* further out: both are in `package.json` `files[]`, so both SHIP to every
|
|
133
|
+
* consumer, and neither had a gate. The census that motivated it (whole-repo
|
|
134
|
+
* probe, 2026-09-18 @ 20a4cbff) found 6 dangling citations across them —
|
|
135
|
+
* `output-styles/wave-summary.md` cited `hooks/on-stop.sh` for a file that has
|
|
136
|
+
* been `.mjs` for two migrations, and `rules/opt-in-stack/*` cited
|
|
137
|
+
* consumer-side example paths with no marker.
|
|
138
|
+
*
|
|
139
|
+
* `CHANGELOG.md` stays OUT, and root files are not a scan root at all: a
|
|
140
|
+
* changelog cites the paths a release TOUCHED, so a path deleted afterwards is
|
|
141
|
+
* still a correct historical statement — 88 such hits, all correct by
|
|
142
|
+
* construction. Annotating them would be noise on every future entry.
|
|
143
|
+
*/
|
|
144
|
+
export const SCAN_DIRS = Object.freeze([
|
|
145
|
+
'skills',
|
|
146
|
+
'commands',
|
|
147
|
+
'agents',
|
|
148
|
+
'docs',
|
|
149
|
+
'rules',
|
|
150
|
+
'output-styles',
|
|
151
|
+
'.claude/rules',
|
|
152
|
+
'.cursor/rules',
|
|
153
|
+
]);
|
|
154
|
+
|
|
155
|
+
/**
|
|
156
|
+
* Extensions treated as instruction markdown.
|
|
157
|
+
*
|
|
158
|
+
* `.mdc` is Cursor's own rule extension and is the ONLY reason `.cursor/rules`
|
|
159
|
+
* is scannable at all: every file there is `<nnn>-<name>.mdc`, so a `.md`-only
|
|
160
|
+
* filter would have added the directory to {@link SCAN_DIRS} and enumerated
|
|
161
|
+
* zero files — a widening that looks live and checks nothing. Same constant,
|
|
162
|
+
* same reason, as `check-skill-links.mjs` § MD_EXTENSIONS.
|
|
163
|
+
*/
|
|
164
|
+
export const MD_EXTENSIONS = Object.freeze(['.md', '.mdc']);
|
|
109
165
|
|
|
110
166
|
/**
|
|
111
167
|
* A cited script path. One regex, one alternation, reused for every
|
|
@@ -114,8 +170,35 @@ export const SCAN_DIRS = Object.freeze(['skills', 'commands', 'agents', 'docs'])
|
|
|
114
170
|
* `hooks/**.sh`. `hooks/**.mjs` is deliberately NOT part of this grammar —
|
|
115
171
|
* the `.mjs` half of the citation surface stays exactly `scripts/`, matching
|
|
116
172
|
* every existing annotation and fence-skip test unchanged.
|
|
173
|
+
*
|
|
174
|
+
* Ceiling (BV-004, #1390 P2): the match is UNANCHORED on the left, so a path
|
|
175
|
+
* NESTED under another directory is read from its `scripts/` / `hooks/`
|
|
176
|
+
* segment onward. `templates/shared/hooks/check-csp-single-source.sh` is judged
|
|
177
|
+
* as `hooks/check-csp-single-source.sh` — a path nobody cited. That cuts both
|
|
178
|
+
* ways: a finding names the truncated tail (fail-closed noise), and a nested
|
|
179
|
+
* path whose tail HAPPENS to exist at the repo root passes although the cited
|
|
180
|
+
* file is missing (fail-open).
|
|
181
|
+
*
|
|
182
|
+
* A lookbehind cannot tell the two readings apart, because the character
|
|
183
|
+
* before the tail is `/` in both: `templates/shared/hooks/…` is a real
|
|
184
|
+
* subdirectory, while `$PLUGIN_ROOT/scripts/…`, `${CLAUDE_PLUGIN_ROOT}/…`,
|
|
185
|
+
* `../../scripts/…` and `…/blob/main/hooks/…` all resolve to the plugin root,
|
|
186
|
+
* so their tail IS the right repo-rooted path. Only the prefix token's meaning
|
|
187
|
+
* differs, and the regex cannot evaluate a variable. Measured 2026-09-19 @
|
|
188
|
+
* 8f6ac022 (prose lines of every SCAN_DIRS file, fences skipped — `forEachLine`
|
|
189
|
+
* + this regex, the character before each hit): 1505 hits in 351 files, 42
|
|
190
|
+
* preceded by `/` — 16 variable-rooted, 21 relative, 5 literal, and of those
|
|
191
|
+
* five exactly ONE is a genuine nested directory (the CSP hook above, in
|
|
192
|
+
* `rules/opt-in-stack/security-web.md`). A `(?<![\w./}-])` guard would drop 37
|
|
193
|
+
* correctly-judged citations to fix one.
|
|
194
|
+
*
|
|
195
|
+
* Escape hatch until then: the nested citation carries
|
|
196
|
+
* `<!-- path-check: example -->` (or `planned #<iid>`), which the one live
|
|
197
|
+
* occurrence already does. Revisit when a second real nested-path citation
|
|
198
|
+
* appears that the annotation cannot reasonably cover — then the grammar needs
|
|
199
|
+
* a list of known plugin-root prefixes, not a lookbehind.
|
|
117
200
|
*/
|
|
118
|
-
const CITATION_RE
|
|
201
|
+
const CITATION_RE =/scripts\/[a-zA-Z0-9_/-]*\.(?:mjs|sh)|hooks\/[a-zA-Z0-9_/-]*\.sh/g;
|
|
119
202
|
|
|
120
203
|
/**
|
|
121
204
|
* A complete inline-code span, including spans delimited by multiple backticks.
|
|
@@ -166,6 +249,107 @@ export function isPlaceholderCitation(citedPath) {
|
|
|
166
249
|
return PLACEHOLDER_FRAGMENTS.some((fragment) => lower.includes(fragment));
|
|
167
250
|
}
|
|
168
251
|
|
|
252
|
+
/**
|
|
253
|
+
* The per-harness STATE roots. A missing citation may be excused as a runtime
|
|
254
|
+
* artefact ONLY from inside one of these — and only when git also ignores it
|
|
255
|
+
* (see {@link isRuntimeArtifact}).
|
|
256
|
+
*
|
|
257
|
+
* Each is a harness's own session-state directory: `.orchestrator/` (this
|
|
258
|
+
* plugin's ledgers, locks and metrics), plus the four harness mirrors that
|
|
259
|
+
* carry a per-session `STATE.md` / `wave-scope.json` / `filescopes/` —
|
|
260
|
+
* `.claude/`, `.codex/`, `.cursor/` (all three gitignored file-by-file in this
|
|
261
|
+
* repo's `.gitignore`) and `.pi/` (`skills/_shared/platform-tools.md` § Pi;
|
|
262
|
+
* absent from this checkout, listed so the Pi harness is covered wherever the
|
|
263
|
+
* plugin is installed).
|
|
264
|
+
*
|
|
265
|
+
* Ceiling (BV-004): exactly these five prefixes, and ONLY in conjunction with
|
|
266
|
+
* the git test. `.gitignore` here also declines to track real, hand-authored
|
|
267
|
+
* documents that simply do not ship (`docs/specs/`, `docs/_private/`) and
|
|
268
|
+
* whole build outputs (`coverage/`, `node_modules/`) — a typo in a
|
|
269
|
+
* `docs/specs/…` citation is a defect this check exists to catch, so those
|
|
270
|
+
* must keep REPORTING. Revisit when a harness adds a sixth state root, or
|
|
271
|
+
* when a state root stops being a dot-directory at the repo root.
|
|
272
|
+
*/
|
|
273
|
+
export const RUNTIME_STATE_PREFIXES = Object.freeze([
|
|
274
|
+
'.orchestrator/',
|
|
275
|
+
'.claude/',
|
|
276
|
+
'.codex/',
|
|
277
|
+
'.cursor/',
|
|
278
|
+
'.pi/',
|
|
279
|
+
]);
|
|
280
|
+
|
|
281
|
+
/**
|
|
282
|
+
* Does `citedPath` live under a harness state root?
|
|
283
|
+
*
|
|
284
|
+
* Necessary but NOT sufficient for the runtime-artefact carve-out — the git
|
|
285
|
+
* test in {@link gitIgnoredPaths} is the second half. `.claude/rules/x.md` is
|
|
286
|
+
* under a state root and TRACKED, so it still reports.
|
|
287
|
+
*
|
|
288
|
+
* @param {string} citedPath repo-relative POSIX path
|
|
289
|
+
* @returns {boolean}
|
|
290
|
+
*/
|
|
291
|
+
export function isRuntimeStatePath(citedPath) {
|
|
292
|
+
return RUNTIME_STATE_PREFIXES.some((prefix) => citedPath.startsWith(prefix));
|
|
293
|
+
}
|
|
294
|
+
|
|
295
|
+
/**
|
|
296
|
+
* Which of `candidates` git IGNORES — one half of the runtime-artefact test
|
|
297
|
+
* (the other is {@link isRuntimeStatePath}).
|
|
298
|
+
*
|
|
299
|
+
* The rules corpora widened into by #1384 P3 cite paths that never exist in a
|
|
300
|
+
* checkout and are not supposed to: `.cursor/STATE.md`, `.orchestrator/…`
|
|
301
|
+
* ledgers, per-session state files. Rather than a hand-kept name list (which
|
|
302
|
+
* would rot the moment a new ledger is added, and which nothing measures), the
|
|
303
|
+
* test is MECHANICAL and matches the repo's own definition: a path the
|
|
304
|
+
* repository declines to track, which does not exist, is by construction
|
|
305
|
+
* written at runtime — so there is nothing for a citation gate to catch.
|
|
306
|
+
*
|
|
307
|
+
* That predicate alone is too wide, which is why the prefix half exists: "git
|
|
308
|
+
* ignores it" and "it is written at runtime" are not the same claim. Measured
|
|
309
|
+
* 2026-09-18, `gitIgnoredPaths` matched `docs/specs/foo.md`,
|
|
310
|
+
* `docs/_private/x.md`, `coverage/report.md` and `node_modules/x/y.mjs` just
|
|
311
|
+
* as readily as `.orchestrator/metrics/events.jsonl` — real local documents
|
|
312
|
+
* whose dead citations this check must still report.
|
|
313
|
+
*
|
|
314
|
+
* ONE `git check-ignore --stdin` for the whole run, never one per path: the
|
|
315
|
+
* corpus carries hundreds of citations and a per-path spawn would dominate the
|
|
316
|
+
* check's runtime.
|
|
317
|
+
*
|
|
318
|
+
* Fails OPEN toward REPORTING (the safe direction here): a missing `git`, a
|
|
319
|
+
* non-git root, or exit 128 yields an empty set, so every absent citation is
|
|
320
|
+
* still reported and no real defect is suppressed by a tooling failure. Exit 1
|
|
321
|
+
* means "none of them are ignored" and is NOT an error.
|
|
322
|
+
*
|
|
323
|
+
* @param {string} repoRoot absolute repo root
|
|
324
|
+
* @param {string[]} candidates repo-relative POSIX paths (already known absent)
|
|
325
|
+
* @returns {Set<string>} the subset git ignores
|
|
326
|
+
*/
|
|
327
|
+
export function gitIgnoredPaths(repoRoot, candidates) {
|
|
328
|
+
const unique = [...new Set(candidates)].filter((p) => p.length > 0 && !p.includes('\n'));
|
|
329
|
+
if (unique.length === 0) return new Set();
|
|
330
|
+
let stdout;
|
|
331
|
+
try {
|
|
332
|
+
stdout = execFileSync('git', ['check-ignore', '--stdin'], {
|
|
333
|
+
cwd: repoRoot,
|
|
334
|
+
input: `${unique.join('\n')}\n`,
|
|
335
|
+
encoding: 'utf8',
|
|
336
|
+
stdio: ['pipe', 'pipe', 'ignore'],
|
|
337
|
+
maxBuffer: 8 * 1024 * 1024,
|
|
338
|
+
});
|
|
339
|
+
} catch (error) {
|
|
340
|
+
// Exit 1 = nothing matched, and git still wrote (empty) stdout. Anything
|
|
341
|
+
// else (128, ENOENT, non-git root) leaves `stdout` undefined → empty set.
|
|
342
|
+
if (error?.status !== 1) return new Set();
|
|
343
|
+
stdout = typeof error.stdout === 'string' ? error.stdout : '';
|
|
344
|
+
}
|
|
345
|
+
return new Set(
|
|
346
|
+
String(stdout)
|
|
347
|
+
.split('\n')
|
|
348
|
+
.map((line) => line.trim())
|
|
349
|
+
.filter(Boolean),
|
|
350
|
+
);
|
|
351
|
+
}
|
|
352
|
+
|
|
169
353
|
/** The annotation marker, in any of its three classes. */
|
|
170
354
|
const ANNOTATION_RE = /<!--\s*path-check:\s*([^>]*?)\s*-->/;
|
|
171
355
|
|
|
@@ -274,10 +458,20 @@ export function scanSkillScriptPaths({ pluginRoot, dirs = SCAN_DIRS, strictSh =
|
|
|
274
458
|
existing: 0,
|
|
275
459
|
annotated: 0,
|
|
276
460
|
placeholders: 0,
|
|
461
|
+
runtimeArtifacts: 0,
|
|
277
462
|
findings: 0,
|
|
278
463
|
warnings: 0,
|
|
279
464
|
};
|
|
280
465
|
|
|
466
|
+
/**
|
|
467
|
+
* Citations that are absent AND unannotated — judged only after the corpus
|
|
468
|
+
* loop, when the single `git check-ignore` call can separate a dead
|
|
469
|
+
* reference from a path written at runtime.
|
|
470
|
+
*
|
|
471
|
+
* @type {{file: string, citation: {line: number, path: string}}[]}
|
|
472
|
+
*/
|
|
473
|
+
const pending = [];
|
|
474
|
+
|
|
281
475
|
/** @type {string[]} */
|
|
282
476
|
let files;
|
|
283
477
|
try {
|
|
@@ -290,7 +484,7 @@ export function scanSkillScriptPaths({ pluginRoot, dirs = SCAN_DIRS, strictSh =
|
|
|
290
484
|
// honours `.gitignore`, so the #1143 exposure a bare `readdirSync` walk
|
|
291
485
|
// would reintroduce (a worktree under `.claude/worktrees/`, gitignored
|
|
292
486
|
// `docs/specs/*.md`) stays closed — see that module's header.
|
|
293
|
-
files = enumerateRepoFiles({ repoRoot: pluginRoot, dirs, exts:
|
|
487
|
+
files = enumerateRepoFiles({ repoRoot: pluginRoot, dirs, exts: MD_EXTENSIONS });
|
|
294
488
|
} catch (error) {
|
|
295
489
|
findings.push({
|
|
296
490
|
kind: 'tool-error',
|
|
@@ -389,30 +583,48 @@ export function scanSkillScriptPaths({ pluginRoot, dirs = SCAN_DIRS, strictSh =
|
|
|
389
583
|
}
|
|
390
584
|
if (marker && !marker.ok) continue; // already reported as bad-annotation
|
|
391
585
|
|
|
392
|
-
//
|
|
393
|
-
//
|
|
394
|
-
|
|
395
|
-
|
|
396
|
-
|
|
397
|
-
|
|
398
|
-
|
|
399
|
-
|
|
400
|
-
|
|
401
|
-
|
|
402
|
-
|
|
403
|
-
|
|
404
|
-
|
|
405
|
-
|
|
406
|
-
|
|
407
|
-
|
|
408
|
-
|
|
409
|
-
|
|
410
|
-
'create it, fix the path, or annotate the citation with ' +
|
|
411
|
-
'`<!-- path-check: planned #<iid> | historical | example -->` on this line or the ' +
|
|
412
|
-
'line directly above',
|
|
413
|
-
severity,
|
|
414
|
-
});
|
|
586
|
+
// Deferred, not reported yet: the runtime-artefact test below needs ONE
|
|
587
|
+
// `git check-ignore` for the whole corpus, not one per citation.
|
|
588
|
+
pending.push({ file: relative, citation });
|
|
589
|
+
}
|
|
590
|
+
}
|
|
591
|
+
|
|
592
|
+
// BOTH halves, never one: under a harness state root AND untracked by git.
|
|
593
|
+
// Only state-root candidates are even offered to git, so the subprocess
|
|
594
|
+
// shrinks to the paths that could possibly qualify.
|
|
595
|
+
const ignored = gitIgnoredPaths(
|
|
596
|
+
pluginRoot,
|
|
597
|
+
pending.map((p) => p.citation.path).filter(isRuntimeStatePath),
|
|
598
|
+
);
|
|
599
|
+
|
|
600
|
+
for (const { file: relative, citation } of pending) {
|
|
601
|
+
if (isRuntimeStatePath(citation.path) && ignored.has(citation.path)) {
|
|
602
|
+
summary.runtimeArtifacts += 1;
|
|
603
|
+
continue;
|
|
415
604
|
}
|
|
605
|
+
// `.mjs` and `.md` are blocking.
|
|
606
|
+
// `.sh` is advisory (`warn`) unless the caller opted into `strictSh`.
|
|
607
|
+
const isSh = path.extname(citation.path) === '.sh';
|
|
608
|
+
const severity = isSh && !strictSh ? 'warn' : 'fail';
|
|
609
|
+
if (severity === 'warn') summary.warnings += 1;
|
|
610
|
+
findings.push({
|
|
611
|
+
kind: 'missing-path',
|
|
612
|
+
file: relative,
|
|
613
|
+
line: citation.line,
|
|
614
|
+
path: citation.path,
|
|
615
|
+
annotation: null,
|
|
616
|
+
message:
|
|
617
|
+
(isSh
|
|
618
|
+
? severity === 'warn'
|
|
619
|
+
? `\`${citation.path}\` does not exist (advisory — .sh citations do not block ` +
|
|
620
|
+
'validate-plugin until re-run with --strict-sh; see #1187) — '
|
|
621
|
+
: `\`${citation.path}\` does not exist (--strict-sh) — `
|
|
622
|
+
: `\`${citation.path}\` does not exist — `) +
|
|
623
|
+
'create it, fix the path, or annotate the citation with ' +
|
|
624
|
+
'`<!-- path-check: planned #<iid> | historical | example -->` on this line or the ' +
|
|
625
|
+
'line directly above',
|
|
626
|
+
severity,
|
|
627
|
+
});
|
|
416
628
|
}
|
|
417
629
|
|
|
418
630
|
findings.sort((a, b) => a.file.localeCompare(b.file) || a.line - b.line);
|
|
@@ -111,6 +111,7 @@
|
|
|
111
111
|
import { readFileSync, readdirSync, statSync } from 'node:fs';
|
|
112
112
|
import path from 'node:path';
|
|
113
113
|
import { isMainModule } from '../is-main-module.mjs';
|
|
114
|
+
import { maskSource } from '../js-mask.mjs';
|
|
114
115
|
|
|
115
116
|
/** Only this directory is scanned — a mutation in `scripts/` is production intent. */
|
|
116
117
|
const SCAN_DIR = 'tests';
|
|
@@ -487,43 +488,24 @@ export function insideStringLiteral(body, index) {
|
|
|
487
488
|
* "no cwd" measured as a cwd. `inCommentLine` cannot serve here: it answers a
|
|
488
489
|
* question about a whole LINE, while this one runs inside a call expression.
|
|
489
490
|
*
|
|
491
|
+
* Delegates to the shared lexer {@link maskSource} in `keepLiterals` mode
|
|
492
|
+
* (#1388). The hand-rolled walker this replaced had no REGEX-LITERAL branch,
|
|
493
|
+
* so a call tail carrying one — measured 2026-09-18:
|
|
494
|
+
* `wrapperHasCwd(", undefined, { env: /\/*$/.source, cwd: dir }")` — read the
|
|
495
|
+
* regex's `/*` as a block-comment opener, swallowed the rest of the tail and
|
|
496
|
+
* returned `false`: a false alarm from this check.
|
|
497
|
+
*
|
|
498
|
+
* One behavioural difference the callers must honour: `maskSource` blanks a
|
|
499
|
+
* comment to SPACES (length-preserving) where this function used to collapse
|
|
500
|
+
* it to a single space. {@link wrapperHasCwd} judges its second positional
|
|
501
|
+
* textually against `second !== ''`, so that difference was checked rather
|
|
502
|
+
* than assumed — see the measurement recorded at that test.
|
|
503
|
+
*
|
|
490
504
|
* @param {string} text
|
|
491
|
-
* @returns {string} same length
|
|
505
|
+
* @returns {string} same length, comment bytes blanked to spaces
|
|
492
506
|
*/
|
|
493
507
|
export function stripComments(text) {
|
|
494
|
-
|
|
495
|
-
/** @type {string|null} */
|
|
496
|
-
let quote = null;
|
|
497
|
-
for (let i = 0; i < text.length; i += 1) {
|
|
498
|
-
const ch = text[i];
|
|
499
|
-
if (quote !== null) {
|
|
500
|
-
out += ch;
|
|
501
|
-
if (ch === '\\') {
|
|
502
|
-
out += text[i + 1] ?? '';
|
|
503
|
-
i += 1;
|
|
504
|
-
} else if (ch === quote) quote = null;
|
|
505
|
-
continue;
|
|
506
|
-
}
|
|
507
|
-
if (ch === "'" || ch === '"' || ch === '`') {
|
|
508
|
-
quote = ch;
|
|
509
|
-
out += ch;
|
|
510
|
-
continue;
|
|
511
|
-
}
|
|
512
|
-
if (ch === '/' && text[i + 1] === '*') {
|
|
513
|
-
const end = text.indexOf('*/', i + 2);
|
|
514
|
-
i = end === -1 ? text.length : end + 1;
|
|
515
|
-
out += ' ';
|
|
516
|
-
continue;
|
|
517
|
-
}
|
|
518
|
-
if (ch === '/' && text[i + 1] === '/') {
|
|
519
|
-
const end = text.indexOf('\n', i);
|
|
520
|
-
i = end === -1 ? text.length : end - 1;
|
|
521
|
-
out += ' ';
|
|
522
|
-
continue;
|
|
523
|
-
}
|
|
524
|
-
out += ch;
|
|
525
|
-
}
|
|
526
|
-
return out;
|
|
508
|
+
return maskSource(text, { keepLiterals: true });
|
|
527
509
|
}
|
|
528
510
|
|
|
529
511
|
/**
|
|
@@ -549,6 +531,14 @@ export function wrapperHasCwd(tail) {
|
|
|
549
531
|
const clean = stripComments(tail);
|
|
550
532
|
const m = /^\s*,\s*/.exec(clean);
|
|
551
533
|
if (m) {
|
|
534
|
+
// NO `.trim()` here, and that is measured rather than assumed (#1388): the
|
|
535
|
+
// shared lexer blanks a comment to SPACES where the local stripper used to
|
|
536
|
+
// delete it, so a comment-only tail LOOKS like it would arrive as truthy
|
|
537
|
+
// whitespace. It cannot — the `\s*` above is greedy and consumes every
|
|
538
|
+
// blanked byte, leaving `second === ''`. Measured 2026-09-18 over
|
|
539
|
+
// `, /* no cwd */`, `, /* a */ /* b */`, `,\n // note\n`,
|
|
540
|
+
// `, /* x */ undefined`, `, undefined /* y */`: all `false`, `, /* c */ dir`
|
|
541
|
+
// → `true`. A `.trim()` would be dead code; the case is pinned by a test.
|
|
552
542
|
const second = clean.slice(m[0].length);
|
|
553
543
|
if (second !== '' && !/^(?:undefined|null)\b/.test(second) && !/^,/.test(second)) return true;
|
|
554
544
|
}
|
|
@@ -108,6 +108,13 @@ import { existsSync, readFileSync, readdirSync, statSync } from 'node:fs';
|
|
|
108
108
|
import { spawnSync } from 'node:child_process';
|
|
109
109
|
import path from 'node:path';
|
|
110
110
|
import { isMainModule } from '../is-main-module.mjs';
|
|
111
|
+
import { maskSource } from '../js-mask.mjs';
|
|
112
|
+
|
|
113
|
+
// `maskSource` moved to `scripts/lib/js-mask.mjs` (#1388 — three other modules
|
|
114
|
+
// needed the same lexer). `package.json` carries no `exports` map, so every
|
|
115
|
+
// `scripts/lib/**` path is public API: this re-export keeps the OLD import path
|
|
116
|
+
// working for any consumer that already reaches in here.
|
|
117
|
+
export { maskSource } from '../js-mask.mjs';
|
|
111
118
|
|
|
112
119
|
// ---------------------------------------------------------------------------
|
|
113
120
|
// Constants
|
|
@@ -167,108 +174,6 @@ const NON_CALLEES = new Set([
|
|
|
167
174
|
'await', 'new', 'do', 'else', 'in', 'of', 'delete', 'void', 'yield', 'import',
|
|
168
175
|
]);
|
|
169
176
|
|
|
170
|
-
// ---------------------------------------------------------------------------
|
|
171
|
-
// Source masking — string/template/comment/regex interiors become spaces
|
|
172
|
-
// ---------------------------------------------------------------------------
|
|
173
|
-
|
|
174
|
-
/**
|
|
175
|
-
* Blank out the INTERIOR of every string literal, template literal, comment and
|
|
176
|
-
* regex literal, preserving byte offsets and newlines. Delimiters are kept so
|
|
177
|
-
* paren/comma balance and identifier boundaries survive.
|
|
178
|
-
*
|
|
179
|
-
* This is what separates CODE from DATA. A test that embeds fixture source in a
|
|
180
|
-
* template literal (this check's own test file does) must not be scanned as
|
|
181
|
-
* though that fixture were its own body — masking makes that structural instead
|
|
182
|
-
* of relying on a self-exemption marker.
|
|
183
|
-
*
|
|
184
|
-
* @param {string} text
|
|
185
|
-
* @returns {string} same-length masked source
|
|
186
|
-
*/
|
|
187
|
-
export function maskSource(text) {
|
|
188
|
-
const out = text.split('');
|
|
189
|
-
const n = out.length;
|
|
190
|
-
let i = 0;
|
|
191
|
-
// Last significant (non-space) char before `i`, used for the regex/division
|
|
192
|
-
// disambiguation below.
|
|
193
|
-
let prev = '';
|
|
194
|
-
|
|
195
|
-
const blank = (from, to) => {
|
|
196
|
-
for (let k = from; k < to && k < n; k++) if (out[k] !== '\n') out[k] = ' ';
|
|
197
|
-
};
|
|
198
|
-
|
|
199
|
-
while (i < n) {
|
|
200
|
-
const c = text[i];
|
|
201
|
-
const next = text[i + 1];
|
|
202
|
-
|
|
203
|
-
// Line comment.
|
|
204
|
-
if (c === '/' && next === '/') {
|
|
205
|
-
let j = i;
|
|
206
|
-
while (j < n && text[j] !== '\n') j++;
|
|
207
|
-
blank(i, j);
|
|
208
|
-
i = j;
|
|
209
|
-
continue;
|
|
210
|
-
}
|
|
211
|
-
// Block comment.
|
|
212
|
-
if (c === '/' && next === '*') {
|
|
213
|
-
let j = i + 2;
|
|
214
|
-
while (j < n && !(text[j] === '*' && text[j + 1] === '/')) j++;
|
|
215
|
-
blank(i, Math.min(j + 2, n));
|
|
216
|
-
i = Math.min(j + 2, n);
|
|
217
|
-
continue;
|
|
218
|
-
}
|
|
219
|
-
// Single/double-quoted string — keep the quotes, blank the interior.
|
|
220
|
-
if (c === "'" || c === '"') {
|
|
221
|
-
let j = i + 1;
|
|
222
|
-
while (j < n && text[j] !== c) {
|
|
223
|
-
if (text[j] === '\\') j++;
|
|
224
|
-
if (text[j] === '\n') break; // unterminated — bail at EOL
|
|
225
|
-
j++;
|
|
226
|
-
}
|
|
227
|
-
blank(i + 1, j);
|
|
228
|
-
i = Math.min(j + 1, n);
|
|
229
|
-
prev = c;
|
|
230
|
-
continue;
|
|
231
|
-
}
|
|
232
|
-
// Template literal — blank everything including `${…}` substitutions.
|
|
233
|
-
if (c === '`') {
|
|
234
|
-
let j = i + 1;
|
|
235
|
-
while (j < n && text[j] !== '`') {
|
|
236
|
-
if (text[j] === '\\') j++;
|
|
237
|
-
j++;
|
|
238
|
-
}
|
|
239
|
-
blank(i + 1, j);
|
|
240
|
-
i = Math.min(j + 1, n);
|
|
241
|
-
prev = c;
|
|
242
|
-
continue;
|
|
243
|
-
}
|
|
244
|
-
// Regex literal — only when the previous significant char cannot end an
|
|
245
|
-
// expression, AND a closing unescaped `/` exists on the SAME line. The
|
|
246
|
-
// same-line bound keeps a misread division from swallowing the file.
|
|
247
|
-
if (c === '/' && (prev === '' || '(,=:[!&|?{};+-*%~^<>'.includes(prev))) {
|
|
248
|
-
let j = i + 1;
|
|
249
|
-
let inClass = false;
|
|
250
|
-
let closed = -1;
|
|
251
|
-
while (j < n && text[j] !== '\n') {
|
|
252
|
-
if (text[j] === '\\') { j += 2; continue; }
|
|
253
|
-
if (text[j] === '[') inClass = true;
|
|
254
|
-
else if (text[j] === ']') inClass = false;
|
|
255
|
-
else if (text[j] === '/' && !inClass) { closed = j; break; }
|
|
256
|
-
j++;
|
|
257
|
-
}
|
|
258
|
-
if (closed > i) {
|
|
259
|
-
blank(i + 1, closed);
|
|
260
|
-
i = closed + 1;
|
|
261
|
-
prev = '/';
|
|
262
|
-
continue;
|
|
263
|
-
}
|
|
264
|
-
}
|
|
265
|
-
|
|
266
|
-
if (!/\s/.test(c)) prev = c;
|
|
267
|
-
i++;
|
|
268
|
-
}
|
|
269
|
-
return out.join('');
|
|
270
|
-
}
|
|
271
|
-
|
|
272
177
|
// ---------------------------------------------------------------------------
|
|
273
178
|
// Tiny source scanners (offset-aligned against the masked text)
|
|
274
179
|
// ---------------------------------------------------------------------------
|