Skip to content

Add proactive Intent hook skill catalogs#180

Merged
LadyBluenotes merged 3 commits into
mainfrom
agent-safe-list-redaction
Jun 22, 2026
Merged

Add proactive Intent hook skill catalogs#180
LadyBluenotes merged 3 commits into
mainfrom
agent-safe-list-redaction

Conversation

@LadyBluenotes

@LadyBluenotes LadyBluenotes commented Jun 22, 2026

Copy link
Copy Markdown
Member

Summary

  • add SessionStart skill catalog injection to installed Intent hooks for supported agents
  • keep the existing PreToolUse edit gate so agents still need to run intent load before editing
  • generate hook catalogs through the Intent CLI with agent audience redaction instead of importing package code from the target repo
  • update hook tests and docs for the proactive catalog plus protective gate behavior

Summary by CodeRabbit

  • New Features

    • Intent hooks installation now includes session-start skill catalog display for supported agents (Claude, Copilot, Codex)
    • Edit gate enforcement remains active until agents load matching guidance
    • Catalog contents customizable via intent.skills and intent.exclude configuration
  • Documentation

    • Clarified hook installation behavior and configuration options in guides

@coderabbitai

coderabbitai Bot commented Jun 22, 2026

Copy link
Copy Markdown
Contributor

Review Change Stack

📝 Walkthrough

Walkthrough

intent hooks install now installs SessionStart lifecycle hooks in addition to the existing PreToolUse edit gate. The generated runner script embeds a CATALOG_COMMAND (computed via formatIntentCommand/detectPackageManager) and emits a formatted skill catalog to the agent at session start. Per-agent upsert logic is consolidated into a new upsertAdapterHooks dispatcher, status messages are split into catalog vs. gate constants, and docs/tests are updated throughout.

Changes

SessionStart Skill Catalog Hook Feature

Layer / File(s) Summary
Hook runner script: SessionStart catalog emission
packages/intent/src/hooks/install.ts
buildHookRunnerScript accepts an optional catalogCommand, splits STATUS_MESSAGE into CATALOG_STATUS_MESSAGE/GATE_STATUS_MESSAGE, and the generated script's async main now branches on SessionStart to spawn the embedded catalog command, parse the JSON output, and write formatted skill guidance to stdout.
Hook installation: per-agent SessionStart + PreToolUse upserts
packages/intent/src/hooks/install.ts
installAgentHook computes catalogCommand and passes it to buildHookRunnerScript; new upsertAdapterHooks dispatcher replaces upsertAdapterPreToolUseHook; claude, codex, and copilot adapters each get both SessionStart and PreToolUse hook group wiring; gate-script detection regex is adjusted.
Tests: SessionStart assertions and catalog behavior
packages/intent/tests/hooks-install.test.ts
Existing install tests extended with SessionStart shape/command checks for all three agents; idempotency tests assert single SessionStart entry; runner-script test updated for new negative assertions; new it.each tests cover per-agent catalog output content, post-catalog edit locking, and silent failure on catalog load error; writeFakeIntentListCommand and quoteShell helpers added.
CLI description and documentation updates
packages/intent/src/cli.ts, docs/cli/intent-hooks.md, docs/getting-started/quick-start-consumers.md, .changeset/mighty-friends-doubt.md
hooks [action] command declaration reformatted; intent-hooks.md behavior bullets and hook-support table updated to document SessionStart catalog and PreToolUse gate semantics, scope/agent defaults, and intent.skills/intent.exclude controls; quick-start guide gets two explanatory lines; Changeset entry added.

Estimated code review effort

🎯 3 (Moderate) | ⏱️ ~25 minutes

Possibly related PRs

  • TanStack/intent#174: Modifies the same buildHookRunnerScript and adapter hook upsert code in packages/intent/src/hooks/install.ts that this PR extends with SessionStart catalog behavior.
  • TanStack/intent#176: Introduces intent list agent-safe audience redaction and hiddenSourceCount output that the new SessionStart catalog command relies on.

