@asteroidai/cli 1.9.346 → 1.9.350

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/asteroid.js CHANGED
@@ -4398,6 +4398,43 @@ var COMMANDS = [
4398
4398
  readOnly: true,
4399
4399
  destructive: false
4400
4400
  },
4401
+ {
4402
+ command: "skill sync",
4403
+ tool: "skill_sync",
4404
+ title: "Sync skills",
4405
+ description: "Get the latest Asteroid skills for the portals your organization has added: how to build Asteroid workflows on each portal. Optional: `learnings`. If a skill was missing something about how a portal works that would have helped you build your automation, send it here. A learning is general knowledge of the portal, such as an SMS-only 2FA or a session that ends after 20 minutes. Each learning has `portal`, the portal's name or host, and `content`, in plain text. Set `portalId` only if you have one from `skills_list`.",
4406
+ method: "POST",
4407
+ path: "/astro/v2/skills",
4408
+ args: [],
4409
+ query: [
4410
+ {
4411
+ name: "surface",
4412
+ flag: "surface",
4413
+ type: "string",
4414
+ required: false,
4415
+ description: "The surface the skills are rendered for. Defaults to `cli`.",
4416
+ enum: ["cli", "mcp"]
4417
+ }
4418
+ ],
4419
+ binary: false,
4420
+ readOnly: false,
4421
+ destructive: false,
4422
+ body: {
4423
+ required: false,
4424
+ contentType: "application/json",
4425
+ fields: [
4426
+ {
4427
+ name: "learnings",
4428
+ flag: "learnings",
4429
+ type: "json",
4430
+ required: false,
4431
+ description: "Up to 10 things you found out about portals. Leave it out to sync only."
4432
+ }
4433
+ ],
4434
+ files: [],
4435
+ credentialOrganization: false
4436
+ }
4437
+ },
4401
4438
  {
4402
4439
  command: "tag create",
4403
4440
  tool: "workflow_tags_create",
@@ -6711,7 +6748,18 @@ function withSyncCommands(commands) {
6711
6748
  (a, b) => a.command.localeCompare(b.command)
6712
6749
  );
6713
6750
  }
6714
- var ALL_COMMANDS = withSyncCommands(COMMANDS);
6751
+ var LEARNING = {
6752
+ name: "learnings",
6753
+ flag: "learning",
6754
+ type: "json[]",
6755
+ required: false,
6756
+ description: 'What you found out about a portal, as JSON: `{"portal":"<name>","content":"<text>"}`. Add `portalId` if you have one. Repeat for more.'
6757
+ };
6758
+ function withLearningFlag(command) {
6759
+ if (command.tool !== "skill_sync" || !command.body) return command;
6760
+ return { ...command, body: { ...command.body, fields: [LEARNING] } };
6761
+ }
6762
+ var ALL_COMMANDS = withSyncCommands(COMMANDS).map(withLearningFlag);
6715
6763
 
6716
6764
  // src/config.ts
6717
6765
  import envPaths from "env-paths";
@@ -6996,12 +7044,18 @@ var BUILTINS = [
6996
7044
  },
6997
7045
  {
6998
7046
  command: "skill sync",
6999
- usage: "asteroid skill sync",
7000
- description: "Install the Asteroid skills, or bring them up to date, in every skills directory found: `~/.claude/skills`, `~/.cursor/skills` and `~/.agents/skills`. Writes the files that changed, removes the skills the API no longer serves, and leaves a skill directory it did not create alone.",
7047
+ usage: "asteroid skill sync [--learning <json>]",
7048
+ description: "Install the Asteroid skills, or bring them up to date, in every skills directory found: `~/.claude/skills`, `~/.cursor/skills` and `~/.agents/skills`. Writes the files that changed, removes the skills the API no longer serves, and leaves a skill directory it did not create alone. Do not edit an installed skill, because the next sync overwrites it. If a skill is missing something about how a portal works, send it with `--learning`.",
7001
7049
  args: 0,
7002
7050
  options: [
7003
7051
  ["--no-remove", "Keep the skills and files the API no longer serves."]
7004
7052
  ],
7053
+ repeatableOptions: [
7054
+ [
7055
+ "--learning <json>",
7056
+ 'Optional. Something the portal\'s skill is missing about how the portal works, as JSON: `{"portal":"<name>","content":"<text>"}`. Add `portalId` if you have one. Repeat for more. Send this instead of editing the skill, because the next sync overwrites local edits. Send general knowledge of the portal only.'
7057
+ ]
7058
+ ],
7005
7059
  section: "Skills"
7006
7060
  }
7007
7061
  ];
