yongle-dadian 1.3.1 → 1.3.2
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/bin/install.js
CHANGED
|
@@ -350,6 +350,12 @@ function installForRuntime(runtime) {
|
|
|
350
350
|
"command": `node "${searchScriptPath}"`
|
|
351
351
|
}
|
|
352
352
|
],
|
|
353
|
+
"PostInvocation": [
|
|
354
|
+
{
|
|
355
|
+
"type": "command",
|
|
356
|
+
"command": `node "${archiveScriptPath}"`
|
|
357
|
+
}
|
|
358
|
+
],
|
|
353
359
|
"Stop": [
|
|
354
360
|
{
|
|
355
361
|
"type": "command",
|
package/package.json
CHANGED
|
@@ -11,15 +11,18 @@ process.stdin.on('end', () => {
|
|
|
11
11
|
try {
|
|
12
12
|
const payload = JSON.parse(inputData);
|
|
13
13
|
|
|
14
|
-
//
|
|
15
|
-
if (payload.
|
|
14
|
+
// 只要包含 transcriptPath 且未显式指定 fullyIdle 为 false,即触发归档检查
|
|
15
|
+
if (payload.transcriptPath && payload.fullyIdle !== false) {
|
|
16
16
|
const archiverScript = path.join(__dirname, 'yongle-bg-archiver.js');
|
|
17
|
+
const repoModulesDir = 'D:/Computers/AIDevelop/Tools/Skills/yongle-dadian/node_modules';
|
|
18
|
+
const nodeModulesDir = path.join(__dirname, '..', 'node_modules');
|
|
19
|
+
const combinedNodePath = [nodeModulesDir, repoModulesDir, process.env.NODE_PATH].filter(Boolean).join(path.delimiter);
|
|
17
20
|
|
|
18
21
|
// 以 Detached (脱机) 模式启动后台归档进程,并切断 stdio 防止阻塞当前进程
|
|
19
22
|
const child = spawn('node', [archiverScript, payload.transcriptPath], {
|
|
20
23
|
detached: true,
|
|
21
24
|
stdio: 'ignore',
|
|
22
|
-
env: { ...process.env, YONGLE_RUNTIME: 'antigravity' }
|
|
25
|
+
env: { ...process.env, YONGLE_RUNTIME: 'antigravity', NODE_PATH: combinedNodePath }
|
|
23
26
|
});
|
|
24
27
|
|
|
25
28
|
child.unref(); // 让当前 Hook 脚本可以立刻退出
|
|
@@ -1,6 +1,6 @@
|
|
|
1
1
|
const fs = require('fs');
|
|
2
2
|
const path = require('path');
|
|
3
|
-
const { execSync } = require('child_process');
|
|
3
|
+
const { execSync, execFileSync } = require('child_process');
|
|
4
4
|
const { getAgentCompletion } = require('./yongle-agent-api.js');
|
|
5
5
|
const { loadMergedConfig } = require('./yongle-config.js');
|
|
6
6
|
const { logAutoFeature } = require('./yongle-logger.js');
|
|
@@ -60,10 +60,10 @@ ${context}`;
|
|
|
60
60
|
try {
|
|
61
61
|
const config = loadMergedConfig();
|
|
62
62
|
const agModel = config.agent?.antigravityModel || 'flash';
|
|
63
|
-
// 尝试调用 agentapi (
|
|
64
|
-
const output =
|
|
63
|
+
// 尝试调用 agentapi (使用 execFileSync 传递数组参数,防 Windows 命令行转义异常)
|
|
64
|
+
const output = execFileSync('agentapi', ['new-conversation', `--model=${agModel}`, prompt], { encoding: 'utf8' });
|
|
65
65
|
const parsed = JSON.parse(output);
|
|
66
|
-
const convId = parsed.response
|
|
66
|
+
const convId = parsed.response?.newConversation?.conversationId;
|
|
67
67
|
|
|
68
68
|
if (convId) {
|
|
69
69
|
usedAgentApi = true;
|
|
@@ -95,15 +95,28 @@ ${context}`;
|
|
|
95
95
|
|
|
96
96
|
// 降级使用 yongle-agent-api.js (外部大模型 API)
|
|
97
97
|
if (!resultJsonStr) {
|
|
98
|
-
|
|
98
|
+
try {
|
|
99
|
+
resultJsonStr = await getAgentCompletion(prompt, '你是一个专门用来提取 JSON 格式的技术经验复盘专家。请只输出 JSON。');
|
|
100
|
+
} catch (e) {}
|
|
99
101
|
}
|
|
100
102
|
|
|
101
|
-
if (!resultJsonStr)
|
|
103
|
+
if (!resultJsonStr) {
|
|
104
|
+
logAutoFeature({
|
|
105
|
+
feature: 'auto-archive',
|
|
106
|
+
status: 'SKIPPED',
|
|
107
|
+
durationMs: Date.now() - startTime,
|
|
108
|
+
details: '会话审查结束,模型未返回有效评估结果'
|
|
109
|
+
});
|
|
110
|
+
return;
|
|
111
|
+
}
|
|
102
112
|
|
|
103
113
|
// 3. 解析与归档
|
|
104
114
|
// 清理 markdown codeblock 标记
|
|
105
115
|
const cleanJsonStr = resultJsonStr.replace(/```json/gi, '').replace(/```/g, '').trim();
|
|
106
|
-
|
|
116
|
+
let data = {};
|
|
117
|
+
try {
|
|
118
|
+
data = JSON.parse(cleanJsonStr);
|
|
119
|
+
} catch(e) {}
|
|
107
120
|
|
|
108
121
|
if (data.solved === true && data.title) {
|
|
109
122
|
const timestamp = new Date().toISOString().replace(/[:.]/g, '-');
|
|
@@ -152,6 +165,13 @@ ${data.solution}
|
|
|
152
165
|
durationMs: Date.now() - startTime,
|
|
153
166
|
details: `归档生成经验: "${data.title}" (${usedAgentApi ? 'Native AgentAPI' : 'External LLM API'})`
|
|
154
167
|
});
|
|
168
|
+
} else {
|
|
169
|
+
logAutoFeature({
|
|
170
|
+
feature: 'auto-archive',
|
|
171
|
+
status: 'SKIPPED',
|
|
172
|
+
durationMs: Date.now() - startTime,
|
|
173
|
+
details: '会话审查完毕,未发现需归档的新 Bug 解决经验'
|
|
174
|
+
});
|
|
155
175
|
}
|
|
156
176
|
|
|
157
177
|
} catch (error) {
|
package/scripts/yongle-status.js
CHANGED