@aid-framework/cli 0.1.59 → 0.1.61
This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
- package/dist/.tsbuildinfo +1 -1
- package/dist/commands/cost.d.ts +29 -0
- package/dist/commands/cost.d.ts.map +1 -0
- package/dist/commands/cost.js +205 -0
- package/dist/commands/cost.js.map +1 -0
- package/dist/commands/dev.d.ts +53 -0
- package/dist/commands/dev.d.ts.map +1 -0
- package/dist/commands/dev.js +235 -0
- package/dist/commands/dev.js.map +1 -0
- package/dist/diagnostics.d.ts +9 -0
- package/dist/diagnostics.d.ts.map +1 -1
- package/dist/diagnostics.js +15 -0
- package/dist/diagnostics.js.map +1 -1
- package/dist/index.d.ts +9 -3
- package/dist/index.d.ts.map +1 -1
- package/dist/index.js +5 -2
- package/dist/index.js.map +1 -1
- package/dist/main.d.ts.map +1 -1
- package/dist/main.js +33 -0
- package/dist/main.js.map +1 -1
- package/dist/python.d.ts +10 -1
- package/dist/python.d.ts.map +1 -1
- package/dist/python.js +12 -3
- package/dist/python.js.map +1 -1
- package/dist/targets.d.ts +19 -0
- package/dist/targets.d.ts.map +1 -1
- package/dist/targets.js +12 -0
- package/dist/targets.js.map +1 -1
- package/dist/trace.d.ts +89 -0
- package/dist/trace.d.ts.map +1 -0
- package/dist/trace.js +212 -0
- package/dist/trace.js.map +1 -0
- package/package.json +6 -6
|
@@ -0,0 +1,29 @@
|
|
|
1
|
+
/**
|
|
2
|
+
* `aid cost` — a cost and latency report read from the local trace sink.
|
|
3
|
+
*
|
|
4
|
+
* The numbers already exist. `runtimes/{python,typescript}` write one JSONL span per line
|
|
5
|
+
* whenever `AID_TRACE_DIR` is set, and those spans carry the GenAI token attributes and
|
|
6
|
+
* the priced `aid.cost.usd` the gateway computed. This command adds no pricing rule and
|
|
7
|
+
* no estimate: it reads what the runtime recorded and aggregates it. The build-time
|
|
8
|
+
* estimate is the IR's cost gate, and a second pricing implementation here would be a
|
|
9
|
+
* second answer to "what does this cost".
|
|
10
|
+
*
|
|
11
|
+
* Exit codes follow the CLI's taxonomy rather than "did the bill look big":
|
|
12
|
+
*
|
|
13
|
+
* - `2` when there is nowhere to read from (no directory, or one that does not exist), or
|
|
14
|
+
* when `--since` is not a date. The invocation or the environment is wrong, so no
|
|
15
|
+
* judgement about the project has been made.
|
|
16
|
+
* - `1` only when a trace file exists and could not be read. The report still prints what
|
|
17
|
+
* was readable, because a partial report is more useful than none.
|
|
18
|
+
* - `0` otherwise, including for an empty directory: a report of zero spans is true, and
|
|
19
|
+
* the warning on stderr says why it is zero.
|
|
20
|
+
*/
|
|
21
|
+
import type { CliContext } from '../context.js';
|
|
22
|
+
import type { CommandOutcome } from '../output.js';
|
|
23
|
+
export interface CostOptions {
|
|
24
|
+
/** The directory to read; defaults to `$AID_TRACE_DIR`. */
|
|
25
|
+
readonly dir: string | undefined;
|
|
26
|
+
readonly since: string | undefined;
|
|
27
|
+
}
|
|
28
|
+
export declare function cost(context: CliContext, options: CostOptions): CommandOutcome;
|
|
29
|
+
//# sourceMappingURL=cost.d.ts.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"cost.d.ts","sourceRoot":"","sources":["../../src/commands/cost.ts"],"names":[],"mappings":"AAAA;;;;;;;;;;;;;;;;;;;GAmBG;AAKH,OAAO,KAAK,EAAE,UAAU,EAAE,MAAM,eAAe,CAAC;AAIhD,OAAO,KAAK,EAAE,cAAc,EAAE,MAAM,cAAc,CAAC;AAQnD,MAAM,WAAW,WAAW;IAC1B,2DAA2D;IAC3D,QAAQ,CAAC,GAAG,EAAE,MAAM,GAAG,SAAS,CAAC;IACjC,QAAQ,CAAC,KAAK,EAAE,MAAM,GAAG,SAAS,CAAC;CACpC;AAyDD,wBAAgB,IAAI,CAAC,OAAO,EAAE,UAAU,EAAE,OAAO,EAAE,WAAW,GAAG,cAAc,CA4I9E"}
|
|
@@ -0,0 +1,205 @@
|
|
|
1
|
+
/**
|
|
2
|
+
* `aid cost` — a cost and latency report read from the local trace sink.
|
|
3
|
+
*
|
|
4
|
+
* The numbers already exist. `runtimes/{python,typescript}` write one JSONL span per line
|
|
5
|
+
* whenever `AID_TRACE_DIR` is set, and those spans carry the GenAI token attributes and
|
|
6
|
+
* the priced `aid.cost.usd` the gateway computed. This command adds no pricing rule and
|
|
7
|
+
* no estimate: it reads what the runtime recorded and aggregates it. The build-time
|
|
8
|
+
* estimate is the IR's cost gate, and a second pricing implementation here would be a
|
|
9
|
+
* second answer to "what does this cost".
|
|
10
|
+
*
|
|
11
|
+
* Exit codes follow the CLI's taxonomy rather than "did the bill look big":
|
|
12
|
+
*
|
|
13
|
+
* - `2` when there is nowhere to read from (no directory, or one that does not exist), or
|
|
14
|
+
* when `--since` is not a date. The invocation or the environment is wrong, so no
|
|
15
|
+
* judgement about the project has been made.
|
|
16
|
+
* - `1` only when a trace file exists and could not be read. The report still prints what
|
|
17
|
+
* was readable, because a partial report is more useful than none.
|
|
18
|
+
* - `0` otherwise, including for an empty directory: a report of zero spans is true, and
|
|
19
|
+
* the warning on stderr says why it is zero.
|
|
20
|
+
*/
|
|
21
|
+
import { readdirSync, readFileSync, statSync } from 'node:fs';
|
|
22
|
+
import { isAbsolute, join, relative, resolve, sep } from 'node:path';
|
|
23
|
+
import { CLI_DIAGNOSTIC_CODES, cliError, cliWarning } from '../diagnostics.js';
|
|
24
|
+
import { EXIT_FAILURE, EXIT_OK, EXIT_USAGE } from '../exit.js';
|
|
25
|
+
import { outcome } from '../output.js';
|
|
26
|
+
import { parseSince, parseTraceLines, summariseSpans } from '../trace.js';
|
|
27
|
+
/** The variable the runtimes read. Named here, not imported, because it is a runtime knob. */
|
|
28
|
+
const TRACE_DIR_ENV = 'AID_TRACE_DIR';
|
|
29
|
+
function displayPath(cwd, absolute) {
|
|
30
|
+
const path = relative(cwd, absolute);
|
|
31
|
+
if (path === '')
|
|
32
|
+
return '.';
|
|
33
|
+
if (path.startsWith('..') || isAbsolute(path))
|
|
34
|
+
return absolute;
|
|
35
|
+
return path.split(sep).join('/');
|
|
36
|
+
}
|
|
37
|
+
function group(value) {
|
|
38
|
+
return String(Math.trunc(value)).replace(/\B(?=(\d{3})+(?!\d))/g, ',');
|
|
39
|
+
}
|
|
40
|
+
function usd(value) {
|
|
41
|
+
return `$${value.toFixed(6)}`;
|
|
42
|
+
}
|
|
43
|
+
function modelLines(models) {
|
|
44
|
+
if (models.length === 0)
|
|
45
|
+
return [];
|
|
46
|
+
const width = Math.max(...models.map((model) => model.model.length));
|
|
47
|
+
const lines = ['by model:'];
|
|
48
|
+
for (const model of models) {
|
|
49
|
+
const unpriced = model.unpricedCalls === 0 ? '' : ` (${model.unpricedCalls} unpriced)`;
|
|
50
|
+
lines.push([
|
|
51
|
+
` ${model.model.padEnd(width)}`,
|
|
52
|
+
`${String(model.calls).padStart(4)} calls`,
|
|
53
|
+
`${group(model.inputTokens).padStart(9)} in`,
|
|
54
|
+
`${group(model.outputTokens).padStart(9)} out`,
|
|
55
|
+
usd(model.costUsd).padStart(14),
|
|
56
|
+
unpriced,
|
|
57
|
+
].join(' '));
|
|
58
|
+
}
|
|
59
|
+
return lines;
|
|
60
|
+
}
|
|
61
|
+
function reportLines(summary, dir, since) {
|
|
62
|
+
const scope = since === undefined ? '' : ` since ${since}`;
|
|
63
|
+
const lines = [
|
|
64
|
+
`dir: ${dir}`,
|
|
65
|
+
`spans: ${group(summary.spans)} in ${group(summary.traces)} trace(s)${scope}`,
|
|
66
|
+
summary.unpricedSpans === 0
|
|
67
|
+
? `cost: ${usd(summary.costUsd)}`
|
|
68
|
+
: `cost: ${usd(summary.costUsd)} (${summary.unpricedSpans} unpriced span(s) not included)`,
|
|
69
|
+
`tokens: ${group(summary.inputTokens)} input, ${group(summary.outputTokens)} output`,
|
|
70
|
+
];
|
|
71
|
+
if (summary.latency !== undefined) {
|
|
72
|
+
lines.push(`latency: p50 ${group(summary.latency.p50)}ms, p95 ${group(summary.latency.p95)}ms over ${group(summary.latency.samples)} model call(s)`);
|
|
73
|
+
}
|
|
74
|
+
if (summary.errors > 0)
|
|
75
|
+
lines.push(`errors: ${group(summary.errors)} span(s)`);
|
|
76
|
+
lines.push(...modelLines(summary.models));
|
|
77
|
+
return lines;
|
|
78
|
+
}
|
|
79
|
+
export function cost(context, options) {
|
|
80
|
+
const command = 'cost';
|
|
81
|
+
const configured = options.dir ?? context.env[TRACE_DIR_ENV]?.trim();
|
|
82
|
+
if (configured === undefined || configured === '') {
|
|
83
|
+
return outcome({
|
|
84
|
+
command,
|
|
85
|
+
exitCode: EXIT_USAGE,
|
|
86
|
+
diagnostics: [
|
|
87
|
+
cliError({
|
|
88
|
+
code: CLI_DIAGNOSTIC_CODES.traceDirMissing,
|
|
89
|
+
message: `no trace directory: \`aid cost\` needs one to read.`,
|
|
90
|
+
hint: `Pass it as \`aid ${command} <dir>\`, or set ${TRACE_DIR_ENV} to the directory the runtime writes to.`,
|
|
91
|
+
}),
|
|
92
|
+
],
|
|
93
|
+
text: `aid: no trace directory. Pass one, or set ${TRACE_DIR_ENV}.\n`,
|
|
94
|
+
});
|
|
95
|
+
}
|
|
96
|
+
let since;
|
|
97
|
+
if (options.since !== undefined) {
|
|
98
|
+
since = parseSince(options.since);
|
|
99
|
+
if (since === undefined) {
|
|
100
|
+
return outcome({
|
|
101
|
+
command,
|
|
102
|
+
exitCode: EXIT_USAGE,
|
|
103
|
+
diagnostics: [
|
|
104
|
+
cliError({
|
|
105
|
+
code: CLI_DIAGNOSTIC_CODES.traceSinceInvalid,
|
|
106
|
+
message: `--since "${options.since}" is not a date.`,
|
|
107
|
+
hint: 'Use YYYY-MM-DD (UTC midnight) or an ISO 8601 instant with an offset, such as 2026-10-01T12:00:00Z.',
|
|
108
|
+
}),
|
|
109
|
+
],
|
|
110
|
+
text: `aid: --since "${options.since}" is not a date.\n`,
|
|
111
|
+
});
|
|
112
|
+
}
|
|
113
|
+
}
|
|
114
|
+
const absolute = resolve(context.cwd, configured);
|
|
115
|
+
const shown = displayPath(context.cwd, absolute);
|
|
116
|
+
const diagnostics = [];
|
|
117
|
+
let isDirectory = false;
|
|
118
|
+
try {
|
|
119
|
+
isDirectory = statSync(absolute).isDirectory();
|
|
120
|
+
}
|
|
121
|
+
catch {
|
|
122
|
+
isDirectory = false;
|
|
123
|
+
}
|
|
124
|
+
if (!isDirectory) {
|
|
125
|
+
return outcome({
|
|
126
|
+
command,
|
|
127
|
+
exitCode: EXIT_USAGE,
|
|
128
|
+
diagnostics: [
|
|
129
|
+
cliError({
|
|
130
|
+
code: CLI_DIAGNOSTIC_CODES.traceDirNotFound,
|
|
131
|
+
message: `"${shown}" is not a directory.`,
|
|
132
|
+
hint: `Point \`aid ${command}\` at the directory ${TRACE_DIR_ENV} names, or unset it to be told which is missing.`,
|
|
133
|
+
}),
|
|
134
|
+
],
|
|
135
|
+
text: `aid: "${shown}" is not a directory.\n`,
|
|
136
|
+
});
|
|
137
|
+
}
|
|
138
|
+
const names = readdirSync(absolute, { withFileTypes: true })
|
|
139
|
+
.filter((entry) => entry.isFile() && entry.name.endsWith('.jsonl'))
|
|
140
|
+
.map((entry) => entry.name)
|
|
141
|
+
.sort();
|
|
142
|
+
let skipped = 0;
|
|
143
|
+
const all = [];
|
|
144
|
+
let unreadable = 0;
|
|
145
|
+
for (const name of names) {
|
|
146
|
+
let text;
|
|
147
|
+
try {
|
|
148
|
+
text = readFileSync(join(absolute, name), 'utf8');
|
|
149
|
+
}
|
|
150
|
+
catch {
|
|
151
|
+
// Counted, not thrown: one unreadable file should not hide the spans in the rest.
|
|
152
|
+
unreadable += 1;
|
|
153
|
+
continue;
|
|
154
|
+
}
|
|
155
|
+
const parsed = parseTraceLines(text);
|
|
156
|
+
all.push(...parsed.spans);
|
|
157
|
+
skipped += parsed.skipped;
|
|
158
|
+
}
|
|
159
|
+
if (unreadable > 0) {
|
|
160
|
+
diagnostics.push(cliError({
|
|
161
|
+
code: CLI_DIAGNOSTIC_CODES.traceUnreadable,
|
|
162
|
+
message: `could not read ${unreadable} trace file(s) in "${shown}": the report covers only the files that were readable.`,
|
|
163
|
+
hint: 'Check the file permissions, or move the unreadable file out of the directory.',
|
|
164
|
+
}));
|
|
165
|
+
}
|
|
166
|
+
if (skipped > 0) {
|
|
167
|
+
diagnostics.push(cliWarning({
|
|
168
|
+
code: CLI_DIAGNOSTIC_CODES.traceMalformed,
|
|
169
|
+
message: `skipped ${skipped} line(s) in "${shown}" that are not complete span records.`,
|
|
170
|
+
hint: 'A trace file is appended to while it is read, so a truncated last line is normal; a large count is not.',
|
|
171
|
+
}));
|
|
172
|
+
}
|
|
173
|
+
if (names.length === 0) {
|
|
174
|
+
diagnostics.push(cliWarning({
|
|
175
|
+
code: CLI_DIAGNOSTIC_CODES.traceEmpty,
|
|
176
|
+
message: `no trace files in "${shown}".`,
|
|
177
|
+
hint: `The runtime writes one when ${TRACE_DIR_ENV} is set and a model call runs; check that this is the directory it names.`,
|
|
178
|
+
}));
|
|
179
|
+
}
|
|
180
|
+
const summary = summariseSpans(all, since === undefined ? {} : { since });
|
|
181
|
+
const exitCode = unreadable > 0 ? EXIT_FAILURE : EXIT_OK;
|
|
182
|
+
return outcome({
|
|
183
|
+
command,
|
|
184
|
+
exitCode,
|
|
185
|
+
fields: {
|
|
186
|
+
dir: shown,
|
|
187
|
+
...(since === undefined ? {} : { since }),
|
|
188
|
+
files: names.length,
|
|
189
|
+
spans: summary.spans,
|
|
190
|
+
traces: summary.traces,
|
|
191
|
+
errors: summary.errors,
|
|
192
|
+
inputTokens: summary.inputTokens,
|
|
193
|
+
outputTokens: summary.outputTokens,
|
|
194
|
+
costUsd: summary.costUsd,
|
|
195
|
+
unpricedSpans: summary.unpricedSpans,
|
|
196
|
+
...(summary.latency === undefined
|
|
197
|
+
? {}
|
|
198
|
+
: { latencyMs: { p50: summary.latency.p50, p95: summary.latency.p95 } }),
|
|
199
|
+
models: summary.models,
|
|
200
|
+
},
|
|
201
|
+
diagnostics,
|
|
202
|
+
text: reportLines(summary, shown, since).join('\n'),
|
|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M;YACnB,KAAK,EAAE,OAAO,CAAC,KAAK;YACpB,MAAM,EAAE,OAAO,CAAC,MAAM;YACtB,MAAM,EAAE,OAAO,CAAC,MAAM;YACtB,WAAW,EAAE,OAAO,CAAC,WAAW;YAChC,YAAY,EAAE,OAAO,CAAC,YAAY;YAClC,OAAO,EAAE,OAAO,CAAC,OAAO;YACxB,aAAa,EAAE,OAAO,CAAC,aAAa;YACpC,GAAG,CAAC,OAAO,CAAC,OAAO,KAAK,SAAS;gBAC/B,CAAC,CAAC,EAAE;gBACJ,CAAC,CAAC,EAAE,SAAS,EAAE,EAAE,GAAG,EAAE,OAAO,CAAC,OAAO,CAAC,GAAG,EAAE,GAAG,EAAE,OAAO,CAAC,OAAO,CAAC,GAAG,EAAE,EAAE,CAAC;YAC1E,MAAM,EAAE,OAAO,CAAC,MAAM;SACvB;QACD,WAAW;QACX,IAAI,EAAE,WAAW,CAAC,OAAO,EAAE,KAAK,EAAE,KAAK,CAAC,CAAC,IAAI,CAAC,IAAI,CAAC;KACpD,CAAC,CAAC;AACL,CAAC"}
|
|
@@ -0,0 +1,53 @@
|
|
|
1
|
+
/**
|
|
2
|
+
* `aid dev` -- compile the spec, reconcile the tree, and run the application.
|
|
3
|
+
*
|
|
4
|
+
* **Why generation is part of it.** The command's whole promise is "the spec you just
|
|
5
|
+
* edited is the thing serving requests", and a `dev` that started a server against a tree
|
|
6
|
+
* compiled from an older spec would answer from code the developer is no longer looking
|
|
7
|
+
* at. So it runs the same generator the `gen` command does, and if generation fails it
|
|
8
|
+
* does not start the server: a tree that could not be reconciled is not a tree to serve.
|
|
9
|
+
*
|
|
10
|
+
* **Why it starts the target's own server instead of one of its own.** The Python target
|
|
11
|
+
* emits routers; the application owns `app/main.py` and decides what to mount and how to
|
|
12
|
+
* run it (the generator says so in its own comments). A dev server implemented here would
|
|
13
|
+
* be a second, competing way to run the same app, and it would drift. So this command
|
|
14
|
+
* spawns the module the application already declares, which is also what a person types by
|
|
15
|
+
* hand: `python -m uvicorn app.main:app`. `-m uvicorn` rather than the `uvicorn` binary,
|
|
16
|
+
* because the probe that proved the interpreter can import the runtime also proves it can
|
|
17
|
+
* import uvicorn; a `uvicorn` script on `PATH` proves neither.
|
|
18
|
+
*
|
|
19
|
+
* **Why a target may refuse.** `ts-vercel` is a deployment target: it emits route handlers
|
|
20
|
+
* that Next mounts, and ships no server of its own to start. Inventing one here would be
|
|
21
|
+
* exactly the competing dev server the previous paragraph rules out. The registry declares
|
|
22
|
+
* that per target, so this command refuses with a reason rather than guessing.
|
|
23
|
+
*
|
|
24
|
+
* **Why the start banner is printed by the command.** Every other command returns text and
|
|
25
|
+
* lets the dispatcher print it. This one hands the terminal to a child for an unbounded
|
|
26
|
+
* time, so a banner returned after the server exits would arrive after the log it was
|
|
27
|
+
* meant to introduce. The banner and the generation summary are therefore written as they
|
|
28
|
+
* happen, and the returned text is only the farewell.
|
|
29
|
+
*
|
|
30
|
+
* **Why there is no `--json`.** A JSON document is a verdict about a finished run. `dev`
|
|
31
|
+
* produces a running process and a stream of server output, so the honest answers are "a
|
|
32
|
+
* document that lies about when the run ended" or "a document interrupted by logs". It
|
|
33
|
+
* refuses `--json` as a usage error instead of emitting something that cannot be parsed.
|
|
34
|
+
*
|
|
35
|
+
* **What is not watched.** uvicorn's `--reload` reloads on changes to the code it imported,
|
|
36
|
+
* and that is left on by default. The *spec* is not watched: regenerating it needs the
|
|
37
|
+
* generator to run again, and doing that from a synchronous command would mean the
|
|
38
|
+
* dispatcher grew an event loop for one command. Restart `aid dev` after editing the spec;
|
|
39
|
+
* the generation step makes that restart cheap and the tree correct either way.
|
|
40
|
+
*/
|
|
41
|
+
import type { CliContext } from '../context.js';
|
|
42
|
+
import type { CommandOutcome } from '../output.js';
|
|
43
|
+
export interface DevOptions {
|
|
44
|
+
readonly spec: string | undefined;
|
|
45
|
+
readonly target: string | undefined;
|
|
46
|
+
readonly port: string | undefined;
|
|
47
|
+
/** Skip regeneration and serve the tree as it is. */
|
|
48
|
+
readonly noGen: boolean;
|
|
49
|
+
/** Turn off uvicorn's own reloader. */
|
|
50
|
+
readonly noReload: boolean;
|
|
51
|
+
}
|
|
52
|
+
export declare function dev(context: CliContext, options: DevOptions): CommandOutcome;
|
|
53
|
+
//# sourceMappingURL=dev.d.ts.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"dev.d.ts","sourceRoot":"","sources":["../../src/commands/dev.ts"],"names":[],"mappings":"AAAA;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;GAuCG;AAMH,OAAO,KAAK,EAAE,UAAU,EAAE,MAAM,eAAe,CAAC;AAIhD,OAAO,KAAK,EAAE,cAAc,EAAE,MAAM,cAAc,CAAC;AAOnD,MAAM,WAAW,UAAU;IACzB,QAAQ,CAAC,IAAI,EAAE,MAAM,GAAG,SAAS,CAAC;IAClC,QAAQ,CAAC,MAAM,EAAE,MAAM,GAAG,SAAS,CAAC;IACpC,QAAQ,CAAC,IAAI,EAAE,MAAM,GAAG,SAAS,CAAC;IAClC,qDAAqD;IACrD,QAAQ,CAAC,KAAK,EAAE,OAAO,CAAC;IACxB,uCAAuC;IACvC,QAAQ,CAAC,QAAQ,EAAE,OAAO,CAAC;CAC5B;AAaD,wBAAgB,GAAG,CAAC,OAAO,EAAE,UAAU,EAAE,OAAO,EAAE,UAAU,GAAG,cAAc,CA6L5E"}
|
|
@@ -0,0 +1,235 @@
|
|
|
1
|
+
/**
|
|
2
|
+
* `aid dev` -- compile the spec, reconcile the tree, and run the application.
|
|
3
|
+
*
|
|
4
|
+
* **Why generation is part of it.** The command's whole promise is "the spec you just
|
|
5
|
+
* edited is the thing serving requests", and a `dev` that started a server against a tree
|
|
6
|
+
* compiled from an older spec would answer from code the developer is no longer looking
|
|
7
|
+
* at. So it runs the same generator the `gen` command does, and if generation fails it
|
|
8
|
+
* does not start the server: a tree that could not be reconciled is not a tree to serve.
|
|
9
|
+
*
|
|
10
|
+
* **Why it starts the target's own server instead of one of its own.** The Python target
|
|
11
|
+
* emits routers; the application owns `app/main.py` and decides what to mount and how to
|
|
12
|
+
* run it (the generator says so in its own comments). A dev server implemented here would
|
|
13
|
+
* be a second, competing way to run the same app, and it would drift. So this command
|
|
14
|
+
* spawns the module the application already declares, which is also what a person types by
|
|
15
|
+
* hand: `python -m uvicorn app.main:app`. `-m uvicorn` rather than the `uvicorn` binary,
|
|
16
|
+
* because the probe that proved the interpreter can import the runtime also proves it can
|
|
17
|
+
* import uvicorn; a `uvicorn` script on `PATH` proves neither.
|
|
18
|
+
*
|
|
19
|
+
* **Why a target may refuse.** `ts-vercel` is a deployment target: it emits route handlers
|
|
20
|
+
* that Next mounts, and ships no server of its own to start. Inventing one here would be
|
|
21
|
+
* exactly the competing dev server the previous paragraph rules out. The registry declares
|
|
22
|
+
* that per target, so this command refuses with a reason rather than guessing.
|
|
23
|
+
*
|
|
24
|
+
* **Why the start banner is printed by the command.** Every other command returns text and
|
|
25
|
+
* lets the dispatcher print it. This one hands the terminal to a child for an unbounded
|
|
26
|
+
* time, so a banner returned after the server exits would arrive after the log it was
|
|
27
|
+
* meant to introduce. The banner and the generation summary are therefore written as they
|
|
28
|
+
* happen, and the returned text is only the farewell.
|
|
29
|
+
*
|
|
30
|
+
* **Why there is no `--json`.** A JSON document is a verdict about a finished run. `dev`
|
|
31
|
+
* produces a running process and a stream of server output, so the honest answers are "a
|
|
32
|
+
* document that lies about when the run ended" or "a document interrupted by logs". It
|
|
33
|
+
* refuses `--json` as a usage error instead of emitting something that cannot be parsed.
|
|
34
|
+
*
|
|
35
|
+
* **What is not watched.** uvicorn's `--reload` reloads on changes to the code it imported,
|
|
36
|
+
* and that is left on by default. The *spec* is not watched: regenerating it needs the
|
|
37
|
+
* generator to run again, and doing that from a synchronous command would mean the
|
|
38
|
+
* dispatcher grew an event loop for one command. Restart `aid dev` after editing the spec;
|
|
39
|
+
* the generation step makes that restart cheap and the tree correct either way.
|
|
40
|
+
*/
|
|
41
|
+
import { existsSync } from 'node:fs';
|
|
42
|
+
import { sortDiagnostics } from '@aid-framework/spec';
|
|
43
|
+
import { CLI_DIAGNOSTIC_CODES, cliError } from '../diagnostics.js';
|
|
44
|
+
import { EXIT_FAILURE, EXIT_OK, EXIT_USAGE } from '../exit.js';
|
|
45
|
+
import { outcome } from '../output.js';
|
|
46
|
+
import { absolutePath } from '../paths.js';
|
|
47
|
+
import { DEV_PROBE, discoverInterpreter, INTERPRETERS, interpreterCommand } from '../python.js';
|
|
48
|
+
import { resolveTarget, unknownTargetDiagnostic } from '../targets.js';
|
|
49
|
+
import { generate } from './gen.js';
|
|
50
|
+
/** uvicorn's own default, so `aid dev` and `uvicorn app.main:app` agree. */
|
|
51
|
+
const DEFAULT_PORT = 8000;
|
|
52
|
+
/** The port, or `undefined` when the flag could not have meant one. */
|
|
53
|
+
function parsePort(raw) {
|
|
54
|
+
if (raw === undefined)
|
|
55
|
+
return DEFAULT_PORT;
|
|
56
|
+
if (!/^\d+$/.test(raw))
|
|
57
|
+
return undefined;
|
|
58
|
+
const port = Number(raw);
|
|
59
|
+
return port >= 1 && port <= 65_535 ? port : undefined;
|
|
60
|
+
}
|
|
61
|
+
export function dev(context, options) {
|
|
62
|
+
const command = 'dev';
|
|
63
|
+
const target = resolveTarget(options.target);
|
|
64
|
+
if (target === undefined) {
|
|
65
|
+
return outcome({
|
|
66
|
+
command,
|
|
67
|
+
exitCode: EXIT_USAGE,
|
|
68
|
+
diagnostics: [unknownTargetDiagnostic(options.target ?? '')],
|
|
69
|
+
});
|
|
70
|
+
}
|
|
71
|
+
// Before the project is touched: a port that is not a port is a mistake in the
|
|
72
|
+
// invocation, and reporting a spec problem instead would bury the actual mistake.
|
|
73
|
+
const port = parsePort(options.port);
|
|
74
|
+
if (port === undefined) {
|
|
75
|
+
return outcome({
|
|
76
|
+
command,
|
|
77
|
+
exitCode: EXIT_USAGE,
|
|
78
|
+
diagnostics: [
|
|
79
|
+
cliError({
|
|
80
|
+
code: CLI_DIAGNOSTIC_CODES.devPortInvalid,
|
|
81
|
+
message: `\`--port\` needs an integer between 1 and 65535, got "${options.port}".`,
|
|
82
|
+
}),
|
|
83
|
+
],
|
|
84
|
+
});
|
|
85
|
+
}
|
|
86
|
+
const specPath = options.spec ?? target.specPath;
|
|
87
|
+
const fields = { target: target.name, spec: specPath, port };
|
|
88
|
+
const surface = target.dev;
|
|
89
|
+
if (surface.kind === 'none') {
|
|
90
|
+
return outcome({
|
|
91
|
+
command,
|
|
92
|
+
// Exit 2, not 1: no server was started and no project was judged, so nothing here
|
|
93
|
+
// is a verdict about the tree.
|
|
94
|
+
exitCode: EXIT_USAGE,
|
|
95
|
+
fields,
|
|
96
|
+
diagnostics: [
|
|
97
|
+
cliError({
|
|
98
|
+
code: CLI_DIAGNOSTIC_CODES.runnerUnsupported,
|
|
99
|
+
message: `\`aid dev\` cannot start ${target.name}: ${surface.reason}.`,
|
|
100
|
+
hint: 'Run the application with the server its platform provides; `aid gen` still compiles and reconciles the tree.',
|
|
101
|
+
}),
|
|
102
|
+
],
|
|
103
|
+
});
|
|
104
|
+
}
|
|
105
|
+
const diagnostics = [];
|
|
106
|
+
if (!options.noGen) {
|
|
107
|
+
const generated = generate(context, {
|
|
108
|
+
spec: options.spec,
|
|
109
|
+
target: options.target,
|
|
110
|
+
dryRun: false,
|
|
111
|
+
force: false,
|
|
112
|
+
check: false,
|
|
113
|
+
});
|
|
114
|
+
if (generated.exitCode !== EXIT_OK) {
|
|
115
|
+
// The generator's own summary and diagnostics are the answer: it is the same
|
|
116
|
+
// failure `aid gen` would have reported, and renaming it here would hide that.
|
|
117
|
+
return outcome({
|
|
118
|
+
command,
|
|
119
|
+
exitCode: generated.exitCode,
|
|
120
|
+
fields,
|
|
121
|
+
diagnostics: generated.diagnostics,
|
|
122
|
+
text: generated.text,
|
|
123
|
+
});
|
|
124
|
+
}
|
|
125
|
+
if (generated.text !== '')
|
|
126
|
+
context.stdout(`${generated.text}\n`);
|
|
127
|
+
diagnostics.push(...generated.diagnostics);
|
|
128
|
+
}
|
|
129
|
+
// The entry point is the application's own file, not a generated one, so its absence
|
|
130
|
+
// means the project was never set up rather than never regenerated. Named explicitly
|
|
131
|
+
// because "app/main.py is missing" is the one thing the reader needs to know.
|
|
132
|
+
const entry = absolutePath(context.cwd, surface.entry);
|
|
133
|
+
if (!existsSync(entry)) {
|
|
134
|
+
return outcome({
|
|
135
|
+
command,
|
|
136
|
+
exitCode: EXIT_FAILURE,
|
|
137
|
+
fields,
|
|
138
|
+
diagnostics: [
|
|
139
|
+
cliError({
|
|
140
|
+
code: CLI_DIAGNOSTIC_CODES.devEntryMissing,
|
|
141
|
+
message: `No ASGI entry point at ${surface.entry}.`,
|
|
142
|
+
path: [surface.entry],
|
|
143
|
+
hint: 'Run `aid init` for a starter entry point, or run `aid dev` from the directory that contains the generated app.',
|
|
144
|
+
}),
|
|
145
|
+
],
|
|
146
|
+
});
|
|
147
|
+
}
|
|
148
|
+
const interpreter = discoverInterpreter(context, DEV_PROBE);
|
|
149
|
+
if (interpreter === undefined) {
|
|
150
|
+
return outcome({
|
|
151
|
+
command,
|
|
152
|
+
// Exit 2: the project was not judged, because nothing could start it.
|
|
153
|
+
exitCode: EXIT_USAGE,
|
|
154
|
+
fields,
|
|
155
|
+
diagnostics: [
|
|
156
|
+
cliError({
|
|
157
|
+
code: CLI_DIAGNOSTIC_CODES.devUvicornMissing,
|
|
158
|
+
message: `No interpreter can import both aid_runtime and uvicorn (tried ${INTERPRETERS.join(', ')}).`,
|
|
159
|
+
hint: 'Install the runtime and uvicorn into the interpreter you run with, or run `python -m uvicorn` yourself.',
|
|
160
|
+
}),
|
|
161
|
+
],
|
|
162
|
+
});
|
|
163
|
+
}
|
|
164
|
+
const argv = [
|
|
165
|
+
...interpreterCommand(interpreter),
|
|
166
|
+
'-m',
|
|
167
|
+
'uvicorn',
|
|
168
|
+
surface.module,
|
|
169
|
+
'--host',
|
|
170
|
+
'127.0.0.1',
|
|
171
|
+
'--port',
|
|
172
|
+
String(port),
|
|
173
|
+
...(options.noReload ? [] : ['--reload']),
|
|
174
|
+
];
|
|
175
|
+
// Bound to loopback on purpose: a dev server is for the machine it runs on, and a
|
|
176
|
+
// `0.0.0.0` default quietly exposes a half-built app to the network.
|
|
177
|
+
context.stdout([
|
|
178
|
+
`${target.name}: serving ${surface.module} on http://127.0.0.1:${port}${options.noReload ? '' : ' (reload on)'}`,
|
|
179
|
+
` ${argv.join(' ')}`,
|
|
180
|
+
'Press Ctrl-C to stop.',
|
|
181
|
+
'',
|
|
182
|
+
].join('\n'));
|
|
183
|
+
const run = context.spawn(argv[0] ?? interpreter, argv.slice(1), {
|
|
184
|
+
cwd: context.cwd,
|
|
185
|
+
stdio: 'inherit',
|
|
186
|
+
env: context.env,
|
|
187
|
+
});
|
|
188
|
+
if (run.error !== undefined) {
|
|
189
|
+
return outcome({
|
|
190
|
+
command,
|
|
191
|
+
exitCode: EXIT_USAGE,
|
|
192
|
+
fields: { ...fields, interpreter },
|
|
193
|
+
diagnostics: [
|
|
194
|
+
cliError({
|
|
195
|
+
code: CLI_DIAGNOSTIC_CODES.runnerFailed,
|
|
196
|
+
message: `Could not start ${interpreter} to run "${surface.module}": ${run.error.message}`,
|
|
197
|
+
}),
|
|
198
|
+
],
|
|
199
|
+
});
|
|
200
|
+
}
|
|
201
|
+
// A null status means the child was ended by a signal, which for a foreground server is
|
|
202
|
+
// how Ctrl-C arrives. Reporting that as a failure would make stopping the dev server
|
|
203
|
+
// look like the server broke.
|
|
204
|
+
if (run.status === null) {
|
|
205
|
+
return outcome({
|
|
206
|
+
command,
|
|
207
|
+
exitCode: EXIT_OK,
|
|
208
|
+
fields: { ...fields, interpreter, stopped: true },
|
|
209
|
+
diagnostics: sortDiagnostics(diagnostics),
|
|
210
|
+
text: 'server stopped.',
|
|
211
|
+
});
|
|
212
|
+
}
|
|
213
|
+
if (run.status !== 0) {
|
|
214
|
+
return outcome({
|
|
215
|
+
command,
|
|
216
|
+
exitCode: EXIT_FAILURE,
|
|
217
|
+
fields: { ...fields, interpreter, status: run.status },
|
|
218
|
+
diagnostics: sortDiagnostics([
|
|
219
|
+
...diagnostics,
|
|
220
|
+
cliError({
|
|
221
|
+
code: CLI_DIAGNOSTIC_CODES.runnerFailed,
|
|
222
|
+
message: `The server exited with status ${run.status}.`,
|
|
223
|
+
}),
|
|
224
|
+
]),
|
|
225
|
+
});
|
|
226
|
+
}
|
|
227
|
+
return outcome({
|
|
228
|
+
command,
|
|
229
|
+
exitCode: EXIT_OK,
|
|
230
|
+
fields: { ...fields, interpreter },
|
|
231
|
+
diagnostics: sortDiagnostics(diagnostics),
|
|
232
|
+
text: 'server stopped.',
|
|
233
|
+
});
|
|
234
|
+
}
|
|
235
|
+
//# sourceMappingURL=dev.js.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"dev.js","sourceRoot":"","sources":["../../src/commands/dev.ts"],"names":[],"mappings":"AAAA;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;GAuCG;AAEH,OAAO,EAAE,UAAU,EAAE,MAAM,SAAS,CAAC;AAErC,OAAO,EAAE,eAAe,EAAE,MAAM,qBAAqB,CAAC;AAItD,OAAO,EAAE,oBAAoB,EAAE,QAAQ,EAAE,MAAM,mBAAmB,CAAC;AACnE,OAAO,EAAE,YAAY,EAAE,OAAO,EAAE,UAAU,EAAE,MAAM,YAAY,CAAC;AAE/D,OAAO,EAAE,OAAO,EAAE,MAAM,cAAc,CAAC;AACvC,OAAO,EAAE,YAAY,EAAE,MAAM,aAAa,CAAC;AAC3C,OAAO,EAAE,SAAS,EAAE,mBAAmB,EAAE,YAAY,EAAE,kBAAkB,EAAE,MAAM,cAAc,CAAC;AAChG,OAAO,EAAE,aAAa,EAAE,uBAAuB,EAAE,MAAM,eAAe,CAAC;AACvE,OAAO,EAAE,QAAQ,EAAE,MAAM,UAAU,CAAC;AAYpC,4EAA4E;AAC5E,MAAM,YAAY,GAAG,IAAI,CAAC;AAE1B,uEAAuE;AACvE,SAAS,SAA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;SACxB,CAAC,CAAC;IACL,CAAC;IAED,IAAI,GAAG,CAAC,MAAM,KAAK,CAAC,EAAE,CAAC;QACrB,OAAO,OAAO,CAAC;YACb,OAAO;YACP,QAAQ,EAAE,YAAY;YACtB,MAAM,EAAE,EAAE,GAAG,MAAM,EAAE,WAAW,EAAE,MAAM,EAAE,GAAG,CAAC,MAAM,EAAE;YACtD,WAAW,EAAE,eAAe,CAAC;gBAC3B,GAAG,WAAW;gBACd,QAAQ,CAAC;oBACP,IAAI,EAAE,oBAAoB,CAAC,YAAY;oBACvC,OAAO,EAAE,iCAAiC,GAAG,CAAC,MAAM,GAAG;iBACxD,CAAC;aACH,CAAC;SACH,CAAC,CAAC;IACL,CAAC;IAED,OAAO,OAAO,CAAC;QACb,OAAO;QACP,QAAQ,EAAE,OAAO;QACjB,MAAM,EAAE,EAAE,GAAG,MAAM,EAAE,WAAW,EAAE;QAClC,WAAW,EAAE,eAAe,CAAC,WAAW,CAAC;QACzC,IAAI,EAAE,iBAAiB;KACxB,CAAC,CAAC;AACL,CAAC"}
|
package/dist/diagnostics.d.ts
CHANGED
|
@@ -48,6 +48,15 @@ export declare const CLI_DIAGNOSTIC_CODES: {
|
|
|
48
48
|
readonly infraDriftDetected: 'cli/infra-drift-detected';
|
|
49
49
|
readonly infraConfirmProdRequired: 'cli/infra-confirm-prod-required';
|
|
50
50
|
readonly ejectUnmanagedPath: 'cli/eject-unmanaged-path';
|
|
51
|
+
readonly traceDirMissing: 'cli/trace-dir-missing';
|
|
52
|
+
readonly traceDirNotFound: 'cli/trace-dir-not-found';
|
|
53
|
+
readonly traceSinceInvalid: 'cli/trace-since-invalid';
|
|
54
|
+
readonly traceUnreadable: 'cli/trace-unreadable';
|
|
55
|
+
readonly traceMalformed: 'cli/trace-malformed';
|
|
56
|
+
readonly traceEmpty: 'cli/trace-empty';
|
|
57
|
+
readonly devPortInvalid: 'cli/dev-port-invalid';
|
|
58
|
+
readonly devEntryMissing: 'cli/dev-entry-missing';
|
|
59
|
+
readonly devUvicornMissing: 'cli/dev-uvicorn-missing';
|
|
51
60
|
};
|
|
52
61
|
export type CliDiagnosticCode = (typeof CLI_DIAGNOSTIC_CODES)[keyof typeof CLI_DIAGNOSTIC_CODES];
|
|
53
62
|
export interface CliDiagnosticInit {
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"diagnostics.d.ts","sourceRoot":"","sources":["../src/diagnostics.ts"],"names":[],"mappings":"AAAA;;;;;;;;;;;;;GAaG;AAEH,OAAO,KAAK,EAAE,UAAU,EAAE,MAAM,qBAAqB,CAAC;AAGtD,gEAAgE;AAChE,MAAM,MAAM,aAAa,GAAG,UAAU,CAAC,MAAM,CAAC,CAAC;AAE/C,eAAO,MAAM,oBAAoB;aAC/B,cAAc,EAAE,qBAAqB;aACrC,aAAa,EAAE,oBAAoB;aACnC,mBAAmB,EAAE,2BAA2B;aAChD,aAAa,EAAE,oBAAoB;aACnC,aAAa,EAAE,qBAAqB;aACpC,kBAAkB,EAAE,0BAA0B;aAC9C,iBAAiB,EAAE,wBAAwB;aAC3C,iBAAiB,EAAE,wBAAwB;aAC3C,iBAAiB,EAAE,yBAAyB;aAC5C,oBAAoB,EAAE,4BAA4B;aAClD,iBAAiB,EAAE,wBAAwB;aAC3C,YAAY,EAAE,mBAAmB;aACjC,YAAY,EAAE,mBAAmB;aAGjC,eAAe,EAAE,sBAAsB;aACvC,kBAAkB,EAAE,yBAAyB;aAC7C,eAAe,EAAE,sBAAsB;aACvC,YAAY,EAAE,mBAAmB;aACjC,eAAe,EAAE,sBAAsB;aACvC,aAAa,EAAE,oBAAoB;aAGnC,uBAAuB,EAAE,+BAA+B;aACxD,sBAAsB,EAAE,8BAA8B;aACtD,eAAe,EAAE,uBAAuB;aACxC,sBAAsB,EAAE,8BAA8B;aACtD,iBAAiB,EAAE,yBAAyB;aAC5C,mBAAmB,EAAE,4BAA4B;aACjD,gBAAgB,EAAE,wBAAwB;aAC1C,eAAe,EAAE,uBAAuB;aACxC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kB,EAAE,0BAA0B;aAC9C,wBAAwB,EAAE,iCAAiC;aAI3D,kBAAkB,EAAE,0BAA0B;aAI9C,eAAe,EAAE,uBAAuB;aACxC,gBAAgB,EAAE,yBAAyB;aAC3C,iBAAiB,EAAE,yBAAyB;aAC5C,eAAe,EAAE,sBAAsB;aACvC,cAAc,EAAE,qBAAqB;aACrC,UAAU,EAAE,iBAAiB;aAI7B,cAAc,EAAE,sBAAsB;aACtC,eAAe,EAAE,uBAAuB;aACxC,iBAAiB,EAAE,yBAAyB;CACpC,CAAC;AAEX,MAAM,MAAM,iBAAiB,GAAG,CAAC,OAAO,oBAAoB,CAAC,CAAC,MAAM,OAAO,oBAAoB,CAAC,CAAC;AAEjG,MAAM,WAAW,iBAAiB;IAChC,QAAQ,CAAC,IAAI,EAAE,iBAAiB,CAAC;IACjC,QAAQ,CAAC,OAAO,EAAE,MAAM,CAAC;IACzB,QAAQ,CAAC,IAAI,CAAC,EAAE,SAAS,MAAM,EAAE,CAAC;IAClC,QAAQ,CAAC,IAAI,CAAC,EAAE,MAAM,CAAC;CACxB;AAED,wBAAgB,QAAQ,CAAC,IAAI,EAAE,iBAAiB,GAAG,aAAa,CAO/D;AAED,wBAAgB,UAAU,CAAC,IAAI,EAAE,iBAAiB,GAAG,aAAa,CAOjE"}
|
package/dist/diagnostics.js
CHANGED
|
@@ -53,6 +53,21 @@ export const CLI_DIAGNOSTIC_CODES = {
|
|
|
53
53
|
// with a `generator/` code, so a reader can tell "you named the wrong tree" from
|
|
54
54
|
// "this file cannot be ejected".
|
|
55
55
|
ejectUnmanagedPath: 'cli/eject-unmanaged-path',
|
|
56
|
+
// `aid cost` reads the runtime's local trace sink. The first two mean there is
|
|
57
|
+
// nothing to read (exit 2); the last three describe a report that is incomplete or
|
|
58
|
+
// empty, which is a fact about the traces rather than about the invocation.
|
|
59
|
+
traceDirMissing: 'cli/trace-dir-missing',
|
|
60
|
+
traceDirNotFound: 'cli/trace-dir-not-found',
|
|
61
|
+
traceSinceInvalid: 'cli/trace-since-invalid',
|
|
62
|
+
traceUnreadable: 'cli/trace-unreadable',
|
|
63
|
+
traceMalformed: 'cli/trace-malformed',
|
|
64
|
+
traceEmpty: 'cli/trace-empty',
|
|
65
|
+
// `aid dev` starts the application's own server, so every failure here is about the
|
|
66
|
+
// environment it needs or the address it was given -- not about the spec, which `gen`
|
|
67
|
+
// has already validated by the time any of these can fire.
|
|
68
|
+
devPortInvalid: 'cli/dev-port-invalid',
|
|
69
|
+
devEntryMissing: 'cli/dev-entry-missing',
|
|
70
|
+
devUvicornMissing: 'cli/dev-uvicorn-missing',
|
|
56
71
|
};
|
|
57
72
|
export function cliError(init) {
|
|
58
73
|
return errorDiagnostic({
|
package/dist/diagnostics.js.map
CHANGED
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"diagnostics.js","sourceRoot":"","sources":["../src/diagnostics.ts"],"names":[],"mappings":"AAAA;;;;;;;;;;;;;GAaG;AAGH,OAAO,EAAE,eAAe,EAAE,iBAAiB,EAAE,MAAM,qBAAqB,CAAC;AAKzE,MAAM,CAAC,MAAM,oBAAoB,GAAG;IAClC,cAAc,EAAE,qBAAqB;IACrC,aAAa,EAAE,oBAAoB;IACnC,mBAAmB,EAAE,2BAA2B;IAChD,aAAa,EAAE,oBAAoB;IACnC,aAAa,EAAE,qBAAqB;IACpC,kBAAkB,EAAE,0BAA0B;IAC9C,iBAAiB,EAAE,wBAAwB;IAC3C,iBAAiB,EAAE,wBAAwB;IAC3C,iBAAiB,EAAE,yBAAyB;IAC5C,oBAAoB,EAAE,4BAA4B;IAClD,iBAAiB,EAAE,wBAAwB;IAC3C,YAAY,EAAE,mBAAmB;IACjC,YAAY,EAAE,mBAAmB;IACjC,kFAAkF;IAClF,8EAA8E;IAC9E,eAAe,EAAE,sBAAsB;IACvC,kBAAkB,EAAE,yBAAyB;IAC7C,eAAe,EAAE,sBAAsB;IACvC,YAAY,EAAE,mBAAmB;IACjC,eAAe,EAAE,sBAAsB;IACvC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I,CAAC,IAAI;QACf,OAAO,EAAE,IAAI,CAAC,OAAO;QACrB,IAAI,EAAE,IAAI,CAAC,IAAI,IAAI,EAAE;QACrB,GAAG,CAAC,IAAI,CAAC,IAAI,KAAK,SAAS,CAAC,CAAC,CAAC,EAAE,CAAC,CAAC,CAAC,EAAE,IAAI,EAAE,IAAI,CAAC,IAAI,EAAE,CAAC;KACxD,CAAC,CAAC;AACL,CAAC"}
|
package/dist/index.d.ts
CHANGED
|
@@ -1,5 +1,5 @@
|
|
|
1
1
|
/**
|
|
2
|
-
* `@aid-framework/cli` - the `aid` command: init, validate, gen, ingest, eval and
|
|
2
|
+
* `@aid-framework/cli` - the `aid` command: init, validate, gen, dev, ingest, eval, cost, doctor, eject and infra.
|
|
3
3
|
*
|
|
4
4
|
* The CLI is glue. Every judgement it reports -- whether a spec parses, what the IR is,
|
|
5
5
|
* what a target can emit, which generated file was hand-edited, whether an eval regressed
|
|
@@ -12,6 +12,10 @@
|
|
|
12
12
|
*/
|
|
13
13
|
export type { FlagSpec, ParsedArguments, ParseOutcome } from './args.js';
|
|
14
14
|
export { booleanFlag, JSON_FLAG, parseArguments, valueFlag } from './args.js';
|
|
15
|
+
export type { CostOptions } from './commands/cost.js';
|
|
16
|
+
export { cost } from './commands/cost.js';
|
|
17
|
+
export type { DevOptions } from './commands/dev.js';
|
|
18
|
+
export { dev } from './commands/dev.js';
|
|
15
19
|
export type { DoctorOptions } from './commands/doctor.js';
|
|
16
20
|
export { doctor } from './commands/doctor.js';
|
|
17
21
|
export type { EvalOptions } from './commands/eval.js';
|
|
@@ -42,9 +46,11 @@ export { emit, outcome } from './output.js';
|
|
|
42
46
|
export { absolutePath, parentPath } from './paths.js';
|
|
43
47
|
export type { Compiled, CompileOutcome, Failed, Lowered, LowerOutcome, ManifestOutcome, ReadManifest, ReadSpec, } from './pipeline.js';
|
|
44
48
|
export { compile, lowerSpec, provenanceFor, readManifest, readSpec } from './pipeline.js';
|
|
45
|
-
export { discoverInterpreter, INTERPRETERS, interpreterCommand, invoke } from './python.js';
|
|
46
|
-
export type { Target } from './targets.js';
|
|
49
|
+
export { DEV_PROBE, discoverInterpreter, INTERPRETERS, interpreterCommand, invoke, } from './python.js';
|
|
50
|
+
export type { Target, TargetDev } from './targets.js';
|
|
47
51
|
export { DEFAULT_SPEC_PATH, DEFAULT_TARGET, resolveTarget, TARGETS, targetCapabilities, targetNames, unknownTargetDiagnostic, } from './targets.js';
|
|
52
|
+
export type { CostSummary, Latency, ModelSpend, ParsedTrace, TraceSpan } from './trace.js';
|
|
53
|
+
export { parseSince, parseTraceLines, summariseSpans } from './trace.js';
|
|
48
54
|
export type { CommandSpec } from './usage.js';
|
|
49
55
|
export { commandUsage, globalUsage } from './usage.js';
|
|
50
56
|
//# sourceMappingURL=index.d.ts.map
|