@xdxer/dingtalk-agent 0.1.4-beta.8 → 0.1.4-beta.9
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/CHANGELOG.md +35 -0
- package/README.en.md +395 -0
- package/README.md +466 -35
- package/dist/bin/dingtalk-agent.js +1058 -10
- package/dist/bin/dingtalk-agent.js.map +1 -1
- package/dist/src/actions.js +98 -14
- package/dist/src/actions.js.map +1 -1
- package/dist/src/agent-audit.js +460 -0
- package/dist/src/agent-audit.js.map +1 -0
- package/dist/src/agent-bindings.js +132 -0
- package/dist/src/agent-bindings.js.map +1 -0
- package/dist/src/agent-definition.js +182 -0
- package/dist/src/agent-definition.js.map +1 -0
- package/dist/src/agent-enhance.js +678 -0
- package/dist/src/agent-enhance.js.map +1 -0
- package/dist/src/bootstrap.js +125 -17
- package/dist/src/bootstrap.js.map +1 -1
- package/dist/src/development-workspace.js +729 -0
- package/dist/src/development-workspace.js.map +1 -0
- package/dist/src/dws.js +145 -0
- package/dist/src/dws.js.map +1 -1
- package/dist/src/eval-evidence.js +193 -0
- package/dist/src/eval-evidence.js.map +1 -0
- package/dist/src/invocation.js +36 -0
- package/dist/src/invocation.js.map +1 -0
- package/dist/src/lab.js +679 -0
- package/dist/src/lab.js.map +1 -0
- package/dist/src/lease.js +100 -0
- package/dist/src/lease.js.map +1 -0
- package/dist/src/memory/candidates.js +451 -0
- package/dist/src/memory/candidates.js.map +1 -0
- package/dist/src/memory/completion-evidence.js +536 -0
- package/dist/src/memory/completion-evidence.js.map +1 -0
- package/dist/src/memory/operational.js +263 -0
- package/dist/src/memory/operational.js.map +1 -0
- package/dist/src/memory/remote-state.js +478 -0
- package/dist/src/memory/remote-state.js.map +1 -0
- package/dist/src/memory/task-checkpoints.js +204 -0
- package/dist/src/memory/task-checkpoints.js.map +1 -0
- package/dist/src/multica-deploy.js +1480 -0
- package/dist/src/multica-deploy.js.map +1 -0
- package/dist/src/multica-provider.js +685 -0
- package/dist/src/multica-provider.js.map +1 -0
- package/dist/src/opencode-evals.js +1062 -0
- package/dist/src/opencode-evals.js.map +1 -0
- package/dist/src/opencode-provider.js +531 -0
- package/dist/src/opencode-provider.js.map +1 -0
- package/dist/src/opencode-workspace.js +197 -0
- package/dist/src/opencode-workspace.js.map +1 -0
- package/dist/src/perception.js +225 -0
- package/dist/src/perception.js.map +1 -0
- package/dist/src/personal-event-evals.js +595 -0
- package/dist/src/personal-event-evals.js.map +1 -0
- package/dist/src/promotion.js +786 -0
- package/dist/src/promotion.js.map +1 -0
- package/dist/src/remote-semantic-state-live-evals.js +888 -0
- package/dist/src/remote-semantic-state-live-evals.js.map +1 -0
- package/dist/src/remote-semantic-state-worker.js +38 -0
- package/dist/src/remote-semantic-state-worker.js.map +1 -0
- package/dist/src/remote-state-evals.js +501 -0
- package/dist/src/remote-state-evals.js.map +1 -0
- package/dist/src/response-gate.js +51 -0
- package/dist/src/response-gate.js.map +1 -0
- package/dist/src/robot-evals.js +770 -0
- package/dist/src/robot-evals.js.map +1 -0
- package/dist/src/sessions.js +66 -105
- package/dist/src/sessions.js.map +1 -1
- package/dist/src/skill-manager.js +25 -16
- package/dist/src/skill-manager.js.map +1 -1
- package/dist/src/skills.js.map +1 -1
- package/dist/src/storage-evals.js +26 -0
- package/dist/src/storage-evals.js.map +1 -0
- package/dist/src/types.js.map +1 -1
- package/dist/src/waits.js +5 -1
- package/dist/src/waits.js.map +1 -1
- package/dist/src/workspace.js +28 -3
- package/dist/src/workspace.js.map +1 -1
- package/docs/INSTALLATION.md +47 -0
- package/docs/SECOND-AGENT-ACCEPTANCE.md +62 -0
- package/docs/architecture/agent-memory-topology.png +0 -0
- package/docs/architecture/agent-memory-topology.svg +132 -0
- package/docs/architecture/general-agent-kernel-topology.png +0 -0
- package/docs/architecture/general-agent-kernel-topology.svg +149 -0
- package/docs/architecture/provider-bound-development-workspace.png +0 -0
- package/docs/architecture/provider-bound-development-workspace.svg +141 -0
- package/docs/architecture/task-completion-gate.png +0 -0
- package/docs/architecture/task-completion-gate.svg +191 -0
- package/docs/schemas/agent-audit-load-evidence.schema.json +14 -0
- package/docs/schemas/agent-audit.schema.json +92 -0
- package/docs/schemas/agent-bindings.schema.json +54 -0
- package/docs/schemas/agent-definition.schema.json +78 -0
- package/docs/schemas/agent-enhancement-plan.schema.json +88 -0
- package/docs/schemas/agent-enhancement-receipt.schema.json +37 -0
- package/docs/schemas/enriched-invocation.schema.json +46 -0
- package/docs/schemas/eval-candidate-plan.schema.json +28 -0
- package/docs/schemas/eval-candidate-result.schema.json +20 -0
- package/docs/schemas/eval-candidate.schema.json +30 -0
- package/docs/schemas/invocation.schema.json +19 -0
- package/docs/schemas/memory-candidate-proposal.schema.json +18 -0
- package/docs/schemas/memory-candidate.schema.json +76 -0
- package/docs/schemas/memory-publish-target.schema.json +25 -0
- package/docs/schemas/multica-deployment-list.schema.json +29 -0
- package/docs/schemas/multica-deployment-operation.schema.json +51 -0
- package/docs/schemas/multica-deployment-plan.schema.json +70 -0
- package/docs/schemas/multica-deployment-receipt.schema.json +87 -0
- package/docs/schemas/multica-deployment-status.schema.json +23 -0
- package/docs/schemas/multica-workspace-inspection.schema.json +77 -0
- package/docs/schemas/multica-workspace-plan.schema.json +68 -0
- package/docs/schemas/multica-workspace-resource-list.schema.json +27 -0
- package/docs/schemas/multica-workspace-status.schema.json +34 -0
- package/docs/schemas/observation.schema.json +21 -0
- package/docs/schemas/operational-memory-provider.schema.json +36 -0
- package/docs/schemas/operational-memory-record.schema.json +24 -0
- package/docs/schemas/perception-input.schema.json +56 -0
- package/docs/schemas/project.schema.json +112 -0
- package/docs/schemas/promotion-list.schema.json +36 -0
- package/docs/schemas/promotion-plan.schema.json +60 -0
- package/docs/schemas/promotion-policy.schema.json +29 -0
- package/docs/schemas/promotion-receipt.schema.json +43 -0
- package/docs/schemas/promotion-status.schema.json +23 -0
- package/docs/schemas/release-readiness.schema.json +65 -0
- package/docs/schemas/remote-semantic-state-live-eval.schema.json +60 -0
- package/docs/schemas/remote-semantic-state-manifest.schema.json +79 -0
- package/docs/schemas/remote-semantic-state-provider.schema.json +98 -0
- package/docs/schemas/response-gate.schema.json +20 -0
- package/docs/schemas/task-checkpoint.schema.json +71 -0
- package/docs/schemas/task-completion-evidence.schema.json +154 -0
- package/docs/schemas/workspace-doctor.schema.json +56 -0
- package/docs/schemas/workspace-state.schema.json +39 -0
- package/evals/baselines/2026-07-16/opencode-basic-010-completion-summary.json +123 -0
- package/evals/baselines/2026-07-16/opencode-basic-skill-required-summary.json +69 -0
- package/evals/baselines/2026-07-16/opencode-multi-surface-summary.json +63 -0
- package/evals/baselines/2026-07-16/remote-state-live-summary.json +70 -0
- package/evals/baselines/2026-07-17/agent-enhance-opencode-dogfood-summary.json +98 -0
- package/evals/baselines/2026-07-17/personal-event-live-readiness-summary.json +68 -0
- package/examples/agents/fde-coach/AGENTS.md +26 -0
- package/examples/agents/fde-coach/MEMORY.md +3 -0
- package/examples/agents/fde-coach/fields/default/field.json +24 -0
- package/examples/agents/fde-coach/knowledge/INDEX.md +4 -0
- package/examples/agents/fde-coach/skills/fde-coach/SKILL.md +13 -0
- package/examples/agents/release-manager/AGENTS.md +26 -0
- package/examples/agents/release-manager/MEMORY.md +3 -0
- package/examples/agents/release-manager/fields/default/field.json +24 -0
- package/examples/agents/release-manager/knowledge/INDEX.md +4 -0
- package/examples/agents/release-manager/skills/release-manager/SKILL.md +13 -0
- package/lab/README.md +109 -0
- package/lab/agent-eval/catalog.json +91 -0
- package/lab/agent-eval/classic-failures.json +177 -0
- package/lab/agent-eval/completion-gate-regression.json +99 -0
- package/lab/agent-eval/personal-event-live.example.json +94 -0
- package/lab/agent-eval/remote-semantic-state-live.example.json +70 -0
- package/lab/agent-eval/remote-semantic-state-provider.fixture.json +47 -0
- package/lab/agent-eval/remote-state-workspace/AGENTS.md +8 -0
- package/lab/agent-eval/remote-state-workspace/opencode.json +7 -0
- package/lab/agent-eval/remote-state-workspace/skills/remote-state-operator/SKILL.md +13 -0
- package/lab/agent-eval/remote-state.example.json +31 -0
- package/lab/agent-eval/workspace/AGENTS.md +7 -0
- package/lab/agent-eval/workspace/MEMORY.md +4 -0
- package/lab/agent-eval/workspace/artifacts/pending-review.md +3 -0
- package/lab/agent-eval/workspace/knowledge/INDEX.md +4 -0
- package/lab/agent-eval/workspace/opencode.json +20 -0
- package/lab/manifest.example.json +27 -0
- package/lab/manifest.personal-event.example.json +27 -0
- package/lab/project-workspace/README.md +11 -0
- package/lab/project-workspace/fake-multica-provider.mjs +266 -0
- package/lab/project-workspace/multica-deploy.fixture.json +29 -0
- package/lab/project-workspace/multica-readonly.fixture.json +69 -0
- package/lab/project-workspace/observation.fixture.json +14 -0
- package/lab/project-workspace/opencode-provider-suite.json +65 -0
- package/lab/project-workspace/project.fixture.json +44 -0
- package/lab/project-workspace/promotion-policy.fixture.json +15 -0
- package/lab/robot-eval/pool.example.json +30 -0
- package/lab/robot-eval/suite.json +123 -0
- package/lab/robot-eval/workspace/AGENTS.md +21 -0
- package/lab/robot-eval/workspace/MEMORY.md +3 -0
- package/lab/robot-eval/workspace/knowledge/INDEX.md +5 -0
- package/lab/robot-eval/workspace/opencode.json +22 -0
- package/lab/schemas/agent-eval-catalog.schema.json +47 -0
- package/lab/schemas/lab-manifest.schema.json +70 -0
- package/lab/schemas/personal-event-eval.schema.json +91 -0
- package/lab/schemas/remote-state-eval.schema.json +66 -0
- package/lab/schemas/robot-eval-suite.schema.json +184 -0
- package/lab/schemas/robot-pool.schema.json +56 -0
- package/package.json +21 -3
- package/skills/dingtalk-agent-boot-multica/SKILL.md +40 -0
- package/skills/dingtalk-agent-compose/SKILL.md +110 -0
- package/skills/dingtalk-agent-compose/assets/AGENTS.template.md +26 -0
- package/skills/dingtalk-agent-compose/assets/agent.bindings.dingtalk-doc.template.json +13 -0
- package/skills/dingtalk-agent-compose/assets/agent.bindings.local.template.json +13 -0
- package/skills/dingtalk-agent-compose/assets/opencode.template.json +12 -0
- package/skills/dingtalk-agent-compose/assets/role-skill.template.md +24 -0
- package/skills/dingtalk-agent-compose/evals/evals.json +94 -0
- package/skills/dingtalk-agent-compose/references/agent-definition-contract.md +55 -0
- package/skills/dingtalk-agent-compose/references/opencode-host-contract.md +65 -0
- package/skills/dingtalk-agent-compose/references/storage-routing.md +20 -0
- package/skills/dingtalk-agent-deploy/SKILL.md +60 -0
- package/skills/dingtalk-agent-deploy/references/multica-deployment-contract.md +49 -0
- package/skills/dingtalk-agent-deploy/references/promotion-observation-contract.md +49 -0
- package/skills/dingtalk-agent-eval/SKILL.md +116 -0
- package/skills/dingtalk-agent-eval/assets/eval-catalog.template.json +18 -0
- package/skills/dingtalk-agent-eval/evals/evals.json +61 -0
- package/skills/dingtalk-agent-eval/references/eval-topology.md +34 -0
- package/skills/dingtalk-agent-eval/references/evidence-contract.md +31 -0
- package/skills/dingtalk-agent-eval/references/scenario-taxonomy.md +25 -0
- package/skills/dingtalk-agent-eval/references/storage-modes.md +75 -0
- package/skills/dingtalk-basic-behavior/SKILL.md +63 -3
- package/skills/dingtalk-basic-behavior/assets/memory-candidate-proposal.json +10 -0
- package/skills/dingtalk-basic-behavior/assets/{task-checkpoint.md → task-checkpoint.json} +2 -21
- package/skills/dingtalk-basic-behavior/references/action-contract.md +2 -0
- package/skills/dingtalk-basic-behavior/references/memory-and-evolution.md +15 -1
- package/skills/dingtalk-basic-behavior/references/perception-and-gates.md +28 -0
- package/skills/dingtalk-basic-behavior/references/task-lifecycle.md +32 -7
|
@@ -9,8 +9,8 @@
|
|
|
9
9
|
//
|
|
10
10
|
// 因为:文档会被漏读、误读、自我说服;**撞到闸门上就没得商量。**
|
|
11
11
|
import { parseArgs } from 'node:util';
|
|
12
|
-
import { join, resolve } from 'node:path';
|
|
13
|
-
import { readFileSync } from 'node:fs';
|
|
12
|
+
import { join, relative, resolve } from 'node:path';
|
|
13
|
+
import { existsSync, readFileSync, realpathSync } from 'node:fs';
|
|
14
14
|
import { spawn, spawnSync } from 'node:child_process';
|
|
15
15
|
import * as cfgmod from '../src/config.js';
|
|
16
16
|
import { init } from '../src/init.js';
|
|
@@ -19,9 +19,25 @@ import { readEventFile, consumeNdjson, heartbeatEvent } from '../src/driver.js';
|
|
|
19
19
|
import { findRun, previewAction, executeAction } from '../src/actions.js';
|
|
20
20
|
import { resolvePackageRoot } from '../src/package-root.js';
|
|
21
21
|
import { bootstrap } from '../src/bootstrap.js';
|
|
22
|
+
import { loadAgentBindings } from '../src/agent-bindings.js';
|
|
23
|
+
import { auditAgent } from '../src/agent-audit.js';
|
|
24
|
+
import { applyAgentEnhancement, planAgentEnhancement, } from '../src/agent-enhance.js';
|
|
25
|
+
import { doctorLab, runLab, teardownLab, verifyLab } from '../src/lab.js';
|
|
26
|
+
import { runRobotEvaluation } from '../src/robot-evals.js';
|
|
27
|
+
import { runOpenCodeEvaluation } from '../src/opencode-evals.js';
|
|
28
|
+
import { runStorageEvaluation } from '../src/storage-evals.js';
|
|
29
|
+
import { runPersonalEventEvaluation } from '../src/personal-event-evals.js';
|
|
22
30
|
import { doctor } from '../src/doctor.js';
|
|
31
|
+
import { doctorDevelopmentWorkspace, inspectAgentProject, showDevelopmentWorkspace, } from '../src/development-workspace.js';
|
|
32
|
+
import { applyOpenCodeWorkspace, evalOpenCodeWorkspace, planOpenCodeWorkspace, runOpenCodeWorkspace, useOpenCodeWorkspace, } from '../src/opencode-provider.js';
|
|
33
|
+
import { inspectMulticaWorkspace, listMulticaWorkspaceResources, planMulticaWorkspace, statusMulticaWorkspace, } from '../src/multica-provider.js';
|
|
34
|
+
import { applyMulticaDeployment, listMulticaDeployments, planMulticaDeployment, statusMulticaDeployment, } from '../src/multica-deploy.js';
|
|
35
|
+
import { applyObservation, applyPromotion, listPromotions, planObservation, planPromotion, statusPromotion, } from '../src/promotion.js';
|
|
23
36
|
import { setup } from '../src/setup.js';
|
|
24
37
|
import { upgradeAgent } from '../src/upgrade.js';
|
|
38
|
+
import { checkpointTask, showTaskCheckpoint } from '../src/memory/task-checkpoints.js';
|
|
39
|
+
import { upsertOperationalMemory } from '../src/memory/operational.js';
|
|
40
|
+
import { proposeMemoryCandidate, publishMemoryCandidate, reviewMemoryCandidate, showMemoryCandidate, } from '../src/memory/candidates.js';
|
|
25
41
|
import { installGlobalSkill, skillStatus, uninstallGlobalSkill, upgradeGlobalSkill, } from '../src/skill-manager.js';
|
|
26
42
|
const PACKAGE_ROOT = resolvePackageRoot(import.meta.url);
|
|
27
43
|
const PACKAGE_JSON = JSON.parse(readFileSync(join(PACKAGE_ROOT, 'package.json'), 'utf8'));
|
|
@@ -30,6 +46,7 @@ const PACKAGE_JSON = JSON.parse(readFileSync(join(PACKAGE_ROOT, 'package.json'),
|
|
|
30
46
|
const ROOT = process.env.DTA_ROOT
|
|
31
47
|
? resolve(process.env.DTA_ROOT)
|
|
32
48
|
: (cfgmod.findRoot(process.cwd()) || process.cwd());
|
|
49
|
+
const PROJECT_START = process.env.DTA_ROOT ? resolve(process.env.DTA_ROOT) : process.cwd();
|
|
33
50
|
const HELP = `
|
|
34
51
|
dta —— 给 Agent 安装钉钉员工的基础行为和工作环境
|
|
35
52
|
|
|
@@ -41,6 +58,9 @@ dta —— 给 Agent 安装钉钉员工的基础行为和工作环境
|
|
|
41
58
|
开始使用:
|
|
42
59
|
dta setup 首次配置 CLI、DWS 和基础行为 Skill
|
|
43
60
|
dta bootstrap --json 为当前 Agent 会话加载工作区
|
|
61
|
+
dta agent enhance / audit 安全增强已有仓库,再审计定义、存储与 Skill 真加载
|
|
62
|
+
dta info / dta workspace doctor <name> 查看 Project 并只读诊断 Workspace
|
|
63
|
+
dta deploy ... / dta promote ... 预览 Multica 受控部署或已验版本晋级
|
|
44
64
|
|
|
45
65
|
维护环境:
|
|
46
66
|
dta doctor 检查哪里没装好,并给出修复提示
|
|
@@ -53,10 +73,14 @@ const RUNTIME_HELP = `
|
|
|
53
73
|
dingtalk-agent 可信事件运行时(可选宿主能力)
|
|
54
74
|
|
|
55
75
|
init [--context-id X] [--memory <uri>] [--knowledge <uri>]
|
|
56
|
-
prepare --event-file <file|->
|
|
76
|
+
prepare --event-file <file|-> [--perception-file <file>]
|
|
57
77
|
run --stdin | --event-file <file> | --heartbeat
|
|
58
78
|
dispatch pending
|
|
59
79
|
dispatch ack --event-id X --run-id X
|
|
80
|
+
task show --json
|
|
81
|
+
task checkpoint --input checkpoint.json --expect-revision N
|
|
82
|
+
memory operational upsert --provider provider.json --input record.json [--live --yes]
|
|
83
|
+
memory candidate propose|show|review|publish
|
|
60
84
|
act ack|reply|ask|silence
|
|
61
85
|
|
|
62
86
|
这些命令负责目标冻结、Session/Run、Wait、幂等和回执;普通 Agent Session 不必使用。
|
|
@@ -70,6 +94,86 @@ dingtalk-agent 可选 Driver / 开发联调适配器
|
|
|
70
94
|
|
|
71
95
|
listen 不是 Agent 主入口。Claude Code、DWS 云端或其他宿主都可以直接提供事件。
|
|
72
96
|
`;
|
|
97
|
+
const LAB_HELP = `
|
|
98
|
+
dingtalk-agent 真实世界联调控制面
|
|
99
|
+
|
|
100
|
+
lab doctor --manifest lab/manifest.local.json
|
|
101
|
+
lab run --manifest <file> --event-file <file> --case-id <id> [--reply <text>]
|
|
102
|
+
lab verify --evidence <run-dir>
|
|
103
|
+
lab teardown --manifest <file> --evidence <run-dir>
|
|
104
|
+
lab eval --pool <pool.local.json> --suite <suite.json> [--lanes stateless,stateful]
|
|
105
|
+
lab eval --engine opencode --workspace <agent-dir> --suite <suite.json> [--cases id1,id2] [--runs 3] [--previous-skill <dir>]
|
|
106
|
+
lab eval --engine storage --workspace <agent-dir> --suite <remote-state.json> [--execute --live --yes]
|
|
107
|
+
lab eval --engine personal-event --workspace <agent-dir> --suite <suite.json> [--execute --live --yes]
|
|
108
|
+
|
|
109
|
+
mock-integration 还要求 DTA_LAB_FAKE_DWS=1;robot/personal Live 必须显式 --live --yes。
|
|
110
|
+
lab eval 默认只输出计划;Robot Live 用 --live --yes,OpenCode A/B 用 --execute --yes。
|
|
111
|
+
Remote State 用 --execute --yes 读取 DWS/调用模型,再加 --live 才执行唯一写探针。
|
|
112
|
+
OpenCode 对照强制验证每个 Basic Skill 的 load probe;提供 --previous-skill 时运行 current/previous,不连接 DWS。
|
|
113
|
+
Lab 只管理 allowlist、预算、marker、证据和清理;事件触发器仍在外部。
|
|
114
|
+
`;
|
|
115
|
+
const AGENT_HELP = `
|
|
116
|
+
dingtalk-agent 开发者装配验收
|
|
117
|
+
|
|
118
|
+
agent audit [--bindings agent.bindings.json] [--require-skill <name>]
|
|
119
|
+
agent audit [--bindings <file>] [--require-skill <name>] --verify-load --yes
|
|
120
|
+
agent audit [--bindings <file>] --load-report <agent-audit-load-evidence.json> [--remote-report <report.json>]
|
|
121
|
+
agent enhance --role-skill <name>[,<name>] [--project-name <name>] [--dry-run] [--json]
|
|
122
|
+
agent enhance --role-skill <name>[,<name>] --plan-id <current-plan-id> --yes [--json]
|
|
123
|
+
|
|
124
|
+
默认只做本地静态审计,不访问 DWS、不调用模型;状态为 partial 时返回退出码 2。
|
|
125
|
+
--verify-load --yes 会运行隔离的 OpenCode load probe,但仍不访问钉钉。
|
|
126
|
+
远端语义状态由 storage eval 独立验收,再通过 --remote-report 绑定证据。
|
|
127
|
+
`;
|
|
128
|
+
const WORKSPACE_HELP = `
|
|
129
|
+
dingtalk-agent Project / Development Workspace
|
|
130
|
+
|
|
131
|
+
info [--json]
|
|
132
|
+
workspace list [--json]
|
|
133
|
+
workspace show <name> [--json]
|
|
134
|
+
workspace doctor <name> [--json]
|
|
135
|
+
workspace plan <multica-name> [--json]
|
|
136
|
+
workspace inspect <multica-name> [--execute --yes] [--json]
|
|
137
|
+
workspace remote-list <multica-name> [--execute --yes] [--json]
|
|
138
|
+
workspace status <multica-name> [--json]
|
|
139
|
+
workspace create <name> [--dry-run | --yes] [--json]
|
|
140
|
+
workspace use <name> [--json]
|
|
141
|
+
workspace run <name> --prompt-file <file> [--execute --yes] [--json]
|
|
142
|
+
workspace eval <name> --suite <file> [--execute --yes] [--runs N] [--json]
|
|
143
|
+
|
|
144
|
+
命令会从当前目录向上发现 dingtalk-agent.json;旧 workspace@1 只读显示为 legacy-prepared。
|
|
145
|
+
Multica plan/status 默认不调用 Provider;inspect/remote-list 只有 --execute --yes 才读取当前 profile 和远端 scope。
|
|
146
|
+
Multica readback 只保存脱敏事实,不执行 create/update/apply/deploy;OpenCode create 只物化本地环境。
|
|
147
|
+
这些命令都不访问 DWS;Multica 远端写入只通过 dta deploy 的冻结 plan 闸门。
|
|
148
|
+
`;
|
|
149
|
+
const DEPLOY_HELP = `
|
|
150
|
+
dingtalk-agent Multica 受控部署
|
|
151
|
+
|
|
152
|
+
deploy --workspace <name> --dry-run [--json]
|
|
153
|
+
deploy --workspace <name> --plan-id <id> --yes [--no-wait] [--json]
|
|
154
|
+
deploy --workspace <name> --status [--operation-id <id>] [--json]
|
|
155
|
+
deploy --workspace <name> --status --operation-id <id> --execute --yes [--json]
|
|
156
|
+
deploy --workspace <name> --list [--json]
|
|
157
|
+
deploy --workspace <name> --retire --dry-run [--json]
|
|
158
|
+
deploy --workspace <name> --retire --plan-id <id> --yes [--json]
|
|
159
|
+
|
|
160
|
+
dry-run 不启动 Multica。apply/retire 必须携带当前 planId;scope 或源码漂移会在写入前拒绝。
|
|
161
|
+
status 默认只验本地脱敏 operation/Receipt;--execute --yes 才做远端独立回读。
|
|
162
|
+
deploy 只管理 Agent、完整 Skill tree、assignment 和 load smoke,不创建机器人、Webhook、Autopilot 或定时 Trigger。
|
|
163
|
+
`;
|
|
164
|
+
const PROMOTION_HELP = `
|
|
165
|
+
dingtalk-agent 已验版本晋级与反馈候选
|
|
166
|
+
|
|
167
|
+
promote --policy <file> --route <id> --dry-run [--json]
|
|
168
|
+
promote --policy <file> --route <id> --plan-id <id> --yes [--no-wait] [--json]
|
|
169
|
+
promote --status [--promotion-id <id>] [--json]
|
|
170
|
+
promote --list [--json]
|
|
171
|
+
observe --promotion-id <id> --input <observation.json> --dry-run [--json]
|
|
172
|
+
observe --promotion-id <id> --input <observation.json> --yes [--json]
|
|
173
|
+
|
|
174
|
+
Promotion 只接受指定 suite 的 load/hard/surface gate 与精确 W2 evidence hash,并委托 W4 deploy。
|
|
175
|
+
Observe 只写 gitignored、proposed、不可直接发布的 Eval candidate;不修改 AGENTS.md、Prompt、Skill 或 Trigger。
|
|
176
|
+
`;
|
|
73
177
|
function fail(msg, code = 1, hint = '') {
|
|
74
178
|
console.error(`错误: ${msg}`);
|
|
75
179
|
if (hint)
|
|
@@ -96,6 +200,26 @@ async function main() {
|
|
|
96
200
|
console.log(ADAPTER_HELP);
|
|
97
201
|
return;
|
|
98
202
|
}
|
|
203
|
+
if (cmd === 'help' && sub === 'lab') {
|
|
204
|
+
console.log(LAB_HELP);
|
|
205
|
+
return;
|
|
206
|
+
}
|
|
207
|
+
if (cmd === 'help' && sub === 'agent') {
|
|
208
|
+
console.log(AGENT_HELP);
|
|
209
|
+
return;
|
|
210
|
+
}
|
|
211
|
+
if (cmd === 'help' && sub === 'workspace') {
|
|
212
|
+
console.log(WORKSPACE_HELP);
|
|
213
|
+
return;
|
|
214
|
+
}
|
|
215
|
+
if (cmd === 'help' && sub === 'deploy') {
|
|
216
|
+
console.log(DEPLOY_HELP);
|
|
217
|
+
return;
|
|
218
|
+
}
|
|
219
|
+
if (cmd === 'help' && ['promote', 'observe'].includes(sub || '')) {
|
|
220
|
+
console.log(PROMOTION_HELP);
|
|
221
|
+
return;
|
|
222
|
+
}
|
|
99
223
|
if (cmd === 'help' && sub) {
|
|
100
224
|
fail(`不认识的帮助主题: ${sub}`, 1, '运行 dta --help 回到产品入口;事件宿主可用 dta help runtime。');
|
|
101
225
|
}
|
|
@@ -107,6 +231,386 @@ async function main() {
|
|
|
107
231
|
console.log(PACKAGE_JSON.version);
|
|
108
232
|
return;
|
|
109
233
|
}
|
|
234
|
+
if (cmd === 'deploy') {
|
|
235
|
+
const { values: o, positionals } = parseArgs({
|
|
236
|
+
args: argv.slice(1), allowPositionals: true,
|
|
237
|
+
options: {
|
|
238
|
+
workspace: { type: 'string' }, json: { type: 'boolean' },
|
|
239
|
+
'dry-run': { type: 'boolean' }, yes: { type: 'boolean' },
|
|
240
|
+
'plan-id': { type: 'string' }, 'no-wait': { type: 'boolean' },
|
|
241
|
+
status: { type: 'boolean' }, list: { type: 'boolean' },
|
|
242
|
+
execute: { type: 'boolean' }, 'operation-id': { type: 'string' },
|
|
243
|
+
timeout: { type: 'string' }, 'smoke-timeout': { type: 'string' },
|
|
244
|
+
retire: { type: 'boolean' },
|
|
245
|
+
},
|
|
246
|
+
});
|
|
247
|
+
if (positionals.length)
|
|
248
|
+
fail('deploy 不接受位置参数;使用 --workspace <name>');
|
|
249
|
+
if (!o.workspace)
|
|
250
|
+
fail('deploy 必须显式传 --workspace <name>');
|
|
251
|
+
const modes = [
|
|
252
|
+
Boolean(o.status), Boolean(o.list), Boolean(o['dry-run']), Boolean(o.yes && !o.status),
|
|
253
|
+
]
|
|
254
|
+
.filter(Boolean).length;
|
|
255
|
+
if (modes !== 1) {
|
|
256
|
+
fail('deploy 必须且只能选择 --dry-run、--yes、--status 或 --list 之一');
|
|
257
|
+
}
|
|
258
|
+
const timeoutMs = parseOptionalTimeout(o.timeout, '--timeout');
|
|
259
|
+
const smokeTimeoutMs = parseOptionalTimeout(o['smoke-timeout'], '--smoke-timeout');
|
|
260
|
+
let out;
|
|
261
|
+
if (o.list) {
|
|
262
|
+
if (o.execute || o['operation-id'] || o.retire || o['plan-id'] || o['no-wait'] ||
|
|
263
|
+
o.timeout || o['smoke-timeout']) {
|
|
264
|
+
fail('deploy --list 只接受 --workspace 和 --json');
|
|
265
|
+
}
|
|
266
|
+
out = listMulticaDeployments(PROJECT_START, o.workspace, PACKAGE_JSON.version);
|
|
267
|
+
}
|
|
268
|
+
else if (o.status) {
|
|
269
|
+
if (o.retire || o['plan-id'] || o['no-wait'] || o['dry-run'] || o['smoke-timeout']) {
|
|
270
|
+
fail('deploy --status 不接受 retire/plan-id/no-wait/dry-run/smoke-timeout');
|
|
271
|
+
}
|
|
272
|
+
if (Boolean(o.execute) !== Boolean(o.yes)) {
|
|
273
|
+
fail('deploy --status 远端 reconcile 必须同时传 --execute --yes');
|
|
274
|
+
}
|
|
275
|
+
out = statusMulticaDeployment(PROJECT_START, o.workspace, {
|
|
276
|
+
execute: o.execute, yes: o.yes, operationId: o['operation-id'], timeoutMs,
|
|
277
|
+
cliVersion: PACKAGE_JSON.version,
|
|
278
|
+
});
|
|
279
|
+
}
|
|
280
|
+
else if (o['dry-run']) {
|
|
281
|
+
if (o.execute || o['operation-id'] || o['plan-id'] || o['no-wait'] ||
|
|
282
|
+
o.timeout || o['smoke-timeout']) {
|
|
283
|
+
fail('deploy --dry-run 不接受 execute/operation-id/plan-id/no-wait/timeout/smoke-timeout');
|
|
284
|
+
}
|
|
285
|
+
out = planMulticaDeployment(PROJECT_START, o.workspace, {
|
|
286
|
+
action: o.retire ? 'retire' : 'apply', cliVersion: PACKAGE_JSON.version,
|
|
287
|
+
});
|
|
288
|
+
}
|
|
289
|
+
else {
|
|
290
|
+
if (o.execute || o['operation-id'] || o.status || o.list || o['dry-run']) {
|
|
291
|
+
fail('deploy apply 不接受 execute/operation-id/status/list/dry-run');
|
|
292
|
+
}
|
|
293
|
+
if (o.retire && (o['no-wait'] || o['smoke-timeout'])) {
|
|
294
|
+
fail('deploy --retire 不接受 no-wait/smoke-timeout');
|
|
295
|
+
}
|
|
296
|
+
out = applyMulticaDeployment(PROJECT_START, o.workspace, {
|
|
297
|
+
yes: o.yes, planId: o['plan-id'], noWait: o['no-wait'],
|
|
298
|
+
timeoutMs, smokeTimeoutMs, cliVersion: PACKAGE_JSON.version,
|
|
299
|
+
}, o.retire ? 'retire' : 'apply');
|
|
300
|
+
}
|
|
301
|
+
if (o.json)
|
|
302
|
+
console.log(JSON.stringify(out, null, 2));
|
|
303
|
+
else
|
|
304
|
+
printMulticaDeployment(out);
|
|
305
|
+
if ('passed' in out && out.passed === false && out.status !== 'verifying')
|
|
306
|
+
process.exitCode = 2;
|
|
307
|
+
return;
|
|
308
|
+
}
|
|
309
|
+
if (cmd === 'promote') {
|
|
310
|
+
const { values: o, positionals } = parseArgs({
|
|
311
|
+
args: argv.slice(1), allowPositionals: true,
|
|
312
|
+
options: {
|
|
313
|
+
policy: { type: 'string' }, route: { type: 'string' },
|
|
314
|
+
'dry-run': { type: 'boolean' }, yes: { type: 'boolean' }, json: { type: 'boolean' },
|
|
315
|
+
'plan-id': { type: 'string' }, status: { type: 'boolean' }, list: { type: 'boolean' },
|
|
316
|
+
'promotion-id': { type: 'string' }, 'no-wait': { type: 'boolean' },
|
|
317
|
+
timeout: { type: 'string' }, 'smoke-timeout': { type: 'string' },
|
|
318
|
+
},
|
|
319
|
+
});
|
|
320
|
+
if (positionals.length)
|
|
321
|
+
fail('promote 不接受位置参数');
|
|
322
|
+
const modes = [Boolean(o['dry-run']), Boolean(o.yes), Boolean(o.status), Boolean(o.list)]
|
|
323
|
+
.filter(Boolean).length;
|
|
324
|
+
if (modes !== 1)
|
|
325
|
+
fail('promote 必须且只能选择 --dry-run、--yes、--status 或 --list 之一');
|
|
326
|
+
let out;
|
|
327
|
+
if (o.list) {
|
|
328
|
+
if (o.policy || o.route || o['plan-id'] || o['promotion-id'] || o['no-wait'] ||
|
|
329
|
+
o.timeout || o['smoke-timeout'])
|
|
330
|
+
fail('promote --list 只接受 --json');
|
|
331
|
+
out = listPromotions(PROJECT_START);
|
|
332
|
+
}
|
|
333
|
+
else if (o.status) {
|
|
334
|
+
if (o.policy || o.route || o['plan-id'] || o['no-wait'] || o.timeout || o['smoke-timeout']) {
|
|
335
|
+
fail('promote --status 只接受 --promotion-id 和 --json');
|
|
336
|
+
}
|
|
337
|
+
out = statusPromotion(PROJECT_START, o['promotion-id'] || '');
|
|
338
|
+
}
|
|
339
|
+
else {
|
|
340
|
+
if (!o.policy || !o.route)
|
|
341
|
+
fail('promote dry-run/apply 必须传 --policy <file> --route <id>');
|
|
342
|
+
if (o['promotion-id'])
|
|
343
|
+
fail('promote dry-run/apply 不接受 --promotion-id');
|
|
344
|
+
if (o['dry-run']) {
|
|
345
|
+
if (o['plan-id'] || o['no-wait'] || o.timeout || o['smoke-timeout']) {
|
|
346
|
+
fail('promote --dry-run 不接受 plan-id/no-wait/timeout/smoke-timeout');
|
|
347
|
+
}
|
|
348
|
+
out = planPromotion(PROJECT_START, o.policy, o.route, { cliVersion: PACKAGE_JSON.version });
|
|
349
|
+
}
|
|
350
|
+
else {
|
|
351
|
+
out = applyPromotion(PROJECT_START, o.policy, o.route, {
|
|
352
|
+
yes: true, planId: o['plan-id'], noWait: o['no-wait'],
|
|
353
|
+
timeoutMs: parseOptionalTimeout(o.timeout, '--timeout'),
|
|
354
|
+
smokeTimeoutMs: parseOptionalTimeout(o['smoke-timeout'], '--smoke-timeout'),
|
|
355
|
+
cliVersion: PACKAGE_JSON.version,
|
|
356
|
+
});
|
|
357
|
+
}
|
|
358
|
+
}
|
|
359
|
+
if (o.json)
|
|
360
|
+
console.log(JSON.stringify(out, null, 2));
|
|
361
|
+
else
|
|
362
|
+
printPromotion(out);
|
|
363
|
+
if ('passed' in out && out.passed === false && out.status !== 'verifying' && out.status !== 'missing') {
|
|
364
|
+
process.exitCode = 2;
|
|
365
|
+
}
|
|
366
|
+
return;
|
|
367
|
+
}
|
|
368
|
+
if (cmd === 'observe') {
|
|
369
|
+
const { values: o, positionals } = parseArgs({
|
|
370
|
+
args: argv.slice(1), allowPositionals: true,
|
|
371
|
+
options: {
|
|
372
|
+
'promotion-id': { type: 'string' }, input: { type: 'string' },
|
|
373
|
+
'dry-run': { type: 'boolean' }, yes: { type: 'boolean' }, json: { type: 'boolean' },
|
|
374
|
+
},
|
|
375
|
+
});
|
|
376
|
+
if (positionals.length)
|
|
377
|
+
fail('observe 不接受位置参数');
|
|
378
|
+
if (!o['promotion-id'] || !o.input) {
|
|
379
|
+
fail('observe 必须传 --promotion-id <id> --input <observation.json>');
|
|
380
|
+
}
|
|
381
|
+
if (Boolean(o['dry-run']) === Boolean(o.yes)) {
|
|
382
|
+
fail('observe 必须且只能选择 --dry-run 或 --yes');
|
|
383
|
+
}
|
|
384
|
+
const out = o['dry-run']
|
|
385
|
+
? planObservation(PROJECT_START, o['promotion-id'], o.input)
|
|
386
|
+
: applyObservation(PROJECT_START, o['promotion-id'], o.input, { yes: true });
|
|
387
|
+
if (o.json)
|
|
388
|
+
console.log(JSON.stringify(out, null, 2));
|
|
389
|
+
else
|
|
390
|
+
printPromotion(out);
|
|
391
|
+
return;
|
|
392
|
+
}
|
|
393
|
+
// ── Project / Development Workspace:W1 只读发现、状态与 Provider 诊断。──
|
|
394
|
+
if (cmd === 'info') {
|
|
395
|
+
const { values: o } = parseArgs({
|
|
396
|
+
args: argv.slice(1), options: { json: { type: 'boolean' } },
|
|
397
|
+
});
|
|
398
|
+
const out = inspectAgentProject(PROJECT_START, PACKAGE_JSON.version);
|
|
399
|
+
if (o.json)
|
|
400
|
+
console.log(JSON.stringify(out, null, 2));
|
|
401
|
+
else
|
|
402
|
+
printProjectInfo(out);
|
|
403
|
+
return;
|
|
404
|
+
}
|
|
405
|
+
if (cmd === 'workspace') {
|
|
406
|
+
const { values: o, positionals } = parseArgs({
|
|
407
|
+
args: argv.slice(2), allowPositionals: true,
|
|
408
|
+
options: {
|
|
409
|
+
json: { type: 'boolean' }, yes: { type: 'boolean' },
|
|
410
|
+
'dry-run': { type: 'boolean' }, execute: { type: 'boolean' },
|
|
411
|
+
'prompt-file': { type: 'string' }, suite: { type: 'string' },
|
|
412
|
+
cases: { type: 'string' }, lanes: { type: 'string' }, runs: { type: 'string' },
|
|
413
|
+
out: { type: 'string' }, timeout: { type: 'string' },
|
|
414
|
+
'previous-skill': { type: 'string' },
|
|
415
|
+
},
|
|
416
|
+
});
|
|
417
|
+
if (sub === 'list') {
|
|
418
|
+
rejectWorkspaceOptions(o, ['json'], 'workspace list');
|
|
419
|
+
if (positionals.length)
|
|
420
|
+
fail('workspace list 不接受 Workspace name');
|
|
421
|
+
const info = inspectAgentProject(PROJECT_START, PACKAGE_JSON.version);
|
|
422
|
+
const out = {
|
|
423
|
+
$schema: 'dingtalk-agent/workspace-list@1',
|
|
424
|
+
root: info.root,
|
|
425
|
+
currentWorkspace: info.currentWorkspace,
|
|
426
|
+
workspaces: info.workspaces,
|
|
427
|
+
sideEffect: false,
|
|
428
|
+
dingtalkSideEffect: false,
|
|
429
|
+
};
|
|
430
|
+
if (o.json)
|
|
431
|
+
console.log(JSON.stringify(out, null, 2));
|
|
432
|
+
else
|
|
433
|
+
printWorkspaceList(info);
|
|
434
|
+
return;
|
|
435
|
+
}
|
|
436
|
+
if (sub === 'show') {
|
|
437
|
+
rejectWorkspaceOptions(o, ['json'], 'workspace show');
|
|
438
|
+
if (positionals.length !== 1)
|
|
439
|
+
fail('workspace show 需要且只接受一个 Workspace name');
|
|
440
|
+
const workspace = showDevelopmentWorkspace(PROJECT_START, positionals[0], PACKAGE_JSON.version);
|
|
441
|
+
const out = {
|
|
442
|
+
$schema: 'dingtalk-agent/development-workspace@1',
|
|
443
|
+
...workspace,
|
|
444
|
+
sideEffect: false,
|
|
445
|
+
dingtalkSideEffect: false,
|
|
446
|
+
};
|
|
447
|
+
if (o.json)
|
|
448
|
+
console.log(JSON.stringify(out, null, 2));
|
|
449
|
+
else
|
|
450
|
+
printDevelopmentWorkspace(workspace);
|
|
451
|
+
return;
|
|
452
|
+
}
|
|
453
|
+
if (sub === 'doctor') {
|
|
454
|
+
rejectWorkspaceOptions(o, ['json'], 'workspace doctor');
|
|
455
|
+
if (positionals.length !== 1)
|
|
456
|
+
fail('workspace doctor 需要且只接受一个 Workspace name');
|
|
457
|
+
const out = doctorDevelopmentWorkspace(PROJECT_START, positionals[0], {
|
|
458
|
+
cliVersion: PACKAGE_JSON.version,
|
|
459
|
+
});
|
|
460
|
+
if (o.json)
|
|
461
|
+
console.log(JSON.stringify(out, null, 2));
|
|
462
|
+
else
|
|
463
|
+
printDevelopmentWorkspaceDoctor(out);
|
|
464
|
+
if (!out.ready)
|
|
465
|
+
process.exitCode = 2;
|
|
466
|
+
return;
|
|
467
|
+
}
|
|
468
|
+
if (sub === 'plan') {
|
|
469
|
+
rejectWorkspaceOptions(o, ['json', 'dry-run'], 'workspace plan');
|
|
470
|
+
if (positionals.length !== 1)
|
|
471
|
+
fail('workspace plan 需要且只接受一个 Multica Workspace name');
|
|
472
|
+
const out = planMulticaWorkspace(PROJECT_START, positionals[0], {
|
|
473
|
+
cliVersion: PACKAGE_JSON.version,
|
|
474
|
+
});
|
|
475
|
+
if (o.json)
|
|
476
|
+
console.log(JSON.stringify(out, null, 2));
|
|
477
|
+
else
|
|
478
|
+
printMulticaWorkspaceOperation(out);
|
|
479
|
+
if (out.blocking.length)
|
|
480
|
+
process.exitCode = 2;
|
|
481
|
+
return;
|
|
482
|
+
}
|
|
483
|
+
if (sub === 'inspect') {
|
|
484
|
+
rejectWorkspaceOptions(o, ['json', 'execute', 'yes', 'out', 'timeout'], 'workspace inspect');
|
|
485
|
+
if (positionals.length !== 1)
|
|
486
|
+
fail('workspace inspect 需要且只接受一个 Multica Workspace name');
|
|
487
|
+
if (Boolean(o.execute) !== Boolean(o.yes)) {
|
|
488
|
+
fail('workspace inspect 读取远端时必须同时传 --execute --yes');
|
|
489
|
+
}
|
|
490
|
+
const timeoutMs = o.timeout === undefined ? undefined : Number(o.timeout);
|
|
491
|
+
const out = inspectMulticaWorkspace(PROJECT_START, positionals[0], {
|
|
492
|
+
execute: o.execute, yes: o.yes, out: o.out, timeoutMs,
|
|
493
|
+
cliVersion: PACKAGE_JSON.version,
|
|
494
|
+
});
|
|
495
|
+
if (o.json)
|
|
496
|
+
console.log(JSON.stringify(out, null, 2));
|
|
497
|
+
else
|
|
498
|
+
printMulticaWorkspaceOperation(out);
|
|
499
|
+
if (o.execute && 'passed' in out && !out.passed)
|
|
500
|
+
process.exitCode = 2;
|
|
501
|
+
return;
|
|
502
|
+
}
|
|
503
|
+
if (sub === 'remote-list') {
|
|
504
|
+
rejectWorkspaceOptions(o, ['json', 'execute', 'yes', 'timeout'], 'workspace remote-list');
|
|
505
|
+
if (positionals.length !== 1)
|
|
506
|
+
fail('workspace remote-list 需要且只接受一个 Multica Workspace name');
|
|
507
|
+
if (Boolean(o.execute) !== Boolean(o.yes)) {
|
|
508
|
+
fail('workspace remote-list 读取远端时必须同时传 --execute --yes');
|
|
509
|
+
}
|
|
510
|
+
const timeoutMs = o.timeout === undefined ? undefined : Number(o.timeout);
|
|
511
|
+
const out = listMulticaWorkspaceResources(PROJECT_START, positionals[0], {
|
|
512
|
+
execute: o.execute, yes: o.yes, timeoutMs, cliVersion: PACKAGE_JSON.version,
|
|
513
|
+
});
|
|
514
|
+
if (o.json)
|
|
515
|
+
console.log(JSON.stringify(out, null, 2));
|
|
516
|
+
else
|
|
517
|
+
printMulticaWorkspaceOperation(out);
|
|
518
|
+
if (o.execute && 'passed' in out && !out.passed)
|
|
519
|
+
process.exitCode = 2;
|
|
520
|
+
return;
|
|
521
|
+
}
|
|
522
|
+
if (sub === 'status') {
|
|
523
|
+
rejectWorkspaceOptions(o, ['json'], 'workspace status');
|
|
524
|
+
if (positionals.length !== 1)
|
|
525
|
+
fail('workspace status 需要且只接受一个 Multica Workspace name');
|
|
526
|
+
const out = statusMulticaWorkspace(PROJECT_START, positionals[0], PACKAGE_JSON.version);
|
|
527
|
+
if (o.json)
|
|
528
|
+
console.log(JSON.stringify(out, null, 2));
|
|
529
|
+
else
|
|
530
|
+
printMulticaWorkspaceOperation(out);
|
|
531
|
+
if (!out.readyForApply)
|
|
532
|
+
process.exitCode = 2;
|
|
533
|
+
return;
|
|
534
|
+
}
|
|
535
|
+
if (sub === 'create') {
|
|
536
|
+
rejectWorkspaceOptions(o, ['json', 'yes', 'dry-run'], 'workspace create');
|
|
537
|
+
if (positionals.length !== 1)
|
|
538
|
+
fail('workspace create 需要且只接受一个 Workspace name');
|
|
539
|
+
if (o.yes && o['dry-run'])
|
|
540
|
+
fail('workspace create 的 --dry-run 与 --yes 不能同时使用');
|
|
541
|
+
const out = o.yes
|
|
542
|
+
? applyOpenCodeWorkspace(PROJECT_START, positionals[0], {
|
|
543
|
+
yes: true, cliVersion: PACKAGE_JSON.version,
|
|
544
|
+
})
|
|
545
|
+
: planOpenCodeWorkspace(PROJECT_START, positionals[0], PACKAGE_JSON.version);
|
|
546
|
+
if (o.json)
|
|
547
|
+
console.log(JSON.stringify(out, null, 2));
|
|
548
|
+
else
|
|
549
|
+
printOpenCodeWorkspaceOperation(out);
|
|
550
|
+
return;
|
|
551
|
+
}
|
|
552
|
+
if (sub === 'use') {
|
|
553
|
+
rejectWorkspaceOptions(o, ['json'], 'workspace use');
|
|
554
|
+
if (positionals.length !== 1)
|
|
555
|
+
fail('workspace use 需要且只接受一个 Workspace name');
|
|
556
|
+
const out = useOpenCodeWorkspace(PROJECT_START, positionals[0], PACKAGE_JSON.version);
|
|
557
|
+
if (o.json)
|
|
558
|
+
console.log(JSON.stringify(out, null, 2));
|
|
559
|
+
else
|
|
560
|
+
console.log(`✅ current workspace: ${out.previous || '-'} → ${out.current}`);
|
|
561
|
+
return;
|
|
562
|
+
}
|
|
563
|
+
if (sub === 'run') {
|
|
564
|
+
rejectWorkspaceOptions(o, ['json', 'yes', 'execute', 'prompt-file', 'out', 'timeout'], 'workspace run');
|
|
565
|
+
if (positionals.length !== 1 || !o['prompt-file']) {
|
|
566
|
+
fail('workspace run 需要一个 Workspace name 和 --prompt-file <file>');
|
|
567
|
+
}
|
|
568
|
+
const timeoutMs = o.timeout === undefined ? undefined : Number(o.timeout);
|
|
569
|
+
const prompt = readProjectText(PROJECT_START, o['prompt-file'], 'workspace run prompt');
|
|
570
|
+
const out = runOpenCodeWorkspace(PROJECT_START, positionals[0], prompt, {
|
|
571
|
+
execute: o.execute, yes: o.yes, timeoutMs, out: o.out,
|
|
572
|
+
});
|
|
573
|
+
if (o.json)
|
|
574
|
+
console.log(JSON.stringify(out, null, 2));
|
|
575
|
+
else if (out.$schema === 'dingtalk-agent/opencode-workspace-run-plan@1') {
|
|
576
|
+
console.log(`DRY-RUN workspace=${out.workspace} model=${out.model} prompt=${out.promptHash}`);
|
|
577
|
+
}
|
|
578
|
+
else {
|
|
579
|
+
console.log(`${out.passed ? '✅' : '❌'} workspace run ${out.runId}`);
|
|
580
|
+
if (out.execution?.answer)
|
|
581
|
+
console.log(out.execution.answer);
|
|
582
|
+
if (out.evidencePath)
|
|
583
|
+
console.log(`evidence=${out.evidencePath}`);
|
|
584
|
+
}
|
|
585
|
+
if (o.execute && !out.passed)
|
|
586
|
+
process.exitCode = 2;
|
|
587
|
+
return;
|
|
588
|
+
}
|
|
589
|
+
if (sub === 'eval') {
|
|
590
|
+
rejectWorkspaceOptions(o, ['json', 'yes', 'execute', 'suite', 'cases', 'lanes', 'runs', 'out', 'previous-skill'], 'workspace eval');
|
|
591
|
+
if (positionals.length !== 1 || !o.suite) {
|
|
592
|
+
fail('workspace eval 需要一个 Workspace name 和 --suite <file>');
|
|
593
|
+
}
|
|
594
|
+
const lanes = String(o.lanes || '').split(',').map((item) => item.trim()).filter(Boolean);
|
|
595
|
+
const invalid = lanes.filter((item) => !['stateless', 'stateful', 'role'].includes(item));
|
|
596
|
+
if (invalid.length)
|
|
597
|
+
fail(`workspace eval lanes 非法: ${invalid.join(',')}`);
|
|
598
|
+
const cases = String(o.cases || '').split(',').map((item) => item.trim()).filter(Boolean);
|
|
599
|
+
const runs = o.runs === undefined ? undefined : Number(o.runs);
|
|
600
|
+
const out = evalOpenCodeWorkspace(PROJECT_START, positionals[0], o.suite, {
|
|
601
|
+
lanes: lanes, caseIds: cases, runs, out: o.out,
|
|
602
|
+
previousSkill: o['previous-skill'], execute: o.execute, yes: o.yes,
|
|
603
|
+
});
|
|
604
|
+
if (o.json)
|
|
605
|
+
console.log(JSON.stringify(out, null, 2));
|
|
606
|
+
else
|
|
607
|
+
printLab(out.report || out);
|
|
608
|
+
if (o.execute && !out.passed)
|
|
609
|
+
process.exitCode = 2;
|
|
610
|
+
return;
|
|
611
|
+
}
|
|
612
|
+
fail(`不认识的 workspace 子命令: ${sub || '(缺失)'}`, 1, `可用命令: dta workspace list | show | doctor | plan | inspect | remote-list | status | create | use | run | eval${suggest(sub || '', ['list', 'show', 'doctor', 'plan', 'inspect', 'remote-list', 'status', 'create', 'use', 'run', 'eval'], 'dta workspace')}`);
|
|
613
|
+
}
|
|
110
614
|
// ── setup / upgrade / doctor:机器级安装与环境闭环。──
|
|
111
615
|
if (cmd === 'setup') {
|
|
112
616
|
const { values: o } = parseArgs({
|
|
@@ -167,13 +671,16 @@ async function main() {
|
|
|
167
671
|
}
|
|
168
672
|
// ── skill:唯一一次性的主入口;完全不依赖 Workspace。──
|
|
169
673
|
if (cmd === 'skill') {
|
|
170
|
-
const { values: o } = parseArgs({
|
|
674
|
+
const { values: o, positionals } = parseArgs({
|
|
171
675
|
args: argv.slice(2),
|
|
676
|
+
allowPositionals: true,
|
|
172
677
|
options: {
|
|
173
|
-
'dry-run': { type: 'boolean' }, json: { type: 'boolean' },
|
|
678
|
+
name: { type: 'string' }, 'dry-run': { type: 'boolean' }, json: { type: 'boolean' },
|
|
174
679
|
},
|
|
175
680
|
});
|
|
176
|
-
|
|
681
|
+
if (positionals.length > 1)
|
|
682
|
+
fail('skill 最多接受一个 Skill name');
|
|
683
|
+
const options = { dryRun: o['dry-run'], name: o.name || positionals[0] };
|
|
177
684
|
let out;
|
|
178
685
|
if (sub === 'install')
|
|
179
686
|
out = installGlobalSkill(PACKAGE_ROOT, options);
|
|
@@ -196,18 +703,27 @@ async function main() {
|
|
|
196
703
|
const { values: o } = parseArgs({
|
|
197
704
|
args: argv.slice(1),
|
|
198
705
|
options: {
|
|
199
|
-
|
|
200
|
-
|
|
706
|
+
agent: { type: 'string' }, storage: { type: 'string' },
|
|
707
|
+
memory: { type: 'string' }, knowledge: { type: 'string' },
|
|
708
|
+
skills: { type: 'string' }, artifacts: { type: 'string' },
|
|
709
|
+
'state-dir': { type: 'string' }, profile: { type: 'string' },
|
|
710
|
+
'expected-user-id': { type: 'string' }, bindings: { type: 'string' },
|
|
711
|
+
json: { type: 'boolean' },
|
|
201
712
|
},
|
|
202
713
|
});
|
|
714
|
+
const loaded = loadConventionalBindings(o.bindings);
|
|
203
715
|
const out = bootstrap(ROOT, {
|
|
204
|
-
|
|
716
|
+
agent: o.agent, storage: o.storage,
|
|
717
|
+
memory: o.memory, knowledge: o.knowledge, skills: o.skills,
|
|
718
|
+
artifacts: o.artifacts, stateDir: o['state-dir'], profile: o.profile,
|
|
719
|
+
expectedUserId: o['expected-user-id'], context: loaded?.context,
|
|
205
720
|
});
|
|
206
721
|
if (o.json)
|
|
207
722
|
console.log(JSON.stringify(out, null, 2));
|
|
208
723
|
else {
|
|
209
724
|
console.log(`✅ ${out.mode === 'workspace' ? '已装载 Workspace' : '直接会话模式'}`);
|
|
210
725
|
console.log(` scope=${out.scopeId} initialized=${out.initialized}`);
|
|
726
|
+
console.log(` agent=${out.definition.id} definition=${out.definition.status}`);
|
|
211
727
|
if (!out.mounts.length)
|
|
212
728
|
console.log(' 没有发现持久上下文;这不是错误,也不需要自动 init。');
|
|
213
729
|
for (const mount of out.mounts)
|
|
@@ -216,6 +732,189 @@ async function main() {
|
|
|
216
732
|
}
|
|
217
733
|
return;
|
|
218
734
|
}
|
|
735
|
+
// ── agent audit:本地定义、Host exposure、真加载与存储证据的稳定验收面。──
|
|
736
|
+
if (cmd === 'agent') {
|
|
737
|
+
if (!['audit', 'enhance'].includes(sub || ''))
|
|
738
|
+
fail(`不认识的 agent 子命令: ${sub || '(缺失)'}`, 1, `可用命令: dta agent audit / dta agent enhance${suggest(sub || '', ['audit', 'enhance'], 'dta agent')}`);
|
|
739
|
+
if (sub === 'enhance') {
|
|
740
|
+
const { values: o } = parseArgs({
|
|
741
|
+
args: argv.slice(2),
|
|
742
|
+
options: {
|
|
743
|
+
bindings: { type: 'string' }, 'project-name': { type: 'string' },
|
|
744
|
+
'role-skill': { type: 'string' }, model: { type: 'string' },
|
|
745
|
+
memory: { type: 'string' }, knowledge: { type: 'string' },
|
|
746
|
+
artifacts: { type: 'string' }, 'state-dir': { type: 'string' },
|
|
747
|
+
profile: { type: 'string' }, 'expected-user-id': { type: 'string' },
|
|
748
|
+
'plan-id': { type: 'string' }, 'dry-run': { type: 'boolean' },
|
|
749
|
+
yes: { type: 'boolean' }, json: { type: 'boolean' },
|
|
750
|
+
},
|
|
751
|
+
});
|
|
752
|
+
if (o.yes && o['dry-run'])
|
|
753
|
+
fail('agent enhance 的 --dry-run 与 --yes 不能同时使用');
|
|
754
|
+
if (!o.yes && o['plan-id'])
|
|
755
|
+
fail('agent enhance plan 不接受 --plan-id;它由 dry-run 生成');
|
|
756
|
+
const options = {
|
|
757
|
+
bindings: o.bindings, projectName: o['project-name'],
|
|
758
|
+
roleSkills: o['role-skill']?.split(','), model: o.model,
|
|
759
|
+
memory: o.memory, knowledge: o.knowledge, artifacts: o.artifacts,
|
|
760
|
+
stateDir: o['state-dir'], profile: o.profile,
|
|
761
|
+
expectedUserId: o['expected-user-id'], cliVersion: PACKAGE_JSON.version,
|
|
762
|
+
planId: o['plan-id'], yes: o.yes,
|
|
763
|
+
};
|
|
764
|
+
const out = o.yes
|
|
765
|
+
? applyAgentEnhancement(ROOT, options)
|
|
766
|
+
: planAgentEnhancement(ROOT, options);
|
|
767
|
+
if (o.json)
|
|
768
|
+
console.log(JSON.stringify(out, null, 2));
|
|
769
|
+
else
|
|
770
|
+
printAgentEnhance(out);
|
|
771
|
+
if ('$schema' in out && out.$schema === 'dingtalk-agent/agent-enhancement-plan@1' && !out.ready) {
|
|
772
|
+
process.exitCode = 2;
|
|
773
|
+
}
|
|
774
|
+
return;
|
|
775
|
+
}
|
|
776
|
+
const { values: o } = parseArgs({
|
|
777
|
+
args: argv.slice(2),
|
|
778
|
+
options: {
|
|
779
|
+
bindings: { type: 'string' }, agent: { type: 'string' }, storage: { type: 'string' },
|
|
780
|
+
memory: { type: 'string' }, knowledge: { type: 'string' },
|
|
781
|
+
skills: { type: 'string' }, artifacts: { type: 'string' },
|
|
782
|
+
'state-dir': { type: 'string' }, profile: { type: 'string' },
|
|
783
|
+
'expected-user-id': { type: 'string' }, 'require-skill': { type: 'string' },
|
|
784
|
+
'verify-load': { type: 'boolean' }, yes: { type: 'boolean' },
|
|
785
|
+
model: { type: 'string' }, out: { type: 'string' },
|
|
786
|
+
'load-report': { type: 'string' }, 'remote-report': { type: 'string' },
|
|
787
|
+
json: { type: 'boolean' },
|
|
788
|
+
},
|
|
789
|
+
});
|
|
790
|
+
const loaded = loadConventionalBindings(o.bindings);
|
|
791
|
+
const out = auditAgent(ROOT, {
|
|
792
|
+
bootstrap: {
|
|
793
|
+
agent: o.agent, storage: o.storage,
|
|
794
|
+
memory: o.memory, knowledge: o.knowledge, skills: o.skills,
|
|
795
|
+
artifacts: o.artifacts, stateDir: o['state-dir'], profile: o.profile,
|
|
796
|
+
expectedUserId: o['expected-user-id'], context: loaded?.context,
|
|
797
|
+
},
|
|
798
|
+
bindings: loaded ? { path: loaded.path, hash: loaded.hash } : undefined,
|
|
799
|
+
requiredSkills: o['require-skill']?.split(','),
|
|
800
|
+
verifyLoad: o['verify-load'], yes: o.yes, model: o.model, out: o.out,
|
|
801
|
+
loadReport: o['load-report'], remoteReport: o['remote-report'],
|
|
802
|
+
});
|
|
803
|
+
if (o.json)
|
|
804
|
+
console.log(JSON.stringify(out, null, 2));
|
|
805
|
+
else
|
|
806
|
+
printAgentAudit(out);
|
|
807
|
+
if (!out.ready)
|
|
808
|
+
process.exitCode = 2;
|
|
809
|
+
return;
|
|
810
|
+
}
|
|
811
|
+
// ── lab:测试控制面;默认无副作用,Live 必须 manifest + --live --yes。──
|
|
812
|
+
if (cmd === 'lab') {
|
|
813
|
+
const { values: o } = parseArgs({
|
|
814
|
+
args: argv.slice(2),
|
|
815
|
+
options: {
|
|
816
|
+
manifest: { type: 'string' }, evidence: { type: 'string' },
|
|
817
|
+
'event-file': { type: 'string' }, 'case-id': { type: 'string' },
|
|
818
|
+
pool: { type: 'string' }, suite: { type: 'string' }, lanes: { type: 'string' },
|
|
819
|
+
cases: { type: 'string' },
|
|
820
|
+
engine: { type: 'string' }, workspace: { type: 'string' }, model: { type: 'string' },
|
|
821
|
+
runs: { type: 'string' }, out: { type: 'string' },
|
|
822
|
+
'previous-skill': { type: 'string' }, execute: { type: 'boolean' },
|
|
823
|
+
reply: { type: 'string' }, input: { type: 'string' },
|
|
824
|
+
live: { type: 'boolean' }, yes: { type: 'boolean' }, json: { type: 'boolean' },
|
|
825
|
+
},
|
|
826
|
+
});
|
|
827
|
+
let out;
|
|
828
|
+
if (sub === 'doctor') {
|
|
829
|
+
if (!o.manifest)
|
|
830
|
+
fail('lab doctor 需要 --manifest <file>');
|
|
831
|
+
out = doctorLab(ROOT, o.manifest);
|
|
832
|
+
if (!out.ready)
|
|
833
|
+
process.exitCode = 2;
|
|
834
|
+
}
|
|
835
|
+
else if (sub === 'run') {
|
|
836
|
+
if (!o.manifest || !o['case-id'])
|
|
837
|
+
fail('lab run 需要 --manifest 和 --case-id');
|
|
838
|
+
const rawEvent = o['event-file']
|
|
839
|
+
? readEventFile(o['event-file']) : null;
|
|
840
|
+
out = runLab(ROOT, cfgmod.must(ROOT), o.manifest, rawEvent, {
|
|
841
|
+
caseId: o['case-id'], replyText: o.reply, inputText: o.input,
|
|
842
|
+
live: o.live, yes: o.yes,
|
|
843
|
+
});
|
|
844
|
+
}
|
|
845
|
+
else if (sub === 'verify') {
|
|
846
|
+
if (!o.evidence)
|
|
847
|
+
fail('lab verify 需要 --evidence <run-dir>');
|
|
848
|
+
out = verifyLab(ROOT, o.evidence);
|
|
849
|
+
if (!out.passed)
|
|
850
|
+
process.exitCode = 2;
|
|
851
|
+
}
|
|
852
|
+
else if (sub === 'teardown') {
|
|
853
|
+
if (!o.manifest || !o.evidence)
|
|
854
|
+
fail('lab teardown 需要 --manifest 和 --evidence');
|
|
855
|
+
out = teardownLab(ROOT, o.manifest, o.evidence, { live: o.live, yes: o.yes });
|
|
856
|
+
}
|
|
857
|
+
else if (sub === 'eval') {
|
|
858
|
+
if (!o.suite)
|
|
859
|
+
fail('lab eval 需要 --suite');
|
|
860
|
+
const lanes = String(o.lanes || '').split(',').map((item) => item.trim()).filter(Boolean);
|
|
861
|
+
const invalid = lanes.filter((item) => !['stateless', 'stateful', 'role'].includes(item));
|
|
862
|
+
if (invalid.length)
|
|
863
|
+
fail(`lab eval lanes 非法: ${invalid.join(',')}`);
|
|
864
|
+
const cases = String(o.cases || '').split(',').map((item) => item.trim()).filter(Boolean);
|
|
865
|
+
const engine = o.engine || 'robot';
|
|
866
|
+
if (engine === 'opencode') {
|
|
867
|
+
if (!o.workspace)
|
|
868
|
+
fail('OpenCode eval 需要 --workspace <agent-dir>');
|
|
869
|
+
const runs = o.runs === undefined ? undefined : Number(o.runs);
|
|
870
|
+
out = runOpenCodeEvaluation(ROOT, o.workspace, o.suite, {
|
|
871
|
+
lanes: lanes, model: o.model, runs,
|
|
872
|
+
caseIds: cases, previousSkill: o['previous-skill'],
|
|
873
|
+
execute: o.execute, yes: o.yes, out: o.out,
|
|
874
|
+
});
|
|
875
|
+
if (o.execute && !out.passed)
|
|
876
|
+
process.exitCode = 2;
|
|
877
|
+
}
|
|
878
|
+
else if (engine === 'storage') {
|
|
879
|
+
if (!o.workspace)
|
|
880
|
+
fail('Remote State eval 需要 --workspace <agent-dir>');
|
|
881
|
+
out = runStorageEvaluation(ROOT, o.workspace, o.suite, {
|
|
882
|
+
model: o.model, execute: o.execute, live: o.live, yes: o.yes, out: o.out,
|
|
883
|
+
});
|
|
884
|
+
if (o.execute && !out.passed)
|
|
885
|
+
process.exitCode = 2;
|
|
886
|
+
}
|
|
887
|
+
else if (engine === 'personal-event') {
|
|
888
|
+
if (!o.workspace)
|
|
889
|
+
fail('Personal Event eval 需要 --workspace <agent-dir>');
|
|
890
|
+
out = runPersonalEventEvaluation(ROOT, o.workspace, o.suite, {
|
|
891
|
+
execute: o.execute, live: o.live, yes: o.yes, out: o.out,
|
|
892
|
+
});
|
|
893
|
+
if (o.execute && !out.passed)
|
|
894
|
+
process.exitCode = 2;
|
|
895
|
+
}
|
|
896
|
+
else if (engine === 'robot') {
|
|
897
|
+
if (!o.pool)
|
|
898
|
+
fail('Robot eval 需要 --pool <pool.local.json>');
|
|
899
|
+
out = runRobotEvaluation(ROOT, o.pool, o.suite, {
|
|
900
|
+
lanes: lanes, live: o.live, yes: o.yes,
|
|
901
|
+
});
|
|
902
|
+
if (o.live && !out.passed)
|
|
903
|
+
process.exitCode = 2;
|
|
904
|
+
}
|
|
905
|
+
else {
|
|
906
|
+
fail(`lab eval engine 非法: ${engine};只支持 robot、opencode、storage 或 personal-event`);
|
|
907
|
+
}
|
|
908
|
+
}
|
|
909
|
+
else {
|
|
910
|
+
fail(`不认识的 lab 子命令: ${sub || '(缺失)'}`, 1, '可用命令: dta lab doctor | run | verify | teardown | eval;详见 dta help lab。');
|
|
911
|
+
}
|
|
912
|
+
if (o.json)
|
|
913
|
+
console.log(JSON.stringify(out, null, 2));
|
|
914
|
+
else
|
|
915
|
+
printLab(out);
|
|
916
|
+
return;
|
|
917
|
+
}
|
|
219
918
|
// ── init ──
|
|
220
919
|
if (cmd === 'init') {
|
|
221
920
|
const { values: o } = parseArgs({
|
|
@@ -240,6 +939,7 @@ async function main() {
|
|
|
240
939
|
options: {
|
|
241
940
|
'event-file': { type: 'string' }, field: { type: 'string' },
|
|
242
941
|
'session-key': { type: 'string' }, 'context-id': { type: 'string' },
|
|
942
|
+
'perception-file': { type: 'string' },
|
|
243
943
|
json: { type: 'boolean' },
|
|
244
944
|
},
|
|
245
945
|
});
|
|
@@ -248,6 +948,7 @@ async function main() {
|
|
|
248
948
|
fail('prepare 需要 --event-file <file|->');
|
|
249
949
|
const out = prepareSession(ROOT, cfg, readEventFile(file), {
|
|
250
950
|
fieldId: o.field, sessionKey: o['session-key'], contextId: o['context-id'],
|
|
951
|
+
perception: o['perception-file'] ? readEventFile(o['perception-file']) : undefined,
|
|
251
952
|
});
|
|
252
953
|
printDispatch(out, o.json);
|
|
253
954
|
return;
|
|
@@ -261,12 +962,14 @@ async function main() {
|
|
|
261
962
|
stdin: { type: 'boolean' }, 'event-file': { type: 'string' },
|
|
262
963
|
field: { type: 'string' }, 'session-key': { type: 'string' },
|
|
263
964
|
'context-id': { type: 'string' },
|
|
965
|
+
'perception-file': { type: 'string' },
|
|
264
966
|
heartbeat: { type: 'boolean' }, 'heartbeat-key': { type: 'string' },
|
|
265
967
|
'heartbeat-event-id': { type: 'string' },
|
|
266
968
|
},
|
|
267
969
|
});
|
|
268
970
|
const options = {
|
|
269
971
|
fieldId: o.field, sessionKey: o['session-key'], contextId: o['context-id'],
|
|
972
|
+
perception: o['perception-file'] ? readEventFile(o['perception-file']) : undefined,
|
|
270
973
|
};
|
|
271
974
|
const modes = [Boolean(o.stdin), Boolean(o.heartbeat), Boolean(o['event-file'] || positionals[0])];
|
|
272
975
|
if (modes.filter(Boolean).length !== 1) {
|
|
@@ -378,6 +1081,133 @@ async function main() {
|
|
|
378
1081
|
}
|
|
379
1082
|
fail('dispatch 的子命令: pending / ack');
|
|
380
1083
|
}
|
|
1084
|
+
// ── task:Session 语义 checkpoint;revision CAS,不承担 Wait/锁/Receipt。──
|
|
1085
|
+
if (cmd === 'task') {
|
|
1086
|
+
const cfg = cfgmod.must(ROOT);
|
|
1087
|
+
const { values: o } = parseArgs({
|
|
1088
|
+
args: argv.slice(2),
|
|
1089
|
+
options: {
|
|
1090
|
+
input: { type: 'string' }, session: { type: 'string' },
|
|
1091
|
+
'expect-revision': { type: 'string' }, json: { type: 'boolean' },
|
|
1092
|
+
},
|
|
1093
|
+
});
|
|
1094
|
+
let out;
|
|
1095
|
+
if (sub === 'show') {
|
|
1096
|
+
out = showTaskCheckpoint(ROOT, cfg, {
|
|
1097
|
+
sessionPath: o.session || process.env.DTA_SESSION,
|
|
1098
|
+
runPath: process.env.DTA_RUN,
|
|
1099
|
+
});
|
|
1100
|
+
}
|
|
1101
|
+
else if (sub === 'checkpoint') {
|
|
1102
|
+
if (!o.input || o['expect-revision'] === undefined) {
|
|
1103
|
+
fail('task checkpoint 需要 --input 和 --expect-revision');
|
|
1104
|
+
}
|
|
1105
|
+
const expectedRevision = Number(o['expect-revision']);
|
|
1106
|
+
out = checkpointTask(ROOT, cfg, readEventFile(o.input), expectedRevision, {
|
|
1107
|
+
sessionPath: o.session || process.env.DTA_SESSION,
|
|
1108
|
+
runPath: process.env.DTA_RUN,
|
|
1109
|
+
});
|
|
1110
|
+
}
|
|
1111
|
+
else {
|
|
1112
|
+
fail('task 的子命令: show / checkpoint');
|
|
1113
|
+
}
|
|
1114
|
+
if (o.json)
|
|
1115
|
+
console.log(JSON.stringify(out, null, 2));
|
|
1116
|
+
else if (!out.found)
|
|
1117
|
+
console.log('当前 Session 尚无 Task checkpoint。');
|
|
1118
|
+
else {
|
|
1119
|
+
console.log(`✅ Task ${out.checkpoint.taskId} · ${out.checkpoint.status}`);
|
|
1120
|
+
console.log(` revision=${out.checkpoint.revision} hash=${out.hash}`);
|
|
1121
|
+
console.log(` next=${out.checkpoint.nextAction || '-'}`);
|
|
1122
|
+
}
|
|
1123
|
+
return;
|
|
1124
|
+
}
|
|
1125
|
+
// ── memory:Provider-neutral 语义路由;当前首个远端事实源是 AI 表格。──
|
|
1126
|
+
if (cmd === 'memory') {
|
|
1127
|
+
const action = argv[2];
|
|
1128
|
+
if (sub === 'operational' && action === 'upsert') {
|
|
1129
|
+
const { values: o } = parseArgs({
|
|
1130
|
+
args: argv.slice(3),
|
|
1131
|
+
options: {
|
|
1132
|
+
provider: { type: 'string' }, input: { type: 'string' },
|
|
1133
|
+
live: { type: 'boolean' }, yes: { type: 'boolean' }, json: { type: 'boolean' },
|
|
1134
|
+
},
|
|
1135
|
+
});
|
|
1136
|
+
const providerPath = o.provider || process.env.DTA_OPERATIONAL_MEMORY_PROVIDER;
|
|
1137
|
+
if (!providerPath || !o.input) {
|
|
1138
|
+
fail('memory operational upsert 需要 --provider(或 DTA_OPERATIONAL_MEMORY_PROVIDER)和 --input');
|
|
1139
|
+
}
|
|
1140
|
+
const out = upsertOperationalMemory(readEventFile(providerPath), readEventFile(o.input), { execute: Boolean(o.live), yes: Boolean(o.yes) });
|
|
1141
|
+
if (o.json || !o.live)
|
|
1142
|
+
console.log(JSON.stringify(out, null, 2));
|
|
1143
|
+
else {
|
|
1144
|
+
console.log(`${out.verified ? '✅' : '⚠️'} Operational Memory · ${out.mode}`);
|
|
1145
|
+
console.log(` record=${out.recordId || '-'} verification=${out.verification}`);
|
|
1146
|
+
}
|
|
1147
|
+
if (out.mode === 'uncertain')
|
|
1148
|
+
process.exitCode = 2;
|
|
1149
|
+
return;
|
|
1150
|
+
}
|
|
1151
|
+
if (sub === 'candidate') {
|
|
1152
|
+
const { values: o } = parseArgs({
|
|
1153
|
+
args: argv.slice(3),
|
|
1154
|
+
options: {
|
|
1155
|
+
input: { type: 'string' }, id: { type: 'string' }, target: { type: 'string' },
|
|
1156
|
+
decision: { type: 'string' }, reviewer: { type: 'string' }, reason: { type: 'string' },
|
|
1157
|
+
'state-dir': { type: 'string' }, 'expect-revision': { type: 'string' },
|
|
1158
|
+
'expect-target-hash': { type: 'string' },
|
|
1159
|
+
live: { type: 'boolean' }, yes: { type: 'boolean' }, json: { type: 'boolean' },
|
|
1160
|
+
},
|
|
1161
|
+
});
|
|
1162
|
+
const options = { stateDir: o['state-dir'], runPath: process.env.DTA_RUN };
|
|
1163
|
+
let out;
|
|
1164
|
+
if (action === 'propose') {
|
|
1165
|
+
if (!o.input)
|
|
1166
|
+
fail('memory candidate propose 需要 --input');
|
|
1167
|
+
out = proposeMemoryCandidate(ROOT, readEventFile(o.input), options);
|
|
1168
|
+
}
|
|
1169
|
+
else if (action === 'show') {
|
|
1170
|
+
if (!o.id)
|
|
1171
|
+
fail('memory candidate show 需要 --id');
|
|
1172
|
+
out = showMemoryCandidate(ROOT, o.id, options);
|
|
1173
|
+
}
|
|
1174
|
+
else if (action === 'review') {
|
|
1175
|
+
if (!o.id || !o.decision || !o.reviewer || !o.reason ||
|
|
1176
|
+
o['expect-revision'] === undefined) {
|
|
1177
|
+
fail('memory candidate review 需要 --id/--decision/--reviewer/--reason/--expect-revision');
|
|
1178
|
+
}
|
|
1179
|
+
out = reviewMemoryCandidate(ROOT, o.id, o.decision, o.reviewer, o.reason, Number(o['expect-revision']), options);
|
|
1180
|
+
}
|
|
1181
|
+
else if (action === 'publish') {
|
|
1182
|
+
if (!o.id || !o.target || o['expect-revision'] === undefined) {
|
|
1183
|
+
fail('memory candidate publish 需要 --id/--target/--expect-revision');
|
|
1184
|
+
}
|
|
1185
|
+
out = publishMemoryCandidate(ROOT, o.id, readEventFile(o.target), Number(o['expect-revision']), o['expect-target-hash'] || '', {
|
|
1186
|
+
...options,
|
|
1187
|
+
execute: Boolean(o.yes || o.live),
|
|
1188
|
+
yes: Boolean(o.yes),
|
|
1189
|
+
live: Boolean(o.live),
|
|
1190
|
+
});
|
|
1191
|
+
}
|
|
1192
|
+
else {
|
|
1193
|
+
fail('memory candidate 的子命令: propose / show / review / publish');
|
|
1194
|
+
}
|
|
1195
|
+
if (o.json)
|
|
1196
|
+
console.log(JSON.stringify(out, null, 2));
|
|
1197
|
+
else if (action === 'publish') {
|
|
1198
|
+
console.log(`${out.verified ? '✅' : out.mode === 'dry-run' ? '🔎' : '⚠️'} Candidate ${o.id}`);
|
|
1199
|
+
console.log(` mode=${out.mode} targetHash=${out.currentTargetHash}`);
|
|
1200
|
+
}
|
|
1201
|
+
else {
|
|
1202
|
+
console.log(`✅ Candidate ${out.candidate.id} · ${out.candidate.status}`);
|
|
1203
|
+
console.log(` revision=${out.candidate.revision} path=${out.path}`);
|
|
1204
|
+
}
|
|
1205
|
+
if (action === 'publish' && out.mode === 'uncertain')
|
|
1206
|
+
process.exitCode = 2;
|
|
1207
|
+
return;
|
|
1208
|
+
}
|
|
1209
|
+
fail('memory 当前支持: operational upsert / candidate propose|show|review|publish');
|
|
1210
|
+
}
|
|
381
1211
|
// ── act:元语化动作;目标/身份/预算/状态转移都由 Run 固定 ──
|
|
382
1212
|
if (cmd === 'act') {
|
|
383
1213
|
const kind = sub;
|
|
@@ -411,9 +1241,16 @@ async function main() {
|
|
|
411
1241
|
return;
|
|
412
1242
|
}
|
|
413
1243
|
fail(`不认识的命令: ${cmd}`, 1, `运行 dta --help 查看全部命令${suggest(cmd, [
|
|
414
|
-
'setup', 'upgrade', 'doctor', 'skill', 'bootstrap', 'init', 'prepare', 'run', 'dispatch', 'act',
|
|
1244
|
+
'setup', 'upgrade', 'doctor', 'skill', 'bootstrap', 'init', 'prepare', 'run', 'dispatch', 'task', 'memory', 'act',
|
|
1245
|
+
'agent',
|
|
1246
|
+
'info', 'workspace',
|
|
415
1247
|
])}`);
|
|
416
1248
|
}
|
|
1249
|
+
function loadConventionalBindings(input) {
|
|
1250
|
+
const conventional = 'agent.bindings.json';
|
|
1251
|
+
const selected = input || (existsSync(resolve(ROOT, conventional)) ? conventional : '');
|
|
1252
|
+
return selected ? loadAgentBindings(ROOT, selected) : null;
|
|
1253
|
+
}
|
|
417
1254
|
function errorHint(message) {
|
|
418
1255
|
if (/unknown option|未知选项|unexpected argument/i.test(message)) {
|
|
419
1256
|
return '检查参数拼写;运行 dta --help 查看当前版本支持的参数。';
|
|
@@ -421,9 +1258,18 @@ function errorHint(message) {
|
|
|
421
1258
|
if (/找不到当前 Run|必须由能访问 DTA_ROOT 的宿主侧执行/.test(message)) {
|
|
422
1259
|
return 'act 只能用于可信事件 Run;先由宿主执行 dta prepare --event-file <file>,再进入返回的 cwd。';
|
|
423
1260
|
}
|
|
1261
|
+
if (/OpenCode/.test(message)) {
|
|
1262
|
+
return '检查 OpenCode 版本、模型认证与项目 Skill/config;运行 dta workspace doctor <name> 查看精确缺口。';
|
|
1263
|
+
}
|
|
1264
|
+
if (/Multica|multica/.test(message)) {
|
|
1265
|
+
return '先运行 dta workspace plan <name> 和 doctor;确认 profile/ID 来源后,再用 inspect --execute --yes 做只读回读。';
|
|
1266
|
+
}
|
|
424
1267
|
if (/\bDWS\b|\bdws\b/.test(message)) {
|
|
425
1268
|
return '运行 dta doctor 检查 DWS 路径、版本和认证;需要登录时执行 dws auth login。';
|
|
426
1269
|
}
|
|
1270
|
+
if (/dingtalk-agent\.json|Project 未声明|current-workspace|Development Workspace/.test(message)) {
|
|
1271
|
+
return '在 Agent Project 内运行 dta info;用 dta workspace list/show/doctor 检查声明和漂移。';
|
|
1272
|
+
}
|
|
427
1273
|
if (/skills CLI|\bnpx\b/.test(message)) {
|
|
428
1274
|
return '确认 node、npm、npx 在 PATH 中;也可以复制错误中的 npx skills 命令单独执行。';
|
|
429
1275
|
}
|
|
@@ -471,6 +1317,62 @@ function printDispatch(out, json = false) {
|
|
|
471
1317
|
console.log(` allowed=${out.allowedActions.join(', ')} default=${out.defaultAction}`);
|
|
472
1318
|
console.log(' Local 模式可直接用 cwd/env;生产模式由宿主 Broker 保留 DWS 与 control 权限。');
|
|
473
1319
|
}
|
|
1320
|
+
function printLab(out) {
|
|
1321
|
+
const passed = out.ready ?? out.passed ?? out.assertions?.passed;
|
|
1322
|
+
console.log(`${passed === false ? '❌' : '✅'} ${out.$schema || 'dingtalk-agent/lab'}`);
|
|
1323
|
+
if (out.mode)
|
|
1324
|
+
console.log(` mode=${out.mode}`);
|
|
1325
|
+
if (out.marker)
|
|
1326
|
+
console.log(` marker=${out.marker}`);
|
|
1327
|
+
if (out.evidencePath)
|
|
1328
|
+
console.log(` evidence=${out.evidencePath}`);
|
|
1329
|
+
if (Array.isArray(out.checks)) {
|
|
1330
|
+
for (const check of out.checks) {
|
|
1331
|
+
console.log(` ${check.passed ? 'PASS' : 'FAIL'} ${check.id}: ${check.detail}`);
|
|
1332
|
+
}
|
|
1333
|
+
}
|
|
1334
|
+
}
|
|
1335
|
+
function printAgentAudit(out) {
|
|
1336
|
+
console.log(`dingtalk-agent agent audit · ${out.ready ? 'READY' : 'PARTIAL'}`);
|
|
1337
|
+
console.log(` definition=${out.definition.hash} storage=${out.storageMode}`);
|
|
1338
|
+
console.log(` dingtalkSideEffect=${out.dingtalkSideEffect} sideEffect=${out.sideEffect}`);
|
|
1339
|
+
for (const check of out.checks) {
|
|
1340
|
+
const mark = check.level === 'pass' ? 'PASS' : check.level === 'warn' ? 'WARN' : 'FAIL';
|
|
1341
|
+
console.log(` ${mark} ${check.id}: ${check.summary}`);
|
|
1342
|
+
}
|
|
1343
|
+
if (out.repairs.length) {
|
|
1344
|
+
console.log('\n修复建议:');
|
|
1345
|
+
for (const repair of out.repairs) {
|
|
1346
|
+
console.log(` ${repair.id}: ${repair.why}`);
|
|
1347
|
+
for (const action of repair.actions)
|
|
1348
|
+
console.log(` - ${action}`);
|
|
1349
|
+
}
|
|
1350
|
+
}
|
|
1351
|
+
}
|
|
1352
|
+
function printAgentEnhance(out) {
|
|
1353
|
+
if (out.$schema === 'dingtalk-agent/agent-enhancement-plan@1') {
|
|
1354
|
+
console.log(`dingtalk-agent agent enhance · ${out.ready ? 'READY PLAN' : 'BLOCKED'}`);
|
|
1355
|
+
console.log(` planId=${out.planId} project=${out.projectName}`);
|
|
1356
|
+
console.log(` sideEffect=${out.sideEffect} dingtalkSideEffect=${out.dingtalkSideEffect}`);
|
|
1357
|
+
for (const operation of out.operations) {
|
|
1358
|
+
console.log(` ${operation.kind.toUpperCase()} ${operation.path}: ${operation.reason}`);
|
|
1359
|
+
}
|
|
1360
|
+
if (out.semanticReview.required) {
|
|
1361
|
+
console.log(` REVIEW ${out.semanticReview.files.join(', ')}: ${out.semanticReview.why}`);
|
|
1362
|
+
}
|
|
1363
|
+
for (const blocker of out.blockers)
|
|
1364
|
+
console.log(` BLOCK ${blocker}`);
|
|
1365
|
+
if (out.ready)
|
|
1366
|
+
console.log(`\nApply:\n ${out.apply.command}`);
|
|
1367
|
+
return;
|
|
1368
|
+
}
|
|
1369
|
+
console.log('dingtalk-agent agent enhance · APPLIED');
|
|
1370
|
+
console.log(` operation=${out.operationId} planId=${out.planId}`);
|
|
1371
|
+
console.log(` changes=${out.changes.length} idempotent=${out.idempotent}`);
|
|
1372
|
+
if (out.backupRoot)
|
|
1373
|
+
console.log(` backup=${out.backupRoot}`);
|
|
1374
|
+
console.log(` audit=${out.audit.status} missing=${out.audit.missing.join(', ') || '-'}`);
|
|
1375
|
+
}
|
|
474
1376
|
function printSkillStatus(out, action, dryRun) {
|
|
475
1377
|
const prefix = dryRun ? 'DRY-RUN' : '✅';
|
|
476
1378
|
const verb = action === 'status' ? '全局 Skill 状态' : `skill ${action}`;
|
|
@@ -504,6 +1406,152 @@ function printDoctor(out) {
|
|
|
504
1406
|
console.log(` ${step}`);
|
|
505
1407
|
}
|
|
506
1408
|
}
|
|
1409
|
+
function printProjectInfo(out) {
|
|
1410
|
+
console.log(`dingtalk-agent Project · ${out.project.name}`);
|
|
1411
|
+
console.log(` root=${out.root}`);
|
|
1412
|
+
console.log(` source=${out.source} manifest=${out.manifest || '(synthetic legacy)'}`);
|
|
1413
|
+
console.log(` hash=${out.manifestHash} dta=${out.project.dtaVersion}`);
|
|
1414
|
+
console.log(` current=${out.currentWorkspace || '(not selected)'}`);
|
|
1415
|
+
for (const workspace of out.workspaces) {
|
|
1416
|
+
console.log(` ${workspace.current ? '*' : '-'} ${workspace.name} · ${workspace.provider.kind} · ${workspace.status}`);
|
|
1417
|
+
}
|
|
1418
|
+
}
|
|
1419
|
+
function printWorkspaceList(out) {
|
|
1420
|
+
console.log(`dingtalk-agent workspaces · ${out.project.name}`);
|
|
1421
|
+
if (!out.workspaces.length)
|
|
1422
|
+
console.log(' 尚未声明 Development Workspace。');
|
|
1423
|
+
for (const workspace of out.workspaces) {
|
|
1424
|
+
console.log(` ${workspace.current ? '*' : '-'} ${workspace.name} provider=${workspace.provider.kind} ` +
|
|
1425
|
+
`stage=${workspace.stage} status=${workspace.status}`);
|
|
1426
|
+
}
|
|
1427
|
+
}
|
|
1428
|
+
function printDevelopmentWorkspace(out) {
|
|
1429
|
+
console.log(`dingtalk-agent workspace · ${out.name}`);
|
|
1430
|
+
console.log(` provider=${out.provider.kind} stage=${out.stage} status=${out.status}`);
|
|
1431
|
+
console.log(` desired=${out.desiredHash} observed=${out.observedHash || '-'}`);
|
|
1432
|
+
console.log(` current=${out.current} legacy=${out.legacy}`);
|
|
1433
|
+
for (const [slot, route] of Object.entries(out.storage))
|
|
1434
|
+
console.log(` ${slot}=${route}`);
|
|
1435
|
+
for (const source of out.configSources)
|
|
1436
|
+
console.log(` source=${source}`);
|
|
1437
|
+
}
|
|
1438
|
+
function printDevelopmentWorkspaceDoctor(out) {
|
|
1439
|
+
console.log(`dingtalk-agent workspace doctor · ${out.workspace} · ${out.ready ? 'READY' : 'PARTIAL'}`);
|
|
1440
|
+
console.log(` provider=${out.provider} status=${out.status}`);
|
|
1441
|
+
console.log(` sideEffect=${out.sideEffect} dingtalkSideEffect=${out.dingtalkSideEffect}`);
|
|
1442
|
+
for (const check of out.checks) {
|
|
1443
|
+
const mark = check.level === 'pass' ? 'PASS' : check.level === 'warn' ? 'WARN' : 'FAIL';
|
|
1444
|
+
console.log(` ${mark} ${check.id}: ${check.summary}`);
|
|
1445
|
+
if (check.fix && check.level !== 'pass')
|
|
1446
|
+
console.log(` fix: ${check.fix}`);
|
|
1447
|
+
}
|
|
1448
|
+
}
|
|
1449
|
+
function printOpenCodeWorkspaceOperation(out) {
|
|
1450
|
+
const applied = out.$schema === 'dingtalk-agent/opencode-workspace-apply@1';
|
|
1451
|
+
console.log(`${applied ? out.applied ? '✅' : '↩️' : 'DRY-RUN'} OpenCode Workspace ${out.workspace}`);
|
|
1452
|
+
console.log(` action=${out.action} model=${out.model}`);
|
|
1453
|
+
console.log(` desired=${out.desiredHash} observed=${out.observedHash || '-'}`);
|
|
1454
|
+
console.log(` managed=${out.managedPath}`);
|
|
1455
|
+
if (!applied && out.writes?.length)
|
|
1456
|
+
console.log(` writes=${out.writes.join(', ')}`);
|
|
1457
|
+
}
|
|
1458
|
+
function printMulticaWorkspaceOperation(out) {
|
|
1459
|
+
const passed = out.passed ?? out.readyForApply ?? out.blocking?.length === 0;
|
|
1460
|
+
const mode = out.remoteRead ? 'REMOTE-READ' : 'DRY-RUN';
|
|
1461
|
+
console.log(`${passed ? '✅' : '⚠️'} ${mode} Multica Workspace ${out.workspace}`);
|
|
1462
|
+
console.log(` schema=${out.$schema} profile=${out.profile || '-'}`);
|
|
1463
|
+
if (out.planId)
|
|
1464
|
+
console.log(` plan=${out.planId}`);
|
|
1465
|
+
if (out.inspectionId)
|
|
1466
|
+
console.log(` inspection=${out.inspectionId}`);
|
|
1467
|
+
if (out.desiredHash)
|
|
1468
|
+
console.log(` desired=${out.desiredHash}`);
|
|
1469
|
+
if (out.observedHash)
|
|
1470
|
+
console.log(` observed=${out.observedHash}`);
|
|
1471
|
+
if (out.diff?.length)
|
|
1472
|
+
console.log(` diff=${out.diff.join(', ')}`);
|
|
1473
|
+
if (out.blocking?.length)
|
|
1474
|
+
console.log(` blocking=${out.blocking.join(', ')}`);
|
|
1475
|
+
if (out.failures?.length)
|
|
1476
|
+
console.log(` failures=${out.failures.join(', ')}`);
|
|
1477
|
+
if (out.evidencePath)
|
|
1478
|
+
console.log(` evidence=${out.evidencePath}`);
|
|
1479
|
+
console.log(` remoteWrite=${out.remoteWrite} dingtalkSideEffect=${out.dingtalkSideEffect}`);
|
|
1480
|
+
}
|
|
1481
|
+
function printMulticaDeployment(out) {
|
|
1482
|
+
console.log(`Multica deploy: ${out.workspace || '<unknown>'}`);
|
|
1483
|
+
if (out.planId)
|
|
1484
|
+
console.log(` plan: ${out.planId}`);
|
|
1485
|
+
if (out.operationId)
|
|
1486
|
+
console.log(` operation: ${out.operationId}`);
|
|
1487
|
+
if (out.receiptId)
|
|
1488
|
+
console.log(` receipt: ${out.receiptId}`);
|
|
1489
|
+
if (out.action)
|
|
1490
|
+
console.log(` action: ${out.action}`);
|
|
1491
|
+
if (out.status)
|
|
1492
|
+
console.log(` status: ${out.status}`);
|
|
1493
|
+
if (typeof out.providerReady === 'boolean')
|
|
1494
|
+
console.log(` provider ready: ${out.providerReady}`);
|
|
1495
|
+
if (Array.isArray(out.blocking) && out.blocking.length) {
|
|
1496
|
+
console.log(` blocking: ${out.blocking.join(', ')}`);
|
|
1497
|
+
}
|
|
1498
|
+
if (Array.isArray(out.failures) && out.failures.length) {
|
|
1499
|
+
console.log(` failures: ${out.failures.join(', ')}`);
|
|
1500
|
+
}
|
|
1501
|
+
if (out.triggerWrite === false)
|
|
1502
|
+
console.log(' triggers: unchanged');
|
|
1503
|
+
}
|
|
1504
|
+
function printPromotion(out) {
|
|
1505
|
+
console.log(`Promotion: ${out.promotionId || out.candidateId || out.candidate?.candidateId || '<none>'}`);
|
|
1506
|
+
if (out.planId)
|
|
1507
|
+
console.log(` plan: ${out.planId}`);
|
|
1508
|
+
if (out.routeId)
|
|
1509
|
+
console.log(` route: ${out.routeId}`);
|
|
1510
|
+
if (out.status)
|
|
1511
|
+
console.log(` status: ${out.status}`);
|
|
1512
|
+
if (out.target?.observedHash)
|
|
1513
|
+
console.log(` observed: ${out.target.observedHash}`);
|
|
1514
|
+
if (out.candidatePath)
|
|
1515
|
+
console.log(` candidate: ${out.candidatePath}`);
|
|
1516
|
+
if (out.candidate?.evidencePath)
|
|
1517
|
+
console.log(` candidate: ${out.candidate.evidencePath}`);
|
|
1518
|
+
if (Array.isArray(out.blocking) && out.blocking.length)
|
|
1519
|
+
console.log(` blocking: ${out.blocking.join(', ')}`);
|
|
1520
|
+
if (out.triggerWrite === false)
|
|
1521
|
+
console.log(' triggers: unchanged');
|
|
1522
|
+
}
|
|
1523
|
+
function parseOptionalTimeout(value, label) {
|
|
1524
|
+
if (value === undefined)
|
|
1525
|
+
return undefined;
|
|
1526
|
+
const parsed = Number(value);
|
|
1527
|
+
if (!Number.isInteger(parsed) || parsed < 100 || parsed > 300_000) {
|
|
1528
|
+
fail(`${label} 必须是 100..300000 的整数毫秒`);
|
|
1529
|
+
}
|
|
1530
|
+
return parsed;
|
|
1531
|
+
}
|
|
1532
|
+
function readProjectText(start, ref, label) {
|
|
1533
|
+
const root = inspectAgentProject(start, PACKAGE_JSON.version).root;
|
|
1534
|
+
const candidate = resolve(root, ref);
|
|
1535
|
+
const lexical = relative(root, candidate);
|
|
1536
|
+
if (lexical === '..' || lexical.startsWith(`..${process.platform === 'win32' ? '\\' : '/'}`)) {
|
|
1537
|
+
throw new Error(`${label} 必须位于 Agent Project 内: ${ref}`);
|
|
1538
|
+
}
|
|
1539
|
+
if (!existsSync(candidate))
|
|
1540
|
+
throw new Error(`${label} 不存在: ${ref}`);
|
|
1541
|
+
const actual = realpathSync(candidate);
|
|
1542
|
+
const resolved = relative(root, actual);
|
|
1543
|
+
if (resolved === '..' || resolved.startsWith(`..${process.platform === 'win32' ? '\\' : '/'}`)) {
|
|
1544
|
+
throw new Error(`${label} 真实路径越出 Agent Project: ${ref}`);
|
|
1545
|
+
}
|
|
1546
|
+
return readFileSync(actual, 'utf8');
|
|
1547
|
+
}
|
|
1548
|
+
function rejectWorkspaceOptions(values, allowed, command) {
|
|
1549
|
+
const extras = Object.entries(values)
|
|
1550
|
+
.filter(([key, value]) => !allowed.includes(key) && value !== undefined && value !== false)
|
|
1551
|
+
.map(([key]) => `--${key}`);
|
|
1552
|
+
if (extras.length)
|
|
1553
|
+
fail(`${command} 不接受参数: ${extras.join(', ')}`);
|
|
1554
|
+
}
|
|
507
1555
|
function printSetup(out) {
|
|
508
1556
|
console.log(`${out.dryRun ? 'DRY-RUN' : '✅'} dingtalk-agent setup`);
|
|
509
1557
|
console.log(` CLI: ${out.cli.executable}`);
|