Skip to content

feat: add Claude Code hooks integration#13

Open
nandanugg wants to merge 6 commits intocortexkit:mainfrom
nandanugg:feat/claude-code-hooks
Open

feat: add Claude Code hooks integration#13
nandanugg wants to merge 6 commits intocortexkit:mainfrom
nandanugg:feat/claude-code-hooks

Conversation

@nandanugg
Copy link
Copy Markdown

Summary

  • Add install/uninstall scripts for Claude Code hooks integration
  • Tool interception routes Read, Grep, Glob through AFT for indexed performance
  • CLI wrapper provides semantic commands (outline, zoom, call_tree, callers, impact, trace_to)
  • Global AFT.md instructions teach Claude to use AFT for 60-90% context savings

Installation

./scripts/install-claude-hooks.sh

Test plan

  • Install script is idempotent (safe to run multiple times)
  • All semantic commands work (outline, zoom, call_tree, callers, impact, trace_to)
  • Hook interception works for Read, Grep, Glob tools
  • Test on fresh system without existing Claude Code config

🤖 Generated with Claude Code

ualtinok and others added 6 commits April 16, 2026 15:39
Add install/uninstall scripts that set up AFT hooks for Claude Code:
- Tool interception for Read, Grep, Glob via PreToolUse hooks
- CLI wrapper for semantic commands (outline, zoom, call_tree, callers, etc.)
- Global AFT.md instructions so Claude learns to use AFT for context savings

Co-Authored-By: Claude Opus 4.5 <noreply@anthropic.com>
- Add MANDATORY section emphasizing AFT-first approach
- Add Decision Tree for quick command selection
- Rename "Best Practices" to "Rules (NOT suggestions)"
- Add Context Protection section to prevent context exhaustion
- Clarify that AFT applies to all file types, not just code

Co-Authored-By: Claude Opus 4.5 <noreply@anthropic.com>
- Add prominent "AFT applies to ALL file types" note in MANDATORY section
- Change "Before ANY code exploration" to "Before reading ANY files"
- Add docs/config example to decision tree
- Add new row for docs/configs in "When to Use What" table
- Add rule cortexkit#6: "ALWAYS outline before sampling"

Addresses feedback that code-centric language caused AFT to be skipped
for markdown/documentation files.

Co-Authored-By: Claude Opus 4.5 <noreply@anthropic.com>
- Remove Read from hooked tools list (conflicts with Edit validation)
- Add guidance to use `aft read` via Bash for indexed reads
- Add warning: use native Read tool when editing is needed

Co-Authored-By: Claude Opus 4.5 <noreply@anthropic.com>
Subagents don't follow ordering guarantees, so leaving "outline first"
as a mid-step instruction doesn't work. Run outline yourself and
include the output in the subagent prompt.

Co-Authored-By: Claude Opus 4.5 <noreply@anthropic.com>
ualtinok added a commit that referenced this pull request Apr 25, 2026
…llowups

Second full-codebase audit found 38 items; 32 confirmed real after triple-
verification, plus a third pass after Oracle review caught one introduced
SSRF bypass.

Security:
- aft-cli: createGitHubIssue uses spawnSync with argv to prevent shell
  injection through repo/title (#6).
- opencode + pi: restrict_to_project_root defaults to true for plugin
  contexts; the Rust CLI default stays false for direct/scripted use (#1).
- opencode: per-server random RPC token (32B hex) stored in JSON port file;
  every request requires the token; legacy integer port files still parsed
  for backward compatibility (#23).
- opencode: url-fetch SSRF guard with manual redirect handling (max 5 hops),
  full IPv6 expansion, and IPv4-mapped/compatible bypass detection
  (::ffff:127.0.0.1, ::127.0.0.1, [::]); allowPrivate escape hatch (#32 +
  Oracle followup).
- Rust: handle_git_conflicts now validates each conflicted file path
  through ctx.validate_path() (#20).

Cross-plugin parity:
- pi-plugin pool keys bridges by realpathSync canonicalization, mirroring
  opencode (#5).
- pi-plugin zoom multi-symbol fan-out routes through callBridge so each
  parallel request carries Pi's session_id (#16 — regression from v0.15.3).
- pi-plugin tool-surface ALL_ONLY constants align with opencode (#9).
- both bridges enforce 64MB MAX_STDOUT_BUFFER and treat overflow as crash
  (#10).
- pi-plugin aft_transform validates per-op required parameters (#17).
- both bridges' compareSemver implements semver pre-release ordering (#29).

Rust correctness:
- glob edit_match wraps multi-file writes in checkpoint snapshot with
  rollback on failure (#3).
- LSP client kills+waits child on shutdown timeout and via Drop impl (#4).
- type-checker working_dir uses config.project_root, not path.parent() (#7).
- ast_search/grep return invalid_pattern errors instead of empty matches
  on malformed regex/AST patterns (#11).
- zoom ambiguous suggestions output 1-based start-end line ranges (#12).
- zoom line-range response uses clamped end_line (#13).
- configure.validate_on_edit accepts booleans (#18).
- checkpoint restore creates parent directories (#19).
- lsp_hints paths_match uses canonical comparison + separator-bounded
  suffix matching (#22).
- format.resolve_tool --version probe has 2s timeout (#24).
- backup.canonicalize_key fallback logs at debug (#25).
- read.handle_directory caps at 1000 entries with truncation note (#34).
- read uses saturating_add/sub for end_line math (#36).
- lsp_rename + lsp_find_references use consistent 1-based character (#37).
- ast_search/replace comments now reference panic=unwind (#27).

Workflow + docs:
- release.yml has top-level concurrency control (#35).
- test job runs bun build before publish-crates (#8).
- release.yml uses sha256sum on Ubuntu (#29).
- version-sync.mjs comment reflects 9 packages (#28).

Verification: 726 Rust tests pass / 1 ignored (was 718, +8 new tests),
383 TS tests pass (was 362, +21 new tests covering RPC auth, SSRF guard,
pool canonicalization, semver pre-release, structure validation, edit_match
atomicity, IPv4-mapped IPv6 bypass detection). Typecheck + lint clean.
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.

2 participants