inplan 0.3.6 → 0.3.8

This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
@@ -125,6 +125,22 @@ function parseLogLine(line) {
125
125
  function parseLog(text) {
126
126
  return text.split("\n").map((l) => l.trim()).filter((l) => l.length > 0).map(parseLogLine);
127
127
  }
128
+ function draftPendingFrom(entries) {
129
+ let model = null;
130
+ for (const e of entries) {
131
+ if (e.type === LogEventType.DraftPending) {
132
+ const m = e.payload?.model;
133
+ model = typeof m === "string" && m.trim() ? m : null;
134
+ } else if (e.actor === "agent" && (e.type === LogEventType.DocumentEdited || e.type === LogEventType.AgentRevisionProposed)) {
135
+ model = null;
136
+ } else if (e.type === LogEventType.SessionClosed) {
137
+ model = null;
138
+ } else if (e.actor === "user" && (e.type === LogEventType.DocumentEdited || e.type === LogEventType.TurnEnded)) {
139
+ model = null;
140
+ }
141
+ }
142
+ return model ? { model } : null;
143
+ }
128
144
  function mintProposalId() {
129
145
  const c = globalThis.crypto;
130
146
  if (c?.randomUUID) return c.randomUUID();
@@ -712,28 +728,10 @@ class Session {
712
728
  }
713
729
  }
714
730
  }
715
- /** The model an agent named when it created this document with `inplan open`, while its first
716
- * draft is still to come. Null otherwise. The log is never reset, so the entry must be retired by
717
- * whatever ends that expectation — not only the draft arriving (as an edit, or parked as a
718
- * proposal), but the session it was raised in closing, or the human saving the document.
719
- * Otherwise an agent that died before writing, or a page the human later cleared, would bring the
720
- * banner back on some later open with no agent anywhere. */
731
+ /** The model an agent named when it created this document, while its first draft is still to come
732
+ * (see draftPendingFrom in @inplan/core, which the CLI's tests drive with a real `inplan open`). */
721
733
  draftPending() {
722
- const entries = readLog(this.paths.logPath);
723
- let model = null;
724
- for (const e of entries) {
725
- if (e.type === LogEventType.DraftPending) {
726
- const m = e.payload?.model;
727
- model = typeof m === "string" && m.trim() ? m : null;
728
- } else if (e.actor === "agent" && (e.type === LogEventType.DocumentEdited || e.type === LogEventType.AgentRevised || e.type === LogEventType.AgentRevisionProposed)) {
729
- model = null;
730
- } else if (e.type === LogEventType.SessionClosed) {
731
- model = null;
732
- } else if (e.actor === "user" && (e.type === LogEventType.DocumentEdited || e.type === LogEventType.TurnEnded)) {
733
- model = null;
734
- }
735
- }
736
- return model ? { model } : null;
734
+ return draftPendingFrom(readLog(this.paths.logPath));
737
735
  }
738
736
  async load() {
739
737
  const pendingDraft = this.draftPending();
package/bin/cli.js CHANGED
@@ -9,7 +9,7 @@ import { homedir as homedir7 } from "os";
9
9
  import { basename as basename3, dirname as dirname11, extname, isAbsolute as isAbsolute2, join as join10, relative as relative4, resolve as resolve3 } from "path";
10
10
  import { fileURLToPath as fileURLToPath2, pathToFileURL as pathToFileURL2 } from "url";
11
11
 
12
- // ../core/dist/chunk-56Z7HGQ3.js
12
+ // ../core/dist/chunk-SJGNSLZ2.js
13
13
  function isReply(c) {
14
14
  return c.parentId !== void 0;
15
15
  }
@@ -4037,10 +4037,20 @@ async function relayText(file, text) {
4037
4037
  } catch {
4038
4038
  }
4039
4039
  }
4040
+ function relayStatus(obj, hookMode) {
4041
+ if (!hookMode) {
4042
+ output(obj);
4043
+ return;
4044
+ }
4045
+ process.stdout.write("{}\n");
4046
+ if (process.env.INPLAN_RELAY_DEBUG === "1") process.stderr.write(`inplan: relay ${JSON.stringify(obj)}
4047
+ `);
4048
+ }
4040
4049
  async function doRelay(args) {
4050
+ const hookMode = args.some((a) => a === "--hook" || a.startsWith("--hook="));
4041
4051
  const file = activeDocForCwd(process.cwd());
4042
4052
  if (!file) {
4043
- output({ status: "relay_skipped", reason: "no_active_doc" });
4053
+ relayStatus({ status: "relay_skipped", reason: "no_active_doc" }, hookMode);
4044
4054
  return;
4045
4055
  }
4046
4056
  const hook = getFlag(args, "hook");
@@ -4060,11 +4070,11 @@ async function doRelay(args) {
4060
4070
  }
4061
4071
  const clean = notes.map((n) => n.trim().slice(0, 2e3)).filter(Boolean);
4062
4072
  if (clean.length === 0) {
4063
- output({ status: "relay_skipped", reason: "no_text" });
4073
+ relayStatus({ status: "relay_skipped", reason: "no_text" }, hookMode);
4064
4074
  return;
4065
4075
  }
4066
4076
  for (const n of clean) await relayText(file, n);
4067
- output({ status: "relayed", count: clean.length });
4077
+ relayStatus({ status: "relayed", count: clean.length }, hookMode);
4068
4078
  }
4069
4079
  function skillTargets() {
4070
4080
  const home = homedir7();
package/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "inplan",
3
- "version": "0.3.6",
3
+ "version": "0.3.8",
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": {