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.
- package/README.md +18 -5
- package/bin/cli.js +164 -145
- package/config/constitution.yaml +2 -0
- package/dashboard/dist/assets/{index-DNOHYBhy.css → index-BaGY7kJI.css} +1 -1
- package/dashboard/dist/assets/{index-6itPuGFl.js → index-DfHY_3ln.js} +25 -25
- package/dashboard/dist/index.html +2 -2
- package/lib/cli/CliLogger.js +78 -0
- package/lib/cli/SetupService.js +9 -718
- package/lib/cli/UpgradeService.js +23 -398
- package/lib/cli/deploy/FileDeployer.js +562 -0
- package/lib/cli/deploy/FileManifest.js +272 -0
- package/lib/external/mcp/McpServer.js +22 -26
- package/lib/external/mcp/autoApproveInjector.js +1 -0
- package/lib/external/mcp/handlers/bootstrap/BootstrapSession.js +5 -5
- package/lib/external/mcp/handlers/bootstrap/pipeline/EpisodicMemory.js +25 -3
- package/lib/external/mcp/handlers/bootstrap/pipeline/IncrementalBootstrap.js +6 -6
- package/lib/external/mcp/handlers/bootstrap/pipeline/ToolResultCache.js +4 -0
- package/lib/external/mcp/handlers/bootstrap/pipeline/dimension-configs.js +5 -5
- package/lib/external/mcp/handlers/bootstrap/pipeline/orchestrator.js +89 -44
- package/lib/external/mcp/handlers/consolidated.js +8 -9
- package/lib/external/mcp/handlers/dimension-complete-external.js +4 -4
- package/lib/external/mcp/handlers/guard.js +283 -5
- package/lib/external/mcp/handlers/task.js +361 -15
- package/lib/external/mcp/tools.js +32 -81
- package/lib/http/HttpServer.js +4 -0
- package/lib/http/routes/remote.js +1138 -0
- package/lib/http/routes/task.js +56 -0
- package/lib/infrastructure/database/migrations/003_add_remote_commands.js +27 -0
- package/lib/service/chat/AnalystAgent.js +12 -12
- package/lib/service/chat/ChatAgent.js +227 -545
- package/lib/service/chat/ChatAgentPrompts.js +9 -11
- package/lib/service/chat/ContextWindow.js +2 -296
- package/lib/service/chat/EpisodicConsolidator.js +15 -15
- package/lib/service/chat/ExplorationTracker.js +1262 -0
- package/lib/service/chat/HandoffProtocol.js +8 -9
- package/lib/service/chat/Memory.js +4 -0
- package/lib/service/chat/ProducerAgent.js +9 -6
- package/lib/service/chat/ProjectSemanticMemory.js +4 -0
- package/lib/service/chat/ReasoningTrace.js +182 -0
- package/lib/service/chat/WorkingMemory.js +4 -0
- package/lib/service/chat/memory/ActiveContext.js +910 -0
- package/lib/service/chat/memory/MemoryCoordinator.js +662 -0
- package/lib/service/chat/memory/PersistentMemory.js +450 -0
- package/lib/service/chat/memory/SessionStore.js +896 -0
- package/lib/service/chat/memory/index.js +13 -0
- package/lib/service/chat/tools/ast-graph.js +17 -16
- package/lib/service/cursor/AgentInstructionsGenerator.js +76 -47
- package/lib/service/cursor/FileProtection.js +4 -1
- package/lib/service/guard/GuardCheckEngine.js +10 -3
- package/lib/service/task/TaskGraphService.js +3 -3
- package/lib/shared/LanguageService.js +2 -1
- package/package.json +12 -1
- package/skills/autosnippet-intent/SKILL.md +1 -3
- package/skills/autosnippet-recipes/SKILL.md +1 -3
- package/templates/claude-code/commands/prime.md +19 -0
- package/templates/claude-code/hooks/autosnippet-session.sh +63 -0
- package/templates/claude-code/settings.json +21 -0
- package/templates/copilot-instructions.md +64 -177
- package/templates/cursor-hooks/commands/prime.md +12 -0
- package/templates/cursor-hooks/hooks/session-start.sh +10 -0
- package/templates/cursor-hooks/hooks.json +11 -0
- package/templates/cursor-rules/autosnippet-conventions.mdc +52 -3
- package/templates/cursor-rules/autosnippet-workflow.mdc +51 -27
- package/lib/external/mcp/handlers/decide.js +0 -109
- package/lib/external/mcp/handlers/ready.js +0 -42
- package/lib/service/chat/ReasoningLayer.js +0 -888
- package/templates/claude-hooks.yaml +0 -19
package/lib/http/routes/task.js
CHANGED
|
@@ -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 预算 —
|
|
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.
|
|
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
|
-
|
|
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
|
-
//
|
|
319
|
-
|
|
320
|
-
episodicMemory: options.episodicMemory || undefined,
|
|
321
|
-
toolResultCache: options.toolResultCache || undefined,
|
|
318
|
+
// v5.0: 统一 MemoryCoordinator
|
|
319
|
+
memoryCoordinator: options.memoryCoordinator || undefined,
|
|
322
320
|
});
|
|
323
321
|
|
|
324
|
-
//
|
|
325
|
-
//
|
|
326
|
-
//
|
|
327
|
-
const
|
|
328
|
-
|
|
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)
|