@zaip-ai/cli 1.0.7 → 1.0.8
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 +6 -4
- package/dist/services/adapters.d.ts +1 -1
- package/dist/services/adapters.d.ts.map +1 -1
- package/dist/services/adapters.js +15 -5
- package/dist/services/adapters.js.map +1 -1
- package/dist/services/adapters.test.js +1 -1
- package/dist/services/agent-adapters.d.ts +9 -0
- package/dist/services/agent-adapters.d.ts.map +1 -1
- package/dist/services/agent-adapters.js +38 -3
- package/dist/services/agent-adapters.js.map +1 -1
- package/dist/services/agent-adapters.test.js +8 -1
- package/dist/services/agent-adapters.test.js.map +1 -1
- package/dist/services/codex-config-template.d.ts +2 -1
- package/dist/services/codex-config-template.d.ts.map +1 -1
- package/dist/services/codex-config-template.js +13 -2
- package/dist/services/codex-config-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 +31 -7
- package/dist/services/codex-rules.js.map +1 -1
- 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 +4 -1
- package/dist/services/codex-subagent-hook-template.js.map +1 -1
- package/dist/services/doctor.d.ts.map +1 -1
- package/dist/services/doctor.js +3 -1
- package/dist/services/doctor.js.map +1 -1
- package/dist/services/global-codex-config.d.ts +6 -3
- package/dist/services/global-codex-config.d.ts.map +1 -1
- package/dist/services/global-codex-config.js +82 -13
- package/dist/services/global-codex-config.js.map +1 -1
- package/dist/services/global-codex-config.test.js +57 -10
- package/dist/services/global-codex-config.test.js.map +1 -1
- package/dist/services/install-agents-template.d.ts.map +1 -1
- package/dist/services/install-agents-template.js +15 -2
- 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 +3 -3
- package/dist/services/logger.test.js.map +1 -1
- package/dist/services/runtime-template.test.js +21 -5
- package/dist/services/runtime-template.test.js.map +1 -1
- package/dist/services/template-manifest.d.ts.map +1 -1
- package/dist/services/template-manifest.js +2 -0
- package/dist/services/template-manifest.js.map +1 -1
- package/package.json +1 -1
- package/templates/.agents/config/agents/catalog.yaml +310 -10
- package/templates/.agents/config/clients/codex/agents/zaip-agent-brand-strategist.toml +30 -0
- package/templates/.agents/config/clients/codex/agents/zaip-agent-designer.toml +5 -5
- package/templates/.agents/config/clients/codex/agents/zaip-agent-finalizer.toml +1 -1
- package/templates/.agents/config/clients/codex/agents/zaip-agent-general-operations.toml +30 -0
- package/templates/.agents/config/clients/codex/agents/zaip-agent-governance-compliance.toml +30 -0
- package/templates/.agents/config/clients/codex/agents/zaip-agent-growth-strategist.toml +30 -0
- package/templates/.agents/config/clients/codex/agents/zaip-agent-marketing-analyst.toml +8 -8
- package/templates/.agents/config/clients/codex/agents/zaip-agent-orchestrator.toml +5 -3
- package/templates/.agents/config/clients/codex/agents/zaip-agent-sales-specialist.toml +30 -0
- package/templates/.agents/config/project.yaml +1 -1
- package/templates/.agents/dashboard/.zaip-managed.json +659 -163
- package/templates/.agents/dashboard/DATA-DICTIONARY.md +2227 -0
- package/templates/.agents/dashboard/README.md +48 -97
- package/templates/.agents/dashboard/apps/frontend/dist/assets/CostCalculationGuidePage-Z60df2r-.js +1 -0
- package/templates/.agents/dashboard/apps/frontend/dist/assets/{DashboardHelpDialog-Cv-JcoxP.js → DashboardHelpDialog-Cs6dzDmW.js} +294 -109
- package/templates/.agents/dashboard/apps/frontend/dist/assets/PricingSettingsDialog-Coc6pA-1.js +1 -0
- package/templates/.agents/dashboard/apps/frontend/dist/assets/ProjectSettingsPage-QE1k9yZB.css +1 -0
- package/templates/.agents/dashboard/apps/frontend/dist/assets/ProjectSettingsPage-_Pf5DA_A.js +3 -0
- package/templates/.agents/dashboard/apps/frontend/dist/assets/TraceabilityWorkspace-BVlz3DLZ.js +1 -0
- package/templates/.agents/dashboard/apps/frontend/dist/assets/TraceabilityWorkspace-CaKwQP43.css +1 -0
- package/templates/.agents/dashboard/apps/frontend/dist/assets/cost-monitor-BZ5WdaMN.css +1 -0
- package/templates/.agents/dashboard/apps/frontend/dist/assets/cost-monitor-Cf9ctPVt.js +68 -0
- package/templates/.agents/dashboard/apps/frontend/dist/assets/{dashboard-localization-C98LGC-Q.js → dashboard-localization-CLJ0lT9v.js} +1 -1
- package/templates/.agents/dashboard/apps/frontend/dist/assets/icons-vendor-DFBuc_qp.js +1 -0
- package/templates/.agents/dashboard/apps/frontend/dist/assets/index-8A4DcNXM.js +2 -0
- package/templates/.agents/dashboard/apps/frontend/dist/assets/index-DK_enB5Z.css +1 -0
- package/templates/.agents/dashboard/apps/frontend/dist/assets/react-vendor-CCQOHdVI.js +9 -0
- package/templates/.agents/dashboard/apps/frontend/dist/assets/rolldown-runtime-D9-fqq9M.js +1 -0
- package/templates/.agents/dashboard/apps/frontend/dist/assets/traceability-DFY7ZDlu.css +1 -0
- package/templates/.agents/dashboard/apps/frontend/dist/assets/traceability-pC2_0J8x.js +1 -0
- package/templates/.agents/dashboard/apps/frontend/dist/index.html +9 -2
- package/templates/.agents/dashboard/apps/frontend/package.json +1 -1
- package/templates/.agents/dashboard/apps/frontend/src/App.tsx +952 -595
- package/templates/.agents/dashboard/apps/frontend/src/AppLoadingBoundary.tsx +48 -0
- package/templates/.agents/dashboard/apps/frontend/src/AppLoadingPanels.tsx +2 -0
- package/templates/.agents/dashboard/apps/frontend/src/AppOverlays.tsx +247 -0
- package/templates/.agents/dashboard/apps/frontend/src/AppRequestGuards.tsx +95 -0
- package/templates/.agents/dashboard/apps/frontend/src/AppSetupRoutes.tsx +87 -0
- package/templates/.agents/dashboard/apps/frontend/src/CostCalculationGuidePage.tsx +641 -0
- package/templates/.agents/dashboard/apps/frontend/src/DashboardAlternateContent.tsx +159 -0
- package/templates/.agents/dashboard/apps/frontend/src/DashboardCapabilityNav.tsx +13 -13
- package/templates/.agents/dashboard/apps/frontend/src/DashboardGlobalSettings.tsx +56 -0
- package/templates/.agents/dashboard/apps/frontend/src/ProjectSettingsPage.tsx +257 -313
- package/templates/.agents/dashboard/apps/frontend/src/ProjectStackEditor.tsx +149 -0
- package/templates/.agents/dashboard/apps/frontend/src/TraceabilityWorkspace.test.ts +35 -0
- package/templates/.agents/dashboard/apps/frontend/src/TraceabilityWorkspace.tsx +111 -12
- package/templates/.agents/dashboard/apps/frontend/src/app-preferences.ts +15 -0
- package/templates/.agents/dashboard/apps/frontend/src/app-session-token.ts +20 -0
- package/templates/.agents/dashboard/apps/frontend/src/cost-calculation-guide.css +267 -0
- package/templates/.agents/dashboard/apps/frontend/src/cost-calculation-guide.test.ts +69 -0
- package/templates/.agents/dashboard/apps/frontend/src/cost-period-refresh.test.ts +70 -0
- package/templates/.agents/dashboard/apps/frontend/src/dashboard-api.test.ts +111 -0
- package/templates/.agents/dashboard/apps/frontend/src/dashboard-api.ts +432 -13
- package/templates/.agents/dashboard/apps/frontend/src/dashboard-localization.ts +1 -1
- package/templates/.agents/dashboard/apps/frontend/src/main.tsx +1 -0
- package/templates/.agents/dashboard/apps/frontend/src/operations-detail-hydration.test.ts +55 -0
- package/templates/.agents/dashboard/apps/frontend/src/operations-detail-hydration.ts +36 -0
- package/templates/.agents/dashboard/apps/frontend/src/operations-entity-page-projection.test.ts +126 -0
- package/templates/.agents/dashboard/apps/frontend/src/operations-entity-page-projection.ts +181 -0
- package/templates/.agents/dashboard/apps/frontend/src/operations-period-contract.test.ts +138 -0
- package/templates/.agents/dashboard/apps/frontend/src/operations-period-render.test.ts +105 -0
- package/templates/.agents/dashboard/apps/frontend/src/operations-period.test.ts +6 -3
- package/templates/.agents/dashboard/apps/frontend/src/operations-period.ts +9 -5
- package/templates/.agents/dashboard/apps/frontend/src/overview-status-page.test.ts +24 -0
- package/templates/.agents/dashboard/apps/frontend/src/period-transition-overlay.css +44 -0
- package/templates/.agents/dashboard/apps/frontend/src/project-settings-model.ts +121 -62
- package/templates/.agents/dashboard/apps/frontend/src/project-settings-page.css +471 -2
- package/templates/.agents/dashboard/apps/frontend/src/project-settings.test.ts +84 -17
- package/templates/.agents/dashboard/apps/frontend/src/snapshot-banner-semantics.test.ts +44 -0
- package/templates/.agents/dashboard/apps/frontend/src/snapshot-coherence.test.ts +196 -39
- package/templates/.agents/dashboard/apps/frontend/src/snapshot-notice.ts +15 -0
- package/templates/.agents/dashboard/apps/frontend/src/sqlite-cost-adapters.ts +26 -0
- package/templates/.agents/dashboard/apps/frontend/src/styles.css +14 -2
- package/templates/.agents/dashboard/apps/frontend/src/traceability-workspace.css +38 -2
- package/templates/.agents/dashboard/apps/frontend/src/use-app-cost-loaders.test.ts +187 -0
- package/templates/.agents/dashboard/apps/frontend/src/use-app-cost-loaders.ts +190 -0
- package/templates/.agents/dashboard/apps/frontend/src/use-app-effects.ts +121 -0
- package/templates/.agents/dashboard/apps/frontend/src/use-app-operations-pages.ts +398 -0
- package/templates/.agents/dashboard/apps/frontend/src/use-app-trace-documents.ts +141 -0
- package/templates/.agents/dashboard/apps/frontend/src/use-idle-cost-prefetch.ts +45 -0
- package/templates/.agents/dashboard/apps/frontend/src/work-list-pagination.test.ts +46 -0
- package/templates/.agents/dashboard/apps/frontend/src/work-list-pagination.ts +37 -0
- package/templates/.agents/dashboard/apps/frontend/vite.config.ts +55 -5
- package/templates/.agents/dashboard/modules/cost-monitor/package.json +1 -1
- package/templates/.agents/dashboard/modules/cost-monitor/src/contracts.ts +47 -6
- package/templates/.agents/dashboard/modules/cost-monitor/src/duration-estimate.ts +13 -0
- package/templates/.agents/dashboard/modules/cost-monitor/src/react/CompactLifecycleCostTable.test.ts +64 -0
- package/templates/.agents/dashboard/modules/cost-monitor/src/react/CompactLifecycleCostTable.tsx +275 -0
- package/templates/.agents/dashboard/modules/cost-monitor/src/react/CostCharts.test.ts +100 -15
- package/templates/.agents/dashboard/modules/cost-monitor/src/react/CostCharts.tsx +131 -40
- package/templates/.agents/dashboard/modules/cost-monitor/src/react/CostFilters.tsx +137 -19
- package/templates/.agents/dashboard/modules/cost-monitor/src/react/CostModelsAuditTable.test.ts +2 -0
- package/templates/.agents/dashboard/modules/cost-monitor/src/react/CostModelsAuditTable.tsx +13 -10
- package/templates/.agents/dashboard/modules/cost-monitor/src/react/CostMonitorContent.tsx +303 -0
- package/templates/.agents/dashboard/modules/cost-monitor/src/react/CostMonitorPage.test.ts +226 -6
- package/templates/.agents/dashboard/modules/cost-monitor/src/react/CostMonitorPage.tsx +479 -402
- package/templates/.agents/dashboard/modules/cost-monitor/src/react/CostSummary.tsx +5 -13
- package/templates/.agents/dashboard/modules/cost-monitor/src/react/CostTables.test.ts +312 -72
- package/templates/.agents/dashboard/modules/cost-monitor/src/react/CostTables.tsx +373 -321
- package/templates/.agents/dashboard/modules/cost-monitor/src/react/MacroCostTable.test.ts +17 -0
- package/templates/.agents/dashboard/modules/cost-monitor/src/react/MacroCostTable.tsx +25 -6
- package/templates/.agents/dashboard/modules/cost-monitor/src/react/cost-monitor-copy.ts +0 -2
- package/templates/.agents/dashboard/modules/cost-monitor/src/react/cost-monitor-page-helpers.ts +17 -0
- package/templates/.agents/dashboard/modules/cost-monitor/src/react/cost-monitor-responsive.css +6 -3
- package/templates/.agents/dashboard/modules/cost-monitor/src/react/cost-monitor-row-filters.ts +123 -0
- package/templates/.agents/dashboard/modules/cost-monitor/src/react/cost-monitor-summary.ts +8 -3
- package/templates/.agents/dashboard/modules/cost-monitor/src/react/cost-monitor-views.ts +32 -0
- package/templates/.agents/dashboard/modules/cost-monitor/src/react/cost-monitor.css +52 -14
- package/templates/.agents/dashboard/modules/cost-monitor/src/react/cost-table-presentation.ts +121 -0
- package/templates/.agents/dashboard/modules/cost-monitor/src/react/index.ts +3 -0
- package/templates/.agents/dashboard/modules/cost-monitor/src/react/period-cost-groups.test.ts +68 -0
- package/templates/.agents/dashboard/modules/cost-monitor/src/react/period-cost-groups.ts +32 -5
- package/templates/.agents/dashboard/modules/cost-monitor/src/react/use-compact-cost-page.ts +108 -0
- package/templates/.agents/dashboard/modules/cost-monitor/src/react/use-cost-group-page.test.ts +12 -0
- package/templates/.agents/dashboard/modules/cost-monitor/src/react/use-cost-group-page.ts +60 -0
- package/templates/.agents/dashboard/modules/cost-monitor/src/react/use-cost-run-page.ts +106 -0
- package/templates/.agents/dashboard/modules/cost-monitor/src/server/aggregate.test.ts +2 -2
- package/templates/.agents/dashboard/modules/cost-monitor/src/server/aggregate.ts +5 -3
- package/templates/.agents/dashboard/modules/cost-monitor/src/server/build-cost-monitor-pricing-fallback.test.ts +53 -0
- package/templates/.agents/dashboard/modules/cost-monitor/src/server/build-cost-monitor-projection.basics.test.ts +34 -0
- package/templates/.agents/dashboard/modules/cost-monitor/src/server/build-cost-monitor-projection.test.ts +168 -137
- package/templates/.agents/dashboard/modules/cost-monitor/src/server/build-cost-monitor-projection.ts +188 -29
- package/templates/.agents/dashboard/modules/cost-monitor/src/server/build-cost-summary-projection.test.ts +956 -0
- package/templates/.agents/dashboard/modules/cost-monitor/src/server/build-cost-summary-projection.ts +775 -0
- package/templates/.agents/dashboard/modules/cost-monitor/src/server/build-cost-summary-terminal-day.test.ts +95 -0
- package/templates/.agents/dashboard/modules/cost-monitor/src/server/index.ts +1 -0
- package/templates/.agents/dashboard/modules/cost-monitor/src/server/refactor-map-xr9l.json +61 -0
- package/templates/.agents/dashboard/modules/cost-monitor/src/task-cost-groups.test.ts +41 -0
- package/templates/.agents/dashboard/modules/cost-monitor/src/task-cost-groups.ts +55 -11
- package/templates/.agents/dashboard/modules/operations/package.json +2 -1
- package/templates/.agents/dashboard/modules/operations/src/contracts.ts +182 -0
- package/templates/.agents/dashboard/modules/operations/src/duration-population.test.ts +63 -1
- package/templates/.agents/dashboard/modules/operations/src/duration-population.ts +60 -5
- package/templates/.agents/dashboard/modules/operations/src/react/EntityDetailsDialog.tsx +14 -3
- package/templates/.agents/dashboard/modules/operations/src/react/EntityTables.test.ts +44 -1
- package/templates/.agents/dashboard/modules/operations/src/react/EntityTables.tsx +325 -18
- package/templates/.agents/dashboard/modules/operations/src/react/MacroPlanningDialog.tsx +1 -0
- package/templates/.agents/dashboard/modules/operations/src/react/OperationDateFilters.test.ts +9 -5
- package/templates/.agents/dashboard/modules/operations/src/react/OperationDateFilters.tsx +2 -2
- package/templates/.agents/dashboard/modules/operations/src/react/OperationsMainContent.tsx +168 -0
- package/templates/.agents/dashboard/modules/operations/src/react/OperationsOverview.helpers.tsx +95 -6
- package/templates/.agents/dashboard/modules/operations/src/react/OperationsOverview.test.ts +365 -14
- package/templates/.agents/dashboard/modules/operations/src/react/OperationsOverview.tsx +532 -131
- package/templates/.agents/dashboard/modules/operations/src/react/OperationsPage.tsx +314 -358
- package/templates/.agents/dashboard/modules/operations/src/react/OperationsPageNavigation.tsx +68 -0
- package/templates/.agents/dashboard/modules/operations/src/react/OperationsPageOverview.tsx +169 -0
- package/templates/.agents/dashboard/modules/operations/src/react/PeriodSummaryTable.tsx +51 -8
- package/templates/.agents/dashboard/modules/operations/src/react/PrdDocumentDialog.test.tsx +32 -0
- package/templates/.agents/dashboard/modules/operations/src/react/PrdDocumentDialog.tsx +62 -6
- package/templates/.agents/dashboard/modules/operations/src/react/TaskBoard.test.ts +55 -0
- package/templates/.agents/dashboard/modules/operations/src/react/TaskBoard.tsx +27 -19
- package/templates/.agents/dashboard/modules/operations/src/react/TaskDetailsDialog.tsx +99 -42
- package/templates/.agents/dashboard/modules/operations/src/react/UnifiedWorkBoard.priority.test.ts +19 -0
- package/templates/.agents/dashboard/modules/operations/src/react/UnifiedWorkBoard.tsx +255 -34
- package/templates/.agents/dashboard/modules/operations/src/react/UnifiedWorkList.test.ts +163 -8
- package/templates/.agents/dashboard/modules/operations/src/react/UnifiedWorkList.tsx +101 -68
- package/templates/.agents/dashboard/modules/operations/src/react/conversation-rows.test.ts +72 -1
- package/templates/.agents/dashboard/modules/operations/src/react/conversation-rows.ts +78 -16
- package/templates/.agents/dashboard/modules/operations/src/react/execution-metrics.ts +6 -4
- package/templates/.agents/dashboard/modules/operations/src/react/export/ExcelExportAction.test.ts +50 -1
- package/templates/.agents/dashboard/modules/operations/src/react/export/ExcelExportAction.tsx +143 -9
- package/templates/.agents/dashboard/modules/operations/src/react/export/export-layout.test.ts +29 -4
- package/templates/.agents/dashboard/modules/operations/src/react/macro-planning-dialog-content.css +49 -0
- package/templates/.agents/dashboard/modules/operations/src/react/macro-planning-dialog.css +93 -50
- package/templates/.agents/dashboard/modules/operations/src/react/manual-work-priority.test.ts +82 -0
- package/templates/.agents/dashboard/modules/operations/src/react/operation-date-range.test.ts +29 -2
- package/templates/.agents/dashboard/modules/operations/src/react/operation-date-range.ts +22 -1
- package/templates/.agents/dashboard/modules/operations/src/react/operation-duration.test.ts +77 -4
- package/templates/.agents/dashboard/modules/operations/src/react/operation-duration.ts +65 -5
- package/templates/.agents/dashboard/modules/operations/src/react/operations-coverage-toast.test.ts +54 -0
- package/templates/.agents/dashboard/modules/operations/src/react/operations-global-filters.test.ts +19 -0
- package/templates/.agents/dashboard/modules/operations/src/react/operations-overview-period-filter.test.ts +149 -12
- package/templates/.agents/dashboard/modules/operations/src/react/operations-overview.status-cards.test.ts +27 -0
- package/templates/.agents/dashboard/modules/operations/src/react/operations-page-contract.ts +136 -0
- package/templates/.agents/dashboard/modules/operations/src/react/operations-period-scope.test.ts +160 -0
- package/templates/.agents/dashboard/modules/operations/src/react/operations-period-scope.ts +47 -0
- package/templates/.agents/dashboard/modules/operations/src/react/operations-query.ts +10 -0
- package/templates/.agents/dashboard/modules/operations/src/react/operations-responsive.css +3 -0
- package/templates/.agents/dashboard/modules/operations/src/react/operations-view-labels.ts +28 -0
- package/templates/.agents/dashboard/modules/operations/src/react/operations-view-order.test.ts +24 -7
- package/templates/.agents/dashboard/modules/operations/src/react/operations.css +42 -0
- package/templates/.agents/dashboard/modules/operations/src/react/period-summary-population.test.ts +54 -0
- package/templates/.agents/dashboard/modules/operations/src/react/period-summary-population.ts +32 -0
- package/templates/.agents/dashboard/modules/operations/src/react/period-summary.test.ts +165 -6
- package/templates/.agents/dashboard/modules/operations/src/react/period-summary.ts +148 -6
- package/templates/.agents/dashboard/modules/operations/src/react/popup-localization.test.ts +1 -1
- package/templates/.agents/dashboard/modules/operations/src/react/unified-work-board.css +132 -0
- package/templates/.agents/dashboard/modules/operations/src/react/unified-work-board.css.test.ts +13 -0
- package/templates/.agents/dashboard/modules/operations/src/react/unified-work-board.header.test.ts +16 -0
- package/templates/.agents/dashboard/modules/operations/src/react/use-infinite-column.ts +11 -5
- package/templates/.agents/dashboard/modules/operations/src/react/work-board-model.test.ts +5 -3
- package/templates/.agents/dashboard/modules/operations/src/react/work-board-model.ts +4 -83
- package/templates/.agents/dashboard/modules/operations/src/server/build-operations-projection.test.ts +291 -15
- package/templates/.agents/dashboard/modules/operations/src/server/build-operations-projection.ts +182 -472
- package/templates/.agents/dashboard/modules/operations/src/server/canonical-compat.test.ts +40 -0
- package/templates/.agents/dashboard/modules/operations/src/server/canonical-compat.ts +19 -6
- package/templates/.agents/dashboard/modules/operations/src/server/canonical-run-projection.ts +31 -6
- package/templates/.agents/dashboard/modules/operations/src/server/daily-duration-projection.ts +220 -0
- package/templates/.agents/dashboard/modules/operations/src/server/execution-duration-projection.ts +28 -0
- package/templates/.agents/dashboard/modules/operations/src/server/execution-relationship-counts.test.ts +27 -2
- package/templates/.agents/dashboard/modules/operations/src/server/execution-relationship-counts.ts +22 -13
- package/templates/.agents/dashboard/modules/operations/src/server/filter.test.ts +3 -3
- package/templates/.agents/dashboard/modules/operations/src/server/filter.ts +7 -2
- package/templates/.agents/dashboard/modules/operations/src/server/index.ts +3 -0
- package/templates/.agents/dashboard/modules/operations/src/server/macro.ts +3 -12
- package/templates/.agents/dashboard/modules/operations/src/server/manifest-usage.ts +65 -0
- package/templates/.agents/dashboard/modules/operations/src/server/operations-projection-aggregates.ts +297 -0
- package/templates/.agents/dashboard/modules/operations/src/server/quick-daily-operations-projection.ts +324 -0
- package/templates/.agents/dashboard/modules/operations/src/server/quick-operations-projection.test.ts +505 -0
- package/templates/.agents/dashboard/modules/operations/src/server/quick-operations-projection.ts +609 -0
- package/templates/.agents/dashboard/modules/operations/src/server/runs.ts +18 -19
- package/templates/.agents/dashboard/modules/operations/src/work-board-model.ts +76 -0
- package/templates/.agents/dashboard/modules/traceability/package.json +1 -1
- package/templates/.agents/dashboard/modules/traceability/src/server/build-task-trace.ts +3 -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/contracts/src/index.ts +1 -0
- package/templates/.agents/dashboard/packages/data-export/package.json +1 -1
- package/templates/.agents/dashboard/packages/local-runtime/dist/server.cjs +1756 -0
- package/templates/.agents/dashboard/packages/local-runtime/dist/sqlite-read-model.cjs +1608 -0
- package/templates/.agents/dashboard/packages/local-runtime/package.json +8 -3
- package/templates/.agents/dashboard/packages/local-runtime/scripts/build-sqlite-dashboard.mjs +12 -0
- package/templates/.agents/dashboard/packages/local-runtime/scripts/build-sqlite-runtime.mjs +83 -0
- package/templates/.agents/dashboard/packages/local-runtime/scripts/rebuild-sqlite-read-model.mjs +28 -0
- package/templates/.agents/dashboard/packages/local-runtime/scripts/test-sqlite-read-model.mjs +262 -0
- package/templates/.agents/dashboard/packages/local-runtime/scripts/test-unix-launchers.mjs +41 -0
- package/templates/.agents/dashboard/packages/local-runtime/scripts/validate-sqlite-read-model.mjs +105 -0
- package/templates/.agents/dashboard/packages/local-runtime/server.mjs +1643 -107
- package/templates/.agents/dashboard/packages/local-runtime/src/agent-adapter-sync.ts +30 -0
- package/templates/.agents/dashboard/packages/local-runtime/src/agent-catalog-settings.test.ts +3 -2
- package/templates/.agents/dashboard/packages/local-runtime/src/agent-catalog-settings.ts +5 -0
- package/templates/.agents/dashboard/packages/local-runtime/src/manifest-runs.ts +72 -33
- package/templates/.agents/dashboard/packages/local-runtime/src/project-settings.test.ts +335 -4
- package/templates/.agents/dashboard/packages/local-runtime/src/project-settings.ts +392 -1
- package/templates/.agents/dashboard/packages/local-runtime/src/runtime.mjs +5 -5
- package/templates/.agents/dashboard/packages/local-runtime/src/server-board.test.ts +71 -0
- package/templates/.agents/dashboard/packages/local-runtime/src/server-board.ts +179 -0
- package/templates/.agents/dashboard/packages/local-runtime/src/server-cross-layer-parity.test.ts +245 -0
- package/templates/.agents/dashboard/packages/local-runtime/src/server-daily-read-models-route.ts +64 -0
- package/templates/.agents/dashboard/packages/local-runtime/src/server-daily-read-models.test.ts +204 -0
- package/templates/.agents/dashboard/packages/local-runtime/src/server-daily-read-models.ts +194 -0
- package/templates/.agents/dashboard/packages/local-runtime/src/server-operations-pages.test.ts +163 -0
- package/templates/.agents/dashboard/packages/local-runtime/src/server-operations-pages.ts +354 -0
- package/templates/.agents/dashboard/packages/local-runtime/src/server-operations-runs-route.test.ts +74 -0
- package/templates/.agents/dashboard/packages/local-runtime/src/server-operations-runs-route.ts +113 -0
- package/templates/.agents/dashboard/packages/local-runtime/src/server-overview.test.ts +68 -0
- package/templates/.agents/dashboard/packages/local-runtime/src/server-period.ts +47 -0
- package/templates/.agents/dashboard/packages/local-runtime/src/server-projections.ts +483 -0
- package/templates/.agents/dashboard/packages/local-runtime/src/server-settings.test.ts +5 -2
- package/templates/.agents/dashboard/packages/local-runtime/src/server-snapshot.test.ts +163 -84
- package/templates/.agents/dashboard/packages/local-runtime/src/server-workspace.ts +145 -0
- package/templates/.agents/dashboard/packages/local-runtime/src/server.test.ts +551 -266
- package/templates/.agents/dashboard/packages/local-runtime/src/server.ts +1145 -308
- package/templates/.agents/dashboard/packages/local-runtime/src/sqlite-metric-contract.test.ts +53 -0
- package/templates/.agents/dashboard/packages/local-runtime/src/sqlite-metric-contract.ts +708 -0
- package/templates/.agents/dashboard/packages/local-runtime/src/sqlite-read-model.test.ts +2232 -0
- package/templates/.agents/dashboard/packages/local-runtime/src/sqlite-read-model.ts +6151 -0
- package/templates/.agents/dashboard/packages/local-runtime/src/work-priority-contract.test.ts +33 -0
- package/templates/.agents/dashboard/packages/local-runtime/start-dashboard-history.mjs +41 -0
- package/templates/.agents/dashboard/packages/local-runtime/start-dashboard-processes.mjs +210 -0
- package/templates/.agents/dashboard/packages/local-runtime/start-dashboard.mjs +437 -190
- package/templates/.agents/dashboard/packages/local-runtime/start-dashboard.test.mjs +299 -24
- package/templates/.agents/dashboard/packages/ui/package.json +1 -1
- package/templates/.agents/dashboard/packages/windows-launcher/LauncherVerificationBehaviorTests.cs +206 -0
- package/templates/.agents/dashboard/packages/windows-launcher/Program.cs +95 -8
- package/templates/.agents/dashboard/packages/windows-launcher/build-dashboard-launcher.ps1 +2 -2
- package/templates/.agents/dashboard/packages/windows-launcher/run-launcher-verification-tests.ps1 +22 -0
- package/templates/.agents/dashboard/read-model.dbml +2201 -0
- package/templates/.agents/dashboard/tests/e2e/package.json +1 -1
- package/templates/.agents/dashboard/tests/e2e/playwright.config.ts +1 -1
- package/templates/.agents/dashboard/tests/e2e/specs/dashboard.spec.ts +214 -41
- package/templates/.agents/dashboard/work-priority.json +34 -0
- package/templates/.agents/dashboard/zaip-dashboard-linux.sh +45 -0
- package/templates/.agents/dashboard/zaip-dashboard-mac.command +3 -0
- package/templates/.agents/dashboard/zaip-dashboard-windows.exe +0 -0
- package/templates/.agents/design/.zaip-managed.json +3 -3
- package/templates/.agents/design/apps/catalog/package.json +1 -1
- package/templates/.agents/design/packages/local-runtime/package.json +1 -1
- package/templates/.agents/requirements/autonomous-assurance.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 +24 -0
- package/templates/.agents/requirements/data-export.md +1 -1
- package/templates/.agents/requirements/design-system.md +1 -1
- package/templates/.agents/requirements/execution-engine.md +1 -1
- package/templates/.agents/requirements/kanban-dashboard.md +4 -3
- package/templates/.agents/requirements/model-orchestration.md +1 -1
- package/templates/.agents/requirements/public-distribution.md +9 -6
- 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 +9 -3
- package/templates/.agents/requirements/zaip-strategic-95.md +4 -4
- package/templates/.agents/rules/autonomy-decision.md +15 -0
- package/templates/.agents/rules/core.md +1 -1
- package/templates/.agents/rules/run-lifecycle-closure.md +1 -1
- package/templates/.agents/rules/specialist-routing.md +19 -0
- package/templates/.agents/rules/workflow.md +1 -1
- package/templates/.agents/runtime/VERSION +1 -1
- package/templates/.agents/runtime/bin/zaip.mjs +114 -64
- package/templates/.agents/runtime/checksums.sha256 +6 -4
- package/templates/.agents/runtime/manifest.json +3 -1
- package/templates/.agents/runtime/pnpm-lock.sha256 +1 -0
- package/templates/.agents/runtime/provenance.json +11 -0
- package/templates/.agents/runtime/sbom.cdx.json +1929 -39
- package/templates/.agents/skills/zaip-aios/SKILL.md +1 -1
- package/templates/.agents/skills/zaip-skill-brand-governance/SKILL.md +15 -0
- package/templates/.agents/skills/zaip-skill-brand-governance/agents/openai.yaml +4 -0
- package/templates/.agents/skills/zaip-skill-brand-governance/references/brandbook-standards.md +30 -0
- package/templates/.agents/skills/zaip-skill-dashboard-sqlite/SKILL.md +25 -0
- package/templates/.agents/skills/zaip-skill-dashboard-sqlite/agents/openai.yaml +4 -0
- package/templates/.agents/skills/zaip-skill-executar-fila-pronta/SKILL.md +18 -0
- package/templates/.agents/skills/zaip-skill-executar-fila-pronta/agents/openai.yaml +6 -0
- package/templates/.agents/skills/zaip-skill-executar-fila-pronta/scripts/ready-queue-fence.mjs +71 -0
- package/templates/.agents/skills/zaip-skill-executar-fila-pronta/scripts/ready-queue-fence.test.mjs +60 -0
- package/templates/.agents/skills/zaip-skill-executar-fila-pronta/scripts/scheduled-ready-queue-contract.test.mjs +111 -0
- package/templates/.agents/skills/zaip-skill-execution/SKILL.md +2 -2
- package/templates/.agents/skills/zaip-skill-frontend-launcher/references/launcher-contract.md +3 -1
- package/templates/.agents/skills/zaip-skill-general-operations/SKILL.md +12 -0
- package/templates/.agents/skills/zaip-skill-general-operations/agents/openai.yaml +4 -0
- package/templates/.agents/skills/zaip-skill-github-deploy/SKILL.md +9 -7
- package/templates/.agents/skills/zaip-skill-github-deploy/agents/openai.yaml +2 -2
- package/templates/.agents/skills/zaip-skill-github-deploy/scripts/github-deploy-contract.test.mjs +11 -38
- package/templates/.agents/skills/zaip-skill-governance-compliance/SKILL.md +12 -0
- package/templates/.agents/skills/zaip-skill-governance-compliance/agents/openai.yaml +4 -0
- package/templates/.agents/skills/zaip-skill-growth-strategy-revops/SKILL.md +15 -0
- package/templates/.agents/skills/zaip-skill-growth-strategy-revops/agents/openai.yaml +4 -0
- package/templates/.agents/skills/zaip-skill-growth-strategy-revops/references/growth-revops-framework.md +25 -0
- package/templates/.agents/skills/zaip-skill-instalar-agendamento/SKILL.md +17 -0
- package/templates/.agents/skills/zaip-skill-instalar-agendamento/agents/openai.yaml +6 -0
- package/templates/.agents/skills/zaip-skill-marketing/SKILL.md +3 -3
- package/templates/.agents/skills/zaip-skill-reconcile-telemetry/scripts/reconcile-local-telemetry.mjs +76 -27
- package/templates/.agents/skills/zaip-skill-reconcile-telemetry/scripts/reconcile-telemetry-lib.mjs +128 -24
- package/templates/.agents/skills/zaip-skill-reconcile-telemetry/scripts/reconcile-telemetry-lib.test.mjs +122 -4
- package/templates/.agents/skills/zaip-skill-reconcile-telemetry/scripts/reconcile-telemetry-remeasurement.mjs +66 -19
- package/templates/.agents/skills/zaip-skill-reconcile-telemetry/scripts/reconcile-telemetry-remeasurement.test.mjs +193 -7
- package/templates/.agents/skills/zaip-skill-sales-methodology/SKILL.md +14 -0
- package/templates/.agents/skills/zaip-skill-sales-methodology/agents/openai.yaml +4 -0
- package/templates/.agents/skills/zaip-skill-sales-methodology/references/sales-process-framework.md +77 -0
- package/templates/.agents/skills/zaip-skill-setup/SKILL.md +5 -0
- package/templates/.agents/skills/zaip-skill-sqlite-read-model/SKILL.md +96 -0
- package/templates/.agents/skills/zaip-skill-sqlite-read-model/agents/openai.yaml +4 -0
- package/templates/.agents/skills/zaip-skill-sqlite-read-model/scripts/ensure-node.mjs +18 -0
- package/templates/.agents/zaip-aios/INDEX.md +1 -0
- package/templates/.agents/zaip-aios/README.md +37 -8
- package/templates/.agents/zaip-aios/VERSION +1 -1
- package/templates/.agents/zaip-aios/guides/09-agentes-e-squads.md +43 -6
- package/templates/.agents/zaip-aios/guides/10-seguranca.md +21 -7
- package/templates/.agents/zaip-aios/guides/17-como-o-custo-e-calculado.md +32 -0
- package/templates/template-manifest.json +945 -214
- package/templates/.agents/dashboard/apps/frontend/dist/assets/AgentCatalogSettingsPage-CLYIi7Vo.js +0 -1
- package/templates/.agents/dashboard/apps/frontend/dist/assets/AgentCatalogSettingsPage-DTDNVQGX.css +0 -1
- package/templates/.agents/dashboard/apps/frontend/dist/assets/PricingSettingsDialog-CzEggcRb.js +0 -1
- package/templates/.agents/dashboard/apps/frontend/dist/assets/ProjectSettingsPage-05YKn6Z4.js +0 -3
- package/templates/.agents/dashboard/apps/frontend/dist/assets/ProjectSettingsPage-YO3yqtgV.css +0 -1
- package/templates/.agents/dashboard/apps/frontend/dist/assets/index-8AzCnl3a.js +0 -77
- package/templates/.agents/dashboard/apps/frontend/dist/assets/index-DdBYQ_8D.css +0 -1
- package/templates/.agents/dashboard/apps/frontend/src/AgentCatalogSettingsPage.tsx +0 -617
- package/templates/.agents/dashboard/apps/frontend/src/agent-catalog-settings-page.css +0 -660
- package/templates/.agents/dashboard/apps/frontend/src/agent-catalog-settings.test.ts +0 -249
- package/templates/.agents/dashboard/dashboard.config.json +0 -4
- package/templates/.agents/dashboard/zaip-dashboard.exe +0 -0
|
@@ -1,6 +1,7 @@
|
|
|
1
|
-
import {
|
|
1
|
+
import { open, readFile, rename, rm, writeFile } from "node:fs/promises";
|
|
2
2
|
import {
|
|
3
3
|
aggregate,
|
|
4
|
+
exactCompletedSegment,
|
|
4
5
|
exactRemeasurementSegment,
|
|
5
6
|
jsonLines,
|
|
6
7
|
pricingFor,
|
|
@@ -9,6 +10,7 @@ import {
|
|
|
9
10
|
recordType,
|
|
10
11
|
usageStatus,
|
|
11
12
|
usageView,
|
|
13
|
+
withSequence,
|
|
12
14
|
} from "./reconcile-telemetry-lib.mjs";
|
|
13
15
|
|
|
14
16
|
export const remeasureSelectedRuns = async ({
|
|
@@ -26,19 +28,35 @@ export const remeasureSelectedRuns = async ({
|
|
|
26
28
|
remeasurement.push({ run_id: runId, eligible: false, reason: "run-not-found" });
|
|
27
29
|
continue;
|
|
28
30
|
}
|
|
29
|
-
const
|
|
30
|
-
|
|
31
|
-
|
|
31
|
+
const effectiveUsage = usageStatus(run.usage).effective;
|
|
32
|
+
const effective = timingOnly
|
|
33
|
+
? effectiveUsage
|
|
34
|
+
: effectiveUsage.filter(
|
|
35
|
+
(usage) => usage.tokens?.input !== null && usage.tokens?.output !== null,
|
|
36
|
+
);
|
|
32
37
|
const superseded = effective.at(-1) ?? null;
|
|
33
38
|
const finished = run.records.find((record) => recordType(record) === "run.finished");
|
|
34
|
-
|
|
35
|
-
|
|
36
|
-
|
|
37
|
-
|
|
38
|
-
|
|
39
|
+
// Timing-only reconciliation is deliberately narrower than normal
|
|
40
|
+
// remeasurement: it may enrich a missing source interval only when the
|
|
41
|
+
// persisted client turn identifies exactly one completed local segment.
|
|
42
|
+
const match = timingOnly
|
|
43
|
+
? exactCompletedSegment(run.started, allSegments)
|
|
44
|
+
: exactRemeasurementSegment(
|
|
45
|
+
run.started,
|
|
46
|
+
superseded?.source_segment_key,
|
|
47
|
+
allSegments,
|
|
48
|
+
superseded?.source_occurred_at,
|
|
49
|
+
superseded?.tokens,
|
|
50
|
+
);
|
|
39
51
|
const segment = match.segment;
|
|
40
52
|
const ambiguous = match.ambiguous;
|
|
41
|
-
if (
|
|
53
|
+
if (
|
|
54
|
+
!finished ||
|
|
55
|
+
segment === null ||
|
|
56
|
+
segment.finished_at === null ||
|
|
57
|
+
ambiguous ||
|
|
58
|
+
superseded === null
|
|
59
|
+
) {
|
|
42
60
|
remeasurement.push({
|
|
43
61
|
run_id: runId,
|
|
44
62
|
eligible: false,
|
|
@@ -121,36 +139,65 @@ export const remeasureSelectedRuns = async ({
|
|
|
121
139
|
return remeasurement;
|
|
122
140
|
};
|
|
123
141
|
|
|
142
|
+
export function timingEnrichmentRunIds({ remeasure, applyBackfill, selectedRunIds, runs }) {
|
|
143
|
+
if (remeasure) return selectedRunIds;
|
|
144
|
+
if (!applyBackfill) return new Set();
|
|
145
|
+
return new Set(
|
|
146
|
+
runs
|
|
147
|
+
.filter(
|
|
148
|
+
(run) =>
|
|
149
|
+
run.nativeMeasured && run.records.some((record) => recordType(record) === "run.finished"),
|
|
150
|
+
)
|
|
151
|
+
.map((run) => run.started.run_id),
|
|
152
|
+
);
|
|
153
|
+
}
|
|
154
|
+
|
|
124
155
|
export async function appendRetrospectiveUsage(file, expectedRecords, event) {
|
|
125
|
-
assertRetrospectiveAppend(expectedRecords, event);
|
|
156
|
+
assertRetrospectiveAppend(expectedRecords, event, { allowPostTerminalCorrections: true });
|
|
126
157
|
const lockPath = `${file}.lock`;
|
|
127
158
|
const handle = await open(lockPath, "wx");
|
|
128
159
|
await handle.close();
|
|
129
160
|
try {
|
|
130
161
|
const persisted = jsonLines(await readFile(file, "utf8"));
|
|
131
|
-
const
|
|
132
|
-
const
|
|
162
|
+
const expectedIds = expectedRecords.map((record) => record?.event_id ?? record?.[2]);
|
|
163
|
+
const persistedIds = persisted.map((record) => record?.event_id ?? record?.[2]);
|
|
133
164
|
if (
|
|
134
165
|
persisted.length !== expectedRecords.length ||
|
|
135
|
-
|
|
136
|
-
recordType(persistedLast) !== "run.finished"
|
|
166
|
+
persistedIds.some((id, index) => id !== expectedIds[index])
|
|
137
167
|
) {
|
|
138
168
|
throw new Error("Run history changed before retrospective append");
|
|
139
169
|
}
|
|
140
|
-
assertRetrospectiveAppend(persisted, event);
|
|
141
|
-
|
|
170
|
+
assertRetrospectiveAppend(persisted, event, { allowPostTerminalCorrections: true });
|
|
171
|
+
const finishIndex = persisted.findIndex((record) => recordType(record) === "run.finished");
|
|
172
|
+
const beforeFinish = persisted.slice(0, finishIndex);
|
|
173
|
+
const finish = persisted[finishIndex];
|
|
174
|
+
const historicalCorrections = persisted.slice(finishIndex + 1);
|
|
175
|
+
const updated = [...beforeFinish, ...historicalCorrections, event, finish].map((record, index) =>
|
|
176
|
+
withSequence(record, index + 1),
|
|
177
|
+
);
|
|
178
|
+
const temporary = `${file}.remeasure.tmp`;
|
|
179
|
+
await writeFile(temporary, `${updated.map((record) => JSON.stringify(record)).join("\n")}\n`, "utf8");
|
|
180
|
+
await rename(temporary, file);
|
|
142
181
|
} finally {
|
|
143
182
|
await rm(lockPath, { force: true });
|
|
144
183
|
}
|
|
145
184
|
}
|
|
146
185
|
|
|
147
|
-
export function assertRetrospectiveAppend(records, event) {
|
|
148
|
-
const
|
|
186
|
+
export function assertRetrospectiveAppend(records, event, { allowPostTerminalCorrections = false } = {}) {
|
|
187
|
+
const finishIndex = records.findIndex((record) => recordType(record) === "run.finished");
|
|
188
|
+
const finished = records[finishIndex];
|
|
149
189
|
const target = records.find(
|
|
150
190
|
(record) => usageView(record)?.event_id === event.supersedes_event_id,
|
|
151
191
|
);
|
|
152
192
|
if (
|
|
153
193
|
recordType(finished) !== "run.finished" ||
|
|
194
|
+
(!allowPostTerminalCorrections && finishIndex !== records.length - 1) ||
|
|
195
|
+
(allowPostTerminalCorrections &&
|
|
196
|
+
records.slice(finishIndex + 1).some(
|
|
197
|
+
(record) =>
|
|
198
|
+
usageView(record)?.activity_kind !== "retrospective_local_remeasurement" ||
|
|
199
|
+
usageView(record)?.retrospective_correction !== true,
|
|
200
|
+
)) ||
|
|
154
201
|
event.type !== "usage.recorded" ||
|
|
155
202
|
event.retrospective_correction !== true ||
|
|
156
203
|
event.activity_kind !== "retrospective_local_remeasurement" ||
|
|
@@ -9,12 +9,34 @@ import {
|
|
|
9
9
|
assertRetrospectiveAppend,
|
|
10
10
|
remeasureSelectedRuns,
|
|
11
11
|
retrospectiveCorrectionOccurredAt,
|
|
12
|
+
timingEnrichmentRunIds,
|
|
12
13
|
} from "./reconcile-telemetry-remeasurement.mjs";
|
|
13
14
|
|
|
14
15
|
const roots = [];
|
|
15
16
|
after(async () => Promise.all(roots.map((root) => rm(root, { recursive: true, force: true }))));
|
|
16
17
|
|
|
17
|
-
test("
|
|
18
|
+
test("selects completed native Runs for default timing-only backfill", () => {
|
|
19
|
+
const selected = timingEnrichmentRunIds({
|
|
20
|
+
remeasure: false,
|
|
21
|
+
applyBackfill: true,
|
|
22
|
+
selectedRunIds: new Set(),
|
|
23
|
+
runs: [
|
|
24
|
+
{
|
|
25
|
+
nativeMeasured: true,
|
|
26
|
+
started: { run_id: "RUN-NATIVE" },
|
|
27
|
+
records: [{ type: "run.started" }, { type: "run.finished" }],
|
|
28
|
+
},
|
|
29
|
+
{
|
|
30
|
+
nativeMeasured: true,
|
|
31
|
+
started: { run_id: "RUN-RUNNING" },
|
|
32
|
+
records: [{ type: "run.started" }],
|
|
33
|
+
},
|
|
34
|
+
],
|
|
35
|
+
});
|
|
36
|
+
assert.deepEqual([...selected], ["RUN-NATIVE"]);
|
|
37
|
+
});
|
|
38
|
+
|
|
39
|
+
test("inserts a correction before the terminal event under an exclusive lock", async () => {
|
|
18
40
|
const root = await mkdtemp(join(tmpdir(), "zaip-remeasure-append-"));
|
|
19
41
|
roots.push(root);
|
|
20
42
|
const file = join(root, "RUN.jsonl");
|
|
@@ -38,8 +60,27 @@ test("appends under an exclusive lock without rewriting the terminal history", a
|
|
|
38
60
|
await appendRetrospectiveUsage(file, records, correction);
|
|
39
61
|
|
|
40
62
|
const persisted = await readFile(file, "utf8");
|
|
41
|
-
|
|
42
|
-
assert.equal(
|
|
63
|
+
const events = jsonLines(persisted);
|
|
64
|
+
assert.equal(events.at(-2).event_id, correction.event_id);
|
|
65
|
+
assert.equal(events.at(-1).type, "run.finished");
|
|
66
|
+
assert.deepEqual(events.map((event) => event.sequence), [1, 2, 3, 4]);
|
|
67
|
+
});
|
|
68
|
+
|
|
69
|
+
test("restores historical retrospective corrections before the terminal event", async () => {
|
|
70
|
+
const root = await mkdtemp(join(tmpdir(), "zaip-remeasure-restore-"));
|
|
71
|
+
roots.push(root);
|
|
72
|
+
const file = join(root, "RUN.jsonl");
|
|
73
|
+
const records = [
|
|
74
|
+
{ type: "run.started", event_id: "RUN:1", sequence: 1, phase: "execution" },
|
|
75
|
+
{ type: "usage.recorded", event_id: "RUN:2", sequence: 2, phase: "execution" },
|
|
76
|
+
{ type: "run.finished", event_id: "RUN:3", sequence: 3, phase: "execution" },
|
|
77
|
+
{ type: "usage.recorded", event_id: "RUN:4", sequence: 4, phase: "execution", activity_kind: "retrospective_local_remeasurement", retrospective_correction: true },
|
|
78
|
+
];
|
|
79
|
+
await writeFile(file, `${records.map((record) => JSON.stringify(record)).join("\n")}\n`, "utf8");
|
|
80
|
+
await appendRetrospectiveUsage(file, records, { type: "usage.recorded", event_id: "RUN:5", sequence: 5, phase: "execution", activity_kind: "retrospective_local_remeasurement", supersedes_event_id: "RUN:2", retrospective_correction: true });
|
|
81
|
+
const events = jsonLines(await readFile(file, "utf8"));
|
|
82
|
+
assert.deepEqual(events.map((event) => event.event_id), ["RUN:1", "RUN:2", "RUN:4", "RUN:5", "RUN:3"]);
|
|
83
|
+
assert.deepEqual(events.map((event) => event.sequence), [1, 2, 3, 4, 5]);
|
|
43
84
|
});
|
|
44
85
|
|
|
45
86
|
test("an unavailable lock leaves the original history byte-identical", async () => {
|
|
@@ -151,17 +192,17 @@ test("uses run.finished phase after planning transitions to execution and reread
|
|
|
151
192
|
workspace: root,
|
|
152
193
|
});
|
|
153
194
|
const persisted = jsonLines(await readFile(file, "utf8"));
|
|
154
|
-
const correction = usageView(persisted.at(-
|
|
195
|
+
const correction = usageView(persisted.at(-2));
|
|
155
196
|
assert.equal(result.applied, true);
|
|
156
197
|
assert.equal(correction.phase, "execution");
|
|
157
198
|
assert.equal(usageStatus([...run.usage, correction]).effective.at(-1).tokens.total, 9);
|
|
158
199
|
assert.throws(
|
|
159
|
-
() => assertRetrospectiveAppend(records, { ...persisted.at(-
|
|
200
|
+
() => assertRetrospectiveAppend(records, { ...persisted.at(-2), phase: "planning" }),
|
|
160
201
|
/Invalid retrospective/,
|
|
161
202
|
);
|
|
162
203
|
});
|
|
163
204
|
|
|
164
|
-
test("
|
|
205
|
+
test("timing-only preserves exact measured tokens and cost while enriching source timing", async () => {
|
|
165
206
|
const root = await mkdtemp(join(tmpdir(), "zaip-remeasure-timing-"));
|
|
166
207
|
roots.push(root);
|
|
167
208
|
await mkdir(join(root, ".agents", "config", "pricing"), { recursive: true });
|
|
@@ -198,6 +239,7 @@ test("enriches exact source timing without changing canonical tokens when remeas
|
|
|
198
239
|
phase: "execution",
|
|
199
240
|
activity_kind: "retrospective_local_reconciliation",
|
|
200
241
|
tokens: { input: 10, cached_input: 0, output: 2, reasoning: 0, total: 12 },
|
|
242
|
+
cost: { usd: 0.000012, brl: 0.00006, fx_rate: 5 },
|
|
201
243
|
supersedes_event_id: null,
|
|
202
244
|
source_segment_key: "session#timing",
|
|
203
245
|
source_occurred_at: "2026-07-25T04:01:00.000Z",
|
|
@@ -217,6 +259,7 @@ test("enriches exact source timing without changing canonical tokens when remeas
|
|
|
217
259
|
records,
|
|
218
260
|
started: {
|
|
219
261
|
run_id: "RUN-TIMING",
|
|
262
|
+
occurred_at: "2026-07-25T04:00:00.000Z",
|
|
220
263
|
phase: "execution",
|
|
221
264
|
client_turn_id: "turn-timing",
|
|
222
265
|
model: "gpt-test",
|
|
@@ -249,15 +292,158 @@ test("enriches exact source timing without changing canonical tokens when remeas
|
|
|
249
292
|
timingOnly: true,
|
|
250
293
|
workspace: root,
|
|
251
294
|
});
|
|
252
|
-
const correction = usageView(jsonLines(await readFile(file, "utf8")).at(-
|
|
295
|
+
const correction = usageView(jsonLines(await readFile(file, "utf8")).at(-2));
|
|
253
296
|
assert.equal(result.unchanged, false);
|
|
254
297
|
assert.equal(result.timing_enrichment, true);
|
|
298
|
+
assert.equal(result.eligible, true);
|
|
255
299
|
assert.equal(result.applied, true);
|
|
256
300
|
assert.equal(correction.tokens.total, 12);
|
|
301
|
+
assert.deepEqual(correction.tokens, usageView(records[1]).tokens);
|
|
302
|
+
assert.deepEqual(correction.cost, usageView(records[1]).cost);
|
|
257
303
|
assert.equal(correction.source_started_at, segment.started_at);
|
|
258
304
|
assert.equal(correction.source_finished_at, segment.finished_at);
|
|
259
305
|
});
|
|
260
306
|
|
|
307
|
+
test("timing-only appends exact source timing while preserving null tokens and cost", async () => {
|
|
308
|
+
const root = await mkdtemp(join(tmpdir(), "zaip-remeasure-null-timing-"));
|
|
309
|
+
roots.push(root);
|
|
310
|
+
const file = join(root, "RUN-NULL.jsonl");
|
|
311
|
+
const records = timingRunRecords("RUN-NULL", "turn-null", {
|
|
312
|
+
input: null,
|
|
313
|
+
cached_input: null,
|
|
314
|
+
output: null,
|
|
315
|
+
reasoning: null,
|
|
316
|
+
total: null,
|
|
317
|
+
});
|
|
318
|
+
await writeFile(file, `${records.map((record) => JSON.stringify(record)).join("\n")}\n`);
|
|
319
|
+
const run = timingRun(file, records, "RUN-NULL", "turn-null");
|
|
320
|
+
const segment = completedSegment("segment-null", "turn-null");
|
|
321
|
+
|
|
322
|
+
const [result] = await remeasureSelectedRuns({
|
|
323
|
+
apply: true,
|
|
324
|
+
allSegments: [segment],
|
|
325
|
+
runs: [run],
|
|
326
|
+
selectedRunIds: new Set(["RUN-NULL"]),
|
|
327
|
+
timingOnly: true,
|
|
328
|
+
workspace: root,
|
|
329
|
+
});
|
|
330
|
+
const correction = usageView(jsonLines(await readFile(file, "utf8")).at(-2));
|
|
331
|
+
assert.equal(result.eligible, true);
|
|
332
|
+
assert.equal(result.applied, true);
|
|
333
|
+
assert.deepEqual(correction.tokens, records[1].tokens);
|
|
334
|
+
assert.deepEqual(correction.cost, records[1].cost);
|
|
335
|
+
assert.equal(correction.source_started_at, segment.started_at);
|
|
336
|
+
assert.equal(correction.source_finished_at, segment.finished_at);
|
|
337
|
+
});
|
|
338
|
+
|
|
339
|
+
test("timing-only rejects a mismatched or ambiguous client turn without appending", async () => {
|
|
340
|
+
const root = await mkdtemp(join(tmpdir(), "zaip-remeasure-exact-turn-"));
|
|
341
|
+
roots.push(root);
|
|
342
|
+
for (const [runId, turnId, segments, reason] of [
|
|
343
|
+
[
|
|
344
|
+
"RUN-MISMATCH",
|
|
345
|
+
"turn-persisted",
|
|
346
|
+
[completedSegment("segment-other", "turn-other")],
|
|
347
|
+
"exact-segment-not-found",
|
|
348
|
+
],
|
|
349
|
+
[
|
|
350
|
+
"RUN-AMBIGUOUS",
|
|
351
|
+
"turn-ambiguous",
|
|
352
|
+
[
|
|
353
|
+
completedSegment("segment-one", "turn-ambiguous"),
|
|
354
|
+
completedSegment("segment-two", "turn-ambiguous"),
|
|
355
|
+
],
|
|
356
|
+
"ambiguous-segment",
|
|
357
|
+
],
|
|
358
|
+
]) {
|
|
359
|
+
const file = join(root, `${runId}.jsonl`);
|
|
360
|
+
const records = timingRunRecords(runId, turnId, {
|
|
361
|
+
input: null,
|
|
362
|
+
cached_input: null,
|
|
363
|
+
output: null,
|
|
364
|
+
reasoning: null,
|
|
365
|
+
total: null,
|
|
366
|
+
});
|
|
367
|
+
await writeFile(file, `${records.map((record) => JSON.stringify(record)).join("\n")}\n`);
|
|
368
|
+
const [result] = await remeasureSelectedRuns({
|
|
369
|
+
apply: true,
|
|
370
|
+
allSegments: segments,
|
|
371
|
+
runs: [timingRun(file, records, runId, turnId)],
|
|
372
|
+
selectedRunIds: new Set([runId]),
|
|
373
|
+
timingOnly: true,
|
|
374
|
+
workspace: root,
|
|
375
|
+
});
|
|
376
|
+
assert.equal(result.eligible, false);
|
|
377
|
+
assert.equal(result.reason, reason);
|
|
378
|
+
assert.deepEqual(jsonLines(await readFile(file, "utf8")), records);
|
|
379
|
+
}
|
|
380
|
+
});
|
|
381
|
+
|
|
382
|
+
function timingRunRecords(runId, turnId, tokens) {
|
|
383
|
+
return [
|
|
384
|
+
{
|
|
385
|
+
type: "run.started",
|
|
386
|
+
event_id: `${runId}:1`,
|
|
387
|
+
run_id: runId,
|
|
388
|
+
sequence: 1,
|
|
389
|
+
occurred_at: "2026-07-29T12:29:45.637Z",
|
|
390
|
+
phase: "execution",
|
|
391
|
+
client_turn_id: turnId,
|
|
392
|
+
},
|
|
393
|
+
{
|
|
394
|
+
type: "usage.recorded",
|
|
395
|
+
event_id: `${runId}:2`,
|
|
396
|
+
run_id: runId,
|
|
397
|
+
sequence: 2,
|
|
398
|
+
occurred_at: "2026-07-29T12:30:00.000Z",
|
|
399
|
+
phase: "execution",
|
|
400
|
+
tokens,
|
|
401
|
+
cost: { usd: null, brl: null },
|
|
402
|
+
supersedes_event_id: null,
|
|
403
|
+
},
|
|
404
|
+
{
|
|
405
|
+
type: "run.finished",
|
|
406
|
+
event_id: `${runId}:3`,
|
|
407
|
+
run_id: runId,
|
|
408
|
+
sequence: 3,
|
|
409
|
+
occurred_at: "2026-07-29T12:31:00.000Z",
|
|
410
|
+
phase: "execution",
|
|
411
|
+
},
|
|
412
|
+
];
|
|
413
|
+
}
|
|
414
|
+
|
|
415
|
+
function timingRun(file, records, runId, turnId) {
|
|
416
|
+
return {
|
|
417
|
+
file,
|
|
418
|
+
records,
|
|
419
|
+
started: {
|
|
420
|
+
run_id: runId,
|
|
421
|
+
occurred_at: "2026-07-29T12:29:45.637Z",
|
|
422
|
+
phase: "execution",
|
|
423
|
+
client_turn_id: turnId,
|
|
424
|
+
},
|
|
425
|
+
usage: records.map(usageView).filter(Boolean),
|
|
426
|
+
};
|
|
427
|
+
}
|
|
428
|
+
|
|
429
|
+
function completedSegment(key, turnId) {
|
|
430
|
+
return {
|
|
431
|
+
key,
|
|
432
|
+
turn_id: turnId,
|
|
433
|
+
started_at: "2026-07-29T12:29:45.637Z",
|
|
434
|
+
finished_at: "2026-07-29T12:40:07.773Z",
|
|
435
|
+
usage: [
|
|
436
|
+
{
|
|
437
|
+
input_tokens: 10,
|
|
438
|
+
cached_input_tokens: 0,
|
|
439
|
+
output_tokens: 2,
|
|
440
|
+
reasoning_output_tokens: 0,
|
|
441
|
+
total_tokens: 12,
|
|
442
|
+
},
|
|
443
|
+
],
|
|
444
|
+
};
|
|
445
|
+
}
|
|
446
|
+
|
|
261
447
|
test("uses the current correction clock instead of fabricating a pre-finish timestamp", () => {
|
|
262
448
|
const current = new Date("2026-07-25T04:06:14.352Z");
|
|
263
449
|
assert.equal(
|
|
@@ -0,0 +1,14 @@
|
|
|
1
|
+
---
|
|
2
|
+
name: zaip-skill-sales-methodology
|
|
3
|
+
description: Design evidence-backed sales processes, qualification playbooks, and configurable scripts. Use for internal sales-methodology work; not for external commercial acts or campaign production.
|
|
4
|
+
---
|
|
5
|
+
|
|
6
|
+
# Metodologia comercial
|
|
7
|
+
|
|
8
|
+
1. Delimite empresa, oferta, ICP, persona, canal, origem inbound/outbound, etapa, nível de awareness, complexidade, ticket, ciclo, regiões, compliance e autoridade. Separe fato, evidência, hipótese e decisão; não fabrique consciência, urgência, prova, ROI, preço ou autoridade.
|
|
9
|
+
2. Desenhe um playbook por etapa com objetivo, dono, entrada, abertura, perguntas, evidência, campos SPIN/BANT, transição, objeções, prova autorizada, microcompromisso, saída, CRM, handoff/SLA e próximo passo. Inclua caminhos de not-qualified, nurture e no-decision.
|
|
10
|
+
3. Use as três etapas ZAIP: descoberta/pré-qualificação (tipicamente SDR), alinhamento/qualificação com handoff definido para closer, e fechamento/negociação pelo closer. O preço só pode ser apresentado como aprovado; proposta e contrato seguem o handoff autorizado.
|
|
11
|
+
4. Aplique SPIN como banco adaptativo de Situation, Problem, Implication e Need-payoff, nunca como interrogatório ou ordem rígida. Use BANT como campos e gates de evidência (Budget, Authority, Need, Timing), nunca para pressionar ou desqualificar de forma manipulativa.
|
|
12
|
+
5. Adapte narrativa, perguntas e CTA a unaware, problem-aware, solution-aware, product-aware e most-aware somente quando houver evidência do estágio. Use o roteiro genérico de qualificação curta e a estrutura de fechamento em [referência de processo](references/sales-process-framework.md).
|
|
13
|
+
6. Aaron somente desenha ou melhora processo, playbook e script internos. Não contata prospects, envia proposta ou link de pagamento, altera preço/desconto, assina contrato nem executa ato comercial externo ou vinculante sem autoridade explícita.
|
|
14
|
+
7. Encaminhe estratégia Growth/RevOps, estratégia empresarial e economia end-to-end para Robert; campanha e copy de aquisição para Lúcia; marca e tom ainda não decididos para Sarah; dados e métodos quantitativos para Gabi; políticas ou limites legais para Renata; e produção documental genérica para Clara. Sales-facing scripts e enablement pertencem a Aaron; copy de campanha pertence a Lúcia.
|
package/templates/.agents/skills/zaip-skill-sales-methodology/references/sales-process-framework.md
ADDED
|
@@ -0,0 +1,77 @@
|
|
|
1
|
+
# Framework de processo comercial
|
|
2
|
+
|
|
3
|
+
## Fronteira e papéis
|
|
4
|
+
|
|
5
|
+
O papel separa prospecção/SDR, qualificação inbound, closer/AE e gestão de conta ou Customer Success quando a operação exigir especialização. Aaron documenta as interfaces e os handoffs, mas não substitui a decisão de capacidade, estratégia de canal ou economia do funil de Robert.
|
|
6
|
+
|
|
7
|
+
## Princípios adaptados
|
|
8
|
+
|
|
9
|
+
Use Positioning, Pace e Practice como lentes de diagnóstico: adequação da narrativa ao mercado, ritmo e investimento autorizados, e capacidade de transformar o plano em prática observável. Organize o playbook nos blocos Targeting, Tools, Prospecting, Qualification e Follow-through. São uma adaptação conceitual das fontes listadas, não uma cópia nem uma sequência obrigatória.
|
|
10
|
+
|
|
11
|
+
## Gates das três etapas
|
|
12
|
+
|
|
13
|
+
| Etapa | Dono típico | Entrada | Saída | Handoff |
|
|
14
|
+
| --- | --- | --- | --- | --- |
|
|
15
|
+
| Descoberta e pré-qualificação | SDR | Lead ou conta elegível com origem registrada | Dor, urgência e contato adequado registrados, ou rota alternativa | Qualificação, nurture ou not-qualified |
|
|
16
|
+
| Alinhamento e qualificação | SDR com closer definido | Contexto mínimo e interesse verificável | Fit, necessidade e próximo passo documentados antes de discutir preço | Handoff com CRM e SLA acordado ao closer |
|
|
17
|
+
| Fechamento e negociação | Closer | Oportunidade aceita e escopo de conversa autorizado | Próximo passo, proposta ou contrato somente por fluxo autorizado; ou no-decision | Proposta/contrato autorizado, nurture ou encerramento registrado |
|
|
18
|
+
|
|
19
|
+
Os gates são critérios de evidência, não metas de pressão. Dados indisponíveis ficam explícitos como lacuna.
|
|
20
|
+
|
|
21
|
+
## Playbook configurável
|
|
22
|
+
|
|
23
|
+
Configure empresa, oferta, ICP, persona, canal, origem, etapa, awareness, complexidade, ticket, ciclo, região e limites de compliance. Para cada etapa, registre objetivo, dono, critérios de entrada e saída, abertura, banco de perguntas, evidências, campos SPIN/BANT, transição, objeções, prova autorizada, microcompromisso, registro de CRM, handoff/SLA e próximo passo.
|
|
24
|
+
|
|
25
|
+
Os três estágios ZAIP são: descoberta e pré-qualificação (dor, urgência e contato adequado); alinhamento e qualificação (fit e solução antes de preço, com handoff definido); e fechamento e negociação (closer, preço aprovado, objeções e próximo passo autorizado). Rotas explícitas para `not-qualified`, `nurture` e `no-decision` evitam fabricar avanço de pipeline.
|
|
26
|
+
|
|
27
|
+
### Contrato de saída do script
|
|
28
|
+
|
|
29
|
+
Um script reutilizável retorna campos configuráveis: `empresa`, `oferta`, `ICP`, `persona`, `canal`, `origem`, `etapa`, `awareness`, `complexidade`, `ticket`, `ciclo`, `região`, `compliance`, `objetivo`, `dono`, `entry_criteria`, `abertura`, `perguntas`, `evidências`, `BANT`, `SPIN`, `objeções`, `prova_autorizada`, `microcompromisso`, `exit_criteria`, `CRM`, `handoff_SLA` e `next_step`. O valor de cada campo pode ser placeholder neutro; campos ausentes não devem ser preenchidos por inferência.
|
|
30
|
+
|
|
31
|
+
## Qualificação curta: outline configurável
|
|
32
|
+
|
|
33
|
+
O modelo abaixo usa uma duração curta configurável (por exemplo, dez minutos), sem promessa rígida.
|
|
34
|
+
|
|
35
|
+
1. Confirme contexto e permissão para a conversa.
|
|
36
|
+
2. Declare a agenda ou objetivo em termos neutros.
|
|
37
|
+
3. Verifique empresa, papel e origem conhecidos.
|
|
38
|
+
4. Explore situação e prioridade atual.
|
|
39
|
+
5. Pergunte por problema ou impacto já declarado.
|
|
40
|
+
6. Investigue implicações sem presumir perda, risco ou urgência.
|
|
41
|
+
7. Convide a pessoa a definir o valor de uma solução adequada.
|
|
42
|
+
8. Registre participantes, processo decisório e BANT conhecido, desconhecido ou não aplicável.
|
|
43
|
+
9. Recapitule somente o que foi confirmado e cheque o fit.
|
|
44
|
+
10. Acorde informações obrigatórias, microcompromisso e próximo passo autorizado.
|
|
45
|
+
|
|
46
|
+
Os itens 1–3 formam abertura/contexto; 4–8, diagnóstico; e 9–10, preparação/transição.
|
|
47
|
+
|
|
48
|
+
SPIN organiza um banco de perguntas adaptável: Situation busca contexto já conhecido; Problem explora dificuldade declarada; Implication pergunta por consequências sem alegá-las; Need-payoff convida a pessoa a descrever valor. BANT registra Budget, Authority, Need e Timing com estado `known`, `unknown` ou `not-applicable`, fonte e data. Esses estados são evidência ou lacuna, nunca justificativa para pressão.
|
|
49
|
+
|
|
50
|
+
| Awareness | Narrativa | CTA |
|
|
51
|
+
| --- | --- | --- |
|
|
52
|
+
| unaware | Contexto e hipótese aberta, sem presumir problema | Pedir permissão para explorar relevância |
|
|
53
|
+
| problem-aware | Dor já declarada e impacto confirmado | Convidar diagnóstico adicional |
|
|
54
|
+
| solution-aware | Critérios e alternativas reconhecidas | Alinhar critérios de avaliação |
|
|
55
|
+
| product-aware | Oferta e fit sob análise | Confirmar lacunas e próximo passo |
|
|
56
|
+
| most-aware | Informação previamente confirmada | Propor ação permitida e reversível |
|
|
57
|
+
|
|
58
|
+
## Fechamento e negociação: outline configurável
|
|
59
|
+
|
|
60
|
+
Um fechamento mais longo pode seguir: (1) rapport e contexto; (2) diagnóstico de dor, impacto e prioridade; (3) riscos e acordo sobre o problema; (4) solução ligada apenas às dores confirmadas; (5) prova autorizada; (6) objeções antes de preço; (7) preço e escopo aprovados; (8) negociação dentro da autoridade; e (9) handoff de proposta ou contrato autorizado. Não inclua depoimentos, ROI, escassez, descontos, links de pagamento ou alegações legais sem evidência e autorização.
|
|
61
|
+
|
|
62
|
+
## Checklist de QA
|
|
63
|
+
|
|
64
|
+
- Cada etapa contém dono, entrada, saída, CRM e handoff/SLA.
|
|
65
|
+
- Perguntas e transições permanecem adaptáveis; não simulam necessidade, urgência ou consciência.
|
|
66
|
+
- BANT/SPIN distinguem evidência de lacuna e não usam coerção.
|
|
67
|
+
- Preço, proposta, desconto, contrato e negociação permanecem sob aprovação e autoridade explícitas.
|
|
68
|
+
- Provas, ROI, depoimentos e claims legais só aparecem quando autorizados e rastreáveis.
|
|
69
|
+
- Rotas `not-qualified`, `nurture` e `no-decision` existem e não são tratadas como falha do prospect.
|
|
70
|
+
|
|
71
|
+
## Referências metodológicas
|
|
72
|
+
|
|
73
|
+
- Predictable Revenue, [Sales Development Methodology](https://predictablerevenue.com/methodology/): referência para separar princípios estratégicos de playbook e para os blocos targeting, tools, prospecting, qualification e follow-through.
|
|
74
|
+
- Predictable Revenue, [Specialize Your Sales Roles](https://predictablerevenue.com/guides/specialize-your-sales-roles/): referência para especialização de papéis e handoffs entre funções comerciais.
|
|
75
|
+
- Huthwaite International, [origem do acrônimo SPIN](https://www.huthwaiteinternational.com/blog/spin-acronym): referência para os conceitos Situation, Problem, Implication e Need-payoff.
|
|
76
|
+
|
|
77
|
+
As fontes são referência conceitual. Não reproduza conteúdo proprietário, não converta seus exemplos em regras rígidas e não introduza afirmações, nomes, preços, descontos, links ou obrigações externas.
|
|
@@ -5,6 +5,11 @@ description: Install, diagnose, migrate, upgrade, or roll back ZAIP configuratio
|
|
|
5
5
|
|
|
6
6
|
# Configurar ZAIP-AIOS
|
|
7
7
|
|
|
8
|
+
For the isolated SQLite dashboard, also discover and use `$zaip-skill-sqlite-read-model`.
|
|
9
|
+
The setup must verify Node.js 22+, install the LTS release with `winget` when the user has
|
|
10
|
+
authorized automatic prerequisite installation, and create the disposable database only from
|
|
11
|
+
canonical `.agents/records` and `.agents/config` sources.
|
|
12
|
+
|
|
8
13
|
1. Faça dry-run, descubra a versão/layout e rejeite conflitos de checksum, ownership ou arquivos divergentes do usuário.
|
|
9
14
|
2. Instale/valide `config/project.yaml`, `config/framework.lock.yaml`, as cinco Rules core diretamente em `rules/`, as Rules locais fora do lock preservadas, todos os Requirements/skills gerenciados pelo manifest, as raízes V2 de `data` e o dashboard frontend-only em `.agents/dashboard` quando ele fizer parte da distribuição.
|
|
10
15
|
3. Nunca mantenha lista fixa da quantidade de Requirements ou skills no workflow; derive o catálogo do release/lock vigente.
|
|
@@ -0,0 +1,96 @@
|
|
|
1
|
+
---
|
|
2
|
+
name: zaip-skill-sqlite-read-model
|
|
3
|
+
description: Install the Node.js prerequisite and create, incrementally update, validate, or rebuild the disposable SQLite read model from canonical ZAIP records.
|
|
4
|
+
---
|
|
5
|
+
|
|
6
|
+
# SQLite read model
|
|
7
|
+
|
|
8
|
+
Use this skill when installing, refreshing, or rebuilding the disposable SQLite
|
|
9
|
+
read model. The canonical inputs are `.agents/records` and `.agents/config`;
|
|
10
|
+
never load lifecycle overviews, dashboard projections, or other aggregates as
|
|
11
|
+
an input.
|
|
12
|
+
|
|
13
|
+
## Prerequisite and rebuild
|
|
14
|
+
|
|
15
|
+
1. Confirm Node.js 22 or newer with `node --version`. If it is absent, install
|
|
16
|
+
the LTS release with `winget install --id OpenJS.NodeJS.LTS --exact` and
|
|
17
|
+
restart the terminal if `node` is still not on `PATH`.
|
|
18
|
+
2. Rebuild the local runtime before rebuilding SQLite. The rebuild script imports
|
|
19
|
+
`packages/local-runtime/dist/server.cjs`; using an old bundle can create an
|
|
20
|
+
old schema even when `src/sqlite-read-model.ts` is current.
|
|
21
|
+
3. Prefer the normal incremental refresh on dashboard startup. Do a full rebuild
|
|
22
|
+
after any schema/view/index change or when validation detects drift.
|
|
23
|
+
4. Keep database files under `.local` (or another disposable local path),
|
|
24
|
+
untracked. Do not make DBeaver or a SQLite server a dependency.
|
|
25
|
+
|
|
26
|
+
```powershell
|
|
27
|
+
node .agents/dashboard/packages/local-runtime/scripts/build-sqlite-runtime.mjs
|
|
28
|
+
node .agents/dashboard/packages/local-runtime/scripts/rebuild-sqlite-read-model.mjs
|
|
29
|
+
```
|
|
30
|
+
|
|
31
|
+
If Windows reports `EPERM` or `EBUSY` replacing
|
|
32
|
+
`.local/dashboard-sqlite/read-model.sqlite`, a live dashboard owns that file.
|
|
33
|
+
Do not treat its old schema as validation evidence. Rebuild and validate an
|
|
34
|
+
isolated generation instead:
|
|
35
|
+
|
|
36
|
+
```powershell
|
|
37
|
+
$env:ZAIP_SQLITE_DB_PATH = (Join-Path $PWD '.local/dashboard-sqlite/read-model-verify.sqlite')
|
|
38
|
+
node .agents/dashboard/packages/local-runtime/scripts/rebuild-sqlite-read-model.mjs
|
|
39
|
+
node .agents/dashboard/packages/local-runtime/scripts/validate-sqlite-read-model.mjs
|
|
40
|
+
```
|
|
41
|
+
|
|
42
|
+
Clear `ZAIP_SQLITE_DB_PATH` after the isolated check when the shell will start
|
|
43
|
+
the normal dashboard again.
|
|
44
|
+
|
|
45
|
+
## Current persisted schema and objective verification
|
|
46
|
+
|
|
47
|
+
The current generator (`packages/local-runtime/src/sqlite-read-model.ts`) owns
|
|
48
|
+
the schema. At schema version 60 it persists exactly these tables:
|
|
49
|
+
|
|
50
|
+
- `zaip_aios_activities`
|
|
51
|
+
- `zaip_dim_zaip_agent`
|
|
52
|
+
- `zaip_dim_llm_model`
|
|
53
|
+
- `zaip_dim_provider`
|
|
54
|
+
- `cost_invocation_dimension_facts`
|
|
55
|
+
|
|
56
|
+
Temporary staging tables and compatibility aliases are connection-local and are
|
|
57
|
+
not persisted. Persisted views use exactly one `zaip_vw_` prefix; query them
|
|
58
|
+
through the documented runtime view names rather than creating duplicate
|
|
59
|
+
unprefixed objects. The generator also requires the activity, cost-dimension,
|
|
60
|
+
and unique run indexes listed below.
|
|
61
|
+
|
|
62
|
+
After every full rebuild, run this check against the same database generation.
|
|
63
|
+
It verifies database integrity, the exact table inventory, view namespace and
|
|
64
|
+
compilability, and the required indexes. It exits non-zero on drift.
|
|
65
|
+
|
|
66
|
+
```powershell
|
|
67
|
+
@'
|
|
68
|
+
import assert from 'node:assert/strict';
|
|
69
|
+
import { DatabaseSync } from 'node:sqlite';
|
|
70
|
+
import { resolve } from 'node:path';
|
|
71
|
+
|
|
72
|
+
const databasePath = process.env.ZAIP_SQLITE_DB_PATH ?? resolve('.local/dashboard-sqlite/read-model.sqlite');
|
|
73
|
+
const database = new DatabaseSync(databasePath, { readOnly: true });
|
|
74
|
+
try {
|
|
75
|
+
assert.equal(database.prepare('PRAGMA integrity_check').get().integrity_check, 'ok');
|
|
76
|
+
const objects = database.prepare("SELECT name, type FROM sqlite_master WHERE type IN ('table', 'view') AND name NOT LIKE 'sqlite_%'").all();
|
|
77
|
+
const tables = objects.filter(({ type }) => type === 'table').map(({ name }) => name).sort();
|
|
78
|
+
assert.deepEqual(tables, ['cost_invocation_dimension_facts', 'zaip_aios_activities', 'zaip_dim_llm_model', 'zaip_dim_provider', 'zaip_dim_zaip_agent']);
|
|
79
|
+
const views = objects.filter(({ type }) => type === 'view').map(({ name }) => name);
|
|
80
|
+
assert.ok(views.length > 0, 'no persisted views');
|
|
81
|
+
assert.ok(views.every((name) => name.startsWith('zaip_vw_') && !name.startsWith('zaip_vw_vw_')), 'invalid persisted-view prefix');
|
|
82
|
+
for (const name of views) database.prepare(`SELECT * FROM main."${name.replaceAll('"', '""')}" LIMIT 0`).all();
|
|
83
|
+
const indexes = new Set(database.prepare("SELECT name FROM sqlite_master WHERE type='index'").all().map(({ name }) => name));
|
|
84
|
+
for (const name of ['zaip_activities_agent_run', 'zaip_activities_task_day', 'zaip_activities_spec_day', 'zaip_activities_prd_day', 'zaip_activities_run_id', 'zaip_activities_period_invocation', 'cost_dimension_facts_day_model', 'cost_dimension_facts_day_provider', 'cost_dimension_facts_invocation']) assert.ok(indexes.has(name), `missing index ${name}`);
|
|
85
|
+
console.log(JSON.stringify({ databasePath, tableCount: tables.length, viewCount: views.length, requiredIndexCount: 9 }));
|
|
86
|
+
} finally {
|
|
87
|
+
database.close();
|
|
88
|
+
}
|
|
89
|
+
'@ | node --input-type=module
|
|
90
|
+
```
|
|
91
|
+
|
|
92
|
+
The checked-in `validate-sqlite-read-model.mjs` and
|
|
93
|
+
`test-sqlite-read-model.mjs` are the installation gates for schema 60. They
|
|
94
|
+
assert the five persisted tables, the `zaip_vw_` view namespace and required
|
|
95
|
+
indexes against a freshly rebuilt database. Do not use an old database or
|
|
96
|
+
weaken those assertions to hide a schema mismatch.
|
|
@@ -0,0 +1,18 @@
|
|
|
1
|
+
import { execFileSync } from "node:child_process";
|
|
2
|
+
|
|
3
|
+
const minimumMajor = 22;
|
|
4
|
+
function version() {
|
|
5
|
+
try { return execFileSync(process.execPath, ["--version"], { encoding: "utf8" }).trim(); } catch { return null; }
|
|
6
|
+
}
|
|
7
|
+
const current = version();
|
|
8
|
+
if (current && Number.parseInt(current.slice(1), 10) >= minimumMajor) {
|
|
9
|
+
process.stdout.write(`${current} is ready\n`);
|
|
10
|
+
process.exit(0);
|
|
11
|
+
}
|
|
12
|
+
if (process.platform !== "win32") throw new Error(`Node.js ${minimumMajor}+ is required; automatic installation is only configured for Windows.`);
|
|
13
|
+
try {
|
|
14
|
+
execFileSync("winget", ["install", "--id", "OpenJS.NodeJS.LTS", "--exact", "--accept-source-agreements", "--accept-package-agreements"], { stdio: "inherit" });
|
|
15
|
+
} catch (error) {
|
|
16
|
+
throw new Error("Node.js 22+ is missing and winget could not install the LTS release. Install Node.js manually and retry.", { cause: error });
|
|
17
|
+
}
|
|
18
|
+
process.stdout.write("Node.js LTS installation completed. Restart the terminal before running the SQLite generator.\n");
|
|
@@ -20,6 +20,7 @@ Use esta pagina como roteador de baixo custo de tokens.
|
|
|
20
20
|
| Diagnosticar problemas | `guides/14-troubleshooting.md` |
|
|
21
21
|
| Configurar MCPs, APIs e Codex | `guides/15-tools-e-codex.md` |
|
|
22
22
|
| Entender status, Runs e reconciliação | `guides/16-lifecycle-e-reconciliacao.md` |
|
|
23
|
+
| Entender tokens, precificacao e conversao de moeda | `guides/17-como-o-custo-e-calculado.md` |
|
|
23
24
|
| Escolher MCP ou API | `../tools/catalog.yaml` |
|
|
24
25
|
|
|
25
26
|
Antes de agir, prevalecem `../config/project.yaml`, as Rules aplicaveis e os
|