文件历史

提交图

11 次代码提交

作者 SHA1 备注 提交日期
Bortlesboat d409c9ae5c test: add session-start JSON regression coverage 2026-05-06 21:21:34 -04:00
Addy Osmani 501d2266dd hooks: gracefully fall back when jq is missing
The fix in 43a0dde introduces jq as a hard runtime dependency for the
session-start hook. jq is not preinstalled on every macOS or Linux setup,
so users without it would hit a cryptic failure on every new session.

Add a `command -v jq` guard that emits a valid INFO-priority JSON message
explaining the dependency and pointing at install commands. Skills remain
available individually — only the meta-skill injection is skipped.

Co-Authored-By: Claude Opus 4.7 (1M context) <noreply@anthropic.com>
2026-04-27 14:09:22 -07:00
james 43a0dde996 fix: JSON-escape hook content in session-start hook
Fixes issue #89: session-start hook now properly escapes SKILL.md content
when constructing JSON output, preventing parse errors when markdown
contains quotes or control characters.

Uses jq -cn with --arg flag to properly escape all special characters
in the message field.
2026-04-24 23:06:28 -07:00
Federico Bartoli 4743df93b7 refactor(hooks): address review feedback on sdd-cache
Drop the 24h TTL: HTTP validators are the whole freshness contract.
Key cache on URL alone; prompt-aware keying with normalization gave
false safety (semantic differences slipped through). Prompt is kept
as metadata and surfaced in the hit message so the next agent can
judge whether the earlier reading applies. Reframe docs around
"HTTP resource cache, not prompt cache".

While here, fix two latent bugs:
- Replace the unquoted heredoc in the pre-hook with printf. The
  heredoc expanded $vars and backticks inside cached content, so a
  compromised doc page could trigger command substitution on cache
  hit.
- Strip CR before awk paragraph-mode parsing of curl -I -L output
  so blank separators between response blocks on a redirect chain
  are recognised (was silently picking intermediate headers).

Remove dead -v IGNORECASE=1 (gawk-only; tolower() already handles it).
2026-04-18 08:49:29 +02:00
Federico Bartoli 9a429d0574 feat(hooks): opt-in citation cache for source-driven-development
Adds a pair of optional Claude Code hooks that cache WebFetch output
on disk but revalidate every reuse against the origin. Content is
served only when the server returns 304 Not Modified, so
source-driven-development's "verify against current docs" guarantee
still holds across sessions.

- hooks/sdd-cache-pre.sh: PreToolUse hook. For a cached entry, issues
  a HEAD with If-None-Match / If-Modified-Since. On 304, blocks the
  WebFetch (exit 2) and returns cached content via stderr; otherwise
  allows the fetch through.
- hooks/sdd-cache-post.sh: PostToolUse hook. Captures response plus
  current ETag / Last-Modified. Entries without a validator are
  never stored — without one, the pre hook cannot verify freshness
  and caching would amount to trusting memory.
- Cache key: sha256(url + normalized_prompt). Prompt is lowercased
  and whitespace-collapsed so stylistic variants hit the same entry;
  semantically different prompts still miss.
- Hard 24h TTL as a safety net against misbehaving origins.
- hooks/SDD-CACHE.md: opt-in setup, end-to-end testing, debugging.
- .gitignore: ignore the .claude/sdd-cache/ directory.

Hooks are opt-in: users register them in .claude/settings.json. The
source-driven-development skill itself is unchanged.
2026-04-16 19:34:38 +02:00
Addy Osmani 111eade87e For #7 some additional minor tweaks 2026-03-27 18:38:08 -07:00
Federico Bartoli 1730a69454 Add simplify-ignore hook for block-level code protection
Single bash script that prevents the model from seeing (and accidentally
simplifying) code blocks marked with simplify-ignore annotations during
/code-simplify sessions.

Hook flow:
- PreToolUse Read: backs up file, replaces blocks with BLOCK_<hash> placeholders
- PostToolUse Edit|Write: expands placeholders, applies model changes, re-filters
- Stop: restores files from backup when session ends

Features:
- Hash-based tokens (content-addressed, unambiguous round-trip)
- Multi-block support per file
- Optional reason string: /* simplify-ignore-start: perf-critical */
- Language-aware placeholders (preserves comment syntax per language)
- Glob-safe parameter expansion (Bash 3.2 compatible)
- Atomic locking with stale lock recovery
- Trailing newline preservation
- Self-healing recovery from interrupted sessions
- Cross-platform: Bash 3.2+, jq, shasum/sha1sum (macOS, Linux, Git Bash)

Implements #2
2026-03-18 05:20:14 +01:00
Federico Bartoli 0490a93323 Add Claude Code plugin manifest and marketplace catalog
Enable this repo to work as a Claude Code plugin so users can
install it via `/plugin marketplace add addyosmani/agent-skills`.

Add:
- .claude-plugin/plugin.json — plugin manifest exposing
  .claude/commands/ as namespaced slash commands under
  the agent-skills: prefix
- .claude-plugin/marketplace.json — marketplace catalog
  listing this repo as the agent-skills plugin

Fix:
- hooks/hooks.json — rewrite from deprecated flat-array format
  to the plugin-system format keyed by event type; use
  ${CLAUDE_PLUGIN_ROOT} so the hook resolves correctly when the
  plugin is installed from the marketplace into the local cache
- README — replace non-existent `claude plugin add` with the
  correct `/plugin marketplace add` workflow; document namespaced
  slash commands and --plugin-dir usage; add .claude-plugin/ to
  the project tree
2026-02-23 12:29:43 +01:00
Federico Bartoli a63f54b8ab Rename stale swe-skills references to agent-skills
The repository was renamed from swe-skills to agent-skills but
internal references were never updated. This caused:
- session-start.sh to silently fail (path using-swe-skills/ did
  not exist; the directory is using-agent-skills/)
- slash commands to invoke non-existent swe-skills: namespace
- docs and setup guides to point at the old clone URL

Rename all occurrences across 14 files: commands, CLAUDE.md,
README tree, docs/, and hooks/.
2026-02-23 12:02:07 +01:00
Addy Osmani a3372ca0fc add hooks session starter 2026-02-15 14:28:13 -08:00
Addy Osmani d2e333a2c6 add CLAUDE.md and hooks 2026-02-15 14:28:07 -08:00