@scrylog/cli 0.1.1 → 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.
package/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "@scrylog/cli",
3
- "version": "0.1.1",
3
+ "version": "0.1.2",
4
4
  "description": "Terminal dashboard for monitoring tmux sessions running AI coding agents",
5
5
  "license": "MIT",
6
6
  "type": "module",
@@ -9,7 +9,7 @@ import {
9
9
  getSystemdUnitPath,
10
10
  getUserUid,
11
11
  } from "../shared/paths";
12
- import { IS_LINUX, IS_MAC, IS_WSL } from "../shared/platform";
12
+ import { IS_LINUX, IS_MAC, IS_WSL, whichCommand } from "../shared/platform";
13
13
  import { maybeRunCommand } from "../shared/utils";
14
14
 
15
15
  export interface ServiceStatus {
@@ -52,13 +52,17 @@ function daemonScriptPath(): string {
52
52
  return join(import.meta.dir, "../daemon/index.ts");
53
53
  }
54
54
 
55
- function daemonExec(configPath?: string): string[] {
55
+ export function resolveDaemonExec(configPath?: string, daemonPath = whichCommand("scrylogd")): string[] {
56
56
  const resolvedConfigPath = getResolvedConfigPath(configPath);
57
+ if (daemonPath) {
58
+ return [daemonPath, "--config", resolvedConfigPath];
59
+ }
57
60
  return [process.execPath, "run", daemonScriptPath(), "--config", resolvedConfigPath];
58
61
  }
59
62
 
60
63
  export function renderLaunchAgentPlist(configPath?: string): string {
61
- const [execPath, runArg, scriptPath, configFlag, resolvedConfigPath] = daemonExec(configPath);
64
+ const args = resolveDaemonExec(configPath);
65
+ const programArguments = args.map((arg) => ` <string>${xmlEscape(arg)}</string>`).join("\n");
62
66
  return `<?xml version="1.0" encoding="UTF-8"?>
63
67
  <!DOCTYPE plist PUBLIC "-//Apple//DTD PLIST 1.0//EN" "http://www.apple.com/DTDs/PropertyList-1.0.dtd">
64
68
  <plist version="1.0">
@@ -67,11 +71,7 @@ export function renderLaunchAgentPlist(configPath?: string): string {
67
71
  <string>${getServiceLabel()}</string>
68
72
  <key>ProgramArguments</key>
69
73
  <array>
70
- <string>${execPath}</string>
71
- <string>${runArg}</string>
72
- <string>${scriptPath}</string>
73
- <string>${configFlag}</string>
74
- <string>${resolvedConfigPath}</string>
74
+ ${programArguments}
75
75
  </array>
76
76
  <key>RunAtLoad</key>
77
77
  <true/>
@@ -83,13 +83,13 @@ export function renderLaunchAgentPlist(configPath?: string): string {
83
83
  }
84
84
 
85
85
  export function renderSystemdUserUnit(configPath?: string): string {
86
- const [execPath, runArg, scriptPath, configFlag, resolvedConfigPath] = daemonExec(configPath);
86
+ const args = resolveDaemonExec(configPath);
87
87
  return `[Unit]
88
88
  Description=scrylog daemon
89
89
  After=default.target
90
90
 
91
91
  [Service]
92
- ExecStart=${shellQuote(execPath)} ${shellQuote(runArg)} ${shellQuote(scriptPath)} ${shellQuote(configFlag)} ${shellQuote(resolvedConfigPath)}
92
+ ExecStart=${args.map(shellQuote).join(" ")}
93
93
  Restart=on-failure
94
94
  RestartSec=3
95
95
 
@@ -240,3 +240,12 @@ class UnsupportedServiceManager implements ServiceManager {
240
240
  function shellQuote(value: string): string {
241
241
  return `'${value.replace(/'/g, `'"'"'`)}'`;
242
242
  }
243
+
244
+ function xmlEscape(value: string): string {
245
+ return value
246
+ .replace(/&/g, "&amp;")
247
+ .replace(/</g, "&lt;")
248
+ .replace(/>/g, "&gt;")
249
+ .replace(/"/g, "&quot;")
250
+ .replace(/'/g, "&apos;");
251
+ }