@zvirb/pinup-canvas 0.0.0-stage → 0.1.0
This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
- package/LICENSE +21 -0
- package/README.md +9 -2
- package/dist/agent/acp.d.ts +21 -0
- package/dist/agent/acp.d.ts.map +1 -0
- package/dist/agent/acp.js +248 -0
- package/dist/agent/acp.js.map +1 -0
- package/dist/agent/backend.d.ts +70 -0
- package/dist/agent/backend.d.ts.map +1 -0
- package/dist/agent/backend.js +112 -0
- package/dist/agent/backend.js.map +1 -0
- package/dist/agent/brief.d.ts +12 -0
- package/dist/agent/brief.d.ts.map +1 -0
- package/dist/agent/brief.js +35 -0
- package/dist/agent/brief.js.map +1 -0
- package/dist/agent/claude.d.ts +6 -0
- package/dist/agent/claude.d.ts.map +1 -0
- package/dist/agent/claude.js +104 -0
- package/dist/agent/claude.js.map +1 -0
- package/dist/agent/codex.d.ts +5 -0
- package/dist/agent/codex.d.ts.map +1 -0
- package/dist/agent/codex.js +127 -0
- package/dist/agent/codex.js.map +1 -0
- package/dist/agent/copies.d.ts +47 -0
- package/dist/agent/copies.d.ts.map +1 -0
- package/dist/agent/copies.js +229 -0
- package/dist/agent/copies.js.map +1 -0
- package/dist/agent/gemini.d.ts +5 -0
- package/dist/agent/gemini.d.ts.map +1 -0
- package/dist/agent/gemini.js +116 -0
- package/dist/agent/gemini.js.map +1 -0
- package/dist/agent/http.d.ts +4 -0
- package/dist/agent/http.d.ts.map +1 -0
- package/dist/agent/http.js +20 -0
- package/dist/agent/http.js.map +1 -0
- package/dist/agent/registry.d.ts +9 -0
- package/dist/agent/registry.d.ts.map +1 -0
- package/dist/agent/registry.js +43 -0
- package/dist/agent/registry.js.map +1 -0
- package/dist/agent/runner.d.ts +33 -0
- package/dist/agent/runner.d.ts.map +1 -0
- package/dist/agent/runner.js +377 -0
- package/dist/agent/runner.js.map +1 -0
- package/dist/agent/steps.d.ts +13 -0
- package/dist/agent/steps.d.ts.map +1 -0
- package/dist/agent/steps.js +88 -0
- package/dist/agent/steps.js.map +1 -0
- package/dist/agents.d.ts +5 -0
- package/dist/agents.d.ts.map +1 -0
- package/dist/agents.js +4 -0
- package/dist/agents.js.map +1 -0
- package/dist/branch-css.d.ts +7 -0
- package/dist/branch-css.d.ts.map +1 -0
- package/dist/branch-css.js +69 -0
- package/dist/branch-css.js.map +1 -0
- package/dist/branch-graph.d.ts +14 -0
- package/dist/branch-graph.d.ts.map +1 -0
- package/dist/branch-graph.js +83 -0
- package/dist/branch-graph.js.map +1 -0
- package/dist/branches.d.ts +29 -0
- package/dist/branches.d.ts.map +1 -0
- package/dist/branches.js +115 -0
- package/dist/branches.js.map +1 -0
- package/dist/client.css +1741 -0
- package/dist/client.js +12153 -0
- package/dist/client.js.map +1 -0
- package/dist/server.d.ts +10 -0
- package/dist/server.d.ts.map +1 -0
- package/dist/server.js +66 -0
- package/dist/server.js.map +1 -0
- package/dist/vite.d.ts +29 -0
- package/dist/vite.d.ts.map +1 -0
- package/dist/vite.js +286 -0
- package/dist/vite.js.map +1 -0
- package/package.json +53 -3
- package/src/agent/acp.ts +299 -0
- package/src/agent/backend.ts +168 -0
- package/src/agent/brief.ts +43 -0
- package/src/agent/claude.ts +142 -0
- package/src/agent/codex.ts +156 -0
- package/src/agent/copies.ts +272 -0
- package/src/agent/gemini.ts +150 -0
- package/src/agent/http.ts +26 -0
- package/src/agent/registry.ts +60 -0
- package/src/agent/runner.ts +423 -0
- package/src/agent/steps.ts +107 -0
- package/src/agents.ts +5 -0
- package/src/branch-css.ts +70 -0
- package/src/branch-graph.ts +100 -0
- package/src/branches.ts +132 -0
- package/src/canvas.css +110 -0
- package/src/server.ts +86 -0
- package/src/vite.ts +339 -0
|
@@ -0,0 +1,104 @@
|
|
|
1
|
+
import { allCommands, once, parseLine, probeVersion, run, } from "./backend.js";
|
|
2
|
+
import { clip, describeTool } from "./steps.js";
|
|
3
|
+
const TOOLS = ['Read', 'Edit', 'Write', 'Glob', 'Grep'];
|
|
4
|
+
export function claudeAllow(commands, options) {
|
|
5
|
+
return [...TOOLS, ...commands.map((c) => `Bash(${c}:*)`), ...(options.allow ?? [])];
|
|
6
|
+
}
|
|
7
|
+
export function claudeCommand(options, commands, session) {
|
|
8
|
+
return [
|
|
9
|
+
...(options.command ?? [
|
|
10
|
+
'claude',
|
|
11
|
+
'-p',
|
|
12
|
+
'--input-format',
|
|
13
|
+
'stream-json',
|
|
14
|
+
'--output-format',
|
|
15
|
+
'stream-json',
|
|
16
|
+
'--verbose',
|
|
17
|
+
'--permission-mode',
|
|
18
|
+
'acceptEdits',
|
|
19
|
+
]),
|
|
20
|
+
...(options.model === undefined ? [] : ['--model', options.model]),
|
|
21
|
+
...(session.resume === undefined ? [] : ['--resume', session.resume]),
|
|
22
|
+
...session.writable.flatMap((dir) => ['--add-dir', dir]),
|
|
23
|
+
'--append-system-prompt',
|
|
24
|
+
session.brief,
|
|
25
|
+
'--allowedTools',
|
|
26
|
+
claudeAllow(commands, options).join(','),
|
|
27
|
+
...(options.args ?? []),
|
|
28
|
+
];
|
|
29
|
+
}
|
|
30
|
+
export function claude(options, commands) {
|
|
31
|
+
const allowed = allCommands(commands);
|
|
32
|
+
return {
|
|
33
|
+
name: 'claude',
|
|
34
|
+
label: options.model === undefined ? 'Claude' : `Claude · ${options.model}`,
|
|
35
|
+
guard: `Edits files; runs only ${allowed.join(', ')}`,
|
|
36
|
+
tools: 'Read files with the Read tool and search with Grep and Glob, not the shell: only the commands listed run without asking, anything else is refused.',
|
|
37
|
+
check: () => probeVersion(options.command ?? ['claude']),
|
|
38
|
+
open: (session) => claudeSession(options, allowed, session),
|
|
39
|
+
};
|
|
40
|
+
}
|
|
41
|
+
function claudeSession(options, commands, session) {
|
|
42
|
+
let id = session.resume;
|
|
43
|
+
let settle;
|
|
44
|
+
let onStep = () => { };
|
|
45
|
+
let stopped = false;
|
|
46
|
+
const child = run(claudeCommand(options, commands, session), { cwd: session.cwd, env: session.env, stdin: 'pipe' }, (line) => {
|
|
47
|
+
const event = parseLine(line);
|
|
48
|
+
if (event === undefined)
|
|
49
|
+
return;
|
|
50
|
+
if (typeof event['session_id'] === 'string')
|
|
51
|
+
id = event['session_id'];
|
|
52
|
+
if (event['type'] === 'assistant') {
|
|
53
|
+
const message = event['message'];
|
|
54
|
+
for (const block of message?.content ?? []) {
|
|
55
|
+
if (block['type'] === 'text')
|
|
56
|
+
onStep({ kind: 'text', text: clip(String(block['text'] ?? ''), 280) });
|
|
57
|
+
if (block['type'] === 'tool_use')
|
|
58
|
+
onStep({
|
|
59
|
+
kind: 'tool',
|
|
60
|
+
text: describeTool(session.cwd, String(block['name'] ?? ''), (block['input'] ?? {})),
|
|
61
|
+
});
|
|
62
|
+
}
|
|
63
|
+
}
|
|
64
|
+
if (event['type'] === 'result') {
|
|
65
|
+
const text = String(event['result'] ?? '').trim();
|
|
66
|
+
settle?.(event['is_error'] === true ? { text, error: clip(text || 'error', 300) } : { text });
|
|
67
|
+
}
|
|
68
|
+
});
|
|
69
|
+
let exited = false;
|
|
70
|
+
child.proc.on('error', (failure) => {
|
|
71
|
+
exited = true;
|
|
72
|
+
settle?.({ text: '', error: `${options.command?.[0] ?? 'claude'}: ${failure.message}` });
|
|
73
|
+
});
|
|
74
|
+
child.proc.on('exit', (code, signal) => {
|
|
75
|
+
exited = true;
|
|
76
|
+
settle?.(stopped || signal === 'SIGTERM'
|
|
77
|
+
? { text: '', stopped: true }
|
|
78
|
+
: { text: '', error: `claude exited (${code ?? signal}): ${child.stderr()}` });
|
|
79
|
+
});
|
|
80
|
+
return {
|
|
81
|
+
turn(prompt, step) {
|
|
82
|
+
onStep = step;
|
|
83
|
+
return new Promise((done) => {
|
|
84
|
+
settle = once((result) => {
|
|
85
|
+
settle = undefined;
|
|
86
|
+
done(result);
|
|
87
|
+
});
|
|
88
|
+
if (exited)
|
|
89
|
+
return settle({ text: '', error: 'claude is not running' });
|
|
90
|
+
const message = { type: 'user', message: { role: 'user', content: prompt } };
|
|
91
|
+
child.proc.stdin?.write(`${JSON.stringify(message)}\n`);
|
|
92
|
+
});
|
|
93
|
+
},
|
|
94
|
+
id: () => id,
|
|
95
|
+
stop() {
|
|
96
|
+
stopped = true;
|
|
97
|
+
child.proc.kill('SIGTERM');
|
|
98
|
+
},
|
|
99
|
+
close() {
|
|
100
|
+
child.proc.stdin?.end();
|
|
101
|
+
},
|
|
102
|
+
};
|
|
103
|
+
}
|
|
104
|
+
//# sourceMappingURL=claude.js.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"claude.js","sourceRoot":"","sources":["../../src/agent/claude.ts"],"names":[],"mappings":"AAIA,OAAO,EAGL,WAAW,EACX,IAAI,EACJ,SAAS,EACT,YAAY,EACZ,GAAG,GAGJ,MAAM,cAAc,CAAA;AACrB,OAAO,EAAE,IAAI,EAAE,YAAY,EAAE,MAAM,YAAY,CAAA;AAE/C,MAAM,KAAK,GAAG,CAAC,MAAM,EAAE,MAAM,EAAE,OAAO,EAAE,MAAM,EAAE,MAAM,CAAC,CAAA;AAEvD,MAAM,UAAU,WAAW,CAAC,QAAkB,EAAE,OAAuB;IACrE,OAAO,CAAC,GAAG,KAAK,EAAE,GAAG,QAAQ,CAAC,GAAG,CAAC,CAAC,CAAC,EAAE,EAAE,CAAC,QAAQ,CAAC,KAAK,CAAC,EAAE,GAAG,CAAC,OAAO,CAAC,KAAK,IAAI,EAAE,CAAC,CAAC,CAAA;AACrF,CAAC;AAED,MAAM,UAAU,aAAa,CAC3B,OAAuB,EACvB,QAAkB,EAClB,OAA8D;IAE9D,OAAO;QACL,GAAG,CAAC,OAAO,CAAC,OAAO,IAAI;YACrB,QAAQ;YACR,IAAI;YACJ,gBAAgB;YAChB,aAAa;YACb,iBAAiB;YACjB,aAAa;YACb,WAAW;YACX,mBAAmB;YACnB,aAAa;SACd,CAAC;QACF,GAAG,CAAC,OAAO,CAAC,KAAK,KAAK,SAAS,CAAC,CAAC,CAAC,EAAE,CAAC,CAAC,CAA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,CAAC,CAAC,IAAI,EAAE,EAAE;gBAC1B,MAAM,GAAG,IAAI,CAAC,CAAC,MAAM,EAAE,EAAE;oBACvB,MAAM,GAAG,SAAS,CAAA;oBAClB,IAAI,CAAC,MAAM,CAAC,CAAA;gBACd,CAAC,CAAC,CAAA;gBACF,IAAI,MAAM;oBAAE,OAAO,MAAM,CAAC,EAAE,IAAI,EAAE,EAAE,EAAE,KAAK,EAAE,uBAAuB,EAAE,CAAC,CAAA;gBACvE,MAAM,OAAO,GAAG,EAAE,IAAI,EAAE,MAAM,EAAE,OAAO,EAAE,EAAE,IAAI,EAAE,MAAM,EAAE,OAAO,EAAE,MAAM,EAAE,EAAE,CAAA;gBAC5E,KAAK,CAAC,IAAI,CAAC,KAAK,EAAE,KAAK,CAAC,GAAG,IAAI,CAAC,SAAS,CAAC,OAAO,CAAC,IAAI,CAAC,CAAA;YACzD,CAAC,CAAC,CAAA;QACJ,CAAC;QACD,EAAE,EAAE,GAAG,EAAE,CAAC,EAAE;QACZ,IAAI;YACF,OAAO,GAAG,IAAI,CAAA;YACd,KAAK,CAAC,IAAI,CAAC,IAAI,CAAC,SAAS,CAAC,CAAA;QAC5B,CAAC;QACD,KAAK;YACH,KAAK,CAAC,IAAI,CAAC,KAAK,EAAE,GAAG,EAAE,CAAA;QACzB,CAAC;KACF,CAAA;AACH,CAAC"}
|
|
@@ -0,0 +1,5 @@
|
|
|
1
|
+
import type { BackendOptions } from '@zvirb/pinup-core';
|
|
2
|
+
import { type AgentBackend, type SessionOptions } from './backend.ts';
|
|
3
|
+
export declare function codexCommand(options: BackendOptions, session: Pick<SessionOptions, 'cwd' | 'writable'>, prompt: string, resume: string | undefined): string[];
|
|
4
|
+
export declare function codex(options: BackendOptions): AgentBackend;
|
|
5
|
+
//# sourceMappingURL=codex.d.ts.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"codex.d.ts","sourceRoot":"","sources":["../../src/agent/codex.ts"],"names":[],"mappings":"AAGA,OAAO,KAAK,EAAE,cAAc,EAAE,MAAM,mBAAmB,CAAA;AACvD,OAAO,EACL,KAAK,YAAY,EAMjB,KAAK,cAAc,EAEpB,MAAM,cAAc,CAAA;AAGrB,wBAAgB,YAAY,CAC1B,OAAO,EAAE,cAAc,EACvB,OAAO,EAAE,IAAI,CAAC,cAAc,EAAE,KAAK,GAAG,UAAU,CAAC,EACjD,MAAM,EAAE,MAAM,EACd,MAAM,EAAE,MAAM,GAAG,SAAS,GACzB,MAAM,EAAE,CAmBV;AAED,wBAAgB,KAAK,CAAC,OAAO,EAAE,cAAc,GAAG,YAAY,CAiB3D"}
|
|
@@ -0,0 +1,127 @@
|
|
|
1
|
+
import { once, parseLine, probeVersion, run, succeeds, } from "./backend.js";
|
|
2
|
+
import { clip, commandStep, toolStep } from "./steps.js";
|
|
3
|
+
export function codexCommand(options, session, prompt, resume) {
|
|
4
|
+
const head = options.command ?? ['codex', 'exec'];
|
|
5
|
+
// Sandbox and folders belong to `exec`; `resume` takes the session and the prompt.
|
|
6
|
+
const scope = [
|
|
7
|
+
'--sandbox',
|
|
8
|
+
'workspace-write',
|
|
9
|
+
'--cd',
|
|
10
|
+
session.cwd,
|
|
11
|
+
...session.writable.flatMap((dir) => ['--add-dir', dir]),
|
|
12
|
+
];
|
|
13
|
+
const own = [
|
|
14
|
+
'--json',
|
|
15
|
+
'--skip-git-repo-check',
|
|
16
|
+
...(options.model === undefined ? [] : ['--model', options.model]),
|
|
17
|
+
...(options.args ?? []),
|
|
18
|
+
];
|
|
19
|
+
return resume === undefined
|
|
20
|
+
? [...head, ...scope, ...own, prompt]
|
|
21
|
+
: [...head, ...scope, 'resume', ...own, resume, prompt];
|
|
22
|
+
}
|
|
23
|
+
export function codex(options) {
|
|
24
|
+
const bin = options.command ?? ['codex'];
|
|
25
|
+
return {
|
|
26
|
+
name: 'codex',
|
|
27
|
+
label: options.model === undefined ? 'Codex' : `Codex · ${options.model}`,
|
|
28
|
+
guard: 'Sandboxed to its folder, no network: may run any command there',
|
|
29
|
+
tools: 'Read and search with the shell (rg, sed -n, ls). You are sandboxed to this folder with no network: never install packages.',
|
|
30
|
+
async check() {
|
|
31
|
+
const version = await probeVersion(bin);
|
|
32
|
+
if (!version.ok || options.command !== undefined)
|
|
33
|
+
return version;
|
|
34
|
+
return (await succeeds(['codex', 'login', 'status']))
|
|
35
|
+
? version
|
|
36
|
+
: { ...version, ok: false, problem: 'codex is not signed in: run `codex login`' };
|
|
37
|
+
},
|
|
38
|
+
open: (session) => codexSession(options, session),
|
|
39
|
+
};
|
|
40
|
+
}
|
|
41
|
+
function codexSession(options, session) {
|
|
42
|
+
let id = session.resume;
|
|
43
|
+
let briefed = id !== undefined;
|
|
44
|
+
let current;
|
|
45
|
+
let stopped = false;
|
|
46
|
+
return {
|
|
47
|
+
turn(prompt, onStep) {
|
|
48
|
+
return new Promise((resolve) => {
|
|
49
|
+
const done = once(resolve);
|
|
50
|
+
// Codex has no system-prompt flag: the brief leads the session's first message.
|
|
51
|
+
const text = briefed ? prompt : `${session.brief}\n\n${prompt}`;
|
|
52
|
+
briefed = true;
|
|
53
|
+
let last = '';
|
|
54
|
+
let failure;
|
|
55
|
+
const onItem = (item, phase) => {
|
|
56
|
+
switch (item.type) {
|
|
57
|
+
case 'agent_message':
|
|
58
|
+
if (phase === 'item.completed') {
|
|
59
|
+
last = String(item['text'] ?? '');
|
|
60
|
+
onStep({ kind: 'text', text: clip(last, 280) });
|
|
61
|
+
}
|
|
62
|
+
break;
|
|
63
|
+
case 'command_execution':
|
|
64
|
+
if (phase === 'item.started')
|
|
65
|
+
onStep({ kind: 'tool', text: commandStep(session.cwd, String(item['command'])) });
|
|
66
|
+
break;
|
|
67
|
+
case 'file_change':
|
|
68
|
+
if (phase === 'item.completed')
|
|
69
|
+
for (const change of (item['changes'] ?? []))
|
|
70
|
+
onStep({
|
|
71
|
+
kind: 'tool',
|
|
72
|
+
text: toolStep(session.cwd, change.kind === 'add' ? 'write' : 'edit', change.path ?? ''),
|
|
73
|
+
});
|
|
74
|
+
break;
|
|
75
|
+
case 'mcp_tool_call':
|
|
76
|
+
if (phase === 'item.started')
|
|
77
|
+
onStep({ kind: 'tool', text: `${item['server']}: ${item['tool']}` });
|
|
78
|
+
break;
|
|
79
|
+
case 'web_search':
|
|
80
|
+
if (phase === 'item.started')
|
|
81
|
+
onStep({
|
|
82
|
+
kind: 'tool',
|
|
83
|
+
text: `Search the web "${clip(String(item['query']), 60)}"`,
|
|
84
|
+
});
|
|
85
|
+
break;
|
|
86
|
+
}
|
|
87
|
+
};
|
|
88
|
+
current = run(codexCommand(options, session, text, id), { cwd: session.cwd, env: session.env, stdin: 'ignore' }, (line) => {
|
|
89
|
+
const event = parseLine(line);
|
|
90
|
+
if (event === undefined)
|
|
91
|
+
return;
|
|
92
|
+
const type = String(event['type'] ?? '');
|
|
93
|
+
if (type === 'thread.started' && typeof event['thread_id'] === 'string')
|
|
94
|
+
id = event['thread_id'];
|
|
95
|
+
if (type.startsWith('item.'))
|
|
96
|
+
onItem((event['item'] ?? {}), type);
|
|
97
|
+
if (type === 'turn.failed')
|
|
98
|
+
failure = String(event['error']?.message ?? 'turn failed');
|
|
99
|
+
if (type === 'turn.completed')
|
|
100
|
+
done({ text: last });
|
|
101
|
+
});
|
|
102
|
+
const child = current;
|
|
103
|
+
child.proc.on('error', (error) => done({ text: '', error: `${options.command?.[0] ?? 'codex'}: ${error.message}` }));
|
|
104
|
+
child.proc.on('exit', (code, signal) => {
|
|
105
|
+
if (current === child)
|
|
106
|
+
current = undefined;
|
|
107
|
+
if (stopped || signal === 'SIGTERM')
|
|
108
|
+
return done({ text: last, stopped: true });
|
|
109
|
+
if (failure !== undefined)
|
|
110
|
+
return done({ text: last, error: clip(failure, 300) });
|
|
111
|
+
done(code === 0
|
|
112
|
+
? { text: last }
|
|
113
|
+
: { text: last, error: `codex exited (${code ?? signal}): ${child.stderr()}` });
|
|
114
|
+
});
|
|
115
|
+
});
|
|
116
|
+
},
|
|
117
|
+
id: () => id,
|
|
118
|
+
stop() {
|
|
119
|
+
stopped = true;
|
|
120
|
+
current?.proc.kill('SIGTERM');
|
|
121
|
+
},
|
|
122
|
+
close() {
|
|
123
|
+
current?.proc.kill('SIGTERM');
|
|
124
|
+
},
|
|
125
|
+
};
|
|
126
|
+
}
|
|
127
|
+
//# sourceMappingURL=codex.js.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"codex.js","sourceRoot":"","sources":["../../src/agent/codex.ts"],"names":[],"mappings":"AAIA,OAAO,EAGL,IAAI,EACJ,SAAS,EACT,YAAY,EACZ,GAAG,EAEH,QAAQ,GACT,MAAM,cAAc,CAAA;AACrB,OAAO,EAAE,IAAI,EAAE,WAAW,EAAE,QAAQ,EAAE,MAAM,YAAY,CAAA;AAExD,MAAM,UAAU,YAAY,CAC1B,OAAuB,EACvB,OAAiD,EACjD,MAAc,EACd,MAA0B;IAE1B,MAAM,IAAI,GAAG,OAAO,CAAC,OAAO,IAAI,CAAC,OAAO,EAAE,MAAM,CAAC,CAAA;IACjD,mFAAmF;IACnF,MAAM,KAAK,GAAG;QACZ,WAAW;QACX,iBAAiB;QACjB,MAAM;QACN,OAAO,CAAC,GAAG;QACX,GAAG,OAAO,CAAC,QAAQ,CAAC,OAAO,CAAC,CAAC,GAAG,EAAE,EAAE,CAAC,CAAC,WAAW,EAAE,GAAG,CAAC,CAAC;KACzD,CAAA;IACD,MAAM,GAAG,GAAG;QACV,QAAQ;QACR,uBAAuB;QACvB,GAAG,CAAC,OAAO,CAAC,KAAK,KAAK,SAAS,CAAC,CAAC,CAAC,EAAE,CAAC,CAAC,CAAC,CAAC,SAAS,EAAE,OAAO,CAAC,KAAK,CAAC,CAAC;QAClE,GAAG,CAAC,OAAO,CAAC,IAAI,IAAI,EAAE,CAAC;KACxB,CAAA;IACD,OAAO,MAAM,KAAK,SAAS;QACzB,CAAC,CAAC,CAAC,GAAG,IAAI,EAAE,GAAG,KAAK,EAAE,GAAG,GAAG,EAAE,MAAM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ACjF,CAAA;gBACH,CAAC,CAAC,CAAA;YACJ,CAAC,CAAC,CAAA;QACJ,CAAC;QACD,EAAE,EAAE,GAAG,EAAE,CAAC,EAAE;QACZ,IAAI;YACF,OAAO,GAAG,IAAI,CAAA;YACd,OAAO,EAAE,IAAI,CAAC,IAAI,CAAC,SAAS,CAAC,CAAA;QAC/B,CAAC;QACD,KAAK;YACH,OAAO,EAAE,IAAI,CAAC,IAAI,CAAC,SAAS,CAAC,CAAA;QAC/B,CAAC;KACF,CAAA;AACH,CAAC"}
|
|
@@ -0,0 +1,47 @@
|
|
|
1
|
+
import { BASES_DIR } from '../branches.ts';
|
|
2
|
+
export { BASES_DIR };
|
|
3
|
+
export interface CopyMeta {
|
|
4
|
+
/** Shown on the canvas: `Agent 2 · Codex (#14)`. */
|
|
5
|
+
label: string;
|
|
6
|
+
comment: string;
|
|
7
|
+
/** The worker that made it, and the backend it ran. */
|
|
8
|
+
agent: string;
|
|
9
|
+
backend: string;
|
|
10
|
+
/** The agent's session, to resume when the reviewer replies. */
|
|
11
|
+
session?: string;
|
|
12
|
+
createdAt: string;
|
|
13
|
+
}
|
|
14
|
+
export type Change = {
|
|
15
|
+
path: string;
|
|
16
|
+
kind: 'added' | 'modified' | 'deleted';
|
|
17
|
+
};
|
|
18
|
+
export type MergeResult = {
|
|
19
|
+
applied: string[];
|
|
20
|
+
} | {
|
|
21
|
+
conflicts: string[];
|
|
22
|
+
};
|
|
23
|
+
/** The project's own files: git's view when there is one (tracked and untracked, not ignored). */
|
|
24
|
+
export declare function projectFiles(root: string): string[];
|
|
25
|
+
/**
|
|
26
|
+
* `skip`: project-relative files a copy must not carry. The comments file: agents reply to the real
|
|
27
|
+
* one (PINUP_COMMENTS), and a stale copy would only mislead them.
|
|
28
|
+
*/
|
|
29
|
+
export declare function createCopies(root: string, skip?: string[]): {
|
|
30
|
+
dirOf: (id: string) => string;
|
|
31
|
+
meta: (id: string) => CopyMeta | undefined;
|
|
32
|
+
changes: (id: string) => Change[];
|
|
33
|
+
/** The comments that have a copy made by an agent. */
|
|
34
|
+
list(): string[];
|
|
35
|
+
/** A fresh copy of the project for one comment. */
|
|
36
|
+
create(id: string, info: CopyMeta): string;
|
|
37
|
+
update(id: string, patch: Partial<CopyMeta>): void;
|
|
38
|
+
/**
|
|
39
|
+
* Copies the change into the project. A file the reviewer edited meanwhile is merged three
|
|
40
|
+
* ways; if any file conflicts, nothing is applied, and the conflicted files are left in the
|
|
41
|
+
* copy with conflict markers, over the project's current version, for the agent to resolve.
|
|
42
|
+
*/
|
|
43
|
+
merge(id: string): MergeResult;
|
|
44
|
+
discard(id: string): void;
|
|
45
|
+
};
|
|
46
|
+
export type Copies = ReturnType<typeof createCopies>;
|
|
47
|
+
//# sourceMappingURL=copies.d.ts.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"copies.d.ts","sourceRoot":"","sources":["../../src/agent/copies.ts"],"names":[],"mappings":"AA0BA,OAAO,EAAE,SAAS,EAAgB,MAAM,gBAAgB,CAAA;AAExD,OAAO,EAAE,SAAS,EAAE,CAAA;AAMpB,MAAM,WAAW,QAAQ;IACvB,oDAAoD;IACpD,KAAK,EAAE,MAAM,CAAA;IACb,OAAO,EAAE,MAAM,CAAA;IACf,uDAAuD;IACvD,KAAK,EAAE,MAAM,CAAA;IACb,OAAO,EAAE,MAAM,CAAA;IACf,gEAAgE;IAChE,OAAO,CAAC,EAAE,MAAM,CAAA;IAChB,SAAS,EAAE,MAAM,CAAA;CAClB;AAED,MAAM,MAAM,MAAM,GAAG;IAAE,IAAI,EAAE,MAAM,CAAC;IAAC,IAAI,EAAE,OAAO,GAAG,UAAU,GAAG,SAAS,CAAA;CAAE,CAAA;AAE7E,MAAM,MAAM,WAAW,GAAG;IAAE,OAAO,EAAE,MAAM,EAAE,CAAA;CAAE,GAAG;IAAE,SAAS,EAAE,MAAM,EAAE,CAAA;CAAE,CAAA;AAezE,kGAAkG;AAClG,wBAAgB,YAAY,CAAC,IAAI,EAAE,MAAM,GAAG,MAAM,EAAE,CAenD;AA4DD;;;GAGG;AACH,wBAAgB,YAAY,CAAC,IAAI,EAAE,MAAM,EAAE,IAAI,GAAE,MAAM,EAAO;gBAGzC,MAAM;eAGP,MAAM,KAAG,QAAQ,GAAG,SAAS;kBAO1B,MAAM,KAAG,MAAM,EAAE;IAqBpC,sDAAsD;YAC9C,MAAM,EAAE;IAQhB,mDAAmD;eACxC,MAAM,QAAQ,QAAQ,GAAG,MAAM;eAwB/B,MAAM,SAAS,OAAO,CAAC,QAAQ,CAAC;IAM3C;;;;OAIG;cACO,MAAM,GAAG,WAAW;gBAyClB,MAAM;EAMrB;AAED,MAAM,MAAM,MAAM,GAAG,UAAU,CAAC,OAAO,YAAY,CAAC,CAAA"}
|
|
@@ -0,0 +1,229 @@
|
|
|
1
|
+
// Worktree isolation: each comment an agent takes gets its own copy of the project, under
|
|
2
|
+
// `.pinup/branches/<comment>/`, which the canvas already shows as a branch (../branches.ts): the
|
|
3
|
+
// change appears as a proposal next to the current design, live. Approve merges it back.
|
|
4
|
+
//
|
|
5
|
+
// .pinup/branches/<id>/ the copy the agent edits (the project's files, node_modules linked)
|
|
6
|
+
// .pinup/base/<id>/ the project as it was when the copy was made: the merge base
|
|
7
|
+
//
|
|
8
|
+
// A plain copy rather than `git worktree`: it carries the reviewer's uncommitted edits, needs no
|
|
9
|
+
// commits, and works without git (only a three-way merge of a file both sides changed needs it).
|
|
10
|
+
import { spawnSync } from 'node:child_process';
|
|
11
|
+
import { copyFileSync, existsSync, globSync, lstatSync, mkdirSync, mkdtempSync, readdirSync, readFileSync, rmSync, symlinkSync, unlinkSync, writeFileSync, } from 'node:fs';
|
|
12
|
+
import { tmpdir } from 'node:os';
|
|
13
|
+
import { dirname, join, sep } from 'node:path';
|
|
14
|
+
import { BASES_DIR, BRANCHES_DIR } from "../branches.js";
|
|
15
|
+
export { BASES_DIR };
|
|
16
|
+
const META = 'branch.json';
|
|
17
|
+
const SKIP = (name) => name === 'node_modules' || name === '.git' || name === '.pinup' || name === 'dist';
|
|
18
|
+
const posix = (path) => path.split(sep).join('/');
|
|
19
|
+
function read(path) {
|
|
20
|
+
try {
|
|
21
|
+
return readFileSync(path);
|
|
22
|
+
}
|
|
23
|
+
catch {
|
|
24
|
+
return undefined;
|
|
25
|
+
}
|
|
26
|
+
}
|
|
27
|
+
const same = (a, b) => a === undefined || b === undefined ? a === b : a.equals(b);
|
|
28
|
+
/** The project's own files: git's view when there is one (tracked and untracked, not ignored). */
|
|
29
|
+
export function projectFiles(root) {
|
|
30
|
+
const git = spawnSync('git', ['ls-files', '-co', '--exclude-standard', '-z'], {
|
|
31
|
+
cwd: root,
|
|
32
|
+
encoding: 'utf8',
|
|
33
|
+
maxBuffer: 64 * 1024 * 1024,
|
|
34
|
+
});
|
|
35
|
+
const files = git.status === 0 ? git.stdout.split('\0').filter(Boolean) : walk(root);
|
|
36
|
+
return files
|
|
37
|
+
.map(posix)
|
|
38
|
+
.filter((file) => !file.startsWith('.pinup/') &&
|
|
39
|
+
!file.split('/').includes('node_modules') &&
|
|
40
|
+
isFile(join(root, file)));
|
|
41
|
+
}
|
|
42
|
+
const isFile = (path) => {
|
|
43
|
+
try {
|
|
44
|
+
return lstatSync(path).isFile();
|
|
45
|
+
}
|
|
46
|
+
catch {
|
|
47
|
+
return false;
|
|
48
|
+
}
|
|
49
|
+
};
|
|
50
|
+
const walk = (dir) => globSync('**/*', { cwd: dir, exclude: SKIP })
|
|
51
|
+
.map(posix)
|
|
52
|
+
.filter((file) => isFile(join(dir, file)));
|
|
53
|
+
/** Files under a copy, project-relative, without its node_modules links or its metadata. */
|
|
54
|
+
const filesIn = (dir) => existsSync(dir) ? walk(dir).filter((file) => file !== META) : [];
|
|
55
|
+
function put(path, data) {
|
|
56
|
+
mkdirSync(dirname(path), { recursive: true });
|
|
57
|
+
writeFileSync(path, data);
|
|
58
|
+
}
|
|
59
|
+
/** A three-way merge of one file with `git merge-file`: the merged text and whether it conflicts. */
|
|
60
|
+
function mergeFile(mine, base, theirs) {
|
|
61
|
+
const tmp = mkdtempSync(join(tmpdir(), 'pinup-merge-'));
|
|
62
|
+
try {
|
|
63
|
+
const [a, b, c] = ['project', 'base', 'proposal'].map((name) => join(tmp, name));
|
|
64
|
+
writeFileSync(a, mine);
|
|
65
|
+
writeFileSync(b, base);
|
|
66
|
+
writeFileSync(c, theirs);
|
|
67
|
+
const result = spawnSync('git', [
|
|
68
|
+
'merge-file',
|
|
69
|
+
'-p',
|
|
70
|
+
'-L',
|
|
71
|
+
'project',
|
|
72
|
+
'-L',
|
|
73
|
+
'base',
|
|
74
|
+
'-L',
|
|
75
|
+
'proposal',
|
|
76
|
+
a,
|
|
77
|
+
b,
|
|
78
|
+
c,
|
|
79
|
+
]);
|
|
80
|
+
if (result.error !== undefined || result.status === null || result.status < 0)
|
|
81
|
+
return undefined;
|
|
82
|
+
return { text: result.stdout, conflict: result.status > 0 };
|
|
83
|
+
}
|
|
84
|
+
finally {
|
|
85
|
+
rmSync(tmp, { recursive: true, force: true });
|
|
86
|
+
}
|
|
87
|
+
}
|
|
88
|
+
/**
|
|
89
|
+
* `skip`: project-relative files a copy must not carry. The comments file: agents reply to the real
|
|
90
|
+
* one (PINUP_COMMENTS), and a stale copy would only mislead them.
|
|
91
|
+
*/
|
|
92
|
+
export function createCopies(root, skip = []) {
|
|
93
|
+
const branches = join(root, BRANCHES_DIR);
|
|
94
|
+
const bases = join(root, BASES_DIR);
|
|
95
|
+
const dirOf = (id) => join(branches, id);
|
|
96
|
+
const baseOf = (id) => join(bases, id);
|
|
97
|
+
const meta = (id) => {
|
|
98
|
+
const text = read(join(dirOf(id), META));
|
|
99
|
+
if (text === undefined)
|
|
100
|
+
return undefined;
|
|
101
|
+
const data = JSON.parse(text.toString('utf8'));
|
|
102
|
+
return typeof data.comment === 'string' ? data : undefined;
|
|
103
|
+
};
|
|
104
|
+
function changes(id) {
|
|
105
|
+
const dir = dirOf(id);
|
|
106
|
+
const base = baseOf(id);
|
|
107
|
+
const now = filesIn(dir);
|
|
108
|
+
const then = new Set(filesIn(base));
|
|
109
|
+
const out = [];
|
|
110
|
+
for (const file of now) {
|
|
111
|
+
const before = read(join(base, file));
|
|
112
|
+
if (before === undefined)
|
|
113
|
+
out.push({ path: file, kind: 'added' });
|
|
114
|
+
else if (!same(before, read(join(dir, file))))
|
|
115
|
+
out.push({ path: file, kind: 'modified' });
|
|
116
|
+
then.delete(file);
|
|
117
|
+
}
|
|
118
|
+
for (const file of then)
|
|
119
|
+
out.push({ path: file, kind: 'deleted' });
|
|
120
|
+
return out.sort((a, b) => a.path.localeCompare(b.path));
|
|
121
|
+
}
|
|
122
|
+
return {
|
|
123
|
+
dirOf,
|
|
124
|
+
meta,
|
|
125
|
+
changes,
|
|
126
|
+
/** The comments that have a copy made by an agent. */
|
|
127
|
+
list() {
|
|
128
|
+
if (!existsSync(branches))
|
|
129
|
+
return [];
|
|
130
|
+
return readdirSync(branches, { withFileTypes: true })
|
|
131
|
+
.filter((entry) => entry.isDirectory() && meta(entry.name) !== undefined)
|
|
132
|
+
.map((entry) => entry.name)
|
|
133
|
+
.sort();
|
|
134
|
+
},
|
|
135
|
+
/** A fresh copy of the project for one comment. */
|
|
136
|
+
create(id, info) {
|
|
137
|
+
const dir = dirOf(id);
|
|
138
|
+
const base = baseOf(id);
|
|
139
|
+
rmSync(dir, { recursive: true, force: true });
|
|
140
|
+
rmSync(base, { recursive: true, force: true });
|
|
141
|
+
const files = projectFiles(root).filter((file) => !skip.includes(file));
|
|
142
|
+
const folders = new Set(['']);
|
|
143
|
+
for (const file of files) {
|
|
144
|
+
const from = join(root, file);
|
|
145
|
+
mkdirSync(dirname(join(dir, file)), { recursive: true });
|
|
146
|
+
mkdirSync(dirname(join(base, file)), { recursive: true });
|
|
147
|
+
copyFileSync(from, join(dir, file));
|
|
148
|
+
copyFileSync(from, join(base, file));
|
|
149
|
+
for (let d = dirname(file); d !== '.' && d !== ''; d = dirname(d))
|
|
150
|
+
folders.add(d);
|
|
151
|
+
}
|
|
152
|
+
// Installed packages are shared, not copied: the copy resolves them as the project does.
|
|
153
|
+
for (const folder of folders) {
|
|
154
|
+
const modules = join(root, folder, 'node_modules');
|
|
155
|
+
if (existsSync(modules))
|
|
156
|
+
symlinkSync(modules, join(dir, folder, 'node_modules'), 'dir');
|
|
157
|
+
}
|
|
158
|
+
writeFileSync(join(dir, META), `${JSON.stringify(info, null, 2)}\n`);
|
|
159
|
+
return dir;
|
|
160
|
+
},
|
|
161
|
+
update(id, patch) {
|
|
162
|
+
const current = meta(id);
|
|
163
|
+
if (current === undefined)
|
|
164
|
+
return;
|
|
165
|
+
writeFileSync(join(dirOf(id), META), `${JSON.stringify({ ...current, ...patch }, null, 2)}\n`);
|
|
166
|
+
},
|
|
167
|
+
/**
|
|
168
|
+
* Copies the change into the project. A file the reviewer edited meanwhile is merged three
|
|
169
|
+
* ways; if any file conflicts, nothing is applied, and the conflicted files are left in the
|
|
170
|
+
* copy with conflict markers, over the project's current version, for the agent to resolve.
|
|
171
|
+
*/
|
|
172
|
+
merge(id) {
|
|
173
|
+
const dir = dirOf(id);
|
|
174
|
+
const base = baseOf(id);
|
|
175
|
+
const writes = [];
|
|
176
|
+
const conflicts = [];
|
|
177
|
+
for (const change of changes(id)) {
|
|
178
|
+
const mine = read(join(root, change.path));
|
|
179
|
+
const before = read(join(base, change.path));
|
|
180
|
+
const theirs = read(join(dir, change.path));
|
|
181
|
+
if (same(mine, before))
|
|
182
|
+
writes.push({ path: change.path, data: theirs });
|
|
183
|
+
else if (same(mine, theirs))
|
|
184
|
+
continue;
|
|
185
|
+
else if (mine !== undefined && before !== undefined && theirs !== undefined) {
|
|
186
|
+
const merged = mergeFile(mine, before, theirs);
|
|
187
|
+
if (merged !== undefined && !merged.conflict)
|
|
188
|
+
writes.push({ path: change.path, data: merged.text });
|
|
189
|
+
else
|
|
190
|
+
conflicts.push({
|
|
191
|
+
path: change.path,
|
|
192
|
+
current: mine,
|
|
193
|
+
...(merged === undefined ? {} : { text: merged.text }),
|
|
194
|
+
});
|
|
195
|
+
}
|
|
196
|
+
else
|
|
197
|
+
conflicts.push({ path: change.path, current: mine });
|
|
198
|
+
}
|
|
199
|
+
if (conflicts.length > 0) {
|
|
200
|
+
for (const conflict of conflicts) {
|
|
201
|
+
// The base moves to the project's current file, so once resolved the copy applies as is.
|
|
202
|
+
if (conflict.current === undefined)
|
|
203
|
+
rmSync(join(base, conflict.path), { force: true });
|
|
204
|
+
else
|
|
205
|
+
put(join(base, conflict.path), conflict.current);
|
|
206
|
+
if (conflict.text !== undefined)
|
|
207
|
+
put(join(dir, conflict.path), conflict.text);
|
|
208
|
+
}
|
|
209
|
+
return { conflicts: conflicts.map((c) => c.path) };
|
|
210
|
+
}
|
|
211
|
+
for (const write of writes) {
|
|
212
|
+
const target = join(root, write.path);
|
|
213
|
+
if (write.data === undefined) {
|
|
214
|
+
if (existsSync(target))
|
|
215
|
+
unlinkSync(target);
|
|
216
|
+
}
|
|
217
|
+
else
|
|
218
|
+
put(target, write.data);
|
|
219
|
+
}
|
|
220
|
+
return { applied: writes.map((w) => w.path) };
|
|
221
|
+
},
|
|
222
|
+
discard(id) {
|
|
223
|
+
// rm doesn't follow the node_modules links: it removes the links, not the packages.
|
|
224
|
+
rmSync(dirOf(id), { recursive: true, force: true });
|
|
225
|
+
rmSync(baseOf(id), { recursive: true, force: true });
|
|
226
|
+
},
|
|
227
|
+
};
|
|
228
|
+
}
|
|
229
|
+
//# sourceMappingURL=copies.js.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"copies.js","sourceRoot":"","sources":["../../src/agent/copies.ts"],"names":[],"mappings":"AAAA,0FAA0F;AAC1F,iGAAiG;AACjG,yFAAyF;AACzF,EAAE;AACF,gGAAgG;AAChG,yFAAyF;AACzF,EAAE;AACF,iGAAiG;AACjG,iGAAiG;AACjG,OAAO,EAAE,SAAS,EAAE,MAAM,oBAAoB,CAAA;AAC9C,OAAO,EACL,YAAY,EACZ,UAAU,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,CAAC,EAAU;YAChB,oFAAoF;YACpF,MAAM,CAAC,KAAK,CAAC,EAAE,CAAC,EAAE,EAAE,SAAS,EAAE,IAAI,EAAE,KAAK,EAAE,IAAI,EAAE,CAAC,CAAA;YACnD,MAAM,CAAC,MAAM,CAAC,EAAE,CAAC,EAAE,EAAE,SAAS,EAAE,IAAI,EAAE,KAAK,EAAE,IAAI,EAAE,CAAC,CAAA;QACtD,CAAC;KACF,CAAA;AACH,CAAC"}
|
|
@@ -0,0 +1,5 @@
|
|
|
1
|
+
import type { BackendOptions } from '@zvirb/pinup-core';
|
|
2
|
+
import { type AgentBackend, type SessionOptions } from './backend.ts';
|
|
3
|
+
export declare function geminiCommand(options: BackendOptions, commands: string[], session: Pick<SessionOptions, 'writable'>, prompt: string, resume: string | undefined): string[];
|
|
4
|
+
export declare function gemini(options: BackendOptions, commands: string[] | undefined): AgentBackend;
|
|
5
|
+
//# sourceMappingURL=gemini.d.ts.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"gemini.d.ts","sourceRoot":"","sources":["../../src/agent/gemini.ts"],"names":[],"mappings":"AAMA,OAAO,KAAK,EAAE,cAAc,EAAE,MAAM,mBAAmB,CAAA;AACvD,OAAO,EACL,KAAK,YAAY,EAOjB,KAAK,cAAc,EACpB,MAAM,cAAc,CAAA;AAGrB,wBAAgB,aAAa,CAC3B,OAAO,EAAE,cAAc,EACvB,QAAQ,EAAE,MAAM,EAAE,EAClB,OAAO,EAAE,IAAI,CAAC,cAAc,EAAE,UAAU,CAAC,EACzC,MAAM,EAAE,MAAM,EACd,MAAM,EAAE,MAAM,GAAG,SAAS,GACzB,MAAM,EAAE,CAgBV;AAED,wBAAgB,MAAM,CAAC,OAAO,EAAE,cAAc,EAAE,QAAQ,EAAE,MAAM,EAAE,GAAG,SAAS,GAAG,YAAY,CAW5F"}
|