siluzan-cso-cli 1.1.14 → 1.1.15

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
@@ -6465,8 +6465,33 @@ function buildMaterialQueryListParams(belongToId, folderId) {
6465
6465
  folderId
6466
6466
  });
6467
6467
  }
6468
+ function mergeFoldersByIdOrder(primary, secondary) {
6469
+ const seen = new Set(primary.map((f) => f.id));
6470
+ const out = [...primary];
6471
+ for (const f of secondary) {
6472
+ if (!seen.has(f.id)) {
6473
+ seen.add(f.id);
6474
+ out.push(f);
6475
+ }
6476
+ }
6477
+ return out;
6478
+ }
6479
+ async function safeQueryMaterialFolderList(csoBaseUrl, config, belongToId, folderId, verbose) {
6480
+ const p = buildMaterialQueryListParams(belongToId, folderId);
6481
+ const url = `${csoBaseUrl}/cutapi/v1/material/querylist?${p.toString()}`;
6482
+ try {
6483
+ const raw = await apiFetch2(url, config, {}, verbose);
6484
+ if (raw.code !== 1) {
6485
+ return { ok: false, reason: raw.message || `\u4E1A\u52A1\u7801 ${raw.code}` };
6486
+ }
6487
+ return { ok: true, folders: raw.data?.folders ?? [] };
6488
+ } catch (e) {
6489
+ return { ok: false, reason: e.message };
6490
+ }
6491
+ }
6468
6492
  async function runRagList(options) {
6469
6493
  const config = loadConfig(options.token);
6494
+ const verbose = Boolean(options.verbose);
6470
6495
  let belongToId = String(options.belongToId ?? "").trim();
6471
6496
  if (!belongToId) {
6472
6497
  const me = await fetchSiluzanCurrentUser(config.apiBaseUrl, config);
@@ -6478,57 +6503,28 @@ async function runRagList(options) {
6478
6503
  );
6479
6504
  process.exit(1);
6480
6505
  }
6481
- const p = buildMaterialQueryListParams(belongToId, RAG_ROOT_FOLDER_ID);
6482
- const url = `${config.csoBaseUrl}/cutapi/v1/material/querylist?${p.toString()}`;
6483
- let raw;
6484
- try {
6485
- raw = await apiFetch2(
6486
- url,
6506
+ const [rootRes, builtinRes] = await Promise.all([
6507
+ safeQueryMaterialFolderList(config.csoBaseUrl, config, belongToId, RAG_ROOT_FOLDER_ID, verbose),
6508
+ safeQueryMaterialFolderList(
6509
+ config.csoBaseUrl,
6487
6510
  config,
6488
- {},
6489
- Boolean(options.verbose)
6490
- );
6491
- } catch (e) {
6511
+ belongToId,
6512
+ RAG_BUILTIN_PARENT_FOLDER_ID,
6513
+ verbose
6514
+ )
6515
+ ]);
6516
+ if (!rootRes.ok) {
6492
6517
  console.error(`
6493
- \u274C \u8BF7\u6C42\u5931\u8D25\uFF1A${e.message}`);
6494
- if (!options.verbose) console.error(" \u52A0 --verbose \u53C2\u6570\u53EF\u67E5\u770B\u8BE6\u7EC6\u9519\u8BEF\u4FE1\u606F");
6518
+ \u274C \u83B7\u53D6\u77E5\u8BC6\u5E93\u5217\u8868\u5931\u8D25\uFF08\u6839\u8282\u70B9\uFF09\uFF1A${rootRes.reason}`);
6519
+ if (!verbose) console.error(" \u52A0 --verbose \u53C2\u6570\u53EF\u67E5\u770B\u8BE6\u7EC6\u9519\u8BEF\u4FE1\u606F");
6495
6520
  process.exit(1);
6496
6521
  }
6497
- if (raw.code !== 1) {
6522
+ let folders = rootRes.folders;
6523
+ if (builtinRes.ok) {
6524
+ folders = mergeFoldersByIdOrder(rootRes.folders, builtinRes.folders);
6525
+ } else if (verbose) {
6498
6526
  console.error(`
6499
- \u274C \u83B7\u53D6\u77E5\u8BC6\u5E93\u5217\u8868\u5931\u8D25\uFF1A${raw.message || `\u4E1A\u52A1\u7801 ${raw.code}`}`);
6500
- process.exit(1);
6501
- }
6502
- let folders = raw.data?.folders ?? [];
6503
- try {
6504
- const pBuiltin = buildMaterialQueryListParams(belongToId, RAG_BUILTIN_PARENT_FOLDER_ID);
6505
- const urlBuiltin = `${config.csoBaseUrl}/cutapi/v1/material/querylist?${pBuiltin.toString()}`;
6506
- const rawBuiltin = await apiFetch2(
6507
- urlBuiltin,
6508
- config,
6509
- {},
6510
- Boolean(options.verbose)
6511
- );
6512
- if (rawBuiltin.code === 1) {
6513
- const extra = rawBuiltin.data?.folders ?? [];
6514
- const seen = new Set(folders.map((f) => f.id));
6515
- for (const f of extra) {
6516
- if (!seen.has(f.id)) {
6517
- seen.add(f.id);
6518
- folders.push(f);
6519
- }
6520
- }
6521
- } else if (options.verbose) {
6522
- console.error(
6523
- `
6524
- \u26A0\uFE0F \u5185\u7F6E\u77E5\u8BC6\u5E93\u5B50\u5217\u8868\u5931\u8D25\uFF1A${rawBuiltin.message || `\u4E1A\u52A1\u7801 ${rawBuiltin.code}`}\uFF08\u5DF2\u8DF3\u8FC7\u5408\u5E76\uFF09`
6525
- );
6526
- }
6527
- } catch (e) {
6528
- if (options.verbose) {
6529
- console.error(`
6530
- \u26A0\uFE0F \u5185\u7F6E\u77E5\u8BC6\u5E93\u5B50\u5217\u8868\u8BF7\u6C42\u5F02\u5E38\uFF1A${e.message}\uFF08\u5DF2\u8DF3\u8FC7\u5408\u5E76\uFF09`);
6531
- }
6527
+ \u26A0\uFE0F \u83B7\u53D6\u77E5\u8BC6\u5E93\u5217\u8868\u5931\u8D25\uFF08\u5185\u7F6E\u7236\u7EA7\uFF09\uFF1A${builtinRes.reason}\uFF08\u5DF2\u4EC5\u7528\u6839\u8282\u70B9\u6570\u636E\u5408\u5E76\u5C55\u793A\uFF09`);
6532
6528
  }
6533
6529
  if (options.ragOnly) {
6534
6530
  folders = folders.filter((f) => f.ragStatus === true);
@@ -1,7 +1,7 @@
1
1
  {
2
2
  "slug": "siluzan-cso",
3
- "version": "1.1.14",
4
- "publishedAt": 1777528215373,
3
+ "version": "1.1.15",
4
+ "publishedAt": 1777536583822,
5
5
  "homepage": "https://www.siluzan.com",
6
6
  "source": "https://dev.azure.com/jack4it/Sammamish/_git/siluzan-skill",
7
7
  "requiredBinaries": [
package/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "siluzan-cso-cli",
3
- "version": "1.1.14",
3
+ "version": "1.1.15",
4
4
  "description": "Siluzan platform AI Skill CLI — multi-platform content publishing (video/image-text) for Cursor, Claude Code, and OpenClaw.",
5
5
  "keywords": [
6
6
  "ai-skill",