@coworker-jp/aidr 0.0.6 → 0.0.8

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 (2) hide show
  1. package/package.json +1 -1
  2. package/src/sentinel.mjs +11 -8
package/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "@coworker-jp/aidr",
3
- "version": "0.0.6",
3
+ "version": "0.0.8",
4
4
  "description": "AIDR setup CLI - installs ai-scanner hooks for 19+ AI coding agents",
5
5
  "type": "module",
6
6
  "bin": {
package/src/sentinel.mjs CHANGED
@@ -60,7 +60,7 @@ function buildLaunchdPlist(envFile) {
60
60
  <array>
61
61
  <string>/bin/sh</string>
62
62
  <string>-c</string>
63
- <string>. ${envFile} &amp;&amp; exec ${SENTINEL_BIN}</string>
63
+ <string>set -a; . ${envFile}; set +a; exec ${SENTINEL_BIN}</string>
64
64
  </array>
65
65
  <key>RunAtLoad</key>
66
66
  <true/>
@@ -167,13 +167,15 @@ async function _installMacos(dryRun, noActivate) {
167
167
  console.error(`[sentinel] Written: ${SENTINEL_PLIST}`);
168
168
 
169
169
  if (!noActivate && process.env.AI_SCANNER_NO_SCHEDULED_ACTIVATE !== "1") {
170
- // Unload existing (ignore errors) then load
171
- spawnSync("launchctl", ["unload", SENTINEL_PLIST], { stdio: "ignore" });
172
- const load = spawnSync("launchctl", ["load", "-w", SENTINEL_PLIST]);
173
- if (load.status !== 0) {
174
- console.warn("[sentinel] launchctl load failed — daemon may need manual start");
175
- } else {
170
+ // Modern launchctl API (bootstrap/bootout). Mirrors scheduled.mjs so
171
+ // both daemons share one mental model. Idempotent: bootout-before-
172
+ // bootstrap absorbs prior loads regardless of which API installed them.
173
+ try { await execFileP("launchctl", ["bootout", "system", SENTINEL_PLIST]); } catch { /* not loaded */ }
174
+ try {
175
+ await execFileP("launchctl", ["bootstrap", "system", SENTINEL_PLIST]);
176
176
  console.error("[sentinel] Daemon loaded via launchctl");
177
+ } catch (e) {
178
+ console.warn("[sentinel] launchctl bootstrap failed — daemon may need manual start:", e.message);
177
179
  }
178
180
  }
179
181
  } else {
@@ -212,7 +214,8 @@ export async function uninstallSentinel({ dryRun = false } = {}) {
212
214
  if (process.platform === "darwin") {
213
215
  if (await exists(SENTINEL_PLIST)) {
214
216
  if (!dryRun) {
215
- spawnSync("launchctl", ["unload", SENTINEL_PLIST], { stdio: "ignore" });
217
+ // Modern launchctl API; mirrors scheduled.mjs's uninstallScheduled.
218
+ try { await execFileP("launchctl", ["bootout", "system", SENTINEL_PLIST]); } catch { /* not loaded */ }
216
219
  await fs.unlink(SENTINEL_PLIST);
217
220
  console.error(`[sentinel] Removed: ${SENTINEL_PLIST}`);
218
221
  } else {