@fish-under-sea/dsh-agent-teams-fish 1.0.2 → 2.0.0
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/NOTICE.md +13 -7
- package/README.en.md +20 -12
- package/README.md +20 -12
- package/compatibility.json +82 -46
- package/icon.png +0 -0
- package/lib/artifacts.js +148 -25
- package/lib/client/ActivityPanel.js +26 -5
- package/lib/client/WorkspaceActivity.js +6 -4
- package/lib/client/activity-monitor.js +113 -41
- package/lib/client/locales.js +14 -0
- package/lib/client.js +433 -199
- package/lib/client.js.map +1 -1
- package/lib/command.js +7 -4
- package/lib/git-artifact-stamp.json +2 -2
- package/lib/harness-compat.js +120 -62
- package/lib/index.js +7 -10
- package/lib/mailbox.js +15 -5
- package/lib/members.js +221 -154
- package/lib/snapshot.js +15 -10
- package/lib/state.js +41 -8
- package/lib/tools.js +123 -64
- package/lib/types/artifacts.d.ts +6 -3
- package/lib/types/client/activity-monitor.d.ts +13 -4
- package/lib/types/client/locales.d.ts +14 -0
- package/lib/types/harness-compat.d.ts +63 -16
- package/lib/types/mailbox.d.ts +2 -0
- package/lib/types/members.d.ts +5 -17
- package/lib/types/snapshot.d.ts +12 -7
- package/lib/types/state.d.ts +10 -3
- package/lib/types/types.d.ts +5 -0
- package/lib/types/web-routes.d.ts +2 -0
- package/lib/types/workspace-audit-service.d.ts +35 -0
- package/lib/types/workspace-audit-worker.d.ts +1 -0
- package/lib/web-routes.js +31 -0
- package/lib/workspace-audit-service.js +165 -0
- package/lib/workspace-audit-worker.js +11 -0
- package/lib/workspace-audit.js +6 -5
- package/locale/en.json +6 -0
- package/locale/zh.json +6 -0
- package/package.json +69 -64
- package/pnpm-workspace.yaml +306 -273
- package/release-notes/v0.1.25.md +16 -0
- package/release-notes/v0.1.26.md +19 -0
- package/release-notes/v0.1.27.md +42 -0
- package/release-notes/v0.1.28.md +45 -0
- package/release-notes/v0.1.29.md +23 -0
- package/release-notes/v1.1.0.md +42 -0
- package/release-notes/v2.0.0.md +17 -0
- package/scripts/artwork-role-match.test.mjs +517 -0
- package/scripts/capabilities.test.mjs +301 -0
- package/scripts/check-install-channel.mjs +55 -0
- package/scripts/check-install-channel.test.mjs +39 -0
- package/scripts/clean-build.mjs +14 -0
- package/scripts/client-harness-migration.test.mjs +46 -0
- package/scripts/compatibility.mjs +20 -0
- package/scripts/compatibility.test.mjs +187 -0
- package/scripts/corrupt-teamjson.test.mjs +180 -0
- package/scripts/custom-artwork.test.mjs +273 -0
- package/scripts/fallback-tdd.mjs +61 -0
- package/scripts/fixtures/harness-benchmark-scope.mjs +16 -0
- package/scripts/fixtures/harness-benchmark-scope.test.mjs +18 -0
- package/scripts/fixtures/harness-complex-case.mjs +201 -0
- package/scripts/fixtures/harness-complex-case.test.mjs +21 -0
- package/scripts/fixtures/harness-complex-oracle.mjs +63 -0
- package/scripts/fixtures/harness-issue-case.mjs +51 -0
- package/scripts/fixtures/harness-issue159-case.mjs +28 -0
- package/scripts/fixtures/harness-model-case.mjs +127 -0
- package/scripts/fixtures/harness-model-case.test.mjs +37 -0
- package/scripts/fixtures/harness-model-driver.mjs +100 -0
- package/scripts/fixtures/harness-runtime-credentials.mjs +23 -0
- package/scripts/fixtures/harness-runtime-entry.mjs +171 -0
- package/scripts/fixtures/harness-runtime-idle.mjs +42 -0
- package/scripts/fixtures/harness-runtime-llm.mjs +193 -0
- package/scripts/fixtures/harness-runtime-protocol.mjs +187 -0
- package/scripts/fixtures/harness-runtime-resume.mjs +24 -0
- package/scripts/fixtures/harness-runtime-stability.mjs +282 -0
- package/scripts/fixtures/harness-runtime-tools.mjs +13 -0
- package/scripts/fixtures/harness-runtime-web-approval.mjs +341 -0
- package/scripts/fixtures/issue-336-audit-worker.mjs +18 -0
- package/scripts/git-artifacts.mjs +64 -0
- package/scripts/git-artifacts.test.mjs +32 -0
- package/scripts/harness-compat-tdd.mjs +492 -0
- package/scripts/harness-issue-verify.mjs +26 -0
- package/scripts/harness-model-benchmark.mjs +163 -0
- package/scripts/harness-runtime-platform.test.mjs +31 -0
- package/scripts/harness-runtime-scenarios.mjs +297 -0
- package/scripts/harness-runtime-verify.mjs +169 -0
- package/scripts/harness-source-verify.mjs +211 -0
- package/scripts/harness-source-verify.test.mjs +97 -0
- package/scripts/harness-validation.mjs +68 -0
- package/scripts/harness-validation.test.mjs +95 -0
- package/scripts/http-body.test.mjs +72 -0
- package/scripts/import-vendor-artwork.mjs +78 -0
- package/scripts/inline-plan-blank-optional-tdd.mjs +121 -0
- package/scripts/issue-159.test.mjs +78 -0
- package/scripts/issue-188.test.mjs +148 -0
- package/scripts/issue-189.test.mjs +100 -0
- package/scripts/issue-203-card.test.mjs +181 -0
- package/scripts/issue-205.test.mjs +163 -0
- package/scripts/issue-234.test.mjs +424 -0
- package/scripts/issue-236-stale-module.test.mjs +63 -0
- package/scripts/issue-236.test.mjs +59 -0
- package/scripts/issue-262.test.mjs +98 -0
- package/scripts/issue-336.test.mjs +404 -0
- package/scripts/legacy-session-source-repair.test.mjs +201 -0
- package/scripts/lifecycle-verify.mjs +1573 -0
- package/scripts/lineage-identity.test.mjs +77 -0
- package/scripts/member-failure-tdd.mjs +451 -0
- package/scripts/member-spawn-recovery.test.mjs +92 -0
- package/scripts/quality-gates-amend.test.mjs +161 -0
- package/scripts/quality-gates-content-bound.test.mjs +572 -0
- package/scripts/quality-gates-cross-binding.test.mjs +184 -0
- package/scripts/quality-gates-excluded-scope.test.mjs +163 -0
- package/scripts/quality-gates-repair-scope.test.mjs +143 -0
- package/scripts/quality-gates-repair-wiring.test.mjs +189 -0
- package/scripts/quality-gates-tdd.mjs +1238 -0
- package/scripts/quality-gates-work-order.test.mjs +494 -0
- package/scripts/readme-version.mjs +89 -0
- package/scripts/readme-version.test.mjs +77 -0
- package/scripts/release-metadata.mjs +45 -0
- package/scripts/release-metadata.test.mjs +66 -0
- package/scripts/scoped-release.test.mjs +52 -0
- package/scripts/stability-tdd.mjs +144 -0
- package/scripts/stress-verify.mjs +548 -0
- package/scripts/symlink-support.mjs +46 -0
- package/scripts/sync-skill.mjs +103 -0
- package/scripts/tool-policies.test.mjs +280 -0
- package/scripts/update-skills.mjs +105 -0
- package/scripts/update-skills.test.mjs +79 -0
- package/scripts/upgrade-status.mjs +66 -0
- package/scripts/upgrade-status.test.mjs +83 -0
- package/scripts/verify-package.mjs +73 -0
- package/scripts/verify.mjs +2199 -0
- package/scripts/web-routes-verify.mjs +142 -0
- package/scripts/workspace-activity.test.mjs +346 -0
- package/scripts/workspace-summary.test.mjs +49 -0
- package/src/artifacts.ts +487 -0
- package/src/artwork-source.ts +262 -0
- package/src/capabilities.ts +113 -0
- package/src/client/ActivityPanel.module.css +2390 -0
- package/src/client/ActivityPanel.tsx +1507 -0
- package/src/client/AgentTeamsCard.module.css +148 -0
- package/src/client/AgentTeamsCard.tsx +155 -0
- package/src/client/StagingPlanEditor.tsx +829 -0
- package/src/client/TeamChatEntry.tsx +27 -0
- package/src/client/WorkspaceActivity.module.css +41 -0
- package/src/client/WorkspaceActivity.tsx +137 -0
- package/src/client/activity-model.ts +372 -0
- package/src/client/activity-monitor.ts +440 -0
- package/src/client/agent-teams-card-definition.ts +250 -0
- package/src/client/artwork.ts +374 -0
- package/src/client/icons.tsx +17 -0
- package/src/client/index.tsx +140 -0
- package/src/client/locales.ts +481 -0
- package/src/client/panel-geometry.ts +194 -0
- package/src/client/session-navigation.ts +73 -0
- package/src/client/workspace-state.ts +52 -0
- package/src/command.ts +145 -0
- package/src/css-modules.d.ts +4 -0
- package/src/event-types.ts +177 -0
- package/src/events.ts +78 -0
- package/src/harness-compat.ts +570 -0
- package/src/index.ts +599 -0
- package/src/lineage.ts +248 -0
- package/src/mailbox.ts +185 -0
- package/src/members.ts +1230 -0
- package/src/profiles.ts +765 -0
- package/src/quality-gates.ts +2124 -0
- package/src/scheduler.ts +554 -0
- package/src/snapshot.ts +333 -0
- package/src/state.ts +1317 -0
- package/src/tool-names.ts +14 -0
- package/src/tool-policies.ts +219 -0
- package/src/tools.ts +2939 -0
- package/src/types.ts +414 -0
- package/src/web-routes.ts +128 -0
- package/src/workspace-audit-service.ts +182 -0
- package/src/workspace-audit-worker.ts +12 -0
- package/src/workspace-audit.ts +57 -0
|
@@ -0,0 +1,95 @@
|
|
|
1
|
+
import assert from 'node:assert/strict'
|
|
2
|
+
import { mkdtempSync, mkdirSync, writeFileSync, rmSync } from 'node:fs'
|
|
3
|
+
import { tmpdir } from 'node:os'
|
|
4
|
+
import { join } from 'node:path'
|
|
5
|
+
import test from 'node:test'
|
|
6
|
+
import { policy } from './compatibility.mjs'
|
|
7
|
+
import { hostVerification, runtimeTargets, requiredRuntimeScenarios, validateRuntimeReport, validateRuntimeReports } from './harness-validation.mjs'
|
|
8
|
+
import { runPluginInstallation } from './harness-runtime-scenarios.mjs'
|
|
9
|
+
|
|
10
|
+
const futureVersion = '0.2.1-rc.999' // Fictional regression input, never a support claim.
|
|
11
|
+
const future = { ...policy, supportedHosts: [...policy.supportedHosts, { version: futureVersion, track: 'preview' }] }
|
|
12
|
+
const expected = { pluginVersion: '0.1.26', artifactSha256: 'a'.repeat(64) }
|
|
13
|
+
function reportFor(target, install = true) {
|
|
14
|
+
return { passed: true, version: target.host, platform: target.os === 'windows-latest' ? 'win32' : 'linux', ...expected,
|
|
15
|
+
runs: [...requiredRuntimeScenarios, ...(install ? ['plugin-manager-install'] : [])].map(scenario => ({ scenario, passed: true })) }
|
|
16
|
+
}
|
|
17
|
+
|
|
18
|
+
test('future targets automatically receive both platforms and a required install probe', () => {
|
|
19
|
+
assert.deepEqual(runtimeTargets(future).filter(t => t.host === futureVersion), [
|
|
20
|
+
{ host: futureVersion, os: 'ubuntu-latest' }, { host: futureVersion, os: 'windows-latest' },
|
|
21
|
+
])
|
|
22
|
+
assert.equal(hostVerification(futureVersion).pluginManagerInstall, true, 'Unlisted prequalification candidates must also exercise installation')
|
|
23
|
+
for (const target of runtimeTargets(future).filter(t => t.host === futureVersion)) {
|
|
24
|
+
assert.throws(() => validateRuntimeReport(reportFor(target, false), target, expected, future), /plugin-manager-install/)
|
|
25
|
+
assert.doesNotThrow(() => validateRuntimeReport(reportFor(target), target, expected, future))
|
|
26
|
+
}
|
|
27
|
+
})
|
|
28
|
+
|
|
29
|
+
test('historical coverage remains explicit without exempting adjacent or unknown versions', () => {
|
|
30
|
+
for (const host of ['0.2.1-rc.2', '0.2.1-rc.3']) {
|
|
31
|
+
for (const os of ['ubuntu-latest', 'windows-latest']) assert.ok(runtimeTargets().some(target => target.host === host && target.os === os))
|
|
32
|
+
}
|
|
33
|
+
const legacy = { host: '0.2.1-rc.1', os: 'ubuntu-latest' }
|
|
34
|
+
assert.ok(hostVerification(legacy.host).legacyDirectInstallReason)
|
|
35
|
+
assert.doesNotThrow(() => validateRuntimeReport(reportFor(legacy, false), legacy, expected))
|
|
36
|
+
for (const host of ['0.2.1-rc.2', '0.2.1-rc.3', futureVersion, '0.3.0']) assert.equal(hostVerification(host).pluginManagerInstall, true)
|
|
37
|
+
for (const version of ['latest', '*', futureVersion + '\n']) assert.throws(() => hostVerification(version), /exact host/)
|
|
38
|
+
for (const properties of [{ platforms: [] }, { platforms: ['windows-latest'] }, { platforms: ['ubuntu-latest', 'macos-latest'] }, { legacyDirectInstallReason: '' }]) {
|
|
39
|
+
const invalid = { ...policy, supportedHosts: policy.supportedHosts.map((host, i) => i ? host : { ...host, ...properties }) }
|
|
40
|
+
assert.throws(() => runtimeTargets(invalid))
|
|
41
|
+
}
|
|
42
|
+
})
|
|
43
|
+
|
|
44
|
+
test('missing scenarios, failed runs, wrong platform or a different candidate cannot pass', () => {
|
|
45
|
+
const target = { host: futureVersion, os: 'windows-latest' }
|
|
46
|
+
const valid = reportFor(target)
|
|
47
|
+
for (const scenario of [...requiredRuntimeScenarios, 'plugin-manager-install']) {
|
|
48
|
+
assert.throws(() => validateRuntimeReport({ ...valid, runs: valid.runs.filter(run => run.scenario !== scenario) }, target, expected, future), new RegExp(scenario))
|
|
49
|
+
}
|
|
50
|
+
for (const change of [{ passed: false }, { version: '0.2.1-rc.3' }, { platform: 'linux' }, { pluginVersion: 'old' }, { artifactSha256: 'b'.repeat(64) }, { runs: [...valid.runs, { scenario: 'extra', passed: false }] }]) {
|
|
51
|
+
assert.throws(() => validateRuntimeReport({ ...valid, ...change }, target, expected, future))
|
|
52
|
+
}
|
|
53
|
+
})
|
|
54
|
+
|
|
55
|
+
test('collection consumes the same platform plan and refuses missing Windows evidence', t => {
|
|
56
|
+
const root = mkdtempSync(join(tmpdir(), 'harness-evidence-'))
|
|
57
|
+
t.after(() => rmSync(root, { recursive: true, force: true }))
|
|
58
|
+
for (const target of runtimeTargets(future)) {
|
|
59
|
+
const directory = join(root, `harness-${target.os}-${target.host}`)
|
|
60
|
+
mkdirSync(directory)
|
|
61
|
+
writeFileSync(join(directory, 'result.json'), JSON.stringify(reportFor(target)))
|
|
62
|
+
}
|
|
63
|
+
assert.equal(validateRuntimeReports(root, expected, future), runtimeTargets(future).length)
|
|
64
|
+
rmSync(join(root, `harness-windows-latest-${futureVersion}`, 'result.json'))
|
|
65
|
+
assert.throws(() => validateRuntimeReports(root, expected, future), /ENOENT/)
|
|
66
|
+
})
|
|
67
|
+
|
|
68
|
+
test('real installation entry is invoked for an unknown candidate and preserves its failures', async t => {
|
|
69
|
+
const report = mkdtempSync(join(tmpdir(), 'harness-install-'))
|
|
70
|
+
t.after(() => rmSync(report, { recursive: true, force: true }))
|
|
71
|
+
let calls = 0
|
|
72
|
+
let exit = 0
|
|
73
|
+
let installedVersion = expected.pluginVersion
|
|
74
|
+
let timedOut = false
|
|
75
|
+
const options = { version: futureVersion, pluginVersion: expected.pluginVersion, artifact: join(report, 'candidate.tgz'), runtime: join(report, 'runtime'), report, environment: extra => extra,
|
|
76
|
+
async command(argv, cwd, env, label) {
|
|
77
|
+
calls++
|
|
78
|
+
assert.equal(label, 'plugin-manager-install')
|
|
79
|
+
assert.deepEqual(argv.slice(2), ['plugin', '--profile', 'web', 'add', '--save-exact', options.artifact])
|
|
80
|
+
const installed = join(env.DSH_HOME, 'profiles/web/node_modules/@nanmicoder/dsh-agent-teams')
|
|
81
|
+
mkdirSync(installed, { recursive: true })
|
|
82
|
+
writeFileSync(join(installed, 'package.json'), JSON.stringify({ version: installedVersion }))
|
|
83
|
+
return { code: exit, timedOut }
|
|
84
|
+
} }
|
|
85
|
+
assert.equal((await runPluginInstallation(options))[0].passed, true)
|
|
86
|
+
exit = 1
|
|
87
|
+
assert.equal((await runPluginInstallation(options))[0].passed, false, 'A leftover package must not hide CLI rejection')
|
|
88
|
+
exit = 0; installedVersion = '0.1.15'
|
|
89
|
+
assert.equal((await runPluginInstallation(options))[0].passed, false)
|
|
90
|
+
installedVersion = expected.pluginVersion; timedOut = true
|
|
91
|
+
assert.equal((await runPluginInstallation(options))[0].passed, false)
|
|
92
|
+
assert.equal(calls, 4)
|
|
93
|
+
assert.deepEqual(await runPluginInstallation({ ...options, version: '0.2.1-rc.1' }), [])
|
|
94
|
+
assert.equal(calls, 4, 'Historical limitation must not silently change coverage')
|
|
95
|
+
})
|
|
@@ -0,0 +1,72 @@
|
|
|
1
|
+
import assert from 'node:assert/strict'
|
|
2
|
+
import { createServer, request } from 'node:http'
|
|
3
|
+
import { once } from 'node:events'
|
|
4
|
+
import { PassThrough } from 'node:stream'
|
|
5
|
+
import test from 'node:test'
|
|
6
|
+
import { readJsonRequest, RequestBodyError } from '../lib/web-routes.js'
|
|
7
|
+
|
|
8
|
+
test('HTTP body reader returns 413 without losing the response or buffering the rest', async (t) => {
|
|
9
|
+
const server = createServer(async (req, res) => {
|
|
10
|
+
try {
|
|
11
|
+
const body = await readJsonRequest(req, 64)
|
|
12
|
+
res.writeHead(200, { 'content-type': 'application/json' })
|
|
13
|
+
res.end(JSON.stringify(body))
|
|
14
|
+
} catch (error) {
|
|
15
|
+
res.writeHead(error instanceof RequestBodyError ? error.status : 500)
|
|
16
|
+
res.end(error.message)
|
|
17
|
+
}
|
|
18
|
+
})
|
|
19
|
+
server.listen(0, '127.0.0.1')
|
|
20
|
+
await once(server, 'listening')
|
|
21
|
+
t.after(() => new Promise(resolve => {
|
|
22
|
+
server.closeAllConnections()
|
|
23
|
+
server.close(resolve)
|
|
24
|
+
}))
|
|
25
|
+
const url = `http://127.0.0.1:${server.address().port}`
|
|
26
|
+
// A client may keep a chunked upload open after crossing the limit. The
|
|
27
|
+
// rejection must be sent immediately, without waiting for its final chunk.
|
|
28
|
+
const openUpload = await new Promise((resolve, reject) => {
|
|
29
|
+
const req = request(url, { method: 'POST' }, response => {
|
|
30
|
+
response.resume()
|
|
31
|
+
response.on('end', () => {
|
|
32
|
+
req.destroy()
|
|
33
|
+
resolve(response.statusCode)
|
|
34
|
+
})
|
|
35
|
+
})
|
|
36
|
+
req.setTimeout(2_000, () => req.destroy(new Error('oversized upload did not receive a response')))
|
|
37
|
+
req.on('error', reject)
|
|
38
|
+
req.write('x'.repeat(65))
|
|
39
|
+
})
|
|
40
|
+
assert.equal(openUpload, 413)
|
|
41
|
+
const empty = await fetch(url, { method: 'POST' })
|
|
42
|
+
assert.equal(empty.status, 200)
|
|
43
|
+
assert.deepEqual(await empty.json(), {}, 'empty bodies retain the previous object default')
|
|
44
|
+
const exact = JSON.stringify({ value: 'a'.repeat(52) })
|
|
45
|
+
assert.equal(Buffer.byteLength(exact), 64)
|
|
46
|
+
const valid = await fetch(url, { method: 'POST', body: exact })
|
|
47
|
+
assert.equal(valid.status, 200)
|
|
48
|
+
assert.deepEqual(await valid.json(), JSON.parse(exact))
|
|
49
|
+
for (const body of [exact + ' ', JSON.stringify({ value: '汉'.repeat(22) }), 'x'.repeat(100_000)]) {
|
|
50
|
+
const response = await fetch(url, { method: 'POST', body })
|
|
51
|
+
assert.equal(response.status, 413)
|
|
52
|
+
assert.match(await response.text(), /too large/)
|
|
53
|
+
}
|
|
54
|
+
for (const body of ['null', '[]', '"scalar"', '{']) {
|
|
55
|
+
const response = await fetch(url, { method: 'POST', body })
|
|
56
|
+
assert.equal(response.status, 400)
|
|
57
|
+
await response.text()
|
|
58
|
+
}
|
|
59
|
+
const afterRejection = await fetch(url, { method: 'POST', body: '{"ok":true}' })
|
|
60
|
+
assert.equal(afterRejection.status, 200)
|
|
61
|
+
assert.deepEqual(await afterRejection.json(), { ok: true })
|
|
62
|
+
})
|
|
63
|
+
|
|
64
|
+
test('aborted body rejects and removes its buffering listeners', async () => {
|
|
65
|
+
const stream = new PassThrough()
|
|
66
|
+
const pending = readJsonRequest(stream)
|
|
67
|
+
stream.write('{"incomplete":')
|
|
68
|
+
stream.emit('aborted')
|
|
69
|
+
await assert.rejects(pending, /aborted/)
|
|
70
|
+
assert.equal(stream.listenerCount('data'), 0)
|
|
71
|
+
stream.destroy()
|
|
72
|
+
})
|
|
@@ -0,0 +1,78 @@
|
|
|
1
|
+
// 把 <from> 目录里的厂商美术导入插件包 assets/agent-teams/。
|
|
2
|
+
// 包内目录的查找**只认候选链里的名字**(host 端对内置目录不做 -v2 别名回退),
|
|
3
|
+
// 所以所有无 -v2 的源文件必须补上后缀,否则「文件在包里但请求永远落空」。
|
|
4
|
+
// 用法:node import-vendor-artwork.mjs --from <dir> [--apply]
|
|
5
|
+
import { readdir, copyFile, mkdir, stat } from 'node:fs/promises';
|
|
6
|
+
import { join, resolve } from 'node:path';
|
|
7
|
+
import { fileURLToPath } from 'node:url';
|
|
8
|
+
|
|
9
|
+
// 2026-10-08:厂商命名空间扩到 15 个(前 10 个有厂商 × 岗位图),岗位桶补上
|
|
10
|
+
// audio / video —— 这两个桶已有 10 个厂商的岗位图,导入时不能再被判成「无法识别」。
|
|
11
|
+
// 2026-10-11:第三轮素材再扩到 17 个,新增 stepfun / jev(都只有通用图与立绘)。
|
|
12
|
+
const VENDORS = ['deepseek', 'qwen', 'glm', 'kimi', 'claude', 'gemini', 'grok', 'gpt', 'hunyuan', 'minimax', 'meta', 'mistral', 'rwkv', 'seed', 'ernie', 'stepfun', 'jev', 'mimo'];
|
|
13
|
+
const ROLES = ['engineer', 'qa', 'security', 'researcher', 'designer', 'docs', 'data', 'operator', 'audio', 'video'];
|
|
14
|
+
const V = `(?:${VENDORS.join('|')})`;
|
|
15
|
+
const RULES = [
|
|
16
|
+
// 厂商 + 岗位、厂商通用、厂商立绘:补 -v2
|
|
17
|
+
[new RegExp(`^member-(${V})-(${ROLES.join('|')})\\.png$`, 'u'), (m) => `member-${m[1]}-${m[2]}-v2.png`],
|
|
18
|
+
[new RegExp(`^member-(${V})-v2\\.png$`, 'u'), (m) => `member-${m[1]}-v2.png`],
|
|
19
|
+
[new RegExp(`^member-(${V})-full-v2\\.png$`, 'u'), (m) => `member-${m[1]}-full-v2.png`],
|
|
20
|
+
// 队长立绘:候选链要的是 team-lead-<vendor>-v2.png
|
|
21
|
+
[new RegExp(`^team-lead-(${V})\\.png$`, 'u'), (m) => `team-lead-${m[1]}-v2.png`],
|
|
22
|
+
[new RegExp(`^brand-(${V})\\.svg$`, 'u'), (m) => `brand-${m[1]}.svg`],
|
|
23
|
+
];
|
|
24
|
+
|
|
25
|
+
const args = process.argv.slice(2);
|
|
26
|
+
const fromIndex = args.indexOf('--from');
|
|
27
|
+
if (fromIndex === -1 || args[fromIndex + 1] === undefined) {
|
|
28
|
+
console.error('usage: node import-vendor-artwork.mjs --from <dir> [--apply]');
|
|
29
|
+
process.exit(2);
|
|
30
|
+
}
|
|
31
|
+
const apply = args.includes('--apply');
|
|
32
|
+
const sourceDir = resolve(args[fromIndex + 1]);
|
|
33
|
+
await stat(sourceDir); // 源目录不存在时直接失败,避免导入 0 个文件还报成功
|
|
34
|
+
const targetDir = fileURLToPath(new URL('../assets/agent-teams/', import.meta.url));
|
|
35
|
+
await mkdir(targetDir, { recursive: true });
|
|
36
|
+
|
|
37
|
+
const sources = (await readdir(sourceDir)).sort();
|
|
38
|
+
const plan = [];
|
|
39
|
+
const skipped = [];
|
|
40
|
+
const unknown = [];
|
|
41
|
+
for (const name of sources) {
|
|
42
|
+
if (name.endsWith('.md') || name.includes('_dummy_')) {
|
|
43
|
+
skipped.push(name);
|
|
44
|
+
continue;
|
|
45
|
+
}
|
|
46
|
+
// 包内基线(内置鲸鱼队长)永远由仓库自己管,外部目录不得覆盖。
|
|
47
|
+
if (name === 'team-lead-v2.png') {
|
|
48
|
+
skipped.push(`${name} (内置基线,交给仓库维护)`);
|
|
49
|
+
continue;
|
|
50
|
+
}
|
|
51
|
+
let target;
|
|
52
|
+
for (const [pattern, rename] of RULES) {
|
|
53
|
+
const match = pattern.exec(name);
|
|
54
|
+
if (match !== null) {
|
|
55
|
+
target = rename(match);
|
|
56
|
+
break;
|
|
57
|
+
}
|
|
58
|
+
}
|
|
59
|
+
if (target === undefined) {
|
|
60
|
+
unknown.push(name);
|
|
61
|
+
continue;
|
|
62
|
+
}
|
|
63
|
+
plan.push({ name, target });
|
|
64
|
+
}
|
|
65
|
+
if (unknown.length > 0) {
|
|
66
|
+
console.error(`无法识别的文件(不猜命名,请先归类):${JSON.stringify(unknown)}`);
|
|
67
|
+
process.exit(2);
|
|
68
|
+
}
|
|
69
|
+
console.log(`${apply ? '导入' : '预演'}:${plan.length} 个文件 ${apply ? '→' : '将写入'} ${targetDir}`);
|
|
70
|
+
console.log(`跳过:${skipped.length} 个(${skipped.slice(0, 3).join(', ')}${skipped.length > 3 ? ', …' : ''})`);
|
|
71
|
+
const renamed = plan.filter(entry => entry.name !== entry.target);
|
|
72
|
+
console.log(`其中需要改名:${renamed.length} 个,例如 ${renamed.slice(0, 3).map(e => `${e.name} → ${e.target}`).join(';')}`);
|
|
73
|
+
if (!apply) {
|
|
74
|
+
console.log('未写入任何文件(加 --apply 才落地)。');
|
|
75
|
+
process.exit(0);
|
|
76
|
+
}
|
|
77
|
+
for (const { name, target } of plan) await copyFile(join(sourceDir, name), join(targetDir, target));
|
|
78
|
+
console.log(`完成:写入 ${plan.length} 个文件。`);
|
|
@@ -0,0 +1,121 @@
|
|
|
1
|
+
#!/usr/bin/env node
|
|
2
|
+
/**
|
|
3
|
+
* Regression TDD: blank optional tool-call arguments must mean "absent".
|
|
4
|
+
*
|
|
5
|
+
* Observed field failure (2 sessions, 48 `agent_teams_create` attempts, 0
|
|
6
|
+
* successes): the captain model filled EVERY optional key with `""` — plain
|
|
7
|
+
* tool-call habit, not a schema requirement — and the inline-plan validator
|
|
8
|
+
* rejected the blank string:
|
|
9
|
+
*
|
|
10
|
+
* profiles.inline-plan.members[0].tool_policy must not be empty (x15)
|
|
11
|
+
* profiles.inline-plan.members[0].provider must not be empty (x6)
|
|
12
|
+
*
|
|
13
|
+
* The same habit broke `list_subagent_models` (``provider`` must be non-empty),
|
|
14
|
+
* `working_directory` (cd must not be empty) and `grep` (include must be a
|
|
15
|
+
* non-empty glob), proving it is caller behaviour, not one tool's contract.
|
|
16
|
+
*
|
|
17
|
+
* The edit path already normalizes blanks away (`trimmedOptional` in
|
|
18
|
+
* `src/tools.ts`), so a blank string is "absent" everywhere else in this
|
|
19
|
+
* plugin. This pins the profile normalizer to the same rule, so a blank
|
|
20
|
+
* optional field can never deadlock a plan again, while required fields and
|
|
21
|
+
* non-string values stay strict.
|
|
22
|
+
*/
|
|
23
|
+
import { resolveTeamProfile } from '../lib/profiles.js'
|
|
24
|
+
|
|
25
|
+
let failures = 0
|
|
26
|
+
function check(label, value) {
|
|
27
|
+
if (value) console.log(` PASS ${label}`)
|
|
28
|
+
else { failures += 1; console.error(` FAIL ${label}`) }
|
|
29
|
+
}
|
|
30
|
+
function ok(label, fn) {
|
|
31
|
+
try { fn(); console.log(` PASS ${label}`) }
|
|
32
|
+
catch (error) { failures += 1; console.error(` FAIL ${label} (threw: ${error.message})`) }
|
|
33
|
+
}
|
|
34
|
+
function throws(label, pattern, fn) {
|
|
35
|
+
try {
|
|
36
|
+
fn()
|
|
37
|
+
failures += 1
|
|
38
|
+
console.error(` FAIL ${label} (did not throw)`)
|
|
39
|
+
} catch (error) {
|
|
40
|
+
if (pattern.test(error.message)) console.log(` PASS ${label}`)
|
|
41
|
+
else { failures += 1; console.error(` FAIL ${label} (message: ${error.message})`) }
|
|
42
|
+
}
|
|
43
|
+
}
|
|
44
|
+
|
|
45
|
+
// ---- The exact failing call: every optional member key blank -------------
|
|
46
|
+
const blankPlan = {
|
|
47
|
+
members: [{
|
|
48
|
+
name: 'tuner-ui',
|
|
49
|
+
role: '',
|
|
50
|
+
provider: '',
|
|
51
|
+
model: '',
|
|
52
|
+
reasoning_effort: '',
|
|
53
|
+
executionPrompt: '',
|
|
54
|
+
tool_policy: '',
|
|
55
|
+
}],
|
|
56
|
+
tasks: [{ id: 't1', subject: 'Tune the panel', description: '', assignee: 'tuner-ui', dependencies: [] }],
|
|
57
|
+
}
|
|
58
|
+
let normalized
|
|
59
|
+
ok('a blank optional member key no longer aborts plan creation', () => {
|
|
60
|
+
normalized = resolveTeamProfile({ 'inline-plan': blankPlan }, 'inline-plan', 8)
|
|
61
|
+
})
|
|
62
|
+
check('blank tool_policy is normalized to absent', normalized?.members[0]?.toolPolicy === undefined)
|
|
63
|
+
check('blank provider is normalized to absent', normalized?.members[0]?.provider === undefined)
|
|
64
|
+
check('blank model is normalized to absent', normalized?.members[0]?.model === undefined)
|
|
65
|
+
check('blank role is normalized to absent', normalized?.members[0]?.role === undefined)
|
|
66
|
+
check('blank reasoning_effort is normalized to absent', normalized?.members[0]?.reasoningEffort === undefined)
|
|
67
|
+
check('blank executionPrompt is normalized to absent', normalized?.members[0]?.executionPrompt === undefined)
|
|
68
|
+
check('blank task description is normalized to absent', normalized?.tasks[0]?.description === undefined)
|
|
69
|
+
|
|
70
|
+
// Whitespace-only is the same shape as an empty string.
|
|
71
|
+
const whitespace = { members: [{ name: 'w', tool_policy: ' ', role: ' ' }], tasks: [{ id: 't1', subject: 's', assignee: 'w' }] }
|
|
72
|
+
let spaced
|
|
73
|
+
ok('whitespace-only optional keys are accepted', () => {
|
|
74
|
+
spaced = resolveTeamProfile({ 'inline-plan': whitespace }, 'inline-plan', 8)
|
|
75
|
+
})
|
|
76
|
+
check('whitespace-only tool_policy normalizes to absent', spaced?.members[0]?.toolPolicy === undefined)
|
|
77
|
+
|
|
78
|
+
// A real value still survives, trimmed.
|
|
79
|
+
const real = {
|
|
80
|
+
members: [{ name: 'w', provider: 'deepseek-f', model: ' workbuddy/deepseek-v4.1-flash ', tool_policy: ' researcher ' }],
|
|
81
|
+
tasks: [{ id: 't1', subject: 's', assignee: 'w' }],
|
|
82
|
+
}
|
|
83
|
+
let kept
|
|
84
|
+
ok('a real optional value is kept', () => {
|
|
85
|
+
kept = resolveTeamProfile({ 'inline-plan': real }, 'inline-plan', 8)
|
|
86
|
+
})
|
|
87
|
+
check('real tool_policy survives, trimmed', kept?.members[0]?.toolPolicy === 'researcher')
|
|
88
|
+
check('real model survives, trimmed', kept?.members[0]?.model === 'workbuddy/deepseek-v4.1-flash')
|
|
89
|
+
|
|
90
|
+
// ---- Profile-level and required-field strictness is unchanged ------------
|
|
91
|
+
const blankProfile = {
|
|
92
|
+
description: '',
|
|
93
|
+
protocol: ' ',
|
|
94
|
+
executionPrompt: '',
|
|
95
|
+
members: [{ name: 'w' }],
|
|
96
|
+
tasks: [{ id: 't1', subject: 's', assignee: 'w' }],
|
|
97
|
+
}
|
|
98
|
+
let blanked
|
|
99
|
+
ok('blank profile-level optional text is accepted', () => {
|
|
100
|
+
blanked = resolveTeamProfile({ 'inline-plan': blankProfile }, 'inline-plan', 8)
|
|
101
|
+
})
|
|
102
|
+
check('blank profile description normalizes to absent', blanked?.description === undefined)
|
|
103
|
+
check('blank profile protocol normalizes to absent', blanked?.protocol === undefined)
|
|
104
|
+
|
|
105
|
+
throws('a member without a name is still rejected', /has a member with an empty name/u,
|
|
106
|
+
() => resolveTeamProfile({ 'inline-plan': { members: [{ name: '' }], tasks: [] } }, 'inline-plan', 8))
|
|
107
|
+
throws('a task without an id is still rejected', /has a task with an empty id/u,
|
|
108
|
+
() => resolveTeamProfile({ 'inline-plan': { members: [{ name: 'w' }], tasks: [{ id: '', subject: 's' }] } }, 'inline-plan', 8))
|
|
109
|
+
throws('a task without a subject is still rejected', /missing a subject/u,
|
|
110
|
+
() => resolveTeamProfile({ 'inline-plan': { members: [{ name: 'w' }], tasks: [{ id: 't1', subject: '' }] } }, 'inline-plan', 8))
|
|
111
|
+
throws('a blank dependency id is still rejected', /dependencies\[0\] must not be empty/u,
|
|
112
|
+
() => resolveTeamProfile({ 'inline-plan': { members: [{ name: 'w' }], tasks: [{ id: 't1', subject: 's', dependencies: [''] }] } }, 'inline-plan', 8))
|
|
113
|
+
throws('a non-string optional value is still rejected', /tool_policy must be a string/u,
|
|
114
|
+
() => resolveTeamProfile({ 'inline-plan': { members: [{ name: 'w', tool_policy: 7 }], tasks: [] } }, 'inline-plan', 8))
|
|
115
|
+
throws('a provider with no model is still rejected', /sets provider without model/u,
|
|
116
|
+
() => resolveTeamProfile({ 'inline-plan': { members: [{ name: 'w', provider: 'deepseek-f' }], tasks: [] } }, 'inline-plan', 8))
|
|
117
|
+
throws('an entirely blank provider+model pair is absent, not a route', /sets provider without model/u,
|
|
118
|
+
() => resolveTeamProfile({ 'inline-plan': { members: [{ name: 'w', provider: 'deepseek-f', model: '' }], tasks: [] } }, 'inline-plan', 8))
|
|
119
|
+
|
|
120
|
+
if (failures > 0) process.exitCode = 1
|
|
121
|
+
else console.log('inline-plan blank-optional TDD checks passed')
|
|
@@ -0,0 +1,78 @@
|
|
|
1
|
+
import test from 'node:test'
|
|
2
|
+
import assert from 'node:assert/strict'
|
|
3
|
+
import { beginTaskAttempt, invalidateTaskAttempt } from '../lib/state.js'
|
|
4
|
+
import { appendTaskEvidence, hasValidQualityTaskFields, evaluateQualityCompletion, validateCreateTask } from '../lib/quality-gates.js'
|
|
5
|
+
import { isCurrentMail } from '../lib/mailbox.js'
|
|
6
|
+
|
|
7
|
+
const task = () => ({ id:'t1', subject:'repair', assignee:'worker', status:'failed', attempt:1, attemptId:'old', dependencies:[], createdAt:1, updatedAt:2, kind:'repair', sourceTaskId:'source', sourceFindingIds:['F1'], objective:'Fix parser', inScope:['src/'], acceptance:['works'], verify:['test'], output:'old result', verdict:'pass', findings:[], changedPaths:['src/a'], acceptanceResults:[{criterion:'works',status:'passed'}], commandsRun:[{command:'test',status:'passed'}] })
|
|
8
|
+
test('retry cannot complete using evidence or verdict from the previous attempt', () => {
|
|
9
|
+
const t=task();invalidateTaskAttempt(t,'worker',true);beginTaskAttempt(t,'worker');t.status='in_progress';
|
|
10
|
+
assert.equal(t.verdict,undefined)
|
|
11
|
+
assert.equal(t.commandsRun,undefined)
|
|
12
|
+
assert.equal(evaluateQualityCompletion(t,{status:'completed'}).ok,false)
|
|
13
|
+
})
|
|
14
|
+
test('source attempt revocation invalidates queued reports, including captain reports', () => {
|
|
15
|
+
const t=task();const team={tasks:[t]};const mail={id:'m',from:'worker',to:'captain',content:'old result',ts:1,sourceTaskId:'t1',sourceAttemptId:'old'};
|
|
16
|
+
assert.equal(isCurrentMail(team,mail),true)
|
|
17
|
+
invalidateTaskAttempt(t,'worker',true)
|
|
18
|
+
assert.equal(isCurrentMail(team,mail),false)
|
|
19
|
+
})
|
|
20
|
+
test('captain cannot create a duplicate repair for the same unresolved findings', () => {
|
|
21
|
+
const existing=task();existing.status='pending';
|
|
22
|
+
const team={tasks:[{id:'source',status:'completed'},existing]};
|
|
23
|
+
const result=validateCreateTask(team,{...existing,subject:'duplicate',dependencies:['t1']});
|
|
24
|
+
assert.equal(result.ok,false);assert.match(result.error,/t1/)
|
|
25
|
+
})
|
|
26
|
+
|
|
27
|
+
test('a queued progress message is superseded by a terminal result, but the actual terminal report survives', () => {
|
|
28
|
+
const t=task();t.status='in_progress';const team={tasks:[t]};
|
|
29
|
+
const mail={from:'worker',to:'captain',sourceTaskId:'t1',sourceAttemptId:'old',sourceTaskStatus:'in_progress'};
|
|
30
|
+
assert.equal(isCurrentMail(team,mail),true);t.status='cancelled';assert.equal(isCurrentMail(team,mail),false)
|
|
31
|
+
assert.equal(isCurrentMail(team,{...mail,sourceTaskStatus:'cancelled'}),true)
|
|
32
|
+
})
|
|
33
|
+
|
|
34
|
+
test('supplements retain author, attempt and old result without reopening a failed gate', () => {
|
|
35
|
+
const t=task(), before=structuredClone(t);
|
|
36
|
+
const input={commandsRun:[{command:'late-check',status:'failed',exitCode:1,evidence:'new observation'}],acceptanceResults:[{criterion:'edge case',status:'failed'}],evidence_note:' Follow-up '};
|
|
37
|
+
assert.equal(appendTaskEvidence(t,input,'worker'),true)
|
|
38
|
+
assert.equal(t.supplementalEvidence[0].by,'worker');assert.equal(t.supplementalEvidence[0].attemptId,'old')
|
|
39
|
+
assert.equal(t.supplementalEvidence[0].note,'Follow-up')
|
|
40
|
+
assert.deepEqual({...t,supplementalEvidence:undefined},{...before,supplementalEvidence:undefined})
|
|
41
|
+
assert.equal(appendTaskEvidence(t,input,'worker'),false)
|
|
42
|
+
assert.equal(appendTaskEvidence(t,{commandsRun:[{evidence:'new observation',exitCode:1,status:'failed',command:'late-check'}]},'worker'),false)
|
|
43
|
+
assert.equal(t.supplementalEvidence.length,1)
|
|
44
|
+
assert.equal(appendTaskEvidence(t,{evidence_note:'Captain independently verified'},'captain'),true)
|
|
45
|
+
assert.equal(hasValidQualityTaskFields(JSON.parse(JSON.stringify(t))),true)
|
|
46
|
+
const n=t.supplementalEvidence.length;assert.throws(()=>appendTaskEvidence(t,{commandsRun:[{command:'bad',status:'maybe'}]},'worker'),/invalid/)
|
|
47
|
+
assert.equal(t.supplementalEvidence.length,n)
|
|
48
|
+
})
|
|
49
|
+
test('terminal immutable fields cannot be silently changed even with unchanged status/output', () => {
|
|
50
|
+
for (const change of [{status:'completed'},{output:'overwrite'},{verdict:'reject'},{findings:[{id:'new'}]},{changedPaths:['elsewhere']}]) {
|
|
51
|
+
const t=task(),before=structuredClone(t);assert.throws(()=>appendTaskEvidence(t,change,'captain'),/immutable/);assert.deepEqual(t,before)
|
|
52
|
+
}
|
|
53
|
+
})
|
|
54
|
+
test('retry preserves attributed historical supplements but does not reuse them as gate evidence', () => {
|
|
55
|
+
const t=task();appendTaskEvidence(t,{evidence_note:'failed attempt inspection'},'worker');const entry=structuredClone(t.supplementalEvidence[0]);
|
|
56
|
+
beginTaskAttempt(t,'worker');assert.deepEqual(t.supplementalEvidence,[entry]);assert.notEqual(t.attemptId,entry.attemptId)
|
|
57
|
+
t.status='in_progress';assert.equal(evaluateQualityCompletion(t,{status:'completed'}).ok,false)
|
|
58
|
+
})
|
|
59
|
+
test('malformed persisted supplements are rejected', () => {
|
|
60
|
+
for(const item of [null,{}, {at:1,by:'worker',attempt:1}, {at:1,by:'worker',attempt:-1,note:'x'},{at:1,by:'',attempt:1,note:'x'},{at:1,by:'worker',attempt:1,commandsRun:[{}]}]) {
|
|
61
|
+
assert.equal(hasValidQualityTaskFields({...task(),supplementalEvidence:[item]}),false)
|
|
62
|
+
}
|
|
63
|
+
})
|
|
64
|
+
|
|
65
|
+
test('durable mailbox fallback discards revoked source reports for captain and peers', async t => {
|
|
66
|
+
const {mkdtemp,rm}=await import('node:fs/promises');const {tmpdir}=await import('node:os');const {join}=await import('node:path');
|
|
67
|
+
const {createTeamDir,appendMailbox,readMailbox}=await import('../lib/state.js');const {readCurrentMailbox}=await import('../lib/mailbox.js');
|
|
68
|
+
const root=await mkdtemp(join(tmpdir(),'issue159-mail-'));t.after(()=>rm(root,{recursive:true,force:true}));
|
|
69
|
+
const team={id:'team',name:'team',captainSessionId:'captain',createdAt:1,taskSeq:1,members:[{name:'worker',id:'worker',status:'idle',joinedAt:1},{name:'peer',id:'peer',status:'idle',joinedAt:1}],tasks:[{...task(),attemptId:'new'}]};
|
|
70
|
+
await createTeamDir(root,team);
|
|
71
|
+
for(const to of ['captain','peer']) {
|
|
72
|
+
const old={id:'old-'+to,from:'worker',to,content:'obsolete',ts:1,sourceTaskId:'t1',sourceAttemptId:'old'};
|
|
73
|
+
const current={...old,id:'new-'+to,content:'current',sourceAttemptId:'new'};
|
|
74
|
+
await appendMailbox(root,'team',to,old);await appendMailbox(root,'team',to,current);
|
|
75
|
+
assert.deepEqual((await readCurrentMailbox(root,'team',to)).map(m=>m.id),[current.id]);
|
|
76
|
+
assert.ok((await readMailbox(root,'team',to)).find(m=>m.id===old.id).discardedAt)
|
|
77
|
+
}
|
|
78
|
+
})
|
|
@@ -0,0 +1,148 @@
|
|
|
1
|
+
// Issue #188 regression: sentinel `line` values must not brick a real team.
|
|
2
|
+
//
|
|
3
|
+
// This is a real-disk regression: it writes real `team.json` files into a real
|
|
4
|
+
// temporary directory and reads them back through the built `readTeam` /
|
|
5
|
+
// `readTeamSync`. No mock reader, no fake state root.
|
|
6
|
+
//
|
|
7
|
+
// The acceptance evidence for this issue is the group's real-host run (official
|
|
8
|
+
// dsh CLI + real Loader + real plugin tools); this file keeps the property
|
|
9
|
+
// regression-testable forever, in both directions:
|
|
10
|
+
// - a legacy record carrying an out-of-range NUMERIC sentinel self-heals;
|
|
11
|
+
// - a genuinely wrong-typed value is still rejected, with the offending task
|
|
12
|
+
// and field named;
|
|
13
|
+
// - contract-valid values survive untouched.
|
|
14
|
+
import { test } from 'node:test'
|
|
15
|
+
import assert from 'node:assert/strict'
|
|
16
|
+
import { mkdirSync, mkdtempSync, writeFileSync, readFileSync, rmSync } from 'node:fs'
|
|
17
|
+
import { tmpdir } from 'node:os'
|
|
18
|
+
import { join } from 'node:path'
|
|
19
|
+
import { readTeam, readTeamSync } from '../lib/state.js'
|
|
20
|
+
|
|
21
|
+
const TEAM_ID = 'repro'
|
|
22
|
+
const healthy = { id: 't1', subject: 'healthy', status: 'completed', dependencies: [], createdAt: 1, updatedAt: 1 }
|
|
23
|
+
|
|
24
|
+
const poisoned = (findingExtras, taskExtras = {}) => ({
|
|
25
|
+
id: TEAM_ID,
|
|
26
|
+
name: TEAM_ID,
|
|
27
|
+
captainSessionId: 'session-x',
|
|
28
|
+
createdAt: 1,
|
|
29
|
+
taskSeq: 2,
|
|
30
|
+
members: [],
|
|
31
|
+
tasks: [
|
|
32
|
+
healthy,
|
|
33
|
+
{
|
|
34
|
+
id: 't2', subject: 'poisoned', status: 'failed', dependencies: [], createdAt: 1, updatedAt: 1,
|
|
35
|
+
kind: 'implementation',
|
|
36
|
+
findings: [{ id: 'f1', severity: 'medium', problem: 'p', requiredFix: 'r', ...findingExtras }],
|
|
37
|
+
...taskExtras,
|
|
38
|
+
},
|
|
39
|
+
],
|
|
40
|
+
})
|
|
41
|
+
|
|
42
|
+
/** Run `body(root)` against a freshly written real team.json, then clean up. */
|
|
43
|
+
async function withTeam(record, body) {
|
|
44
|
+
const root = mkdtempSync(join(tmpdir(), 'agentteams-188-'))
|
|
45
|
+
try {
|
|
46
|
+
mkdirSync(join(root, TEAM_ID, 'inbox'), { recursive: true })
|
|
47
|
+
writeFileSync(join(root, TEAM_ID, 'team.json'), JSON.stringify(record, null, 2))
|
|
48
|
+
return await body(root)
|
|
49
|
+
} finally {
|
|
50
|
+
rmSync(root, { recursive: true, force: true })
|
|
51
|
+
}
|
|
52
|
+
}
|
|
53
|
+
|
|
54
|
+
async function rejection(record) {
|
|
55
|
+
return withTeam(record, async (root) => {
|
|
56
|
+
try {
|
|
57
|
+
await readTeam(root, TEAM_ID)
|
|
58
|
+
return undefined
|
|
59
|
+
} catch (error) {
|
|
60
|
+
return error
|
|
61
|
+
}
|
|
62
|
+
})
|
|
63
|
+
}
|
|
64
|
+
|
|
65
|
+
for (const line of [-1, -1.5, -1176]) {
|
|
66
|
+
await test(`a legacy record with findings[0].line ${line} self-heals on read`, async () => {
|
|
67
|
+
await withTeam(poisoned({ line }), async (root) => {
|
|
68
|
+
const team = await readTeam(root, TEAM_ID)
|
|
69
|
+
assert.notEqual(team, undefined)
|
|
70
|
+
assert.equal(team.tasks[1].findings[0].line, undefined)
|
|
71
|
+
assert.equal(team.tasks[1].findings[0].problem, 'p')
|
|
72
|
+
assert.equal(team.tasks[0].status, 'completed')
|
|
73
|
+
// the same file must also be readable through the synchronous reader
|
|
74
|
+
const sync = readTeamSync(root, TEAM_ID)
|
|
75
|
+
assert.notEqual(sync, undefined)
|
|
76
|
+
assert.equal(sync.tasks[1].findings[0].line, undefined)
|
|
77
|
+
})
|
|
78
|
+
})
|
|
79
|
+
}
|
|
80
|
+
|
|
81
|
+
await test('round 0, reviewedAttempt -1 and attempt -1 self-heal with blank list entries', async () => {
|
|
82
|
+
await withTeam(poisoned({}, { round: 0, reviewedAttempt: -1, attempt: -1, inScope: ['src/a.ts', ' ', ''] }), async (root) => {
|
|
83
|
+
const task = (await readTeam(root, TEAM_ID)).tasks[1]
|
|
84
|
+
assert.equal(task.round, undefined)
|
|
85
|
+
assert.equal(task.reviewedAttempt, undefined)
|
|
86
|
+
assert.equal(task.attempt, undefined)
|
|
87
|
+
assert.deepEqual(task.inScope, ['src/a.ts'])
|
|
88
|
+
})
|
|
89
|
+
})
|
|
90
|
+
|
|
91
|
+
await test('contract-valid numeric values survive the read untouched', async () => {
|
|
92
|
+
await withTeam(poisoned({ line: 0 }, { round: 2, reviewedAttempt: 0, attempt: 3 }), async (root) => {
|
|
93
|
+
const task = (await readTeam(root, TEAM_ID)).tasks[1]
|
|
94
|
+
assert.equal(task.findings[0].line, 0)
|
|
95
|
+
assert.equal(task.round, 2)
|
|
96
|
+
assert.equal(task.reviewedAttempt, 0)
|
|
97
|
+
assert.equal(task.attempt, 3)
|
|
98
|
+
})
|
|
99
|
+
await withTeam(poisoned({ line: 1176, file: 'src/x.ts', resolved: false }), async (root) => {
|
|
100
|
+
const finding = (await readTeam(root, TEAM_ID)).tasks[1].findings[0]
|
|
101
|
+
assert.equal(finding.line, 1176)
|
|
102
|
+
assert.equal(finding.file, 'src/x.ts')
|
|
103
|
+
assert.equal(finding.resolved, false)
|
|
104
|
+
})
|
|
105
|
+
})
|
|
106
|
+
|
|
107
|
+
await test('wrong-typed values are still hard failures, named down to the field', async () => {
|
|
108
|
+
for (const bad of [{ line: 'oops' }, { line: null }]) {
|
|
109
|
+
const error = await rejection(poisoned(bad))
|
|
110
|
+
assert.notEqual(error, undefined, `expected rejection for ${JSON.stringify(bad)}`)
|
|
111
|
+
assert.match(error.message, /^invalid AgentTeams state in team "repro"/)
|
|
112
|
+
assert.match(error.message, /task "t2": findings\[0\]\.line/)
|
|
113
|
+
}
|
|
114
|
+
for (const bad of [{ round: 'oops' }, { attempt: {} }]) {
|
|
115
|
+
const error = await rejection(poisoned({}, bad))
|
|
116
|
+
assert.notEqual(error, undefined, `expected rejection for ${JSON.stringify(bad)}`)
|
|
117
|
+
assert.match(error.message, /task "t2": (round|attempt)/)
|
|
118
|
+
}
|
|
119
|
+
})
|
|
120
|
+
|
|
121
|
+
await test('unrelated corruption is still rejected with a task-scoped diagnostic', async () => {
|
|
122
|
+
const error = await rejection({
|
|
123
|
+
id: TEAM_ID, name: TEAM_ID, captainSessionId: 'session-x', createdAt: 1, taskSeq: 1,
|
|
124
|
+
members: [], tasks: [{ ...healthy, status: 'nonsense' }],
|
|
125
|
+
})
|
|
126
|
+
assert.notEqual(error, undefined)
|
|
127
|
+
assert.match(error.message, /^invalid AgentTeams state in team "repro"/)
|
|
128
|
+
assert.match(error.message, /task "t1": status "nonsense" is invalid/)
|
|
129
|
+
})
|
|
130
|
+
|
|
131
|
+
await test('the exact reported record reads clean, healthy sibling intact', async () => {
|
|
132
|
+
await withTeam(poisoned({ line: -1 }), async (root) => {
|
|
133
|
+
const team = await readTeam(root, TEAM_ID)
|
|
134
|
+
assert.equal(team.tasks[0].subject, 'healthy')
|
|
135
|
+
assert.equal(team.tasks[1].findings[0].id, 'f1')
|
|
136
|
+
})
|
|
137
|
+
})
|
|
138
|
+
|
|
139
|
+
await test('the raw writer is the low-level API: bytes are preserved, the reader heals them', async () => {
|
|
140
|
+
// The tool-side guard lives in the tool parser, not in `writeTeam`, so this
|
|
141
|
+
// pins the division of responsibility rather than a guarantee the raw writer
|
|
142
|
+
// does not make. The tool path itself is covered by the real-host case.
|
|
143
|
+
await withTeam(poisoned({ line: -1 }), async (root) => {
|
|
144
|
+
const bytes = JSON.parse(readFileSync(join(root, TEAM_ID, 'team.json'), 'utf8'))
|
|
145
|
+
assert.equal(bytes.tasks[1].findings[0].line, -1)
|
|
146
|
+
assert.equal((await readTeam(root, TEAM_ID)).tasks[1].findings[0].line, undefined)
|
|
147
|
+
})
|
|
148
|
+
})
|