@helm-ai/cli 0.22.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 +138 -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";
|
|
@@ -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 = {
|
|
@@ -2933,12 +2960,18 @@ function registerCalendarCommands(parent) {
|
|
|
2933
2960
|
}
|
|
2934
2961
|
|
|
2935
2962
|
// src/commands/doc.ts
|
|
2963
|
+
import { InvalidArgumentError } from "commander";
|
|
2936
2964
|
import { readFileSync as readFileSync2 } from "fs";
|
|
2937
2965
|
function readContent(opts) {
|
|
2938
2966
|
if (opts.contentFile) return readFileSync2(opts.contentFile, "utf8");
|
|
2939
2967
|
if (opts.content === "-") return readFileSync2(0, "utf8");
|
|
2940
2968
|
return opts.content;
|
|
2941
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
|
+
}
|
|
2942
2975
|
function registerDocCommands(parent) {
|
|
2943
2976
|
const cmd = parent.command("doc").alias("docs").description("Manage documents");
|
|
2944
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) => {
|
|
@@ -3010,6 +3043,63 @@ function registerDocCommands(parent) {
|
|
|
3010
3043
|
return;
|
|
3011
3044
|
}
|
|
3012
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
|
+
});
|
|
3013
3103
|
const page = cmd.command("page").description("Manage pages within a document");
|
|
3014
3104
|
page.command("list <documentId>").description("List the pages in a document").option("-o, --output <format>").option("-p, --profile <name>").action(async (documentId, opts) => {
|
|
3015
3105
|
try {
|
|
@@ -3019,7 +3109,8 @@ function registerDocCommands(parent) {
|
|
|
3019
3109
|
{ header: "Order", get: (r) => String(r.page_order) },
|
|
3020
3110
|
{ header: "Title", get: (r) => r.title, truncate: 40 },
|
|
3021
3111
|
{ header: "Updated", get: (r) => r.updated_at?.slice(0, 10) },
|
|
3022
|
-
|
|
3112
|
+
// Full IDs: page update/delete/reorder take them as arguments.
|
|
3113
|
+
{ header: "ID", get: (r) => r.id }
|
|
3023
3114
|
], opts.output ?? defaultFormat()));
|
|
3024
3115
|
} catch (err) {
|
|
3025
3116
|
console.error(formatErrorForCli(err));
|
|
@@ -3027,7 +3118,7 @@ function registerDocCommands(parent) {
|
|
|
3027
3118
|
return;
|
|
3028
3119
|
}
|
|
3029
3120
|
});
|
|
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",
|
|
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) => {
|
|
3031
3122
|
try {
|
|
3032
3123
|
const client = HelmClient.fromProfile(resolveProfile(opts.profile));
|
|
3033
3124
|
const newPage = await client.documents.createPage(documentId, {
|
|
@@ -3043,6 +3134,48 @@ function registerDocCommands(parent) {
|
|
|
3043
3134
|
return;
|
|
3044
3135
|
}
|
|
3045
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
|
+
});
|
|
3046
3179
|
}
|
|
3047
3180
|
|
|
3048
3181
|
// src/commands/agent.ts
|
|
@@ -4250,7 +4383,7 @@ function registerEmailCommands(parent) {
|
|
|
4250
4383
|
}
|
|
4251
4384
|
|
|
4252
4385
|
// src/cli.ts
|
|
4253
|
-
var program = new
|
|
4386
|
+
var program = new Command2();
|
|
4254
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 }) : "");
|
|
4255
4388
|
registerAuthCommands(program);
|
|
4256
4389
|
registerProfileCommands(program);
|