kaizen-agent 1.78.0 → 1.79.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/cli/accounts.ts +38 -0
- package/cli/install.ts +10 -7
- package/cli/sources.ts +3 -3
- package/cli/web.ts +29 -5
- package/package.json +1 -1
- package/skills/kaizen/SKILL.md +1 -1
- package/skills/kaizen/discover.md +1 -1
- package/skills/kaizen-explore/SKILL.md +2 -2
- package/skills/kaizen-help/SKILL.md +2 -2
- package/web/board/icebox.ts +52 -28
- package/web/board/settings-accounts.ts +19 -5
- package/web/board/settings-pages.ts +1 -1
- package/web/board.html +19 -2
- package/web/board.js +79 -74
- package/web/notebook.js +92 -87
- package/web/notes.html +16 -1
- package/web/term.js +1 -1
- package/web/video.html +16 -1
- package/web/video.js +102 -97
package/cli/accounts.ts
CHANGED
|
@@ -82,6 +82,44 @@ export function addAccount(tool: unknown, name: unknown): { id: string } | { err
|
|
|
82
82
|
// Whether the tool has saved a login here. The file is only looked at, never read.
|
|
83
83
|
export const signedIn = (dir: string, tool: Tool) => existsSync(join(dir, tool === "claude" ? ".credentials.json" : "auth.json"));
|
|
84
84
|
|
|
85
|
+
// Who is signed in, as the tool itself says: `claude auth status --json` / `codex login status`,
|
|
86
|
+
// pointed at an account folder (`dir`) or at the normal login. kaizen never opens the login
|
|
87
|
+
// files; without the CLI (or when it hangs past 5 s) it falls back to whether the file exists.
|
|
88
|
+
export type Login = { signedIn: boolean; who?: string; plan?: string; via?: string; checked: "cli" | "file" };
|
|
89
|
+
export async function loginStatus(tool: Tool, dir?: string, env: NodeJS.ProcessEnv = process.env, timeoutMs = 5000): Promise<Login> {
|
|
90
|
+
const home = env.HOME || homedir();
|
|
91
|
+
const fallback = (): Login => ({ signedIn: signedIn(dir ?? join(home, tool === "claude" ? ".claude" : ".codex"), tool), checked: "file" });
|
|
92
|
+
const bin = Bun.which(tool, { PATH: env.PATH ?? "" });
|
|
93
|
+
if (!bin) return fallback();
|
|
94
|
+
const e: Record<string, string> = {};
|
|
95
|
+
for (const [k, v] of Object.entries(env)) if (typeof v === "string") e[k] = v;
|
|
96
|
+
if (dir) e[ACCOUNT_VAR[tool]] = dir; else delete e[ACCOUNT_VAR[tool]];
|
|
97
|
+
let p: ReturnType<typeof Bun.spawn> | null = null, timer: ReturnType<typeof setTimeout> | undefined;
|
|
98
|
+
// Raced against the clock: a killed CLI's own children can keep its output open, so the
|
|
99
|
+
// answer never waits on the pipes past the timeout.
|
|
100
|
+
const late = new Promise<Login>((done) => { timer = setTimeout(() => { try { p?.kill(); } catch { /* gone */ } done(fallback()); }, timeoutMs); });
|
|
101
|
+
const ask = (async (): Promise<Login> => {
|
|
102
|
+
p = Bun.spawn(tool === "claude" ? [bin, "auth", "status", "--json"] : [bin, "login", "status"], { env: e, stdin: "ignore", stdout: "pipe", stderr: "pipe" });
|
|
103
|
+
const [out, err] = await Promise.all([new Response(p.stdout as ReadableStream).text(), new Response(p.stderr as ReadableStream).text()]);
|
|
104
|
+
await p.exited;
|
|
105
|
+
return read(out, err);
|
|
106
|
+
})().catch(fallback);
|
|
107
|
+
try { return await Promise.race([ask, late]); } finally { clearTimeout(timer); }
|
|
108
|
+
function read(out: string, err: string): Login {
|
|
109
|
+
if (tool === "claude") {
|
|
110
|
+
const j = JSON.parse(out);
|
|
111
|
+
const str = (v: unknown) => (typeof v === "string" && v.trim() ? v.trim().slice(0, 120) : undefined);
|
|
112
|
+
return { signedIn: j?.loggedIn === true, who: str(j?.email), plan: str(j?.subscriptionType) ?? str(j?.planTier), via: str(j?.authMethod), checked: "cli" };
|
|
113
|
+
}
|
|
114
|
+
const txt = (out + "\n" + err).trim();
|
|
115
|
+
const m = /^Logged in using (.+)$/im.exec(txt);
|
|
116
|
+
// "an API key - sk-…": only the method, never a piece of the key.
|
|
117
|
+
if (m) return { signedIn: true, via: m[1]!.split(" - ")[0]!.trim().slice(0, 60), checked: "cli" };
|
|
118
|
+
if (/not logged in/i.test(txt)) return { signedIn: false, checked: "cli" };
|
|
119
|
+
return fallback();
|
|
120
|
+
}
|
|
121
|
+
}
|
|
122
|
+
|
|
85
123
|
export function removeAccount(id: string, deleteFolder = false): string | null {
|
|
86
124
|
const a = readAccounts();
|
|
87
125
|
if (!validId(id) || !a.accounts.some((x) => x.id === id)) return "unknown account";
|
package/cli/install.ts
CHANGED
|
@@ -349,6 +349,9 @@ if (Bun.argv[2] === "sources" || Bun.argv[2] === "gather" || Bun.argv[2] === "ic
|
|
|
349
349
|
const state = locate() ?? join(home, ".kaizen");
|
|
350
350
|
// A source belongs to the project the command is run in; every answer names it.
|
|
351
351
|
const where = c.dim(`project ${label(state)}`);
|
|
352
|
+
// An icebox "collection" was first called a board: both words work, and `board` is what is stored.
|
|
353
|
+
if (Bun.argv[2] === "icebox" && (Bun.argv[3] === "collection" || Bun.argv[3] === "collections")) Bun.argv[3] = Bun.argv[3].replace("collection", "board");
|
|
354
|
+
for (let i = 4; Bun.argv[2] === "icebox" && i < Bun.argv.length; i++) if (Bun.argv[i] === "--collection") Bun.argv[i] = "--board";
|
|
352
355
|
const [, , cmd, op, url = "", ...rest] = Bun.argv;
|
|
353
356
|
const line = (r: { url: string; ok: boolean; note: string }) => ` ${r.ok ? c.green("ok ") : "fail"} ${r.url} ${c.dim(r.note)}`;
|
|
354
357
|
const waiting = c.dim(" new requests wait in the icebox — kaizen icebox");
|
|
@@ -376,10 +379,10 @@ if (Bun.argv[2] === "sources" || Bun.argv[2] === "gather" || Bun.argv[2] === "ic
|
|
|
376
379
|
const one = (f: string) => flags.get(f)?.at(-1);
|
|
377
380
|
const id = op === "edit" ? words.shift() : undefined;
|
|
378
381
|
if (op === "edit" && (!id || words.length)) { console.log("\n kaizen icebox edit <id> --file <path> (or the new text on stdin)\n"); process.exit(1); }
|
|
379
|
-
if (one("board") && one("client")) { console.log("\n --
|
|
382
|
+
if (one("board") && one("client")) { console.log("\n --collection or --client, not both\n"); process.exit(1); }
|
|
380
383
|
const raw = words.length ? words.join(" ") : one("file") ? readFileSync(one("file")!, "utf8") : process.stdin.isTTY ? "" : await Bun.stdin.text();
|
|
381
384
|
const [first = "", ...more] = raw.replace(/\r\n/g, "\n").trim().split("\n");
|
|
382
|
-
if (!first.trim()) { console.log("\n kaizen icebox add [text] [--file <path>] [--kind client|finding|people] [--
|
|
385
|
+
if (!first.trim()) { console.log("\n kaizen icebox add [text] [--file <path>] [--kind client|finding|people] [--collection <name> | --client <name>] [--tag <tag>]...\n the text as words, from --file, or on stdin\n"); process.exit(1); }
|
|
383
386
|
if (op === "edit") {
|
|
384
387
|
const why = src.editItem(state, id!, first, more.join("\n"));
|
|
385
388
|
if (why) { console.log(`\n ${why}\n`); process.exit(1); }
|
|
@@ -401,21 +404,21 @@ if (Bun.argv[2] === "sources" || Bun.argv[2] === "gather" || Bun.argv[2] === "ic
|
|
|
401
404
|
: op === "board" ? src.setBoard(state, ids, val.trim() === "-" ? "" : val)
|
|
402
405
|
: op === "snooze" ? src.snooze(state, ids, val)
|
|
403
406
|
: src.unsnooze(state, ids);
|
|
404
|
-
if (why) { console.log(`\n ${why}\n kaizen icebox kind <ids> client|finding|people · tag <ids> <tags> ·
|
|
405
|
-
console.log(`\n ${op}: ${ids.join(", ")}\n ${where}\n`);
|
|
407
|
+
if (why) { console.log(`\n ${why}\n kaizen icebox kind <ids> client|finding|people · tag <ids> <tags> · collection <ids> <name | -> · snooze <ids> <1d|1w|1m|YYYY-MM-DD> · unsnooze <ids>\n`); process.exit(1); }
|
|
408
|
+
console.log(`\n ${op === "board" ? "collection" : op}: ${ids.join(", ")}\n ${where}\n`);
|
|
406
409
|
} else if (cmd === "icebox" && op === "boards") {
|
|
407
|
-
// kaizen icebox
|
|
410
|
+
// kaizen icebox collections [add <name> [--client] | rm <name>] (also: boards)
|
|
408
411
|
const [verb, ...nm] = Bun.argv.slice(4);
|
|
409
412
|
if (verb === "add" || verb === "rm") {
|
|
410
413
|
const client = nm.includes("--client"), name = nm.filter((w) => w !== "--client").join(" ");
|
|
411
414
|
const why = verb === "add" ? src.saveBoard(state, name, client) : src.removeBoard(state, name);
|
|
412
415
|
if (why) { console.log(`\n ${why}\n`); process.exit(1); }
|
|
413
|
-
} else if (verb) { console.log("\n kaizen icebox
|
|
416
|
+
} else if (verb) { console.log("\n kaizen icebox collections [add <name> [--client] | rm <name>]\n"); process.exit(1); }
|
|
414
417
|
const all = src.readIcebox(state), boards = src.readBoards(state);
|
|
415
418
|
console.log(`\n ${where}`);
|
|
416
419
|
console.log(boards.length
|
|
417
420
|
? "\n" + boards.map((b) => ` ${b.name}${b.client ? c.dim(" client") : ""} ${c.dim(`${all.filter((s) => s.status === "new" && s.board === b.name).length} waiting`)}`).join("\n") + "\n"
|
|
418
|
-
: `\n no
|
|
421
|
+
: `\n no collections yet ${c.dim("— kaizen icebox collections add <name> [--client]")}\n`);
|
|
419
422
|
} else if (cmd === "icebox") {
|
|
420
423
|
const all = src.readIcebox(state), boards = src.readBoards(state), now = Date.now();
|
|
421
424
|
const fresh = all.filter((s) => s.status === "new" && !src.isSnoozed(s, now));
|
package/cli/sources.ts
CHANGED
|
@@ -306,7 +306,7 @@ const writeBoards = (state: string, list: Board[]) => { mkdirSync(state, { recur
|
|
|
306
306
|
// A board name as stored, or why not.
|
|
307
307
|
function boardName(raw: string): { name: string } | { why: string } {
|
|
308
308
|
const name = oneLine(raw);
|
|
309
|
-
return name && name.length <= 40 ? { name } : { why: "a
|
|
309
|
+
return name && name.length <= 40 ? { name } : { why: "a collection name is 1 to 40 characters" };
|
|
310
310
|
}
|
|
311
311
|
// Makes the board when it is new; `client` marks it a client's (never unmarks). The name
|
|
312
312
|
// as the board already spells it.
|
|
@@ -328,8 +328,8 @@ export function saveBoard(state: string, raw: string, client = false): string |
|
|
|
328
328
|
export function removeBoard(state: string, raw: string): string | null {
|
|
329
329
|
const list = readBoards(state);
|
|
330
330
|
const b = list.find((x) => same(x.name, oneLine(raw)));
|
|
331
|
-
if (!b) return "no such
|
|
332
|
-
if (readIcebox(state).some((s) => s.board && same(s.board, b.name))) return "the
|
|
331
|
+
if (!b) return "no such collection";
|
|
332
|
+
if (readIcebox(state).some((s) => s.board && same(s.board, b.name))) return "the collection still has items";
|
|
333
333
|
writeBoards(state, list.filter((x) => x !== b));
|
|
334
334
|
return null;
|
|
335
335
|
}
|
package/cli/web.ts
CHANGED
|
@@ -11,7 +11,7 @@ import {
|
|
|
11
11
|
reviewFindings, pickFindings, backlogItem, startedBacklog, closeBacklog, markBacklogDone, fixPrompt, approvalPrompt, canApproveAwaiting, gateOf, recordAcceptance, healRuns, finishRun, nativePath, closeSessions, sweepSessions, issueUrl,
|
|
12
12
|
launchMode, pruneRuns, pruneSessions, readSessions, ownerOf, runIndex, resumePrompt, runAgent, firstSession, webHosts,
|
|
13
13
|
} from "./state.ts";
|
|
14
|
-
import { ACCOUNT_VAR, accountDir, addAccount, readAccounts, renameAccount,
|
|
14
|
+
import { ACCOUNT_VAR, accountDir, addAccount, loginStatus, readAccounts, renameAccount, removeAccount, resolveAccount, setDefaultAccount, type Login } from "./accounts.ts";
|
|
15
15
|
import { readReport, signalOf } from "./report.ts";
|
|
16
16
|
import { MAX_IMAGE, saveImage } from "./term-image.ts";
|
|
17
17
|
import { shellHistory } from "./term-history.ts";
|
|
@@ -350,6 +350,7 @@ export async function web(repoDir: string, opts: Opts = {}) {
|
|
|
350
350
|
let usageCache: Usage[] = [];
|
|
351
351
|
let usageAt = 0;
|
|
352
352
|
const acctUsage = new Map<string, { at: number; usage: Usage | null }>();
|
|
353
|
+
const acctLogin = new Map<string, { at: number; login: Login }>();
|
|
353
354
|
let pending: ReturnType<typeof setTimeout> | null = null;
|
|
354
355
|
const prBusy = new Set<string>();
|
|
355
356
|
// /state costs ~250 ms of this one thread on a big board (git status per project), and
|
|
@@ -1021,8 +1022,9 @@ export async function web(repoDir: string, opts: Opts = {}) {
|
|
|
1021
1022
|
const a = KNOWN_AGENTS.find((k) => k.cmd === body.agent);
|
|
1022
1023
|
if (!a || !agentUsable(a.cmd)) return bad("unknown agent", 400);
|
|
1023
1024
|
agent = a.cmd;
|
|
1024
|
-
// A sign-in names its account and runs plain: no bypass, no arguments.
|
|
1025
|
-
|
|
1025
|
+
// A sign-in names its account and runs plain: no bypass, no arguments. `account: ""`
|
|
1026
|
+
// with `login: true` signs in the normal login (~/.claude, ~/.codex), never a default account.
|
|
1027
|
+
const signIn = typeof body.account === "string" && (body.account !== "" || body.login === true);
|
|
1026
1028
|
const acct = resolveAccount(a.cmd, signIn ? body.account : undefined);
|
|
1027
1029
|
if (acct.error) return bad(acct.error, 400);
|
|
1028
1030
|
bypass = !signIn && bypassForLaunch(a.cmd, body.yolo, !!YOLO_FLAGS[a.cmd]);
|
|
@@ -1586,9 +1588,18 @@ export async function web(repoDir: string, opts: Opts = {}) {
|
|
|
1586
1588
|
if (why) return bad(why);
|
|
1587
1589
|
added = r?.id;
|
|
1588
1590
|
acctUsage.clear();
|
|
1591
|
+
acctLogin.clear();
|
|
1589
1592
|
changed();
|
|
1590
1593
|
}
|
|
1591
1594
|
const a = readAccounts();
|
|
1595
|
+
// Who is signed in, asked of the tool itself (cli/accounts.ts loginStatus), a minute at a time.
|
|
1596
|
+
const who = async (key: string, tool: "claude" | "codex", dir?: string): Promise<Login> => {
|
|
1597
|
+
const hit = acctLogin.get(key);
|
|
1598
|
+
if (hit && Date.now() - hit.at < 60_000) return hit.login;
|
|
1599
|
+
const login = await loginStatus(tool, dir);
|
|
1600
|
+
acctLogin.set(key, { at: Date.now(), login });
|
|
1601
|
+
return login;
|
|
1602
|
+
};
|
|
1592
1603
|
const rows = await Promise.all(a.accounts.map(async (x) => {
|
|
1593
1604
|
const dir = accountDir(x.id);
|
|
1594
1605
|
let hit = acctUsage.get(x.id);
|
|
@@ -1596,9 +1607,22 @@ export async function web(repoDir: string, opts: Opts = {}) {
|
|
|
1596
1607
|
hit = { at: Date.now(), usage: x.tool === "claude" ? await claudeUsageAt(dir) : codexUsageAt(dir) };
|
|
1597
1608
|
acctUsage.set(x.id, hit);
|
|
1598
1609
|
}
|
|
1599
|
-
|
|
1610
|
+
const l = await who(x.id, x.tool, dir);
|
|
1611
|
+
return { ...x, isDefault: a.default[x.tool] === x.id, signedIn: l.signedIn, who: l.who, plan: l.plan, via: l.via, usage: hit.usage, signIn: `${ACCOUNT_VAR[x.tool]}=${dir} ${x.tool}${x.tool === "codex" ? " login" : ""}` };
|
|
1612
|
+
}));
|
|
1613
|
+
// The normal login of each installed tool (~/.claude, ~/.codex): the one runs use unless an
|
|
1614
|
+
// account above is the default.
|
|
1615
|
+
const normal = await Promise.all((["claude", "codex"] as const).filter((t) => onPath(t)).map(async (t) => {
|
|
1616
|
+
const key = "normal:" + t;
|
|
1617
|
+
let hit = acctUsage.get(key);
|
|
1618
|
+
if (!hit || Date.now() - hit.at > 60_000) {
|
|
1619
|
+
hit = { at: Date.now(), usage: t === "claude" ? await claudeUsage(home) : codexUsage(home) };
|
|
1620
|
+
acctUsage.set(key, hit);
|
|
1621
|
+
}
|
|
1622
|
+
const l = await who(key, t);
|
|
1623
|
+
return { tool: t, isDefault: !a.default[t], signedIn: l.signedIn, who: l.who, plan: l.plan, via: l.via, usage: hit.usage, signIn: t === "claude" ? "claude auth login" : "codex login" };
|
|
1600
1624
|
}));
|
|
1601
|
-
return json({ accounts: rows, windows: process.platform === "win32", ...(added ? { added } : {}) });
|
|
1625
|
+
return json({ accounts: rows, normal, windows: process.platform === "win32", ...(added ? { added } : {}) });
|
|
1602
1626
|
}
|
|
1603
1627
|
|
|
1604
1628
|
// Settings → General → Cleanup: what `kaizen prune` would remove from this page's project,
|
package/package.json
CHANGED
package/skills/kaizen/SKILL.md
CHANGED
|
@@ -52,7 +52,7 @@ Porting the workflow to Codex or Antigravity is covered in [`adapters.md`](adapt
|
|
|
52
52
|
| `/kaizen backlog` | Print the open backlog items across all runs, grouped by source run, with rescued items last under `Orphaned` |
|
|
53
53
|
| `/kaizen gather` | Read the request sources kaizen cannot read by itself and hand their requests over to the icebox |
|
|
54
54
|
| `/kaizen discover` | Read the icebox, group what was gathered, propose tasks, and promote the ones the user picks |
|
|
55
|
-
| "put this in the icebox" (any words) | Not a run: write the text to a temporary file with your file tool (first line the item, the rest notes), then `kaizen icebox add --file <path>`, adding `--kind client\|finding\|people` and `--
|
|
55
|
+
| "put this in the icebox" (any words) | Not a run: write the text to a temporary file with your file tool (first line the item, the rest notes), then `kaizen icebox add --file <path>`, adding `--kind client\|finding\|people` and `--collection <name>` or `--client <name>` when the user made them clear. Never put the text on the command line |
|
|
56
56
|
| `/kaizen docs` | Write this project's documentation into the notebook as a vault agents read first, or bring it up to date |
|
|
57
57
|
| `/kaizen docs lint` | Run the read-only `kaizen docs lint` CLI command; report broken links, missing sources and stale notes |
|
|
58
58
|
| `/kaizen concept [number] <brief>` | Make product concepts as clickable prototypes and get one approved before any build |
|
|
@@ -9,7 +9,7 @@ the need actually is, and which are worth a task. The user decides; you propose.
|
|
|
9
9
|
|
|
10
10
|
1. Run `kaizen icebox`. It prints one item per line: an id; in brackets the kind
|
|
11
11
|
(Client, Finding or People say; a `?` after it means no one sorted it yet), the
|
|
12
|
-
|
|
12
|
+
collection and `#tags`; the category in brackets; the text; the source (`manual` is the
|
|
13
13
|
user's own capture); and the item's link title and other cells beneath. Snoozed items
|
|
14
14
|
are listed apart and are not proposed. If it says the icebox is empty, say so and stop.
|
|
15
15
|
2. **Sort what is unsorted.** For each item whose kind has a `?`, pick its kind from
|
|
@@ -114,8 +114,8 @@ Maintain `00-explore.md` with:
|
|
|
114
114
|
findings (one line each, with its link) as a multi-select question: "Add any of these
|
|
115
115
|
to the icebox?". Add only the ones the user ticks: for each, write its line and link
|
|
116
116
|
to a new temporary file outside the project with the file tool, then run
|
|
117
|
-
`kaizen icebox add --file <path> --kind finding` (add `--
|
|
118
|
-
names
|
|
117
|
+
`kaizen icebox add --file <path> --kind finding` (add `--collection <name>` when the run
|
|
118
|
+
names one). Nothing ticked, nothing added; never add without the question, and
|
|
119
119
|
never put the finding's text on the command line.
|
|
120
120
|
|
|
121
121
|
When the material questions are resolved or explicitly deferred, show the short
|
|
@@ -38,8 +38,8 @@ anything.
|
|
|
38
38
|
| `/kaizen backlog` | Print open backlog items across all runs, grouped by source run, rescued items last under `Orphaned` |
|
|
39
39
|
| `/kaizen gather` | Read request sources kaizen cannot read by itself; their requests land in the icebox, nothing starts |
|
|
40
40
|
| `/kaizen discover` | Group what is in the icebox and promote the tasks you pick; nothing starts |
|
|
41
|
-
| `kaizen icebox add [--file <f>] [--kind client\|finding\|people] [--
|
|
42
|
-
| `kaizen icebox edit\|kind\|tag\|
|
|
41
|
+
| `kaizen icebox add [--file <f>] [--kind client\|finding\|people] [--collection <c> \| --client <name>] [--tag <t>]` | "Put this in the icebox": a note, link or file, text from the file or stdin (never a shell word); a link's title is read |
|
|
42
|
+
| `kaizen icebox edit\|kind\|tag\|collection\|snooze\|unsnooze <ids> ...`, `kaizen icebox collections` | Reword an item, set its kind, tags or collection, hide it until `1d`/`1w`/`1m`/a date; list or add boards |
|
|
43
43
|
| `/kaizen docs [lint]` | Write or refresh the project's docs vault in the notebook, which agents read first; `lint` only reports what is stale, broken or uncovered |
|
|
44
44
|
| `kaizen automation list\|add\|run <id>\|pause <id>\|resume <id>\|rm <id>\|runs <id>` | Schedules that start an unattended auto-mode run in this project (hourly, daily, weekdays, weekly or cron; optional precheck). Fires only while a board runs |
|
|
45
45
|
| `kaizen worker init\|start <wid>\|status\|config\|merge\|set <run> on\|off` | Orchestration (off by default): split a run into workers, each in its own board terminal and folder. `kaizen worker report` is for the workers themselves |
|
package/web/board/icebox.ts
CHANGED
|
@@ -3,7 +3,7 @@ import { termStop } from "./agent-term.ts";
|
|
|
3
3
|
import { load, post } from "./api.ts";
|
|
4
4
|
import { via } from "./cards.ts";
|
|
5
5
|
import { mic, stopDictation } from "./dictation.ts";
|
|
6
|
-
import { $, dataUrls, html, ico, motion, pageOf, pager, pagerHtml, raw, SKEL, wirePager } from "./dom.ts";
|
|
6
|
+
import { $, dataUrls, html, ico, modal, motion, pageOf, pager, pagerHtml, raw, SKEL, wirePager } from "./dom.ts";
|
|
7
7
|
import { plogo, setShown, short, showable } from "./projects.ts";
|
|
8
8
|
import { playSound, soundPick, toast } from "./toast.ts";
|
|
9
9
|
import { go, view } from "./views.ts";
|
|
@@ -88,7 +88,26 @@ function wireOnce() {
|
|
|
88
88
|
if (view === "sources" && srcOpen()) openSources();
|
|
89
89
|
});
|
|
90
90
|
}
|
|
91
|
-
// A
|
|
91
|
+
// A new collection: its name and whether it is a client's, asked in the board's own dialog
|
|
92
|
+
// (the desktop app has no window.prompt). Resolves null when cancelled.
|
|
93
|
+
function askCollection(where = ""): Promise<{ name: string; client: boolean } | null> {
|
|
94
|
+
return new Promise((done) => {
|
|
95
|
+
const dl = modal(html`<label class="hint" for="ice-cn" style="margin:0">New collection${where ? ` in ${where}` : ""}: a client or a topic</label><input class="sel" id="ice-cn" maxlength="40" placeholder="e.g. Arupadatu, Pricing" autocomplete="off" spellcheck="false"><label class="ice-cn-cl"><input type="checkbox" id="ice-cn-c"> A client — its items count as Client</label><div class="row"><button type="button" class="btn ghost" value="">Cancel</button><button class="btn pri">Create</button></div>`);
|
|
96
|
+
const f = dl.querySelector("form"), inp = dl.querySelector("#ice-cn") as HTMLInputElement;
|
|
97
|
+
let answer = null;
|
|
98
|
+
dl.querySelector(".btn.ghost").onclick = () => dl.close();
|
|
99
|
+
f.onsubmit = (e) => {
|
|
100
|
+
e.preventDefault();
|
|
101
|
+
const name = inp.value.trim();
|
|
102
|
+
if (!name) return inp.focus();
|
|
103
|
+
answer = { name, client: (dl.querySelector("#ice-cn-c") as HTMLInputElement).checked };
|
|
104
|
+
dl.close();
|
|
105
|
+
};
|
|
106
|
+
dl.addEventListener("close", () => done(answer));
|
|
107
|
+
inp.focus();
|
|
108
|
+
});
|
|
109
|
+
}
|
|
110
|
+
// A person mark for a client's collection.
|
|
92
111
|
const PERSON = raw(
|
|
93
112
|
'<svg viewBox="0 0 16 16" aria-hidden="true"><circle cx="8" cy="5.2" r="2.6" fill="none" stroke="currentColor" stroke-width="1.5"/><path d="M3 13.6c.7-2.5 2.6-3.8 5-3.8s4.3 1.3 5 3.8" fill="none" stroke="currentColor" stroke-width="1.5" stroke-linecap="round"/></svg>',
|
|
94
113
|
);
|
|
@@ -264,7 +283,7 @@ export async function openSources() {
|
|
|
264
283
|
// left out of the list, the count and Swipe until its date (the server says `asleep`).
|
|
265
284
|
awake = ((d && d.icebox) || []).filter((it) => !it.asleep),
|
|
266
285
|
ice = [...awake, ...((d && d.dismissed) || [])],
|
|
267
|
-
waiting = awake.length,
|
|
286
|
+
waiting = awake.filter((it) => it.status === "new").length,
|
|
268
287
|
G = (d && d.gatherer) || {},
|
|
269
288
|
chatOn = G.use === "chatgpt" && G.connected;
|
|
270
289
|
// A source belongs to one project, named on its row. Picking another only arms Move: a select
|
|
@@ -314,7 +333,9 @@ export async function openSources() {
|
|
|
314
333
|
? "Dismissed"
|
|
315
334
|
: it.status === "done"
|
|
316
335
|
? "Done"
|
|
317
|
-
: it.
|
|
336
|
+
: it.status === "promoted"
|
|
337
|
+
? "Promoted"
|
|
338
|
+
: it.category || srcOf(it)?.category || platOf(srcOf(it) || { url: it.source }),
|
|
318
339
|
count = (xs, f) => {
|
|
319
340
|
const m = new Map();
|
|
320
341
|
xs.forEach((it) => {
|
|
@@ -352,7 +373,7 @@ export async function openSources() {
|
|
|
352
373
|
.map((_, i) => i)
|
|
353
374
|
.filter((i) => {
|
|
354
375
|
const it = ice[i];
|
|
355
|
-
return inProj(it) && onBoard(it) && ofKind(it) && (iceCat ? catOf(it) === iceCat : it.status
|
|
376
|
+
return inProj(it) && onBoard(it) && ofKind(it) && (iceCat ? catOf(it) === iceCat : it.status === "new") && (!iceSrc || srcKey(it) === iceSrc);
|
|
356
377
|
})
|
|
357
378
|
.sort((a, b) => (Date.parse(ice[b].at) || 0) - (Date.parse(ice[a].at) || 0));
|
|
358
379
|
// Only the page: j and k, select-all and bulk actions stay on what shows.
|
|
@@ -382,8 +403,8 @@ export async function openSources() {
|
|
|
382
403
|
const srcIco = (it) => fav(it.source, "link", srcOf(it)?.social);
|
|
383
404
|
const curSrc = iceSrc && [...bySrc].find(([k]) => k === iceSrc)?.[1].it;
|
|
384
405
|
const chips = html`${
|
|
385
|
-
// Dismissed and Done are hidden until picked, so even a lone one is a choice.
|
|
386
|
-
byCat.size > 1 || byCat.has("Dismissed") || byCat.has("Done")
|
|
406
|
+
// Promoted, Dismissed and Done are hidden until picked, so even a lone one is a choice.
|
|
407
|
+
byCat.size > 1 || byCat.has("Dismissed") || byCat.has("Done") || byCat.has("Promoted")
|
|
387
408
|
? pick(
|
|
388
409
|
"ice-fc",
|
|
389
410
|
"Category",
|
|
@@ -407,8 +428,8 @@ export async function openSources() {
|
|
|
407
428
|
cardsOn = iceView === "cards" && !narrow;
|
|
408
429
|
// The boards bar: All, each board with what waits on it, + Board; the kind filters on the right.
|
|
409
430
|
const nOn = (b) => pv.filter((it) => isWaiting(it) && sameName(it.board, b.name)).length;
|
|
410
|
-
const boardsBar = html`<div class="ice-boards"><div class="ice-chips" role="group" aria-label="
|
|
411
|
-
const bar = html`<div class="tk-bar ice-bar">${!cardsOn && !narrow && order.length ? html`<input type="checkbox" id="ice-all" aria-label="Select every request shown"${nSel && nSel === order.length ? " checked" : ""}>` : ""}${narrow ? "" : html`<div class="ice-view" role="group" aria-label="View"><button data-view="cards" aria-pressed="${String(cardsOn)}">Cards</button><button data-view="sort" aria-pressed="${String(!cardsOn)}">Sort</button></div>`}<span class="count">${iceCat === "Dismissed" || iceCat === "Done" ? `${order.length} ${iceCat.toLowerCase()}` : `${order.length < waiting ? `${order.length} of ${waiting}` : waiting} waiting`}</span><span class="end"></span>${String(chips) ? html`<details class="ice-filt"><summary class="ib${iceCat || iceSrc ? " on" : ""}" aria-label="Filter requests" title="Filter by category or source">${ico("filter")}</summary><div class="ice-fpop">${chips}</div></details>` : ""}${order.some((i) => isWaiting(ice[i])) ? html`<button class="btn ghost sm" id="ice-sw" title="Sort one at a time: swipe right to promote, left to dismiss"><span aria-hidden="true">⇆</span> Swipe</button>` : ""}${narrow ? "" : html`<button class="btn sm" id="src-tog" aria-expanded="${String(!!srcShow)}" aria-controls="src-sec" title="Sources, and Gather all">${ico("link")} Sources · ${list.length}</button>`}</div>`;
|
|
431
|
+
const boardsBar = html`<div class="ice-boards"><div class="ice-chips" role="group" aria-label="Collections"><button class="ice-chip${iceBoard ? "" : " on"}" data-bd="" aria-pressed="${String(!iceBoard)}">All</button>${boards.map((b) => html`<button class="ice-chip${sameName(iceBoard, b.name) ? " on" : ""}" data-bd="${b.name}" aria-pressed="${String(sameName(iceBoard, b.name))}"${b.client ? raw(' title="A client\'s collection: its items are Client"') : ""}>${b.client ? PERSON : ""}<span>${b.name}</span><i>${nOn(b)}</i></button>`)}<button class="ice-chip add" id="ice-nb" title="Make a collection for a client or a topic">${ico("plus")}Collection</button></div><div class="ice-chips" role="group" aria-label="Kinds">${Object.entries(KIND).map(([k, l]) => html`<button class="ice-chip k-${k}${iceKinds.has(k) ? " on" : ""}" data-kf="${k}" aria-pressed="${String(iceKinds.has(k))}">${l}</button>`)}</div></div>`;
|
|
432
|
+
const bar = html`<div class="tk-bar ice-bar">${!cardsOn && !narrow && order.length ? html`<input type="checkbox" id="ice-all" aria-label="Select every request shown"${nSel && nSel === order.length ? " checked" : ""}>` : ""}${narrow ? "" : html`<div class="ice-view" role="group" aria-label="View"><button data-view="cards" aria-pressed="${String(cardsOn)}">Cards</button><button data-view="sort" aria-pressed="${String(!cardsOn)}">Sort</button></div>`}<span class="count">${iceCat === "Dismissed" || iceCat === "Done" || iceCat === "Promoted" ? `${order.length} ${iceCat.toLowerCase()}` : `${order.length < waiting ? `${order.length} of ${waiting}` : waiting} waiting`}</span><span class="end"></span>${String(chips) ? html`<details class="ice-filt"><summary class="ib${iceCat || iceSrc ? " on" : ""}" aria-label="Filter requests" title="Filter by category or source">${ico("filter")}</summary><div class="ice-fpop">${chips}</div></details>` : ""}${order.some((i) => isWaiting(ice[i])) ? html`<button class="btn ghost sm" id="ice-sw" title="Sort one at a time: swipe right to promote, left to dismiss"><span aria-hidden="true">⇆</span> Swipe</button>` : ""}${narrow ? "" : html`<button class="btn sm" id="src-tog" aria-expanded="${String(!!srcShow)}" aria-controls="src-sec" title="Sources, and Gather all">${ico("link")} Sources · ${list.length}</button>`}</div>`;
|
|
412
433
|
// The capture box: what is typed, pasted, attached or dictated lands in the icebox on the picked
|
|
413
434
|
// board. In All projects it names the project, as the Add pop-up did. Field and mic are slotted in.
|
|
414
435
|
const capPs = dir ? [] : showable();
|
|
@@ -420,7 +441,7 @@ export async function openSources() {
|
|
|
420
441
|
const capTo = capTo0,
|
|
421
442
|
capP = capPs.find((p) => p.dir === cap.dir);
|
|
422
443
|
const capBoards = ((d && d.boards) || []).filter((b) => b.dir === capTo);
|
|
423
|
-
const capBox = html`<div class="ice-cap" id="ice-cap"><span id="ice-cap-slot"></span>${cap.files.length ? html`<div class="ice-att">${cap.files.map((f, n) => html`<span class="ice-file">${ico("clip")}<span>${f.name}</span><button type="button" class="ib sm" data-rf="${n}" aria-label="Remove ${f.name}" title="Remove">${ico("x")}</button></span>`)}</div>` : ""}<div class="ice-cap-row"><button type="button" class="ib" id="ice-pick" aria-label="Attach files" title="Attach files">${ico("clip")}</button><span id="ice-mic-slot"></span><input type="file" id="ice-file" multiple hidden>${dir ? "" : pick("ice-cp", "Project", capP ? html`${plogo(capP.dir, capP.label)}<span>${short(capP.label)}</span>` : html`<span>Choose project</span>`, html`${capPs.map((p) => opt(p.dir, p.dir === cap.dir, html`${plogo(p.dir, p.label)}<span>${p.label}</span>`, p.label))}`)}${pick("ice-cb", "
|
|
444
|
+
const capBox = html`<div class="ice-cap" id="ice-cap"><span id="ice-cap-slot"></span>${cap.files.length ? html`<div class="ice-att">${cap.files.map((f, n) => html`<span class="ice-file">${ico("clip")}<span>${f.name}</span><button type="button" class="ib sm" data-rf="${n}" aria-label="Remove ${f.name}" title="Remove">${ico("x")}</button></span>`)}</div>` : ""}<div class="ice-cap-row"><button type="button" class="ib" id="ice-pick" aria-label="Attach files" title="Attach files">${ico("clip")}</button><span id="ice-mic-slot"></span><input type="file" id="ice-file" multiple hidden>${dir ? "" : pick("ice-cp", "Project", capP ? html`${plogo(capP.dir, capP.label)}<span>${short(capP.label)}</span>` : html`<span>Choose project</span>`, html`${capPs.map((p) => opt(p.dir, p.dir === cap.dir, html`${plogo(p.dir, p.label)}<span>${p.label}</span>`, p.label))}`)}${pick("ice-cb", "Collection", html`<span>${cap.board || "Inbox"}</span>`, html`${opt("", !cap.board, html`<span>Inbox</span>`, "inbox")}${capBoards.map((b) => opt(b.name, sameName(cap.board, b.name), html`${b.client ? PERSON : ""}<span>${b.name}</span>`, b.name))}${cap.board && !capBoards.some((b) => sameName(b.name, cap.board)) ? opt(cap.board, true, html`<span>${cap.board}</span><i>new</i>`, cap.board) : ""}${opt("\n", false, html`${ico("plus")}<span>New collection…</span>`, "new collection")}`)}<span class="end"></span><button type="button" class="btn pri sm" id="ice-save" aria-label="Save to the icebox"${cap.busy ? " disabled" : ""}>${ico("send")}<span>${cap.busy ? "Saving…" : "Save ↵"}</span></button></div></div>`;
|
|
424
445
|
const bulk = iceSel.size
|
|
425
446
|
? html`<div class="ice-bulk" role="toolbar" aria-label="Selected requests"><span>${iceSel.size} selected</span><span class="end"></span><button class="btn sm" id="ice-bp" title="Promote (p)">${ico("plus")} Promote</button><button class="btn ghost sm" id="ice-bz" title="Snooze a week (h)">${ico("clock")} Snooze</button><button class="btn ghost sm" id="ice-bd" title="Dismiss (d)">${ico("x")} Dismiss</button><button class="btn ghost sm" id="ice-bc" title="Clear selection (Esc)">Clear</button></div>`
|
|
426
447
|
: "";
|
|
@@ -465,8 +486,8 @@ export async function openSources() {
|
|
|
465
486
|
? html`${b("data-sz", "1d", "Tomorrow")}${b("data-sz", "1w", "Next week")}${b("data-sz", "1m", "Next month")}<div class="ice-date"><input type="date" class="sel" id="ice-sd" min="${day(1)}" max="${day(365)}" aria-label="Snooze until"><button type="button" class="btn sm" data-sz="">Snooze</button></div>`
|
|
466
487
|
: m === "kind"
|
|
467
488
|
? html`${Object.entries(KIND).map(([v, l]) => b("data-kd", v, l, it.kind === v && it.sorted !== "rules"))}`
|
|
468
|
-
: html`${b("data-bo", "", "Inbox", !it.board)}${((d && d.boards) || []).filter((x) => x.dir === it.dir).map((x) => b("data-bo", x.name, html`${x.client ? PERSON : ""}${x.name}`, sameName(it.board, x.name)))}<button type="button" role="menuitem" data-bo-new="1">${ico("plus")}New
|
|
469
|
-
return html`<div class="menu-pop ice-mpop" role="menu" data-mi="${i}" aria-label="${m === "snooze" ? "Snooze until" : m === "kind" ? "Kind" : "
|
|
489
|
+
: html`${b("data-bo", "", "Inbox", !it.board)}${((d && d.boards) || []).filter((x) => x.dir === it.dir).map((x) => b("data-bo", x.name, html`${x.client ? PERSON : ""}${x.name}`, sameName(it.board, x.name)))}<button type="button" role="menuitem" data-bo-new="1">${ico("plus")}New collection…</button>`;
|
|
490
|
+
return html`<div class="menu-pop ice-mpop" role="menu" data-mi="${i}" aria-label="${m === "snooze" ? "Snooze until" : m === "kind" ? "Kind" : "Collection"}">${inner}</div>`;
|
|
470
491
|
};
|
|
471
492
|
const badges = (it) =>
|
|
472
493
|
html`${it.status === "done" && it.written ? html`<span title="Written back ${ago(it.written)}">written back</span>` : ""}${it.status === "done" && it.writeError ? html`<span title="${it.writeError}">write-back failed</span>` : ""}${it.status === "promoted" ? html`<span title="Promoted to Tasks: ${it.idea || ""}">promoted</span>` : ""}${it.replied ? html`<span title="Replied ${ago(it.replied)}">replied</span>` : ""}`;
|
|
@@ -475,7 +496,7 @@ export async function openSources() {
|
|
|
475
496
|
const it = ice[i],
|
|
476
497
|
k = iceKey(it),
|
|
477
498
|
open = iceForm === k;
|
|
478
|
-
const head = html`<div class="ice-row${iceCur === k ? " cur" : ""}${iceSel.has(k) ? " sel" : ""}" data-i="${i}" data-k="${k}"><input type="checkbox" id="ice-ck-${i}" data-ck="${i}"${iceSel.has(k) ? " checked" : ""} aria-label="Select: ${it.text}">${live(it) ? menuBtn(i, it, "kind", kindOf(it), "ice-kb", "Kind") : kindOf(it)}<span class="ice-src" title="${srcName(it)}">${fav(it.source, "link", srcOf(it)?.social)}</span><button class="ice-t" id="ice-o-${i}" data-o="${i}" aria-expanded="${String(open)}" title="${it.text}">${it.text}</button><span class="ice-meta">${proj(it)}${badges(it)}${live(it) ? menuBtn(i, it, "board", it.board || "Inbox", "ice-bo" + (it.board ? "" : " none"), "
|
|
499
|
+
const head = html`<div class="ice-row${iceCur === k ? " cur" : ""}${iceSel.has(k) ? " sel" : ""}" data-i="${i}" data-k="${k}"><input type="checkbox" id="ice-ck-${i}" data-ck="${i}"${iceSel.has(k) ? " checked" : ""} aria-label="Select: ${it.text}">${live(it) ? menuBtn(i, it, "kind", kindOf(it), "ice-kb", "Kind") : kindOf(it)}<span class="ice-src" title="${srcName(it)}">${fav(it.source, "link", srcOf(it)?.social)}</span><button class="ice-t" id="ice-o-${i}" data-o="${i}" aria-expanded="${String(open)}" title="${it.text}">${it.text}</button><span class="ice-meta">${proj(it)}${badges(it)}${live(it) ? menuBtn(i, it, "board", it.board || "Inbox", "ice-bo" + (it.board ? "" : " none"), "Collection") : it.board ? html`<span>${it.board}</span>` : ""}<span class="ice-age">${ago(it.at)}</span><span class="ice-ra">${it.status === "promoted" || it.status === "done" ? "" : html`<button class="btn ghost sm" id="ice-pr-${i}" data-pr="${i}" title="Promote to Tasks (p)" aria-label="Promote to Tasks: ${it.text}">${ico("plus")}</button>`}${live(it) ? menuBtn(i, it, "snooze", ico("clock"), "btn ghost sm", "Snooze (h: a week)") : ""}${it.status === "promoted" || it.status === "done" ? "" : it.status === "dismissed" ? html`<button class="btn ghost sm" id="ice-rs-${i}" data-rs="${i}" title="Restore to waiting" aria-label="Restore: ${it.text}">Restore</button>` : html`<button class="btn ghost sm" id="ice-ds-${i}" data-ds="${i}" title="Dismiss (d)" aria-label="Dismiss: ${it.text}">${ico("x")}</button>`}</span></span>${menu(i, it)}</div>`;
|
|
479
500
|
const more = open
|
|
480
501
|
? html`<div class="ice-open">${it.notes ? html`<div class="ice-notes">${it.notes}</div>` : ""}${imgs(it)}<span class="hint" style="margin:0">From ${srcName(it)} · ${ago(it.at)}${it.post ? html` · <a href="${web(it.post)}" target="_blank" rel="noopener">open post</a>` : ""}</span>${replyBox(it)}${icePro === k ? form(it) : ""}</div>`
|
|
481
502
|
: "";
|
|
@@ -502,7 +523,7 @@ export async function openSources() {
|
|
|
502
523
|
const head = html`<div class="ice-row ice-prow${iceCur === k ? " cur" : ""}" data-i="${i}" data-k="${k}"${live(it) ? raw(' data-swipe="1"') : ""}><div class="ice-pbg" aria-hidden="true"><span class="pro">${ico("check")}Task</span><span class="dis">Dismiss${ico("x")}</span></div><div class="ice-pf"><div class="ice-pm"><div class="ice-ph">${live(it) ? menuBtn(i, it, "kind", kindOf(it), "ice-kb", "Kind") : kindOf(it)}${it.sorted === "rules" && live(it) ? html`<span class="ice-uns">unsorted</span>` : ""}<span class="ice-meta">${badges(it)}</span></div><button class="ice-t" id="ice-o-${i}" data-o="${i}" aria-expanded="${String(open)}">${it.text}</button><span class="ice-pmeta">${proj(it)}${it.board ? html`<span>${it.board}</span>` : ""}<span>${ago(it.at)}</span></span></div>${thumb(it)}${done ? "" : it.status === "dismissed" ? html`<button class="btn ghost sm" id="ice-rs-${i}" data-rs="${i}" aria-label="Restore: ${it.text}">Restore</button>` : html`<button class="ib ice-ptask" id="ice-pr-${i}" data-pr="${i}" aria-label="Make a task: ${it.text}" title="Make a task">${ico("arrow")}</button>`}</div>${menu(i, it)}</div>`;
|
|
503
524
|
// Opened, a phone row also offers what its gestures do, for anyone who cannot swipe or hold.
|
|
504
525
|
const acts = live(it)
|
|
505
|
-
? html`<div class="ice-form-acts ice-pacts">${menuBtn(i, it, "snooze", html`${ico("clock")}Snooze`, "btn ghost sm", "Snooze")}${menuBtn(i, it, "board", html
|
|
526
|
+
? html`<div class="ice-form-acts ice-pacts">${menuBtn(i, it, "snooze", html`${ico("clock")}Snooze`, "btn ghost sm", "Snooze")}${menuBtn(i, it, "board", html`${it.board || "Inbox"}`, "btn ghost sm", "Collection")}<span class="end"></span><button class="btn ghost sm" id="ice-ds-${i}" data-ds="${i}" aria-label="Dismiss: ${it.text}">${ico("x")}Dismiss</button></div>`
|
|
506
527
|
: "";
|
|
507
528
|
const more = open
|
|
508
529
|
? html`<div class="ice-open">${it.notes ? html`<div class="ice-notes">${it.notes}</div>` : ""}${imgs(it)}<span class="hint" style="margin:0">From ${srcName(it)} · ${ago(it.at)}${it.post ? html` · <a href="${web(it.post)}" target="_blank" rel="noopener">open post</a>` : ""}</span>${acts}${replyBox(it)}${icePro === k ? form(it) : ""}</div>`
|
|
@@ -516,7 +537,7 @@ export async function openSources() {
|
|
|
516
537
|
k = iceKey(it),
|
|
517
538
|
lk = it.link && /^https?:\/\//i.test(it.link.url) ? it.link : null,
|
|
518
539
|
site = lk ? host(lk.url).replace(/^www\./, "") : "";
|
|
519
|
-
const acts = html`${it.status === "promoted" || it.status === "done" ? "" : html`<button class="btn ghost sm" id="ice-pr-${i}" data-pr="${i}" title="Promote to Tasks (p)" aria-label="Promote to Tasks: ${it.text}">${ico("arrow")}Task</button>`}${live(it) ? html`${menuBtn(i, it, "snooze", html`${ico("clock")}Snooze`, "btn ghost sm", "Snooze")}${menuBtn(i, it, "kind", "Kind", "btn ghost sm", "Kind")}${menuBtn(i, it, "board", "
|
|
540
|
+
const acts = html`${it.status === "promoted" || it.status === "done" ? "" : html`<button class="btn ghost sm" id="ice-pr-${i}" data-pr="${i}" title="Promote to Tasks (p)" aria-label="Promote to Tasks: ${it.text}">${ico("arrow")}Task</button>`}${live(it) ? html`${menuBtn(i, it, "snooze", html`${ico("clock")}Snooze`, "btn ghost sm", "Snooze")}${menuBtn(i, it, "kind", "Kind", "btn ghost sm", "Kind")}${menuBtn(i, it, "board", "Collection", "btn ghost sm", "Collection")}` : ""}<span class="end"></span>${it.status === "promoted" || it.status === "done" ? "" : it.status === "dismissed" ? html`<button class="btn ghost sm" id="ice-rs-${i}" data-rs="${i}" title="Restore to waiting" aria-label="Restore: ${it.text}">Restore</button>` : html`<button class="btn ghost sm" id="ice-ds-${i}" data-ds="${i}" title="Dismiss (d)" aria-label="Dismiss: ${it.text}">${ico("x")}</button>`}`;
|
|
520
541
|
return html`<article class="ice-card${iceCur === k ? " cur" : ""}" data-i="${i}" data-k="${k}">${lk ? html`<a class="ice-lk" href="${web(lk.url)}" target="_blank" rel="noopener noreferrer" style="--h:${hue(site)}"><b>${lk.title || site}</b>${lk.summary ? html`<span>${lk.summary}</span>` : ""}<small>${site}</small></a>` : ""}<div class="ice-cb"><div class="ice-ch">${kindOf(it)}${it.sorted === "rules" && live(it) ? html`<span class="ice-uns" title="Kind set by a rule: pick one with Kind">unsorted</span>` : ""}<span class="ice-meta">${badges(it)}</span></div><button class="ice-ct" id="ice-o-${i}" data-o="${i}" title="Open in the Sort list">${it.text}</button>${imgs(it, true)}<div class="ice-cf">${it.board ? html`<span class="ice-cbd">${it.board}</span>` : ""}${(it.tags || []).map((t) => html`<span class="ice-tag">#${t}</span>`)}${proj(it)}<span class="end"></span><span class="ice-when">${it.source !== "manual" ? `${srcName(it)} · ` : ""}${ago(it.at)}</span></div></div><div class="ice-ca">${acts}</div>${menu(i, it)}</article>`;
|
|
521
542
|
};
|
|
522
543
|
const inbox =
|
|
@@ -682,12 +703,12 @@ export async function openSources() {
|
|
|
682
703
|
cap.dir = v;
|
|
683
704
|
openSources().then(() => cap.ta.focus());
|
|
684
705
|
});
|
|
685
|
-
wirePick("ice-cb", (v) => {
|
|
706
|
+
wirePick("ice-cb", async (v) => {
|
|
686
707
|
if (v === "\n") {
|
|
687
|
-
const
|
|
688
|
-
if (!
|
|
689
|
-
if (
|
|
690
|
-
v =
|
|
708
|
+
const a = await askCollection();
|
|
709
|
+
if (!a) return cap.ta.focus();
|
|
710
|
+
if (a.client) await post("/icebox", { op: "boards", act: "add", dir: dir || cap.dir, name: a.name, client: true });
|
|
711
|
+
v = a.name;
|
|
691
712
|
}
|
|
692
713
|
cap.board = v;
|
|
693
714
|
cap.boardDir = dir || cap.dir;
|
|
@@ -733,17 +754,17 @@ export async function openSources() {
|
|
|
733
754
|
} catch (e) {}
|
|
734
755
|
openSources();
|
|
735
756
|
}));
|
|
736
|
-
// +
|
|
757
|
+
// + Collection: a name, and whether it is a client's (its items then count as Client).
|
|
737
758
|
if ($("ice-nb"))
|
|
738
759
|
$("ice-nb").onclick = async () => {
|
|
739
760
|
const to = dir || cap.dir;
|
|
740
761
|
if (!to) return toast("Pick a project first");
|
|
741
|
-
const
|
|
742
|
-
if (!
|
|
743
|
-
const
|
|
762
|
+
const a = await askCollection(dir ? "" : capP?.label || "this project");
|
|
763
|
+
if (!a) return;
|
|
764
|
+
const { name, client } = a;
|
|
744
765
|
const j = await post("/icebox", { op: "boards", act: "add", dir: to, name, client });
|
|
745
766
|
if (j.ok) {
|
|
746
|
-
toast(`
|
|
767
|
+
toast(`Collection ${name} made`);
|
|
747
768
|
load();
|
|
748
769
|
}
|
|
749
770
|
if (srcOpen()) openSources();
|
|
@@ -1073,9 +1094,12 @@ export async function openSources() {
|
|
|
1073
1094
|
}));
|
|
1074
1095
|
pp.querySelectorAll("[data-kd]").forEach((b) => (b.onclick = () => setOne(it, { op: "kind", kind: b.dataset.kd }, `Kind: ${KIND[b.dataset.kd]}`)));
|
|
1075
1096
|
pp.querySelectorAll("[data-bo]").forEach((b) => (b.onclick = () => setOne(it, { op: "board", board: b.dataset.bo }, b.dataset.bo ? `Moved to ${b.dataset.bo}` : "Moved to the Inbox")));
|
|
1076
|
-
pp.querySelectorAll("[data-bo-new]").forEach((b) => (b.onclick = () => {
|
|
1077
|
-
|
|
1078
|
-
|
|
1097
|
+
pp.querySelectorAll("[data-bo-new]").forEach((b) => (b.onclick = async () => {
|
|
1098
|
+
iceMenu = "";
|
|
1099
|
+
const a = await askCollection();
|
|
1100
|
+
if (!a) return;
|
|
1101
|
+
if (a.client) await post("/icebox", { op: "boards", act: "add", dir: it.dir, name: a.name, client: true });
|
|
1102
|
+
setOne(it, { op: "board", board: a.name }, `Moved to ${a.name}`);
|
|
1079
1103
|
}));
|
|
1080
1104
|
});
|
|
1081
1105
|
// Bulk: one dismiss per project; promote one request at a time, each its own task
|
|
@@ -5,7 +5,11 @@ import { store } from "./store.ts";
|
|
|
5
5
|
import { toast } from "./toast.ts";
|
|
6
6
|
|
|
7
7
|
// Settings → AI Provider Accounts. /accounts never carries a token.
|
|
8
|
-
type Row = { id: string; tool: string; name: string; isDefault: boolean; signedIn: boolean; signIn: string; usage: any };
|
|
8
|
+
type Row = { id: string; tool: string; name: string; isDefault: boolean; signedIn: boolean; signIn: string; usage: any; who?: string; plan?: string; via?: string };
|
|
9
|
+
type Normal = { tool: string; isDefault: boolean; signedIn: boolean; signIn: string; usage: any; who?: string; plan?: string; via?: string };
|
|
10
|
+
// Who the tool says is signed in: an email (Claude), else how (Codex: "ChatGPT"), and the plan.
|
|
11
|
+
const whoLine = (a: { signedIn: boolean; who?: string; plan?: string; via?: string }) =>
|
|
12
|
+
a.signedIn && (a.who || a.via || a.plan) ? html`<span class="ac-who">${[a.who ?? (a.via ? `via ${a.via}` : ""), a.plan].filter(Boolean).join(" · ")}</span>` : "";
|
|
9
13
|
const TOOL: Record<string, string> = { claude: "Claude", codex: "Codex" };
|
|
10
14
|
|
|
11
15
|
function usageLine(u: any, signed: boolean) {
|
|
@@ -17,15 +21,25 @@ function usageLine(u: any, signed: boolean) {
|
|
|
17
21
|
|
|
18
22
|
const row = (a: Row) =>
|
|
19
23
|
html`<div class="sk" data-q="account ${a.name.toLowerCase()} ${a.tool}">
|
|
20
|
-
<div class="sk-h"><img class="ag-i" src="${AGENT_FAVICONS[a.tool] ?? ""}" alt="" width="28" height="28"><span class="sk-n"><input class="sel ac-name" data-ac-name="${a.id}" value="${a.name}" aria-label="Account name, click to rename" title="Click to rename" maxlength="60" autocomplete="off" spellcheck="false">${usageLine(a.usage, a.signedIn)}</span>
|
|
24
|
+
<div class="sk-h"><img class="ag-i" src="${AGENT_FAVICONS[a.tool] ?? ""}" alt="" width="28" height="28"><span class="sk-n"><input class="sel ac-name" data-ac-name="${a.id}" value="${a.name}" aria-label="Account name, click to rename" title="Click to rename" maxlength="60" autocomplete="off" spellcheck="false">${whoLine(a)}${usageLine(a.usage, a.signedIn)}</span>
|
|
21
25
|
${a.signedIn && !a.usage?.expired ? "" : html`<button type="button" class="btn" data-ac-sign="${a.id}" data-tool="${a.tool}">Sign in</button>`}
|
|
22
26
|
<button type="button" class="btn" data-ac-def="${a.isDefault ? "" : a.id}" data-tool="${a.tool}" aria-pressed="${String(a.isDefault)}">${a.isDefault ? "✓ Default" : "Default"}</button>
|
|
23
27
|
<button type="button" class="btn" data-ac-rm="${a.id}" data-name="${a.name}">Remove</button></div>
|
|
24
28
|
${a.signedIn && !a.usage?.expired ? "" : html`<div class="sk-a"><code>${a.signIn}</code></div>`}
|
|
25
29
|
</div>`;
|
|
26
30
|
|
|
27
|
-
|
|
28
|
-
|
|
31
|
+
// The login the tool uses on its own (~/.claude, ~/.codex): first in its section, Default unless an
|
|
32
|
+
// account below is.
|
|
33
|
+
const normalRow = (n: Normal) =>
|
|
34
|
+
html`<div class="sk ac-normal" data-q="account login normal default ${n.tool} ${(n.who ?? "").toLowerCase()}">
|
|
35
|
+
<div class="sk-h"><img class="ag-i" src="${AGENT_FAVICONS[n.tool] ?? ""}" alt="" width="28" height="28"><span class="sk-n"><span class="ac-nm">Your login <i>~/.${n.tool}</i></span>${whoLine(n)}${usageLine(n.usage, n.signedIn)}</span>
|
|
36
|
+
${n.signedIn && !n.usage?.expired ? "" : html`<button type="button" class="btn" data-ac-sign="" data-tool="${n.tool}">Sign in</button>`}
|
|
37
|
+
<button type="button" class="btn" data-ac-def="" data-tool="${n.tool}" aria-pressed="${String(n.isDefault)}"${n.isDefault ? " disabled" : ""} title="${n.isDefault ? "Runs use this login" : "Use this login for runs again"}">${n.isDefault ? "✓ Default" : "Default"}</button></div>
|
|
38
|
+
${n.signedIn && !n.usage?.expired ? "" : html`<div class="sk-a"><code>${n.signIn}</code></div>`}
|
|
39
|
+
</div>`;
|
|
40
|
+
|
|
41
|
+
export const accountRows = (d: { accounts: Row[]; normal?: Normal[]; windows: boolean }) =>
|
|
42
|
+
html`${["claude", "codex"].filter((t) => d.accounts.some((a) => a.tool === t) || (d.normal ?? []).some((n) => n.tool === t)).map((t) => html`<h3 class="sg">${TOOL[t]}</h3><div class="sgrp">${(d.normal ?? []).filter((n) => n.tool === t).map(normalRow)}${d.accounts.filter((a) => a.tool === t).map(row)}</div>`)}
|
|
29
43
|
<h3 class="sg">Add an account</h3><div class="sgrp"><div class="ac-add" data-q="add account sign in claude codex provider">
|
|
30
44
|
<div class="achips">${["claude", "codex"].map((t) => html`<button type="button" data-ac-new="${t}"${d.windows ? " disabled" : ""}><img src="${AGENT_FAVICONS[t]}" alt="" width="16" height="16">Add ${TOOL[t]} account</button>`)}</div></div></div>`;
|
|
31
45
|
|
|
@@ -51,7 +65,7 @@ export function wireAccounts(redraw: () => Promise<unknown>) {
|
|
|
51
65
|
const signIn = async (id: string, tool: string) => {
|
|
52
66
|
const dir = store.dir || store.S?.dir;
|
|
53
67
|
if (!dir) return toast("Open a project first, or run the line shown here in a terminal");
|
|
54
|
-
const j = await post("/shell", { dir, agent: tool, account: id });
|
|
68
|
+
const j = await post("/shell", { dir, agent: tool, account: id, login: true });
|
|
55
69
|
if (j.error || !j.key) return toast(j.error || "Could not open a terminal. Run the line shown here");
|
|
56
70
|
const opened = !dispatchEvent(new CustomEvent("kz-open-term", { cancelable: true, detail: { dir, ws: j.ws, key: j.key } }));
|
|
57
71
|
toast(opened ? "Sign in, then close the terminal" : "Terminal started. Open it from the side menu");
|
|
@@ -4,7 +4,7 @@ export type SettingsPage = { id: string; title: string; desc: string; ico: strin
|
|
|
4
4
|
export const SETTINGS_NAV: [string, SettingsPage[]][] = [
|
|
5
5
|
["AI Capabilities", [
|
|
6
6
|
{ id: "agents", title: "Agents", desc: "Manage AI agents, set a default, and customize commands.", ico: "ai" },
|
|
7
|
-
{ id: "accounts", title: "AI Provider Accounts", desc: "
|
|
7
|
+
{ id: "accounts", title: "AI Provider Accounts", desc: "Who is signed in to each AI tool kaizen runs. Add accounts only to switch between more than one.", ico: "link" },
|
|
8
8
|
{ id: "orchestration", title: "Orchestration", desc: "Split a run into workers, each in its own terminal. Off by default.", ico: "ai" },
|
|
9
9
|
{ id: "skills", title: "Skills", desc: "What your agents can do. Changes apply to new sessions.", ico: "note" },
|
|
10
10
|
{ id: "voice", title: "Voice", desc: "Speech-to-text dictation, run in the browser.", ico: "mic" },
|