agentera 3.0.0-dev.7 → 3.0.0-dev.72
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 +118 -22
- package/bundle/CHANGELOG.md +1361 -0
- package/bundle/DESIGN.md +229 -0
- package/bundle/LICENSE +201 -0
- package/bundle/README.md +143 -0
- package/bundle/UPGRADE.md +252 -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 +488 -0
- package/bundle/references/adapters/package-registry.yaml +435 -188
- package/bundle/references/adapters/package-surface-characterization.md +66 -34
- 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 +518 -0
- package/bundle/references/analysis/verification-policy.yaml +266 -0
- package/bundle/references/artifacts/artifact-registry-interface-model.yaml +17 -8
- package/bundle/references/artifacts/glossary-entry-contract.yaml +1254 -0
- package/bundle/references/artifacts/state-storage-authority.yaml +3061 -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 +4 -2
- package/bundle/references/cli/vocabulary-index.yaml +5 -7
- package/bundle/references/cli/vocabulary.md +51 -93
- package/bundle/references/meta/retained-reference-authority.yaml +151 -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 +9 -4
- package/bundle/skills/agentera/capabilities/profile/schemas/exit.yaml +4 -4
- package/bundle/skills/agentera/capabilities/profile/schemas/triggers.yaml +8 -37
- package/bundle/skills/agentera/capabilities/profile/schemas/validation.yaml +61 -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 +30 -12
- package/bundle/skills/agentera/schemas/artifacts/design.yaml +1 -0
- package/bundle/skills/agentera/schemas/artifacts/docs.yaml +7 -12
- package/bundle/skills/agentera/schemas/artifacts/experiments.yaml +140 -9
- package/bundle/skills/agentera/schemas/artifacts/glossary.yaml +82 -0
- package/bundle/skills/agentera/schemas/artifacts/health.yaml +56 -19
- package/bundle/skills/agentera/schemas/artifacts/objective.yaml +18 -4
- package/bundle/skills/agentera/schemas/artifacts/plan.yaml +457 -32
- package/bundle/skills/agentera/schemas/artifacts/progress.yaml +131 -18
- package/bundle/skills/agentera/schemas/artifacts/todo.yaml +302 -7
- package/dist/analytics/extractCorpus/cli.js +52 -11
- package/dist/analytics/extractCorpus/copilotSessions.js +6 -4
- package/dist/analytics/extractCorpus/core.js +40 -12
- package/dist/analytics/extractCorpus/corpus.js +39 -17
- package/dist/analytics/extractCorpus/coverageAudit.js +44 -45
- package/dist/analytics/extractCorpus/cursorSessions.js +6 -4
- package/dist/analytics/extractCorpus/evidenceTiers.js +603 -0
- package/dist/analytics/extractCorpus/extractCorpusParity.js +4 -4
- package/dist/analytics/extractCorpus/filesystemSources.js +1 -5
- package/dist/analytics/extractCorpus/index.js +3 -1
- package/dist/analytics/extractCorpus/jsonlSessions.js +24 -5
- package/dist/analytics/extractCorpus/sqliteCaps.js +0 -1
- package/dist/analytics/extractCorpus/sqliteSessions.js +0 -1
- 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 +133 -0
- package/dist/analytics/personalGlossaryProfile.js +219 -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 +16 -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 +70 -6
- 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 +51 -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 +117 -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/personalGlossary.js +176 -0
- package/dist/cli/commands/prime/briefOrientation.js +746 -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 +326 -0
- package/dist/cli/commands/prime/collectOrientationState.js +126 -63
- package/dist/cli/commands/prime/orientationOutput.js +267 -56
- package/dist/cli/commands/prime/types.js +0 -1
- package/dist/cli/commands/prime/v1Migration.js +0 -1
- package/dist/cli/commands/prime.js +76 -11
- package/dist/cli/commands/profileGrounding.js +55 -0
- package/dist/cli/commands/query.js +74 -52
- package/dist/cli/commands/report.js +73 -19
- package/dist/cli/commands/route.js +142 -0
- package/dist/cli/commands/schema.js +257 -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 +433 -0
- package/dist/cli/commands/upgrade.js +146 -5
- package/dist/cli/commands/upgradeVerify.js +118 -0
- package/dist/cli/commands/validate.js +235 -136
- package/dist/cli/commands/verify.js +23 -8
- 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 +77 -52
- package/dist/cli/dispatch/lifecycle.js +117 -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 +358 -39
- package/dist/cli/migrationRequired.js +122 -0
- package/dist/cli/orientation/attention.js +19 -19
- 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/profileAcquisition.js +167 -0
- package/dist/cli/startupCompletenessContract.js +11 -8
- 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 +20 -0
- package/dist/core/developmentChannel.js +1 -0
- package/dist/core/developmentInvocation.js +374 -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 +8 -1
- package/dist/eval/evalSkills.js +13 -14
- 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 +108 -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 +371 -0
- package/dist/registries/glossaryAdviceContract.js +79 -0
- package/dist/registries/glossaryCaveatContract.js +67 -0
- package/dist/registries/glossaryConsumerContractValidation.js +787 -0
- package/dist/registries/glossaryEntryContract.js +757 -0
- package/dist/registries/glossaryTermIdentity.js +17 -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/todoReadinessContract.js +448 -0
- package/dist/registries/triggerLoader.js +7 -44
- package/dist/registries/verbosityBudgetContract.js +205 -0
- package/dist/release/releaseMetadata.js +155 -5
- 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 +502 -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/todoDocsEntities.js +1124 -0
- package/dist/state/todoDocsEntityValidation.js +158 -0
- package/dist/state/todoMarkdownProjection.js +51 -0
- package/dist/state/todoReconciliationActivation.js +182 -0
- package/dist/state/todoReconciliationInspection.js +171 -0
- package/dist/state/todoReconciliationRepair.js +318 -0
- package/dist/state/todoReconciliationTransaction.js +595 -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 +377 -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 +187 -21
- package/dist/upgrade/lifecycleUpgrade.js +113 -0
- package/dist/upgrade/migrateArtifactsV2ToV3.js +334 -64
- package/dist/upgrade/migrationPublication.js +122 -0
- package/dist/upgrade/nextMajorDoctor.js +0 -1
- package/dist/upgrade/npxPlatformStatus.js +0 -1
- package/dist/upgrade/projectIntegration.js +121 -159
- package/dist/upgrade/projectIntegrationDecision.js +42 -85
- package/dist/upgrade/retiredResourceDiagnostics.js +117 -0
- package/dist/upgrade/runtimeMigration.js +262 -453
- package/dist/upgrade/upgradeCommands.js +14 -1
- package/dist/upgrade/upgradeLock.js +85 -0
- package/dist/upgrade/upgradeOrchestrator.js +263 -59
- package/dist/upgrade/v3CapabilitySurface.js +2 -3
- package/dist/upgrade/versionResolution.js +0 -1
- package/dist/validate/activationArtifactEvidence.js +852 -0
- package/dist/validate/activationArtifactEvidenceTypes.js +12 -0
- package/dist/validate/activationConjunction.js +816 -0
- package/dist/validate/activationEvidenceManifest.js +531 -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/retainedReferenceAuthority.js +879 -0
- package/dist/validate/selfAudit.js +39 -45
- package/dist/validate/v1LegacyCruft.js +131 -0
- package/dist/validate/vocabularyAuthority.js +8 -8
- package/package.json +41 -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/dokumentera/instructions.js +0 -6
- package/dist/capabilities/dokumentera/instructions.js.map +0 -1
- package/dist/capabilities/hej/instructions.js +0 -6
- package/dist/capabilities/hej/instructions.js.map +0 -1
- package/dist/capabilities/index.js.map +0 -1
- package/dist/capabilities/inspektera/instructions.js +0 -6
- package/dist/capabilities/inspektera/instructions.js.map +0 -1
- package/dist/capabilities/inspirera/instructions.js +0 -6
- package/dist/capabilities/inspirera/instructions.js.map +0 -1
- package/dist/capabilities/optimera/instructions.js +0 -6
- package/dist/capabilities/optimera/instructions.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/orkestrera/instructions.js +0 -6
- package/dist/capabilities/orkestrera/instructions.js.map +0 -1
- package/dist/capabilities/plan/instructions.js.map +0 -1
- package/dist/capabilities/planera/instructions.js +0 -6
- package/dist/capabilities/planera/instructions.js.map +0 -1
- package/dist/capabilities/profile/instructions.js.map +0 -1
- package/dist/capabilities/profilera/instructions.js +0 -6
- package/dist/capabilities/profilera/instructions.js.map +0 -1
- package/dist/capabilities/realisera/instructions.js +0 -6
- package/dist/capabilities/realisera/instructions.js.map +0 -1
- package/dist/capabilities/research/instructions.js.map +0 -1
- package/dist/capabilities/resonera/instructions.js +0 -6
- package/dist/capabilities/resonera/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/capabilities/visionera/instructions.js +0 -6
- package/dist/capabilities/visionera/instructions.js.map +0 -1
- package/dist/capabilities/visualisera/instructions.js +0 -5
- package/dist/capabilities/visualisera/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/realisera.js +0 -174
- package/dist/cli/capabilityContext/realisera.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/backfill.js +0 -84
- package/dist/cli/commands/backfill.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/routeOutput.js +0 -50
- package/dist/cli/commands/prime/routeOutput.js.map +0 -1
- package/dist/cli/commands/prime/types.js.map +0 -1
- 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/state.js +0 -1023
- package/dist/cli/commands/state.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/git.js +0 -43
- package/dist/core/git.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/todoResolved.js +0 -137
- package/dist/hooks/compaction/todoResolved.js.map +0 -1
- package/dist/hooks/compaction/types.js.map +0 -1
- package/dist/hooks/compaction.js +0 -935
- package/dist/hooks/compaction.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/todoLayout.js +0 -177
- package/dist/hooks/todoLayout.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/hooks/validateArtifact.js +0 -924
- package/dist/hooks/validateArtifact.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/routing/index.js +0 -2
- package/dist/routing/index.js.map +0 -1
- package/dist/routing/routeEngine.js +0 -189
- package/dist/routing/routeEngine.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/progressCommit.js +0 -289
- package/dist/state/progressCommit.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/cliProbe.js +0 -22
- package/dist/upgrade/cliProbe.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,19 +1,24 @@
|
|
|
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 {
|
|
10
|
-
import {
|
|
11
|
-
import {
|
|
13
|
+
import { applyLegacyAgentCleanupItems, planLegacyAgentCleanupItems, planLegacyCapabilityAgentCleanupItems, } from "./legacyAgentCleanup.js";
|
|
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"
|
|
21
|
+
export const MIGRATION_STATUSES = ["pending", "applied", "noop", "blocked", "failed"];
|
|
17
22
|
export const V1_ARTIFACT_PAIRS = [
|
|
18
23
|
[".agentera/PROGRESS.md", ".agentera/progress.yaml"],
|
|
19
24
|
[".agentera/PLAN.md", ".agentera/plan.yaml"],
|
|
@@ -22,15 +27,133 @@ export const V1_ARTIFACT_PAIRS = [
|
|
|
22
27
|
[".agentera/DOCS.md", ".agentera/docs.yaml"],
|
|
23
28
|
["VISION.md", ".agentera/vision.yaml"],
|
|
24
29
|
];
|
|
25
|
-
|
|
26
|
-
|
|
27
|
-
|
|
28
|
-
|
|
29
|
-
|
|
30
|
-
|
|
31
|
-
|
|
30
|
+
const PLAN_ARCHIVE_FILE = /^PLAN-.+\.ya?ml$/i;
|
|
31
|
+
const PLAN_LIFECYCLE_ACTION = "normalize-plan-lifecycle";
|
|
32
|
+
function isMapping(value) {
|
|
33
|
+
return value !== null && typeof value === "object" && !Array.isArray(value);
|
|
34
|
+
}
|
|
35
|
+
function relativeToProject(project, artifactPath) {
|
|
36
|
+
return path.relative(project, artifactPath);
|
|
37
|
+
}
|
|
38
|
+
function planTaskList(data) {
|
|
39
|
+
if (Array.isArray(data.tasks))
|
|
40
|
+
return data.tasks;
|
|
41
|
+
if (Array.isArray(data.entries))
|
|
42
|
+
return data.entries;
|
|
43
|
+
return null;
|
|
44
|
+
}
|
|
45
|
+
function completedTasksOnly(tasks) {
|
|
46
|
+
return tasks.every((task) => isMapping(task) && (task.status === "complete" || task.status === "completed"));
|
|
47
|
+
}
|
|
48
|
+
function rewritePlanStatus(text, status) {
|
|
49
|
+
const document = YAML.parseDocument(text);
|
|
50
|
+
if (document.errors.length > 0) {
|
|
51
|
+
throw new Error(document.errors.map((error) => error.message).join("; "));
|
|
52
|
+
}
|
|
53
|
+
document.setIn(["header", "status"], status);
|
|
54
|
+
return document.toString();
|
|
55
|
+
}
|
|
56
|
+
function lifecycleMigrationItem(project, artifactPath) {
|
|
57
|
+
const source = relativeToProject(project, artifactPath);
|
|
58
|
+
try {
|
|
59
|
+
const text = fs.readFileSync(artifactPath, "utf8");
|
|
60
|
+
const data = loadYamlMapping(text);
|
|
61
|
+
const header = isMapping(data.header) ? data.header : null;
|
|
62
|
+
const tasks = planTaskList(data);
|
|
63
|
+
if (!header || tasks === null) {
|
|
64
|
+
return {
|
|
65
|
+
status: "blocked",
|
|
66
|
+
action: PLAN_LIFECYCLE_ACTION,
|
|
67
|
+
source,
|
|
68
|
+
target: source,
|
|
69
|
+
message: "plan requires a header mapping and a tasks or entries array before lifecycle migration",
|
|
70
|
+
};
|
|
71
|
+
}
|
|
72
|
+
const status = typeof header.status === "string" ? header.status : "";
|
|
73
|
+
if (status === "open" || status === "complete") {
|
|
74
|
+
return {
|
|
75
|
+
status: "noop",
|
|
76
|
+
action: PLAN_LIFECYCLE_ACTION,
|
|
77
|
+
source,
|
|
78
|
+
target: source,
|
|
79
|
+
preserved: ["all plan fields"],
|
|
80
|
+
message: "plan lifecycle is already canonical",
|
|
81
|
+
};
|
|
82
|
+
}
|
|
83
|
+
if (status !== "active" && status !== "completed") {
|
|
84
|
+
return {
|
|
85
|
+
status: "blocked",
|
|
86
|
+
action: PLAN_LIFECYCLE_ACTION,
|
|
87
|
+
source,
|
|
88
|
+
target: source,
|
|
89
|
+
message: `plan header.status must be active, completed, open, or complete; received ${status || "missing"}`,
|
|
90
|
+
};
|
|
91
|
+
}
|
|
92
|
+
const collisions = [];
|
|
93
|
+
const targetStatus = status === "active" || !completedTasksOnly(tasks)
|
|
94
|
+
? "open"
|
|
95
|
+
: "complete";
|
|
96
|
+
if (status === "completed" && targetStatus === "open") {
|
|
97
|
+
collisions.push("header.status=completed conflicts with unfinished task evidence; preserving task evidence and migrating status to open");
|
|
98
|
+
}
|
|
99
|
+
return {
|
|
100
|
+
status: "pending",
|
|
101
|
+
action: PLAN_LIFECYCLE_ACTION,
|
|
102
|
+
source,
|
|
103
|
+
target: source,
|
|
104
|
+
preserved: ["all plan fields except header.status"],
|
|
105
|
+
...(collisions.length > 0 ? { collisions } : {}),
|
|
106
|
+
newText: rewritePlanStatus(text, targetStatus),
|
|
107
|
+
message: `will migrate plan lifecycle ${status} to ${targetStatus}`,
|
|
108
|
+
};
|
|
109
|
+
}
|
|
110
|
+
catch (error) {
|
|
111
|
+
return {
|
|
112
|
+
status: "blocked",
|
|
113
|
+
action: PLAN_LIFECYCLE_ACTION,
|
|
114
|
+
source,
|
|
115
|
+
target: source,
|
|
116
|
+
message: `cannot migrate plan lifecycle: ${error.message}`,
|
|
117
|
+
};
|
|
118
|
+
}
|
|
119
|
+
}
|
|
120
|
+
function lifecyclePlanArtifacts(project) {
|
|
121
|
+
const root = resolvePath(project);
|
|
122
|
+
let activePath;
|
|
123
|
+
try {
|
|
124
|
+
const record = loadArtifactRecord("plan");
|
|
125
|
+
if (!record)
|
|
126
|
+
throw new Error("plan artifact is not registered");
|
|
127
|
+
activePath = resolveArtifactPath(record, root, { strictWrite: true });
|
|
128
|
+
}
|
|
129
|
+
catch (error) {
|
|
130
|
+
return [{
|
|
131
|
+
status: "blocked",
|
|
132
|
+
action: PLAN_LIFECYCLE_ACTION,
|
|
133
|
+
message: `cannot resolve docs-mapped plan path: ${error.message}`,
|
|
134
|
+
}];
|
|
135
|
+
}
|
|
136
|
+
const artifacts = isFile(activePath) ? [activePath] : [];
|
|
137
|
+
const archiveDirectory = path.join(path.dirname(activePath), "archive");
|
|
138
|
+
try {
|
|
139
|
+
for (const name of fs.readdirSync(archiveDirectory).sort()) {
|
|
140
|
+
if (!PLAN_ARCHIVE_FILE.test(name))
|
|
141
|
+
continue;
|
|
142
|
+
const archivePath = path.join(archiveDirectory, name);
|
|
143
|
+
if (isFile(archivePath))
|
|
144
|
+
artifacts.push(archivePath);
|
|
145
|
+
}
|
|
146
|
+
}
|
|
147
|
+
catch {
|
|
148
|
+
// A missing archive directory is normal before the first archive.
|
|
149
|
+
}
|
|
150
|
+
return artifacts.map((artifactPath) => lifecycleMigrationItem(root, artifactPath));
|
|
151
|
+
}
|
|
152
|
+
export function hasPendingPlanLifecycleMigration(project) {
|
|
153
|
+
return lifecyclePlanArtifacts(project).some((item) => item.status === "pending");
|
|
154
|
+
}
|
|
32
155
|
function emptySummary() {
|
|
33
|
-
return { pending: 0, applied: 0, noop: 0, blocked: 0, failed: 0
|
|
156
|
+
return { pending: 0, applied: 0, noop: 0, blocked: 0, failed: 0 };
|
|
34
157
|
}
|
|
35
158
|
export function summarizePhase(name, items, message = "") {
|
|
36
159
|
const summary = emptySummary();
|
|
@@ -50,9 +173,6 @@ export function summarizePhase(name, items, message = "") {
|
|
|
50
173
|
else if (summary.applied > 0) {
|
|
51
174
|
status = "applied";
|
|
52
175
|
}
|
|
53
|
-
else if (summary.skipped > 0 && summary.noop === 0 && summary.applied === 0) {
|
|
54
|
-
status = "skipped";
|
|
55
|
-
}
|
|
56
176
|
else {
|
|
57
177
|
status = "noop";
|
|
58
178
|
}
|
|
@@ -99,35 +219,88 @@ export function planArtifactsPhase(project) {
|
|
|
99
219
|
]);
|
|
100
220
|
}
|
|
101
221
|
const v1Pairs = detectV1ArtifactPairs(root);
|
|
102
|
-
|
|
103
|
-
|
|
104
|
-
|
|
222
|
+
const v1Items = v1Pairs.map((source) => ({
|
|
223
|
+
status: "blocked",
|
|
224
|
+
action: "manual-v1-handoff",
|
|
225
|
+
source,
|
|
226
|
+
message: "v1 Markdown state is unsupported; convert it with a v2 CLI before running the v2-to-v3 upgrade",
|
|
227
|
+
}));
|
|
105
228
|
const yamlArtifacts = listV2YamlArtifacts(root);
|
|
106
|
-
|
|
229
|
+
const lifecycleItems = lifecyclePlanArtifacts(root);
|
|
230
|
+
if (yamlArtifacts.length === 0 && v1Items.length === 0 && lifecycleItems.length === 0) {
|
|
107
231
|
return summarizePhase("artifacts", [], "no project artifacts found");
|
|
108
232
|
}
|
|
109
|
-
const
|
|
110
|
-
|
|
111
|
-
|
|
112
|
-
source
|
|
113
|
-
|
|
114
|
-
|
|
233
|
+
const lifecycleSources = new Set(lifecycleItems.flatMap((item) => item.source ? [item.source] : []));
|
|
234
|
+
const items = [
|
|
235
|
+
...v1Items,
|
|
236
|
+
...yamlArtifacts.filter((source) => !lifecycleSources.has(source)).map((source) => ({
|
|
237
|
+
status: "noop",
|
|
238
|
+
action: "preserve",
|
|
239
|
+
source,
|
|
240
|
+
message: "v2 YAML artifact preserved; no v2→v3 schema migration required",
|
|
241
|
+
})),
|
|
242
|
+
...lifecycleItems,
|
|
243
|
+
];
|
|
115
244
|
return summarizePhase("artifacts", items);
|
|
116
245
|
}
|
|
117
|
-
export function applyArtifactsPhase(phase, project,
|
|
246
|
+
export function applyArtifactsPhase(phase, project, _force = false) {
|
|
118
247
|
const root = resolvePath(project);
|
|
119
|
-
const
|
|
120
|
-
|
|
121
|
-
|
|
122
|
-
|
|
248
|
+
for (const item of phase.items) {
|
|
249
|
+
if (item.status !== "pending" || item.action !== PLAN_LIFECYCLE_ACTION || !item.source)
|
|
250
|
+
continue;
|
|
251
|
+
const sourcePath = path.join(root, item.source);
|
|
252
|
+
const current = lifecycleMigrationItem(root, sourcePath);
|
|
253
|
+
if (current.status !== "pending") {
|
|
254
|
+
item.status = current.status;
|
|
255
|
+
item.message = current.message;
|
|
256
|
+
item.collisions = current.collisions;
|
|
257
|
+
continue;
|
|
258
|
+
}
|
|
259
|
+
if (current.newText !== item.newText) {
|
|
260
|
+
item.status = "blocked";
|
|
261
|
+
item.message = "plan changed after migration preview; rerun dry-run before applying";
|
|
262
|
+
continue;
|
|
263
|
+
}
|
|
264
|
+
try {
|
|
265
|
+
writeFileAtomic(sourcePath, current.newText, "utf8");
|
|
266
|
+
item.status = "applied";
|
|
267
|
+
item.message = "migrated plan lifecycle without changing retained evidence";
|
|
268
|
+
}
|
|
269
|
+
catch (error) {
|
|
270
|
+
item.status = "failed";
|
|
271
|
+
item.message = `plan lifecycle migration failed: ${error.message}`;
|
|
272
|
+
}
|
|
123
273
|
}
|
|
124
|
-
|
|
274
|
+
const updated = summarizePhase("artifacts", phase.items, phase.message);
|
|
275
|
+
phase.status = updated.status;
|
|
276
|
+
phase.summary = updated.summary;
|
|
125
277
|
}
|
|
126
|
-
export function
|
|
278
|
+
export function delegatePlanLifecycleToEntityCutover(phase) {
|
|
279
|
+
for (const item of phase.items) {
|
|
280
|
+
if (item.status !== "pending" || item.action !== PLAN_LIFECYCLE_ACTION)
|
|
281
|
+
continue;
|
|
282
|
+
item.status = "noop";
|
|
283
|
+
item.message = "entity cutover normalizes plan lifecycle while retaining the legacy source as recovery evidence";
|
|
284
|
+
}
|
|
285
|
+
const updated = summarizePhase("artifacts", phase.items, phase.message);
|
|
286
|
+
phase.status = updated.status;
|
|
287
|
+
phase.summary = updated.summary;
|
|
288
|
+
}
|
|
289
|
+
export function planRuntimeRetirementPhase(ctx, _resolvedChannel) {
|
|
127
290
|
const items = planRuntimeMigrationItems(ctx);
|
|
128
|
-
|
|
291
|
+
const blockedPaths = new Set(items
|
|
292
|
+
.filter((item) => item.status === "blocked")
|
|
293
|
+
.flatMap((item) => [item.source, item.target])
|
|
294
|
+
.filter((value) => typeof value === "string"));
|
|
295
|
+
for (const item of items) {
|
|
296
|
+
if (item.status !== "pending" || ![item.source, item.target].some((value) => value && blockedPaths.has(value)))
|
|
297
|
+
continue;
|
|
298
|
+
item.status = "blocked";
|
|
299
|
+
item.message = "action required before Agentera can modify this runtime resource";
|
|
300
|
+
}
|
|
301
|
+
return summarizePhase("runtime", items, items.length === 0 ? "no retired native Agentera hooks found" : "");
|
|
129
302
|
}
|
|
130
|
-
export function
|
|
303
|
+
export function applyRuntimeRetirementPhase(phase, ctx) {
|
|
131
304
|
if (ctx) {
|
|
132
305
|
applyRuntimeMigrationItems(phase.items, ctx);
|
|
133
306
|
}
|
|
@@ -144,13 +317,72 @@ export function applyRuntimeRewirePhase(phase, ctx) {
|
|
|
144
317
|
}
|
|
145
318
|
/** Whether `app/` under app-home still carries a managed bundle worth removing during v2→v3 cleanup. */
|
|
146
319
|
export function hasManagedBundleEvidence(managedAppRoot) {
|
|
147
|
-
|
|
148
|
-
if (isFile(
|
|
149
|
-
return
|
|
320
|
+
const marker = path.join(managedAppRoot, BUNDLE_MARKER);
|
|
321
|
+
if (!isFile(marker))
|
|
322
|
+
return false;
|
|
323
|
+
try {
|
|
324
|
+
const parsed = JSON.parse(fs.readFileSync(marker, "utf8"));
|
|
325
|
+
return parsed.schemaVersion === "agentera.bundle.v1" && typeof parsed.version === "string";
|
|
326
|
+
}
|
|
327
|
+
catch {
|
|
328
|
+
return false;
|
|
150
329
|
}
|
|
151
|
-
|
|
152
|
-
|
|
153
|
-
|
|
330
|
+
}
|
|
331
|
+
const SUPPORTED_V2_BUNDLE_INVENTORY_BY_MAJOR = {
|
|
332
|
+
"2": {
|
|
333
|
+
[BUNDLE_MARKER]: "file",
|
|
334
|
+
"registry.json": "file",
|
|
335
|
+
scripts: "directory",
|
|
336
|
+
"scripts/agentera": "file",
|
|
337
|
+
skills: "directory",
|
|
338
|
+
"skills/agentera": "directory",
|
|
339
|
+
"skills/agentera/SKILL.md": "file",
|
|
340
|
+
},
|
|
341
|
+
};
|
|
342
|
+
function markedBundleInventoryViolations(managedAppRoot) {
|
|
343
|
+
let version;
|
|
344
|
+
try {
|
|
345
|
+
const marker = JSON.parse(fs.readFileSync(path.join(managedAppRoot, BUNDLE_MARKER), "utf8"));
|
|
346
|
+
version = typeof marker.version === "string" ? marker.version : "";
|
|
347
|
+
}
|
|
348
|
+
catch {
|
|
349
|
+
return ["bundle marker is unreadable"];
|
|
350
|
+
}
|
|
351
|
+
const inventory = SUPPORTED_V2_BUNDLE_INVENTORY_BY_MAJOR[version.split(".")[0] ?? ""];
|
|
352
|
+
if (!inventory)
|
|
353
|
+
return [`bundle version ${version || "missing"} has no supported cleanup inventory`];
|
|
354
|
+
const actual = new Map();
|
|
355
|
+
const walk = (directory, prefix = "") => {
|
|
356
|
+
for (const name of fs.readdirSync(directory).sort()) {
|
|
357
|
+
const destination = path.join(directory, name);
|
|
358
|
+
const relative = prefix ? `${prefix}/${name}` : name;
|
|
359
|
+
const stat = fs.lstatSync(destination);
|
|
360
|
+
const kind = stat.isSymbolicLink()
|
|
361
|
+
? "symlink"
|
|
362
|
+
: stat.isFile()
|
|
363
|
+
? "file"
|
|
364
|
+
: stat.isDirectory()
|
|
365
|
+
? "directory"
|
|
366
|
+
: "other";
|
|
367
|
+
actual.set(relative, kind);
|
|
368
|
+
if (kind === "directory")
|
|
369
|
+
walk(destination, relative);
|
|
370
|
+
}
|
|
371
|
+
};
|
|
372
|
+
walk(managedAppRoot);
|
|
373
|
+
const violations = [];
|
|
374
|
+
for (const [relative, kind] of actual) {
|
|
375
|
+
const expected = inventory[relative];
|
|
376
|
+
if (!expected)
|
|
377
|
+
violations.push(`unknown ${kind} ${relative}`);
|
|
378
|
+
else if (expected !== kind)
|
|
379
|
+
violations.push(`${relative} must be ${expected}, found ${kind}`);
|
|
380
|
+
}
|
|
381
|
+
for (const [relative, kind] of Object.entries(inventory)) {
|
|
382
|
+
if (!actual.has(relative))
|
|
383
|
+
violations.push(`missing ${kind} ${relative}`);
|
|
384
|
+
}
|
|
385
|
+
return violations.sort();
|
|
154
386
|
}
|
|
155
387
|
function listManagedBundlePreview(managedAppRoot, limit = 20) {
|
|
156
388
|
if (!pathExists(managedAppRoot)) {
|
|
@@ -185,7 +417,17 @@ export function planCleanupPhase(ctx) {
|
|
|
185
417
|
env: ctx.env,
|
|
186
418
|
});
|
|
187
419
|
const preserved = preflight.preservedAbsolutePaths;
|
|
188
|
-
const
|
|
420
|
+
const installedHookItems = planInstalledHooksRetirementItems(ctx).filter((item) => item.status !== "noop"
|
|
421
|
+
&& item.source !== undefined
|
|
422
|
+
&& !item.source.startsWith(`${managedAppRoot}${path.sep}`));
|
|
423
|
+
const hasOwnedRootHooks = installedHookItems.some((item) => item.source?.startsWith(`${path.join(appHome, "hooks")}${path.sep}`));
|
|
424
|
+
const unknown = appHomeHasUnrecognizedEntriesWithPreflight(appHome, preflight)
|
|
425
|
+
.filter((name) => !(name === "hooks" && hasOwnedRootHooks));
|
|
426
|
+
const managedBundle = hasManagedBundleEvidence(managedAppRoot);
|
|
427
|
+
const refreshAuthorized = managedBundle
|
|
428
|
+
|| hasBundleRootEvidence(roots.activeBundleRoot)
|
|
429
|
+
|| (pathExists(appHome) && fs.readdirSync(appHome).length === 0);
|
|
430
|
+
const appRootUnknown = managedBundle ? markedBundleInventoryViolations(managedAppRoot) : [];
|
|
189
431
|
const items = [
|
|
190
432
|
...preflight.handoffCatalog.map((entry) => ({
|
|
191
433
|
status: "noop",
|
|
@@ -194,8 +436,12 @@ export function planCleanupPhase(ctx) {
|
|
|
194
436
|
preserved: entry.entries,
|
|
195
437
|
message: handoffCatalogMessage(entry),
|
|
196
438
|
})),
|
|
197
|
-
...planAppContentRefreshItems(ctx),
|
|
198
439
|
...planLegacyAgentCleanupItems(ctx),
|
|
440
|
+
...planLegacyCapabilityAgentCleanupItems(ctx),
|
|
441
|
+
...installedHookItems,
|
|
442
|
+
...(refreshAuthorized
|
|
443
|
+
? planAppContentRefreshItems(ctx).filter((item) => item.action === "refresh-app-content")
|
|
444
|
+
: []),
|
|
199
445
|
];
|
|
200
446
|
if (unknown.length > 0 && !ctx.force) {
|
|
201
447
|
items.push({
|
|
@@ -203,18 +449,39 @@ export function planCleanupPhase(ctx) {
|
|
|
203
449
|
action: "remove-managed-app-home",
|
|
204
450
|
source: appHome,
|
|
205
451
|
preserved,
|
|
206
|
-
message:
|
|
452
|
+
message: `app home has unrecognized entries (not preserved user state or managed app content): ${unknown.join(", ")}; cleanup blocked without --force`,
|
|
453
|
+
});
|
|
454
|
+
return summarizePhase("cleanup", items);
|
|
455
|
+
}
|
|
456
|
+
if (appRootUnknown.length > 0) {
|
|
457
|
+
items.push({
|
|
458
|
+
status: "blocked",
|
|
459
|
+
action: "remove-managed-app-home",
|
|
460
|
+
source: managedAppRoot,
|
|
461
|
+
target: appHome,
|
|
462
|
+
preserved: [managedAppRoot],
|
|
463
|
+
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`,
|
|
207
464
|
});
|
|
208
465
|
return summarizePhase("cleanup", items);
|
|
209
466
|
}
|
|
210
|
-
if (!
|
|
467
|
+
if (!managedBundle) {
|
|
468
|
+
if (pathExists(managedAppRoot)) {
|
|
469
|
+
items.push({
|
|
470
|
+
status: "blocked",
|
|
471
|
+
action: "remove-managed-app-home",
|
|
472
|
+
source: managedAppRoot,
|
|
473
|
+
target: appHome,
|
|
474
|
+
message: `app directory preserved because ${BUNDLE_MARKER} ownership evidence is missing or invalid; review it manually`,
|
|
475
|
+
});
|
|
476
|
+
return summarizePhase("cleanup", items);
|
|
477
|
+
}
|
|
211
478
|
if (items.length === 0) {
|
|
212
479
|
return summarizePhase("cleanup", [], "no managed Python app-home bundle to remove");
|
|
213
480
|
}
|
|
214
481
|
return summarizePhase("cleanup", items);
|
|
215
482
|
}
|
|
216
483
|
const removedPreview = listManagedBundlePreview(managedAppRoot);
|
|
217
|
-
|
|
484
|
+
const cleanupItem = {
|
|
218
485
|
status: "pending",
|
|
219
486
|
action: "remove-managed-app-home",
|
|
220
487
|
source: managedAppRoot,
|
|
@@ -222,32 +489,36 @@ export function planCleanupPhase(ctx) {
|
|
|
222
489
|
preserved,
|
|
223
490
|
removedPreview,
|
|
224
491
|
message: "will remove managed Python app-home bundle under app/ while preserving user state at app-home root",
|
|
225
|
-
}
|
|
226
|
-
|
|
227
|
-
|
|
228
|
-
|
|
229
|
-
|
|
230
|
-
return;
|
|
492
|
+
};
|
|
493
|
+
const evidenceError = bindMigrationTree(cleanupItem, managedAppRoot, [appHome]);
|
|
494
|
+
if (evidenceError) {
|
|
495
|
+
cleanupItem.status = "blocked";
|
|
496
|
+
cleanupItem.message = `managed app cleanup preserved the bundle: ${evidenceError}; review the unsafe path manually`;
|
|
231
497
|
}
|
|
232
|
-
|
|
498
|
+
items.push(cleanupItem);
|
|
499
|
+
return summarizePhase("cleanup", items);
|
|
233
500
|
}
|
|
234
501
|
export function applyCleanupPhase(phase, ctx) {
|
|
235
502
|
if (ctx) {
|
|
503
|
+
applyLegacyAgentCleanupItems(phase.items, ctx);
|
|
504
|
+
applyInstalledHooksRetirementItems(phase.items, ctx);
|
|
236
505
|
applyAppContentRefreshItems(phase.items, ctx);
|
|
237
506
|
}
|
|
238
|
-
applyLegacyAgentCleanupItems(phase.items);
|
|
239
507
|
for (const item of phase.items) {
|
|
240
508
|
if (item.status !== "pending" || item.action !== "remove-managed-app-home" || !item.source) {
|
|
241
509
|
continue;
|
|
242
510
|
}
|
|
243
511
|
try {
|
|
244
|
-
|
|
512
|
+
if (process.env.NODE_ENV === "test" && process.env.AGENTERA_FAULT_INJECT_V2_CLEANUP_FAILURE === "1") {
|
|
513
|
+
throw new Error("simulated post-marker cleanup failure");
|
|
514
|
+
}
|
|
515
|
+
removeBoundMigrationTree(item);
|
|
245
516
|
item.status = "applied";
|
|
246
517
|
item.message = "managed Python app-home bundle removed; user state preserved";
|
|
247
518
|
}
|
|
248
519
|
catch (exc) {
|
|
249
|
-
item.status = "
|
|
250
|
-
item.message = `cleanup
|
|
520
|
+
item.status = "blocked";
|
|
521
|
+
item.message = `cleanup preserved the managed app bundle: ${exc.message}; rerun migration and review it manually`;
|
|
251
522
|
}
|
|
252
523
|
}
|
|
253
524
|
const updated = summarizePhase("cleanup", phase.items, phase.message);
|
|
@@ -257,25 +528,24 @@ export function applyCleanupPhase(phase, ctx) {
|
|
|
257
528
|
export function dryRunMigration(ctx) {
|
|
258
529
|
return {
|
|
259
530
|
artifacts: planArtifactsPhase(ctx.project),
|
|
260
|
-
runtime:
|
|
531
|
+
runtime: planRuntimeRetirementPhase(ctx),
|
|
261
532
|
cleanup: planCleanupPhase(ctx),
|
|
262
533
|
};
|
|
263
534
|
}
|
|
264
535
|
export function applyMigrationPhases(ctx, preview, only = ["artifacts", "runtime", "cleanup"]) {
|
|
265
536
|
const result = {
|
|
266
|
-
artifacts: { ...preview.artifacts, items: preview.artifacts.items.map(
|
|
267
|
-
runtime: { ...preview.runtime, items: preview.runtime.items.map(
|
|
268
|
-
cleanup: { ...preview.cleanup, items: preview.cleanup.items.map(
|
|
537
|
+
artifacts: { ...preview.artifacts, items: preview.artifacts.items.map(cloneMigrationItem) },
|
|
538
|
+
runtime: { ...preview.runtime, items: preview.runtime.items.map(cloneMigrationItem) },
|
|
539
|
+
cleanup: { ...preview.cleanup, items: preview.cleanup.items.map(cloneMigrationItem) },
|
|
269
540
|
};
|
|
270
541
|
if (only.includes("artifacts")) {
|
|
271
542
|
applyArtifactsPhase(result.artifacts, ctx.project, ctx.force);
|
|
272
543
|
}
|
|
273
544
|
if (only.includes("runtime")) {
|
|
274
|
-
|
|
545
|
+
applyRuntimeRetirementPhase(result.runtime, ctx);
|
|
275
546
|
}
|
|
276
547
|
if (only.includes("cleanup")) {
|
|
277
548
|
applyCleanupPhase(result.cleanup, ctx);
|
|
278
549
|
}
|
|
279
550
|
return result;
|
|
280
551
|
}
|
|
281
|
-
//# 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
|
+
}
|