@unscientificjszhai/howto 1.0.2 → 1.1.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 (51) hide show
  1. package/README.md +88 -29
  2. package/{README.CN.md → README.zh-hans-cn.md} +84 -25
  3. package/THIRD_PARTY_NOTICES.md +1 -0
  4. package/dist/ai/chatgpt-models.js +148 -0
  5. package/dist/ai/chatgpt.js +495 -0
  6. package/dist/ai/command-schema.js +8 -0
  7. package/dist/ai/errors.js +6 -0
  8. package/dist/ai/gemini.js +117 -4
  9. package/dist/ai/index.js +4 -1
  10. package/dist/ai/openai.js +105 -2
  11. package/dist/ai/usage-session.js +144 -0
  12. package/dist/auth/chatgpt/commands.js +90 -0
  13. package/dist/auth/chatgpt/errors.js +85 -0
  14. package/dist/auth/chatgpt/http.js +97 -0
  15. package/dist/auth/chatgpt/index.js +229 -0
  16. package/dist/auth/chatgpt/instructions.js +22 -0
  17. package/dist/auth/chatgpt/oauth.js +320 -0
  18. package/dist/auth/chatgpt/storage.js +366 -0
  19. package/dist/auth/chatgpt/types.js +1 -0
  20. package/dist/cli.js +77 -16
  21. package/dist/config-file.js +2 -0
  22. package/dist/config.js +10 -3
  23. package/dist/errors.js +4 -0
  24. package/dist/index.js +11 -4
  25. package/dist/init/ChatGptInitializationStep.js +223 -0
  26. package/dist/init/InitializationApp.js +71 -37
  27. package/dist/init/index.js +24 -5
  28. package/dist/init/state.js +14 -3
  29. package/dist/prompt.js +36 -6
  30. package/dist/shell/command-analysis.js +24 -4
  31. package/dist/ui/App.js +99 -10
  32. package/dist/ui/ConfirmView.js +6 -39
  33. package/dist/ui/InteractiveSessionProvider.js +7 -8
  34. package/dist/ui/ResolvePlaceholdersView.js +6 -1
  35. package/dist/ui/UsageApprovalView.js +320 -0
  36. package/dist/ui/interactive-session.js +180 -39
  37. package/dist/ui/keyboard-framing.js +102 -0
  38. package/dist/ui/paste-framing.js +69 -32
  39. package/dist/ui/resize-safe-output.js +2 -2
  40. package/dist/ui/run-interactive-command.js +2 -2
  41. package/dist/ui/text-input.js +4 -1
  42. package/dist/ui/use-keyboard-input.js +6 -1
  43. package/dist/ui/use-paste-aware-input.js +8 -3
  44. package/dist/usage/arguments.js +61 -0
  45. package/dist/usage/generate.js +156 -0
  46. package/dist/usage/output.js +216 -0
  47. package/dist/usage/risk.js +17 -0
  48. package/dist/usage/runner.js +238 -0
  49. package/dist/usage/types.js +1 -0
  50. package/dist/validation/usage-response.js +39 -0
  51. package/package.json +21 -19
