@event4u/agent-config 14.18.0 → 14.20.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.
Files changed (210) hide show
  1. package/.augment-plugin/marketplace.json +3 -3
  2. package/.augment-plugin/plugin.json +1 -1
  3. package/.claude-plugin/marketplace.json +1 -1
  4. package/CHANGELOG.md +120 -129
  5. package/README.md +71 -149
  6. package/dist/agent-src/README.md +1 -1
  7. package/dist/agent-src/commands/agent-handoff.md +44 -43
  8. package/dist/agent-src/commands/review/changes.md +19 -19
  9. package/dist/agent-src/commands/review.md +2 -2
  10. package/dist/agent-src/contexts/execution/host-capability-manifest.md +37 -4
  11. package/dist/agent-src/rules/autonomous-execution.md +1 -1
  12. package/dist/agent-src/rules/git-history-discipline.md +2 -2
  13. package/dist/agent-src/rules/guidelines.md +1 -1
  14. package/dist/agent-src/rules/session-canary.md +2 -2
  15. package/dist/agent-src/rules/token-efficiency.md +1 -1
  16. package/dist/agent-src/rules/untrusted-input-defense.md +0 -2
  17. package/dist/agent-src/skills/adversarial-review/SKILL.md +0 -8
  18. package/dist/agent-src/skills/canvas-design/SKILL.md +1 -1
  19. package/dist/agent-src/skills/design-intelligence/SKILL.md +1 -1
  20. package/dist/agent-src/skills/design-intelligence/data/app-interface.csv +1 -1
  21. package/dist/agent-src/skills/design-intelligence/data/motion.csv +17 -17
  22. package/dist/agent-src/skills/design-intelligence/data/ux-guidelines.csv +2 -2
  23. package/dist/agent-src/skills/design-intelligence/references/context-and-registers.md +17 -0
  24. package/dist/agent-src/skills/design-intelligence/references/design-rules-checklist.md +4 -4
  25. package/dist/agent-src/skills/design-review/SKILL.md +1 -1
  26. package/dist/agent-src/skills/design-variations/SKILL.md +1 -1
  27. package/dist/agent-src/skills/evaluate-llm-feature/SKILL.md +1 -1
  28. package/dist/agent-src/skills/existing-ui-audit/SKILL.md +1 -1
  29. package/dist/agent-src/skills/fe-design/SKILL.md +32 -5
  30. package/dist/agent-src/skills/fe-design/references/craft-floor.md +7 -0
  31. package/dist/agent-src/skills/fe-design/references/design-patterns.md +47 -2
  32. package/dist/agent-src/skills/laravel-scheduling/SKILL.md +3 -1
  33. package/dist/agent-src/skills/markitdown/SKILL.md +1 -1
  34. package/dist/agent-src/skills/project-analyzer/SKILL.md +0 -6
  35. package/dist/agent-src/skills/react-native-setup/SKILL.md +3 -3
  36. package/dist/agent-src/skills/react-shadcn-ui/SKILL.md +1 -1
  37. package/dist/agent-src/skills/sequential-thinking/SKILL.md +18 -8
  38. package/dist/agent-src/skills/skill-improvement-pipeline/SKILL.md +28 -6
  39. package/dist/agent-src/skills/tailwind-engineer/SKILL.md +1 -1
  40. package/dist/agent-src/skills/test-driven-development/SKILL.md +1 -3
  41. package/dist/agent-src/skills/ui-apply-generic/SKILL.md +1 -1
  42. package/dist/agent-src/skills/ui-component-architect/SKILL.md +1 -1
  43. package/dist/agent-src/skills/using-git-worktrees/SKILL.md +17 -2
  44. package/dist/agent-src/templates/agents/agent-project-settings.example.yml +1 -1
  45. package/dist/agent-src/templates/roadmaps.md +14 -1
  46. package/dist/agent-src/templates/scripts/telemetry/mcp_lite.ts +213 -0
  47. package/dist/agent-src/templates/scripts/telemetry/report_renderer.ts +16 -0
  48. package/dist/agent-src/templates/scripts/telemetry_report.ts +22 -2
  49. package/dist/cli/commands/recordTriggerEval.js +2 -2
  50. package/dist/cli/main.js +1 -1
  51. package/dist/cli/mcp/dispatch.js +10 -0
  52. package/dist/cli/mcp/stdio.js +33 -2
  53. package/dist/cli/mcp/telemetry.js +227 -0
  54. package/dist/cli-delegate/{chunk-AKJGUQNO.js → chunk-C6IPZRDA.js} +484 -353
  55. package/dist/cli-delegate/{chunk-CYH5SP6M.js → chunk-I6RHFQEG.js} +151 -16
  56. package/dist/cli-delegate/{chunk-7RXIKF62.js → chunk-NUMQHLS5.js} +304 -136
  57. package/dist/cli-delegate/{chunk-PMEKGDED.js → chunk-PI2GU3DP.js} +163 -1
  58. package/dist/cli-delegate/{chunk-7PRE6ZV2.js → chunk-YS6XTLEK.js} +199 -4
  59. package/dist/cli-delegate/chunk-ZVBOHSVF.js +1109 -0
  60. package/dist/cli-delegate/cmd_adr_effective.js +318 -81
  61. package/dist/cli-delegate/cmd_conformance.js +489 -121
  62. package/dist/cli-delegate/cmd_doctor.js +2 -2
  63. package/dist/cli-delegate/cmd_export.js +2 -2
  64. package/dist/cli-delegate/cmd_handoff.js +42 -12
  65. package/dist/cli-delegate/cmd_memory_get.js +1 -1
  66. package/dist/cli-delegate/cmd_prune.js +2 -2
  67. package/dist/cli-delegate/cmd_route_audit.js +2 -2
  68. package/dist/cli-delegate/cmd_session_recycle.js +59 -902
  69. package/dist/cli-delegate/cmd_settings_migrate.js +2 -2
  70. package/dist/cli-delegate/cmd_sync.js +2 -2
  71. package/dist/cli-delegate/cmd_uninstall.js +2 -2
  72. package/dist/cli-delegate/cmd_validate.js +2 -2
  73. package/dist/discovery/deprecation-report.md +1 -1
  74. package/dist/discovery/discovery-manifest.json +34 -33
  75. package/dist/discovery/discovery-manifest.json.sha256 +1 -1
  76. package/dist/discovery/discovery-manifest.summary.md +1 -1
  77. package/dist/discovery/dormancy-report.md +1 -1
  78. package/dist/discovery/orphan-report.md +1 -1
  79. package/dist/discovery/packs.json +2 -2
  80. package/dist/discovery/trust-report.md +1 -1
  81. package/dist/discovery/workspaces.json +2 -2
  82. package/dist/hooks/dispatch.js +4455 -3025
  83. package/dist/install/install.mjs +975 -689
  84. package/dist/mcp/registry-manifest.json +2 -2
  85. package/dist/mcp/server.json +2 -2
  86. package/dist/mcp/server.mjs +2087 -1134
  87. package/dist/scripts/_lib/model_tier.js +1 -1
  88. package/dist/scripts/mcp_server/telemetry.js +148 -0
  89. package/docs/guidelines/agent-infra/evaluator-independence-mechanics.md +1 -1
  90. package/docs/guidelines/agent-infra/naming.md +1 -1
  91. package/docs/guidelines/agent-infra/roadmap-progress-mechanics.md +1 -1
  92. package/docs/guidelines/agent-infra/security-lint-containment.md +46 -6
  93. package/docs/guidelines/agent-infra/self-improvement-pipeline.md +4 -4
  94. package/docs/guidelines/agent-infra/untrusted-input-spotlighting.md +1 -1
  95. package/docs/guidelines/design-antipatterns.md +87 -64
  96. package/docs/guidelines/redundancy-taxonomy.md +28 -0
  97. package/package.json +1 -1
  98. package/src/agent-src/README.md +1 -1
  99. package/src/agent-src/templates/scripts/telemetry/mcp_lite.ts +213 -0
  100. package/src/agent-src/templates/scripts/telemetry/report_renderer.ts +16 -0
  101. package/src/agent-src/templates/scripts/telemetry_report.ts +22 -2
  102. package/src/config/assurance-capability-registry.json +9 -0
  103. package/src/config/ci-local-parity.yml +6 -0
  104. package/src/config/gate-coverage.yml +225 -0
  105. package/src/config/gate-violation-baselines.json +18 -6
  106. package/src/config/release-gate-locality.yml +12 -0
  107. package/src/scripts/_cli/cmd_doctor.ts +2 -2
  108. package/src/scripts/_cli/cmd_handoff.ts +1 -1
  109. package/src/scripts/_cli/cmd_session_recycle.ts +51 -3
  110. package/src/scripts/_cli/cmd_update.ts +1 -1
  111. package/src/scripts/_cli/cmd_versions.ts +1 -1
  112. package/src/scripts/_lib/adr_frontmatter.ts +44 -0
  113. package/src/scripts/_lib/audit_field_provenance.ts +44 -3
  114. package/src/scripts/_lib/consequence_objects.ts +152 -0
  115. package/src/scripts/_lib/exec_evidence.ts +7 -0
  116. package/src/scripts/_lib/global_deploy_inventory.ts +2 -2
  117. package/src/scripts/_lib/host_capability.ts +38 -0
  118. package/src/scripts/_lib/host_permission_checks.ts +251 -0
  119. package/src/scripts/_lib/install_reach_checks.ts +33 -1
  120. package/src/scripts/_lib/mcp_bridge.ts +222 -10
  121. package/src/scripts/_lib/mcp_consent_residual.ts +173 -0
  122. package/src/scripts/_lib/model_tier.ts +1 -1
  123. package/src/scripts/_lib/obligation_frequency.ts +2 -2
  124. package/src/scripts/_lib/orchestration_record.ts +23 -1
  125. package/src/scripts/_lib/recycle_envelope_paths.ts +190 -0
  126. package/src/scripts/_lib/release_highlights.ts +93 -0
  127. package/src/scripts/_lib/release_material.ts +64 -1
  128. package/src/scripts/_lib/release_position.ts +96 -0
  129. package/src/scripts/_lib/review_skipped_record.ts +17 -1
  130. package/src/scripts/_lib/runtime_journal.ts +26 -3
  131. package/src/scripts/_lib/runtime_wiring_checks.ts +12 -1
  132. package/src/scripts/_lib/security_lint.ts +179 -7
  133. package/src/scripts/_lib/self_repair.ts +141 -6
  134. package/src/scripts/_lib/self_repair_store.ts +273 -7
  135. package/src/scripts/_lib/session_register.ts +11 -6
  136. package/src/scripts/_lib/sqlite_schema.ts +22 -0
  137. package/src/scripts/_lib/subagent_capsule.ts +155 -3
  138. package/src/scripts/_lib/surface.ts +86 -0
  139. package/src/scripts/_lib/ui_authority.ts +116 -0
  140. package/src/scripts/adr/regenerate_index.ts +54 -1
  141. package/src/scripts/adr_cite_check.ts +71 -15
  142. package/src/scripts/ai_council/clients.ts +1 -1
  143. package/src/scripts/autonomy_friction_corpus.ts +229 -0
  144. package/src/scripts/build_proof.ts +15 -2
  145. package/src/scripts/build_rule_trigger_matrix.ts +5 -0
  146. package/src/scripts/check_beta_review_markers.ts +141 -17
  147. package/src/scripts/check_enforcement_coverage.ts +1 -1
  148. package/src/scripts/check_enforcement_denominator.ts +121 -11
  149. package/src/scripts/check_finding_dispositions.ts +66 -9
  150. package/src/scripts/check_gate_coverage.ts +96 -0
  151. package/src/scripts/check_mcp_doc_drift.ts +217 -0
  152. package/src/scripts/check_pack_size.ts +321 -3
  153. package/src/scripts/check_release_highlights.ts +74 -1
  154. package/src/scripts/check_skill_activation_claim.ts +179 -0
  155. package/src/scripts/check_trigger_evals.ts +1 -1
  156. package/src/scripts/conformance_scan.ts +44 -3
  157. package/src/scripts/explain_run.ts +1 -1
  158. package/src/scripts/generate_capability_matrix.ts +1 -1
  159. package/src/scripts/git_authorization_hook.ts +75 -1
  160. package/src/scripts/handoff_context_hook.ts +54 -7
  161. package/src/scripts/hook_manifest.json +1 -1
  162. package/src/scripts/hook_manifest.yaml +14 -11
  163. package/src/scripts/hooks/augment-dispatcher.sh +1 -1
  164. package/src/scripts/hooks/category_a.ts +291 -0
  165. package/src/scripts/hooks/cline-dispatcher.sh +1 -1
  166. package/src/scripts/hooks/cursor-dispatcher.sh +11 -5
  167. package/src/scripts/hooks/dispatch_hook.ts +17 -22
  168. package/src/scripts/hooks/git_command_classifier.ts +156 -1
  169. package/src/scripts/hooks/host_lowering.ts +215 -0
  170. package/src/scripts/hooks/host_lowering.yaml +185 -0
  171. package/src/scripts/hooks/host_semantics.ts +105 -37
  172. package/src/scripts/hooks/journal_record_hook.ts +10 -0
  173. package/src/scripts/hooks/permission_gate.ts +117 -0
  174. package/src/scripts/hooks/session_eol_hook.ts +18 -7
  175. package/src/scripts/hooks_status.ts +12 -10
  176. package/src/scripts/install.ts +57 -86
  177. package/src/scripts/install_anthropic_key.sh +2 -2
  178. package/src/scripts/lint_agent_security.ts +316 -25
  179. package/src/scripts/lint_confusables.ts +42 -6
  180. package/src/scripts/lint_design_antipattern_parity.ts +80 -0
  181. package/src/scripts/lint_evidence_artifacts.ts +45 -1
  182. package/src/scripts/lint_handoffs.ts +0 -132
  183. package/src/scripts/lint_hidden_unicode.ts +49 -7
  184. package/src/scripts/lint_hook_manifest.ts +87 -3
  185. package/src/scripts/lint_instruction_smuggling.ts +42 -6
  186. package/src/scripts/lint_mcp_config_security.ts +42 -6
  187. package/src/scripts/lint_motion_authority_drift.ts +731 -0
  188. package/src/scripts/lint_readme_size.ts +158 -12
  189. package/src/scripts/lint_reasoning_fixtures.ts +216 -0
  190. package/src/scripts/lint_roadmap_later_disposition.ts +217 -27
  191. package/src/scripts/lint_skill_frontmatter_safety.ts +43 -7
  192. package/src/scripts/lint_skill_trigger_contradiction.ts +161 -0
  193. package/src/scripts/mcp_server/resources.ts +41 -0
  194. package/src/scripts/mcp_server/telemetry.ts +19 -4
  195. package/src/scripts/measure_sibling_naming.ts +150 -0
  196. package/src/scripts/orchestration_record.ts +12 -1
  197. package/src/scripts/redact_hook_capture.ts +1 -1
  198. package/src/scripts/release.ts +24 -24
  199. package/src/scripts/release_publication.ts +6 -2
  200. package/src/scripts/report_skill_activation.ts +319 -7
  201. package/src/scripts/schemas/review-findings.schema.json +5 -0
  202. package/src/scripts/schemas/skill.schema.json +2 -2
  203. package/src/scripts/self_repair_cli.ts +31 -1
  204. package/src/scripts/session_canary_hook.ts +1 -1
  205. package/src/scripts/session_register_hook.ts +4 -3
  206. package/src/scripts/skill_scout.ts +69 -0
  207. package/src/scripts/trigger_eval_grandfather.json +5 -1
  208. package/src/scripts/validate_agent_settings.ts +1 -1
  209. package/dist/cli-delegate/chunk-2GNWGMAL.js +0 -172
  210. package/dist/cli-delegate/chunk-LPPWO5CE.js +0 -161
