Compare commits
8 Commits
| Author | SHA1 | Date | |
|---|---|---|---|
| 5a63d09f2f | |||
| 19b5272f38 | |||
| 1337907df3 | |||
| 490bbe29c9 | |||
| 0eef347336 | |||
| 243e611eeb | |||
| 985238403f | |||
| af3f96379a |
Binary file not shown.
|
Before Width: | Height: | Size: 366 KiB |
+9
-23
@@ -7,12 +7,7 @@ import path from 'node:path';
|
|||||||
const execFileP = promisify(execFile);
|
const execFileP = promisify(execFile);
|
||||||
|
|
||||||
// Each entry defines how to invoke the agent in non-interactive "one-shot" mode.
|
// Each entry defines how to invoke the agent in non-interactive "one-shot" mode.
|
||||||
// `buildArgs(prompt, imagePaths, extraAllowedDirs)` returns argv for the child
|
// `buildArgs(prompt, imagePaths)` returns argv for the child process.
|
||||||
// process. `extraAllowedDirs` is a list of absolute directories the agent must
|
|
||||||
// be permitted to read files from (skill seeds, design-system specs) that live
|
|
||||||
// outside the project cwd. Currently only Claude Code wires this through
|
|
||||||
// (`--add-dir`); other agents either inherit broader access or run with cwd
|
|
||||||
// boundaries we can't widen via flags.
|
|
||||||
// `streamFormat` hints to the daemon how to interpret stdout:
|
// `streamFormat` hints to the daemon how to interpret stdout:
|
||||||
// - 'claude-stream-json' : line-delimited JSON emitted by Claude Code's
|
// - 'claude-stream-json' : line-delimited JSON emitted by Claude Code's
|
||||||
// `--output-format stream-json`. Daemon parses it into typed events
|
// `--output-format stream-json`. Daemon parses it into typed events
|
||||||
@@ -24,23 +19,14 @@ export const AGENT_DEFS = [
|
|||||||
name: 'Claude Code',
|
name: 'Claude Code',
|
||||||
bin: 'claude',
|
bin: 'claude',
|
||||||
versionArgs: ['--version'],
|
versionArgs: ['--version'],
|
||||||
buildArgs: (prompt, _imagePaths, extraAllowedDirs = []) => {
|
buildArgs: (prompt) => [
|
||||||
const args = [
|
'-p',
|
||||||
'-p',
|
prompt,
|
||||||
prompt,
|
'--output-format',
|
||||||
'--output-format',
|
'stream-json',
|
||||||
'stream-json',
|
'--verbose',
|
||||||
'--verbose',
|
'--include-partial-messages',
|
||||||
'--include-partial-messages',
|
],
|
||||||
];
|
|
||||||
const dirs = (extraAllowedDirs || []).filter(
|
|
||||||
(d) => typeof d === 'string' && d.length > 0,
|
|
||||||
);
|
|
||||||
if (dirs.length > 0) {
|
|
||||||
args.push('--add-dir', ...dirs);
|
|
||||||
}
|
|
||||||
return args;
|
|
||||||
},
|
|
||||||
streamFormat: 'claude-stream-json',
|
streamFormat: 'claude-stream-json',
|
||||||
},
|
},
|
||||||
{
|
{
|
||||||
|
|||||||
+1
-11
@@ -769,17 +769,7 @@ export async function startServer({ port = 7456 } = {}) {
|
|||||||
safeImages.length ? `\n\n${safeImages.map((p) => `@${p}`).join(' ')}` : '',
|
safeImages.length ? `\n\n${safeImages.map((p) => `@${p}`).join(' ')}` : '',
|
||||||
].join('');
|
].join('');
|
||||||
|
|
||||||
// Skill seeds (`skills/<id>/assets/template.html`) and design-system
|
const args = def.buildArgs(composed, safeImages);
|
||||||
// specs (`design-systems/<id>/DESIGN.md`) live outside the project cwd.
|
|
||||||
// The composed system prompt asks the agent to Read them via absolute
|
|
||||||
// paths in the skill-root preamble — without an explicit allowlist,
|
|
||||||
// Claude Code blocks those reads (issue #6: "no permission to read
|
|
||||||
// skills template"). We surface both roots so any agent that honours
|
|
||||||
// `--add-dir` can resolve those side files.
|
|
||||||
const extraAllowedDirs = [SKILLS_DIR, DESIGN_SYSTEMS_DIR].filter(
|
|
||||||
(d) => fs.existsSync(d),
|
|
||||||
);
|
|
||||||
const args = def.buildArgs(composed, safeImages, extraAllowedDirs);
|
|
||||||
|
|
||||||
res.setHeader('Content-Type', 'text/event-stream');
|
res.setHeader('Content-Type', 'text/event-stream');
|
||||||
res.setHeader('Cache-Control', 'no-cache, no-transform');
|
res.setHeader('Cache-Control', 'no-cache, no-transform');
|
||||||
|
|||||||
+1
-1
@@ -11,7 +11,7 @@
|
|||||||
"scripts": {
|
"scripts": {
|
||||||
"daemon": "node daemon/cli.js --no-open",
|
"daemon": "node daemon/cli.js --no-open",
|
||||||
"dev": "vite",
|
"dev": "vite",
|
||||||
"dev:all": "node scripts/dev-all.mjs",
|
"dev:all": "concurrently -k -n daemon,web -c cyan,magenta \"npm:daemon\" \"npm:dev\"",
|
||||||
"build": "tsc -b && vite build",
|
"build": "tsc -b && vite build",
|
||||||
"preview": "vite preview",
|
"preview": "vite preview",
|
||||||
"typecheck": "tsc -b --noEmit",
|
"typecheck": "tsc -b --noEmit",
|
||||||
|
|||||||
@@ -1,84 +0,0 @@
|
|||||||
#!/usr/bin/env node
|
|
||||||
// Launcher for `npm run dev:all`.
|
|
||||||
//
|
|
||||||
// Probes for free ports for the daemon (OD_PORT, default 7456) and the Vite
|
|
||||||
// dev server (VITE_PORT, default 5173) before spawning `concurrently`, so a
|
|
||||||
// stray process holding either port doesn't kill the whole boot. The
|
|
||||||
// resolved ports are exported into the child env, which means:
|
|
||||||
// * the daemon's cli.js sees the new OD_PORT and binds to it
|
|
||||||
// * vite.config.ts reads the same OD_PORT and points its /api proxy at
|
|
||||||
// the daemon's actual port
|
|
||||||
// * Vite itself binds to VITE_PORT
|
|
||||||
//
|
|
||||||
// If a port is busy we walk forward up to PORT_SEARCH_RANGE steps and log
|
|
||||||
// the switch so the user notices.
|
|
||||||
|
|
||||||
import { spawn } from 'node:child_process';
|
|
||||||
import net from 'node:net';
|
|
||||||
|
|
||||||
const HOST = '127.0.0.1';
|
|
||||||
const PORT_SEARCH_RANGE = 50;
|
|
||||||
|
|
||||||
function isPortFree(port, host = HOST) {
|
|
||||||
return new Promise((resolve) => {
|
|
||||||
const server = net.createServer();
|
|
||||||
server.unref();
|
|
||||||
server.once('error', () => resolve(false));
|
|
||||||
server.listen({ port, host, exclusive: true }, () => {
|
|
||||||
server.close(() => resolve(true));
|
|
||||||
});
|
|
||||||
});
|
|
||||||
}
|
|
||||||
|
|
||||||
async function findFreePort(start, label) {
|
|
||||||
for (let port = start; port < start + PORT_SEARCH_RANGE; port++) {
|
|
||||||
if (await isPortFree(port)) return port;
|
|
||||||
}
|
|
||||||
throw new Error(
|
|
||||||
`[dev:all] could not find a free ${label} port near ${start} (tried ${PORT_SEARCH_RANGE})`,
|
|
||||||
);
|
|
||||||
}
|
|
||||||
|
|
||||||
const desiredDaemon = Number(process.env.OD_PORT) || 7456;
|
|
||||||
const desiredVite = Number(process.env.VITE_PORT) || 5173;
|
|
||||||
|
|
||||||
const daemonPort = await findFreePort(desiredDaemon, 'daemon');
|
|
||||||
const vitePort = await findFreePort(desiredVite, 'vite');
|
|
||||||
|
|
||||||
if (daemonPort !== desiredDaemon) {
|
|
||||||
console.log(
|
|
||||||
`[dev:all] daemon port ${desiredDaemon} is busy, switching to ${daemonPort}`,
|
|
||||||
);
|
|
||||||
}
|
|
||||||
if (vitePort !== desiredVite) {
|
|
||||||
console.log(
|
|
||||||
`[dev:all] vite port ${desiredVite} is busy, switching to ${vitePort}`,
|
|
||||||
);
|
|
||||||
}
|
|
||||||
|
|
||||||
const env = {
|
|
||||||
...process.env,
|
|
||||||
OD_PORT: String(daemonPort),
|
|
||||||
VITE_PORT: String(vitePort),
|
|
||||||
};
|
|
||||||
|
|
||||||
// We spawn the local `concurrently` bin via shell so Windows .cmd shims
|
|
||||||
// resolve correctly. The `npm:daemon` / `npm:dev` shorthand runs the
|
|
||||||
// matching package.json scripts, so any future tweak to those scripts is
|
|
||||||
// picked up automatically.
|
|
||||||
const child = spawn(
|
|
||||||
'concurrently',
|
|
||||||
['-k', '-n', 'daemon,web', '-c', 'cyan,magenta', 'npm:daemon', 'npm:dev'],
|
|
||||||
{ env, stdio: 'inherit', shell: true },
|
|
||||||
);
|
|
||||||
|
|
||||||
child.on('exit', (code, signal) => {
|
|
||||||
if (signal) process.kill(process.pid, signal);
|
|
||||||
else process.exit(code ?? 0);
|
|
||||||
});
|
|
||||||
|
|
||||||
for (const sig of ['SIGINT', 'SIGTERM']) {
|
|
||||||
process.on(sig, () => {
|
|
||||||
if (!child.killed) child.kill(sig);
|
|
||||||
});
|
|
||||||
}
|
|
||||||
@@ -116,7 +116,6 @@ export function App() {
|
|||||||
const withOnboarding: AppConfig = { ...next, onboardingCompleted: true };
|
const withOnboarding: AppConfig = { ...next, onboardingCompleted: true };
|
||||||
saveConfig(withOnboarding);
|
saveConfig(withOnboarding);
|
||||||
setConfig(withOnboarding);
|
setConfig(withOnboarding);
|
||||||
setSettingsOpen(false);
|
|
||||||
}, []);
|
}, []);
|
||||||
|
|
||||||
const handleModeChange = useCallback(
|
const handleModeChange = useCallback(
|
||||||
|
|||||||
@@ -276,7 +276,10 @@ export function SettingsDialog({
|
|||||||
type="button"
|
type="button"
|
||||||
className="primary"
|
className="primary"
|
||||||
disabled={!canSave}
|
disabled={!canSave}
|
||||||
onClick={() => onSave(cfg)}
|
onClick={() => {
|
||||||
|
onSave(cfg);
|
||||||
|
onClose();
|
||||||
|
}}
|
||||||
>
|
>
|
||||||
{welcome ? t('settings.getStarted') : t('common.save')}
|
{welcome ? t('settings.getStarted') : t('common.save')}
|
||||||
</button>
|
</button>
|
||||||
|
|||||||
+1
-2
@@ -2,12 +2,11 @@ import { defineConfig } from 'vite';
|
|||||||
import react from '@vitejs/plugin-react';
|
import react from '@vitejs/plugin-react';
|
||||||
|
|
||||||
const DAEMON_PORT = Number(process.env.OD_PORT) || 7456;
|
const DAEMON_PORT = Number(process.env.OD_PORT) || 7456;
|
||||||
const VITE_PORT = Number(process.env.VITE_PORT) || 5173;
|
|
||||||
|
|
||||||
export default defineConfig({
|
export default defineConfig({
|
||||||
plugins: [react()],
|
plugins: [react()],
|
||||||
server: {
|
server: {
|
||||||
port: VITE_PORT,
|
port: 5173,
|
||||||
proxy: {
|
proxy: {
|
||||||
'/api': {
|
'/api': {
|
||||||
target: `http://127.0.0.1:${DAEMON_PORT}`,
|
target: `http://127.0.0.1:${DAEMON_PORT}`,
|
||||||
|
|||||||
Reference in New Issue
Block a user