8000 feat: Enforce mandatory 4-skill initialization protocol by wxy · Pull Request #3 · wxy/evoskills · GitHub
[go: up one dir, main page]

Skip to content
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
48 changes: 47 additions & 1 deletion .agent/skills/_context-ack/SKILL.md
Original file line number Diff line number Diff line change
@@ -1,3 +1,4 @@
````skill
---
name: _context-ack
description: 在每次回复中使用固定前缀并列出本次实际参考的指令/文件,便于校验是否遵循上下文与规则。
Expand Down Expand Up @@ -38,7 +39,7 @@ description: 在每次回复中使用固定前缀并列出本次实际参考的

### 3.1) 引用校验清单(强制)
- **已读指令**必须来自本次显式读取(如 `read_file`)。
- 禁止填写“未实际读取但猜测存在”的文件。
- 禁止填写"未实际读取但猜测存在"的文件。
- 如未读取任何指令文件,必须写 `已读指令:无`。
### 3.2) 技能使用证据收集(可选增强)

Expand Down Expand Up @@ -101,3 +102,48 @@ description: 在每次回复中使用固定前缀并列出本次实际参考的
- 不要虚构引用。
- 不要列出仅"已在上下文但未使用"的文件。
- 保持简洁,清单只列实际使用项。

---

## 禁止虚假列表(强制规则)

### 什么不能列出

1. **未实际读取的指令文件**
- ❌ "我记得有这个文件,应该符合规范" → 不能列
- ✅ "我用 read_file 工具读取了这个文件" → 可以列

2. **未在正文中体现的技能**
- ❌ "_git-commit(即使我可能会用)" → 不能列
- ✅ "_git-commit(我在正文中提到了'已使用 Conventional Commits 格式')" → 可以列

3. **猜测性的文件依赖**
- ❌ "根据项目结构,应该存在某某配置文件" → 不能列
- ✅ "我实际读取了 package.json 并发现..." → 可以列

### 虚假列表的症状

以下现象表明存在虚假列表问题:
- 用户指出:"你没有在回复中提到这个技能"
- 用户指出:"这个指令文件没有被应用到你的回复中"
- 清单中的技能数量 > 正文中体现的技能数量

### 修正流程

当发现虚假列表时:
1. **停止当前回复**
2. **重新逐项验证**清单中的每一项是否有正文支撑
3. **删除无法验证**的项目
4. **增加正文**来体现那些确实需要的技能
5. **再次提交**修正后的回复

### 自检清单(每次回复前必须做)

```
□ 已读指令中的每个文件,我都用 read_file 读取过吗?
□ 已启用技能中的每个技能,我都在正文中体现过吗?(至少一个关键步骤或结论)
□ 如果某个技能只是"在上下文中存在"但未使用,我有删除它吗?
□ 我能为清单中的每一项都举出具体证据吗?
```

````
22 changes: 22 additions & 0 deletions .agent/skills/_execution-precheck/SKILL.md
Original file line number Diff line number Diff line change
Expand Up @@ -157,6 +157,28 @@ description: 执行前检查清单。每次回复前必须自动进行的自我

---

### 第 7 步:步骤执行签字(强制)

**问题**:"我是否真的执行了全部 6 步,而不是跳过或假装?"

这一步是对**机制失败**(技能虽然被定义却未被坚持执行)的终极防线。

**执行标志**:
- [ ] 第 1-6 步是否**全部完成**了检查(即使某些步骤的结果是"无需操作",也必须明确说出)?
- [ ] 在最终响应的"已启用技能"行中,是否明确标记了本次检查的完整性?

**标记方式**:
在末尾的"已启用技能"中,当列出 `_execution-precheck` 时,必须附加以下签字:
```
已启用技能:_execution-precheck - 第1步✓ 第2步✓ 第3步✓ 第4步✓ 第5步✓ 第6步✓ 第7步✓
```

**如何理解**:每个 `✓` 代表该步骤被**真实执行**且通过验证。若任何步骤未通过,必须停止回复生成,改为修正。

**完成标志**:用户看到 `第1-7步✓` 的完整签字,就能确信本次回复的合规性。

---

## 核心承诺

使用这项检查的目的**不是为了显示合规**,而是**为了真正做到合规**。
Expand Down
22 changes: 21 additions & 1 deletion .github/AI_CONSTITUTION.md
Original file line number Diff line number Diff line change
Expand Up @@ -88,6 +88,26 @@ When creating skill `_my-skill`, you only need to declare its tier and dependenc

---

## Mandatory Initialization Binding

The constitution defines **why** evolution and discipline are required.
The initialization protocol defines **how** every response is enforced.

### Authority and layering

1. **Constitution** (`.github/AI_CONSTITUTION.md`): immutable evolution principles
2. **Initialization protocol** (`.github/AI_INITIALIZATION.md`): mandatory 4-phase execution contract
3. **Instruction entrypoint** (`.github/copilot-instructions.md`): active loading and per-response gate
4. **Skill definitions** (`.agent/skills/*/SKILL.md`): implementation details

### Compliance contract

- A response is valid only when it satisfies all required initialization markers and checks.
- If any required phase is missing, execution must stop and resume from the missing phase.
- Evolution outputs (new rules/skills) must remain compatible with this enforcement chain.

---

## Glossary

| Term | Definition |
Expand All @@ -101,4 +121,4 @@ When creating skill `_my-skill`, you only need to declare its tier and dependenc

> **Version**: 2.1
> **Focus**: Evolution mechanism only (lean and focused)
> **Related Files**: See `.github/EXECUTION_RULES.md` for mandatory rules, `AGENTS.md` for skill registry
> **Related Files**: `.github/AI_INITIALIZATION.md`, `.github/copilot-instructions.md`, `AGENTS.md`
163 changes: 163 additions & 0 deletions .github/AI_INITIALIZATION.md
Original file line number Diff line number Diff line change
@@ -0,0 +1,163 @@
# Required Initialization Protocol

