Skip to content

Commit ab71158

Browse files
Merge pull request #40 from johnlindquist/remove-stray-session-logic
Remove stray session logic from lib.ts
2 parents 2828635 + 034ca40 commit ab71158

File tree

2 files changed

+0
-41
lines changed

2 files changed

+0
-41
lines changed

templates/hooks/lib.ts

Lines changed: 0 additions & 39 deletions
Original file line numberDiff line numberDiff line change
@@ -1,8 +1,5 @@
11
#!/usr/bin/env bun
22

3-
import * as fs from 'node:fs/promises'
4-
import * as path from 'node:path'
5-
63
// Input payload types based on official Claude Code schemas
74
export interface PreToolUsePayload {
85
session_id: string
@@ -143,42 +140,6 @@ export interface HookHandlers {
143140
preCompact?: PreCompactHandler
144141
}
145142

146-
// Session management utilities
147-
const SESSIONS_DIR = path.join(process.cwd(), '.claude', 'hooks', 'sessions')
148-
149-
export async function ensureSessionsDirectory(): Promise<void> {
150-
try {
151-
await fs.mkdir(SESSIONS_DIR, {recursive: true})
152-
} catch (error) {
153-
console.error('Failed to create sessions directory:', error)
154-
}
155-
}
156-
157-
export async function saveSessionData(hookType: string, payload: HookPayload): Promise<void> {
158-
try {
159-
const timestamp = new Date().toISOString()
160-
const sessionFile = path.join(SESSIONS_DIR, `${payload.session_id}.json`)
161-
162-
let sessionData: Array<{timestamp: string; hookType: string; payload: HookPayload}> = []
163-
try {
164-
const existing = await fs.readFile(sessionFile, 'utf-8')
165-
sessionData = JSON.parse(existing)
166-
} catch {
167-
// File doesn't exist yet
168-
}
169-
170-
sessionData.push({
171-
timestamp,
172-
hookType,
173-
payload,
174-
})
175-
176-
await fs.writeFile(sessionFile, JSON.stringify(sessionData, null, 2))
177-
} catch (error) {
178-
console.error('Failed to save session data:', error)
179-
}
180-
}
181-
182143
// Logging utility
183144
export function log(...args: unknown[]): void {
184145
console.log(`[${new Date().toISOString()}]`, ...args)

test/smoke/generated-files.test.ts

Lines changed: 0 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -149,8 +149,6 @@ describe.skip('Smoke Tests - Generated Files', () => {
149149
it('should export utility functions', () => {
150150
expect(libContent).to.include('export function log')
151151
expect(libContent).to.include('export function runHook')
152-
expect(libContent).to.include('export async function ensureSessionsDirectory')
153-
expect(libContent).to.include('export async function saveSessionData')
154152
})
155153
156154
it('should handle stdin for hook communication', () => {

0 commit comments

Comments
 (0)