archymedes-cli 2.3.0 → 2.5.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.
Files changed (25) hide show
  1. package/dist/{archymedes-aj30app4.mjs → archymedes-06fh0z84.mjs} +370 -159
  2. package/dist/{archymedes-d5wqcmdr.mjs → archymedes-0jxzsh4z.mjs} +97 -97
  3. package/dist/archymedes-130jt0wr.mjs +1231 -0
  4. package/dist/{archymedes-twbks7g3.mjs → archymedes-138genyy.mjs} +214 -5
  5. package/dist/{archymedes-h13ap0za.mjs → archymedes-1g1y6q74.mjs} +1 -1
  6. package/dist/{archymedes-dz59nvw7.mjs → archymedes-2kvjaajw.mjs} +21 -11
  7. package/dist/{archymedes-g8y3rt6t.mjs → archymedes-5vhvv8kr.mjs} +332 -9
  8. package/dist/{archymedes-4kx65anz.mjs → archymedes-a3ms7jvr.mjs} +43 -12
  9. package/dist/{archymedes-tsne2m7p.mjs → archymedes-bmtdqqwt.mjs} +2 -2
  10. package/dist/{archymedes-sf9t1hz9.mjs → archymedes-d3azqkay.mjs} +176 -77
  11. package/dist/archymedes-main.mjs +31312 -28352
  12. package/dist/archymedes-w4bjfye7.mjs +280 -0
  13. package/dist/{editor-screen-g08zzt70.mjs → editor-screen-e01mn7dd.mjs} +49 -14
  14. package/dist/{factory-7vtm2fed.mjs → factory-hyv8agr0.mjs} +326 -326
  15. package/dist/{file-screen-ma9yxq2b.mjs → file-screen-stcxznwy.mjs} +11 -9
  16. package/dist/{guide-screen-gd129txd.mjs → guide-screen-w5nb9sry.mjs} +10 -8
  17. package/dist/{index-qvgcwsvm.mjs → index-teq1cta4.mjs} +1 -1
  18. package/dist/{node-mdgzx68h.mjs → node-0fh63p8z.mjs} +7 -7
  19. package/dist/pager-screen-aamt6xv0.mjs +155 -0
  20. package/dist/projection-x6x6hm9t.mjs +248 -0
  21. package/dist/{sandbox-templates-9jcjws23.mjs → sandbox-templates-8sd1psez.mjs} +2 -2
  22. package/dist/workspace-screen-62k6hnq7.mjs +70 -0
  23. package/package.json +2 -2
  24. package/dist/archymedes-a10k8yrk.mjs +0 -464
  25. package/dist/workspace-screen-8cwk6jz9.mjs +0 -241
