scoutline 0.11.0 → 0.12.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 +27 -0
- package/dist/capabilities/diagnostics.d.ts +75 -0
- package/dist/capabilities/diagnostics.d.ts.map +1 -1
- package/dist/capabilities/diagnostics.js.map +1 -1
- package/dist/capabilities/quota.d.ts +64 -1
- package/dist/capabilities/quota.d.ts.map +1 -1
- package/dist/capabilities/quota.js.map +1 -1
- package/dist/commands/code.d.ts +9 -1
- package/dist/commands/code.d.ts.map +1 -1
- package/dist/commands/code.js +4 -4
- package/dist/commands/code.js.map +1 -1
- package/dist/commands/doctor.d.ts +71 -1
- package/dist/commands/doctor.d.ts.map +1 -1
- package/dist/commands/doctor.js +81 -5
- package/dist/commands/doctor.js.map +1 -1
- package/dist/commands/init.d.ts +186 -0
- package/dist/commands/init.d.ts.map +1 -0
- package/dist/commands/init.js +1221 -0
- package/dist/commands/init.js.map +1 -0
- package/dist/commands/quota.d.ts +32 -0
- package/dist/commands/quota.d.ts.map +1 -1
- package/dist/commands/quota.js +165 -24
- package/dist/commands/quota.js.map +1 -1
- package/dist/commands/tools.d.ts +8 -0
- package/dist/commands/tools.d.ts.map +1 -1
- package/dist/commands/tools.js +4 -4
- package/dist/commands/tools.js.map +1 -1
- package/dist/commands/vision.d.ts +10 -0
- package/dist/commands/vision.d.ts.map +1 -1
- package/dist/commands/vision.js +23 -1
- package/dist/commands/vision.js.map +1 -1
- package/dist/index.d.ts +125 -1
- package/dist/index.d.ts.map +1 -1
- package/dist/index.js +578 -70
- package/dist/index.js.map +1 -1
- package/dist/lib/api-client.d.ts +1 -1
- package/dist/lib/api-client.d.ts.map +1 -1
- package/dist/lib/api-client.js +6 -2
- package/dist/lib/api-client.js.map +1 -1
- package/dist/lib/cache.d.ts +9 -2
- package/dist/lib/cache.d.ts.map +1 -1
- package/dist/lib/cache.js +9 -2
- package/dist/lib/cache.js.map +1 -1
- package/dist/lib/code-mode.d.ts +8 -0
- package/dist/lib/code-mode.d.ts.map +1 -1
- package/dist/lib/code-mode.js +3 -1
- package/dist/lib/code-mode.js.map +1 -1
- package/dist/lib/config-store.d.ts +165 -0
- package/dist/lib/config-store.d.ts.map +1 -0
- package/dist/lib/config-store.js +332 -0
- package/dist/lib/config-store.js.map +1 -0
- package/dist/lib/config.d.ts +2 -2
- package/dist/lib/config.d.ts.map +1 -1
- package/dist/lib/config.js +19 -11
- package/dist/lib/config.js.map +1 -1
- package/dist/lib/consumption.d.ts +144 -0
- package/dist/lib/consumption.d.ts.map +1 -0
- package/dist/lib/consumption.js +161 -0
- package/dist/lib/consumption.js.map +1 -0
- package/dist/lib/execution.d.ts +32 -4
- package/dist/lib/execution.d.ts.map +1 -1
- package/dist/lib/execution.js +144 -5
- package/dist/lib/execution.js.map +1 -1
- package/dist/lib/mcp-client.d.ts +12 -0
- package/dist/lib/mcp-client.d.ts.map +1 -1
- package/dist/lib/mcp-client.js +16 -7
- package/dist/lib/mcp-client.js.map +1 -1
- package/dist/lib/mcp-config.d.ts +10 -0
- package/dist/lib/mcp-config.d.ts.map +1 -1
- package/dist/lib/mcp-config.js +13 -7
- package/dist/lib/mcp-config.js.map +1 -1
- package/dist/lib/monitor-client.d.ts +19 -3
- package/dist/lib/monitor-client.d.ts.map +1 -1
- package/dist/lib/monitor-client.js +21 -5
- package/dist/lib/monitor-client.js.map +1 -1
- package/dist/lib/quota-mapping.d.ts +402 -0
- package/dist/lib/quota-mapping.d.ts.map +1 -0
- package/dist/lib/quota-mapping.js +539 -0
- package/dist/lib/quota-mapping.js.map +1 -0
- package/dist/lib/quota-store.d.ts +271 -0
- package/dist/lib/quota-store.d.ts.map +1 -0
- package/dist/lib/quota-store.js +540 -0
- package/dist/lib/quota-store.js.map +1 -0
- package/dist/lib/trigger-detection.d.ts +149 -0
- package/dist/lib/trigger-detection.d.ts.map +1 -0
- package/dist/lib/trigger-detection.js +149 -0
- package/dist/lib/trigger-detection.js.map +1 -0
- package/dist/lib/tty.d.ts +8 -1
- package/dist/lib/tty.d.ts.map +1 -1
- package/dist/lib/tty.js +53 -1
- package/dist/lib/tty.js.map +1 -1
- package/dist/providers/brave/adapter.d.ts +26 -0
- package/dist/providers/brave/adapter.d.ts.map +1 -1
- package/dist/providers/brave/adapter.js +64 -4
- package/dist/providers/brave/adapter.js.map +1 -1
- package/dist/providers/brave/client.d.ts +46 -2
- package/dist/providers/brave/client.d.ts.map +1 -1
- package/dist/providers/brave/client.js +55 -3
- package/dist/providers/brave/client.js.map +1 -1
- package/dist/providers/selection.d.ts +114 -1
- package/dist/providers/selection.d.ts.map +1 -1
- package/dist/providers/selection.js +99 -3
- package/dist/providers/selection.js.map +1 -1
- package/dist/providers/types.d.ts +5 -1
- package/dist/providers/types.d.ts.map +1 -1
- package/dist/providers/types.js.map +1 -1
- package/dist/providers/zai/adapter.d.ts.map +1 -1
- package/dist/providers/zai/adapter.js +14 -5
- package/dist/providers/zai/adapter.js.map +1 -1
- package/package.json +2 -1
|
@@ -0,0 +1,186 @@
|
|
|
1
|
+
/**
|
|
2
|
+
* Init command — interactive onboarding wizard (T3a + T3b — Plan A).
|
|
3
|
+
*
|
|
4
|
+
* This module owns the interactive `scoutline init` flow:
|
|
5
|
+
* - State detection (absent / corrupt / already-onboarded / fresh).
|
|
6
|
+
* - Provider checklist (registry-derived; none pre-checked — equal weight).
|
|
7
|
+
* - Per-provider ask-key-first → hidden input → inline single-attempt
|
|
8
|
+
* validation through `DiagnosticsCapability.invoke({probe:true})` against
|
|
9
|
+
* an EPHEMERAL resolved env (never persists, never mutates `process.env`).
|
|
10
|
+
* - Honest broad classification of probe failures: key-problems
|
|
11
|
+
* (`AuthError`/`ApiError`) reject + re-prompt; `NetworkError` offers
|
|
12
|
+
* save-unverified. No false-precise "wrong/disabled/mismatch" subtypes
|
|
13
|
+
* are inferred from message text — the taxonomy only distinguishes
|
|
14
|
+
* `AuthError`/`ApiError`/`NetworkError`.
|
|
15
|
+
* - Credit-cost disclosure before any paid-provider probe.
|
|
16
|
+
* - Fallback preference question.
|
|
17
|
+
* - Atomic config write (T1 `writeConfig` primitive) + redacted summary.
|
|
18
|
+
*
|
|
19
|
+
* T3b additions:
|
|
20
|
+
* - **Re-config menu** when an already-valid config exists: edit a
|
|
21
|
+
* Provider key, add a Provider, remove a Provider, change the
|
|
22
|
+
* fallback preference, re-run the full wizard, or cancel. Editing
|
|
23
|
+
* a Provider key resets `verification.status` to `unverified`
|
|
24
|
+
* (Doctor re-promotes after a successful probe).
|
|
25
|
+
* - **Corrupt-config repair**: tolerant `inspectConfig` distinguishes
|
|
26
|
+
* `absent` / `valid` / `corrupt`. On `corrupt` the wizard offers to
|
|
27
|
+
* back up the live file and rewrite a fresh config — `init` is the
|
|
28
|
+
* recovery path, not a victim of corruption.
|
|
29
|
+
* - **Formal non-TTY refuse**: without an interactive terminal the
|
|
30
|
+
* wizard refuses before any prompt, prints env instructions and
|
|
31
|
+
* the `init` hint, and exits.
|
|
32
|
+
* - **Stale-env-after-import warning**: when the user imports a key
|
|
33
|
+
* from env, the wizard notes that the env value will continue to
|
|
34
|
+
* take precedence (env > file in the runtime precedence rule) —
|
|
35
|
+
* the wizard cannot turn off the env value for the user.
|
|
36
|
+
* - **`hintShown` reset on re-init**: a re-config or fresh write
|
|
37
|
+
* resets the env-only hint marker so a user who later switches to
|
|
38
|
+
* env-only usage sees the hint once again.
|
|
39
|
+
*
|
|
40
|
+
* Boundary rules:
|
|
41
|
+
* - No Provider transport is constructed outside the per-provider probe;
|
|
42
|
+
* the candidate credential lives only in the ephemeral env until the
|
|
43
|
+
* final atomic write.
|
|
44
|
+
* - All prompt IO flows through the {@link InitPrompts} seam; no direct
|
|
45
|
+
* `process.stdin` / `process.stdout` reads in this module. Production
|
|
46
|
+
* wires `@inquirer/prompts`; tests inject scripted doubles.
|
|
47
|
+
* - Registration links render BOTH a terminal hyperlink AND the literal
|
|
48
|
+
* URL text so captured / non-hyperlink output stays usable.
|
|
49
|
+
* - No selection work (Plan B); the wizard writes at most one
|
|
50
|
+
* `fallbackEnabled` flag and per-Provider records.
|
|
51
|
+
*/
|
|
52
|
+
import type { ConfigInspection, ScoutlineConfig, WriteConfigOptions } from "../lib/config-store.js";
|
|
53
|
+
import type { ProviderDescriptor } from "../providers/types.js";
|
|
54
|
+
/**
|
|
55
|
+
* Help text for `scoutline init --help`. T3b completes the wizard's
|
|
56
|
+
* lifecycle (re-config menu, corrupt-config repair, formal non-TTY
|
|
57
|
+
* refuse), so the T3a PREVIEW caveat is dropped — the public claim of
|
|
58
|
+
* a complete `init` is now accurate.
|
|
59
|
+
*/
|
|
60
|
+
export declare const INIT_HELP: string;
|
|
61
|
+
/**
|
|
62
|
+
* Multi-select prompt choice for the provider checklist. `value` is the
|
|
63
|
+
* provider id; `description` carries env-detected and credit-cost hints
|
|
64
|
+
* surfaced in the choice description column.
|
|
65
|
+
*/
|
|
66
|
+
export interface InitChoice<T> {
|
|
67
|
+
readonly value: T;
|
|
68
|
+
readonly name: string;
|
|
69
|
+
readonly description?: string;
|
|
70
|
+
/**
|
|
71
|
+
* Pre-checked state. The provider checklist NEVER pre-checks (equal
|
|
72
|
+
* weight); this field exists for forward compatibility with T3b.
|
|
73
|
+
*/
|
|
74
|
+
readonly checked?: boolean;
|
|
75
|
+
}
|
|
76
|
+
/**
|
|
77
|
+
* Injectable prompt IO seam. Production wires `@inquirer/prompts` via
|
|
78
|
+
* {@link createInquirerPrompts}; tests inject scripted doubles that
|
|
79
|
+
* never touch a real TTY.
|
|
80
|
+
*
|
|
81
|
+
* The shape mirrors the four prompt types the wizard uses: multi-select
|
|
82
|
+
* checkbox, yes/no confirm, hidden password, and free-text input.
|
|
83
|
+
*/
|
|
84
|
+
export interface InitPrompts {
|
|
85
|
+
/**
|
|
86
|
+
* Multi-select. Returns the chosen values in selection order. Throws
|
|
87
|
+
* on user cancel (Ctrl+C / EOF) — the caller catches and treats as
|
|
88
|
+
* no-write.
|
|
89
|
+
*/
|
|
90
|
+
checkbox<T>(message: string, choices: readonly InitChoice<T>[]): Promise<T[]>;
|
|
91
|
+
/**
|
|
92
|
+
* Single-select menu. Returns the chosen value. Throws on user
|
|
93
|
+
* cancel. Used by the T3b re-config menu (edit/add/remove/fallback/
|
|
94
|
+
* rerun/cancel) and the corrupt-config-repair prompt.
|
|
95
|
+
*/
|
|
96
|
+
select<T>(message: string, choices: readonly InitChoice<T>[]): Promise<T>;
|
|
97
|
+
/** Yes/no. `defaultYes` carries the documented default ([Y/n] vs [y/N]). */
|
|
98
|
+
confirm(message: string, defaultYes: boolean): Promise<boolean>;
|
|
99
|
+
/** Hidden password input. Returns the trimmed value (possibly empty). */
|
|
100
|
+
password(message: string): Promise<string>;
|
|
101
|
+
/** Free-text input. Used for follow-up re-prompt loops. */
|
|
102
|
+
input(message: string): Promise<string>;
|
|
103
|
+
}
|
|
104
|
+
/**
|
|
105
|
+
* Injectable config-store seam. Production wires the real
|
|
106
|
+
* {@link inspectConfig} / {@link writeConfig}; tests inject in-memory or
|
|
107
|
+
* temp-dir-backed doubles so the wizard is hermetic — no real
|
|
108
|
+
* `~/.scoutline/config.json` I/O during tests.
|
|
109
|
+
*/
|
|
110
|
+
export interface InitConfigStore {
|
|
111
|
+
inspect(): Promise<ConfigInspection>;
|
|
112
|
+
write(config: ScoutlineConfig, options?: WriteConfigOptions): Promise<void>;
|
|
113
|
+
}
|
|
114
|
+
/**
|
|
115
|
+
* Wrap the real `inspectConfig` / `writeConfig` pair as an
|
|
116
|
+
* {@link InitConfigStore}. The default options object is captured per-call
|
|
117
|
+
* so the wizard can pass a temp `filePath` / atomic options through
|
|
118
|
+
* unchanged in tests.
|
|
119
|
+
*/
|
|
120
|
+
export declare function createDefaultConfigStore(options?: WriteConfigOptions): InitConfigStore;
|
|
121
|
+
/**
|
|
122
|
+
* Injectable dependencies for the init wizard. Production supplies the
|
|
123
|
+
* real defaults via the composition root in `src/index.ts`; tests pass
|
|
124
|
+
* in-memory / temp-dir doubles for hermeticity.
|
|
125
|
+
*/
|
|
126
|
+
export interface InitDependencies {
|
|
127
|
+
/** The provider registry — canonical checklist source/order. */
|
|
128
|
+
readonly descriptors: readonly ProviderDescriptor[];
|
|
129
|
+
/** Injectable prompt IO seam. */
|
|
130
|
+
readonly prompts: InitPrompts;
|
|
131
|
+
/** Injectable config-store seam. */
|
|
132
|
+
readonly configStore: InitConfigStore;
|
|
133
|
+
/** Injectable environment view (for env-key-import detection). */
|
|
134
|
+
readonly env: NodeJS.ProcessEnv;
|
|
135
|
+
/**
|
|
136
|
+
* Injectable clock, used for verification `checkedAt` timestamps.
|
|
137
|
+
* Production wires `Date.now`; tests inject a fixed clock.
|
|
138
|
+
*/
|
|
139
|
+
readonly now: () => number;
|
|
140
|
+
/** Whether stdin is an interactive TTY. Non-TTY gets a graceful guard. */
|
|
141
|
+
readonly stdinIsTTY: boolean;
|
|
142
|
+
/** Progress / disclosure sink. */
|
|
143
|
+
readonly writeStderr: (value: string) => void;
|
|
144
|
+
/** Final-summary sink (the only stdout write in the wizard). */
|
|
145
|
+
readonly writeStdout: (value: string) => void;
|
|
146
|
+
}
|
|
147
|
+
/**
|
|
148
|
+
* Run the interactive init wizard. Performs the T3b state dispatch:
|
|
149
|
+
* - non-TTY → refuse before any prompt + exit 1.
|
|
150
|
+
* - corrupt config → offer backup + rewrite (init is the recovery path).
|
|
151
|
+
* - valid + already-onboarded → re-config menu.
|
|
152
|
+
* - valid + empty / absent → fresh-onboarding flow.
|
|
153
|
+
*
|
|
154
|
+
* Returns the exit code:
|
|
155
|
+
* - 0 on success, re-config applied, or already-onboarded + Cancel.
|
|
156
|
+
* - 1 on user cancel, non-TTY refuse, write failure, or declined repair.
|
|
157
|
+
*/
|
|
158
|
+
export declare function runFreshOnboarding(deps: InitDependencies): Promise<number>;
|
|
159
|
+
/**
|
|
160
|
+
* Build the production {@link InitPrompts} from `@inquirer/prompts`. The
|
|
161
|
+
* adapter:
|
|
162
|
+
* - Rewires the inquirer output stream to `process.stderr` so the
|
|
163
|
+
* wizard keeps the codebase's data-only-stdout contract (the final
|
|
164
|
+
* summary line is the only stdout write).
|
|
165
|
+
* - Maps the four wizard prompt shapes onto the inquirer calls.
|
|
166
|
+
*
|
|
167
|
+
* Tests never call this — they inject a scripted {@link InitPrompts}
|
|
168
|
+
* double instead, so test runs are fully hermetic and do not need a TTY.
|
|
169
|
+
*/
|
|
170
|
+
export declare function createInquirerPrompts(): InitPrompts;
|
|
171
|
+
/**
|
|
172
|
+
* Top-level init handler. Wired into the dispatch switch in `index.ts`.
|
|
173
|
+
*
|
|
174
|
+
* - `--help` / `-h` prints {@link INIT_HELP} to stdout and returns 0.
|
|
175
|
+
* - Otherwise dispatches to {@link runFreshOnboarding}.
|
|
176
|
+
*
|
|
177
|
+
* The CLI arg list is the same shape every other handler receives; the
|
|
178
|
+
* handler only inspects it for the help flag.
|
|
179
|
+
*/
|
|
180
|
+
export declare function handleInitWithHelp(args: readonly string[], deps: InitDependencies): Promise<number>;
|
|
181
|
+
/**
|
|
182
|
+
* Backwards-compatible alias used by the dispatch switch. Tests that drive
|
|
183
|
+
* the wizard directly pass an empty arg list.
|
|
184
|
+
*/
|
|
185
|
+
export declare function handleInit(deps: InitDependencies): Promise<number>;
|
|
186
|
+
//# sourceMappingURL=init.d.ts.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"init.d.ts","sourceRoot":"","sources":["../../src/commands/init.ts"],"names":[],"mappings":"AAAA;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;GAkDG;AAEH,OAAO,KAAK,EACV,gBAAgB,EAGhB,eAAe,EACf,kBAAkB,EACnB,MAAM,wBAAwB,CAAC;AAGhC,OAAO,KAAK,EAAE,kBAAkB,EAAc,MAAM,uBAAuB,CAAC;AAO5E;;;;;GAKG;AACH,eAAO,MAAM,SAAS,QAgDd,CAAC;AA+GT;;;;GAIG;AACH,MAAM,WAAW,UAAU,CAAC,CAAC;IAC3B,QAAQ,CAAC,KA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