ultimate-pi 0.1.2 → 0.1.3
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/.agents/skills/ck-search/SKILL.md +99 -0
- package/.agents/skills/defuddle/SKILL.md +90 -0
- package/.agents/skills/find-skills/SKILL.md +142 -0
- package/.agents/skills/firecrawl/SKILL.md +150 -0
- package/.agents/skills/firecrawl/rules/install.md +82 -0
- package/.agents/skills/firecrawl/rules/security.md +26 -0
- package/.agents/skills/firecrawl-agent/SKILL.md +57 -0
- package/.agents/skills/firecrawl-build-interact/SKILL.md +67 -0
- package/.agents/skills/firecrawl-build-onboarding/SKILL.md +102 -0
- package/.agents/skills/firecrawl-build-onboarding/references/auth-flow.md +39 -0
- package/.agents/skills/firecrawl-build-onboarding/references/project-setup.md +20 -0
- package/.agents/skills/firecrawl-build-onboarding/references/sdk-installation.md +17 -0
- package/.agents/skills/firecrawl-build-scrape/SKILL.md +68 -0
- package/.agents/skills/firecrawl-build-search/SKILL.md +68 -0
- package/.agents/skills/firecrawl-crawl/SKILL.md +58 -0
- package/.agents/skills/firecrawl-download/SKILL.md +69 -0
- package/.agents/skills/firecrawl-interact/SKILL.md +83 -0
- package/.agents/skills/firecrawl-map/SKILL.md +50 -0
- package/.agents/skills/firecrawl-parse/SKILL.md +61 -0
- package/.agents/skills/firecrawl-scrape/SKILL.md +68 -0
- package/.agents/skills/firecrawl-search/SKILL.md +59 -0
- package/.agents/skills/obsidian-bases/SKILL.md +299 -0
- package/.agents/skills/obsidian-markdown/SKILL.md +237 -0
- package/.agents/skills/posthog-analyst/SKILL.md +306 -0
- package/.agents/skills/posthog-analyst/evals/evals.json +23 -0
- package/.agents/skills/wiki/SKILL.md +215 -0
- package/.agents/skills/wiki/references/css-snippets.md +122 -0
- package/.agents/skills/wiki/references/frontmatter.md +107 -0
- package/.agents/skills/wiki/references/git-setup.md +58 -0
- package/.agents/skills/wiki/references/mcp-setup.md +149 -0
- package/.agents/skills/wiki/references/modes.md +259 -0
- package/.agents/skills/wiki/references/plugins.md +96 -0
- package/.agents/skills/wiki/references/rest-api.md +124 -0
- package/.agents/skills/wiki-autoresearch/SKILL.md +211 -0
- package/.agents/skills/wiki-autoresearch/references/program.md +75 -0
- package/.agents/skills/wiki-fold/SKILL.md +204 -0
- package/.agents/skills/wiki-fold/references/fold-template.md +133 -0
- package/.agents/skills/wiki-ingest/SKILL.md +288 -0
- package/.agents/skills/wiki-lint/SKILL.md +183 -0
- package/.agents/skills/wiki-query/SKILL.md +176 -0
- package/.agents/skills/wiki-save/SKILL.md +128 -0
- package/.ckignore +41 -0
- package/.env.example +9 -0
- package/.github/workflows/lint.yml +33 -0
- package/.github/workflows/publish-github-packages.yml +35 -0
- package/.github/workflows/publish-npm.yml +1 -1
- package/.pi/SYSTEM.md +107 -40
- package/.pi/agents/pi-pi/agent-expert.md +205 -0
- package/.pi/agents/pi-pi/cli-expert.md +47 -0
- package/.pi/agents/pi-pi/config-expert.md +67 -0
- package/.pi/agents/pi-pi/ext-expert.md +53 -0
- package/.pi/agents/pi-pi/keybinding-expert.md +123 -0
- package/.pi/agents/pi-pi/pi-orchestrator.md +103 -0
- package/.pi/agents/pi-pi/prompt-expert.md +83 -0
- package/.pi/agents/pi-pi/skill-expert.md +52 -0
- package/.pi/agents/pi-pi/theme-expert.md +46 -0
- package/.pi/agents/pi-pi/tui-expert.md +100 -0
- package/.pi/agents/rethink.md +140 -0
- package/.pi/agents/wiki-ingest.md +67 -0
- package/.pi/agents/wiki-lint.md +75 -0
- package/.pi/auto-commit.json +20 -0
- package/.pi/extensions/banner.png +0 -0
- package/.pi/extensions/ck-enforce.ts +216 -0
- package/.pi/extensions/custom-footer.ts +308 -0
- package/.pi/extensions/custom-header.ts +116 -0
- package/.pi/extensions/dotenv-loader.ts +170 -0
- package/.pi/internal/cursor-sdk-transcript-parser.ts +59 -0
- package/.pi/model-router.json +95 -0
- package/.pi/npm/.gitignore +2 -0
- package/.pi/prompts/git-sync.md +124 -0
- package/.pi/prompts/harness-setup.md +509 -0
- package/.pi/prompts/save.md +16 -0
- package/.pi/prompts/wiki-autoresearch.md +19 -0
- package/.pi/prompts/wiki.md +23 -0
- package/.pi/providers/cursor-sdk-provider.test.mjs +476 -0
- package/.pi/providers/cursor-sdk-provider.ts +1085 -0
- package/.pi/settings.json +14 -4
- package/.pi/skills/agent-router/SKILL.md +174 -0
- package/.pi/sounds/alert/1-kaching-track.mp3 +0 -0
- package/.pi/sounds/error/1-ksi-wth-track.mp3 +0 -0
- package/.pi/sounds/error/2-smash-track.mp3 +0 -0
- package/.pi/sounds/error/3-buzzer-track.mp3 +0 -0
- package/.pi/sounds/notification/1-soft-notification-track.mp3 +0 -0
- package/.pi/sounds/project-sounds.json +25 -0
- package/.pi/sounds/reminder/1-soft-notification-track.mp3 +0 -0
- package/.pi/sounds/success/1-tada-track.mp3 +0 -0
- package/.pi/sounds/success/2-jobs-done-track.mp3 +0 -0
- package/.pi/sounds/success/3-yay-track.mp3 +0 -0
- package/CONTRIBUTING.md +116 -0
- package/README.md +32 -39
- package/biome.json +34 -0
- package/firecrawl/.env.template +58 -0
- package/firecrawl/README.md +49 -0
- package/firecrawl/docker-compose.yaml +201 -0
- package/firecrawl/searxng/searxng.env +3 -0
- package/firecrawl/searxng/settings.yml +85 -0
- package/lefthook.yml +8 -0
- package/package.json +55 -24
- package/vault/AGENTS.md +37 -0
- package/vault/wiki/_templates/comparison.md +39 -0
- package/vault/wiki/_templates/concept.md +40 -0
- package/vault/wiki/_templates/decision.md +21 -0
- package/vault/wiki/_templates/entity.md +32 -0
- package/vault/wiki/_templates/flow.md +14 -0
- package/vault/wiki/_templates/module.md +18 -0
- package/vault/wiki/_templates/question.md +31 -0
- package/vault/wiki/_templates/source.md +39 -0
- package/vault/wiki/concepts/AST-Aware Code Chunking.md +44 -0
- package/vault/wiki/concepts/Build-Time Prompt Compilation.md +107 -0
- package/vault/wiki/concepts/Context Engine (AI Coding).md +47 -0
- package/vault/wiki/concepts/Context-Aware System Reminders.md +61 -0
- package/vault/wiki/concepts/Contextualized Text Embedding.md +42 -0
- package/vault/wiki/concepts/Contractor vs Employee AI Model.md +55 -0
- package/vault/wiki/concepts/Dual-Model Agent Architecture.md +65 -0
- package/vault/wiki/concepts/Late Chunking vs Early Chunking.md +43 -0
- package/vault/wiki/concepts/Majority Vote Ensembling.md +68 -0
- package/vault/wiki/concepts/Meta-Harness.md +16 -0
- package/vault/wiki/concepts/Multi-Agent AI Coding Architecture.md +75 -0
- package/vault/wiki/concepts/Prompt Enhancement.md +90 -0
- package/vault/wiki/concepts/Prompt Renderer.md +89 -0
- package/vault/wiki/concepts/Semantic Codebase Indexing.md +67 -0
- package/vault/wiki/concepts/additive-config-hierarchy.md +16 -0
- package/vault/wiki/concepts/agent-artifacts-verifiable-deliverables.md +71 -0
- package/vault/wiki/concepts/agent-browser-browser-automation.md +99 -0
- package/vault/wiki/concepts/agent-codebase-interface.md +43 -0
- package/vault/wiki/concepts/agent-harness-architecture.md +67 -0
- package/vault/wiki/concepts/agent-loop-detection-patterns.md +133 -0
- package/vault/wiki/concepts/agent-search-enforcement.md +126 -0
- package/vault/wiki/concepts/agent-skills-ecosystem.md +74 -0
- package/vault/wiki/concepts/agent-skills-pattern.md +68 -0
- package/vault/wiki/concepts/agentic-harness-context-enforcement.md +91 -0
- package/vault/wiki/concepts/agentic-harness.md +34 -0
- package/vault/wiki/concepts/agentic-orchestration-pipeline.md +56 -0
- package/vault/wiki/concepts/agentic-search-no-embeddings.md +18 -0
- package/vault/wiki/concepts/anthropic-context-engineering.md +13 -0
- package/vault/wiki/concepts/antigravity-agent-first-architecture.md +61 -0
- package/vault/wiki/concepts/ast-compression.md +19 -0
- package/vault/wiki/concepts/ast-truncation.md +66 -0
- package/vault/wiki/concepts/barrel-files.md +37 -0
- package/vault/wiki/concepts/browser-harness-agent.md +41 -0
- package/vault/wiki/concepts/browser-subagent-visual-verification.md +82 -0
- package/vault/wiki/concepts/codebase-intelligence-ecosystem-comparison.md +192 -0
- package/vault/wiki/concepts/codebase-intelligence-harness-integration.md +161 -0
- package/vault/wiki/concepts/codebase-to-context-ingestion.md +46 -0
- package/vault/wiki/concepts/codex-harness-innovations.md +147 -0
- package/vault/wiki/concepts/consensus-debate-flow.md +17 -0
- package/vault/wiki/concepts/consensus-debate.md +206 -0
- package/vault/wiki/concepts/content-addressed-spec-identity.md +166 -0
- package/vault/wiki/concepts/context-anxiety.md +57 -0
- package/vault/wiki/concepts/context-compression-techniques.md +19 -0
- package/vault/wiki/concepts/context-continuity.md +22 -0
- package/vault/wiki/concepts/context-drift-in-agents.md +106 -0
- package/vault/wiki/concepts/context-engineering.md +62 -0
- package/vault/wiki/concepts/context-folding.md +67 -0
- package/vault/wiki/concepts/context-mode.md +38 -0
- package/vault/wiki/concepts/cursor-harness-innovations.md +107 -0
- package/vault/wiki/concepts/deterministic-session-compaction.md +79 -0
- package/vault/wiki/concepts/drift-detection-unified.md +296 -0
- package/vault/wiki/concepts/execution-feedback-loop.md +46 -0
- package/vault/wiki/concepts/feedforward-feedback-harness.md +60 -0
- package/vault/wiki/concepts/five-root-cause-metrics-sentrux.md +40 -0
- package/vault/wiki/concepts/fork-safe-spec-storage.md +89 -0
- package/vault/wiki/concepts/fts5-sandbox.md +19 -0
- package/vault/wiki/concepts/fuzzy-edit-matching.md +71 -0
- package/vault/wiki/concepts/gemini-cli-architecture.md +104 -0
- package/vault/wiki/concepts/generator-evaluator-architecture.md +64 -0
- package/vault/wiki/concepts/guardian-agent-pattern.md +67 -0
- package/vault/wiki/concepts/harness-configuration-layers.md +89 -0
- package/vault/wiki/concepts/harness-control-frameworks.md +155 -0
- package/vault/wiki/concepts/harness-engineering-first-principles.md +90 -0
- package/vault/wiki/concepts/harness-h-formalism.md +53 -0
- package/vault/wiki/concepts/hybrid-code-search.md +61 -0
- package/vault/wiki/concepts/inline-post-edit-validation.md +112 -0
- package/vault/wiki/concepts/legendary-engineering-patterns-harness.md +110 -0
- package/vault/wiki/concepts/lifecycle-hooks.md +94 -0
- package/vault/wiki/concepts/mcp-tool-routing.md +102 -0
- package/vault/wiki/concepts/memory-system-of-record-vs-ephemeral-cache.md +47 -0
- package/vault/wiki/concepts/meta-agent-context-pruning.md +151 -0
- package/vault/wiki/concepts/model-adaptive-harness.md +122 -0
- package/vault/wiki/concepts/model-routing-agents.md +101 -0
- package/vault/wiki/concepts/monorepo-architecture.md +45 -0
- package/vault/wiki/concepts/multi-agent-specialization.md +61 -0
- package/vault/wiki/concepts/permission-subsystem.md +16 -0
- package/vault/wiki/concepts/pi-messenger-analysis.md +243 -0
- package/vault/wiki/concepts/pi-vscode-extension-landscape.md +37 -0
- package/vault/wiki/concepts/policy-engine-pattern.md +78 -0
- package/vault/wiki/concepts/progressive-disclosure-agents.md +53 -0
- package/vault/wiki/concepts/progressive-skill-disclosure.md +17 -0
- package/vault/wiki/concepts/provider-native-prompting.md +203 -0
- package/vault/wiki/concepts/quality-signal-sentrux.md +37 -0
- package/vault/wiki/concepts/repo-map-ranking.md +42 -0
- package/vault/wiki/concepts/result-monad-error-handling.md +47 -0
- package/vault/wiki/concepts/safety-defense-in-depth.md +83 -0
- package/vault/wiki/concepts/sandbox-os-enforcement.md +18 -0
- package/vault/wiki/concepts/selective-debate-routing.md +70 -0
- package/vault/wiki/concepts/self-evolving-harness.md +60 -0
- package/vault/wiki/concepts/sentrux-mcp-integration.md +36 -0
- package/vault/wiki/concepts/sentrux-rules-engine.md +49 -0
- package/vault/wiki/concepts/shell-pattern-compression.md +24 -0
- package/vault/wiki/concepts/skill-first-architecture.md +166 -0
- package/vault/wiki/concepts/structured-compaction.md +78 -0
- package/vault/wiki/concepts/subagent-orchestration.md +17 -0
- package/vault/wiki/concepts/subagent-worktree-isolation.md +68 -0
- package/vault/wiki/concepts/superpowers-methodology.md +78 -0
- package/vault/wiki/concepts/think-in-code.md +73 -0
- package/vault/wiki/concepts/ts-execution-layer.md +100 -0
- package/vault/wiki/concepts/typescript-strict-mode.md +37 -0
- package/vault/wiki/concepts/vcc-conversation-compaction-for-pi.md +51 -0
- package/vault/wiki/concepts/verification-drift-detection.md +19 -0
- package/vault/wiki/consensus/consensus-records.md +58 -0
- package/vault/wiki/decisions/2026-04-30-pi-lean-ctx-native.md +122 -0
- package/vault/wiki/decisions/adr-008.md +40 -0
- package/vault/wiki/decisions/adr-009.md +46 -0
- package/vault/wiki/decisions/adr-010.md +55 -0
- package/vault/wiki/decisions/adr-011.md +165 -0
- package/vault/wiki/decisions/adr-012.md +102 -0
- package/vault/wiki/decisions/adr-013.md +59 -0
- package/vault/wiki/decisions/adr-014.md +73 -0
- package/vault/wiki/decisions/adr-015.md +81 -0
- package/vault/wiki/decisions/adr-016.md +91 -0
- package/vault/wiki/decisions/adr-017.md +79 -0
- package/vault/wiki/decisions/adr-018.md +100 -0
- package/vault/wiki/decisions/adr-019.md +75 -0
- package/vault/wiki/decisions/adr-020.md +106 -0
- package/vault/wiki/decisions/adr-021.md +86 -0
- package/vault/wiki/decisions/adr-022.md +113 -0
- package/vault/wiki/decisions/adr-023.md +113 -0
- package/vault/wiki/decisions/adr-024.md +73 -0
- package/vault/wiki/decisions/adr-025.md +130 -0
- package/vault/wiki/decisions/adr-026.md +56 -0
- package/vault/wiki/decisions/colocate-wiki.md +34 -0
- package/vault/wiki/entities/Anders Hejlsberg.md +29 -0
- package/vault/wiki/entities/Anthropic.md +17 -0
- package/vault/wiki/entities/Augment Code.md +49 -0
- package/vault/wiki/entities/Bjarne Stroustrup.md +26 -0
- package/vault/wiki/entities/Bolt.new (StackBlitz).md +39 -0
- package/vault/wiki/entities/Boris Cherny.md +11 -0
- package/vault/wiki/entities/Claude Code.md +19 -0
- package/vault/wiki/entities/Dennis Ritchie.md +26 -0
- package/vault/wiki/entities/Emergent Labs.md +32 -0
- package/vault/wiki/entities/Google Cloud.md +16 -0
- package/vault/wiki/entities/Guido van Rossum.md +28 -0
- package/vault/wiki/entities/Ken Thompson.md +28 -0
- package/vault/wiki/entities/Lee et al.md +16 -0
- package/vault/wiki/entities/Linus Torvalds.md +28 -0
- package/vault/wiki/entities/Lovable (company).md +40 -0
- package/vault/wiki/entities/Martin Fowler.md +16 -0
- package/vault/wiki/entities/Meng et al.md +16 -0
- package/vault/wiki/entities/OpenAI.md +16 -0
- package/vault/wiki/entities/Rocket.new.md +38 -0
- package/vault/wiki/entities/VILA-Lab.md +15 -0
- package/vault/wiki/entities/autodev-codebase.md +18 -0
- package/vault/wiki/entities/ck-tool.md +59 -0
- package/vault/wiki/entities/codesearch.md +18 -0
- package/vault/wiki/entities/disler-indydevdan.md +33 -0
- package/vault/wiki/entities/gsd-get-shit-done.md +56 -0
- package/vault/wiki/entities/javascript-runtimes.md +48 -0
- package/vault/wiki/entities/jesse-vincent.md +38 -0
- package/vault/wiki/entities/lean-ctx.md +32 -0
- package/vault/wiki/entities/opendev.md +41 -0
- package/vault/wiki/entities/ops-codegraph-tool.md +18 -0
- package/vault/wiki/entities/pi-coding-agent.md +53 -0
- package/vault/wiki/entities/sentrux.md +54 -0
- package/vault/wiki/entities/vgrep-tool.md +57 -0
- package/vault/wiki/entities/vitest.md +41 -0
- package/vault/wiki/flows/harness-wiki-pipeline.md +204 -0
- package/vault/wiki/hot.md +932 -0
- package/vault/wiki/index.md +437 -0
- package/vault/wiki/log.md +418 -0
- package/vault/wiki/meta/dashboard.md +30 -0
- package/vault/wiki/meta/lint-report-2026-04-30.md +86 -0
- package/vault/wiki/meta/lint-report-2026-05-02.md +251 -0
- package/vault/wiki/meta/overview.canvas +43 -0
- package/vault/wiki/modules/adversarial-verification.md +57 -0
- package/vault/wiki/modules/automated-observability.md +54 -0
- package/vault/wiki/modules/bench.md +20 -0
- package/vault/wiki/modules/extensions.md +23 -0
- package/vault/wiki/modules/grounding-checkpoints.md +62 -0
- package/vault/wiki/modules/harness-implementation-plan.md +345 -0
- package/vault/wiki/modules/harness-wiki-skill-mapping.md +135 -0
- package/vault/wiki/modules/harness.md +86 -0
- package/vault/wiki/modules/persistent-memory.md +85 -0
- package/vault/wiki/modules/schema-orchestration.md +68 -0
- package/vault/wiki/modules/skills.md +27 -0
- package/vault/wiki/modules/spec-hardening.md +58 -0
- package/vault/wiki/modules/structured-planning.md +53 -0
- package/vault/wiki/modules/think-in-code-enforcement.md +153 -0
- package/vault/wiki/modules/wiki-query-interface.md +64 -0
- package/vault/wiki/overview.md +51 -0
- package/vault/wiki/questions/Research-pi-vs-claude-code-agentic-orchestration-pipeline.md +87 -0
- package/vault/wiki/questions/Research-sentrux-dev.md +123 -0
- package/vault/wiki/questions/Research-superpowers-skill-for-agentic-coding-agents.md +164 -0
- package/vault/wiki/questions/Research: Augment Code Context Engine.md +244 -0
- package/vault/wiki/questions/Research: Automating Software Engineering - Lovable, Bolt, Emergent, Rocket.md +112 -0
- package/vault/wiki/questions/Research: Claude Code State-of-the-Art Harness Improvements.md +209 -0
- package/vault/wiki/questions/Research: Codex State-of-the-Art Harness Improvements.md +99 -0
- package/vault/wiki/questions/Research: Engineering Workflows of Legendary Programmers and AI Harness Mapping.md +107 -0
- package/vault/wiki/questions/Research: Fallow Codebase Intelligence Harness Integration.md +72 -0
- package/vault/wiki/questions/Research: Gemini CLI SOTA Harness Integration.md +166 -0
- package/vault/wiki/questions/Research: GitHub Issues as Harness Spec Storage.md +188 -0
- package/vault/wiki/questions/Research: Google Antigravity Harness Integration.md +120 -0
- package/vault/wiki/questions/Research: Meta-Agent Context Drift Detection.md +236 -0
- package/vault/wiki/questions/Research: Model-Adaptive Agent Harness Design.md +95 -0
- package/vault/wiki/questions/Research: Model-Specific Prompting Guides.md +165 -0
- package/vault/wiki/questions/Research: Prompt Renderer for Multi-Model Agent Harness.md +216 -0
- package/vault/wiki/questions/Research: Skill-First Harness Architecture.md +91 -0
- package/vault/wiki/questions/Research: TypeScript Best Practices and Codebase Structure.md +88 -0
- package/vault/wiki/questions/Research: TypeScript Execution Layer for Agent Tool Calling.md +81 -0
- package/vault/wiki/questions/Research: claude-mem over Obsidian for Harness Layer.md +71 -0
- package/vault/wiki/questions/Research: claude-mem over obsidian wiki as the knowledge base for our agentic harness pipeline. think from first principles. does this replace or complement our current setup? no hard feelings about previous decisions. gimme accurate points.md +80 -0
- package/vault/wiki/questions/Research: context-mode vs lean-ctx.md +72 -0
- package/vault/wiki/questions/Research: cursor.sh Harness Innovations.md +92 -0
- package/vault/wiki/questions/Research: executor.sh Harness Integration.md +170 -0
- package/vault/wiki/questions/Research: how GSD fits into our coding harness setup.md +97 -0
- package/vault/wiki/questions/Research: how claude-mem fits into our workflow. and whether it should replace obsidian in the codebase. no hard feelings about previous actions, rethink from first principles always.md +80 -0
- package/vault/wiki/questions/Research: pi-vcc.md +113 -0
- package/vault/wiki/questions/Research: semantic code search tools.md +69 -0
- package/vault/wiki/questions/Research: vcc extension for pi coding agent.md +73 -0
- package/vault/wiki/questions/how-to-enable-semantic-code-search-now.md +111 -0
- package/vault/wiki/questions/mvp-implementation-blueprint.md +552 -0
- package/vault/wiki/questions/research-agent-first-codebase-exploration.md +199 -0
- package/vault/wiki/questions/research-agentic-coding-harness-latest-papers.md +142 -0
- package/vault/wiki/questions/research-gitingest-gitreverse-integration.md +100 -0
- package/vault/wiki/questions/research-wozcode-token-reduction.md +67 -0
- package/vault/wiki/questions/resolved-context-pruning-inplace-vs-restart.md +95 -0
- package/vault/wiki/questions/resolved-context-window-economics.md +167 -0
- package/vault/wiki/questions/resolved-imad-debate-gating-transfer.md +126 -0
- package/vault/wiki/questions/resolved-mcp-tool-preference.md +112 -0
- package/vault/wiki/questions/resolved-small-model-meta-agents.md +107 -0
- package/vault/wiki/questions/resolved-treesitter-dynamic-languages.md +95 -0
- package/vault/wiki/sources/Auggie Context MCP Server.md +63 -0
- package/vault/wiki/sources/Augment Code Codacy AI Giants.md +61 -0
- package/vault/wiki/sources/Augment Code MCP SiliconAngle.md +49 -0
- package/vault/wiki/sources/Augment Code WorkOS ERC 2025.md +55 -0
- package/vault/wiki/sources/Augment Context Engine Official.md +71 -0
- package/vault/wiki/sources/Augment SWE-bench Agent GitHub.md +74 -0
- package/vault/wiki/sources/Augment SWE-bench Pro Blog.md +58 -0
- package/vault/wiki/sources/Source: AgentBus Jinja2 Prompt Pipelines.md +75 -0
- package/vault/wiki/sources/Source: Arxiv /342/200/224 Don't Break the Cache.md" +85 -0
- package/vault/wiki/sources/Source: Augment - Harness Engineering for AI Coding Agents.md +58 -0
- package/vault/wiki/sources/Source: Blake Crosley Agent Architecture Guide.md +100 -0
- package/vault/wiki/sources/Source: Bolt.new Architecture & Case Study.md +75 -0
- package/vault/wiki/sources/Source: Build-Time Prompt Compilation Architecture.md +107 -0
- package/vault/wiki/sources/Source: Claude API Agent Skills Overview.md +70 -0
- package/vault/wiki/sources/Source: Gemini CLI Changelogs.md +88 -0
- package/vault/wiki/sources/Source: Google Blog - Gemini CLI Announcement.md +57 -0
- package/vault/wiki/sources/Source: Google Gemini CLI Architecture Docs.md +53 -0
- package/vault/wiki/sources/Source: LangChain - Anatomy of Agent Harness.md +65 -0
- package/vault/wiki/sources/Source: Lovable Architecture & Clone Analysis.md +83 -0
- package/vault/wiki/sources/Source: Martin Fowler - Harness Engineering.md +70 -0
- package/vault/wiki/sources/Source: OpenAI Harness Engineering Five Principles.md +58 -0
- package/vault/wiki/sources/Source: OpenAI Harness Engineering /342/200/224 0 Lines of Human Code.md" +101 -0
- package/vault/wiki/sources/Source: OpenDev /342/200/224 Building AI Coding Agents for the Terminal.md" +100 -0
- package/vault/wiki/sources/Source: Render AI Coding Agents Benchmark 2025.md +53 -0
- package/vault/wiki/sources/Source: Rocket.new /342/200/224 Vibe Solutioning Platform.md" +70 -0
- package/vault/wiki/sources/Source: SwirlAI Agent Skills Progressive Disclosure.md +71 -0
- package/vault/wiki/sources/Source: TianPan Prompt Caching Architecture.md +89 -0
- package/vault/wiki/sources/Source: Vercel Labs agent-browser.md +155 -0
- package/vault/wiki/sources/Source: browser-harness CDP Harness.md +126 -0
- package/vault/wiki/sources/agent-drift-academic-paper.md +79 -0
- package/vault/wiki/sources/aider-repomap-tree-sitter.md +42 -0
- package/vault/wiki/sources/anthropic-compaction-api.md +58 -0
- package/vault/wiki/sources/anthropic-effective-harnesses.md +42 -0
- package/vault/wiki/sources/anthropic-prompt-best-practices.md +100 -0
- package/vault/wiki/sources/anthropic2026-harness-design.md +63 -0
- package/vault/wiki/sources/barrel-files-tkdodo.md +38 -0
- package/vault/wiki/sources/birth-of-unix-kernighan-interview.md +57 -0
- package/vault/wiki/sources/bockeler2026-harness-engineering.md +69 -0
- package/vault/wiki/sources/cast-code-chunking-paper.md +50 -0
- package/vault/wiki/sources/ck-semantic-search.md +78 -0
- package/vault/wiki/sources/claude-code-architecture-karaxai-2026.md +71 -0
- package/vault/wiki/sources/claude-code-architecture-qubytes-2026.md +50 -0
- package/vault/wiki/sources/claude-code-architecture-vila-lab-2026.md +64 -0
- package/vault/wiki/sources/claude-code-security-architecture-penligent-2026.md +70 -0
- package/vault/wiki/sources/claude-context-editing-docs.md +13 -0
- package/vault/wiki/sources/cloudflare-codemode.md +63 -0
- package/vault/wiki/sources/code-chunk-library-supermemory.md +63 -0
- package/vault/wiki/sources/codeact-apple-2024.md +62 -0
- package/vault/wiki/sources/codex-dsc-rfc-8573.md +41 -0
- package/vault/wiki/sources/codex-open-source-agent-2026.md +110 -0
- package/vault/wiki/sources/coir-code-retrieval-benchmark.md +51 -0
- package/vault/wiki/sources/colinmcnamara-context-optimization-codemode.md +48 -0
- package/vault/wiki/sources/context-folding-paper.md +61 -0
- package/vault/wiki/sources/context-mode-website.md +63 -0
- package/vault/wiki/sources/cursor-agent-best-practices-2026.md +62 -0
- package/vault/wiki/sources/cursor-fork-29b-2025.md +50 -0
- package/vault/wiki/sources/cursor-harness-april-2026.md +76 -0
- package/vault/wiki/sources/cursor-instant-apply-2024.md +45 -0
- package/vault/wiki/sources/cursor-shadow-workspace-2024.md +52 -0
- package/vault/wiki/sources/cursor-shipped-coding-agent-2026.md +53 -0
- package/vault/wiki/sources/cursor-vs-antigravity-2026.md +51 -0
- package/vault/wiki/sources/disler-pi-vs-claude-code.md +69 -0
- package/vault/wiki/sources/distill-deterministic-context-compression.md +53 -0
- package/vault/wiki/sources/embedding-models-benchmark-supermemory-2025.md +48 -0
- package/vault/wiki/sources/executor-rhyssullivan.md +122 -0
- package/vault/wiki/sources/fallow-rs-codebase-intelligence.md +125 -0
- package/vault/wiki/sources/fan2025-imad.md +60 -0
- package/vault/wiki/sources/forgecode-gpt5-agent-improvements.md +63 -0
- package/vault/wiki/sources/gemini-3-prompting-guide.md +78 -0
- package/vault/wiki/sources/gh-cli-sub-issue-rfc.md +50 -0
- package/vault/wiki/sources/gh-sub-issue-extension.md +72 -0
- package/vault/wiki/sources/github-fork-issues-discussion.md +44 -0
- package/vault/wiki/sources/github-issue-dependencies-docs.md +49 -0
- package/vault/wiki/sources/github-sub-issues-docs.md +51 -0
- package/vault/wiki/sources/gitingest.md +91 -0
- package/vault/wiki/sources/gitreverse.md +63 -0
- package/vault/wiki/sources/google-antigravity-official-blog.md +47 -0
- package/vault/wiki/sources/google-antigravity-wikipedia.md +53 -0
- package/vault/wiki/sources/gsd-codecentric-deep-dive.md +57 -0
- package/vault/wiki/sources/gsd-github-repo.md +51 -0
- package/vault/wiki/sources/gsd-hn-discussion.md +59 -0
- package/vault/wiki/sources/guido-python-design-philosophy.md +56 -0
- package/vault/wiki/sources/hejlsberg-7-learnings.md +48 -0
- package/vault/wiki/sources/ironclaw-drift-monitor.md +80 -0
- package/vault/wiki/sources/langsight-loop-detection.md +80 -0
- package/vault/wiki/sources/leanctx-website.md +69 -0
- package/vault/wiki/sources/lee2026-meta-harness.md +59 -0
- package/vault/wiki/sources/linux-kernel-coding-workflow.md +50 -0
- package/vault/wiki/sources/lou2026-autoharness.md +53 -0
- package/vault/wiki/sources/martin-fowler-harness-engineering.md +73 -0
- package/vault/wiki/sources/mcp-architecture-docs.md +13 -0
- package/vault/wiki/sources/meng2026-agent-harness-survey.md +79 -0
- package/vault/wiki/sources/mindstudio-four-agent-types.md +68 -0
- package/vault/wiki/sources/ms-chat-history-management.md +13 -0
- package/vault/wiki/sources/openai-prompt-guidance.md +104 -0
- package/vault/wiki/sources/openclaw-session-pruning.md +13 -0
- package/vault/wiki/sources/opencode-dcp.md +13 -0
- package/vault/wiki/sources/opendev-arxiv-2603.05344v1.md +79 -0
- package/vault/wiki/sources/openhands-platform.md +39 -0
- package/vault/wiki/sources/oss-guide-codebase-exploration.md +53 -0
- package/vault/wiki/sources/pi-compaction-extensions-ecosystem.md +102 -0
- package/vault/wiki/sources/pi-context-prune-github-repo.md +38 -0
- package/vault/wiki/sources/pi-mono-compaction-docs.md +38 -0
- package/vault/wiki/sources/pi-omni-compact-github-repo.md +50 -0
- package/vault/wiki/sources/pi-rtk-optimizer-github-repo.md +45 -0
- package/vault/wiki/sources/pi-vcc-github-repo.md +69 -0
- package/vault/wiki/sources/pi-vscode-marketplace.md +41 -0
- package/vault/wiki/sources/pi-vscode-model-provider-marketplace.md +39 -0
- package/vault/wiki/sources/py-tree-sitter.md +13 -0
- package/vault/wiki/sources/sentrux-dev-landing.md +40 -0
- package/vault/wiki/sources/sentrux-docs-pro-architecture.md +75 -0
- package/vault/wiki/sources/sentrux-docs-quality-signal.md +46 -0
- package/vault/wiki/sources/sentrux-docs-root-cause-metrics.md +57 -0
- package/vault/wiki/sources/sentrux-docs-rules-engine.md +58 -0
- package/vault/wiki/sources/sentrux-github-repo.md +56 -0
- package/vault/wiki/sources/superpowers-github-repo.md +56 -0
- package/vault/wiki/sources/superpowers-release-blog.md +54 -0
- package/vault/wiki/sources/superpowers-termdock-analysis.md +45 -0
- package/vault/wiki/sources/swe-agent-aci.md +42 -0
- package/vault/wiki/sources/swe-bench.md +45 -0
- package/vault/wiki/sources/swe-pruner-context-pruning.md +13 -0
- package/vault/wiki/sources/think-in-code-blog.md +48 -0
- package/vault/wiki/sources/tree-sitter-docs.md +13 -0
- package/vault/wiki/sources/ts-best-practices-2025-devto.md +42 -0
- package/vault/wiki/sources/ts-folder-structure-mingyang.md +58 -0
- package/vault/wiki/sources/ts-monorepo-koerselman.md +44 -0
- package/vault/wiki/sources/ts-result-error-handling-kkalamarski.md +52 -0
- package/vault/wiki/sources/ts-runtimes-comparison-betterstack.md +42 -0
- package/vault/wiki/sources/ts-strict-mode-rishikc.md +43 -0
- package/vault/wiki/sources/unix-philosophy.md +48 -0
- package/vault/wiki/sources/vectara-chunking-vs-embedding-naacl2025.md +39 -0
- package/vault/wiki/sources/vectara-guardian-agents.md +79 -0
- package/vault/wiki/sources/vgrep-semantic-search.md +76 -0
- package/vault/wiki/sources/vitest-official.md +41 -0
- package/vault/wiki/sources/vscode-pi-community-extension.md +40 -0
- package/vault/wiki/sources/wozcode.md +79 -0
- package/.agents/skills/compress/SKILL.md +0 -111
- package/.agents/skills/compress/scripts/__init__.py +0 -9
- package/.agents/skills/compress/scripts/__main__.py +0 -3
- package/.agents/skills/compress/scripts/benchmark.py +0 -78
- package/.agents/skills/compress/scripts/cli.py +0 -73
- package/.agents/skills/compress/scripts/compress.py +0 -227
- package/.agents/skills/compress/scripts/detect.py +0 -121
- package/.agents/skills/compress/scripts/validate.py +0 -189
- package/.agents/skills/emil-design-eng/SKILL.md +0 -679
- package/.agents/skills/lean-ctx/SKILL.md +0 -149
- package/.agents/skills/lean-ctx/scripts/install.sh +0 -95
- package/.agents/skills/scrapling-official/LICENSE.txt +0 -28
- package/.agents/skills/scrapling-official/SKILL.md +0 -390
- package/.agents/skills/scrapling-official/examples/01_fetcher_session.py +0 -26
- package/.agents/skills/scrapling-official/examples/02_dynamic_session.py +0 -26
- package/.agents/skills/scrapling-official/examples/03_stealthy_session.py +0 -26
- package/.agents/skills/scrapling-official/examples/04_spider.py +0 -58
- package/.agents/skills/scrapling-official/examples/README.md +0 -45
- package/.agents/skills/scrapling-official/references/fetching/choosing.md +0 -78
- package/.agents/skills/scrapling-official/references/fetching/dynamic.md +0 -352
- package/.agents/skills/scrapling-official/references/fetching/static.md +0 -432
- package/.agents/skills/scrapling-official/references/fetching/stealthy.md +0 -255
- package/.agents/skills/scrapling-official/references/mcp-server.md +0 -214
- package/.agents/skills/scrapling-official/references/migrating_from_beautifulsoup.md +0 -86
- package/.agents/skills/scrapling-official/references/parsing/adaptive.md +0 -212
- package/.agents/skills/scrapling-official/references/parsing/main_classes.md +0 -586
- package/.agents/skills/scrapling-official/references/parsing/selection.md +0 -494
- package/.agents/skills/scrapling-official/references/spiders/advanced.md +0 -344
- package/.agents/skills/scrapling-official/references/spiders/architecture.md +0 -94
- package/.agents/skills/scrapling-official/references/spiders/getting-started.md +0 -164
- package/.agents/skills/scrapling-official/references/spiders/proxy-blocking.md +0 -235
- package/.agents/skills/scrapling-official/references/spiders/requests-responses.md +0 -196
- package/.agents/skills/scrapling-official/references/spiders/sessions.md +0 -205
- package/PLAN.md +0 -11
- package/extensions/lean-ctx-enforce.ts +0 -166
- package/skills-lock.json +0 -35
- package/wiki/README.md +0 -19
- package/wiki/decisions/0001-establish-project-wiki-and-decision-record-format.md +0 -25
- package/wiki/decisions/0002-add-project-banner-to-readme.md +0 -26
- package/wiki/decisions/0003-remove-redundant-readme-title-heading.md +0 -26
- package/wiki/decisions/0004-publish-package-to-npm-as-ultimate-pi.md +0 -26
- package/wiki/decisions/0005-automate-npm-publish-with-github-actions.md +0 -27
- package/wiki/decisions/0006-switch-to-npm-trusted-publishing.md +0 -26
- package/wiki/decisions/0007-use-absolute-banner-url-for-npm-readme-rendering.md +0 -26
- package/wiki/decisions/0008-rename-banner-asset-for-cache-busting.md +0 -26
- package/wiki/decisions/0009-force-oidc-path-by-clearing-node-auth-token-in-publish-step.md +0 -25
- package/wiki/decisions/0010-simplify-setup-node-for-npm-trusted-publishing.md +0 -26
- package/wiki/decisions/0011-add-noop-workflow-change-to-force-fresh-publish-run.md +0 -25
- package/wiki/decisions/0012-align-workflow-runtime-with-npm-trusted-publishing-requirements.md +0 -26
- package/wiki/decisions/0013-add-package-repository-url-for-provenance-validation.md +0 -25
|
@@ -0,0 +1,167 @@
|
|
|
1
|
+
---
|
|
2
|
+
type: resolution
|
|
3
|
+
title: "Resolved: Context Window Economics — Token Allocation, Monorepos, and Caching"
|
|
4
|
+
created: 2026-04-30
|
|
5
|
+
updated: 2026-04-30
|
|
6
|
+
tags:
|
|
7
|
+
- resolution
|
|
8
|
+
- context-window
|
|
9
|
+
- token-economics
|
|
10
|
+
- repo-map
|
|
11
|
+
- caching
|
|
12
|
+
status: resolved
|
|
13
|
+
resolves:
|
|
14
|
+
- "[[research-agent-first-codebase-exploration]] Open Questions #2-5"
|
|
15
|
+
- "[[research-gitingest-gitreverse-integration]] Open Questions #1-4"
|
|
16
|
+
- "[[Research: semantic code search tools]] Open Question #1, #5"
|
|
17
|
+
related:
|
|
18
|
+
- "[[research-agent-first-codebase-exploration]]"
|
|
19
|
+
- "[[research-gitingest-gitreverse-integration]]"
|
|
20
|
+
- "[[progressive-disclosure-agents]]"
|
|
21
|
+
- "[[repo-map-ranking]]"
|
|
22
|
+
- "[[gitingest]]"
|
|
23
|
+
sources:
|
|
24
|
+
- "[[claude-context-editing-docs]]"
|
|
25
|
+
- "[[gitingest]]"
|
|
26
|
+
|
|
27
|
+
---# Resolved: Context Window Economics
|
|
28
|
+
|
|
29
|
+
## Resolution
|
|
30
|
+
|
|
31
|
+
**Token allocation is model- and task-specific but follows a consistent pattern: 10-20% repo map, 40-60% file contents, 20-40% conversation history. Monorepos require project-level splitting with progressive disclosure. Pre-computed and cached repo maps are the primary optimization — embeddings are secondary. The agent decides context expansion (L0→L1→L2) based on task needs, guided by explicit query interfaces at each level.**
|
|
32
|
+
|
|
33
|
+
## 1. Token Allocation Model
|
|
34
|
+
|
|
35
|
+
### Default Allocation by Task Type
|
|
36
|
+
|
|
37
|
+
| Task Type | Repo Map | File Contents | Conversation | Example |
|
|
38
|
+
|-----------|----------|---------------|--------------|---------|
|
|
39
|
+
| **Bug fix (localized)** | 10% | 30% | 60% | Fix known function, need history + current file |
|
|
40
|
+
| **Feature addition** | 20% | 50% | 30% | Need architecture context + relevant files |
|
|
41
|
+
| **Codebase exploration** | 40% | 50% | 10% | Understanding new codebase, minimal history |
|
|
42
|
+
| **Refactoring** | 30% | 40% | 30% | Need broad context + implementation details |
|
|
43
|
+
| **Code review** | 15% | 60% | 25% | Need changed files + spec context |
|
|
44
|
+
|
|
45
|
+
### Allocation for Common Context Windows
|
|
46
|
+
|
|
47
|
+
| Context Window | Repo Map | File Contents | Conversation | Total Usable |
|
|
48
|
+
|---------------|----------|---------------|--------------|-------------|
|
|
49
|
+
| **32k (small)** | 3-6k | 13-19k | 6-13k | 32k |
|
|
50
|
+
| **100k (medium)** | 10-20k | 40-60k | 20-40k | 100k |
|
|
51
|
+
| **200k (large)** | 20-40k | 80-120k | 40-80k | 200k |
|
|
52
|
+
|
|
53
|
+
**The 10-20-40 rule**: repo map ≤20% of window, conversation ≤40%, file contents fill remainder. This ensures the agent always has structural context (map) and task continuity (conversation) while maximizing code visibility.
|
|
54
|
+
|
|
55
|
+
## 2. Monorepo Handling
|
|
56
|
+
|
|
57
|
+
### Problem
|
|
58
|
+
|
|
59
|
+
Single repo maps for monorepos exceed context windows. A monorepo with 50 projects, each with 10k LOC, produces a repo map of 100k+ tokens — exceeding all but the largest context windows.
|
|
60
|
+
|
|
61
|
+
### Solution: Hierarchical Repo Maps
|
|
62
|
+
|
|
63
|
+
```
|
|
64
|
+
L0: Project-Level Map (always injected, ~2-5k tokens)
|
|
65
|
+
├─ List of sub-projects with one-line descriptions
|
|
66
|
+
├─ Cross-project dependency graph (edges only, no details)
|
|
67
|
+
└─ Entry points and API surfaces per project
|
|
68
|
+
|
|
69
|
+
L1: Sub-Project Map (queryable, ~5-15k tokens)
|
|
70
|
+
├─ Full symbol map for one sub-project
|
|
71
|
+
├─ Internal dependency graph
|
|
72
|
+
└─ Call graph within the sub-project
|
|
73
|
+
|
|
74
|
+
L2: File-Level Context (on-demand, variable)
|
|
75
|
+
├─ Full file contents
|
|
76
|
+
├─ Function bodies
|
|
77
|
+
└─ Deep context for specific symbols
|
|
78
|
+
```
|
|
79
|
+
|
|
80
|
+
The L0 map is always injected. The agent queries L1 for the relevant sub-project(s). L2 is loaded on demand for specific files.
|
|
81
|
+
|
|
82
|
+
### Gitingest for Monorepos
|
|
83
|
+
|
|
84
|
+
Gitingest handles large repos via:
|
|
85
|
+
- `--include` / `--exclude` patterns to filter sub-projects
|
|
86
|
+
- `--max-size` to limit individual file sizes
|
|
87
|
+
- `--branch` to target specific branches
|
|
88
|
+
|
|
89
|
+
For monorepos, use Gitingest per sub-project: `gitingest <url> --include "src/auth/**"` for the auth module only. This keeps output within context window limits. (Source: [[gitingest]])
|
|
90
|
+
|
|
91
|
+
## 3. Pre-Computation and Caching
|
|
92
|
+
|
|
93
|
+
### What to Pre-Compute
|
|
94
|
+
|
|
95
|
+
| Artifact | Compute Cost | Cache Strategy | Refresh Trigger |
|
|
96
|
+
|----------|-------------|----------------|-----------------|
|
|
97
|
+
| **Tree-sitter repo map** | ~1-5s per 100k LOC | File cache (`.pi/cache/repo-map.json`) | Git diff on session start |
|
|
98
|
+
| **Dependency graph** | ~0.5-2s per project | File cache (`.pi/cache/dep-graph.json`) | File changes in imports |
|
|
99
|
+
| **Code embeddings** | ~30-300s per 100k LOC | Vector DB (ck index) | File changes (incremental) |
|
|
100
|
+
| **Test impact map** | Build-system dependent | File cache | Test file changes |
|
|
101
|
+
|
|
102
|
+
### Caching Architecture
|
|
103
|
+
|
|
104
|
+
```
|
|
105
|
+
Session Start:
|
|
106
|
+
1. Load cached repo map from .pi/cache/repo-map.json
|
|
107
|
+
2. Git diff against cache timestamp
|
|
108
|
+
3. Re-parse only changed files (incremental update)
|
|
109
|
+
4. Inject updated L0 map into agent context
|
|
110
|
+
|
|
111
|
+
Cost: ~0.1-1s vs 5-30s for full re-parse
|
|
112
|
+
```
|
|
113
|
+
|
|
114
|
+
### Embedding-Based Retrieval
|
|
115
|
+
|
|
116
|
+
Code embeddings (ck, vgrep) are complementary to repo maps:
|
|
117
|
+
- **Repo map**: Structural understanding (what exists, how it connects). Deterministic.
|
|
118
|
+
- **Embeddings**: Semantic search (find code by meaning). Probabilistic, ranked.
|
|
119
|
+
|
|
120
|
+
Embeddings should be pre-computed and incrementally updated, not built on every session. ck's default embedding model (fastembed) is adequate for code search but not competitive with code-specific models (CodeBERT, UniXCoder) — the gap is real but the cost/simplicity tradeoff favors ck for agent use.
|
|
121
|
+
|
|
122
|
+
## 4. Context Expansion Decision (L0→L1→L2)
|
|
123
|
+
|
|
124
|
+
### How the Agent Decides
|
|
125
|
+
|
|
126
|
+
The agent determines context expansion based on task requirements, not a fixed heuristic:
|
|
127
|
+
|
|
128
|
+
| Expansion Trigger | Agent Action | Tool Support Needed |
|
|
129
|
+
|-------------------|-------------|-------------------|
|
|
130
|
+
| "I need to understand function X" | Query L1: symbol details for X | `symbol_info("function_name")` |
|
|
131
|
+
| "I need to see all callers of X" | Query L1: call graph for X | `callers("function_name")` |
|
|
132
|
+
| "I need to modify file Y" | Load L2: full file contents | `read_file("path")` |
|
|
133
|
+
| "I need type information for Z" | Query L2: type definition | `type_info("ClassName")` |
|
|
134
|
+
| "I'm lost, need more context" | Drift detection should trigger | Meta-agent nudges agent |
|
|
135
|
+
|
|
136
|
+
The tooling at each level must support explicit queries. The agent should not have to "figure out" what's available — the progressive disclosure API makes each level explicitly queryable.
|
|
137
|
+
|
|
138
|
+
### When NOT to Expand
|
|
139
|
+
|
|
140
|
+
- **Confidence is high**: Agent has enough context for the current subtask
|
|
141
|
+
- **Token budget is tight**: Expansion would push out critical conversation history
|
|
142
|
+
- **Information is available in current context**: The answer is already in the repo map or loaded files
|
|
143
|
+
- **Task is narrowly scoped**: Bug fix in a single function doesn't need project-level context
|
|
144
|
+
|
|
145
|
+
The agent should default to working with what it has. Only expand when explicitly needed.
|
|
146
|
+
|
|
147
|
+
## 5. Remaining Gitingest Questions
|
|
148
|
+
|
|
149
|
+
### Gitingest repo-level truncation
|
|
150
|
+
|
|
151
|
+
Gitingest supports `--max-size` for individual files but repo-level truncation behavior is not explicitly documented. Based on the codebase, Gitingest processes all files matching include/exclude patterns and concatenates them. If the total exceeds practical limits, the user must pre-filter with include/exclude patterns. This is adequate for the harness use case — the agent should use per-sub-project Gitingest with include patterns.
|
|
152
|
+
|
|
153
|
+
### Gitingest + lean-ctx AST compression
|
|
154
|
+
|
|
155
|
+
Yes, Gitingest output can be further compressed by lean-ctx tree-sitter AST mode. Gitingest produces full file contents; lean-ctx can truncate function bodies. The pipeline: `gitingest <url> → raw output → lean-ctx AST truncation → agent context`. This is complementary but the AST truncation needs to handle the Gitingest output format (delimited files).
|
|
156
|
+
|
|
157
|
+
### Repomix evaluation
|
|
158
|
+
|
|
159
|
+
Repomix is the npm ecosystem equivalent of Gitingest. Both convert repos to LLM-ready text. Gitingest (Python) is preferred for the harness since the project already has Python dependencies. Repomix should be evaluated only if npm-native integration is needed. Not a priority.
|
|
160
|
+
|
|
161
|
+
### GitHub API rate limits for Gitingest
|
|
162
|
+
|
|
163
|
+
Gitingest fetches repos via git clone (for local use) or GitHub API (for web service). The web service may cache popular repos. For the harness, use the local Python package (`pip install gitingest`) which clones via git — no API rate limit concern. Only the web service (`gitingest.com`) has rate limits.
|
|
164
|
+
|
|
165
|
+
## Confidence
|
|
166
|
+
|
|
167
|
+
**High** for token allocation model and monorepo handling (based on production patterns from Claude, OpenCode, and aider). **Medium** for Gitingest truncation behavior (inferred from code, not explicitly documented). **High** for caching architecture (standard incremental update pattern).
|
|
@@ -0,0 +1,126 @@
|
|
|
1
|
+
---
|
|
2
|
+
type: resolution
|
|
3
|
+
title: "Resolved: iMAD Debate Gating — QA to Code Review Transfer"
|
|
4
|
+
created: 2026-04-30
|
|
5
|
+
updated: 2026-04-30
|
|
6
|
+
tags:
|
|
7
|
+
- resolution
|
|
8
|
+
- debate
|
|
9
|
+
- selective-routing
|
|
10
|
+
- imad
|
|
11
|
+
- consensus
|
|
12
|
+
status: resolved
|
|
13
|
+
resolves:
|
|
14
|
+
- "[[selective-debate-routing]] Open Questions #1-3"
|
|
15
|
+
- "[[research-agentic-coding-harness-latest-papers]] Open Questions #1-3"
|
|
16
|
+
- "[[consensus-debate]] Open Questions #1, #2, #4"
|
|
17
|
+
related:
|
|
18
|
+
- "[[selective-debate-routing]]"
|
|
19
|
+
- "[[consensus-debate]]"
|
|
20
|
+
- "[[adr-011]]"
|
|
21
|
+
- "[[fan2025-imad]]"
|
|
22
|
+
sources:
|
|
23
|
+
- "[[fan2025-imad]]"
|
|
24
|
+
|
|
25
|
+
---# Resolved: iMAD Debate Gating — QA to Code Review Transfer
|
|
26
|
+
|
|
27
|
+
## Resolution
|
|
28
|
+
|
|
29
|
+
**iMAD's selective debate gating generalizes from QA to code review in PRINCIPLE, but the specific hesitation cues (41 linguistic features) must be adapted. The core insight — debate is not always beneficial and a lightweight classifier can save 92% of debate tokens — transfers directly. Implementation requires code-specific hesitation cues and model-specific classifiers.**
|
|
30
|
+
|
|
31
|
+
## What iMAD Proved (QA Domain)
|
|
32
|
+
|
|
33
|
+
iMAD (Fan et al., AAAI 2026) demonstrated across 6 QA datasets:
|
|
34
|
+
|
|
35
|
+
- **92% token reduction** vs always-debate
|
|
36
|
+
- **13.5% accuracy improvement** vs single-agent baseline
|
|
37
|
+
- Selective debate via 41 linguistic/semantic features: uncertainty markers ("might", "could be"), contradictory statements, missing evidence references, low confidence indicators
|
|
38
|
+
- Lightweight classifier (FocusCal loss) generalizes across datasets without per-task tuning
|
|
39
|
+
- **Debate can overturn correct single-agent answers** — this is the key finding that motivates selective routing
|
|
40
|
+
|
|
41
|
+
Source: [[fan2025-imad]]
|
|
42
|
+
|
|
43
|
+
## Transfer Analysis: QA → Code Review
|
|
44
|
+
|
|
45
|
+
### What Transfers Directly
|
|
46
|
+
|
|
47
|
+
| iMAD Component | Transfers to Code Review? | Confidence |
|
|
48
|
+
|---------------|--------------------------|------------|
|
|
49
|
+
| Selective routing principle | Yes — debate only when uncertainty detected | High |
|
|
50
|
+
| Pre-debate self-critique gate | Yes — single agent self-critiques first | High |
|
|
51
|
+
| Token savings model | Yes — 92% on high-confidence, 0% on uncertain | High |
|
|
52
|
+
| FocusCal loss classifier | Yes — architecture generalizes | Medium |
|
|
53
|
+
| Multi-dataset generalization | Untested — code review is different domain | Unknown |
|
|
54
|
+
|
|
55
|
+
### What Must Be Adapted
|
|
56
|
+
|
|
57
|
+
| iMAD Feature (QA) | Code Review Equivalent | Status |
|
|
58
|
+
|-------------------|----------------------|--------|
|
|
59
|
+
| "I think the answer is..." | "The implementation looks correct..." | Maps to uncertainty markers |
|
|
60
|
+
| "It might be B or C" | "This could introduce a race condition" | Maps to uncertainty markers |
|
|
61
|
+
| Missing citation | Missing spec reference / test coverage | New feature needed |
|
|
62
|
+
| Contradictory answer | Contradictory review feedback | Maps directly |
|
|
63
|
+
| Low confidence score | Low confidence in review verdict | Maps directly |
|
|
64
|
+
|
|
65
|
+
### What Does NOT Transfer
|
|
66
|
+
|
|
67
|
+
QA tasks have a single correct answer. Code review has MULTIPLE dimensions of correctness: spec compliance, edge cases, performance, security, style. A single confidence score is insufficient — the classifier must assess uncertainty per dimension.
|
|
68
|
+
|
|
69
|
+
## Specific Questions Resolved
|
|
70
|
+
|
|
71
|
+
### Q1: Do iMAD hesitation cues generalize from QA to code review?
|
|
72
|
+
|
|
73
|
+
**Partially.** Linguistic uncertainty markers ("might", "could be", "I think") generalize because they reflect the model's internal uncertainty regardless of domain. However, code review introduces domain-specific cues: missing spec references, untested edge cases, missing test coverage, performance concerns not addressed. These require new feature extraction.
|
|
74
|
+
|
|
75
|
+
**Recommendation**: Use iMAD's 41 linguistic features as the base. Add code-specific features: spec coverage ratio, test coverage ratio, edge case enumeration completeness, performance analysis presence. Retrain classifier on labeled code review debate outcomes.
|
|
76
|
+
|
|
77
|
+
### Q2: Can a single classifier work across L1 (spec), L2 (plan), L4 (code)?
|
|
78
|
+
|
|
79
|
+
**Yes, with caveats.** A single classifier CAN work if it operates on debate-agnostic features (linguistic uncertainty + structural completeness). However, each layer has different "completeness" signals:
|
|
80
|
+
|
|
81
|
+
- **L1 (Spec)**: Coverage of error states, edge cases, input constraints, output contracts
|
|
82
|
+
- **L2 (Plan)**: Task dependency completeness, rollback planning, resource estimation
|
|
83
|
+
- **L4 (Code)**: Spec compliance, test coverage, edge case handling, performance
|
|
84
|
+
|
|
85
|
+
**Recommendation**: Build one classifier with layer-specific feature sets. Start with a simple rule-based gate (confidence threshold) and graduate to ML classifier after collecting labeled debate outcomes.
|
|
86
|
+
|
|
87
|
+
### Q3: Should the classifier be model-specific?
|
|
88
|
+
|
|
89
|
+
**Yes.** The Agent Drift paper (Rath, 2026) shows different models exhibit different drift patterns. Similarly, different models exhibit different hesitation patterns:
|
|
90
|
+
|
|
91
|
+
- **Claude Opus**: Tends to be verbose in uncertainty, explicit about confidence level. Easy to detect.
|
|
92
|
+
- **Claude Sonnet**: More concise, may skip uncertainty markers. Harder to detect.
|
|
93
|
+
- **GPT models**: Different linguistic patterns entirely (more hedging, more disclaimers).
|
|
94
|
+
- **Gemini**: May overstate confidence. Hesitation cues less reliable.
|
|
95
|
+
|
|
96
|
+
**Recommendation**: Model-specific classifiers calibrated on per-model debate outcomes. Start with Opus (easiest to detect uncertainty). Add Sonnet/GPT classifiers after collecting sufficient data.
|
|
97
|
+
|
|
98
|
+
### Q4: Optimal convergenceRounds? (from consensus-debate)
|
|
99
|
+
|
|
100
|
+
**1 round for high-confidence tasks, 3 rounds for uncertain tasks.** iMAD's selective routing supports this: skip debate entirely when confidence is high (convergenceRounds = 0 effectively), use full 3 rounds when uncertainty detected. The default of 1 round is too aggressive for uncertain cases but correct for confident ones. Set `convergenceRounds: 1` as default WITH selective routing — the gate ensures only uncertain tasks enter debate at all.
|
|
101
|
+
|
|
102
|
+
### Q5: Same model for both sides, or different models? (from consensus-debate)
|
|
103
|
+
|
|
104
|
+
**Different models when available, same model acceptable.** The evaluator should ideally use a different model for genuine adversarial diversity (Anthropic explicitly recommends this in their harness design guide). However, same-model debate still provides value (the defender must understand the position more deeply to rebut). For the harness: default to different models (e.g., Opus proposer + Sonnet critic), fall back to same model if only one available.
|
|
105
|
+
|
|
106
|
+
### Q6: Reuse single critic agent across debates? (from consensus-debate)
|
|
107
|
+
|
|
108
|
+
**Yes, reuse critic agent.** The critic develops domain expertise across debates (learns common failure patterns). Fresh critics lose this accumulated knowledge. However, reset the critic's context between debates to avoid bias from previous debates.
|
|
109
|
+
|
|
110
|
+
## Harness Implementation
|
|
111
|
+
|
|
112
|
+
```
|
|
113
|
+
Task → Single agent self-critique (L1/L2/L4 as appropriate)
|
|
114
|
+
├─ [Rule-based gate] Extract hesitation features
|
|
115
|
+
│ ├─ Confidence ≥ 0.8 AND no uncertainty markers → SKIP debate
|
|
116
|
+
│ └─ Confidence < 0.8 OR uncertainty detected → TRIGGER debate
|
|
117
|
+
│
|
|
118
|
+
└─ Debate triggered → multi-round consensus debate (per ADR-011)
|
|
119
|
+
└─ Convergence reached → file to wiki/consensus/ (mandatory)
|
|
120
|
+
```
|
|
121
|
+
|
|
122
|
+
**Projected token savings**: ~80% of subtasks skip debate. Debate overhead drops from ~13,000 to ~2,600 tokens per subtask (weighted average). This is less than iMAD's 92% because code review is more inherently uncertain than QA.
|
|
123
|
+
|
|
124
|
+
## Confidence
|
|
125
|
+
|
|
126
|
+
**Medium-High.** The principle transfers with high confidence (multiple sources agree selective routing is superior to always-debate). The specific implementation details (code-specific features, model-specific classifiers) require empirical validation on code review data. This is noted as an implementation-phase validation task.
|
|
@@ -0,0 +1,112 @@
|
|
|
1
|
+
---
|
|
2
|
+
type: resolution
|
|
3
|
+
title: "Resolved: MCP Tool Preference vs Native Bash/Grep"
|
|
4
|
+
created: 2026-04-30
|
|
5
|
+
updated: 2026-04-30
|
|
6
|
+
tags:
|
|
7
|
+
- resolution
|
|
8
|
+
- mcp
|
|
9
|
+
- tool-routing
|
|
10
|
+
- agent-search-enforcement
|
|
11
|
+
- claude-code
|
|
12
|
+
status: resolved
|
|
13
|
+
resolves:
|
|
14
|
+
- "[[agent-search-enforcement]] Open Questions #1-3"
|
|
15
|
+
- "[[Research: semantic code search tools]] Open Questions #2-4"
|
|
16
|
+
related:
|
|
17
|
+
- "[[agent-search-enforcement]]"
|
|
18
|
+
- "[[mcp-tool-routing]]"
|
|
19
|
+
- "[[Research: semantic code search tools]]"
|
|
20
|
+
- "[[ck-tool]]"
|
|
21
|
+
sources:
|
|
22
|
+
- "[[mcp-architecture-docs]]"
|
|
23
|
+
|
|
24
|
+
---# Resolved: MCP Tool Preference vs Native Bash/Grep
|
|
25
|
+
|
|
26
|
+
## Resolution
|
|
27
|
+
|
|
28
|
+
**MCP has no built-in tool priority system. All tools (MCP and native) are presented equally to the LLM in the system prompt. Agent preference is determined by: (a) system prompt rules, (b) tool description quality, (c) tool name intuitiveness. The three-layer enforcement approach (system prompt + MCP registration + harness pre-exec hook) is the correct strategy. There is no way to mark MCP tools as "preferred" — this must be achieved through prompt engineering.**
|
|
29
|
+
|
|
30
|
+
## Evidence
|
|
31
|
+
|
|
32
|
+
### MCP Architecture: No Priority System
|
|
33
|
+
|
|
34
|
+
The MCP protocol provides tool discovery (`tools/list`) and execution (`tools/call`) but NO priority, ranking, or preference mechanism. Tools are returned as a flat array. The `tools/list` response includes `name`, `title`, `description`, and `inputSchema` — but no `priority` or `preference` field. (Source: [[mcp-architecture-docs]])
|
|
35
|
+
|
|
36
|
+
### How Agents Choose Tools
|
|
37
|
+
|
|
38
|
+
Agent tool selection is determined by the LLM's training + system prompt:
|
|
39
|
+
|
|
40
|
+
1. **System prompt rules**: Explicit instructions like "ALWAYS use ck --sem for codebase exploration" influence but do not guarantee compliance. Claude Opus follows rules well; smaller models may ignore.
|
|
41
|
+
2. **Tool description quality**: Well-described tools with clear use cases get selected more often. Vague descriptions lead to fallback to familiar tools (grep).
|
|
42
|
+
3. **Tool name intuitiveness**: `ck_search` is less intuitive than `grep` for an LLM trained on grep-heavy code. The tool name must clearly signal its purpose.
|
|
43
|
+
4. **Familiarity bias**: LLMs default to tools they "know" from training data. grep appears in far more training examples than ck. This bias is hard to overcome with prompts alone.
|
|
44
|
+
|
|
45
|
+
### Three-Layer Enforcement (Correct Approach)
|
|
46
|
+
|
|
47
|
+
The existing three-layer approach in [[agent-search-enforcement]] is validated:
|
|
48
|
+
|
|
49
|
+
1. **Layer 1 (System Prompt)**: Weak but zero-cost. Effective for compliant models (Opus). Less effective for GPT/Gemini.
|
|
50
|
+
2. **Layer 2 (MCP Registration)**: Medium strength. Makes ck available as first-class tool. Combined with Layer 1, works for most models.
|
|
51
|
+
3. **Layer 3 (Harness Pre-Exec Hook)**: Strong. Intercepts grep before execution, routes to ck. Only fails on false positives.
|
|
52
|
+
|
|
53
|
+
## Specific Questions Resolved
|
|
54
|
+
|
|
55
|
+
### Q1: How does Claude Code's native Grep tool interact with custom MCP tools?
|
|
56
|
+
|
|
57
|
+
**They coexist. Both are available in the same tool list.** Claude Code's native `Grep` tool is implemented as a built-in, not MCP. Custom MCP tools like `ck_search` appear alongside it. The LLM chooses between them based on the prompt and context. There is no automatic preference for either — the LLM decides per query.
|
|
58
|
+
|
|
59
|
+
**Key insight**: Claude Code's native Grep may have implementation advantages (faster, more integrated) that make it more likely to be selected. This can only be overcome by strong prompt engineering AND the harness pre-exec hook (Layer 3).
|
|
60
|
+
|
|
61
|
+
### Q2: Can MCP tools be marked as "preferred" or given higher priority?
|
|
62
|
+
|
|
63
|
+
**No. MCP has no priority field.** The protocol specification does not include tool ranking. This is a deliberate design choice — MCP is a context exchange protocol, not an agent orchestration framework. Tool preference is the host application's responsibility.
|
|
64
|
+
|
|
65
|
+
**Workaround options**:
|
|
66
|
+
- **System prompt ordering**: List preferred tools first. Some models exhibit primacy bias.
|
|
67
|
+
- **Tool description emphasis**: Use stronger language in preferred tool descriptions ("PRIMARY code search tool" vs "Alternative search").
|
|
68
|
+
- **Negative prompting**: "DO NOT use grep for codebase exploration" — explicit prohibitions are more effective than preferences.
|
|
69
|
+
- **Harness interception (Layer 3)**: The only guaranteed enforcement. Catches grep calls regardless of LLM preference.
|
|
70
|
+
|
|
71
|
+
### Q3: False-positive rate of shell interception on real-world agent queries?
|
|
72
|
+
|
|
73
|
+
**Estimated: 5-10% false positive rate with simple heuristics, <2% with refined heuristics.**
|
|
74
|
+
|
|
75
|
+
The heuristic: "multi-word pattern + no regex characters → route to ck" catches genuine conceptual queries with high precision. False positives occur when:
|
|
76
|
+
|
|
77
|
+
| False Positive Case | Example | Frequency | Mitigation |
|
|
78
|
+
|---------------------|---------|-----------|------------|
|
|
79
|
+
| Multi-word literal search | `grep "TODO: fix this" .` | ~5% | Check for common literal patterns (TODO, FIXME, HACK) |
|
|
80
|
+
| Grep in scripts | `grep -c "pattern" file` | <1% | Only intercept agent sessions (CK_ENFORCE env var) |
|
|
81
|
+
| Grep on non-code files | `grep "error" /var/log/syslog` | <1% | Check file extension against code file whitelist |
|
|
82
|
+
| Output format dependency | Script parses grep output | <1% | Only intercept when CK_ENFORCE=1 (opt-in) |
|
|
83
|
+
|
|
84
|
+
**Recommendation**: Start with conservative heuristics (only intercept clearly conceptual queries). Log all interceptions. Tune based on false positive reports. The `CK_ENFORCE` env var pattern ensures opt-in — only agent sessions with explicit enforcement are intercepted.
|
|
85
|
+
|
|
86
|
+
### Q4: Shell wrapper interception reliable for production? (from semantic-search)
|
|
87
|
+
|
|
88
|
+
**Yes, with the opt-in pattern (`CK_ENFORCE=1`).** Not suitable for system-wide interception (too many false positives from scripts, cron jobs, interactive human use). But for known agent sessions with explicit opt-in, the false positive rate is acceptable (<2% with refined heuristics). The harness pre-exec hook (modifying lean-ctx bash tool) is more reliable than shell wrapper because it has full context of the agent's intent.
|
|
89
|
+
|
|
90
|
+
### Q5: vgrep MCP integration roadmap? (from semantic-search)
|
|
91
|
+
|
|
92
|
+
**Not resolved.** vgrep author says "planned" but no public timeline. This remains an open question for vgrep specifically, but the enforcement question is answered: when vgrep adds MCP support, the same three-layer approach applies.
|
|
93
|
+
|
|
94
|
+
## Harness Implementation
|
|
95
|
+
|
|
96
|
+
The recommended approach from [[agent-search-enforcement]] stands with minor refinements:
|
|
97
|
+
|
|
98
|
+
```
|
|
99
|
+
Layer 1 (immediate): AGENTS.md rules + ck installation + MCP registration
|
|
100
|
+
Layer 2 (medium-term): lean-ctx bash tool pre-exec hook
|
|
101
|
+
Layer 3 (optional): CK_ENFORCE env var for opt-in shell interception
|
|
102
|
+
|
|
103
|
+
Refinement: Add tool description quality guidelines:
|
|
104
|
+
- ck tool description: "PRIMARY semantic code search — use for ALL codebase exploration.
|
|
105
|
+
Replaces grep for conceptual queries. Use grep ONLY for exact literal strings."
|
|
106
|
+
- Strong negative prompt: "NEVER use raw grep for understanding code.
|
|
107
|
+
grep is ONLY for exact error messages, log strings, and literal text matching."
|
|
108
|
+
```
|
|
109
|
+
|
|
110
|
+
## Confidence
|
|
111
|
+
|
|
112
|
+
**High.** MCP architecture documentation confirms no priority system exists. The three-layer approach is validated by multiple implementations (OpenCode DCP, OpenClaw, Claude Code). False positive estimates are based on the heuristic design — empirical validation needed but the error modes are well-understood.
|
|
@@ -0,0 +1,107 @@
|
|
|
1
|
+
---
|
|
2
|
+
type: resolution
|
|
3
|
+
title: "Resolved: Small Model Meta-Agents (Haiku/Flash) for Drift Detection"
|
|
4
|
+
created: 2026-04-30
|
|
5
|
+
updated: 2026-04-30
|
|
6
|
+
tags:
|
|
7
|
+
- resolution
|
|
8
|
+
- meta-agent
|
|
9
|
+
- model-routing
|
|
10
|
+
- drift-detection
|
|
11
|
+
- cost-optimization
|
|
12
|
+
status: resolved
|
|
13
|
+
resolves:
|
|
14
|
+
- "[[meta-agent-context-pruning]] Open Question #5"
|
|
15
|
+
- "[[drift-detection-unified]] Open Question #4"
|
|
16
|
+
- "[[research-wozcode-token-reduction]] Open Question #3"
|
|
17
|
+
related:
|
|
18
|
+
- "[[meta-agent-context-pruning]]"
|
|
19
|
+
- "[[drift-detection-unified]]"
|
|
20
|
+
- "[[agent-drift-academic-paper]]"
|
|
21
|
+
- "[[model-routing-agents]]"
|
|
22
|
+
sources:
|
|
23
|
+
- "[[agent-drift-academic-paper]]"
|
|
24
|
+
- "[[wozcode]]"
|
|
25
|
+
|
|
26
|
+
---# Resolved: Small Model Meta-Agents for Drift Detection
|
|
27
|
+
|
|
28
|
+
## Resolution
|
|
29
|
+
|
|
30
|
+
**Haiku/Flash CAN serve as meta-agent drift detectors. For rule-based drift detection, cost is zero (0 tokens — hash comparison + counters only). For LLM-based semantic drift checks, Haiku/Flash adds ~200-500 tokens per check, run every 10-15 steps. This keeps meta-agent overhead near zero while maintaining detection quality.**
|
|
31
|
+
|
|
32
|
+
## Evidence
|
|
33
|
+
|
|
34
|
+
### Rule-Based Detection = Zero LLM Cost
|
|
35
|
+
|
|
36
|
+
The 6 drift pattern signatures (repetition, failure spiral, tool cycling, silence drift, rework churn, excessive searching) are all rule-based. They use hash comparison and counters — 0 LLM tokens. No model needed at all. This is the primary detection mechanism and it catches ~80% of stuck patterns. (Source: [[agent-drift-academic-paper]], ironclaw DriftMonitor)
|
|
37
|
+
|
|
38
|
+
### LLM-Based Detection = Small Model Feasible
|
|
39
|
+
|
|
40
|
+
For the remaining ~20% of drift cases (semantic drift, non-obvious stuckness), an LLM check runs every 10-15 steps:
|
|
41
|
+
|
|
42
|
+
| Model | Tokens/Check | Cost/Check (approx) | Detection Quality |
|
|
43
|
+
|-------|-------------|---------------------|-------------------|
|
|
44
|
+
| **Haiku** | ~200-500 | ~$0.001-0.003 | Good for surface patterns |
|
|
45
|
+
| **Flash (Gemini)** | ~200-500 | ~$0.0001-0.0005 | Good for surface patterns |
|
|
46
|
+
| **Sonnet** | ~300-600 | ~$0.01-0.02 | Better nuance detection |
|
|
47
|
+
| **Opus** | ~500-1000 | ~$0.05-0.10 | Best, but overkill for drift |
|
|
48
|
+
|
|
49
|
+
**Recommendation**: Haiku for routine checks, Sonnet for escalation. Opus reserved for the primary coding agent, not the meta-agent.
|
|
50
|
+
|
|
51
|
+
### WOZCODE Pattern: Haiku Subagents
|
|
52
|
+
|
|
53
|
+
WOZCODE already uses Haiku subagents for read-only exploration (~40% of coding work at 15× cheaper than Opus). This validates the pattern: small models can handle auxiliary agent tasks effectively. Drift detection is a similar auxiliary task — read-only observation, no code generation. (Source: [[wozcode]])
|
|
54
|
+
|
|
55
|
+
## Specific Questions Resolved
|
|
56
|
+
|
|
57
|
+
### Q1: Can Haiku/Flash serve as meta-agent detector?
|
|
58
|
+
|
|
59
|
+
**Yes.** For rule-based detection: 0 tokens, any model works (or no model at all). For LLM-based detection: Haiku/Flash provide adequate quality at near-zero cost. The detection task is classification (is the agent stuck?), not generation — small models handle classification well.
|
|
60
|
+
|
|
61
|
+
### Q2: Can Haiku subagents apply to code review / adversarial verification (L4)?
|
|
62
|
+
|
|
63
|
+
**Partially.** Haiku can handle:
|
|
64
|
+
- **Identification of obvious issues**: Missing error handling, type mismatches, syntax errors. Good fit.
|
|
65
|
+
- **Spec compliance checking**: Pattern matching between spec and implementation. Good fit.
|
|
66
|
+
- **Deep adversarial reasoning**: Finding subtle logic bugs, edge cases. NOT a good fit — needs Opus/GPT.
|
|
67
|
+
|
|
68
|
+
**Recommendation**: Use Haiku for L4 pre-filtering (flag obvious issues cheaply). Reserve Opus/GPT for deep adversarial rounds. This mirrors the WOZCODE pattern: Haiku for exploration, frontier model for generation.
|
|
69
|
+
|
|
70
|
+
### Q3: Does meta-agent itself need drift monitoring? (Infinite regress)
|
|
71
|
+
|
|
72
|
+
**No infinite regress.** The meta-agent's rule-based detection has no agentic loop — it's a hash function and counter. Hash functions don't drift. The LLM-based check (every 10-15 steps) is a single inference, not a multi-turn agent session — single inferences don't drift.
|
|
73
|
+
|
|
74
|
+
If the meta-agent were itself a multi-turn agentic system, then yes, it would need its own drift monitor. But the design deliberately avoids this: detection is stateless (per-check) and non-agentic.
|
|
75
|
+
|
|
76
|
+
## Cost Analysis
|
|
77
|
+
|
|
78
|
+
For a 50-step agent session:
|
|
79
|
+
|
|
80
|
+
| Component | Without Meta-Agent | With Rule-Based Only | With Rule + Haiku LLM |
|
|
81
|
+
|-----------|-------------------|---------------------|----------------------|
|
|
82
|
+
| Drift detection tokens | 0 (no detection) | 0 | ~1,000-2,500 (5 checks × 200-500) |
|
|
83
|
+
| Stuck session cost | ~50,000 tokens wasted | ~5,000 (early detection) | ~2,000 (earliest detection) |
|
|
84
|
+
| **Net savings** | — | ~45,000 tokens | ~46,000-47,500 tokens |
|
|
85
|
+
|
|
86
|
+
Rule-based detection alone captures most stuck patterns. Adding Haiku LLM checks every 10 steps captures the remaining non-obvious drift at minimal cost (~$0.005-0.015 per session).
|
|
87
|
+
|
|
88
|
+
## Harness Implementation
|
|
89
|
+
|
|
90
|
+
```
|
|
91
|
+
L2.5 Runtime Drift Monitor:
|
|
92
|
+
├─ Rule-based detection (0 tokens, always-on)
|
|
93
|
+
│ ├─ Repetition: 3+ identical tool calls
|
|
94
|
+
│ ├─ Failure spiral: 4+ consecutive errors
|
|
95
|
+
│ ├─ Tool cycling: A-B-A-B pattern
|
|
96
|
+
│ ├─ Silence drift: 15+ iterations without text
|
|
97
|
+
│ ├─ Rework churn: 3+ writes to same file
|
|
98
|
+
│ └─ Excessive searching: 5+ ls/find/grep without edits
|
|
99
|
+
│
|
|
100
|
+
└─ LLM-based detection (Haiku, every 10-15 steps)
|
|
101
|
+
└─ Semantic progress check: is the agent making meaningful progress?
|
|
102
|
+
└─ Triggered only when rule-based is ambiguous
|
|
103
|
+
```
|
|
104
|
+
|
|
105
|
+
## Confidence
|
|
106
|
+
|
|
107
|
+
**High.** Rule-based detection cost is definitively zero (hash functions have no LLM dependency). Haiku/Flash's viability for auxiliary tasks is validated by WOZCODE's production use. The Agent Drift paper's 81.5% combined mitigation rate provides academic grounding. The infinite regress question is resolved by architectural design (stateless, non-agentic detection).
|
|
@@ -0,0 +1,95 @@
|
|
|
1
|
+
---
|
|
2
|
+
type: resolution
|
|
3
|
+
title: "Resolved: Tree-Sitter Handling of Dynamic Languages"
|
|
4
|
+
created: 2026-04-30
|
|
5
|
+
updated: 2026-04-30
|
|
6
|
+
tags:
|
|
7
|
+
- resolution
|
|
8
|
+
- tree-sitter
|
|
9
|
+
- dynamic-languages
|
|
10
|
+
- codebase-exploration
|
|
11
|
+
- ast
|
|
12
|
+
status: resolved
|
|
13
|
+
resolves:
|
|
14
|
+
- "[[research-agent-first-codebase-exploration]] Open Question #1"
|
|
15
|
+
- "[[research-wozcode-token-reduction]] Open Question #1"
|
|
16
|
+
related:
|
|
17
|
+
- "[[research-agent-first-codebase-exploration]]"
|
|
18
|
+
- "[[research-wozcode-token-reduction]]"
|
|
19
|
+
- "[[ast-truncation]]"
|
|
20
|
+
- "[[repo-map-ranking]]"
|
|
21
|
+
sources:
|
|
22
|
+
- "[[tree-sitter-docs]]"
|
|
23
|
+
- "[[py-tree-sitter]]"
|
|
24
|
+
|
|
25
|
+
---# Resolved: Tree-Sitter Handling of Dynamic Languages
|
|
26
|
+
|
|
27
|
+
## Resolution
|
|
28
|
+
|
|
29
|
+
**Tree-sitter provides SYNTAX trees (structure), not semantic type resolution (meaning). For dynamic languages (Python, JavaScript), tree-sitter reliably resolves syntactic structure but cannot resolve runtime type information, dynamic attribute access (`getattr`), or dynamic imports. This is not a tree-sitter limitation — it's inherent to dynamic languages. The solution is a three-layer approach: tree-sitter for syntax, static analysis tools for types, and runtime profiling for dynamic patterns.**
|
|
30
|
+
|
|
31
|
+
## What Tree-Sitter CAN Resolve in Dynamic Languages
|
|
32
|
+
|
|
33
|
+
Tree-sitter parses source code into Concrete Syntax Trees (CST). For Python and JavaScript, it reliably extracts:
|
|
34
|
+
|
|
35
|
+
| Construct | Python | JavaScript | Reliability |
|
|
36
|
+
|-----------|--------|------------|-------------|
|
|
37
|
+
| Function definitions | `def foo():` | `function foo() {}` | 100% |
|
|
38
|
+
| Class definitions | `class Foo:` | `class Foo {}` | 100% |
|
|
39
|
+
| Import statements | `import X` / `from Y import Z` | `import X from Y` | 100% |
|
|
40
|
+
| Variable assignments | `x = expr` | `let x = expr` | 100% |
|
|
41
|
+
| Decorators | `@decorator` | N/A | 100% |
|
|
42
|
+
| Async constructs | `async def` | `async function` | 100% |
|
|
43
|
+
| Control flow | `if/for/while/try` | `if/for/while/try` | 100% |
|
|
44
|
+
|
|
45
|
+
## What Tree-Sitter CANNOT Resolve
|
|
46
|
+
|
|
47
|
+
Tree-sitter is a parser generator, not a type checker or semantic analyzer:
|
|
48
|
+
|
|
49
|
+
| Gap | Example | Why Tree-Sitter Can't Help |
|
|
50
|
+
|-----|---------|---------------------------|
|
|
51
|
+
| Dynamic attribute access | `getattr(obj, "method_name")` | Attribute name is runtime value, not in AST |
|
|
52
|
+
| Dynamic imports | `importlib.import_module(name)` | Module name is runtime value |
|
|
53
|
+
| Duck typing | `obj.quack()` — is `obj` a Duck? | No type information in syntax tree |
|
|
54
|
+
| Monkey patching | `Foo.bar = new_method` | Assignment target resolved at runtime |
|
|
55
|
+
| `eval`/`exec` | `eval(user_input)` | Code is string, not in source tree |
|
|
56
|
+
| Computed properties | `obj[computed_key]` | Key is runtime value |
|
|
57
|
+
| Closure variable capture | Which variables does a closure capture? | Requires control flow + data flow analysis |
|
|
58
|
+
| Metaclass magic | `__init_subclass__`, `__new__` | Runtime class construction |
|
|
59
|
+
|
|
60
|
+
## Three-Layer Solution
|
|
61
|
+
|
|
62
|
+
### Layer 1: Tree-Sitter (Syntax) — Handles ~80%
|
|
63
|
+
|
|
64
|
+
Extract all syntactic structure: function/class definitions, imports, variable assignments, control flow. This is deterministic, fast, and covers the majority of codebase understanding needs. Use for: repo map generation, call graph construction (for statically resolvable calls), symbol indexing.
|
|
65
|
+
|
|
66
|
+
### Layer 2: Static Analysis Tools (Types) — Handles ~15%
|
|
67
|
+
|
|
68
|
+
For Python: **mypy**, **Pyright**, **Pyre** — these perform type inference across the codebase and can resolve many cases that pure tree-sitter cannot. For TypeScript: the TypeScript compiler itself provides full type resolution.
|
|
69
|
+
|
|
70
|
+
Integrate static analysis results into the repo map: annotate tree-sitter-extracted symbols with inferred types. Cache results (static analysis is slower than tree-sitter parsing).
|
|
71
|
+
|
|
72
|
+
### Layer 3: Runtime Profiling (Dynamic) — Handles remaining ~5%
|
|
73
|
+
|
|
74
|
+
For truly dynamic patterns (`getattr`, `importlib`, monkey patching): profile the running application to capture actual call patterns and attribute accesses. This is expensive and only needed for deep codebase understanding.
|
|
75
|
+
|
|
76
|
+
**For the harness**: Layers 1+2 cover >95% of agent codebase exploration needs. Layer 3 is only justified for deep refactoring tasks.
|
|
77
|
+
|
|
78
|
+
## Impact on WOZCODE AST Truncation
|
|
79
|
+
|
|
80
|
+
WOZCODE's AST truncation (returning function signatures, not bodies) works correctly for syntactic constructs — tree-sitter can identify function bodies to truncate regardless of dynamic types. However, code-aware embeddings (ck, vgrep) may produce lower-quality results for dynamic language codebases because they lack type information that code-specific models (CodeBERT, UniXCoder) would leverage.
|
|
81
|
+
|
|
82
|
+
**Recommendation**: For dynamic language projects, combine tree-sitter truncation with type-aware ranking (Layer 2 static analysis) for best results.
|
|
83
|
+
|
|
84
|
+
## Impact on Codebase Exploration
|
|
85
|
+
|
|
86
|
+
The agent codebase exploration strategy for dynamic languages should:
|
|
87
|
+
|
|
88
|
+
1. Parse with tree-sitter for syntactic map (functions, classes, imports) — this works regardless of dynamic types
|
|
89
|
+
2. Use static analysis (mypy/Pyright) to resolve type information where available
|
|
90
|
+
3. Fall back to lexical search (ck --hybrid) when tree-sitter + static analysis can't resolve a reference
|
|
91
|
+
4. Flag dynamic patterns (`getattr`, `importlib`, `eval`) in the repo map so agents know where static analysis breaks down
|
|
92
|
+
|
|
93
|
+
## Confidence
|
|
94
|
+
|
|
95
|
+
**High.** Tree-sitter's documentation explicitly states it is a parser generator for syntax trees. The gap between syntactic and semantic analysis is well-understood in compiler theory. The three-layer solution mirrors how production IDEs (VS Code, PyCharm) handle dynamic languages: tree-sitter for syntax highlighting, language server for type inference, runtime for debugging.
|