@yansirplus/cli 0.5.17 → 0.5.19

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.
Files changed (53) hide show
  1. package/README.md +12 -6
  2. package/agent-catalog/agentOS/SKILL.md +22 -0
  3. package/agent-catalog/agentOS/references/agent/decision-graph.json +530 -0
  4. package/agent-catalog/agentOS/references/agent/errors.json +497 -0
  5. package/agent-catalog/agentOS/references/agent/invariant-matrix.json +337 -0
  6. package/agent-catalog/agentOS/references/agent/primitives.json +989 -0
  7. package/agent-catalog/agentOS/references/agent/recipes.json +109 -0
  8. package/agent-catalog/agentOS/references/agent/start-here.md +25 -0
  9. package/agent-catalog/agentOS/references/package-map.md +73 -0
  10. package/agent-catalog/agentOS/references/provenance.json +251 -0
  11. package/agent-catalog/agentOS/references/public-api/cli.md +20 -0
  12. package/agent-catalog/agentOS/references/public-api/client.md +90 -0
  13. package/agent-catalog/agentOS/references/public-api/core.md +1907 -0
  14. package/agent-catalog/agentOS/references/public-api/runtime.md +843 -0
  15. package/dist/build/agent-authoring/config.d.ts +20 -5
  16. package/dist/build/agent-authoring/config.js +132 -32
  17. package/dist/build/agent-authoring/manifest-compiler.d.ts +131 -2
  18. package/dist/build/agent-authoring/manifest-compiler.js +630 -8
  19. package/dist/build/agent-authoring/shared.d.ts +2 -0
  20. package/dist/build/agent-authoring/shared.js +2 -0
  21. package/dist/build/agent-authoring/static-target.d.ts +6 -3
  22. package/dist/build/agent-authoring/static-target.js +1900 -281
  23. package/dist/build/agent-authoring.d.ts +3 -3
  24. package/dist/build/agent-authoring.js +1 -1
  25. package/dist/build/build-cli.d.ts +1 -1
  26. package/dist/build/build-cli.js +1629 -26
  27. package/dist/check/algorithmic/client-boundary-checks.mjs +3 -34
  28. package/dist/check/algorithmic/convergence-smoke-checks.mjs +652 -6
  29. package/dist/check/algorithmic/distribution-checks.mjs +8 -7
  30. package/dist/check/algorithmic/package-boundary-checks.mjs +3 -2
  31. package/dist/check/algorithmic/repo-surface-checks.mjs +55 -1
  32. package/dist/check/algorithmic/static-target-checks.mjs +83 -5
  33. package/dist/check/algorithmic-checks.mjs +10 -17
  34. package/dist/check/default-gate.mjs +3 -3
  35. package/dist/check/effect-scan-gate.mjs +121 -0
  36. package/dist/check/package-graph.mjs +2 -32
  37. package/dist/consumer-overlay.mjs +1281 -0
  38. package/dist/lib/public-api-model.mjs +19 -0
  39. package/dist/lib/repo-source-files.mjs +26 -0
  40. package/dist/lib/ts-module-loader.mjs +44 -0
  41. package/dist/lib/workspace-manifest.mjs +77 -0
  42. package/dist/main.mjs +171 -21
  43. package/dist/release-status.mjs +515 -0
  44. package/package.json +8 -4
  45. package/dist/check/check-coverage.mjs +0 -231
  46. package/dist/generate/generate-agent-docs.mjs +0 -435
  47. package/dist/generate/generate-carrier-reference.mjs +0 -514
  48. package/dist/generate/generate-docs.mjs +0 -345
  49. package/dist/generate/generate-effect-skill-manifests.mjs +0 -193
  50. package/dist/generate/project-docs-site.mjs +0 -190
  51. package/dist/lib/boundary-rules.mjs +0 -63
  52. package/dist/lib/capability-routes.mjs +0 -354
  53. package/dist/lib/projection-sink.mjs +0 -113
