feat: Claude Code + Claw Code patterns transfer#148
Conversation
There was a problem hiding this comment.
💡 Codex Review
Here are some automated review suggestions for this pull request.
Reviewed commit: ef2cb4fe6f
ℹ️ About Codex in GitHub
Your team has set up Codex to review pull requests in this repo. Reviews are triggered when you
- Open a pull request for review
- Mark a draft as ready
- Comment "@codex review".
If Codex has suggestions, it will comment; otherwise it will react with 👍.
Codex can also answer questions or update the PR. Try commenting "@codex address that feedback".
| .replace(/[^a-z0-9s/_-]/g, '') | ||
| .split(/[s/_-]+/) |
There was a problem hiding this comment.
Split prompt tokens on whitespace
The tokenizer regexes use s instead of \s, so prompts are split on the literal letter s rather than whitespace. That means multi-word queries often stay as one token (and words containing s get fragmented), which makes routePrompt miss relevant tools or rank them incorrectly for normal user inputs like "read file" or "show git diff".
Useful? React with 👍 / 👎.
| for (let i = half; i < sorted.length; i++) { | ||
| const f = sorted[i]; |
There was a problem hiding this comment.
Downgrade least-relevant files under token pressure
Because files are sorted ascending by relevance, iterating from half to the end downgrades the most relevant half instead of the least relevant half. Under token pressure this strips detail from the files you most want to preserve, which directly harms answer quality and makes compaction behavior opposite to the intent in the comment.
Useful? React with 👍 / 👎.
| const baseTokens = oldRatio > 0 ? item.tokens / oldRatio : item.tokens; | ||
| const newTokens = Math.max(1, Math.ceil(baseTokens * newRatio)); | ||
| newTotal += newTokens; | ||
| return { ...item, depth: newDepthNumeric, tokens: newTokens }; |
There was a problem hiding this comment.
Recompute packed content after depth adjustment
This updates depth and tokens but keeps the original content, so reactive compaction can report a shallow depth while still sending deeper content to the model. In practice that breaks token-budget assumptions and can exceed context limits because the actual text no longer matches the recalculated token estimate.
Useful? React with 👍 / 👎.
| const hash = JSON.stringify(agents.map(a => a.id).sort()); | ||
| if (!_searchInstance || hash !== _lastIndexHash) { |
There was a problem hiding this comment.
Reindex search when agent metadata changes
The cache key only includes sorted agent IDs, so changes to descriptions, roles, tags, capabilities, or any knowledge source content do not trigger a rebuild. That leaves AgentSearch serving stale TF-IDF scores until reindex() is called manually, which makes search results incorrect after normal metadata edits.
Useful? React with 👍 / 👎.
…ction, memory pipeline, context collapse, tool summary, agent search)
…compaction, memory, collapse, tool summary, search
…nner, E2E tests - Task 1: SystemPromptBuilder wired into systemFrameBuilder (buildSystemFrameOptimized) - Task 2: ReactiveCompaction wired into packer (packContextReactive) - Task 3: MemoryStore wired into contextAssembler (assemblePipelineContextWithMemory) - Task 4: ContextMiddleware wired into pipeline (middleware option) - Task 5: AgentSearch endpoint added to agents route (GET /agents/search) - Task 6: WorktreeManager connected to teamRunner (prepareAgentWorktree) - Task 7: E2E tests for pipeline and team-worktree integration - Task 8: Barrel export updated (src/claude-code-patterns/index.ts) - Fix: Removed duplicate Repository block in teamRunner
Transferred from claw-code clean-room rewrite analysis: - Fuzzy Prompt Routing (only relevant tools injected per turn — better answers) - Transcript Compaction (sliding window + key decision protection — longer sessions) - Permission Gate (denied tools removed from context, trust-gated init — safety moat)
- 5 adapter files in src/adapters/ (systemPrompt, reactivePacker, memory, contextMiddleware, search) - Updated barrel export in src/claude-code-patterns/index.ts with Phase 2 adapters - Integration tests for all 5 adapters in tests/unit/claude-code-phase2-adapters.test.ts - Zero modifications to existing files (adapter/wrapper pattern)
0e2131a to
4cf4dbd
Compare
Codex Review Fixes (all 4 issues)
|
- Fix PromptRouter regex: \s not s for whitespace splitting - Fix ReactiveCompaction: downgrade least-relevant half, not most-relevant - Fix reactivePackerWrapper: truncate content after depth adjustment - Fix agentSearchIntegration: include metadata in cache key for freshness
Claude Code & Claw Code Patterns Transfer
Transfers context engineering patterns from Claude Code analysis + claw-code clean-room rewrite into modular-patchbay.
Phase 1 (Claude Code leak — Mar 31)
SystemPromptBuilder.ts)ReactiveCompaction.ts)ContextCollapse.ts)ToolUseSummary.ts)AgentSearch.ts)MemoryStore.ts)Phase 2 (Claw Code rewrite — Apr 1)
PromptRouter.ts)TranscriptCompaction.ts)PermissionGate.ts)Moat impact
Test coverage
Files changed