@@ -1,241 +0,0 @@
1
- import {
2
- StreamSeries,
3
- waveLine
4
- } from "./archymedes-twbks7g3.mjs";
5
- import {
6
- scrollIndicator,
7
- scrollPercent
8
- } from "./archymedes-g8y3rt6t.mjs";
9
- import {
10
- clip
11
- } from "./archymedes-tsne2m7p.mjs";
12
- import {
13
- visibleWidth
14
- } from "./archymedes-a10k8yrk.mjs";
15
- import {
16
- __require
17
- } from "./archymedes-x67v3n58.mjs";
18
-
19
- // src/ui/workspace-screen.tsx
20
- import { useInput, useInterval, useState } from "@termuijs/jsx";
21
- import { Box, Text } from "@termuijs/widgets";
22
-
23
- // src/ui/workspace-model.ts
24
- function paneHeight(rows) {
25
- return Math.max(1, rows - 4);
26
- }
27
- function selectedPane(snapshot) {
28
- if (snapshot.panes.length === 0)
29
- return;
30
- const index = Math.max(0, Math.min(snapshot.selected, snapshot.panes.length - 1));
31
- return snapshot.panes[index];
32
- }
33
- function visibleLines(pane, height, scroll) {
34
- const clamped = Math.max(0, Math.min(scroll, Math.max(0, pane.lines.length - height)));
35
- const end = pane.lines.length - clamped;
36
- return pane.lines.slice(Math.max(0, end - height), end);
37
- }
38
- function atLiveEdge(pane, height, scroll) {
39
- return Math.min(scroll, Math.max(0, pane.lines.length - height)) === 0;
40
- }
41
- function keyToAction(key, character) {
42
- const name = key.name ?? "";
43
- const isEscape = name === "escape" || name === "\x1B";
44
- const isEnter = name === "return" || name === "enter" || name === "\r" || name === `
45
- `;
46
- if (isEscape || name === "q" && !key.ctrl || key.ctrl && name === "c")
47
- return { kind: "exit" };
48
- if (isEnter)
49
- return { kind: "focus" };
50
- if (name === "tab")
51
- return { kind: "cycle", step: key.shift ? -1 : 1 };
52
- if (name === "left")
53
- return { kind: "cycle", step: -1 };
54
- if (name === "right")
55
- return { kind: "cycle", step: 1 };
56
- if (name === "up" || name === "k")
57
- return { kind: "scroll", lines: 1 };
58
- if (name === "down" || name === "j")
59
- return { kind: "scroll", lines: -1 };
60
- if (name === "pageup")
61
- return { kind: "scroll", lines: 10 };
62
- if (name === "pagedown")
63
- return { kind: "scroll", lines: -10 };
64
- if (name === "home" || character === "g")
65
- return { kind: "top" };
66
- if (name === "end" || character === "G")
67
- return { kind: "bottom" };
68
- const digit = character && /^[1-9]$/.test(character) ? Number(character) : undefined;
69
- if (digit !== undefined)
70
- return { kind: "select", index: digit - 1 };
71
- return { kind: "none" };
72
- }
73
- function applyAction(snapshot, action) {
74
- const count = snapshot.panes.length;
75
- if (count === 0 || action.kind === "none" || action.kind === "exit" || action.kind === "focus")
76
- return snapshot;
77
- if (action.kind === "select") {
78
- if (action.index < 0 || action.index >= count)
79
- return snapshot;
80
- return { ...snapshot, selected: action.index, scroll: 0 };
81
- }
82
- if (action.kind === "cycle") {
83
- const next = ((snapshot.selected + action.step) % count + count) % count;
84
- return { ...snapshot, selected: next, scroll: 0 };
85
- }
86
- const pane = selectedPane(snapshot);
87
- const height = paneHeight(snapshot.rows);
88
- const furthest = Math.max(0, (pane?.lines.length ?? 0) - height);
89
- if (action.kind === "bottom")
90
- return { ...snapshot, scroll: 0 };
91
- if (action.kind === "top")
92
- return { ...snapshot, scroll: furthest };
93
- return { ...snapshot, scroll: Math.max(0, Math.min(snapshot.scroll + action.lines, furthest)) };
94
- }
95
- function paneTabs(snapshot) {
96
- const selected = Math.max(0, Math.min(snapshot.selected, snapshot.panes.length - 1));
97
- return snapshot.panes.map((pane, index) => ({
98
- label: `${index + 1} ${pane.title}`,
99
- active: index === selected,
100
- status: pane.status
101
- }));
102
- }
103
-
104
- class PaneActivity {
105
- capacity;
106
- series = new Map;
107
- seen = new Map;
108
- constructor(capacity = 48) {
109
- this.capacity = capacity;
110
- }
111
- sample(panes) {
112
- const live = new Set(panes.map((pane) => pane.key));
113
- for (const key of [...this.series.keys()]) {
114
- if (!live.has(key)) {
115
- this.series.delete(key);
116
- this.seen.delete(key);
117
- }
118
- }
119
- const result = new Map;
120
- for (const pane of panes) {
121
- const produced = pane.lines.length + pane.dropped;
122
- const previous = this.seen.get(pane.key);
123
- this.seen.set(pane.key, produced);
124
- const stream = this.series.get(pane.key) ?? new StreamSeries(this.capacity);
125
- this.series.set(pane.key, stream);
126
- if (previous !== undefined)
127
- stream.push(Math.max(0, produced - previous));
128
- result.set(pane.key, stream.values());
129
- }
130
- return result;
131
- }
132
- }
133
- var STATUS_MARK = {
134
- running: "●",
135
- failed: "✕",
136
- done: "✓",
137
- idle: " "
138
- };
139
- var WORKSPACE_LEGEND = "1-9 pane · ←→ move · ↑↓ scroll · g/G ends · q leave";
140
- function paneBar(snapshot, columns) {
141
- const tabs = paneTabs(snapshot);
142
- const cells = tabs.map((tab) => ` ${STATUS_MARK[tab.status] ?? " "}${tab.label} `);
143
- const full = cells.join("");
144
- if (full.length <= columns)
145
- return full || " no panes ";
146
- const selected = Math.max(0, Math.min(snapshot.selected, tabs.length - 1));
147
- return `${selected > 0 ? "‹ " : ""}${cells[selected] ?? " no panes "}${selected < tabs.length - 1 ? " ›" : ""}`;
148
- }
149
- function composeFrame(snapshot) {
150
- const rows = [];
151
- const columns = Math.max(1, Math.floor(snapshot.columns));
152
- const rowCount = Math.max(1, Math.floor(snapshot.rows));
153
- const pane = selectedPane(snapshot);
154
- const height = paneHeight(rowCount);
155
- const theme = snapshot.palette.tokens;
156
- const bar = paneBar(snapshot, columns);
157
- rows.push({ text: bar || " no panes ", bold: true, color: theme.primary });
158
- const scrolled = pane && !atLiveEdge(pane, height, snapshot.scroll);
159
- const position = (() => {
160
- if (!pane || !scrolled)
161
- return "";
162
- const maxOffset = Math.max(0, pane.lines.length - height);
163
- const offsetFromTop = maxOffset - Math.min(snapshot.scroll, maxOffset);
164
- return scrollIndicator(scrollPercent(offsetFromTop, pane.lines.length, height));
165
- })();
166
- const dropped = pane && pane.dropped > 0 ? ` (${pane.dropped} earlier lines dropped)` : "";
167
- const header = pane ? `${pane.title} ${pane.subtitle}${dropped}` : "nothing open";
168
- const activityWidth = Math.min(24, Math.max(0, columns - visibleWidth(header) - 3));
169
- const activity = pane?.activity && pane.activity.length > 1 && activityWidth >= 8 ? ` ${waveLine(pane.activity, { width: activityWidth })}` : "";
170
- rows.push({
171
- text: pane ? `${header}${activity}` : header,
172
- bold: true,
173
- color: pane?.status === "failed" ? theme.error : pane?.status === "running" ? theme.success : theme.accent
174
- });
175
- const body = pane ? visibleLines(pane, height, snapshot.scroll) : [];
176
- for (let index = 0;index < height; index += 1)
177
- rows.push({ text: body[index] ?? "" });
178
- while (rows.length < rowCount - 1)
179
- rows.push({ text: "" });
180
- rows.length = Math.max(0, rowCount - 1);
181
- rows.push({
182
- text: `${WORKSPACE_LEGEND}${scrolled ? ` ▲ scrolled back ${position}` : ""}`,
183
- dim: true,
184
- color: theme.textMuted
185
- });
186
- return rows.map((row) => ({ ...row, text: clip(row.text, columns) }));
187
- }
188
-
189
- // src/ui/workspace-screen.tsx
190
- import { jsxDEV } from "@termuijs/jsx/jsx-dev-runtime";
191
- var Panel = Box;
192
- var Line = Text;
193
- function Workspace({ read, onExit, refreshMs = 200 }) {
194
- const [snapshot, setSnapshot] = useState(() => read());
195
- useInterval(() => {
196
- setSnapshot((current) => ({ ...read(), selected: current.selected, scroll: current.scroll }));
197
- }, refreshMs);
198
- useInput((input, key) => {
199
- const action = keyToAction({ name: key?.key, ctrl: key?.ctrl, shift: key?.shift }, input);
200
- if (action.kind === "exit") {
201
- onExit();
202
- return;
203
- }
204
- setSnapshot((current) => applyAction(current, action));
205
- });
206
- const rows = composeFrame(snapshot);
207
- return /* @__PURE__ */ jsxDEV(Panel, {
208
- flexDirection: "column",
209
- width: snapshot.columns,
210
- height: snapshot.rows,
211
- children: rows.map((row, index) => /* @__PURE__ */ jsxDEV(Line, {
212
- bold: row.bold,
213
- dimColor: row.dim,
214
- inverse: row.inverse,
215
- color: row.color,
216
- children: row.text
217
- }, `row-${index}`, false, undefined, this))
218
- }, undefined, false, undefined, this);
219
- }
220
- async function runWorkspace(host) {
221
- const { renderApp } = await import("@termuijs/jsx");
222
- await new Promise((resolve) => {
223
- let settled = false;
224
- const finish = () => {
225
- if (settled)
226
- return;
227
- settled = true;
228
- host.onExit?.();
229
- resolve();
230
- };
231
- renderApp(Workspace, {
232
- read: host.read,
233
- onExit: finish,
234
- fullscreen: true
235
- }).catch(finish);
236
- });
237
- }
238
- export {
239
- runWorkspace,
240
- Workspace
241
- };