@@ -167,6 +167,25 @@ const sourceExportRecordsFromAst = (file, entrypoint, seen) => {
167
167
  records.push(
168
168
  ...sourceExportRecordsFromAst(resolveRelativeModule(abs, specifier), entrypoint, seen),
169
169
  );
170
+ } else if (
171
+ statement.exportClause !== undefined &&
172
+ ts.isNamedExports(statement.exportClause) &&
173
+ specifier !== null &&
174
+ specifier.startsWith(".")
175
+ ) {
176
+ const target = resolveRelativeModule(abs, specifier);
177
+ const targetRecords = sourceExportRecordsFromAst(target, entrypoint, new Set(seen));
178
+ for (const element of statement.exportClause.elements) {
179
+ const importedName = element.propertyName?.text ?? element.name.text;
180
+ const exportedName = element.name.text;
181
+ const targetRecord = targetRecords.find((record) => record.name === importedName);
182
+ if (targetRecord === undefined) continue;
183
+ records.push({
184
+ ...targetRecord,
185
+ name: exportedName,
186
+ key: `${entrypoint}:${exportedName}`,
187
+ });
188
+ }
170
189
  }
171
190
  continue;
172
191
  }
@@ -0,0 +1,26 @@
1
+ import fs from "node:fs";
2
+ import path from "node:path";
3
+
4
+ export const repoSourceIgnoredDirectoryNames = Object.freeze(
5
+ new Set(["node_modules", "dist", ".wrangler", ".turbo", ".parallel", ".cst", ".git", ".codex"]),
6
+ );
7
+
8
+ const compare = (left, right) => left.localeCompare(right);
9
+
10
+ const toRepoPath = (file) => file.split(path.sep).join("/");
11
+
12
+ export const walkRepoSourceFiles = (repoRoot, relativePath = ".", options = {}) => {
13
+ const absolutePath = path.join(repoRoot, relativePath);
14
+ if (!fs.existsSync(absolutePath)) return [];
15
+ const stat = fs.statSync(absolutePath);
16
+ if (stat.isFile()) return [toRepoPath(relativePath)];
17
+ const ignored = options.ignored ?? repoSourceIgnoredDirectoryNames;
18
+ const files = [];
19
+ for (const entry of fs.readdirSync(absolutePath, { withFileTypes: true })) {
20
+ if (entry.isDirectory() && ignored.has(entry.name)) continue;
21
+ const child = path.join(relativePath, entry.name);
22
+ if (entry.isDirectory()) files.push(...walkRepoSourceFiles(repoRoot, child, options));
23
+ if (entry.isFile()) files.push(toRepoPath(child));
24
+ }
25
+ return files.sort(compare);
26
+ };
@@ -0,0 +1,44 @@
1
+ import { randomUUID } from "node:crypto";
2
+ import { mkdir, rm } from "node:fs/promises";
3
+ import os from "node:os";
4
+ import path from "node:path";
5
+ import { pathToFileURL } from "node:url";
6
+
7
+ import { build } from "esbuild";
8
+
9
+ const compare = (left, right) => left.localeCompare(right);
10
+
11
+ export const bundleModuleForNode = async (
12
+ entryPoint,
13
+ { define = {}, external = [], prefix = "agentos-ts-module-", tempRoot = os.tmpdir() } = {},
14
+ ) => {
15
+ const outDir = path.join(tempRoot, `${prefix}${randomUUID()}`);
16
+ const outfile = path.join(outDir, "entry.mjs");
17
+ await mkdir(outDir, { recursive: true });
18
+ await build({
19
+ entryPoints: [entryPoint],
20
+ outfile,
21
+ bundle: true,
22
+ format: "esm",
23
+ platform: "node",
24
+ target: "node22",
25
+ define,
26
+ external: [...new Set(["esbuild", "cloudflare:*", ...external])].sort(compare),
27
+ logLevel: "silent",
28
+ });
29
+ return {
30
+ outfile,
31
+ cleanup: async () => {
32
+ await rm(outDir, { recursive: true, force: true });
33
+ },
34
+ };
35
+ };
36
+
37
+ export const importBundledModule = async (entryPoint, options = {}) => {
38
+ const bundled = await bundleModuleForNode(entryPoint, options);
39
+ try {
40
+ return await import(`${pathToFileURL(bundled.outfile).href}?agentos=${Date.now()}`);
41
+ } finally {
42
+ await bundled.cleanup();
43
+ }
44
+ };
@@ -0,0 +1,77 @@
1
+ import fs from "node:fs";
2
+ import path from "node:path";
3
+
4
+ import { parse as parseYaml } from "yaml";
5
+
6
+ const compare = (left, right) => left.localeCompare(right);
7
+ const readJsonFile = (file) => JSON.parse(fs.readFileSync(file, "utf8"));
8
+
9
+ const workspaceManifestPath = (repoRoot) => path.join(repoRoot, "pnpm-workspace.yaml");
10
+
11
+ const requireRecord = (value, label) => {
12
+ if (value === null || typeof value !== "object" || Array.isArray(value)) {
13
+ throw new Error(`${label} must be an object`);
14
+ }
15
+ return value;
16
+ };
17
+
18
+ export const readWorkspaceManifest = (repoRoot) => {
19
+ const file = workspaceManifestPath(repoRoot);
20
+ if (!fs.existsSync(file)) {
21
+ throw new Error("pnpm-workspace.yaml is the workspace manifest SSOT and must exist");
22
+ }
23
+ const manifest = requireRecord(parseYaml(fs.readFileSync(file, "utf8")), "pnpm-workspace.yaml");
24
+ return manifest;
25
+ };
26
+
27
+ export const workspacePackagePatterns = (repoRoot) => {
28
+ const packages = readWorkspaceManifest(repoRoot).packages;
29
+ if (!Array.isArray(packages)) {
30
+ throw new Error("pnpm-workspace.yaml packages must be an array");
31
+ }
32
+ return packages.filter((entry) => typeof entry === "string").sort(compare);
33
+ };
34
+
35
+ export const workspaceCatalog = (repoRoot) => {
36
+ const catalog = readWorkspaceManifest(repoRoot).catalog;
37
+ if (catalog === undefined) return {};
38
+ return requireRecord(catalog, "pnpm-workspace.yaml catalog");
39
+ };
40
+
41
+ export const workspaceOverrides = (repoRoot) => {
42
+ const overrides = readWorkspaceManifest(repoRoot).overrides;
43
+ if (overrides === undefined) return {};
44
+ return requireRecord(overrides, "pnpm-workspace.yaml overrides");
45
+ };
46
+
47
+ export const workspacePackagePaths = (repoRoot) => {
48
+ const paths = new Set();
49
+ for (const workspace of workspacePackagePatterns(repoRoot)) {
50
+ if (workspace.endsWith("/*")) {
51
+ const base = workspace.slice(0, -2);
52
+ const baseDir = path.join(repoRoot, base);
53
+ if (!fs.existsSync(baseDir)) continue;
54
+ for (const entry of fs.readdirSync(baseDir, { withFileTypes: true })) {
55
+ if (!entry.isDirectory()) continue;
56
+ const packagePath = `${base}/${entry.name}`;
57
+ if (fs.existsSync(path.join(repoRoot, packagePath, "package.json"))) {
58
+ paths.add(packagePath);
59
+ }
60
+ }
61
+ continue;
62
+ }
63
+
64
+ if (fs.existsSync(path.join(repoRoot, workspace, "package.json"))) {
65
+ paths.add(workspace);
66
+ }
67
+ }
68
+ return [...paths].sort(compare);
69
+ };
70
+
71
+ export const workspacePackageRecords = (repoRoot) =>
72
+ workspacePackagePaths(repoRoot)
73
+ .map((packagePath) => ({
74
+ name: readJsonFile(path.join(repoRoot, packagePath, "package.json")).name,
75
+ path: packagePath,
76
+ }))
77
+ .sort((left, right) => left.path.localeCompare(right.path));
package/dist/main.mjs CHANGED
@@ -1,7 +1,17 @@
1
1
  #!/usr/bin/env node
