@artis-lab/cli 0.15.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 +10 -7
- package/package.json +2 -3
- package/src/bin.js +6 -5
- package/src/lib/app.js +6 -5
- package/src/lib/{chunk-VBJGJXYL.js → chunk-2GXGXTAO.js} +8 -17
- package/src/lib/chunk-4O5BCFCD.js +60 -0
- package/src/lib/{chunk-JPCT7RRK.js → chunk-6PK46UOP.js} +58 -15
- package/src/lib/{chunk-43EXTJSU.js → chunk-FSJVBXCW.js} +3 -31
- package/src/lib/chunk-I5P3FLKO.js +929 -0
- package/src/lib/{chunk-VLYS5R67.js → chunk-XZYT3B5O.js} +1 -1
- package/src/lib/cli.js +3 -3
- package/src/lib/commands.js +5 -4
- package/src/lib/files.js +2 -1
- package/src/lib/verify.js +2 -3
- package/src/lib/chunk-QZFIUZXT.js +0 -10954
package/README.md
CHANGED
|
@@ -89,13 +89,16 @@ violations. It exits 8 when it finds any. It needs the optional
|
|
|
89
89
|
10 MB and no browser binaries) and a
|
|
90
90
|
Chromium-based browser; set `ARTIS_CHROME_PATH` to use a specific one.
|
|
91
91
|
|
|
92
|
-
A slide deck is a directory of files,
|
|
93
|
-
`artis verify --root deck --type slides` (a published
|
|
94
|
-
names its type).
|
|
95
|
-
|
|
96
|
-
|
|
97
|
-
|
|
98
|
-
|
|
92
|
+
A slide deck, or the source of any installed Type, is a directory of files,
|
|
93
|
+
checked as its type: `artis verify --root deck --type slides` (a published
|
|
94
|
+
revision already names its type). The CLI bundles no Type: it reads the
|
|
95
|
+
Type's package (entry page, runtime and format check) from the server
|
|
96
|
+
`artis login` signed in to. It first runs the format check, in the browser
|
|
97
|
+
with the network off, and lists each issue with its level, rule, file and
|
|
98
|
+
line: errors exit 8, hints are reported only. It then serves the files at the
|
|
99
|
+
paths Artis serves them at, with the entry page, runtime and the Google Fonts
|
|
100
|
+
CSP the Type gets, in light and dark themes, adds the issues the runtime
|
|
101
|
+
prints, and for a deck reports every slide whose content runs past its
|
|
99
102
|
1920×1080 (4:3: 1440×1080) canvas. The server never runs these checks, so
|
|
100
103
|
run `verify` before every publish and revise.
|
|
101
104
|
|
package/package.json
CHANGED
|
@@ -1,6 +1,6 @@
|
|
|
1
1
|
{
|
|
2
2
|
"name": "@artis-lab/cli",
|
|
3
|
-
"version": "0.
|
|
3
|
+
"version": "0.16.0",
|
|
4
4
|
"description": "Agent-first CLI for creating, sharing and maintaining artifacts on Artis, an open-source, self-hostable place for what AI agents build.",
|
|
5
5
|
"type": "module",
|
|
6
6
|
"bin": {
|
|
@@ -48,7 +48,6 @@
|
|
|
48
48
|
"devDependencies": {
|
|
49
49
|
"@artis/api-contract": "0.0.1",
|
|
50
50
|
"@artis/sdk": "0.0.1",
|
|
51
|
-
"@artis/slides-format": "0.0.1"
|
|
52
|
-
"@artis/types-slides": "0.0.1"
|
|
51
|
+
"@artis/slides-format": "0.0.1"
|
|
53
52
|
}
|
|
54
53
|
}
|
package/src/bin.js
CHANGED
|
@@ -1,16 +1,17 @@
|
|
|
1
1
|
#!/usr/bin/env node
|
|
2
2
|
import {
|
|
3
3
|
runAgentCli
|
|
4
|
-
} from "./lib/chunk-
|
|
5
|
-
import "./lib/chunk-
|
|
6
|
-
import "./lib/chunk-
|
|
4
|
+
} from "./lib/chunk-XZYT3B5O.js";
|
|
5
|
+
import "./lib/chunk-2GXGXTAO.js";
|
|
6
|
+
import "./lib/chunk-I5P3FLKO.js";
|
|
7
|
+
import "./lib/chunk-6PK46UOP.js";
|
|
7
8
|
import "./lib/chunk-43WVFZLO.js";
|
|
8
9
|
import "./lib/chunk-JYMG2Y6C.js";
|
|
9
10
|
import "./lib/chunk-2LRPXCLL.js";
|
|
10
|
-
import "./lib/chunk-QZFIUZXT.js";
|
|
11
11
|
import "./lib/chunk-IZYFOV2K.js";
|
|
12
12
|
import "./lib/chunk-46DMRA3V.js";
|
|
13
|
-
import "./lib/chunk-
|
|
13
|
+
import "./lib/chunk-FSJVBXCW.js";
|
|
14
|
+
import "./lib/chunk-4O5BCFCD.js";
|
|
14
15
|
import "./lib/chunk-IKQ5U3DH.js";
|
|
15
16
|
import {
|
|
16
17
|
exitCodeFor
|
package/src/lib/app.js
CHANGED
|
@@ -1,15 +1,16 @@
|
|
|
1
1
|
import {
|
|
2
2
|
runAgentCli
|
|
3
|
-
} from "./chunk-
|
|
4
|
-
import "./chunk-
|
|
5
|
-
import "./chunk-
|
|
3
|
+
} from "./chunk-XZYT3B5O.js";
|
|
4
|
+
import "./chunk-2GXGXTAO.js";
|
|
5
|
+
import "./chunk-I5P3FLKO.js";
|
|
6
|
+
import "./chunk-6PK46UOP.js";
|
|
6
7
|
import "./chunk-43WVFZLO.js";
|
|
7
8
|
import "./chunk-JYMG2Y6C.js";
|
|
8
9
|
import "./chunk-2LRPXCLL.js";
|
|
9
|
-
import "./chunk-QZFIUZXT.js";
|
|
10
10
|
import "./chunk-IZYFOV2K.js";
|
|
11
11
|
import "./chunk-46DMRA3V.js";
|
|
12
|
-
import "./chunk-
|
|
12
|
+
import "./chunk-FSJVBXCW.js";
|
|
13
|
+
import "./chunk-4O5BCFCD.js";
|
|
13
14
|
import "./chunk-IKQ5U3DH.js";
|
|
14
15
|
import "./chunk-HUWOFEEU.js";
|
|
15
16
|
export {
|
|
@@ -1,3 +1,8 @@
|
|
|
1
|
+
import {
|
|
2
|
+
VerifyUnavailableError,
|
|
3
|
+
formatVerifyReport,
|
|
4
|
+
verifyFiles
|
|
5
|
+
} from "./chunk-I5P3FLKO.js";
|
|
1
6
|
import {
|
|
2
7
|
artifactShortId,
|
|
3
8
|
batchDocuments,
|
|
@@ -38,18 +43,13 @@ import {
|
|
|
38
43
|
uploadAsset,
|
|
39
44
|
watchArtifact,
|
|
40
45
|
whoami
|
|
41
|
-
} from "./chunk-
|
|
46
|
+
} from "./chunk-6PK46UOP.js";
|
|
42
47
|
import {
|
|
43
48
|
installSkill,
|
|
44
49
|
listSkillHarnesses,
|
|
45
50
|
printHarnessTable,
|
|
46
51
|
printInstallResults
|
|
47
52
|
} from "./chunk-2LRPXCLL.js";
|
|
48
|
-
import {
|
|
49
|
-
VerifyUnavailableError,
|
|
50
|
-
formatVerifyReport,
|
|
51
|
-
verifyFiles
|
|
52
|
-
} from "./chunk-QZFIUZXT.js";
|
|
53
53
|
import {
|
|
54
54
|
artisCliVersion
|
|
55
55
|
} from "./chunk-IZYFOV2K.js";
|
|
@@ -545,7 +545,7 @@ ${type.references.map((path) => ` ${path}`).join("\n")}`
|
|
|
545
545
|
type: flags.type,
|
|
546
546
|
revision: flags.revision
|
|
547
547
|
});
|
|
548
|
-
const title = `Verified ${job.label}${job.type ? ` (type ${job.type})` : ""}`;
|
|
548
|
+
const title = `Verified ${job.label}${job.type ? ` (type ${job.type.name})` : ""}`;
|
|
549
549
|
let report;
|
|
550
550
|
try {
|
|
551
551
|
report = await verifyFiles(job.files, {
|
|
@@ -554,16 +554,7 @@ ${type.references.map((path) => ` ${path}`).join("\n")}`
|
|
|
554
554
|
});
|
|
555
555
|
} catch (error) {
|
|
556
556
|
if (error instanceof VerifyUnavailableError) {
|
|
557
|
-
|
|
558
|
-
console.log(title);
|
|
559
|
-
for (const line of formatVerifyReport(error.partial)) {
|
|
560
|
-
console.log(line);
|
|
561
|
-
}
|
|
562
|
-
}
|
|
563
|
-
throw new CliError(
|
|
564
|
-
error.partial ? `Rendering checks did not run: ${error.message}` : error.message,
|
|
565
|
-
exitCodes.error
|
|
566
|
-
);
|
|
557
|
+
throw new CliError(error.message, exitCodes.error);
|
|
567
558
|
}
|
|
568
559
|
throw error;
|
|
569
560
|
}
|
|
@@ -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
|
+
};
|
|
@@ -9,9 +9,6 @@ import {
|
|
|
9
9
|
getRememberedBase,
|
|
10
10
|
rememberBase
|
|
11
11
|
} from "./chunk-JYMG2Y6C.js";
|
|
12
|
-
import {
|
|
13
|
-
verifyTypes
|
|
14
|
-
} from "./chunk-QZFIUZXT.js";
|
|
15
12
|
import {
|
|
16
13
|
ARTIS_DEFAULT_HOST,
|
|
17
14
|
findProfileForHost,
|
|
@@ -27,7 +24,10 @@ import {
|
|
|
27
24
|
changedFiles,
|
|
28
25
|
readFilesDir,
|
|
29
26
|
writeFilesDir
|
|
30
|
-
} from "./chunk-
|
|
27
|
+
} from "./chunk-FSJVBXCW.js";
|
|
28
|
+
import {
|
|
29
|
+
isTypePackageName
|
|
30
|
+
} from "./chunk-4O5BCFCD.js";
|
|
31
31
|
import {
|
|
32
32
|
CliError,
|
|
33
33
|
exitCodeForResponse,
|
|
@@ -909,13 +909,52 @@ function parseVerifyType(value) {
|
|
|
909
909
|
if (type === void 0 || type === "html") {
|
|
910
910
|
return void 0;
|
|
911
911
|
}
|
|
912
|
-
if (!
|
|
912
|
+
if (!isTypePackageName(type)) {
|
|
913
913
|
throw usageError(
|
|
914
|
-
`
|
|
914
|
+
`"${type}" is not a type name: 1-40 lower-case letters, digits and -, starting with a letter.`
|
|
915
915
|
);
|
|
916
916
|
}
|
|
917
917
|
return type;
|
|
918
918
|
}
|
|
919
|
+
async function readVerifyTypePackage(input, name) {
|
|
920
|
+
let files;
|
|
921
|
+
try {
|
|
922
|
+
({
|
|
923
|
+
type: { package: files }
|
|
924
|
+
} = await publicCall(input, "GET /api/types/{name}", {
|
|
925
|
+
params: { name }
|
|
926
|
+
}));
|
|
927
|
+
} catch (error) {
|
|
928
|
+
if (error instanceof CliError && error.exitCode === exitCodes.notFound) {
|
|
929
|
+
throw new CliError(
|
|
930
|
+
`The type ${name} is not installed on ${resolveBaseUrl(input, await readCliConfig())}. List the installed types with: artis types`,
|
|
931
|
+
exitCodes.notFound
|
|
932
|
+
);
|
|
933
|
+
}
|
|
934
|
+
throw error;
|
|
935
|
+
}
|
|
936
|
+
const read = async (path) => (await readTypeReference({ ...input, name, path })).content;
|
|
937
|
+
if (!files || typeof files.entry !== "string") {
|
|
938
|
+
throw new CliError(
|
|
939
|
+
`${resolveBaseUrl(input, await readCliConfig())} does not serve the ${name} package to artis verify: the server needs updating.`,
|
|
940
|
+
exitCodes.error
|
|
941
|
+
);
|
|
942
|
+
}
|
|
943
|
+
const { entry, runtime, check, googleFonts, layout } = files;
|
|
944
|
+
const [entryText, runtimeText, checkText] = await Promise.all([
|
|
945
|
+
read(entry),
|
|
946
|
+
read(runtime),
|
|
947
|
+
check ? read(check) : void 0
|
|
948
|
+
]);
|
|
949
|
+
return {
|
|
950
|
+
name,
|
|
951
|
+
entry: entryText,
|
|
952
|
+
runtime: runtimeText,
|
|
953
|
+
...checkText === void 0 ? {} : { check: checkText },
|
|
954
|
+
googleFonts,
|
|
955
|
+
...layout ? { layout } : {}
|
|
956
|
+
};
|
|
957
|
+
}
|
|
919
958
|
async function prepareVerify(input) {
|
|
920
959
|
const { target, root } = input;
|
|
921
960
|
if (!target && !root) {
|
|
@@ -924,7 +963,12 @@ async function prepareVerify(input) {
|
|
|
924
963
|
);
|
|
925
964
|
}
|
|
926
965
|
if (root) {
|
|
927
|
-
|
|
966
|
+
const job = await prepareFilesDirVerify(input, root);
|
|
967
|
+
return job.typeName ? {
|
|
968
|
+
files: job.files,
|
|
969
|
+
label: job.label,
|
|
970
|
+
type: await readVerifyTypePackage(input, job.typeName)
|
|
971
|
+
} : { files: job.files, label: job.label };
|
|
928
972
|
}
|
|
929
973
|
const reference = target;
|
|
930
974
|
let type = parseVerifyType(input.type);
|
|
@@ -978,17 +1022,16 @@ async function prepareVerify(input) {
|
|
|
978
1022
|
(revision) => revision.id === read.listed.revisionId
|
|
979
1023
|
)?.type;
|
|
980
1024
|
if (declared !== void 0 && declared !== "html") {
|
|
981
|
-
if (!verifyTypes.includes(declared)) {
|
|
982
|
-
throw new CliError(
|
|
983
|
-
`${label} is of type ${declared}, which this CLI cannot verify. Update the CLI.`,
|
|
984
|
-
exitCodes.error
|
|
985
|
-
);
|
|
986
|
-
}
|
|
987
1025
|
type = declared;
|
|
988
1026
|
}
|
|
989
1027
|
}
|
|
990
1028
|
}
|
|
991
|
-
return {
|
|
1029
|
+
return {
|
|
1030
|
+
files,
|
|
1031
|
+
label,
|
|
1032
|
+
...type ? { type: await readVerifyTypePackage(input, type) } : {},
|
|
1033
|
+
loadAsset
|
|
1034
|
+
};
|
|
992
1035
|
}
|
|
993
1036
|
async function prepareFilesDirVerify(input, root) {
|
|
994
1037
|
if (input.target) {
|
|
@@ -1004,7 +1047,7 @@ async function prepareFilesDirVerify(input, root) {
|
|
|
1004
1047
|
`${root} has no index.html: an html artifact is that one file. For a deck, add --type slides.`
|
|
1005
1048
|
);
|
|
1006
1049
|
}
|
|
1007
|
-
return { files, label: root, type };
|
|
1050
|
+
return { files, label: root, ...type ? { typeName: type } : {} };
|
|
1008
1051
|
}
|
|
1009
1052
|
async function listArtifacts(input) {
|
|
1010
1053
|
const credentials = await resolveCredentials(input);
|
|
@@ -1,3 +1,6 @@
|
|
|
1
|
+
import {
|
|
2
|
+
isArtifactFilePath
|
|
3
|
+
} from "./chunk-4O5BCFCD.js";
|
|
1
4
|
import {
|
|
2
5
|
usageError
|
|
3
6
|
} from "./chunk-HUWOFEEU.js";
|
|
@@ -6,37 +9,6 @@ import {
|
|
|
6
9
|
import { createHash } from "node:crypto";
|
|
7
10
|
import { mkdir, readdir, readFile, writeFile } from "node:fs/promises";
|
|
8
11
|
import path from "node:path";
|
|
9
|
-
|
|
10
|
-
// packages/sdk/src/lib/artifact-types.ts
|
|
11
|
-
var artifactTypeRegistry = {
|
|
12
|
-
slides: {}
|
|
13
|
-
};
|
|
14
|
-
var HTML_TYPE = "html";
|
|
15
|
-
var typePackageNames = Object.keys(artifactTypeRegistry);
|
|
16
|
-
var artifactTypeNames = [
|
|
17
|
-
HTML_TYPE,
|
|
18
|
-
...typePackageNames
|
|
19
|
-
];
|
|
20
|
-
var PACKAGE_PATH_PATTERN = /^(?!.*(?:^|\/)\.{1,2}(?:\/|$))[A-Za-z0-9._-]+(?:\/[A-Za-z0-9._-]+)*$/;
|
|
21
|
-
function isPackagePath(value) {
|
|
22
|
-
return typeof value === "string" && value.length <= 256 && PACKAGE_PATH_PATTERN.test(value);
|
|
23
|
-
}
|
|
24
|
-
var artifactFileLimits = {
|
|
25
|
-
/** Files in one revision. */
|
|
26
|
-
files: 1e3,
|
|
27
|
-
/** UTF-8 bytes in one file. */
|
|
28
|
-
fileBytes: 2 * 1024 * 1024,
|
|
29
|
-
/** UTF-8 bytes in all the files one request sends. */
|
|
30
|
-
requestBytes: 16 * 1024 * 1024,
|
|
31
|
-
/** Characters in one path. */
|
|
32
|
-
pathLength: 256
|
|
33
|
-
};
|
|
34
|
-
function isArtifactFilePath(value) {
|
|
35
|
-
return typeof value === "string" && value.length <= artifactFileLimits.pathLength && isPackagePath(value) && !value.split("/").some((segment) => segment.startsWith("."));
|
|
36
|
-
}
|
|
37
|
-
var utf8 = new TextEncoder();
|
|
38
|
-
|
|
39
|
-
// packages/cli/src/lib/files.ts
|
|
40
12
|
function isSkipped(name) {
|
|
41
13
|
return name.startsWith(".") || name === "node_modules";
|
|
42
14
|
}
|