@event4u/agent-config 14.22.0 → 15.0.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/.augment-plugin/marketplace.json +3 -3
- package/.augment-plugin/plugin.json +1 -1
- package/.claude-plugin/marketplace.json +1 -1
- package/CHANGELOG.md +333 -356
- package/README.md +1 -1
- package/dist/agent-src/commands/agent-handoff.md +8 -7
- package/dist/agent-src/commands/agents/init.md +1 -1
- package/dist/agent-src/commands/agents/user/accept.md +4 -4
- package/dist/agent-src/commands/agents/user/delete.md +2 -2
- package/dist/agent-src/commands/agents/user/init.md +3 -3
- package/dist/agent-src/commands/agents/user/review.md +3 -3
- package/dist/agent-src/commands/agents/user/show.md +3 -3
- package/dist/agent-src/commands/agents/user/update.md +2 -2
- package/dist/agent-src/commands/agents/user.md +6 -6
- package/dist/agent-src/commands/analytics/prune.md +1 -1
- package/dist/agent-src/commands/analytics/show.md +2 -2
- package/dist/agent-src/commands/analyze/decision.md +2 -2
- package/dist/agent-src/commands/analyze/inbox.md +5 -5
- package/dist/agent-src/commands/analyze/incident.md +3 -3
- package/dist/agent-src/commands/analyze/near-miss.md +3 -3
- package/dist/agent-src/commands/analyze/postmortem.md +4 -4
- package/dist/agent-src/commands/analyze/premortem.md +2 -2
- package/dist/agent-src/commands/analyze.md +2 -2
- package/dist/agent-src/commands/bug/fix.md +1 -1
- package/dist/agent-src/commands/bug/investigate.md +2 -2
- package/dist/agent-src/commands/cost/profile.md +3 -3
- package/dist/agent-src/commands/design.md +1 -1
- package/dist/agent-src/commands/feature/explore.md +1 -1
- package/dist/agent-src/commands/feature/plan.md +2 -2
- package/dist/agent-src/commands/feature/roadmap.md +2 -2
- package/dist/agent-src/commands/ghostwriter/fetch.md +4 -4
- package/dist/agent-src/commands/ghostwriter/list.md +1 -1
- package/dist/agent-src/commands/ghostwriter/show.md +1 -1
- package/dist/agent-src/commands/ghostwriter/write.md +9 -9
- package/dist/agent-src/commands/humanize.md +6 -6
- package/dist/agent-src/commands/jira-ticket.md +1 -1
- package/dist/agent-src/commands/judge/solo.md +1 -1
- package/dist/agent-src/commands/judge.md +1 -1
- package/dist/agent-src/commands/knowledge/cross-repo.md +1 -1
- package/dist/agent-src/commands/knowledge/forget.md +1 -1
- package/dist/agent-src/commands/knowledge/ingest.md +2 -2
- package/dist/agent-src/commands/knowledge/list.md +1 -1
- package/dist/agent-src/commands/memory/add.md +3 -3
- package/dist/agent-src/commands/memory/load.md +4 -4
- package/dist/agent-src/commands/memory/mine-session.md +1 -1
- package/dist/agent-src/commands/memory/promote.md +4 -4
- package/dist/agent-src/commands/memory/propose.md +2 -2
- package/dist/agent-src/commands/mode.md +5 -5
- package/dist/agent-src/commands/post-as/ghostwriter.md +3 -3
- package/dist/agent-src/commands/post-as/me.md +7 -7
- package/dist/agent-src/commands/pr/create.md +1 -1
- package/dist/agent-src/commands/pr/merge.md +48 -39
- package/dist/agent-src/commands/profile/activate.md +1 -1
- package/dist/agent-src/commands/profile/show.md +1 -1
- package/dist/agent-src/commands/research/deep.md +2 -2
- package/dist/agent-src/commands/research/report.md +2 -2
- package/dist/agent-src/commands/review/changes.md +1 -1
- package/dist/agent-src/commands/review/routing.md +1 -1
- package/dist/agent-src/commands/roadmap/create.md +1 -1
- package/dist/agent-src/commands/roadmap/materialize.md +2 -2
- package/dist/agent-src/commands/roadmap/next.md +9 -1
- package/dist/agent-src/commands/roadmap/process-full.md +2 -2
- package/dist/agent-src/commands/security-audit-config.md +3 -3
- package/dist/agent-src/commands/skill/preview.md +1 -1
- package/dist/agent-src/commands/skills/discover.md +1 -1
- package/dist/agent-src/commands/sync/agent-settings.md +2 -2
- package/dist/agent-src/commands/sync/gitignore/fix.md +1 -1
- package/dist/agent-src/commands/tests/create.md +1 -1
- package/dist/agent-src/commands/tests/e2e-heal.md +1 -1
- package/dist/agent-src/commands/tests/e2e-plan.md +1 -1
- package/dist/agent-src/contexts/authority/kernel-rule-edits.md +6 -6
- package/dist/agent-src/contexts/communication/rules-auto/slash-command-routing-policy-mechanics.md +1 -2
- package/dist/agent-src/contexts/communication/rules-auto/think-before-action-mechanics.md +2 -2
- package/dist/agent-src/contexts/communication/rules-auto/token-efficiency-mechanics.md +88 -1
- package/dist/agent-src/contexts/communication/rules-auto/user-interaction-mechanics.md +1 -1
- package/dist/agent-src/contexts/contracts/frugality-charter.md +1 -1
- package/dist/agent-src/contexts/execution/auto-dispatch-classification.md +1 -1
- package/dist/agent-src/contexts/execution/auto-orchestration-activation.md +1 -1
- package/dist/agent-src/contexts/execution/autonomy-mechanics.md +13 -1
- package/dist/agent-src/contexts/execution/cheap-question-mechanics.md +1 -1
- package/dist/agent-src/contexts/execution/contract-decision-sheet.md +3 -3
- package/dist/agent-src/contexts/execution/mandated-lines.md +1 -1
- package/dist/agent-src/contexts/execution/non-interactive-contract.md +1 -1
- package/dist/agent-src/contexts/execution/orchestration-telemetry.md +1 -1
- package/dist/agent-src/contexts/execution/plan-confidence-gate.md +5 -5
- package/dist/agent-src/contexts/execution/roadmap-execution-contract.md +1 -1
- package/dist/agent-src/contexts/execution/subagent-modes-detail.md +1 -1
- package/dist/agent-src/contexts/execution/subagent-routing.md +2 -2
- package/dist/agent-src/contexts/execution/subagent-spawn-contract.md +1 -1
- package/dist/agent-src/contexts/execution/user-memory-channels.md +3 -3
- package/dist/agent-src/contexts/execution/verification-mechanics.md +1 -1
- package/dist/agent-src/contexts/judges/persona-voice-rubric.md +2 -2
- package/dist/agent-src/guidelines/abstraction-thresholds.md +88 -0
- package/dist/agent-src/guidelines/agent-infra/5w2h-analysis.md +260 -0
- package/dist/agent-src/guidelines/agent-infra/active-remediation-mechanics.md +99 -0
- package/dist/agent-src/guidelines/agent-infra/agent-interaction-and-decision-quality.md +325 -0
- package/dist/agent-src/guidelines/agent-infra/api-cost-levers.md +177 -0
- package/dist/agent-src/guidelines/agent-infra/artifact-drafting-protocol-mechanics.md +222 -0
- package/dist/agent-src/guidelines/agent-infra/ask-when-uncertain-demos.md +134 -0
- package/dist/agent-src/guidelines/agent-infra/asking-and-brevity-examples.md +198 -0
- package/dist/agent-src/guidelines/agent-infra/break-glass-usage.md +113 -0
- package/dist/agent-src/guidelines/agent-infra/carve-out-predicates.md +17 -0
- package/dist/agent-src/guidelines/agent-infra/comparison-matrix.md +179 -0
- package/dist/agent-src/guidelines/agent-infra/context-hygiene-mechanics.md +165 -0
- package/dist/agent-src/guidelines/agent-infra/corpus-grounding-authoring.md +91 -0
- package/dist/agent-src/guidelines/agent-infra/critical-thinking.md +156 -0
- package/dist/agent-src/guidelines/agent-infra/cross-source-consistency-mechanics.md +109 -0
- package/dist/agent-src/guidelines/agent-infra/developer-judgment.md +82 -0
- package/dist/agent-src/guidelines/agent-infra/direct-answers-demos.md +142 -0
- package/dist/agent-src/guidelines/agent-infra/domain-adoption-gates.md +112 -0
- package/dist/agent-src/guidelines/agent-infra/domain-eval-anti-pattern.md +53 -0
- package/dist/agent-src/guidelines/agent-infra/domain-pack-architecture.md +56 -0
- package/dist/agent-src/guidelines/agent-infra/downstream-changes-mechanics.md +91 -0
- package/dist/agent-src/guidelines/agent-infra/emphasis-budget.md +45 -0
- package/dist/agent-src/guidelines/agent-infra/engineering-memory-data-format.md +210 -0
- package/dist/agent-src/guidelines/agent-infra/evaluator-independence-mechanics.md +92 -0
- package/dist/agent-src/guidelines/agent-infra/existence-question-verdicts.md +80 -0
- package/dist/agent-src/guidelines/agent-infra/failure-signatures.md +70 -0
- package/dist/agent-src/guidelines/agent-infra/false-green.md +233 -0
- package/dist/agent-src/guidelines/agent-infra/first-principles.md +192 -0
- package/dist/agent-src/guidelines/agent-infra/framework-neutrality-patterns.md +66 -0
- package/dist/agent-src/guidelines/agent-infra/frontier-reasoning-operating-profile.md +169 -0
- package/dist/agent-src/guidelines/agent-infra/gate-authoring.md +177 -0
- package/dist/agent-src/guidelines/agent-infra/guarded-baseline.md +39 -0
- package/dist/agent-src/guidelines/agent-infra/installed-tools-manifest.md +142 -0
- package/dist/agent-src/guidelines/agent-infra/inversion-thinking.md +388 -0
- package/dist/agent-src/guidelines/agent-infra/ios-simulator-guide.md +378 -0
- package/dist/agent-src/guidelines/agent-infra/language-and-tone-examples.md +141 -0
- package/dist/agent-src/guidelines/agent-infra/layered-settings.md +317 -0
- package/dist/agent-src/guidelines/agent-infra/linked-projects-onboarding-gate.md +80 -0
- package/dist/agent-src/guidelines/agent-infra/mcp-request-signing.md +197 -0
- package/dist/agent-src/guidelines/agent-infra/memory-access.md +149 -0
- package/dist/agent-src/guidelines/agent-infra/mental-models.md +314 -0
- package/dist/agent-src/guidelines/agent-infra/minimal-safe-diff-mechanics.md +241 -0
- package/dist/agent-src/guidelines/agent-infra/missing-tool-handling.md +66 -0
- package/dist/agent-src/guidelines/agent-infra/model-recommendation.md +101 -0
- package/dist/agent-src/guidelines/agent-infra/naming.md +69 -0
- package/dist/agent-src/guidelines/agent-infra/notes-horizon-mechanics.md +90 -0
- package/dist/agent-src/guidelines/agent-infra/output-patterns.md +117 -0
- package/dist/agent-src/guidelines/agent-infra/recurring-criticism-mechanics.md +96 -0
- package/dist/agent-src/guidelines/agent-infra/reuse-verdict-mechanics.md +71 -0
- package/dist/agent-src/guidelines/agent-infra/review-routing-data-format.md +143 -0
- package/dist/agent-src/guidelines/agent-infra/roadmap-deferred-resolution-provenance.md +54 -0
- package/dist/agent-src/guidelines/agent-infra/roadmap-progress-mechanics.md +274 -0
- package/dist/agent-src/guidelines/agent-infra/role-contracts.md +209 -0
- package/dist/agent-src/guidelines/agent-infra/role-mode-router.md +89 -0
- package/dist/agent-src/guidelines/agent-infra/rule-body-migration-inventory.md +241 -0
- package/dist/agent-src/guidelines/agent-infra/rule-type-governance.md +73 -0
- package/dist/agent-src/guidelines/agent-infra/runtime-layer.md +89 -0
- package/dist/agent-src/guidelines/agent-infra/scqa-framework.md +526 -0
- package/dist/agent-src/guidelines/agent-infra/security-lint-containment.md +121 -0
- package/dist/agent-src/guidelines/agent-infra/self-improvement-pipeline.md +134 -0
- package/dist/agent-src/guidelines/agent-infra/simplicity-and-goal-demos.md +211 -0
- package/dist/agent-src/guidelines/agent-infra/six-hats.md +353 -0
- package/dist/agent-src/guidelines/agent-infra/size-and-scope.md +229 -0
- package/dist/agent-src/guidelines/agent-infra/skill-quality-checklist.md +157 -0
- package/dist/agent-src/guidelines/agent-infra/source-confidentiality-mechanics.md +109 -0
- package/dist/agent-src/guidelines/agent-infra/symptom-driven-harvest-loop.md +104 -0
- package/dist/agent-src/guidelines/agent-infra/systems-thinking.md +220 -0
- package/dist/agent-src/guidelines/agent-infra/tool-description-as-policy.md +35 -0
- package/dist/agent-src/guidelines/agent-infra/tool-integration.md +73 -0
- package/dist/agent-src/guidelines/agent-infra/traceability-field-mechanics.md +50 -0
- package/dist/agent-src/guidelines/agent-infra/untrusted-input-spotlighting.md +166 -0
- package/dist/agent-src/guidelines/agent-infra/verify-before-complete-demos.md +128 -0
- package/dist/agent-src/guidelines/augment-portability-patterns.md +70 -0
- package/dist/agent-src/guidelines/code-clarity.md +350 -0
- package/dist/agent-src/guidelines/component-oriented-and-oop-development.md +189 -0
- package/dist/agent-src/guidelines/cross-role-handoff.md +127 -0
- package/dist/agent-src/guidelines/design-antipatterns-triggers.json +18 -0
- package/dist/agent-src/guidelines/design-antipatterns.md +327 -0
- package/dist/agent-src/guidelines/design-asset-discipline.md +38 -0
- package/dist/agent-src/guidelines/design-canon.md +63 -0
- package/dist/agent-src/guidelines/design-fidelity-mechanics.md +293 -0
- package/dist/agent-src/guidelines/design-fidelity-routing.md +78 -0
- package/dist/agent-src/guidelines/design-handover-extraction.md +117 -0
- package/dist/agent-src/guidelines/design-modes.md +143 -0
- package/dist/agent-src/guidelines/design-reconciliation.md +172 -0
- package/dist/agent-src/guidelines/docs/readme-size-and-splitting.md +209 -0
- package/dist/agent-src/guidelines/e2e/playwright.md +363 -0
- package/dist/agent-src/guidelines/gtm-handoff.md +114 -0
- package/dist/agent-src/guidelines/monorepo-antipatterns.md +141 -0
- package/dist/agent-src/guidelines/php/api-design.md +115 -0
- package/dist/agent-src/guidelines/php/artisan-commands.md +81 -0
- package/dist/agent-src/guidelines/php/blade-ui.md +78 -0
- package/dist/agent-src/guidelines/php/controllers.md +90 -0
- package/dist/agent-src/guidelines/php/database.md +194 -0
- package/dist/agent-src/guidelines/php/eloquent.md +208 -0
- package/dist/agent-src/guidelines/php/flux.md +80 -0
- package/dist/agent-src/guidelines/php/general.md +207 -0
- package/dist/agent-src/guidelines/php/git.md +164 -0
- package/dist/agent-src/guidelines/php/jobs.md +111 -0
- package/dist/agent-src/guidelines/php/livewire.md +71 -0
- package/dist/agent-src/guidelines/php/logging.md +79 -0
- package/dist/agent-src/guidelines/php/naming.md +89 -0
- package/dist/agent-src/guidelines/php/patterns/dependency-injection.md +57 -0
- package/dist/agent-src/guidelines/php/patterns/dtos.md +199 -0
- package/dist/agent-src/guidelines/php/patterns/events.md +67 -0
- package/dist/agent-src/guidelines/php/patterns/factory.md +53 -0
- package/dist/agent-src/guidelines/php/patterns/pipelines.md +66 -0
- package/dist/agent-src/guidelines/php/patterns/policies.md +66 -0
- package/dist/agent-src/guidelines/php/patterns/repositories.md +122 -0
- package/dist/agent-src/guidelines/php/patterns/service-layer.md +64 -0
- package/dist/agent-src/guidelines/php/patterns/strategy.md +247 -0
- package/dist/agent-src/guidelines/php/patterns.md +28 -0
- package/dist/agent-src/guidelines/php/performance.md +92 -0
- package/dist/agent-src/guidelines/php/php-coding-patterns.md +80 -0
- package/dist/agent-src/guidelines/php/resources.md +100 -0
- package/dist/agent-src/guidelines/php/security.md +110 -0
- package/dist/agent-src/guidelines/php/sql.md +97 -0
- package/dist/agent-src/guidelines/php/validations.md +119 -0
- package/dist/agent-src/guidelines/php/websocket.md +100 -0
- package/dist/agent-src/guidelines/prompt-templates.md +189 -0
- package/dist/agent-src/guidelines/redundancy-taxonomy.md +208 -0
- package/dist/agent-src/guidelines/wing4-handoff.md +127 -0
- package/dist/agent-src/personas/README.md +1 -1
- package/dist/agent-src/personas/_template-specialist/persona.md +1 -1
- package/dist/agent-src/personas/product-owner.md +1 -1
- package/dist/agent-src/rules/active-remediation.md +1 -1
- package/dist/agent-src/rules/architecture.md +2 -2
- package/dist/agent-src/rules/artifact-drafting-protocol.md +1 -1
- package/dist/agent-src/rules/ask-when-uncertain.md +2 -2
- package/dist/agent-src/rules/brand-source-of-truth.md +9 -7
- package/dist/agent-src/rules/code-comment-discipline.md +2 -2
- package/dist/agent-src/rules/code-provenance.md +1 -1
- package/dist/agent-src/rules/content-quoting-floor.md +1 -1
- package/dist/agent-src/rules/context-hygiene.md +5 -5
- package/dist/agent-src/rules/cross-source-consistency.md +1 -1
- package/dist/agent-src/rules/design-fidelity.md +36 -46
- package/dist/agent-src/rules/direct-answers.md +2 -2
- package/dist/agent-src/rules/domain-adoption-policy.md +1 -1
- package/dist/agent-src/rules/evaluator-independence.md +1 -1
- package/dist/agent-src/rules/framework-neutrality-in-generic-skills.md +1 -1
- package/dist/agent-src/rules/icon-consistency.md +5 -1
- package/dist/agent-src/rules/improve-before-implement.md +1 -1
- package/dist/agent-src/rules/language-and-tone.md +3 -3
- package/dist/agent-src/rules/minimal-safe-diff.md +1 -1
- package/dist/agent-src/rules/notes-first-reasoning.md +36 -25
- package/dist/agent-src/rules/recurring-criticism.md +1 -1
- package/dist/agent-src/rules/roadmap-progress-sync.md +1 -1
- package/dist/agent-src/rules/role-mode-adherence.md +2 -2
- package/dist/agent-src/rules/security-sensitive-stop.md +1 -1
- package/dist/agent-src/rules/size-enforcement.md +1 -1
- package/dist/agent-src/rules/source-confidentiality.md +2 -2
- package/dist/agent-src/rules/think-before-action.md +1 -1
- package/dist/agent-src/rules/token-efficiency.md +7 -5
- package/dist/agent-src/rules/ui-audit-gate.md +3 -2
- package/dist/agent-src/rules/untrusted-input-defense.md +3 -3
- package/dist/agent-src/scripts/archive_completed_roadmaps.ts +106 -4
- package/dist/agent-src/skills/activation-design/SKILL.md +2 -2
- package/dist/agent-src/skills/adr-create/SKILL.md +5 -5
- package/dist/agent-src/skills/ai-council/SKILL.md +1 -1
- package/dist/agent-src/skills/ai-council/references/advanced-modes.md +1 -1
- package/dist/agent-src/skills/blade-ui/SKILL.md +1 -1
- package/dist/agent-src/skills/blast-radius-analyzer/SKILL.md +1 -1
- package/dist/agent-src/skills/brand-to-tokens/SKILL.md +24 -3
- package/dist/agent-src/skills/bug-analyzer/SKILL.md +1 -1
- package/dist/agent-src/skills/build-buy-partner/SKILL.md +1 -1
- package/dist/agent-src/skills/churn-prevention/SKILL.md +2 -2
- package/dist/agent-src/skills/code-intelligence/SKILL.md +57 -1
- package/dist/agent-src/skills/code-refactoring/SKILL.md +3 -3
- package/dist/agent-src/skills/code-review/SKILL.md +3 -3
- package/dist/agent-src/skills/command-writing/SKILL.md +3 -3
- package/dist/agent-src/skills/comp-banding/SKILL.md +1 -1
- package/dist/agent-src/skills/competitive-moat-analysis/SKILL.md +1 -1
- package/dist/agent-src/skills/competitive-positioning/SKILL.md +2 -2
- package/dist/agent-src/skills/complexity-first-planning/SKILL.md +1 -1
- package/dist/agent-src/skills/condense-memory/SKILL.md +1 -1
- package/dist/agent-src/skills/content-funnel-design/SKILL.md +2 -2
- package/dist/agent-src/skills/contracts-cognition/SKILL.md +1 -1
- package/dist/agent-src/skills/copilot-agents-optimization/SKILL.md +2 -2
- package/dist/agent-src/skills/corpus-grounding/SKILL.md +2 -2
- package/dist/agent-src/skills/customer-research/SKILL.md +2 -2
- package/dist/agent-src/skills/dashboard-design/SKILL.md +1 -1
- package/dist/agent-src/skills/data-handling-judgment/SKILL.md +1 -1
- package/dist/agent-src/skills/deal-qualification-meddic/SKILL.md +2 -2
- package/dist/agent-src/skills/decision-record/SKILL.md +3 -3
- package/dist/agent-src/skills/decision-review/SKILL.md +8 -8
- package/dist/agent-src/skills/deep-reading-analyst/SKILL.md +22 -22
- package/dist/agent-src/skills/design-intelligence/SKILL.md +4 -4
- package/dist/agent-src/skills/design-intelligence/references/context-and-registers.md +2 -2
- package/dist/agent-src/skills/design-review/SKILL.md +4 -4
- package/dist/agent-src/skills/design-system-capture/references/design-system-json.md +20 -1
- package/dist/agent-src/skills/design-tokens/SKILL.md +17 -2
- package/dist/agent-src/skills/design-variations/SKILL.md +2 -2
- package/dist/agent-src/skills/developer-like-execution/SKILL.md +2 -2
- package/dist/agent-src/skills/discovery-interview/SKILL.md +2 -2
- package/dist/agent-src/skills/doc-coauthoring/SKILL.md +3 -3
- package/dist/agent-src/skills/editorial-calendar/SKILL.md +2 -2
- package/dist/agent-src/skills/existing-ui-audit/SKILL.md +44 -1
- package/dist/agent-src/skills/existing-ui-audit/references/anti-slop-cross-reference.md +2 -2
- package/dist/agent-src/skills/expansion-playbook/SKILL.md +2 -2
- package/dist/agent-src/skills/experiment-loop/SKILL.md +1 -1
- package/dist/agent-src/skills/experiment-loop/references/protocol.md +1 -1
- package/dist/agent-src/skills/fe-design/SKILL.md +3 -3
- package/dist/agent-src/skills/fe-design/references/design-patterns.md +1 -1
- package/dist/agent-src/skills/fe-design/references/design-read-and-memory.md +3 -3
- package/dist/agent-src/skills/fe-design/references/source-led-port.md +1 -1
- package/dist/agent-src/skills/feature-planning/SKILL.md +1 -1
- package/dist/agent-src/skills/flux/SKILL.md +1 -1
- package/dist/agent-src/skills/forecast-accuracy/SKILL.md +2 -2
- package/dist/agent-src/skills/forecasting/SKILL.md +2 -2
- package/dist/agent-src/skills/fundraising-narrative/SKILL.md +2 -2
- package/dist/agent-src/skills/funnel-analysis/SKILL.md +2 -2
- package/dist/agent-src/skills/git-workflow/references/push-closes-its-loop.md +9 -0
- package/dist/agent-src/skills/gtm-launch/SKILL.md +2 -2
- package/dist/agent-src/skills/hiring-loop-design/SKILL.md +1 -1
- package/dist/agent-src/skills/html-deck/SKILL.md +5 -5
- package/dist/agent-src/skills/humanizer/SKILL.md +1 -1
- package/dist/agent-src/skills/humanizer/data/patterns.md +1 -1
- package/dist/agent-src/skills/iconography/SKILL.md +3 -3
- package/dist/agent-src/skills/judge-synthesis/SKILL.md +1 -1
- package/dist/agent-src/skills/laravel-api-endpoint/SKILL.md +2 -2
- package/dist/agent-src/skills/launch-readiness/SKILL.md +3 -3
- package/dist/agent-src/skills/learning-to-rule-or-skill/SKILL.md +6 -6
- package/dist/agent-src/skills/livewire/SKILL.md +1 -1
- package/dist/agent-src/skills/market-entry-analysis/SKILL.md +1 -1
- package/dist/agent-src/skills/mcp-builder/SKILL.md +1 -1
- package/dist/agent-src/skills/memory-consolidation/SKILL.md +3 -3
- package/dist/agent-src/skills/messaging-architecture/SKILL.md +2 -2
- package/dist/agent-src/skills/monorepo-workspace/SKILL.md +1 -1
- package/dist/agent-src/skills/onboarding-design/SKILL.md +2 -2
- package/dist/agent-src/skills/onboarding-program/SKILL.md +1 -1
- package/dist/agent-src/skills/one-on-one-cadence/SKILL.md +1 -1
- package/dist/agent-src/skills/org-design/SKILL.md +1 -1
- package/dist/agent-src/skills/overbuild-review-lens/SKILL.md +3 -3
- package/dist/agent-src/skills/override-management/SKILL.md +1 -1
- package/dist/agent-src/skills/perf-feedback-craft/SKILL.md +1 -1
- package/dist/agent-src/skills/persona-writing/SKILL.md +1 -1
- package/dist/agent-src/skills/php-coder/SKILL.md +1 -1
- package/dist/agent-src/skills/pipeline-strategy/SKILL.md +2 -2
- package/dist/agent-src/skills/playwright-testing/SKILL.md +3 -3
- package/dist/agent-src/skills/po-discovery/SKILL.md +1 -1
- package/dist/agent-src/skills/positioning-strategy/SKILL.md +2 -2
- package/dist/agent-src/skills/privacy-review/SKILL.md +1 -1
- package/dist/agent-src/skills/prompt-optimizer/SKILL.md +3 -3
- package/dist/agent-src/skills/react-shadcn-ui/SKILL.md +1 -1
- package/dist/agent-src/skills/reasoning-orchestrator/SKILL.md +2 -2
- package/dist/agent-src/skills/receiving-code-review/SKILL.md +1 -1
- package/dist/agent-src/skills/refine-ticket/SKILL.md +2 -2
- package/dist/agent-src/skills/release-comms/SKILL.md +2 -2
- package/dist/agent-src/skills/retention-loops/SKILL.md +2 -2
- package/dist/agent-src/skills/review-routing/SKILL.md +2 -2
- package/dist/agent-src/skills/roadmap-management/SKILL.md +1 -1
- package/dist/agent-src/skills/roadmap-management/references/archival.md +1 -1
- package/dist/agent-src/skills/roadmap-writing/SKILL.md +5 -5
- package/dist/agent-src/skills/rule-writing/SKILL.md +6 -6
- package/dist/agent-src/skills/runway-cognition/SKILL.md +2 -2
- package/dist/agent-src/skills/scenario-modeling/SKILL.md +2 -2
- package/dist/agent-src/skills/skill-writing/SKILL.md +2 -2
- package/dist/agent-src/skills/skill-writing/references/procedure.md +1 -1
- package/dist/agent-src/skills/skill-writing/references/section-patterns.md +3 -3
- package/dist/agent-src/skills/spreadsheet-authoring/SKILL.md +1 -1
- package/dist/agent-src/skills/stakeholder-tradeoff/SKILL.md +3 -3
- package/dist/agent-src/skills/subagent-orchestration/SKILL.md +1 -1
- package/dist/agent-src/skills/supply-chain-intake/SKILL.md +1 -1
- package/dist/agent-src/skills/systematic-debugging/SKILL.md +2 -2
- package/dist/agent-src/skills/tailwind-engineer/SKILL.md +60 -4
- package/dist/agent-src/skills/throughput-vs-morale-tradeoff/SKILL.md +1 -1
- package/dist/agent-src/skills/token-optimizer/SKILL.md +1 -1
- package/dist/agent-src/skills/typography-system/SKILL.md +2 -2
- package/dist/agent-src/skills/ui-component-architect/SKILL.md +28 -8
- package/dist/agent-src/skills/unit-economics-modeling/SKILL.md +2 -2
- package/dist/agent-src/skills/upstream-contribute/SKILL.md +1 -1
- package/dist/agent-src/skills/validate-feature-fit/SKILL.md +2 -2
- package/dist/agent-src/skills/verify-repair-loop/SKILL.md +2 -2
- package/dist/agent-src/skills/vision-articulation/SKILL.md +1 -1
- package/dist/agent-src/skills/voc-extract/SKILL.md +2 -2
- package/dist/agent-src/skills/voice-and-tone-design/SKILL.md +2 -2
- package/dist/agent-src/skills/wireframe/SKILL.md +1 -1
- package/dist/agent-src/skills/workspace-link/SKILL.md +1 -1
- package/dist/agent-src/templates/agent-settings.md +6 -6
- package/dist/agent-src/templates/agents/agent-project-settings.example.yml +1 -1
- package/dist/agent-src/templates/contexts/knowledge-pages.md +2 -3
- package/dist/agent-src/templates/copilot-instructions.md +1 -1
- package/dist/agent-src/templates/roadmaps.md +1 -1
- package/dist/agent-src/templates/scripts/README.md +2 -2
- package/dist/agent-src/user-types/_template/user-type.md +1 -1
- package/dist/cli/registry.js +1 -1
- package/dist/cli-delegate/archive_completed_roadmaps.js +52 -4
- package/dist/cli-delegate/check_update_banner.js +12 -1
- package/dist/cli-delegate/{chunk-TGIPZBCW.js → chunk-2KKXJW25.js} +22 -8
- package/dist/cli-delegate/{chunk-NLP54U3J.js → chunk-2XY7ILBT.js} +13 -1
- package/dist/cli-delegate/{chunk-4FS4WRXP.js → chunk-3FKR64R5.js} +34 -6
- package/dist/cli-delegate/{chunk-J3RFNKG4.js → chunk-55ACLDUE.js} +2 -2
- package/dist/cli-delegate/{chunk-PKOBQADP.js → chunk-57PN4GYJ.js} +1 -1
- package/dist/cli-delegate/{chunk-BIXEDQPZ.js → chunk-AK6HODNQ.js} +4 -4
- package/dist/cli-delegate/{chunk-2FTMENJL.js → chunk-GYC3VRYN.js} +1 -1
- package/dist/cli-delegate/{chunk-LWTYTX6F.js → chunk-HZ52BRGG.js} +24 -18
- package/dist/cli-delegate/{chunk-6RJA2F5A.js → chunk-IVBPRCQO.js} +1 -1
- package/dist/cli-delegate/{chunk-I6RHFQEG.js → chunk-YUM5KURG.js} +17 -1
- package/dist/cli-delegate/cmd_analyze_session.js +1 -1
- package/dist/cli-delegate/cmd_brand_status.js +1 -1
- package/dist/cli-delegate/cmd_conformance.js +3 -3
- package/dist/cli-delegate/cmd_doctor.js +3 -3
- package/dist/cli-delegate/cmd_explain.js +2 -2
- package/dist/cli-delegate/cmd_export.js +4 -4
- package/dist/cli-delegate/cmd_handoff.js +24 -16
- package/dist/cli-delegate/cmd_mcp_available.js +1 -1
- package/dist/cli-delegate/cmd_memory_get.js +1 -1
- package/dist/cli-delegate/cmd_migrate.js +2 -2
- package/dist/cli-delegate/cmd_packs_active.js +2 -2
- package/dist/cli-delegate/cmd_prune.js +4 -4
- package/dist/cli-delegate/cmd_route_audit.js +3 -3
- package/dist/cli-delegate/cmd_route_explain.js +1 -1
- package/dist/cli-delegate/cmd_session_recycle.js +4 -14
- package/dist/cli-delegate/cmd_settings_get.js +15 -9
- package/dist/cli-delegate/cmd_settings_migrate.js +4 -4
- package/dist/cli-delegate/cmd_settings_set.js +41 -11
- package/dist/cli-delegate/cmd_sync.js +4 -4
- package/dist/cli-delegate/cmd_uninstall.js +4 -4
- package/dist/cli-delegate/cmd_update.js +1 -1
- package/dist/cli-delegate/cmd_upgrade.js +1 -1
- package/dist/cli-delegate/cmd_validate.js +4 -4
- package/dist/cli-delegate/cmd_versions.js +1 -1
- package/dist/discovery/deprecation-report.md +1 -1
- package/dist/discovery/discovery-manifest.json +27 -80
- package/dist/discovery/discovery-manifest.json.sha256 +1 -1
- package/dist/discovery/discovery-manifest.summary.md +3 -3
- package/dist/discovery/dormancy-report.md +1 -1
- package/dist/discovery/orphan-report.md +1 -1
- package/dist/discovery/packs.json +5 -7
- package/dist/discovery/trust-report.md +2 -2
- package/dist/discovery/workspaces.json +4 -6
- package/dist/hooks/dispatch.js +9249 -8981
- package/dist/install/install.mjs +47 -8
- package/dist/mcp/registry-manifest.json +3 -3
- package/dist/mcp/server.json +2 -2
- package/dist/mcp/server.mjs +5496 -2400
- package/dist/router.json +1 -1
- package/dist/scripts/_lib/agent_settings.js +73 -0
- package/dist/scripts/_lib/agent_src.js +20 -0
- package/dist/scripts/_lib/guidelines_lane.js +158 -0
- package/dist/scripts/_lib/lean_projection_mode.js +108 -0
- package/dist/scripts/_lib/router_match.js +243 -0
- package/dist/scripts/_lib/rule_injection.js +216 -0
- package/dist/scripts/condense.js +22 -25
- package/dist/scripts/project_thin_rules.js +139 -19
- package/dist/server/io/yamlIO.js +125 -17
- package/dist/server/schemas/settings.js +32 -5
- package/dist/shared/settingsSurface.js +6 -1
- package/docs/MIGRATION.md +56 -0
- package/docs/contracts/settings-classes.md +48 -7
- package/docs/guidelines/abstraction-thresholds.md +35 -0
- package/docs/guidelines/agent-infra/active-remediation-mechanics.md +3 -3
- package/docs/guidelines/agent-infra/false-green.md +2 -2
- package/docs/guidelines/agent-infra/notes-horizon-mechanics.md +90 -0
- package/docs/guidelines/agent-infra/roadmap-progress-mechanics.md +1 -1
- package/docs/guidelines/agent-infra/skill-quality-checklist.md +1 -1
- package/docs/guidelines/design-fidelity-mechanics.md +4 -0
- package/docs/guidelines/design-fidelity-routing.md +78 -0
- package/docs/guidelines/design-reconciliation.md +172 -0
- package/docs/guidelines/gtm-handoff.md +2 -2
- package/docs/guidelines/wing4-handoff.md +2 -2
- package/llms.txt +1 -1
- package/package.json +7 -3
- package/src/agent-src/scripts/archive_completed_roadmaps.ts +106 -4
- package/src/config/agent-settings.template.yml +94 -1
- package/src/config/ci-local-parity.yml +34 -0
- package/src/config/continuity-surface.json +8 -29
- package/src/config/evaluator-budgets.json +4 -4
- package/src/config/gate-coverage.yml +31 -8
- package/src/config/gate-reachability-exemptions.json +1 -0
- package/src/config/gate-violation-baselines.json +3 -3
- package/src/config/hook-token-budget.json +8 -7
- package/src/config/host-injection-effect.json +2 -2
- package/src/config/pack-size-budget.json +55 -4
- package/src/config/packed-binary-manifest.json +1 -1
- package/src/config/platform-anchor.json +47 -0
- package/src/config/preamble-payload-budget.json +2 -3
- package/src/config/publish-surface.json +4 -2
- package/src/config/ratification-policy.json +7 -0
- package/src/config/routing-coverage-seed.json +9 -2
- package/src/config/rule-stub-ceilings.json +16 -9
- package/src/scripts/_cli/cmd_session_recycle.ts +2 -25
- package/src/scripts/_cli/cmd_settings_get.ts +22 -7
- package/src/scripts/_cli/handoff_sessions.ts +14 -44
- package/src/scripts/_lib/agent_settings.ts +85 -0
- package/src/scripts/_lib/agent_src.ts +21 -0
- package/src/scripts/_lib/artifact_maturity.ts +242 -0
- package/src/scripts/_lib/conformance_report.ts +403 -0
- package/src/scripts/_lib/continuity_slot.ts +295 -0
- package/src/scripts/_lib/continuity_writer.ts +312 -0
- package/src/scripts/_lib/design_system_import.ts +20 -0
- package/src/scripts/_lib/design_tolerance.ts +281 -0
- package/src/scripts/_lib/guidelines_lane.ts +164 -0
- package/src/scripts/_lib/hook_settings.ts +85 -0
- package/src/scripts/_lib/lean_projection_mode.ts +127 -0
- package/src/scripts/_lib/obligation_frequency.ts +2 -3
- package/src/scripts/_lib/packed_binary_predicate.ts +37 -0
- package/src/scripts/_lib/platform_anchor.ts +1053 -0
- package/src/scripts/_lib/ratification_artifact.ts +278 -0
- package/src/scripts/_lib/recycle_envelope_paths.ts +109 -21
- package/src/scripts/_lib/regression_neighbourhood.ts +159 -22
- package/src/scripts/_lib/security_lint.ts +23 -2
- package/src/scripts/_lib/self_repair.ts +21 -0
- package/src/scripts/_lib/session_eol.ts +44 -0
- package/src/scripts/_lib/session_index_trust.ts +387 -0
- package/src/scripts/_lib/standing_bound_ratchet.ts +220 -0
- package/src/scripts/_lib/tolerance_shadow.ts +177 -0
- package/src/scripts/_lib/vendored_grammar_upstream.ts +280 -0
- package/src/scripts/ai_council/redact_low_impact_entry.ts +8 -0
- package/src/scripts/audit_mcp_tools.ts +69 -25
- package/src/scripts/autonomy_friction_traffic.ts +379 -0
- package/src/scripts/build_mcp_catalog.ts +24 -1
- package/src/scripts/check_host_tree_parity.ts +291 -0
- package/src/scripts/check_kernel_edit_ratified.ts +462 -0
- package/src/scripts/check_loss_class_declared.ts +793 -46
- package/src/scripts/check_platform_anchor.ts +390 -0
- package/src/scripts/check_preamble_payload_budget.ts +424 -7
- package/src/scripts/check_projected_rule_routes.ts +395 -0
- package/src/scripts/check_rule_projection_integrity.ts +102 -2
- package/src/scripts/ci_settle.ts +205 -5
- package/src/scripts/code_graph/build.ts +79 -0
- package/src/scripts/code_graph/cli.ts +264 -7
- package/src/scripts/code_graph/detect.ts +38 -0
- package/src/scripts/code_graph/query.ts +25 -2
- package/src/scripts/code_graph/sqlite_store.ts +16 -1
- package/src/scripts/code_graph/types.ts +52 -3
- package/src/scripts/code_graph/validate.ts +3 -1
- package/src/scripts/code_graph/verbs.ts +590 -0
- package/src/scripts/condense.ts +22 -26
- package/src/scripts/generate_host_cost_table.ts +354 -0
- package/src/scripts/handoff_context_hook.ts +39 -1
- package/src/scripts/hook_manifest.json +1 -1
- package/src/scripts/hook_manifest.yaml +59 -28
- package/src/scripts/hooks/block_speaking_inbox_dir.ts +182 -16
- package/src/scripts/hooks/category_a.ts +1 -1
- package/src/scripts/hooks/chain_nudge_hook.ts +311 -25
- package/src/scripts/hooks/code_graph_context_hook.ts +7 -18
- package/src/scripts/hooks/push_settle_hook.ts +3 -2
- package/src/scripts/hooks/rule_inject_hook.ts +107 -20
- package/src/scripts/hooks/session_eol_hook.ts +177 -145
- package/src/scripts/hooks/source_first_gate_hook.ts +12 -0
- package/src/scripts/hooks/ui_route_nudge_hook.ts +52 -15
- package/src/scripts/hot_context_hook.ts +103 -408
- package/src/scripts/lint_evidence_artifacts.ts +1 -0
- package/src/scripts/lint_knowledge_scale.ts +0 -26
- package/src/scripts/lint_roadmap_blockers.ts +164 -1
- package/src/scripts/mcp_server/consumer_tool_catalog.json +152 -2
- package/src/scripts/mcp_server/graph_tools.ts +294 -0
- package/src/scripts/mcp_server/path_util.ts +31 -0
- package/src/scripts/mcp_server/tool_catalog_source.ts +7 -1
- package/src/scripts/mcp_server/tools.ts +3 -13
- package/src/scripts/memory_lookup.ts +9 -9
- package/src/scripts/model_rule_injection.ts +61 -4
- package/src/scripts/project_thin_rules.ts +149 -16
- package/src/scripts/report_standing_payload_by_host.ts +650 -0
- package/src/scripts/schemas/agent-settings.schema.json +7 -1
- package/src/scripts/session_memory_index.ts +86 -8
- package/src/scripts/sync_agent_settings.ts +270 -10
- package/src/server/io/yamlIO.ts +127 -17
- package/src/server/schemas/settings.ts +45 -6
- package/src/shared/settingsSurface.ts +13 -2
- package/src/templates/compact-instructions.md +8 -3
- package/src/vendor/grammars/README.md +27 -2
- package/dist/agent-src/commands/chat-history/import.md +0 -170
- package/dist/agent-src/commands/chat-history.md +0 -63
|
@@ -1,395 +1,63 @@
|
|
|
1
1
|
#!/usr/bin/env node
|
|
2
2
|
/**
|
|
3
|
-
*
|
|
3
|
+
* Memory session-index restore — `session_start` hook.
|
|
4
4
|
*
|
|
5
|
-
*
|
|
6
|
-
*
|
|
7
|
-
*
|
|
8
|
-
*
|
|
5
|
+
* The working-memory CACHE this concern used to carry was retired
|
|
6
|
+
* (road-to-continuity-writer-activation step 3.1, AI council 2026-09-09 under
|
|
7
|
+
* the owner's written delegation; openai's mechanism operative). What survives
|
|
8
|
+
* is the half the council kept: the `session_start` restore of the persisted
|
|
9
|
+
* memory session index.
|
|
9
10
|
*
|
|
10
|
-
*
|
|
11
|
-
*
|
|
12
|
-
*
|
|
11
|
+
* The concern id `hot-context` is DELIBERATELY unchanged. Retiring the id was
|
|
12
|
+
* the competing proposal and was rejected: the −1 on `concern_count` buys
|
|
13
|
+
* nothing, while untagged running code costs the manifest its completeness
|
|
14
|
+
* property. Its DESCRIPTION is what changed.
|
|
13
15
|
*
|
|
14
|
-
*
|
|
16
|
+
* Contract:
|
|
17
|
+
* - `session_start` only. The `stop` / `session_end` / `pre_compact` write
|
|
18
|
+
* bindings are gone, and the cache file they maintained is neither written
|
|
19
|
+
* nor read any more.
|
|
20
|
+
* - Emits `{"decision":"allow","context":"<block>"}` on stdout; the
|
|
21
|
+
* dispatcher forwards `context` so the host adds it to the session context.
|
|
22
|
+
* The block is spotlighted as DATA, not instructions
|
|
23
|
+
* (untrusted-input-defense).
|
|
24
|
+
* - Never blocks: exit 0 on every path; failures are silent (stderr note).
|
|
15
25
|
*
|
|
16
|
-
*
|
|
17
|
-
*
|
|
18
|
-
*
|
|
19
|
-
*
|
|
20
|
-
*
|
|
21
|
-
* the output, and neither should be: this file is a privacy-floored cache whose
|
|
22
|
-
* source of truth is the transcript it was built from, and storing a recovery
|
|
23
|
-
* for a line dropped for privacy would defeat the reason it was dropped.
|
|
26
|
+
* No `loss_class` is declared on THIS file any more, and that is a real
|
|
27
|
+
* coverage change rather than an omission. The two lossy transforms the class
|
|
28
|
+
* described — the 400-word cap and the fail-closed `_redact_lines` drop — left
|
|
29
|
+
* with the cache. The 30-row cap the memory index still applies lives in
|
|
30
|
+
* `_lib/session_index_trust.ts`, which is not a concern script.
|
|
24
31
|
*
|
|
25
|
-
* `
|
|
26
|
-
*
|
|
27
|
-
*
|
|
28
|
-
*
|
|
29
|
-
*
|
|
30
|
-
*
|
|
31
|
-
*
|
|
32
|
-
*
|
|
33
|
-
*
|
|
34
|
-
*
|
|
35
|
-
*
|
|
36
|
-
*
|
|
37
|
-
* spotlighted as DATA, not instructions (untrusted-input-defense).
|
|
38
|
-
* - Staleness: discard (delete) when the stamped branch differs from the
|
|
39
|
-
* current branch, the stamp is older than 48 h, or the host says
|
|
40
|
-
* `source=clear`. `source=compact` / `resume` / `startup` re-inject.
|
|
41
|
-
* - Never blocks: exit 0 on every path; failures are silent (stderr note).
|
|
32
|
+
* A `loss_module:` pointer used to sit here, naming that module so the gate
|
|
33
|
+
* could see it. It is gone because the gate now REACHES the module instead of
|
|
34
|
+
* being told about it: `check_loss_class_declared` walks relative specifiers
|
|
35
|
+
* from every context-emitting concern, and this file's `createRequire` load of
|
|
36
|
+
* `_lib/session_index_trust.js` is one. The pointer's premise — that only a
|
|
37
|
+
* static-import closure was on offer and it could not see a `createRequire`
|
|
38
|
+
* load — is what changed; a specifier walk sees both.
|
|
39
|
+
*
|
|
40
|
+
* What that costs, stated because a pointer did catch one thing a walk cannot:
|
|
41
|
+
* a module loaded through a COMPUTED specifier is now invisible again. Nothing
|
|
42
|
+
* here does that, and if something ever does, the answer is to name the module
|
|
43
|
+
* rather than to reason about the walk.
|
|
42
44
|
*
|
|
43
45
|
* Reads the dispatcher JSON envelope on stdin
|
|
44
46
|
* (`{platform, event, payload, workspace_root, …}`).
|
|
45
47
|
*/
|
|
46
48
|
|
|
47
|
-
import { spawnSync } from 'node:child_process';
|
|
48
|
-
import * as fs from 'node:fs';
|
|
49
49
|
import { createRequire } from 'node:module';
|
|
50
50
|
import * as path from 'node:path';
|
|
51
51
|
import process from 'node:process';
|
|
52
52
|
import { fileURLToPath } from 'node:url';
|
|
53
53
|
|
|
54
|
-
import { hardenedSpawnEnv } from './_lib/spawn_env.js';
|
|
55
|
-
import { computeRereads } from './_lib/transcript_reads.js';
|
|
56
|
-
import { redact_low_impact_entry } from './ai_council/redact_low_impact_entry.js';
|
|
57
54
|
import { readHookStdin } from './hooks/hook_stdin.js';
|
|
58
55
|
|
|
59
|
-
export const HOT_CONTEXT_REL = path.join('agents', 'runtime', 'state', 'hot-context.md');
|
|
60
|
-
|
|
61
56
|
/** Replay-fixture runs must never mutate state (same contract as chat_history). */
|
|
62
57
|
const REPLAY_ENV_VAR = 'AGENT_CONFIG_REPLAY';
|
|
63
58
|
function _is_replay_mode(): boolean {
|
|
64
59
|
return (process.env[REPLAY_ENV_VAR] ?? '').trim() === '1';
|
|
65
60
|
}
|
|
66
|
-
export const WORD_CAP = 400;
|
|
67
|
-
export const MAX_AGE_HOURS = 48;
|
|
68
|
-
|
|
69
|
-
const HISTORY_REL = 'agents/runtime/.agent-chat-history';
|
|
70
|
-
|
|
71
|
-
const MAX_ACTIVE_THREADS = 3; // last user intents
|
|
72
|
-
const MAX_RECENT_CHANGES = 5; // last tool results
|
|
73
|
-
const MAX_OPEN_VERIFICATIONS = 3;
|
|
74
|
-
const THREAD_SNIPPET_CHARS = 200;
|
|
75
|
-
const CHANGE_SNIPPET_CHARS = 120;
|
|
76
|
-
const KEY_FACTS_CHARS = 600;
|
|
77
|
-
const MAX_REREAD_LINES = 3; // advisory, not an inventory — see _reread_lines
|
|
78
|
-
|
|
79
|
-
const VERIFICATION_RE = /\b(fail(ing|ed|ure)?|error|exit[= ][1-9]|red\b|broken)\b/i;
|
|
80
|
-
|
|
81
|
-
interface HistoryEntry {
|
|
82
|
-
t?: string;
|
|
83
|
-
ts?: string;
|
|
84
|
-
s?: string;
|
|
85
|
-
text?: string;
|
|
86
|
-
tool?: string;
|
|
87
|
-
[k: string]: unknown;
|
|
88
|
-
}
|
|
89
|
-
|
|
90
|
-
// ---------------------------------------------------------------------
|
|
91
|
-
// shared helpers
|
|
92
|
-
// ---------------------------------------------------------------------
|
|
93
|
-
|
|
94
|
-
function _history_path(root: string): string {
|
|
95
|
-
return process.env.AGENT_CHAT_HISTORY_FILE || path.join(root, HISTORY_REL);
|
|
96
|
-
}
|
|
97
|
-
|
|
98
|
-
function _hot_context_path(root: string): string {
|
|
99
|
-
return process.env.AGENT_HOT_CONTEXT_FILE || path.join(root, HOT_CONTEXT_REL);
|
|
100
|
-
}
|
|
101
|
-
|
|
102
|
-
export function _current_branch(root: string): string {
|
|
103
|
-
try {
|
|
104
|
-
const proc = spawnSync('git', ['rev-parse', '--abbrev-ref', 'HEAD'], {
|
|
105
|
-
cwd: root,
|
|
106
|
-
encoding: 'utf-8',
|
|
107
|
-
timeout: 5000,
|
|
108
|
-
env: hardenedSpawnEnv(),
|
|
109
|
-
});
|
|
110
|
-
if (proc.status === 0) {
|
|
111
|
-
return (proc.stdout || '').trim() || 'unknown';
|
|
112
|
-
}
|
|
113
|
-
} catch {
|
|
114
|
-
// fall through
|
|
115
|
-
}
|
|
116
|
-
return 'unknown';
|
|
117
|
-
}
|
|
118
|
-
|
|
119
|
-
function _read_history(root: string): HistoryEntry[] {
|
|
120
|
-
let text: string;
|
|
121
|
-
try {
|
|
122
|
-
text = fs.readFileSync(_history_path(root), 'utf-8');
|
|
123
|
-
} catch {
|
|
124
|
-
return [];
|
|
125
|
-
}
|
|
126
|
-
const entries: HistoryEntry[] = [];
|
|
127
|
-
for (const line of text.split('\n')) {
|
|
128
|
-
const trimmed = line.trim();
|
|
129
|
-
if (!trimmed) continue;
|
|
130
|
-
try {
|
|
131
|
-
const parsed = JSON.parse(trimmed) as unknown;
|
|
132
|
-
if (parsed && typeof parsed === 'object' && !Array.isArray(parsed)) {
|
|
133
|
-
entries.push(parsed as HistoryEntry);
|
|
134
|
-
}
|
|
135
|
-
} catch {
|
|
136
|
-
// skip malformed lines — fail-open
|
|
137
|
-
}
|
|
138
|
-
}
|
|
139
|
-
return entries;
|
|
140
|
-
}
|
|
141
|
-
|
|
142
|
-
/** Entries of the most recent session (by `s` tag of the last body entry). */
|
|
143
|
-
export function _latest_session_entries(entries: HistoryEntry[]): HistoryEntry[] {
|
|
144
|
-
const body = entries.filter((e) => e.t && e.t !== 'header');
|
|
145
|
-
if (body.length === 0) return [];
|
|
146
|
-
const sid = body[body.length - 1]?.s;
|
|
147
|
-
if (!sid) {
|
|
148
|
-
// untagged history — fall back to the trailing 50 entries
|
|
149
|
-
return body.slice(-50);
|
|
150
|
-
}
|
|
151
|
-
return body.filter((e) => e.s === sid);
|
|
152
|
-
}
|
|
153
|
-
|
|
154
|
-
function _snippet(text: string, max: number): string {
|
|
155
|
-
const oneLine = text.replace(/\s+/g, ' ').trim();
|
|
156
|
-
return oneLine.length <= max ? oneLine : oneLine.slice(0, max - 1) + '…';
|
|
157
|
-
}
|
|
158
|
-
|
|
159
|
-
/** Privacy floor: keep only lines the low-impact redactor clears. */
|
|
160
|
-
function _redact_lines(lines: string[]): { kept: string[]; dropped: number } {
|
|
161
|
-
const kept: string[] = [];
|
|
162
|
-
let dropped = 0;
|
|
163
|
-
for (const line of lines) {
|
|
164
|
-
try {
|
|
165
|
-
const result = redact_low_impact_entry(line);
|
|
166
|
-
if (result.ok) {
|
|
167
|
-
kept.push(line);
|
|
168
|
-
} else {
|
|
169
|
-
dropped += 1;
|
|
170
|
-
}
|
|
171
|
-
} catch {
|
|
172
|
-
dropped += 1; // fail-closed per line: on redactor error, drop
|
|
173
|
-
}
|
|
174
|
-
}
|
|
175
|
-
return { kept, dropped };
|
|
176
|
-
}
|
|
177
|
-
|
|
178
|
-
function _word_count(text: string): number {
|
|
179
|
-
return text.split(/\s+/).filter((w) => w.length > 0).length;
|
|
180
|
-
}
|
|
181
|
-
|
|
182
|
-
// ---------------------------------------------------------------------
|
|
183
|
-
// re-read advisory (road-to-role-scoped-spawn-profiles Phase 3 Steps 4-5)
|
|
184
|
-
// ---------------------------------------------------------------------
|
|
185
|
-
|
|
186
|
-
/**
|
|
187
|
-
* Files this leg read more than once, as advisory lines for the cache.
|
|
188
|
-
*
|
|
189
|
-
* Phase 3 Step 4 of `road-to-role-scoped-spawn-profiles` requires the
|
|
190
|
-
* suppression to ride THIS surface rather than arrive as a second artefact,
|
|
191
|
-
* and Step 5 requires it to stay advice: there is no refuse branch anywhere
|
|
192
|
-
* below, and there is no code path that returns a deny on a re-read condition.
|
|
193
|
-
* The output is three lines in a markdown cache; the next leg may ignore it.
|
|
194
|
-
*
|
|
195
|
-
* **Why the path is relativised, and why an outside path is dropped rather
|
|
196
|
-
* than shortened.** The privacy floor
|
|
197
|
-
* ({@link _redact_lines} → `redact_low_impact_entry`) drops any line carrying
|
|
198
|
-
* a project-rooted absolute path, so emitting `/Users/...` would produce a
|
|
199
|
-
* silently empty section — the feature would look implemented and do nothing.
|
|
200
|
-
* Relativising to the workspace root keeps the line inside the floor. A path
|
|
201
|
-
* OUTSIDE the root cannot be relativised without `../` escapes that re-reveal
|
|
202
|
-
* the layout, and it is another project's business in any case, so it is
|
|
203
|
-
* dropped entirely.
|
|
204
|
-
*
|
|
205
|
-
* Fail-silent: no transcript path, an unreadable one, or a malformed leg all
|
|
206
|
-
* yield `[]`. This is a cache, and a cache that throws is worse than a cache
|
|
207
|
-
* that is short.
|
|
208
|
-
*/
|
|
209
|
-
export function _reread_lines(transcriptPath: string | null, root: string): string[] {
|
|
210
|
-
if (!transcriptPath) return [];
|
|
211
|
-
const result = computeRereads([transcriptPath]);
|
|
212
|
-
const lines: string[] = [];
|
|
213
|
-
for (const f of result.files) {
|
|
214
|
-
if (lines.length >= MAX_REREAD_LINES) break;
|
|
215
|
-
const rel = path.relative(root, f.file_path);
|
|
216
|
-
if (rel === '' || rel.startsWith('..') || path.isAbsolute(rel)) continue;
|
|
217
|
-
lines.push(`${rel} — read ${f.total_reads}x this leg (${f.duplicate_reads} re-read)`);
|
|
218
|
-
}
|
|
219
|
-
return lines;
|
|
220
|
-
}
|
|
221
|
-
|
|
222
|
-
// ---------------------------------------------------------------------
|
|
223
|
-
// stop — deterministic write
|
|
224
|
-
// ---------------------------------------------------------------------
|
|
225
|
-
|
|
226
|
-
export function build_hot_context(
|
|
227
|
-
root: string,
|
|
228
|
-
now: Date = new Date(),
|
|
229
|
-
transcriptPath: string | null = null,
|
|
230
|
-
): string {
|
|
231
|
-
const session = _latest_session_entries(_read_history(root));
|
|
232
|
-
|
|
233
|
-
const userPrompts = session.filter((e) => e.t === 'user_prompt' && e.text);
|
|
234
|
-
const toolUses = session.filter((e) => e.t === 'post_tool_use' && (e.tool || e.text));
|
|
235
|
-
const stops = session.filter((e) => e.t === 'stop' && e.text);
|
|
236
|
-
|
|
237
|
-
const activeThreads = _redact_lines(
|
|
238
|
-
userPrompts.slice(-MAX_ACTIVE_THREADS).map((e) => _snippet(String(e.text), THREAD_SNIPPET_CHARS)),
|
|
239
|
-
);
|
|
240
|
-
const recentChanges = _redact_lines(
|
|
241
|
-
toolUses
|
|
242
|
-
.slice(-MAX_RECENT_CHANGES)
|
|
243
|
-
.map((e) => _snippet(`${e.tool ? `${e.tool}: ` : ''}${String(e.text ?? '')}`, CHANGE_SNIPPET_CHARS)),
|
|
244
|
-
);
|
|
245
|
-
const openVerifications = _redact_lines(
|
|
246
|
-
toolUses
|
|
247
|
-
.filter((e) => VERIFICATION_RE.test(String(e.text ?? '')))
|
|
248
|
-
.slice(-MAX_OPEN_VERIFICATIONS)
|
|
249
|
-
.map((e) => _snippet(`${e.tool ? `${e.tool}: ` : ''}${String(e.text ?? '')}`, CHANGE_SNIPPET_CHARS)),
|
|
250
|
-
);
|
|
251
|
-
const lastStop = String(stops[stops.length - 1]?.text ?? '');
|
|
252
|
-
const keyFacts = _redact_lines(lastStop ? [_snippet(lastStop, KEY_FACTS_CHARS)] : []);
|
|
253
|
-
const rereads = _redact_lines(_reread_lines(transcriptPath, root));
|
|
254
|
-
|
|
255
|
-
const droppedTotal =
|
|
256
|
-
activeThreads.dropped +
|
|
257
|
-
recentChanges.dropped +
|
|
258
|
-
openVerifications.dropped +
|
|
259
|
-
keyFacts.dropped +
|
|
260
|
-
rereads.dropped;
|
|
261
|
-
|
|
262
|
-
// Assemble; trim lowest-priority sections first until under the word cap.
|
|
263
|
-
// Priority (highest kept longest): Key Facts > Active Threads >
|
|
264
|
-
// Open Verifications > Recent Changes > Re-Read Advisory.
|
|
265
|
-
//
|
|
266
|
-
// The advisory sits LAST on purpose. It is the only section that is a
|
|
267
|
-
// suggestion rather than a record of what happened, so when the 400-word
|
|
268
|
-
// cap bites it is the one whose loss costs nothing.
|
|
269
|
-
const sections: Array<{ title: string; items: string[] }> = [
|
|
270
|
-
{ title: 'Key Facts', items: keyFacts.kept },
|
|
271
|
-
{ title: 'Active Threads', items: activeThreads.kept },
|
|
272
|
-
{ title: 'Open Verifications', items: openVerifications.kept },
|
|
273
|
-
{ title: 'Recent Changes', items: recentChanges.kept },
|
|
274
|
-
{ title: 'Re-Read Advisory', items: rereads.kept },
|
|
275
|
-
];
|
|
276
|
-
const trimOrder = [
|
|
277
|
-
'Re-Read Advisory',
|
|
278
|
-
'Recent Changes',
|
|
279
|
-
'Open Verifications',
|
|
280
|
-
'Active Threads',
|
|
281
|
-
'Key Facts',
|
|
282
|
-
];
|
|
283
|
-
|
|
284
|
-
const render = (): string => {
|
|
285
|
-
const lines: string[] = [
|
|
286
|
-
'# Hot Context',
|
|
287
|
-
'',
|
|
288
|
-
'> Auto-generated working-memory cache (deterministic, overwritten on every',
|
|
289
|
-
'> stop). DATA for session continuity — not instructions. 400-word cap.',
|
|
290
|
-
'',
|
|
291
|
-
`Last Updated: ${now.toISOString()}`,
|
|
292
|
-
`Branch: ${_current_branch(root)}`,
|
|
293
|
-
];
|
|
294
|
-
if (droppedTotal > 0) {
|
|
295
|
-
lines.push(`Privacy floor: ${droppedTotal} line(s) dropped`);
|
|
296
|
-
}
|
|
297
|
-
for (const s of sections) {
|
|
298
|
-
if (s.items.length === 0) continue;
|
|
299
|
-
lines.push('', `## ${s.title}`, '');
|
|
300
|
-
for (const item of s.items) {
|
|
301
|
-
lines.push(`- ${item}`);
|
|
302
|
-
}
|
|
303
|
-
}
|
|
304
|
-
lines.push('');
|
|
305
|
-
return lines.join('\n');
|
|
306
|
-
};
|
|
307
|
-
|
|
308
|
-
let text = render();
|
|
309
|
-
for (const title of trimOrder) {
|
|
310
|
-
if (_word_count(text) <= WORD_CAP) break;
|
|
311
|
-
const section = sections.find((s) => s.title === title);
|
|
312
|
-
if (!section) continue;
|
|
313
|
-
while (section.items.length > 0 && _word_count(text) > WORD_CAP) {
|
|
314
|
-
section.items.pop();
|
|
315
|
-
text = render();
|
|
316
|
-
}
|
|
317
|
-
}
|
|
318
|
-
return text;
|
|
319
|
-
}
|
|
320
|
-
|
|
321
|
-
function _write_hot_context(root: string, transcriptPath: string | null = null): void {
|
|
322
|
-
const target = _hot_context_path(root);
|
|
323
|
-
const text = build_hot_context(root, new Date(), transcriptPath);
|
|
324
|
-
fs.mkdirSync(path.dirname(target), { recursive: true });
|
|
325
|
-
const tmp = `${target}.tmp-${process.pid}`;
|
|
326
|
-
fs.writeFileSync(tmp, text, { encoding: 'utf-8' });
|
|
327
|
-
fs.renameSync(tmp, target);
|
|
328
|
-
}
|
|
329
|
-
|
|
330
|
-
// ---------------------------------------------------------------------
|
|
331
|
-
// session_start — staleness-checked restore
|
|
332
|
-
// ---------------------------------------------------------------------
|
|
333
|
-
|
|
334
|
-
export interface RestoreDecision {
|
|
335
|
-
action: 'inject' | 'discard' | 'absent';
|
|
336
|
-
reason: string;
|
|
337
|
-
context?: string;
|
|
338
|
-
}
|
|
339
|
-
|
|
340
|
-
export function restore_hot_context(
|
|
341
|
-
root: string,
|
|
342
|
-
source: string,
|
|
343
|
-
now: Date = new Date(),
|
|
344
|
-
): RestoreDecision {
|
|
345
|
-
const target = _hot_context_path(root);
|
|
346
|
-
let text: string;
|
|
347
|
-
try {
|
|
348
|
-
text = fs.readFileSync(target, 'utf-8');
|
|
349
|
-
} catch {
|
|
350
|
-
return { action: 'absent', reason: 'no cache file' };
|
|
351
|
-
}
|
|
352
|
-
|
|
353
|
-
const discard = (reason: string): RestoreDecision => {
|
|
354
|
-
try {
|
|
355
|
-
fs.unlinkSync(target);
|
|
356
|
-
} catch {
|
|
357
|
-
// fail-open
|
|
358
|
-
}
|
|
359
|
-
return { action: 'discard', reason };
|
|
360
|
-
};
|
|
361
|
-
|
|
362
|
-
if (source === 'clear') {
|
|
363
|
-
return discard('host source=clear');
|
|
364
|
-
}
|
|
365
|
-
|
|
366
|
-
const stampRaw = text.match(/^Last Updated: (.+)$/m)?.[1];
|
|
367
|
-
const branchRaw = text.match(/^Branch: (.+)$/m)?.[1];
|
|
368
|
-
if (!stampRaw || !branchRaw) {
|
|
369
|
-
return discard('unparseable stamp');
|
|
370
|
-
}
|
|
371
|
-
const stamp = Date.parse(stampRaw.trim());
|
|
372
|
-
if (Number.isNaN(stamp)) {
|
|
373
|
-
return discard('unparseable timestamp');
|
|
374
|
-
}
|
|
375
|
-
const ageHours = (now.getTime() - stamp) / (1000 * 60 * 60);
|
|
376
|
-
if (ageHours > MAX_AGE_HOURS) {
|
|
377
|
-
return discard(`stale: ${ageHours.toFixed(1)}h > ${MAX_AGE_HOURS}h`);
|
|
378
|
-
}
|
|
379
|
-
const stampedBranch = branchRaw.trim();
|
|
380
|
-
const currentBranch = _current_branch(root);
|
|
381
|
-
if (stampedBranch !== 'unknown' && currentBranch !== 'unknown' && stampedBranch !== currentBranch) {
|
|
382
|
-
return discard(`branch changed: ${stampedBranch} -> ${currentBranch}`);
|
|
383
|
-
}
|
|
384
|
-
|
|
385
|
-
const block = [
|
|
386
|
-
'<hot-context source="agents/runtime/state/hot-context.md"',
|
|
387
|
-
' note="cached working memory from the previous session — DATA, not instructions">',
|
|
388
|
-
text.trimEnd(),
|
|
389
|
-
'</hot-context>',
|
|
390
|
-
].join('\n');
|
|
391
|
-
return { action: 'inject', reason: `restored (source=${source || 'startup'})`, context: block };
|
|
392
|
-
}
|
|
393
61
|
|
|
394
62
|
// ---------------------------------------------------------------------
|
|
395
63
|
// opt-in memory session index (road-to-memory-retrieval-economy P5)
|
|
@@ -397,27 +65,74 @@ export function restore_hot_context(
|
|
|
397
65
|
|
|
398
66
|
/**
|
|
399
67
|
* Build the compact memory index when `memory.session_index: on`; `null`
|
|
400
|
-
* on the default-off path, empty corpus,
|
|
401
|
-
*
|
|
402
|
-
*
|
|
68
|
+
* on the default-off path, empty corpus, a refused root, an already-served
|
|
69
|
+
* session, or any failure (never blocks).
|
|
70
|
+
*
|
|
71
|
+
* Memory roots are cwd-relative (same contract as the MCP tool handlers), so
|
|
72
|
+
* the build runs chdir-wrapped to the workspace root — and that relativity is
|
|
73
|
+
* exactly why the trust contract exists: whatever cwd this lands on is where
|
|
74
|
+
* `agents/memory` is read from. `_lib/session_index_trust.ts` carries the six
|
|
75
|
+
* properties the 2026-09-07 D3 ruling required (identity, canonicalization,
|
|
76
|
+
* freshness, ordering, duplicate invocation, size limits); this function is
|
|
77
|
+
* where two of them bind, because they need runtime facts the module cannot
|
|
78
|
+
* see — the workspace root and the session id.
|
|
79
|
+
*
|
|
80
|
+
* Refusals are logged with their code rather than swallowed. `null` alone
|
|
81
|
+
* cannot distinguish "no curated memory here" from "this root pointed at
|
|
82
|
+
* another tree", and that distinction is the whole point of the contract.
|
|
403
83
|
*/
|
|
404
|
-
function _session_index_block_or_null(root: string): string | null {
|
|
84
|
+
function _session_index_block_or_null(root: string, sessionId: string): string | null {
|
|
405
85
|
try {
|
|
406
86
|
// Lazy require (ESM-safe via createRequire) keeps the default-off
|
|
407
87
|
// fast path free of the memory_lookup + settings-cascade import cost.
|
|
408
88
|
const req = createRequire(import.meta.url);
|
|
409
89
|
const mod = req('./session_memory_index.js') as {
|
|
410
90
|
session_index_enabled: (root: string) => boolean;
|
|
411
|
-
|
|
91
|
+
serve_session_index_block: (grant: unknown, cap?: number) => string | null;
|
|
92
|
+
session_index_trust: (workspaceRoot: string) => { ok: boolean; code?: string; detail?: string };
|
|
412
93
|
};
|
|
413
94
|
if (!mod.session_index_enabled(root)) return null;
|
|
95
|
+
|
|
96
|
+
// P1-P3, computed ONCE here and handed to the server as a grant. The
|
|
97
|
+
// builder used to re-check it, which R2 finding 7 named as a duplicate
|
|
98
|
+
// for a diagnostic nothing forwards; `serve_session_index_block` now
|
|
99
|
+
// takes the grant, so the check cannot be skipped and is not repeated.
|
|
100
|
+
const verdict = mod.session_index_trust(root);
|
|
101
|
+
if (!verdict.ok) {
|
|
102
|
+
process.stderr.write(`hot-context-hook: session index refused [${String(verdict.code)}]: ${String(verdict.detail)}\n`);
|
|
103
|
+
return null;
|
|
104
|
+
}
|
|
105
|
+
|
|
414
106
|
const prev = process.cwd();
|
|
107
|
+
let block: string | null;
|
|
415
108
|
try {
|
|
416
109
|
process.chdir(root);
|
|
417
|
-
|
|
110
|
+
block = mod.serve_session_index_block(verdict);
|
|
418
111
|
} finally {
|
|
419
112
|
process.chdir(prev);
|
|
420
113
|
}
|
|
114
|
+
|
|
115
|
+
// P5 — duplicate invocation, claimed LAST. `session_start` can fire
|
|
116
|
+
// more than once for one session (resume, host reconnect, compaction
|
|
117
|
+
// boundary on some hosts), and two injections double a fixed cost while
|
|
118
|
+
// presenting two corpora as one session's memory.
|
|
119
|
+
//
|
|
120
|
+
// The ordering is the whole property and it took two corrections to get
|
|
121
|
+
// right. Claiming before the verdict let a refused root burn the
|
|
122
|
+
// session's one claim; claiming before the RENDER let an empty corpus
|
|
123
|
+
// burn it too (R2 finding 5) — so a session that started before its
|
|
124
|
+
// memory was curated would never receive an index afterwards. Nothing
|
|
125
|
+
// is claimed until there is something to serve.
|
|
126
|
+
if (block === null) return null;
|
|
127
|
+
const trust = req('./_lib/session_index_trust.js') as {
|
|
128
|
+
claimSessionOnce: (workspaceRoot: string, sessionId: string) => { ok: boolean; code?: string };
|
|
129
|
+
};
|
|
130
|
+
const claim = trust.claimSessionOnce(root, sessionId);
|
|
131
|
+
if (!claim.ok) {
|
|
132
|
+
process.stderr.write(`hot-context-hook: session index already served [${String(claim.code)}]\n`);
|
|
133
|
+
return null;
|
|
134
|
+
}
|
|
135
|
+
return block;
|
|
421
136
|
} catch (exc) {
|
|
422
137
|
process.stderr.write(`hot-context-hook: session index skipped: ${String(exc)}\n`);
|
|
423
138
|
return null;
|
|
@@ -457,45 +172,25 @@ export function main(): number {
|
|
|
457
172
|
if (_is_replay_mode()) {
|
|
458
173
|
return 0; // replay fixtures: read-only, no state mutation
|
|
459
174
|
}
|
|
460
|
-
|
|
461
|
-
// context-ledger Step 2.1). It is the only slot that fires WHILE state
|
|
462
|
-
// is being destroyed, and until now it carried no writer at all: the
|
|
463
|
-
// cache a post-compaction `session_start` restores was written at the
|
|
464
|
-
// last `stop`, so everything the session did since then was lost with
|
|
465
|
-
// the compaction. Writing here makes the restore reflect the moment
|
|
466
|
-
// before the loss instead of the moment before the last turn.
|
|
467
|
-
//
|
|
468
|
-
// Cheap and idempotent by construction: `_write_hot_context` is a
|
|
469
|
-
// deterministic rebuild from the history file, so an extra fire costs
|
|
470
|
-
// one rebuild and can never produce a worse cache than the older one it
|
|
471
|
-
// replaces. It emits nothing — the restore side is unchanged.
|
|
472
|
-
if (event === 'stop' || event === 'session_end' || event === 'pre_compact') {
|
|
473
|
-
// Claude Code puts the leg's own transcript on the stop payload;
|
|
474
|
-
// the camelCase alias is defensive, matching how the subagent
|
|
475
|
-
// ledger reads `last_assistant_message`. Absent on other hosts,
|
|
476
|
-
// where the advisory is simply empty.
|
|
477
|
-
const tp = payload.transcript_path ?? payload.transcriptPath;
|
|
478
|
-
_write_hot_context(root, typeof tp === 'string' && tp.length > 0 ? tp : null);
|
|
479
|
-
} else if (event === 'session_start') {
|
|
480
|
-
const source = String(payload.source ?? '');
|
|
481
|
-
const decision = restore_hot_context(root, source);
|
|
482
|
-
const blocks: string[] = [];
|
|
483
|
-
if (decision.action === 'inject' && decision.context) {
|
|
484
|
-
blocks.push(decision.context);
|
|
485
|
-
}
|
|
175
|
+
if (event === 'session_start') {
|
|
486
176
|
// Opt-in compact memory index (road-to-memory-retrieval-economy
|
|
487
|
-
// P5) — default OFF
|
|
488
|
-
//
|
|
489
|
-
|
|
177
|
+
// P5) — default OFF. Memory roots are cwd-relative, so resolve
|
|
178
|
+
// from the workspace root.
|
|
179
|
+
// R2 finding 1: reading the payload alone left P5 INERT whenever
|
|
180
|
+
// the host supplied no payload id. `dispatch_hook.ts` resolves
|
|
181
|
+
// `envelope.session_id` from the payload OR `AGENT_SESSION_ID`, and
|
|
182
|
+
// every sibling concern reads the envelope first — proven by two
|
|
183
|
+
// dispatcher runs that emitted the block twice and never latched.
|
|
184
|
+
const sessionId = String(
|
|
185
|
+
envelope.session_id ?? payload.session_id ?? payload.sessionId ?? '',
|
|
186
|
+
);
|
|
187
|
+
const indexBlock = _session_index_block_or_null(root, sessionId);
|
|
490
188
|
if (indexBlock !== null) {
|
|
491
|
-
blocks.push(indexBlock);
|
|
492
|
-
}
|
|
493
|
-
if (blocks.length > 0) {
|
|
494
189
|
process.stdout.write(
|
|
495
190
|
JSON.stringify({
|
|
496
191
|
decision: 'allow',
|
|
497
|
-
reason:
|
|
498
|
-
context:
|
|
192
|
+
reason: 'memory session index',
|
|
193
|
+
context: indexBlock,
|
|
499
194
|
}) + '\n',
|
|
500
195
|
);
|
|
501
196
|
}
|
|
@@ -18,9 +18,6 @@
|
|
|
18
18
|
* trigram, no engine fork / no FTS5; ADR-061 honoured)
|
|
19
19
|
* - corpus scale — > 500 files across all types
|
|
20
20
|
* → same lexical-index activation path
|
|
21
|
-
* - hot-context size — `agents/runtime/state/hot-context.md` > 600 tokens
|
|
22
|
-
* (estimated at 4 chars/token) → trim schema / fix the
|
|
23
|
-
* deterministic writer
|
|
24
21
|
*
|
|
25
22
|
* Usage: lint_knowledge_scale.ts [--dir <repo-root>] [--format text|json] [--quiet]
|
|
26
23
|
* Exit codes: 0 = ran cleanly (warnings never fail the build), 1 = usage
|
|
@@ -39,8 +36,6 @@ export const INTAKE_EVENTS_MAX = 2000;
|
|
|
39
36
|
export const SESSIONS_PAGES_MAX = 50;
|
|
40
37
|
export const TYPE_FILES_MAX = 200;
|
|
41
38
|
export const CORPUS_FILES_MAX = 500;
|
|
42
|
-
export const HOT_CONTEXT_TOKENS_MAX = 600;
|
|
43
|
-
export const CHARS_PER_TOKEN = 4;
|
|
44
39
|
|
|
45
40
|
const KNOWLEDGE_TYPED_DIRS = ['sessions', 'concepts', 'procedures', 'decisions'] as const;
|
|
46
41
|
|
|
@@ -206,27 +201,6 @@ export function runChecks(root: string, stats?: ScanStats): Warning[] {
|
|
|
206
201
|
});
|
|
207
202
|
}
|
|
208
203
|
|
|
209
|
-
// 5. Hot-context budget.
|
|
210
|
-
const hotContext = path.join(root, 'agents', 'runtime', 'state', 'hot-context.md');
|
|
211
|
-
let hotText = '';
|
|
212
|
-
try {
|
|
213
|
-
hotText = fs.readFileSync(hotContext, 'utf-8');
|
|
214
|
-
} catch {
|
|
215
|
-
// absent — fine (feature not active or fresh session)
|
|
216
|
-
}
|
|
217
|
-
if (hotText) {
|
|
218
|
-
const tokens = Math.ceil(hotText.length / CHARS_PER_TOKEN);
|
|
219
|
-
if (tokens > HOT_CONTEXT_TOKENS_MAX) {
|
|
220
|
-
warnings.push({
|
|
221
|
-
rule: 'hot-context-budget',
|
|
222
|
-
metric: `${tokens}/${HOT_CONTEXT_TOKENS_MAX}`,
|
|
223
|
-
message:
|
|
224
|
-
`hot-context.md parses to ~${tokens} tokens (> ${HOT_CONTEXT_TOKENS_MAX}). ` +
|
|
225
|
-
'Activation path (pre-decided): trim the schema sections or fix the deterministic writer cap.',
|
|
226
|
-
});
|
|
227
|
-
}
|
|
228
|
-
}
|
|
229
|
-
|
|
230
204
|
return warnings;
|
|
231
205
|
}
|
|
232
206
|
|