Add internationalization support for help view and implement help rendering logic

- Introduced `help-i18n.js` for managing translations in Chinese and English for the help view.
- Created `help.js` to render the help view, including command categories, workflow diagrams, and CodexLens quick-start.
- Implemented search functionality with debounce for command filtering.
- Added workflow diagram rendering with Cytoscape.js integration.
- Developed tests for write-file verification, ensuring proper handling of small and large JSON files.
This commit is contained in:
catlog22
2025-12-16 22:24:29 +08:00
parent b702791c2c
commit 154a9283b5
21 changed files with 2003 additions and 303 deletions

6
.claude/CLAUDE.md Normal file
View File

@@ -0,0 +1,6 @@
# Claude Instructions
- **CLI Tools Usage**: @~/.claude/rules/cli-tools-usage.md
- **Coding Philosophy**: @~/.claude/rules/coding-philosophy.md
- **Context Requirements**: @~/.claude/rules/context-requirements.md
- **File Modification**: @~/.claude/rules/file-modification.md

View File

@@ -470,14 +470,14 @@ function computeCliStrategy(task, allTasks) {
// Pattern: Gemini CLI deep analysis
{
"step": "gemini_analyze_[aspect]",
"command": "ccw cli exec 'PURPOSE: [goal]\\nTASK: [tasks]\\nMODE: analysis\\nCONTEXT: @[paths]\\nEXPECTED: [output]\\nRULES: $(cat [template]) | [constraints] | analysis=READ-ONLY' --tool gemini --cd [path]",
"command": "ccw cli exec 'PURPOSE: [goal]\\nTASK: [tasks]\\nMODE: analysis\\nCONTEXT: @[paths]\\nEXPECTED: [output]\\nRULES: $(cat [template]) | [constraints] | analysis=READ-ONLY' --tool gemini --mode analysis --cd [path]",
"output_to": "analysis_result"
},
// Pattern: Qwen CLI analysis (fallback/alternative)
{
"step": "qwen_analyze_[aspect]",
"command": "ccw cli exec '[similar to gemini pattern]' --tool qwen --cd [path]",
"command": "ccw cli exec '[similar to gemini pattern]' --tool qwen --mode analysis --cd [path]",
"output_to": "analysis_result"
},
@@ -518,7 +518,7 @@ The examples above demonstrate **patterns**, not fixed requirements. Agent MUST:
4. **Command Composition Patterns**:
- **Single command**: `bash([simple_search])`
- **Multiple commands**: `["bash([cmd1])", "bash([cmd2])"]`
- **CLI analysis**: `ccw cli exec '[prompt]' --tool gemini --cd [path]`
- **CLI analysis**: `ccw cli exec '[prompt]' --tool gemini --mode analysis --cd [path]`
- **MCP integration**: `mcp__[tool]__[function]([params])`
**Key Principle**: Examples show **structure patterns**, not specific implementations. Agent must create task-appropriate steps dynamically.

View File

@@ -155,7 +155,7 @@ MODE: analysis
CONTEXT: @**/*
EXPECTED: {output}
RULES: $(cat ~/.claude/workflows/cli-templates/prompts/analysis/pattern.txt)
" --tool gemini --cd {dir}
" --tool gemini --mode analysis --cd {dir}
# Qwen fallback: Replace '--tool gemini' with '--tool qwen'
```
@@ -172,7 +172,7 @@ ccw cli exec "..." --tool codex --mode auto --cd {dir}
**Cross-Directory** (Gemini/Qwen):
```bash
ccw cli exec "CONTEXT: @**/* @../shared/**/*" --tool gemini --cd src/auth --includeDirs ../shared
ccw cli exec "CONTEXT: @**/* @../shared/**/*" --tool gemini --mode analysis --cd src/auth --includeDirs ../shared
```
**Directory Scope**:

View File

@@ -85,7 +85,7 @@ MODE: analysis
CONTEXT: @**/*
EXPECTED: {from prompt}
RULES: {from prompt, if template specified} | analysis=READ-ONLY
" --tool gemini --cd {dir}
" --tool gemini --mode analysis --cd {dir}
```
**Fallback Chain**: Gemini → Qwen → Codex → Bash-only

View File

@@ -111,7 +111,7 @@ RULES: $(cat ~/.claude/workflows/cli-templates/prompts/planning/02-breakdown-tas
- Acceptance/verification must be quantified
- Dependencies use task IDs
- analysis=READ-ONLY
" --tool {cli_tool} --cd {project_root}
" --tool {cli_tool} --mode analysis --cd {project_root}
```
## Core Functions

View File

@@ -134,7 +134,7 @@ RULES: $(cat ~/.claude/workflows/cli-templates/prompts/{template}) |
- Consider previous iteration failures
- Validate fix doesn't introduce new vulnerabilities
- analysis=READ-ONLY
" --tool {cli_tool} --cd {project_root} --timeout {timeout_value}
" --tool {cli_tool} --mode analysis --cd {project_root} --timeout {timeout_value}
```
**Layer-Specific Guidance Injection**:
@@ -529,7 +529,7 @@ See: `.process/iteration-{iteration}-cli-output.txt`
```bash
ccw cli exec "PURPOSE: Analyze integration test failure...
TASK: Examine component interactions, data flow, interface contracts...
RULES: Analyze full call stack and data flow across components" --tool gemini
RULES: Analyze full call stack and data flow across components" --tool gemini --mode analysis
```
3. **Parse Output**: Extract RCA, 修复建议, 验证建议 sections
4. **Generate Task JSON** (IMPL-fix-1.json):

View File

@@ -49,11 +49,20 @@ RULES: $(cat ~/.claude/workflows/cli-templates/prompts/[category]/[template].txt
## Tool Selection Matrix
| Task Category | Tool | MODE | When to Use |
|---------------|------|------|-------------|
| **Read/Analyze** | Gemini/Qwen | `analysis` | Code review, architecture analysis, pattern discovery, exploration |
| **Write/Create** | Gemini/Qwen | `write` | Documentation generation, file creation (non-code) |
| **Implement/Fix** | Codex | `auto` | Feature implementation, bug fixes, test creation, refactoring |
- **Read/Analyze**
- Tool: Gemini/Qwen
- MODE: `analysis`
- When to Use: Code review, architecture analysis, pattern discovery, exploration
- **Write/Create**
- Tool: Gemini/Qwen
- MODE: `write`
- When to Use: Documentation generation, file creation (non-code)
- **Implement/Fix**
- Tool: Codex
- MODE: `auto`
- When to Use: Feature implementation, bug fixes, test creation, refactoring
## Essential Command Structure
@@ -78,20 +87,30 @@ ccw cli exec "<PROMPT>" --tool <gemini|qwen|codex> --mode <analysis|write|auto>
### MODE Options
| Mode | Permission | Use For | Specification |
|------|------------|---------|---------------|
| `analysis` | Read-only (default) | Code review, architecture analysis, pattern discovery | Auto for Gemini/Qwen |
| `write` | Create/Modify/Delete | Documentation, code creation, file modifications | Requires `--mode write` |
| `auto` | Full operations | Feature implementation, bug fixes, autonomous development | Codex only, requires `--mode auto` |
- **`analysis`**
- Permission: Read-only (default)
- Use For: Code review, architecture analysis, pattern discovery
- Specification: Auto for Gemini/Qwen
- **`write`**
- Permission: Create/Modify/Delete
- Use For: Documentation, code creation, file modifications
- Specification: Requires `--mode write`
- **`auto`**
- Permission: Full operations
- Use For: Feature implementation, bug fixes, autonomous development
- Specification: Codex only, requires `--mode auto`
### Mode Protocol References (MANDATORY)
**⚠️ REQUIRED**: Every CLI execution MUST include the corresponding mode protocol in RULES:
| Mode | Protocol (REQUIRED) |
|------|---------------------|
| `analysis` | `$(cat ~/.claude/workflows/cli-templates/protocols/analysis-protocol.md)` |
| `write/auto` | `$(cat ~/.claude/workflows/cli-templates/protocols/write-protocol.md)` |
- **`analysis`**
- Protocol (REQUIRED): `$(cat ~/.claude/workflows/cli-templates/protocols/analysis-protocol.md)`
- **`write/auto`**
- Protocol (REQUIRED): `$(cat ~/.claude/workflows/cli-templates/protocols/write-protocol.md)`
**RULES Format** (protocol MUST be included):
```bash
@@ -140,10 +159,8 @@ ccw cli exec "Continue analyzing" --tool gemini --mode analysis --resume
ccw cli exec "Fix issues found" --tool codex --mode auto --resume <id> # Resume specific session
```
| Value | Description |
|-------|-------------|
| `--resume` (empty) | Resume most recent session |
| `--resume <id>` | Resume specific execution ID |
- **`--resume` (empty)**: Resume most recent session
- **`--resume <id>`**: Resume specific execution ID
**Context Assembly** (automatic):
```
@@ -164,14 +181,41 @@ ASSISTANT RESPONSE: [Previous output]
Every command MUST include these fields:
| Field | Purpose | Components | Bad Example | Good Example |
|-------|---------|------------|-------------|--------------|
| **PURPOSE** | Goal + motivation + success | What + Why + Success Criteria + Constraints | "Analyze code" | "Identify security vulnerabilities in auth module to pass compliance audit; success = all OWASP Top 10 addressed; scope = src/auth/** only" |
| **TASK** | Actionable steps | Specific verbs + targets | "• Review code • Find issues" | "• Scan for SQL injection in query builders • Check XSS in template rendering • Verify CSRF token validation" |
| **MODE** | Permission level | analysis / write / auto | (missing) | "analysis" or "write" |
| **CONTEXT** | File scope + history | File patterns + Memory | "@**/*" | "@src/auth/**/*.ts @shared/utils/security.ts \| Memory: Previous auth refactoring (WFS-001)" |
| **EXPECTED** | Output specification | Format + Quality + Structure | "Report" | "Markdown report with: severity levels (Critical/High/Medium/Low), file:line references, remediation code snippets, priority ranking" |
| **RULES** | Template + constraints | $(cat template) + domain rules | (missing) | "$(cat ~/.claude/.../security.txt) \| Focus on authentication \| Ignore test files \| analysis=READ-ONLY" |
- **PURPOSE**
- Purpose: Goal + motivation + success
- Components: What + Why + Success Criteria + Constraints
- Bad Example: "Analyze code"
- Good Example: "Identify security vulnerabilities in auth module to pass compliance audit; success = all OWASP Top 10 addressed; scope = src/auth/** only"
- **TASK**
- Purpose: Actionable steps
- Components: Specific verbs + targets
- Bad Example: "• Review code • Find issues"
- Good Example: "• Scan for SQL injection in query builders • Check XSS in template rendering • Verify CSRF token validation"
- **MODE**
- Purpose: Permission level
- Components: analysis / write / auto
- Bad Example: (missing)
- Good Example: "analysis" or "write"
- **CONTEXT**
- Purpose: File scope + history
- Components: File patterns + Memory
- Bad Example: "@**/*"
- Good Example: "@src/auth/**/*.ts @shared/utils/security.ts \| Memory: Previous auth refactoring (WFS-001)"
- **EXPECTED**
- Purpose: Output specification
- Components: Format + Quality + Structure
- Bad Example: "Report"
- Good Example: "Markdown report with: severity levels (Critical/High/Medium/Low), file:line references, remediation code snippets, priority ranking"
- **RULES**
- Purpose: Template + constraints
- Components: $(cat template) + domain rules
- Bad Example: (missing)
- Good Example: "$(cat ~/.claude/.../security.txt) \| Focus on authentication \| Ignore test files \| analysis=READ-ONLY"
### CONTEXT Configuration
@@ -180,12 +224,10 @@ Every command MUST include these fields:
#### File Patterns
| Pattern | Scope |
|---------|-------|
| `@**/*` | All files (default) |
| `@src/**/*.ts` | TypeScript in src |
| `@../shared/**/*` | Sibling directory (requires `--includeDirs`) |
| `@CLAUDE.md` | Specific file |
- **`@**/*`**: All files (default)
- **`@src/**/*.ts`**: TypeScript in src
- **`@../shared/**/*`**: Sibling directory (requires `--includeDirs`)
- **`@CLAUDE.md`**: Specific file
#### Memory Context
@@ -253,35 +295,33 @@ RULES: $(cat ~/.claude/workflows/cli-templates/prompts/universal/00-universal-ri
**Universal Templates**:
| Template | Use For |
|----------|---------|
| `universal/00-universal-rigorous-style.txt` | Precision-critical, systematic methodology |
| `universal/00-universal-creative-style.txt` | Exploratory, innovative solutions |
- **`universal/00-universal-rigorous-style.txt`**: Precision-critical, systematic methodology
- **`universal/00-universal-creative-style.txt`**: Exploratory, innovative solutions
**Task-Template Matrix**:
| Task Type | Template |
|-----------|----------|
| **Analysis** | |
| Execution Tracing | `analysis/01-trace-code-execution.txt` |
| Bug Diagnosis | `analysis/01-diagnose-bug-root-cause.txt` |
| Code Patterns | `analysis/02-analyze-code-patterns.txt` |
| Document Analysis | `analysis/02-analyze-technical-document.txt` |
| Architecture Review | `analysis/02-review-architecture.txt` |
| Code Review | `analysis/02-review-code-quality.txt` |
| Performance | `analysis/03-analyze-performance.txt` |
| Security | `analysis/03-assess-security-risks.txt` |
| **Planning** | |
| Architecture | `planning/01-plan-architecture-design.txt` |
| Task Breakdown | `planning/02-breakdown-task-steps.txt` |
| Component Design | `planning/02-design-component-spec.txt` |
| Migration | `planning/03-plan-migration-strategy.txt` |
| **Development** | |
| Feature | `development/02-implement-feature.txt` |
| Refactoring | `development/02-refactor-codebase.txt` |
| Tests | `development/02-generate-tests.txt` |
| UI Component | `development/02-implement-component-ui.txt` |
| Debugging | `development/03-debug-runtime-issues.txt` |
**Analysis**:
- Execution Tracing: `analysis/01-trace-code-execution.txt`
- Bug Diagnosis: `analysis/01-diagnose-bug-root-cause.txt`
- Code Patterns: `analysis/02-analyze-code-patterns.txt`
- Document Analysis: `analysis/02-analyze-technical-document.txt`
- Architecture Review: `analysis/02-review-architecture.txt`
- Code Review: `analysis/02-review-code-quality.txt`
- Performance: `analysis/03-analyze-performance.txt`
- Security: `analysis/03-assess-security-risks.txt`
**Planning**:
- Architecture: `planning/01-plan-architecture-design.txt`
- Task Breakdown: `planning/02-breakdown-task-steps.txt`
- Component Design: `planning/02-design-component-spec.txt`
- Migration: `planning/03-plan-migration-strategy.txt`
**Development**:
- Feature: `development/02-implement-feature.txt`
- Refactoring: `development/02-refactor-codebase.txt`
- Tests: `development/02-generate-tests.txt`
- UI Component: `development/02-implement-component-ui.txt`
- Debugging: `development/03-debug-runtime-issues.txt`
---
@@ -289,16 +329,37 @@ RULES: $(cat ~/.claude/workflows/cli-templates/prompts/universal/00-universal-ri
### Command Options
| Option | Description | Default |
|--------|-------------|---------|
| `--tool <tool>` | gemini, qwen, codex | gemini |
| `--mode <mode>` | **REQUIRED**: analysis, write, auto | **NONE** (must specify) |
| `--model <model>` | Model override | auto-select |
| `--cd <path>` | Working directory | current |
| `--includeDirs <dirs>` | Additional directories (comma-separated) | none |
| `--timeout <ms>` | Timeout in milliseconds | 300000 |
| `--resume [id]` | Resume previous session | - |
| `--no-stream` | Disable streaming | false |
- **`--tool <tool>`**
- Description: gemini, qwen, codex
- Default: gemini
- **`--mode <mode>`**
- Description: **REQUIRED**: analysis, write, auto
- Default: **NONE** (must specify)
- **`--model <model>`**
- Description: Model override
- Default: auto-select
- **`--cd <path>`**
- Description: Working directory
- Default: current
- **`--includeDirs <dirs>`**
- Description: Additional directories (comma-separated)
- Default: none
- **`--timeout <ms>`**
- Description: Timeout in milliseconds
- Default: 300000
- **`--resume [id]`**
- Description: Resume previous session
- Default: -
- **`--no-stream`**
- Description: Disable streaming
- Default: false
### Directory Configuration
@@ -331,12 +392,21 @@ ccw cli exec "..." --tool gemini --mode analysis --cd src/auth --includeDirs ../
CCW automatically maps to tool-specific syntax:
| CCW Parameter | Gemini/Qwen | Codex |
|---------------|-------------|-------|
| `--cd <path>` | `cd <path> &&` | `-C <path>` |
| `--includeDirs <dirs>` | `--include-directories` | `--add-dir` (per dir) |
| `--mode write` | `--approval-mode yolo` | `-s danger-full-access` |
| `--mode auto` | N/A | `-s danger-full-access` |
- **`--cd <path>`**
- Gemini/Qwen: `cd <path> &&`
- Codex: `-C <path>`
- **`--includeDirs <dirs>`**
- Gemini/Qwen: `--include-directories`
- Codex: `--add-dir` (per dir)
- **`--mode write`**
- Gemini/Qwen: `--approval-mode yolo`
- Codex: `-s danger-full-access`
- **`--mode auto`**
- Gemini/Qwen: N/A
- Codex: `-s danger-full-access`
### Command Examples
@@ -397,12 +467,17 @@ RULES: $(cat ~/.claude/workflows/cli-templates/prompts/development/02-refactor-c
**Minimum**: 5 minutes (300000ms)
| Complexity | Range | Examples |
|------------|-------|----------|
| Simple | 5-10min (300000-600000ms) | Analysis, search |
| Medium | 10-20min (600000-1200000ms) | Refactoring, documentation |
| Complex | 20-60min (1200000-3600000ms) | Implementation, migration |
| Heavy | 60-120min (3600000-7200000ms) | Large codebase, multi-file |
- **Simple**: 5-10min (300000-600000ms)
- Examples: Analysis, search
- **Medium**: 10-20min (600000-1200000ms)
- Examples: Refactoring, documentation
- **Complex**: 20-60min (1200000-3600000ms)
- Examples: Implementation, migration
- **Heavy**: 60-120min (3600000-7200000ms)
- Examples: Large codebase, multi-file
**Codex Multiplier**: 3x allocated time (minimum 15min / 900000ms)
@@ -437,12 +512,10 @@ ccw cli exec "<prompt>" --tool codex --mode auto --timeout 1800000 # 30 min
### Workflow Integration
| Phase | Command |
|-------|---------|
| Understanding | `ccw cli exec "<prompt>" --tool gemini` |
| Architecture | `ccw cli exec "<prompt>" --tool gemini` |
| Implementation | `ccw cli exec "<prompt>" --tool codex --mode auto` |
| Quality | `ccw cli exec "<prompt>" --tool codex --mode write` |
- **Understanding**: `ccw cli exec "<prompt>" --tool gemini`
- **Architecture**: `ccw cli exec "<prompt>" --tool gemini`
- **Implementation**: `ccw cli exec "<prompt>" --tool codex --mode auto`
- **Quality**: `ccw cli exec "<prompt>" --tool codex --mode write`
### Planning Checklist

View File

@@ -40,3 +40,24 @@
- Learn from existing implementations
- Stop after 3 failed attempts and reassess
- **Edit fallback**: When Edit tool fails 2+ times on same file, try Bash sed/awk first, then Write to recreate if still failing
## Learning the Codebase
- Find 3 similar features/components
- Identify common patterns and conventions
- Use same libraries/utilities when possible
- Follow existing test patterns
## Tooling
- Use project's existing build system
- Use project's test framework
- Use project's formatter/linter settings
- Don't introduce new tools without strong justification
## Content Uniqueness Rules
- **Each layer owns its abstraction level** - no content sharing between layers
- **Reference, don't duplicate** - point to other layers, never copy content
- **Maintain perspective** - each layer sees the system at its appropriate scale
- **Avoid implementation creep** - higher layers stay architectural

View File

@@ -1,22 +0,0 @@
# Project Integration Rules
## Learning the Codebase
- Find 3 similar features/components
- Identify common patterns and conventions
- Use same libraries/utilities when possible
- Follow existing test patterns
## Tooling
- Use project's existing build system
- Use project's test framework
- Use project's formatter/linter settings
- Don't introduce new tools without strong justification
## Content Uniqueness Rules
- **Each layer owns its abstraction level** - no content sharing between layers
- **Reference, don't duplicate** - point to other layers, never copy content
- **Maintain perspective** - each layer sees the system at its appropriate scale
- **Avoid implementation creep** - higher layers stay architectural