dsh-cohub 0.13.13 → 0.13.14
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/README.md +1 -1
- package/lib/index.js +82 -13
- package/package.json +1 -1
package/README.md
CHANGED
|
@@ -1,6 +1,6 @@
|
|
|
1
1
|
# dsh-cohub
|
|
2
2
|
|
|
3
|
-
> 本文对应 **v0.13.
|
|
3
|
+
> 本文对应 **v0.13.14**;完整变更历史见 [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
|
@@ -433,7 +433,7 @@ function resolveProfilePatchPath(home, env = process.env) {
|
|
|
433
433
|
|
|
434
434
|
// src/preset-runtime.ts
|
|
435
435
|
import { existsSync as existsSync2, readFileSync as readFileSync2, readdirSync as readdirSync2 } from "node:fs";
|
|
436
|
-
import { join as join2 } from "node:path";
|
|
436
|
+
import { join as join2, resolve, sep } from "node:path";
|
|
437
437
|
import { fileURLToPath } from "node:url";
|
|
438
438
|
var COHUB_PRESETS_DIR = fileURLToPath(new URL("../presets/", import.meta.url));
|
|
439
439
|
function unquoteScalar(text) {
|
|
@@ -570,6 +570,11 @@ function parseMiniYaml(text) {
|
|
|
570
570
|
out.push(parseBlock(indent + 1));
|
|
571
571
|
continue;
|
|
572
572
|
}
|
|
573
|
+
if (/^!!js(\s|$)/.test(rest)) {
|
|
574
|
+
cursor++;
|
|
575
|
+
out.push(parseScalar(rest));
|
|
576
|
+
continue;
|
|
577
|
+
}
|
|
573
578
|
lines[cursor] = { raw: " ".repeat(indent + 2) + rest, indent: indent + 2, content: rest };
|
|
574
579
|
out.push(parseBlock(indent + 1));
|
|
575
580
|
}
|
|
@@ -590,6 +595,8 @@ function parseMiniYaml(text) {
|
|
|
590
595
|
return root;
|
|
591
596
|
}
|
|
592
597
|
var JS_TAG_PREFIX = /^!!js\s+([\s\S]+)$/;
|
|
598
|
+
var URL_DIR_EXPR = /^(?:process\s*\.\s*getBuiltinModule\(\s*(['"])node:url\1\s*\)\s*\.\s*)?fileURLToPath\(\s*new\s+URL\(\s*(['"])([^'"]*)\2\s*,\s*baseUrl\s*\)\s*\)$/;
|
|
599
|
+
var DROP_JS_TAG = Symbol("cohub.dropJsTag");
|
|
593
600
|
function evaluatePlatformExpr(expr, platform = process.platform) {
|
|
594
601
|
const text = expr.trim();
|
|
595
602
|
const negated = text.startsWith("!") && !text.startsWith("!==");
|
|
@@ -603,27 +610,85 @@ function evaluatePlatformExpr(expr, platform = process.platform) {
|
|
|
603
610
|
const result = equal ? platform === target : platform !== target;
|
|
604
611
|
return negated ? !result : result;
|
|
605
612
|
}
|
|
606
|
-
function
|
|
613
|
+
function evaluateUrlDirExpr(expr, baseDir) {
|
|
614
|
+
const match = URL_DIR_EXPR.exec(unquoteScalar(expr.trim()));
|
|
615
|
+
if (match === null)
|
|
616
|
+
return;
|
|
617
|
+
const relative = match[3];
|
|
618
|
+
if (relative === "" || relative.startsWith("/") || relative.startsWith("\\") || /^[a-zA-Z]:/.test(relative))
|
|
619
|
+
return;
|
|
620
|
+
const root = resolve(baseDir);
|
|
621
|
+
const target = resolve(root, relative);
|
|
622
|
+
const prefix = root.endsWith(sep) ? root : root + sep;
|
|
623
|
+
if (target !== root && !target.startsWith(prefix))
|
|
624
|
+
return;
|
|
625
|
+
return target;
|
|
626
|
+
}
|
|
627
|
+
function assertCustomSkillDirs(plugins, logger) {
|
|
628
|
+
for (const line of plugins) {
|
|
629
|
+
if (line === null || typeof line !== "object" || Array.isArray(line))
|
|
630
|
+
continue;
|
|
631
|
+
const record = line;
|
|
632
|
+
if (record.name !== "@deepseek-ai/dsh-skill-filesystem")
|
|
633
|
+
continue;
|
|
634
|
+
const config = record.config;
|
|
635
|
+
if (config === null || typeof config !== "object" || Array.isArray(config))
|
|
636
|
+
continue;
|
|
637
|
+
const cfg = config;
|
|
638
|
+
if (!("customSkillDirs" in cfg))
|
|
639
|
+
continue;
|
|
640
|
+
const dirs = cfg.customSkillDirs;
|
|
641
|
+
if (!Array.isArray(dirs)) {
|
|
642
|
+
logger?.warn?.(`cohub: skill-filesystem.customSkillDirs 不是数组(${typeof dirs}),已丢弃该键`);
|
|
643
|
+
delete cfg.customSkillDirs;
|
|
644
|
+
continue;
|
|
645
|
+
}
|
|
646
|
+
const kept = dirs.filter((entry) => typeof entry === "string");
|
|
647
|
+
if (kept.length !== dirs.length) {
|
|
648
|
+
logger?.warn?.(`cohub: skill-filesystem.customSkillDirs 含 ${dirs.length - kept.length} 个非字符串项,已剔除`);
|
|
649
|
+
cfg.customSkillDirs = kept;
|
|
650
|
+
}
|
|
651
|
+
}
|
|
652
|
+
}
|
|
653
|
+
function materializeJsTags(node, logger, platform = process.platform, path = "plugins", baseDir) {
|
|
607
654
|
if (typeof node === "string") {
|
|
608
655
|
const match = JS_TAG_PREFIX.exec(node.trim());
|
|
609
656
|
if (match === null)
|
|
610
657
|
return node;
|
|
611
|
-
const
|
|
612
|
-
|
|
613
|
-
|
|
614
|
-
|
|
615
|
-
|
|
616
|
-
|
|
658
|
+
const rawExpr = match[1].trim();
|
|
659
|
+
const expr = unquoteScalar(rawExpr);
|
|
660
|
+
const boolValue = evaluatePlatformExpr(expr, platform);
|
|
661
|
+
if (boolValue !== undefined)
|
|
662
|
+
return boolValue;
|
|
663
|
+
if (baseDir !== undefined) {
|
|
664
|
+
const dirValue = evaluateUrlDirExpr(expr, baseDir);
|
|
665
|
+
if (dirValue !== undefined)
|
|
666
|
+
return dirValue;
|
|
667
|
+
}
|
|
668
|
+
logger?.warn?.(`cohub: 无法求值的 !!js 表达式,已丢弃该键以免把非字符串值交给宿主:${path} = ${rawExpr}`);
|
|
669
|
+
return DROP_JS_TAG;
|
|
617
670
|
}
|
|
618
671
|
if (Array.isArray(node)) {
|
|
619
|
-
for (let i = 0;i < node.length; i++)
|
|
620
|
-
|
|
672
|
+
for (let i = 0;i < node.length; i++) {
|
|
673
|
+
const value = materializeJsTags(node[i], logger, platform, `${path}[${i}]`, baseDir);
|
|
674
|
+
if (value === DROP_JS_TAG) {
|
|
675
|
+
node.splice(i, 1);
|
|
676
|
+
i--;
|
|
677
|
+
continue;
|
|
678
|
+
}
|
|
679
|
+
node[i] = value;
|
|
680
|
+
}
|
|
621
681
|
return node;
|
|
622
682
|
}
|
|
623
683
|
if (node !== null && typeof node === "object") {
|
|
624
684
|
const record = node;
|
|
625
685
|
for (const key of Object.keys(record)) {
|
|
626
|
-
|
|
686
|
+
const value = materializeJsTags(record[key], logger, platform, `${path}.${key}`, baseDir);
|
|
687
|
+
if (value === DROP_JS_TAG) {
|
|
688
|
+
delete record[key];
|
|
689
|
+
continue;
|
|
690
|
+
}
|
|
691
|
+
record[key] = value;
|
|
627
692
|
}
|
|
628
693
|
return record;
|
|
629
694
|
}
|
|
@@ -669,7 +734,7 @@ function loadCohubPresetDefs(presetsDir = COHUB_PRESETS_DIR, logger) {
|
|
|
669
734
|
logger?.info?.(`cohub: preset ${entry.name} 由团队注册接管(内置 dev 团队),档位注册跳过`);
|
|
670
735
|
continue;
|
|
671
736
|
}
|
|
672
|
-
const dir =
|
|
737
|
+
const dir = resolve(presetsDir, entry.name);
|
|
673
738
|
const agentFile = join2(dir, "agent.cordis.yml");
|
|
674
739
|
if (!existsSync2(agentFile))
|
|
675
740
|
continue;
|
|
@@ -680,7 +745,8 @@ function loadCohubPresetDefs(presetsDir = COHUB_PRESETS_DIR, logger) {
|
|
|
680
745
|
continue;
|
|
681
746
|
}
|
|
682
747
|
const meta = readPresetMeta2(dir);
|
|
683
|
-
const plugins = materializeJsTags(parsed, logger);
|
|
748
|
+
const plugins = materializeJsTags(parsed, logger, process.platform, "plugins", dir);
|
|
749
|
+
assertCustomSkillDirs(plugins, logger);
|
|
684
750
|
defs.push({
|
|
685
751
|
id: entry.name,
|
|
686
752
|
name: meta.name ?? entry.name,
|
|
@@ -771,6 +837,7 @@ async function registerCohubPresets(ctx, logger, presetsDir = COHUB_PRESETS_DIR)
|
|
|
771
837
|
const defs = loadCohubPresetDefs(presetsDir, logger);
|
|
772
838
|
for (const def of defs) {
|
|
773
839
|
try {
|
|
840
|
+
assertCustomSkillDirs(def.plugins, logger);
|
|
774
841
|
releaseExisting(registry, def.id);
|
|
775
842
|
let handle;
|
|
776
843
|
try {
|
|
@@ -10612,12 +10679,14 @@ export {
|
|
|
10612
10679
|
Team,
|
|
10613
10680
|
apply,
|
|
10614
10681
|
applyPresetPatchDeclarations,
|
|
10682
|
+
assertCustomSkillDirs,
|
|
10615
10683
|
buildPresetPatchDeclarations,
|
|
10616
10684
|
buildTeamPersona,
|
|
10617
10685
|
buildTeamPresetDefs,
|
|
10618
10686
|
buildTeamPresetPlugins,
|
|
10619
10687
|
copyTree,
|
|
10620
10688
|
evaluatePlatformExpr,
|
|
10689
|
+
evaluateUrlDirExpr,
|
|
10621
10690
|
hashTree,
|
|
10622
10691
|
inject,
|
|
10623
10692
|
installShippedPresets,
|
package/package.json
CHANGED
|
@@ -1,6 +1,6 @@
|
|
|
1
1
|
{
|
|
2
2
|
"name": "dsh-cohub",
|
|
3
|
-
"version": "0.13.
|
|
3
|
+
"version": "0.13.14",
|
|
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",
|