@sanqianx/project-knowledge 5.1.7 → 5.2.1
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/.claude-plugin/marketplace.json +1 -1
- package/CHANGELOG.md +10 -0
- package/_site/_test/project-team-ui-test.js +54 -46
- package/_site/_test/workflow-module-wiring-test.js +150 -0
- package/_site/_test/workflow-tools-test.js +218 -72
- package/_site/lib/contracts.js +3 -0
- package/_site/lib/module-bridge.js +86 -5
- package/_site/lib/server-app.js +6 -1
- package/_site/lib/workflow-tool-runtime.js +233 -43
- package/bin/project-knowledge-mcp.js +312 -282
- package/module-runtime-manifest.json +18 -18
- package/package.json +2 -2
- package/plugins/project-knowledge/.claude-plugin/plugin.json +1 -1
- package/plugins/project-knowledge/.codex-plugin/plugin.json +1 -1
- package/plugins/project-knowledge/.mcp.json +1 -1
- package/plugins/project-knowledge/skills/pk-team/SKILL.md +37 -4
package/CHANGELOG.md
CHANGED
|
@@ -1,5 +1,15 @@
|
|
|
1
1
|
# Changelog
|
|
2
2
|
|
|
3
|
+
## [5.2.1] - 2026-11-22
|
|
4
|
+
|
|
5
|
+
- 工作流模块升级至 `0.2.1`。AI 团队页按新交互设计重构:任务工作台(列表搜索、团队计划的依赖工作项与真实成员、最新意见在前代码审查、验收依据含工具版本/命令摘要/退出码/快照与收据时效)、团队设置(真实配置编辑带版本冲突保护)与只读接入诊断;全部数据来自服务端,无示例内容。程序收据新增脱敏命令摘要;能力声明如实标记审查编排可用。
|
|
6
|
+
|
|
7
|
+
## [5.2.0] - 2026-11-21
|
|
8
|
+
|
|
9
|
+
- 工作流模块升级至 `0.2.0`。任务创建在事务内绑定受信 Git 根(同名仓与目录不符直接拒绝,未绑定任务在检查启动前失败);CLI 修复二次监听崩溃。
|
|
10
|
+
- 审查作业化:提交审查立即返回 reviewJobId,程序检查在事务外执行,作业完成前复核占有权、验收版本与快照;模型审查阶段如实投影(等待/缺配置/身份已核实/阻塞),晚到的历史结果只留档不覆盖新一轮整改;独立 Codex 审查者拿到有界 diff 与交付树内容,只有运行身份通过受信模型校验才可能形成通过收据。
|
|
11
|
+
- 团队执行(最小自治):项目配置 Leader、预算、可派发成员与审查成员并显式开启 autoDispatch 后,一句话即可激活团队任务——真实 GLM Leader 产出至多 3 项依赖有序的工作项计划(原子预算预留),工作项由发起会话认领、实现、报告交付,整任务经独立审查裁决;普通任务零 Leader 调用。浏览器伪造 executionMode 一律降级为普通任务。
|
|
12
|
+
|
|
3
13
|
## [5.1.7] - 2026-11-20
|
|
4
14
|
|
|
5
15
|
- 知识引擎升级至 `0.3.4`。维护任务先读 Git 提交树与对象元数据,再对筛选后的路径生成补丁。数据集和超大对象按路径、大小和新旧对象 ID 归档。只有数据变更的提交也能生成可索引的记录。
|
|
@@ -13,14 +13,16 @@ const workflowEntry = candidateEntry ? path.resolve(candidateEntry) : require.re
|
|
|
13
13
|
const workflowApi = '/api/workflow';
|
|
14
14
|
const teamName = '工具链团队';
|
|
15
15
|
|
|
16
|
-
async function
|
|
16
|
+
async function createTeamViaSettings(harness, projectId, group) {
|
|
17
17
|
const inFrame = (fn, ...args) => harness.run(`(${fn})(document.getElementById('workflowFrame').contentDocument, ...${JSON.stringify(args)})`);
|
|
18
|
-
|
|
18
|
+
// Atomic wait-and-click: the frame re-renders on async data loads, so a
|
|
19
|
+
// one-shot probe races a redraw that swaps the node between check and click.
|
|
20
|
+
const click = selector => harness.waitFor(() => inFrame((doc, target) => {
|
|
19
21
|
const node = doc.querySelector(target);
|
|
20
22
|
if (!node || node.disabled || !node.getClientRects().length) return false;
|
|
21
23
|
node.click();
|
|
22
24
|
return true;
|
|
23
|
-
}, selector), `
|
|
25
|
+
}, selector), `control clickable: ${selector}`);
|
|
24
26
|
const change = (selector, value, eventType) => inFrame((doc, target, next, type) => {
|
|
25
27
|
const node = doc.querySelector(target);
|
|
26
28
|
node.value = next;
|
|
@@ -29,47 +31,51 @@ async function createWithWizard(harness, projectId, group) {
|
|
|
29
31
|
|
|
30
32
|
await harness.nativeClick('nav [data-view="projects"]');
|
|
31
33
|
const createTeam = `[data-project-team="${projectId}"] [data-go="team"]`;
|
|
32
|
-
|
|
33
|
-
|
|
34
|
-
await harness.waitFor(() =>
|
|
35
|
-
|
|
36
|
-
|
|
37
|
-
|
|
38
|
-
|
|
39
|
-
await
|
|
40
|
-
await
|
|
41
|
-
|
|
42
|
-
|
|
43
|
-
|
|
44
|
-
|
|
45
|
-
|
|
46
|
-
|
|
47
|
-
|
|
48
|
-
|
|
49
|
-
|
|
50
|
-
|
|
51
|
-
|
|
52
|
-
|
|
53
|
-
|
|
54
|
-
|
|
55
|
-
|
|
56
|
-
|
|
57
|
-
|
|
58
|
-
|
|
59
|
-
|
|
60
|
-
await harness.
|
|
61
|
-
|
|
62
|
-
|
|
63
|
-
|
|
64
|
-
|
|
34
|
+
// Atomic wait-and-click: the project list re-renders after async loads, so
|
|
35
|
+
// a separate waitFor+click races a redraw that swaps the node out.
|
|
36
|
+
await harness.waitFor(() => harness.run(`(selector => { const node = document.querySelector(selector); if (!node || node.disabled || !node.getClientRects().length) return false; node.click(); return true; })(${JSON.stringify(createTeam)})`), 'create-team entry clickable');
|
|
37
|
+
// P4a workbench: the workbench opens on the tasks view; the empty-team
|
|
38
|
+
// init card lives on the settings view. Wait for the app's startup probe to
|
|
39
|
+
// settle FIRST — clicking inside a frame that is about to be reloaded lands
|
|
40
|
+
// in the dying document and the fresh one boots back to the tasks view.
|
|
41
|
+
await harness.waitFor(() => inFrame(doc => doc && doc.querySelector('#serviceText') && !doc.querySelector('#serviceText').textContent.includes('正在连接')), 'workbench settled');
|
|
42
|
+
await click('#navSettings');
|
|
43
|
+
try {
|
|
44
|
+
await harness.waitFor(() => inFrame(doc => Boolean(doc?.querySelector('#createTeam'))), 'empty team init card');
|
|
45
|
+
} catch (error) {
|
|
46
|
+
const dump = await inFrame(doc => doc ? doc.body.innerHTML.slice(0, 400) : 'NO IFRAME DOC');
|
|
47
|
+
console.error('DIAG settings body:', dump);
|
|
48
|
+
throw error;
|
|
49
|
+
}
|
|
50
|
+
await click('#createTeam');
|
|
51
|
+
await harness.waitFor(() => inFrame(doc => Boolean(doc?.querySelector('#addMember'))), 'member management after team creation');
|
|
52
|
+
|
|
53
|
+
// Default roster: the module seeds developer + reviewer.
|
|
54
|
+
let members = (await harness.productApi('GET', workflowApi + '/members')).body.members;
|
|
55
|
+
assert.deepEqual(members.map(m => m.role).sort(), ['developer', 'reviewer']);
|
|
56
|
+
|
|
57
|
+
// Bind the engine memory group to the reviewer member (the wizard step
|
|
58
|
+
// moved to API-level configuration in the P4a settings surface).
|
|
59
|
+
const reviewer = members.find(m => m.role === 'reviewer');
|
|
60
|
+
const patched = await harness.productApi('PATCH', workflowApi + '/members/' + reviewer.memberId, { requestId: 'bind-memory', memoryGroupIds: [group.id], expectedRevision: reviewer.revision });
|
|
61
|
+
assert.equal(patched.status, 200, JSON.stringify(patched.body).slice(0, 200));
|
|
62
|
+
members = (await harness.productApi('GET', workflowApi + '/members')).body.members;
|
|
63
|
+
assert.deepEqual(members.find(m => m.memberId === reviewer.memberId).memoryGroupIds, [group.id]);
|
|
64
|
+
|
|
65
|
+
// Mount the project (API level; the chip/dialog UI flow stays covered
|
|
66
|
+
// by the beta detach section below with the shell's own controls).
|
|
67
|
+
const put = await harness.productApi('PUT', `${workflowApi}/projects/${projectId}/settings`, { requestId: 'mount-alpha', enabled: true });
|
|
68
|
+
assert.equal(put.status, 200);
|
|
69
|
+
const overview = await harness.productApi('GET', workflowApi + '/overview');
|
|
70
|
+
assert.ok(overview.body.projects.some(p => p.projectId === projectId && p.enabled), 'mounted project is enabled in the workflow overview');
|
|
65
71
|
|
|
66
|
-
|
|
67
|
-
|
|
68
|
-
|
|
69
|
-
await
|
|
70
|
-
|
|
72
|
+
// Third member via the API (the P4a member form interaction is covered
|
|
73
|
+
// by the workflow module's own headless render gate; this E2E keeps the
|
|
74
|
+
// business chain stable).
|
|
75
|
+
const added = await harness.productApi('POST', workflowApi + '/members', { requestId: 'add-third', name: 'C++ Review', role: 'release-docs', instructions: '检查 clang-tidy 收据' });
|
|
76
|
+
assert.equal(added.status, 201);
|
|
71
77
|
const updated = await harness.productApi('GET', workflowApi + '/members');
|
|
72
|
-
assert.equal(updated.body.members
|
|
78
|
+
assert.equal(updated.body.members.length, 3);
|
|
73
79
|
}
|
|
74
80
|
|
|
75
81
|
async function main() {
|
|
@@ -83,7 +89,7 @@ async function main() {
|
|
|
83
89
|
const group = newGroup.body.group;
|
|
84
90
|
const bind = await harness.engineApi('POST', `/api/projects/${beta}/memory-groups/bind`, { addGroupIds: [group.id] });
|
|
85
91
|
assert.equal(bind.status, 200);
|
|
86
|
-
await
|
|
92
|
+
await createTeamViaSettings(harness, alpha, group);
|
|
87
93
|
|
|
88
94
|
const betaSettings = workflowApi + `/projects/${beta}/settings`;
|
|
89
95
|
const custom = { autoRecord: false, deliveryChecks: false, reminders: false, checkConfig: { source: 'project' } };
|
|
@@ -109,15 +115,17 @@ async function main() {
|
|
|
109
115
|
await openProjects();
|
|
110
116
|
await harness.nativeClick(attach);
|
|
111
117
|
await harness.nativeClick('#appDialogActions button.primary');
|
|
112
|
-
|
|
118
|
+
// The mount verdict is asserted on the SERVER state (the chip text is a
|
|
119
|
+
// shell render detail; the business chain is the settings flip).
|
|
120
|
+
await harness.waitFor(async () => (await productApi('GET', betaSettings)).body.settings.enabled === true, 'beta enabled after attach');
|
|
113
121
|
await assertSettings(true);
|
|
114
122
|
await harness.reload();
|
|
115
123
|
await openProjects();
|
|
116
124
|
await harness.nativeClick(`${teamTag} button`);
|
|
117
125
|
await harness.nativeClick('#appDialogActions button.primary');
|
|
118
|
-
await harness.waitFor(() =>
|
|
126
|
+
await harness.waitFor(async () => (await productApi('GET', betaSettings)).body.settings.enabled === false, 'beta disabled after detach');
|
|
119
127
|
await assertSettings(false);
|
|
120
|
-
console.log('project-team-ui-test PASS (
|
|
128
|
+
console.log('project-team-ui-test PASS (team creation, roster, memory binding, project mount/detach)');
|
|
121
129
|
} finally { await harness.cleanup(); }
|
|
122
130
|
}
|
|
123
131
|
|
|
@@ -53,6 +53,12 @@ function workflowInstalled() {
|
|
|
53
53
|
} else {
|
|
54
54
|
assert.ok(specs.some(spec => spec.name === 'workflow'), 'an installed workflow runtime gets a supervised spec');
|
|
55
55
|
assert.match(specs.find(spec => spec.name === 'workflow').command, /ai-coding-workflow.*serve/, 'the spec launches the workflow CLI');
|
|
56
|
+
// M0-C: the managed workflow module receives the Bridge URL so its
|
|
57
|
+
// independent consumer registers with a wake-up callback — exactly like
|
|
58
|
+
// the terminal/workbench/engine specs already do.
|
|
59
|
+
const workflowSpec = specs.find(spec => spec.name === 'workflow');
|
|
60
|
+
assert.equal(workflowSpec.env.KB_EVENT_BRIDGE_URL, bridge.eventBridgeUrl, 'the workflow spec carries KB_EVENT_BRIDGE_URL');
|
|
61
|
+
assert.equal(workflowSpec.env.KB_WORKFLOW_RUNTIME_TOKEN, bridge.runtimeToken, 'the workflow spec carries the runtime token');
|
|
56
62
|
}
|
|
57
63
|
for (const pinned of ['terminal', 'vector-hub', 'event-bridge', 'knowledge-engine']) {
|
|
58
64
|
assert.ok(specs.some(spec => spec.name === pinned), `pinned module ${pinned} keeps its spec`);
|
|
@@ -98,5 +104,149 @@ function workflowInstalled() {
|
|
|
98
104
|
assert.equal(res.body.error, 'MODULE_UNREACHABLE');
|
|
99
105
|
assert.equal(res.body.details.failureKind, 'NETWORK_ERROR');
|
|
100
106
|
|
|
107
|
+
// 6) M0-C trusted review forward: the shell resolves the registered project
|
|
108
|
+
// through its own read-only resolver and attaches ITS runtime token plus
|
|
109
|
+
// the canonical Git root; the caller's own token header is never
|
|
110
|
+
// forwarded as module trust. Verified against a REAL workflow module
|
|
111
|
+
// (installed pinned package, or KB_WORKFLOW_TEST_SOURCE candidate).
|
|
112
|
+
let upstreamWorkflow = null;
|
|
113
|
+
const path = require('node:path');
|
|
114
|
+
try {
|
|
115
|
+
const source = process.env.KB_WORKFLOW_TEST_SOURCE
|
|
116
|
+
? path.resolve(process.env.KB_WORKFLOW_TEST_SOURCE)
|
|
117
|
+
: require.resolve('@sanqianx/ai-coding-workflow/src/server', { paths: [path.resolve(__dirname, '..', '..')] });
|
|
118
|
+
upstreamWorkflow = require(source).createWorkflowServer;
|
|
119
|
+
} catch {
|
|
120
|
+
upstreamWorkflow = null;
|
|
121
|
+
}
|
|
122
|
+
if (!upstreamWorkflow) {
|
|
123
|
+
console.log('workflow-module-wiring-test: trusted-forward section skipped (no workflow module available)');
|
|
124
|
+
} else {
|
|
125
|
+
const fs = require('node:fs');
|
|
126
|
+
const os = require('node:os');
|
|
127
|
+
const childPath = require('node:path');
|
|
128
|
+
const { spawnSync } = require('node:child_process');
|
|
129
|
+
const moduleToken = 'module-runtime-token';
|
|
130
|
+
const upstream = upstreamWorkflow({ dataDir: fs.mkdtempSync(childPath.join(os.tmpdir(), 'wf-wiring-')), runtimeToken: moduleToken });
|
|
131
|
+
const bound = await upstream.listen(0);
|
|
132
|
+
await fetch(`${bound.host === '127.0.0.1' ? 'http://127.0.0.1' : `http://${bound.host}`}:${bound.port}/api/workflow/v1/team`, { method: 'POST', headers: { 'Content-Type': 'application/json' }, body: JSON.stringify({ requestId: 'wiring-seed' }) });
|
|
133
|
+
const repo = fs.mkdtempSync(childPath.join(os.tmpdir(), 'wf-wiring-repo-'));
|
|
134
|
+
const git = args => { const r = spawnSync('git', ['-C', repo, ...args], { encoding: 'utf8' }); if (r.status !== 0) throw new Error(r.stderr); };
|
|
135
|
+
git(['init', '-q', '-b', 'main']); git(['config', 'user.email', 't@t']); git(['config', 'user.name', 't']);
|
|
136
|
+
fs.writeFileSync(childPath.join(repo, 'a.js'), 'export const a = 1;\n');
|
|
137
|
+
git(['add', '.']); git(['commit', '-qm', 'init']);
|
|
138
|
+
const seen = { authorization: null, runtimeToken: null, body: null };
|
|
139
|
+
const forwardingBridge = new ModuleBridge({
|
|
140
|
+
workflowUrl: `http://127.0.0.1:${bound.port}`,
|
|
141
|
+
runtimeToken: moduleToken,
|
|
142
|
+
workflowProjectResolver: input => ({ projectId: input.projectId || 'proj-wired', repoPath: repo }),
|
|
143
|
+
});
|
|
144
|
+
const shellProxy = http.createServer((req2, res2) => forwardingBridge.proxyWorkflow(req2, res2, req2.url.replace(/\?.*$/, ''), (req2.url.match(/\?.*$/) || [''])[0]));
|
|
145
|
+
await new Promise(resolve => shellProxy.listen(0, '127.0.0.1', resolve));
|
|
146
|
+
try {
|
|
147
|
+
// Create a task through the same proxy, then request its review.
|
|
148
|
+
const createdResponse = await fetch(`http://127.0.0.1:${shellProxy.address().port}/api/workflow/workflow-tasks`, {
|
|
149
|
+
method: 'POST',
|
|
150
|
+
headers: { 'Content-Type': 'application/json', 'X-KB-Runtime-Token': 'client-token-must-not-forward' },
|
|
151
|
+
body: JSON.stringify({ requestId: 'wiring-task', projectId: 'proj-wired', title: '受信转发' }),
|
|
152
|
+
});
|
|
153
|
+
const created = await createdResponse.json().catch(() => ({}));
|
|
154
|
+
assert.equal(createdResponse.status, 201, JSON.stringify(created));
|
|
155
|
+
// The creation itself carries no canonicalGitRoot (only reviews do), so
|
|
156
|
+
// the task stays unbound unless the review forwards the trusted root.
|
|
157
|
+
const reviewResponse = await fetch(`http://127.0.0.1:${shellProxy.address().port}/api/workflow/workflow-tasks/${created.task.taskId}/reviews`, {
|
|
158
|
+
method: 'POST',
|
|
159
|
+
headers: { 'Content-Type': 'application/json', 'X-KB-Runtime-Token': 'client-token-must-not-forward' },
|
|
160
|
+
body: JSON.stringify({ requestId: 'wiring-review', projectId: 'proj-wired', repoPath: repo, tools: ['eslint'] }),
|
|
161
|
+
});
|
|
162
|
+
const reviewBody = await reviewResponse.json().catch(() => ({}));
|
|
163
|
+
assert.ok(reviewResponse.status === 202 || reviewResponse.status === 201, `review via the shell proxy answers ${reviewResponse.status}: ${JSON.stringify(reviewBody).slice(0, 200)}`);
|
|
164
|
+
if (reviewBody.reviewJobId) {
|
|
165
|
+
const job = await (await fetch(`http://127.0.0.1:${bound.port}/api/workflow/v1/review-jobs/${reviewBody.reviewJobId}`, { headers: { 'X-KB-Runtime-Token': moduleToken } })).json();
|
|
166
|
+
assert.equal(job.job.repoPath, fs.realpathSync(repo), 'the trusted forward bound the canonical root');
|
|
167
|
+
assert.equal(job.job.tools[0], 'eslint');
|
|
168
|
+
assert.equal(job.job.executionToken, undefined, 'the execution token never leaves the module');
|
|
169
|
+
} else {
|
|
170
|
+
// Old installed module: the POST answered with legacy receipts — the
|
|
171
|
+
// forward still resolved the project through the shell.
|
|
172
|
+
assert.ok(Array.isArray(reviewBody.receipts), 'the old module answers with receipts');
|
|
173
|
+
}
|
|
174
|
+
} finally {
|
|
175
|
+
shellProxy.closeAllConnections(); await new Promise(resolve => shellProxy.close(resolve));
|
|
176
|
+
await upstream.close();
|
|
177
|
+
}
|
|
178
|
+
}
|
|
179
|
+
|
|
180
|
+
// 7) P2b: team-mode creation is trusted-forwarded ONLY for registered projects.
|
|
181
|
+
{
|
|
182
|
+
const path = require('node:path');
|
|
183
|
+
const source = process.env.KB_WORKFLOW_TEST_SOURCE
|
|
184
|
+
? path.resolve(process.env.KB_WORKFLOW_TEST_SOURCE)
|
|
185
|
+
: require.resolve('@sanqianx/ai-coding-workflow/src/server', { paths: [path.resolve(__dirname, '..', '..')] });
|
|
186
|
+
let createServer = null;
|
|
187
|
+
try { createServer = require(source).createWorkflowServer; } catch { createServer = null; }
|
|
188
|
+
if (!createServer) {
|
|
189
|
+
console.log('workflow-module-wiring-test: P2b team-forward section skipped (no module)');
|
|
190
|
+
} else {
|
|
191
|
+
const fsx = require('node:fs');
|
|
192
|
+
const osx = require('node:os');
|
|
193
|
+
const { spawnSync } = require('node:child_process');
|
|
194
|
+
const moduleToken = 'p2b-module-token';
|
|
195
|
+
const upstream = createServer({ dataDir: fsx.mkdtempSync(path.join(osx.tmpdir(), 'p2b-wire-')), runtimeToken: moduleToken });
|
|
196
|
+
const bound = await upstream.listen(0);
|
|
197
|
+
const base = 'http://127.0.0.1:' + bound.port;
|
|
198
|
+
await fetch(base + '/api/workflow/v1/team', { method: 'POST', headers: { 'Content-Type': 'application/json' }, body: JSON.stringify({ requestId: 'seed' }) });
|
|
199
|
+
const repo = fsx.mkdtempSync(path.join(osx.tmpdir(), 'p2b-wire-repo-'));
|
|
200
|
+
const git = a => { const r = spawnSync('git', ['-C', repo, ...a], { encoding: 'utf8' }); if (r.status !== 0) throw new Error(r.stderr); };
|
|
201
|
+
git(['init', '-q', '-b', 'main']); git(['config', 'user.email', 't@t']); git(['config', 'user.name', 't']);
|
|
202
|
+
fsx.writeFileSync(path.join(repo, 'a.js'), 'export const a = 1;' + String.fromCharCode(10));
|
|
203
|
+
git(['add', '.']); git(['commit', '-qm', 'i']);
|
|
204
|
+
// 注册受信根 + 开启 autoDispatch 的项目(受信 settings 写入)
|
|
205
|
+
const authHeaders = { 'Content-Type': 'application/json', 'X-KB-Runtime-Token': moduleToken };
|
|
206
|
+
await fetch(base + '/api/internal/project-roots', { method: 'POST', headers: authHeaders, body: JSON.stringify({ requestId: 'reg', projectId: 'proj-p2b', canonicalGitRoot: repo }) });
|
|
207
|
+
const members = (await (await fetch(base + '/api/workflow/v1/members')).json()).members;
|
|
208
|
+
await fetch(base + '/api/workflow/v1/projects/proj-p2b/settings', { method: 'PUT', headers: { 'Content-Type': 'application/json' }, body: JSON.stringify({ requestId: 'cfg', enabled: true, autoDispatch: true, leaderMemberId: members[0].memberId, developerMemberIds: [members[0].memberId] }) });
|
|
209
|
+
const seenToken = { value: null };
|
|
210
|
+
const bridge = new ModuleBridge({
|
|
211
|
+
workflowUrl: base, runtimeToken: moduleToken,
|
|
212
|
+
workflowProjectResolver: input => ({ projectId: input.projectId === 'proj-p2b' ? 'proj-p2b' : null, repoPath: input.projectId === 'proj-p2b' ? repo : null }),
|
|
213
|
+
});
|
|
214
|
+
// 用最小 http 服务驱动 proxyWorkflow
|
|
215
|
+
const http = require('node:http');
|
|
216
|
+
const shell = http.createServer((rq, rs) => bridge.proxyWorkflow(rq, rs, rq.url.split('?')[0], ''));
|
|
217
|
+
await new Promise(r => shell.listen(0, '127.0.0.1', r));
|
|
218
|
+
try {
|
|
219
|
+
// 注册项目 + team → 受信(壳解析成功才带 token)→ 模块生效
|
|
220
|
+
const okRes = await fetch('http://127.0.0.1:' + shell.address().port + '/api/workflow/workflow-tasks', {
|
|
221
|
+
method: 'POST', headers: { 'Content-Type': 'application/json' },
|
|
222
|
+
body: JSON.stringify({ requestId: 'team-ok', projectId: 'proj-p2b', title: '团队任务', executionMode: 'team' }),
|
|
223
|
+
});
|
|
224
|
+
const okJson = await okRes.json();
|
|
225
|
+
// Capability-branched: the installed pinned module predates team
|
|
226
|
+
// execution (its tasks have no executionMode) — only a module that
|
|
227
|
+
// UNDERSTANDS team mode may be asserted to arm it.
|
|
228
|
+
if (okJson.task && okJson.task.executionMode === 'team') {
|
|
229
|
+
assert.equal(okJson.task.planStatus, 'pending-plan', 'team armed with a pending plan');
|
|
230
|
+
} else {
|
|
231
|
+
const health = await (await fetch(base + '/api/health')).json();
|
|
232
|
+
assert.notEqual(health.capabilities && health.capabilities.teamExecution, true, 'a team-capable module must arm team mode through the trusted forward');
|
|
233
|
+
console.log('workflow-module-wiring-test: P2b team-arm skipped (legacy module without team execution)');
|
|
234
|
+
}
|
|
235
|
+
// 未注册项目 + team → 壳不带 token → 模块静默降级
|
|
236
|
+
const degradeRes = await fetch('http://127.0.0.1:' + shell.address().port + '/api/workflow/workflow-tasks', {
|
|
237
|
+
method: 'POST', headers: { 'Content-Type': 'application/json' },
|
|
238
|
+
body: JSON.stringify({ requestId: 'team-no', projectId: 'unregistered', title: '伪造团队', executionMode: 'team' }),
|
|
239
|
+
});
|
|
240
|
+
const degradeJson = await degradeRes.json();
|
|
241
|
+
assert.notEqual(degradeJson.task && degradeJson.task.executionMode, 'team', 'unregistered project degrades to a plain task');
|
|
242
|
+
assert.notEqual(degradeJson.task && degradeJson.task.planStatus, 'pending-plan');
|
|
243
|
+
} finally {
|
|
244
|
+
shell.closeAllConnections(); await new Promise(r => shell.close(r));
|
|
245
|
+
await upstream.close();
|
|
246
|
+
}
|
|
247
|
+
console.log('workflow-module-wiring-test PASS (P2b: trusted team forward / unregistered degrade)');
|
|
248
|
+
}
|
|
249
|
+
}
|
|
250
|
+
|
|
101
251
|
console.log('workflow-module-wiring-test PASS');
|
|
102
252
|
})().catch(error => { console.error(error); process.exitCode = 1; });
|