@zhuan-ai/zhuanspec 2.17.6 → 2.17.8
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/hooks.js +9 -0
- package/dist/core/hooks/knowledge-references.d.ts +91 -0
- package/dist/core/hooks/knowledge-references.js +1629 -0
- package/dist/core/init.js +11 -0
- package/dist/core/templates/codex-hooks-template.js +6 -0
- package/dist/core/templates/slash-command-templates.js +32 -17
- package/package.json +1 -1
package/dist/cli/hooks.js
CHANGED
|
@@ -16,6 +16,7 @@ import { deviationCheckHook } from '../core/hooks/deviation-check.js';
|
|
|
16
16
|
import { recordProgressHook, initializeProgress } from '../core/hooks/record-progress.js';
|
|
17
17
|
import { collectKnowledgeHook } from '../core/hooks/collect-knowledge.js';
|
|
18
18
|
import { knowledgeUsageHook } from '../core/hooks/knowledge-usage.js';
|
|
19
|
+
import { knowledgeReferencesHook } from '../core/hooks/knowledge-references.js';
|
|
19
20
|
import { summarizeHook } from '../core/hooks/summarize.js';
|
|
20
21
|
import { runUserInputHook } from '../core/hooks/user-input-hook.js';
|
|
21
22
|
import { preArchiveHook } from '../core/hooks/pre-archive.js';
|
|
@@ -104,6 +105,14 @@ program
|
|
|
104
105
|
.action(async (options) => {
|
|
105
106
|
await knowledgeUsageHook(options);
|
|
106
107
|
});
|
|
108
|
+
// PostToolUse hook - knowledge references(知识溯源记录)
|
|
109
|
+
program
|
|
110
|
+
.command('knowledge-references')
|
|
111
|
+
.description('PostToolUse hook - Record knowledge references during tech-design/proposal/apply')
|
|
112
|
+
.option('--json', 'Output as JSON for Claude Code consumption')
|
|
113
|
+
.action(async (options) => {
|
|
114
|
+
await knowledgeReferencesHook(options);
|
|
115
|
+
});
|
|
107
116
|
// Stop hook
|
|
108
117
|
program
|
|
109
118
|
.command('summarize')
|
|
@@ -0,0 +1,91 @@
|
|
|
1
|
+
/**
|
|
2
|
+
* Knowledge References Hook(知识溯源记录)
|
|
3
|
+
*
|
|
4
|
+
* PostToolUse 旁路 hook:在 tech-design / proposal / apply 三个阶段,
|
|
5
|
+
* 自动解析 Skill、Read/Grep/Glob、Bash、MCP 等工具的输出,
|
|
6
|
+
* 提取知识引用信息并落盘到 log/knowledge-references/{phase}.json。
|
|
7
|
+
*
|
|
8
|
+
* 设计原则:
|
|
9
|
+
* - 纯旁路指标,始终 continue:true / 0 退出,绝不阻断主流程。
|
|
10
|
+
* - 混合解析策略(C):优先取结构化字段,fallback 启发式提取。
|
|
11
|
+
* - refs 为空时不写入,避免噪音。
|
|
12
|
+
*/
|
|
13
|
+
export interface KnowledgeRef {
|
|
14
|
+
confidence?: number;
|
|
15
|
+
relevance?: string;
|
|
16
|
+
citedTitle?: string;
|
|
17
|
+
citedKnowledgeType?: string;
|
|
18
|
+
citedSource?: string;
|
|
19
|
+
citedUrl?: string;
|
|
20
|
+
}
|
|
21
|
+
export interface KnowledgeRecord {
|
|
22
|
+
source: string;
|
|
23
|
+
query: string;
|
|
24
|
+
at: string;
|
|
25
|
+
refs: KnowledgeRef[];
|
|
26
|
+
}
|
|
27
|
+
export interface KnowledgeAgentActionInvocation {
|
|
28
|
+
source: string;
|
|
29
|
+
skillName: string;
|
|
30
|
+
query: string;
|
|
31
|
+
at: string;
|
|
32
|
+
responseSource: string;
|
|
33
|
+
toolResultKey: string;
|
|
34
|
+
toolUseId?: string;
|
|
35
|
+
transcriptPath?: string;
|
|
36
|
+
changeId?: string;
|
|
37
|
+
request: Record<string, unknown>;
|
|
38
|
+
response: unknown;
|
|
39
|
+
launcherResponse?: unknown;
|
|
40
|
+
backgroundTaskId?: string;
|
|
41
|
+
nestedToolUseIds?: string[];
|
|
42
|
+
resolutionError?: string;
|
|
43
|
+
}
|
|
44
|
+
export interface KnowledgeReferencesFile {
|
|
45
|
+
phase: string;
|
|
46
|
+
records: KnowledgeRecord[];
|
|
47
|
+
knowledgeAgentActionInvocations?: KnowledgeAgentActionInvocation[];
|
|
48
|
+
}
|
|
49
|
+
interface KnowledgeReferencesOptions {
|
|
50
|
+
json?: boolean;
|
|
51
|
+
}
|
|
52
|
+
export declare function selectKnowledgeReferenceToolResult(stdinData: Record<string, unknown>): {
|
|
53
|
+
key: string;
|
|
54
|
+
value: unknown;
|
|
55
|
+
};
|
|
56
|
+
interface TaskOutputPayload {
|
|
57
|
+
outputFilePath?: string;
|
|
58
|
+
rawOutput?: string;
|
|
59
|
+
}
|
|
60
|
+
export declare function extractTaskOutputPayload(content: string): TaskOutputPayload;
|
|
61
|
+
export declare function extractFirstJsonValueFromText(text: string): unknown;
|
|
62
|
+
export declare function parseKnowledgeReferenceToolCall(toolName: string, toolInput: Record<string, unknown>, toolResult: unknown): KnowledgeRecord | null;
|
|
63
|
+
export declare function buildKnowledgeAgentActionInvocation(toolName: string, toolInput: Record<string, unknown>, toolResult: unknown, context: {
|
|
64
|
+
toolResultKey: string;
|
|
65
|
+
toolUseId?: string;
|
|
66
|
+
transcriptPath?: string;
|
|
67
|
+
changeId?: string;
|
|
68
|
+
}): KnowledgeAgentActionInvocation | null;
|
|
69
|
+
/**
|
|
70
|
+
* 为 TaskOutput 命中的知识检索结果构造 invocation 记录,保留完整原始 JSON 到 response。
|
|
71
|
+
* 仅当解析出至少一条知识 ref 时返回,避免噪音。
|
|
72
|
+
*/
|
|
73
|
+
export declare function buildTaskOutputKnowledgeInvocation(toolInput: Record<string, unknown>, toolResult: unknown, context: {
|
|
74
|
+
toolResultKey: string;
|
|
75
|
+
toolUseId?: string;
|
|
76
|
+
transcriptPath?: string;
|
|
77
|
+
changeId?: string;
|
|
78
|
+
}): KnowledgeAgentActionInvocation | null;
|
|
79
|
+
/**
|
|
80
|
+
* 为前台 Bash 跑 search_knowledge.py 命中的知识检索结果构造 invocation 记录,
|
|
81
|
+
* 保留完整原始 JSON 到 response。仅当解析出至少一条知识 ref 时返回。
|
|
82
|
+
*/
|
|
83
|
+
export declare function buildBashKnowledgeInvocation(toolInput: Record<string, unknown>, toolResult: unknown, context: {
|
|
84
|
+
toolResultKey: string;
|
|
85
|
+
toolUseId?: string;
|
|
86
|
+
transcriptPath?: string;
|
|
87
|
+
changeId?: string;
|
|
88
|
+
}): KnowledgeAgentActionInvocation | null;
|
|
89
|
+
export declare function knowledgeReferencesHook(_options: KnowledgeReferencesOptions): Promise<void>;
|
|
90
|
+
export {};
|
|
91
|
+
//# sourceMappingURL=knowledge-references.d.ts.map
|