topside-arch 0.0.0-stage → 0.1.2

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 (95) hide show
  1. package/LICENSE +21 -0
  2. package/README.md +217 -2
  3. package/contrib/aur/.SRCINFO +20 -0
  4. package/contrib/aur/PKGBUILD +35 -0
  5. package/contrib/aur/topside-arch.install +28 -0
  6. package/contrib/icons/hicolor/scalable/apps/topside.svg +28 -0
  7. package/contrib/systemd/topside.service +10 -0
  8. package/contrib/themes/sakura.json +31 -0
  9. package/dist/adapters/claude/attach.js +92 -0
  10. package/dist/adapters/claude/hook-event.js +173 -0
  11. package/dist/adapters/claude/one-shot.js +30 -0
  12. package/dist/adapters/claude/settings.js +78 -0
  13. package/dist/adapters/claude/usage.js +76 -0
  14. package/dist/adapters/codex/codex.js +73 -0
  15. package/dist/adapters/codex/patch.js +39 -0
  16. package/dist/adapters/codex/usage.js +77 -0
  17. package/dist/adapters/pi/extension.js +271 -0
  18. package/dist/adapters/pi/risk-gate.js +256 -0
  19. package/dist/cli/commands.js +615 -0
  20. package/dist/cli/hook-log.js +32 -0
  21. package/dist/cli/main.js +100 -0
  22. package/dist/daemon/preview.js +70 -0
  23. package/dist/daemon/processes.js +105 -0
  24. package/dist/daemon/server.js +437 -0
  25. package/dist/daemon/session-state.js +179 -0
  26. package/dist/daemon/store.js +176 -0
  27. package/dist/dms/setup.js +137 -0
  28. package/dist/hosts/hosts.js +39 -0
  29. package/dist/jump/jump.js +199 -0
  30. package/dist/pill/config.js +92 -0
  31. package/dist/pill/launch.js +38 -0
  32. package/dist/sekaipop/setup.js +267 -0
  33. package/dist/service/unit.js +77 -0
  34. package/dist/shared/ancestry.js +27 -0
  35. package/dist/shared/client.js +29 -0
  36. package/dist/shared/package.js +25 -0
  37. package/dist/shared/paths.js +69 -0
  38. package/dist/shared/protocol.js +35 -0
  39. package/dist/shared/qml-lib.js +33 -0
  40. package/dist/shared/result.js +6 -0
  41. package/dist/shared/terminal.js +42 -0
  42. package/dist/themes/themes.js +84 -0
  43. package/package.json +49 -4
  44. package/shell/core/AgentIcon.qml +24 -0
  45. package/shell/core/AppLogo.qml +48 -0
  46. package/shell/core/ApprovalRow.qml +197 -0
  47. package/shell/core/BoardDetail.qml +336 -0
  48. package/shell/core/BoardList.qml +419 -0
  49. package/shell/core/BoardNotice.qml +189 -0
  50. package/shell/core/CardButton.qml +55 -0
  51. package/shell/core/CardHeader.qml +46 -0
  52. package/shell/core/ChalkBoard.qml +99 -0
  53. package/shell/core/CompletionCard.qml +106 -0
  54. package/shell/core/FlapText.qml +110 -0
  55. package/shell/core/KeyCap.qml +72 -0
  56. package/shell/core/Mascot.qml +13 -0
  57. package/shell/core/MascotBadge.qml +40 -0
  58. package/shell/core/MascotEffect.qml +40 -0
  59. package/shell/core/Paper.qml +54 -0
  60. package/shell/core/PixelGrid.qml +40 -0
  61. package/shell/core/QuestionRow.qml +161 -0
  62. package/shell/core/SessionRow.qml +257 -0
  63. package/shell/core/Stamp.qml +62 -0
  64. package/shell/core/StatusDots.qml +33 -0
  65. package/shell/core/Surface.qml +32 -0
  66. package/shell/core/Tag.qml +22 -0
  67. package/shell/core/TerminalIcon.qml +34 -0
  68. package/shell/core/Theme.qml +100 -0
  69. package/shell/core/TicketDetail.qml +657 -0
  70. package/shell/core/TicketList.qml +717 -0
  71. package/shell/core/TicketNotice.qml +198 -0
  72. package/shell/core/TopsideClient.qml +201 -0
  73. package/shell/core/UsageLine.qml +106 -0
  74. package/shell/core/agents.js +79 -0
  75. package/shell/core/board.js +132 -0
  76. package/shell/core/hiding.js +68 -0
  77. package/shell/core/pixels.js +542 -0
  78. package/shell/core/qmldir +30 -0
  79. package/shell/core/sounds.js +31 -0
  80. package/shell/core/themes.js +195 -0
  81. package/shell/core/ticket.js +170 -0
  82. package/shell/dms-plugin/TopsideSettings.qml +696 -0
  83. package/shell/dms-plugin/TopsideWidget.qml +554 -0
  84. package/shell/dms-plugin/plugin.json +14 -0
  85. package/shell/pill.qml +279 -0
  86. package/shell/sekaipop-plugin/Bar.qml +150 -0
  87. package/shell/sekaipop-plugin/Card.qml +296 -0
  88. package/shell/sekaipop-plugin/Floating.qml +74 -0
  89. package/shell/sekaipop-plugin/ListWindow.qml +156 -0
  90. package/shell/sekaipop-plugin/Popup.qml +70 -0
  91. package/shell/sekaipop-plugin/Service.qml +418 -0
  92. package/shell/sekaipop-plugin/ShellLook.qml +43 -0
  93. package/shell/sekaipop-plugin/StyledCard.qml +194 -0
  94. package/shell/sekaipop-plugin/place.js +28 -0
  95. package/shell/sekaipop-plugin/plugin.json +109 -0
