@zaip-ai/cli 2.2.0 → 3.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/README.md +36 -13
- package/dist/services/adapters.d.ts +1 -1
- package/dist/services/adapters.d.ts.map +1 -1
- package/dist/services/adapters.js +26 -9
- package/dist/services/adapters.js.map +1 -1
- package/dist/services/agent-adapters.js +37 -18
- package/dist/services/agent-adapters.js.map +1 -1
- package/dist/services/agent-discovery.d.ts +27 -0
- package/dist/services/agent-discovery.d.ts.map +1 -0
- package/dist/services/agent-discovery.js +73 -0
- package/dist/services/agent-discovery.js.map +1 -0
- package/dist/services/codex-conversation-lifecycle-hook.d.ts.map +1 -1
- package/dist/services/codex-conversation-lifecycle-hook.js +164 -24
- package/dist/services/codex-conversation-lifecycle-hook.js.map +1 -1
- package/dist/services/codex-pre-tool-hook-template.d.ts.map +1 -1
- package/dist/services/codex-pre-tool-hook-template.js +146 -72
- package/dist/services/codex-pre-tool-hook-template.js.map +1 -1
- package/dist/services/codex-rules.d.ts +1 -1
- package/dist/services/codex-rules.d.ts.map +1 -1
- package/dist/services/codex-rules.js +3 -3
- package/dist/services/codex-subagent-hook-template.d.ts +1 -1
- package/dist/services/codex-subagent-hook-template.d.ts.map +1 -1
- package/dist/services/codex-subagent-hook-template.js +117 -66
- package/dist/services/codex-subagent-hook-template.js.map +1 -1
- package/dist/services/install-agents-template.d.ts.map +1 -1
- package/dist/services/install-agents-template.js +65 -7
- package/dist/services/install-agents-template.js.map +1 -1
- package/dist/services/logger.js +1 -1
- package/dist/services/logger.js.map +1 -1
- package/dist/services/logger.test.js +22 -1
- package/dist/services/logger.test.js.map +1 -1
- package/dist/services/runtime-template.test.js +153 -1
- package/dist/services/runtime-template.test.js.map +1 -1
- package/dist/services/transactional-files.d.ts.map +1 -1
- package/dist/services/transactional-files.js +59 -14
- package/dist/services/transactional-files.js.map +1 -1
- package/package.json +1 -1
- package/templates/.agents/.env.example +9 -3
- package/templates/.agents/README-ENG.md +101 -15
- package/templates/.agents/README.md +102 -17
- package/templates/.agents/architecture/software-architecture.md +1 -59
- package/templates/.agents/branding/brandbook.md +3 -0
- package/templates/.agents/config/agents/catalog.yaml +25 -10
- package/templates/.agents/config/agents/discovery.json +319 -0
- package/templates/.agents/config/clients/codex/agents/zaip-agent-analyst.toml +1 -1
- package/templates/.agents/config/clients/codex/agents/zaip-agent-auditor.toml +1 -1
- package/templates/.agents/config/clients/codex/agents/zaip-agent-backend.toml +3 -3
- package/templates/.agents/config/clients/codex/agents/zaip-agent-brand-strategist.toml +1 -1
- package/templates/.agents/config/clients/codex/agents/zaip-agent-builder.toml +3 -3
- package/templates/.agents/config/clients/codex/agents/zaip-agent-cloud-engineer.toml +12 -9
- package/templates/.agents/config/clients/codex/agents/zaip-agent-data-analyst.toml +1 -1
- package/templates/.agents/config/clients/codex/agents/zaip-agent-designer.toml +3 -3
- package/templates/.agents/config/clients/codex/agents/zaip-agent-finalizer.toml +2 -2
- package/templates/.agents/config/clients/codex/agents/zaip-agent-frontend.toml +3 -3
- package/templates/.agents/config/clients/codex/agents/zaip-agent-general-operations.toml +1 -1
- package/templates/.agents/config/clients/codex/agents/zaip-agent-governance-compliance.toml +1 -1
- package/templates/.agents/config/clients/codex/agents/zaip-agent-growth-strategist.toml +1 -1
- package/templates/.agents/config/clients/codex/agents/zaip-agent-integrator.toml +1 -1
- package/templates/.agents/config/clients/codex/agents/zaip-agent-marketing-analyst.toml +1 -1
- package/templates/.agents/config/clients/codex/agents/zaip-agent-orchestrator.toml +13 -10
- package/templates/.agents/config/clients/codex/agents/zaip-agent-refactoring-specialist.toml +1 -1
- package/templates/.agents/config/clients/codex/agents/zaip-agent-reviewer.toml +1 -1
- package/templates/.agents/config/clients/codex/agents/zaip-agent-sales-specialist.toml +1 -1
- package/templates/.agents/config/clients/codex/agents/zaip-agent-security-auditor.toml +1 -1
- package/templates/.agents/config/clients/codex/agents/zaip-agent-task-executor.toml +3 -3
- package/templates/.agents/config/clients/codex/agents/zaip-agent-website-developer.toml +3 -3
- package/templates/.agents/config/clients/codex/agents/zaip-agent-writer.toml +1 -1
- package/templates/.agents/config/pricing/models.json +9 -5
- package/templates/.agents/config/project.yaml +22 -2
- package/templates/.agents/dashboard/.zaip-managed.json +530 -138
- package/templates/.agents/dashboard/README.md +16 -0
- package/templates/.agents/dashboard/apps/frontend/dist/assets/CostCalculationGuidePage-CEDZjl4V.js +1 -0
- package/templates/.agents/dashboard/apps/frontend/dist/assets/{DashboardHelpDialog-DaSllaJp.js → DashboardHelpDialog-TnrL1ZyZ.js} +967 -578
- package/templates/.agents/dashboard/apps/frontend/dist/assets/PricingSettingsDialog-DjQpBqGU.js +1 -0
- package/templates/.agents/dashboard/apps/frontend/dist/assets/ProjectSettingsPage-B9GWkEyN.css +1 -0
- package/templates/.agents/dashboard/apps/frontend/dist/assets/ProjectSettingsPage-BAvLPAee.js +3 -0
- package/templates/.agents/dashboard/apps/frontend/dist/assets/TraceabilityWorkspace-BQZXUnQu.js +1 -0
- package/templates/.agents/dashboard/apps/frontend/dist/assets/cost-monitor-06__WZco.js +68 -0
- package/templates/.agents/dashboard/apps/frontend/dist/assets/dashboard-localization-Basaw1NR.js +824 -0
- package/templates/.agents/dashboard/apps/frontend/dist/assets/{icons-vendor-TPUT2IUt.js → icons-vendor-DEmo6Tn2.js} +1 -1
- package/templates/.agents/dashboard/apps/frontend/dist/assets/index-BQe3zTvL.js +2 -0
- package/templates/.agents/dashboard/apps/frontend/dist/assets/{react-vendor-Ct48XHGL.js → react-vendor-CadYsm83.js} +1 -1
- package/templates/.agents/dashboard/apps/frontend/dist/assets/rolldown-runtime-Bh1tDfsg.js +1 -0
- package/templates/.agents/dashboard/apps/frontend/dist/assets/traceability-BzKK8kK3.js +1 -0
- package/templates/.agents/dashboard/apps/frontend/dist/index.html +6 -6
- package/templates/.agents/dashboard/apps/frontend/package.json +1 -1
- package/templates/.agents/dashboard/apps/frontend/src/App.tsx +3 -1264
- package/templates/.agents/dashboard/apps/frontend/src/AppDashboardContent.tsx +368 -0
- package/templates/.agents/dashboard/apps/frontend/src/AutonomySettings.tsx +82 -0
- package/templates/.agents/dashboard/apps/frontend/src/ProjectSettingsPage.dom.test.ts +130 -0
- package/templates/.agents/dashboard/apps/frontend/src/ProjectSettingsPage.tsx +206 -157
- package/templates/.agents/dashboard/apps/frontend/src/ProjectStackEditor.tsx +3 -1
- package/templates/.agents/dashboard/apps/frontend/src/__tests__/app-composition-support.ts +12 -0
- package/templates/.agents/dashboard/apps/frontend/src/cost-monitor-population.test.tsx +149 -0
- package/templates/.agents/dashboard/apps/frontend/src/cost-period-refresh.test.ts +9 -7
- package/templates/.agents/dashboard/apps/frontend/src/dashboard-api-settings.ts +152 -0
- package/templates/.agents/dashboard/apps/frontend/src/dashboard-api.test.ts +19 -0
- package/templates/.agents/dashboard/apps/frontend/src/dashboard-api.ts +50 -154
- package/templates/.agents/dashboard/apps/frontend/src/dashboard-app-shell.tsx +33 -0
- package/templates/.agents/dashboard/apps/frontend/src/dashboard-cost-facts.test.ts +54 -0
- package/templates/.agents/dashboard/apps/frontend/src/dashboard-cost-facts.ts +48 -0
- package/templates/.agents/dashboard/apps/frontend/src/dashboard-localization.test.ts +37 -43
- package/templates/.agents/dashboard/apps/frontend/src/dashboard-localization.ts +9 -251
- package/templates/.agents/dashboard/apps/frontend/src/dashboard-project-overview.ts +35 -2
- package/templates/.agents/dashboard/apps/frontend/src/dashboard-retry.ts +17 -0
- package/templates/.agents/dashboard/apps/frontend/src/dashboard-setup-route.ts +29 -0
- package/templates/.agents/dashboard/apps/frontend/src/dashboard-view-actions.test.ts +51 -0
- package/templates/.agents/dashboard/apps/frontend/src/dashboard-view-actions.ts +68 -0
- package/templates/.agents/dashboard/apps/frontend/src/operations-period-render.test.ts +38 -2
- package/templates/.agents/dashboard/apps/frontend/src/operations-period.test.ts +19 -4
- package/templates/.agents/dashboard/apps/frontend/src/operations-period.ts +5 -3
- package/templates/.agents/dashboard/apps/frontend/src/overview-status-page.test.ts +2 -2
- package/templates/.agents/dashboard/apps/frontend/src/project-installation-status.test.ts +137 -0
- package/templates/.agents/dashboard/apps/frontend/src/project-installation-status.ts +66 -0
- package/templates/.agents/dashboard/apps/frontend/src/project-settings-copy.ts +181 -0
- package/templates/.agents/dashboard/apps/frontend/src/project-settings-model.ts +11 -1
- package/templates/.agents/dashboard/apps/frontend/src/project-settings-page.css +102 -51
- package/templates/.agents/dashboard/apps/frontend/src/project-settings-state.css +55 -0
- package/templates/.agents/dashboard/apps/frontend/src/project-settings.test.ts +14 -2
- package/templates/.agents/dashboard/apps/frontend/src/sao-paulo-day-rollover.test.ts +36 -0
- package/templates/.agents/dashboard/apps/frontend/src/sao-paulo-day-rollover.ts +30 -0
- package/templates/.agents/dashboard/apps/frontend/src/snapshot-banner-semantics.test.ts +2 -5
- package/templates/.agents/dashboard/apps/frontend/src/snapshot-coherence.test.ts +31 -20
- package/templates/.agents/dashboard/apps/frontend/src/traceability-task-pagination.ts +1 -2
- package/templates/.agents/dashboard/apps/frontend/src/use-app-cost-loaders.test.ts +6 -0
- package/templates/.agents/dashboard/apps/frontend/src/use-app-cost-loaders.ts +2 -0
- package/templates/.agents/dashboard/apps/frontend/src/use-app-effects.ts +9 -1
- package/templates/.agents/dashboard/apps/frontend/src/use-app-trace-documents.ts +3 -1
- package/templates/.agents/dashboard/apps/frontend/src/use-app-trace-task-pagination.ts +66 -0
- package/templates/.agents/dashboard/apps/frontend/src/use-app-work-board.ts +397 -0
- package/templates/.agents/dashboard/apps/frontend/src/use-dashboard-app-model.tsx +782 -0
- package/templates/.agents/dashboard/apps/frontend/src/use-snapshot-notice.tsx +49 -0
- package/templates/.agents/dashboard/modules/cost-monitor/package.json +1 -1
- package/templates/.agents/dashboard/modules/cost-monitor/src/complete-cost-average.test.ts +73 -0
- package/templates/.agents/dashboard/modules/cost-monitor/src/contracts.ts +9 -0
- package/templates/.agents/dashboard/modules/cost-monitor/src/period-averages.ts +60 -0
- package/templates/.agents/dashboard/modules/cost-monitor/src/react/CostDeveloperPanelSlot.tsx +16 -0
- package/templates/.agents/dashboard/modules/cost-monitor/src/react/CostGroupsTable.tsx +459 -0
- package/templates/.agents/dashboard/modules/cost-monitor/src/react/CostMonitorContent.tsx +8 -22
- package/templates/.agents/dashboard/modules/cost-monitor/src/react/CostMonitorPage.test.ts +27 -17
- package/templates/.agents/dashboard/modules/cost-monitor/src/react/CostMonitorPage.tsx +64 -189
- package/templates/.agents/dashboard/modules/cost-monitor/src/react/CostMonitorRunDialog.tsx +20 -0
- package/templates/.agents/dashboard/modules/cost-monitor/src/react/CostPeriodAverageCards.tsx +32 -8
- package/templates/.agents/dashboard/modules/cost-monitor/src/react/CostTables-hides-calls-that-have-no-collected.test.ts +80 -0
- package/templates/.agents/dashboard/modules/cost-monitor/src/react/CostTables-keeps-legacy-codex-identity-fields-blank.test.ts +455 -0
- package/templates/.agents/dashboard/modules/cost-monitor/src/react/CostTables.test.ts +18 -525
- package/templates/.agents/dashboard/modules/cost-monitor/src/react/CostTables.tsx +32 -508
- package/templates/.agents/dashboard/modules/cost-monitor/src/react/cost-monitor-export-sources.ts +74 -0
- package/templates/.agents/dashboard/modules/cost-monitor/src/react/cost-monitor-page-actions.ts +19 -0
- package/templates/.agents/dashboard/modules/cost-monitor/src/react/cost-monitor-page-selectors.ts +49 -0
- package/templates/.agents/dashboard/modules/cost-monitor/src/react/cost-monitor-summary.ts +3 -2
- package/templates/.agents/dashboard/modules/cost-monitor/src/react/cost-table-formatters.ts +115 -0
- package/templates/.agents/dashboard/modules/cost-monitor/src/react/period-cost-groups.ts +1 -42
- package/templates/.agents/dashboard/modules/cost-monitor/src/react/use-cost-group-page.ts +2 -1
- package/templates/.agents/dashboard/modules/cost-monitor/src/server/build-cost-monitor-projection.test-fixtures.ts +2 -0
- package/templates/.agents/dashboard/modules/cost-monitor/src/server/build-cost-monitor-projection.ts +3 -2
- package/templates/.agents/dashboard/modules/cost-monitor/src/server/build-cost-summary-projection.ts +8 -2
- package/templates/.agents/dashboard/modules/cost-monitor/src/server/index.ts +1 -0
- package/templates/.agents/dashboard/modules/operations/package.json +1 -1
- package/templates/.agents/dashboard/modules/operations/src/contracts.ts +4 -0
- package/templates/.agents/dashboard/modules/operations/src/react/EntityTableBadges.tsx +34 -0
- package/templates/.agents/dashboard/modules/operations/src/react/EntityTables.tsx +8 -38
- package/templates/.agents/dashboard/modules/operations/src/react/OperationsOverview-keeps-structure-classes-mutually-exclusive.test.ts +244 -0
- package/templates/.agents/dashboard/modules/operations/src/react/OperationsOverview.helpers.tsx +66 -3
- package/templates/.agents/dashboard/modules/operations/src/react/OperationsOverview.test.ts +98 -276
- package/templates/.agents/dashboard/modules/operations/src/react/OperationsOverview.tsx +105 -276
- package/templates/.agents/dashboard/modules/operations/src/react/OperationsOverviewCharts.tsx +171 -0
- package/templates/.agents/dashboard/modules/operations/src/react/OperationsOverviewPanels.tsx +64 -0
- package/templates/.agents/dashboard/modules/operations/src/react/OperationsPage.tsx +9 -17
- package/templates/.agents/dashboard/modules/operations/src/react/OperationsPageOverview.tsx +3 -0
- package/templates/.agents/dashboard/modules/operations/src/react/OverviewCostKpi.tsx +46 -0
- package/templates/.agents/dashboard/modules/operations/src/react/PrdDocumentDialog.test.tsx +2 -1
- package/templates/.agents/dashboard/modules/operations/src/react/UnifiedWorkList.test.ts +28 -1
- package/templates/.agents/dashboard/modules/operations/src/react/UnifiedWorkList.tsx +11 -4
- package/templates/.agents/dashboard/modules/operations/src/react/index.ts +1 -0
- package/templates/.agents/dashboard/modules/operations/src/react/manual-work-priority.test.ts +2 -1
- package/templates/.agents/dashboard/modules/operations/src/react/operations-coverage-toast.test.ts +8 -4
- package/templates/.agents/dashboard/modules/operations/src/react/operations-overview-period-filter.test.ts +34 -22
- package/templates/.agents/dashboard/modules/operations/src/react/operations-overview.status-cards.test.ts +3 -1
- package/templates/.agents/dashboard/modules/operations/src/react/operations-page-contract.ts +21 -2
- package/templates/.agents/dashboard/modules/operations/src/react/overview-cost-card.test.tsx +89 -0
- package/templates/.agents/dashboard/modules/operations/src/react/overview-metric-format.ts +32 -0
- package/templates/.agents/dashboard/modules/operations/src/react/work-board-model.test.ts +3 -3
- package/templates/.agents/dashboard/modules/operations/src/work-board-model.ts +2 -1
- package/templates/.agents/dashboard/modules/traceability/package.json +1 -1
- package/templates/.agents/dashboard/packages/branding/package.json +1 -1
- package/templates/.agents/dashboard/packages/branding/src/index.ts +1 -1
- package/templates/.agents/dashboard/packages/contracts/package.json +1 -1
- package/templates/.agents/dashboard/packages/data-export/package.json +1 -1
- package/templates/.agents/dashboard/packages/local-runtime/dist/server.cjs +1625 -1613
- package/templates/.agents/dashboard/packages/local-runtime/dist/sqlite-read-model.cjs +1592 -1582
- package/templates/.agents/dashboard/packages/local-runtime/package.json +3 -2
- package/templates/.agents/dashboard/packages/local-runtime/scripts/build-sqlite-runtime.mjs +22 -28
- package/templates/.agents/dashboard/packages/local-runtime/server.mjs +1625 -1614
- package/templates/.agents/dashboard/packages/local-runtime/src/active-codex-telemetry.ts +25 -0
- package/templates/.agents/dashboard/packages/local-runtime/src/agent-catalog-settings.test.ts +1 -1
- package/templates/.agents/dashboard/packages/local-runtime/src/project-installation-summary.test.ts +142 -0
- package/templates/.agents/dashboard/packages/local-runtime/src/project-installation-summary.ts +190 -0
- package/templates/.agents/dashboard/packages/local-runtime/src/project-settings.test.ts +118 -8
- package/templates/.agents/dashboard/packages/local-runtime/src/project-settings.ts +92 -36
- package/templates/.agents/dashboard/packages/local-runtime/src/projection-refresh-diagnostics.ts +35 -0
- package/templates/.agents/dashboard/packages/local-runtime/src/server-browser-lease.test.ts +91 -0
- package/templates/.agents/dashboard/packages/local-runtime/src/server-browser-lease.ts +24 -4
- package/templates/.agents/dashboard/packages/local-runtime/src/server-costs-routes.ts +168 -0
- package/templates/.agents/dashboard/packages/local-runtime/src/server-dual-reads-manifest-summaries-without-losing.test.ts +344 -0
- package/templates/.agents/dashboard/packages/local-runtime/src/server-hono-security.test.ts +17 -0
- package/templates/.agents/dashboard/packages/local-runtime/src/server-http-contracts.ts +31 -0
- package/templates/.agents/dashboard/packages/local-runtime/src/server-operations-routes.ts +364 -0
- package/templates/.agents/dashboard/packages/local-runtime/src/server-read-projections.ts +461 -0
- package/templates/.agents/dashboard/packages/local-runtime/src/server-reconciliation-refresh.test.ts +78 -0
- package/templates/.agents/dashboard/packages/local-runtime/src/server-route-context.ts +13 -0
- package/templates/.agents/dashboard/packages/local-runtime/src/server-snapshot-refresh.test.ts +94 -2
- package/templates/.agents/dashboard/packages/local-runtime/src/server-snapshot-refresh.ts +62 -12
- package/templates/.agents/dashboard/packages/local-runtime/src/server-snapshot-synchronization.test.ts +44 -0
- package/templates/.agents/dashboard/packages/local-runtime/src/server-snapshot-synchronization.ts +22 -3
- package/templates/.agents/dashboard/packages/local-runtime/src/server-snapshot.test.ts +22 -21
- package/templates/.agents/dashboard/packages/local-runtime/src/server-sqlite-task-trace.test.ts +97 -0
- package/templates/.agents/dashboard/packages/local-runtime/src/server-sqlite-task-trace.ts +10 -13
- package/templates/.agents/dashboard/packages/local-runtime/src/server-sqlite-view-allowlist.test.ts +25 -0
- package/templates/.agents/dashboard/packages/local-runtime/src/server-trace-routes.ts +56 -0
- package/templates/.agents/dashboard/packages/local-runtime/src/server-traceability-index.test.ts +84 -0
- package/templates/.agents/dashboard/packages/local-runtime/src/server-work-reconciliation.test.ts +2 -30
- package/templates/.agents/dashboard/packages/local-runtime/src/server-work-reconciliation.ts +6 -23
- package/templates/.agents/dashboard/packages/local-runtime/src/server.test-fixtures.ts +1 -1
- package/templates/.agents/dashboard/packages/local-runtime/src/server.test.ts +2 -330
- package/templates/.agents/dashboard/packages/local-runtime/src/server.ts +87 -1060
- package/templates/.agents/dashboard/packages/local-runtime/src/sqlite-cost-dimension-facts.test.ts +12 -1
- package/templates/.agents/dashboard/packages/local-runtime/src/sqlite-file-index.test.ts +69 -0
- package/templates/.agents/dashboard/packages/local-runtime/src/sqlite-first-fold-cache.ts +3 -1
- package/templates/.agents/dashboard/packages/local-runtime/src/sqlite-force-canonical.test.ts +3 -1
- package/templates/.agents/dashboard/packages/local-runtime/src/sqlite-incremental-refresh.test.ts +2 -0
- package/templates/.agents/dashboard/packages/local-runtime/src/sqlite-materialize-first-fold.ts +78 -0
- package/templates/.agents/dashboard/packages/local-runtime/src/sqlite-materialize-projections.ts +570 -0
- package/templates/.agents/dashboard/packages/local-runtime/src/sqlite-materialize-runs.ts +600 -0
- package/templates/.agents/dashboard/packages/local-runtime/src/sqlite-metric-contract.test.ts +1 -1
- package/templates/.agents/dashboard/packages/local-runtime/src/sqlite-period-averages.ts +46 -0
- package/templates/.agents/dashboard/packages/local-runtime/src/sqlite-provider-alias-parity.test.ts +50 -0
- package/templates/.agents/dashboard/packages/local-runtime/src/sqlite-query-agent-dimension.ts +269 -0
- package/templates/.agents/dashboard/packages/local-runtime/src/sqlite-query-context.ts +32 -0
- package/templates/.agents/dashboard/packages/local-runtime/src/sqlite-query-entity-group.ts +244 -0
- package/templates/.agents/dashboard/packages/local-runtime/src/sqlite-query-filtered-dimension.ts +303 -0
- package/templates/.agents/dashboard/packages/local-runtime/src/sqlite-query-financial.ts +547 -0
- package/templates/.agents/dashboard/packages/local-runtime/src/sqlite-query-model-dimension.ts +360 -0
- package/templates/.agents/dashboard/packages/local-runtime/src/sqlite-query-provider-dimension.ts +169 -0
- package/templates/.agents/dashboard/packages/local-runtime/src/sqlite-query-summary.ts +493 -0
- package/templates/.agents/dashboard/packages/local-runtime/src/sqlite-query-temporal-dimension.ts +134 -0
- package/templates/.agents/dashboard/packages/local-runtime/src/sqlite-query-timing.ts +299 -0
- package/templates/.agents/dashboard/packages/local-runtime/src/sqlite-query-view-page.ts +692 -0
- package/templates/.agents/dashboard/packages/local-runtime/src/sqlite-read-model-counts-every-root-execution-day-returns.test.ts +763 -0
- package/templates/.agents/dashboard/packages/local-runtime/src/sqlite-read-model-does-not-convert-delayed-historical-finalizer.test.ts +706 -0
- package/templates/.agents/dashboard/packages/local-runtime/src/sqlite-read-model-filesystem.ts +762 -0
- package/templates/.agents/dashboard/packages/local-runtime/src/sqlite-read-model-first-fold-types.ts +1 -1
- package/templates/.agents/dashboard/packages/local-runtime/src/sqlite-read-model-keeps-orphan-telemetry-out-kanban-without.test.ts +710 -0
- package/templates/.agents/dashboard/packages/local-runtime/src/sqlite-read-model-marks-token-cost-telemetry-unavailable-when.test.ts +618 -0
- package/templates/.agents/dashboard/packages/local-runtime/src/sqlite-read-model-rebuild.ts +764 -0
- package/templates/.agents/dashboard/packages/local-runtime/src/sqlite-read-model-rebuilds-disposable-snapshot-serves-zaip-records.test.ts +276 -0
- package/templates/.agents/dashboard/packages/local-runtime/src/sqlite-read-model-schema.ts +193 -0
- package/templates/.agents/dashboard/packages/local-runtime/src/sqlite-read-model-source-fingerprint.test.ts +54 -1
- package/templates/.agents/dashboard/packages/local-runtime/src/sqlite-read-model-source-fingerprint.ts +7 -3
- package/templates/.agents/dashboard/packages/local-runtime/src/sqlite-read-model-types.ts +123 -0
- package/templates/.agents/dashboard/packages/local-runtime/src/sqlite-read-model.test.ts +5 -2806
- package/templates/.agents/dashboard/packages/local-runtime/src/sqlite-read-model.ts +17 -6930
- package/templates/.agents/dashboard/packages/local-runtime/src/sqlite-risk-population.test.ts +98 -0
- package/templates/.agents/dashboard/packages/local-runtime/src/sqlite-schema-base-views.ts +390 -0
- package/templates/.agents/dashboard/packages/local-runtime/src/sqlite-schema-dashboard-views.ts +413 -0
- package/templates/.agents/dashboard/packages/local-runtime/src/sqlite-snapshot-seed.test.ts +2 -0
- package/templates/.agents/dashboard/packages/local-runtime/src/verify-project-settings.mjs +57 -0
- package/templates/.agents/dashboard/packages/local-runtime/src/work-priority-contract.test.ts +4 -3
- package/templates/.agents/dashboard/packages/local-runtime/start-dashboard-build.mjs +195 -0
- package/templates/.agents/dashboard/packages/local-runtime/start-dashboard-lifecycle.test.mjs +2 -7
- package/templates/.agents/dashboard/packages/local-runtime/start-dashboard-logging.mjs +35 -0
- package/templates/.agents/dashboard/packages/local-runtime/start-dashboard-navigation.mjs +114 -0
- package/templates/.agents/dashboard/packages/local-runtime/start-dashboard-paths.mjs +90 -0
- package/templates/.agents/dashboard/packages/local-runtime/start-dashboard.mjs +89 -418
- package/templates/.agents/dashboard/packages/local-runtime/start-dashboard.test.mjs +22 -12
- package/templates/.agents/dashboard/packages/ui/package.json +1 -1
- package/templates/.agents/dashboard/scripts/qualify-observability.mjs +130 -0
- package/templates/.agents/dashboard/scripts/verify-autonomy-settings.mjs +175 -0
- package/templates/.agents/dashboard/scripts/verify-observability.mjs +254 -0
- package/templates/.agents/dashboard/scripts/verify-project-setup.mjs +64 -0
- package/templates/.agents/dashboard/tests/e2e/lease-global-setup.ts +37 -0
- package/templates/.agents/dashboard/tests/e2e/package.json +1 -1
- package/templates/.agents/dashboard/tests/e2e/playwright.config.ts +9 -4
- package/templates/.agents/dashboard/tests/e2e/specs/cost-monitor-period-transition.spec.ts +22 -1
- package/templates/.agents/dashboard/tests/e2e/specs/dashboard-performance-matrix.spec.ts +17 -8
- package/templates/.agents/dashboard/tests/e2e/specs/dashboard.spec.ts +47 -6
- package/templates/.agents/dashboard/tests/e2e/specs/lease-lifetime.spec.ts +14 -0
- package/templates/.agents/dashboard/tests/observability-fixture.mjs +200 -0
- package/templates/.agents/design/.zaip-managed.json +86 -42
- package/templates/.agents/design/DESIGN.md +2 -186
- package/templates/.agents/design/README.md +12 -2
- package/templates/.agents/design/apps/catalog/dist/assets/index-BJV597iq.js +72 -0
- package/templates/.agents/design/apps/catalog/dist/assets/index-BOjCcUaU.js +72 -0
- package/templates/.agents/design/apps/catalog/dist/assets/index-B_WhrCZe.js +72 -0
- package/templates/.agents/design/apps/catalog/dist/assets/index-CqtYXZfV.js +72 -0
- package/templates/.agents/design/apps/catalog/dist/assets/index-D_lfqoyx.js +72 -0
- package/templates/.agents/design/apps/catalog/dist/assets/index-i_PO2k9R.js +9 -0
- package/templates/.agents/design/apps/catalog/dist/index.html +1 -1
- package/templates/.agents/design/apps/catalog/dist/storybook/assets/CatalogShell-Cstn1UwA.js +1 -0
- package/templates/.agents/design/apps/catalog/dist/storybook/assets/{Color-6AOWCN3U-B-kAgAjB.js → Color-6AOWCN3U-Cm-yJJz_.js} +1 -1
- package/templates/.agents/design/apps/catalog/dist/storybook/assets/Components.stories-D1WopB2L.js +137 -0
- package/templates/.agents/design/apps/catalog/dist/storybook/assets/DesignSystem.stories-DQ9PJ3N3.js +1 -0
- package/templates/.agents/design/apps/catalog/dist/storybook/assets/{DocsRenderer-JROSPFPF-BVN7xHtv.js → DocsRenderer-JROSPFPF-Belk4jRr.js} +4 -4
- package/templates/.agents/design/apps/catalog/dist/storybook/assets/{WithTooltip-7X4HQR7L-CDHtKYkz.js → WithTooltip-7X4HQR7L-DoPvjkS1.js} +1 -1
- package/templates/.agents/design/apps/catalog/dist/storybook/assets/{chunk-DRQKCCAG-D6AsDkMK.js → chunk-DRQKCCAG-B1itKXEN.js} +1 -1
- package/templates/.agents/design/apps/catalog/dist/storybook/assets/{chunk-W22LQPXL-B4m5uloN.js → chunk-W22LQPXL-C-Eb5SPY.js} +1 -1
- package/templates/.agents/design/apps/catalog/dist/storybook/assets/{components-CN8YyTUg.js → components-DnyKLwhj.js} +5 -5
- package/templates/.agents/design/apps/catalog/dist/storybook/assets/formatter-L2YTDE3Q-D0OSgxWz.js +1 -0
- package/templates/.agents/design/apps/catalog/dist/storybook/assets/{iframe-9yZfIsdT.js → iframe-DcXBsFPz.js} +3 -3
- package/templates/.agents/design/apps/catalog/dist/storybook/assets/{react-18-BoCSnq6H.js → react-18-CRM89QRf.js} +1 -1
- package/templates/.agents/design/apps/catalog/dist/storybook/assets/react-C3tkVMIp.js +1 -0
- package/templates/.agents/design/apps/catalog/dist/storybook/assets/{syntaxhighlighter-YFXUGROL-Bnn_nMwJ.js → syntaxhighlighter-YFXUGROL-B03jQGTF.js} +1 -1
- package/templates/.agents/design/apps/catalog/dist/storybook/assets/{theming-DS_ue2sb.js → theming-4ZyufAga.js} +1 -1
- package/templates/.agents/design/apps/catalog/dist/storybook/iframe.html +1 -1
- package/templates/.agents/design/apps/catalog/dist/storybook/index.json +1 -1
- package/templates/.agents/design/apps/catalog/package.json +2 -2
- package/templates/.agents/design/apps/catalog/src/components/AutonomySpecimen.tsx +15 -0
- package/templates/.agents/design/apps/catalog/src/components/CostPopulationSpecimen.test.tsx +19 -0
- package/templates/.agents/design/apps/catalog/src/components/CostPopulationSpecimen.tsx +45 -0
- package/templates/.agents/design/apps/catalog/src/components/EstimatedCostSpecimen.tsx +48 -0
- package/templates/.agents/design/apps/catalog/src/components/ProjectStatusSpecimen.tsx +169 -0
- package/templates/.agents/design/apps/catalog/src/pages/ComponentsPage.tsx +55 -0
- package/templates/.agents/design/apps/catalog/src/stories/Components.stories.tsx +60 -0
- package/templates/.agents/design/packages/local-runtime/package.json +1 -1
- package/templates/.agents/growth/strategy.md +3 -0
- package/templates/.agents/marketing/strategy.md +3 -0
- package/templates/.agents/requirements/autonomous-assurance.md +2 -1
- package/templates/.agents/requirements/cloud-hostinger-autonomy.md +1 -1
- package/templates/.agents/requirements/comparative-audit.md +1 -1
- package/templates/.agents/requirements/context-engine.md +1 -1
- package/templates/.agents/requirements/cost-observability.md +1 -1
- package/templates/.agents/requirements/dashboard-launch.md +1 -1
- package/templates/.agents/requirements/data-export.md +1 -1
- package/templates/.agents/requirements/design-system.md +13 -4
- package/templates/.agents/requirements/execution-engine.md +1 -1
- package/templates/.agents/requirements/kanban-dashboard.md +1 -1
- package/templates/.agents/requirements/model-orchestration.md +1 -1
- package/templates/.agents/requirements/public-distribution.md +4 -2
- package/templates/.agents/requirements/software-architecture.md +1 -1
- package/templates/.agents/requirements/strategic-improvements.md +1 -1
- package/templates/.agents/requirements/work-lifecycle.md +6 -6
- package/templates/.agents/requirements/zaip-strategic-95.md +1 -1
- package/templates/.agents/rules/architecture.md +2 -0
- package/templates/.agents/rules/astra-diagnostic.md +3 -1
- package/templates/.agents/rules/autonomy-decision.md +12 -2
- package/templates/.agents/rules/cloud-hostinger-autonomy.md +2 -0
- package/templates/.agents/rules/context.md +2 -1
- package/templates/.agents/rules/core.md +15 -4
- package/templates/.agents/rules/design-system-central-contract.md +17 -0
- package/templates/.agents/rules/evolution.md +3 -1
- package/templates/.agents/rules/frontend-lite.md +3 -1
- package/templates/.agents/rules/local-sqlite-storage.md +2 -2
- package/templates/.agents/rules/meta-mcp.md +3 -1
- package/templates/.agents/rules/model-orchestration.md +1 -1
- package/templates/.agents/rules/run-lifecycle-closure.md +11 -7
- package/templates/.agents/rules/security.md +3 -1
- package/templates/.agents/rules/specialist-routing.md +3 -1
- package/templates/.agents/rules/text-writing-utf8.md +1 -1
- package/templates/.agents/rules/workflow.md +7 -5
- package/templates/.agents/runtime/VERSION +1 -1
- package/templates/.agents/runtime/bin/zaip.mjs +821 -516
- package/templates/.agents/runtime/checksums.sha256 +6 -6
- package/templates/.agents/runtime/manifest.json +1 -1
- package/templates/.agents/runtime/pnpm-lock.sha256 +1 -1
- package/templates/.agents/runtime/provenance.json +5 -5
- package/templates/.agents/runtime/sbom.cdx.json +3 -3
- package/templates/.agents/sales/playbook.md +3 -0
- package/templates/.agents/skills/zaip-aios/SKILL.md +5 -3
- package/templates/.agents/skills/zaip-skill-adapt-stack/SKILL.md +1 -0
- package/templates/.agents/skills/zaip-skill-api-contracts/SKILL.md +14 -0
- package/templates/.agents/skills/zaip-skill-api-contracts/agents/openai.yaml +4 -0
- package/templates/.agents/skills/zaip-skill-application-observability/SKILL.md +15 -0
- package/templates/.agents/skills/zaip-skill-application-observability/agents/openai.yaml +4 -0
- package/templates/.agents/skills/zaip-skill-application-observability/references/signal-design.md +3 -0
- package/templates/.agents/skills/zaip-skill-application-readiness/SKILL.md +15 -0
- package/templates/.agents/skills/zaip-skill-application-readiness/agents/openai.yaml +4 -0
- package/templates/.agents/skills/zaip-skill-application-readiness/references/evidence-matrix.md +3 -0
- package/templates/.agents/skills/zaip-skill-architecture-design/SKILL.md +14 -0
- package/templates/.agents/skills/zaip-skill-architecture-design/agents/openai.yaml +4 -0
- package/templates/.agents/skills/zaip-skill-async-jobs/SKILL.md +14 -0
- package/templates/.agents/skills/zaip-skill-async-jobs/agents/openai.yaml +4 -0
- package/templates/.agents/skills/zaip-skill-auth-tenancy/SKILL.md +15 -0
- package/templates/.agents/skills/zaip-skill-auth-tenancy/agents/openai.yaml +4 -0
- package/templates/.agents/skills/zaip-skill-auth-tenancy/references/data-access-paths.md +9 -0
- package/templates/.agents/skills/zaip-skill-auth-tenancy/references/worker-scenario.md +5 -0
- package/templates/.agents/skills/zaip-skill-auth-tenancy/scripts/worker-contract.test.mjs +27 -0
- package/templates/.agents/skills/zaip-skill-author-skills/SKILL.md +2 -0
- package/templates/.agents/skills/zaip-skill-author-skills/references/engineering-skill-index.md +9 -0
- package/templates/.agents/skills/zaip-skill-author-skills/scripts/audit-skill-catalog.mjs +5 -3
- package/templates/.agents/skills/zaip-skill-author-skills/scripts/author-skill-scripts.test.mjs +27 -0
- package/templates/.agents/skills/zaip-skill-backend/SKILL.md +4 -0
- package/templates/.agents/skills/zaip-skill-backend/references/deployment-environments.md +75 -0
- package/templates/.agents/skills/zaip-skill-backend/references/supabase-migration-contract.md +23 -0
- package/templates/.agents/skills/zaip-skill-brand-governance/SKILL.md +2 -0
- package/templates/.agents/skills/zaip-skill-cache-strategy/SKILL.md +14 -0
- package/templates/.agents/skills/zaip-skill-cache-strategy/agents/openai.yaml +4 -0
- package/templates/.agents/skills/zaip-skill-change/SKILL.md +1 -1
- package/templates/.agents/skills/zaip-skill-cloud-engineering/SKILL.md +7 -0
- package/templates/.agents/skills/zaip-skill-cloudflare-github-deploy/SKILL.md +37 -0
- package/templates/.agents/skills/zaip-skill-cloudflare-github-deploy/agents/openai.yaml +6 -0
- package/templates/.agents/skills/zaip-skill-cloudflare-github-deploy/references/workers-static-assets.md +26 -0
- package/templates/.agents/skills/zaip-skill-cloudflare-github-deploy/references/workflow-templates.md +71 -0
- package/templates/.agents/skills/zaip-skill-cloudflare-github-deploy/scripts/cloudflare-github-deploy-contract.test.mjs +77 -0
- package/templates/.agents/skills/zaip-skill-config/SKILL.md +21 -11
- package/templates/.agents/skills/zaip-skill-config/agents/openai.yaml +2 -2
- package/templates/.agents/skills/zaip-skill-container-runtime/SKILL.md +14 -0
- package/templates/.agents/skills/zaip-skill-container-runtime/agents/openai.yaml +4 -0
- package/templates/.agents/skills/zaip-skill-context/SKILL.md +6 -1
- package/templates/.agents/skills/zaip-skill-context/references/prd-spec-task-handoff.md +10 -0
- package/templates/.agents/skills/zaip-skill-context/references/rule-selection.md +20 -0
- package/templates/.agents/skills/zaip-skill-cqrs/SKILL.md +1 -0
- package/templates/.agents/skills/zaip-skill-cybersecurity/SKILL.md +18 -0
- package/templates/.agents/skills/zaip-skill-cybersecurity/agents/openai.yaml +4 -0
- package/templates/.agents/skills/zaip-skill-cybersecurity/references/audit-contract.md +94 -0
- package/templates/.agents/skills/zaip-skill-cybersecurity/scripts/score-audit.mjs +185 -0
- package/templates/.agents/skills/zaip-skill-cybersecurity/scripts/score-audit.test.mjs +101 -0
- package/templates/.agents/skills/zaip-skill-data-modeling/SKILL.md +14 -0
- package/templates/.agents/skills/zaip-skill-data-modeling/agents/openai.yaml +4 -0
- package/templates/.agents/skills/zaip-skill-database-migrations/SKILL.md +20 -0
- package/templates/.agents/skills/zaip-skill-database-migrations/agents/openai.yaml +4 -0
- package/templates/.agents/skills/zaip-skill-database-migrations/references/manual-mode.md +15 -0
- package/templates/.agents/skills/zaip-skill-database-migrations/references/promotion-example.md +5 -0
- package/templates/.agents/skills/zaip-skill-database-migrations/scripts/export-manual-sql.mjs +145 -0
- package/templates/.agents/skills/zaip-skill-database-migrations/scripts/export-manual-sql.test.mjs +178 -0
- package/templates/.agents/skills/zaip-skill-dependency-upgrade/SKILL.md +14 -0
- package/templates/.agents/skills/zaip-skill-dependency-upgrade/agents/openai.yaml +4 -0
- package/templates/.agents/skills/zaip-skill-deployment-pipeline/SKILL.md +15 -0
- package/templates/.agents/skills/zaip-skill-deployment-pipeline/agents/openai.yaml +4 -0
- package/templates/.agents/skills/zaip-skill-deployment-pipeline/references/runtime-shapes.md +3 -0
- package/templates/.agents/skills/zaip-skill-design-system/SKILL.md +20 -9
- package/templates/.agents/skills/zaip-skill-dev-environment/SKILL.md +16 -0
- package/templates/.agents/skills/zaip-skill-dev-environment/agents/openai.yaml +4 -0
- package/templates/.agents/skills/zaip-skill-dev-environment/references/inventory-contract.md +7 -0
- package/templates/.agents/skills/zaip-skill-dev-environment/scripts/inventory.mjs +77 -0
- package/templates/.agents/skills/zaip-skill-disaster-recovery/SKILL.md +15 -0
- package/templates/.agents/skills/zaip-skill-disaster-recovery/agents/openai.yaml +4 -0
- package/templates/.agents/skills/zaip-skill-disaster-recovery/references/recovery-scope.md +3 -0
- package/templates/.agents/skills/zaip-skill-execution/SKILL.md +31 -8
- package/templates/.agents/skills/zaip-skill-execution/references/correction-cycle.md +7 -0
- package/templates/.agents/skills/zaip-skill-execution/references/runtime-governance.md +18 -8
- package/templates/.agents/skills/zaip-skill-external-integrations/SKILL.md +14 -0
- package/templates/.agents/skills/zaip-skill-external-integrations/agents/openai.yaml +4 -0
- package/templates/.agents/skills/zaip-skill-frontend/SKILL.md +4 -0
- package/templates/.agents/skills/zaip-skill-frontend-componentization/SKILL.md +44 -0
- package/templates/.agents/skills/zaip-skill-frontend-componentization/agents/openai.yaml +4 -0
- package/templates/.agents/skills/zaip-skill-frontend-data-flows/SKILL.md +14 -0
- package/templates/.agents/skills/zaip-skill-frontend-data-flows/agents/openai.yaml +4 -0
- package/templates/.agents/skills/zaip-skill-general-operations/SKILL.md +2 -0
- package/templates/.agents/skills/zaip-skill-github-actions-setup/SKILL.md +36 -0
- package/templates/.agents/skills/zaip-skill-github-actions-setup/agents/openai.yaml +4 -0
- package/templates/.agents/skills/zaip-skill-github-actions-setup/references/cloudflare-pages.md +33 -0
- package/templates/.agents/skills/zaip-skill-github-actions-setup/references/github.md +63 -0
- package/templates/.agents/skills/zaip-skill-github-actions-setup/references/hostinger-vps.md +55 -0
- package/templates/.agents/skills/zaip-skill-github-actions-setup/references/npm.md +30 -0
- package/templates/.agents/skills/zaip-skill-github-actions-setup/scripts/check-skill.mjs +55 -0
- package/templates/.agents/skills/zaip-skill-github-actions-setup/scripts/verify-cloudflare.mjs +61 -0
- package/templates/.agents/skills/zaip-skill-github-actions-setup/scripts/verify-cloudflare.test.mjs +128 -0
- package/templates/.agents/skills/zaip-skill-github-actions-setup/scripts/verify-ssh.integration.test.mjs +106 -0
- package/templates/.agents/skills/zaip-skill-github-deploy/SKILL.md +42 -76
- package/templates/.agents/skills/zaip-skill-github-deploy/references/deployment-workflow.md +135 -0
- package/templates/.agents/skills/zaip-skill-github-deploy/references/github-release-workflow-template.md +31 -0
- package/templates/.agents/skills/zaip-skill-github-deploy/references/release-gate-matrix.md +24 -0
- package/templates/.agents/skills/zaip-skill-github-deploy/references/release-identity.md +44 -0
- package/templates/.agents/skills/zaip-skill-github-deploy/references/release-notes.md +134 -0
- package/templates/.agents/skills/zaip-skill-github-deploy/scripts/consumer-release-preparation.mjs +389 -0
- package/templates/.agents/skills/zaip-skill-github-deploy/scripts/consumer-release-preparation.test.mjs +134 -0
- package/templates/.agents/skills/zaip-skill-github-deploy/scripts/github-deploy-contract.test.mjs +25 -2
- package/templates/.agents/skills/zaip-skill-github-deploy/scripts/github-readiness-api.test.mjs +134 -0
- package/templates/.agents/skills/zaip-skill-github-deploy/scripts/github-readiness.mjs +98 -0
- package/templates/.agents/skills/zaip-skill-github-deploy/scripts/github-readiness.test.mjs +25 -0
- package/templates/.agents/skills/zaip-skill-github-deploy/scripts/install-github-readiness-workflow.mjs +159 -0
- package/templates/.agents/skills/zaip-skill-github-deploy/scripts/install-github-readiness-workflow.test.mjs +160 -0
- package/templates/.agents/skills/zaip-skill-github-deploy/scripts/preflight.mjs +149 -12
- package/templates/.agents/skills/zaip-skill-github-deploy/scripts/preflight.test.mjs +64 -5
- package/templates/.agents/skills/zaip-skill-github-deploy/scripts/release-notes-coverage.test.mjs +126 -0
- package/templates/.agents/skills/zaip-skill-github-deploy/scripts/resolve-release-identity.mjs +78 -0
- package/templates/.agents/skills/zaip-skill-github-deploy/scripts/resolve-release-identity.test.mjs +51 -0
- package/templates/.agents/skills/zaip-skill-github-deploy/scripts/validate-release-notes.mjs +184 -0
- package/templates/.agents/skills/zaip-skill-github-deploy/scripts/validate-release-notes.test.mjs +109 -0
- package/templates/.agents/skills/zaip-skill-growth-strategy-revops/SKILL.md +2 -0
- package/templates/.agents/skills/zaip-skill-hostinger-cloudflare-terraform/SKILL.md +18 -10
- package/templates/.agents/skills/zaip-skill-hostinger-cloudflare-terraform/agents/openai.yaml +3 -4
- package/templates/.agents/skills/zaip-skill-hostinger-cloudflare-terraform/references/aws-cli-terraform.md +62 -0
- package/templates/.agents/skills/zaip-skill-hostinger-cloudflare-terraform/references/guia-iniciante-hostinger-vps.md +183 -0
- package/templates/.agents/skills/zaip-skill-marketing/SKILL.md +2 -0
- package/templates/.agents/skills/zaip-skill-module-scaffold/SKILL.md +14 -0
- package/templates/.agents/skills/zaip-skill-module-scaffold/agents/openai.yaml +4 -0
- package/templates/.agents/skills/zaip-skill-module-scaffold/references/scaffold-contract.md +9 -0
- package/templates/.agents/skills/zaip-skill-module-scaffold/scripts/helpers.test.mjs +121 -0
- package/templates/.agents/skills/zaip-skill-module-scaffold/scripts/scaffold.mjs +169 -0
- package/templates/.agents/skills/zaip-skill-move-prd/SKILL.md +3 -1
- package/templates/.agents/skills/zaip-skill-move-spec/SKILL.md +1 -1
- package/templates/.agents/skills/zaip-skill-performance-engineering/SKILL.md +14 -0
- package/templates/.agents/skills/zaip-skill-performance-engineering/agents/openai.yaml +4 -0
- package/templates/.agents/skills/zaip-skill-prd/SKILL.md +3 -1
- package/templates/.agents/skills/zaip-skill-reconcile-telemetry/scripts/reconcile-local-telemetry.mjs +1 -0
- package/templates/.agents/skills/zaip-skill-reconcile-telemetry/scripts/reconcile-telemetry-lib.mjs +26 -9
- package/templates/.agents/skills/zaip-skill-reconcile-telemetry/scripts/reconcile-telemetry-lib.test.mjs +39 -13
- package/templates/.agents/skills/zaip-skill-reconcile-telemetry/scripts/reconcile-telemetry-remeasurement.mjs +1 -0
- package/templates/.agents/skills/zaip-skill-refactor-landing-page/SKILL.md +66 -0
- package/templates/.agents/skills/zaip-skill-refactor-landing-page/agents/openai.yaml +4 -0
- package/templates/.agents/skills/zaip-skill-refactor-landing-page/references/behavioral-dry-run.md +23 -0
- package/templates/.agents/skills/zaip-skill-release-qualification/SKILL.md +38 -1
- package/templates/.agents/skills/zaip-skill-release-qualification/references/local-preparation.md +122 -0
- package/templates/.agents/skills/zaip-skill-review/SKILL.md +1 -0
- package/templates/.agents/skills/zaip-skill-rules/SKILL.md +3 -3
- package/templates/.agents/skills/zaip-skill-sales-methodology/SKILL.md +2 -0
- package/templates/.agents/skills/zaip-skill-setup/SKILL.md +21 -21
- package/templates/.agents/skills/zaip-skill-setup/agents/openai.yaml +2 -2
- package/templates/.agents/skills/zaip-skill-spec/SKILL.md +3 -2
- package/templates/.agents/skills/zaip-skill-storage-uploads/SKILL.md +14 -0
- package/templates/.agents/skills/zaip-skill-storage-uploads/agents/openai.yaml +4 -0
- package/templates/.agents/skills/zaip-skill-systematic-debugging/SKILL.md +14 -0
- package/templates/.agents/skills/zaip-skill-systematic-debugging/agents/openai.yaml +4 -0
- package/templates/.agents/skills/zaip-skill-task/SKILL.md +16 -7
- package/templates/.agents/skills/zaip-skill-task/references/commit-policy.md +25 -0
- package/templates/.agents/skills/zaip-skill-test-data/SKILL.md +14 -0
- package/templates/.agents/skills/zaip-skill-test-data/agents/openai.yaml +4 -0
- package/templates/.agents/skills/zaip-skill-test-data/scripts/generate.mjs +72 -0
- package/templates/.agents/skills/zaip-skill-testing-strategy/SKILL.md +15 -0
- package/templates/.agents/skills/zaip-skill-testing-strategy/agents/openai.yaml +4 -0
- package/templates/.agents/skills/zaip-skill-testing-strategy/references/example-map.md +3 -0
- package/templates/.agents/skills/zaip-skill-tool-setup/SKILL.md +2 -0
- package/templates/.agents/skills/zaip-skill-website-readiness/SKILL.md +8 -0
- package/templates/.agents/zaip-aios/INDEX.md +9 -1
- package/templates/.agents/zaip-aios/README.md +23 -2
- package/templates/.agents/zaip-aios/VERSION +1 -1
- package/templates/.agents/zaip-aios/guides/01-primeiros-passos.md +5 -1
- package/templates/.agents/zaip-aios/guides/03-tasks.md +15 -2
- package/templates/.agents/zaip-aios/guides/04-specs.md +13 -0
- package/templates/.agents/zaip-aios/guides/05-prds.md +13 -0
- package/templates/.agents/zaip-aios/guides/06-execucao.md +19 -4
- package/templates/.agents/zaip-aios/guides/07-revisao-e-validacao.md +14 -0
- package/templates/.agents/zaip-aios/guides/08-contexto-e-tokens.md +4 -3
- package/templates/.agents/zaip-aios/guides/09-agentes-e-squads.md +17 -9
- package/templates/.agents/zaip-aios/guides/10-seguranca.md +11 -1
- package/templates/.agents/zaip-aios/guides/11-observabilidade-e-custos.md +69 -0
- package/templates/.agents/zaip-aios/guides/12-instalacao-e-upgrade.md +9 -4
- package/templates/.agents/zaip-aios/guides/13-boas-praticas.md +7 -1
- package/templates/.agents/zaip-aios/guides/14-troubleshooting.md +18 -0
- package/templates/.agents/zaip-aios/guides/16-lifecycle-e-reconciliacao.md +54 -3
- package/templates/.agents/zaip-aios/guides/18-catalogo-de-agentes.md +10 -2
- package/templates/.agents/zaip-aios/guides/19-assurance-e-autonomia.md +186 -5
- package/templates/.agents/zaip-aios/guides/20-instalacao-detalhada.md +26 -18
- package/templates/.agents/zaip-aios/guides/21-telemetria-monitor-custos.md +18 -2
- package/templates/.agents/zaip-aios/guides/22-fluxos-e-roteamento.md +14 -2
- package/templates/.agents/zaip-aios/guides/23-orquestracao-de-modelos.md +190 -489
- package/templates/.agents/zaip-aios/guides/26-qualidade-e-release.md +61 -13
- package/templates/.agents/zaip-aios/guides/27-telemetria-git-native.md +18 -0
- package/templates/.agents/zaip-aios/guides/28-lifecycle-completo.md +18 -1
- package/templates/scripts/validate-cloud-hostinger-contract.mjs +34 -0
- package/templates/template-manifest.json +1229 -329
- package/templates/.agents/branding/.gitkeep +0 -0
- package/templates/.agents/dashboard/apps/frontend/dist/assets/CostCalculationGuidePage-snUCQYTC.js +0 -1
- package/templates/.agents/dashboard/apps/frontend/dist/assets/PricingSettingsDialog-BPtVUGgs.js +0 -1
- package/templates/.agents/dashboard/apps/frontend/dist/assets/ProjectSettingsPage-3Awyaovx.js +0 -3
- package/templates/.agents/dashboard/apps/frontend/dist/assets/ProjectSettingsPage-GgzpZ_PY.css +0 -1
- package/templates/.agents/dashboard/apps/frontend/dist/assets/TraceabilityWorkspace-BCvZFMEf.js +0 -1
- package/templates/.agents/dashboard/apps/frontend/dist/assets/cost-monitor-DbaLbU2q.js +0 -68
- package/templates/.agents/dashboard/apps/frontend/dist/assets/dashboard-localization-CLJ0lT9v.js +0 -231
- package/templates/.agents/dashboard/apps/frontend/dist/assets/index-_MEktQNM.js +0 -2
- package/templates/.agents/dashboard/apps/frontend/dist/assets/rolldown-runtime-D9-fqq9M.js +0 -1
- package/templates/.agents/dashboard/apps/frontend/dist/assets/traceability-BDe4_Ubl.js +0 -1
- package/templates/.agents/design/apps/catalog/dist/storybook/assets/CatalogShell-BWY-80s4.js +0 -1
- package/templates/.agents/design/apps/catalog/dist/storybook/assets/Components.stories-Be2mDUQj.js +0 -27
- package/templates/.agents/design/apps/catalog/dist/storybook/assets/DesignSystem.stories-DRx9blDs.js +0 -1
- package/templates/.agents/design/apps/catalog/dist/storybook/assets/formatter-L2YTDE3Q-EwuTh8Zk.js +0 -1
- package/templates/.agents/design/apps/catalog/dist/storybook/assets/react-DyL61NPT.js +0 -1
- package/templates/.agents/growth/.gitkeep +0 -0
- package/templates/.agents/marketing/.gitkeep +0 -0
- package/templates/.agents/sales/.gitkeep +0 -0
|
@@ -0,0 +1,493 @@
|
|
|
1
|
+
import type { CostSummarySource } from "@zaip-ai/dashboard-cost-monitor/server";
|
|
2
|
+
import { artifactStructuralRowsSql } from "./sqlite-artifact-counts.js";
|
|
3
|
+
import type { SqliteQueryContext } from "./sqlite-query-context.js";
|
|
4
|
+
import { costMonitorFilterDay } from "./sqlite-read-model-canonical.js";
|
|
5
|
+
import type { SqliteReadModelFileSystem } from "./sqlite-read-model-filesystem.js";
|
|
6
|
+
export function queryCostMonitorSummaryAggregate(
|
|
7
|
+
context: SqliteQueryContext,
|
|
8
|
+
filter: Parameters<SqliteReadModelFileSystem["activityCostRows"]>[0],
|
|
9
|
+
): CostSummarySource {
|
|
10
|
+
const { from, to, providers = [], models = [] } = filter;
|
|
11
|
+
const sourceFrom = costMonitorFilterDay(from);
|
|
12
|
+
const sourceTo = costMonitorFilterDay(to);
|
|
13
|
+
const cacheKey = JSON.stringify({ ...filter, from: sourceFrom, to: sourceTo });
|
|
14
|
+
const generationCached = context.costMonitorSummaryCache.get(cacheKey);
|
|
15
|
+
if (generationCached !== undefined) return structuredClone(generationCached);
|
|
16
|
+
const remember = (value: CostSummarySource) => {
|
|
17
|
+
if (context.costMonitorSummaryCache.size >= 64) {
|
|
18
|
+
const oldest = context.costMonitorSummaryCache.keys().next().value as string | undefined;
|
|
19
|
+
if (oldest !== undefined) context.costMonitorSummaryCache.delete(oldest);
|
|
20
|
+
}
|
|
21
|
+
context.costMonitorSummaryCache.set(cacheKey, structuredClone(value));
|
|
22
|
+
return structuredClone(value);
|
|
23
|
+
};
|
|
24
|
+
const unfilteredAllTime =
|
|
25
|
+
sourceFrom === null &&
|
|
26
|
+
sourceTo === null &&
|
|
27
|
+
[
|
|
28
|
+
providers,
|
|
29
|
+
models,
|
|
30
|
+
filter.agents,
|
|
31
|
+
filter.phases,
|
|
32
|
+
filter.statuses,
|
|
33
|
+
filter.tasks,
|
|
34
|
+
filter.specs,
|
|
35
|
+
filter.prds,
|
|
36
|
+
filter.executions,
|
|
37
|
+
filter.changes,
|
|
38
|
+
].every((values) => values === undefined || values.length === 0);
|
|
39
|
+
if (unfilteredAllTime) {
|
|
40
|
+
const cached = context.database
|
|
41
|
+
.prepare(
|
|
42
|
+
"SELECT payload_json FROM zaip_aios_activities WHERE payload_type='cost_monitor_summary_cache' ORDER BY recorded_at DESC LIMIT 1",
|
|
43
|
+
)
|
|
44
|
+
.get() as { payload_json?: string } | undefined;
|
|
45
|
+
if (typeof cached?.payload_json === "string")
|
|
46
|
+
return remember(JSON.parse(cached.payload_json) as CostSummarySource);
|
|
47
|
+
}
|
|
48
|
+
if (
|
|
49
|
+
sourceFrom !== null &&
|
|
50
|
+
sourceTo !== null &&
|
|
51
|
+
[
|
|
52
|
+
providers,
|
|
53
|
+
models,
|
|
54
|
+
filter.agents,
|
|
55
|
+
filter.phases,
|
|
56
|
+
filter.statuses,
|
|
57
|
+
filter.tasks,
|
|
58
|
+
filter.specs,
|
|
59
|
+
filter.prds,
|
|
60
|
+
filter.executions,
|
|
61
|
+
filter.changes,
|
|
62
|
+
].every((values) => values === undefined || values.length === 0)
|
|
63
|
+
) {
|
|
64
|
+
const cached = context.database
|
|
65
|
+
.prepare(
|
|
66
|
+
"SELECT payload_json FROM zaip_aios_activities WHERE payload_type='cost_monitor_summary_month_cache' ORDER BY recorded_at DESC LIMIT 1",
|
|
67
|
+
)
|
|
68
|
+
.get() as { payload_json?: string } | undefined;
|
|
69
|
+
if (typeof cached?.payload_json === "string") {
|
|
70
|
+
const payload = JSON.parse(cached.payload_json) as {
|
|
71
|
+
from: string;
|
|
72
|
+
to: string;
|
|
73
|
+
aggregate: CostSummarySource;
|
|
74
|
+
};
|
|
75
|
+
if (payload.from === sourceFrom && payload.to === sourceTo)
|
|
76
|
+
return remember(payload.aggregate);
|
|
77
|
+
}
|
|
78
|
+
}
|
|
79
|
+
const sourceDay =
|
|
80
|
+
"date(COALESCE(a.source_started_at, a.source_occurred_at, a.occurred_at), '-3 hours')";
|
|
81
|
+
const clauses = [
|
|
82
|
+
// Availability affects coverage, not membership. Excluding unknown Runs
|
|
83
|
+
// silently inflated coverage and made Cost Monitor disagree with Operations.
|
|
84
|
+
`(? IS NULL OR ${sourceDay} >= ?)`,
|
|
85
|
+
`(? IS NULL OR ${sourceDay} <= ?)`,
|
|
86
|
+
];
|
|
87
|
+
const values: Array<string | number | null> = [sourceFrom, sourceFrom, sourceTo, sourceTo];
|
|
88
|
+
const add = (column: string, items?: readonly string[]) => {
|
|
89
|
+
if (items === undefined || items.length === 0) return;
|
|
90
|
+
clauses.push(`a.${column} IN (${items.map(() => "?").join(",")})`);
|
|
91
|
+
values.push(...items);
|
|
92
|
+
};
|
|
93
|
+
add("zaip_agent", filter.agents);
|
|
94
|
+
add("phase", filter.phases);
|
|
95
|
+
add("status", filter.statuses);
|
|
96
|
+
add("task_id", filter.tasks);
|
|
97
|
+
add("spec_id", filter.specs);
|
|
98
|
+
add("prd_id", filter.prds);
|
|
99
|
+
add("execution_id", filter.executions);
|
|
100
|
+
add("change_id", filter.changes);
|
|
101
|
+
if (providers.length > 0 || models.length > 0) {
|
|
102
|
+
const usageClauses: string[] = [];
|
|
103
|
+
const directClauses: string[] = [];
|
|
104
|
+
const usageValues: string[] = [];
|
|
105
|
+
const directValues: string[] = [];
|
|
106
|
+
if (providers.length > 0) {
|
|
107
|
+
usageClauses.push(
|
|
108
|
+
`COALESCE(u.provider, 'unavailable') IN (${providers.map(() => "?").join(",")})`,
|
|
109
|
+
);
|
|
110
|
+
directClauses.push(
|
|
111
|
+
`COALESCE(a.provider, 'unavailable') IN (${providers.map(() => "?").join(",")})`,
|
|
112
|
+
);
|
|
113
|
+
usageValues.push(...providers);
|
|
114
|
+
directValues.push(...providers);
|
|
115
|
+
}
|
|
116
|
+
if (models.length > 0) {
|
|
117
|
+
usageClauses.push(`COALESCE(u.model, 'unavailable') IN (${models.map(() => "?").join(",")})`);
|
|
118
|
+
directClauses.push(
|
|
119
|
+
`COALESCE(a.model, 'unavailable') IN (${models.map(() => "?").join(",")})`,
|
|
120
|
+
);
|
|
121
|
+
usageValues.push(...models);
|
|
122
|
+
directValues.push(...models);
|
|
123
|
+
}
|
|
124
|
+
clauses.push(
|
|
125
|
+
`((a.agent_run_id IS NULL AND ${directClauses.join(" AND ")}) OR ` +
|
|
126
|
+
`(a.agent_run_id IS NOT NULL AND a.agent_run_id IN (` +
|
|
127
|
+
`SELECT u.agent_invocation_id FROM invocation_usage u WHERE ${usageClauses.join(" AND ")})))`,
|
|
128
|
+
);
|
|
129
|
+
values.push(...directValues, ...usageValues);
|
|
130
|
+
}
|
|
131
|
+
const selected = `WITH selected AS (
|
|
132
|
+
SELECT ${sourceDay} AS day,
|
|
133
|
+
CASE WHEN a.phase='conversation' THEN 'conversation'
|
|
134
|
+
WHEN a.phase='planning' THEN 'planning' ELSE 'execution' END AS phase_key,
|
|
135
|
+
a.task_id, a.model, a.agent_run_id, a.activity_source_kind, a.work_type AS work_key,
|
|
136
|
+
a.source_event_count AS event_count,
|
|
137
|
+
a.attributed_token_active_ms AS duration_ms,
|
|
138
|
+
a.input_tokens, a.cached_input_tokens, a.output_tokens, a.reasoning_tokens,
|
|
139
|
+
a.total_tokens, a.cost_usd, a.cost_brl
|
|
140
|
+
FROM activities a WHERE ${clauses.join(" AND ")}
|
|
141
|
+
)`;
|
|
142
|
+
const aggregateColumns = `COUNT(*) AS eligible_runs,
|
|
143
|
+
json_group_array(DISTINCT task_id) AS task_ids_json,
|
|
144
|
+
COALESCE(SUM(event_count), 0) AS events,
|
|
145
|
+
SUM(duration_ms) AS duration_ms,
|
|
146
|
+
SUM(input_tokens) AS input_tokens,
|
|
147
|
+
SUM(cached_input_tokens) AS cached_input_tokens,
|
|
148
|
+
SUM(output_tokens) AS output_tokens,
|
|
149
|
+
SUM(reasoning_tokens) AS reasoning_tokens,
|
|
150
|
+
SUM(total_tokens) AS total_tokens,
|
|
151
|
+
SUM(cost_usd) AS cost_usd,
|
|
152
|
+
SUM(cost_brl) AS cost_brl,
|
|
153
|
+
COUNT(duration_ms) AS duration_known,
|
|
154
|
+
COUNT(total_tokens) AS tokens_known,
|
|
155
|
+
COUNT(cost_usd) AS usd_known,
|
|
156
|
+
COUNT(cost_brl) AS brl_known`;
|
|
157
|
+
// SQLite returns at most one aggregate row per day/phase. Node rolls those
|
|
158
|
+
// tiny rows up for the cards and daily table, so the expensive financial
|
|
159
|
+
// population is evaluated once rather than once per dashboard widget.
|
|
160
|
+
const factRows = context.database
|
|
161
|
+
.prepare(`${selected}
|
|
162
|
+
SELECT day, phase_key, work_key, ${aggregateColumns}
|
|
163
|
+
FROM selected GROUP BY day, phase_key, work_key ORDER BY day, phase_key, work_key`)
|
|
164
|
+
.all(...values) as Array<Record<string, unknown>>;
|
|
165
|
+
const nullableColumns = [
|
|
166
|
+
"duration_ms",
|
|
167
|
+
"input_tokens",
|
|
168
|
+
"cached_input_tokens",
|
|
169
|
+
"output_tokens",
|
|
170
|
+
"reasoning_tokens",
|
|
171
|
+
"total_tokens",
|
|
172
|
+
"cost_usd",
|
|
173
|
+
"cost_brl",
|
|
174
|
+
] as const;
|
|
175
|
+
const additiveColumns = [
|
|
176
|
+
"eligible_runs",
|
|
177
|
+
"events",
|
|
178
|
+
"duration_known",
|
|
179
|
+
"tokens_known",
|
|
180
|
+
"usd_known",
|
|
181
|
+
"brl_known",
|
|
182
|
+
] as const;
|
|
183
|
+
const rollup = (key: string, rows: readonly Record<string, unknown>[]) => {
|
|
184
|
+
const result: Record<string, unknown> = { key };
|
|
185
|
+
for (const column of additiveColumns)
|
|
186
|
+
result[column] = rows.reduce(
|
|
187
|
+
(sum, row) => sum + (typeof row[column] === "number" ? Number(row[column]) : 0),
|
|
188
|
+
0,
|
|
189
|
+
);
|
|
190
|
+
for (const column of nullableColumns) {
|
|
191
|
+
const present = rows.filter((row) => typeof row[column] === "number");
|
|
192
|
+
result[column] =
|
|
193
|
+
present.length === 0 ? null : present.reduce((sum, row) => sum + Number(row[column]), 0);
|
|
194
|
+
}
|
|
195
|
+
const taskIds = new Set<string>();
|
|
196
|
+
for (const row of rows) {
|
|
197
|
+
if (typeof row.task_ids_json !== "string") continue;
|
|
198
|
+
for (const value of JSON.parse(row.task_ids_json) as unknown[])
|
|
199
|
+
if (typeof value === "string") taskIds.add(value);
|
|
200
|
+
}
|
|
201
|
+
result.task_count = taskIds.size;
|
|
202
|
+
return result;
|
|
203
|
+
};
|
|
204
|
+
const phaseKeys = ["conversation", "planning", "execution"] as const;
|
|
205
|
+
const phaseRows = phaseKeys.map((key) =>
|
|
206
|
+
rollup(
|
|
207
|
+
key,
|
|
208
|
+
factRows.filter((row) => row.phase_key === key),
|
|
209
|
+
),
|
|
210
|
+
);
|
|
211
|
+
phaseRows.push(rollup("total", factRows));
|
|
212
|
+
const dailyRows = [...new Set(factRows.map((row) => String(row.day)))].map((day) =>
|
|
213
|
+
rollup(
|
|
214
|
+
day,
|
|
215
|
+
factRows.filter((row) => String(row.day) === day),
|
|
216
|
+
),
|
|
217
|
+
);
|
|
218
|
+
const structuralRows = context.database
|
|
219
|
+
.prepare(`WITH canonical_ids AS MATERIALIZED (
|
|
220
|
+
SELECT entity_kind AS kind, id FROM canonical_work_items
|
|
221
|
+
), work_item_days AS (
|
|
222
|
+
SELECT entity_kind AS kind, id, occurred_day_sp AS day FROM canonical_work_items
|
|
223
|
+
WHERE entity_kind <> 'task' OR COALESCE(status, 'draft') <> 'draft'
|
|
224
|
+
UNION ALL
|
|
225
|
+
SELECT 'task', a.task_id, MIN(a.occurred_day_sp) FROM activities a
|
|
226
|
+
LEFT JOIN canonical_ids c ON c.kind='task' AND c.id=a.task_id
|
|
227
|
+
WHERE a.task_id IS NOT NULL AND c.id IS NULL
|
|
228
|
+
GROUP BY a.task_id
|
|
229
|
+
HAVING COALESCE(MAX(a.work_item_status), 'draft') <> 'draft'
|
|
230
|
+
UNION ALL
|
|
231
|
+
SELECT 'spec', a.spec_id, MIN(a.occurred_day_sp) FROM activities a
|
|
232
|
+
LEFT JOIN canonical_ids c ON c.kind='spec' AND c.id=a.spec_id
|
|
233
|
+
WHERE a.spec_id IS NOT NULL AND c.id IS NULL
|
|
234
|
+
GROUP BY a.spec_id
|
|
235
|
+
UNION ALL
|
|
236
|
+
SELECT 'prd', a.prd_id, MIN(a.occurred_day_sp) FROM activities a
|
|
237
|
+
LEFT JOIN canonical_ids c ON c.kind='prd' AND c.id=a.prd_id
|
|
238
|
+
WHERE a.prd_id IS NOT NULL AND c.id IS NULL
|
|
239
|
+
GROUP BY a.prd_id
|
|
240
|
+
), structural AS (
|
|
241
|
+
SELECT day,
|
|
242
|
+
SUM(CASE WHEN kind='prd' THEN 1 ELSE 0 END) AS prd_count,
|
|
243
|
+
SUM(CASE WHEN kind='spec' THEN 1 ELSE 0 END) AS spec_count,
|
|
244
|
+
SUM(CASE WHEN kind='task' THEN 1 ELSE 0 END) AS task_count,
|
|
245
|
+
0 AS validation_count, 0 AS evidence_count
|
|
246
|
+
FROM work_item_days
|
|
247
|
+
WHERE day IS NOT NULL
|
|
248
|
+
AND (? IS NULL OR day >= ?)
|
|
249
|
+
AND (? IS NULL OR day <= ?)
|
|
250
|
+
GROUP BY day
|
|
251
|
+
${artifactStructuralRowsSql()}
|
|
252
|
+
)
|
|
253
|
+
SELECT day,
|
|
254
|
+
SUM(prd_count) AS prd_count,
|
|
255
|
+
SUM(spec_count) AS spec_count,
|
|
256
|
+
SUM(task_count) AS task_count,
|
|
257
|
+
SUM(validation_count) AS validation_count,
|
|
258
|
+
SUM(evidence_count) AS evidence_count
|
|
259
|
+
FROM structural GROUP BY day ORDER BY day`)
|
|
260
|
+
.all(
|
|
261
|
+
sourceFrom,
|
|
262
|
+
sourceFrom,
|
|
263
|
+
sourceTo,
|
|
264
|
+
sourceTo,
|
|
265
|
+
sourceFrom,
|
|
266
|
+
sourceFrom,
|
|
267
|
+
sourceTo,
|
|
268
|
+
sourceTo,
|
|
269
|
+
) as Array<Record<string, unknown>>;
|
|
270
|
+
const number = (value: unknown) => (typeof value === "number" ? value : 0);
|
|
271
|
+
const nullable = (value: unknown) => (typeof value === "number" ? value : null);
|
|
272
|
+
const metric = (row?: Record<string, unknown>) => {
|
|
273
|
+
const eligible = number(row?.eligible_runs);
|
|
274
|
+
return {
|
|
275
|
+
events: number(row?.events),
|
|
276
|
+
duration_ms: nullable(row?.duration_ms),
|
|
277
|
+
tokens: {
|
|
278
|
+
input: nullable(row?.input_tokens),
|
|
279
|
+
cached_input: nullable(row?.cached_input_tokens),
|
|
280
|
+
output: nullable(row?.output_tokens),
|
|
281
|
+
reasoning: nullable(row?.reasoning_tokens),
|
|
282
|
+
total: nullable(row?.total_tokens),
|
|
283
|
+
},
|
|
284
|
+
cost: { usd: nullable(row?.cost_usd), brl: nullable(row?.cost_brl) },
|
|
285
|
+
coverage: {
|
|
286
|
+
events: number(row?.events),
|
|
287
|
+
tokens: number(row?.tokens_known),
|
|
288
|
+
usd: number(row?.usd_known),
|
|
289
|
+
brl: number(row?.brl_known),
|
|
290
|
+
},
|
|
291
|
+
_duration_population: {
|
|
292
|
+
eligible_runs: eligible,
|
|
293
|
+
known_runs: number(row?.duration_known),
|
|
294
|
+
},
|
|
295
|
+
};
|
|
296
|
+
};
|
|
297
|
+
const byKey = new Map(phaseRows.map((row) => [String(row.key), row]));
|
|
298
|
+
const totalRow = byKey.get("total");
|
|
299
|
+
const stripDurationPopulation = (value: ReturnType<typeof metric>) => {
|
|
300
|
+
const { _duration_population: _ignored, ...publicMetric } = value;
|
|
301
|
+
return publicMetric;
|
|
302
|
+
};
|
|
303
|
+
const conversation = stripDurationPopulation(metric(byKey.get("conversation")));
|
|
304
|
+
const planning = stripDurationPopulation(metric(byKey.get("planning")));
|
|
305
|
+
const execution = stripDurationPopulation(metric(byKey.get("execution")));
|
|
306
|
+
const total = stripDurationPopulation(metric(byKey.get("total")));
|
|
307
|
+
const newWork = stripDurationPopulation(
|
|
308
|
+
metric(
|
|
309
|
+
rollup(
|
|
310
|
+
"new",
|
|
311
|
+
factRows.filter((row) => row.work_key === "new"),
|
|
312
|
+
),
|
|
313
|
+
),
|
|
314
|
+
);
|
|
315
|
+
const rework = stripDurationPopulation(
|
|
316
|
+
metric(
|
|
317
|
+
rollup(
|
|
318
|
+
"rework",
|
|
319
|
+
factRows.filter((row) => row.work_key === "rework"),
|
|
320
|
+
),
|
|
321
|
+
),
|
|
322
|
+
);
|
|
323
|
+
const financialByDay = new Map(dailyRows.map((row) => [String(row.key), row]));
|
|
324
|
+
const structuralByDay = new Map(structuralRows.map((row) => [String(row.day), row]));
|
|
325
|
+
const days = [...new Set([...financialByDay.keys(), ...structuralByDay.keys()])].sort();
|
|
326
|
+
const compactDailyRows = days.map((day) => {
|
|
327
|
+
const financial = financialByDay.get(day);
|
|
328
|
+
const structural = structuralByDay.get(day);
|
|
329
|
+
const eligible = number(financial?.eligible_runs);
|
|
330
|
+
const knownDuration = number(financial?.duration_known);
|
|
331
|
+
return {
|
|
332
|
+
key: day,
|
|
333
|
+
prd_count: number(structural?.prd_count),
|
|
334
|
+
spec_count: number(structural?.spec_count),
|
|
335
|
+
task_count: number(structural?.task_count),
|
|
336
|
+
validation_count: number(structural?.validation_count),
|
|
337
|
+
evidence_count: number(structural?.evidence_count),
|
|
338
|
+
total_run_count: eligible,
|
|
339
|
+
total_duration: nullable(financial?.duration_ms),
|
|
340
|
+
duration_known: number(financial?.duration_ms),
|
|
341
|
+
duration_unknown: Math.max(0, eligible - knownDuration),
|
|
342
|
+
total_tokens: nullable(financial?.total_tokens),
|
|
343
|
+
total_cost_usd: nullable(financial?.cost_usd),
|
|
344
|
+
total_cost_brl: nullable(financial?.cost_brl),
|
|
345
|
+
source_event_count: number(financial?.events),
|
|
346
|
+
};
|
|
347
|
+
});
|
|
348
|
+
const periods = Object.fromEntries(
|
|
349
|
+
compactDailyRows.map((row) => {
|
|
350
|
+
const financial = financialByDay.get(row.key);
|
|
351
|
+
const eligible = number(financial?.eligible_runs);
|
|
352
|
+
const tokensKnown = number(financial?.tokens_known);
|
|
353
|
+
const costKnown = number(financial?.brl_known);
|
|
354
|
+
return [
|
|
355
|
+
row.key,
|
|
356
|
+
{
|
|
357
|
+
prds: row.prd_count,
|
|
358
|
+
specs: row.spec_count,
|
|
359
|
+
tasks: row.task_count,
|
|
360
|
+
validations: row.validation_count,
|
|
361
|
+
evidences: row.evidence_count,
|
|
362
|
+
runs: eligible,
|
|
363
|
+
usage: {
|
|
364
|
+
total_tokens: {
|
|
365
|
+
known_sum: number(financial?.total_tokens),
|
|
366
|
+
unknown: eligible - tokensKnown,
|
|
367
|
+
complete: tokensKnown === eligible,
|
|
368
|
+
coverage_ratio: eligible === 0 ? 1 : tokensKnown / eligible,
|
|
369
|
+
},
|
|
370
|
+
cost: {
|
|
371
|
+
known_sum: number(financial?.cost_brl),
|
|
372
|
+
unknown: eligible - costKnown,
|
|
373
|
+
complete: costKnown === eligible,
|
|
374
|
+
coverage_ratio: eligible === 0 ? 1 : costKnown / eligible,
|
|
375
|
+
currency: "BRL" as const,
|
|
376
|
+
},
|
|
377
|
+
},
|
|
378
|
+
events: {
|
|
379
|
+
known_sum: number(financial?.events),
|
|
380
|
+
unknown: 0,
|
|
381
|
+
complete: true,
|
|
382
|
+
coverage_ratio: 1,
|
|
383
|
+
},
|
|
384
|
+
},
|
|
385
|
+
];
|
|
386
|
+
}),
|
|
387
|
+
);
|
|
388
|
+
const durations = Object.fromEntries(
|
|
389
|
+
dailyRows.map((row) => {
|
|
390
|
+
const value = metric(row);
|
|
391
|
+
return [
|
|
392
|
+
String(row.key),
|
|
393
|
+
{
|
|
394
|
+
known_sum: number(row.duration_ms),
|
|
395
|
+
eligible_runs: value._duration_population.eligible_runs,
|
|
396
|
+
known_runs: value._duration_population.known_runs,
|
|
397
|
+
},
|
|
398
|
+
];
|
|
399
|
+
}),
|
|
400
|
+
);
|
|
401
|
+
// Build models from the same selected financial population as the cards,
|
|
402
|
+
// phases and daily rows. Calling the paginated view here was tempting but
|
|
403
|
+
// silently loses multi-value and lineage filters (Task/SPEC/PRD/etc.).
|
|
404
|
+
// This remains one bounded SQL aggregate, without transporting Runs.
|
|
405
|
+
const summaryModelRows = context.database
|
|
406
|
+
.prepare(`${selected},
|
|
407
|
+
segment_totals AS (
|
|
408
|
+
SELECT agent_invocation_id, SUM(total_tokens) AS total_tokens,
|
|
409
|
+
SUM(cost_usd) AS cost_usd, SUM(cost_brl) AS cost_brl
|
|
410
|
+
FROM cost_invocation_dimension_facts
|
|
411
|
+
WHERE total_tokens IS NOT NULL OR cost_usd IS NOT NULL OR cost_brl IS NOT NULL
|
|
412
|
+
GROUP BY agent_invocation_id
|
|
413
|
+
), components AS (
|
|
414
|
+
-- Agent facts can contain several observed models. Attribute their
|
|
415
|
+
-- financial components to the model segment, never to a mixed parent.
|
|
416
|
+
SELECT CASE WHEN f.model IS NULL OR trim(f.model) = '' OR lower(f.model) IN ('unavailable', 'unknown', 'mixed')
|
|
417
|
+
THEN 'unavailable' ELSE f.model END AS key,
|
|
418
|
+
SUM(f.total_tokens) AS total_tokens, SUM(f.cost_usd) AS total_cost_usd,
|
|
419
|
+
SUM(f.cost_brl) AS total_cost_brl
|
|
420
|
+
FROM selected s JOIN cost_invocation_dimension_facts f
|
|
421
|
+
ON f.agent_invocation_id=s.agent_run_id
|
|
422
|
+
WHERE s.agent_run_id IS NOT NULL
|
|
423
|
+
GROUP BY key
|
|
424
|
+
UNION ALL
|
|
425
|
+
-- Non-agent financial facts have no invocation segments, so their
|
|
426
|
+
-- observed model remains the only factual dimension.
|
|
427
|
+
SELECT CASE WHEN model IS NULL OR trim(model) = '' OR lower(model) IN ('unavailable', 'unknown', 'mixed')
|
|
428
|
+
THEN 'unavailable' ELSE model END AS key,
|
|
429
|
+
SUM(total_tokens), SUM(cost_usd), SUM(cost_brl)
|
|
430
|
+
FROM selected WHERE agent_run_id IS NULL GROUP BY key
|
|
431
|
+
UNION ALL
|
|
432
|
+
-- Preserve any consolidated invocation remainder as Sem dimensão so
|
|
433
|
+
-- the model chart reconciles to the same financial population.
|
|
434
|
+
SELECT 'unavailable' AS key,
|
|
435
|
+
SUM(s.total_tokens - COALESCE(st.total_tokens, 0)),
|
|
436
|
+
SUM(s.cost_usd - COALESCE(st.cost_usd, 0)),
|
|
437
|
+
SUM(s.cost_brl - COALESCE(st.cost_brl, 0))
|
|
438
|
+
FROM selected s LEFT JOIN segment_totals st ON st.agent_invocation_id=s.agent_run_id
|
|
439
|
+
WHERE s.agent_run_id IS NOT NULL
|
|
440
|
+
AND (s.total_tokens <> COALESCE(st.total_tokens, 0)
|
|
441
|
+
OR s.cost_usd <> COALESCE(st.cost_usd, 0)
|
|
442
|
+
OR s.cost_brl <> COALESCE(st.cost_brl, 0))
|
|
443
|
+
)
|
|
444
|
+
SELECT key, 0 AS invocation_count, NULL AS task_count,
|
|
445
|
+
NULL AS total_duration, 0 AS duration_unknown, 0 AS duration_known,
|
|
446
|
+
0 AS source_event_count, SUM(total_tokens) AS total_tokens,
|
|
447
|
+
SUM(total_cost_usd) AS total_cost_usd, SUM(total_cost_brl) AS total_cost_brl
|
|
448
|
+
FROM components GROUP BY key ORDER BY total_cost_brl DESC, key`)
|
|
449
|
+
.all(...values) as Array<Record<string, unknown>>;
|
|
450
|
+
const model_groups = summaryModelRows.map((row) => {
|
|
451
|
+
const duration = nullable(row.total_duration);
|
|
452
|
+
const durationUnknown = number(row.duration_unknown);
|
|
453
|
+
const durationKnown = nullable(row.duration_known) ?? duration ?? 0;
|
|
454
|
+
return {
|
|
455
|
+
key: String(row.key ?? "unavailable"),
|
|
456
|
+
label: String(row.label ?? row.key ?? "unavailable"),
|
|
457
|
+
latest_started_at: "",
|
|
458
|
+
run_count: number(row.invocation_count),
|
|
459
|
+
task_count: nullable(row.task_count),
|
|
460
|
+
prd_count: 0,
|
|
461
|
+
spec_count: 0,
|
|
462
|
+
evidence_count: 0,
|
|
463
|
+
test_count: 0,
|
|
464
|
+
event_count: number(row.source_event_count),
|
|
465
|
+
total_tokens: nullable(row.total_tokens),
|
|
466
|
+
estimated_usd: nullable(row.total_cost_usd),
|
|
467
|
+
estimated_brl: nullable(row.total_cost_brl),
|
|
468
|
+
duration_ms: duration,
|
|
469
|
+
duration: {
|
|
470
|
+
known_sum: durationKnown,
|
|
471
|
+
unknown: durationUnknown,
|
|
472
|
+
complete: durationUnknown === 0,
|
|
473
|
+
coverage_ratio: durationUnknown === 0 ? 1 : 0,
|
|
474
|
+
},
|
|
475
|
+
coverage: { events: 0, tokens: 0, usd: 0, brl: 0 },
|
|
476
|
+
};
|
|
477
|
+
});
|
|
478
|
+
return remember({
|
|
479
|
+
periods: { daily: periods },
|
|
480
|
+
aggregate_usage: {
|
|
481
|
+
conversation,
|
|
482
|
+
planning,
|
|
483
|
+
execution,
|
|
484
|
+
total,
|
|
485
|
+
new_work: newWork,
|
|
486
|
+
rework,
|
|
487
|
+
},
|
|
488
|
+
task_count: number(totalRow?.task_count),
|
|
489
|
+
model_groups,
|
|
490
|
+
cost_monitor_daily_duration: durations,
|
|
491
|
+
daily_rows: compactDailyRows,
|
|
492
|
+
});
|
|
493
|
+
}
|
package/templates/.agents/dashboard/packages/local-runtime/src/sqlite-query-temporal-dimension.ts
ADDED
|
@@ -0,0 +1,134 @@
|
|
|
1
|
+
import { sqlitePeriodAverages } from "./sqlite-period-averages.js";
|
|
2
|
+
import type { SqliteQueryContext, SqliteViewInput } from "./sqlite-query-context.js";
|
|
3
|
+
import { costMonitorFilterDay } from "./sqlite-read-model-canonical.js";
|
|
4
|
+
import type { SqliteViewName } from "./sqlite-read-model-types.js";
|
|
5
|
+
export function readTemporalDimension(
|
|
6
|
+
context: SqliteQueryContext,
|
|
7
|
+
view: SqliteViewName,
|
|
8
|
+
input: SqliteViewInput,
|
|
9
|
+
filteredCostGroup: "day" | "month" | "year",
|
|
10
|
+
) {
|
|
11
|
+
const from = costMonitorFilterDay(input.from);
|
|
12
|
+
const to = costMonitorFilterDay(input.to);
|
|
13
|
+
const aggregate = context.costMonitorSummaryAggregate({ from, to });
|
|
14
|
+
const financialRows = aggregate.daily_rows as Array<Record<string, unknown>>;
|
|
15
|
+
const financialByDay = new Map(financialRows.map((row) => [String(row.key), row]));
|
|
16
|
+
const days = [...financialByDay.keys()].sort();
|
|
17
|
+
const grouped = new Map<string, Record<string, unknown>>();
|
|
18
|
+
const additive = [
|
|
19
|
+
// These fields exist only in the unfiltered temporal daily cache. Do
|
|
20
|
+
// not add them to the dimensional invocation grouping below: its
|
|
21
|
+
// source cannot establish canonical lifecycle attribution.
|
|
22
|
+
"prd_count",
|
|
23
|
+
"spec_count",
|
|
24
|
+
"task_count",
|
|
25
|
+
"validation_count",
|
|
26
|
+
"evidence_count",
|
|
27
|
+
"total_run_count",
|
|
28
|
+
"invocation_count",
|
|
29
|
+
"cost_monitor_invocation_count",
|
|
30
|
+
"llm_call_count",
|
|
31
|
+
"source_event_count",
|
|
32
|
+
"total_tokens",
|
|
33
|
+
"total_cost_usd",
|
|
34
|
+
"total_cost_brl",
|
|
35
|
+
] as const;
|
|
36
|
+
for (const day of days) {
|
|
37
|
+
const key =
|
|
38
|
+
filteredCostGroup === "day"
|
|
39
|
+
? day
|
|
40
|
+
: filteredCostGroup === "month"
|
|
41
|
+
? day.slice(0, 7)
|
|
42
|
+
: day.slice(0, 4);
|
|
43
|
+
const target = grouped.get(key) ?? {
|
|
44
|
+
key,
|
|
45
|
+
label: key,
|
|
46
|
+
period_key: key,
|
|
47
|
+
start_day: day,
|
|
48
|
+
end_day: day,
|
|
49
|
+
total_duration: null,
|
|
50
|
+
duration_incomplete: false,
|
|
51
|
+
duration_provenance: "unavailable",
|
|
52
|
+
estimation_basis: null,
|
|
53
|
+
};
|
|
54
|
+
target.start_day = String(target.start_day) < day ? target.start_day : day;
|
|
55
|
+
target.end_day = String(target.end_day) > day ? target.end_day : day;
|
|
56
|
+
const financial = financialByDay.get(day);
|
|
57
|
+
for (const column of additive) {
|
|
58
|
+
const value = financial?.[column];
|
|
59
|
+
if (typeof value === "number")
|
|
60
|
+
target[column] = (typeof target[column] === "number" ? Number(target[column]) : 0) + value;
|
|
61
|
+
}
|
|
62
|
+
const duration = financial?.total_duration;
|
|
63
|
+
if (typeof duration === "number") {
|
|
64
|
+
target.total_duration =
|
|
65
|
+
(typeof target.total_duration === "number" ? Number(target.total_duration) : 0) + duration;
|
|
66
|
+
}
|
|
67
|
+
if (typeof financial?.duration_unknown === "number" && financial.duration_unknown > 0)
|
|
68
|
+
target.duration_incomplete = true;
|
|
69
|
+
grouped.set(key, target);
|
|
70
|
+
}
|
|
71
|
+
const query = input.query?.toLocaleLowerCase() ?? null;
|
|
72
|
+
const allRows = [...grouped.values()]
|
|
73
|
+
.map<Record<string, unknown>>((row) => {
|
|
74
|
+
// Coverage remains explicit on the row; it must not erase a
|
|
75
|
+
// calculable shared temporal total from the visible Cost table.
|
|
76
|
+
const factual = typeof row.total_duration === "number" ? row.total_duration : null;
|
|
77
|
+
const durationUnknown = row.duration_incomplete === true ? 1 : 0;
|
|
78
|
+
return {
|
|
79
|
+
// Daily first fold is an allowlisted table contract. Do not leak
|
|
80
|
+
// cache fields, technical payload columns, or unused aggregates.
|
|
81
|
+
key: String(row.key),
|
|
82
|
+
label: String(row.label),
|
|
83
|
+
prd_count: Number(row.prd_count ?? 0),
|
|
84
|
+
spec_count: Number(row.spec_count ?? 0),
|
|
85
|
+
task_count: Number(row.task_count ?? 0),
|
|
86
|
+
total_run_count: Number(row.total_run_count ?? 0),
|
|
87
|
+
validation_count: Number(row.validation_count ?? 0),
|
|
88
|
+
evidence_count: Number(row.evidence_count ?? 0),
|
|
89
|
+
total_duration: factual,
|
|
90
|
+
duration_known: factual ?? 0,
|
|
91
|
+
duration_unknown: durationUnknown,
|
|
92
|
+
total_tokens: typeof row.total_tokens === "number" ? row.total_tokens : null,
|
|
93
|
+
total_cost_usd: typeof row.total_cost_usd === "number" ? row.total_cost_usd : null,
|
|
94
|
+
total_cost_brl: typeof row.total_cost_brl === "number" ? row.total_cost_brl : null,
|
|
95
|
+
};
|
|
96
|
+
})
|
|
97
|
+
.filter((row) => query === null || String(row.key).toLocaleLowerCase().includes(query))
|
|
98
|
+
.sort((left, right) => String(right.key).localeCompare(String(left.key)));
|
|
99
|
+
const totals = allRows.reduce<Record<string, number | null>>((result, row) => {
|
|
100
|
+
for (const key of [
|
|
101
|
+
"prd_count",
|
|
102
|
+
"spec_count",
|
|
103
|
+
"task_count",
|
|
104
|
+
"total_run_count",
|
|
105
|
+
"validation_count",
|
|
106
|
+
"evidence_count",
|
|
107
|
+
"total_duration",
|
|
108
|
+
"duration_known",
|
|
109
|
+
"duration_unknown",
|
|
110
|
+
"total_tokens",
|
|
111
|
+
"total_cost_usd",
|
|
112
|
+
"total_cost_brl",
|
|
113
|
+
] as const) {
|
|
114
|
+
const value = row[key];
|
|
115
|
+
if (typeof value === "number") result[key] = (result[key] ?? 0) + value;
|
|
116
|
+
else if (!(key in result)) result[key] = null;
|
|
117
|
+
}
|
|
118
|
+
return result;
|
|
119
|
+
}, {});
|
|
120
|
+
const limit = Math.min(200, Math.max(1, input.limit ?? 50));
|
|
121
|
+
const offset = Math.max(0, input.offset ?? 0);
|
|
122
|
+
const rows = allRows.slice(offset, offset + limit);
|
|
123
|
+
return {
|
|
124
|
+
data_source: "sqlite_read_model" as const,
|
|
125
|
+
view,
|
|
126
|
+
offset,
|
|
127
|
+
limit,
|
|
128
|
+
total_count: allRows.length,
|
|
129
|
+
has_more: offset + rows.length < allRows.length,
|
|
130
|
+
totals,
|
|
131
|
+
period_averages: sqlitePeriodAverages(allRows),
|
|
132
|
+
rows,
|
|
133
|
+
};
|
|
134
|
+
}
|