@kevisual/cli 0.0.95 → 0.0.96

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/assistant.js CHANGED
@@ -68762,7 +68762,11 @@ var createRandomApp = (opts) => {
68762
68762
  }
68763
68763
  if (!app.key) {
68764
68764
  const randomSuffix = Math.random().toString(36).substring(2, 8);
68765
- app.key = packageJson.basename || `${"unknown-app"}-${randomSuffix}`;
68765
+ let appKey = packageJson.basename || `${"unknown-app"}-${randomSuffix}`;
68766
+ if (appKey.startsWith("/")) {
68767
+ appKey = appKey.slice(1);
68768
+ }
68769
+ app.key = appKey;
68766
68770
  }
68767
68771
  app.path = pwd;
68768
68772
  if (app.type === "pm2-system-app" && !app.pm2Options) {
package/dist/envision.js CHANGED
@@ -22327,8 +22327,8 @@ InitEnv.init();
22327
22327
  var version = useContextKey("version", () => {
22328
22328
  let version2 = "0.0.64";
22329
22329
  try {
22330
- if ("0.0.95")
22331
- version2 = "0.0.95";
22330
+ if ("0.0.96")
22331
+ version2 = "0.0.96";
22332
22332
  } catch (e) {}
22333
22333
  return version2;
22334
22334
  });
@@ -34553,7 +34553,7 @@ aiCmd.addCommand(aiRun);
34553
34553
  aiCmd.addCommand(aiRunDeploy);
34554
34554
  program.addCommand(aiCmd);
34555
34555
 
34556
- // src/command/claude/cc.ts
34556
+ // src/command/coding-plan/cc.ts
34557
34557
  import path14 from "node:path";
34558
34558
  import os4 from "node:os";
34559
34559
  import fs18 from "node:fs";
@@ -34673,6 +34673,90 @@ var command11 = new Command("cc").description("切换claude code模型,支持G
34673
34673
  });
34674
34674
  program.addCommand(command11);
34675
34675
 
