mirror of
https://github.com/Ark0N/Codeman.git
synced 2026-10-06 15:39:41 +02:00
review fixes: every claude create path routes through the workspace-hooks decision
Post-#304 follow-ups. The install-vs-refresh decision (workspaceHooksEnabled, default ON) moved from a session-routes-local helper into hooks-config.ts as applyWorkspaceHooks(workspace, install?), and the claude session-create sites that bypassed it now go through it: cron job fires (cron-service), legacy scheduled-run iterations (runScheduledLoop), and the plan-orchestrator research and planner one-shots. A cron or scheduled run firing in a linked case that never had an interactive session ran hook-blind (no stop for completion detection, no tab alert on a blocking dialog). The shared core also carries the two guards every caller needs: a workspace that no longer exists is skipped (ensureCodemanHooks mkdir -p's, so the boot recovery sweep used to resurrect a deleted repo as an empty tree holding only .claude/settings.local.json), and all errors are swallowed since a create must never fail on hooks. Route handlers keep resolving the setting through their ConfigPort and pass it in; non-route callers omit it and the core reads settings.json itself (absent key or unreadable file = ON). Two adjacent gates tightened in session-routes: - the docker quick-start hooks branch excluded the five external CLIs but let `shell` through, contradicting its own rule that only claude reads .claude hooks; it is now gated on mode === 'claude' - the statusLine exporter call in POST /api/sessions got the same !remote && body.workingDir guard the hooks call got in499d355(it mkdirs the same way, so a remote attach created a junk user@host:session dir locally and a cwd-fallback create wrote into $HOME) plan-routes' one-shot deliberately stays out: its workingDir is process.cwd(), exactly the target499d355forbids writing into. restoreMuxSessions stays out too: the boot sweep already covers recovered workspaces. Tests: quick-start existing-case install, docker claude-installs/shell-does-not, and the core directly (default-ON install, OFF add-nothing, OFF still heals a stale block, malformed file untouched, vanished workspace skipped); the remote and cwd-fallback regressions now also send statusLineTelemetry:true to pin the statusLine guard. Co-Authored-By: Claude Fable 5 <noreply@anthropic.com>
This commit is contained in:
@@ -20,6 +20,7 @@ import type { TerminalMultiplexer } from './mux-interface.js';
|
||||
import { existsSync, mkdirSync, writeFileSync } from 'node:fs';
|
||||
import { join } from 'node:path';
|
||||
import { RESEARCH_AGENT_PROMPT, PLANNER_PROMPT } from './prompts/index.js';
|
||||
import { applyWorkspaceHooks } from './hooks-config.js';
|
||||
import { getErrorMessage, type PlanItem, type ClaudeMode } from './types.js';
|
||||
|
||||
// Re-export for backward compatibility
|
||||
@@ -429,6 +430,11 @@ export class PlanOrchestrator {
|
||||
detail: 'Researching...',
|
||||
});
|
||||
|
||||
// Workspace hooks for the case this plan targets (see applyWorkspaceHooks in
|
||||
// hooks-config): claude-mode, local workingDir, and the helper itself skips a
|
||||
// vanished dir + swallows failures — the plan run must never fail on hooks.
|
||||
await applyWorkspaceHooks(this.workingDir);
|
||||
|
||||
const session = new Session({
|
||||
workingDir: this.workingDir,
|
||||
mux: this.mux,
|
||||
@@ -591,6 +597,10 @@ export class PlanOrchestrator {
|
||||
detail: 'Generating plan...',
|
||||
});
|
||||
|
||||
// Workspace hooks: same rationale as the research one-shot above (idempotent —
|
||||
// the helper short-circuits when the hooks block is already current).
|
||||
await applyWorkspaceHooks(this.workingDir);
|
||||
|
||||
const session = new Session({
|
||||
workingDir: this.workingDir,
|
||||
mux: this.mux,
|
||||
|
||||
Reference in New Issue
Block a user