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.
Files changed (110) hide show
  1. package/README.md +27 -0
  2. package/dist/capabilities/diagnostics.d.ts +75 -0
  3. package/dist/capabilities/diagnostics.d.ts.map +1 -1
  4. package/dist/capabilities/diagnostics.js.map +1 -1
  5. package/dist/capabilities/quota.d.ts +64 -1
  6. package/dist/capabilities/quota.d.ts.map +1 -1
  7. package/dist/capabilities/quota.js.map +1 -1
  8. package/dist/commands/code.d.ts +9 -1
  9. package/dist/commands/code.d.ts.map +1 -1
  10. package/dist/commands/code.js +4 -4
  11. package/dist/commands/code.js.map +1 -1
  12. package/dist/commands/doctor.d.ts +71 -1
  13. package/dist/commands/doctor.d.ts.map +1 -1
  14. package/dist/commands/doctor.js +81 -5
  15. package/dist/commands/doctor.js.map +1 -1
  16. package/dist/commands/init.d.ts +186 -0
  17. package/dist/commands/init.d.ts.map +1 -0
  18. package/dist/commands/init.js +1221 -0
  19. package/dist/commands/init.js.map +1 -0
  20. package/dist/commands/quota.d.ts +32 -0
  21. package/dist/commands/quota.d.ts.map +1 -1
  22. package/dist/commands/quota.js +165 -24
  23. package/dist/commands/quota.js.map +1 -1
  24. package/dist/commands/tools.d.ts +8 -0
  25. package/dist/commands/tools.d.ts.map +1 -1
  26. package/dist/commands/tools.js +4 -4
  27. package/dist/commands/tools.js.map +1 -1
  28. package/dist/commands/vision.d.ts +10 -0
  29. package/dist/commands/vision.d.ts.map +1 -1
  30. package/dist/commands/vision.js +23 -1
  31. package/dist/commands/vision.js.map +1 -1
  32. package/dist/index.d.ts +125 -1
  33. package/dist/index.d.ts.map +1 -1
  34. package/dist/index.js +578 -70
  35. package/dist/index.js.map +1 -1
  36. package/dist/lib/api-client.d.ts +1 -1
  37. package/dist/lib/api-client.d.ts.map +1 -1
  38. package/dist/lib/api-client.js +6 -2
  39. package/dist/lib/api-client.js.map +1 -1
  40. package/dist/lib/cache.d.ts +9 -2
  41. package/dist/lib/cache.d.ts.map +1 -1
  42. package/dist/lib/cache.js +9 -2
  43. package/dist/lib/cache.js.map +1 -1
  44. package/dist/lib/code-mode.d.ts +8 -0
  45. package/dist/lib/code-mode.d.ts.map +1 -1
  46. package/dist/lib/code-mode.js +3 -1
  47. package/dist/lib/code-mode.js.map +1 -1
  48. package/dist/lib/config-store.d.ts +165 -0
  49. package/dist/lib/config-store.d.ts.map +1 -0
  50. package/dist/lib/config-store.js +332 -0
  51. package/dist/lib/config-store.js.map +1 -0
  52. package/dist/lib/config.d.ts +2 -2
  53. package/dist/lib/config.d.ts.map +1 -1
  54. package/dist/lib/config.js +19 -11
  55. package/dist/lib/config.js.map +1 -1
  56. package/dist/lib/consumption.d.ts +144 -0
  57. package/dist/lib/consumption.d.ts.map +1 -0
  58. package/dist/lib/consumption.js +161 -0
  59. package/dist/lib/consumption.js.map +1 -0
  60. package/dist/lib/execution.d.ts +32 -4
  61. package/dist/lib/execution.d.ts.map +1 -1
  62. package/dist/lib/execution.js +144 -5
  63. package/dist/lib/execution.js.map +1 -1
  64. package/dist/lib/mcp-client.d.ts +12 -0
  65. package/dist/lib/mcp-client.d.ts.map +1 -1
  66. package/dist/lib/mcp-client.js +16 -7
  67. package/dist/lib/mcp-client.js.map +1 -1
  68. package/dist/lib/mcp-config.d.ts +10 -0
  69. package/dist/lib/mcp-config.d.ts.map +1 -1
  70. package/dist/lib/mcp-config.js +13 -7
  71. package/dist/lib/mcp-config.js.map +1 -1
  72. package/dist/lib/monitor-client.d.ts +19 -3
  73. package/dist/lib/monitor-client.d.ts.map +1 -1
  74. package/dist/lib/monitor-client.js +21 -5
  75. package/dist/lib/monitor-client.js.map +1 -1
  76. package/dist/lib/quota-mapping.d.ts +402 -0
  77. package/dist/lib/quota-mapping.d.ts.map +1 -0
  78. package/dist/lib/quota-mapping.js +539 -0
  79. package/dist/lib/quota-mapping.js.map +1 -0
  80. package/dist/lib/quota-store.d.ts +271 -0
  81. package/dist/lib/quota-store.d.ts.map +1 -0
  82. package/dist/lib/quota-store.js +540 -0
  83. package/dist/lib/quota-store.js.map +1 -0
  84. package/dist/lib/trigger-detection.d.ts +149 -0
  85. package/dist/lib/trigger-detection.d.ts.map +1 -0
  86. package/dist/lib/trigger-detection.js +149 -0
  87. package/dist/lib/trigger-detection.js.map +1 -0
  88. package/dist/lib/tty.d.ts +8 -1
  89. package/dist/lib/tty.d.ts.map +1 -1
  90. package/dist/lib/tty.js +53 -1
  91. package/dist/lib/tty.js.map +1 -1
  92. package/dist/providers/brave/adapter.d.ts +26 -0
  93. package/dist/providers/brave/adapter.d.ts.map +1 -1
  94. package/dist/providers/brave/adapter.js +64 -4
  95. package/dist/providers/brave/adapter.js.map +1 -1
  96. package/dist/providers/brave/client.d.ts +46 -2
  97. package/dist/providers/brave/client.d.ts.map +1 -1
  98. package/dist/providers/brave/client.js +55 -3
  99. package/dist/providers/brave/client.js.map +1 -1
  100. package/dist/providers/selection.d.ts +114 -1
  101. package/dist/providers/selection.d.ts.map +1 -1
  102. package/dist/providers/selection.js +99 -3
  103. package/dist/providers/selection.js.map +1 -1
  104. package/dist/providers/types.d.ts +5 -1
  105. package/dist/providers/types.d.ts.map +1 -1
  106. package/dist/providers/types.js.map +1 -1
  107. package/dist/providers/zai/adapter.d.ts.map +1 -1
  108. package/dist/providers/zai/adapter.js +14 -5
  109. package/dist/providers/zai/adapter.js.map +1 -1
  110. 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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