autosnippet 3.2.3 → 3.2.4
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/config/constitution.yaml
CHANGED
package/lib/cli/SetupService.js
CHANGED
|
@@ -442,8 +442,13 @@ export class SetupService {
|
|
|
442
442
|
configured.push('cursor-mcp');
|
|
443
443
|
|
|
444
444
|
// 模板文件(可能因已存在/用户文件而跳过)
|
|
445
|
-
|
|
446
|
-
|
|
445
|
+
const copilotCopied = this._copyCopilotInstructions();
|
|
446
|
+
if (copilotCopied) {
|
|
447
|
+
configured.push('copilot-instructions');
|
|
448
|
+
} else {
|
|
449
|
+
// 模板未复制(用户已有文件)→ 注入 AutoSnippet 段落
|
|
450
|
+
this._ensureTaskGraphInstructions();
|
|
451
|
+
}
|
|
447
452
|
if (this._generateAgentInstructionFiles()) configured.push('agent-instructions');
|
|
448
453
|
if (this._copyCursorRules()) configured.push('cursor-rules');
|
|
449
454
|
if (this._copySkillsTemplate()) configured.push('skills-template');
|
|
@@ -735,35 +740,30 @@ export class SetupService {
|
|
|
735
740
|
return true;
|
|
736
741
|
}
|
|
737
742
|
|
|
738
|
-
/**
|
|
743
|
+
/**
|
|
744
|
+
* @private TaskGraph 决策记忆段落注入
|
|
745
|
+
* 从 templates/copilot-instructions.md 提取 <!-- autosnippet:begin/end --> 间的内容注入。
|
|
746
|
+
* 单一数据源:模板即注入内容,无需维护第二份文件。
|
|
747
|
+
*/
|
|
739
748
|
_ensureTaskGraphInstructions() {
|
|
740
749
|
const githubDir = join(this.projectRoot, '.github');
|
|
741
750
|
const filePath = join(githubDir, 'copilot-instructions.md');
|
|
742
751
|
|
|
743
|
-
// 使用 HTML 注释标记界定段落,避免标题被编辑后重复追加(D3)
|
|
744
752
|
const BEGIN_MARKER = '<!-- autosnippet:begin -->';
|
|
745
753
|
const END_MARKER = '<!-- autosnippet:end -->';
|
|
746
754
|
|
|
747
|
-
|
|
748
|
-
|
|
749
|
-
|
|
750
|
-
|
|
751
|
-
|
|
752
|
-
|
|
753
|
-
|
|
754
|
-
|
|
755
|
-
|
|
756
|
-
|
|
757
|
-
|
|
758
|
-
|
|
759
|
-
|
|
760
|
-
\`\`\`
|
|
761
|
-
autosnippet_ready() → Load decisions + context (ALWAYS FIRST)
|
|
762
|
-
autosnippet_decide(record) → Save new team agreement
|
|
763
|
-
autosnippet_task(create/close) → Task lifecycle
|
|
764
|
-
\`\`\`
|
|
765
|
-
${END_MARKER}
|
|
766
|
-
`;
|
|
755
|
+
// 从模板提取标记间内容
|
|
756
|
+
const templateSrc = join(REPO_ROOT, 'templates', 'copilot-instructions.md');
|
|
757
|
+
if (!existsSync(templateSrc)) {
|
|
758
|
+
return { action: 'skipped' };
|
|
759
|
+
}
|
|
760
|
+
const templateContent = readFileSync(templateSrc, 'utf8');
|
|
761
|
+
const beginIdx = templateContent.indexOf(BEGIN_MARKER);
|
|
762
|
+
const endIdx = templateContent.indexOf(END_MARKER);
|
|
763
|
+
if (beginIdx === -1 || endIdx === -1) {
|
|
764
|
+
return { action: 'skipped' };
|
|
765
|
+
}
|
|
766
|
+
const snippetContent = templateContent.slice(beginIdx, endIdx + END_MARKER.length);
|
|
767
767
|
|
|
768
768
|
if (!existsSync(githubDir)) {
|
|
769
769
|
mkdirSync(githubDir, { recursive: true });
|
|
@@ -771,22 +771,21 @@ ${END_MARKER}
|
|
|
771
771
|
|
|
772
772
|
if (existsSync(filePath)) {
|
|
773
773
|
const existing = readFileSync(filePath, 'utf8');
|
|
774
|
-
// 通过 HTML 注释标记检测,不依赖可编辑的标题文本
|
|
775
774
|
if (existing.includes(BEGIN_MARKER)) {
|
|
776
775
|
// 替换现有段落(支持升级)
|
|
777
776
|
const updated = existing.replace(
|
|
778
777
|
new RegExp(`${BEGIN_MARKER}[\\s\\S]*?${END_MARKER}`),
|
|
779
|
-
|
|
778
|
+
snippetContent
|
|
780
779
|
);
|
|
781
780
|
writeFileSync(filePath, updated);
|
|
782
781
|
return { action: 'updated' };
|
|
783
782
|
}
|
|
784
783
|
// 追加到末尾
|
|
785
|
-
writeFileSync(filePath, existing
|
|
784
|
+
writeFileSync(filePath, `${existing}\n\n${snippetContent}\n`);
|
|
786
785
|
return { action: 'appended' };
|
|
787
786
|
}
|
|
788
787
|
|
|
789
|
-
writeFileSync(filePath,
|
|
788
|
+
writeFileSync(filePath, `${snippetContent}\n`);
|
|
790
789
|
return { action: 'created' };
|
|
791
790
|
}
|
|
792
791
|
|
|
@@ -281,19 +281,22 @@ export class AgentInstructionsGenerator {
|
|
|
281
281
|
// Key tools highlight for Claude
|
|
282
282
|
lines.push('### Recommended Workflow', '');
|
|
283
283
|
lines.push(
|
|
284
|
-
'1. **
|
|
284
|
+
'1. **Every message → `autosnippet_ready()`** — Load decisions + tasks + knowledge context (ALWAYS FIRST)'
|
|
285
285
|
);
|
|
286
286
|
lines.push(
|
|
287
|
-
'2. **
|
|
287
|
+
'2. **User agrees/disagrees → `autosnippet_decide(record/revise/unpin)`** — Persist decision immediately'
|
|
288
288
|
);
|
|
289
289
|
lines.push(
|
|
290
|
-
'3. **
|
|
290
|
+
'3. **Before writing code**: `autosnippet_search({ query: "<topic>" })` to find relevant patterns'
|
|
291
291
|
);
|
|
292
292
|
lines.push(
|
|
293
|
-
'4. **
|
|
293
|
+
'4. **Check compliance**: `autosnippet_guard({ code: "<your code>" })` before committing'
|
|
294
294
|
);
|
|
295
295
|
lines.push(
|
|
296
|
-
'5. **
|
|
296
|
+
'5. **Complete task**: `autosnippet_task({ operation: "close", id: "<id>" })`'
|
|
297
|
+
);
|
|
298
|
+
lines.push(
|
|
299
|
+
'6. **Guard diagnostics**: Read ruleId → `autosnippet_search({ query: "<ruleId>" })` → fix'
|
|
297
300
|
);
|
|
298
301
|
lines.push('');
|
|
299
302
|
|
|
@@ -390,11 +393,13 @@ export class AgentInstructionsGenerator {
|
|
|
390
393
|
return [
|
|
391
394
|
'## Mandatory Constraints',
|
|
392
395
|
'',
|
|
393
|
-
'1. **
|
|
394
|
-
'2.
|
|
395
|
-
'3. **
|
|
396
|
-
'4.
|
|
397
|
-
'5.
|
|
396
|
+
'1. **Every message → `autosnippet_ready()`** — Load latest decisions and task context. Skipping causes contradictions with team agreements.',
|
|
397
|
+
'2. **User agrees/disagrees with a plan → `autosnippet_decide(record/revise/unpin)` immediately** — Persist team memory first, then continue execution.',
|
|
398
|
+
'3. **Do NOT modify** knowledge base files directly (`AutoSnippet/recipes/`, `.autosnippet/`).',
|
|
399
|
+
'4. Create or update knowledge **only** through MCP tools (`autosnippet_submit_knowledge`).',
|
|
400
|
+
'5. **Prefer Recipes** as project standards; source code is supplementary.',
|
|
401
|
+
'6. Use `autosnippet_search` for knowledge retrieval; do not retry on failure in the same turn.',
|
|
402
|
+
'7. Skills handle semantics and workflow; MCP handles capabilities — do not hardcode URLs in Skills.',
|
|
398
403
|
];
|
|
399
404
|
}
|
|
400
405
|
|
|
@@ -406,15 +411,16 @@ export class AgentInstructionsGenerator {
|
|
|
406
411
|
return [
|
|
407
412
|
'## Recommended Workflow',
|
|
408
413
|
'',
|
|
409
|
-
'###
|
|
410
|
-
'1. `autosnippet_ready()` —
|
|
414
|
+
'### First Actions (MANDATORY)',
|
|
415
|
+
'1. **Every message** → `autosnippet_ready()` — Load decisions + tasks + knowledge context (never skip)',
|
|
416
|
+
'2. **User agrees/disagrees** → `autosnippet_decide({ operation: "record" | "revise" | "unpin" })` — Persist decision before continuing',
|
|
411
417
|
'',
|
|
412
418
|
'### Task Lifecycle',
|
|
413
|
-
'
|
|
414
|
-
'
|
|
415
|
-
'
|
|
416
|
-
'
|
|
417
|
-
'
|
|
419
|
+
'3. `autosnippet_task({ operation: "claim", id: "asd-xxx" })` — Start working',
|
|
420
|
+
'4. `autosnippet_search({ query: "<topic>" })` — Search knowledge before coding',
|
|
421
|
+
'5. **CODE** — Write the implementation',
|
|
422
|
+
'6. `autosnippet_guard({ code: "<code>" })` — Check compliance',
|
|
423
|
+
'7. `autosnippet_task({ operation: "close", id: "asd-xxx" })` — Complete',
|
|
418
424
|
'',
|
|
419
425
|
'### Guard Diagnostics Response',
|
|
420
426
|
'When editor shows diagnostics from "AutoSnippet Guard":',
|
package/package.json
CHANGED
|
@@ -1,3 +1,4 @@
|
|
|
1
|
+
<!-- autosnippet:begin -->
|
|
1
2
|
<!-- On every human message, call autosnippet_ready() as your first action. No exceptions. -->
|
|
2
3
|
<!-- On any explicit user agreement/disagreement about a plan/decision, call autosnippet_decide(...) immediately to persist team memory. -->
|
|
3
4
|
|
|
@@ -175,3 +176,4 @@ Skill 包含:完整的 V3 字段格式、JSON 示例模板、维度分析策
|
|
|
175
176
|
---
|
|
176
177
|
<!-- REMINDER: If you have not yet called autosnippet_ready(), do it now before responding. -->
|
|
177
178
|
<!-- REMINDER: If user has explicitly agreed/disagreed with a plan, call autosnippet_decide(...) before continuing. -->
|
|
179
|
+
<!-- autosnippet:end -->
|