mirror of
https://github.com/catlog22/Claude-Code-Workflow.git
synced 2026-02-10 02:24:35 +08:00
- Introduced a new benchmark results file for performance comparison on 2026-02-09. - Added a test for LspGraphBuilder to ensure it does not expand nodes at maximum depth. - Created a test for the staged search pipeline to validate fallback behavior when stage 1 returns empty results.
40 lines
1.1 KiB
TypeScript
40 lines
1.1 KiB
TypeScript
import { existsSync, mkdirSync, appendFileSync } from 'fs';
|
|
import path from 'path';
|
|
|
|
export type CliSessionAuditEventType =
|
|
| 'session_created'
|
|
| 'session_closed'
|
|
| 'session_send'
|
|
| 'session_execute'
|
|
| 'session_resize'
|
|
| 'session_share_created'
|
|
| 'session_idle_reaped';
|
|
|
|
export interface CliSessionAuditEvent {
|
|
type: CliSessionAuditEventType;
|
|
timestamp: string;
|
|
projectRoot: string;
|
|
sessionKey?: string;
|
|
tool?: string;
|
|
resumeKey?: string;
|
|
workingDir?: string;
|
|
ip?: string;
|
|
userAgent?: string;
|
|
details?: Record<string, unknown>;
|
|
}
|
|
|
|
function auditFilePath(projectRoot: string): string {
|
|
return path.join(projectRoot, '.workflow', 'audit', 'cli-sessions.jsonl');
|
|
}
|
|
|
|
export function appendCliSessionAudit(event: CliSessionAuditEvent): void {
|
|
try {
|
|
const filePath = auditFilePath(event.projectRoot);
|
|
const dir = path.dirname(filePath);
|
|
if (!existsSync(dir)) mkdirSync(dir, { recursive: true });
|
|
appendFileSync(filePath, JSON.stringify(event) + '\n', { encoding: 'utf8' });
|
|
} catch {
|
|
// Best-effort: never fail API requests due to audit write errors.
|
|
}
|
|
}
|