@dreamlake/dreamlake-cli 0.97.2 → 0.98.0
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/dist/api/client.d.ts +1 -1
- package/dist/api/client.js +4 -4
- package/dist/api/http.d.ts +48 -1
- package/dist/api/http.js +111 -4
- package/dist/api/index.d.ts +17 -513
- package/dist/api/index.js +6 -2
- package/dist/api/note-edits.d.ts +40 -2
- package/dist/api/note-edits.js +197 -2
- package/dist/api/note-events.d.ts +40 -4
- package/dist/api/note-events.js +55 -2
- package/dist/api/note-facade.d.ts +268 -0
- package/dist/api/note-facade.js +376 -0
- package/dist/api/note-reading.d.ts +27 -0
- package/dist/api/note-reading.js +27 -0
- package/dist/api/note-write.d.ts +110 -0
- package/dist/api/note-write.js +217 -0
- package/dist/api/notes.d.ts +33 -44
- package/dist/api/notes.js +44 -34
- package/dist/api/sessions.d.ts +5 -5
- package/dist/cli/client.d.ts +2 -41
- package/dist/cli/client.js +13 -90
- package/dist/cli/help-examples.generated.js +1 -1
- package/dist/cli/notes/api-transport.js +6 -6
- package/dist/cli/notes/document.d.ts +32 -26
- package/dist/cli/notes/document.js +150 -95
- package/dist/cli/notes/edit-commands.d.ts +26 -5
- package/dist/cli/notes/edit-commands.js +163 -36
- package/dist/cli/notes/events.d.ts +3 -33
- package/dist/cli/notes/events.js +4 -51
- package/dist/cli/notes/html-read.d.ts +6 -0
- package/dist/cli/notes/html-read.js +12 -0
- package/dist/cli/notes/index.d.ts +10 -1
- package/dist/cli/notes/index.js +98 -27
- package/dist/cli/notes/move-command.d.ts +4 -0
- package/dist/cli/notes/move-command.js +7 -0
- package/dist/cli/sessions/runner/serve.d.ts +1 -1
- package/dist/cli/vault/sshTransfer.d.ts +1 -1
- package/dist/cli/version.d.ts +1 -1
- package/dist/cli/version.js +1 -1
- package/package.json +9 -9
package/dist/cli/notes/index.js
CHANGED
|
@@ -18,8 +18,9 @@ import { runNotesTextSelect } from "./select-command.js";
|
|
|
18
18
|
import { readFileSync } from "node:fs";
|
|
19
19
|
import { runMediaUpload } from "./media-commands.js";
|
|
20
20
|
import { runNotesLinger } from "./linger.js";
|
|
21
|
-
import { runDocumentRead, runDocumentPatch, readDocumentSnapshot, readStdinBytes,
|
|
22
|
-
import {
|
|
21
|
+
import { runDocumentRead, runDocumentPatch, runNotesCommandStatus, readDocumentSnapshot, readStdinBytes, submitDocumentPatch, printPatchReceipt, documentWriteError, commandIdFlag, withCommandId, canonicalInput } from "./document.js";
|
|
22
|
+
import { appendPlan, writePlan } from "../../api/note-write.js";
|
|
23
|
+
import { NotePatchError } from "./character-plan.js";
|
|
23
24
|
import { HttpError, requestJson, requestRaw } from "../client.js";
|
|
24
25
|
import { runNotesDelete, runNotesFind, runNotesInsert, runNotesReplace, runNotesGrep, runNotesSelect, runNotesToc, } from "./edit-commands.js";
|
|
25
26
|
import { runFilesCat, runFilesPreview, runFilesCopy, runFilesDownload, runFilesList, runFilesMove, runFilesRestore, runFilesRm, runFilesUpload, runFilesWrite, runFilesOperation, } from "./files-commands.js";
|
|
@@ -125,7 +126,7 @@ export async function resolveNote(c, ref) {
|
|
|
125
126
|
}
|
|
126
127
|
/** Body text from --file, --text, or stdin. Exactly one, so an empty write is
|
|
127
128
|
* always deliberate rather than the result of a forgotten flag. */
|
|
128
|
-
async function bodyFrom(opts, nativeSourceStdin = false) {
|
|
129
|
+
export async function bodyFrom(opts, nativeSourceStdin = false) {
|
|
129
130
|
const given = [opts.file, opts.text].filter((v) => v !== undefined).length;
|
|
130
131
|
if (given > 1) {
|
|
131
132
|
fail("pass one of --file or --text, not both");
|
|
@@ -220,11 +221,11 @@ export function registerNotesCommand(program) {
|
|
|
220
221
|
strict(notes.command("projects"))
|
|
221
222
|
.argument("<note-id>", "stable Note ID")
|
|
222
223
|
.description("inspect current project filing and server-computed filing permissions (JSON)")
|
|
223
|
-
.
|
|
224
|
+
.option("--namespace <slug>", "the Note's owning namespace (or --ns)")
|
|
224
225
|
.action(async (id, opts) => { process.exitCode = await runNotesProjects(id, opts); });
|
|
225
226
|
// ── notes create ──
|
|
226
227
|
strict(notes.command("create"))
|
|
227
|
-
.argument("
|
|
228
|
+
.argument("[name]", "the note's title (default: Untitled)")
|
|
228
229
|
.description("create a note, optionally with a body")
|
|
229
230
|
.option("--project <slug>", "file the new Note in this same-namespace project (repeatable)", (value, previous) => [...previous, value], [])
|
|
230
231
|
.option("--file <path>", "initial body from a file ('-' for stdin)")
|
|
@@ -238,6 +239,7 @@ export function registerNotesCommand(program) {
|
|
|
238
239
|
.description("list notes in one namespace")
|
|
239
240
|
.option("--include-archived", "include archived notes")
|
|
240
241
|
.option("--limit <n>", "page size", "50")
|
|
242
|
+
.option("--offset <n>", "skip this many rows first (zero-based paging: 0, 20, 40, …)")
|
|
241
243
|
.option("--namespace <slug>", "whose notes (default: your personal namespace, not an org's)")
|
|
242
244
|
.option("--shared", "list notes other people shared with you, across namespaces")
|
|
243
245
|
.option("--json", "emit JSON")
|
|
@@ -397,20 +399,21 @@ export function registerNotesCommand(program) {
|
|
|
397
399
|
.action(async (ref, opts) => { process.exitCode = await runNotesSections(ref, opts); });
|
|
398
400
|
// ── notes read ──
|
|
399
401
|
strict(notes.command("read"))
|
|
400
|
-
.option("--
|
|
401
|
-
.option("--
|
|
402
|
+
.option("--lines <a:b>", "only these source lines (1-based, inclusive) with their code-point address; never a complete body")
|
|
403
|
+
.option("--start-line <n>", "legacy: first line to read (1-based, inclusive)")
|
|
404
|
+
.option("--end-line <n>", "legacy: last line to read (1-based, inclusive)")
|
|
402
405
|
// Positional OR --note. The issue's examples use `--note`, matching the
|
|
403
406
|
// edit commands; the positional came first and scripts use it. Accepting
|
|
404
407
|
// one form and rejecting the other would make half the documented recipes
|
|
405
408
|
// fail on a flag rather than on anything real.
|
|
406
409
|
.argument("[note]", "note id, slug or name (or pass --note)")
|
|
407
410
|
.option("--note <ref>", "the note to read, as an alternative to the positional")
|
|
408
|
-
.description("read canonical source or a mapped HTML snapshot with its write revision")
|
|
411
|
+
.description("read the mapped Markdown view, exact canonical source (--json, --view source) or a mapped HTML snapshot with its write revision")
|
|
409
412
|
.option("--linger", "stay present and stream batched diffs, presence and activity in the foreground")
|
|
410
413
|
.option("--debounce <duration>", "edit quiet period with --linger (default 2s; 250ms–5m)")
|
|
411
414
|
.option("--throttle <duration>", "minimum output interval with --linger (default 2s; 250ms–5m)")
|
|
412
415
|
.option("--intent <text>", "with --linger: one short sentence of purpose, shown on your presence card")
|
|
413
|
-
.option("--view <view>", "
|
|
416
|
+
.option("--view <view>", "markdown with address hints (default for text), source (exact; default for --json), or html with source attributes")
|
|
414
417
|
.option("--version <version-id>", "read an immutable saved version instead of the live note")
|
|
415
418
|
.option("--at <revision>", "read a retained snapshot without advancing to the current revision")
|
|
416
419
|
.option("--toc", "read only the heading outline as mapped HTML")
|
|
@@ -448,6 +451,7 @@ export function registerNotesCommand(program) {
|
|
|
448
451
|
.option("--legacy", "use the retained ETag/body replacement write")
|
|
449
452
|
.option("--base-revision <revision>", "compare the target body to this original retained source snapshot")
|
|
450
453
|
.option("--exact", "require the original revision to remain current")
|
|
454
|
+
.option("--command-id <id>", "caller-stable id (8–128 chars of A-Za-z0-9._:-); a retry with the same id returns the same receipt")
|
|
451
455
|
.option("--namespace <slug>", "whose notes (default: your personal namespace, not an org's)")
|
|
452
456
|
.option("--json", "emit JSON")
|
|
453
457
|
.option("--dry-run", "show the write that would be sent, and send nothing")
|
|
@@ -462,6 +466,7 @@ export function registerNotesCommand(program) {
|
|
|
462
466
|
.option("--legacy", "use the retained ETag/body replacement append")
|
|
463
467
|
.option("--base-revision <revision>", "append against this original retained source snapshot")
|
|
464
468
|
.option("--exact", "require the original revision to remain current")
|
|
469
|
+
.option("--command-id <id>", "caller-stable id (8–128 chars of A-Za-z0-9._:-); a retry with the same id returns the same receipt")
|
|
465
470
|
.option("--namespace <slug>", "whose notes (default: your personal namespace, not an org's)")
|
|
466
471
|
.option("--json", "emit JSON")
|
|
467
472
|
.option("--dry-run", "show the write that would be sent, and send nothing")
|
|
@@ -469,7 +474,7 @@ export function registerNotesCommand(program) {
|
|
|
469
474
|
// ── notes patch ──
|
|
470
475
|
strict(notes.command("patch"))
|
|
471
476
|
.argument("<note>", "note id, slug or name")
|
|
472
|
-
.description("apply a source patch to its original RTC identities; merge by default, exact revision checks opt-in")
|
|
477
|
+
.description("apply a source patch to its original RTC identities; merge by default, exact revision checks opt-in (sends without reading: the reading-view header check is best-effort here, the server enforces it)")
|
|
473
478
|
.option("--format <format>", "inline-dff (default) or diff")
|
|
474
479
|
.option("--legacy", "use the previous unified diff/etag interface")
|
|
475
480
|
.option("--file <path>", "read the diff from a file ('-' for stdin)")
|
|
@@ -477,6 +482,7 @@ export function registerNotesCommand(program) {
|
|
|
477
482
|
.option("--exact", "require the current note to match the original revision for this request")
|
|
478
483
|
.option("--base-revision <revision>", "original saved snapshot used to validate source and RTC identities")
|
|
479
484
|
.option("--if-match <revision>", "compatibility exact-mode token; must match --base-revision when both are given")
|
|
485
|
+
.option("--command-id <id>", "caller-stable id (8–128 chars of A-Za-z0-9._:-); a retry with the same id returns the same receipt")
|
|
480
486
|
.option("--force", "legacy only: apply without a precondition")
|
|
481
487
|
.option("--namespace <slug>", "whose notes (default: your personal namespace, not an org's)")
|
|
482
488
|
.option("--json", "emit JSON")
|
|
@@ -509,21 +515,28 @@ export function registerNotesCommand(program) {
|
|
|
509
515
|
.option("--regex <pattern>", "search with a JavaScript regular expression")
|
|
510
516
|
.option("--flags <flags>", "regex flags: i, m, s, u (not g — see --all)")
|
|
511
517
|
.option("--limit <n>", "stop after this many matches")
|
|
512
|
-
.option("--
|
|
518
|
+
.option("--at <revision>", "search the retained snapshot at this revision")
|
|
519
|
+
.option("--case-sensitive", "match case for a literal query (the default)")
|
|
520
|
+
.option("--no-case-sensitive", "ignore case for a literal query")
|
|
521
|
+
.option("--json", "emit matches with note, hash and the source revision")
|
|
513
522
|
.option("--namespace <slug>", "whose notes (default: your personal namespace, not an org's)")
|
|
514
523
|
.action(async (query, opts) => { process.exitCode = await runNotesFind(query, opts); });
|
|
515
524
|
strict(notes.command("toc"))
|
|
516
525
|
.description("the note's outline, with line and character ranges")
|
|
517
526
|
.option("--note <ref>", "the note: slug, id or exact title")
|
|
518
527
|
.option("--html", "parse as HTML rather than Markdown")
|
|
519
|
-
.option("--
|
|
528
|
+
.option("--at <revision>", "outline the retained snapshot at this revision")
|
|
529
|
+
.option("--json", "emit entries with note, hash and the source revision")
|
|
520
530
|
.option("--namespace <slug>", "whose notes (default: your personal namespace, not an org's)")
|
|
521
531
|
.action(async (opts) => { process.exitCode = await runNotesToc(opts); });
|
|
522
532
|
strict(notes.command("replace"))
|
|
523
533
|
.description("replace text; one match required unless --all or --count")
|
|
524
|
-
.argument("[query]", "literal text to replace")
|
|
534
|
+
.argument("[query]", "literal text to replace (or the note ID when --lines/--address select the span)")
|
|
525
535
|
.option("--note <ref>", "the note: slug, id or exact title")
|
|
526
536
|
.option("--text <text>", "the replacement")
|
|
537
|
+
.option("--file <path>", "the replacement from a file ('-' for stdin), exact UTF-8")
|
|
538
|
+
.option("--lines <a:b>", "replace source lines a..b (1-based, inclusive)")
|
|
539
|
+
.option("--address <id>", "replace the full original span of this mapped element (e.g. s1.p2)")
|
|
527
540
|
.option("--selector <css>", "scope the query to one HTML element")
|
|
528
541
|
.option("--regex <pattern>", "match with a JavaScript regular expression")
|
|
529
542
|
.option("--flags <flags>", "regex flags: i, m, s, u")
|
|
@@ -536,15 +549,21 @@ export function registerNotesCommand(program) {
|
|
|
536
549
|
.option("--legacy", "use the retained ETag/body replacement replace")
|
|
537
550
|
.option("--base-revision <revision>", "target this original retained source snapshot")
|
|
538
551
|
.option("--exact", "require the original revision to remain current")
|
|
552
|
+
.option("--command-id <id>", "caller-stable id (8–128 chars of A-Za-z0-9._:-); a retry with the same id returns the same receipt")
|
|
539
553
|
.option("--dry-run", "print what would be written and stop")
|
|
540
554
|
.option("--json", "emit the new revision")
|
|
541
555
|
.option("--namespace <slug>", "whose notes (default: your personal namespace, not an org's)")
|
|
542
556
|
.option("--html <markup>", "with --selector: replace the element's contents with markup (not escaped)")
|
|
543
557
|
.action(async (query, opts) => { process.exitCode = await runNotesReplace(query, opts); });
|
|
544
558
|
strict(notes.command("insert"))
|
|
545
|
-
.description("insert text at a
|
|
559
|
+
.description("insert text before/after a mapped element, at a cursor, or at a line")
|
|
560
|
+
.argument("[note]", "note id (alternative to --note)")
|
|
546
561
|
.option("--note <ref>", "the note: slug, id or exact title")
|
|
547
|
-
.option("--text <text>", "what to insert")
|
|
562
|
+
.option("--text <text>", "what to insert, verbatim")
|
|
563
|
+
.option("--file <path>", "what to insert from a file ('-' for stdin), exact UTF-8")
|
|
564
|
+
.option("--before <id>", "insert at the start of this mapped element's full original span")
|
|
565
|
+
.option("--after <id>", "insert at the end of this mapped element's full original span")
|
|
566
|
+
.option("--cursor <n>", "insert at this original code-point position (0-based)")
|
|
548
567
|
.option("--line <n>", "insert before this line (1-based)")
|
|
549
568
|
.option("--ind <n>", "insert at this character position (0-based code points)")
|
|
550
569
|
.option("--if-match <etag>", "quoted ETag from notes read --legacy --json (not an rtc: revision)")
|
|
@@ -552,16 +571,20 @@ export function registerNotesCommand(program) {
|
|
|
552
571
|
.option("--legacy", "use the retained ETag/body replacement insert")
|
|
553
572
|
.option("--base-revision <revision>", "place text in this original retained source snapshot")
|
|
554
573
|
.option("--exact", "require the original revision to remain current")
|
|
574
|
+
.option("--command-id <id>", "caller-stable id (8–128 chars of A-Za-z0-9._:-); a retry with the same id returns the same receipt")
|
|
555
575
|
.option("--dry-run", "print what would be written and stop")
|
|
556
576
|
.option("--json", "emit the new revision")
|
|
557
577
|
.option("--namespace <slug>", "whose notes (default: your personal namespace, not an org's)")
|
|
558
578
|
.option("--selector <css>", "insert relative to this element instead of a line")
|
|
559
579
|
.option("--position <where>", "with --selector: before | after | prepend | append", "append")
|
|
560
|
-
.action(async (opts) => { process.exitCode = await runNotesInsert(opts); });
|
|
580
|
+
.action(async (note, opts) => { process.exitCode = await runNotesInsert(note, opts); });
|
|
561
581
|
strict(notes.command("delete"))
|
|
562
|
-
.
|
|
563
|
-
.
|
|
582
|
+
.alias("remove")
|
|
583
|
+
.description("remove text (selected source, never the note); one match required unless --all or --count")
|
|
584
|
+
.argument("[query]", "literal text to remove (or the note ID when --lines/--address select the span)")
|
|
564
585
|
.option("--note <ref>", "the note: slug, id or exact title")
|
|
586
|
+
.option("--lines <a:b>", "remove source lines a..b (1-based, inclusive)")
|
|
587
|
+
.option("--address <id>", "remove the full original span of this mapped element (e.g. s1.p2)")
|
|
565
588
|
.option("--selector <css>", "scope the query to one HTML element")
|
|
566
589
|
.option("--regex <pattern>", "match with a JavaScript regular expression")
|
|
567
590
|
.option("--flags <flags>", "regex flags: i, m, s, u")
|
|
@@ -574,10 +597,18 @@ export function registerNotesCommand(program) {
|
|
|
574
597
|
.option("--legacy", "use the retained ETag/body replacement delete")
|
|
575
598
|
.option("--base-revision <revision>", "target this original retained source snapshot")
|
|
576
599
|
.option("--exact", "require the original revision to remain current")
|
|
600
|
+
.option("--command-id <id>", "caller-stable id (8–128 chars of A-Za-z0-9._:-); a retry with the same id returns the same receipt")
|
|
577
601
|
.option("--dry-run", "print what would be written and stop")
|
|
578
602
|
.option("--json", "emit the new revision")
|
|
579
603
|
.option("--namespace <slug>", "whose notes (default: your personal namespace, not an org's)")
|
|
580
604
|
.action(async (query, opts) => { process.exitCode = await runNotesDelete(query, opts); });
|
|
605
|
+
strict(notes.command("command-status"))
|
|
606
|
+
.argument("<note>", "note id, slug or name")
|
|
607
|
+
.argument("<command-id>", "the --command-id of an earlier write")
|
|
608
|
+
.description("the durable outcome of one identified write: pending, accepted, no-write or unknown")
|
|
609
|
+
.option("--namespace <slug>", "whose notes (default: your personal namespace, not an org's)")
|
|
610
|
+
.option("--json", "emit JSON")
|
|
611
|
+
.action(async (ref, commandId, opts) => { process.exitCode = await runNotesCommandStatus(ref, commandId, opts); });
|
|
581
612
|
strict(notes.command("select"))
|
|
582
613
|
.description("publish an agent selection with --text, or report one HTML element by CSS")
|
|
583
614
|
.argument("[css]", "a CSS selector matching exactly one element (lookup only)")
|
|
@@ -606,6 +637,26 @@ export function registerNotesCommand(program) {
|
|
|
606
637
|
.option("--json", "emit JSON")
|
|
607
638
|
.option("--dry-run", "show the write that would be sent, and send nothing")
|
|
608
639
|
.action(async (ref, anchor, opts) => { process.exitCode = await runNotesRmSection(ref, anchor, opts); });
|
|
640
|
+
addNamespaceAlias(notes);
|
|
641
|
+
}
|
|
642
|
+
/** `--ns` aliases `--namespace` on every Notes command that takes one (Notes API
|
|
643
|
+
* contract: both are source context, never a destination). Registered after the
|
|
644
|
+
* tree is complete so later-added subcommands are covered too. */
|
|
645
|
+
function addNamespaceAlias(group) {
|
|
646
|
+
for (const cmd of group.commands) {
|
|
647
|
+
if (cmd.options.some(o => o.long === "--namespace") && !cmd.options.some(o => o.long === "--ns")) {
|
|
648
|
+
cmd.option("--ns <slug>", "alias of --namespace: the source namespace to look in");
|
|
649
|
+
cmd.hook("preAction", thisCommand => {
|
|
650
|
+
const o = thisCommand.opts();
|
|
651
|
+
if (o.ns === undefined)
|
|
652
|
+
return;
|
|
653
|
+
if (o.namespace !== undefined && o.namespace !== o.ns)
|
|
654
|
+
thisCommand.error("--namespace and --ns name different namespaces; give one", { exitCode: 1 });
|
|
655
|
+
thisCommand.setOptionValue("namespace", o.ns);
|
|
656
|
+
});
|
|
657
|
+
}
|
|
658
|
+
addNamespaceAlias(cmd);
|
|
659
|
+
}
|
|
609
660
|
}
|
|
610
661
|
// ─── implementations ──────────────────────────────────────────────────────────
|
|
611
662
|
export async function runNotesList(opts) {
|
|
@@ -615,7 +666,7 @@ export async function runNotesList(opts) {
|
|
|
615
666
|
try {
|
|
616
667
|
const rows = opts.shared
|
|
617
668
|
? (await requestJson(c.remote, "/me/notes/shared", { token: c.token, query: { includeArchived: opts.includeArchived } })).notes
|
|
618
|
-
: (await requestJson(c.remote, `/namespaces/${seg(c.ns)}/notes?limit=${encodeURIComponent(opts.limit ?? "50")}${opts.includeArchived ? "&includeArchived=true" : ""}`, { token: c.token })).notes;
|
|
669
|
+
: (await requestJson(c.remote, `/namespaces/${seg(c.ns)}/notes?limit=${encodeURIComponent(opts.limit ?? "50")}${opts.offset !== undefined ? `&offset=${encodeURIComponent(opts.offset)}` : ""}${opts.includeArchived ? "&includeArchived=true" : ""}`, { token: c.token })).notes;
|
|
619
670
|
if (opts.json)
|
|
620
671
|
return emitJson({ notes: rows }), 0;
|
|
621
672
|
if (rows.length === 0) {
|
|
@@ -823,8 +874,14 @@ export async function runNotesWrite(ref, opts) {
|
|
|
823
874
|
fail("--section/--legacy/--force/--if-match cannot combine with --base-revision or --exact");
|
|
824
875
|
return 1;
|
|
825
876
|
}
|
|
877
|
+
if (opts.commandId !== undefined) {
|
|
878
|
+
fail("--command-id requires the v2 write; it cannot combine with --section, --legacy, --force or --if-match");
|
|
879
|
+
return 1;
|
|
880
|
+
}
|
|
826
881
|
return runLegacyNotesWrite(ref, opts);
|
|
827
882
|
}
|
|
883
|
+
if (!commandIdFlag(opts))
|
|
884
|
+
return 1;
|
|
828
885
|
if (opts.baseRevision !== undefined && (!opts.baseRevision.trim() || opts.baseRevision === "*" || /[\r\n]/.test(opts.baseRevision))) {
|
|
829
886
|
fail("--base-revision requires the original retained revision");
|
|
830
887
|
return 1;
|
|
@@ -848,11 +905,7 @@ export async function runNotesWrite(ref, opts) {
|
|
|
848
905
|
if (!id)
|
|
849
906
|
return 1;
|
|
850
907
|
const source = await readDocumentSnapshot(c, id, opts.baseRevision);
|
|
851
|
-
const
|
|
852
|
-
const payload = documentEdits(source, edits.map(edit => ({ start: edit.start, end: edit.end, text: edit.replacementText })), opts.exact);
|
|
853
|
-
if (edits.length > PATCH_LIMITS.maxEdits || Buffer.byteLength(payload.patch, "utf8") > PATCH_LIMITS.maxPatchBytes) {
|
|
854
|
-
throw new NotePatchError("Generated source patch exceeds the edit/byte limit", "LIMIT_EXCEEDED");
|
|
855
|
-
}
|
|
908
|
+
const payload = withCommandId(writePlan(source, text, opts.exact ? "exact" : "merge"), opts);
|
|
856
909
|
if (opts.dryRun) {
|
|
857
910
|
const path = `/namespaces/${seg(c.ns)}/notes/${seg(id)}/body`;
|
|
858
911
|
if (opts.json)
|
|
@@ -994,8 +1047,14 @@ export async function runNotesAppend(ref, opts) {
|
|
|
994
1047
|
fail("--legacy/--force cannot combine with --base-revision or --exact");
|
|
995
1048
|
return 1;
|
|
996
1049
|
}
|
|
1050
|
+
if (opts.commandId !== undefined) {
|
|
1051
|
+
fail("--command-id requires the v2 write; it cannot combine with --legacy or --force");
|
|
1052
|
+
return 1;
|
|
1053
|
+
}
|
|
997
1054
|
return runLegacyNotesAppend(ref, opts);
|
|
998
1055
|
}
|
|
1056
|
+
if (!commandIdFlag(opts))
|
|
1057
|
+
return 1;
|
|
999
1058
|
if (opts.baseRevision !== undefined && (!opts.baseRevision.trim() || opts.baseRevision === "*" || /[\r\n]/.test(opts.baseRevision))) {
|
|
1000
1059
|
fail("--base-revision requires the original retained revision");
|
|
1001
1060
|
return 1;
|
|
@@ -1006,16 +1065,18 @@ export async function runNotesAppend(ref, opts) {
|
|
|
1006
1065
|
const addition = await bodyFrom(opts);
|
|
1007
1066
|
if (addition === null)
|
|
1008
1067
|
return 1;
|
|
1068
|
+
if (!canonicalInput(addition, "the text"))
|
|
1069
|
+
return 1;
|
|
1009
1070
|
try {
|
|
1010
1071
|
const id = await resolveNote(c, ref);
|
|
1011
1072
|
if (!id)
|
|
1012
1073
|
return 1;
|
|
1013
1074
|
const current = await readDocumentSnapshot(c, id, opts.baseRevision);
|
|
1014
|
-
const suffix = (current.content && !current.content.endsWith("\n") ? "\n" : "") + addition;
|
|
1015
1075
|
const mode = opts.exact ? "exact" : "merge";
|
|
1076
|
+
const { suffix, request } = appendPlan(current, addition, mode);
|
|
1016
1077
|
const headers = {};
|
|
1017
1078
|
const path = `/namespaces/${seg(c.ns)}/notes/${seg(id)}/body`;
|
|
1018
|
-
const payload =
|
|
1079
|
+
const payload = withCommandId(request, opts);
|
|
1019
1080
|
if (opts.dryRun) {
|
|
1020
1081
|
if (opts.json)
|
|
1021
1082
|
emitJson({ dryRun: true, method: "PATCH", path, headers, payload, ...(suffix ? {} : { noChange: true }) });
|
|
@@ -1073,6 +1134,8 @@ async function runLegacyNotesAppend(ref, opts) {
|
|
|
1073
1134
|
}
|
|
1074
1135
|
}
|
|
1075
1136
|
export async function runNotesCreate(name, opts) {
|
|
1137
|
+
// Notes API contract: the title is optional and an omitted one displays as Untitled.
|
|
1138
|
+
name ??= "Untitled";
|
|
1076
1139
|
const c = await ctx(opts);
|
|
1077
1140
|
if (!c)
|
|
1078
1141
|
return 1;
|
|
@@ -1187,6 +1250,10 @@ export async function runNotesRmSection(ref, anchor, opts) {
|
|
|
1187
1250
|
}
|
|
1188
1251
|
/** Explicit compatibility keeps legacy body-only output and ETag semantics available. */
|
|
1189
1252
|
export async function runNotesRead(ref, opts) {
|
|
1253
|
+
if (opts.lines !== undefined && (opts.legacy || opts.startLine !== undefined || opts.endLine !== undefined || opts.numbered || opts.linger || opts.version !== undefined)) {
|
|
1254
|
+
fail("--lines is the v2 line range of the live source; it cannot combine with --legacy, --start-line, --end-line, --numbered, --linger or --version");
|
|
1255
|
+
return 1;
|
|
1256
|
+
}
|
|
1190
1257
|
if (opts.version !== undefined)
|
|
1191
1258
|
return runSavedVersionRead(ref, opts);
|
|
1192
1259
|
if (opts.linger)
|
|
@@ -1227,6 +1294,10 @@ export async function runNotesDiff(ref, opts) {
|
|
|
1227
1294
|
return runDocumentRead(ref, opts);
|
|
1228
1295
|
}
|
|
1229
1296
|
export async function runNotesPatch(ref, opts) {
|
|
1297
|
+
if (opts.legacy && opts.commandId !== undefined) {
|
|
1298
|
+
fail("--command-id requires the v2 patch contract");
|
|
1299
|
+
return 1;
|
|
1300
|
+
}
|
|
1230
1301
|
if (opts.legacy && (opts.baseRevision !== undefined || opts.exact)) {
|
|
1231
1302
|
fail("--base-revision/--exact require the v2 patch contract");
|
|
1232
1303
|
return 1;
|
|
@@ -1293,7 +1364,7 @@ export async function runNotesVisit(ref, opts) {
|
|
|
1293
1364
|
export async function runNotesProjects(id, opts) {
|
|
1294
1365
|
try {
|
|
1295
1366
|
if (!/^[a-f0-9]{24}$/i.test(id) || !opts.namespace?.trim())
|
|
1296
|
-
throw new Error('Use a stable Note ID and explicit --namespace');
|
|
1367
|
+
throw new Error('Use a stable Note ID and an explicit --namespace (or --ns)');
|
|
1297
1368
|
const c = await ctx(opts);
|
|
1298
1369
|
if (!c)
|
|
1299
1370
|
return 1;
|
|
@@ -3,7 +3,11 @@ import { type ConnOpts } from "./index.js";
|
|
|
3
3
|
export interface MoveOptions extends ConnOpts {
|
|
4
4
|
toNamespace?: string;
|
|
5
5
|
project?: string[];
|
|
6
|
+
/** Contract spelling of --project. */
|
|
7
|
+
toProject?: string[];
|
|
6
8
|
folder?: string;
|
|
9
|
+
/** Contract spelling of --folder. */
|
|
10
|
+
toFolder?: string;
|
|
7
11
|
dryRun?: boolean;
|
|
8
12
|
json?: boolean;
|
|
9
13
|
}
|
|
@@ -6,6 +6,11 @@ import { emitJson, fail } from "../helpers.js";
|
|
|
6
6
|
import { resolveNote, seg } from "./index.js";
|
|
7
7
|
/** Ownership changes never read or rewrite the collaborative body, nor retry a POST. */
|
|
8
8
|
export async function runNotesMove(ref, opts) {
|
|
9
|
+
if (opts.folder !== undefined && opts.toFolder !== undefined && opts.folder !== opts.toFolder) {
|
|
10
|
+
fail("--folder and --to-folder name different folders; give one");
|
|
11
|
+
return 1;
|
|
12
|
+
}
|
|
13
|
+
opts = { ...opts, project: [...(opts.project ?? []), ...(opts.toProject ?? [])], folder: opts.folder ?? opts.toFolder };
|
|
9
14
|
if (opts.folder !== undefined)
|
|
10
15
|
return runNotesFolderMove(ref, opts);
|
|
11
16
|
let attempted = false;
|
|
@@ -253,6 +258,8 @@ export function registerMoveCommand(notes) {
|
|
|
253
258
|
.option("--namespace <slug>", "assert the source workspace; used for slug/title lookup")
|
|
254
259
|
.option("--project <slug>", "destination project; repeat for multiple projects", (value, previous) => [...previous, value], [])
|
|
255
260
|
.option("--folder <path>", "relocate the note within --project to this existing folder (e.g. a/b)")
|
|
261
|
+
.option("--to-project <slug>", "destination project (contract spelling of --project; repeatable)", (value, previous) => [...previous, value], [])
|
|
262
|
+
.option("--to-folder <path>", "destination folder (contract spelling of --folder)")
|
|
256
263
|
.option("--dry-run", "validate on the server and preview access changes without writing")
|
|
257
264
|
.option("--json", "emit the server move receipt as JSON")
|
|
258
265
|
.action(async (note, opts) => { process.exitCode = await runNotesMove(note, opts); });
|
|
@@ -78,7 +78,7 @@ export declare function handleCommand(input: {
|
|
|
78
78
|
shutdown?: AbortSignal;
|
|
79
79
|
tickMs?: number;
|
|
80
80
|
journal?: RunnerJournal;
|
|
81
|
-
}): Promise<import("../../../api/sessions.js").Command<"
|
|
81
|
+
}): Promise<import("../../../api/sessions.js").Command<"start" | "stop" | "status" | "resume" | "send" | "sync" | "subagents"> | null>;
|
|
82
82
|
export declare function serve(options: RunnerOptions): Promise<{
|
|
83
83
|
runnerId: string;
|
|
84
84
|
handled: number;
|
|
@@ -13,7 +13,7 @@ export declare function validateKey(value: string): void;
|
|
|
13
13
|
export declare function prepareTransfers(transfers: Transfer[]): Promise<void>;
|
|
14
14
|
export declare function transferSelected(transfers: Transfer[], call: VaultCall, cancelled?: () => boolean): Promise<void>;
|
|
15
15
|
export declare function transferReport(transfers: Transfer[]): {
|
|
16
|
-
status: "
|
|
16
|
+
status: "success" | "pending" | "unknown" | "failure";
|
|
17
17
|
detail: string;
|
|
18
18
|
ifMatch?: number | undefined;
|
|
19
19
|
id: string;
|
package/dist/cli/version.d.ts
CHANGED
|
@@ -1 +1 @@
|
|
|
1
|
-
export declare const VERSION = "0.
|
|
1
|
+
export declare const VERSION = "0.98.0";
|
package/dist/cli/version.js
CHANGED
package/package.json
CHANGED
|
@@ -1,6 +1,6 @@
|
|
|
1
1
|
{
|
|
2
2
|
"name": "@dreamlake/dreamlake-cli",
|
|
3
|
-
"version": "0.
|
|
3
|
+
"version": "0.98.0",
|
|
4
4
|
"repository": {
|
|
5
5
|
"type": "git",
|
|
6
6
|
"url": "git+https://github.com/dreamlake-ai/dreamlake-cli.git"
|
|
@@ -35,13 +35,13 @@
|
|
|
35
35
|
"node": ">=18"
|
|
36
36
|
},
|
|
37
37
|
"optionalDependencies": {
|
|
38
|
-
"@dreamlake/dreamlake-cli-darwin-arm64": "0.
|
|
39
|
-
"@dreamlake/dreamlake-cli-darwin-x64": "0.
|
|
40
|
-
"@dreamlake/dreamlake-cli-linux-x64": "0.
|
|
41
|
-
"@dreamlake/dreamlake-cli-linux-arm64": "0.
|
|
42
|
-
"@dreamlake/dreamlake-cli-linux-x64-musl": "0.
|
|
43
|
-
"@dreamlake/dreamlake-cli-linux-arm64-musl": "0.
|
|
44
|
-
"@dreamlake/dreamlake-cli-win32-x64": "0.
|
|
45
|
-
"@dreamlake/dreamlake-cli-win32-arm64": "0.
|
|
38
|
+
"@dreamlake/dreamlake-cli-darwin-arm64": "0.98.0",
|
|
39
|
+
"@dreamlake/dreamlake-cli-darwin-x64": "0.98.0",
|
|
40
|
+
"@dreamlake/dreamlake-cli-linux-x64": "0.98.0",
|
|
41
|
+
"@dreamlake/dreamlake-cli-linux-arm64": "0.98.0",
|
|
42
|
+
"@dreamlake/dreamlake-cli-linux-x64-musl": "0.98.0",
|
|
43
|
+
"@dreamlake/dreamlake-cli-linux-arm64-musl": "0.98.0",
|
|
44
|
+
"@dreamlake/dreamlake-cli-win32-x64": "0.98.0",
|
|
45
|
+
"@dreamlake/dreamlake-cli-win32-arm64": "0.98.0"
|
|
46
46
|
}
|
|
47
47
|
}
|