@arkyn/cli 3.0.8 → 3.0.9
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/bundle.js +44 -25
- package/dist/bundle.js.map +1 -1
- package/package.json +4 -4
package/dist/bundle.js
CHANGED
|
@@ -20,18 +20,13 @@ function s(e, t) {
|
|
|
20
20
|
return n !== -1 && r !== -1 ? `${e.slice(0, n)}${t}${e.slice(r + 25)}` : `${e}${e.endsWith("\n") ? "\n" : "\n\n"}${t}\n`;
|
|
21
21
|
}
|
|
22
22
|
//#endregion
|
|
23
|
-
//#region src/utils/findInstalledArkynPackages.ts
|
|
24
|
-
var c = "@arkyn/cli";
|
|
25
|
-
function l(e) {
|
|
26
|
-
let t = /* @__PURE__ */ new Set();
|
|
27
|
-
for (let n of Object.keys(e.dependencies ?? {})) n.startsWith("@arkyn/") && t.add(n);
|
|
28
|
-
for (let n of Object.keys(e.devDependencies ?? {})) n.startsWith("@arkyn/") && t.add(n);
|
|
29
|
-
return t.delete(c), [...t].sort();
|
|
30
|
-
}
|
|
31
|
-
//#endregion
|
|
32
23
|
//#region src/utils/resolveAgentsDocs.ts
|
|
33
|
-
|
|
34
|
-
|
|
24
|
+
var c = "[A-Za-z0-9](?:[A-Za-z0-9._-]*[A-Za-z0-9])?", l = RegExp(`^${c}$`), u = RegExp(`^@${c}/${c}$`);
|
|
25
|
+
function d(e) {
|
|
26
|
+
return typeof e != "string" || e.length === 0 ? !1 : l.test(e) || u.test(e);
|
|
27
|
+
}
|
|
28
|
+
function f(t, n, i = e) {
|
|
29
|
+
return n.filter((e) => d(e) ? !0 : (console.warn(`arkyn init: skipping "${e}" — not a valid package name.`), !1)).map((e) => {
|
|
35
30
|
let n = [
|
|
36
31
|
"node_modules",
|
|
37
32
|
...e.split("/"),
|
|
@@ -48,46 +43,70 @@ function u(t, n, i = e) {
|
|
|
48
43
|
}));
|
|
49
44
|
}
|
|
50
45
|
//#endregion
|
|
46
|
+
//#region src/utils/findInstalledArkynPackages.ts
|
|
47
|
+
var p = "@arkyn/cli";
|
|
48
|
+
function m(e, t) {
|
|
49
|
+
for (let n of Object.keys(e ?? {})) if (n.startsWith("@arkyn/")) {
|
|
50
|
+
if (!d(n)) {
|
|
51
|
+
console.warn(`arkyn init: ignoring "${n}" — not a valid package name.`);
|
|
52
|
+
continue;
|
|
53
|
+
}
|
|
54
|
+
t.add(n);
|
|
55
|
+
}
|
|
56
|
+
}
|
|
57
|
+
function h(e) {
|
|
58
|
+
let t = /* @__PURE__ */ new Set();
|
|
59
|
+
return m(e.dependencies, t), m(e.devDependencies, t), t.delete(p), [...t].sort();
|
|
60
|
+
}
|
|
61
|
+
//#endregion
|
|
51
62
|
//#region src/commands/init.ts
|
|
52
|
-
function
|
|
63
|
+
function g(i) {
|
|
53
64
|
let a = r(i, "package.json");
|
|
54
65
|
if (!e(a)) {
|
|
55
66
|
console.error(`No package.json found in ${i}. Run this command from your project root.`), process.exitCode = 1;
|
|
56
67
|
return;
|
|
57
68
|
}
|
|
58
|
-
let c =
|
|
59
|
-
|
|
69
|
+
let c = t(a, "utf8"), l;
|
|
70
|
+
try {
|
|
71
|
+
l = JSON.parse(c);
|
|
72
|
+
} catch (e) {
|
|
73
|
+
let t = e instanceof Error ? e.message : String(e);
|
|
74
|
+
console.error(`Failed to parse ${a}: ${t}`), process.exitCode = 1;
|
|
75
|
+
return;
|
|
76
|
+
}
|
|
77
|
+
let u = h(l);
|
|
78
|
+
if (u.length === 0) {
|
|
60
79
|
console.log("No @arkyn/* packages found in dependencies or devDependencies.");
|
|
61
80
|
return;
|
|
62
81
|
}
|
|
63
|
-
let d =
|
|
82
|
+
let d = f(i, u);
|
|
64
83
|
if (d.length === 0) {
|
|
65
|
-
console.log(`Found ${
|
|
84
|
+
console.log(`Found ${u.join(", ")}, but none of them ship an AGENTS.md yet.`);
|
|
66
85
|
return;
|
|
67
86
|
}
|
|
68
|
-
let
|
|
69
|
-
n(
|
|
87
|
+
let p = r(i, "AGENTS.md");
|
|
88
|
+
n(p, s(e(p) ? t(p, "utf8") : null, o(d))), console.log(`Updated AGENTS.md with docs for: ${d.map((e) => e.name).join(", ")}`);
|
|
70
89
|
}
|
|
71
90
|
//#endregion
|
|
72
91
|
//#region src/index.ts
|
|
73
|
-
var
|
|
74
|
-
function
|
|
92
|
+
var _ = "Usage: arkyn <command> [flags]\n\nCommands:\n init --agents Create or update AGENTS.md in the current project, referencing\n the AGENTS.md docs shipped by installed @arkyn/* packages.\n\nFlags:\n -h, --help Show this help message\n";
|
|
93
|
+
function v() {
|
|
75
94
|
let [e, ...t] = process.argv.slice(2);
|
|
76
95
|
if (!e || e === "-h" || e === "--help") {
|
|
77
|
-
console.log(
|
|
96
|
+
console.log(_);
|
|
78
97
|
return;
|
|
79
98
|
}
|
|
80
99
|
if (e === "init") {
|
|
81
100
|
if (!t.includes("--agents")) {
|
|
82
|
-
console.error("arkyn init requires the --agents flag.\n"), console.log(
|
|
101
|
+
console.error("arkyn init requires the --agents flag.\n"), console.log(_), process.exitCode = 1;
|
|
83
102
|
return;
|
|
84
103
|
}
|
|
85
|
-
|
|
104
|
+
g(process.cwd());
|
|
86
105
|
return;
|
|
87
106
|
}
|
|
88
|
-
console.error(`Unknown command: ${e}\n`), console.log(
|
|
107
|
+
console.error(`Unknown command: ${e}\n`), console.log(_), process.exitCode = 1;
|
|
89
108
|
}
|
|
90
|
-
|
|
109
|
+
v();
|
|
91
110
|
//#endregion
|
|
92
111
|
|
|
93
112
|
//# sourceMappingURL=bundle.js.map
|
package/dist/bundle.js.map
CHANGED
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"bundle.js","names":[],"sources":["../src/utils/agentsBlock.ts","../src/utils/
|
|
1
|
+
{"version":3,"file":"bundle.js","names":[],"sources":["../src/utils/agentsBlock.ts","../src/utils/resolveAgentsDocs.ts","../src/utils/findInstalledArkynPackages.ts","../src/commands/init.ts","../src/index.ts"],"sourcesContent":["import type { ArkynAgentsDoc } from \"./resolveAgentsDocs\";\n\nconst START_MARKER = \"<!-- arkyn:agents:start -->\";\nconst END_MARKER = \"<!-- arkyn:agents:end -->\";\n\nexport function buildAgentsBlock(docs: ArkynAgentsDoc[]): string {\n\tconst links = docs\n\t\t.map((doc) => `- [${doc.name}](${doc.relativePath})`)\n\t\t.join(\"\\n\");\n\n\treturn [\n\t\tSTART_MARKER,\n\t\t\"## Arkyn\",\n\t\t\"\",\n\t\t\"Consult each installed Arkyn package's AGENTS.md before using its components or utilities:\",\n\t\t\"\",\n\t\tlinks,\n\t\tEND_MARKER,\n\t].join(\"\\n\");\n}\n\nexport function mergeAgentsBlock(\n\texisting: string | null,\n\tblock: string,\n): string {\n\tif (!existing) return `${block}\\n`;\n\n\tconst start = existing.indexOf(START_MARKER);\n\tconst end = existing.indexOf(END_MARKER);\n\n\tif (start !== -1 && end !== -1) {\n\t\treturn `${existing.slice(0, start)}${block}${existing.slice(\n\t\t\tend + END_MARKER.length,\n\t\t)}`;\n\t}\n\n\tconst separator = existing.endsWith(\"\\n\") ? \"\\n\" : \"\\n\\n\";\n\treturn `${existing}${separator}${block}\\n`;\n}\n","import { existsSync } from \"node:fs\";\nimport { join } from \"node:path\";\n\nexport interface ArkynAgentsDoc {\n\tname: string;\n\trelativePath: string;\n}\n\n// A single \"segment\" of a package name: cannot start/end with a separator,\n// cannot be empty, and only contains characters npm allows in a package name.\nconst NAME_SEGMENT = \"[A-Za-z0-9](?:[A-Za-z0-9._-]*[A-Za-z0-9])?\";\nconst UNSCOPED_NAME_PATTERN = new RegExp(`^${NAME_SEGMENT}$`);\nconst SCOPED_NAME_PATTERN = new RegExp(`^@${NAME_SEGMENT}/${NAME_SEGMENT}$`);\n\n/**\n * Validates that a package name is safe to use when building filesystem\n * paths or Markdown content: no path traversal segments (`..`), no leading\n * `/` (absolute paths), no more than one `@scope/name` separator, and no\n * characters outside what npm allows in a real package name. This guards\n * against a malicious/malformed `package.json` steering `resolveAgentsDocs`\n * outside of `node_modules` or injecting content into `AGENTS.md`.\n */\nexport function isValidPackageName(name: string): boolean {\n\tif (typeof name !== \"string\" || name.length === 0) return false;\n\n\treturn UNSCOPED_NAME_PATTERN.test(name) || SCOPED_NAME_PATTERN.test(name);\n}\n\nexport function resolveAgentsDocs(\n\tcwd: string,\n\tpackageNames: string[],\n\texists: (absolutePath: string) => boolean = existsSync,\n): ArkynAgentsDoc[] {\n\treturn packageNames\n\t\t.filter((name) => {\n\t\t\tif (isValidPackageName(name)) return true;\n\n\t\t\tconsole.warn(\n\t\t\t\t`arkyn init: skipping \"${name}\" — not a valid package name.`,\n\t\t\t);\n\t\t\treturn false;\n\t\t})\n\t\t.map((name) => {\n\t\t\tconst parts = [\"node_modules\", ...name.split(\"/\"), \"AGENTS.md\"];\n\n\t\t\treturn {\n\t\t\t\tname,\n\t\t\t\trelativePath: parts.join(\"/\"),\n\t\t\t\tabsolutePath: join(cwd, ...parts),\n\t\t\t};\n\t\t})\n\t\t.filter((doc) => exists(doc.absolutePath))\n\t\t.map(({ name, relativePath }) => ({ name, relativePath }));\n}\n","import { isValidPackageName } from \"./resolveAgentsDocs\";\n\nexport interface PackageJson {\n\tdependencies?: Record<string, string>;\n\tdevDependencies?: Record<string, string>;\n\t[key: string]: unknown;\n}\n\nconst SELF_PACKAGE = \"@arkyn/cli\";\n\nfunction collectArkynNames(\n\tdeps: Record<string, string> | undefined,\n\tnames: Set<string>,\n): void {\n\tfor (const name of Object.keys(deps ?? {})) {\n\t\tif (!name.startsWith(\"@arkyn/\")) continue;\n\n\t\tif (!isValidPackageName(name)) {\n\t\t\tconsole.warn(\n\t\t\t\t`arkyn init: ignoring \"${name}\" — not a valid package name.`,\n\t\t\t);\n\t\t\tcontinue;\n\t\t}\n\n\t\tnames.add(name);\n\t}\n}\n\nexport function findInstalledArkynPackages(pkg: PackageJson): string[] {\n\tconst names = new Set<string>();\n\n\tcollectArkynNames(pkg.dependencies, names);\n\tcollectArkynNames(pkg.devDependencies, names);\n\n\tnames.delete(SELF_PACKAGE);\n\n\treturn [...names].sort();\n}\n","import { existsSync, readFileSync, writeFileSync } from \"node:fs\";\nimport { join } from \"node:path\";\nimport { buildAgentsBlock, mergeAgentsBlock } from \"../utils/agentsBlock\";\nimport {\n\tfindInstalledArkynPackages,\n\ttype PackageJson,\n} from \"../utils/findInstalledArkynPackages\";\nimport { resolveAgentsDocs } from \"../utils/resolveAgentsDocs\";\n\nexport function runInit(cwd: string): void {\n\tconst packageJsonPath = join(cwd, \"package.json\");\n\n\tif (!existsSync(packageJsonPath)) {\n\t\tconsole.error(\n\t\t\t`No package.json found in ${cwd}. Run this command from your project root.`,\n\t\t);\n\t\tprocess.exitCode = 1;\n\t\treturn;\n\t}\n\n\tconst rawPackageJson = readFileSync(packageJsonPath, \"utf8\");\n\n\tlet pkg: PackageJson;\n\ttry {\n\t\tpkg = JSON.parse(rawPackageJson) as PackageJson;\n\t} catch (error) {\n\t\tconst reason = error instanceof Error ? error.message : String(error);\n\t\tconsole.error(`Failed to parse ${packageJsonPath}: ${reason}`);\n\t\tprocess.exitCode = 1;\n\t\treturn;\n\t}\n\n\tconst packageNames = findInstalledArkynPackages(pkg);\n\n\tif (packageNames.length === 0) {\n\t\tconsole.log(\n\t\t\t\"No @arkyn/* packages found in dependencies or devDependencies.\",\n\t\t);\n\t\treturn;\n\t}\n\n\tconst docs = resolveAgentsDocs(cwd, packageNames);\n\n\tif (docs.length === 0) {\n\t\tconsole.log(\n\t\t\t`Found ${packageNames.join(\", \")}, but none of them ship an AGENTS.md yet.`,\n\t\t);\n\t\treturn;\n\t}\n\n\tconst agentsPath = join(cwd, \"AGENTS.md\");\n\tconst existing = existsSync(agentsPath)\n\t\t? readFileSync(agentsPath, \"utf8\")\n\t\t: null;\n\n\tconst block = buildAgentsBlock(docs);\n\twriteFileSync(agentsPath, mergeAgentsBlock(existing, block));\n\n\tconsole.log(\n\t\t`Updated AGENTS.md with docs for: ${docs.map((doc) => doc.name).join(\", \")}`,\n\t);\n}\n","import { runInit } from \"./commands/init\";\n\nconst HELP_TEXT = `Usage: arkyn <command> [flags]\n\nCommands:\n init --agents Create or update AGENTS.md in the current project, referencing\n the AGENTS.md docs shipped by installed @arkyn/* packages.\n\nFlags:\n -h, --help Show this help message\n`;\n\nfunction main() {\n\tconst [command, ...flags] = process.argv.slice(2);\n\n\tif (!command || command === \"-h\" || command === \"--help\") {\n\t\tconsole.log(HELP_TEXT);\n\t\treturn;\n\t}\n\n\tif (command === \"init\") {\n\t\tif (!flags.includes(\"--agents\")) {\n\t\t\tconsole.error(\"arkyn init requires the --agents flag.\\n\");\n\t\t\tconsole.log(HELP_TEXT);\n\t\t\tprocess.exitCode = 1;\n\t\t\treturn;\n\t\t}\n\n\t\trunInit(process.cwd());\n\t\treturn;\n\t}\n\n\tconsole.error(`Unknown command: ${command}\\n`);\n\tconsole.log(HELP_TEXT);\n\tprocess.exitCode = 1;\n}\n\nmain();\n"],"mappings":";;;;AAEA,IAAM,IAAe,+BACf,IAAa;AAEnB,SAAgB,EAAiB,GAAgC;CAKhE,OAAO;EACN;EACA;EACA;EACA;EACA;EATa,EACZ,KAAK,MAAQ,MAAM,EAAI,KAAK,IAAI,EAAI,aAAa,EAAE,CAAC,CACpD,KAAK,IAQN;EACA;CACD,CAAC,CAAC,KAAK,IAAI;AACZ;AAEA,SAAgB,EACf,GACA,GACS;CACT,IAAI,CAAC,GAAU,OAAO,GAAG,EAAM;CAE/B,IAAM,IAAQ,EAAS,QAAQ,CAAY,GACrC,IAAM,EAAS,QAAQ,CAAU;CASvC,OAPI,MAAU,MAAM,MAAQ,KACpB,GAAG,EAAS,MAAM,GAAG,CAAK,IAAI,IAAQ,EAAS,MACrD,IAAM,EACP,MAIM,GAAG,IADQ,EAAS,SAAS,IAAI,IAAI,OAAO,SAClB,EAAM;AACxC;;;AC5BA,IAAM,IAAe,8CACf,IAA4B,OAAO,IAAI,EAAa,EAAE,GACtD,IAA0B,OAAO,KAAK,EAAa,GAAG,EAAa,EAAE;AAU3E,SAAgB,EA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|
|
|
1
1
|
{
|
|
2
2
|
"name": "@arkyn/cli",
|
|
3
|
-
"version": "3.0.
|
|
3
|
+
"version": "3.0.9",
|
|
4
4
|
"type": "module",
|
|
5
5
|
"private": false,
|
|
6
6
|
"license": "Apache-2.0",
|
|
@@ -37,12 +37,12 @@
|
|
|
37
37
|
"LICENSE.txt"
|
|
38
38
|
],
|
|
39
39
|
"scripts": {
|
|
40
|
-
"audit": "bun audit
|
|
40
|
+
"audit": "bun audit",
|
|
41
41
|
"build": "bunx vite build",
|
|
42
42
|
"postbuild": "chmod +x dist/bundle.js",
|
|
43
43
|
"prebuild": "rm -rf dist",
|
|
44
|
-
"publish:beta": "
|
|
45
|
-
"publish:latest": "
|
|
44
|
+
"publish:beta": "bash ../../scripts/publish-idempotent.sh beta",
|
|
45
|
+
"publish:latest": "bash ../../scripts/publish-idempotent.sh latest",
|
|
46
46
|
"release:beta": "bun ./generate-version.ts beta",
|
|
47
47
|
"release:patch": "bun ./generate-version.ts patch",
|
|
48
48
|
"release:minor": "bun ./generate-version.ts minor",
|