Skip to content

feat: Claude Runtime Status Module + Preset Status Parity - #133

Merged
Yeachan-Heo merged 1 commit into
mainfrom
feat/claude-runtime-status-parity
Apr 23, 2026
Merged

feat: Claude Runtime Status Module + Preset Status Parity#133
Yeachan-Heo merged 1 commit into
mainfrom
feat/claude-runtime-status-parity

Conversation

@minislively

Copy link
Copy Markdown
Owner

Summary

Extract true status-string builders into claude-runtime-status.ts and add readClaudeHookPresetStatus() to achieve structural parity with the Codex adapter.

Changes

  • Create src/adapters/claude-runtime-status.ts

    • CLAUDE_ADDITIONAL_CONTEXT_MAX_CHARS constant (moved from hook file)
    • clampAdditionalContext() — 9000-char cap utility
    • sessionStartContext() — SessionStart context string
    • boundedFallbackContext() — fallback guidance string
  • Refactor src/adapters/claude-runtime-hook.ts

    • Imports status utilities from ./claude-runtime-status
    • Re-exports CLAUDE_ADDITIONAL_CONTEXT_MAX_CHARS for backward-compatible test imports
    • Keeps buildPayloadContext() in place (payload assembly stays in hook file)
  • Add readClaudeHookPresetStatus() to src/adapters/claude-hook-preset.ts

    • Returns ClaudeHookPresetStatus with installedEvents, missingEvents, unexpectedFooksEvents, disabledByLocalSettings
    • Wraps file reading in try/catch; returns valid: false + blocker on parse failure
    • Migrates hookCommandsForEvent helper into preset module
  • Refactor src/adapters/claude-status.ts

    • hookStatus() delegates core preset validation to readClaudeHookPresetStatus()
    • Keeps manifest/adapter JSON checks as enrichment layer
    • Removes ~60 lines of duplicated preset-reading logic, types, and helpers

Principles

  1. Honest module boundaries — *-runtime-status.ts mirrors Codex: simple string builders only
  2. Zero behavior change — pure refactoring, no functional differences
  3. Preserve public APIs — ClaudeRuntimeHookDecision and exports remain stable
  4. Deduplicate, don't duplicate — readClaudeHookPresetStatus() becomes source of truth

Verification

  • npm run build passes with zero TypeScript errors
  • npm test passes (209 tests, 0 failures)
  • Architect reviewer verified module boundaries and backward compatibility

Test plan

  • Build passes
  • All tests pass
  • Spot-check: SessionStart, escape-hatch, first-seen, repeated-file, fallback context strings are byte-identical before/after refactor

Extract true status-string builders into claude-runtime-status.ts and add
readClaudeHookPresetStatus() for Codex/Claude adapter parity.

Changes:
- Create src/adapters/claude-runtime-status.ts with:
  - CLAUDE_ADDITIONAL_CONTEXT_MAX_CHARS constant
  - clampAdditionalContext() - 9000-char cap utility
  - sessionStartContext() - SessionStart context string
  - boundedFallbackContext() - fallback guidance string

- Refactor src/adapters/claude-runtime-hook.ts:
  - Import status utilities from new module
  - Re-export CLAUDE_ADDITIONAL_CONTEXT_MAX_CHARS for test compatibility
  - Keep buildPayloadContext() in place (payload assembly)

- Add readClaudeHookPresetStatus() to src/adapters/claude-hook-preset.ts:
  - Returns ClaudeHookPresetStatus with installedEvents, missingEvents,
    unexpectedFooksEvents, disabledByLocalSettings
  - Graceful error handling with valid:false + blocker on parse failure

- Refactor src/adapters/claude-status.ts:
  - hookStatus() delegates to readClaudeHookPresetStatus()
  - Keep manifest/adapter JSON checks as enrichment layer
  - Remove ~60 lines of duplicated preset-reading logic

Zero behavior change - pure refactoring with honest module boundaries.

Co-Authored-By: Claude Opus 4.7 <noreply@anthropic.com>
@Yeachan-Heo
Yeachan-Heo merged commit 5ccaf77 into main Apr 23, 2026
2 checks passed
@Yeachan-Heo
Yeachan-Heo deleted the feat/claude-runtime-status-parity branch April 23, 2026 03:15
minislively added a commit that referenced this pull request May 14, 2026
Extract true status-string builders into claude-runtime-status.ts and add
readClaudeHookPresetStatus() for Codex/Claude adapter parity.

Changes:
- Create src/adapters/claude-runtime-status.ts with:
  - CLAUDE_ADDITIONAL_CONTEXT_MAX_CHARS constant
  - clampAdditionalContext() - 9000-char cap utility
  - sessionStartContext() - SessionStart context string
  - boundedFallbackContext() - fallback guidance string

- Refactor src/adapters/claude-runtime-hook.ts:
  - Import status utilities from new module
  - Re-export CLAUDE_ADDITIONAL_CONTEXT_MAX_CHARS for test compatibility
  - Keep buildPayloadContext() in place (payload assembly)

- Add readClaudeHookPresetStatus() to src/adapters/claude-hook-preset.ts:
  - Returns ClaudeHookPresetStatus with installedEvents, missingEvents,
    unexpectedFooksEvents, disabledByLocalSettings
  - Graceful error handling with valid:false + blocker on parse failure

- Refactor src/adapters/claude-status.ts:
  - hookStatus() delegates to readClaudeHookPresetStatus()
  - Keep manifest/adapter JSON checks as enrichment layer
  - Remove ~60 lines of duplicated preset-reading logic

Zero behavior change - pure refactoring with honest module boundaries.

Co-authored-by: minislively <minislively@users.noreply.github.com>
Co-authored-by: Claude Opus 4.7 <noreply@anthropic.com>
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