@zaip-ai/cli 1.3.0 → 1.3.2

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.
Files changed (258) hide show
  1. package/README.md +3 -2
  2. package/dist/services/agent-adapters.js +1 -1
  3. package/dist/services/agent-adapters.js.map +1 -1
  4. package/dist/services/agent-adapters.test.js +2 -1
  5. package/dist/services/agent-adapters.test.js.map +1 -1
  6. package/dist/services/codex-pre-tool-hook-template.d.ts.map +1 -1
  7. package/dist/services/codex-pre-tool-hook-template.js +89 -7
  8. package/dist/services/codex-pre-tool-hook-template.js.map +1 -1
  9. package/dist/services/codex-rules.d.ts +1 -1
  10. package/dist/services/codex-rules.d.ts.map +1 -1
  11. package/dist/services/codex-rules.js +7 -0
  12. package/dist/services/codex-rules.js.map +1 -1
  13. package/dist/services/install-agents-template.d.ts.map +1 -1
  14. package/dist/services/install-agents-template.js +1 -0
  15. package/dist/services/install-agents-template.js.map +1 -1
  16. package/dist/services/runtime-template.test.js +31 -7
  17. package/dist/services/runtime-template.test.js.map +1 -1
  18. package/dist/services/template-manifest.d.ts.map +1 -1
  19. package/dist/services/template-manifest.js +7 -3
  20. package/dist/services/template-manifest.js.map +1 -1
  21. package/package.json +1 -1
  22. package/templates/.agents/config/agents/catalog.yaml +7 -7
  23. package/templates/.agents/config/clients/codex/agents/zaip-agent-backend.toml +2 -2
  24. package/templates/.agents/config/clients/codex/agents/zaip-agent-designer.toml +2 -2
  25. package/templates/.agents/config/clients/codex/agents/zaip-agent-frontend.toml +8 -8
  26. package/templates/.agents/dashboard/.zaip-managed.json +373 -205
  27. package/templates/.agents/dashboard/apps/frontend/dist/assets/{CostCalculationGuidePage-DxR_pgSV.js → CostCalculationGuidePage-ovxurkIk.js} +1 -1
  28. package/templates/.agents/dashboard/apps/frontend/dist/assets/{DashboardHelpDialog-4jZLTWE_.js → DashboardHelpDialog-BXy6nti1.js} +268 -86
  29. package/templates/.agents/dashboard/apps/frontend/dist/assets/{PricingSettingsDialog-CKcsqb-r.js → PricingSettingsDialog-vSvvOHQp.js} +1 -1
  30. package/templates/.agents/dashboard/apps/frontend/dist/assets/{ProjectSettingsPage-DmmJD2Th.js → ProjectSettingsPage-zH758vfs.js} +1 -1
  31. package/templates/.agents/dashboard/apps/frontend/dist/assets/TraceabilityWorkspace-CTH2wDs5.js +1 -0
  32. package/templates/.agents/dashboard/apps/frontend/dist/assets/{TraceabilityWorkspace-CaKwQP43.css → TraceabilityWorkspace-DvvavDLY.css} +1 -1
  33. package/templates/.agents/dashboard/apps/frontend/dist/assets/cost-monitor-DKwP1stV.js +68 -0
  34. package/templates/.agents/dashboard/apps/frontend/dist/assets/cost-monitor-PoJA2PI1.css +1 -0
  35. package/templates/.agents/dashboard/apps/frontend/dist/assets/{icons-vendor-C0fj2uU9.js → icons-vendor-B_lDDHn1.js} +1 -1
  36. package/templates/.agents/dashboard/apps/frontend/dist/assets/index-B31GMG5O.css +1 -0
  37. package/templates/.agents/dashboard/apps/frontend/dist/assets/index-CuMcoUni.js +2 -0
  38. package/templates/.agents/dashboard/apps/frontend/dist/assets/{react-vendor-BEsJ-FYH.js → react-vendor-B3TJrD4O.js} +1 -1
  39. package/templates/.agents/dashboard/apps/frontend/dist/assets/{traceability-B6y6Gw12.js → traceability-7f1j5wx3.js} +1 -1
  40. package/templates/.agents/dashboard/apps/frontend/dist/index.html +7 -7
  41. package/templates/.agents/dashboard/apps/frontend/playwright.dom.config.ts +32 -0
  42. package/templates/.agents/dashboard/apps/frontend/src/App.tsx +132 -245
  43. package/templates/.agents/dashboard/apps/frontend/src/AppOverlays.tsx +0 -21
  44. package/templates/.agents/dashboard/apps/frontend/src/DashboardAlternateContent.tsx +9 -0
  45. package/templates/.agents/dashboard/apps/frontend/src/TraceabilityWorkspace.dom.e2e.ts +56 -0
  46. package/templates/.agents/dashboard/apps/frontend/src/TraceabilityWorkspace.test.ts +18 -1
  47. package/templates/.agents/dashboard/apps/frontend/src/TraceabilityWorkspace.tsx +75 -8
  48. package/templates/.agents/dashboard/apps/frontend/src/dashboard-api.test.ts +25 -1
  49. package/templates/.agents/dashboard/apps/frontend/src/dashboard-api.ts +7 -9
  50. package/templates/.agents/dashboard/apps/frontend/src/operations-period-render.test.ts +4 -4
  51. package/templates/.agents/dashboard/apps/frontend/src/overview-status-page.test.ts +1 -1
  52. package/templates/.agents/dashboard/apps/frontend/src/snapshot-banner-semantics.test.ts +7 -0
  53. package/templates/.agents/dashboard/apps/frontend/src/snapshot-coherence.test.ts +20 -8
  54. package/templates/.agents/dashboard/apps/frontend/src/sqlite-page-export.test.ts +32 -0
  55. package/templates/.agents/dashboard/apps/frontend/src/sqlite-page-export.ts +21 -0
  56. package/templates/.agents/dashboard/apps/frontend/src/styles.css +19 -0
  57. package/templates/.agents/dashboard/apps/frontend/src/traceability-task-pagination.test.ts +32 -0
  58. package/templates/.agents/dashboard/apps/frontend/src/traceability-task-pagination.ts +36 -0
  59. package/templates/.agents/dashboard/apps/frontend/src/traceability-workspace.css +6 -2
  60. package/templates/.agents/dashboard/apps/frontend/src/use-app-cost-loaders.test.ts +48 -0
  61. package/templates/.agents/dashboard/apps/frontend/src/use-app-cost-loaders.ts +31 -27
  62. package/templates/.agents/dashboard/apps/frontend/src/use-app-trace-documents.ts +7 -1
  63. package/templates/.agents/dashboard/apps/frontend/src/use-app-work-list-page.test.ts +163 -0
  64. package/templates/.agents/dashboard/apps/frontend/src/use-app-work-list-page.ts +136 -0
  65. package/templates/.agents/dashboard/apps/frontend/src/use-operations-detail-export.ts +76 -0
  66. package/templates/.agents/dashboard/apps/frontend/src/work-list-load-dedup.test.ts +23 -0
  67. package/templates/.agents/dashboard/apps/frontend/src/work-list-load-dedup.ts +27 -0
  68. package/templates/.agents/dashboard/apps/frontend/src/work-list-pagination.test.ts +38 -14
  69. package/templates/.agents/dashboard/modules/cost-monitor/src/react/CostDeveloperAttributionPanel.tsx +60 -0
  70. package/templates/.agents/dashboard/modules/cost-monitor/src/react/CostDeveloperAttributionTable.tsx +191 -0
  71. package/templates/.agents/dashboard/modules/cost-monitor/src/react/CostFilters.loading.test.ts +14 -0
  72. package/templates/.agents/dashboard/modules/cost-monitor/src/react/CostFilters.run-page.test.ts +18 -0
  73. package/templates/.agents/dashboard/modules/cost-monitor/src/react/CostFilters.tsx +18 -3
  74. package/templates/.agents/dashboard/modules/cost-monitor/src/react/CostMonitorContent.tsx +8 -2
  75. package/templates/.agents/dashboard/modules/cost-monitor/src/react/CostMonitorLoadErrors.tsx +35 -0
  76. package/templates/.agents/dashboard/modules/cost-monitor/src/react/CostMonitorPage.test.ts +47 -1
  77. package/templates/.agents/dashboard/modules/cost-monitor/src/react/CostMonitorPage.tsx +50 -58
  78. package/templates/.agents/dashboard/modules/cost-monitor/src/react/CostTableLoading.test.ts +132 -0
  79. package/templates/.agents/dashboard/modules/cost-monitor/src/react/CostTableLoading.tsx +70 -0
  80. package/templates/.agents/dashboard/modules/cost-monitor/src/react/CostTables.test.ts +128 -138
  81. package/templates/.agents/dashboard/modules/cost-monitor/src/react/CostTables.tsx +17 -67
  82. package/templates/.agents/dashboard/modules/cost-monitor/src/react/cost-monitor-copy.ts +2 -0
  83. package/templates/.agents/dashboard/modules/cost-monitor/src/react/cost-monitor-views.ts +3 -1
  84. package/templates/.agents/dashboard/modules/cost-monitor/src/react/cost-page-range.ts +35 -0
  85. package/templates/.agents/dashboard/modules/cost-monitor/src/react/use-compact-cost-page.ts +16 -4
  86. package/templates/.agents/dashboard/modules/cost-monitor/src/react/use-cost-group-page.test.ts +37 -2
  87. package/templates/.agents/dashboard/modules/cost-monitor/src/react/use-cost-group-page.ts +44 -8
  88. package/templates/.agents/dashboard/modules/cost-monitor/src/react/use-cost-run-page.ts +6 -1
  89. package/templates/.agents/dashboard/modules/operations/src/contracts.ts +20 -3
  90. package/templates/.agents/dashboard/modules/operations/src/react/DeveloperAttributionPanel.test.ts +54 -0
  91. package/templates/.agents/dashboard/modules/operations/src/react/DeveloperAttributionPanel.tsx +247 -0
  92. package/templates/.agents/dashboard/modules/operations/src/react/OperationsMainContent.tsx +39 -13
  93. package/templates/.agents/dashboard/modules/operations/src/react/OperationsOverview.helpers.tsx +107 -2
  94. package/templates/.agents/dashboard/modules/operations/src/react/OperationsOverview.macro-metrics.test.ts +55 -0
  95. package/templates/.agents/dashboard/modules/operations/src/react/OperationsOverview.test.ts +20 -28
  96. package/templates/.agents/dashboard/modules/operations/src/react/OperationsOverview.tsx +162 -165
  97. package/templates/.agents/dashboard/modules/operations/src/react/OperationsOverviewTopPanel.tsx +127 -0
  98. package/templates/.agents/dashboard/modules/operations/src/react/OperationsPage.tsx +13 -46
  99. package/templates/.agents/dashboard/modules/operations/src/react/OperationsPageOverview.tsx +3 -0
  100. package/templates/.agents/dashboard/modules/operations/src/react/PagedWorkList.test.tsx +43 -0
  101. package/templates/.agents/dashboard/modules/operations/src/react/PagedWorkList.tsx +181 -0
  102. package/templates/.agents/dashboard/modules/operations/src/react/UnifiedWorkList.test.ts +4 -2
  103. package/templates/.agents/dashboard/modules/operations/src/react/UnifiedWorkList.tsx +13 -0
  104. package/templates/.agents/dashboard/modules/operations/src/react/developer-identities.test.ts +18 -0
  105. package/templates/.agents/dashboard/modules/operations/src/react/developer-identities.ts +30 -0
  106. package/templates/.agents/dashboard/modules/operations/src/react/execution-metrics.ts +1 -0
  107. package/templates/.agents/dashboard/modules/operations/src/react/export/ExcelExportAction.test.ts +8 -0
  108. package/templates/.agents/dashboard/modules/operations/src/react/export/ExcelExportAction.tsx +3 -0
  109. package/templates/.agents/dashboard/modules/operations/src/react/export/export-layout.test.ts +14 -5
  110. package/templates/.agents/dashboard/modules/operations/src/react/index.ts +1 -0
  111. package/templates/.agents/dashboard/modules/operations/src/react/operations-coverage-toast.test.ts +4 -3
  112. package/templates/.agents/dashboard/modules/operations/src/react/operations-date-filters.css +1 -1
  113. package/templates/.agents/dashboard/modules/operations/src/react/operations-overview-period-filter.test.ts +21 -11
  114. package/templates/.agents/dashboard/modules/operations/src/react/operations-overview.css +4 -0
  115. package/templates/.agents/dashboard/modules/operations/src/react/operations-page-contract.ts +8 -1
  116. package/templates/.agents/dashboard/modules/operations/src/react/operations-view-order.test.ts +1 -0
  117. package/templates/.agents/dashboard/modules/operations/src/react/period-summary.ts +1 -0
  118. package/templates/.agents/dashboard/modules/operations/src/server/metric-coverage.ts +1 -0
  119. package/templates/.agents/dashboard/packages/local-runtime/dist/server.cjs +527 -335
  120. package/templates/.agents/dashboard/packages/local-runtime/dist/sqlite-read-model.cjs +501 -309
  121. package/templates/.agents/dashboard/packages/local-runtime/gitignore.template +2 -0
  122. package/templates/.agents/dashboard/packages/local-runtime/scripts/rebuild-sqlite-read-model.mjs +3 -1
  123. package/templates/.agents/dashboard/packages/local-runtime/scripts/test-sqlite-read-model.mjs +3 -3
  124. package/templates/.agents/dashboard/packages/local-runtime/scripts/validate-sqlite-read-model.mjs +25 -15
  125. package/templates/.agents/dashboard/packages/local-runtime/server.mjs +527 -335
  126. package/templates/.agents/dashboard/packages/local-runtime/src/server-board.test.ts +34 -0
  127. package/templates/.agents/dashboard/packages/local-runtime/src/server-board.ts +15 -8
  128. package/templates/.agents/dashboard/packages/local-runtime/src/server-classification-page.test.ts +87 -0
  129. package/templates/.agents/dashboard/packages/local-runtime/src/server-period-macro-metric.test.ts +44 -0
  130. package/templates/.agents/dashboard/packages/local-runtime/src/server-period-macro-metric.ts +125 -0
  131. package/templates/.agents/dashboard/packages/local-runtime/src/server-reconciliation-refresh.test.ts +66 -0
  132. package/templates/.agents/dashboard/packages/local-runtime/src/server-request-authority.test.ts +61 -0
  133. package/templates/.agents/dashboard/packages/local-runtime/src/server-request-authority.ts +18 -0
  134. package/templates/.agents/dashboard/packages/local-runtime/src/server-run-projections.test.ts +42 -0
  135. package/templates/.agents/dashboard/packages/local-runtime/src/server-snapshot-refresh.ts +97 -0
  136. package/templates/.agents/dashboard/packages/local-runtime/src/server-snapshot.test.ts +3 -1
  137. package/templates/.agents/dashboard/packages/local-runtime/src/server-sqlite-task-trace.ts +91 -0
  138. package/templates/.agents/dashboard/packages/local-runtime/src/server.test-fixtures.ts +36 -0
  139. package/templates/.agents/dashboard/packages/local-runtime/src/server.test.ts +98 -123
  140. package/templates/.agents/dashboard/packages/local-runtime/src/server.ts +111 -135
  141. package/templates/.agents/dashboard/packages/local-runtime/src/sqlite-artifact-counts.ts +28 -0
  142. package/templates/.agents/dashboard/packages/local-runtime/src/sqlite-cost-agent-page.test.ts +63 -0
  143. package/templates/.agents/dashboard/packages/local-runtime/src/sqlite-cost-agent-page.ts +109 -0
  144. package/templates/.agents/dashboard/packages/local-runtime/src/sqlite-cost-aggregates.ts +497 -0
  145. package/templates/.agents/dashboard/packages/local-runtime/src/sqlite-cost-fast-page-parity.test-support.ts +65 -0
  146. package/templates/.agents/dashboard/packages/local-runtime/src/sqlite-cost-group-page.test.ts +176 -0
  147. package/templates/.agents/dashboard/packages/local-runtime/src/sqlite-cost-group-page.ts +119 -0
  148. package/templates/.agents/dashboard/packages/local-runtime/src/sqlite-cost-group-projection.ts +41 -0
  149. package/templates/.agents/dashboard/packages/local-runtime/src/sqlite-cost-invocation-page.test.ts +16 -0
  150. package/templates/.agents/dashboard/packages/local-runtime/src/sqlite-cost-invocation-page.ts +29 -0
  151. package/templates/.agents/dashboard/packages/local-runtime/src/sqlite-first-fold-cache.ts +355 -0
  152. package/templates/.agents/dashboard/packages/local-runtime/src/sqlite-first-fold-persistence.ts +121 -0
  153. package/templates/.agents/dashboard/packages/local-runtime/src/sqlite-first-fold-timing.ts +27 -0
  154. package/templates/.agents/dashboard/packages/local-runtime/src/sqlite-operations-projection.ts +15 -0
  155. package/templates/.agents/dashboard/packages/local-runtime/src/sqlite-operations-work-list.test.ts +293 -0
  156. package/templates/.agents/dashboard/packages/local-runtime/src/sqlite-operations-work-list.ts +371 -0
  157. package/templates/.agents/dashboard/packages/local-runtime/src/sqlite-read-model-cache.test-support.ts +23 -0
  158. package/templates/.agents/dashboard/packages/local-runtime/src/sqlite-read-model-first-fold-types.ts +89 -0
  159. package/templates/.agents/dashboard/packages/local-runtime/src/sqlite-read-model-multi-provider-fixture.ts +227 -0
  160. package/templates/.agents/dashboard/packages/local-runtime/src/sqlite-read-model-multi-provider.test.ts +691 -0
  161. package/templates/.agents/dashboard/packages/local-runtime/src/sqlite-read-model-source-fingerprint.ts +81 -0
  162. package/templates/.agents/dashboard/packages/local-runtime/src/sqlite-read-model.test.ts +440 -863
  163. package/templates/.agents/dashboard/packages/local-runtime/src/sqlite-read-model.ts +1120 -1086
  164. package/templates/.agents/dashboard/packages/local-runtime/src/sqlite-snapshot-cache.ts +129 -0
  165. package/templates/.agents/dashboard/packages/local-runtime/src/sqlite-snapshot-install.test.ts +26 -0
  166. package/templates/.agents/dashboard/packages/local-runtime/src/sqlite-snapshot-install.ts +28 -0
  167. package/templates/.agents/dashboard/packages/local-runtime/src/sqlite-snapshot-seed.test.ts +116 -0
  168. package/templates/.agents/dashboard/packages/local-runtime/start-dashboard-launch-page.mjs +146 -0
  169. package/templates/.agents/dashboard/packages/local-runtime/start-dashboard-launch-page.test.mjs +165 -0
  170. package/templates/.agents/dashboard/packages/local-runtime/start-dashboard-refresh.mjs +140 -0
  171. package/templates/.agents/dashboard/packages/local-runtime/start-dashboard.mjs +188 -299
  172. package/templates/.agents/dashboard/packages/local-runtime/start-dashboard.test.mjs +51 -70
  173. package/templates/.agents/dashboard/packages/windows-launcher/Program.cs +5 -2
  174. package/templates/.agents/dashboard/tests/e2e/playwright.config.ts +4 -1
  175. package/templates/.agents/dashboard/tests/e2e/specs/cost-monitor-loading.spec.ts +142 -0
  176. package/templates/.agents/dashboard/tests/e2e/specs/cost-monitor-pagination.spec.ts +232 -0
  177. package/templates/.agents/dashboard/tests/e2e/specs/dashboard-performance-matrix.spec.ts +743 -0
  178. package/templates/.agents/dashboard/tests/e2e/specs/dashboard.spec.ts +183 -210
  179. package/templates/.agents/dashboard/zaip-dashboard-windows.exe +0 -0
  180. package/templates/.agents/requirements/autonomous-assurance.md +6 -6
  181. package/templates/.agents/requirements/comparative-audit.md +1 -1
  182. package/templates/.agents/requirements/context-engine.md +1 -1
  183. package/templates/.agents/requirements/cost-observability.md +1 -1
  184. package/templates/.agents/requirements/dashboard-launch.md +1 -1
  185. package/templates/.agents/requirements/data-export.md +1 -1
  186. package/templates/.agents/requirements/design-system.md +1 -1
  187. package/templates/.agents/requirements/execution-engine.md +3 -3
  188. package/templates/.agents/requirements/kanban-dashboard.md +10 -2
  189. package/templates/.agents/requirements/model-orchestration.md +1 -1
  190. package/templates/.agents/requirements/public-distribution.md +1 -1
  191. package/templates/.agents/requirements/software-architecture.md +1 -1
  192. package/templates/.agents/requirements/strategic-improvements.md +1 -1
  193. package/templates/.agents/requirements/work-lifecycle.md +4 -4
  194. package/templates/.agents/requirements/zaip-strategic-95.md +1 -1
  195. package/templates/.agents/rules/dashboard-ui-consistency.md +14 -0
  196. package/templates/.agents/rules/frontend-lite.md +4 -4
  197. package/templates/.agents/rules/run-lifecycle-closure.md +4 -4
  198. package/templates/.agents/runtime/bin/zaip.mjs +1137 -1037
  199. package/templates/.agents/runtime/checksums.sha256 +2 -2
  200. package/templates/.agents/runtime/provenance.json +2 -2
  201. package/templates/.agents/skills/criar-pasta-obsidian/scripts/generate-obsidian-vault.test.mjs +20 -16
  202. package/templates/.agents/skills/zaip-skill-agent-catalog/SKILL.md +22 -0
  203. package/templates/.agents/skills/zaip-skill-agent-catalog/agents/openai.yaml +4 -0
  204. package/templates/.agents/skills/zaip-skill-author-skills/SKILL.md +3 -2
  205. package/templates/.agents/skills/zaip-skill-author-skills/scripts/audit-skill-catalog.mjs +49 -0
  206. package/templates/.agents/skills/zaip-skill-author-skills/scripts/author-skill-scripts.test.mjs +27 -0
  207. package/templates/.agents/skills/zaip-skill-author-skills/scripts/run-skill-tests.mjs +37 -0
  208. package/templates/.agents/skills/zaip-skill-backend/SKILL.md +1 -0
  209. package/templates/.agents/skills/zaip-skill-change/SKILL.md +1 -1
  210. package/templates/.agents/skills/zaip-skill-change/references/observable-evidence.md +83 -0
  211. package/templates/.agents/skills/zaip-skill-dashboard-diagnostics/SKILL.md +22 -0
  212. package/templates/.agents/skills/zaip-skill-dashboard-diagnostics/agents/openai.yaml +4 -0
  213. package/templates/.agents/skills/zaip-skill-execution/SKILL.md +1 -1
  214. package/templates/.agents/skills/zaip-skill-frontend/SKILL.md +4 -3
  215. package/templates/.agents/skills/zaip-skill-frontend/agents/openai.yaml +2 -2
  216. package/templates/.agents/skills/zaip-skill-github-deploy/SKILL.md +10 -10
  217. package/templates/.agents/skills/zaip-skill-lifecycle-closure/SKILL.md +27 -0
  218. package/templates/.agents/skills/zaip-skill-lifecycle-closure/agents/openai.yaml +4 -0
  219. package/templates/.agents/skills/zaip-skill-prd/SKILL.md +4 -0
  220. package/templates/.agents/skills/zaip-skill-reconcile-telemetry/scripts/reconcile-local-telemetry.mjs +72 -22
  221. package/templates/.agents/skills/zaip-skill-reconcile-telemetry/scripts/reconcile-telemetry-explicit-recovery.mjs +223 -0
  222. package/templates/.agents/skills/zaip-skill-reconcile-telemetry/scripts/reconcile-telemetry-lib.mjs +42 -1
  223. package/templates/.agents/skills/zaip-skill-reconcile-telemetry/scripts/reconcile-telemetry-lib.test.mjs +101 -0
  224. package/templates/.agents/skills/zaip-skill-reconcile-telemetry/scripts/reconcile-telemetry-remeasurement.test.mjs +53 -0
  225. package/templates/.agents/skills/zaip-skill-release-qualification/SKILL.md +20 -0
  226. package/templates/.agents/skills/zaip-skill-release-qualification/agents/openai.yaml +4 -0
  227. package/templates/.agents/skills/zaip-skill-review/SKILL.md +5 -0
  228. package/templates/.agents/skills/zaip-skill-rules/SKILL.md +1 -1
  229. package/templates/.agents/skills/zaip-skill-spec/SKILL.md +4 -0
  230. package/templates/.agents/skills/zaip-skill-sqlite-read-model/SKILL.md +22 -90
  231. package/templates/.agents/zaip-aios/INDEX.md +57 -32
  232. package/templates/.agents/zaip-aios/README.md +22 -12
  233. package/templates/.agents/zaip-aios/guides/02-requirements.md +5 -0
  234. package/templates/.agents/zaip-aios/guides/06-execucao.md +13 -4
  235. package/templates/.agents/zaip-aios/guides/07-revisao-e-validacao.md +7 -0
  236. package/templates/.agents/zaip-aios/guides/10-seguranca.md +23 -0
  237. package/templates/.agents/zaip-aios/guides/11-observabilidade-e-custos.md +6 -6
  238. package/templates/.agents/zaip-aios/guides/13-boas-praticas.md +3 -0
  239. package/templates/.agents/zaip-aios/guides/16-lifecycle-e-reconciliacao.md +12 -3
  240. package/templates/.agents/zaip-aios/guides/17-como-o-custo-e-calculado.md +5 -5
  241. package/templates/.agents/zaip-aios/guides/19-assurance-e-autonomia.md +23 -0
  242. package/templates/.agents/zaip-aios/guides/20-instalacao-detalhada.md +44 -8
  243. package/templates/.agents/zaip-aios/guides/21-telemetria-monitor-custos.md +8 -14
  244. package/templates/.agents/zaip-aios/guides/22-fluxos-e-roteamento.md +5 -0
  245. package/templates/.agents/zaip-aios/guides/23-orquestracao-de-modelos.md +6 -6
  246. package/templates/.agents/zaip-aios/guides/24-calculo-de-custos-openai.md +8 -8
  247. package/templates/.agents/zaip-aios/guides/25-fontes-de-precos-openai.md +3 -2
  248. package/templates/.agents/zaip-aios/guides/26-qualidade-e-release.md +92 -10
  249. package/templates/.agents/zaip-aios/guides/27-telemetria-git-native.md +8 -3
  250. package/templates/.agents/zaip-aios/guides/28-lifecycle-completo.md +5 -0
  251. package/templates/template-manifest.json +555 -170
  252. package/templates/.agents/dashboard/apps/frontend/dist/assets/TraceabilityWorkspace-BwtitWa_.js +0 -1
  253. package/templates/.agents/dashboard/apps/frontend/dist/assets/cost-monitor-BZ5WdaMN.css +0 -1
  254. package/templates/.agents/dashboard/apps/frontend/dist/assets/cost-monitor-N5Csr0RP.js +0 -68
  255. package/templates/.agents/dashboard/apps/frontend/dist/assets/index-C4aIB1PV.js +0 -2
  256. package/templates/.agents/dashboard/apps/frontend/dist/assets/index-DK_enB5Z.css +0 -1
  257. package/templates/.agents/dashboard/apps/frontend/src/use-idle-cost-prefetch.ts +0 -45
  258. package/templates/.agents/dashboard/packages/local-runtime/dist/server.cjs.metafile.json +0 -7333
