@jaimevalasek/aioson 1.5.1 → 1.7.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/CHANGELOG.md +49 -0
- package/README.md +729 -226
- package/docs/design-previews/aurora-command-ui-website.html +884 -0
- package/docs/design-previews/aurora-command-ui.html +682 -0
- package/docs/design-previews/bold-editorial-ui-website.html +658 -0
- package/docs/design-previews/bold-editorial-ui.html +717 -0
- package/docs/design-previews/clean-saas-ui-website.html +1202 -0
- package/docs/design-previews/clean-saas-ui.html +549 -0
- package/docs/design-previews/cognitive-core-ui-website.html +1009 -0
- package/docs/design-previews/cognitive-core-ui.html +463 -0
- package/docs/design-previews/glassmorphism-ui-website.html +572 -0
- package/docs/design-previews/glassmorphism-ui.html +886 -0
- package/docs/design-previews/index.html +699 -0
- package/docs/design-previews/interface-design-website.html +1187 -0
- package/docs/design-previews/interface-design.html +513 -0
- package/docs/design-previews/neo-brutalist-ui-website.html +621 -0
- package/docs/design-previews/neo-brutalist-ui.html +797 -0
- package/docs/design-previews/premium-command-center-ui-website.html +1217 -0
- package/docs/design-previews/premium-command-center-ui.html +552 -0
- package/docs/design-previews/pt.squarespace.com-homepage.html +889 -0
- package/docs/design-previews/warm-craft-ui-website.html +684 -0
- package/docs/design-previews/warm-craft-ui.html +739 -0
- package/docs/en/cli-reference.md +20 -9
- package/docs/integrations/sdlc-genius-boundary.md +76 -0
- package/docs/integrations/sdlc-genius-eval-matrix.md +75 -0
- package/docs/integrations/sdlc-genius-install-checklist.md +93 -0
- package/docs/integrations/sdlc-genius-review-samples.md +86 -0
- package/docs/pt/README.md +10 -0
- package/docs/pt/agent-sharding.md +132 -0
- package/docs/pt/agentes.md +9 -2
- package/docs/pt/busca-de-contexto.md +129 -0
- package/docs/pt/cache-de-contexto.md +156 -0
- package/docs/pt/comandos-cli.md +915 -1
- package/docs/pt/design-hybrid-forge.md +356 -0
- package/docs/pt/devlog-pipeline.md +270 -0
- package/docs/pt/fluxo-artefatos.md +178 -0
- package/docs/pt/hooks-session-guard.md +454 -0
- package/docs/pt/inicio-rapido.md +54 -3
- package/docs/pt/inteligencia-adaptativa.md +324 -0
- package/docs/pt/monitor-de-contexto.md +158 -0
- package/docs/pt/recuperacao-de-sessao.md +125 -0
- package/docs/pt/sandbox.md +125 -0
- package/docs/pt/sdd-automation-scripts.md +557 -0
- package/docs/pt/site-forge.md +309 -0
- package/docs/pt/skills.md +98 -6
- package/docs/pt/spec-learnings-pipeline.md +265 -0
- package/package.json +1 -1
- package/src/a2a/client.js +165 -0
- package/src/a2a/server.js +223 -0
- package/src/agent-loader.js +280 -0
- package/src/cli.js +329 -1
- package/src/commands/agent-audit.js +397 -0
- package/src/commands/agent-export-skill.js +229 -0
- package/src/commands/agent-loader.js +85 -0
- package/src/commands/artifact-validate.js +189 -0
- package/src/commands/brief-gen.js +405 -0
- package/src/commands/brief-validate.js +65 -0
- package/src/commands/classify.js +256 -0
- package/src/commands/context-cache.js +90 -0
- package/src/commands/context-compact.js +49 -0
- package/src/commands/context-health.js +175 -0
- package/src/commands/context-monitor.js +163 -0
- package/src/commands/context-search.js +66 -0
- package/src/commands/context-trim.js +177 -0
- package/src/commands/design-hybrid-options.js +385 -0
- package/src/commands/detect-test-runner.js +55 -0
- package/src/commands/devlog-export-brains.js +27 -0
- package/src/commands/devlog-process.js +292 -0
- package/src/commands/devlog-watch.js +131 -0
- package/src/commands/feature-close.js +165 -0
- package/src/commands/gate-check.js +228 -0
- package/src/commands/health.js +214 -0
- package/src/commands/hooks-emit.js +253 -0
- package/src/commands/hooks-install.js +347 -0
- package/src/commands/init.js +54 -13
- package/src/commands/install.js +52 -13
- package/src/commands/learning-auto-promote.js +195 -0
- package/src/commands/learning-evolve.js +364 -0
- package/src/commands/learning-export.js +103 -0
- package/src/commands/learning-rollback.js +164 -0
- package/src/commands/live.js +59 -1
- package/src/commands/pattern-detect.js +33 -0
- package/src/commands/preflight-context.js +30 -0
- package/src/commands/preflight.js +208 -0
- package/src/commands/pulse-update.js +130 -0
- package/src/commands/recovery.js +43 -0
- package/src/commands/runner-daemon.js +274 -0
- package/src/commands/runner-plan.js +70 -0
- package/src/commands/runner-queue-from-plan.js +166 -0
- package/src/commands/runner-queue.js +189 -0
- package/src/commands/runner-run.js +129 -0
- package/src/commands/runtime.js +47 -1
- package/src/commands/sandbox.js +37 -0
- package/src/commands/self-implement-loop.js +256 -0
- package/src/commands/session-guard.js +218 -0
- package/src/commands/setup-context.js +22 -2
- package/src/commands/setup.js +178 -0
- package/src/commands/sizing.js +165 -0
- package/src/commands/skill.js +144 -32
- package/src/commands/spec-checkpoint.js +177 -0
- package/src/commands/spec-status.js +79 -0
- package/src/commands/spec-sync.js +190 -0
- package/src/commands/spec-tasks.js +288 -0
- package/src/commands/squad-autorun.js +1220 -0
- package/src/commands/squad-bus.js +217 -0
- package/src/commands/squad-card.js +149 -0
- package/src/commands/squad-daemon.js +134 -0
- package/src/commands/squad-dependency-graph.js +164 -0
- package/src/commands/squad-review.js +106 -0
- package/src/commands/squad-scaffold.js +55 -0
- package/src/commands/squad-tool-register.js +157 -0
- package/src/commands/state-save.js +122 -0
- package/src/commands/tool-registry-cmd.js +232 -0
- package/src/commands/update.js +9 -0
- package/src/commands/verify-gate.js +572 -0
- package/src/commands/workflow-execute.js +241 -0
- package/src/constants.js +18 -0
- package/src/context-cache.js +159 -0
- package/src/context-search.js +326 -0
- package/src/design-variation-catalog.js +503 -0
- package/src/i18n/messages/en.js +32 -2
- package/src/i18n/messages/es.js +30 -2
- package/src/i18n/messages/fr.js +30 -2
- package/src/i18n/messages/pt-BR.js +32 -2
- package/src/install-animation.js +260 -0
- package/src/install-profile.js +143 -0
- package/src/install-wizard.js +475 -0
- package/src/installer.js +44 -10
- package/src/lib/health-check.js +158 -0
- package/src/lib/hook-protocol.js +76 -0
- package/src/mcp/apps/squad-dashboard/app.js +163 -0
- package/src/mcp/apps/squad-dashboard/index.html +261 -0
- package/src/mcp/apps/squad-dashboard/mcp-manifest.json +23 -0
- package/src/mcp/resources/squad-state.js +130 -0
- package/src/parser.js +7 -1
- package/src/preflight-engine.js +443 -0
- package/src/recovery-context-session.js +154 -0
- package/src/runner/cascade.js +97 -0
- package/src/runner/cli-launcher.js +109 -0
- package/src/runner/plan-importer.js +63 -0
- package/src/runner/queue-store.js +159 -0
- package/src/runtime-store.js +158 -4
- package/src/sandbox.js +177 -0
- package/src/squad/agent-teams-adapter.js +264 -0
- package/src/squad/brief-validator.js +350 -0
- package/src/squad/bus-bridge.js +140 -0
- package/src/squad/context-compactor.js +265 -0
- package/src/squad/cross-ai-synthesizer.js +250 -0
- package/src/squad/hooks-generator.js +196 -0
- package/src/squad/inter-squad-events.js +175 -0
- package/src/squad/intra-bus.js +345 -0
- package/src/squad/learning-extractor.js +213 -0
- package/src/squad/pattern-detector.js +365 -0
- package/src/squad/preflight-context.js +296 -0
- package/src/squad/recovery-context.js +242 -71
- package/src/squad/reflection.js +365 -0
- package/src/squad/squad-scaffold.js +177 -0
- package/src/squad/state-manager.js +310 -0
- package/src/squad/task-decomposer.js +652 -0
- package/src/squad/verify-gate.js +303 -0
- package/src/tool-executor.js +94 -0
- package/src/updater.js +10 -3
- package/src/worker-runner.js +186 -1
- package/template/.aioson/agents/analyst.md +119 -3
- package/template/.aioson/agents/architect.md +98 -0
- package/template/.aioson/agents/design-hybrid-forge.md +141 -0
- package/template/.aioson/agents/dev.md +335 -14
- package/template/.aioson/agents/deyvin.md +117 -2
- package/template/.aioson/agents/discovery-design-doc.md +44 -0
- package/template/.aioson/agents/genome.md +14 -0
- package/template/.aioson/agents/neo.md +78 -1
- package/template/.aioson/agents/orache.md +50 -4
- package/template/.aioson/agents/orchestrator.md +197 -1
- package/template/.aioson/agents/pm.md +93 -0
- package/template/.aioson/agents/product.md +77 -4
- package/template/.aioson/agents/profiler-enricher.md +14 -0
- package/template/.aioson/agents/profiler-forge.md +14 -0
- package/template/.aioson/agents/profiler-researcher.md +14 -0
- package/template/.aioson/agents/qa.md +249 -19
- package/template/.aioson/agents/setup.md +144 -12
- package/template/.aioson/agents/sheldon.md +237 -11
- package/template/.aioson/agents/site-forge.md +1753 -0
- package/template/.aioson/agents/squad.md +162 -0
- package/template/.aioson/agents/tester.md +209 -0
- package/template/.aioson/agents/ux-ui.md +34 -1
- package/template/.aioson/brains/README.md +128 -0
- package/template/.aioson/brains/_index.json +16 -0
- package/template/.aioson/brains/scripts/query.js +103 -0
- package/template/.aioson/brains/site-forge/visual-patterns.brain.json +205 -0
- package/template/.aioson/config.md +158 -13
- package/template/.aioson/constitution.md +33 -0
- package/template/.aioson/context/forensics/.gitkeep +0 -0
- package/template/.aioson/context/project-pulse.md +34 -0
- package/template/.aioson/context/seeds/seed-example.md +27 -0
- package/template/.aioson/context/user-profile.md +42 -0
- package/template/.aioson/docs/LAYERS.md +79 -0
- package/template/.aioson/docs/README.md +76 -0
- package/template/.aioson/docs/example-external-api-context.md +72 -0
- package/template/.aioson/locales/en/agents/architect.md +17 -0
- package/template/.aioson/locales/en/agents/dev.md +79 -13
- package/template/.aioson/locales/en/agents/orache.md +6 -0
- package/template/.aioson/locales/en/agents/orchestrator.md +24 -0
- package/template/.aioson/locales/en/agents/product.md +50 -0
- package/template/.aioson/locales/en/agents/setup.md +33 -1
- package/template/.aioson/locales/en/agents/sheldon.md +115 -0
- package/template/.aioson/locales/en/agents/squad.md +14 -0
- package/template/.aioson/locales/en/agents/tester.md +6 -0
- package/template/.aioson/locales/es/agents/analyst.md +2 -0
- package/template/.aioson/locales/es/agents/architect.md +19 -0
- package/template/.aioson/locales/es/agents/dev.md +64 -4
- package/template/.aioson/locales/es/agents/deyvin.md +2 -0
- package/template/.aioson/locales/es/agents/discovery-design-doc.md +2 -0
- package/template/.aioson/locales/es/agents/genome.md +2 -0
- package/template/.aioson/locales/es/agents/neo.md +2 -0
- package/template/.aioson/locales/es/agents/orache.md +2 -0
- package/template/.aioson/locales/es/agents/orchestrator.md +26 -0
- package/template/.aioson/locales/es/agents/pair.md +2 -0
- package/template/.aioson/locales/es/agents/pm.md +2 -0
- package/template/.aioson/locales/es/agents/product.md +52 -0
- package/template/.aioson/locales/es/agents/profiler-enricher.md +2 -0
- package/template/.aioson/locales/es/agents/profiler-forge.md +2 -0
- package/template/.aioson/locales/es/agents/profiler-researcher.md +2 -0
- package/template/.aioson/locales/es/agents/qa.md +2 -0
- package/template/.aioson/locales/es/agents/setup.md +35 -1
- package/template/.aioson/locales/es/agents/sheldon.md +117 -0
- package/template/.aioson/locales/es/agents/squad.md +16 -0
- package/template/.aioson/locales/es/agents/tester.md +9 -0
- package/template/.aioson/locales/es/agents/ux-ui.md +2 -0
- package/template/.aioson/locales/fr/agents/analyst.md +2 -0
- package/template/.aioson/locales/fr/agents/architect.md +19 -0
- package/template/.aioson/locales/fr/agents/dev.md +64 -4
- package/template/.aioson/locales/fr/agents/deyvin.md +2 -0
- package/template/.aioson/locales/fr/agents/discovery-design-doc.md +2 -0
- package/template/.aioson/locales/fr/agents/genome.md +2 -0
- package/template/.aioson/locales/fr/agents/neo.md +2 -0
- package/template/.aioson/locales/fr/agents/orache.md +2 -0
- package/template/.aioson/locales/fr/agents/orchestrator.md +26 -0
- package/template/.aioson/locales/fr/agents/pair.md +2 -0
- package/template/.aioson/locales/fr/agents/pm.md +2 -0
- package/template/.aioson/locales/fr/agents/product.md +52 -0
- package/template/.aioson/locales/fr/agents/profiler-enricher.md +2 -0
- package/template/.aioson/locales/fr/agents/profiler-forge.md +2 -0
- package/template/.aioson/locales/fr/agents/profiler-researcher.md +2 -0
- package/template/.aioson/locales/fr/agents/qa.md +2 -0
- package/template/.aioson/locales/fr/agents/setup.md +35 -1
- package/template/.aioson/locales/fr/agents/sheldon.md +117 -0
- package/template/.aioson/locales/fr/agents/squad.md +16 -0
- package/template/.aioson/locales/fr/agents/tester.md +9 -0
- package/template/.aioson/locales/fr/agents/ux-ui.md +2 -0
- package/template/.aioson/locales/pt-BR/agents/analyst.md +64 -3
- package/template/.aioson/locales/pt-BR/agents/architect.md +42 -0
- package/template/.aioson/locales/pt-BR/agents/dev.md +147 -14
- package/template/.aioson/locales/pt-BR/agents/deyvin.md +47 -0
- package/template/.aioson/locales/pt-BR/agents/neo.md +62 -1
- package/template/.aioson/locales/pt-BR/agents/orchestrator.md +158 -2
- package/template/.aioson/locales/pt-BR/agents/pm.md +95 -1
- package/template/.aioson/locales/pt-BR/agents/product.md +145 -18
- package/template/.aioson/locales/pt-BR/agents/qa.md +16 -0
- package/template/.aioson/locales/pt-BR/agents/setup.md +134 -19
- package/template/.aioson/locales/pt-BR/agents/sheldon.md +132 -1
- package/template/.aioson/locales/pt-BR/agents/squad.md +14 -0
- package/template/.aioson/locales/pt-BR/agents/tester.md +449 -0
- package/template/.aioson/rules/README.md +69 -0
- package/template/.aioson/rules/data-format-convention.md +136 -0
- package/template/.aioson/rules/example-monetary-values.md +30 -0
- package/template/.aioson/schemas/squad-manifest.schema.json +124 -3
- package/template/.aioson/skills/design/aurora-command-ui/SKILL.md +243 -0
- package/template/.aioson/skills/design/aurora-command-ui/references/art-direction.md +293 -0
- package/template/.aioson/skills/design/aurora-command-ui/references/components.md +827 -0
- package/template/.aioson/skills/design/aurora-command-ui/references/dashboards.md +250 -0
- package/template/.aioson/skills/design/aurora-command-ui/references/design-tokens.md +585 -0
- package/template/.aioson/skills/design/aurora-command-ui/references/motion.md +365 -0
- package/template/.aioson/skills/design/aurora-command-ui/references/patterns.md +482 -0
- package/template/.aioson/skills/design/aurora-command-ui/references/websites.md +387 -0
- package/template/.aioson/skills/design/glassmorphism-ui/SKILL.md +222 -0
- package/template/.aioson/skills/design/glassmorphism-ui/references/art-direction.md +159 -0
- package/template/.aioson/skills/design/glassmorphism-ui/references/components.md +498 -0
- package/template/.aioson/skills/design/glassmorphism-ui/references/dashboards.md +236 -0
- package/template/.aioson/skills/design/glassmorphism-ui/references/design-tokens.md +274 -0
- package/template/.aioson/skills/design/glassmorphism-ui/references/motion.md +355 -0
- package/template/.aioson/skills/design/glassmorphism-ui/references/patterns.md +198 -0
- package/template/.aioson/skills/design/glassmorphism-ui/references/websites.md +307 -0
- package/template/.aioson/skills/design/neo-brutalist-ui/SKILL.md +213 -0
- package/template/.aioson/skills/design/neo-brutalist-ui/references/art-direction.md +228 -0
- package/template/.aioson/skills/design/neo-brutalist-ui/references/components.md +855 -0
- package/template/.aioson/skills/design/neo-brutalist-ui/references/dashboards.md +334 -0
- package/template/.aioson/skills/design/neo-brutalist-ui/references/design-tokens.md +342 -0
- package/template/.aioson/skills/design/neo-brutalist-ui/references/motion.md +286 -0
- package/template/.aioson/skills/design/neo-brutalist-ui/references/patterns.md +458 -0
- package/template/.aioson/skills/design/neo-brutalist-ui/references/websites.md +723 -0
- package/template/.aioson/skills/design/pt.squarespace.com/.skill-meta.json +31 -0
- package/template/.aioson/skills/design/pt.squarespace.com/SKILL.md +66 -0
- package/template/.aioson/skills/design/pt.squarespace.com/references/components.md +368 -0
- package/template/.aioson/skills/design/pt.squarespace.com/references/design-tokens.md +150 -0
- package/template/.aioson/skills/design/pt.squarespace.com/references/motion.md +270 -0
- package/template/.aioson/skills/design/pt.squarespace.com/references/patterns.md +189 -0
- package/template/.aioson/skills/design/pt.squarespace.com/references/websites.md +165 -0
- package/template/.aioson/skills/process/aioson-spec-driven/SKILL.md +46 -0
- package/template/.aioson/skills/process/aioson-spec-driven/references/analyst.md +30 -0
- package/template/.aioson/skills/process/aioson-spec-driven/references/approval-gates.md +109 -0
- package/template/.aioson/skills/process/aioson-spec-driven/references/architect.md +23 -0
- package/template/.aioson/skills/process/aioson-spec-driven/references/artifact-map.md +44 -0
- package/template/.aioson/skills/process/aioson-spec-driven/references/classification-map.md +37 -0
- package/template/.aioson/skills/process/aioson-spec-driven/references/dev.md +47 -0
- package/template/.aioson/skills/process/aioson-spec-driven/references/deyvin.md +27 -0
- package/template/.aioson/skills/process/aioson-spec-driven/references/hardening-lane.md +49 -0
- package/template/.aioson/skills/process/aioson-spec-driven/references/maintenance-and-state.md +101 -0
- package/template/.aioson/skills/process/aioson-spec-driven/references/product.md +25 -0
- package/template/.aioson/skills/process/aioson-spec-driven/references/qa.md +30 -0
- package/template/.aioson/skills/process/aioson-spec-driven/references/sheldon.md +25 -0
- package/template/.aioson/skills/process/aioson-spec-driven/references/ui-language.md +75 -0
- package/template/.aioson/skills/process/design-hybrid-forge/SKILL.md +147 -0
- package/template/.aioson/skills/process/design-hybrid-forge/references/crossover-protocol.md +221 -0
- package/template/.aioson/skills/process/design-hybrid-forge/references/naming-registry.md +88 -0
- package/template/.aioson/skills/process/design-hybrid-forge/references/output-contract.md +306 -0
- package/template/.aioson/skills/process/design-hybrid-forge/references/pair-compatibility.md +149 -0
- package/template/.aioson/skills/process/design-hybrid-forge/references/quality-gates.md +208 -0
- package/template/.aioson/skills/process/design-hybrid-forge/references/variation-library.md +125 -0
- package/template/.aioson/skills/process/simplify/SKILL.md +173 -0
- package/template/.aioson/skills/static/context-budget-guide.md +46 -0
- package/template/.aioson/skills/static/harness-sensors.md +74 -0
- package/template/.aioson/skills/static/multi-agent-patterns.md +43 -0
- package/template/.aioson/skills/static/react-motion-patterns.md +22 -0
- package/template/.aioson/skills/static/static-html-patterns/checklists.md +43 -0
- package/template/.aioson/skills/static/static-html-patterns/css-tokens.md +609 -0
- package/template/.aioson/skills/static/static-html-patterns/motion.md +193 -0
- package/template/.aioson/skills/static/static-html-patterns/premium.md +711 -0
- package/template/.aioson/skills/static/static-html-patterns/structure.md +209 -0
- package/template/.aioson/skills/static/static-html-patterns/utilities.md +190 -0
- package/template/.aioson/skills/static/static-html-patterns.md +58 -1913
- package/template/.aioson/skills/static/threejs-patterns.md +929 -0
- package/template/.aioson/skills/static/web-research-cache.md +112 -0
- package/template/.aioson/tasks/implementation-plan.md +21 -1
- package/template/.claude/commands/aioson/agent/design-hybrid-forge.md +5 -0
- package/template/.claude/commands/aioson/agent/orache.md +5 -0
- package/template/.claude/commands/aioson/agent/sheldon.md +5 -0
- package/template/.claude/commands/aioson/agent/site-forge.md +5 -0
- package/template/AGENTS.md +75 -1
- package/template/CLAUDE.md +31 -0
- package/template/OPENCODE.md +4 -0
- package/template/researchs/.gitkeep +0 -0
|
@@ -0,0 +1,163 @@
|
|
|
1
|
+
'use strict';
|
|
2
|
+
|
|
3
|
+
const path = require('node:path');
|
|
4
|
+
const {
|
|
5
|
+
getContextUsage,
|
|
6
|
+
computeWarningLevel,
|
|
7
|
+
THRESHOLDS
|
|
8
|
+
} = require('../squad-dashboard/context-monitor');
|
|
9
|
+
const { openRuntimeDb, appendRunEvent } = require('../runtime-store');
|
|
10
|
+
|
|
11
|
+
const PROJECT_BUDGET_ZONES = {
|
|
12
|
+
safe: 0.60,
|
|
13
|
+
warning: 0.80,
|
|
14
|
+
critical: 1.00
|
|
15
|
+
};
|
|
16
|
+
|
|
17
|
+
const BAR_WIDTH = 20;
|
|
18
|
+
const LEVEL_ICONS = { normal: ' ', warning: '⚠', critical: '!', overflow: 'X', unknown: '?' };
|
|
19
|
+
|
|
20
|
+
function renderBar(ratio, width) {
|
|
21
|
+
const clamped = Math.max(0, Math.min(1, ratio));
|
|
22
|
+
const filled = Math.round(clamped * width);
|
|
23
|
+
const bar = '█'.repeat(filled) + '░'.repeat(width - filled);
|
|
24
|
+
return `[${bar}] ${Math.round(clamped * 100)}%`;
|
|
25
|
+
}
|
|
26
|
+
|
|
27
|
+
function formatTokens(n) {
|
|
28
|
+
if (typeof n !== 'number') return '?';
|
|
29
|
+
return n.toLocaleString();
|
|
30
|
+
}
|
|
31
|
+
|
|
32
|
+
function renderAgent(slug, agent) {
|
|
33
|
+
const used = agent.totalUsed || 0;
|
|
34
|
+
const win = agent.windowSize || 0;
|
|
35
|
+
const ratio = win > 0 ? used / win : 0;
|
|
36
|
+
const level = agent.warningLevel || computeWarningLevel(used, win);
|
|
37
|
+
const icon = LEVEL_ICONS[level] || '?';
|
|
38
|
+
const bar = renderBar(ratio, BAR_WIDTH);
|
|
39
|
+
const line = ` ${icon} ${slug.padEnd(16)} ${bar} ${formatTokens(used)}/${formatTokens(win)}`;
|
|
40
|
+
if (level === 'warning' || level === 'critical' || level === 'overflow') {
|
|
41
|
+
return `${line} [${level.toUpperCase()}]`;
|
|
42
|
+
}
|
|
43
|
+
return line;
|
|
44
|
+
}
|
|
45
|
+
|
|
46
|
+
async function emitBudgetEvent(cwd, { tokens, budget, pct, zone, agentName }) {
|
|
47
|
+
const { db } = await openRuntimeDb(cwd, { mustExist: true }).catch(() => ({ db: null }));
|
|
48
|
+
if (!db) return;
|
|
49
|
+
try {
|
|
50
|
+
const run = db.prepare(
|
|
51
|
+
"SELECT run_key FROM agent_runs WHERE status = 'running' ORDER BY updated_at DESC LIMIT 1"
|
|
52
|
+
).get();
|
|
53
|
+
if (run) {
|
|
54
|
+
appendRunEvent(db, {
|
|
55
|
+
runKey: run.run_key,
|
|
56
|
+
eventType: zone === 'critical' ? 'context_budget_critical' : 'context_budget_warning',
|
|
57
|
+
phase: 'live',
|
|
58
|
+
status: 'running',
|
|
59
|
+
message: `Context at ${pct}% of budget (${tokens.toLocaleString()} tokens)`,
|
|
60
|
+
payload: { tokens, budget, pct, zone, agentName: agentName || null },
|
|
61
|
+
createdAt: new Date().toISOString()
|
|
62
|
+
});
|
|
63
|
+
}
|
|
64
|
+
} finally {
|
|
65
|
+
db.close();
|
|
66
|
+
}
|
|
67
|
+
}
|
|
68
|
+
|
|
69
|
+
async function runContextMonitor({ args, options, logger }) {
|
|
70
|
+
const cwd = path.resolve(process.cwd(), args[0] || '.');
|
|
71
|
+
const squadSlug = options.squad || null;
|
|
72
|
+
const agentSlug = options.agent || null;
|
|
73
|
+
const budget = options.budget ? Number(options.budget) : null;
|
|
74
|
+
|
|
75
|
+
// Project-level budget monitoring (--budget=<tokens>)
|
|
76
|
+
if (budget && !squadSlug) {
|
|
77
|
+
const tokens = options.tokens ? Number(options.tokens) : null;
|
|
78
|
+
if (tokens !== null) {
|
|
79
|
+
const pct = Math.round((tokens / budget) * 100);
|
|
80
|
+
const zone = pct >= 100 ? 'overflow'
|
|
81
|
+
: pct >= PROJECT_BUDGET_ZONES.warning * 100 ? 'critical'
|
|
82
|
+
: pct >= PROJECT_BUDGET_ZONES.safe * 100 ? 'warning'
|
|
83
|
+
: 'safe';
|
|
84
|
+
|
|
85
|
+
const icon = zone === 'overflow' ? 'X' : zone === 'critical' ? '!' : zone === 'warning' ? '⚠' : '✓';
|
|
86
|
+
|
|
87
|
+
if (!options.json) {
|
|
88
|
+
logger.log(` ${icon} Context: ${tokens.toLocaleString()} tokens (${pct}%) — ${zone.toUpperCase()}`);
|
|
89
|
+
if (zone === 'warning') {
|
|
90
|
+
logger.log(` Suggestion: /clear before next agent activation`);
|
|
91
|
+
} else if (zone === 'critical' || zone === 'overflow') {
|
|
92
|
+
logger.log(` Run: aioson context:health . for reduction options`);
|
|
93
|
+
}
|
|
94
|
+
}
|
|
95
|
+
|
|
96
|
+
if (zone === 'warning' || zone === 'critical' || zone === 'overflow') {
|
|
97
|
+
await emitBudgetEvent(cwd, { tokens, budget, pct, zone, agentName: agentSlug });
|
|
98
|
+
}
|
|
99
|
+
|
|
100
|
+
if (options.json) {
|
|
101
|
+
return { ok: true, tokens, budget, pct, zone };
|
|
102
|
+
}
|
|
103
|
+
return { ok: true, tokens, budget, pct, zone };
|
|
104
|
+
}
|
|
105
|
+
|
|
106
|
+
if (!options.json) {
|
|
107
|
+
logger.log(` Budget: ${budget.toLocaleString()} tokens`);
|
|
108
|
+
logger.log(` Zones: safe=<${PROJECT_BUDGET_ZONES.safe * 100}% warning=${PROJECT_BUDGET_ZONES.safe * 100}-${PROJECT_BUDGET_ZONES.warning * 100}% critical=>=${PROJECT_BUDGET_ZONES.warning * 100}%`);
|
|
109
|
+
logger.log(` Use --tokens=<n> to check against budget`);
|
|
110
|
+
}
|
|
111
|
+
return { ok: true, budget, zones: PROJECT_BUDGET_ZONES };
|
|
112
|
+
}
|
|
113
|
+
|
|
114
|
+
if (!squadSlug) {
|
|
115
|
+
logger.log('\n Context Monitor\n');
|
|
116
|
+
logger.log(' No squad specified. Use --squad=<slug> to monitor a squad.');
|
|
117
|
+
logger.log(' Example: aioson context:monitor . --squad=my-squad');
|
|
118
|
+
logger.log(' Or use --budget=<tokens> --tokens=<current> for project-level monitoring.');
|
|
119
|
+
logger.log('');
|
|
120
|
+
return { ok: true, squads: [] };
|
|
121
|
+
}
|
|
122
|
+
|
|
123
|
+
const data = await getContextUsage(cwd, squadSlug, agentSlug || null);
|
|
124
|
+
|
|
125
|
+
if (!data) {
|
|
126
|
+
logger.log(`\n No context data found for squad: ${squadSlug}`);
|
|
127
|
+
logger.log(' The squad may not have started yet or context-monitor.json is missing.');
|
|
128
|
+
logger.log('');
|
|
129
|
+
return { ok: true, squadSlug, agents: {} };
|
|
130
|
+
}
|
|
131
|
+
|
|
132
|
+
if (options.json) {
|
|
133
|
+
return { ok: true, ...data };
|
|
134
|
+
}
|
|
135
|
+
|
|
136
|
+
logger.log(`\n Context Monitor — ${squadSlug}\n`);
|
|
137
|
+
|
|
138
|
+
if (agentSlug) {
|
|
139
|
+
// Single agent
|
|
140
|
+
const agent = data;
|
|
141
|
+
logger.log(renderAgent(agentSlug, agent));
|
|
142
|
+
} else {
|
|
143
|
+
const agents = data.agents || {};
|
|
144
|
+
if (Object.keys(agents).length === 0) {
|
|
145
|
+
logger.log(' No agents tracked yet.');
|
|
146
|
+
} else {
|
|
147
|
+
for (const [slug, agent] of Object.entries(agents)) {
|
|
148
|
+
logger.log(renderAgent(slug, agent));
|
|
149
|
+
}
|
|
150
|
+
}
|
|
151
|
+
}
|
|
152
|
+
|
|
153
|
+
logger.log('');
|
|
154
|
+
logger.log(` Thresholds: warning=${Math.round(THRESHOLDS.warning * 100)}% critical=${Math.round(THRESHOLDS.critical * 100)}%`);
|
|
155
|
+
if (data.updatedAt) {
|
|
156
|
+
logger.log(` Updated: ${data.updatedAt}`);
|
|
157
|
+
}
|
|
158
|
+
logger.log('');
|
|
159
|
+
|
|
160
|
+
return { ok: true, ...data };
|
|
161
|
+
}
|
|
162
|
+
|
|
163
|
+
module.exports = { runContextMonitor };
|
|
@@ -0,0 +1,66 @@
|
|
|
1
|
+
'use strict';
|
|
2
|
+
|
|
3
|
+
const path = require('node:path');
|
|
4
|
+
const { withIndex } = require('../context-search');
|
|
5
|
+
|
|
6
|
+
async function runContextSearch({ args, options, logger }) {
|
|
7
|
+
const query = args[0] || options.query || '';
|
|
8
|
+
const cwd = path.resolve(process.cwd(), options.cwd || '.');
|
|
9
|
+
const limit = Number(options.limit) || 10;
|
|
10
|
+
|
|
11
|
+
if (!query) {
|
|
12
|
+
logger.log('Usage: aioson context:search <query> [--limit=10] [--cwd=.]');
|
|
13
|
+
return { ok: false, error: 'missing_query' };
|
|
14
|
+
}
|
|
15
|
+
|
|
16
|
+
const results = await withIndex(async (idx) => {
|
|
17
|
+
return idx.search(query, { limit, projectDir: cwd });
|
|
18
|
+
});
|
|
19
|
+
|
|
20
|
+
if (options.json) {
|
|
21
|
+
return { ok: true, results };
|
|
22
|
+
}
|
|
23
|
+
|
|
24
|
+
if (results.length === 0) {
|
|
25
|
+
logger.log(`No results for: ${query}`);
|
|
26
|
+
return { ok: true, results: [] };
|
|
27
|
+
}
|
|
28
|
+
|
|
29
|
+
logger.log(`\n Search results for: "${query}"\n`);
|
|
30
|
+
for (let i = 0; i < results.length; i++) {
|
|
31
|
+
const r = results[i];
|
|
32
|
+
logger.log(` ${i + 1}. ${r.title}`);
|
|
33
|
+
logger.log(` ${r.relPath}`);
|
|
34
|
+
if (r.snippet) {
|
|
35
|
+
logger.log(` ${r.snippet.replace(/\n/g, ' ')}`);
|
|
36
|
+
}
|
|
37
|
+
logger.log('');
|
|
38
|
+
}
|
|
39
|
+
|
|
40
|
+
return { ok: true, results };
|
|
41
|
+
}
|
|
42
|
+
|
|
43
|
+
async function runContextSearchIndex({ args, options, logger }) {
|
|
44
|
+
const cwd = path.resolve(process.cwd(), args[0] || '.');
|
|
45
|
+
const force = Boolean(options.force);
|
|
46
|
+
|
|
47
|
+
logger.log(`Indexing: ${cwd} ...`);
|
|
48
|
+
|
|
49
|
+
const result = await withIndex(async (idx) => {
|
|
50
|
+
const r = await idx.indexDirectory(cwd, { force });
|
|
51
|
+
const stats = idx.stats();
|
|
52
|
+
return { ...r, stats };
|
|
53
|
+
});
|
|
54
|
+
|
|
55
|
+
if (options.json) {
|
|
56
|
+
return { ok: true, ...result };
|
|
57
|
+
}
|
|
58
|
+
|
|
59
|
+
logger.log(` Indexed: ${result.indexed} files`);
|
|
60
|
+
logger.log(` Skipped: ${result.skipped} files (already indexed)`);
|
|
61
|
+
logger.log(` Total in index: ${result.stats.totalDocs} docs`);
|
|
62
|
+
|
|
63
|
+
return { ok: true, ...result };
|
|
64
|
+
}
|
|
65
|
+
|
|
66
|
+
module.exports = { runContextSearch, runContextSearchIndex };
|
|
@@ -0,0 +1,177 @@
|
|
|
1
|
+
'use strict';
|
|
2
|
+
|
|
3
|
+
const fs = require('node:fs/promises');
|
|
4
|
+
const path = require('node:path');
|
|
5
|
+
|
|
6
|
+
const CHARS_PER_TOKEN = 4;
|
|
7
|
+
const LARGE_SECTION_BULLETS = 20; // warn if a section has more than this many bullet lines
|
|
8
|
+
|
|
9
|
+
function estimateTokens(content) {
|
|
10
|
+
return Math.ceil(content.length / CHARS_PER_TOKEN);
|
|
11
|
+
}
|
|
12
|
+
|
|
13
|
+
function formatBytes(bytes) {
|
|
14
|
+
return `${(bytes / 1024).toFixed(1)}KB`;
|
|
15
|
+
}
|
|
16
|
+
|
|
17
|
+
async function loadFeatureStatuses(contextDir) {
|
|
18
|
+
const featuresPath = path.join(contextDir, 'features.md');
|
|
19
|
+
try {
|
|
20
|
+
const content = await fs.readFile(featuresPath, 'utf8');
|
|
21
|
+
const done = new Set();
|
|
22
|
+
for (const line of content.split(/\r?\n/)) {
|
|
23
|
+
const m = line.match(/[-|]\s*([a-z0-9_-]+)\s*[:|]\s*done/i);
|
|
24
|
+
if (m) done.add(m[1].toLowerCase());
|
|
25
|
+
}
|
|
26
|
+
return done;
|
|
27
|
+
} catch {
|
|
28
|
+
return new Set();
|
|
29
|
+
}
|
|
30
|
+
}
|
|
31
|
+
|
|
32
|
+
function findLargeSections(content, fileName) {
|
|
33
|
+
const sections = [];
|
|
34
|
+
const sectionRe = /^#{2,4}\s+(.+)/gm;
|
|
35
|
+
let match;
|
|
36
|
+
const sectionStarts = [];
|
|
37
|
+
|
|
38
|
+
while ((match = sectionRe.exec(content)) !== null) {
|
|
39
|
+
sectionStarts.push({ title: match[1].trim(), start: match.index });
|
|
40
|
+
}
|
|
41
|
+
|
|
42
|
+
for (let i = 0; i < sectionStarts.length; i++) {
|
|
43
|
+
const { title, start } = sectionStarts[i];
|
|
44
|
+
const end = i + 1 < sectionStarts.length ? sectionStarts[i + 1].start : content.length;
|
|
45
|
+
const body = content.slice(start, end);
|
|
46
|
+
const bulletCount = (body.match(/^[-*]\s/gm) || []).length;
|
|
47
|
+
if (bulletCount > LARGE_SECTION_BULLETS) {
|
|
48
|
+
sections.push({
|
|
49
|
+
file: fileName,
|
|
50
|
+
section: title,
|
|
51
|
+
bulletCount,
|
|
52
|
+
sizeBytes: body.length,
|
|
53
|
+
tokens: estimateTokens(body)
|
|
54
|
+
});
|
|
55
|
+
}
|
|
56
|
+
}
|
|
57
|
+
return sections;
|
|
58
|
+
}
|
|
59
|
+
|
|
60
|
+
async function runContextTrim({ args, options = {}, logger }) {
|
|
61
|
+
const targetDir = path.resolve(process.cwd(), args[0] || '.');
|
|
62
|
+
const contextDir = path.join(targetDir, '.aioson', 'context');
|
|
63
|
+
const archiveDir = path.join(contextDir, 'archive');
|
|
64
|
+
const dryRun = options['dry-run'] || options.dryRun || false;
|
|
65
|
+
const force = options.force || false;
|
|
66
|
+
|
|
67
|
+
let entries;
|
|
68
|
+
try {
|
|
69
|
+
entries = await fs.readdir(contextDir);
|
|
70
|
+
} catch {
|
|
71
|
+
if (!options.json) logger.log('No .aioson/context/ directory found.');
|
|
72
|
+
return { ok: false, reason: 'no_context_dir' };
|
|
73
|
+
}
|
|
74
|
+
|
|
75
|
+
const mdFiles = entries.filter((f) => f.endsWith('.md') && f !== 'archive');
|
|
76
|
+
const doneFeatures = await loadFeatureStatuses(contextDir);
|
|
77
|
+
|
|
78
|
+
const staleSpecs = [];
|
|
79
|
+
const largeSections = [];
|
|
80
|
+
|
|
81
|
+
for (const file of mdFiles) {
|
|
82
|
+
// Identify stale specs
|
|
83
|
+
if (file.startsWith('spec-')) {
|
|
84
|
+
const slug = file.replace(/^spec-/, '').replace(/\.md$/, '');
|
|
85
|
+
if (doneFeatures.has(slug)) {
|
|
86
|
+
const stat = await fs.stat(path.join(contextDir, file)).catch(() => null);
|
|
87
|
+
staleSpecs.push({
|
|
88
|
+
file,
|
|
89
|
+
slug,
|
|
90
|
+
sizeBytes: stat ? stat.size : 0
|
|
91
|
+
});
|
|
92
|
+
}
|
|
93
|
+
}
|
|
94
|
+
|
|
95
|
+
// Find large sections in active specs
|
|
96
|
+
if (file.startsWith('spec-') || file === 'spec.md') {
|
|
97
|
+
const content = await fs.readFile(path.join(contextDir, file), 'utf8').catch(() => null);
|
|
98
|
+
if (content) {
|
|
99
|
+
const found = findLargeSections(content, file);
|
|
100
|
+
largeSections.push(...found);
|
|
101
|
+
}
|
|
102
|
+
}
|
|
103
|
+
}
|
|
104
|
+
|
|
105
|
+
const totalStaleSaved = staleSpecs.reduce((s, r) => s + r.sizeBytes, 0);
|
|
106
|
+
|
|
107
|
+
if (options.json) {
|
|
108
|
+
return {
|
|
109
|
+
ok: true,
|
|
110
|
+
staleSpecs,
|
|
111
|
+
largeSections,
|
|
112
|
+
totalStaleSavedBytes: totalStaleSaved,
|
|
113
|
+
dryRun
|
|
114
|
+
};
|
|
115
|
+
}
|
|
116
|
+
|
|
117
|
+
logger.log('Context Trim Analysis');
|
|
118
|
+
logger.log('─'.repeat(50));
|
|
119
|
+
|
|
120
|
+
if (staleSpecs.length === 0 && largeSections.length === 0) {
|
|
121
|
+
logger.log('✓ No stale specs or oversized sections found.');
|
|
122
|
+
logger.log('');
|
|
123
|
+
return { ok: true, staleSpecs: [], largeSections: [], totalStaleSavedBytes: 0, dryRun };
|
|
124
|
+
}
|
|
125
|
+
|
|
126
|
+
if (staleSpecs.length > 0) {
|
|
127
|
+
logger.log(`Stale specs (feature: done):`);
|
|
128
|
+
for (const s of staleSpecs) {
|
|
129
|
+
logger.log(` ${s.file.padEnd(30)} — ${s.slug} is done (${formatBytes(s.sizeBytes)})`);
|
|
130
|
+
}
|
|
131
|
+
if (totalStaleSaved > 0) {
|
|
132
|
+
logger.log(` → Archiving saves ~${formatBytes(totalStaleSaved)} (~${estimateTokens(totalStaleSaved * CHARS_PER_TOKEN)} tokens) per session`);
|
|
133
|
+
}
|
|
134
|
+
logger.log('');
|
|
135
|
+
}
|
|
136
|
+
|
|
137
|
+
if (largeSections.length > 0) {
|
|
138
|
+
logger.log('Large sections in active specs:');
|
|
139
|
+
for (const s of largeSections) {
|
|
140
|
+
logger.log(` ${s.file} § ${s.section} (${s.bulletCount} entries, ${formatBytes(s.sizeBytes)})`);
|
|
141
|
+
logger.log(` → Consider trimming to last ${LARGE_SECTION_BULLETS} entries to save ~${formatBytes(s.sizeBytes - Math.floor(s.sizeBytes * LARGE_SECTION_BULLETS / s.bulletCount))}`);
|
|
142
|
+
}
|
|
143
|
+
logger.log('');
|
|
144
|
+
}
|
|
145
|
+
|
|
146
|
+
// Archive stale specs
|
|
147
|
+
if (staleSpecs.length > 0) {
|
|
148
|
+
if (force || dryRun) {
|
|
149
|
+
if (!dryRun) {
|
|
150
|
+
await fs.mkdir(archiveDir, { recursive: true });
|
|
151
|
+
for (const s of staleSpecs) {
|
|
152
|
+
const src = path.join(contextDir, s.file);
|
|
153
|
+
const dest = path.join(archiveDir, s.file);
|
|
154
|
+
await fs.rename(src, dest);
|
|
155
|
+
logger.log(` Archived: ${s.file} → context/archive/${s.file}`);
|
|
156
|
+
}
|
|
157
|
+
logger.log('');
|
|
158
|
+
logger.log(`${staleSpecs.length} spec(s) archived to .aioson/context/archive/`);
|
|
159
|
+
} else {
|
|
160
|
+
logger.log(`[dry-run] Would archive ${staleSpecs.length} stale spec(s) to .aioson/context/archive/`);
|
|
161
|
+
}
|
|
162
|
+
} else {
|
|
163
|
+
logger.log(`Run with --force to archive stale specs, or --dry-run to preview.`);
|
|
164
|
+
}
|
|
165
|
+
}
|
|
166
|
+
|
|
167
|
+
return {
|
|
168
|
+
ok: true,
|
|
169
|
+
staleSpecs,
|
|
170
|
+
largeSections,
|
|
171
|
+
totalStaleSavedBytes: totalStaleSaved,
|
|
172
|
+
archived: force && !dryRun ? staleSpecs.length : 0,
|
|
173
|
+
dryRun
|
|
174
|
+
};
|
|
175
|
+
}
|
|
176
|
+
|
|
177
|
+
module.exports = { runContextTrim };
|