@shi_zhen/code-helper 0.1.4 → 0.1.6
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/index.js +206 -109
- package/dist/cli/index.js.map +1 -1
- package/dist/cli/index.mjs +210 -109
- package/dist/cli/index.mjs.map +1 -1
- package/dist/index.d.mts +1 -2
- package/dist/index.d.ts +1 -2
- package/dist/index.js +0 -33
- package/dist/index.js.map +1 -1
- package/dist/index.mjs +0 -7
- package/dist/index.mjs.map +1 -1
- package/package.json +1 -1
package/dist/cli/index.mjs
CHANGED
|
@@ -1,17 +1,13 @@
|
|
|
1
|
+
var __create = Object.create;
|
|
1
2
|
var __defProp = Object.defineProperty;
|
|
2
3
|
var __getOwnPropDesc = Object.getOwnPropertyDescriptor;
|
|
3
4
|
var __getOwnPropNames = Object.getOwnPropertyNames;
|
|
5
|
+
var __getProtoOf = Object.getPrototypeOf;
|
|
4
6
|
var __hasOwnProp = Object.prototype.hasOwnProperty;
|
|
5
|
-
var __require = /* @__PURE__ */ ((x) => typeof require !== "undefined" ? require : typeof Proxy !== "undefined" ? new Proxy(x, {
|
|
6
|
-
get: (a, b) => (typeof require !== "undefined" ? require : a)[b]
|
|
7
|
-
}) : x)(function(x) {
|
|
8
|
-
if (typeof require !== "undefined") return require.apply(this, arguments);
|
|
9
|
-
throw Error('Dynamic require of "' + x + '" is not supported');
|
|
10
|
-
});
|
|
11
7
|
var __esm = (fn, res) => function __init() {
|
|
12
8
|
return fn && (res = (0, fn[__getOwnPropNames(fn)[0]])(fn = 0)), res;
|
|
13
9
|
};
|
|
14
|
-
var __commonJS = (cb, mod) => function
|
|
10
|
+
var __commonJS = (cb, mod) => function __require() {
|
|
15
11
|
return mod || (0, cb[__getOwnPropNames(cb)[0]])((mod = { exports: {} }).exports, mod), mod.exports;
|
|
16
12
|
};
|
|
17
13
|
var __export = (target, all) => {
|
|
@@ -26,14 +22,21 @@ var __copyProps = (to, from, except, desc) => {
|
|
|
26
22
|
}
|
|
27
23
|
return to;
|
|
28
24
|
};
|
|
29
|
-
var
|
|
25
|
+
var __toESM = (mod, isNodeMode, target) => (target = mod != null ? __create(__getProtoOf(mod)) : {}, __copyProps(
|
|
26
|
+
// If the importer is in node compatibility mode or this is not an ESM
|
|
27
|
+
// file that has been converted to a CommonJS file using a Babel-
|
|
28
|
+
// compatible transform (i.e. "__esModule" has not been set), then set
|
|
29
|
+
// "default" to the CommonJS "module.exports" for node compatibility.
|
|
30
|
+
isNodeMode || !mod || !mod.__esModule ? __defProp(target, "default", { value: mod, enumerable: true }) : target,
|
|
31
|
+
mod
|
|
32
|
+
));
|
|
30
33
|
|
|
31
34
|
// package.json
|
|
32
35
|
var require_package = __commonJS({
|
|
33
36
|
"package.json"(exports, module) {
|
|
34
37
|
module.exports = {
|
|
35
38
|
name: "@shi_zhen/code-helper",
|
|
36
|
-
version: "0.1.
|
|
39
|
+
version: "0.1.6",
|
|
37
40
|
description: "Code Helper - A unified tool to manage your Claude Code",
|
|
38
41
|
repository: {
|
|
39
42
|
type: "git",
|
|
@@ -176,9 +179,11 @@ __export(version_exports, {
|
|
|
176
179
|
});
|
|
177
180
|
import chalk3 from "chalk";
|
|
178
181
|
import ora7 from "ora";
|
|
182
|
+
import os11 from "os";
|
|
183
|
+
import path11 from "path";
|
|
184
|
+
import fs10 from "fs";
|
|
179
185
|
function getLocalVersion() {
|
|
180
|
-
|
|
181
|
-
return pkg3.version;
|
|
186
|
+
return import_package.default.version;
|
|
182
187
|
}
|
|
183
188
|
async function getRemoteVersion() {
|
|
184
189
|
try {
|
|
@@ -307,14 +312,12 @@ async function testUpdate() {
|
|
|
307
312
|
chalk3.cyan("\n\u{1F4A1} \u63D0\u793A: \u53D1\u5E03\u65B0\u7248\u672C\u540E\uFF0C\u7528\u6237\u9996\u6B21\u542F\u52A8\u65F6\u4F1A\u81EA\u52A8\u66F4\u65B0\n")
|
|
308
313
|
);
|
|
309
314
|
}
|
|
310
|
-
var
|
|
315
|
+
var import_package, CACHE_DIR, CACHE_FILE, CHECK_INTERVAL;
|
|
311
316
|
var init_version = __esm({
|
|
312
317
|
"src/cli/utils/version.ts"() {
|
|
313
318
|
"use strict";
|
|
314
319
|
init_exec();
|
|
315
|
-
|
|
316
|
-
path11 = __require("path");
|
|
317
|
-
fs10 = __require("fs");
|
|
320
|
+
import_package = __toESM(require_package());
|
|
318
321
|
CACHE_DIR = path11.join(os11.homedir(), ".code-helper");
|
|
319
322
|
CACHE_FILE = path11.join(CACHE_DIR, "version-check.json");
|
|
320
323
|
CHECK_INTERVAL = 24 * 60 * 60 * 1e3;
|
|
@@ -691,6 +694,15 @@ function switchProfile(id) {
|
|
|
691
694
|
if (profile.timeout) {
|
|
692
695
|
settings.env.API_TIMEOUT_MS = profile.timeout;
|
|
693
696
|
}
|
|
697
|
+
if (profile.haikuModel) {
|
|
698
|
+
settings.env.ANTHROPIC_DEFAULT_HAIKU_MODEL = profile.haikuModel;
|
|
699
|
+
}
|
|
700
|
+
if (profile.sonnetModel) {
|
|
701
|
+
settings.env.ANTHROPIC_DEFAULT_SONNET_MODEL = profile.sonnetModel;
|
|
702
|
+
}
|
|
703
|
+
if (profile.opusModel) {
|
|
704
|
+
settings.env.ANTHROPIC_DEFAULT_OPUS_MODEL = profile.opusModel;
|
|
705
|
+
}
|
|
694
706
|
writeClaudeSettings(settings);
|
|
695
707
|
config.currentProfileId = id;
|
|
696
708
|
writeProfiles(config);
|
|
@@ -711,14 +723,14 @@ import ora from "ora";
|
|
|
711
723
|
// src/cli/utils/api.ts
|
|
712
724
|
import http from "http";
|
|
713
725
|
import https from "https";
|
|
714
|
-
async function verifyApiKey(baseUrl, apiKey) {
|
|
726
|
+
async function verifyApiKey(baseUrl, apiKey, model) {
|
|
715
727
|
return new Promise((resolve) => {
|
|
716
728
|
try {
|
|
717
729
|
const url = new URL(baseUrl);
|
|
718
730
|
const isHttps = url.protocol === "https:";
|
|
719
731
|
const client = isHttps ? https : http;
|
|
720
732
|
const testPayload = JSON.stringify({
|
|
721
|
-
model: "claude-3-5-sonnet-20241022",
|
|
733
|
+
model: model || "claude-3-5-sonnet-20241022",
|
|
722
734
|
max_tokens: 1,
|
|
723
735
|
messages: [{ role: "user", content: "test" }]
|
|
724
736
|
});
|
|
@@ -808,6 +820,15 @@ async function showAuthMenu() {
|
|
|
808
820
|
console.log(
|
|
809
821
|
`${theme.dim(" API Key:")} ${maskApiKey(currentProfile.apiKey)}`
|
|
810
822
|
);
|
|
823
|
+
if (currentProfile.haikuModel) {
|
|
824
|
+
console.log(`${theme.dim(" Haiku Model:")} ${currentProfile.haikuModel}`);
|
|
825
|
+
}
|
|
826
|
+
if (currentProfile.sonnetModel) {
|
|
827
|
+
console.log(`${theme.dim(" Sonnet Model:")} ${currentProfile.sonnetModel}`);
|
|
828
|
+
}
|
|
829
|
+
if (currentProfile.opusModel) {
|
|
830
|
+
console.log(`${theme.dim(" Opus Model:")} ${currentProfile.opusModel}`);
|
|
831
|
+
}
|
|
811
832
|
console.log();
|
|
812
833
|
}
|
|
813
834
|
const savedProfiles = getAllProfiles();
|
|
@@ -1111,9 +1132,49 @@ async function handleManualAuth() {
|
|
|
1111
1132
|
}
|
|
1112
1133
|
}
|
|
1113
1134
|
]);
|
|
1135
|
+
let haikuModel;
|
|
1136
|
+
let sonnetModel;
|
|
1137
|
+
let opusModel;
|
|
1138
|
+
const { configModels } = await inquirer.prompt([
|
|
1139
|
+
{
|
|
1140
|
+
type: "confirm",
|
|
1141
|
+
name: "configModels",
|
|
1142
|
+
message: "\u662F\u5426\u9700\u8981\u914D\u7F6E\u6A21\u578B\u6620\u5C04\uFF1F\uFF08\u7528\u4E8E ZenMux \u7B49\u9700\u8981\u81EA\u5B9A\u4E49\u6A21\u578B\u7684\u5E73\u53F0\uFF09",
|
|
1143
|
+
default: false
|
|
1144
|
+
}
|
|
1145
|
+
]);
|
|
1146
|
+
if (configModels) {
|
|
1147
|
+
console.log();
|
|
1148
|
+
console.log(theme.dim("\u8BF7\u8F93\u5165\u5404\u6A21\u578B\u7684\u6620\u5C04\u540D\u79F0\uFF08\u76F4\u63A5\u56DE\u8F66\u8DF3\u8FC7\uFF09\uFF1A"));
|
|
1149
|
+
console.log();
|
|
1150
|
+
const modelAnswers = await inquirer.prompt([
|
|
1151
|
+
{
|
|
1152
|
+
type: "input",
|
|
1153
|
+
name: "haikuModel",
|
|
1154
|
+
message: "ANTHROPIC_DEFAULT_HAIKU_MODEL\uFF08\u5FEB\u901F\u6A21\u578B\uFF09:",
|
|
1155
|
+
default: ""
|
|
1156
|
+
},
|
|
1157
|
+
{
|
|
1158
|
+
type: "input",
|
|
1159
|
+
name: "sonnetModel",
|
|
1160
|
+
message: "ANTHROPIC_DEFAULT_SONNET_MODEL\uFF08\u5747\u8861\u6A21\u578B\uFF09:",
|
|
1161
|
+
default: ""
|
|
1162
|
+
},
|
|
1163
|
+
{
|
|
1164
|
+
type: "input",
|
|
1165
|
+
name: "opusModel",
|
|
1166
|
+
message: "ANTHROPIC_DEFAULT_OPUS_MODEL\uFF08\u6700\u5F3A\u6A21\u578B\uFF09:",
|
|
1167
|
+
default: ""
|
|
1168
|
+
}
|
|
1169
|
+
]);
|
|
1170
|
+
if (modelAnswers.haikuModel?.trim()) haikuModel = modelAnswers.haikuModel.trim();
|
|
1171
|
+
if (modelAnswers.sonnetModel?.trim()) sonnetModel = modelAnswers.sonnetModel.trim();
|
|
1172
|
+
if (modelAnswers.opusModel?.trim()) opusModel = modelAnswers.opusModel.trim();
|
|
1173
|
+
}
|
|
1174
|
+
const verifyModel = sonnetModel || haikuModel || opusModel;
|
|
1114
1175
|
console.log();
|
|
1115
1176
|
const spinner = ora("\u6B63\u5728\u9A8C\u8BC1 API Key...").start();
|
|
1116
|
-
const verification = await verifyApiKey(baseUrl.trim(), apiKey.trim());
|
|
1177
|
+
const verification = await verifyApiKey(baseUrl.trim(), apiKey.trim(), verifyModel);
|
|
1117
1178
|
if (!verification.valid) {
|
|
1118
1179
|
spinner.fail("API Key \u9A8C\u8BC1\u5931\u8D25");
|
|
1119
1180
|
console.log();
|
|
@@ -1127,6 +1188,9 @@ async function handleManualAuth() {
|
|
|
1127
1188
|
if (timeout && timeout.trim()) {
|
|
1128
1189
|
options.timeout = timeout.trim();
|
|
1129
1190
|
}
|
|
1191
|
+
if (haikuModel) options.haikuModel = haikuModel;
|
|
1192
|
+
if (sonnetModel) options.sonnetModel = sonnetModel;
|
|
1193
|
+
if (opusModel) options.opusModel = opusModel;
|
|
1130
1194
|
await saveApiConfig(baseUrl.trim(), apiKey.trim(), options);
|
|
1131
1195
|
console.log();
|
|
1132
1196
|
showSuccess("\u914D\u7F6E\u5DF2\u751F\u6548");
|
|
@@ -1136,7 +1200,10 @@ async function handleManualAuth() {
|
|
|
1136
1200
|
baseUrl.trim(),
|
|
1137
1201
|
apiKey.trim(),
|
|
1138
1202
|
void 0,
|
|
1139
|
-
timeout && timeout.trim() ? timeout.trim() : void 0
|
|
1203
|
+
timeout && timeout.trim() ? timeout.trim() : void 0,
|
|
1204
|
+
haikuModel,
|
|
1205
|
+
sonnetModel,
|
|
1206
|
+
opusModel
|
|
1140
1207
|
);
|
|
1141
1208
|
} catch (error) {
|
|
1142
1209
|
console.log();
|
|
@@ -1144,7 +1211,7 @@ async function handleManualAuth() {
|
|
|
1144
1211
|
await waitForEnter();
|
|
1145
1212
|
}
|
|
1146
1213
|
}
|
|
1147
|
-
async function askToSaveProfile(defaultName, baseUrl, apiKey, model, timeout) {
|
|
1214
|
+
async function askToSaveProfile(defaultName, baseUrl, apiKey, model, timeout, haikuModel, sonnetModel, opusModel) {
|
|
1148
1215
|
console.log();
|
|
1149
1216
|
const { save } = await inquirer.prompt([
|
|
1150
1217
|
{
|
|
@@ -1173,7 +1240,10 @@ async function askToSaveProfile(defaultName, baseUrl, apiKey, model, timeout) {
|
|
|
1173
1240
|
baseUrl,
|
|
1174
1241
|
apiKey,
|
|
1175
1242
|
model,
|
|
1176
|
-
timeout
|
|
1243
|
+
timeout,
|
|
1244
|
+
haikuModel,
|
|
1245
|
+
sonnetModel,
|
|
1246
|
+
opusModel
|
|
1177
1247
|
});
|
|
1178
1248
|
switchProfile(newProfile.id);
|
|
1179
1249
|
showSuccess(`\u914D\u7F6E "${name.trim()}" \u5DF2\u4FDD\u5B58`);
|
|
@@ -2436,6 +2506,37 @@ var MarketplaceService = class {
|
|
|
2436
2506
|
this.execClaude(`plugin marketplace add "${market.source}"`);
|
|
2437
2507
|
return true;
|
|
2438
2508
|
} catch (error) {
|
|
2509
|
+
if (error.message.includes("HTTPS authentication failed") || error.message.includes("terminal prompts disabled") || error.message.includes("could not read Username")) {
|
|
2510
|
+
throw new Error(`\u274C \u6DFB\u52A0\u5E02\u573A\u5931\u8D25\uFF1AGit HTTPS \u8BA4\u8BC1\u5931\u8D25
|
|
2511
|
+
|
|
2512
|
+
\u{1F4CB} \u95EE\u9898\u539F\u56E0\uFF1A
|
|
2513
|
+
\u4ED3\u5E93\u9700\u8981 HTTPS \u8BA4\u8BC1\uFF0C\u4F46\u7EC8\u7AEF\u63D0\u793A\u5DF2\u88AB\u7981\u7528
|
|
2514
|
+
|
|
2515
|
+
\u{1F4A1} \u89E3\u51B3\u65B9\u6848\uFF08\u8BF7\u9009\u62E9\u5176\u4E2D\u4E00\u79CD\uFF09\uFF1A
|
|
2516
|
+
|
|
2517
|
+
\u65B9\u6848 1\uFF1A\u914D\u7F6E Git \u51ED\u8BC1\u52A9\u624B\uFF08\u63A8\u8350\uFF09
|
|
2518
|
+
$ git config --global credential.helper store
|
|
2519
|
+
\u7136\u540E\u624B\u52A8\u514B\u9686\u4E00\u6B21\u8BE5\u4ED3\u5E93\uFF0C\u7CFB\u7EDF\u4F1A\u4FDD\u5B58\u51ED\u8BC1\uFF1A
|
|
2520
|
+
$ git clone ${market.source}
|
|
2521
|
+
|
|
2522
|
+
\u65B9\u6848 2\uFF1A\u4F7F\u7528 SSH URL \u683C\u5F0F
|
|
2523
|
+
\u5C06 HTTPS URL:
|
|
2524
|
+
${market.source}
|
|
2525
|
+
|
|
2526
|
+
\u6539\u4E3A SSH \u683C\u5F0F\uFF0C\u4F8B\u5982\uFF1A
|
|
2527
|
+
git@github.com:org/repo.git
|
|
2528
|
+
|
|
2529
|
+
\u65B9\u6848 3\uFF1A\u4F7F\u7528 GitHub CLI\uFF08\u9002\u7528\u4E8E GitHub\uFF09
|
|
2530
|
+
$ gh auth login
|
|
2531
|
+
|
|
2532
|
+
\u65B9\u6848 4\uFF1A\u914D\u7F6E Git \u8BA4\u8BC1\u6587\u4EF6
|
|
2533
|
+
\u5728 ~/.netrc \u6587\u4EF6\u4E2D\u6DFB\u52A0\u8BA4\u8BC1\u4FE1\u606F\uFF1A
|
|
2534
|
+
machine github.com (\u6216\u5176\u4ED6\u57DF\u540D)
|
|
2535
|
+
login your-username
|
|
2536
|
+
password your-token
|
|
2537
|
+
|
|
2538
|
+
\u63D0\u793A\uFF1A\u914D\u7F6E\u5B8C\u6210\u540E\uFF0C\u8BF7\u91CD\u65B0\u8FD0\u884C\u5B89\u88C5\u547D\u4EE4`);
|
|
2539
|
+
}
|
|
2439
2540
|
if (error.message.includes("already exists") || error.message.includes("already configured") || error.message.includes("already installed")) {
|
|
2440
2541
|
return true;
|
|
2441
2542
|
}
|
|
@@ -3273,68 +3374,68 @@ var PERMISSION_RULES = {
|
|
|
3273
3374
|
"Glob(*)",
|
|
3274
3375
|
"Grep(*)",
|
|
3275
3376
|
// Git 常规操作
|
|
3276
|
-
"Bash(git
|
|
3277
|
-
"Bash(git
|
|
3278
|
-
"Bash(git
|
|
3279
|
-
"Bash(git
|
|
3280
|
-
"Bash(git
|
|
3281
|
-
"Bash(git
|
|
3282
|
-
"Bash(git
|
|
3283
|
-
"Bash(git
|
|
3284
|
-
"Bash(git
|
|
3285
|
-
"Bash(git
|
|
3286
|
-
"Bash(git
|
|
3287
|
-
"Bash(git
|
|
3377
|
+
"Bash(git status*)",
|
|
3378
|
+
"Bash(git add*)",
|
|
3379
|
+
"Bash(git commit*)",
|
|
3380
|
+
"Bash(git pull*)",
|
|
3381
|
+
"Bash(git branch*)",
|
|
3382
|
+
"Bash(git checkout*)",
|
|
3383
|
+
"Bash(git diff*)",
|
|
3384
|
+
"Bash(git log*)",
|
|
3385
|
+
"Bash(git clone*)",
|
|
3386
|
+
"Bash(git stash*)",
|
|
3387
|
+
"Bash(git show*)",
|
|
3388
|
+
"Bash(git fetch*)",
|
|
3288
3389
|
// Node/NPM
|
|
3289
|
-
"Bash(node
|
|
3290
|
-
"Bash(npm
|
|
3291
|
-
"Bash(npm
|
|
3292
|
-
"Bash(npm
|
|
3293
|
-
"Bash(npx
|
|
3390
|
+
"Bash(node *)",
|
|
3391
|
+
"Bash(npm run*)",
|
|
3392
|
+
"Bash(npm test*)",
|
|
3393
|
+
"Bash(npm install*)",
|
|
3394
|
+
"Bash(npx *)",
|
|
3294
3395
|
// Python
|
|
3295
|
-
"Bash(python
|
|
3296
|
-
"Bash(python3
|
|
3297
|
-
"Bash(pip
|
|
3298
|
-
"Bash(pip3
|
|
3396
|
+
"Bash(python *)",
|
|
3397
|
+
"Bash(python3 *)",
|
|
3398
|
+
"Bash(pip install*)",
|
|
3399
|
+
"Bash(pip3 install*)",
|
|
3299
3400
|
// 常用工具
|
|
3300
|
-
"Bash(cat
|
|
3301
|
-
"Bash(ls
|
|
3302
|
-
"Bash(grep
|
|
3303
|
-
"Bash(find
|
|
3304
|
-
"Bash(curl
|
|
3305
|
-
"Bash(wget
|
|
3306
|
-
"Bash(echo
|
|
3307
|
-
"Bash(mkdir
|
|
3308
|
-
"Bash(cp
|
|
3309
|
-
"Bash(mv
|
|
3310
|
-
"Bash(touch
|
|
3311
|
-
"Bash(pwd
|
|
3312
|
-
"Bash(cd
|
|
3401
|
+
"Bash(cat *)",
|
|
3402
|
+
"Bash(ls *)",
|
|
3403
|
+
"Bash(grep *)",
|
|
3404
|
+
"Bash(find *)",
|
|
3405
|
+
"Bash(curl *)",
|
|
3406
|
+
"Bash(wget *)",
|
|
3407
|
+
"Bash(echo *)",
|
|
3408
|
+
"Bash(mkdir *)",
|
|
3409
|
+
"Bash(cp *)",
|
|
3410
|
+
"Bash(mv *)",
|
|
3411
|
+
"Bash(touch *)",
|
|
3412
|
+
"Bash(pwd*)",
|
|
3413
|
+
"Bash(cd *)"
|
|
3313
3414
|
],
|
|
3314
3415
|
deny: [
|
|
3315
3416
|
// 高危操作
|
|
3316
|
-
"Bash(rm
|
|
3317
|
-
"Bash(rm
|
|
3318
|
-
"Bash(rm
|
|
3319
|
-
"Bash(sudo
|
|
3320
|
-
"Bash(git
|
|
3321
|
-
"Bash(git
|
|
3322
|
-
"Bash(chmod
|
|
3323
|
-
"Bash(chown
|
|
3417
|
+
"Bash(rm -rf*)",
|
|
3418
|
+
"Bash(rm *-rf*)",
|
|
3419
|
+
"Bash(rm *-r*-f*)",
|
|
3420
|
+
"Bash(sudo *)",
|
|
3421
|
+
"Bash(git push*--force*)",
|
|
3422
|
+
"Bash(git push*-f*)",
|
|
3423
|
+
"Bash(chmod *)",
|
|
3424
|
+
"Bash(chown *)",
|
|
3324
3425
|
// 反黑客操作
|
|
3325
|
-
"Bash(nc
|
|
3426
|
+
"Bash(nc *-e*)",
|
|
3326
3427
|
// 反向 shell
|
|
3327
|
-
"Bash(bash
|
|
3428
|
+
"Bash(bash *-i*)",
|
|
3328
3429
|
// 交互式 bash
|
|
3329
3430
|
"Bash(*>&*)",
|
|
3330
3431
|
// 重定向到网络
|
|
3331
3432
|
"Bash(*base64*-d*)",
|
|
3332
3433
|
// 可疑的 base64 解码
|
|
3333
|
-
"Bash(wget
|
|
3434
|
+
"Bash(wget *&&*)",
|
|
3334
3435
|
// 下载并执行
|
|
3335
|
-
"Bash(curl
|
|
3436
|
+
"Bash(curl *|*sh*)",
|
|
3336
3437
|
// 管道执行
|
|
3337
|
-
"Bash(curl
|
|
3438
|
+
"Bash(curl *|*bash*)"
|
|
3338
3439
|
]
|
|
3339
3440
|
},
|
|
3340
3441
|
// 最大权限配置
|
|
@@ -3347,58 +3448,58 @@ var PERMISSION_RULES = {
|
|
|
3347
3448
|
"Glob(*)",
|
|
3348
3449
|
"Grep(*)",
|
|
3349
3450
|
// Git 所有操作(除了强制推送)
|
|
3350
|
-
"Bash(git
|
|
3451
|
+
"Bash(git *)",
|
|
3351
3452
|
// Node/NPM
|
|
3352
|
-
"Bash(node
|
|
3353
|
-
"Bash(npm
|
|
3354
|
-
"Bash(npx
|
|
3453
|
+
"Bash(node *)",
|
|
3454
|
+
"Bash(npm *)",
|
|
3455
|
+
"Bash(npx *)",
|
|
3355
3456
|
// Python
|
|
3356
|
-
"Bash(python
|
|
3357
|
-
"Bash(python3
|
|
3358
|
-
"Bash(pip
|
|
3359
|
-
"Bash(pip3
|
|
3457
|
+
"Bash(python *)",
|
|
3458
|
+
"Bash(python3 *)",
|
|
3459
|
+
"Bash(pip *)",
|
|
3460
|
+
"Bash(pip3 *)",
|
|
3360
3461
|
// 常用工具
|
|
3361
|
-
"Bash(cat
|
|
3362
|
-
"Bash(ls
|
|
3363
|
-
"Bash(grep
|
|
3364
|
-
"Bash(find
|
|
3365
|
-
"Bash(curl
|
|
3366
|
-
"Bash(wget
|
|
3367
|
-
"Bash(echo
|
|
3368
|
-
"Bash(mkdir
|
|
3369
|
-
"Bash(cp
|
|
3370
|
-
"Bash(mv
|
|
3371
|
-
"Bash(touch
|
|
3372
|
-
"Bash(pwd
|
|
3373
|
-
"Bash(cd
|
|
3462
|
+
"Bash(cat *)",
|
|
3463
|
+
"Bash(ls *)",
|
|
3464
|
+
"Bash(grep *)",
|
|
3465
|
+
"Bash(find *)",
|
|
3466
|
+
"Bash(curl *)",
|
|
3467
|
+
"Bash(wget *)",
|
|
3468
|
+
"Bash(echo *)",
|
|
3469
|
+
"Bash(mkdir *)",
|
|
3470
|
+
"Bash(cp *)",
|
|
3471
|
+
"Bash(mv *)",
|
|
3472
|
+
"Bash(touch *)",
|
|
3473
|
+
"Bash(pwd*)",
|
|
3474
|
+
"Bash(cd *)",
|
|
3374
3475
|
// 额外允许的操作
|
|
3375
|
-
"Bash(rm
|
|
3476
|
+
"Bash(rm *)"
|
|
3376
3477
|
// 允许删除,但不包括 rm -rf
|
|
3377
3478
|
],
|
|
3378
3479
|
deny: [
|
|
3379
3480
|
// 高危操作(需要确认)
|
|
3380
|
-
"Bash(rm
|
|
3381
|
-
"Bash(rm
|
|
3382
|
-
"Bash(rm
|
|
3383
|
-
"Bash(sudo
|
|
3384
|
-
"Bash(git
|
|
3385
|
-
"Bash(git
|
|
3386
|
-
"Bash(dd
|
|
3387
|
-
"Bash(mkfs
|
|
3481
|
+
"Bash(rm -rf*)",
|
|
3482
|
+
"Bash(rm *-rf*)",
|
|
3483
|
+
"Bash(rm *-r*-f*)",
|
|
3484
|
+
"Bash(sudo *)",
|
|
3485
|
+
"Bash(git push*--force*)",
|
|
3486
|
+
"Bash(git push*-f*)",
|
|
3487
|
+
"Bash(dd *)",
|
|
3488
|
+
"Bash(mkfs *)",
|
|
3388
3489
|
// 反黑客操作
|
|
3389
|
-
"Bash(nc
|
|
3490
|
+
"Bash(nc *-e*)",
|
|
3390
3491
|
// 反向 shell
|
|
3391
|
-
"Bash(bash
|
|
3492
|
+
"Bash(bash *-i*)",
|
|
3392
3493
|
// 交互式 bash
|
|
3393
3494
|
"Bash(*>&*)",
|
|
3394
3495
|
// 重定向到网络
|
|
3395
3496
|
"Bash(*base64*-d*)",
|
|
3396
3497
|
// 可疑的 base64 解码
|
|
3397
|
-
"Bash(wget
|
|
3498
|
+
"Bash(wget *&&*)",
|
|
3398
3499
|
// 下载并执行
|
|
3399
|
-
"Bash(curl
|
|
3500
|
+
"Bash(curl *|*sh*)",
|
|
3400
3501
|
// 管道执行
|
|
3401
|
-
"Bash(curl
|
|
3502
|
+
"Bash(curl *|*bash*)"
|
|
3402
3503
|
]
|
|
3403
3504
|
}
|
|
3404
3505
|
};
|
|
@@ -3943,7 +4044,7 @@ async function showMainMenu() {
|
|
|
3943
4044
|
await showPluginsMenu();
|
|
3944
4045
|
break;
|
|
3945
4046
|
case "webui" /* WEBUI */: {
|
|
3946
|
-
const { launchWebUI: launchWebUI2 } = (init_webui(),
|
|
4047
|
+
const { launchWebUI: launchWebUI2 } = await Promise.resolve().then(() => (init_webui(), webui_exports));
|
|
3947
4048
|
await launchWebUI2();
|
|
3948
4049
|
break;
|
|
3949
4050
|
}
|
|
@@ -3956,27 +4057,27 @@ async function showMainMenu() {
|
|
|
3956
4057
|
|
|
3957
4058
|
// src/cli/index.ts
|
|
3958
4059
|
init_version();
|
|
3959
|
-
var
|
|
4060
|
+
var import_package2 = __toESM(require_package());
|
|
3960
4061
|
async function main() {
|
|
3961
4062
|
try {
|
|
3962
4063
|
const args = process.argv.slice(2);
|
|
3963
4064
|
if (args.includes("--version") || args.includes("-v")) {
|
|
3964
|
-
console.log(`v${
|
|
4065
|
+
console.log(`v${import_package2.default.version}`);
|
|
3965
4066
|
process.exit(0);
|
|
3966
4067
|
}
|
|
3967
4068
|
if (args.includes("--test-update")) {
|
|
3968
|
-
const { testUpdate: testUpdate2 } = (init_version(),
|
|
4069
|
+
const { testUpdate: testUpdate2 } = await Promise.resolve().then(() => (init_version(), version_exports));
|
|
3969
4070
|
await testUpdate2();
|
|
3970
4071
|
process.exit(0);
|
|
3971
4072
|
}
|
|
3972
4073
|
if (args.includes("ui")) {
|
|
3973
|
-
const { launchWebUI: launchWebUI2 } = (init_webui(),
|
|
4074
|
+
const { launchWebUI: launchWebUI2 } = await Promise.resolve().then(() => (init_webui(), webui_exports));
|
|
3974
4075
|
await launchWebUI2();
|
|
3975
4076
|
process.exit(0);
|
|
3976
4077
|
}
|
|
3977
4078
|
if (args.includes("--help") || args.includes("-h")) {
|
|
3978
4079
|
console.log(`
|
|
3979
|
-
Code Helper v${
|
|
4080
|
+
Code Helper v${import_package2.default.version}
|
|
3980
4081
|
A unified tool to manage your Claude Code
|
|
3981
4082
|
|
|
3982
4083
|
Usage:
|