@aid-framework/cli 0.0.0 → 0.1.39

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 (76) hide show
  1. package/LICENSE +201 -0
  2. package/README.md +46 -0
  3. package/dist/.tsbuildinfo +1 -0
  4. package/dist/args.d.ts +37 -0
  5. package/dist/args.d.ts.map +1 -0
  6. package/dist/args.js +74 -0
  7. package/dist/args.js.map +1 -0
  8. package/dist/cli.d.ts +17 -0
  9. package/dist/cli.d.ts.map +1 -0
  10. package/dist/cli.js +26 -0
  11. package/dist/cli.js.map +1 -0
  12. package/dist/commands/eval.d.ts +44 -0
  13. package/dist/commands/eval.d.ts.map +1 -0
  14. package/dist/commands/eval.js +257 -0
  15. package/dist/commands/eval.js.map +1 -0
  16. package/dist/commands/gen.d.ts +42 -0
  17. package/dist/commands/gen.d.ts.map +1 -0
  18. package/dist/commands/gen.js +138 -0
  19. package/dist/commands/gen.js.map +1 -0
  20. package/dist/commands/ingest.d.ts +44 -0
  21. package/dist/commands/ingest.d.ts.map +1 -0
  22. package/dist/commands/ingest.js +238 -0
  23. package/dist/commands/ingest.js.map +1 -0
  24. package/dist/commands/init.d.ts +38 -0
  25. package/dist/commands/init.d.ts.map +1 -0
  26. package/dist/commands/init.js +203 -0
  27. package/dist/commands/init.js.map +1 -0
  28. package/dist/commands/validate.d.ts +22 -0
  29. package/dist/commands/validate.d.ts.map +1 -0
  30. package/dist/commands/validate.js +53 -0
  31. package/dist/commands/validate.js.map +1 -0
  32. package/dist/context.d.ts +37 -0
  33. package/dist/context.d.ts.map +1 -0
  34. package/dist/context.js +36 -0
  35. package/dist/context.js.map +1 -0
  36. package/dist/diagnostics.d.ts +42 -0
  37. package/dist/diagnostics.d.ts.map +1 -0
  38. package/dist/diagnostics.js +47 -0
  39. package/dist/diagnostics.js.map +1 -0
  40. package/dist/exit.d.ts +16 -0
  41. package/dist/exit.d.ts.map +1 -0
  42. package/dist/exit.js +15 -0
  43. package/dist/exit.js.map +1 -0
  44. package/dist/index.d.ts +42 -0
  45. package/dist/index.d.ts.map +1 -0
  46. package/dist/index.js +29 -0
  47. package/dist/index.js.map +1 -0
  48. package/dist/main.d.ts +25 -0
  49. package/dist/main.d.ts.map +1 -0
  50. package/dist/main.js +155 -0
  51. package/dist/main.js.map +1 -0
  52. package/dist/output.d.ts +48 -0
  53. package/dist/output.d.ts.map +1 -0
  54. package/dist/output.js +50 -0
  55. package/dist/output.js.map +1 -0
  56. package/dist/paths.d.ts +21 -0
  57. package/dist/paths.d.ts.map +1 -0
  58. package/dist/paths.js +31 -0
  59. package/dist/paths.js.map +1 -0
  60. package/dist/pipeline.d.ts +74 -0
  61. package/dist/pipeline.d.ts.map +1 -0
  62. package/dist/pipeline.js +113 -0
  63. package/dist/pipeline.js.map +1 -0
  64. package/dist/python.d.ts +30 -0
  65. package/dist/python.d.ts.map +1 -0
  66. package/dist/python.js +57 -0
  67. package/dist/python.js.map +1 -0
  68. package/dist/targets.d.ts +75 -0
  69. package/dist/targets.d.ts.map +1 -0
  70. package/dist/targets.js +136 -0
  71. package/dist/targets.js.map +1 -0
  72. package/dist/usage.d.ts +20 -0
  73. package/dist/usage.d.ts.map +1 -0
  74. package/dist/usage.js +49 -0
  75. package/dist/usage.js.map +1 -0
  76. package/package.json +49 -14