@@ -0,0 +1,216 @@
1
+ import { StringDecoder } from "node:string_decoder";
2
+ const HEAD_BYTES = 24 * 1024;
3
+ const TAIL_BYTES = 8 * 1024;
4
+ const REDACTED = "[redacted]";
5
+ export function sanitizeUsageText(value, credentials = []) {
6
+ const sanitizer = new TerminalOutputSanitizer();
7
+ const redactor = new CredentialRedactor(credentials);
8
+ const text = redactor.write(sanitizer.write(value)) + redactor.finish();
9
+ return { text, credentialsRedacted: redactor.credentialsRedacted };
10
+ }
11
+ export function sanitizeUsageLookupResult(result, credentials = []) {
12
+ let credentialsRedacted = result.credentialsRedacted;
13
+ const sanitize = (value) => {
14
+ const sanitized = sanitizeUsageText(value, credentials);
15
+ credentialsRedacted ||= sanitized.credentialsRedacted;
16
+ return sanitized.text;
17
+ };
18
+ const redactMetadata = (value) => {
19
+ const redactor = new CredentialRedactor(credentials, false);
20
+ const text = redactor.write(value) + redactor.finish();
21
+ credentialsRedacted ||= redactor.credentialsRedacted;
22
+ return text;
23
+ };
24
+ const seen = new Set();
25
+ const sanitizeRequested = (value) => {
26
+ if (typeof value === "string")
27
+ return redactMetadata(value);
28
+ if (typeof value !== "object" || value === null) {
29
+ return typeof value === "number" || typeof value === "boolean" ? value : null;
30
+ }
31
+ if (seen.has(value))
32
+ return null;
33
+ seen.add(value);
34
+ const sanitized = Array.isArray(value)
35
+ ? value.map(sanitizeRequested)
36
+ : Object.fromEntries(Object.entries(value).map(([key, item]) => [
37
+ redactMetadata(key),
38
+ sanitizeRequested(item),
39
+ ]));
40
+ seen.delete(value);
41
+ return sanitized;
42
+ };
43
+ const requested = sanitizeRequested(result.requested);
44
+ const actualCommand = result.actualCommand === null
45
+ ? null
46
+ : {
47
+ executable: redactMetadata(result.actualCommand.executable),
48
+ args: result.actualCommand.args.map(redactMetadata),
49
+ ...(result.actualCommand.argv0 === undefined
50
+ ? {}
51
+ : { argv0: redactMetadata(result.actualCommand.argv0) }),
52
+ };
53
+ const stdout = sanitize(result.stdout);
54
+ const stderr = sanitize(result.stderr);
55
+ return { ...result, requested, actualCommand, stdout, stderr, credentialsRedacted };
56
+ }
57
+ /** 先流式净化和脱敏,再限制字节数,避免凭据跨 chunk 或截断边界泄漏。 */
58
+ export class UsageOutputCapture {
59
+ decoder = new StringDecoder("utf8");
60
+ sanitizer = new TerminalOutputSanitizer();
61
+ redactor;
62
+ head = Buffer.alloc(0);
63
+ tail = Buffer.alloc(0);
64
+ totalBytes = 0;
65
+ result;
66
+ constructor(credentials = []) {
67
+ this.redactor = new CredentialRedactor(credentials);
68
+ }
69
+ write(chunk) {
70
+ if (this.result !== undefined)
71
+ return;
72
+ this.capture(this.redactor.write(this.sanitizer.write(this.decoder.write(chunk))));
73
+ }
74
+ finish() {
75
+ if (this.result !== undefined)
76
+ return this.result;
77
+ this.capture(this.redactor.write(this.sanitizer.write(this.decoder.end())));
78
+ this.capture(this.redactor.finish());
79
+ const truncated = this.totalBytes > HEAD_BYTES + TAIL_BYTES;
80
+ // 不让截断切开 UTF-8 字符;完整输出按原顺序拼回,截断输出分别修剪边界。
81
+ const text = truncated
82
+ ? new StringDecoder("utf8").write(this.head) + decodeUtf8Tail(this.tail)
83
+ : Buffer.concat([this.head, this.tail]).toString("utf8");
84
+ this.result = {
85
+ text,
86
+ truncated,
87
+ credentialsRedacted: this.redactor.credentialsRedacted,
88
+ };
89
+ return this.result;
90
+ }
91
+ capture(text) {
92
+ if (text === "")
93
+ return;
94
+ let bytes = Buffer.from(text, "utf8");
95
+ this.totalBytes += bytes.length;
96
+ if (this.head.length < HEAD_BYTES) {
97
+ const count = Math.min(HEAD_BYTES - this.head.length, bytes.length);
98
+ this.head = Buffer.concat([this.head, bytes.subarray(0, count)]);
99
+ bytes = bytes.subarray(count);
100
+ }
101
+ if (bytes.length > 0) {
102
+ this.tail = Buffer.from(bytes.length >= TAIL_BYTES
103
+ ? bytes.subarray(-TAIL_BYTES)
104
+ : Buffer.concat([this.tail, bytes]).subarray(-TAIL_BYTES));
105
+ }
106
+ }
107
+ }
108
+ class CredentialRedactor {
109
+ credentials;
110
+ lookbehind;
111
+ credentialsRedacted = false;
112
+ pending = "";
113
+ constructor(credentials, clean = true) {
114
+ this.credentials = [
115
+ ...new Set((clean ? credentials.map(cleanCredential) : credentials).filter(Boolean)),
116
+ ].sort((left, right) => right.length - left.length);
117
+ this.lookbehind = Math.max(0, ...this.credentials.map((value) => value.length - 1));
118
+ }
119
+ write(text) {
120
+ this.pending += text;
121
+ return this.flush(Math.max(0, this.pending.length - this.lookbehind));
122
+ }
123
+ finish() {
124
+ return this.flush(this.pending.length);
125
+ }
126
+ flush(boundary) {
127
+ let text = "";
128
+ let index = 0;
129
+ while (index < boundary) {
130
+ const credential = this.credentials.find((value) => this.pending.startsWith(value, index));
131
+ if (credential !== undefined) {
132
+ text += REDACTED;
133
+ this.credentialsRedacted = true;
134
+ index += credential.length;
135
+ }
136
+ else {
137
+ const codePoint = this.pending.codePointAt(index);
138
+ const width = codePoint > 0xffff ? 2 : 1;
139
+ text += this.pending.slice(index, index + width);
140
+ index += width;
141
+ }
142
+ }
143
+ this.pending = this.pending.slice(index);
144
+ return text;
145
+ }
146
+ }
147
+ class TerminalOutputSanitizer {
148
+ state = "text";
149
+ afterCarriageReturn = false;
150
+ write(value) {
151
+ let text = "";
152
+ for (const char of value) {
153
+ const code = char.codePointAt(0);
154
+ if (this.state === "string" || this.state === "string-escape") {
155
+ if (code === 0x07 || code === 0x9c || (this.state === "string-escape" && char === "\\")) {
156
+ this.state = "text";
157
+ }
158
+ else {
159
+ this.state = code === 0x1b ? "string-escape" : "string";
160
+ }
161
+ continue;
162
+ }
163
+ if (this.state === "csi") {
164
+ if (code >= 0x40 && code <= 0x7e)
165
+ this.state = "text";
166
+ else if (code === 0x1b)
167
+ this.state = "escape";
168
+ continue;
169
+ }
170
+ if (this.state === "escape" || this.state === "intermediate") {
171
+ if (this.state === "escape" && char === "[")
172
+ this.state = "csi";
173
+ else if (this.state === "escape" && "]PX^_".includes(char))
174
+ this.state = "string";
175
+ else if (code >= 0x20 && code <= 0x2f)
176
+ this.state = "intermediate";
177
+ else
178
+ this.state = code === 0x1b ? "escape" : "text";
179
+ continue;
180
+ }
181
+ if (code === 0x1b)
182
+ this.state = "escape";
183
+ else if (code === 0x9b)
184
+ this.state = "csi";
185
+ else if ([0x90, 0x98, 0x9d, 0x9e, 0x9f].includes(code))
186
+ this.state = "string";
187
+ else if (char === "\r") {
188
+ text += "\n";
189
+ this.afterCarriageReturn = true;
190
+ continue;
191
+ }
192
+ else if (char === "\n") {
193
+ if (!this.afterCarriageReturn)
194
+ text += char;
195
+ }
196
+ else if (char === "\t" ||
197
+ (code >= 0x20 &&
198
+ !(code >= 0x7f && code <= 0x9f) &&
199
+ !(code >= 0x202a && code <= 0x202e) &&
200
+ !(code >= 0x2066 && code <= 0x2069))) {
201
+ text += char;
202
+ }
203
+ this.afterCarriageReturn = false;
204
+ }
205
+ return text;
206
+ }
207
+ }
208
+ function cleanCredential(value) {
209
+ return new TerminalOutputSanitizer().write(value);
210
+ }
211
+ function decodeUtf8Tail(value) {
212
+ let start = 0;
213
+ while (start < value.length && (value[start] & 0xc0) === 0x80)
214
+ start += 1;
215
+ return value.subarray(start).toString("utf8");
216
+ }
@@ -0,0 +1,17 @@
1
+ import { detectDangerousCommand } from "../safety/dangerous-command.js";
2
+ import { formatUsageCommand } from "./arguments.js";
3
+ /** 符号链接可能改变 basename;原调用名与真实程序任一风险都不能被另一者覆盖。 */
4
+ export function resolveUsageCommandDanger(commandName, executable, args, lookup) {
5
+ const named = detectDangerousCommand(formatUsageCommand(commandName, args));
6
+ const resolved = detectDangerousCommand(formatUsageCommand(executable, args));
7
+ const local = named?.rule === "indeterminate-shell-command" ? (resolved ?? named) : (named ?? resolved);
8
+ const reasons = new Set([named?.reason, resolved?.reason].filter((reason) => reason !== undefined));
9
+ if (lookup.dangerous)
10
+ reasons.add(`AI: ${lookup.dangerReason}`);
11
+ if (local === undefined && !lookup.dangerous)
12
+ return undefined;
13
+ return {
14
+ rule: local?.rule ?? "ai-flagged-dangerous-command",
15
+ reason: [...reasons].join("; "),
16
+ };
17
+ }
@@ -0,0 +1,238 @@
1
+ import { spawn } from "node:child_process";
2
+ import { accessSync, constants, realpathSync, statSync } from "node:fs";
3
+ import { delimiter, isAbsolute, resolve } from "node:path";
4
+ import { onExit as signalExit } from "signal-exit";
5
+ import { validateUsageArgumentList, validateUsageLookupArguments } from "./arguments.js";
6
+ import { sanitizeUsageLookupResult, UsageOutputCapture } from "./output.js";
7
+ export function resolveUsageExecutable(useCommand) {
8
+ if (useCommand === "" || useCommand.includes("\0"))
9
+ return null;
10
+ const candidates = useCommand.includes("/")
11
+ ? [resolve(useCommand)]
12
+ : (process.env["PATH"]?.split(delimiter) ?? []).map((directory) => resolve(directory, useCommand));
13
+ for (const candidate of candidates) {
14
+ try {
15
+ const path = realpathSync(candidate);
16
+ if (isExecutable(path))
17
+ return path;
18
+ }
19
+ catch {
20
+ // 路径缺失、循环链接或权限不足均视为不可执行,不回传底层异常。
21
+ }
22
+ }
23
+ return null;
24
+ }
25
+ export function createUsageLookupResult(requested, status) {
26
+ return {
27
+ requested,
28
+ actualCommand: null,
29
+ status,
30
+ stdout: "",
31
+ stderr: "",
32
+ exitCode: null,
33
+ timedOut: false,
34
+ stdoutTruncated: false,
35
+ stderrTruncated: false,
36
+ credentialsRedacted: false,
37
+ };
38
+ }
39
+ export function executeUsageLookup(options) {
40
+ const result = createUsageLookupResult(options.requested, "spawn_failed");
41
+ const sanitizedResult = () => sanitizeUsageLookupResult(result, options.knownCredentials);
42
+ let args;
43
+ try {
44
+ validateUsageLookupArguments(options.requested);
45
+ args = validateUsageArgumentList(options.args);
46
+ if (options.argv0 !== undefined)
47
+ validateUsageArgumentList([options.argv0]);
48
+ }
49
+ catch {
50
+ result.status = "invalid_arguments";
51
+ return Promise.resolve(sanitizedResult());
52
+ }
53
+ if (!isAbsolute(options.executable) || !isExecutable(options.executable)) {
54
+ result.status = "not_found";
55
+ return Promise.resolve(sanitizedResult());
56
+ }
57
+ return new Promise((resolveResult) => {
58
+ const stdout = new UsageOutputCapture(options.knownCredentials);
59
+ const stderr = new UsageOutputCapture(options.knownCredentials);
60
+ let child;
61
+ let stopStatus;
62
+ let completed = false;
63
+ let closed = false;
64
+ let exited = false;
65
+ let cleaning = false;
66
+ let cleanupFinished = false;
67
+ let timeout = undefined;
68
+ let cleanupTimeout;
69
+ let unsubscribe = () => { };
70
+ let removeExitHook;
71
+ const cleanupListeners = () => {
72
+ if (timeout !== undefined)
73
+ clearTimeout(timeout);
74
+ if (cleanupTimeout !== undefined)
75
+ clearTimeout(cleanupTimeout);
76
+ options.signal.removeEventListener("abort", onAbort);
77
+ unsubscribe();
78
+ removeExitHook?.();
79
+ removeExitHook = undefined;
80
+ };
81
+ const finish = () => {
82
+ if (completed)
83
+ return;
84
+ completed = true;
85
+ cleanupListeners();
86
+ const capturedStdout = stdout.finish();
87
+ const capturedStderr = stderr.finish();
88
+ result.stdout = capturedStdout.text;
89
+ result.stderr = capturedStderr.text;
90
+ result.stdoutTruncated = capturedStdout.truncated;
91
+ result.stderrTruncated = capturedStderr.truncated;
92
+ result.credentialsRedacted =
93
+ capturedStdout.credentialsRedacted || capturedStderr.credentialsRedacted;
94
+ if (stopStatus !== undefined)
95
+ result.status = stopStatus;
96
+ resolveResult(sanitizedResult());
97
+ };
98
+ const finishIfClean = () => {
99
+ if (!closed || completed)
100
+ return;
101
+ if (processGroupExists(child?.pid) && !cleanupFinished) {
102
+ cleanProcessGroup();
103
+ return;
104
+ }
105
+ finish();
106
+ };
107
+ const finishCleanup = () => {
108
+ cleanupFinished = true;
109
+ // 后代可能脱离进程组却仍持有 pipe;停止查询后不再等待它释放 fd。
110
+ child?.stdout?.destroy();
111
+ child?.stderr?.destroy();
112
+ if (closed || exited)
113
+ finish();
114
+ };
115
+ const cleanProcessGroup = () => {
116
+ if (cleaning || completed || child?.pid === undefined)
117
+ return;
118
+ cleaning = true;
119
+ signalProcessGroup(child.pid, "SIGTERM");
120
+ if (!processGroupExists(child.pid)) {
121
+ finishCleanup();
122
+ return;
123
+ }
124
+ cleanupTimeout = setTimeout(() => {
125
+ if (processGroupExists(child?.pid))
126
+ signalProcessGroup(child.pid, "SIGKILL");
127
+ finishCleanup();
128
+ }, 500);
129
+ };
130
+ const stop = (status) => {
131
+ if (completed)
132
+ return;
133
+ if (stopStatus === undefined || status === "cancelled")
134
+ stopStatus = status;
135
+ if (status === "timeout")
136
+ result.timedOut = true;
137
+ if (child !== undefined)
138
+ cleanProcessGroup();
139
+ };
140
+ const onAbort = () => stop("cancelled");
141
+ const onPolicyChange = () => {
142
+ if (options.getExecutionPolicy() === "print")
143
+ stop("permission_revoked");
144
+ };
145
+ try {
146
+ options.signal.addEventListener("abort", onAbort, { once: true });
147
+ unsubscribe = options.subscribeExecutionPolicy(onPolicyChange);
148
+ if (options.signal.aborted)
149
+ stop("cancelled");
150
+ // 必须最后同步复查;从复查到 spawn 不经过 await,避免待处理输入使检查失败后仍启动。
151
+ if ((options.checkExecutionPolicy?.() ?? options.getExecutionPolicy()) === "print")
152
+ stop("permission_revoked");
153
+ }
154
+ catch (error) {
155
+ cleanupListeners();
156
+ throw error;
157
+ }
158
+ if (stopStatus !== undefined || options.signal.aborted) {
159
+ if (options.signal.aborted)
160
+ stop("cancelled");
161
+ finish();
162
+ return;
163
+ }
164
+ try {
165
+ // 进程退出不再运行 500ms 定时器;同步清理本查询组,保留父进程的原退出语义。
166
+ removeExitHook = signalExit(() => {
167
+ if (child?.pid !== undefined)
168
+ signalProcessGroup(child.pid, "SIGKILL");
169
+ });
170
+ child = spawn(options.executable, args, {
171
+ // 保留原调用名,避免 realpath 后的 BusyBox 等多调用程序改变分派语义。
172
+ argv0: options.argv0 ?? options.executable,
173
+ cwd: process.cwd(),
174
+ shell: false,
175
+ stdio: ["ignore", "pipe", "pipe"],
176
+ detached: true,
177
+ });
178
+ }
179
+ catch {
180
+ finish();
181
+ return;
182
+ }
183
+ if (child.pid !== undefined) {
184
+ result.actualCommand = {
185
+ executable: options.executable,
186
+ args,
187
+ ...(options.argv0 === undefined ? {} : { argv0: options.argv0 }),
188
+ };
189
+ }
190
+ child.stdout?.on("data", (chunk) => stdout.write(chunk));
191
+ child.stderr?.on("data", (chunk) => stderr.write(chunk));
192
+ child.once("error", () => {
193
+ result.status = "spawn_failed";
194
+ if (child?.pid !== undefined)
195
+ cleanProcessGroup();
196
+ });
197
+ child.once("exit", (code) => {
198
+ exited = true;
199
+ result.exitCode = code;
200
+ result.status = code === 0 ? "success" : "nonzero_exit";
201
+ if (processGroupExists(child?.pid))
202
+ cleanProcessGroup();
203
+ });
204
+ child.once("close", () => {
205
+ closed = true;
206
+ finishIfClean();
207
+ });
208
+ timeout = setTimeout(() => stop("timeout"), options.timeoutMs ?? 10_000);
209
+ });
210
+ }
211
+ function isExecutable(path) {
212
+ try {
213
+ accessSync(path, constants.X_OK);
214
+ return statSync(path).isFile();
215
+ }
216
+ catch {
217
+ return false;
218
+ }
219
+ }
220
+ function processGroupExists(pid) {
221
+ if (pid === undefined)
222
+ return false;
223
+ try {
224
+ process.kill(-pid, 0);
225
+ return true;
226
+ }
227
+ catch (error) {
228
+ return typeof error === "object" && error !== null && "code" in error && error.code === "EPERM";
229
+ }
230
+ }
231
+ function signalProcessGroup(pid, signal) {
232
+ try {
233
+ process.kill(-pid, signal);
234
+ }
235
+ catch {
236
+ // 自然退出与进程组信号存在竞态;组已消失即无需继续处理。
237
+ }
238
+ }
@@ -0,0 +1 @@
1
+ export {};
@@ -0,0 +1,39 @@
1
+ import { AppError } from "../errors.js";
2
+ import { hasUnsafeTerminalControlCharacters } from "../terminal-text.js";
3
+ import { AiResponseValidationError, parseAndValidateAiResponse } from "./ai-response.js";
4
+ export class UsageGenerationFailureError extends AppError {
5
+ constructor(reason) {
6
+ super(reason, 2);
7
+ this.name = "UsageGenerationFailureError";
8
+ }
9
+ }
10
+ /** 仅交互式 use 会话接受明确失败;成功候选继续通过既有全部强校验。 */
11
+ export function parseAndValidateUsageResponse(rawText) {
12
+ let parsed;
13
+ try {
14
+ parsed = JSON.parse(rawText);
15
+ }
16
+ catch {
17
+ throw new AiResponseValidationError("AI response is not valid JSON");
18
+ }
19
+ if (typeof parsed !== "object" || parsed === null || Array.isArray(parsed)) {
20
+ throw new AiResponseValidationError("AI response root must be a JSON object");
21
+ }
22
+ const root = parsed;
23
+ if (Object.keys(root).some((key) => key !== "commands" && key !== "failureReason") ||
24
+ !Array.isArray(root.commands) ||
25
+ typeof root.failureReason !== "string" ||
26
+ hasUnsafeTerminalControlCharacters(root.failureReason)) {
27
+ throw new AiResponseValidationError("usage response must contain commands and failureReason");
28
+ }
29
+ if (root.commands.length === 0) {
30
+ if (root.failureReason.trim() === "") {
31
+ throw new AiResponseValidationError("empty commands require a non-empty failureReason");
32
+ }
33
+ throw new UsageGenerationFailureError(root.failureReason);
34
+ }
35
+ if (root.failureReason !== "") {
36
+ throw new AiResponseValidationError("successful commands require an empty failureReason");
37
+ }
38
+ return parseAndValidateAiResponse(rawText);
39
+ }
package/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "@unscientificjszhai/howto",
3
- "version": "1.0.2",
3
+ "version": "1.1.0",
4
4
  "type": "module",
