@aaac/toolchain 0.1.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 ADDED
@@ -0,0 +1,178 @@
1
+ # @aaac/toolchain
2
+
3
+ Artifact-bound toolchain declarations — defines which tools operate on which artifacts.
4
+
5
+ ## Install
6
+
7
+ ```bash
8
+ npm install @aaac/toolchain
9
+ ```
10
+
11
+ ## What it does
12
+
13
+ `toolchain-contracts` is a declarative contract layer that binds **tools → artifacts**. Each toolchain entry declares what it consumes and produces, enabling static validation and dataflow lint across artifact-contracts, agent-contracts, and toolchain-contracts.
14
+
15
+ ## Quick Start
16
+
17
+ Create `toolchain-contracts.yaml`:
18
+
19
+ ```yaml
20
+ schema: aaac/toolchain/0.1
21
+
22
+ system:
23
+ id: my-project
24
+
25
+ toolchains:
26
+ prettier:
27
+ kind: library
28
+ module: prettier
29
+ artifacts:
30
+ consumes: [source-code]
31
+ produces: [source-code]
32
+ operations: [format]
33
+
34
+ eslint:
35
+ kind: cli
36
+ command: npx eslint --fix
37
+ artifacts:
38
+ consumes: [source-code]
39
+ produces: [source-code]
40
+
41
+ speckeeper:
42
+ kind: component
43
+ component_contract: ./speckeeper.component.yaml
44
+ artifacts:
45
+ consumes: [spec-md, codebase]
46
+ produces: [conformance-report]
47
+ ```
48
+
49
+ Validate it:
50
+
51
+ ```bash
52
+ npx aaac-toolchain validate toolchain-contracts.yaml
53
+ ```
54
+
55
+ ## DSL Schema
56
+
57
+ | Field | Description |
58
+ |-------|-------------|
59
+ | `schema` | Schema version (e.g. `aaac/toolchain/0.1`) |
60
+ | `system` | Project identity (`id`, optional `name`) |
61
+ | `toolchains` | Map of toolchain ID → toolchain definition |
62
+
63
+ Each toolchain entry:
64
+
65
+ | Field | Description |
66
+ |-------|-------------|
67
+ | `kind` | Binding type: `library`, `cli`, or `component` |
68
+ | `module` | npm package name (required for `library`) |
69
+ | `command` | Shell command (for `cli` when no `cli_contract`) |
70
+ | `cli_contract` | Path to cli-contracts YAML (alternative for `cli`) |
71
+ | `component_contract` | Path to component contract YAML (required for `component`) |
72
+ | `artifacts` | `consumes` and `produces` artifact IDs |
73
+ | `operations` | Optional operation names (e.g. `format`, `lint`) |
74
+
75
+ ## Kind types
76
+
77
+ | Kind | Meaning | Required field |
78
+ |------|---------|----------------|
79
+ | `library` | npm package invoked programmatically | `module` |
80
+ | `cli` | External CLI tool | `command` or `cli_contract` |
81
+ | `component` | AAAC component with its own contract | `component_contract` |
82
+
83
+ ## `$refs`
84
+
85
+ Split toolchain definitions across files using `$refs`:
86
+
87
+ ```yaml
88
+ schema: aaac/toolchain/0.1
89
+
90
+ system:
91
+ id: my-project
92
+
93
+ toolchains:
94
+ inline-tool:
95
+ kind: library
96
+ module: inline-lib
97
+ artifacts:
98
+ consumes: [source-code]
99
+
100
+ $refs:
101
+ - ./formatting.yaml
102
+ - ./linting.yaml
103
+ ```
104
+
105
+ Referenced files contain additional `toolchains` entries that are merged into the root document. Duplicate toolchain IDs across files are rejected.
106
+
107
+ ## CLI Commands
108
+
109
+ ### `aaac-toolchain validate`
110
+
111
+ Validate schema and semantic rules for a toolchain-contracts file.
112
+
113
+ ```bash
114
+ npx aaac-toolchain validate toolchain-contracts.yaml
115
+
116
+ # Optional: check artifact IDs against a known set
117
+ npx aaac-toolchain validate toolchain-contracts.yaml \
118
+ --artifact-ids source-code spec-md codebase conformance-report
119
+ ```
120
+
121
+ ### `aaac-toolchain lint`
122
+
123
+ Check dataflow integrity across contract layers.
124
+
125
+ ```bash
126
+ npx aaac-toolchain lint toolchain-contracts.yaml \
127
+ --artifact-contracts artifact-contracts.yaml \
128
+ --agent-contracts agent-contracts.yaml
129
+ ```
130
+
131
+ ### Exit codes
132
+
133
+ | Code | Meaning |
134
+ |-----:|---------|
135
+ | 0 | All checks pass |
136
+ | 1 | Validation or lint issues found |
137
+ | 2 | File read or schema error |
138
+
139
+ ## Library API
140
+
141
+ ```typescript
142
+ import {
143
+ loadToolchainContracts,
144
+ parseToolchainFile,
145
+ validateToolchainContracts,
146
+ lintDataflow,
147
+ } from "@aaac/toolchain";
148
+
149
+ // Load and parse (resolves $refs)
150
+ const doc = await loadToolchainContracts("./toolchain-contracts.yaml");
151
+
152
+ // Validate
153
+ const issues = validateToolchainContracts(doc, {
154
+ artifactIds: ["source-code", "spec-md"],
155
+ });
156
+
157
+ // Lint dataflow against other contract layers
158
+ const lintIssues = lintDataflow(doc, {
159
+ artifacts: [{ id: "source-code", derived_from: [] }],
160
+ agents: [{ id: "reviewer", consumes: ["source-code"], produces: ["review-report"] }],
161
+ });
162
+ ```
163
+
164
+ | Function | Description |
165
+ |----------|-------------|
166
+ | `loadToolchainContracts` | Load YAML file, resolve `$refs`, validate schema |
167
+ | `parseToolchainFile` | Parse file without `$ref` resolution |
168
+ | `validateToolchainContracts` | Semantic validation (artifact IDs, duplicates) |
169
+ | `lintDataflow` | Cross-contract dataflow integrity checks |
170
+
171
+ ## Related packages
172
+
173
+ - [`@aaac/contracts`](../contracts/) — Component contract compiler and code generators
174
+ - [`@aaac/runtime`](../runtime/) — Runtime SDK for executing AAAC workflows
175
+
176
+ ## License
177
+
178
+ MIT — see [LICENSE](../../LICENSE).
@@ -0,0 +1,383 @@
1
+ // src/schema.ts
2
+ import { z } from "zod";
3
+ var SCHEMA_VERSION_PATTERN = /^aaac\/toolchain\/\d+\.\d+$/;
4
+ var SUPPORTED_SCHEMA_VERSIONS = ["aaac/toolchain/0.1"];
5
+ var SystemSchema = z.object({
6
+ id: z.string().min(1),
7
+ name: z.string().optional()
8
+ });
9
+ var ArtifactsSchema = z.object({
10
+ consumes: z.array(z.string()).default([]),
11
+ produces: z.array(z.string()).default([])
12
+ });
13
+ var ToolchainKindSchema = z.enum(["library", "cli", "component"]);
14
+ var ToolchainSchema = z.object({
15
+ kind: ToolchainKindSchema,
16
+ description: z.string().optional(),
17
+ module: z.string().optional(),
18
+ command: z.string().optional(),
19
+ cli_contract: z.string().optional(),
20
+ component_contract: z.string().optional(),
21
+ artifacts: ArtifactsSchema.default({ consumes: [], produces: [] }),
22
+ operations: z.array(z.string()).optional()
23
+ }).superRefine((tc, ctx) => {
24
+ if (tc.kind === "library" && !tc.module) {
25
+ ctx.addIssue({
26
+ code: "custom",
27
+ message: "module is required for kind: library",
28
+ path: ["module"]
29
+ });
30
+ }
31
+ if (tc.kind === "cli" && !tc.cli_contract && !tc.command) {
32
+ ctx.addIssue({
33
+ code: "custom",
34
+ message: "cli_contract or command is required for kind: cli",
35
+ path: ["cli_contract"]
36
+ });
37
+ }
38
+ if (tc.kind === "component" && !tc.component_contract) {
39
+ ctx.addIssue({
40
+ code: "custom",
41
+ message: "component_contract is required for kind: component",
42
+ path: ["component_contract"]
43
+ });
44
+ }
45
+ });
46
+ var ToolchainContractsSchema = z.object({
47
+ schema: z.string().regex(SCHEMA_VERSION_PATTERN, 'schema must match pattern "aaac/toolchain/x.y"'),
48
+ system: SystemSchema,
49
+ toolchains: z.record(z.string(), ToolchainSchema)
50
+ });
51
+
52
+ // src/errors.ts
53
+ var ToolchainParseError = class extends Error {
54
+ constructor(message, filePath, cause) {
55
+ super(filePath ? `${filePath}: ${message}` : message);
56
+ this.filePath = filePath;
57
+ this.cause = cause;
58
+ this.name = "ToolchainParseError";
59
+ }
60
+ filePath;
61
+ cause;
62
+ };
63
+ var ToolchainValidationError = class extends Error {
64
+ constructor(message, issues = []) {
65
+ super(message);
66
+ this.issues = issues;
67
+ this.name = "ToolchainValidationError";
68
+ }
69
+ issues;
70
+ };
71
+
72
+ // src/loader.ts
73
+ import { readFileSync } from "fs";
74
+ import { readFile } from "fs/promises";
75
+ import { resolve, dirname } from "path";
76
+ import { parse as parseYaml } from "yaml";
77
+ function formatZodError(error, filePath) {
78
+ const prefix = filePath ? `${filePath}: ` : "";
79
+ const details = error.issues.map((issue) => {
80
+ const path = issue.path.length > 0 ? issue.path.join(".") : "(root)";
81
+ return `${path}: ${issue.message}`;
82
+ }).join("; ");
83
+ return `${prefix}Validation failed: ${details}`;
84
+ }
85
+ function validateRaw(raw, filePath) {
86
+ const result = ToolchainContractsSchema.safeParse(raw);
87
+ if (!result.success) {
88
+ throw new ToolchainParseError(
89
+ formatZodError(result.error, filePath),
90
+ filePath,
91
+ result.error
92
+ );
93
+ }
94
+ return result.data;
95
+ }
96
+ function resolveRefsInDocument(raw, options, visited = /* @__PURE__ */ new Set()) {
97
+ const refs = raw.$refs;
98
+ if (!refs || !Array.isArray(refs)) {
99
+ return raw;
100
+ }
101
+ const result = { ...raw };
102
+ delete result.$refs;
103
+ const mergedToolchains = {
104
+ ...result.toolchains || {}
105
+ };
106
+ for (const refPath of refs) {
107
+ if (typeof refPath !== "string") continue;
108
+ const absPath = resolve(options.basePath, refPath);
109
+ if (visited.has(absPath)) {
110
+ throw new ToolchainParseError(
111
+ `Circular $refs detected: ${refPath}`,
112
+ absPath
113
+ );
114
+ }
115
+ visited.add(absPath);
116
+ let content;
117
+ try {
118
+ content = readFileSync(absPath, "utf-8");
119
+ } catch (err) {
120
+ throw new ToolchainParseError(
121
+ `Cannot read $refs file: ${err.message}`,
122
+ absPath,
123
+ err
124
+ );
125
+ }
126
+ let refData;
127
+ try {
128
+ refData = parseYaml(content);
129
+ } catch (err) {
130
+ throw new ToolchainParseError(
131
+ `Invalid YAML in $refs file: ${err.message}`,
132
+ absPath,
133
+ err
134
+ );
135
+ }
136
+ if (!refData || typeof refData !== "object") {
137
+ throw new ToolchainParseError(
138
+ `$refs file must contain a YAML object`,
139
+ absPath
140
+ );
141
+ }
142
+ if (refData.$refs) {
143
+ refData = resolveRefsInDocument(
144
+ refData,
145
+ { basePath: dirname(absPath) },
146
+ visited
147
+ );
148
+ }
149
+ for (const [id, value] of Object.entries(refData)) {
150
+ if (id === "$refs") continue;
151
+ if (id in mergedToolchains) {
152
+ throw new ToolchainParseError(
153
+ `Duplicate toolchain ID "${id}" found in $refs file: ${refPath}`,
154
+ absPath
155
+ );
156
+ }
157
+ mergedToolchains[id] = value;
158
+ }
159
+ visited.delete(absPath);
160
+ }
161
+ result.toolchains = mergedToolchains;
162
+ return result;
163
+ }
164
+ function parseToolchainString(content, filePath) {
165
+ let raw;
166
+ try {
167
+ raw = parseYaml(content);
168
+ } catch (err) {
169
+ throw new ToolchainParseError(
170
+ `Invalid YAML: ${err.message}`,
171
+ filePath,
172
+ err
173
+ );
174
+ }
175
+ return validateRaw(raw, filePath);
176
+ }
177
+ async function parseToolchainFile(filePath) {
178
+ let content;
179
+ try {
180
+ content = await readFile(filePath, "utf-8");
181
+ } catch (err) {
182
+ throw new ToolchainParseError(
183
+ `Cannot read file: ${err.message}`,
184
+ filePath,
185
+ err
186
+ );
187
+ }
188
+ return parseToolchainString(content, filePath);
189
+ }
190
+ async function loadToolchainContracts(filePath) {
191
+ let content;
192
+ try {
193
+ content = await readFile(filePath, "utf-8");
194
+ } catch (err) {
195
+ throw new ToolchainParseError(
196
+ `Cannot read file: ${err.message}`,
197
+ filePath,
198
+ err
199
+ );
200
+ }
201
+ let raw;
202
+ try {
203
+ raw = parseYaml(content);
204
+ } catch (err) {
205
+ throw new ToolchainParseError(
206
+ `Invalid YAML: ${err.message}`,
207
+ filePath,
208
+ err
209
+ );
210
+ }
211
+ if (!raw || typeof raw !== "object") {
212
+ throw new ToolchainParseError(
213
+ "Document must be a YAML object",
214
+ filePath
215
+ );
216
+ }
217
+ const resolved = resolveRefsInDocument(raw, {
218
+ basePath: dirname(resolve(filePath))
219
+ });
220
+ return validateRaw(resolved, filePath);
221
+ }
222
+
223
+ // src/validator.ts
224
+ function validateToolchainContracts(doc, options = {}) {
225
+ const issues = [];
226
+ const knownIds = options.artifactIds ? new Set(options.artifactIds) : void 0;
227
+ for (const [id, tc] of Object.entries(doc.toolchains)) {
228
+ if (knownIds) {
229
+ for (const artifactId of tc.artifacts.consumes) {
230
+ if (!knownIds.has(artifactId)) {
231
+ issues.push({
232
+ code: "unknown-artifact-id",
233
+ message: `Toolchain "${id}" consumes unknown artifact "${artifactId}"`,
234
+ path: ["toolchains", id, "artifacts", "consumes"],
235
+ severity: "error"
236
+ });
237
+ }
238
+ }
239
+ for (const artifactId of tc.artifacts.produces) {
240
+ if (!knownIds.has(artifactId)) {
241
+ issues.push({
242
+ code: "unknown-artifact-id",
243
+ message: `Toolchain "${id}" produces unknown artifact "${artifactId}"`,
244
+ path: ["toolchains", id, "artifacts", "produces"],
245
+ severity: "error"
246
+ });
247
+ }
248
+ }
249
+ }
250
+ if (tc.artifacts.consumes.length === 0 && tc.artifacts.produces.length === 0) {
251
+ issues.push({
252
+ code: "no-artifact-binding",
253
+ message: `Toolchain "${id}" has no artifact bindings (both consumes and produces are empty)`,
254
+ path: ["toolchains", id, "artifacts"],
255
+ severity: "warning"
256
+ });
257
+ }
258
+ }
259
+ return issues;
260
+ }
261
+ function assertValid(doc, options = {}) {
262
+ const issues = validateToolchainContracts(doc, options);
263
+ const errors = issues.filter((i) => i.severity === "error");
264
+ if (errors.length > 0) {
265
+ throw new ToolchainValidationError(
266
+ `Validation failed with ${errors.length} error(s): ${errors.map((e) => e.message).join("; ")}`,
267
+ issues
268
+ );
269
+ }
270
+ }
271
+
272
+ // src/linter.ts
273
+ function lintDataflow(toolchainDoc, options = {}) {
274
+ const issues = [];
275
+ const artifactMap = new Map((options.artifacts ?? []).map((a) => [a.id, a]));
276
+ const allArtifactIds = new Set(artifactMap.keys());
277
+ const producerMap = /* @__PURE__ */ new Map();
278
+ const consumerMap = /* @__PURE__ */ new Map();
279
+ for (const [tcId, tc] of Object.entries(toolchainDoc.toolchains)) {
280
+ for (const artifactId of tc.artifacts.produces) {
281
+ if (!producerMap.has(artifactId)) producerMap.set(artifactId, []);
282
+ producerMap.get(artifactId).push(`toolchain:${tcId}`);
283
+ }
284
+ for (const artifactId of tc.artifacts.consumes) {
285
+ if (!consumerMap.has(artifactId)) consumerMap.set(artifactId, []);
286
+ consumerMap.get(artifactId).push(`toolchain:${tcId}`);
287
+ }
288
+ }
289
+ for (const agent of options.agents ?? []) {
290
+ for (const artifactId of agent.produces ?? []) {
291
+ if (!producerMap.has(artifactId)) producerMap.set(artifactId, []);
292
+ producerMap.get(artifactId).push(`agent:${agent.id}`);
293
+ }
294
+ for (const artifactId of agent.consumes ?? []) {
295
+ if (!consumerMap.has(artifactId)) consumerMap.set(artifactId, []);
296
+ consumerMap.get(artifactId).push(`agent:${agent.id}`);
297
+ }
298
+ }
299
+ for (const artifact of options.artifacts ?? []) {
300
+ if (artifact.derived_from && artifact.derived_from.length > 0) {
301
+ if (!producerMap.has(artifact.id)) {
302
+ issues.push({
303
+ code: "producer-absent",
304
+ message: `Artifact "${artifact.id}" has derived_from [${artifact.derived_from.join(", ")}] but no toolchain or agent produces it`,
305
+ path: ["artifacts", artifact.id],
306
+ severity: "error"
307
+ });
308
+ }
309
+ }
310
+ }
311
+ for (const [artifactId, producers] of producerMap) {
312
+ if (!consumerMap.has(artifactId)) {
313
+ issues.push({
314
+ code: "consumer-absent",
315
+ message: `Artifact "${artifactId}" is produced by ${producers.join(", ")} but nobody consumes it`,
316
+ path: ["toolchains"],
317
+ severity: "warning"
318
+ });
319
+ }
320
+ }
321
+ for (const artifact of options.artifacts ?? []) {
322
+ if (!artifact.derived_from || artifact.derived_from.length === 0) continue;
323
+ const producers = producerMap.get(artifact.id) ?? [];
324
+ for (const producerName of producers) {
325
+ for (const sourceId of artifact.derived_from) {
326
+ const [type, id] = producerName.split(":", 2);
327
+ let producerConsumes = [];
328
+ if (type === "toolchain") {
329
+ const tc = toolchainDoc.toolchains[id];
330
+ if (tc) producerConsumes = tc.artifacts.consumes;
331
+ } else if (type === "agent") {
332
+ const agent = options.agents?.find((a) => a.id === id);
333
+ if (agent) producerConsumes = agent.consumes ?? [];
334
+ }
335
+ if (!producerConsumes.includes(sourceId)) {
336
+ issues.push({
337
+ code: "dataflow-inconsistency",
338
+ message: `${producerName} produces "${artifact.id}" (derived_from: "${sourceId}") but does not consume "${sourceId}"`,
339
+ path: ["toolchains", id],
340
+ severity: "error"
341
+ });
342
+ }
343
+ }
344
+ }
345
+ }
346
+ if (allArtifactIds.size > 0) {
347
+ for (const [tcId, tc] of Object.entries(toolchainDoc.toolchains)) {
348
+ for (const artifactId of [
349
+ ...tc.artifacts.consumes,
350
+ ...tc.artifacts.produces
351
+ ]) {
352
+ if (!allArtifactIds.has(artifactId)) {
353
+ issues.push({
354
+ code: "undefined-artifact",
355
+ message: `Toolchain "${tcId}" references undefined artifact "${artifactId}"`,
356
+ path: ["toolchains", tcId, "artifacts"],
357
+ severity: "error"
358
+ });
359
+ }
360
+ }
361
+ }
362
+ }
363
+ return issues;
364
+ }
365
+
366
+ export {
367
+ SCHEMA_VERSION_PATTERN,
368
+ SUPPORTED_SCHEMA_VERSIONS,
369
+ SystemSchema,
370
+ ArtifactsSchema,
371
+ ToolchainKindSchema,
372
+ ToolchainSchema,
373
+ ToolchainContractsSchema,
374
+ ToolchainParseError,
375
+ ToolchainValidationError,
376
+ parseToolchainString,
377
+ parseToolchainFile,
378
+ loadToolchainContracts,
379
+ validateToolchainContracts,
380
+ assertValid,
381
+ lintDataflow
382
+ };
383
+ //# sourceMappingURL=chunk-MMMN4A7Z.js.map
@@ -0,0 +1 @@
1
+ {"version":3,"sources":["../src/schema.ts","../src/errors.ts","../src/loader.ts","../src/validator.ts","../src/linter.ts"],"sourcesContent":["import { z } from \"zod\";\n\nexport const SCHEMA_VERSION_PATTERN = /^aaac\\/toolchain\\/\\d+\\.\\d+$/;\nexport const SUPPORTED_SCHEMA_VERSIONS = [\"aaac/toolchain/0.1\"] as const;\n\nconst SystemSchema = z.object({\n id: z.string().min(1),\n name: z.string().optional(),\n});\n\nconst ArtifactsSchema = z.object({\n consumes: z.array(z.string()).default([]),\n produces: z.array(z.string()).default([]),\n});\n\nconst ToolchainKindSchema = z.enum([\"library\", \"cli\", \"component\"]);\n\nconst ToolchainSchema = z\n .object({\n kind: ToolchainKindSchema,\n description: z.string().optional(),\n module: z.string().optional(),\n command: z.string().optional(),\n cli_contract: z.string().optional(),\n component_contract: z.string().optional(),\n artifacts: ArtifactsSchema.default({ consumes: [], produces: [] }),\n operations: z.array(z.string()).optional(),\n })\n .superRefine((tc, ctx) => {\n if (tc.kind === \"library\" && !tc.module) {\n ctx.addIssue({\n code: \"custom\",\n message: \"module is required for kind: library\",\n path: [\"module\"],\n });\n }\n if (tc.kind === \"cli\" && !tc.cli_contract && !tc.command) {\n ctx.addIssue({\n code: \"custom\",\n message: \"cli_contract or command is required for kind: cli\",\n path: [\"cli_contract\"],\n });\n }\n if (tc.kind === \"component\" && !tc.component_contract) {\n ctx.addIssue({\n code: \"custom\",\n message: \"component_contract is required for kind: component\",\n path: [\"component_contract\"],\n });\n }\n });\n\nexport const ToolchainContractsSchema = z.object({\n schema: z.string().regex(SCHEMA_VERSION_PATTERN, 'schema must match pattern \"aaac/toolchain/x.y\"'),\n system: SystemSchema,\n toolchains: z.record(z.string(), ToolchainSchema),\n});\n\nexport type ToolchainContractsDSL = z.infer<typeof ToolchainContractsSchema>;\nexport type ToolchainDSL = z.infer<typeof ToolchainSchema>;\nexport type ToolchainKind = z.infer<typeof ToolchainKindSchema>;\n\nexport { SystemSchema, ToolchainSchema, ArtifactsSchema, ToolchainKindSchema };\n","export class ToolchainParseError extends Error {\n constructor(\n message: string,\n public readonly filePath?: string,\n public readonly cause?: unknown,\n ) {\n super(filePath ? `${filePath}: ${message}` : message);\n this.name = \"ToolchainParseError\";\n }\n}\n\nexport class ToolchainValidationError extends Error {\n constructor(\n message: string,\n public readonly issues: ValidationIssue[] = [],\n ) {\n super(message);\n this.name = \"ToolchainValidationError\";\n }\n}\n\nexport interface ValidationIssue {\n code: string;\n message: string;\n path?: string[];\n severity: \"error\" | \"warning\";\n}\n","import { readFileSync } from \"node:fs\";\nimport { readFile } from \"node:fs/promises\";\nimport { resolve, dirname } from \"node:path\";\nimport { parse as parseYaml } from \"yaml\";\nimport { ZodError } from \"zod\";\nimport { ToolchainContractsSchema, type ToolchainContractsDSL } from \"./schema.js\";\nimport { ToolchainParseError } from \"./errors.js\";\n\ninterface RefsResolutionOptions {\n basePath: string;\n}\n\nfunction formatZodError(error: ZodError, filePath?: string): string {\n const prefix = filePath ? `${filePath}: ` : \"\";\n const details = error.issues\n .map((issue) => {\n const path = issue.path.length > 0 ? issue.path.join(\".\") : \"(root)\";\n return `${path}: ${issue.message}`;\n })\n .join(\"; \");\n return `${prefix}Validation failed: ${details}`;\n}\n\nfunction validateRaw(\n raw: unknown,\n filePath?: string,\n): ToolchainContractsDSL {\n const result = ToolchainContractsSchema.safeParse(raw);\n if (!result.success) {\n throw new ToolchainParseError(\n formatZodError(result.error, filePath),\n filePath,\n result.error,\n );\n }\n return result.data;\n}\n\nfunction resolveRefsInDocument(\n raw: Record<string, unknown>,\n options: RefsResolutionOptions,\n visited: Set<string> = new Set(),\n): Record<string, unknown> {\n const refs = raw.$refs;\n if (!refs || !Array.isArray(refs)) {\n return raw;\n }\n\n const result = { ...raw };\n delete result.$refs;\n\n const mergedToolchains: Record<string, unknown> = {\n ...((result.toolchains as Record<string, unknown>) || {}),\n };\n\n for (const refPath of refs) {\n if (typeof refPath !== \"string\") continue;\n\n const absPath = resolve(options.basePath, refPath);\n\n if (visited.has(absPath)) {\n throw new ToolchainParseError(\n `Circular $refs detected: ${refPath}`,\n absPath,\n );\n }\n visited.add(absPath);\n\n let content: string;\n try {\n content = readFileSync(absPath, \"utf-8\");\n } catch (err) {\n throw new ToolchainParseError(\n `Cannot read $refs file: ${(err as Error).message}`,\n absPath,\n err,\n );\n }\n\n let refData: Record<string, unknown>;\n try {\n refData = parseYaml(content) as Record<string, unknown>;\n } catch (err) {\n throw new ToolchainParseError(\n `Invalid YAML in $refs file: ${(err as Error).message}`,\n absPath,\n err,\n );\n }\n\n if (!refData || typeof refData !== \"object\") {\n throw new ToolchainParseError(\n `$refs file must contain a YAML object`,\n absPath,\n );\n }\n\n if (refData.$refs) {\n refData = resolveRefsInDocument(\n refData,\n { basePath: dirname(absPath) },\n visited,\n ) as Record<string, unknown>;\n }\n\n for (const [id, value] of Object.entries(refData)) {\n if (id === \"$refs\") continue;\n if (id in mergedToolchains) {\n throw new ToolchainParseError(\n `Duplicate toolchain ID \"${id}\" found in $refs file: ${refPath}`,\n absPath,\n );\n }\n mergedToolchains[id] = value;\n }\n\n visited.delete(absPath);\n }\n\n result.toolchains = mergedToolchains;\n return result;\n}\n\nexport function parseToolchainString(\n content: string,\n filePath?: string,\n): ToolchainContractsDSL {\n let raw: unknown;\n try {\n raw = parseYaml(content);\n } catch (err) {\n throw new ToolchainParseError(\n `Invalid YAML: ${(err as Error).message}`,\n filePath,\n err,\n );\n }\n\n return validateRaw(raw, filePath);\n}\n\nexport async function parseToolchainFile(\n filePath: string,\n): Promise<ToolchainContractsDSL> {\n let content: string;\n try {\n content = await readFile(filePath, \"utf-8\");\n } catch (err) {\n throw new ToolchainParseError(\n `Cannot read file: ${(err as Error).message}`,\n filePath,\n err,\n );\n }\n return parseToolchainString(content, filePath);\n}\n\nexport async function loadToolchainContracts(\n filePath: string,\n): Promise<ToolchainContractsDSL> {\n let content: string;\n try {\n content = await readFile(filePath, \"utf-8\");\n } catch (err) {\n throw new ToolchainParseError(\n `Cannot read file: ${(err as Error).message}`,\n filePath,\n err,\n );\n }\n\n let raw: unknown;\n try {\n raw = parseYaml(content);\n } catch (err) {\n throw new ToolchainParseError(\n `Invalid YAML: ${(err as Error).message}`,\n filePath,\n err,\n );\n }\n\n if (!raw || typeof raw !== \"object\") {\n throw new ToolchainParseError(\n \"Document must be a YAML object\",\n filePath,\n );\n }\n\n const resolved = resolveRefsInDocument(raw as Record<string, unknown>, {\n basePath: dirname(resolve(filePath)),\n });\n\n return validateRaw(resolved, filePath);\n}\n","import type { ToolchainContractsDSL } from \"./schema.js\";\nimport { ToolchainValidationError, type ValidationIssue } from \"./errors.js\";\n\nexport interface ValidateOptions {\n /** Known artifact IDs (from artifact-contracts) */\n artifactIds?: string[];\n}\n\nexport function validateToolchainContracts(\n doc: ToolchainContractsDSL,\n options: ValidateOptions = {},\n): ValidationIssue[] {\n const issues: ValidationIssue[] = [];\n const knownIds = options.artifactIds\n ? new Set(options.artifactIds)\n : undefined;\n\n for (const [id, tc] of Object.entries(doc.toolchains)) {\n if (knownIds) {\n for (const artifactId of tc.artifacts.consumes) {\n if (!knownIds.has(artifactId)) {\n issues.push({\n code: \"unknown-artifact-id\",\n message: `Toolchain \"${id}\" consumes unknown artifact \"${artifactId}\"`,\n path: [\"toolchains\", id, \"artifacts\", \"consumes\"],\n severity: \"error\",\n });\n }\n }\n for (const artifactId of tc.artifacts.produces) {\n if (!knownIds.has(artifactId)) {\n issues.push({\n code: \"unknown-artifact-id\",\n message: `Toolchain \"${id}\" produces unknown artifact \"${artifactId}\"`,\n path: [\"toolchains\", id, \"artifacts\", \"produces\"],\n severity: \"error\",\n });\n }\n }\n }\n\n if (\n tc.artifacts.consumes.length === 0 &&\n tc.artifacts.produces.length === 0\n ) {\n issues.push({\n code: \"no-artifact-binding\",\n message: `Toolchain \"${id}\" has no artifact bindings (both consumes and produces are empty)`,\n path: [\"toolchains\", id, \"artifacts\"],\n severity: \"warning\",\n });\n }\n }\n\n return issues;\n}\n\nexport function assertValid(\n doc: ToolchainContractsDSL,\n options: ValidateOptions = {},\n): void {\n const issues = validateToolchainContracts(doc, options);\n const errors = issues.filter((i) => i.severity === \"error\");\n if (errors.length > 0) {\n throw new ToolchainValidationError(\n `Validation failed with ${errors.length} error(s): ${errors.map((e) => e.message).join(\"; \")}`,\n issues,\n );\n }\n}\n","import type { ToolchainContractsDSL } from \"./schema.js\";\nimport type { ValidationIssue } from \"./errors.js\";\n\nexport interface ArtifactContractInfo {\n id: string;\n derived_from?: string[];\n}\n\nexport interface AgentContractInfo {\n id: string;\n produces?: string[];\n consumes?: string[];\n}\n\nexport interface LintOptions {\n artifacts?: ArtifactContractInfo[];\n agents?: AgentContractInfo[];\n}\n\nexport function lintDataflow(\n toolchainDoc: ToolchainContractsDSL,\n options: LintOptions = {},\n): ValidationIssue[] {\n const issues: ValidationIssue[] = [];\n\n const artifactMap = new Map((options.artifacts ?? []).map((a) => [a.id, a]));\n const allArtifactIds = new Set(artifactMap.keys());\n\n const producerMap = new Map<string, string[]>();\n const consumerMap = new Map<string, string[]>();\n\n for (const [tcId, tc] of Object.entries(toolchainDoc.toolchains)) {\n for (const artifactId of tc.artifacts.produces) {\n if (!producerMap.has(artifactId)) producerMap.set(artifactId, []);\n producerMap.get(artifactId)!.push(`toolchain:${tcId}`);\n }\n for (const artifactId of tc.artifacts.consumes) {\n if (!consumerMap.has(artifactId)) consumerMap.set(artifactId, []);\n consumerMap.get(artifactId)!.push(`toolchain:${tcId}`);\n }\n }\n\n for (const agent of options.agents ?? []) {\n for (const artifactId of agent.produces ?? []) {\n if (!producerMap.has(artifactId)) producerMap.set(artifactId, []);\n producerMap.get(artifactId)!.push(`agent:${agent.id}`);\n }\n for (const artifactId of agent.consumes ?? []) {\n if (!consumerMap.has(artifactId)) consumerMap.set(artifactId, []);\n consumerMap.get(artifactId)!.push(`agent:${agent.id}`);\n }\n }\n\n // Check 1: Producer absence\n for (const artifact of options.artifacts ?? []) {\n if (artifact.derived_from && artifact.derived_from.length > 0) {\n if (!producerMap.has(artifact.id)) {\n issues.push({\n code: \"producer-absent\",\n message: `Artifact \"${artifact.id}\" has derived_from [${artifact.derived_from.join(\", \")}] but no toolchain or agent produces it`,\n path: [\"artifacts\", artifact.id],\n severity: \"error\",\n });\n }\n }\n }\n\n // Check 2: Consumer absence (dead artifact)\n for (const [artifactId, producers] of producerMap) {\n if (!consumerMap.has(artifactId)) {\n issues.push({\n code: \"consumer-absent\",\n message: `Artifact \"${artifactId}\" is produced by ${producers.join(\", \")} but nobody consumes it`,\n path: [\"toolchains\"],\n severity: \"warning\",\n });\n }\n }\n\n // Check 3: Dataflow inconsistency\n for (const artifact of options.artifacts ?? []) {\n if (!artifact.derived_from || artifact.derived_from.length === 0) continue;\n const producers = producerMap.get(artifact.id) ?? [];\n for (const producerName of producers) {\n for (const sourceId of artifact.derived_from) {\n const [type, id] = producerName.split(\":\", 2);\n let producerConsumes: string[] = [];\n if (type === \"toolchain\") {\n const tc = toolchainDoc.toolchains[id];\n if (tc) producerConsumes = tc.artifacts.consumes;\n } else if (type === \"agent\") {\n const agent = options.agents?.find((a) => a.id === id);\n if (agent) producerConsumes = agent.consumes ?? [];\n }\n\n if (!producerConsumes.includes(sourceId)) {\n issues.push({\n code: \"dataflow-inconsistency\",\n message: `${producerName} produces \"${artifact.id}\" (derived_from: \"${sourceId}\") but does not consume \"${sourceId}\"`,\n path: [\"toolchains\", id],\n severity: \"error\",\n });\n }\n }\n }\n }\n\n // Check 4: Undefined artifact ID\n if (allArtifactIds.size > 0) {\n for (const [tcId, tc] of Object.entries(toolchainDoc.toolchains)) {\n for (const artifactId of [\n ...tc.artifacts.consumes,\n ...tc.artifacts.produces,\n ]) {\n if (!allArtifactIds.has(artifactId)) {\n issues.push({\n code: \"undefined-artifact\",\n message: `Toolchain \"${tcId}\" references undefined artifact \"${artifactId}\"`,\n path: [\"toolchains\", tcId, \"artifacts\"],\n severity: \"error\",\n });\n }\n }\n }\n }\n\n return issues;\n}\n"],"mappings":";AAAA,SAAS,SAAS;AAEX,IAAM,yBAAyB;AAC/B,IAAM,4BAA4B,CAAC,oBAAoB;AAE9D,IAAM,eAAe,EAAE,OAAO;AAAA,EAC5B,IAAI,EAAE,OAAO,EAAE,IAAI,CAAC;AAAA,EACpB,MAAM,EAAE,OAAO,EAAE,SAAS;AAC5B,CAAC;AAED,IAAM,kBAAkB,EAAE,OAAO;AAAA,EAC/B,UAAU,EAAE,MAAM,EAAE,OAAO,CAAC,EAAE,QAAQ,CAAC,CAAC;AAAA,EACxC,UAAU,EAAE,MAAM,EAAE,OAAO,CAAC,EAAE,QAAQ,CAAC,CAAC;AAC1C,CAAC;AAED,IAAM,sBAAsB,EAAE,KAAK,CAAC,WAAW,OAAO,WAAW,CAAC;AAElE,IAAM,kBAAkB,EACrB,OAAO;AAAA,EACN,MAAM;AAAA,EACN,aAAa,EA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BAAW,cAAc;AAAA,QACvB,GAAG,GAAG,UAAU;AAAA,QAChB,GAAG,GAAG,UAAU;AAAA,MAClB,GAAG;AACD,YAAI,CAAC,eAAe,IAAI,UAAU,GAAG;AACnC,iBAAO,KAAK;AAAA,YACV,MAAM;AAAA,YACN,SAAS,cAAc,IAAI,oCAAoC,UAAU;AAAA,YACzE,MAAM,CAAC,cAAc,MAAM,WAAW;AAAA,YACtC,UAAU;AAAA,UACZ,CAAC;AAAA,QACH;AAAA,MACF;AAAA,IACF;AAAA,EACF;AAEA,SAAO;AACT;","names":[]}
@@ -0,0 +1 @@
1
+ #!/usr/bin/env node
@@ -0,0 +1,115 @@
1
+ #!/usr/bin/env node
2
+ import {
3
+ ToolchainParseError,
4
+ lintDataflow,
5
+ loadToolchainContracts,
6
+ validateToolchainContracts
7
+ } from "../chunk-MMMN4A7Z.js";
8
+
9
+ // src/cli/index.ts
10
+ import { Command } from "commander";
11
+ import { createRequire } from "module";
12
+ import { resolve } from "path";
13
+ import { readFileSync } from "fs";
14
+ import { parse as parseYaml } from "yaml";
15
+ var require2 = createRequire(import.meta.url);
16
+ var pkg = require2("../../package.json");
17
+ var program = new Command();
18
+ program.name("aaac-toolchain").description("CLI for validating toolchain contracts").version(pkg.version);
19
+ program.command("validate").description("Validate a toolchain-contracts YAML file").argument("<file>", "Path to toolchain-contracts YAML file").option("--artifact-ids <ids...>", "Known artifact IDs for semantic validation").action(async (file, options) => {
20
+ try {
21
+ const filePath = resolve(file);
22
+ const doc = await loadToolchainContracts(filePath);
23
+ const issues = validateToolchainContracts(doc, {
24
+ artifactIds: options.artifactIds
25
+ });
26
+ const errors = issues.filter((i) => i.severity === "error");
27
+ const warnings = issues.filter((i) => i.severity === "warning");
28
+ if (warnings.length > 0) {
29
+ for (const w of warnings) {
30
+ console.error(`\u26A0 [${w.code}] ${w.message}`);
31
+ }
32
+ }
33
+ if (errors.length > 0) {
34
+ for (const e of errors) {
35
+ console.error(`\u2717 [${e.code}] ${e.message}`);
36
+ }
37
+ console.error(
38
+ `
39
+ Validation failed: ${errors.length} error(s), ${warnings.length} warning(s)`
40
+ );
41
+ process.exit(1);
42
+ }
43
+ const tcCount = Object.keys(doc.toolchains).length;
44
+ console.log(`\u2713 Valid: ${tcCount} toolchain(s), ${warnings.length} warning(s)`);
45
+ } catch (err) {
46
+ if (err instanceof ToolchainParseError) {
47
+ console.error(`\u2717 ${err.message}`);
48
+ process.exit(2);
49
+ }
50
+ throw err;
51
+ }
52
+ });
53
+ program.command("lint").description("Check dataflow integrity across contract layers").argument("<file>", "Path to toolchain-contracts YAML file").option("--artifact-contracts <file>", "Path to artifact-contracts YAML").option("--agent-contracts <file>", "Path to agent-contracts YAML").action(
54
+ async (file, options) => {
55
+ try {
56
+ const filePath = resolve(file);
57
+ const doc = await loadToolchainContracts(filePath);
58
+ let artifacts;
59
+ if (options.artifactContracts) {
60
+ const artifactPath = resolve(options.artifactContracts);
61
+ const raw = parseYaml(readFileSync(artifactPath, "utf-8"));
62
+ const artifactsMap = raw.artifacts;
63
+ if (artifactsMap) {
64
+ artifacts = Object.entries(artifactsMap).map(([id, a]) => ({
65
+ id,
66
+ derived_from: a.derived_from ?? []
67
+ }));
68
+ }
69
+ }
70
+ let agents;
71
+ if (options.agentContracts) {
72
+ const agentPath = resolve(options.agentContracts);
73
+ const raw = parseYaml(readFileSync(agentPath, "utf-8"));
74
+ const agentsMap = raw.agents;
75
+ if (agentsMap) {
76
+ agents = Object.entries(agentsMap).map(([id, a]) => {
77
+ const agentArtifacts = a.artifacts;
78
+ return {
79
+ id,
80
+ produces: agentArtifacts?.produces ?? [],
81
+ consumes: agentArtifacts?.consumes ?? []
82
+ };
83
+ });
84
+ }
85
+ }
86
+ const issues = lintDataflow(doc, { artifacts, agents });
87
+ const errors = issues.filter((i) => i.severity === "error");
88
+ const warnings = issues.filter((i) => i.severity === "warning");
89
+ if (warnings.length > 0) {
90
+ for (const w of warnings) {
91
+ console.error(`\u26A0 [${w.code}] ${w.message}`);
92
+ }
93
+ }
94
+ if (errors.length > 0) {
95
+ for (const e of errors) {
96
+ console.error(`\u2717 [${e.code}] ${e.message}`);
97
+ }
98
+ console.error(
99
+ `
100
+ Dataflow lint failed: ${errors.length} error(s), ${warnings.length} warning(s)`
101
+ );
102
+ process.exit(1);
103
+ }
104
+ console.log(`\u2713 Dataflow lint passed: ${warnings.length} warning(s)`);
105
+ } catch (err) {
106
+ if (err instanceof ToolchainParseError) {
107
+ console.error(`\u2717 ${err.message}`);
108
+ process.exit(2);
109
+ }
110
+ throw err;
111
+ }
112
+ }
113
+ );
114
+ program.parseAsync(process.argv);
115
+ //# sourceMappingURL=index.js.map
@@ -0,0 +1 @@
1
+ {"version":3,"sources":["../../src/cli/index.ts"],"sourcesContent":["#!/usr/bin/env node\nimport { Command } from \"commander\";\nimport { createRequire } from \"node:module\";\nimport { resolve } from \"node:path\";\nimport { readFileSync } from \"node:fs\";\nimport { parse as parseYaml } from \"yaml\";\nimport { loadToolchainContracts } from \"../loader.js\";\nimport { validateToolchainContracts } from \"../validator.js\";\nimport {\n lintDataflow,\n type ArtifactContractInfo,\n type AgentContractInfo,\n} from \"../linter.js\";\nimport { ToolchainParseError } from \"../errors.js\";\n\nconst require = createRequire(import.meta.url);\nconst pkg = require(\"../../package.json\") as { version: string };\n\nconst program = new Command();\n\nprogram\n .name(\"aaac-toolchain\")\n .description(\"CLI for validating toolchain contracts\")\n .version(pkg.version);\n\nprogram\n .command(\"validate\")\n .description(\"Validate a toolchain-contracts YAML file\")\n .argument(\"<file>\", \"Path to toolchain-contracts YAML file\")\n .option(\"--artifact-ids <ids...>\", \"Known artifact IDs for semantic validation\")\n .action(async (file: string, options: { artifactIds?: string[] }) => {\n try {\n const filePath = resolve(file);\n const doc = await loadToolchainContracts(filePath);\n\n const issues = validateToolchainContracts(doc, {\n artifactIds: options.artifactIds,\n });\n\n const errors = issues.filter((i) => i.severity === \"error\");\n const warnings = issues.filter((i) => i.severity === \"warning\");\n\n if (warnings.length > 0) {\n for (const w of warnings) {\n console.error(`⚠ [${w.code}] ${w.message}`);\n }\n }\n\n if (errors.length > 0) {\n for (const e of errors) {\n console.error(`✗ [${e.code}] ${e.message}`);\n }\n console.error(\n `\\nValidation failed: ${errors.length} error(s), ${warnings.length} warning(s)`,\n );\n process.exit(1);\n }\n\n const tcCount = Object.keys(doc.toolchains).length;\n console.log(`✓ Valid: ${tcCount} toolchain(s), ${warnings.length} warning(s)`);\n } catch (err) {\n if (err instanceof ToolchainParseError) {\n console.error(`✗ ${err.message}`);\n process.exit(2);\n }\n throw err;\n }\n });\n\nprogram\n .command(\"lint\")\n .description(\"Check dataflow integrity across contract layers\")\n .argument(\"<file>\", \"Path to toolchain-contracts YAML file\")\n .option(\"--artifact-contracts <file>\", \"Path to artifact-contracts YAML\")\n .option(\"--agent-contracts <file>\", \"Path to agent-contracts YAML\")\n .action(\n async (\n file: string,\n options: { artifactContracts?: string; agentContracts?: string },\n ) => {\n try {\n const filePath = resolve(file);\n const doc = await loadToolchainContracts(filePath);\n\n let artifacts: ArtifactContractInfo[] | undefined;\n if (options.artifactContracts) {\n const artifactPath = resolve(options.artifactContracts);\n const raw = parseYaml(readFileSync(artifactPath, \"utf-8\")) as Record<\n string,\n unknown\n >;\n const artifactsMap = raw.artifacts as\n | Record<string, Record<string, unknown>>\n | undefined;\n if (artifactsMap) {\n artifacts = Object.entries(artifactsMap).map(([id, a]) => ({\n id,\n derived_from: (a.derived_from as string[] | undefined) ?? [],\n }));\n }\n }\n\n let agents: AgentContractInfo[] | undefined;\n if (options.agentContracts) {\n const agentPath = resolve(options.agentContracts);\n const raw = parseYaml(readFileSync(agentPath, \"utf-8\")) as Record<\n string,\n unknown\n >;\n const agentsMap = raw.agents as\n | Record<string, Record<string, unknown>>\n | undefined;\n if (agentsMap) {\n agents = Object.entries(agentsMap).map(([id, a]) => {\n const agentArtifacts = a.artifacts as\n | Record<string, unknown>\n | undefined;\n return {\n id,\n produces: (agentArtifacts?.produces as string[]) ?? [],\n consumes: (agentArtifacts?.consumes as string[]) ?? [],\n };\n });\n }\n }\n\n const issues = lintDataflow(doc, { artifacts, agents });\n\n const errors = issues.filter((i) => i.severity === \"error\");\n const warnings = issues.filter((i) => i.severity === \"warning\");\n\n if (warnings.length > 0) {\n for (const w of warnings) {\n console.error(`⚠ [${w.code}] ${w.message}`);\n }\n }\n\n if (errors.length > 0) {\n for (const e of errors) {\n console.error(`✗ [${e.code}] ${e.message}`);\n }\n console.error(\n `\\nDataflow lint failed: ${errors.length} error(s), ${warnings.length} warning(s)`,\n );\n process.exit(1);\n }\n\n console.log(`✓ Dataflow lint passed: ${warnings.length} warning(s)`);\n } catch (err) {\n if (err instanceof ToolchainParseError) {\n console.error(`✗ ${err.message}`);\n process.exit(2);\n }\n throw err;\n }\n },\n );\n\nprogram.parseAsync(process.argv);\n"],"mappings":";;;;;;;;;AACA,SAAS,eAAe;AACxB,SAAS,qBAAqB;AAC9B,SAAS,eAAe;AACxB,SAAS,oBAAoB;AAC7B,SAAS,SAAS,iBAAiB;AAUnC,IAAMA,WAAU,cAAc,YAAY,GAAG;AAC7C,IAAM,MAAMA,SAAQ,oBAAoB;AAExC,IAAM,UAAU,IAAI,QAAQ;AAE5B,QACG,KAAK,gBAAgB,EACrB,YAAY,wCAAwC,EACpD,QAAQ,IAAI,OAAO;AAEtB,QACG,QAAQ,UAAU,EAClB,YAAY,0CAA0C,EACtD,SAAS,UAAU,uCAAuC,EAC1D,OAAO,2BAA2B,4CAA4C,EAC9E,OAAO,OAAO,MAAc,YAAwC;AACnE,MAAI;AACF,UAAM,WAAW,QAAQ,IAAI;AAC7B,UAAM,MAAM,MAAM,uBAAuB,QAAQ;AAEjD,UAAM,SAAS,2BAA2B,KAAK;AAAA,MAC7C,aAAa,QAAQ;AAAA,IACvB,CAAC;AAED,UAAM,SAAS,OAAO,OAAO,CAAC,MAAM,EAAE,aAAa,OAAO;AAC1D,UAAM,WAAW,OAAO,OAAO,CAAC,MAAM,EAAE,aAAa,SAAS;AAE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QAAQ,WAAW,QAAQ,IAAI;","names":["require"]}
@@ -0,0 +1,107 @@
1
+ import { z } from 'zod';
2
+
3
+ declare const SCHEMA_VERSION_PATTERN: RegExp;
4
+ declare const SUPPORTED_SCHEMA_VERSIONS: readonly ["aaac/toolchain/0.1"];
5
+ declare const SystemSchema: z.ZodObject<{
6
+ id: z.ZodString;
7
+ name: z.ZodOptional<z.ZodString>;
8
+ }, z.core.$strip>;
9
+ declare const ArtifactsSchema: z.ZodObject<{
10
+ consumes: z.ZodDefault<z.ZodArray<z.ZodString>>;
11
+ produces: z.ZodDefault<z.ZodArray<z.ZodString>>;
12
+ }, z.core.$strip>;
13
+ declare const ToolchainKindSchema: z.ZodEnum<{
14
+ library: "library";
15
+ cli: "cli";
16
+ component: "component";
17
+ }>;
18
+ declare const ToolchainSchema: z.ZodObject<{
19
+ kind: z.ZodEnum<{
20
+ library: "library";
21
+ cli: "cli";
22
+ component: "component";
23
+ }>;
24
+ description: z.ZodOptional<z.ZodString>;
25
+ module: z.ZodOptional<z.ZodString>;
26
+ command: z.ZodOptional<z.ZodString>;
27
+ cli_contract: z.ZodOptional<z.ZodString>;
28
+ component_contract: z.ZodOptional<z.ZodString>;
29
+ artifacts: z.ZodDefault<z.ZodObject<{
30
+ consumes: z.ZodDefault<z.ZodArray<z.ZodString>>;
31
+ produces: z.ZodDefault<z.ZodArray<z.ZodString>>;
32
+ }, z.core.$strip>>;
33
+ operations: z.ZodOptional<z.ZodArray<z.ZodString>>;
34
+ }, z.core.$strip>;
35
+ declare const ToolchainContractsSchema: z.ZodObject<{
36
+ schema: z.ZodString;
37
+ system: z.ZodObject<{
38
+ id: z.ZodString;
39
+ name: z.ZodOptional<z.ZodString>;
40
+ }, z.core.$strip>;
41
+ toolchains: z.ZodRecord<z.ZodString, z.ZodObject<{
42
+ kind: z.ZodEnum<{
43
+ library: "library";
44
+ cli: "cli";
45
+ component: "component";
46
+ }>;
47
+ description: z.ZodOptional<z.ZodString>;
48
+ module: z.ZodOptional<z.ZodString>;
49
+ command: z.ZodOptional<z.ZodString>;
50
+ cli_contract: z.ZodOptional<z.ZodString>;
51
+ component_contract: z.ZodOptional<z.ZodString>;
52
+ artifacts: z.ZodDefault<z.ZodObject<{
53
+ consumes: z.ZodDefault<z.ZodArray<z.ZodString>>;
54
+ produces: z.ZodDefault<z.ZodArray<z.ZodString>>;
55
+ }, z.core.$strip>>;
56
+ operations: z.ZodOptional<z.ZodArray<z.ZodString>>;
57
+ }, z.core.$strip>>;
58
+ }, z.core.$strip>;
59
+ type ToolchainContractsDSL = z.infer<typeof ToolchainContractsSchema>;
60
+ type ToolchainDSL = z.infer<typeof ToolchainSchema>;
61
+ type ToolchainKind = z.infer<typeof ToolchainKindSchema>;
62
+
63
+ declare function parseToolchainString(content: string, filePath?: string): ToolchainContractsDSL;
64
+ declare function parseToolchainFile(filePath: string): Promise<ToolchainContractsDSL>;
65
+ declare function loadToolchainContracts(filePath: string): Promise<ToolchainContractsDSL>;
66
+
67
+ declare class ToolchainParseError extends Error {
68
+ readonly filePath?: string | undefined;
69
+ readonly cause?: unknown | undefined;
70
+ constructor(message: string, filePath?: string | undefined, cause?: unknown | undefined);
71
+ }
72
+ declare class ToolchainValidationError extends Error {
73
+ readonly issues: ValidationIssue[];
74
+ constructor(message: string, issues?: ValidationIssue[]);
75
+ }
76
+ interface ValidationIssue {
77
+ code: string;
78
+ message: string;
79
+ path?: string[];
80
+ severity: "error" | "warning";
81
+ }
82
+
83
+ interface ValidateOptions {
84
+ /** Known artifact IDs (from artifact-contracts) */
85
+ artifactIds?: string[];
86
+ }
87
+ declare function validateToolchainContracts(doc: ToolchainContractsDSL, options?: ValidateOptions): ValidationIssue[];
88
+ declare function assertValid(doc: ToolchainContractsDSL, options?: ValidateOptions): void;
89
+
90
+ interface ArtifactContractInfo {
91
+ id: string;
92
+ derived_from?: string[];
93
+ }
94
+ interface AgentContractInfo {
95
+ id: string;
96
+ produces?: string[];
97
+ consumes?: string[];
98
+ }
99
+ interface LintOptions {
100
+ artifacts?: ArtifactContractInfo[];
101
+ agents?: AgentContractInfo[];
102
+ }
103
+ declare function lintDataflow(toolchainDoc: ToolchainContractsDSL, options?: LintOptions): ValidationIssue[];
104
+
105
+ declare const version: string;
106
+
107
+ export { type AgentContractInfo, type ArtifactContractInfo, ArtifactsSchema, type LintOptions, SCHEMA_VERSION_PATTERN, SUPPORTED_SCHEMA_VERSIONS, SystemSchema, type ToolchainContractsDSL, ToolchainContractsSchema, type ToolchainDSL, type ToolchainKind, ToolchainKindSchema, ToolchainParseError, ToolchainSchema, ToolchainValidationError, type ValidateOptions, type ValidationIssue, assertValid, lintDataflow, loadToolchainContracts, parseToolchainFile, parseToolchainString, validateToolchainContracts, version };
package/dist/index.js ADDED
@@ -0,0 +1,42 @@
1
+ import {
2
+ ArtifactsSchema,
3
+ SCHEMA_VERSION_PATTERN,
4
+ SUPPORTED_SCHEMA_VERSIONS,
5
+ SystemSchema,
6
+ ToolchainContractsSchema,
7
+ ToolchainKindSchema,
8
+ ToolchainParseError,
9
+ ToolchainSchema,
10
+ ToolchainValidationError,
11
+ assertValid,
12
+ lintDataflow,
13
+ loadToolchainContracts,
14
+ parseToolchainFile,
15
+ parseToolchainString,
16
+ validateToolchainContracts
17
+ } from "./chunk-MMMN4A7Z.js";
18
+
19
+ // src/index.ts
20
+ import { createRequire } from "module";
21
+ var require2 = createRequire(import.meta.url);
22
+ var pkg = require2("../package.json");
23
+ var version = pkg.version;
24
+ export {
25
+ ArtifactsSchema,
26
+ SCHEMA_VERSION_PATTERN,
27
+ SUPPORTED_SCHEMA_VERSIONS,
28
+ SystemSchema,
29
+ ToolchainContractsSchema,
30
+ ToolchainKindSchema,
31
+ ToolchainParseError,
32
+ ToolchainSchema,
33
+ ToolchainValidationError,
34
+ assertValid,
35
+ lintDataflow,
36
+ loadToolchainContracts,
37
+ parseToolchainFile,
38
+ parseToolchainString,
39
+ validateToolchainContracts,
40
+ version
41
+ };
42
+ //# sourceMappingURL=index.js.map
@@ -0,0 +1 @@
1
+ {"version":3,"sources":["../src/index.ts"],"sourcesContent":["import { createRequire } from \"node:module\";\n\nconst require = createRequire(import.meta.url);\nconst pkg = require(\"../package.json\") as { version: string };\n\nexport const version = pkg.version;\n\nexport {\n ToolchainContractsSchema,\n ToolchainSchema,\n SystemSchema,\n ArtifactsSchema,\n ToolchainKindSchema,\n SUPPORTED_SCHEMA_VERSIONS,\n SCHEMA_VERSION_PATTERN,\n type ToolchainContractsDSL,\n type ToolchainDSL,\n type ToolchainKind,\n} from \"./schema.js\";\n\nexport {\n loadToolchainContracts,\n parseToolchainFile,\n parseToolchainString,\n} from \"./loader.js\";\n\nexport {\n validateToolchainContracts,\n assertValid,\n type ValidateOptions,\n} from \"./validator.js\";\n\nexport {\n ToolchainParseError,\n ToolchainValidationError,\n type ValidationIssue,\n} from \"./errors.js\";\n\nexport {\n lintDataflow,\n type LintOptions,\n type ArtifactContractInfo,\n type AgentContractInfo,\n} from \"./linter.js\";\n"],"mappings":";;;;;;;;;;;;;;;;;;;AAAA,SAAS,qBAAqB;AAE9B,IAAMA,WAAU,cAAc,YAAY,GAAG;AAC7C,IAAM,MAAMA,SAAQ,iBAAiB;AAE9B,IAAM,UAAU,IAAI;","names":["require"]}
package/package.json ADDED
@@ -0,0 +1,39 @@
1
+ {
2
+ "name": "@aaac/toolchain",
3
+ "version": "0.1.0",
4
+ "description": "Toolchain contract definitions for artifact-bound tool declarations",
5
+ "type": "module",
6
+ "bin": {
7
+ "aaac-toolchain": "./dist/cli/index.js"
8
+ },
9
+ "main": "dist/index.js",
10
+ "types": "dist/index.d.ts",
11
+ "exports": {
12
+ ".": {
13
+ "import": "./dist/index.js",
14
+ "types": "./dist/index.d.ts"
15
+ }
16
+ },
17
+ "files": ["dist/", "README.md", "LICENSE"],
18
+ "scripts": {
19
+ "build": "tsup",
20
+ "clean": "rm -rf dist",
21
+ "test": "vitest run",
22
+ "prepublishOnly": "npm run clean && npm run build"
23
+ },
24
+ "publishConfig": { "access": "public" },
25
+ "repository": { "type": "git", "url": "https://github.com/foo-log-inc/aaac" },
26
+ "author": "foo-log-inc",
27
+ "license": "MIT",
28
+ "engines": { "node": ">=20.0.0" },
29
+ "dependencies": {
30
+ "commander": "^15.0.0",
31
+ "yaml": "^2.8.3",
32
+ "zod": "^4.0.0"
33
+ },
34
+ "devDependencies": {
35
+ "tsup": "^8.5.0",
36
+ "typescript": "^5.9.0",
37
+ "vitest": "^4.0.0"
38
+ }
39
+ }