@minonl/dia 0.0.10 → 0.0.11
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/dist/cli.js +107 -50
- package/docs/msg-collab-m1.md +9 -0
- package/package.json +1 -1
- package/packages/wt/bin/dia-wt +6 -2
package/dist/cli.js
CHANGED
|
@@ -4392,7 +4392,7 @@ function migrateLegacy(opts = {}) {
|
|
|
4392
4392
|
|
|
4393
4393
|
// src/claims.ts
|
|
4394
4394
|
init_paths();
|
|
4395
|
-
import { appendFileSync as appendFileSync5, existsSync as existsSync14, mkdirSync as mkdirSync13, readFileSync as readFileSync13 } from "node:fs";
|
|
4395
|
+
import { appendFileSync as appendFileSync5, existsSync as existsSync14, mkdirSync as mkdirSync13, readFileSync as readFileSync13, renameSync as renameSync7, writeFileSync as writeFileSync11 } from "node:fs";
|
|
4396
4396
|
import { execFileSync as execFileSync4 } from "node:child_process";
|
|
4397
4397
|
import { randomBytes as randomBytes3 } from "node:crypto";
|
|
4398
4398
|
import { basename as basename7, join as join16, relative as relative5, resolve as resolve9, sep as sep7 } from "node:path";
|
|
@@ -4510,6 +4510,58 @@ function unclaim(target, opts = {}) {
|
|
|
4510
4510
|
return { ...hit, released_at: new Date().toISOString() };
|
|
4511
4511
|
});
|
|
4512
4512
|
}
|
|
4513
|
+
function compact(opts = {}) {
|
|
4514
|
+
const days = Math.max(0, Number(opts.days ?? 7));
|
|
4515
|
+
const now = opts.now || new Date;
|
|
4516
|
+
const cutoff = now.getTime() - days * 86400000;
|
|
4517
|
+
return withLock("claims", () => {
|
|
4518
|
+
const f = file();
|
|
4519
|
+
if (!existsSync14(f))
|
|
4520
|
+
return { before: 0, after: 0, dropped: 0 };
|
|
4521
|
+
const raw = readFileSync13(f, "utf8");
|
|
4522
|
+
const lines = raw.split(`
|
|
4523
|
+
`).filter((l) => l.trim());
|
|
4524
|
+
const keepIds = new Set;
|
|
4525
|
+
for (const line of lines) {
|
|
4526
|
+
let e;
|
|
4527
|
+
try {
|
|
4528
|
+
e = JSON.parse(line);
|
|
4529
|
+
} catch {
|
|
4530
|
+
continue;
|
|
4531
|
+
}
|
|
4532
|
+
if (e.event !== "claim" || !e.id)
|
|
4533
|
+
continue;
|
|
4534
|
+
const created = new Date(e.created_at || e.ts).getTime();
|
|
4535
|
+
if (isActive({ id: e.id, path: e.path || "", scope: e.scope || "", holder: e.holder || "", created_at: e.created_at || e.ts, expires_at: e.expires_at || e.ts }, now.getTime()) || created > cutoff) {
|
|
4536
|
+
keepIds.add(e.id);
|
|
4537
|
+
}
|
|
4538
|
+
}
|
|
4539
|
+
const kept = [];
|
|
4540
|
+
let dropped = 0;
|
|
4541
|
+
for (const line of lines) {
|
|
4542
|
+
let e;
|
|
4543
|
+
try {
|
|
4544
|
+
e = JSON.parse(line);
|
|
4545
|
+
} catch {
|
|
4546
|
+
dropped++;
|
|
4547
|
+
continue;
|
|
4548
|
+
}
|
|
4549
|
+
if (e.id && keepIds.has(e.id))
|
|
4550
|
+
kept.push(line);
|
|
4551
|
+
else
|
|
4552
|
+
dropped++;
|
|
4553
|
+
}
|
|
4554
|
+
if (dropped) {
|
|
4555
|
+
const tmp = `${f}.tmp.${process.pid}`;
|
|
4556
|
+
writeFileSync11(tmp, kept.join(`
|
|
4557
|
+
`) + (kept.length ? `
|
|
4558
|
+
` : ""), { mode: 384 });
|
|
4559
|
+
renameSync7(tmp, f);
|
|
4560
|
+
}
|
|
4561
|
+
const after = existsSync14(f) ? readFileSync13(f, "utf8").length : 0;
|
|
4562
|
+
return { before: raw.length, after, dropped };
|
|
4563
|
+
});
|
|
4564
|
+
}
|
|
4513
4565
|
|
|
4514
4566
|
// src/task.ts
|
|
4515
4567
|
init_paths();
|
|
@@ -4786,7 +4838,7 @@ init_paths();
|
|
|
4786
4838
|
|
|
4787
4839
|
// src/agents.ts
|
|
4788
4840
|
init_paths();
|
|
4789
|
-
import { existsSync as existsSync16, mkdirSync as mkdirSync15, readdirSync as readdirSync9, readFileSync as readFileSync15, renameSync as
|
|
4841
|
+
import { existsSync as existsSync16, mkdirSync as mkdirSync15, readdirSync as readdirSync9, readFileSync as readFileSync15, renameSync as renameSync8, rmSync as rmSync6, writeFileSync as writeFileSync12 } from "node:fs";
|
|
4790
4842
|
import { basename as basename8, join as join18, resolve as resolve10 } from "node:path";
|
|
4791
4843
|
import { execFileSync as execFileSync5 } from "node:child_process";
|
|
4792
4844
|
var agentsRoot2 = () => agentsRoot();
|
|
@@ -4794,8 +4846,8 @@ var fileOf = (agent) => join18(agentsRoot2(), `${agent}.json`);
|
|
|
4794
4846
|
function atomicWrite2(path, data) {
|
|
4795
4847
|
mkdirSync15(join18(path, ".."), { recursive: true });
|
|
4796
4848
|
const tmp = `${path}.tmp.${process.pid}`;
|
|
4797
|
-
|
|
4798
|
-
|
|
4849
|
+
writeFileSync12(tmp, data);
|
|
4850
|
+
renameSync8(tmp, path);
|
|
4799
4851
|
}
|
|
4800
4852
|
function sh(cmd, args) {
|
|
4801
4853
|
try {
|
|
@@ -4893,7 +4945,7 @@ function discoverTmux() {
|
|
|
4893
4945
|
|
|
4894
4946
|
// src/tmux.ts
|
|
4895
4947
|
import { execFileSync as execFileSync6 } from "node:child_process";
|
|
4896
|
-
import { mkdtempSync, writeFileSync as
|
|
4948
|
+
import { mkdtempSync, writeFileSync as writeFileSync13 } from "node:fs";
|
|
4897
4949
|
import { tmpdir as tmpdir2 } from "node:os";
|
|
4898
4950
|
import { join as join19 } from "node:path";
|
|
4899
4951
|
function tmux(args) {
|
|
@@ -4939,7 +4991,7 @@ function deliver(agent, id, opts = {}) {
|
|
|
4939
4991
|
`);
|
|
4940
4992
|
const dir = mkdtempSync(join19(tmpdir2(), "dia-msg-"));
|
|
4941
4993
|
const buf = join19(dir, "body.txt");
|
|
4942
|
-
|
|
4994
|
+
writeFileSync13(buf, text);
|
|
4943
4995
|
try {
|
|
4944
4996
|
tmux(["load-buffer", "-b", `dia-${m.id}`, buf]);
|
|
4945
4997
|
tmux(["paste-buffer", "-p", "-b", `dia-${m.id}`, "-t", pane]);
|
|
@@ -5404,7 +5456,7 @@ function checks(reg) {
|
|
|
5404
5456
|
|
|
5405
5457
|
// src/deps.ts
|
|
5406
5458
|
init_paths();
|
|
5407
|
-
import { existsSync as existsSync20, readFileSync as readFileSync18, mkdirSync as mkdirSync16, writeFileSync as
|
|
5459
|
+
import { existsSync as existsSync20, readFileSync as readFileSync18, mkdirSync as mkdirSync16, writeFileSync as writeFileSync14, chmodSync as chmodSync3 } from "node:fs";
|
|
5408
5460
|
import { homedir as homedir10 } from "node:os";
|
|
5409
5461
|
import { dirname as dirname11, join as join23 } from "node:path";
|
|
5410
5462
|
import { execFileSync as execFileSync9 } from "node:child_process";
|
|
@@ -5511,7 +5563,7 @@ function append4(entry, p) {
|
|
|
5511
5563
|
const line = JSON.stringify(entry) + `
|
|
5512
5564
|
`;
|
|
5513
5565
|
const prev = existsSync20(path) ? readFileSync18(path, "utf8") : "";
|
|
5514
|
-
|
|
5566
|
+
writeFileSync14(path, prev.endsWith(`
|
|
5515
5567
|
`) || !prev ? prev + line : prev + `
|
|
5516
5568
|
` + line);
|
|
5517
5569
|
try {
|
|
@@ -5847,7 +5899,7 @@ function run2(cfg, cmd, opts = {}) {
|
|
|
5847
5899
|
}
|
|
5848
5900
|
|
|
5849
5901
|
// src/bw.ts
|
|
5850
|
-
import { chmodSync as chmodSync4, existsSync as existsSync24, mkdirSync as mkdirSync17, readFileSync as readFileSync21, rmSync as rmSync7, writeFileSync as
|
|
5902
|
+
import { chmodSync as chmodSync4, existsSync as existsSync24, mkdirSync as mkdirSync17, readFileSync as readFileSync21, rmSync as rmSync7, writeFileSync as writeFileSync15 } from "node:fs";
|
|
5851
5903
|
init_paths();
|
|
5852
5904
|
import { join as join27 } from "node:path";
|
|
5853
5905
|
import { execFileSync as execFileSync10 } from "node:child_process";
|
|
@@ -5869,7 +5921,7 @@ function readSession2() {
|
|
|
5869
5921
|
function writeSession(key) {
|
|
5870
5922
|
const f = sessionFile2();
|
|
5871
5923
|
mkdirSync17(join27(f, ".."), { recursive: true });
|
|
5872
|
-
|
|
5924
|
+
writeFileSync15(f, key + `
|
|
5873
5925
|
`, { mode: 384 });
|
|
5874
5926
|
chmodSync4(f, 384);
|
|
5875
5927
|
}
|
|
@@ -6108,7 +6160,7 @@ import { fileURLToPath as fileURLToPath4 } from "node:url";
|
|
|
6108
6160
|
import { resolve as resolvePath, sep as pathSep } from "node:path";
|
|
6109
6161
|
|
|
6110
6162
|
// src/team.ts
|
|
6111
|
-
import { appendFileSync as appendFileSync8, cpSync as cpSync3, existsSync as existsSync26, mkdirSync as mkdirSync18, readFileSync as readFileSync23, readdirSync as readdirSync11, rmSync as rmSync8, writeFileSync as
|
|
6163
|
+
import { appendFileSync as appendFileSync8, cpSync as cpSync3, existsSync as existsSync26, mkdirSync as mkdirSync18, readFileSync as readFileSync23, readdirSync as readdirSync11, rmSync as rmSync8, writeFileSync as writeFileSync16 } from "node:fs";
|
|
6112
6164
|
import { homedir as homedir15, tmpdir as tmpdir3 } from "node:os";
|
|
6113
6165
|
import { join as join29, resolve as resolve14 } from "node:path";
|
|
6114
6166
|
|
|
@@ -6161,23 +6213,23 @@ function runMock(id) {
|
|
|
6161
6213
|
const t = get2(id);
|
|
6162
6214
|
const dir = runDir(id);
|
|
6163
6215
|
mkdirSync18(dir, { recursive: true, mode: 448 });
|
|
6164
|
-
|
|
6216
|
+
writeFileSync16(join29(dir, "plan.md"), `# Plan: ${t.title}
|
|
6165
6217
|
|
|
6166
6218
|
- judge: ${t.judge || "(missing)"}
|
|
6167
6219
|
- roles: planner → builder → verifier → redteam
|
|
6168
6220
|
`);
|
|
6169
|
-
|
|
6221
|
+
writeFileSync16(join29(dir, "diff.patch"), `# mock diff
|
|
6170
6222
|
`);
|
|
6171
|
-
|
|
6223
|
+
writeFileSync16(join29(dir, "test.log"), `mock tests: 0 failures
|
|
6172
6224
|
`);
|
|
6173
|
-
|
|
6174
|
-
|
|
6175
|
-
|
|
6225
|
+
writeFileSync16(join29(dir, "verify.json"), JSON.stringify({ conclusion: "通过", commit: "mock", evidence: ["mock test.log"] }, null, 1));
|
|
6226
|
+
writeFileSync16(join29(dir, "redteam.json"), JSON.stringify({ findings: [] }, null, 1));
|
|
6227
|
+
writeFileSync16(join29(dir, "packet.md"), `# 验收包 ${id}
|
|
6176
6228
|
|
|
6177
6229
|
- 结论:通过(mock)
|
|
6178
6230
|
- 风险:无
|
|
6179
6231
|
`);
|
|
6180
|
-
|
|
6232
|
+
writeFileSync16(join29(dir, "run.json"), JSON.stringify({ mock: true, judge: t.judge || null, ts: new Date().toISOString() }, null, 1));
|
|
6181
6233
|
status3(id, "awaiting_acceptance", "mock run");
|
|
6182
6234
|
return dir;
|
|
6183
6235
|
}
|
|
@@ -6197,7 +6249,7 @@ function runJudgeSafe(workspace, judge) {
|
|
|
6197
6249
|
}
|
|
6198
6250
|
}
|
|
6199
6251
|
function writeUsage(dir, id, acc) {
|
|
6200
|
-
|
|
6252
|
+
writeFileSync16(join29(dir, "usage.json"), JSON.stringify({ task_id: id, calls: acc.rows.length, input_tokens: acc.input, output_tokens: acc.output, total_tokens: acc.total, cost_usd: acc.cost, unpriced_calls: acc.unpriced, by_role: acc.rows }, null, 1));
|
|
6201
6253
|
}
|
|
6202
6254
|
function judgeWorkspace(dir, fallback) {
|
|
6203
6255
|
try {
|
|
@@ -6269,8 +6321,8 @@ function gate(id) {
|
|
|
6269
6321
|
exit = typeof e?.status === "number" ? e.status : 1;
|
|
6270
6322
|
out = String(e?.stdout || e?.message || "");
|
|
6271
6323
|
}
|
|
6272
|
-
|
|
6273
|
-
|
|
6324
|
+
writeFileSync16(join29(dir, "judge.json"), JSON.stringify({ source: "gate", command: judgeCmd, exit, ms: Date.now() - started, ts: new Date().toISOString() }, null, 1));
|
|
6325
|
+
writeFileSync16(join29(dir, "judge.log"), out.slice(0, 20000));
|
|
6274
6326
|
if (exit !== 0)
|
|
6275
6327
|
return { ok: false, reason: `judge exit: ${exit}(见 judge.log)` };
|
|
6276
6328
|
return { ok: true };
|
|
@@ -6377,7 +6429,7 @@ function snapPath(id, dir, tag) {
|
|
|
6377
6429
|
list = [];
|
|
6378
6430
|
}
|
|
6379
6431
|
list.push(p);
|
|
6380
|
-
|
|
6432
|
+
writeFileSync16(f, JSON.stringify(list, null, 1));
|
|
6381
6433
|
return p;
|
|
6382
6434
|
}
|
|
6383
6435
|
function snapshotWorkspace(src, dest) {
|
|
@@ -6415,17 +6467,17 @@ async function repairRedteamHighs(o) {
|
|
|
6415
6467
|
await o.builderFix(high);
|
|
6416
6468
|
const workspace = judgeWorkspace(dir, o.workspace);
|
|
6417
6469
|
const jr = runJudgeSafe(workspace, judge);
|
|
6418
|
-
|
|
6470
|
+
writeFileSync16(join29(dir, "test.log"), `judge: ${judge}
|
|
6419
6471
|
exit=${jr.code}
|
|
6420
6472
|
${jr.out}`.slice(0, 20000));
|
|
6421
6473
|
const diff2 = gitDiff(workspace);
|
|
6422
|
-
|
|
6474
|
+
writeFileSync16(join29(dir, "diff.patch"), diff2);
|
|
6423
6475
|
const ws2 = snapshotWorkspace(workspace, snapPath(id, dir, "redteam-ws-2"));
|
|
6424
6476
|
const p2 = await o.round2(ws2, diff2);
|
|
6425
6477
|
redteam = { ...normalizeRedteam(p2.value), repaired: p2.repaired, round: 2 };
|
|
6426
|
-
|
|
6478
|
+
writeFileSync16(join29(dir, "redteam.json"), JSON.stringify(redteam, null, 1));
|
|
6427
6479
|
if (jr.code !== 0 || highFindings(redteam).length) {
|
|
6428
|
-
|
|
6480
|
+
writeFileSync16(join29(dir, "packet.md"), `# 验收包 ${id}
|
|
6429
6481
|
|
|
6430
6482
|
- 任务:${t.title}
|
|
6431
6483
|
- 结论:**已升级**(redteam 修复后仍不达标)
|
|
@@ -6523,7 +6575,7 @@ Keep exploration bounded (at most 3 reads); return only the JSON object now.`);
|
|
|
6523
6575
|
});
|
|
6524
6576
|
plan = planned.value;
|
|
6525
6577
|
} catch (e) {
|
|
6526
|
-
|
|
6578
|
+
writeFileSync16(join29(dir, "packet.md"), `# 验收包 ${id}
|
|
6527
6579
|
|
|
6528
6580
|
- 任务:${t.title}
|
|
6529
6581
|
- 结论:**已升级**(planner 输出无法解析)
|
|
@@ -6533,7 +6585,7 @@ Keep exploration bounded (at most 3 reads); return only the JSON object now.`);
|
|
|
6533
6585
|
status3(id, "escalated", "planner: " + e.message);
|
|
6534
6586
|
return { dir, escalated: true, error: e.message };
|
|
6535
6587
|
}
|
|
6536
|
-
|
|
6588
|
+
writeFileSync16(join29(dir, "plan.md"), `# Plan
|
|
6537
6589
|
|
|
6538
6590
|
${JSON.stringify(plan, null, 1)}
|
|
6539
6591
|
`);
|
|
@@ -6551,7 +6603,7 @@ Plan: ${JSON.stringify(plan)}
|
|
|
6551
6603
|
Judge: ${judge}${fix}
|
|
6552
6604
|
Report briefly what you changed and test results.`);
|
|
6553
6605
|
recordModelCall(id, `builder-${round}`, modelOf(buildNs), buildOut.usage, usageAcc, prices);
|
|
6554
|
-
|
|
6606
|
+
writeFileSync16(join29(dir, `builder-${round}.md`), buildOut.text || "(no output)");
|
|
6555
6607
|
const vws = snapshotWorkspace(workspace, snapPath(id, dir, `verify-ws-${round}`));
|
|
6556
6608
|
const verifyNs = await acp.newSession(vws);
|
|
6557
6609
|
const sVerify = verifyNs.sessionId;
|
|
@@ -6566,8 +6618,8 @@ Return only the JSON object.`);
|
|
|
6566
6618
|
return r.text;
|
|
6567
6619
|
});
|
|
6568
6620
|
verify = { ...normalizeVerify(fixed.value), repaired: fixed.repaired };
|
|
6569
|
-
|
|
6570
|
-
|
|
6621
|
+
writeFileSync16(join29(dir, "verify.json"), JSON.stringify(verify, null, 1));
|
|
6622
|
+
writeFileSync16(join29(dir, "test.log"), (verify.evidence || []).join(`
|
|
6571
6623
|
`) || "(no evidence)");
|
|
6572
6624
|
if (verify.conclusion === "通过")
|
|
6573
6625
|
break;
|
|
@@ -6577,9 +6629,9 @@ Return only the JSON object.`);
|
|
|
6577
6629
|
lastVerifyKey = key;
|
|
6578
6630
|
}
|
|
6579
6631
|
const diff = gitDiff(workspace);
|
|
6580
|
-
|
|
6632
|
+
writeFileSync16(join29(dir, "diff.patch"), diff);
|
|
6581
6633
|
if (verify?.conclusion !== "通过") {
|
|
6582
|
-
|
|
6634
|
+
writeFileSync16(join29(dir, "packet.md"), `# 验收包 ${id}
|
|
6583
6635
|
|
|
6584
6636
|
- 任务:${t.title}
|
|
6585
6637
|
- 结论:**已升级**(验证未通过)
|
|
@@ -6594,7 +6646,7 @@ ${(verify?.evidence || []).map((e) => "- " + e).join(`
|
|
|
6594
6646
|
status3(id, "escalated", "verify: " + verify?.conclusion);
|
|
6595
6647
|
return { dir, verify, escalated: true };
|
|
6596
6648
|
}
|
|
6597
|
-
|
|
6649
|
+
writeFileSync16(join29(dir, "run.json"), JSON.stringify({ mock: false, mode: "acp", workspace, judge, ts: new Date().toISOString() }, null, 1));
|
|
6598
6650
|
const rws = snapshotWorkspace(workspace, snapPath(id, dir, "redteam-ws"));
|
|
6599
6651
|
const redNs = await acp.newSession(rws);
|
|
6600
6652
|
const sRed = redNs.sessionId;
|
|
@@ -6610,7 +6662,7 @@ Return only the JSON object.`);
|
|
|
6610
6662
|
return r.text;
|
|
6611
6663
|
});
|
|
6612
6664
|
let redteam = { ...normalizeRedteam(fixed.value), repaired: fixed.repaired, round: 1 };
|
|
6613
|
-
|
|
6665
|
+
writeFileSync16(join29(dir, "redteam.json"), JSON.stringify(redteam, null, 1));
|
|
6614
6666
|
const repaired = await repairRedteamHighs({
|
|
6615
6667
|
id,
|
|
6616
6668
|
dir,
|
|
@@ -6647,7 +6699,7 @@ Return only the JSON object.`);
|
|
|
6647
6699
|
if (repaired.escalated)
|
|
6648
6700
|
return { dir, verify, redteam, escalated: true };
|
|
6649
6701
|
writeUsage(dir, id, usageAcc);
|
|
6650
|
-
|
|
6702
|
+
writeFileSync16(join29(dir, "packet.md"), `# 验收包 ${id}
|
|
6651
6703
|
|
|
6652
6704
|
- 任务:${t.title}
|
|
6653
6705
|
- 判据:${judge}
|
|
@@ -6768,7 +6820,7 @@ Judge: ${t.judge}
|
|
|
6768
6820
|
});
|
|
6769
6821
|
plan = planned.value;
|
|
6770
6822
|
} catch (e) {
|
|
6771
|
-
|
|
6823
|
+
writeFileSync16(join29(dir, "packet.md"), `# 验收包 ${id}
|
|
6772
6824
|
|
|
6773
6825
|
- 任务:${t.title}
|
|
6774
6826
|
- 结论:**已升级**(planner 输出无法解析)
|
|
@@ -6778,7 +6830,7 @@ Judge: ${t.judge}
|
|
|
6778
6830
|
status3(id, "escalated", "planner: " + e.message);
|
|
6779
6831
|
return { dir, escalated: true, error: e.message };
|
|
6780
6832
|
}
|
|
6781
|
-
|
|
6833
|
+
writeFileSync16(join29(dir, "plan.md"), `# Plan
|
|
6782
6834
|
|
|
6783
6835
|
${JSON.stringify(plan, null, 1)}
|
|
6784
6836
|
`);
|
|
@@ -6793,7 +6845,7 @@ Plan: ${JSON.stringify(plan)}
|
|
|
6793
6845
|
Judge: ${judge}${fix}
|
|
6794
6846
|
Report briefly what you changed and test results.`, tracker);
|
|
6795
6847
|
recordModelCall(id, `builder-${round}`, buildOut.model, buildOut.usage, usageAcc, prices);
|
|
6796
|
-
|
|
6848
|
+
writeFileSync16(join29(dir, `builder-${round}.md`), buildOut.text || "(no output)");
|
|
6797
6849
|
const vws = snapshotWorkspace(workspace, snapPath(id, dir, `verify-ws-${round}`));
|
|
6798
6850
|
const vOut = await callDsh("verifier", vws, `Repo: ${vws}
|
|
6799
6851
|
Run this judge yourself: ${judge}
|
|
@@ -6807,8 +6859,8 @@ ${msg}`, tracker);
|
|
|
6807
6859
|
return r.text;
|
|
6808
6860
|
});
|
|
6809
6861
|
verify = { ...normalizeVerify(fixed.value), repaired: fixed.repaired };
|
|
6810
|
-
|
|
6811
|
-
|
|
6862
|
+
writeFileSync16(join29(dir, "verify.json"), JSON.stringify(verify, null, 1));
|
|
6863
|
+
writeFileSync16(join29(dir, "test.log"), (verify.evidence || []).join(`
|
|
6812
6864
|
`) || "(no evidence)");
|
|
6813
6865
|
if (verify.conclusion === "通过")
|
|
6814
6866
|
break;
|
|
@@ -6818,9 +6870,9 @@ ${msg}`, tracker);
|
|
|
6818
6870
|
lastKey = key;
|
|
6819
6871
|
}
|
|
6820
6872
|
const diff = gitDiff(workspace);
|
|
6821
|
-
|
|
6873
|
+
writeFileSync16(join29(dir, "diff.patch"), diff);
|
|
6822
6874
|
if (verify?.conclusion !== "通过") {
|
|
6823
|
-
|
|
6875
|
+
writeFileSync16(join29(dir, "packet.md"), `# 验收包 ${id}
|
|
6824
6876
|
|
|
6825
6877
|
- 任务:${t.title}
|
|
6826
6878
|
- 结论:**已升级**(验证未通过)
|
|
@@ -6835,7 +6887,7 @@ ${(verify?.evidence || []).map((e) => "- " + e).join(`
|
|
|
6835
6887
|
status3(id, "escalated", "verify: " + verify?.conclusion);
|
|
6836
6888
|
return { dir, verify, escalated: true };
|
|
6837
6889
|
}
|
|
6838
|
-
|
|
6890
|
+
writeFileSync16(join29(dir, "run.json"), JSON.stringify({ mock: false, mode: "dsh", workspace, judge, ts: new Date().toISOString() }, null, 1));
|
|
6839
6891
|
const rws = snapshotWorkspace(workspace, snapPath(id, dir, "redteam-ws"));
|
|
6840
6892
|
const rOut = await callDsh("redteam", rws, `Repo: ${rws}
|
|
6841
6893
|
Diff:
|
|
@@ -6851,7 +6903,7 @@ ${msg}`, tracker);
|
|
|
6851
6903
|
return r.text;
|
|
6852
6904
|
});
|
|
6853
6905
|
let redteam = { ...normalizeRedteam(fixed.value), repaired: fixed.repaired, round: 1 };
|
|
6854
|
-
|
|
6906
|
+
writeFileSync16(join29(dir, "redteam.json"), JSON.stringify(redteam, null, 1));
|
|
6855
6907
|
const repaired = await repairRedteamHighs({
|
|
6856
6908
|
id,
|
|
6857
6909
|
dir,
|
|
@@ -6888,7 +6940,7 @@ ${msg}`, tracker);
|
|
|
6888
6940
|
if (repaired.escalated)
|
|
6889
6941
|
return { dir, verify, redteam, escalated: true };
|
|
6890
6942
|
writeUsage(dir, id, usageAcc);
|
|
6891
|
-
|
|
6943
|
+
writeFileSync16(join29(dir, "packet.md"), `# 验收包 ${id}
|
|
6892
6944
|
|
|
6893
6945
|
- 任务:${t.title}
|
|
6894
6946
|
- 判据:${judge}
|
|
@@ -6897,7 +6949,7 @@ ${msg}`, tracker);
|
|
|
6897
6949
|
- 反驳:${(redteam.findings || []).length} 条
|
|
6898
6950
|
- 模型调用:${usageAcc.rows.length} 次 / ${usageAcc.total} tokens
|
|
6899
6951
|
`);
|
|
6900
|
-
|
|
6952
|
+
writeFileSync16(join29(dir, "run.json"), JSON.stringify({ mock: false, mode: "dsh", workspace, judge, ts: new Date().toISOString() }, null, 1));
|
|
6901
6953
|
status3(id, "awaiting_acceptance", "dsh run");
|
|
6902
6954
|
return { dir, verify, redteam };
|
|
6903
6955
|
} finally {
|
|
@@ -7111,7 +7163,7 @@ import {
|
|
|
7111
7163
|
statSync as statSync12,
|
|
7112
7164
|
symlinkSync as symlinkSync3,
|
|
7113
7165
|
unlinkSync as unlinkSync3,
|
|
7114
|
-
writeFileSync as
|
|
7166
|
+
writeFileSync as writeFileSync17
|
|
7115
7167
|
} from "node:fs";
|
|
7116
7168
|
import { hostname as osHostname } from "node:os";
|
|
7117
7169
|
import { basename as basename9, dirname as dirname13, isAbsolute as isAbsolute4, join as join31, relative as relative6, resolve as resolve15, sep as sep8 } from "node:path";
|
|
@@ -8231,7 +8283,7 @@ function add2(opts) {
|
|
|
8231
8283
|
rmSync9(copy, { recursive: true, force: true });
|
|
8232
8284
|
copyTree(dir, copy);
|
|
8233
8285
|
}
|
|
8234
|
-
|
|
8286
|
+
writeFileSync17(serviceLockPath(svc.id), JSON.stringify(lock, null, 1) + `
|
|
8235
8287
|
`);
|
|
8236
8288
|
return result;
|
|
8237
8289
|
}
|
|
@@ -8513,7 +8565,7 @@ usage:
|
|
|
8513
8565
|
dia msg deliver <agent> <id> [--transport tmux|acp]
|
|
8514
8566
|
dia task add|list|link|status|done [--owner S] [--depends a,b] [--touches p1,p2]
|
|
8515
8567
|
dia graph [--json] [--task t-...] [--tui [--watch] [--no-color]]
|
|
8516
|
-
dia claim <path> [--reason R] [--ttl 4h] [--session S] | dia claims [--all] [--mine] | dia unclaim <path|id> [--force]
|
|
8568
|
+
dia claim <path> [--reason R] [--ttl 4h] [--session S] | dia claims [--all] [--mine] [--gc [--days 7]] | dia unclaim <path|id> [--force]
|
|
8517
8569
|
dia team run <id> --mock | --acp|--dsh --workspace DIR
|
|
8518
8570
|
dia team gate|accept|reject|next
|
|
8519
8571
|
dia team accept <id> [--note ...] [--pr N [--repo R] [--merge]] # --pr:先验 CI,绿才接受/合并
|
|
@@ -9251,6 +9303,11 @@ async function claimsCli(argv) {
|
|
|
9251
9303
|
return 0;
|
|
9252
9304
|
}
|
|
9253
9305
|
if (sub === "claims") {
|
|
9306
|
+
if (has(args, "--gc")) {
|
|
9307
|
+
const r = compact({ days: Number(flag(args, "--days") || 7) });
|
|
9308
|
+
out(asJson ? JSON.stringify(r, null, 1) : `claims gc: before=${r.before} after=${r.after} dropped=${r.dropped}`);
|
|
9309
|
+
return 0;
|
|
9310
|
+
}
|
|
9254
9311
|
const mine = has(args, "--mine") ? resolveSessionId(session) : undefined;
|
|
9255
9312
|
const rows = list3({ all: has(args, "--all"), mine });
|
|
9256
9313
|
out(asJson ? JSON.stringify(rows, null, 1) : rows.map((c) => `${c.path} ${c.holder} ${c.reason || ""} ${c.expires_at}${isActive(c) ? "" : "\t(expired)"}`).join(`
|
package/docs/msg-collab-m1.md
CHANGED
|
@@ -93,3 +93,12 @@ dia out --to ses_xxx --kind handoff --subject "交接" --body-file handoff.md \
|
|
|
93
93
|
- 发送时如果有他人活跃 claim,输出 `⚠ claim overlap`(advisory,仍发送);
|
|
94
94
|
- 收件方 `dia in` 会在消息下显示 `⚠ claim: <path> 由 <holder> 持有`;
|
|
95
95
|
- 不自动排队/阻断;claim 仍是可见性工具。
|
|
96
|
+
|
|
97
|
+
## 清理历史(可选)
|
|
98
|
+
|
|
99
|
+
```bash
|
|
100
|
+
dia claims --gc --days 7
|
|
101
|
+
```
|
|
102
|
+
|
|
103
|
+
- 保留活跃 claim + 最近 7 天的记录,删除更早的已过期/已释放事件;
|
|
104
|
+
- 只压缩本地 `claims.jsonl`,不影响任何活跃 claim。
|
package/package.json
CHANGED
package/packages/wt/bin/dia-wt
CHANGED
|
@@ -1368,7 +1368,9 @@ cmd_adopt() {
|
|
|
1368
1368
|
[ -n "$cfgDef" ] && def="$cfgDef"
|
|
1369
1369
|
fi
|
|
1370
1370
|
local mgr2; mgr2="$(python3 -c 'import json,sys;print(json.load(open(sys.argv[1])).get("hooksManager") or "")' "$cfg" 2>/dev/null || true)"
|
|
1371
|
-
if [ "$mgr2" = "
|
|
1371
|
+
if [ "$mgr2" = "external" ]; then
|
|
1372
|
+
echo "WARN D02 $repo 由其它 hook manager 接管(core.hooksPath=$prev),守卫未生效;建议改用 simple-git-hooks"
|
|
1373
|
+
elif [ "$mgr2" = "simple-git-hooks" ]; then
|
|
1372
1374
|
local rcf; rcf="$(wt_hooks_rc_dir)/simple-git-hooks-rc.sh"
|
|
1373
1375
|
[ -f "$rcf" ] || { echo "FAIL D02 缺 simple-git-hooks RC:$rcf"; bad=1; }
|
|
1374
1376
|
grep -rqs "SIMPLE_GIT_HOOKS_RC" "$HOME/.zshenv" || { echo "FAIL D02 shell 未 export SIMPLE_GIT_HOOKS_RC"; bad=1; }
|
|
@@ -1577,7 +1579,9 @@ RC
|
|
|
1577
1579
|
bad=1
|
|
1578
1580
|
fi
|
|
1579
1581
|
mgr2="$(python3 -c 'import json,sys;print(json.load(open(sys.argv[1])).get("hooksManager") or "")' "$cfg" 2>/dev/null || true)"
|
|
1580
|
-
if [ "$mgr2" = "
|
|
1582
|
+
if [ "$mgr2" = "external" ]; then
|
|
1583
|
+
echo "WARN D02 $repo 由其它 hook manager 接管(core.hooksPath=$prev),守卫未生效;建议改用 simple-git-hooks"
|
|
1584
|
+
elif [ "$mgr2" = "simple-git-hooks" ]; then
|
|
1581
1585
|
local rcf; rcf="$(wt_hooks_rc_dir)/simple-git-hooks-rc.sh"
|
|
1582
1586
|
[ -f "$rcf" ] || { echo "FAIL D02 $repo 缺 simple-git-hooks RC:$rcf"; bad=1; }
|
|
1583
1587
|
grep -rqs "SIMPLE_GIT_HOOKS_RC" "$HOME/.zshenv" || echo "WARN D02 $repo shell 未 export SIMPLE_GIT_HOOKS_RC(守卫不会执行)"
|