2
2
  import { spawn } from "node:child_process";
3
- import { fileURLToPath } from "node:url";
3
+ import { existsSync, readFileSync } from "node:fs";
4
+ import path from "node:path";
5
+ import { fileURLToPath, pathToFileURL } from "node:url";
4
6
 
7
+ import { bundleModuleForNode } from "./lib/ts-module-loader.mjs";
8
+ import {
9
+ consumerCheck,
10
+ consumerStatus,
11
+ installConsumer,
12
+ restoreConsumer,
13
+ } from "./consumer-overlay.mjs";
14
+ import { releaseStatus } from "./release-status.mjs";
5
15
  import {
6
16
  algorithmicCheckerAcceptsArgs,
7
17
  hasAlgorithmicChecker,
@@ -13,9 +23,27 @@ import {
13
23
  runAffectedGates,
14
24
  } from "./check/gate-selector.mjs";
15
25
  import { runDefaultGate } from "./check/default-gate.mjs";
26
+ import { runEffectScanGate } from "./check/effect-scan-gate.mjs";
16
27
  import { listGuards, runGroup, runGuard } from "./runner.mjs";
17
28
 
18
- const version = "0.5.16";
29
+ const packageRootFromMain = () => path.dirname(path.dirname(fileURLToPath(import.meta.url)));
30
+
31
+ const repoRootFromMain = () => path.dirname(path.dirname(packageRootFromMain()));
32
+
33
+ const readReleaseVersion = () => {
34
+ const rootPackagePath = path.join(repoRootFromMain(), "package.json");
35
+ const packagePath = existsSync(rootPackagePath)
36
+ ? rootPackagePath
37
+ : path.join(packageRootFromMain(), "package.json");
38
+ const packageJson = JSON.parse(readFileSync(packagePath, "utf8"));
39
+ const version = packageJson.agentOsRelease?.version ?? packageJson.version;
40
+ if (typeof version !== "string" || version.length === 0) {
41
+ throw new Error("package.json version must be a non-empty string");
42
+ }
43
+ return version;
44
+ };
45
+
46
+ const version = readReleaseVersion();
19
47
 
20
48
  const helpText = `agentOS repository CLI ${version}
21
49
 
@@ -23,11 +51,22 @@ Usage:
23
51
  agentos --help
24
52
  agentos --version
25
53
  agentos build [--cwd <path>] [--config <path>] [--package-scope <scope>]
54
+ agentos info [--cwd <path>] [--config <path>] [--json]
55
+ agentos serve [--cwd <path>] [--config <path>] [--package-scope <scope>] [--host <host>] [--port <port>] [--llm config|test] [--llm-response <text>] [--json]
56
+ agentos dev [--cwd <path>] [--config <path>] [--package-scope <scope>] [--host <host>] [--port <port>] [--llm config|test] [--llm-response <text>] [--json]
57
+ agentos eval [--cwd <path>] [--config <path>] [--package-scope <scope>] [--target local|remote] [--base-url <url>] [--header <name=value>] [--llm config|test] [--llm-response <text>] [--json]
58
+ agentos preflight llm [--cwd <path>] [--config <path>] [--route <binding-ref>] [--json]
59
+ agentos release status [path/to/consumer] [--json] [--check-npm] [--registry <url>] [--install-manifest <path>]
60
+ agentos consumer install /path/to/consumer [--from-manifest <path>] [--no-install] [--skip-pack] [--json]
61
+ agentos consumer status /path/to/consumer [--json] [--check-npm] [--registry <url>]
62
+ agentos consumer check /path/to/consumer [--json] [--check-npm] [--registry <url>]
63
+ agentos consumer restore /path/to/consumer [--no-install] [--json]
26
64
  agentos check all
27
65
  agentos check default
28
66
  agentos check structural
29
67
  agentos check affected [--base <ref>] [--head <ref>] [--json] [--explain] [--run]
30
68
  agentos check docs
69
+ agentos check effect-scan [--repo <path>] [--evidence <path>] [--scanner <command>]
31
70
  agentos check effect-manifests
32
71
  agentos check release
33
72
  agentos check site
@@ -50,6 +89,13 @@ const fail = (message) => {
50
89
  if (
51
90
  message.startsWith("agentos:") ||
52
91
  message.startsWith("agentos build:") ||
92
+ message.startsWith("agentos info:") ||
93
+ message.startsWith("agentos serve:") ||
94
+ message.startsWith("agentos dev:") ||
95
+ message.startsWith("agentos eval:") ||
96
+ message.startsWith("agentos preflight:") ||
97
+ message.startsWith("agentos release:") ||
98
+ message.startsWith("agentos consumer:") ||
53
99
  message.startsWith("agentos check:") ||
54
100
  message.startsWith("agentos generate:")
55
101
  ) {
@@ -64,25 +110,103 @@ const expectNoExtraArgs = (args, command) => {
64
110
  }
65
111
  };
66
112
 
67
- const runBuild = async (args) => {
113
+ const runBuildRunner = async (command, args) => {
68
114
  const runner = fileURLToPath(new URL("./build/build-cli.js", import.meta.url));
69
- await new Promise((resolve, reject) => {
70
- const child = spawn("bun", [runner, "build", ...args], { stdio: "inherit" });
71
- child.on("error", (error) => {
72
- reject(new Error(`agentos build: failed to start bun: ${error.message}`));
73
- });
74
- child.on("exit", (code, signal) => {
75
- if (signal !== null) {
76
- reject(new Error(`agentos build: build runner terminated by ${signal}`));
77
- return;
78
- }
79
- if (code !== 0) {
80
- reject(new Error(`agentos build: build runner failed with exit code ${code ?? 1}`));
81
- return;
82
- }
83
- resolve();
84
- });
115
+ const bundled = await bundleModuleForNode(runner, {
116
+ prefix: "agentos-build-runner-",
117
+ tempRoot: path.join(packageRootFromMain(), "node_modules", ".cache", "agentos-build"),
85
118
  });
119
+ try {
120
+ await new Promise((resolve, reject) => {
121
+ const child = spawn(process.execPath, [bundled.outfile, command, ...args], {
122
+ stdio: "inherit",
123
+ });
124
+ child.on("error", (error) => {
125
+ reject(
126
+ new Error(`agentos ${command}: failed to start node build runner: ${error.message}`),
127
+ );
128
+ });
129
+ child.on("exit", (code, signal) => {
130
+ if (signal !== null) {
131
+ reject(new Error(`agentos ${command}: build runner terminated by ${signal}`));
132
+ return;
133
+ }
134
+ if (code !== 0) {
135
+ process.exitCode = code ?? 1;
136
+ }
137
+ resolve();
138
+ });
139
+ });
140
+ } finally {
141
+ await bundled.cleanup();
142
+ }
143
+ };
144
+
145
+ const runBuild = async (args) => runBuildRunner("build", args);
146
+
147
+ const runInfo = async (args) => runBuildRunner("info", args);
148
+
149
+ const runServe = async (args) => runBuildRunner("serve", args);
150
+
151
+ const runDev = async (args) => runBuildRunner("dev", args);
152
+
153
+ const runEval = async (args) => runBuildRunner("eval", args);
154
+
155
+ const runPreflight = async (args) => runBuildRunner("preflight", args);
156
+
157
+ const sourceConsumerProducer = () => {
158
+ const modulePath = path.join(repoRootFromMain(), "tooling/distribution/pack-check.mjs");
159
+ const supportPath = path.join(repoRootFromMain(), "tooling/distribution/support.mjs");
160
+ if (!existsSync(modulePath) || !existsSync(supportPath)) return undefined;
161
+ return {
162
+ sourceRoot: repoRootFromMain(),
163
+ defaultInstallManifestPath: path.join(
164
+ repoRootFromMain(),
165
+ "dist/internal-npm/install-manifest.json",
166
+ ),
167
+ produceInstallManifest: async () => {
168
+ const producer = await import(pathToFileURL(modulePath).href);
169
+ producer.packInternal();
170
+ return path.join(repoRootFromMain(), "dist/internal-npm/install-manifest.json");
171
+ },
172
+ };
173
+ };
174
+
175
+ const runConsumer = async (args) => {
176
+ const [command, ...rest] = args;
177
+ const commandArgs = rest[0] === "--" ? rest.slice(1) : rest;
178
+ const sourceContext = sourceConsumerProducer() ?? {};
179
+ const context = { packageRoot: packageRootFromMain(), ...sourceContext };
180
+ switch (command) {
181
+ case "install":
182
+ await installConsumer(commandArgs, context);
183
+ return;
184
+ case "status":
185
+ consumerStatus(commandArgs, context);
186
+ return;
187
+ case "check":
188
+ consumerCheck(commandArgs, context);
189
+ return;
190
+ case "restore":
191
+ restoreConsumer(commandArgs, context);
192
+ return;
193
+ default:
194
+ throw new Error("agentos consumer: choose one of install, status, check, restore");
195
+ }
196
+ };
197
+
198
+ const runRelease = async (args) => {
199
+ const [command, ...rest] = args;
200
+ const commandArgs = rest[0] === "--" ? rest.slice(1) : rest;
201
+ const sourceContext = sourceConsumerProducer() ?? {};
202
+ const context = { packageRoot: packageRootFromMain(), ...sourceContext };
203
+ switch (command) {
204
+ case "status":
205
+ releaseStatus(commandArgs, context);
206
+ return;
207
+ default:
208
+ throw new Error("agentos release: choose status");
209
+ }
86
210
  };
87
211
 
88
212
  const runCheck = async (args) => {
@@ -134,6 +258,9 @@ const runCheck = async (args) => {
134
258
  expectNoExtraArgs(rest, "agentos check docs");
135
259
  await runGroup("check-docs");
136
260
  return;
261
+ case "effect-scan":
262
+ runEffectScanGate(rest, { defaultRepoRoot: repoRootFromMain() });
263
+ return;
137
264
  case "effect-manifests":
138
265
  expectNoExtraArgs(rest, "agentos check effect-manifests");
139
266
  await runGroup("check-effect-manifests");
@@ -170,7 +297,7 @@ const runCheck = async (args) => {
170
297
  return;
171
298
  }
172
299
  throw new Error(
173
- "agentos check: choose one of all, default, structural, affected, docs, effect-manifests, release, site, guard-coverage, guard, guards, or an algorithmic checker id",
300
+ "agentos check: choose one of all, default, structural, affected, docs, effect-scan, effect-manifests, release, site, guard-coverage, guard, guards, or an algorithmic checker id",
174
301
  );
175
302
  }
176
303
  };
@@ -215,6 +342,27 @@ const main = async () => {
215
342
  case "build":
216
343
  await runBuild(rest);
217
344
  return;
345
+ case "info":
346
+ await runInfo(rest);
347
+ return;
348
+ case "serve":
349
+ await runServe(rest);
350
+ return;
351
+ case "dev":
352
+ await runDev(rest);
353
+ return;
354
+ case "eval":
355
+ await runEval(rest);
356
+ return;
357
+ case "preflight":
358
+ await runPreflight(rest);
359
+ return;
360
+ case "release":
361
+ await runRelease(rest);
362
+ return;
363
+ case "consumer":
364
+ await runConsumer(rest);
365
+ return;
218
366
  case "check":
219
367
  await runCheck(rest);
220
368
  return;
@@ -222,7 +370,9 @@ const main = async () => {
222
370
  await runGenerate(rest);
223
371
  return;
224
372
  default:
225
- throw new Error("agentos: choose one of build, check, generate");
373
+ throw new Error(
374
+ "agentos: choose one of build, info, serve, dev, eval, preflight, release, consumer, check, generate",
375
+ );
226
376
  }
227
377
  };
228
378