@sirenodeck/sirenodeck 0.1.1-alpha.0 → 0.2.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 (84) hide show
  1. package/LICENSE +674 -21
  2. package/bin/dev.js +12 -2
  3. package/dist/main.mjs +3655 -1657
  4. package/package.json +18 -16
  5. package/src/api/protocol-internal.ts +16 -1
  6. package/src/assets/logo.png +0 -0
  7. package/src/assets/logo72x72.png +0 -0
  8. package/src/builtin-addons/brightness/buttons/brightness/config.ts +12 -2
  9. package/src/builtin-addons/coding-agents/buttons/agent/config.ts +5 -1
  10. package/src/builtin-addons/coding-agents/buttons/summary/config.ts +15 -3
  11. package/src/builtin-addons/coding-agents/buttons/summary/frontend.tsx +3 -3
  12. package/src/builtin-addons/coding-agents/global/backend.ts +56 -34
  13. package/src/builtin-addons/coding-agents/providers/opencode.ts +4 -5
  14. package/src/builtin-addons/core/buttons/action/config.ts +5 -2
  15. package/src/builtin-addons/core/buttons/change-deck/config.ts +6 -3
  16. package/src/builtin-addons/core/buttons/media-sample/config.ts +2 -2
  17. package/src/builtin-addons/core/buttons/toggle/config.ts +26 -9
  18. package/src/builtin-addons/date-time/buttons/custom/config.ts +5 -1
  19. package/src/builtin-addons/date-time/buttons/date/config.ts +2 -2
  20. package/src/builtin-addons/date-time/buttons/time/config.ts +5 -1
  21. package/src/builtin-addons/emoji-selector/buttons/category/config.ts +3 -3
  22. package/src/builtin-addons/emoji-selector/buttons/emoji/config.ts +5 -2
  23. package/src/builtin-addons/emoji-selector/support.ts +5 -2
  24. package/src/builtin-addons/global-services.ts +23 -0
  25. package/src/builtin-addons/internal-settings/buttons/app-info/config.ts +2 -1
  26. package/src/builtin-addons/internal-settings/buttons/brightness-down/config.ts +6 -1
  27. package/src/builtin-addons/internal-settings/buttons/brightness-up/config.ts +6 -1
  28. package/src/builtin-addons/media/backend.ts +54 -0
  29. package/src/builtin-addons/media/buttons/volume/volume-down/config.ts +1 -1
  30. package/src/builtin-addons/media/buttons/volume/volume-up/config.ts +1 -1
  31. package/src/builtin-addons/session/buttons/time/config.ts +1 -1
  32. package/src/builtin-addons/system-status/buttons/system-status/schemas.ts +32 -6
  33. package/src/builtin-addons/system-status/manifest.ts +49 -0
  34. package/src/builtin-addons/value-display/buttons/value-display/config.ts +23 -9
  35. package/src/builtin-addons/weather/buttons/weather/config.ts +11 -6
  36. package/src/cli/coding-agents-onboarding.ts +181 -34
  37. package/src/cli/commands/command-executor.ts +61 -0
  38. package/src/cli/commands/emulator-mode.ts +17 -2
  39. package/src/cli/commands/network-bind.ts +13 -9
  40. package/src/cli/commands/restart.ts +15 -5
  41. package/src/cli/commands/run.ts +174 -317
  42. package/src/cli/commands/service/render-template.ts +10 -0
  43. package/src/cli/commands/skills.ts +106 -0
  44. package/src/cli/commands/start.ts +39 -9
  45. package/src/cli/commands/stop.ts +3 -2
  46. package/src/cli/commands/system-requirements.ts +1 -0
  47. package/src/cli/index.ts +16 -3
  48. package/src/cli/main.ts +15 -2
  49. package/src/cli/package-manager.ts +6 -0
  50. package/src/cli/skills-first-run.ts +46 -0
  51. package/src/cli/startup-display.ts +35 -17
  52. package/src/config/mutation.ts +13 -1
  53. package/src/config/schemas.ts +3 -3
  54. package/src/config/validation.ts +7 -1
  55. package/src/core/icon-asset-registry.ts +11 -6
  56. package/src/deck/addon-handler-bridge.ts +246 -176
  57. package/src/deck/deck-config.ts +11 -2
  58. package/src/deck/deck-presentation-publisher.ts +116 -0
  59. package/src/deck/index.ts +13 -0
  60. package/src/deck/inject-config-ui-button.ts +23 -0
  61. package/src/deck/methods.ts +23 -0
  62. package/src/deck/position-settings-version-button.ts +20 -0
  63. package/src/deck/runtime/host-policy-coordinator.ts +186 -0
  64. package/src/deck/runtime/runtime.ts +123 -250
  65. package/src/deck/system-back-injection.ts +2 -1
  66. package/src/device/reconnecting.ts +8 -1
  67. package/src/index.ts +1 -2
  68. package/src/outputClient/emulator.ts +13 -0
  69. package/src/outputClient/index.ts +8 -0
  70. package/src/outputClient/real.ts +40 -45
  71. package/src/outputClient/remote-mirror.ts +77 -0
  72. package/src/outputClient/types.ts +2 -0
  73. package/src/render/editor-handler.ts +12 -1
  74. package/src/render/frontend-bridge-url.ts +10 -0
  75. package/src/render/push-startup-screen.ts +76 -0
  76. package/src/render/ws-bridge.ts +2 -0
  77. package/src/system/providers/active-app/capture-file.ts +61 -0
  78. package/src/system/providers/active-app/wayland-gnome.ts +26 -10
  79. package/src/system/providers/active-app.ts +6 -0
  80. package/src/system/providers/clipboard/darwin.ts +28 -4
  81. package/src/system/providers/url.ts +57 -0
  82. package/src/util/logger.ts +19 -3
  83. package/src/version.ts +3 -1
  84. package/src/vite/virtual-modules.ts +12 -6
