inplan 0.3.12 → 0.3.13

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.
@@ -1203,6 +1203,9 @@ function startCloudSignIn(cloudBase, timeoutMs = 5 * 6e4) {
1203
1203
  });
1204
1204
  });
1205
1205
  }
1206
+ function aboutPanelOptions(inplanVersion, electronVersion) {
1207
+ return { applicationName: "inplan", applicationVersion: inplanVersion?.trim() || "dev", version: `Electron ${electronVersion}` };
1208
+ }
1206
1209
  const __dirname$1 = node_path.dirname(node_url.fileURLToPath(require("url").pathToFileURL(__filename).href));
1207
1210
  widenConnectAttemptBudget();
1208
1211
  registerPluginScheme();
@@ -1214,7 +1217,7 @@ const pluginToken = () => runCli(["token"], void 0, 15e3).then((r) => {
1214
1217
  }
1215
1218
  });
1216
1219
  electron.app.setName("inplan");
1217
- electron.app.setAboutPanelOptions({ applicationName: "inplan" });
1220
+ electron.app.setAboutPanelOptions(aboutPanelOptions("0.3.13", process.versions.electron));
1218
1221
  process.on("uncaughtException", (err) => {
1219
1222
  process.stderr.write(`[inplan] uncaught exception: ${err instanceof Error ? err.stack ?? err.message : String(err)}
1220
1223
  `);
@@ -47,7 +47,11 @@ body {
47
47
  .ap-spinner { width: 28px; height: 28px; border: 3px solid var(--line-strong); border-top-color: var(--accent); border-radius: 50%; animation: ap-spin 0.8s linear infinite; }
48
48
  .ap-spinner-sm { width: 14px; height: 14px; border: 2px solid var(--line-strong); border-top-color: var(--accent); border-radius: 50%; animation: ap-spin 0.8s linear infinite; flex-shrink: 0; }
49
49
  @keyframes ap-spin { to { transform: rotate(360deg); } }
50
- @media (prefers-reduced-motion: reduce) { .ap-spinner { animation-duration: 2.4s; } }
50
+ /* Restart: while the replacement launches (up to ~35s) the button must visibly be busy, not look clickable. */
51
+ .ap-restart { display: inline-flex; align-items: center; gap: 6px; }
52
+ .ap-restart:disabled { opacity: 0.6; cursor: progress; }
53
+ .ap-restart .ap-spinner-sm { border-color: color-mix(in srgb, currentColor 40%, transparent); border-top-color: currentColor; }
54
+ @media (prefers-reduced-motion: reduce) { .ap-spinner, .ap-spinner-sm { animation-duration: 2.4s; } }
51
55
 
52
56
  /* top bar */
53
57
  .ap-topbar { display: flex; align-items: center; gap: 8px; padding: 7px 12px; border-bottom: 1px solid var(--line); background: var(--bg); }
@@ -43735,6 +43735,7 @@ var EN = {
43735
43735
  "banner.restartFailed": "Could not reopen inplan. This window is still open; try Restart again.",
43736
43736
  "banner.restartToApply": "— restart inplan to apply.",
43737
43737
  "banner.restart": "Restart",
43738
+ "banner.restarting": "Restarting…",
43738
43739
  "banner.newVersion": "⬆️ A new version is available",
43739
43740
  "banner.updateFailed": "Update failed — try again.",
43740
43741
  "banner.updating": "Updating…",
@@ -47641,8 +47642,9 @@ function App(props = {}) {
47641
47642
  /* @__PURE__ */ jsxRuntimeExports.jsx(
47642
47643
  "button",
47643
47644
  {
47644
- className: "ap-primary",
47645
+ className: "ap-primary ap-restart",
47645
47646
  disabled: restartState === "running",
47647
+ "aria-busy": restartState === "running",
47646
47648
  onClick: async () => {
47647
47649
  setRestartState("running");
47648
47650
  try {
@@ -47654,7 +47656,10 @@ function App(props = {}) {
47654
47656
  }
47655
47657
  setRestartState("failed");
47656
47658
  },
47657
- children: t2("banner.restart")
47659
+ children: restartState === "running" ? /* @__PURE__ */ jsxRuntimeExports.jsxs(jsxRuntimeExports.Fragment, { children: [
47660
+ /* @__PURE__ */ jsxRuntimeExports.jsx("span", { className: "ap-spinner-sm", "aria-hidden": "true" }),
47661
+ t2("banner.restarting")
47662
+ ] }) : t2("banner.restart")
47658
47663
  }
47659
47664
  )
47660
47665
  ] }) : /* @__PURE__ */ jsxRuntimeExports.jsxs(jsxRuntimeExports.Fragment, { children: [
@@ -21,8 +21,8 @@
21
21
  content="default-src 'self'; style-src 'self' 'unsafe-inline'; script-src 'self' inplan-plugin:; img-src 'self' file: https:; connect-src 'self' inplan-plugin: ws://127.0.0.1:* ws://localhost:*; frame-src https://inplan.ai http://127.0.0.1:* http://localhost:*"
22
22
  />
23
23
  <title>inplan</title>
24
- <script type="module" crossorigin src="./assets/index-CK4CX-zj.js"></script>
25
- <link rel="stylesheet" crossorigin href="./assets/index-CD5LIK6f.css">
24
+ <script type="module" crossorigin src="./assets/index-DSPgh74Z.js"></script>
25
+ <link rel="stylesheet" crossorigin href="./assets/index-CNr1ZwEx.css">
26
26
  </head>
27
27
  <body>
28
28
  <div id="root"></div>
package/bin/cli.js CHANGED
@@ -1,12 +1,12 @@
1
1
  #!/usr/bin/env node
2
2
 
3
3
  // src/cli.ts
4
- import { execFileSync as execFileSync2, spawn as spawn3, spawnSync } from "child_process";
4
+ import { spawn as spawn3, spawnSync } from "child_process";
5
5
  import { createHash as createHash4, randomBytes } from "crypto";
6
6
  import { createRequire } from "module";
7
- import { appendFileSync as appendFileSync3, copyFileSync, existsSync as existsSync11, mkdirSync as mkdirSync10, readdirSync as readdirSync2, readFileSync as readFileSync11, realpathSync, renameSync as renameSync4, statSync as statSync5, writeFileSync as writeFileSync10 } from "fs";
7
+ import { appendFileSync as appendFileSync3, copyFileSync, existsSync as existsSync12, mkdirSync as mkdirSync10, readdirSync as readdirSync2, readFileSync as readFileSync11, realpathSync, renameSync as renameSync4, statSync as statSync5, writeFileSync as writeFileSync11 } from "fs";
8
8
  import { homedir as homedir7 } from "os";
9
- import { basename as basename3, dirname as dirname11, extname, isAbsolute as isAbsolute2, join as join10, relative as relative4, resolve as resolve3 } from "path";
9
+ import { basename as basename3, dirname as dirname11, extname, isAbsolute as isAbsolute2, join as join11, relative as relative4, resolve as resolve3 } from "path";
10
10
  import { fileURLToPath as fileURLToPath2, pathToFileURL as pathToFileURL2 } from "url";
11
11
 
12
12
  // ../core/dist/chunk-SJGNSLZ2.js
@@ -2845,6 +2845,42 @@ function trackCli(event, enabled, props) {
2845
2845
  });
2846
2846
  }
2847
2847
 
2848
+ // src/electronRuntime.ts
2849
+ import { execFileSync as execFileSync2 } from "child_process";
2850
+ import { existsSync as existsSync11, writeFileSync as writeFileSync10 } from "fs";
2851
+ import { join as join10 } from "path";
2852
+ function electronDistRel(platform) {
2853
+ if (platform === "win32") return "electron.exe";
2854
+ if (platform === "darwin") return join10("Electron.app", "Contents", "MacOS", "Electron");
2855
+ return "electron";
2856
+ }
2857
+ function electronBinaryOnDisk(pkgDir, platform = process.platform) {
2858
+ const rel = electronDistRel(platform);
2859
+ const bin = join10(pkgDir, "dist", rel);
2860
+ if (!existsSync11(bin)) return null;
2861
+ try {
2862
+ const pathFile = join10(pkgDir, "path.txt");
2863
+ if (!existsSync11(pathFile)) writeFileSync10(pathFile, rel);
2864
+ } catch {
2865
+ }
2866
+ return bin;
2867
+ }
2868
+ function resolveElectronBinary(pkgDir, env = process.env, platform = process.platform) {
2869
+ if (env.ELECTRON_OVERRIDE_DIST_PATH) {
2870
+ const bin = join10(env.ELECTRON_OVERRIDE_DIST_PATH, electronDistRel(platform));
2871
+ return existsSync11(bin) ? bin : null;
2872
+ }
2873
+ return electronBinaryOnDisk(pkgDir, platform);
2874
+ }
2875
+ var ELECTRON_INSTALL_TIMEOUT_MS = 18e4;
2876
+ function electronInstallTimeoutMs(env = process.env) {
2877
+ const v = Number(env.INPLAN_ELECTRON_INSTALL_TIMEOUT_MS);
2878
+ return Number.isFinite(v) && v > 0 ? v : ELECTRON_INSTALL_TIMEOUT_MS;
2879
+ }
2880
+ function runElectronInstaller(pkgDir, nodeExe = process.execPath, env = process.env, timeoutMs = electronInstallTimeoutMs(env)) {
2881
+ execFileSync2(nodeExe, [join10(pkgDir, "install.js")], { cwd: pkgDir, stdio: ["ignore", 2, 2], env, timeout: timeoutMs });
2882
+ }
2883
+
2848
2884
  // src/cli.ts
2849
2885
  var VERSION = versionFromModule(import.meta.url);
2850
2886
  function output(obj) {
@@ -2863,31 +2899,17 @@ function getFlag(args, name) {
2863
2899
  function hasFlag(args, name) {
2864
2900
  return args.includes(`--${name}`);
2865
2901
  }
2866
- function electronDistRel(platform) {
2867
- if (platform === "win32") return "electron.exe";
2868
- if (platform === "darwin") return join10("Electron.app", "Contents", "MacOS", "Electron");
2869
- return "electron";
2870
- }
2871
- function electronBinaryFromDisk(reqUrl) {
2902
+ function electronPkgDir(reqUrl) {
2872
2903
  try {
2873
- const pkgDir = dirname11(createRequire(reqUrl).resolve("electron/package.json"));
2874
- const rel = electronDistRel(process.platform);
2875
- const bin = join10(pkgDir, "dist", rel);
2876
- if (!existsSync11(bin)) return null;
2877
- try {
2878
- const pathFile = join10(pkgDir, "path.txt");
2879
- if (!existsSync11(pathFile)) writeFileSync10(pathFile, rel);
2880
- } catch {
2881
- }
2882
- return bin;
2904
+ return dirname11(createRequire(reqUrl).resolve("electron/package.json"));
2883
2905
  } catch {
2884
2906
  return null;
2885
2907
  }
2886
2908
  }
2887
2909
  function electronCacheDir() {
2888
- if (process.platform === "win32") return join10(process.env.LOCALAPPDATA ?? join10(homedir7(), "AppData", "Local"), "electron", "Cache");
2889
- if (process.platform === "darwin") return join10(homedir7(), "Library", "Caches", "electron");
2890
- return join10(process.env.XDG_CACHE_HOME ?? join10(homedir7(), ".cache"), "electron");
2910
+ if (process.platform === "win32") return join11(process.env.LOCALAPPDATA ?? join11(homedir7(), "AppData", "Local"), "electron", "Cache");
2911
+ if (process.platform === "darwin") return join11(homedir7(), "Library", "Caches", "electron");
2912
+ return join11(process.env.XDG_CACHE_HOME ?? join11(homedir7(), ".cache"), "electron");
2891
2913
  }
2892
2914
  function cachedElectronZip(version, platform, arch) {
2893
2915
  const root = electronCacheDir();
@@ -2895,8 +2917,8 @@ function cachedElectronZip(version, platform, arch) {
2895
2917
  try {
2896
2918
  let best = null;
2897
2919
  for (const sub of readdirSync2(root)) {
2898
- const f = join10(root, sub, want);
2899
- if (!existsSync11(f)) continue;
2920
+ const f = join11(root, sub, want);
2921
+ if (!existsSync12(f)) continue;
2900
2922
  const mtime = statSync5(f).mtimeMs;
2901
2923
  if (!best || mtime > best.mtime) best = { file: f, mtime };
2902
2924
  }
@@ -2916,36 +2938,31 @@ function expandArchiveWindows(zipPath, destDir) {
2916
2938
  function autoInstallElectron(reqUrl) {
2917
2939
  if (process.env.INPLAN_NO_ELECTRON_DOWNLOAD === "1") return false;
2918
2940
  try {
2919
- const pkgDir = dirname11(createRequire(reqUrl).resolve("electron/package.json"));
2920
- const installJs = join10(pkgDir, "install.js");
2921
- if (!existsSync11(installJs)) return false;
2922
- process.stderr.write("[inplan] editor runtime missing \u2014 retrying the download \u2026\n");
2923
- execFileSync2(process.execPath, [installJs], { cwd: pkgDir, stdio: "inherit", env: process.env });
2924
- if (electronBinaryFromDisk(reqUrl) !== null) return true;
2941
+ const pkgDir = electronPkgDir(reqUrl);
2942
+ if (!pkgDir || !existsSync12(join11(pkgDir, "install.js"))) return false;
2943
+ process.stderr.write("[inplan] downloading the editor runtime \u2026\n");
2944
+ runElectronInstaller(pkgDir);
2945
+ if (electronBinaryOnDisk(pkgDir) !== null) return true;
2925
2946
  if (process.platform === "win32") {
2926
- const { version } = JSON.parse(readFileSync11(join10(pkgDir, "package.json"), "utf8"));
2947
+ const { version } = JSON.parse(readFileSync11(join11(pkgDir, "package.json"), "utf8"));
2927
2948
  const zip = cachedElectronZip(version, "win32", process.env.npm_config_arch || process.arch);
2928
- if (zip && expandArchiveWindows(zip, join10(pkgDir, "dist"))) {
2929
- writeFileSync10(join10(pkgDir, "path.txt"), "electron.exe");
2949
+ if (zip && expandArchiveWindows(zip, join11(pkgDir, "dist"))) {
2950
+ writeFileSync11(join11(pkgDir, "path.txt"), "electron.exe");
2930
2951
  }
2931
2952
  }
2932
- return electronBinaryFromDisk(reqUrl) !== null;
2953
+ return electronBinaryOnDisk(pkgDir) !== null;
2933
2954
  } catch {
2934
2955
  return false;
2935
2956
  }
2936
2957
  }
2937
2958
  function resolveBundledApp() {
2938
2959
  const here = dirname11(fileURLToPath2(import.meta.url));
2939
- const appMain = join10(here, "..", "app", "main", "index.cjs");
2940
- if (!existsSync11(appMain)) return { appMain: null };
2941
- try {
2942
- const electron = createRequire(import.meta.url)("electron");
2943
- if (typeof electron === "string" && electron && existsSync11(electron)) return { electron, appMain };
2944
- } catch {
2945
- }
2946
- const onDisk = electronBinaryFromDisk(import.meta.url);
2960
+ const appMain = join11(here, "..", "app", "main", "index.cjs");
2961
+ if (!existsSync12(appMain)) return { appMain: null };
2962
+ const pkgDir = electronPkgDir(import.meta.url);
2963
+ const onDisk = pkgDir ? resolveElectronBinary(pkgDir) : null;
2947
2964
  if (onDisk) return { electron: onDisk, appMain };
2948
- return { appMain, error: "Electron's binary isn't installed \u2014 its download was likely blocked (proxy/AV), and path.txt is missing" };
2965
+ return { appMain, error: pkgDir ? "Electron's binary isn't downloaded yet, or its download was blocked (proxy/AV)" : "the electron package isn't installed" };
2949
2966
  }
2950
2967
  function spawnApp(file) {
2951
2968
  const { ELECTRON_RUN_AS_NODE: _runAsNode, ...inherited } = process.env;
@@ -3616,12 +3633,12 @@ async function pendingLoginExit(existing) {
3616
3633
  });
3617
3634
  }
3618
3635
  function stalenessCache() {
3619
- const path = join10(sidecarRoot(), ".update-check.json");
3636
+ const path = join11(sidecarRoot(), ".update-check.json");
3620
3637
  return {
3621
- readCache: () => existsSync11(path) ? readFileSync11(path, "utf8") : null,
3638
+ readCache: () => existsSync12(path) ? readFileSync11(path, "utf8") : null,
3622
3639
  writeCache: (v) => {
3623
3640
  mkdirSync10(dirname11(path), { recursive: true });
3624
- writeFileSync10(path, v);
3641
+ writeFileSync11(path, v);
3625
3642
  }
3626
3643
  };
3627
3644
  }
@@ -3698,13 +3715,13 @@ async function runRemote(cmd, docId, explicitCursor, confirmed, rest, localFile,
3698
3715
  presenceTokenResolver(backend.token, async () => {
3699
3716
  const fresh = await remoteBackend(docId, "cli-agent");
3700
3717
  if (fresh) return fresh;
3701
- if (!existsSync11(authPath())) return null;
3718
+ if (!existsSync12(authPath())) return null;
3702
3719
  throw new Error("transient token refresh failure");
3703
3720
  }),
3704
3721
  model
3705
3722
  );
3706
3723
  try {
3707
- const workFile = join10(sidecarRoot(), "remote", `${docId}.plan.md`);
3724
+ const workFile = join11(sidecarRoot(), "remote", `${docId}.plan.md`);
3708
3725
  const rds = new RemoteDocState(workFile, docId);
3709
3726
  rds.ensureDir();
3710
3727
  let canonical = "";
@@ -3828,7 +3845,7 @@ async function runRemote(cmd, docId, explicitCursor, confirmed, rest, localFile,
3828
3845
  process.stderr.write(`inplan: the doc moved local, but an unpushed edit remains at ${workFile} \u2014 merge it into ${localFile} by hand if you still want it.
3829
3846
  `);
3830
3847
  }
3831
- writeFileSync10(localFile, body2);
3848
+ writeFileSync11(localFile, body2);
3832
3849
  writeStatus(docPaths(localFile).statusPath, { location: "local", originalPath: localFile, lastSyncedHash: hashBody(body2) });
3833
3850
  const pid = spawnApp(localFile);
3834
3851
  output({ status: "moved_local", path: localFile, reopened: pid !== null, ...info });
@@ -3896,7 +3913,7 @@ function doPromote(file, args) {
3896
3913
  process.stderr.write("usage: inplan promote <file> --cloud-doc <docId> [--locator org/repo/path]\n");
3897
3914
  process.exit(64);
3898
3915
  }
3899
- const body2 = existsSync11(file) ? readFileSync11(file, "utf8") : "";
3916
+ const body2 = existsSync12(file) ? readFileSync11(file, "utf8") : "";
3900
3917
  const status = { location: "cloud", cloudDocId, originalPath: file, lastSyncedHash: hashBody(body2) };
3901
3918
  const locator = getFlag(args, "locator");
3902
3919
  if (locator) {
@@ -3941,7 +3958,7 @@ async function doDemote(file, args) {
3941
3958
  return;
3942
3959
  }
3943
3960
  const body2 = choice.use === "hub" ? hubBody : await backend.store.loadDoc();
3944
- writeFileSync10(dest, body2);
3961
+ writeFileSync11(dest, body2);
3945
3962
  writeStatus(p.statusPath, { location: "local", originalPath: dest, lastSyncedHash: hashBody(body2) });
3946
3963
  output({ status: "demoted", location: "local", path: dest, source: choice.use });
3947
3964
  }
@@ -3977,16 +3994,16 @@ async function doToken() {
3977
3994
  function bundledSkillPath() {
3978
3995
  try {
3979
3996
  const override = process.env.INPLAN_SKILL_SRC;
3980
- if (override) return existsSync11(override) ? override : null;
3981
- const p = join10(dirname11(fileURLToPath2(import.meta.url)), "..", "skill", "SKILL.md");
3982
- return existsSync11(p) ? p : null;
3997
+ if (override) return existsSync12(override) ? override : null;
3998
+ const p = join11(dirname11(fileURLToPath2(import.meta.url)), "..", "skill", "SKILL.md");
3999
+ return existsSync12(p) ? p : null;
3983
4000
  } catch {
3984
4001
  return null;
3985
4002
  }
3986
4003
  }
3987
4004
  function activeDocForCwd(cwd) {
3988
4005
  const root = sidecarRoot();
3989
- if (!existsSync11(root)) return null;
4006
+ if (!existsSync12(root)) return null;
3990
4007
  const real = (p) => {
3991
4008
  try {
3992
4009
  return realpathSync(p);
@@ -3998,13 +4015,13 @@ function activeDocForCwd(cwd) {
3998
4015
  let best = null;
3999
4016
  for (const entry of readdirSync2(root)) {
4000
4017
  try {
4001
- const dir = join10(root, entry);
4002
- const orig = readStatus(join10(dir, "status.json")).originalPath;
4018
+ const dir = join11(root, entry);
4019
+ const orig = readStatus(join11(dir, "status.json")).originalPath;
4003
4020
  if (!orig) continue;
4004
4021
  const rel = relative4(base2, real(orig));
4005
4022
  if (rel === "" || rel.startsWith("..") || isAbsolute2(rel)) continue;
4006
- const logPath = join10(dir, "log.jsonl");
4007
- const mtime = existsSync11(logPath) ? statSync5(logPath).mtimeMs : 0;
4023
+ const logPath = join11(dir, "log.jsonl");
4024
+ const mtime = existsSync12(logPath) ? statSync5(logPath).mtimeMs : 0;
4008
4025
  if (!best || mtime > best.mtime) best = { file: resolve3(orig), mtime };
4009
4026
  } catch {
4010
4027
  }
@@ -4013,7 +4030,7 @@ function activeDocForCwd(cwd) {
4013
4030
  }
4014
4031
  function relayCursorPath(sessionKey) {
4015
4032
  const id = createHash4("sha1").update(sessionKey).digest("hex").slice(0, 16);
4016
- return join10(sidecarRoot(), ".relay-cursors", `${id}.json`);
4033
+ return join11(sidecarRoot(), ".relay-cursors", `${id}.json`);
4017
4034
  }
4018
4035
  function readRelayCursor(sessionKey) {
4019
4036
  try {
@@ -4027,7 +4044,7 @@ function writeRelayCursor(sessionKey, sent) {
4027
4044
  try {
4028
4045
  const p = relayCursorPath(sessionKey);
4029
4046
  mkdirSync10(dirname11(p), { recursive: true });
4030
- writeFileSync10(p, JSON.stringify({ sent }) + "\n");
4047
+ writeFileSync11(p, JSON.stringify({ sent }) + "\n");
4031
4048
  } catch {
4032
4049
  }
4033
4050
  }
@@ -4080,7 +4097,7 @@ function notesFromHook(kind, stdin, argv) {
4080
4097
  const p = parse2(stdin);
4081
4098
  const transcript = str(p.transcript_path);
4082
4099
  const sessionKey = str(p.session_id) || transcript;
4083
- const blocks = transcript && existsSync11(transcript) && sessionKey ? transcriptTextBlocks(transcript) : [];
4100
+ const blocks = transcript && existsSync12(transcript) && sessionKey ? transcriptTextBlocks(transcript) : [];
4084
4101
  if (blocks.length > 0) {
4085
4102
  const sent = readRelayCursor(sessionKey);
4086
4103
  for (let i = Math.max(0, sent); i < blocks.length; i++) notes.push(blocks[i]);
@@ -4152,19 +4169,19 @@ async function doRelay(args) {
4152
4169
  function skillTargets() {
4153
4170
  const home = homedir7();
4154
4171
  return [
4155
- { name: "Claude Code", root: join10(home, ".claude"), target: join10(home, ".claude", "skills", "inplan", "SKILL.md") },
4156
- { name: "Pi", root: join10(home, ".pi", "agent"), target: join10(home, ".pi", "agent", "skills", "inplan", "SKILL.md") },
4157
- { name: "Codex", root: join10(home, ".codex"), target: join10(home, ".codex", "skills", "inplan", "SKILL.md") }
4172
+ { name: "Claude Code", root: join11(home, ".claude"), target: join11(home, ".claude", "skills", "inplan", "SKILL.md") },
4173
+ { name: "Pi", root: join11(home, ".pi", "agent"), target: join11(home, ".pi", "agent", "skills", "inplan", "SKILL.md") },
4174
+ { name: "Codex", root: join11(home, ".codex"), target: join11(home, ".codex", "skills", "inplan", "SKILL.md") }
4158
4175
  ];
4159
4176
  }
4160
4177
  var SKILL_ALLOW = ["Bash(inplan *)", "Edit(**/*.plan.md)", "Read(~/.inplan/**)", "Edit(~/.inplan/**)"];
4161
4178
  var SKILL_ALLOW_OBSOLETE = ["Write(**/*.plan.md)", "Write(~/.inplan/**)"];
4162
4179
  var SKILL_DIRS = ["~/.inplan/"];
4163
4180
  function grantClaudePermissions(claudeRoot) {
4164
- const settingsPath = join10(claudeRoot, "settings.json");
4181
+ const settingsPath = join11(claudeRoot, "settings.json");
4165
4182
  let settings = {};
4166
4183
  try {
4167
- if (existsSync11(settingsPath)) {
4184
+ if (existsSync12(settingsPath)) {
4168
4185
  const parsed = JSON.parse(readFileSync11(settingsPath, "utf8"));
4169
4186
  if (!parsed || typeof parsed !== "object" || Array.isArray(parsed)) return false;
4170
4187
  settings = parsed;
@@ -4198,7 +4215,7 @@ function grantClaudePermissions(claudeRoot) {
4198
4215
  settings.permissions = perms;
4199
4216
  try {
4200
4217
  const tmp = settingsPath + ".tmp";
4201
- writeFileSync10(tmp, JSON.stringify(settings, null, 2) + "\n");
4218
+ writeFileSync11(tmp, JSON.stringify(settings, null, 2) + "\n");
4202
4219
  renameSync4(tmp, settingsPath);
4203
4220
  } catch {
4204
4221
  return false;
@@ -4244,7 +4261,7 @@ function mergeRelayHooks(settings, entries) {
4244
4261
  }
4245
4262
  function readJsonObject(path) {
4246
4263
  try {
4247
- if (!existsSync11(path)) return {};
4264
+ if (!existsSync12(path)) return {};
4248
4265
  const parsed = JSON.parse(readFileSync11(path, "utf8"));
4249
4266
  if (!parsed || typeof parsed !== "object" || Array.isArray(parsed)) return null;
4250
4267
  return parsed;
@@ -4256,7 +4273,7 @@ function writeJsonAtomic(path, value) {
4256
4273
  try {
4257
4274
  mkdirSync10(dirname11(path), { recursive: true });
4258
4275
  const tmp = path + ".tmp";
4259
- writeFileSync10(tmp, JSON.stringify(value, null, 2) + "\n");
4276
+ writeFileSync11(tmp, JSON.stringify(value, null, 2) + "\n");
4260
4277
  renameSync4(tmp, path);
4261
4278
  return true;
4262
4279
  } catch {
@@ -4264,13 +4281,13 @@ function writeJsonAtomic(path, value) {
4264
4281
  }
4265
4282
  }
4266
4283
  function installClaudeHooks(claudeRoot) {
4267
- const path = join10(claudeRoot, "settings.json");
4284
+ const path = join11(claudeRoot, "settings.json");
4268
4285
  const settings = readJsonObject(path);
4269
4286
  if (!settings || !mergeRelayHooks(settings, CLAUDE_RELAY_HOOKS)) return false;
4270
4287
  return writeJsonAtomic(path, settings);
4271
4288
  }
4272
4289
  function installCodexHooks(codexRoot) {
4273
- const path = join10(codexRoot, "hooks.json");
4290
+ const path = join11(codexRoot, "hooks.json");
4274
4291
  const cfg = readJsonObject(path);
4275
4292
  if (!cfg || !mergeRelayHooks(cfg, CODEX_RELAY_HOOKS)) return false;
4276
4293
  return writeJsonAtomic(path, cfg);
@@ -4320,16 +4337,16 @@ export default function (pi) {
4320
4337
  }
4321
4338
  `;
4322
4339
  function installPiRelayExtension(piAgentRoot) {
4323
- const path = join10(piAgentRoot, "extensions", "inplan-relay.ts");
4340
+ const path = join11(piAgentRoot, "extensions", "inplan-relay.ts");
4324
4341
  try {
4325
- if (existsSync11(path)) {
4342
+ if (existsSync12(path)) {
4326
4343
  const cur = readFileSync11(path, "utf8");
4327
4344
  if (cur === PI_RELAY_EXTENSION) return false;
4328
4345
  if (!cur.startsWith(PI_RELAY_MARKER)) return false;
4329
4346
  }
4330
4347
  mkdirSync10(dirname11(path), { recursive: true });
4331
4348
  const tmp = path + ".tmp";
4332
- writeFileSync10(tmp, PI_RELAY_EXTENSION);
4349
+ writeFileSync11(tmp, PI_RELAY_EXTENSION);
4333
4350
  renameSync4(tmp, path);
4334
4351
  return true;
4335
4352
  } catch {
@@ -4350,8 +4367,8 @@ function doInstallSkill(args) {
4350
4367
  const installed = [];
4351
4368
  for (const a of skillTargets()) {
4352
4369
  try {
4353
- if (!existsSync11(a.root)) continue;
4354
- if (!existsSync11(a.target)) {
4370
+ if (!existsSync12(a.root)) continue;
4371
+ if (!existsSync12(a.target)) {
4355
4372
  mkdirSync10(dirname11(a.target), { recursive: true });
4356
4373
  copyFileSync(src, a.target);
4357
4374
  installed.push(a.name);
@@ -4359,19 +4376,19 @@ function doInstallSkill(args) {
4359
4376
  `);
4360
4377
  }
4361
4378
  if (a.name === "Claude Code" && grantClaudePermissions(a.root)) {
4362
- process.stderr.write(`inplan: granted scoped auto-approval (plan files + ~/.inplan + inplan CLI) in ${join10(a.root, "settings.json")}.
4379
+ process.stderr.write(`inplan: granted scoped auto-approval (plan files + ~/.inplan + inplan CLI) in ${join11(a.root, "settings.json")}.
4363
4380
  `);
4364
4381
  }
4365
4382
  if (a.name === "Claude Code" && installClaudeHooks(a.root)) {
4366
- process.stderr.write(`inplan: configured the agent-console relay hooks in ${join10(a.root, "settings.json")}.
4383
+ process.stderr.write(`inplan: configured the agent-console relay hooks in ${join11(a.root, "settings.json")}.
4367
4384
  `);
4368
4385
  }
4369
4386
  if (a.name === "Codex" && installCodexHooks(a.root)) {
4370
- process.stderr.write(`inplan: configured the agent-console relay hooks in ${join10(a.root, "hooks.json")}.
4387
+ process.stderr.write(`inplan: configured the agent-console relay hooks in ${join11(a.root, "hooks.json")}.
4371
4388
  `);
4372
4389
  }
4373
4390
  if (a.name === "Pi" && installPiRelayExtension(a.root)) {
4374
- process.stderr.write(`inplan: installed the agent-console relay extension in ${join10(a.root, "extensions", "inplan-relay.ts")}.
4391
+ process.stderr.write(`inplan: installed the agent-console relay extension in ${join11(a.root, "extensions", "inplan-relay.ts")}.
4375
4392
  `);
4376
4393
  }
4377
4394
  } catch {
@@ -4405,7 +4422,7 @@ async function doUpload(file, args) {
4405
4422
  process.exit(1);
4406
4423
  }
4407
4424
  const org = orgOf(pick);
4408
- const body2 = existsSync11(file) ? readFileSync11(file, "utf8") : "";
4425
+ const body2 = existsSync12(file) ? readFileSync11(file, "utf8") : "";
4409
4426
  const prov = gitProvenance(file);
4410
4427
  const repo = getFlag(args, "repo") ?? prov.repo;
4411
4428
  const path = getFlag(args, "path") ?? prov.path;
@@ -4460,7 +4477,7 @@ async function doUpload(file, args) {
4460
4477
  "the document changed in the cloud while migrating images (a live session attached first) \u2014 not overwriting it; the local images were not migrated, re-paste them once you're collaborating on this doc in the cloud"
4461
4478
  );
4462
4479
  }
4463
- const onDiskNow = existsSync11(file) ? readFileSync11(file, "utf8") : null;
4480
+ const onDiskNow = existsSync12(file) ? readFileSync11(file, "utf8") : null;
4464
4481
  if (onDiskNow !== null && onDiskNow !== body2) {
4465
4482
  finalBody = onDiskNow;
4466
4483
  throw new Error(
@@ -4468,10 +4485,10 @@ async function doUpload(file, args) {
4468
4485
  );
4469
4486
  }
4470
4487
  try {
4471
- writeFileSync10(file, migrated.body);
4488
+ writeFileSync11(file, migrated.body);
4472
4489
  finalBody = migrated.body;
4473
4490
  } catch (e) {
4474
- finalBody = existsSync11(file) ? readFileSync11(file, "utf8") : body2;
4491
+ finalBody = existsSync12(file) ? readFileSync11(file, "utf8") : body2;
4475
4492
  throw new Error(
4476
4493
  `the cloud copy was updated, but writing it back to the local file failed (${e instanceof Error ? e.message : String(e)}) \u2014 the local file is now stale; open this doc in the editor (or re-run \`inplan wait\`) to pull the migrated body back down`
4477
4494
  );
@@ -4635,7 +4652,7 @@ async function migrateLocalImages(body2, docDir, db, orgId, docId) {
4635
4652
  continue;
4636
4653
  }
4637
4654
  const abs = resolve3(docDir, dest);
4638
- if (!existsSync11(abs)) continue;
4655
+ if (!existsSync12(abs)) continue;
4639
4656
  let absReal;
4640
4657
  try {
4641
4658
  absReal = realpathSync(abs);
@@ -4700,7 +4717,7 @@ function routeFor(file, cmd, args) {
4700
4717
  const status = readStatus(p.statusPath);
4701
4718
  if (status.location !== "cloud" || !status.cloudDocId) return { kind: "local" };
4702
4719
  const docId = status.cloudDocId;
4703
- if (cmd === "signal" || cmd === "message" || !existsSync11(file)) return { kind: "cloud", docId };
4720
+ if (cmd === "signal" || cmd === "message" || !existsSync12(file)) return { kind: "cloud", docId };
4704
4721
  const local = readFileSync11(file, "utf8");
4705
4722
  const diverged = status.lastSyncedHash !== void 0 && hashBody(local) !== status.lastSyncedHash;
4706
4723
  if (!diverged || hasFlag(args, "use-cloud")) return { kind: "cloud", docId };
@@ -4742,9 +4759,15 @@ async function main() {
4742
4759
  await doLogout();
4743
4760
  return;
4744
4761
  }
4762
+ if (cmd === "prepare-editor") {
4763
+ const bundled = resolveBundledApp();
4764
+ const ready = "electron" in bundled || bundled.appMain !== null && autoInstallElectron(import.meta.url);
4765
+ output({ status: ready ? "ready" : "unavailable" });
4766
+ return;
4767
+ }
4745
4768
  if (cmd === "launch-editor") {
4746
4769
  const target = argv[1] ? resolve3(argv[1]) : "";
4747
- if (!target || !existsSync11(target)) {
4770
+ if (!target || !existsSync12(target)) {
4748
4771
  output({ status: "launch_failed", message: `file not found: ${target || "(none)"}` });
4749
4772
  process.exitCode = 1;
4750
4773
  return;
@@ -4768,6 +4791,7 @@ async function main() {
4768
4791
  output({ status: "update_check", pkg, ...await checkForUpdate({ pkg, current: VERSION }) });
4769
4792
  } else {
4770
4793
  const r = await selfUpdate(pkg);
4794
+ if (r.ok && process.argv[1]) spawnSync(process.execPath, [process.argv[1], "prepare-editor"], { stdio: ["ignore", 2, 2], timeout: electronInstallTimeoutMs() + 3e4, killSignal: "SIGKILL" });
4771
4795
  output({ status: r.ok ? "updated" : "update_failed", pkg, output: r.output });
4772
4796
  }
4773
4797
  return;
@@ -4870,7 +4894,7 @@ async function main() {
4870
4894
  output({ status: "messaged" });
4871
4895
  return;
4872
4896
  }
4873
- if (cmd !== "open" && !existsSync11(file)) {
4897
+ if (cmd !== "open" && !existsSync12(file)) {
4874
4898
  process.stderr.write(`inplan ${cmd}: file not found: ${file}
4875
4899
  `);
4876
4900
  process.exit(1);
@@ -4906,7 +4930,7 @@ async function main() {
4906
4930
  ...question ? { question } : {},
4907
4931
  mayResolve: hasFlag(args, "may-resolve")
4908
4932
  });
4909
- writeFileSync10(file, nextText);
4933
+ writeFileSync11(file, nextText);
4910
4934
  const p = docPaths(file);
4911
4935
  mkdirSync10(p.controlDir, { recursive: true });
4912
4936
  await new FsControlChannel(p).append({
package/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "inplan",
3
- "version": "0.3.12",
3
+ "version": "0.3.13",
4
4
  "description": "inplan — a Markdown editor for human ⇄ coding-agent planning. CLI + desktop editor.",
5
5
  "license": "AGPL-3.0-or-later",
6
6
  "repository": {