Skip to content

feat: Claude Code patterns transfer (6 features + pipeline integration)#150

Merged
VictorGjn merged 3 commits intomasterfrom
feat/claude-code-patterns
Apr 2, 2026
Merged

feat: Claude Code patterns transfer (6 features + pipeline integration)#150
VictorGjn merged 3 commits intomasterfrom
feat/claude-code-patterns

Conversation

@VictorGjn
Copy link
Copy Markdown
Owner

Claude Code Patterns → modular-patchbay

Transfer de 6 features + 5 adapters + pipeline wiring extraits du source code Claude Code.

Features (3 phases)

Phase 1 — Standalone modules (6 source + 6 test files, 58 tests)

Feature File
System Prompt Builder (static/dynamic boundary) src/prompt/SystemPromptBuilder.ts
Reactive Compaction (5 signal types) src/context/ReactiveCompaction.ts
Memory Pipeline (FS-backed + extraction) src/memory/MemoryStore.ts
Context Collapse (4 strategies) src/context/ContextCollapse.ts
Tool Use Summary (grouping + heuristics) src/context/ToolUseSummary.ts
Agent/Skill Search (TF-IDF) src/search/AgentSearch.ts

Phase 2 — Adapters + barrel export

Adapter Bridges
systemFrameBuilderAdapter.ts SystemPromptBuilder → buildSystemFrame()
reactivePackerWrapper.ts ReactiveCompaction → packContext()
memoryStoreIntegration.ts MemoryStore → context assembly
contextMiddleware.ts ContextCollapse + ToolUseSummary → pipeline
agentSearchIntegration.ts AgentSearch → agent registry

Phase 3 — Pipeline wiring + E2E

  • systemFrameBuilder.tsbuildSystemFrameOptimized()
  • packer.tspackContextReactive
  • contextAssembler.tsassemblePipelineContextWithMemory()
  • pipelineChat.ts → context middleware singleton
  • server/routes/agents.tsGET /agents/search
  • server/services/teamRunner.ts → worktree auto-setup for agents with repoUrl
  • Barrel export: src/claude-code-patterns/index.ts
  • 2 E2E test files (8 test cases)

Architecture

systemFrameBuilderAdapter  → systemFrameBuilder.ts (buildSystemFrameOptimized)
reactivePackerWrapper      → packer.ts (packContextReactive)
memoryStoreIntegration     → contextAssembler.ts (assemblePipelineContextWithMemory)
contextMiddleware          → pipelineChat.ts (singleton)
agentSearchIntegration     → server/routes/agents.ts (GET /search)
worktreeManager            → server/services/teamRunner.ts (prepareAgentWorktree)

Testing

  • ~69 unit tests + 2 E2E test files
  • npx vitest run to verify locally

Key design choice

All integrations use adapter/wrapper pattern — zero modifications to existing function signatures, zero regression risk. Each adapter can be adopted incrementally.

- 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
Copy link
Copy Markdown

@chatgpt-codex-connector chatgpt-codex-connector bot left a comment

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

💡 Codex Review

Here are some automated review suggestions for this pull request.

Reviewed commit: 255ed2ab3d

ℹ️ 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".

Comment on lines +133 to +135
const truncatedContent = contentStr.length > truncatedLength
? contentStr.slice(0, truncatedLength) + '
[... truncated by reactive compaction]'
Copy link
Copy Markdown

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

P1 Badge Prevent truncated marker from increasing content size

The new truncation path appends a fixed "[... truncated by reactive compaction]" suffix without accounting for its length, so short files can become longer after “compaction” (for example, truncating a 5-character string to 1 character still yields a ~40-character result). In that case newTokens is reduced while the actual emitted content grows, which can silently violate token-budget assumptions and overflow downstream context windows.

Useful? React with 👍 / 👎.

knowledge: KnowledgeSource[] = [],
): AgentSearchService {
const hash = JSON.stringify(agents.map(a => a.id).sort());
const hash = JSON.stringify(agents.map(a => [a.id, a.description, a.role, ...(a.tags ?? [])].join('|')).sort());
Copy link
Copy Markdown

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

P2 Badge Serialize agent hash fields without delimiter collisions

Building the cache key with [...].join('|') is ambiguous for free-form strings, so different agent metadata can collapse to the same hash whenever a field contains | (e.g., descriptions or tags), and the service will incorrectly reuse a stale _searchInstance instead of rebuilding the index. Using structured serialization per agent (rather than delimiter-joined text) avoids these false cache hits.

Useful? React with 👍 / 👎.

@VictorGjn VictorGjn merged commit 341a541 into master Apr 2, 2026
1 of 2 checks passed
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

None yet

Projects

None yet

Development

Successfully merging this pull request may close these issues.

1 participant