yongle-dadian 1.3.2 → 1.3.3

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/README.md CHANGED
@@ -320,6 +320,7 @@ npx yongle-dadian --global --antigravity
320
320
  | `/yongle-recall` | 无 | **记忆召回**。秒级搜索已沉淀的项目风格决策、架构建议等全局/局部思维模式(Thoughts/Styles)。 |
321
321
  | `/yongle-reindex` | 无 | **重建 SQLite**。全量重新扫描指定 scope 的 Markdown 目录并无损重建 SQLite 主库的 Entries 关联。 |
322
322
  | `npm run embed:all` | 无 | **并发向量灌库**。以最多 5 的并发连接池安全、快速地把所有存量文件进行 Semantic Chunking 分块,并通过防 ENAMETOOLONG 的内存模块方式录入 LanceDB。 |
323
+ | `/yongle-status` | 无 | **健康看板**。查看后台自动化功能(前置自动搜索、会话停止自动归档、梦境守护整理)的运行状态、上次触发时间、耗时及运行日志。 |
323
324
  | `/yongle-sync` | 无 | **增量云同步**。在后台非阻塞式将本地库推送到绑定的 GitHub 团队/个人仓库。 |
324
325
  | `/yongle-config-export` | 无 | **配置导出**。将全局配置以 JSON 格式输出到终端,所有 `apiKey` 字段已自动排除。输出可直接用于 `/yongle-config-import`。 |
325
326
  | `/yongle-config-import` | `<file>` | **配置导入**。从指定 JSON 文件导入配置,显示 dry-run 预览并需 `[y/N]` 确认,自动排除并警告 `apiKey` 字段。 |
@@ -439,8 +440,8 @@ npx yongle-dadian --global --antigravity
439
440
  #### 🔧 Approach B: Local Source Installation (For Custom Hacking)
440
441
  1. Clone the repository:
441
442
  ```powershell
442
- git clone https://github.com/Lemony/yongle-dadian.git
443
- cd yongle-dadian
443
+ git clone https://github.com/TwotwoPiggy/Yongle-Dadian.git
444
+ cd Yongle-Dadian
444
445
  ```
445
446
  2. Install npm dependencies:
446
447
  ```powershell
@@ -645,6 +646,7 @@ Three steps to run semantic search in your daily coding workflows:
645
646
  | `/yongle-recall` | None | **Mind Recall**. Instantly searches structured styles, architecture plans, and thinking patterns (Thoughts/Styles). |
646
647
  | `/yongle-reindex` | None | **Reindex Database**. Rescans specified markdown directories to reconstruct a fresh SQLite main database schema. |
647
648
  | `npm run embed:all` | None | **Batch Vector Backfiller**. Implements concurrent processing (pool size 5) with custom memory-upsert wrappers to bypass Windows shell length limits. |
649
+ | `/yongle-status` | None | **Health Dashboard**. View execution status, last trigger time, duration, and logs for background automation (Auto-search, Session-stop Auto-archive, Dreamer Guard). |
648
650
  | `/yongle-sync` | None | **Sync Cloud Push**. Merges local memory stores to a target GitHub repository in the background. |
649
651
  | `/yongle-config-export` | None | **Config Export**. Outputs the global config as JSON to terminal with all `apiKey` fields automatically excluded. Output can be directly used with `/yongle-config-import`. |
650
652
  | `/yongle-config-import` | `<file>` | **Config Import**. Imports config from a JSON file with dry-run preview and `[y/N]` confirmation. `apiKey` fields are automatically excluded with a warning. |
package/bin/install.js CHANGED
@@ -367,6 +367,39 @@ function installForRuntime(runtime) {
367
367
  fs.mkdirSync(hooksDir, { recursive: true });
368
368
  fs.writeFileSync(hooksPath, JSON.stringify(hooksData, null, 2) + '\n', 'utf8');
369
369
  console.log(` ${green}✓${reset} Antigravity PreInvocation hook registered`);
370
+
371
+ // 5b. Register to ~/.gemini/settings.json AND ~/.gemini/antigravity/settings.json AfterTool
372
+ const settingsPaths = [
373
+ path.join(os.homedir(), '.gemini', 'settings.json'),
374
+ path.join(os.homedir(), '.gemini', 'antigravity', 'settings.json')
375
+ ];
376
+ for (const agSettingsPath of settingsPaths) {
377
+ if (!fs.existsSync(agSettingsPath)) continue;
378
+ try {
379
+ const agSettings = JSON.parse(fs.readFileSync(agSettingsPath, 'utf8'));
380
+ if (!agSettings.hooks) agSettings.hooks = {};
381
+ if (!agSettings.hooks.AfterTool) agSettings.hooks.AfterTool = [];
382
+
383
+ const yongleEntry = {
384
+ matcher: "*",
385
+ hooks: [{
386
+ type: "command",
387
+ command: `& "D:/Computers/Environments/Nodejs/node.exe" "${archiveScriptPath}"`,
388
+ timeout: 10
389
+ }]
390
+ };
391
+
392
+ // Check if our hook already exists in ANY entry
393
+ const exists = agSettings.hooks.AfterTool.some(entry =>
394
+ entry.hooks && entry.hooks.some(h => h.command && h.command.includes('yongle-auto-archive-hook.js'))
395
+ );
396
+ if (!exists) {
397
+ agSettings.hooks.AfterTool.push(yongleEntry);
398
+ fs.writeFileSync(agSettingsPath, JSON.stringify(agSettings, null, 2) + '\n', 'utf8');
399
+ console.log(` ${green}✓${reset} ${path.basename(path.dirname(agSettingsPath))}/settings.json AfterTool hook registered`);
400
+ }
401
+ } catch(e) {}
402
+ }
370
403
  }
371
404
  }
372
405
 
package/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "yongle-dadian",
3
- "version": "1.3.2",
3
+ "version": "1.3.3",
4
4
  "description": "永乐大典 — AI 开发经验知识库引擎。自动复盘、过程追踪、毫秒级检索。独立于 GSD 运行。",
5
5
  "repository": {
6
6
  "type": "git",
@@ -9,24 +9,70 @@ process.stdin.on('data', chunk => {
9
9
 
10
10
  process.stdin.on('end', () => {
11
11
  try {
12
- const payload = JSON.parse(inputData);
12
+ try {
13
+ const logDir = 'C:/Users/Lemony/.yongle_knowledge/logs';
14
+ if (!fs.existsSync(logDir)) fs.mkdirSync(logDir, { recursive: true });
15
+ fs.appendFileSync(path.join(logDir, 'hook_debug.log'), `${new Date().toISOString()} Input: ${inputData}\n`);
16
+ } catch (e) {}
17
+
18
+ let payload = {};
19
+ try { payload = JSON.parse(inputData); } catch (e) {}
13
20
 
14
- // 只要包含 transcriptPath 且未显式指定 fullyIdle 为 false,即触发归档检查
15
- if (payload.transcriptPath && payload.fullyIdle !== false) {
21
+ const repoModulesDir = 'D:/Computers/AIDevelop/Tools/Skills/yongle-dadian/node_modules';
22
+ const nodeModulesDir = path.join(__dirname, '..', 'node_modules');
23
+ const combinedNodePath = [nodeModulesDir, repoModulesDir, process.env.NODE_PATH].filter(Boolean).join(path.delimiter);
24
+
25
+ // 无论是何种 Hook 事件,无条件触发梦境守护者 (Dreamer) 静默检查
26
+ const dreamerScript = path.join(__dirname, 'yongle-dreamer.js');
27
+ if (fs.existsSync(dreamerScript)) {
28
+ const dreamerChild = spawn('node', [dreamerScript, '--once'], {
29
+ detached: true,
30
+ stdio: 'ignore',
31
+ env: { ...process.env, YONGLE_RUNTIME: 'antigravity', ANTIGRAVITY_AGENT: '1', NODE_PATH: combinedNodePath }
32
+ });
33
+ dreamerChild.unref();
34
+ }
35
+
36
+ function getLatestTranscriptPath() {
37
+ try {
38
+ const brainDir = path.join(os.homedir(), '.gemini', 'antigravity', 'brain');
39
+ if (!fs.existsSync(brainDir)) return null;
40
+ const sessions = fs.readdirSync(brainDir);
41
+ let latestPath = null;
42
+ let latestMtime = 0;
43
+ for (const sid of sessions) {
44
+ const logFile = path.join(brainDir, sid, '.system_generated', 'logs', 'transcript.jsonl');
45
+ if (fs.existsSync(logFile)) {
46
+ const mtime = fs.statSync(logFile).mtimeMs;
47
+ if (mtime > latestMtime) {
48
+ latestMtime = mtime;
49
+ latestPath = logFile;
50
+ }
51
+ }
52
+ }
53
+ return latestPath;
54
+ } catch (e) { return null; }
55
+ }
56
+
57
+ // 兼容 transcript_path (蛇形), transcriptPath (驼峰), session_id 推导, 以及自动扫描最新日志保底
58
+ const transcriptPath = payload.transcript_path
59
+ || payload.transcriptPath
60
+ || (payload.session_id ? path.join(os.homedir(), '.gemini', 'antigravity', 'brain', payload.session_id, '.system_generated', 'logs', 'transcript.jsonl') : null)
61
+ || getLatestTranscriptPath();
62
+
63
+ // 只要能推导出存在的 transcriptPath 且未显式指定 fullyIdle 为 false,即触发归档检查
64
+ if (transcriptPath && fs.existsSync(transcriptPath) && payload.fullyIdle !== false) {
16
65
  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);
20
66
 
21
67
  // 以 Detached (脱机) 模式启动后台归档进程,并切断 stdio 防止阻塞当前进程
22
- const child = spawn('node', [archiverScript, payload.transcriptPath], {
68
+ const child = spawn('node', [archiverScript, transcriptPath], {
23
69
  detached: true,
24
70
  stdio: 'ignore',
25
71
  env: { ...process.env, YONGLE_RUNTIME: 'antigravity', NODE_PATH: combinedNodePath }
26
72
  });
27
73
 
28
74
  child.unref(); // 让当前 Hook 脚本可以立刻退出
29
-
75
+
30
76
  const { logAutoFeature } = require('./yongle-logger');
31
77
  logAutoFeature({
32
78
  feature: 'auto-archive',
@@ -92,7 +92,7 @@ function main() {
92
92
  },
93
93
  {
94
94
  id: 'dreamer',
95
- name: '4. 梦境守护与整理 (Dreamer)',
95
+ name: '3. 梦境守护与整理 (Dreamer)',
96
96
  data: latestMap['dreamer']
97
97
  }
98
98
  ];