@ngockhoale/ckit 0.2.3 → 0.2.4
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/dist/src/gui/server.d.ts +2 -0
- package/dist/src/gui/server.js +12 -1
- package/gui/app.css +3 -0
- package/gui/app.js +8 -1
- package/gui/explorer.js +9 -4
- package/package.json +1 -1
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}$/;
|
|
@@ -178,7 +189,7 @@ 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,
|
|
192
|
+
return json(res, 200, { config: publicConfig(c), configExists: existsSync(teamConfigPath(root)), projectRoot: root, version: START_VERSION, diskVersion: packageVersion(), simulatedDefault: !configured,
|
|
182
193
|
run: current ? { runId: current.handle.runId, goal: current.goal, simulated: current.simulated, startedAt: current.startedAt, running: current.outcome === null, outcome: current.outcome } : null });
|
|
183
194
|
}
|
|
184
195
|
if (m === 'PUT' && p === '/api/config') {
|
package/gui/app.css
CHANGED
|
@@ -265,3 +265,6 @@ 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}
|
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
|
|
|
@@ -1011,7 +1018,7 @@
|
|
|
1011
1018
|
return;
|
|
1012
1019
|
}
|
|
1013
1020
|
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;
|
|
1021
|
+
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;
|
|
1015
1022
|
S.replay = !!(r.body.run && r.body.run.goal === '(replay)');
|
|
1016
1023
|
setupAgents(S.config);
|
|
1017
1024
|
// First run (no .ckit/team.json, nothing running): land on Config so setup starts in the GUI.
|
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/package.json
CHANGED
|
@@ -1,6 +1,6 @@
|
|
|
1
1
|
{
|
|
2
2
|
"name": "@ngockhoale/ckit",
|
|
3
|
-
"version": "0.2.
|
|
3
|
+
"version": "0.2.4",
|
|
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": {
|