34676
+ // src/command/coding-plan/oc.ts
34677
+ import path15 from "node:path";
34678
+ import os5 from "node:os";
34679
+ import fs19 from "node:fs";
34680
+ var readOpencodeConfig = (configPath2) => {
34681
+ if (fs19.existsSync(configPath2)) {
34682
+ const content = fs19.readFileSync(configPath2, "utf-8");
34683
+ try {
34684
+ return JSON.parse(content);
34685
+ } catch {
34686
+ return { provider: {} };
34687
+ }
34688
+ }
34689
+ return { provider: {} };
34690
+ };
34691
+ var saveOpencodeConfig = (configPath2, config2) => {
34692
+ fs19.writeFileSync(configPath2, JSON.stringify(config2, null, 2));
34693
+ };
34694
+ var extractAvailableModels = (config2) => {
34695
+ const models = [];
34696
+ const providers = config2.provider || {};
34697
+ for (const [providerKey, providerConfig] of Object.entries(providers)) {
34698
+ const providerModels = providerConfig.models || {};
34699
+ for (const [modelKey] of Object.entries(providerModels)) {
34700
+ models.push({
34701
+ name: providerConfig.name,
34702
+ provider: providerKey,
34703
+ model: modelKey,
34704
+ label: `${providerKey}/${modelKey}`
34705
+ });
34706
+ }
34707
+ }
34708
+ return models;
34709
+ };
34710
+ var command12 = new Command("oc").description("切换 opencode 模型,从配置的 provider 中选择").option("-m, --model <model:string>", "选择模型 (格式: provider/model)").action(async (options) => {
34711
+ const configPath2 = path15.join(os5.homedir(), ".config", "opencode", "opencode.json");
34712
+ const config2 = readOpencodeConfig(configPath2);
34713
+ const availableModels = extractAvailableModels(config2);
34714
+ if (availableModels.length === 0) {
34715
+ console.log(chalk2.red("没有找到可用的模型配置,请检查 opencode.json 中的 provider 配置"));
34716
+ return;
34717
+ }
34718
+ let selectedModel;
34719
+ if (options.model) {
34720
+ selectedModel = options.model;
34721
+ } else {
34722
+ selectedModel = await dist_default4({
34723
+ message: "请选择模型:",
34724
+ choices: availableModels.map((m) => ({
34725
+ name: `${m.name} - ${m.model}`,
34726
+ value: m.label
34727
+ }))
34728
+ });
34729
+ }
34730
+ const validModel = availableModels.find((m) => m.label === selectedModel);
34731
+ if (!validModel) {
34732
+ console.log(chalk2.red(`无效的模型选择: ${selectedModel}`));
34733
+ return;
34734
+ }
34735
+ config2.model = selectedModel;
34736
+ saveOpencodeConfig(configPath2, config2);
34737
+ console.log(`已切换到模型: ${chalk2.green(selectedModel)}`);
34738
+ console.log(`提供商: ${chalk2.cyan(validModel.name)}`);
34739
+ console.log(`配置已保存到: ${configPath2}`);
34740
+ });
34741
+ var showCommand = new Command("show").description("显示当前 opencode 配置的 model").action(() => {
34742
+ const configPath2 = path15.join(os5.homedir(), ".config", "opencode", "opencode.json");
34743
+ const config2 = readOpencodeConfig(configPath2);
34744
+ if (!config2.model) {
34745
+ console.log(chalk2.yellow("当前没有配置 model"));
34746
+ return;
34747
+ }
34748
+ const availableModels = extractAvailableModels(config2);
34749
+ const currentModel = availableModels.find((m) => m.label === config2.model);
34750
+ console.log(chalk2.bold("当前 opencode 配置:"));
34751
+ console.log(`模型: ${chalk2.green(config2.model)}`);
34752
+ if (currentModel) {
34753
+ console.log(`提供商: ${chalk2.cyan(currentModel.name)}`);
34754
+ }
34755
+ console.log(`配置文件: ${configPath2}`);
34756
+ });
34757
+ command12.addCommand(showCommand);
34758
+ program.addCommand(command12);
34759
+
34676
34760
  // src/command/docker.ts
34677
34761
  import { spawn as spawn4 } from "node:child_process";
