delivrie-cli 0.2.0 → 0.3.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 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,108 @@ 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
+ const manifestPath = path.join(dir, ".delivrie.json");
645
+ const manifest = (() => { try {
646
+ return JSON.parse(fs.readFileSync(manifestPath, "utf8"));
647
+ }
648
+ catch {
649
+ return { skills: {} };
650
+ } })();
651
+ manifest.skills ||= {};
652
+ const sha = (b) => createHash("sha256").update(b).digest("hex");
653
+ const fileOf = (n) => path.join(dir, n, "SKILL.md");
654
+ // Each installed skill: missing, current, outdated (Delivrie published a newer one), edited (changed locally).
655
+ const state = (n, remote) => {
656
+ if (!fs.existsSync(fileOf(n)))
657
+ return "missing";
658
+ const local = sha(fs.readFileSync(fileOf(n)));
659
+ if (manifest.skills[n] && local !== manifest.skills[n])
660
+ return "edited";
661
+ return local === remote ? "current" : "outdated";
662
+ };
663
+ const install = async (names) => {
664
+ const done = [], kept = [];
665
+ for (const s of index.skills.filter((x) => names.includes(x.name))) {
666
+ const st = state(s.name, s.sha256);
667
+ if (st === "current") {
668
+ manifest.skills[s.name] = s.sha256;
669
+ continue;
670
+ }
671
+ if (st === "edited" && !flags.force) {
672
+ kept.push(s.name);
673
+ continue;
674
+ }
675
+ const body = Buffer.from(await (await get(s.url)).arrayBuffer());
676
+ fs.mkdirSync(path.dirname(fileOf(s.name)), { recursive: true });
677
+ fs.writeFileSync(fileOf(s.name), body);
678
+ manifest.skills[s.name] = sha(body);
679
+ done.push(s.name);
680
+ }
681
+ manifest.version = index.version;
682
+ fs.mkdirSync(dir, { recursive: true });
683
+ fs.writeFileSync(manifestPath, JSON.stringify(manifest, null, 2) + "\n");
684
+ return { done, kept };
685
+ };
686
+ const rel = path.relative(process.cwd(), dir) || ".";
687
+ if (action === "list") {
688
+ 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;
689
+ }
690
+ if (action === "init" || action === "update") {
691
+ 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);
692
+ const unknown = want.filter((n) => !index.skills.some((s) => s.name === n));
693
+ if (unknown.length)
694
+ throw new UsageError(`No skill named ${unknown.join(", ")}. Run delivrie skills list`);
695
+ if (action === "update" && !want.length)
696
+ return fail("No Delivrie skills installed here. Run `delivrie init` first.");
697
+ const r = await install(want);
698
+ if (flags.json)
699
+ return json({ dir, version: index.version, installed: r.done, kept_edited: r.kept }), 0;
700
+ if (r.done.length)
701
+ print(out.green("✓") + ` ${action === "init" ? "Installed" : "Updated"} ${r.done.length} skill${r.done.length === 1 ? "" : "s"} in ${rel}: ${r.done.join(", ")}`);
702
+ else
703
+ print(out.green("✓") + ` Skills in ${rel} are up to date (${index.version}).`);
704
+ if (r.kept.length)
705
+ print(out.yellow("!") + ` Kept your edits to ${r.kept.join(", ")}. Add --force to replace them.`);
706
+ if (action === "init") {
707
+ print("");
708
+ print("Next: connect the MCP server so the skills can work with your account.");
709
+ print(out.dim(" Claude Code: claude mcp add --transport http delivrie https://delivrie.io/api/mcp"));
710
+ print(out.dim(" Or the plugin, which includes both: /plugin marketplace add bysurce/delivrie"));
711
+ print(out.dim(" Then try: \"Why are emails to Outlook bouncing this week?\""));
712
+ }
713
+ return 0;
714
+ }
715
+ if (action === "status") {
716
+ const rows = index.skills.map((s) => ({ name: s.name, status: state(s.name, s.sha256), tracked: !!manifest.skills[s.name] }))
717
+ .filter((r) => r.status !== "missing" || Object.keys(manifest.skills).length);
718
+ if (flags.json)
719
+ return json({ dir, latest: index.version, installed: manifest.version || null, skills: rows }), 0;
720
+ if (!rows.length) {
721
+ print(`No Delivrie skills in ${rel}. Run ${out.bold("delivrie init")} to install them.`);
722
+ return 0;
723
+ }
724
+ const label = { current: out.green("up to date"), outdated: out.yellow("update available"), edited: out.yellow("edited locally"), missing: out.dim("not installed") };
725
+ print(out.table(rows, [{ label: "SKILL", get: (r) => r.name }, { label: "STATUS", get: (r) => label[r.status] }]));
726
+ const n = rows.filter((r) => r.status === "outdated" || r.status === "missing").length;
727
+ 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}).`);
728
+ return 0;
729
+ }
730
+ throw new UsageError(`Unknown: skills ${action}. Try delivrie skills --help`);
731
+ }
610
732
  default:
611
733
  return fail(`Unknown command "${cmd}". Run delivrie --help to see them all.`, 2);
612
734
  }
package/dist/version.js CHANGED
@@ -1 +1 @@
1
- export const VERSION = "0.2.0";
1
+ export const VERSION = "0.3.0";
package/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "delivrie-cli",
3
- "version": "0.2.0",
3
+ "version": "0.3.0",
4
4
  "description": "The Delivrie command-line tool: send email, check deliveries, and manage domains, API keys, webhooks and templates from your terminal.",
5
5
  "keywords": [
6
6
  "delivrie",