@helm-ai/cli 1.0.0 → 1.2.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/README.md +1 -0
- package/dist/cli.js +123 -11
- package/package.json +1 -1
package/README.md
CHANGED
|
@@ -86,6 +86,7 @@ Every resource follows the same shape — `list`, `get <id>`, `create`, `update
|
|
|
86
86
|
| `company`, `contact`, `deal`, `pipeline` | Customers: companies, people, and the sales pipeline |
|
|
87
87
|
| `invoice`, `estimate`, `product` | Money: billing documents and the product catalog |
|
|
88
88
|
| `doc` | Rich-text documents, folders, and pages |
|
|
89
|
+
| `file` | Uploaded files and saved links: `list`, and `read` for the extracted text (`--text`) or a download (`--save`) |
|
|
89
90
|
| `calendar` | Events and meetings |
|
|
90
91
|
| `form`, `sequence`, `email` | Capture and follow-up |
|
|
91
92
|
| `workflow`, `template` | Automations and reusable project structures |
|
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 as
|
|
4
|
+
import { Command as Command4 } 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 = "1.
|
|
28
|
+
var version = "1.2.0";
|
|
29
29
|
|
|
30
30
|
// src/commands/auth.ts
|
|
31
31
|
import prompts from "prompts";
|
|
@@ -641,6 +641,22 @@ var HelmClient = class _HelmClient {
|
|
|
641
641
|
return data;
|
|
642
642
|
}
|
|
643
643
|
};
|
|
644
|
+
/** Uploaded files and saved links (Helm Files). Documents are `documents`. */
|
|
645
|
+
files = {
|
|
646
|
+
list: async (filters = {}) => {
|
|
647
|
+
const data = await this.request("list_files", "GET", filters);
|
|
648
|
+
return {
|
|
649
|
+
files: data.files ?? [],
|
|
650
|
+
total: data.total ?? null,
|
|
651
|
+
has_more: data.has_more === true
|
|
652
|
+
};
|
|
653
|
+
},
|
|
654
|
+
/** Extracted text when there is any, plus a download link valid for 5 minutes. */
|
|
655
|
+
read: async (fileId) => {
|
|
656
|
+
const data = await this.request("read_file", "GET", { file_id: fileId });
|
|
657
|
+
return data;
|
|
658
|
+
}
|
|
659
|
+
};
|
|
644
660
|
documents = {
|
|
645
661
|
list: async (filters = {}) => {
|
|
646
662
|
const data = await this.request("get_documents", "GET", filters);
|
|
@@ -1643,6 +1659,10 @@ function registerCompanyCommands(parent) {
|
|
|
1643
1659
|
|
|
1644
1660
|
// src/commands/deal.ts
|
|
1645
1661
|
import prompts2 from "prompts";
|
|
1662
|
+
function clearable(value) {
|
|
1663
|
+
if (value === void 0) return void 0;
|
|
1664
|
+
return value.trim() || null;
|
|
1665
|
+
}
|
|
1646
1666
|
function registerDealCommands(parent) {
|
|
1647
1667
|
const cmd = parent.command("deal").alias("deals").description("Manage sales deals");
|
|
1648
1668
|
cmd.command("list").description("List deals").option("--stage <stage>", "stage key (defined per pipeline; see `pipeline list`)").option("--priority <level>").option("-C, --company <id>").option("--pipeline <id>", "filter by pipeline ID (see `pipeline list`)").option("-l, --limit <n>", "max rows", (v) => parseInt(v, 10), 50).option("-o, --output <format>").option("-p, --profile <name>").action(async (opts) => {
|
|
@@ -1679,7 +1699,7 @@ function registerDealCommands(parent) {
|
|
|
1679
1699
|
return;
|
|
1680
1700
|
}
|
|
1681
1701
|
});
|
|
1682
|
-
cmd.command("create").description("Create a deal").requiredOption("-t, --title <title>", "deal title (required)").option("--pipeline <id>", "pipeline ID (defaults to the workspace default; see `pipeline list`)").option("--stage <stage>", "stage key (defaults to the pipeline first stage)").option("--priority <level>", "low|medium|high|urgent").option("--value <amount>", "deal value in dollars", parseFloat).option("--probability <pct>", "0-100", parseFloat).option("-C, --company <id>").option("--contact <id>", "link the deal to a contact/person (see `contact list`)").option("--close-date <date>", "expected close (ISO 8601)").option("-p, --profile <name>").action(async (opts) => {
|
|
1702
|
+
cmd.command("create").description("Create a deal").requiredOption("-t, --title <title>", "deal title (required)").option("--pipeline <id>", "pipeline ID (defaults to the workspace default; see `pipeline list`)").option("--stage <stage>", "stage key (defaults to the pipeline first stage)").option("--priority <level>", "low|medium|high|urgent").option("--value <amount>", "deal value in dollars", parseFloat).option("--probability <pct>", "0-100", parseFloat).option("-C, --company <id>").option("--contact <id>", "link the deal to a contact/person (see `contact list`)").option("--close-date <date>", "expected close (ISO 8601)").option("--next-step <text>", "what the deal is waiting on, in a sentence").option("--next-step-date <date>", "when the next step is due (YYYY-MM-DD)").option("--source <text>", "where the deal came from").option("-p, --profile <name>").action(async (opts) => {
|
|
1683
1703
|
try {
|
|
1684
1704
|
const client = HelmClient.fromProfile(resolveProfile(opts.profile));
|
|
1685
1705
|
const deal = await client.deals.create({
|
|
@@ -1691,7 +1711,10 @@ function registerDealCommands(parent) {
|
|
|
1691
1711
|
probability: opts.probability,
|
|
1692
1712
|
company_id: opts.company,
|
|
1693
1713
|
contact_id: opts.contact,
|
|
1694
|
-
expected_close_date: opts.closeDate
|
|
1714
|
+
expected_close_date: opts.closeDate,
|
|
1715
|
+
next_step: opts.nextStep,
|
|
1716
|
+
next_step_date: opts.nextStepDate,
|
|
1717
|
+
source: opts.source
|
|
1695
1718
|
});
|
|
1696
1719
|
console.log(JSON.stringify(deal, null, 2));
|
|
1697
1720
|
} catch (err) {
|
|
@@ -1700,7 +1723,7 @@ function registerDealCommands(parent) {
|
|
|
1700
1723
|
return;
|
|
1701
1724
|
}
|
|
1702
1725
|
});
|
|
1703
|
-
cmd.command("update <id>").description("Update a deal").option("-t, --title <title>").option("--pipeline <id>", "move the deal to another pipeline (see `pipeline list`)").option("--stage <stage>", "stage key within the deal pipeline").option("--priority <level>", "low|medium|high|urgent").option("--value <amount>", "deal value in dollars", parseFloat).option("--probability <pct>", "0-100", parseFloat).option("-C, --company <id>").option("--contact <id>", "link the deal to a contact/person (see `contact list`)").option("--close-date <date>", "expected close (ISO 8601)").option("-p, --profile <name>").action(async (id, opts) => {
|
|
1726
|
+
cmd.command("update <id>").description("Update a deal").option("-t, --title <title>").option("--pipeline <id>", "move the deal to another pipeline (see `pipeline list`)").option("--stage <stage>", "stage key within the deal pipeline").option("--priority <level>", "low|medium|high|urgent").option("--value <amount>", "deal value in dollars", parseFloat).option("--probability <pct>", "0-100", parseFloat).option("-C, --company <id>").option("--contact <id>", "link the deal to a contact/person (see `contact list`)").option("--close-date <date>", "expected close (ISO 8601)").option("--next-step <text>", "what the deal is waiting on, in a sentence").option("--next-step-date <date>", "when the next step is due (YYYY-MM-DD)").option("--source <text>", "where the deal came from").option("--lost-reason <text>", "why the deal was lost").option("-p, --profile <name>").action(async (id, opts) => {
|
|
1704
1727
|
try {
|
|
1705
1728
|
const client = HelmClient.fromProfile(resolveProfile(opts.profile));
|
|
1706
1729
|
const deal = await client.deals.update(id, {
|
|
@@ -1712,7 +1735,11 @@ function registerDealCommands(parent) {
|
|
|
1712
1735
|
probability: opts.probability,
|
|
1713
1736
|
company_id: opts.company,
|
|
1714
1737
|
contact_id: opts.contact,
|
|
1715
|
-
expected_close_date: opts.closeDate
|
|
1738
|
+
expected_close_date: opts.closeDate,
|
|
1739
|
+
next_step: clearable(opts.nextStep),
|
|
1740
|
+
next_step_date: clearable(opts.nextStepDate),
|
|
1741
|
+
source: clearable(opts.source),
|
|
1742
|
+
lost_reason: clearable(opts.lostReason)
|
|
1716
1743
|
});
|
|
1717
1744
|
console.log(JSON.stringify(deal, null, 2));
|
|
1718
1745
|
} catch (err) {
|
|
@@ -1784,14 +1811,14 @@ function registerPipelineCommands(parent) {
|
|
|
1784
1811
|
cmd.command("create").description("Create a pipeline (seeds default stages unless --stage given)").requiredOption("-n, --name <name>", "pipeline name (required)").option("-d, --description <text>").option("--color <name>", "accent color name").option("--default", "make this the default pipeline").option("--stage <key:label>", "seed stage (repeatable), e.g. --stage trial:Trial", collectStage, []).option("-p, --profile <name>").action(async (opts) => {
|
|
1785
1812
|
try {
|
|
1786
1813
|
const client = HelmClient.fromProfile(resolveProfile(opts.profile));
|
|
1787
|
-
const
|
|
1814
|
+
const pipeline2 = await client.pipelines.create({
|
|
1788
1815
|
name: opts.name,
|
|
1789
1816
|
description: opts.description,
|
|
1790
1817
|
color: opts.color,
|
|
1791
1818
|
is_default: opts.default,
|
|
1792
1819
|
stages: opts.stage.length ? opts.stage : void 0
|
|
1793
1820
|
});
|
|
1794
|
-
console.log(JSON.stringify(
|
|
1821
|
+
console.log(JSON.stringify(pipeline2, null, 2));
|
|
1795
1822
|
} catch (err) {
|
|
1796
1823
|
console.error(formatErrorForCli(err));
|
|
1797
1824
|
process.exitCode = 1;
|
|
@@ -1801,14 +1828,14 @@ function registerPipelineCommands(parent) {
|
|
|
1801
1828
|
cmd.command("update <id>").description("Update a pipeline").option("-n, --name <name>").option("-d, --description <text>").option("--color <name>").option("--default", "make this the default pipeline").option("--position <n>", "order position", (v) => parseInt(v, 10)).option("-p, --profile <name>").action(async (id, opts) => {
|
|
1802
1829
|
try {
|
|
1803
1830
|
const client = HelmClient.fromProfile(resolveProfile(opts.profile));
|
|
1804
|
-
const
|
|
1831
|
+
const pipeline2 = await client.pipelines.update(id, {
|
|
1805
1832
|
name: opts.name,
|
|
1806
1833
|
description: opts.description,
|
|
1807
1834
|
color: opts.color,
|
|
1808
1835
|
is_default: opts.default,
|
|
1809
1836
|
position: opts.position
|
|
1810
1837
|
});
|
|
1811
|
-
console.log(JSON.stringify(
|
|
1838
|
+
console.log(JSON.stringify(pipeline2, null, 2));
|
|
1812
1839
|
} catch (err) {
|
|
1813
1840
|
console.error(formatErrorForCli(err));
|
|
1814
1841
|
process.exitCode = 1;
|
|
@@ -3703,6 +3730,90 @@ function registerDocCommands(parent) {
|
|
|
3703
3730
|
});
|
|
3704
3731
|
}
|
|
3705
3732
|
|
|
3733
|
+
// src/commands/file.ts
|
|
3734
|
+
import { InvalidArgumentError as InvalidArgumentError4 } from "commander";
|
|
3735
|
+
import { createWriteStream } from "fs";
|
|
3736
|
+
import { Readable } from "stream";
|
|
3737
|
+
import { pipeline } from "stream/promises";
|
|
3738
|
+
var KINDS = ["image", "pdf", "spreadsheet", "video", "link", "other"];
|
|
3739
|
+
function parseKind(value) {
|
|
3740
|
+
if (!KINDS.includes(value)) {
|
|
3741
|
+
throw new InvalidArgumentError4(`must be one of: ${KINDS.join(", ")}`);
|
|
3742
|
+
}
|
|
3743
|
+
return value;
|
|
3744
|
+
}
|
|
3745
|
+
function parseCount(value) {
|
|
3746
|
+
const n = Number(value);
|
|
3747
|
+
if (!Number.isInteger(n) || n < 1) throw new InvalidArgumentError4("must be a whole number, 1 or more");
|
|
3748
|
+
return n;
|
|
3749
|
+
}
|
|
3750
|
+
function formatSize(bytes) {
|
|
3751
|
+
if (typeof bytes !== "number" || bytes < 0) return "";
|
|
3752
|
+
const units = ["B", "KB", "MB", "GB"];
|
|
3753
|
+
let n = bytes;
|
|
3754
|
+
let i = 0;
|
|
3755
|
+
while (n >= 1024 && i < units.length - 1) {
|
|
3756
|
+
n /= 1024;
|
|
3757
|
+
i++;
|
|
3758
|
+
}
|
|
3759
|
+
return i === 0 ? `${n} B` : `${n.toFixed(1)} ${units[i]}`;
|
|
3760
|
+
}
|
|
3761
|
+
function registerFileCommands(parent) {
|
|
3762
|
+
const cmd = parent.command("file").alias("files").description("Uploaded files and saved links (Helm Files)");
|
|
3763
|
+
cmd.command("list").description("List files, newest first").option("-q, --query <text>", "match part of the file name").option("-k, --kind <kind>", KINDS.join("|"), parseKind).option("--folder <id>", 'a folder id, or "root" for files in no folder').option("--company <id>", "files attached to this company").option("--project <id>", "files attached to this project").option("-l, --limit <n>", "max rows (up to 100)", parseCount, 25).option("-o, --output <format>").option("-p, --profile <name>").action(async (opts) => {
|
|
3764
|
+
try {
|
|
3765
|
+
const client = HelmClient.fromProfile(resolveProfile(opts.profile));
|
|
3766
|
+
const { files, total, has_more } = await client.files.list({
|
|
3767
|
+
query: opts.query,
|
|
3768
|
+
kind: opts.kind,
|
|
3769
|
+
folder_id: opts.folder,
|
|
3770
|
+
company_id: opts.company,
|
|
3771
|
+
project_id: opts.project,
|
|
3772
|
+
limit: opts.limit
|
|
3773
|
+
});
|
|
3774
|
+
console.log(render(files, [
|
|
3775
|
+
{ header: "Name", get: (r) => r.name, truncate: 40 },
|
|
3776
|
+
{ header: "Kind", get: (r) => r.kind },
|
|
3777
|
+
{ header: "Size", get: (r) => r.kind === "link" ? "" : formatSize(r.size_bytes) },
|
|
3778
|
+
{ header: "Folder", get: (r) => r.folder ?? "" },
|
|
3779
|
+
{ header: "Added", get: (r) => r.created_at?.slice(0, 10) },
|
|
3780
|
+
{ header: "ID", get: (r) => r.file_id }
|
|
3781
|
+
], opts.output ?? defaultFormat()));
|
|
3782
|
+
if (has_more) console.error(`Showing ${files.length}${total !== null ? ` of ${total}` : ""}. Use --limit for more.`);
|
|
3783
|
+
} catch (err) {
|
|
3784
|
+
console.error(formatErrorForCli(err));
|
|
3785
|
+
process.exitCode = 1;
|
|
3786
|
+
}
|
|
3787
|
+
});
|
|
3788
|
+
cmd.command("read <id>").description("Show a file: its extracted text and a 5-minute download link (JSON by default)").option("--text", "print only the extracted text").option("--save <path>", "download the file to this path").option("-p, --profile <name>").action(async (id, opts) => {
|
|
3789
|
+
try {
|
|
3790
|
+
const client = HelmClient.fromProfile(resolveProfile(opts.profile));
|
|
3791
|
+
const file = await client.files.read(id);
|
|
3792
|
+
if (opts.save) {
|
|
3793
|
+
if (!file.download_url) throw new Error(file.kind === "link" ? `That's a saved link: ${file.url}` : "No download link for that file.");
|
|
3794
|
+
const res = await fetch(file.download_url);
|
|
3795
|
+
if (!res.ok || !res.body) throw new Error(`Download failed (${res.status}).`);
|
|
3796
|
+
await pipeline(Readable.fromWeb(res.body), createWriteStream(opts.save));
|
|
3797
|
+
console.error(`Saved ${file.name} to ${opts.save}`);
|
|
3798
|
+
return;
|
|
3799
|
+
}
|
|
3800
|
+
if (opts.text) {
|
|
3801
|
+
if (typeof file.text !== "string") {
|
|
3802
|
+
const why = file.kind === "link" ? `it's a saved link: ${file.url}` : file.text_status === "pending" ? "its text is still being extracted" : "no text could be extracted from it";
|
|
3803
|
+
throw new Error(`No text for ${file.name}: ${why}.`);
|
|
3804
|
+
}
|
|
3805
|
+
console.log(file.text);
|
|
3806
|
+
if (file.text_truncated) console.error("(Only the first part of this file was extracted.)");
|
|
3807
|
+
return;
|
|
3808
|
+
}
|
|
3809
|
+
console.log(JSON.stringify(file, null, 2));
|
|
3810
|
+
} catch (err) {
|
|
3811
|
+
console.error(formatErrorForCli(err));
|
|
3812
|
+
process.exitCode = 1;
|
|
3813
|
+
}
|
|
3814
|
+
});
|
|
3815
|
+
}
|
|
3816
|
+
|
|
3706
3817
|
// src/commands/agent.ts
|
|
3707
3818
|
var DAY_MAP = {
|
|
3708
3819
|
sun: 0,
|
|
@@ -4908,7 +5019,7 @@ function registerEmailCommands(parent) {
|
|
|
4908
5019
|
}
|
|
4909
5020
|
|
|
4910
5021
|
// src/cli.ts
|
|
4911
|
-
var program = new
|
|
5022
|
+
var program = new Command4();
|
|
4912
5023
|
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 }) : "");
|
|
4913
5024
|
registerAuthCommands(program);
|
|
4914
5025
|
registerProfileCommands(program);
|
|
@@ -4929,6 +5040,7 @@ registerProductCommands(program);
|
|
|
4929
5040
|
registerFormCommands(program);
|
|
4930
5041
|
registerCalendarCommands(program);
|
|
4931
5042
|
registerDocCommands(program);
|
|
5043
|
+
registerFileCommands(program);
|
|
4932
5044
|
registerAgentCommands(program);
|
|
4933
5045
|
registerImportCommands(program);
|
|
4934
5046
|
registerTemplateCommands(program);
|