fix(mcp): slim instructions to <2KB, enrich tool descriptions, add IDs to hook#139
fix(mcp): slim instructions to <2KB, enrich tool descriptions, add IDs to hook#139
Conversation
…s to hook
mcpInstructions was 3,232 bytes — Claude Code truncates at 2KB,
silently dropping the Project IDs, Cross-Project, and Tasks sections.
Changes:
- Slim instructions from 3,232 to 1,625 bytes (under 2KB limit)
- Move category list, importance scale to ghost_memory_save description
- Add concrete examples to 5 most-used tool descriptions
- Add FTS5 syntax examples to search query jsonschema
- Improve all project_id jsonschema tags with examples
- Add explicit project_id anchor to hook output header
- Include memory IDs and task IDs in hook output
- Show memory count in hook ("25 shown")
- Add cross-project save guidance to instructions
- Fix priority zero-value bug: omitted priority now defaults to P2
(was silently P0 critical due to Go int zero value)
|
Caution Review failedPull request was closed or merged during review 📝 WalkthroughWalkthroughSessionStart hook output and session-context loading were changed: the hook emits a "## Ghost context" header with project_id guidance and reformats memories/tasks to include truncated IDs; loadSessionContext now returns memories and tasks tuples with added ID/description elements. MCP server instructions and tool schemas were updated; task priority became optional. Changes
Estimated code review effort🎯 3 (Moderate) | ⏱️ ~20 minutes Possibly related PRs
Poem
🚥 Pre-merge checks | ✅ 2 | ❌ 1❌ Failed checks (1 warning)
✅ Passed checks (2 passed)
✏️ Tip: You can configure your own custom pre-merge checks in the settings. ✨ Finishing Touches📝 Generate docstrings
🧪 Generate unit tests (beta)
Thanks for using CodeRabbit! It's free for OSS, and your support helps us grow. If you like it, consider giving us a shout-out. Comment |
There was a problem hiding this comment.
Actionable comments posted: 1
🤖 Prompt for all review comments with AI agents
Verify each finding against the current code and only fix it if needed.
Inline comments:
In `@internal/mcpinit/hook.go`:
- Line 62: The code is slicing IDs with m[0][:8] (seen in the fmt.Fprintf call
that formats "- [%s] `%s` %s\n") which will panic for IDs shorter than 8; update
both occurrences (the one using m[1], m[0][:8], m[2] and the similar occurrence
around line 198) to safely compute a prefix: if len(m[0]) >= 8 use m[0][:8] else
use m[0] (or a small helper like shortID(id string) string) and use that value
in the fmt.Fprintf calls so short IDs do not cause runtime panics.
🪄 Autofix (Beta)
Fix all unresolved CodeRabbit comments on this PR:
- Push a commit to this branch (recommended)
- Create a new PR with the fixes
ℹ️ Review info
⚙️ Run configuration
Configuration used: defaults
Review profile: CHILL
Plan: Pro
Run ID: d17b37d9-97f7-41de-af61-92b3d7d87561
📒 Files selected for processing (2)
internal/mcpinit/hook.gointernal/mcpserver/mcpserver.go
Problem
mcpInstructionswas 3,232 bytes. Claude Code truncates at 2KB, silently dropping the Project IDs, Cross-Project, and Tasks sections. This is why Claude never knows how to handle project_id or cross-project saves.Changes
Instructions (3,232 → 1,625 bytes):
ghost_memory_savedescriptionTool descriptions:
'ghost', 'infra')Hook output:
Use project_id: "ghost" for all ghost_* tool calls.[architecture] \6BDC098A` ...`)[active] \F2A46791` P3 ...`)Bug fix:
ghost_task_createpriority defaulted to P0 (critical) when omitted due to Go int zero value. Now uses*intpointer, defaults to P2 (normal).Test plan
go test ./...— all passSummary by CodeRabbit
New Features
Improvements