@helm-ai/cli 0.22.0 → 0.24.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 +236 -20
- 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.24.0";
|
|
29
29
|
|
|
30
30
|
// src/commands/auth.ts
|
|
31
31
|
import prompts from "prompts";
|
|
@@ -579,6 +579,33 @@ var HelmClient = class _HelmClient {
|
|
|
579
579
|
if (data.page) return data.page;
|
|
580
580
|
const { page_id, message: _msg, ...rest } = data;
|
|
581
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 });
|
|
582
609
|
}
|
|
583
610
|
};
|
|
584
611
|
agentSchedules = {
|
|
@@ -2160,6 +2187,77 @@ function registerTimeCommands(parent) {
|
|
|
2160
2187
|
});
|
|
2161
2188
|
}
|
|
2162
2189
|
|
|
2190
|
+
// src/lib/line-items.ts
|
|
2191
|
+
import { readFileSync as readFileSync2 } from "fs";
|
|
2192
|
+
import { InvalidArgumentError } from "commander";
|
|
2193
|
+
function parseLineItem(value) {
|
|
2194
|
+
const parts = value.split("|");
|
|
2195
|
+
if (parts.length < 2) {
|
|
2196
|
+
throw new Error(`Invalid --item "${value}". Use "description|quantity|rate" or "description|rate".`);
|
|
2197
|
+
}
|
|
2198
|
+
const num = (s, label) => {
|
|
2199
|
+
const n = Number(s.trim().replace(/^\$/, "").replace(/,/g, ""));
|
|
2200
|
+
if (s.trim() === "" || !Number.isFinite(n)) throw new Error(`Invalid ${label} "${s}" in --item "${value}"`);
|
|
2201
|
+
return n;
|
|
2202
|
+
};
|
|
2203
|
+
const rate = num(parts.pop(), "rate");
|
|
2204
|
+
let quantity = 1;
|
|
2205
|
+
if (parts.length >= 2) {
|
|
2206
|
+
const maybeQty = Number(parts[parts.length - 1].trim());
|
|
2207
|
+
if (parts[parts.length - 1].trim() !== "" && Number.isFinite(maybeQty)) {
|
|
2208
|
+
quantity = maybeQty;
|
|
2209
|
+
parts.pop();
|
|
2210
|
+
}
|
|
2211
|
+
}
|
|
2212
|
+
const description = parts.join("|").trim();
|
|
2213
|
+
if (!description) throw new Error(`Missing description in --item "${value}"`);
|
|
2214
|
+
if (quantity <= 0) throw new Error(`Quantity must be greater than 0 in --item "${value}"`);
|
|
2215
|
+
return { description, quantity, rate };
|
|
2216
|
+
}
|
|
2217
|
+
function collectLineItem(value, previous = []) {
|
|
2218
|
+
try {
|
|
2219
|
+
return [...previous, parseLineItem(value)];
|
|
2220
|
+
} catch (e) {
|
|
2221
|
+
throw new InvalidArgumentError(e.message);
|
|
2222
|
+
}
|
|
2223
|
+
}
|
|
2224
|
+
async function readLineItemsFile(path) {
|
|
2225
|
+
let raw;
|
|
2226
|
+
if (path === "-") {
|
|
2227
|
+
const chunks = [];
|
|
2228
|
+
for await (const chunk of process.stdin) chunks.push(chunk);
|
|
2229
|
+
raw = Buffer.concat(chunks).toString("utf8");
|
|
2230
|
+
} else {
|
|
2231
|
+
raw = readFileSync2(path, "utf8");
|
|
2232
|
+
}
|
|
2233
|
+
let parsed;
|
|
2234
|
+
try {
|
|
2235
|
+
parsed = JSON.parse(raw);
|
|
2236
|
+
} catch (e) {
|
|
2237
|
+
throw new Error(`Invalid JSON in ${path === "-" ? "stdin" : path}: ${e.message}`);
|
|
2238
|
+
}
|
|
2239
|
+
if (!Array.isArray(parsed)) throw new Error("--items must be a JSON array of {description, quantity, rate}");
|
|
2240
|
+
return parsed.map((item, i) => {
|
|
2241
|
+
if (!item || typeof item !== "object" || typeof item.description !== "string" || !item.description.trim()) {
|
|
2242
|
+
throw new Error(`--items[${i}] needs a description`);
|
|
2243
|
+
}
|
|
2244
|
+
if (item.rate != null && !Number.isFinite(Number(item.rate))) throw new Error(`--items[${i}] has an invalid rate`);
|
|
2245
|
+
if (item.quantity != null && !(Number(item.quantity) > 0)) throw new Error(`--items[${i}] needs a quantity greater than 0`);
|
|
2246
|
+
return {
|
|
2247
|
+
...item,
|
|
2248
|
+
quantity: item.quantity != null ? Number(item.quantity) : 1,
|
|
2249
|
+
rate: item.rate != null ? Number(item.rate) : 0
|
|
2250
|
+
};
|
|
2251
|
+
});
|
|
2252
|
+
}
|
|
2253
|
+
async function resolveLineItems(opts) {
|
|
2254
|
+
const fromFile = opts.items ? await readLineItemsFile(opts.items) : [];
|
|
2255
|
+
const all = [...fromFile, ...opts.item ?? []];
|
|
2256
|
+
return all.length ? all : void 0;
|
|
2257
|
+
}
|
|
2258
|
+
var LINE_ITEM_HELP = 'line item "description|quantity|rate" or "description|rate" (repeatable)';
|
|
2259
|
+
var LINE_ITEMS_FILE_HELP = 'JSON array of line items [{description, quantity, rate}] (path, or "-" for stdin)';
|
|
2260
|
+
|
|
2163
2261
|
// src/commands/invoice.ts
|
|
2164
2262
|
function registerInvoiceCommands(parent) {
|
|
2165
2263
|
const cmd = parent.command("invoice").alias("invoices").description("Manage invoices");
|
|
@@ -2197,7 +2295,11 @@ function registerInvoiceCommands(parent) {
|
|
|
2197
2295
|
return;
|
|
2198
2296
|
}
|
|
2199
2297
|
});
|
|
2200
|
-
cmd.command("create").description("Create an invoice").requiredOption("-t, --title <title>", "invoice title (required)").option("-d, --description <text>").option("-a, --account <id>").option("--deal <id>", "deal this invoice bills against").option("--tax-rate <pct>", "tax rate %", parseFloat).option("--issue-date <date>", "ISO 8601").option("--due-date <date>", "ISO 8601").option("--notes <text>", "client-visible notes").option("--internal-notes <text>").option("-p, --profile <name>").
|
|
2298
|
+
cmd.command("create").description("Create an invoice").requiredOption("-t, --title <title>", "invoice title (required)").option("-d, --description <text>").option("-a, --account <id>").option("--deal <id>", "deal this invoice bills against").option("-i, --item <item>", LINE_ITEM_HELP, collectLineItem).option("--items <path>", LINE_ITEMS_FILE_HELP).option("--tax-rate <pct>", "tax rate %", parseFloat).option("--issue-date <date>", "ISO 8601").option("--due-date <date>", "ISO 8601").option("--notes <text>", "client-visible notes").option("--internal-notes <text>").option("-p, --profile <name>").addHelpText("after", `
|
|
2299
|
+
Examples:
|
|
2300
|
+
helm-ai invoice create -t "October retainer" -a <account-id> \\
|
|
2301
|
+
--item "Development|10|150" --item "Hosting|49"
|
|
2302
|
+
helm-ai invoice create -t "October retainer" -a <account-id> --items items.json`).action(async (opts) => {
|
|
2201
2303
|
try {
|
|
2202
2304
|
const client = HelmClient.fromProfile(resolveProfile(opts.profile));
|
|
2203
2305
|
const invoice = await client.invoices.create({
|
|
@@ -2205,6 +2307,7 @@ function registerInvoiceCommands(parent) {
|
|
|
2205
2307
|
description: opts.description,
|
|
2206
2308
|
account_id: opts.account,
|
|
2207
2309
|
deal_id: opts.deal,
|
|
2310
|
+
line_items: await resolveLineItems(opts),
|
|
2208
2311
|
tax_rate: opts.taxRate,
|
|
2209
2312
|
issue_date: opts.issueDate,
|
|
2210
2313
|
due_date: opts.dueDate,
|
|
@@ -2458,17 +2561,24 @@ function registerEstimateCommands(parent) {
|
|
|
2458
2561
|
return;
|
|
2459
2562
|
}
|
|
2460
2563
|
});
|
|
2461
|
-
cmd.command("create").description("Create an estimate").requiredOption("-t, --title <title>", "estimate title (required)").option("-d, --description <text>").option("-a, --account <id>").option("--tax-rate <pct>", "", parseFloat).option("--issue-date <date>").option("--expiry-date <date>").option("--notes <text>").option("-p, --profile <name>").
|
|
2564
|
+
cmd.command("create").description("Create an estimate").requiredOption("-t, --title <title>", "estimate title (required)").option("-d, --description <text>").option("-a, --account <id>").option("-c, --contact <id>", "person at the account the estimate is addressed to").option("-i, --item <item>", LINE_ITEM_HELP, collectLineItem).option("--items <path>", LINE_ITEMS_FILE_HELP).option("--tax-rate <pct>", "", parseFloat).option("--issue-date <date>").option("--expiry-date <date>").option("--notes <text>").option("--internal-notes <text>").option("-p, --profile <name>").addHelpText("after", `
|
|
2565
|
+
Examples:
|
|
2566
|
+
helm-ai estimate create -t "Launch readiness" -a <account-id> \\
|
|
2567
|
+
--item "Checkout fixes|4|150" --item "Speed pass|500"
|
|
2568
|
+
helm-ai estimate create -t "Launch readiness" --items items.json`).action(async (opts) => {
|
|
2462
2569
|
try {
|
|
2463
2570
|
const client = HelmClient.fromProfile(resolveProfile(opts.profile));
|
|
2464
2571
|
const estimate = await client.estimates.create({
|
|
2465
2572
|
title: opts.title,
|
|
2466
2573
|
description: opts.description,
|
|
2467
2574
|
account_id: opts.account,
|
|
2575
|
+
contact_id: opts.contact,
|
|
2576
|
+
line_items: await resolveLineItems(opts),
|
|
2468
2577
|
tax_rate: opts.taxRate,
|
|
2469
2578
|
issue_date: opts.issueDate,
|
|
2470
2579
|
expiry_date: opts.expiryDate,
|
|
2471
|
-
notes: opts.notes
|
|
2580
|
+
notes: opts.notes,
|
|
2581
|
+
internal_notes: opts.internalNotes
|
|
2472
2582
|
});
|
|
2473
2583
|
console.log(JSON.stringify(estimate, null, 2));
|
|
2474
2584
|
} catch (err) {
|
|
@@ -2933,12 +3043,18 @@ function registerCalendarCommands(parent) {
|
|
|
2933
3043
|
}
|
|
2934
3044
|
|
|
2935
3045
|
// src/commands/doc.ts
|
|
2936
|
-
import {
|
|
3046
|
+
import { InvalidArgumentError as InvalidArgumentError2 } from "commander";
|
|
3047
|
+
import { readFileSync as readFileSync3 } from "fs";
|
|
2937
3048
|
function readContent(opts) {
|
|
2938
|
-
if (opts.contentFile) return
|
|
2939
|
-
if (opts.content === "-") return
|
|
3049
|
+
if (opts.contentFile) return readFileSync3(opts.contentFile, "utf8");
|
|
3050
|
+
if (opts.content === "-") return readFileSync3(0, "utf8");
|
|
2940
3051
|
return opts.content;
|
|
2941
3052
|
}
|
|
3053
|
+
function parsePosition(value) {
|
|
3054
|
+
const n = Number(value);
|
|
3055
|
+
if (!Number.isInteger(n) || n < 0) throw new InvalidArgumentError2("must be a whole number, 0 or more");
|
|
3056
|
+
return n;
|
|
3057
|
+
}
|
|
2942
3058
|
function registerDocCommands(parent) {
|
|
2943
3059
|
const cmd = parent.command("doc").alias("docs").description("Manage documents");
|
|
2944
3060
|
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) => {
|
|
@@ -3010,6 +3126,63 @@ function registerDocCommands(parent) {
|
|
|
3010
3126
|
return;
|
|
3011
3127
|
}
|
|
3012
3128
|
});
|
|
3129
|
+
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) => {
|
|
3130
|
+
try {
|
|
3131
|
+
const client = HelmClient.fromProfile(resolveProfile(opts.profile));
|
|
3132
|
+
const outline = await client.documents.outline(id, opts.blocks ? "blocks" : "headings");
|
|
3133
|
+
console.log(JSON.stringify(outline, null, 2));
|
|
3134
|
+
} catch (err) {
|
|
3135
|
+
console.error(formatErrorForCli(err));
|
|
3136
|
+
process.exitCode = 1;
|
|
3137
|
+
return;
|
|
3138
|
+
}
|
|
3139
|
+
});
|
|
3140
|
+
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) => {
|
|
3141
|
+
try {
|
|
3142
|
+
const client = HelmClient.fromProfile(resolveProfile(opts.profile));
|
|
3143
|
+
const blocks = await client.documents.blocks(id, {
|
|
3144
|
+
addresses: addresses.length ? addresses : void 0,
|
|
3145
|
+
section: opts.section
|
|
3146
|
+
});
|
|
3147
|
+
console.log(JSON.stringify(blocks, null, 2));
|
|
3148
|
+
} catch (err) {
|
|
3149
|
+
console.error(formatErrorForCli(err));
|
|
3150
|
+
process.exitCode = 1;
|
|
3151
|
+
return;
|
|
3152
|
+
}
|
|
3153
|
+
});
|
|
3154
|
+
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) => {
|
|
3155
|
+
try {
|
|
3156
|
+
let edits;
|
|
3157
|
+
const single = [
|
|
3158
|
+
["replace", opts.replace],
|
|
3159
|
+
["insert_after", opts.insertAfter],
|
|
3160
|
+
["insert_before", opts.insertBefore],
|
|
3161
|
+
["delete", opts.delete]
|
|
3162
|
+
].filter(([, address]) => address);
|
|
3163
|
+
if (opts.editsFile) {
|
|
3164
|
+
if (single.length) throw new Error("Use --edits-file or a single-edit flag, not both.");
|
|
3165
|
+
edits = JSON.parse(readFileSync3(opts.editsFile === "-" ? 0 : opts.editsFile, "utf8"));
|
|
3166
|
+
if (!Array.isArray(edits)) throw new Error("--edits-file must contain a JSON array of edits.");
|
|
3167
|
+
} else {
|
|
3168
|
+
if (single.length !== 1) {
|
|
3169
|
+
throw new Error("Pass exactly one of --replace, --insert-after, --insert-before or --delete (or --edits-file for several).");
|
|
3170
|
+
}
|
|
3171
|
+
const [op, address] = single[0];
|
|
3172
|
+
const content = readContent(opts);
|
|
3173
|
+
if (op !== "delete" && content === void 0) throw new Error(`--${op.replace("_", "-")} needs --content or --content-file.`);
|
|
3174
|
+
edits = [{ op, address, ...op !== "delete" ? { content } : {} }];
|
|
3175
|
+
}
|
|
3176
|
+
const client = HelmClient.fromProfile(resolveProfile(opts.profile));
|
|
3177
|
+
const result = await client.documents.patch(id, edits);
|
|
3178
|
+
console.log(JSON.stringify(result, null, 2));
|
|
3179
|
+
if (typeof result.failed === "number" && result.failed > 0) process.exitCode = 1;
|
|
3180
|
+
} catch (err) {
|
|
3181
|
+
console.error(formatErrorForCli(err));
|
|
3182
|
+
process.exitCode = 1;
|
|
3183
|
+
return;
|
|
3184
|
+
}
|
|
3185
|
+
});
|
|
3013
3186
|
const page = cmd.command("page").description("Manage pages within a document");
|
|
3014
3187
|
page.command("list <documentId>").description("List the pages in a document").option("-o, --output <format>").option("-p, --profile <name>").action(async (documentId, opts) => {
|
|
3015
3188
|
try {
|
|
@@ -3019,7 +3192,8 @@ function registerDocCommands(parent) {
|
|
|
3019
3192
|
{ header: "Order", get: (r) => String(r.page_order) },
|
|
3020
3193
|
{ header: "Title", get: (r) => r.title, truncate: 40 },
|
|
3021
3194
|
{ header: "Updated", get: (r) => r.updated_at?.slice(0, 10) },
|
|
3022
|
-
|
|
3195
|
+
// Full IDs: page update/delete/reorder take them as arguments.
|
|
3196
|
+
{ header: "ID", get: (r) => r.id }
|
|
3023
3197
|
], opts.output ?? defaultFormat()));
|
|
3024
3198
|
} catch (err) {
|
|
3025
3199
|
console.error(formatErrorForCli(err));
|
|
@@ -3027,7 +3201,7 @@ function registerDocCommands(parent) {
|
|
|
3027
3201
|
return;
|
|
3028
3202
|
}
|
|
3029
3203
|
});
|
|
3030
|
-
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",
|
|
3204
|
+
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) => {
|
|
3031
3205
|
try {
|
|
3032
3206
|
const client = HelmClient.fromProfile(resolveProfile(opts.profile));
|
|
3033
3207
|
const newPage = await client.documents.createPage(documentId, {
|
|
@@ -3043,6 +3217,48 @@ function registerDocCommands(parent) {
|
|
|
3043
3217
|
return;
|
|
3044
3218
|
}
|
|
3045
3219
|
});
|
|
3220
|
+
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) => {
|
|
3221
|
+
try {
|
|
3222
|
+
const client = HelmClient.fromProfile(resolveProfile(opts.profile));
|
|
3223
|
+
const updated = await client.documents.updatePage(documentId, pageId, {
|
|
3224
|
+
title: opts.title,
|
|
3225
|
+
content: readContent(opts),
|
|
3226
|
+
icon: opts.icon,
|
|
3227
|
+
page_order: opts.order
|
|
3228
|
+
});
|
|
3229
|
+
console.log(JSON.stringify(updated, null, 2));
|
|
3230
|
+
} catch (err) {
|
|
3231
|
+
console.error(formatErrorForCli(err));
|
|
3232
|
+
process.exitCode = 1;
|
|
3233
|
+
return;
|
|
3234
|
+
}
|
|
3235
|
+
});
|
|
3236
|
+
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) => {
|
|
3237
|
+
try {
|
|
3238
|
+
const client = HelmClient.fromProfile(resolveProfile(opts.profile));
|
|
3239
|
+
const result = await client.documents.deletePage(documentId, pageId);
|
|
3240
|
+
console.log(result.message);
|
|
3241
|
+
} catch (err) {
|
|
3242
|
+
console.error(formatErrorForCli(err));
|
|
3243
|
+
process.exitCode = 1;
|
|
3244
|
+
return;
|
|
3245
|
+
}
|
|
3246
|
+
});
|
|
3247
|
+
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) => {
|
|
3248
|
+
try {
|
|
3249
|
+
const client = HelmClient.fromProfile(resolveProfile(opts.profile));
|
|
3250
|
+
const rows = await client.documents.reorderPages(documentId, pageIds);
|
|
3251
|
+
console.log(render(rows, [
|
|
3252
|
+
{ header: "Order", get: (r) => String(r.page_order) },
|
|
3253
|
+
{ header: "Title", get: (r) => r.title, truncate: 40 },
|
|
3254
|
+
{ header: "ID", get: (r) => r.id }
|
|
3255
|
+
], opts.output ?? defaultFormat()));
|
|
3256
|
+
} catch (err) {
|
|
3257
|
+
console.error(formatErrorForCli(err));
|
|
3258
|
+
process.exitCode = 1;
|
|
3259
|
+
return;
|
|
3260
|
+
}
|
|
3261
|
+
});
|
|
3046
3262
|
}
|
|
3047
3263
|
|
|
3048
3264
|
// src/commands/agent.ts
|
|
@@ -3204,11 +3420,11 @@ import ora from "ora";
|
|
|
3204
3420
|
import { writeFileSync as writeFileSync2 } from "fs";
|
|
3205
3421
|
|
|
3206
3422
|
// src/lib/csv.ts
|
|
3207
|
-
import { readFileSync as
|
|
3423
|
+
import { readFileSync as readFileSync4 } from "fs";
|
|
3208
3424
|
import { parse as parse2 } from "csv-parse/sync";
|
|
3209
3425
|
function readDataFile(path) {
|
|
3210
3426
|
const ext = path.toLowerCase().split(".").pop();
|
|
3211
|
-
const raw =
|
|
3427
|
+
const raw = readFileSync4(path, "utf8");
|
|
3212
3428
|
if (ext === "json") {
|
|
3213
3429
|
const data = JSON.parse(raw);
|
|
3214
3430
|
if (!Array.isArray(data)) throw new Error("JSON file must contain an array of objects");
|
|
@@ -3786,8 +4002,8 @@ async function readJsonSource(path) {
|
|
|
3786
4002
|
for await (const chunk of process.stdin) chunks.push(chunk);
|
|
3787
4003
|
raw = Buffer.concat(chunks).toString("utf8");
|
|
3788
4004
|
} else {
|
|
3789
|
-
const { readFileSync:
|
|
3790
|
-
raw =
|
|
4005
|
+
const { readFileSync: readFileSync6 } = await import("fs");
|
|
4006
|
+
raw = readFileSync6(path, "utf8");
|
|
3791
4007
|
}
|
|
3792
4008
|
try {
|
|
3793
4009
|
return JSON.parse(raw);
|
|
@@ -3882,8 +4098,8 @@ function registerWorkflowCommands(parent) {
|
|
|
3882
4098
|
try {
|
|
3883
4099
|
let triggerData;
|
|
3884
4100
|
if (opts.dataFile) {
|
|
3885
|
-
const { readFileSync:
|
|
3886
|
-
triggerData = JSON.parse(
|
|
4101
|
+
const { readFileSync: readFileSync6 } = await import("fs");
|
|
4102
|
+
triggerData = JSON.parse(readFileSync6(opts.dataFile, "utf8"));
|
|
3887
4103
|
} else if (opts.data) {
|
|
3888
4104
|
triggerData = JSON.parse(opts.data);
|
|
3889
4105
|
}
|
|
@@ -4118,7 +4334,7 @@ Next: add emails with
|
|
|
4118
4334
|
}
|
|
4119
4335
|
|
|
4120
4336
|
// src/commands/email.ts
|
|
4121
|
-
import { readFileSync as
|
|
4337
|
+
import { readFileSync as readFileSync5 } from "fs";
|
|
4122
4338
|
function registerEmailCommands(parent) {
|
|
4123
4339
|
const cmd = parent.command("email").description("Draft and revise email from your own address");
|
|
4124
4340
|
cmd.command("identities").alias("addresses").description("List the addresses you can send from").option("-o, --output <format>").option("-p, --profile <name>").action(async (opts) => {
|
|
@@ -4150,7 +4366,7 @@ function registerEmailCommands(parent) {
|
|
|
4150
4366
|
const splitAddrs = (v) => (v ?? "").split(",").map((s) => s.trim()).filter(Boolean);
|
|
4151
4367
|
let body = opts.body;
|
|
4152
4368
|
if (opts.bodyFile) {
|
|
4153
|
-
body =
|
|
4369
|
+
body = readFileSync5(opts.bodyFile === "-" ? 0 : opts.bodyFile, "utf8");
|
|
4154
4370
|
}
|
|
4155
4371
|
if (!body && !opts.html) {
|
|
4156
4372
|
throw new Error("--body, --body-file, or --html is required");
|
|
@@ -4211,7 +4427,7 @@ function registerEmailCommands(parent) {
|
|
|
4211
4427
|
const splitAddrs = (v) => v.split(",").map((s) => s.trim()).filter(Boolean);
|
|
4212
4428
|
let body = opts.body;
|
|
4213
4429
|
if (opts.bodyFile) {
|
|
4214
|
-
body =
|
|
4430
|
+
body = readFileSync5(opts.bodyFile === "-" ? 0 : opts.bodyFile, "utf8");
|
|
4215
4431
|
}
|
|
4216
4432
|
const client = HelmClient.fromProfile(resolveProfile(opts.profile));
|
|
4217
4433
|
const draft = await client.email.updateDraft({
|
|
@@ -4250,7 +4466,7 @@ function registerEmailCommands(parent) {
|
|
|
4250
4466
|
}
|
|
4251
4467
|
|
|
4252
4468
|
// src/cli.ts
|
|
4253
|
-
var program = new
|
|
4469
|
+
var program = new Command2();
|
|
4254
4470
|
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 }) : "");
|
|
4255
4471
|
registerAuthCommands(program);
|
|
4256
4472
|
registerProfileCommands(program);
|