agentera 3.0.0-dev.7 → 3.0.0-dev.74

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 (763) hide show
  1. package/LICENSE +201 -0
  2. package/README.md +229 -22
  3. package/bundle/.agentera-build-source.json +8 -0
  4. package/bundle/CHANGELOG.md +1361 -0
  5. package/bundle/DESIGN.md +229 -0
  6. package/bundle/LICENSE +201 -0
  7. package/bundle/README.md +143 -0
  8. package/bundle/UPGRADE.md +252 -0
  9. package/bundle/extract-corpus-parity.json +2 -4
  10. package/bundle/fixtures/routing/hybrid-corpus.yaml +154 -0
  11. package/bundle/references/adapters/package-publication.json +484 -0
  12. package/bundle/references/adapters/package-registry.yaml +439 -188
  13. package/bundle/references/adapters/package-surface-characterization.md +68 -34
  14. package/bundle/references/adapters/runtime-lifecycle-adapters.yaml +74 -0
  15. package/bundle/references/adapters/runtime-lifecycle-authority.yaml +62 -0
  16. package/bundle/references/adapters/runtime-lifecycle-operation-contract.yaml +84 -0
  17. package/bundle/references/adapters/runtime-retired-resources.yaml +333 -0
  18. package/bundle/references/analysis/evidence-tier-authority.yaml +559 -0
  19. package/bundle/references/analysis/personal-glossary-evaluation-authority.yaml +175 -0
  20. package/bundle/references/analysis/personal-glossary-evaluation-corpus.yaml +291 -0
  21. package/bundle/references/analysis/personal-glossary-holdout.yaml +192 -0
  22. package/bundle/references/analysis/verification-policy.yaml +266 -0
  23. package/bundle/references/artifacts/artifact-registry-interface-model.yaml +17 -8
  24. package/bundle/references/artifacts/glossary-entry-contract.yaml +2752 -0
  25. package/bundle/references/artifacts/state-storage-authority.yaml +3061 -0
  26. package/bundle/references/artifacts/verbosity-budget-authority.yaml +42 -0
  27. package/bundle/references/cli/app-lifecycle-vocabulary.yaml +3 -4
  28. package/bundle/references/cli/capability-instruction-contract.yaml +11 -14
  29. package/bundle/references/cli/hybrid-route-contract.yaml +438 -0
  30. package/bundle/references/cli/routing-model.md +152 -93
  31. package/bundle/references/cli/trigger-schema-enrichment.md +57 -46
  32. package/bundle/references/cli/update-channels.yaml +6 -4
  33. package/bundle/references/cli/vocabulary-index.yaml +5 -7
  34. package/bundle/references/cli/vocabulary.md +52 -94
  35. package/bundle/references/meta/retained-reference-authority.yaml +166 -0
  36. package/bundle/skills/agentera/SKILL.md +183 -63
  37. package/bundle/skills/agentera/capabilities/audit/schemas/artifacts.yaml +27 -19
  38. package/bundle/skills/agentera/capabilities/audit/schemas/exit.yaml +2 -2
  39. package/bundle/skills/agentera/capabilities/audit/schemas/triggers.yaml +13 -35
  40. package/bundle/skills/agentera/capabilities/audit/schemas/validation.yaml +30 -11
  41. package/bundle/skills/agentera/capabilities/build/schemas/artifacts.yaml +44 -21
  42. package/bundle/skills/agentera/capabilities/build/schemas/exit.yaml +8 -6
  43. package/bundle/skills/agentera/capabilities/build/schemas/triggers.yaml +14 -36
  44. package/bundle/skills/agentera/capabilities/build/schemas/validation.yaml +95 -21
  45. package/bundle/skills/agentera/capabilities/design/schemas/artifacts.yaml +6 -6
  46. package/bundle/skills/agentera/capabilities/design/schemas/exit.yaml +5 -5
  47. package/bundle/skills/agentera/capabilities/design/schemas/triggers.yaml +5 -34
  48. package/bundle/skills/agentera/capabilities/design/schemas/validation.yaml +2 -2
  49. package/bundle/skills/agentera/capabilities/discuss/schemas/artifacts.yaml +17 -13
  50. package/bundle/skills/agentera/capabilities/discuss/schemas/exit.yaml +2 -2
  51. package/bundle/skills/agentera/capabilities/discuss/schemas/triggers.yaml +6 -40
  52. package/bundle/skills/agentera/capabilities/discuss/schemas/validation.yaml +72 -5
  53. package/bundle/skills/agentera/capabilities/document/schemas/artifacts.yaml +24 -17
  54. package/bundle/skills/agentera/capabilities/document/schemas/triggers.yaml +5 -35
  55. package/bundle/skills/agentera/capabilities/document/schemas/validation.yaml +13 -13
  56. package/bundle/skills/agentera/capabilities/optimize/schemas/artifacts.yaml +10 -10
  57. package/bundle/skills/agentera/capabilities/optimize/schemas/exit.yaml +2 -2
  58. package/bundle/skills/agentera/capabilities/optimize/schemas/triggers.yaml +4 -35
  59. package/bundle/skills/agentera/capabilities/optimize/schemas/validation.yaml +3 -3
  60. package/bundle/skills/agentera/capabilities/orchestrate/schemas/artifacts.yaml +34 -22
  61. package/bundle/skills/agentera/capabilities/orchestrate/schemas/exit.yaml +9 -7
  62. package/bundle/skills/agentera/capabilities/orchestrate/schemas/triggers.yaml +5 -37
  63. package/bundle/skills/agentera/capabilities/orchestrate/schemas/validation.yaml +38 -37
  64. package/bundle/skills/agentera/capabilities/plan/schemas/artifacts.yaml +20 -16
  65. package/bundle/skills/agentera/capabilities/plan/schemas/triggers.yaml +8 -31
  66. package/bundle/skills/agentera/capabilities/plan/schemas/validation.yaml +66 -6
  67. package/bundle/skills/agentera/capabilities/profile/schemas/artifacts.yaml +13 -4
  68. package/bundle/skills/agentera/capabilities/profile/schemas/exit.yaml +8 -5
  69. package/bundle/skills/agentera/capabilities/profile/schemas/triggers.yaml +8 -37
  70. package/bundle/skills/agentera/capabilities/profile/schemas/validation.yaml +67 -3
  71. package/bundle/skills/agentera/capabilities/research/schemas/artifacts.yaml +6 -6
  72. package/bundle/skills/agentera/capabilities/research/schemas/triggers.yaml +5 -29
  73. package/bundle/skills/agentera/capabilities/status/schemas/artifacts.yaml +13 -12
  74. package/bundle/skills/agentera/capabilities/status/schemas/triggers.yaml +7 -49
  75. package/bundle/skills/agentera/capabilities/vision/schemas/artifacts.yaml +8 -8
  76. package/bundle/skills/agentera/capabilities/vision/schemas/exit.yaml +7 -6
  77. package/bundle/skills/agentera/capabilities/vision/schemas/triggers.yaml +7 -39
  78. package/bundle/skills/agentera/capabilities/vision/schemas/validation.yaml +14 -16
  79. package/bundle/skills/agentera/capability_schema_contract.yaml +32 -32
  80. package/bundle/skills/agentera/protocol.yaml +4 -4
  81. package/bundle/skills/agentera/route-phrases.yaml +81 -0
  82. package/bundle/skills/agentera/schemas/artifacts/changelog.yaml +1 -0
  83. package/bundle/skills/agentera/schemas/artifacts/decisions.yaml +30 -12
  84. package/bundle/skills/agentera/schemas/artifacts/design.yaml +1 -0
  85. package/bundle/skills/agentera/schemas/artifacts/docs.yaml +7 -12
  86. package/bundle/skills/agentera/schemas/artifacts/experiments.yaml +140 -9
  87. package/bundle/skills/agentera/schemas/artifacts/glossary.yaml +87 -0
  88. package/bundle/skills/agentera/schemas/artifacts/health.yaml +56 -19
  89. package/bundle/skills/agentera/schemas/artifacts/objective.yaml +18 -4
  90. package/bundle/skills/agentera/schemas/artifacts/plan.yaml +464 -32
  91. package/bundle/skills/agentera/schemas/artifacts/progress.yaml +131 -18
  92. package/bundle/skills/agentera/schemas/artifacts/todo.yaml +302 -7
  93. package/dist/.agentera-build-source.json +8 -0
  94. package/dist/analytics/extractCorpus/cli.js +52 -11
  95. package/dist/analytics/extractCorpus/copilotSessions.js +19 -8
  96. package/dist/analytics/extractCorpus/core.js +262 -14
  97. package/dist/analytics/extractCorpus/corpus.js +57 -18
  98. package/dist/analytics/extractCorpus/coverageAudit.js +44 -45
  99. package/dist/analytics/extractCorpus/cursorSessions.js +28 -8
  100. package/dist/analytics/extractCorpus/evidenceTiers.js +709 -0
  101. package/dist/analytics/extractCorpus/extractCorpusParity.js +4 -4
  102. package/dist/analytics/extractCorpus/filesystemSources.js +5 -5
  103. package/dist/analytics/extractCorpus/index.js +4 -2
  104. package/dist/analytics/extractCorpus/jsonlSessions.js +76 -8
  105. package/dist/analytics/extractCorpus/sqliteCaps.js +0 -1
  106. package/dist/analytics/extractCorpus/sqliteSessions.js +12 -4
  107. package/dist/analytics/extractCorpus/tierReader.js +108 -0
  108. package/dist/analytics/extractCorpus.js +0 -1
  109. package/dist/analytics/glossaryAdviceResolution.js +166 -0
  110. package/dist/analytics/glossaryInputAcquisition.js +319 -0
  111. package/dist/analytics/personalGlossaryAdmission.js +113 -0
  112. package/dist/analytics/personalGlossaryCandidateProjection.js +692 -0
  113. package/dist/analytics/personalGlossaryCandidateProjectionExcerpts.js +144 -0
  114. package/dist/analytics/personalGlossaryCandidateReadView.js +23 -0
  115. package/dist/analytics/personalGlossaryCurrentGeneration.js +25 -0
  116. package/dist/analytics/personalGlossaryDecision.js +203 -0
  117. package/dist/analytics/personalGlossaryExplicit.js +788 -0
  118. package/dist/analytics/personalGlossaryExplicitMining.js +285 -0
  119. package/dist/analytics/personalGlossaryExplicitScope.js +41 -0
  120. package/dist/analytics/personalGlossaryExplicitSegments.js +418 -0
  121. package/dist/analytics/personalGlossaryExplicitTypes.js +26 -0
  122. package/dist/analytics/personalGlossaryLexicalClassifier.js +175 -0
  123. package/dist/analytics/personalGlossaryProfile.js +229 -0
  124. package/dist/analytics/personalGlossaryRecurrence.js +618 -0
  125. package/dist/analytics/personalGlossaryReviewRecordStorage.js +428 -0
  126. package/dist/analytics/personalGlossaryReviewRecords.js +332 -0
  127. package/dist/analytics/profileSignals.js +211 -0
  128. package/dist/analytics/usageStats.js +150 -23
  129. package/dist/audit/terminologyDrift.js +281 -0
  130. package/dist/bin/agentera.js +3 -2
  131. package/dist/capabilities/audit/instructions.js +16 -6
  132. package/dist/capabilities/build/instructions.js +59 -6
  133. package/dist/capabilities/design/instructions.js +3 -4
  134. package/dist/capabilities/discuss/instructions.js +29 -6
  135. package/dist/capabilities/document/instructions.js +11 -6
  136. package/dist/capabilities/index.js +20 -14
  137. package/dist/capabilities/optimize/instructions.js +14 -6
  138. package/dist/capabilities/orchestrate/instructions.js +42 -6
  139. package/dist/capabilities/plan/instructions.js +30 -3
  140. package/dist/capabilities/profile/instructions.js +104 -5
  141. package/dist/capabilities/research/instructions.js +4 -5
  142. package/dist/capabilities/status/instructions.js +15 -6
  143. package/dist/capabilities/status/startupInstructions.js +34 -0
  144. package/dist/capabilities/vision/instructions.js +3 -5
  145. package/dist/cli/appContext.js +14 -7
  146. package/dist/cli/argvalidate.js +0 -1
  147. package/dist/cli/capabilityContext/benchmark.js +5 -4
  148. package/dist/cli/capabilityContext/bespoke.js +14 -6
  149. package/dist/cli/capabilityContext/build.js +116 -42
  150. package/dist/cli/capabilityContext/closeout.js +30 -27
  151. package/dist/cli/capabilityContext/contract.js +18 -27
  152. package/dist/cli/capabilityContext/evidence.js +84 -77
  153. package/dist/cli/capabilityContext/index.js +0 -1
  154. package/dist/cli/capabilityContext/orchestration.js +42 -18
  155. package/dist/cli/capabilityContext/planState.js +89 -96
  156. package/dist/cli/capabilityContext/progress.js +51 -12
  157. package/dist/cli/capabilityContext/projectVerification.js +409 -0
  158. package/dist/cli/capabilityContext/shared.js +9 -20
  159. package/dist/cli/capabilityContext/slim.js +52 -8
  160. package/dist/cli/capabilityContext/startup.js +51 -114
  161. package/dist/cli/capabilityContext/startupAggregation.js +68 -0
  162. package/dist/cli/capabilityContext/types.js +26 -10
  163. package/dist/cli/capabilityContext.js +0 -1
  164. package/dist/cli/commands/appHome.js +0 -1
  165. package/dist/cli/commands/capability.js +2 -2
  166. package/dist/cli/commands/compact.js +163 -13
  167. package/dist/cli/commands/doctor.js +117 -11
  168. package/dist/cli/commands/durability.js +81 -0
  169. package/dist/cli/commands/glossaryAdvice.js +138 -0
  170. package/dist/cli/commands/lint.js +22 -8
  171. package/dist/cli/commands/personalGlossaryCandidateReads.js +744 -0
  172. package/dist/cli/commands/personalGlossaryDecision.js +349 -0
  173. package/dist/cli/commands/personalGlossaryPublish.js +484 -0
  174. package/dist/cli/commands/personalGlossaryReviewRecordReads.js +209 -0
  175. package/dist/cli/commands/personalGlossaryReviewRecords.js +623 -0
  176. package/dist/cli/commands/prime/briefOrientation.js +845 -0
  177. package/dist/cli/commands/prime/buildExecutionRequest.js +165 -0
  178. package/dist/cli/commands/prime/bundleStatus.js +54 -4
  179. package/dist/cli/commands/prime/collectEntityOrientation.js +326 -0
  180. package/dist/cli/commands/prime/collectOrientationState.js +126 -63
  181. package/dist/cli/commands/prime/orientationOutput.js +267 -56
  182. package/dist/cli/commands/prime/types.js +0 -1
  183. package/dist/cli/commands/prime/v1Migration.js +0 -1
  184. package/dist/cli/commands/prime.js +76 -11
  185. package/dist/cli/commands/profileGrounding.js +55 -0
  186. package/dist/cli/commands/query.js +74 -52
  187. package/dist/cli/commands/report.js +91 -21
  188. package/dist/cli/commands/route.js +142 -0
  189. package/dist/cli/commands/schema.js +436 -138
  190. package/dist/cli/commands/state/decisions.js +40 -56
  191. package/dist/cli/commands/state/docs.js +58 -85
  192. package/dist/cli/commands/state/experimentRecords.js +151 -0
  193. package/dist/cli/commands/state/experiments.js +11 -65
  194. package/dist/cli/commands/state/get.js +129 -0
  195. package/dist/cli/commands/state/health.js +11 -113
  196. package/dist/cli/commands/state/index.js +6 -41
  197. package/dist/cli/commands/state/list.js +194 -0
  198. package/dist/cli/commands/state/objective.js +21 -65
  199. package/dist/cli/commands/state/plan.js +11 -170
  200. package/dist/cli/commands/state/planTasks.js +154 -0
  201. package/dist/cli/commands/state/plans.js +154 -0
  202. package/dist/cli/commands/state/progress.js +11 -45
  203. package/dist/cli/commands/state/shared.js +0 -1
  204. package/dist/cli/commands/state/todo.js +28 -107
  205. package/dist/cli/commands/state/write.js +433 -0
  206. package/dist/cli/commands/upgrade.js +146 -5
  207. package/dist/cli/commands/upgradeVerify.js +118 -0
  208. package/dist/cli/commands/validate.js +235 -136
  209. package/dist/cli/commands/verify.js +73 -16
  210. package/dist/cli/contracts/bundleStatus.js +0 -1
  211. package/dist/cli/contracts/orientationState.js +0 -1
  212. package/dist/cli/dispatch/argvParser.js +0 -1
  213. package/dist/cli/dispatch/check.js +84 -40
  214. package/dist/cli/dispatch/commands.js +3 -3
  215. package/dist/cli/dispatch/index.js +77 -52
  216. package/dist/cli/dispatch/lifecycle.js +162 -62
  217. package/dist/cli/dispatch/prime.js +37 -2
  218. package/dist/cli/dispatch/projections.js +17 -0
  219. package/dist/cli/dispatch/shared.js +1 -2
  220. package/dist/cli/dispatch/state.js +62 -66
  221. package/dist/cli/dispatch.js +0 -1
  222. package/dist/cli/errors.js +16 -17
  223. package/dist/cli/help.js +404 -39
  224. package/dist/cli/migrationRequired.js +125 -0
  225. package/dist/cli/orientation/attention.js +19 -19
  226. package/dist/cli/orientation/corpusCoverage.js +32 -1
  227. package/dist/cli/orientation.js +346 -129
  228. package/dist/cli/planArtifacts.js +350 -0
  229. package/dist/cli/planEvidence.js +157 -0
  230. package/dist/cli/planLifecycleState.js +36 -0
  231. package/dist/cli/planTaskIndex.js +11 -0
  232. package/dist/cli/preCutoverCommand.js +32 -0
  233. package/dist/cli/prime-blob.js +71 -3
  234. package/dist/cli/profileAcquisition.js +167 -0
  235. package/dist/cli/startupCompletenessContract.js +11 -8
  236. package/dist/cli/stateQuery.js +47 -12
  237. package/dist/cli/structured.js +0 -1
  238. package/dist/cli/todoMarkdown.js +25 -12
  239. package/dist/cli/todoReadinessSelection.js +192 -0
  240. package/dist/cli/todoSeverity.js +0 -1
  241. package/dist/core/atomicWriter.js +23 -0
  242. package/dist/core/developmentChannel.js +1 -0
  243. package/dist/core/developmentInvocation.js +377 -0
  244. package/dist/core/difflib.js +0 -1
  245. package/dist/core/envPaths.js +0 -1
  246. package/dist/core/jsonValue.js +0 -1
  247. package/dist/core/paths.js +0 -1
  248. package/dist/core/pyjson.js +0 -1
  249. package/dist/core/shell.js +4 -0
  250. package/dist/core/skillIdentity.js +23 -0
  251. package/dist/core/sourceRoot.js +9 -12
  252. package/dist/core/text.js +10 -0
  253. package/dist/core/toml.js +0 -1
  254. package/dist/core/yaml.js +61 -2
  255. package/dist/eval/evalSkills.js +13 -14
  256. package/dist/eval/glossaryEvaluation.js +751 -0
  257. package/dist/eval/glossaryEvaluationProcess.js +29 -0
  258. package/dist/eval/glossaryEvaluationRunner.js +571 -0
  259. package/dist/eval/glossaryEvaluationSuccessReport.js +297 -0
  260. package/dist/eval/hybridRouteEvaluation.js +155 -0
  261. package/dist/eval/semanticEval.js +0 -1
  262. package/dist/eval/semanticFixtures.js +0 -1
  263. package/dist/hooks/common.js +3 -56
  264. package/dist/hooks/compaction/apply.js +224 -47
  265. package/dist/hooks/compaction/dryRun.js +2 -1
  266. package/dist/hooks/compaction/index.js +5 -6
  267. package/dist/hooks/compaction/parse.js +73 -6
  268. package/dist/hooks/compaction/retention.js +28 -25
  269. package/dist/hooks/compaction/status.js +145 -26
  270. package/dist/hooks/compaction/types.js +0 -1
  271. package/dist/hooks/validateArtifact/agentFacing.js +0 -1
  272. package/dist/hooks/validateArtifact/index.js +6 -65
  273. package/dist/hooks/validateArtifact/markdown.js +9 -10
  274. package/dist/hooks/validateArtifact/schema.js +96 -9
  275. package/dist/hooks/validateArtifact/traversal.js +12 -11
  276. package/dist/hooks/validateArtifact/violations.js +5 -3
  277. package/dist/migrate/v2HandoffManifest.js +8 -3
  278. package/dist/registries/activationContract.js +2 -0
  279. package/dist/registries/activationTuples.js +136 -0
  280. package/dist/registries/artifactProtocolIds.js +2 -1
  281. package/dist/registries/artifactRegistry.js +207 -60
  282. package/dist/registries/artifactSchemaProjection.js +45 -0
  283. package/dist/registries/capabilityContract.js +5 -21
  284. package/dist/registries/evaluatorHandoffContract.js +0 -1
  285. package/dist/registries/evidenceTierContract.js +375 -0
  286. package/dist/registries/explicitSegmentGrammarContract.js +619 -0
  287. package/dist/registries/glossaryAdviceContract.js +79 -0
  288. package/dist/registries/glossaryCandidateContractPaths.js +6 -0
  289. package/dist/registries/glossaryCandidateContracts.js +820 -0
  290. package/dist/registries/glossaryCandidateDecisionAuthority.js +119 -0
  291. package/dist/registries/glossaryCandidateDecisionContract.js +62 -0
  292. package/dist/registries/glossaryCandidateProjectionAuthority.js +197 -0
  293. package/dist/registries/glossaryCandidateProjectionContract.js +104 -0
  294. package/dist/registries/glossaryCaveatContract.js +67 -0
  295. package/dist/registries/glossaryConsumerContractValidation.js +787 -0
  296. package/dist/registries/glossaryEntryContract.js +759 -0
  297. package/dist/registries/glossaryEntryTemporal.js +12 -0
  298. package/dist/registries/glossaryMiningAuthority.js +764 -0
  299. package/dist/registries/glossaryProfileFullContract.js +24 -0
  300. package/dist/registries/glossaryReviewRecordsAuthority.js +426 -0
  301. package/dist/registries/glossaryReviewRecordsContract.js +129 -0
  302. package/dist/registries/glossaryTermIdentity.js +139 -0
  303. package/dist/registries/glossaryTermOccurrence.js +20 -0
  304. package/dist/registries/hybridRoute.js +274 -0
  305. package/dist/registries/hybridRouteReceipt.js +221 -0
  306. package/dist/registries/packagePublication.js +273 -0
  307. package/dist/registries/packageRegistry.js +184 -209
  308. package/dist/registries/personalGlossaryContracts.js +1 -0
  309. package/dist/registries/todoReadinessContract.js +448 -0
  310. package/dist/registries/triggerLoader.js +7 -44
  311. package/dist/registries/verbosityBudgetContract.js +205 -0
  312. package/dist/release/releaseMetadata.js +167 -10
  313. package/dist/runtime/lifecycleAdapterContract.js +457 -0
  314. package/dist/runtime/lifecycleAdapters.js +777 -0
  315. package/dist/runtime/lifecycleAuthority.js +453 -0
  316. package/dist/runtime/lifecycleOperationContract.js +123 -0
  317. package/dist/runtime/lifecycleOperations.js +634 -0
  318. package/dist/runtime/lifecycleOwnershipJournal.js +622 -0
  319. package/dist/runtime/lifecyclePublication.js +415 -0
  320. package/dist/runtime/lifecycleSnapshot.js +438 -0
  321. package/dist/runtime/nativeResourceCleanup.js +502 -0
  322. package/dist/setup/opencode.js +20 -13
  323. package/dist/setup/opencodeConstants.js +1 -0
  324. package/dist/setup/sharedSkill.js +45 -0
  325. package/dist/setup/smokeChecks.js +14 -75
  326. package/dist/state/archiveDiscovery.js +580 -0
  327. package/dist/state/archivePublication.js +225 -0
  328. package/dist/state/archiveRecovery.js +237 -0
  329. package/dist/state/archiveReplay.js +53 -0
  330. package/dist/state/canonicalMigrationRecord.js +36 -0
  331. package/dist/state/changelog.js +221 -0
  332. package/dist/state/decisionEntities.js +367 -0
  333. package/dist/state/decisionLegacyValidation.js +215 -0
  334. package/dist/state/decisionMigrationProvenance.js +199 -0
  335. package/dist/state/decisionOverlay.js +254 -0
  336. package/dist/state/decisionRevision.js +256 -0
  337. package/dist/state/decisionRevisionMigration.js +89 -0
  338. package/dist/state/directRetrieval.js +323 -0
  339. package/dist/state/durability.js +324 -0
  340. package/dist/state/entityCutover.js +459 -0
  341. package/dist/state/entityCutoverGit.js +127 -0
  342. package/dist/state/entityGlossaryAuthority.js +13 -0
  343. package/dist/state/entityListProjection.js +187 -0
  344. package/dist/state/entityListRuntimeRegistry.js +85 -0
  345. package/dist/state/entityMigrationCausality.js +97 -0
  346. package/dist/state/entityMigrationIdentity.js +5 -0
  347. package/dist/state/entityMigrationPreview.js +840 -0
  348. package/dist/state/entityMigrationTodo.js +133 -0
  349. package/dist/state/entityPublicationContext.js +859 -0
  350. package/dist/state/entityRetrievalHelp.js +506 -0
  351. package/dist/state/entityStorage.js +899 -0
  352. package/dist/state/exactReplacementRecovery.js +18 -0
  353. package/dist/state/experimentArchive.js +63 -0
  354. package/dist/state/experimentIdentity.js +202 -0
  355. package/dist/state/healthEntities.js +262 -0
  356. package/dist/state/healthEntityValidation.js +18 -0
  357. package/dist/state/healthRepair.js +69 -0
  358. package/dist/state/installRoot.js +15 -7
  359. package/dist/state/legacyEntityCutoverEvidence.js +65 -0
  360. package/dist/state/legacyIdentity.js +47 -0
  361. package/dist/state/legacySummaryRecord.js +6 -0
  362. package/dist/state/listAccounting.js +54 -0
  363. package/dist/state/listClassification.js +17 -0
  364. package/dist/state/listCursor.js +42 -0
  365. package/dist/state/listRetrieval.js +781 -0
  366. package/dist/state/migrationSourceBinding.js +30 -0
  367. package/dist/state/objectiveExperimentEntities.js +322 -0
  368. package/dist/state/planEntities.js +1027 -0
  369. package/dist/state/planIdentity.js +47 -0
  370. package/dist/state/planLineageValidation.js +52 -0
  371. package/dist/state/planReplacementTransaction.js +475 -0
  372. package/dist/state/planRetrieval.js +313 -0
  373. package/dist/state/planTaskRetrieval.js +294 -0
  374. package/dist/state/progressEntities.js +512 -0
  375. package/dist/state/progressGlossaryCaveat.js +168 -0
  376. package/dist/state/progressPublicationOrder.js +19 -0
  377. package/dist/state/progressWritePolicy.js +33 -0
  378. package/dist/state/projectRoot.js +62 -0
  379. package/dist/state/projectionPolicy.js +190 -0
  380. package/dist/state/retrievalAuthority.js +156 -0
  381. package/dist/state/safeProjectFile.js +155 -0
  382. package/dist/state/startupAnalysis/benchmark.js +70 -9
  383. package/dist/state/startupAnalysis/contract.js +44 -10
  384. package/dist/state/startupAnalysis/helpers.js +1 -2
  385. package/dist/state/startupAnalysis/index.js +0 -1
  386. package/dist/state/startupAnalysis/metrics.js +0 -1
  387. package/dist/state/startupAnalysis/records.js +0 -1
  388. package/dist/state/startupAnalysis/report.js +0 -1
  389. package/dist/state/startupAnalysis/threshold.js +13 -1
  390. package/dist/state/startupAnalysis.js +0 -1
  391. package/dist/state/startupProjection.js +499 -0
  392. package/dist/state/stateMode.js +222 -0
  393. package/dist/state/stateStorageAuthority.js +47 -0
  394. package/dist/state/summaryEntityRead.js +25 -0
  395. package/dist/state/summaryMigrationProvenance.js +66 -0
  396. package/dist/state/summarySourceRowAuthority.js +36 -0
  397. package/dist/state/todoActivationSafety.js +58 -0
  398. package/dist/state/todoDocsEntities.js +1124 -0
  399. package/dist/state/todoDocsEntityValidation.js +158 -0
  400. package/dist/state/todoMarkdownProjection.js +51 -0
  401. package/dist/state/todoReconciliationActivation.js +182 -0
  402. package/dist/state/todoReconciliationInspection.js +171 -0
  403. package/dist/state/todoReconciliationRepair.js +318 -0
  404. package/dist/state/todoReconciliationTransaction.js +595 -0
  405. package/dist/state/write/assign.js +20 -0
  406. package/dist/state/write/candidateMutation.js +269 -0
  407. package/dist/state/write/errors.js +11 -0
  408. package/dist/state/write/experimentPublication.js +192 -0
  409. package/dist/state/write/explain.js +377 -0
  410. package/dist/state/write/fields.js +61 -0
  411. package/dist/state/write/glossaryPublication.js +263 -0
  412. package/dist/state/write/grammar.js +285 -0
  413. package/dist/state/write/helpers.js +29 -0
  414. package/dist/state/write/index.js +12 -0
  415. package/dist/state/write/input.js +391 -0
  416. package/dist/state/write/lock.js +837 -0
  417. package/dist/state/write/mutation.js +234 -0
  418. package/dist/state/write/operations.js +170 -0
  419. package/dist/state/write/planEvaluation.js +128 -0
  420. package/dist/state/write/planPublication.js +179 -0
  421. package/dist/state/write/runtimeOperations.js +146 -0
  422. package/dist/state/write/serialize.js +1 -0
  423. package/dist/state/write/transaction.js +57 -0
  424. package/dist/state/write/validate.js +7 -0
  425. package/dist/upgrade/appContentRefresh.js +77 -36
  426. package/dist/upgrade/appModel.js +0 -1
  427. package/dist/upgrade/atomicWriter.js +1 -0
  428. package/dist/upgrade/bundleEvidence.js +0 -1
  429. package/dist/upgrade/channels.js +6 -9
  430. package/dist/upgrade/compatibility.js +43 -17
  431. package/dist/upgrade/doctor.js +55 -32
  432. package/dist/upgrade/doctorClassifier.js +11 -1
  433. package/dist/upgrade/installedHooksRetirement.js +46 -40
  434. package/dist/upgrade/legacyAgentCleanup.js +187 -21
  435. package/dist/upgrade/lifecycleUpgrade.js +113 -0
  436. package/dist/upgrade/migrateArtifactsV2ToV3.js +334 -64
  437. package/dist/upgrade/migrationPublication.js +122 -0
  438. package/dist/upgrade/nextMajorDoctor.js +0 -1
  439. package/dist/upgrade/npxPlatformStatus.js +2 -2
  440. package/dist/upgrade/projectIntegration.js +128 -160
  441. package/dist/upgrade/projectIntegrationDecision.js +42 -85
  442. package/dist/upgrade/retiredResourceDiagnostics.js +117 -0
  443. package/dist/upgrade/runtimeMigration.js +262 -453
  444. package/dist/upgrade/upgradeCommands.js +14 -1
  445. package/dist/upgrade/upgradeLock.js +85 -0
  446. package/dist/upgrade/upgradeOrchestrator.js +263 -59
  447. package/dist/upgrade/v3CapabilitySurface.js +2 -3
  448. package/dist/upgrade/versionResolution.js +0 -1
  449. package/dist/validate/activationArtifactEvidence.js +866 -0
  450. package/dist/validate/activationArtifactEvidenceTypes.js +12 -0
  451. package/dist/validate/activationConjunction.js +816 -0
  452. package/dist/validate/activationEvidenceManifest.js +610 -0
  453. package/dist/validate/activationPackageSemantics.js +29 -0
  454. package/dist/validate/appHomeContract.js +1 -7
  455. package/dist/validate/bootstrapAuthority.js +44 -0
  456. package/dist/validate/capability.js +11 -3
  457. package/dist/validate/crossCapability.js +14 -9
  458. package/dist/validate/retainedReferenceAuthority.js +879 -0
  459. package/dist/validate/selfAudit.js +39 -45
  460. package/dist/validate/v1LegacyCruft.js +131 -0
  461. package/dist/validate/vocabularyAuthority.js +8 -8
  462. package/package.json +39 -13
  463. package/bundle/references/adapters/cursor.md +0 -214
  464. package/bundle/references/adapters/opencode.md +0 -530
  465. package/bundle/references/adapters/package-manifest-interface-model.yaml +0 -337
  466. package/bundle/references/adapters/runtime-adapter-characterization.md +0 -79
  467. package/bundle/references/adapters/runtime-adapter-interface-model.yaml +0 -200
  468. package/bundle/references/adapters/runtime-adapter-registry.yaml +0 -554
  469. package/bundle/references/adapters/runtime-feature-parity.md +0 -189
  470. package/bundle/references/analysis/benchmark.md +0 -267
  471. package/bundle/references/analysis/startup-measurement-contract.yaml +0 -424
  472. package/bundle/references/cli/agent-ready-state-contract.yaml +0 -953
  473. package/bundle/references/cli/audience-namespace-cli-migration.yaml +0 -369
  474. package/bundle/references/cli/bundle-skill-vocabulary.yaml +0 -250
  475. package/bundle/references/cli/capability-tool-classification.yaml +0 -53
  476. package/bundle/references/cli/coexistence-probe.yaml +0 -13
  477. package/bundle/references/cli/parity-expected-actual-template.md +0 -30
  478. package/bundle/references/cli/routing-execution-vocabulary.yaml +0 -281
  479. package/bundle/references/cli/single-name-protocol.yaml +0 -42
  480. package/bundle/references/cli/upgrade-repair-wording.md +0 -45
  481. package/bundle/references/cli/v3-handoff-manifest.schema.yaml +0 -98
  482. package/bundle/references/meta/documentation-inventory.md +0 -49
  483. package/bundle/skills/agentera/.claude-plugin/plugin.json +0 -27
  484. package/bundle/skills/agentera/agents/audit.toml +0 -6
  485. package/bundle/skills/agentera/agents/build.toml +0 -6
  486. package/bundle/skills/agentera/agents/design.toml +0 -6
  487. package/bundle/skills/agentera/agents/discuss.toml +0 -6
  488. package/bundle/skills/agentera/agents/document.toml +0 -6
  489. package/bundle/skills/agentera/agents/optimize.toml +0 -6
  490. package/bundle/skills/agentera/agents/orchestrate.toml +0 -6
  491. package/bundle/skills/agentera/agents/plan.toml +0 -6
  492. package/bundle/skills/agentera/agents/profile.toml +0 -6
  493. package/bundle/skills/agentera/agents/research.toml +0 -6
  494. package/bundle/skills/agentera/agents/status.toml +0 -6
  495. package/bundle/skills/agentera/agents/vision.toml +0 -6
  496. package/bundle/skills/agentera/references/contract.md +0 -1048
  497. package/dist/analytics/extractCorpus/cli.js.map +0 -1
  498. package/dist/analytics/extractCorpus/copilotSessions.js.map +0 -1
  499. package/dist/analytics/extractCorpus/core.js.map +0 -1
  500. package/dist/analytics/extractCorpus/corpus.js.map +0 -1
  501. package/dist/analytics/extractCorpus/coverageAudit.js.map +0 -1
  502. package/dist/analytics/extractCorpus/cursorSessions.js.map +0 -1
  503. package/dist/analytics/extractCorpus/extractCorpusParity.js.map +0 -1
  504. package/dist/analytics/extractCorpus/filesystemSources.js.map +0 -1
  505. package/dist/analytics/extractCorpus/index.js.map +0 -1
  506. package/dist/analytics/extractCorpus/jsonlSessions.js.map +0 -1
  507. package/dist/analytics/extractCorpus/sqliteCaps.js.map +0 -1
  508. package/dist/analytics/extractCorpus/sqliteSessions.js.map +0 -1
  509. package/dist/analytics/extractCorpus.js.map +0 -1
  510. package/dist/analytics/usageStats.js.map +0 -1
  511. package/dist/bin/agentera.js.map +0 -1
  512. package/dist/capabilities/audit/instructions.js.map +0 -1
  513. package/dist/capabilities/build/instructions.js.map +0 -1
  514. package/dist/capabilities/design/instructions.js.map +0 -1
  515. package/dist/capabilities/discuss/instructions.js.map +0 -1
  516. package/dist/capabilities/document/instructions.js.map +0 -1
  517. package/dist/capabilities/dokumentera/instructions.js +0 -6
  518. package/dist/capabilities/dokumentera/instructions.js.map +0 -1
  519. package/dist/capabilities/hej/instructions.js +0 -6
  520. package/dist/capabilities/hej/instructions.js.map +0 -1
  521. package/dist/capabilities/index.js.map +0 -1
  522. package/dist/capabilities/inspektera/instructions.js +0 -6
  523. package/dist/capabilities/inspektera/instructions.js.map +0 -1
  524. package/dist/capabilities/inspirera/instructions.js +0 -6
  525. package/dist/capabilities/inspirera/instructions.js.map +0 -1
  526. package/dist/capabilities/optimera/instructions.js +0 -6
  527. package/dist/capabilities/optimera/instructions.js.map +0 -1
  528. package/dist/capabilities/optimize/instructions.js.map +0 -1
  529. package/dist/capabilities/orchestrate/instructions.js.map +0 -1
  530. package/dist/capabilities/orkestrera/instructions.js +0 -6
  531. package/dist/capabilities/orkestrera/instructions.js.map +0 -1
  532. package/dist/capabilities/plan/instructions.js.map +0 -1
  533. package/dist/capabilities/planera/instructions.js +0 -6
  534. package/dist/capabilities/planera/instructions.js.map +0 -1
  535. package/dist/capabilities/profile/instructions.js.map +0 -1
  536. package/dist/capabilities/profilera/instructions.js +0 -6
  537. package/dist/capabilities/profilera/instructions.js.map +0 -1
  538. package/dist/capabilities/realisera/instructions.js +0 -6
  539. package/dist/capabilities/realisera/instructions.js.map +0 -1
  540. package/dist/capabilities/research/instructions.js.map +0 -1
  541. package/dist/capabilities/resonera/instructions.js +0 -6
  542. package/dist/capabilities/resonera/instructions.js.map +0 -1
  543. package/dist/capabilities/status/instructions.js.map +0 -1
  544. package/dist/capabilities/vision/instructions.js.map +0 -1
  545. package/dist/capabilities/visionera/instructions.js +0 -6
  546. package/dist/capabilities/visionera/instructions.js.map +0 -1
  547. package/dist/capabilities/visualisera/instructions.js +0 -5
  548. package/dist/capabilities/visualisera/instructions.js.map +0 -1
  549. package/dist/cli/appContext.js.map +0 -1
  550. package/dist/cli/argvalidate.js.map +0 -1
  551. package/dist/cli/capabilityContext/benchmark.js.map +0 -1
  552. package/dist/cli/capabilityContext/bespoke.js.map +0 -1
  553. package/dist/cli/capabilityContext/build.js.map +0 -1
  554. package/dist/cli/capabilityContext/closeout.js.map +0 -1
  555. package/dist/cli/capabilityContext/contract.js.map +0 -1
  556. package/dist/cli/capabilityContext/evidence.js.map +0 -1
  557. package/dist/cli/capabilityContext/index.js.map +0 -1
  558. package/dist/cli/capabilityContext/orchestration.js.map +0 -1
  559. package/dist/cli/capabilityContext/planState.js.map +0 -1
  560. package/dist/cli/capabilityContext/progress.js.map +0 -1
  561. package/dist/cli/capabilityContext/realisera.js +0 -174
  562. package/dist/cli/capabilityContext/realisera.js.map +0 -1
  563. package/dist/cli/capabilityContext/shared.js.map +0 -1
  564. package/dist/cli/capabilityContext/slim.js.map +0 -1
  565. package/dist/cli/capabilityContext/startup.js.map +0 -1
  566. package/dist/cli/capabilityContext/types.js.map +0 -1
  567. package/dist/cli/capabilityContext.js.map +0 -1
  568. package/dist/cli/commands/appHome.js.map +0 -1
  569. package/dist/cli/commands/backfill.js +0 -84
  570. package/dist/cli/commands/backfill.js.map +0 -1
  571. package/dist/cli/commands/capability.js.map +0 -1
  572. package/dist/cli/commands/compact.js.map +0 -1
  573. package/dist/cli/commands/doctor.js.map +0 -1
  574. package/dist/cli/commands/lint.js.map +0 -1
  575. package/dist/cli/commands/prime/bundleStatus.js.map +0 -1
  576. package/dist/cli/commands/prime/collectOrientationState.js.map +0 -1
  577. package/dist/cli/commands/prime/orientationOutput.js.map +0 -1
  578. package/dist/cli/commands/prime/routeOutput.js +0 -50
  579. package/dist/cli/commands/prime/routeOutput.js.map +0 -1
  580. package/dist/cli/commands/prime/types.js.map +0 -1
  581. package/dist/cli/commands/prime/v1Migration.js.map +0 -1
  582. package/dist/cli/commands/prime.js.map +0 -1
  583. package/dist/cli/commands/query.js.map +0 -1
  584. package/dist/cli/commands/report.js.map +0 -1
  585. package/dist/cli/commands/schema.js.map +0 -1
  586. package/dist/cli/commands/state/decisions.js.map +0 -1
  587. package/dist/cli/commands/state/docs.js.map +0 -1
  588. package/dist/cli/commands/state/experiments.js.map +0 -1
  589. package/dist/cli/commands/state/health.js.map +0 -1
  590. package/dist/cli/commands/state/index.js.map +0 -1
  591. package/dist/cli/commands/state/objective.js.map +0 -1
  592. package/dist/cli/commands/state/plan.js.map +0 -1
  593. package/dist/cli/commands/state/progress.js.map +0 -1
  594. package/dist/cli/commands/state/shared.js.map +0 -1
  595. package/dist/cli/commands/state/todo.js.map +0 -1
  596. package/dist/cli/commands/state.js +0 -1023
  597. package/dist/cli/commands/state.js.map +0 -1
  598. package/dist/cli/commands/upgrade.js.map +0 -1
  599. package/dist/cli/commands/validate.js.map +0 -1
  600. package/dist/cli/commands/verify.js.map +0 -1
  601. package/dist/cli/contracts/bundleStatus.js.map +0 -1
  602. package/dist/cli/contracts/orientationState.js.map +0 -1
  603. package/dist/cli/dispatch/argvParser.js.map +0 -1
  604. package/dist/cli/dispatch/check.js.map +0 -1
  605. package/dist/cli/dispatch/commands.js.map +0 -1
  606. package/dist/cli/dispatch/index.js.map +0 -1
  607. package/dist/cli/dispatch/lifecycle.js.map +0 -1
  608. package/dist/cli/dispatch/prime.js.map +0 -1
  609. package/dist/cli/dispatch/shared.js.map +0 -1
  610. package/dist/cli/dispatch/state.js.map +0 -1
  611. package/dist/cli/dispatch.js.map +0 -1
  612. package/dist/cli/errors.js.map +0 -1
  613. package/dist/cli/help.js.map +0 -1
  614. package/dist/cli/orientation/attention.js.map +0 -1
  615. package/dist/cli/orientation/corpusCoverage.js.map +0 -1
  616. package/dist/cli/orientation.js.map +0 -1
  617. package/dist/cli/prime-blob.js.map +0 -1
  618. package/dist/cli/startupCompletenessContract.js.map +0 -1
  619. package/dist/cli/stateQuery.js.map +0 -1
  620. package/dist/cli/structured.js.map +0 -1
  621. package/dist/cli/todoMarkdown.js.map +0 -1
  622. package/dist/cli/todoSeverity.js.map +0 -1
  623. package/dist/core/difflib.js.map +0 -1
  624. package/dist/core/envPaths.js.map +0 -1
  625. package/dist/core/git.js +0 -43
  626. package/dist/core/git.js.map +0 -1
  627. package/dist/core/jsonValue.js.map +0 -1
  628. package/dist/core/paths.js.map +0 -1
  629. package/dist/core/pyjson.js.map +0 -1
  630. package/dist/core/sourceRoot.js.map +0 -1
  631. package/dist/core/toml.js.map +0 -1
  632. package/dist/core/yaml.js.map +0 -1
  633. package/dist/eval/evalSkills.js.map +0 -1
  634. package/dist/eval/semanticEval.js.map +0 -1
  635. package/dist/eval/semanticFixtures.js.map +0 -1
  636. package/dist/hooks/common.js.map +0 -1
  637. package/dist/hooks/compaction/apply.js.map +0 -1
  638. package/dist/hooks/compaction/dryRun.js.map +0 -1
  639. package/dist/hooks/compaction/index.js.map +0 -1
  640. package/dist/hooks/compaction/parse.js.map +0 -1
  641. package/dist/hooks/compaction/retention.js.map +0 -1
  642. package/dist/hooks/compaction/status.js.map +0 -1
  643. package/dist/hooks/compaction/todoResolved.js +0 -137
  644. package/dist/hooks/compaction/todoResolved.js.map +0 -1
  645. package/dist/hooks/compaction/types.js.map +0 -1
  646. package/dist/hooks/compaction.js +0 -935
  647. package/dist/hooks/compaction.js.map +0 -1
  648. package/dist/hooks/cursorPreToolUse.js +0 -19
  649. package/dist/hooks/cursorPreToolUse.js.map +0 -1
  650. package/dist/hooks/cursorSessionStart.js +0 -79
  651. package/dist/hooks/cursorSessionStart.js.map +0 -1
  652. package/dist/hooks/sessionStart.js +0 -216
  653. package/dist/hooks/sessionStart.js.map +0 -1
  654. package/dist/hooks/sessionStop.js +0 -206
  655. package/dist/hooks/sessionStop.js.map +0 -1
  656. package/dist/hooks/todoLayout.js +0 -177
  657. package/dist/hooks/todoLayout.js.map +0 -1
  658. package/dist/hooks/validateArtifact/agentFacing.js.map +0 -1
  659. package/dist/hooks/validateArtifact/index.js.map +0 -1
  660. package/dist/hooks/validateArtifact/markdown.js.map +0 -1
  661. package/dist/hooks/validateArtifact/runtime.js +0 -86
  662. package/dist/hooks/validateArtifact/runtime.js.map +0 -1
  663. package/dist/hooks/validateArtifact/schema.js.map +0 -1
  664. package/dist/hooks/validateArtifact/traversal.js.map +0 -1
  665. package/dist/hooks/validateArtifact/violations.js.map +0 -1
  666. package/dist/hooks/validateArtifact.js +0 -924
  667. package/dist/hooks/validateArtifact.js.map +0 -1
  668. package/dist/migrate/v2HandoffManifest.js.map +0 -1
  669. package/dist/registries/artifactProtocolIds.js.map +0 -1
  670. package/dist/registries/artifactRegistry.js.map +0 -1
  671. package/dist/registries/capabilityContract.js.map +0 -1
  672. package/dist/registries/evaluatorHandoffContract.js.map +0 -1
  673. package/dist/registries/packageRegistry.js.map +0 -1
  674. package/dist/registries/runtimeAdapterRegistry.js +0 -316
  675. package/dist/registries/runtimeAdapterRegistry.js.map +0 -1
  676. package/dist/registries/triggerLoader.js.map +0 -1
  677. package/dist/release/releaseMetadata.js.map +0 -1
  678. package/dist/routing/index.js +0 -2
  679. package/dist/routing/index.js.map +0 -1
  680. package/dist/routing/routeEngine.js +0 -189
  681. package/dist/routing/routeEngine.js.map +0 -1
  682. package/dist/setup/codex/agents.js +0 -96
  683. package/dist/setup/codex/agents.js.map +0 -1
  684. package/dist/setup/codex/cli.js +0 -161
  685. package/dist/setup/codex/cli.js.map +0 -1
  686. package/dist/setup/codex/configToml.js +0 -639
  687. package/dist/setup/codex/configToml.js.map +0 -1
  688. package/dist/setup/codex/constants.js +0 -29
  689. package/dist/setup/codex/constants.js.map +0 -1
  690. package/dist/setup/codex/installRoot.js +0 -64
  691. package/dist/setup/codex/installRoot.js.map +0 -1
  692. package/dist/setup/codex/state.js +0 -270
  693. package/dist/setup/codex/state.js.map +0 -1
  694. package/dist/setup/codex.js +0 -12
  695. package/dist/setup/codex.js.map +0 -1
  696. package/dist/setup/copilot.js +0 -227
  697. package/dist/setup/copilot.js.map +0 -1
  698. package/dist/setup/cursor.js +0 -129
  699. package/dist/setup/cursor.js.map +0 -1
  700. package/dist/setup/cursorSurfaces.js +0 -67
  701. package/dist/setup/cursorSurfaces.js.map +0 -1
  702. package/dist/setup/doctor/core.js +0 -300
  703. package/dist/setup/doctor/core.js.map +0 -1
  704. package/dist/setup/doctor/diagnostics.js +0 -240
  705. package/dist/setup/doctor/diagnostics.js.map +0 -1
  706. package/dist/setup/doctor/opencode.js +0 -313
  707. package/dist/setup/doctor/opencode.js.map +0 -1
  708. package/dist/setup/doctor/report.js +0 -425
  709. package/dist/setup/doctor/report.js.map +0 -1
  710. package/dist/setup/doctor.js +0 -10
  711. package/dist/setup/doctor.js.map +0 -1
  712. package/dist/setup/opencode.js.map +0 -1
  713. package/dist/setup/smokeChecks.js.map +0 -1
  714. package/dist/state/installRoot.js.map +0 -1
  715. package/dist/state/progressCommit.js +0 -289
  716. package/dist/state/progressCommit.js.map +0 -1
  717. package/dist/state/startupAnalysis/benchmark.js.map +0 -1
  718. package/dist/state/startupAnalysis/contract.js.map +0 -1
  719. package/dist/state/startupAnalysis/helpers.js.map +0 -1
  720. package/dist/state/startupAnalysis/index.js.map +0 -1
  721. package/dist/state/startupAnalysis/metrics.js.map +0 -1
  722. package/dist/state/startupAnalysis/records.js.map +0 -1
  723. package/dist/state/startupAnalysis/report.js.map +0 -1
  724. package/dist/state/startupAnalysis/threshold.js.map +0 -1
  725. package/dist/state/startupAnalysis.js.map +0 -1
  726. package/dist/upgrade/appContentRefresh.js.map +0 -1
  727. package/dist/upgrade/appModel.js.map +0 -1
  728. package/dist/upgrade/bundleEvidence.js.map +0 -1
  729. package/dist/upgrade/channels.js.map +0 -1
  730. package/dist/upgrade/cliProbe.js +0 -22
  731. package/dist/upgrade/cliProbe.js.map +0 -1
  732. package/dist/upgrade/coexistenceProbe.js +0 -107
  733. package/dist/upgrade/coexistenceProbe.js.map +0 -1
  734. package/dist/upgrade/compatibility.js.map +0 -1
  735. package/dist/upgrade/doctor.js.map +0 -1
  736. package/dist/upgrade/doctorClassifier.js.map +0 -1
  737. package/dist/upgrade/installedHooksRetirement.js.map +0 -1
  738. package/dist/upgrade/legacyAgentCleanup.js.map +0 -1
  739. package/dist/upgrade/migrateArtifactsV1ToV2.js +0 -570
  740. package/dist/upgrade/migrateArtifactsV1ToV2.js.map +0 -1
  741. package/dist/upgrade/migrateArtifactsV2ToV3.js.map +0 -1
  742. package/dist/upgrade/nextMajorDoctor.js.map +0 -1
  743. package/dist/upgrade/npxPlatformStatus.js.map +0 -1
  744. package/dist/upgrade/projectIntegration.js.map +0 -1
  745. package/dist/upgrade/projectIntegrationDecision.js.map +0 -1
  746. package/dist/upgrade/runtimeMigration.js.map +0 -1
  747. package/dist/upgrade/upgradeCommands.js.map +0 -1
  748. package/dist/upgrade/upgradeOrchestrator.js.map +0 -1
  749. package/dist/upgrade/v3CapabilitySurface.js.map +0 -1
  750. package/dist/upgrade/versionResolution.js.map +0 -1
  751. package/dist/validate/appHomeContract.js.map +0 -1
  752. package/dist/validate/capability.js.map +0 -1
  753. package/dist/validate/crossCapability.js.map +0 -1
  754. package/dist/validate/lifecycleAdapters/legacyPythonParity.js +0 -93
  755. package/dist/validate/lifecycleAdapters/legacyPythonParity.js.map +0 -1
  756. package/dist/validate/lifecycleAdapters/nodeFormChecks.js +0 -488
  757. package/dist/validate/lifecycleAdapters/nodeFormChecks.js.map +0 -1
  758. package/dist/validate/lifecycleAdapters/shared.js +0 -198
  759. package/dist/validate/lifecycleAdapters/shared.js.map +0 -1
  760. package/dist/validate/lifecycleAdapters.js +0 -62
  761. package/dist/validate/lifecycleAdapters.js.map +0 -1
  762. package/dist/validate/selfAudit.js.map +0 -1
  763. package/dist/validate/vocabularyAuthority.js.map +0 -1
