@cannbot-ai/install-helper 1.1.8-beta.0 → 1.1.9-beta.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/dist/index.js CHANGED
@@ -1,6 +1,12 @@
1
1
  #!/usr/bin/env node
2
2
  var __defProp = Object.defineProperty;
3
3
  var __getOwnPropNames = Object.getOwnPropertyNames;
4
+ var __require = /* @__PURE__ */ ((x) => typeof require !== "undefined" ? require : typeof Proxy !== "undefined" ? new Proxy(x, {
5
+ get: (a, b) => (typeof require !== "undefined" ? require : a)[b]
6
+ }) : x)(function(x) {
7
+ if (typeof require !== "undefined") return require.apply(this, arguments);
8
+ throw Error('Dynamic require of "' + x + '" is not supported');
9
+ });
4
10
  var __esm = (fn, res) => function __init() {
5
11
  return fn && (res = (0, fn[__getOwnPropNames(fn)[0]])(fn = 0)), res;
6
12
  };
@@ -74,6 +80,7 @@ var init_embedded_plugins = __esm({
74
80
  "ascendc-regbase-best-practice",
75
81
  "ascendc-blaze-best-practice",
76
82
  "ascendc-blaze-migration",
83
+ "ascendc-mc2-best-practice",
77
84
  "ops-precision-standard",
78
85
  "ascendc-docs-search",
79
86
  "ascendc-env-check",
@@ -83,8 +90,7 @@ var init_embedded_plugins = __esm({
83
90
  "torch-ascendc-op-extension",
84
91
  "ascendc-runtime-debug",
85
92
  "ascendc-crash-debug",
86
- "ascendc-code-review",
87
- "ascendc-mc2-best-practice"
93
+ "ascendc-code-review"
88
94
  ]
89
95
  },
90
96
  {
@@ -186,6 +192,7 @@ var init_embedded_plugins = __esm({
186
192
  "npu-arch",
187
193
  "ascendc-performance-best-practices",
188
194
  "ascendc-precision-debug",
195
+ "ascendc-perf-optimize",
189
196
  "ascendc-regbase-best-practice",
190
197
  "ascendc-registry-invoke-template",
191
198
  "ascendc-runtime-debug",
@@ -195,9 +202,8 @@ var init_embedded_plugins = __esm({
195
202
  "ascendc-whitebox-design",
196
203
  "ops-precision-standard",
197
204
  "ops-profiling",
198
- "ops-spec-gen",
199
- "ascendc-perf-optimize",
200
- "ops-simulator"
205
+ "ops-simulator",
206
+ "ops-spec-gen"
201
207
  ]
202
208
  },
203
209
  {
@@ -363,21 +369,21 @@ var init_embedded_plugins = __esm({
363
369
  {
364
370
  dir: "ops",
365
371
  skills: [
366
- "pypto-intent-understand",
367
- "pypto-api-explore",
368
- "pypto-op-design",
369
- "pypto-op-develop",
370
- "pypto-precision-debug",
371
- "pypto-precision-compare",
372
- "pypto-op-perf-tune",
373
- "pypto-golden-generate",
374
372
  "pypto-orchestration-manual",
373
+ "pypto-intent-understand",
375
374
  "pypto-op-plan",
375
+ "pypto-api-explore",
376
376
  "pypto-docs-search",
377
+ "pypto-golden-generate",
378
+ "pypto-op-design",
377
379
  "pypto-op-construct",
380
+ "pypto-op-develop",
378
381
  "pypto-op-verify",
379
382
  "pypto-op-review",
383
+ "pypto-precision-compare",
384
+ "pypto-precision-debug",
380
385
  "pypto-general-debug",
386
+ "pypto-op-perf-tune",
381
387
  "pypto-op-knowledge",
382
388
  "pypto-memory-template"
383
389
  ]
@@ -469,8 +475,8 @@ var init_embedded_plugins = __esm({
469
475
  "triton-op-coding",
470
476
  "triton-op-verifier",
471
477
  "triton-latency-optimizer",
472
- "npu-arch",
473
478
  "triton-precision-debug",
479
+ "npu-arch",
474
480
  "triton-simulator-optimizer"
475
481
  ]
476
482
  }
@@ -2444,7 +2450,7 @@ init_registry();
2444
2450
 
2445
2451
  // src/core/metadata-sync.ts
2446
2452
  init_registry();
2447
- import { existsSync as existsSync9, readFileSync as readFileSync5, statSync as statSync2 } from "fs";
2453
+ import { existsSync as existsSync9, readFileSync as readFileSync5, statSync as statSync2, readdirSync as readdirSync3 } from "fs";
2448
2454
  import { join as join8 } from "path";
2449
2455
  function readPluginJson(pluginDir) {
2450
2456
  const pjPath = join8(pluginDir, ".claude-plugin", "plugin.json");
@@ -2489,7 +2495,56 @@ function collectDeclaredSkillNames(installSkills2) {
2489
2495
  }
2490
2496
  function resolveAgentsFromPluginJson(pj) {
2491
2497
  if (!pj || !Array.isArray(pj.agents)) return [];
2492
- return pj.agents.map((a) => a.replace(/^\.\/agents\//, "").replace(/\.md$/, "")).filter(Boolean);
2498
+ return pj.agents.filter((a) => a.startsWith("./agents/")).map((a) => a.replace(/^\.\/agents\//, "").replace(/\.md$/, "")).filter(Boolean);
2499
+ }
2500
+ function parseIncludedAgentPattern(initShPath) {
2501
+ try {
2502
+ const text = readFileSync5(initShPath, "utf-8");
2503
+ const m = text.match(/INCLUDED_AGENT_PATTERN="([^"]*)"/);
2504
+ if (!m) return null;
2505
+ return m[1].trim() || null;
2506
+ } catch {
2507
+ return null;
2508
+ }
2509
+ }
2510
+ function simpleGlobToRegExp(pattern) {
2511
+ let re = "^";
2512
+ for (let i = 0; i < pattern.length; i++) {
2513
+ const c = pattern[i];
2514
+ if (c === "*") re += ".*";
2515
+ else if (c === "?") re += ".";
2516
+ else re += c.replace(/[.+^${}()|[\]\\]/g, "\\$&");
2517
+ }
2518
+ return new RegExp(re + "$");
2519
+ }
2520
+ function matchAgentsByPattern(agentsDir, pattern) {
2521
+ const filePattern = pattern.endsWith(".md") ? pattern : pattern + ".md";
2522
+ try {
2523
+ const fsSync = __require("fs");
2524
+ if (typeof fsSync.globSync === "function") {
2525
+ return fsSync.globSync(filePattern, { cwd: agentsDir }).map((f) => f.replace(/\.md$/, "").replace(/\\/g, "/"));
2526
+ }
2527
+ } catch {
2528
+ }
2529
+ if (filePattern.includes("@(") || filePattern.includes("+(") || filePattern.includes("!(")) {
2530
+ return [];
2531
+ }
2532
+ try {
2533
+ const re = simpleGlobToRegExp(filePattern);
2534
+ return readdirSync3(agentsDir).filter((f) => f.endsWith(".md") && re.test(f)).map((f) => f.replace(/\.md$/, ""));
2535
+ } catch {
2536
+ return [];
2537
+ }
2538
+ }
2539
+ function discoverAgents(pluginDir, pj, initShPath) {
2540
+ const fromPj = resolveAgentsFromPluginJson(pj);
2541
+ if (fromPj.length > 0) return fromPj;
2542
+ if (pj && Array.isArray(pj.agents) && pj.agents.length === 0) return [];
2543
+ const pattern = parseIncludedAgentPattern(initShPath);
2544
+ if (!pattern) return [];
2545
+ const agentsDir = join8(pluginDir, "agents");
2546
+ if (!existsSync9(agentsDir)) return [];
2547
+ return matchAgentsByPattern(agentsDir, pattern);
2493
2548
  }
2494
2549
  function countSkills(installSkills2) {
2495
2550
  if (!installSkills2) return 0;
@@ -2532,7 +2587,8 @@ function enrichPluginMetadata(repoPath) {
2532
2587
  if (pj && pj.name && plugin.displayName === plugin.id) {
2533
2588
  plugin.displayName = pj.name;
2534
2589
  }
2535
- plugin.installAgents = resolveAgentsFromPluginJson(pj);
2590
+ const initShPath = join8(pluginDir, "init.sh");
2591
+ plugin.installAgents = discoverAgents(pluginDir, pj, initShPath);
2536
2592
  const merged = mergeInitSkills(plugin.installSkills, pluginDir, repoPath, scanDirs);
2537
2593
  plugin.installSkills = merged;
2538
2594
  plugin.skills = countSkills(merged);
@@ -2676,7 +2732,7 @@ init_fs();
2676
2732
  init_fs_helpers();
2677
2733
  init_logger();
2678
2734
  init_i18n();
2679
- import { existsSync as existsSync11, mkdirSync as mkdirSync4, readFileSync as readFileSync7, unlinkSync as unlinkSync3, readdirSync as readdirSync3 } from "fs";
2735
+ import { existsSync as existsSync11, mkdirSync as mkdirSync4, readFileSync as readFileSync7, unlinkSync as unlinkSync3, readdirSync as readdirSync4 } from "fs";
2680
2736
  import { join as join10 } from "path";
2681
2737
  function getInstallsDir() {
2682
2738
  return join10(getCannbotConfigDir(), "installs");
@@ -2876,7 +2932,7 @@ function getInstalledSkills(tool, level, installPath, allowFsScan = true) {
2876
2932
  const fromFs = [];
2877
2933
  if (existsSync11(skillsDir)) {
2878
2934
  try {
2879
- const entries = readdirSync3(skillsDir);
2935
+ const entries = readdirSync4(skillsDir);
2880
2936
  for (const entry of entries) {
2881
2937
  if (entry === "." || entry === "..") continue;
2882
2938
  const entryPath = join10(skillsDir, entry);
@@ -2906,7 +2962,7 @@ function getLastBatchSkills(tool, level, installPath) {
2906
2962
 
2907
2963
  // src/core/backup.ts
2908
2964
  init_manifest();
2909
- import { existsSync as existsSync12, copyFileSync, readdirSync as readdirSync4, unlinkSync as unlinkSync4 } from "fs";
2965
+ import { existsSync as existsSync12, copyFileSync, readdirSync as readdirSync5, unlinkSync as unlinkSync4 } from "fs";
2910
2966
  import { join as join11 } from "path";
2911
2967
  init_registry();
2912
2968
  init_paths();
@@ -2971,7 +3027,7 @@ function findBackups(configRoot) {
2971
3027
  if (!existsSync12(configRoot)) {
2972
3028
  return [];
2973
3029
  }
2974
- const files = readdirSync4(configRoot);
3030
+ const files = readdirSync5(configRoot);
2975
3031
  const backups = [];
2976
3032
  for (const file of files) {
2977
3033
  if (file.includes(".cannbot-backup.")) {
@@ -3168,7 +3224,6 @@ async function installExternalRepos(repos, repoPath, configRoot, installPath, le
3168
3224
  await execa3("git", ["pull", "--quiet"], { cwd: targetDir, timeout: 12e4 });
3169
3225
  } catch {
3170
3226
  logger.warn(t("external_repo_update_failed").replace("{dir}", repo.dir));
3171
- continue;
3172
3227
  }
3173
3228
  } else if (!existsSync13(targetDir)) {
3174
3229
  const args = ["clone"];
@@ -3569,7 +3624,7 @@ init_fs_helpers();
3569
3624
  init_constants();
3570
3625
  init_logger();
3571
3626
  init_i18n();
3572
- import { existsSync as existsSync15, mkdirSync as mkdirSync6, symlinkSync as symlinkSync2, readdirSync as readdirSync5, rmSync as rmSync4, realpathSync as realpathSync2, readlinkSync as readlinkSync2, cpSync as cpSync2 } from "fs";
3627
+ import { existsSync as existsSync15, mkdirSync as mkdirSync6, symlinkSync as symlinkSync2, readdirSync as readdirSync6, rmSync as rmSync4, realpathSync as realpathSync2, readlinkSync as readlinkSync2, cpSync as cpSync2 } from "fs";
3573
3628
  import { join as join14, dirname as dirname5, isAbsolute } from "path";
3574
3629
  import { select as select3, checkbox, Separator as Separator2 } from "@inquirer/prompts";
3575
3630
  import chalk5 from "chalk";
@@ -3669,7 +3724,7 @@ async function uninstallSkills(skillIds, tool, level) {
3669
3724
  }
3670
3725
  if (existsSync15(skillsDir)) {
3671
3726
  try {
3672
- const entries = readdirSync5(skillsDir);
3727
+ const entries = readdirSync6(skillsDir);
3673
3728
  if (entries.length === 0) {
3674
3729
  rmSync4(skillsDir, { recursive: true });
3675
3730
  logger.step(` ${t("uninstall_clean_empty_dir")}: skills/`);
@@ -4432,7 +4487,7 @@ init_manifest();
4432
4487
  init_paths();
4433
4488
  init_i18n();
4434
4489
  import chalk8 from "chalk";
4435
- import { existsSync as existsSync17, readdirSync as readdirSync6, lstatSync as lstatSync2, unlinkSync as unlinkSync5, mkdirSync as mkdirSync7 } from "fs";
4490
+ import { existsSync as existsSync17, readdirSync as readdirSync7, lstatSync as lstatSync2, unlinkSync as unlinkSync5, mkdirSync as mkdirSync7 } from "fs";
4436
4491
  import { join as join16 } from "path";
4437
4492
  async function doctorCommand(options = {}) {
4438
4493
  console.log();
@@ -4491,7 +4546,7 @@ async function doctorCommand(options = {}) {
4491
4546
  if (existsSync17(skillsDir)) {
4492
4547
  const brokenLinks = checkBrokenLinks(skillsDir);
4493
4548
  if (brokenLinks === 0) {
4494
- const count = readdirSync6(skillsDir).length;
4549
+ const count = readdirSync7(skillsDir).length;
4495
4550
  console.log(chalk8.green(" \u2713") + ` ${skillsDir} \u2014 ${t("doctor_links_valid").replace("{count}", String(count))}`);
4496
4551
  } else {
4497
4552
  console.log(chalk8.yellow(" \u26A0") + ` ${skillsDir} \u2014 ${t("doctor_broken_links").replace("{count}", String(brokenLinks))}`);
@@ -4513,7 +4568,7 @@ async function doctorCommand(options = {}) {
4513
4568
  if (existsSync17(agentsDir)) {
4514
4569
  const brokenLinks = checkBrokenLinks(agentsDir);
4515
4570
  if (brokenLinks === 0) {
4516
- const count = readdirSync6(agentsDir).length;
4571
+ const count = readdirSync7(agentsDir).length;
4517
4572
  console.log(chalk8.green(" \u2713") + ` ${agentsDir} \u2014 ${t("doctor_links_valid").replace("{count}", String(count))}`);
4518
4573
  } else {
4519
4574
  console.log(chalk8.yellow(" \u26A0") + ` ${agentsDir} \u2014 ${t("doctor_broken_links").replace("{count}", String(brokenLinks))}`);
@@ -4560,7 +4615,7 @@ async function doctorCommand(options = {}) {
4560
4615
  function checkBrokenLinks(dir) {
4561
4616
  let broken = 0;
4562
4617
  try {
4563
- const entries = readdirSync6(dir);
4618
+ const entries = readdirSync7(dir);
4564
4619
  for (const entry of entries) {
4565
4620
  const fullPath = join16(dir, entry);
4566
4621
  try {
@@ -4581,7 +4636,7 @@ function checkBrokenLinks(dir) {
4581
4636
  function fixBrokenLinks(dir) {
4582
4637
  let fixed = 0;
4583
4638
  try {
4584
- const entries = readdirSync6(dir);
4639
+ const entries = readdirSync7(dir);
4585
4640
  for (const entry of entries) {
4586
4641
  const fullPath = join16(dir, entry);
4587
4642
  try {
@@ -4968,7 +5023,7 @@ async function installPlugins(pluginIds, tool, level, repoPath, installPath, yes
4968
5023
 
4969
5024
  // src/commands/uninstall.ts
4970
5025
  init_registry();
4971
- import { existsSync as existsSync18, unlinkSync as unlinkSync6, rmdirSync, readdirSync as readdirSync7, readFileSync as readFileSync9 } from "fs";
5026
+ import { existsSync as existsSync18, unlinkSync as unlinkSync6, rmdirSync, readdirSync as readdirSync8, readFileSync as readFileSync9 } from "fs";
4972
5027
  import { resolve, basename as basename3, sep, join as join18 } from "path";
4973
5028
  import chalk11 from "chalk";
4974
5029
  import { select as select5, checkbox as checkbox2, Separator as Separator4, confirm as confirm3 } from "@inquirer/prompts";
@@ -5321,7 +5376,7 @@ async function uninstallPluginById(pluginId, batchMode) {
5321
5376
  continue;
5322
5377
  }
5323
5378
  if (existsSync18(dirPath)) {
5324
- const entries = readdirSync7(dirPath);
5379
+ const entries = readdirSync8(dirPath);
5325
5380
  if (entries.length === 0) {
5326
5381
  rmdirSync(dirPath);
5327
5382
  const name = basename3(dirPath);
@@ -5482,7 +5537,7 @@ async function updateCommand(pluginNames, options) {
5482
5537
  // src/commands/info.ts
5483
5538
  init_registry();
5484
5539
  import chalk13 from "chalk";
5485
- import { existsSync as existsSync19, readdirSync as readdirSync8 } from "fs";
5540
+ import { existsSync as existsSync19, readdirSync as readdirSync9 } from "fs";
5486
5541
  import { join as join19 } from "path";
5487
5542
  init_manifest();
5488
5543
  init_i18n();
@@ -5516,7 +5571,7 @@ async function infoCommand(pluginName) {
5516
5571
  }
5517
5572
  const agentsDir = join19(repoPath, plugin.dir, "agents");
5518
5573
  if (existsSync19(agentsDir)) {
5519
- const agentFiles = readdirSync8(agentsDir).filter((f) => f.endsWith(".md"));
5574
+ const agentFiles = readdirSync9(agentsDir).filter((f) => f.endsWith(".md"));
5520
5575
  if (agentFiles.length > 0) {
5521
5576
  console.log();
5522
5577
  console.log(` ${chalk13.bold("Agents:")}`);