Suggested reviewers

  • KevinVandy

Poem

🐰 A rabbit hops in at session's dawn,
skills catalog ready before the first yawn.
SessionStart fires, the agent sees all —
each Intent skill listed, ready to call.
The edit gate holds till guidance is done,
but now the bunny's already begun! 🌟

🚥 Pre-merge checks | ✅ 3 | ❌ 2

❌ Failed checks (2 warnings)

Check name Status Explanation Resolution
Description check ⚠️ Warning The PR description provides a clear summary of changes and objectives, but does not follow the template structure with required sections like 'Changes', 'Checklist', and 'Release Impact'. Restructure the PR description to match the template format with 'Changes', 'Checklist', and 'Release Impact' sections, and confirm the changeset has been generated.
Docstring Coverage ⚠️ Warning Docstring coverage is 0.00% which is insufficient. The required threshold is 80.00%. Write docstrings for the functions missing them to satisfy the coverage threshold.
✅ Passed checks (3 passed)
Check name Status Explanation
Title check ✅ Passed The title clearly and concisely summarizes the main change: adding proactive Intent hook skill catalogs for supported agents.
Linked Issues check ✅ Passed Check skipped because no linked issues were found for this pull request.
Out of Scope Changes check ✅ Passed Check skipped because no linked issues were found for this pull request.

✏️ Tip: You can configure your own custom pre-merge checks in the settings.

✨ Finishing Touches
📝 Generate docstrings
  • Create stacked PR
  • Commit on current branch
🧪 Generate unit tests (beta)
  • Create PR with unit tests
  • Commit unit tests in branch agent-safe-list-redaction

Thanks for using CodeRabbit! It's free for OSS, and your support helps us grow. If you like it, consider giving us a shout-out.

❤️ Share

Comment @coderabbitai help to get the list of available commands and usage tips.

@nx-cloud

nx-cloud Bot commented Jun 22, 2026

Copy link
Copy Markdown

View your CI Pipeline Execution ↗ for commit b380827

