@suifei/dsh-ai-team 0.4.32 → 0.4.33

This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
package/CHANGELOG.md CHANGED
@@ -1,5 +1,16 @@
1
1
  # Changelog
2
2
 
3
+ ## 0.4.33 - 2026-11-12
4
+
5
+ **中危批次 4:验收门禁、权限沿革、技能过滤、job 原子写**
6
+
7
+ - **Human 验收也要过 QA 门禁**:`accept` 的清单校验原本只在 `reviewer !== null`(Agent)时执行,而 Human 是 UI 上唯一的验收人 —— `qaRequired` 的卡可以零勾选通过,未校验的 `checks` 还会原样写进 `task.qaChecks`。现在对所有验收人生效;没有清单却提交勾选会被拒。
8
+ - **换 owner 会同时换权限**:`project/owner-changed` 只更新 `ownerMemberId`,`ownerId` 停在原主;`isLead` 对两者做 OR 判定,于是**前** owner 继续保留 lead 权限。现在两者一起改。
9
+ - **技能目录按 `invocation.modelInvocable` 过滤**:`SkillSummary` 把开关放在 `invocation` 下,之前读顶层字段(恒 undefined),`disable-model-invocation` 的技能照样写进成员 prompt。
10
+ - **job 文件原子写**:`writeJob` 从裸 `writeFileSync` 改为「写临时文件 + rename」,进程中断不再留下半截 JSON(半截文件会让下一轮 tick 把成功误判成 conflict failed)。
11
+ - **rubric 计数不再被捕获组放大**:`String.match` 带捕获组时返回数组含分组,命中一次会被算成多次,dim3 分数系统性虚高。改为 `matchAll` 只数完整匹配。
12
+ - 测试:`node --test` **221/221**(新增 `test/audit-medium-batch.test.js` 5 例)。
13
+
3
14
  ## 0.4.32 - 2026-11-12
4
15
 
5
16
  **中危批次 3:前端断流自愈、重复提交、同人绑定**
@@ -1132,7 +1132,10 @@ export class TeamService {
1132
1132
  }
1133
1133
  const checklist = Array.isArray(task.qaChecklist) ? task.qaChecklist : [];
1134
1134
  const checks = Array.isArray(command.payload?.checks) ? command.payload.checks : [];
