claude-self-reflect 2.5.7 → 2.5.9
This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
- package/mcp-server/pyproject.toml +1 -1
- package/mcp-server/run-mcp.sh +4 -0
- package/mcp-server/src/server.py +44 -40
- package/mcp-server/src/utils.py +34 -1
- package/package.json +1 -1
package/mcp-server/run-mcp.sh
CHANGED
|
@@ -1,6 +1,10 @@
|
|
|
1
1
|
#!/bin/bash
|
|
2
2
|
# Run the Python MCP server using FastMCP
|
|
3
3
|
|
|
4
|
+
# CRITICAL: Capture the original working directory before changing it
|
|
5
|
+
# This is where Claude Code is actually running from
|
|
6
|
+
export MCP_CLIENT_CWD="$PWD"
|
|
7
|
+
|
|
4
8
|
# Get the directory of this script
|
|
5
9
|
SCRIPT_DIR="$( cd "$( dirname "${BASH_SOURCE[0]}" )" && pwd )"
|
|
6
10
|
|
package/mcp-server/src/server.py
CHANGED
|
@@ -192,9 +192,14 @@ async def reflect_on_past(
|
|
|
192
192
|
|
|
193
193
|
# Determine project scope
|
|
194
194
|
target_project = project
|
|
195
|
+
|
|
196
|
+
# Always get the working directory for logging purposes
|
|
197
|
+
cwd = os.environ.get('MCP_CLIENT_CWD', os.getcwd())
|
|
198
|
+
|
|
195
199
|
if project is None:
|
|
196
|
-
#
|
|
197
|
-
|
|
200
|
+
# Use MCP_CLIENT_CWD environment variable set by run-mcp.sh
|
|
201
|
+
# This contains the actual working directory where Claude Code is running
|
|
202
|
+
|
|
198
203
|
# Extract project name from path (e.g., /Users/.../projects/project-name)
|
|
199
204
|
path_parts = Path(cwd).parts
|
|
200
205
|
if 'projects' in path_parts:
|
|
@@ -220,6 +225,7 @@ async def reflect_on_past(
|
|
|
220
225
|
pass # We'll handle this differently in the filtering logic
|
|
221
226
|
|
|
222
227
|
await ctx.debug(f"Searching for: {query}")
|
|
228
|
+
await ctx.debug(f"Client working directory: {cwd}")
|
|
223
229
|
await ctx.debug(f"Project scope: {target_project if target_project != 'all' else 'all projects'}")
|
|
224
230
|
await ctx.debug(f"Decay enabled: {should_use_decay}")
|
|
225
231
|
await ctx.debug(f"Native decay mode: {USE_NATIVE_DECAY}")
|
|
@@ -741,18 +747,17 @@ async def quick_search(
|
|
|
741
747
|
project: Optional[str] = Field(default=None, description="Search specific project only. If not provided, searches current project based on working directory. Use 'all' to search across all projects.")
|
|
742
748
|
) -> str:
|
|
743
749
|
"""Quick search that returns only the count and top result for fast overview."""
|
|
744
|
-
|
|
745
|
-
|
|
746
|
-
|
|
747
|
-
|
|
748
|
-
|
|
749
|
-
|
|
750
|
-
|
|
751
|
-
|
|
752
|
-
|
|
753
|
-
|
|
754
|
-
|
|
755
|
-
)
|
|
750
|
+
# MCP architectural limitation: MCP tools cannot call other MCP tools
|
|
751
|
+
return """<error>
|
|
752
|
+
MCP Architectural Limitation: This tool cannot directly call other MCP tools.
|
|
753
|
+
|
|
754
|
+
To perform a quick search, please:
|
|
755
|
+
1. Call reflect_on_past directly with limit=1 and brief=True
|
|
756
|
+
2. Or use the reflection-specialist agent for quick searches
|
|
757
|
+
|
|
758
|
+
This limitation exists because MCP tools can only be orchestrated by the client (Claude),
|
|
759
|
+
not by other tools within the MCP server.
|
|
760
|
+
</error>"""
|
|
756
761
|
|
|
757
762
|
# Parse and reformat for quick overview
|
|
758
763
|
import re
|
|
@@ -792,17 +797,20 @@ async def search_summary(
|
|
|
792
797
|
project: Optional[str] = Field(default=None, description="Search specific project only. If not provided, searches current project based on working directory. Use 'all' to search across all projects.")
|
|
793
798
|
) -> str:
|
|
794
799
|
"""Get aggregated insights from search results without individual result details."""
|
|
795
|
-
#
|
|
796
|
-
|
|
797
|
-
|
|
798
|
-
|
|
799
|
-
|
|
800
|
-
|
|
801
|
-
|
|
802
|
-
|
|
803
|
-
|
|
804
|
-
|
|
805
|
-
|
|
800
|
+
# MCP architectural limitation: MCP tools cannot call other MCP tools
|
|
801
|
+
# This is a fundamental constraint of the MCP protocol
|
|
802
|
+
return """<error>
|
|
803
|
+
MCP Architectural Limitation: This tool cannot directly call other MCP tools.
|
|
804
|
+
|
|
805
|
+
To get a search summary, please use the reflection-specialist agent instead:
|
|
806
|
+
1. Call the reflection-specialist agent
|
|
807
|
+
2. Ask it to provide a summary of search results for your query
|
|
808
|
+
|
|
809
|
+
Alternative: Call reflect_on_past directly and analyze the results yourself.
|
|
810
|
+
|
|
811
|
+
This limitation exists because MCP tools can only be orchestrated by the client (Claude),
|
|
812
|
+
not by other tools within the MCP server.
|
|
813
|
+
</error>"""
|
|
806
814
|
|
|
807
815
|
# Parse results for summary generation
|
|
808
816
|
import re
|
|
@@ -866,21 +874,17 @@ async def get_more_results(
|
|
|
866
874
|
project: Optional[str] = Field(default=None, description="Search specific project only")
|
|
867
875
|
) -> str:
|
|
868
876
|
"""Get additional search results after an initial search (pagination support)."""
|
|
869
|
-
#
|
|
870
|
-
|
|
871
|
-
|
|
872
|
-
|
|
873
|
-
|
|
874
|
-
|
|
875
|
-
|
|
876
|
-
|
|
877
|
-
|
|
878
|
-
|
|
879
|
-
|
|
880
|
-
response_format="xml",
|
|
881
|
-
brief=False,
|
|
882
|
-
include_raw=False
|
|
883
|
-
)
|
|
877
|
+
# MCP architectural limitation: MCP tools cannot call other MCP tools
|
|
878
|
+
return """<error>
|
|
879
|
+
MCP Architectural Limitation: This tool cannot directly call other MCP tools.
|
|
880
|
+
|
|
881
|
+
To get more search results, please:
|
|
882
|
+
1. Call reflect_on_past directly with a higher limit parameter
|
|
883
|
+
2. Or use the reflection-specialist agent to handle pagination
|
|
884
|
+
|
|
885
|
+
This limitation exists because MCP tools can only be orchestrated by the client (Claude),
|
|
886
|
+
not by other tools within the MCP server.
|
|
887
|
+
</error>"""
|
|
884
888
|
|
|
885
889
|
# Parse and extract only the additional results
|
|
886
890
|
import re
|
package/mcp-server/src/utils.py
CHANGED
|
@@ -3,6 +3,30 @@
|
|
|
3
3
|
from pathlib import Path
|
|
4
4
|
|
|
5
5
|
|
|
6
|
+
def path_to_dash_encoded(path: str) -> str:
|
|
7
|
+
"""
|
|
8
|
+
Convert a file path to dash-encoded format used in Claude logs.
|
|
9
|
+
|
|
10
|
+
Examples:
|
|
11
|
+
- /Users/kyle/projects/my-app -> -Users-kyle-projects-my-app
|
|
12
|
+
- /home/user/Code/project -> -home-user-Code-project
|
|
13
|
+
|
|
14
|
+
Args:
|
|
15
|
+
path: File system path
|
|
16
|
+
|
|
17
|
+
Returns:
|
|
18
|
+
Dash-encoded path string
|
|
19
|
+
"""
|
|
20
|
+
# Convert to Path object and get parts
|
|
21
|
+
path_obj = Path(path)
|
|
22
|
+
|
|
23
|
+
# Remove empty parts and join with dashes
|
|
24
|
+
parts = [p for p in path_obj.parts if p and p != '/']
|
|
25
|
+
|
|
26
|
+
# Join with dashes and add leading dash
|
|
27
|
+
return '-' + '-'.join(parts)
|
|
28
|
+
|
|
29
|
+
|
|
6
30
|
def normalize_project_name(project_path: str) -> str:
|
|
7
31
|
"""
|
|
8
32
|
Normalize project name for consistent hashing across import/search.
|
|
@@ -65,8 +89,17 @@ def normalize_project_name(project_path: str) -> str:
|
|
|
65
89
|
# Handle regular paths - if it's a file, get the parent directory
|
|
66
90
|
# Otherwise use the directory/project name itself
|
|
67
91
|
if path_obj.suffix: # It's a file (has an extension)
|
|
68
|
-
#
|
|
92
|
+
# Check if .claude is anywhere in the parent path
|
|
93
|
+
for parent in path_obj.parents:
|
|
94
|
+
if parent.name == '.claude' and parent.parent:
|
|
95
|
+
return parent.parent.name
|
|
96
|
+
# No .claude found, use immediate parent
|
|
69
97
|
return path_obj.parent.name
|
|
70
98
|
else:
|
|
99
|
+
# Check if any parent in the path is .claude
|
|
100
|
+
for parent in [path_obj] + list(path_obj.parents):
|
|
101
|
+
if parent.name == '.claude' and parent.parent:
|
|
102
|
+
# Return the parent of .claude (the project directory)
|
|
103
|
+
return parent.parent.name
|
|
71
104
|
# Use the directory name itself
|
|
72
105
|
return path_obj.name
|