mirror of
https://github.com/catlog22/Claude-Code-Workflow.git
synced 2026-02-15 02:42:45 +08:00
refactor: Convert skill-generator from Chinese to English and remove emoji icons
- Convert all markdown files from Chinese to English - Remove all emoji/icon decorations (🔧📋⚙️✅🏁🔍📚⛔⭐) - Update all section headers, descriptions, and documentation - Keep all content logic, structure, code examples unchanged - Maintain template variables and file paths as-is Files converted (9 files total): - SKILL.md: Output structure comments - templates/skill-md.md: All Chinese descriptions and comments - specs/reference-docs-spec.md: All section headers and explanations - phases/01-requirements-discovery.md through 05-validation.md (5 files) - specs/execution-modes.md, skill-requirements.md, cli-integration.md, scripting-integration.md (4 files) - templates/sequential-phase.md, autonomous-orchestrator.md, autonomous-action.md, code-analysis-action.md, llm-action.md, script-template.md (6 files) All 16 files in skill-generator are now fully in English.
This commit is contained in:
@@ -1,59 +1,59 @@
|
||||
# Autonomous Orchestrator Template
|
||||
|
||||
自主模式编排器的模板。
|
||||
Template for orchestrator file in Autonomous execution mode.
|
||||
|
||||
## Purpose
|
||||
|
||||
生成 Autonomous 执行模式的 Orchestrator 文件,负责状态驱动的动作选择和执行循环。
|
||||
Generate Orchestrator file for Autonomous execution mode, responsible for state-driven action selection and execution loop.
|
||||
|
||||
## Usage Context
|
||||
|
||||
| Phase | Usage |
|
||||
|-------|-------|
|
||||
| Phase 3 (Phase Generation) | `config.execution_mode === 'autonomous'` 时生成 |
|
||||
| Generation Trigger | 创建编排器逻辑,管理动作选择和状态更新 |
|
||||
| Phase 3 (Phase Generation) | Generated when `config.execution_mode === 'autonomous'` |
|
||||
| Generation Trigger | Create orchestrator logic to manage action selection and state updates |
|
||||
| Output Location | `.claude/skills/{skill-name}/phases/orchestrator.md` |
|
||||
|
||||
---
|
||||
|
||||
## ⚠️ 重要提示
|
||||
## Important Notes
|
||||
|
||||
> **Phase 0 是强制前置阶段**:在 Orchestrator 启动执行循环之前,必须先完成 Phase 0 的规范研读。
|
||||
> **Phase 0 is mandatory prerequisite**: Before Orchestrator starts execution loop, Phase 0 specification review must be completed first.
|
||||
>
|
||||
> 生成 Orchestrator 时,需要确保:
|
||||
> 1. SKILL.md 中已包含 Phase 0 规范研读步骤
|
||||
> 2. Orchestrator 启动前验证规范已阅读
|
||||
> 3. 所有 Action 文件都引用相关的规范文档
|
||||
> 4. Architecture Overview 中 Phase 0 位于 Orchestrator 之前
|
||||
> When generating Orchestrator, ensure:
|
||||
> 1. Phase 0 specification review step is included in SKILL.md
|
||||
> 2. Orchestrator validates specification has been reviewed before starting execution loop
|
||||
> 3. All Action files reference related specification documents
|
||||
> 4. Architecture Overview places Phase 0 before Orchestrator
|
||||
|
||||
## 模板结构
|
||||
## Template Structure
|
||||
|
||||
```markdown
|
||||
# Orchestrator
|
||||
|
||||
## Role
|
||||
|
||||
根据当前状态选择并执行下一个动作。
|
||||
Select and execute next action based on current state.
|
||||
|
||||
## State Management
|
||||
|
||||
### 读取状态
|
||||
### Read State
|
||||
|
||||
\`\`\`javascript
|
||||
const state = JSON.parse(Read(`${workDir}/state.json`));
|
||||
const state = JSON.parse(Read(\`${workDir}/state.json\`));
|
||||
\`\`\`
|
||||
|
||||
### 更新状态
|
||||
### Update State
|
||||
|
||||
\`\`\`javascript
|
||||
function updateState(updates) {
|
||||
const state = JSON.parse(Read(`${workDir}/state.json`));
|
||||
const state = JSON.parse(Read(\`${workDir}/state.json\`));
|
||||
const newState = {
|
||||
...state,
|
||||
...updates,
|
||||
updated_at: new Date().toISOString()
|
||||
};
|
||||
Write(`${workDir}/state.json`, JSON.stringify(newState, null, 2));
|
||||
Write(\`${workDir}/state.json\`, JSON.stringify(newState, null, 2));
|
||||
return newState;
|
||||
}
|
||||
\`\`\`
|
||||
@@ -62,18 +62,18 @@ function updateState(updates) {
|
||||
|
||||
\`\`\`javascript
|
||||
function selectNextAction(state) {
|
||||
// 1. 终止条件检查
|
||||
// 1. Check termination conditions
|
||||
{{termination_checks}}
|
||||
|
||||
// 2. 错误限制检查
|
||||
|
||||
// 2. Check error limit
|
||||
if (state.error_count >= 3) {
|
||||
return 'action-abort';
|
||||
}
|
||||
|
||||
// 3. 动作选择逻辑
|
||||
|
||||
// 3. Action selection logic
|
||||
{{action_selection_logic}}
|
||||
|
||||
// 4. 默认完成
|
||||
|
||||
// 4. Default completion
|
||||
return 'action-complete';
|
||||
}
|
||||
\`\`\`
|
||||
@@ -83,34 +83,34 @@ function selectNextAction(state) {
|
||||
\`\`\`javascript
|
||||
async function runOrchestrator() {
|
||||
console.log('=== Orchestrator Started ===');
|
||||
|
||||
|
||||
let iteration = 0;
|
||||
const MAX_ITERATIONS = 100;
|
||||
|
||||
|
||||
while (iteration < MAX_ITERATIONS) {
|
||||
iteration++;
|
||||
|
||||
// 1. 读取当前状态
|
||||
const state = JSON.parse(Read(`${workDir}/state.json`));
|
||||
console.log(`[Iteration ${iteration}] Status: ${state.status}`);
|
||||
|
||||
// 2. 选择下一个动作
|
||||
|
||||
// 1. Read current state
|
||||
const state = JSON.parse(Read(\`${workDir}/state.json\`));
|
||||
console.log(\`[Iteration ${iteration}] Status: ${state.status}\`);
|
||||
|
||||
// 2. Select next action
|
||||
const actionId = selectNextAction(state);
|
||||
|
||||
|
||||
if (!actionId) {
|
||||
console.log('No action selected, terminating.');
|
||||
break;
|
||||
}
|
||||
|
||||
console.log(`[Iteration ${iteration}] Executing: ${actionId}`);
|
||||
|
||||
// 3. 更新状态:当前动作
|
||||
|
||||
console.log(\`[Iteration ${iteration}] Executing: ${actionId}\`);
|
||||
|
||||
// 3. Update state: current action
|
||||
updateState({ current_action: actionId });
|
||||
|
||||
// 4. 执行动作
|
||||
|
||||
// 4. Execute action
|
||||
try {
|
||||
const actionPrompt = Read(`phases/actions/${actionId}.md`);
|
||||
|
||||
const actionPrompt = Read(\`phases/actions/${actionId}.md\`);
|
||||
|
||||
const result = await Task({
|
||||
subagent_type: 'universal-executor',
|
||||
run_in_background: false,
|
||||
@@ -125,18 +125,18 @@ async function runOrchestrator() {
|
||||
Return JSON with stateUpdates field.
|
||||
\`
|
||||
});
|
||||
|
||||
|
||||
const actionResult = JSON.parse(result);
|
||||
|
||||
// 5. 更新状态:动作完成
|
||||
|
||||
// 5. Update state: action completed
|
||||
updateState({
|
||||
current_action: null,
|
||||
completed_actions: [...state.completed_actions, actionId],
|
||||
...actionResult.stateUpdates
|
||||
});
|
||||
|
||||
|
||||
} catch (error) {
|
||||
// 错误处理
|
||||
// Error handling
|
||||
updateState({
|
||||
current_action: null,
|
||||
errors: [...state.errors, {
|
||||
@@ -148,7 +148,7 @@ Return JSON with stateUpdates field.
|
||||
});
|
||||
}
|
||||
}
|
||||
|
||||
|
||||
console.log('=== Orchestrator Finished ===');
|
||||
}
|
||||
\`\`\`
|
||||
@@ -167,28 +167,28 @@ Return JSON with stateUpdates field.
|
||||
|
||||
| Error Type | Recovery Strategy |
|
||||
|------------|-------------------|
|
||||
| 动作执行失败 | 重试最多 3 次 |
|
||||
| 状态不一致 | 回滚到上一个稳定状态 |
|
||||
| 用户中止 | 保存当前状态,允许恢复 |
|
||||
| Action execution failed | Retry up to 3 times |
|
||||
| State inconsistency | Rollback to last stable state |
|
||||
| User abort | Save current state, allow recovery |
|
||||
```
|
||||
|
||||
## 变量说明
|
||||
## Variable Descriptions
|
||||
|
||||
| 变量 | 说明 |
|
||||
|------|------|
|
||||
| `{{termination_checks}}` | 终止条件检查代码 |
|
||||
| `{{action_selection_logic}}` | 动作选择逻辑代码 |
|
||||
| `{{action_catalog_table}}` | 动作目录表格 |
|
||||
| `{{termination_conditions_list}}` | 终止条件列表 |
|
||||
| Variable | Description |
|
||||
|----------|-------------|
|
||||
| `{{termination_checks}}` | Termination condition check code |
|
||||
| `{{action_selection_logic}}` | Action selection logic code |
|
||||
| `{{action_catalog_table}}` | Action directory table |
|
||||
| `{{termination_conditions_list}}` | List of termination conditions |
|
||||
|
||||
## 生成函数
|
||||
## Generation Function
|
||||
|
||||
```javascript
|
||||
function generateOrchestrator(config) {
|
||||
const actions = config.autonomous_config.actions;
|
||||
const terminations = config.autonomous_config.termination_conditions || [];
|
||||
|
||||
// 生成终止条件检查
|
||||
|
||||
// Generate termination checks
|
||||
const terminationChecks = terminations.map(t => {
|
||||
const checks = {
|
||||
'user_exit': 'if (state.status === "user_exit") return null;',
|
||||
@@ -198,24 +198,24 @@ function generateOrchestrator(config) {
|
||||
};
|
||||
return checks[t] || `if (state.${t}) return null;`;
|
||||
}).join('\n ');
|
||||
|
||||
// 生成动作选择逻辑
|
||||
|
||||
// Generate action selection logic
|
||||
const actionSelectionLogic = actions.map(action => {
|
||||
if (!action.preconditions?.length) {
|
||||
return `// ${action.name}: 无前置条件,需要手动添加选择逻辑`;
|
||||
return `// ${action.name}: No preconditions, add selection logic manually`;
|
||||
}
|
||||
const conditions = action.preconditions.map(p => `state.${p}`).join(' && ');
|
||||
return `if (${conditions}) return '${action.id}';`;
|
||||
}).join('\n ');
|
||||
|
||||
// 生成动作目录表格
|
||||
const actionCatalogTable = actions.map(a =>
|
||||
|
||||
// Generate action catalog table
|
||||
const actionCatalogTable = actions.map(a =>
|
||||
`| [${a.id}](actions/${a.id}.md) | ${a.description || a.name} | ${a.preconditions?.join(', ') || '-'} |`
|
||||
).join('\n');
|
||||
|
||||
// 生成终止条件列表
|
||||
|
||||
// Generate termination conditions list
|
||||
const terminationConditionsList = terminations.map(t => `- ${t}`).join('\n');
|
||||
|
||||
|
||||
return template
|
||||
.replace('{{termination_checks}}', terminationChecks)
|
||||
.replace('{{action_selection_logic}}', actionSelectionLogic)
|
||||
@@ -224,11 +224,11 @@ function generateOrchestrator(config) {
|
||||
}
|
||||
```
|
||||
|
||||
## 编排策略
|
||||
## Orchestration Strategies
|
||||
|
||||
### 1. 优先级策略
|
||||
### 1. Priority Strategy
|
||||
|
||||
按预定义优先级选择动作:
|
||||
Select action by predefined priority:
|
||||
|
||||
```javascript
|
||||
const PRIORITY = ['action-init', 'action-process', 'action-review', 'action-complete'];
|
||||
@@ -243,16 +243,16 @@ function selectByPriority(state, availableActions) {
|
||||
}
|
||||
```
|
||||
|
||||
### 2. 用户驱动策略
|
||||
### 2. User-Driven Strategy
|
||||
|
||||
询问用户选择下一个动作:
|
||||
Ask user to select next action:
|
||||
|
||||
```javascript
|
||||
async function selectByUser(state, availableActions) {
|
||||
const response = await AskUserQuestion({
|
||||
questions: [{
|
||||
question: "选择下一个操作:",
|
||||
header: "操作",
|
||||
question: "Select next operation:",
|
||||
header: "Operations",
|
||||
multiSelect: false,
|
||||
options: availableActions.map(a => ({
|
||||
label: a.name,
|
||||
@@ -260,32 +260,32 @@ async function selectByUser(state, availableActions) {
|
||||
}))
|
||||
}]
|
||||
});
|
||||
|
||||
return availableActions.find(a => a.name === response["操作"])?.id;
|
||||
|
||||
return availableActions.find(a => a.name === response["Operations"])?.id;
|
||||
}
|
||||
```
|
||||
|
||||
### 3. 状态驱动策略
|
||||
### 3. State-Driven Strategy
|
||||
|
||||
完全基于状态自动决策:
|
||||
Fully automatic decision based on state:
|
||||
|
||||
```javascript
|
||||
function selectByState(state) {
|
||||
// 初始化
|
||||
// Initialization
|
||||
if (state.status === 'pending') return 'action-init';
|
||||
|
||||
// 有待处理项
|
||||
|
||||
// Has pending items
|
||||
if (state.pending_items?.length > 0) return 'action-process';
|
||||
|
||||
// 需要审核
|
||||
|
||||
// Needs review
|
||||
if (state.needs_review) return 'action-review';
|
||||
|
||||
// 完成
|
||||
|
||||
// Completed
|
||||
return 'action-complete';
|
||||
}
|
||||
```
|
||||
|
||||
## 状态机示例
|
||||
## State Machine Example
|
||||
|
||||
```mermaid
|
||||
stateDiagram-v2
|
||||
|
||||
Reference in New Issue
Block a user