delivrie-cli 0.2.0 → 0.4.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 +2 -0
- package/dist/cli.js +149 -2
- package/dist/version.js +1 -1
- package/package.json +1 -1
package/README.md
CHANGED
|
@@ -25,6 +25,8 @@ delivrie send -f "Acme <hi@acme.com>" -t ada@example.com -s "Hello" --text "It w
|
|
|
25
25
|
| `delivrie contacts list\|add\|get\|delete` | Contacts by id or email |
|
|
26
26
|
| `delivrie suppressions list\|add\|remove` | Addresses Delivrie won't send to |
|
|
27
27
|
| `delivrie logs list\|get` | API request logs |
|
|
28
|
+
| `delivrie init` | Install Delivrie's agent skills into `.claude/skills/` (`--dir` for another agent) |
|
|
29
|
+
| `delivrie skills list\|status\|update` | See which skills exist, which are out of date, and refresh them |
|
|
28
30
|
|
|
29
31
|
Run `delivrie <command> --help` for options. Add `--json` to any command for the raw API response, which makes the
|
|
30
32
|
CLI easy to script:
|
package/dist/cli.js
CHANGED
|
@@ -1,14 +1,14 @@
|
|
|
1
1
|
// The Delivrie CLI. `run(argv, io)` returns an exit code; io carries stdout/stderr/stdin/env/fetch so tests can drive it.
|
|
2
2
|
import fs from "node:fs";
|
|
3
3
|
import path from "node:path";
|
|
4
|
-
import { randomUUID } from "node:crypto";
|
|
4
|
+
import { randomUUID, createHash } from "node:crypto";
|
|
5
5
|
import { parseArgs, UsageError } from "./args.js";
|
|
6
6
|
import { createClient, ApiError } from "./api.js";
|
|
7
7
|
import { readConfig, writeConfig, clearConfig, configPath } from "./config.js";
|
|
8
8
|
import { makeOut, when, list } from "./format.js";
|
|
9
9
|
import { VERSION } from "./version.js";
|
|
10
10
|
const DEFAULT_BASE = "https://delivrie.io/api";
|
|
11
|
-
const BOOLEANS = ["json", "yes", "help", "version", "sending", "received", "quiet", "publish"];
|
|
11
|
+
const BOOLEANS = ["json", "yes", "help", "version", "sending", "received", "quiet", "publish", "force"];
|
|
12
12
|
const REPEATABLE = ["to", "cc", "bcc", "reply-to", "attach", "tag", "header", "var", "events"];
|
|
13
13
|
const ALIASES = { h: "help", v: "version", y: "yes", q: "quiet", f: "from", t: "to", s: "subject", n: "limit" };
|
|
14
14
|
const HELP = {
|
|
@@ -26,6 +26,10 @@ Sending
|
|
|
26
26
|
send Send an email (see delivrie send --help)
|
|
27
27
|
emails list|get|cancel|reschedule
|
|
28
28
|
|
|
29
|
+
Agent skills
|
|
30
|
+
init Install Delivrie's skills for your coding agent in this project
|
|
31
|
+
skills list|status|update
|
|
32
|
+
|
|
29
33
|
Setup
|
|
30
34
|
domains list|add|get|verify|delete
|
|
31
35
|
keys list|create|delete
|
|
@@ -115,6 +119,22 @@ and every {{variable}} in it is listed on the template. Changes stay a draft unt
|
|
|
115
119
|
delivrie suppressions list
|
|
116
120
|
delivrie suppressions add <email> [<email>...]
|
|
117
121
|
delivrie suppressions remove <email>`,
|
|
122
|
+
init: `Usage: delivrie init [--dir <path>] [--force]
|
|
123
|
+
|
|
124
|
+
Installs Delivrie's agent skills (send-email, inbox-triage, broadcasts, domain-setup, deliverability-check, automations
|
|
125
|
+
and more) into .claude/skills/ in this project, where Claude Code picks them up. Other agents: point --dir at their
|
|
126
|
+
skills folder. Then connect the MCP server so the skills can act on your account: https://delivrie.io/docs/mcp
|
|
127
|
+
|
|
128
|
+
--dir <path> Where to install (default .claude/skills)
|
|
129
|
+
--force Overwrite skills you've edited
|
|
130
|
+
|
|
131
|
+
Keep them current with \`delivrie skills status\` and \`delivrie skills update\`.`,
|
|
132
|
+
skills: `Usage:
|
|
133
|
+
delivrie skills list Every published skill
|
|
134
|
+
delivrie skills status [--dir <path>] Installed skills: up to date, out of date, edited or missing
|
|
135
|
+
delivrie skills update [<name>...] [--dir <path>] [--force]
|
|
136
|
+
|
|
137
|
+
update leaves skills you've edited alone unless you add --force. Skills come from https://delivrie.io/skills/index.json.`,
|
|
118
138
|
logs: `Usage:
|
|
119
139
|
delivrie logs list [--limit 20] [--offset 0]
|
|
120
140
|
delivrie logs get <id>`,
|
|
@@ -607,6 +627,133 @@ export async function run(argv, io = {}) {
|
|
|
607
627
|
}
|
|
608
628
|
throw new UsageError(`Unknown: logs ${sub}. Try delivrie logs --help`);
|
|
609
629
|
}
|
|
630
|
+
// ------------------------------------------------------------ agent skills
|
|
631
|
+
case "init":
|
|
632
|
+
case "skills": {
|
|
633
|
+
const action = cmd === "init" ? "init" : sub || "status";
|
|
634
|
+
const dir = path.resolve(flags.dir || ".claude/skills");
|
|
635
|
+
const base = (env.DELIVRIE_SKILLS_URL || "https://delivrie.io/skills").replace(/\/$/, "");
|
|
636
|
+
const fetchImpl = io.fetch || globalThis.fetch;
|
|
637
|
+
const get = async (url) => {
|
|
638
|
+
const r = await fetchImpl(url, { headers: { "user-agent": `delivrie-cli/${VERSION}` } });
|
|
639
|
+
if (!r.ok)
|
|
640
|
+
throw new ApiError(r.status, "skills_unavailable", `Couldn't download ${url} (${r.status})`);
|
|
641
|
+
return r;
|
|
642
|
+
};
|
|
643
|
+
const index = (await (await get(`${base}/index.json`)).json());
|
|
644
|
+
// Older indexes listed file names only (SKILL.md); newer ones list every file with its hash.
|
|
645
|
+
const filesOf = (s) => s.files.map((f) => typeof f === "string" ? { path: f, sha256: s.sha256, url: f === "SKILL.md" ? s.url : `${base}/${s.name}/${f}` } : f);
|
|
646
|
+
const manifestPath = path.join(dir, ".delivrie.json");
|
|
647
|
+
const manifest = (() => { try {
|
|
648
|
+
return JSON.parse(fs.readFileSync(manifestPath, "utf8"));
|
|
649
|
+
}
|
|
650
|
+
catch {
|
|
651
|
+
return { skills: {} };
|
|
652
|
+
} })();
|
|
653
|
+
manifest.skills ||= {};
|
|
654
|
+
const entry = (n) => { const e = manifest.skills[n]; return !e ? null : typeof e === "string" ? { sha256: e, files: ["SKILL.md"] } : e; };
|
|
655
|
+
const sha = (b) => createHash("sha256").update(b).digest("hex");
|
|
656
|
+
const safe = (n, rel) => {
|
|
657
|
+
const p = path.resolve(dir, n, rel);
|
|
658
|
+
if (!p.startsWith(path.resolve(dir, n) + path.sep))
|
|
659
|
+
throw new UsageError(`Refusing to write outside ${dir}: ${rel}`);
|
|
660
|
+
return p;
|
|
661
|
+
};
|
|
662
|
+
const combinedOf = (files) => sha(files.map((f) => `${f.path}:${f.sha256}\n`).join(""));
|
|
663
|
+
// The hash of what's on disk for these files (missing files count as changed).
|
|
664
|
+
const localHash = (n, files, legacy) => {
|
|
665
|
+
if (legacy)
|
|
666
|
+
return fs.existsSync(safe(n, "SKILL.md")) ? sha(fs.readFileSync(safe(n, "SKILL.md"))) : "";
|
|
667
|
+
return combinedOf(files.map((f) => ({ path: f, sha256: fs.existsSync(safe(n, f)) ? sha(fs.readFileSync(safe(n, f))) : "missing" })));
|
|
668
|
+
};
|
|
669
|
+
// Each installed skill: missing, current, outdated (Delivrie published a newer one), edited (changed locally).
|
|
670
|
+
const state = (s) => {
|
|
671
|
+
if (!fs.existsSync(safe(s.name, "SKILL.md")))
|
|
672
|
+
return "missing";
|
|
673
|
+
const e = entry(s.name), legacy = !!e && typeof manifest.skills[s.name] === "string";
|
|
674
|
+
if (e && localHash(s.name, e.files, legacy) !== e.sha256)
|
|
675
|
+
return "edited";
|
|
676
|
+
const remote = filesOf(s);
|
|
677
|
+
return localHash(s.name, remote.map((f) => f.path), false) === combinedOf(remote) ? "current" : "outdated";
|
|
678
|
+
};
|
|
679
|
+
const install = async (names) => {
|
|
680
|
+
const done = [], kept = [];
|
|
681
|
+
for (const s of index.skills.filter((x) => names.includes(x.name))) {
|
|
682
|
+
const st = state(s), files = filesOf(s);
|
|
683
|
+
if (st === "current") {
|
|
684
|
+
manifest.skills[s.name] = { sha256: combinedOf(files), files: files.map((f) => f.path) };
|
|
685
|
+
continue;
|
|
686
|
+
}
|
|
687
|
+
if (st === "edited" && !flags.force) {
|
|
688
|
+
kept.push(s.name);
|
|
689
|
+
continue;
|
|
690
|
+
}
|
|
691
|
+
const bodies = [];
|
|
692
|
+
for (const f of files)
|
|
693
|
+
bodies.push([f, Buffer.from(await (await get(f.url)).arrayBuffer())]);
|
|
694
|
+
// Remove files an older version had that this one doesn't.
|
|
695
|
+
for (const old of entry(s.name)?.files || [])
|
|
696
|
+
if (!files.some((f) => f.path === old))
|
|
697
|
+
fs.rmSync(safe(s.name, old), { force: true });
|
|
698
|
+
for (const [f, body] of bodies) {
|
|
699
|
+
const p = safe(s.name, f.path);
|
|
700
|
+
fs.mkdirSync(path.dirname(p), { recursive: true });
|
|
701
|
+
fs.writeFileSync(p, body);
|
|
702
|
+
}
|
|
703
|
+
manifest.skills[s.name] = { sha256: combinedOf(bodies.map(([f, b]) => ({ path: f.path, sha256: sha(b) }))), files: files.map((f) => f.path) };
|
|
704
|
+
done.push(s.name);
|
|
705
|
+
}
|
|
706
|
+
manifest.version = index.version;
|
|
707
|
+
fs.mkdirSync(dir, { recursive: true });
|
|
708
|
+
fs.writeFileSync(manifestPath, JSON.stringify(manifest, null, 2) + "\n");
|
|
709
|
+
return { done, kept };
|
|
710
|
+
};
|
|
711
|
+
const rel = path.relative(process.cwd(), dir) || ".";
|
|
712
|
+
if (action === "list") {
|
|
713
|
+
return show(index, () => { print(out.table(index.skills, [{ label: "SKILL", get: (s) => s.name }, { label: "WHAT IT DOES", get: (s) => trunc(s.description.split(". Use when")[0], 90) }])); }), 0;
|
|
714
|
+
}
|
|
715
|
+
if (action === "init" || action === "update") {
|
|
716
|
+
const want = action === "update" && rest.length ? rest : action === "update" ? Object.keys(manifest.skills).filter((n) => index.skills.some((s) => s.name === n)) : index.skills.map((s) => s.name);
|
|
717
|
+
const unknown = want.filter((n) => !index.skills.some((s) => s.name === n));
|
|
718
|
+
if (unknown.length)
|
|
719
|
+
throw new UsageError(`No skill named ${unknown.join(", ")}. Run delivrie skills list`);
|
|
720
|
+
if (action === "update" && !want.length)
|
|
721
|
+
return fail("No Delivrie skills installed here. Run `delivrie init` first.");
|
|
722
|
+
const r = await install(want);
|
|
723
|
+
if (flags.json)
|
|
724
|
+
return json({ dir, version: index.version, installed: r.done, kept_edited: r.kept }), 0;
|
|
725
|
+
if (r.done.length)
|
|
726
|
+
print(out.green("✓") + ` ${action === "init" ? "Installed" : "Updated"} ${r.done.length} skill${r.done.length === 1 ? "" : "s"} in ${rel}: ${r.done.join(", ")}`);
|
|
727
|
+
else
|
|
728
|
+
print(out.green("✓") + ` Skills in ${rel} are up to date (${index.version}).`);
|
|
729
|
+
if (r.kept.length)
|
|
730
|
+
print(out.yellow("!") + ` Kept your edits to ${r.kept.join(", ")}. Add --force to replace them.`);
|
|
731
|
+
if (action === "init") {
|
|
732
|
+
print("");
|
|
733
|
+
print("Next: connect the MCP server so the skills can work with your account.");
|
|
734
|
+
print(out.dim(" Claude Code: claude mcp add --transport http delivrie https://delivrie.io/api/mcp"));
|
|
735
|
+
print(out.dim(" Or the plugin, which includes both: /plugin marketplace add bysurce/delivrie"));
|
|
736
|
+
print(out.dim(" Then try: \"Why are emails to Outlook bouncing this week?\""));
|
|
737
|
+
}
|
|
738
|
+
return 0;
|
|
739
|
+
}
|
|
740
|
+
if (action === "status") {
|
|
741
|
+
const rows = index.skills.map((s) => ({ name: s.name, status: state(s), tracked: !!manifest.skills[s.name] }))
|
|
742
|
+
.filter((r) => r.status !== "missing" || Object.keys(manifest.skills).length);
|
|
743
|
+
if (flags.json)
|
|
744
|
+
return json({ dir, latest: index.version, installed: manifest.version || null, skills: rows }), 0;
|
|
745
|
+
if (!rows.length) {
|
|
746
|
+
print(`No Delivrie skills in ${rel}. Run ${out.bold("delivrie init")} to install them.`);
|
|
747
|
+
return 0;
|
|
748
|
+
}
|
|
749
|
+
const label = { current: out.green("up to date"), outdated: out.yellow("update available"), edited: out.yellow("edited locally"), missing: out.dim("not installed") };
|
|
750
|
+
print(out.table(rows, [{ label: "SKILL", get: (r) => r.name }, { label: "STATUS", get: (r) => label[r.status] }]));
|
|
751
|
+
const n = rows.filter((r) => r.status === "outdated" || r.status === "missing").length;
|
|
752
|
+
print(n ? `\n${n} to install or update. Run ${out.bold("delivrie skills update")}${rows.some((r) => r.status === "missing") ? ` (or ${out.bold("delivrie init")} for new ones)` : ""}.` : `\nAll up to date (${index.version}).`);
|
|
753
|
+
return 0;
|
|
754
|
+
}
|
|
755
|
+
throw new UsageError(`Unknown: skills ${action}. Try delivrie skills --help`);
|
|
756
|
+
}
|
|
610
757
|
default:
|
|
611
758
|
return fail(`Unknown command "${cmd}". Run delivrie --help to see them all.`, 2);
|
|
612
759
|
}
|
package/dist/version.js
CHANGED
|
@@ -1 +1 @@
|
|
|
1
|
-
export const VERSION = "0.
|
|
1
|
+
export const VERSION = "0.4.0";
|
package/package.json
CHANGED