@zhuan-ai/zhuanspec 2.17.8 → 2.17.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.
@@ -49,6 +49,14 @@ export interface KnowledgeReferencesFile {
49
49
  interface KnowledgeReferencesOptions {
50
50
  json?: boolean;
51
51
  }
52
+ /**
53
+ * 判断是否为知识检索类工具调用(强特征、低误伤)。
54
+ *
55
+ * 覆盖:knowledge-agent-action / load-project-knowledge skill,以及前台 Bash 跑
56
+ * search_knowledge.py。这类工具出现时几乎必然处于 techDesign 流程,即便当前 phase
57
+ * 仍是 idle(set-phase 尚未执行、被检索抢跑),也应落盘,避免丢失知识溯源。
58
+ */
59
+ export declare function isKnowledgeRetrievalTool(toolName: string, toolInput: Record<string, unknown>): boolean;
52
60
  export declare function selectKnowledgeReferenceToolResult(stdinData: Record<string, unknown>): {
53
61
  key: string;
54
62
  value: unknown;
@@ -143,6 +143,24 @@ function isKnowledgeAgentSearchInvocation(toolName, toolInput) {
143
143
  const skillName = extractSkillName(toolName, toolInput);
144
144
  return isKnowledgeSkill(skillName, toolName) || isKnowledgeCarrierSkill(skillName);
145
145
  }
146
+ /**
147
+ * 判断是否为知识检索类工具调用(强特征、低误伤)。
148
+ *
149
+ * 覆盖:knowledge-agent-action / load-project-knowledge skill,以及前台 Bash 跑
150
+ * search_knowledge.py。这类工具出现时几乎必然处于 techDesign 流程,即便当前 phase
151
+ * 仍是 idle(set-phase 尚未执行、被检索抢跑),也应落盘,避免丢失知识溯源。
152
+ */
153
+ export function isKnowledgeRetrievalTool(toolName, toolInput) {
154
+ if (isSkillAnalyticsTool(toolName))
155
+ return false;
156
+ if (isKnowledgeAgentSearchInvocation(toolName, toolInput))
157
+ return true;
158
+ if (toolName === 'Bash') {
159
+ const command = toolInput.command || '';
160
+ return isKnowledgeSearchScriptCommand(command);
161
+ }
162
+ return false;
163
+ }
146
164
  function isGenericSuccessEnvelope(toolResult) {
147
165
  if (!isObject(toolResult))
148
166
  return false;
@@ -1499,13 +1517,25 @@ export async function knowledgeReferencesHook(_options) {
1499
1517
  };
1500
1518
  // 阶段过滤
1501
1519
  if (!ACTIVE_PHASES.includes(phase)) {
1502
- await appendDebugLog(debugBase, {
1503
- ...debugContext,
1504
- event: 'phase-skipped',
1505
- activePhases: ACTIVE_PHASES,
1506
- });
1507
- outputEnvelope();
1508
- return;
1520
+ // 容错:techDesign 流程里知识检索可能抢跑在 set-phase 之前,此时 phase 仍是 idle。
1521
+ // 对知识检索类工具(强特征、低误伤)放行,归到 tech-design 落盘,避免丢失知识溯源。
1522
+ if (phase === 'idle' && isKnowledgeRetrievalTool(toolName, toolInput)) {
1523
+ phase = 'tech-design';
1524
+ await appendDebugLog(debugBase, {
1525
+ ...debugContext,
1526
+ event: 'idle-knowledge-retrieval-recovered',
1527
+ recoveredPhase: phase,
1528
+ });
1529
+ }
1530
+ else {
1531
+ await appendDebugLog(debugBase, {
1532
+ ...debugContext,
1533
+ event: 'phase-skipped',
1534
+ activePhases: ACTIVE_PHASES,
1535
+ });
1536
+ outputEnvelope();
1537
+ return;
1538
+ }
1509
1539
  }
1510
1540
  // TaskOutput 大输出会被截断并写入文件,读取全量文件以拿到完整知识 JSON。
1511
1541
  let effectiveToolResult = toolResult;
package/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "@zhuan-ai/zhuanspec",
3
- "version": "2.17.8",
3
+ "version": "2.17.11",
4
4
  "description": "AI-native system for spec-driven development",
5
5
  "keywords": [
6
6
  "zhuanspec",
@@ -39,26 +39,6 @@
39
39
  "!dist/**/__tests__",
40
40
  "!dist/**/*.map"
41
41
  ],
42
- "scripts": {
43
- "lint": "eslint src/",
44
- "build": "node build.js",
45
- "dev": "tsc --watch",
46
- "dev:cli": "pnpm build && node bin/zhuanspec.js",
47
- "test": "vitest run",
48
- "test:watch": "vitest",
49
- "test:ui": "vitest --ui",
50
- "test:coverage": "vitest --coverage",
51
- "test:postinstall": "node scripts/postinstall.js",
52
- "prepare": "npm run build",
53
- "prepublishOnly": "npm run build",
54
- "postinstall": "node scripts/postinstall.js",
55
- "check:pack-version": "node scripts/pack-version-check.mjs",
56
- "diagnose:cursor": "node scripts/diagnose-cursor-commands.js",
57
- "release": "pnpm run release:ci",
58
- "release:ci": "pnpm run check:pack-version && pnpm exec changeset publish",
59
- "release:local": "pnpm exec changeset version && pnpm run check:pack-version && pnpm exec changeset publish",
60
- "changeset": "changeset"
61
- },
62
42
  "engines": {
63
43
  "node": ">=20.19.0"
64
44
  },
@@ -80,5 +60,23 @@
80
60
  "ora": "^8.2.0",
81
61
  "yaml": "^2.8.2",
82
62
  "zod": "^4.0.17"
63
+ },
64
+ "scripts": {
65
+ "lint": "eslint src/",
66
+ "build": "node build.js",
67
+ "dev": "tsc --watch",
68
+ "dev:cli": "pnpm build && node bin/zhuanspec.js",
69
+ "test": "vitest run",
70
+ "test:watch": "vitest",
71
+ "test:ui": "vitest --ui",
72
+ "test:coverage": "vitest --coverage",
73
+ "test:postinstall": "node scripts/postinstall.js",
74
+ "postinstall": "node scripts/postinstall.js",
75
+ "check:pack-version": "node scripts/pack-version-check.mjs",
76
+ "diagnose:cursor": "node scripts/diagnose-cursor-commands.js",
77
+ "release": "pnpm run release:ci",
78
+ "release:ci": "pnpm run check:pack-version && pnpm exec changeset publish",
79
+ "release:local": "pnpm exec changeset version && pnpm run check:pack-version && pnpm exec changeset publish",
80
+ "changeset": "changeset"
83
81
  }
84
- }
82
+ }