@dayofweek/dcli 1.9.0 → 1.10.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/bin/dcli.js +86 -0
- package/dist/bundle/dcli.cjs +74 -2
- package/dist/client.d.ts +25 -0
- package/dist/client.js +25 -0
- package/package.json +1 -1
package/dist/bin/dcli.js
CHANGED
|
@@ -267,10 +267,31 @@ brainSource
|
|
|
267
267
|
.option("--mime <mimeType>", "MIME type; inferred from extension when omitted")
|
|
268
268
|
.option("--meeting", "Mark this source as a recorded meeting")
|
|
269
269
|
.option("--consent-ack", "Confirm recorded participants were informed and consented")
|
|
270
|
+
.option("--as-source", "Store an HTML document as a raw source instead of publishing it as a Page")
|
|
270
271
|
.action(async (opts) => {
|
|
271
272
|
if (opts.meeting && !opts.consentAck) {
|
|
272
273
|
throw new Error("--consent-ack is required: you are attesting that recorded participants were informed and consented");
|
|
273
274
|
}
|
|
275
|
+
// A full HTML document is almost always meant to be a Page (the Pages tab),
|
|
276
|
+
// which is published as a note via `brain share` — not stored as a raw
|
|
277
|
+
// source. Uploading it here would land it in Sources, where nobody looks
|
|
278
|
+
// for a page. Refuse unless the caller explicitly wants a raw source.
|
|
279
|
+
if (!opts.asSource) {
|
|
280
|
+
const looksHtmlName = /\.html?$/i.test(opts.file);
|
|
281
|
+
let looksHtmlContent = false;
|
|
282
|
+
try {
|
|
283
|
+
const head = readFileSync(opts.file, "utf8").slice(0, 512);
|
|
284
|
+
looksHtmlContent = /^\s*(<!doctype html|<html[\s>])/i.test(head);
|
|
285
|
+
}
|
|
286
|
+
catch {
|
|
287
|
+
// Unreadable as text (binary) — not an HTML page.
|
|
288
|
+
}
|
|
289
|
+
if (looksHtmlName || looksHtmlContent) {
|
|
290
|
+
throw new Error("This looks like a Page (a full HTML document). Pages live in the area's Pages tab and are published with:\n" +
|
|
291
|
+
" dcli brain share --area <areaId> --title \"…\" --file " + opts.file + "\n" +
|
|
292
|
+
"Pass --as-source only if you really want the raw HTML stored as a source file.");
|
|
293
|
+
}
|
|
294
|
+
}
|
|
274
295
|
output(await getClient().uploadBrainSource({
|
|
275
296
|
areaId: opts.area,
|
|
276
297
|
path: opts.file,
|
|
@@ -409,6 +430,71 @@ brainSource
|
|
|
409
430
|
}
|
|
410
431
|
output(await getClient().scopeBrainSource(sourceId, opts.actor ?? null));
|
|
411
432
|
});
|
|
433
|
+
const brainTags = brain
|
|
434
|
+
.command("tags")
|
|
435
|
+
.description("Work with an area's tag vocabulary and resource couplings");
|
|
436
|
+
brainTags
|
|
437
|
+
.command("list")
|
|
438
|
+
.description("List an area's tags (predefined hierarchical set + user-defined)")
|
|
439
|
+
.requiredOption("--area <areaId>", "Area id (from `brain list`)")
|
|
440
|
+
.action(async (opts) => {
|
|
441
|
+
output(await getClient().listBrainTags(opts.area));
|
|
442
|
+
});
|
|
443
|
+
brainTags
|
|
444
|
+
.command("add")
|
|
445
|
+
.description("Add a user-defined tag (idempotent on the derived key)")
|
|
446
|
+
.requiredOption("--area <areaId>", "Area id (from `brain list`)")
|
|
447
|
+
.requiredOption("--label <label>", "Tag label")
|
|
448
|
+
.option("--parent <key>", "Parent tag key (makes this a child tag)")
|
|
449
|
+
.option("--description <text>", "What the tag means")
|
|
450
|
+
.action(async (opts) => {
|
|
451
|
+
output(await getClient().createBrainTag({
|
|
452
|
+
areaId: opts.area,
|
|
453
|
+
label: opts.label,
|
|
454
|
+
parentKey: opts.parent,
|
|
455
|
+
description: opts.description,
|
|
456
|
+
}));
|
|
457
|
+
});
|
|
458
|
+
brainTags
|
|
459
|
+
.command("couplings")
|
|
460
|
+
.description("List tag/actor couplings — filter by actor, tag, source or note")
|
|
461
|
+
.requiredOption("--area <areaId>", "Area id (from `brain list`)")
|
|
462
|
+
.option("--tag <key>", "Resources coupled to this tag")
|
|
463
|
+
.option("--actor <actorId>", "Resources coupled to this actor")
|
|
464
|
+
.option("--source <sourceId>", "One source's tags and actors")
|
|
465
|
+
.option("--note <noteId>", "One note/page's tags and actors")
|
|
466
|
+
.action(async (opts) => {
|
|
467
|
+
output(await getClient().listBrainCouplings({
|
|
468
|
+
areaId: opts.area,
|
|
469
|
+
tag: opts.tag,
|
|
470
|
+
actor: opts.actor,
|
|
471
|
+
source: opts.source,
|
|
472
|
+
note: opts.note,
|
|
473
|
+
}));
|
|
474
|
+
});
|
|
475
|
+
brainTags
|
|
476
|
+
.command("couple")
|
|
477
|
+
.description("Couple a source/note to a tag or an actor (--remove uncouples)")
|
|
478
|
+
.option("--source <sourceId>", "Source to couple")
|
|
479
|
+
.option("--note <noteId>", "Note/page to couple")
|
|
480
|
+
.option("--tag <key>", "Tag key (from `brain tags list`)")
|
|
481
|
+
.option("--actor <actorId>", "Actor id (from `brain actors list`)")
|
|
482
|
+
.option("--remove", "Remove the coupling instead of adding it")
|
|
483
|
+
.action(async (opts) => {
|
|
484
|
+
if (Boolean(opts.source) === Boolean(opts.note)) {
|
|
485
|
+
throw new Error("Pass exactly one of --source <sourceId> or --note <noteId>");
|
|
486
|
+
}
|
|
487
|
+
if (Boolean(opts.tag) === Boolean(opts.actor)) {
|
|
488
|
+
throw new Error("Pass exactly one of --tag <key> or --actor <actorId>");
|
|
489
|
+
}
|
|
490
|
+
output(await getClient().coupleBrainResource({
|
|
491
|
+
sourceId: opts.source,
|
|
492
|
+
noteId: opts.note,
|
|
493
|
+
tagKey: opts.tag,
|
|
494
|
+
actorId: opts.actor,
|
|
495
|
+
remove: opts.remove,
|
|
496
|
+
}));
|
|
497
|
+
});
|
|
412
498
|
auth
|
|
413
499
|
.command("devices")
|
|
414
500
|
.description("List your agent tokens")
|
package/dist/bundle/dcli.cjs
CHANGED
|
@@ -4518,6 +4518,27 @@ var DayOfWeekClient = class {
|
|
|
4518
4518
|
async scopeBrainSource(sourceId, actorId) {
|
|
4519
4519
|
return this.patch(`/brain/sources/${encodeURIComponent(sourceId)}/actor`, { actorId });
|
|
4520
4520
|
}
|
|
4521
|
+
/** The area's tag vocabulary: predefined hierarchical set + user-defined. */
|
|
4522
|
+
async listBrainTags(areaId) {
|
|
4523
|
+
return this.get(`/brain/tags?area=${encodeURIComponent(areaId)}`);
|
|
4524
|
+
}
|
|
4525
|
+
/** Add a user-defined tag to an area's vocabulary. Idempotent on the key. */
|
|
4526
|
+
async createBrainTag(input) {
|
|
4527
|
+
return this.post("/brain/tags", input);
|
|
4528
|
+
}
|
|
4529
|
+
/** Tag/actor couplings, filterable by actor, tag, source or note. */
|
|
4530
|
+
async listBrainCouplings(input) {
|
|
4531
|
+
const params = new URLSearchParams({ area: input.areaId });
|
|
4532
|
+
if (input.tag) params.set("tag", input.tag);
|
|
4533
|
+
if (input.actor) params.set("actor", input.actor);
|
|
4534
|
+
if (input.source) params.set("source", input.source);
|
|
4535
|
+
if (input.note) params.set("note", input.note);
|
|
4536
|
+
return this.get(`/brain/tags/couplings?${params.toString()}`);
|
|
4537
|
+
}
|
|
4538
|
+
/** Couple (or uncouple, with remove) a source/note to a tag or an actor. */
|
|
4539
|
+
async coupleBrainResource(input) {
|
|
4540
|
+
return this.post("/brain/tags/couplings", input);
|
|
4541
|
+
}
|
|
4521
4542
|
/** Entities with an active customer role and no investor/partner/producer role. */
|
|
4522
4543
|
async adminCustomersOnly() {
|
|
4523
4544
|
return this.get("/admin/customers-only");
|
|
@@ -5144,7 +5165,7 @@ var import_promises4 = require("node:readline/promises");
|
|
|
5144
5165
|
// package.json
|
|
5145
5166
|
var package_default = {
|
|
5146
5167
|
name: "@dayofweek/dcli",
|
|
5147
|
-
version: "1.
|
|
5168
|
+
version: "1.10.0",
|
|
5148
5169
|
description: "CLI for the Day of Week AgTech platform \u2014 read data and submit proposals for review",
|
|
5149
5170
|
license: "MIT",
|
|
5150
5171
|
type: "module",
|
|
@@ -5435,10 +5456,25 @@ brainSource.command("get <uri>").description("Read source metadata and derived t
|
|
|
5435
5456
|
if (source.areaId !== parsed.areaId) throw new Error("Server returned a mismatched area");
|
|
5436
5457
|
output(source);
|
|
5437
5458
|
});
|
|
5438
|
-
brainSource.command("upload").description("Upload an original file or meeting recording").requiredOption("--area <areaId>", "Destination area").requiredOption("--file <path>", "File to upload").option("--mime <mimeType>", "MIME type; inferred from extension when omitted").option("--meeting", "Mark this source as a recorded meeting").option("--consent-ack", "Confirm recorded participants were informed and consented").action(async (opts) => {
|
|
5459
|
+
brainSource.command("upload").description("Upload an original file or meeting recording").requiredOption("--area <areaId>", "Destination area").requiredOption("--file <path>", "File to upload").option("--mime <mimeType>", "MIME type; inferred from extension when omitted").option("--meeting", "Mark this source as a recorded meeting").option("--consent-ack", "Confirm recorded participants were informed and consented").option("--as-source", "Store an HTML document as a raw source instead of publishing it as a Page").action(async (opts) => {
|
|
5439
5460
|
if (opts.meeting && !opts.consentAck) {
|
|
5440
5461
|
throw new Error("--consent-ack is required: you are attesting that recorded participants were informed and consented");
|
|
5441
5462
|
}
|
|
5463
|
+
if (!opts.asSource) {
|
|
5464
|
+
const looksHtmlName = /\.html?$/i.test(opts.file);
|
|
5465
|
+
let looksHtmlContent = false;
|
|
5466
|
+
try {
|
|
5467
|
+
const head = (0, import_node_fs8.readFileSync)(opts.file, "utf8").slice(0, 512);
|
|
5468
|
+
looksHtmlContent = /^\s*(<!doctype html|<html[\s>])/i.test(head);
|
|
5469
|
+
} catch {
|
|
5470
|
+
}
|
|
5471
|
+
if (looksHtmlName || looksHtmlContent) {
|
|
5472
|
+
throw new Error(
|
|
5473
|
+
`This looks like a Page (a full HTML document). Pages live in the area's Pages tab and are published with:
|
|
5474
|
+
dcli brain share --area <areaId> --title "\u2026" --file ` + opts.file + "\nPass --as-source only if you really want the raw HTML stored as a source file."
|
|
5475
|
+
);
|
|
5476
|
+
}
|
|
5477
|
+
}
|
|
5442
5478
|
output(await getClient().uploadBrainSource({
|
|
5443
5479
|
areaId: opts.area,
|
|
5444
5480
|
path: opts.file,
|
|
@@ -5517,6 +5553,42 @@ brainSource.command("scope <sourceId>").description("Scope a source to an actor
|
|
|
5517
5553
|
}
|
|
5518
5554
|
output(await getClient().scopeBrainSource(sourceId, opts.actor ?? null));
|
|
5519
5555
|
});
|
|
5556
|
+
var brainTags = brain.command("tags").description("Work with an area's tag vocabulary and resource couplings");
|
|
5557
|
+
brainTags.command("list").description("List an area's tags (predefined hierarchical set + user-defined)").requiredOption("--area <areaId>", "Area id (from `brain list`)").action(async (opts) => {
|
|
5558
|
+
output(await getClient().listBrainTags(opts.area));
|
|
5559
|
+
});
|
|
5560
|
+
brainTags.command("add").description("Add a user-defined tag (idempotent on the derived key)").requiredOption("--area <areaId>", "Area id (from `brain list`)").requiredOption("--label <label>", "Tag label").option("--parent <key>", "Parent tag key (makes this a child tag)").option("--description <text>", "What the tag means").action(async (opts) => {
|
|
5561
|
+
output(await getClient().createBrainTag({
|
|
5562
|
+
areaId: opts.area,
|
|
5563
|
+
label: opts.label,
|
|
5564
|
+
parentKey: opts.parent,
|
|
5565
|
+
description: opts.description
|
|
5566
|
+
}));
|
|
5567
|
+
});
|
|
5568
|
+
brainTags.command("couplings").description("List tag/actor couplings \u2014 filter by actor, tag, source or note").requiredOption("--area <areaId>", "Area id (from `brain list`)").option("--tag <key>", "Resources coupled to this tag").option("--actor <actorId>", "Resources coupled to this actor").option("--source <sourceId>", "One source's tags and actors").option("--note <noteId>", "One note/page's tags and actors").action(async (opts) => {
|
|
5569
|
+
output(await getClient().listBrainCouplings({
|
|
5570
|
+
areaId: opts.area,
|
|
5571
|
+
tag: opts.tag,
|
|
5572
|
+
actor: opts.actor,
|
|
5573
|
+
source: opts.source,
|
|
5574
|
+
note: opts.note
|
|
5575
|
+
}));
|
|
5576
|
+
});
|
|
5577
|
+
brainTags.command("couple").description("Couple a source/note to a tag or an actor (--remove uncouples)").option("--source <sourceId>", "Source to couple").option("--note <noteId>", "Note/page to couple").option("--tag <key>", "Tag key (from `brain tags list`)").option("--actor <actorId>", "Actor id (from `brain actors list`)").option("--remove", "Remove the coupling instead of adding it").action(async (opts) => {
|
|
5578
|
+
if (Boolean(opts.source) === Boolean(opts.note)) {
|
|
5579
|
+
throw new Error("Pass exactly one of --source <sourceId> or --note <noteId>");
|
|
5580
|
+
}
|
|
5581
|
+
if (Boolean(opts.tag) === Boolean(opts.actor)) {
|
|
5582
|
+
throw new Error("Pass exactly one of --tag <key> or --actor <actorId>");
|
|
5583
|
+
}
|
|
5584
|
+
output(await getClient().coupleBrainResource({
|
|
5585
|
+
sourceId: opts.source,
|
|
5586
|
+
noteId: opts.note,
|
|
5587
|
+
tagKey: opts.tag,
|
|
5588
|
+
actorId: opts.actor,
|
|
5589
|
+
remove: opts.remove
|
|
5590
|
+
}));
|
|
5591
|
+
});
|
|
5520
5592
|
auth.command("devices").description("List your agent tokens").action(async () => {
|
|
5521
5593
|
const client = getClient();
|
|
5522
5594
|
const devices = await client.listDevices();
|
package/dist/client.d.ts
CHANGED
|
@@ -251,6 +251,31 @@ export declare class DayOfWeekClient {
|
|
|
251
251
|
}): Promise<any>;
|
|
252
252
|
/** Scope a source to an actor (actorId null returns it to area level). */
|
|
253
253
|
scopeBrainSource(sourceId: string, actorId: string | null): Promise<any>;
|
|
254
|
+
/** The area's tag vocabulary: predefined hierarchical set + user-defined. */
|
|
255
|
+
listBrainTags(areaId: string): Promise<any>;
|
|
256
|
+
/** Add a user-defined tag to an area's vocabulary. Idempotent on the key. */
|
|
257
|
+
createBrainTag(input: {
|
|
258
|
+
areaId: string;
|
|
259
|
+
label: string;
|
|
260
|
+
parentKey?: string;
|
|
261
|
+
description?: string;
|
|
262
|
+
}): Promise<any>;
|
|
263
|
+
/** Tag/actor couplings, filterable by actor, tag, source or note. */
|
|
264
|
+
listBrainCouplings(input: {
|
|
265
|
+
areaId: string;
|
|
266
|
+
tag?: string;
|
|
267
|
+
actor?: string;
|
|
268
|
+
source?: string;
|
|
269
|
+
note?: string;
|
|
270
|
+
}): Promise<any>;
|
|
271
|
+
/** Couple (or uncouple, with remove) a source/note to a tag or an actor. */
|
|
272
|
+
coupleBrainResource(input: {
|
|
273
|
+
sourceId?: string;
|
|
274
|
+
noteId?: string;
|
|
275
|
+
tagKey?: string;
|
|
276
|
+
actorId?: string;
|
|
277
|
+
remove?: boolean;
|
|
278
|
+
}): Promise<any>;
|
|
254
279
|
/** Entities with an active customer role and no investor/partner/producer role. */
|
|
255
280
|
adminCustomersOnly(): Promise<any>;
|
|
256
281
|
/** Tips mailed to press@mail.dayofweek.com, read by the press-scan skill. */
|
package/dist/client.js
CHANGED
|
@@ -378,6 +378,31 @@ export class DayOfWeekClient {
|
|
|
378
378
|
async scopeBrainSource(sourceId, actorId) {
|
|
379
379
|
return this.patch(`/brain/sources/${encodeURIComponent(sourceId)}/actor`, { actorId });
|
|
380
380
|
}
|
|
381
|
+
/** The area's tag vocabulary: predefined hierarchical set + user-defined. */
|
|
382
|
+
async listBrainTags(areaId) {
|
|
383
|
+
return this.get(`/brain/tags?area=${encodeURIComponent(areaId)}`);
|
|
384
|
+
}
|
|
385
|
+
/** Add a user-defined tag to an area's vocabulary. Idempotent on the key. */
|
|
386
|
+
async createBrainTag(input) {
|
|
387
|
+
return this.post("/brain/tags", input);
|
|
388
|
+
}
|
|
389
|
+
/** Tag/actor couplings, filterable by actor, tag, source or note. */
|
|
390
|
+
async listBrainCouplings(input) {
|
|
391
|
+
const params = new URLSearchParams({ area: input.areaId });
|
|
392
|
+
if (input.tag)
|
|
393
|
+
params.set("tag", input.tag);
|
|
394
|
+
if (input.actor)
|
|
395
|
+
params.set("actor", input.actor);
|
|
396
|
+
if (input.source)
|
|
397
|
+
params.set("source", input.source);
|
|
398
|
+
if (input.note)
|
|
399
|
+
params.set("note", input.note);
|
|
400
|
+
return this.get(`/brain/tags/couplings?${params.toString()}`);
|
|
401
|
+
}
|
|
402
|
+
/** Couple (or uncouple, with remove) a source/note to a tag or an actor. */
|
|
403
|
+
async coupleBrainResource(input) {
|
|
404
|
+
return this.post("/brain/tags/couplings", input);
|
|
405
|
+
}
|
|
381
406
|
/** Entities with an active customer role and no investor/partner/producer role. */
|
|
382
407
|
async adminCustomersOnly() {
|
|
383
408
|
return this.get("/admin/customers-only");
|