@@ -1,935 +0,0 @@
1
- import fs from "node:fs";
2
- import path from "node:path";
3
- import YAML from "yaml";
4
- import { loadYamlMapping } from "../core/yaml.js";
5
- import { DEFAULT_ARTIFACT_PATHS, MAX_FULL_ENTRIES, MAX_ONELINE_ENTRIES, MAX_TOTAL_ENTRIES, applyRetentionCaps, parseDocsYamlMapping, } from "./common.js";
6
- // --- body field helpers ----------------------------------------------------
7
- function extractField(body, label) {
8
- const pattern = new RegExp(`^\\*\\*${escapeRe(label)}\\*\\*:\\s*(.+?)$`, "m");
9
- const m = pattern.exec(body);
10
- return m ? m[1].trim() : "";
11
- }
12
- function escapeRe(s) {
13
- return s.replace(/[.*+?^${}()|[\]\\]/g, "\\$&");
14
- }
15
- function firstNonEmpty(body) {
16
- for (const line of body.split(/\r\n|\r|\n/)) {
17
- if (line.trim())
18
- return line.trim();
19
- }
20
- return "";
21
- }
22
- function truncateWords(text, limit = 15) {
23
- const words = text.split(/\s+/).filter((w) => w.length > 0);
24
- // Match Python str.split() token count but preserve original spacing on no-trunc.
25
- const tokenCount = (text.match(/\S+/g) ?? []).length;
26
- if (tokenCount <= limit)
27
- return text;
28
- return words.slice(0, limit).join(" ") + "...";
29
- }
30
- const HEADER_NUM_RE = /(?:Cycle|Decision|Audit|Experiment)\s+(\d+)/;
31
- const HEADER_DATE_RE = /(\d{4}-\d{2}-\d{2})/;
32
- const NUMBER_RE = /(?:Cycle|Decision|Audit|Experiment|EXP-)\s*(\d+)/;
33
- function parseHeader(header) {
34
- const numMatch = HEADER_NUM_RE.exec(header);
35
- const dateMatch = HEADER_DATE_RE.exec(header);
36
- const number = numMatch ? numMatch[1] : "";
37
- const date = dateMatch ? dateMatch[1] : "";
38
- const parts = header.split(" · ");
39
- let title = parts.length >= 2 ? parts[parts.length - 1].trim() : "";
40
- if (title === date) {
41
- title = parts.length >= 3 ? parts[parts.length - 2].trim() : "";
42
- }
43
- return [number, date, title];
44
- }
45
- // --- one-line formatters ---------------------------------------------------
46
- function formatProgressOneline(entry) {
47
- let [number, date, title] = parseHeader(entry.header);
48
- if (!title) {
49
- title = extractField(entry.body, "What") || firstNonEmpty(entry.body);
50
- }
51
- title = truncateWords(title || "(no summary)", 20);
52
- const numberPart = number ? `Cycle ${number}` : "Cycle ?";
53
- const datePart = date ? ` (${date})` : "";
54
- return `- ${numberPart}${datePart}: ${title}`;
55
- }
56
- function formatDecisionOneline(entry) {
57
- const [number, date] = parseHeader(entry.header);
58
- let chosen = extractField(entry.body, "Chosen alternative");
59
- if (!chosen)
60
- chosen = extractField(entry.body, "Chosen");
61
- if (!chosen)
62
- chosen = firstNonEmpty(entry.body);
63
- chosen = truncateWords(chosen || "(no rationale)", 20);
64
- const numberPart = number ? `Decision ${number}` : "Decision ?";
65
- const datePart = date ? ` (${date})` : "";
66
- return `- ${numberPart}${datePart}: ${chosen}`;
67
- }
68
- function formatHealthOneline(entry) {
69
- const [number, date] = parseHeader(entry.header);
70
- let grade = extractField(entry.body, "Overall");
71
- if (!grade)
72
- grade = extractField(entry.body, "Grade");
73
- let trajectory = extractField(entry.body, "Overall trajectory");
74
- if (!trajectory)
75
- trajectory = "";
76
- const summaryBits = [];
77
- if (grade)
78
- summaryBits.push(truncateWords(grade, 10));
79
- if (trajectory && trajectory !== grade)
80
- summaryBits.push(truncateWords(trajectory, 10));
81
- const summary = summaryBits.length > 0 ? summaryBits.join(" | ") : "no summary";
82
- const numberPart = number ? `Audit ${number}` : "Audit ?";
83
- const datePart = date ? ` · ${date}` : "";
84
- return `### ${numberPart}${datePart} (${summary})`;
85
- }
86
- function formatExperimentOneline(entry) {
87
- const [number] = parseHeader(entry.header);
88
- let summary = extractField(entry.body, "Metric");
89
- if (!summary)
90
- summary = extractField(entry.body, "Conclusion");
91
- if (!summary)
92
- summary = extractField(entry.body, "Result");
93
- if (!summary)
94
- summary = firstNonEmpty(entry.body);
95
- summary = truncateWords(summary || "(no result)", 15);
96
- const numberPart = number ? `EXP-${number}` : "EXP-?";
97
- return `- ${numberPart}: ${summary}`;
98
- }
99
- const TODO_CHECKBOX_RE = /^-\s*\[x\]\s*/;
100
- const TODO_ISS_LABEL_RE = /ISS-\d+:?\s*/;
101
- function isTodoOnelinePassthrough(entry) {
102
- return entry.kind === "oneline" && String(entry.header).includes("~~");
103
- }
104
- function stripTodoMetadata(header) {
105
- let stripped = header.replace(TODO_CHECKBOX_RE, "");
106
- stripped = stripped.replace(/~~/g, "").trim();
107
- stripped = stripped.split(" · ")[0].trim();
108
- stripped = stripped.replace(TODO_ISS_LABEL_RE, "").trim();
109
- return stripped;
110
- }
111
- function formatTodoOneline(entry) {
112
- const header = String(entry.header).trim();
113
- if (isTodoOnelinePassthrough(entry)) {
114
- return header.startsWith("- ") ? header : `- ${header}`;
115
- }
116
- const summary = truncateWords(stripTodoMetadata(header) || "(resolved)", 15);
117
- return `- [x] ~~${summary}~~`;
118
- }
119
- export const SPECS = {
120
- progress: {
121
- name: "progress",
122
- entryHeadingRe: /^■?\s*##\s+Cycle\s+\d+/m,
123
- onelineHeadingRe: /^-\s+Cycle\s+\d+/m,
124
- archiveHeading: "## Archived Cycles",
125
- formatOneline: formatProgressOneline,
126
- scopedSection: null,
127
- },
128
- decisions: {
129
- name: "decisions",
130
- entryHeadingRe: /^##\s+Decision\s+\d+/m,
131
- onelineHeadingRe: /^-\s+Decision\s+\d+/m,
132
- archiveHeading: "## Archived Decisions",
133
- formatOneline: formatDecisionOneline,
134
- scopedSection: null,
135
- },
136
- health: {
137
- name: "health",
138
- entryHeadingRe: /^##\s+Audit\s+\d+/m,
139
- onelineHeadingRe: /^###\s+Audit\s+\d+/m,
140
- archiveHeading: "## Archived Audits",
141
- formatOneline: formatHealthOneline,
142
- scopedSection: null,
143
- },
144
- experiments: {
145
- name: "experiments",
146
- entryHeadingRe: /^##\s+Experiment\s+\d+/m,
147
- onelineHeadingRe: /^-\s+EXP-\d+/m,
148
- archiveHeading: "## Archived Experiments",
149
- formatOneline: formatExperimentOneline,
150
- scopedSection: null,
151
- },
152
- "todo-resolved": {
153
- name: "todo-resolved",
154
- entryHeadingRe: /^-\s+\[x\]\s+/m,
155
- onelineHeadingRe: null,
156
- archiveHeading: null,
157
- formatOneline: formatTodoOneline,
158
- scopedSection: "## Resolved",
159
- },
160
- };
161
- export const COMPACTABLE_YAML_ARTIFACTS = {
162
- progress: ["cycles", "archive"],
163
- decisions: ["decisions", "archive"],
164
- health: ["audits", "archive"],
165
- };
166
- const YAML_SPEC_BY_ARTIFACT = {
167
- progress: "progress",
168
- decisions: "decisions",
169
- health: "health",
170
- };
171
- const NON_COMPACTABLE_ARTIFACTS = {
172
- changelog: ["exempt", "public release history is not compacted"],
173
- plan: ["unsupported", "active plan is lifecycle state, not a uniform retained-entry log"],
174
- docs: ["unsupported", "docs owns artifact mapping and schema metadata"],
175
- vision: ["protected", "vision state is protected during execution cycles"],
176
- design: ["unsupported", "design is a human-facing identity artifact, not a uniform retained-entry log"],
177
- };
178
- function overLimitCount(activeCount, archiveCount) {
179
- const totalCount = activeCount + archiveCount;
180
- return Math.max(Math.max(activeCount - MAX_FULL_ENTRIES, 0), Math.max(archiveCount - MAX_ONELINE_ENTRIES, 0), Math.max(totalCount - MAX_TOTAL_ENTRIES, 0));
181
- }
182
- function artifactPaths(projectRoot) {
183
- const paths = { ...DEFAULT_ARTIFACT_PATHS };
184
- const docsPath = path.join(projectRoot, ".agentera", "docs.yaml");
185
- if (fs.existsSync(docsPath)) {
186
- Object.assign(paths, parseDocsYamlMapping(fs.readFileSync(docsPath, "utf8")));
187
- }
188
- const resolved = {};
189
- for (const [artifact, rel] of Object.entries(paths)) {
190
- resolved[artifact] = path.join(projectRoot, rel);
191
- }
192
- return resolved;
193
- }
194
- function missingStatus(artifact, p, classification) {
195
- return {
196
- artifact,
197
- path: p,
198
- classification,
199
- active_count: 0,
200
- archive_count: 0,
201
- total_count: 0,
202
- over_limit_count: 0,
203
- reason: "artifact path is not present",
204
- protected_overflow_count: 0,
205
- exists: false,
206
- };
207
- }
208
- function yamlErrorStatus(artifact, p, message) {
209
- return {
210
- artifact,
211
- path: p,
212
- classification: "error",
213
- active_count: null,
214
- archive_count: null,
215
- total_count: null,
216
- over_limit_count: null,
217
- reason: message.trim() || "invalid YAML mapping root",
218
- protected_overflow_count: 0,
219
- exists: true,
220
- };
221
- }
222
- function yamlCounts(p, activeKey, archiveKey) {
223
- const data = loadYamlMapping(fs.readFileSync(p, "utf8"));
224
- if (!data || typeof data !== "object" || Array.isArray(data))
225
- return [0, 0];
226
- const active = data[activeKey] || [];
227
- const archive = data[archiveKey] || [];
228
- return [Array.isArray(active) ? active.length : 0, Array.isArray(archive) ? archive.length : 0];
229
- }
230
- function yamlLists(p, activeKey, archiveKey) {
231
- const data = loadYamlMapping(fs.readFileSync(p, "utf8"));
232
- if (!data || typeof data !== "object" || Array.isArray(data))
233
- return [[], []];
234
- const active = data[activeKey] || [];
235
- const archive = data[archiveKey] || [];
236
- return [Array.isArray(active) ? active : [], Array.isArray(archive) ? archive : []];
237
- }
238
- function yamlEntryNumber(entry) {
239
- let summary;
240
- if (entry && typeof entry === "object" && !Array.isArray(entry)) {
241
- const number = entry.number;
242
- if (typeof number === "number" && Number.isInteger(number))
243
- return number;
244
- if (typeof number === "string" && /^\d+$/.test(number))
245
- return parseInt(number, 10);
246
- summary = String(entry.summary ?? "");
247
- }
248
- else {
249
- summary = String(entry);
250
- }
251
- const match = NUMBER_RE.exec(summary);
252
- return match ? parseInt(match[1], 10) : 0;
253
- }
254
- function yamlEntryTimestamp(entry) {
255
- if (entry && typeof entry === "object" && !Array.isArray(entry)) {
256
- return String(entry.timestamp || entry.date || "");
257
- }
258
- return "";
259
- }
260
- function yamlSummaryText(entry, ...fields) {
261
- for (const field of fields) {
262
- const value = entry[field];
263
- if (typeof value === "string" && value.trim()) {
264
- return truncateWords(value.trim(), 15);
265
- }
266
- if (value && typeof value === "object" && !Array.isArray(value) && Object.keys(value).length > 0) {
267
- return truncateWords(Object.entries(value).map(([k, v]) => `${k}: ${v}`).join(", "), 15);
268
- }
269
- }
270
- return "no summary";
271
- }
272
- function isEmptyish(v) {
273
- return (v === null ||
274
- v === undefined ||
275
- v === "" ||
276
- (Array.isArray(v) && v.length === 0) ||
277
- (typeof v === "object" && v !== null && !Array.isArray(v) && Object.keys(v).length === 0));
278
- }
279
- function yamlArchiveEntry(specName, entry) {
280
- if (!entry || typeof entry !== "object" || Array.isArray(entry)) {
281
- return { summary: String(entry) };
282
- }
283
- const e = entry;
284
- if (specName === "progress") {
285
- const number = e.number ?? "?";
286
- const date = String(e.timestamp ?? "").split(/\s+/)[0] || "";
287
- const datePart = date ? ` (${date})` : "";
288
- const summary = yamlSummaryText(e, "what", "type");
289
- return { summary: `Cycle ${number}${datePart}: ${summary}` };
290
- }
291
- if (specName === "decisions") {
292
- const number = e.number ?? "?";
293
- const date = String(e.date ?? "");
294
- const datePart = date ? ` (${date})` : "";
295
- const choice = yamlSummaryText(e, "choice", "question");
296
- const archiveEntry = { summary: `Decision ${number}${datePart}: ${choice}` };
297
- for (const field of ["number", "date", "choice", "outcome", "feeds_into", "satisfaction"]) {
298
- const value = e[field];
299
- if (!isEmptyish(value))
300
- archiveEntry[field] = value;
301
- }
302
- if (!("outcome" in archiveEntry) && !isEmptyish(archiveEntry.choice)) {
303
- archiveEntry.outcome = archiveEntry.choice;
304
- }
305
- return archiveEntry;
306
- }
307
- if (specName === "health") {
308
- const number = e.number ?? "?";
309
- const date = String(e.date ?? "");
310
- const datePart = date ? ` (${date})` : "";
311
- const summary = yamlSummaryText(e, "trajectory", "grades");
312
- return { summary: `Audit ${number}${datePart}: ${summary}` };
313
- }
314
- if (specName === "session") {
315
- return { timestamp: String(e.timestamp ?? ""), summary: yamlSummaryText(e, "summary") };
316
- }
317
- return { summary: yamlSummaryText(e, "summary") };
318
- }
319
- function stableSortBy(arr, key, reverse = false) {
320
- return arr
321
- .map((x, i) => [x, i])
322
- .sort((a, b) => {
323
- const ka = key(a[0]);
324
- const kb = key(b[0]);
325
- let cmp = ka < kb ? -1 : ka > kb ? 1 : 0;
326
- if (reverse)
327
- cmp = -cmp;
328
- return cmp !== 0 ? cmp : a[1] - b[1];
329
- })
330
- .map(([x]) => x);
331
- }
332
- function yamlSortEntries(entries, specName) {
333
- if (specName === "decisions" || specName === "health") {
334
- return stableSortBy(entries, yamlEntryNumber);
335
- }
336
- if (specName === "session") {
337
- return stableSortBy(entries, yamlEntryTimestamp, true);
338
- }
339
- return stableSortBy(entries, yamlEntryNumber, true);
340
- }
341
- function yamlRecentFullAndOlder(entries, specName) {
342
- const newestFirst = specName === "session"
343
- ? stableSortBy(entries, yamlEntryTimestamp, true)
344
- : stableSortBy(entries, yamlEntryNumber, true);
345
- const recent = newestFirst.slice(0, MAX_FULL_ENTRIES);
346
- const older = newestFirst.slice(MAX_FULL_ENTRIES);
347
- return [yamlSortEntries(recent, specName), older];
348
- }
349
- function yamlArchiveSortKey(entry) {
350
- const timestamp = yamlEntryTimestamp(entry);
351
- if (timestamp)
352
- return ["timestamp", timestamp];
353
- return ["number", yamlEntryNumber(entry)];
354
- }
355
- function yamlArchiveEntries(entries) {
356
- // Sort by (tag, value) descending, mirroring Python tuple comparison.
357
- return entries
358
- .map((x, i) => [x, i])
359
- .sort((a, b) => {
360
- const ka = yamlArchiveSortKey(a[0]);
361
- const kb = yamlArchiveSortKey(b[0]);
362
- let cmp = 0;
363
- if (ka[0] !== kb[0])
364
- cmp = ka[0] < kb[0] ? -1 : 1;
365
- else
366
- cmp = ka[1] < kb[1] ? -1 : ka[1] > kb[1] ? 1 : 0;
367
- cmp = -cmp;
368
- return cmp !== 0 ? cmp : a[1] - b[1];
369
- })
370
- .map(([x]) => x);
371
- }
372
- function decisionSatisfactionState(entry) {
373
- if (!entry || typeof entry !== "object")
374
- return null;
375
- const satisfaction = entry.satisfaction;
376
- if (!satisfaction || typeof satisfaction !== "object")
377
- return null;
378
- const state = satisfaction.state;
379
- return typeof state === "string" ? state : null;
380
- }
381
- function decisionRequiresUserReview(entry) {
382
- if (!entry || typeof entry !== "object")
383
- return true;
384
- const satisfaction = entry.satisfaction;
385
- if (!satisfaction || typeof satisfaction !== "object")
386
- return true;
387
- const confirmation = satisfaction.user_confirmation;
388
- return (decisionSatisfactionState(entry) !== "user_confirmed_satisfied" ||
389
- !confirmation ||
390
- typeof confirmation !== "object" ||
391
- Object.keys(confirmation).length === 0);
392
- }
393
- function decisionProtectedOverflowCount(active, archive) {
394
- const protectedActive = active.filter((e) => decisionRequiresUserReview(e)).length;
395
- const protectedArchive = archive.filter((e) => decisionRequiresUserReview(e)).length;
396
- return Math.max(protectedActive - MAX_FULL_ENTRIES, protectedArchive - MAX_ONELINE_ENTRIES, protectedActive + protectedArchive - MAX_TOTAL_ENTRIES, 0);
397
- }
398
- function selectDecisionActiveEntries(active) {
399
- const protectedEntries = active.filter((e) => decisionRequiresUserReview(e));
400
- if (protectedEntries.length > MAX_FULL_ENTRIES) {
401
- throw new Error("decisions: protected-overflow review pressure; " +
402
- `${protectedEntries.length} protected active decision(s) exceed ${MAX_FULL_ENTRIES} full-detail slots`);
403
- }
404
- const satisfied = active.filter((e) => !decisionRequiresUserReview(e));
405
- const newestSatisfied = stableSortBy(satisfied, yamlEntryNumber, true);
406
- const keepSatisfied = newestSatisfied.slice(0, MAX_FULL_ENTRIES - protectedEntries.length);
407
- const compactSatisfied = newestSatisfied.slice(MAX_FULL_ENTRIES - protectedEntries.length);
408
- return [yamlSortEntries([...protectedEntries, ...keepSatisfied], "decisions"), compactSatisfied];
409
- }
410
- function selectDecisionArchiveEntries(archiveCandidates) {
411
- const protectedEntries = archiveCandidates.filter((e) => decisionRequiresUserReview(e));
412
- if (protectedEntries.length > MAX_ONELINE_ENTRIES) {
413
- throw new Error("decisions: protected-overflow review pressure; " +
414
- `${protectedEntries.length} protected archived decision(s) exceed ${MAX_ONELINE_ENTRIES} archive slots`);
415
- }
416
- const satisfied = archiveCandidates.filter((e) => !decisionRequiresUserReview(e));
417
- const keepSatisfied = yamlArchiveEntries(satisfied).slice(0, MAX_ONELINE_ENTRIES - protectedEntries.length);
418
- return yamlArchiveEntries([...protectedEntries, ...keepSatisfied]);
419
- }
420
- export function compactYamlFile(p, artifact) {
421
- if (!(artifact in COMPACTABLE_YAML_ARTIFACTS)) {
422
- throw new Error(`unsupported YAML artifact: ${artifact}`);
423
- }
424
- if (!fs.existsSync(p)) {
425
- throw new Error(p);
426
- }
427
- const [activeKey, archiveKey] = COMPACTABLE_YAML_ARTIFACTS[artifact];
428
- const specName = YAML_SPEC_BY_ARTIFACT[artifact];
429
- const data = loadYamlMapping(fs.readFileSync(p, "utf8"));
430
- let active = data[activeKey] || [];
431
- let archive = data[archiveKey] || [];
432
- if (!Array.isArray(active))
433
- active = [];
434
- if (!Array.isArray(archive))
435
- archive = [];
436
- const fullBefore = active.length;
437
- const onelineBefore = archive.length;
438
- if (overLimitCount(fullBefore, onelineBefore) === 0) {
439
- return { full_before: fullBefore, oneline_before: onelineBefore, full_after: fullBefore, oneline_after: onelineBefore, dropped: 0, changed: false };
440
- }
441
- let recentFull;
442
- let olderActive;
443
- if (specName === "decisions") {
444
- [recentFull, olderActive] = selectDecisionActiveEntries(active);
445
- }
446
- else {
447
- [recentFull, olderActive] = yamlRecentFullAndOlder(active, specName);
448
- }
449
- const compactedFromActive = olderActive.map((entry) => yamlArchiveEntry(specName, entry));
450
- const archiveCandidates = yamlArchiveEntries([...compactedFromActive, ...archive]);
451
- let archiveAfter;
452
- if (specName === "decisions") {
453
- archiveAfter = selectDecisionArchiveEntries(archiveCandidates);
454
- }
455
- else {
456
- const merged = applyRetentionCaps(recentFull, archiveCandidates);
457
- archiveAfter = merged.slice(recentFull.length);
458
- }
459
- data[activeKey] = recentFull;
460
- data[archiveKey] = archiveAfter;
461
- fs.writeFileSync(p, YAML.stringify(data));
462
- const fullAfter = recentFull.length;
463
- const onelineAfter = archiveAfter.length;
464
- const dropped = fullBefore + onelineBefore - fullAfter - onelineAfter;
465
- return { full_before: fullBefore, oneline_before: onelineBefore, full_after: fullAfter, oneline_after: onelineAfter, dropped, changed: true };
466
- }
467
- function countStatus(artifact, p, activeCount, archiveCount, protectedOverflowCount = 0) {
468
- const totalCount = activeCount + archiveCount;
469
- return {
470
- artifact,
471
- path: p,
472
- classification: "compactable",
473
- active_count: activeCount,
474
- archive_count: archiveCount,
475
- total_count: totalCount,
476
- over_limit_count: overLimitCount(activeCount, archiveCount),
477
- reason: protectedOverflowCount ? "protected-overflow review pressure" : "uniform_10_40_50",
478
- protected_overflow_count: protectedOverflowCount,
479
- exists: true,
480
- };
481
- }
482
- export function computeCompactionStatus(projectRoot) {
483
- const paths = artifactPaths(projectRoot);
484
- const statuses = [];
485
- const todoPath = paths.todo;
486
- if (fs.existsSync(todoPath)) {
487
- const entries = parseEntries(fs.readFileSync(todoPath, "utf8"), "todo-resolved");
488
- const activeCount = entries.filter((e) => e.kind === "full").length;
489
- const archiveCount = entries.filter((e) => e.kind === "oneline").length;
490
- statuses.push(countStatus("todo#Resolved", todoPath, activeCount, archiveCount));
491
- }
492
- else {
493
- statuses.push(missingStatus("todo#Resolved", todoPath, "compactable"));
494
- }
495
- for (const [artifact, [activeKey, archiveKey]] of Object.entries(COMPACTABLE_YAML_ARTIFACTS)) {
496
- const p = paths[artifact];
497
- if (fs.existsSync(p)) {
498
- let active;
499
- let archive;
500
- try {
501
- [active, archive] = yamlLists(p, activeKey, archiveKey);
502
- }
503
- catch (exc) {
504
- statuses.push(yamlErrorStatus(artifact, p, exc.message));
505
- continue;
506
- }
507
- const protectedOverflowCount = artifact === "decisions" ? decisionProtectedOverflowCount(active, archive) : 0;
508
- statuses.push(countStatus(artifact, p, active.length, archive.length, protectedOverflowCount));
509
- }
510
- else {
511
- statuses.push(missingStatus(artifact, p, "compactable"));
512
- }
513
- }
514
- for (const [artifact, [classification, reason]] of Object.entries(NON_COMPACTABLE_ARTIFACTS)) {
515
- const p = paths[artifact];
516
- statuses.push({
517
- artifact,
518
- path: p,
519
- classification,
520
- active_count: null,
521
- archive_count: null,
522
- total_count: null,
523
- over_limit_count: null,
524
- reason,
525
- protected_overflow_count: 0,
526
- exists: fs.existsSync(p),
527
- });
528
- }
529
- const optimeraDir = path.join(projectRoot, ".agentera", "optimera");
530
- if (fs.existsSync(optimeraDir) && fs.statSync(optimeraDir).isDirectory()) {
531
- const experimentPaths = [];
532
- for (const sub of fs.readdirSync(optimeraDir).sort()) {
533
- const expPath = path.join(optimeraDir, sub, "experiments.yaml");
534
- if (fs.existsSync(expPath))
535
- experimentPaths.push(expPath);
536
- }
537
- for (const expPath of experimentPaths) {
538
- let activeCount;
539
- let archiveCount;
540
- try {
541
- [activeCount, archiveCount] = yamlCounts(expPath, "experiments", "archive");
542
- }
543
- catch (exc) {
544
- statuses.push(yamlErrorStatus("experiments", expPath, exc.message));
545
- continue;
546
- }
547
- statuses.push({
548
- artifact: "experiments",
549
- path: expPath,
550
- classification: "protected",
551
- active_count: activeCount,
552
- archive_count: archiveCount,
553
- total_count: activeCount + archiveCount,
554
- over_limit_count: overLimitCount(activeCount, archiveCount),
555
- reason: "objective-state experiment files are classified but skipped by default",
556
- protected_overflow_count: 0,
557
- exists: true,
558
- });
559
- }
560
- }
561
- return statuses;
562
- }
563
- function operationForStatus(status, mode) {
564
- const base = (action, message) => ({
565
- status,
566
- mode,
567
- action,
568
- changed: false,
569
- result: null,
570
- message,
571
- });
572
- if (!status.exists)
573
- return base("missing", status.reason);
574
- if (status.classification === "error")
575
- return base("error", status.reason);
576
- if (status.classification !== "compactable")
577
- return base("skipped", status.reason);
578
- if (status.protected_overflow_count) {
579
- return base("protected_overflow", `protected-overflow review pressure by ${status.protected_overflow_count}`);
580
- }
581
- if (!status.over_limit_count)
582
- return base("ok", "within uniform_10_40_50 limits");
583
- return base(mode === "check" ? "over_limit" : "pending_fix", `over uniform_10_40_50 limit by ${status.over_limit_count}`);
584
- }
585
- export function checkCompaction(projectRoot) {
586
- return computeCompactionStatus(projectRoot).map((status) => operationForStatus(status, "check"));
587
- }
588
- export function fixCompaction(projectRoot) {
589
- const operations = [];
590
- for (const status of computeCompactionStatus(projectRoot)) {
591
- const baseline = operationForStatus(status, "fix");
592
- if (baseline.action !== "pending_fix") {
593
- operations.push(baseline);
594
- continue;
595
- }
596
- const p = status.path;
597
- let result;
598
- try {
599
- if (status.artifact === "todo#Resolved") {
600
- result = compactFile(p, "todo-resolved");
601
- }
602
- else if (status.artifact in YAML_SPEC_BY_ARTIFACT) {
603
- result = compactYamlFile(p, status.artifact);
604
- }
605
- else {
606
- operations.push({ status, mode: "fix", action: "skipped", changed: false, result: null, message: `no fixer registered for ${status.artifact}` });
607
- continue;
608
- }
609
- }
610
- catch (exc) {
611
- operations.push({ status, mode: "fix", action: "error", changed: false, result: null, message: exc.message });
612
- continue;
613
- }
614
- operations.push({
615
- status,
616
- mode: "fix",
617
- action: result.changed ? "compacted" : "ok",
618
- changed: result.changed,
619
- result,
620
- message: `full ${result.full_before}->${result.full_after}; ` +
621
- `archive ${result.oneline_before}->${result.oneline_after}; ` +
622
- `dropped ${result.dropped}`,
623
- });
624
- }
625
- return operations;
626
- }
627
- export function runCompaction(projectRoot, mode = "check") {
628
- if (mode === "check")
629
- return checkCompaction(projectRoot);
630
- if (mode === "fix")
631
- return fixCompaction(projectRoot);
632
- throw new Error(`unknown compaction mode: ${mode}`);
633
- }
634
- // --- markdown parse + compaction -------------------------------------------
635
- function splitArchive(text, archiveHeading) {
636
- if (!archiveHeading)
637
- return [text, ""];
638
- const pattern = new RegExp(`^${escapeRe(archiveHeading)}\\s*$`, "m");
639
- const match = pattern.exec(text);
640
- if (!match)
641
- return [text, ""];
642
- const pre = text.slice(0, match.index).replace(/\s+$/, "");
643
- const after = text.slice(match.index + match[0].length);
644
- const nextSection = /^##\s/m.exec(after);
645
- if (nextSection) {
646
- const archiveBody = after.slice(0, nextSection.index);
647
- const trailing = after.slice(nextSection.index);
648
- return [pre, archiveBody.trim() + (trailing ? "\n\n" + trailing : "")];
649
- }
650
- return [pre, after.trim()];
651
- }
652
- function parseFullEntries(text, spec) {
653
- const entries = [];
654
- const re = new RegExp(spec.entryHeadingRe.source, "gm");
655
- const matches = [...text.matchAll(re)];
656
- for (let i = 0; i < matches.length; i++) {
657
- const m = matches[i];
658
- const lineStart = text.lastIndexOf("\n", m.index - 1) + 1;
659
- let lineEnd = text.indexOf("\n", m.index);
660
- if (lineEnd === -1)
661
- lineEnd = text.length;
662
- const headerLine = text.slice(lineStart, lineEnd).trim();
663
- const glyphMatch = /^(■)\s*/.exec(headerLine);
664
- const glyph = glyphMatch ? glyphMatch[1] + " " : "";
665
- const remainder = glyphMatch ? headerLine.slice(glyphMatch[0].length) : headerLine;
666
- const header = glyph + remainder.replace(/^#+/, "").trim();
667
- const bodyStart = lineEnd + 1;
668
- let bodyEnd;
669
- if (i + 1 < matches.length) {
670
- bodyEnd = text.lastIndexOf("\n", matches[i + 1].index - 1) + 1;
671
- }
672
- else {
673
- bodyEnd = text.length;
674
- }
675
- const body = text.slice(bodyStart, bodyEnd).trim();
676
- entries.push({ header, body, kind: "full" });
677
- }
678
- return entries;
679
- }
680
- function parseOnelineEntries(text, spec) {
681
- if (spec.onelineHeadingRe === null)
682
- return [];
683
- const entries = [];
684
- const re = new RegExp(spec.onelineHeadingRe.source);
685
- for (const line of text.split(/\r\n|\r|\n/)) {
686
- if (re.test(line)) {
687
- entries.push({ header: line.replace(/\s+$/, ""), body: "", kind: "oneline" });
688
- }
689
- }
690
- return entries;
691
- }
692
- export function parseEntries(text, specName) {
693
- const spec = SPECS[specName];
694
- if (spec.name === "todo-resolved") {
695
- return parseTodoResolved(text, spec);
696
- }
697
- const [pre, archiveBody] = splitArchive(text, spec.archiveHeading || "");
698
- const fullEntries = parseFullEntries(pre, spec);
699
- const onelineEntries = parseOnelineEntries(archiveBody, spec);
700
- return [...fullEntries, ...onelineEntries];
701
- }
702
- function extractResolvedSection(text) {
703
- const m = /^##\s+(?:✓\s+)?Resolved\s*$/m.exec(text);
704
- if (!m)
705
- return [-1, -1, ""];
706
- const bodyStart = m.index + m[0].length + 1;
707
- const nextSection = /^##\s/m.exec(text.slice(bodyStart));
708
- const bodyEnd = nextSection ? bodyStart + nextSection.index : text.length;
709
- return [m.index, bodyEnd, text.slice(bodyStart, bodyEnd)];
710
- }
711
- function parseTodoResolved(text, spec) {
712
- const [, , body] = extractResolvedSection(text);
713
- if (!body)
714
- return [];
715
- const entries = [];
716
- const lines = body.split(/\r\n|\r|\n/);
717
- const headRe = new RegExp(spec.entryHeadingRe.source);
718
- let i = 0;
719
- while (i < lines.length) {
720
- const line = lines[i];
721
- if (headRe.test(line)) {
722
- const detailLines = [];
723
- let j = i + 1;
724
- while (j < lines.length) {
725
- const nxt = lines[j];
726
- if (nxt.startsWith(" ") || nxt.startsWith("\t")) {
727
- detailLines.push(nxt);
728
- j += 1;
729
- }
730
- else if (nxt.trim() === "") {
731
- if (j + 1 < lines.length && (lines[j + 1].startsWith(" ") || lines[j + 1].startsWith("\t"))) {
732
- detailLines.push(nxt);
733
- j += 1;
734
- }
735
- else {
736
- break;
737
- }
738
- }
739
- else {
740
- break;
741
- }
742
- }
743
- const bodyText = detailLines.join("\n").trim();
744
- entries.push({ header: line.replace(/\s+$/, ""), body: bodyText, kind: bodyText ? "full" : "oneline" });
745
- i = j;
746
- }
747
- else {
748
- i += 1;
749
- }
750
- }
751
- return entries;
752
- }
753
- function entryNumber(entry) {
754
- const m = NUMBER_RE.exec(entry.header);
755
- return m ? parseInt(m[1], 10) : 0;
756
- }
757
- function detectDirection(entries) {
758
- let asc = 0;
759
- let desc = 0;
760
- for (let i = 0; i < entries.length - 1; i++) {
761
- const a = entryNumber(entries[i]);
762
- const b = entryNumber(entries[i + 1]);
763
- if (a === 0 || b === 0 || a === b)
764
- continue;
765
- if (a < b)
766
- asc += 1;
767
- else
768
- desc += 1;
769
- }
770
- if (asc === 0 && desc === 0)
771
- return "descending";
772
- return asc > desc ? "ascending" : "descending";
773
- }
774
- export function compactEntries(entries, maxFull = MAX_FULL_ENTRIES, maxOneline = MAX_ONELINE_ENTRIES, formatOneline = null) {
775
- const maxTotal = maxFull + maxOneline;
776
- if (entries.length === 0)
777
- return [];
778
- const ascending = detectDirection(entries) === "ascending";
779
- const newestFirst = stableSortBy(entries, entryNumber, true);
780
- const full = [];
781
- const archive = [];
782
- newestFirst.forEach((entry, i) => {
783
- if (i < maxFull) {
784
- full.push(entry);
785
- }
786
- else if (i < maxTotal) {
787
- if (entry.kind === "full" && formatOneline !== null) {
788
- archive.push({ header: formatOneline(entry), body: "", kind: "oneline" });
789
- }
790
- else {
791
- archive.push(entry);
792
- }
793
- }
794
- });
795
- const result = applyRetentionCaps(full, archive, { maxFull, maxOneline, maxTotal });
796
- if (ascending)
797
- result.reverse();
798
- return result;
799
- }
800
- function compactTodoEntries(entries) {
801
- const result = [];
802
- let fullCount = 0;
803
- let onelineCount = 0;
804
- for (const entry of entries) {
805
- if (entry.kind === "full" && fullCount < MAX_FULL_ENTRIES) {
806
- result.push(entry);
807
- fullCount += 1;
808
- continue;
809
- }
810
- if (onelineCount < MAX_ONELINE_ENTRIES) {
811
- if (entry.kind === "full") {
812
- result.push({ header: formatTodoOneline(entry), body: "", kind: "oneline" });
813
- }
814
- else {
815
- result.push(entry);
816
- }
817
- onelineCount += 1;
818
- }
819
- }
820
- return result;
821
- }
822
- function formatProgressLike(headerPrefix, entries, spec) {
823
- const lines = [];
824
- if (headerPrefix.trim()) {
825
- lines.push(headerPrefix.replace(/\s+$/, ""));
826
- lines.push("");
827
- }
828
- const fullEntries = entries.filter((e) => e.kind === "full");
829
- const onelineEntries = entries.filter((e) => e.kind === "oneline");
830
- for (const entry of fullEntries) {
831
- const header = entry.header;
832
- const glyphMatch = /^(■)\s+(.*)$/.exec(header);
833
- if (glyphMatch) {
834
- lines.push(`${glyphMatch[1]} ## ${glyphMatch[2]}`);
835
- }
836
- else {
837
- lines.push(`## ${header}`);
838
- }
839
- if (entry.body) {
840
- lines.push("");
841
- lines.push(entry.body);
842
- }
843
- lines.push("");
844
- }
845
- if (onelineEntries.length > 0 && spec.archiveHeading) {
846
- lines.push(spec.archiveHeading);
847
- lines.push("");
848
- for (const entry of onelineEntries) {
849
- lines.push(entry.header);
850
- }
851
- lines.push("");
852
- }
853
- return lines.join("\n").replace(/\s+$/, "") + "\n";
854
- }
855
- function extractHeaderPrefix(text, spec) {
856
- const firstEntry = new RegExp(spec.entryHeadingRe.source, "m").exec(text);
857
- let firstArchiveIdx = -1;
858
- if (spec.archiveHeading) {
859
- const archiveMatch = new RegExp(`^${escapeRe(spec.archiveHeading)}\\s*$`, "m").exec(text);
860
- if (archiveMatch)
861
- firstArchiveIdx = archiveMatch.index;
862
- }
863
- const candidates = [firstEntry ? firstEntry.index : -1, firstArchiveIdx].filter((c) => c >= 0);
864
- if (candidates.length === 0)
865
- return text.replace(/\s+$/, "");
866
- return text.slice(0, Math.min(...candidates)).replace(/\s+$/, "");
867
- }
868
- function compactTodoResolved(p) {
869
- const spec = SPECS["todo-resolved"];
870
- const text = fs.readFileSync(p, "utf8");
871
- const [start, end, body] = extractResolvedSection(text);
872
- if (start < 0)
873
- return { full_before: 0, oneline_before: 0, full_after: 0, oneline_after: 0, dropped: 0, changed: false };
874
- const entries = parseTodoResolved(text, spec);
875
- const fullBefore = entries.filter((e) => e.kind === "full").length;
876
- const onelineBefore = entries.filter((e) => e.kind === "oneline").length;
877
- const totalBefore = entries.length;
878
- if (totalBefore <= MAX_TOTAL_ENTRIES && fullBefore <= MAX_FULL_ENTRIES && onelineBefore <= MAX_ONELINE_ENTRIES) {
879
- return { full_before: fullBefore, oneline_before: onelineBefore, full_after: fullBefore, oneline_after: onelineBefore, dropped: 0, changed: false };
880
- }
881
- const compacted = compactTodoEntries(entries);
882
- const fullAfter = compacted.filter((e) => e.kind === "full").length;
883
- const onelineAfter = compacted.filter((e) => e.kind === "oneline").length;
884
- const dropped = totalBefore - compacted.length;
885
- const newLines = [];
886
- for (const entry of compacted) {
887
- if (entry.kind === "full") {
888
- newLines.push(entry.header);
889
- if (entry.body)
890
- newLines.push(entry.body);
891
- }
892
- else {
893
- newLines.push(spec.formatOneline(entry));
894
- }
895
- }
896
- const newBody = newLines.join("\n") + "\n";
897
- const headingEnd = text.indexOf("\n", start) + 1;
898
- const newText = text.slice(0, headingEnd) + "\n" + newBody + text.slice(end);
899
- fs.writeFileSync(p, newText);
900
- return { full_before: fullBefore, oneline_before: onelineBefore, full_after: fullAfter, oneline_after: onelineAfter, dropped, changed: true };
901
- }
902
- export function compactFile(p, specName) {
903
- if (!(specName in SPECS))
904
- throw new Error(`unknown spec: ${specName}`);
905
- if (!fs.existsSync(p))
906
- throw new Error(p);
907
- const spec = SPECS[specName];
908
- if (spec.name === "todo-resolved") {
909
- return compactTodoResolved(p);
910
- }
911
- const text = fs.readFileSync(p, "utf8");
912
- const entries = parseEntries(text, specName);
913
- const fullBefore = entries.filter((e) => e.kind === "full").length;
914
- const onelineBefore = entries.filter((e) => e.kind === "oneline").length;
915
- const totalBefore = fullBefore + onelineBefore;
916
- const needsCompact = fullBefore > MAX_FULL_ENTRIES || onelineBefore > MAX_ONELINE_ENTRIES || totalBefore > MAX_FULL_ENTRIES + MAX_ONELINE_ENTRIES;
917
- if (!needsCompact) {
918
- return { full_before: fullBefore, oneline_before: onelineBefore, full_after: fullBefore, oneline_after: onelineBefore, dropped: 0, changed: false };
919
- }
920
- const compacted = compactEntries(entries, MAX_FULL_ENTRIES, MAX_ONELINE_ENTRIES, spec.formatOneline);
921
- const fullAfter = compacted.filter((e) => e.kind === "full").length;
922
- const onelineAfter = compacted.filter((e) => e.kind === "oneline").length;
923
- const dropped = totalBefore - compacted.length;
924
- const headerPrefix = extractHeaderPrefix(text, spec);
925
- const newText = formatProgressLike(headerPrefix, compacted, spec);
926
- fs.writeFileSync(p, newText);
927
- return { full_before: fullBefore, oneline_before: onelineBefore, full_after: fullAfter, oneline_after: onelineAfter, dropped, changed: true };
928
- }
929
- export function detectOverflow(text, specName) {
930
- const entries = parseEntries(text, specName);
931
- const fullCount = entries.filter((e) => e.kind === "full").length;
932
- const onelineCount = entries.filter((e) => e.kind === "oneline").length;
933
- return [fullCount, onelineCount];
934
- }
935
- //# sourceMappingURL=compaction.js.map