mirror of
https://github.com/catlog22/Claude-Code-Workflow.git
synced 2026-02-14 02:42:04 +08:00
refactor(workflow): enhance init command documentation with memory discovery features
This commit is contained in:
@@ -10,12 +10,14 @@ examples:
|
|||||||
# Workflow Init Command (/workflow:init)
|
# Workflow Init Command (/workflow:init)
|
||||||
|
|
||||||
## Overview
|
## Overview
|
||||||
Initializes `.workflow/project.json` with comprehensive project understanding by leveraging **cli-explore-agent** for intelligent analysis.
|
Initializes `.workflow/project.json` with comprehensive project understanding by leveraging **cli-explore-agent** for intelligent analysis and **memory discovery** for SKILL package indexing.
|
||||||
|
|
||||||
**Key Features**:
|
**Key Features**:
|
||||||
- **Intelligent Project Analysis**: Uses cli-explore-agent's Deep Scan mode
|
- **Intelligent Project Analysis**: Uses cli-explore-agent's Deep Scan mode
|
||||||
- **Technology Stack Detection**: Identifies languages, frameworks, build tools
|
- **Technology Stack Detection**: Identifies languages, frameworks, build tools
|
||||||
- **Architecture Overview**: Discovers patterns, layers, key components
|
- **Architecture Overview**: Discovers patterns, layers, key components
|
||||||
|
- **Memory Discovery**: Scans and indexes available SKILL packages
|
||||||
|
- **Smart Recommendations**: Suggests memory commands based on project state
|
||||||
- **One-time Initialization**: Skips if project.json exists (unless --regenerate)
|
- **One-time Initialization**: Skips if project.json exists (unless --regenerate)
|
||||||
|
|
||||||
## Usage
|
## Usage
|
||||||
@@ -246,13 +248,19 @@ Files: ${metrics.total_files}
|
|||||||
LOC: ${metrics.lines_of_code}
|
LOC: ${metrics.lines_of_code}
|
||||||
Complexity: ${metrics.complexity}
|
Complexity: ${metrics.complexity}
|
||||||
|
|
||||||
## Next Steps
|
### Memory Resources
|
||||||
1. Start a workflow: /workflow:plan "feature description"
|
SKILL Packages: ${memory_resources.skills.length}
|
||||||
2. View project state: /workflow:status --project
|
Documentation: ${memory_resources.documentation.length} project(s)
|
||||||
3. View details: cat .workflow/project.json
|
Module Docs: ${memory_resources.module_docs.length} file(s)
|
||||||
|
Gaps: ${memory_resources.gaps.join(', ') || 'none'}
|
||||||
|
|
||||||
|
## Quick Start
|
||||||
|
• /workflow:plan "feature description" - Start new workflow
|
||||||
|
• /workflow:status --project - View project state
|
||||||
|
|
||||||
---
|
---
|
||||||
Project state saved to: .workflow/project.json
|
Project state saved to: .workflow/project.json
|
||||||
|
Memory index updated: ${memory_resources.last_scanned}
|
||||||
```
|
```
|
||||||
|
|
||||||
## Extended project.json Schema
|
## Extended project.json Schema
|
||||||
@@ -321,14 +329,130 @@ Project state saved to: .workflow/project.json
|
|||||||
"last_updated": "2025-01-18T10:00:00Z"
|
"last_updated": "2025-01-18T10:00:00Z"
|
||||||
},
|
},
|
||||||
|
|
||||||
|
"memory_resources": {
|
||||||
|
"skills": [
|
||||||
|
{"name": "claude_dms3", "type": "project_docs", "path": ".claude/skills/claude_dms3"},
|
||||||
|
{"name": "workflow-progress", "type": "workflow_progress", "path": ".claude/skills/workflow-progress"}
|
||||||
|
],
|
||||||
|
"documentation": [
|
||||||
|
{
|
||||||
|
"name": "claude_dms3",
|
||||||
|
"path": ".workflow/docs/claude_dms3",
|
||||||
|
"has_readme": true,
|
||||||
|
"has_architecture": true
|
||||||
|
}
|
||||||
|
],
|
||||||
|
"module_docs": [
|
||||||
|
".claude/commands/workflow/CLAUDE.md",
|
||||||
|
".claude/agents/CLAUDE.md"
|
||||||
|
],
|
||||||
|
"gaps": ["tech_stack"],
|
||||||
|
"last_scanned": "2025-01-18T10:05:00Z"
|
||||||
|
},
|
||||||
|
|
||||||
"_metadata": {
|
"_metadata": {
|
||||||
"initialized_by": "cli-explore-agent",
|
"initialized_by": "cli-explore-agent",
|
||||||
"analysis_timestamp": "2025-01-18T10:00:00Z",
|
"analysis_timestamp": "2025-01-18T10:00:00Z",
|
||||||
"analysis_mode": "deep-scan"
|
"analysis_mode": "deep-scan",
|
||||||
|
"memory_scan_timestamp": "2025-01-18T10:05:00Z"
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
```
|
```
|
||||||
|
|
||||||
|
### Phase 5: Discover Memory Resources
|
||||||
|
|
||||||
|
**Goal**: Scan and index available SKILL packages (memory command products) using agent delegation
|
||||||
|
|
||||||
|
**Invoke general-purpose agent** to discover and catalog all memory products:
|
||||||
|
|
||||||
|
```javascript
|
||||||
|
Task(
|
||||||
|
subagent_type="general-purpose",
|
||||||
|
description="Discover memory resources",
|
||||||
|
prompt=`
|
||||||
|
Discover and index all memory command products: SKILL packages, documentation, and CLAUDE.md files.
|
||||||
|
|
||||||
|
## Discovery Scope
|
||||||
|
1. **SKILL Packages** (.claude/skills/) - Generated by /memory:skill-memory, /memory:tech-research, etc.
|
||||||
|
2. **Documentation** (.workflow/docs/) - Generated by /memory:docs
|
||||||
|
3. **Module Docs** (**/CLAUDE.md) - Generated by /memory:update-full, /memory:update-related
|
||||||
|
|
||||||
|
## Discovery Tasks
|
||||||
|
|
||||||
|
### 1. Scan SKILL Packages
|
||||||
|
- List all directories in .claude/skills/
|
||||||
|
- For each: extract name, classify type, record path
|
||||||
|
- Types: workflow-progress | codemap-* | style-* | tech_stacks | project_docs
|
||||||
|
|
||||||
|
### 2. Scan Documentation
|
||||||
|
- List directories in .workflow/docs/
|
||||||
|
- For each project: name, path, check README.md, ARCHITECTURE.md existence
|
||||||
|
|
||||||
|
### 3. Scan CLAUDE.md Files
|
||||||
|
- Find all **/CLAUDE.md (exclude: node_modules, .git, dist, build)
|
||||||
|
- Return path list only
|
||||||
|
|
||||||
|
### 4. Identify Gaps
|
||||||
|
- No project SKILL? → "project_skill"
|
||||||
|
- No documentation? → "documentation"
|
||||||
|
- Missing tech stack SKILL? → "tech_stack"
|
||||||
|
- No workflow-progress? → "workflow_history"
|
||||||
|
- <10% modules have CLAUDE.md? → "module_docs_low_coverage"
|
||||||
|
|
||||||
|
### 5. Return JSON:
|
||||||
|
{
|
||||||
|
"skills": [
|
||||||
|
{"name": "claude_dms3", "type": "project_docs", "path": ".claude/skills/claude_dms3"},
|
||||||
|
{"name": "workflow-progress", "type": "workflow_progress", "path": ".claude/skills/workflow-progress"}
|
||||||
|
],
|
||||||
|
"documentation": [
|
||||||
|
{
|
||||||
|
"name": "my_project",
|
||||||
|
"path": ".workflow/docs/my_project",
|
||||||
|
"has_readme": true,
|
||||||
|
"has_architecture": true
|
||||||
|
}
|
||||||
|
],
|
||||||
|
"module_docs": [
|
||||||
|
"src/core/CLAUDE.md",
|
||||||
|
"lib/utils/CLAUDE.md"
|
||||||
|
],
|
||||||
|
"gaps": ["tech_stack", "module_docs_low_coverage"]
|
||||||
|
}
|
||||||
|
|
||||||
|
## Context
|
||||||
|
- Project tech stack: ${JSON.stringify(analysis.technology_stack)}
|
||||||
|
- Check .workflow/.archives for session history
|
||||||
|
- If directories missing, return empty state with recommendations
|
||||||
|
`
|
||||||
|
)
|
||||||
|
```
|
||||||
|
|
||||||
|
**Agent Output**: JSON structure with skills, documentation, module_docs, and gaps
|
||||||
|
|
||||||
|
**Update project.json**:
|
||||||
|
```javascript
|
||||||
|
const memoryDiscovery = JSON.parse(agentOutput);
|
||||||
|
|
||||||
|
projectMeta.memory_resources = {
|
||||||
|
...memoryDiscovery,
|
||||||
|
last_scanned: new Date().toISOString()
|
||||||
|
};
|
||||||
|
|
||||||
|
Write('.workflow/project.json', JSON.stringify(projectMeta, null, 2));
|
||||||
|
```
|
||||||
|
|
||||||
|
**Output Summary**:
|
||||||
|
```
|
||||||
|
Memory Resources Indexed:
|
||||||
|
- SKILL Packages: ${skills.length}
|
||||||
|
- Documentation: ${documentation.length} project(s)
|
||||||
|
- Module Docs: ${module_docs.length} file(s)
|
||||||
|
- Gaps: ${gaps.join(', ') || 'none'}
|
||||||
|
```
|
||||||
|
|
||||||
|
---
|
||||||
|
|
||||||
## Regeneration Behavior
|
## Regeneration Behavior
|
||||||
|
|
||||||
When using `--regenerate` flag:
|
When using `--regenerate` flag:
|
||||||
@@ -347,7 +471,9 @@ When using `--regenerate` flag:
|
|||||||
|
|
||||||
3. **Re-run cli-explore-agent analysis**
|
3. **Re-run cli-explore-agent analysis**
|
||||||
|
|
||||||
4. **Merge preserved data with new analysis**:
|
4. **Re-run memory discovery (Phase 5)**
|
||||||
|
|
||||||
|
5. **Merge preserved data with new analysis**:
|
||||||
```javascript
|
```javascript
|
||||||
const newProjectMeta = {
|
const newProjectMeta = {
|
||||||
...analysisResults,
|
...analysisResults,
|
||||||
@@ -356,7 +482,7 @@ When using `--regenerate` flag:
|
|||||||
};
|
};
|
||||||
```
|
```
|
||||||
|
|
||||||
5. **Output**:
|
6. **Output**:
|
||||||
```
|
```
|
||||||
✓ Project analysis regenerated
|
✓ Project analysis regenerated
|
||||||
Backup saved: .workflow/project.json.backup
|
Backup saved: .workflow/project.json.backup
|
||||||
@@ -365,6 +491,7 @@ When using `--regenerate` flag:
|
|||||||
- Technology stack analysis
|
- Technology stack analysis
|
||||||
- Architecture overview
|
- Architecture overview
|
||||||
- Key components discovery
|
- Key components discovery
|
||||||
|
- Memory resources index
|
||||||
|
|
||||||
Preserved:
|
Preserved:
|
||||||
- ${preservedFeatures.length} existing features
|
- ${preservedFeatures.length} existing features
|
||||||
@@ -397,3 +524,41 @@ If not in git repo and empty directory:
|
|||||||
2. Create minimal project.json
|
2. Create minimal project.json
|
||||||
3. Suggest: "Add code files and run /workflow:init --regenerate"
|
3. Suggest: "Add code files and run /workflow:init --regenerate"
|
||||||
```
|
```
|
||||||
|
|
||||||
|
### Memory Discovery Failures
|
||||||
|
|
||||||
|
**Missing Directories**:
|
||||||
|
```
|
||||||
|
If .claude/skills, .workflow/docs, or CLAUDE.md files not found:
|
||||||
|
1. Return empty state for that category
|
||||||
|
2. Mark in gaps.missing array
|
||||||
|
3. Continue initialization
|
||||||
|
```
|
||||||
|
|
||||||
|
**Metadata Read Failures**:
|
||||||
|
```
|
||||||
|
If SKILL.md files are unreadable:
|
||||||
|
1. Include SKILL with basic info: name (from directory), type (inferred), path
|
||||||
|
2. Log warning: "SKILL package {name} has invalid metadata"
|
||||||
|
3. Continue with other SKILLs
|
||||||
|
```
|
||||||
|
|
||||||
|
**Coverage Check Failures**:
|
||||||
|
```
|
||||||
|
If unable to determine module doc coverage:
|
||||||
|
1. Skip adding "module_docs_low_coverage" to gaps
|
||||||
|
2. Continue with other gap checks
|
||||||
|
```
|
||||||
|
|
||||||
|
**Default Empty State**:
|
||||||
|
```json
|
||||||
|
{
|
||||||
|
"memory_resources": {
|
||||||
|
"skills": [],
|
||||||
|
"documentation": [],
|
||||||
|
"module_docs": [],
|
||||||
|
"gaps": ["project_skill", "documentation", "tech_stack", "workflow_history", "module_docs"],
|
||||||
|
"last_scanned": "ISO_TIMESTAMP"
|
||||||
|
}
|
||||||
|
}
|
||||||
|
```
|
||||||
|
|||||||
Reference in New Issue
Block a user