feat: Add agent preview integration with auto-teardown and simplified commands
- Add agentId label to preview containers (cw.agent-id) for tracking - Add startForAgent/stopByAgentId methods to PreviewManager - Auto-teardown: previews torn down on agent:stopped event - Conditional preview prompt injection for execute/refine/discuss agents - Agent-simplified CLI: cw preview start/stop --agent <id> - cw preview setup command with --auto mode for guided config generation - hasPreviewConfig hint on cw project register output - New tRPC procedures: startPreviewForAgent, stopPreviewByAgent
This commit is contained in:
@@ -5,7 +5,7 @@
|
||||
import { TRPCError } from '@trpc/server';
|
||||
import { z } from 'zod';
|
||||
import { join } from 'node:path';
|
||||
import { rm } from 'node:fs/promises';
|
||||
import { rm, access } from 'node:fs/promises';
|
||||
import type { ProcedureBuilder } from '../trpc.js';
|
||||
import { requireProjectRepository, requireProjectSyncManager } from './_helpers.js';
|
||||
import { cloneProject } from '../../git/clone.js';
|
||||
@@ -69,7 +69,17 @@ export function projectProcedures(publicProcedure: ProcedureBuilder) {
|
||||
}
|
||||
}
|
||||
|
||||
return project;
|
||||
// Check for preview config
|
||||
let hasPreviewConfig = false;
|
||||
if (ctx.workspaceRoot) {
|
||||
const clonePath = join(ctx.workspaceRoot, getProjectCloneDir(input.name, project.id));
|
||||
try {
|
||||
await access(join(clonePath, '.cw-preview.yml'));
|
||||
hasPreviewConfig = true;
|
||||
} catch { /* no config */ }
|
||||
}
|
||||
|
||||
return { ...project, hasPreviewConfig };
|
||||
}),
|
||||
|
||||
listProjects: publicProcedure
|
||||
|
||||
Reference in New Issue
Block a user