@ngockhoale/ckit 0.2.3 → 0.2.5
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/README.md +1 -1
- package/dist/src/gui/server.d.ts +2 -0
- package/dist/src/gui/server.js +34 -9
- package/gui/app.css +8 -0
- package/gui/app.js +28 -9
- package/gui/explorer.js +9 -4
- package/gui/index.html +1 -0
- package/package.json +1 -1
package/README.md
CHANGED
|
@@ -30,7 +30,7 @@ ckit team --init # write the default .ckit/team.json (--force overwrites
|
|
|
30
30
|
```
|
|
31
31
|
- Teams are configurable in Config: only the Director is mandatory; BA, Implement and QC can each be removed or re-added, and `+ Add team` creates your own team (`extraTeams` in `.ckit/team.json`: name, mission, agents). All teams follow one numbered flow, `order` (e.g. `["ba","implement","test","qc"]`, reorder with the arrows in Config; absent = ba, implement, qc with custom teams placed by the old `runAfter`): work goes Director -> team 1 -> team 2 ..., each team gets the Director's brief and the previous team's output. A team can end its message with `ASK PREVIOUS: <question>` (the team before it, or the Director, answers) or `RETURN TO PREVIOUS: <reason>` (QC's FAIL means the same); both are limited to `limits.qcLoops` per team boundary ("Max send-backs per team"). Each agent (Director too) also has an optional `cliArgs` text box ("Extra CLI arguments"), e.g. `--settings ./other-settings.json`: it is split like a shell would (quotes group; `~` and `$HOME` become your home folder, other `$VAR` are not expanded), appended to that agent's start command after CKit's own flags and before the prompt, and empty means not used.
|
|
32
32
|
|
|
33
|
-
Every run is journaled to `.ckit/team/runs/<runId>/` (`events.jsonl`, `handoff-ba.md`, `qc-report-N.md`, `transcript.md`, `report.md`). Real agents use their own CLI login; codex runs `read-only` unless the agent has `access: "write"` (then `workspace-write`), claude uses `acceptEdits` only for write access, never bypass.
|
|
33
|
+
The Runs list replays a past run at 1×, 2× or 4×; the row being replayed is marked REPLAYING with a Stop button (also in the header), other rows show READY, and pressing another speed restarts the replay at that speed. Every run is journaled to `.ckit/team/runs/<runId>/` (`events.jsonl`, `handoff-ba.md`, `qc-report-N.md`, `transcript.md`, `report.md`). Real agents use their own CLI login; codex runs `read-only` unless the agent has `access: "write"` (then `workspace-write`), claude uses `acceptEdits` only for write access, never bypass.
|
|
34
34
|
|
|
35
35
|
`ckit gui` network settings (all optional): flags > shell env > the folder's env file > `.ckit/gui.json` > default `127.0.0.1:4317`; see `.env.example`. The earlier `ckit run` command (API advisor + single executor) was removed on 2026-11-14; use the GUI or `ckit team`.
|
|
36
36
|
|
package/dist/src/gui/server.d.ts
CHANGED
|
@@ -10,6 +10,8 @@ export interface GuiServer {
|
|
|
10
10
|
url: string;
|
|
11
11
|
close(): Promise<void>;
|
|
12
12
|
}
|
|
13
|
+
/** Version in package.json right now. The page compares it with the version this process started with: after an update the files on disk are newer than the running server, and new screens would call routes it does not have. */
|
|
14
|
+
export declare function packageVersion(file?: string): string;
|
|
13
15
|
export declare function openBrowser(url: string, platform?: NodeJS.Platform): void;
|
|
14
16
|
/** The instruction that turns an owner's rough request into a brief the Director can act on. Pure. Exported for tests. */
|
|
15
17
|
export declare function requestEnhancePrompt(draft: string, ctx: {
|
package/dist/src/gui/server.js
CHANGED
|
@@ -23,6 +23,17 @@ import { DEFAULT_MISSIONS, allAgentsOf, effectiveOrder } from '../team/types.js'
|
|
|
23
23
|
import { mkdirSync, writeFileSync } from 'node:fs';
|
|
24
24
|
import { dirname } from 'node:path';
|
|
25
25
|
const GUI_DIR = resolve(fileURLToPath(new URL('../../../gui/', import.meta.url)));
|
|
26
|
+
/** Version in package.json right now. The page compares it with the version this process started with: after an update the files on disk are newer than the running server, and new screens would call routes it does not have. */
|
|
27
|
+
export function packageVersion(file = fileURLToPath(new URL('../../../package.json', import.meta.url))) {
|
|
28
|
+
try {
|
|
29
|
+
const v = JSON.parse(readFileSync(file, 'utf8')).version;
|
|
30
|
+
return typeof v === 'string' ? v : '';
|
|
31
|
+
}
|
|
32
|
+
catch {
|
|
33
|
+
return '';
|
|
34
|
+
}
|
|
35
|
+
}
|
|
36
|
+
const START_VERSION = packageVersion();
|
|
26
37
|
const MIME = { '.html': 'text/html; charset=utf-8', '.css': 'text/css; charset=utf-8', '.js': 'text/javascript; charset=utf-8', '.json': 'application/json; charset=utf-8', '.svg': 'image/svg+xml', '.png': 'image/png', '.ico': 'image/x-icon' };
|
|
27
38
|
const ARTIFACT_RE = /^(report\.md|transcript\.md|handoff-ba\.md|qc-report-\d{1,3}\.md)$/;
|
|
28
39
|
const RUN_ID_RE = /^team-\d{8}-\d{6}-[0-9a-f]{4}$/;
|
|
@@ -93,9 +104,9 @@ export async function startGuiServer(opts) {
|
|
|
93
104
|
const sse = new Set();
|
|
94
105
|
let unsub = null;
|
|
95
106
|
const sendEvent = (res, e) => { res.write(`data: ${JSON.stringify(e)}\n\n`); };
|
|
96
|
-
const attach = (handle, goal, simulated) => {
|
|
107
|
+
const attach = (handle, goal, simulated, replay) => {
|
|
97
108
|
unsub?.();
|
|
98
|
-
const cur = { handle, goal, simulated, startedAt: new Date().toISOString(), outcome: null };
|
|
109
|
+
const cur = { handle, goal, simulated, startedAt: new Date().toISOString(), outcome: null, ...(replay ? { replay } : {}) };
|
|
99
110
|
current = cur;
|
|
100
111
|
for (const r of sse)
|
|
101
112
|
r.write('event: reset\ndata: {}\n\n');
|
|
@@ -178,8 +189,8 @@ export async function startGuiServer(opts) {
|
|
|
178
189
|
if (m === 'GET' && p === '/api/state') {
|
|
179
190
|
const c = loadConfig();
|
|
180
191
|
const configured = allAgents(c).some(a => a.cli !== 'auto' && a.cli !== 'simulated');
|
|
181
|
-
return json(res, 200, { config: publicConfig(c), configExists: existsSync(teamConfigPath(root)), projectRoot: root, simulatedDefault: !configured,
|
|
182
|
-
run: current ? { runId: current.handle.runId, goal: current.goal, simulated: current.simulated, startedAt: current.startedAt, running: current.outcome === null, outcome: current.outcome } : null });
|
|
192
|
+
return json(res, 200, { config: publicConfig(c), configExists: existsSync(teamConfigPath(root)), projectRoot: root, version: START_VERSION, diskVersion: packageVersion(), simulatedDefault: !configured,
|
|
193
|
+
run: current ? { runId: current.handle.runId, goal: current.goal, simulated: current.simulated, startedAt: current.startedAt, running: current.outcome === null, outcome: current.outcome, ...(current.replay ? { replay: current.replay } : {}) } : null });
|
|
183
194
|
}
|
|
184
195
|
if (m === 'PUT' && p === '/api/config') {
|
|
185
196
|
const body = await readBody(req);
|
|
@@ -236,7 +247,8 @@ export async function startGuiServer(opts) {
|
|
|
236
247
|
const lane = ev.find(e => e.type === 'lane.chosen');
|
|
237
248
|
return { runId: r.runId, goal, outcome, lane: lane && lane.type === 'lane.chosen' ? lane.name : null, waiting: last?.type === 'run.waiting', startedAt: first?.at ?? null, durationMs, simulated: first?.type === 'run.started' ? first.simulated : false };
|
|
238
249
|
});
|
|
239
|
-
|
|
250
|
+
// The run on screen right now (a real run or a playback), so the list can mark its row and offer Stop.
|
|
251
|
+
return json(res, 200, { runs, active: isRunning() && current ? { runId: current.handle.runId, replay: !!current.replay, speed: current.replay?.speed ?? null } : null });
|
|
240
252
|
}
|
|
241
253
|
if (m === 'POST' && p === '/api/uploads') {
|
|
242
254
|
// Raw file body (any type), name in ?name=. Streamed to disk, never parsed or executed here.
|
|
@@ -289,14 +301,17 @@ export async function startGuiServer(opts) {
|
|
|
289
301
|
if (rp) {
|
|
290
302
|
const id = decodeURIComponent(rp[1]);
|
|
291
303
|
if (m === 'POST' && rp[2] === 'replay') {
|
|
292
|
-
|
|
304
|
+
// A playback may be replaced by another playback (other run or other speed); a real run is never interrupted this way.
|
|
305
|
+
if (isRunning() && !current?.replay)
|
|
293
306
|
return json(res, 409, { error: 'a run is already active' });
|
|
294
307
|
const dir = runDirOf(id);
|
|
295
308
|
if (!dir || id === 'current')
|
|
296
309
|
return json(res, 404, { error: 'unknown run' });
|
|
297
|
-
const
|
|
298
|
-
|
|
299
|
-
|
|
310
|
+
const asked = Number(obj(await readBody(req))['speed']), speed = [1, 2, 4].includes(asked) ? asked : 1;
|
|
311
|
+
if (isRunning())
|
|
312
|
+
current?.handle.stop();
|
|
313
|
+
const handle = replayTeamRun(dir, { speed });
|
|
314
|
+
attach(handle, '(replay)', false, { speed });
|
|
300
315
|
return json(res, 200, { runId: handle.runId, replay: true });
|
|
301
316
|
}
|
|
302
317
|
if (m === 'GET' && rp[2]?.startsWith('attachment/') && rp[3]) {
|
|
@@ -441,6 +456,16 @@ export async function startGuiServer(opts) {
|
|
|
441
456
|
if (!isRunning() || !current)
|
|
442
457
|
return json(res, 409, { error: 'no active run' });
|
|
443
458
|
current.handle.stop();
|
|
459
|
+
// A playback has no run.completed of its own when it is cut short, so every open page is told directly.
|
|
460
|
+
if (current.replay) {
|
|
461
|
+
current.outcome = 'stopped';
|
|
462
|
+
for (const r of sse) {
|
|
463
|
+
try {
|
|
464
|
+
r.write('event: replaystop\ndata: {}\n\n');
|
|
465
|
+
}
|
|
466
|
+
catch { /* dead socket */ }
|
|
467
|
+
}
|
|
468
|
+
}
|
|
444
469
|
return json(res, 200, { ok: true });
|
|
445
470
|
}
|
|
446
471
|
json(res, 404, { error: 'not found' });
|
package/gui/app.css
CHANGED
|
@@ -265,3 +265,11 @@ table.runs td.warn{color:var(--am)}
|
|
|
265
265
|
.exu.ok .exubar i{background:var(--gr)}.exu.bad .exubar i{background:var(--rd)}.exust{color:var(--mu);overflow:hidden;text-overflow:ellipsis;white-space:nowrap}.exu.bad .exust{color:var(--rd)}.exu.ok .exust{color:var(--gr)}
|
|
266
266
|
.exfoot{justify-content:space-between!important;align-items:center;font-size:11px;color:var(--mu)}.exstat.err{color:var(--rd)}.exhint{overflow:hidden;text-overflow:ellipsis;white-space:nowrap;min-width:0}
|
|
267
267
|
@media (max-width:1000px){.exdlg.hasprev .exmain{grid-template-columns:minmax(0,1fr);grid-template-rows:minmax(0,1fr) 40%}.exdlg.hasprev .exprev{border-left:0;border-top:1px solid var(--b1)}.exfilter{width:130px}}
|
|
268
|
+
|
|
269
|
+
.stale{position:fixed;left:50%;bottom:14px;transform:translateX(-50%);z-index:60;max-width:min(760px,92vw);padding:9px 14px;border:1px solid var(--am);border-radius:8px;background:#1a1407;color:var(--am);font-size:12.5px;line-height:1.45;box-shadow:0 8px 30px rgba(0,0,0,.5)}
|
|
270
|
+
.exupl{max-width:230px;overflow:hidden;text-overflow:ellipsis;white-space:nowrap}
|
|
271
|
+
.rstat{display:inline-block;font:700 10px var(--mono);letter-spacing:.1em;padding:3px 8px;border-radius:10px;border:1px solid var(--b1);color:var(--mu);white-space:nowrap}
|
|
272
|
+
.rstat.rp{color:var(--am);border-color:#6b4a1c;background:rgba(243,165,68,.1)}.rstat.run{color:var(--rd);border-color:#6e2a38;background:rgba(240,86,104,.08)}
|
|
273
|
+
table.runs tr.replaying td{background:rgba(243,165,68,.05)}table.runs tr.replaying td:first-child{box-shadow:inset 3px 0 0 var(--am)}
|
|
274
|
+
.rpbtns{white-space:nowrap}.rpbtns button{margin-right:4px}.rpbtns button.on{border-color:var(--am);color:var(--am)}
|
|
275
|
+
#bStopRp{padding:4px 10px;font-size:12px;white-space:nowrap}#bStopRp[hidden]{display:none}
|
package/gui/app.js
CHANGED
|
@@ -140,6 +140,13 @@
|
|
|
140
140
|
var cur = r.el.querySelector('.cur'); if (cur) cur.style.display = r.typed ? 'none' : '';
|
|
141
141
|
});
|
|
142
142
|
}
|
|
143
|
+
/* The server answers with the version it started with and the one on disk now; when they differ, new screens can hit routes the running process lacks. */
|
|
144
|
+
function staleNotice(running, disk) {
|
|
145
|
+
var el = $('stale'), on = !running || (!!disk && running !== disk);
|
|
146
|
+
if (!on) { if (el) el.remove(); return; }
|
|
147
|
+
if (!el) { el = h('div', {id: 'stale', class: 'stale', role: 'status'}); document.body.appendChild(el); }
|
|
148
|
+
el.textContent = (running ? 'CKit was updated to ' + disk + ' but this process still runs ' + running : 'CKit was updated while this process was running') + '. Stop it with Ctrl+C in its terminal and run ckit again (a live run will be interrupted).';
|
|
149
|
+
}
|
|
143
150
|
function toast(t) { var el = h('div', {class: 'toast', text: t}); document.body.appendChild(el); setTimeout(function () { el.classList.add('out'); }, 3600); setTimeout(function () { el.remove(); }, 4200); }
|
|
144
151
|
function shortPath(p) { var parts = String(p || '').split(/[\\/]/).filter(Boolean); return parts.length > 3 ? '…/' + parts.slice(-3).join('/') : String(p || ''); }
|
|
145
152
|
|
|
@@ -243,7 +250,7 @@
|
|
|
243
250
|
case 'subagent.activity': if (a && a.subs[e.childId]) { a.subs[e.childId].text = e.text; net.subActivity(e.childId, e.text); } break;
|
|
244
251
|
case 'subagent.finished': if (a && a.subs[e.childId]) { a.subs[e.childId].state = e.ok ? 'done' : 'failed'; net.finishSub(e.childId, e.ok); feedSub(e.agentId, (e.ok ? '✓ ' : '✕ ') + a.subs[e.childId].kind + ': ' + e.summary); } break;
|
|
245
252
|
case 'run.completed':
|
|
246
|
-
S.ended = Date.parse(e.at); S.outcome = e.outcome; S.reportText = e.report; if (S.run) S.run.running = false;
|
|
253
|
+
S.ended = Date.parse(e.at); S.outcome = e.outcome; S.reportText = e.report; if (S.run) S.run.running = false; if (S.view === 'runs') renderRuns();
|
|
247
254
|
if (S.stageKey) S.stageTimes[S.stageKey] = Date.parse(e.at) - S.lastStageAt;
|
|
248
255
|
if (e.outcome === 'delivered') { var sl2 = stageList(S.config); S.stageIdx = sl2.length; S.stageKey = 'done'; net.setStage(sl2.length, S.loop, sl2.length); }
|
|
249
256
|
S.order.forEach(function (id) { if (A(id).state === 'thinking') { A(id).state = 'idle'; net.setState(id, 'idle'); } });
|
|
@@ -486,7 +493,8 @@
|
|
|
486
493
|
function renderTop() {
|
|
487
494
|
var live = S.run && S.run.running && !S.outcome, b = $('badge');
|
|
488
495
|
b.className = 'badge ' + (S.outcome === 'declined' ? 'replay' : S.outcome ? 'done' : live ? (S.replay ? 'replay' : 'live') : '');
|
|
489
|
-
b.querySelector('span').textContent = S.outcome ? (S.replay ? 'REPLAY DONE' : S.outcome === 'delivered' ? 'COMPLETE' : String(S.outcome).toUpperCase()) : live ? (S.replay ? 'REPLAY' : S.waiting ? 'WAITING' : 'LIVE') : 'IDLE';
|
|
496
|
+
b.querySelector('span').textContent = S.outcome ? (S.replay ? 'REPLAY DONE' : S.outcome === 'delivered' ? 'COMPLETE' : String(S.outcome).toUpperCase()) : live ? (S.replay ? 'REPLAY' + (S.replaySpeed ? ' ' + S.replaySpeed + '×' : '') : S.waiting ? 'WAITING' : 'LIVE') : S.replay && S.run ? 'REPLAY STOPPED' : 'IDLE';
|
|
497
|
+
$('bStopRp').hidden = !(live && S.replay);
|
|
490
498
|
var end = S.outcome || S.replay ? (S.lastAt || S.started) : Date.now();
|
|
491
499
|
$('elapsed').textContent = S.started ? fmtT(end - S.started) : '00:00'; $('tokens').textContent = fmtN(S.tokens); $('msgs').textContent = S.msgs;
|
|
492
500
|
$('active').textContent = S.order.filter(function (i) { return A(i).state === 'thinking'; }).length + activeSubs();
|
|
@@ -535,22 +543,32 @@
|
|
|
535
543
|
$('bRuns').onclick = function () { setView('runs'); };
|
|
536
544
|
$('bCfg').onclick = function () { setView('settings'); }; $('bNew').onclick = newRunDialog; $('bHint').onclick = newRunDialog;
|
|
537
545
|
function renderRuns() {
|
|
538
|
-
var box = $('runs');
|
|
546
|
+
var box = $('runs');
|
|
539
547
|
api('GET', '/api/runs').then(function (r) {
|
|
540
|
-
|
|
548
|
+
box.innerHTML = '<div class="ml" style="margin:6px 0 10px">PAST RUNS — open to replay</div>';
|
|
549
|
+
var rows = r.body.runs || [], act = r.body.active || null, t = h('table', {class: 'runs'}); t.innerHTML = '<tr><th>Date</th><th>Goal</th><th>Lane</th><th>Outcome</th><th>Duration</th><th>Status</th><th>Replay</th></tr>';
|
|
541
550
|
rows.forEach(function (x) {
|
|
542
551
|
var tr = h('tr'); tr.appendChild(h('td', {class: 'mono', text: x.startedAt ? new Date(x.startedAt).toLocaleString() : x.runId})); tr.appendChild(h('td', {text: (x.simulated ? '[demo] ' : '') + x.goal}));
|
|
543
552
|
var lbl = x.outcome === 'declined' ? 'declined: the Director could not take this request' : x.outcome === 'incomplete' ? (x.waiting ? 'interrupted while waiting for your answer' : 'interrupted before it finished') : x.outcome;
|
|
544
553
|
tr.appendChild(h('td', {text: x.lane || ''}));
|
|
545
554
|
tr.appendChild(h('td', {class: x.outcome === 'delivered' ? 'ok' : x.outcome === 'failed' ? 'bad' : x.outcome === 'declined' || x.outcome === 'incomplete' ? 'warn' : '', title: x.outcome === 'incomplete' ? 'A run lives only in the CKit process that started it and is not resumed after CKit stops or restarts. Start the request again as a new run.' : '', text: lbl})); tr.appendChild(h('td', {class: 'mono', text: fmtT(x.durationMs)}));
|
|
546
|
-
var
|
|
555
|
+
var mine = !!act && act.runId === x.runId, rp = mine && act.replay, busy = !!act && !act.replay;
|
|
556
|
+
if (rp) tr.className = 'replaying';
|
|
557
|
+
tr.appendChild(h('td', {}, [h('span', {class: 'rstat ' + (rp ? 'rp' : mine ? 'run' : ''), text: rp ? '▶ REPLAYING ' + act.speed + '×' : mine ? '● RUNNING' : 'READY'})]));
|
|
558
|
+
var td = h('td', {class: 'rpbtns'});
|
|
559
|
+
[1, 2, 4].forEach(function (sp) { td.appendChild(h('button', {text: sp + '×', class: rp && act.speed === sp ? 'on' : '', disabled: busy, title: busy ? 'A run is active; replay is available when it ends.' : rp && act.speed === sp ? 'Playing at this speed' : rp ? 'Restart this replay at ' + sp + '×' : 'Replay at ' + sp + '×', onclick: function () { replay(x.runId, sp); }})); });
|
|
560
|
+
if (rp) td.appendChild(h('button', {class: 'danger', text: '■ Stop', title: 'Stop this replay', onclick: stopReplay}));
|
|
561
|
+
tr.appendChild(td); t.appendChild(tr);
|
|
547
562
|
});
|
|
548
|
-
if (!rows.length) t.appendChild(h('tr', {}, [h('td', {colSpan:
|
|
563
|
+
if (!rows.length) t.appendChild(h('tr', {}, [h('td', {colSpan: 7, text: 'No runs yet.'})]));
|
|
549
564
|
box.appendChild(t);
|
|
550
565
|
});
|
|
551
566
|
}
|
|
552
567
|
function simDefault() { return !S.config || !!S.simulatedDefault || !cfgAgents(S.config).some(function (a) { return a.cli !== 'auto' && a.cli !== 'simulated'; }); }
|
|
553
|
-
function replay(id, speed) { api('POST', '/api/runs/' + id + '/replay', {speed: speed}).then(function (r) { if (r.status !== 200) { toast(r.body.error || 'replay failed'); return; } S.replay = true; setComic(false); setView('live'); }); }
|
|
568
|
+
function replay(id, speed) { api('POST', '/api/runs/' + id + '/replay', {speed: speed}).then(function (r) { if (r.status !== 200) { toast(r.body.error || 'replay failed'); return; } S.replay = true; S.replaySpeed = speed; setComic(false); setView('live'); }); }
|
|
569
|
+
function stopReplay() { api('POST', '/api/runs/current/stop').then(function (r) { if (r.status !== 200) toast(r.body.error || 'No replay is playing'); else toast('Replay stopped'); replayStopped(); }); }
|
|
570
|
+
/* A stopped playback sends no run.completed, so the page is told separately (also for other open tabs). */
|
|
571
|
+
function replayStopped() { if (S.run) S.run.running = false; S.dirty = true; if (S.view === 'runs') renderRuns(); }
|
|
554
572
|
function newRunDialog() {
|
|
555
573
|
var goal = h('textarea', {rows: 4, placeholder: 'Describe the mission… e.g. "Add a dark-mode toggle to the settings page"'}), sim = h('input', {type: 'checkbox', style: 'width:auto'});
|
|
556
574
|
sim.checked = simDefault(); var laneSel = laneSelect();
|
|
@@ -1000,6 +1018,7 @@
|
|
|
1000
1018
|
es.onmessage = function (m) { try { onEvent(JSON.parse(m.data)); } catch (err) { console.error(err); } };
|
|
1001
1019
|
es.addEventListener('reset', function () { resetRun(); S.history = true; });
|
|
1002
1020
|
es.addEventListener('ready', function () { S.history = false; S.dirty = true; shots(); });
|
|
1021
|
+
es.addEventListener('replaystop', replayStopped);
|
|
1003
1022
|
}
|
|
1004
1023
|
api('GET', '/api/clis').then(function (r) { if (r.status === 200) { CLIS = r.body.clis || []; S.configFile = r.body.configFile; if (S.view === 'settings') setView('settings'); } });
|
|
1005
1024
|
api('GET', '/api/state').then(function (r) {
|
|
@@ -1011,8 +1030,8 @@
|
|
|
1011
1030
|
return;
|
|
1012
1031
|
}
|
|
1013
1032
|
if (r.status !== 200) { document.body.innerHTML = '<p style="padding:40px;color:#F05668;font-family:monospace">Missing or invalid session token. Open the URL printed by `ckit gui`.</p>'; return; }
|
|
1014
|
-
S.config = r.body.config; S.configExists = r.body.configExists !== false; S.projectRoot = r.body.projectRoot || ''; (function (root) { var name = root.split(/[\\/]/).filter(Boolean).pop() || root, ws = $('cwd').parentNode; $('cwdn').textContent = name; $('cwd').textContent = '\u200e' + root; document.title = name + ' · CKit'; ws.title = 'Open workspace files\n' + root; ws.style.cursor = 'pointer'; ws.setAttribute('role', 'button'); ws.tabIndex = 0; ws.onclick = function () { if (window.__ckExplorer) window.__ckExplorer.open(''); }; ws.onkeydown = function (e) { if (e.key === 'Enter' || e.key === ' ') { e.preventDefault(); ws.onclick(); } }; })(S.projectRoot); S.simulatedDefault = r.body.simulatedDefault; S.run = r.body.run ? {runId: r.body.run.runId, running: r.body.run.running, goal: r.body.run.goal} : null;
|
|
1015
|
-
S.replay = !!(r.body.run && r.body.run.goal === '(replay)');
|
|
1033
|
+
S.config = r.body.config; S.configExists = r.body.configExists !== false; S.projectRoot = r.body.projectRoot || ''; staleNotice(r.body.version, r.body.diskVersion); (function (root) { var name = root.split(/[\\/]/).filter(Boolean).pop() || root, ws = $('cwd').parentNode; $('cwdn').textContent = name; $('cwd').textContent = '\u200e' + root; document.title = name + ' · CKit'; ws.title = 'Open workspace files\n' + root; ws.style.cursor = 'pointer'; ws.setAttribute('role', 'button'); ws.tabIndex = 0; ws.onclick = function () { if (window.__ckExplorer) window.__ckExplorer.open(''); }; ws.onkeydown = function (e) { if (e.key === 'Enter' || e.key === ' ') { e.preventDefault(); ws.onclick(); } }; })(S.projectRoot); S.simulatedDefault = r.body.simulatedDefault; S.run = r.body.run ? {runId: r.body.run.runId, running: r.body.run.running, goal: r.body.run.goal} : null;
|
|
1034
|
+
S.replay = !!(r.body.run && r.body.run.goal === '(replay)'); S.replaySpeed = r.body.run && r.body.run.replay ? r.body.run.replay.speed : 0; $('bStopRp').onclick = stopReplay;
|
|
1016
1035
|
setupAgents(S.config);
|
|
1017
1036
|
// First run (no .ckit/team.json, nothing running): land on Config so setup starts in the GUI.
|
|
1018
1037
|
var v = location.hash.slice(1); setView(['live', 'settings', 'runs'].indexOf(v) >= 0 ? v : (!S.configExists && !r.body.run && !SHOT && Q.get('demo') !== '1') ? 'settings' : 'live');
|
package/gui/explorer.js
CHANGED
|
@@ -27,6 +27,8 @@
|
|
|
27
27
|
var wsName = function () { return (S.projectRoot || '').split(/[\\/]/).filter(Boolean).pop() || 'Workspace'; };
|
|
28
28
|
var fileUrl = function (path, dl) { return '/api/fs/file?path=' + encodeURIComponent(path) + (dl ? '&download=1' : '') + '&t=' + encodeURIComponent(TOKEN); };
|
|
29
29
|
|
|
30
|
+
/* The root folder always exists, so 404 on it means the running ckit process predates this screen (updated while running). */
|
|
31
|
+
var RESTART = 'This ckit process is older than the screen you opened (CKit was updated while it was running). Stop it with Ctrl+C in its terminal and run ckit again.';
|
|
30
32
|
function fs(method, path, body) {
|
|
31
33
|
return fetch(path, {method: method, headers: {'x-ckit-token': TOKEN, 'content-type': 'application/json'}, body: body === undefined ? undefined : JSON.stringify(body)})
|
|
32
34
|
.then(function (r) { return r.json().catch(function () { return {}; }).then(function (j) { return {status: r.status, body: j}; }); }, function () { return {status: 0, body: {error: 'Cannot reach CKit; check that ckit is still running.'}}; });
|
|
@@ -52,14 +54,14 @@
|
|
|
52
54
|
function open(startPath) {
|
|
53
55
|
if (EX) return;
|
|
54
56
|
EX = {path: startPath || '', entries: [], sig: '', sel: [], anchor: null, sort: {k: 'name', dir: 1}, filter: '', base: {}, hist: {}, flash: {}, uploads: [], prev: null, prevTok: 0, busy: false, err: '', opened: Date.now(), timer: 0, dropDir: null, rootNames: null, loaded: false};
|
|
55
|
-
var up = h('input', {type: 'file', multiple: true, hidden: true}); up.addEventListener('change', function () { upload(up.files,
|
|
57
|
+
var up = h('input', {type: 'file', multiple: true, hidden: true}); up.addEventListener('change', function () { upload(up.files, uploadDir()); up.value = ''; });
|
|
56
58
|
EX.el = {};
|
|
57
59
|
var E = EX.el;
|
|
58
60
|
E.bc = h('div', {class: 'exbc'}); E.filter = h('input', {class: 'exfilter', placeholder: 'Filter this folder…', spellcheck: false, autocomplete: 'off', 'aria-label': 'Filter files in this folder'});
|
|
59
61
|
E.filter.addEventListener('input', function () { EX.filter = E.filter.value.trim().toLowerCase(); renderList(); });
|
|
60
62
|
E.btnRef = h('button', {type: 'button', class: 'exref', text: '+ References folder', title: 'Files you put here stay in the project; point agents at them with @references/…', onclick: makeReferences});
|
|
61
63
|
E.tools = h('div', {class: 'extool'}, [h('button', {type: 'button', class: 'exup', title: 'Go up one folder (Backspace)', text: '↑', onclick: goUp}), E.bc, E.filter,
|
|
62
|
-
h('button', {type: 'button', text: '+ New folder', onclick: newFolder}), h('button', {type: 'button', class: 'primary', text: '⬆ Upload', onclick: function () { up.click(); }}), E.btnRef, up]);
|
|
64
|
+
h('button', {type: 'button', text: '+ New folder', onclick: newFolder}), (E.btnUp = h('button', {type: 'button', class: 'primary exupl', text: '⬆ Upload', onclick: function () { up.click(); }})), E.btnRef, up]);
|
|
63
65
|
E.head = h('div', {class: 'exrow exhead'}, [h('span'), sortHead('name', 'Name'), sortHead('size', 'Size'), sortHead('mtime', 'Modified'), h('span')]);
|
|
64
66
|
E.rows = h('div', {class: 'exrows', tabIndex: 0, role: 'listbox', 'aria-label': 'Files and folders'});
|
|
65
67
|
E.rows.addEventListener('click', function (ev) { if (ev.target === E.rows) { EX.sel = []; syncSel(); } });
|
|
@@ -95,7 +97,7 @@
|
|
|
95
97
|
if (EX !== my) return; my.busy = false;
|
|
96
98
|
if (r.status === 200) { my.err = ''; if (path !== my.path || first) { my.path = path; } apply(r.body, true); return; }
|
|
97
99
|
if (r.status === 404 && path) { ck.toast('That folder is gone; showing its parent.'); return load(parentOf(path)); }
|
|
98
|
-
my.err = r.body.error || 'Could not read this folder.'; if (my.loaded) { setStatus(); } else { renderList(); }
|
|
100
|
+
my.err = r.status === 404 && !path ? RESTART : (r.body.error || 'Could not read this folder.'); if (my.loaded) { setStatus(); } else { renderList(); }
|
|
99
101
|
});
|
|
100
102
|
}
|
|
101
103
|
function poll() {
|
|
@@ -199,9 +201,12 @@
|
|
|
199
201
|
var E = EX.el, dirs = EX.entries.filter(function (e) { return e.dir; }).length, files = EX.entries.length - dirs;
|
|
200
202
|
var sel = EX.sel.length ? ' · ' + EX.sel.length + ' selected' : '';
|
|
201
203
|
E.status.textContent = EX.err ? EX.err : (dirs + (dirs === 1 ? ' folder' : ' folders') + ', ' + files + (files === 1 ? ' file' : ' files') + sel + (EX.truncated ? ' · showing the first 5000 items' : ''));
|
|
202
|
-
E.status.classList.toggle('err', !!EX.err); E.live.classList.toggle('off', !!EX.err);
|
|
204
|
+
E.status.classList.toggle('err', !!EX.err); E.live.classList.toggle('off', !!EX.err); syncUpload();
|
|
203
205
|
}
|
|
204
206
|
function byName(n) { return EX.entries.filter(function (e) { return e.name === n; })[0]; }
|
|
207
|
+
/* The Upload button targets the one selected folder; with no folder selected (or several items) it targets the folder being shown. */
|
|
208
|
+
function uploadDir() { var e = EX.sel.length === 1 ? byName(EX.sel[0]) : null; return e && e.dir ? join(EX.path, e.name) : EX.path; }
|
|
209
|
+
function syncUpload() { var b = EX.el.btnUp; if (!b) return; var d = uploadDir(), name = d ? d.slice(d.lastIndexOf('/') + 1) : wsName(); b.textContent = '⬆ Upload to ' + name + '/'; b.title = 'Files go into ' + (d ? wsName() + '/' + d : wsName() + ' (the workspace folder)') + '. Select one folder first to upload into it.'; }
|
|
205
210
|
function syncSel() {
|
|
206
211
|
Array.prototype.forEach.call(EX.el.rows.children, function (r) { var on = EX.sel.indexOf(r.getAttribute('data-name')) >= 0; r.classList.toggle('sel', on); r.setAttribute('aria-selected', on ? 'true' : 'false'); });
|
|
207
212
|
setStatus();
|
package/gui/index.html
CHANGED
|
@@ -8,6 +8,7 @@
|
|
|
8
8
|
<div class="goal" id="goal" title="">No active run</div>
|
|
9
9
|
<div class="meta"><span class="ml">RUN</span><span class="mv mono" id="runid">—</span></div>
|
|
10
10
|
<div class="badge" id="badge"><i></i><span>IDLE</span></div>
|
|
11
|
+
<button id="bStopRp" class="danger" type="button" title="Stop this replay" hidden>■ Stop replay</button>
|
|
11
12
|
<div class="metric"><span class="ml">ELAPSED</span><span class="mv big mono" id="elapsed">00:00</span></div>
|
|
12
13
|
<div class="metric"><span class="ml">TOKENS</span><span class="mv big mono" id="tokens">0</span></div>
|
|
13
14
|
<div class="metric"><span class="ml">MESSAGES</span><span class="mv big mono" id="msgs">0</span></div>
|
package/package.json
CHANGED
|
@@ -1,6 +1,6 @@
|
|
|
1
1
|
{
|
|
2
2
|
"name": "@ngockhoale/ckit",
|
|
3
|
-
"version": "0.2.
|
|
3
|
+
"version": "0.2.5",
|
|
4
4
|
"description": "CKit — local Agent Company: a Director plus BA / Implement / QC teams running your own codex, claude and omp CLIs, with a web Mission Control (ckit gui).",
|
|
5
5
|
"type": "module",
|
|
6
6
|
"bin": {
|