vigiles 7.0.0 → 8.0.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.
@@ -135,7 +135,7 @@ export declare function guidance(text: string): GuidanceRule;
135
135
  * Declare a reactive guard: runs a command when watched files change.
136
136
  *
137
137
  * guard({ watch: "*.spec.ts", run: "npx vigiles compile" }, "Recompile on spec change")
138
- * guard({ watch: ["eslint.config.*", "package.json"], run: "npx vigiles generate-types" }, "Regen types")
138
+ * guard({ watch: ["eslint.config.*", "package.json"], run: "npx vigiles generate types" }, "Regen types")
139
139
  */
140
140
  export declare function guard(options: {
141
141
  watch: string | readonly string[];
@@ -237,6 +237,9 @@ export declare function glob(pattern: string): GlobRef;
237
237
  * the region the unit is treated as read-only (the `"pure"` effective floor),
238
238
  * inside it the declared purity floor applies. The position-aware companion to
239
239
  * the per-call `purity` floor. See `research/effect-boundary-design.md`.
240
+ *
241
+ * @internal Experimental (parked P3) — NOT part of the frozen public surface;
242
+ * may change or be removed without a major bump pre-1.0.
240
243
  */
241
244
  export interface EffectRegion {
242
245
  readonly _ref: "effect";
@@ -269,6 +272,9 @@ export declare function instructions(strings: TemplateStringsArray, ...values: I
269
272
  * Returns an `EffectRegion` fragment; `compile` wraps its rendered body in
270
273
  * `<!-- vigiles:effect -->` markers. Independent of the `doc()` authoring
271
274
  * surface — it does not block on it.
275
+ *
276
+ * @internal Experimental (parked P3) — NOT part of the frozen public surface;
277
+ * may change or be removed without a major bump pre-1.0.
272
278
  */
273
279
  export declare function effect(strings: TemplateStringsArray, ...values: InstructionFragment[]): EffectRegion;
274
280
  /**
@@ -732,6 +738,9 @@ export declare function railway(spec: Omit<Railway, "_specType">): Railway;
732
738
  * Declared via `needs(...)` and threaded into the typed agent so `pipe` can
733
739
  * cross-reference it. Independent of `result()` (the output) — an agent both
734
740
  * `needs` an input shape and produces an `ok`/`err` output shape.
741
+ *
742
+ * @internal Experimental typed-composition surface — NOT part of the frozen
743
+ * public API (pre-1.0); may change without a major bump.
735
744
  */
736
745
  export type NeedsContract<N extends Shape> = N;
737
746
  /**
@@ -740,12 +749,18 @@ export type NeedsContract<N extends Shape> = N;
740
749
  * step with no upstream requirement — valid as the FIRST step of a pipeline.
741
750
  *
742
751
  * needs({ plan: "string", files: "string[]" })
752
+ *
753
+ * @internal Experimental typed-composition surface — NOT part of the frozen
754
+ * public API (pre-1.0); may change without a major bump.
743
755
  */
744
756
  export declare function needs<const N extends Shape>(shape: N): NeedsContract<N>;
745
757
  /**
746
758
  * A typed pipeline step: a `TypedAgentSpec` paired with the input `needs` it
747
759
  * reads from the prior step's `ok`. `step()` builds one; `pipe` checks that the
748
760
  * prior step's `ok` shape supplies this step's `needs`.
761
+ *
762
+ * @internal Experimental typed-composition surface — NOT part of the frozen
763
+ * public API (pre-1.0); may change without a major bump.
749
764
  */
750
765
  export interface PipeStep<Needs extends Shape, Ok extends Shape, Err extends Shape> {
751
766
  readonly _step: "typed-delegate";
@@ -758,6 +773,9 @@ export interface PipeStep<Needs extends Shape, Ok extends Shape, Err extends Sha
758
773
  * second is the `needs(...)` input contract.
759
774
  *
760
775
  * pipeStep(implementer, needs({ plan: "string", files: "string[]" }))
776
+ *
777
+ * @internal Experimental typed-composition surface — NOT part of the frozen
778
+ * public API (pre-1.0); may change without a major bump.
761
779
  */
762
780
  export declare function pipeStep<Needs extends Shape, Ok extends Shape, Err extends Shape>(a: TypedAgentSpec<Ok, Err>, needsContract?: Needs): PipeStep<Needs, Ok, Err>;
763
781
  /**
@@ -766,6 +784,9 @@ export declare function pipeStep<Needs extends Shape, Ok extends Shape, Err exte
766
784
  * descriptive error object naming the offending field (`__missing` /
767
785
  * `__mismatch`), which surfaces at the mismatched call. Shallow (a per-field
768
786
  * mapped type, not a recursion) to avoid TS2589.
787
+ *
788
+ * @internal Experimental typed-composition surface — NOT part of the frozen
789
+ * public API (pre-1.0); may change without a major bump.
769
790
  */
770
791
  export type Supplies<Producer extends Shape, Consumer extends Shape> = {
771
792
  [K in keyof Consumer]: K extends keyof Producer ? Producer[K] extends Consumer[K] ? true : {
@@ -788,12 +809,17 @@ export type Supplies<Producer extends Shape, Consumer extends Shape> = {
788
809
  * assigning `true` to it is a `tsc` error at edit time. Shallow (one wrap over
789
810
  * the per-field `Supplies` mapped type, no recursion); the generator emits one
790
811
  * assertion per consecutive step pair (O(N)), keeping clear of TS2589.
812
+ *
813
+ * @internal Experimental typed-composition surface — NOT part of the frozen
814
+ * public API (pre-1.0); may change without a major bump.
791
815
  */
792
816
  export type Handoff<Producer extends Shape, Consumer extends Shape> = Supplies<Producer, Consumer> extends true ? true : {
793
817
  readonly __handoff_error: Supplies<Producer, Consumer>;
794
818
  };
795
819
  /** A typed pipeline value — carries the LAST step's `ok` and the UNION of every
796
- * step's `err` (any step can short-circuit to the error track). */
820
+ * step's `err` (any step can short-circuit to the error track).
821
+ * @internal Experimental typed-composition surface — NOT part of the frozen
822
+ * public API (pre-1.0); may change without a major bump. */
797
823
  export interface Pipeline<Ok extends Shape, Err extends Shape> {
798
824
  readonly _specType: "pipeline";
799
825
  /** Ordered agent names — the resolved compose order. */
@@ -809,6 +835,9 @@ export interface Pipeline<Ok extends Shape, Err extends Shape> {
809
835
  * Begin a typed pipeline from its first step. The first step has no upstream, so
810
836
  * its `needs` must be empty (`needs({})` or omitted). Returns a `Pipeline`
811
837
  * carrying that step's `ok`/`err` forward.
838
+ *
839
+ * @internal Experimental typed-composition surface — NOT part of the frozen
840
+ * public API (pre-1.0); may change without a major bump.
812
841
  */
813
842
  export declare function start<Ok extends Shape, Err extends Shape>(first: PipeStep<Record<string, never>, Ok, Err> | TypedAgentSpec<Ok, Err>): Pipeline<Ok, Err>;
814
843
  /**
@@ -821,6 +850,9 @@ export declare function start<Ok extends Shape, Err extends Shape>(first: PipeSt
821
850
  * Named `andThen` (Wlaschin's railway `bind`/`andThen`), NOT `then`: a module
822
851
  * exporting a function called `then` becomes a thenable, so `await import()` of
823
852
  * any barrel re-exporting it would invoke it — a footgun the rename avoids.
853
+ *
854
+ * @internal Experimental typed-composition surface — NOT part of the frozen
855
+ * public API (pre-1.0); may change without a major bump.
824
856
  */
825
857
  export declare function andThen<PriorOk extends Shape, PriorErr extends Shape, Needs extends Shape, Ok extends Shape, Err extends Shape>(prior: Pipeline<PriorOk, PriorErr>, next: Supplies<PriorOk, Needs> extends true ? PipeStep<Needs, Ok, Err> : {
826
858
  readonly __HANDOFF_ERROR: Supplies<PriorOk, Needs>;
@@ -841,6 +873,9 @@ export declare function andThen<PriorOk extends Shape, PriorErr extends Shape, N
841
873
  * pipeStep(implementer, needs({ plan: "string", files: "string[]" })),
842
874
  * pipeStep(reviewer, needs({ diff: "string" })),
843
875
  * ) // ← won't compile if a handoff doesn't line up
876
+ *
877
+ * @internal Experimental typed-composition surface — NOT part of the frozen
878
+ * public API (pre-1.0); may change without a major bump.
844
879
  */
845
880
  export declare function pipe<A extends Shape, AE extends Shape>(a: TypedAgentSpec<A, AE>): Pipeline<A, AE>;
846
881
  export declare function pipe<A extends Shape, AE extends Shape, BN extends Shape, B extends Shape, BE extends Shape>(a: TypedAgentSpec<A, AE>, b: Supplies<A, BN> extends true ? PipeStep<BN, B, BE> : {
@@ -866,6 +901,9 @@ export declare function pipe<A extends Shape, AE extends Shape, BN extends Shape
866
901
  * object naming the dangling target + the railway it came from — so assigning
867
902
  * `true` to it is a `tsc` error at edit time. Shallow (one conditional, no
868
903
  * recursion); the generator emits one assertion per edge (O(N)).
904
+ *
905
+ * @internal Experimental whole-harness-codegen surface — NOT part of the frozen
906
+ * public API (pre-1.0); may change without a major bump.
869
907
  */
870
908
  export type KnownAgentName<Target extends string, Names extends string, From extends string = string> = [Target] extends [Names] ? true : {
871
909
  readonly __dangling_delegate: Target;
package/dist/core/spec.js CHANGED
@@ -73,7 +73,7 @@ function guidance(text) {
73
73
  * Declare a reactive guard: runs a command when watched files change.
74
74
  *
75
75
  * guard({ watch: "*.spec.ts", run: "npx vigiles compile" }, "Recompile on spec change")
76
- * guard({ watch: ["eslint.config.*", "package.json"], run: "npx vigiles generate-types" }, "Regen types")
76
+ * guard({ watch: ["eslint.config.*", "package.json"], run: "npx vigiles generate types" }, "Regen types")
77
77
  */
78
78
  function guard(options, description) {
79
79
  return {
@@ -166,6 +166,9 @@ function instructions(strings, ...values) {
166
166
  * Returns an `EffectRegion` fragment; `compile` wraps its rendered body in
167
167
  * `<!-- vigiles:effect -->` markers. Independent of the `doc()` authoring
168
168
  * surface — it does not block on it.
169
+ *
170
+ * @internal Experimental (parked P3) — NOT part of the frozen public surface;
171
+ * may change or be removed without a major bump pre-1.0.
169
172
  */
170
173
  function effect(strings, ...values) {
171
174
  const body = [];
@@ -304,6 +307,9 @@ function railway(spec) {
304
307
  * step with no upstream requirement — valid as the FIRST step of a pipeline.
305
308
  *
306
309
  * needs({ plan: "string", files: "string[]" })
310
+ *
311
+ * @internal Experimental typed-composition surface — NOT part of the frozen
312
+ * public API (pre-1.0); may change without a major bump.
307
313
  */
308
314
  function needs(shape) {
309
315
  return shape;
@@ -314,6 +320,9 @@ function needs(shape) {
314
320
  * second is the `needs(...)` input contract.
315
321
  *
316
322
  * pipeStep(implementer, needs({ plan: "string", files: "string[]" }))
323
+ *
324
+ * @internal Experimental typed-composition surface — NOT part of the frozen
325
+ * public API (pre-1.0); may change without a major bump.
317
326
  */
318
327
  function pipeStep(a, needsContract = {}) {
319
328
  return { _step: "typed-delegate", agent: a, needs: needsContract };
@@ -322,6 +331,9 @@ function pipeStep(a, needsContract = {}) {
322
331
  * Begin a typed pipeline from its first step. The first step has no upstream, so
323
332
  * its `needs` must be empty (`needs({})` or omitted). Returns a `Pipeline`
324
333
  * carrying that step's `ok`/`err` forward.
334
+ *
335
+ * @internal Experimental typed-composition surface — NOT part of the frozen
336
+ * public API (pre-1.0); may change without a major bump.
325
337
  */
326
338
  function start(first) {
327
339
  const step = "_step" in first ? first : pipeStep(first, {});
@@ -347,6 +359,9 @@ function start(first) {
347
359
  * Named `andThen` (Wlaschin's railway `bind`/`andThen`), NOT `then`: a module
348
360
  * exporting a function called `then` becomes a thenable, so `await import()` of
349
361
  * any barrel re-exporting it would invoke it — a footgun the rename avoids.
362
+ *
363
+ * @internal Experimental typed-composition surface — NOT part of the frozen
364
+ * public API (pre-1.0); may change without a major bump.
350
365
  */
351
366
  function andThen(prior, next) {
352
367
  const real = next;
@@ -82,12 +82,23 @@ export interface TestCoverageConfig {
82
82
  exclude?: readonly string[];
83
83
  }
84
84
  export interface RulesConfig {
85
- /** Require .spec.ts for CLAUDE.md / AGENTS.md. Default: "warn". */
86
- "require-spec"?: RuleSeverity;
87
85
  /**
88
- * @deprecated Skills are legitimately hand-written; use `untested-skill`
89
- * ("every skill ships with a test/eval") instead. Default: false (off). The
90
- * check still runs if you set this explicitly.
86
+ * Require a `.spec.ts` behind each instruction file (CLAUDE.md / AGENTS.md) —
87
+ * the file must be compiled from a typed spec, not hand-written. NARROW: only a
88
+ * `.spec.ts` sibling (or an explicit `<!-- vigiles-disable
89
+ * require-instructions-spec -->` marker) satisfies it; inline
90
+ * `<!-- vigiles:enforce -->` comments do NOT (the rule name says "spec"). Default:
91
+ * "warn". `vigiles init` auto-adopts every instruction file into a spec, so this
92
+ * is GREEN by construction after setup — a safety net for a NEW hand-added file,
93
+ * not a nag. The workflow-tier opt-in (gated under `--strict`).
94
+ */
95
+ "require-instructions-spec"?: RuleSeverity;
96
+ /**
97
+ * Require a `.spec.ts` behind each SKILL.md — the consistent
98
+ * `require-<surface>-spec` parallel to `require-instructions-spec`. Default:
99
+ * false (OFF): skills are legitimately hand-written, and the coverage that
100
+ * matters ("every skill ships with a test/eval") is the `untested-skill` rule.
101
+ * Set it explicitly if your team wants every skill spec-managed.
91
102
  */
92
103
  "require-skill-spec"?: RuleSeverity;
93
104
  /** Detect hand-edits to compiled markdown via SHA-256 hash. Default: "warn". */
@@ -161,6 +172,18 @@ export interface RulesConfig {
161
172
  * "warn"; "error" gates CI. Same detector as `scan` (hooks status "missing").
162
173
  */
163
174
  "hook-script-exists"?: RuleSeverity;
175
+ /**
176
+ * A single repo-level RECOMMENDATION (one finding regardless of hook count):
177
+ * when a plugin/repo ships hand-written hook commands that aren't compiled
178
+ * `vigiles/hook` artifacts, nudge toward compiled hooks — they make whole hook
179
+ * bug classes (exit-1-not-2, wrong decision field, matcher bypass) UNREPRESENTABLE
180
+ * at authoring time, and `guardrail-check` proves an existing one blocks. A
181
+ * discovery nudge, not a defect: the hand-written shell lane stays first-class,
182
+ * so it's opt-out and fires ONCE (never per-hook). The message links
183
+ * `docs/compiled-hooks.md`. Default "warn"; set "off" to silence or "error" to
184
+ * enforce. Same detector as `scan` (manualHookCount).
185
+ */
186
+ "prefer-compiled-hooks"?: RuleSeverity;
164
187
  /**
165
188
  * Cross-reference a subagent's `disallowedTools:` block-list against the
166
189
  * catalog — the deny-side mirror of `subagent-tool-contract`. A close typo there
@@ -226,7 +249,8 @@ export interface VigilesConfig {
226
249
  * (tsconfig-style, relative to the repo root). Use it for vendored or
227
250
  * benchmark fixtures the repo's own lint shouldn't police — e.g.
228
251
  * `["bench/**"]` so a third-party `CLAUDE.md` injected verbatim as a benchmark
229
- * arm isn't held to `require-spec`. `node_modules`/`dist` are always excluded.
252
+ * arm isn't held to `require-instructions-spec`. `node_modules`/`dist` are always
253
+ * excluded.
230
254
  */
231
255
  exclude?: readonly string[];
232
256
  /**
@@ -11,8 +11,6 @@ const node_fs_1 = require("node:fs");
11
11
  const glob_1 = require("glob");
12
12
  const node_path_1 = require("node:path");
13
13
  const cosmiconfig_1 = require("cosmiconfig");
14
- const inline_js_1 = require("./inline.js");
15
- const frontmatter_js_1 = require("./frontmatter.js");
16
14
  // ---------------------------------------------------------------------------
17
15
  // Constants & regex
18
16
  // ---------------------------------------------------------------------------
@@ -31,13 +29,13 @@ const INSTRUCTION_FILES = ["CLAUDE.md", "AGENTS.md"];
31
29
  // The default instruction file to validate when no config names one.
32
30
  const DEFAULT_FILES = [INSTRUCTION_FILES[0]];
33
31
  const DEFAULT_RULES = {
34
- "require-spec": "warn",
35
- // DEPRECATEDdefault OFF. Skills are legitimately hand-written (Level 0/1),
36
- // so requiring a .spec.ts per SKILL.md was the wrong constraint and only added
37
- // noise (it also nagged about vendored/fixture/bench skills). Use the
38
- // `untested-*` rules instead — "every skill/agent/hook ships with a test or
39
- // eval" is the coverage that matters. The implementation is kept: setting
40
- // `require-skill-spec` explicitly still works for anyone who wants it.
32
+ "require-instructions-spec": "warn",
33
+ // Default OFF the consistent `require-<surface>-spec` parallel. Skills are
34
+ // legitimately hand-written, so requiring a .spec.ts per SKILL.md is the wrong
35
+ // default (it would nag about vendored/fixture/bench skills); the coverage that
36
+ // matters is the `untested-*` rules ("every skill/agent/hook ships with a test
37
+ // or eval"). Set `require-skill-spec` explicitly if your team wants every skill
38
+ // spec-managed.
41
39
  "require-skill-spec": false,
42
40
  integrity: "warn",
43
41
  coverage: false,
@@ -60,6 +58,10 @@ const DEFAULT_RULES = {
60
58
  "mcp-tool-resolves": "warn",
61
59
  // A hook script referenced but missing never runs — on by default at warn.
62
60
  "hook-script-exists": "warn",
61
+ // Discovery nudge toward compiled hooks (one finding) — default OFF: it's a
62
+ // recommendation, not a defect (the hand-written shell lane stays first-class),
63
+ // so it shouldn't fire unasked. Set "warn"/"error" to opt in.
64
+ "prefer-compiled-hooks": false,
63
65
  // High-precision (close-typo only) deny-list mirror of subagent-tool-contract.
64
66
  "disallowed-tools-contract": "warn",
65
67
  // Deterministic NCD precision proxy (near-identical skill descriptions) — warn.
@@ -176,26 +178,25 @@ function validate(content, { ruleMarkers, rules: rulesConfig, filePath, dialect
176
178
  const missingCount = parsedRules.filter((r) => r.enforcement === "missing").length;
177
179
  const errors = [];
178
180
  const warnings = [];
179
- const disableComment = /<!--\s*vigiles-disable\s+require-spec\s*-->/;
181
+ const disableComment = /<!--\s*vigiles-disable\s+require-instructions-spec\s*-->/;
180
182
  if (filePath) {
181
183
  const basename = (0, node_path_1.basename)(filePath);
182
184
  const recognized = dialect?.instructionTargets ?? INSTRUCTION_FILES;
183
185
  const isInstruction = recognized.includes(basename);
184
186
  const isSkill = basename === "SKILL.md";
185
- // --- require-spec (CLAUDE.md / AGENTS.md) ---
186
- const specSeverity = activeRules["require-spec"];
187
+ // --- require-instructions-spec (CLAUDE.md / AGENTS.md) ---
188
+ // NARROW: only a `.spec.ts` sibling satisfies it. The rule name says "spec",
189
+ // so inline `<!-- vigiles:enforce -->` / `vigiles:` frontmatter do NOT count
190
+ // (a user on inline mode keeps this rule off — it's a workflow-tier opt-in).
191
+ // `vigiles init` auto-adopts every instruction file into a spec, so this is
192
+ // green by construction after setup.
193
+ const specSeverity = activeRules["require-instructions-spec"];
187
194
  if (specSeverity && isInstruction && !disableComment.test(content)) {
188
195
  const specPath = filePath + ".spec.ts";
189
- // Inline mode counts as a spec — any parseable
190
- // `<!-- vigiles:enforce ... -->` comment means the file is
191
- // verified on `vigiles lint` even without a .spec.ts sibling.
192
- // Delegate to the real parser so a malformed marker can't
193
- // satisfy require-spec with a rule that lint can't verify.
194
- const hasInline = (0, inline_js_1.hasInlineRules)(content) || (0, frontmatter_js_1.hasFrontmatterRules)(content);
195
- if (!(0, node_fs_1.existsSync)(specPath) && !hasInline) {
196
+ if (!(0, node_fs_1.existsSync)(specPath)) {
196
197
  const msg = {
197
- rule: "require-spec",
198
- message: `No spec file found for "${filePath}". Expected "${specPath}". Run \`npx vigiles init --target=${filePath}\` to create one, add inline \`<!-- vigiles:enforce ... -->\` comments or a \`vigiles:\` frontmatter block, or disable with <!-- vigiles-disable require-spec -->.`,
198
+ rule: "require-instructions-spec",
199
+ message: `No spec file found for "${filePath}". Expected "${specPath}". Run \`npx vigiles init --target=${filePath}\` to adopt it into a spec, or disable with <!-- vigiles-disable require-instructions-spec -->.`,
199
200
  line: 1,
200
201
  };
201
202
  if (specSeverity === "error") {
@@ -206,9 +207,8 @@ function validate(content, { ruleMarkers, rules: rulesConfig, filePath, dialect
206
207
  }
207
208
  }
208
209
  }
209
- // --- require-skill-spec (SKILL.md) — DEPRECATED but still honored when a
210
- // user sets it explicitly, so reading the deprecated key here is intentional.
211
- // eslint-disable-next-line @typescript-eslint/no-deprecated
210
+ // --- require-skill-spec (SKILL.md) — the consistent require-<surface>-spec
211
+ // parallel, off by default; honored when a user sets it explicitly.
212
212
  const skillSeverity = activeRules["require-skill-spec"];
213
213
  if (skillSeverity && isSkill && !disableComment.test(content)) {
214
214
  const specPath = filePath + ".spec.ts";
@@ -302,7 +302,7 @@ function validatePaths(paths, { followSymlinks = false, ruleMarkers, rules: rule
302
302
  let allValid = true;
303
303
  // Maps a real (symlink-resolved) path → the first path validated for it, so a
304
304
  // symlinked/synced CLAUDE.md⇄AGENTS.md mirror is validated ONCE on the real
305
- // file instead of double-firing require-spec on the mirror's name (sync-tool-
305
+ // file instead of double-firing require-instructions-spec on the mirror's name (sync-tool-
306
306
  // compatibility.md req 7). Recorded only on a successful validation, so a
307
307
  // symlink seen first (and skipped) never shadows its real target.
308
308
  const seenReal = new Map();
@@ -338,7 +338,7 @@ function validatePaths(paths, { followSymlinks = false, ruleMarkers, rules: rule
338
338
  allValid = false;
339
339
  continue;
340
340
  }
341
- // Attribute require-spec/integrity to the REAL file when this path is a
341
+ // Attribute require-instructions-spec/integrity to the REAL file when this path is a
342
342
  // symlink, so a symlinked AGENTS.md resolves to CLAUDE.md's spec rather than
343
343
  // a nonexistent AGENTS.md.spec.ts. Non-symlinks keep the original path
344
344
  // verbatim (behaviour-preserving).
@@ -75,7 +75,7 @@ export declare function unblockedDisasters(results: readonly GuardrailResult[]):
75
75
  */
76
76
  export declare function assertBlocksDisasters(hookCommand: string, opts?: VerifyGuardrailOptions): void;
77
77
  /**
78
- * Render a coverage report (Level 0 — informational, NEUTRAL). It reports what the
78
+ * Render a coverage report (informational, NEUTRAL). It reports what the
79
79
  * hook blocks WITHOUT judging it: a hook that allows these may simply not be a
80
80
  * bash-safety guard (our own pre-edit.sh blocks .md edits, not `rm -rf`). The
81
81
  * "false confidence" verdict only applies once intent is DECLARED — see
@@ -131,7 +131,7 @@ function assertBlocksDisasters(hookCommand, opts = {}) {
131
131
  throw new Error(`Guardrail \`${hookCommand}\` did NOT block ${misses.length} dangerous action(s):\n${lines.join("\n")}\nA hook that doesn't block these is false confidence — fix it (PreToolUse + exit 2).`);
132
132
  }
133
133
  /**
134
- * Render a coverage report (Level 0 — informational, NEUTRAL). It reports what the
134
+ * Render a coverage report (informational, NEUTRAL). It reports what the
135
135
  * hook blocks WITHOUT judging it: a hook that allows these may simply not be a
136
136
  * bash-safety guard (our own pre-edit.sh blocks .md edits, not `rm -rf`). The
137
137
  * "false confidence" verdict only applies once intent is DECLARED — see
@@ -0,0 +1,54 @@
1
+ /**
2
+ * scan → trigger-tier nudge. When a plugin ships model-invocable skills AND a
3
+ * real model is reachable, surface the (real-model) `scan --trigger` tier that
4
+ * measures whether those skills actually FIRE (recall + precision). Pure
5
+ * decision + helpers; the IO (prompt / scaffold write / running the measure)
6
+ * lives in the CLI. Honors `great-agent-flow`: an agent (non-TTY / `--json` /
7
+ * `--no-interactive`) is HINTED, never prompted — a `scan` must never hang.
8
+ */
9
+ /** Only the env vars that signal a reachable model (parse, don't validate). */
10
+ export interface ModelEnv {
11
+ readonly ANTHROPIC_API_KEY?: string;
12
+ readonly CLAUDECODE?: string;
13
+ readonly CLAUDE_CODE_ENTRYPOINT?: string;
14
+ }
15
+ /**
16
+ * Is a real model reachable for the eval / trigger tier? Either a metered API
17
+ * key (`ANTHROPIC_API_KEY`), OR an authenticated Claude Code session
18
+ * (`CLAUDECODE=1` / `CLAUDE_CODE_ENTRYPOINT`, web/desktop/CLI) — the latter
19
+ * drives the `claude` CLI on the user's subscription, no key needed. Keeping
20
+ * this a tiny, env-only predicate (not a live probe) means it never spends a
21
+ * token just to decide whether to suggest spending one.
22
+ */
23
+ export declare function hasModelAccess(env: ModelEnv): boolean;
24
+ export type TriggerSuggestion = "prompt" | "hint" | "none";
25
+ export interface SuggestOpts {
26
+ /** A real model is reachable (`hasModelAccess`). */
27
+ readonly modelAccess: boolean;
28
+ /** stdout is an interactive terminal (a human is watching). */
29
+ readonly isTTY: boolean;
30
+ /** Count of model-invocable, described skills worth measuring. */
31
+ readonly triggerableSkills: number;
32
+ /** `--json` — machine output; never decorate or prompt. */
33
+ readonly json: boolean;
34
+ /** `--no-interactive` — explicit agent/CI mode; hint, never prompt. */
35
+ readonly noInteractive: boolean;
36
+ }
37
+ /**
38
+ * Decide how `scan` surfaces the trigger tier after its report:
39
+ * - `"none"` — no model-invocable skills, no model access, or `--json`.
40
+ * - `"hint"` — model access + skills but non-interactive (agent / CI / non-TTY
41
+ * / `--no-interactive`): a one-line, non-blocking hint.
42
+ * - `"prompt"` — model access + skills + a human at a TTY: offer to set it up.
43
+ */
44
+ export declare function decideTriggerSuggestion(o: SuggestOpts): TriggerSuggestion;
45
+ /** The one-line, non-blocking hint (the agent/CI surface). */
46
+ export declare function formatTriggerHint(dir: string, triggerableSkills: number): string;
47
+ /**
48
+ * A starter `--prompts` file (the real `TriggerPromptSet` shape: bare skill name
49
+ * → `{ prompts, irrelevant }`). One entry per triggerable skill, with TODO
50
+ * placeholders the user replaces with real requests. Deterministic; written
51
+ * only on an explicit human "yes" so a plain `scan` never spends a token.
52
+ */
53
+ export declare function scaffoldTriggerPrompts(skillNames: readonly string[]): string;
54
+ //# sourceMappingURL=scan-trigger-suggest.d.ts.map
@@ -0,0 +1,70 @@
1
+ "use strict";
2
+ /**
3
+ * scan → trigger-tier nudge. When a plugin ships model-invocable skills AND a
4
+ * real model is reachable, surface the (real-model) `scan --trigger` tier that
5
+ * measures whether those skills actually FIRE (recall + precision). Pure
6
+ * decision + helpers; the IO (prompt / scaffold write / running the measure)
7
+ * lives in the CLI. Honors `great-agent-flow`: an agent (non-TTY / `--json` /
8
+ * `--no-interactive`) is HINTED, never prompted — a `scan` must never hang.
9
+ */
10
+ Object.defineProperty(exports, "__esModule", { value: true });
11
+ exports.hasModelAccess = hasModelAccess;
12
+ exports.decideTriggerSuggestion = decideTriggerSuggestion;
13
+ exports.formatTriggerHint = formatTriggerHint;
14
+ exports.scaffoldTriggerPrompts = scaffoldTriggerPrompts;
15
+ /**
16
+ * Is a real model reachable for the eval / trigger tier? Either a metered API
17
+ * key (`ANTHROPIC_API_KEY`), OR an authenticated Claude Code session
18
+ * (`CLAUDECODE=1` / `CLAUDE_CODE_ENTRYPOINT`, web/desktop/CLI) — the latter
19
+ * drives the `claude` CLI on the user's subscription, no key needed. Keeping
20
+ * this a tiny, env-only predicate (not a live probe) means it never spends a
21
+ * token just to decide whether to suggest spending one.
22
+ */
23
+ function hasModelAccess(env) {
24
+ return Boolean(env.ANTHROPIC_API_KEY ||
25
+ env.CLAUDECODE === "1" ||
26
+ env.CLAUDE_CODE_ENTRYPOINT);
27
+ }
28
+ /**
29
+ * Decide how `scan` surfaces the trigger tier after its report:
30
+ * - `"none"` — no model-invocable skills, no model access, or `--json`.
31
+ * - `"hint"` — model access + skills but non-interactive (agent / CI / non-TTY
32
+ * / `--no-interactive`): a one-line, non-blocking hint.
33
+ * - `"prompt"` — model access + skills + a human at a TTY: offer to set it up.
34
+ */
35
+ function decideTriggerSuggestion(o) {
36
+ if (o.json || o.triggerableSkills < 1 || !o.modelAccess)
37
+ return "none";
38
+ if (o.noInteractive || !o.isTTY)
39
+ return "hint";
40
+ return "prompt";
41
+ }
42
+ /** The one-line, non-blocking hint (the agent/CI surface). */
43
+ function formatTriggerHint(dir, triggerableSkills) {
44
+ const n = triggerableSkills;
45
+ return (`ℹ ${String(n)} model-invocable skill${n === 1 ? "" : "s"} + model access detected — ` +
46
+ `measure whether they actually FIRE (recall + precision) with:\n` +
47
+ ` vigiles scan ${dir} --trigger --prompts=trigger-prompts.json`);
48
+ }
49
+ /**
50
+ * A starter `--prompts` file (the real `TriggerPromptSet` shape: bare skill name
51
+ * → `{ prompts, irrelevant }`). One entry per triggerable skill, with TODO
52
+ * placeholders the user replaces with real requests. Deterministic; written
53
+ * only on an explicit human "yes" so a plain `scan` never spends a token.
54
+ */
55
+ function scaffoldTriggerPrompts(skillNames) {
56
+ const obj = {};
57
+ for (const name of skillNames) {
58
+ obj[name] = {
59
+ prompts: [
60
+ `TODO: a request that SHOULD trigger "${name}"`,
61
+ `TODO: a differently-phrased request that should also trigger it`,
62
+ ],
63
+ irrelevant: [
64
+ `TODO: an unrelated request that should NOT trigger "${name}"`,
65
+ ],
66
+ };
67
+ }
68
+ return JSON.stringify(obj, null, 2) + "\n";
69
+ }
70
+ //# sourceMappingURL=scan-trigger-suggest.js.map
package/dist/scan.d.ts CHANGED
@@ -94,7 +94,7 @@ export interface ScanHook {
94
94
  * Every cc/codex repo has one even when it ships no plugin surface, so `scan`
95
95
  * reports it — otherwise a plain instruction-only repo looks empty. `hasSpec` is
96
96
  * the deterministic fact that a `<file>.spec.ts` sits beside it (spec-managed vs
97
- * hand-written); it is informational, NOT the `require-spec` gate (that's lint).
97
+ * hand-written); it is informational, NOT the `require-instructions-spec` gate (that's lint).
98
98
  */
99
99
  export interface ScanInstructions {
100
100
  readonly file: string;
@@ -109,6 +109,13 @@ export interface ScanReport {
109
109
  readonly hooks: readonly ScanHook[];
110
110
  /** Hook entries with no script file (inline shell one-liners) — can't be path-checked. */
111
111
  readonly inlineHooks: number;
112
+ /**
113
+ * Hand-written hook commands that are NOT compiled `vigiles/hook` artifacts (a
114
+ * compiled hook's command invokes `vigiles hook-runtime run-program`). The basis
115
+ * for the `prefer-compiled-hooks` recommendation — a single nudge regardless of
116
+ * count. Zero when there are no hooks or every hook is vigiles-managed.
117
+ */
118
+ readonly manualHookCount: number;
112
119
  readonly commands: number;
113
120
  readonly mcp: boolean;
114
121
  /**
@@ -175,6 +182,15 @@ export interface SurfaceClassifier {
175
182
  * no drift). The ≥20% guard avoids a near-empty string tripping on one letter.
176
183
  */
177
184
  export declare function unexpectedScript(text: string, expected?: Script): Script | null;
185
+ /**
186
+ * A compiled `vigiles/hook` artifact runs through the `hook-runtime run-program`
187
+ * runtime entrypoint; any other hook command is hand-written (a shell script or
188
+ * an inline one-liner) the author maintains directly. The basis for the
189
+ * `prefer-compiled-hooks` nudge.
190
+ */
191
+ export declare function isManagedHookCommand(command: string): boolean;
192
+ /** The `prefer-compiled-hooks` recommendation message (shared by `lint` + `scan`). */
193
+ export declare function preferCompiledHooksMessage(count: number): string;
178
194
  /** Scan a plugin/repo directory and report its surfaces + structural issues. */
179
195
  export declare function scanPlugin(dir: string, layout?: PluginLayout, dialect?: HarnessDialect): ScanReport;
180
196
  /**
package/dist/scan.js CHANGED
@@ -14,6 +14,8 @@
14
14
  */
15
15
  Object.defineProperty(exports, "__esModule", { value: true });
16
16
  exports.unexpectedScript = unexpectedScript;
17
+ exports.isManagedHookCommand = isManagedHookCommand;
18
+ exports.preferCompiledHooksMessage = preferCompiledHooksMessage;
17
19
  exports.scanPlugin = scanPlugin;
18
20
  exports.verifyLiveMcpTools = verifyLiveMcpTools;
19
21
  exports.formatMcpContractReport = formatMcpContractReport;
@@ -265,10 +267,32 @@ function resolveScript(token, root, pluginRootToken) {
265
267
  // target is INTENTIONAL, not a broken reference. Don't flag scripts in such a
266
268
  // command as MISSING (a false positive caught on gmickel/flow-next's ralph-guard).
267
269
  const EXISTENCE_GUARD = /(?:\[\[?\s*!?\s*-[efsx]\s)|(?:\btest\s+!?\s*-[efsx]\s)/;
270
+ /**
271
+ * A compiled `vigiles/hook` artifact runs through the `hook-runtime run-program`
272
+ * runtime entrypoint; any other hook command is hand-written (a shell script or
273
+ * an inline one-liner) the author maintains directly. The basis for the
274
+ * `prefer-compiled-hooks` nudge.
275
+ */
276
+ function isManagedHookCommand(command) {
277
+ return /\bhook-runtime\b/.test(command);
278
+ }
279
+ /** The `prefer-compiled-hooks` recommendation message (shared by `lint` + `scan`). */
280
+ function preferCompiledHooksMessage(count) {
281
+ return (`${String(count)} hand-written hook command(s) — if any gate the agent ` +
282
+ `(a block/deny decision), compiled hooks (\`vigiles/hook\`) make whole hook ` +
283
+ `bug classes unrepresentable at authoring time, and \`guardrail-check\` proves ` +
284
+ `an existing one blocks. See docs/compiled-hooks.md.`);
285
+ }
268
286
  /** Pull script-file hook commands out of the resolved settings; count inline ones. */
269
287
  function scanHooks(settings, root, pluginRootToken) {
270
288
  const text = JSON.stringify(settings.hooks ?? {});
271
289
  const commands = [...text.matchAll(/"command":\s*"((?:[^"\\]|\\.)*)"/g)].map((m) => m[1]);
290
+ // A hand-written hook is any non-empty command that isn't a vigiles-managed
291
+ // (compiled) hook-runtime invocation — the basis for the prefer-compiled-hooks nudge.
292
+ const manual = commands.filter((c) => {
293
+ const u = c.replace(/\\(.)/g, "$1").trim();
294
+ return u !== "" && !isManagedHookCommand(u);
295
+ }).length;
272
296
  const byScript = new Map();
273
297
  let inline = 0;
274
298
  for (const cmd of commands) {
@@ -290,7 +314,7 @@ function scanHooks(settings, root, pluginRootToken) {
290
314
  }
291
315
  }
292
316
  const hooks = [...byScript.values()].sort((a, b) => a.script.localeCompare(b.script));
293
- return { hooks, inline };
317
+ return { hooks, inline, manual };
294
318
  }
295
319
  // ---------------------------------------------------------------------------
296
320
  // Public API
@@ -487,7 +511,7 @@ function scanPlugin(dir, layout, dialect = dialect_js_1.claudeCodeDialect) {
487
511
  const lay = layout ?? layout_js_1.claudeCodeLayout;
488
512
  const cls = makeClassifier(lay);
489
513
  const loaded = (0, plugin_loader_js_1.loadPlugin)(dir, lay);
490
- const { hooks, inline } = scanHooks(loaded.settings, (0, node_path_1.resolve)(dir), lay.pluginRootToken);
514
+ const { hooks, inline, manual } = scanHooks(loaded.settings, (0, node_path_1.resolve)(dir), lay.pluginRootToken);
491
515
  // Hook-event keys are a CLOSED platform set — an unrecognized one is a dead
492
516
  // registration (the hook never fires), so flag every unknown (not just typos).
493
517
  // ONLY for the canonical object-keyed-by-event shape: a plugin shipping a
@@ -521,6 +545,7 @@ function scanPlugin(dir, layout, dialect = dialect_js_1.claudeCodeDialect) {
521
545
  agents,
522
546
  hooks,
523
547
  inlineHooks: inline,
548
+ manualHookCount: manual,
524
549
  commands: Object.keys(loaded.files).filter(cls.isCommand).length,
525
550
  mcp: loaded.warnings.some((w) => w.includes("MCP server")),
526
551
  danglingRefs: (0, plugin_loader_js_2.danglingRefs)((0, node_path_1.resolve)(dir), lay),
@@ -749,6 +774,11 @@ function formatScanReport(r) {
749
774
  if (r.skillMetaIssues.length > 0) {
750
775
  out.push(`ℹ ${String(r.skillMetaIssues.length)} skill(s) lack an explicit frontmatter name/description (recommended for a reliable trigger surface) — they still load via fallback`, "");
751
776
  }
777
+ // One discovery nudge toward compiled hooks (never per-hook); the hand-written
778
+ // shell lane stays first-class, so this is a recommendation, not a defect.
779
+ if (r.manualHookCount > 0) {
780
+ out.push(`ℹ ${preferCompiledHooksMessage(r.manualHookCount)}`, "");
781
+ }
752
782
  // Malformed-YAML frontmatter is INFORMATIONAL, not a structural defect: js-yaml
753
783
  // is stricter than some loaders (a colon/quote/<example> in a one-line
754
784
  // description trips it though the file may still load), and the other fields are