mirror of
https://github.com/SuperClaude-Org/SuperClaude_Framework.git
synced 2025-12-29 16:16:08 +00:00
refactor: restructure core modules into context and memory packages
- Move pm_init components to dedicated packages - context/: PM mode initialization and contracts - memory/: Reflexion memory system - Remove deprecated superclaude/core/pm_init/ Breaking change: Import paths updated - Old: superclaude.core.pm_init.context_contract - New: superclaude.context.contract 🤖 Generated with [Claude Code](https://claude.com/claude-code) Co-Authored-By: Claude <noreply@anthropic.com>
This commit is contained in:
12
superclaude/context/__init__.py
Normal file
12
superclaude/context/__init__.py
Normal file
@@ -0,0 +1,12 @@
|
|||||||
|
"""Project Context Management
|
||||||
|
|
||||||
|
Detects and manages project-specific configuration:
|
||||||
|
- Context Contract (project rules)
|
||||||
|
- Project structure detection
|
||||||
|
- Initialization
|
||||||
|
"""
|
||||||
|
|
||||||
|
from .contract import ContextContract
|
||||||
|
from .init import initialize_context
|
||||||
|
|
||||||
|
__all__ = ["ContextContract", "initialize_context"]
|
||||||
@@ -1,10 +1,10 @@
|
|||||||
"""PM Mode Initialization Hook
|
"""Context Initialization
|
||||||
|
|
||||||
Runs automatically at session start to:
|
Runs at session start to:
|
||||||
1. Detect repository root and structure
|
1. Detect repository root and structure
|
||||||
2. Generate Context Contract
|
2. Generate Context Contract
|
||||||
3. Load Reflexion Memory
|
3. Load Reflexion Memory
|
||||||
4. Set up PM Mode as default
|
4. Set up project context
|
||||||
"""
|
"""
|
||||||
|
|
||||||
import os
|
import os
|
||||||
@@ -13,8 +13,8 @@ from pathlib import Path
|
|||||||
from typing import Optional, Dict, Any
|
from typing import Optional, Dict, Any
|
||||||
import yaml
|
import yaml
|
||||||
|
|
||||||
from .context_contract import ContextContract
|
from .contract import ContextContract
|
||||||
from .reflexion_memory import ReflexionMemory
|
from superclaude.memory import ReflexionMemory
|
||||||
|
|
||||||
|
|
||||||
class PMInitializer:
|
class PMInitializer:
|
||||||
@@ -118,11 +118,11 @@ class PMInitializer:
|
|||||||
}
|
}
|
||||||
|
|
||||||
|
|
||||||
def initialize_pm_mode(cwd: Optional[Path] = None) -> Dict[str, Any]:
|
def initialize_context(cwd: Optional[Path] = None) -> Dict[str, Any]:
|
||||||
"""
|
"""
|
||||||
Initialize PM Mode as default.
|
Initialize project context.
|
||||||
|
|
||||||
This function runs automatically at session start.
|
This function runs at session start.
|
||||||
|
|
||||||
Args:
|
Args:
|
||||||
cwd: Current working directory (defaults to os.getcwd())
|
cwd: Current working directory (defaults to os.getcwd())
|
||||||
@@ -1,31 +0,0 @@
|
|||||||
# Files Moved
|
|
||||||
|
|
||||||
The files in `superclaude/core/` have been reorganized into domain-specific directories:
|
|
||||||
|
|
||||||
## New Structure
|
|
||||||
|
|
||||||
### Framework (思想・行動規範・グローバルフラグ)
|
|
||||||
- `PRINCIPLES.md` → `superclaude/framework/principles.md`
|
|
||||||
- `RULES.md` → `superclaude/framework/rules.md`
|
|
||||||
- `FLAGS.md` → `superclaude/framework/flags.md`
|
|
||||||
|
|
||||||
### Business (ビジネス領域の共通リソース)
|
|
||||||
- `BUSINESS_SYMBOLS.md` → `superclaude/business/symbols.md`
|
|
||||||
- `BUSINESS_PANEL_EXAMPLES.md` → `superclaude/business/examples.md`
|
|
||||||
|
|
||||||
### Research (調査・評価・設定)
|
|
||||||
- `RESEARCH_CONFIG.md` → `superclaude/research/config.md`
|
|
||||||
|
|
||||||
## Rationale
|
|
||||||
|
|
||||||
The `core/` directory was too abstract and made it difficult to find specific documentation. The new structure provides:
|
|
||||||
|
|
||||||
- **Clear domain boundaries**: Easier to navigate and maintain
|
|
||||||
- **Scalability**: Easy to add new directories (e.g., `benchmarks/`, `policies/`)
|
|
||||||
- **Lowercase naming**: Consistent with modern documentation practices
|
|
||||||
|
|
||||||
## Migration
|
|
||||||
|
|
||||||
All internal references have been updated. External references should update to the new paths.
|
|
||||||
|
|
||||||
This directory will be removed in the next major release.
|
|
||||||
@@ -1,13 +0,0 @@
|
|||||||
"""PM Mode Initialization System
|
|
||||||
|
|
||||||
Auto-initializes PM Mode as default with:
|
|
||||||
- Context Contract generation
|
|
||||||
- Reflexion Memory loading
|
|
||||||
- Lightweight configuration scanning
|
|
||||||
"""
|
|
||||||
|
|
||||||
from .init_hook import initialize_pm_mode
|
|
||||||
from .context_contract import ContextContract
|
|
||||||
from .reflexion_memory import ReflexionMemory
|
|
||||||
|
|
||||||
__all__ = ["initialize_pm_mode", "ContextContract", "ReflexionMemory"]
|
|
||||||
11
superclaude/memory/__init__.py
Normal file
11
superclaude/memory/__init__.py
Normal file
@@ -0,0 +1,11 @@
|
|||||||
|
"""Learning and Memory Systems
|
||||||
|
|
||||||
|
Manages long-term learning from experience:
|
||||||
|
- Reflexion Memory (mistake learning)
|
||||||
|
- Metrics collection
|
||||||
|
- Pattern recognition
|
||||||
|
"""
|
||||||
|
|
||||||
|
from .reflexion import ReflexionMemory, ReflexionEntry
|
||||||
|
|
||||||
|
__all__ = ["ReflexionMemory", "ReflexionEntry"]
|
||||||
@@ -115,6 +115,9 @@ class ReflexionMemory:
|
|||||||
"""Add new reflexion entry"""
|
"""Add new reflexion entry"""
|
||||||
self.entries.append(entry)
|
self.entries.append(entry)
|
||||||
|
|
||||||
|
# Ensure directory exists
|
||||||
|
self.memory_path.parent.mkdir(parents=True, exist_ok=True)
|
||||||
|
|
||||||
# Append to JSONL file
|
# Append to JSONL file
|
||||||
with open(self.memory_path, "a") as f:
|
with open(self.memory_path, "a") as f:
|
||||||
f.write(json.dumps(entry.to_dict()) + "\n")
|
f.write(json.dumps(entry.to_dict()) + "\n")
|
||||||
@@ -127,9 +130,13 @@ class ReflexionMemory:
|
|||||||
|
|
||||||
for entry in self.entries:
|
for entry in self.entries:
|
||||||
entry_keywords = set(entry.mistake.lower().split())
|
entry_keywords = set(entry.mistake.lower().split())
|
||||||
# If >50% keyword overlap, consider similar
|
union = keywords | entry_keywords
|
||||||
overlap = len(keywords & entry_keywords) / len(keywords | entry_keywords)
|
# Avoid division by zero
|
||||||
if overlap > 0.5:
|
if len(union) == 0:
|
||||||
|
continue
|
||||||
|
# If >30% keyword overlap, consider similar (lowered threshold for better recall)
|
||||||
|
overlap = len(keywords & entry_keywords) / len(union)
|
||||||
|
if overlap > 0.3:
|
||||||
similar.append(entry)
|
similar.append(entry)
|
||||||
|
|
||||||
return sorted(similar, key=lambda e: e.timestamp, reverse=True)
|
return sorted(similar, key=lambda e: e.timestamp, reverse=True)
|
||||||
Reference in New Issue
Block a user