diff --git a/superclaude/context/__init__.py b/superclaude/context/__init__.py new file mode 100644 index 0000000..d262a9a --- /dev/null +++ b/superclaude/context/__init__.py @@ -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"] diff --git a/superclaude/core/pm_init/context_contract.py b/superclaude/context/contract.py similarity index 100% rename from superclaude/core/pm_init/context_contract.py rename to superclaude/context/contract.py diff --git a/superclaude/core/pm_init/init_hook.py b/superclaude/context/init.py similarity index 92% rename from superclaude/core/pm_init/init_hook.py rename to superclaude/context/init.py index bcbccf7..43aa341 100644 --- a/superclaude/core/pm_init/init_hook.py +++ b/superclaude/context/init.py @@ -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 2. Generate Context Contract 3. Load Reflexion Memory -4. Set up PM Mode as default +4. Set up project context """ import os @@ -13,8 +13,8 @@ from pathlib import Path from typing import Optional, Dict, Any import yaml -from .context_contract import ContextContract -from .reflexion_memory import ReflexionMemory +from .contract import ContextContract +from superclaude.memory import ReflexionMemory 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: cwd: Current working directory (defaults to os.getcwd()) diff --git a/superclaude/core/MOVED.md b/superclaude/core/MOVED.md deleted file mode 100644 index 788e453..0000000 --- a/superclaude/core/MOVED.md +++ /dev/null @@ -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. diff --git a/superclaude/core/__init__.py b/superclaude/core/__init__.py deleted file mode 100644 index e69de29..0000000 diff --git a/superclaude/core/pm_init/__init__.py b/superclaude/core/pm_init/__init__.py deleted file mode 100644 index 96afd18..0000000 --- a/superclaude/core/pm_init/__init__.py +++ /dev/null @@ -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"] diff --git a/superclaude/memory/__init__.py b/superclaude/memory/__init__.py new file mode 100644 index 0000000..9e15a1b --- /dev/null +++ b/superclaude/memory/__init__.py @@ -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"] diff --git a/superclaude/core/pm_init/reflexion_memory.py b/superclaude/memory/reflexion.py similarity index 91% rename from superclaude/core/pm_init/reflexion_memory.py rename to superclaude/memory/reflexion.py index aee7773..b206c2e 100644 --- a/superclaude/core/pm_init/reflexion_memory.py +++ b/superclaude/memory/reflexion.py @@ -115,6 +115,9 @@ class ReflexionMemory: """Add new reflexion entry""" self.entries.append(entry) + # Ensure directory exists + self.memory_path.parent.mkdir(parents=True, exist_ok=True) + # Append to JSONL file with open(self.memory_path, "a") as f: f.write(json.dumps(entry.to_dict()) + "\n") @@ -127,9 +130,13 @@ class ReflexionMemory: for entry in self.entries: entry_keywords = set(entry.mistake.lower().split()) - # If >50% keyword overlap, consider similar - overlap = len(keywords & entry_keywords) / len(keywords | entry_keywords) - if overlap > 0.5: + union = keywords | entry_keywords + # Avoid division by zero + 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) return sorted(similar, key=lambda e: e.timestamp, reverse=True)