@artis-lab/cli 0.14.0 → 0.16.0
This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
- package/README.md +28 -21
- package/package.json +3 -7
- package/src/bin.js +13 -4
- package/src/lib/app.js +13 -4
- package/src/lib/chunk-2GXGXTAO.js +1229 -0
- package/src/lib/{chunk-CT5TD6L2.js → chunk-2LRPXCLL.js} +24 -47
- package/src/lib/chunk-4O5BCFCD.js +60 -0
- package/src/lib/chunk-6PK46UOP.js +1804 -0
- package/src/lib/{chunk-MEPQKMK5.js → chunk-FSJVBXCW.js} +4 -32
- package/src/lib/{chunk-H32QAUSA.js → chunk-HUWOFEEU.js} +7 -0
- package/src/lib/chunk-I5P3FLKO.js +929 -0
- package/src/lib/chunk-IKQ5U3DH.js +146 -0
- package/src/lib/chunk-XZYT3B5O.js +113 -0
- package/src/lib/cli.js +87 -61
- package/src/lib/commands.js +25 -0
- package/src/lib/exit-codes.js +5 -3
- package/src/lib/files.js +3 -2
- package/src/lib/next-actions.js +12 -5
- package/src/lib/skill-install.js +9 -4
- package/src/lib/verify.js +2 -3
- package/src/bin.d.ts +0 -2
- package/src/index.d.ts +0 -1
- package/src/index.js +0 -76
- package/src/lib/app.d.ts +0 -3
- package/src/lib/args.d.ts +0 -4
- package/src/lib/args.js +0 -12
- package/src/lib/chunk-CCCATRMP.js +0 -591
- package/src/lib/chunk-KJV7R7DE.js +0 -82
- package/src/lib/chunk-PG7WDW5F.js +0 -2420
- package/src/lib/chunk-Q5KBGVKT.js +0 -155
- package/src/lib/chunk-QZFIUZXT.js +0 -10954
- package/src/lib/cli.d.ts +0 -147
- package/src/lib/config.d.ts +0 -50
- package/src/lib/exit-codes.d.ts +0 -28
- package/src/lib/files.d.ts +0 -19
- package/src/lib/next-actions.d.ts +0 -13
- package/src/lib/oauth.d.ts +0 -45
- package/src/lib/revision-bases.d.ts +0 -9
- package/src/lib/skill-install.d.ts +0 -50
- package/src/lib/verify.d.ts +0 -152
- package/src/lib/version.d.ts +0 -9
|
@@ -1,9 +1,3 @@
|
|
|
1
|
-
import {
|
|
2
|
-
collectFlagValues,
|
|
3
|
-
hasFlag,
|
|
4
|
-
parseFlagValue
|
|
5
|
-
} from "./chunk-KJV7R7DE.js";
|
|
6
|
-
|
|
7
1
|
// packages/cli/src/lib/skill-install.ts
|
|
8
2
|
import { spawnSync } from "node:child_process";
|
|
9
3
|
import { mkdir, stat, writeFile } from "node:fs/promises";
|
|
@@ -79,7 +73,7 @@ Do not publish to Artis if the user asks for Markdown, plain text, a PDF, an ans
|
|
|
79
73
|
artis login --host <url> # browser approval; stores OAuth tokens
|
|
80
74
|
artis whoami
|
|
81
75
|
|
|
82
|
-
Never ask the user for a password. Hosts default to https://artis.xiispace.eu.org;
|
|
76
|
+
Never ask the user for a password. Hosts default to https://artis.xiispace.eu.org; for a self-hosted server run \`artis login --host <url>\` once, and every command uses it until you log in to another. If a command reports missing or invalid credentials, run \`artis login\` and retry once; if login cannot complete here, say so and ask the user to authenticate. On any other failure, show the HTTP status and error once; do not retry blindly.
|
|
83
77
|
`;
|
|
84
78
|
function hermesHomeDir(home) {
|
|
85
79
|
const fromEnv = process.env["HERMES_HOME"];
|
|
@@ -204,7 +198,7 @@ async function getSkillHarnessReports(home) {
|
|
|
204
198
|
}
|
|
205
199
|
return reports;
|
|
206
200
|
}
|
|
207
|
-
async function installSkillFile(skillPath, force) {
|
|
201
|
+
async function installSkillFile(skillPath, force = false) {
|
|
208
202
|
const existed = await pathExists(skillPath, "file");
|
|
209
203
|
if (existed && !force) {
|
|
210
204
|
return "skipped";
|
|
@@ -225,22 +219,13 @@ function printHarnessTable(reports) {
|
|
|
225
219
|
);
|
|
226
220
|
}
|
|
227
221
|
}
|
|
228
|
-
async function
|
|
222
|
+
async function listSkillHarnesses(options = {}) {
|
|
223
|
+
return getSkillHarnessReports(options.home ?? homedir());
|
|
224
|
+
}
|
|
225
|
+
async function installSkill(input, options = {}) {
|
|
229
226
|
const home = options.home ?? homedir();
|
|
230
|
-
const
|
|
231
|
-
const
|
|
232
|
-
if (hasFlag(args, "--list")) {
|
|
233
|
-
const reports = await getSkillHarnessReports(home);
|
|
234
|
-
if (json) {
|
|
235
|
-
console.log(JSON.stringify({ harnesses: reports }, null, 2));
|
|
236
|
-
} else {
|
|
237
|
-
printHarnessTable(reports);
|
|
238
|
-
}
|
|
239
|
-
return;
|
|
240
|
-
}
|
|
241
|
-
const harnessValues = collectFlagValues(args, "--harness");
|
|
242
|
-
const dir = parseFlagValue(args, "--dir");
|
|
243
|
-
const yes = hasFlag(args, "--yes");
|
|
227
|
+
const harnessValues = (input.harness ?? []).filter(Boolean);
|
|
228
|
+
const { dir, yes } = input;
|
|
244
229
|
if (dir && (harnessValues.length > 0 || yes)) {
|
|
245
230
|
throw new Error("Pass either --dir or --harness/--yes, not both.");
|
|
246
231
|
}
|
|
@@ -278,7 +263,7 @@ async function installSkillFromCli(args, options = {}) {
|
|
|
278
263
|
const errors = [];
|
|
279
264
|
for (const target of targets) {
|
|
280
265
|
try {
|
|
281
|
-
const status = await installSkillFile(target.skillPath, force);
|
|
266
|
+
const status = await installSkillFile(target.skillPath, input.force);
|
|
282
267
|
results.push({ target: target.target, status, path: target.skillPath });
|
|
283
268
|
} catch (error) {
|
|
284
269
|
errors.push({
|
|
@@ -287,30 +272,19 @@ async function installSkillFromCli(args, options = {}) {
|
|
|
287
272
|
});
|
|
288
273
|
}
|
|
289
274
|
}
|
|
290
|
-
|
|
291
|
-
|
|
292
|
-
|
|
293
|
-
|
|
294
|
-
|
|
295
|
-
|
|
296
|
-
|
|
297
|
-
|
|
298
|
-
|
|
299
|
-
|
|
300
|
-
|
|
301
|
-
);
|
|
302
|
-
}
|
|
303
|
-
}
|
|
304
|
-
}
|
|
305
|
-
if (errors.length > 0) {
|
|
306
|
-
for (const failure of errors) {
|
|
307
|
-
console.error(
|
|
308
|
-
`install-skill failed for ${failure.target}: ${failure.error}`
|
|
275
|
+
return { results, errors };
|
|
276
|
+
}
|
|
277
|
+
function printInstallResults(results) {
|
|
278
|
+
for (const result of results) {
|
|
279
|
+
if (result.status === "skipped") {
|
|
280
|
+
console.log(
|
|
281
|
+
`Skipped ${result.target} (already installed; use --force to overwrite): ${result.path}`
|
|
282
|
+
);
|
|
283
|
+
} else {
|
|
284
|
+
console.log(
|
|
285
|
+
`${result.status === "updated" ? "Updated" : "Installed"} artis skill for ${result.target}: ${result.path}`
|
|
309
286
|
);
|
|
310
287
|
}
|
|
311
|
-
throw new Error(
|
|
312
|
-
`install-skill completed with errors (${errors.map((failure) => failure.target).join(", ")}).`
|
|
313
|
-
);
|
|
314
288
|
}
|
|
315
289
|
}
|
|
316
290
|
|
|
@@ -319,5 +293,8 @@ export {
|
|
|
319
293
|
skillPathFor,
|
|
320
294
|
parseHarnessIds,
|
|
321
295
|
getSkillHarnessReports,
|
|
322
|
-
|
|
296
|
+
printHarnessTable,
|
|
297
|
+
listSkillHarnesses,
|
|
298
|
+
installSkill,
|
|
299
|
+
printInstallResults
|
|
323
300
|
};
|
|
@@ -0,0 +1,60 @@
|
|
|
1
|
+
// packages/sdk/src/lib/artifact-types.ts
|
|
2
|
+
var TYPE_PACKAGE_NAME_PATTERN = /^(?!html$)[a-z][a-z0-9-]{0,39}$/;
|
|
3
|
+
function isTypePackageName(value) {
|
|
4
|
+
return typeof value === "string" && TYPE_PACKAGE_NAME_PATTERN.test(value);
|
|
5
|
+
}
|
|
6
|
+
function typeSourceIssuePrefix(type) {
|
|
7
|
+
return `[artis:${type}] `;
|
|
8
|
+
}
|
|
9
|
+
function parseTypeSourceIssueLine(type, text) {
|
|
10
|
+
const prefix = typeSourceIssuePrefix(type);
|
|
11
|
+
if (!text.startsWith(prefix)) return void 0;
|
|
12
|
+
try {
|
|
13
|
+
return toTypeSourceIssue(JSON.parse(text.slice(prefix.length)));
|
|
14
|
+
} catch {
|
|
15
|
+
return void 0;
|
|
16
|
+
}
|
|
17
|
+
}
|
|
18
|
+
function toTypeSourceIssue(value) {
|
|
19
|
+
if (!isPlainObject(value)) return void 0;
|
|
20
|
+
const { severity, code, message } = value;
|
|
21
|
+
if (severity !== "error" && severity !== "hint" || typeof code !== "string" || typeof message !== "string") {
|
|
22
|
+
return void 0;
|
|
23
|
+
}
|
|
24
|
+
const issue = { severity, code, message };
|
|
25
|
+
if (typeof value["path"] === "string") issue.path = value["path"];
|
|
26
|
+
if (Number.isInteger(value["line"])) issue.line = value["line"];
|
|
27
|
+
if (Number.isInteger(value["column"])) {
|
|
28
|
+
issue.column = value["column"];
|
|
29
|
+
}
|
|
30
|
+
if (typeof value["example"] === "string") issue.example = value["example"];
|
|
31
|
+
return issue;
|
|
32
|
+
}
|
|
33
|
+
var PACKAGE_PATH_PATTERN = /^(?!.*(?:^|\/)\.{1,2}(?:\/|$))[A-Za-z0-9._-]+(?:\/[A-Za-z0-9._-]+)*$/;
|
|
34
|
+
function isPackagePath(value) {
|
|
35
|
+
return typeof value === "string" && value.length <= 256 && PACKAGE_PATH_PATTERN.test(value);
|
|
36
|
+
}
|
|
37
|
+
function isPlainObject(value) {
|
|
38
|
+
return typeof value === "object" && value !== null && !Array.isArray(value);
|
|
39
|
+
}
|
|
40
|
+
var artifactFileLimits = {
|
|
41
|
+
/** Files in one revision. */
|
|
42
|
+
files: 1e3,
|
|
43
|
+
/** UTF-8 bytes in one file. */
|
|
44
|
+
fileBytes: 2 * 1024 * 1024,
|
|
45
|
+
/** UTF-8 bytes in all the files one request sends. */
|
|
46
|
+
requestBytes: 16 * 1024 * 1024,
|
|
47
|
+
/** Characters in one path. */
|
|
48
|
+
pathLength: 256
|
|
49
|
+
};
|
|
50
|
+
function isArtifactFilePath(value) {
|
|
51
|
+
return typeof value === "string" && value.length <= artifactFileLimits.pathLength && isPackagePath(value) && !value.split("/").some((segment) => segment.startsWith("."));
|
|
52
|
+
}
|
|
53
|
+
var utf8 = new TextEncoder();
|
|
54
|
+
|
|
55
|
+
export {
|
|
56
|
+
isTypePackageName,
|
|
57
|
+
parseTypeSourceIssueLine,
|
|
58
|
+
toTypeSourceIssue,
|
|
59
|
+
isArtifactFilePath
|
|
60
|
+
};
|