autosnippet 2.8.2 → 2.8.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.
@@ -244,6 +244,8 @@ export async function bootstrapKnowledge(ctx, args) {
244
244
  language: inferLang(f.name),
245
245
  totalLines: lines.length,
246
246
  priority: inferFilePriority(f.name),
247
+ // content 仅保留在内存中供 Phase 5 异步 pipeline 使用
248
+ // MCP 响应不包含文件内容(避免 1MB+ 响应导致 Cursor 无法处理)
247
249
  content: lines.slice(0, contentMaxLines).join('\n'),
248
250
  truncated: lines.length > contentMaxLines,
249
251
  });
@@ -344,7 +346,19 @@ export async function bootstrapKnowledge(ctx, args) {
344
346
  fileCount: (targetFileMap[name] || []).length,
345
347
  };
346
348
  }),
347
- filesByTarget: targetFileMap,
349
+ // 响应中只返回每个 target 的高优先级文件摘要(不含 content),
350
+ // 避免 500+ 文件清单导致响应过大。完整文件列表保留在服务端供 Phase 5 使用。
351
+ filesByTarget: Object.fromEntries(
352
+ Object.entries(targetFileMap).map(([target, files]) => {
353
+ const sorted = [...files].sort((a, b) => (b.priority || 0) - (a.priority || 0));
354
+ const top = sorted.slice(0, 10);
355
+ return [target, {
356
+ totalFiles: files.length,
357
+ topFiles: top.map(({ content, ...meta }) => meta),
358
+ ...(files.length > 10 ? { truncated: true } : {}),
359
+ }];
360
+ })
361
+ ),
348
362
  dependencyGraph: depGraphData ? {
349
363
  nodes: (depGraphData.nodes || []).map(n => ({
350
364
  id: typeof n === 'string' ? n : n.id,
@@ -394,44 +408,23 @@ export async function bootstrapKnowledge(ctx, args) {
394
408
  } : null,
395
409
  } : null,
396
410
 
397
- // 引导 Agent 下一步操作(严格质量要求)
411
+ // 引导 Agent 下一步操作
398
412
  nextSteps: [
399
- '⚠️ 重要:以下 Candidate 为启发式初稿,质量不足以直接发布。你必须执行以下步骤提升质量:',
413
+ ' Bootstrap 骨架已创建,9 个维度的 AI 分析任务已在后台启动。',
400
414
  '',
401
- '== 第一步:结构补齐 ==',
402
- '1. 调用 autosnippet_enrich_candidates(candidateIds) 获取每条候选的缺失字段清单',
403
- '2. 根据返回的 missingFields,分析 filesByTarget 中的代码内容,逐条补全:',
404
- ' - category(必填): View/Service/Tool/Model/Network/Storage/UI/Utility',
405
- ' - trigger(必填): @开头的触发词,如 @video-cover-cell',
406
- ' - summary_cn(必填): ≤100字中文摘要,准确描述代码意图,禁止泛化模板',
407
- ' - summary_en(必填): ≤100 words 英文摘要',
408
- ' - headers(必填): 完整 import/include 语句数组',
409
- ' - reasoning.whyStandard(必填): 为什么这段代码值得沉淀',
410
- ' - reasoning.sources(必填): 来源文件路径列表',
411
- ' - reasoning.confidence(必填): 置信度 0-1',
415
+ '== 后台自动执行中 ==',
416
+ '后台 AI pipeline 正在逐维度分析代码并创建候选(Analyst → Producer 双 Agent 模式)。',
417
+ '进度通过 Dashboard 实时展示,无需手动操作。',
412
418
  '',
413
- '== 第二步:AI 内容润色 ==',
414
- '3. 调用 autosnippet_bootstrap_refine() 对全部候选进行 AI 精炼',
415
- ' - 改善模板化 summary 精准自然语言描述',
416
- ' - 补充架构 insight 洞察',
417
- ' - 推断 relations 关联(requires/extends/calls)',
418
- ' - 调整 confidence 评分',
419
+ '== 完成后可执行的后续操作 ==',
420
+ '1. 调用 autosnippet_enrich_candidates(candidateIds) 补全候选缺失字段',
421
+ '2. 调用 autosnippet_bootstrap_refine() 对候选进行 AI 精炼',
422
+ '3. 使用 autosnippet_submit_candidates 手动提交更多候选',
423
+ '4. 使用 autosnippet_load_skill 加载自动生成的 Project Skills',
419
424
  '',
420
- '== 第三步:深入分析补充 ==',
421
- '4. 逐 Target 深入分析 filesByTarget,按 analysisFramework.dimensions 补充更细粒度候选',
422
- '5. 优先分析 priority=high 的文件和 inferredRole=core/service Target',
423
- '6. 参考 dependencyGraph 理解模块间依赖关系',
424
- '7. 参考 guardViolationFiles 了解已发现的规范违反(代码问题由 Guard 独立处理)',
425
- '8. Agent注意事项维度需包含 trigger 字段(如 @agent-threading)',
426
- '9. 新提交的候选重复 Step 1-3 确保质量',
427
- '',
428
- '== 注意:宏观维度走 Project Skills,不产生 Candidate ==',
429
- '宏观维度(architecture、code-standard、project-profile、agent-guidelines)',
430
- '已自动生成 Project Skill 到 AutoSnippet/skills/,可通过 autosnippet_load_skill 加载。',
431
- '这些维度不会创建 Candidate/Recipe,避免重复。后续 AI 精炼步骤仅针对微观维度的 Candidate。',
432
- '',
433
- '质量红线:summary 不得包含「本模块」「该文件」等泛化措辞;每条候选必须有 reasoning;confidence < 0.5 的需标注原因。',
434
- '三大核心原则(严谨性·深度特征·完整性)已写入 project-agent-guidelines Skill,Agent 加载后自动遵循。',
425
+ '== 宏观维度 → Project Skills ==',
426
+ '宏观维度(architecture/code-standard/project-profile/agent-guidelines/objc-deep-scan/category-scan)',
427
+ '自动生成 Project Skill AutoSnippet/skills/,可通过 autosnippet_load_skill 加载。',
435
428
  ],
436
429
  };
437
430
 
@@ -7,7 +7,6 @@ import fs from 'node:fs';
7
7
  import path from 'node:path';
8
8
  import { envelope } from '../envelope.js';
9
9
  import { TOOLS, TOOL_GATEWAY_MAP } from '../tools.js';
10
- import * as Paths from '../../../infrastructure/config/Paths.js';
11
10
 
12
11
  export async function health(ctx) {
13
12
  const checks = { database: false, gateway: false, vectorStore: false };
@@ -77,10 +76,11 @@ export async function health(ctx) {
77
76
  issues.push(`vectorStore: ${e.message}`);
78
77
  }
79
78
 
80
- // 5) 版本号(从 package.json 读取,缓存到模块级变量)
79
+ // 5) 版本号(从 AutoSnippet 包自身的 package.json 读取,不依赖 cwd)
81
80
  if (!_pkgVersion) {
82
81
  try {
83
- const pkgPath = path.resolve(Paths.ROOT_DIR || process.cwd(), 'package.json');
82
+ const __dir = path.dirname(new URL(import.meta.url).pathname);
83
+ const pkgPath = path.resolve(__dir, '../../../../package.json');
84
84
  _pkgVersion = JSON.parse(fs.readFileSync(pkgPath, 'utf8')).version || '2.0.0';
85
85
  } catch {
86
86
  _pkgVersion = '2.0.0';
package/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "autosnippet",
3
- "version": "2.8.2",
3
+ "version": "2.8.3",
4
4
  "description": "AutoSnippet - 连接开发者、AI 与项目知识库的工具",
5
5
  "type": "module",
6
6
  "main": "lib/bootstrap.js",