myshell-tools 2.7.0 → 2.10.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/CHANGELOG.md +32 -0
- package/README.md +36 -5
- package/dist/cli.js +28 -0
- package/dist/cli.js.map +1 -1
- package/dist/commands/login.d.ts +8 -5
- package/dist/commands/login.js +143 -44
- package/dist/commands/login.js.map +1 -1
- package/dist/core/classify.d.ts +20 -4
- package/dist/core/classify.js +241 -43
- package/dist/core/classify.js.map +1 -1
- package/dist/core/orchestrate.js +57 -84
- package/dist/core/orchestrate.js.map +1 -1
- package/dist/infra/config.d.ts +6 -0
- package/dist/infra/config.js.map +1 -1
- package/dist/infra/credentials.d.ts +28 -0
- package/dist/infra/credentials.js +52 -1
- package/dist/infra/credentials.js.map +1 -1
- package/dist/infra/update-check.d.ts +67 -0
- package/dist/infra/update-check.js +181 -0
- package/dist/infra/update-check.js.map +1 -0
- package/dist/interface/menu.d.ts +42 -0
- package/dist/interface/menu.js +159 -26
- package/dist/interface/menu.js.map +1 -1
- package/package.json +1 -1
package/CHANGELOG.md
CHANGED
|
@@ -11,6 +11,38 @@ and the project adheres to [Semantic Versioning](https://semver.org/spec/v2.0.0.
|
|
|
11
11
|
- Cross-OS CI execution (requires a public remote).
|
|
12
12
|
- First npm publish.
|
|
13
13
|
|
|
14
|
+
## [2.10.0]
|
|
15
|
+
|
|
16
|
+
### Added
|
|
17
|
+
- **Claude token auto-capture (no paste step)**: `login claude --code` now tees the `claude setup-token` output and automatically extracts the `sk-ant-oat…` token — you no longer have to copy/paste it. A robust paste fallback remains for when auto-capture can't read it: it retries (up to 3×), strips surrounding quotes/whitespace, and gives a specific warning if you paste an Anthropic **API key** (`sk-ant-api…`) instead of the **OAuth token** (`sk-ant-oat…`). New pure helpers `classifyPastedSecret` / `stripPastedSecretWrapper` in `src/infra/credentials.ts`.
|
|
18
|
+
|
|
19
|
+
### Changed
|
|
20
|
+
- **Smarter task classifier**: tier selection is now multi-signal scored — read/lookup phrasing → worker, edit/implement verbs → ic, design/review/security/audit/architecture → manager (deterministic tie-break manager > ic > worker, default ic). Risk signals were tightened with word boundaries (no more false hits like "keyboard") and expanded (oauth, api key, private key, jwt, session → critical; production, release, rollback, terraform, kubernetes, docker, db migration → high; lint, ci, build, dependencies → medium). Still pure/deterministic; the `rationale` names every matched signal so routing stays auditable.
|
|
21
|
+
- **Internal**: the duplicated provider-streaming loop in the orchestrator (IC run vs cross-vendor review run) is now a single shared `streamProvider` generator — behavior-identical (no test changes), just less duplication in the most critical code path.
|
|
22
|
+
|
|
23
|
+
## [2.9.0]
|
|
24
|
+
|
|
25
|
+
### Added
|
|
26
|
+
- **Update notifier**: myshell-tools now checks the npm registry (once per 24h, cached) for a newer version and shows a banner `▲ Update available: <current> → <latest> (press u)` in the control-panel header when one is found. The check is injected via a seam in tests so no real npm requests are made during the test suite.
|
|
27
|
+
- **`[u] Update now`**: a new Options menu entry appears only when an update is available. Pressing `u` runs `npm install -g myshell-tools@latest` (stdio inherit) and prints `✓ Updated to <latest> — restart myshell-tools to use it.` on success. The manual `[u]` path does not auto-relaunch — restart is explicit and safe.
|
|
28
|
+
- **Opt-in auto-update**: when `autoUpdate: true` is set in config, myshell-tools updates itself at launch (before entering the main loop) and relaunches the freshly-installed binary. On failure it prints a note and continues to the menu normally.
|
|
29
|
+
- **`autoUpdate` config flag** (`src/infra/config.ts`): new optional boolean field in `AppConfig`. Absent/false = notify-only banner. True = auto-update at launch. Merged over defaults so old config files are unaffected.
|
|
30
|
+
- **Wizard auto-update prompt**: the first-run welcome wizard now asks `Keep myshell-tools up to date automatically? (y/N)` after set-as-default, using the standard `(y/N)` convention (Enter → no).
|
|
31
|
+
- **Settings `[3] Auto-update` toggle**: the Settings screen (`[s]`) now lists `[3] Auto-update: on/off`; selecting it flips the flag and persists the updated config.
|
|
32
|
+
|
|
33
|
+
## [2.8.0]
|
|
34
|
+
|
|
35
|
+
### Added
|
|
36
|
+
- **opencode offered in first-run setup**: the welcome wizard now prompts `Add opencode? (optional — free models + more providers) (y/N)` after the claude/codex install offers, defaulting to NO. Answering `y` installs `opencode-ai` and re-detects the environment (via the injected seam, so tests stay hermetic). No opencode sign-in prompt is shown — opencode is authenticated-when-installed.
|
|
37
|
+
|
|
38
|
+
### Changed
|
|
39
|
+
- **Wizard uses consistent (y/n) prompts**: all yes/no prompts in `runWelcome` now follow a single convention — `(Y/n)` when Enter means yes (install offers, sign-in offers) and `(y/N)` when Enter means no (set-as-default). A new exported pure helper `parseYesNo(input, defaultYes)` handles the parsing; it never throws and is fully unit-tested.
|
|
40
|
+
|
|
41
|
+
## [2.7.1]
|
|
42
|
+
|
|
43
|
+
### Fixed
|
|
44
|
+
- **opencode is now connectable directly from the control panel** — the Auth section always offers `[o] Login opencode` (alongside `[j] Login Claude` and `[k] Login Codex`); when opencode isn't installed yet the entry reads `[o] Login opencode (installs it first)` and the handler installs `opencode-ai` (with consent) before running `opencode auth login`. Previously the entry only appeared after opencode was already installed, leaving no in-app path to add it.
|
|
45
|
+
|
|
14
46
|
## [2.7.0]
|
|
15
47
|
|
|
16
48
|
### Added
|
package/README.md
CHANGED
|
@@ -4,7 +4,7 @@
|
|
|
4
4
|
|
|
5
5
|
`myshell-tools` routes each task to the *cheapest* model likely to succeed, runs it on your real codebase, optionally has a **different vendor** review the result, and shows you exactly what it did and what it truly cost — with **no fabricated data, ever**.
|
|
6
6
|
|
|
7
|
-
> **Status: `2.
|
|
7
|
+
> **Status: `2.10.0` — honest, tested, and real.** Claude, Codex, and opencode (experimental) all work, provider auth is detected for real, and the tool notifies you when a newer version is available.
|
|
8
8
|
|
|
9
9
|
---
|
|
10
10
|
|
|
@@ -46,7 +46,7 @@ Using one frontier model for everything is wasteful (renaming a variable doesn't
|
|
|
46
46
|
- **Cross‑vendor adversarial review** — a *different vendor* checks the first model's output (Codex reviewing Claude, or vice‑versa). Different families, different blind spots. Review gating depends on mode; see Efficiency modes above.
|
|
47
47
|
- **Multi-turn context continuity** — follow-up messages carry real context. Prior conversation turns are compacted into a bounded history block (~6 k chars, most recent 12 turns) and replayed to the model, so it actually knows what was said earlier. Confidence envelopes are stripped before replay to save tokens.
|
|
48
48
|
- **Container / SSH sign-in** — `myshell-tools login` auto-detects headless and cloud-IDE environments (Replit, Codespaces, Gitpod, SSH sessions) and switches to a no-localhost sign-in flow automatically. Force either flow with `--code` or `--browser`. For Claude, the tool prompts you to paste the `sk-ant-oat…` OAuth token printed by `claude setup-token`, stores it locally (mode 0600), and injects it at startup — no manual env-var wiring needed. For Codex, a device-code flow is used.
|
|
49
|
-
- **opencode provider (experimental)** — auto-detected; works instantly with free hosted models (no keys).
|
|
49
|
+
- **opencode provider (experimental)** — auto-detected; works instantly with free hosted models (no keys). `[o]` is always visible in the Auth section: it installs `opencode-ai` (with consent) if missing, then runs `opencode auth login`. Route to it explicitly or let the policy fall back to it automatically.
|
|
50
50
|
- **Routing prefers advertised models** — detection passes each provider's actual model list to `route()`, which picks the cheapest model the CLI *actually has*, not just the cheapest in the pricing table. Falls back gracefully if the advertised list doesn't match any pricing entry.
|
|
51
51
|
- **Subscription, not metering** — it drives the **Claude Code**, **Codex**, and **opencode** CLIs you already use. No API keys, no per‑token bill for the free path.
|
|
52
52
|
- **Honest by construction** — every number on screen traces to a real measurement. A suite of *architecture tests* makes fabricated/mock output literally unmergeable.
|
|
@@ -59,7 +59,7 @@ Using one frontier model for everything is wasteful (renaming a variable doesn't
|
|
|
59
59
|
- At least one provider CLI. `npx myshell-tools` will **offer to install** them for you on first run — or you can install manually:
|
|
60
60
|
- **Claude Code** — `npm install -g @anthropic-ai/claude-code`, then sign in when prompted. In containers or over SSH, run `myshell-tools login claude --code`: complete the link shown, then paste the `sk-ant-oat…` OAuth token when the tool prompts you. The token is stored in `~/.myshell-tools/credentials.json` (mode 0600) and injected automatically at startup — do **not** set it as `ANTHROPIC_API_KEY`.
|
|
61
61
|
- **Codex** — `npm install -g @openai/codex`. In containers or over SSH, run `myshell-tools login codex --code` for a device-code flow (no localhost callback needed).
|
|
62
|
-
- **opencode** *(experimental, optional)* — auto-detected when the `opencode` CLI is installed. Works immediately with free hosted models (no keys).
|
|
62
|
+
- **opencode** *(experimental, optional)* — auto-detected when the `opencode` CLI is installed. Works immediately with free hosted models (no keys). `[o]` is **always available** in the control-panel Auth section: if opencode is not yet installed, selecting it asks for consent and runs `npm install -g opencode-ai`, then runs `opencode auth login` to add a premium provider or subscription — myshell-tools never handles the credentials. Appears in the control-panel header and raw-session picker only when installed.
|
|
63
63
|
|
|
64
64
|
You need **one** to start; install **both** claude and codex to unlock cross‑vendor review.
|
|
65
65
|
|
|
@@ -69,10 +69,41 @@ You need **one** to start; install **both** claude and codex to unlock cross‑v
|
|
|
69
69
|
|
|
70
70
|
| Method | Command | Notes |
|
|
71
71
|
|--------|---------|-------|
|
|
72
|
-
| Zero-install (
|
|
73
|
-
| Global install | `npm install -g myshell-tools` then `myshell-tools` |
|
|
72
|
+
| Zero-install (one-time) | `npx myshell-tools` | Fetches and runs; first-run setup included |
|
|
73
|
+
| Global install (recommended for regular use) | `npm install -g myshell-tools` then `myshell-tools` | Fastest; gets the update notifier |
|
|
74
74
|
| From source | See below | For development |
|
|
75
75
|
|
|
76
|
+
### `npx` vs. `npm install -g` — which to choose?
|
|
77
|
+
|
|
78
|
+
`npx myshell-tools` is convenient for a one-off run but **caches the downloaded version** — subsequent invocations reuse the cache and **will not pick up new releases** automatically.
|
|
79
|
+
|
|
80
|
+
For day-to-day use, a global install is recommended:
|
|
81
|
+
|
|
82
|
+
```bash
|
|
83
|
+
npm install -g myshell-tools
|
|
84
|
+
myshell-tools
|
|
85
|
+
```
|
|
86
|
+
|
|
87
|
+
The globally-installed CLI includes the **update notifier**: it checks the npm registry once per 24 hours (cached, non-blocking) and shows a banner in the control panel when a newer version is available:
|
|
88
|
+
|
|
89
|
+
```
|
|
90
|
+
▲ Update available: 2.9.0 → 3.0.0 (press u)
|
|
91
|
+
```
|
|
92
|
+
|
|
93
|
+
Press `u` to install the update in-place (`npm install -g myshell-tools@latest`). No relaunch is forced — restart the CLI when you're ready.
|
|
94
|
+
|
|
95
|
+
You can also enable **auto-update** so the CLI updates and relaunches itself silently at startup:
|
|
96
|
+
|
|
97
|
+
- During first-run setup: answer `y` to the `Keep myshell-tools up to date automatically? (y/N)` prompt.
|
|
98
|
+
- In the control panel: `[s] Settings → [3] Auto-update: off → on`.
|
|
99
|
+
- Or set `"autoUpdate": true` in `~/.myshell-tools/config.json`.
|
|
100
|
+
|
|
101
|
+
To update manually at any time:
|
|
102
|
+
|
|
103
|
+
```bash
|
|
104
|
+
npm install -g myshell-tools@latest
|
|
105
|
+
```
|
|
106
|
+
|
|
76
107
|
### From source
|
|
77
108
|
|
|
78
109
|
```bash
|
package/dist/cli.js
CHANGED
|
@@ -6,6 +6,7 @@
|
|
|
6
6
|
* All other modules return values and let this file decide the exit code.
|
|
7
7
|
*/
|
|
8
8
|
import { createRequire } from 'node:module';
|
|
9
|
+
import { execa } from 'execa';
|
|
9
10
|
import { systemClock } from './infra/clock.js';
|
|
10
11
|
import { createSessionWriter } from './infra/session.js';
|
|
11
12
|
import { createLedger } from './infra/ledger.js';
|
|
@@ -17,6 +18,7 @@ import { buildProviders } from './providers/registry.js';
|
|
|
17
18
|
import { detectEnvironment } from './providers/detect.js';
|
|
18
19
|
import { createFileConversationStore } from './infra/conversations.js';
|
|
19
20
|
import { loadConfig } from './infra/config.js';
|
|
21
|
+
import { checkForUpdate } from './infra/update-check.js';
|
|
20
22
|
import { runDoctor } from './commands/doctor.js';
|
|
21
23
|
import { runCost } from './commands/cost.js';
|
|
22
24
|
import { runLogin } from './commands/login.js';
|
|
@@ -180,6 +182,32 @@ async function main() {
|
|
|
180
182
|
cwd,
|
|
181
183
|
sandbox: 'workspace-write',
|
|
182
184
|
timeoutMs: 120000,
|
|
185
|
+
checkForUpdate: () => checkForUpdate({ currentVersion: version, now: Date.now() }),
|
|
186
|
+
updateSelf: async (updateOut) => {
|
|
187
|
+
try {
|
|
188
|
+
const result = await execa('npm', ['install', '-g', 'myshell-tools@latest'], {
|
|
189
|
+
stdio: 'inherit',
|
|
190
|
+
reject: false,
|
|
191
|
+
});
|
|
192
|
+
return result.exitCode === 0;
|
|
193
|
+
}
|
|
194
|
+
catch {
|
|
195
|
+
updateOut.write('Update failed — run: npm install -g myshell-tools@latest\n');
|
|
196
|
+
return false;
|
|
197
|
+
}
|
|
198
|
+
},
|
|
199
|
+
relaunch: async () => {
|
|
200
|
+
try {
|
|
201
|
+
const result = await execa('myshell-tools', process.argv.slice(2), {
|
|
202
|
+
stdio: 'inherit',
|
|
203
|
+
reject: false,
|
|
204
|
+
});
|
|
205
|
+
return result.exitCode ?? 0;
|
|
206
|
+
}
|
|
207
|
+
catch {
|
|
208
|
+
return 1;
|
|
209
|
+
}
|
|
210
|
+
},
|
|
183
211
|
};
|
|
184
212
|
await startMenu(menuCtx, out);
|
|
185
213
|
process.exit(0);
|
package/dist/cli.js.map
CHANGED
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"cli.js","sourceRoot":"","sources":["../src/cli.ts"],"names":[],"mappings":";AACA;;;;;GAKG;AAEH,OAAO,EAAE,aAAa,EAAE,MAAM,aAAa,CAAC;AAC5C,OAAO,EAAE,WAAW,EAAE,MAAM,kBAAkB,CAAC;AAC/C,OAAO,EAAE,mBAAmB,EAAE,MAAM,oBAAoB,CAAC;AACzD,OAAO,EAAE,YAAY,EAAE,MAAM,mBAAmB,CAAC;AACjD,OAAO,EAAE,cAAc,EAAE,MAAM,kBAAkB,CAAC;AAGlD,OAAO,EAAE,OAAO,EAAE,MAAM,oBAAoB,CAAC;AAC7C,OAAO,EAAE,SAAS,EAAE,MAAM,qBAAqB,CAAC;AAChD,OAAO,EAAE,SAAS,EAAE,MAAM,qBAAqB,CAAC;AAEhD,OAAO,EAAE,cAAc,EAAE,MAAM,yBAAyB,CAAC;AACzD,OAAO,EAAE,iBAAiB,EAAE,MAAM,uBAAuB,CAAC;AAC1D,OAA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mC,IAAI,CAAC,CAAC,CAAC,IAAI,EAAE,0CAA0C,CAC3F,CAAC;IACF,OAAO,CAAC,IAAI,CAAC,CAAC,CAAC,CAAC;AAClB,CAAC;AAED,IAAI,EAAE,CAAC,KAAK,CAAC,CAAC,GAAG,EAAE,EAAE;IACnB,OAAO,CAAC,MAAM,CAAC,KAAK,CAAC,MAAM,CAAC,GAAG,CAAC,GAAG,IAAI,CAAC,CAAC;IACzC,OAAO,CAAC,IAAI,CAAC,CAAC,CAAC,CAAC;AAClB,CAAC,CAAC,CAAC"}
|
package/dist/commands/login.d.ts
CHANGED
|
@@ -13,9 +13,11 @@
|
|
|
13
13
|
* - 'code': a no-localhost flow that works anywhere.
|
|
14
14
|
* · claude → `claude setup-token`: prints a link; the user signs in at
|
|
15
15
|
* claude.ai, copies the authorization code, and pastes it back here.
|
|
16
|
-
*
|
|
17
|
-
* (sk-ant-oat…)
|
|
18
|
-
*
|
|
16
|
+
* We TEE the output so we can scan it for the minted token
|
|
17
|
+
* (sk-ant-oat…) automatically. If auto-capture finds the token, it is
|
|
18
|
+
* persisted immediately with no user action required. Otherwise we fall
|
|
19
|
+
* back to prompting the user to paste it (up to 3 retries, with helpful
|
|
20
|
+
* warnings for blank or wrong-type inputs).
|
|
19
21
|
* · codex → `codex login --device-auth`: prints a URL + one-time code;
|
|
20
22
|
* the user authorizes their ChatGPT account on any device.
|
|
21
23
|
*
|
|
@@ -23,8 +25,9 @@
|
|
|
23
25
|
* to 'code' (so the localhost trap is avoided), everything else to 'browser'.
|
|
24
26
|
*
|
|
25
27
|
* Security: myshell-tools never stores raw API keys or passwords. The Claude
|
|
26
|
-
* OAuth token (sk-ant-oat…) is captured
|
|
27
|
-
* it and is stored in
|
|
28
|
+
* OAuth token (sk-ant-oat…) is either auto-captured from the tee'd output or
|
|
29
|
+
* captured after the user explicitly pastes it, and is stored in
|
|
30
|
+
* ~/.myshell-tools/credentials.json (mode 0o600).
|
|
28
31
|
*/
|
|
29
32
|
import type { OutputSink } from '../interface/render.js';
|
|
30
33
|
import type { ProviderId } from '../providers/port.js';
|
package/dist/commands/login.js
CHANGED
|
@@ -13,9 +13,11 @@
|
|
|
13
13
|
* - 'code': a no-localhost flow that works anywhere.
|
|
14
14
|
* · claude → `claude setup-token`: prints a link; the user signs in at
|
|
15
15
|
* claude.ai, copies the authorization code, and pastes it back here.
|
|
16
|
-
*
|
|
17
|
-
* (sk-ant-oat…)
|
|
18
|
-
*
|
|
16
|
+
* We TEE the output so we can scan it for the minted token
|
|
17
|
+
* (sk-ant-oat…) automatically. If auto-capture finds the token, it is
|
|
18
|
+
* persisted immediately with no user action required. Otherwise we fall
|
|
19
|
+
* back to prompting the user to paste it (up to 3 retries, with helpful
|
|
20
|
+
* warnings for blank or wrong-type inputs).
|
|
19
21
|
* · codex → `codex login --device-auth`: prints a URL + one-time code;
|
|
20
22
|
* the user authorizes their ChatGPT account on any device.
|
|
21
23
|
*
|
|
@@ -23,14 +25,15 @@
|
|
|
23
25
|
* to 'code' (so the localhost trap is avoided), everything else to 'browser'.
|
|
24
26
|
*
|
|
25
27
|
* Security: myshell-tools never stores raw API keys or passwords. The Claude
|
|
26
|
-
* OAuth token (sk-ant-oat…) is captured
|
|
27
|
-
* it and is stored in
|
|
28
|
+
* OAuth token (sk-ant-oat…) is either auto-captured from the tee'd output or
|
|
29
|
+
* captured after the user explicitly pastes it, and is stored in
|
|
30
|
+
* ~/.myshell-tools/credentials.json (mode 0o600).
|
|
28
31
|
*/
|
|
29
32
|
import readline from 'node:readline';
|
|
30
33
|
import { execa } from 'execa';
|
|
31
34
|
import { detectProvider, getInstallCommand } from '../providers/detect.js';
|
|
32
|
-
import { bold, dim, green, red } from '../ui/theme.js';
|
|
33
|
-
import { extractClaudeToken, saveClaudeToken } from '../infra/credentials.js';
|
|
35
|
+
import { bold, dim, green, red, yellow } from '../ui/theme.js';
|
|
36
|
+
import { classifyPastedSecret, extractClaudeToken, saveClaudeToken, stripPastedSecretWrapper, } from '../infra/credentials.js';
|
|
34
37
|
/** Each provider's default (browser/localhost) sign-in command. */
|
|
35
38
|
const LOGIN_COMMAND = {
|
|
36
39
|
claude: { bin: 'claude', args: ['auth', 'login'] },
|
|
@@ -50,7 +53,8 @@ const LOGIN_CODE_COMMAND = {
|
|
|
50
53
|
guidance: 'A sign-in link will appear below.\n' +
|
|
51
54
|
' 1. Open it in any browser and sign in at claude.ai.\n' +
|
|
52
55
|
' 2. Copy the authorization code it shows you.\n' +
|
|
53
|
-
' 3. Paste the code back here at the prompt and press Enter
|
|
56
|
+
' 3. Paste the code back here at the prompt and press Enter.\n' +
|
|
57
|
+
' We will capture the token automatically when possible.',
|
|
54
58
|
},
|
|
55
59
|
codex: {
|
|
56
60
|
bin: 'codex',
|
|
@@ -142,28 +146,60 @@ export async function runLogin(out, providerArg, opts) {
|
|
|
142
146
|
}
|
|
143
147
|
// stdio:'inherit' hands the terminal to the provider CLI so its OAuth /
|
|
144
148
|
// device / paste flow runs in place. reject:false so we report rather than throw.
|
|
149
|
+
//
|
|
150
|
+
// For the claude code method we use a special tee-capture approach: stdout
|
|
151
|
+
// and stderr are piped so we can scan for the token, but each line is also
|
|
152
|
+
// written verbatim to the real terminal so the user sees the flow live.
|
|
153
|
+
// stdin is still inherited so the user can interact (paste the auth code).
|
|
145
154
|
let result;
|
|
146
|
-
|
|
155
|
+
let capturedOutput = '';
|
|
156
|
+
if (method === 'code' && id === 'claude') {
|
|
147
157
|
const { bin, args, guidance } = LOGIN_CODE_COMMAND[id];
|
|
148
158
|
out.write(bold(`\nSigning in to ${id} — code method (no localhost needed).\n`, out.color));
|
|
149
159
|
out.write(dim(guidance + '\n', out.color));
|
|
150
|
-
|
|
160
|
+
capturedOutput = await runWithTeeCapture(bin, [...args]);
|
|
161
|
+
// We use a synthetic exit-code-0 result — tee-capture never throws, and
|
|
162
|
+
// we treat the flow as complete regardless of the subprocess exit code
|
|
163
|
+
// (the token presence is the real signal).
|
|
164
|
+
result = { exitCode: 0 };
|
|
165
|
+
}
|
|
166
|
+
else if (method === 'code') {
|
|
167
|
+
const { bin, args, guidance } = LOGIN_CODE_COMMAND[id];
|
|
168
|
+
out.write(bold(`\nSigning in to ${id} — code method (no localhost needed).\n`, out.color));
|
|
169
|
+
out.write(dim(guidance + '\n', out.color));
|
|
170
|
+
result = await execa(bin, [...args], { stdin: 'inherit', stdout: 'inherit', stderr: 'inherit', reject: false });
|
|
151
171
|
}
|
|
152
172
|
else {
|
|
153
173
|
const { bin, args } = LOGIN_COMMAND[id];
|
|
154
174
|
out.write(bold(`\nSigning in to ${id} — a browser window may open…\n`, out.color));
|
|
155
|
-
result = await execa(bin, [...args], {
|
|
175
|
+
result = await execa(bin, [...args], { stdin: 'inherit', stdout: 'inherit', stderr: 'inherit', reject: false });
|
|
156
176
|
}
|
|
157
177
|
if (result.exitCode === 0) {
|
|
158
|
-
out.write(green(`✓ ${id} sign-in complete.\n`, out.color));
|
|
159
178
|
// --- Claude code-method token capture -----------------------------------
|
|
160
179
|
// `claude setup-token` mints a long-lived token (sk-ant-oat01-…) and PRINTS
|
|
161
|
-
// it to the terminal
|
|
162
|
-
//
|
|
163
|
-
//
|
|
164
|
-
// every subsequent `claude -p …` spawn work without manual env-var setup.
|
|
180
|
+
// it to the terminal. We tee'd the output above and scan it first.
|
|
181
|
+
// If auto-capture finds the token, we're done. Otherwise we fall back to
|
|
182
|
+
// the paste prompt (up to 3 retries) so the user can paste it manually.
|
|
165
183
|
if (id === 'claude' && method === 'code') {
|
|
166
|
-
|
|
184
|
+
const autoToken = extractClaudeToken(capturedOutput);
|
|
185
|
+
if (autoToken !== null) {
|
|
186
|
+
try {
|
|
187
|
+
await saveClaudeToken(autoToken);
|
|
188
|
+
process.env['CLAUDE_CODE_OAUTH_TOKEN'] = autoToken;
|
|
189
|
+
out.write(green('✓ Claude token captured and saved — claude is now ready.\n', out.color));
|
|
190
|
+
}
|
|
191
|
+
catch {
|
|
192
|
+
out.write(dim('Could not save token to disk — re-run `myshell-tools login claude --code` later.\n', out.color));
|
|
193
|
+
}
|
|
194
|
+
}
|
|
195
|
+
else {
|
|
196
|
+
// Auto-capture found nothing — fall back to paste prompt.
|
|
197
|
+
out.write(green(`✓ ${id} sign-in complete.\n`, out.color));
|
|
198
|
+
await captureClaudeTokenWithPaste(out, opts?.readLine);
|
|
199
|
+
}
|
|
200
|
+
}
|
|
201
|
+
else {
|
|
202
|
+
out.write(green(`✓ ${id} sign-in complete.\n`, out.color));
|
|
167
203
|
}
|
|
168
204
|
}
|
|
169
205
|
else {
|
|
@@ -179,45 +215,108 @@ export async function runLogin(out, providerArg, opts) {
|
|
|
179
215
|
return 0;
|
|
180
216
|
}
|
|
181
217
|
// ---------------------------------------------------------------------------
|
|
182
|
-
//
|
|
218
|
+
// Tee-capture helper (internal)
|
|
219
|
+
// ---------------------------------------------------------------------------
|
|
220
|
+
/**
|
|
221
|
+
* Run a command with stdout and stderr piped (tee'd to the real terminal) and
|
|
222
|
+
* stdin inherited. Returns the accumulated stdout+stderr text, or an empty
|
|
223
|
+
* string on spawn failure. Never throws.
|
|
224
|
+
*
|
|
225
|
+
* Uses execa v9's `all: true` option to merge stdout+stderr into one stream,
|
|
226
|
+
* then iterates it via `subprocess.iterable({ from: 'all', preserveNewlines: true })`
|
|
227
|
+
* while mirroring each chunk to `process.stdout` so the user sees the output
|
|
228
|
+
* live. stdin is inherited so the user can interact (e.g. paste an auth code).
|
|
229
|
+
*/
|
|
230
|
+
async function runWithTeeCapture(bin, args) {
|
|
231
|
+
try {
|
|
232
|
+
const subprocess = execa(bin, [...args], {
|
|
233
|
+
stdin: 'inherit',
|
|
234
|
+
stdout: 'pipe',
|
|
235
|
+
stderr: 'pipe',
|
|
236
|
+
all: true,
|
|
237
|
+
reject: false,
|
|
238
|
+
timeout: 300_000,
|
|
239
|
+
});
|
|
240
|
+
const chunks = [];
|
|
241
|
+
for await (const line of subprocess.iterable({ from: 'all', preserveNewlines: true })) {
|
|
242
|
+
const text = typeof line === 'string' ? line : String(line);
|
|
243
|
+
process.stdout.write(text);
|
|
244
|
+
chunks.push(text);
|
|
245
|
+
}
|
|
246
|
+
await subprocess; // wait for exit (already resolved by the iteration above)
|
|
247
|
+
return chunks.join('');
|
|
248
|
+
}
|
|
249
|
+
catch {
|
|
250
|
+
// Spawn error or unexpected failure — return empty so the caller falls back
|
|
251
|
+
// to the paste prompt.
|
|
252
|
+
return '';
|
|
253
|
+
}
|
|
254
|
+
}
|
|
255
|
+
// ---------------------------------------------------------------------------
|
|
256
|
+
// Paste-fallback token capture helper (internal)
|
|
183
257
|
// ---------------------------------------------------------------------------
|
|
184
258
|
/**
|
|
185
259
|
* Prompt the user to paste the token shown by `claude setup-token`, extract
|
|
186
260
|
* it, persist it, and inject it into `process.env.CLAUDE_CODE_OAUTH_TOKEN`.
|
|
187
261
|
*
|
|
262
|
+
* Retries up to 3 times:
|
|
263
|
+
* - Blank input → skip silently with a note.
|
|
264
|
+
* - API key → print a specific warning (that's sk-ant-api, not sk-ant-oat).
|
|
265
|
+
* - Invalid → warn and re-prompt.
|
|
266
|
+
* - Valid token → save and set env.
|
|
267
|
+
*
|
|
188
268
|
* Uses the injected `readLine` when provided (menu shares its single readline
|
|
189
269
|
* interface). Otherwise creates a temporary readline interface, reads ONE line,
|
|
190
270
|
* and immediately closes it (so stdin is not held open).
|
|
191
271
|
*
|
|
192
|
-
* Never throws
|
|
272
|
+
* Never throws.
|
|
193
273
|
*/
|
|
194
|
-
async function
|
|
195
|
-
|
|
196
|
-
|
|
197
|
-
|
|
198
|
-
|
|
199
|
-
|
|
200
|
-
|
|
201
|
-
|
|
202
|
-
|
|
203
|
-
|
|
204
|
-
|
|
205
|
-
|
|
206
|
-
|
|
207
|
-
|
|
208
|
-
if (token !== null) {
|
|
209
|
-
try {
|
|
210
|
-
await saveClaudeToken(token);
|
|
211
|
-
process.env['CLAUDE_CODE_OAUTH_TOKEN'] = token;
|
|
212
|
-
out.write(green('✓ Claude token saved — claude is now ready.\n', out.color));
|
|
274
|
+
async function captureClaudeTokenWithPaste(out, readLine) {
|
|
275
|
+
const MAX_RETRIES = 3;
|
|
276
|
+
for (let attempt = 1; attempt <= MAX_RETRIES; attempt++) {
|
|
277
|
+
out.write(`\nPaste the token shown above (starts with sk-ant-oat) and press Enter` +
|
|
278
|
+
` — or leave blank to skip (attempt ${attempt}/${MAX_RETRIES}):\n> `);
|
|
279
|
+
let raw;
|
|
280
|
+
if (readLine !== undefined) {
|
|
281
|
+
// Menu injected its own reader — use it directly, do NOT create a second
|
|
282
|
+
// readline interface (that would double-consume stdin).
|
|
283
|
+
raw = await readLine();
|
|
284
|
+
}
|
|
285
|
+
else {
|
|
286
|
+
// CLI direct path — create a temporary readline, read one line, close.
|
|
287
|
+
raw = await readOneLineFromStdin();
|
|
213
288
|
}
|
|
214
|
-
|
|
215
|
-
|
|
289
|
+
const normalised = stripPastedSecretWrapper(raw ?? '');
|
|
290
|
+
if (normalised === '') {
|
|
291
|
+
out.write(dim('Skipped — no token entered.\n', out.color));
|
|
292
|
+
return;
|
|
293
|
+
}
|
|
294
|
+
const kind = classifyPastedSecret(normalised);
|
|
295
|
+
if (kind === 'api-key') {
|
|
296
|
+
out.write(yellow('That looks like an Anthropic API key (sk-ant-api…), not the setup-token\n' +
|
|
297
|
+
'OAuth token. Please paste the sk-ant-oat… value instead.\n', out.color));
|
|
298
|
+
continue;
|
|
299
|
+
}
|
|
300
|
+
const token = extractClaudeToken(normalised);
|
|
301
|
+
if (token !== null) {
|
|
302
|
+
try {
|
|
303
|
+
await saveClaudeToken(token);
|
|
304
|
+
process.env['CLAUDE_CODE_OAUTH_TOKEN'] = token;
|
|
305
|
+
out.write(green('✓ Claude token saved — claude is now ready.\n', out.color));
|
|
306
|
+
}
|
|
307
|
+
catch {
|
|
308
|
+
out.write(dim('Could not save token to disk — you can re-run `myshell-tools login claude --code` later.\n', out.color));
|
|
309
|
+
}
|
|
310
|
+
return;
|
|
311
|
+
}
|
|
312
|
+
// Not a recognised token format.
|
|
313
|
+
if (attempt < MAX_RETRIES) {
|
|
314
|
+
out.write(dim('Token not recognised — expected sk-ant-oat… format. Please try again.\n', out.color));
|
|
315
|
+
}
|
|
316
|
+
else {
|
|
317
|
+
out.write(dim('Token not captured after 3 attempts. Re-run `myshell-tools login claude --code`\n' +
|
|
318
|
+
'and paste the sk-ant-oat… value (NOT an Anthropic API key starting with sk-ant-api).\n', out.color));
|
|
216
319
|
}
|
|
217
|
-
}
|
|
218
|
-
else {
|
|
219
|
-
out.write(dim('Token not captured. Re-run `myshell-tools login claude --code` and paste the\n' +
|
|
220
|
-
'sk-ant-oat… value (NOT an Anthropic API key starting with sk-ant-api).\n', out.color));
|
|
221
320
|
}
|
|
222
321
|
}
|
|
223
322
|
/**
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"login.js","sourceRoot":"","sources":["../../src/commands/login.ts"],"names":[],"mappings":"AAAA
|
|
1
|
+
{"version":3,"file":"login.js","sourceRoot":"","sources":["../../src/commands/login.ts"],"names":[],"mappings":"AAAA;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;GA8BG;AAEH,OAAO,QAAQ,MAAM,eAAe,CAAC;AACrC,OAAO,EAAE,KAAK,EAAE,MAAM,OAAO,CAAC;AAG9B,OAAO,EAAE,cAAc,EAAE,iBAAiB,EAAE,MAAM,wBAAwB,CAAC;AAC3E,OAAO,EAAE,IAAI,EAAE,GAAG,EAAE,KAAK,EAAE,GAAG,EAAE,MAAM,EAAE,MAAM,gBAAgB,CAAC;AAC/D,OAAO,EACL,oBAAoB,EACpB,kBAAkB,EAClB,eAAe,EACf,wBAAwB,GACzB,MAAM,yBAAyB,CAAC;AAKjC,mEAAmE;AACnE,MAAM,aAAa,GAAmF;IACpG,MAAM,EAAE,EAAE,GAAG,EAAE,QAAQ,EAAE,IAAI,EAAE,CAAC,MAAM,EAAE,OAAO,CAAC,EAAE;IAClD,KAAK,EAAE,EAAE,GAAG,EAAE,OAAO,EAAE,IAAI,EAAE,CAAC,OAAO,CAAC,EAAE;IACx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AC,KAAK,CACV,CACF,CAAC;QACJ,CAAC;IACH,CAAC;AACH,CAAC;AAED;;;;;;GAMG;AACH,SAAS,oBAAoB;IAC3B,OAAO,IAAI,OAAO,CAAgB,CAAC,OAAO,EAAE,EAAE;QAC5C,MAAM,EAAE,GAAG,QAAQ,CAAC,eAAe,CAAC;YAClC,KAAK,EAAE,OAAO,CAAC,KAAK;YACpB,MAAM,EAAE,OAAO,CAAC,MAAM;YACtB,QAAQ,EAAE,KAAK;SAChB,CAAC,CAAC;QAEH,IAAI,QAAQ,GAAG,KAAK,CAAC;QAErB,EAAE,CAAC,IAAI,CAAC,MAAM,EAAE,CAAC,GAAW,EAAE,EAAE;YAC9B,QAAQ,GAAG,IAAI,CAAC;YAChB,EAAE,CAAC,KAAK,EAAE,CAAC;YACX,OAAO,CAAC,GAAG,CAAC,IAAI,EAAE,CAAC,CAAC;QACtB,CAAC,CAAC,CAAC;QAEH,EAAE,CAAC,IAAI,CAAC,OAAO,EAAE,GAAG,EAAE;YACpB,IAAI,CAAC,QAAQ,EAAE,CAAC;gBACd,QAAQ,GAAG,IAAI,CAAC;gBAChB,OAAO,CAAC,IAAI,CAAC,CAAC;YAChB,CAAC;QACH,CAAC,CAAC,CAAC;IACL,CAAC,CAAC,CAAC;AACL,CAAC;AAED,8EAA8E;AAC9E,gFAAgF"}
|
package/dist/core/classify.d.ts
CHANGED
|
@@ -2,17 +2,33 @@
|
|
|
2
2
|
* src/core/classify.ts — pure task classification.
|
|
3
3
|
*
|
|
4
4
|
* Determines the orchestration tier and security risk level from a free-text
|
|
5
|
-
* task description using
|
|
5
|
+
* task description using a multi-signal scoring approach. No I/O, no time,
|
|
6
|
+
* no randomness — pure function.
|
|
6
7
|
*
|
|
7
8
|
* Honesty Contract: no fabricated confidence numbers are produced here.
|
|
8
|
-
* The rationale field names the matched
|
|
9
|
+
* The rationale field names the matched signals so callers can audit decisions.
|
|
10
|
+
*
|
|
11
|
+
* # Tier scoring model
|
|
12
|
+
*
|
|
13
|
+
* Each tier has a list of keyword patterns. The text is matched against all
|
|
14
|
+
* three lists and a score (count of matches) is accumulated per tier.
|
|
15
|
+
* Tie-break is deterministic: manager > ic > worker.
|
|
16
|
+
* Default when nothing matches: ic.
|
|
17
|
+
*
|
|
18
|
+
* # Risk model
|
|
19
|
+
*
|
|
20
|
+
* Priority cascade: critical > high > medium > low.
|
|
21
|
+
* Word boundaries prevent false positives (e.g. "keyboard" does not match
|
|
22
|
+
* the "key" critical signal).
|
|
9
23
|
*/
|
|
10
24
|
import type { Classification } from './types.js';
|
|
11
25
|
/**
|
|
12
26
|
* Classify a free-text `task` string into a {@link Classification}.
|
|
13
27
|
*
|
|
14
|
-
* Tier
|
|
15
|
-
* Risk priority
|
|
28
|
+
* Tier: multi-signal scoring; tie-break manager > ic > worker; default ic.
|
|
29
|
+
* Risk: priority cascade critical > high > medium > low; default low.
|
|
30
|
+
*
|
|
31
|
+
* Never throws — empty or whitespace input returns a safe default.
|
|
16
32
|
*
|
|
17
33
|
* @param task - The raw task description from the user.
|
|
18
34
|
*/
|