Command Status Duration Result
nx run-many --targets=build --exclude=examples/** ✅ Succeeded 2s View ↗

☁️ Nx Cloud last updated this comment at 2026-06-22 00:52:14 UTC

@nx-cloud

nx-cloud Bot commented Jun 22, 2026

Copy link
Copy Markdown

View your CI Pipeline Execution ↗ for commit b380827

Command Status Duration Result
nx run-many --targets=build --exclude=examples/** ✅ Succeeded 2s View ↗

☁️ Nx Cloud last updated this comment at 2026-06-22 00:52:15 UTC

@pkg-pr-new

pkg-pr-new Bot commented Jun 22, 2026

Copy link
Copy Markdown

Open in StackBlitz

npm i https://pkg.pr.new/TanStack/intent/@tanstack/intent@180

commit: b380827

@coderabbitai coderabbitai Bot left a comment

Copy link
Copy Markdown
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

🧹 Nitpick comments (2)
packages/intent/src/hooks/install.ts (2)

550-553: 🧹 Nitpick | 🔵 Trivial | ⚡ Quick win

Unnecessary escape character in regex.

The forward slash doesn't need escaping inside a character class.

🔧 Suggested fix
 function isIntentGateScriptReference(value: string): boolean {
-  return /(?:^|[\s"'\/])(?:old-)?intent-(claude|codex|copilot)-gate\.mjs(?:$|[?#\s"'])/i.test(
+  return /(?:^|[\s"'/])(?:old-)?intent-(claude|codex|copilot)-gate\.mjs(?:$|[?#\s"'])/i.test(
     value,
   )
 }
🤖 Prompt for AI Agents
Verify each finding against current code. Fix only still-valid issues, skip the
rest with a brief reason, keep changes minimal, and validate.

In `@packages/intent/src/hooks/install.ts` around lines 550 - 553, The regex
pattern in the isIntentGateScriptReference function contains an unnecessarily
escaped forward slash inside the character class. Remove the backslash escape
from the forward slash in the character class portion of the regex pattern where
it matches starting delimiters, leaving just the forward slash without the
escape character. This will clean up the regex without changing its
functionality.

Source: Linters/SAST tools


62-68: 🧹 Nitpick | 🔵 Trivial | 💤 Low value

Default catalogCommand is computed at build time, not runtime.

The default value detectPackageManager() (no cwd argument) uses process.cwd() at the moment buildHookRunnerScript is called. If this function is invoked in a context where process.cwd() differs from the target repository root (e.g., during tests or global installation), the wrong package manager may be detected and baked into the generated script.

This is mitigated because installAgentHook explicitly passes detectPackageManager(root) at line 352-353. However, direct callers relying on the default (like the test at hooks-install.test.ts:314) may get unexpected results if their working directory differs from the intended root.

Consider documenting this or making catalogCommand a required parameter to avoid accidental misuse.

🤖 Prompt for AI Agents
Verify each finding against current code. Fix only still-valid issues, skip the
rest with a brief reason, keep changes minimal, and validate.

In `@packages/intent/src/hooks/install.ts` around lines 62 - 68, The default value
for the `catalogCommand` parameter in the `buildHookRunnerScript` function is
computed at call time using `detectPackageManager()` without specifying a
working directory, which means it uses the current `process.cwd()`. This can
cause incorrect package manager detection if the function is invoked from a
different working directory than the target repository root. Either make the
`catalogCommand` parameter required (removing the default value) to force
callers to explicitly pass the correct command with the proper context, or add
clear documentation explaining that the default value depends on the current
working directory and may not be suitable for all calling contexts.
🤖 Prompt for all review comments with AI agents
Verify each finding against current code. Fix only still-valid issues, skip the
rest with a brief reason, keep changes minimal, and validate.

Nitpick comments:
In `@packages/intent/src/hooks/install.ts`:
- Around line 550-553: The regex pattern in the isIntentGateScriptReference
function contains an unnecessarily escaped forward slash inside the character
class. Remove the backslash escape from the forward slash in the character class
portion of the regex pattern where it matches starting delimiters, leaving just
the forward slash without the escape character. This will clean up the regex
without changing its functionality.
- Around line 62-68: The default value for the `catalogCommand` parameter in the
`buildHookRunnerScript` function is computed at call time using
`detectPackageManager()` without specifying a working directory, which means it
uses the current `process.cwd()`. This can cause incorrect package manager
detection if the function is invoked from a different working directory than the
target repository root. Either make the `catalogCommand` parameter required
(removing the default value) to force callers to explicitly pass the correct
command with the proper context, or add clear documentation explaining that the
default value depends on the current working directory and may not be suitable
for all calling contexts.

ℹ️ Review info
⚙️ Run configuration

Configuration used: defaults

Review profile: CHILL

Plan: Pro

Run ID: 5d06ef29-ba71-4603-b9c4-25f91838a742

📥 Commits

Reviewing files that changed from the base of the PR and between 85f4b1d and e0e78ef.

📒 Files selected for processing (6)
  • .changeset/mighty-friends-doubt.md
  • docs/cli/intent-hooks.md
  • docs/getting-started/quick-start-consumers.md
  • packages/intent/src/cli.ts
  • packages/intent/src/hooks/install.ts
  • packages/intent/tests/hooks-install.test.ts

@LadyBluenotes LadyBluenotes merged commit d67a5d6 into main Jun 22, 2026
3 checks passed
@LadyBluenotes LadyBluenotes deleted the agent-safe-list-redaction branch June 22, 2026 03:33
@github-actions github-actions Bot mentioned this pull request Jun 22, 2026
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

None yet

Projects

None yet

Development

Successfully merging this pull request may close these issues.

1 participant