Repository navigation
fix(hooks): add skill-active-state lifecycle to plugin scripts - #1480
Conversation
The original Yeachan-Heo#1033 fix (f315a84) and subsequent enhancements (Yeachan-Heo#1424, Yeachan-Heo#1432) were applied only to src/hooks/ (bridge code), which is never invoked at runtime. The actual plugin hook scripts routed via hooks/hooks.json — scripts/pre-tool-enforcer.mjs (PreToolUse) and scripts/persistent-mode.cjs (Stop) — were never updated. This caused skills like ralplan, code-review, plan, and tdd to have zero stop protection at runtime, leading to premature session termination mid-skill. Changes: scripts/pre-tool-enforcer.mjs: - Add SKILL_PROTECTION_MAP and SKILL_PROTECTION_CONFIGS with per-skill protection levels (none/light/medium/heavy) - Add writeSkillActiveState() to write skill-active-state.json on Skill tool invocation with session-scoped paths - Add extractSkillName() to parse skill name from tool input variants scripts/persistent-mode.cjs: - Add Priority 9 block to read skill-active-state.json via readStateFileWithSession() - Implement staleness check using per-skill TTL - Implement reinforcement counting with session isolation - Clear state file when reinforcement limit is reached templates/hooks/pre-tool-use.mjs: - Sync legacy hook template with the same skill-active-state writing logic for non-plugin installations Note: This is a partial fix covering generic skill-active-state protection. It does not port the first-class checkRalplan() (30 reinforcements, 45-min TTL) or checkTeamPipeline() (20 reinforcements, 5-min TTL) from src/hooks/persistent-mode/index.ts. Refs: Yeachan-Heo#1033, Yeachan-Heo#1424, Yeachan-Heo#1432 Co-Authored-By: Claude Opus 4.6 <[email protected]>
Yeachan-Heo
left a comment
There was a problem hiding this comment.
Solid implementation. The protection level taxonomy (none/light/medium/heavy) with per-skill mappings is well-thought-out.
Code quality notes:
- Atomic writes with tmp+rename ✅
- Session-scoped state paths ✅
- Consistent pattern between
pre-tool-enforcer.mjsandtemplates/hooks/pre-tool-use.mjs✅ - Staleness detection + reinforcement counting in the Stop hook ✅
- Cleanup on reinforcement limit reached ✅
The explicit callout that checkRalplan() (30 reinforcements, 45-min TTL) and checkTeamPipeline() (20 reinforcements, 5-min TTL) are NOT covered here is appreciated — clear scoping.
One minor note: the SKILL_PROTECTION_MAP / SKILL_PROTECTION constants are duplicated across 2 files (pre-tool-enforcer.mjs and templates/hooks/pre-tool-use.mjs). This is acceptable for now since the scripts are standalone, but something to watch for drift. The medium-term consolidation to bridge-only hooks (#1479 option 3) would fix this.
LGTM ✅ Will merge once CI is green.
—
[repo owner's gaebal-gajae (clawdbot) 🦞]
…-mode.cjs Follow-up to Yeachan-Heo#1480. Ports the first-class stop-hook enforcement for ralplan and team pipeline from src/hooks/persistent-mode/index.ts to the actual runtime script scripts/persistent-mode.cjs. Previously only generic skill-active-state protection existed in scripts/. This adds dedicated enforcement matching the bridge code: Team Pipeline (Priority 2.5): - Phase normalization with canonical field priority (phase → current_phase → currentStage → current_stage → stage) - Terminal phase detection (complete/failed/cancelled/etc.) - Known active phase gating with fail-open for unknown phases - Status-level terminal check - cancel.requested bypass - Circuit breaker: 20 reinforcements, 5-min TTL - Guards existing Priority 6 Team block to avoid double-handling Ralplan (Priority 2.6): - Terminal current_phase detection (complete/completed/failed/cancelled/done) - Session isolation via isSessionMatch() - Circuit breaker: 30 reinforcements, 45-min TTL Shared: - readStopBreaker() / writeStopBreaker() helpers with TTL-based expiry - Constants matching src/hooks/persistent-mode/index.ts exactly Refs: Yeachan-Heo#1479, Yeachan-Heo#1424, Yeachan-Heo#1432 Co-Authored-By: Claude Opus 4.6 <[email protected]>
…-mode.cjs Follow-up to Yeachan-Heo#1480. Ports the first-class stop-hook enforcement for ralplan and team pipeline from src/hooks/persistent-mode/index.ts to the actual runtime script scripts/persistent-mode.cjs. Previously only generic skill-active-state protection existed in scripts/. This adds dedicated enforcement matching the bridge code: Team Pipeline (Priority 2.5): - Phase normalization with canonical field priority (phase → current_phase → currentStage → current_stage → stage) - Terminal phase detection (complete/failed/cancelled/etc.) - Known active phase gating with fail-open for unknown phases - Status-level terminal check - cancel.requested bypass - Circuit breaker: 20 reinforcements, 5-min TTL - Guards existing Priority 6 Team block to avoid double-handling Ralplan (Priority 2.6): - Terminal current_phase detection (complete/completed/failed/cancelled/done) - Session isolation via isSessionMatch() - Circuit breaker: 30 reinforcements, 45-min TTL Shared: - readStopBreaker() / writeStopBreaker() helpers with TTL-based expiry - Constants matching src/hooks/persistent-mode/index.ts exactly Refs: Yeachan-Heo#1479, Yeachan-Heo#1424, Yeachan-Heo#1432 Co-Authored-By: Claude Opus 4.6 <[email protected]>
…-mode.cjs Follow-up to Yeachan-Heo#1480. Ports the first-class stop-hook enforcement for ralplan and team pipeline from src/hooks/persistent-mode/index.ts to the actual runtime script scripts/persistent-mode.cjs. Previously only generic skill-active-state protection existed in scripts/. This adds dedicated enforcement matching the bridge code: Team Pipeline (Priority 2.5): - Phase normalization with canonical field priority (phase → current_phase → currentStage → current_stage → stage) - Terminal phase detection (complete/failed/cancelled/etc.) - Known active phase gating with fail-open for unknown phases - Status-level terminal check - cancel.requested bypass - Circuit breaker: 20 reinforcements, 5-min TTL - Guards existing Priority 6 Team block to avoid double-handling Ralplan (Priority 2.6): - Terminal current_phase detection (complete/completed/failed/cancelled/done) - Session isolation via isSessionMatch() - Circuit breaker: 30 reinforcements, 45-min TTL Shared: - readStopBreaker() / writeStopBreaker() helpers with TTL-based expiry - Constants matching src/hooks/persistent-mode/index.ts exactly Refs: Yeachan-Heo#1479, Yeachan-Heo#1424, Yeachan-Heo#1432 Co-Authored-By: Claude Opus 4.6 <[email protected]>
…-mode.cjs (#1482) Follow-up to #1480. Ports the first-class stop-hook enforcement for ralplan and team pipeline from src/hooks/persistent-mode/index.ts to the actual runtime script scripts/persistent-mode.cjs. Previously only generic skill-active-state protection existed in scripts/. This adds dedicated enforcement matching the bridge code: Team Pipeline (Priority 2.5): - Phase normalization with canonical field priority (phase → current_phase → currentStage → current_stage → stage) - Terminal phase detection (complete/failed/cancelled/etc.) - Known active phase gating with fail-open for unknown phases - Status-level terminal check - cancel.requested bypass - Circuit breaker: 20 reinforcements, 5-min TTL - Guards existing Priority 6 Team block to avoid double-handling Ralplan (Priority 2.6): - Terminal current_phase detection (complete/completed/failed/cancelled/done) - Session isolation via isSessionMatch() - Circuit breaker: 30 reinforcements, 45-min TTL Shared: - readStopBreaker() / writeStopBreaker() helpers with TTL-based expiry - Constants matching src/hooks/persistent-mode/index.ts exactly Refs: #1479, #1424, #1432 Co-authored-by: Claude Opus 4.6 <[email protected]>
The .cjs Stop hook outputs `{ decision: "block" }` without
`continue: false` when blocking stops for active modes. The original
fix (Yeachan-Heo#1216) added `continue: false` to the .mjs scripts but the .cjs
version was never updated, and subsequent commits (Yeachan-Heo#1306, Yeachan-Heo#1330, Yeachan-Heo#1374,
Yeachan-Heo#1480, Yeachan-Heo#1482) did not carry over this fix.
Since hooks.json references the .cjs version, the plugin Stop hook has
been missing hard-block capability, allowing sessions to end mid-execution.
- Add `continue: false` to all 12 blocking outputs in persistent-mode.cjs
- Add `continue: false` to context-guard-stop.mjs (1 output)
- Add `continue: false` to code-simplifier.mjs and its template (1 each)
Closes Yeachan-Heo#1516
…arch (#1549) * feat(setup): add rtk token optimization integration * revert(setup): remove RTK integration from PR #1489 * fix(hooks): fail open on critical context exhaustion * fix(skill): harden omc-teams tmux and agent validation * Add Ralph critic selection for verification * fix(doctor): accept supported omc config keys * feat(openclaw): normalize native clawhip signals * fix: skip legacy agent sync when plugin agents exist * fix(hud): preserve stale usage limits on API failures * Reduce startup OMC guidance context * fix: clean up stale transient files on session end (#1510) - session-end: cleanupTransientState now removes agent-replay-*.jsonl, last-tool-error.json, hud-state.json, hud-stdin-cache.json, idle-notif-cooldown.json, *-stop-breaker.json, cancel-signal files inside session dirs, and empty session directories - keyword-detector: activateState adds project_path field for parity with TypeScript activateUltrawork in bridge.ts - persistent-mode: readStateFileWithSession adds fallback scan of all session directories when session-scoped path lookup fails * fix(hud): reduce transient usage API retry hammering (#1513) * fix(hooks): add missing continue: false to persistent-mode.cjs Stop hook The .cjs Stop hook outputs `{ decision: "block" }` without `continue: false` when blocking stops for active modes. The original fix (#1216) added `continue: false` to the .mjs scripts but the .cjs version was never updated, and subsequent commits (#1306, #1330, #1374, #1480, #1482) did not carry over this fix. Since hooks.json references the .cjs version, the plugin Stop hook has been missing hard-block capability, allowing sessions to end mid-execution. - Add `continue: false` to all 12 blocking outputs in persistent-mode.cjs - Add `continue: false` to context-guard-stop.mjs (1 output) - Add `continue: false` to code-simplifier.mjs and its template (1 each) Closes #1516 * feat(doc-specialist): add first-pass context hub guidance (#1519) * Add skill pipeline handoff metadata (#1520) * chore: remove stale root development artifacts (#1526) * docs(rebrand): update scoped guidance docs (#1527) * docs: rebrand main README to oh-my-openagent (#1528) * docs: rebrand localized readmes to oh-my-openagent (#1529) * revert: undo unauthorized rebrand PRs 1527-1529 * docs: fix outdated install references in REFERENCE.md - Update platform support table: "curl or npm" → "Claude Code Plugin" for macOS/Linux, consistent with the deprecation notice at the top of the Installation section - Replace deprecated curl uninstall one-liner with the plugin uninstall command (/plugin uninstall oh-my-claudecode@oh-my-claudecode) Co-Authored-By: Claude Opus 4.6 <[email protected]> * docs: remove stale analytics references * fix(team): port startup hardening from omx * fix(team): finish runtime hardening port * fix(team): resolve worktree mailbox trigger paths * fix(hud): avoid repeated watch mode initialization * feat: add session history search * fix(team): require real startup evidence * fix(routing): normalize explicit model IDs in all code paths (#1415) The prior fix (PR #1464) only normalized auto-injected models but missed two paths where full model IDs like 'claude-sonnet-4-6' leaked through: 1. enforceModel() passed explicitly-provided models as-is without normalizing to CC aliases (sonnet/opus/haiku) 2. buildLaunchArgs() in model-contract.ts passed model directly to --model flag for team worker launches Extract normalizeToCcAlias() helper and apply it in both paths. Add 5 tests covering explicit ID normalization and Bedrock ID handling. Closes #1415 Co-Authored-By: Claude Opus 4.6 (1M context) <[email protected]> * chore(release): bump version to v4.7.10 Version bumps: - package.json: 4.7.9 → 4.7.10 - .claude-plugin/plugin.json: 4.7.9 → 4.7.10 - .claude-plugin/marketplace.json: 4.7.9 → 4.7.10 - CHANGELOG.md: Updated release header Includes rebuilt dist artifacts for: - Bedrock model routing fixes - Team runtime hardening - Session history search feature - Lazy agent loading Co-Authored-By: Claude Opus 4.6 <[email protected]> --------- Co-authored-by: ChoKhoOu <[email protected]> Co-authored-by: Yong <[email protected]> Co-authored-by: Claude Opus 4.6 <[email protected]> Co-authored-by: Carlos Cubas <[email protected]>
Summary
scripts/pre-tool-enforcer.mjs(PreToolUse hook)scripts/persistent-mode.cjs(Stop hook)templates/hooks/pre-tool-use.mjswith the same logicFixes #1479
Context
The original #1033 fix and subsequent enhancements (#1424, #1432) were applied only to
src/hooks/(bridge code), which is not invoked at runtime. The actual plugin scripts routed viahooks/hooks.jsonwere never updated, causing skills likeralplan,code-review, andplanto have zero stop protection.See #1479 for full root cause analysis.
What this covers
skill-active-state.json)What this does NOT cover
checkRalplan()(30 reinforcements, 45-min TTL) fromsrc/hooks/persistent-mode/index.tscheckTeamPipeline()(20 reinforcements, 5-min TTL)These require a design decision on the
src/hooks/vsscripts/sync strategy (see #1479).Test plan
SESSION_ID_PATTERN,readStateFileWithSession,isSessionMatch,writeJsonFileverified to exist in their respective files/ralplan, verify stop is blocked during consensus workflow/code-review, verify stop is blocked during review🤖 Generated with Claude Code