@shi_zhen/code-helper 0.1.4 → 0.1.5
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 +133 -103
- package/dist/cli/index.js.map +1 -1
- package/dist/cli/index.mjs +137 -103
- 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.js
CHANGED
|
@@ -31,14 +31,13 @@ var __toESM = (mod, isNodeMode, target) => (target = mod != null ? __create(__ge
|
|
|
31
31
|
isNodeMode || !mod || !mod.__esModule ? __defProp(target, "default", { value: mod, enumerable: true }) : target,
|
|
32
32
|
mod
|
|
33
33
|
));
|
|
34
|
-
var __toCommonJS = (mod) => __copyProps(__defProp({}, "__esModule", { value: true }), mod);
|
|
35
34
|
|
|
36
35
|
// package.json
|
|
37
36
|
var require_package = __commonJS({
|
|
38
37
|
"package.json"(exports2, module2) {
|
|
39
38
|
module2.exports = {
|
|
40
39
|
name: "@shi_zhen/code-helper",
|
|
41
|
-
version: "0.1.
|
|
40
|
+
version: "0.1.5",
|
|
42
41
|
description: "Code Helper - A unified tool to manage your Claude Code",
|
|
43
42
|
repository: {
|
|
44
43
|
type: "git",
|
|
@@ -182,8 +181,7 @@ __export(version_exports, {
|
|
|
182
181
|
testUpdate: () => testUpdate
|
|
183
182
|
});
|
|
184
183
|
function getLocalVersion() {
|
|
185
|
-
|
|
186
|
-
return pkg3.version;
|
|
184
|
+
return import_package.default.version;
|
|
187
185
|
}
|
|
188
186
|
async function getRemoteVersion() {
|
|
189
187
|
try {
|
|
@@ -198,10 +196,10 @@ async function getRemoteVersion() {
|
|
|
198
196
|
}
|
|
199
197
|
function readCache() {
|
|
200
198
|
try {
|
|
201
|
-
if (!
|
|
199
|
+
if (!import_fs10.default.existsSync(CACHE_FILE)) {
|
|
202
200
|
return null;
|
|
203
201
|
}
|
|
204
|
-
const content =
|
|
202
|
+
const content = import_fs10.default.readFileSync(CACHE_FILE, "utf-8");
|
|
205
203
|
return JSON.parse(content);
|
|
206
204
|
} catch {
|
|
207
205
|
return null;
|
|
@@ -209,10 +207,10 @@ function readCache() {
|
|
|
209
207
|
}
|
|
210
208
|
function writeCache(data) {
|
|
211
209
|
try {
|
|
212
|
-
if (!
|
|
213
|
-
|
|
210
|
+
if (!import_fs10.default.existsSync(CACHE_DIR)) {
|
|
211
|
+
import_fs10.default.mkdirSync(CACHE_DIR, { recursive: true });
|
|
214
212
|
}
|
|
215
|
-
|
|
213
|
+
import_fs10.default.writeFileSync(CACHE_FILE, JSON.stringify(data, null, 2));
|
|
216
214
|
} catch (error) {
|
|
217
215
|
}
|
|
218
216
|
}
|
|
@@ -312,18 +310,19 @@ async function testUpdate() {
|
|
|
312
310
|
import_chalk3.default.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")
|
|
313
311
|
);
|
|
314
312
|
}
|
|
315
|
-
var import_chalk3, import_ora7,
|
|
313
|
+
var import_chalk3, import_ora7, import_os11, import_path11, import_fs10, import_package, CACHE_DIR, CACHE_FILE, CHECK_INTERVAL;
|
|
316
314
|
var init_version = __esm({
|
|
317
315
|
"src/cli/utils/version.ts"() {
|
|
318
316
|
"use strict";
|
|
319
317
|
import_chalk3 = __toESM(require("chalk"));
|
|
320
318
|
import_ora7 = __toESM(require("ora"));
|
|
319
|
+
import_os11 = __toESM(require("os"));
|
|
320
|
+
import_path11 = __toESM(require("path"));
|
|
321
|
+
import_fs10 = __toESM(require("fs"));
|
|
321
322
|
init_exec();
|
|
322
|
-
|
|
323
|
-
|
|
324
|
-
|
|
325
|
-
CACHE_DIR = path11.join(os11.homedir(), ".code-helper");
|
|
326
|
-
CACHE_FILE = path11.join(CACHE_DIR, "version-check.json");
|
|
323
|
+
import_package = __toESM(require_package());
|
|
324
|
+
CACHE_DIR = import_path11.default.join(import_os11.default.homedir(), ".code-helper");
|
|
325
|
+
CACHE_FILE = import_path11.default.join(CACHE_DIR, "version-check.json");
|
|
327
326
|
CHECK_INTERVAL = 24 * 60 * 60 * 1e3;
|
|
328
327
|
}
|
|
329
328
|
});
|
|
@@ -2443,6 +2442,37 @@ var MarketplaceService = class {
|
|
|
2443
2442
|
this.execClaude(`plugin marketplace add "${market.source}"`);
|
|
2444
2443
|
return true;
|
|
2445
2444
|
} catch (error) {
|
|
2445
|
+
if (error.message.includes("HTTPS authentication failed") || error.message.includes("terminal prompts disabled") || error.message.includes("could not read Username")) {
|
|
2446
|
+
throw new Error(`\u274C \u6DFB\u52A0\u5E02\u573A\u5931\u8D25\uFF1AGit HTTPS \u8BA4\u8BC1\u5931\u8D25
|
|
2447
|
+
|
|
2448
|
+
\u{1F4CB} \u95EE\u9898\u539F\u56E0\uFF1A
|
|
2449
|
+
\u4ED3\u5E93\u9700\u8981 HTTPS \u8BA4\u8BC1\uFF0C\u4F46\u7EC8\u7AEF\u63D0\u793A\u5DF2\u88AB\u7981\u7528
|
|
2450
|
+
|
|
2451
|
+
\u{1F4A1} \u89E3\u51B3\u65B9\u6848\uFF08\u8BF7\u9009\u62E9\u5176\u4E2D\u4E00\u79CD\uFF09\uFF1A
|
|
2452
|
+
|
|
2453
|
+
\u65B9\u6848 1\uFF1A\u914D\u7F6E Git \u51ED\u8BC1\u52A9\u624B\uFF08\u63A8\u8350\uFF09
|
|
2454
|
+
$ git config --global credential.helper store
|
|
2455
|
+
\u7136\u540E\u624B\u52A8\u514B\u9686\u4E00\u6B21\u8BE5\u4ED3\u5E93\uFF0C\u7CFB\u7EDF\u4F1A\u4FDD\u5B58\u51ED\u8BC1\uFF1A
|
|
2456
|
+
$ git clone ${market.source}
|
|
2457
|
+
|
|
2458
|
+
\u65B9\u6848 2\uFF1A\u4F7F\u7528 SSH URL \u683C\u5F0F
|
|
2459
|
+
\u5C06 HTTPS URL:
|
|
2460
|
+
${market.source}
|
|
2461
|
+
|
|
2462
|
+
\u6539\u4E3A SSH \u683C\u5F0F\uFF0C\u4F8B\u5982\uFF1A
|
|
2463
|
+
git@github.com:org/repo.git
|
|
2464
|
+
|
|
2465
|
+
\u65B9\u6848 3\uFF1A\u4F7F\u7528 GitHub CLI\uFF08\u9002\u7528\u4E8E GitHub\uFF09
|
|
2466
|
+
$ gh auth login
|
|
2467
|
+
|
|
2468
|
+
\u65B9\u6848 4\uFF1A\u914D\u7F6E Git \u8BA4\u8BC1\u6587\u4EF6
|
|
2469
|
+
\u5728 ~/.netrc \u6587\u4EF6\u4E2D\u6DFB\u52A0\u8BA4\u8BC1\u4FE1\u606F\uFF1A
|
|
2470
|
+
machine github.com (\u6216\u5176\u4ED6\u57DF\u540D)
|
|
2471
|
+
login your-username
|
|
2472
|
+
password your-token
|
|
2473
|
+
|
|
2474
|
+
\u63D0\u793A\uFF1A\u914D\u7F6E\u5B8C\u6210\u540E\uFF0C\u8BF7\u91CD\u65B0\u8FD0\u884C\u5B89\u88C5\u547D\u4EE4`);
|
|
2475
|
+
}
|
|
2446
2476
|
if (error.message.includes("already exists") || error.message.includes("already configured") || error.message.includes("already installed")) {
|
|
2447
2477
|
return true;
|
|
2448
2478
|
}
|
|
@@ -3280,68 +3310,68 @@ var PERMISSION_RULES = {
|
|
|
3280
3310
|
"Glob(*)",
|
|
3281
3311
|
"Grep(*)",
|
|
3282
3312
|
// Git 常规操作
|
|
3283
|
-
"Bash(git
|
|
3284
|
-
"Bash(git
|
|
3285
|
-
"Bash(git
|
|
3286
|
-
"Bash(git
|
|
3287
|
-
"Bash(git
|
|
3288
|
-
"Bash(git
|
|
3289
|
-
"Bash(git
|
|
3290
|
-
"Bash(git
|
|
3291
|
-
"Bash(git
|
|
3292
|
-
"Bash(git
|
|
3293
|
-
"Bash(git
|
|
3294
|
-
"Bash(git
|
|
3313
|
+
"Bash(git status*)",
|
|
3314
|
+
"Bash(git add*)",
|
|
3315
|
+
"Bash(git commit*)",
|
|
3316
|
+
"Bash(git pull*)",
|
|
3317
|
+
"Bash(git branch*)",
|
|
3318
|
+
"Bash(git checkout*)",
|
|
3319
|
+
"Bash(git diff*)",
|
|
3320
|
+
"Bash(git log*)",
|
|
3321
|
+
"Bash(git clone*)",
|
|
3322
|
+
"Bash(git stash*)",
|
|
3323
|
+
"Bash(git show*)",
|
|
3324
|
+
"Bash(git fetch*)",
|
|
3295
3325
|
// Node/NPM
|
|
3296
|
-
"Bash(node
|
|
3297
|
-
"Bash(npm
|
|
3298
|
-
"Bash(npm
|
|
3299
|
-
"Bash(npm
|
|
3300
|
-
"Bash(npx
|
|
3326
|
+
"Bash(node *)",
|
|
3327
|
+
"Bash(npm run*)",
|
|
3328
|
+
"Bash(npm test*)",
|
|
3329
|
+
"Bash(npm install*)",
|
|
3330
|
+
"Bash(npx *)",
|
|
3301
3331
|
// Python
|
|
3302
|
-
"Bash(python
|
|
3303
|
-
"Bash(python3
|
|
3304
|
-
"Bash(pip
|
|
3305
|
-
"Bash(pip3
|
|
3332
|
+
"Bash(python *)",
|
|
3333
|
+
"Bash(python3 *)",
|
|
3334
|
+
"Bash(pip install*)",
|
|
3335
|
+
"Bash(pip3 install*)",
|
|
3306
3336
|
// 常用工具
|
|
3307
|
-
"Bash(cat
|
|
3308
|
-
"Bash(ls
|
|
3309
|
-
"Bash(grep
|
|
3310
|
-
"Bash(find
|
|
3311
|
-
"Bash(curl
|
|
3312
|
-
"Bash(wget
|
|
3313
|
-
"Bash(echo
|
|
3314
|
-
"Bash(mkdir
|
|
3315
|
-
"Bash(cp
|
|
3316
|
-
"Bash(mv
|
|
3317
|
-
"Bash(touch
|
|
3318
|
-
"Bash(pwd
|
|
3319
|
-
"Bash(cd
|
|
3337
|
+
"Bash(cat *)",
|
|
3338
|
+
"Bash(ls *)",
|
|
3339
|
+
"Bash(grep *)",
|
|
3340
|
+
"Bash(find *)",
|
|
3341
|
+
"Bash(curl *)",
|
|
3342
|
+
"Bash(wget *)",
|
|
3343
|
+
"Bash(echo *)",
|
|
3344
|
+
"Bash(mkdir *)",
|
|
3345
|
+
"Bash(cp *)",
|
|
3346
|
+
"Bash(mv *)",
|
|
3347
|
+
"Bash(touch *)",
|
|
3348
|
+
"Bash(pwd*)",
|
|
3349
|
+
"Bash(cd *)"
|
|
3320
3350
|
],
|
|
3321
3351
|
deny: [
|
|
3322
3352
|
// 高危操作
|
|
3323
|
-
"Bash(rm
|
|
3324
|
-
"Bash(rm
|
|
3325
|
-
"Bash(rm
|
|
3326
|
-
"Bash(sudo
|
|
3327
|
-
"Bash(git
|
|
3328
|
-
"Bash(git
|
|
3329
|
-
"Bash(chmod
|
|
3330
|
-
"Bash(chown
|
|
3353
|
+
"Bash(rm -rf*)",
|
|
3354
|
+
"Bash(rm *-rf*)",
|
|
3355
|
+
"Bash(rm *-r*-f*)",
|
|
3356
|
+
"Bash(sudo *)",
|
|
3357
|
+
"Bash(git push*--force*)",
|
|
3358
|
+
"Bash(git push*-f*)",
|
|
3359
|
+
"Bash(chmod *)",
|
|
3360
|
+
"Bash(chown *)",
|
|
3331
3361
|
// 反黑客操作
|
|
3332
|
-
"Bash(nc
|
|
3362
|
+
"Bash(nc *-e*)",
|
|
3333
3363
|
// 反向 shell
|
|
3334
|
-
"Bash(bash
|
|
3364
|
+
"Bash(bash *-i*)",
|
|
3335
3365
|
// 交互式 bash
|
|
3336
3366
|
"Bash(*>&*)",
|
|
3337
3367
|
// 重定向到网络
|
|
3338
3368
|
"Bash(*base64*-d*)",
|
|
3339
3369
|
// 可疑的 base64 解码
|
|
3340
|
-
"Bash(wget
|
|
3370
|
+
"Bash(wget *&&*)",
|
|
3341
3371
|
// 下载并执行
|
|
3342
|
-
"Bash(curl
|
|
3372
|
+
"Bash(curl *|*sh*)",
|
|
3343
3373
|
// 管道执行
|
|
3344
|
-
"Bash(curl
|
|
3374
|
+
"Bash(curl *|*bash*)"
|
|
3345
3375
|
]
|
|
3346
3376
|
},
|
|
3347
3377
|
// 最大权限配置
|
|
@@ -3354,58 +3384,58 @@ var PERMISSION_RULES = {
|
|
|
3354
3384
|
"Glob(*)",
|
|
3355
3385
|
"Grep(*)",
|
|
3356
3386
|
// Git 所有操作(除了强制推送)
|
|
3357
|
-
"Bash(git
|
|
3387
|
+
"Bash(git *)",
|
|
3358
3388
|
// Node/NPM
|
|
3359
|
-
"Bash(node
|
|
3360
|
-
"Bash(npm
|
|
3361
|
-
"Bash(npx
|
|
3389
|
+
"Bash(node *)",
|
|
3390
|
+
"Bash(npm *)",
|
|
3391
|
+
"Bash(npx *)",
|
|
3362
3392
|
// Python
|
|
3363
|
-
"Bash(python
|
|
3364
|
-
"Bash(python3
|
|
3365
|
-
"Bash(pip
|
|
3366
|
-
"Bash(pip3
|
|
3393
|
+
"Bash(python *)",
|
|
3394
|
+
"Bash(python3 *)",
|
|
3395
|
+
"Bash(pip *)",
|
|
3396
|
+
"Bash(pip3 *)",
|
|
3367
3397
|
// 常用工具
|
|
3368
|
-
"Bash(cat
|
|
3369
|
-
"Bash(ls
|
|
3370
|
-
"Bash(grep
|
|
3371
|
-
"Bash(find
|
|
3372
|
-
"Bash(curl
|
|
3373
|
-
"Bash(wget
|
|
3374
|
-
"Bash(echo
|
|
3375
|
-
"Bash(mkdir
|
|
3376
|
-
"Bash(cp
|
|
3377
|
-
"Bash(mv
|
|
3378
|
-
"Bash(touch
|
|
3379
|
-
"Bash(pwd
|
|
3380
|
-
"Bash(cd
|
|
3398
|
+
"Bash(cat *)",
|
|
3399
|
+
"Bash(ls *)",
|
|
3400
|
+
"Bash(grep *)",
|
|
3401
|
+
"Bash(find *)",
|
|
3402
|
+
"Bash(curl *)",
|
|
3403
|
+
"Bash(wget *)",
|
|
3404
|
+
"Bash(echo *)",
|
|
3405
|
+
"Bash(mkdir *)",
|
|
3406
|
+
"Bash(cp *)",
|
|
3407
|
+
"Bash(mv *)",
|
|
3408
|
+
"Bash(touch *)",
|
|
3409
|
+
"Bash(pwd*)",
|
|
3410
|
+
"Bash(cd *)",
|
|
3381
3411
|
// 额外允许的操作
|
|
3382
|
-
"Bash(rm
|
|
3412
|
+
"Bash(rm *)"
|
|
3383
3413
|
// 允许删除,但不包括 rm -rf
|
|
3384
3414
|
],
|
|
3385
3415
|
deny: [
|
|
3386
3416
|
// 高危操作(需要确认)
|
|
3387
|
-
"Bash(rm
|
|
3388
|
-
"Bash(rm
|
|
3389
|
-
"Bash(rm
|
|
3390
|
-
"Bash(sudo
|
|
3391
|
-
"Bash(git
|
|
3392
|
-
"Bash(git
|
|
3393
|
-
"Bash(dd
|
|
3394
|
-
"Bash(mkfs
|
|
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(dd *)",
|
|
3424
|
+
"Bash(mkfs *)",
|
|
3395
3425
|
// 反黑客操作
|
|
3396
|
-
"Bash(nc
|
|
3426
|
+
"Bash(nc *-e*)",
|
|
3397
3427
|
// 反向 shell
|
|
3398
|
-
"Bash(bash
|
|
3428
|
+
"Bash(bash *-i*)",
|
|
3399
3429
|
// 交互式 bash
|
|
3400
3430
|
"Bash(*>&*)",
|
|
3401
3431
|
// 重定向到网络
|
|
3402
3432
|
"Bash(*base64*-d*)",
|
|
3403
3433
|
// 可疑的 base64 解码
|
|
3404
|
-
"Bash(wget
|
|
3434
|
+
"Bash(wget *&&*)",
|
|
3405
3435
|
// 下载并执行
|
|
3406
|
-
"Bash(curl
|
|
3436
|
+
"Bash(curl *|*sh*)",
|
|
3407
3437
|
// 管道执行
|
|
3408
|
-
"Bash(curl
|
|
3438
|
+
"Bash(curl *|*bash*)"
|
|
3409
3439
|
]
|
|
3410
3440
|
}
|
|
3411
3441
|
};
|
|
@@ -3950,7 +3980,7 @@ async function showMainMenu() {
|
|
|
3950
3980
|
await showPluginsMenu();
|
|
3951
3981
|
break;
|
|
3952
3982
|
case "webui" /* WEBUI */: {
|
|
3953
|
-
const { launchWebUI: launchWebUI2 } = (init_webui(),
|
|
3983
|
+
const { launchWebUI: launchWebUI2 } = await Promise.resolve().then(() => (init_webui(), webui_exports));
|
|
3954
3984
|
await launchWebUI2();
|
|
3955
3985
|
break;
|
|
3956
3986
|
}
|
|
@@ -3963,27 +3993,27 @@ async function showMainMenu() {
|
|
|
3963
3993
|
|
|
3964
3994
|
// src/cli/index.ts
|
|
3965
3995
|
init_version();
|
|
3966
|
-
var
|
|
3996
|
+
var import_package2 = __toESM(require_package());
|
|
3967
3997
|
async function main() {
|
|
3968
3998
|
try {
|
|
3969
3999
|
const args = process.argv.slice(2);
|
|
3970
4000
|
if (args.includes("--version") || args.includes("-v")) {
|
|
3971
|
-
console.log(`v${
|
|
4001
|
+
console.log(`v${import_package2.default.version}`);
|
|
3972
4002
|
process.exit(0);
|
|
3973
4003
|
}
|
|
3974
4004
|
if (args.includes("--test-update")) {
|
|
3975
|
-
const { testUpdate: testUpdate2 } = (init_version(),
|
|
4005
|
+
const { testUpdate: testUpdate2 } = await Promise.resolve().then(() => (init_version(), version_exports));
|
|
3976
4006
|
await testUpdate2();
|
|
3977
4007
|
process.exit(0);
|
|
3978
4008
|
}
|
|
3979
4009
|
if (args.includes("ui")) {
|
|
3980
|
-
const { launchWebUI: launchWebUI2 } = (init_webui(),
|
|
4010
|
+
const { launchWebUI: launchWebUI2 } = await Promise.resolve().then(() => (init_webui(), webui_exports));
|
|
3981
4011
|
await launchWebUI2();
|
|
3982
4012
|
process.exit(0);
|
|
3983
4013
|
}
|
|
3984
4014
|
if (args.includes("--help") || args.includes("-h")) {
|
|
3985
4015
|
console.log(`
|
|
3986
|
-
Code Helper v${
|
|
4016
|
+
Code Helper v${import_package2.default.version}
|
|
3987
4017
|
A unified tool to manage your Claude Code
|
|
3988
4018
|
|
|
3989
4019
|
Usage:
|