Adding cartography - #87
Conversation
Greptile OverviewGreptile SummaryAdds a new "cartography" custom skill for repository mapping and hierarchical codemap generation. The PR introduces infrastructure for bundled custom skills (distinct from npx-installed recommended skills) and implements a Python-based tool that tracks file changes and generates empty codemap templates. Key Changes:
Issues Found:
Confidence Score: 3/5
Important Files Changed
Sequence DiagramsequenceDiagram
participant User
participant Installer as install.ts
participant CustomSkills as custom-skills.ts
participant FileSystem as File System
participant Cartographer as cartographer.py
User->>Installer: Run installation
Installer->>Installer: Ask "Install custom skills?"
User->>Installer: Yes
Installer->>CustomSkills: installCustomSkill(cartography, projectRoot)
CustomSkills->>FileSystem: Check source exists at src/skills/cartography
FileSystem-->>CustomSkills: Source exists
CustomSkills->>CustomSkills: copyDirRecursive()
CustomSkills->>FileSystem: Copy to ~/.config/opencode/skills/cartography
FileSystem-->>CustomSkills: Copy complete
CustomSkills-->>Installer: Installation succeeded
Installer-->>User: Custom skills installed
Note over User,Cartographer: Later: User invokes cartography skill
User->>Cartographer: python cartographer.py init --root /repo --include "src/**/*.ts"
Cartographer->>FileSystem: Load .gitignore patterns
Cartographer->>FileSystem: Scan repository with rglob("*")
Cartographer->>Cartographer: Filter files by include/exclude patterns
Cartographer->>Cartographer: Compute MD5 hashes for each file
Cartographer->>Cartographer: Compute folder hashes
Cartographer->>FileSystem: Save .slim/cartography.json
Cartographer->>FileSystem: Create empty codemap.md in each folder
Cartographer-->>User: Initialization complete
|
| export const CUSTOM_SKILLS: CustomSkill[] = [ | ||
| { | ||
| name: 'cartography', | ||
| description: 'Repository understanding and hierarchical codemap generation', | ||
| allowedAgents: ['orchestrator'], | ||
| sourcePath: 'src/skills/cartography', | ||
| }, |
There was a problem hiding this comment.
allowedAgents field is defined but never used. Unlike RECOMMENDED_SKILLS in skills.ts, custom skills don't integrate with getSkillPermissionsForAgent() in src/agents/index.ts:58. This means the cartography skill won't be automatically granted to the orchestrator agent.
Prompt To Fix With AI
This is a comment left during a code review.
Path: src/cli/custom-skills.ts
Line: 23:29
Comment:
`allowedAgents` field is defined but never used. Unlike `RECOMMENDED_SKILLS` in `skills.ts`, custom skills don't integrate with `getSkillPermissionsForAgent()` in `src/agents/index.ts:58`. This means the cartography skill won't be automatically granted to the orchestrator agent.
How can I resolve this? If you propose a fix, please make it concise.| if "**" in pattern: | ||
| # Convert ** to work with fnmatch | ||
| parts = pattern.split("**") | ||
| if len(parts) == 2 and parts[0] == "" and parts[1].startswith("/"): | ||
| # Pattern like **/foo matches foo anywhere | ||
| suffix = parts[1][1:] # Remove leading / | ||
| if fnmatch(path, f"*{suffix}") or fnmatch(path, f"*/{suffix}"): | ||
| return True | ||
| elif fnmatch(path, pattern.replace("**", "*")): | ||
| return True | ||
| elif fnmatch(path, pattern) or fnmatch(os.path.basename(path), pattern): | ||
| return True | ||
| return False |
There was a problem hiding this comment.
The ** glob pattern matching logic is incomplete. Patterns like src/**/*.ts won't correctly match nested files because fnmatch doesn't natively support **. Consider using pathlib.Path.match() or the wcmatch library for proper recursive glob matching.
Prompt To Fix With AI
This is a comment left during a code review.
Path: src/skills/cartography/scripts/cartographer.py
Line: 57:69
Comment:
The `**` glob pattern matching logic is incomplete. Patterns like `src/**/*.ts` won't correctly match nested files because `fnmatch` doesn't natively support `**`. Consider using `pathlib.Path.match()` or the `wcmatch` library for proper recursive glob matching.
How can I resolve this? If you propose a fix, please make it concise.e59ef77 to
5289634
Compare
Summary
Changes