5
5
  "os": [
6
6
  "darwin",
@@ -28,8 +28,8 @@
28
28
  "THIRD_PARTY_NOTICES.md"
29
29
  ],
30
30
  "scripts": {
31
- "build": "npm run clean:dist && tsc",
32
- "build:test": "npm run clean:dist-test && tsc -p tsconfig.test.json",
31
+ "build": "npm run clean:dist && node ./node_modules/@typescript/native/bin/tsc",
32
+ "build:test": "npm run clean:dist-test && node ./node_modules/@typescript/native/bin/tsc -p tsconfig.test.json",
33
33
  "clean:dist": "node -e \"require('node:fs').rmSync('dist', { recursive: true, force: true })\"",
34
34
  "clean:dist-test": "node -e \"require('node:fs').rmSync('dist-test', { recursive: true, force: true })\"",
35
35
  "format": "prettier . --write",
@@ -41,28 +41,30 @@
41
41
  "test": "npm run build:test && node --test dist-test/tests/unit/*.test.js dist-test/tests/unit/**/*.test.js dist-test/tests/integration/*.test.js dist-test/tests/integration/**/*.test.js",
42
42
  "test:integration": "npm run build:test && node --test dist-test/tests/integration/*.test.js dist-test/tests/integration/**/*.test.js",
43
43
  "test:package": "npm run build:test && node dist-test/tests/package-smoke.js",
44
- "test:unit": "npm run build:test && node --test dist-test/tests/unit/*.test.js dist-test/tests/unit/**/*.test.js"
44
+ "test:unit": "npm run build:test && node --test dist-test/tests/unit/*.test.js dist-test/tests/unit/**/*.test.js",
45
+ "check:toolchain": "node scripts/check-toolchain.mjs"
45
46
  },
