mirror of
https://github.com/catlog22/Claude-Code-Workflow.git
synced 2026-02-11 02:33:51 +08:00
feat: initialize monorepo with package.json for CCW workflow platform
This commit is contained in:
249
ccw/docs-site/docs/commands/memory/memory-compact.mdx
Normal file
249
ccw/docs-site/docs/commands/memory/memory-compact.mdx
Normal file
@@ -0,0 +1,249 @@
|
||||
---
|
||||
title: /memory:compact
|
||||
sidebar_label: /memory:compact
|
||||
sidebar_position: 6
|
||||
description: Compact session memory into structured text for recovery
|
||||
---
|
||||
|
||||
# /memory:compact
|
||||
|
||||
Compress current session working memory into structured text optimized for session recovery and persistent storage.
|
||||
|
||||
## Overview
|
||||
|
||||
The `/memory:compact` command compresses the current session's working memory into structured text, extracting critical information and saving it to persistent storage via MCP `core_memory` tool.
|
||||
|
||||
**Parameters**:
|
||||
- `--description="..."`: Custom session description
|
||||
- `--tags=<tag1,tag2>`: Add custom tags
|
||||
- `--force`: Override existing memory without confirmation
|
||||
|
||||
**Execution Flow**:
|
||||
1. Session Analysis → 2. Structure Extraction → 3. Text Generation → 4. MCP Import
|
||||
|
||||
## Features
|
||||
|
||||
- **Session Compression** - Extracts key information from working memory
|
||||
- **Structured Format** - Organizes content for easy recovery
|
||||
- **Critical State Capture** - Preserves objectives, plans, and decisions
|
||||
- **Tag Support** - Add custom tags for organization
|
||||
- **Persistent Storage** - Saves via MCP core_memory tool
|
||||
- **Session Recovery** - Enables resuming from compacted state
|
||||
|
||||
## Usage
|
||||
|
||||
```bash
|
||||
# Compact current session
|
||||
/memory:compact
|
||||
|
||||
# With custom description
|
||||
/memory:compact --description="User authentication implementation"
|
||||
|
||||
# With tags
|
||||
/memory:compact --tags=auth,security,api
|
||||
|
||||
# Force overwrite
|
||||
/memory:compact --force
|
||||
```
|
||||
|
||||
## Execution Flow
|
||||
|
||||
### Phase 1: Session Analysis
|
||||
|
||||
Analyze current session state to extract:
|
||||
- Session objectives and goals
|
||||
- Implementation plan
|
||||
- Files modified
|
||||
- Key decisions made
|
||||
- Constraints and requirements
|
||||
- Current state
|
||||
|
||||
### Phase 2: Structure Extraction
|
||||
|
||||
```javascript
|
||||
const sessionAnalysis = {
|
||||
objective: extract_objective(session),
|
||||
plan: extract_plan(session),
|
||||
files: extract_files(session),
|
||||
decisions: extract_decisions(session),
|
||||
constraints: extract_constraints(session),
|
||||
state: extract_state(session),
|
||||
notes: extract_notes(session)
|
||||
};
|
||||
```
|
||||
|
||||
### Phase 3: Structured Text Generation
|
||||
|
||||
```text
|
||||
# Session: {session_id}
|
||||
|
||||
## Objective
|
||||
{objective}
|
||||
|
||||
## Implementation Plan
|
||||
{plan}
|
||||
|
||||
## Files Modified
|
||||
{files}
|
||||
|
||||
## Key Decisions
|
||||
{decisions}
|
||||
|
||||
## Constraints
|
||||
{constraints}
|
||||
|
||||
## Current State
|
||||
{state}
|
||||
|
||||
## Notes
|
||||
{notes}
|
||||
```
|
||||
|
||||
### Phase 4: MCP Import
|
||||
|
||||
```javascript
|
||||
mcp__ccw-tools__core_memory({
|
||||
operation: "import",
|
||||
text: structuredText
|
||||
})
|
||||
```
|
||||
|
||||
## Output Format
|
||||
|
||||
```json
|
||||
{
|
||||
"operation": "import",
|
||||
"id": "CMEM-YYYYMMDD-HHMMSS",
|
||||
"message": "Created memory: CMEM-YYYYMMDD-HHMMSS"
|
||||
}
|
||||
```
|
||||
|
||||
## Structured Text Template
|
||||
|
||||
```markdown
|
||||
# Session: {session_id}
|
||||
|
||||
**Date**: {timestamp}
|
||||
**Description**: {custom_description or auto-generated}
|
||||
**Tags**: {tags}
|
||||
|
||||
---
|
||||
|
||||
## Objective
|
||||
|
||||
{session_objective}
|
||||
|
||||
---
|
||||
|
||||
## Implementation Plan
|
||||
|
||||
{implementation_plan}
|
||||
|
||||
---
|
||||
|
||||
## Files Modified
|
||||
|
||||
| File | Changes |
|
||||
|------|---------|
|
||||
| {file1} | {changes1} |
|
||||
| {file2} | {changes2} |
|
||||
|
||||
---
|
||||
|
||||
## Key Decisions
|
||||
|
||||
1. {decision1}
|
||||
2. {decision2}
|
||||
3. {decision3}
|
||||
|
||||
---
|
||||
|
||||
## Constraints
|
||||
|
||||
- {constraint1}
|
||||
- {constraint2}
|
||||
|
||||
---
|
||||
|
||||
## Current State
|
||||
|
||||
{current_state}
|
||||
|
||||
---
|
||||
|
||||
## Notes
|
||||
|
||||
{additional_notes}
|
||||
```
|
||||
|
||||
## Examples
|
||||
|
||||
### Basic Usage
|
||||
|
||||
```bash
|
||||
# Compact current session
|
||||
/memory:compact
|
||||
|
||||
# Output:
|
||||
# Analyzing session...
|
||||
# Extracting key information...
|
||||
# Generating structured text...
|
||||
# Importing to core memory...
|
||||
# ✅ Memory compacted: CMEM-20250203-143022
|
||||
```
|
||||
|
||||
### With Custom Description
|
||||
|
||||
```bash
|
||||
# Compact with description
|
||||
/memory:compact --description="OAuth2 implementation"
|
||||
|
||||
# Description is saved with the memory
|
||||
```
|
||||
|
||||
### With Tags
|
||||
|
||||
```bash
|
||||
# Compact with tags
|
||||
/memory:compact --tags=oauth,authentication,security
|
||||
|
||||
# Tags help with organization and retrieval
|
||||
```
|
||||
|
||||
## Recovery
|
||||
|
||||
To recover a compacted session:
|
||||
|
||||
```bash
|
||||
# List available memories
|
||||
mcp__ccw-tools__core_memory({ operation: "list" })
|
||||
|
||||
# Export specific memory
|
||||
mcp__ccw-tools__core_memory({ operation: "export", id: "CMEM-YYYYMMDD-HHMMSS" })
|
||||
|
||||
# Search for memories
|
||||
mcp__ccw-tools__core_memory({ operation: "search", query: "oauth" })
|
||||
```
|
||||
|
||||
## Use Cases
|
||||
|
||||
1. **Session Handoff** - Preserve context for later continuation
|
||||
2. **Knowledge Base** - Store insights and decisions for reference
|
||||
3. **Team Sharing** - Share session state with team members
|
||||
4. **Documentation** - Generate structured records of work sessions
|
||||
5. **Recovery** - Restore session state after interruption
|
||||
|
||||
## Related Commands
|
||||
|
||||
- **/memory:load** - Load project context into memory
|
||||
- **/memory:update-full** - Update all CLAUDE.md files
|
||||
- **/memory:update-related** - Update changed CLAUDE.md files
|
||||
|
||||
## Notes
|
||||
|
||||
- **Persistent storage** - Saved via MCP core_memory tool
|
||||
- **Structured format** - Optimized for readability and parsing
|
||||
- **Automatic ID generation** - Format: CMEM-YYYYMMDD-HHMMSS
|
||||
- **Force option** - Override existing memory without confirmation
|
||||
- **Tag support** - Add custom tags for organization and search
|
||||
- **Custom description** - Add meaningful description for easy identification
|
||||
178
ccw/docs-site/docs/commands/memory/memory-docs-full-cli.mdx
Normal file
178
ccw/docs-site/docs/commands/memory/memory-docs-full-cli.mdx
Normal file
@@ -0,0 +1,178 @@
|
||||
---
|
||||
title: /memory:docs-full-cli
|
||||
sidebar_label: /memory:docs-full-cli
|
||||
sidebar_position: 4
|
||||
description: Generate full CLI documentation for all project modules
|
||||
---
|
||||
|
||||
# /memory:docs-full-cli
|
||||
|
||||
Generate comprehensive CLI documentation for all project modules using batched agent execution with automatic tool fallback.
|
||||
|
||||
## Overview
|
||||
|
||||
The `/memory:docs-full-cli` command generates complete documentation for all modules in the project using CLI tools with intelligent batching and automatic fallback.
|
||||
|
||||
**Parameters**:
|
||||
- `--tool <gemini|qwen|codex>`: Primary tool (default: gemini)
|
||||
- `--path <directory>`: Target directory (default: project root)
|
||||
|
||||
**Execution Flow**:
|
||||
1. Module Detection → 2. Plan Presentation → 3. Batched Generation → 4. Verification
|
||||
|
||||
## Features
|
||||
|
||||
- **Full Coverage** - Documents all modules in the project
|
||||
- **Intelligent Batching** - Groups modules by depth (4 modules/batch)
|
||||
- **Automatic Fallback** - gemini→qwen→codex on failure
|
||||
- **Depth Sequential** - Process depths N→0, parallel batches within depth
|
||||
- **Smart Filtering** - Auto-detects and skips tests/build/config/docs
|
||||
|
||||
## Usage
|
||||
|
||||
```bash
|
||||
# Generate full documentation
|
||||
/memory:docs-full-cli
|
||||
|
||||
# Target specific directory
|
||||
/memory:docs-full-cli --path src/auth
|
||||
|
||||
# Use specific tool
|
||||
/memory:docs-full-cli --tool qwen
|
||||
```
|
||||
|
||||
## Tool Fallback Hierarchy
|
||||
|
||||
```javascript
|
||||
--tool gemini → [gemini, qwen, codex] // default
|
||||
--tool qwen → [qwen, gemini, codex]
|
||||
--tool codex → [codex, gemini, qwen]
|
||||
```
|
||||
|
||||
## Execution Flow
|
||||
|
||||
### Phase 1: Module Detection & Analysis
|
||||
|
||||
```javascript
|
||||
// Get module structure with classification
|
||||
Bash({command: "ccw tool exec get_modules_by_depth '{\"format\":\"list\"}' | ccw tool exec classify_folders '{}'", run_in_background: false});
|
||||
|
||||
// OR with path parameter
|
||||
Bash({command: "cd <target-path> && ccw tool exec get_modules_by_depth '{\"format\":\"list\"}' | ccw tool exec classify_folders '{}'", run_in_background: false});
|
||||
```
|
||||
|
||||
**Parse output** `depth:N|path:<PATH>|type:<code|navigation>|...` to extract module paths, types, and count.
|
||||
|
||||
**Smart filter**: Auto-detect and skip tests/build/config/vendor based on project tech stack.
|
||||
|
||||
### Phase 2: Plan Presentation
|
||||
|
||||
- Parse `--tool` (default: gemini)
|
||||
- Get module structure with classification
|
||||
- **Smart filter modules** (auto-detect tech stack, skip tests/build/config)
|
||||
- Construct tool fallback order
|
||||
- **Present filtered plan** with module types and counts
|
||||
- **Wait for y/n confirmation**
|
||||
|
||||
### Phase 3: Batched Documentation Generation
|
||||
|
||||
```javascript
|
||||
let modules_by_depth = group_by_depth(all_modules);
|
||||
let tool_order = construct_tool_order(primary_tool);
|
||||
|
||||
for (let depth of sorted_depths.reverse()) { // N → 0
|
||||
let batches = batch_modules(modules_by_depth[depth], 4);
|
||||
|
||||
for (let batch of batches) {
|
||||
let parallel_tasks = batch.map(module => {
|
||||
return async () => {
|
||||
let strategy = module.depth >= 3 ? "full" : "single";
|
||||
for (let tool of tool_order) {
|
||||
Bash({
|
||||
command: `cd ${module.path} && ccw tool exec generate_module_docs '{"strategy":"${strategy}","sourcePath":".","projectName":"${project_name}","tool":"${tool}"}'`,
|
||||
run_in_background: false
|
||||
});
|
||||
if (bash_result.exit_code === 0) {
|
||||
report(`✅ ${module.path} (Layer ${layer}) docs generated with ${tool}`);
|
||||
return true;
|
||||
}
|
||||
}
|
||||
report(`❌ FAILED: ${module.path} (Layer ${layer}) failed all tools`);
|
||||
return false;
|
||||
};
|
||||
});
|
||||
await Promise.all(parallel_tasks.map(task => task()));
|
||||
}
|
||||
}
|
||||
```
|
||||
|
||||
### Phase 4: Verification
|
||||
|
||||
- Verify documentation files were created
|
||||
- Display statistics
|
||||
- Show summary of generated docs
|
||||
|
||||
## Strategy Selection
|
||||
|
||||
| Module Depth | Strategy | Description |
|
||||
|--------------|----------|-------------|
|
||||
| Depth < 3 | single | Single document for module |
|
||||
| Depth >= 3 | full | Comprehensive documentation with subsections |
|
||||
|
||||
## Module Types
|
||||
|
||||
| Type | Description | Documentation Focus |
|
||||
|------|-------------|---------------------|
|
||||
| **code** | Source code modules | API, classes, functions |
|
||||
| **navigation** | Directory structures | Organization, file purposes |
|
||||
|
||||
## Examples
|
||||
|
||||
### Basic Usage
|
||||
|
||||
```bash
|
||||
# Generate full project documentation
|
||||
/memory:docs-full-cli
|
||||
|
||||
# Output:
|
||||
# Analyzing workspace...
|
||||
# Found 45 modules (38 code, 7 navigation)
|
||||
# Filtered: 12 test/build/config modules skipped
|
||||
# Plan: Generate docs for 33 modules
|
||||
# Confirm? (y/n): y
|
||||
#
|
||||
# Depth 7: [4/4] ✅
|
||||
# Depth 6: [8/8] ✅
|
||||
# ...
|
||||
# Summary: 33/33 modules documented
|
||||
```
|
||||
|
||||
### Directory-Specific
|
||||
|
||||
```bash
|
||||
# Document specific feature
|
||||
/memory:docs-full-cli --path src/features/auth
|
||||
|
||||
# Only documents auth feature
|
||||
```
|
||||
|
||||
### Tool Selection
|
||||
|
||||
```bash
|
||||
# Use Qwen for generation
|
||||
/memory:docs-full-cli --tool qwen
|
||||
```
|
||||
|
||||
## Related Commands
|
||||
|
||||
- **/memory:docs-related-cli** - Generate docs for changed modules only
|
||||
- **/memory:update-full** - Update CLAUDE.md files
|
||||
- **/memory:compact** - Compact session memory
|
||||
|
||||
## Notes
|
||||
|
||||
- **Smart filtering** automatically skips test/build/config directories
|
||||
- **Classification** distinguishes between code and navigation modules
|
||||
- **Depth-based strategy** optimizes documentation detail level
|
||||
- **Tool fallback** ensures completion even if primary tool fails
|
||||
- **Verification** confirms all documentation files created successfully
|
||||
174
ccw/docs-site/docs/commands/memory/memory-docs-related-cli.mdx
Normal file
174
ccw/docs-site/docs/commands/memory/memory-docs-related-cli.mdx
Normal file
@@ -0,0 +1,174 @@
|
||||
---
|
||||
title: /memory:docs-related-cli
|
||||
sidebar_label: /memory:docs-related-cli
|
||||
sidebar_position: 5
|
||||
description: Generate CLI documentation for git-changed modules
|
||||
---
|
||||
|
||||
# /memory:docs-related-cli
|
||||
|
||||
Generate CLI documentation for modules affected by git changes using batched agent execution with automatic tool fallback.
|
||||
|
||||
## Overview
|
||||
|
||||
The `/memory:docs-related-cli` command generates documentation only for modules affected by recent git changes, providing faster documentation updates for daily development.
|
||||
|
||||
**Parameters**:
|
||||
- `--tool <gemini|qwen|codex>`: Primary tool (default: gemini)
|
||||
|
||||
**Execution Flow**:
|
||||
1. Change Detection → 2. Plan Presentation → 3. Batched Generation → 4. Verification
|
||||
|
||||
## Features
|
||||
|
||||
- **Changed Module Detection** - Uses git diff to identify affected modules
|
||||
- **Intelligent Batching** - Groups modules by depth (4 modules/agent)
|
||||
- **Automatic Fallback** - gemini→qwen→codex on failure
|
||||
- **Depth Sequential** - Process depths N→0, parallel batches within depth
|
||||
- **Smart Filtering** - Auto-detects and skips tests/build/config/docs
|
||||
- **Single Strategy** - Uses single-layer documentation for speed
|
||||
|
||||
## Usage
|
||||
|
||||
```bash
|
||||
# Generate docs for changed modules
|
||||
/memory:docs-related-cli
|
||||
|
||||
# Use specific tool
|
||||
/memory:docs-related-cli --tool qwen
|
||||
```
|
||||
|
||||
## Tool Fallback Hierarchy
|
||||
|
||||
```javascript
|
||||
--tool gemini → [gemini, qwen, codex] // default
|
||||
--tool qwen → [qwen, gemini, codex]
|
||||
--tool codex → [codex, gemini, qwen]
|
||||
```
|
||||
|
||||
## Execution Flow
|
||||
|
||||
### Phase 1: Change Detection & Analysis
|
||||
|
||||
```javascript
|
||||
// Detect changed modules
|
||||
Bash({command: "ccw tool exec detect_changed_modules '{\"format\":\"list\"}'", run_in_background: false});
|
||||
|
||||
// Cache git changes
|
||||
Bash({command: "git add -A 2>/dev/null || true", run_in_background: false});
|
||||
```
|
||||
|
||||
**Parse output** `depth:N|path:<PATH>|change:<TYPE>` to extract affected modules.
|
||||
|
||||
**Smart filter**: Auto-detect and skip tests/build/config/docs based on project tech stack.
|
||||
|
||||
**Fallback**: If no changes detected, use recent modules (first 10 by depth).
|
||||
|
||||
### Phase 2: Plan Presentation
|
||||
|
||||
- Parse `--tool` (default: gemini)
|
||||
- Refresh code index for accurate change detection
|
||||
- Detect changed modules
|
||||
- **Smart filter modules** (auto-detect tech stack, skip tests/build/config)
|
||||
- Cache git changes
|
||||
- Apply fallback if no changes
|
||||
- Construct tool fallback order
|
||||
- **Present filtered plan** with change types
|
||||
- **Wait for y/n confirmation**
|
||||
|
||||
### Phase 3: Batched Documentation Generation
|
||||
|
||||
```javascript
|
||||
let modules_by_depth = group_by_depth(changed_modules);
|
||||
let tool_order = construct_tool_order(primary_tool);
|
||||
|
||||
for (let depth of sorted_depths.reverse()) { // N → 0
|
||||
let batches = batch_modules(modules_by_depth[depth], 4);
|
||||
|
||||
for (let batch of batches) {
|
||||
let parallel_tasks = batch.map(module => {
|
||||
return async () => {
|
||||
for (let tool of tool_order) {
|
||||
Bash({
|
||||
command: `cd ${module.path} && ccw tool exec generate_module_docs '{"strategy":"single","sourcePath":".","projectName":"${project_name}","tool":"${tool}"}'`,
|
||||
run_in_background: false
|
||||
});
|
||||
if (bash_result.exit_code === 0) {
|
||||
report(`✅ ${module.path} docs generated with ${tool}`);
|
||||
return true;
|
||||
}
|
||||
}
|
||||
report(`❌ FAILED: ${module.path} failed all tools`);
|
||||
return false;
|
||||
};
|
||||
});
|
||||
await Promise.all(parallel_tasks.map(task => task()));
|
||||
}
|
||||
}
|
||||
```
|
||||
|
||||
### Phase 4: Verification
|
||||
|
||||
- Verify documentation files were created
|
||||
- Display statistics
|
||||
- Show summary of generated docs
|
||||
|
||||
## Strategy Selection
|
||||
|
||||
**Related Mode** uses `single` strategy:
|
||||
- Generates single document per module
|
||||
- Faster than full mode's multi-layer approach
|
||||
- Suitable for iterative development
|
||||
|
||||
## Comparison with Full CLI Documentation
|
||||
|
||||
| Aspect | Related Docs | Full Docs |
|
||||
|--------|--------------|-----------|
|
||||
| **Scope** | Changed modules only | All project modules |
|
||||
| **Speed** | Fast (minutes) | Slower (10-30 min) |
|
||||
| **Use case** | Daily development | Major refactoring |
|
||||
| **Strategy** | single only | full for depth>=3 |
|
||||
| **Trigger** | After commits | After major changes |
|
||||
| **Batching** | 4 modules/agent | 4 modules/agent |
|
||||
| **Fallback** | gemini→qwen→codex | gemini→qwen→codex |
|
||||
|
||||
## Examples
|
||||
|
||||
### Basic Usage
|
||||
|
||||
```bash
|
||||
# Document changed modules after commits
|
||||
/memory:docs-related-cli
|
||||
|
||||
# Output:
|
||||
# Detecting git changes...
|
||||
# Found 8 changed modules
|
||||
# Filtered: 3 test modules skipped
|
||||
# Plan: Generate docs for 5 modules
|
||||
# Confirm? (y/n): y
|
||||
#
|
||||
# Depth 3: [4/4] ✅
|
||||
# Depth 2: [1/1] ✅
|
||||
# Summary: 5/5 modules documented
|
||||
```
|
||||
|
||||
### Tool Selection
|
||||
|
||||
```bash
|
||||
# Use Qwen for generation
|
||||
/memory:docs-related-cli --tool qwen
|
||||
```
|
||||
|
||||
## Related Commands
|
||||
|
||||
- **/memory:docs-full-cli** - Generate docs for all modules
|
||||
- **/memory:update-related** - Update CLAUDE.md for changed modules
|
||||
- **/memory:compact** - Compact session memory
|
||||
|
||||
## Notes
|
||||
|
||||
- **Smart filtering** automatically skips test/build/config directories
|
||||
- **Change detection** uses git diff to find affected modules
|
||||
- **Single strategy** optimizes for speed in iterative development
|
||||
- **Tool fallback** ensures completion even if primary tool fails
|
||||
- **Verification** confirms all documentation files created successfully
|
||||
189
ccw/docs-site/docs/commands/memory/memory-load.mdx
Normal file
189
ccw/docs-site/docs/commands/memory/memory-load.mdx
Normal file
@@ -0,0 +1,189 @@
|
||||
---
|
||||
title: /memory:load
|
||||
sidebar_label: /memory:load
|
||||
sidebar_position: 3
|
||||
description: Load project context and core content into memory
|
||||
---
|
||||
|
||||
# /memory:load
|
||||
|
||||
Delegate to a universal-executor agent to analyze the project and return a structured "Core Content Pack" for memory optimization.
|
||||
|
||||
## Overview
|
||||
|
||||
The `/memory:load` command analyzes the project and returns a structured content package loaded directly into main thread memory, providing essential context for subsequent agent operations while minimizing token consumption.
|
||||
|
||||
**Core Philosophy**:
|
||||
- **Agent-Driven**: Fully delegates execution to universal-executor agent
|
||||
- **Read-Only Analysis**: Does not modify code, only extracts context
|
||||
- **Structured Output**: Returns standardized JSON content package
|
||||
- **Memory Optimization**: Package loaded directly into main thread memory
|
||||
- **Token Efficiency**: CLI analysis executed within agent to save tokens
|
||||
|
||||
## Features
|
||||
|
||||
- **Project Analysis** - Comprehensive codebase understanding
|
||||
- **Core Content Extraction** - Identifies key components and patterns
|
||||
- **Structured Output** - JSON format for easy integration
|
||||
- **Memory Optimization** - Reduces token usage for subsequent operations
|
||||
- **Tech Stack Detection** - Automatic identification of technologies used
|
||||
|
||||
## Usage
|
||||
|
||||
```bash
|
||||
# Load project context into memory
|
||||
/memory:load
|
||||
|
||||
# Load with custom scope
|
||||
/memory:load --path src/features
|
||||
|
||||
# Load with specific depth
|
||||
/memory:load --depth 3
|
||||
```
|
||||
|
||||
## Execution Flow
|
||||
|
||||
```
|
||||
User Input
|
||||
↓
|
||||
Delegate to universal-executor agent
|
||||
↓
|
||||
Phase 1: Project Analysis
|
||||
├─ Analyze project structure
|
||||
├─ Identify tech stack
|
||||
├─ Detect key components
|
||||
└─ Extract architectural patterns
|
||||
↓
|
||||
Phase 2: Core Content Extraction
|
||||
├─ Extract main components
|
||||
├─ Identify data structures
|
||||
├─ Find key interfaces
|
||||
└─ Document important patterns
|
||||
↓
|
||||
Phase 3: Structured Output Generation
|
||||
├─ Format as JSON
|
||||
├─ Organize by categories
|
||||
└─ Add metadata
|
||||
↓
|
||||
Phase 4: Memory Loading
|
||||
├─ Load into main thread memory
|
||||
├─ Make available for subsequent operations
|
||||
└─ Display summary
|
||||
```
|
||||
|
||||
## Output Format
|
||||
|
||||
The command returns a structured "Core Content Pack":
|
||||
|
||||
```json
|
||||
{
|
||||
"project_name": "string",
|
||||
"tech_stack": ["list", "of", "technologies"],
|
||||
"architecture": {
|
||||
"overview": "string",
|
||||
"key_components": ["list"],
|
||||
"patterns": ["list"]
|
||||
},
|
||||
"core_content": {
|
||||
"components": [
|
||||
{
|
||||
"name": "string",
|
||||
"purpose": "string",
|
||||
"location": "path",
|
||||
"dependencies": ["list"]
|
||||
}
|
||||
],
|
||||
"data_structures": [
|
||||
{
|
||||
"name": "string",
|
||||
"purpose": "string",
|
||||
"location": "path"
|
||||
}
|
||||
],
|
||||
"interfaces": [
|
||||
{
|
||||
"name": "string",
|
||||
"methods": ["list"],
|
||||
"location": "path"
|
||||
}
|
||||
]
|
||||
},
|
||||
"metadata": {
|
||||
"total_modules": number,
|
||||
"depth_analyzed": number,
|
||||
"timestamp": "ISO8601"
|
||||
}
|
||||
}
|
||||
```
|
||||
|
||||
## Examples
|
||||
|
||||
### Basic Usage
|
||||
|
||||
```bash
|
||||
# Load full project context
|
||||
/memory:load
|
||||
|
||||
# Output:
|
||||
# Delegating to universal-executor agent...
|
||||
# Analyzing project structure...
|
||||
# Detected: TypeScript, React, Node.js
|
||||
# Extracting core content...
|
||||
# Core Content Pack loaded:
|
||||
# - 45 components identified
|
||||
# - 12 data structures
|
||||
# - 28 interfaces
|
||||
# Memory load complete
|
||||
```
|
||||
|
||||
### Scoped Analysis
|
||||
|
||||
```bash
|
||||
# Load specific directory
|
||||
/memory:load --path src/features/auth
|
||||
|
||||
# Only analyzes auth feature
|
||||
```
|
||||
|
||||
## Core Content Pack Categories
|
||||
|
||||
### Components
|
||||
- Main application components
|
||||
- UI elements
|
||||
- Service classes
|
||||
- Utility functions
|
||||
|
||||
### Data Structures
|
||||
- Type definitions
|
||||
- Interfaces
|
||||
- Enums
|
||||
- Configuration schemas
|
||||
|
||||
### Patterns
|
||||
- Architectural patterns
|
||||
- Design patterns
|
||||
- Coding conventions
|
||||
- Best practices
|
||||
|
||||
## Benefits
|
||||
|
||||
1. **Token Efficiency** - Reduces token usage for subsequent operations
|
||||
2. **Faster Context Loading** - Pre-loaded content available immediately
|
||||
3. **Improved Accuracy** - Better context for agent decisions
|
||||
4. **Structured Knowledge** - Organized project information
|
||||
5. **Quick Navigation** - Easy access to key components
|
||||
|
||||
## Related Commands
|
||||
|
||||
- **/memory:update-full** - Full project documentation update
|
||||
- **/memory:update-related** - Changed module documentation update
|
||||
- **/memory:compact** - Compact session memory
|
||||
|
||||
## Notes
|
||||
|
||||
- **Read-only operation** - Does not modify any files
|
||||
- **Agent-driven** - Fully delegates to universal-executor agent
|
||||
- **Memory optimization** - Reduces token consumption for subsequent operations
|
||||
- **Project agnostic** - Works with any project type and structure
|
||||
- **Automatic tech stack detection** - Identifies technologies in use
|
||||
- **Structured output** - JSON format for easy integration
|
||||
228
ccw/docs-site/docs/commands/memory/memory-update-full.mdx
Normal file
228
ccw/docs-site/docs/commands/memory/memory-update-full.mdx
Normal file
@@ -0,0 +1,228 @@
|
||||
---
|
||||
title: /memory:update-full
|
||||
sidebar_label: /memory:update-full
|
||||
sidebar_position: 1
|
||||
description: Update CLAUDE.md for all project modules using batched agent execution
|
||||
---
|
||||
|
||||
# /memory:update-full
|
||||
|
||||
Orchestrates comprehensive CLAUDE.md updates for all project modules using batched agent execution with automatic tool fallback.
|
||||
|
||||
## Overview
|
||||
|
||||
The `/memory:update-full` command updates CLAUDE.md documentation for all project modules with intelligent batching and automatic tool fallback (gemini→qwen→codex).
|
||||
|
||||
**Parameters**:
|
||||
- `--tool <gemini|qwen|codex>`: Primary tool (default: gemini)
|
||||
- `--path <directory>`: Target directory (default: project root)
|
||||
|
||||
**Execution Flow**:
|
||||
1. Module Detection → 2. Plan Presentation → 3. Batched Execution → 4. Safety Verification
|
||||
|
||||
## Features
|
||||
|
||||
- **Full Project Coverage** - Updates all modules in the project
|
||||
- **Intelligent Batching** - Groups modules by depth (4 modules/batch)
|
||||
- **Automatic Fallback** - gemini→qwen→codex on failure
|
||||
- **Depth Sequential** - Process depths N→0, parallel batches within depth
|
||||
- **Smart Filtering** - Auto-detects and skips tests/build/config/docs
|
||||
|
||||
## Usage
|
||||
|
||||
```bash
|
||||
# Full project update (auto-strategy selection)
|
||||
/memory:update-full
|
||||
|
||||
# Target specific directory
|
||||
/memory:update-full --path .claude
|
||||
/memory:update-full --path src/features/auth
|
||||
|
||||
# Use specific tool
|
||||
/memory:update-full --tool qwen
|
||||
/memory:update-full --path .claude --tool qwen
|
||||
```
|
||||
|
||||
## Tool Fallback Hierarchy
|
||||
|
||||
```javascript
|
||||
--tool gemini → [gemini, qwen, codex] // default
|
||||
--tool qwen → [qwen, gemini, codex]
|
||||
--tool codex → [codex, gemini, qwen]
|
||||
```
|
||||
|
||||
**Trigger**: Non-zero exit code from update script
|
||||
|
||||
## Execution Modes
|
||||
|
||||
### Small Projects (<15 modules)
|
||||
- **Direct parallel execution**
|
||||
- Max 4 concurrent per depth
|
||||
- No agent overhead
|
||||
- Faster execution
|
||||
|
||||
### Large Projects (>=15 modules)
|
||||
- **Agent batch processing**
|
||||
- 4 modules/agent
|
||||
- 73% overhead reduction
|
||||
- Better resource utilization
|
||||
|
||||
## Execution Flow
|
||||
|
||||
### Phase 1: Module Detection & Analysis
|
||||
|
||||
```javascript
|
||||
// Get module structure
|
||||
Bash({command: "ccw tool exec get_modules_by_depth '{\"format\":\"list\"}'", run_in_background: false});
|
||||
|
||||
// OR with --path
|
||||
Bash({command: "cd <target-path> && ccw tool exec get_modules_by_depth '{\"format\":\"list\"}'", run_in_background: false});
|
||||
```
|
||||
|
||||
**Parse output** `depth:N|path:<PATH>|...` to extract module paths and count.
|
||||
|
||||
**Smart filter**: Auto-detect and skip tests/build/config/docs based on project tech stack.
|
||||
|
||||
### Phase 2: Plan Presentation
|
||||
|
||||
- Parse `--tool` (default: gemini)
|
||||
- Get module structure from workspace
|
||||
- **Smart filter modules** (auto-detect tech stack, skip tests/build/config/docs)
|
||||
- Construct tool fallback order
|
||||
- **Present filtered plan** with skip reasons
|
||||
- **Wait for y/n confirmation**
|
||||
|
||||
### Phase 3A: Direct Execution (<15 modules)
|
||||
|
||||
```javascript
|
||||
for (let depth of sorted_depths.reverse()) { // N → 0
|
||||
let modules = modules_by_depth[depth];
|
||||
let batches = batch_modules(modules, 4);
|
||||
|
||||
for (let batch of batches) {
|
||||
let parallel_tasks = batch.map(module => {
|
||||
return async () => {
|
||||
let strategy = module.depth >= 3 ? "multi-layer" : "single-layer";
|
||||
for (let tool of tool_order) {
|
||||
Bash({
|
||||
command: `cd ${module.path} && ccw tool exec update_module_claude '{"strategy":"${strategy}","path":".","tool":"${tool}"}'`,
|
||||
run_in_background: false
|
||||
});
|
||||
if (bash_result.exit_code === 0) {
|
||||
report(`✅ ${module.path} updated with ${tool}`);
|
||||
return true;
|
||||
}
|
||||
}
|
||||
report(`❌ FAILED: ${module.path} failed all tools`);
|
||||
return false;
|
||||
};
|
||||
});
|
||||
await Promise.all(parallel_tasks.map(task => task()));
|
||||
}
|
||||
}
|
||||
```
|
||||
|
||||
### Phase 3B: Agent Execution (>=15 modules)
|
||||
|
||||
```javascript
|
||||
let modules_by_depth = group_by_depth(all_modules);
|
||||
let tool_order = construct_tool_order(primary_tool);
|
||||
|
||||
for (let depth of sorted_depths.reverse()) { // N → 0
|
||||
let batches = batch_modules(modules_by_depth[depth], 4);
|
||||
let worker_tasks = [];
|
||||
|
||||
for (let batch of batches) {
|
||||
worker_tasks.push(
|
||||
Task(
|
||||
subagent_type="memory-bridge",
|
||||
description=`Update ${batch.length} modules at depth ${depth}`,
|
||||
prompt=generate_batch_worker_prompt(batch, tool_order, "full")
|
||||
)
|
||||
);
|
||||
}
|
||||
|
||||
await parallel_execute(worker_tasks); // Batches run in parallel
|
||||
}
|
||||
```
|
||||
|
||||
### Phase 4: Safety Verification
|
||||
|
||||
- Verify only CLAUDE.md files were modified
|
||||
- Display git diff statistics
|
||||
- Show summary of updates
|
||||
|
||||
## Strategy Selection
|
||||
|
||||
| Module Depth | Strategy | Description |
|
||||
|--------------|----------|-------------|
|
||||
| Depth < 3 | single-layer | Updates only current module's CLAUDE.md |
|
||||
| Depth >= 3 | multi-layer | Updates current module + all parent CLAUDE.md files |
|
||||
|
||||
## Comparison with Related Update
|
||||
|
||||
| Aspect | Full Update | Related Update |
|
||||
|--------|-------------|----------------|
|
||||
| **Scope** | All project modules | Changed modules only |
|
||||
| **Speed** | Slower (10-30 min) | Fast (minutes) |
|
||||
| **Use case** | Major refactoring | Daily development |
|
||||
| **Mode** | `"full"` | `"related"` |
|
||||
| **Trigger** | After major changes | After commits |
|
||||
| **Batching** | 4 modules/agent | 4 modules/agent |
|
||||
| **Fallback** | gemini→qwen→codex | gemini→qwen→codex |
|
||||
| **Complexity threshold** | <=20 modules | <=15 modules |
|
||||
|
||||
## Examples
|
||||
|
||||
### Basic Usage
|
||||
|
||||
```bash
|
||||
# Full project update
|
||||
/memory:update-full
|
||||
|
||||
# Output:
|
||||
# Analyzing workspace...
|
||||
# Found 45 modules across 8 depth levels
|
||||
# Filtered: 12 test/build/config modules skipped
|
||||
# Plan: Update 33 modules with gemini→qwen→codex fallback
|
||||
# Confirm? (y/n): y
|
||||
#
|
||||
# Depth 7: [4/4] ✅
|
||||
# Depth 6: [8/8] ✅
|
||||
# ...
|
||||
# Summary: 33/33 modules updated
|
||||
# Safety check: Only CLAUDE.md modified ✅
|
||||
```
|
||||
|
||||
### Directory-Specific Update
|
||||
|
||||
```bash
|
||||
# Update specific feature directory
|
||||
/memory:update-full --path src/features/auth
|
||||
|
||||
# Only updates modules within src/features/auth
|
||||
```
|
||||
|
||||
### Tool Selection
|
||||
|
||||
```bash
|
||||
# Use Qwen for faster updates
|
||||
/memory:update-full --tool qwen
|
||||
|
||||
# Tries qwen → gemini → codex
|
||||
```
|
||||
|
||||
## Related Commands
|
||||
|
||||
- **/memory:update-related** - Update only changed modules
|
||||
- **/memory:load** - Load project context into memory
|
||||
- **/memory:compact** - Compact session memory
|
||||
|
||||
## Notes
|
||||
|
||||
- **Direct execution** for <15 modules (faster, no agent overhead)
|
||||
- **Agent execution** for >=15 modules (better resource utilization)
|
||||
- **Smart filtering** automatically skips test/build/config directories
|
||||
- **Safety check** ensures only CLAUDE.md files are modified
|
||||
- **Git diff statistics** provide summary of changes
|
||||
- **Automatic backup** of existing files before update
|
||||
230
ccw/docs-site/docs/commands/memory/memory-update-related.mdx
Normal file
230
ccw/docs-site/docs/commands/memory/memory-update-related.mdx
Normal file
@@ -0,0 +1,230 @@
|
||||
---
|
||||
title: /memory:update-related
|
||||
sidebar_label: /memory:update-related
|
||||
sidebar_position: 2
|
||||
description: Update CLAUDE.md for git-changed modules using batched execution
|
||||
---
|
||||
|
||||
# /memory:update-related
|
||||
|
||||
Orchestrates context-aware CLAUDE.md updates for changed modules using batched agent execution with automatic tool fallback.
|
||||
|
||||
## Overview
|
||||
|
||||
The `/memory:update-related` command updates CLAUDE.md documentation only for modules affected by git changes, providing faster updates for daily development.
|
||||
|
||||
**Parameters**:
|
||||
- `--tool <gemini|qwen|codex>`: Primary tool (default: gemini)
|
||||
|
||||
**Execution Flow**:
|
||||
1. Change Detection → 2. Plan Presentation → 3. Batched Execution → 4. Safety Verification
|
||||
|
||||
## Features
|
||||
|
||||
- **Changed Module Detection** - Uses git diff to identify affected modules
|
||||
- **Intelligent Batching** - Groups modules by depth (4 modules/agent)
|
||||
- **Automatic Fallback** - gemini→qwen→codex on failure
|
||||
- **Depth Sequential** - Process depths N→0, parallel batches within depth
|
||||
- **Related Mode** - Update only changed modules and their parent contexts
|
||||
- **Smart Filtering** - Auto-detects and skips tests/build/config/docs
|
||||
|
||||
## Usage
|
||||
|
||||
```bash
|
||||
# Update git-changed modules
|
||||
/memory:update-related
|
||||
|
||||
# Use specific tool
|
||||
/memory:update-related --tool qwen
|
||||
|
||||
# Fallback to recent modules if no changes detected
|
||||
/memory:update-related
|
||||
```
|
||||
|
||||
## Tool Fallback Hierarchy
|
||||
|
||||
```javascript
|
||||
--tool gemini → [gemini, qwen, codex] // default
|
||||
--tool qwen → [qwen, gemini, codex]
|
||||
--tool codex → [codex, gemini, qwen]
|
||||
```
|
||||
|
||||
**Trigger**: Non-zero exit code from update script
|
||||
|
||||
## Execution Modes
|
||||
|
||||
### Small Changes (<15 modules)
|
||||
- **Direct parallel execution**
|
||||
- Max 4 concurrent per depth
|
||||
- No agent overhead
|
||||
|
||||
### Large Changes (>=15 modules)
|
||||
- **Agent batch processing**
|
||||
- 4 modules/agent
|
||||
- Better resource utilization
|
||||
|
||||
## Execution Flow
|
||||
|
||||
### Phase 1: Change Detection & Analysis
|
||||
|
||||
```javascript
|
||||
// Detect changed modules
|
||||
Bash({command: "ccw tool exec detect_changed_modules '{\"format\":\"list\"}'", run_in_background: false});
|
||||
|
||||
// Cache git changes
|
||||
Bash({command: "git add -A 2>/dev/null || true", run_in_background: false});
|
||||
```
|
||||
|
||||
**Parse output** `depth:N|path:<PATH>|change:<TYPE>` to extract affected modules.
|
||||
|
||||
**Smart filter**: Auto-detect and skip tests/build/config/docs based on project tech stack.
|
||||
|
||||
**Fallback**: If no changes detected, use recent modules (first 10 by depth).
|
||||
|
||||
### Phase 2: Plan Presentation
|
||||
|
||||
- Parse `--tool` (default: gemini)
|
||||
- Refresh code index for accurate change detection
|
||||
- Detect changed modules via detect_changed_modules
|
||||
- **Smart filter modules** (auto-detect tech stack, skip tests/build/config/docs)
|
||||
- Cache git changes
|
||||
- Apply fallback if no changes (recent 10 modules)
|
||||
- Construct tool fallback order
|
||||
- **Present filtered plan** with skip reasons and change types
|
||||
- **Wait for y/n confirmation**
|
||||
|
||||
### Phase 3A: Direct Execution (<15 modules)
|
||||
|
||||
```javascript
|
||||
for (let depth of sorted_depths.reverse()) { // N → 0
|
||||
let batches = batch_modules(modules_by_depth[depth], 4);
|
||||
|
||||
for (let batch of batches) {
|
||||
let parallel_tasks = batch.map(module => {
|
||||
return async () => {
|
||||
for (let tool of tool_order) {
|
||||
Bash({
|
||||
command: `cd ${module.path} && ccw tool exec update_module_claude '{"strategy":"single-layer","path":".","tool":"${tool}"}'`,
|
||||
run_in_background: false
|
||||
});
|
||||
if (bash_result.exit_code === 0) {
|
||||
report(`✅ ${module.path} updated with ${tool}`);
|
||||
return true;
|
||||
}
|
||||
}
|
||||
report(`❌ FAILED: ${module.path} failed all tools`);
|
||||
return false;
|
||||
};
|
||||
});
|
||||
await Promise.all(parallel_tasks.map(task => task()));
|
||||
}
|
||||
}
|
||||
```
|
||||
|
||||
### Phase 3B: Agent Execution (>=15 modules)
|
||||
|
||||
```javascript
|
||||
let modules_by_depth = group_by_depth(changed_modules);
|
||||
let tool_order = construct_tool_order(primary_tool);
|
||||
|
||||
for (let depth of sorted_depths.reverse()) { // N → 0
|
||||
let batches = batch_modules(modules_by_depth[depth], 4);
|
||||
let worker_tasks = [];
|
||||
|
||||
for (let batch of batches) {
|
||||
worker_tasks.push(
|
||||
Task(
|
||||
subagent_type="memory-bridge",
|
||||
description=`Update ${batch.length} modules at depth ${depth}`,
|
||||
prompt=generate_batch_worker_prompt(batch, tool_order, "related")
|
||||
)
|
||||
);
|
||||
}
|
||||
|
||||
await parallel_execute(worker_tasks); // Batches run in parallel
|
||||
}
|
||||
```
|
||||
|
||||
### Phase 4: Safety Verification
|
||||
|
||||
- Verify only CLAUDE.md files were modified
|
||||
- Display git diff statistics
|
||||
- Show summary of updates
|
||||
|
||||
## Strategy Selection
|
||||
|
||||
**Related Mode** uses `single-layer` strategy:
|
||||
- Updates only the changed module's CLAUDE.md
|
||||
- Faster than full update's multi-layer approach
|
||||
- Suitable for iterative development
|
||||
|
||||
## Comparison with Full Update
|
||||
|
||||
| Aspect | Related Update | Full Update |
|
||||
|--------|----------------|-------------|
|
||||
| **Scope** | Changed modules only | All project modules |
|
||||
| **Speed** | Fast (minutes) | Slower (10-30 min) |
|
||||
| **Use case** | Daily development | Major refactoring |
|
||||
| **Mode** | `"related"` | `"full"` |
|
||||
| **Trigger** | After commits | After major changes |
|
||||
| **Batching** | 4 modules/agent | 4 modules/agent |
|
||||
| **Fallback** | gemini→qwen→codex | gemini→qwen→codex |
|
||||
| **Complexity threshold** | <=15 modules | <=20 modules |
|
||||
| **Strategy** | single-layer only | multi-layer for depth>=3 |
|
||||
|
||||
## Examples
|
||||
|
||||
### Basic Usage
|
||||
|
||||
```bash
|
||||
# Update changed modules after commits
|
||||
/memory:update-related
|
||||
|
||||
# Output:
|
||||
# Detecting git changes...
|
||||
# Found 8 changed modules
|
||||
# Filtered: 3 test modules skipped
|
||||
# Plan: Update 5 modules with gemini→qwen→codex fallback
|
||||
# Confirm? (y/n): y
|
||||
#
|
||||
# Depth 3: [4/4] ✅
|
||||
# Depth 2: [1/1] ✅
|
||||
# Summary: 5/5 modules updated
|
||||
# Safety check: Only CLAUDE.md modified ✅
|
||||
```
|
||||
|
||||
### Tool Selection
|
||||
|
||||
```bash
|
||||
# Use Qwen for faster updates
|
||||
/memory:update-related --tool qwen
|
||||
|
||||
# Tries qwen → gemini → codex
|
||||
```
|
||||
|
||||
### No Changes Detected
|
||||
|
||||
```bash
|
||||
# When no git changes found
|
||||
/memory:update-related
|
||||
|
||||
# Output:
|
||||
# No git changes detected, using recent 10 modules
|
||||
# Plan: Update recent modules
|
||||
```
|
||||
|
||||
## Related Commands
|
||||
|
||||
- **/memory:update-full** - Update all project modules
|
||||
- **/memory:load** - Load project context into memory
|
||||
- **/memory:compact** - Compact session memory
|
||||
|
||||
## Notes
|
||||
|
||||
- **Direct execution** for <15 modules (faster, no agent overhead)
|
||||
- **Agent execution** for >=15 modules (better resource utilization)
|
||||
- **Smart filtering** automatically skips test/build/config directories
|
||||
- **Change detection** uses git diff to find affected modules
|
||||
- **Fallback** to recent modules when no changes detected
|
||||
- **Safety check** ensures only CLAUDE.md files are modified
|
||||
- **Git diff statistics** provide summary of changes
|
||||
Reference in New Issue
Block a user