@helm-ai/cli 0.21.0 → 0.23.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/cli.js +318 -5
- package/package.json +1 -1
package/dist/cli.js
CHANGED
|
@@ -1,7 +1,7 @@
|
|
|
1
1
|
#!/usr/bin/env node
|
|
2
2
|
|
|
3
3
|
// src/cli.ts
|
|
4
|
-
import { Command } from "commander";
|
|
4
|
+
import { Command as Command2 } from "commander";
|
|
5
5
|
import kleur8 from "kleur";
|
|
6
6
|
|
|
7
7
|
// src/lib/branding.ts
|
|
@@ -25,7 +25,7 @@ function renderSplash(ctx) {
|
|
|
25
25
|
}
|
|
26
26
|
|
|
27
27
|
// src/version.ts
|
|
28
|
-
var version = "0.
|
|
28
|
+
var version = "0.23.0";
|
|
29
29
|
|
|
30
30
|
// src/commands/auth.ts
|
|
31
31
|
import prompts from "prompts";
|
|
@@ -410,6 +410,43 @@ var HelmClient = class _HelmClient {
|
|
|
410
410
|
return data.payment;
|
|
411
411
|
}
|
|
412
412
|
};
|
|
413
|
+
// Customer subscriptions -- the recurring revenue the workspace bills its own
|
|
414
|
+
// clients, not the workspace's own Helm plan.
|
|
415
|
+
subscriptions = {
|
|
416
|
+
list: async (filters = {}) => {
|
|
417
|
+
const data = await this.request("list_subscriptions", "GET", filters);
|
|
418
|
+
return data.subscriptions ?? [];
|
|
419
|
+
},
|
|
420
|
+
get: async (idOrStripeId) => {
|
|
421
|
+
const key = idOrStripeId.startsWith("sub_") ? "stripe_subscription_id" : "id";
|
|
422
|
+
const data = await this.request("get_subscription", "GET", { [key]: idOrStripeId });
|
|
423
|
+
return data.subscription;
|
|
424
|
+
},
|
|
425
|
+
mrr: async () => {
|
|
426
|
+
const data = await this.request("get_subscription_mrr", "GET", {});
|
|
427
|
+
return data.mrr;
|
|
428
|
+
},
|
|
429
|
+
create: async (input) => {
|
|
430
|
+
const data = await this.request("create_subscription", "POST", input);
|
|
431
|
+
return data;
|
|
432
|
+
},
|
|
433
|
+
cancel: async (id, immediately = false) => {
|
|
434
|
+
const data = await this.request("cancel_subscription", "POST", { id, immediately });
|
|
435
|
+
return data.subscription;
|
|
436
|
+
},
|
|
437
|
+
pause: async (id, resumes_at) => {
|
|
438
|
+
const data = await this.request("pause_subscription", "POST", { id, resumes_at });
|
|
439
|
+
return data.subscription;
|
|
440
|
+
},
|
|
441
|
+
resume: async (id) => {
|
|
442
|
+
const data = await this.request("resume_subscription", "POST", { id });
|
|
443
|
+
return data.subscription;
|
|
444
|
+
},
|
|
445
|
+
refresh: async (id) => {
|
|
446
|
+
const data = await this.request("refresh_subscription", "POST", { id });
|
|
447
|
+
return data.subscription;
|
|
448
|
+
}
|
|
449
|
+
};
|
|
413
450
|
estimates = {
|
|
414
451
|
list: async (filters = {}) => {
|
|
415
452
|
const data = await this.request("get_estimates", "GET", filters);
|
|
@@ -542,6 +579,33 @@ var HelmClient = class _HelmClient {
|
|
|
542
579
|
if (data.page) return data.page;
|
|
543
580
|
const { page_id, message: _msg, ...rest } = data;
|
|
544
581
|
return { id: page_id, ...rest };
|
|
582
|
+
},
|
|
583
|
+
updatePage: async (documentId, pageId, input) => {
|
|
584
|
+
const data = await this.request("update_document_page", "POST", { document_id: documentId, page_id: pageId, ...input });
|
|
585
|
+
const { page_id, message: _msg, ...rest } = data;
|
|
586
|
+
return { id: page_id, ...rest };
|
|
587
|
+
},
|
|
588
|
+
deletePage: async (documentId, pageId) => {
|
|
589
|
+
return await this.request("delete_document_page", "POST", { document_id: documentId, page_id: pageId });
|
|
590
|
+
},
|
|
591
|
+
reorderPages: async (documentId, pageIds) => {
|
|
592
|
+
const data = await this.request("reorder_document_pages", "POST", { document_id: documentId, page_ids: pageIds });
|
|
593
|
+
return data.pages ?? [];
|
|
594
|
+
},
|
|
595
|
+
// Block-level editing: map the document, read the blocks to change, then
|
|
596
|
+
// patch them by address. Unlike update, this leaves every other block alone.
|
|
597
|
+
outline: async (documentId, detail) => {
|
|
598
|
+
return await this.request("get_document_outline", "GET", { document_id: documentId, detail });
|
|
599
|
+
},
|
|
600
|
+
blocks: async (documentId, input) => {
|
|
601
|
+
return await this.request("get_document_blocks", "GET", {
|
|
602
|
+
document_id: documentId,
|
|
603
|
+
addresses: input.addresses?.join(","),
|
|
604
|
+
section: input.section
|
|
605
|
+
});
|
|
606
|
+
},
|
|
607
|
+
patch: async (documentId, edits) => {
|
|
608
|
+
return await this.request("patch_document", "POST", { document_id: documentId, edits });
|
|
545
609
|
}
|
|
546
610
|
};
|
|
547
611
|
agentSchedules = {
|
|
@@ -2254,6 +2318,148 @@ function registerPaymentCommands(parent) {
|
|
|
2254
2318
|
});
|
|
2255
2319
|
}
|
|
2256
2320
|
|
|
2321
|
+
// src/commands/subscription.ts
|
|
2322
|
+
var INTERVAL_SHORT = { day: "day", week: "wk", month: "mo", year: "yr" };
|
|
2323
|
+
function money(cents, currency) {
|
|
2324
|
+
if (cents === null || cents === void 0) return "";
|
|
2325
|
+
return new Intl.NumberFormat("en-US", {
|
|
2326
|
+
style: "currency",
|
|
2327
|
+
currency: (currency || "usd").toUpperCase(),
|
|
2328
|
+
maximumFractionDigits: 2
|
|
2329
|
+
}).format(cents / 100);
|
|
2330
|
+
}
|
|
2331
|
+
function recurring(r) {
|
|
2332
|
+
const base = money(r.amount, r.currency);
|
|
2333
|
+
if (!r.billing_interval) return base;
|
|
2334
|
+
const n = r.interval_count && r.interval_count > 1 ? r.interval_count : 1;
|
|
2335
|
+
if (n > 1) return `${base}/${n}${INTERVAL_SHORT[r.billing_interval] ?? r.billing_interval}`;
|
|
2336
|
+
return `${base}/${INTERVAL_SHORT[r.billing_interval] ?? r.billing_interval}`;
|
|
2337
|
+
}
|
|
2338
|
+
function statusOf(r) {
|
|
2339
|
+
return r.cancel_at_period_end && r.status !== "canceled" ? `${r.status} (ending)` : r.status;
|
|
2340
|
+
}
|
|
2341
|
+
function registerSubscriptionCommands(parent) {
|
|
2342
|
+
const cmd = parent.command("subscription").alias("subscriptions").alias("sub").description("Recurring plans you bill your customers");
|
|
2343
|
+
cmd.command("list").description("List customer subscriptions").option("-s, --status <status>", "active|trialing|past_due|unpaid|canceled|incomplete|paused").option("--active", "only live revenue (active, trialing, past_due)").option("--origin <origin>", "helm|external \u2014 helm revenue is fee-bearing").option("-a, --account <id>").option("-c, --contact <id>").option("--product <id>").option("-l, --limit <n>", "max rows", (v) => parseInt(v, 10), 50).option("-o, --output <format>").option("-p, --profile <name>").action(async (opts) => {
|
|
2344
|
+
try {
|
|
2345
|
+
const client = HelmClient.fromProfile(resolveProfile(opts.profile));
|
|
2346
|
+
const rows = await client.subscriptions.list({
|
|
2347
|
+
status: opts.status,
|
|
2348
|
+
active_only: opts.active || void 0,
|
|
2349
|
+
origin: opts.origin,
|
|
2350
|
+
account_id: opts.account,
|
|
2351
|
+
contact_id: opts.contact,
|
|
2352
|
+
product_id: opts.product,
|
|
2353
|
+
limit: opts.limit
|
|
2354
|
+
});
|
|
2355
|
+
console.log(render(rows, [
|
|
2356
|
+
{ header: "Status", get: (r) => statusOf(r) },
|
|
2357
|
+
{ header: "Amount", get: (r) => recurring(r) },
|
|
2358
|
+
{ header: "Source", get: (r) => r.origin === "helm" ? "Helm" : "observed" },
|
|
2359
|
+
{ header: "Renews", get: (r) => r.current_period_end?.slice(0, 10) ?? "" },
|
|
2360
|
+
{ header: "Stripe", get: (r) => r.stripe_subscription_id, truncate: 20 },
|
|
2361
|
+
{ header: "ID", get: (r) => r.id, truncate: 8 }
|
|
2362
|
+
], opts.output ?? defaultFormat()));
|
|
2363
|
+
} catch (err) {
|
|
2364
|
+
console.error(formatErrorForCli(err));
|
|
2365
|
+
process.exitCode = 1;
|
|
2366
|
+
}
|
|
2367
|
+
});
|
|
2368
|
+
cmd.command("mrr").description("Monthly recurring revenue, split by source").option("-o, --output <format>").option("-p, --profile <name>").action(async (opts) => {
|
|
2369
|
+
try {
|
|
2370
|
+
const client = HelmClient.fromProfile(resolveProfile(opts.profile));
|
|
2371
|
+
const mrr = await client.subscriptions.mrr();
|
|
2372
|
+
const format = opts.output ?? defaultFormat();
|
|
2373
|
+
if (format === "json") {
|
|
2374
|
+
console.log(JSON.stringify(mrr, null, 2));
|
|
2375
|
+
return;
|
|
2376
|
+
}
|
|
2377
|
+
console.log(`Through Helm ${money(mrr.helm_cents)}`);
|
|
2378
|
+
console.log(`Observed ${money(mrr.external_cents)}`);
|
|
2379
|
+
console.log(`Total ${money(mrr.total_cents)} (${mrr.count} live subscriptions)`);
|
|
2380
|
+
} catch (err) {
|
|
2381
|
+
console.error(formatErrorForCli(err));
|
|
2382
|
+
process.exitCode = 1;
|
|
2383
|
+
}
|
|
2384
|
+
});
|
|
2385
|
+
cmd.command("get <id>").description("Show one subscription (Helm id or Stripe sub_\u2026 id)").option("-o, --output <format>").option("-p, --profile <name>").action(async (id, opts) => {
|
|
2386
|
+
try {
|
|
2387
|
+
const client = HelmClient.fromProfile(resolveProfile(opts.profile));
|
|
2388
|
+
const sub = await client.subscriptions.get(id);
|
|
2389
|
+
console.log(JSON.stringify(sub, null, 2));
|
|
2390
|
+
} catch (err) {
|
|
2391
|
+
console.error(formatErrorForCli(err));
|
|
2392
|
+
process.exitCode = 1;
|
|
2393
|
+
}
|
|
2394
|
+
});
|
|
2395
|
+
cmd.command("create").description("Start billing a customer on a recurring schedule").requiredOption("-c, --contact <id>", "the person to bill (Stripe bills a person, not an account)").requiredOption("--product <id>", "a recurring product from your catalogue").option("--price <id>", "price tier on that product; omit to use its default price").option("-a, --account <id>", "account attribution; defaults to the contact's account").option("-q, --quantity <n>", "seats or units", (v) => parseInt(v, 10), 1).option("--trial <days>", "free trial length in days", (v) => parseInt(v, 10)).option("--checkout", "always return a payment link instead of charging a saved card").option("-p, --profile <name>").action(async (opts) => {
|
|
2396
|
+
try {
|
|
2397
|
+
const client = HelmClient.fromProfile(resolveProfile(opts.profile));
|
|
2398
|
+
const result = await client.subscriptions.create({
|
|
2399
|
+
contact_id: opts.contact,
|
|
2400
|
+
product_id: opts.product,
|
|
2401
|
+
product_price_id: opts.price,
|
|
2402
|
+
account_id: opts.account,
|
|
2403
|
+
quantity: opts.quantity,
|
|
2404
|
+
trial_days: opts.trial,
|
|
2405
|
+
method: opts.checkout ? "checkout" : "auto"
|
|
2406
|
+
});
|
|
2407
|
+
if (result.method === "checkout") {
|
|
2408
|
+
console.log("Send this link to the customer:");
|
|
2409
|
+
console.log(result.checkout_url);
|
|
2410
|
+
console.log("\nThe subscription appears in Helm once they complete payment.");
|
|
2411
|
+
} else {
|
|
2412
|
+
console.log(`\u2713 Subscription started (${result.subscription.stripe_subscription_id})`);
|
|
2413
|
+
}
|
|
2414
|
+
} catch (err) {
|
|
2415
|
+
console.error(formatErrorForCli(err));
|
|
2416
|
+
process.exitCode = 1;
|
|
2417
|
+
}
|
|
2418
|
+
});
|
|
2419
|
+
cmd.command("cancel <id>").description("Cancel a subscription (at the end of the current period by default)").option("--now", "end it immediately instead of at the period end").option("-p, --profile <name>").action(async (id, opts) => {
|
|
2420
|
+
try {
|
|
2421
|
+
const client = HelmClient.fromProfile(resolveProfile(opts.profile));
|
|
2422
|
+
const sub = await client.subscriptions.cancel(id, !!opts.now);
|
|
2423
|
+
console.log(
|
|
2424
|
+
opts.now ? "\u2713 Cancelled" : `\u2713 Will end ${sub.current_period_end?.slice(0, 10) ?? "at the period end"}`
|
|
2425
|
+
);
|
|
2426
|
+
} catch (err) {
|
|
2427
|
+
console.error(formatErrorForCli(err));
|
|
2428
|
+
process.exitCode = 1;
|
|
2429
|
+
}
|
|
2430
|
+
});
|
|
2431
|
+
cmd.command("pause <id>").description("Pause collection without ending the subscription").option("--resumes <date>", "ISO date to resume automatically").option("-p, --profile <name>").action(async (id, opts) => {
|
|
2432
|
+
try {
|
|
2433
|
+
const client = HelmClient.fromProfile(resolveProfile(opts.profile));
|
|
2434
|
+
await client.subscriptions.pause(id, opts.resumes);
|
|
2435
|
+
console.log("\u2713 Paused");
|
|
2436
|
+
} catch (err) {
|
|
2437
|
+
console.error(formatErrorForCli(err));
|
|
2438
|
+
process.exitCode = 1;
|
|
2439
|
+
}
|
|
2440
|
+
});
|
|
2441
|
+
cmd.command("resume <id>").description("Resume billing (undoes a pending cancellation or a pause)").option("-p, --profile <name>").action(async (id, opts) => {
|
|
2442
|
+
try {
|
|
2443
|
+
const client = HelmClient.fromProfile(resolveProfile(opts.profile));
|
|
2444
|
+
await client.subscriptions.resume(id);
|
|
2445
|
+
console.log("\u2713 Resumed");
|
|
2446
|
+
} catch (err) {
|
|
2447
|
+
console.error(formatErrorForCli(err));
|
|
2448
|
+
process.exitCode = 1;
|
|
2449
|
+
}
|
|
2450
|
+
});
|
|
2451
|
+
cmd.command("refresh <id>").description("Re-read one subscription from Stripe and update Helm's copy").option("-p, --profile <name>").action(async (id, opts) => {
|
|
2452
|
+
try {
|
|
2453
|
+
const client = HelmClient.fromProfile(resolveProfile(opts.profile));
|
|
2454
|
+
const sub = await client.subscriptions.refresh(id);
|
|
2455
|
+
console.log(`\u2713 Refreshed (${sub.status})`);
|
|
2456
|
+
} catch (err) {
|
|
2457
|
+
console.error(formatErrorForCli(err));
|
|
2458
|
+
process.exitCode = 1;
|
|
2459
|
+
}
|
|
2460
|
+
});
|
|
2461
|
+
}
|
|
2462
|
+
|
|
2257
2463
|
// src/commands/estimate.ts
|
|
2258
2464
|
function registerEstimateCommands(parent) {
|
|
2259
2465
|
const cmd = parent.command("estimate").alias("estimates").description("Manage estimates");
|
|
@@ -2754,12 +2960,18 @@ function registerCalendarCommands(parent) {
|
|
|
2754
2960
|
}
|
|
2755
2961
|
|
|
2756
2962
|
// src/commands/doc.ts
|
|
2963
|
+
import { InvalidArgumentError } from "commander";
|
|
2757
2964
|
import { readFileSync as readFileSync2 } from "fs";
|
|
2758
2965
|
function readContent(opts) {
|
|
2759
2966
|
if (opts.contentFile) return readFileSync2(opts.contentFile, "utf8");
|
|
2760
2967
|
if (opts.content === "-") return readFileSync2(0, "utf8");
|
|
2761
2968
|
return opts.content;
|
|
2762
2969
|
}
|
|
2970
|
+
function parsePosition(value) {
|
|
2971
|
+
const n = Number(value);
|
|
2972
|
+
if (!Number.isInteger(n) || n < 0) throw new InvalidArgumentError("must be a whole number, 0 or more");
|
|
2973
|
+
return n;
|
|
2974
|
+
}
|
|
2763
2975
|
function registerDocCommands(parent) {
|
|
2764
2976
|
const cmd = parent.command("doc").alias("docs").description("Manage documents");
|
|
2765
2977
|
cmd.command("list").description("List documents").option("-s, --status <status>", "draft|published|archived").option("--visibility <vis>", "private|workspace|shared|public").option("--category <cat>").option("--project <id>").option("-l, --limit <n>", "max rows", (v) => parseInt(v, 10), 50).option("-o, --output <format>").option("-p, --profile <name>").action(async (opts) => {
|
|
@@ -2831,6 +3043,63 @@ function registerDocCommands(parent) {
|
|
|
2831
3043
|
return;
|
|
2832
3044
|
}
|
|
2833
3045
|
});
|
|
3046
|
+
cmd.command("outline <id>").description("Map a document: every page, its headings, and an address for each block").option("--blocks", "list every block, not just headings").option("-p, --profile <name>").action(async (id, opts) => {
|
|
3047
|
+
try {
|
|
3048
|
+
const client = HelmClient.fromProfile(resolveProfile(opts.profile));
|
|
3049
|
+
const outline = await client.documents.outline(id, opts.blocks ? "blocks" : "headings");
|
|
3050
|
+
console.log(JSON.stringify(outline, null, 2));
|
|
3051
|
+
} catch (err) {
|
|
3052
|
+
console.error(formatErrorForCli(err));
|
|
3053
|
+
process.exitCode = 1;
|
|
3054
|
+
return;
|
|
3055
|
+
}
|
|
3056
|
+
});
|
|
3057
|
+
cmd.command("blocks <id> [addresses...]").description("Read blocks as markdown by address, or a whole section with --section").option("--section <address>", "a heading address; reads that heading and everything under it").option("-p, --profile <name>").action(async (id, addresses, opts) => {
|
|
3058
|
+
try {
|
|
3059
|
+
const client = HelmClient.fromProfile(resolveProfile(opts.profile));
|
|
3060
|
+
const blocks = await client.documents.blocks(id, {
|
|
3061
|
+
addresses: addresses.length ? addresses : void 0,
|
|
3062
|
+
section: opts.section
|
|
3063
|
+
});
|
|
3064
|
+
console.log(JSON.stringify(blocks, null, 2));
|
|
3065
|
+
} catch (err) {
|
|
3066
|
+
console.error(formatErrorForCli(err));
|
|
3067
|
+
process.exitCode = 1;
|
|
3068
|
+
return;
|
|
3069
|
+
}
|
|
3070
|
+
});
|
|
3071
|
+
cmd.command("patch <id>").description("Change specific blocks by address, leaving the rest of the document untouched").option("--replace <address>", "replace this block with --content").option("--insert-after <address>", "insert --content after this block").option("--insert-before <address>", "insert --content before this block").option("--delete <address>", "delete this block").option("-c, --content <text>", 'markdown for the new block(s) (use "-" for stdin)').option("--content-file <path>", "read content from a file").option("--edits-file <path>", 'JSON array of {op, address, content} edits ("-" for stdin)').option("-p, --profile <name>").action(async (id, opts) => {
|
|
3072
|
+
try {
|
|
3073
|
+
let edits;
|
|
3074
|
+
const single = [
|
|
3075
|
+
["replace", opts.replace],
|
|
3076
|
+
["insert_after", opts.insertAfter],
|
|
3077
|
+
["insert_before", opts.insertBefore],
|
|
3078
|
+
["delete", opts.delete]
|
|
3079
|
+
].filter(([, address]) => address);
|
|
3080
|
+
if (opts.editsFile) {
|
|
3081
|
+
if (single.length) throw new Error("Use --edits-file or a single-edit flag, not both.");
|
|
3082
|
+
edits = JSON.parse(readFileSync2(opts.editsFile === "-" ? 0 : opts.editsFile, "utf8"));
|
|
3083
|
+
if (!Array.isArray(edits)) throw new Error("--edits-file must contain a JSON array of edits.");
|
|
3084
|
+
} else {
|
|
3085
|
+
if (single.length !== 1) {
|
|
3086
|
+
throw new Error("Pass exactly one of --replace, --insert-after, --insert-before or --delete (or --edits-file for several).");
|
|
3087
|
+
}
|
|
3088
|
+
const [op, address] = single[0];
|
|
3089
|
+
const content = readContent(opts);
|
|
3090
|
+
if (op !== "delete" && content === void 0) throw new Error(`--${op.replace("_", "-")} needs --content or --content-file.`);
|
|
3091
|
+
edits = [{ op, address, ...op !== "delete" ? { content } : {} }];
|
|
3092
|
+
}
|
|
3093
|
+
const client = HelmClient.fromProfile(resolveProfile(opts.profile));
|
|
3094
|
+
const result = await client.documents.patch(id, edits);
|
|
3095
|
+
console.log(JSON.stringify(result, null, 2));
|
|
3096
|
+
if (typeof result.failed === "number" && result.failed > 0) process.exitCode = 1;
|
|
3097
|
+
} catch (err) {
|
|
3098
|
+
console.error(formatErrorForCli(err));
|
|
3099
|
+
process.exitCode = 1;
|
|
3100
|
+
return;
|
|
3101
|
+
}
|
|
3102
|
+
});
|
|
2834
3103
|
const page = cmd.command("page").description("Manage pages within a document");
|
|
2835
3104
|
page.command("list <documentId>").description("List the pages in a document").option("-o, --output <format>").option("-p, --profile <name>").action(async (documentId, opts) => {
|
|
2836
3105
|
try {
|
|
@@ -2840,7 +3109,8 @@ function registerDocCommands(parent) {
|
|
|
2840
3109
|
{ header: "Order", get: (r) => String(r.page_order) },
|
|
2841
3110
|
{ header: "Title", get: (r) => r.title, truncate: 40 },
|
|
2842
3111
|
{ header: "Updated", get: (r) => r.updated_at?.slice(0, 10) },
|
|
2843
|
-
|
|
3112
|
+
// Full IDs: page update/delete/reorder take them as arguments.
|
|
3113
|
+
{ header: "ID", get: (r) => r.id }
|
|
2844
3114
|
], opts.output ?? defaultFormat()));
|
|
2845
3115
|
} catch (err) {
|
|
2846
3116
|
console.error(formatErrorForCli(err));
|
|
@@ -2848,7 +3118,7 @@ function registerDocCommands(parent) {
|
|
|
2848
3118
|
return;
|
|
2849
3119
|
}
|
|
2850
3120
|
});
|
|
2851
|
-
page.command("create <documentId>").description("Add a page to a document (content from --content, --content-file, or stdin with -c -)").option("-t, --title <title>", "page title", "Untitled Page").option("-c, --content <text>", 'content as markdown (use "-" for stdin)').option("--content-file <path>", "read content from a file").option("--icon <name>", "icon name (e.g. FileText)").option("--order <n>", "zero-based position; omit to append at end",
|
|
3121
|
+
page.command("create <documentId>").description("Add a page to a document (content from --content, --content-file, or stdin with -c -)").option("-t, --title <title>", "page title", "Untitled Page").option("-c, --content <text>", 'content as markdown (use "-" for stdin)').option("--content-file <path>", "read content from a file").option("--icon <name>", "icon name (e.g. FileText)").option("--order <n>", "zero-based position; omit to append at end", parsePosition).option("-p, --profile <name>").action(async (documentId, opts) => {
|
|
2852
3122
|
try {
|
|
2853
3123
|
const client = HelmClient.fromProfile(resolveProfile(opts.profile));
|
|
2854
3124
|
const newPage = await client.documents.createPage(documentId, {
|
|
@@ -2864,6 +3134,48 @@ function registerDocCommands(parent) {
|
|
|
2864
3134
|
return;
|
|
2865
3135
|
}
|
|
2866
3136
|
});
|
|
3137
|
+
page.command("update <documentId> <pageId>").description("Rename, rewrite, re-icon or move a page (content from --content, --content-file, or stdin with -c -)").option("-t, --title <title>", "new page title").option("-c, --content <text>", 'replacement content as markdown (use "-" for stdin)').option("--content-file <path>", "read replacement content from a file").option("--icon <name>", 'icon name (e.g. FileText); "" clears it').option("--order <n>", "move to this zero-based position; the other pages shift", parsePosition).option("-p, --profile <name>").action(async (documentId, pageId, opts) => {
|
|
3138
|
+
try {
|
|
3139
|
+
const client = HelmClient.fromProfile(resolveProfile(opts.profile));
|
|
3140
|
+
const updated = await client.documents.updatePage(documentId, pageId, {
|
|
3141
|
+
title: opts.title,
|
|
3142
|
+
content: readContent(opts),
|
|
3143
|
+
icon: opts.icon,
|
|
3144
|
+
page_order: opts.order
|
|
3145
|
+
});
|
|
3146
|
+
console.log(JSON.stringify(updated, null, 2));
|
|
3147
|
+
} catch (err) {
|
|
3148
|
+
console.error(formatErrorForCli(err));
|
|
3149
|
+
process.exitCode = 1;
|
|
3150
|
+
return;
|
|
3151
|
+
}
|
|
3152
|
+
});
|
|
3153
|
+
page.command("delete <documentId> <pageId>").description("Delete a page and the comments on it (cannot be undone)").option("-p, --profile <name>").action(async (documentId, pageId, opts) => {
|
|
3154
|
+
try {
|
|
3155
|
+
const client = HelmClient.fromProfile(resolveProfile(opts.profile));
|
|
3156
|
+
const result = await client.documents.deletePage(documentId, pageId);
|
|
3157
|
+
console.log(result.message);
|
|
3158
|
+
} catch (err) {
|
|
3159
|
+
console.error(formatErrorForCli(err));
|
|
3160
|
+
process.exitCode = 1;
|
|
3161
|
+
return;
|
|
3162
|
+
}
|
|
3163
|
+
});
|
|
3164
|
+
page.command("reorder <documentId> <pageIds...>").description("Put the pages in a new order; list every page ID once, first page excluded").option("-o, --output <format>").option("-p, --profile <name>").action(async (documentId, pageIds, opts) => {
|
|
3165
|
+
try {
|
|
3166
|
+
const client = HelmClient.fromProfile(resolveProfile(opts.profile));
|
|
3167
|
+
const rows = await client.documents.reorderPages(documentId, pageIds);
|
|
3168
|
+
console.log(render(rows, [
|
|
3169
|
+
{ header: "Order", get: (r) => String(r.page_order) },
|
|
3170
|
+
{ header: "Title", get: (r) => r.title, truncate: 40 },
|
|
3171
|
+
{ header: "ID", get: (r) => r.id }
|
|
3172
|
+
], opts.output ?? defaultFormat()));
|
|
3173
|
+
} catch (err) {
|
|
3174
|
+
console.error(formatErrorForCli(err));
|
|
3175
|
+
process.exitCode = 1;
|
|
3176
|
+
return;
|
|
3177
|
+
}
|
|
3178
|
+
});
|
|
2867
3179
|
}
|
|
2868
3180
|
|
|
2869
3181
|
// src/commands/agent.ts
|
|
@@ -4071,7 +4383,7 @@ function registerEmailCommands(parent) {
|
|
|
4071
4383
|
}
|
|
4072
4384
|
|
|
4073
4385
|
// src/cli.ts
|
|
4074
|
-
var program = new
|
|
4386
|
+
var program = new Command2();
|
|
4075
4387
|
program.name("helm-ai").description("Helm CLI \u2014 run your business operations (projects, CRM, billing, automations, AI agents) from the terminal").version(version, "-v, --version").addHelpText("beforeAll", () => process.stdout.isTTY ? renderSplash({ version }) : "");
|
|
4076
4388
|
registerAuthCommands(program);
|
|
4077
4389
|
registerProfileCommands(program);
|
|
@@ -4085,6 +4397,7 @@ registerTaskCommands(program);
|
|
|
4085
4397
|
registerTimeCommands(program);
|
|
4086
4398
|
registerInvoiceCommands(program);
|
|
4087
4399
|
registerPaymentCommands(program);
|
|
4400
|
+
registerSubscriptionCommands(program);
|
|
4088
4401
|
registerEstimateCommands(program);
|
|
4089
4402
|
registerProductCommands(program);
|
|
4090
4403
|
registerFormCommands(program);
|