@asteroidai/cli 1.9.181 → 1.9.182
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 +537 -145
- package/dist/core.js +21 -4
- package/package.json +1 -1
package/dist/asteroid.js
CHANGED
|
@@ -6723,6 +6723,7 @@ import {
|
|
|
6723
6723
|
renameSync,
|
|
6724
6724
|
writeFileSync
|
|
6725
6725
|
} from "node:fs";
|
|
6726
|
+
import { homedir } from "node:os";
|
|
6726
6727
|
import { dirname, join } from "node:path";
|
|
6727
6728
|
|
|
6728
6729
|
// src/output.ts
|
|
@@ -6872,7 +6873,8 @@ function readEnv(env = process.env) {
|
|
|
6872
6873
|
org: env.ASTEROID_ORG || void 0,
|
|
6873
6874
|
workosClientId: env.ASTEROID_WORKOS_CLIENT_ID || DEFAULT_WORKOS_CLIENT_ID,
|
|
6874
6875
|
workosApiUrl: (env.ASTEROID_WORKOS_API_URL || DEFAULT_WORKOS_API_URL).replace(/\/+$/, ""),
|
|
6875
|
-
configDir: env.ASTEROID_CONFIG_DIR || envPaths("asteroid", { suffix: "" }).config
|
|
6876
|
+
configDir: env.ASTEROID_CONFIG_DIR || envPaths("asteroid", { suffix: "" }).config,
|
|
6877
|
+
home: env.HOME || homedir()
|
|
6876
6878
|
};
|
|
6877
6879
|
}
|
|
6878
6880
|
function readJson(path, fallback) {
|
|
@@ -6945,8 +6947,9 @@ var BUILTINS = [
|
|
|
6945
6947
|
{
|
|
6946
6948
|
command: "login",
|
|
6947
6949
|
usage: "asteroid login",
|
|
6948
|
-
description: "Sign in with your browser. Stores a refresh token in the OS keychain, or in a private file in the config directory when no keychain is available.",
|
|
6949
|
-
args: 0
|
|
6950
|
+
description: "Sign in with your browser. Stores a refresh token in the OS keychain, or in a private file in the config directory when no keychain is available. Then offers to install the Asteroid skills into every skills directory it finds: `~/.claude/skills` (Claude Code), `~/.cursor/skills` (Cursor) and `~/.agents/skills`.",
|
|
6951
|
+
args: 0,
|
|
6952
|
+
options: [["--no-skills", "Do not offer to install the Asteroid skills."]]
|
|
6950
6953
|
},
|
|
6951
6954
|
{
|
|
6952
6955
|
command: "logout",
|
|
@@ -6989,6 +6992,16 @@ var BUILTINS = [
|
|
|
6989
6992
|
usage: "asteroid whoami",
|
|
6990
6993
|
description: "Show who you act as, in which organization, and how long the token lasts.",
|
|
6991
6994
|
args: 0
|
|
6995
|
+
},
|
|
6996
|
+
{
|
|
6997
|
+
command: "skill sync",
|
|
6998
|
+
usage: "asteroid skill sync",
|
|
6999
|
+
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.",
|
|
7000
|
+
args: 0,
|
|
7001
|
+
options: [
|
|
7002
|
+
["--no-remove", "Keep the skills and files the API no longer serves."]
|
|
7003
|
+
],
|
|
7004
|
+
section: "Skills"
|
|
6992
7005
|
}
|
|
6993
7006
|
];
|
|
6994
7007
|
var BUILTIN_COMMANDS = new Set(BUILTINS.map((b) => b.command));
|
|
@@ -7132,9 +7145,16 @@ function defineCommands(root, options, dotted2 = /* @__PURE__ */ new Map(), onIn
|
|
|
7132
7145
|
for (const [flags, text3] of GLOBAL_FLAGS) {
|
|
7133
7146
|
if (!flags.startsWith("-h")) root.option(flags, text3);
|
|
7134
7147
|
}
|
|
7148
|
+
const groups = /* @__PURE__ */ new Map();
|
|
7135
7149
|
for (const builtin of options.builtins ?? []) {
|
|
7136
|
-
const
|
|
7150
|
+
const words = builtin.command.split(" ");
|
|
7151
|
+
let parent = root;
|
|
7152
|
+
for (let i = 0; i < words.length - 1; i++) {
|
|
7153
|
+
parent = group(parent, words[i], groups, words.slice(0, i + 1).join(" "));
|
|
7154
|
+
}
|
|
7155
|
+
const leaf = parent.command(words.at(-1)).description(builtin.description);
|
|
7137
7156
|
if (builtin.arg) leaf.argument(`[${builtin.arg}]`);
|
|
7157
|
+
for (const [flags, text3] of builtin.options ?? []) leaf.option(flags, text3);
|
|
7138
7158
|
for (const [flags, text3] of builtin.hiddenOptions ?? [])
|
|
7139
7159
|
leaf.addOption(new Flag(flags, text3).hideHelp());
|
|
7140
7160
|
leaf.action((...args) => {
|
|
@@ -7147,7 +7167,6 @@ function defineCommands(root, options, dotted2 = /* @__PURE__ */ new Map(), onIn
|
|
|
7147
7167
|
});
|
|
7148
7168
|
}
|
|
7149
7169
|
const reserved = new Set((options.builtins ?? []).map((b) => b.command));
|
|
7150
|
-
const groups = /* @__PURE__ */ new Map();
|
|
7151
7170
|
for (const command of options.commands) {
|
|
7152
7171
|
if (reserved.has(command.command)) continue;
|
|
7153
7172
|
const words = command.command.split(" ");
|
|
@@ -7263,7 +7282,7 @@ async function runCompletion(argv2, options) {
|
|
|
7263
7282
|
}
|
|
7264
7283
|
|
|
7265
7284
|
// src/run.ts
|
|
7266
|
-
import { writeFileSync as
|
|
7285
|
+
import { writeFileSync as writeFileSync3 } from "node:fs";
|
|
7267
7286
|
|
|
7268
7287
|
// src/auth/store.ts
|
|
7269
7288
|
import { mkdirSync as mkdirSync2, rmSync } from "node:fs";
|
|
@@ -7710,7 +7729,7 @@ var ApiError = class extends Error {
|
|
|
7710
7729
|
status;
|
|
7711
7730
|
body;
|
|
7712
7731
|
};
|
|
7713
|
-
var VERSION = "1.9.
|
|
7732
|
+
var VERSION = "1.9.182";
|
|
7714
7733
|
function problem(status, body, fallback) {
|
|
7715
7734
|
if (body && typeof body === "object") {
|
|
7716
7735
|
const record2 = body;
|
|
@@ -7796,6 +7815,456 @@ async function send(apiUrl, auth, request, binary, fetchImpl = fetch) {
|
|
|
7796
7815
|
return { status: response.status, text: await response.text() };
|
|
7797
7816
|
}
|
|
7798
7817
|
|
|
7818
|
+
// src/skills.ts
|
|
7819
|
+
import {
|
|
7820
|
+
existsSync as existsSync2,
|
|
7821
|
+
lstatSync,
|
|
7822
|
+
mkdirSync as mkdirSync3,
|
|
7823
|
+
readdirSync,
|
|
7824
|
+
rmdirSync,
|
|
7825
|
+
rmSync as rmSync2,
|
|
7826
|
+
writeFileSync as writeFileSync2
|
|
7827
|
+
} from "node:fs";
|
|
7828
|
+
import { dirname as dirname2, join as join4 } from "node:path";
|
|
7829
|
+
|
|
7830
|
+
// ../workflow-files/src/representation/name-charset.ts
|
|
7831
|
+
var NAME_CHARSET_RE = /^[A-Za-z0-9 !#$%&'()+,.;=@^`{}[\]~-]+$/;
|
|
7832
|
+
var WINDOWS_RESERVED = /* @__PURE__ */ new Set([
|
|
7833
|
+
"con",
|
|
7834
|
+
"prn",
|
|
7835
|
+
"aux",
|
|
7836
|
+
"nul",
|
|
7837
|
+
...Array.from({ length: 9 }, (_, i) => `com${i + 1}`),
|
|
7838
|
+
...Array.from({ length: 9 }, (_, i) => `lpt${i + 1}`)
|
|
7839
|
+
]);
|
|
7840
|
+
function isNameCharsetConforming(name) {
|
|
7841
|
+
return NAME_CHARSET_RE.test(name);
|
|
7842
|
+
}
|
|
7843
|
+
|
|
7844
|
+
// ../workflow-files/src/representation/types.ts
|
|
7845
|
+
function normalizeNodeName(name) {
|
|
7846
|
+
let result = name.toLowerCase();
|
|
7847
|
+
result = result.replace(/[^a-z0-9]+/g, "_");
|
|
7848
|
+
result = result.replace(/^_+|_+$/g, "");
|
|
7849
|
+
if (result.length > 80) {
|
|
7850
|
+
result = result.slice(0, 80).replace(/_+$/, "");
|
|
7851
|
+
}
|
|
7852
|
+
if (result === "") {
|
|
7853
|
+
throw new Error(
|
|
7854
|
+
`representation: node name "${name}" produces an empty directory name after normalization`
|
|
7855
|
+
);
|
|
7856
|
+
}
|
|
7857
|
+
return result;
|
|
7858
|
+
}
|
|
7859
|
+
function lossySlugOr(name, fallback) {
|
|
7860
|
+
try {
|
|
7861
|
+
return normalizeNodeName(name);
|
|
7862
|
+
} catch {
|
|
7863
|
+
return fallback;
|
|
7864
|
+
}
|
|
7865
|
+
}
|
|
7866
|
+
function nodeDirName(name) {
|
|
7867
|
+
if (isNameCharsetConforming(name)) {
|
|
7868
|
+
return name.replaceAll(" ", "_");
|
|
7869
|
+
}
|
|
7870
|
+
return normalizeNodeName(name);
|
|
7871
|
+
}
|
|
7872
|
+
function agentDirName(name) {
|
|
7873
|
+
try {
|
|
7874
|
+
return nodeDirName(name);
|
|
7875
|
+
} catch {
|
|
7876
|
+
return "agent";
|
|
7877
|
+
}
|
|
7878
|
+
}
|
|
7879
|
+
function executionDirName(executionId2) {
|
|
7880
|
+
return executionId2.slice(0, 8);
|
|
7881
|
+
}
|
|
7882
|
+
function workflowDirName(workflowId, version, parentId, parentVersion) {
|
|
7883
|
+
const short = workflowId.slice(0, 8);
|
|
7884
|
+
if (version !== void 0 && version !== null) {
|
|
7885
|
+
return `v${version}_${short}`;
|
|
7886
|
+
}
|
|
7887
|
+
if (parentId) {
|
|
7888
|
+
if (parentVersion !== void 0 && parentVersion !== null) {
|
|
7889
|
+
return `draft_${short}_from_v${parentVersion}`;
|
|
7890
|
+
}
|
|
7891
|
+
return `draft_${short}_from_draft_${parentId.slice(0, 8)}`;
|
|
7892
|
+
}
|
|
7893
|
+
return `draft_${short}`;
|
|
7894
|
+
}
|
|
7895
|
+
|
|
7896
|
+
// src/sync/paths.ts
|
|
7897
|
+
import { createHash } from "node:crypto";
|
|
7898
|
+
function join3(...parts) {
|
|
7899
|
+
return parts.filter((part) => part !== "").join("/").replace(/\/{2,}/g, "/");
|
|
7900
|
+
}
|
|
7901
|
+
function workflowRoot(root, workflowName) {
|
|
7902
|
+
return join3(root, agentDirName(workflowName));
|
|
7903
|
+
}
|
|
7904
|
+
function isContained(path) {
|
|
7905
|
+
if (path === "" || path.startsWith("/") || path.includes("\\")) return false;
|
|
7906
|
+
return path.split("/").every((segment) => segment !== ".." && segment !== "");
|
|
7907
|
+
}
|
|
7908
|
+
function sha256(bytes) {
|
|
7909
|
+
return createHash("sha256").update(bytes).digest("hex");
|
|
7910
|
+
}
|
|
7911
|
+
function matchesGlob(path, pattern) {
|
|
7912
|
+
let source = "";
|
|
7913
|
+
for (let i = 0; i < pattern.length; i++) {
|
|
7914
|
+
const ch = pattern[i];
|
|
7915
|
+
if (ch === "*" && pattern[i + 1] === "*" && pattern[i + 2] === "/") {
|
|
7916
|
+
source += "(?:.*/)?";
|
|
7917
|
+
i += 2;
|
|
7918
|
+
} else if (ch === "*" && pattern[i + 1] === "*") {
|
|
7919
|
+
source += ".*";
|
|
7920
|
+
i += 1;
|
|
7921
|
+
} else if (ch === "*") source += "[^/]*";
|
|
7922
|
+
else if (ch === "?") source += "[^/]";
|
|
7923
|
+
else source += ch.replace(/[.+^${}()|[\]\\]/g, "\\$&");
|
|
7924
|
+
}
|
|
7925
|
+
return new RegExp(`^${source}$`).test(path);
|
|
7926
|
+
}
|
|
7927
|
+
|
|
7928
|
+
// src/skills.ts
|
|
7929
|
+
var SKILLS_FILE = "skills.json";
|
|
7930
|
+
var CHECK_INTERVAL_MS = 24 * 36e5;
|
|
7931
|
+
var SYNC_HINT = "Run `asteroid skill sync`";
|
|
7932
|
+
var HOST_PARENTS = [
|
|
7933
|
+
{ name: "Claude Code", parent: ".claude" },
|
|
7934
|
+
{ name: "Cursor", parent: ".cursor" },
|
|
7935
|
+
{ name: "~/.agents", parent: ".agents" }
|
|
7936
|
+
];
|
|
7937
|
+
var SKILL_NAME = /^[a-z0-9][a-z0-9-]{0,63}$/;
|
|
7938
|
+
var CONCURRENCY = 8;
|
|
7939
|
+
function detectHosts(home) {
|
|
7940
|
+
return HOST_PARENTS.filter((host) => existsSync2(join4(home, host.parent))).map(
|
|
7941
|
+
(host) => ({ name: host.name, dir: join4(home, host.parent, "skills") })
|
|
7942
|
+
);
|
|
7943
|
+
}
|
|
7944
|
+
function hostLabel(hosts) {
|
|
7945
|
+
const names = hosts.map((host) => host.name);
|
|
7946
|
+
if (names.length <= 1) return names.join("");
|
|
7947
|
+
return `${names.slice(0, -1).join(", ")} and ${names.at(-1)}`;
|
|
7948
|
+
}
|
|
7949
|
+
function loadSkillsState(env) {
|
|
7950
|
+
const state = readJson(
|
|
7951
|
+
join4(env.configDir, SKILLS_FILE),
|
|
7952
|
+
{}
|
|
7953
|
+
);
|
|
7954
|
+
return { ...state, hosts: state.hosts ?? {} };
|
|
7955
|
+
}
|
|
7956
|
+
function saveSkillsState(env, state) {
|
|
7957
|
+
writePrivateJson(join4(env.configDir, SKILLS_FILE), state);
|
|
7958
|
+
}
|
|
7959
|
+
function installable(row) {
|
|
7960
|
+
return row.kind !== "portal" || row.added === true;
|
|
7961
|
+
}
|
|
7962
|
+
function wantedSkills(rows, skipped) {
|
|
7963
|
+
const seen = /* @__PURE__ */ new Set();
|
|
7964
|
+
const wanted = [];
|
|
7965
|
+
for (const row of rows) {
|
|
7966
|
+
if (!installable(row)) continue;
|
|
7967
|
+
if (!SKILL_NAME.test(row.name)) {
|
|
7968
|
+
skipped.push(`${clean(row.name)} (not a skill name)`);
|
|
7969
|
+
continue;
|
|
7970
|
+
}
|
|
7971
|
+
if (seen.has(row.name)) {
|
|
7972
|
+
skipped.push(
|
|
7973
|
+
`${row.kind} skill ${row.name} (another skill has the same name)`
|
|
7974
|
+
);
|
|
7975
|
+
continue;
|
|
7976
|
+
}
|
|
7977
|
+
seen.add(row.name);
|
|
7978
|
+
wanted.push(row);
|
|
7979
|
+
}
|
|
7980
|
+
return wanted;
|
|
7981
|
+
}
|
|
7982
|
+
async function listSkills(env, auth, fetchImpl) {
|
|
7983
|
+
const response = await send(
|
|
7984
|
+
env.apiUrl,
|
|
7985
|
+
auth,
|
|
7986
|
+
{ method: "GET", path: "/astro/v2/skills", query: new URLSearchParams() },
|
|
7987
|
+
false,
|
|
7988
|
+
fetchImpl
|
|
7989
|
+
);
|
|
7990
|
+
return response.json.skills ?? [];
|
|
7991
|
+
}
|
|
7992
|
+
async function getSkill(env, auth, fetchImpl, row) {
|
|
7993
|
+
const response = await send(
|
|
7994
|
+
env.apiUrl,
|
|
7995
|
+
auth,
|
|
7996
|
+
{
|
|
7997
|
+
method: "GET",
|
|
7998
|
+
path: `/astro/v2/skills/${encodeURIComponent(row.name)}`,
|
|
7999
|
+
query: new URLSearchParams({ kind: row.kind })
|
|
8000
|
+
},
|
|
8001
|
+
false,
|
|
8002
|
+
fetchImpl
|
|
8003
|
+
);
|
|
8004
|
+
return response.json;
|
|
8005
|
+
}
|
|
8006
|
+
function servedDigests(row, skipped) {
|
|
8007
|
+
const digests = {};
|
|
8008
|
+
for (const file of row.files) {
|
|
8009
|
+
if (isContained(file.path)) digests[file.path] = file.digest;
|
|
8010
|
+
else skipped.push(`${row.name}/${clean(file.path)} (unsafe path)`);
|
|
8011
|
+
}
|
|
8012
|
+
return digests;
|
|
8013
|
+
}
|
|
8014
|
+
function sameDigests(a, b) {
|
|
8015
|
+
if (!a) return false;
|
|
8016
|
+
const keys = Object.keys(a);
|
|
8017
|
+
return keys.length === Object.keys(b).length && keys.every((path) => a[path] === b[path]);
|
|
8018
|
+
}
|
|
8019
|
+
function removeEmptyDirs(from, upTo) {
|
|
8020
|
+
let dir = from;
|
|
8021
|
+
while (dir.startsWith(upTo)) {
|
|
8022
|
+
try {
|
|
8023
|
+
if (readdirSync(dir).length > 0) return;
|
|
8024
|
+
rmdirSync(dir);
|
|
8025
|
+
} catch {
|
|
8026
|
+
return;
|
|
8027
|
+
}
|
|
8028
|
+
if (dir === upTo) return;
|
|
8029
|
+
dir = dirname2(dir);
|
|
8030
|
+
}
|
|
8031
|
+
}
|
|
8032
|
+
function removeFile(skillDir, path) {
|
|
8033
|
+
rmSync2(join4(skillDir, path), { force: true });
|
|
8034
|
+
removeEmptyDirs(dirname2(join4(skillDir, path)), skillDir);
|
|
8035
|
+
}
|
|
8036
|
+
function throughSymlink(skillDir, path) {
|
|
8037
|
+
let current = skillDir;
|
|
8038
|
+
for (const part of ["", ...path.split("/")]) {
|
|
8039
|
+
current = join4(current, part);
|
|
8040
|
+
try {
|
|
8041
|
+
if (lstatSync(current).isSymbolicLink()) return true;
|
|
8042
|
+
} catch (error) {
|
|
8043
|
+
return error.code !== "ENOENT";
|
|
8044
|
+
}
|
|
8045
|
+
}
|
|
8046
|
+
return false;
|
|
8047
|
+
}
|
|
8048
|
+
function planHost(host, owned, wanted, served) {
|
|
8049
|
+
const result = {
|
|
8050
|
+
dir: host.dir,
|
|
8051
|
+
skills: 0,
|
|
8052
|
+
written: 0,
|
|
8053
|
+
removed: 0,
|
|
8054
|
+
skipped: []
|
|
8055
|
+
};
|
|
8056
|
+
const names = /* @__PURE__ */ new Set();
|
|
8057
|
+
const needs = /* @__PURE__ */ new Map();
|
|
8058
|
+
for (const row of wanted) {
|
|
8059
|
+
const skillDir = join4(host.dir, row.name);
|
|
8060
|
+
if (!(row.name in owned) && existsSync2(skillDir)) {
|
|
8061
|
+
result.skipped.push(`${skillDir} (not installed by asteroid)`);
|
|
8062
|
+
continue;
|
|
8063
|
+
}
|
|
8064
|
+
names.add(row.name);
|
|
8065
|
+
result.skills++;
|
|
8066
|
+
const digests = served.get(row.name) ?? {};
|
|
8067
|
+
const stale = /* @__PURE__ */ new Set();
|
|
8068
|
+
for (const [path, digest] of Object.entries(digests)) {
|
|
8069
|
+
if (owned[row.name]?.[path] !== digest || !existsSync2(join4(skillDir, path)))
|
|
8070
|
+
stale.add(path);
|
|
8071
|
+
}
|
|
8072
|
+
if (stale.size > 0) needs.set(row.name, stale);
|
|
8073
|
+
}
|
|
8074
|
+
return { host, owned, names, needs, result };
|
|
8075
|
+
}
|
|
8076
|
+
async function inBatches(items, each) {
|
|
8077
|
+
for (let i = 0; i < items.length; i += CONCURRENCY) {
|
|
8078
|
+
await Promise.all(items.slice(i, i + CONCURRENCY).map(each));
|
|
8079
|
+
}
|
|
8080
|
+
}
|
|
8081
|
+
function applyHost(plan, served, fetched, options) {
|
|
8082
|
+
const { host, owned, names, needs, result } = plan;
|
|
8083
|
+
for (const name of names) {
|
|
8084
|
+
const skillDir = join4(host.dir, name);
|
|
8085
|
+
const digests = { ...served.get(name) };
|
|
8086
|
+
const stale = needs.get(name);
|
|
8087
|
+
const skill = fetched.get(name);
|
|
8088
|
+
const unwritten = /* @__PURE__ */ new Set();
|
|
8089
|
+
if (stale && skill) {
|
|
8090
|
+
for (const file of skill.files) {
|
|
8091
|
+
if (!stale.has(file.path)) continue;
|
|
8092
|
+
if (throughSymlink(skillDir, file.path)) {
|
|
8093
|
+
result.skipped.push(
|
|
8094
|
+
`${join4(skillDir, file.path)} (a symlink is in the way)`
|
|
8095
|
+
);
|
|
8096
|
+
unwritten.add(file.path);
|
|
8097
|
+
continue;
|
|
8098
|
+
}
|
|
8099
|
+
mkdirSync3(dirname2(join4(skillDir, file.path)), { recursive: true });
|
|
8100
|
+
writeFileSync2(join4(skillDir, file.path), file.content, "utf8");
|
|
8101
|
+
result.written++;
|
|
8102
|
+
}
|
|
8103
|
+
}
|
|
8104
|
+
for (const path of unwritten) delete digests[path];
|
|
8105
|
+
const previous = owned[name] ?? {};
|
|
8106
|
+
const kept = {};
|
|
8107
|
+
for (const path of Object.keys(previous)) {
|
|
8108
|
+
if (path in digests) continue;
|
|
8109
|
+
if (options.remove) {
|
|
8110
|
+
removeFile(skillDir, path);
|
|
8111
|
+
result.removed++;
|
|
8112
|
+
} else kept[path] = previous[path];
|
|
8113
|
+
}
|
|
8114
|
+
owned[name] = { ...kept, ...digests };
|
|
8115
|
+
}
|
|
8116
|
+
for (const name of Object.keys(owned)) {
|
|
8117
|
+
if (names.has(name) || !options.remove) continue;
|
|
8118
|
+
const skillDir = join4(host.dir, name);
|
|
8119
|
+
for (const path of Object.keys(owned[name])) {
|
|
8120
|
+
removeFile(skillDir, path);
|
|
8121
|
+
result.removed++;
|
|
8122
|
+
}
|
|
8123
|
+
delete owned[name];
|
|
8124
|
+
}
|
|
8125
|
+
}
|
|
8126
|
+
async function installSkills(deps, auth, hosts, options, rows) {
|
|
8127
|
+
rows ??= await listSkills(deps.env, auth, deps.fetch);
|
|
8128
|
+
const skipped = [];
|
|
8129
|
+
const wanted = wantedSkills(rows, skipped);
|
|
8130
|
+
const served = new Map(
|
|
8131
|
+
wanted.map((row) => [row.name, servedDigests(row, skipped)])
|
|
8132
|
+
);
|
|
8133
|
+
const state = loadSkillsState(deps.env);
|
|
8134
|
+
const plans = hosts.map(
|
|
8135
|
+
(host) => planHost(host, state.hosts[host.dir] ??= {}, wanted, served)
|
|
8136
|
+
);
|
|
8137
|
+
const toFetch = wanted.filter(
|
|
8138
|
+
(row) => plans.some((plan) => plan.needs.has(row.name))
|
|
8139
|
+
);
|
|
8140
|
+
const fetched = /* @__PURE__ */ new Map();
|
|
8141
|
+
await inBatches(toFetch, async (row) => {
|
|
8142
|
+
fetched.set(row.name, await getSkill(deps.env, auth, deps.fetch, row));
|
|
8143
|
+
});
|
|
8144
|
+
for (const plan of plans) applyHost(plan, served, fetched, options);
|
|
8145
|
+
saveSkillsState(deps.env, state);
|
|
8146
|
+
return {
|
|
8147
|
+
skills: wanted.length,
|
|
8148
|
+
skipped,
|
|
8149
|
+
hosts: plans.map((plan) => plan.result)
|
|
8150
|
+
};
|
|
8151
|
+
}
|
|
8152
|
+
function formatInstall(result) {
|
|
8153
|
+
const lines = result.hosts.map((host) => {
|
|
8154
|
+
const changes = [
|
|
8155
|
+
host.written > 0 ? `${host.written} files written` : "",
|
|
8156
|
+
host.removed > 0 ? `${host.removed} removed` : ""
|
|
8157
|
+
].filter(Boolean);
|
|
8158
|
+
return `${host.dir}: ${host.skills} skills, ${changes.length > 0 ? changes.join(", ") : "up to date"}.`;
|
|
8159
|
+
});
|
|
8160
|
+
for (const line2 of [
|
|
8161
|
+
...result.skipped,
|
|
8162
|
+
...result.hosts.flatMap((host) => host.skipped)
|
|
8163
|
+
])
|
|
8164
|
+
lines.push(`Skipped ${line2}.`);
|
|
8165
|
+
return lines.join("\n");
|
|
8166
|
+
}
|
|
8167
|
+
function staleSkills(state, hosts, rows) {
|
|
8168
|
+
const wanted = wantedSkills(rows, []);
|
|
8169
|
+
const served = new Map(
|
|
8170
|
+
wanted.map((row) => [row.name, servedDigests(row, [])])
|
|
8171
|
+
);
|
|
8172
|
+
const stale = /* @__PURE__ */ new Set();
|
|
8173
|
+
for (const host of hosts) {
|
|
8174
|
+
const owned = state.hosts[host.dir] ?? {};
|
|
8175
|
+
for (const [name, digests] of served) {
|
|
8176
|
+
const present = Object.keys(digests).every(
|
|
8177
|
+
(path) => existsSync2(join4(host.dir, name, path))
|
|
8178
|
+
);
|
|
8179
|
+
if (!present || !sameDigests(owned[name], digests)) stale.add(name);
|
|
8180
|
+
}
|
|
8181
|
+
for (const name of Object.keys(owned))
|
|
8182
|
+
if (!served.has(name)) stale.add(name);
|
|
8183
|
+
}
|
|
8184
|
+
return stale.size;
|
|
8185
|
+
}
|
|
8186
|
+
async function authFor(deps, flagOrg) {
|
|
8187
|
+
const config = loadConfig(deps.env);
|
|
8188
|
+
return resolveAuth(
|
|
8189
|
+
deps.env,
|
|
8190
|
+
config,
|
|
8191
|
+
requestedOrg(flagOrg, deps.env, deps.cwd, config),
|
|
8192
|
+
deps.fetch
|
|
8193
|
+
);
|
|
8194
|
+
}
|
|
8195
|
+
function noHosts(deps) {
|
|
8196
|
+
deps.stderr(
|
|
8197
|
+
"No skills directory found: none of ~/.claude, ~/.cursor or ~/.agents exists.\n"
|
|
8198
|
+
);
|
|
8199
|
+
}
|
|
8200
|
+
async function syncSkills(deps, flagOrg, options) {
|
|
8201
|
+
const auth = await authFor(deps, flagOrg);
|
|
8202
|
+
const hosts = detectHosts(deps.env.home);
|
|
8203
|
+
if (hosts.length === 0) {
|
|
8204
|
+
noHosts(deps);
|
|
8205
|
+
return 1;
|
|
8206
|
+
}
|
|
8207
|
+
const result = await installSkills(deps, auth, hosts, options);
|
|
8208
|
+
deps.stderr(`${formatInstall(result)}
|
|
8209
|
+
`);
|
|
8210
|
+
return 0;
|
|
8211
|
+
}
|
|
8212
|
+
async function offerSkills(deps) {
|
|
8213
|
+
const hosts = detectHosts(deps.env.home);
|
|
8214
|
+
if (hosts.length === 0) return noHosts(deps);
|
|
8215
|
+
try {
|
|
8216
|
+
const auth = await authFor(deps, void 0);
|
|
8217
|
+
const rows = await listSkills(deps.env, auth, deps.fetch);
|
|
8218
|
+
const count = wantedSkills(rows, []).length;
|
|
8219
|
+
if (count === 0) return;
|
|
8220
|
+
const label = `${count} Asteroid skill${count === 1 ? "" : "s"} for ${hostLabel(hosts)}`;
|
|
8221
|
+
if (!deps.ui) {
|
|
8222
|
+
deps.stderr(`${SYNC_HINT} to install ${label}.
|
|
8223
|
+
`);
|
|
8224
|
+
return;
|
|
8225
|
+
}
|
|
8226
|
+
const yes = await deps.ui.confirm(`Install ${label}?`, true);
|
|
8227
|
+
if (!yes) {
|
|
8228
|
+
deps.stderr(`Skipped. ${SYNC_HINT} to install them later.
|
|
8229
|
+
`);
|
|
8230
|
+
return;
|
|
8231
|
+
}
|
|
8232
|
+
const result = await installSkills(
|
|
8233
|
+
deps,
|
|
8234
|
+
auth,
|
|
8235
|
+
hosts,
|
|
8236
|
+
{ remove: true },
|
|
8237
|
+
rows
|
|
8238
|
+
);
|
|
8239
|
+
deps.stderr(`${formatInstall(result)}
|
|
8240
|
+
`);
|
|
8241
|
+
} catch (error) {
|
|
8242
|
+
deps.stderr(
|
|
8243
|
+
`Could not install the Asteroid skills: ${clean(error instanceof Error ? error.message : String(error))}. ${SYNC_HINT} to retry.
|
|
8244
|
+
`
|
|
8245
|
+
);
|
|
8246
|
+
}
|
|
8247
|
+
}
|
|
8248
|
+
async function skillsNotice(deps, flagOrg) {
|
|
8249
|
+
try {
|
|
8250
|
+
const state = loadSkillsState(deps.env);
|
|
8251
|
+
if (Object.keys(state.hosts).length === 0) return;
|
|
8252
|
+
if (state.checkedAt && Date.now() - state.checkedAt < CHECK_INTERVAL_MS)
|
|
8253
|
+
return;
|
|
8254
|
+
saveSkillsState(deps.env, { ...state, checkedAt: Date.now() });
|
|
8255
|
+
const auth = await authFor(deps, flagOrg);
|
|
8256
|
+
const rows = await listSkills(deps.env, auth, deps.fetch);
|
|
8257
|
+
const stale = staleSkills(state, detectHosts(deps.env.home), rows);
|
|
8258
|
+
if (stale === 0) return;
|
|
8259
|
+
deps.stderr(
|
|
8260
|
+
`${stale} Asteroid skill${stale === 1 ? " is" : "s are"} out of date. ${SYNC_HINT}.
|
|
8261
|
+
`
|
|
8262
|
+
);
|
|
8263
|
+
} catch {
|
|
8264
|
+
return;
|
|
8265
|
+
}
|
|
8266
|
+
}
|
|
8267
|
+
|
|
7799
8268
|
// src/account.ts
|
|
7800
8269
|
async function chooseOrg(deps, orgs2) {
|
|
7801
8270
|
if (orgs2.length === 0)
|
|
@@ -7809,7 +8278,7 @@ async function chooseOrg(deps, orgs2) {
|
|
|
7809
8278
|
if (!chosen) throw new AuthError("sign-in cancelled");
|
|
7810
8279
|
return chosen;
|
|
7811
8280
|
}
|
|
7812
|
-
async function login(deps) {
|
|
8281
|
+
async function login(deps, options = {}) {
|
|
7813
8282
|
if (deps.env.apiKey)
|
|
7814
8283
|
deps.stderr(
|
|
7815
8284
|
`Warning: ${API_KEY_OVERRIDES} Every command will use the key, not this sign-in. ${UNSET_API_KEY}
|
|
@@ -7862,6 +8331,7 @@ and confirm the code ${clean(device.user_code)}
|
|
|
7862
8331
|
`Signed in as ${clean(session2.email ?? "you")}${config.org ? ` in ${orgLabel(config.org)}` : ""}. Token saved to the ${where === "keychain" ? "OS keychain" : "config directory"}.
|
|
7863
8332
|
`
|
|
7864
8333
|
);
|
|
8334
|
+
if (options.skills !== false) await offerSkills(deps);
|
|
7865
8335
|
return 0;
|
|
7866
8336
|
}
|
|
7867
8337
|
async function logout(deps) {
|
|
@@ -8493,104 +8963,6 @@ function formatActivitiesMarkdown(activities, status, createdAt) {
|
|
|
8493
8963
|
return lines.join("\n");
|
|
8494
8964
|
}
|
|
8495
8965
|
|
|
8496
|
-
// ../workflow-files/src/representation/name-charset.ts
|
|
8497
|
-
var NAME_CHARSET_RE = /^[A-Za-z0-9 !#$%&'()+,.;=@^`{}[\]~-]+$/;
|
|
8498
|
-
var WINDOWS_RESERVED = /* @__PURE__ */ new Set([
|
|
8499
|
-
"con",
|
|
8500
|
-
"prn",
|
|
8501
|
-
"aux",
|
|
8502
|
-
"nul",
|
|
8503
|
-
...Array.from({ length: 9 }, (_, i) => `com${i + 1}`),
|
|
8504
|
-
...Array.from({ length: 9 }, (_, i) => `lpt${i + 1}`)
|
|
8505
|
-
]);
|
|
8506
|
-
function isNameCharsetConforming(name) {
|
|
8507
|
-
return NAME_CHARSET_RE.test(name);
|
|
8508
|
-
}
|
|
8509
|
-
|
|
8510
|
-
// ../workflow-files/src/representation/types.ts
|
|
8511
|
-
function normalizeNodeName(name) {
|
|
8512
|
-
let result = name.toLowerCase();
|
|
8513
|
-
result = result.replace(/[^a-z0-9]+/g, "_");
|
|
8514
|
-
result = result.replace(/^_+|_+$/g, "");
|
|
8515
|
-
if (result.length > 80) {
|
|
8516
|
-
result = result.slice(0, 80).replace(/_+$/, "");
|
|
8517
|
-
}
|
|
8518
|
-
if (result === "") {
|
|
8519
|
-
throw new Error(
|
|
8520
|
-
`representation: node name "${name}" produces an empty directory name after normalization`
|
|
8521
|
-
);
|
|
8522
|
-
}
|
|
8523
|
-
return result;
|
|
8524
|
-
}
|
|
8525
|
-
function lossySlugOr(name, fallback) {
|
|
8526
|
-
try {
|
|
8527
|
-
return normalizeNodeName(name);
|
|
8528
|
-
} catch {
|
|
8529
|
-
return fallback;
|
|
8530
|
-
}
|
|
8531
|
-
}
|
|
8532
|
-
function nodeDirName(name) {
|
|
8533
|
-
if (isNameCharsetConforming(name)) {
|
|
8534
|
-
return name.replaceAll(" ", "_");
|
|
8535
|
-
}
|
|
8536
|
-
return normalizeNodeName(name);
|
|
8537
|
-
}
|
|
8538
|
-
function agentDirName(name) {
|
|
8539
|
-
try {
|
|
8540
|
-
return nodeDirName(name);
|
|
8541
|
-
} catch {
|
|
8542
|
-
return "agent";
|
|
8543
|
-
}
|
|
8544
|
-
}
|
|
8545
|
-
function executionDirName(executionId2) {
|
|
8546
|
-
return executionId2.slice(0, 8);
|
|
8547
|
-
}
|
|
8548
|
-
function workflowDirName(workflowId, version, parentId, parentVersion) {
|
|
8549
|
-
const short = workflowId.slice(0, 8);
|
|
8550
|
-
if (version !== void 0 && version !== null) {
|
|
8551
|
-
return `v${version}_${short}`;
|
|
8552
|
-
}
|
|
8553
|
-
if (parentId) {
|
|
8554
|
-
if (parentVersion !== void 0 && parentVersion !== null) {
|
|
8555
|
-
return `draft_${short}_from_v${parentVersion}`;
|
|
8556
|
-
}
|
|
8557
|
-
return `draft_${short}_from_draft_${parentId.slice(0, 8)}`;
|
|
8558
|
-
}
|
|
8559
|
-
return `draft_${short}`;
|
|
8560
|
-
}
|
|
8561
|
-
|
|
8562
|
-
// src/sync/paths.ts
|
|
8563
|
-
import { createHash } from "node:crypto";
|
|
8564
|
-
function join3(...parts) {
|
|
8565
|
-
return parts.filter((part) => part !== "").join("/").replace(/\/{2,}/g, "/");
|
|
8566
|
-
}
|
|
8567
|
-
function workflowRoot(root, workflowName) {
|
|
8568
|
-
return join3(root, agentDirName(workflowName));
|
|
8569
|
-
}
|
|
8570
|
-
function isContained(path) {
|
|
8571
|
-
if (path === "" || path.startsWith("/") || path.includes("\\")) return false;
|
|
8572
|
-
return path.split("/").every((segment) => segment !== ".." && segment !== "");
|
|
8573
|
-
}
|
|
8574
|
-
function sha256(bytes) {
|
|
8575
|
-
return createHash("sha256").update(bytes).digest("hex");
|
|
8576
|
-
}
|
|
8577
|
-
function matchesGlob(path, pattern) {
|
|
8578
|
-
let source = "";
|
|
8579
|
-
for (let i = 0; i < pattern.length; i++) {
|
|
8580
|
-
const ch = pattern[i];
|
|
8581
|
-
if (ch === "*" && pattern[i + 1] === "*" && pattern[i + 2] === "/") {
|
|
8582
|
-
source += "(?:.*/)?";
|
|
8583
|
-
i += 2;
|
|
8584
|
-
} else if (ch === "*" && pattern[i + 1] === "*") {
|
|
8585
|
-
source += ".*";
|
|
8586
|
-
i += 1;
|
|
8587
|
-
} else if (ch === "*") source += "[^/]*";
|
|
8588
|
-
else if (ch === "?") source += "[^/]";
|
|
8589
|
-
else source += ch.replace(/[.+^${}()|[\]\\]/g, "\\$&");
|
|
8590
|
-
}
|
|
8591
|
-
return new RegExp(`^${source}$`).test(path);
|
|
8592
|
-
}
|
|
8593
|
-
|
|
8594
8966
|
// src/sync/execution-pull.ts
|
|
8595
8967
|
var DIRECTORIES = ["workspace", "downloads", "shared"];
|
|
8596
8968
|
function relativeFilePath(file) {
|
|
@@ -8873,7 +9245,7 @@ function formatInsightPull(result) {
|
|
|
8873
9245
|
|
|
8874
9246
|
// src/sync/node-files.ts
|
|
8875
9247
|
import { mkdir, readdir, readFile, rm, writeFile } from "node:fs/promises";
|
|
8876
|
-
import { dirname as
|
|
9248
|
+
import { dirname as dirname3, relative, resolve, sep } from "node:path";
|
|
8877
9249
|
function missing(error) {
|
|
8878
9250
|
return error.code === "ENOENT";
|
|
8879
9251
|
}
|
|
@@ -8897,7 +9269,7 @@ function nodeFiles(cwd) {
|
|
|
8897
9269
|
}
|
|
8898
9270
|
},
|
|
8899
9271
|
async write(path, bytes) {
|
|
8900
|
-
await mkdir(
|
|
9272
|
+
await mkdir(dirname3(at(path)), { recursive: true });
|
|
8901
9273
|
await writeFile(at(path), bytes);
|
|
8902
9274
|
},
|
|
8903
9275
|
async remove(path) {
|
|
@@ -8928,7 +9300,7 @@ async function writeManifest(sync, dir, manifest) {
|
|
|
8928
9300
|
}
|
|
8929
9301
|
|
|
8930
9302
|
// src/sync/workflow-pull.ts
|
|
8931
|
-
var
|
|
9303
|
+
var CONCURRENCY2 = 16;
|
|
8932
9304
|
function pullDir(root, tree, head) {
|
|
8933
9305
|
const base = workflowRoot(root, tree.workflowName);
|
|
8934
9306
|
if (head) return join3(base, "head");
|
|
@@ -8966,10 +9338,10 @@ function wantedEntries(options, tree, skipped) {
|
|
|
8966
9338
|
return false;
|
|
8967
9339
|
});
|
|
8968
9340
|
}
|
|
8969
|
-
async function
|
|
8970
|
-
for (let i = 0; i < items.length; i +=
|
|
9341
|
+
async function inBatches2(items, each) {
|
|
9342
|
+
for (let i = 0; i < items.length; i += CONCURRENCY2) {
|
|
8971
9343
|
const results = await Promise.allSettled(
|
|
8972
|
-
items.slice(i, i +
|
|
9344
|
+
items.slice(i, i + CONCURRENCY2).map(each)
|
|
8973
9345
|
);
|
|
8974
9346
|
const failed = results.find((r) => r.status === "rejected");
|
|
8975
9347
|
if (failed) throw failed.reason;
|
|
@@ -8980,7 +9352,7 @@ async function writeEntries(sync, options, tree, dir) {
|
|
|
8980
9352
|
const skipped = [];
|
|
8981
9353
|
let shared = 0;
|
|
8982
9354
|
let written = 0;
|
|
8983
|
-
await
|
|
9355
|
+
await inBatches2(wantedEntries(options, tree, skipped), async (entry) => {
|
|
8984
9356
|
const bytes = await entryBytes(sync, options.workflowId, tree, entry);
|
|
8985
9357
|
if (!bytes) return void skipped.push(`${entry.path} (no content)`);
|
|
8986
9358
|
await sync.files.write(join3(dir, entry.path), bytes);
|
|
@@ -9030,7 +9402,7 @@ async function mergeEntries(sync, options, tree, dir, previous) {
|
|
|
9030
9402
|
written: 0
|
|
9031
9403
|
};
|
|
9032
9404
|
const wanted = wantedEntries(options, tree, out.skipped);
|
|
9033
|
-
await
|
|
9405
|
+
await inBatches2(
|
|
9034
9406
|
wanted,
|
|
9035
9407
|
(entry) => mergeEntry(sync, options, tree, dir, previous, entry, out)
|
|
9036
9408
|
);
|
|
@@ -9440,7 +9812,9 @@ async function runBuiltin(name, parsed, deps) {
|
|
|
9440
9812
|
rejectOrgWithApiKey(deps, parsed.org);
|
|
9441
9813
|
switch (name) {
|
|
9442
9814
|
case "login":
|
|
9443
|
-
return login(deps
|
|
9815
|
+
return login(deps, {
|
|
9816
|
+
skills: parsed.flags.get("skills")?.[0] !== "false"
|
|
9817
|
+
});
|
|
9444
9818
|
case "logout":
|
|
9445
9819
|
return logout(deps);
|
|
9446
9820
|
case "orgs":
|
|
@@ -9454,6 +9828,10 @@ async function runBuiltin(name, parsed, deps) {
|
|
|
9454
9828
|
reason: parsed.flags.get("reason")?.[0],
|
|
9455
9829
|
exit: parsed.flags.has("exit")
|
|
9456
9830
|
});
|
|
9831
|
+
case "skill sync":
|
|
9832
|
+
return syncSkills(deps, parsed.org, {
|
|
9833
|
+
remove: parsed.flags.get("remove")?.[0] !== "false"
|
|
9834
|
+
});
|
|
9457
9835
|
default:
|
|
9458
9836
|
return whoami(deps, parsed.org, parsed.json);
|
|
9459
9837
|
}
|
|
@@ -9469,7 +9847,7 @@ async function credentialOrganization(deps, auth) {
|
|
|
9469
9847
|
);
|
|
9470
9848
|
return response.json?.organizationId;
|
|
9471
9849
|
}
|
|
9472
|
-
async function
|
|
9850
|
+
async function authFor2(parsed, deps) {
|
|
9473
9851
|
rejectOrgWithApiKey(deps, parsed.org);
|
|
9474
9852
|
const config = loadConfig(deps.env);
|
|
9475
9853
|
return resolveAuth(
|
|
@@ -9489,7 +9867,7 @@ function announce(command, auth, deps) {
|
|
|
9489
9867
|
async function runCommand(command, parsed, deps) {
|
|
9490
9868
|
const needsOrganization = command.body?.credentialOrganization === true;
|
|
9491
9869
|
let request = needsOrganization ? void 0 : await buildRequest(command, parsed);
|
|
9492
|
-
const auth = await
|
|
9870
|
+
const auth = await authFor2(parsed, deps);
|
|
9493
9871
|
request ??= await buildRequest(command, parsed, {
|
|
9494
9872
|
organizationId: await credentialOrganization(deps, auth)
|
|
9495
9873
|
});
|
|
@@ -9503,7 +9881,7 @@ async function runCommand(command, parsed, deps) {
|
|
|
9503
9881
|
);
|
|
9504
9882
|
if (response.bytes) {
|
|
9505
9883
|
if (parsed.output) {
|
|
9506
|
-
|
|
9884
|
+
writeFileSync3(parsed.output, response.bytes);
|
|
9507
9885
|
deps.stderr(
|
|
9508
9886
|
`Wrote ${response.bytes.length} bytes to ${parsed.output}.
|
|
9509
9887
|
`
|
|
@@ -9545,9 +9923,35 @@ function nodeRemote(apiUrl, auth, fetchImpl) {
|
|
|
9545
9923
|
};
|
|
9546
9924
|
}
|
|
9547
9925
|
var DESCRIPTION = "The Asteroid CLI. Sign in with `asteroid login`, or set ASTEROID_API_KEY.\nAt a terminal, tables show up to 6 columns and cut long cells to fit; when output is piped, they show every column in full. Use `--json` for every field.";
|
|
9926
|
+
var NO_NOTICE = /* @__PURE__ */ new Set(["login", "logout", "complete", "skill sync"]);
|
|
9927
|
+
function noticeApplies(invocation, deps) {
|
|
9928
|
+
if (!deps.ui || deps.env.apiKey || invocation.parsed.json) return false;
|
|
9929
|
+
return invocation.kind === "command" || !NO_NOTICE.has(invocation.name);
|
|
9930
|
+
}
|
|
9931
|
+
async function execute2(invocation, deps) {
|
|
9932
|
+
if (invocation.kind === "exit") {
|
|
9933
|
+
if (invocation.stdout) deps.stdout(invocation.stdout);
|
|
9934
|
+
if (invocation.stderr) deps.stderr(invocation.stderr);
|
|
9935
|
+
return invocation.code;
|
|
9936
|
+
}
|
|
9937
|
+
if (invocation.kind === "builtin") {
|
|
9938
|
+
return runBuiltin(invocation.name, invocation.parsed, deps);
|
|
9939
|
+
}
|
|
9940
|
+
if (runsLocally(invocation.command, invocation.parsed)) {
|
|
9941
|
+
const auth = await authFor2(invocation.parsed, deps);
|
|
9942
|
+
announce(invocation.command, auth, deps);
|
|
9943
|
+
return runSync(invocation.command, invocation.parsed, {
|
|
9944
|
+
...deps,
|
|
9945
|
+
remote: nodeRemote(deps.env.apiUrl, auth, deps.fetch)
|
|
9946
|
+
});
|
|
9947
|
+
}
|
|
9948
|
+
return runCommand(invocation.command, invocation.parsed, deps);
|
|
9949
|
+
}
|
|
9548
9950
|
async function run(argv2, deps) {
|
|
9951
|
+
let invocation;
|
|
9952
|
+
let code2;
|
|
9549
9953
|
try {
|
|
9550
|
-
|
|
9954
|
+
invocation = await parseInvocation(argv2, {
|
|
9551
9955
|
commands: ALL_COMMANDS,
|
|
9552
9956
|
builtins: BUILTINS,
|
|
9553
9957
|
version: VERSION,
|
|
@@ -9555,41 +9959,25 @@ async function run(argv2, deps) {
|
|
|
9555
9959
|
defaultArg: (command, arg) => command.files === "push" && arg.name === "workflowId" ? "" : void 0,
|
|
9556
9960
|
defaultArgNote: "<workflow-id> defaults to the workflow the pushed folder was pulled from."
|
|
9557
9961
|
});
|
|
9558
|
-
|
|
9559
|
-
if (invocation.stdout) deps.stdout(invocation.stdout);
|
|
9560
|
-
if (invocation.stderr) deps.stderr(invocation.stderr);
|
|
9561
|
-
return invocation.code;
|
|
9562
|
-
}
|
|
9563
|
-
if (invocation.kind === "builtin") {
|
|
9564
|
-
return await runBuiltin(invocation.name, invocation.parsed, deps);
|
|
9565
|
-
}
|
|
9566
|
-
if (runsLocally(invocation.command, invocation.parsed)) {
|
|
9567
|
-
const auth = await authFor(invocation.parsed, deps);
|
|
9568
|
-
announce(invocation.command, auth, deps);
|
|
9569
|
-
return await runSync(invocation.command, invocation.parsed, {
|
|
9570
|
-
...deps,
|
|
9571
|
-
remote: nodeRemote(deps.env.apiUrl, auth, deps.fetch)
|
|
9572
|
-
});
|
|
9573
|
-
}
|
|
9574
|
-
return await runCommand(invocation.command, invocation.parsed, deps);
|
|
9962
|
+
code2 = await execute2(invocation, deps);
|
|
9575
9963
|
} catch (error) {
|
|
9576
9964
|
if (error instanceof UsageError) {
|
|
9577
9965
|
deps.stderr(`asteroid: ${clean(error.message)}
|
|
9578
9966
|
`);
|
|
9579
|
-
|
|
9580
|
-
}
|
|
9581
|
-
if (error instanceof ApiError) {
|
|
9967
|
+
code2 = 2;
|
|
9968
|
+
} else if (error instanceof ApiError) {
|
|
9582
9969
|
deps.stderr(`asteroid: ${error.status}: ${clean(error.message)}
|
|
9583
9970
|
`);
|
|
9584
|
-
|
|
9585
|
-
}
|
|
9586
|
-
if (error instanceof AuthError || error instanceof WorkosError) {
|
|
9971
|
+
code2 = 1;
|
|
9972
|
+
} else if (error instanceof AuthError || error instanceof WorkosError) {
|
|
9587
9973
|
deps.stderr(`asteroid: ${clean(error.message)}
|
|
9588
9974
|
`);
|
|
9589
|
-
|
|
9590
|
-
}
|
|
9591
|
-
throw error;
|
|
9975
|
+
code2 = 1;
|
|
9976
|
+
} else throw error;
|
|
9592
9977
|
}
|
|
9978
|
+
if (invocation && invocation.kind !== "exit" && noticeApplies(invocation, deps))
|
|
9979
|
+
await skillsNotice(deps, invocation.parsed.org);
|
|
9980
|
+
return code2;
|
|
9593
9981
|
}
|
|
9594
9982
|
|
|
9595
9983
|
// src/ui.ts
|
|
@@ -9603,6 +9991,10 @@ var clackUi = {
|
|
|
9603
9991
|
const value2 = await clack.text({ message });
|
|
9604
9992
|
return clack.isCancel(value2) ? void 0 : value2;
|
|
9605
9993
|
},
|
|
9994
|
+
async confirm(message, initial) {
|
|
9995
|
+
const value2 = await clack.confirm({ message, initialValue: initial });
|
|
9996
|
+
return clack.isCancel(value2) ? void 0 : value2;
|
|
9997
|
+
},
|
|
9606
9998
|
async wait(message, done, work) {
|
|
9607
9999
|
const spinner2 = clack.spinner();
|
|
9608
10000
|
spinner2.start(message);
|
package/dist/core.js
CHANGED
|
@@ -6689,8 +6689,9 @@ var BUILTINS = [
|
|
|
6689
6689
|
{
|
|
6690
6690
|
command: "login",
|
|
6691
6691
|
usage: "asteroid login",
|
|
6692
|
-
description: "Sign in with your browser. Stores a refresh token in the OS keychain, or in a private file in the config directory when no keychain is available.",
|
|
6693
|
-
args: 0
|
|
6692
|
+
description: "Sign in with your browser. Stores a refresh token in the OS keychain, or in a private file in the config directory when no keychain is available. Then offers to install the Asteroid skills into every skills directory it finds: `~/.claude/skills` (Claude Code), `~/.cursor/skills` (Cursor) and `~/.agents/skills`.",
|
|
6693
|
+
args: 0,
|
|
6694
|
+
options: [["--no-skills", "Do not offer to install the Asteroid skills."]]
|
|
6694
6695
|
},
|
|
6695
6696
|
{
|
|
6696
6697
|
command: "logout",
|
|
@@ -6733,6 +6734,16 @@ var BUILTINS = [
|
|
|
6733
6734
|
usage: "asteroid whoami",
|
|
6734
6735
|
description: "Show who you act as, in which organization, and how long the token lasts.",
|
|
6735
6736
|
args: 0
|
|
6737
|
+
},
|
|
6738
|
+
{
|
|
6739
|
+
command: "skill sync",
|
|
6740
|
+
usage: "asteroid skill sync",
|
|
6741
|
+
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.",
|
|
6742
|
+
args: 0,
|
|
6743
|
+
options: [
|
|
6744
|
+
["--no-remove", "Keep the skills and files the API no longer serves."]
|
|
6745
|
+
],
|
|
6746
|
+
section: "Skills"
|
|
6736
6747
|
}
|
|
6737
6748
|
];
|
|
6738
6749
|
var BUILTIN_COMMANDS = new Set(BUILTINS.map((b) => b.command));
|
|
@@ -6876,9 +6887,16 @@ function defineCommands(root, options, dotted2 = /* @__PURE__ */ new Map(), onIn
|
|
|
6876
6887
|
for (const [flags, text2] of GLOBAL_FLAGS) {
|
|
6877
6888
|
if (!flags.startsWith("-h")) root.option(flags, text2);
|
|
6878
6889
|
}
|
|
6890
|
+
const groups = /* @__PURE__ */ new Map();
|
|
6879
6891
|
for (const builtin of options.builtins ?? []) {
|
|
6880
|
-
const
|
|
6892
|
+
const words = builtin.command.split(" ");
|
|
6893
|
+
let parent = root;
|
|
6894
|
+
for (let i = 0; i < words.length - 1; i++) {
|
|
6895
|
+
parent = group(parent, words[i], groups, words.slice(0, i + 1).join(" "));
|
|
6896
|
+
}
|
|
6897
|
+
const leaf = parent.command(words.at(-1)).description(builtin.description);
|
|
6881
6898
|
if (builtin.arg) leaf.argument(`[${builtin.arg}]`);
|
|
6899
|
+
for (const [flags, text2] of builtin.options ?? []) leaf.option(flags, text2);
|
|
6882
6900
|
for (const [flags, text2] of builtin.hiddenOptions ?? [])
|
|
6883
6901
|
leaf.addOption(new Flag(flags, text2).hideHelp());
|
|
6884
6902
|
leaf.action((...args) => {
|
|
@@ -6891,7 +6909,6 @@ function defineCommands(root, options, dotted2 = /* @__PURE__ */ new Map(), onIn
|
|
|
6891
6909
|
});
|
|
6892
6910
|
}
|
|
6893
6911
|
const reserved = new Set((options.builtins ?? []).map((b) => b.command));
|
|
6894
|
-
const groups = /* @__PURE__ */ new Map();
|
|
6895
6912
|
for (const command of options.commands) {
|
|
6896
6913
|
if (reserved.has(command.command)) continue;
|
|
6897
6914
|
const words = command.command.split(" ");
|