34678
34762
  var dockerCommand = new Command("docker").description("Docker 相关指令").action(async () => {
@@ -37350,13 +37434,13 @@ class LRUCache2 {
37350
37434
  }
37351
37435
 
37352
37436
  // src/command/jwks.ts
37353
- import fs19 from "node:fs";
37354
- import path15 from "node:path";
37437
+ import fs20 from "node:fs";
37438
+ import path16 from "node:path";
37355
37439
  var getPath = async (dir) => {
37356
- const JWKS_PATH = path15.join(dir, "jwks.json");
37357
- const PRIVATE_JWK_PATH = path15.join(dir, "privateKey.json");
37358
- const PRIVATE_KEY_PATH = path15.join(dir, "privateKey.txt");
37359
- const PUBLIC_KEY_PATH = path15.join(dir, "publicKey.txt");
37440
+ const JWKS_PATH = path16.join(dir, "jwks.json");
37441
+ const PRIVATE_JWK_PATH = path16.join(dir, "privateKey.json");
37442
+ const PRIVATE_KEY_PATH = path16.join(dir, "privateKey.txt");
37443
+ const PUBLIC_KEY_PATH = path16.join(dir, "publicKey.txt");
37360
37444
  return {
37361
37445
  JWKS_PATH,
37362
37446
  PRIVATE_JWK_PATH,
@@ -37366,39 +37450,39 @@ var getPath = async (dir) => {
37366
37450
  };
37367
37451
  var jwksCmd = new Command("jwks").description("JWKS 相关命令").action(async (opts) => {});
37368
37452
  var jwksGenerate = new Command("generate").alias("gen").option("-d , --dir <dir>", "指定保存目录,默认当前目录下 jwt 文件夹", "jwt").description("生成 JWKS 密钥对").action(async (opts) => {
37369
- const dir = path15.isAbsolute(opts.dir) ? opts.dir : path15.join(process.cwd(), opts.dir);
37370
- if (!fs19.existsSync(dir)) {
37371
- fs19.mkdirSync(dir, { recursive: true });
37453
+ const dir = path16.isAbsolute(opts.dir) ? opts.dir : path16.join(process.cwd(), opts.dir);
37454
+ if (!fs20.existsSync(dir)) {
37455
+ fs20.mkdirSync(dir, { recursive: true });
37372
37456
  }
37373
37457
  const { JWKS_PATH, PRIVATE_JWK_PATH, PRIVATE_KEY_PATH, PUBLIC_KEY_PATH } = await getPath(dir);
37374
37458
  const { jwks, privateJWK, privatePEM, publicPEM } = await generate();
37375
- fs19.writeFileSync(PUBLIC_KEY_PATH, publicPEM);
37376
- fs19.writeFileSync(PRIVATE_KEY_PATH, privatePEM);
37377
- fs19.writeFileSync(PRIVATE_JWK_PATH, JSON.stringify(privateJWK, null, 2));
37378
- fs19.writeFileSync(JWKS_PATH, JSON.stringify(jwks, null, 2));
37459
+ fs20.writeFileSync(PUBLIC_KEY_PATH, publicPEM);
37460
+ fs20.writeFileSync(PRIVATE_KEY_PATH, privatePEM);
37461
+ fs20.writeFileSync(PRIVATE_JWK_PATH, JSON.stringify(privateJWK, null, 2));
37462
+ fs20.writeFileSync(JWKS_PATH, JSON.stringify(jwks, null, 2));
37379
37463
  console.log(`Keys have been saved to directory: ${dir}`);
37380
37464
  });
37381
37465
  jwksCmd.addCommand(jwksGenerate);
37382
37466
  var getJWKS = new Command("get").description("获取 JWKS 内容").option("-d , --dir <dir>", "指定 JWKS 所在目录,默认当前目录下 jwt 文件夹", "jwt").option("-t, --type <type>", "指定获取类型,jwks 或 privateJWK", "jwks").action(async (opts) => {
37383
- const dir = path15.isAbsolute(opts.dir) ? opts.dir : path15.join(process.cwd(), opts.dir);
37467
+ const dir = path16.isAbsolute(opts.dir) ? opts.dir : path16.join(process.cwd(), opts.dir);
37384
37468
  const { JWKS_PATH, PRIVATE_JWK_PATH } = await getPath(dir);
37385
37469
  const type = opts.type || "jwks";
37386
37470
  if (type !== "jwks") {
37387
- if (!fs19.existsSync(PRIVATE_JWK_PATH)) {
37471
+ if (!fs20.existsSync(PRIVATE_JWK_PATH)) {
37388
37472
  console.error(`Private JWK file not found in directory: ${dir}`);
37389
37473
  return;
37390
37474
  }
37391
- const privateJWKContent = fs19.readFileSync(PRIVATE_JWK_PATH, "utf-8");
37475
+ const privateJWKContent = fs20.readFileSync(PRIVATE_JWK_PATH, "utf-8");
37392
37476
  console.log(`Private JWK:
37393
37477
  `);
37394
37478
  console.log(privateJWKContent);
37395
37479
  return;
37396
37480
  }
37397
- if (!fs19.existsSync(JWKS_PATH)) {
37481
+ if (!fs20.existsSync(JWKS_PATH)) {
37398
37482
  console.error(`JWKS file not found in directory: ${dir}`);
37399
37483
  return;
37400
37484
  }
37401
- const jwksContent = fs19.readFileSync(JWKS_PATH, "utf-8");
37485
+ const jwksContent = fs20.readFileSync(JWKS_PATH, "utf-8");
37402
37486
  console.log(`PublicJWKS:
37403
37487
  `);
37404
37488
  console.log(jwksContent);
package/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "@kevisual/cli",
3
- "version": "0.0.95",
3
+ "version": "0.0.96",
4
4
  "description": "envision 命令行工具",
5
5
  "type": "module",
6
6
  "basename": "/root/cli",