autosnippet 3.2.18 → 3.2.20
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 +73 -104
- package/dashboard/dist/assets/{index-CKMy5LY6.js → index-DdvZE4Yd.js} +1 -1
- package/dashboard/dist/index.html +1 -1
- package/dist/bin/cli.js +45 -10
- package/dist/lib/agent/AgentEventBus.js +3 -3
- package/dist/lib/agent/AgentFactory.d.ts +3 -3
- package/dist/lib/agent/AgentFactory.js +4 -4
- package/dist/lib/agent/AgentMessage.d.ts +8 -8
- package/dist/lib/agent/AgentMessage.js +8 -8
- package/dist/lib/agent/AgentRuntime.js +2 -2
- package/dist/lib/agent/AgentState.js +4 -4
- package/dist/lib/agent/ConversationStore.d.ts +1 -1
- package/dist/lib/agent/ConversationStore.js +1 -1
- package/dist/lib/agent/PipelineStrategy.js +1 -1
- package/dist/lib/agent/context/ContextWindow.d.ts +2 -2
- package/dist/lib/agent/context/ContextWindow.js +7 -7
- package/dist/lib/agent/context/ExplorationTracker.js +9 -9
- package/dist/lib/agent/context/exploration/PlanTracker.js +2 -2
- package/dist/lib/agent/context/exploration/SignalDetector.d.ts +1 -1
- package/dist/lib/agent/context/exploration/SignalDetector.js +1 -1
- package/dist/lib/agent/core/LoopContext.d.ts +21 -21
- package/dist/lib/agent/core/LoopContext.js +21 -21
- package/dist/lib/agent/core/SystemPromptBuilder.js +4 -4
- package/dist/lib/agent/domain/EvidenceCollector.js +5 -5
- package/dist/lib/agent/memory/ActiveContext.js +1 -1
- package/dist/lib/agent/memory/MemoryRetriever.js +1 -1
- package/dist/lib/agent/memory/MemoryStore.js +2 -2
- package/dist/lib/agent/memory/SessionStore.js +3 -3
- package/dist/lib/agent/policies.d.ts +1 -1
- package/dist/lib/agent/policies.js +1 -1
- package/dist/lib/agent/strategies.d.ts +1 -1
- package/dist/lib/agent/strategies.js +4 -4
- package/dist/lib/agent/tools/_shared.d.ts +1 -1
- package/dist/lib/agent/tools/_shared.js +1 -1
- package/dist/lib/agent/tools/infrastructure.js +2 -2
- package/dist/lib/cli/SetupService.d.ts +25 -25
- package/dist/lib/cli/SetupService.js +28 -15
- package/dist/lib/cli/deploy/FileDeployer.d.ts +9 -2
- package/dist/lib/cli/deploy/FileDeployer.js +139 -46
- package/dist/lib/cli/deploy/FileManifest.d.ts +23 -39
- package/dist/lib/cli/deploy/FileManifest.js +22 -27
- package/dist/lib/core/AstAnalyzer.d.ts +2 -2
- package/dist/lib/core/AstAnalyzer.js +2 -2
- package/dist/lib/core/analysis/CallEdgeResolver.d.ts +7 -7
- package/dist/lib/core/analysis/CallEdgeResolver.js +9 -9
- package/dist/lib/core/analysis/CallGraphAnalyzer.d.ts +4 -4
- package/dist/lib/core/analysis/CallGraphAnalyzer.js +2 -2
- package/dist/lib/core/analysis/ImportPathResolver.d.ts +0 -2
- package/dist/lib/core/analysis/ImportPathResolver.js +2 -4
- package/dist/lib/core/ast/ProjectGraph.js +7 -7
- package/dist/lib/core/capability/CapabilityProbe.js +6 -14
- package/dist/lib/domain/knowledge/UnifiedValidator.js +2 -2
- package/dist/lib/domain/knowledge/values/Constraints.js +4 -4
- package/dist/lib/domain/knowledge/values/Content.js +6 -6
- package/dist/lib/domain/knowledge/values/Quality.js +5 -5
- package/dist/lib/domain/knowledge/values/Reasoning.js +5 -5
- package/dist/lib/domain/knowledge/values/Relations.js +1 -1
- package/dist/lib/domain/knowledge/values/Stats.js +6 -6
- package/dist/lib/domain/task/TaskIdGenerator.d.ts +4 -4
- package/dist/lib/domain/task/TaskIdGenerator.js +2 -2
- package/dist/lib/external/lark/LarkTransport.js +4 -4
- package/dist/lib/external/mcp/McpServer.d.ts +3 -7
- package/dist/lib/external/mcp/McpServer.js +9 -13
- package/dist/lib/external/mcp/handlers/bootstrap/ExternalSubmissionTracker.js +5 -5
- package/dist/lib/external/mcp/handlers/bootstrap/MissionBriefingBuilder.js +4 -3
- package/dist/lib/external/mcp/handlers/bootstrap/pipeline/BootstrapSnapshot.d.ts +3 -3
- package/dist/lib/external/mcp/handlers/bootstrap/pipeline/BootstrapSnapshot.js +3 -3
- package/dist/lib/external/mcp/handlers/bootstrap/pipeline/IncrementalBootstrap.d.ts +1 -1
- package/dist/lib/external/mcp/handlers/bootstrap/pipeline/IncrementalBootstrap.js +1 -1
- package/dist/lib/external/mcp/handlers/bootstrap/pipeline/dimension-context.js +3 -3
- package/dist/lib/external/mcp/handlers/bootstrap/shared/dimension-sop.js +27 -14
- package/dist/lib/external/mcp/handlers/bootstrap-external.js +6 -0
- package/dist/lib/external/mcp/handlers/dimension-complete-external.js +55 -1
- package/dist/lib/external/mcp/handlers/skill.js +9 -31
- package/dist/lib/external/mcp/handlers/system.js +2 -2
- package/dist/lib/external/mcp/handlers/task.js +16 -1
- package/dist/lib/external/mcp/tools.d.ts +12 -10
- package/dist/lib/external/mcp/tools.js +97 -69
- package/dist/lib/http/utils/routeHelpers.d.ts +1 -1
- package/dist/lib/http/utils/routeHelpers.js +1 -1
- package/dist/lib/http/utils/sse-sessions.d.ts +1 -1
- package/dist/lib/http/utils/sse-sessions.js +1 -1
- package/dist/lib/infrastructure/cache/CacheService.js +1 -1
- package/dist/lib/infrastructure/vector/AsyncPersistence.js +8 -8
- package/dist/lib/infrastructure/vector/BatchEmbedder.d.ts +1 -1
- package/dist/lib/infrastructure/vector/BatchEmbedder.js +2 -2
- package/dist/lib/infrastructure/vector/HnswIndex.d.ts +4 -4
- package/dist/lib/infrastructure/vector/HnswIndex.js +5 -5
- package/dist/lib/infrastructure/vector/HnswVectorAdapter.js +8 -8
- package/dist/lib/infrastructure/vector/ScalarQuantizer.d.ts +1 -1
- package/dist/lib/infrastructure/vector/ScalarQuantizer.js +4 -4
- package/dist/lib/infrastructure/vector/VectorStore.d.ts +1 -1
- package/dist/lib/infrastructure/vector/VectorStore.js +1 -1
- package/dist/lib/injection/ServiceContainer.d.ts +1 -1
- package/dist/lib/injection/ServiceContainer.js +1 -1
- package/dist/lib/platform/NativeUi.d.ts +1 -1
- package/dist/lib/platform/NativeUi.js +1 -1
- package/dist/lib/platform/ios/spm/DependencyGraph.d.ts +1 -1
- package/dist/lib/platform/ios/spm/DependencyGraph.js +1 -1
- package/dist/lib/platform/ios/spm/PolicyEngine.d.ts +1 -1
- package/dist/lib/platform/ios/spm/PolicyEngine.js +1 -1
- package/dist/lib/platform/ios/spm/SpmDiscoverer.js +1 -1
- package/dist/lib/platform/ios/spm/SpmHelper.js +3 -3
- package/dist/lib/platform/ios/xcode/SaveEventFilter.js +2 -2
- package/dist/lib/platform/ios/xcode/XcodeIntegration.js +1 -1
- package/dist/lib/repository/base/BaseRepository.js +1 -1
- package/dist/lib/repository/task/TaskRepository.impl.d.ts +2 -2
- package/dist/lib/repository/task/TaskRepository.impl.js +1 -1
- package/dist/lib/repository/token/TokenUsageStore.js +1 -1
- package/dist/lib/service/automation/ActionPipeline.d.ts +1 -1
- package/dist/lib/service/automation/ActionPipeline.js +1 -1
- package/dist/lib/service/bootstrap/BootstrapEventEmitter.js +2 -2
- package/dist/lib/service/bootstrap/BootstrapTaskManager.d.ts +1 -1
- package/dist/lib/service/bootstrap/BootstrapTaskManager.js +2 -2
- package/dist/lib/service/bootstrap/DimensionCopyRegistry.d.ts +2 -2
- package/dist/lib/service/bootstrap/DimensionCopyRegistry.js +2 -2
- package/dist/lib/service/delivery/AgentInstructionsGenerator.d.ts +6 -15
- package/dist/lib/service/delivery/AgentInstructionsGenerator.js +53 -189
- package/dist/lib/service/delivery/CursorDeliveryPipeline.d.ts +6 -16
- package/dist/lib/service/delivery/CursorDeliveryPipeline.js +14 -19
- package/dist/lib/service/delivery/KnowledgeCompressor.d.ts +1 -1
- package/dist/lib/service/delivery/KnowledgeCompressor.js +1 -1
- package/dist/lib/service/delivery/RulesGenerator.d.ts +10 -3
- package/dist/lib/service/delivery/RulesGenerator.js +43 -3
- package/dist/lib/service/delivery/SkillsSyncer.d.ts +21 -7
- package/dist/lib/service/delivery/SkillsSyncer.js +46 -10
- package/dist/lib/service/delivery/TopicClassifier.d.ts +3 -6
- package/dist/lib/service/delivery/TopicClassifier.js +0 -3
- package/dist/lib/service/guard/ExclusionManager.d.ts +1 -1
- package/dist/lib/service/guard/ExclusionManager.js +1 -1
- package/dist/lib/service/guard/GuardCheckEngine.d.ts +3 -3
- package/dist/lib/service/guard/GuardCheckEngine.js +5 -5
- package/dist/lib/service/guard/GuardCrossFileChecks.d.ts +1 -1
- package/dist/lib/service/guard/GuardFeedbackLoop.d.ts +3 -3
- package/dist/lib/service/guard/GuardFeedbackLoop.js +3 -3
- package/dist/lib/service/guard/GuardPatternUtils.js +1 -1
- package/dist/lib/service/guard/GuardService.d.ts +1 -15
- package/dist/lib/service/guard/GuardService.js +0 -1
- package/dist/lib/service/guard/RuleLearner.d.ts +1 -1
- package/dist/lib/service/guard/RuleLearner.js +1 -1
- package/dist/lib/service/knowledge/CodeEntityGraph.d.ts +3 -3
- package/dist/lib/service/knowledge/CodeEntityGraph.js +3 -3
- package/dist/lib/service/knowledge/KnowledgeService.d.ts +0 -1
- package/dist/lib/service/knowledge/KnowledgeService.js +0 -1
- package/dist/lib/service/module/ModuleService.d.ts +1 -1
- package/dist/lib/service/module/ModuleService.js +2 -2
- package/dist/lib/service/search/HybridRetriever.d.ts +2 -2
- package/dist/lib/service/search/HybridRetriever.js +2 -2
- package/dist/lib/service/search/SearchEngine.d.ts +1 -3
- package/dist/lib/service/search/SearchEngine.js +1 -3
- package/dist/lib/service/search/contextBoost.d.ts +1 -1
- package/dist/lib/service/skills/EventAggregator.js +2 -2
- package/dist/lib/service/skills/SignalCollector.js +1 -1
- package/dist/lib/service/snippet/codecs/VSCodeCodec.js +1 -1
- package/dist/lib/service/task/TaskGraphService.d.ts +0 -3
- package/dist/lib/service/task/TaskGraphService.js +0 -3
- package/dist/lib/service/task/TaskKnowledgeBridge.d.ts +8 -27
- package/dist/lib/service/task/TaskKnowledgeBridge.js +0 -8
- package/dist/lib/service/task/TaskReadyEngine.d.ts +1 -2
- package/dist/lib/service/task/TaskReadyEngine.js +0 -1
- package/dist/lib/service/wiki/WikiRenderers.js +0 -1
- package/dist/lib/service/wiki/WikiUtils.js +2 -7
- package/dist/lib/shared/PathGuard.js +6 -6
- package/dist/lib/shared/schemas/mcp-tools.js +84 -43
- package/dist/scripts/install-vscode-copilot.js +14 -4
- package/package.json +1 -1
- package/skills/autosnippet-create/SKILL.md +131 -131
- package/skills/autosnippet-devdocs/SKILL.md +1 -2
- package/skills/autosnippet-guard/SKILL.md +20 -89
- package/skills/autosnippet-recipes/SKILL.md +35 -117
- package/skills/autosnippet-structure/SKILL.md +23 -55
- package/templates/cursor-rules/autosnippet-skills.mdc +17 -33
- package/templates/instructions/agent-static.md +24 -0
- package/templates/instructions/conventions.md +42 -0
- package/skills/autosnippet-analysis/SKILL.md +0 -169
- package/skills/autosnippet-candidates/SKILL.md +0 -367
- package/skills/autosnippet-coldstart/SKILL.md +0 -988
- package/skills/autosnippet-concepts/SKILL.md +0 -630
- package/skills/autosnippet-intent/SKILL.md +0 -55
- package/skills/autosnippet-lifecycle/SKILL.md +0 -100
- package/templates/copilot-instructions.md +0 -66
- package/templates/cursor-rules/autosnippet-conventions.mdc +0 -172
- package/templates/cursor-rules/autosnippet-workflow.mdc +0 -76
|
@@ -23,7 +23,7 @@ import { Strategy, StrategyRegistry } from './strategies.js';
|
|
|
23
23
|
const _pipelineLogger = Logger.getInstance();
|
|
24
24
|
export class PipelineStrategy extends Strategy {
|
|
25
25
|
#stages;
|
|
26
|
-
/**
|
|
26
|
+
/** 最大重试次数 (Gate 失败时全局兜底) */
|
|
27
27
|
#maxRetries;
|
|
28
28
|
constructor({ stages = [], maxRetries = 1, } = {}) {
|
|
29
29
|
super();
|
|
@@ -62,7 +62,7 @@ export declare class ContextWindow {
|
|
|
62
62
|
* - 微窗口 (<16k): 预算 = 窗口 × 0.7(留 30% 给 prompt/tool schema)
|
|
63
63
|
*
|
|
64
64
|
* @param modelName 模型名称,如 'gemini-3-flash-preview', 'gpt-4o-mini'
|
|
65
|
-
* @param
|
|
65
|
+
* @param [opts] - isSystem 为 true 时给予更高预算
|
|
66
66
|
* @returns 建议的 token 预算
|
|
67
67
|
*/
|
|
68
68
|
static resolveTokenBudget(modelName: string, opts?: {
|
|
@@ -147,7 +147,7 @@ export declare class ContextWindow {
|
|
|
147
147
|
*
|
|
148
148
|
* @param toolName 工具名
|
|
149
149
|
* @param result 工具原始返回
|
|
150
|
-
* @param
|
|
150
|
+
* @param quota 动态配额
|
|
151
151
|
* @returns 压缩后的结果字符串
|
|
152
152
|
*/
|
|
153
153
|
export declare function limitToolResult(toolName: string, result: unknown, quota: ToolResultQuota): string;
|
|
@@ -28,15 +28,15 @@ import { estimateTokensFast } from '#shared/token-utils.js';
|
|
|
28
28
|
* - 或单独的 user/assistant 文本消息
|
|
29
29
|
*/
|
|
30
30
|
export class ContextWindow {
|
|
31
|
-
/**
|
|
31
|
+
/** 统一格式消息 */
|
|
32
32
|
#messages = [];
|
|
33
|
-
/**
|
|
33
|
+
/** token 预算(默认 24000,约对应 Gemini 的安全阈值) */
|
|
34
34
|
#tokenBudget;
|
|
35
|
-
/**
|
|
35
|
+
/** 被压缩掉的轮次摘要(用于 digest 生成) */
|
|
36
36
|
#compactionLog = [];
|
|
37
|
-
/**
|
|
37
|
+
/** 被压缩前提取的已提交候选标题 */
|
|
38
38
|
#compactedSubmits = new Set();
|
|
39
|
-
/**
|
|
39
|
+
/** 日志器 */
|
|
40
40
|
#logger;
|
|
41
41
|
/**
|
|
42
42
|
* 模型名 → 上下文窗口大小映射(token 数)。
|
|
@@ -87,7 +87,7 @@ export class ContextWindow {
|
|
|
87
87
|
* - 微窗口 (<16k): 预算 = 窗口 × 0.7(留 30% 给 prompt/tool schema)
|
|
88
88
|
*
|
|
89
89
|
* @param modelName 模型名称,如 'gemini-3-flash-preview', 'gpt-4o-mini'
|
|
90
|
-
* @param
|
|
90
|
+
* @param [opts] - isSystem 为 true 时给予更高预算
|
|
91
91
|
* @returns 建议的 token 预算
|
|
92
92
|
*/
|
|
93
93
|
static resolveTokenBudget(modelName, opts = {}) {
|
|
@@ -420,7 +420,7 @@ export class ContextWindow {
|
|
|
420
420
|
*
|
|
421
421
|
* @param toolName 工具名
|
|
422
422
|
* @param result 工具原始返回
|
|
423
|
-
* @param
|
|
423
|
+
* @param quota 动态配额
|
|
424
424
|
* @returns 压缩后的结果字符串
|
|
425
425
|
*/
|
|
426
426
|
export function limitToolResult(toolName, result, quota) {
|
|
@@ -28,13 +28,13 @@ import { PlanTracker } from './exploration/PlanTracker.js';
|
|
|
28
28
|
import { SEARCH_TOOLS, SignalDetector } from './exploration/SignalDetector.js';
|
|
29
29
|
// ─── ExplorationTracker 主类 ─────────────────────────────
|
|
30
30
|
export class ExplorationTracker {
|
|
31
|
-
/**
|
|
31
|
+
/** 策略配置 */
|
|
32
32
|
#strategy;
|
|
33
|
-
/**
|
|
33
|
+
/** 预算配置 */
|
|
34
34
|
#budget;
|
|
35
|
-
/**
|
|
35
|
+
/** 当前阶段 */
|
|
36
36
|
#phase;
|
|
37
|
-
/**
|
|
37
|
+
/** 日志器 */
|
|
38
38
|
#logger;
|
|
39
39
|
// ── 子模块 ──
|
|
40
40
|
#signalDetector;
|
|
@@ -54,16 +54,16 @@ export class ExplorationTracker {
|
|
|
54
54
|
phaseRounds: 0,
|
|
55
55
|
};
|
|
56
56
|
// ── 阶段控制 ──
|
|
57
|
-
/**
|
|
57
|
+
/** 是否刚完成阶段转换(用于 pending nudge) */
|
|
58
58
|
#justTransitioned = false;
|
|
59
|
-
/**
|
|
59
|
+
/** 转换前的旧阶段 */
|
|
60
60
|
#transitionFromPhase = null;
|
|
61
61
|
// ── Graceful exit 控制 ──
|
|
62
|
-
/**
|
|
62
|
+
/** 进入 graceful exit 的轮次 */
|
|
63
63
|
#gracefulExitRound = null;
|
|
64
|
-
/**
|
|
64
|
+
/** tick 是否已调用(用于 rollback) */
|
|
65
65
|
#ticked = false;
|
|
66
|
-
/**
|
|
66
|
+
/** 提交工具名(用于 nudge 文本生成) */
|
|
67
67
|
#submitToolName = 'submit_knowledge';
|
|
68
68
|
/** 管线类型标识 — 统一场景判别(替代 submitToolName / strategy.name 字符串比较) */
|
|
69
69
|
#pipelineType;
|
|
@@ -13,9 +13,9 @@ const DEFAULT_DEVIATION_THRESHOLD = 0.6;
|
|
|
13
13
|
/** 最少经过 N 轮后才允许再次触发 replan(防止 replan 风暴) */
|
|
14
14
|
const MIN_REPLAN_GAP = 3;
|
|
15
15
|
export class PlanTracker {
|
|
16
|
-
/**
|
|
16
|
+
/** 等待 AI 输出 replan */
|
|
17
17
|
#pendingReplan = false;
|
|
18
|
-
/**
|
|
18
|
+
/** 计划进度 */
|
|
19
19
|
#planProgress = {
|
|
20
20
|
coveredSteps: 0,
|
|
21
21
|
totalSteps: 0,
|
|
@@ -21,7 +21,7 @@ interface SignalMetrics {
|
|
|
21
21
|
export declare class SignalDetector {
|
|
22
22
|
#private;
|
|
23
23
|
/**
|
|
24
|
-
* @param
|
|
24
|
+
* @param metrics
|
|
25
25
|
*/
|
|
26
26
|
constructor(metrics: SignalMetrics);
|
|
27
27
|
/**
|
|
@@ -30,7 +30,7 @@ export class SignalDetector {
|
|
|
30
30
|
/** 共享引用 — 指向 ExplorationTracker 的 metrics 中的三个 Set */
|
|
31
31
|
#metrics;
|
|
32
32
|
/**
|
|
33
|
-
* @param
|
|
33
|
+
* @param metrics
|
|
34
34
|
*/
|
|
35
35
|
constructor(metrics) {
|
|
36
36
|
this.#metrics = metrics;
|
|
@@ -63,51 +63,51 @@ interface LoopContextConfig {
|
|
|
63
63
|
toolChoiceOverride?: string | null;
|
|
64
64
|
}
|
|
65
65
|
export declare class LoopContext {
|
|
66
|
-
/**
|
|
66
|
+
/** 统一消息适配器 */
|
|
67
67
|
messages: MessageAdapter;
|
|
68
|
-
/**
|
|
68
|
+
/** ExplorationTracker 实例 */
|
|
69
69
|
tracker: ExplorationTracker | null;
|
|
70
|
-
/**
|
|
70
|
+
/** ActiveContext 实例 */
|
|
71
71
|
trace: ActiveContext | null;
|
|
72
|
-
/**
|
|
72
|
+
/** MemoryCoordinator 实例 */
|
|
73
73
|
memoryCoordinator: MemoryCoordinator | null;
|
|
74
|
-
/**
|
|
74
|
+
/** 共享状态 */
|
|
75
75
|
sharedState: SharedState | null;
|
|
76
|
-
/**
|
|
76
|
+
/** 当前迭代次数 */
|
|
77
77
|
iteration: number;
|
|
78
|
-
/**
|
|
78
|
+
/** 最终回复文本 */
|
|
79
79
|
lastReply: string;
|
|
80
|
-
/**
|
|
80
|
+
/** 本轮工具调用记录 */
|
|
81
81
|
toolCalls: any[];
|
|
82
|
-
/**
|
|
82
|
+
/** } 本轮 token 用量 */
|
|
83
83
|
tokenUsage: {
|
|
84
84
|
input: number;
|
|
85
85
|
output: number;
|
|
86
86
|
};
|
|
87
|
-
/**
|
|
87
|
+
/** 循环开始时间戳 */
|
|
88
88
|
loopStartTime: number;
|
|
89
|
-
/**
|
|
89
|
+
/** 连续 AI 错误计数 (2-strike 策略) */
|
|
90
90
|
consecutiveAiErrors: number;
|
|
91
|
-
/**
|
|
91
|
+
/** 连续空响应计数 */
|
|
92
92
|
consecutiveEmptyResponses: number;
|
|
93
|
-
/**
|
|
93
|
+
/** 来源 'user' | 'system' */
|
|
94
94
|
source: string;
|
|
95
|
-
/**
|
|
95
|
+
/** 预算配置 */
|
|
96
96
|
budget: BudgetConfig;
|
|
97
97
|
capabilities: Capability[];
|
|
98
|
-
/**
|
|
98
|
+
/** 基础系统提示词 */
|
|
99
99
|
baseSystemPrompt: string;
|
|
100
|
-
/**
|
|
100
|
+
/** 工具 schemas */
|
|
101
101
|
toolSchemas: Array<Record<string, unknown>>;
|
|
102
|
-
/**
|
|
102
|
+
/** 原始用户提示 */
|
|
103
103
|
prompt: string;
|
|
104
|
-
/**
|
|
104
|
+
/** 工具调用钩子 */
|
|
105
105
|
onToolCall: ToolCallHook | null;
|
|
106
|
-
/**
|
|
106
|
+
/** 额外上下文 */
|
|
107
107
|
context: Record<string, unknown>;
|
|
108
|
-
/**
|
|
108
|
+
/** 原始 ContextWindow 引用 */
|
|
109
109
|
contextWindow: ContextWindow | null;
|
|
110
|
-
/**
|
|
110
|
+
/** 首轮 toolChoice 覆盖 ('required'/'auto'/'none') */
|
|
111
111
|
toolChoiceOverride: string | null;
|
|
112
112
|
constructor(config: LoopContextConfig);
|
|
113
113
|
/** 是否为 system 场景 */
|
|
@@ -13,52 +13,52 @@
|
|
|
13
13
|
*/
|
|
14
14
|
export class LoopContext {
|
|
15
15
|
// ─── 注入依赖 ───
|
|
16
|
-
/**
|
|
16
|
+
/** 统一消息适配器 */
|
|
17
17
|
messages;
|
|
18
|
-
/**
|
|
18
|
+
/** ExplorationTracker 实例 */
|
|
19
19
|
tracker;
|
|
20
|
-
/**
|
|
20
|
+
/** ActiveContext 实例 */
|
|
21
21
|
trace;
|
|
22
|
-
/**
|
|
22
|
+
/** MemoryCoordinator 实例 */
|
|
23
23
|
memoryCoordinator;
|
|
24
|
-
/**
|
|
24
|
+
/** 共享状态 */
|
|
25
25
|
sharedState;
|
|
26
26
|
// ─── 循环状态 ───
|
|
27
|
-
/**
|
|
27
|
+
/** 当前迭代次数 */
|
|
28
28
|
iteration = 0;
|
|
29
|
-
/**
|
|
29
|
+
/** 最终回复文本 */
|
|
30
30
|
lastReply = '';
|
|
31
|
-
/**
|
|
31
|
+
/** 本轮工具调用记录 */
|
|
32
32
|
// eslint-disable-next-line @typescript-eslint/no-explicit-any -- tool call entries have varying shapes (ToolCallEntry, ToolCallRecord, etc.) across callers; no common structural type satisfies all consumers
|
|
33
33
|
toolCalls = [];
|
|
34
|
-
/**
|
|
34
|
+
/** } 本轮 token 用量 */
|
|
35
35
|
tokenUsage = { input: 0, output: 0 };
|
|
36
|
-
/**
|
|
36
|
+
/** 循环开始时间戳 */
|
|
37
37
|
loopStartTime = 0;
|
|
38
38
|
// ─── 错误恢复 ───
|
|
39
|
-
/**
|
|
39
|
+
/** 连续 AI 错误计数 (2-strike 策略) */
|
|
40
40
|
consecutiveAiErrors = 0;
|
|
41
|
-
/**
|
|
41
|
+
/** 连续空响应计数 */
|
|
42
42
|
consecutiveEmptyResponses = 0;
|
|
43
43
|
// ─── 配置 (只读) ───
|
|
44
|
-
/**
|
|
44
|
+
/** 来源 'user' | 'system' */
|
|
45
45
|
source;
|
|
46
|
-
/**
|
|
46
|
+
/** 预算配置 */
|
|
47
47
|
budget;
|
|
48
48
|
capabilities;
|
|
49
|
-
/**
|
|
49
|
+
/** 基础系统提示词 */
|
|
50
50
|
baseSystemPrompt;
|
|
51
|
-
/**
|
|
51
|
+
/** 工具 schemas */
|
|
52
52
|
toolSchemas;
|
|
53
|
-
/**
|
|
53
|
+
/** 原始用户提示 */
|
|
54
54
|
prompt;
|
|
55
|
-
/**
|
|
55
|
+
/** 工具调用钩子 */
|
|
56
56
|
onToolCall;
|
|
57
|
-
/**
|
|
57
|
+
/** 额外上下文 */
|
|
58
58
|
context;
|
|
59
|
-
/**
|
|
59
|
+
/** 原始 ContextWindow 引用 */
|
|
60
60
|
contextWindow;
|
|
61
|
-
/**
|
|
61
|
+
/** 首轮 toolChoice 覆盖 ('required'/'auto'/'none') */
|
|
62
62
|
toolChoiceOverride;
|
|
63
63
|
constructor(config) {
|
|
64
64
|
this.messages = config.messages;
|
|
@@ -12,13 +12,13 @@
|
|
|
12
12
|
* @module SystemPromptBuilder
|
|
13
13
|
*/
|
|
14
14
|
export class SystemPromptBuilder {
|
|
15
|
-
/**
|
|
15
|
+
/** persona 配置 */
|
|
16
16
|
#persona;
|
|
17
|
-
/**
|
|
17
|
+
/** 文件缓存 */
|
|
18
18
|
#fileCache;
|
|
19
|
-
/**
|
|
19
|
+
/** 语言偏好 */
|
|
20
20
|
#lang;
|
|
21
|
-
/**
|
|
21
|
+
/** 记忆配置 */
|
|
22
22
|
#memoryConfig;
|
|
23
23
|
constructor({ persona, fileCache, lang, memoryConfig } = {}) {
|
|
24
24
|
this.#persona = persona || null;
|
|
@@ -25,15 +25,15 @@ const MAX_SEARCH_MATCHES = 5;
|
|
|
25
25
|
const DEFAULT_SNIPPET_BUDGET = 32_000;
|
|
26
26
|
// ── 主类 ──────────────────────────────────────────────────────────
|
|
27
27
|
export class EvidenceCollector {
|
|
28
|
-
/**
|
|
28
|
+
/** 文件 → 证据条目 */
|
|
29
29
|
#evidenceMap = new Map();
|
|
30
|
-
/**
|
|
30
|
+
/** 探索日志 */
|
|
31
31
|
#explorationLog = [];
|
|
32
|
-
/**
|
|
32
|
+
/** 负空间信号 */
|
|
33
33
|
#negativeSignals = [];
|
|
34
|
-
/**
|
|
34
|
+
/** 代码片段总字符预算 */
|
|
35
35
|
#snippetBudget;
|
|
36
|
-
/**
|
|
36
|
+
/** 当前已使用的片段字符数 */
|
|
37
37
|
#snippetCharsUsed = 0;
|
|
38
38
|
/** @param [options.snippetBudget=32000] 代码片段总字符预算 */
|
|
39
39
|
constructor(options = {}) {
|
|
@@ -669,7 +669,7 @@ export class ActiveContext {
|
|
|
669
669
|
// ═══════════════════════════════════════════════════════
|
|
670
670
|
/**
|
|
671
671
|
* 工具结果压缩 — 使用特化策略 (从 WorkingMemory 迁入)
|
|
672
|
-
* @param
|
|
672
|
+
* @param observation
|
|
673
673
|
* @returns }
|
|
674
674
|
*/
|
|
675
675
|
#compressObservation(observation) {
|
|
@@ -23,7 +23,7 @@ const RECENCY_HALF_LIFE_DAYS = 7;
|
|
|
23
23
|
const SIMILARITY_UPDATE = 0.85;
|
|
24
24
|
export class MemoryRetriever {
|
|
25
25
|
#store;
|
|
26
|
-
/**
|
|
26
|
+
/** 向量嵌入函数 */
|
|
27
27
|
#embeddingFn;
|
|
28
28
|
/** @param [opts.embeddingFn] 向量嵌入函数 (异步) */
|
|
29
29
|
constructor(store, opts = {}) {
|
|
@@ -29,9 +29,9 @@ const ARCHIVE_DAYS = 30;
|
|
|
29
29
|
const FORGET_DAYS = 90;
|
|
30
30
|
export class MemoryStore {
|
|
31
31
|
#db;
|
|
32
|
-
/**
|
|
32
|
+
/** 预编译 SQL Statements */
|
|
33
33
|
#stmts = null;
|
|
34
|
-
/**
|
|
34
|
+
/** 动态 update SQL 缓存 */
|
|
35
35
|
#updateStmtCache = new Map();
|
|
36
36
|
/** @param db better-sqlite3 实例 (raw) */
|
|
37
37
|
constructor(db) {
|
|
@@ -43,17 +43,17 @@ const DEFAULT_TTL_MS = CACHE.DEFAULT_TTL_MS;
|
|
|
43
43
|
export class SessionStore {
|
|
44
44
|
// ── 子系统 1: DimensionReports (from EpisodicMemory) ──
|
|
45
45
|
#dimensionReports = new Map();
|
|
46
|
-
/**
|
|
46
|
+
/** filePath → Evidence[] */
|
|
47
47
|
#evidenceStore = new Map();
|
|
48
48
|
#crossReferences = [];
|
|
49
49
|
#tierReflections = [];
|
|
50
|
-
/**
|
|
50
|
+
/** dimId → candidates */
|
|
51
51
|
#submittedCandidates = new Map();
|
|
52
52
|
#projectContext;
|
|
53
53
|
// ── 子系统 2: ReadOnlyCache (from ToolResultCache) ──
|
|
54
54
|
#searchCache = new Map();
|
|
55
55
|
#fileCache = new Map();
|
|
56
|
-
/**
|
|
56
|
+
/** } */
|
|
57
57
|
#cacheStats = { hits: 0, misses: 0, evictions: 0 };
|
|
58
58
|
#ttlMs;
|
|
59
59
|
#cleanupTimer = null;
|
|
@@ -140,7 +140,7 @@ export declare class FanOutStrategy extends Strategy {
|
|
|
140
140
|
constructor({ itemStrategy, tiers, merge }?: FanOutOpts);
|
|
141
141
|
get name(): string;
|
|
142
142
|
/**
|
|
143
|
-
* @param
|
|
143
|
+
* @param opts.items 子任务列表
|
|
144
144
|
*/
|
|
145
145
|
execute(runtime: StrategyRuntime, message: AgentMessage, opts?: FanOutExecuteOpts): Promise<StrategyResult>;
|
|
146
146
|
}
|
|
@@ -86,11 +86,11 @@ export class SingleStrategy extends Strategy {
|
|
|
86
86
|
* })
|
|
87
87
|
*/
|
|
88
88
|
export class FanOutStrategy extends Strategy {
|
|
89
|
-
/**
|
|
89
|
+
/** 每个子任务的执行策略 */
|
|
90
90
|
#itemStrategy;
|
|
91
|
-
/**
|
|
91
|
+
/** >} 分层并发配置 */
|
|
92
92
|
#tiers;
|
|
93
|
-
/**
|
|
93
|
+
/** 结果合并函数 */
|
|
94
94
|
#merge;
|
|
95
95
|
/**
|
|
96
96
|
* @param opts.itemStrategy 每个子任务使用的策略
|
|
@@ -107,7 +107,7 @@ export class FanOutStrategy extends Strategy {
|
|
|
107
107
|
return 'fan_out';
|
|
108
108
|
}
|
|
109
109
|
/**
|
|
110
|
-
* @param
|
|
110
|
+
* @param opts.items 子任务列表
|
|
111
111
|
*/
|
|
112
112
|
async execute(runtime, message, opts = {}) {
|
|
113
113
|
const { items = [] } = opts;
|
|
@@ -18,7 +18,7 @@ export declare const DIMENSION_DISPLAY_GROUP: {
|
|
|
18
18
|
};
|
|
19
19
|
/**
|
|
20
20
|
* 基于维度元数据 (dimensionMeta) 检查提交是否合法
|
|
21
|
-
* @param
|
|
21
|
+
* @param dimensionMeta
|
|
22
22
|
* @param params submit_knowledge 的参数
|
|
23
23
|
* @returns | null} 不合法返回 rejected,合法返回 null
|
|
24
24
|
*/
|
|
@@ -20,7 +20,7 @@ export const DIMENSION_DISPLAY_GROUP = {
|
|
|
20
20
|
};
|
|
21
21
|
/**
|
|
22
22
|
* 基于维度元数据 (dimensionMeta) 检查提交是否合法
|
|
23
|
-
* @param
|
|
23
|
+
* @param dimensionMeta
|
|
24
24
|
* @param params submit_knowledge 的参数
|
|
25
25
|
* @returns | null} 不合法返回 rejected,合法返回 null
|
|
26
26
|
*/
|
|
@@ -85,13 +85,13 @@ export const queryAuditLog = {
|
|
|
85
85
|
// ────────────────────────────────────────────────────────────
|
|
86
86
|
export const loadSkill = {
|
|
87
87
|
name: 'load_skill',
|
|
88
|
-
description: '加载指定的 Agent Skill
|
|
88
|
+
description: '加载指定的 Agent Skill 文档,获取领域操作指南和最佳实践参考。如知识提交 (autosnippet-create)、规范审计 (autosnippet-guard)、项目标准 (autosnippet-recipes) 等。',
|
|
89
89
|
parameters: {
|
|
90
90
|
type: 'object',
|
|
91
91
|
properties: {
|
|
92
92
|
skillName: {
|
|
93
93
|
type: 'string',
|
|
94
|
-
description: 'Skill 目录名(如 autosnippet-
|
|
94
|
+
description: 'Skill 目录名(如 autosnippet-create, autosnippet-guard, autosnippet-recipes 等)',
|
|
95
95
|
},
|
|
96
96
|
},
|
|
97
97
|
required: ['skillName'],
|
|
@@ -67,7 +67,7 @@ export declare class SetupService {
|
|
|
67
67
|
/** 子仓库远程仓库 URL(为空则 recipes/ 作为普通目录随主仓库提交) */
|
|
68
68
|
subRepoUrl: string | undefined;
|
|
69
69
|
/**
|
|
70
|
-
* @param
|
|
70
|
+
* @param options
|
|
71
71
|
*/
|
|
72
72
|
constructor(options: {
|
|
73
73
|
projectRoot: string;
|
|
@@ -106,8 +106,8 @@ export declare class SetupService {
|
|
|
106
106
|
ok: boolean;
|
|
107
107
|
error?: string;
|
|
108
108
|
}[]>;
|
|
109
|
-
/**
|
|
110
|
-
_formatStepDetail
|
|
109
|
+
/** 格式化步骤结果的简要信息 */
|
|
110
|
+
private _formatStepDetail;
|
|
111
111
|
printSummary(): void;
|
|
112
112
|
stepRuntime(): {
|
|
113
113
|
created: string;
|
|
@@ -118,16 +118,16 @@ export declare class SetupService {
|
|
|
118
118
|
subRepoPath: string;
|
|
119
119
|
hasUrl: boolean;
|
|
120
120
|
};
|
|
121
|
-
/**
|
|
122
|
-
_writeConstitution
|
|
123
|
-
/**
|
|
124
|
-
_writeBoxspec
|
|
125
|
-
/**
|
|
126
|
-
_copyRecipeTemplate
|
|
127
|
-
/**
|
|
128
|
-
_copySeedRecipes
|
|
129
|
-
/**
|
|
130
|
-
_writeCoreReadme
|
|
121
|
+
/** 写入 constitution.yaml(优先从模板复制) */
|
|
122
|
+
private _writeConstitution;
|
|
123
|
+
/** 写入 boxspec.json */
|
|
124
|
+
private _writeBoxspec;
|
|
125
|
+
/** 复制 _template.md 到 recipes/ */
|
|
126
|
+
private _copyRecipeTemplate;
|
|
127
|
+
/** 复制示例 Recipe(冷启动推荐) */
|
|
128
|
+
private _copySeedRecipes;
|
|
129
|
+
/** 写入核心目录 README */
|
|
130
|
+
private _writeCoreReadme;
|
|
131
131
|
stepIDE(): {
|
|
132
132
|
configured: string[];
|
|
133
133
|
};
|
|
@@ -135,27 +135,27 @@ export declare class SetupService {
|
|
|
135
135
|
dbPath: string;
|
|
136
136
|
}>;
|
|
137
137
|
/**
|
|
138
|
-
*
|
|
138
|
+
* 从 AutoSnippet/recipes/*.md + candidates/*.md 同步到 DB 缓存
|
|
139
139
|
* 委托 KnowledgeSyncService 执行全字段同步(setup 场景跳过违规记录)
|
|
140
140
|
*/
|
|
141
|
-
_syncRecipesToDB
|
|
141
|
+
private _syncRecipesToDB;
|
|
142
142
|
stepPlatform(): Promise<any>;
|
|
143
143
|
/**
|
|
144
|
-
*
|
|
144
|
+
* 在项目根目录创建 .env 文件(从 .env.example 复制)
|
|
145
145
|
* 如果 .env 已存在则跳过并提示用户手动配置。
|
|
146
146
|
*/
|
|
147
|
-
_ensureEnvFile
|
|
148
|
-
/**
|
|
149
|
-
_git
|
|
150
|
-
/**
|
|
151
|
-
_hasFiles
|
|
152
|
-
/**
|
|
153
|
-
_ensureRemote
|
|
147
|
+
private _ensureEnvFile;
|
|
148
|
+
/** 在指定目录执行 git 命令 */
|
|
149
|
+
private _git;
|
|
150
|
+
/** 检查目录中是否有文件(排除 . 和 ..) */
|
|
151
|
+
private _hasFiles;
|
|
152
|
+
/** 确保子仓库的 remote origin 与给定 URL 一致 */
|
|
153
|
+
private _ensureRemote;
|
|
154
154
|
/**
|
|
155
|
-
*
|
|
155
|
+
* 备份已有文件 → clone → 合并回来(不覆盖远端文件)
|
|
156
156
|
* 适用于 recipes/ 有模板文件但还不是 git 仓库的场景
|
|
157
157
|
*/
|
|
158
|
-
_cloneWithMerge
|
|
158
|
+
private _cloneWithMerge;
|
|
159
159
|
/**
|
|
160
160
|
* 尝试初始化向量索引: 检查 embedding provider 可用性,
|
|
161
161
|
* 若可用则自动构建初始索引;否则提示用户手动运行 asd embed。
|