agentera 3.0.0-dev.8 → 3.0.0-dev.80
This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
- package/LICENSE +201 -0
- package/README.md +252 -22
- package/bundle/.agentera-build-source.json +8 -0
- package/bundle/CHANGELOG.md +1387 -0
- package/bundle/DESIGN.md +229 -0
- package/bundle/LICENSE +201 -0
- package/bundle/README.md +143 -0
- package/bundle/UPGRADE.md +271 -0
- package/bundle/extract-corpus-parity.json +2 -4
- package/bundle/fixtures/routing/hybrid-corpus.yaml +154 -0
- package/bundle/references/adapters/package-publication.json +484 -0
- package/bundle/references/adapters/package-registry.yaml +443 -188
- package/bundle/references/adapters/package-surface-characterization.md +68 -34
- package/bundle/references/adapters/product-v1-reset.yaml +101 -0
- package/bundle/references/adapters/runtime-lifecycle-adapters.yaml +74 -0
- package/bundle/references/adapters/runtime-lifecycle-authority.yaml +62 -0
- package/bundle/references/adapters/runtime-lifecycle-operation-contract.yaml +84 -0
- package/bundle/references/adapters/runtime-retired-resources.yaml +333 -0
- package/bundle/references/analysis/evidence-tier-authority.yaml +559 -0
- package/bundle/references/analysis/personal-glossary-evaluation-authority.yaml +175 -0
- package/bundle/references/analysis/personal-glossary-evaluation-corpus.yaml +291 -0
- package/bundle/references/analysis/personal-glossary-holdout.yaml +192 -0
- package/bundle/references/analysis/verification-policy.yaml +261 -0
- package/bundle/references/artifacts/artifact-registry-interface-model.yaml +17 -8
- package/bundle/references/artifacts/glossary-entry-contract.yaml +2906 -0
- package/bundle/references/artifacts/state-storage-authority.yaml +3065 -0
- package/bundle/references/artifacts/verbosity-budget-authority.yaml +42 -0
- package/bundle/references/cli/app-lifecycle-vocabulary.yaml +3 -4
- package/bundle/references/cli/capability-instruction-contract.yaml +11 -14
- package/bundle/references/cli/hybrid-route-contract.yaml +438 -0
- package/bundle/references/cli/routing-model.md +152 -93
- package/bundle/references/cli/trigger-schema-enrichment.md +57 -46
- package/bundle/references/cli/update-channels.yaml +7 -5
- package/bundle/references/cli/vocabulary-index.yaml +7 -9
- package/bundle/references/cli/vocabulary.md +54 -97
- package/bundle/references/meta/retained-reference-authority.yaml +171 -0
- package/bundle/skills/agentera/SKILL.md +183 -63
- package/bundle/skills/agentera/capabilities/audit/schemas/artifacts.yaml +27 -19
- package/bundle/skills/agentera/capabilities/audit/schemas/exit.yaml +2 -2
- package/bundle/skills/agentera/capabilities/audit/schemas/triggers.yaml +13 -35
- package/bundle/skills/agentera/capabilities/audit/schemas/validation.yaml +30 -11
- package/bundle/skills/agentera/capabilities/build/schemas/artifacts.yaml +44 -21
- package/bundle/skills/agentera/capabilities/build/schemas/exit.yaml +8 -6
- package/bundle/skills/agentera/capabilities/build/schemas/triggers.yaml +14 -36
- package/bundle/skills/agentera/capabilities/build/schemas/validation.yaml +95 -21
- package/bundle/skills/agentera/capabilities/design/schemas/artifacts.yaml +6 -6
- package/bundle/skills/agentera/capabilities/design/schemas/exit.yaml +5 -5
- package/bundle/skills/agentera/capabilities/design/schemas/triggers.yaml +5 -34
- package/bundle/skills/agentera/capabilities/design/schemas/validation.yaml +2 -2
- package/bundle/skills/agentera/capabilities/discuss/schemas/artifacts.yaml +17 -13
- package/bundle/skills/agentera/capabilities/discuss/schemas/exit.yaml +2 -2
- package/bundle/skills/agentera/capabilities/discuss/schemas/triggers.yaml +6 -40
- package/bundle/skills/agentera/capabilities/discuss/schemas/validation.yaml +72 -5
- package/bundle/skills/agentera/capabilities/document/schemas/artifacts.yaml +24 -17
- package/bundle/skills/agentera/capabilities/document/schemas/triggers.yaml +5 -35
- package/bundle/skills/agentera/capabilities/document/schemas/validation.yaml +13 -13
- package/bundle/skills/agentera/capabilities/optimize/schemas/artifacts.yaml +10 -10
- package/bundle/skills/agentera/capabilities/optimize/schemas/exit.yaml +2 -2
- package/bundle/skills/agentera/capabilities/optimize/schemas/triggers.yaml +4 -35
- package/bundle/skills/agentera/capabilities/optimize/schemas/validation.yaml +3 -3
- package/bundle/skills/agentera/capabilities/orchestrate/schemas/artifacts.yaml +34 -22
- package/bundle/skills/agentera/capabilities/orchestrate/schemas/exit.yaml +9 -7
- package/bundle/skills/agentera/capabilities/orchestrate/schemas/triggers.yaml +5 -37
- package/bundle/skills/agentera/capabilities/orchestrate/schemas/validation.yaml +38 -37
- package/bundle/skills/agentera/capabilities/plan/schemas/artifacts.yaml +20 -16
- package/bundle/skills/agentera/capabilities/plan/schemas/triggers.yaml +8 -31
- package/bundle/skills/agentera/capabilities/plan/schemas/validation.yaml +66 -6
- package/bundle/skills/agentera/capabilities/profile/schemas/artifacts.yaml +13 -4
- package/bundle/skills/agentera/capabilities/profile/schemas/exit.yaml +8 -5
- package/bundle/skills/agentera/capabilities/profile/schemas/triggers.yaml +8 -37
- package/bundle/skills/agentera/capabilities/profile/schemas/validation.yaml +67 -3
- package/bundle/skills/agentera/capabilities/research/schemas/artifacts.yaml +6 -6
- package/bundle/skills/agentera/capabilities/research/schemas/triggers.yaml +5 -29
- package/bundle/skills/agentera/capabilities/status/schemas/artifacts.yaml +13 -12
- package/bundle/skills/agentera/capabilities/status/schemas/triggers.yaml +7 -49
- package/bundle/skills/agentera/capabilities/vision/schemas/artifacts.yaml +8 -8
- package/bundle/skills/agentera/capabilities/vision/schemas/exit.yaml +7 -6
- package/bundle/skills/agentera/capabilities/vision/schemas/triggers.yaml +7 -39
- package/bundle/skills/agentera/capabilities/vision/schemas/validation.yaml +14 -16
- package/bundle/skills/agentera/capability_schema_contract.yaml +32 -32
- package/bundle/skills/agentera/protocol.yaml +4 -4
- package/bundle/skills/agentera/route-phrases.yaml +81 -0
- package/bundle/skills/agentera/schemas/artifacts/changelog.yaml +1 -0
- package/bundle/skills/agentera/schemas/artifacts/decisions.yaml +29 -30
- package/bundle/skills/agentera/schemas/artifacts/design.yaml +1 -0
- package/bundle/skills/agentera/schemas/artifacts/docs.yaml +7 -43
- package/bundle/skills/agentera/schemas/artifacts/experiments.yaml +140 -34
- package/bundle/skills/agentera/schemas/artifacts/glossary.yaml +87 -0
- package/bundle/skills/agentera/schemas/artifacts/health.yaml +53 -51
- package/bundle/skills/agentera/schemas/artifacts/objective.yaml +18 -35
- package/bundle/skills/agentera/schemas/artifacts/plan.yaml +453 -55
- package/bundle/skills/agentera/schemas/artifacts/progress.yaml +128 -39
- package/bundle/skills/agentera/schemas/artifacts/todo.yaml +305 -7
- package/bundle/skills/agentera/schemas/artifacts/vision.yaml +0 -19
- package/dist/.agentera-build-source.json +8 -0
- package/dist/analytics/extractCorpus/cli.js +52 -11
- package/dist/analytics/extractCorpus/copilotSessions.js +19 -8
- package/dist/analytics/extractCorpus/core.js +262 -14
- package/dist/analytics/extractCorpus/corpus.js +57 -18
- package/dist/analytics/extractCorpus/coverageAudit.js +44 -45
- package/dist/analytics/extractCorpus/cursorSessions.js +28 -8
- package/dist/analytics/extractCorpus/evidenceTiers.js +709 -0
- package/dist/analytics/extractCorpus/extractCorpusParity.js +4 -4
- package/dist/analytics/extractCorpus/filesystemSources.js +5 -5
- package/dist/analytics/extractCorpus/index.js +4 -2
- package/dist/analytics/extractCorpus/jsonlSessions.js +76 -8
- package/dist/analytics/extractCorpus/sqliteCaps.js +0 -1
- package/dist/analytics/extractCorpus/sqliteSessions.js +12 -4
- package/dist/analytics/extractCorpus/tierReader.js +108 -0
- package/dist/analytics/extractCorpus.js +0 -1
- package/dist/analytics/glossaryAdviceResolution.js +166 -0
- package/dist/analytics/glossaryInputAcquisition.js +319 -0
- package/dist/analytics/personalGlossaryAdmission.js +113 -0
- package/dist/analytics/personalGlossaryCandidateProjection.js +788 -0
- package/dist/analytics/personalGlossaryCandidateProjectionExcerpts.js +144 -0
- package/dist/analytics/personalGlossaryCandidateProjectionModel.js +1 -0
- package/dist/analytics/personalGlossaryCandidateReadView.js +23 -0
- package/dist/analytics/personalGlossaryCurrentGeneration.js +25 -0
- package/dist/analytics/personalGlossaryDecision.js +203 -0
- package/dist/analytics/personalGlossaryExplicit.js +788 -0
- package/dist/analytics/personalGlossaryExplicitMining.js +285 -0
- package/dist/analytics/personalGlossaryExplicitScope.js +41 -0
- package/dist/analytics/personalGlossaryExplicitSegments.js +418 -0
- package/dist/analytics/personalGlossaryExplicitTypes.js +26 -0
- package/dist/analytics/personalGlossaryLexicalClassifier.js +175 -0
- package/dist/analytics/personalGlossaryProfile.js +229 -0
- package/dist/analytics/personalGlossaryRecurrence.js +618 -0
- package/dist/analytics/personalGlossaryRefreshProjection.js +351 -0
- package/dist/analytics/personalGlossaryReviewRecordStorage.js +428 -0
- package/dist/analytics/personalGlossaryReviewRecords.js +332 -0
- package/dist/analytics/profileSignals.js +211 -0
- package/dist/analytics/usageStats.js +150 -23
- package/dist/audit/terminologyDrift.js +281 -0
- package/dist/bin/agentera.js +3 -2
- package/dist/capabilities/audit/instructions.js +16 -6
- package/dist/capabilities/build/instructions.js +59 -6
- package/dist/capabilities/design/instructions.js +3 -4
- package/dist/capabilities/discuss/instructions.js +29 -6
- package/dist/capabilities/document/instructions.js +11 -6
- package/dist/capabilities/index.js +20 -14
- package/dist/capabilities/optimize/instructions.js +14 -6
- package/dist/capabilities/orchestrate/instructions.js +42 -6
- package/dist/capabilities/plan/instructions.js +30 -3
- package/dist/capabilities/profile/instructions.js +104 -5
- package/dist/capabilities/research/instructions.js +4 -5
- package/dist/capabilities/status/instructions.js +15 -6
- package/dist/capabilities/status/startupInstructions.js +34 -0
- package/dist/capabilities/vision/instructions.js +3 -5
- package/dist/cli/appContext.js +14 -7
- package/dist/cli/argvalidate.js +0 -1
- package/dist/cli/capabilityContext/benchmark.js +5 -4
- package/dist/cli/capabilityContext/bespoke.js +14 -6
- package/dist/cli/capabilityContext/build.js +116 -42
- package/dist/cli/capabilityContext/closeout.js +30 -27
- package/dist/cli/capabilityContext/contract.js +18 -27
- package/dist/cli/capabilityContext/evidence.js +84 -77
- package/dist/cli/capabilityContext/index.js +0 -1
- package/dist/cli/capabilityContext/orchestration.js +42 -18
- package/dist/cli/capabilityContext/planState.js +89 -96
- package/dist/cli/capabilityContext/progress.js +52 -12
- package/dist/cli/capabilityContext/projectVerification.js +409 -0
- package/dist/cli/capabilityContext/shared.js +9 -20
- package/dist/cli/capabilityContext/slim.js +52 -8
- package/dist/cli/capabilityContext/startup.js +51 -114
- package/dist/cli/capabilityContext/startupAggregation.js +68 -0
- package/dist/cli/capabilityContext/types.js +26 -10
- package/dist/cli/capabilityContext.js +0 -1
- package/dist/cli/commands/appHome.js +0 -1
- package/dist/cli/commands/capability.js +2 -2
- package/dist/cli/commands/compact.js +163 -13
- package/dist/cli/commands/doctor.js +118 -11
- package/dist/cli/commands/durability.js +81 -0
- package/dist/cli/commands/glossaryAdvice.js +138 -0
- package/dist/cli/commands/lint.js +22 -8
- package/dist/cli/commands/personalGlossaryCandidateReads.js +755 -0
- package/dist/cli/commands/personalGlossaryDecision.js +349 -0
- package/dist/cli/commands/personalGlossaryPublish.js +484 -0
- package/dist/cli/commands/personalGlossaryReviewRecordReads.js +209 -0
- package/dist/cli/commands/personalGlossaryReviewRecords.js +623 -0
- package/dist/cli/commands/prime/briefOrientation.js +845 -0
- package/dist/cli/commands/prime/buildExecutionRequest.js +165 -0
- package/dist/cli/commands/prime/bundleStatus.js +54 -4
- package/dist/cli/commands/prime/collectEntityOrientation.js +338 -0
- package/dist/cli/commands/prime/collectOrientationState.js +124 -68
- package/dist/cli/commands/prime/orientationOutput.js +271 -59
- package/dist/cli/commands/prime/types.js +0 -1
- package/dist/cli/commands/prime.js +89 -11
- package/dist/cli/commands/profileGrounding.js +55 -0
- package/dist/cli/commands/query.js +74 -52
- package/dist/cli/commands/report.js +187 -27
- package/dist/cli/commands/route.js +142 -0
- package/dist/cli/commands/schema.js +436 -138
- package/dist/cli/commands/state/decisions.js +40 -56
- package/dist/cli/commands/state/docs.js +58 -85
- package/dist/cli/commands/state/experimentRecords.js +151 -0
- package/dist/cli/commands/state/experiments.js +11 -65
- package/dist/cli/commands/state/get.js +129 -0
- package/dist/cli/commands/state/health.js +11 -113
- package/dist/cli/commands/state/index.js +6 -41
- package/dist/cli/commands/state/list.js +194 -0
- package/dist/cli/commands/state/objective.js +21 -65
- package/dist/cli/commands/state/plan.js +11 -170
- package/dist/cli/commands/state/planTasks.js +154 -0
- package/dist/cli/commands/state/plans.js +154 -0
- package/dist/cli/commands/state/progress.js +11 -45
- package/dist/cli/commands/state/shared.js +0 -1
- package/dist/cli/commands/state/todo.js +28 -107
- package/dist/cli/commands/state/write.js +459 -0
- package/dist/cli/commands/upgrade.js +176 -5
- package/dist/cli/commands/upgradeVerify.js +118 -0
- package/dist/cli/commands/validate.js +235 -136
- package/dist/cli/commands/verify.js +73 -16
- package/dist/cli/contracts/bundleStatus.js +0 -1
- package/dist/cli/contracts/orientationState.js +0 -1
- package/dist/cli/dispatch/argvParser.js +0 -1
- package/dist/cli/dispatch/check.js +84 -40
- package/dist/cli/dispatch/commands.js +3 -3
- package/dist/cli/dispatch/index.js +84 -52
- package/dist/cli/dispatch/lifecycle.js +182 -62
- package/dist/cli/dispatch/prime.js +37 -2
- package/dist/cli/dispatch/projections.js +17 -0
- package/dist/cli/dispatch/shared.js +1 -2
- package/dist/cli/dispatch/state.js +62 -66
- package/dist/cli/dispatch.js +0 -1
- package/dist/cli/errors.js +16 -17
- package/dist/cli/help.js +419 -41
- package/dist/cli/migrationRequired.js +125 -0
- package/dist/cli/orientation/attention.js +19 -22
- package/dist/cli/orientation/corpusCoverage.js +32 -1
- package/dist/cli/orientation.js +346 -129
- package/dist/cli/planArtifacts.js +350 -0
- package/dist/cli/planEvidence.js +157 -0
- package/dist/cli/planLifecycleState.js +36 -0
- package/dist/cli/planTaskIndex.js +11 -0
- package/dist/cli/preCutoverCommand.js +32 -0
- package/dist/cli/prime-blob.js +71 -3
- package/dist/cli/productV1Eol.js +55 -0
- package/dist/cli/profileAcquisition.js +167 -0
- package/dist/cli/startupCompletenessContract.js +11 -9
- package/dist/cli/stateQuery.js +47 -12
- package/dist/cli/structured.js +0 -1
- package/dist/cli/todoMarkdown.js +25 -12
- package/dist/cli/todoReadinessSelection.js +192 -0
- package/dist/cli/todoSeverity.js +0 -1
- package/dist/core/atomicWriter.js +23 -0
- package/dist/core/developmentChannel.js +1 -0
- package/dist/core/developmentInvocation.js +377 -0
- package/dist/core/difflib.js +0 -1
- package/dist/core/envPaths.js +0 -1
- package/dist/core/jsonValue.js +0 -1
- package/dist/core/paths.js +0 -1
- package/dist/core/pyjson.js +0 -1
- package/dist/core/shell.js +4 -0
- package/dist/core/skillIdentity.js +23 -0
- package/dist/core/sourceRoot.js +9 -12
- package/dist/core/text.js +10 -0
- package/dist/core/toml.js +0 -1
- package/dist/core/yaml.js +61 -2
- package/dist/eval/evalSkills.js +13 -14
- package/dist/eval/glossaryEvaluation.js +751 -0
- package/dist/eval/glossaryEvaluationProcess.js +29 -0
- package/dist/eval/glossaryEvaluationRunner.js +571 -0
- package/dist/eval/glossaryEvaluationSuccessReport.js +297 -0
- package/dist/eval/hybridRouteEvaluation.js +155 -0
- package/dist/eval/semanticEval.js +0 -1
- package/dist/eval/semanticFixtures.js +0 -1
- package/dist/hooks/common.js +3 -56
- package/dist/hooks/compaction/apply.js +224 -47
- package/dist/hooks/compaction/dryRun.js +2 -1
- package/dist/hooks/compaction/index.js +5 -6
- package/dist/hooks/compaction/parse.js +73 -6
- package/dist/hooks/compaction/retention.js +28 -25
- package/dist/hooks/compaction/status.js +145 -26
- package/dist/hooks/compaction/types.js +0 -1
- package/dist/hooks/validateArtifact/agentFacing.js +0 -1
- package/dist/hooks/validateArtifact/index.js +6 -65
- package/dist/hooks/validateArtifact/markdown.js +9 -10
- package/dist/hooks/validateArtifact/schema.js +96 -9
- package/dist/hooks/validateArtifact/traversal.js +12 -11
- package/dist/hooks/validateArtifact/violations.js +5 -3
- package/dist/migrate/v2HandoffManifest.js +8 -3
- package/dist/registries/activationContract.js +2 -0
- package/dist/registries/activationTuples.js +145 -0
- package/dist/registries/artifactProtocolIds.js +2 -1
- package/dist/registries/artifactRegistry.js +207 -60
- package/dist/registries/artifactSchemaProjection.js +45 -0
- package/dist/registries/capabilityContract.js +5 -21
- package/dist/registries/evaluatorHandoffContract.js +0 -1
- package/dist/registries/evidenceTierContract.js +375 -0
- package/dist/registries/explicitSegmentGrammarContract.js +619 -0
- package/dist/registries/glossaryAdviceContract.js +79 -0
- package/dist/registries/glossaryCandidateContractPaths.js +6 -0
- package/dist/registries/glossaryCandidateContracts.js +820 -0
- package/dist/registries/glossaryCandidateDecisionAuthority.js +119 -0
- package/dist/registries/glossaryCandidateDecisionContract.js +62 -0
- package/dist/registries/glossaryCandidateProjectionAuthority.js +345 -0
- package/dist/registries/glossaryCandidateProjectionContract.js +108 -0
- package/dist/registries/glossaryCaveatContract.js +67 -0
- package/dist/registries/glossaryConsumerContractValidation.js +787 -0
- package/dist/registries/glossaryEntryContract.js +759 -0
- package/dist/registries/glossaryEntryTemporal.js +12 -0
- package/dist/registries/glossaryMiningAuthority.js +764 -0
- package/dist/registries/glossaryProfileFullContract.js +24 -0
- package/dist/registries/glossaryReviewRecordsAuthority.js +426 -0
- package/dist/registries/glossaryReviewRecordsContract.js +129 -0
- package/dist/registries/glossaryTermIdentity.js +139 -0
- package/dist/registries/glossaryTermOccurrence.js +20 -0
- package/dist/registries/hybridRoute.js +274 -0
- package/dist/registries/hybridRouteReceipt.js +221 -0
- package/dist/registries/packagePublication.js +273 -0
- package/dist/registries/packageRegistry.js +184 -209
- package/dist/registries/personalGlossaryContracts.js +1 -0
- package/dist/registries/todoReadinessContract.js +448 -0
- package/dist/registries/triggerLoader.js +7 -44
- package/dist/registries/verbosityBudgetContract.js +205 -0
- package/dist/release/releaseMetadata.js +168 -11
- package/dist/runtime/lifecycleAdapterContract.js +457 -0
- package/dist/runtime/lifecycleAdapters.js +777 -0
- package/dist/runtime/lifecycleAuthority.js +453 -0
- package/dist/runtime/lifecycleOperationContract.js +123 -0
- package/dist/runtime/lifecycleOperations.js +634 -0
- package/dist/runtime/lifecycleOwnershipJournal.js +622 -0
- package/dist/runtime/lifecyclePublication.js +415 -0
- package/dist/runtime/lifecycleSnapshot.js +438 -0
- package/dist/runtime/nativeResourceCleanup.js +503 -0
- package/dist/setup/opencode.js +20 -13
- package/dist/setup/opencodeConstants.js +1 -0
- package/dist/setup/sharedSkill.js +45 -0
- package/dist/setup/smokeChecks.js +14 -75
- package/dist/state/archiveDiscovery.js +580 -0
- package/dist/state/archivePublication.js +225 -0
- package/dist/state/archiveRecovery.js +237 -0
- package/dist/state/archiveReplay.js +53 -0
- package/dist/state/canonicalMigrationRecord.js +36 -0
- package/dist/state/changelog.js +221 -0
- package/dist/state/decisionEntities.js +367 -0
- package/dist/state/decisionLegacyValidation.js +215 -0
- package/dist/state/decisionMigrationProvenance.js +199 -0
- package/dist/state/decisionOverlay.js +254 -0
- package/dist/state/decisionRevision.js +256 -0
- package/dist/state/decisionRevisionMigration.js +89 -0
- package/dist/state/directRetrieval.js +323 -0
- package/dist/state/durability.js +324 -0
- package/dist/state/entityCutover.js +459 -0
- package/dist/state/entityCutoverGit.js +127 -0
- package/dist/state/entityGlossaryAuthority.js +13 -0
- package/dist/state/entityListProjection.js +187 -0
- package/dist/state/entityListRuntimeRegistry.js +85 -0
- package/dist/state/entityMigrationCausality.js +97 -0
- package/dist/state/entityMigrationIdentity.js +5 -0
- package/dist/state/entityMigrationPreview.js +840 -0
- package/dist/state/entityMigrationTodo.js +133 -0
- package/dist/state/entityPublicationContext.js +859 -0
- package/dist/state/entityRetrievalHelp.js +506 -0
- package/dist/state/entityStorage.js +899 -0
- package/dist/state/exactReplacementRecovery.js +18 -0
- package/dist/state/experimentArchive.js +63 -0
- package/dist/state/experimentIdentity.js +202 -0
- package/dist/state/healthEntities.js +262 -0
- package/dist/state/healthEntityValidation.js +18 -0
- package/dist/state/healthRepair.js +69 -0
- package/dist/state/installRoot.js +15 -7
- package/dist/state/legacyEntityCutoverEvidence.js +65 -0
- package/dist/state/legacyIdentity.js +47 -0
- package/dist/state/legacySummaryRecord.js +6 -0
- package/dist/state/listAccounting.js +54 -0
- package/dist/state/listClassification.js +17 -0
- package/dist/state/listCursor.js +42 -0
- package/dist/state/listRetrieval.js +781 -0
- package/dist/state/migrationSourceBinding.js +30 -0
- package/dist/state/objectiveExperimentEntities.js +322 -0
- package/dist/state/planEntities.js +1027 -0
- package/dist/state/planIdentity.js +47 -0
- package/dist/state/planLineageValidation.js +52 -0
- package/dist/state/planReplacementTransaction.js +475 -0
- package/dist/state/planRetrieval.js +313 -0
- package/dist/state/planTaskRetrieval.js +294 -0
- package/dist/state/progressEntities.js +512 -0
- package/dist/state/progressGlossaryCaveat.js +168 -0
- package/dist/state/progressPublicationOrder.js +19 -0
- package/dist/state/progressWritePolicy.js +33 -0
- package/dist/state/projectRoot.js +62 -0
- package/dist/state/projectionPolicy.js +190 -0
- package/dist/state/retrievalAuthority.js +156 -0
- package/dist/state/safeProjectFile.js +155 -0
- package/dist/state/startupAnalysis/benchmark.js +70 -9
- package/dist/state/startupAnalysis/contract.js +44 -10
- package/dist/state/startupAnalysis/helpers.js +1 -2
- package/dist/state/startupAnalysis/index.js +0 -1
- package/dist/state/startupAnalysis/metrics.js +0 -1
- package/dist/state/startupAnalysis/records.js +0 -1
- package/dist/state/startupAnalysis/report.js +0 -1
- package/dist/state/startupAnalysis/threshold.js +13 -1
- package/dist/state/startupAnalysis.js +0 -1
- package/dist/state/startupProjection.js +499 -0
- package/dist/state/stateMode.js +222 -0
- package/dist/state/stateStorageAuthority.js +47 -0
- package/dist/state/summaryEntityRead.js +25 -0
- package/dist/state/summaryMigrationProvenance.js +66 -0
- package/dist/state/summarySourceRowAuthority.js +36 -0
- package/dist/state/todoActivationSafety.js +58 -0
- package/dist/state/todoCreateBatch.js +69 -0
- package/dist/state/todoDocsEntities.js +1339 -0
- package/dist/state/todoDocsEntityValidation.js +158 -0
- package/dist/state/todoMarkdownProjection.js +63 -0
- package/dist/state/todoReconciliationActivation.js +182 -0
- package/dist/state/todoReconciliationInspection.js +184 -0
- package/dist/state/todoReconciliationRepair.js +320 -0
- package/dist/state/todoReconciliationTransaction.js +628 -0
- package/dist/state/todoSeverityHeadings.js +71 -0
- package/dist/state/todoTransitionBatch.js +65 -0
- package/dist/state/todoUpdateBatch.js +50 -0
- package/dist/state/write/assign.js +20 -0
- package/dist/state/write/candidateMutation.js +269 -0
- package/dist/state/write/errors.js +11 -0
- package/dist/state/write/experimentPublication.js +192 -0
- package/dist/state/write/explain.js +380 -0
- package/dist/state/write/fields.js +61 -0
- package/dist/state/write/glossaryPublication.js +263 -0
- package/dist/state/write/grammar.js +285 -0
- package/dist/state/write/helpers.js +29 -0
- package/dist/state/write/index.js +12 -0
- package/dist/state/write/input.js +391 -0
- package/dist/state/write/lock.js +837 -0
- package/dist/state/write/mutation.js +234 -0
- package/dist/state/write/operations.js +170 -0
- package/dist/state/write/planEvaluation.js +128 -0
- package/dist/state/write/planPublication.js +179 -0
- package/dist/state/write/runtimeOperations.js +146 -0
- package/dist/state/write/serialize.js +1 -0
- package/dist/state/write/transaction.js +57 -0
- package/dist/state/write/validate.js +7 -0
- package/dist/upgrade/appContentRefresh.js +77 -36
- package/dist/upgrade/appModel.js +0 -1
- package/dist/upgrade/atomicWriter.js +1 -0
- package/dist/upgrade/bundleEvidence.js +0 -1
- package/dist/upgrade/channels.js +6 -9
- package/dist/upgrade/compatibility.js +43 -17
- package/dist/upgrade/doctor.js +55 -32
- package/dist/upgrade/doctorClassifier.js +11 -1
- package/dist/upgrade/installedHooksRetirement.js +46 -40
- package/dist/upgrade/legacyAgentCleanup.js +133 -34
- package/dist/upgrade/lifecycleUpgrade.js +113 -0
- package/dist/upgrade/migrateArtifactsV2ToV3.js +325 -82
- package/dist/upgrade/migrationPublication.js +122 -0
- package/dist/upgrade/nextMajorDoctor.js +0 -22
- package/dist/upgrade/npxPlatformStatus.js +2 -2
- package/dist/upgrade/productV1Reset.js +515 -0
- package/dist/upgrade/productV1ResetAuthority.js +139 -0
- package/dist/upgrade/projectIntegration.js +126 -134
- package/dist/upgrade/projectIntegrationDecision.js +21 -13
- package/dist/upgrade/retiredResourceDiagnostics.js +117 -0
- package/dist/upgrade/runtimeMigration.js +210 -430
- package/dist/upgrade/upgradeCommands.js +14 -1
- package/dist/upgrade/upgradeLock.js +85 -0
- package/dist/upgrade/upgradeOrchestrator.js +253 -48
- package/dist/upgrade/v3CapabilitySurface.js +2 -3
- package/dist/upgrade/versionResolution.js +0 -1
- package/dist/validate/activationArtifactEvidence.js +866 -0
- package/dist/validate/activationArtifactEvidenceTypes.js +12 -0
- package/dist/validate/activationConjunction.js +816 -0
- package/dist/validate/activationEvidenceManifest.js +610 -0
- package/dist/validate/activationPackageSemantics.js +29 -0
- package/dist/validate/appHomeContract.js +1 -7
- package/dist/validate/bootstrapAuthority.js +44 -0
- package/dist/validate/capability.js +11 -3
- package/dist/validate/crossCapability.js +14 -9
- package/dist/validate/glossaryVariantGuard.js +96 -0
- package/dist/validate/retainedReferenceAuthority.js +879 -0
- package/dist/validate/selfAudit.js +39 -45
- package/dist/validate/vocabularyAuthority.js +8 -8
- package/package.json +39 -13
- package/bundle/references/adapters/cursor.md +0 -214
- package/bundle/references/adapters/opencode.md +0 -530
- package/bundle/references/adapters/package-manifest-interface-model.yaml +0 -337
- package/bundle/references/adapters/runtime-adapter-characterization.md +0 -79
- package/bundle/references/adapters/runtime-adapter-interface-model.yaml +0 -200
- package/bundle/references/adapters/runtime-adapter-registry.yaml +0 -554
- package/bundle/references/adapters/runtime-feature-parity.md +0 -189
- package/bundle/references/analysis/benchmark.md +0 -267
- package/bundle/references/analysis/startup-measurement-contract.yaml +0 -424
- package/bundle/references/cli/agent-ready-state-contract.yaml +0 -953
- package/bundle/references/cli/audience-namespace-cli-migration.yaml +0 -369
- package/bundle/references/cli/bundle-skill-vocabulary.yaml +0 -250
- package/bundle/references/cli/capability-tool-classification.yaml +0 -53
- package/bundle/references/cli/coexistence-probe.yaml +0 -13
- package/bundle/references/cli/parity-expected-actual-template.md +0 -30
- package/bundle/references/cli/routing-execution-vocabulary.yaml +0 -281
- package/bundle/references/cli/single-name-protocol.yaml +0 -42
- package/bundle/references/cli/upgrade-repair-wording.md +0 -45
- package/bundle/references/cli/v3-handoff-manifest.schema.yaml +0 -98
- package/bundle/references/meta/documentation-inventory.md +0 -49
- package/bundle/skills/agentera/.claude-plugin/plugin.json +0 -27
- package/bundle/skills/agentera/agents/audit.toml +0 -6
- package/bundle/skills/agentera/agents/build.toml +0 -6
- package/bundle/skills/agentera/agents/design.toml +0 -6
- package/bundle/skills/agentera/agents/discuss.toml +0 -6
- package/bundle/skills/agentera/agents/document.toml +0 -6
- package/bundle/skills/agentera/agents/optimize.toml +0 -6
- package/bundle/skills/agentera/agents/orchestrate.toml +0 -6
- package/bundle/skills/agentera/agents/plan.toml +0 -6
- package/bundle/skills/agentera/agents/profile.toml +0 -6
- package/bundle/skills/agentera/agents/research.toml +0 -6
- package/bundle/skills/agentera/agents/status.toml +0 -6
- package/bundle/skills/agentera/agents/vision.toml +0 -6
- package/bundle/skills/agentera/references/contract.md +0 -1048
- package/dist/analytics/extractCorpus/cli.js.map +0 -1
- package/dist/analytics/extractCorpus/copilotSessions.js.map +0 -1
- package/dist/analytics/extractCorpus/core.js.map +0 -1
- package/dist/analytics/extractCorpus/corpus.js.map +0 -1
- package/dist/analytics/extractCorpus/coverageAudit.js.map +0 -1
- package/dist/analytics/extractCorpus/cursorSessions.js.map +0 -1
- package/dist/analytics/extractCorpus/extractCorpusParity.js.map +0 -1
- package/dist/analytics/extractCorpus/filesystemSources.js.map +0 -1
- package/dist/analytics/extractCorpus/index.js.map +0 -1
- package/dist/analytics/extractCorpus/jsonlSessions.js.map +0 -1
- package/dist/analytics/extractCorpus/sqliteCaps.js.map +0 -1
- package/dist/analytics/extractCorpus/sqliteSessions.js.map +0 -1
- package/dist/analytics/extractCorpus.js.map +0 -1
- package/dist/analytics/usageStats.js.map +0 -1
- package/dist/bin/agentera.js.map +0 -1
- package/dist/capabilities/audit/instructions.js.map +0 -1
- package/dist/capabilities/build/instructions.js.map +0 -1
- package/dist/capabilities/design/instructions.js.map +0 -1
- package/dist/capabilities/discuss/instructions.js.map +0 -1
- package/dist/capabilities/document/instructions.js.map +0 -1
- package/dist/capabilities/index.js.map +0 -1
- package/dist/capabilities/optimize/instructions.js.map +0 -1
- package/dist/capabilities/orchestrate/instructions.js.map +0 -1
- package/dist/capabilities/plan/instructions.js.map +0 -1
- package/dist/capabilities/profile/instructions.js.map +0 -1
- package/dist/capabilities/research/instructions.js.map +0 -1
- package/dist/capabilities/status/instructions.js.map +0 -1
- package/dist/capabilities/vision/instructions.js.map +0 -1
- package/dist/cli/appContext.js.map +0 -1
- package/dist/cli/argvalidate.js.map +0 -1
- package/dist/cli/capabilityContext/benchmark.js.map +0 -1
- package/dist/cli/capabilityContext/bespoke.js.map +0 -1
- package/dist/cli/capabilityContext/build.js.map +0 -1
- package/dist/cli/capabilityContext/closeout.js.map +0 -1
- package/dist/cli/capabilityContext/contract.js.map +0 -1
- package/dist/cli/capabilityContext/evidence.js.map +0 -1
- package/dist/cli/capabilityContext/index.js.map +0 -1
- package/dist/cli/capabilityContext/orchestration.js.map +0 -1
- package/dist/cli/capabilityContext/planState.js.map +0 -1
- package/dist/cli/capabilityContext/progress.js.map +0 -1
- package/dist/cli/capabilityContext/shared.js.map +0 -1
- package/dist/cli/capabilityContext/slim.js.map +0 -1
- package/dist/cli/capabilityContext/startup.js.map +0 -1
- package/dist/cli/capabilityContext/types.js.map +0 -1
- package/dist/cli/capabilityContext.js.map +0 -1
- package/dist/cli/commands/appHome.js.map +0 -1
- package/dist/cli/commands/capability.js.map +0 -1
- package/dist/cli/commands/compact.js.map +0 -1
- package/dist/cli/commands/doctor.js.map +0 -1
- package/dist/cli/commands/lint.js.map +0 -1
- package/dist/cli/commands/prime/bundleStatus.js.map +0 -1
- package/dist/cli/commands/prime/collectOrientationState.js.map +0 -1
- package/dist/cli/commands/prime/orientationOutput.js.map +0 -1
- package/dist/cli/commands/prime/types.js.map +0 -1
- package/dist/cli/commands/prime/v1Migration.js +0 -39
- package/dist/cli/commands/prime/v1Migration.js.map +0 -1
- package/dist/cli/commands/prime.js.map +0 -1
- package/dist/cli/commands/query.js.map +0 -1
- package/dist/cli/commands/report.js.map +0 -1
- package/dist/cli/commands/schema.js.map +0 -1
- package/dist/cli/commands/state/decisions.js.map +0 -1
- package/dist/cli/commands/state/docs.js.map +0 -1
- package/dist/cli/commands/state/experiments.js.map +0 -1
- package/dist/cli/commands/state/health.js.map +0 -1
- package/dist/cli/commands/state/index.js.map +0 -1
- package/dist/cli/commands/state/objective.js.map +0 -1
- package/dist/cli/commands/state/plan.js.map +0 -1
- package/dist/cli/commands/state/progress.js.map +0 -1
- package/dist/cli/commands/state/shared.js.map +0 -1
- package/dist/cli/commands/state/todo.js.map +0 -1
- package/dist/cli/commands/upgrade.js.map +0 -1
- package/dist/cli/commands/validate.js.map +0 -1
- package/dist/cli/commands/verify.js.map +0 -1
- package/dist/cli/contracts/bundleStatus.js.map +0 -1
- package/dist/cli/contracts/orientationState.js.map +0 -1
- package/dist/cli/dispatch/argvParser.js.map +0 -1
- package/dist/cli/dispatch/check.js.map +0 -1
- package/dist/cli/dispatch/commands.js.map +0 -1
- package/dist/cli/dispatch/index.js.map +0 -1
- package/dist/cli/dispatch/lifecycle.js.map +0 -1
- package/dist/cli/dispatch/prime.js.map +0 -1
- package/dist/cli/dispatch/shared.js.map +0 -1
- package/dist/cli/dispatch/state.js.map +0 -1
- package/dist/cli/dispatch.js.map +0 -1
- package/dist/cli/errors.js.map +0 -1
- package/dist/cli/help.js.map +0 -1
- package/dist/cli/orientation/attention.js.map +0 -1
- package/dist/cli/orientation/corpusCoverage.js.map +0 -1
- package/dist/cli/orientation.js.map +0 -1
- package/dist/cli/prime-blob.js.map +0 -1
- package/dist/cli/startupCompletenessContract.js.map +0 -1
- package/dist/cli/stateQuery.js.map +0 -1
- package/dist/cli/structured.js.map +0 -1
- package/dist/cli/todoMarkdown.js.map +0 -1
- package/dist/cli/todoSeverity.js.map +0 -1
- package/dist/core/difflib.js.map +0 -1
- package/dist/core/envPaths.js.map +0 -1
- package/dist/core/jsonValue.js.map +0 -1
- package/dist/core/paths.js.map +0 -1
- package/dist/core/pyjson.js.map +0 -1
- package/dist/core/sourceRoot.js.map +0 -1
- package/dist/core/toml.js.map +0 -1
- package/dist/core/yaml.js.map +0 -1
- package/dist/eval/evalSkills.js.map +0 -1
- package/dist/eval/semanticEval.js.map +0 -1
- package/dist/eval/semanticFixtures.js.map +0 -1
- package/dist/hooks/common.js.map +0 -1
- package/dist/hooks/compaction/apply.js.map +0 -1
- package/dist/hooks/compaction/dryRun.js.map +0 -1
- package/dist/hooks/compaction/index.js.map +0 -1
- package/dist/hooks/compaction/parse.js.map +0 -1
- package/dist/hooks/compaction/retention.js.map +0 -1
- package/dist/hooks/compaction/status.js.map +0 -1
- package/dist/hooks/compaction/types.js.map +0 -1
- package/dist/hooks/cursorPreToolUse.js +0 -19
- package/dist/hooks/cursorPreToolUse.js.map +0 -1
- package/dist/hooks/cursorSessionStart.js +0 -79
- package/dist/hooks/cursorSessionStart.js.map +0 -1
- package/dist/hooks/sessionStart.js +0 -216
- package/dist/hooks/sessionStart.js.map +0 -1
- package/dist/hooks/sessionStop.js +0 -206
- package/dist/hooks/sessionStop.js.map +0 -1
- package/dist/hooks/validateArtifact/agentFacing.js.map +0 -1
- package/dist/hooks/validateArtifact/index.js.map +0 -1
- package/dist/hooks/validateArtifact/markdown.js.map +0 -1
- package/dist/hooks/validateArtifact/runtime.js +0 -86
- package/dist/hooks/validateArtifact/runtime.js.map +0 -1
- package/dist/hooks/validateArtifact/schema.js.map +0 -1
- package/dist/hooks/validateArtifact/traversal.js.map +0 -1
- package/dist/hooks/validateArtifact/violations.js.map +0 -1
- package/dist/migrate/v2HandoffManifest.js.map +0 -1
- package/dist/registries/artifactProtocolIds.js.map +0 -1
- package/dist/registries/artifactRegistry.js.map +0 -1
- package/dist/registries/capabilityContract.js.map +0 -1
- package/dist/registries/evaluatorHandoffContract.js.map +0 -1
- package/dist/registries/packageRegistry.js.map +0 -1
- package/dist/registries/runtimeAdapterRegistry.js +0 -316
- package/dist/registries/runtimeAdapterRegistry.js.map +0 -1
- package/dist/registries/triggerLoader.js.map +0 -1
- package/dist/release/releaseMetadata.js.map +0 -1
- package/dist/setup/codex/agents.js +0 -96
- package/dist/setup/codex/agents.js.map +0 -1
- package/dist/setup/codex/cli.js +0 -161
- package/dist/setup/codex/cli.js.map +0 -1
- package/dist/setup/codex/configToml.js +0 -639
- package/dist/setup/codex/configToml.js.map +0 -1
- package/dist/setup/codex/constants.js +0 -29
- package/dist/setup/codex/constants.js.map +0 -1
- package/dist/setup/codex/installRoot.js +0 -64
- package/dist/setup/codex/installRoot.js.map +0 -1
- package/dist/setup/codex/state.js +0 -270
- package/dist/setup/codex/state.js.map +0 -1
- package/dist/setup/codex.js +0 -12
- package/dist/setup/codex.js.map +0 -1
- package/dist/setup/copilot.js +0 -227
- package/dist/setup/copilot.js.map +0 -1
- package/dist/setup/cursor.js +0 -129
- package/dist/setup/cursor.js.map +0 -1
- package/dist/setup/cursorSurfaces.js +0 -67
- package/dist/setup/cursorSurfaces.js.map +0 -1
- package/dist/setup/doctor/core.js +0 -300
- package/dist/setup/doctor/core.js.map +0 -1
- package/dist/setup/doctor/diagnostics.js +0 -240
- package/dist/setup/doctor/diagnostics.js.map +0 -1
- package/dist/setup/doctor/opencode.js +0 -313
- package/dist/setup/doctor/opencode.js.map +0 -1
- package/dist/setup/doctor/report.js +0 -425
- package/dist/setup/doctor/report.js.map +0 -1
- package/dist/setup/doctor.js +0 -10
- package/dist/setup/doctor.js.map +0 -1
- package/dist/setup/opencode.js.map +0 -1
- package/dist/setup/smokeChecks.js.map +0 -1
- package/dist/state/installRoot.js.map +0 -1
- package/dist/state/startupAnalysis/benchmark.js.map +0 -1
- package/dist/state/startupAnalysis/contract.js.map +0 -1
- package/dist/state/startupAnalysis/helpers.js.map +0 -1
- package/dist/state/startupAnalysis/index.js.map +0 -1
- package/dist/state/startupAnalysis/metrics.js.map +0 -1
- package/dist/state/startupAnalysis/records.js.map +0 -1
- package/dist/state/startupAnalysis/report.js.map +0 -1
- package/dist/state/startupAnalysis/threshold.js.map +0 -1
- package/dist/state/startupAnalysis.js.map +0 -1
- package/dist/upgrade/appContentRefresh.js.map +0 -1
- package/dist/upgrade/appModel.js.map +0 -1
- package/dist/upgrade/bundleEvidence.js.map +0 -1
- package/dist/upgrade/channels.js.map +0 -1
- package/dist/upgrade/coexistenceProbe.js +0 -107
- package/dist/upgrade/coexistenceProbe.js.map +0 -1
- package/dist/upgrade/compatibility.js.map +0 -1
- package/dist/upgrade/doctor.js.map +0 -1
- package/dist/upgrade/doctorClassifier.js.map +0 -1
- package/dist/upgrade/installedHooksRetirement.js.map +0 -1
- package/dist/upgrade/legacyAgentCleanup.js.map +0 -1
- package/dist/upgrade/migrateArtifactsV1ToV2.js +0 -570
- package/dist/upgrade/migrateArtifactsV1ToV2.js.map +0 -1
- package/dist/upgrade/migrateArtifactsV2ToV3.js.map +0 -1
- package/dist/upgrade/nextMajorDoctor.js.map +0 -1
- package/dist/upgrade/npxPlatformStatus.js.map +0 -1
- package/dist/upgrade/projectIntegration.js.map +0 -1
- package/dist/upgrade/projectIntegrationDecision.js.map +0 -1
- package/dist/upgrade/runtimeMigration.js.map +0 -1
- package/dist/upgrade/upgradeCommands.js.map +0 -1
- package/dist/upgrade/upgradeOrchestrator.js.map +0 -1
- package/dist/upgrade/v3CapabilitySurface.js.map +0 -1
- package/dist/upgrade/versionResolution.js.map +0 -1
- package/dist/validate/appHomeContract.js.map +0 -1
- package/dist/validate/capability.js.map +0 -1
- package/dist/validate/crossCapability.js.map +0 -1
- package/dist/validate/lifecycleAdapters/legacyPythonParity.js +0 -93
- package/dist/validate/lifecycleAdapters/legacyPythonParity.js.map +0 -1
- package/dist/validate/lifecycleAdapters/nodeFormChecks.js +0 -488
- package/dist/validate/lifecycleAdapters/nodeFormChecks.js.map +0 -1
- package/dist/validate/lifecycleAdapters/shared.js +0 -198
- package/dist/validate/lifecycleAdapters/shared.js.map +0 -1
- package/dist/validate/lifecycleAdapters.js +0 -62
- package/dist/validate/lifecycleAdapters.js.map +0 -1
- package/dist/validate/selfAudit.js.map +0 -1
- package/dist/validate/vocabularyAuthority.js.map +0 -1
|
@@ -1,36 +1,151 @@
|
|
|
1
1
|
import fs from "node:fs";
|
|
2
2
|
import path from "node:path";
|
|
3
|
+
import YAML from "yaml";
|
|
3
4
|
import { isFile, pathExists, resolvePath } from "../core/paths.js";
|
|
5
|
+
import { loadYamlMapping } from "../core/yaml.js";
|
|
6
|
+
import { loadArtifactRecord, resolveArtifactPath } from "../registries/artifactRegistry.js";
|
|
4
7
|
import { BUNDLE_MARKER } from "../state/installRoot.js";
|
|
8
|
+
import { hasBundleRootEvidence } from "./bundleEvidence.js";
|
|
9
|
+
import { applyAppContentRefreshItems, planAppContentRefreshItems, } from "./appContentRefresh.js";
|
|
5
10
|
import { doctorRoots } from "./appModel.js";
|
|
6
11
|
import { AGENTERA_USER_STATE_NAMES, } from "./doctor.js";
|
|
7
|
-
import { applyV1ArtifactsPhase, planV1ArtifactsPhase, } from "./migrateArtifactsV1ToV2.js";
|
|
8
12
|
import { appHomeHasUnrecognizedEntriesWithPreflight, handoffCatalogMessage, resolveMigrationUserStatePreflight, } from "../migrate/v2HandoffManifest.js";
|
|
9
|
-
import { applyAppContentRefreshItems, planAppContentRefreshItems, } from "./appContentRefresh.js";
|
|
10
13
|
import { applyLegacyAgentCleanupItems, planLegacyAgentCleanupItems, planLegacyCapabilityAgentCleanupItems, } from "./legacyAgentCleanup.js";
|
|
11
|
-
import { applyRuntimeMigrationItems, planRuntimeMigrationItems,
|
|
14
|
+
import { applyRuntimeMigrationItems, planRuntimeMigrationItems, } from "./runtimeMigration.js";
|
|
15
|
+
import { writeFileAtomic } from "./atomicWriter.js";
|
|
16
|
+
import { bindMigrationTree, cloneMigrationItem, removeBoundMigrationTree } from "./migrationPublication.js";
|
|
17
|
+
import { applyInstalledHooksRetirementItems, planInstalledHooksRetirementItems, } from "./installedHooksRetirement.js";
|
|
12
18
|
/**
|
|
13
19
|
* v2→v3 migration phases: artifacts (noop for YAML), runtime rewire, cleanup.
|
|
14
|
-
* v1 Markdown→YAML migration uses detectV1ArtifactPairs (shared with prime).
|
|
15
20
|
*/
|
|
16
|
-
export const MIGRATION_STATUSES = ["pending", "applied", "noop", "blocked", "failed"
|
|
17
|
-
|
|
18
|
-
|
|
19
|
-
|
|
20
|
-
|
|
21
|
-
|
|
22
|
-
|
|
23
|
-
|
|
24
|
-
|
|
25
|
-
|
|
26
|
-
|
|
27
|
-
|
|
28
|
-
|
|
29
|
-
|
|
30
|
-
|
|
31
|
-
|
|
21
|
+
export const MIGRATION_STATUSES = ["pending", "applied", "noop", "blocked", "failed"];
|
|
22
|
+
const PLAN_ARCHIVE_FILE = /^PLAN-.+\.ya?ml$/i;
|
|
23
|
+
const PLAN_LIFECYCLE_ACTION = "normalize-plan-lifecycle";
|
|
24
|
+
function isMapping(value) {
|
|
25
|
+
return value !== null && typeof value === "object" && !Array.isArray(value);
|
|
26
|
+
}
|
|
27
|
+
function relativeToProject(project, artifactPath) {
|
|
28
|
+
return path.relative(project, artifactPath);
|
|
29
|
+
}
|
|
30
|
+
function planTaskList(data) {
|
|
31
|
+
if (Array.isArray(data.tasks))
|
|
32
|
+
return data.tasks;
|
|
33
|
+
if (Array.isArray(data.entries))
|
|
34
|
+
return data.entries;
|
|
35
|
+
return null;
|
|
36
|
+
}
|
|
37
|
+
function completedTasksOnly(tasks) {
|
|
38
|
+
return tasks.every((task) => isMapping(task) && (task.status === "complete" || task.status === "completed"));
|
|
39
|
+
}
|
|
40
|
+
function rewritePlanStatus(text, status) {
|
|
41
|
+
const document = YAML.parseDocument(text);
|
|
42
|
+
if (document.errors.length > 0) {
|
|
43
|
+
throw new Error(document.errors.map((error) => error.message).join("; "));
|
|
44
|
+
}
|
|
45
|
+
document.setIn(["header", "status"], status);
|
|
46
|
+
return document.toString();
|
|
47
|
+
}
|
|
48
|
+
function lifecycleMigrationItem(project, artifactPath) {
|
|
49
|
+
const source = relativeToProject(project, artifactPath);
|
|
50
|
+
try {
|
|
51
|
+
const text = fs.readFileSync(artifactPath, "utf8");
|
|
52
|
+
const data = loadYamlMapping(text);
|
|
53
|
+
const header = isMapping(data.header) ? data.header : null;
|
|
54
|
+
const tasks = planTaskList(data);
|
|
55
|
+
if (!header || tasks === null) {
|
|
56
|
+
return {
|
|
57
|
+
status: "blocked",
|
|
58
|
+
action: PLAN_LIFECYCLE_ACTION,
|
|
59
|
+
source,
|
|
60
|
+
target: source,
|
|
61
|
+
message: "plan requires a header mapping and a tasks or entries array before lifecycle migration",
|
|
62
|
+
};
|
|
63
|
+
}
|
|
64
|
+
const status = typeof header.status === "string" ? header.status : "";
|
|
65
|
+
if (status === "open" || status === "complete") {
|
|
66
|
+
return {
|
|
67
|
+
status: "noop",
|
|
68
|
+
action: PLAN_LIFECYCLE_ACTION,
|
|
69
|
+
source,
|
|
70
|
+
target: source,
|
|
71
|
+
preserved: ["all plan fields"],
|
|
72
|
+
message: "plan lifecycle is already canonical",
|
|
73
|
+
};
|
|
74
|
+
}
|
|
75
|
+
if (status !== "active" && status !== "completed") {
|
|
76
|
+
return {
|
|
77
|
+
status: "blocked",
|
|
78
|
+
action: PLAN_LIFECYCLE_ACTION,
|
|
79
|
+
source,
|
|
80
|
+
target: source,
|
|
81
|
+
message: `plan header.status must be active, completed, open, or complete; received ${status || "missing"}`,
|
|
82
|
+
};
|
|
83
|
+
}
|
|
84
|
+
const collisions = [];
|
|
85
|
+
const targetStatus = status === "active" || !completedTasksOnly(tasks)
|
|
86
|
+
? "open"
|
|
87
|
+
: "complete";
|
|
88
|
+
if (status === "completed" && targetStatus === "open") {
|
|
89
|
+
collisions.push("header.status=completed conflicts with unfinished task evidence; preserving task evidence and migrating status to open");
|
|
90
|
+
}
|
|
91
|
+
return {
|
|
92
|
+
status: "pending",
|
|
93
|
+
action: PLAN_LIFECYCLE_ACTION,
|
|
94
|
+
source,
|
|
95
|
+
target: source,
|
|
96
|
+
preserved: ["all plan fields except header.status"],
|
|
97
|
+
...(collisions.length > 0 ? { collisions } : {}),
|
|
98
|
+
newText: rewritePlanStatus(text, targetStatus),
|
|
99
|
+
message: `will migrate plan lifecycle ${status} to ${targetStatus}`,
|
|
100
|
+
};
|
|
101
|
+
}
|
|
102
|
+
catch (error) {
|
|
103
|
+
return {
|
|
104
|
+
status: "blocked",
|
|
105
|
+
action: PLAN_LIFECYCLE_ACTION,
|
|
106
|
+
source,
|
|
107
|
+
target: source,
|
|
108
|
+
message: `cannot migrate plan lifecycle: ${error.message}`,
|
|
109
|
+
};
|
|
110
|
+
}
|
|
111
|
+
}
|
|
112
|
+
function lifecyclePlanArtifacts(project) {
|
|
113
|
+
const root = resolvePath(project);
|
|
114
|
+
let activePath;
|
|
115
|
+
try {
|
|
116
|
+
const record = loadArtifactRecord("plan");
|
|
117
|
+
if (!record)
|
|
118
|
+
throw new Error("plan artifact is not registered");
|
|
119
|
+
activePath = resolveArtifactPath(record, root, { strictWrite: true });
|
|
120
|
+
}
|
|
121
|
+
catch (error) {
|
|
122
|
+
return [{
|
|
123
|
+
status: "blocked",
|
|
124
|
+
action: PLAN_LIFECYCLE_ACTION,
|
|
125
|
+
message: `cannot resolve docs-mapped plan path: ${error.message}`,
|
|
126
|
+
}];
|
|
127
|
+
}
|
|
128
|
+
const artifacts = isFile(activePath) ? [activePath] : [];
|
|
129
|
+
const archiveDirectory = path.join(path.dirname(activePath), "archive");
|
|
130
|
+
try {
|
|
131
|
+
for (const name of fs.readdirSync(archiveDirectory).sort()) {
|
|
132
|
+
if (!PLAN_ARCHIVE_FILE.test(name))
|
|
133
|
+
continue;
|
|
134
|
+
const archivePath = path.join(archiveDirectory, name);
|
|
135
|
+
if (isFile(archivePath))
|
|
136
|
+
artifacts.push(archivePath);
|
|
137
|
+
}
|
|
138
|
+
}
|
|
139
|
+
catch {
|
|
140
|
+
// A missing archive directory is normal before the first archive.
|
|
141
|
+
}
|
|
142
|
+
return artifacts.map((artifactPath) => lifecycleMigrationItem(root, artifactPath));
|
|
143
|
+
}
|
|
144
|
+
export function hasPendingPlanLifecycleMigration(project) {
|
|
145
|
+
return lifecyclePlanArtifacts(project).some((item) => item.status === "pending");
|
|
146
|
+
}
|
|
32
147
|
function emptySummary() {
|
|
33
|
-
return { pending: 0, applied: 0, noop: 0, blocked: 0, failed: 0
|
|
148
|
+
return { pending: 0, applied: 0, noop: 0, blocked: 0, failed: 0 };
|
|
34
149
|
}
|
|
35
150
|
export function summarizePhase(name, items, message = "") {
|
|
36
151
|
const summary = emptySummary();
|
|
@@ -50,24 +165,11 @@ export function summarizePhase(name, items, message = "") {
|
|
|
50
165
|
else if (summary.applied > 0) {
|
|
51
166
|
status = "applied";
|
|
52
167
|
}
|
|
53
|
-
else if (summary.skipped > 0 && summary.noop === 0 && summary.applied === 0) {
|
|
54
|
-
status = "skipped";
|
|
55
|
-
}
|
|
56
168
|
else {
|
|
57
169
|
status = "noop";
|
|
58
170
|
}
|
|
59
171
|
return { name, status, summary, items, message };
|
|
60
172
|
}
|
|
61
|
-
export function detectV1ArtifactPairs(project) {
|
|
62
|
-
const root = resolvePath(project);
|
|
63
|
-
const found = [];
|
|
64
|
-
for (const [md, yaml] of V1_ARTIFACT_PAIRS) {
|
|
65
|
-
if (isFile(path.join(root, md)) && !isFile(path.join(root, yaml))) {
|
|
66
|
-
found.push(md);
|
|
67
|
-
}
|
|
68
|
-
}
|
|
69
|
-
return found;
|
|
70
|
-
}
|
|
71
173
|
function listV2YamlArtifacts(project) {
|
|
72
174
|
const root = resolvePath(project);
|
|
73
175
|
const agenteraDir = path.join(root, ".agentera");
|
|
@@ -98,36 +200,81 @@ export function planArtifactsPhase(project) {
|
|
|
98
200
|
},
|
|
99
201
|
]);
|
|
100
202
|
}
|
|
101
|
-
const v1Pairs = detectV1ArtifactPairs(root);
|
|
102
|
-
if (v1Pairs.length > 0) {
|
|
103
|
-
return planV1ArtifactsPhase(root);
|
|
104
|
-
}
|
|
105
203
|
const yamlArtifacts = listV2YamlArtifacts(root);
|
|
106
|
-
|
|
204
|
+
const lifecycleItems = lifecyclePlanArtifacts(root);
|
|
205
|
+
if (yamlArtifacts.length === 0 && lifecycleItems.length === 0) {
|
|
107
206
|
return summarizePhase("artifacts", [], "no project artifacts found");
|
|
108
207
|
}
|
|
109
|
-
const
|
|
110
|
-
|
|
111
|
-
|
|
112
|
-
|
|
113
|
-
|
|
114
|
-
|
|
208
|
+
const lifecycleSources = new Set(lifecycleItems.flatMap((item) => item.source ? [item.source] : []));
|
|
209
|
+
const items = [
|
|
210
|
+
...yamlArtifacts.filter((source) => !lifecycleSources.has(source)).map((source) => ({
|
|
211
|
+
status: "noop",
|
|
212
|
+
action: "preserve",
|
|
213
|
+
source,
|
|
214
|
+
message: "v2 YAML artifact preserved; no v2→v3 schema migration required",
|
|
215
|
+
})),
|
|
216
|
+
...lifecycleItems,
|
|
217
|
+
];
|
|
115
218
|
return summarizePhase("artifacts", items);
|
|
116
219
|
}
|
|
117
|
-
export function applyArtifactsPhase(phase, project,
|
|
220
|
+
export function applyArtifactsPhase(phase, project, _force = false) {
|
|
118
221
|
const root = resolvePath(project);
|
|
119
|
-
const
|
|
120
|
-
|
|
121
|
-
|
|
122
|
-
|
|
222
|
+
for (const item of phase.items) {
|
|
223
|
+
if (item.status !== "pending" || item.action !== PLAN_LIFECYCLE_ACTION || !item.source)
|
|
224
|
+
continue;
|
|
225
|
+
const sourcePath = path.join(root, item.source);
|
|
226
|
+
const current = lifecycleMigrationItem(root, sourcePath);
|
|
227
|
+
if (current.status !== "pending") {
|
|
228
|
+
item.status = current.status;
|
|
229
|
+
item.message = current.message;
|
|
230
|
+
item.collisions = current.collisions;
|
|
231
|
+
continue;
|
|
232
|
+
}
|
|
233
|
+
if (current.newText !== item.newText) {
|
|
234
|
+
item.status = "blocked";
|
|
235
|
+
item.message = "plan changed after migration preview; rerun dry-run before applying";
|
|
236
|
+
continue;
|
|
237
|
+
}
|
|
238
|
+
try {
|
|
239
|
+
writeFileAtomic(sourcePath, current.newText, "utf8");
|
|
240
|
+
item.status = "applied";
|
|
241
|
+
item.message = "migrated plan lifecycle without changing retained evidence";
|
|
242
|
+
}
|
|
243
|
+
catch (error) {
|
|
244
|
+
item.status = "failed";
|
|
245
|
+
item.message = `plan lifecycle migration failed: ${error.message}`;
|
|
246
|
+
}
|
|
123
247
|
}
|
|
124
|
-
|
|
248
|
+
const updated = summarizePhase("artifacts", phase.items, phase.message);
|
|
249
|
+
phase.status = updated.status;
|
|
250
|
+
phase.summary = updated.summary;
|
|
125
251
|
}
|
|
126
|
-
export function
|
|
252
|
+
export function delegatePlanLifecycleToEntityCutover(phase) {
|
|
253
|
+
for (const item of phase.items) {
|
|
254
|
+
if (item.status !== "pending" || item.action !== PLAN_LIFECYCLE_ACTION)
|
|
255
|
+
continue;
|
|
256
|
+
item.status = "noop";
|
|
257
|
+
item.message = "entity cutover normalizes plan lifecycle while retaining the legacy source as recovery evidence";
|
|
258
|
+
}
|
|
259
|
+
const updated = summarizePhase("artifacts", phase.items, phase.message);
|
|
260
|
+
phase.status = updated.status;
|
|
261
|
+
phase.summary = updated.summary;
|
|
262
|
+
}
|
|
263
|
+
export function planRuntimeRetirementPhase(ctx, _resolvedChannel) {
|
|
127
264
|
const items = planRuntimeMigrationItems(ctx);
|
|
128
|
-
|
|
265
|
+
const blockedPaths = new Set(items
|
|
266
|
+
.filter((item) => item.status === "blocked")
|
|
267
|
+
.flatMap((item) => [item.source, item.target])
|
|
268
|
+
.filter((value) => typeof value === "string"));
|
|
269
|
+
for (const item of items) {
|
|
270
|
+
if (item.status !== "pending" || ![item.source, item.target].some((value) => value && blockedPaths.has(value)))
|
|
271
|
+
continue;
|
|
272
|
+
item.status = "blocked";
|
|
273
|
+
item.message = "action required before Agentera can modify this runtime resource";
|
|
274
|
+
}
|
|
275
|
+
return summarizePhase("runtime", items, items.length === 0 ? "no retired native Agentera hooks found" : "");
|
|
129
276
|
}
|
|
130
|
-
export function
|
|
277
|
+
export function applyRuntimeRetirementPhase(phase, ctx) {
|
|
131
278
|
if (ctx) {
|
|
132
279
|
applyRuntimeMigrationItems(phase.items, ctx);
|
|
133
280
|
}
|
|
@@ -144,13 +291,72 @@ export function applyRuntimeRewirePhase(phase, ctx) {
|
|
|
144
291
|
}
|
|
145
292
|
/** Whether `app/` under app-home still carries a managed bundle worth removing during v2→v3 cleanup. */
|
|
146
293
|
export function hasManagedBundleEvidence(managedAppRoot) {
|
|
147
|
-
|
|
148
|
-
if (isFile(
|
|
149
|
-
return
|
|
294
|
+
const marker = path.join(managedAppRoot, BUNDLE_MARKER);
|
|
295
|
+
if (!isFile(marker))
|
|
296
|
+
return false;
|
|
297
|
+
try {
|
|
298
|
+
const parsed = JSON.parse(fs.readFileSync(marker, "utf8"));
|
|
299
|
+
return parsed.schemaVersion === "agentera.bundle.v1" && typeof parsed.version === "string";
|
|
300
|
+
}
|
|
301
|
+
catch {
|
|
302
|
+
return false;
|
|
150
303
|
}
|
|
151
|
-
|
|
152
|
-
|
|
153
|
-
|
|
304
|
+
}
|
|
305
|
+
const SUPPORTED_V2_BUNDLE_INVENTORY_BY_MAJOR = {
|
|
306
|
+
"2": {
|
|
307
|
+
[BUNDLE_MARKER]: "file",
|
|
308
|
+
"registry.json": "file",
|
|
309
|
+
scripts: "directory",
|
|
310
|
+
"scripts/agentera": "file",
|
|
311
|
+
skills: "directory",
|
|
312
|
+
"skills/agentera": "directory",
|
|
313
|
+
"skills/agentera/SKILL.md": "file",
|
|
314
|
+
},
|
|
315
|
+
};
|
|
316
|
+
function markedBundleInventoryViolations(managedAppRoot) {
|
|
317
|
+
let version;
|
|
318
|
+
try {
|
|
319
|
+
const marker = JSON.parse(fs.readFileSync(path.join(managedAppRoot, BUNDLE_MARKER), "utf8"));
|
|
320
|
+
version = typeof marker.version === "string" ? marker.version : "";
|
|
321
|
+
}
|
|
322
|
+
catch {
|
|
323
|
+
return ["bundle marker is unreadable"];
|
|
324
|
+
}
|
|
325
|
+
const inventory = SUPPORTED_V2_BUNDLE_INVENTORY_BY_MAJOR[version.split(".")[0] ?? ""];
|
|
326
|
+
if (!inventory)
|
|
327
|
+
return [`bundle version ${version || "missing"} has no supported cleanup inventory`];
|
|
328
|
+
const actual = new Map();
|
|
329
|
+
const walk = (directory, prefix = "") => {
|
|
330
|
+
for (const name of fs.readdirSync(directory).sort()) {
|
|
331
|
+
const destination = path.join(directory, name);
|
|
332
|
+
const relative = prefix ? `${prefix}/${name}` : name;
|
|
333
|
+
const stat = fs.lstatSync(destination);
|
|
334
|
+
const kind = stat.isSymbolicLink()
|
|
335
|
+
? "symlink"
|
|
336
|
+
: stat.isFile()
|
|
337
|
+
? "file"
|
|
338
|
+
: stat.isDirectory()
|
|
339
|
+
? "directory"
|
|
340
|
+
: "other";
|
|
341
|
+
actual.set(relative, kind);
|
|
342
|
+
if (kind === "directory")
|
|
343
|
+
walk(destination, relative);
|
|
344
|
+
}
|
|
345
|
+
};
|
|
346
|
+
walk(managedAppRoot);
|
|
347
|
+
const violations = [];
|
|
348
|
+
for (const [relative, kind] of actual) {
|
|
349
|
+
const expected = inventory[relative];
|
|
350
|
+
if (!expected)
|
|
351
|
+
violations.push(`unknown ${kind} ${relative}`);
|
|
352
|
+
else if (expected !== kind)
|
|
353
|
+
violations.push(`${relative} must be ${expected}, found ${kind}`);
|
|
354
|
+
}
|
|
355
|
+
for (const [relative, kind] of Object.entries(inventory)) {
|
|
356
|
+
if (!actual.has(relative))
|
|
357
|
+
violations.push(`missing ${kind} ${relative}`);
|
|
358
|
+
}
|
|
359
|
+
return violations.sort();
|
|
154
360
|
}
|
|
155
361
|
function listManagedBundlePreview(managedAppRoot, limit = 20) {
|
|
156
362
|
if (!pathExists(managedAppRoot)) {
|
|
@@ -185,7 +391,17 @@ export function planCleanupPhase(ctx) {
|
|
|
185
391
|
env: ctx.env,
|
|
186
392
|
});
|
|
187
393
|
const preserved = preflight.preservedAbsolutePaths;
|
|
188
|
-
const
|
|
394
|
+
const installedHookItems = planInstalledHooksRetirementItems(ctx).filter((item) => item.status !== "noop"
|
|
395
|
+
&& item.source !== undefined
|
|
396
|
+
&& !item.source.startsWith(`${managedAppRoot}${path.sep}`));
|
|
397
|
+
const hasOwnedRootHooks = installedHookItems.some((item) => item.source?.startsWith(`${path.join(appHome, "hooks")}${path.sep}`));
|
|
398
|
+
const unknown = appHomeHasUnrecognizedEntriesWithPreflight(appHome, preflight)
|
|
399
|
+
.filter((name) => !(name === "hooks" && hasOwnedRootHooks));
|
|
400
|
+
const managedBundle = hasManagedBundleEvidence(managedAppRoot);
|
|
401
|
+
const refreshAuthorized = managedBundle
|
|
402
|
+
|| hasBundleRootEvidence(roots.activeBundleRoot)
|
|
403
|
+
|| (pathExists(appHome) && fs.readdirSync(appHome).length === 0);
|
|
404
|
+
const appRootUnknown = managedBundle ? markedBundleInventoryViolations(managedAppRoot) : [];
|
|
189
405
|
const items = [
|
|
190
406
|
...preflight.handoffCatalog.map((entry) => ({
|
|
191
407
|
status: "noop",
|
|
@@ -194,9 +410,12 @@ export function planCleanupPhase(ctx) {
|
|
|
194
410
|
preserved: entry.entries,
|
|
195
411
|
message: handoffCatalogMessage(entry),
|
|
196
412
|
})),
|
|
197
|
-
...planAppContentRefreshItems(ctx),
|
|
198
413
|
...planLegacyAgentCleanupItems(ctx),
|
|
199
414
|
...planLegacyCapabilityAgentCleanupItems(ctx),
|
|
415
|
+
...installedHookItems,
|
|
416
|
+
...(refreshAuthorized
|
|
417
|
+
? planAppContentRefreshItems(ctx).filter((item) => item.action === "refresh-app-content")
|
|
418
|
+
: []),
|
|
200
419
|
];
|
|
201
420
|
if (unknown.length > 0 && !ctx.force) {
|
|
202
421
|
items.push({
|
|
@@ -204,18 +423,39 @@ export function planCleanupPhase(ctx) {
|
|
|
204
423
|
action: "remove-managed-app-home",
|
|
205
424
|
source: appHome,
|
|
206
425
|
preserved,
|
|
207
|
-
message:
|
|
426
|
+
message: `app home has unrecognized entries (not preserved user state or managed app content): ${unknown.join(", ")}; cleanup blocked without --force`,
|
|
427
|
+
});
|
|
428
|
+
return summarizePhase("cleanup", items);
|
|
429
|
+
}
|
|
430
|
+
if (appRootUnknown.length > 0) {
|
|
431
|
+
items.push({
|
|
432
|
+
status: "blocked",
|
|
433
|
+
action: "remove-managed-app-home",
|
|
434
|
+
source: managedAppRoot,
|
|
435
|
+
target: appHome,
|
|
436
|
+
preserved: [managedAppRoot],
|
|
437
|
+
message: `managed app bundle does not match the supported v2 recursive inventory (${appRootUnknown.slice(0, 10).join(", ")}${appRootUnknown.length > 10 ? `; ${appRootUnknown.length - 10} more` : ""}); cleanup preserved the entire app directory for manual review`,
|
|
208
438
|
});
|
|
209
439
|
return summarizePhase("cleanup", items);
|
|
210
440
|
}
|
|
211
|
-
if (!
|
|
441
|
+
if (!managedBundle) {
|
|
442
|
+
if (pathExists(managedAppRoot)) {
|
|
443
|
+
items.push({
|
|
444
|
+
status: "blocked",
|
|
445
|
+
action: "remove-managed-app-home",
|
|
446
|
+
source: managedAppRoot,
|
|
447
|
+
target: appHome,
|
|
448
|
+
message: `app directory preserved because ${BUNDLE_MARKER} ownership evidence is missing or invalid; review it manually`,
|
|
449
|
+
});
|
|
450
|
+
return summarizePhase("cleanup", items);
|
|
451
|
+
}
|
|
212
452
|
if (items.length === 0) {
|
|
213
453
|
return summarizePhase("cleanup", [], "no managed Python app-home bundle to remove");
|
|
214
454
|
}
|
|
215
455
|
return summarizePhase("cleanup", items);
|
|
216
456
|
}
|
|
217
457
|
const removedPreview = listManagedBundlePreview(managedAppRoot);
|
|
218
|
-
|
|
458
|
+
const cleanupItem = {
|
|
219
459
|
status: "pending",
|
|
220
460
|
action: "remove-managed-app-home",
|
|
221
461
|
source: managedAppRoot,
|
|
@@ -223,32 +463,36 @@ export function planCleanupPhase(ctx) {
|
|
|
223
463
|
preserved,
|
|
224
464
|
removedPreview,
|
|
225
465
|
message: "will remove managed Python app-home bundle under app/ while preserving user state at app-home root",
|
|
226
|
-
}
|
|
227
|
-
|
|
228
|
-
|
|
229
|
-
|
|
230
|
-
|
|
231
|
-
return;
|
|
466
|
+
};
|
|
467
|
+
const evidenceError = bindMigrationTree(cleanupItem, managedAppRoot, [appHome]);
|
|
468
|
+
if (evidenceError) {
|
|
469
|
+
cleanupItem.status = "blocked";
|
|
470
|
+
cleanupItem.message = `managed app cleanup preserved the bundle: ${evidenceError}; review the unsafe path manually`;
|
|
232
471
|
}
|
|
233
|
-
|
|
472
|
+
items.push(cleanupItem);
|
|
473
|
+
return summarizePhase("cleanup", items);
|
|
234
474
|
}
|
|
235
475
|
export function applyCleanupPhase(phase, ctx) {
|
|
236
476
|
if (ctx) {
|
|
477
|
+
applyLegacyAgentCleanupItems(phase.items, ctx);
|
|
478
|
+
applyInstalledHooksRetirementItems(phase.items, ctx);
|
|
237
479
|
applyAppContentRefreshItems(phase.items, ctx);
|
|
238
480
|
}
|
|
239
|
-
applyLegacyAgentCleanupItems(phase.items);
|
|
240
481
|
for (const item of phase.items) {
|
|
241
482
|
if (item.status !== "pending" || item.action !== "remove-managed-app-home" || !item.source) {
|
|
242
483
|
continue;
|
|
243
484
|
}
|
|
244
485
|
try {
|
|
245
|
-
|
|
486
|
+
if (process.env.NODE_ENV === "test" && process.env.AGENTERA_FAULT_INJECT_V2_CLEANUP_FAILURE === "1") {
|
|
487
|
+
throw new Error("simulated post-marker cleanup failure");
|
|
488
|
+
}
|
|
489
|
+
removeBoundMigrationTree(item);
|
|
246
490
|
item.status = "applied";
|
|
247
491
|
item.message = "managed Python app-home bundle removed; user state preserved";
|
|
248
492
|
}
|
|
249
493
|
catch (exc) {
|
|
250
|
-
item.status = "
|
|
251
|
-
item.message = `cleanup
|
|
494
|
+
item.status = "blocked";
|
|
495
|
+
item.message = `cleanup preserved the managed app bundle: ${exc.message}; rerun migration and review it manually`;
|
|
252
496
|
}
|
|
253
497
|
}
|
|
254
498
|
const updated = summarizePhase("cleanup", phase.items, phase.message);
|
|
@@ -258,25 +502,24 @@ export function applyCleanupPhase(phase, ctx) {
|
|
|
258
502
|
export function dryRunMigration(ctx) {
|
|
259
503
|
return {
|
|
260
504
|
artifacts: planArtifactsPhase(ctx.project),
|
|
261
|
-
runtime:
|
|
505
|
+
runtime: planRuntimeRetirementPhase(ctx),
|
|
262
506
|
cleanup: planCleanupPhase(ctx),
|
|
263
507
|
};
|
|
264
508
|
}
|
|
265
509
|
export function applyMigrationPhases(ctx, preview, only = ["artifacts", "runtime", "cleanup"]) {
|
|
266
510
|
const result = {
|
|
267
|
-
artifacts: { ...preview.artifacts, items: preview.artifacts.items.map(
|
|
268
|
-
runtime: { ...preview.runtime, items: preview.runtime.items.map(
|
|
269
|
-
cleanup: { ...preview.cleanup, items: preview.cleanup.items.map(
|
|
511
|
+
artifacts: { ...preview.artifacts, items: preview.artifacts.items.map(cloneMigrationItem) },
|
|
512
|
+
runtime: { ...preview.runtime, items: preview.runtime.items.map(cloneMigrationItem) },
|
|
513
|
+
cleanup: { ...preview.cleanup, items: preview.cleanup.items.map(cloneMigrationItem) },
|
|
270
514
|
};
|
|
271
515
|
if (only.includes("artifacts")) {
|
|
272
516
|
applyArtifactsPhase(result.artifacts, ctx.project, ctx.force);
|
|
273
517
|
}
|
|
274
518
|
if (only.includes("runtime")) {
|
|
275
|
-
|
|
519
|
+
applyRuntimeRetirementPhase(result.runtime, ctx);
|
|
276
520
|
}
|
|
277
521
|
if (only.includes("cleanup")) {
|
|
278
522
|
applyCleanupPhase(result.cleanup, ctx);
|
|
279
523
|
}
|
|
280
524
|
return result;
|
|
281
525
|
}
|
|
282
|
-
//# sourceMappingURL=migrateArtifactsV2ToV3.js.map
|
|
@@ -0,0 +1,122 @@
|
|
|
1
|
+
import fs from "node:fs";
|
|
2
|
+
import path from "node:path";
|
|
3
|
+
import { observeLifecyclePath, publishLifecycleResource, removeLifecycleResource, verifyLifecycleResourceAtPublication, withPinnedLifecycleDirectory, } from "../runtime/lifecyclePublication.js";
|
|
4
|
+
const evidenceByItem = new WeakMap();
|
|
5
|
+
const MIGRATION_EVIDENCE = Symbol.for("agentera.migrationMutationEvidence");
|
|
6
|
+
function evidenceFor(item) {
|
|
7
|
+
const existing = evidenceByItem.get(item) ?? item[MIGRATION_EVIDENCE];
|
|
8
|
+
if (existing)
|
|
9
|
+
return existing;
|
|
10
|
+
const created = { resources: {} };
|
|
11
|
+
evidenceByItem.set(item, created);
|
|
12
|
+
item[MIGRATION_EVIDENCE] = created;
|
|
13
|
+
return created;
|
|
14
|
+
}
|
|
15
|
+
function readEvidence(item) {
|
|
16
|
+
return evidenceByItem.get(item) ?? item[MIGRATION_EVIDENCE];
|
|
17
|
+
}
|
|
18
|
+
export function cloneMigrationItem(item) {
|
|
19
|
+
const clone = { ...item };
|
|
20
|
+
const evidence = readEvidence(item);
|
|
21
|
+
if (evidence) {
|
|
22
|
+
evidenceByItem.set(clone, evidence);
|
|
23
|
+
clone[MIGRATION_EVIDENCE] = evidence;
|
|
24
|
+
}
|
|
25
|
+
return clone;
|
|
26
|
+
}
|
|
27
|
+
function observationError(destination, observation, expectedKind) {
|
|
28
|
+
if (observation.unsafeReason)
|
|
29
|
+
return observation.unsafeReason;
|
|
30
|
+
if (!observation.parentComplete)
|
|
31
|
+
return `parent chain is incomplete for ${destination}`;
|
|
32
|
+
if (observation.kind !== expectedKind || !observation.identity || !observation.fingerprint) {
|
|
33
|
+
return `${destination} is not an observable ${expectedKind}`;
|
|
34
|
+
}
|
|
35
|
+
return null;
|
|
36
|
+
}
|
|
37
|
+
export function bindMigrationResource(item, role, destination, allowedRoots, kind) {
|
|
38
|
+
const observation = observeLifecyclePath(destination, allowedRoots);
|
|
39
|
+
const error = observationError(destination, observation, kind);
|
|
40
|
+
if (error)
|
|
41
|
+
return error;
|
|
42
|
+
evidenceFor(item).resources[role] = { destination, kind, observation };
|
|
43
|
+
return null;
|
|
44
|
+
}
|
|
45
|
+
function boundResource(item, role) {
|
|
46
|
+
const resource = readEvidence(item)?.resources[role];
|
|
47
|
+
if (!resource)
|
|
48
|
+
throw new Error(`migration ${role} publication evidence is missing`);
|
|
49
|
+
return resource;
|
|
50
|
+
}
|
|
51
|
+
export function verifyBoundMigrationResource(item, role) {
|
|
52
|
+
const resource = boundResource(item, role);
|
|
53
|
+
verifyLifecycleResourceAtPublication({ id: `${item.action}.${role}`, destination: resource.destination, kind: resource.kind }, resource.observation);
|
|
54
|
+
}
|
|
55
|
+
export function withBoundMigrationDirectory(item, role, callback, hook) {
|
|
56
|
+
const resource = boundResource(item, role);
|
|
57
|
+
if (resource.kind !== "directory")
|
|
58
|
+
throw new Error(`migration ${role} is not a directory`);
|
|
59
|
+
return withPinnedLifecycleDirectory({ id: `${item.action}.${role}`, destination: resource.destination, kind: "directory" }, resource.observation, callback, hook);
|
|
60
|
+
}
|
|
61
|
+
export function updateBoundMigrationFile(item, role, content) {
|
|
62
|
+
const resource = boundResource(item, role);
|
|
63
|
+
if (resource.kind !== "file")
|
|
64
|
+
throw new Error(`migration ${role} is not a file`);
|
|
65
|
+
publishLifecycleResource({ id: `${item.action}.${role}`, destination: resource.destination, kind: "file", content }, "update", resource.observation);
|
|
66
|
+
}
|
|
67
|
+
export function removeBoundMigrationResource(item, role) {
|
|
68
|
+
const resource = boundResource(item, role);
|
|
69
|
+
removeLifecycleResource({ id: `${item.action}.${role}`, destination: resource.destination, kind: resource.kind }, resource.observation);
|
|
70
|
+
}
|
|
71
|
+
function walkTree(root) {
|
|
72
|
+
const entries = [];
|
|
73
|
+
const walk = (destination) => {
|
|
74
|
+
const stat = fs.lstatSync(destination);
|
|
75
|
+
const kind = stat.isSymbolicLink()
|
|
76
|
+
? "symlink"
|
|
77
|
+
: stat.isFile()
|
|
78
|
+
? "file"
|
|
79
|
+
: stat.isDirectory()
|
|
80
|
+
? "directory"
|
|
81
|
+
: (() => { throw new Error(`unsupported bundle entry type at ${destination}`); })();
|
|
82
|
+
entries.push({ destination, kind });
|
|
83
|
+
if (kind === "directory") {
|
|
84
|
+
for (const name of fs.readdirSync(destination).sort())
|
|
85
|
+
walk(path.join(destination, name));
|
|
86
|
+
}
|
|
87
|
+
};
|
|
88
|
+
walk(root);
|
|
89
|
+
return entries;
|
|
90
|
+
}
|
|
91
|
+
export function bindMigrationTree(item, root, allowedRoots) {
|
|
92
|
+
try {
|
|
93
|
+
const tree = walkTree(root).map(({ destination, kind }) => {
|
|
94
|
+
const observation = observeLifecyclePath(destination, allowedRoots);
|
|
95
|
+
const error = observationError(destination, observation, kind);
|
|
96
|
+
if (error)
|
|
97
|
+
throw new Error(error);
|
|
98
|
+
return { destination, kind, observation };
|
|
99
|
+
});
|
|
100
|
+
evidenceFor(item).tree = tree;
|
|
101
|
+
return null;
|
|
102
|
+
}
|
|
103
|
+
catch (error) {
|
|
104
|
+
return error.message;
|
|
105
|
+
}
|
|
106
|
+
}
|
|
107
|
+
export function removeBoundMigrationTree(item) {
|
|
108
|
+
const tree = readEvidence(item)?.tree;
|
|
109
|
+
if (!tree)
|
|
110
|
+
throw new Error("migration cleanup tree evidence is missing");
|
|
111
|
+
const current = walkTree(tree[0].destination);
|
|
112
|
+
if (current.length !== tree.length
|
|
113
|
+
|| current.some((entry, index) => entry.destination !== tree[index]?.destination || entry.kind !== tree[index]?.kind)) {
|
|
114
|
+
throw new Error("managed app cleanup set changed after preview");
|
|
115
|
+
}
|
|
116
|
+
for (const entry of tree) {
|
|
117
|
+
verifyLifecycleResourceAtPublication({ id: `${item.action}.verify`, destination: entry.destination, kind: entry.kind }, entry.observation);
|
|
118
|
+
}
|
|
119
|
+
for (const entry of [...tree].reverse()) {
|
|
120
|
+
removeLifecycleResource({ id: `${item.action}.remove`, destination: entry.destination, kind: entry.kind }, entry.observation);
|
|
121
|
+
}
|
|
122
|
+
}
|