autosnippet 3.2.4 → 3.2.7

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.
Files changed (67) hide show
  1. package/README.md +18 -5
  2. package/bin/cli.js +164 -145
  3. package/config/constitution.yaml +2 -0
  4. package/dashboard/dist/assets/{index-DNOHYBhy.css → index-BaGY7kJI.css} +1 -1
  5. package/dashboard/dist/assets/{index-6itPuGFl.js → index-DfHY_3ln.js} +25 -25
  6. package/dashboard/dist/index.html +2 -2
  7. package/lib/cli/CliLogger.js +78 -0
  8. package/lib/cli/SetupService.js +9 -718
  9. package/lib/cli/UpgradeService.js +23 -398
  10. package/lib/cli/deploy/FileDeployer.js +562 -0
  11. package/lib/cli/deploy/FileManifest.js +272 -0
  12. package/lib/external/mcp/McpServer.js +22 -26
  13. package/lib/external/mcp/autoApproveInjector.js +1 -0
  14. package/lib/external/mcp/handlers/bootstrap/BootstrapSession.js +5 -5
  15. package/lib/external/mcp/handlers/bootstrap/pipeline/EpisodicMemory.js +25 -3
  16. package/lib/external/mcp/handlers/bootstrap/pipeline/IncrementalBootstrap.js +6 -6
  17. package/lib/external/mcp/handlers/bootstrap/pipeline/ToolResultCache.js +4 -0
  18. package/lib/external/mcp/handlers/bootstrap/pipeline/dimension-configs.js +5 -5
  19. package/lib/external/mcp/handlers/bootstrap/pipeline/orchestrator.js +89 -44
  20. package/lib/external/mcp/handlers/consolidated.js +8 -9
  21. package/lib/external/mcp/handlers/dimension-complete-external.js +4 -4
  22. package/lib/external/mcp/handlers/guard.js +283 -5
  23. package/lib/external/mcp/handlers/task.js +361 -15
  24. package/lib/external/mcp/tools.js +32 -81
  25. package/lib/http/HttpServer.js +4 -0
  26. package/lib/http/routes/remote.js +1138 -0
  27. package/lib/http/routes/task.js +56 -0
  28. package/lib/infrastructure/database/migrations/003_add_remote_commands.js +27 -0
  29. package/lib/service/chat/AnalystAgent.js +12 -12
  30. package/lib/service/chat/ChatAgent.js +227 -545
  31. package/lib/service/chat/ChatAgentPrompts.js +9 -11
  32. package/lib/service/chat/ContextWindow.js +2 -296
  33. package/lib/service/chat/EpisodicConsolidator.js +15 -15
  34. package/lib/service/chat/ExplorationTracker.js +1262 -0
  35. package/lib/service/chat/HandoffProtocol.js +8 -9
  36. package/lib/service/chat/Memory.js +4 -0
  37. package/lib/service/chat/ProducerAgent.js +9 -6
  38. package/lib/service/chat/ProjectSemanticMemory.js +4 -0
  39. package/lib/service/chat/ReasoningTrace.js +182 -0
  40. package/lib/service/chat/WorkingMemory.js +4 -0
  41. package/lib/service/chat/memory/ActiveContext.js +910 -0
  42. package/lib/service/chat/memory/MemoryCoordinator.js +662 -0
  43. package/lib/service/chat/memory/PersistentMemory.js +450 -0
  44. package/lib/service/chat/memory/SessionStore.js +896 -0
  45. package/lib/service/chat/memory/index.js +13 -0
  46. package/lib/service/chat/tools/ast-graph.js +17 -16
  47. package/lib/service/cursor/AgentInstructionsGenerator.js +76 -47
  48. package/lib/service/cursor/FileProtection.js +4 -1
  49. package/lib/service/guard/GuardCheckEngine.js +10 -3
  50. package/lib/service/task/TaskGraphService.js +3 -3
  51. package/lib/shared/LanguageService.js +2 -1
  52. package/package.json +12 -1
  53. package/skills/autosnippet-intent/SKILL.md +1 -3
  54. package/skills/autosnippet-recipes/SKILL.md +1 -3
  55. package/templates/claude-code/commands/prime.md +19 -0
  56. package/templates/claude-code/hooks/autosnippet-session.sh +63 -0
  57. package/templates/claude-code/settings.json +21 -0
  58. package/templates/copilot-instructions.md +64 -177
  59. package/templates/cursor-hooks/commands/prime.md +12 -0
  60. package/templates/cursor-hooks/hooks/session-start.sh +10 -0
  61. package/templates/cursor-hooks/hooks.json +11 -0
  62. package/templates/cursor-rules/autosnippet-conventions.mdc +52 -3
  63. package/templates/cursor-rules/autosnippet-workflow.mdc +51 -27
  64. package/lib/external/mcp/handlers/decide.js +0 -109
  65. package/lib/external/mcp/handlers/ready.js +0 -42
  66. package/lib/service/chat/ReasoningLayer.js +0 -888
  67. package/templates/claude-hooks.yaml +0 -19
