@asteroidai/cli 1.9.167 → 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 +573 -159
- package/dist/core.js +57 -18
- package/package.json +1 -1
package/dist/asteroid.js
CHANGED
|
@@ -387,7 +387,7 @@ var COMMANDS = [
|
|
|
387
387
|
command: "catalog template get",
|
|
388
388
|
tool: "catalog_template_get",
|
|
389
389
|
title: "Get catalog template",
|
|
390
|
-
description: "One catalog template, with `runnable`, its `inputs`, the portal's credential fields and the organization's `accessLevel`. `organizationId` defaults to the caller's one organization.",
|
|
390
|
+
description: "One catalog template, with `runnable`, its `inputs`, the portal's credential fields and the organization's `accessLevel`. Set `includeWorkflowDefinition` to also get the template's rules, nodes and transitions as a read-only reference when building or editing a workflow; on an organization-scoped read it needs `accessLevel` `granted`. To get an editable copy, use `catalog_template_instantiate`. `organizationId` defaults to the caller's one organization.",
|
|
391
391
|
method: "GET",
|
|
392
392
|
path: "/agents/v2/catalog/templates/{templateId}",
|
|
393
393
|
args: [
|
|
@@ -398,7 +398,15 @@ var COMMANDS = [
|
|
|
398
398
|
required: true
|
|
399
399
|
}
|
|
400
400
|
],
|
|
401
|
-
query: [
|
|
401
|
+
query: [
|
|
402
|
+
{
|
|
403
|
+
name: "includeWorkflowDefinition",
|
|
404
|
+
flag: "include-workflow-definition",
|
|
405
|
+
type: "boolean",
|
|
406
|
+
required: false,
|
|
407
|
+
description: "Also return `workflowDefinition`: the rules, nodes and transitions of the source agent's latest published workflow. On an organization-scoped read it needs `granted` access; a `viewable` template returns 403."
|
|
408
|
+
}
|
|
409
|
+
],
|
|
402
410
|
binary: false,
|
|
403
411
|
readOnly: true,
|
|
404
412
|
destructive: false
|
|
@@ -713,14 +721,14 @@ var COMMANDS = [
|
|
|
713
721
|
flag: "dedicated",
|
|
714
722
|
type: "json",
|
|
715
723
|
required: false,
|
|
716
|
-
description: "Admin only, and returned to admins only. Dedicated
|
|
724
|
+
description: "Admin only, and returned to admins only. Dedicated workers and environments. Absent means no workers are kept. Exclusive with warmPool and warmCache.",
|
|
717
725
|
fields: [
|
|
718
726
|
{
|
|
719
727
|
name: "targetSize",
|
|
720
728
|
flag: "target-size",
|
|
721
729
|
type: "integer",
|
|
722
730
|
required: false,
|
|
723
|
-
description: "Baseline number of
|
|
731
|
+
description: "Baseline number of environments to keep ready outside any scheduled window. 0 drains the custom environment."
|
|
724
732
|
},
|
|
725
733
|
{
|
|
726
734
|
name: "schedule",
|
|
@@ -752,18 +760,25 @@ var COMMANDS = [
|
|
|
752
760
|
description: "Member max age in minutes. As for a warm pool, the replacement boots ahead of it."
|
|
753
761
|
},
|
|
754
762
|
{
|
|
755
|
-
name: "
|
|
756
|
-
flag: "executions-per-
|
|
763
|
+
name: "executionsPerEnvironment",
|
|
764
|
+
flag: "executions-per-environment",
|
|
765
|
+
type: "integer",
|
|
766
|
+
required: false,
|
|
767
|
+
description: "Executions one environment runs at once. On a browser base they share its active tab"
|
|
768
|
+
},
|
|
769
|
+
{
|
|
770
|
+
name: "workers",
|
|
771
|
+
flag: "workers",
|
|
757
772
|
type: "integer",
|
|
758
773
|
required: false,
|
|
759
|
-
description: "
|
|
774
|
+
description: "Workers the environment keeps, 1 to 8. Each drives every member environment and takes any execution; add more for volume. Absent means one per member profile"
|
|
760
775
|
},
|
|
761
776
|
{
|
|
762
777
|
name: "initialization",
|
|
763
778
|
flag: "initialization",
|
|
764
779
|
type: "json",
|
|
765
780
|
required: false,
|
|
766
|
-
description: "Workflow that initialises each member before
|
|
781
|
+
description: "Workflow that initialises each member before a worker drives it, such as a sign-in. Absent means a worker drives it as soon as the environment has booted.",
|
|
767
782
|
fields: [
|
|
768
783
|
{
|
|
769
784
|
name: "workflowId",
|
|
@@ -1123,14 +1138,14 @@ var COMMANDS = [
|
|
|
1123
1138
|
flag: "dedicated",
|
|
1124
1139
|
type: "json",
|
|
1125
1140
|
required: false,
|
|
1126
|
-
description: "Admin only, and returned to admins only. Dedicated
|
|
1141
|
+
description: "Admin only, and returned to admins only. Dedicated workers and environments. Absent means no workers are kept. Exclusive with warmPool and warmCache.",
|
|
1127
1142
|
fields: [
|
|
1128
1143
|
{
|
|
1129
1144
|
name: "targetSize",
|
|
1130
1145
|
flag: "target-size",
|
|
1131
1146
|
type: "integer",
|
|
1132
1147
|
required: false,
|
|
1133
|
-
description: "Baseline number of
|
|
1148
|
+
description: "Baseline number of environments to keep ready outside any scheduled window. 0 drains the custom environment."
|
|
1134
1149
|
},
|
|
1135
1150
|
{
|
|
1136
1151
|
name: "schedule",
|
|
@@ -1162,18 +1177,25 @@ var COMMANDS = [
|
|
|
1162
1177
|
description: "Member max age in minutes. As for a warm pool, the replacement boots ahead of it."
|
|
1163
1178
|
},
|
|
1164
1179
|
{
|
|
1165
|
-
name: "
|
|
1166
|
-
flag: "executions-per-
|
|
1180
|
+
name: "executionsPerEnvironment",
|
|
1181
|
+
flag: "executions-per-environment",
|
|
1167
1182
|
type: "integer",
|
|
1168
1183
|
required: false,
|
|
1169
|
-
description: "Executions one
|
|
1184
|
+
description: "Executions one environment runs at once. On a browser base they share its active tab"
|
|
1185
|
+
},
|
|
1186
|
+
{
|
|
1187
|
+
name: "workers",
|
|
1188
|
+
flag: "workers",
|
|
1189
|
+
type: "integer",
|
|
1190
|
+
required: false,
|
|
1191
|
+
description: "Workers the environment keeps, 1 to 8. Each drives every member environment and takes any execution; add more for volume. Absent means one per member profile"
|
|
1170
1192
|
},
|
|
1171
1193
|
{
|
|
1172
1194
|
name: "initialization",
|
|
1173
1195
|
flag: "initialization",
|
|
1174
1196
|
type: "json",
|
|
1175
1197
|
required: false,
|
|
1176
|
-
description: "Workflow that initialises each member before
|
|
1198
|
+
description: "Workflow that initialises each member before a worker drives it, such as a sign-in. Absent means a worker drives it as soon as the environment has booted.",
|
|
1177
1199
|
fields: [
|
|
1178
1200
|
{
|
|
1179
1201
|
name: "workflowId",
|
|
@@ -6701,6 +6723,7 @@ import {
|
|
|
6701
6723
|
renameSync,
|
|
6702
6724
|
writeFileSync
|
|
6703
6725
|
} from "node:fs";
|
|
6726
|
+
import { homedir } from "node:os";
|
|
6704
6727
|
import { dirname, join } from "node:path";
|
|
6705
6728
|
|
|
6706
6729
|
// src/output.ts
|
|
@@ -6850,7 +6873,8 @@ function readEnv(env = process.env) {
|
|
|
6850
6873
|
org: env.ASTEROID_ORG || void 0,
|
|
6851
6874
|
workosClientId: env.ASTEROID_WORKOS_CLIENT_ID || DEFAULT_WORKOS_CLIENT_ID,
|
|
6852
6875
|
workosApiUrl: (env.ASTEROID_WORKOS_API_URL || DEFAULT_WORKOS_API_URL).replace(/\/+$/, ""),
|
|
6853
|
-
configDir: env.ASTEROID_CONFIG_DIR || envPaths("asteroid", { suffix: "" }).config
|
|
6876
|
+
configDir: env.ASTEROID_CONFIG_DIR || envPaths("asteroid", { suffix: "" }).config,
|
|
6877
|
+
home: env.HOME || homedir()
|
|
6854
6878
|
};
|
|
6855
6879
|
}
|
|
6856
6880
|
function readJson(path, fallback) {
|
|
@@ -6923,8 +6947,9 @@ var BUILTINS = [
|
|
|
6923
6947
|
{
|
|
6924
6948
|
command: "login",
|
|
6925
6949
|
usage: "asteroid login",
|
|
6926
|
-
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.",
|
|
6927
|
-
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."]]
|
|
6928
6953
|
},
|
|
6929
6954
|
{
|
|
6930
6955
|
command: "logout",
|
|
@@ -6967,6 +6992,16 @@ var BUILTINS = [
|
|
|
6967
6992
|
usage: "asteroid whoami",
|
|
6968
6993
|
description: "Show who you act as, in which organization, and how long the token lasts.",
|
|
6969
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"
|
|
6970
7005
|
}
|
|
6971
7006
|
];
|
|
6972
7007
|
var BUILTIN_COMMANDS = new Set(BUILTINS.map((b) => b.command));
|
|
@@ -7110,9 +7145,16 @@ function defineCommands(root, options, dotted2 = /* @__PURE__ */ new Map(), onIn
|
|
|
7110
7145
|
for (const [flags, text3] of GLOBAL_FLAGS) {
|
|
7111
7146
|
if (!flags.startsWith("-h")) root.option(flags, text3);
|
|
7112
7147
|
}
|
|
7148
|
+
const groups = /* @__PURE__ */ new Map();
|
|
7113
7149
|
for (const builtin of options.builtins ?? []) {
|
|
7114
|
-
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);
|
|
7115
7156
|
if (builtin.arg) leaf.argument(`[${builtin.arg}]`);
|
|
7157
|
+
for (const [flags, text3] of builtin.options ?? []) leaf.option(flags, text3);
|
|
7116
7158
|
for (const [flags, text3] of builtin.hiddenOptions ?? [])
|
|
7117
7159
|
leaf.addOption(new Flag(flags, text3).hideHelp());
|
|
7118
7160
|
leaf.action((...args) => {
|
|
@@ -7125,7 +7167,6 @@ function defineCommands(root, options, dotted2 = /* @__PURE__ */ new Map(), onIn
|
|
|
7125
7167
|
});
|
|
7126
7168
|
}
|
|
7127
7169
|
const reserved = new Set((options.builtins ?? []).map((b) => b.command));
|
|
7128
|
-
const groups = /* @__PURE__ */ new Map();
|
|
7129
7170
|
for (const command of options.commands) {
|
|
7130
7171
|
if (reserved.has(command.command)) continue;
|
|
7131
7172
|
const words = command.command.split(" ");
|
|
@@ -7241,7 +7282,7 @@ async function runCompletion(argv2, options) {
|
|
|
7241
7282
|
}
|
|
7242
7283
|
|
|
7243
7284
|
// src/run.ts
|
|
7244
|
-
import { writeFileSync as
|
|
7285
|
+
import { writeFileSync as writeFileSync3 } from "node:fs";
|
|
7245
7286
|
|
|
7246
7287
|
// src/auth/store.ts
|
|
7247
7288
|
import { mkdirSync as mkdirSync2, rmSync } from "node:fs";
|
|
@@ -7688,7 +7729,7 @@ var ApiError = class extends Error {
|
|
|
7688
7729
|
status;
|
|
7689
7730
|
body;
|
|
7690
7731
|
};
|
|
7691
|
-
var VERSION = "1.9.
|
|
7732
|
+
var VERSION = "1.9.182";
|
|
7692
7733
|
function problem(status, body, fallback) {
|
|
7693
7734
|
if (body && typeof body === "object") {
|
|
7694
7735
|
const record2 = body;
|
|
@@ -7774,6 +7815,456 @@ async function send(apiUrl, auth, request, binary, fetchImpl = fetch) {
|
|
|
7774
7815
|
return { status: response.status, text: await response.text() };
|
|
7775
7816
|
}
|
|
7776
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
|
+
|
|
7777
8268
|
// src/account.ts
|
|
7778
8269
|
async function chooseOrg(deps, orgs2) {
|
|
7779
8270
|
if (orgs2.length === 0)
|
|
@@ -7787,7 +8278,7 @@ async function chooseOrg(deps, orgs2) {
|
|
|
7787
8278
|
if (!chosen) throw new AuthError("sign-in cancelled");
|
|
7788
8279
|
return chosen;
|
|
7789
8280
|
}
|
|
7790
|
-
async function login(deps) {
|
|
8281
|
+
async function login(deps, options = {}) {
|
|
7791
8282
|
if (deps.env.apiKey)
|
|
7792
8283
|
deps.stderr(
|
|
7793
8284
|
`Warning: ${API_KEY_OVERRIDES} Every command will use the key, not this sign-in. ${UNSET_API_KEY}
|
|
@@ -7840,6 +8331,7 @@ and confirm the code ${clean(device.user_code)}
|
|
|
7840
8331
|
`Signed in as ${clean(session2.email ?? "you")}${config.org ? ` in ${orgLabel(config.org)}` : ""}. Token saved to the ${where === "keychain" ? "OS keychain" : "config directory"}.
|
|
7841
8332
|
`
|
|
7842
8333
|
);
|
|
8334
|
+
if (options.skills !== false) await offerSkills(deps);
|
|
7843
8335
|
return 0;
|
|
7844
8336
|
}
|
|
7845
8337
|
async function logout(deps) {
|
|
@@ -8471,104 +8963,6 @@ function formatActivitiesMarkdown(activities, status, createdAt) {
|
|
|
8471
8963
|
return lines.join("\n");
|
|
8472
8964
|
}
|
|
8473
8965
|
|
|
8474
|
-
// ../workflow-files/src/representation/name-charset.ts
|
|
8475
|
-
var NAME_CHARSET_RE = /^[A-Za-z0-9 !#$%&'()+,.;=@^`{}[\]~-]+$/;
|
|
8476
|
-
var WINDOWS_RESERVED = /* @__PURE__ */ new Set([
|
|
8477
|
-
"con",
|
|
8478
|
-
"prn",
|
|
8479
|
-
"aux",
|
|
8480
|
-
"nul",
|
|
8481
|
-
...Array.from({ length: 9 }, (_, i) => `com${i + 1}`),
|
|
8482
|
-
...Array.from({ length: 9 }, (_, i) => `lpt${i + 1}`)
|
|
8483
|
-
]);
|
|
8484
|
-
function isNameCharsetConforming(name) {
|
|
8485
|
-
return NAME_CHARSET_RE.test(name);
|
|
8486
|
-
}
|
|
8487
|
-
|
|
8488
|
-
// ../workflow-files/src/representation/types.ts
|
|
8489
|
-
function normalizeNodeName(name) {
|
|
8490
|
-
let result = name.toLowerCase();
|
|
8491
|
-
result = result.replace(/[^a-z0-9]+/g, "_");
|
|
8492
|
-
result = result.replace(/^_+|_+$/g, "");
|
|
8493
|
-
if (result.length > 80) {
|
|
8494
|
-
result = result.slice(0, 80).replace(/_+$/, "");
|
|
8495
|
-
}
|
|
8496
|
-
if (result === "") {
|
|
8497
|
-
throw new Error(
|
|
8498
|
-
`representation: node name "${name}" produces an empty directory name after normalization`
|
|
8499
|
-
);
|
|
8500
|
-
}
|
|
8501
|
-
return result;
|
|
8502
|
-
}
|
|
8503
|
-
function lossySlugOr(name, fallback) {
|
|
8504
|
-
try {
|
|
8505
|
-
return normalizeNodeName(name);
|
|
8506
|
-
} catch {
|
|
8507
|
-
return fallback;
|
|
8508
|
-
}
|
|
8509
|
-
}
|
|
8510
|
-
function nodeDirName(name) {
|
|
8511
|
-
if (isNameCharsetConforming(name)) {
|
|
8512
|
-
return name.replaceAll(" ", "_");
|
|
8513
|
-
}
|
|
8514
|
-
return normalizeNodeName(name);
|
|
8515
|
-
}
|
|
8516
|
-
function agentDirName(name) {
|
|
8517
|
-
try {
|
|
8518
|
-
return nodeDirName(name);
|
|
8519
|
-
} catch {
|
|
8520
|
-
return "agent";
|
|
8521
|
-
}
|
|
8522
|
-
}
|
|
8523
|
-
function executionDirName(executionId2) {
|
|
8524
|
-
return executionId2.slice(0, 8);
|
|
8525
|
-
}
|
|
8526
|
-
function workflowDirName(workflowId, version, parentId, parentVersion) {
|
|
8527
|
-
const short = workflowId.slice(0, 8);
|
|
8528
|
-
if (version !== void 0 && version !== null) {
|
|
8529
|
-
return `v${version}_${short}`;
|
|
8530
|
-
}
|
|
8531
|
-
if (parentId) {
|
|
8532
|
-
if (parentVersion !== void 0 && parentVersion !== null) {
|
|
8533
|
-
return `draft_${short}_from_v${parentVersion}`;
|
|
8534
|
-
}
|
|
8535
|
-
return `draft_${short}_from_draft_${parentId.slice(0, 8)}`;
|
|
8536
|
-
}
|
|
8537
|
-
return `draft_${short}`;
|
|
8538
|
-
}
|
|
8539
|
-
|
|
8540
|
-
// src/sync/paths.ts
|
|
8541
|
-
import { createHash } from "node:crypto";
|
|
8542
|
-
function join3(...parts) {
|
|
8543
|
-
return parts.filter((part) => part !== "").join("/").replace(/\/{2,}/g, "/");
|
|
8544
|
-
}
|
|
8545
|
-
function workflowRoot(root, workflowName) {
|
|
8546
|
-
return join3(root, agentDirName(workflowName));
|
|
8547
|
-
}
|
|
8548
|
-
function isContained(path) {
|
|
8549
|
-
if (path === "" || path.startsWith("/") || path.includes("\\")) return false;
|
|
8550
|
-
return path.split("/").every((segment) => segment !== ".." && segment !== "");
|
|
8551
|
-
}
|
|
8552
|
-
function sha256(bytes) {
|
|
8553
|
-
return createHash("sha256").update(bytes).digest("hex");
|
|
8554
|
-
}
|
|
8555
|
-
function matchesGlob(path, pattern) {
|
|
8556
|
-
let source = "";
|
|
8557
|
-
for (let i = 0; i < pattern.length; i++) {
|
|
8558
|
-
const ch = pattern[i];
|
|
8559
|
-
if (ch === "*" && pattern[i + 1] === "*" && pattern[i + 2] === "/") {
|
|
8560
|
-
source += "(?:.*/)?";
|
|
8561
|
-
i += 2;
|
|
8562
|
-
} else if (ch === "*" && pattern[i + 1] === "*") {
|
|
8563
|
-
source += ".*";
|
|
8564
|
-
i += 1;
|
|
8565
|
-
} else if (ch === "*") source += "[^/]*";
|
|
8566
|
-
else if (ch === "?") source += "[^/]";
|
|
8567
|
-
else source += ch.replace(/[.+^${}()|[\]\\]/g, "\\$&");
|
|
8568
|
-
}
|
|
8569
|
-
return new RegExp(`^${source}$`).test(path);
|
|
8570
|
-
}
|
|
8571
|
-
|
|
8572
8966
|
// src/sync/execution-pull.ts
|
|
8573
8967
|
var DIRECTORIES = ["workspace", "downloads", "shared"];
|
|
8574
8968
|
function relativeFilePath(file) {
|
|
@@ -8851,7 +9245,7 @@ function formatInsightPull(result) {
|
|
|
8851
9245
|
|
|
8852
9246
|
// src/sync/node-files.ts
|
|
8853
9247
|
import { mkdir, readdir, readFile, rm, writeFile } from "node:fs/promises";
|
|
8854
|
-
import { dirname as
|
|
9248
|
+
import { dirname as dirname3, relative, resolve, sep } from "node:path";
|
|
8855
9249
|
function missing(error) {
|
|
8856
9250
|
return error.code === "ENOENT";
|
|
8857
9251
|
}
|
|
@@ -8875,7 +9269,7 @@ function nodeFiles(cwd) {
|
|
|
8875
9269
|
}
|
|
8876
9270
|
},
|
|
8877
9271
|
async write(path, bytes) {
|
|
8878
|
-
await mkdir(
|
|
9272
|
+
await mkdir(dirname3(at(path)), { recursive: true });
|
|
8879
9273
|
await writeFile(at(path), bytes);
|
|
8880
9274
|
},
|
|
8881
9275
|
async remove(path) {
|
|
@@ -8906,7 +9300,7 @@ async function writeManifest(sync, dir, manifest) {
|
|
|
8906
9300
|
}
|
|
8907
9301
|
|
|
8908
9302
|
// src/sync/workflow-pull.ts
|
|
8909
|
-
var
|
|
9303
|
+
var CONCURRENCY2 = 16;
|
|
8910
9304
|
function pullDir(root, tree, head) {
|
|
8911
9305
|
const base = workflowRoot(root, tree.workflowName);
|
|
8912
9306
|
if (head) return join3(base, "head");
|
|
@@ -8944,10 +9338,10 @@ function wantedEntries(options, tree, skipped) {
|
|
|
8944
9338
|
return false;
|
|
8945
9339
|
});
|
|
8946
9340
|
}
|
|
8947
|
-
async function
|
|
8948
|
-
for (let i = 0; i < items.length; i +=
|
|
9341
|
+
async function inBatches2(items, each) {
|
|
9342
|
+
for (let i = 0; i < items.length; i += CONCURRENCY2) {
|
|
8949
9343
|
const results = await Promise.allSettled(
|
|
8950
|
-
items.slice(i, i +
|
|
9344
|
+
items.slice(i, i + CONCURRENCY2).map(each)
|
|
8951
9345
|
);
|
|
8952
9346
|
const failed = results.find((r) => r.status === "rejected");
|
|
8953
9347
|
if (failed) throw failed.reason;
|
|
@@ -8958,7 +9352,7 @@ async function writeEntries(sync, options, tree, dir) {
|
|
|
8958
9352
|
const skipped = [];
|
|
8959
9353
|
let shared = 0;
|
|
8960
9354
|
let written = 0;
|
|
8961
|
-
await
|
|
9355
|
+
await inBatches2(wantedEntries(options, tree, skipped), async (entry) => {
|
|
8962
9356
|
const bytes = await entryBytes(sync, options.workflowId, tree, entry);
|
|
8963
9357
|
if (!bytes) return void skipped.push(`${entry.path} (no content)`);
|
|
8964
9358
|
await sync.files.write(join3(dir, entry.path), bytes);
|
|
@@ -9008,7 +9402,7 @@ async function mergeEntries(sync, options, tree, dir, previous) {
|
|
|
9008
9402
|
written: 0
|
|
9009
9403
|
};
|
|
9010
9404
|
const wanted = wantedEntries(options, tree, out.skipped);
|
|
9011
|
-
await
|
|
9405
|
+
await inBatches2(
|
|
9012
9406
|
wanted,
|
|
9013
9407
|
(entry) => mergeEntry(sync, options, tree, dir, previous, entry, out)
|
|
9014
9408
|
);
|
|
@@ -9418,7 +9812,9 @@ async function runBuiltin(name, parsed, deps) {
|
|
|
9418
9812
|
rejectOrgWithApiKey(deps, parsed.org);
|
|
9419
9813
|
switch (name) {
|
|
9420
9814
|
case "login":
|
|
9421
|
-
return login(deps
|
|
9815
|
+
return login(deps, {
|
|
9816
|
+
skills: parsed.flags.get("skills")?.[0] !== "false"
|
|
9817
|
+
});
|
|
9422
9818
|
case "logout":
|
|
9423
9819
|
return logout(deps);
|
|
9424
9820
|
case "orgs":
|
|
@@ -9432,6 +9828,10 @@ async function runBuiltin(name, parsed, deps) {
|
|
|
9432
9828
|
reason: parsed.flags.get("reason")?.[0],
|
|
9433
9829
|
exit: parsed.flags.has("exit")
|
|
9434
9830
|
});
|
|
9831
|
+
case "skill sync":
|
|
9832
|
+
return syncSkills(deps, parsed.org, {
|
|
9833
|
+
remove: parsed.flags.get("remove")?.[0] !== "false"
|
|
9834
|
+
});
|
|
9435
9835
|
default:
|
|
9436
9836
|
return whoami(deps, parsed.org, parsed.json);
|
|
9437
9837
|
}
|
|
@@ -9447,7 +9847,7 @@ async function credentialOrganization(deps, auth) {
|
|
|
9447
9847
|
);
|
|
9448
9848
|
return response.json?.organizationId;
|
|
9449
9849
|
}
|
|
9450
|
-
async function
|
|
9850
|
+
async function authFor2(parsed, deps) {
|
|
9451
9851
|
rejectOrgWithApiKey(deps, parsed.org);
|
|
9452
9852
|
const config = loadConfig(deps.env);
|
|
9453
9853
|
return resolveAuth(
|
|
@@ -9467,7 +9867,7 @@ function announce(command, auth, deps) {
|
|
|
9467
9867
|
async function runCommand(command, parsed, deps) {
|
|
9468
9868
|
const needsOrganization = command.body?.credentialOrganization === true;
|
|
9469
9869
|
let request = needsOrganization ? void 0 : await buildRequest(command, parsed);
|
|
9470
|
-
const auth = await
|
|
9870
|
+
const auth = await authFor2(parsed, deps);
|
|
9471
9871
|
request ??= await buildRequest(command, parsed, {
|
|
9472
9872
|
organizationId: await credentialOrganization(deps, auth)
|
|
9473
9873
|
});
|
|
@@ -9481,7 +9881,7 @@ async function runCommand(command, parsed, deps) {
|
|
|
9481
9881
|
);
|
|
9482
9882
|
if (response.bytes) {
|
|
9483
9883
|
if (parsed.output) {
|
|
9484
|
-
|
|
9884
|
+
writeFileSync3(parsed.output, response.bytes);
|
|
9485
9885
|
deps.stderr(
|
|
9486
9886
|
`Wrote ${response.bytes.length} bytes to ${parsed.output}.
|
|
9487
9887
|
`
|
|
@@ -9523,9 +9923,35 @@ function nodeRemote(apiUrl, auth, fetchImpl) {
|
|
|
9523
9923
|
};
|
|
9524
9924
|
}
|
|
9525
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
|
+
}
|
|
9526
9950
|
async function run(argv2, deps) {
|
|
9951
|
+
let invocation;
|
|
9952
|
+
let code2;
|
|
9527
9953
|
try {
|
|
9528
|
-
|
|
9954
|
+
invocation = await parseInvocation(argv2, {
|
|
9529
9955
|
commands: ALL_COMMANDS,
|
|
9530
9956
|
builtins: BUILTINS,
|
|
9531
9957
|
version: VERSION,
|
|
@@ -9533,41 +9959,25 @@ async function run(argv2, deps) {
|
|
|
9533
9959
|
defaultArg: (command, arg) => command.files === "push" && arg.name === "workflowId" ? "" : void 0,
|
|
9534
9960
|
defaultArgNote: "<workflow-id> defaults to the workflow the pushed folder was pulled from."
|
|
9535
9961
|
});
|
|
9536
|
-
|
|
9537
|
-
if (invocation.stdout) deps.stdout(invocation.stdout);
|
|
9538
|
-
if (invocation.stderr) deps.stderr(invocation.stderr);
|
|
9539
|
-
return invocation.code;
|
|
9540
|
-
}
|
|
9541
|
-
if (invocation.kind === "builtin") {
|
|
9542
|
-
return await runBuiltin(invocation.name, invocation.parsed, deps);
|
|
9543
|
-
}
|
|
9544
|
-
if (runsLocally(invocation.command, invocation.parsed)) {
|
|
9545
|
-
const auth = await authFor(invocation.parsed, deps);
|
|
9546
|
-
announce(invocation.command, auth, deps);
|
|
9547
|
-
return await runSync(invocation.command, invocation.parsed, {
|
|
9548
|
-
...deps,
|
|
9549
|
-
remote: nodeRemote(deps.env.apiUrl, auth, deps.fetch)
|
|
9550
|
-
});
|
|
9551
|
-
}
|
|
9552
|
-
return await runCommand(invocation.command, invocation.parsed, deps);
|
|
9962
|
+
code2 = await execute2(invocation, deps);
|
|
9553
9963
|
} catch (error) {
|
|
9554
9964
|
if (error instanceof UsageError) {
|
|
9555
9965
|
deps.stderr(`asteroid: ${clean(error.message)}
|
|
9556
9966
|
`);
|
|
9557
|
-
|
|
9558
|
-
}
|
|
9559
|
-
if (error instanceof ApiError) {
|
|
9967
|
+
code2 = 2;
|
|
9968
|
+
} else if (error instanceof ApiError) {
|
|
9560
9969
|
deps.stderr(`asteroid: ${error.status}: ${clean(error.message)}
|
|
9561
9970
|
`);
|
|
9562
|
-
|
|
9563
|
-
}
|
|
9564
|
-
if (error instanceof AuthError || error instanceof WorkosError) {
|
|
9971
|
+
code2 = 1;
|
|
9972
|
+
} else if (error instanceof AuthError || error instanceof WorkosError) {
|
|
9565
9973
|
deps.stderr(`asteroid: ${clean(error.message)}
|
|
9566
9974
|
`);
|
|
9567
|
-
|
|
9568
|
-
}
|
|
9569
|
-
throw error;
|
|
9975
|
+
code2 = 1;
|
|
9976
|
+
} else throw error;
|
|
9570
9977
|
}
|
|
9978
|
+
if (invocation && invocation.kind !== "exit" && noticeApplies(invocation, deps))
|
|
9979
|
+
await skillsNotice(deps, invocation.parsed.org);
|
|
9980
|
+
return code2;
|
|
9571
9981
|
}
|
|
9572
9982
|
|
|
9573
9983
|
// src/ui.ts
|
|
@@ -9581,6 +9991,10 @@ var clackUi = {
|
|
|
9581
9991
|
const value2 = await clack.text({ message });
|
|
9582
9992
|
return clack.isCancel(value2) ? void 0 : value2;
|
|
9583
9993
|
},
|
|
9994
|
+
async confirm(message, initial) {
|
|
9995
|
+
const value2 = await clack.confirm({ message, initialValue: initial });
|
|
9996
|
+
return clack.isCancel(value2) ? void 0 : value2;
|
|
9997
|
+
},
|
|
9584
9998
|
async wait(message, done, work) {
|
|
9585
9999
|
const spinner2 = clack.spinner();
|
|
9586
10000
|
spinner2.start(message);
|
package/dist/core.js
CHANGED
|
@@ -408,7 +408,7 @@ var COMMANDS = [
|
|
|
408
408
|
command: "catalog template get",
|
|
409
409
|
tool: "catalog_template_get",
|
|
410
410
|
title: "Get catalog template",
|
|
411
|
-
description: "One catalog template, with `runnable`, its `inputs`, the portal's credential fields and the organization's `accessLevel`. `organizationId` defaults to the caller's one organization.",
|
|
411
|
+
description: "One catalog template, with `runnable`, its `inputs`, the portal's credential fields and the organization's `accessLevel`. Set `includeWorkflowDefinition` to also get the template's rules, nodes and transitions as a read-only reference when building or editing a workflow; on an organization-scoped read it needs `accessLevel` `granted`. To get an editable copy, use `catalog_template_instantiate`. `organizationId` defaults to the caller's one organization.",
|
|
412
412
|
method: "GET",
|
|
413
413
|
path: "/agents/v2/catalog/templates/{templateId}",
|
|
414
414
|
args: [
|
|
@@ -419,7 +419,15 @@ var COMMANDS = [
|
|
|
419
419
|
required: true
|
|
420
420
|
}
|
|
421
421
|
],
|
|
422
|
-
query: [
|
|
422
|
+
query: [
|
|
423
|
+
{
|
|
424
|
+
name: "includeWorkflowDefinition",
|
|
425
|
+
flag: "include-workflow-definition",
|
|
426
|
+
type: "boolean",
|
|
427
|
+
required: false,
|
|
428
|
+
description: "Also return `workflowDefinition`: the rules, nodes and transitions of the source agent's latest published workflow. On an organization-scoped read it needs `granted` access; a `viewable` template returns 403."
|
|
429
|
+
}
|
|
430
|
+
],
|
|
423
431
|
binary: false,
|
|
424
432
|
readOnly: true,
|
|
425
433
|
destructive: false
|
|
@@ -734,14 +742,14 @@ var COMMANDS = [
|
|
|
734
742
|
flag: "dedicated",
|
|
735
743
|
type: "json",
|
|
736
744
|
required: false,
|
|
737
|
-
description: "Admin only, and returned to admins only. Dedicated
|
|
745
|
+
description: "Admin only, and returned to admins only. Dedicated workers and environments. Absent means no workers are kept. Exclusive with warmPool and warmCache.",
|
|
738
746
|
fields: [
|
|
739
747
|
{
|
|
740
748
|
name: "targetSize",
|
|
741
749
|
flag: "target-size",
|
|
742
750
|
type: "integer",
|
|
743
751
|
required: false,
|
|
744
|
-
description: "Baseline number of
|
|
752
|
+
description: "Baseline number of environments to keep ready outside any scheduled window. 0 drains the custom environment."
|
|
745
753
|
},
|
|
746
754
|
{
|
|
747
755
|
name: "schedule",
|
|
@@ -773,18 +781,25 @@ var COMMANDS = [
|
|
|
773
781
|
description: "Member max age in minutes. As for a warm pool, the replacement boots ahead of it."
|
|
774
782
|
},
|
|
775
783
|
{
|
|
776
|
-
name: "
|
|
777
|
-
flag: "executions-per-
|
|
784
|
+
name: "executionsPerEnvironment",
|
|
785
|
+
flag: "executions-per-environment",
|
|
778
786
|
type: "integer",
|
|
779
787
|
required: false,
|
|
780
|
-
description: "Executions one
|
|
788
|
+
description: "Executions one environment runs at once. On a browser base they share its active tab"
|
|
789
|
+
},
|
|
790
|
+
{
|
|
791
|
+
name: "workers",
|
|
792
|
+
flag: "workers",
|
|
793
|
+
type: "integer",
|
|
794
|
+
required: false,
|
|
795
|
+
description: "Workers the environment keeps, 1 to 8. Each drives every member environment and takes any execution; add more for volume. Absent means one per member profile"
|
|
781
796
|
},
|
|
782
797
|
{
|
|
783
798
|
name: "initialization",
|
|
784
799
|
flag: "initialization",
|
|
785
800
|
type: "json",
|
|
786
801
|
required: false,
|
|
787
|
-
description: "Workflow that initialises each member before
|
|
802
|
+
description: "Workflow that initialises each member before a worker drives it, such as a sign-in. Absent means a worker drives it as soon as the environment has booted.",
|
|
788
803
|
fields: [
|
|
789
804
|
{
|
|
790
805
|
name: "workflowId",
|
|
@@ -1144,14 +1159,14 @@ var COMMANDS = [
|
|
|
1144
1159
|
flag: "dedicated",
|
|
1145
1160
|
type: "json",
|
|
1146
1161
|
required: false,
|
|
1147
|
-
description: "Admin only, and returned to admins only. Dedicated
|
|
1162
|
+
description: "Admin only, and returned to admins only. Dedicated workers and environments. Absent means no workers are kept. Exclusive with warmPool and warmCache.",
|
|
1148
1163
|
fields: [
|
|
1149
1164
|
{
|
|
1150
1165
|
name: "targetSize",
|
|
1151
1166
|
flag: "target-size",
|
|
1152
1167
|
type: "integer",
|
|
1153
1168
|
required: false,
|
|
1154
|
-
description: "Baseline number of
|
|
1169
|
+
description: "Baseline number of environments to keep ready outside any scheduled window. 0 drains the custom environment."
|
|
1155
1170
|
},
|
|
1156
1171
|
{
|
|
1157
1172
|
name: "schedule",
|
|
@@ -1183,18 +1198,25 @@ var COMMANDS = [
|
|
|
1183
1198
|
description: "Member max age in minutes. As for a warm pool, the replacement boots ahead of it."
|
|
1184
1199
|
},
|
|
1185
1200
|
{
|
|
1186
|
-
name: "
|
|
1187
|
-
flag: "executions-per-
|
|
1201
|
+
name: "executionsPerEnvironment",
|
|
1202
|
+
flag: "executions-per-environment",
|
|
1188
1203
|
type: "integer",
|
|
1189
1204
|
required: false,
|
|
1190
|
-
description: "Executions one
|
|
1205
|
+
description: "Executions one environment runs at once. On a browser base they share its active tab"
|
|
1206
|
+
},
|
|
1207
|
+
{
|
|
1208
|
+
name: "workers",
|
|
1209
|
+
flag: "workers",
|
|
1210
|
+
type: "integer",
|
|
1211
|
+
required: false,
|
|
1212
|
+
description: "Workers the environment keeps, 1 to 8. Each drives every member environment and takes any execution; add more for volume. Absent means one per member profile"
|
|
1191
1213
|
},
|
|
1192
1214
|
{
|
|
1193
1215
|
name: "initialization",
|
|
1194
1216
|
flag: "initialization",
|
|
1195
1217
|
type: "json",
|
|
1196
1218
|
required: false,
|
|
1197
|
-
description: "Workflow that initialises each member before
|
|
1219
|
+
description: "Workflow that initialises each member before a worker drives it, such as a sign-in. Absent means a worker drives it as soon as the environment has booted.",
|
|
1198
1220
|
fields: [
|
|
1199
1221
|
{
|
|
1200
1222
|
name: "workflowId",
|
|
@@ -6667,8 +6689,9 @@ var BUILTINS = [
|
|
|
6667
6689
|
{
|
|
6668
6690
|
command: "login",
|
|
6669
6691
|
usage: "asteroid login",
|
|
6670
|
-
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.",
|
|
6671
|
-
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."]]
|
|
6672
6695
|
},
|
|
6673
6696
|
{
|
|
6674
6697
|
command: "logout",
|
|
@@ -6711,6 +6734,16 @@ var BUILTINS = [
|
|
|
6711
6734
|
usage: "asteroid whoami",
|
|
6712
6735
|
description: "Show who you act as, in which organization, and how long the token lasts.",
|
|
6713
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"
|
|
6714
6747
|
}
|
|
6715
6748
|
];
|
|
6716
6749
|
var BUILTIN_COMMANDS = new Set(BUILTINS.map((b) => b.command));
|
|
@@ -6854,9 +6887,16 @@ function defineCommands(root, options, dotted2 = /* @__PURE__ */ new Map(), onIn
|
|
|
6854
6887
|
for (const [flags, text2] of GLOBAL_FLAGS) {
|
|
6855
6888
|
if (!flags.startsWith("-h")) root.option(flags, text2);
|
|
6856
6889
|
}
|
|
6890
|
+
const groups = /* @__PURE__ */ new Map();
|
|
6857
6891
|
for (const builtin of options.builtins ?? []) {
|
|
6858
|
-
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);
|
|
6859
6898
|
if (builtin.arg) leaf.argument(`[${builtin.arg}]`);
|
|
6899
|
+
for (const [flags, text2] of builtin.options ?? []) leaf.option(flags, text2);
|
|
6860
6900
|
for (const [flags, text2] of builtin.hiddenOptions ?? [])
|
|
6861
6901
|
leaf.addOption(new Flag(flags, text2).hideHelp());
|
|
6862
6902
|
leaf.action((...args) => {
|
|
@@ -6869,7 +6909,6 @@ function defineCommands(root, options, dotted2 = /* @__PURE__ */ new Map(), onIn
|
|
|
6869
6909
|
});
|
|
6870
6910
|
}
|
|
6871
6911
|
const reserved = new Set((options.builtins ?? []).map((b) => b.command));
|
|
6872
|
-
const groups = /* @__PURE__ */ new Map();
|
|
6873
6912
|
for (const command of options.commands) {
|
|
6874
6913
|
if (reserved.has(command.command)) continue;
|
|
6875
6914
|
const words = command.command.split(" ");
|