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
|
@@ -15,7 +15,7 @@ import { PackageSwiftParser } from './PackageSwiftParser.js';
|
|
|
15
15
|
export class SpmDiscoverer extends ProjectDiscoverer {
|
|
16
16
|
#parser = null;
|
|
17
17
|
#projectRoot = null;
|
|
18
|
-
/**
|
|
18
|
+
/** >} */
|
|
19
19
|
#parsedPackages = [];
|
|
20
20
|
get id() {
|
|
21
21
|
return 'spm';
|
|
@@ -21,7 +21,7 @@ export class SpmHelper {
|
|
|
21
21
|
#targetPackageMap;
|
|
22
22
|
/** 包级依赖图:packagePath → Set<packagePath>(用于跨包循环检测) */
|
|
23
23
|
#packageDepGraph;
|
|
24
|
-
/**
|
|
24
|
+
/** 磁盘缓存层 */
|
|
25
25
|
#graphCache;
|
|
26
26
|
constructor(projectRoot, options = {}) {
|
|
27
27
|
this.#projectRoot = projectRoot;
|
|
@@ -181,7 +181,7 @@ export class SpmHelper {
|
|
|
181
181
|
// ─────────────── 包级依赖图构建 ───────────────
|
|
182
182
|
/**
|
|
183
183
|
* 解析所有 Package.swift 中的 .package(path: "...") 声明,构建包级依赖图
|
|
184
|
-
* @param
|
|
184
|
+
* @param allParsed
|
|
185
185
|
*/
|
|
186
186
|
#buildPackageDepGraph(allParsed) {
|
|
187
187
|
this.#packageDepGraph.clear();
|
|
@@ -392,7 +392,7 @@ export class SpmHelper {
|
|
|
392
392
|
* 确保 Package.swift 中有对目标包的 .package(path: "...") 声明
|
|
393
393
|
* @param content Package.swift 内容
|
|
394
394
|
* @param fromPkgPath 当前包的 Package.swift 路径
|
|
395
|
-
* @param
|
|
395
|
+
* @param toPkg 目标包信息
|
|
396
396
|
* @returns }
|
|
397
397
|
*/
|
|
398
398
|
#ensurePackageDependency(content, fromPkgPath, toPkg) {
|
|
@@ -36,9 +36,9 @@ class SaveEventFilter {
|
|
|
36
36
|
_contentHashes;
|
|
37
37
|
_selfWrites;
|
|
38
38
|
constructor() {
|
|
39
|
-
/**
|
|
39
|
+
/** filePath → 最后一次 self-write 的时间戳 */
|
|
40
40
|
this._selfWrites = new Map();
|
|
41
|
-
/**
|
|
41
|
+
/** filePath → 上次处理时的内容 MD5 哈希 */
|
|
42
42
|
this._contentHashes = new Map();
|
|
43
43
|
// 定期清理过期条目,防止内存泄漏
|
|
44
44
|
this._cleanupInterval = setInterval(() => this._cleanup(), 60_000);
|
|
@@ -90,7 +90,7 @@ export async function insertHeaders(watcher, fullPath, headers, opts = {}) {
|
|
|
90
90
|
const CM = await import('../../ClipboardManager.js');
|
|
91
91
|
const NU = (await import('../../NativeUi.js'));
|
|
92
92
|
const result = { inserted: [], skipped: [], cancelled: false };
|
|
93
|
-
/**
|
|
93
|
+
/** 模块名 → 提示注释('提示操作插入'按钮选择时记录) */
|
|
94
94
|
const depWarnings = opts.depWarnings instanceof Map ? new Map(opts.depWarnings) : new Map();
|
|
95
95
|
if (!headers || headers.length === 0) {
|
|
96
96
|
return result;
|
|
@@ -12,7 +12,7 @@ export class BaseRepository {
|
|
|
12
12
|
db;
|
|
13
13
|
logger;
|
|
14
14
|
tableName;
|
|
15
|
-
/**
|
|
15
|
+
/** lazily-populated column whitelist */
|
|
16
16
|
#columnWhitelist = null;
|
|
17
17
|
constructor(database, tableName) {
|
|
18
18
|
// 校验 tableName 防止 SQL 注入(与列名使用相同的标识符规则)
|
|
@@ -64,8 +64,8 @@ export declare class TaskRepositoryImpl {
|
|
|
64
64
|
db: Database;
|
|
65
65
|
logger: WinstonLogger;
|
|
66
66
|
constructor(database: DatabaseWrapper, drizzle?: DrizzleDB);
|
|
67
|
-
/**
|
|
68
|
-
_prepareStatements
|
|
67
|
+
/** 预编译复杂查询(仅保留 drizzle 无法表达的递归 CTE) */
|
|
68
|
+
private _prepareStatements;
|
|
69
69
|
/**
|
|
70
70
|
* 创建任务
|
|
71
71
|
* ★ Drizzle 类型安全 INSERT
|
|
@@ -25,7 +25,7 @@ export class TaskRepositoryImpl {
|
|
|
25
25
|
this.#drizzle = drizzle ?? getDrizzle();
|
|
26
26
|
this._prepareStatements();
|
|
27
27
|
}
|
|
28
|
-
/**
|
|
28
|
+
/** 预编译复杂查询(仅保留 drizzle 无法表达的递归 CTE) */
|
|
29
29
|
_prepareStatements() {
|
|
30
30
|
// ── 环检测 (递归 CTE) — drizzle 不支持递归 CTE ──
|
|
31
31
|
this._reachableStmt = this.db.prepare(`
|
|
@@ -21,7 +21,7 @@ export class TokenUsageStore {
|
|
|
21
21
|
#dailyStmt;
|
|
22
22
|
#bySourceStmt;
|
|
23
23
|
#summaryStmt;
|
|
24
|
-
/**
|
|
24
|
+
/** | null} */
|
|
25
25
|
#reportCache = null;
|
|
26
26
|
/** @param db — raw better-sqlite3 instance */
|
|
27
27
|
constructor(db, drizzle) {
|
|
@@ -13,7 +13,7 @@ export declare class ActionPipeline {
|
|
|
13
13
|
register(type: string, handler: (trigger: Record<string, unknown>, context: Record<string, unknown>) => Promise<unknown>): void;
|
|
14
14
|
/**
|
|
15
15
|
* 执行管线
|
|
16
|
-
* @param
|
|
16
|
+
* @param trigger
|
|
17
17
|
* @returns >}
|
|
18
18
|
*/
|
|
19
19
|
execute(trigger: {
|
|
@@ -7,9 +7,9 @@
|
|
|
7
7
|
* @module shared/BootstrapEventEmitter
|
|
8
8
|
*/
|
|
9
9
|
export class BootstrapEventEmitter {
|
|
10
|
-
/**
|
|
10
|
+
/** EventBus 实例 */
|
|
11
11
|
#eventBus;
|
|
12
|
-
/**
|
|
12
|
+
/** BootstrapTaskManager 实例 */
|
|
13
13
|
#taskManager;
|
|
14
14
|
/** @param container DI Container */
|
|
15
15
|
constructor(container) {
|
|
@@ -102,7 +102,7 @@ export declare class BootstrapTaskManager {
|
|
|
102
102
|
*
|
|
103
103
|
* 如果上一个会话仍在运行,自动 abort 后再创建新会话(防止重复触发产出重复 Candidate)。
|
|
104
104
|
*
|
|
105
|
-
* @param
|
|
105
|
+
* @param taskDefs 任务定义列表
|
|
106
106
|
*/
|
|
107
107
|
startSession(taskDefs: TaskDef[]): BootstrapSession;
|
|
108
108
|
/**
|
|
@@ -118,7 +118,7 @@ class BootstrapSession {
|
|
|
118
118
|
export class BootstrapTaskManager {
|
|
119
119
|
#currentSession = null;
|
|
120
120
|
#eventBus = null;
|
|
121
|
-
/**
|
|
121
|
+
/** 获取 RealtimeService 的 getter(延迟获取,避免循环依赖) */
|
|
122
122
|
#getRealtimeService = null;
|
|
123
123
|
constructor({ eventBus, getRealtimeService } = {}) {
|
|
124
124
|
this.#eventBus = eventBus || null;
|
|
@@ -132,7 +132,7 @@ export class BootstrapTaskManager {
|
|
|
132
132
|
*
|
|
133
133
|
* 如果上一个会话仍在运行,自动 abort 后再创建新会话(防止重复触发产出重复 Candidate)。
|
|
134
134
|
*
|
|
135
|
-
* @param
|
|
135
|
+
* @param taskDefs 任务定义列表
|
|
136
136
|
*/
|
|
137
137
|
startSession(taskDefs) {
|
|
138
138
|
// ── 并发锁:如果上一个 session 还在运行,先中止 ──
|
|
@@ -25,7 +25,7 @@ export declare class DimensionCopy {
|
|
|
25
25
|
/**
|
|
26
26
|
* 批量为维度数组注入语言差异化文案(单语言版本)
|
|
27
27
|
* 会直接修改维度对象的 label 和 guide 字段
|
|
28
|
-
* @param
|
|
28
|
+
* @param dimensions
|
|
29
29
|
* @param lang 主语言
|
|
30
30
|
* @returns >} 原数组引用
|
|
31
31
|
*/
|
|
@@ -46,7 +46,7 @@ export declare class DimensionCopy {
|
|
|
46
46
|
* - guide 以主语言为主体,追加次要语言的差异化要点
|
|
47
47
|
* - 如果主语言和次要语言属于同一语言族,跳过(避免重复)
|
|
48
48
|
*
|
|
49
|
-
* @param
|
|
49
|
+
* @param dimensions
|
|
50
50
|
* @param primary 主语言 ID
|
|
51
51
|
* @param secondary 次要语言 ID 列表
|
|
52
52
|
* @returns >} 原数组引用
|
|
@@ -311,7 +311,7 @@ export class DimensionCopy {
|
|
|
311
311
|
/**
|
|
312
312
|
* 批量为维度数组注入语言差异化文案(单语言版本)
|
|
313
313
|
* 会直接修改维度对象的 label 和 guide 字段
|
|
314
|
-
* @param
|
|
314
|
+
* @param dimensions
|
|
315
315
|
* @param lang 主语言
|
|
316
316
|
* @returns >} 原数组引用
|
|
317
317
|
*/
|
|
@@ -333,7 +333,7 @@ export class DimensionCopy {
|
|
|
333
333
|
* - guide 以主语言为主体,追加次要语言的差异化要点
|
|
334
334
|
* - 如果主语言和次要语言属于同一语言族,跳过(避免重复)
|
|
335
335
|
*
|
|
336
|
-
* @param
|
|
336
|
+
* @param dimensions
|
|
337
337
|
* @param primary 主语言 ID
|
|
338
338
|
* @param secondary 次要语言 ID 列表
|
|
339
339
|
* @returns >} 原数组引用
|
|
@@ -8,7 +8,7 @@
|
|
|
8
8
|
*
|
|
9
9
|
* 设计原则:
|
|
10
10
|
* 1. 内容来源统一 — 从 _loadEntries() 已加载的知识条目中提取
|
|
11
|
-
* 2.
|
|
11
|
+
* 2. 互补不重复 — .mdc 处理行为规则,Channel F 处理项目知识
|
|
12
12
|
* 3. 轻量索引 — 只输出摘要和规则,详细内容引导至 MCP 工具
|
|
13
13
|
* 4. 幂等生成 — 每次 deliver 重写全部文件,不做增量 diff
|
|
14
14
|
*/
|
|
@@ -59,7 +59,6 @@ export declare class AgentInstructionsGenerator {
|
|
|
59
59
|
};
|
|
60
60
|
/**
|
|
61
61
|
* 从知识条目构建共享内容段
|
|
62
|
-
* @private
|
|
63
62
|
*/
|
|
64
63
|
_buildSections({ rules, patterns, skills, }: {
|
|
65
64
|
rules: KnowledgeEntryProps[];
|
|
@@ -71,7 +70,6 @@ export declare class AgentInstructionsGenerator {
|
|
|
71
70
|
skillLines: string[];
|
|
72
71
|
toolLines: string[];
|
|
73
72
|
};
|
|
74
|
-
/** @private */
|
|
75
73
|
_writeAgentsMd(sections: {
|
|
76
74
|
ruleLines: string[];
|
|
77
75
|
patternRows: string[];
|
|
@@ -82,7 +80,6 @@ export declare class AgentInstructionsGenerator {
|
|
|
82
80
|
tokensUsed: number;
|
|
83
81
|
skipped: boolean;
|
|
84
82
|
};
|
|
85
|
-
/** @private */
|
|
86
83
|
_writeClaudeMd(sections: {
|
|
87
84
|
ruleLines: string[];
|
|
88
85
|
patternRows: string[];
|
|
@@ -95,10 +92,9 @@ export declare class AgentInstructionsGenerator {
|
|
|
95
92
|
};
|
|
96
93
|
/**
|
|
97
94
|
* 动态生成 copilot-instructions.md
|
|
98
|
-
*
|
|
99
|
-
* @private
|
|
95
|
+
* 读取 templates/instructions/conventions.md + HTML markers
|
|
100
96
|
*/
|
|
101
|
-
_writeCopilotInstructions(
|
|
97
|
+
_writeCopilotInstructions(_sections: {
|
|
102
98
|
ruleLines: string[];
|
|
103
99
|
patternRows: string[];
|
|
104
100
|
skillLines: string[];
|
|
@@ -109,14 +105,9 @@ export declare class AgentInstructionsGenerator {
|
|
|
109
105
|
skipped: boolean;
|
|
110
106
|
};
|
|
111
107
|
/**
|
|
112
|
-
*
|
|
113
|
-
*
|
|
108
|
+
* 读取 templates/instructions/conventions.md — 唯一内容源
|
|
109
|
+
* .mdc、copilot-instructions.md、Channel F 动态版全部从这里读取
|
|
114
110
|
*/
|
|
115
|
-
|
|
116
|
-
/**
|
|
117
|
-
* 推荐工作流(AGENTS.md 用)
|
|
118
|
-
* @private
|
|
119
|
-
*/
|
|
120
|
-
_renderWorkflow(): string[];
|
|
111
|
+
_loadConventionsTemplate(): string;
|
|
121
112
|
}
|
|
122
113
|
export default AgentInstructionsGenerator;
|
|
@@ -8,17 +8,17 @@
|
|
|
8
8
|
*
|
|
9
9
|
* 设计原则:
|
|
10
10
|
* 1. 内容来源统一 — 从 _loadEntries() 已加载的知识条目中提取
|
|
11
|
-
* 2.
|
|
11
|
+
* 2. 互补不重复 — .mdc 处理行为规则,Channel F 处理项目知识
|
|
12
12
|
* 3. 轻量索引 — 只输出摘要和规则,详细内容引导至 MCP 工具
|
|
13
13
|
* 4. 幂等生成 — 每次 deliver 重写全部文件,不做增量 diff
|
|
14
14
|
*/
|
|
15
15
|
import fs from 'node:fs';
|
|
16
16
|
import path from 'node:path';
|
|
17
|
+
import { TEMPLATES_DIR } from '../../shared/package-root.js';
|
|
17
18
|
import { checkWriteSafety, safeWriteFile } from './FileProtection.js';
|
|
18
19
|
import { estimateTokens } from './TokenBudget.js';
|
|
19
20
|
/**
|
|
20
21
|
* Agent 指令文件 token 预算
|
|
21
|
-
* AGENTS.md / CLAUDE.md 不受 Cursor 200K 限制,但需控制体积以便 Agent 快速消化
|
|
22
22
|
*/
|
|
23
23
|
const AGENT_BUDGET = Object.freeze({
|
|
24
24
|
MAX_RULES: 15,
|
|
@@ -28,6 +28,10 @@ const AGENT_BUDGET = Object.freeze({
|
|
|
28
28
|
});
|
|
29
29
|
/** MCP 工具清单 — 精简版(跟随实际 MCP handler 注册名称) */
|
|
30
30
|
const MCP_TOOLS_SUMMARY = [
|
|
31
|
+
{
|
|
32
|
+
name: 'autosnippet_task',
|
|
33
|
+
desc: 'Task & decision management: prime (CALL FIRST every message) / create/claim/close/fail/defer/progress/decompose / record_decision/revise_decision',
|
|
34
|
+
},
|
|
31
35
|
{
|
|
32
36
|
name: 'autosnippet_search',
|
|
33
37
|
desc: 'Search knowledge base (mode: auto/context/keyword/semantic)',
|
|
@@ -47,13 +51,9 @@ const MCP_TOOLS_SUMMARY = [
|
|
|
47
51
|
{ name: 'autosnippet_guard', desc: 'Code compliance check (single file or batch audit)' },
|
|
48
52
|
{ name: 'autosnippet_structure', desc: 'Project structure discovery (targets/files/metadata)' },
|
|
49
53
|
{ name: 'autosnippet_graph', desc: 'Knowledge graph query (query/impact/path/stats)' },
|
|
50
|
-
{ name: 'autosnippet_skill', desc: 'Skill management (list/load/create/update/delete
|
|
54
|
+
{ name: 'autosnippet_skill', desc: 'Skill management (list/load/create/update/delete)' },
|
|
51
55
|
{ name: 'autosnippet_save_document', desc: 'Save development document (auto-publish)' },
|
|
52
|
-
{ name: 'autosnippet_bootstrap', desc: 'Project cold-start & scan
|
|
53
|
-
{
|
|
54
|
-
name: 'autosnippet_task',
|
|
55
|
-
desc: 'Unified task & decision management: prime (session entry, CALL FIRST) / create/claim/close/fail/defer/progress/decompose (task CRUD) / record_decision/revise_decision/unpin_decision/list_decisions (decisions)',
|
|
56
|
-
},
|
|
56
|
+
{ name: 'autosnippet_bootstrap', desc: 'Project cold-start & scan' },
|
|
57
57
|
{ name: 'autosnippet_health', desc: 'Service health & KB statistics' },
|
|
58
58
|
{ name: 'autosnippet_capabilities', desc: 'List all available MCP tools (self-discovery)' },
|
|
59
59
|
];
|
|
@@ -78,15 +78,18 @@ export class AgentInstructionsGenerator {
|
|
|
78
78
|
const startTime = Date.now();
|
|
79
79
|
// 构建共享内容块
|
|
80
80
|
const sections = this._buildSections({ rules, patterns, skills });
|
|
81
|
-
//
|
|
82
|
-
//
|
|
83
|
-
//
|
|
81
|
+
// AGENTS.md 与 CLAUDE.md 互斥(双向):
|
|
82
|
+
// 有 CLAUDE.md → 走 CLAUDE.md 路线(跳过 AGENTS.md)
|
|
83
|
+
// 否则 → 走 AGENTS.md 路线(跳过 CLAUDE.md)
|
|
84
84
|
const claudePath = path.join(this.projectRoot, 'CLAUDE.md');
|
|
85
|
-
const
|
|
86
|
-
const
|
|
87
|
-
|
|
85
|
+
const agentsPath = path.join(this.projectRoot, 'AGENTS.md');
|
|
86
|
+
const useClaudeMode = fs.existsSync(claudePath);
|
|
87
|
+
const agents = useClaudeMode
|
|
88
|
+
? { filePath: agentsPath, tokensUsed: 0, skipped: true }
|
|
88
89
|
: this._writeAgentsMd(sections);
|
|
89
|
-
const claude =
|
|
90
|
+
const claude = useClaudeMode
|
|
91
|
+
? this._writeClaudeMd(sections)
|
|
92
|
+
: { filePath: claudePath, tokensUsed: 0, skipped: true };
|
|
90
93
|
const copilot = this._writeCopilotInstructions(sections);
|
|
91
94
|
const duration = Date.now() - startTime;
|
|
92
95
|
const allResults = [agents, claude, copilot];
|
|
@@ -114,7 +117,6 @@ export class AgentInstructionsGenerator {
|
|
|
114
117
|
// ─── 内容构建 ──────────────────────────────────────
|
|
115
118
|
/**
|
|
116
119
|
* 从知识条目构建共享内容段
|
|
117
|
-
* @private
|
|
118
120
|
*/
|
|
119
121
|
_buildSections({ rules, patterns, skills, }) {
|
|
120
122
|
// 编码规则(Channel A 格式,一行一条)
|
|
@@ -157,103 +159,64 @@ export class AgentInstructionsGenerator {
|
|
|
157
159
|
return { ruleLines, patternRows, skillLines, toolLines };
|
|
158
160
|
}
|
|
159
161
|
// ─── AGENTS.md ─────────────────────────────────────
|
|
160
|
-
/** @private */
|
|
161
162
|
_writeAgentsMd(sections) {
|
|
162
163
|
const lines = [
|
|
163
164
|
`# ${this.projectName} — Agent Instructions`,
|
|
164
165
|
'',
|
|
165
|
-
'> Auto-generated by [AutoSnippet](https://github.com/
|
|
166
|
-
'> This file is regenerated when the knowledge base changes.',
|
|
167
|
-
'',
|
|
168
|
-
'## Project Knowledge Base',
|
|
169
|
-
'',
|
|
170
|
-
`This project uses **AutoSnippet** as its knowledge management system.`,
|
|
171
|
-
`The knowledge base contains coding standards, architecture patterns, and best practices`,
|
|
172
|
-
`accessible through MCP tools.`,
|
|
166
|
+
'> Auto-generated by [AutoSnippet](https://github.com/GxFn/AutoSnippet). Do not edit manually.',
|
|
173
167
|
'',
|
|
174
|
-
|
|
168
|
+
'This project uses **AutoSnippet** for knowledge management.',
|
|
169
|
+
'Access the knowledge base through MCP tools.',
|
|
175
170
|
'',
|
|
176
171
|
];
|
|
177
172
|
// Coding Standards
|
|
178
173
|
if (sections.ruleLines.length > 0) {
|
|
179
|
-
lines.push('## Coding Standards', '');
|
|
180
|
-
lines.push(...sections.ruleLines);
|
|
181
|
-
lines.push('');
|
|
174
|
+
lines.push('## Coding Standards', '', ...sections.ruleLines, '');
|
|
182
175
|
}
|
|
183
176
|
// Architecture Patterns
|
|
184
177
|
if (sections.patternRows.length > 0) {
|
|
185
|
-
lines.push('## Architecture Patterns', '');
|
|
186
|
-
lines.push('| Trigger | When | Do |');
|
|
187
|
-
lines.push('|---------|------|----|');
|
|
188
|
-
lines.push(...sections.patternRows);
|
|
189
|
-
lines.push('');
|
|
178
|
+
lines.push('## Architecture Patterns', '', '| Trigger | When | Do |', '|---------|------|----|', ...sections.patternRows, '');
|
|
190
179
|
}
|
|
191
180
|
// MCP Tools
|
|
192
|
-
lines.push('## MCP Tools
|
|
193
|
-
lines.push('Use these MCP tools to access the full knowledge base:', '');
|
|
194
|
-
lines.push(...sections.toolLines);
|
|
195
|
-
lines.push('');
|
|
181
|
+
lines.push('## MCP Tools', '', ...sections.toolLines, '');
|
|
196
182
|
// Skills
|
|
197
183
|
if (sections.skillLines.length > 0) {
|
|
198
|
-
lines.push('##
|
|
199
|
-
lines.push('Load with `autosnippet_skill({ operation: "load", name: "<skill>" })`:', '');
|
|
200
|
-
lines.push(...sections.skillLines);
|
|
201
|
-
lines.push('');
|
|
184
|
+
lines.push('## Skills', '', 'Load with `autosnippet_skill({ operation: "load", name: "<skill>" })`:', '', ...sections.skillLines, '');
|
|
202
185
|
}
|
|
203
|
-
//
|
|
204
|
-
lines.push(
|
|
186
|
+
// Constraints
|
|
187
|
+
lines.push('## Constraints', '', '1. Do NOT modify knowledge base files directly (`AutoSnippet/recipes/`, `.autosnippet/`).', '2. Prefer Recipes as project standards; source code is supplementary.', '3. Create or update knowledge only through MCP tools.', '');
|
|
205
188
|
const content = `${lines.join('\n')}\n`;
|
|
206
189
|
const filePath = path.join(this.projectRoot, 'AGENTS.md');
|
|
207
190
|
const result = safeWriteFile(filePath, content, { logger: this.logger });
|
|
208
191
|
return { filePath, tokensUsed: estimateTokens(content), skipped: !result.written };
|
|
209
192
|
}
|
|
210
193
|
// ─── CLAUDE.md ─────────────────────────────────────
|
|
211
|
-
/** @private */
|
|
212
194
|
_writeClaudeMd(sections) {
|
|
213
195
|
const lines = [
|
|
214
196
|
`# ${this.projectName} — Claude Code Instructions`,
|
|
215
197
|
'',
|
|
216
198
|
'> Auto-generated by AutoSnippet. Regenerated when knowledge base changes.',
|
|
217
199
|
'',
|
|
200
|
+
'This project uses **AutoSnippet** for knowledge management.',
|
|
201
|
+
'Access the knowledge base through MCP tools.',
|
|
202
|
+
'',
|
|
218
203
|
];
|
|
219
|
-
// Constraints (Claude prefers clear bullet points)
|
|
220
|
-
lines.push(...this._renderConstraints());
|
|
221
|
-
lines.push('');
|
|
222
204
|
// Coding Standards
|
|
223
205
|
if (sections.ruleLines.length > 0) {
|
|
224
|
-
lines.push('## Coding Standards', '');
|
|
225
|
-
lines.push('These are mandatory project rules extracted from the knowledge base:', '');
|
|
226
|
-
lines.push(...sections.ruleLines);
|
|
227
|
-
lines.push('');
|
|
206
|
+
lines.push('## Coding Standards', '', ...sections.ruleLines, '');
|
|
228
207
|
}
|
|
229
|
-
// Patterns
|
|
208
|
+
// Patterns
|
|
230
209
|
if (sections.patternRows.length > 0) {
|
|
231
|
-
lines.push('## Key Patterns', '');
|
|
232
|
-
lines.push('| Trigger | When | Do |');
|
|
233
|
-
lines.push('|---------|------|----|');
|
|
234
|
-
lines.push(...sections.patternRows);
|
|
235
|
-
lines.push('');
|
|
210
|
+
lines.push('## Key Patterns', '', '| Trigger | When | Do |', '|---------|------|----|', ...sections.patternRows, '');
|
|
236
211
|
}
|
|
237
212
|
// MCP — Claude Code natively supports MCP
|
|
238
|
-
lines.push('## MCP
|
|
239
|
-
lines.push('This project has an AutoSnippet MCP server configured. ', 'Use the following tools to access project knowledge:', '');
|
|
240
|
-
lines.push(...sections.toolLines);
|
|
241
|
-
lines.push('');
|
|
242
|
-
// Key tools highlight for Claude
|
|
243
|
-
lines.push('### Task Workflow', '');
|
|
244
|
-
lines.push('1. **Every message → `autosnippet_task({ operation: "prime" })`** — Load decisions + tasks + knowledge context (ALWAYS FIRST)');
|
|
245
|
-
lines.push('2. **Create task for non-trivial work** — ≥2 files OR ≥10 lines → `create` → `claim` → code → `close`');
|
|
246
|
-
lines.push('3. **User agrees/disagrees → `autosnippet_task({ operation: "record_decision" })`** — Persist decision immediately');
|
|
247
|
-
lines.push('4. **Before writing code**: `autosnippet_search({ query: "<topic>" })` to find relevant patterns');
|
|
248
|
-
lines.push('5. **Complete task**: `autosnippet_task({ operation: "close", id: "<id>", reason: "..." })`');
|
|
249
|
-
lines.push('6. **Session end**: Close or defer ALL in_progress tasks — zero in_progress on exit');
|
|
250
|
-
lines.push('');
|
|
213
|
+
lines.push('## MCP Tools', '', ...sections.toolLines, '');
|
|
251
214
|
// Skills
|
|
252
215
|
if (sections.skillLines.length > 0) {
|
|
253
|
-
lines.push('## Skills', '');
|
|
254
|
-
lines.push(...sections.skillLines);
|
|
255
|
-
lines.push('');
|
|
216
|
+
lines.push('## Skills', '', ...sections.skillLines, '');
|
|
256
217
|
}
|
|
218
|
+
// Constraints
|
|
219
|
+
lines.push('', '## Constraints', '', '1. Do NOT modify knowledge base files directly (`AutoSnippet/recipes/`, `.autosnippet/`).', '2. Prefer Recipes as project standards; source code is supplementary.', '3. Create or update knowledge only through MCP tools.', '');
|
|
257
220
|
const content = `${lines.join('\n')}\n`;
|
|
258
221
|
const filePath = path.join(this.projectRoot, 'CLAUDE.md');
|
|
259
222
|
const result = safeWriteFile(filePath, content, { logger: this.logger });
|
|
@@ -262,50 +225,20 @@ export class AgentInstructionsGenerator {
|
|
|
262
225
|
// ─── copilot-instructions.md ───────────────────────
|
|
263
226
|
/**
|
|
264
227
|
* 动态生成 copilot-instructions.md
|
|
265
|
-
*
|
|
266
|
-
* @private
|
|
228
|
+
* 读取 templates/instructions/conventions.md + HTML markers
|
|
267
229
|
*/
|
|
268
|
-
_writeCopilotInstructions(
|
|
269
|
-
const
|
|
270
|
-
|
|
230
|
+
_writeCopilotInstructions(_sections) {
|
|
231
|
+
const body = this._loadConventionsTemplate();
|
|
232
|
+
const content = [
|
|
233
|
+
'<!-- autosnippet:begin -->',
|
|
271
234
|
'',
|
|
272
|
-
'
|
|
273
|
-
`- Project: **${this.projectName}**`,
|
|
274
|
-
'- Knowledge System: AutoSnippet V3 (ESM, SQLite, MCP)',
|
|
275
|
-
'- Knowledge Base: `AutoSnippet/` directory (recipes, skills, constitution)',
|
|
235
|
+
'# AutoSnippet Conventions',
|
|
276
236
|
'',
|
|
277
|
-
|
|
237
|
+
body,
|
|
278
238
|
'',
|
|
279
|
-
|
|
280
|
-
|
|
281
|
-
|
|
282
|
-
lines.push('## Coding Standards', '');
|
|
283
|
-
lines.push(...sections.ruleLines);
|
|
284
|
-
lines.push('');
|
|
285
|
-
}
|
|
286
|
-
// MCP Tools (compact for Copilot)
|
|
287
|
-
lines.push('## MCP Tools', '');
|
|
288
|
-
lines.push('Access the knowledge base through MCP:', '');
|
|
289
|
-
// Copilot: show fewer, most essential tools
|
|
290
|
-
const essentialTools = [
|
|
291
|
-
'- `autosnippet_search` — Search knowledge (mode: auto/context/keyword/semantic)',
|
|
292
|
-
'- `autosnippet_knowledge` — Browse/get recipes (operation: list/get/insights)',
|
|
293
|
-
'- `autosnippet_submit_knowledge` — Submit candidate (strict validation, all fields required)',
|
|
294
|
-
'- `autosnippet_guard` — Code compliance check',
|
|
295
|
-
'- `autosnippet_skill` — Load project skills (list/load)',
|
|
296
|
-
'- `autosnippet_health` — Service health & KB stats',
|
|
297
|
-
];
|
|
298
|
-
lines.push(...essentialTools);
|
|
299
|
-
lines.push('');
|
|
300
|
-
// Knowledge Types
|
|
301
|
-
lines.push('## Knowledge Types', '');
|
|
302
|
-
lines.push('- **rule** — Coding standards, enforced by Guard');
|
|
303
|
-
lines.push('- **pattern** — Reusable code patterns and architecture');
|
|
304
|
-
lines.push('- **fact** — Structural knowledge (relations, data flow)');
|
|
305
|
-
lines.push('');
|
|
306
|
-
// Workflow
|
|
307
|
-
lines.push(...this._renderWorkflow());
|
|
308
|
-
const content = `${lines.join('\n')}\n`;
|
|
239
|
+
'<!-- autosnippet:end -->',
|
|
240
|
+
'',
|
|
241
|
+
].join('\n');
|
|
309
242
|
const destDir = path.join(this.projectRoot, '.github');
|
|
310
243
|
const filePath = path.join(destDir, 'copilot-instructions.md');
|
|
311
244
|
const { canWrite } = checkWriteSafety(filePath);
|
|
@@ -315,83 +248,14 @@ export class AgentInstructionsGenerator {
|
|
|
315
248
|
const result = safeWriteFile(filePath, content, { logger: this.logger });
|
|
316
249
|
return { filePath, tokensUsed: estimateTokens(content), skipped: !result.written };
|
|
317
250
|
}
|
|
318
|
-
// ───
|
|
319
|
-
/**
|
|
320
|
-
* 核心约束(所有 Agent 共享)
|
|
321
|
-
* @private
|
|
322
|
-
*/
|
|
323
|
-
_renderConstraints() {
|
|
324
|
-
return [
|
|
325
|
-
"## CRITICAL: You Operate autosnippet_task — The User Doesn't",
|
|
326
|
-
'',
|
|
327
|
-
'You are the task operator. Users speak naturally; you translate to task operations.',
|
|
328
|
-
"DO NOT tell users to call autosnippet_task. That's YOUR job.",
|
|
329
|
-
'',
|
|
330
|
-
'- WRONG: "You can run autosnippet_task({ operation: \'create\' }) to create a task"',
|
|
331
|
-
'- RIGHT: *(you run create yourself and tell the user "Created task asd-42: Fix login bug")*',
|
|
332
|
-
'',
|
|
333
|
-
'## Task Tracking Rules (MANDATORY)',
|
|
334
|
-
'',
|
|
335
|
-
'1. **MUST prime on EVERY message** — `autosnippet_task({ operation: "prime" })` BEFORE anything else. No exceptions.',
|
|
336
|
-
'2. **MUST create task for non-trivial work** — ≥2 files OR ≥10 lines → create BEFORE starting.',
|
|
337
|
-
'3. **MUST claim before coding** — `autosnippet_task({ operation: "claim", id })` then code.',
|
|
338
|
-
'4. **MUST close when done** — `autosnippet_task({ operation: "close", id, reason })` with meaningful reason.',
|
|
339
|
-
'5. **MUST handle unfinished tasks first** — If prime shows in-progress, ask user: Continue, Defer, Abandon? Do NOT auto-resume.',
|
|
340
|
-
'6. **NEVER skip prime** — Even for follow-up messages.',
|
|
341
|
-
'7. **NEVER start new work with open in-progress tasks** — Handle existing first.',
|
|
342
|
-
'8. **NEVER leave tasks in in_progress when session ends** — Close or defer everything.',
|
|
343
|
-
'9. **NEVER tell the user to run task commands** — You are the operator.',
|
|
344
|
-
'',
|
|
345
|
-
'When in doubt → create a task. When idle → `autosnippet_task({ operation: "ready" })`.',
|
|
346
|
-
'',
|
|
347
|
-
'**When NOT to create**: Quick questions, single-file trivial fixes (<10 lines), code explanation, running tests.',
|
|
348
|
-
'',
|
|
349
|
-
'## Knowledge Rules',
|
|
350
|
-
'',
|
|
351
|
-
'1. **User agrees/disagrees with a plan → `autosnippet_task({ operation: "record_decision" })` immediately** — Persist team memory first.',
|
|
352
|
-
'2. **Do NOT modify** knowledge base files directly (`AutoSnippet/recipes/`, `.autosnippet/`).',
|
|
353
|
-
'3. **Prefer Recipes** as project standards; source code is supplementary.',
|
|
354
|
-
'4. Use `autosnippet_search` for knowledge retrieval; do not retry on failure in the same turn.',
|
|
355
|
-
'5. Skills handle semantics and workflow; MCP handles capabilities — do not hardcode URLs in Skills.',
|
|
356
|
-
];
|
|
357
|
-
}
|
|
251
|
+
// ─── 模板读取 ──────────────────────────────────────
|
|
358
252
|
/**
|
|
359
|
-
*
|
|
360
|
-
*
|
|
253
|
+
* 读取 templates/instructions/conventions.md — 唯一内容源
|
|
254
|
+
* .mdc、copilot-instructions.md、Channel F 动态版全部从这里读取
|
|
361
255
|
*/
|
|
362
|
-
|
|
363
|
-
|
|
364
|
-
|
|
365
|
-
'',
|
|
366
|
-
'| User Says | Your Action |',
|
|
367
|
-
'|---|---|',
|
|
368
|
-
'| "Fix this bug" / "帮我修 bug" | `create` → `claim` → code → `close` |',
|
|
369
|
-
'| "Implement this" / "做功能" | `create` → `claim` → code → `close` |',
|
|
370
|
-
'| "Continue" / "继续" | resume in-progress → code → `close` |',
|
|
371
|
-
'| "Pause" / "先不做了" | `defer(id, reason)` |',
|
|
372
|
-
'| "Abandon" / "不做了" | `fail(id, reason)` |',
|
|
373
|
-
'| "Break it down" / "太大了" | `decompose(id, subtasks)` |',
|
|
374
|
-
'| "What\'s next" / "有什么要做的" | `ready()` → present list |',
|
|
375
|
-
'| "Agreed" / "就这么定了" | `record_decision(...)` |',
|
|
376
|
-
'| Quick question (no code) | No task. Just answer. |',
|
|
377
|
-
'',
|
|
378
|
-
'## Session Closing Protocol',
|
|
379
|
-
'',
|
|
380
|
-
'Before ending work, you MUST complete this checklist:',
|
|
381
|
-
'',
|
|
382
|
-
'- [ ] Close every claimed task with reason describing what was accomplished',
|
|
383
|
-
'- [ ] Defer any incomplete tasks with notes on why and what remains',
|
|
384
|
-
'- [ ] Verify zero tasks in in_progress state',
|
|
385
|
-
'- [ ] If prime showed ready tasks, mention them to the user for next session',
|
|
386
|
-
'',
|
|
387
|
-
'**Work is not done until all tasks are closed or deferred.**',
|
|
388
|
-
'',
|
|
389
|
-
'## Context Pressure',
|
|
390
|
-
'',
|
|
391
|
-
'- `_contextHint: CONTEXT_PRESSURE:WARNING` → Summarize completed work, then continue',
|
|
392
|
-
'- `_contextHint: CONTEXT_PRESSURE:CRITICAL` → Call `autosnippet_task({ operation: "prime" })` immediately',
|
|
393
|
-
'',
|
|
394
|
-
];
|
|
256
|
+
_loadConventionsTemplate() {
|
|
257
|
+
const tplPath = path.join(TEMPLATES_DIR, 'instructions/conventions.md');
|
|
258
|
+
return fs.readFileSync(tplPath, 'utf8').trimEnd();
|
|
395
259
|
}
|
|
396
260
|
}
|
|
397
261
|
export default AgentInstructionsGenerator;
|