@@ -25,6 +25,7 @@ import { spawnSync } from "node:child_process";
25
25
  import { fileURLToPath as fileURLToPath2, pathToFileURL } from "node:url";
26
26
 
27
27
  // src/scripts/_lib/security_lint.ts
28
+ import { createHash } from "node:crypto";
28
29
  import * as fs from "node:fs";
29
30
  import * as path from "node:path";
30
31
  import { fileURLToPath } from "node:url";
@@ -41,7 +42,7 @@ var DEFAULT_SCAN_ROOTS = [
41
42
  "dist/agent-src"
42
43
  ];
43
44
  var _EXAMPLE_PATH = /(^|\/)(docs|evals|tests?|fixtures?)(\/|$)|example|template|sample|\/_template/i;
44
- var _PRAGMA = /<!--\s*security-lint:\s*allow\s+([A-Za-z0-9_-]+)\s+"([^"]+)"\s*-->/g;
45
+ var _PRAGMA = /<!--\s*security-lint:\s*allow\s+([A-Za-z0-9_-]+)\s+"([^"]+)"((?:\s+sha256:[0-9a-f]{64})*)\s*-->/g;
45
46
  var _FENCE = /^(\s*)(`{3,}|~{3,})\s*([A-Za-z0-9_-]*)\s*$/;
46
47
  var SEVERITY_RANK = { LOW: 1, MED: 2, HIGH: 3 };
47
48
  var Finding = class {
@@ -87,6 +88,10 @@ function is_example_path(rel_path) {
87
88
  function path_weight(rel_path) {
88
89
  return is_example_path(rel_path) ? 0.25 : 1;
89
90
  }
91
+ var PROJECTION_PREFIX = "dist/agent-src/";
92
+ function source_identity(rel) {
93
+ return rel.startsWith(PROJECTION_PREFIX) ? `src/${rel.slice(PROJECTION_PREFIX.length)}` : rel;
94
+ }
90
95
  var ScannedFile = class {
91
96
  path;
92
97
  // absolute or as-given path
@@ -97,8 +102,10 @@ var ScannedFile = class {
97
102
  in_any_fence;
98
103
  pragmas;
99
104
  // check id → reason
105
+ /** check id → the sha256 fingerprints that pragma accepts. Empty = unbound. */
106
+ pragma_hashes;
100
107
  weight;
101
- constructor(pathArg, rel, lines, in_example_fence, in_any_fence, pragmas, weight) {
108
+ constructor(pathArg, rel, lines, in_example_fence, in_any_fence, pragmas, weight, pragma_hashes = {}) {
102
109
  this.path = pathArg;
103
110
  this.rel = rel;
104
111
  this.lines = lines;
@@ -106,10 +113,74 @@ var ScannedFile = class {
106
113
  this.in_any_fence = in_any_fence;
107
114
  this.pragmas = pragmas;
108
115
  this.weight = weight;
116
+ this.pragma_hashes = pragma_hashes;
109
117
  }
110
118
  pragma_allows(check) {
111
119
  return Object.prototype.hasOwnProperty.call(this.pragmas, check);
112
120
  }
121
+ /**
122
+ * Which form of pragma this file carries for `check`.
123
+ *
124
+ * `absent` — no pragma; scan normally.
125
+ * `legacy` — a pragma with no fingerprint. Suppresses the whole file, as it
126
+ * always did, and says so: a key lookup accepts whatever the
127
+ * line is later changed to say, which is the defect being paid
128
+ * down, not a mode anybody should choose.
129
+ * `bound` — a pragma listing fingerprints. Suppresses exactly the matches
130
+ * whose evidence hashes to one of them; anything else survives.
131
+ */
132
+ pragma_form(check) {
133
+ if (!this.pragma_allows(check)) return "absent";
134
+ return (this.pragma_hashes[check] ?? []).length > 0 ? "bound" : "legacy";
135
+ }
136
+ /**
137
+ * The fingerprint one finding's evidence hashes to.
138
+ *
139
+ * WHAT IS HASHED, and each part earns its place:
140
+ * check id — the same line may legitimately be accepted for one check
141
+ * and not another.
142
+ * rel path — the location IDENTITY. Not the line NUMBER: an unrelated
143
+ * insert above would otherwise break every pragma in the
144
+ * file, and a suppression that breaks on unrelated edits
145
+ * gets deleted rather than re-derived. A `dist/agent-src/`
146
+ * path folds to its `src/` original first, because the
147
+ * projection is byte-exact by contract (ADR-201) and
148
+ * carries the pragma verbatim — without the fold, every
149
+ * migrated pragma would suppress the source and leave its
150
+ * own copy flagged, which is a gate that reds on a file
151
+ * nobody may edit.
152
+ * matched line, — the evidence. ASCII whitespace runs collapse so a reflow
153
+ * normalized does not invalidate the binding, `sha256:<hex>` tokens are
154
+ * removed, and NOTHING else is stripped: the zero-width
155
+ * characters this suite hunts are exactly what a wider
156
+ * normalizer would erase.
157
+ *
158
+ * WHY THE HASH TOKENS COME OUT. A pragma's own reason string can be the
159
+ * matched evidence — two in this tree are, because they quote the very
160
+ * phrases their check detects in order to explain themselves. Without this
161
+ * the fingerprint would have to be computed over a line that already
162
+ * contains it, which has no fixed point: writing the hash changes the line,
163
+ * which changes the hash. Stripping the tokens makes the fingerprint stable
164
+ * under the act of recording it, and costs nothing elsewhere — a `sha256:`
165
+ * token in ordinary prose is not evidence of anything a linter here checks.
166
+ *
167
+ * Deliberately NOT the whole file: incidental content elsewhere would make
168
+ * every unrelated edit re-fire the pragma, which is the noise that produces
169
+ * blanket suppressions.
170
+ */
171
+ evidence_fingerprint(finding) {
172
+ const text = finding.line > 0 ? this.lines[finding.line - 1] ?? "" : "";
173
+ const normalized = text.replace(/\s*sha256:[0-9a-f]{64}/g, "").replace(/[ \t]+/g, " ").trim();
174
+ return createHash("sha256").update(`${finding.check}
175
+ ${source_identity(this.rel)}
176
+ ${normalized}`, "utf-8").digest("hex");
177
+ }
178
+ /** Drop the findings this file's BOUND pragma for `check` accepts. */
179
+ filter_bound_pragma(check, findings) {
180
+ const accepted = new Set(this.pragma_hashes[check] ?? []);
181
+ if (accepted.size === 0) return [...findings];
182
+ return findings.filter((f) => !accepted.has(this.evidence_fingerprint(f)));
183
+ }
113
184
  /** Yield [lineno, text] honouring the fence masks (mirrors iter_lines). */
114
185
  *iter_lines(opts = {}) {
115
186
  const skip_example_fence = opts.skip_example_fence ?? true;
@@ -200,11 +271,18 @@ function scan_file(filePath) {
200
271
  }
201
272
  }
202
273
  const pragmas = {};
274
+ const pragmaHashes = {};
203
275
  for (const text of lines) {
204
276
  _PRAGMA.lastIndex = 0;
205
277
  let m;
206
278
  while ((m = _PRAGMA.exec(text)) !== null) {
207
- pragmas[m[1]] = m[2];
279
+ const check = m[1];
280
+ pragmas[check] = m[2];
281
+ const hashes = (m[3] ?? "").match(/sha256:([0-9a-f]{64})/g) ?? [];
282
+ pragmaHashes[check] = [
283
+ ...pragmaHashes[check] ?? [],
284
+ ...hashes.map((h) => h.slice("sha256:".length))
285
+ ];
208
286
  if (m.index === _PRAGMA.lastIndex) {
209
287
  _PRAGMA.lastIndex += 1;
210
288
  }
@@ -217,7 +295,29 @@ function scan_file(filePath) {
217
295
  in_example,
218
296
  in_any,
219
297
  pragmas,
220
- path_weight(rel)
298
+ path_weight(rel),
299
+ pragmaHashes
300
+ );
301
+ }
302
+ function scan_path(filePath, base) {
303
+ const sf = scan_file(filePath);
304
+ let rel;
305
+ const baseResolved = path.resolve(base);
306
+ const fileResolved = path.resolve(filePath);
307
+ if (fileResolved === baseResolved || fileResolved.startsWith(baseResolved + path.sep)) {
308
+ rel = path.relative(baseResolved, fileResolved).split(path.sep).join("/");
309
+ } else {
310
+ rel = path.basename(filePath);
311
+ }
312
+ return new ScannedFile(
313
+ sf.path,
314
+ rel,
315
+ sf.lines,
316
+ sf.in_example_fence,
317
+ sf.in_any_fence,
318
+ sf.pragmas,
319
+ path_weight(rel),
320
+ sf.pragma_hashes
221
321
  );
222
322
  }
223
323
  function _rglobSorted(base) {
@@ -253,9 +353,9 @@ function _pathCmp(a, b) {
253
353
  if (pa.length > pb.length) return 1;
254
354
  return 0;
255
355
  }
256
- function* iter_corpus(roots = DEFAULT_SCAN_ROOTS, exts = [".md"]) {
356
+ function* iter_corpus(roots = DEFAULT_SCAN_ROOTS, exts = [".md"], scanBase = ROOT) {
257
357
  for (const root of roots) {
258
- const base = path.join(ROOT, root);
358
+ const base = path.join(scanBase, root);
259
359
  if (!fs.existsSync(base)) {
260
360
  continue;
261
361
  }
@@ -267,11 +367,27 @@ function* iter_corpus(roots = DEFAULT_SCAN_ROOTS, exts = [".md"]) {
267
367
  continue;
268
368
  }
269
369
  if (st.isFile() && exts.includes(path.extname(p))) {
270
- yield scan_file(p);
370
+ yield scan_path(p, scanBase);
271
371
  }
272
372
  }
273
373
  }
274
374
  }
375
+ var LEGACY_PRAGMA_CHECK = "legacy-pragma";
376
+ function legacy_pragma_finding(sf, check) {
377
+ return new Finding(
378
+ sf.rel,
379
+ 0,
380
+ LEGACY_PRAGMA_CHECK,
381
+ "LOW",
382
+ `unbound \`security-lint: allow ${check}\` pragma suppresses this whole file \u2014 it accepts whatever the matched text is later changed to say. Bind it with \`sha256:<hex>\` per accepted match.`,
383
+ sf.weight
384
+ );
385
+ }
386
+ var CHILD_SCANNED_PREFIX = "scanned: ";
387
+ function report_child_scanned(count) {
388
+ process.stderr.write(`${CHILD_SCANNED_PREFIX}${String(count)}
389
+ `);
390
+ }
275
391
  function report(findings, opts) {
276
392
  const check_label = opts.check_label;
277
393
  if (findings.length === 0) {
@@ -647,9 +763,11 @@ function _cpName(cp) {
647
763
  return n !== void 0 ? n : "<unnamed>";
648
764
  }
649
765
  function _scan(sf) {
650
- if (sf.pragma_allows(CHECK)) {
651
- return [];
766
+ const pragmaForm = sf.pragma_form(CHECK);
767
+ if (pragmaForm === "legacy") {
768
+ return [legacy_pragma_finding(sf, CHECK)];
652
769
  }
770
+ const finish = (hits) => pragmaForm === "bound" ? sf.filter_bound_pragma(CHECK, hits) : hits;
653
771
  const out = [];
654
772
  for (const [lineno, text] of sf.iter_lines({ skip_example_fence: true })) {
655
773
  let vs_run = 0;
@@ -687,7 +805,7 @@ function _scan(sf) {
687
805
  );
688
806
  }
689
807
  }
690
- return out;
808
+ return finish(out);
691
809
  }
692
810
  var _BINARY_EXT = /* @__PURE__ */ new Set([
693
811
  "png",
@@ -848,7 +966,7 @@ function _sanitize(filePath) {
848
966
  return out;
849
967
  }
850
968
  function _argError(msg) {
851
- process.stderr.write("usage: lint_hidden_unicode [-h] [--json] [--fix]\n");
969
+ process.stderr.write("usage: lint_hidden_unicode [-h] [--json] [--fix] [--root DIR]\n");
852
970
  process.stderr.write(`lint_hidden_unicode: error: ${msg}
853
971
  `);
854
972
  process.exit(2);
@@ -856,14 +974,27 @@ function _argError(msg) {
856
974
  function parse_args(argv) {
857
975
  const out = { json: false, fix: false };
858
976
  const extra = [];
977
+ let rootPending = false;
859
978
  for (const a of argv) {
979
+ if (rootPending) {
980
+ out.root = a;
981
+ rootPending = false;
982
+ continue;
983
+ }
860
984
  if (a === "-h" || a === "--help") {
861
- process.stdout.write("usage: lint_hidden_unicode [-h] [--json] [--fix]\n");
985
+ process.stdout.write("usage: lint_hidden_unicode [-h] [--json] [--fix] [--root DIR]\n");
862
986
  process.exit(0);
863
987
  } else if (a === "--json") {
864
988
  out.json = true;
865
989
  } else if (a === "--fix") {
866
990
  out.fix = true;
991
+ } else if (a === "--root" || a.startsWith("--root=")) {
992
+ const eq = a.indexOf("=");
993
+ if (eq !== -1) {
994
+ out.root = a.slice(eq + 1);
995
+ } else {
996
+ rootPending = true;
997
+ }
867
998
  } else {
868
999
  extra.push(a);
869
1000
  }
@@ -875,10 +1006,11 @@ function parse_args(argv) {
875
1006
  }
876
1007
  function main(argv = null) {
877
1008
  const args = parse_args(argv ?? process.argv.slice(2));
1009
+ const scanBase = args.root === void 0 ? ROOT : path2.resolve(args.root);
878
1010
  const findings = [];
879
1011
  const flagged = /* @__PURE__ */ new Set();
880
1012
  let corpusFiles = 0;
881
- for (const sf of iter_corpus()) {
1013
+ for (const sf of iter_corpus(DEFAULT_SCAN_ROOTS, [".md"], scanBase)) {
882
1014
  corpusFiles += 1;
883
1015
  const hits = _scan(sf);
884
1016
  for (const h of hits) {
@@ -903,7 +1035,7 @@ function main(argv = null) {
903
1035
  }
904
1036
  throw exc;
905
1037
  }
906
- const sourceFiles = _eligibleSourceFiles();
1038
+ const sourceFiles = args.root === void 0 ? _eligibleSourceFiles() : [];
907
1039
  for (const h of _scanSourceControlBytes(sourceFiles)) {
908
1040
  findings.push(h);
909
1041
  }
@@ -922,6 +1054,9 @@ function main(argv = null) {
922
1054
  `);
923
1055
  }
924
1056
  }
1057
+ if (args.json) {
1058
+ report_child_scanned(corpusFiles + (sourceFiles === null ? 0 : sourceFiles.length));
1059
+ }
925
1060
  if (args.json) {
926
1061
  const payload = py_json_dumps_indent2(findings.map((f) => f.toDict()));
927
1062
  process.stdout.write(payload + "\n");
@@ -2298,7 +2433,7 @@ function queryIndex(indexPath, keys, types) {
2298
2433
  }
2299
2434
 
2300
2435
  // src/scripts/learning_sidecar.ts
2301
- import { createHash } from "node:crypto";
2436
+ import { createHash as createHash2 } from "node:crypto";
2302
2437
  import * as fs6 from "node:fs";
2303
2438
  import * as path6 from "node:path";
2304
2439
  import process4 from "node:process";
@@ -2314,7 +2449,7 @@ function _parseTsMs(ts) {
2314
2449
  return Number.isNaN(t) ? null : t;
2315
2450
  }
2316
2451
  function _bodyHash(body) {
2317
- return createHash("sha256").update(body.trim().toLowerCase()).digest("hex").slice(0, 12);
2452
+ return createHash2("sha256").update(body.trim().toLowerCase()).digest("hex").slice(0, 12);
2318
2453
  }
2319
2454
  function _globSignalFiles(dir) {
2320
2455
  let names;