inplan 0.1.14 → 0.1.15

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/app/main/index.js CHANGED
@@ -515,6 +515,8 @@ class Session {
515
515
  complete(content) {
516
516
  writeFileSync$1(this.paths.file, content);
517
517
  writeFileSync$1(this.paths.canonicalPath, content);
518
+ this.pendingDirty = false;
519
+ this.pendingContent = content;
518
520
  }
519
521
  /** The parked Review-mode proposal, if one is pending (the file exists ⇔ undecided). */
520
522
  pendingProposal() {
@@ -1038,6 +1040,7 @@ async function refreshPluginAndView(file) {
1038
1040
  else win.webContents.send("doc:navigated", session.load());
1039
1041
  }
1040
1042
  function quitNow(reason) {
1043
+ if (session?.hasUnsaved) session.complete(session.pending);
1041
1044
  if (quitFallbackTimer) {
1042
1045
  clearTimeout(quitFallbackTimer);
1043
1046
  quitFallbackTimer = null;
@@ -1224,7 +1227,7 @@ ${body.replace(/\s*$/, "")}
1224
1227
  }
1225
1228
  });
1226
1229
  ipcMain.handle("app:quit", (_e, content, opts) => {
1227
- if (opts.save) session?.complete(content);
1230
+ session?.complete(content);
1228
1231
  if (opts.startBuild && session) session.setSettings({ ...session.getSettings(), agentMode: "implementation" });
1229
1232
  quitNow(opts.startBuild ? "completed" : "window_closed");
1230
1233
  });
@@ -43227,12 +43227,12 @@ function addSpanComment(doc2, selectedText, fields, span) {
43227
43227
  if (!range) return null;
43228
43228
  const id2 = genId(takenIds(doc2));
43229
43229
  const body = wrapSpanWithComment(doc2.body, range.start, range.end, id2);
43230
- const comment2 = { id: id2, author: fields.author, date: nowIso(), resolved: false, text: fields.text, ...fields.question ? { question: fields.question } : {} };
43230
+ const comment2 = { id: id2, author: fields.author, date: nowIso(), resolved: false, text: fields.text, ...fields.question ? { question: fields.question } : {}, ...fields.agent === false ? { agent: false } : {} };
43231
43231
  return { doc: { body, comments: [...doc2.comments, comment2] }, id: id2 };
43232
43232
  }
43233
43233
  function addDocComment(doc2, fields) {
43234
43234
  const id2 = genId(takenIds(doc2));
43235
- const comment2 = { id: id2, anchor: "doc", author: fields.author, date: nowIso(), resolved: false, text: fields.text, ...fields.question ? { question: fields.question } : {} };
43235
+ const comment2 = { id: id2, anchor: "doc", author: fields.author, date: nowIso(), resolved: false, text: fields.text, ...fields.question ? { question: fields.question } : {}, ...fields.agent === false ? { agent: false } : {} };
43236
43236
  return { doc: { ...doc2, comments: [...doc2.comments, comment2] }, id: id2 };
43237
43237
  }
43238
43238
  function addReply(doc2, parentId, text2, author) {
@@ -43468,9 +43468,7 @@ var EN = {
43468
43468
  "topbar.finishTurn": "Finish turn",
43469
43469
  "topbar.finishTurnTitle": "Finish turn — hand off to the agent",
43470
43470
  "quit.title": "Do you want to quit?",
43471
- "quit.save": "Save {file}",
43472
43471
  "quit.startBuild": "Switch agent to build mode",
43473
- "quit.thisDoc": "this document",
43474
43472
  "quit.quit": "Quit",
43475
43473
  "quit.cancel": "Cancel",
43476
43474
  "topbar.noAgent": "Connect an agent (open this doc with a local or cloud agent) to use this",
@@ -43505,6 +43503,14 @@ var EN = {
43505
43503
  "onboarding.doc.body": "With nothing selected, the menu reads “Comment on Doc” and posts a note about the whole plan. Try adding one.",
43506
43504
  "onboarding.answer.title": "Answer the agent",
43507
43505
  "onboarding.answer.body": "The agent asked a question in the comments. Pick an option and click Answer.",
43506
+ "onboarding.layout.title": "Arrange the panes",
43507
+ "onboarding.layout.body": "These buttons show one, two, or three panes — the preview, the Markdown source, and the comments. Switch the layout now to see them.",
43508
+ "onboarding.source.title": "Edit the Markdown source",
43509
+ "onboarding.source.body": "The source pane holds the raw Markdown. Type a change there and the preview updates live. Try editing a line.",
43510
+ "onboarding.movedoc.title": "Split off a new document",
43511
+ "onboarding.movedoc.body": "As a plan grows, select a section, right-click, and choose “Move to New Doc” to break it into its own linked document. (Just a heads-up — no need to do it now.)",
43512
+ "onboarding.finishturn.title": "Hand the turn back",
43513
+ "onboarding.finishturn.body": "When you're done editing, the paper-plane button finishes your turn and hands control to the agent so it can revise. (Nothing is sent during this tour.)",
43508
43514
  "onboarding.finish.title": "You're all set 🎉",
43509
43515
  "onboarding.finish.body": "That's the loop: comment, answer, and let the agent revise. Ready to open your plan?",
43510
43516
  // pane tabs + splitter
@@ -43552,6 +43558,9 @@ var EN = {
43552
43558
  "composer.placeholder": "Add a comment… ({mod}+Enter to submit)",
43553
43559
  "composer.comment": "Comment",
43554
43560
  "composer.cancel": "cancel",
43561
+ "composer.audience": "Comment audience",
43562
+ "composer.talkToAgent": "Talk to the agent",
43563
+ "composer.leaveMemo": "Leave a memo",
43555
43564
  // agent connection indicator
43556
43565
  "agent.connectCloud": "Connect a cloud agent",
43557
43566
  "agent.waitLocal": "Wait for my local agent",
@@ -43616,9 +43625,14 @@ var EN = {
43616
43625
  "banner.reviewNext": "Review next",
43617
43626
  "banner.acceptAll": "Accept all",
43618
43627
  "banner.rejectAll": "Reject all",
43628
+ "banner.allChanges": "accept or reject all changes",
43629
+ "banner.allAccepted": "All changes accepted — click to reject all",
43630
+ "banner.allRejected": "All changes rejected — click to accept all",
43631
+ "banner.allMixed": "Some changes accepted — click to accept all",
43619
43632
  "banner.apply": "Apply",
43620
43633
  "banner.laterLower": "later",
43621
43634
  "banner.locked": "— locked while the agent works; finish handing back to act",
43635
+ "banner.readOnly": "This document is archived — view and download only. Reactivate it to edit.",
43622
43636
  // find / replace bar
43623
43637
  "find.toggleReplace": "toggle replace",
43624
43638
  "find.replace": "Replace",
@@ -43809,6 +43823,57 @@ function resolveDocPath(basePath, href) {
43809
43823
  }
43810
43824
  var ua = typeof navigator !== "undefined" && (navigator.userAgent || navigator.platform) || "";
43811
43825
  var MOD_KEY = /mac/i.test(ua) ? "⌘" : "Ctrl";
43826
+ function Glyph({ children }) {
43827
+ return /* @__PURE__ */ jsxRuntimeExports.jsx("svg", { viewBox: "0 0 24 24", fill: "none", stroke: "currentColor", strokeWidth: 2, strokeLinecap: "round", strokeLinejoin: "round", "aria-hidden": "true", focusable: "false", children });
43828
+ }
43829
+ var IconBack = () => /* @__PURE__ */ jsxRuntimeExports.jsx(Glyph, { children: /* @__PURE__ */ jsxRuntimeExports.jsx("polyline", { points: "15 18 9 12 15 6" }) });
43830
+ var IconForward = () => /* @__PURE__ */ jsxRuntimeExports.jsx(Glyph, { children: /* @__PURE__ */ jsxRuntimeExports.jsx("polyline", { points: "9 18 15 12 9 6" }) });
43831
+ var IconUp = () => /* @__PURE__ */ jsxRuntimeExports.jsx(Glyph, { children: /* @__PURE__ */ jsxRuntimeExports.jsx("polyline", { points: "18 15 12 9 6 15" }) });
43832
+ var IconDown = () => /* @__PURE__ */ jsxRuntimeExports.jsx(Glyph, { children: /* @__PURE__ */ jsxRuntimeExports.jsx("polyline", { points: "6 9 12 15 18 9" }) });
43833
+ var IconZoomOut = () => /* @__PURE__ */ jsxRuntimeExports.jsx(Glyph, { children: /* @__PURE__ */ jsxRuntimeExports.jsx("line", { x1: "5", y1: "12", x2: "19", y2: "12" }) });
43834
+ var IconZoomIn = () => /* @__PURE__ */ jsxRuntimeExports.jsxs(Glyph, { children: [
43835
+ /* @__PURE__ */ jsxRuntimeExports.jsx("line", { x1: "12", y1: "5", x2: "12", y2: "19" }),
43836
+ /* @__PURE__ */ jsxRuntimeExports.jsx("line", { x1: "5", y1: "12", x2: "19", y2: "12" })
43837
+ ] });
43838
+ var IconFind = () => /* @__PURE__ */ jsxRuntimeExports.jsxs(Glyph, { children: [
43839
+ /* @__PURE__ */ jsxRuntimeExports.jsx("circle", { cx: "11", cy: "11", r: "7" }),
43840
+ /* @__PURE__ */ jsxRuntimeExports.jsx("line", { x1: "21", y1: "21", x2: "16.65", y2: "16.65" })
43841
+ ] });
43842
+ var IconComment = () => /* @__PURE__ */ jsxRuntimeExports.jsxs(Glyph, { children: [
43843
+ /* @__PURE__ */ jsxRuntimeExports.jsx("path", { d: "M21 15a2 2 0 0 1-2 2H7l-4 4V5a2 2 0 0 1 2-2h14a2 2 0 0 1 2 2z" }),
43844
+ /* @__PURE__ */ jsxRuntimeExports.jsx("line", { x1: "12", y1: "7", x2: "12", y2: "13" }),
43845
+ /* @__PURE__ */ jsxRuntimeExports.jsx("line", { x1: "9", y1: "10", x2: "15", y2: "10" })
43846
+ ] });
43847
+ var IconMemo = () => /* @__PURE__ */ jsxRuntimeExports.jsxs(Glyph, { children: [
43848
+ /* @__PURE__ */ jsxRuntimeExports.jsx("path", { d: "M14 3H6a2 2 0 0 0-2 2v14a2 2 0 0 0 2 2h12a2 2 0 0 0 2-2V9z" }),
43849
+ /* @__PURE__ */ jsxRuntimeExports.jsx("polyline", { points: "14 3 14 9 20 9" }),
43850
+ /* @__PURE__ */ jsxRuntimeExports.jsx("line", { x1: "8", y1: "13", x2: "16", y2: "13" }),
43851
+ /* @__PURE__ */ jsxRuntimeExports.jsx("line", { x1: "8", y1: "17", x2: "13", y2: "17" })
43852
+ ] });
43853
+ var IconSave = () => /* @__PURE__ */ jsxRuntimeExports.jsxs(Glyph, { children: [
43854
+ /* @__PURE__ */ jsxRuntimeExports.jsx("path", { d: "M19 21H5a2 2 0 0 1-2-2V5a2 2 0 0 1 2-2h11l5 5v11a2 2 0 0 1-2 2z" }),
43855
+ /* @__PURE__ */ jsxRuntimeExports.jsx("polyline", { points: "17 21 17 13 7 13 7 21" }),
43856
+ /* @__PURE__ */ jsxRuntimeExports.jsx("polyline", { points: "7 3 7 8 15 8" })
43857
+ ] });
43858
+ var IconFinishTurn = () => /* @__PURE__ */ jsxRuntimeExports.jsxs(Glyph, { children: [
43859
+ /* @__PURE__ */ jsxRuntimeExports.jsx("line", { x1: "22", y1: "2", x2: "11", y2: "13" }),
43860
+ /* @__PURE__ */ jsxRuntimeExports.jsx("polygon", { points: "22 2 15 22 11 13 2 9 22 2" })
43861
+ ] });
43862
+ var IconComplete = () => /* @__PURE__ */ jsxRuntimeExports.jsx(Glyph, { children: /* @__PURE__ */ jsxRuntimeExports.jsx("polyline", { points: "20 6 9 17 4 12" }) });
43863
+ var IconReopen = () => /* @__PURE__ */ jsxRuntimeExports.jsxs(Glyph, { children: [
43864
+ /* @__PURE__ */ jsxRuntimeExports.jsx("polyline", { points: "3 3 3 9 9 9" }),
43865
+ /* @__PURE__ */ jsxRuntimeExports.jsx("path", { d: "M3.5 13a8 8 0 1 0 2.2-7.4L3 9" })
43866
+ ] });
43867
+ var IconRevealArchive = () => /* @__PURE__ */ jsxRuntimeExports.jsxs(Glyph, { children: [
43868
+ /* @__PURE__ */ jsxRuntimeExports.jsx("path", { d: "M4 7c2.6-3.2 13.4-3.2 16 0c-2.6 3.2-13.4 3.2-16 0Z" }),
43869
+ /* @__PURE__ */ jsxRuntimeExports.jsx("circle", { cx: "12", cy: "7", r: "1.6" }),
43870
+ /* @__PURE__ */ jsxRuntimeExports.jsx("rect", { x: "5", y: "13", width: "14", height: "7", rx: "1" }),
43871
+ /* @__PURE__ */ jsxRuntimeExports.jsx("line", { x1: "5", y1: "16", x2: "19", y2: "16" })
43872
+ ] });
43873
+ var IconPencil = () => /* @__PURE__ */ jsxRuntimeExports.jsxs(Glyph, { children: [
43874
+ /* @__PURE__ */ jsxRuntimeExports.jsx("path", { d: "M12 20h9" }),
43875
+ /* @__PURE__ */ jsxRuntimeExports.jsx("path", { d: "M16.5 3.5a2.12 2.12 0 0 1 3 3L7 19l-4 1 1-4Z" })
43876
+ ] });
43812
43877
  function ComposerPopover({
43813
43878
  target,
43814
43879
  pos,
@@ -43818,6 +43883,7 @@ function ComposerPopover({
43818
43883
  }) {
43819
43884
  const t2 = useT();
43820
43885
  const [text2, setText] = reactExports.useState("");
43886
+ const [talkToAgent, setTalkToAgent] = reactExports.useState(true);
43821
43887
  const [p2, setP] = reactExports.useState(pos);
43822
43888
  const box = reactExports.useRef(null);
43823
43889
  const ta2 = reactExports.useRef(null);
@@ -43851,7 +43917,7 @@ function ComposerPopover({
43851
43917
  el2.style.height = `${Math.min(el2.scrollHeight, 8 * 22)}px`;
43852
43918
  };
43853
43919
  const submit = () => {
43854
- if (text2.trim()) onSubmit(text2.trim());
43920
+ if (text2.trim()) onSubmit(text2.trim(), talkToAgent);
43855
43921
  };
43856
43922
  return /* @__PURE__ */ jsxRuntimeExports.jsxs("div", { className: "ap-composer ap-composer-float", ref: box, style: { left: p2.x, top: p2.y, right: "auto" }, children: [
43857
43923
  /* @__PURE__ */ jsxRuntimeExports.jsxs("div", { className: "ap-composer-head", onMouseDown: (e) => drag.current = { dx: e.clientX - p2.x, dy: e.clientY - p2.y }, children: [
@@ -43879,6 +43945,36 @@ function ComposerPopover({
43879
43945
  }
43880
43946
  ),
43881
43947
  /* @__PURE__ */ jsxRuntimeExports.jsxs("div", { className: "ap-row", children: [
43948
+ /* @__PURE__ */ jsxRuntimeExports.jsxs("span", { className: "ap-agent-toggle", role: "radiogroup", "aria-label": t2("composer.audience"), children: [
43949
+ /* @__PURE__ */ jsxRuntimeExports.jsx(
43950
+ "button",
43951
+ {
43952
+ type: "button",
43953
+ className: `ap-agent-opt${talkToAgent ? " active" : ""}`,
43954
+ role: "radio",
43955
+ "aria-checked": talkToAgent,
43956
+ title: t2("composer.talkToAgent"),
43957
+ "aria-label": t2("composer.talkToAgent"),
43958
+ disabled,
43959
+ onClick: () => setTalkToAgent(true),
43960
+ children: /* @__PURE__ */ jsxRuntimeExports.jsx(IconComment, {})
43961
+ }
43962
+ ),
43963
+ /* @__PURE__ */ jsxRuntimeExports.jsx(
43964
+ "button",
43965
+ {
43966
+ type: "button",
43967
+ className: `ap-agent-opt${!talkToAgent ? " active" : ""}`,
43968
+ role: "radio",
43969
+ "aria-checked": !talkToAgent,
43970
+ title: t2("composer.leaveMemo"),
43971
+ "aria-label": t2("composer.leaveMemo"),
43972
+ disabled,
43973
+ onClick: () => setTalkToAgent(false),
43974
+ children: /* @__PURE__ */ jsxRuntimeExports.jsx(IconMemo, {})
43975
+ }
43976
+ )
43977
+ ] }),
43882
43978
  /* @__PURE__ */ jsxRuntimeExports.jsx("button", { onClick: submit, disabled: disabled || !text2.trim(), children: t2("composer.comment") }),
43883
43979
  /* @__PURE__ */ jsxRuntimeExports.jsx("button", { className: "ap-link", onClick: onClose, children: t2("composer.cancel") })
43884
43980
  ] })
@@ -43890,9 +43986,11 @@ function Switch({
43890
43986
  label,
43891
43987
  disabled,
43892
43988
  className,
43893
- ariaLabel
43989
+ ariaLabel,
43990
+ intent
43894
43991
  }) {
43895
- return /* @__PURE__ */ jsxRuntimeExports.jsxs("label", { className: `ap-switch${disabled ? " disabled" : ""}${className ? ` ${className}` : ""}`, children: [
43992
+ const accept = intent === "accept";
43993
+ return /* @__PURE__ */ jsxRuntimeExports.jsxs("label", { className: `ap-switch${accept ? " ap-switch--accept" : ""}${disabled ? " disabled" : ""}${className ? ` ${className}` : ""}`, children: [
43896
43994
  label != null && /* @__PURE__ */ jsxRuntimeExports.jsx("span", { className: "ap-switch-label", children: label }),
43897
43995
  /* @__PURE__ */ jsxRuntimeExports.jsx(
43898
43996
  "input",
@@ -43906,7 +44004,11 @@ function Switch({
43906
44004
  onChange: (e) => onChange(e.target.checked)
43907
44005
  }
43908
44006
  ),
43909
- /* @__PURE__ */ jsxRuntimeExports.jsx("span", { className: "ap-switch-track", "aria-hidden": "true", children: /* @__PURE__ */ jsxRuntimeExports.jsx("span", { className: "ap-switch-thumb" }) })
44007
+ /* @__PURE__ */ jsxRuntimeExports.jsxs("span", { className: "ap-switch-track", "aria-hidden": "true", children: [
44008
+ accept && /* @__PURE__ */ jsxRuntimeExports.jsx("span", { className: "ap-sw-yes", children: "✓" }),
44009
+ accept && /* @__PURE__ */ jsxRuntimeExports.jsx("span", { className: "ap-sw-no", children: "✗" }),
44010
+ /* @__PURE__ */ jsxRuntimeExports.jsx("span", { className: "ap-switch-thumb" })
44011
+ ] })
43910
44012
  ] });
43911
44013
  }
43912
44014
  function ContextMenu({
@@ -44167,7 +44269,9 @@ var SourceEditor = reactExports.forwardRef(function SourceEditor2({ value, edita
44167
44269
  return true;
44168
44270
  }
44169
44271
  }),
44170
- // Plugin-injected binding extensions (e.g. remote cursors).
44272
+ // Plugin-injected binding extensions (e.g. yCollab: live text sync, remote cursors, and —
44273
+ // wrapped at highest precedence by the binding via highestPrecKeymap — the collaborative
44274
+ // Yjs undo/redo keymap, so Mod-z beats basicSetup's native history).
44171
44275
  ...binding ? binding.extensions : []
44172
44276
  ]
44173
44277
  })
@@ -44495,13 +44599,10 @@ function ProfileMenu({
44495
44599
  }
44496
44600
  function QuotaPie({ pct, color }) {
44497
44601
  const deg = Math.round(Math.max(0, Math.min(1, pct)) * 360);
44498
- return /* @__PURE__ */ jsxRuntimeExports.jsx(
44499
- "span",
44500
- {
44501
- className: "ap-agent-pie",
44502
- style: { background: `conic-gradient(${color} ${deg}deg, var(--line) 0)` },
44503
- "aria-hidden": "true"
44504
- }
44602
+ return (
44603
+ // The conic ring carries usage (`color` fills `pct`, `var(--line)` the rest); the inner
44604
+ // core disc is the green "connected" indicator and stays green regardless of usage.
44605
+ /* @__PURE__ */ jsxRuntimeExports.jsx("span", { className: "ap-agent-pie", style: { background: `conic-gradient(${color} ${deg}deg, var(--line) 0)` }, "aria-hidden": "true", children: /* @__PURE__ */ jsxRuntimeExports.jsx("span", { className: "ap-agent-pie-core", "aria-hidden": "true" }) })
44505
44606
  );
44506
44607
  }
44507
44608
  function AgentIndicator({
@@ -44596,51 +44697,6 @@ function AgentIndicator({
44596
44697
  ] })
44597
44698
  ] });
44598
44699
  }
44599
- function Glyph({ children }) {
44600
- return /* @__PURE__ */ jsxRuntimeExports.jsx("svg", { viewBox: "0 0 24 24", fill: "none", stroke: "currentColor", strokeWidth: 2, strokeLinecap: "round", strokeLinejoin: "round", "aria-hidden": "true", focusable: "false", children });
44601
- }
44602
- var IconBack = () => /* @__PURE__ */ jsxRuntimeExports.jsx(Glyph, { children: /* @__PURE__ */ jsxRuntimeExports.jsx("polyline", { points: "15 18 9 12 15 6" }) });
44603
- var IconForward = () => /* @__PURE__ */ jsxRuntimeExports.jsx(Glyph, { children: /* @__PURE__ */ jsxRuntimeExports.jsx("polyline", { points: "9 18 15 12 9 6" }) });
44604
- var IconUp = () => /* @__PURE__ */ jsxRuntimeExports.jsx(Glyph, { children: /* @__PURE__ */ jsxRuntimeExports.jsx("polyline", { points: "18 15 12 9 6 15" }) });
44605
- var IconDown = () => /* @__PURE__ */ jsxRuntimeExports.jsx(Glyph, { children: /* @__PURE__ */ jsxRuntimeExports.jsx("polyline", { points: "6 9 12 15 18 9" }) });
44606
- var IconZoomOut = () => /* @__PURE__ */ jsxRuntimeExports.jsx(Glyph, { children: /* @__PURE__ */ jsxRuntimeExports.jsx("line", { x1: "5", y1: "12", x2: "19", y2: "12" }) });
44607
- var IconZoomIn = () => /* @__PURE__ */ jsxRuntimeExports.jsxs(Glyph, { children: [
44608
- /* @__PURE__ */ jsxRuntimeExports.jsx("line", { x1: "12", y1: "5", x2: "12", y2: "19" }),
44609
- /* @__PURE__ */ jsxRuntimeExports.jsx("line", { x1: "5", y1: "12", x2: "19", y2: "12" })
44610
- ] });
44611
- var IconFind = () => /* @__PURE__ */ jsxRuntimeExports.jsxs(Glyph, { children: [
44612
- /* @__PURE__ */ jsxRuntimeExports.jsx("circle", { cx: "11", cy: "11", r: "7" }),
44613
- /* @__PURE__ */ jsxRuntimeExports.jsx("line", { x1: "21", y1: "21", x2: "16.65", y2: "16.65" })
44614
- ] });
44615
- var IconComment = () => /* @__PURE__ */ jsxRuntimeExports.jsxs(Glyph, { children: [
44616
- /* @__PURE__ */ jsxRuntimeExports.jsx("path", { d: "M21 15a2 2 0 0 1-2 2H7l-4 4V5a2 2 0 0 1 2-2h14a2 2 0 0 1 2 2z" }),
44617
- /* @__PURE__ */ jsxRuntimeExports.jsx("line", { x1: "12", y1: "7", x2: "12", y2: "13" }),
44618
- /* @__PURE__ */ jsxRuntimeExports.jsx("line", { x1: "9", y1: "10", x2: "15", y2: "10" })
44619
- ] });
44620
- var IconSave = () => /* @__PURE__ */ jsxRuntimeExports.jsxs(Glyph, { children: [
44621
- /* @__PURE__ */ jsxRuntimeExports.jsx("path", { d: "M19 21H5a2 2 0 0 1-2-2V5a2 2 0 0 1 2-2h11l5 5v11a2 2 0 0 1-2 2z" }),
44622
- /* @__PURE__ */ jsxRuntimeExports.jsx("polyline", { points: "17 21 17 13 7 13 7 21" }),
44623
- /* @__PURE__ */ jsxRuntimeExports.jsx("polyline", { points: "7 3 7 8 15 8" })
44624
- ] });
44625
- var IconFinishTurn = () => /* @__PURE__ */ jsxRuntimeExports.jsxs(Glyph, { children: [
44626
- /* @__PURE__ */ jsxRuntimeExports.jsx("line", { x1: "22", y1: "2", x2: "11", y2: "13" }),
44627
- /* @__PURE__ */ jsxRuntimeExports.jsx("polygon", { points: "22 2 15 22 11 13 2 9 22 2" })
44628
- ] });
44629
- var IconComplete = () => /* @__PURE__ */ jsxRuntimeExports.jsx(Glyph, { children: /* @__PURE__ */ jsxRuntimeExports.jsx("polyline", { points: "20 6 9 17 4 12" }) });
44630
- var IconReopen = () => /* @__PURE__ */ jsxRuntimeExports.jsxs(Glyph, { children: [
44631
- /* @__PURE__ */ jsxRuntimeExports.jsx("polyline", { points: "3 3 3 9 9 9" }),
44632
- /* @__PURE__ */ jsxRuntimeExports.jsx("path", { d: "M3.5 13a8 8 0 1 0 2.2-7.4L3 9" })
44633
- ] });
44634
- var IconRevealArchive = () => /* @__PURE__ */ jsxRuntimeExports.jsxs(Glyph, { children: [
44635
- /* @__PURE__ */ jsxRuntimeExports.jsx("path", { d: "M4 7c2.6-3.2 13.4-3.2 16 0c-2.6 3.2-13.4 3.2-16 0Z" }),
44636
- /* @__PURE__ */ jsxRuntimeExports.jsx("circle", { cx: "12", cy: "7", r: "1.6" }),
44637
- /* @__PURE__ */ jsxRuntimeExports.jsx("rect", { x: "5", y: "13", width: "14", height: "7", rx: "1" }),
44638
- /* @__PURE__ */ jsxRuntimeExports.jsx("line", { x1: "5", y1: "16", x2: "19", y2: "16" })
44639
- ] });
44640
- var IconPencil = () => /* @__PURE__ */ jsxRuntimeExports.jsxs(Glyph, { children: [
44641
- /* @__PURE__ */ jsxRuntimeExports.jsx("path", { d: "M12 20h9" }),
44642
- /* @__PURE__ */ jsxRuntimeExports.jsx("path", { d: "M16.5 3.5a2.12 2.12 0 0 1 3 3L7 19l-4 1 1-4Z" })
44643
- ] });
44644
44700
  function parseAuthor(author) {
44645
44701
  const m2 = author.match(/^(.*?)\s*<([^>]+)>\s*$/);
44646
44702
  const email = m2 ? m2[2].trim() : "";
@@ -44708,13 +44764,10 @@ function AuthorChip({ author }) {
44708
44764
  ] });
44709
44765
  }
44710
44766
  function QuitDialog({
44711
- fileName,
44712
- dirty,
44713
44767
  onQuit,
44714
44768
  onCancel
44715
44769
  }) {
44716
44770
  const t2 = useT();
44717
- const [save, setSave] = reactExports.useState(true);
44718
44771
  const [build, setBuild] = reactExports.useState(false);
44719
44772
  const ref = reactExports.useRef(null);
44720
44773
  reactExports.useEffect(() => ref.current?.querySelector(".ap-primary")?.focus(), []);
@@ -44727,19 +44780,13 @@ function QuitDialog({
44727
44780
  }, [onCancel]);
44728
44781
  return /* @__PURE__ */ jsxRuntimeExports.jsx("div", { className: "ap-modal-backdrop", onMouseDown: onCancel, children: /* @__PURE__ */ jsxRuntimeExports.jsxs("div", { className: "ap-modal ap-quit", role: "dialog", "aria-modal": "true", "aria-label": t2("quit.title"), ref, onMouseDown: (e) => e.stopPropagation(), children: [
44729
44782
  /* @__PURE__ */ jsxRuntimeExports.jsx("div", { className: "ap-quit-title", children: t2("quit.title") }),
44730
- /* @__PURE__ */ jsxRuntimeExports.jsxs("div", { className: "ap-quit-opts", children: [
44731
- dirty && /* @__PURE__ */ jsxRuntimeExports.jsxs("label", { className: "ap-quit-opt", children: [
44732
- /* @__PURE__ */ jsxRuntimeExports.jsx("input", { type: "checkbox", checked: save, onChange: (e) => setSave(e.target.checked) }),
44733
- t2("quit.save", { file: fileName ?? t2("quit.thisDoc") })
44734
- ] }),
44735
- /* @__PURE__ */ jsxRuntimeExports.jsxs("label", { className: "ap-quit-opt", children: [
44736
- /* @__PURE__ */ jsxRuntimeExports.jsx("input", { type: "checkbox", checked: build, onChange: (e) => setBuild(e.target.checked) }),
44737
- t2("quit.startBuild")
44738
- ] })
44739
- ] }),
44783
+ /* @__PURE__ */ jsxRuntimeExports.jsx("div", { className: "ap-quit-opts", children: /* @__PURE__ */ jsxRuntimeExports.jsxs("label", { className: "ap-quit-opt", children: [
44784
+ /* @__PURE__ */ jsxRuntimeExports.jsx("input", { type: "checkbox", checked: build, onChange: (e) => setBuild(e.target.checked) }),
44785
+ t2("quit.startBuild")
44786
+ ] }) }),
44740
44787
  /* @__PURE__ */ jsxRuntimeExports.jsxs("div", { className: "ap-quit-actions", children: [
44741
44788
  /* @__PURE__ */ jsxRuntimeExports.jsx("button", { className: "ap-link", onClick: onCancel, children: t2("quit.cancel") }),
44742
- /* @__PURE__ */ jsxRuntimeExports.jsx("button", { className: "ap-primary", onClick: () => onQuit({ save: dirty && save, startBuild: build }), children: t2("quit.quit") })
44789
+ /* @__PURE__ */ jsxRuntimeExports.jsx("button", { className: "ap-primary", onClick: () => onQuit({ startBuild: build }), children: t2("quit.quit") })
44743
44790
  ] })
44744
44791
  ] }) });
44745
44792
  }
@@ -44770,6 +44817,13 @@ var STEPS = [
44770
44817
  { id: "inline", target: '[data-onboard="preview"]', gate: (n2, b) => n2.inline > b.inline },
44771
44818
  { id: "doc", target: '[data-onboard="preview"]', gate: (n2, b) => n2.doc > b.doc },
44772
44819
  { id: "answer", target: '[data-onboard="comments"]', gate: (n2, b) => n2.answered > b.answered },
44820
+ { id: "layout", target: '[data-onboard="panes"]', gate: (n2, b) => n2.panes !== b.panes },
44821
+ { id: "source", target: '[data-onboard="source"]', gate: (n2, b) => n2.sourceEdits > b.sourceEdits },
44822
+ // The last two are informational (no gate): triggering them for real would navigate the tour
44823
+ // off the throwaway sample (Move to New Doc) or hand the turn to an agent that isn't there
44824
+ // (Finish turn), so we spotlight + explain them rather than force the action.
44825
+ { id: "movedoc", target: '[data-onboard="preview"]', gate: null },
44826
+ { id: "finishturn", target: '[data-onboard="finishturn"]', gate: null },
44773
44827
  { id: "finish", target: null, gate: null }
44774
44828
  ];
44775
44829
  var SPOTLIGHT = "ap-coach-target";
@@ -44877,6 +44931,8 @@ Select any line above, then press the comment shortcut to leave a note on it.
44877
44931
  function createMemoryApi(opts) {
44878
44932
  const store = new MemoryDocumentStore(opts.content);
44879
44933
  const channel = new MemoryControlChannel();
44934
+ let currentPath = "memory://doc";
44935
+ let currentReadOnly = opts.readOnly === true;
44880
44936
  let settings = opts.settings ?? { autoResolve: true };
44881
44937
  let closed = false;
44882
44938
  const telemetryEvents = [];
@@ -44897,7 +44953,7 @@ function createMemoryApi(opts) {
44897
44953
  const api = {
44898
44954
  async load() {
44899
44955
  if (await store.getCanonical() === null) await store.setCanonical(opts.content);
44900
- return { path: "memory://doc", content: await store.loadDoc() };
44956
+ return { path: currentPath, content: await store.loadDoc(), ...currentReadOnly ? { readOnly: true } : {} };
44901
44957
  },
44902
44958
  async save(content2, options) {
44903
44959
  if (options.kind === "backup") {
@@ -44935,10 +44991,8 @@ function createMemoryApi(opts) {
44935
44991
  showBackButton: opts.backButton ?? false,
44936
44992
  // opt-in (web-like): expose the in-editor Back control
44937
44993
  quit(content2, opts2) {
44938
- if (opts2.save) {
44939
- void store.saveDoc(content2);
44940
- void store.setCanonical(content2);
44941
- }
44994
+ void store.saveDoc(content2);
44995
+ void store.setCanonical(content2);
44942
44996
  void channel.append({ actor: "user", type: LogEventType.SessionClosed, payload: { reason: opts2.startBuild ? "completed" : "window_closed" } });
44943
44997
  closed = true;
44944
44998
  }
@@ -44991,10 +45045,12 @@ function createMemoryApi(opts) {
44991
45045
  void channel.append({ actor: "agent", type: LogEventType.AgentMessage, payload: { text: text2 }, ts });
44992
45046
  for (const cb2 of messages) cb2({ text: text2, ts });
44993
45047
  },
44994
- navigate(content2, path = "memory://doc2") {
45048
+ navigate(content2, path = "memory://doc2", readOnly2 = opts.readOnly === true) {
44995
45049
  void store.saveDoc(content2);
44996
45050
  void store.setCanonical(content2);
44997
- for (const cb2 of navigated) cb2({ path, content: content2 });
45051
+ currentPath = path;
45052
+ currentReadOnly = readOnly2;
45053
+ for (const cb2 of navigated) cb2({ path, content: content2, ...readOnly2 ? { readOnly: true } : {} });
44998
45054
  },
44999
45055
  async log() {
45000
45056
  return (await channel.readSince(0)).entries;
@@ -45159,22 +45215,47 @@ function CloudSignInOverlay({ url, onDismiss }) {
45159
45215
  }, [onDismiss]);
45160
45216
  return /* @__PURE__ */ jsxRuntimeExports.jsx("div", { className: "ap-signin-backdrop", onMouseDown: onDismiss, role: "presentation", children: /* @__PURE__ */ jsxRuntimeExports.jsx("div", { className: "ap-signin-panel", onMouseDown: (e) => e.stopPropagation(), children: /* @__PURE__ */ jsxRuntimeExports.jsx("iframe", { className: "ap-signin-frame", src: url, title: "Sign in to inplan.ai" }) }) });
45161
45217
  }
45218
+ function readLayout() {
45219
+ try {
45220
+ const parsed = JSON.parse(localStorage.getItem("ap-layout") ?? "{}");
45221
+ return parsed && typeof parsed === "object" && !Array.isArray(parsed) ? parsed : {};
45222
+ } catch {
45223
+ return {};
45224
+ }
45225
+ }
45162
45226
  function App(props = {}) {
45163
45227
  const t2 = useT();
45164
45228
  const [loaded, setLoaded] = reactExports.useState(false);
45165
45229
  const [doc2, setDoc] = reactExports.useState(EMPTY);
45166
- const [cadence, setCadence] = reactExports.useState("turn");
45230
+ const [readOnly2, setReadOnly] = reactExports.useState(false);
45167
45231
  const modes = reactExports.useMemo(() => [TURN_MODE, ...hostApi().extraModes ?? []], []);
45232
+ const [cadence, setCadence] = reactExports.useState(() => {
45233
+ const c = readLayout().cadence;
45234
+ return typeof c === "string" && modes.some((m2) => m2.id === c) ? c : "turn";
45235
+ });
45168
45236
  const mode = resolveMode(cadence, modes);
45169
45237
  const [acceptance, setAcceptance] = reactExports.useState("review");
45170
45238
  const [autoResolve, setAutoResolve] = reactExports.useState(false);
45171
45239
  const [agentMode, setAgentMode] = reactExports.useState("planning");
45172
45240
  const [telemetry, setTelemetry] = reactExports.useState(false);
45173
- const [panes, setPanes] = reactExports.useState(2);
45174
- const [rightTab, setRightTab] = reactExports.useState("comments");
45175
- const [srcW, setSrcW] = reactExports.useState(380);
45176
- const [cmtW, setCmtW] = reactExports.useState(380);
45177
- const [zoom, setZoom] = reactExports.useState(1);
45241
+ const [panes, setPanes] = reactExports.useState(() => {
45242
+ const p2 = readLayout().panes;
45243
+ return p2 === 1 || p2 === 2 || p2 === 3 ? p2 : 2;
45244
+ });
45245
+ const [onboardSourceEdits, setOnboardSourceEdits] = reactExports.useState(0);
45246
+ const [rightTab, setRightTab] = reactExports.useState(() => readLayout().rightTab === "source" ? "source" : "comments");
45247
+ const [srcW, setSrcW] = reactExports.useState(() => {
45248
+ const w2 = readLayout().srcW;
45249
+ return typeof w2 === "number" ? Math.min(900, Math.max(220, w2)) : 380;
45250
+ });
45251
+ const [cmtW, setCmtW] = reactExports.useState(() => {
45252
+ const w2 = readLayout().cmtW;
45253
+ return typeof w2 === "number" ? Math.min(900, Math.max(220, w2)) : 380;
45254
+ });
45255
+ const [zoom, setZoom] = reactExports.useState(() => {
45256
+ const z2 = readLayout().zoom;
45257
+ return typeof z2 === "number" ? Math.min(ZOOM_MAX, Math.max(ZOOM_MIN, z2)) : 1;
45258
+ });
45178
45259
  const [dirty, setDirty] = reactExports.useState(false);
45179
45260
  const [status, setStatus] = reactExports.useState("");
45180
45261
  const [agentThinking, setAgentThinking] = reactExports.useState(false);
@@ -45190,7 +45271,7 @@ function App(props = {}) {
45190
45271
  const userAuthorRef = reactExports.useRef(userAuthor);
45191
45272
  userAuthorRef.current = userAuthor;
45192
45273
  const [updating, setUpdating] = reactExports.useState("idle");
45193
- const [showResolvedOrphaned, setShowResolvedOrphaned] = reactExports.useState(false);
45274
+ const [showResolvedOrphaned, setShowResolvedOrphaned] = reactExports.useState(() => readLayout().showResolvedOrphaned === true);
45194
45275
  const [selectionText, setSelectionText] = reactExports.useState("");
45195
45276
  const [composer, setComposer] = reactExports.useState(null);
45196
45277
  const [newDocReq, setNewDocReq] = reactExports.useState(null);
@@ -45227,19 +45308,6 @@ function App(props = {}) {
45227
45308
  const autoResolvedRef = reactExports.useRef(/* @__PURE__ */ new Set());
45228
45309
  const saveNowRef = reactExports.useRef(() => {
45229
45310
  });
45230
- reactExports.useEffect(() => {
45231
- try {
45232
- const s = JSON.parse(localStorage.getItem("ap-layout") ?? "{}");
45233
- if (s.panes === 1 || s.panes === 2 || s.panes === 3) setPanes(s.panes);
45234
- if (s.rightTab === "comments" || s.rightTab === "source") setRightTab(s.rightTab);
45235
- if (typeof s.zoom === "number") setZoom(Math.min(ZOOM_MAX, Math.max(ZOOM_MIN, s.zoom)));
45236
- if (typeof s.showResolvedOrphaned === "boolean") setShowResolvedOrphaned(s.showResolvedOrphaned);
45237
- if (typeof s.cadence === "string" && modes.some((m2) => m2.id === s.cadence)) setCadence(s.cadence);
45238
- if (typeof s.srcW === "number") setSrcW(Math.min(900, Math.max(220, s.srcW)));
45239
- if (typeof s.cmtW === "number") setCmtW(Math.min(900, Math.max(220, s.cmtW)));
45240
- } catch {
45241
- }
45242
- }, []);
45243
45311
  reactExports.useEffect(() => {
45244
45312
  localStorage.setItem("ap-layout", JSON.stringify({ panes, rightTab, zoom, showResolvedOrphaned, cadence, srcW, cmtW }));
45245
45313
  }, [panes, rightTab, zoom, showResolvedOrphaned, cadence, srcW, cmtW]);
@@ -45259,8 +45327,9 @@ function App(props = {}) {
45259
45327
  setStatus(t2("msg.proposedReview"));
45260
45328
  };
45261
45329
  const commentStore = hostApi().commentStore ?? null;
45262
- hostApi().load().then(({ content: content2, path }) => {
45330
+ hostApi().load().then(({ content: content2, path, readOnly: ro }) => {
45263
45331
  docPathRef.current = path;
45332
+ setReadOnly(!!ro);
45264
45333
  const parsed = parse(content2);
45265
45334
  const d = commentStore ? { ...parsed, comments: commentStore.list() } : parsed;
45266
45335
  setDoc(d);
@@ -45270,12 +45339,14 @@ function App(props = {}) {
45270
45339
  }).catch(() => setLoaded(true));
45271
45340
  const subs = [
45272
45341
  hostApi().onExternalChange(({ content: content2 }) => {
45342
+ const prevDoc = docRef.current;
45273
45343
  const parsed = parse(content2);
45274
45344
  const next = commentStore ? { ...parsed, comments: commentStore.list() } : parsed;
45275
45345
  setAgentThinking(false);
45276
45346
  setDoc(next);
45277
45347
  savedRef.current = serialize(next);
45278
45348
  setDirty(false);
45349
+ syncExternalDoc(next, prevDoc.comments, prevDoc.body);
45279
45350
  setStatus(t2("msg.agentUpdated"));
45280
45351
  }),
45281
45352
  // Review-mode body changes arrive parked, as a proposal to accept/reject.
@@ -45294,9 +45365,10 @@ function App(props = {}) {
45294
45365
  hostApi().onAgentMessage?.((msg) => setAgentMessages((prev) => [...prev, msg])),
45295
45366
  // Desktop only: the window followed a link to another doc — reset to it (a fresh
45296
45367
  // load), clearing any in-flight proposal/turn state, then re-show a parked proposal.
45297
- hostApi().onNavigated?.(({ content: content2, path }) => {
45368
+ hostApi().onNavigated?.(({ content: content2, path, readOnly: ro }) => {
45298
45369
  if (docPathRef.current) historyByDoc.current.set(docPathRef.current, { undo: history2.current, redo: future.current });
45299
45370
  docPathRef.current = path;
45371
+ setReadOnly(!!ro);
45300
45372
  const parsed = parse(content2);
45301
45373
  const d = commentStore ? { ...parsed, comments: commentStore.list() } : parsed;
45302
45374
  setDoc(d);
@@ -45419,7 +45491,8 @@ function App(props = {}) {
45419
45491
  document.addEventListener("keydown", onKey);
45420
45492
  return () => document.removeEventListener("keydown", onKey);
45421
45493
  }, [composer, findOpen, proposal, reviewOpen, undo2, redo2]);
45422
- const editingLocked = mode.locksEditor && agentThinking;
45494
+ const agentLocked = mode.locksEditor && agentThinking;
45495
+ const editingLocked = agentLocked || readOnly2;
45423
45496
  const takeBackControl = reactExports.useCallback(() => {
45424
45497
  setAgentThinking(false);
45425
45498
  setStatus(t2("msg.tookBack"));
@@ -45606,29 +45679,31 @@ function App(props = {}) {
45606
45679
  reactExports.useEffect(() => {
45607
45680
  const real = realHostApi();
45608
45681
  return real?.exit?.onRequest?.(() => {
45609
- if (props.onboarding) real.exit?.quit("", { save: false, startBuild: false });
45682
+ if (props.onboarding) real.exit?.quit("", { startBuild: false });
45610
45683
  else setQuitOpen(true);
45611
45684
  });
45612
45685
  }, [props.onboarding]);
45613
45686
  const addComment = reactExports.useCallback(
45614
- (text2, target, span, question2) => {
45687
+ (text2, target, span, question2, talkToAgent = true) => {
45688
+ const agent = talkToAgent ? void 0 : false;
45689
+ const memoPayload = talkToAgent ? {} : { agent: false };
45615
45690
  if (target) {
45616
45691
  const blocker = spanCommentBlocker(docRef.current.body, target, span ?? void 0);
45617
45692
  if (blocker) {
45618
45693
  setStatus(blocker === "overlap" ? t2("topbar.cantOverlap") : t2("msg.cantAnchor"));
45619
45694
  return;
45620
45695
  }
45621
- const res = addSpanComment(docRef.current, target, { text: text2, author: userAuthorRef.current, question: question2 }, span ?? void 0);
45696
+ const res = addSpanComment(docRef.current, target, { text: text2, author: userAuthorRef.current, question: question2, agent }, span ?? void 0);
45622
45697
  if (!res) {
45623
45698
  setStatus(t2("msg.cantAnchor"));
45624
45699
  return;
45625
45700
  }
45626
- apply(res.doc, { type: "comment_created", payload: { id: res.id } });
45701
+ apply(res.doc, { type: "comment_created", payload: { id: res.id, ...memoPayload } });
45627
45702
  hostApi().telemetry?.("comment_created", { kind: "span" });
45628
45703
  setFocused(res.id);
45629
45704
  } else {
45630
- const res = addDocComment(docRef.current, { text: text2, author: userAuthorRef.current, question: question2 });
45631
- apply(res.doc, { type: "comment_created", payload: { id: res.id, anchor: "doc" } });
45705
+ const res = addDocComment(docRef.current, { text: text2, author: userAuthorRef.current, question: question2, agent });
45706
+ apply(res.doc, { type: "comment_created", payload: { id: res.id, anchor: "doc", ...memoPayload } });
45632
45707
  hostApi().telemetry?.("comment_created", { kind: "doc" });
45633
45708
  setFocused(res.id);
45634
45709
  }
@@ -45861,7 +45936,8 @@ function App(props = {}) {
45861
45936
  (segs, accepted2) => {
45862
45937
  if (!proposal || editingLocked) return;
45863
45938
  const body = applySegments(segs, accepted2);
45864
- const live = docRef.current.comments;
45939
+ const prevDoc = docRef.current;
45940
+ const live = prevDoc.comments;
45865
45941
  const have = new Set(live.map((c) => c.id));
45866
45942
  const merged = [...live, ...proposal.next.comments.filter((c) => !have.has(c.id))];
45867
45943
  const comments = merged.map((c) => !c.parentId && c.anchor !== "doc" && !body.includes(`](#${c.id})`) ? { ...c, anchor: "doc" } : c);
@@ -45873,12 +45949,16 @@ function App(props = {}) {
45873
45949
  savedRef.current = serialized;
45874
45950
  setDirty(false);
45875
45951
  const acceptedCount = accepted2.filter(Boolean).length;
45876
- void hostApi().save(serialized, { kind: "apply", cadence }).then(() => setCheckpoint(serialized));
45952
+ if (syncExternalDoc(finalDoc, prevDoc.comments, prevDoc.body)) {
45953
+ setCheckpoint(serialized);
45954
+ } else {
45955
+ void hostApi().save(serialized, { kind: "apply", cadence }).then(() => setCheckpoint(serialized));
45956
+ }
45877
45957
  void hostApi().clearProposal();
45878
45958
  void hostApi().logAction(acceptedCount === accepted2.length ? "revision_accepted_all" : acceptedCount === 0 ? "revision_rejected_all" : "revision_hunk_accepted", { accepted: acceptedCount, total: accepted2.length });
45879
45959
  setStatus(`applied agent revision (${acceptedCount}/${accepted2.length} hunks)`);
45880
45960
  },
45881
- [proposal, cadence, editingLocked]
45961
+ [proposal, cadence, editingLocked, syncExternalDoc]
45882
45962
  );
45883
45963
  const reviewSegs = reactExports.useMemo(() => proposal ? lineSegments(proposal.baseBody, proposal.next.body) : [], [proposal]);
45884
45964
  const changeCount = reactExports.useMemo(() => reviewSegs.filter(isChange).length, [reviewSegs]);
@@ -46048,9 +46128,11 @@ function App(props = {}) {
46048
46128
  () => ({
46049
46129
  inline: doc2.comments.filter(isSpanComment).length,
46050
46130
  doc: doc2.comments.filter(isDocComment).length,
46051
- answered: doc2.comments.filter((c) => c.selected !== void 0).length
46131
+ answered: doc2.comments.filter((c) => c.selected !== void 0).length,
46132
+ panes,
46133
+ sourceEdits: onboardSourceEdits
46052
46134
  }),
46053
- [doc2.comments]
46135
+ [doc2.comments, panes, onboardSourceEdits]
46054
46136
  );
46055
46137
  if (!loaded) return /* @__PURE__ */ jsxRuntimeExports.jsx("div", { className: "ap-loading", children: t2("app.loading") });
46056
46138
  const showSource = panes === 3 || panes === 2 && rightTab === "source";
@@ -46198,6 +46280,7 @@ function App(props = {}) {
46198
46280
  ),
46199
46281
  /* @__PURE__ */ jsxRuntimeExports.jsx("button", { className: "ap-link", onClick: () => setUpdate(null), children: t2("banner.later") })
46200
46282
  ] }) }),
46283
+ readOnly2 && /* @__PURE__ */ jsxRuntimeExports.jsx("div", { className: "ap-banner ap-banner--readonly", role: "status", children: t2("banner.readOnly") }),
46201
46284
  proposal && !reviewOpen && /* @__PURE__ */ jsxRuntimeExports.jsxs("div", { className: "ap-banner", children: [
46202
46285
  t2("banner.proposalPending"),
46203
46286
  " ",
@@ -46216,8 +46299,7 @@ function App(props = {}) {
46216
46299
  TriSwitch,
46217
46300
  {
46218
46301
  state: changeCount > 0 && accepted.slice(0, changeCount).every(Boolean) ? "accept" : changeCount > 0 && accepted.slice(0, changeCount).every((v2) => !v2) ? "reject" : "mixed",
46219
- onAccept: () => setAllAccepted(true),
46220
- onReject: () => setAllAccepted(false),
46302
+ onCycle: (v2) => setAllAccepted(v2),
46221
46303
  disabled: editingLocked || !changeCount
46222
46304
  }
46223
46305
  ),
@@ -46231,22 +46313,14 @@ function App(props = {}) {
46231
46313
  target: composer.target,
46232
46314
  pos: composer.pos,
46233
46315
  disabled: editingLocked,
46234
- onSubmit: (text2) => {
46235
- addComment(text2, composer.target, composer.span);
46316
+ onSubmit: (text2, talkToAgent) => {
46317
+ addComment(text2, composer.target, composer.span, void 0, talkToAgent);
46236
46318
  setComposer(null);
46237
46319
  },
46238
46320
  onClose: () => setComposer(null)
46239
46321
  }
46240
46322
  ),
46241
- quitOpen && /* @__PURE__ */ jsxRuntimeExports.jsx(
46242
- QuitDialog,
46243
- {
46244
- fileName: docPathRef.current ? docPathRef.current.split(/[\\/]/).pop() || null : null,
46245
- dirty,
46246
- onQuit: confirmQuit,
46247
- onCancel: () => setQuitOpen(false)
46248
- }
46249
- ),
46323
+ quitOpen && /* @__PURE__ */ jsxRuntimeExports.jsx(QuitDialog, { onQuit: confirmQuit, onCancel: () => setQuitOpen(false) }),
46250
46324
  newDocReq && /* @__PURE__ */ jsxRuntimeExports.jsx(
46251
46325
  NewDocModal,
46252
46326
  {
@@ -46260,7 +46334,17 @@ function App(props = {}) {
46260
46334
  onCancel: () => setNewDocReq(null)
46261
46335
  }
46262
46336
  ),
46263
- props.onboarding && props.onFinishOnboarding && /* @__PURE__ */ jsxRuntimeExports.jsx(Onboarding, { signals: onboardingSignals, onFinish: props.onFinishOnboarding, onActiveStep: (id2) => setForceSettingsOpen(id2 === "settings") }),
46337
+ props.onboarding && props.onFinishOnboarding && /* @__PURE__ */ jsxRuntimeExports.jsx(
46338
+ Onboarding,
46339
+ {
46340
+ signals: onboardingSignals,
46341
+ onFinish: props.onFinishOnboarding,
46342
+ onActiveStep: (id2) => {
46343
+ setForceSettingsOpen(id2 === "settings");
46344
+ if (id2 === "source") setPanes(3);
46345
+ }
46346
+ }
46347
+ ),
46264
46348
  signInUrl && /* @__PURE__ */ jsxRuntimeExports.jsx(
46265
46349
  CloudSignInOverlay,
46266
46350
  {
@@ -46389,7 +46473,7 @@ function App(props = {}) {
46389
46473
  ),
46390
46474
  showSource && /* @__PURE__ */ jsxRuntimeExports.jsxs(jsxRuntimeExports.Fragment, { children: [
46391
46475
  /* @__PURE__ */ jsxRuntimeExports.jsx(VSplitter, { width: srcW, setWidth: setSrcW }),
46392
- /* @__PURE__ */ jsxRuntimeExports.jsxs("section", { className: "ap-pane", style: { width: srcW }, children: [
46476
+ /* @__PURE__ */ jsxRuntimeExports.jsxs("section", { className: "ap-pane", style: { width: srcW }, "data-onboard": "source", children: [
46393
46477
  panes === 2 && /* @__PURE__ */ jsxRuntimeExports.jsx(PaneTabs, { tab: rightTab, onTab: setRightTab }),
46394
46478
  proposal && reviewOpen ? /* @__PURE__ */ jsxRuntimeExports.jsx(DiffSource, { segs: editedSegs, accepted, focused: reviewCursor, onToggle: toggleHunk }) : /* @__PURE__ */ jsxRuntimeExports.jsx(EditorErrorBoundary, { label: "The source editor", children: /* @__PURE__ */ jsxRuntimeExports.jsx(
46395
46479
  SourceEditor,
@@ -46400,6 +46484,7 @@ function App(props = {}) {
46400
46484
  editable: !editingLocked,
46401
46485
  onChange: (body) => {
46402
46486
  setDoc((d) => ({ ...d, body }));
46487
+ if (props.onboarding) setOnboardSourceEdits((n2) => n2 + 1);
46403
46488
  if (!hostApi().binding?.setText) setDirty(serialize({ ...docRef.current, body }) !== savedRef.current);
46404
46489
  },
46405
46490
  onCursorLine: (line) => setActivePreviewLine(line),
@@ -46473,7 +46558,7 @@ function App(props = {}) {
46473
46558
  dirty: dirty && serialize(doc2) !== checkpoint,
46474
46559
  agentThinking,
46475
46560
  messages: agentMessages,
46476
- canTakeBack: editingLocked,
46561
+ canTakeBack: agentLocked,
46477
46562
  onTakeBack: takeBackControl
46478
46563
  }
46479
46564
  )
@@ -46497,6 +46582,7 @@ function AppRoot() {
46497
46582
  const real = window.api;
46498
46583
  sample.i18n = real?.i18n;
46499
46584
  sample.extraModes = real?.extraModes;
46585
+ sample.profile = realHostApi().profile;
46500
46586
  setApiOverride(sample);
46501
46587
  }, []);
46502
46588
  reactExports.useEffect(() => {
@@ -46569,7 +46655,7 @@ function TopBar(props) {
46569
46655
  const { cadence, acceptance, panes, onMode } = props;
46570
46656
  const profile = useProfile();
46571
46657
  const t2 = useT();
46572
- const noAgent = profile?.presenceAware === true && profile.agentLocation == null;
46658
+ const noAgent = profile?.presenceAware === true && profile.agentAvailable !== true && profile.agentLocation == null;
46573
46659
  const noAgentTitle = noAgent ? t2("topbar.noAgent") : void 0;
46574
46660
  return /* @__PURE__ */ jsxRuntimeExports.jsxs("header", { className: "ap-topbar", children: [
46575
46661
  props.onBack && /* @__PURE__ */ jsxRuntimeExports.jsxs("button", { className: "ap-iconbtn ap-iconbtn--primary", onClick: props.onBack, title: t2("topbar.back"), "aria-label": t2("topbar.back"), children: [
@@ -46587,7 +46673,7 @@ function TopBar(props) {
46587
46673
  },
46588
46674
  m2.id
46589
46675
  )) }),
46590
- /* @__PURE__ */ jsxRuntimeExports.jsx("div", { className: "ap-seg", role: "group", "aria-label": "panes", children: [1, 2, 3].map((n2) => /* @__PURE__ */ jsxRuntimeExports.jsx(
46676
+ /* @__PURE__ */ jsxRuntimeExports.jsx("div", { className: "ap-seg", role: "group", "aria-label": "panes", "data-onboard": "panes", children: [1, 2, 3].map((n2) => /* @__PURE__ */ jsxRuntimeExports.jsx(
46591
46677
  "button",
46592
46678
  {
46593
46679
  className: panes === n2 ? "active" : "",
@@ -46634,6 +46720,7 @@ function TopBar(props) {
46634
46720
  "button",
46635
46721
  {
46636
46722
  className: "ap-iconbtn",
46723
+ "data-onboard": "finishturn",
46637
46724
  onClick: props.onFinishTurn,
46638
46725
  disabled: props.locked || noAgent,
46639
46726
  title: noAgentTitle ?? t2("topbar.finishTurnTitle"),
@@ -46822,12 +46909,28 @@ function FindReplaceBar({
46822
46909
  /* @__PURE__ */ jsxRuntimeExports.jsx("button", { className: "ap-link", onClick: onClose, children: t2("find.close") })
46823
46910
  ] });
46824
46911
  }
46825
- function TriSwitch({ state, onAccept, onReject, disabled }) {
46826
- return /* @__PURE__ */ jsxRuntimeExports.jsxs("span", { className: `ap-tri ap-tri--${state}${disabled ? " disabled" : ""}`, role: "group", "aria-label": "accept or reject all changes", children: [
46827
- /* @__PURE__ */ jsxRuntimeExports.jsx("button", { type: "button", className: "ap-tri-end ap-tri-accept", "aria-pressed": state === "accept", disabled, onClick: onAccept, children: "Accept all" }),
46828
- /* @__PURE__ */ jsxRuntimeExports.jsx("span", { className: "ap-tri-track", "aria-hidden": "true", children: /* @__PURE__ */ jsxRuntimeExports.jsx("span", { className: "ap-tri-thumb" }) }),
46829
- /* @__PURE__ */ jsxRuntimeExports.jsx("button", { type: "button", className: "ap-tri-end ap-tri-reject", "aria-pressed": state === "reject", disabled, onClick: onReject, children: "Reject all" })
46830
- ] });
46912
+ function TriSwitch({ state, onCycle, disabled }) {
46913
+ const t2 = useT();
46914
+ const next = state !== "accept";
46915
+ const title = state === "accept" ? t2("banner.allAccepted") : state === "reject" ? t2("banner.allRejected") : t2("banner.allMixed");
46916
+ return /* @__PURE__ */ jsxRuntimeExports.jsx(
46917
+ "button",
46918
+ {
46919
+ type: "button",
46920
+ className: `ap-tri ap-tri--${state}${disabled ? " disabled" : ""}`,
46921
+ role: "checkbox",
46922
+ "aria-checked": state === "mixed" ? "mixed" : state === "accept",
46923
+ "aria-label": t2("banner.allChanges"),
46924
+ title,
46925
+ disabled,
46926
+ onClick: () => onCycle(next),
46927
+ children: /* @__PURE__ */ jsxRuntimeExports.jsxs("span", { className: "ap-switch-track", "aria-hidden": "true", children: [
46928
+ /* @__PURE__ */ jsxRuntimeExports.jsx("span", { className: "ap-sw-yes", children: "✓" }),
46929
+ /* @__PURE__ */ jsxRuntimeExports.jsx("span", { className: "ap-sw-no", children: "✗" }),
46930
+ /* @__PURE__ */ jsxRuntimeExports.jsx("span", { className: "ap-switch-thumb" })
46931
+ ] })
46932
+ }
46933
+ );
46831
46934
  }
46832
46935
  function HunkBar({ idx, on, onToggle, onEdit, editing }) {
46833
46936
  return /* @__PURE__ */ jsxRuntimeExports.jsxs("div", { className: "ap-hunk-bar", children: [
@@ -46838,7 +46941,7 @@ function HunkBar({ idx, on, onToggle, onEdit, editing }) {
46838
46941
  /* @__PURE__ */ jsxRuntimeExports.jsx("span", { className: "ap-spacer" }),
46839
46942
  on && onEdit && /* @__PURE__ */ jsxRuntimeExports.jsx("button", { type: "button", className: `ap-hunk-edit${editing ? " active" : ""}`, "aria-label": `edit change ${idx + 1}`, title: "Edit this change", onClick: () => onEdit(idx), children: /* @__PURE__ */ jsxRuntimeExports.jsx(IconPencil, {}) }),
46840
46943
  /* @__PURE__ */ jsxRuntimeExports.jsx("span", { className: "ap-willbe", children: on ? "will be accepted" : "will be rejected" }),
46841
- /* @__PURE__ */ jsxRuntimeExports.jsx(Switch, { checked: on, onChange: (v2) => onToggle(idx, v2), ariaLabel: `accept change ${idx + 1}` })
46944
+ /* @__PURE__ */ jsxRuntimeExports.jsx(Switch, { checked: on, onChange: (v2) => onToggle(idx, v2), ariaLabel: `accept change ${idx + 1}`, intent: "accept" })
46842
46945
  ] });
46843
46946
  }
46844
46947
  function DiffPreview({
@@ -109,6 +109,17 @@ body {
109
109
  .ap-switch-input:checked ~ .ap-switch-track .ap-switch-thumb { transform: translateX(14px); }
110
110
  .ap-switch-input:focus-visible ~ .ap-switch-track { outline: 2px solid var(--accent); outline-offset: 2px; }
111
111
  .ap-switch.disabled .ap-switch-track { cursor: default; }
112
+ /* Accept/reject variant (the per-hunk review switch + the tri-state all-control): on = green/✓
113
+ (accepted), off = red/✗ (rejected). The ✓/✗ glyphs sit on the track and show on the side
114
+ opposite the thumb (✓ left = accept side, ✗ right = reject side). */
115
+ .ap-switch--accept .ap-switch-input:not(:checked) ~ .ap-switch-track { background: var(--danger); }
116
+ .ap-sw-yes, .ap-sw-no { position: absolute; top: 0; height: 100%; display: flex; align-items: center; font-size: 10px; line-height: 1; color: #fbfaf6; pointer-events: none; transition: opacity 0.15s ease; }
117
+ .ap-sw-yes { left: 5px; }
118
+ .ap-sw-no { right: 5px; }
119
+ .ap-switch--accept .ap-sw-yes { opacity: 0; }
120
+ .ap-switch--accept .ap-sw-no { opacity: 1; }
121
+ .ap-switch--accept .ap-switch-input:checked ~ .ap-switch-track .ap-sw-yes { opacity: 1; }
122
+ .ap-switch--accept .ap-switch-input:checked ~ .ap-switch-track .ap-sw-no { opacity: 0; }
112
123
  .ap-profile-edit { gap: 6px; padding: 8px 10px 4px; }
113
124
  .ap-profile-input { font: inherit; font-size: 13px; padding: 6px 8px; border: 1px solid var(--line-strong); border-radius: 7px; background: var(--bg); color: var(--fg); }
114
125
  .ap-profile-input:focus { outline: none; border-color: var(--accent); }
@@ -123,7 +134,9 @@ body {
123
134
  .ap-agent-dot { width: 10px; height: 10px; border-radius: 50%; flex: 0 0 auto; }
124
135
  .ap-agent-local { background: #2bb673; } /* agent on your machine */
125
136
  .ap-agent-off { background: var(--danger); } /* no agent connected */
126
- .ap-agent-pie { width: 13px; height: 13px; border-radius: 50%; flex: 0 0 auto; }
137
+ .ap-agent-pie { position: relative; width: 14px; height: 14px; border-radius: 50%; flex: 0 0 auto; }
138
+ /* Green "connected" core; only the thin outer band of .ap-agent-pie shows the usage conic. */
139
+ .ap-agent-pie-core { position: absolute; inset: 16%; border-radius: 50%; background: var(--accent); }
127
140
  /* Anchor to the trigger's RIGHT edge (it sits on the right of the topbar) so the 220px menu opens
128
141
  leftward and stays on-screen — left:0 made it overflow off the right of the viewport, clipping the
129
142
  item labels. Mirrors .ap-profile-menu. */
@@ -180,6 +193,8 @@ body {
180
193
  /* banner */
181
194
  .ap-banner { background: var(--accent-soft); border-bottom: 1px solid var(--line); padding: 9px 14px; display: flex; gap: 10px; align-items: center; }
182
195
  .ap-banner-reload { background: #f6ecdd; }
196
+ /* Archived/read-only doc notice — muted amber, no action (view + download only). */
197
+ .ap-banner--readonly { background: #f6ecdd; color: var(--amber); font-size: 13px; }
183
198
 
184
199
  /* main layout */
185
200
  .ap-main { flex: 1; display: flex; min-height: 0; position: relative; }
@@ -242,6 +257,16 @@ body {
242
257
  .ap-muted { color: var(--muted); }
243
258
  .ap-row { display: flex; gap: 6px; align-items: center; margin-top: 6px; }
244
259
 
260
+ /* Composer audience switch: conversation (talk to the agent) ⇄ memo (the agent ignores it). A small
261
+ two-icon pill; the active side is filled with the accent, the other is muted. Margin-right pushes
262
+ the Comment/cancel buttons to the right. */
263
+ .ap-agent-toggle { display: inline-flex; align-items: center; gap: 2px; padding: 2px; border: 1px solid var(--line-strong); border-radius: 999px; background: var(--surface, #fff); margin-right: auto; }
264
+ .ap-agent-opt { display: inline-flex; align-items: center; justify-content: center; width: 28px; height: 22px; padding: 0; border: 0; border-radius: 999px; background: transparent; color: var(--ink-faint, #a8a08c); cursor: pointer; transition: background 0.12s ease, color 0.12s ease; }
265
+ .ap-agent-opt svg { width: 14px; height: 14px; }
266
+ .ap-agent-opt:hover:not(:disabled):not(.active) { color: var(--accent); background: var(--accent-soft); }
267
+ .ap-agent-opt.active { background: var(--accent); color: #fbfaf6; }
268
+ .ap-agent-opt:disabled { opacity: 0.5; cursor: default; }
269
+
245
270
  textarea, input[type="text"], input[type="email"], input[type="number"], select {
246
271
  font: inherit; color: var(--fg); background: var(--bg);
247
272
  border: 1px solid var(--line-strong); border-radius: 7px; padding: 7px 9px;
@@ -446,20 +471,23 @@ input[type="checkbox"]:focus-visible, input[type="radio"]:focus-visible { outlin
446
471
  .ap-hunk-edit { display: inline-flex; align-items: center; justify-content: center; border: 1px solid var(--line-strong); background: var(--bg); border-radius: 6px; padding: 2px; cursor: pointer; color: var(--muted); }
447
472
  .ap-hunk-edit:hover, .ap-hunk-edit.active { background: var(--accent-soft); color: var(--accent); border-color: var(--accent); }
448
473
  .ap-hunk-edit svg { width: 13px; height: 13px; display: block; }
449
- /* Tri-state accept/reject-all switch: two end buttons + a thumb that sits L/centre/R. */
450
- .ap-tri { display: inline-flex; align-items: center; gap: 6px; }
451
- .ap-tri-end { font: inherit; font-size: 12px; border: 1px solid var(--line-strong); background: var(--bg); border-radius: 6px; padding: 3px 9px; cursor: pointer; color: var(--muted); }
452
- .ap-tri-end:disabled { opacity: 0.5; cursor: default; }
453
- .ap-tri-accept[aria-pressed="true"] { background: #2e9e5b; border-color: #2e9e5b; color: #fbfaf6; }
454
- .ap-tri-reject[aria-pressed="true"] { background: var(--danger); border-color: var(--danger); color: #fbfaf6; }
455
- .ap-tri-track { position: relative; width: 34px; height: 18px; border-radius: 999px; background: var(--line-strong); flex: 0 0 auto; }
456
- .ap-tri-thumb { position: absolute; top: 2px; width: 14px; height: 14px; border-radius: 50%; background: #fff; box-shadow: 0 1px 2px rgba(0,0,0,0.25); transition: left 0.15s ease; }
457
- .ap-tri--accept .ap-tri-track { background: #2e9e5b; }
458
- .ap-tri--reject .ap-tri-track { background: var(--danger); }
459
- .ap-tri--accept .ap-tri-thumb { left: 2px; }
460
- .ap-tri--mixed .ap-tri-thumb { left: 10px; }
461
- .ap-tri--reject .ap-tri-thumb { left: 18px; }
462
- .ap-tri.disabled { opacity: 0.5; }
474
+ /* Tri-state accept/reject-all toggle — a single click-to-cycle control reusing the per-hunk
475
+ switch's track/thumb/glyphs (accept = thumb-right/green/✓, reject = thumb-left/red/✗,
476
+ mixed = centre/neutral with no glyph), so it matches the per-hunk switch exactly. */
477
+ .ap-tri { display: inline-flex; align-items: center; border: none; background: none; padding: 0; margin: 0; cursor: pointer; }
478
+ .ap-tri:disabled, .ap-tri.disabled { opacity: 0.5; cursor: default; }
479
+ .ap-tri:focus-visible .ap-switch-track { outline: 2px solid var(--accent); outline-offset: 2px; }
480
+ .ap-tri--accept .ap-switch-track { background: var(--accent); }
481
+ .ap-tri--reject .ap-switch-track { background: var(--danger); }
482
+ .ap-tri--mixed .ap-switch-track { background: var(--line-strong); }
483
+ .ap-tri--accept .ap-switch-thumb { transform: translateX(14px); }
484
+ .ap-tri--reject .ap-switch-thumb { transform: translateX(0); }
485
+ .ap-tri--mixed .ap-switch-thumb { transform: translateX(7px); }
486
+ .ap-tri--accept .ap-sw-yes { opacity: 1; }
487
+ .ap-tri--accept .ap-sw-no { opacity: 0; }
488
+ .ap-tri--reject .ap-sw-yes { opacity: 0; }
489
+ .ap-tri--reject .ap-sw-no { opacity: 1; }
490
+ .ap-tri--mixed .ap-sw-yes, .ap-tri--mixed .ap-sw-no { opacity: 0; }
463
491
  .ap-ihunk-del { background: #fbeae6; padding: 3px 12px; }
464
492
  .ap-ihunk-del :where(p, h1, h2, h3, h4, li, blockquote) { text-decoration: line-through; }
465
493
  .ap-ihunk-add { background: #e9f3ec; padding: 3px 12px; }
@@ -11,8 +11,8 @@
11
11
  content="default-src 'self'; style-src 'self' 'unsafe-inline'; script-src 'self' inplan-plugin:; connect-src 'self' inplan-plugin: ws://127.0.0.1:* ws://localhost:*; frame-src https://inplan.ai http://127.0.0.1:* http://localhost:*"
12
12
  />
13
13
  <title>inplan</title>
14
- <script type="module" crossorigin src="./assets/index-B5mCdcn1.js"></script>
15
- <link rel="stylesheet" crossorigin href="./assets/index-Hw2I1zYD.css">
14
+ <script type="module" crossorigin src="./assets/index-C7Dv9pUL.js"></script>
15
+ <link rel="stylesheet" crossorigin href="./assets/index-DPBeZ4rp.css">
16
16
  </head>
17
17
  <body>
18
18
  <div id="root"></div>
package/bin/cli.js CHANGED
@@ -1,7 +1,7 @@
1
1
  #!/usr/bin/env node
2
2
 
3
3
  // src/cli.ts
4
- import { spawn as spawn2 } from "child_process";
4
+ import { spawn as spawn3 } from "child_process";
5
5
  import { createHash as createHash4 } from "crypto";
6
6
  import { createRequire } from "module";
7
7
  import { appendFileSync as appendFileSync2, copyFileSync, existsSync as existsSync9, mkdirSync as mkdirSync8, readdirSync as readdirSync2, readFileSync as readFileSync9, realpathSync, renameSync, statSync as statSync2, writeFileSync as writeFileSync8 } from "fs";
@@ -9,7 +9,7 @@ import { homedir as homedir6 } from "os";
9
9
  import { basename as basename3, dirname as dirname9, isAbsolute as isAbsolute2, join as join9, relative as relative4, resolve as resolve3 } from "path";
10
10
  import { fileURLToPath as fileURLToPath2 } from "url";
11
11
 
12
- // ../core/dist/chunk-RMG4JQWQ.js
12
+ // ../core/dist/chunk-2A42CIA7.js
13
13
  function isReply(c) {
14
14
  return c.parentId !== void 0;
15
15
  }
@@ -859,6 +859,103 @@ async function remoteBackend(docId, consumerId = "cli-agent") {
859
859
  };
860
860
  }
861
861
 
862
+ // src/cliLogin.ts
863
+ import { createServer } from "http";
864
+ import { spawn } from "child_process";
865
+ import { randomBytes } from "crypto";
866
+ var DEFAULT_WEB_ORIGIN = process.env.INPLAN_WEB_URL || "https://inplan.ai";
867
+ var DEFAULT_TIMEOUT_MS = 3 * 6e4;
868
+ var MAX_BODY_BYTES = 64 * 1024;
869
+ function openInBrowser(url) {
870
+ const cmd = process.platform === "darwin" ? "open" : process.platform === "win32" ? "cmd" : "xdg-open";
871
+ const args = process.platform === "win32" ? ["/c", "start", "", url] : [url];
872
+ try {
873
+ const child = spawn(cmd, args, { detached: true, stdio: "ignore" });
874
+ child.on("error", () => {
875
+ });
876
+ child.unref();
877
+ } catch {
878
+ }
879
+ }
880
+ function isHandoff(v) {
881
+ if (typeof v !== "object" || v === null) return false;
882
+ const o = v;
883
+ return typeof o.state === "string" && typeof o.url === "string" && typeof o.anon === "string" && typeof o.refresh === "string" && (o.email === void 0 || typeof o.email === "string");
884
+ }
885
+ function browserLogin(opts = {}) {
886
+ const webOrigin = (opts.webOrigin ?? DEFAULT_WEB_ORIGIN).replace(/\/$/, "");
887
+ const timeoutMs = opts.timeoutMs ?? DEFAULT_TIMEOUT_MS;
888
+ const open = opts.open ?? openInBrowser;
889
+ const state = randomBytes(16).toString("hex");
890
+ return new Promise((resolve4, reject) => {
891
+ let settled = false;
892
+ const finish = (fn) => {
893
+ if (settled) return;
894
+ settled = true;
895
+ clearTimeout(timer);
896
+ server.close();
897
+ fn();
898
+ };
899
+ const cors = (req, res) => {
900
+ res.setHeader("Access-Control-Allow-Origin", req.headers.origin || webOrigin);
901
+ res.setHeader("Vary", "Origin");
902
+ res.setHeader("Access-Control-Allow-Methods", "POST, OPTIONS");
903
+ res.setHeader("Access-Control-Allow-Headers", "content-type");
904
+ };
905
+ const server = createServer((req, res) => {
906
+ const url = req.url ?? "";
907
+ if (req.method === "OPTIONS" && url.startsWith("/cb")) {
908
+ cors(req, res);
909
+ res.writeHead(204).end();
910
+ return;
911
+ }
912
+ if (req.method !== "POST" || !url.startsWith("/cb")) {
913
+ res.writeHead(404).end();
914
+ return;
915
+ }
916
+ cors(req, res);
917
+ let body = "";
918
+ let tooBig = false;
919
+ req.on("data", (chunk) => {
920
+ body += chunk.toString("utf8");
921
+ if (body.length > MAX_BODY_BYTES) {
922
+ tooBig = true;
923
+ req.destroy();
924
+ }
925
+ });
926
+ req.on("end", () => {
927
+ if (tooBig) {
928
+ res.writeHead(413).end();
929
+ return;
930
+ }
931
+ let parsed;
932
+ try {
933
+ parsed = JSON.parse(body);
934
+ } catch {
935
+ res.writeHead(400).end();
936
+ return;
937
+ }
938
+ if (!isHandoff(parsed) || parsed.state !== state) {
939
+ res.writeHead(403).end();
940
+ return;
941
+ }
942
+ res.writeHead(200, { "content-type": "text/plain" }).end("inplan: signed in \u2014 you can close this tab.");
943
+ const { url: projUrl, anon, refresh, email } = parsed;
944
+ finish(() => resolve4({ url: projUrl, anonKey: anon, refreshToken: refresh, ...email ? { email } : {} }));
945
+ });
946
+ });
947
+ server.on("error", (err) => finish(() => reject(err)));
948
+ const timer = setTimeout(() => finish(() => reject(new Error("login timed out \u2014 no response from the browser"))), timeoutMs);
949
+ if (typeof timer.unref === "function") timer.unref();
950
+ server.listen(0, "127.0.0.1", () => {
951
+ const { port } = server.address();
952
+ const target = `${webOrigin}/cli-auth?port=${port}&state=${state}`;
953
+ opts.onUrl?.(target);
954
+ open(target);
955
+ });
956
+ });
957
+ }
958
+
862
959
  // src/cliProfile.ts
863
960
  import { existsSync as existsSync8, mkdirSync as mkdirSync6, readFileSync as readFileSync7, writeFileSync as writeFileSync6 } from "fs";
864
961
  import { homedir as homedir4 } from "os";
@@ -920,7 +1017,7 @@ async function resolveIdentity(file) {
920
1017
  }
921
1018
 
922
1019
  // src/update.ts
923
- import { spawn } from "child_process";
1020
+ import { spawn as spawn2 } from "child_process";
924
1021
  var UPDATE_PKG = process.env.INPLAN_PKG || "inplan";
925
1022
  function compareVersions(a, b) {
926
1023
  const parts = (v) => v.split("-")[0].split(".").map((n) => Number.parseInt(n, 10) || 0);
@@ -948,7 +1045,7 @@ async function checkForUpdate(opts) {
948
1045
  }
949
1046
  function selfUpdate(pkg) {
950
1047
  return new Promise((resolve4) => {
951
- const child = spawn("npm", ["install", "-g", `${pkg}@latest`], { stdio: ["ignore", "pipe", "pipe"] });
1048
+ const child = spawn2("npm", ["install", "-g", `${pkg}@latest`], { stdio: ["ignore", "pipe", "pipe"] });
952
1049
  let output2 = "";
953
1050
  child.stdout?.on("data", (d) => output2 += d);
954
1051
  child.stderr?.on("data", (d) => output2 += d);
@@ -1278,13 +1375,13 @@ function spawnApp(file) {
1278
1375
  const env = { ...process.env, INPLAN_CLI: process.argv[1] ?? "" };
1279
1376
  const override = process.env.INPLAN_APP_CMD;
1280
1377
  if (override) {
1281
- const child = spawn2(override, [file], { detached: true, stdio: "ignore", shell: true, env });
1378
+ const child = spawn3(override, [file], { detached: true, stdio: "ignore", shell: true, env });
1282
1379
  child.unref();
1283
1380
  return child.pid ?? null;
1284
1381
  }
1285
1382
  const bundled = resolveBundledApp();
1286
1383
  if ("electron" in bundled) {
1287
- const child = spawn2(bundled.electron, [bundled.appMain, file], { detached: true, stdio: "ignore", env });
1384
+ const child = spawn3(bundled.electron, [bundled.appMain, file], { detached: true, stdio: "ignore", env });
1288
1385
  child.unref();
1289
1386
  return child.pid ?? null;
1290
1387
  }
@@ -1449,14 +1546,26 @@ async function doLogin(args) {
1449
1546
  const url = getFlag(args, "url") ?? process.env.INPLAN_SUPABASE_URL;
1450
1547
  const anonKey = getFlag(args, "anon") ?? process.env.INPLAN_SUPABASE_ANON_KEY;
1451
1548
  const refreshToken = getFlag(args, "refresh") ?? process.env.INPLAN_REFRESH_TOKEN;
1452
- if (!url || !anonKey || !refreshToken) {
1453
- process.stderr.write("usage: inplan login --url <url> --anon <anon-key> --refresh <refresh-token> [--email <e>]\n");
1454
- process.exit(64);
1455
- }
1456
1549
  const email = getFlag(args, "email");
1457
- saveAuth({ url, anonKey, refreshToken, ...email ? { email } : {} });
1458
- await persistCloudIdentity();
1459
- output({ status: "logged_in", url, ...email ? { email } : {} });
1550
+ if (url && anonKey && refreshToken) {
1551
+ saveAuth({ url, anonKey, refreshToken, ...email ? { email } : {} });
1552
+ await persistCloudIdentity();
1553
+ output({ status: "logged_in", url, ...email ? { email } : {} });
1554
+ return;
1555
+ }
1556
+ try {
1557
+ const auth = await browserLogin({ onUrl: (u) => process.stderr.write(`Opening your browser to sign in:
1558
+ ${u}
1559
+ If it didn't open, paste that URL into your browser.
1560
+ `) });
1561
+ saveAuth(auth);
1562
+ await persistCloudIdentity();
1563
+ output({ status: "logged_in", url: auth.url, ...auth.email ? { email: auth.email } : {} });
1564
+ } catch (e) {
1565
+ process.stderr.write(`inplan login: ${e instanceof Error ? e.message : String(e)}
1566
+ `);
1567
+ process.exit(1);
1568
+ }
1460
1569
  }
1461
1570
  async function persistCloudIdentity() {
1462
1571
  try {
@@ -2091,7 +2200,7 @@ async function main() {
2091
2200
  );
2092
2201
  if (!cmd || !["open", "wait", "signal", "message", "relay", "status", "promote", "demote", "upload"].includes(cmd)) {
2093
2202
  process.stderr.write(
2094
- 'usage: inplan <open|wait|signal> <file|--remote DOC_ID> [--model NAME] [--cursor N] [--confirmed-comment-deletion=a,b] [--done] [--reload]\n inplan message <file> "your message" (relay a note to the editor status bar)\n inplan relay [--hook <kind> | --text <s> [--activity]] (agent-hook \u2192 editor; resolves the active doc)\n inplan status <file>\n inplan upload <file> [--org <slug>] [--repo <name>] [--path <p>] (Collaborate on Cloud)\n inplan promote <file> --cloud-doc <docId> [--locator org/repo/path]\n inplan demote <file>\n inplan login --url <url> --anon <anon-key> --refresh <refresh-token> [--email <e>]\n inplan whoami | logout\n'
2203
+ 'usage: inplan <open|wait|signal> <file|--remote DOC_ID> [--model NAME] [--cursor N] [--confirmed-comment-deletion=a,b] [--done] [--reload]\n inplan message <file> "your message" (relay a note to the editor status bar)\n inplan relay [--hook <kind> | --text <s> [--activity]] (agent-hook \u2192 editor; resolves the active doc)\n inplan status <file>\n inplan upload <file> [--org <slug>] [--repo <name>] [--path <p>] (Collaborate on Cloud)\n inplan promote <file> --cloud-doc <docId> [--locator org/repo/path]\n inplan demote <file>\n inplan login (opens the browser to sign in; or --url <url> --anon <key> --refresh <token> for scripts)\n inplan whoami | logout\n'
2095
2204
  );
2096
2205
  process.exit(64);
2097
2206
  }
package/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "inplan",
3
- "version": "0.1.14",
3
+ "version": "0.1.15",
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": {