@jiugeqqqqq/dsh-house2 0.2.0 → 0.2.1

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
@@ -3,6 +3,10 @@
3
3
  > 每次发版都必须在这里写一条:改了什么、为什么改、别人要不要跟着动。
4
4
  > 版本号跟 `package.json` 走,`npm i` 的人看这里就知道升了什么。
5
5
 
6
+ ## 0.2.1 — 2026-10-30
7
+
8
+ - `house_search` 加 `stage` 参数:先按工段名找到它挂的积木文件(`stage_done` 时写的「积木:xxx」),只在那一个文件里搜,比全目录翻更快更准。不传就还是全目录搜。
9
+
6
10
  ## 0.2.0 — 2026-10-30
7
11
 
8
12
  - 新功能:**工段(任务段)**。不再按轮数切,按「这件事做完了没有」切——`stage_start` 开一座、`stage_done` 收掉(写结果 + 积木文件名)。
package/lib/host/index.js CHANGED
@@ -528,11 +528,12 @@ export function apply(ctx, config = {}) {
528
528
  return out;
529
529
  }
530
530
 
531
- function searchKnowledge(query, limit) {
531
+ function searchKnowledge(query, limit, onlyFiles) {
532
532
  const q = String(query ?? '').trim().toLowerCase();
533
533
  if (!q) return { ok: false, error: { code: 'invalid', message: '要给个关键词。' } };
534
534
  const max = Math.max(1, Math.min(30, Number(limit) || 8));
535
- const files = walkKnowledge(knowledgeDir);
535
+ // 2026-10-30:给了 onlyFiles 就只在这些积木里搜(工段定向检索)。
536
+ const files = Array.isArray(onlyFiles) && onlyFiles.length ? onlyFiles : walkKnowledge(knowledgeDir);
536
537
  const hits = [];
537
538
  for (const f of files) {
538
539
  if (hits.length >= max) break;
@@ -557,6 +558,22 @@ export function apply(ctx, config = {}) {
557
558
  return { ok: true, data: { query: q, hits, scanned: files.length } };
558
559
  }
559
560
 
561
+ /** 按工段名找它挂的积木文件(stage_done 时写的「积木:xxx」)。 */
562
+ function stageBrickFiles(stageName) {
563
+ const name = String(stageName ?? '').trim();
564
+ if (!name) return null;
565
+ const { doing, done } = stages.parse();
566
+ const all = [...doing, ...done];
567
+ const hit = all.find((x) => x.name === name) || all.find((x) => x.name.includes(name) || name.includes(x.name));
568
+ if (!hit) return { error: `没有叫「${name}」的工段` };
569
+ const m = hit.line.match(/积木[::]\s*([^\s|]+)/);
570
+ if (!m) return { error: `工段「${hit.name}」没有记积木文件名` };
571
+ const base = m[1].replace(/\.md$/i, '');
572
+ const file = path.join(knowledgeDir, `${base}.md`);
573
+ if (!fs.existsSync(file)) return { error: `积木文件不存在:${base}.md` };
574
+ return { files: [file], brick: base };
575
+ }
576
+
560
577
 
561
578
  // 2026-10-27:以前「房子清单能不能进模型上下文」要靠**另一个插件**
562
579
  // (dsh-session-rotate 的 assetsPath) 配一下才行 —— 等于装了这个插件的人也
@@ -659,13 +676,20 @@ export function apply(ctx, config = {}) {
659
676
  properties: {
660
677
  query: { type: 'string', description: '关键词,比如 抖音、画图、报错信息里的词' },
661
678
  limit: { type: 'number', description: '最多返回几处,默认 8' },
679
+ stage: { type: 'string', description: '可选:先定位到这个工段,只搜它挂的积木文件(更快更准)' },
662
680
  },
663
681
  required: ['query'],
664
682
  additionalProperties: false,
665
683
  },
666
684
  output,
667
685
  async execute(args) {
668
- const r = searchKnowledge(args?.query, args?.limit);
686
+ let onlyFiles = null;
687
+ if (args?.stage) {
688
+ const sb = stageBrickFiles(args.stage);
689
+ if (!sb || sb.error) return { ok: false, message: sb?.error || '找不到这个工段' };
690
+ onlyFiles = sb.files;
691
+ }
692
+ const r = searchKnowledge(args?.query, args?.limit, onlyFiles);
669
693
  if (!r.ok) return { ok: false, message: r.error?.message || '没搜成' };
670
694
  if (!r.data.hits.length) return { ok: true, message: `积木里没搜到「${r.data.query}」(翻过 ${r.data.scanned} 个文件)` };
671
695
  const body = r.data.hits.map((h) => `${h.file}:${h.line} ${h.text}`).join('\n');
package/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "@jiugeqqqqq/dsh-house2",
3
- "version": "0.2.0",
3
+ "version": "0.2.1",
4
4
  "description": "房子 2 —— 资产/能力清单 + 工段,配侧边栏页面。0.1.0 先把安装跑通(保守兼容写法),功能后续迭代。",
5
5
  "type": "module",
6
6
  "license": "MIT",