dsh-cohub 0.13.5 → 0.13.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.
Files changed (3) hide show
  1. package/README.md +1 -1
  2. package/lib/index.js +420 -28
  3. package/package.json +1 -1
package/README.md CHANGED
@@ -1,6 +1,6 @@
1
1
  # dsh-cohub
2
2
 
3
- > 本文对应 **v0.13.5**;完整变更历史见 [CHANGELOG.md](./CHANGELOG.md)。
3
+ > 本文对应 **v0.13.6**;完整变更历史见 [CHANGELOG.md](./CHANGELOG.md)。
4
4
 
5
5
  DeepSeek Harness 版(对照 [OpenCode 版](../oh-my-opencode-cohub/)):中文智能体编排插件。
6
6
  把「纯调度模式 + 内置技能(代理编排体系 + co-cordis 组合创作 + 写作组)+ 多模型共识 + 运行期调度韧性」移植到 DSH 原生能力之上。
package/lib/index.js CHANGED
@@ -1,7 +1,7 @@
1
1
  // src/index.ts
2
2
  import z2 from "@deepseek-ai/schemastery";
3
- import { readFileSync as readFileSync5 } from "node:fs";
4
- import { fileURLToPath } from "node:url";
3
+ import { readFileSync as readFileSync6 } from "node:fs";
4
+ import { fileURLToPath as fileURLToPath2 } from "node:url";
5
5
  import { dshHomePath as dshHomePath5 } from "@deepseek-ai/dsh-home-paths";
6
6
 
7
7
  // src/preset-install.ts
@@ -431,6 +431,379 @@ function resolveProfilePatchPath(home, env = process.env) {
431
431
  return null;
432
432
  }
433
433
 
