agent-whisker 0.1.0 → 0.2.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/README.md +12 -3
- package/README.zh-CN.md +12 -3
- package/package.json +3 -2
- package/packages/antigravity-plugin/package.json +1 -1
- package/packages/antigravity-plugin/plugin.json +1 -1
- package/packages/claude-plugin/.claude-plugin/plugin.json +1 -1
- package/packages/claude-plugin/.codex-plugin/plugin.json +1 -1
- package/packages/claude-plugin/README.md +11 -1
- package/packages/claude-plugin/README.zh-CN.md +4 -1
- package/packages/claude-plugin/bin/taskstate +145 -4
- package/packages/claude-plugin/hooks/codex.json +8 -8
- package/packages/claude-plugin/package.json +1 -1
- package/packages/cli/README.md +76 -3
- package/packages/cli/README.zh-CN.md +76 -3
- package/packages/cli/package.json +1 -1
- package/packages/cli/src/command.js +20 -3
- package/packages/cli/src/commands/catalog.js +26 -7
- package/packages/cli/src/commands/doctor.js +31 -27
- package/packages/cli/src/commands/exclude.js +156 -0
- package/packages/cli/src/commands/extract.js +4 -2
- package/packages/cli/src/commands/index-command.js +1 -1
- package/packages/cli/src/commands/index.js +4 -0
- package/packages/cli/src/commands/install.js +12 -1
- package/packages/cli/src/commands/nudge.js +39 -37
- package/packages/cli/src/commands/read.js +2 -1
- package/packages/cli/src/commands/search.js +33 -3
- package/packages/cli/src/commands/sessions.js +20 -12
- package/packages/cli/src/commands/status.js +6 -3
- package/packages/cli/src/commands/tui.js +62 -0
- package/packages/cli/src/commands/version.js +4 -4
- package/packages/cli/src/exclusion.js +88 -0
- package/packages/cli/src/install/codex-plugin.js +6 -5
- package/packages/cli/src/install/external.js +48 -37
- package/packages/cli/src/install/handlers.js +4 -3
- package/packages/cli/src/install/mcp.js +3 -3
- package/packages/cli/src/install/steps.js +43 -15
- package/packages/cli/src/install/wrapper.js +28 -5
- package/packages/cli/src/main.js +9 -12
- package/packages/cli/src/node-version.js +25 -0
- package/packages/cli/src/run.js +25 -5
- package/packages/cli/src/tui/app.js +1430 -0
- package/packages/cli/src/tui/data/call.js +83 -0
- package/packages/cli/src/tui/data/poll.js +24 -0
- package/packages/cli/src/tui/glyphs.js +93 -0
- package/packages/cli/src/tui/i18n.js +342 -0
- package/packages/cli/src/tui/model.js +251 -0
- package/packages/cli/src/tui/pages/common.js +71 -0
- package/packages/cli/src/tui/pages/library.js +154 -0
- package/packages/cli/src/tui/pages/sessions.js +96 -0
- package/packages/cli/src/tui/pages/system.js +124 -0
- package/packages/cli/src/tui/pages/tasks.js +297 -0
- package/packages/cli/src/tui/run.js +216 -0
- package/packages/cli/src/tui/term/keys.js +152 -0
- package/packages/cli/src/tui/term/screen.js +88 -0
- package/packages/cli/src/tui/term/term.js +157 -0
- package/packages/cli/src/tui/term/width.js +290 -0
- package/packages/cli/src/tui/ui/widgets.js +247 -0
- package/packages/core/README.md +1 -1
- package/packages/core/README.zh-CN.md +2 -2
- package/packages/core/package.json +1 -1
- package/packages/core/src/catalog.js +13 -1
- package/packages/core/src/clairic.js +1 -1
- package/packages/core/src/convert.js +1 -1
- package/packages/core/src/db.js +6 -1
- package/packages/core/src/host.js +104 -0
- package/packages/core/src/index.js +2 -2
- package/packages/core/src/library-read.js +12 -8
- package/packages/core/src/nudge.js +34 -1
- package/packages/core/src/schema.js +17 -0
- package/packages/core/src/sessions-read.js +23 -11
- package/packages/dsh-plugin/package.json +1 -1
- package/packages/herdr-plugin/herdr-plugin.toml +1 -1
- package/packages/herdr-plugin/package.json +1 -1
- package/packages/mcp/README.md +5 -5
- package/packages/mcp/README.zh-CN.md +5 -5
- package/packages/mcp/package.json +1 -1
- package/packages/pi-extension/README.md +1 -1
- package/packages/pi-extension/README.zh-CN.md +1 -1
- package/packages/pi-extension/package.json +1 -1
- package/packages/pi-extension/src/extension.ts +3 -3
- package/packages/service/package.json +1 -1
- package/packages/service/src/index.js +1 -1
- package/packages/service/src/runtime.js +4 -0
|
@@ -0,0 +1,251 @@
|
|
|
1
|
+
// The interface's state, and the shapes of the --json answers it reads. Answers are checked field by field when they
|
|
2
|
+
// arrive (shape.ts); every string in them has had its control characters replaced (sanitizeDeep), so nothing drawn
|
|
3
|
+
// can be a terminal escape.
|
|
4
|
+
|
|
5
|
+
|
|
6
|
+
|
|
7
|
+
import { sanitize } from "./term/width.js";
|
|
8
|
+
|
|
9
|
+
|
|
10
|
+
export const PAGES = ["tasks", "library", "sessions", "agents", "doctor"] ;
|
|
11
|
+
|
|
12
|
+
|
|
13
|
+
/** A taskstate run as `show --json` gives it. */
|
|
14
|
+
|
|
15
|
+
|
|
16
|
+
|
|
17
|
+
|
|
18
|
+
|
|
19
|
+
|
|
20
|
+
|
|
21
|
+
|
|
22
|
+
|
|
23
|
+
|
|
24
|
+
|
|
25
|
+
|
|
26
|
+
|
|
27
|
+
|
|
28
|
+
|
|
29
|
+
|
|
30
|
+
|
|
31
|
+
|
|
32
|
+
|
|
33
|
+
|
|
34
|
+
|
|
35
|
+
|
|
36
|
+
|
|
37
|
+
|
|
38
|
+
|
|
39
|
+
|
|
40
|
+
|
|
41
|
+
|
|
42
|
+
|
|
43
|
+
|
|
44
|
+
|
|
45
|
+
|
|
46
|
+
|
|
47
|
+
|
|
48
|
+
|
|
49
|
+
|
|
50
|
+
|
|
51
|
+
|
|
52
|
+
|
|
53
|
+
|
|
54
|
+
|
|
55
|
+
|
|
56
|
+
|
|
57
|
+
|
|
58
|
+
|
|
59
|
+
|
|
60
|
+
|
|
61
|
+
|
|
62
|
+
|
|
63
|
+
|
|
64
|
+
|
|
65
|
+
|
|
66
|
+
|
|
67
|
+
|
|
68
|
+
|
|
69
|
+
|
|
70
|
+
|
|
71
|
+
|
|
72
|
+
|
|
73
|
+
|
|
74
|
+
|
|
75
|
+
|
|
76
|
+
|
|
77
|
+
|
|
78
|
+
|
|
79
|
+
|
|
80
|
+
|
|
81
|
+
|
|
82
|
+
|
|
83
|
+
|
|
84
|
+
|
|
85
|
+
|
|
86
|
+
|
|
87
|
+
|
|
88
|
+
|
|
89
|
+
|
|
90
|
+
|
|
91
|
+
|
|
92
|
+
|
|
93
|
+
|
|
94
|
+
|
|
95
|
+
|
|
96
|
+
|
|
97
|
+
|
|
98
|
+
|
|
99
|
+
|
|
100
|
+
|
|
101
|
+
|
|
102
|
+
|
|
103
|
+
|
|
104
|
+
|
|
105
|
+
|
|
106
|
+
|
|
107
|
+
|
|
108
|
+
|
|
109
|
+
|
|
110
|
+
|
|
111
|
+
|
|
112
|
+
|
|
113
|
+
|
|
114
|
+
|
|
115
|
+
|
|
116
|
+
|
|
117
|
+
|
|
118
|
+
|
|
119
|
+
/** A write the confirmation bar offers: what it says, the command, and how it may be confirmed. */
|
|
120
|
+
|
|
121
|
+
|
|
122
|
+
|
|
123
|
+
|
|
124
|
+
|
|
125
|
+
|
|
126
|
+
|
|
127
|
+
|
|
128
|
+
|
|
129
|
+
|
|
130
|
+
|
|
131
|
+
|
|
132
|
+
|
|
133
|
+
|
|
134
|
+
|
|
135
|
+
|
|
136
|
+
|
|
137
|
+
|
|
138
|
+
|
|
139
|
+
/** The argv a confirmation runs: its argv, the toggle's flag when on, the chosen tier. Shown and run from this one value. */
|
|
140
|
+
export function confirmArgv(confirm ) {
|
|
141
|
+
return [
|
|
142
|
+
...confirm.argv,
|
|
143
|
+
...(confirm.toggle?.on ? [confirm.toggle.flag] : []),
|
|
144
|
+
...(confirm.tier?.chosen ? ["--tier", confirm.tier.chosen] : []),
|
|
145
|
+
];
|
|
146
|
+
}
|
|
147
|
+
|
|
148
|
+
/** One write the interface ran, for the audit printed on exit. */
|
|
149
|
+
|
|
150
|
+
|
|
151
|
+
|
|
152
|
+
|
|
153
|
+
|
|
154
|
+
|
|
155
|
+
|
|
156
|
+
|
|
157
|
+
|
|
158
|
+
|
|
159
|
+
|
|
160
|
+
|
|
161
|
+
|
|
162
|
+
|
|
163
|
+
|
|
164
|
+
|
|
165
|
+
|
|
166
|
+
|
|
167
|
+
|
|
168
|
+
|
|
169
|
+
|
|
170
|
+
|
|
171
|
+
|
|
172
|
+
|
|
173
|
+
|
|
174
|
+
|
|
175
|
+
|
|
176
|
+
|
|
177
|
+
|
|
178
|
+
|
|
179
|
+
|
|
180
|
+
|
|
181
|
+
|
|
182
|
+
|
|
183
|
+
|
|
184
|
+
|
|
185
|
+
|
|
186
|
+
|
|
187
|
+
|
|
188
|
+
|
|
189
|
+
|
|
190
|
+
|
|
191
|
+
|
|
192
|
+
|
|
193
|
+
|
|
194
|
+
|
|
195
|
+
|
|
196
|
+
|
|
197
|
+
|
|
198
|
+
|
|
199
|
+
|
|
200
|
+
|
|
201
|
+
|
|
202
|
+
|
|
203
|
+
|
|
204
|
+
|
|
205
|
+
|
|
206
|
+
|
|
207
|
+
|
|
208
|
+
|
|
209
|
+
|
|
210
|
+
|
|
211
|
+
|
|
212
|
+
|
|
213
|
+
|
|
214
|
+
|
|
215
|
+
|
|
216
|
+
|
|
217
|
+
|
|
218
|
+
|
|
219
|
+
|
|
220
|
+
|
|
221
|
+
|
|
222
|
+
|
|
223
|
+
|
|
224
|
+
|
|
225
|
+
|
|
226
|
+
|
|
227
|
+
|
|
228
|
+
|
|
229
|
+
|
|
230
|
+
|
|
231
|
+
|
|
232
|
+
|
|
233
|
+
|
|
234
|
+
|
|
235
|
+
|
|
236
|
+
|
|
237
|
+
|
|
238
|
+
|
|
239
|
+
|
|
240
|
+
|
|
241
|
+
/** Every string in value with sanitize applied, at any depth: what each answer goes through before it is kept. */
|
|
242
|
+
export function sanitizeDeep (value ) {
|
|
243
|
+
if (typeof value === "string") return sanitize(value) ;
|
|
244
|
+
if (Array.isArray(value)) return value.map((item) => sanitizeDeep(item)) ;
|
|
245
|
+
if (value !== null && typeof value === "object") {
|
|
246
|
+
const out = {};
|
|
247
|
+
for (const [key, item] of Object.entries(value)) out[sanitize(key)] = sanitizeDeep(item);
|
|
248
|
+
return out ;
|
|
249
|
+
}
|
|
250
|
+
return value;
|
|
251
|
+
}
|
|
@@ -0,0 +1,71 @@
|
|
|
1
|
+
// What the pages share: how long ago a time was, a tier's glyph, the header of a pane.
|
|
2
|
+
import { posix, win32 } from "node:path";
|
|
3
|
+
|
|
4
|
+
|
|
5
|
+
|
|
6
|
+
/** How long before nowMs the time at was, in the interface's language: `3m`, `2h`, `5d` (`3分钟`, `2小时`, `5天`). */
|
|
7
|
+
export function ago(model , at , nowMs ) {
|
|
8
|
+
if (at === null) return "";
|
|
9
|
+
const ms = typeof at === "number" ? at : Date.parse(at);
|
|
10
|
+
if (!Number.isFinite(ms)) return "";
|
|
11
|
+
const s = Math.max(0, Math.round((nowMs - ms) / 1000));
|
|
12
|
+
const zh = model.lang === "zh-CN";
|
|
13
|
+
if (s < 60) return zh ? `${s}秒` : `${s}s`;
|
|
14
|
+
const m = Math.round(s / 60);
|
|
15
|
+
if (m < 60) return zh ? `${m}分钟` : `${m}m`;
|
|
16
|
+
const h = Math.round(m / 60);
|
|
17
|
+
if (h < 48) return zh ? `${h}小时` : `${h}h`;
|
|
18
|
+
const d = Math.round(h / 24);
|
|
19
|
+
return zh ? `${d}天` : `${d}d`;
|
|
20
|
+
}
|
|
21
|
+
|
|
22
|
+
/** A tier's glyph: ◯ open, ◎ personal (sensitive never reaches the interface: its ceiling is personal). */
|
|
23
|
+
export function tierGlyph(model , tier ) {
|
|
24
|
+
return tier === "open" ? model.glyphs.open : model.glyphs.personal;
|
|
25
|
+
}
|
|
26
|
+
|
|
27
|
+
/** A pane's title row: bold, inverse when the pane has the focus in the wide layout. */
|
|
28
|
+
export function titleRow(text , focused ) {
|
|
29
|
+
const style = focused ? { bold: true, inverse: true } : { bold: true };
|
|
30
|
+
return [{ text: ` ${text} `, style }];
|
|
31
|
+
}
|
|
32
|
+
|
|
33
|
+
/** An empty-state or error row, dim. */
|
|
34
|
+
export function noteRow(text ) {
|
|
35
|
+
return [{ text: ` ${text}`, style: { dim: true } }];
|
|
36
|
+
}
|
|
37
|
+
|
|
38
|
+
/** The user's home shown as `~`. */
|
|
39
|
+
export function tilde(model , path ) {
|
|
40
|
+
const home = model.homeDir;
|
|
41
|
+
if (path === home) return "~";
|
|
42
|
+
if (path.startsWith(`${home}/`) || path.startsWith(`${home}\\`)) {
|
|
43
|
+
return `~${path.slice(home.length).replaceAll("\\", "/")}`;
|
|
44
|
+
}
|
|
45
|
+
return path;
|
|
46
|
+
}
|
|
47
|
+
|
|
48
|
+
/**
|
|
49
|
+
* The parent directory of a document's file from its catalog label: under homeDir for user scope, under projectRoot
|
|
50
|
+
* for a project scope, or the label itself when absolute. Returns null when the root is unknown, at the filesystem
|
|
51
|
+
* root, or at homeDir itself (excluding homeDir would keep every later user ingest out).
|
|
52
|
+
*/
|
|
53
|
+
export function documentParentDir(
|
|
54
|
+
doc ,
|
|
55
|
+
homeDir ,
|
|
56
|
+
projectRoot ,
|
|
57
|
+
) {
|
|
58
|
+
const label = doc.source.startsWith("~/") || doc.source.startsWith("~\\") ? doc.source.slice(2) : doc.source;
|
|
59
|
+
const base = doc.scope === "user" ? homeDir : projectRoot;
|
|
60
|
+
const win =
|
|
61
|
+
/^[A-Za-z]:[\\/]/u.test(label) ||
|
|
62
|
+
label.includes("\\") ||
|
|
63
|
+
/^[A-Za-z]:[\\/]/u.test(base ?? homeDir) ||
|
|
64
|
+
(base ?? homeDir).includes("\\");
|
|
65
|
+
const p = win ? win32 : posix;
|
|
66
|
+
const full = p.isAbsolute(label) ? p.normalize(label) : base === null ? null : p.join(base, label);
|
|
67
|
+
if (full === null) return null;
|
|
68
|
+
const dir = p.dirname(full);
|
|
69
|
+
if (dir === full || dir === "." || p.parse(dir).root === dir || dir === p.normalize(homeDir)) return null;
|
|
70
|
+
return dir;
|
|
71
|
+
}
|
|
@@ -0,0 +1,154 @@
|
|
|
1
|
+
// The Library page, by boundary rather than by folder: on top, the flow from the documents to what an agent can see
|
|
2
|
+
// (the MCP gate: visible and hidden) and where it may be processed (the machine boundary: ◎ personal stays on this
|
|
3
|
+
// machine, ◯ open may reach a cloud model); below it, one flat list of documents for the facet chosen (all visible,
|
|
4
|
+
// personal, open, hidden and excluded). Counts come from `catalog --json` and `catalog --removed --json`.
|
|
5
|
+
|
|
6
|
+
|
|
7
|
+
import { displayWidth, fit } from "../term/width.js";
|
|
8
|
+
import { fitRow, line, listRows, wrapped } from "../ui/widgets.js";
|
|
9
|
+
import { noteRow, tierGlyph, titleRow } from "./common.js";
|
|
10
|
+
|
|
11
|
+
/** The documents of the current facet, in list order. */
|
|
12
|
+
export function facetDocs(model ) {
|
|
13
|
+
const page = model.library;
|
|
14
|
+
const docs = page.docs ?? [];
|
|
15
|
+
if (page.facet === 1) return docs.filter((doc) => doc.tier === "personal");
|
|
16
|
+
if (page.facet === 2) return docs.filter((doc) => doc.tier === "open");
|
|
17
|
+
if (page.facet === 3) return page.hidden ?? [];
|
|
18
|
+
return docs;
|
|
19
|
+
}
|
|
20
|
+
|
|
21
|
+
/** The flow diagram, on one line when it fits width, else on three. */
|
|
22
|
+
function flowRows(model , width ) {
|
|
23
|
+
const t = model.t;
|
|
24
|
+
const g = model.glyphs;
|
|
25
|
+
const docs = model.library.docs ?? [];
|
|
26
|
+
const hidden = model.library.hidden?.length ?? 0;
|
|
27
|
+
const local = docs.filter((doc) => doc.tier === "personal").length;
|
|
28
|
+
const cloud = docs.filter((doc) => doc.tier === "open").length;
|
|
29
|
+
const a = model.paint.ambiguous;
|
|
30
|
+
const source = [{ text: ` ${t("flowSources")} `, style: { bold: true } }];
|
|
31
|
+
const gate = [
|
|
32
|
+
{ text: `[${t("flowGate")}: ` },
|
|
33
|
+
{ text: t("flowVisible", docs.length) },
|
|
34
|
+
{ text: " | ", style: { dim: true } },
|
|
35
|
+
{ text: `${g.hidden}${g.void} ${t("flowHidden", hidden)}`, style: { dim: true } },
|
|
36
|
+
{ text: "]" },
|
|
37
|
+
];
|
|
38
|
+
const boundary = [
|
|
39
|
+
{ text: `[${t("flowBoundary")}: ` },
|
|
40
|
+
{ text: `${g.personal} ${t("flowLocal", local)}` },
|
|
41
|
+
{ text: " | ", style: { dim: true } },
|
|
42
|
+
{ text: `${g.open} ${t("flowCloud", cloud)}` },
|
|
43
|
+
{ text: "]" },
|
|
44
|
+
];
|
|
45
|
+
const arrow = { text: ` ${g.arrow} `, style: { dim: true } };
|
|
46
|
+
const one = [...source, arrow, ...gate, arrow, ...boundary];
|
|
47
|
+
const rows =
|
|
48
|
+
displayWidth(one.map((span) => span.text).join(""), a) <= width
|
|
49
|
+
? [one]
|
|
50
|
+
: [source, [{ text: " " }, arrow, ...gate], [{ text: " " }, arrow, ...boundary]];
|
|
51
|
+
rows.push(...wrapped(t("flowNote"), width, a, { dim: true }, 1).slice(0, 2));
|
|
52
|
+
return rows.map((row) => fitRow(row, width, a));
|
|
53
|
+
}
|
|
54
|
+
|
|
55
|
+
/** The facet tabs: the chosen one inverse. */
|
|
56
|
+
function facetRow(model , width ) {
|
|
57
|
+
const t = model.t;
|
|
58
|
+
const g = model.glyphs;
|
|
59
|
+
const docs = model.library.docs ?? [];
|
|
60
|
+
const counts = [
|
|
61
|
+
docs.length,
|
|
62
|
+
docs.filter((doc) => doc.tier === "personal").length,
|
|
63
|
+
docs.filter((doc) => doc.tier === "open").length,
|
|
64
|
+
model.library.hidden?.length ?? 0,
|
|
65
|
+
];
|
|
66
|
+
const long = [
|
|
67
|
+
t("facetAll"),
|
|
68
|
+
`${g.personal} ${t("facetPersonal")}`,
|
|
69
|
+
`${g.open} ${t("facetOpen")}`,
|
|
70
|
+
`${g.hidden}${g.void} ${t("facetHidden")}`,
|
|
71
|
+
];
|
|
72
|
+
const short = [t("facetAll").split(" ")[0] ?? "", g.personal, g.open, `${g.hidden}${g.void}`];
|
|
73
|
+
const label = (texts ) => texts.map((text, index) => `${text} ${counts[index]}`);
|
|
74
|
+
const room = (texts ) => texts.reduce((sum, text) => sum + displayWidth(text, model.paint.ambiguous) + 3, 1);
|
|
75
|
+
const labels = room(label(long)) <= width ? label(long) : label(short);
|
|
76
|
+
const spans = [{ text: " " }];
|
|
77
|
+
labels.forEach((label, index) => {
|
|
78
|
+
spans.push({
|
|
79
|
+
text: ` ${label} `,
|
|
80
|
+
style: index === model.library.facet ? { inverse: true, bold: true } : { dim: true },
|
|
81
|
+
});
|
|
82
|
+
spans.push({ text: " " });
|
|
83
|
+
});
|
|
84
|
+
return fitRow(spans, width, model.paint.ambiguous);
|
|
85
|
+
}
|
|
86
|
+
|
|
87
|
+
/** The documents of the facet as list items: glyph, title, and (when there is room) kind and source. */
|
|
88
|
+
function libraryItems(model , width ) {
|
|
89
|
+
const a = model.paint.ambiguous;
|
|
90
|
+
const g = model.glyphs;
|
|
91
|
+
return facetDocs(model).map((doc) => {
|
|
92
|
+
const hidden = model.library.facet === 3;
|
|
93
|
+
const glyph = hidden ? (doc.excluded ? g.void : g.hidden) : tierGlyph(model, doc.tier);
|
|
94
|
+
const tag = hidden ? (doc.excluded ? model.t("libExcludedTag") : model.t("libHiddenTag")) : doc.docKind;
|
|
95
|
+
const tagWidth = Math.min(18, displayWidth(tag, a) + 1);
|
|
96
|
+
const room = Math.max(6, width - 4 - tagWidth);
|
|
97
|
+
return {
|
|
98
|
+
key: `${doc.scope} ${doc.docId}`,
|
|
99
|
+
selectable: true,
|
|
100
|
+
rows: [
|
|
101
|
+
[
|
|
102
|
+
{ text: `${glyph} `, ...(hidden ? { style: { dim: true } } : {}) },
|
|
103
|
+
{ text: fit(doc.title || doc.source, room, a), ...(hidden ? { style: { dim: true } } : {}) },
|
|
104
|
+
{ text: fit(` ${tag}`, tagWidth, a), style: { dim: true } },
|
|
105
|
+
],
|
|
106
|
+
...(width >= 72 ? [[{ text: ` ${fit(doc.source, width - 4, a)}`, style: { dim: true } }] ] : []),
|
|
107
|
+
],
|
|
108
|
+
};
|
|
109
|
+
});
|
|
110
|
+
}
|
|
111
|
+
|
|
112
|
+
/** The list pane: flow, facets, documents. */
|
|
113
|
+
export function libraryListRows(model , width , height ) {
|
|
114
|
+
const page = model.library;
|
|
115
|
+
if (page.error !== null) return [noteRow(page.error)];
|
|
116
|
+
if (page.docs === null) return [noteRow(model.t("loading"))];
|
|
117
|
+
const head = [...flowRows(model, width), facetRow(model, width)];
|
|
118
|
+
const items = libraryItems(model, width);
|
|
119
|
+
if (items.length === 0) return [...head, noteRow(model.t("libNone"))];
|
|
120
|
+
return [
|
|
121
|
+
...head,
|
|
122
|
+
...listRows(items, page.sel, height - head.length, width, page.view, model.glyphs, model.paint, (k, n) =>
|
|
123
|
+
model.t(k, n),
|
|
124
|
+
),
|
|
125
|
+
];
|
|
126
|
+
}
|
|
127
|
+
|
|
128
|
+
/** The selected document's detail. */
|
|
129
|
+
export function libraryDetailRows(model , width , focused ) {
|
|
130
|
+
const doc = facetDocs(model)[model.library.sel];
|
|
131
|
+
if (doc === undefined) return [];
|
|
132
|
+
const a = model.paint.ambiguous;
|
|
133
|
+
const t = model.t;
|
|
134
|
+
const rows = [fitRow(titleRow(doc.title || doc.source, focused), width, a)];
|
|
135
|
+
rows.push(
|
|
136
|
+
...wrapped(
|
|
137
|
+
`${tierGlyph(model, doc.tier)} ${doc.tier === "open" ? t("tierOpen") : t("tierPersonal")}`,
|
|
138
|
+
width,
|
|
139
|
+
a,
|
|
140
|
+
undefined,
|
|
141
|
+
1,
|
|
142
|
+
),
|
|
143
|
+
);
|
|
144
|
+
rows.push(...wrapped(t("docDetail", doc.docKind, doc.bytes, doc.source), width, a, { dim: true }, 1));
|
|
145
|
+
rows.push(line(` ${doc.docId} · ${doc.scope}`, { dim: true }));
|
|
146
|
+
if (model.library.facet === 3)
|
|
147
|
+
rows.push(
|
|
148
|
+
line(
|
|
149
|
+
` ${doc.excluded ? `${model.glyphs.void} ${t("libExcludedTag")}` : `${model.glyphs.hidden} ${t("libHiddenTag")}`}`,
|
|
150
|
+
{ fg: "yellow" },
|
|
151
|
+
),
|
|
152
|
+
);
|
|
153
|
+
return rows;
|
|
154
|
+
}
|
|
@@ -0,0 +1,96 @@
|
|
|
1
|
+
// The Sessions page: the five programs' sessions agent-whisker keeps, filtered by program, time range and a search,
|
|
2
|
+
// each marked when its file is gone and only the kept copy remains, and linked both ways with the task whose
|
|
3
|
+
// sessions name it (↔T#). The reader shows a session's entries wrapped to the width, never cutting a character.
|
|
4
|
+
|
|
5
|
+
|
|
6
|
+
import { displayWidth, fit } from "../term/width.js";
|
|
7
|
+
import { fitRow, line, listRows, wrapped } from "../ui/widgets.js";
|
|
8
|
+
import { ago, noteRow, tilde, titleRow } from "./common.js";
|
|
9
|
+
|
|
10
|
+
/** The time ranges ←/→ step through, in days; 0 means any time. */
|
|
11
|
+
export const RANGES = [7, 30, 90, 0, 1] ;
|
|
12
|
+
/** The programs h steps through; null means all. */
|
|
13
|
+
export const HARNESS_FILTERS = [null, "claude", "codex", "pi", "antigravity", "dsh"] ;
|
|
14
|
+
|
|
15
|
+
export function sessionItems(model , width , nowMs ) {
|
|
16
|
+
const a = model.paint.ambiguous;
|
|
17
|
+
return (model.sessions.list ?? []).map((session ) => {
|
|
18
|
+
const link = model.sessions.links[session.session];
|
|
19
|
+
const tag = session.sourceGone ? model.t("sessGone") : link ? `${model.glyphs.link}${link}` : "";
|
|
20
|
+
const age = fit(ago(model, session.lastMs, nowMs), 6, a);
|
|
21
|
+
const harness = fit(session.harness, 8, a);
|
|
22
|
+
const tagWidth = tag === "" ? 0 : displayWidth(tag, a) + 1;
|
|
23
|
+
const room = Math.max(4, width - 1 - 6 - 8 - tagWidth - 1);
|
|
24
|
+
const second = `${tilde(model, session.cwd)} · ${model.t("sessEntries", session.entries)}`;
|
|
25
|
+
return {
|
|
26
|
+
key: session.session,
|
|
27
|
+
selectable: true,
|
|
28
|
+
rows: [
|
|
29
|
+
[
|
|
30
|
+
{ text: age, style: { dim: true } },
|
|
31
|
+
{ text: harness },
|
|
32
|
+
{ text: fit(session.title, room, a) },
|
|
33
|
+
...(tag === ""
|
|
34
|
+
? []
|
|
35
|
+
: [{ text: ` ${tag}`, style: session.sourceGone ? { fg: "yellow" } : { dim: true } }]),
|
|
36
|
+
],
|
|
37
|
+
[
|
|
38
|
+
{
|
|
39
|
+
text: `${" ".repeat(14)}${fit(session.excerpt ?? second, Math.max(1, width - 15), a)}`,
|
|
40
|
+
style: { dim: true },
|
|
41
|
+
},
|
|
42
|
+
],
|
|
43
|
+
],
|
|
44
|
+
};
|
|
45
|
+
});
|
|
46
|
+
}
|
|
47
|
+
|
|
48
|
+
function sessionHeader(model , width ) {
|
|
49
|
+
const page = model.sessions;
|
|
50
|
+
const range = RANGES[page.range] ?? 7;
|
|
51
|
+
const parts = [page.harness ?? model.t("sessAll"), range === 0 ? model.t("sessAny") : model.t("sessDays", range)];
|
|
52
|
+
return fitRow(
|
|
53
|
+
[
|
|
54
|
+
{ text: ` ${parts.join(" · ")}`, style: { dim: true } },
|
|
55
|
+
...(page.query ? [{ text: ` ${model.glyphs.prompt} ${page.query}` }] : []),
|
|
56
|
+
],
|
|
57
|
+
width,
|
|
58
|
+
model.paint.ambiguous,
|
|
59
|
+
);
|
|
60
|
+
}
|
|
61
|
+
|
|
62
|
+
export function sessionListRows(model , width , height , nowMs ) {
|
|
63
|
+
const page = model.sessions;
|
|
64
|
+
const head = [sessionHeader(model, width)];
|
|
65
|
+
if (page.error !== null) return [...head, noteRow(page.error)];
|
|
66
|
+
if (page.list === null) return [...head, noteRow(model.t("loading"))];
|
|
67
|
+
if (page.list.length === 0) return [...head, noteRow(model.t("sessNone"))];
|
|
68
|
+
const items = sessionItems(model, width, nowMs);
|
|
69
|
+
return [
|
|
70
|
+
...head,
|
|
71
|
+
...listRows(items, page.sel, height - 1, width, page.view, model.glyphs, model.paint, (k, n) => model.t(k, n)),
|
|
72
|
+
];
|
|
73
|
+
}
|
|
74
|
+
|
|
75
|
+
/** The reader: a head line and every entry, its own head then its text wrapped. All rows; the caller scrolls. */
|
|
76
|
+
export function readerRows(model , width , focused ) {
|
|
77
|
+
const reader = model.sessions.reader;
|
|
78
|
+
if (reader === null) return [];
|
|
79
|
+
const a = model.paint.ambiguous;
|
|
80
|
+
const s = reader.session;
|
|
81
|
+
const rows = [
|
|
82
|
+
fitRow(titleRow(s.title || s.session, focused), width, a),
|
|
83
|
+
line(
|
|
84
|
+
` ${s.harness} · ${tilde(model, s.cwd)} · ${model.t("sessReader", s.session, s.entries)}${model.sessions.links[s.session] ? ` · ${model.glyphs.link} ${model.sessions.links[s.session]}` : ""}`,
|
|
85
|
+
{ dim: true },
|
|
86
|
+
),
|
|
87
|
+
];
|
|
88
|
+
for (const item of reader.items) {
|
|
89
|
+
const time = item.timeMs === null ? "" : new Date(item.timeMs).toISOString().slice(11, 16);
|
|
90
|
+
rows.push(line(` [${item.at}] ${item.role} ${time}${item.cut ? " …" : ""}`, { bold: true }));
|
|
91
|
+
rows.push(
|
|
92
|
+
...wrapped(item.text, width, a, item.role === "tool" || item.role === "result" ? { dim: true } : undefined, 3),
|
|
93
|
+
);
|
|
94
|
+
}
|
|
95
|
+
return rows;
|
|
96
|
+
}
|
|
@@ -0,0 +1,124 @@
|
|
|
1
|
+
// The Agents page (what `install --dry-run` would do for each agent program, previewed only) and the Models & doctor
|
|
2
|
+
// page (the two read-time model paths, Decide and Extract, as the environment configures them, the format tools, and
|
|
3
|
+
// doctor's checks once D runs it). On first use both start with a checklist derived from the real state.
|
|
4
|
+
|
|
5
|
+
|
|
6
|
+
import { fitRow, line, listRows, wrapped } from "../ui/widgets.js";
|
|
7
|
+
import { noteRow, titleRow } from "./common.js";
|
|
8
|
+
|
|
9
|
+
function statusMark(model , status ) {
|
|
10
|
+
const g = model.glyphs;
|
|
11
|
+
if (status === "ok") return { text: g.met, style: { fg: "green" } };
|
|
12
|
+
if (status === "fail") return { text: g.notMet, style: { fg: "red" } };
|
|
13
|
+
return { text: g.review, style: { fg: "yellow" } };
|
|
14
|
+
}
|
|
15
|
+
|
|
16
|
+
/** The get-started checklist: data directory, documents, agent programs; [] once all three are done. */
|
|
17
|
+
function startRows(model , width ) {
|
|
18
|
+
const store = model.store;
|
|
19
|
+
if (store === null) return [];
|
|
20
|
+
const installed =
|
|
21
|
+
model.agents.steps?.filter((step) => step.id.startsWith("mcp-")).some((step) => step.status === "ok") ?? null;
|
|
22
|
+
const items = [
|
|
23
|
+
[store.initialised, model.t("startInit")],
|
|
24
|
+
[store.documents > 0, model.t("startLibrary")],
|
|
25
|
+
[installed === true, model.t("startInstall")],
|
|
26
|
+
];
|
|
27
|
+
if (items.every(([done]) => done)) return [];
|
|
28
|
+
const g = model.glyphs;
|
|
29
|
+
const rows = [line(` ${model.t("startTitle")}`, { bold: true })];
|
|
30
|
+
for (const [done, text] of items)
|
|
31
|
+
rows.push(
|
|
32
|
+
fitRow(
|
|
33
|
+
[
|
|
34
|
+
{ text: ` ${done ? g.ok : g.none} `, style: done ? { fg: "green" } : { dim: true } },
|
|
35
|
+
{ text, ...(done ? { style: { dim: true } } : {}) },
|
|
36
|
+
],
|
|
37
|
+
width,
|
|
38
|
+
model.paint.ambiguous,
|
|
39
|
+
),
|
|
40
|
+
);
|
|
41
|
+
rows.push([]);
|
|
42
|
+
return rows;
|
|
43
|
+
}
|
|
44
|
+
|
|
45
|
+
function checkItems(model , checks , width ) {
|
|
46
|
+
const a = model.paint.ambiguous;
|
|
47
|
+
return checks.map((check) => {
|
|
48
|
+
const mark = statusMark(model, check.status);
|
|
49
|
+
const detail = wrapped(check.detail, width - 1, a, { dim: true }, 4).slice(0, 3);
|
|
50
|
+
return {
|
|
51
|
+
key: check.id,
|
|
52
|
+
selectable: true,
|
|
53
|
+
rows: [
|
|
54
|
+
[
|
|
55
|
+
{ text: `${mark.text} `, style: mark.style },
|
|
56
|
+
{ text: check.id, style: { bold: true } },
|
|
57
|
+
{ text: ` ${check.status}`, style: { dim: true } },
|
|
58
|
+
],
|
|
59
|
+
...detail,
|
|
60
|
+
],
|
|
61
|
+
};
|
|
62
|
+
});
|
|
63
|
+
}
|
|
64
|
+
|
|
65
|
+
export function agentsRows(model , width , height ) {
|
|
66
|
+
const page = model.agents;
|
|
67
|
+
const head = [
|
|
68
|
+
...startRows(model, width),
|
|
69
|
+
fitRow(titleRow(model.t("agentsTitle"), false), width, model.paint.ambiguous),
|
|
70
|
+
];
|
|
71
|
+
if (page.error !== null)
|
|
72
|
+
return [...head, ...wrapped(model.t("agentsNone", page.error), width, model.paint.ambiguous, { dim: true }, 1)];
|
|
73
|
+
if (page.steps === null) return [...head, noteRow(model.t("loading"))];
|
|
74
|
+
const items = checkItems(model, page.steps, width);
|
|
75
|
+
return [
|
|
76
|
+
...head,
|
|
77
|
+
...listRows(items, page.sel, height - head.length, width, page.view, model.glyphs, model.paint, (k, n) =>
|
|
78
|
+
model.t(k, n),
|
|
79
|
+
),
|
|
80
|
+
];
|
|
81
|
+
}
|
|
82
|
+
|
|
83
|
+
export function doctorRows(model , width , height ) {
|
|
84
|
+
const page = model.doctor;
|
|
85
|
+
const a = model.paint.ambiguous;
|
|
86
|
+
const t = model.t;
|
|
87
|
+
const head = [...startRows(model, width), fitRow(titleRow(t("doctorTitle"), false), width, a)];
|
|
88
|
+
const path = (name , value ) =>
|
|
89
|
+
fitRow(
|
|
90
|
+
[
|
|
91
|
+
{
|
|
92
|
+
text: ` ${value === null ? model.glyphs.none : model.glyphs.met} `,
|
|
93
|
+
style: value === null ? { dim: true } : { fg: "green" },
|
|
94
|
+
},
|
|
95
|
+
{ text: `${name}: ` },
|
|
96
|
+
{ text: value === null ? t("notConfigured") : t("configured", value), style: { dim: true } },
|
|
97
|
+
],
|
|
98
|
+
width,
|
|
99
|
+
a,
|
|
100
|
+
);
|
|
101
|
+
head.push(path(t("decide"), model.models.decide), path(t("extract"), model.models.extract));
|
|
102
|
+
const convert = page.checks?.find((check) => check.id === "convert");
|
|
103
|
+
head.push(
|
|
104
|
+
fitRow(
|
|
105
|
+
[
|
|
106
|
+
{ text: ` ${t("tools")}: ` },
|
|
107
|
+
{ text: convert ? convert.detail : "pdftotext · qpdf · pandoc", style: { dim: true } },
|
|
108
|
+
],
|
|
109
|
+
width,
|
|
110
|
+
a,
|
|
111
|
+
),
|
|
112
|
+
);
|
|
113
|
+
if (page.error !== null) head.push(noteRow(t("failed", page.error)));
|
|
114
|
+
if (page.checks === null) return [...head, [], noteRow(page.running ? t("running", "doctor") : t("doctorHint"))];
|
|
115
|
+
const count = (status ) => page.checks?.filter((check) => check.status === status).length ?? 0;
|
|
116
|
+
head.push(line(` ${t("doctorChecks", count("ok"), count("warn"), count("fail"))}`, { bold: true }));
|
|
117
|
+
const items = checkItems(model, page.checks, width);
|
|
118
|
+
return [
|
|
119
|
+
...head,
|
|
120
|
+
...listRows(items, page.sel, height - head.length, width, page.view, model.glyphs, model.paint, (k, n) =>
|
|
121
|
+
model.t(k, n),
|
|
122
|
+
),
|
|
123
|
+
];
|
|
124
|
+
}
|