Refactor path management: Migrate path discovery logic to shared paths module

- Removed `path-discovery.ts` service and replaced its usage with a new `paths.ts` module.
- Updated all commands and services to utilize the new path constants and helper functions.
- Ensured all necessary directories are created using the new utility functions.
- Improved code readability and maintainability by centralizing path configurations.
This commit is contained in:
Alex Newman
2025-10-16 14:46:47 -04:00
parent 2ba840aaac
commit f2551ac366
18 changed files with 327 additions and 233 deletions
+1 -2
View File
@@ -1,5 +1,4 @@
import { HooksDatabase } from '../services/sqlite/HooksDatabase.js';
import { PathDiscovery } from '../services/path-discovery.js';
import path from 'path';
export interface SessionStartInput {
@@ -69,7 +68,7 @@ export function contextHook(input: SessionStartInput): void {
output.push(`**Files Edited:** ${files.join(', ')}`);
}
} catch {
// If not valid JSON, show as text
// Backwards compatibility: if not valid JSON, show as text
if (summary.files_edited.trim()) {
output.push(`**Files Edited:** ${summary.files_edited}`);
}
+2 -4
View File
@@ -1,7 +1,6 @@
import net from 'net';
import { join } from 'path';
import { HooksDatabase } from '../services/sqlite/HooksDatabase.js';
import { PathDiscovery } from '../services/path-discovery.js';
import { getWorkerSocketPath } from '../shared/paths.js';
export interface PostToolUseInput {
session_id: string;
@@ -45,8 +44,7 @@ export function saveHook(input: PostToolUseInput): void {
}
// Get socket path
const dataDir = PathDiscovery.getInstance().getDataDirectory();
const socketPath = join(dataDir, `worker-${session.id}.sock`);
const socketPath = getWorkerSocketPath(session.id);
// Send observation via Unix socket
const message = {
+2 -4
View File
@@ -1,7 +1,6 @@
import net from 'net';
import { join } from 'path';
import { HooksDatabase } from '../services/sqlite/HooksDatabase.js';
import { PathDiscovery } from '../services/path-discovery.js';
import { getWorkerSocketPath } from '../shared/paths.js';
export interface StopInput {
session_id: string;
@@ -29,8 +28,7 @@ export function summaryHook(input: StopInput): void {
}
// Get socket path
const dataDir = PathDiscovery.getInstance().getDataDirectory();
const socketPath = join(dataDir, `worker-${session.id}.sock`);
const socketPath = getWorkerSocketPath(session.id);
// Send FINALIZE message via Unix socket
const message = {