@@ -0,0 +1,195 @@
1
+ .pragma library
2
+
3
+ .import "pixels.js" as Pixels
4
+
5
+ // Topside's nine themes, from the shared pixel file (pixels.js, VIA-PARITY
6
+ // section 24). Each has a dark and a light side; each side lists background,
7
+ // surface, text, muted, working, waiting, done, reminder, idle
8
+ // (`themeColors` in the file, `slots` below). `names` is the order the
9
+ // pickers show them in, as on the Mac.
10
+ var names = ["topsideBlack", "tokyoNight", "monokai", "catppuccin", "dracula", "nord", "gruvbox", "solarized", "one"];
11
+
12
+ var titles = {};
13
+ var palettes = {};
14
+ (function () {
15
+ function lower(side) {
16
+ return side.map(function (c) { return c.toLowerCase(); });
17
+ }
18
+ for (var id in Pixels.data.themes) {
19
+ var theme = Pixels.data.themes[id];
20
+ titles[id] = theme.title;
21
+ palettes[id] = { dark: lower(theme.dark), light: lower(theme.light) };
22
+ }
23
+ })();
24
+
25
+ function rgb(hex) {
26
+ var value = parseInt(hex.slice(1), 16);
27
+ return { r: (value >> 16) & 255, g: (value >> 8) & 255, b: value & 255 };
28
+ }
29
+
30
+ function hex(color) {
31
+ function part(n) {
32
+ var s = Math.round(n).toString(16);
33
+ return s.length === 1 ? "0" + s : s;
34
+ }
35
+ return "#" + part(color.r) + part(color.g) + part(color.b);
36
+ }
37
+
38
+ // `from` moved `amount` (0 to 1) of the way toward `to`.
39
+ function mix(from, to, amount) {
40
+ var a = rgb(from);
41
+ var b = rgb(to);
42
+ return hex({ r: a.r + (b.r - a.r) * amount, g: a.g + (b.g - a.g) * amount, b: a.b + (b.b - a.b) * amount });
43
+ }
44
+
45
+ // An unknown theme reads as Topside Black.
46
+ function known(name) {
47
+ return palettes[name] ? name : "topsideBlack";
48
+ }
49
+
50
+ // The colors a view draws with. Shades beyond the nine are mixed the way
51
+ // Topside's Palette.swift mixes them. `neutrals` ({ background, raised, text,
52
+ // muted }, "#rrggbb"), when a host passes it, stands in for the theme's four
53
+ // neutrals, so a card takes the shell's surfaces and ink but keeps the
54
+ // theme's status colors.
55
+ //
56
+ // `custom` is a theme read from a file (`read` below), used in place of the
57
+ // built-in `name` names.
58
+ function colors(name, dark, neutrals, custom) {
59
+ var side = custom ? custom[dark ? "dark" : "light"] : palettes[known(name)][dark ? "dark" : "light"];
60
+ var back = neutrals ? neutrals.background : side[0];
61
+ var raised = neutrals ? neutrals.raised : side[1];
62
+ var text = neutrals ? neutrals.text : side[2];
63
+ var muted = neutrals ? neutrals.muted : side[3];
64
+ return {
65
+ background: back,
66
+ raised: raised,
67
+ surface: mix(back, raised, 0.55),
68
+ primary: text,
69
+ secondary: mix(muted, text, 0.3),
70
+ tertiary: mix(muted, back, 0.2),
71
+ stroke: mix(back, text, 0.16),
72
+ // The reminder color darkened, so white text reads on it in every theme.
73
+ crimson: mix(side[7], "#000000", 0.3),
74
+ working: side[4],
75
+ waiting: side[5],
76
+ done: side[6],
77
+ reminder: side[7],
78
+ idle: side[8],
79
+ };
80
+ }
81
+
82
+ // The theme `steps` along `list` (the built-in names unless given) from
83
+ // `name`, wrapping around. A name not in the list starts from the first.
84
+ function stepped(name, steps, list) {
85
+ var all = list && list.length > 0 ? list : names;
86
+ var index = Math.max(0, all.indexOf(name)) + steps;
87
+ return all[((index % all.length) + all.length) % all.length];
88
+ }
89
+
90
+ // ===== Theme files =====
91
+ // A theme of your own is a JSON file, `<config>/topside/themes/<id>.json`:
92
+ // { "name": "Sakura",
93
+ // "dark": { "background": "#1a1b26", "surface": ..., "text": ..., "muted": ...,
94
+ // "working": ..., "waiting": ..., "done": ..., "reminder": ..., "idle": ... },
95
+ // "light": { the same nine, optional: without it the dark side is used },
96
+ // "shape": { "font": "Inter", "cardRadius": 12, ... optional } }
97
+ // Data only. `read` is the one reader: the QML draws what it returns and
98
+ // `topside theme check` prints its problems, so the two never disagree.
99
+
100
+ // The nine colors of a side, in the order the built-in palettes list them.
101
+ var slots = ["background", "surface", "text", "muted", "working", "waiting", "done", "reminder", "idle"];
102
+
103
+ // The shape a file may set, with the range each number is kept in.
104
+ var shapeKeys = {
105
+ font: "text",
106
+ monoFont: "text",
107
+ cardRadius: [0, 30],
108
+ buttonRadius: [0, 30],
109
+ chipRadius: [0, 20],
110
+ rowRadius: [0, 30],
111
+ panelRadius: [0, 40],
112
+ lineWidth: [0, 6],
113
+ shadowOffset: [0, 12],
114
+ };
115
+
116
+ function isColor(value) {
117
+ return typeof value === "string" && /^#[0-9a-fA-F]{6}$/.test(value);
118
+ }
119
+
120
+ function isObject(value) {
121
+ return value !== null && typeof value === "object" && !Array.isArray(value);
122
+ }
123
+
124
+ // A file's text, read. `theme` is null when it can't be drawn (not JSON, or
125
+ // no complete dark side); `problems` lists everything wrong, as lines.
126
+ // A wrong shape value or an incomplete light side is left out, not fatal.
127
+ function read(text) {
128
+ var problems = [];
129
+ var data;
130
+ try {
131
+ data = JSON.parse(text);
132
+ } catch (e) {
133
+ return { theme: null, problems: ["not JSON: " + e.message] };
134
+ }
135
+ if (!isObject(data)) return { theme: null, problems: ["the file must hold one JSON object"] };
136
+
137
+ function side(key) {
138
+ var value = data[key];
139
+ if (value === undefined) return null;
140
+ if (!isObject(value)) {
141
+ problems.push(key + ": must be an object of nine colors");
142
+ return null;
143
+ }
144
+ var out = [];
145
+ var whole = true;
146
+ for (var i = 0; i < slots.length; i++) {
147
+ var color = value[slots[i]];
148
+ if (color === undefined) {
149
+ problems.push(key + "." + slots[i] + ": missing");
150
+ whole = false;
151
+ } else if (!isColor(color)) {
152
+ problems.push(key + "." + slots[i] + ": " + JSON.stringify(color) + " is not a #rrggbb color");
153
+ whole = false;
154
+ } else {
155
+ out.push(color.toLowerCase());
156
+ }
157
+ }
158
+ for (var extra in value) if (slots.indexOf(extra) < 0) problems.push(key + "." + extra + ": not a color Topside knows (" + slots.join(", ") + ")");
159
+ return whole ? out : null;
160
+ }
161
+
162
+ for (var key in data) if (["name", "dark", "light", "shape"].indexOf(key) < 0) problems.push(key + ": not a part of a theme (name, dark, light, shape)");
163
+ if (data.name !== undefined && (typeof data.name !== "string" || data.name.trim() === "")) problems.push("name: must be some text");
164
+ if (data.dark === undefined) problems.push("dark: missing; a theme needs at least its dark side");
165
+ var dark = side("dark");
166
+ var light = side("light");
167
+
168
+ var shape = {};
169
+ if (data.shape !== undefined) {
170
+ if (!isObject(data.shape)) {
171
+ problems.push("shape: must be an object");
172
+ } else {
173
+ for (var name in data.shape) {
174
+ var rule = shapeKeys[name];
175
+ var value = data.shape[name];
176
+ if (rule === undefined) {
177
+ problems.push("shape." + name + ": not a shape Topside knows (" + Object.keys(shapeKeys).join(", ") + ")");
178
+ } else if (rule === "text") {
179
+ if (typeof value === "string" && value.trim() !== "") shape[name] = value;
180
+ else problems.push("shape." + name + ": must be a font's name");
181
+ } else if (typeof value === "number" && Math.round(value) === value && value >= rule[0] && value <= rule[1]) {
182
+ shape[name] = value;
183
+ } else {
184
+ problems.push("shape." + name + ": must be a whole number from " + rule[0] + " to " + rule[1]);
185
+ }
186
+ }
187
+ }
188
+ }
189
+
190
+ if (!dark) return { theme: null, problems: problems };
191
+ return {
192
+ theme: { name: typeof data.name === "string" && data.name.trim() !== "" ? data.name : "", dark: dark, light: light || dark, shape: shape },
193
+ problems: problems,
194
+ };
195
+ }
@@ -0,0 +1,170 @@
1
+ .pragma library
2
+ .import "board.js" as Board
3
+
4
+ // The order ticket style (Settings > Style > Ticket): what each ticket
5
+ // says. Your agents are the kitchen: a request prints as a paper ticket, you
6
+ // answer with a rubber stamp, a finished turn is ORDER UP!, and the list is
7
+ // the rail with every session's ticket clipped to it. Pure functions, so
8
+ // `node --test` covers them and the QML only draws (TicketNotice.qml,
9
+ // TicketList.qml, TicketDetail.qml). Who waits and in what order is the
10
+ // board's logic (board.js), shared.
11
+
12
+ // The paper and its inks. A ticket is a physical thing, so these stay the
13
+ // same whatever the theme.
14
+ var paper = "#fbf8ef";
15
+ var ink = "#1d1c20";
16
+ var faint = "#6e6a62";
17
+ var rule = "#9b978c";
18
+ var green = "#1f7a3c";
19
+ var red = "#b0302e";
20
+ var inks = { waiting: "#c25e00", working: "#2b5fb8", done: "#1f7a3c", idle: "#6b55b8", untracked: "#6e6a62" };
21
+
22
+ // The stamp on a session's ticket on the rail.
23
+ function tag(session) {
24
+ if (!session) return "";
25
+ if (session.untracked) return "NOT TRACKED";
26
+ if (session.status === "waiting") return "NEEDS YOU";
27
+ if (session.status === "working") return "COOKING";
28
+ if (session.status === "done") return "ORDER UP";
29
+ return "ON BREAK";
30
+ }
31
+
32
+ // That stamp's ink.
33
+ function tagInk(session) {
34
+ if (!session) return faint;
35
+ if (session.untracked) return inks.untracked;
36
+ return inks[session.status] || inks.idle;
37
+ }
38
+
39
+ // The ticket's big line. `request` is a pending entry (Board.pending()),
40
+ // `minutes` how long it has waited when its reminder shows (0 otherwise).
41
+ function headline(request, session, finished, minutes) {
42
+ if (request && minutes > 0) return "STILL WAITING · " + minutes + " MIN";
43
+ if (request && request.kind === "question") return "QUESTION";
44
+ if (request) {
45
+ if (session && Board.gated(session.agent)) return "RISKY COMMAND";
46
+ var tool = String(request.item.toolName || "");
47
+ if (tool === "Edit" || tool === "MultiEdit" || tool === "apply_patch") return "MAY I EDIT?";
48
+ if (tool === "Write") return "MAY I WRITE?";
49
+ if (tool === "Bash" || tool === "shell" || tool === "exec_command") return "MAY I RUN?";
50
+ return "MAY I USE " + tool.replace(/_/g, " ").toUpperCase() + "?";
51
+ }
52
+ if (finished) return "ORDER UP!";
53
+ return tag(session);
54
+ }
55
+
56
+ // The band across the top: the reminder's second notice, the risk gate's hazard.
57
+ function band(request, session, reminding) {
58
+ if (request && reminding) return "2ND NOTICE";
59
+ if (request && request.kind === "approval" && session && Board.gated(session.agent)) return "HAZARD";
60
+ return "";
61
+ }
62
+
63
+ // A ticket's number, the same for the same session every time.
64
+ function orderNumber(id) {
65
+ var h = 0;
66
+ var text = String(id || "");
67
+ for (var i = 0; i < text.length; i++) h = (h * 31 + text.charCodeAt(i)) % 10000;
68
+ var digits = String(h);
69
+ while (digits.length < 4) digits = "0" + digits;
70
+ return "#" + digits;
71
+ }
72
+
73
+ // The stamp a card shortcut presses (⌃Y ⌃N ⌃A), so a key slams and tears
74
+ // like a click: a gated command's stamps are Run it and Block.
75
+ function stampFor(decision, gated) {
76
+ if (decision === "allow") return gated ? "run" : "allow";
77
+ if (decision === "deny") return gated ? "block" : "deny";
78
+ return decision;
79
+ }
80
+
81
+ // The word a stamp leaves on the paper once you've pressed it.
82
+ function stampWord(action, label) {
83
+ var words = { allow: "ALLOWED", deny: "DENIED", always: "ALWAYS", auto: "AUTO", block: "BLOCKED", run: "ALLOWED", spike: "SPIKED", jump: "ON THE WAY" };
84
+ if (action === "answer") return String(label || "").toUpperCase();
85
+ return words[action] || "DONE";
86
+ }
87
+
88
+ // Stamps that mean no come out red.
89
+ function stampBad(action) {
90
+ return action === "deny" || action === "block";
91
+ }
92
+
93
+ // What the printer on the bar says.
94
+ function printerLine(connected, sessions, waiting) {
95
+ if (!connected) return "OFFLINE";
96
+ if (waiting > 0) return waiting + " NEED YOU";
97
+ var cooking = (sessions || []).filter(function (s) { return s.status === "working"; }).length;
98
+ if (cooking > 0) return cooking + " COOKING";
99
+ return (sessions || []).length > 0 ? (sessions || []).length + " ON RAIL" : "NO ORDERS";
100
+ }
101
+
102
+ // How long until a plan window resets: "4D5H", "3H41M", "12M".
103
+ function timeLeft(resetsAt, nowSeconds) {
104
+ var left = Math.max(0, Math.floor(resetsAt - nowSeconds));
105
+ var days = Math.floor(left / 86400), hours = Math.floor(left % 86400 / 3600), minutes = Math.floor(left % 3600 / 60);
106
+ if (days > 0) return days + "D" + hours + "H";
107
+ if (hours > 0) return hours + "H" + minutes + "M";
108
+ return minutes + "M";
109
+ }
110
+
111
+ // "182K", "1.2M".
112
+ function tokens(n) {
113
+ if (!(n > 0)) return "0";
114
+ if (n >= 1e6) return (Math.round(n / 1e5) / 10) + "M";
115
+ if (n >= 1e3) return Math.round(n / 1e3) + "K";
116
+ return String(n);
117
+ }
118
+
119
+ // The shift report's two lines, always two, so the rail under it never
120
+ // moves: { label, percent (null draws a dashed bar, -1 no bar), value, note }.
121
+ // A line with nothing to show says why, or what gets it there.
122
+ function planRows(usage, agent, spend, connected, nowSeconds) {
123
+ if (!connected) return [
124
+ { label: "PRINTER OFFLINE", percent: -1, value: "", note: "" },
125
+ { label: "", percent: null, value: "", note: "start Topside to print" },
126
+ ];
127
+ if (agent === "pi" || agent === "omp") return [
128
+ { label: "TAB", percent: -1, value: spend && spend.cost > 0 ? "$" + spend.cost.toFixed(2) + " · " + tokens(spend.tokens) + " TOKENS" : "nothing yet", note: "this session" },
129
+ { label: "PLAN", percent: -1, value: "", note: "pay as you go · no limits to watch" },
130
+ ];
131
+ var hints = agent === "codex" ? ["after its next turn", ""] : ["waiting for the first reading", "topside usage install"];
132
+ return [["5H", "fiveHour"], ["7D", "sevenDay"]].map(function (w, i) {
133
+ var window = usage ? usage[w[1]] : null;
134
+ if (!window) return { label: w[0] + " PLAN", percent: null, value: "", note: hints[i] };
135
+ if (!(window.resetsAt > nowSeconds)) return { label: w[0] + " PLAN", percent: 0, value: "0%", note: "fresh window" };
136
+ var used = Math.round(window.usedPercentage);
137
+ return { label: w[0] + " PLAN", percent: used, value: used + "%", note: timeLeft(window.resetsAt, nowSeconds) };
138
+ });
139
+ }
140
+
141
+ // One page of the rail, `perRail` tickets at most (VIA-PARITY §28): the
142
+ // sessions come newest first and the rail keeps that order. Every session
143
+ // waiting for an answer goes on the first page (the newest `perRail` of
144
+ // them), so none waits unseen on the spike; the newest of the rest fill it
145
+ // up, and the others page through the spike. A page that's gone starts over.
146
+ // { rows, onSpike (how many aren't on this page), pages }.
147
+ function rail(sessions, page, perRail) {
148
+ var all = sessions || [];
149
+ var front = {};
150
+ var waiting = all.filter(function (s) { return s.status === "waiting"; }).slice(0, perRail);
151
+ waiting.forEach(function (s) { front[s.id] = true; });
152
+ all.filter(function (s) { return s.status !== "waiting"; }).slice(0, perRail - waiting.length)
153
+ .forEach(function (s) { front[s.id] = true; });
154
+ var first = all.filter(function (s) { return front[s.id]; });
155
+ var rest = all.filter(function (s) { return !front[s.id]; });
156
+ var pages = 1 + Math.ceil(rest.length / perRail);
157
+ var at = page < pages ? page : 0;
158
+ var rows = at === 0 ? first : rest.slice((at - 1) * perRail, at * perRail);
159
+ return { rows: rows, onSpike: all.length - rows.length, pages: pages };
160
+ }
161
+
162
+ // The rail page a session's ticket hangs on, or -1.
163
+ function pageOf(sessions, id, perRail) {
164
+ var r = rail(sessions, 0, perRail);
165
+ for (var p = 0; p < r.pages; p++) {
166
+ var rows = p === 0 ? r.rows : rail(sessions, p, perRail).rows;
167
+ for (var i = 0; i < rows.length; i++) if (rows[i].id === id) return p;
168
+ }
169
+ return -1;
170
+ }