> This file defines the **mandatory initialization sequence** that MUST execute before every AI response. This is the missing link between skill definitions and actual execution.

---

## Problem Statement

**Situation**: Four Tier 2 system skills are defined with clear requirements, but there was no explicit rule forcing them to activate on every response. This created a gap where:
- Skills were loaded into context ✅
- Skills were documented fully ✅
- But they weren't **automatically executed** ❌

**Solution**: This file establishes a **forced initialization protocol** that cannot be bypassed.

---

## The Mandatory 4-Skill Initialization Sequence

Before generating ANY response, the AI MUST execute these skills **in this exact order**:

### Non-skippable Enforcement (Hard Rules)

The protocol is **fail-closed** and must be treated as executable constraints, not guidance:

1. **Do not draft final content** before completing all 4 phases in order.
2. If any phase is missing, **run the missing phase first**, then continue.
3. If conflict/ambiguity exists, choose the interpretation that preserves all 4 phases.
4. Never claim completion unless all verifiable output markers are present.

### Phase 1: Load Instructions (_instruction-guard)
```
Execute: read_file('.github/copilot-instructions.md')
Verify: Confirm understanding of 3-5 key project constraints
Status: Must complete before proceeding
```

### Phase 2: Load Core Rules (_execution-precheck)
```
Execute: Complete the 6-step self-check from _execution-precheck/SKILL.md
Verify: Yes to all 6 steps, especially Step 5 (truthfulness test)
Status: Must complete before drafting response
```

### Phase 3: Format Response (_context-ack)
```
Execute: Prepare response structure per _context-ack/SKILL.md
Structure:
Line 1: ✨ 已启用上下文校验
Line 2: [blank]
Line 3: 尊敬的主人:
Line 4-N: Main content
Last lines: 已读指令 / 已启用技能 footer lines
Status: Must be applied to final output
```

### Phase 4: Validate Operations (_file-output-guard)
```
Execute: Check _file-output-guard/SKILL.md constraints
If file ops needed:
- Use create_file or apply_patch only
- No HERE documents (cat > file << 'EOF')
- >5KB = segment into multiple write operations
Status: Must validate before executing file tools
```

---

## When This Protocol Applies

**Mandatory scope**:
- ✅ All user requests without exception
- ✅ All types of responses (code, explanation, file creation, etc.)
- ✅ All conversation contexts

**Exceptions** (only if explicitly requested):
- User says: "Skip formatting for this response"
- User says: "No need for acknowledgment format"
- (Note: Even exceptions should include at least _instruction-guard and _execution-precheck)

---

## Success Criteria

A response is compliant ONLY if:

- [ ] **_instruction-guard**: The response was generated AFTER reading `.github/copilot-instructions.md` (visible in "已读指令" section)
- [ ] **_execution-precheck**: All 6 steps documented; Step 5 (truthfulness) reflected honestly (visible in skill application)
- [ ] **_context-ack**: Proper format (prefix, honorific, diff footer) with only REAL file reads listed
- [ ] **_file-output-guard**: File operations use correct tools; large files segmented if needed

### Verifiable Output Markers (Required in every response)

A response is compliant only when all markers exist:

- First line: `✨ 已启用上下文校验`
- A standalone salutation line: `尊敬的主人:`
- Footer line: `已读指令:...` (only files actually read in this turn)
- Footer lines: one `已启用技能:技能名 - 本次作用` per actually used skill

If any marker is missing, the response is invalid and must be regenerated before sending.

### Pre-Send Gate (Mandatory checklist)

Before sending any response, confirm:

- [ ] `.github/copilot-instructions.md` was explicitly read this turn
- [ ] `_execution-precheck` 6-step self-check completed
- [ ] `_context-ack` format fully applied
- [ ] `_file-output-guard` constraints satisfied for any file operations

Do not bypass this checklist for speed.

## How to Verify Compliance

Users can quickly scan with this checklist:
```
✓ Does response start with "✨ 已启用上下文校验"? [_context-ack active]
✓ Does response list actual files read in footer? [_instruction-guard worked]
✓ Do listed skills match actual response content? [_execution-precheck truthful]
✓ No HERE documents in code blocks? [_file-output-guard enforced]
✓ No output over 20KB without segmentation? [_session-safety respected]
```

---

## Integration with Other Systems

This **Initialization Protocol** is:
- **Above** skill definitions (more authoritative)
- **Below** the Constitution (doesn't modify evolution principles)
- **Separate from** EXECUTION_RULES.md (which was "optional"; this is "mandatory")

Think of it as the **missing layer** in the system architecture:
```
AI_CONSTITUTION.md (evolution principles)
↓
REQUIRED_INITIALIZATION.md (this file - forced sequence) 🆕
↓
EXECUTION_RULES.md / AGENTS.md (skill definitions)
↓
AI execution
```

---

## Key Enforcement Point

**Paradox to solve**: How can the AI "decide" to execute this protocol?

**Answer**: This file must be **listed in the copilot-instructions.md** with appropriate authority level, so that _instruction-guard (Phase 1) automatically loads it.

Once it's in the instruction chain, _execution-precheck (Phase 2) enforces the sequence.

---

## Version & Status

- **Version**: 1.1
- **Status**: Active
- **Created**: 2026-03-05
- **Updated**: 2026-03-05
- **Purpose**: Enforce and verify mandatory initialization on every response
105 changes: 0 additions & 105 deletions .github/EXECUTION_RULES.md

This file was deleted.

Loading
0