@@ -7156,10 +7210,14 @@ function defineCommands(root, options, dotted2 = /* @__PURE__ */ new Map(), onIn
7156
7210
  const leaf = parent.command(words.at(-1)).description(builtin.description);
7157
7211
  if (builtin.arg) leaf.argument(`[${builtin.arg}]`);
7158
7212
  for (const [flags, text3] of builtin.options ?? []) leaf.option(flags, text3);
7213
+ for (const [flags, text3] of builtin.repeatableOptions ?? [])
7214
+ leaf.option(flags, text3, collect);
7159
7215
  for (const [flags, text3] of builtin.hiddenOptions ?? [])
7160
7216
  leaf.addOption(new Flag(flags, text3).hideHelp());
7161
7217
  leaf.action((...args) => {
7162
7218
  const cmd = args.at(-1);
7219
+ const [dottedFlag] = dotted2.keys();
7220
+ if (dottedFlag) throw new UsageError(`unknown flag: --${dottedFlag}`);
7163
7221
  onInvocation({
7164
7222
  kind: "builtin",
7165
7223
  name: builtin.command,
@@ -7732,7 +7790,7 @@ var ApiError = class extends Error {
7732
7790
  status;
7733
7791
  body;
7734
7792
  };
7735
- var VERSION = "1.9.346";
7793
+ var VERSION = "1.9.350";
7736
7794
  function problem(status, body, fallback) {
7737
7795
  if (body && typeof body === "object") {
7738
7796
  const record2 = body;
@@ -7819,170 +7877,405 @@ async function send(apiUrl, auth, request, binary, fetchImpl = fetch) {
7819
7877
  }
7820
7878
 
7821
7879
  // src/skills.ts
7880
+ import { createHash as createHash2 } from "node:crypto";
7822
7881
  import {
7823
7882
  existsSync as existsSync2,
7824
7883
  lstatSync,
7825
7884
  mkdirSync as mkdirSync3,
7826
7885
  readdirSync,
7886
+ readFileSync as readFileSync3,
7827
7887
  rmdirSync,
7828
7888
  rmSync as rmSync2,
7829
7889
  writeFileSync as writeFileSync2
7830
7890
  } from "node:fs";
7831
7891
  import { dirname as dirname2, join as join4 } from "node:path";
7832
7892
 
7833
- // ../workflow-files/src/representation/name-charset.ts
7834
- var NAME_CHARSET_RE = /^[A-Za-z0-9 !#$%&'()+,.;=@^`{}[\]~-]+$/;
7835
- var WINDOWS_RESERVED = /* @__PURE__ */ new Set([
7836
- "con",
7837
- "prn",
7838
- "aux",
7839
- "nul",
7840
- ...Array.from({ length: 9 }, (_, i) => `com${i + 1}`),
7841
- ...Array.from({ length: 9 }, (_, i) => `lpt${i + 1}`)
7842
- ]);
7843
- function isNameCharsetConforming(name) {
7844
- return NAME_CHARSET_RE.test(name);
7893
+ // src/request.ts
7894
+ import { readFileSync as readFileSync2 } from "node:fs";
7895
+ import { basename } from "node:path";
7896
+ function camel(segment) {
7897
+ return segment.replace(/-([a-z0-9])/g, (_, c) => c.toUpperCase());
7845
7898
  }
7846
-
7847
- // ../workflow-files/src/representation/types.ts
7848
- function normalizeNodeName(name) {
7849
- let result = name.toLowerCase();
7850
- result = result.replace(/[^a-z0-9]+/g, "_");
7851
- result = result.replace(/^_+|_+$/g, "");
7852
- if (result.length > 80) {
7853
- result = result.slice(0, 80).replace(/_+$/, "");
7854
- }
7855
- if (result === "") {
7856
- throw new Error(
7857
- `representation: node name "${name}" produces an empty directory name after normalization`
7899
+ function scalar(option2, raw) {
7900
+ const type = option2.type.replace("[]", "");
7901
+ if (option2.enum && !option2.enum.includes(raw)) {
7902
+ throw new UsageError(
7903
+ `--${option2.flag} must be one of ${option2.enum.join(", ")}`
7858
7904
  );
7859
7905
  }
7860
- return result;
7861
- }
7862
- function lossySlugOr(name, fallback) {
7863
- try {
7864
- return normalizeNodeName(name);
7865
- } catch {
7866
- return fallback;
7906
+ if (type === "integer" || type === "number") {
7907
+ const value2 = Number(raw);
7908
+ if (raw.trim() === "" || Number.isNaN(value2) || type === "integer" && !Number.isInteger(value2)) {
7909
+ throw new UsageError(
7910
+ `--${option2.flag} must be ${type === "integer" ? "an integer" : "a number"}`
7911
+ );
7912
+ }
7913
+ return value2;
7914
+ }
7915
+ if (type === "boolean") {
7916
+ if (raw !== "true" && raw !== "false") {
7917
+ throw new UsageError(`--${option2.flag} must be true or false`);
7918
+ }
7919
+ return raw === "true";
7867
7920
  }
7921
+ if (type === "json") return parseJson(raw, `--${option2.flag}`);
7922
+ return raw;
7868
7923
  }
7869
- function nodeDirName(name) {
7870
- if (isNameCharsetConforming(name)) {
7871
- return name.replaceAll(" ", "_");
7924
+ function value(option2, raws) {
7925
+ if (option2.type.endsWith("[]")) return raws.map((raw) => scalar(option2, raw));
7926
+ return scalar(option2, raws.at(-1));
7927
+ }
7928
+ var nodeReader = {
7929
+ text: async (path) => readFileSync2(path, "utf8"),
7930
+ bytes: async (path) => new Uint8Array(readFileSync2(path))
7931
+ };
7932
+ async function readInput(raw, io) {
7933
+ if (raw === "-") return io.text(0);
7934
+ if (raw.startsWith("@")) return io.text(raw.slice(1));
7935
+ return raw;
7936
+ }
7937
+ async function resolveInputs(command, parsed, io) {
7938
+ const jsonFlags = [...command.query, ...command.body?.fields ?? []].filter((option2) => option2.type === "json" || option2.type === "json[]").map((option2) => option2.flag);
7939
+ const flags = new Map(parsed.flags);
7940
+ for (const flag2 of jsonFlags) {
7941
+ const raws = flags.get(flag2);
7942
+ if (raws)
7943
+ flags.set(flag2, await Promise.all(raws.map((raw) => readInput(raw, io))));
7872
7944
  }
7873
- return normalizeNodeName(name);
7945
+ const body = parsed.body === void 0 ? void 0 : await readInput(parsed.body, io);
7946
+ return { ...parsed, flags, body };
7874
7947
  }
7875
- function agentDirName(name) {
7948
+ function parseJson(raw, label) {
7876
7949
  try {
7877
- return nodeDirName(name);
7950
+ return JSON.parse(raw);
7878
7951
  } catch {
7879
- return "agent";
7952
+ throw new UsageError(`${label} is not valid JSON`);
7880
7953
  }
7881
7954
  }
7882
- function executionDirName(executionId2) {
7883
- return executionId2.slice(0, 8);
7884
- }
7885
- function workflowDirName(workflowId, version, parentId, parentVersion) {
7886
- const short = workflowId.slice(0, 8);
7887
- if (version !== void 0 && version !== null) {
7888
- return `v${version}_${short}`;
7889
- }
7890
- if (parentId) {
7891
- if (parentVersion !== void 0 && parentVersion !== null) {
7892
- return `draft_${short}_from_v${parentVersion}`;
7955
+ function loose(raw) {
7956
+ if (/^(true|false|null)$/.test(raw) || /^[[{]/.test(raw.trim())) {
7957
+ try {
7958
+ return JSON.parse(raw);
7959
+ } catch {
7960
+ return raw;
7893
7961
  }
7894
- return `draft_${short}_from_draft_${parentId.slice(0, 8)}`;
7895
7962
  }
7896
- return `draft_${short}`;
7897
- }
7898
-
7899
- // src/sync/paths.ts
7900
- import { createHash } from "node:crypto";
7901
- function join3(...parts) {
7902
- return parts.filter((part) => part !== "").join("/").replace(/\/{2,}/g, "/");
7903
- }
7904
- function workflowRoot(root, workflowName) {
7905
- return join3(root, agentDirName(workflowName));
7906
- }
7907
- function isContained(path) {
7908
- if (path === "" || path.startsWith("/") || path.includes("\\")) return false;
7909
- return path.split("/").every((segment) => segment !== ".." && segment !== "");
7910
- }
7911
- function sha256(bytes) {
7912
- return createHash("sha256").update(bytes).digest("hex");
7963
+ return raw;
7913
7964
  }
7914
- function matchesGlob(path, pattern) {
7915
- let source = "";
7916
- for (let i = 0; i < pattern.length; i++) {
7917
- const ch = pattern[i];
7918
- if (ch === "*" && pattern[i + 1] === "*" && pattern[i + 2] === "/") {
7919
- source += "(?:.*/)?";
7920
- i += 2;
7921
- } else if (ch === "*" && pattern[i + 1] === "*") {
7922
- source += ".*";
7923
- i += 1;
7924
- } else if (ch === "*") source += "[^/]*";
7925
- else if (ch === "?") source += "[^/]";
7926
- else source += ch.replace(/[.+^${}()|[\]\\]/g, "\\$&");
7965
+ function setPath(target, path, value2) {
7966
+ let node = target;
7967
+ for (const key of path.slice(0, -1)) {
7968
+ const next = node[key];
7969
+ if (typeof next !== "object" || next === null || Array.isArray(next))
7970
+ node[key] = {};
7971
+ node = node[key];
7927
7972
  }
7928
- return new RegExp(`^${source}$`).test(path);
7929
- }
7930
-
7931
- // src/skills.ts
7932
- var SKILLS_FILE = "skills.json";
7933
- var CHECK_INTERVAL_MS = 24 * 36e5;
7934
- var SYNC_HINT = "Run `asteroid skill sync`";
7935
- var HOST_PARENTS = [
7936
- { name: "Claude Code", parent: ".claude" },
7937
- { name: "Cursor", parent: ".cursor" },
7938
- { name: "~/.agents", parent: ".agents" }
7939
- ];
7940
- var SKILL_NAME = /^[a-z0-9][a-z0-9-]{0,63}$/;
7941
- var CONCURRENCY = 8;
7942
- function detectHosts(home) {
7943
- return HOST_PARENTS.filter((host) => existsSync2(join4(home, host.parent))).map(
7944
- (host) => ({ name: host.name, dir: join4(home, host.parent, "skills") })
7945
- );
7946
- }
7947
- function hostLabel(hosts) {
7948
- const names = hosts.map((host) => host.name);
7949
- if (names.length <= 1) return names.join("");
7950
- return `${names.slice(0, -1).join(", ")} and ${names.at(-1)}`;
7951
- }
7952
- function loadSkillsState(env) {
7953
- const state = readJson(
7954
- join4(env.configDir, SKILLS_FILE),
7955
- {}
7956
- );
7957
- return { ...state, hosts: state.hosts ?? {} };
7958
- }
7959
- function saveSkillsState(env, state) {
7960
- writePrivateJson(join4(env.configDir, SKILLS_FILE), state);
7961
- }
7962
- function installable(row) {
7963
- return row.kind !== "portal" || row.added === true;
7973
+ node[path.at(-1)] = value2;
7964
7974
  }
7965
- function wantedSkills(rows, skipped) {
7966
- const seen = /* @__PURE__ */ new Set();
7967
- const wanted = [];
7968
- for (const row of rows) {
7969
- if (!installable(row)) continue;
7970
- if (!SKILL_NAME.test(row.name)) {
7971
- skipped.push(`${clean(row.name)} (not a skill name)`);
7972
- continue;
7975
+ async function dotted(field, segments, flag2, raws, io) {
7976
+ const path = [];
7977
+ let option2 = field;
7978
+ for (const [i, segment] of segments.entries()) {
7979
+ if (option2?.record) {
7980
+ const key = segments.slice(i).join(".");
7981
+ const entry = { ...option2, flag: flag2, type: option2.record };
7982
+ delete entry.enum;
7983
+ return [
7984
+ [...path, key],
7985
+ entry.type === "json" ? loose(raws.at(-1)) : value(entry, raws)
7986
+ ];
7973
7987
  }
7974
- if (seen.has(row.name)) {
7975
- skipped.push(
7976
- `${row.kind} skill ${row.name} (another skill has the same name)`
7988
+ if (option2?.fields) {
7989
+ const child = option2.fields.find(
7990
+ (f) => f.flag === segment
7977
7991
  );
7992
+ if (!child) throw new UsageError(`unknown flag: --${flag2}`);
7993
+ path.push(child.name);
7994
+ option2 = child;
7978
7995
  continue;
7979
7996
  }
7980
- seen.add(row.name);
7981
- wanted.push(row);
7997
+ if (option2 && option2.type !== "json") {
7998
+ throw new UsageError(`unknown flag: --${flag2}`);
7999
+ }
8000
+ path.push(camel(segment));
8001
+ option2 = void 0;
7982
8002
  }
7983
- return wanted;
7984
- }
7985
- async function listSkills(env, auth, fetchImpl) {
8003
+ if (!option2) return [path, loose(raws.at(-1))];
8004
+ if (option2.fields || option2.record) {
8005
+ throw new UsageError(`--${flag2} needs a field, as --${flag2}.<name>`);
8006
+ }
8007
+ const inputs = option2.type === "json" ? await Promise.all(raws.map((raw) => readInput(raw, io))) : raws;
8008
+ return [path, value({ ...option2, flag: flag2 }, inputs)];
8009
+ }
8010
+ async function buildRequest(command, input, context = {}) {
8011
+ const io = context.io ?? nodeReader;
8012
+ const parsed = await resolveInputs(command, input, io);
8013
+ if (parsed.positionals.length !== command.args.length) {
8014
+ const expected = command.args.map((a) => `<${a.flag}>`).join(" ") || "no arguments";
8015
+ throw new UsageError(
8016
+ `expected ${expected}, got ${parsed.positionals.length} argument(s)`
8017
+ );
8018
+ }
8019
+ let path = command.path;
8020
+ command.args.forEach((arg, i) => {
8021
+ path = path.replace(
8022
+ `{${arg.name}}`,
8023
+ encodeURIComponent(parsed.positionals[i])
8024
+ );
8025
+ });
8026
+ const flags = new Map(parsed.flags);
8027
+ const query = new URLSearchParams();
8028
+ for (const option2 of command.query) {
8029
+ const raws = flags.get(option2.flag);
8030
+ flags.delete(option2.flag);
8031
+ if (!raws) {
8032
+ if (option2.required) throw new UsageError(`--${option2.flag} is required`);
8033
+ continue;
8034
+ }
8035
+ const parsedValue = value(option2, raws);
8036
+ const values = Array.isArray(parsedValue) ? parsedValue : [parsedValue];
8037
+ if (option2.explode === false)
8038
+ query.append(option2.name, values.map(String).join(","));
8039
+ else for (const v of values) query.append(option2.name, String(v));
8040
+ }
8041
+ const built = { method: command.method, path, query };
8042
+ const body = command.body;
8043
+ if (!body) {
8044
+ if (parsed.body) throw new UsageError(`${command.command} takes no body`);
8045
+ rejectUnknown(flags);
8046
+ return built;
8047
+ }
8048
+ if (body.contentType === "multipart/form-data") {
8049
+ if (parsed.body) {
8050
+ throw new UsageError(
8051
+ `${command.command} uploads files; use the file flags, not --body`
8052
+ );
8053
+ }
8054
+ const form = new FormData();
8055
+ for (const file of body.files) {
8056
+ const paths = flags.get(file) ?? [];
8057
+ if (body.required && paths.length === 0) {
8058
+ throw new UsageError(`--${file} is required`);
8059
+ }
8060
+ for (const filePath of paths) {
8061
+ form.append(
8062
+ file,
8063
+ new Blob([await io.bytes(filePath)]),
8064
+ basename(filePath)
8065
+ );
8066
+ }
8067
+ flags.delete(file);
8068
+ }
8069
+ for (const field of body.fields) {
8070
+ const raws = flags.get(field.flag);
8071
+ flags.delete(field.flag);
8072
+ if (raws) for (const raw of raws) form.append(field.name, raw);
8073
+ }
8074
+ rejectUnknown(flags);
8075
+ built.form = form;
8076
+ return built;
8077
+ }
8078
+ const base = parsed.body ? parseJson(parsed.body, "--body") : {};
8079
+ if (typeof base !== "object" || base === null || Array.isArray(base)) {
8080
+ throw new UsageError("--body must be a JSON object");
8081
+ }
8082
+ const json = base;
8083
+ for (const field of body.fields) {
8084
+ const raws = flags.get(field.flag);
8085
+ if (!raws) continue;
8086
+ flags.delete(field.flag);
8087
+ json[field.name] = value(field, raws);
8088
+ }
8089
+ for (const [flag2, raws] of [...flags]) {
8090
+ const [head, ...rest] = flag2.split(".");
8091
+ const field = body.fields.find((f) => f.flag === head);
8092
+ if (!field || rest.length === 0) continue;
8093
+ flags.delete(flag2);
8094
+ const current = json[field.name];
8095
+ json[field.name] = typeof current === "object" && current !== null ? current : {};
8096
+ const [path2, value2] = await dotted(field, rest, flag2, raws, io);
8097
+ setPath(json, [field.name, ...path2], value2);
8098
+ }
8099
+ rejectUnknown(flags);
8100
+ delete json.organizationId;
8101
+ if (body.credentialOrganization) {
8102
+ if (!context.organizationId) {
8103
+ throw new UsageError(
8104
+ "could not tell which organization this credential acts in"
8105
+ );
8106
+ }
8107
+ json.organizationId = context.organizationId;
8108
+ }
8109
+ for (const field of body.fields) {
8110
+ if (field.required && json[field.name] === void 0) {
8111
+ throw new UsageError(`--${field.flag} is required`);
8112
+ }
8113
+ }
8114
+ if (body.required || Object.keys(json).length > 0) built.json = json;
8115
+ return built;
8116
+ }
8117
+ function rejectUnknown(flags) {
8118
+ const unknown = [...flags.keys()];
8119
+ if (unknown.length > 0) {
8120
+ throw new UsageError(
8121
+ `unknown flag${unknown.length > 1 ? "s" : ""}: ${unknown.map((f) => `--${f}`).join(", ")}`
8122
+ );
8123
+ }
8124
+ }
8125
+
8126
+ // ../workflow-files/src/representation/name-charset.ts
8127
+ var NAME_CHARSET_RE = /^[A-Za-z0-9 !#$%&'()+,.;=@^`{}[\]~-]+$/;
8128
+ var WINDOWS_RESERVED = /* @__PURE__ */ new Set([
8129
+ "con",
8130
+ "prn",
8131
+ "aux",
8132
+ "nul",
8133
+ ...Array.from({ length: 9 }, (_, i) => `com${i + 1}`),
8134
+ ...Array.from({ length: 9 }, (_, i) => `lpt${i + 1}`)
8135
+ ]);
8136
+ function isNameCharsetConforming(name) {
8137
+ return NAME_CHARSET_RE.test(name);
8138
+ }
8139
+
8140
+ // ../workflow-files/src/representation/types.ts
8141
+ function normalizeNodeName(name) {
8142
+ let result = name.toLowerCase();
8143
+ result = result.replace(/[^a-z0-9]+/g, "_");
8144
+ result = result.replace(/^_+|_+$/g, "");
8145
+ if (result.length > 80) {
8146
+ result = result.slice(0, 80).replace(/_+$/, "");
8147
+ }
8148
+ if (result === "") {
8149
+ throw new Error(
8150
+ `representation: node name "${name}" produces an empty directory name after normalization`
8151
+ );
8152
+ }
8153
+ return result;
8154
+ }
8155
+ function lossySlugOr(name, fallback) {
8156
+ try {
8157
+ return normalizeNodeName(name);
8158
+ } catch {
8159
+ return fallback;
8160
+ }
8161
+ }
8162
+ function nodeDirName(name) {
8163
+ if (isNameCharsetConforming(name)) {
8164
+ return name.replaceAll(" ", "_");
8165
+ }
8166
+ return normalizeNodeName(name);
8167
+ }
8168
+ function agentDirName(name) {
8169
+ try {
8170
+ return nodeDirName(name);
8171
+ } catch {
8172
+ return "agent";
8173
+ }
8174
+ }
8175
+ function executionDirName(executionId2) {
8176
+ return executionId2.slice(0, 8);
8177
+ }
8178
+ function workflowDirName(workflowId, version, parentId, parentVersion) {
8179
+ const short = workflowId.slice(0, 8);
8180
+ if (version !== void 0 && version !== null) {
8181
+ return `v${version}_${short}`;
8182
+ }
8183
+ if (parentId) {
8184
+ if (parentVersion !== void 0 && parentVersion !== null) {
8185
+ return `draft_${short}_from_v${parentVersion}`;
8186
+ }
8187
+ return `draft_${short}_from_draft_${parentId.slice(0, 8)}`;
8188
+ }
8189
+ return `draft_${short}`;
8190
+ }
8191
+
8192
+ // src/sync/paths.ts
8193
+ import { createHash } from "node:crypto";
8194
+ function join3(...parts) {
8195
+ return parts.filter((part) => part !== "").join("/").replace(/\/{2,}/g, "/");
8196
+ }
8197
+ function workflowRoot(root, workflowName) {
8198
+ return join3(root, agentDirName(workflowName));
8199
+ }
8200
+ function isContained(path) {
8201
+ if (path === "" || path.startsWith("/") || path.includes("\\")) return false;
8202
+ return path.split("/").every((segment) => segment !== ".." && segment !== "");
8203
+ }
8204
+ function sha256(bytes) {
8205
+ return createHash("sha256").update(bytes).digest("hex");
8206
+ }
8207
+ function matchesGlob(path, pattern) {
8208
+ let source = "";
8209
+ for (let i = 0; i < pattern.length; i++) {
8210
+ const ch = pattern[i];
8211
+ if (ch === "*" && pattern[i + 1] === "*" && pattern[i + 2] === "/") {
8212
+ source += "(?:.*/)?";
8213
+ i += 2;
8214
+ } else if (ch === "*" && pattern[i + 1] === "*") {
8215
+ source += ".*";
8216
+ i += 1;
8217
+ } else if (ch === "*") source += "[^/]*";
8218
+ else if (ch === "?") source += "[^/]";
8219
+ else source += ch.replace(/[.+^${}()|[\]\\]/g, "\\$&");
8220
+ }
8221
+ return new RegExp(`^${source}$`).test(path);
8222
+ }
8223
+
8224
+ // src/skills.ts
8225
+ var SKILLS_FILE = "skills.json";
8226
+ var CHECK_INTERVAL_MS = 24 * 36e5;
8227
+ var SYNC_HINT = "Run `asteroid skill sync`";
8228
+ var HOST_PARENTS = [
8229
+ { name: "Claude Code", parent: ".claude" },
8230
+ { name: "Cursor", parent: ".cursor" },
8231
+ { name: "~/.agents", parent: ".agents" }
8232
+ ];
8233
+ var SKILL_NAME = /^[a-z0-9][a-z0-9-]{0,63}$/;
8234
+ var CONCURRENCY = 8;
8235
+ function detectHosts(home) {
8236
+ return HOST_PARENTS.filter((host) => existsSync2(join4(home, host.parent))).map(
8237
+ (host) => ({ name: host.name, dir: join4(home, host.parent, "skills") })
8238
+ );
8239
+ }
8240
+ function hostLabel(hosts) {
8241
+ const names = hosts.map((host) => host.name);
8242
+ if (names.length <= 1) return names.join("");
8243
+ return `${names.slice(0, -1).join(", ")} and ${names.at(-1)}`;
8244
+ }
8245
+ function loadSkillsState(env) {
8246
+ const state = readJson(
8247
+ join4(env.configDir, SKILLS_FILE),
8248
+ {}
8249
+ );
8250
+ return { ...state, hosts: state.hosts ?? {} };
8251
+ }
8252
+ function saveSkillsState(env, state) {
8253
+ writePrivateJson(join4(env.configDir, SKILLS_FILE), state);
8254
+ }
8255
+ function installable(row) {
8256
+ return row.kind !== "portal" || row.added === true;
8257
+ }
8258
+ function wantedSkills(rows, skipped) {
8259
+ const seen = /* @__PURE__ */ new Set();
8260
+ const wanted = [];
8261
+ for (const row of rows) {
8262
+ if (!installable(row)) continue;
8263
+ if (!SKILL_NAME.test(row.name)) {
8264
+ skipped.push(`${clean(row.name)} (not a skill name)`);
8265
+ continue;
8266
+ }
8267
+ if (seen.has(row.name)) {
8268
+ skipped.push(
8269
+ `${row.kind} skill ${row.name} (another skill has the same name)`
8270
+ );
8271
+ continue;
8272
+ }
8273
+ seen.add(row.name);
8274
+ wanted.push(row);
8275
+ }
8276
+ return wanted;
8277
+ }
8278
+ async function listSkills(env, auth, fetchImpl) {
7986
8279
  const response = await send(
7987
8280
  env.apiUrl,
7988
8281
  auth,
@@ -8032,10 +8325,22 @@ function removeEmptyDirs(from, upTo) {
8032
8325
  dir = dirname2(dir);
8033
8326
  }
8034
8327
  }
8035
- function removeFile(skillDir, path) {
8036
- rmSync2(join4(skillDir, path), { force: true });
8037
- removeEmptyDirs(dirname2(join4(skillDir, path)), skillDir);
8038
- }
8328
+ function removeFile(skillDir, path) {
8329
+ rmSync2(join4(skillDir, path), { force: true });
8330
+ removeEmptyDirs(dirname2(join4(skillDir, path)), skillDir);
8331
+ }
8332
+ function matchesLocal(skillDir, path, digest) {
8333
+ const file = join4(skillDir, path);
8334
+ try {
8335
+ if (!existsSync2(file)) return false;
8336
+ if (throughSymlink(skillDir, path) || !lstatSync(file).isFile())
8337
+ return true;
8338
+ const local2 = createHash2("sha256").update(readFileSync3(file)).digest("hex");
8339
+ return digest === `sha256:${local2}`;
8340
+ } catch {
8341
+ return false;
8342
+ }
8343
+ }
8039
8344
  function throughSymlink(skillDir, path) {
8040
8345
  let current = skillDir;
8041
8346
  for (const part of ["", ...path.split("/")]) {
@@ -8069,7 +8374,7 @@ function planHost(host, owned, wanted, served) {
8069
8374
  const digests = served.get(row.name) ?? {};
8070
8375
  const stale = /* @__PURE__ */ new Set();
8071
8376
  for (const [path, digest] of Object.entries(digests)) {
8072
- if (owned[row.name]?.[path] !== digest || !existsSync2(join4(skillDir, path)))
8377
+ if (owned[row.name]?.[path] !== digest || !matchesLocal(skillDir, path, digest))
8073
8378
  stale.add(path);
8074
8379
  }
8075
8380
  if (stale.size > 0) needs.set(row.name, stale);
@@ -8099,9 +8404,16 @@ function applyHost(plan, served, fetched, options) {
8099
8404
  unwritten.add(file.path);
8100
8405
  continue;
8101
8406
  }
8102
- mkdirSync3(dirname2(join4(skillDir, file.path)), { recursive: true });
8103
- writeFileSync2(join4(skillDir, file.path), file.content, "utf8");
8104
- result.written++;
8407
+ try {
8408
+ mkdirSync3(dirname2(join4(skillDir, file.path)), { recursive: true });
8409
+ writeFileSync2(join4(skillDir, file.path), file.content, "utf8");
8410
+ result.written++;
8411
+ } catch (error) {
8412
+ result.skipped.push(
8413
+ `${join4(skillDir, file.path)} (${error.message})`
8414
+ );
8415
+ unwritten.add(file.path);
8416
+ }
8105
8417
  }
8106
8418
  }
8107
8419
  for (const path of unwritten) delete digests[path];
@@ -8109,7 +8421,9 @@ function applyHost(plan, served, fetched, options) {
8109
8421
  const kept = {};
8110
8422
  for (const path of Object.keys(previous)) {
8111
8423
  if (path in digests) continue;
8112
- if (options.remove) {
8424
+ if (unwritten.has(path)) {
8425
+ kept[path] = previous[path];
8426
+ } else if (options.remove) {
8113
8427
  removeFile(skillDir, path);
8114
8428
  result.removed++;
8115
8429
  } else kept[path] = previous[path];
@@ -8200,17 +8514,43 @@ function noHosts(deps) {
8200
8514
  "No skills directory found: none of ~/.claude, ~/.cursor or ~/.agents exists.\n"
8201
8515
  );
8202
8516
  }
8517
+ async function sendLearnings(deps, auth, learnings) {
8518
+ const command = ALL_COMMANDS.find((c) => c.tool === "skill_sync");
8519
+ if (!command) throw new Error("skill_sync is missing from the command table");
8520
+ const request = await buildRequest(command, {
8521
+ positionals: [],
8522
+ flags: /* @__PURE__ */ new Map([["learning", learnings]]),
8523
+ json: false
8524
+ });
8525
+ await send(deps.env.apiUrl, auth, request, false, deps.fetch);
8526
+ const noun = learnings.length === 1 ? "learning" : "learnings";
8527
+ deps.stderr(`Sent ${learnings.length} ${noun}.
8528
+ `);
8529
+ }
8203
8530
  async function syncSkills(deps, flagOrg, options) {
8204
8531
  const auth = await authFor(deps, flagOrg);
8532
+ const sent = options.learnings.length > 0;
8533
+ if (sent) await sendLearnings(deps, auth, options.learnings);
8205
8534
  const hosts = detectHosts(deps.env.home);
8206
8535
  if (hosts.length === 0) {
8207
8536
  noHosts(deps);
8208
- return 1;
8537
+ return sent ? 0 : 1;
8209
8538
  }
8210
- const result = await installSkills(deps, auth, hosts, options);
8211
- deps.stderr(`${formatInstall(result)}
8539
+ try {
8540
+ const result = await installSkills(deps, auth, hosts, {
8541
+ remove: options.remove && !sent
8542
+ });
8543
+ deps.stderr(`${formatInstall(result)}
8212
8544
  `);
8213
- return 0;
8545
+ return 0;
8546
+ } catch (error) {
8547
+ if (!sent) throw error;
8548
+ deps.stderr(
8549
+ `The skills did not update: ${clean(error.message)}. ${SYNC_HINT} to retry.
8550
+ `
8551
+ );
8552
+ return 0;
8553
+ }
8214
8554
  }
8215
8555
  async function offerSkills(deps) {
8216
8556
  const hosts = detectHosts(deps.env.home);
@@ -8661,239 +9001,6 @@ async function whoami(deps, flagOrg, json) {
8661
9001
  return 0;
8662
9002
  }
8663
9003
 
8664
- // src/request.ts
8665
- import { readFileSync as readFileSync2 } from "node:fs";
8666
- import { basename } from "node:path";
8667
- function camel(segment) {
8668
- return segment.replace(/-([a-z0-9])/g, (_, c) => c.toUpperCase());
8669
- }
8670
- function scalar(option2, raw) {
8671
- const type = option2.type.replace("[]", "");
8672
- if (option2.enum && !option2.enum.includes(raw)) {
8673
- throw new UsageError(
8674
- `--${option2.flag} must be one of ${option2.enum.join(", ")}`
8675
- );
8676
- }
8677
- if (type === "integer" || type === "number") {
8678
- const value2 = Number(raw);
8679
- if (raw.trim() === "" || Number.isNaN(value2) || type === "integer" && !Number.isInteger(value2)) {
8680
- throw new UsageError(
8681
- `--${option2.flag} must be ${type === "integer" ? "an integer" : "a number"}`
8682
- );
8683
- }
8684
- return value2;
8685
- }
8686
- if (type === "boolean") {
8687
- if (raw !== "true" && raw !== "false") {
8688
- throw new UsageError(`--${option2.flag} must be true or false`);
8689
- }
8690
- return raw === "true";
8691
- }
8692
- if (type === "json") return parseJson(raw, `--${option2.flag}`);
8693
- return raw;
8694
- }
8695
- function value(option2, raws) {
8696
- if (option2.type.endsWith("[]")) return raws.map((raw) => scalar(option2, raw));
8697
- return scalar(option2, raws.at(-1));
8698
- }
8699
- var nodeReader = {
8700
- text: async (path) => readFileSync2(path, "utf8"),
8701
- bytes: async (path) => new Uint8Array(readFileSync2(path))
8702
- };
8703
- async function readInput(raw, io) {
8704
- if (raw === "-") return io.text(0);
8705
- if (raw.startsWith("@")) return io.text(raw.slice(1));
8706
- return raw;
8707
- }
8708
- async function resolveInputs(command, parsed, io) {
8709
- const jsonFlags = [...command.query, ...command.body?.fields ?? []].filter((option2) => option2.type === "json").map((option2) => option2.flag);
8710
- const flags = new Map(parsed.flags);
8711
- for (const flag2 of jsonFlags) {
8712
- const raws = flags.get(flag2);
8713
- if (raws)
8714
- flags.set(flag2, await Promise.all(raws.map((raw) => readInput(raw, io))));
8715
- }
8716
- const body = parsed.body === void 0 ? void 0 : await readInput(parsed.body, io);
8717
- return { ...parsed, flags, body };
8718
- }
8719
- function parseJson(raw, label) {
8720
- try {
8721
- return JSON.parse(raw);
8722
- } catch {
8723
- throw new UsageError(`${label} is not valid JSON`);
8724
- }
8725
- }
8726
- function loose(raw) {
8727
- if (/^(true|false|null)$/.test(raw) || /^[[{]/.test(raw.trim())) {
8728
- try {
8729
- return JSON.parse(raw);
8730
- } catch {
8731
- return raw;
8732
- }
8733
- }
8734
- return raw;
8735
- }
8736
- function setPath(target, path, value2) {
8737
- let node = target;
8738
- for (const key of path.slice(0, -1)) {
8739
- const next = node[key];
8740
- if (typeof next !== "object" || next === null || Array.isArray(next))
8741
- node[key] = {};
8742
- node = node[key];
8743
- }
8744
- node[path.at(-1)] = value2;
8745
- }
8746
- async function dotted(field, segments, flag2, raws, io) {
8747
- const path = [];
8748
- let option2 = field;
8749
- for (const [i, segment] of segments.entries()) {
8750
- if (option2?.record) {
8751
- const key = segments.slice(i).join(".");
8752
- const entry = { ...option2, flag: flag2, type: option2.record };
8753
- delete entry.enum;
8754
- return [
8755
- [...path, key],
8756
- entry.type === "json" ? loose(raws.at(-1)) : value(entry, raws)
8757
- ];
8758
- }
8759
- if (option2?.fields) {
8760
- const child = option2.fields.find(
8761
- (f) => f.flag === segment
8762
- );
8763
- if (!child) throw new UsageError(`unknown flag: --${flag2}`);
8764
- path.push(child.name);
8765
- option2 = child;
8766
- continue;
8767
- }
8768
- if (option2 && option2.type !== "json") {
8769
- throw new UsageError(`unknown flag: --${flag2}`);
8770
- }
8771
- path.push(camel(segment));
8772
- option2 = void 0;
8773
- }
8774
- if (!option2) return [path, loose(raws.at(-1))];
8775
- if (option2.fields || option2.record) {
8776
- throw new UsageError(`--${flag2} needs a field, as --${flag2}.<name>`);
8777
- }
8778
- const inputs = option2.type === "json" ? await Promise.all(raws.map((raw) => readInput(raw, io))) : raws;
8779
- return [path, value({ ...option2, flag: flag2 }, inputs)];
8780
- }
8781
- async function buildRequest(command, input, context = {}) {
8782
- const io = context.io ?? nodeReader;
8783
- const parsed = await resolveInputs(command, input, io);
8784
- if (parsed.positionals.length !== command.args.length) {
8785
- const expected = command.args.map((a) => `<${a.flag}>`).join(" ") || "no arguments";
8786
- throw new UsageError(
8787
- `expected ${expected}, got ${parsed.positionals.length} argument(s)`
8788
- );
8789
- }
8790
- let path = command.path;
8791
- command.args.forEach((arg, i) => {
8792
- path = path.replace(
8793
- `{${arg.name}}`,
8794
- encodeURIComponent(parsed.positionals[i])
8795
- );
8796
- });
8797
- const flags = new Map(parsed.flags);
8798
- const query = new URLSearchParams();
8799
- for (const option2 of command.query) {
8800
- const raws = flags.get(option2.flag);
8801
- flags.delete(option2.flag);
8802
- if (!raws) {
8803
- if (option2.required) throw new UsageError(`--${option2.flag} is required`);
8804
- continue;
8805
- }
8806
- const parsedValue = value(option2, raws);
8807
- const values = Array.isArray(parsedValue) ? parsedValue : [parsedValue];
8808
- if (option2.explode === false)
8809
- query.append(option2.name, values.map(String).join(","));
8810
- else for (const v of values) query.append(option2.name, String(v));
8811
- }
8812
- const built = { method: command.method, path, query };
8813
- const body = command.body;
8814
- if (!body) {
8815
- if (parsed.body) throw new UsageError(`${command.command} takes no body`);
8816
- rejectUnknown(flags);
8817
- return built;
8818
- }
8819
- if (body.contentType === "multipart/form-data") {
8820
- if (parsed.body) {
8821
- throw new UsageError(
8822
- `${command.command} uploads files; use the file flags, not --body`
8823
- );
8824
- }
8825
- const form = new FormData();
8826
- for (const file of body.files) {
8827
- const paths = flags.get(file) ?? [];
8828
- if (body.required && paths.length === 0) {
8829
- throw new UsageError(`--${file} is required`);
8830
- }
8831
- for (const filePath of paths) {
8832
- form.append(
8833
- file,
8834
- new Blob([await io.bytes(filePath)]),
8835
- basename(filePath)
8836
- );
8837
- }
8838
- flags.delete(file);
8839
- }
8840
- for (const field of body.fields) {
8841
- const raws = flags.get(field.flag);
8842
- flags.delete(field.flag);
8843
- if (raws) for (const raw of raws) form.append(field.name, raw);
8844
- }
8845
- rejectUnknown(flags);
8846
- built.form = form;
8847
- return built;
8848
- }
8849
- const base = parsed.body ? parseJson(parsed.body, "--body") : {};
8850
- if (typeof base !== "object" || base === null || Array.isArray(base)) {
8851
- throw new UsageError("--body must be a JSON object");
8852
- }
8853
- const json = base;
8854
- for (const field of body.fields) {
8855
- const raws = flags.get(field.flag);
8856
- if (!raws) continue;
8857
- flags.delete(field.flag);
8858
- json[field.name] = value(field, raws);
8859
- }
8860
- for (const [flag2, raws] of [...flags]) {
8861
- const [head, ...rest] = flag2.split(".");
8862
- const field = body.fields.find((f) => f.flag === head);
8863
- if (!field || rest.length === 0) continue;
8864
- flags.delete(flag2);
8865
- const current = json[field.name];
8866
- json[field.name] = typeof current === "object" && current !== null ? current : {};
8867
- const [path2, value2] = await dotted(field, rest, flag2, raws, io);
8868
- setPath(json, [field.name, ...path2], value2);
8869
- }
8870
- rejectUnknown(flags);
8871
- delete json.organizationId;
8872
- if (body.credentialOrganization) {
8873
- if (!context.organizationId) {
8874
- throw new UsageError(
8875
- "could not tell which organization this credential acts in"
8876
- );
8877
- }
8878
- json.organizationId = context.organizationId;
8879
- }
8880
- for (const field of body.fields) {
8881
- if (field.required && json[field.name] === void 0) {
8882
- throw new UsageError(`--${field.flag} is required`);
8883
- }
8884
- }
8885
- if (body.required || Object.keys(json).length > 0) built.json = json;
8886
- return built;
8887
- }
8888
- function rejectUnknown(flags) {
8889
- const unknown = [...flags.keys()];
8890
- if (unknown.length > 0) {
8891
- throw new UsageError(
8892
- `unknown flag${unknown.length > 1 ? "s" : ""}: ${unknown.map((f) => `--${f}`).join(", ")}`
8893
- );
8894
- }
8895
- }
8896
-
8897
9004
  // src/sync/activities.ts
8898
9005
  function indentJson(data) {
8899
9006
  return JSON.stringify(data, null, 2).split("\n").map((line2) => ` ${line2}`).join("\n");
@@ -9890,8 +9997,11 @@ async function runBuiltin(name, parsed, deps) {
9890
9997
  exit: parsed.flags.has("exit")
9891
9998
  });
9892
9999
  case "skill sync":
10000
+ if (parsed.body)
10001
+ throw new UsageError("skill sync takes --learning, not --body");
9893
10002
  return syncSkills(deps, parsed.org, {
9894
- remove: parsed.flags.get("remove")?.[0] !== "false"
10003
+ remove: parsed.flags.get("remove")?.[0] !== "false",
10004
+ learnings: parsed.flags.get("learning") ?? []
9895
10005
  });
9896
10006
  default:
9897
10007
  return whoami(deps, parsed.org, parsed.json);
package/dist/core.js CHANGED
@@ -4419,6 +4419,43 @@ var COMMANDS = [
4419
4419
  readOnly: true,
4420
4420
  destructive: false
4421
4421
  },
4422
+ {
4423
+ command: "skill sync",
4424
+ tool: "skill_sync",
4425
+ title: "Sync skills",
4426
+ description: "Get the latest Asteroid skills for the portals your organization has added: how to build Asteroid workflows on each portal. Optional: `learnings`. If a skill was missing something about how a portal works that would have helped you build your automation, send it here. A learning is general knowledge of the portal, such as an SMS-only 2FA or a session that ends after 20 minutes. Each learning has `portal`, the portal's name or host, and `content`, in plain text. Set `portalId` only if you have one from `skills_list`.",
4427
+ method: "POST",
4428
+ path: "/astro/v2/skills",
4429
+ args: [],
4430
+ query: [
4431
+ {
4432
+ name: "surface",
4433
+ flag: "surface",
4434
+ type: "string",
4435
+ required: false,
4436
+ description: "The surface the skills are rendered for. Defaults to `cli`.",
4437
+ enum: ["cli", "mcp"]
4438
+ }
4439
+ ],
4440
+ binary: false,
4441
+ readOnly: false,
4442
+ destructive: false,
4443
+ body: {
4444
+ required: false,
4445
+ contentType: "application/json",
4446
+ fields: [
4447
+ {
4448
+ name: "learnings",
4449
+ flag: "learnings",
4450
+ type: "json",
4451
+ required: false,
4452
+ description: "Up to 10 things you found out about portals. Leave it out to sync only."
4453
+ }
4454
+ ],
4455
+ files: [],
4456
+ credentialOrganization: false
4457
+ }
4458
+ },
4422
4459
  {
4423
4460
  command: "tag create",
4424
4461
  tool: "workflow_tags_create",
@@ -6761,12 +6798,18 @@ var BUILTINS = [
6761
6798
  },
6762
6799
  {
6763
6800
  command: "skill sync",
6764
- usage: "asteroid skill sync",
6765
- description: "Install the Asteroid skills, or bring them up to date, in every skills directory found: `~/.claude/skills`, `~/.cursor/skills` and `~/.agents/skills`. Writes the files that changed, removes the skills the API no longer serves, and leaves a skill directory it did not create alone.",
6801
+ usage: "asteroid skill sync [--learning <json>]",
6802
+ description: "Install the Asteroid skills, or bring them up to date, in every skills directory found: `~/.claude/skills`, `~/.cursor/skills` and `~/.agents/skills`. Writes the files that changed, removes the skills the API no longer serves, and leaves a skill directory it did not create alone. Do not edit an installed skill, because the next sync overwrites it. If a skill is missing something about how a portal works, send it with `--learning`.",
6766
6803
  args: 0,
6767
6804
  options: [
6768
6805
  ["--no-remove", "Keep the skills and files the API no longer serves."]
6769
6806
  ],
6807
+ repeatableOptions: [
6808
+ [
6809
+ "--learning <json>",
6810
+ 'Optional. Something the portal\'s skill is missing about how the portal works, as JSON: `{"portal":"<name>","content":"<text>"}`. Add `portalId` if you have one. Repeat for more. Send this instead of editing the skill, because the next sync overwrites local edits. Send general knowledge of the portal only.'
6811
+ ]
6812
+ ],
6770
6813
  section: "Skills"
6771
6814
  }
6772
6815
  ];
@@ -6921,10 +6964,14 @@ function defineCommands(root, options, dotted2 = /* @__PURE__ */ new Map(), onIn
6921
6964
  const leaf = parent.command(words.at(-1)).description(builtin.description);
6922
6965
  if (builtin.arg) leaf.argument(`[${builtin.arg}]`);
6923
6966
  for (const [flags, text2] of builtin.options ?? []) leaf.option(flags, text2);
6967
+ for (const [flags, text2] of builtin.repeatableOptions ?? [])
6968
+ leaf.option(flags, text2, collect);
6924
6969
  for (const [flags, text2] of builtin.hiddenOptions ?? [])
6925
6970
  leaf.addOption(new Flag(flags, text2).hideHelp());
6926
6971
  leaf.action((...args) => {
6927
6972
  const cmd = args.at(-1);
6973
+ const [dottedFlag] = dotted2.keys();
6974
+ if (dottedFlag) throw new UsageError(`unknown flag: --${dottedFlag}`);
6928
6975
  onInvocation({
6929
6976
  kind: "builtin",
6930
6977
  name: builtin.command,
@@ -7085,7 +7132,7 @@ async function readInput(raw, io) {
7085
7132
  return raw;
7086
7133
  }
7087
7134
  async function resolveInputs(command, parsed, io) {
7088
- const jsonFlags = [...command.query, ...command.body?.fields ?? []].filter((option2) => option2.type === "json").map((option2) => option2.flag);
7135
+ const jsonFlags = [...command.query, ...command.body?.fields ?? []].filter((option2) => option2.type === "json" || option2.type === "json[]").map((option2) => option2.flag);
7089
7136
  const flags = new Map(parsed.flags);
7090
7137
  for (const flag2 of jsonFlags) {
7091
7138
  const raws = flags.get(flag2);
@@ -7437,7 +7484,18 @@ function withSyncCommands(commands) {
7437
7484
  (a, b) => a.command.localeCompare(b.command)
7438
7485
  );
7439
7486
  }
7440
- var ALL_COMMANDS = withSyncCommands(COMMANDS);
7487
+ var LEARNING = {
7488
+ name: "learnings",
7489
+ flag: "learning",
7490
+ type: "json[]",
7491
+ required: false,
7492
+ description: 'What you found out about a portal, as JSON: `{"portal":"<name>","content":"<text>"}`. Add `portalId` if you have one. Repeat for more.'
7493
+ };
7494
+ function withLearningFlag(command) {
7495
+ if (command.tool !== "skill_sync" || !command.body) return command;
7496
+ return { ...command, body: { ...command.body, fields: [LEARNING] } };
7497
+ }
7498
+ var ALL_COMMANDS = withSyncCommands(COMMANDS).map(withLearningFlag);
7441
7499
 
7442
7500
  // src/sync/activities.ts
7443
7501
  function indentJson(data) {
package/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "@asteroidai/cli",
3
- "version": "1.9.346",
3
+ "version": "1.9.350",
4
4
  "description": "The asteroid command-line interface for the Asteroid platform.",
5
5
  "type": "module",
6
6
  "license": "MIT",