You signed in with another tab or window. Reload to refresh your session.You signed out in another tab or window. Reload to refresh your session.You switched accounts on another tab or window. Reload to refresh your session.Dismiss alert
Add Intent hook enforcement for supported agents (#174)
* Refactor skill mapping guidance and add `run` command support in intent skills block
* Refactor intent skill mappings to use new structure and update related tests
* Add hooked-intent condition and related functionality to intent discovery evals
- Introduce 'hooked-intent' condition in conditions.ts
- Implement live-router-hooked-intent task in live-tasks.ts
- Create gate.mjs and hook-core.mts for intent hooks management
- Add hook-io.mjs for event handling and observation logging
- Implement prepare-copilot-home.ts for managing copilot home directory
- Update run-copilot-task.ts to support gate state management
- Enhance setup-intent-condition.ts to handle hooked-intent
- Add tests for hooked-intent functionality in intent-hooks.eval.ts
- Update vitest configuration for live concurrency settings
* Refactor install command to use guidance module for intent skills block handling
* Add hooks and policy for intent handling with agent-specific outputs
* Add support for agent hooks in install command with project/user scope
* Enhance intent installation with lifecycle hooks support and update documentation
- Added `--hooks` option to `intent install` for lifecycle hook installation.
- Updated documentation to reflect new hook options and usage.
- Introduced hook adapters for Claude, Codex, and Copilot with project/user scope support.
- Implemented tests to verify supported scopes in the adapter registry.
* Refactor intent installation and hook handling; enhance command patterns and add skill categorization tests
* Add intent hooks command and update documentation for lifecycle hooks installation
* Improve folder layout
* Refactor intent installation and update file structure; remove deprecated install command and enhance type definitions
* ci: apply automated fixes
* changeset
* Apply fixes
---------
Co-authored-by: autofix-ci[bot] <114827586+autofix-ci[bot]@users.noreply.github.com>
Add `intent hooks install` for supported AI coding agents.
6
+
7
+
This adds lifecycle-hook installation for supported agents, including project/user scope handling, generated hook runner scripts, and agent-specific enforcement policy. It also documents the hook setup flow and adds eval/test coverage for hooked intent discovery.
| Claude Code |`.claude/settings.json`|`~/.claude/settings.json`| Blocks configured edit tools with `PreToolUse`|
30
+
| Codex |`.codex/hooks.json`|`~/.codex/hooks.json`| Blocks supported `Bash`, `apply_patch`, and MCP tool calls; Codex hook interception is not a complete security boundary |
31
+
| GitHub Copilot CLI | Guidance via `.github/copilot-instructions.md`; blocking hooks are not project-scoped |`$COPILOT_HOME/hooks/hooks.json` or `~/.copilot/hooks/hooks.json`| Blocks supported edit tools with `PreToolUse`|
32
+
| Cursor | Guidance only | Guidance only | Use `AGENTS.md` or Cursor rules; no blocking hook is installed |
33
+
| Generic `AGENTS.md` agents | Guidance only | Guidance only | Use the `intent-skills` guidance block; no blocking hook is installed |
34
+
35
+
`.github/copilot-instructions.md` is a supported project guidance target for `intent install`. GitHub Copilot CLI hook enforcement uses the user-scoped Copilot hooks directory because that is the supported hook location.
36
+
37
+
Codex requires users to review and trust non-managed hooks before they run. If Codex reports hooks awaiting review, open its hook browser and trust the generated Intent hook.
38
+
39
+
## Status messages
40
+
41
+
- Hook installed: `Installed Intent hooks for claude (project) in .claude/settings.json.`
42
+
- Hook skipped: `Skipped Intent hooks for copilot: project scope is not supported; use --scope user`
- Creates `AGENTS.md` when no managed block exists.
25
30
- Updates an existing managed block in a supported config file.
26
31
- Preserves all content outside the managed block.
27
-
- Scans packages and writes compact `when`and `use` mappings only when `--map` is passed.
32
+
- Scans packages and writes compact `id`, `run`, and `for` mappings only when `--map` is passed.
28
33
- Surfaces packages permitted by `package.json#intent.skills` in `--map` mode. See [Configuration](../concepts/configuration).
29
34
- Skips reference, meta, maintainer, and maintainer-only skills in `--map` mode.
30
-
- Writes compact `when`and `use` entries instead of load paths in `--map` mode.
35
+
- Writes compact skill identities and runnable guidance commands instead of local file paths in `--map` mode.
31
36
- Verifies the managed block before reporting success.
32
37
- Prints `No intent-enabled skills found.` and does not create a config file when `--map` finds no actionable skills.
33
38
@@ -41,29 +46,32 @@ The default block tells agents to discover skills and load matching guidance on
41
46
<!-- intent-skills:start -->
42
47
## Skill Loading
43
48
44
-
Before substantial work:
45
-
- Skill check: run `npx @tanstack/intent@latest list`, or use skills already listed in context.
46
-
- Skill guidance: if one local skill clearly matches the task, run `npx @tanstack/intent@latest load <package>#<skill>` and follow the returned `SKILL.md`.
49
+
Before editing files for a substantial task:
50
+
- Run `npx @tanstack/intent@latest list` from the workspace root to see available local skills.
51
+
- If a listed skill matches the task, run `npx @tanstack/intent@latest load <package>#<skill>` before changing files.
52
+
- Use the loaded `SKILL.md` guidance while making the change.
47
53
- Monorepos: when working across packages, run the skill check from the workspace root and prefer the local skill for the package being changed.
48
54
- Multiple matches: prefer the most specific local skill for the package or concern you are changing; load additional skills only when the task spans multiple packages or concerns.
49
55
<!-- intent-skills:end -->
50
56
```
51
57
52
58
## Mapping output
53
59
54
-
`--map` writes compact skill identities:
60
+
`--map` writes compact skill identities and commands:
Copy file name to clipboardExpand all lines: docs/getting-started/quick-start-consumers.md
+18-4Lines changed: 18 additions & 4 deletions
Display the source diff
Display the rich diff
Original file line number
Diff line number
Diff line change
@@ -31,16 +31,31 @@ Intent creates guidance like:
31
31
<!-- intent-skills:start -->
32
32
## Skill Loading
33
33
34
-
Before substantial work:
35
-
- Skill check: run `pnpm dlx @tanstack/intent@latest list`, or use skills already listed in context.
36
-
- Skill guidance: if one local skill clearly matches the task, run `pnpm dlx @tanstack/intent@latest load <package>#<skill>` and follow the returned `SKILL.md`.
34
+
Before editing files for a substantial task:
35
+
- Run `pnpm dlx @tanstack/intent@latest list` from the workspace root to see available local skills.
36
+
- If a listed skill matches the task, run `pnpm dlx @tanstack/intent@latest load <package>#<skill>` before changing files.
37
+
- Use the loaded `SKILL.md` guidance while making the change.
37
38
- Monorepos: when working across packages, run the skill check from the workspace root and prefer the local skill for the package being changed.
38
39
- Multiple matches: prefer the most specific local skill for the package or concern you are changing; load additional skills only when the task spans multiple packages or concerns.
39
40
<!-- intent-skills:end -->
40
41
```
41
42
42
43
Intent detects the package manager when generating this block, so the runner may be `npx`, `pnpm dlx`, `yarn dlx`, or `bunx`.
43
44
45
+
To enforce loading guidance before edits in supported agents, opt in to hooks:
46
+
47
+
```bash
48
+
npx @tanstack/intent@latest hooks install
49
+
```
50
+
51
+
Project-scoped hooks are installed for Claude Code and Codex. `intent install` can write project guidance to `.github/copilot-instructions.md`, but GitHub Copilot CLI hook enforcement is user-scoped, so configure it explicitly:
52
+
53
+
```bash
54
+
npx @tanstack/intent@latest hooks install --scope user --agents copilot
55
+
```
56
+
57
+
Cursor and generic `AGENTS.md` agents use the guidance block only.
58
+
44
59
## 2. Choose which packages' skills to use
45
60
46
61
`package.json#intent.skills` is an allowlist of the packages whose skills you want surfaced.
@@ -106,4 +121,3 @@ You can also check if any skills reference outdated source documentation:
Creates or updates lightweight `intent-skills` guidance in your config files (`AGENTS.md`, `CLAUDE.md`, `.cursorrules`, etc.). Existing guidance is updated in place; otherwise `AGENTS.md` is the default target. Pass `--map` to opt in to explicit task-to-skill mappings.
52
55
56
+
```bash
57
+
npx @tanstack/intent@latest hooks install
58
+
```
59
+
60
+
Installs hook enforcement for supported agents. Project-scoped hooks are available for Claude Code and Codex. GitHub Copilot CLI project guidance can live in `.github/copilot-instructions.md`, while blocking hooks are user-scoped. Cursor and generic `AGENTS.md` agents use guidance only.
Set `INTENT_DISCOVERY_RUN_COUNT=3` with the live commands to run each live condition three times and include `pass@k` / `pass^k` in the generated summary.
24
24
25
+
## Live eval speed
26
+
27
+
Only the live `copilot -p` subprocess runs are slow; the saved-transcript suite (`pnpm eval:intent-discovery`) is unaffected.
28
+
29
+
-`INTENT_DISCOVERY_LIVE_CONCURRENCY` bounds how many live runs execute at once (default `1`, clamped to an integer `>= 1`). Values above `1` measured slower here: concurrent `copilot -p` calls on one account contend upstream (a run with its own isolated `COPILOT_HOME` still slowed ~2x), so raise it only with separate accounts or dedicated infrastructure.
30
+
-`COPILOT_MODEL` selects the Copilot model end-to-end. The adapter passes the process environment through to `copilot -p`, and the CLI honors `COPILOT_MODEL`. `INTENT_DISCOVERY_COPILOT_MODEL` only sets the model label recorded in report metadata; it does not change the model the CLI runs.
31
+
-`INTENT_DISCOVERY_RUN_COUNT` stays `1` by default for iteration. Set it to `3` only when measuring `pass@k` / `pass^k`.
32
+
25
33
The optional LLM judge is secondary. It can annotate whether final answers appear to apply loaded guidance, but it never changes deterministic scores such as `StrictIntentInvocation`, `CorrectSkillLoaded`, or `AutonomousDiscoverySuccess`.
0 commit comments