aios-core 4.2.15 → 4.4.0
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/.aios-core/cli/commands/validate/index.js +1 -1
- package/.aios-core/core/code-intel/code-intel-client.js +19 -5
- package/.aios-core/core/code-intel/helpers/creation-helper.js +183 -0
- package/.aios-core/core/code-intel/helpers/devops-helper.js +166 -0
- package/.aios-core/core/code-intel/helpers/planning-helper.js +248 -0
- package/.aios-core/core/code-intel/helpers/qa-helper.js +187 -0
- package/.aios-core/core/code-intel/helpers/story-helper.js +146 -0
- package/.aios-core/core/code-intel/hook-runtime.js +186 -0
- package/.aios-core/core/code-intel/index.js +2 -0
- package/.aios-core/core/code-intel/providers/code-graph-provider.js +8 -0
- package/.aios-core/core/code-intel/providers/provider-interface.js +9 -0
- package/.aios-core/core/code-intel/providers/registry-provider.js +515 -0
- package/.aios-core/core/config/schemas/framework-config.schema.json +155 -7
- package/.aios-core/core/config/schemas/project-config.schema.json +329 -15
- package/.aios-core/core/config/template-overrides.js +84 -0
- package/.aios-core/core/docs/troubleshooting-guide.md +1 -1
- package/.aios-core/core/doctor/checks/agent-memory.js +63 -0
- package/.aios-core/core/doctor/checks/claude-md.js +56 -0
- package/.aios-core/core/doctor/checks/code-intel.js +131 -0
- package/.aios-core/core/doctor/checks/commands-count.js +81 -0
- package/.aios-core/core/doctor/checks/core-config.js +53 -0
- package/.aios-core/core/doctor/checks/entity-registry.js +53 -0
- package/.aios-core/core/doctor/checks/git-hooks.js +50 -0
- package/.aios-core/core/doctor/checks/graph-dashboard.js +48 -0
- package/.aios-core/core/doctor/checks/hooks-claude-count.js +118 -0
- package/.aios-core/core/doctor/checks/ide-sync.js +85 -0
- package/.aios-core/core/doctor/checks/index.js +46 -0
- package/.aios-core/core/doctor/checks/node-version.js +33 -0
- package/.aios-core/core/doctor/checks/npm-packages.js +35 -0
- package/.aios-core/core/doctor/checks/rules-files.js +61 -0
- package/.aios-core/core/doctor/checks/settings-json.js +121 -0
- package/.aios-core/core/doctor/checks/skills-count.js +72 -0
- package/.aios-core/core/doctor/fix-handler.js +165 -0
- package/.aios-core/core/doctor/formatters/json.js +14 -0
- package/.aios-core/core/doctor/formatters/text.js +59 -0
- package/.aios-core/core/doctor/index.js +94 -0
- package/.aios-core/core/graph-dashboard/cli.js +361 -0
- package/.aios-core/core/graph-dashboard/data-sources/code-intel-source.js +234 -0
- package/.aios-core/core/graph-dashboard/data-sources/metrics-source.js +95 -0
- package/.aios-core/core/graph-dashboard/data-sources/registry-source.js +106 -0
- package/.aios-core/core/graph-dashboard/formatters/dot-formatter.js +45 -0
- package/.aios-core/core/graph-dashboard/formatters/html-formatter.js +1437 -0
- package/.aios-core/core/graph-dashboard/formatters/json-formatter.js +13 -0
- package/.aios-core/core/graph-dashboard/formatters/mermaid-formatter.js +59 -0
- package/.aios-core/core/graph-dashboard/index.js +21 -0
- package/.aios-core/core/graph-dashboard/renderers/stats-renderer.js +217 -0
- package/.aios-core/core/graph-dashboard/renderers/status-renderer.js +125 -0
- package/.aios-core/core/graph-dashboard/renderers/tree-renderer.js +119 -0
- package/.aios-core/core/health-check/base-check.js +1 -1
- package/.aios-core/core/health-check/check-registry.js +1 -1
- package/.aios-core/core/health-check/checks/deployment/build-config.js +1 -1
- package/.aios-core/core/health-check/checks/deployment/ci-config.js +1 -1
- package/.aios-core/core/health-check/checks/deployment/deployment-readiness.js +1 -1
- package/.aios-core/core/health-check/checks/deployment/docker-config.js +1 -1
- package/.aios-core/core/health-check/checks/deployment/env-file.js +1 -1
- package/.aios-core/core/health-check/checks/deployment/index.js +1 -1
- package/.aios-core/core/health-check/checks/index.js +1 -1
- package/.aios-core/core/health-check/checks/local/disk-space.js +1 -1
- package/.aios-core/core/health-check/checks/local/environment-vars.js +1 -1
- package/.aios-core/core/health-check/checks/local/git-install.js +1 -1
- package/.aios-core/core/health-check/checks/local/ide-detection.js +1 -1
- package/.aios-core/core/health-check/checks/local/index.js +1 -1
- package/.aios-core/core/health-check/checks/local/memory.js +1 -1
- package/.aios-core/core/health-check/checks/local/network.js +1 -1
- package/.aios-core/core/health-check/checks/local/npm-install.js +1 -1
- package/.aios-core/core/health-check/checks/local/shell-environment.js +1 -1
- package/.aios-core/core/health-check/checks/project/agent-config.js +1 -1
- package/.aios-core/core/health-check/checks/project/aios-directory.js +1 -1
- package/.aios-core/core/health-check/checks/project/dependencies.js +1 -1
- package/.aios-core/core/health-check/checks/project/framework-config.js +1 -1
- package/.aios-core/core/health-check/checks/project/index.js +1 -1
- package/.aios-core/core/health-check/checks/project/node-version.js +1 -1
- package/.aios-core/core/health-check/checks/project/package-json.js +1 -1
- package/.aios-core/core/health-check/checks/project/task-definitions.js +1 -1
- package/.aios-core/core/health-check/checks/project/workflow-dependencies.js +1 -1
- package/.aios-core/core/health-check/checks/repository/branch-protection.js +1 -1
- package/.aios-core/core/health-check/checks/repository/commit-history.js +1 -1
- package/.aios-core/core/health-check/checks/repository/conflicts.js +1 -1
- package/.aios-core/core/health-check/checks/repository/git-repo.js +1 -1
- package/.aios-core/core/health-check/checks/repository/git-status.js +1 -1
- package/.aios-core/core/health-check/checks/repository/gitignore.js +1 -1
- package/.aios-core/core/health-check/checks/repository/index.js +1 -1
- package/.aios-core/core/health-check/checks/repository/large-files.js +1 -1
- package/.aios-core/core/health-check/checks/repository/lockfile-integrity.js +1 -1
- package/.aios-core/core/health-check/checks/services/api-endpoints.js +1 -1
- package/.aios-core/core/health-check/checks/services/claude-code.js +1 -1
- package/.aios-core/core/health-check/checks/services/gemini-cli.js +1 -1
- package/.aios-core/core/health-check/checks/services/github-cli.js +1 -1
- package/.aios-core/core/health-check/checks/services/index.js +1 -1
- package/.aios-core/core/health-check/checks/services/mcp-integration.js +1 -1
- package/.aios-core/core/health-check/engine.js +1 -1
- package/.aios-core/core/health-check/healers/backup-manager.js +1 -1
- package/.aios-core/core/health-check/healers/index.js +1 -1
- package/.aios-core/core/health-check/index.js +9 -2
- package/.aios-core/core/health-check/reporters/console.js +1 -1
- package/.aios-core/core/health-check/reporters/index.js +1 -1
- package/.aios-core/core/health-check/reporters/json.js +1 -1
- package/.aios-core/core/health-check/reporters/markdown.js +1 -1
- package/.aios-core/core/ids/layer-classifier.js +65 -0
- package/.aios-core/core/ids/registry-updater.js +49 -0
- package/.aios-core/core/index.esm.js +1 -1
- package/.aios-core/core/index.js +1 -1
- package/.aios-core/core/session/context-detector.js +2 -7
- package/.aios-core/core/synapse/context/context-tracker.js +9 -1
- package/.aios-core/core/synapse/engine.js +33 -13
- package/.aios-core/core/synapse/memory/memory-bridge.js +17 -43
- package/.aios-core/core/synapse/memory/synapse-memory-provider.js +201 -0
- package/.aios-core/core/synapse/runtime/hook-runtime.js +40 -2
- package/.aios-core/core/synapse/session/session-manager.js +3 -2
- package/.aios-core/core/synapse/utils/atomic-write.js +79 -0
- package/.aios-core/core-config.yaml +34 -1
- package/.aios-core/data/aios-kb.md +2 -2
- package/.aios-core/data/capability-detection.js +290 -0
- package/.aios-core/data/entity-registry.yaml +10450 -2129
- package/.aios-core/data/mcp-discipline.js +166 -0
- package/.aios-core/data/mcp-tool-examples.yaml +215 -0
- package/.aios-core/data/tok2-validation.js +168 -0
- package/.aios-core/data/tok3-token-comparison.js +123 -0
- package/.aios-core/data/tool-registry.yaml +648 -0
- package/.aios-core/data/tool-search-validation.js +174 -0
- package/.aios-core/data/workflow-chains.yaml +156 -0
- package/.aios-core/development/agents/aios-master.md +17 -10
- package/.aios-core/development/agents/analyst/MEMORY.md +33 -0
- package/.aios-core/development/agents/analyst.md +17 -10
- package/.aios-core/development/agents/architect/MEMORY.md +39 -0
- package/.aios-core/development/agents/architect.md +17 -10
- package/.aios-core/development/agents/data-engineer/MEMORY.md +32 -0
- package/.aios-core/development/agents/data-engineer.md +17 -10
- package/.aios-core/development/agents/dev/MEMORY.md +46 -0
- package/.aios-core/development/agents/dev.md +18 -11
- package/.aios-core/development/agents/devops/MEMORY.md +39 -0
- package/.aios-core/development/agents/devops.md +44 -10
- package/.aios-core/development/agents/pm/MEMORY.md +38 -0
- package/.aios-core/development/agents/pm.md +17 -10
- package/.aios-core/development/agents/po/MEMORY.md +45 -0
- package/.aios-core/development/agents/po.md +17 -10
- package/.aios-core/development/agents/qa/MEMORY.md +42 -0
- package/.aios-core/development/agents/qa.md +18 -11
- package/.aios-core/development/agents/sm/MEMORY.md +31 -0
- package/.aios-core/development/agents/sm.md +17 -10
- package/.aios-core/development/agents/squad-creator.md +18 -9
- package/.aios-core/development/agents/ux/MEMORY.md +31 -0
- package/.aios-core/development/agents/ux-design-expert.md +16 -9
- package/.aios-core/development/checklists/issue-triage-checklist.md +35 -0
- package/.aios-core/development/checklists/memory-audit-checklist.md +53 -0
- package/.aios-core/development/scripts/issue-triage.js +171 -0
- package/.aios-core/development/scripts/populate-entity-registry.js +412 -19
- package/.aios-core/development/scripts/unified-activation-pipeline.js +31 -10
- package/.aios-core/development/tasks/analyze-project-structure.md +48 -0
- package/.aios-core/development/tasks/apply-qa-fixes.md +7 -0
- package/.aios-core/development/tasks/architect-analyze-impact.md +8 -1
- package/.aios-core/development/tasks/brownfield-create-epic.md +41 -0
- package/.aios-core/development/tasks/brownfield-create-story.md +7 -0
- package/.aios-core/development/tasks/build-autonomous.md +7 -0
- package/.aios-core/development/tasks/create-deep-research-prompt.md +7 -0
- package/.aios-core/development/tasks/create-doc.md +44 -0
- package/.aios-core/development/tasks/create-next-story.md +17 -0
- package/.aios-core/development/tasks/create-suite.md +7 -0
- package/.aios-core/development/tasks/dev-develop-story.md +9 -1
- package/.aios-core/development/tasks/execute-checklist.md +7 -0
- package/.aios-core/development/tasks/github-devops-github-pr-automation.md +56 -0
- package/.aios-core/development/tasks/github-devops-pre-push-quality-gate.md +70 -0
- package/.aios-core/development/tasks/github-issue-triage.md +118 -0
- package/.aios-core/development/tasks/health-check.yaml +206 -171
- package/.aios-core/development/tasks/kb-mode-interaction.md +3 -3
- package/.aios-core/development/tasks/plan-create-context.md +47 -1
- package/.aios-core/development/tasks/plan-create-implementation.md +55 -0
- package/.aios-core/development/tasks/po-close-story.md +7 -0
- package/.aios-core/development/tasks/pr-automation.md +5 -5
- package/.aios-core/development/tasks/qa-create-fix-request.md +7 -0
- package/.aios-core/development/tasks/qa-fix-issues.md +7 -0
- package/.aios-core/development/tasks/qa-gate.md +56 -0
- package/.aios-core/development/tasks/qa-review-story.md +32 -1
- package/.aios-core/development/tasks/release-management.md +7 -0
- package/.aios-core/development/tasks/resolve-github-issue.md +608 -0
- package/.aios-core/development/tasks/review-contributor-pr.md +152 -0
- package/.aios-core/development/tasks/setup-llm-routing.md +1 -1
- package/.aios-core/development/tasks/spec-critique.md +8 -0
- package/.aios-core/development/tasks/spec-gather-requirements.md +7 -0
- package/.aios-core/development/tasks/spec-research-dependencies.md +4 -0
- package/.aios-core/development/tasks/spec-write-spec.md +5 -0
- package/.aios-core/development/tasks/triage-github-issues.md +356 -0
- package/.aios-core/development/tasks/validate-agents.md +4 -0
- package/.aios-core/development/tasks/validate-next-story.md +17 -0
- package/.aios-core/development/templates/agent-handoff-tmpl.yaml +48 -0
- package/.aios-core/development/templates/code-intel-integration-pattern.md +199 -0
- package/.aios-core/development/templates/ptc-entity-validation.md +113 -0
- package/.aios-core/development/templates/ptc-qa-gate.md +100 -0
- package/.aios-core/development/templates/ptc-research-aggregation.md +94 -0
- package/.aios-core/development/templates/service-template/README.md.hbs +158 -158
- package/.aios-core/development/templates/service-template/__tests__/index.test.ts.hbs +237 -237
- package/.aios-core/development/templates/service-template/client.ts.hbs +403 -403
- package/.aios-core/development/templates/service-template/errors.ts.hbs +182 -182
- package/.aios-core/development/templates/service-template/index.ts.hbs +120 -120
- package/.aios-core/development/templates/service-template/package.json.hbs +87 -87
- package/.aios-core/development/templates/service-template/types.ts.hbs +145 -145
- package/.aios-core/development/templates/squad/agent-template.md +11 -0
- package/.aios-core/development/templates/squad/task-template.md +21 -0
- package/.aios-core/development/templates/squad-template/LICENSE +21 -21
- package/.aios-core/docs/standards/AIOS-LIVRO-DE-OURO-V2.1-COMPLETE.md +1 -1
- package/.aios-core/docs/standards/AIOS-LIVRO-DE-OURO-V2.2-SUMMARY.md +1 -1
- package/.aios-core/framework-config.yaml +8 -0
- package/.aios-core/index.esm.js +1 -1
- package/.aios-core/index.js +1 -1
- package/.aios-core/infrastructure/integrations/ai-providers/index.js +1 -1
- package/.aios-core/infrastructure/schemas/task-v3-schema.json +6 -0
- package/.aios-core/infrastructure/scripts/collect-tool-usage.js +311 -0
- package/.aios-core/infrastructure/scripts/generate-optimization-report.js +497 -0
- package/.aios-core/infrastructure/scripts/generate-settings-json.js +300 -0
- package/.aios-core/infrastructure/scripts/git-config-detector.js +65 -9
- package/.aios-core/infrastructure/scripts/ide-sync/index.js +3 -1
- package/.aios-core/infrastructure/scripts/ide-sync/transformers/github-copilot.js +184 -0
- package/.aios-core/infrastructure/scripts/repository-detector.js +3 -3
- package/.aios-core/infrastructure/templates/aios-sync.yaml.template +182 -182
- package/.aios-core/infrastructure/templates/coderabbit.yaml.template +279 -279
- package/.aios-core/infrastructure/templates/github-workflows/ci.yml.template +169 -169
- package/.aios-core/infrastructure/templates/github-workflows/pr-automation.yml.template +330 -330
- package/.aios-core/infrastructure/templates/github-workflows/release.yml.template +196 -196
- package/.aios-core/infrastructure/templates/gitignore/gitignore-aios-base.tmpl +63 -63
- package/.aios-core/infrastructure/templates/gitignore/gitignore-brownfield-merge.tmpl +18 -18
- package/.aios-core/infrastructure/templates/gitignore/gitignore-node.tmpl +85 -85
- package/.aios-core/infrastructure/templates/gitignore/gitignore-python.tmpl +145 -145
- package/.aios-core/install-manifest.yaml +613 -305
- package/.aios-core/lib/build.json +1 -0
- package/.aios-core/local-config.yaml.template +71 -71
- package/.aios-core/monitor/hooks/lib/__init__.py +1 -1
- package/.aios-core/monitor/hooks/lib/enrich.py +58 -58
- package/.aios-core/monitor/hooks/lib/send_event.py +47 -47
- package/.aios-core/monitor/hooks/notification.py +29 -29
- package/.aios-core/monitor/hooks/post_tool_use.py +45 -45
- package/.aios-core/monitor/hooks/pre_compact.py +29 -29
- package/.aios-core/monitor/hooks/pre_tool_use.py +40 -40
- package/.aios-core/monitor/hooks/stop.py +29 -29
- package/.aios-core/monitor/hooks/subagent_stop.py +29 -29
- package/.aios-core/monitor/hooks/user_prompt_submit.py +38 -38
- package/.aios-core/product/templates/adr.hbs +125 -125
- package/.aios-core/product/templates/dbdr.hbs +241 -241
- package/.aios-core/product/templates/epic.hbs +212 -212
- package/.aios-core/product/templates/ide-rules/claude-rules.md +125 -0
- package/.aios-core/product/templates/pmdr.hbs +186 -186
- package/.aios-core/product/templates/prd-v2.0.hbs +216 -216
- package/.aios-core/product/templates/prd.hbs +201 -201
- package/.aios-core/product/templates/story.hbs +263 -263
- package/.aios-core/product/templates/task.hbs +170 -170
- package/.aios-core/product/templates/tmpl-comment-on-examples.sql +158 -158
- package/.aios-core/product/templates/tmpl-migration-script.sql +91 -91
- package/.aios-core/product/templates/tmpl-rls-granular-policies.sql +104 -104
- package/.aios-core/product/templates/tmpl-rls-kiss-policy.sql +10 -10
- package/.aios-core/product/templates/tmpl-rls-roles.sql +135 -135
- package/.aios-core/product/templates/tmpl-rls-simple.sql +77 -77
- package/.aios-core/product/templates/tmpl-rls-tenant.sql +152 -152
- package/.aios-core/product/templates/tmpl-rollback-script.sql +77 -77
- package/.aios-core/product/templates/tmpl-seed-data.sql +140 -140
- package/.aios-core/product/templates/tmpl-smoke-test.sql +16 -16
- package/.aios-core/product/templates/tmpl-staging-copy-merge.sql +139 -139
- package/.aios-core/product/templates/tmpl-stored-proc.sql +140 -140
- package/.aios-core/product/templates/tmpl-trigger.sql +152 -152
- package/.aios-core/product/templates/tmpl-view-materialized.sql +133 -133
- package/.aios-core/product/templates/tmpl-view.sql +177 -177
- package/.aios-core/scripts/pm.sh +0 -0
- package/.aios-core/user-guide.md +15 -15
- package/.aios-core/utils/filters/constants.js +10 -0
- package/.aios-core/utils/filters/content-filter.js +223 -0
- package/.aios-core/utils/filters/field-filter.js +126 -0
- package/.aios-core/utils/filters/index.js +180 -0
- package/.aios-core/utils/filters/schema-filter.js +157 -0
- package/.claude/CLAUDE.md +62 -0
- package/.claude/hooks/enforce-architecture-first.py +196 -196
- package/.claude/hooks/enforce-git-push-authority.sh +33 -0
- package/.claude/hooks/mind-clone-governance.py +192 -192
- package/.claude/hooks/read-protection.py +151 -151
- package/.claude/hooks/slug-validation.py +176 -176
- package/.claude/hooks/sql-governance.py +182 -182
- package/.claude/hooks/synapse-engine.cjs +28 -5
- package/.claude/hooks/write-path-validation.py +194 -194
- package/.claude/rules/agent-authority.md +105 -0
- package/.claude/rules/agent-handoff.md +97 -0
- package/.claude/rules/agent-memory-imports.md +15 -0
- package/.claude/rules/coderabbit-integration.md +101 -0
- package/.claude/rules/ids-principles.md +119 -0
- package/.claude/rules/story-lifecycle.md +145 -0
- package/.claude/rules/tool-examples.md +64 -0
- package/.claude/rules/tool-response-filtering.md +57 -0
- package/.claude/rules/workflow-execution.md +150 -0
- package/LICENSE +33 -33
- package/bin/aios-graph.js +9 -0
- package/bin/aios-init.js +2 -2
- package/bin/aios-minimal.js +0 -0
- package/bin/aios.js +17 -221
- package/bin/utils/detect-fsmonitor.js +70 -0
- package/bin/utils/framework-guard.js +238 -0
- package/bin/utils/validate-publish.js +108 -0
- package/package.json +6 -3
- package/packages/aios-install/bin/aios-install.js +0 -0
- package/packages/aios-install/bin/edmcp.js +0 -0
- package/packages/aios-pro-cli/bin/aios-pro.js +2 -0
- package/packages/installer/src/config/templates/core-config-template.js +25 -0
- package/packages/installer/src/installer/brownfield-upgrader.js +68 -5
- package/packages/installer/src/merger/index.js +3 -0
- package/packages/installer/src/merger/strategies/index.js +6 -0
- package/packages/installer/src/merger/strategies/yaml-merger.js +181 -0
- package/packages/installer/src/updater/index.js +4 -4
- package/packages/installer/src/wizard/i18n.js +321 -3
- package/packages/installer/src/wizard/ide-config-generator.js +173 -25
- package/packages/installer/src/wizard/index.js +119 -1
- package/packages/installer/src/wizard/pro-setup.js +137 -121
- package/packages/installer/tests/unit/artifact-copy-pipeline/artifact-copy-pipeline.test.js +271 -0
- package/packages/installer/tests/unit/claude-md-template-v5/claude-md-template-v5.test.js +192 -0
- package/packages/installer/tests/unit/doctor/doctor-checks.test.js +610 -0
- package/packages/installer/tests/unit/doctor/doctor-orchestrator.test.js +134 -0
- package/packages/installer/tests/unit/entity-registry-bootstrap.test.js +186 -0
- package/packages/installer/tests/unit/generate-settings-json/generate-settings-json.test.js +309 -0
- package/packages/installer/tests/unit/ide-sync-integration/ide-sync-integration.test.js +230 -0
- package/packages/installer/tests/unit/merger/strategies.test.js +2 -2
- package/packages/installer/tests/unit/merger/yaml-merger.test.js +327 -0
- package/scripts/check-markdown-links.py +352 -352
- package/scripts/dashboard-parallel-dev.sh +0 -0
- package/scripts/dashboard-parallel-phase3.sh +0 -0
- package/scripts/dashboard-parallel-phase4.sh +0 -0
- package/scripts/install-monitor-hooks.sh +0 -0
- package/scripts/package-synapse.js +2 -1
- package/pro/README.md +0 -66
- package/pro/license/degradation.js +0 -220
- package/pro/license/errors.js +0 -450
- package/pro/license/feature-gate.js +0 -354
- package/pro/license/index.js +0 -181
- package/pro/license/license-api.js +0 -651
- package/pro/license/license-cache.js +0 -523
- package/pro/license/license-crypto.js +0 -303
|
@@ -0,0 +1,199 @@
|
|
|
1
|
+
# Code Intelligence Integration Pattern
|
|
2
|
+
|
|
3
|
+
> Standard pattern for integrating code intelligence into new tasks and helpers.
|
|
4
|
+
> Follow this template to ensure consistent, provider-agnostic integration with graceful fallback.
|
|
5
|
+
|
|
6
|
+
## Pattern Overview
|
|
7
|
+
|
|
8
|
+
```
|
|
9
|
+
import → isCodeIntelAvailable guard → enrich → fallback (return null)
|
|
10
|
+
```
|
|
11
|
+
|
|
12
|
+
All code intelligence integrations MUST follow this 4-step pattern:
|
|
13
|
+
|
|
14
|
+
1. **Import** from the code-intel public API (`../index` or relative path)
|
|
15
|
+
2. **Guard** with `isCodeIntelAvailable()` — return null if no provider
|
|
16
|
+
3. **Enrich** by calling enricher/client capabilities inside try/catch
|
|
17
|
+
4. **Fallback** — always return null on any error, never throw
|
|
18
|
+
|
|
19
|
+
## Complete Example
|
|
20
|
+
|
|
21
|
+
```javascript
|
|
22
|
+
'use strict';
|
|
23
|
+
|
|
24
|
+
const { getEnricher, getClient, isCodeIntelAvailable } = require('../index');
|
|
25
|
+
|
|
26
|
+
/**
|
|
27
|
+
* ModuleDoc — describe the helper's purpose and target agent/task.
|
|
28
|
+
*
|
|
29
|
+
* All functions return null gracefully when no provider is available.
|
|
30
|
+
* Never throws — safe to call unconditionally in task workflows.
|
|
31
|
+
*/
|
|
32
|
+
|
|
33
|
+
async function myFunction(param) {
|
|
34
|
+
// Step 1: Input validation
|
|
35
|
+
if (!param) return null;
|
|
36
|
+
|
|
37
|
+
// Step 2: Provider guard
|
|
38
|
+
if (!isCodeIntelAvailable()) return null;
|
|
39
|
+
|
|
40
|
+
try {
|
|
41
|
+
// Step 3: Call enricher (composite) or client (primitive)
|
|
42
|
+
const enricher = getEnricher();
|
|
43
|
+
const result = await enricher.someCapability(param);
|
|
44
|
+
|
|
45
|
+
// Validate result
|
|
46
|
+
if (!result) return null;
|
|
47
|
+
|
|
48
|
+
// Step 4: Format and return
|
|
49
|
+
return {
|
|
50
|
+
// ... formatted result
|
|
51
|
+
};
|
|
52
|
+
} catch {
|
|
53
|
+
// Never throw — return null on any error
|
|
54
|
+
return null;
|
|
55
|
+
}
|
|
56
|
+
}
|
|
57
|
+
|
|
58
|
+
module.exports = { myFunction };
|
|
59
|
+
```
|
|
60
|
+
|
|
61
|
+
## Partial Results Pattern
|
|
62
|
+
|
|
63
|
+
When calling multiple capabilities, use per-capability try/catch to accept partial results:
|
|
64
|
+
|
|
65
|
+
```javascript
|
|
66
|
+
async function multiCapabilityFunction(param) {
|
|
67
|
+
if (!param) return null;
|
|
68
|
+
if (!isCodeIntelAvailable()) return null;
|
|
69
|
+
|
|
70
|
+
try {
|
|
71
|
+
const enricher = getEnricher();
|
|
72
|
+
const client = getClient();
|
|
73
|
+
|
|
74
|
+
let dataA = null;
|
|
75
|
+
let dataB = null;
|
|
76
|
+
|
|
77
|
+
try {
|
|
78
|
+
dataA = await enricher.describeProject(param);
|
|
79
|
+
} catch { /* skip — partial result ok */ }
|
|
80
|
+
|
|
81
|
+
try {
|
|
82
|
+
dataB = await client.findReferences(param);
|
|
83
|
+
} catch { /* skip — partial result ok */ }
|
|
84
|
+
|
|
85
|
+
// Return null only if we got nothing at all
|
|
86
|
+
if (!dataA && !dataB) return null;
|
|
87
|
+
|
|
88
|
+
return { dataA, dataB };
|
|
89
|
+
} catch {
|
|
90
|
+
return null;
|
|
91
|
+
}
|
|
92
|
+
}
|
|
93
|
+
```
|
|
94
|
+
|
|
95
|
+
## Available Capabilities
|
|
96
|
+
|
|
97
|
+
### Enricher (composite — via `getEnricher()`)
|
|
98
|
+
|
|
99
|
+
| Capability | Input | Output | Use Case |
|
|
100
|
+
|-----------|-------|--------|----------|
|
|
101
|
+
| `describeProject(path)` | Path string | `{ codebase, stats }` | Project overview |
|
|
102
|
+
| `getConventions(path)` | Path string | `{ patterns, stats }` | Naming/coding patterns |
|
|
103
|
+
| `detectDuplicates(desc, opts)` | Description + options | `{ matches, codebaseOverview }` | Duplicate detection |
|
|
104
|
+
| `assessImpact(files)` | File array | `{ blastRadius, references, complexity }` | Change impact |
|
|
105
|
+
| `findTests(symbol)` | Symbol name | Test file references | Test discovery |
|
|
106
|
+
|
|
107
|
+
### Client (primitive — via `getClient()`)
|
|
108
|
+
|
|
109
|
+
| Capability | Input | Output | Use Case |
|
|
110
|
+
|-----------|-------|--------|----------|
|
|
111
|
+
| `findReferences(symbol)` | Symbol name | `[{ file, line, context }]` | Symbol usage |
|
|
112
|
+
| `findDefinition(symbol)` | Symbol name | `{ file, line, column }` | Symbol definition |
|
|
113
|
+
| `analyzeDependencies(path)` | Path string | `{ nodes, edges }` | Dependency graph |
|
|
114
|
+
| `findCallers(symbol)` | Symbol name | Caller references | Call graph (inbound) |
|
|
115
|
+
| `findCallees(symbol)` | Symbol name | Callee references | Call graph (outbound) |
|
|
116
|
+
| `analyzeComplexity(path)` | Path string | Complexity metrics | Code complexity |
|
|
117
|
+
| `analyzeCodebase(path)` | Path string | Codebase overview | Full analysis |
|
|
118
|
+
| `getProjectStats(path)` | Path string | Project statistics | Stats only |
|
|
119
|
+
|
|
120
|
+
## Testing Pattern
|
|
121
|
+
|
|
122
|
+
### Mock Strategy
|
|
123
|
+
|
|
124
|
+
```javascript
|
|
125
|
+
// Mock the code-intel module at the top of your test file
|
|
126
|
+
jest.mock('../../.aios-core/core/code-intel/index', () => ({
|
|
127
|
+
isCodeIntelAvailable: jest.fn(),
|
|
128
|
+
getEnricher: jest.fn(),
|
|
129
|
+
getClient: jest.fn(),
|
|
130
|
+
}));
|
|
131
|
+
|
|
132
|
+
const {
|
|
133
|
+
isCodeIntelAvailable,
|
|
134
|
+
getEnricher,
|
|
135
|
+
getClient,
|
|
136
|
+
} = require('../../.aios-core/core/code-intel/index');
|
|
137
|
+
```
|
|
138
|
+
|
|
139
|
+
### Required Test Scenarios
|
|
140
|
+
|
|
141
|
+
Every code intelligence integration MUST test:
|
|
142
|
+
|
|
143
|
+
1. **Happy path** — provider available, data returned
|
|
144
|
+
2. **Fallback** — provider unavailable (`isCodeIntelAvailable` returns false)
|
|
145
|
+
3. **Error handling** — provider throws (enricher/client rejects)
|
|
146
|
+
4. **Empty input** — null/empty parameters
|
|
147
|
+
5. **Partial results** — one capability fails, other succeeds (if multi-capability)
|
|
148
|
+
|
|
149
|
+
### Test Helper Setup
|
|
150
|
+
|
|
151
|
+
```javascript
|
|
152
|
+
function setupProviderAvailable() {
|
|
153
|
+
isCodeIntelAvailable.mockReturnValue(true);
|
|
154
|
+
}
|
|
155
|
+
|
|
156
|
+
function setupProviderUnavailable() {
|
|
157
|
+
isCodeIntelAvailable.mockReturnValue(false);
|
|
158
|
+
}
|
|
159
|
+
|
|
160
|
+
function createMockEnricher(overrides = {}) {
|
|
161
|
+
const enricher = {
|
|
162
|
+
detectDuplicates: jest.fn().mockResolvedValue(null),
|
|
163
|
+
getConventions: jest.fn().mockResolvedValue(null),
|
|
164
|
+
describeProject: jest.fn().mockResolvedValue(null),
|
|
165
|
+
assessImpact: jest.fn().mockResolvedValue(null),
|
|
166
|
+
findTests: jest.fn().mockResolvedValue(null),
|
|
167
|
+
...overrides,
|
|
168
|
+
};
|
|
169
|
+
getEnricher.mockReturnValue(enricher);
|
|
170
|
+
return enricher;
|
|
171
|
+
}
|
|
172
|
+
|
|
173
|
+
function createMockClient(overrides = {}) {
|
|
174
|
+
const client = {
|
|
175
|
+
findReferences: jest.fn().mockResolvedValue(null),
|
|
176
|
+
findDefinition: jest.fn().mockResolvedValue(null),
|
|
177
|
+
analyzeDependencies: jest.fn().mockResolvedValue(null),
|
|
178
|
+
// ... add other capabilities as needed
|
|
179
|
+
...overrides,
|
|
180
|
+
};
|
|
181
|
+
getClient.mockReturnValue(client);
|
|
182
|
+
return client;
|
|
183
|
+
}
|
|
184
|
+
```
|
|
185
|
+
|
|
186
|
+
## Existing Helpers (Reference)
|
|
187
|
+
|
|
188
|
+
| Helper | Agent | Functions | Story |
|
|
189
|
+
|--------|-------|-----------|-------|
|
|
190
|
+
| `dev-helper.js` | @dev | checkBeforeWriting, suggestReuse, getConventionsForPath, assessRefactoringImpact | NOG-3 |
|
|
191
|
+
| `qa-helper.js` | @qa | validateTestCoverage, detectRegressionRisk | NOG-4 |
|
|
192
|
+
| `planning-helper.js` | @architect | analyzeComplexity, suggestArchitecture | NOG-5 |
|
|
193
|
+
| `story-helper.js` | @sm/@po | detectDuplicateStory, suggestRelevantFiles, validateNoDuplicates | NOG-6 |
|
|
194
|
+
| `devops-helper.js` | @devops | assessDeploymentRisk, validatePipelineImpact | NOG-7 |
|
|
195
|
+
| `creation-helper.js` | squad-creator | getCodebaseContext, checkDuplicateArtefact, enrichRegistryEntry | NOG-8 |
|
|
196
|
+
|
|
197
|
+
---
|
|
198
|
+
|
|
199
|
+
*Template created for Story NOG-8 — Code Intelligence Integration Pattern*
|
|
@@ -0,0 +1,113 @@
|
|
|
1
|
+
# PTC Template: Entity Validation Batch
|
|
2
|
+
|
|
3
|
+
---
|
|
4
|
+
execution_mode: programmatic
|
|
5
|
+
ptc_type: bash-batch # Fallback — true PTC not available in Claude Code CLI (ADR-7)
|
|
6
|
+
adr_reference: ADR-3 (PTC native ONLY — no MCP tools in batch blocks)
|
|
7
|
+
story: TOK-3
|
|
8
|
+
---
|
|
9
|
+
|
|
10
|
+
## Purpose
|
|
11
|
+
|
|
12
|
+
Batch-scan all entities in entity-registry.yaml against their validation rules.
|
|
13
|
+
N entities x M checks consolidated into a single Bash block with one summary output.
|
|
14
|
+
|
|
15
|
+
**Token savings:** ~20-30% vs individual Grep/Read calls per entity.
|
|
16
|
+
|
|
17
|
+
## Restriction (ADR-3)
|
|
18
|
+
|
|
19
|
+
**ONLY native/CLI tools allowed inside this batch block.**
|
|
20
|
+
MCP tools are EXCLUDED. Uses: Bash, grep (via bash), file reads (via bash).
|
|
21
|
+
|
|
22
|
+
## Template
|
|
23
|
+
|
|
24
|
+
```bash
|
|
25
|
+
#!/bin/bash
|
|
26
|
+
# PTC-ENTITY-VALIDATION: Batch entity registry scan
|
|
27
|
+
# Usage: Execute as single Bash tool call. Only the final summary enters context.
|
|
28
|
+
|
|
29
|
+
REGISTRY=".aios-core/data/entity-registry.yaml"
|
|
30
|
+
TOOL_REGISTRY=".aios-core/data/tool-registry.yaml"
|
|
31
|
+
|
|
32
|
+
PASS=0
|
|
33
|
+
FAIL=0
|
|
34
|
+
WARN=0
|
|
35
|
+
RESULTS=""
|
|
36
|
+
|
|
37
|
+
# --- Check 1: Registry file exists ---
|
|
38
|
+
if [ ! -f "$REGISTRY" ]; then
|
|
39
|
+
echo "FATAL: entity-registry.yaml not found at $REGISTRY"
|
|
40
|
+
exit 1
|
|
41
|
+
fi
|
|
42
|
+
|
|
43
|
+
# --- Check 2: Required fields present in each entity ---
|
|
44
|
+
required_fields=("name" "type" "layer" "description")
|
|
45
|
+
for field in "${required_fields[@]}"; do
|
|
46
|
+
count=$(grep -c " $field:" "$REGISTRY" 2>/dev/null || echo "0")
|
|
47
|
+
if [ "$count" -gt 0 ]; then
|
|
48
|
+
RESULTS+="FIELD '$field': found $count occurrences — PASS\n"
|
|
49
|
+
((PASS++))
|
|
50
|
+
else
|
|
51
|
+
RESULTS+="FIELD '$field': NOT FOUND — FAIL\n"
|
|
52
|
+
((FAIL++))
|
|
53
|
+
fi
|
|
54
|
+
done
|
|
55
|
+
|
|
56
|
+
# --- Check 3: No duplicate entity names ---
|
|
57
|
+
duplicates=$(grep "^ [a-zA-Z]" "$REGISTRY" | sort | uniq -d)
|
|
58
|
+
if [ -z "$duplicates" ]; then
|
|
59
|
+
RESULTS+="DUPLICATES: none — PASS\n"
|
|
60
|
+
((PASS++))
|
|
61
|
+
else
|
|
62
|
+
RESULTS+="DUPLICATES: found\n$duplicates\n— FAIL\n"
|
|
63
|
+
((FAIL++))
|
|
64
|
+
fi
|
|
65
|
+
|
|
66
|
+
# --- Check 4: Tool registry consistency ---
|
|
67
|
+
if [ -f "$TOOL_REGISTRY" ]; then
|
|
68
|
+
tool_count=$(grep -c "tier:" "$TOOL_REGISTRY" 2>/dev/null || echo "0")
|
|
69
|
+
RESULTS+="TOOL-REGISTRY: $tool_count tools found — PASS\n"
|
|
70
|
+
((PASS++))
|
|
71
|
+
else
|
|
72
|
+
RESULTS+="TOOL-REGISTRY: file missing — WARN\n"
|
|
73
|
+
((WARN++))
|
|
74
|
+
fi
|
|
75
|
+
|
|
76
|
+
# --- Check 5: Layer annotations valid (L1-L4) ---
|
|
77
|
+
invalid_layers=$(grep "layer:" "$REGISTRY" | grep -v "L[1-4]" | head -5)
|
|
78
|
+
if [ -z "$invalid_layers" ]; then
|
|
79
|
+
RESULTS+="LAYERS: all valid (L1-L4) — PASS\n"
|
|
80
|
+
((PASS++))
|
|
81
|
+
else
|
|
82
|
+
RESULTS+="LAYERS: invalid entries found\n$invalid_layers\n— FAIL\n"
|
|
83
|
+
((FAIL++))
|
|
84
|
+
fi
|
|
85
|
+
|
|
86
|
+
# --- Summary ---
|
|
87
|
+
echo "=== ENTITY VALIDATION SUMMARY ==="
|
|
88
|
+
echo "Passed: $PASS | Failed: $FAIL | Warnings: $WARN"
|
|
89
|
+
echo ""
|
|
90
|
+
echo -e "$RESULTS"
|
|
91
|
+
|
|
92
|
+
if [ $FAIL -gt 0 ]; then
|
|
93
|
+
echo "VERDICT: FAIL"
|
|
94
|
+
exit 1
|
|
95
|
+
else
|
|
96
|
+
echo "VERDICT: PASS"
|
|
97
|
+
exit 0
|
|
98
|
+
fi
|
|
99
|
+
```
|
|
100
|
+
|
|
101
|
+
## Token Comparison
|
|
102
|
+
|
|
103
|
+
| Approach | Tool Calls | Context Entries | Estimated Tokens |
|
|
104
|
+
|----------|-----------|-----------------|-----------------|
|
|
105
|
+
| Direct (N checks) | 5-10 | 5-10 (each result) | ~5,000-10,000 |
|
|
106
|
+
| Batch (1 call) | 1 | 1 (summary only) | ~2,000-3,000 |
|
|
107
|
+
| **Reduction** | -80% calls | -80% entries | **~20-40%** |
|
|
108
|
+
|
|
109
|
+
## Notes
|
|
110
|
+
|
|
111
|
+
- Extensible: add more checks by appending to the script
|
|
112
|
+
- Each check reports PASS/FAIL/WARN independently
|
|
113
|
+
- Only summary enters context — intermediate grep/read results stay in shell
|
|
@@ -0,0 +1,100 @@
|
|
|
1
|
+
# PTC Template: QA Gate Batch
|
|
2
|
+
|
|
3
|
+
---
|
|
4
|
+
execution_mode: programmatic
|
|
5
|
+
ptc_type: bash-batch # Fallback — true PTC not available in Claude Code CLI (ADR-7)
|
|
6
|
+
adr_reference: ADR-3 (PTC native ONLY — no MCP tools in batch blocks)
|
|
7
|
+
story: TOK-3
|
|
8
|
+
---
|
|
9
|
+
|
|
10
|
+
## Purpose
|
|
11
|
+
|
|
12
|
+
Consolidate QA Gate checks (lint, typecheck, test) into a single Bash block.
|
|
13
|
+
Intermediate results stay in shell variables — only the final summary enters context.
|
|
14
|
+
|
|
15
|
+
**Token savings:** ~20% vs 3 separate tool calls (conservative estimate).
|
|
16
|
+
True PTC (API-level) would yield ~37% but is not available in Claude Code CLI.
|
|
17
|
+
|
|
18
|
+
## Restriction (ADR-3)
|
|
19
|
+
|
|
20
|
+
**ONLY native/CLI tools allowed inside this batch block.**
|
|
21
|
+
MCP tools (EXA, Playwright, Apify, Context7, Nogic, Code-Graph) are EXCLUDED.
|
|
22
|
+
|
|
23
|
+
Eligible tools: Bash, Read, Write, Edit, Grep, Glob (all `ptc_eligible: true` in tool-registry.yaml).
|
|
24
|
+
|
|
25
|
+
## Template
|
|
26
|
+
|
|
27
|
+
```bash
|
|
28
|
+
#!/bin/bash
|
|
29
|
+
# PTC-QA-GATE: Batch quality checks — single Bash block, one summary output
|
|
30
|
+
# Usage: Execute as single Bash tool call. Only the final echo enters context.
|
|
31
|
+
|
|
32
|
+
set -o pipefail
|
|
33
|
+
|
|
34
|
+
PASS=0
|
|
35
|
+
FAIL=0
|
|
36
|
+
RESULTS=""
|
|
37
|
+
|
|
38
|
+
# --- Check 1: Lint ---
|
|
39
|
+
lint_output=$(npm run lint 2>&1)
|
|
40
|
+
lint_exit=$?
|
|
41
|
+
if [ $lint_exit -eq 0 ]; then
|
|
42
|
+
RESULTS+="LINT: PASS\n"
|
|
43
|
+
((PASS++))
|
|
44
|
+
else
|
|
45
|
+
RESULTS+="LINT: FAIL\n${lint_output}\n"
|
|
46
|
+
((FAIL++))
|
|
47
|
+
fi
|
|
48
|
+
|
|
49
|
+
# --- Check 2: TypeCheck ---
|
|
50
|
+
typecheck_output=$(npm run typecheck 2>&1)
|
|
51
|
+
typecheck_exit=$?
|
|
52
|
+
if [ $typecheck_exit -eq 0 ]; then
|
|
53
|
+
RESULTS+="TYPECHECK: PASS\n"
|
|
54
|
+
((PASS++))
|
|
55
|
+
else
|
|
56
|
+
RESULTS+="TYPECHECK: FAIL\n${typecheck_output}\n"
|
|
57
|
+
((FAIL++))
|
|
58
|
+
fi
|
|
59
|
+
|
|
60
|
+
# --- Check 3: Tests ---
|
|
61
|
+
test_output=$(npm test 2>&1)
|
|
62
|
+
test_exit=$?
|
|
63
|
+
if [ $test_exit -eq 0 ]; then
|
|
64
|
+
RESULTS+="TESTS: PASS\n"
|
|
65
|
+
((PASS++))
|
|
66
|
+
else
|
|
67
|
+
RESULTS+="TESTS: FAIL\n${test_output}\n"
|
|
68
|
+
((FAIL++))
|
|
69
|
+
fi
|
|
70
|
+
|
|
71
|
+
# --- Summary (only this enters context) ---
|
|
72
|
+
echo "=== QA GATE SUMMARY ==="
|
|
73
|
+
echo "Passed: $PASS / $((PASS + FAIL))"
|
|
74
|
+
echo "Failed: $FAIL"
|
|
75
|
+
echo ""
|
|
76
|
+
echo -e "$RESULTS"
|
|
77
|
+
|
|
78
|
+
if [ $FAIL -gt 0 ]; then
|
|
79
|
+
echo "VERDICT: FAIL"
|
|
80
|
+
exit 1
|
|
81
|
+
else
|
|
82
|
+
echo "VERDICT: PASS"
|
|
83
|
+
exit 0
|
|
84
|
+
fi
|
|
85
|
+
```
|
|
86
|
+
|
|
87
|
+
## Token Comparison
|
|
88
|
+
|
|
89
|
+
| Approach | Tool Calls | Context Entries | Estimated Tokens |
|
|
90
|
+
|----------|-----------|-----------------|-----------------|
|
|
91
|
+
| Direct (3 calls) | 3 | 3 (each result) | ~3,000-9,000 |
|
|
92
|
+
| Batch (1 call) | 1 | 1 (summary only) | ~1,500-3,000 |
|
|
93
|
+
| **Reduction** | -67% calls | -67% entries | **~20-50%** |
|
|
94
|
+
|
|
95
|
+
## Notes
|
|
96
|
+
|
|
97
|
+
- If any check fails, the full output for that check is included in summary
|
|
98
|
+
- Passing checks show only "PASS" (minimal context)
|
|
99
|
+
- Exit code 1 = at least one check failed
|
|
100
|
+
- This template can be extended with additional checks (build, coverage, etc.)
|
|
@@ -0,0 +1,94 @@
|
|
|
1
|
+
# PTC Template: Research Aggregation Batch
|
|
2
|
+
|
|
3
|
+
---
|
|
4
|
+
execution_mode: programmatic
|
|
5
|
+
ptc_type: bash-batch # Fallback — true PTC not available in Claude Code CLI (ADR-7)
|
|
6
|
+
adr_reference: ADR-3 (PTC native ONLY — no MCP tools in batch blocks)
|
|
7
|
+
story: TOK-3
|
|
8
|
+
---
|
|
9
|
+
|
|
10
|
+
## Purpose
|
|
11
|
+
|
|
12
|
+
Consolidate multi-file research aggregation (scan docs, extract findings, merge)
|
|
13
|
+
into a single Bash block. Intermediate grep/read results stay in shell variables.
|
|
14
|
+
|
|
15
|
+
**Token savings:** ~20% vs multiple Read + Grep tool calls.
|
|
16
|
+
|
|
17
|
+
**Note:** This template uses native CLI tools only. For web-based research
|
|
18
|
+
(WebSearch, EXA), those tool calls must remain separate — they are NOT
|
|
19
|
+
ptc_eligible (MCP tools excluded per ADR-3). This template covers the
|
|
20
|
+
**aggregation** phase (local file scanning), not the **search** phase.
|
|
21
|
+
|
|
22
|
+
## Restriction (ADR-3)
|
|
23
|
+
|
|
24
|
+
**ONLY native/CLI tools allowed inside this batch block.**
|
|
25
|
+
MCP tools (EXA, Context7, Apify) are EXCLUDED from batch blocks.
|
|
26
|
+
WebSearch/WebFetch are native Tier 1 but operate as API calls — they can be
|
|
27
|
+
included in batch if executed via shell scripting patterns.
|
|
28
|
+
|
|
29
|
+
## Template
|
|
30
|
+
|
|
31
|
+
```bash
|
|
32
|
+
#!/bin/bash
|
|
33
|
+
# PTC-RESEARCH-AGGREGATION: Batch scan research docs and aggregate findings
|
|
34
|
+
# Usage: Execute as single Bash tool call. Only the final summary enters context.
|
|
35
|
+
|
|
36
|
+
RESEARCH_DIR="docs/research"
|
|
37
|
+
OUTPUT=""
|
|
38
|
+
TOPICS_FOUND=0
|
|
39
|
+
FILES_SCANNED=0
|
|
40
|
+
|
|
41
|
+
# --- Scan all research directories ---
|
|
42
|
+
for dir in "$RESEARCH_DIR"/*/; do
|
|
43
|
+
if [ -d "$dir" ]; then
|
|
44
|
+
readme="$dir/README.md"
|
|
45
|
+
if [ -f "$readme" ]; then
|
|
46
|
+
((FILES_SCANNED++))
|
|
47
|
+
|
|
48
|
+
# Extract title (first H1)
|
|
49
|
+
title=$(grep -m1 "^# " "$readme" | sed 's/^# //')
|
|
50
|
+
|
|
51
|
+
# Extract key findings (lines with "finding" or "conclusion" or "result")
|
|
52
|
+
findings=$(grep -i -c "finding\|conclusion\|result\|recommendation" "$readme" 2>/dev/null || echo "0")
|
|
53
|
+
|
|
54
|
+
# Extract token/performance metrics if present
|
|
55
|
+
metrics=$(grep -i "token\|reduction\|saving\|performance\|latency" "$readme" | head -3)
|
|
56
|
+
|
|
57
|
+
OUTPUT+="## $title\n"
|
|
58
|
+
OUTPUT+="- Source: $readme\n"
|
|
59
|
+
OUTPUT+="- Key findings count: $findings\n"
|
|
60
|
+
if [ -n "$metrics" ]; then
|
|
61
|
+
OUTPUT+="- Metrics:\n"
|
|
62
|
+
while IFS= read -r line; do
|
|
63
|
+
OUTPUT+=" - $line\n"
|
|
64
|
+
done <<< "$metrics"
|
|
65
|
+
fi
|
|
66
|
+
OUTPUT+="\n"
|
|
67
|
+
((TOPICS_FOUND++))
|
|
68
|
+
fi
|
|
69
|
+
fi
|
|
70
|
+
done
|
|
71
|
+
|
|
72
|
+
# --- Summary ---
|
|
73
|
+
echo "=== RESEARCH AGGREGATION SUMMARY ==="
|
|
74
|
+
echo "Directories scanned: $FILES_SCANNED"
|
|
75
|
+
echo "Topics with findings: $TOPICS_FOUND"
|
|
76
|
+
echo ""
|
|
77
|
+
echo -e "$OUTPUT"
|
|
78
|
+
```
|
|
79
|
+
|
|
80
|
+
## Token Comparison
|
|
81
|
+
|
|
82
|
+
| Approach | Tool Calls | Context Entries | Estimated Tokens |
|
|
83
|
+
|----------|-----------|-----------------|-----------------|
|
|
84
|
+
| Direct (N reads + N greps) | 10-20 | 10-20 results | ~8,000-15,000 |
|
|
85
|
+
| Batch (1 call) | 1 | 1 (summary only) | ~3,000-5,000 |
|
|
86
|
+
| **Reduction** | -90% calls | -90% entries | **~30-50%** |
|
|
87
|
+
|
|
88
|
+
## Notes
|
|
89
|
+
|
|
90
|
+
- Scans `docs/research/*/README.md` by default — adjust path as needed
|
|
91
|
+
- Extracts title, findings count, and performance metrics per research doc
|
|
92
|
+
- Only the aggregated summary enters context
|
|
93
|
+
- For web research (EXA, WebSearch), run those as separate tool calls first,
|
|
94
|
+
then use this template to aggregate the saved results
|