1135
- if (reviewer !== null && checklist.length > 0) {
1135
+ // 门禁对**所有**验收人都生效:Human 是 UI 上唯一的验收人,之前把它
1136
+ // 排除在 `reviewer !== null` 之外,等于让 qaRequired 的卡零勾选通过,
1137
+ // 未校验的 checks 还会原样写进 task.qaChecks。
1138
+ if (checklist.length > 0) {
1136
1139
  // QA 门禁必须逐项对应 task.qaChecklist:只比较条数 + passed 会让
1137
1140
  // 任意 item 文本(含伪造/无关条目)通过门禁,与 tool schema 契约
1138
1141
  // "Exact qaChecklist item" 不一致。
@@ -1149,6 +1152,9 @@ export class TeamService {
1149
1152
  if (pending.length > 0) {
1150
1153
  fail(ERRORS.INVALID_STATE, `QA checklist item not verified: ${pending[0]}`);
1151
1154
  }
1155
+ } else if (checks.length > 0) {
1156
+ // 没有清单却提交了勾选:不接受未知证据,避免写进投影后无从核对。
1157
+ fail(ERRORS.INVALID_ARGUMENT, 'this task has no QA checklist; do not submit checks');
1152
1158
  }
1153
1159
  outcome = acceptTask(task, command.actor, {
1154
1160
  note: command.payload?.note,
@@ -733,10 +733,12 @@ export function applyEvent(state, event) {
733
733
  const ownerMemberId = textOr(payload.ownerMemberId, null);
734
734
  const project = state.projects?.[projectId];
735
735
  if (project === undefined || ownerMemberId === null) return advance(state, event);
736
+ // ownerId 与 ownerMemberId 必须一起改:`isLead` 对两者做 OR 判定,只改
737
+ // ownerMemberId 会让**前** owner 因旧的 ownerId 继续保留 lead 权限。
736
738
  return advance(state, event, {
737
739
  projects: {
738
740
  ...state.projects,
739
- [projectId]: { ...project, ownerMemberId },
741
+ [projectId]: { ...project, ownerId: ownerMemberId, ownerMemberId },
740
742
  },
741
743
  });
742
744
  }
@@ -20,8 +20,15 @@ export async function formatSkillCatalog(skills, options = {}) {
20
20
  if (!Array.isArray(summaries) || summaries.length === 0) return '';
21
21
  // 只注入「模型可以自己调用」的技能:`disable-model-invocation: true` 的技能
22
22
  // 是给 Human 显式用的,列进成员 prompt 会把成员引向一个它无权调用的入口。
23
- const available = summaries.filter((skill) =>
24
- !isSkillExcluded(skill?.name) && skill?.modelInvocable !== false && skill?.disableModelInvocation !== true);
23
+ // SkillSummary 把这两个开关放在 `invocation` 下;直接读顶层字段会让过滤永远
24
+ // 通过(字段恒为 undefined),被禁的技能照样写进 prompt。
25
+ const available = summaries.filter((skill) => {
26
+ if (isSkillExcluded(skill?.name)) return false;
27
+ const modelInvocable = skill?.invocation?.modelInvocable ?? skill?.modelInvocable;
28
+ const disabled = skill?.invocation?.disableModelInvocation ?? skill?.disableModelInvocation;
29
+ if (modelInvocable === false || disabled === true) return false;
30
+ return true;
31
+ });
25
32
  if (available.length === 0) return '';
26
33
  const limit = Number.isSafeInteger(options.limit) && options.limit > 0 ? options.limit : 12;
27
34
  const rows = available.slice(0, limit).map((skill) => {
@@ -12,7 +12,7 @@
12
12
  * job 状态:`generating` → `judging` → `done` | `failed`。
13
13
  * 全部为纯逻辑 + 注入式 I/O,便于在测试里用内存文件系统驱动任意 tick 序列。
14
14
  */
15
- import { existsSync, mkdirSync, readFileSync, readdirSync, unlinkSync, writeFileSync } from 'node:fs';
15
+ import { existsSync, mkdirSync, readFileSync, readdirSync, renameSync, unlinkSync, writeFileSync } from 'node:fs';
16
16
  import { join } from 'node:path';
17
17
 
18
18
  export const JOB_STATES = Object.freeze(['generating', 'judging', 'done', 'failed']);
@@ -49,11 +49,14 @@ export function listJobs(projectDir) {
49
49
  return jobs.sort((a, b) => (a.createdAt ?? 0) - (b.createdAt ?? 0));
50
50
  }
51
51
 
52
- /** 写入 job(原子性靠单写者约定;插件 tick 单线程)。 */
52
+ /** 写入 job:先写临时文件再改名,避免进程中断留下半截 JSON。 */
53
53
  export function writeJob(projectDir, job) {
54
54
  const dir = jobsDir(projectDir);
55
55
  mkdirSync(dir, { recursive: true });
56
- writeFileSync(join(dir, `${job.id}.json`), JSON.stringify(job, null, 2), 'utf8');
56
+ const target = join(dir, `${job.id}.json`);
57
+ const temp = `${target}.tmp`;
58
+ writeFileSync(temp, JSON.stringify(job, null, 2), 'utf8');
59
+ renameSync(temp, target);
57
60
  return job;
58
61
  }
59
62
 
@@ -44,7 +44,15 @@ const CHECKPOINT_PATTERNS = [/🔴/, /🛑/, /CHECKPOINT/, /STOP/];
44
44
  const COUNTEREXAMPLE_PATTERNS = [/反例/, /黑名单/, /不要做/, /禁止/, /反模式/];
45
45
 
46
46
  const clampScore = (value) => Math.max(1, Math.min(10, value));
47
- const countMatches = (text, patterns) => patterns.reduce((total, pattern) => total + (String(text).match(pattern)?.length ?? 0), 0);
47
+ // 只数**完整匹配**:`String.match` 在带捕获组时会把分组也塞进返回数组,长度
48
+ // 因此虚高(`/(a)(b)/g` 命中一次返回 3 个元素),dim3 分数被系统性抬高。
49
+ const countMatches = (text, patterns) => patterns.reduce((total, pattern) => {
50
+ const flags = pattern.flags.includes('g') ? pattern.flags : `${pattern.flags}g`;
51
+ const global = new RegExp(pattern.source, flags);
52
+ let hits = 0;
53
+ for (const _ of String(text).matchAll(global)) hits += 1;
54
+ return total + hits;
55
+ }, 0);
48
56
 
49
57
  /**
50
58
  * 静态评分(dims 1-7、9)。dim8 由调用方注入(measured dim8 干跑/实测分)。
package/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "@suifei/dsh-ai-team",
3
- "version": "0.4.32",
3
+ "version": "0.4.33",
4
4
  "type": "module",
5
5
  "description": "文渊阁 (Wenyuan Pavilion) — AI Team mode for DeepSeek Harness: concurrent projects, owned tasks, threads, inbox and an append-only team ledger",
6
6
  "license": "MIT",