inplan 0.1.21 → 0.1.23
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/bin/cli.js +157 -6
- package/package.json +3 -3
- package/skill/SKILL.md +24 -1
package/bin/cli.js
CHANGED
|
@@ -19,7 +19,29 @@ function isDocComment(c) {
|
|
|
19
19
|
function isSpanComment(c) {
|
|
20
20
|
return !isReply(c) && !isDocComment(c);
|
|
21
21
|
}
|
|
22
|
+
var ID_PREFIX = "cmt-";
|
|
23
|
+
var ID_LEN = 6;
|
|
22
24
|
var COMMENT_ID_RE = /^cmt-[0-9a-z]+$/;
|
|
25
|
+
function isTaken(taken, id) {
|
|
26
|
+
if (!taken) return false;
|
|
27
|
+
return typeof taken === "function" ? taken(id) : taken.has(id);
|
|
28
|
+
}
|
|
29
|
+
function randomBase36(len) {
|
|
30
|
+
const bytes = new Uint8Array(len);
|
|
31
|
+
globalThis.crypto.getRandomValues(bytes);
|
|
32
|
+
let out = "";
|
|
33
|
+
for (let i = 0; i < len; i++) {
|
|
34
|
+
out += (bytes[i] % 36).toString(36);
|
|
35
|
+
}
|
|
36
|
+
return out;
|
|
37
|
+
}
|
|
38
|
+
function genId(taken) {
|
|
39
|
+
for (let attempt = 0; attempt < 1e3; attempt++) {
|
|
40
|
+
const id = ID_PREFIX + randomBase36(ID_LEN);
|
|
41
|
+
if (!isTaken(taken, id)) return id;
|
|
42
|
+
}
|
|
43
|
+
throw new Error("genId: failed to generate a unique id after 1000 attempts");
|
|
44
|
+
}
|
|
23
45
|
var ANCHOR_LINK_RE = /\]\(#(cmt-[0-9a-z]+)\)/gi;
|
|
24
46
|
function stripCode(body) {
|
|
25
47
|
let inFence = false;
|
|
@@ -1110,14 +1132,28 @@ function evaluateAgentEdit(canonicalText, currentText, confirmed) {
|
|
|
1110
1132
|
const current = parse(currentText);
|
|
1111
1133
|
const canonical = parse(canonicalText);
|
|
1112
1134
|
const lost = detectLostComments(canonical, current);
|
|
1113
|
-
const
|
|
1114
|
-
const
|
|
1115
|
-
|
|
1135
|
+
const deletionGraph = new Map([...current.comments, ...canonical.comments].map((c) => [c.id, c]));
|
|
1136
|
+
const removedSet = new Set(lost.filter((c) => confirmed.has(c.id)).map((c) => c.id));
|
|
1137
|
+
for (let grew = true; grew; ) {
|
|
1138
|
+
grew = false;
|
|
1139
|
+
for (const c of deletionGraph.values()) {
|
|
1140
|
+
if (c.parentId !== void 0 && removedSet.has(c.parentId) && confirmed.has(c.id) && !removedSet.has(c.id)) {
|
|
1141
|
+
removedSet.add(c.id);
|
|
1142
|
+
grew = true;
|
|
1143
|
+
}
|
|
1144
|
+
}
|
|
1145
|
+
}
|
|
1146
|
+
const removedIds = [...removedSet];
|
|
1116
1147
|
const accepted = {
|
|
1117
1148
|
body: current.body,
|
|
1118
1149
|
comments: current.comments.filter((c) => !removedSet.has(c.id))
|
|
1119
1150
|
};
|
|
1120
|
-
const
|
|
1151
|
+
const dangling = [...deletionGraph.values()].filter((c) => c.parentId !== void 0 && removedSet.has(c.parentId) && !removedSet.has(c.id));
|
|
1152
|
+
const danglingIds = new Set(dangling.map((c) => c.id));
|
|
1153
|
+
const unconfirmed = [...lost.filter((c) => !confirmed.has(c.id)), ...dangling];
|
|
1154
|
+
const integrityErrors = checkIntegrity(accepted).errors.filter(
|
|
1155
|
+
(e) => e.code !== "span_missing_link" && !(e.code === "missing_parent" && e.commentId !== void 0 && danglingIds.has(e.commentId))
|
|
1156
|
+
);
|
|
1121
1157
|
return {
|
|
1122
1158
|
integrityOk: integrityErrors.length === 0,
|
|
1123
1159
|
integrityErrors,
|
|
@@ -1129,6 +1165,69 @@ function evaluateAgentEdit(canonicalText, currentText, confirmed) {
|
|
|
1129
1165
|
};
|
|
1130
1166
|
}
|
|
1131
1167
|
|
|
1168
|
+
// src/commentAdd.ts
|
|
1169
|
+
var AddCommentError = class extends Error {
|
|
1170
|
+
};
|
|
1171
|
+
function isChoice(v) {
|
|
1172
|
+
if (typeof v !== "object" || v === null) return false;
|
|
1173
|
+
const c = v;
|
|
1174
|
+
return typeof c.label === "string" && (c.description === void 0 || typeof c.description === "string");
|
|
1175
|
+
}
|
|
1176
|
+
function isQuestion(v) {
|
|
1177
|
+
if (typeof v !== "object" || v === null) return false;
|
|
1178
|
+
const q = v;
|
|
1179
|
+
return typeof q.multiSelect === "boolean" && Array.isArray(q.choices) && q.choices.every(isChoice);
|
|
1180
|
+
}
|
|
1181
|
+
function placeSpanLink(body, span, id) {
|
|
1182
|
+
const first = body.indexOf(span);
|
|
1183
|
+
if (first === -1) throw new AddCommentError(`comment: --span text not found in the body: ${JSON.stringify(span)}`);
|
|
1184
|
+
if (body.indexOf(span, first + span.length) !== -1) {
|
|
1185
|
+
throw new AddCommentError(
|
|
1186
|
+
`comment: --span text appears more than once in the body, so the target is ambiguous: ${JSON.stringify(span)}. Include more surrounding context to make it unique.`
|
|
1187
|
+
);
|
|
1188
|
+
}
|
|
1189
|
+
return body.slice(0, first) + `[${span}](#${id})` + body.slice(first + span.length);
|
|
1190
|
+
}
|
|
1191
|
+
function addComment(currentText, input) {
|
|
1192
|
+
const targetCount = (input.parentId ? 1 : 0) + (input.doc ? 1 : 0) + (input.span ? 1 : 0);
|
|
1193
|
+
if (targetCount > 1) {
|
|
1194
|
+
throw new AddCommentError("comment: --parent-id, --doc, and --span are mutually exclusive");
|
|
1195
|
+
}
|
|
1196
|
+
if (targetCount === 0) {
|
|
1197
|
+
throw new AddCommentError(
|
|
1198
|
+
'comment: pass --parent-id <id> (reply), --doc (document-level), or --span "<exact body text>" (anchored to that text)'
|
|
1199
|
+
);
|
|
1200
|
+
}
|
|
1201
|
+
if (input.question !== void 0 && !isQuestion(input.question)) {
|
|
1202
|
+
throw new AddCommentError('comment: --question must be shaped like { "multiSelect": boolean, "choices": [{ "label": string }, ...] }');
|
|
1203
|
+
}
|
|
1204
|
+
const doc = parse(currentText);
|
|
1205
|
+
if (input.parentId && !doc.comments.some((c) => c.id === input.parentId)) {
|
|
1206
|
+
throw new AddCommentError(`comment: no such parent id: ${input.parentId}`);
|
|
1207
|
+
}
|
|
1208
|
+
const id = genId(new Set(doc.comments.map((c) => c.id)));
|
|
1209
|
+
const now = input.now ?? (() => /* @__PURE__ */ new Date());
|
|
1210
|
+
const comment = {
|
|
1211
|
+
id,
|
|
1212
|
+
...input.parentId ? { parentId: input.parentId } : input.doc ? { anchor: "doc" } : {},
|
|
1213
|
+
text: input.text,
|
|
1214
|
+
author: input.author,
|
|
1215
|
+
date: now().toISOString(),
|
|
1216
|
+
resolved: false,
|
|
1217
|
+
...input.question ? { question: input.question } : {},
|
|
1218
|
+
...input.mayResolve ? { may_resolve: true } : {}
|
|
1219
|
+
};
|
|
1220
|
+
const body = input.span ? placeSpanLink(doc.body, input.span, id) : doc.body;
|
|
1221
|
+
const next = { body, comments: [...doc.comments, comment], version: doc.version };
|
|
1222
|
+
const integrity = checkIntegrity(next);
|
|
1223
|
+
if (!integrity.ok) {
|
|
1224
|
+
throw new AddCommentError(
|
|
1225
|
+
`comment: the document already had a structural problem before this call (this comment didn't cause it): ${integrity.errors.map((e) => e.message).join("; ")}`
|
|
1226
|
+
);
|
|
1227
|
+
}
|
|
1228
|
+
return { text: serialize(next), comment };
|
|
1229
|
+
}
|
|
1230
|
+
|
|
1132
1231
|
// src/pluginGate.ts
|
|
1133
1232
|
import { homedir as homedir5 } from "os";
|
|
1134
1233
|
import { join as join7 } from "path";
|
|
@@ -2252,6 +2351,13 @@ async function doUpload(file, args) {
|
|
|
2252
2351
|
writeStatus(docPaths(file).statusPath, status);
|
|
2253
2352
|
output({ status: "uploaded", cloudDocId, ...org?.slug ? { locator: { org: org.slug, repo, path } } : {} });
|
|
2254
2353
|
}
|
|
2354
|
+
function rejectCommentOnCloud(cmd, hasLocalFile) {
|
|
2355
|
+
if (cmd !== "comment") return;
|
|
2356
|
+
const fallback = hasLocalFile ? " \u2014 edit the file directly and `wait`." : ".";
|
|
2357
|
+
process.stderr.write(`inplan comment: cloud docs aren't supported yet${fallback}
|
|
2358
|
+
`);
|
|
2359
|
+
process.exit(64);
|
|
2360
|
+
}
|
|
2255
2361
|
function routeFor(file, cmd, args) {
|
|
2256
2362
|
const p = docPaths(file);
|
|
2257
2363
|
const status = readStatus(p.statusPath);
|
|
@@ -2317,9 +2423,9 @@ async function main() {
|
|
|
2317
2423
|
const confirmed = new Set(
|
|
2318
2424
|
(getFlag(args, "confirmed-comment-deletion") ?? "").split(",").map((s) => s.trim()).filter(Boolean)
|
|
2319
2425
|
);
|
|
2320
|
-
if (!cmd || !["open", "wait", "signal", "message", "relay", "status", "promote", "demote", "upload"].includes(cmd)) {
|
|
2426
|
+
if (!cmd || !["open", "wait", "signal", "message", "comment", "relay", "status", "promote", "demote", "upload"].includes(cmd)) {
|
|
2321
2427
|
process.stderr.write(
|
|
2322
|
-
'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>] [--evict-lru] (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'
|
|
2428
|
+
'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 comment <file> (--parent-id <id>|--doc|--span "text") --text "..." [--model NAME] [--may-resolve] [--question <json>]\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>] [--evict-lru] (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'
|
|
2323
2429
|
);
|
|
2324
2430
|
process.exit(64);
|
|
2325
2431
|
}
|
|
@@ -2329,6 +2435,7 @@ async function main() {
|
|
|
2329
2435
|
}
|
|
2330
2436
|
const remoteDocId = getFlag(args, "remote");
|
|
2331
2437
|
if (remoteDocId) {
|
|
2438
|
+
rejectCommentOnCloud(cmd, false);
|
|
2332
2439
|
await runRemote(cmd, remoteDocId, explicitCursor, confirmed, args, void 0, model);
|
|
2333
2440
|
return;
|
|
2334
2441
|
}
|
|
@@ -2365,6 +2472,7 @@ async function main() {
|
|
|
2365
2472
|
return;
|
|
2366
2473
|
}
|
|
2367
2474
|
if (route.kind === "cloud") {
|
|
2475
|
+
rejectCommentOnCloud(cmd, true);
|
|
2368
2476
|
await runRemote(cmd, route.docId, explicitCursor, confirmed, args, file, model);
|
|
2369
2477
|
return;
|
|
2370
2478
|
}
|
|
@@ -2399,6 +2507,49 @@ async function main() {
|
|
|
2399
2507
|
`);
|
|
2400
2508
|
process.exit(1);
|
|
2401
2509
|
}
|
|
2510
|
+
if (cmd === "comment") {
|
|
2511
|
+
const text = getFlag(args, "text");
|
|
2512
|
+
if (!text) {
|
|
2513
|
+
process.stderr.write(
|
|
2514
|
+
'inplan comment: usage: inplan comment <file> (--parent-id <id>|--doc|--span "exact body text") --text "..." [--model NAME] [--may-resolve] [--question <json>]\n'
|
|
2515
|
+
);
|
|
2516
|
+
process.exit(64);
|
|
2517
|
+
}
|
|
2518
|
+
const parentId = getFlag(args, "parent-id");
|
|
2519
|
+
const span = getFlag(args, "span");
|
|
2520
|
+
const questionRaw = getFlag(args, "question");
|
|
2521
|
+
let question;
|
|
2522
|
+
if (questionRaw !== void 0) {
|
|
2523
|
+
try {
|
|
2524
|
+
question = JSON.parse(questionRaw);
|
|
2525
|
+
} catch {
|
|
2526
|
+
process.stderr.write("inplan comment: --question must be valid JSON\n");
|
|
2527
|
+
process.exit(64);
|
|
2528
|
+
}
|
|
2529
|
+
}
|
|
2530
|
+
try {
|
|
2531
|
+
const currentText = readFileSync9(file, "utf8");
|
|
2532
|
+
const { text: nextText, comment } = addComment(currentText, {
|
|
2533
|
+
text,
|
|
2534
|
+
author: agentAuthorFor(model),
|
|
2535
|
+
...parentId ? { parentId } : {},
|
|
2536
|
+
...hasFlag(args, "doc") ? { doc: true } : {},
|
|
2537
|
+
...span ? { span } : {},
|
|
2538
|
+
...question ? { question } : {},
|
|
2539
|
+
mayResolve: hasFlag(args, "may-resolve")
|
|
2540
|
+
});
|
|
2541
|
+
writeFileSync8(file, nextText);
|
|
2542
|
+
output({ status: "commented", id: comment.id, date: comment.date, author: comment.author });
|
|
2543
|
+
} catch (err) {
|
|
2544
|
+
if (err instanceof AddCommentError) {
|
|
2545
|
+
process.stderr.write(`${err.message}
|
|
2546
|
+
`);
|
|
2547
|
+
process.exit(64);
|
|
2548
|
+
}
|
|
2549
|
+
throw err;
|
|
2550
|
+
}
|
|
2551
|
+
return;
|
|
2552
|
+
}
|
|
2402
2553
|
if (cmd === "open") {
|
|
2403
2554
|
ensureDocFile(file);
|
|
2404
2555
|
const p = docPaths(file);
|
package/package.json
CHANGED
|
@@ -1,6 +1,6 @@
|
|
|
1
1
|
{
|
|
2
2
|
"name": "inplan",
|
|
3
|
-
"version": "0.1.
|
|
3
|
+
"version": "0.1.23",
|
|
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": {
|
|
@@ -19,13 +19,13 @@
|
|
|
19
19
|
"LICENSE"
|
|
20
20
|
],
|
|
21
21
|
"engines": {
|
|
22
|
-
"node": ">=22"
|
|
22
|
+
"node": ">= 22.12.0"
|
|
23
23
|
},
|
|
24
24
|
"scripts": {
|
|
25
25
|
"postinstall": "node bin/cli.js install-skill --quiet || true"
|
|
26
26
|
},
|
|
27
27
|
"dependencies": {
|
|
28
|
-
"electron": "^
|
|
28
|
+
"electron": "^43.2.0",
|
|
29
29
|
"@hocuspocus/provider": "^2.15.3",
|
|
30
30
|
"@supabase/supabase-js": "^2.45.0",
|
|
31
31
|
"ws": "^8.18.0",
|
package/skill/SKILL.md
CHANGED
|
@@ -87,9 +87,24 @@ anchored comment is an inline Markdown link whose href is the comment id:
|
|
|
87
87
|
- **Span comment**: exactly one in-body `[text](#cmt-id)` link; no `parentId`/`anchor`.
|
|
88
88
|
- **Reply / answer**: `parentId` set, no link. An answer carries `selected: [labels]`.
|
|
89
89
|
- **Document-level**: `anchor: "doc"`, no link.
|
|
90
|
+
- **Incorporating an answer**: when you fold a question's answer into the body, keep the
|
|
91
|
+
anchor link — rewrite the linked text from the open question to the resulting statement,
|
|
92
|
+
don't delete the link. Anchoring is id-based, not text-based, so the link survives the
|
|
93
|
+
rewrite (`[Team size is fixed at 3.](#cmt-m4n5o6)` is fine). Signal that the thread is done
|
|
94
|
+
with `may_resolve` (below), not by removing its anchor. Only actually orphan a span
|
|
95
|
+
comment (drop its link) when its topic is genuinely gone, not merely answered — and then
|
|
96
|
+
follow the `confirm_required` protocol (see § Turn-taking).
|
|
90
97
|
- **Question**: `question.multiSelect` false = pick one (radio), true = pick many
|
|
91
98
|
(checkbox); the human may also answer with free text.
|
|
92
99
|
- Generate ids as `cmt-` + 6 base36 characters.
|
|
100
|
+
- **`date`**: you have no reliable clock, so never invent this by hand. Use `inplan comment
|
|
101
|
+
<file> (--parent-id <id>|--doc|--span "exact body text") --text "..." [--model NAME]
|
|
102
|
+
[--may-resolve] [--question <json>]` instead of hand-editing the JSON block — it stamps
|
|
103
|
+
`date` from the real system clock and fills `author` from `--model` for you (same as
|
|
104
|
+
`open`/`wait`), and prints the new comment's `id`/`date`/`author` back. `--span` covers the
|
|
105
|
+
span-comment case too: give it the exact, currently-unlinked body text to anchor to (it must
|
|
106
|
+
occur exactly once — add surrounding context if it's ambiguous) and it wraps that text in
|
|
107
|
+
the link itself, so you never hand-edit the body for this either.
|
|
93
108
|
- **`author`**: sign **every** comment you write with **your own model identity**, so
|
|
94
109
|
the human sees which model is talking. Always pass `--model "<your model>"` (e.g.
|
|
95
110
|
`--model "Opus 4.8"`) on `open`/`wait`; the wait result echoes the exact string to
|
|
@@ -158,7 +173,15 @@ the plan, then call `wait`.** Do not pass `--cursor` and do not hand-manage it.
|
|
|
158
173
|
listening. `humanLocked: false`.
|
|
159
174
|
- `confirm_required` — your edit removed an anchored comment (`lost`). If
|
|
160
175
|
intentional, re-run with `--confirmed-comment-deletion=<ids>`; otherwise
|
|
161
|
-
restore the anchor link and try again.
|
|
176
|
+
restore the anchor link and try again. Deleting a comment that has replies
|
|
177
|
+
orphans those replies too — `lost` only lists the comment itself, never its
|
|
178
|
+
descendants, so include every reply/reply-of-reply id in
|
|
179
|
+
`--confirmed-comment-deletion` as well, or you'll hit `missing_parent` on
|
|
180
|
+
the next `wait`. **These two options are the only remedies.** Never change a
|
|
181
|
+
comment's `anchor` or `parentId` field to dodge this gate — e.g. relabeling
|
|
182
|
+
an orphaned span comment as `anchor: "doc"` to make the missing-link check
|
|
183
|
+
stop applying to it. That's not a documented recovery path; it silently
|
|
184
|
+
miscategorizes the comment and routes around the confirm gate entirely.
|
|
162
185
|
- `integrity_error` — the document violates the comment grammar (`errors`).
|
|
163
186
|
Fix it and wait again.
|
|
164
187
|
- `closed` — the planning session is over; stop the loop. `reason` says what to do next:
|