@xenos1996/usa 2.15.0 → 2.16.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/dist/cli-args.d.ts +25 -0
- package/dist/cli-args.d.ts.map +1 -0
- package/dist/cli-args.js +90 -0
- package/dist/cli-args.js.map +1 -0
- package/dist/cli-audit.d.ts +3 -0
- package/dist/cli-audit.d.ts.map +1 -0
- package/dist/cli-audit.js +180 -0
- package/dist/cli-audit.js.map +1 -0
- package/dist/cli-evolve.d.ts +4 -0
- package/dist/cli-evolve.d.ts.map +1 -0
- package/dist/cli-evolve.js +182 -0
- package/dist/cli-evolve.js.map +1 -0
- package/dist/cli-help.d.ts +6 -0
- package/dist/cli-help.d.ts.map +1 -0
- package/dist/cli-help.js +152 -0
- package/dist/cli-help.js.map +1 -0
- package/dist/cli-query.d.ts +13 -0
- package/dist/cli-query.d.ts.map +1 -0
- package/dist/cli-query.js +166 -0
- package/dist/cli-query.js.map +1 -0
- package/dist/cli-reports.d.ts +5 -0
- package/dist/cli-reports.d.ts.map +1 -0
- package/dist/cli-reports.js +111 -0
- package/dist/cli-reports.js.map +1 -0
- package/dist/cli-scaffold.d.ts +6 -0
- package/dist/cli-scaffold.d.ts.map +1 -0
- package/dist/cli-scaffold.js +129 -0
- package/dist/cli-scaffold.js.map +1 -0
- package/dist/cli-session.d.ts +18 -0
- package/dist/cli-session.d.ts.map +1 -0
- package/dist/cli-session.js +136 -0
- package/dist/cli-session.js.map +1 -0
- package/dist/cli.d.ts +1 -1
- package/dist/cli.d.ts.map +1 -1
- package/dist/cli.js +11 -1097
- package/dist/cli.js.map +1 -1
- package/dist/report/html.d.ts +20 -0
- package/dist/report/html.d.ts.map +1 -0
- package/dist/report/html.js +117 -0
- package/dist/report/html.js.map +1 -0
- package/package.json +1 -1
|
@@ -0,0 +1,18 @@
|
|
|
1
|
+
import { type Args } from './cli-args.js';
|
|
2
|
+
/** Conversational commands: foundation init/show, live sessions, model listing. */
|
|
3
|
+
export declare function cmdFoundation(args: Args): number;
|
|
4
|
+
/**
|
|
5
|
+
* `usa live`: conversational audit session (foundation → audit → triage →
|
|
6
|
+
* report). The default chat is the agent layer's `complete()`; without a
|
|
7
|
+
* configured provider the session runs deterministically (loud skips, no
|
|
8
|
+
* model calls). Async only because the LLM transport is async — every
|
|
9
|
+
* deterministic step stays synchronous underneath.
|
|
10
|
+
*/
|
|
11
|
+
export declare function cmdLive(args: Args): Promise<number>;
|
|
12
|
+
/**
|
|
13
|
+
* `usa models`: what the provider actually serves, so a model id can be
|
|
14
|
+
* checked before a session burns calls on a 404. Read-only and side-effect
|
|
15
|
+
* free beyond one GET.
|
|
16
|
+
*/
|
|
17
|
+
export declare function cmdModels(args: Args): Promise<number>;
|
|
18
|
+
//# sourceMappingURL=cli-session.d.ts.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"cli-session.d.ts","sourceRoot":"","sources":["../src/cli-session.ts"],"names":[],"mappings":"AAIA,OAAO,EAA2B,KAAK,IAAI,EAAE,MAAM,eAAe,CAAC;AAEnE,mFAAmF;AAGnF,wBAAgB,aAAa,CAAC,IAAI,EAAE,IAAI,GAAG,MAAM,CAiBhD;AAID;;;;;;GAMG;AACH,wBAAsB,OAAO,CAAC,IAAI,EAAE,IAAI,GAAG,OAAO,CAAC,MAAM,CAAC,CA4BzD;AA0DD;;;;GAIG;AACH,wBAAsB,SAAS,CAAC,IAAI,EAAE,IAAI,GAAG,OAAO,CAAC,MAAM,CAAC,CAsB3D"}
|
|
@@ -0,0 +1,136 @@
|
|
|
1
|
+
import { createStdinAsk, runFoundationInit, runFoundationShow } from './foundation/interview.js';
|
|
2
|
+
import { checkModelAdvertised, runLiveSession } from './live/runner.js';
|
|
3
|
+
import { complete, listModels, loadProviderConfig } from './agent/index.js';
|
|
4
|
+
import { LIVE_HELP_TEXT, MODELS_HELP_TEXT } from './cli-help.js';
|
|
5
|
+
import { bool, dryRunWrites, str } from './cli-args.js';
|
|
6
|
+
/** Conversational commands: foundation init/show, live sessions, model listing. */
|
|
7
|
+
/* ------------------------------------------------------------ foundation -- */
|
|
8
|
+
export function cmdFoundation(args) {
|
|
9
|
+
const sub = args._[1];
|
|
10
|
+
const dir = str(args, 'dir') ?? args._[2] ?? '.';
|
|
11
|
+
if (sub === 'init') {
|
|
12
|
+
return runFoundationInit({
|
|
13
|
+
dir,
|
|
14
|
+
nonInteractive: bool(args, 'non-interactive'),
|
|
15
|
+
dryRun: bool(args, 'dry-run'),
|
|
16
|
+
});
|
|
17
|
+
}
|
|
18
|
+
if (sub === 'show' || sub === undefined) {
|
|
19
|
+
return runFoundationShow({ dir });
|
|
20
|
+
}
|
|
21
|
+
console.error('Usage: usa foundation <init|show> [path] [--dir <path>] [--non-interactive] [--dry-run]');
|
|
22
|
+
return 2;
|
|
23
|
+
}
|
|
24
|
+
/* ------------------------------------------------------------------ live -- */
|
|
25
|
+
/**
|
|
26
|
+
* `usa live`: conversational audit session (foundation → audit → triage →
|
|
27
|
+
* report). The default chat is the agent layer's `complete()`; without a
|
|
28
|
+
* configured provider the session runs deterministically (loud skips, no
|
|
29
|
+
* model calls). Async only because the LLM transport is async — every
|
|
30
|
+
* deterministic step stays synchronous underneath.
|
|
31
|
+
*/
|
|
32
|
+
export async function cmdLive(args) {
|
|
33
|
+
if (bool(args, 'help')) {
|
|
34
|
+
console.log(LIVE_HELP_TEXT);
|
|
35
|
+
return 0;
|
|
36
|
+
}
|
|
37
|
+
const dir = args._[1] ?? '.';
|
|
38
|
+
const providerId = str(args, 'provider') ?? process.env['USA_PROVIDER'] ?? process.env['USA_LIVE_PROVIDER'];
|
|
39
|
+
const modelOpt = str(args, 'model') ?? process.env['USA_MODEL'];
|
|
40
|
+
const transcriptPath = str(args, 'transcript');
|
|
41
|
+
const triageLimit = parseTriageLimit(str(args, 'triage-limit'));
|
|
42
|
+
if (triageLimit === null) {
|
|
43
|
+
console.error('--triage-limit must be a positive number');
|
|
44
|
+
return 2;
|
|
45
|
+
}
|
|
46
|
+
// CLI-003: preview before any provider call or prompting.
|
|
47
|
+
if (!dryRunWrites(args, transcriptPath ? [transcriptPath] : []))
|
|
48
|
+
return 0;
|
|
49
|
+
const chat = await resolveLiveChatOrAnnounce(providerId, modelOpt);
|
|
50
|
+
return runLiveSession({
|
|
51
|
+
dir,
|
|
52
|
+
ask: createStdinAsk(),
|
|
53
|
+
print: (line) => console.log(line),
|
|
54
|
+
chat,
|
|
55
|
+
transcriptPath,
|
|
56
|
+
provider: providerId,
|
|
57
|
+
model: modelOpt,
|
|
58
|
+
triageLimit: triageLimit ?? undefined,
|
|
59
|
+
});
|
|
60
|
+
}
|
|
61
|
+
/**
|
|
62
|
+
* Resolve the session chat, announcing deterministic-only mode when no
|
|
63
|
+
* provider is configured. The pre-flight warns once up front about
|
|
64
|
+
* unadvertised model ids (the classic mid-session 404); the call itself
|
|
65
|
+
* stays authoritative.
|
|
66
|
+
*/
|
|
67
|
+
async function resolveLiveChatOrAnnounce(providerId, modelOpt) {
|
|
68
|
+
if (providerId)
|
|
69
|
+
return resolveLiveChat(providerId, modelOpt);
|
|
70
|
+
console.log('live: no provider configured (set --provider or USA_PROVIDER) — deterministic-only mode.');
|
|
71
|
+
return undefined;
|
|
72
|
+
}
|
|
73
|
+
/**
|
|
74
|
+
* Resolve the session chat, or undefined for deterministic-only mode. The
|
|
75
|
+
* pre-flight warns once up front about unadvertised model ids (the classic
|
|
76
|
+
* mid-session 404); the call itself stays authoritative.
|
|
77
|
+
*/
|
|
78
|
+
async function resolveLiveChat(providerId, modelOpt) {
|
|
79
|
+
try {
|
|
80
|
+
const cfg = loadProviderConfig(providerId, modelOpt === undefined ? undefined : { model: modelOpt });
|
|
81
|
+
const provider = providerId;
|
|
82
|
+
const model = modelOpt;
|
|
83
|
+
const admonition = await checkModelAdvertised(providerId, cfg.model, listModels);
|
|
84
|
+
if (admonition)
|
|
85
|
+
console.error(admonition);
|
|
86
|
+
return (req) => complete({ ...req, provider, ...(model === undefined ? {} : { model }) });
|
|
87
|
+
}
|
|
88
|
+
catch {
|
|
89
|
+
// Deliberately a STATIC message: provider failures name key material
|
|
90
|
+
// (env vars, endpoints) and even the provider id is env-derived, so a
|
|
91
|
+
// transcript-adjacent CLI interpolates nothing here — neither the
|
|
92
|
+
// error nor the id. The user just typed it; they know which one failed.
|
|
93
|
+
console.error('live: LLM provider unavailable (check its API key) — continuing in deterministic-only mode.');
|
|
94
|
+
return undefined;
|
|
95
|
+
}
|
|
96
|
+
}
|
|
97
|
+
/** Positive integer, or null when the flag value is unusable. */
|
|
98
|
+
function parseTriageLimit(raw) {
|
|
99
|
+
if (raw === undefined)
|
|
100
|
+
return undefined;
|
|
101
|
+
const n = Number(raw);
|
|
102
|
+
if (!Number.isInteger(n) || n < 1)
|
|
103
|
+
return null;
|
|
104
|
+
return n;
|
|
105
|
+
}
|
|
106
|
+
/**
|
|
107
|
+
* `usa models`: what the provider actually serves, so a model id can be
|
|
108
|
+
* checked before a session burns calls on a 404. Read-only and side-effect
|
|
109
|
+
* free beyond one GET.
|
|
110
|
+
*/
|
|
111
|
+
export async function cmdModels(args) {
|
|
112
|
+
if (bool(args, 'help')) {
|
|
113
|
+
console.log(MODELS_HELP_TEXT);
|
|
114
|
+
return 0;
|
|
115
|
+
}
|
|
116
|
+
const providerId = str(args, 'provider') ?? process.env['USA_PROVIDER'];
|
|
117
|
+
if (!providerId) {
|
|
118
|
+
console.error('Usage: usa models --provider <id> (or set USA_PROVIDER)');
|
|
119
|
+
return 2;
|
|
120
|
+
}
|
|
121
|
+
let names;
|
|
122
|
+
try {
|
|
123
|
+
// Validates the key and resolves static defaults first — same fail-closed
|
|
124
|
+
// contract as the session; the static message policy applies here too.
|
|
125
|
+
loadProviderConfig(providerId);
|
|
126
|
+
names = (await listModels(providerId)).map((m) => m.name);
|
|
127
|
+
}
|
|
128
|
+
catch {
|
|
129
|
+
console.error('live: LLM provider unavailable (check its API key).');
|
|
130
|
+
return 2;
|
|
131
|
+
}
|
|
132
|
+
for (const name of names)
|
|
133
|
+
console.log(name);
|
|
134
|
+
return 0;
|
|
135
|
+
}
|
|
136
|
+
//# sourceMappingURL=cli-session.js.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"cli-session.js","sourceRoot":"","sources":["../src/cli-session.ts"],"names":[],"mappings":"AAAA,OAAO,EAAE,cAAc,EAAE,iBAAiB,EAAE,iBAAiB,EAAE,MAAM,2BAA2B,CAAC;AACjG,OAAO,EAAE,oBAAoB,EAAE,cAAc,EAAe,MAAM,kBAAkB,CAAC;AACrF,OAAO,EAAE,QAAQ,EAAE,UAAU,EAAE,kBAAkB,EAAE,MAAM,kBAAkB,CAAC;AAC5E,OAAO,EAAE,cAAc,EAAE,gBAAgB,EAAE,MAAM,eAAe,CAAC;AACjE,OAAO,EAAE,IAAI,EAAE,YAAY,EAAE,GAAG,EAAa,MAAM,eAAe,CAAC;AAEnE,mFAAmF;AACnF,gFAAgF;AAEhF,MAAM,UAAU,aAAa,CAAC,IAAU;IACtC,MAAM,GAAG,GAAG,IAAI,CAAC,CAAC,CAAC,CAAC,CAAuB,CAAC;IAC5C,MAAM,GAAG,GAAG,GAAG,CAAC,IAAI,EAAE,KAAK,CAAC,IAAK,IAAI,CAAC,CAAC,CAAC,CAAC,CAAwB,IAAI,GAAG,CAAC;IACzE,IAAI,GAAG,KAAK,MAAM,EAAE,CAAC;QACnB,OAAO,iBAAiB,CAAC;YACvB,GAAG;YACH,cAAc,EAAE,IAAI,CAAC,IAAI,EAAE,iBAAiB,CAAC;YAC7C,MAAM,EAAE,IAAI,CAAC,IAAI,EAAE,SAAS,CAAC;SAC9B,CAAC,CAAC;IACL,CAAC;IACD,IAAI,GAAG,KAAK,MAAM,IAAI,GAAG,KAAK,SAAS,EAAE,CAAC;QACxC,OAAO,iBAAiB,CAAC,EAAE,GAAG,EAAE,CAAC,CAAC;IACpC,CAAC;IACD,OAAO,CAAC,KAAK,CACX,yFAAyF,CAC1F,CAAC;IACF,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AACX,CAAC"}
|
package/dist/cli.d.ts
CHANGED
|
@@ -1,5 +1,5 @@
|
|
|
1
|
-
#!/usr/bin/env node
|
|
2
1
|
export declare function main(argv: string[]): number | Promise<number>;
|
|
2
|
+
/** Resolves the report format from an explicit flag, else the --out suffix. */
|
|
3
3
|
declare function isEntryPoint(argv1?: string | undefined, thisUrl?: string): boolean;
|
|
4
4
|
export { isEntryPoint };
|
|
5
5
|
//# sourceMappingURL=cli.d.ts.map
|
package/dist/cli.d.ts.map
CHANGED
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"cli.d.ts","sourceRoot":"","sources":["../src/cli.ts"],"names":[],"mappings":"
|
|
1
|
+
{"version":3,"file":"cli.d.ts","sourceRoot":"","sources":["../src/cli.ts"],"names":[],"mappings":"AAiDA,wBAAgB,IAAI,CAAC,IAAI,EAAE,MAAM,EAAE,GAAG,MAAM,GAAG,OAAO,CAAC,MAAM,CAAC,CA2B7D;AAID,+EAA+E;AAE/E,iBAAS,YAAY,CACnB,KAAK,GAAE,MAAM,GAAG,SAA2B,EAC3C,OAAO,GAAE,MAAwB,GAChC,OAAO,CAOT;AAED,OAAO,EAAE,YAAY,EAAE,CAAC"}
|