refactor: PEP8 compliance - directory rename and code formatting (#425)

* fix(orchestration): add WebFetch auto-trigger for infrastructure configuration

Problem: Infrastructure configuration changes (e.g., Traefik port settings)
were being made based on assumptions without consulting official documentation,
violating the 'Evidence > assumptions' principle in PRINCIPLES.md.

Solution:
- Added Infrastructure Configuration Validation section to MODE_Orchestration.md
- Auto-triggers WebFetch for infrastructure tools (Traefik, nginx, Docker, etc.)
- Enforces MODE_DeepResearch activation for investigation
- BLOCKS assumption-based configuration changes

Testing: Verified WebFetch successfully retrieves Traefik official docs (port 80 default)

This prevents production outages from infrastructure misconfiguration by ensuring
all technical recommendations are backed by official documentation.

* feat: Add PM Agent (Project Manager Agent) for seamless orchestration

Introduces PM Agent as the default orchestration layer that coordinates
all sub-agents and manages workflows automatically.

Key Features:
- Default orchestration: All user interactions handled by PM Agent
- Auto-delegation: Intelligent sub-agent selection based on task analysis
- Docker Gateway integration: Zero-token baseline with dynamic MCP loading
- Self-improvement loop: Automatic documentation of patterns and mistakes
- Optional override: Users can specify sub-agents explicitly if desired

Architecture:
- Agent spec: SuperClaude/Agents/pm-agent.md
- Command: SuperClaude/Commands/pm.md
- Updated docs: README.md (15→16 agents), agents.md (new Orchestration category)

User Experience:
- Default: PM Agent handles everything (seamless, no manual routing)
- Optional: Explicit --agent flag for direct sub-agent access
- Both modes available simultaneously (no user downside)

Implementation Status:
-  Specification complete
-  Documentation complete
-  Prototype implementation needed
-  Docker Gateway integration needed
-  Testing and validation needed

Refs: kazukinakai/docker-mcp-gateway (IRIS MCP Gateway integration)

* feat: Add Agent Orchestration rules for PM Agent default activation

Implements PM Agent as the default orchestration layer in RULES.md.

Key Changes:
- New 'Agent Orchestration' section (CRITICAL priority)
- PM Agent receives ALL user requests by default
- Manual override with @agent-[name] bypasses PM Agent
- Agent Selection Priority clearly defined:
  1. Manual override → Direct routing
  2. Default → PM Agent → Auto-delegation
  3. Delegation based on keywords, file types, complexity, context

User Experience:
- Default: PM Agent handles everything (seamless)
- Override: @agent-[name] for direct specialist access
- Transparent: PM Agent reports delegation decisions

This establishes PM Agent as the orchestration layer while
respecting existing auto-activation patterns and manual overrides.

Next Steps:
- Local testing in agiletec project
- Iteration based on actual behavior
- Documentation updates as needed

* refactor(pm-agent): redesign as self-improvement meta-layer

Problem Resolution:
PM Agent's initial design competed with existing auto-activation for task routing,
creating confusion about orchestration responsibilities and adding unnecessary complexity.

Design Change:
Redefined PM Agent as a meta-layer agent that operates AFTER specialist agents
complete tasks, focusing on:
- Post-implementation documentation and pattern recording
- Immediate mistake analysis with prevention checklists
- Monthly documentation maintenance and noise reduction
- Pattern extraction and knowledge synthesis

Two-Layer Orchestration System:
1. Task Execution Layer: Existing auto-activation handles task routing (unchanged)
2. Self-Improvement Layer: PM Agent meta-layer handles documentation (new)

Files Modified:
- SuperClaude/Agents/pm-agent.md: Complete rewrite with meta-layer design
  - Category: orchestration → meta
  - Triggers: All user interactions → Post-implementation, mistakes, monthly
  - Behavioral Mindset: Continuous learning system
  - Self-Improvement Workflow: BEFORE/DURING/AFTER/MISTAKE RECOVERY/MAINTENANCE

- SuperClaude/Core/RULES.md: Agent Orchestration section updated
  - Split into Task Execution Layer + Self-Improvement Layer
  - Added orchestration flow diagram
  - Clarified PM Agent activates AFTER task completion

- README.md: Updated PM Agent description
  - "orchestrates all interactions" → "ensures continuous learning"

- Docs/User-Guide/agents.md: PM Agent section rewritten
  - Section: Orchestration Agent → Meta-Layer Agent
  - Expertise: Project orchestration → Self-improvement workflow executor
  - Examples: Task coordination → Post-implementation documentation

- PR_DOCUMENTATION.md: Comprehensive PR documentation added
  - Summary, motivation, changes, testing, breaking changes
  - Two-layer orchestration system diagram
  - Verification checklist

Integration Validated:
Tested with agiletec project's self-improvement-workflow.md:
 PM Agent aligns with existing BEFORE/DURING/AFTER/MISTAKE RECOVERY phases
 Complements (not competes with) existing workflow
 agiletec workflow defines WHAT, PM Agent defines WHO executes it

Breaking Changes: None
- Existing auto-activation continues unchanged
- Specialist agents unaffected
- User workflows remain the same
- New capability: Automatic documentation and knowledge maintenance

Value Proposition:
Transforms SuperClaude into a continuously learning system that accumulates
knowledge, prevents recurring mistakes, and maintains fresh documentation
without manual intervention.

🤖 Generated with [Claude Code](https://claude.com/claude-code)

Co-Authored-By: Claude <noreply@anthropic.com>

* docs: add Claude Code conversation history management research

Research covering .jsonl file structure, performance impact, and retention policies.

Content:
- Claude Code .jsonl file format and message types
- Performance issues from GitHub (memory leaks, conversation compaction)
- Retention policies (consumer vs enterprise)
- Rotation recommendations based on actual data
- File history snapshot tracking mechanics

Source: Moved from agiletec project (research applicable to all Claude Code projects)

🤖 Generated with [Claude Code](https://claude.com/claude-code)

Co-Authored-By: Claude <noreply@anthropic.com>

* feat: add Development documentation structure

Phase 1: Documentation Structure complete

- Add Docs/Development/ directory for development documentation
- Add ARCHITECTURE.md - System architecture with PM Agent meta-layer
- Add ROADMAP.md - 5-phase development plan with checkboxes
- Add TASKS.md - Daily task tracking with progress indicators
- Add PROJECT_STATUS.md - Current status dashboard and metrics
- Add pm-agent-integration.md - Implementation guide for PM Agent mode

This establishes comprehensive documentation foundation for:
- System architecture understanding
- Development planning and tracking
- Implementation guidance
- Progress visibility

Related: #pm-agent-mode #documentation #phase-1

🤖 Generated with [Claude Code](https://claude.com/claude-code)

Co-Authored-By: Claude <noreply@anthropic.com>

* feat: PM Agent session lifecycle and PDCA implementation

Phase 2: PM Agent Mode Integration (Design Phase)

Commands/pm.md updates:
- Add "Always-Active Foundation Layer" concept
- Add Session Lifecycle (Session Start/During Work/Session End)
- Add PDCA Cycle (Plan/Do/Check/Act) automation
- Add Serena MCP Memory Integration (list/read/write_memory)
- Document auto-activation triggers

Agents/pm-agent.md updates:
- Add Session Start Protocol (MANDATORY auto-activation)
- Add During Work PDCA Cycle with example workflows
- Add Session End Protocol with state preservation
- Add PDCA Self-Evaluation Pattern
- Add Documentation Strategy (temp → patterns/mistakes)
- Add Memory Operations Reference

Key Features:
- Session start auto-activation for context restoration
- 30-minute checkpoint saves during work
- Self-evaluation with think_about_* operations
- Systematic documentation lifecycle
- Knowledge evolution to CLAUDE.md

Implementation Status:
-  Design complete (Commands/pm.md, Agents/pm-agent.md)
-  Implementation pending (Core components)
-  Serena MCP integration pending

Salvaged from mistaken development in ~/.claude directory

Related: #pm-agent-mode #session-lifecycle #pdca-cycle #phase-2

🤖 Generated with [Claude Code](https://claude.com/claude-code)

Co-Authored-By: Claude <noreply@anthropic.com>

* fix: disable Serena MCP auto-browser launch

Disable web dashboard and GUI log window auto-launch in Serena MCP server
to prevent intrusive browser popups on startup. Users can still manually
access the dashboard at http://localhost:24282/dashboard/ if needed.

Changes:
- Add CLI flags to Serena run command:
  - --enable-web-dashboard false
  - --enable-gui-log-window false
- Ensures Git-tracked configuration (no reliance on ~/.serena/serena_config.yml)
- Aligns with AIRIS MCP Gateway integration approach

🤖 Generated with [Claude Code](https://claude.com/claude-code)

Co-Authored-By: Claude <noreply@anthropic.com>

* refactor: rename directories to lowercase for PEP8 compliance

- Rename superclaude/Agents -> superclaude/agents
- Rename superclaude/Commands -> superclaude/commands
- Rename superclaude/Core -> superclaude/core
- Rename superclaude/Examples -> superclaude/examples
- Rename superclaude/MCP -> superclaude/mcp
- Rename superclaude/Modes -> superclaude/modes

This change follows Python PEP8 naming conventions for package directories.

* style: fix PEP8 violations and update package name to lowercase

Changes:
- Format all Python files with black (43 files reformatted)
- Update package name from 'SuperClaude' to 'superclaude' in pyproject.toml
- Fix import statements to use lowercase package name
- Add missing imports (timedelta, __version__)
- Remove old SuperClaude.egg-info directory

PEP8 violations reduced from 2672 to 701 (mostly E501 line length due to black's 88 char vs flake8's 79 char limit).

* docs: add PM Agent development documentation

Add comprehensive PM Agent development documentation:
- PM Agent ideal workflow (7-phase autonomous cycle)
- Project structure understanding (Git vs installed environment)
- Installation flow understanding (CommandsComponent behavior)
- Task management system (current-tasks.md)

Purpose: Eliminate repeated explanations and enable autonomous PDCA cycles

🤖 Generated with [Claude Code](https://claude.com/claude-code)

Co-Authored-By: Claude <noreply@anthropic.com>

* feat(pm-agent): add self-correcting execution and warning investigation culture

## Changes

### superclaude/commands/pm.md
- Add "Self-Correcting Execution" section with root cause analysis protocol
- Add "Warning/Error Investigation Culture" section enforcing zero-tolerance for dismissal
- Define error detection protocol: STOP → Investigate → Hypothesis → Different Solution → Execute
- Document anti-patterns (retry without understanding) and correct patterns (research-first)

### docs/Development/hypothesis-pm-autonomous-enhancement-2025-10-14.md
- Add PDCA workflow hypothesis document for PM Agent autonomous enhancement

## Rationale

PM Agent must never retry failed operations without understanding root causes.
All warnings and errors require investigation via context7/WebFetch/documentation
to ensure production-quality code and prevent technical debt accumulation.

🤖 Generated with [Claude Code](https://claude.com/claude-code)

Co-Authored-By: Claude <noreply@anthropic.com>

* feat(installer): add airis-mcp-gateway MCP server option

## Changes

- Add airis-mcp-gateway to MCP server options in installer
- Configuration: GitHub-based installation via uvx
- Repository: https://github.com/oraios/airis-mcp-gateway
- Purpose: Dynamic MCP Gateway for zero-token baseline and on-demand tool loading

## Implementation

Added to setup/components/mcp.py self.mcp_servers dictionary with:
- install_method: github
- install_command: uvx test installation
- run_command: uvx runtime execution
- required: False (optional server)

🤖 Generated with [Claude Code](https://claude.com/claude-code)

Co-Authored-By: Claude <noreply@anthropic.com>

---------

Co-authored-by: kazuki <kazuki@kazukinoMacBook-Air.local>
Co-authored-by: Claude <noreply@anthropic.com>
This commit is contained in:
kazuki nakai
2025-10-14 12:17:09 +09:00
committed by GitHub
parent 302c5851b1
commit 050d5ea2ab
194 changed files with 9698 additions and 3693 deletions

View File

@@ -0,0 +1,310 @@
# 会话管理指南
SuperClaude 通过 Serena MCP 服务器提供持久会话管理,实现在 Claude Code 对话中真正的上下文保存和长期项目连续性。
## 具有持久内存的核心会话命令
### `/sc:load` - 具有持久内存的上下文加载
**目的**:使用项目上下文和以前会话的持久内存初始化会话
**MCP 集成**:触发 Serena MCP 读取存储的项目内存
**语法**`/sc:load [project_path]`
**发生什么**
- Serena MCP 从以前的会话中读取持久内存文件
- 从存储的内存中恢复项目上下文
- 加载以前的决策、模式和进度
- 使用历史上下文初始化会话状态
**使用案例**
```bash
# 从持久内存加载现有项目上下文
/sc:load src/
# 恢复特定项目工作及其完整历史
/sc:load "authentication system"
# 使用代码库分析和先前见解初始化
/sc:load . --analyze
```
### `/sc:save` - 会话持久化到内存
**目的**:将当前会话状态和决策保存到持久内存
**MCP 集成**:触发 Serena MCP 写入内存文件
**语法**`/sc:save "会话描述"`
**发生什么**
- 当前上下文和决策被写入 Serena 内存
- 项目状态和进度在对话中持久保存
- 关键见解和模式被存储以供未来会话使用
- 创建带有时间戳的会话摘要以便检索
**使用案例**
```bash
# 保存已完成的特性工作以供未来参考
/sc:save "user authentication implemented with JWT"
# 复杂工作期间的检查点
/sc:save "API design phase complete, ready for implementation"
# 永久存储架构决策
/sc:save "microservices architecture decided, service boundaries defined"
```
### `/sc:reflect` - 带有内存上下文的进度评估
**目的**:根据存储的内存分析当前进度并验证会话完整性
**MCP 集成**:使用 Serena MCP 将当前状态与存储的内存进行比较
**语法**`/sc:reflect [--scope project|session]`
**发生什么**
- Serena MCP 读取以前的内存和当前上下文
- 根据存储的目标和里程碑评估进度
- 使用历史上下文识别差距和下一步
- 根据项目内存验证会话完整性
**使用案例**
```bash
# 根据存储的里程碑评估项目进度
/sc:reflect --scope project
# 验证当前会话完整性
/sc:reflect
# 根据内存检查是否准备进入下一阶段
/sc:reflect --scope session
```
## 持久内存架构
### Serena MCP 如何实现真正的持久性
**内存存储**
- 会话上下文作为结构化内存文件存储
- 项目决策和架构模式永久保存
- 代码分析结果和见解在对话中保持
- 进度跟踪和里程碑数据长期维护
**跨会话连续性**
- 新对话中自动加载以前的会话上下文
- 决策和理由在对话中保存和可访问
- 从过去的模式和解决方案中学习并维护
- 一致的项目理解无限期维护
**内存类型**
- **项目内存**:长期项目上下文和架构
- **会话内存**:特定对话结果和决策
- **模式内存**:可重用的解决方案和架构模式
- **进度内存**:里程碑跟踪和完成状态
## 具有持久性的会话生命周期模式
### 新项目初始化
```bash
# 1. 开始全新项目
/sc:brainstorm "e-commerce platform requirements"
# 2. 将初始决策保存到持久内存
/sc:save "project scope and requirements defined"
# 3. 开始实现规划
/sc:workflow "user authentication system"
# 4. 永久保存架构决策
/sc:save "authentication architecture: JWT + refresh tokens + rate limiting"
```
### 恢复现有工作(跨对话)
```bash
# 1. 从持久内存加载以前的上下文
/sc:load "e-commerce project"
# 2. 根据存储的进度评估当前状态
/sc:reflect --scope project
# 3. 使用存储的上下文继续下一阶段
/sc:implement "payment processing integration"
# 4. 将进度检查点保存到内存
/sc:save "payment system integrated with Stripe API"
```
### 长期项目管理
```bash
# 具有持久性的周检查点模式
/sc:load project-name
/sc:reflect --scope project
# ... 处理特性 ...
/sc:save "week N progress: features X, Y, Z completed"
# 具有内存的阶段完成模式
/sc:reflect --scope project
/sc:save "phase 1 complete: core authentication and user management"
/sc:workflow "phase 2: payment and order processing"
```
## 跨对话连续性
### 使用持久性开始新对话
当开始新的 Claude Code 对话时,持久内存系统允许:
1. **自动上下文恢复**
```bash
/sc:load project-name
# 自动恢复所有以前的上下文、决策和进度
```
2. **进度继续**
- 以前会话的决策立即可用
- 架构模式和代码见解被保存
- 项目历史和理由被维护
3. **智能上下文构建**
- Serena MCP 根据当前工作提供相关内存
- 过去的解决方案和模式指导新的实现
- 项目演变被跟踪和理解
### 内存优化
**有效的内存使用**
- 使用描述性、可搜索的内存名称
- 包含项目阶段和时间戳上下文
- 引用特定功能或架构决策
- 让未来的检索变得直观
**内存内容策略**
- 存储决策和理由,而不仅仅是结果
- 包含考虑的替代方案
- 记录集成模式和依赖关系
- 为未来参考保留学习和洞察
**内存生命周期管理**
- 定期清理过时的内存
- 整合相关的会话内存
- 归档已完成的项目阶段
- 修剪过时的架构决策
## 持久会话的最佳实践
### 会话开始协议
1. 对于现有项目始终以 `/sc:load` 开始
2. 使用 `/sc:reflect` 从内存中了解当前状态
3. 根据持久上下文和存储的模式规划工作
4. 基于以前的决策和架构选择构建
### 会话结束协议
1. 使用 `/sc:reflect` 根据存储的目标评估完整性
2. 使用 `/sc:save` 保存关键决策以供未来会话
3. 在内存中记录下一步和未解决的问题
4. 为无缝的未来继续保存上下文
### 内存质量维护
- 使用清晰、描述性的内存名称以便于检索
- 包含关于决策和替代方法的上下文
- 引用特定的代码位置和模式
- 在跨会话中保持内存结构的一致性
## 与其他 SuperClaude 功能的集成
### MCP 服务器协调
- **Serena MCP**:提供持久内存基础设施
- **Sequential MCP**:使用存储的内存进行增强的复杂分析
- **Context7 MCP**:引用存储的模式和文档方法
- **Morphllm MCP**:一致地应用存储的重构模式
### 智能体与内存的协作
- 智能体访问持久内存以增强上下文
- 先前的专家决策被保留和引用
- 通过共享内存进行跨会话智能体协调
- 基于项目历史的一致专家建议
### 命令与持久化的集成
- 所有 `/sc:` 命令都可以引用和构建持久上下文
- 先前的命令输出和决策在跨会话中可用
- 工作流程模式被存储和重用
- 实现历史指导未来的命令决策
## 持久会话故障排除
### 常见问题
**内存未加载**
- 验证 Serena MCP 配置正确并正常运行
- 检查内存文件权限和可访问性
- 确保一致的项目命名约定
- 验证内存文件完整性和格式
**会话间上下文丢失**
- 在结束会话前始终使用 `/sc:save`
- 使用描述性内存名称以便于检索
- 定期使用 `/sc:reflect` 验证内存完整性
- 定期备份重要的内存文件
**内存冲突**
- 使用带时间戳的内存名称进行版本控制
- 定期清理过时的内存
- 清楚分离项目和会话内存
- 在跨会话中保持一致的内存命名约定
### 快速修复
**重置会话状态**
```bash
/sc:load --fresh # 不带先前上下文开始
/sc:reflect # 评估当前状态
```
**内存清理**
```bash
/sc:reflect --cleanup # 删除过时的内存
/sc:save --consolidate # 合并相关内存
```
**上下文恢复**
```bash
/sc:load --recent # 加载最近的内存
/sc:reflect --repair # 识别并修复上下文空白
```
## 高级持久会话模式
### 多阶段项目
- 使用阶段特定的内存命名进行组织
- 跨阶段维护架构决策连续性
- 通过持久内存进行跨阶段依赖跟踪
- 具有历史上下文的渐进式复杂性管理
### 团队协作
- 共享的内存约定和命名标准
- 为团队上下文保留决策理由
- 所有团队成员都可访问的集成模式文档
- 通过内存实现一致的代码风格和架构执行
### 长期维护
- 已完成项目的内存归档策略
- 通过累积内存开发模式库
- 随时间建立的可重用解决方案文档
- 通过持久内存积累建立知识库
## 持久会话管理的关键优势
### 项目连续性
- 在多次对话中无缝的工作延续
- Claude Code 会话之间无上下文丢失
- 保留的架构决策和技术理由
- 长期项目演进跟踪
### 提升生产力
- 减少重新解释项目上下文的需要
- 继续工作的更快启动时间
- 基于先前的洞察和模式进行构建
- 累积的项目知识增长
### 质量一致性
- 跨会话的一致架构模式
- 保留的代码质量决策和标准
- 可重用的解决方案和最佳实践
- 维持的技术债务意识
---
**关键要点**:通过 Serena MCP 的会话管理将 SuperClaude 从单次对话帮助转变为持久项目伙伴关系,在所有开发阶段和 Claude Code 对话中维护上下文、决策和学习。