434
+ // src/preset-runtime.ts
435
+ import { existsSync as existsSync2, readFileSync as readFileSync2, readdirSync as readdirSync2 } from "node:fs";
436
+ import { join as join2 } from "node:path";
437
+ import { fileURLToPath } from "node:url";
438
+ var COHUB_PRESETS_DIR = fileURLToPath(new URL("../presets/", import.meta.url));
439
+ function unquoteScalar(text) {
440
+ const trimmed = text.trim();
441
+ if (trimmed.length >= 2 && trimmed.startsWith('"') && trimmed.endsWith('"')) {
442
+ try {
443
+ return JSON.parse(trimmed);
444
+ } catch {
445
+ return trimmed.slice(1, -1);
446
+ }
447
+ }
448
+ if (trimmed.length >= 2 && trimmed.startsWith("'") && trimmed.endsWith("'")) {
449
+ return trimmed.slice(1, -1).replace(/''/g, "'");
450
+ }
451
+ return trimmed;
452
+ }
453
+ function stripInlineComment(text) {
454
+ const trimmed = text;
455
+ if (trimmed.startsWith('"') || trimmed.startsWith("'"))
456
+ return trimmed;
457
+ const at = trimmed.search(/\s#/);
458
+ return at < 0 ? trimmed : trimmed.slice(0, at);
459
+ }
460
+ function parseScalar(text) {
461
+ const bare = stripInlineComment(text).trim();
462
+ if (bare === "")
463
+ return null;
464
+ if (bare === "true")
465
+ return true;
466
+ if (bare === "false")
467
+ return false;
468
+ if (bare === "null" || bare === "~")
469
+ return null;
470
+ if (bare.startsWith('"') || bare.startsWith("'"))
471
+ return unquoteScalar(bare);
472
+ if (bare.startsWith("!!js ") || bare === "!!js")
473
+ return bare;
474
+ if (/^-?\d+$/.test(bare))
475
+ return Number(bare);
476
+ if (/^-?\d+\.\d+$/.test(bare))
477
+ return Number(bare);
478
+ return bare;
479
+ }
480
+ function parseMiniYaml(text) {
481
+ const lines = text.replace(/\r\n/g, `
482
+ `).split(`
483
+ `).map((raw) => {
484
+ const trimmedStart = raw.trimStart();
485
+ return { raw, indent: raw.length - trimmedStart.length, content: trimmedStart.trimEnd() };
486
+ });
487
+ let cursor = 0;
488
+ const skipIgnorable = () => {
489
+ while (cursor < lines.length) {
490
+ const line = lines[cursor];
491
+ if (line.content === "" || line.content.startsWith("#"))
492
+ cursor++;
493
+ else
494
+ break;
495
+ }
496
+ };
497
+ const readBlockScalar = (header, parentIndent) => {
498
+ const folded = header.startsWith(">");
499
+ const strip = header.endsWith("-");
500
+ const collected = [];
501
+ const pendingBlank = [];
502
+ let blockIndent = -1;
503
+ while (cursor < lines.length) {
504
+ const line = lines[cursor];
505
+ if (line.content === "") {
506
+ pendingBlank.push("");
507
+ cursor++;
508
+ continue;
509
+ }
510
+ if (line.indent <= parentIndent)
511
+ break;
512
+ if (blockIndent < 0)
513
+ blockIndent = line.indent;
514
+ if (pendingBlank.length > 0) {
515
+ collected.push(...pendingBlank);
516
+ pendingBlank.length = 0;
517
+ }
518
+ collected.push(line.raw.slice(blockIndent));
519
+ cursor++;
520
+ }
521
+ const body = folded ? collected.join(" ") : collected.join(`
522
+ `);
523
+ return strip ? body : body + `
524
+ `;
525
+ };
526
+ const parseMap = (indent) => {
527
+ const out = {};
528
+ for (;; ) {
529
+ skipIgnorable();
530
+ if (cursor >= lines.length)
531
+ break;
532
+ const line = lines[cursor];
533
+ if (line.indent !== indent)
534
+ break;
535
+ if (line.content === "-" || line.content.startsWith("- "))
536
+ break;
537
+ const match = /^([^:#][^:]*?):(?:\s+([\s\S]*))?$/.exec(line.content);
538
+ if (match === null)
539
+ break;
540
+ const key = unquoteScalar(match[1].trim());
541
+ const rest = (match[2] ?? "").trim();
542
+ cursor++;
543
+ if (rest === "") {
544
+ const child = parseBlock(indent + 1);
545
+ out[key] = child;
546
+ continue;
547
+ }
548
+ if (/^[|>][+-]?\d*$/.test(rest)) {
549
+ out[key] = readBlockScalar(rest, indent);
550
+ continue;
551
+ }
552
+ out[key] = parseScalar(rest);
553
+ }
554
+ return out;
555
+ };
556
+ const parseSeq = (indent) => {
557
+ const out = [];
558
+ for (;; ) {
559
+ skipIgnorable();
560
+ if (cursor >= lines.length)
561
+ break;
562
+ const line = lines[cursor];
563
+ if (line.indent !== indent)
564
+ break;
565
+ if (!(line.content === "-" || line.content.startsWith("- ")))
566
+ break;
567
+ const rest = line.content === "-" ? "" : line.content.slice(2).trim();
568
+ if (rest === "") {
569
+ cursor++;
570
+ out.push(parseBlock(indent + 1));
571
+ continue;
572
+ }
573
+ lines[cursor] = { raw: " ".repeat(indent + 2) + rest, indent: indent + 2, content: rest };
574
+ out.push(parseBlock(indent + 1));
575
+ }
576
+ return out;
577
+ };
578
+ const parseBlock = (minIndent) => {
579
+ skipIgnorable();
580
+ if (cursor >= lines.length)
581
+ return null;
582
+ const line = lines[cursor];
583
+ if (line.indent < minIndent)
584
+ return null;
585
+ if (line.content === "-" || line.content.startsWith("- "))
586
+ return parseSeq(line.indent);
587
+ return parseMap(line.indent);
588
+ };
589
+ const root = parseBlock(0);
590
+ return root;
591
+ }
592
+ var JS_TAG_PREFIX = /^!!js\s+([\s\S]+)$/;
593
+ function evaluatePlatformExpr(expr, platform = process.platform) {
594
+ const text = expr.trim();
595
+ const negated = text.startsWith("!") && !text.startsWith("!==");
596
+ const body = negated ? text.replace(/^!+/, "").trim() : text;
597
+ const match = /^process\.platform\s*(===|!==|==|!=)\s*(['"])([\w.-]+)\2$/.exec(body);
598
+ if (match === null)
599
+ return;
600
+ const op = match[1];
601
+ const target = match[3];
602
+ const equal = op === "===" || op === "==";
603
+ const result = equal ? platform === target : platform !== target;
604
+ return negated ? !result : result;
605
+ }
606
+ function materializeJsTags(node, logger, platform = process.platform, path = "plugins") {
607
+ if (typeof node === "string") {
608
+ const match = JS_TAG_PREFIX.exec(node.trim());
609
+ if (match === null)
610
+ return node;
611
+ const value = evaluatePlatformExpr(match[1], platform);
612
+ if (value === undefined) {
613
+ logger?.warn?.(`cohub: 无法求值的 !!js 表达式(原样交给宿主):${path} = ${match[1]}`);
614
+ return node;
615
+ }
616
+ return value;
617
+ }
618
+ if (Array.isArray(node)) {
619
+ for (let i = 0;i < node.length; i++)
620
+ node[i] = materializeJsTags(node[i], logger, platform, `${path}[${i}]`);
621
+ return node;
622
+ }
623
+ if (node !== null && typeof node === "object") {
624
+ const record = node;
625
+ for (const key of Object.keys(record)) {
626
+ record[key] = materializeJsTags(record[key], logger, platform, `${path}.${key}`);
627
+ }
628
+ return record;
629
+ }
630
+ return node;
631
+ }
632
+ function isSafePresetId2(id) {
633
+ return /^[a-z0-9][a-z0-9._-]*$/i.test(id) && !id.includes("..");
634
+ }
635
+ function readPresetMeta2(dir) {
636
+ try {
637
+ const node = parseMiniYaml(readFileSync2(join2(dir, "preset.yml"), "utf8"));
638
+ if (node === null || typeof node !== "object" || Array.isArray(node))
639
+ return {};
640
+ const record = node;
641
+ const name = typeof record.name === "string" ? record.name : undefined;
642
+ const description = typeof record.description === "string" ? record.description : undefined;
643
+ const order = typeof record.order === "number" && Number.isFinite(record.order) ? record.order : undefined;
644
+ return { name, description, order };
645
+ } catch {
646
+ return {};
647
+ }
648
+ }
649
+ function loadCohubPresetDefs(presetsDir = COHUB_PRESETS_DIR, logger) {
650
+ let entries;
651
+ try {
652
+ entries = readdirSync2(presetsDir, { withFileTypes: true });
653
+ } catch (error) {
654
+ logger?.warn?.(`cohub: 读取内置 preset 目录失败(${presetsDir})`, error);
655
+ return [];
656
+ }
657
+ const defs = [];
658
+ for (const entry of entries) {
659
+ if (!entry.isDirectory() || !isSafePresetId2(entry.name))
660
+ continue;
661
+ const dir = join2(presetsDir, entry.name);
662
+ const agentFile = join2(dir, "agent.cordis.yml");
663
+ if (!existsSync2(agentFile))
664
+ continue;
665
+ try {
666
+ const parsed = parseMiniYaml(readFileSync2(agentFile, "utf8"));
667
+ if (!Array.isArray(parsed) || parsed.length === 0) {
668
+ logger?.warn?.(`cohub: preset ${entry.name} 的 agent.cordis.yml 解析结果不是非空数组,已跳过`);
669
+ continue;
670
+ }
671
+ const meta = readPresetMeta2(dir);
672
+ const plugins = materializeJsTags(parsed, logger);
673
+ defs.push({
674
+ id: entry.name,
675
+ name: meta.name ?? entry.name,
676
+ ...meta.description === undefined ? {} : { description: meta.description },
677
+ ...meta.order === undefined ? {} : { order: meta.order },
678
+ plugins
679
+ });
680
+ } catch (error) {
681
+ logger?.warn?.(`cohub: 解析 preset ${entry.name} 失败,已跳过`, error);
682
+ }
683
+ }
684
+ defs.sort((a, b) => (a.order ?? Number.MAX_SAFE_INTEGER) - (b.order ?? Number.MAX_SAFE_INTEGER) || a.id.localeCompare(b.id));
685
+ return defs;
686
+ }
687
+ var handlesByRegistry = new WeakMap;
688
+ function resolveRegistry(ctx) {
689
+ try {
690
+ const fromReflect = ctx?.reflect?.get?.("agentPresets", false);
691
+ if (fromReflect)
692
+ return fromReflect;
693
+ } catch {}
694
+ try {
695
+ return ctx?.agentPresets;
696
+ } catch {
697
+ return;
698
+ }
699
+ }
700
+ function handlesOf(registry) {
701
+ let map = handlesByRegistry.get(registry);
702
+ if (map === undefined) {
703
+ map = new Map;
704
+ handlesByRegistry.set(registry, map);
705
+ }
706
+ return map;
707
+ }
708
+ function isDuplicateError(error) {
709
+ const message = String(error?.message ?? error ?? "");
710
+ return /duplicate/i.test(message);
711
+ }
712
+ function releaseExisting(registry, id) {
713
+ const owned = handlesOf(registry).get(id);
714
+ if (typeof owned === "function") {
715
+ handlesOf(registry).delete(id);
716
+ try {
717
+ owned();
718
+ return true;
719
+ } catch {}
720
+ }
721
+ let existing;
722
+ try {
723
+ existing = typeof registry.get === "function" ? registry.get(id) : undefined;
724
+ } catch {
725
+ existing = undefined;
726
+ }
727
+ if (existing !== undefined && existing !== null) {
728
+ if (typeof existing.unregister === "function") {
729
+ existing.unregister();
730
+ return true;
731
+ }
732
+ if (typeof registry.delete === "function") {
733
+ registry.delete(id);
734
+ return true;
735
+ }
736
+ }
737
+ return false;
738
+ }
739
+ function forceRelease(registry, id) {
740
+ if (releaseExisting(registry, id))
741
+ return true;
742
+ for (const method of ["unregister", "remove", "delete"]) {
743
+ const fn = registry?.[method];
744
+ if (typeof fn !== "function")
745
+ continue;
746
+ try {
747
+ fn.call(registry, id);
748
+ return true;
749
+ } catch {}
750
+ }
751
+ return false;
752
+ }
753
+ async function registerCohubPresets(ctx, logger, presetsDir = COHUB_PRESETS_DIR) {
754
+ const registry = resolveRegistry(ctx);
755
+ const result = { registered: [], failed: [] };
756
+ if (!registry || typeof registry.register !== "function") {
757
+ logger?.info?.("cohub: agentPresets 服务不可用,档位 preset 交由 profile patch 声明(需重启生效)");
758
+ return result;
759
+ }
760
+ const defs = loadCohubPresetDefs(presetsDir, logger);
761
+ for (const def of defs) {
762
+ try {
763
+ releaseExisting(registry, def.id);
764
+ let handle;
765
+ try {
766
+ handle = await registry.register(def);
767
+ } catch (error) {
768
+ if (!isDuplicateError(error) || !forceRelease(registry, def.id))
769
+ throw error;
770
+ handle = await registry.register(def);
771
+ }
772
+ if (typeof handle === "function")
773
+ handlesOf(registry).set(def.id, handle);
774
+ result.registered.push(def.id);
775
+ } catch (error) {
776
+ result.failed.push(def.id);
777
+ logger?.warn?.(`cohub: 运行时注册 preset ${def.id} 失败(将其余档位继续)`, error);
778
+ }
779
+ }
780
+ if (result.registered.length > 0) {
781
+ logger?.info?.(`cohub: 已运行时注册 ${result.registered.length} 个档位 preset(${result.registered.join(", ")}),无需重启`);
782
+ }
783
+ return result;
784
+ }
785
+ function unregisterCohubPresets(ctx, logger) {
786
+ const registry = resolveRegistry(ctx);
787
+ if (!registry || typeof registry !== "object")
788
+ return [];
789
+ const handles = handlesByRegistry.get(registry);
790
+ if (handles === undefined || handles.size === 0)
791
+ return [];
792
+ const removed = [];
793
+ for (const [id, handle] of [...handles.entries()]) {
794
+ handles.delete(id);
795
+ try {
796
+ handle();
797
+ removed.push(id);
798
+ } catch (error) {
799
+ logger?.warn?.(`cohub: 卸载 preset ${id} 失败(忽略)`, error);
800
+ }
801
+ }
802
+ if (removed.length > 0)
803
+ logger?.info?.(`cohub: 已卸载 ${removed.length} 个运行时 preset(${removed.join(", ")})`);
804
+ return removed;
805
+ }
806
+
434
807
  // src/shared/chinese.ts
435
808
  var CHINESE_LANGUAGE_INSTRUCTION = `# 中文语言要求
436
809
 
@@ -1999,7 +2372,7 @@ function contentText(output) {
1999
2372
  import { defineTool } from "@deepseek-ai/dsh-tools";
2000
2373
 
2001
2374
  // src/env-signatures.ts
2002
- import { existsSync as existsSync2, mkdirSync as mkdirSync2, readFileSync as readFileSync2, writeFileSync as writeFileSync2 } from "node:fs";
2375
+ import { existsSync as existsSync3, mkdirSync as mkdirSync2, readFileSync as readFileSync3, writeFileSync as writeFileSync2 } from "node:fs";
2003
2376
  import { createRequire } from "node:module";
2004
2377
  import { dirname as dirname2 } from "node:path";
2005
2378
  import { dshHomePath } from "@deepseek-ai/dsh-home-paths";
@@ -2128,9 +2501,9 @@ function envFingerprint(deps) {
2128
2501
  function readEnvSignatures(path) {
2129
2502
  try {
2130
2503
  const file = path ?? envSignaturesCachePath();
2131
- if (!existsSync2(file))
2504
+ if (!existsSync3(file))
2132
2505
  return null;
2133
- const parsed = JSON.parse(readFileSync2(file, "utf8"));
2506
+ const parsed = JSON.parse(readFileSync3(file, "utf8"));
2134
2507
  if (!parsed || typeof parsed !== "object" || parsed.version !== CACHE_VERSION)
2135
2508
  return null;
2136
2509
  return parsed;
@@ -7176,7 +7549,7 @@ ${r.result}
7176
7549
 
7177
7550
  // src/review-store.ts
7178
7551
  import { createHash as createHash2 } from "node:crypto";
7179
- import { existsSync as existsSync3, mkdirSync as mkdirSync3, readFileSync as readFileSync3, renameSync, writeFileSync as writeFileSync3 } from "node:fs";
7552
+ import { existsSync as existsSync4, mkdirSync as mkdirSync3, readFileSync as readFileSync4, renameSync, writeFileSync as writeFileSync3 } from "node:fs";
7180
7553
  import { dirname as dirname3 } from "node:path";
7181
7554
  import { dshHomePath as dshHomePath2 } from "@deepseek-ai/dsh-home-paths";
7182
7555
  var REVIEW_STATS_VERSION = 1;
@@ -7194,9 +7567,9 @@ function reviewStorePath(cwd, sessionId, fileName = "stats.json") {
7194
7567
  function loadStats(cwd, sessionId) {
7195
7568
  const file = reviewStorePath(cwd, sessionId);
7196
7569
  try {
7197
- if (!existsSync3(file))
7570
+ if (!existsSync4(file))
7198
7571
  return null;
7199
- const text = readFileSync3(file, "utf8");
7572
+ const text = readFileSync4(file, "utf8");
7200
7573
  const parsed = JSON.parse(text);
7201
7574
  if (!parsed || typeof parsed !== "object")
7202
7575
  throw new Error("stats.json 结构不合法");
@@ -7215,7 +7588,7 @@ function loadStats(cwd, sessionId) {
7215
7588
  }
7216
7589
  function isolateCorrupt(file) {
7217
7590
  try {
7218
- if (!existsSync3(file))
7591
+ if (!existsSync4(file))
7219
7592
  return;
7220
7593
  renameSync(file, file + ".corrupt");
7221
7594
  } catch {}
@@ -7230,7 +7603,7 @@ async function saveStats(cwd, sessionId, stats) {
7230
7603
  return true;
7231
7604
  } catch {
7232
7605
  try {
7233
- if (existsSync3(tmp))
7606
+ if (existsSync4(tmp))
7234
7607
  renameSync(tmp, tmp + ".failed");
7235
7608
  } catch {}
7236
7609
  return false;
@@ -7589,7 +7962,7 @@ function createReviewCollector(ctx, opts = {}) {
7589
7962
 
7590
7963
  // src/review-command.ts
7591
7964
  import { createHash as createHash4 } from "node:crypto";
7592
- import { appendFileSync, existsSync as existsSync5, mkdirSync as mkdirSync5, renameSync as renameSync3, writeFileSync as writeFileSync5 } from "node:fs";
7965
+ import { appendFileSync, existsSync as existsSync6, mkdirSync as mkdirSync5, renameSync as renameSync3, writeFileSync as writeFileSync5 } from "node:fs";
7593
7966
  import { dirname as dirname5 } from "node:path";
7594
7967
  import { dshHomePath as dshHomePath4 } from "@deepseek-ai/dsh-home-paths";
7595
7968
 
@@ -8139,26 +8512,26 @@ function renderMarkdown(report, opts = {}) {
8139
8512
  }
8140
8513
 
8141
8514
  // src/review-index.ts
8142
- import { existsSync as existsSync4, mkdirSync as mkdirSync4, readFileSync as readFileSync4, renameSync as renameSync2, writeFileSync as writeFileSync4 } from "node:fs";
8143
- import { basename, dirname as dirname4, join as join2 } from "node:path";
8515
+ import { existsSync as existsSync5, mkdirSync as mkdirSync4, readFileSync as readFileSync5, renameSync as renameSync2, writeFileSync as writeFileSync4 } from "node:fs";
8516
+ import { basename, dirname as dirname4, join as join3 } from "node:path";
8144
8517
  import { dshHomePath as dshHomePath3 } from "@deepseek-ai/dsh-home-paths";
8145
8518
  var REVIEW_INDEX_VERSION = 1;
8146
8519
  function reviewIndexDir() {
8147
8520
  return dshHomePath3("cohub", "reviews");
8148
8521
  }
8149
8522
  function indexPath() {
8150
- return join2(reviewIndexDir(), "index.json");
8523
+ return join3(reviewIndexDir(), "index.json");
8151
8524
  }
8152
8525
  function indexMarkdownPath() {
8153
- return join2(reviewIndexDir(), "INDEX.md");
8526
+ return join3(reviewIndexDir(), "INDEX.md");
8154
8527
  }
8155
8528
  function projectReviewDir(cwd) {
8156
- return join2(cwd, ".cohub", "reviews");
8529
+ return join3(cwd, ".cohub", "reviews");
8157
8530
  }
8158
8531
  function projectCopyPath(cwd, stamp) {
8159
8532
  if (typeof cwd !== "string" || cwd.length === 0)
8160
8533
  return null;
8161
- return join2(projectReviewDir(cwd), "report-" + stamp + ".md");
8534
+ return join3(projectReviewDir(cwd), "report-" + stamp + ".md");
8162
8535
  }
8163
8536
  function writeTextAtomic(file, text) {
8164
8537
  const tmp = file + ".tmp";
@@ -8169,17 +8542,17 @@ function writeTextAtomic(file, text) {
8169
8542
  return true;
8170
8543
  } catch {
8171
8544
  try {
8172
- if (existsSync4(tmp))
8545
+ if (existsSync5(tmp))
8173
8546
  renameSync2(tmp, tmp + ".failed");
8174
8547
  } catch {}
8175
8548
  return false;
8176
8549
  }
8177
8550
  }
8178
8551
  function ensureProjectGitignore(cwd) {
8179
- const file = join2(cwd, ".cohub", ".gitignore");
8552
+ const file = join3(cwd, ".cohub", ".gitignore");
8180
8553
  try {
8181
- if (existsSync4(file)) {
8182
- const text = readFileSync4(file, "utf8");
8554
+ if (existsSync5(file)) {
8555
+ const text = readFileSync5(file, "utf8");
8183
8556
  if (!text.includes("*")) {
8184
8557
  return "已存在 " + file + ' 且内容不含 "*",未覆盖;如需忽略整个 .cohub/ 请手动加入一行 *';
8185
8558
  }
@@ -8219,9 +8592,9 @@ function emptyIndex() {
8219
8592
  function loadIndex() {
8220
8593
  const file = indexPath();
8221
8594
  try {
8222
- if (!existsSync4(file))
8595
+ if (!existsSync5(file))
8223
8596
  return emptyIndex();
8224
- const parsed = JSON.parse(readFileSync4(file, "utf8"));
8597
+ const parsed = JSON.parse(readFileSync5(file, "utf8"));
8225
8598
  if (parsed === null || typeof parsed !== "object" || Array.isArray(parsed))
8226
8599
  throw new Error("index.json 结构不合法");
8227
8600
  if (parsed.version !== REVIEW_INDEX_VERSION)
@@ -8241,7 +8614,7 @@ function loadIndex() {
8241
8614
  }
8242
8615
  function isolateCorrupt2(file) {
8243
8616
  try {
8244
- if (!existsSync4(file))
8617
+ if (!existsSync5(file))
8245
8618
  return;
8246
8619
  renameSync2(file, file + ".corrupt");
8247
8620
  } catch {}
@@ -8522,7 +8895,7 @@ function writeTextAtomic2(file, text) {
8522
8895
  return true;
8523
8896
  } catch {
8524
8897
  try {
8525
- if (existsSync5(tmp))
8898
+ if (existsSync6(tmp))
8526
8899
  renameSync3(tmp, tmp + ".failed");
8527
8900
  } catch {}
8528
8901
  return false;
@@ -9389,10 +9762,10 @@ var CohubSettingsSchema = z2.object({
9389
9762
  resultBudget: ResultBudgetConfig,
9390
9763
  delegateBackground: DelegateBackgroundConfig
9391
9764
  });
9392
- var SHIPPED_PRESETS_DIR = fileURLToPath(new URL("../presets/", import.meta.url));
9765
+ var SHIPPED_PRESETS_DIR = fileURLToPath2(new URL("../presets/", import.meta.url));
9393
9766
  function readPackageVersion() {
9394
9767
  try {
9395
- const pkg = JSON.parse(readFileSync5(fileURLToPath(new URL("../package.json", import.meta.url)), "utf8"));
9768
+ const pkg = JSON.parse(readFileSync6(fileURLToPath2(new URL("../package.json", import.meta.url)), "utf8"));
9396
9769
  return typeof pkg?.version === "string" ? pkg.version : "0.0.0";
9397
9770
  } catch {
9398
9771
  return "0.0.0";
@@ -9441,6 +9814,18 @@ function apply(ctx, config) {
9441
9814
  customRoleSkills.dispose();
9442
9815
  };
9443
9816
  }, "cohub.customRoles()");
9817
+ ctx.effect(() => {
9818
+ registerCohubPresets(ctx, ctx.logger).catch((error) => {
9819
+ ctx.logger?.warn?.("cohub: 运行时注册档位 preset 失败(忽略,回退到 profile patch 声明)", error);
9820
+ });
9821
+ return () => {
9822
+ try {
9823
+ unregisterCohubPresets(ctx, ctx.logger);
9824
+ } catch (error) {
9825
+ ctx.logger?.warn?.("cohub: 卸载运行时 preset 失败(忽略)", error);
9826
+ }
9827
+ };
9828
+ }, "cohub.agentPresets()");
9444
9829
  if (config.installPresets !== false) {
9445
9830
  try {
9446
9831
  const r = installAgentPresets(ctx.logger);
@@ -9528,6 +9913,7 @@ function apply(ctx, config) {
9528
9913
  }
9529
9914
  }
9530
9915
  export {
9916
+ COHUB_PRESETS_DIR,
9531
9917
  CohubSettingsSchema,
9532
9918
  Config,
9533
9919
  CustomRole,
@@ -9539,10 +9925,16 @@ export {
9539
9925
  applyPresetPatchDeclarations,
9540
9926
  buildPresetPatchDeclarations,
9541
9927
  copyTree,
9928
+ evaluatePlatformExpr,
9542
9929
  hashTree,
9543
9930
  inject,
9544
9931
  installShippedPresets,
9932
+ loadCohubPresetDefs,
9933
+ materializeJsTags,
9545
9934
  name,
9935
+ parseMiniYaml,
9936
+ registerCohubPresets,
9546
9937
  removeInstallRecord,
9547
- resolveProfilePatchPath
9938
+ resolveProfilePatchPath,
9939
+ unregisterCohubPresets
9548
9940
  };
package/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "dsh-cohub",
3
- "version": "0.13.5",
3
+ "version": "0.13.6",
4
4
  "description": "DeepSeek Harness 版 CoHub:中文智能体编排——用户可选 2 种工作模式(co-orchestrator 纯调度 / cohub-cordis 创造模式)+ 13 个专职代理技能 + 多模型共识;另由 cohub-subagent-readonly / cohub-subagent-write 两个支撑 preset 实现子代理读写硬隔离(共 4 个 preset)",
5
5
  "type": "module",
6
6
  "main": "lib/index.js",