46
47
  "dependencies": {
47
- "@google/genai": "^2.18.0",
48
- "ink": "^7.1.1",
49
- "openai": "^7.5.0",
50
- "react": "^19.2.8",
51
- "signal-exit": "^3.0.7",
52
- "string-width": "^8.2.2"
48
+ "@google/genai": "^2.31.0",
49
+ "ink": "^8.0.0",
50
+ "jose": "^6.2.13",
51
+ "openai": "^7.43.0",
52
+ "react": "^19.3.1",
53
+ "signal-exit": "^4.1.0",
54
+ "string-width": "^8.3.0"
53
55
  },
54
56
  "devDependencies": {
55
57
  "@eslint/js": "^10.0.1",
56
- "@types/node": "^26.2.0",
57
- "@types/react": "^19.2.18",
58
- "@types/react-dom": "^19.2.4",
59
- "@types/signal-exit": "^3.0.4",
60
- "eslint": "^10.9.0",
58
+ "@types/node": "^26.6.5",
59
+ "@types/react": "^19.3.0",
60
+ "@types/react-dom": "^19.3.0",
61
+ "@typescript/native": "npm:typescript@^7.0.2",
62
+ "eslint": "^10.13.0",
61
63
  "husky": "^9.1.7",
62
- "lint-staged": "^17.3.0",
63
- "prettier": "^3.9.6",
64
- "typescript": "^6.0.3",
65
- "typescript-eslint": "^8.67.0"
64
+ "lint-staged": "^17.6.0",
65
+ "prettier": "^3.9.10",
66
+ "typescript": "npm:@typescript/typescript6@^6.0.2",
67
+ "typescript-eslint": "^8.72.0"
66
68
  },
67
69
  "lint-staged": {
68
70
  "*.{ts,tsx}": [