@@ -36,6 +36,13 @@ export function averageObserved(values: readonly (number | null)[]): number | nu
36
36
  : observed.reduce((total, value) => total + value, 0) / observed.length;
37
37
  }
38
38
 
39
+ export function sumKnownOverviewMetric(values: readonly (number | null)[]): number | null {
40
+ return values.reduce<number | null>(
41
+ (total, value) => (value === null ? total : (total ?? 0) + value),
42
+ null,
43
+ );
44
+ }
45
+
39
46
  export function overviewMetricAverages(
40
47
  totals: { durationMs: number | null; tokens: number | null; costBrl: number | null },
41
48
  selectedCount: number | null,
@@ -50,6 +57,13 @@ export function overviewMetricAverages(
50
57
  };
51
58
  }
52
59
 
60
+ export function taskMetricAverages(
61
+ totals: { durationMs: number | null; tokens: number | null; costBrl: number | null },
62
+ taskCount: number | null,
63
+ ) {
64
+ return overviewMetricAverages(totals, taskCount);
65
+ }
66
+
53
67
  export function findLatestTaskCreatedAt(
54
68
  tasks: readonly Pick<OperationsProjection["tasks"][number], "created_at">[],
55
69
  ): string | null {
@@ -298,7 +312,13 @@ export interface EntityMetric {
298
312
  id: string;
299
313
  title: string;
300
314
  durationMs: number | null;
301
- durationProvenance?: "observed" | "reconciled" | "legacy_inferred" | "estimated" | "unavailable";
315
+ durationProvenance?:
316
+ | "observed"
317
+ | "reconciled"
318
+ | "legacy_inferred"
319
+ | "shared_creation_allocation"
320
+ | "estimated"
321
+ | "unavailable";
302
322
  durationEligible?: number | null;
303
323
  durationKnown?: number | null;
304
324
  tokens: number | null;
@@ -306,6 +326,90 @@ export interface EntityMetric {
306
326
  runCount: number;
307
327
  }
308
328
 
329
+ type OverviewView = "tasks" | "specs" | "prds";
330
+
331
+ export function selectedOverviewCount(
332
+ view: OverviewView,
333
+ overviewMetrics: OperationsProjection["summary"]["overview_metrics"] | undefined,
334
+ fallback: number,
335
+ ): number | null {
336
+ if (view === "specs") return overviewMetrics?.selected_counts?.specs ?? fallback;
337
+ if (view === "prds") return overviewMetrics?.selected_counts?.prds ?? fallback;
338
+ return overviewMetrics?.task_count ?? fallback;
339
+ }
340
+
341
+ export function selectedMacroMetricTotals(entityMetrics: readonly EntityMetric[]) {
342
+ return {
343
+ durationMs: sumKnownOverviewMetric(entityMetrics.map((entity) => entity.durationMs)),
344
+ tokens: sumKnownOverviewMetric(entityMetrics.map((entity) => entity.tokens)),
345
+ costBrl: sumKnownOverviewMetric(entityMetrics.map((entity) => entity.costBrl)),
346
+ };
347
+ }
348
+
349
+ export function scopedOverviewMetric(
350
+ view: OverviewView,
351
+ macroValue: number | null | undefined,
352
+ taskValue: number | null,
353
+ ): number | null {
354
+ return view === "tasks" ? taskValue : (macroValue ?? null);
355
+ }
356
+
357
+ export function canonicalMacroMetric(
358
+ hasCanonicalAggregate: boolean,
359
+ canonicalValue: number | null | undefined,
360
+ fallbackValue: number | null,
361
+ ): number | null {
362
+ return hasCanonicalAggregate ? (canonicalValue ?? null) : fallbackValue;
363
+ }
364
+
365
+ /** Selects currency totals without treating Operations' BRL aggregate as USD. */
366
+ export function resolveOverviewCostTotal({
367
+ currency,
368
+ factualSnapshotTotal,
369
+ macroCostTotal,
370
+ overviewView,
371
+ resolvedRunTotal,
372
+ operationsBrlTotal,
373
+ }: {
374
+ currency: "BRL" | "USD";
375
+ factualSnapshotTotal: number | null | undefined;
376
+ macroCostTotal?: number | null | undefined;
377
+ overviewView?: OverviewView;
378
+ resolvedRunTotal: number | null;
379
+ operationsBrlTotal: number | null;
380
+ }): number | null {
381
+ if (overviewView !== undefined && overviewView !== "tasks") return macroCostTotal ?? null;
382
+ if (factualSnapshotTotal !== null && factualSnapshotTotal !== undefined)
383
+ return factualSnapshotTotal;
384
+ if (resolvedRunTotal !== null) return resolvedRunTotal;
385
+ return currency === "BRL" ? operationsBrlTotal : null;
386
+ }
387
+
388
+ export function partialOverviewMetrics(data: OperationsProjection) {
389
+ return data.summary.overview_metrics;
390
+ }
391
+
392
+ export function runsForOverviewView(
393
+ view: OverviewView,
394
+ tasks: OperationsProjection["tasks"],
395
+ macros: OperationsProjection["specs"] | OperationsProjection["prds"],
396
+ runs: OperationsProjection["runs"],
397
+ ): OperationsProjection["runs"] {
398
+ if (view === "tasks") {
399
+ const taskIds = new Set(tasks.map((task) => task.id));
400
+ return runs.filter((run) => run.task_id !== null && taskIds.has(run.task_id));
401
+ }
402
+ const macroIds = new Set(macros.map((macro) => macro.id));
403
+ const declaredRunIds = new Set(macros.flatMap((macro) => macro.run_ids));
404
+ return runs.filter(
405
+ (run) =>
406
+ declaredRunIds.has(run.id) ||
407
+ (view === "specs"
408
+ ? run.spec_id !== null && macroIds.has(run.spec_id)
409
+ : run.prd_id !== null && macroIds.has(run.prd_id)),
410
+ );
411
+ }
412
+
309
413
  export function summarizeTopTaskMetrics(
310
414
  topTasks: readonly { id: string; durationMs: number | null }[],
311
415
  runs: readonly {
@@ -416,9 +520,10 @@ export function overviewText(locale: OperationsLocale) {
416
520
  } as const;
417
521
  }
418
522
 
419
- export function countExecutionDays(runs: readonly { started_at: string }[]): number {
523
+ export function countExecutionDays(runs: readonly { started_at?: string }[]): number {
420
524
  const days = new Set<string>();
421
525
  for (const run of runs) {
526
+ if (run.started_at === undefined) continue;
422
527
  const date = new Date(run.started_at);
423
528
  if (Number.isNaN(date.getTime())) continue;
424
529
  days.add(`${date.getFullYear()}-${date.getMonth()}-${date.getDate()}`);
@@ -0,0 +1,55 @@
1
+ import { readFileSync } from "node:fs";
2
+ import { describe, expect, it } from "vitest";
3
+ import {
4
+ canonicalMacroMetric,
5
+ scopedOverviewMetric,
6
+ selectedMacroMetricTotals,
7
+ } from "./OperationsOverview.js";
8
+
9
+ describe("macro overview metrics", () => {
10
+ it("keeps narrowed SPEC/PRD totals scoped to returned entities", () => {
11
+ const totals = selectedMacroMetricTotals([
12
+ { id: "SPEC-1", title: "One", durationMs: null, tokens: 40, costBrl: 3, runCount: 1 },
13
+ { id: "SPEC-2", title: "Two", durationMs: null, tokens: null, costBrl: null, runCount: 0 },
14
+ ]);
15
+ expect(totals).toEqual({ durationMs: null, tokens: 40, costBrl: 3 });
16
+ expect(totals.durationMs).not.toBe(83.4 * 3_600_000);
17
+ expect(totals.tokens).not.toBe(2_200_000_000);
18
+ });
19
+
20
+ it("never substitutes global Task metrics for an unavailable macro metric", () => {
21
+ expect(scopedOverviewMetric("specs", null, 83.4 * 3_600_000)).toBeNull();
22
+ expect(scopedOverviewMetric("prds", undefined, 2_200_000_000)).toBeNull();
23
+ expect(scopedOverviewMetric("tasks", null, 83.4 * 3_600_000)).toBe(83.4 * 3_600_000);
24
+ expect(canonicalMacroMetric(true, null, 83.4 * 3_600_000)).toBeNull();
25
+ expect(canonicalMacroMetric(true, undefined, 2_200_000_000)).toBeNull();
26
+ expect(canonicalMacroMetric(false, undefined, 2_200_000_000)).toBe(2_200_000_000);
27
+ });
28
+
29
+ it("renders returned macros even when some durations are unavailable", () => {
30
+ const overview = readFileSync(new URL("OperationsOverview.tsx", import.meta.url), "utf8");
31
+ const topPanel = readFileSync(
32
+ new URL("OperationsOverviewTopPanel.tsx", import.meta.url),
33
+ "utf8",
34
+ );
35
+ expect(overview).toContain('overviewView !== "tasks" && aggregateTopMacros.length > 0');
36
+ expect(overview).not.toContain('overviewView !== "tasks" && runs.length === 0');
37
+ expect(topPanel).toContain("topEntities.map((entity, index)");
38
+ expect(topPanel).toMatch(/entity\.durationMs === null\s*\?\s*"0%"/);
39
+ expect(topPanel).toContain('" is-duration-unavailable"');
40
+ });
41
+
42
+ it("keeps Top 5 coverage and provenance internal while using the scoped subtitle", () => {
43
+ const overview = readFileSync(new URL("OperationsOverview.tsx", import.meta.url), "utf8");
44
+ const topPanel = readFileSync(
45
+ new URL("OperationsOverviewTopPanel.tsx", import.meta.url),
46
+ "utf8",
47
+ );
48
+ expect(overview).toContain('"Tempo de ciclo de vida (Runs-raiz, todas as fases)."');
49
+ expect(overview).toContain('"Lifecycle time (root Runs, all phases)."');
50
+ expect(topPanel).toContain(`<span>{\`#\${index + 1} \${entity.id.slice(-4)}\`}</span>`);
51
+ expect(`${overview}\n${topPanel}`).not.toContain("operations-top-coverage");
52
+ expect(`${overview}\n${topPanel}`).not.toContain("duração comprovada");
53
+ expect(`${overview}\n${topPanel}`).not.toContain("durationSourceLabel");
54
+ });
55
+ });
@@ -29,6 +29,9 @@ import {
29
29
  taskStatusDistribution,
30
30
  } from "./OperationsOverview.js";
31
31
 
32
+ const readOverviewSource = (file = "OperationsOverview.tsx") =>
33
+ readFileSync(new URL(file, import.meta.url), "utf8");
34
+
32
35
  describe("global card population", () => {
33
36
  it("includes conversation and planning usage but excludes them from duration", () => {
34
37
  const runs = [
@@ -97,23 +100,22 @@ describe("global card population", () => {
97
100
  });
98
101
  });
99
102
  });
100
-
101
103
  describe("partial overview charts", () => {
102
104
  it("renders aggregate Status and Classification rather than incomplete task arrays", () => {
103
- const source = readFileSync(new URL("OperationsOverview.tsx", import.meta.url), "utf8");
105
+ const source = readOverviewSource();
104
106
  expect(source).toMatch(/const taskStatusStats\s*=\s*aggregateTaskStatusCounts/);
105
107
  expect(source).toMatch(/aggregateTaskRiskCounts\s*\?/);
106
108
  expect(source).not.toContain("{overviewIsPartial ? (");
107
109
  });
108
110
  });
109
-
110
111
  describe("overview aggregate source", () => {
111
112
  it("keeps aggregate-only Top 5 USD factual and leaves a missing value unavailable", () => {
112
- const source = readFileSync(new URL("OperationsOverview.tsx", import.meta.url), "utf8");
113
+ const source = readOverviewSource();
114
+ const topPanelSource = readOverviewSource("OperationsOverviewTopPanel.tsx");
113
115
  expect(source).toMatch(
114
116
  /costBrl:\s*currency === "USD"\s*\?\s*\(metric\.total_cost_usd \?\? null\)\s*:\s*metric\.cost_brl/,
115
117
  );
116
- expect(source).toContain("topEntitiesCost === null");
118
+ expect(topPanelSource).toContain("topCost === null");
117
119
  });
118
120
 
119
121
  it("uses the factual compact USD summary when its Run rows are intentionally absent", () => {
@@ -208,8 +210,6 @@ describe("overview aggregate source", () => {
208
210
  },
209
211
  } as never);
210
212
 
211
- // The view-local collections can be incomplete on all three routes; cards
212
- // and classifications remain attached to the filtered global aggregate.
213
213
  expect(partial).toMatchObject({ task_count: 265 });
214
214
  expect(
215
215
  Object.values(partial?.task_status_counts ?? {}).reduce((sum, count) => sum + count, 0),
@@ -252,13 +252,16 @@ describe("execution average summary", () => {
252
252
  });
253
253
 
254
254
  it("uses the summary task count when the fast overview omits task records", () => {
255
- const source = readFileSync(new URL("OperationsOverview.tsx", import.meta.url), "utf8");
255
+ const source = readOverviewSource();
256
256
  const durationCard = source.slice(
257
257
  source.indexOf("hint={formatExecutionAverageHint("),
258
- source.indexOf("label={text.totalExecutionTime}"),
258
+ source.indexOf("label={", source.indexOf("hint={formatExecutionAverageHint(")),
259
259
  );
260
260
 
261
- expect(durationCard).toContain("taskCount ?? 0");
261
+ expect(source).toContain(
262
+ 'const metricPopulationCount = overviewView === "tasks" ? taskCount : selectedCount;',
263
+ );
264
+ expect(durationCard).toContain("metricPopulationCount ?? 0");
262
265
  expect(durationCard).not.toContain("tasks.length");
263
266
  });
264
267
 
@@ -329,7 +332,6 @@ describe("statusColors", () => {
329
332
  expect(statusColors.failed).toBe("#64748b");
330
333
  });
331
334
  });
332
-
333
335
  describe("overviewMetricAverages", () => {
334
336
  it("uses aggregate totals and the selected population, preserving unavailable totals", () => {
335
337
  expect(overviewMetricAverages({ durationMs: 900, tokens: 90, costBrl: 9 }, 3)).toEqual({
@@ -352,7 +354,7 @@ describe("overviewMetricAverages", () => {
352
354
  it("passes unknown totals through as unavailable instead of coercing them to zero", () => {
353
355
  const averages = overviewMetricAverages({ durationMs: null, tokens: null, costBrl: null }, 3);
354
356
  expect(averages).toEqual({ durationMs: null, tokens: null, costBrl: null });
355
- const source = readFileSync(new URL("OperationsOverview.tsx", import.meta.url), "utf8");
357
+ const source = readOverviewSource();
356
358
  expect(source).toContain(
357
359
  "durationMs: totalDurationMetric, tokens: totalTokensMetric, costBrl: totalCostMetric",
358
360
  );
@@ -360,15 +362,17 @@ describe("overviewMetricAverages", () => {
360
362
  expect(source).not.toContain("executionMetrics.durationMs ?? 0");
361
363
  });
362
364
  });
363
-
364
365
  describe("selectedOverviewCount", () => {
366
+ it("hydrates extended macro aggregates when a SPEC or PRD card is selected", () => {
367
+ const source = readOverviewSource();
368
+ expect(source).toContain('if (view !== "tasks") onLoadMacroMetrics?.();');
369
+ });
365
370
  it("uses the same server-selected SPEC/PRD population for quick and full projections", () => {
366
371
  const metrics = { selected_counts: { specs: 4, prds: 2 }, task_count: 9 } as never;
367
372
  expect(selectedOverviewCount("specs", metrics, 99)).toBe(4);
368
373
  expect(selectedOverviewCount("prds", metrics, 99)).toBe(2);
369
374
  expect(selectedOverviewCount("tasks", metrics, 99)).toBe(9);
370
375
  });
371
-
372
376
  it("falls back only when a selected count is absent", () => {
373
377
  expect(selectedOverviewCount("specs", undefined, 0)).toBe(0);
374
378
  expect(overviewMetricAverages({ durationMs: 120, tokens: null, costBrl: 6 }, 0)).toEqual({
@@ -499,20 +503,8 @@ describe("selectTopEntities", () => {
499
503
  tokens: 7,
500
504
  costBrl: 3,
501
505
  });
502
- const source = readFileSync(new URL("OperationsOverview.tsx", import.meta.url), "utf8");
503
- expect(source).toContain("formatEntityDuration(topEntitiesSummary.durationMs, locale)");
504
- });
505
- });
506
-
507
- describe("Top 5 presentation", () => {
508
- it("keeps coverage and provenance internal while using the scoped subtitle", () => {
509
- const source = readFileSync(new URL("OperationsOverview.tsx", import.meta.url), "utf8");
510
- expect(source).toContain('"Tempo de ciclo de vida (Runs-raiz, todas as fases)."');
511
- expect(source).toContain('"Lifecycle time (root Runs, all phases)."');
512
- expect(source).toContain("<span>{`#${index + 1} ${entity.id.slice(-4)}`}</span>");
513
- expect(source).not.toContain("operations-top-coverage");
514
- expect(source).not.toContain("duração comprovada");
515
- expect(source).not.toContain("durationSourceLabel");
506
+ const source = readOverviewSource("OperationsOverviewTopPanel.tsx");
507
+ expect(source).toContain("duration(summary.durationMs, locale)");
516
508
  });
517
509
  });
518
510