@@ -59,6 +59,7 @@ router.post(
59
59
  if (result.success === false) {
60
60
  return res.status(400).json(result);
61
61
  }
62
+
62
63
  return res.json(result);
63
64
  } catch (err) {
64
65
  return res.status(400).json({
@@ -208,6 +209,57 @@ async function _prime(svc) {
208
209
  const decisionTitles = (result.decisions || []).map((d) => d.title).join('; ');
209
210
  const statsLine = `${result.inProgress.length} in-progress, ${result.ready.length} ready, ${result.stats.total} total`;
210
211
 
212
+ // ── Behavioral Rules Reminder (synced with MCP handler) ──
213
+ result._taskRules = {
214
+ reminder: [
215
+ '📋 TASK RULES (MANDATORY):',
216
+ '🔑 YOU are the task operator — user speaks naturally, you translate to task operations. NEVER tell user to run task commands.',
217
+ '• MUST prime on EVERY message BEFORE anything else',
218
+ '• MUST create task for non-trivial work (≥2 files OR ≥10 lines)',
219
+ '• MUST claim before coding, close when done with meaningful reason',
220
+ '• MUST handle unfinished tasks before starting new work (ask user: Continue/Defer/Abandon)',
221
+ '• NEVER skip prime, NEVER start new work with open in_progress tasks',
222
+ '• NEVER leave tasks in in_progress when session ends — close or defer ALL',
223
+ '• When in doubt → create a task. When idle → ready()',
224
+ '• Session end → close all tasks, defer incomplete, verify zero in_progress',
225
+ ].join('\n'),
226
+ translationHint: [
227
+ 'User Says → You Run:',
228
+ '"fix bug"/"implement" → create→claim→code→close',
229
+ '"continue" → resume in-progress→close',
230
+ '"pause" → defer | "abandon" → fail | "break down" → decompose',
231
+ '"what\'s next" → ready() | "agreed" → record_decision',
232
+ 'Quick question → No task. Just answer.',
233
+ ].join('\n'),
234
+ };
235
+
236
+ // ── Resume Prompt: 有 inProgress 任务时,提示 Agent 让用户选择 ──
237
+ if (result.inProgress.length > 0) {
238
+ const taskList = result.inProgress.map((t) => {
239
+ const age = t.updatedAt
240
+ ? `${Math.floor((Date.now() / 1000 - t.updatedAt) / 86400)}d ago`
241
+ : '';
242
+ return `• **${t.id}** — ${t.title}${age ? ` (${age})` : ''}`;
243
+ }).join('\n');
244
+
245
+ result._resumePrompt = {
246
+ instruction: [
247
+ 'There are unfinished tasks. You MUST present these options to the user BEFORE doing anything else:',
248
+ '',
249
+ '**Unfinished tasks:**',
250
+ taskList,
251
+ '',
252
+ 'Ask the user to choose:',
253
+ '1. **Continue** — resume the unfinished task(s)',
254
+ '2. **Defer** — pause it and work on something else',
255
+ '3. **Abandon** — close/fail it and start fresh',
256
+ '',
257
+ 'Wait for the user\'s answer. Do NOT auto-resume.',
258
+ ].join('\n'),
259
+ taskIds: result.inProgress.map((t) => t.id),
260
+ };
261
+ }
262
+
211
263
  let message;
212
264
  if (decisionCount > 0) {
213
265
  const stalePart = staleCount > 0 ? ` ${staleCount} stale.` : '';
@@ -216,6 +268,10 @@ async function _prime(svc) {
216
268
  message = `${statsLine}.`;
217
269
  }
218
270
 
271
+ if (result.inProgress.length > 0) {
272
+ message += ` ⏸️ ${result.inProgress.length} unfinished task(s) — ask user before resuming.`;
273
+ }
274
+
219
275
  return {
220
276
  success: true,
221
277
  data: result,
@@ -0,0 +1,27 @@
1
+ /**
2
+ * Migration 003 — Remote Command Queue
3
+ *
4
+ * 飞书/Telegram 等 IM 远程指令队列表
5
+ * VSCode 扩展轮询 pending → 注入 Copilot Chat → 回写结果
6
+ */
7
+ export default function migrate(db) {
8
+ db.exec(`
9
+ CREATE TABLE IF NOT EXISTS remote_commands (
10
+ id TEXT PRIMARY KEY,
11
+ source TEXT NOT NULL DEFAULT 'lark',
12
+ chat_id TEXT,
13
+ message_id TEXT,
14
+ user_id TEXT,
15
+ user_name TEXT,
16
+ command TEXT NOT NULL,
17
+ status TEXT NOT NULL DEFAULT 'pending',
18
+ result TEXT,
19
+ created_at INTEGER NOT NULL,
20
+ claimed_at INTEGER,
21
+ completed_at INTEGER
22
+ );
23
+
24
+ CREATE INDEX IF NOT EXISTS idx_remote_commands_status ON remote_commands(status);
25
+ CREATE INDEX IF NOT EXISTS idx_remote_commands_created ON remote_commands(created_at);
26
+ `);
27
+ }
@@ -74,7 +74,7 @@ const ANALYST_TOOLS = [
74
74
  ];
75
75
 
76
76
  // ──────────────────────────────────────────────────────────────────
77
- // Analyst 预算 — 自由探索,不需要 PhaseRouter
77
+ // Analyst 预算 — 使用 analyst 策略(自由探索,无阶段约束)
78
78
  // ──────────────────────────────────────────────────────────────────
79
79
 
80
80
  const ANALYST_BUDGET = {
@@ -283,7 +283,7 @@ export class AnalystAgent {
283
283
  dimConfig,
284
284
  projectInfo,
285
285
  options.dimensionContext,
286
- options.episodicMemory, // v4.0: EpisodicMemory 增强
286
+ options.memoryCoordinator?.getSessionStore(), // v5.0: SessionStore 提供跨维度上下文
287
287
  options.semanticMemory, // v4.1: ProjectSemanticMemory 历史记忆
288
288
  options.codeEntityGraph // Phase E: CodeEntityGraph 代码实体图谱
289
289
  );
@@ -308,24 +308,24 @@ export class AnalystAgent {
308
308
  budget: ANALYST_BUDGET,
309
309
  systemPromptOverride: ANALYST_SYSTEM_PROMPT,
310
310
  allowedTools: ANALYST_TOOLS,
311
- disablePhaseRouter: true,
311
+ strategy: 'analyst',
312
312
  temperature: 0.4,
313
313
  dimensionMeta: {
314
314
  id: dimId,
315
315
  outputType: 'analysis',
316
316
  allowedKnowledgeTypes: dimConfig.allowedKnowledgeTypes || [],
317
317
  },
318
- // v4.0: Agent Memory 注入
319
- workingMemory: options.workingMemory || undefined,
320
- episodicMemory: options.episodicMemory || undefined,
321
- toolResultCache: options.toolResultCache || undefined,
318
+ // v5.0: 统一 MemoryCoordinator
319
+ memoryCoordinator: options.memoryCoordinator || undefined,
322
320
  });
323
321
 
324
- // 构建 AnalysisReport/AnalysisArtifact
325
- // v2: WorkingMemory 可用时使用 buildAnalysisArtifact (包含 evidenceMap/findings/negativeSignals)
326
- // v1: 回退到 buildAnalysisReport (仅 text + referencedFiles)
327
- const report = options.workingMemory
328
- ? buildAnalysisArtifact(result, dimId, this.#projectGraph, options.workingMemory)
322
+ // v5.0: 当有 MemoryCoordinator 时使用 ActiveContext 的 distill 结果
323
+ // 构建 AnalysisArtifact (包含 evidenceMap/findings/negativeSignals)
324
+ // 使用显式 scopeId 确保并行执行安全
325
+ const analystScopeId = `${dimId}:analyst`;
326
+ const ac = options.memoryCoordinator?.getActiveContext(analystScopeId);
327
+ const report = ac
328
+ ? buildAnalysisArtifact(result, dimId, this.#projectGraph, ac)
329
329
  : buildAnalysisReport(result, dimId, this.#projectGraph);
330
330
 
331
331
  // 附加推理链数据(如果 ChatAgent 返回了 ReasoningTrace)