@yansirplus/cli 0.5.17
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/PUBLIC_API.md +22 -0
- package/README.md +34 -0
- package/dist/build/agent-authoring/config.d.ts +177 -0
- package/dist/build/agent-authoring/config.js +607 -0
- package/dist/build/agent-authoring/manifest-compiler.d.ts +159 -0
- package/dist/build/agent-authoring/manifest-compiler.js +737 -0
- package/dist/build/agent-authoring/shared.d.ts +10 -0
- package/dist/build/agent-authoring/shared.js +57 -0
- package/dist/build/agent-authoring/static-target.d.ts +59 -0
- package/dist/build/agent-authoring/static-target.js +1857 -0
- package/dist/build/agent-authoring.d.ts +9 -0
- package/dist/build/agent-authoring.js +5 -0
- package/dist/build/build-cli.d.ts +2 -0
- package/dist/build/build-cli.js +264 -0
- package/dist/check/algorithmic/architecture-checks.mjs +971 -0
- package/dist/check/algorithmic/client-boundary-checks.mjs +337 -0
- package/dist/check/algorithmic/convergence-smoke-checks.mjs +608 -0
- package/dist/check/algorithmic/distribution-checks.mjs +919 -0
- package/dist/check/algorithmic/owner-checks.mjs +647 -0
- package/dist/check/algorithmic/package-boundary-checks.mjs +985 -0
- package/dist/check/algorithmic/projection-boundary-checks.mjs +302 -0
- package/dist/check/algorithmic/repo-surface-checks.mjs +267 -0
- package/dist/check/algorithmic/runtime-structural-checks.mjs +264 -0
- package/dist/check/algorithmic/source-alias-checks.mjs +106 -0
- package/dist/check/algorithmic/static-target-checks.mjs +447 -0
- package/dist/check/algorithmic-checks.mjs +482 -0
- package/dist/check/check-coverage.mjs +231 -0
- package/dist/check/command-runner.mjs +22 -0
- package/dist/check/default-gate.mjs +51 -0
- package/dist/check/gate-selector.mjs +305 -0
- package/dist/check/manifest-rules.mjs +223 -0
- package/dist/check/package-graph.mjs +464 -0
- package/dist/generate/generate-agent-docs.mjs +435 -0
- package/dist/generate/generate-carrier-reference.mjs +514 -0
- package/dist/generate/generate-docs.mjs +345 -0
- package/dist/generate/generate-effect-skill-manifests.mjs +193 -0
- package/dist/generate/project-docs-site.mjs +190 -0
- package/dist/index.d.ts +2 -0
- package/dist/index.js +25 -0
- package/dist/lib/agent-docs-model.mjs +888 -0
- package/dist/lib/boundary-rules.mjs +63 -0
- package/dist/lib/capability-routes.mjs +354 -0
- package/dist/lib/projection-sink.mjs +113 -0
- package/dist/lib/public-api-model.mjs +306 -0
- package/dist/main.mjs +233 -0
- package/dist/runner.mjs +127 -0
- package/package.json +32 -0
|
@@ -0,0 +1,190 @@
|
|
|
1
|
+
#!/usr/bin/env node
|
|
2
|
+
import fs from "node:fs";
|
|
3
|
+
import os from "node:os";
|
|
4
|
+
import path from "node:path";
|
|
5
|
+
import { spawnSync } from "node:child_process";
|
|
6
|
+
|
|
7
|
+
const root = process.cwd();
|
|
8
|
+
const check = process.argv.includes("--check");
|
|
9
|
+
const watch = process.argv.includes("--watch");
|
|
10
|
+
const docsRoot = path.join(root, "docs");
|
|
11
|
+
const targetRoot = path.join(root, "tooling/docs-site/src/content/docs");
|
|
12
|
+
const failures = [];
|
|
13
|
+
|
|
14
|
+
const generatedNotice = (source) =>
|
|
15
|
+
`<!-- generated by packages/cli/src/generate/project-docs-site.mjs; edit ${source} -->`;
|
|
16
|
+
|
|
17
|
+
const walk = (dir) => {
|
|
18
|
+
if (!fs.existsSync(dir)) return [];
|
|
19
|
+
const out = [];
|
|
20
|
+
for (const entry of fs.readdirSync(dir, { withFileTypes: true })) {
|
|
21
|
+
const full = path.join(dir, entry.name);
|
|
22
|
+
if (entry.isDirectory()) {
|
|
23
|
+
out.push(...walk(full));
|
|
24
|
+
continue;
|
|
25
|
+
}
|
|
26
|
+
if (entry.isFile()) out.push(full);
|
|
27
|
+
}
|
|
28
|
+
return out;
|
|
29
|
+
};
|
|
30
|
+
|
|
31
|
+
const slash = (value) => value.replaceAll(path.sep, "/");
|
|
32
|
+
const relRoot = (file) => slash(path.relative(root, file));
|
|
33
|
+
const escapeYaml = (value) => value.replaceAll("\\", "\\\\").replaceAll('"', '\\"');
|
|
34
|
+
|
|
35
|
+
const isProjectedSource = (file) => {
|
|
36
|
+
const rel = slash(path.relative(docsRoot, file));
|
|
37
|
+
if (!file.endsWith(".md")) return false;
|
|
38
|
+
if (rel.startsWith("templates/")) return false;
|
|
39
|
+
return true;
|
|
40
|
+
};
|
|
41
|
+
|
|
42
|
+
const siteRouteForDocsRel = (docsRel, anchor = "") => {
|
|
43
|
+
const normalized = slash(docsRel).replace(/\.md$/u, "");
|
|
44
|
+
if (normalized === "README") return `/${anchor}`;
|
|
45
|
+
return `/${normalized}/${anchor}`;
|
|
46
|
+
};
|
|
47
|
+
|
|
48
|
+
const targetRelForDocsRel = (docsRel) => {
|
|
49
|
+
if (docsRel === "README.md") return "index.md";
|
|
50
|
+
return docsRel;
|
|
51
|
+
};
|
|
52
|
+
|
|
53
|
+
const parseTargetHref = (href, sourceDocsRel) => {
|
|
54
|
+
if (!href.endsWith(".md") && !href.includes(".md#")) return null;
|
|
55
|
+
const [rawPath, rawAnchor] = href.split("#");
|
|
56
|
+
if (!rawPath.endsWith(".md")) return null;
|
|
57
|
+
const sourceDir = path.posix.dirname(sourceDocsRel);
|
|
58
|
+
const targetDocsRel = slash(path.posix.normalize(path.posix.join(sourceDir, rawPath)));
|
|
59
|
+
const anchor = rawAnchor === undefined ? "" : `#${rawAnchor}`;
|
|
60
|
+
return siteRouteForDocsRel(targetDocsRel, anchor);
|
|
61
|
+
};
|
|
62
|
+
|
|
63
|
+
const rewriteLinksForSite = (text, sourceDocsRel) =>
|
|
64
|
+
text.replace(/\[([^\]\n]+)\]\(([^)\s]+)(\s+"[^"]*")?\)/gu, (full, label, href, title = "") => {
|
|
65
|
+
const rewritten = parseTargetHref(href, sourceDocsRel);
|
|
66
|
+
return rewritten === null ? full : `[${label}](${rewritten}${title})`;
|
|
67
|
+
});
|
|
68
|
+
|
|
69
|
+
const projectMarkdown = (sourceFile, options = {}) => {
|
|
70
|
+
const docsRel = slash(path.relative(docsRoot, sourceFile));
|
|
71
|
+
const sourceRel = relRoot(sourceFile);
|
|
72
|
+
const source = fs.readFileSync(sourceFile, "utf8").replace(/\s+$/u, "");
|
|
73
|
+
const h1 = source.match(/^# (.+)$/mu);
|
|
74
|
+
const title = h1?.[1] ?? sourceRel;
|
|
75
|
+
const withoutH1 =
|
|
76
|
+
h1 === null ? source : source.replace(/^# .+\r?\n\r?\n?/u, "").replace(/\s+$/u, "");
|
|
77
|
+
const bodyPrefix = options.bodyPrefix ?? "";
|
|
78
|
+
const body = `${bodyPrefix}${rewriteLinksForSite(withoutH1, docsRel)}`;
|
|
79
|
+
return [
|
|
80
|
+
"---",
|
|
81
|
+
`title: "${escapeYaml(title)}"`,
|
|
82
|
+
"---",
|
|
83
|
+
"",
|
|
84
|
+
generatedNotice(sourceRel),
|
|
85
|
+
"",
|
|
86
|
+
body,
|
|
87
|
+
"",
|
|
88
|
+
].join("\n");
|
|
89
|
+
};
|
|
90
|
+
|
|
91
|
+
const formatProjectedMarkdown = (expected) => {
|
|
92
|
+
const tmpDir = fs.mkdtempSync(path.join(os.tmpdir(), "agent-docs-site-"));
|
|
93
|
+
try {
|
|
94
|
+
for (const [targetRel, content] of expected) {
|
|
95
|
+
const target = path.join(tmpDir, targetRel);
|
|
96
|
+
fs.mkdirSync(path.dirname(target), { recursive: true });
|
|
97
|
+
fs.writeFileSync(target, `${content.replace(/\s+$/u, "")}\n`);
|
|
98
|
+
}
|
|
99
|
+
const result = spawnSync("vp", ["fmt", tmpDir, "--write"], {
|
|
100
|
+
cwd: root,
|
|
101
|
+
encoding: "utf8",
|
|
102
|
+
});
|
|
103
|
+
if (result.status !== 0) {
|
|
104
|
+
failures.push(
|
|
105
|
+
`docs-site projection formatting failed: ${result.stderr || result.stdout || result.status}`,
|
|
106
|
+
);
|
|
107
|
+
return expected;
|
|
108
|
+
}
|
|
109
|
+
const formatted = new Map();
|
|
110
|
+
for (const targetRel of expected.keys()) {
|
|
111
|
+
formatted.set(targetRel, fs.readFileSync(path.join(tmpDir, targetRel), "utf8"));
|
|
112
|
+
}
|
|
113
|
+
return formatted;
|
|
114
|
+
} finally {
|
|
115
|
+
fs.rmSync(tmpDir, { recursive: true, force: true });
|
|
116
|
+
}
|
|
117
|
+
};
|
|
118
|
+
|
|
119
|
+
const removeEmptyDirs = (dir) => {
|
|
120
|
+
if (!fs.existsSync(dir)) return;
|
|
121
|
+
for (const entry of fs.readdirSync(dir, { withFileTypes: true })) {
|
|
122
|
+
if (entry.isDirectory()) removeEmptyDirs(path.join(dir, entry.name));
|
|
123
|
+
}
|
|
124
|
+
if (dir !== targetRoot && fs.readdirSync(dir).length === 0) fs.rmdirSync(dir);
|
|
125
|
+
};
|
|
126
|
+
|
|
127
|
+
const project = () => {
|
|
128
|
+
failures.length = 0;
|
|
129
|
+
const sources = walk(docsRoot).filter(isProjectedSource).sort();
|
|
130
|
+
const expected = new Map();
|
|
131
|
+
|
|
132
|
+
for (const source of sources) {
|
|
133
|
+
const docsRel = slash(path.relative(docsRoot, source));
|
|
134
|
+
const targetRel = targetRelForDocsRel(docsRel);
|
|
135
|
+
expected.set(targetRel, projectMarkdown(source));
|
|
136
|
+
}
|
|
137
|
+
const formattedExpected = formatProjectedMarkdown(expected);
|
|
138
|
+
|
|
139
|
+
for (const [targetRel, content] of formattedExpected) {
|
|
140
|
+
const target = path.join(targetRoot, targetRel);
|
|
141
|
+
const expectedText = `${content.replace(/\s+$/u, "")}\n`;
|
|
142
|
+
if (check) {
|
|
143
|
+
const actual = fs.existsSync(target) ? fs.readFileSync(target, "utf8") : "";
|
|
144
|
+
if (actual !== expectedText) failures.push(`${slash(path.relative(root, target))} is stale`);
|
|
145
|
+
continue;
|
|
146
|
+
}
|
|
147
|
+
fs.mkdirSync(path.dirname(target), { recursive: true });
|
|
148
|
+
fs.writeFileSync(target, expectedText);
|
|
149
|
+
}
|
|
150
|
+
|
|
151
|
+
const actualTargets = walk(targetRoot)
|
|
152
|
+
.filter((file) => file.endsWith(".md"))
|
|
153
|
+
.map((file) => slash(path.relative(targetRoot, file)))
|
|
154
|
+
.sort();
|
|
155
|
+
for (const targetRel of actualTargets) {
|
|
156
|
+
if (!formattedExpected.has(targetRel)) {
|
|
157
|
+
const target = path.join(targetRoot, targetRel);
|
|
158
|
+
if (check) {
|
|
159
|
+
failures.push(`${slash(path.relative(root, target))} is stale extra projection`);
|
|
160
|
+
} else {
|
|
161
|
+
fs.rmSync(target);
|
|
162
|
+
}
|
|
163
|
+
}
|
|
164
|
+
}
|
|
165
|
+
if (!check) removeEmptyDirs(targetRoot);
|
|
166
|
+
|
|
167
|
+
if (failures.length > 0) {
|
|
168
|
+
console.error(failures.join("\n"));
|
|
169
|
+
process.exitCode = 1;
|
|
170
|
+
return false;
|
|
171
|
+
}
|
|
172
|
+
|
|
173
|
+
console.log(`projected docs site content for ${expected.size} pages`);
|
|
174
|
+
return true;
|
|
175
|
+
};
|
|
176
|
+
|
|
177
|
+
project();
|
|
178
|
+
|
|
179
|
+
if (watch) {
|
|
180
|
+
console.log("watching docs/** for docs-site projection changes");
|
|
181
|
+
let timer = null;
|
|
182
|
+
const schedule = () => {
|
|
183
|
+
if (timer !== null) clearTimeout(timer);
|
|
184
|
+
timer = setTimeout(() => {
|
|
185
|
+
timer = null;
|
|
186
|
+
project();
|
|
187
|
+
}, 100);
|
|
188
|
+
};
|
|
189
|
+
fs.watch(docsRoot, { recursive: true }, schedule);
|
|
190
|
+
}
|
package/dist/index.d.ts
ADDED
package/dist/index.js
ADDED
|
@@ -0,0 +1,25 @@
|
|
|
1
|
+
import { compileAgentTree as compileAgentTreeImpl, linkWorkspaceStaticTarget as linkWorkspaceStaticTargetImpl, } from "./build/agent-authoring.js";
|
|
2
|
+
/**
|
|
3
|
+
* Compile an authored `agent/` tree into one normalized manifest plus
|
|
4
|
+
* provenance. Runtime facts and provider material are rejected before they can
|
|
5
|
+
* become manifest truth.
|
|
6
|
+
*
|
|
7
|
+
* @agentosPrimitive primitive.agent-authoring.compileAgentTree
|
|
8
|
+
* @agentosInvariant invariant.docs.agent-projection
|
|
9
|
+
* @agentosInvariant invariant.algebra.single-code-source
|
|
10
|
+
* @agentosDocs docs/guides/build-natural-language-workspace-agent.md
|
|
11
|
+
* @public
|
|
12
|
+
*/
|
|
13
|
+
export const compileAgentTree = compileAgentTreeImpl;
|
|
14
|
+
/**
|
|
15
|
+
* Link normalized workspace authoring intent to a closed-target residual
|
|
16
|
+
* program. Implementation wiring is static imports and factory composition;
|
|
17
|
+
* manifest and deployment JSON remain semantic/provenance data only.
|
|
18
|
+
*
|
|
19
|
+
* @agentosPrimitive primitive.agent-authoring.linkWorkspaceStaticTarget
|
|
20
|
+
* @agentosInvariant invariant.docs.agent-projection
|
|
21
|
+
* @agentosInvariant invariant.algebra.single-code-source
|
|
22
|
+
* @agentosDocs docs/guides/build-natural-language-workspace-agent.md
|
|
23
|
+
* @public
|
|
24
|
+
*/
|
|
25
|
+
export const linkWorkspaceStaticTarget = linkWorkspaceStaticTargetImpl;
|