@ngockhoale/ckit 0.2.0 → 0.2.1
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.js +13 -1
- package/dist/src/team/cli-args.d.ts +4 -2
- package/dist/src/team/cli-args.js +14 -3
- package/gui/app.css +11 -0
- package/gui/app.js +29 -6
- package/package.json +1 -1
package/dist/src/gui/server.js
CHANGED
|
@@ -15,6 +15,7 @@ import { deleteSecret, hasSecret, readSecret, setSecret, SECRET_NAME_RE } from '
|
|
|
15
15
|
import { replayTeamRun, startTeamRun } from '../team/engine.js';
|
|
16
16
|
import { detectClis } from '../team/cli-models.js';
|
|
17
17
|
import { dispatchRunner } from '../team/runners.js';
|
|
18
|
+
import { splitCliArgs } from '../team/cli-args.js';
|
|
18
19
|
import { listTeamRuns, readTeamJournal } from '../team/journal.js';
|
|
19
20
|
import { DEFAULT_MISSIONS, allAgentsOf, effectiveOrder } from '../team/types.js';
|
|
20
21
|
import { mkdirSync, writeFileSync } from 'node:fs';
|
|
@@ -306,11 +307,22 @@ export async function startGuiServer(opts) {
|
|
|
306
307
|
return json(res, 400, { error: 'cli must be claude-code, codex or omp' });
|
|
307
308
|
if (model !== null && (typeof model !== 'string' || !/^[A-Za-z0-9._:\/@\[\]-]{1,120}$/.test(model)))
|
|
308
309
|
return json(res, 400, { error: 'invalid model name' });
|
|
310
|
+
const rawArgs = b['cliArgs'];
|
|
311
|
+
let cliArgs;
|
|
312
|
+
if (rawArgs !== undefined && rawArgs !== null && rawArgs !== '') {
|
|
313
|
+
if (typeof rawArgs !== 'string' || rawArgs.length > 500 || /[\n\r\0]/.test(rawArgs))
|
|
314
|
+
return json(res, 400, { error: 'extra CLI arguments must be one line of at most 500 characters' });
|
|
315
|
+
const sp = splitCliArgs(rawArgs);
|
|
316
|
+
if (!sp.ok)
|
|
317
|
+
return json(res, 400, { error: `extra CLI arguments ${sp.error}; close the quote or remove it` });
|
|
318
|
+
if (rawArgs.trim())
|
|
319
|
+
cliArgs = rawArgs.trim();
|
|
320
|
+
}
|
|
309
321
|
if (checks >= 3)
|
|
310
322
|
return json(res, 429, { error: 'too many checks running; wait for one to finish' });
|
|
311
323
|
checks++;
|
|
312
324
|
try {
|
|
313
|
-
const r = await dispatchRunner({ id: 'check', name: 'check', team: 'qc', cli, model, access: 'read' }, 'Reply with the single word OK. Do not use any tools.', { cwd: root, timeoutMs: 90_000 });
|
|
325
|
+
const r = await dispatchRunner({ id: 'check', name: 'check', team: 'qc', cli, model, access: 'read', ...(cliArgs ? { cliArgs } : {}) }, 'Reply with the single word OK. Do not use any tools.', { cwd: root, timeoutMs: 90_000 });
|
|
314
326
|
return json(res, 200, r.ok ? { ok: true } : { ok: false, reason: r.reason });
|
|
315
327
|
}
|
|
316
328
|
finally {
|
|
@@ -6,5 +6,7 @@ export declare function splitCliArgs(text: string): {
|
|
|
6
6
|
ok: false;
|
|
7
7
|
error: string;
|
|
8
8
|
};
|
|
9
|
-
/**
|
|
10
|
-
export declare
|
|
9
|
+
/** Home-folder shorthand as a shell would resolve it: a leading `~` / `~/` (also right after `--flag=`), and `$HOME` / `${HOME}`. No other variable is expanded. */
|
|
10
|
+
export declare function expandHome(token: string, home: string): string;
|
|
11
|
+
/** Tokens for an agent, home shorthand expanded; a value that does not split (cannot happen after parseTeamConfig) yields none. */
|
|
12
|
+
export declare const cliArgTokens: (cliArgs: string | undefined, home?: string) => string[];
|
|
@@ -1,3 +1,4 @@
|
|
|
1
|
+
import { homedir } from 'node:os';
|
|
1
2
|
// Per-agent "extra CLI arguments": a shell-like splitter (no shell is ever involved; tokens go straight into the spawn argv array).
|
|
2
3
|
/** Splits `text` on whitespace; single and double quotes group; a backslash escapes the next character outside quotes and inside double quotes. No ~ or $VAR expansion. */
|
|
3
4
|
export function splitCliArgs(text) {
|
|
@@ -48,11 +49,21 @@ export function splitCliArgs(text) {
|
|
|
48
49
|
args.push(cur);
|
|
49
50
|
return { ok: true, args };
|
|
50
51
|
}
|
|
51
|
-
/**
|
|
52
|
-
export
|
|
52
|
+
/** Home-folder shorthand as a shell would resolve it: a leading `~` / `~/` (also right after `--flag=`), and `$HOME` / `${HOME}`. No other variable is expanded. */
|
|
53
|
+
export function expandHome(token, home) {
|
|
54
|
+
const t = token.replace(/\$\{HOME\}|\$HOME(?![A-Za-z0-9_])/g, () => home);
|
|
55
|
+
if (t === '~')
|
|
56
|
+
return home;
|
|
57
|
+
if (t.startsWith('~/'))
|
|
58
|
+
return home + t.slice(1);
|
|
59
|
+
const m = /^(--?[A-Za-z0-9][A-Za-z0-9_-]*=)~(\/.*)?$/.exec(t);
|
|
60
|
+
return m ? `${m[1]}${home}${m[2] ?? ''}` : t;
|
|
61
|
+
}
|
|
62
|
+
/** Tokens for an agent, home shorthand expanded; a value that does not split (cannot happen after parseTeamConfig) yields none. */
|
|
63
|
+
export const cliArgTokens = (cliArgs, home = homedir()) => {
|
|
53
64
|
if (!cliArgs || !cliArgs.trim())
|
|
54
65
|
return [];
|
|
55
66
|
const r = splitCliArgs(cliArgs);
|
|
56
|
-
return r.ok ? r.args : [];
|
|
67
|
+
return r.ok ? r.args.map(a => expandHome(a, home)) : [];
|
|
57
68
|
};
|
|
58
69
|
//# sourceMappingURL=cli-args.js.map
|
package/gui/app.css
CHANGED
|
@@ -195,3 +195,14 @@ table.runs td.warn{color:var(--am)}
|
|
|
195
195
|
.lteam{display:flex;align-items:center;gap:6px;margin:4px 0;font-size:12px}.lteam .nbadge{flex:none}.lteam span.nm{flex:1}.lteam button{padding:1px 7px;font-size:10px}
|
|
196
196
|
.ltag{font:700 8px var(--mono);letter-spacing:.06em;border:1px solid var(--b2);border-radius:7px;padding:0 5px;color:var(--vi);margin-left:4px;text-transform:uppercase}
|
|
197
197
|
.chkrow{display:flex;gap:8px;align-items:flex-start;margin:6px 0}.chkrow input{width:auto;margin-top:3px}
|
|
198
|
+
|
|
199
|
+
/* text dialog (askText) */
|
|
200
|
+
.ask{position:fixed;inset:0;z-index:80;display:grid;place-items:center;background:rgba(3,5,10,.72);backdrop-filter:blur(6px);animation:askfade .14s ease-out}
|
|
201
|
+
.askcard{width:min(520px,92vw);background:linear-gradient(180deg,rgba(33,214,232,.07),transparent 90px),var(--p1);border:1px solid var(--b2);border-top:2px solid var(--cy);border-radius:6px;box-shadow:0 24px 80px rgba(0,0,0,.6),0 0 60px rgba(33,214,232,.14);animation:askpop .18s cubic-bezier(.2,1.2,.4,1)}
|
|
202
|
+
.askcard header{display:flex;justify-content:space-between;align-items:center;padding:14px 18px 4px}.askcard header b{font:700 13px var(--mono);letter-spacing:.14em;text-transform:uppercase;color:#fff}
|
|
203
|
+
.askx{border:0;background:none;color:var(--mu);padding:2px 6px;font-size:13px}.askx:hover{color:#fff;box-shadow:none}
|
|
204
|
+
.askbody{padding:10px 18px 6px}.askbody label{display:block;margin-bottom:6px}.askbody input{width:100%;font:15px var(--mono);padding:10px 12px}
|
|
205
|
+
.askbody p{margin:10px 0 0;font-size:12px;line-height:1.5;color:var(--mu)}.askerr{min-height:16px;margin-top:5px;font-size:12px;color:var(--rd)}
|
|
206
|
+
.askchips{display:flex;flex-wrap:wrap;gap:6px;align-items:center;margin-top:4px}.askchips span{font:11px var(--mono);color:var(--mu);margin-right:2px}.askchips button{font:12px var(--mono);padding:3px 9px;border-radius:999px}
|
|
207
|
+
.askcard footer{display:flex;gap:8px;align-items:center;justify-content:flex-end;padding:12px 18px 16px}.askkeys{margin-right:auto;font:11px var(--mono);color:var(--mu)}
|
|
208
|
+
@keyframes askfade{from{opacity:0}to{opacity:1}}@keyframes askpop{from{opacity:0;transform:translateY(8px) scale(.98)}to{opacity:1;transform:none}}
|
package/gui/app.js
CHANGED
|
@@ -329,6 +329,25 @@
|
|
|
329
329
|
p.querySelector('.dron').appendChild(h('span', {text: '◆ ' + (e.kind || 'sub') + ' · ' + e.task.slice(0, 50)}));
|
|
330
330
|
}
|
|
331
331
|
|
|
332
|
+
/* small text dialog (replaces window.prompt); sits above the Config modal. Resolves the trimmed text, or null when cancelled. */
|
|
333
|
+
function askText(o) {
|
|
334
|
+
return new Promise(function (done) {
|
|
335
|
+
var input = h('input', {value: o.value || '', placeholder: o.placeholder || '', spellcheck: false, autocomplete: 'off'}), err = h('div', {class: 'askerr'});
|
|
336
|
+
var close = function (v) { layer.remove(); done(v); };
|
|
337
|
+
var ok = function () { var v = input.value.trim(), bad = !v ? 'Type a name, or press Cancel.' : o.check ? o.check(v) : ''; if (bad) { err.textContent = bad; input.focus(); return; } close(v); };
|
|
338
|
+
var chips = (o.suggestions || []).length ? h('div', {class: 'askchips'}, [h('span', {text: 'Found on this machine'})].concat(o.suggestions.map(function (s) { return h('button', {type: 'button', text: s, onclick: function () { input.value = s; err.textContent = ''; input.focus(); }}); }))) : null;
|
|
339
|
+
var card = h('div', {class: 'askcard'}, [
|
|
340
|
+
h('header', {}, [h('b', {text: o.title}), h('button', {class: 'askx', type: 'button', text: '✕', title: 'Cancel', onclick: function () { close(null); }})]),
|
|
341
|
+
h('div', {class: 'askbody'}, [h('label', {class: 'ml', text: o.label}), input, err, chips, o.hint ? h('p', {text: o.hint}) : null]),
|
|
342
|
+
h('footer', {}, [h('span', {class: 'askkeys', text: 'Enter to confirm · Esc to cancel'}), h('button', {type: 'button', text: 'Cancel', onclick: function () { close(null); }}), h('button', {type: 'button', class: 'primary', text: o.okText || 'OK', onclick: ok})])]);
|
|
343
|
+
card.setAttribute('role', 'dialog'); card.setAttribute('aria-modal', 'true'); card.setAttribute('aria-label', o.title);
|
|
344
|
+
var layer = h('div', {class: 'ask'}, [card]);
|
|
345
|
+
layer.addEventListener('mousedown', function (e) { if (e.target === layer) close(null); });
|
|
346
|
+
layer.addEventListener('keydown', function (e) { if (e.key === 'Escape') { e.stopPropagation(); close(null); } else if (e.key === 'Enter' && e.target === input) { e.preventDefault(); ok(); } });
|
|
347
|
+
input.addEventListener('input', function () { err.textContent = ''; });
|
|
348
|
+
document.body.appendChild(layer); input.focus(); input.select();
|
|
349
|
+
});
|
|
350
|
+
}
|
|
332
351
|
/* overlay */
|
|
333
352
|
function showHoBanner(t) { var b = $('hobanner'); b.textContent = t; b.classList.add('on'); clearTimeout(b._t); b._t = setTimeout(function () { b.classList.remove('on'); }, 3200); }
|
|
334
353
|
function showDeclined(e, ov) {
|
|
@@ -357,7 +376,7 @@
|
|
|
357
376
|
if (/not found on PATH/.test(r)) return 'The ' + cli + ' program is not installed (or not on PATH) on this machine. Install it, or open Config and switch this agent to an engine you have.';
|
|
358
377
|
if ((m = /Missing environment variable: `?([A-Z0-9_]+)/.exec(r))) return cli + ' needs the environment variable ' + m[1] + ' and did not get it.' + (/env boundary withheld/.test(r) ? ' CKit withheld it because it holds the same key as the CKit advisor; worker agents never receive the advisor key. Fix: give this agent its own key or let ' + cli + ' use its own login, or open Config and switch this agent to another engine (for example claude-code).' : ' Fix: set it in the terminal before running ckit gui, or switch this agent to another engine in Config.');
|
|
359
378
|
if (/401|403|unauthori[sz]ed|invalid api key|authentication/i.test(r)) return 'The provider rejected the credentials. Check the API key or login for ' + cli + ', then use Test connection in Config.';
|
|
360
|
-
if (/model.*(not found|does not exist|may not exist|unknown)|unknown model|unrecognized_model/i.test(r)) return 'The model "' + (cfg && cfg.model || '') + '" is not available to ' + cli + '. Open Config and set this agent\'s Model to a name that ' + cli + ' accepts when you run it yourself in the terminal' + (cli === 'claude-code' ? ' (for example haiku, sonnet or opus)' : '') + ', or leave it blank to use the CLI default.';
|
|
379
|
+
if (/model.*(not found|does not exist|may not exist|unknown)|unknown model|unrecognized_model/i.test(r)) return 'The model "' + (cfg && cfg.model || '') + '" is not available to ' + cli + '. Open Config and set this agent\'s Model to a name that ' + cli + ' accepts when you run it yourself in the terminal' + (cli === 'claude-code' ? ' (for example haiku, sonnet or opus)' : '') + ', or leave it blank to use the CLI default. If this model comes from another settings or profile file, put that file in “Extra CLI arguments” (for example --settings ~/.claude/profile/name.json) and check again.';
|
|
361
380
|
if (/timed out/.test(r)) return 'The agent did not answer in time. Check the network or provider, or raise the timeout in Config.';
|
|
362
381
|
if (/429|rate limit|quota/i.test(r)) return 'The provider is rate-limiting or the quota is used up. Wait and retry, or switch this agent to another model.';
|
|
363
382
|
if (/ECONNREFUSED|ENOTFOUND|network|fetch failed/i.test(r)) return 'The provider could not be reached. Check the network and the endpoint URL of this agent in Config.';
|
|
@@ -789,7 +808,11 @@
|
|
|
789
808
|
ci.models.forEach(function (m) { s.appendChild(h('option', {value: m, text: m, selected: a.model === m})); });
|
|
790
809
|
if (a.model && !known) s.appendChild(h('option', {value: a.model, text: a.model + ' (typed by you, not in the CLI list)', selected: true}));
|
|
791
810
|
s.appendChild(h('option', {value: '\u0000', text: 'Other…'}));
|
|
792
|
-
s.addEventListener('change', function () { var v = s.value;
|
|
811
|
+
s.addEventListener('change', function () { var v = s.value; var set = function (x) { a.model = x || null; a._auto = true; mark(); render(); };
|
|
812
|
+
if (v !== '\u0000') return set(v);
|
|
813
|
+
askText({title: 'Custom model', label: 'Model name, exactly as ' + a.cli + ' accepts it', value: known ? '' : a.model || '', placeholder: 'model-name', okText: 'Use this model', suggestions: ci.models,
|
|
814
|
+
hint: 'CKit passes this name to ' + a.cli + ' unchanged. If the model comes from another settings or profile file, name that file in “Extra CLI arguments” below.',
|
|
815
|
+
check: function (x) { return /^[A-Za-z0-9._:\/@\[\]-]{1,120}$/.test(x) ? '' : 'Use letters, digits and . _ : / @ [ ] - only (max 120), no spaces.'; }}).then(function (x) { if (x === null) render(); else set(x); }); });
|
|
793
816
|
return s;
|
|
794
817
|
}
|
|
795
818
|
function editAgent(a) {
|
|
@@ -808,15 +831,15 @@
|
|
|
808
831
|
cli.addEventListener('change', function () { a.cli = cli.value; a.model = null; a._auto = true; mark(); render(); });
|
|
809
832
|
var acc = h('select'); ['read', 'write'].forEach(function (o) { var op = h('option', {text: o === 'write' ? 'Read + write (can change code)' : 'Read only (changes nothing)', value: o}); if (o === a.access) op.selected = true; acc.appendChild(op); }); acc.addEventListener('change', function () { a.access = acc.value; mark(); render(); });
|
|
810
833
|
f.appendChild(h('div', {class: 'row3'}, [fld('CLI', cli), fld('Model', modelPick(a, ci)), fld('Access', acc)]));
|
|
811
|
-
if (a.cli === 'claude-code' || a.cli === 'codex' || a.cli === 'omp') f.appendChild(fld('Extra CLI arguments (optional)', bind(h('input', {value: a.cliArgs || '', maxLength: 500, placeholder: '--settings
|
|
834
|
+
if (a.cli === 'claude-code' || a.cli === 'codex' || a.cli === 'omp') f.appendChild(fld('Extra CLI arguments (optional)', bind(h('input', {value: a.cliArgs || '', maxLength: 500, placeholder: '--settings ~/.claude/profile/other.json', spellcheck: false, style: 'font-family:var(--mono)', onchange: function () { a._auto = true; render(); }}), a, 'cliArgs'), 'Added to this agent\'s start command as typed. Leave empty to use the CLI\'s defaults. ~ and $HOME mean your home folder; quote values with spaces. The check below runs with these arguments.'));
|
|
812
835
|
f.appendChild(h('div', {class: 'clinote', text: a.access === 'write' ? 'Access: this agent reads the whole project and may change files in it.' : 'Access: this agent reads the whole project (code, docs, attachments) but changes nothing. Pick “Read + write” for agents that must edit code.'}));
|
|
813
836
|
if (ci && ci.installed) {
|
|
814
837
|
/* verify the pair with one real tiny turn; result is cached per CLI + model */
|
|
815
|
-
var ck = a.cli + '|' + (a.model || ''), st = CHECK[ck];
|
|
816
|
-
var run = function () { CHECK[ck] = {state: 'run'}; render(); api('POST', '/api/check-agent', {cli: a.cli, model: a.model || null}).then(function (r) { CHECK[ck] = r.status === 200 && r.body.ok ? {state: 'ok'} : {state: 'bad', reason: r.body.reason || r.body.error || 'check failed'}; render(); }); };
|
|
838
|
+
var xa = (a.cliArgs || '').trim(), ck = a.cli + '|' + (a.model || '') + '|' + xa, st = CHECK[ck];
|
|
839
|
+
var run = function () { CHECK[ck] = {state: 'run'}; render(); api('POST', '/api/check-agent', {cli: a.cli, model: a.model || null, cliArgs: xa}).then(function (r) { CHECK[ck] = r.status === 200 && r.body.ok ? {state: 'ok'} : {state: 'bad', reason: r.body.reason || r.body.error || 'check failed'}; render(); }); };
|
|
817
840
|
var line = h('div', {class: 'chk ' + (st ? st.state : '')}, [
|
|
818
841
|
h('button', {text: st && st.state === 'run' ? 'Checking…' : st ? 'Check again' : 'Check this CLI + model', disabled: !!(st && st.state === 'run'), onclick: run}),
|
|
819
|
-
h('span', {text: !st ? 'Runs one tiny real turn to confirm ' + a.cli + ' accepts this model.' : st.state === 'run' ? 'asking ' + a.cli + ' for a one-word reply (up to 90 s)…' : st.state === 'ok' ? '✓ works: ' + a.cli + ' answered with ' + (a.model || 'its default model') : '✕ ' + a.cli + ' rejected this setup'})]);
|
|
842
|
+
h('span', {text: !st ? 'Runs one tiny real turn to confirm ' + a.cli + ' accepts this model' + (xa ? ' with the extra arguments.' : '.') : st.state === 'run' ? 'asking ' + a.cli + ' for a one-word reply (up to 90 s)…' : st.state === 'ok' ? '✓ works: ' + a.cli + ' answered with ' + (a.model || 'its default model') + (xa ? ' and the extra arguments' : '') : '✕ ' + a.cli + ' rejected this setup'})]);
|
|
820
843
|
f.appendChild(line);
|
|
821
844
|
if (st && st.state === 'bad') { f.appendChild(h('pre', {class: 'chkerr', text: st.reason})); f.appendChild(h('div', {class: 'fix'}, [h('b', {text: 'How to fix '}), fixHint(st.reason, a)])); }
|
|
822
845
|
if (a._auto) { a._auto = false; if (!st) setTimeout(run, 0); }
|
package/package.json
CHANGED
|
@@ -1,6 +1,6 @@
|
|
|
1
1
|
{
|
|
2
2
|
"name": "@ngockhoale/ckit",
|
|
3
|
-
"version": "0.2.
|
|
3
|
+
"version": "0.2.1",
|
|
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": {
|