Skip to content

refactor(auto-recall): accept parsed hook input directly#42

Merged
jeff-r2026 merged 2 commits into
Tencent:mainfrom
wustwyh:fix/auto-recall-parsed-input
Jun 24, 2026
Merged

refactor(auto-recall): accept parsed hook input directly#42
jeff-r2026 merged 2 commits into
Tencent:mainfrom
wustwyh:fix/auto-recall-parsed-input

Conversation

@wustwyh

@wustwyh wustwyh commented Jun 24, 2026

Copy link
Copy Markdown
Contributor

Remove the stdout-mocking hack in hook-handlers.ts by introducing autoRecallFromInput(input: HookInput). The CLI entry autoRecall() now reads STDIN and delegates to autoRecallFromInput, which returns the hook output JSON (or null). This makes the handler testable without intercepting process.stdout and keeps the existing CLI behavior backward-compatible.

Subsequent commits further reduce duplication:

  • Extract parseHookInput() to normalize tool_name / tool_input / tool_output / session_id across STDIN conventions; returns null for unidentified payloads.
  • Extract deriveSessionId() into src/utils/session-id.ts with optional includeCwd fallback.
  • Adopt the shared helpers in autoRecallHandler, todowrite-hint, dashboard-collector, and contribute-check.
  • Expand unit tests for parseHookInput, autoRecallFromInput edge cases, WebSearch/WebFetch recall, dedup/rate-limit, and deriveSessionId.

Type of Change

  • Bug fix (non-breaking change that fixes an issue)
  • New feature (non-breaking change that adds functionality)
  • Breaking change (fix or feature causing existing behavior to change)
  • Documentation only
  • Refactor / internal cleanup

Test Plan

px tsc --noEmit passes

px vitest run src/tests/auto-recall.test.ts src/tests/hook-handlers.test.ts src/tests/session-id.test.ts src/tests/dashboard-collector.test.ts src/tests/todowrite-hint.test.ts src/tests/contribute-check.test.ts src/tests/contribute-check-phase2.test.ts src/tests/auto-recall-quality.test.ts passes

  • Added/updated tests for the change

Related Issues

N/A

Notes for Reviewers

The PR keeps existing behavior unchanged:

  • autoRecall() remains the STDIN-based CLI entry point.
  • The PID+cwd composite fallback in dashboard-collector and contribute-check is preserved via deriveSessionId({ includeCwd: true }).
  • The contribute-check handler still requires an explicit session_id before running.

wustwyh added 2 commits June 24, 2026 14:43
Remove the stdout-mocking hack in hook-handlers.ts by introducing
autoRecallFromInput(input: HookInput). The CLI entry autoRecall() now
reads STDIN and delegates to autoRecallFromInput, which returns the
hook output JSON (or null). This makes the handler testable without
intercepting process.stdout and keeps the existing CLI behavior
backward-compatible.

- Export HookInput type from auto-recall.ts
- Add autoRecallFromInput() containing the core recall logic
- Keep autoRecall() as the STDIN-based CLI wrapper
- Update autoRecallHandler to parse stdin and call autoRecallFromInput
- Add unit tests for autoRecallFromInput
- Update hook-handlers mock/test for the new function
…nId helper

- Add parseHookInput() to normalize tool_name/tool_input/tool_output/session_id
  from hook payloads; return null for unidentified tools
- Refactor readStdin() and autoRecallHandler to use parseHookInput
- Extract deriveSessionId() into src/utils/session-id.ts with optional includeCwd
- Adopt deriveSessionId across dashboard-collector, todowrite-hint, and contribute-check
- Expand unit tests for parseHookInput, autoRecallFromInput edge cases, and deriveSessionId
@wustwyh wustwyh force-pushed the fix/auto-recall-parsed-input branch from a1e4830 to 1fdc50f Compare June 24, 2026 10:29
@jeff-r2026 jeff-r2026 merged commit 8b7d3e2 into Tencent:main Jun 24, 2026
7 checks passed
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