From 97624458765d03282e5b5db74b2746091c418607 Mon Sep 17 00:00:00 2001 From: catlog22 Date: Thu, 29 Jan 2026 15:42:46 +0800 Subject: [PATCH] refactor: Convert skill-generator from Chinese to English and remove emoji icons MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit - 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. --- .claude/skills/skill-generator/SKILL.md | 407 +++++++------- .../phases/01-requirements-discovery.md | 160 +++--- .../phases/02-structure-generation.md | 91 ++-- .../phases/03-phase-generation.md | 515 +++++++++--------- .../phases/04-specs-templates.md | 178 +++--- .../skill-generator/phases/05-validation.md | 100 ++-- .../skill-generator/specs/cli-integration.md | 262 ++++----- .../skill-generator/specs/execution-modes.md | 247 ++++----- .../specs/reference-docs-spec.md | 218 ++++---- .../specs/scripting-integration.md | 152 +++--- .../specs/skill-requirements.md | 328 +++++------ .../templates/autonomous-action.md | 177 +++--- .../templates/autonomous-orchestrator.md | 178 +++--- .../templates/code-analysis-action.md | 297 +++++----- .../skill-generator/templates/llm-action.md | 200 +++---- .../templates/script-template.md | 158 +++--- .../templates/sequential-phase.md | 258 ++++----- .../skill-generator/templates/skill-md.md | 189 +++---- 18 files changed, 2049 insertions(+), 2066 deletions(-) diff --git a/.claude/skills/skill-generator/SKILL.md b/.claude/skills/skill-generator/SKILL.md index ad2b70ea..5410bcc0 100644 --- a/.claude/skills/skill-generator/SKILL.md +++ b/.claude/skills/skill-generator/SKILL.md @@ -1,6 +1,6 @@ --- name: skill-generator -description: Meta-skill for creating new Claude Code skills with configurable execution modes. Supports sequential (fixed order) and autonomous (stateless) phase patterns. Use for skill scaffolding, skill creation, or building new workflows. Triggers on "create skill", "new skill", "skill generator", "生成技胜", "创建技胜". +description: Meta-skill for creating new Claude Code skills with configurable execution modes. Supports sequential (fixed order) and autonomous (stateless) phase patterns. Use for skill scaffolding, skill creation, or building new workflows. Triggers on "create skill", "new skill", "skill generator". allowed-tools: Task, AskUserQuestion, Read, Bash, Glob, Grep, Write --- @@ -36,96 +36,94 @@ Meta-skill for creating new Claude Code skills with configurable execution modes ## Execution Modes -### Mode 1: Sequential (固定顺序) +### Mode 1: Sequential (Fixed Order) -䌠统线性执行暡匏阶段按数字前猀顺序执行。 +Traditional linear execution model, phases execute in numeric prefix order. ``` -Phase 01 → Phase 02 → Phase 03 → ... → Phase N +Phase 01 -> Phase 02 -> Phase 03 -> ... -> Phase N ``` -**适甚场景**: -- 流氎线匏任务收集 → 分析 → 生成 -- 阶段闎有区䟝赖关系 -- 蟓出结构固定 +**Use Cases**: +- Pipeline tasks (collect -> analyze -> generate) +- Strong dependencies between phases +- Fixed output structure -**瀺䟋**: `software-manual`, `copyright-docs` +**Examples**: `software-manual`, `copyright-docs` -### Mode 2: Autonomous (无状态自䞻选择) +### Mode 2: Autonomous (Stateless Auto-Select) -智胜路由暡匏根据䞊䞋文劚态选择执行路埄。 +Intelligent routing model, dynamically selects execution path based on context. ``` -┌─────────────────────────────────────────┐ -│ Orchestrator Agent │ -│ (读取状态 → 选择 Phase → 执行 → 曎新) │ -└───────────────┬─────────────────────────┘ - │ - ┌───────────┌───────────┐ - ↓ ↓ ↓ -┌───────┐ ┌───────┐ ┌───────┐ -│Phase A│ │Phase B│ │Phase C│ -│(独立) │ │(独立) │ │(独立) │ -└───────┘ └───────┘ └───────┘ +--------------------------------------------------- + Orchestrator Agent + (Read state -> Select Phase -> Execute -> Update) +--------------------------------------------------- + | + ---------+----------+---------- + | | | + Phase A Phase B Phase C + (standalone) (standalone) (standalone) ``` -**适甚场景**: -- 亀互匏任务对话、问答 -- 阶段闎无区䟝赖 -- 需芁劚态响应甚户意囟 +**Use Cases**: +- Interactive tasks (chat, Q&A) +- No strong dependencies between phases +- Dynamic user intent response required -**瀺䟋**: `issue-manage`, `workflow-debug` +**Examples**: `issue-manage`, `workflow-debug` ## Key Design Principles -1. **暡匏感知**: 根据任务特性自劚掚荐执行暡匏 -2. **骚架生成**: 生成完敎目圕结构和文件骚架 -3. **规范遵埪**: 䞥栌遵埪 `_shared/SKILL-DESIGN-SPEC.md` -4. **可扩展性**: 生成的 Skill 易于扩展和修改 +1. **Mode Awareness**: Automatically recommend execution mode based on task characteristics +2. **Skeleton Generation**: Generate complete directory structure and file skeletons +3. **Standards Compliance**: Strictly follow `_shared/SKILL-DESIGN-SPEC.md` +4. **Extensibility**: Generated Skills are easy to extend and modify --- -## ⚠ Mandatory Prerequisites (区制前眮条件) +## Required Prerequisites -> **⛔ 犁止跳过**: 圚执行任䜕生成操䜜之前**必须**完敎阅读以䞋文档。未阅读规范盎接生成将富臎蟓出䞍笊合莚量标准。 +IMPORTANT: Before any generation operation, read the following specification documents. Generating without understanding these standards will result in non-conforming output. -### 栞心规范 (必读) +### Core Specifications (Mandatory Read) | Document | Purpose | Priority | |----------|---------|----------| -| [../_shared/SKILL-DESIGN-SPEC.md](../_shared/SKILL-DESIGN-SPEC.md) | 通甚讟计规范 - 定义所有 Skill 的结构、呜名、莚量标准 | **P0 - 最高** | -| [specs/reference-docs-spec.md](specs/reference-docs-spec.md) | **参考文档生成规范** - 确保生成的skilläž­Reference Documents郚分有正确的分阶段组织和䜿甚时机指匕 | **P0 - 最高** | +| [../_shared/SKILL-DESIGN-SPEC.md](../_shared/SKILL-DESIGN-SPEC.md) | Universal design spec - defines structure, naming, quality standards for all Skills | **P0 - Critical** | +| [specs/reference-docs-spec.md](specs/reference-docs-spec.md) | Reference document generation spec - ensures generated Skills have proper phase-based Reference Documents with usage timing guidance | **P0 - Critical** | -### 暡板文件 (生成前必读) +### Template Files (Read Before Generation) | Document | Purpose | |----------|---------| -| [templates/skill-md.md](templates/skill-md.md) | SKILL.md 入口文件暡板 | -| [templates/sequential-phase.md](templates/sequential-phase.md) | Sequential Phase 暡板 | -| [templates/autonomous-orchestrator.md](templates/autonomous-orchestrator.md) | Autonomous 猖排噚暡板 | -| [templates/autonomous-action.md](templates/autonomous-action.md) | Autonomous Action 暡板 | -| [templates/code-analysis-action.md](templates/code-analysis-action.md) | 代码分析 Action 暡板 | -| [templates/llm-action.md](templates/llm-action.md) | LLM Action 暡板 | -| [templates/script-template.md](templates/script-template.md) | 统䞀脚本暡板 (Bash + Python) | +| [templates/skill-md.md](templates/skill-md.md) | SKILL.md entry file template | +| [templates/sequential-phase.md](templates/sequential-phase.md) | Sequential Phase template | +| [templates/autonomous-orchestrator.md](templates/autonomous-orchestrator.md) | Autonomous Orchestrator template | +| [templates/autonomous-action.md](templates/autonomous-action.md) | Autonomous Action template | +| [templates/code-analysis-action.md](templates/code-analysis-action.md) | Code Analysis Action template | +| [templates/llm-action.md](templates/llm-action.md) | LLM Action template | +| [templates/script-template.md](templates/script-template.md) | Unified Script Template (Bash + Python) | -### 规范文档 (按需阅读) +### Specification Documents (Read as Needed) | Document | Purpose | |----------|---------| -| [specs/execution-modes.md](specs/execution-modes.md) | 执行暡匏规范 | -| [specs/skill-requirements.md](specs/skill-requirements.md) | Skill 需求规范 | -| [specs/cli-integration.md](specs/cli-integration.md) | CLI 集成规范 | -| [specs/scripting-integration.md](specs/scripting-integration.md) | 脚本集成规范 | +| [specs/execution-modes.md](specs/execution-modes.md) | Execution Modes Specification | +| [specs/skill-requirements.md](specs/skill-requirements.md) | Skill Requirements Specification | +| [specs/cli-integration.md](specs/cli-integration.md) | CLI Integration Specification | +| [specs/scripting-integration.md](specs/scripting-integration.md) | Script Integration Specification | -### Phase 执行指南 (执行时参考) +### Phase Execution Guides (Reference During Execution) | Document | Purpose | |----------|---------| -| [phases/01-requirements-discovery.md](phases/01-requirements-discovery.md) | 收集 Skill 需求 | -| [phases/02-structure-generation.md](phases/02-structure-generation.md) | 生成目圕结构 | -| [phases/03-phase-generation.md](phases/03-phase-generation.md) | 生成 Phase 文件 | -| [phases/04-specs-templates.md](phases/04-specs-templates.md) | 生成规范和暡板 | -| [phases/05-validation.md](phases/05-validation.md) | 验证和文档 | +| [phases/01-requirements-discovery.md](phases/01-requirements-discovery.md) | Collect Skill Requirements | +| [phases/02-structure-generation.md](phases/02-structure-generation.md) | Generate Directory Structure | +| [phases/03-phase-generation.md](phases/03-phase-generation.md) | Generate Phase Files | +| [phases/04-specs-templates.md](phases/04-specs-templates.md) | Generate Specs and Templates | +| [phases/05-validation.md](phases/05-validation.md) | Validation and Documentation | --- @@ -135,92 +133,73 @@ Phase 01 → Phase 02 → Phase 03 → ... → Phase N Input Parsing: └─ Convert user request to structured format (skill-name/purpose/mode) -Phase 0: Specification Study (⚠ MANDATORY - 犁止跳过) - └─ Read specification documents - ├─ Load: ../_shared/SKILL-DESIGN-SPEC.md - ├─ Load: All templates/*.md files - ├─ Understand: Structure rules, naming conventions, quality standards - └─ Output: Internalized requirements (in-memory, no file output) - └─ Validation: ⛔ MUST complete before Phase 1 +Phase 0: Specification Study (MANDATORY - Must complete before proceeding) + - Read specification documents + - Load: ../_shared/SKILL-DESIGN-SPEC.md + - Load: All templates/*.md files + - Understand: Structure rules, naming conventions, quality standards + - Output: Internalized requirements (in-memory, no file output) + - Validation: MUST complete before Phase 1 Phase 1: Requirements Discovery - └─ Gather skill requirements via user interaction - ├─ Tool: AskUserQuestion - │ ├─ Prompt: Skill name, purpose, execution mode - │ ├─ Prompt: Phase/Action definition - │ └─ Prompt: Tool dependencies, output format - ├─ Process: Generate configuration object - └─ Output: skill-config.json → ${workDir}/ - ├─ skill_name: string - ├─ execution_mode: "sequential" | "autonomous" - ├─ phases/actions: array - └─ allowed_tools: array + - Gather skill requirements via user interaction + - Tool: AskUserQuestion + - Collect: Skill name, purpose, execution mode + - Collect: Phase/Action definition + - Collect: Tool dependencies, output format + - Process: Generate configuration object + - Output: skill-config.json + - Contains: skill_name, execution_mode, phases/actions, allowed_tools Phase 2: Structure Generation - └─ Create directory structure and entry file - ├─ Input: skill-config.json (from Phase 1) - ├─ Tool: Bash - │ └─ Execute: mkdir -p .claude/skills/{skill-name}/{phases,specs,templates,scripts} - ├─ Tool: Write - │ └─ Generate: SKILL.md (entry point with architecture diagram) - └─ Output: Complete directory structure - ├─ .claude/skills/{skill-name}/SKILL.md - ├─ .claude/skills/{skill-name}/phases/ - ├─ .claude/skills/{skill-name}/specs/ - ├─ .claude/skills/{skill-name}/templates/ - └─ .claude/skills/{skill-name}/scripts/ + - Create directory structure and entry file + - Input: skill-config.json (from Phase 1) + - Tool: Bash + - Execute: mkdir -p .claude/skills/{skill-name}/{phases,specs,templates,scripts} + - Tool: Write + - Generate: SKILL.md (entry point with architecture diagram) + - Output: Complete directory structure Phase 3: Phase/Action Generation - └─ Decision (execution_mode check): - ├─ execution_mode === "sequential" → Generate Sequential Phases - │ ├─ Tool: Read (template: templates/sequential-phase.md) - │ ├─ Loop: For each phase in config.sequential_config.phases - │ │ ├─ Generate: phases/{phase-id}.md - │ │ └─ Link: Previous phase output → Current phase input - │ ├─ Tool: Write (orchestrator: phases/_orchestrator.md) - │ ├─ Tool: Write (workflow definition: workflow.json) - │ └─ Output: phases/01-{name}.md, phases/02-{name}.md, ... - │ - └─ execution_mode === "autonomous" → Generate Orchestrator + Actions - ├─ Tool: Read (template: templates/autonomous-orchestrator.md) - ├─ Tool: Write (state schema: phases/state-schema.md) - ├─ Tool: Write (orchestrator: phases/orchestrator.md) - ├─ Tool: Write (action catalog: specs/action-catalog.md) - ├─ Loop: For each action in config.autonomous_config.actions - │ ├─ Tool: Read (template: templates/autonomous-action.md) - │ └─ Generate: phases/actions/{action-id}.md - └─ Output: phases/orchestrator.md, phases/actions/*.md + - Decision (execution_mode check): + - IF execution_mode === "sequential": Generate Sequential Phases + - Read template: templates/sequential-phase.md + - Loop: For each phase in config.sequential_config.phases + - Generate: phases/{phase-id}.md + - Link: Previous phase output -> Current phase input + - Write: phases/_orchestrator.md + - Write: workflow.json + - Output: phases/01-{name}.md, phases/02-{name}.md, ... + + - ELSE IF execution_mode === "autonomous": Generate Orchestrator + Actions + - Read template: templates/autonomous-orchestrator.md + - Write: phases/state-schema.md + - Write: phases/orchestrator.md + - Write: specs/action-catalog.md + - Loop: For each action in config.autonomous_config.actions + - Read template: templates/autonomous-action.md + - Generate: phases/actions/{action-id}.md + - Output: phases/orchestrator.md, phases/actions/*.md Phase 4: Specs & Templates - └─ Generate domain specifications and templates - ├─ Input: skill-config.json (domain context) - ├─ ⚠ 参考规范: [specs/reference-docs-spec.md](specs/reference-docs-spec.md) - 确保生成的参考文档有正确的分阶段组织 - ├─ Tool: Write - │ ├─ Generate: specs/{domain}-requirements.md - │ ├─ Generate: specs/quality-standards.md - │ └─ Generate: templates/agent-base.md (if needed) - └─ Output: Domain-specific documentation - ├─ specs/{skill-name}-requirements.md - ├─ specs/quality-standards.md - └─ templates/agent-base.md + - Generate domain specifications and templates + - Input: skill-config.json (domain context) + - Reference: [specs/reference-docs-spec.md](specs/reference-docs-spec.md) for document organization + - Tool: Write + - Generate: specs/{domain}-requirements.md + - Generate: specs/quality-standards.md + - Generate: templates/agent-base.md (if needed) + - Output: Domain-specific documentation Phase 5: Validation & Documentation - └─ Verify completeness and generate usage guide - ├─ Input: All generated files from previous phases - ├─ Tool: Glob + Read - │ └─ Check: Required files exist and contain proper structure - ├─ Tool: Write - │ ├─ Generate: README.md (usage instructions) - │ └─ Generate: validation-report.json (completeness check) - └─ Output: Final documentation - ├─ README.md (how to use this skill) - └─ validation-report.json (quality gate results) - -Return: - └─ Summary with skill location and next steps - ├─ Skill path: .claude/skills/{skill-name}/ - ├─ Status: ✅ All phases completed - └─ Suggestion: "Review SKILL.md and customize phase files as needed" + - Verify completeness and generate usage guide + - Input: All generated files from previous phases + - Tool: Glob + Read + - Check: Required files exist and contain proper structure + - Tool: Write + - Generate: README.md (usage instructions) + - Generate: validation-report.json (completeness check) + - Output: Final documentation ``` **Execution Protocol**: @@ -278,83 +257,83 @@ Write(`${skillDir}/README.md`, generateReadme(config, validation)); ## Reference Documents by Phase -> **重芁**: 本郚分展瀺skill-generator劂䜕组织自己的参考文档这是生成的skill应该暡仿的瀺䟋。诊见 [specs/reference-docs-spec.md](specs/reference-docs-spec.md) +IMPORTANT: This section demonstrates how skill-generator organizes its own reference documentation. This is the pattern that all generated Skills should emulate. See [specs/reference-docs-spec.md](specs/reference-docs-spec.md) for details. -### 🔧 Phase 0: Specification Study (区制前眮) +### Phase 0: Specification Study (Mandatory Prerequisites) -所有生成操䜜前必须阅读的规范 +Specification documents that must be read before any generation operation | Document | Purpose | When to Use | |----------|---------|-------------| -| [../_shared/SKILL-DESIGN-SPEC.md](../_shared/SKILL-DESIGN-SPEC.md) | Skill讟计通甚规范 | 理解Skill结构和呜名规范 ✅ **必读** | -| [specs/reference-docs-spec.md](specs/reference-docs-spec.md) | 参考文档生成规范 | 确保Reference Documents有正确的组织方匏 ✅ **必读** | +| [../_shared/SKILL-DESIGN-SPEC.md](../_shared/SKILL-DESIGN-SPEC.md) | Universal Skill design specification | Understand Skill structure and naming conventions - **REQUIRED** | +| [specs/reference-docs-spec.md](specs/reference-docs-spec.md) | Reference document generation specification | Ensure Reference Documents have proper phase-based organization - **REQUIRED** | -### 📋 Phase 1: Requirements Discovery +### Phase 1: Requirements Discovery -收集Skill需求和配眮 +Collect Skill requirements and configuration | Document | Purpose | When to Use | |----------|---------|-------------| -| [phases/01-requirements-discovery.md](phases/01-requirements-discovery.md) | Phase 1执行指南 | 理解劂䜕收集甚户需求和生成配眮 | -| [specs/skill-requirements.md](specs/skill-requirements.md) | Skill需求规范 | 理解Skill应包含哪些信息 | +| [phases/01-requirements-discovery.md](phases/01-requirements-discovery.md) | Phase 1 execution guide | Understand how to collect user requirements and generate configuration | +| [specs/skill-requirements.md](specs/skill-requirements.md) | Skill requirements specification | Understand what information a Skill should contain | -### 🔧 Phase 2: Structure Generation +### Phase 2: Structure Generation -生成目圕结构和入口文件 +Generate directory structure and entry file | Document | Purpose | When to Use | |----------|---------|-------------| -| [phases/02-structure-generation.md](phases/02-structure-generation.md) | Phase 2执行指南 | 理解劂䜕生成目圕结构 | -| [templates/skill-md.md](templates/skill-md.md) | SKILL.md暡板 | 了解劂䜕生成入口文件 | +| [phases/02-structure-generation.md](phases/02-structure-generation.md) | Phase 2 execution guide | Understand how to generate directory structure | +| [templates/skill-md.md](templates/skill-md.md) | SKILL.md template | Learn how to generate the entry file | -### ⚙ Phase 3: Phase/Action Generation +### Phase 3: Phase/Action Generation -根据执行暡匏生成具䜓的phase或action文件 +Generate specific phase or action files based on execution mode | Document | Purpose | When to Use | |----------|---------|-------------| -| [phases/03-phase-generation.md](phases/03-phase-generation.md) | Phase 3执行指南 | 理解Sequential vs Autonomous生成逻蟑 | -| [templates/sequential-phase.md](templates/sequential-phase.md) | Sequential Phase暡板 | 生成Sequential暡匏的phase文件 | -| [templates/autonomous-orchestrator.md](templates/autonomous-orchestrator.md) | Orchestrator暡板 | 生成Autonomous暡匏的猖排噚 | -| [templates/autonomous-action.md](templates/autonomous-action.md) | Action暡板 | 生成Autonomous暡匏的action | +| [phases/03-phase-generation.md](phases/03-phase-generation.md) | Phase 3 execution guide | Understand Sequential vs Autonomous generation logic | +| [templates/sequential-phase.md](templates/sequential-phase.md) | Sequential Phase template | Generate phase files for Sequential mode | +| [templates/autonomous-orchestrator.md](templates/autonomous-orchestrator.md) | Orchestrator template | Generate orchestrator for Autonomous mode | +| [templates/autonomous-action.md](templates/autonomous-action.md) | Action template | Generate action files for Autonomous mode | -### ✅ Phase 4: Specs & Templates +### Phase 4: Specs & Templates -生成领域特定的规范和暡板 +Generate domain-specific specifications and templates | Document | Purpose | When to Use | |----------|---------|-------------| -| [phases/04-specs-templates.md](phases/04-specs-templates.md) | Phase 4执行指南 | 理解劂䜕生成domain-specific文档 | -| [specs/reference-docs-spec.md](specs/reference-docs-spec.md) | 参考文档规范 | ⭐ 生成Specs时芁遵埪的规范 | +| [phases/04-specs-templates.md](phases/04-specs-templates.md) | Phase 4 execution guide | Understand how to generate domain-specific documentation | +| [specs/reference-docs-spec.md](specs/reference-docs-spec.md) | Reference document specification | IMPORTANT: Follow this spec when generating Specs | -### 🏁 Phase 5: Validation & Documentation +### Phase 5: Validation & Documentation -验证生成结果并生成最终文档 +Verify results and generate final documentation | Document | Purpose | When to Use | |----------|---------|-------------| -| [phases/05-validation.md](phases/05-validation.md) | Phase 5执行指南 | 理解劂䜕验证生成的skill完敎性 | +| [phases/05-validation.md](phases/05-validation.md) | Phase 5 execution guide | Understand how to verify generated Skill completeness | -### 🔍 Debugging & Troubleshooting +### Debugging & Troubleshooting -遇到问题时查阅 +Reference documents when encountering issues | Issue | Solution Document | |-------|------------------| -| 生成的Skill猺少Reference Documents | [specs/reference-docs-spec.md](specs/reference-docs-spec.md) - 检查是吊遵埪分阶段组织 | -| 参考文档组织混乱 | [specs/reference-docs-spec.md](specs/reference-docs-spec.md) - 栞心原则郚分 | -| 生成的文档䞍笊合莚量标准 | [../_shared/SKILL-DESIGN-SPEC.md](../_shared/SKILL-DESIGN-SPEC.md) | +| Generated Skill missing Reference Documents | [specs/reference-docs-spec.md](specs/reference-docs-spec.md) - verify phase-based organization is followed | +| Reference document organization unclear | [specs/reference-docs-spec.md](specs/reference-docs-spec.md) - Core Principles section | +| Generated documentation does not meet quality standards | [../_shared/SKILL-DESIGN-SPEC.md](../_shared/SKILL-DESIGN-SPEC.md) | -### 📚 Reference & Background +### Reference & Background -甚于深床孊习和讟计决策 +Documents for deep learning and design decisions | Document | Purpose | Notes | |----------|---------|-------| -| [specs/execution-modes.md](specs/execution-modes.md) | 执行暡匏诊细规范 | Sequential vs Autonomous的对比和适甚场景 | -| [specs/cli-integration.md](specs/cli-integration.md) | CLI集成规范 | 生成的Skill劂䜕䞎CLI集成 | -| [specs/scripting-integration.md](specs/scripting-integration.md) | 脚本集成规范 | Phase䞭劂䜕䜿甚脚本 | -| [templates/script-template.md](templates/script-template.md) | 脚本暡板 | Bash + Python统䞀暡板 | +| [specs/execution-modes.md](specs/execution-modes.md) | Detailed execution modes specification | Comparison and use cases for Sequential vs Autonomous | +| [specs/cli-integration.md](specs/cli-integration.md) | CLI integration specification | How generated Skills integrate with CLI | +| [specs/scripting-integration.md](specs/scripting-integration.md) | Script integration specification | How to use scripts in Phases | +| [templates/script-template.md](templates/script-template.md) | Script template | Unified Bash + Python template | --- @@ -364,13 +343,13 @@ Write(`${skillDir}/README.md`, generateReadme(config, validation)); ``` .claude/skills/{skill-name}/ -├── SKILL.md # 入口文件 +├── SKILL.md # Entry file ├── phases/ -│ ├── _orchestrator.md # 声明匏猖排噚 -│ ├── workflow.json # 工䜜流定义 -│ ├── 01-{step-one}.md # 阶段 1 -│ ├── 02-{step-two}.md # 阶段 2 -│ └── 03-{step-three}.md # 阶段 3 +│ ├── _orchestrator.md # Declarative orchestrator +│ ├── workflow.json # Workflow definition +│ ├── 01-{step-one}.md # Phase 1 +│ ├── 02-{step-two}.md # Phase 2 +│ └── 03-{step-three}.md # Phase 3 ├── specs/ │ ├── {skill-name}-requirements.md │ └── quality-standards.md @@ -384,10 +363,10 @@ Write(`${skillDir}/README.md`, generateReadme(config, validation)); ``` .claude/skills/{skill-name}/ -├── SKILL.md # 入口文件 +├── SKILL.md # Entry file ├── phases/ -│ ├── orchestrator.md # 猖排噚 (状态驱劚) -│ ├── state-schema.md # 状态结构定义 +│ ├── orchestrator.md # Orchestrator (state-driven) +│ ├── state-schema.md # State schema definition │ └── actions/ │ ├── action-init.md │ ├── action-create.md @@ -407,80 +386,80 @@ Write(`${skillDir}/README.md`, generateReadme(config, validation)); ## Reference Documents by Phase -> **重芁**: 本郚分展瀺skill-generator劂䜕组织自己的参考文档这是生成的skill应该暡仿的瀺䟋。诊见 [specs/reference-docs-spec.md](specs/reference-docs-spec.md) +IMPORTANT: This section demonstrates how skill-generator organizes its own reference documentation. This is the pattern that all generated Skills should emulate. See [specs/reference-docs-spec.md](specs/reference-docs-spec.md) for details. -### 🔧 Phase 0: Specification Study (区制前眮) +### Phase 0: Specification Study (Mandatory Prerequisites) -所有生成操䜜前必须阅读的规范 +Specification documents that must be read before any generation operation | Document | Purpose | When to Use | |----------|---------|-------------| -| [../_shared/SKILL-DESIGN-SPEC.md](../_shared/SKILL-DESIGN-SPEC.md) | Skill讟计通甚规范 | 理解Skill结构和呜名规范 ✅ **必读** | -| [specs/reference-docs-spec.md](specs/reference-docs-spec.md) | 参考文档生成规范 | 确保Reference Documents有正确的组织方匏 ✅ **必读** | +| [../_shared/SKILL-DESIGN-SPEC.md](../_shared/SKILL-DESIGN-SPEC.md) | Universal Skill design specification | Understand Skill structure and naming conventions - **REQUIRED** | +| [specs/reference-docs-spec.md](specs/reference-docs-spec.md) | Reference document generation specification | Ensure Reference Documents have proper phase-based organization - **REQUIRED** | -### 📋 Phase 1: Requirements Discovery +### Phase 1: Requirements Discovery -收集Skill需求和配眮 +Collect Skill requirements and configuration | Document | Purpose | When to Use | |----------|---------|-------------| -| [phases/01-requirements-discovery.md](phases/01-requirements-discovery.md) | Phase 1执行指南 | 理解劂䜕收集甚户需求和生成配眮 | -| [specs/skill-requirements.md](specs/skill-requirements.md) | Skill需求规范 | 理解Skill应包含哪些信息 | +| [phases/01-requirements-discovery.md](phases/01-requirements-discovery.md) | Phase 1 execution guide | Understand how to collect user requirements and generate configuration | +| [specs/skill-requirements.md](specs/skill-requirements.md) | Skill requirements specification | Understand what information a Skill should contain | -### 🔧 Phase 2: Structure Generation +### Phase 2: Structure Generation -生成目圕结构和入口文件 +Generate directory structure and entry file | Document | Purpose | When to Use | |----------|---------|-------------| -| [phases/02-structure-generation.md](phases/02-structure-generation.md) | Phase 2执行指南 | 理解劂䜕生成目圕结构 | -| [templates/skill-md.md](templates/skill-md.md) | SKILL.md暡板 | 了解劂䜕生成入口文件 | +| [phases/02-structure-generation.md](phases/02-structure-generation.md) | Phase 2 execution guide | Understand how to generate directory structure | +| [templates/skill-md.md](templates/skill-md.md) | SKILL.md template | Learn how to generate the entry file | -### ⚙ Phase 3: Phase/Action Generation +### Phase 3: Phase/Action Generation -根据执行暡匏生成具䜓的phase或action文件 +Generate specific phase or action files based on execution mode | Document | Purpose | When to Use | |----------|---------|-------------| -| [phases/03-phase-generation.md](phases/03-phase-generation.md) | Phase 3执行指南 | 理解Sequential vs Autonomous生成逻蟑 | -| [templates/sequential-phase.md](templates/sequential-phase.md) | Sequential Phase暡板 | 生成Sequential暡匏的phase文件 | -| [templates/autonomous-orchestrator.md](templates/autonomous-orchestrator.md) | Orchestrator暡板 | 生成Autonomous暡匏的猖排噚 | -| [templates/autonomous-action.md](templates/autonomous-action.md) | Action暡板 | 生成Autonomous暡匏的action | +| [phases/03-phase-generation.md](phases/03-phase-generation.md) | Phase 3 execution guide | Understand Sequential vs Autonomous generation logic | +| [templates/sequential-phase.md](templates/sequential-phase.md) | Sequential Phase template | Generate phase files for Sequential mode | +| [templates/autonomous-orchestrator.md](templates/autonomous-orchestrator.md) | Orchestrator template | Generate orchestrator for Autonomous mode | +| [templates/autonomous-action.md](templates/autonomous-action.md) | Action template | Generate action files for Autonomous mode | -### ✅ Phase 4: Specs & Templates +### Phase 4: Specs & Templates -生成领域特定的规范和暡板 +Generate domain-specific specifications and templates | Document | Purpose | When to Use | |----------|---------|-------------| -| [phases/04-specs-templates.md](phases/04-specs-templates.md) | Phase 4执行指南 | 理解劂䜕生成domain-specific文档 | -| [specs/reference-docs-spec.md](specs/reference-docs-spec.md) | 参考文档规范 | ⭐ 生成Specs时芁遵埪的规范 | +| [phases/04-specs-templates.md](phases/04-specs-templates.md) | Phase 4 execution guide | Understand how to generate domain-specific documentation | +| [specs/reference-docs-spec.md](specs/reference-docs-spec.md) | Reference document specification | IMPORTANT: Follow this spec when generating Specs | -### 🏁 Phase 5: Validation & Documentation +### Phase 5: Validation & Documentation -验证生成结果并生成最终文档 +Verify results and generate final documentation | Document | Purpose | When to Use | |----------|---------|-------------| -| [phases/05-validation.md](phases/05-validation.md) | Phase 5执行指南 | 理解劂䜕验证生成的skill完敎性 | +| [phases/05-validation.md](phases/05-validation.md) | Phase 5 execution guide | Understand how to verify generated Skill completeness | -### 🔍 Debugging & Troubleshooting +### Debugging & Troubleshooting -遇到问题时查阅 +Reference documents when encountering issues | Issue | Solution Document | |-------|------------------| -| 生成的Skill猺少Reference Documents | [specs/reference-docs-spec.md](specs/reference-docs-spec.md) - 检查是吊遵埪分阶段组织 | -| 参考文档组织混乱 | [specs/reference-docs-spec.md](specs/reference-docs-spec.md) - 栞心原则郚分 | -| 生成的文档䞍笊合莚量标准 | [../_shared/SKILL-DESIGN-SPEC.md](../_shared/SKILL-DESIGN-SPEC.md) | +| Generated Skill missing Reference Documents | [specs/reference-docs-spec.md](specs/reference-docs-spec.md) - verify phase-based organization is followed | +| Reference document organization unclear | [specs/reference-docs-spec.md](specs/reference-docs-spec.md) - Core Principles section | +| Generated documentation does not meet quality standards | [../_shared/SKILL-DESIGN-SPEC.md](../_shared/SKILL-DESIGN-SPEC.md) | -### 📚 Reference & Background +### Reference & Background -甚于深床孊习和讟计决策 +Documents for deep learning and design decisions | Document | Purpose | Notes | |----------|---------|-------| -| [specs/execution-modes.md](specs/execution-modes.md) | 执行暡匏诊细规范 | Sequential vs Autonomous的对比和适甚场景 | -| [specs/cli-integration.md](specs/cli-integration.md) | CLI集成规范 | 生成的Skill劂䜕䞎CLI集成 | -| [specs/scripting-integration.md](specs/scripting-integration.md) | 脚本集成规范 | Phase䞭劂䜕䜿甚脚本 | -| [templates/script-template.md](templates/script-template.md) | 脚本暡板 | Bash + Python统䞀暡板 | \ No newline at end of file +| [specs/execution-modes.md](specs/execution-modes.md) | Detailed execution modes specification | Comparison and use cases for Sequential vs Autonomous | +| [specs/cli-integration.md](specs/cli-integration.md) | CLI integration specification | How generated Skills integrate with CLI | +| [specs/scripting-integration.md](specs/scripting-integration.md) | Script integration specification | How to use scripts in Phases | +| [templates/script-template.md](templates/script-template.md) | Script template | Unified Bash + Python template | \ No newline at end of file diff --git a/.claude/skills/skill-generator/phases/01-requirements-discovery.md b/.claude/skills/skill-generator/phases/01-requirements-discovery.md index b54b69c2..e218deb3 100644 --- a/.claude/skills/skill-generator/phases/01-requirements-discovery.md +++ b/.claude/skills/skill-generator/phases/01-requirements-discovery.md @@ -1,114 +1,125 @@ +# Phase 1: Requirements Discovery +Collect basic skill information, configuration, and execution mode based on user input. -### Step 1: 基本信息收集 +## Objective + +- Collect skill basic information (name, description, trigger words) +- Determine execution mode (Sequential/Autonomous/Hybrid) +- Define phases or actions +- Generate initial configuration file + +## Execution Steps + +### Step 1: Basic Information Collection ```javascript const basicInfo = await AskUserQuestion({ questions: [ { - question: "新 Skill 的名称是什么英文小写-连字笊栌匏劂 'api-docs'", - header: "Skill 名称", + question: "What is the name of the new Skill? (English, lowercase with hyphens, e.g., 'api-docs')", + header: "Skill Name", multiSelect: false, options: [ - { label: "自劚生成", description: "根据后续描述自劚生成名称" }, - { label: "手劚蟓入", description: "现圚蟓入自定义名称" } + { label: "Auto-generate", description: "Generate name automatically based on description" }, + { label: "Manual Input", description: "Enter custom name now" } ] }, { - question: "Skill 的䞻芁甚途是什么", - header: "甚途类型", + question: "What is the primary purpose of the Skill?", + header: "Purpose Type", multiSelect: false, options: [ - { label: "文档生成", description: "生成 Markdown/HTML 文档劂手册、报告" }, - { label: "代码分析", description: "分析代码结构、莚量、安党性" }, - { label: "亀互管理", description: "管理 Issue、任务、工䜜流CRUD 操䜜" }, - { label: "数据倄理", description: "ETL、栌匏蜬换、报告生成" } + { label: "Document Generation", description: "Generate Markdown/HTML documents (manuals, reports)" }, + { label: "Code Analysis", description: "Analyze code structure, quality, security" }, + { label: "Interactive Management", description: "Manage Issues, tasks, workflows (CRUD operations)" }, + { label: "Data Processing", description: "ETL, format conversion, report generation" } ] } ] }); -// 劂果选择手劚蟓入进䞀步询问 -if (basicInfo["Skill 名称"] === "手劚蟓入") { - // 甚户䌚圚 "Other" 䞭蟓入 +// If manual input is selected, prompt further +if (basicInfo["Skill Name"] === "Manual Input") { + // User will input in "Other" } -// 根据甚途类型掚断描述暡板 +// Infer description template based on purpose type const purposeTemplates = { - "文档生成": "Generate {type} documents from {source}", - "代码分析": "Analyze {target} for {purpose}", - "亀互管理": "Manage {entity} with interactive operations", - "数据倄理": "Process {data} and generate {output}" + "Document Generation": "Generate {type} documents from {source}", + "Code Analysis": "Analyze {target} for {purpose}", + "Interactive Management": "Manage {entity} with interactive operations", + "Data Processing": "Process {data} and generate {output}" }; ``` -### Step 2: 执行暡匏选择 +### Step 2: Execution Mode Selection ```javascript const modeInfo = await AskUserQuestion({ questions: [ { - question: "选择执行暡匏", - header: "执行暡匏", + question: "Select execution mode:", + header: "Execution Mode", multiSelect: false, options: [ - { - label: "Sequential (顺序暡匏)", - description: "阶段按固定顺序执行收集→分析→生成适合流氎线任务掚荐" + { + label: "Sequential (Sequential Mode)", + description: "Phases execute in fixed order (collect→analyze→generate), suitable for pipeline tasks (recommended)" }, - { - label: "Autonomous (自䞻暡匏)", - description: "劚态选择执行路埄适合亀互匏任务劂 Issue 管理" + { + label: "Autonomous (Autonomous Mode)", + description: "Dynamically select execution path, suitable for interactive tasks (e.g., Issue management)" }, - { - label: "Hybrid (混合暡匏)", - description: "初始化和收尟固定䞭闎亀互灵掻" + { + label: "Hybrid (Hybrid Mode)", + description: "Fixed initialization and finalization, flexible interaction in the middle" } ] } ] }); -const executionMode = modeInfo["执行暡匏"].includes("Sequential") ? "sequential" : - modeInfo["执行暡匏"].includes("Autonomous") ? "autonomous" : "hybrid"; +const executionMode = modeInfo["Execution Mode"].includes("Sequential") ? "sequential" : + modeInfo["Execution Mode"].includes("Autonomous") ? "autonomous" : "hybrid"; ``` -### Step 3: 阶段/劚䜜定义 +### Step 3: Phase/Action Definition -#### Sequential 暡匏 +#### Sequential Mode ```javascript if (executionMode === "sequential") { const phaseInfo = await AskUserQuestion({ questions: [ { - question: "需芁倚少䞪执行阶段", - header: "阶段数量", + question: "How many execution phases are needed?", + header: "Phase Count", multiSelect: false, options: [ - { label: "3 阶段简单", description: "收集 → 倄理 → 蟓出" }, - { label: "5 阶段标准", description: "收集 → 探玢 → 分析 → 组装 → 验证" }, - { label: "7 阶段完敎", description: "含并行倄理、汇总、迭代䌘化" } + { label: "3 Phases (Simple)", description: "Collection → Processing → Output" }, + { label: "5 Phases (Standard)", description: "Collection → Exploration → Analysis → Assembly → Validation" }, + { label: "7 Phases (Complete)", description: "Includes parallel processing, consolidation, iterative optimization" } ] } ] }); - - // 根据选择生成阶段定义 + + // Generate phase definitions based on selection const phaseTemplates = { - "3 阶段": [ + "3 Phases": [ { id: "01-collection", name: "Data Collection" }, { id: "02-processing", name: "Processing" }, { id: "03-output", name: "Output Generation" } ], - "5 阶段": [ + "5 Phases": [ { id: "01-collection", name: "Requirements Collection" }, { id: "02-exploration", name: "Project Exploration" }, { id: "03-analysis", name: "Deep Analysis" }, { id: "04-assembly", name: "Document Assembly" }, { id: "05-validation", name: "Validation" } ], - "7 阶段": [ + "7 Phases": [ { id: "01-collection", name: "Requirements Collection" }, { id: "02-exploration", name: "Project Exploration" }, { id: "03-parallel", name: "Parallel Analysis" }, @@ -121,23 +132,23 @@ if (executionMode === "sequential") { } ``` -#### Autonomous 暡匏 +#### Autonomous Mode ```javascript if (executionMode === "autonomous") { const actionInfo = await AskUserQuestion({ questions: [ { - question: "栞心劚䜜有哪些可倚选", - header: "劚䜜定义", + question: "What are the core actions? (Multiple selection allowed)", + header: "Action Definition", multiSelect: true, options: [ - { label: "初始化 (init)", description: "讟眮初始状态" }, - { label: "列衚 (list)", description: "星瀺圓前项目列衚" }, - { label: "创建 (create)", description: "创建新项目" }, - { label: "猖蟑 (edit)", description: "修改现有项目" }, - { label: "删陀 (delete)", description: "删陀项目" }, - { label: "搜玢 (search)", description: "搜玢/过滀项目" } + { label: "Initialize (init)", description: "Set initial state" }, + { label: "List (list)", description: "Display current item list" }, + { label: "Create (create)", description: "Create new item" }, + { label: "Edit (edit)", description: "Modify existing item" }, + { label: "Delete (delete)", description: "Delete item" }, + { label: "Search (search)", description: "Search/filter items" } ] } ] @@ -145,37 +156,37 @@ if (executionMode === "autonomous") { } ``` -### Step 4: 工具和蟓出配眮 +### Step 4: Tool and Output Configuration ```javascript const toolsInfo = await AskUserQuestion({ questions: [ { - question: "需芁哪些特殊工具基础工具已默讀包含", - header: "工具选择", + question: "Which special tools are needed? (Basic tools are included by default)", + header: "Tool Selection", multiSelect: true, options: [ - { label: "甚户亀互 (AskUserQuestion)", description: "需芁䞎甚户对话" }, - { label: "Chrome 截囟 (mcp__chrome__*)", description: "需芁眑页截囟" }, - { label: "倖郚搜玢 (mcp__exa__search)", description: "需芁搜玢倖郚信息" }, - { label: "无特殊需求", description: "仅䜿甚基础工具" } + { label: "User Interaction (AskUserQuestion)", description: "Need to dialog with user" }, + { label: "Chrome Screenshot (mcp__chrome__*)", description: "Need web page screenshots" }, + { label: "External Search (mcp__exa__search)", description: "Need to search external information" }, + { label: "No Special Requirements", description: "Use basic tools only" } ] }, { - question: "蟓出栌匏是什么", - header: "蟓出栌匏", + question: "What is the output format?", + header: "Output Format", multiSelect: false, options: [ - { label: "Markdown", description: "适合文档和报告" }, - { label: "HTML", description: "适合亀互匏文档" }, - { label: "JSON", description: "适合数据和配眮" } + { label: "Markdown", description: "Suitable for documents and reports" }, + { label: "HTML", description: "Suitable for interactive documents" }, + { label: "JSON", description: "Suitable for data and configuration" } ] } ] }); ``` -### Step 5: 生成配眮文件 +### Step 5: Generate Configuration File ```javascript const config = { @@ -184,41 +195,40 @@ const config = { description: description, triggers: triggers, execution_mode: executionMode, - - // 暡匏特定配眮 + + // Mode-specific configuration ...(executionMode === "sequential" ? { sequential_config: { phases: phases } } : { - autonomous_config: { + autonomous_config: { state_schema: stateSchema, actions: actions, termination_conditions: ["user_exit", "error_limit", "task_completed"] } }), - + allowed_tools: [ "Task", "Read", "Write", "Glob", "Grep", "Bash", ...selectedTools ], - + output: { format: outputFormat.toLowerCase(), location: `.workflow/.scratchpad/${skillName}-{timestamp}`, filename_pattern: `{name}-output.${outputFormat === "HTML" ? "html" : outputFormat === "JSON" ? "json" : "md"}` }, - + created_at: new Date().toISOString(), version: "1.0.0" }; -// 写入配眮文件 +// Write configuration file const workDir = `.workflow/.scratchpad/skill-gen-${timestamp}`; Bash(`mkdir -p "${workDir}"`); Write(`${workDir}/skill-config.json`, JSON.stringify(config, null, 2)); ``` - ## Next Phase → [Phase 2: Structure Generation](02-structure-generation.md) diff --git a/.claude/skills/skill-generator/phases/02-structure-generation.md b/.claude/skills/skill-generator/phases/02-structure-generation.md index 65d6007b..cf6b7879 100644 --- a/.claude/skills/skill-generator/phases/02-structure-generation.md +++ b/.claude/skills/skill-generator/phases/02-structure-generation.md @@ -1,41 +1,40 @@ # Phase 2: Structure Generation -根据配眮创建 Skill 目圕结构和入口文件。 +Create Skill directory structure and entry file based on configuration. ## Objective -- 创建标准目圕结构 -- 生成 SKILL.md 入口文件 -- 根据执行暡匏创建对应的子目圕 - +- Create standard directory structure +- Generate SKILL.md entry file +- Create corresponding subdirectories based on execution mode ## Execution Steps -### Step 1: 读取配眮 +### Step 1: Read Configuration ```javascript const config = JSON.parse(Read(`${workDir}/skill-config.json`)); const skillDir = `.claude/skills/${config.skill_name}`; ``` -### Step 2: 创建目圕结构 +### Step 2: Create Directory Structure -#### 基础目圕所有暡匏 +#### Base Directories (All Modes) ```javascript -// 基础架构 +// Base infrastructure Bash(`mkdir -p "${skillDir}/{phases,specs,templates,scripts}"`); ``` -#### 执行暡匏特定目圕 +#### Execution Mode-Specific Directories ``` config.execution_mode ↓ ├─ "sequential" │ ↓ Creates: - │ └─ phases/ (基础目圕已包含) + │ └─ phases/ (base directory already included) │ ├─ _orchestrator.md │ └─ workflow.json │ @@ -43,36 +42,36 @@ config.execution_mode ↓ Creates: └─ phases/actions/ ├─ state-schema.md - └─ *.md (劚䜜文件) + └─ *.md (action files) ``` ```javascript -// Autonomous/Hybrid 暡匏额倖目圕 +// Additional directories for Autonomous/Hybrid mode if (config.execution_mode === 'autonomous' || config.execution_mode === 'hybrid') { Bash(`mkdir -p "${skillDir}/phases/actions"`); } ``` -#### Context Strategy 特定目圕 (P0 增区) +#### Context Strategy-Specific Directories (P0 Enhancement) ```javascript -// ========== P0: 根据䞊䞋文策略创建目圕 ========== +// ========== P0: Create directories based on context strategy ========== const contextStrategy = config.context_strategy || 'file'; if (contextStrategy === 'file') { - // 文件策略创建䞊䞋文持久化目圕 + // File strategy: Create persistent context directory Bash(`mkdir -p "${skillDir}/.scratchpad-template/context"`); - // 创建䞊䞋文暡板文件 + // Create context template file Write( `${skillDir}/.scratchpad-template/context/.gitkeep`, "# Runtime context storage for file-based strategy" ); } -// 内存策略无需创建目圕 (in-memory only) +// Memory strategy does not require directory creation (in-memory only) ``` -**目圕树视囟**: +**Directory Tree View**: ``` Sequential + File Strategy: @@ -83,7 +82,7 @@ Sequential + File Strategy: │ ├── 01-*.md │ └── 02-*.md ├── .scratchpad-template/ - │ └── context/ ← File strategy persistent storage + │ └── context/ <- File strategy persistent storage └── specs/ Autonomous + Memory Strategy: @@ -96,7 +95,7 @@ Autonomous + Memory Strategy: └── specs/ ``` -### Step 3: 生成 SKILL.md +### Step 3: Generate SKILL.md ```javascript const skillMdTemplate = `--- @@ -130,8 +129,8 @@ const timestamp = new Date().toISOString().slice(0,19).replace(/[-:T]/g, ''); const workDir = \`${config.output.location.replace('{timestamp}', '${timestamp}')}\`; Bash(\`mkdir -p "\${workDir}"\`); -${config.execution_mode === 'sequential' ? - `Bash(\`mkdir -p "\${workDir}/sections"\`);` : +${config.execution_mode === 'sequential' ? + `Bash(\`mkdir -p "\${workDir}/sections"\`);` : `Bash(\`mkdir -p "\${workDir}/state"\`);`} \`\`\` @@ -149,53 +148,53 @@ ${generateReferenceTable(config)} Write(`${skillDir}/SKILL.md`, skillMdTemplate); ``` -### Step 4: 架构囟生成凜数 +### Step 4: Architecture Diagram Generation Functions ```javascript function generateArchitectureDiagram(config) { if (config.execution_mode === 'sequential') { - return config.sequential_config.phases.map((p, i) => + return config.sequential_config.phases.map((p, i) => `│ Phase ${i+1}: ${p.name.padEnd(15)} → ${p.output || 'output-' + (i+1) + '.json'}${' '.repeat(10)}│` ).join('\n│ ↓' + ' '.repeat(45) + '│\n'); } else { return ` ┌─────────────────────────────────────────────────────────────────┐ -│ Orchestrator (状态驱劚决策) │ +│ Orchestrator (State-driven decision-making) │ └───────────────┬─────────────────────────────────────────────────┘ │ ┌───────────┌───────────┐ ↓ ↓ ↓ -${config.autonomous_config.actions.slice(0, 3).map(a => +${config.autonomous_config.actions.slice(0, 3).map(a => `┌─────────┐ `).join('')} -${config.autonomous_config.actions.slice(0, 3).map(a => +${config.autonomous_config.actions.slice(0, 3).map(a => `│${a.name.slice(0, 7).padEnd(7)}│ `).join('')} -${config.autonomous_config.actions.slice(0, 3).map(a => +${config.autonomous_config.actions.slice(0, 3).map(a => `└─────────┘ `).join('')}`; } } function generateDesignPrinciples(config) { const common = [ - "1. **规范遵埪**: 䞥栌遵埪 `_shared/SKILL-DESIGN-SPEC.md`", - "2. **简芁返回**: Agent 返回路埄+摘芁避免䞊䞋文溢出" + "1. **Specification Compliance**: Strictly follow `_shared/SKILL-DESIGN-SPEC.md`", + "2. **Brief Return**: Agent returns path+summary, avoiding context overflow" ]; - + if (config.execution_mode === 'sequential') { return [...common, - "3. **阶段隔犻**: 每䞪阶段独立可测", - "4. **铟匏蟓出**: 阶段产出䜜䞺䞋阶段蟓入" + "3. **Phase Isolation**: Each phase is independently testable", + "4. **Chained Output**: Phase output becomes next phase input" ].join('\n'); } else { return [...common, - "3. **状态驱劚**: 星匏状态管理劚态决策", - "4. **劚䜜独立**: 每䞪劚䜜无副䜜甚䟝赖" + "3. **State-driven**: Explicit state management, dynamic decision-making", + "4. **Action Independence**: Each action has no side-effect dependencies" ].join('\n'); } } function generateExecutionFlow(config) { if (config.execution_mode === 'sequential') { - return '```\n' + config.sequential_config.phases.map((p, i) => + return '```\n' + config.sequential_config.phases.map((p, i) => `├─ Phase ${i+1}: ${p.name}\n│ → Output: ${p.output || 'output.json'}` ).join('\n') + '\n```'; } else { @@ -216,9 +215,9 @@ function generateExecutionFlow(config) { function generateOutputStructure(config) { const base = `${config.output.location}/ ├── ${config.execution_mode === 'sequential' ? 'sections/' : 'state.json'}`; - + if (config.execution_mode === 'sequential') { - return base + '\n' + config.sequential_config.phases.map(p => + return base + '\n' + config.sequential_config.phases.map(p => `│ └── ${p.output || 'section-' + p.id + '.md'}` ).join('\n') + `\n└── ${config.output.filename_pattern}`; } else { @@ -230,22 +229,22 @@ function generateOutputStructure(config) { function generateReferenceTable(config) { const rows = []; - + if (config.execution_mode === 'sequential') { config.sequential_config.phases.forEach(p => { rows.push(`| [phases/${p.id}.md](phases/${p.id}.md) | ${p.name} |`); }); } else { - rows.push(`| [phases/orchestrator.md](phases/orchestrator.md) | 猖排噚 |`); - rows.push(`| [phases/state-schema.md](phases/state-schema.md) | 状态定义 |`); + rows.push(`| [phases/orchestrator.md](phases/orchestrator.md) | Orchestrator |`); + rows.push(`| [phases/state-schema.md](phases/state-schema.md) | State Definition |`); config.autonomous_config.actions.forEach(a => { rows.push(`| [phases/actions/${a.id}.md](phases/actions/${a.id}.md) | ${a.name} |`); }); } - - rows.push(`| [specs/${config.skill_name}-requirements.md](specs/${config.skill_name}-requirements.md) | 领域规范 |`); - rows.push(`| [specs/quality-standards.md](specs/quality-standards.md) | 莚量标准 |`); - + + rows.push(`| [specs/${config.skill_name}-requirements.md](specs/${config.skill_name}-requirements.md) | Domain Requirements |`); + rows.push(`| [specs/quality-standards.md](specs/quality-standards.md) | Quality Standards |`); + return `| Document | Purpose |\n|----------|---------||\n` + rows.join('\n'); } ``` diff --git a/.claude/skills/skill-generator/phases/03-phase-generation.md b/.claude/skills/skill-generator/phases/03-phase-generation.md index e8f2c5ca..a9ec7624 100644 --- a/.claude/skills/skill-generator/phases/03-phase-generation.md +++ b/.claude/skills/skill-generator/phases/03-phase-generation.md @@ -1,23 +1,22 @@ # Phase 3: Phase Generation -根据执行暡匏生成 Phase 文件包含声明匏工䜜流猖排和䞊䞋文策略支持。 +Generate Phase files based on execution mode, including declarative workflow orchestration and context strategy support. ## Objective -- Sequential 暡匏生成顺序 Phase 文件 + **声明匏猖排噚** -- Autonomous 暡匏生成猖排噚和劚䜜文件 -- 支持 **文件䞊䞋文** 和 **内存䞊䞋文** 䞀种策略 +- Sequential Mode: Generate sequential Phase files + **declarative orchestrator** +- Autonomous Mode: Generate orchestrator and action files +- Support **file-based context** and **memory context** strategies +## Context Strategy (P0 Enhancement) -## 䞊䞋文策略 (P0 增区) +Generate different context management code based on `config.context_strategy`: -根据 `config.context_strategy` 生成䞍同的䞊䞋文管理代码 - -| 策略 | 适甚场景 | 䌘点 | 猺点 | -|------|----------|------|------| -| `file` | 倍杂倚阶段任务 | 持久化、可调试、可恢倍 | IO 匀销 | -| `memory` | 简单线性任务 | 速床快 | 无法恢倍、调试困隟 | +| Strategy | Use Case | Advantages | Disadvantages | +|----------|----------|------------|---------------| +| `file` | Complex multi-phase tasks | Persistence, debuggable, recoverable | I/O overhead | +| `memory` | Simple linear tasks | Fast speed | Not recoverable, hard to debug | ```javascript const CONTEXT_STRATEGIES = { @@ -36,36 +35,36 @@ const CONTEXT_STRATEGIES = { ## Execution Steps -### Step 1: 读取配眮和暡板 +### Step 1: Load Configuration and Templates ```javascript const config = JSON.parse(Read(`${workDir}/skill-config.json`)); const skillDir = `.claude/skills/${config.skill_name}`; -const contextStrategy = config.context_strategy || 'file'; // 默讀文件策略 +const contextStrategy = config.context_strategy || 'file'; // Default file strategy -// 读取暡板 +// Load templates const skillRoot = '.claude/skills/skill-generator'; ``` -### Step 2: Sequential 暡匏 - 生成阶段文件 + 声明匏猖排噚 +### Step 2: Sequential Mode - Generate Phase Files + Declarative Orchestrator ```javascript if (config.execution_mode === 'sequential') { const phases = config.sequential_config.phases; - // ========== P0 增区: 生成声明匏猖排噚 ========== + // ========== P0 Enhancement: Generate declarative orchestrator ========== const workflowOrchestrator = generateSequentialOrchestrator(config, phases); Write(`${skillDir}/phases/_orchestrator.md`, workflowOrchestrator); - // ========== P0 增区: 生成工䜜流定义 ========== + // ========== P0 Enhancement: Generate workflow definition ========== const workflowDef = generateWorkflowDefinition(config, phases); Write(`${skillDir}/workflow.json`, JSON.stringify(workflowDef, null, 2)); - // ========== P0 增区: 生成 Phase 0 (区制规范研读) ========== + // ========== P0 Enhancement: Generate Phase 0 (mandatory specification study) ========== const phase0Content = generatePhase0Spec(config); Write(`${skillDir}/phases/00-spec-study.md`, phase0Content); - // ========== 生成甚户定义的各阶段文件 ========== + // ========== Generate user-defined phase files ========== for (let i = 0; i < phases.length; i++) { const phase = phases[i]; const prevPhase = i > 0 ? phases[i-1] : null; @@ -76,7 +75,7 @@ if (config.execution_mode === 'sequential') { phaseId: phase.id, phaseName: phase.name, phaseDescription: phase.description || `Execute ${phase.name}`, - input: prevPhase ? prevPhase.output : "phase 0 output", // Phase 0 䞺銖䞪蟓入源 + input: prevPhase ? prevPhase.output : "phase 0 output", // Phase 0 as first input source output: phase.output, nextPhase: nextPhase ? nextPhase.id : null, config: config, @@ -87,16 +86,16 @@ if (config.execution_mode === 'sequential') { } } -// ========== P0 增区: 声明匏工䜜流定义 ========== +// ========== P0 Enhancement: Declarative workflow definition ========== function generateWorkflowDefinition(config, phases) { - // ========== P0: 添加区制 Phase 0 ========== + // ========== P0: Add mandatory Phase 0 ========== const phase0 = { id: '00-spec-study', name: 'Specification Study', order: 0, input: null, output: 'spec-study-complete.flag', - description: '⚠ MANDATORY: Read all specification documents before execution', + description: 'MANDATORY: Read all specification documents before execution', parallel: false, condition: null, agent: { @@ -111,21 +110,21 @@ function generateWorkflowDefinition(config, phases) { execution_mode: "sequential", context_strategy: config.context_strategy || "file", - // ========== P0: Phase 0 眮于銖䜍 ========== + // ========== P0: Phase 0 placed first ========== phases_to_run: ['00-spec-study', ...phases.map(p => p.id)], - // ========== P0: Phase 0 + 甚户定义阶段 ========== + // ========== P0: Phase 0 + user-defined phases ========== phases: [ phase0, ...phases.map((p, i) => ({ id: p.id, name: p.name, order: i + 1, - input: i === 0 ? phase0.output : phases[i-1].output, // 第䞀䞪阶段䟝赖 Phase 0 + input: i === 0 ? phase0.output : phases[i-1].output, // First phase depends on Phase 0 output: p.output, parallel: p.parallel || false, condition: p.condition || null, - // Agent 配眮 (支持 LLM 集成) + // Agent configuration (supports LLM integration) agent: p.agent || (config.llm_integration?.enabled ? { type: "llm", tool: config.llm_integration.default_tool, @@ -139,7 +138,7 @@ function generateWorkflowDefinition(config, phases) { })) ], - // 终止条件 + // Termination conditions termination: { on_success: "all_phases_completed", on_error: "stop_and_report", @@ -148,52 +147,52 @@ function generateWorkflowDefinition(config, phases) { }; } -// ========== P0 增区: 声明匏猖排噚 ========== +// ========== P0 Enhancement: Declarative orchestrator ========== function generateSequentialOrchestrator(config, phases) { return `# Sequential Orchestrator -声明匏工䜜流猖排噚按 \`workflow.json\` 定义顺序执行阶段。 +Declarative workflow orchestrator that executes phases in order defined by \`workflow.json\`. -## 工䜜流定义 +## Workflow Definition \`\`\`javascript const workflow = JSON.parse(Read(\`\${skillDir}/workflow.json\`)); \`\`\` -## 猖排逻蟑 +## Orchestration Logic \`\`\`javascript async function runSequentialWorkflow(workDir) { const workflow = JSON.parse(Read(\`\${skillDir}/workflow.json\`)); const contextStrategy = workflow.context_strategy; - - // 初始化䞊䞋文 - ${config.context_strategy === 'file' ? + + // Initialize context + ${config.context_strategy === 'file' ? `Bash(\`mkdir -p "\${workDir}/context"\`);` : `const state = { context: {} };`} - - // 执行状态远螪 + + // Execution state tracking const execution = { started_at: new Date().toISOString(), phases_completed: [], current_phase: null, errors: [] }; - + Write(\`\${workDir}/execution-state.json\`, JSON.stringify(execution, null, 2)); - - // 按声明顺序执行阶段 + + // Execute phases in declared order for (const phaseId of workflow.phases_to_run) { const phaseConfig = workflow.phases.find(p => p.id === phaseId); - - // 曎新执行状态 + + // Update execution state execution.current_phase = phaseId; Write(\`\${workDir}/execution-state.json\`, JSON.stringify(execution, null, 2)); - + console.log(\`[Orchestrator] Executing: \${phaseId}\`); - + try { - // 检查条件执行 + // Check conditional execution if (phaseConfig.condition) { const shouldRun = evaluateCondition(phaseConfig.condition, execution); if (!shouldRun) { @@ -201,46 +200,46 @@ async function runSequentialWorkflow(workDir) { continue; } } - - // 执行阶段 + + // Execute phase const result = await executePhase(phaseId, phaseConfig, workDir); - - // 记圕完成 + + // Record completion execution.phases_completed.push({ id: phaseId, completed_at: new Date().toISOString(), output: phaseConfig.output }); - + } catch (error) { execution.errors.push({ phase: phaseId, message: error.message, timestamp: new Date().toISOString() }); - - // 错误倄理策略 + + // Error handling strategy if (workflow.termination.on_error === 'stop_and_report') { console.error(\`[Orchestrator] Failed at \${phaseId}: \${error.message}\`); break; } } - + Write(\`\${workDir}/execution-state.json\`, JSON.stringify(execution, null, 2)); } - - // 完成 + + // Complete execution.current_phase = null; execution.completed_at = new Date().toISOString(); Write(\`\${workDir}/execution-state.json\`, JSON.stringify(execution, null, 2)); - + return execution; } async function executePhase(phaseId, phaseConfig, workDir) { const phasePrompt = Read(\`\${skillDir}/phases/\${phaseId}.md\`); - - // 䜿甚 Task 调甚 Agent + + // Use Task to invoke Agent const result = await Task({ subagent_type: phaseConfig.agent?.type || 'universal-executor', run_in_background: phaseConfig.agent?.run_in_background || false, @@ -253,14 +252,14 @@ async function executePhase(phaseId, phaseConfig, workDir) { \${phasePrompt} \` }); - + return JSON.parse(result); } \`\`\` -## 阶段执行计划 +## Phase Execution Plan -**执行流皋**: +**Execution Flow**: \`\`\` START @@ -270,43 +269,43 @@ Phase 0: Specification Study ↓ Phase 1: ${phases[0]?.name || 'First Phase'} ↓ Output: ${phases[0]?.output || 'phase-1.json'} -${phases.slice(1).map((p, i) => ` ↓ -Phase ${i+2}: ${p.name} - ↓ Output: ${p.output}`).join('\n')} +${phases.slice(1).map((p, i) => \` ↓ +Phase \${i+2}: \${p.name} + ↓ Output: \${p.output}\`).join('\n')} ↓ COMPLETE \`\`\` -**阶段列衚**: +**Phase List**: | Order | Phase | Input | Output | Agent | |-------|-------|-------|--------|-------| | 0 | 00-spec-study | - | spec-study-complete.flag | universal-executor | ${phases.map((p, i) => - `| ${i+1} | ${p.id} | ${i === 0 ? 'spec-study-complete.flag' : phases[i-1].output} | ${p.output} | ${p.agent?.type || 'universal-executor'} |` + \`| \${i+1} | \${p.id} | \${i === 0 ? 'spec-study-complete.flag' : phases[i-1].output} | \${p.output} | \${p.agent?.type || 'universal-executor'} |\` ).join('\n')} -## 错误恢倍 +## Error Recovery \`\`\`javascript -// 从指定阶段恢倍执行 +// Resume execution from specified phase async function resumeFromPhase(phaseId, workDir) { const workflow = JSON.parse(Read(\`\${skillDir}/workflow.json\`)); const startIndex = workflow.phases_to_run.indexOf(phaseId); - + if (startIndex === -1) { throw new Error(\`Phase not found: \${phaseId}\`); } - - // 从指定阶段匀始执行 + + // Continue execution from specified phase const remainingPhases = workflow.phases_to_run.slice(startIndex); - // ...继续执行 + // ...continue execution } \`\`\` `; } -// 生成阶段文件增区䞊䞋文策略支持 +// Generate phase files (enhanced context strategy support) function generateSequentialPhase(params) { const contextCode = params.contextStrategy === 'file' ? { readPrev: `const prevOutput = JSON.parse(Read(\`\${workDir}/${params.input}\`));`, @@ -326,32 +325,32 @@ ${params.phaseDescription} ## Objective -- 䞻芁目标描述 -- 具䜓任务列衚 +- Primary objective description +- Specific task list ## Input -- 䟝赖: \`${params.input}\` -- 配眮: \`{workDir}/skill-config.json\` -- 䞊䞋文策略: \`${params.contextStrategy}\` +- Dependency: \`${params.input}\` +- Configuration: \`{workDir}/skill-config.json\` +- Context Strategy: \`${params.contextStrategy}\` ## Execution Steps -### Step 1: 读取蟓入 +### Step 1: Read Input \`\`\`javascript -// 䞊䞋文策略: ${params.contextStrategy} -${params.phaseNumber > 1 ? contextCode.readPrev : '// 銖阶段盎接从配眮匀始'} +// Context strategy: ${params.contextStrategy} +${params.phaseNumber > 1 ? contextCode.readPrev : '// First phase, start directly from config'} \`\`\` -### Step 2: 栞心倄理 +### Step 2: Core Processing \`\`\`javascript -// TODO: 实现栞心逻蟑 +// TODO: Implement core logic const result = { status: 'completed', data: { - // 倄理结果 + // Processing results }, metadata: { phase: '${params.phaseId}', @@ -360,17 +359,17 @@ const result = { }; \`\`\` -### Step 3: 蟓出结果 +### Step 3: Output Results \`\`\`javascript -// 写入阶段产出 (䞊䞋文策略: ${params.contextStrategy}) +// Write phase output (context strategy: ${params.contextStrategy}) ${contextCode.writeResult} -// 返回简芁信息给猖排噚 +// Return summary information to orchestrator return { status: 'completed', output_file: '${params.output}', - summary: '阶段 ${params.phaseNumber} 完成' + summary: 'Phase ${params.phaseNumber} completed' }; \`\`\` @@ -382,57 +381,57 @@ return { ## Quality Checklist -- [ ] 蟓入数据验证通过 -- [ ] 栞心逻蟑执行成功 -- [ ] 蟓出栌匏正确 -- [ ] 䞊䞋文正确保存 +- [ ] Input data validation passed +- [ ] Core logic executed successfully +- [ ] Output format correct +- [ ] Context saved correctly -${params.nextPhase ? - `## Next Phase\n\n→ [Phase ${params.phaseNumber + 1}: ${params.nextPhase}](${params.nextPhase}.md)` : - `## Completion\n\n歀䞺最后阶段蟓出最终产物。`} +${params.nextPhase ? + `## Next Phase\n\n→ [Phase ${params.phaseNumber + 1}: ${params.nextPhase}](${params.nextPhase}.md)` : + `## Completion\n\nThis is the final phase, produce final deliverables.`} `; } ``` -### Step 3: Autonomous 暡匏 - 生成猖排噚 (增区版) +### Step 3: Autonomous Mode - Generate Enhanced Orchestrator ```javascript if (config.execution_mode === 'autonomous' || config.execution_mode === 'hybrid') { const contextStrategy = config.context_strategy || 'file'; - - // 生成状态 Schema (增区文件策略支持) + + // Generate state schema (enhanced file strategy support) const stateSchema = generateStateSchema(config, contextStrategy); Write(`${skillDir}/phases/state-schema.md`, stateSchema); - - // 生成猖排噚 (增区版) + + // Generate enhanced orchestrator const orchestrator = generateEnhancedOrchestrator(config, contextStrategy); Write(`${skillDir}/phases/orchestrator.md`, orchestrator); - - // 生成劚䜜目圕 + + // Generate action catalog const actionCatalog = generateActionCatalog(config); Write(`${skillDir}/specs/action-catalog.md`, actionCatalog); - - // 生成劚䜜文件 + + // Generate action files for (const action of config.autonomous_config.actions) { const actionContent = generateEnhancedAction(action, config, contextStrategy); Write(`${skillDir}/phases/actions/${action.id}.md`, actionContent); } } -// 增区版猖排噚生成 +// Enhanced orchestrator generation function generateEnhancedOrchestrator(config, contextStrategy) { const actions = config.autonomous_config.actions; - + return `# Orchestrator (Enhanced) -增区版猖排噚支持声明匏劚䜜调床和文件䞊䞋文策略。 +Enhanced orchestrator supporting declarative action scheduling and file-based context strategy. -## 配眮 +## Configuration -- **䞊䞋文策略**: ${contextStrategy} -- **终止条件**: ${config.autonomous_config.termination_conditions?.join(', ') || 'task_completed'} +- **Context Strategy**: ${contextStrategy} +- **Termination Conditions**: ${config.autonomous_config.termination_conditions?.join(', ') || 'task_completed'} -## 声明匏劚䜜目圕 +## Declarative Action Catalog \`\`\`javascript const ACTION_CATALOG = ${JSON.stringify(actions.map(a => ({ @@ -444,87 +443,87 @@ const ACTION_CATALOG = ${JSON.stringify(actions.map(a => ({ })), null, 2)}; \`\`\` -## 䞊䞋文管理 (${contextStrategy} 策略) +## Context Management (${contextStrategy} Strategy) \`\`\`javascript const ContextManager = { - ${contextStrategy === 'file' ? ` - // 文件策略: 持久化到 .scratchpad + ${contextStrategy === 'file' ? \` + // File strategy: persist to .scratchpad init: (workDir) => { Bash(\`mkdir -p "\${workDir}/context"\`); Write(\`\${workDir}/state.json\`, JSON.stringify(initialState, null, 2)); }, - + readState: (workDir) => JSON.parse(Read(\`\${workDir}/state.json\`)), - + writeState: (workDir, state) => { state.updated_at = new Date().toISOString(); Write(\`\${workDir}/state.json\`, JSON.stringify(state, null, 2)); }, - + readContext: (workDir, key) => { try { return JSON.parse(Read(\`\${workDir}/context/\${key}.json\`)); } catch { return null; } }, - + writeContext: (workDir, key, data) => { Write(\`\${workDir}/context/\${key}.json\`, JSON.stringify(data, null, 2)); - }` : ` - // 内存策略: 仅圚运行时保持 + }\` : \` + // Memory strategy: maintain only at runtime state: null, context: {}, - + init: (workDir) => { ContextManager.state = { ...initialState }; ContextManager.context = {}; }, - + readState: () => ContextManager.state, - + writeState: (workDir, state) => { state.updated_at = new Date().toISOString(); ContextManager.state = state; }, - + readContext: (workDir, key) => ContextManager.context[key], - + writeContext: (workDir, key, data) => { ContextManager.context[key] = data; - }`} + }\`} }; \`\`\` -## 决策逻蟑 +## Decision Logic \`\`\`javascript function selectNextAction(state) { - // 1. 终止条件检查 -${config.autonomous_config.termination_conditions?.map(c => - ` if (${getTerminationCheck(c)}) return null;` + // 1. Check termination conditions +${config.autonomous_config.termination_conditions?.map(c => + \` if (\${getTerminationCheck(c)}) return null;\` ).join('\n') || ' if (state.status === "completed") return null;'} - - // 2. 错误限制检查 + + // 2. Check error limit if (state.error_count >= 3) return 'action-abort'; - - // 3. 按䌘先级选择满足前眮条件的劚䜜 + + // 3. Select actions that meet preconditions, sorted by priority const availableActions = ACTION_CATALOG .filter(a => checkPreconditions(a.preconditions, state)) .filter(a => !state.completed_actions.includes(a.id)) .sort((a, b) => b.priority - a.priority); - + if (availableActions.length > 0) { return availableActions[0].id; } - - // 4. 默讀完成 + + // 4. Default complete return 'action-complete'; } function checkPreconditions(conditions, state) { if (!conditions || conditions.length === 0) return true; return conditions.every(cond => { - // 支持倚种条件栌匏 + // Support multiple condition formats if (cond.includes('===')) { const [left, right] = cond.split('===').map(s => s.trim()); return eval(\`state.\${left}\`) === eval(right); @@ -534,46 +533,46 @@ function checkPreconditions(conditions, state) { } \`\`\` -## 执行埪环 (增区版) +## Execution Loop (Enhanced) \`\`\`javascript async function runOrchestrator(workDir) { console.log('=== Orchestrator Started ==='); console.log(\`Context Strategy: ${contextStrategy}\`); - - // 初始化 + + // Initialize ContextManager.init(workDir); - + let iteration = 0; const MAX_ITERATIONS = 100; - + while (iteration < MAX_ITERATIONS) { iteration++; - - // 1. 读取状态 + + // 1. Read state const state = ContextManager.readState(workDir); console.log(\`[Iteration \${iteration}] Status: \${state.status}, Completed: \${state.completed_actions.length}\`); - - // 2. 选择劚䜜 + + // 2. Select action const actionId = selectNextAction(state); - + if (!actionId) { console.log('=== All actions completed ==='); state.status = 'completed'; ContextManager.writeState(workDir, state); break; } - + console.log(\`[Iteration \${iteration}] Executing: \${actionId}\`); - - // 3. 曎新圓前劚䜜 + + // 3. Update current action state.current_action = actionId; ContextManager.writeState(workDir, state); - - // 4. 执行劚䜜 + + // 4. Execute action try { const actionPrompt = Read(\`\${skillDir}/phases/actions/\${actionId}.md\`); - + const result = await Task({ subagent_type: 'universal-executor', run_in_background: false, @@ -594,16 +593,16 @@ ${contextStrategy} Return JSON: { "status": "completed"|"failed", "stateUpdates": {...}, "summary": "..." } \` }); - + const actionResult = JSON.parse(result); - - // 5. 曎新状态 + + // 5. Update state state.completed_actions.push(actionId); state.current_action = null; Object.assign(state, actionResult.stateUpdates || {}); - + console.log(\`[Iteration \${iteration}] Completed: \${actionResult.summary || actionId}\`); - + } catch (error) { console.error(\`[Iteration \${iteration}] Error: \${error.message}\`); state.errors.push({ @@ -614,27 +613,27 @@ Return JSON: { "status": "completed"|"failed", "stateUpdates": {...}, "summary": state.error_count++; state.current_action = null; } - + ContextManager.writeState(workDir, state); } - + console.log('=== Orchestrator Finished ==='); return ContextManager.readState(workDir); } \`\`\` -## 劚䜜目圕 +## Action Catalog | Action | Priority | Preconditions | Effects | |--------|----------|---------------|---------| -${actions.map(a => - `| [${a.id}](actions/${a.id}.md) | ${a.priority || 0} | ${a.preconditions?.join(', ') || '-'} | ${a.effects?.join(', ') || '-'} |` +${actions.map(a => + \`| [${a.id}](actions/${a.id}.md) | ${a.priority || 0} | ${a.preconditions?.join(', ') || '-'} | ${a.effects?.join(', ') || '-'} |\` ).join('\n')} -## 调试䞎恢倍 +## Debugging and Recovery \`\`\`javascript -// 从特定状态恢倍 +// Resume from specific state async function resumeFromState(workDir) { const state = ContextManager.readState(workDir); console.log(\`Resuming from: \${state.current_action || 'start'}\`); @@ -642,7 +641,7 @@ async function resumeFromState(workDir) { return runOrchestrator(workDir); } -// 重试倱莥的劚䜜 +// Retry failed action async function retryFailedAction(workDir) { const state = ContextManager.readState(workDir); if (state.errors.length > 0) { @@ -657,62 +656,62 @@ async function retryFailedAction(workDir) { `; } -// 增区版劚䜜生成 +// Enhanced action generation function generateEnhancedAction(action, config, contextStrategy) { return `# Action: ${action.name} -${action.description || '执行 ' + action.name + ' 操䜜'} +${action.description || 'Execute ' + action.name + ' operation'} ## Purpose -${action.description || 'TODO: 描述歀劚䜜的目的'} +${action.description || 'TODO: Describe the purpose of this action'} ## Preconditions -${action.preconditions?.map(p => `- [ ] \`${p}\``).join('\n') || '- [ ] 无特殊前眮条件'} +${action.preconditions?.map(p => \`- [ ] \\\`${p}\\\`\`).join('\n') || '- [ ] No special preconditions'} -## Context Access (${contextStrategy} 策略) +## Context Access (${contextStrategy} Strategy) \`\`\`javascript -// 读取共享䞊䞋文 +// Read shared context ${contextStrategy === 'file' ? - `const sharedData = JSON.parse(Read(\`\${workDir}/context/shared.json\`));` : - `const sharedData = state.context.shared || {};`} + \`const sharedData = JSON.parse(Read(\\\`\${workDir}/context/shared.json\\\`));\` : + \`const sharedData = state.context.shared || {};\`} -// 写入共享䞊䞋文 +// Write shared context ${contextStrategy === 'file' ? - `Write(\`\${workDir}/context/shared.json\`, JSON.stringify(updatedData, null, 2));` : - `state.context.shared = updatedData;`} + \`Write(\\\`\${workDir}/context/shared.json\\\`, JSON.stringify(updatedData, null, 2));\` : + \`state.context.shared = updatedData;\`} \`\`\` ## Execution \`\`\`javascript async function execute(state, workDir) { - // 1. 读取必芁数据 + // 1. Read necessary data ${contextStrategy === 'file' ? - `const input = JSON.parse(Read(\`\${workDir}/context/input.json\`));` : - `const input = state.context.input || {};`} - - // 2. 执行栞心逻蟑 - // TODO: 实现劚䜜逻蟑 + \`const input = JSON.parse(Read(\\\`\${workDir}/context/input.json\\\`));\` : + \`const input = state.context.input || {};\`} + + // 2. Execute core logic + // TODO: Implement action logic const result = { - // 倄理结果 + // Processing results }; - - // 3. 保存结果 (${contextStrategy} 策略) + + // 3. Save results (${contextStrategy} strategy) ${contextStrategy === 'file' ? - `Write(\`\${workDir}/context/${action.id.replace(/-/g, '_')}_result.json\`, JSON.stringify(result, null, 2));` : - `// 结果通过 stateUpdates 返回`} - - // 4. 返回状态曎新 + \`Write(\\\`\${workDir}/context/${action.id.replace(/-/g, '_')}_result.json\\\`, JSON.stringify(result, null, 2));\` : + \`// Results returned via stateUpdates\`} + + // 4. Return state updates return { status: 'completed', stateUpdates: { completed_actions: [...state.completed_actions, '${action.id}'], - ${contextStrategy === 'memory' ? `context: { ...state.context, ${action.id.replace(/-/g, '_')}_result: result }` : '// 文件策略结果已保存到文件'} + ${contextStrategy === 'memory' ? \`context: { ...state.context, ${action.id.replace(/-/g, '_')}_result: result }\` : '// File strategy: results saved to file'} }, - summary: '${action.name} 完成' + summary: '${action.name} completed' }; } \`\`\` @@ -724,35 +723,35 @@ return { status: 'completed', stateUpdates: { completed_actions: [...state.completed_actions, '${action.id}'], -${action.effects?.map(e => ` // Effect: ${e}`).join('\n') || ' // 无额倖效果'} +${action.effects?.map(e => \` // Effect: ${e}\`).join('\n') || ' // No additional effects'} } }; \`\`\` ## Error Handling -| 错误类型 | 倄理方匏 | -|----------|----------| -| 数据验证倱莥 | 返回错误䞍曎新状态 | -| 执行匂垞 | 记圕错误增加 error_count | -| 䞊䞋文读取倱莥 | 䜿甚默讀倌或跳过 | +| Error Type | Handling | +|------------|----------| +| Data validation failure | Return error, do not update state | +| Execution exception | Log error, increment error_count | +| Context read failure | Use default value or skip | ## Next Actions (Hints) -- 成功: 由猖排噚根据 \`ACTION_CATALOG\` 䌘先级决定 -- 倱莥: 重试或 \`action-abort\` +- Success: Determined by orchestrator based on \`ACTION_CATALOG\` priority +- Failure: Retry or \`action-abort\` `; } -// 生成劚䜜目圕 +// Generate action catalog function generateActionCatalog(config) { const actions = config.autonomous_config.actions; - + return `# Action Catalog -${config.display_name} 的可甚劚䜜目圕声明匏。 +Available action catalog for ${config.display_name} (declarative). -## 劚䜜定义 +## Action Definition \`\`\`json ${JSON.stringify(actions.map(a => ({ @@ -765,7 +764,7 @@ ${JSON.stringify(actions.map(a => ({ })), null, 2)} \`\`\` -## 劚䜜䟝赖囟 +## Action Dependency Graph \`\`\`mermaid graph TD @@ -773,32 +772,32 @@ ${actions.map((a, i) => { const deps = a.preconditions?.filter(p => p.startsWith('completed_actions.includes')) .map(p => p.match(/'([^']+)'/)?.[1]) .filter(Boolean) || []; - + if (deps.length === 0 && i === 0) { - return ` START((Start)) --> ${a.id.replace(/-/g, '_')}[${a.name}]`; + return \` START((Start)) --> ${a.id.replace(/-/g, '_')}[${a.name}]\`; } else if (deps.length > 0) { - return deps.map(d => ` ${d.replace(/-/g, '_')} --> ${a.id.replace(/-/g, '_')}[${a.name}]`).join('\n'); + return deps.map(d => \` ${d.replace(/-/g, '_')} --> ${a.id.replace(/-/g, '_')}[${a.name}]\`).join('\n'); } return ''; }).filter(Boolean).join('\n')} ${actions[actions.length-1]?.id.replace(/-/g, '_') || 'last'} --> END((End)) \`\`\` -## 选择䌘先级 +## Selection Priority | Priority | Action | Description | |----------|--------|-------------| -${actions.sort((a, b) => (b.priority || 0) - (a.priority || 0)).map(a => - `| ${a.priority || 0} | ${a.id} | ${a.description || a.name} |` +${actions.sort((a, b) => (b.priority || 0) - (a.priority || 0)).map(a => + \`| ${a.priority || 0} | ${a.id} | ${a.description || a.name} |\` ).join('\n')} `; } ``` -### Step 4: 蟅助凜数 +### Step 4: Helper Functions ```javascript -// ========== P0: Phase 0 生成凜数 ========== +// ========== P0: Phase 0 generation function ========== function generatePhase0Spec(config) { const skillRoot = '.claude/skills/skill-generator'; const specsToRead = [ @@ -808,54 +807,54 @@ function generatePhase0Spec(config) { return `# Phase 0: Specification Study -⚠ **MANDATORY PREREQUISITE** - 歀阶段䞍可跳过 +MANDATORY PREREQUISITE - This phase cannot be skipped ## Objective -圚生成任䜕文件前完敎阅读所有规范文档理解 Skill 讟计标准。 +Complete reading of all specification documents before generating any files, understand Skill design standards. ## Why This Matters -**䞍研读规范 (❌)**: +**Without reading specifications ()**: \`\`\` -跳过规范 - ├─ ✗ 䞍笊合标准 - ├─ ✗ 结构混乱 - └─ ✗ 莚量问题 +Skip specifications + ├─ Does not meet standards + ├─ Messy structure + └─ Quality issues \`\`\` -**研读规范 (✅)**: +**With reading specifications ()**: \`\`\` -完敎研读 - ├─ ✓ 标准化蟓出 - ├─ ✓ 高莚量代码 - └─ ✓ 易于绎技 +Complete reading + ├─ Standardized output + ├─ High quality code + └─ Easy to maintain \`\`\` ## Required Reading -### P0 - 栞心讟计规范 +### P0 - Core Design Specification \`\`\`javascript -// 通甚讟计标准 (MUST READ) +// Universal design standards (MUST READ) const designSpec = Read('.claude/skills/_shared/SKILL-DESIGN-SPEC.md'); -// 关键内容检查点: +// Key content checkpoints: const checkpoints = { - structure: '目圕结构纊定', - naming: '呜名规范', - quality: '莚量标准', - output: '蟓出栌匏芁求' + structure: 'Directory structure conventions', + naming: 'Naming standards', + quality: 'Quality standards', + output: 'Output format requirements' }; \`\`\` -### P1 - 暡板文件 (生成前必读) +### P1 - Template Files (Must read before generation) \`\`\`javascript -// 根据执行暡匏加蜜对应暡板 +// Load corresponding templates based on execution mode const templates = { all: [ - 'templates/skill-md.md' // SKILL.md 入口文件暡板 + 'templates/skill-md.md' // SKILL.md entry file template ], sequential: [ 'templates/sequential-phase.md' @@ -871,24 +870,24 @@ const requiredTemplates = [...templates.all, ...templates[mode]]; requiredTemplates.forEach(template => { const content = Read(\`.claude/skills/skill-generator/\${template}\`); - // 理解暡板结构、变量䜍眮、生成规则 + // Understand template structure, variable positions, generation rules }); \`\`\` ## Execution \`\`\`javascript -// ========== 加蜜规范 ========== +// ========== Load specifications ========== const specs = []; -// 1. 讟计规范 (P0) +// 1. Design specification (P0) specs.push({ file: '../_shared/SKILL-DESIGN-SPEC.md', content: Read('.claude/skills/_shared/SKILL-DESIGN-SPEC.md'), priority: 'P0' }); -// 2. 暡板文件 (P1) +// 2. Template files (P1) const templateFiles = Glob('.claude/skills/skill-generator/templates/*.md'); templateFiles.forEach(file => { specs.push({ @@ -898,14 +897,14 @@ templateFiles.forEach(file => { }); }); -// ========== 内化规范 ========== -console.log('📖 Reading specifications...'); +// ========== Internalize specifications ========== +console.log('Reading specifications...'); specs.forEach(spec => { console.log(\` [\${spec.priority}] \${spec.file}\`); - // 理解内容无需生成文件仅内存倄理 + // Understand content (no need to generate files, only memory processing) }); -// ========== 生成完成标记 ========== +// ========== Generate completion flag ========== const result = { status: 'completed', specs_loaded: specs.length, @@ -917,27 +916,27 @@ Write(\`\${workDir}/spec-study-complete.flag\`, JSON.stringify(result, null, 2)) ## Output -- **标记文件**: \`spec-study-complete.flag\` (证明已完成阅读) -- **副䜜甚**: 内化规范知识后续阶段遵埪标准 +- **Flag File**: \`spec-study-complete.flag\` (proves reading completion) +- **Side Effect**: Internalize specification knowledge, subsequent phases follow standards ## Success Criteria -✅ **通过标准**: -- [ ] 已阅读 SKILL-DESIGN-SPEC.md -- [ ] 已阅读执行暡匏对应的暡板文件 -- [ ] 理解目圕结构纊定 -- [ ] 理解呜名规范 -- [ ] 理解莚量标准 +Completion criteria: +- [ ] Read SKILL-DESIGN-SPEC.md +- [ ] Read execution mode corresponding template files +- [ ] Understand directory structure conventions +- [ ] Understand naming standards +- [ ] Understand quality standards ## Next Phase → [Phase 1: Requirements Discovery](01-requirements-discovery.md) -**关键**: 只有完成规范研读后Phase 1 才胜正确收集需求并生成笊合标准的配眮。 +**Key**: Only after completing specification study can Phase 1 correctly collect requirements and generate specification-compliant configurations. `; } -// ========== 其他蟅助凜数 ========== +// ========== Other helper functions ========== function toPascalCase(str) { return str.split('-').map(s => s.charAt(0).toUpperCase() + s.slice(1)).join(''); } @@ -967,3 +966,11 @@ function getPreconditionCheck(action) { ``` +## Next Phase + +→ [Phase 4: Specifications & Templates](04-specs-templates.md) + +**Data Flow to Phase 4**: +- All phase/action files generated in phases/ directory +- Complete skill directory structure ready for specs and templates generation +- skill-config.json for reference in documentation generation diff --git a/.claude/skills/skill-generator/phases/04-specs-templates.md b/.claude/skills/skill-generator/phases/04-specs-templates.md index 6870bed0..876ac616 100644 --- a/.claude/skills/skill-generator/phases/04-specs-templates.md +++ b/.claude/skills/skill-generator/phases/04-specs-templates.md @@ -40,7 +40,7 @@ Generate comprehensive specifications and templates: ```markdown # {display_name} Requirements - When to Use (phase/action reference table) -- Domain Requirements (功胜芁求, 蟓出芁求, 莚量芁求) +- Domain Requirements (Functional requirements, Output requirements, Quality requirements) - Validation Function (JavaScript code) - Error Handling (recovery strategies) ``` @@ -57,10 +57,10 @@ Generate comprehensive specifications and templates: **Agent Base** (`templates/agent-base.md`): ```markdown # Agent Base Template -- 通甹 Prompt 结构 (ROLE, PROJECT CONTEXT, TASK, CONSTRAINTS, OUTPUT_FORMAT, QUALITY_CHECKLIST) -- 变量诎明 (workDir, output_path) -- 返回栌匏 (AgentReturn interface) -- 角色定义参考 (phase/action specific agents) +- Universal Prompt Structure (ROLE, PROJECT CONTEXT, TASK, CONSTRAINTS, OUTPUT_FORMAT, QUALITY_CHECKLIST) +- Variable Description (workDir, output_path) +- Return Format (AgentReturn interface) +- Role Definition Reference (phase/action specific agents) ``` **Action Catalog** (`specs/action-catalog.md`, Autonomous/Hybrid only): @@ -114,39 +114,39 @@ ${config.execution_mode === 'sequential' ? config.sequential_config.phases.map((p, i) => `| Phase ${i+1} | ${p.name} | ${p.id}.md |` ).join('\n') : - `| Orchestrator | 劚䜜选择 | orchestrator.md | -| Actions | 劚䜜执行 | actions/*.md |`} + `| Orchestrator | Action selection | orchestrator.md | +| Actions | Action execution | actions/*.md |`} --- ## Domain Requirements -### 功胜芁求 +### Functional Requirements -- [ ] 芁求1: TODO -- [ ] 芁求2: TODO -- [ ] 芁求3: TODO +- [ ] Requirement 1: TODO +- [ ] Requirement 2: TODO +- [ ] Requirement 3: TODO -### 蟓出芁求 +### Output Requirements -- [ ] 栌匏: ${config.output.format} -- [ ] 䜍眮: ${config.output.location} -- [ ] 呜名: ${config.output.filename_pattern} +- [ ] Format: ${config.output.format} +- [ ] Location: ${config.output.location} +- [ ] Naming: ${config.output.filename_pattern} -### 莚量芁求 +### Quality Requirements -- [ ] 完敎性: 所有必需内容存圚 -- [ ] 䞀臎性: 术语和栌匏统䞀 -- [ ] 准确性: 内容基于实际分析 +- [ ] Completeness: All necessary content exists +- [ ] Consistency: Terminology and format unified +- [ ] Accuracy: Content based on actual analysis ## Validation Function \`\`\`javascript function validate${toPascalCase(config.skill_name)}(output) { const checks = [ - // TODO: 添加验证规则 - { name: "栌匏正确", pass: output.format === "${config.output.format}" }, - { name: "内容完敎", pass: output.content?.length > 0 } + // TODO: Add validation rules + { name: "Format correct", pass: output.format === "${config.output.format}" }, + { name: "Content complete", pass: output.content?.length > 0 } ]; return { @@ -161,9 +161,9 @@ function validate${toPascalCase(config.skill_name)}(output) { | Error | Recovery | |-------|----------| -| 蟓入数据猺倱 | 返回明确错误信息 | -| 倄理超时 | 猩小范囎重试 | -| 蟓出验证倱莥 | 记圕问题人工审栞 | +| Missing input data | Return clear error message | +| Processing timeout | Reduce scope, retry | +| Output validation failure | Log issue, manual review | `; Write(`${skillDir}/specs/${config.skill_name}-requirements.md`, domainRequirements); @@ -171,68 +171,68 @@ Write(`${skillDir}/specs/${config.skill_name}-requirements.md`, domainRequiremen // Step 2: Generate quality standards const qualityStandards = `# Quality Standards -${config.display_name} 的莚量评䌰标准。 +Quality assessment standards for ${config.display_name}. ## Quality Dimensions -### 1. Completeness (完敎性) - 25% +### 1. Completeness (Completeness) - 25% -| 芁求 | 权重 | 检查方匏 | -|------|------|----------| -| 所有必需蟓出存圚 | 10 | 文件检查 | -| 内容芆盖完敎 | 10 | 内容分析 | -| 无占䜍笊残留 | 5 | 文本搜玢 | +| Requirement | Weight | Validation Method | +|------------|--------|-----------------| +| All necessary outputs exist | 10 | File check | +| Content coverage complete | 10 | Content analysis | +| No placeholder remnants | 5 | Text search | -### 2. Consistency (䞀臎性) - 25% +### 2. Consistency (Consistency) - 25% -| 方面 | 检查 | -|------|------| -| 术语 | 同䞀抂念䜿甚盞同术语 | -| 栌匏 | 标题层级、代码块栌匏䞀臎 | -| 风栌 | 语气和衚蟟方匏统䞀 | +| Aspect | Check | +|--------|-------| +| Terminology | Use same term for same concept | +| Format | Title levels, code block format consistent | +| Style | Tone and expression unified | -### 3. Accuracy (准确性) - 25% +### 3. Accuracy (Accuracy) - 25% -| 芁求 | 诎明 | -|------|------| -| 数据正确 | 匕甚和数据无错误 | -| 逻蟑正确 | 流皋和关系描述准确 | -| 代码正确 | 代码瀺䟋可运行 | +| Requirement | Description | +|-------------|------------| +| Data correct | References and data error-free | +| Logic correct | Process and relationship descriptions accurate | +| Code correct | Code examples runnable | -### 4. Usability (可甚性) - 25% +### 4. Usability (Usability) - 25% -| 指标 | 目标 | -|------|------| -| 可读性 | 结构枅晰易于理解 | -| 可富航 | 目圕和铟接正确 | -| 可操䜜 | 步骀明确可执行 | +| Metric | Goal | +|--------|------| +| Readability | Clear structure, easy to understand | +| Navigability | Table of contents and links correct | +| Operability | Steps clear, executable | ## Quality Gates | Gate | Threshold | Action | |------|-----------|--------| -| Pass | ≥ 80% | 蟓出最终产物 | -| Review | 60-79% | 倄理譊告后继续 | -| Fail | < 60% | 必须修倍 | +| Pass | >= 80% | Output final deliverables | +| Review | 60-79% | Process warnings then continue | +| Fail | < 60% | Must fix | ## Issue Classification ### Errors (Must Fix) -- 必需蟓出猺倱 -- 数据错误 -- 代码䞍可运行 +- Necessary output missing +- Data error +- Code not runnable ### Warnings (Should Fix) -- 栌匏䞍䞀臎 -- 内容深床䞍足 -- 猺少瀺䟋 +- Format inconsistency +- Content depth insufficient +- Missing examples ### Info (Nice to Have) -- 䌘化建议 -- 增区机䌚 +- Optimization suggestions +- Enhancement opportunities ## Automated Checks @@ -267,44 +267,44 @@ Write(`${skillDir}/specs/quality-standards.md`, qualityStandards); // Step 3: Generate agent base template const agentBase = `# Agent Base Template -${config.display_name} 的 Agent 基础暡板。 +Agent base template for ${config.display_name}. -## 通甹 Prompt 结构 +## Universal Prompt Structure \`\`\` -[ROLE] 䜠是{角色}䞓泚于{职莣}。 +[ROLE] You are {role}, focused on {responsibility}. [PROJECT CONTEXT] Skill: ${config.skill_name} -目标: ${config.description} +Objective: ${config.description} [TASK] -{任务描述} -- 蟓出: {output_path} -- 栌匏: ${config.output.format} +{task description} +- Output: {output_path} +- Format: ${config.output.format} [CONSTRAINTS] -- 纊束1 -- 纊束2 +- Constraint 1 +- Constraint 2 [OUTPUT_FORMAT] -1. 执行任务 -2. 返回 JSON 简芁信息 +1. Execute task +2. Return JSON summary information [QUALITY_CHECKLIST] -- [ ] 蟓出栌匏正确 -- [ ] 内容完敎无遗挏 -- [ ] 无占䜍笊残留 +- [ ] Output format correct +- [ ] Content complete without omission +- [ ] No placeholder remnants \`\`\` -## 变量诎明 +## Variable Description -| 变量 | 来源 | 瀺䟋 | -|------|------|------| -| {workDir} | 运行时 | .workflow/.scratchpad/${config.skill_name}-xxx | -| {output_path} | 配眮 | ${config.output.location}/${config.output.filename_pattern} | +| Variable | Source | Example | +|----------|--------|---------| +| {workDir} | Runtime | .workflow/.scratchpad/${config.skill_name}-xxx | +| {output_path} | Configuration | ${config.output.location}/${config.output.filename_pattern} | -## 返回栌匏 +## Return Format \`\`\`typescript interface AgentReturn { @@ -318,14 +318,14 @@ interface AgentReturn { } \`\`\` -## 角色定义参考 +## Role Definition Reference ${config.execution_mode === 'sequential' ? config.sequential_config.phases.map((p, i) => - `- **Phase ${i+1} Agent**: ${p.name} 䞓家` + `- **Phase ${i+1} Agent**: ${p.name} Expert` ).join('\n') : config.autonomous_config.actions.map(a => - `- **${a.name} Agent**: ${a.description || a.name + ' 执行者'}` + `- **${a.name} Agent**: ${a.description || a.name + ' Executor'}` ).join('\n')} `; @@ -335,7 +335,7 @@ Write(`${skillDir}/templates/agent-base.md`, agentBase); if (config.execution_mode === 'autonomous' || config.execution_mode === 'hybrid') { const actionCatalog = `# Action Catalog -${config.display_name} 的可甚劚䜜目圕。 +Available action catalog for ${config.display_name}. ## Available Actions @@ -350,9 +350,9 @@ ${config.autonomous_config.actions.map(a => \`\`\`mermaid graph TD ${config.autonomous_config.actions.map((a, i, arr) => { - if (i === 0) return ` ${a.id.replace(/-/g, '_')}[${a.name}]`; + if (i === 0) return \` ${a.id.replace(/-/g, '_')}[${a.name}]\`; const prev = arr[i-1]; - return ` ${prev.id.replace(/-/g, '_')} --> ${a.id.replace(/-/g, '_')}[${a.name}]`; + return \` ${prev.id.replace(/-/g, '_')} --> ${a.id.replace(/-/g, '_')}[${a.name}]\`; }).join('\n')} \`\`\` @@ -369,10 +369,10 @@ ${config.autonomous_config.actions.slice(1).map(a => ## Selection Priority -圓倚䞪劚䜜的前眮条件郜满足时按以䞋䌘先级选择 +When multiple actions' preconditions are met, select based on the following priority: ${config.autonomous_config.actions.map((a, i) => - `${i + 1}. \`${a.id}\` - ${a.name}` + \`${i + 1}. \\\`${a.id}\\\` - ${a.name}\` ).join('\n')} `; diff --git a/.claude/skills/skill-generator/phases/05-validation.md b/.claude/skills/skill-generator/phases/05-validation.md index 2d90e1ef..8462dd0b 100644 --- a/.claude/skills/skill-generator/phases/05-validation.md +++ b/.claude/skills/skill-generator/phases/05-validation.md @@ -246,16 +246,16 @@ function collectIssues(fileResults, contentResults) { const issues = []; fileResults.filter(f => !f.exists).forEach(f => { - issues.push({ type: 'ERROR', message: `文件猺倱: ${f.file}` }); + issues.push({ type: 'ERROR', message: `Missing file: ${f.file}` }); }); fileResults.filter(f => f.hasTodo).forEach(f => { - issues.push({ type: 'WARNING', message: `包含 TODO: ${f.file}` }); + issues.push({ type: 'WARNING', message: `Contains TODO: ${f.file}` }); }); contentResults.forEach(c => { c.checks.filter(ch => !ch.pass).forEach(ch => { - issues.push({ type: 'WARNING', message: `${c.file}: 猺少 ${ch.name}` }); + issues.push({ type: 'WARNING', message: `${c.file}: Missing ${ch.name}` }); }); }); @@ -266,12 +266,12 @@ function generateRecommendations(fileResults, contentResults) { const recommendations = []; if (fileResults.some(f => f.hasTodo)) { - recommendations.push('替换所有 TODO 占䜍笊䞺实际内容'); + recommendations.push('Replace all TODO placeholders with actual content'); } contentResults.forEach(c => { if (c.checks.some(ch => !ch.pass)) { - recommendations.push(`完善 ${c.file} 的结构`); + recommendations.push(`Improve structure of ${c.file}`); } }); @@ -285,81 +285,81 @@ ${config.description} ## Quick Start -### 觊发词 +### Trigger Words ${config.triggers.map(t => `- "${t}"`).join('\n')} -### 执行暡匏 +### Execution Mode -**${config.execution_mode === 'sequential' ? 'Sequential (顺序)' : 'Autonomous (自䞻)'}** +**${config.execution_mode === 'sequential' ? 'Sequential (Sequential)' : 'Autonomous (Autonomous)'}** ${config.execution_mode === 'sequential' ? - `阶段按固定顺序执行\n${config.sequential_config.phases.map((p, i) => - `${i + 1}. ${p.name}` - ).join('\n')}` : - `劚䜜由猖排噚劚态选择\n${config.autonomous_config.actions.map(a => - `- ${a.name}: ${a.description || ''}` - ).join('\n')}`} + \`Phases execute in fixed order:\n\${config.sequential_config.phases.map((p, i) => + \`\${i + 1}. \${p.name}\` + ).join('\n')}\` : + \`Actions selected dynamically by orchestrator:\n\${config.autonomous_config.actions.map(a => + \`- \${a.name}: \${a.description || ''}\` + ).join('\n')}\`} ## Usage \`\`\` -# 盎接觊发 -甚户: ${config.triggers[0]} +# Direct trigger +User: ${config.triggers[0]} -# 或䜿甚 Skill 名称 -甚户: /skill ${config.skill_name} +# Or use Skill name +User: /skill ${config.skill_name} \`\`\` ## Output -- **栌匏**: ${config.output.format} -- **䜍眮**: \`${config.output.location}\` -- **文件名**: \`${config.output.filename_pattern}\` +- **Format**: ${config.output.format} +- **Location**: \`${config.output.location}\` +- **Filename**: \`${config.output.filename_pattern}\` ## Directory Structure \`\`\` .claude/skills/${config.skill_name}/ -├── SKILL.md # 入口文件 -├── phases/ # 执行阶段 +├── SKILL.md # Entry file +├── phases/ # Execution phases ${config.execution_mode === 'sequential' ? - config.sequential_config.phases.map(p => `│ ├── ${p.id}.md`).join('\n') : - `│ ├── orchestrator.md + config.sequential_config.phases.map(p => \`│ ├── \${p.id}.md\`).join('\n') : + \`│ ├── orchestrator.md │ ├── state-schema.md │ └── actions/ -${config.autonomous_config.actions.map(a => `│ ├── ${a.id}.md`).join('\n')}`} -├── specs/ # 规范文件 +\${config.autonomous_config.actions.map(a => \`│ ├── \${a.id}.md\`).join('\n')}\`} +├── specs/ # Specification files │ ├── ${config.skill_name}-requirements.md │ ├── quality-standards.md ${config.execution_mode === 'autonomous' ? '│ └── action-catalog.md' : ''} -└── templates/ # 暡板文件 +└── templates/ # Template files └── agent-base.md \`\`\` ## Customization -### 修改执行逻蟑 +### Modify Execution Logic -猖蟑 \`phases/\` 目圕䞋的阶段文件。 +Edit phase files in the \`phases/\` directory. -### 调敎莚量标准 +### Adjust Quality Standards -猖蟑 \`specs/quality-standards.md\`。 +Edit \`specs/quality-standards.md\`. -### 添加新${config.execution_mode === 'sequential' ? '阶段' : '劚䜜'} +### Add New ${config.execution_mode === 'sequential' ? 'Phase' : 'Action'} ${config.execution_mode === 'sequential' ? - `1. 圚 \`phases/\` 创建新的阶段文件 (劂 \`03.5-new-step.md\`) -2. 曎新 SKILL.md 的执行流皋` : - `1. 圚 \`phases/actions/\` 创建新的劚䜜文件 -2. 曎新 \`specs/action-catalog.md\` -3. 圚 \`phases/orchestrator.md\` 添加选择逻蟑`} + \`1. Create new phase file in \`phases/\` (e.g., \`03.5-new-step.md\`) +2. Update execution flow in SKILL.md\` : + \`1. Create new action file in \`phases/actions/\` +2. Update \`specs/action-catalog.md\` +3. Add selection logic in \`phases/orchestrator.md\`\`} ## Related Documents -- [讟计规范](../_shared/SKILL-DESIGN-SPEC.md) -- [执行暡匏规范](specs/../../../skill-generator/specs/execution-modes.md) +- [Design Specification](../_shared/SKILL-DESIGN-SPEC.md) +- [Execution Modes Specification](specs/../../../skill-generator/specs/execution-modes.md) --- @@ -383,20 +383,20 @@ const finalResult = { validation: report.summary, next_steps: [ - '1. 审阅生成的文件结构', - '2. 替换 TODO 占䜍笊', - '3. 根据实际需求调敎阶段逻蟑', - '4. 测试 Skill 执行流皋', - '5. 曎新觊发词和描述' + '1. Review generated file structure', + '2. Replace TODO placeholders', + '3. Adjust phase logic based on actual requirements', + '4. Test Skill execution flow', + '5. Update trigger words and descriptions' ] }; -console.log('=== Skill 生成完成 ==='); -console.log(`路埄: ${skillDir}`); -console.log(`暡匏: ${config.execution_mode}`); -console.log(`状态: ${report.summary.status}`); +console.log('=== Skill Generation Complete ==='); +console.log(\`Path: \${skillDir}\`); +console.log(\`Mode: \${config.execution_mode}\`); +console.log(\`Status: \${report.summary.status}\`); console.log(''); -console.log('䞋䞀步:'); +console.log('Next Steps:'); finalResult.next_steps.forEach(s => console.log(s)); ``` diff --git a/.claude/skills/skill-generator/specs/cli-integration.md b/.claude/skills/skill-generator/specs/cli-integration.md index d002c591..6d57954f 100644 --- a/.claude/skills/skill-generator/specs/cli-integration.md +++ b/.claude/skills/skill-generator/specs/cli-integration.md @@ -1,111 +1,111 @@ # CLI Integration Specification -CCW CLI 集成规范定义 Skill 䞭劂䜕正确调甚倖郚 CLI 工具。 +CCW CLI integration specification that defines how to properly call external CLI tools within Skills. --- -## 执行暡匏 +## Execution Modes -### 1. 同步执行 (Blocking) +### 1. Synchronous Execution (Blocking) -适甚于需芁立即获取结果的场景。 +Suitable for scenarios that need immediate results. ```javascript -// Agent 调甚 - 同步 +// Agent call - synchronous const result = Task({ subagent_type: 'universal-executor', - prompt: '执行任务...', - run_in_background: false // 关键: 同步执行 + prompt: 'Execute task...', + run_in_background: false // Key: synchronous execution }); -// 结果立即可甚 +// Result immediately available console.log(result); ``` -### 2. 匂步执行 (Background) +### 2. Asynchronous Execution (Background) -适甚于长时闎运行的 CLI 呜什。 +Suitable for long-running CLI commands. ```javascript -// CLI 调甚 - 匂步 +// CLI call - asynchronous const task = Bash({ command: 'ccw cli -p "..." --tool gemini --mode analysis', - run_in_background: true // 关键: 后台执行 + run_in_background: true // Key: background execution }); -// 立即返回䞍等埅结果 -// task.task_id 可甚于后续查询 +// Returns immediately without waiting for result +// task.task_id available for later queries ``` --- -## CCW CLI 调甚规范 +## CCW CLI Call Specification -### 基础呜什结构 +### Basic Command Structure ```bash ccw cli -p "" --tool --mode ``` -### 参数诎明 +### Parameter Description -| 参数 | 必需 | 诎明 | -|------|------|------| -| `-p ""` | ✓ | 提瀺词䜿甚双匕号 | -| `--tool ` | ✓ | 工具选择: gemini, qwen, codex | -| `--mode ` | ✓ | 执行暡匏: analysis, write | -| `--cd ` | - | 工䜜目圕 | -| `--includeDirs ` | - | 包含额倖目圕逗号分隔 | -| `--resume [id]` | - | 恢倍䌚话 | +| Parameter | Required | Description | +|-----------|----------|-------------| +| `-p ""` | Yes | Prompt text (use double quotes) | +| `--tool ` | Yes | Tool selection: gemini, qwen, codex | +| `--mode ` | Yes | Execution mode: analysis, write | +| `--cd ` | - | Working directory | +| `--includeDirs ` | - | Additional directories (comma-separated) | +| `--resume [id]` | - | Resume session | -### 暡匏选择 +### Mode Selection ``` -┌─ 分析/文档任务? -│ └─→ --mode analysis (只读) -│ -└─ 实现/修改任务? - └─→ --mode write (读写) +- Analysis/Documentation tasks? + → --mode analysis (read-only) + +- Implementation/Modification tasks? + → --mode write (read-write) ``` --- -## Agent 类型䞎选择 +## Agent Types and Selection ### universal-executor -通甚执行噚最垞甚的 Agent 类型。 +General-purpose executor, the most commonly used agent type. ```javascript Task({ subagent_type: 'universal-executor', prompt: ` -执行任务: -1. 读取配眮文件 -2. 分析䟝赖关系 -3. 生成报告到 ${outputPath} +Execute task: +1. Read configuration file +2. Analyze dependencies +3. Generate report to ${outputPath} `, run_in_background: false }); ``` -**适甚场景**: -- 倚步骀任务执行 -- 文件操䜜读/写/猖蟑 -- 需芁工具调甚的任务 +**Applicable Scenarios**: +- Multi-step task execution +- File operations (read/write/edit) +- Tasks that require tool invocation ### Explore -代码探玢 Agent快速理解代码库。 +Code exploration agent for quick codebase understanding. ```javascript Task({ subagent_type: 'Explore', prompt: ` -探玢 src/ 目圕: -- 识别䞻芁暡块 -- 理解目圕结构 -- 扟到入口点 +Explore src/ directory: +- Identify main modules +- Understand directory structure +- Find entry points Thoroughness: medium `, @@ -113,104 +113,104 @@ Thoroughness: medium }); ``` -**适甚场景**: -- 代码库探玢 -- 文件发现 -- 结构理解 +**Applicable Scenarios**: +- Codebase exploration +- File discovery +- Structure understanding ### cli-explore-agent -深床代码分析 Agent。 +Deep code analysis agent. ```javascript Task({ subagent_type: 'cli-explore-agent', prompt: ` -深床分析 src/auth/ 暡块: -- 讀证流皋 -- 䌚话管理 -- 安党机制 +Deep analysis of src/auth/ module: +- Authentication flow +- Session management +- Security mechanisms `, run_in_background: false }); ``` -**适甚场景**: -- 深床代码理解 -- 讟计暡匏识别 -- 倍杂逻蟑分析 +**Applicable Scenarios**: +- Deep code understanding +- Design pattern identification +- Complex logic analysis --- -## 䌚话管理 +## Session Management -### 䌚话恢倍 +### Session Recovery ```javascript -// 保存䌚话 ID +// Save session ID const session = Bash({ - command: 'ccw cli -p "初始分析..." --tool gemini --mode analysis', + command: 'ccw cli -p "Initial analysis..." --tool gemini --mode analysis', run_in_background: true }); -// 后续恢倍 +// Resume later const continuation = Bash({ - command: `ccw cli -p "继续分析..." --tool gemini --mode analysis --resume ${session.id}`, + command: `ccw cli -p "Continue analysis..." --tool gemini --mode analysis --resume ${session.id}`, run_in_background: true }); ``` -### 倚䌚话合并 +### Multi-Session Merge ```javascript -// 合并倚䞪䌚话的䞊䞋文 +// Merge context from multiple sessions const merged = Bash({ - command: `ccw cli -p "汇总分析..." --tool gemini --mode analysis --resume ${id1},${id2}`, + command: `ccw cli -p "Aggregate analysis..." --tool gemini --mode analysis --resume ${id1},${id2}`, run_in_background: true }); ``` --- -## Skill 侭的 CLI 集成暡匏 +## CLI Integration Patterns in Skills -### 暡匏 1: 单次调甚 +### Pattern 1: Single Call -简单任务䞀次调甚完成。 +Simple tasks completed in one call. ```javascript -// Phase 执行 +// Phase execution async function executePhase(context) { const result = Bash({ command: `ccw cli -p " -PURPOSE: 分析项目结构 -TASK: 识别暡块、䟝赖、入口点 +PURPOSE: Analyze project structure +TASK: Identify modules, dependencies, entry points MODE: analysis CONTEXT: @src/**/* -EXPECTED: JSON 栌匏的结构报告 +EXPECTED: JSON format structure report " --tool gemini --mode analysis --cd ${context.projectRoot}`, run_in_background: true, timeout: 600000 }); - // 等埅完成 + // Wait for completion return await waitForCompletion(result.task_id); } ``` -### 暡匏 2: 铟匏调甚 +### Pattern 2: Chained Calls -倚步骀任务每步䟝赖前䞀步结果。 +Multi-step tasks where each step depends on previous results. ```javascript async function executeChain(context) { - // Step 1: 收集 + // Step 1: Collect const collectId = await runCLI('collect', context); - // Step 2: 分析 (䟝赖 Step 1) + // Step 2: Analyze (depends on Step 1) const analyzeId = await runCLI('analyze', context, `--resume ${collectId}`); - // Step 3: 生成 (䟝赖 Step 2) + // Step 3: Generate (depends on Step 2) const generateId = await runCLI('generate', context, `--resume ${analyzeId}`); return generateId; @@ -218,9 +218,9 @@ async function executeChain(context) { async function runCLI(step, context, resumeFlag = '') { const prompts = { - collect: 'PURPOSE: 收集代码文件...', - analyze: 'PURPOSE: 分析代码暡匏...', - generate: 'PURPOSE: 生成文档...' + collect: 'PURPOSE: Collect code files...', + analyze: 'PURPOSE: Analyze code patterns...', + generate: 'PURPOSE: Generate documentation...' }; const result = Bash({ @@ -232,9 +232,9 @@ async function runCLI(step, context, resumeFlag = '') { } ``` -### 暡匏 3: 并行调甚 +### Pattern 3: Parallel Calls -独立任务并行执行。 +Independent tasks executed in parallel. ```javascript async function executeParallel(context) { @@ -244,15 +244,15 @@ async function executeParallel(context) { { type: 'patterns', tool: 'qwen' } ]; - // 并行启劚 + // Start tasks in parallel const taskIds = tasks.map(task => Bash({ - command: `ccw cli -p "分析 ${task.type}..." --tool ${task.tool} --mode analysis`, + command: `ccw cli -p "Analyze ${task.type}..." --tool ${task.tool} --mode analysis`, run_in_background: true }).task_id ); - // 等埅党郚完成 + // Wait for all to complete const results = await Promise.all( taskIds.map(id => waitForCompletion(id)) ); @@ -261,9 +261,9 @@ async function executeParallel(context) { } ``` -### 暡匏 4: Fallback 铟 +### Pattern 4: Fallback Chain -工具倱莥时自劚切换。 +Automatically switch tools on failure. ```javascript async function executeWithFallback(context) { @@ -299,9 +299,9 @@ async function runWithTool(tool, context) { --- -## 提瀺词暡板集成 +## Prompt Template Integration -### 匕甚协议暡板 +### Reference Protocol Templates ```bash # Analysis mode - use --rule to auto-load protocol and template (appended to prompt) @@ -315,7 +315,7 @@ CONSTRAINTS: ... ..." --tool codex --mode write --rule development-feature ``` -### 劚态暡板构建 +### Dynamic Template Building ```javascript function buildPrompt(config) { @@ -334,21 +334,21 @@ CONSTRAINTS: ${constraints || ''} --- -## 超时配眮 +## Timeout Configuration -### 掚荐超时倌 +### Recommended Timeout Values -| 任务类型 | 超时 (ms) | 诎明 | -|---------|----------|------| -| 快速分析 | 300000 | 5 分钟 | -| 标准分析 | 600000 | 10 分钟 | -| 深床分析 | 1200000 | 20 分钟 | -| 代码生成 | 1800000 | 30 分钟 | -| 倍杂任务 | 3600000 | 60 分钟 | +| Task Type | Timeout (ms) | Description | +|-----------|--------------|-------------| +| Quick analysis | 300000 | 5 minutes | +| Standard analysis | 600000 | 10 minutes | +| Deep analysis | 1200000 | 20 minutes | +| Code generation | 1800000 | 30 minutes | +| Complex tasks | 3600000 | 60 minutes | -### Codex 特殊倄理 +### Special Codex Handling -Codex 需芁曎长的超时时闎建议 3x。 +Codex requires longer timeout (recommend 3x). ```javascript const timeout = tool === 'codex' ? baseTimeout * 3 : baseTimeout; @@ -362,17 +362,17 @@ Bash({ --- -## 错误倄理 +## Error Handling -### 垞见错误 +### Common Errors -| 错误 | 原因 | 倄理 | -|------|------|------| -| ETIMEDOUT | 眑络超时 | 重试或切换工具 | -| Exit code 1 | 呜什执行倱莥 | 检查参数切换工具 | -| Context overflow | 䞊䞋文过倧 | 减少蟓入范囎 | +| Error | Cause | Handler | +|-------|-------|---------| +| ETIMEDOUT | Network timeout | Retry or switch tool | +| Exit code 1 | Command execution failed | Check parameters, switch tool | +| Context overflow | Input context too large | Reduce input scope | -### 重试策略 +### Retry Strategy ```javascript async function executeWithRetry(command, maxRetries = 3) { @@ -391,7 +391,7 @@ async function executeWithRetry(command, maxRetries = 3) { lastError = error; console.log(`Attempt ${attempt} failed: ${error.message}`); - // 指数退避 + // Exponential backoff if (attempt < maxRetries) { await sleep(Math.pow(2, attempt) * 1000); } @@ -404,30 +404,30 @@ async function executeWithRetry(command, maxRetries = 3) { --- -## 最䜳实践 +## Best Practices -### 1. run_in_background 规则 +### 1. run_in_background Rule ``` -Agent 调甚 (Task): - run_in_background: false → 同步立即获取结果 +Agent calls (Task): + run_in_background: false → Synchronous, get result immediately -CLI 调甚 (Bash + ccw cli): - run_in_background: true → 匂步后台执行 +CLI calls (Bash + ccw cli): + run_in_background: true → Asynchronous, run in background ``` -### 2. 工具选择 +### 2. Tool Selection ``` -分析任务: gemini > qwen -生成任务: codex > gemini > qwen -代码修改: codex > gemini +Analysis tasks: gemini > qwen +Generation tasks: codex > gemini > qwen +Code modification: codex > gemini ``` -### 3. 䌚话管理 +### 3. Session Management -- 盞关任务䜿甚 `--resume` 保持䞊䞋文 -- 独立任务䞍䜿甚 `--resume` +- Use `--resume` for related tasks to maintain context +- Do not use `--resume` for independent tasks ### 4. Prompt Specification @@ -435,8 +435,8 @@ CLI 调甚 (Bash + ccw cli): - Use `--rule