Description
The pai-history-system pack is missing the required src/lib/metadata-extraction.ts file, causing installation failures. This file was lost during the kai-* → pai-* rebranding.
Impact
Severity: High - Breaks pai-history-system installation
When users install pai-history-system following the wizard in INSTALL.md, the hooks are copied but the required library file is missing, resulting in:
SessionEnd hook [bun run $PAI_DIR/hooks/capture-all-events.ts --event-type SessionEnd] failed:
error: Cannot find module './lib/metadata-extraction' from '/Users/user/.claude/hooks/capture-all-events.ts'
Files Affected
The following files import from the missing module:
-
src/capture-all-events.ts:8
import { enrichEventWithAgentMetadata, isAgentSpawningCall } from './lib/metadata-extraction';
-
src/subagent-stop-hook.ts:8
import { extractAgentInstanceId } from './lib/metadata-extraction';
Root Cause
Git history analysis:
- Commit
1c34d06 (directory-based migration): File existed at Packs/kai-history-system/src/lib/metadata-extraction.ts ✓
- Commit
0faf5e4 (kai-* → pai-* rebranding): File was deleted (75 lines removed) but never re-added to Packs/pai-history-system/src/lib/
Evidence:
$ git ls-tree -r 1c34d06 --name-only | grep metadata-extraction
Packs/kai-history-system/src/lib/metadata-extraction.ts # ✓ existed
Packs/kai-observability-server/src/hooks/lib/metadata-extraction.ts
$ git ls-tree -r 0faf5e4 --name-only | grep metadata-extraction
Packs/pai-observability-server/src/hooks/lib/metadata-extraction.ts # ✗ pai-history-system missing
Expected vs Actual
Expected (per README.md line 35)
pai-history-system/
├── src/
│ ├── capture-all-events.ts
│ ├── stop-hook.ts
│ ├── subagent-stop-hook.ts
│ ├── capture-session-summary.ts
│ └── lib/
│ └── metadata-extraction.ts ← Should exist
Actual
pai-history-system/
├── src/
│ ├── capture-all-events.ts
│ ├── stop-hook.ts
│ ├── subagent-stop-hook.ts
│ ├── capture-session-summary.ts
│ └── lib/ ← Directory missing entirely
Proposed Fix
Restore the file from the last known good commit:
git show 1c34d06:Packs/kai-history-system/src/lib/metadata-extraction.ts \
> Packs/pai-history-system/src/lib/metadata-extraction.ts
The file should contain ~75 lines with these exports:
extractAgentInstanceId()
enrichEventWithAgentMetadata()
isAgentSpawningCall()
Workaround (for users)
Users can manually copy the file from pai-observability-server:
mkdir -p ~/.claude/hooks/lib
cp Packs/pai-observability-server/src/hooks/lib/metadata-extraction.ts \
~/.claude/hooks/lib/
Additional Context
- This does NOT indicate pai-history-system depends on pai-observability-server
- Both packs originally had independent copies of this shared utility
- The file should be restored to pai-history-system for proper installation
- Documentation (README.md, INSTALL.md) correctly references the file - only the actual file is missing
Verification
After fix, verify:
# File should exist
ls -la Packs/pai-history-system/src/lib/metadata-extraction.ts
# Should contain these exports
grep -E "export (function|interface)" Packs/pai-history-system/src/lib/metadata-extraction.ts
Expected output:
export interface AgentInstanceMetadata
export function extractAgentInstanceId
export function enrichEventWithAgentMetadata
export function isAgentSpawningCall
Description
The
pai-history-systempack is missing the requiredsrc/lib/metadata-extraction.tsfile, causing installation failures. This file was lost during the kai-* → pai-* rebranding.Impact
Severity: High - Breaks pai-history-system installation
When users install
pai-history-systemfollowing the wizard inINSTALL.md, the hooks are copied but the required library file is missing, resulting in:Files Affected
The following files import from the missing module:
src/capture-all-events.ts:8src/subagent-stop-hook.ts:8Root Cause
Git history analysis:
1c34d06(directory-based migration): File existed atPacks/kai-history-system/src/lib/metadata-extraction.ts✓0faf5e4(kai-* → pai-* rebranding): File was deleted (75 lines removed) but never re-added toPacks/pai-history-system/src/lib/Evidence:
Expected vs Actual
Expected (per README.md line 35)
Actual
Proposed Fix
Restore the file from the last known good commit:
git show 1c34d06:Packs/kai-history-system/src/lib/metadata-extraction.ts \ > Packs/pai-history-system/src/lib/metadata-extraction.tsThe file should contain ~75 lines with these exports:
extractAgentInstanceId()enrichEventWithAgentMetadata()isAgentSpawningCall()Workaround (for users)
Users can manually copy the file from pai-observability-server:
Additional Context
Verification
After fix, verify:
Expected output: