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,84 @@
1
+ import { existsSync, readdirSync, readFileSync } from "node:fs";
2
+ import { basename, extname, join } from "node:path";
3
+ import { env } from "node:process";
4
+ import { configDir } from "../shared/paths.js";
5
+ import { coreLib } from "../shared/qml-lib.js";
6
+ import { err, ok } from "../shared/result.js";
7
+ // shell/core/themes.js, run by coreLib.
8
+ export function themesLib() {
9
+ return coreLib("themes.js");
10
+ }
11
+ export function themesDir() {
12
+ return env.TOPSIDE_THEMES ?? join(configDir(), "topside", "themes");
13
+ }
14
+ // A file's name is the theme's id, which the settings store.
15
+ const idPattern = /^[A-Za-z0-9][A-Za-z0-9_-]*$/;
16
+ export function readThemeFile(path) {
17
+ const id = basename(path, extname(path));
18
+ const lib = themesLib();
19
+ let text;
20
+ try {
21
+ text = readFileSync(path, "utf8");
22
+ }
23
+ catch (error) {
24
+ return { id, title: id, source: path, usable: false, problems: [`can't read it: ${error.message}`] };
25
+ }
26
+ const read = lib.read(text);
27
+ const problems = [...read.problems];
28
+ let usable = read.theme !== null;
29
+ if (!idPattern.test(id)) {
30
+ problems.unshift(`the file's name must be letters, digits, - and _ (it is the theme's id)`);
31
+ usable = false;
32
+ }
33
+ if (lib.names.includes(id)) {
34
+ problems.unshift(`"${id}" is a built-in theme's id, and the built-in wins; rename the file`);
35
+ usable = false;
36
+ }
37
+ return { id, title: read.theme?.name || id, source: path, usable, problems };
38
+ }
39
+ export function builtInThemes() {
40
+ const lib = themesLib();
41
+ return lib.names.map((id) => ({ id, title: lib.titles[id] ?? id, source: "built-in", usable: true, problems: [] }));
42
+ }
43
+ export function userThemes(dir = themesDir()) {
44
+ if (!existsSync(dir))
45
+ return [];
46
+ let files;
47
+ try {
48
+ files = readdirSync(dir).filter((f) => f.endsWith(".json"));
49
+ }
50
+ catch {
51
+ return [];
52
+ }
53
+ return files.sort().map((f) => readThemeFile(join(dir, f)));
54
+ }
55
+ export function allThemes(dir = themesDir()) {
56
+ return [...builtInThemes(), ...userThemes(dir)];
57
+ }
58
+ // A theme by id (built-in or a file in the folder), or a file by path.
59
+ export function findTheme(nameOrPath, dir = themesDir()) {
60
+ if (nameOrPath.includes("/") || nameOrPath.endsWith(".json")) {
61
+ return existsSync(nameOrPath) ? ok(readThemeFile(nameOrPath)) : err(`no file at ${nameOrPath}`);
62
+ }
63
+ const found = allThemes(dir).find((t) => t.id === nameOrPath);
64
+ return found ? ok(found) : err(`no theme "${nameOrPath}": not built in, and no ${join(dir, `${nameOrPath}.json`)}`);
65
+ }
66
+ export function formatThemes(entries, dir = themesDir()) {
67
+ const width = Math.max(...entries.map((t) => t.id.length));
68
+ const line = (t) => {
69
+ const mark = !t.usable ? "✗" : t.problems.length > 0 ? "!" : "✓";
70
+ const title = t.title !== t.id ? ` ${t.title}` : "";
71
+ return `${mark} ${t.id.padEnd(width)}${title}${t.source === "built-in" ? "" : " (yours)"}`;
72
+ };
73
+ const yours = entries.filter((t) => t.source !== "built-in");
74
+ const tail = yours.length === 0 ? `\nNo themes of your own yet. Put one in ${dir}/<id>.json; see the README.\n` : yours.some((t) => t.problems.length > 0) ? `\nSee what's wrong with: topside theme check <id>\n` : "";
75
+ return entries.map(line).join("\n") + "\n" + tail;
76
+ }
77
+ export function formatCheck(entry) {
78
+ if (entry.source === "built-in")
79
+ return `${entry.id} is built in and fine.\n`;
80
+ if (entry.problems.length === 0)
81
+ return `${entry.id} (${entry.source}) is fine.\n`;
82
+ const verdict = entry.usable ? "Topside draws it, leaving out what's wrong:" : "Topside can't draw it, so it falls back to Topside Black:";
83
+ return `${entry.id} (${entry.source})\n${verdict}\n${entry.problems.map((p) => ` - ${p}`).join("\n")}\n`;
84
+ }
package/package.json CHANGED
@@ -1,6 +1,51 @@
1
1
  {
2
2
  "name": "topside-arch",
3
- "version": "0.0.0-stage",
4
- "stub": true,
5
- "description": "Temporary package placeholder for staged publishing"
6
- }
3
+ "version": "0.1.2",
4
+ "description": "Topside for Arch Linux: watch your coding agents from your Quickshell bar (SekaiPop, DankMaterialShell or a pill), answer their requests, jump to their terminal",
5
+ "keywords": [
6
+ "claude-code",
7
+ "codex",
8
+ "coding-agents",
9
+ "quickshell",
10
+ "hyprland",
11
+ "arch-linux",
12
+ "dankmaterialshell",
13
+ "sekaipop"
14
+ ],
15
+ "homepage": "https://topside.ducban.com/arch/",
16
+ "bugs": {
17
+ "url": "https://github.com/ducban/topside/issues"
18
+ },
19
+ "license": "MIT",
20
+ "author": "Nguyen Duc Ban",
21
+ "type": "module",
22
+ "bin": {
23
+ "topside": "dist/cli/main.js",
24
+ "via": "dist/cli/main.js"
25
+ },
26
+ "files": [
27
+ "dist",
28
+ "!dist/**/*.test.js",
29
+ "contrib",
30
+ "shell"
31
+ ],
32
+ "engines": {
33
+ "node": ">=26"
34
+ },
35
+ "scripts": {
36
+ "build": "tsc",
37
+ "typecheck": "tsc --noEmit",
38
+ "test": "node --test \"src/**/*.test.ts\"",
39
+ "lint": "eslint src/",
40
+ "release:patch": "bash scripts/release.sh patch",
41
+ "release:minor": "bash scripts/release.sh minor",
42
+ "release:major": "bash scripts/release.sh major"
43
+ },
44
+ "devDependencies": {
45
+ "@eslint/js": "^10.0.1",
46
+ "@types/node": "^26.6.5",
47
+ "eslint": "^10.13.0",
48
+ "typescript": "~6.0.3",
49
+ "typescript-eslint": "^8.72.0"
50
+ }
51
+ }
@@ -0,0 +1,24 @@
1
+ import QtQuick
2
+ import "agents.js" as Agents
3
+
4
+ // An agent's mark on a rounded square of its color. Drawn, not borrowed.
5
+ Rectangle {
6
+ id: icon
7
+ property string agent: "claude"
8
+ property real size: 18
9
+ readonly property var style: Agents.style(agent)
10
+
11
+ width: size
12
+ height: size
13
+ radius: size * 0.24
14
+ color: style.tint
15
+
16
+ Text {
17
+ anchors.centerIn: parent
18
+ text: icon.style.mark
19
+ color: "white"
20
+ font.pixelSize: icon.size * (icon.style.mark.length > 1 ? 0.52 : 0.62)
21
+ font.weight: Font.Black
22
+ font.family: icon.style.mark.length > 1 ? Theme.monoFont : Theme.font
23
+ }
24
+ }
@@ -0,0 +1,48 @@
1
+ import QtQuick
2
+ import "agents.js" as Agents
3
+
4
+ // Topside's logotype from the shared pixel file: "TOPS", three status dots
5
+ // (working, waiting, done) standing in for the "I", then "DE". The dots
6
+ // belong to no agent.
7
+ Row {
8
+ id: logo
9
+ property real cell: 2
10
+ property color color: Theme.fg
11
+
12
+ spacing: cell * Agents.logotype.letterGap
13
+
14
+ Repeater {
15
+ model: Agents.logotype.before.split("")
16
+ delegate: PixelGrid {
17
+ required property string modelData
18
+ pixels: Agents.glyphs[modelData]
19
+ color: logo.color
20
+ cell: logo.cell
21
+ }
22
+ }
23
+
24
+ Column {
25
+ spacing: logo.cell * Agents.logotype.dotGap
26
+ anchors.verticalCenter: parent.verticalCenter
27
+ Repeater {
28
+ model: Agents.logotype.dots.map(name => Theme[name])
29
+ delegate: Rectangle {
30
+ required property color modelData
31
+ width: logo.cell * Agents.logotype.dotSize
32
+ height: width
33
+ radius: width / 2
34
+ color: modelData
35
+ }
36
+ }
37
+ }
38
+
39
+ Repeater {
40
+ model: Agents.logotype.after.split("")
41
+ delegate: PixelGrid {
42
+ required property string modelData
43
+ pixels: Agents.glyphs[modelData]
44
+ color: logo.color
45
+ cell: logo.cell
46
+ }
47
+ }
48
+ }
@@ -0,0 +1,197 @@
1
+ import QtQuick
2
+ import QtQuick.Layouts
3
+
4
+ // A tool call waiting for an answer, laid out as Topside's permission card:
5
+ // the session's row, "Allow <tool>", the change in a box (a diff with line
6
+ // numbers for edits and writes, the command otherwise), then the answers.
7
+ // Always shows only when the agent offers something to remember; Auto mode
8
+ // only for Claude Code, the one agent that takes it from a hook.
9
+ ColumnLayout {
10
+ id: card
11
+ required property var approval
12
+ property var session: null
13
+ // Show the keys on the buttons: only where they work (the DMS popout's
14
+ // first card).
15
+ property bool shortcuts: false
16
+ signal decided(string decision)
17
+ signal jump()
18
+
19
+ readonly property string toolName: approval.toolName || ""
20
+ readonly property string file: approval.file || ""
21
+ readonly property string always: approval.always || ""
22
+ readonly property bool claude: !session || session.agent === "claude"
23
+ // The box always shows something: the preview, else the one-line command.
24
+ readonly property var lines: (approval.preview || []).length > 0 ? approval.preview
25
+ : [{ kind: "context", text: (approval.summary || "").replace(toolName + ": ", "") }]
26
+ readonly property int added: lines.filter(l => l.kind === "add").length
27
+ readonly property int removed: lines.filter(l => l.kind === "remove").length
28
+
29
+ // Removed lines count the old side, added lines the new one, as in a unified diff.
30
+ readonly property var numbers: {
31
+ let before = 0;
32
+ let after = 0;
33
+ return lines.map(l => l.kind === "remove" ? ++before
34
+ : l.kind === "add" ? ++after
35
+ : l.kind === "context" ? (++after, ++before)
36
+ : "");
37
+ }
38
+
39
+ function foreground(kind) {
40
+ return kind === "add" ? Theme.done : kind === "remove" ? Theme.reminder
41
+ : kind === "more" ? Theme.fgFaint : Theme.level(0.85);
42
+ }
43
+
44
+ spacing: 12
45
+
46
+ CardHeader {
47
+ session: card.session
48
+ Layout.fillWidth: true
49
+ onJump: card.jump()
50
+ }
51
+
52
+ Row {
53
+ spacing: 7
54
+ Text {
55
+ font.family: Theme.font
56
+ text: "⚠"
57
+ color: Theme.waiting
58
+ font.pixelSize: Theme.s(13)
59
+ font.weight: Font.Bold
60
+ }
61
+ Text {
62
+ text: "Allow " + card.toolName
63
+ color: Theme.fg
64
+ font.family: Theme.monoFont
65
+ font.pixelSize: Theme.s(13)
66
+ font.weight: Font.Bold
67
+ }
68
+ }
69
+
70
+ Surface {
71
+ Layout.fillWidth: true
72
+ implicitHeight: box.implicitHeight + (card.file ? 4 : 18)
73
+
74
+ Column {
75
+ id: box
76
+ y: card.file ? 0 : 9
77
+ width: parent.width
78
+
79
+ Row {
80
+ visible: card.file !== ""
81
+ x: 12
82
+ height: 28
83
+ spacing: 8
84
+ Repeater {
85
+ model: [
86
+ { text: card.file, color: Theme.level(0.75), show: true },
87
+ { text: "+" + card.added, color: Theme.done, show: card.added > 0 },
88
+ { text: "−" + card.removed, color: Theme.reminder, show: card.removed > 0 },
89
+ ]
90
+ delegate: Text {
91
+ required property var modelData
92
+ visible: modelData.show
93
+ text: modelData.text
94
+ color: modelData.color
95
+ font.family: Theme.monoFont
96
+ font.pixelSize: Theme.s(12)
97
+ font.weight: Font.DemiBold
98
+ anchors.verticalCenter: parent.verticalCenter
99
+ }
100
+ }
101
+ }
102
+
103
+ Repeater {
104
+ model: card.lines
105
+ delegate: Rectangle {
106
+ id: line
107
+ required property var modelData
108
+ required property int index
109
+ readonly property color ink: card.foreground(modelData.kind)
110
+ width: box.width
111
+ height: Math.max(21, content.implicitHeight)
112
+ color: modelData.kind === "add" ? Qt.rgba(Theme.done.r, Theme.done.g, Theme.done.b, 0.14)
113
+ : modelData.kind === "remove" ? Qt.rgba(Theme.reminder.r, Theme.reminder.g, Theme.reminder.b, 0.14)
114
+ : "transparent"
115
+
116
+ Row {
117
+ id: content
118
+ x: card.file ? 0 : 12
119
+ width: parent.width - x - 8
120
+ anchors.verticalCenter: parent.verticalCenter
121
+
122
+ Text {
123
+ visible: card.file !== ""
124
+ width: 30
125
+ text: card.numbers[line.index]
126
+ horizontalAlignment: Text.AlignRight
127
+ color: Qt.rgba(line.ink.r, line.ink.g, line.ink.b, 0.55)
128
+ font.family: Theme.monoFont
129
+ font.pixelSize: Theme.s(12)
130
+ }
131
+ Text {
132
+ visible: card.file !== ""
133
+ width: 30
134
+ text: line.modelData.kind === "add" ? "+" : line.modelData.kind === "remove" ? "−" : ""
135
+ horizontalAlignment: Text.AlignHCenter
136
+ color: line.ink
137
+ font.family: Theme.monoFont
138
+ font.pixelSize: Theme.s(12)
139
+ }
140
+ Text {
141
+ width: content.width - (card.file ? 60 : 0)
142
+ text: line.modelData.text
143
+ color: line.ink
144
+ font.family: Theme.monoFont
145
+ font.pixelSize: Theme.s(12)
146
+ elide: Text.ElideRight
147
+ textFormat: Text.PlainText
148
+ }
149
+ }
150
+ }
151
+ }
152
+ }
153
+ }
154
+
155
+ RowLayout {
156
+ spacing: 10
157
+ Layout.fillWidth: true
158
+
159
+ CardButton {
160
+ label: "Deny"
161
+ shortcut: card.shortcuts ? "⌃N" : ""
162
+ Layout.fillWidth: true
163
+ onClicked: card.decided("deny")
164
+ }
165
+ CardButton {
166
+ visible: card.always !== ""
167
+ label: "Always"
168
+ shortcut: card.shortcuts ? "⌃A" : ""
169
+ Layout.fillWidth: true
170
+ onClicked: card.decided("always")
171
+ }
172
+ CardButton {
173
+ label: "Allow"
174
+ shortcut: card.shortcuts ? "⌃Y" : ""
175
+ style: "light"
176
+ Layout.fillWidth: true
177
+ onClicked: card.decided("allow")
178
+ }
179
+ CardButton {
180
+ visible: card.claude
181
+ label: "Auto mode"
182
+ style: "danger"
183
+ Layout.fillWidth: true
184
+ onClicked: card.decided("auto")
185
+ }
186
+ }
187
+
188
+ Text {
189
+ font.family: Theme.font
190
+ visible: card.always !== ""
191
+ text: "Always: " + card.always
192
+ color: Theme.fgFaint
193
+ font.pixelSize: Theme.s(11)
194
+ elide: Text.ElideRight
195
+ Layout.fillWidth: true
196
+ }
197
+ }