package/dist/python.js ADDED
@@ -0,0 +1,57 @@
1
+ /**
2
+ * The Python toolchain the commands that run generated code have to find.
3
+ *
4
+ * `aid eval` and `aid ingest` both shell out to a module the generator emitted, so both
5
+ * need the same two answers: which interpreter can actually import the runtime, and how
6
+ * to spawn it. Keeping the discovery here means there is one definition of "a usable
7
+ * interpreter" -- if the two commands each carried their own, an environment could work
8
+ * for one and not the other without anything explaining why.
9
+ *
10
+ * The contract is deliberately narrow: the caller names the module, and this file only
11
+ * decides which program runs it and from where. It knows nothing about evals or ingest.
12
+ */
13
+ /**
14
+ * Tried in order. The interpreter already active on this project comes first: it is the
15
+ * one the runtime was installed into. `uv` is last, and is kept because a uv-managed
16
+ * environment that has not been activated is a real setup where none of the others exist.
17
+ */
18
+ export const INTERPRETERS = ['python3', 'python', 'uv'];
19
+ /**
20
+ * Discovery asks whether a candidate can import the runtime, not merely whether it
21
+ * exists. A machine with a system `python` beside a project virtualenv has several
22
+ * interpreters, and picking the one that cannot `import aid_runtime` reports a missing
23
+ * dependency as a broken generated module. The probe is the import itself, so it cannot
24
+ * disagree with what the run will do a moment later.
25
+ */
26
+ const RUNTIME_PROBE = 'import aid_runtime.evals';
27
+ /** `uv run python` is a different argv shape from `python`, so it is not a rename. */
28
+ export function interpreterCommand(interpreter) {
29
+ return interpreter === 'uv' ? ['uv', 'run', 'python'] : [interpreter];
30
+ }
31
+ /**
32
+ * Spawn, or `undefined` when the program could not be executed at all. `spawnSync` reports
33
+ * a missing binary as `error` with a `null` status, and collapsing those two into one
34
+ * `undefined` is what lets discovery and the real run share a code path.
35
+ */
36
+ export function invoke(context, command, stdin) {
37
+ const [program, ...args] = command;
38
+ if (program === undefined)
39
+ return undefined;
40
+ const result = context.spawn(program, args, {
41
+ cwd: context.cwd,
42
+ stdio: 'pipe',
43
+ env: context.env,
44
+ ...(stdin === undefined ? {} : { stdin }),
45
+ });
46
+ return result.error === undefined ? result : undefined;
47
+ }
48
+ /** The first interpreter that can import the runtime, or `undefined` when none can. */
49
+ export function discoverInterpreter(context) {
50
+ for (const interpreter of INTERPRETERS) {
51
+ const probe = invoke(context, [...interpreterCommand(interpreter), '-c', RUNTIME_PROBE]);
52
+ if (probe !== undefined && probe.status === 0)
53
+ return interpreter;
54
+ }
55
+ return undefined;
56
+ }
57
+ //# sourceMappingURL=python.js.map
@@ -0,0 +1 @@
1
+ {"version":3,"file":"python.js","sourceRoot":"","sources":["../src/python.ts"],"names":[],"mappings":"AAAA;;;;;;;;;;;GAWG;AAIH;;;;GAIG;AACH,MAAM,CAAC,MAAM,YAAY,GAAG,CAAC,SAAS,EAAE,QAAQ,EAAE,IAAI,CAAU,CAAC;AAEjE;;;;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
+ /**
2
+ * The target registry: the one place the CLI learns what a target *is*.
3
+ *
4
+ * A target is a generator plus the layout it declares. Nothing here restates that
5
+ * layout -- the spec path, the generated root, the business root, the manifest path and
6
+ * the eval module names all come from `@aid-framework/generator-sdk`'s `managedRoots` and
7
+ * `@aid-framework/generator-py-fastapi`'s path helpers, so a generator that moves a file moves
8
+ * every command with it, without the CLI being edited.
9
+ *
10
+ * The capability declarations are the SDK's `phase0TargetCapabilities`, not `@aid-framework/ir`'s
11
+ * placeholder of the same name. The placeholder exists so the gate could be written
12
+ * before a real generator existed; feeding it to the gate would make the capability gate
13
+ * pass vacuously for every spec, which is the one failure mode a gate must not have.
14
+ */
15
+ import { type Generator, type GeneratorManifest, type Plan } from '@aid-framework/generator-sdk';
16
+ import type { IR, TargetCapabilityDeclarations } from '@aid-framework/ir';
17
+ import type { CliDiagnostic } from './diagnostics.js';
18
+ /**
19
+ * How `aid eval` and `aid ingest` run a target's generated entry points.
20
+ *
21
+ * Both commands used to assume CPython: they discover an interpreter and run `-m`. A
22
+ * target whose emitted modules are not Python has no such entry point, and the honest
23
+ * answer is a diagnostic, not a Python traceback about a missing module.
24
+ */
25
+ export type TargetRunner = 'python' | 'node';
26
+ export interface Target {
27
+ /** The target id, as a spec's `project.targets` spells it. */
28
+ readonly name: string;
29
+ /** The spec this target's project is expected to keep, repo-relative. */
30
+ readonly specPath: string;
31
+ readonly generatedDir: string;
32
+ readonly businessDir: string;
33
+ readonly manifestPath: string;
34
+ /** The generated evals package, repo-relative. */
35
+ readonly evalsDir: string;
36
+ readonly manifest: GeneratorManifest;
37
+ readonly generator: Generator;
38
+ /** Which toolchain `aid eval` and `aid ingest` would need to run this target. */
39
+ readonly runner: TargetRunner;
40
+ /** Everything that stops this target compiling the IR, as diagnostics. */
41
+ check(ir: IR): readonly CliDiagnostic[];
42
+ plan(ir: IR): Plan;
43
+ /** The dotted module path of the generated eval module for `evalId`. */
44
+ evalModule(evalId: string): string;
45
+ /** The repo-relative file the generated eval module for `evalId` lives in. */
46
+ evalModuleFile(evalId: string): string;
47
+ /** The dotted module path of the generated ingest module for `retrieverId`. */
48
+ retrievalIngestModule(retrieverId: string): string;
49
+ /** The repo-relative file the generated ingest module for `retrieverId` lives in. */
50
+ retrievalIngestModuleFile(retrieverId: string): string;
51
+ }
52
+ /**
53
+ * The registry. Order matters only for the default: the first entry is what `aid gen`,
54
+ * `aid validate` and `aid init` use when the caller names no target, and that has been
55
+ * `py-fastapi` since Phase 0.
56
+ */
57
+ export declare const TARGETS: readonly Target[];
58
+ export declare const DEFAULT_TARGET: string;
59
+ /** Where `aid validate` and `aid gen` look when the caller names no spec. */
60
+ export declare const DEFAULT_SPEC_PATH: string;
61
+ export declare function targetNames(): string[];
62
+ /** The named target, the default when `name` is absent, or `undefined` when unknown. */
63
+ export declare function resolveTarget(name: string | undefined): Target | undefined;
64
+ /**
65
+ * The capability declarations the build-time gates are run against.
66
+ *
67
+ * Derived from this registry rather than from the SDK's own `phase0Generators`, because
68
+ * the registry is the list of generators this binary can actually run: a spec targeting
69
+ * `ts-vercel` must be judged against `ts-vercel`'s declaration, and the SDK cannot name
70
+ * a generator that depends on the SDK.
71
+ */
72
+ export declare function targetCapabilities(): TargetCapabilityDeclarations;
73
+ /** Diagnostics for a target id the registry does not know. */
74
+ export declare function unknownTargetDiagnostic(name: string): CliDiagnostic;
75
+ //# sourceMappingURL=targets.d.ts.map
@@ -0,0 +1 @@
1
+ {"version":3,"file":"targets.d.ts","sourceRoot":"","sources":["../src/targets.ts"],"names":[],"mappings":"AAAA;;;;;;;;;;;;;GAaG;AAUH,OAAO,EACL,KAAK,SAAS,EACd,KAAK,iBAAiB,EAEtB,KAAK,IAAI,EAEV,MAAM,8BAA8B,CAAC;AAStC,OAAO,KAAK,EAAE,EAAE,EAAE,4BAA4B,EAAE,MAAM,mBAAmB,CAAC;AAG1E,OAAO,KAAK,EAAE,aAAa,EAAE,MAAM,kBAAkB,CAAC;AAiBtD;;;;;;GAMG;AACH,MAAM,M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S,GAAG,MAAM,GAAG,SAAS,CAG1E;AAED;;;;;;;GAOG;AACH,wBAAgB,kBAAkB,IAAI,4BAA4B,CAEjE;AAED,8DAA8D;AAC9D,wBAAgB,uBAAuB,CAAC,IAAI,EAAE,MAAM,GAAG,aAAa,CAOnE"}
@@ -0,0 +1,136 @@
1
+ /**
2
+ * The target registry: the one place the CLI learns what a target *is*.
3
+ *
4
+ * A target is a generator plus the layout it declares. Nothing here restates that
5
+ * layout -- the spec path, the generated root, the business root, the manifest path and
6
+ * the eval module names all come from `@aid-framework/generator-sdk`'s `managedRoots` and
7
+ * `@aid-framework/generator-py-fastapi`'s path helpers, so a generator that moves a file moves
8
+ * every command with it, without the CLI being edited.
9
+ *
10
+ * The capability declarations are the SDK's `phase0TargetCapabilities`, not `@aid-framework/ir`'s
11
+ * placeholder of the same name. The placeholder exists so the gate could be written
12
+ * before a real generator existed; feeding it to the gate would make the capability gate
13
+ * pass vacuously for every spec, which is the one failure mode a gate must not have.
14
+ */
15
+ import { checkPlan as checkPyFastApi, EVALS_INIT_PATH, PY_FASTAPI_MANIFEST, evalModulePath as pyFastApiEvalModulePath, pyFastApiGenerator, retrievalIngestModulePath as pyFastApiIngestModulePath, } from '@aid-framework/generator-py-fastapi';
16
+ import { managedRoots, targetCapabilityDeclarations, } from '@aid-framework/generator-sdk';
17
+ import { checkPlan as checkTsVercel, TS_VERCEL_MANIFEST, evalModulePath as tsVercelEvalModulePath, tsVercelGenerator, retrievalIngestModulePath as tsVercelIngestModulePath, paths as tsVercelPaths, } from '@aid-framework/generator-ts-vercel';
18
+ import { errorDiagnostic } from '@aid-framework/spec';
19
+ import { CLI_DIAGNOSTIC_CODES } from './diagnostics.js';
20
+ import { parentPath } from './paths.js';
21
+ function dotted(path, extension) {
22
+ return path
23
+ .replace(new RegExp(`${extension.replace('.', '\\.')}$`), '')
24
+ .split('/')
25
+ .join('.');
26
+ }
27
+ function targetFor(module) {
28
+ const { manifest } = module;
29
+ const roots = managedRoots(manifest);
30
+ return {
31
+ name: manifest.target,
32
+ specPath: `${manifest.output.root}/app.spec.yaml`,
33
+ generatedDir: roots.generatedDir,
34
+ businessDir: roots.businessDir,
35
+ manifestPath: roots.manifestFilename,
36
+ evalsDir: parentPath(module.evalsIndexPath),
37
+ manifest,
38
+ generator: module.generator,
39
+ runner: module.runner,
40
+ // `checkPlan` is the target's own compiler, and it throws the same problems
41
+ // `plan` does. Reporting them through it means the CLI prints the target's codes
42
+ // and paths verbatim: no catching, no renaming, no second opinion about what is
43
+ // wrong with a spec.
44
+ check(ir) {
45
+ return module.checkPlan(ir).map((problem) => errorDiagnostic({
46
+ code: problem.code,
47
+ message: problem.message,
48
+ path: [problem.path],
49
+ }));
50
+ },
51
+ plan(ir) {
52
+ return module.generator.plan(ir, {
53
+ generatorVersion: manifest.version,
54
+ root: manifest.output.root,
55
+ });
56
+ },
57
+ evalModuleFile(evalId) {
58
+ return module.evalModulePath(evalId);
59
+ },
60
+ evalModule(evalId) {
61
+ return dotted(module.evalModulePath(evalId), module.extension);
62
+ },
63
+ retrievalIngestModuleFile(retrieverId) {
64
+ return module.retrievalIngestModulePath(retrieverId);
65
+ },
66
+ retrievalIngestModule(retrieverId) {
67
+ return dotted(module.retrievalIngestModulePath(retrieverId), module.extension);
68
+ },
69
+ };
70
+ }
71
+ /**
72
+ * The registry. Order matters only for the default: the first entry is what `aid gen`,
73
+ * `aid validate` and `aid init` use when the caller names no target, and that has been
74
+ * `py-fastapi` since Phase 0.
75
+ */
76
+ export const TARGETS = [
77
+ targetFor({
78
+ manifest: PY_FASTAPI_MANIFEST,
79
+ generator: pyFastApiGenerator,
80
+ runner: 'python',
81
+ extension: '.py',
82
+ evalsIndexPath: EVALS_INIT_PATH,
83
+ evalModulePath: pyFastApiEvalModulePath,
84
+ retrievalIngestModulePath: pyFastApiIngestModulePath,
85
+ checkPlan: checkPyFastApi,
86
+ }),
87
+ targetFor({
88
+ manifest: TS_VERCEL_MANIFEST,
89
+ generator: tsVercelGenerator,
90
+ runner: 'node',
91
+ // The generated modules are `.ts` on disk and `.js` once compiled; the dotted name
92
+ // is the same either way, and the path helpers hand back the file that exists.
93
+ extension: '.ts',
94
+ evalsIndexPath: tsVercelPaths.evalsIndex,
95
+ evalModulePath: tsVercelEvalModulePath,
96
+ retrievalIngestModulePath: tsVercelIngestModulePath,
97
+ checkPlan: checkTsVercel,
98
+ }),
99
+ ];
100
+ const [primary] = TARGETS;
101
+ if (primary === undefined) {
102
+ throw new Error('No Phase 0 target is registered.');
103
+ }
104
+ export const DEFAULT_TARGET = primary.name;
105
+ /** Where `aid validate` and `aid gen` look when the caller names no spec. */
106
+ export const DEFAULT_SPEC_PATH = primary.specPath;
107
+ export function targetNames() {
108
+ return TARGETS.map((target) => target.name);
109
+ }
110
+ /** The named target, the default when `name` is absent, or `undefined` when unknown. */
111
+ export function resolveTarget(name) {
112
+ if (name === undefined)
113
+ return primary;
114
+ return TARGETS.find((target) => target.name === name);
115
+ }
116
+ /**
117
+ * The capability declarations the build-time gates are run against.
118
+ *
119
+ * Derived from this registry rather than from the SDK's own `phase0Generators`, because
120
+ * the registry is the list of generators this binary can actually run: a spec targeting
121
+ * `ts-vercel` must be judged against `ts-vercel`'s declaration, and the SDK cannot name
122
+ * a generator that depends on the SDK.
123
+ */
124
+ export function targetCapabilities() {
125
+ return targetCapabilityDeclarations(TARGETS.map((target) => target.manifest));
126
+ }
127
+ /** Diagnostics for a target id the registry does not know. */
128
+ export function unknownTargetDiagnostic(name) {
129
+ return errorDiagnostic({
130
+ code: CLI_DIAGNOSTIC_CODES.unknownTarget,
131
+ message: `Unknown target \`${name}\`.`,
132
+ path: [],
133
+ hint: `Known targets: ${targetNames().join(', ')}.`,
134
+ });
135
+ }
136
+ //# sourceMappingURL=targets.js.map
@@ -0,0 +1 @@
1
+ {"version":3,"file":"targets.js","sourceRoot":"","sources":["../src/targets.ts"],"names":[],"mappings":"AAAA;;;;;;;;;;;;;GAaG;AAEH,OAAO,EACL,SAAS,IAAI,cAAc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AC;AAChF,CAAC;AAED,8DAA8D;AAC9D,MAAM,UAAU,uBAAuB,CAAC,IAAY;IAClD,OAAO,eAAe,CAAC;QACrB,IAAI,EAAE,oBAAoB,CAAC,aAAa;QACxC,OAAO,EAAE,oBAAoB,IAAI,KAAK;QACtC,IAAI,EAAE,EAAE;QACR,IAAI,EAAE,kBAAkB,WAAW,EAAE,CAAC,IAAI,CAAC,IAAI,CAAC,GAAG;KACpD,CAAC,CAAC;AACL,CAAC"}
@@ -0,0 +1,20 @@
1
+ /**
2
+ * Usage text, rendered from the same flag specs the parser enforces.
3
+ *
4
+ * Help that is written by hand drifts from the parser the first time a flag is added, and
5
+ * a help text listing a flag that does not exist is worse than no help. So one command
6
+ * table is the single source: `main.ts` registers each command with its flags, the parser
7
+ * validates against those flags, and these functions render them.
8
+ */
9
+ import type { FlagSpec } from './args.js';
10
+ export interface CommandSpec {
11
+ readonly name: string;
12
+ /** One line, shown in the global listing. */
13
+ readonly summary: string;
14
+ /** The invocation shape, as the user would type it. */
15
+ readonly usage: string;
16
+ readonly flags: readonly FlagSpec[];
17
+ }
18
+ export declare function commandUsage(command: CommandSpec): string;
19
+ export declare function globalUsage(commands: readonly CommandSpec[]): string;
20
+ //# sourceMappingURL=usage.d.ts.map
@@ -0,0 +1 @@
1
+ {"version":3,"file":"usage.d.ts","sourceRoot":"","sources":["../src/usage.ts"],"names":[],"mappings":"AAAA;;;;;;;GAOG;AAEH,OAAO,KAAK,EAAE,QAAQ,EAAE,MAAM,WAAW,CAAC;AAE1C,MAAM,WAAW,WAAW;IAC1B,QAAQ,CAAC,IAAI,EAAE,MAAM,CAAC;IACtB,6CAA6C;IAC7C,QAAQ,CAAC,OAAO,EAAE,MAAM,CAAC;IACzB,uDAAuD;IACvD,QAAQ,CAAC,KAAK,EAAE,MAAM,CAAC;IACvB,QAAQ,CAAC,KAAK,EAAE,SAAS,QAAQ,EAAE,CAAC;CACrC;AAaD,wBAAgB,YAAY,CAAC,OAAO,EAAE,WAAW,GAAG,MAAM,CAYzD;AAED,wBAAgB,WAAW,CAAC,QAAQ,EAAE,SAAS,WAAW,EAAE,GAAG,MAAM,CAiBpE"}
package/dist/usage.js ADDED
@@ -0,0 +1,49 @@
1
+ /**
2
+ * Usage text, rendered from the same flag specs the parser enforces.
3
+ *
4
+ * Help that is written by hand drifts from the parser the first time a flag is added, and
5
+ * a help text listing a flag that does not exist is worse than no help. So one command
6
+ * table is the single source: `main.ts` registers each command with its flags, the parser
7
+ * validates against those flags, and these functions render them.
8
+ */
9
+ /** The parser treats `help` specially; the help text still has to mention it. */
10
+ const HELP = {
11
+ name: 'help',
12
+ kind: 'boolean',
13
+ summary: "print this command's usage",
14
+ };
15
+ function flagLabel(flag) {
16
+ return flag.kind === 'value' ? `--${flag.name} <${flag.value ?? 'value'}>` : `--${flag.name}`;
17
+ }
18
+ export function commandUsage(command) {
19
+ const flags = [...command.flags, HELP];
20
+ const width = Math.max(...flags.map((flag) => flagLabel(flag).length));
21
+ return [
22
+ `Usage: aid ${command.usage}`,
23
+ '',
24
+ command.summary,
25
+ '',
26
+ 'Options:',
27
+ ...flags.map((flag) => ` ${flagLabel(flag).padEnd(width)} ${flag.summary}`),
28
+ '',
29
+ ].join('\n');
30
+ }
31
+ export function globalUsage(commands) {
32
+ const width = Math.max(...commands.map((command) => command.name.length));
33
+ return [
34
+ 'aid - the AID Framework CLI.',
35
+ '',
36
+ 'Usage: aid <command> [arguments] [options]',
37
+ '',
38
+ 'Commands:',
39
+ ...commands.map((command) => ` ${command.name.padEnd(width)} ${command.summary}`),
40
+ '',
41
+ 'Every command answers `--json` with one JSON document on stdout and `-h` with its',
42
+ 'usage. Exit codes: 0 the project is as asked, 1 the spec, a gate, the target or the',
43
+ 'working tree said no, 2 the invocation was wrong or the CLI failed internally.',
44
+ '',
45
+ "Run `aid <command> --help` for a command's options.",
46
+ '',
47
+ ].join('\n');
48
+ }
49
+ //# sourceMappingURL=usage.js.map
@@ -0,0 +1 @@
1
+ {"version":3,"file":"us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L,8BAA8B;QAC9B,EAAE;QACF,4CAA4C;QAC5C,EAAE;QACF,WAAW;QACX,GAAG,QAAQ,CAAC,GAAG,CAAC,CAAC,OAAO,EAAE,EAAE,CAAC,KAAK,OAAO,CAAC,IAAI,CAAC,MAAM,CAAC,KAAK,CAAC,KAAK,OAAO,CAAC,OAAO,EAAE,CAAC;QACnF,EAAE;QACF,mFAAmF;QACnF,qFAAqF;QACrF,gFAAgF;QAChF,EAAE;QACF,qDAAqD;QACrD,EAAE;KACH,CAAC,IAAI,CAAC,IAAI,CAAC,CAAC;AACf,CAAC"}
package/package.json CHANGED
@@ -1,14 +1,49 @@
1
- {
2
- "name": "@aid-framework/cli",
3
- "version": "0.0.0",
4
- "description": "Placeholder package created to register this name for OIDC trusted publishing. Contains no code; real releases are published by GitHub Actions.",
5
- "license": "Apache-2.0",
6
- "repository": {
7
- "type": "git",
8
- "url": "git+https://github.com/aid-framework/aid-framework.git",
9
- "directory": "packages/cli"
10
- },
11
- "publishConfig": {
12
- "access": "public"
13
- }
14
- }
1
+ {
2
+ "name": "@aid-framework/cli",
3
+ "version": "0.1.39",
4
+ "description": "The `aid` command: scaffold a project, validate its spec, generate its code, and run its eval gate.",
5
+ "license": "Apache-2.0",
6
+ "repository": {
7
+ "type": "git",
8
+ "url": "git+https://github.com/aid-framework/aid-framework.git",
9
+ "directory": "packages/cli"
10
+ },
11
+ "type": "module",
12
+ "main": "./dist/index.js",
13
+ "types": "./dist/index.d.ts",
14
+ "bin": {
15
+ "aid": "./dist/cli.js"
16
+ },
17
+ "exports": {
18
+ ".": {
19
+ "types": "./dist/index.d.ts",
20
+ "default": "./dist/index.js"
21
+ },
22
+ "./package.json": "./package.json"
23
+ },
24
+ "files": [
25
+ "dist",
26
+ "README.md"
27
+ ],
28
+ "sideEffects": false,
29
+ "engines": {
30
+ "node": ">=24"
31
+ },
32
+ "publishConfig": {
33
+ "access": "public"
34
+ },
35
+ "dependencies": {
36
+ "@aid-framework/generator-py-fastapi": "0.1.39",
37
+ "@aid-framework/generator-sdk": "0.1.39",
38
+ "@aid-framework/generator-ts-vercel": "0.1.39",
39
+ "@aid-framework/ir": "0.1.39",
40
+ "@aid-framework/spec": "0.1.39"
41
+ },
42
+ "devDependencies": {
43
+ "@types/node": "^26.6.5"
44
+ },
45
+ "scripts": {
46
+ "build": "tsc -b",
47
+ "clean": "tsc -b --clean"
48
+ }
49
+ }