@@ -120,6 +120,16 @@ export const renderDarwinPlist = (vars: TemplateVars): string => {
120
120
  " <dict>",
121
121
  " <key>PATH</key>",
122
122
  ` <string>${darwinPathEntries(program)}</string>`,
123
+ // ponytail: launchd starts the daemon with no locale, and a process with
124
+ // no locale on macOS is assumed to speak Mac OS Roman. `pbcopy` then read
125
+ // an emoji's UTF-8 bytes as Mac OS Roman characters and copied those
126
+ // instead — 🏉 arrived as "üèâ" — without failing or logging anything.
127
+ // The clipboard provider states its own encoding now, so this is belt and
128
+ // braces, but any other child process the daemon spawns inherits it too.
129
+ " <key>LANG</key>",
130
+ " <string>en_US.UTF-8</string>",
131
+ " <key>LC_CTYPE</key>",
132
+ " <string>UTF-8</string>",
123
133
  " </dict>",
124
134
  " <key>WorkingDirectory</key>",
125
135
  ` <string>${vars.workingDirectory}</string>`,
@@ -0,0 +1,106 @@
1
+ import { execa } from "execa"
2
+
3
+ import type { CommandModule } from "yargs"
4
+
5
+ import { confirm, isCancel, intro, log, note } from "@/cli/prompt"
6
+
7
+ const SKILLS_SOURCE =
8
+ "https://github.com/sergiocarracedo/sireno-deck/tree/main/skills/sirenodeck-config"
9
+
10
+ export interface SkillsOptions {
11
+ readonly yes?: boolean
12
+ readonly confirmed?: boolean
13
+ readonly agents?: ReadonlyArray<string>
14
+ readonly interactive?: boolean
15
+ }
16
+
17
+ export const installConfigSkill = async (
18
+ options: SkillsOptions = {},
19
+ ): Promise<boolean> => {
20
+ const yes = options.yes === true
21
+ const interactive = options.interactive ?? process.stdin.isTTY === true
22
+ if (!yes && !interactive) {
23
+ note(
24
+ `No terminal is available. Run this command interactively, or use:\n\nnpx skills add ${SKILLS_SOURCE} --skill sirenodeck-config --global`,
25
+ "Install Sireno Deck skill",
26
+ )
27
+ return false
28
+ }
29
+
30
+ intro("sirenodeck skills")
31
+ note(
32
+ "Install the Sireno Deck config skill for your preferred coding agent. It helps your agent configure and update decks, buttons, and themes from your config.yml. The skill is installed globally from GitHub; it can read and edit your config only with your agent's normal file access.",
33
+ "Configure decks with your agent",
34
+ )
35
+
36
+ if (!yes && options.confirmed !== true) {
37
+ const answer = await confirm({
38
+ message: "Install the Sireno Deck config skill globally?",
39
+ initialValue: false,
40
+ })
41
+ if (isCancel(answer) || !answer) {
42
+ log.info("Skill installation cancelled.")
43
+ return false
44
+ }
45
+ }
46
+
47
+ const args = [
48
+ "skills",
49
+ "add",
50
+ SKILLS_SOURCE,
51
+ "--skill",
52
+ "sirenodeck-config",
53
+ "--global",
54
+ ]
55
+ if (options.agents !== undefined && options.agents.length > 0) {
56
+ for (const agent of options.agents) args.push("--agent", agent)
57
+ } else if (yes) {
58
+ // A non-interactive install must choose a target. Explicitly target all
59
+ // supported agents rather than relying on the upstream CLI's default.
60
+ args.push("--agent", "*")
61
+ }
62
+ if (yes) args.push("--yes")
63
+
64
+ try {
65
+ await execa("npx", ["--yes", ...args], { stdio: "inherit" })
66
+ log.success("Sireno Deck config skill installed.")
67
+ return true
68
+ } catch (error) {
69
+ log.error(
70
+ `Could not install the skill: ${error instanceof Error ? error.message : String(error)}\nYou can retry with: npx skills add ${SKILLS_SOURCE} --skill sirenodeck-config --global`,
71
+ )
72
+ return false
73
+ }
74
+ }
75
+
76
+ interface SkillsArgs {
77
+ readonly yes?: boolean
78
+ readonly agent?: ReadonlyArray<string>
79
+ }
80
+
81
+ export const skillsCommand: CommandModule<object, SkillsArgs> = {
82
+ command: "skills",
83
+ describe: "Install the Sireno Deck config skill for a coding agent",
84
+ builder: (yargs) =>
85
+ yargs
86
+ .option("yes", {
87
+ alias: "y",
88
+ type: "boolean",
89
+ description:
90
+ "Skip confirmation; if no --agent is provided, install for all supported agents",
91
+ default: false,
92
+ })
93
+ .option("agent", {
94
+ type: "string",
95
+ array: true,
96
+ description:
97
+ "Target agent ID (repeat for multiple agents); without this, choose interactively",
98
+ }),
99
+ handler: async (argv) => {
100
+ const success = await installConfigSkill({
101
+ yes: argv.yes,
102
+ agents: argv.agent,
103
+ })
104
+ if (!success && argv.yes === true) process.exitCode = 1
105
+ },
106
+ }
@@ -14,7 +14,15 @@ import {
14
14
  readProcCmdline,
15
15
  } from "./port-identity"
16
16
 
17
- import { resolveConfigPath as resolveRunConfigPath } from "./pipeline/helpers"
17
+ import {
18
+ resolveConfigPath as resolveRunConfigPath,
19
+ resolveRunFolderConfigPath,
20
+ } from "./pipeline/helpers"
21
+ import {
22
+ DEFAULT_BRIDGE_PORT,
23
+ DEFAULT_CONFIG_UI_PORT,
24
+ DEFAULT_FRONTEND_PORT,
25
+ } from "./emulator-mode"
18
26
  import type { ResolveConfigPathResult } from "./pipeline/helpers"
19
27
  import {
20
28
  acquireStartLock,
@@ -66,6 +74,7 @@ import { systemRequirements } from "./system-requirements"
66
74
  import { buildStandardProbeDeps } from "@/cli/probe-deps"
67
75
  import { onboardCodingAgents } from "@/cli/coding-agents-onboarding"
68
76
  import { resolveUserPath } from "@/cli/cwd"
77
+ import { offerConfigSkillOnFirstRun } from "@/cli/skills-first-run"
69
78
 
70
79
  export interface StartOptions {
71
80
  readonly config?: string
@@ -478,6 +487,13 @@ const resolveConfigPath = (options: StartOptions): ResolveConfigPathResult => {
478
487
  }
479
488
  return { path: explicit, source: "cli" }
480
489
  }
490
+ // A fresh `start` from a checkout must use that checkout's config rather
491
+ // than a global pointer left by another worktree. `restart` retains its
492
+ // cached flags and therefore remains the explicit "same session" command.
493
+ const runFolderConfig = resolveRunFolderConfigPath()
494
+ if (existsSync(runFolderConfig)) {
495
+ return { path: runFolderConfig, source: "run-folder" }
496
+ }
481
497
  // ponytail: the daemon honors the cached pointer first so the running
482
498
  // session keeps editing the same config it was launched with. When the
483
499
  // cached path is gone (e.g. worktree removed) we fall through to the
@@ -497,7 +513,9 @@ const resolveConfigPath = (options: StartOptions): ResolveConfigPathResult => {
497
513
  }
498
514
 
499
515
  const buildRuntimeFlags = (options: StartOptions): RuntimeFlags => ({
500
- emulator: options.emulator === true || options.remote === true,
516
+ // Remote mode adds the browser surface; it does not replace attached
517
+ // hardware. Only an explicit --emulator selects the virtual output device.
518
+ emulator: options.emulator === true,
501
519
  remote: options.remote,
502
520
  httpPort: options.httpPort ?? 3939,
503
521
  ...(options.config !== undefined ? { config: options.config } : {}),
@@ -910,7 +928,9 @@ const runFirstRunCheckIfNeeded = async (
910
928
  return true
911
929
  }
912
930
 
913
- const start = async (options: StartOptions): Promise<void> => {
931
+ export type StartLaunchResult = "started" | "blocked" | "cancelled"
932
+
933
+ const start = async (options: StartOptions): Promise<StartLaunchResult> => {
914
934
  const { logger } = options
915
935
 
916
936
  // ponytail: skip the first-run wizard in the daemon child. The forked
@@ -923,10 +943,18 @@ const start = async (options: StartOptions): Promise<void> => {
923
943
  // the wizard before forking, so the child has no business re-running it.
924
944
  if (isUnderServiceManager()) {
925
945
  await runInProcess(options)
926
- return
946
+ return "started"
927
947
  }
928
948
 
929
- if (!(await runFirstRunCheckIfNeeded(options, logger))) return
949
+ if (!(await runFirstRunCheckIfNeeded(options, logger))) {
950
+ return process.exitCode === 1 ? "blocked" : "cancelled"
951
+ }
952
+
953
+ try {
954
+ await offerConfigSkillOnFirstRun()
955
+ } catch (error) {
956
+ logger.warn({ err: error }, "start: agent skill offer failed, continuing")
957
+ }
930
958
 
931
959
  await onboardCodingAgents(resolveConfigPath(options).path)
932
960
 
@@ -943,7 +971,7 @@ const start = async (options: StartOptions): Promise<void> => {
943
971
  const action = await promptConflict(existing)
944
972
  if (action === "cancel") {
945
973
  logger.info("start cancelled")
946
- return
974
+ return "cancelled"
947
975
  }
948
976
  // ponytail: a supervised daemon cannot be restarted by killing it. launchd
949
977
  // with KeepAlive brings it back in about two seconds — measured — and the
@@ -979,7 +1007,7 @@ const start = async (options: StartOptions): Promise<void> => {
979
1007
  ? "start: service manager restarted the daemon (pid not yet visible)"
980
1008
  : "start: daemon restarted by the service manager",
981
1009
  )
982
- return
1010
+ return "started"
983
1011
  }
984
1012
  if (existing !== null) await stopExisting(existing, logger)
985
1013
  else
@@ -1034,10 +1062,11 @@ const start = async (options: StartOptions): Promise<void> => {
1034
1062
  // SIGKILL that left orphans adopted by systemd), the port still binds
1035
1063
  // the orphan. ss -ltnp → SIGTERM every listener → 500ms grace → start.
1036
1064
  // Cost: bounded, no-op when the ports are free.
1065
+ const bridgePort = options.port ?? DEFAULT_BRIDGE_PORT
1037
1066
  await killPortListeners(
1038
1067
  options.emulator === true
1039
- ? [5180, 3939, 52937, 52938]
1040
- : [5180, 3939, 52937],
1068
+ ? [DEFAULT_FRONTEND_PORT, 3939, bridgePort, DEFAULT_CONFIG_UI_PORT]
1069
+ : [DEFAULT_FRONTEND_PORT, 3939, bridgePort],
1041
1070
  logger,
1042
1071
  )
1043
1072
 
@@ -1056,6 +1085,7 @@ const start = async (options: StartOptions): Promise<void> => {
1056
1085
  } else {
1057
1086
  await startProduction(options)
1058
1087
  }
1088
+ return "started"
1059
1089
  }
1060
1090
 
1061
1091
  export default start
@@ -1,4 +1,5 @@
1
1
  import type pino from "pino"
2
+ import { DEFAULT_BRIDGE_PORT } from "./emulator-mode"
2
3
 
3
4
  import { join } from "node:path"
4
5
 
@@ -27,7 +28,7 @@ export interface StopOptions {
27
28
  readonly logger: pino.Logger
28
29
  }
29
30
 
30
- const DEFAULT_PORT = 52937
31
+ const DEFAULT_PORT = DEFAULT_BRIDGE_PORT
31
32
 
32
33
  const killGracefully = async (
33
34
  pid: number,
@@ -111,7 +112,7 @@ export const stop = async ({ logger }: StopOptions): Promise<void> => {
111
112
  // daemon IS stopped from a process-management perspective.
112
113
  logger.warn(
113
114
  { port: DEFAULT_PORT },
114
- "stop: daemon exited but port 52937 is still bound — check for orphans with `p dev status`",
115
+ `stop: daemon exited but port ${DEFAULT_PORT} is still bound — check for orphans with \`p dev status\``,
115
116
  )
116
117
  }
117
118
 
@@ -652,6 +652,7 @@ export const systemRequirementsCommand: CommandModule<
652
652
  SystemRequirementsArgs
653
653
  > = {
654
654
  command: "system-requirements",
655
+ aliases: ["onboard"],
655
656
  describe:
656
657
  "Detect system capabilities (key macro, clipboard, notification, active-app) and optionally install missing pieces",
657
658
  builder: (yargs) =>
package/src/cli/index.ts CHANGED
@@ -35,6 +35,7 @@ import {
35
35
  resolveDaemonPaths,
36
36
  } from "@/util/daemon"
37
37
  import { cancel, intro, log } from "./prompt"
38
+ import { skillsCommand } from "./commands/skills"
38
39
 
39
40
  export interface GlobalOptions {
40
41
  verbose?: boolean
@@ -174,7 +175,15 @@ const startCommand: CommandModule<object, StartArgs> = {
174
175
  const logSnapshot = snapshotDaemonLog()
175
176
  const logPath = join(resolveDaemonPaths().runtimeDir, "service.log")
176
177
  const startRequestedAt = Date.now()
177
- const startPromise = start(options)
178
+ const launchResult = await start(options)
179
+ if (launchResult !== "started") {
180
+ if (launchResult === "blocked") {
181
+ const message =
182
+ "Startup stopped before the daemon was launched. Resolve the requirement warning above, then retry."
183
+ printStartupFailed(message)
184
+ }
185
+ return
186
+ }
178
187
  const outcome: StartOutcome = await waitForFullStart({
179
188
  port: options.port ?? 52937,
180
189
  tcpTimeoutMs: 30_000,
@@ -212,13 +221,16 @@ const startCommand: CommandModule<object, StartArgs> = {
212
221
  // ponytail: TCP never bound. Either the daemon crashed during
213
222
  // boot, or port 52937 is held by an unrelated process. Either
214
223
  // way, the start failed — the operator needs to know.
215
- const message = `daemon: port ${options.port ?? 52937} did not accept connections in 30s`
224
+ const port = options.port ?? 52937
225
+ const message =
226
+ `SirenoDeck did not open its WebSocket on 127.0.0.1:${port} within 30 seconds. ` +
227
+ "The daemon may have exited during startup. Check `sirenodeck logs` for the cause; " +
228
+ "if another app is using this port, stop it or retry with `--port <port>`."
216
229
  logger.warn(message)
217
230
  process.exitCode = 1
218
231
  printStartupFailed(message)
219
232
  return
220
233
  }
221
- await startPromise
222
234
  } catch (err) {
223
235
  printStartupFailed(err)
224
236
  const e = err as { issues?: unknown; message?: unknown }
@@ -348,6 +360,7 @@ export const buildCli = async (): Promise<{
348
360
  logsCommand as CommandModule<object, GlobalOptions>,
349
361
  systemRequirementsCommand as CommandModule<object, GlobalOptions>,
350
362
  installCommand as CommandModule<object, GlobalOptions>,
363
+ skillsCommand as CommandModule<object, GlobalOptions>,
351
364
  ],
352
365
  packageName: PACKAGE_NAME,
353
366
  version: VERSION,
package/src/cli/main.ts CHANGED
@@ -68,9 +68,10 @@ const installProcessGuards = (
68
68
  logger: ReturnType<typeof createLogger>,
69
69
  ): void => {
70
70
  process.on("uncaughtException", (err, origin) => {
71
+ const summary = `${err.name}: ${err.message}`
71
72
  logger.fatal(
72
73
  { err, origin },
73
- "uncaughtException — exiting to surface the failure",
74
+ `Unexpected error: ${summary}. See the stack trace for where it occurred.`,
74
75
  )
75
76
  killChildrenAndExit(logger, 1)
76
77
  })
@@ -89,12 +90,24 @@ const installProcessGuards = (
89
90
  typeof (promise as unknown as { stack?: unknown }).stack === "string"
90
91
  ? (promise as unknown as { stack: string }).stack
91
92
  : undefined
93
+ const summary =
94
+ reason instanceof Error
95
+ ? `${reason.name}: ${reason.message}`
96
+ : typeof reason === "string"
97
+ ? reason
98
+ : (() => {
99
+ try {
100
+ return JSON.stringify(reason) ?? String(reason)
101
+ } catch {
102
+ return String(reason)
103
+ }
104
+ })()
92
105
  logger.fatal(
93
106
  {
94
107
  reason: reasonDump,
95
108
  ...(stackDump !== undefined ? { stack: stackDump } : {}),
96
109
  },
97
- "unhandledRejection — exiting to surface the failure",
110
+ `An asynchronous operation failed: ${summary}. See the stack trace for where it originated.`,
98
111
  )
99
112
  killChildrenAndExit(logger, 1)
100
113
  })
@@ -1,5 +1,6 @@
1
1
  import { execFileSync } from "node:child_process"
2
2
  import { existsSync } from "node:fs"
3
+ import { homedir } from "node:os"
3
4
  import { join } from "node:path"
4
5
 
5
6
  export type PackageManager = "pnpm" | "npm" | "yarn"
@@ -132,8 +133,13 @@ const probeRoot = (manager: PackageManager): RootProbe => {
132
133
  try {
133
134
  const root = execFileSync(manager, ["root", "--global"], {
134
135
  ...probeOptions(),
136
+ // These discovery probes ask only for a global root. Avoid loading a
137
+ // workspace .npmrc (which contains pnpm-only settings) and suppress
138
+ // package-manager warnings that are unrelated to startup diagnostics.
139
+ cwd: homedir(),
135
140
  encoding: "utf8",
136
141
  env: probeEnv(),
142
+ stdio: ["ignore", "pipe", "ignore"],
137
143
  }).trim()
138
144
  return root.length > 0 ? { kind: "root", root } : { kind: "unavailable" }
139
145
  } catch (error) {
@@ -0,0 +1,46 @@
1
+ import { existsSync, mkdirSync, writeFileSync } from "node:fs"
2
+ import { homedir } from "node:os"
3
+ import { dirname, join } from "node:path"
4
+
5
+ import { confirm, isCancel, note } from "@/cli/prompt"
6
+
7
+ import { installConfigSkill } from "./commands/skills"
8
+
9
+ const offerPath = (): string =>
10
+ join(
11
+ process.env["XDG_CONFIG_HOME"] ?? join(homedir(), ".config"),
12
+ "sirenodeck",
13
+ "skills-offer-v1.json",
14
+ )
15
+
16
+ export const offerConfigSkillOnFirstRun = async (): Promise<void> => {
17
+ if (process.stdin.isTTY !== true || existsSync(offerPath())) return
18
+
19
+ note(
20
+ "Your coding agent can help configure and update Sireno Deck decks, buttons, and themes. This optional skill is installed from GitHub.",
21
+ "Sireno Deck agent skill",
22
+ )
23
+ const answer = await confirm({
24
+ message: "Install the Sireno Deck skill for your coding agent?",
25
+ initialValue: false,
26
+ })
27
+ if (isCancel(answer) || !answer) {
28
+ saveOfferChoice("declined")
29
+ return
30
+ }
31
+
32
+ if (await installConfigSkill({ confirmed: true })) saveOfferChoice("accepted")
33
+ }
34
+
35
+ const saveOfferChoice = (choice: "declined" | "accepted"): void => {
36
+ const path = offerPath()
37
+ try {
38
+ mkdirSync(dirname(path), { recursive: true })
39
+ writeFileSync(path, JSON.stringify({ version: 1, choice }), {
40
+ encoding: "utf8",
41
+ mode: 0o600,
42
+ })
43
+ } catch {
44
+ // The offer is advisory: inability to remember it must not block startup.
45
+ }
46
+ }
@@ -15,6 +15,8 @@ import {
15
15
  } from "@/system/setup-wizard"
16
16
 
17
17
  import { cancel, intro, log, outro } from "@/cli/prompt"
18
+ import { color } from "@/system/setup-wizard/format"
19
+ import { VERSION } from "@/version"
18
20
 
19
21
  import {
20
22
  readDaemonEventsFromSnapshot,
@@ -174,20 +176,30 @@ const tryBind = (port: number): Promise<boolean> =>
174
176
  }
175
177
  })
176
178
 
177
- interface FeatureItem {
179
+ export interface FeatureItem {
178
180
  readonly name: string
179
181
  readonly available: boolean
180
182
  readonly reason?: string
181
183
  }
182
184
 
183
- const formatFeaturesLine = (items: ReadonlyArray<FeatureItem>): string =>
184
- items
185
- .map((it) =>
186
- it.available
187
- ? `[✓ ${it.name}]`
188
- : `[✗ ${it.name}${it.reason !== undefined ? ` — ${it.reason}` : ""}]`,
189
- )
190
- .join(" ")
185
+ export const formatFeaturesList = (
186
+ items: ReadonlyArray<FeatureItem>,
187
+ ): string[] => [
188
+ "Features",
189
+ ...items.map(
190
+ (it) =>
191
+ ` ${it.name} ${it.available ? color.green("✓") : color.red("✗")}${!it.available && it.reason ? ` — ${it.reason}` : ""}`,
192
+ ),
193
+ ]
194
+
195
+ export const printFeaturesList = (
196
+ items: ReadonlyArray<FeatureItem>,
197
+ write: (text: string) => void = (text) => process.stdout.write(text),
198
+ ): string[] => {
199
+ const lines = formatFeaturesList(items)
200
+ write(`${lines.slice(1).join("\n")}\n`)
201
+ return lines
202
+ }
191
203
 
192
204
  const toFeatureItem = (
193
205
  name: string,
@@ -213,7 +225,7 @@ const deviceLabel = (
213
225
  }
214
226
 
215
227
  export interface BannerResult {
216
- readonly featuresLine: string
228
+ readonly featuresLines: string[]
217
229
  readonly deviceLabel: string
218
230
  }
219
231
 
@@ -247,13 +259,19 @@ export const buildStartupBanner = async (
247
259
  toFeatureItem("http", http),
248
260
  ]
249
261
 
250
- const featuresLine = formatFeaturesLine(items)
262
+ const featuresLines = formatFeaturesList(items)
251
263
  const label = deviceLabel(options.emulator, options.deviceModel, devices)
252
264
 
253
- intro("Starting SirenoDeck")
265
+ intro(`Starting SirenoDeck v${VERSION}`)
254
266
  log.info(`Device: ${label}`)
255
- log.info(featuresLine)
256
- return { featuresLine, deviceLabel: label }
267
+ log.info("Features")
268
+ printFeaturesList(items)
269
+ if (items.some((item) => !item.available)) {
270
+ log.warn(
271
+ "Some features are unavailable. Run `sirenodeck onboard` to install missing dependencies.",
272
+ )
273
+ }
274
+ return { featuresLines, deviceLabel: label }
257
275
  }
258
276
 
259
277
  const toSystemCap = (
@@ -321,7 +339,7 @@ export const printDaemonUrl = async (
321
339
  const isTty = Boolean(process.stdout.isTTY)
322
340
  if (isTty) {
323
341
  write("\n Emulator (LAN):\n")
324
- for (const addr of state.addresses) {
342
+ for (const addr of state.addresses.slice(0, 1)) {
325
343
  const url = buildUrl(addr, true)
326
344
  const qr = await qrcode.toString(url, {
327
345
  type: "terminal",
@@ -330,8 +348,8 @@ export const printDaemonUrl = async (
330
348
  write(`\n${qr} ${url}\n`)
331
349
  }
332
350
  } else {
333
- for (const addr of state.addresses) {
334
- write(` ${addr}: ${buildUrl(addr, false)}\n`)
351
+ for (const addr of state.addresses.slice(0, 1)) {
352
+ write(` ${addr}: ${buildUrl(addr, true)}\n`)
335
353
  }
336
354
  }
337
355
  }
@@ -273,9 +273,21 @@ export const createConfigMutationService = ({
273
273
  } catch {
274
274
  throw new ConfigMutationError("Invalid asset data")
275
275
  }
276
+ if (bytes.length > 2_000_000)
277
+ throw new ConfigMutationError("SVG asset exceeds 2 MB")
278
+ if (!safeName.toLowerCase().endsWith(".svg"))
279
+ throw new ConfigMutationError("Only SVG assets are supported")
280
+ if (!/^\s*(?:<\?xml[^>]*>\s*)?<svg\b/i.test(bytes.toString("utf8")))
281
+ throw new ConfigMutationError("Invalid SVG asset")
276
282
  const assetDir = join(dirname(rootPath), "assets")
277
283
  mkdirSync(assetDir, { recursive: true })
278
- writeFileSync(join(assetDir, safeName), bytes)
284
+ try {
285
+ writeFileSync(join(assetDir, safeName), bytes, { flag: "wx" })
286
+ } catch (error) {
287
+ if ((error as NodeJS.ErrnoException).code === "EEXIST")
288
+ throw new ConfigMutationError(`Asset already exists: ${safeName}`)
289
+ throw error
290
+ }
279
291
  },
280
292
  apply: (mutation) =>
281
293
  run(() => {
@@ -14,9 +14,9 @@ export const TriggerSchema = z
14
14
 
15
15
  export const ButtonActionsSchema = z
16
16
  .object({
17
- tap: z.string().min(1).optional(),
18
- dbltap: z.string().min(1).optional(),
19
- hold: z.string().min(1).optional(),
17
+ tap: z.string().min(1).optional().meta({ title: "Tap action" }),
18
+ dbltap: z.string().min(1).optional().meta({ title: "Double-tap action" }),
19
+ hold: z.string().min(1).optional().meta({ title: "Hold action" }),
20
20
  })
21
21
  .strict()
22
22
 
@@ -103,10 +103,16 @@ export const validateButton = (
103
103
  const base = { deckId, position }
104
104
  const issues: FullValidationIssue[] = []
105
105
  if (!registry.hasButtonType(btn.type)) {
106
+ const addonName = btn.type.split(":", 1)[0]
107
+ const availableTypes = registry.getAddon(addonName ?? "")?.buttonTypes
108
+ const hint =
109
+ availableTypes !== undefined
110
+ ? ` Available button types for '${addonName}': ${Object.keys(availableTypes).join(", ") || "none"}. Check the type spelling.`
111
+ : " Check the type spelling and confirm that its addon is installed and enabled."
106
112
  issues.push({
107
113
  level: "error",
108
114
  path: `${path}.type`,
109
- message: `Unknown button type: ${btn.type}`,
115
+ message: `Unknown button type: ${btn.type}.${hint}`,
110
116
  reason: "unknown-type",
111
117
  ...base,
112
118
  })
@@ -86,11 +86,16 @@ const registerOneIcon = (
86
86
  })
87
87
  }
88
88
 
89
- const readButtonIcon = (button: RuntimeButton): string | undefined => {
89
+ const readButtonIcons = (button: RuntimeButton): string[] => {
90
90
  const cfg = button.config
91
- if (typeof cfg !== "object" || cfg === null) return undefined
92
- const icon = (cfg as Record<string, unknown>).icon
93
- return typeof icon === "string" && icon !== "" ? icon : undefined
91
+ const configIcon =
92
+ typeof cfg === "object" && cfg !== null
93
+ ? (cfg as Record<string, unknown>).icon
94
+ : undefined
95
+ return [configIcon, button.icon].filter(
96
+ (icon, index, icons): icon is string =>
97
+ typeof icon === "string" && icon !== "" && icons.indexOf(icon) === index,
98
+ )
94
99
  }
95
100
 
96
101
  export const registerIconForDeck = (
@@ -99,8 +104,8 @@ export const registerIconForDeck = (
99
104
  logger?: pino.Logger,
100
105
  ): void => {
101
106
  for (const button of buttons) {
102
- const icon = readButtonIcon(button)
103
- if (icon !== undefined) registerOneIcon(icon, resolverOptions, logger)
107
+ for (const icon of readButtonIcons(button))
108
+ registerOneIcon(icon, resolverOptions, logger)
104
109
  }
105
110
  }
106
111