agentera 3.0.0-dev.8 → 3.0.0-dev.81
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 +1389 -0
- package/bundle/DESIGN.md +229 -0
- package/bundle/LICENSE +201 -0
- package/bundle/README.md +142 -0
- package/bundle/UPGRADE.md +275 -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 +357 -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 +262 -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 +3075 -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 +162 -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 +618 -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 +894 -0
- package/dist/state/entityWriterLock.js +18 -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 +126 -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 +257 -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
|
@@ -7,19 +7,6 @@ import { resolveRunningVersion } from "./versionResolution.js";
|
|
|
7
7
|
*/
|
|
8
8
|
export const NEXT_MAJOR_SECTION_HEADER = "Next major";
|
|
9
9
|
export const NEXT_MAJOR_LINE_CAP = 6;
|
|
10
|
-
/** v1 installs predate the channel authority; hardcoded stable-line successor mapping. */
|
|
11
|
-
export const V1_NEXT_MAJOR_FALLBACK = {
|
|
12
|
-
concept: "forward_successor_line",
|
|
13
|
-
currentVersion: "1.x",
|
|
14
|
-
currentChannel: "stable",
|
|
15
|
-
channel: "stable",
|
|
16
|
-
version: "2.x",
|
|
17
|
-
announced: true,
|
|
18
|
-
npmOnlyAdvisory: "",
|
|
19
|
-
guideUrl: "https://github.com/jgabor/agentera/blob/main/UPGRADE.md#recommended-upgrade-v1--v2-stable-channel",
|
|
20
|
-
previewCommand: "npx -y agentera@latest upgrade --dry-run",
|
|
21
|
-
irreversibleAdvisory: "Forward migration upgrades artifact format from Markdown to YAML; review the preview before applying.",
|
|
22
|
-
};
|
|
23
10
|
function parseNextMajorBlock(raw) {
|
|
24
11
|
if (raw === null || raw === undefined) {
|
|
25
12
|
return null;
|
|
@@ -120,14 +107,6 @@ export function resolveNextMajorDoctorLines(ctx) {
|
|
|
120
107
|
const displayChannel = install?.kind === "v2_managed_app_home" ? "stable" : currentChannel;
|
|
121
108
|
const runningDistributionMajor = ctx.runningDistributionMajor ??
|
|
122
109
|
(install?.kind === "v2_managed_app_home" ? 2 : cliDistributionMajor(sourceRoot));
|
|
123
|
-
if (runningDistributionMajor === 1) {
|
|
124
|
-
const block = V1_NEXT_MAJOR_FALLBACK;
|
|
125
|
-
return formatNextMajorDoctorLines({
|
|
126
|
-
currentVersion: block.currentVersion,
|
|
127
|
-
currentChannel: block.currentChannel,
|
|
128
|
-
block,
|
|
129
|
-
});
|
|
130
|
-
}
|
|
131
110
|
const authorityBlock = loadChannelNextMajor(sourceRoot, successorChannel);
|
|
132
111
|
if (!authorityBlock || !authorityBlock.announced) {
|
|
133
112
|
return null;
|
|
@@ -153,4 +132,3 @@ export function prependNextMajorDoctorSection(text, sectionLines) {
|
|
|
153
132
|
}
|
|
154
133
|
return `${sectionLines.join("\n")}\n\n${text}`;
|
|
155
134
|
}
|
|
156
|
-
//# sourceMappingURL=nextMajorDoctor.js.map
|
|
@@ -1,4 +1,5 @@
|
|
|
1
1
|
import { expanduser } from "../core/paths.js";
|
|
2
|
+
import { SOURCE_LABELS } from "../state/installRoot.js";
|
|
2
3
|
import { resolvePlatformAppHome } from "./appModel.js";
|
|
3
4
|
import { buildDoctorStatus } from "./doctor.js";
|
|
4
5
|
/** Shared npx platform app-home resolution for prime and projectIntegration. */
|
|
@@ -6,7 +7,7 @@ export function resolveNpxPlatformStatus(opts) {
|
|
|
6
7
|
const env = { ...process.env, ...(opts.env ?? {}), HOME: expanduser(opts.home) };
|
|
7
8
|
const platformRoot = resolvePlatformAppHome(opts.home, env);
|
|
8
9
|
const doctorOpts = {
|
|
9
|
-
rootSource:
|
|
10
|
+
rootSource: SOURCE_LABELS.default,
|
|
10
11
|
sourceRoot: opts.sourceRoot,
|
|
11
12
|
home: opts.home,
|
|
12
13
|
project: opts.project,
|
|
@@ -20,4 +21,3 @@ export function resolveNpxPlatformStatus(opts) {
|
|
|
20
21
|
const platformStatus = buildDoctorStatus(platformRoot, doctorOpts);
|
|
21
22
|
return { platformRoot, platformStatus };
|
|
22
23
|
}
|
|
23
|
-
//# sourceMappingURL=npxPlatformStatus.js.map
|
|
@@ -0,0 +1,515 @@
|
|
|
1
|
+
import { createHash } from "node:crypto";
|
|
2
|
+
import fs from "node:fs";
|
|
3
|
+
import os from "node:os";
|
|
4
|
+
import path from "node:path";
|
|
5
|
+
import { resolveProfileDirOverride } from "../core/envPaths.js";
|
|
6
|
+
import { expanduser } from "../core/paths.js";
|
|
7
|
+
import { resolveSourceRoot } from "../core/sourceRoot.js";
|
|
8
|
+
import { loadNativeResourceCleanupContract, } from "../runtime/nativeResourceCleanup.js";
|
|
9
|
+
import { defaultAppHome } from "../state/installRoot.js";
|
|
10
|
+
import { classifyProjectState } from "../state/stateMode.js";
|
|
11
|
+
import { applyAppContentRefresh } from "./appContentRefresh.js";
|
|
12
|
+
import { loadProductV1ResetAuthority } from "./productV1ResetAuthority.js";
|
|
13
|
+
function hash(bytes) {
|
|
14
|
+
return createHash("sha256").update(bytes).digest("hex");
|
|
15
|
+
}
|
|
16
|
+
function lstat(target) {
|
|
17
|
+
try {
|
|
18
|
+
return fs.lstatSync(target);
|
|
19
|
+
}
|
|
20
|
+
catch (error) {
|
|
21
|
+
if (error.code === "ENOENT")
|
|
22
|
+
return null;
|
|
23
|
+
throw error;
|
|
24
|
+
}
|
|
25
|
+
}
|
|
26
|
+
function existingAncestor(target) {
|
|
27
|
+
let candidate = target;
|
|
28
|
+
while (lstat(candidate) === null) {
|
|
29
|
+
const parent = path.dirname(candidate);
|
|
30
|
+
if (parent === candidate)
|
|
31
|
+
break;
|
|
32
|
+
candidate = parent;
|
|
33
|
+
}
|
|
34
|
+
return candidate;
|
|
35
|
+
}
|
|
36
|
+
function safeRoot(name, value) {
|
|
37
|
+
const absolute = path.resolve(expanduser(value));
|
|
38
|
+
if (lstat(absolute)?.isSymbolicLink())
|
|
39
|
+
throw new Error(`${name} must not be a symbolic link: ${absolute}`);
|
|
40
|
+
const ancestor = existingAncestor(absolute);
|
|
41
|
+
const resolved = path.join(fs.realpathSync(ancestor), path.relative(ancestor, absolute));
|
|
42
|
+
if (resolved !== absolute)
|
|
43
|
+
throw new Error(`${name} resolves through an alias outside its declared root: ${absolute}`);
|
|
44
|
+
return absolute;
|
|
45
|
+
}
|
|
46
|
+
function resolvedRoots(options) {
|
|
47
|
+
const env = options.env ?? process.env;
|
|
48
|
+
const home = safeRoot("runtime home", options.home ?? os.homedir());
|
|
49
|
+
const project = safeRoot("project root", options.project ?? process.cwd());
|
|
50
|
+
const installCandidate = options.installRoot ?? env.AGENTERA_HOME ?? env.AGENTERA_DEFAULT_INSTALL_ROOT
|
|
51
|
+
?? defaultAppHome(env, home);
|
|
52
|
+
const installRoot = safeRoot("install root", installCandidate);
|
|
53
|
+
const profileRoot = safeRoot("profile root", resolveProfileDirOverride(env) ?? installRoot);
|
|
54
|
+
return { project, profile_root: profileRoot, install_root: installRoot, runtime_home: home };
|
|
55
|
+
}
|
|
56
|
+
function assertContained(root, target) {
|
|
57
|
+
const relative = path.relative(root, target);
|
|
58
|
+
if (relative === ".." || relative.startsWith(`..${path.sep}`) || path.isAbsolute(relative)) {
|
|
59
|
+
throw new Error(`reset target is outside its declared root: ${target}`);
|
|
60
|
+
}
|
|
61
|
+
let current = root;
|
|
62
|
+
for (const part of relative.split(path.sep).filter(Boolean).slice(0, -1)) {
|
|
63
|
+
current = path.join(current, part);
|
|
64
|
+
if (lstat(current)?.isSymbolicLink()) {
|
|
65
|
+
throw new Error(`reset target resolves through a symbolic link: ${current}`);
|
|
66
|
+
}
|
|
67
|
+
}
|
|
68
|
+
}
|
|
69
|
+
function snapshot(target) {
|
|
70
|
+
if (lstat(target) === null)
|
|
71
|
+
return [{ path: target, type: "absent" }];
|
|
72
|
+
const result = [];
|
|
73
|
+
const visit = (current) => {
|
|
74
|
+
const stat = fs.lstatSync(current);
|
|
75
|
+
if (stat.isSymbolicLink()) {
|
|
76
|
+
result.push({ path: current, type: "symlink", link_target: fs.readlinkSync(current) });
|
|
77
|
+
return;
|
|
78
|
+
}
|
|
79
|
+
if (stat.isDirectory()) {
|
|
80
|
+
result.push({ path: current, type: "directory" });
|
|
81
|
+
for (const name of fs.readdirSync(current).sort())
|
|
82
|
+
visit(path.join(current, name));
|
|
83
|
+
return;
|
|
84
|
+
}
|
|
85
|
+
if (stat.isFile()) {
|
|
86
|
+
result.push({ path: current, type: "file", sha256: hash(fs.readFileSync(current)) });
|
|
87
|
+
return;
|
|
88
|
+
}
|
|
89
|
+
result.push({ path: current, type: "other" });
|
|
90
|
+
};
|
|
91
|
+
visit(target);
|
|
92
|
+
return result;
|
|
93
|
+
}
|
|
94
|
+
function inFileState(target) {
|
|
95
|
+
const stat = lstat(target);
|
|
96
|
+
if (stat === null)
|
|
97
|
+
return { type: "absent" };
|
|
98
|
+
if (!stat.isFile() || stat.isSymbolicLink()) {
|
|
99
|
+
throw new Error(`in-file reset target must be a regular file, not a link or directory: ${target}`);
|
|
100
|
+
}
|
|
101
|
+
return { type: "file", sha256: hash(fs.readFileSync(target)) };
|
|
102
|
+
}
|
|
103
|
+
function expandTemplate(template, roots) {
|
|
104
|
+
return path.resolve(template
|
|
105
|
+
.replaceAll("{project}", roots.project)
|
|
106
|
+
.replaceAll("{home}", roots.runtime_home)
|
|
107
|
+
.replaceAll("{install_root}", roots.install_root));
|
|
108
|
+
}
|
|
109
|
+
function runtimeTargets(roots, contract) {
|
|
110
|
+
const targets = [];
|
|
111
|
+
for (const resource of contract.diagnosticResources) {
|
|
112
|
+
const names = resource.names.length > 0 ? resource.names : [null];
|
|
113
|
+
for (const name of names)
|
|
114
|
+
for (const destination of resource.destinations) {
|
|
115
|
+
const declared = name === null ? destination : destination.replaceAll("{name}", name);
|
|
116
|
+
const target = expandTemplate(declared, roots);
|
|
117
|
+
const root = declared.startsWith("{project}") ? roots.project
|
|
118
|
+
: declared.startsWith("{install_root}") ? roots.install_root : roots.runtime_home;
|
|
119
|
+
assertContained(root, target);
|
|
120
|
+
targets.push(resource.contains === null
|
|
121
|
+
? { declared, operation: "remove_path", path: target, entries: snapshot(target) }
|
|
122
|
+
: {
|
|
123
|
+
declared,
|
|
124
|
+
operation: "remove_in_file_selector",
|
|
125
|
+
path: target,
|
|
126
|
+
selector: { kind: "contains", value: resource.contains },
|
|
127
|
+
file_state: inFileState(target),
|
|
128
|
+
});
|
|
129
|
+
}
|
|
130
|
+
}
|
|
131
|
+
for (const unit of contract.configuration) {
|
|
132
|
+
const target = expandTemplate(unit.destination, roots);
|
|
133
|
+
assertContained(roots.runtime_home, target);
|
|
134
|
+
targets.push({
|
|
135
|
+
declared: unit.destination,
|
|
136
|
+
operation: "remove_in_file_selector",
|
|
137
|
+
path: target,
|
|
138
|
+
selector: { kind: "key", value: unit.key },
|
|
139
|
+
file_state: inFileState(target),
|
|
140
|
+
});
|
|
141
|
+
}
|
|
142
|
+
return targets;
|
|
143
|
+
}
|
|
144
|
+
function evidence(project, installRoot, manifest) {
|
|
145
|
+
const authority = loadProductV1ResetAuthority();
|
|
146
|
+
const found = authority.projectArtifacts
|
|
147
|
+
.filter((item) => item.triggersReset && fs.existsSync(path.join(project, item.path)))
|
|
148
|
+
.map((item) => path.join(project, item.path));
|
|
149
|
+
const registryPath = path.join(installRoot, manifest);
|
|
150
|
+
if (fs.existsSync(registryPath)) {
|
|
151
|
+
try {
|
|
152
|
+
const value = JSON.parse(fs.readFileSync(registryPath, "utf8"));
|
|
153
|
+
if (typeof value.skills?.[0]?.version === "string" && /^1\./.test(value.skills[0].version))
|
|
154
|
+
found.push(registryPath);
|
|
155
|
+
}
|
|
156
|
+
catch { /* malformed state is not product-generation evidence */ }
|
|
157
|
+
}
|
|
158
|
+
return found.sort();
|
|
159
|
+
}
|
|
160
|
+
export function previewProductV1Reset(options = {}, dependencies = {}) {
|
|
161
|
+
const roots = resolvedRoots(options);
|
|
162
|
+
const project = roots.project;
|
|
163
|
+
const installRoot = roots.install_root;
|
|
164
|
+
const authority = loadProductV1ResetAuthority();
|
|
165
|
+
const foundEvidence = evidence(project, installRoot, authority.installationPackage.manifest);
|
|
166
|
+
if (foundEvidence.length === 0)
|
|
167
|
+
throw new Error("product-v1 reset requires declared product-v1 generation evidence");
|
|
168
|
+
const rootFor = (name) => name === "runtime_declared_roots" ? roots.runtime_home : roots[name];
|
|
169
|
+
const deletions = authority.scope.filter((item) => item.action === "delete").map((item) => ({
|
|
170
|
+
id: item.id,
|
|
171
|
+
owner: item.owner,
|
|
172
|
+
root: rootFor(item.boundedRoot),
|
|
173
|
+
targets: item.boundedRoot === "runtime_declared_roots"
|
|
174
|
+
? runtimeTargets(roots, dependencies.runtimeContract ?? loadNativeResourceCleanupContract())
|
|
175
|
+
: item.targets.map((declared) => {
|
|
176
|
+
const target = path.resolve(rootFor(item.boundedRoot), declared);
|
|
177
|
+
assertContained(rootFor(item.boundedRoot), target);
|
|
178
|
+
return { declared, operation: "remove_path", path: target, entries: snapshot(target) };
|
|
179
|
+
}),
|
|
180
|
+
}));
|
|
181
|
+
const recreations = authority.scope.filter((item) => item.action === "recreate").map((item) => ({
|
|
182
|
+
id: item.id,
|
|
183
|
+
owner: item.owner,
|
|
184
|
+
root: rootFor(item.boundedRoot),
|
|
185
|
+
targets: item.targets.map((declared) => ({ declared })),
|
|
186
|
+
}));
|
|
187
|
+
const unsigned = {
|
|
188
|
+
schemaVersion: "agentera.productV1ResetPreview.v1",
|
|
189
|
+
mode: "preview",
|
|
190
|
+
status: "review_required",
|
|
191
|
+
evidence: foundEvidence,
|
|
192
|
+
roots,
|
|
193
|
+
deletions,
|
|
194
|
+
recreations,
|
|
195
|
+
irreversible_loss: deletions.map(({ id }) => `${id}: permanently removes only the listed paths and in-file selectors; no backup, rollback, or restore is available.`),
|
|
196
|
+
mutation_performed: false,
|
|
197
|
+
};
|
|
198
|
+
return { ...unsigned, authorization: `sha256:${hash(JSON.stringify(unsigned))}` };
|
|
199
|
+
}
|
|
200
|
+
const RESET_JOURNAL = ".agentera-product-v1-reset.json";
|
|
201
|
+
const RESET_JOURNAL_STAGING = `${RESET_JOURNAL}.staging`;
|
|
202
|
+
const SELECTOR_STAGING_SUFFIX = ".agentera-product-v1-reset.staging";
|
|
203
|
+
function validatedScope(preview) {
|
|
204
|
+
return { roots: preview.roots, deletions: preview.deletions, recreations: preview.recreations };
|
|
205
|
+
}
|
|
206
|
+
function journalPath(project) {
|
|
207
|
+
return path.join(project, RESET_JOURNAL);
|
|
208
|
+
}
|
|
209
|
+
function journalStagingPath(project) {
|
|
210
|
+
return path.join(project, RESET_JOURNAL_STAGING);
|
|
211
|
+
}
|
|
212
|
+
function selectorStagingPath(target) {
|
|
213
|
+
return `${target}${SELECTOR_STAGING_SUFFIX}`;
|
|
214
|
+
}
|
|
215
|
+
function journalDigest(journal) {
|
|
216
|
+
return hash(JSON.stringify(journal));
|
|
217
|
+
}
|
|
218
|
+
function assertRegularJournalFile(target) {
|
|
219
|
+
const stat = lstat(target);
|
|
220
|
+
if (stat === null)
|
|
221
|
+
return;
|
|
222
|
+
if (!stat.isFile() || stat.isSymbolicLink())
|
|
223
|
+
throw new Error(`product-v1 reset journal is not a regular file: ${target}`);
|
|
224
|
+
}
|
|
225
|
+
function parseJournal(project, authorization) {
|
|
226
|
+
const target = journalPath(project);
|
|
227
|
+
if (lstat(target) === null)
|
|
228
|
+
return null;
|
|
229
|
+
assertRegularJournalFile(target);
|
|
230
|
+
const journal = JSON.parse(fs.readFileSync(target, "utf8"));
|
|
231
|
+
if (journal.schemaVersion !== "agentera.productV1ResetJournal.v1" || journal.preview?.authorization !== authorization) {
|
|
232
|
+
throw new Error("product-v1 reset journal does not match the approved operation");
|
|
233
|
+
}
|
|
234
|
+
const { authorization: _stored, ...unsigned } = journal.preview;
|
|
235
|
+
if (`sha256:${hash(JSON.stringify(unsigned))}` !== authorization)
|
|
236
|
+
throw new Error("product-v1 reset journal scope is corrupt");
|
|
237
|
+
if (!["prepared", "deleting", "initializing", "complete"].includes(journal.stage))
|
|
238
|
+
throw new Error("product-v1 reset journal stage is corrupt");
|
|
239
|
+
const digestInput = {
|
|
240
|
+
schemaVersion: journal.schemaVersion,
|
|
241
|
+
preview: journal.preview,
|
|
242
|
+
selector_states: journal.selector_states,
|
|
243
|
+
};
|
|
244
|
+
if (journal.digest !== journalDigest(digestInput))
|
|
245
|
+
throw new Error("product-v1 reset journal is corrupt");
|
|
246
|
+
return journal;
|
|
247
|
+
}
|
|
248
|
+
function writeJournal(project, journal) {
|
|
249
|
+
const staging = journalStagingPath(project);
|
|
250
|
+
assertRegularJournalFile(staging);
|
|
251
|
+
fs.rmSync(staging, { force: true });
|
|
252
|
+
fs.writeFileSync(staging, JSON.stringify(journal) + "\n", { flag: "wx", mode: 0o600 });
|
|
253
|
+
fs.renameSync(staging, journalPath(project));
|
|
254
|
+
}
|
|
255
|
+
function journalFor(preview, stage) {
|
|
256
|
+
const selector_states = selectorStates(validatedScope(preview));
|
|
257
|
+
const base = { schemaVersion: "agentera.productV1ResetJournal.v1", preview, selector_states };
|
|
258
|
+
return { ...base, stage, digest: journalDigest(base) };
|
|
259
|
+
}
|
|
260
|
+
function setJournalStage(project, journal, stage) {
|
|
261
|
+
const updated = { ...journal, stage };
|
|
262
|
+
writeJournal(project, updated);
|
|
263
|
+
return updated;
|
|
264
|
+
}
|
|
265
|
+
function removeTomlSection(lines, header) {
|
|
266
|
+
const escaped = header.replace(/[.*+?^${}()|[\]\\]/g, "\\$&");
|
|
267
|
+
const exactHeader = new RegExp(`^\\s*${escaped}\\s*(?:#.*)?$`);
|
|
268
|
+
const start = lines.findIndex((line) => exactHeader.test(line));
|
|
269
|
+
if (start < 0)
|
|
270
|
+
return lines;
|
|
271
|
+
let end = start + 1;
|
|
272
|
+
while (end < lines.length && !/^\s*\[.+\]\s*(?:#.*)?$/.test(lines[end]))
|
|
273
|
+
end += 1;
|
|
274
|
+
return [...lines.slice(0, start), ...lines.slice(end)];
|
|
275
|
+
}
|
|
276
|
+
function removeTomlKey(lines, dottedKey) {
|
|
277
|
+
const parts = dottedKey.split(".");
|
|
278
|
+
const key = parts.pop();
|
|
279
|
+
const section = parts.join(".");
|
|
280
|
+
let current = "";
|
|
281
|
+
return lines.filter((line) => {
|
|
282
|
+
const header = line.match(/^\s*\[([^\]]+)\]\s*(?:#.*)?$/);
|
|
283
|
+
if (header)
|
|
284
|
+
current = header[1].trim();
|
|
285
|
+
return !(current === section && new RegExp(`^\\s*${key.replace(/[.*+?^${}()|[\]\\]/g, "\\$&")}\\s*=`).test(line));
|
|
286
|
+
});
|
|
287
|
+
}
|
|
288
|
+
function transformedSelectors(original, selectors) {
|
|
289
|
+
const trailingNewline = original.endsWith("\n");
|
|
290
|
+
let lines = original.split("\n");
|
|
291
|
+
if (trailingNewline)
|
|
292
|
+
lines.pop();
|
|
293
|
+
for (const selector of selectors) {
|
|
294
|
+
if (selector.kind === "key")
|
|
295
|
+
lines = removeTomlKey(lines, selector.value);
|
|
296
|
+
else if (selector.value.startsWith("[") && selector.value.endsWith("]"))
|
|
297
|
+
lines = removeTomlSection(lines, selector.value);
|
|
298
|
+
else
|
|
299
|
+
lines = removeTomlKey(lines, selector.value);
|
|
300
|
+
}
|
|
301
|
+
return lines.join("\n") + (trailingNewline ? "\n" : "");
|
|
302
|
+
}
|
|
303
|
+
function selectorGroups(scope) {
|
|
304
|
+
const groups = new Map();
|
|
305
|
+
for (const deletion of scope.deletions)
|
|
306
|
+
for (const target of deletion.targets) {
|
|
307
|
+
if (target.operation === "remove_in_file_selector" && target.path && target.selector) {
|
|
308
|
+
groups.set(target.path, [...(groups.get(target.path) ?? []), target.selector]);
|
|
309
|
+
}
|
|
310
|
+
}
|
|
311
|
+
return groups;
|
|
312
|
+
}
|
|
313
|
+
function selectorStates(scope) {
|
|
314
|
+
return [...selectorGroups(scope)].map(([target, selectors]) => {
|
|
315
|
+
const stat = lstat(target);
|
|
316
|
+
if (stat === null)
|
|
317
|
+
return { path: target, before: "absent", after: "absent" };
|
|
318
|
+
if (!stat.isFile() || stat.isSymbolicLink())
|
|
319
|
+
throw new Error(`in-file reset target must be a regular file: ${target}`);
|
|
320
|
+
const original = fs.readFileSync(target, "utf8");
|
|
321
|
+
const approved = scope.deletions.flatMap((deletion) => deletion.targets)
|
|
322
|
+
.find((candidate) => candidate.path === target)?.file_state?.sha256;
|
|
323
|
+
if (approved !== hash(original))
|
|
324
|
+
throw new Error("product-v1 reset scope changed after preview; run a new preview and review its authorization");
|
|
325
|
+
return { path: target, before: hash(original), after: hash(transformedSelectors(original, selectors)) };
|
|
326
|
+
});
|
|
327
|
+
}
|
|
328
|
+
function cleanSelectorStaging(states) {
|
|
329
|
+
for (const state of states)
|
|
330
|
+
fs.rmSync(selectorStagingPath(state.path), { force: true });
|
|
331
|
+
}
|
|
332
|
+
function removeSelectors(target, selectors, afterEffect) {
|
|
333
|
+
const stat = lstat(target);
|
|
334
|
+
if (stat === null)
|
|
335
|
+
return;
|
|
336
|
+
if (!stat.isFile() || stat.isSymbolicLink())
|
|
337
|
+
throw new Error(`in-file reset target must remain a regular file: ${target}`);
|
|
338
|
+
const original = fs.readFileSync(target, "utf8");
|
|
339
|
+
const updated = transformedSelectors(original, selectors);
|
|
340
|
+
if (updated === original)
|
|
341
|
+
return;
|
|
342
|
+
const staging = selectorStagingPath(target);
|
|
343
|
+
const mode = stat.mode & 0o7777;
|
|
344
|
+
fs.writeFileSync(staging, updated, { flag: "wx", mode });
|
|
345
|
+
fs.chmodSync(staging, mode);
|
|
346
|
+
afterEffect?.(`selector-staged:${target}`);
|
|
347
|
+
fs.renameSync(staging, target);
|
|
348
|
+
}
|
|
349
|
+
function sameScopePath(left, right) {
|
|
350
|
+
return left.path === right.path && left.type === right.type && left.sha256 === right.sha256 && left.link_target === right.link_target;
|
|
351
|
+
}
|
|
352
|
+
function validateRemovePath(target, exact) {
|
|
353
|
+
const approved = target.entries ?? [];
|
|
354
|
+
const current = snapshot(target.path);
|
|
355
|
+
if (current.length === 1 && current[0].type === "absent") {
|
|
356
|
+
if (exact && !(approved.length === 1 && approved[0].type === "absent"))
|
|
357
|
+
throw new Error(`reset retry target changed after approval: ${target.path}`);
|
|
358
|
+
return;
|
|
359
|
+
}
|
|
360
|
+
const approvedByPath = new Map(approved.map((entry) => [entry.path, entry]));
|
|
361
|
+
if (current.some((entry) => !approvedByPath.has(entry.path) || !sameScopePath(entry, approvedByPath.get(entry.path)))) {
|
|
362
|
+
throw new Error(`reset retry target has a new or changed entry: ${target.path}`);
|
|
363
|
+
}
|
|
364
|
+
if (exact && (current.length !== approved.length || approved.some((entry) => !current.some((candidate) => sameScopePath(candidate, entry))))) {
|
|
365
|
+
throw new Error(`reset retry target changed after approval: ${target.path}`);
|
|
366
|
+
}
|
|
367
|
+
}
|
|
368
|
+
function validateSelectorState(state, stage) {
|
|
369
|
+
const stat = lstat(state.path);
|
|
370
|
+
if (stat === null) {
|
|
371
|
+
if (stage === "prepared" && state.before !== "absent")
|
|
372
|
+
throw new Error(`reset retry selector target changed after approval: ${state.path}`);
|
|
373
|
+
return;
|
|
374
|
+
}
|
|
375
|
+
if (!stat.isFile() || stat.isSymbolicLink())
|
|
376
|
+
throw new Error(`reset retry selector target changed after approval: ${state.path}`);
|
|
377
|
+
const current = hash(fs.readFileSync(state.path));
|
|
378
|
+
const allowed = stage === "initializing" ? [state.after] : stage === "prepared" ? [state.before] : [state.before, state.after];
|
|
379
|
+
if (!allowed.includes(current))
|
|
380
|
+
throw new Error(`reset retry selector target has changed: ${state.path}`);
|
|
381
|
+
}
|
|
382
|
+
function validateRetryState(journal) {
|
|
383
|
+
const scope = validatedScope(journal.preview);
|
|
384
|
+
const exact = journal.stage === "prepared";
|
|
385
|
+
for (const deletion of scope.deletions)
|
|
386
|
+
for (const target of deletion.targets) {
|
|
387
|
+
if (target.operation === "remove_path" && target.path) {
|
|
388
|
+
if (journal.stage === "initializing") {
|
|
389
|
+
const current = snapshot(target.path);
|
|
390
|
+
if (!(current.length === 1 && current[0].type === "absent")) {
|
|
391
|
+
throw new Error(`reset retry target reappeared after deletion: ${target.path}`);
|
|
392
|
+
}
|
|
393
|
+
}
|
|
394
|
+
else
|
|
395
|
+
validateRemovePath(target, exact);
|
|
396
|
+
}
|
|
397
|
+
}
|
|
398
|
+
for (const state of journal.selector_states)
|
|
399
|
+
validateSelectorState(state, journal.stage);
|
|
400
|
+
}
|
|
401
|
+
function loadResetJournal(options, authorization, dependencies, project) {
|
|
402
|
+
const target = journalPath(project);
|
|
403
|
+
const staging = journalStagingPath(project);
|
|
404
|
+
const hasTarget = lstat(target) !== null;
|
|
405
|
+
const hasStaging = lstat(staging) !== null;
|
|
406
|
+
if (hasStaging)
|
|
407
|
+
assertRegularJournalFile(staging);
|
|
408
|
+
if (hasTarget) {
|
|
409
|
+
try {
|
|
410
|
+
const journal = parseJournal(project, authorization);
|
|
411
|
+
if (hasStaging)
|
|
412
|
+
fs.rmSync(staging, { force: true });
|
|
413
|
+
return { journal, retry: true };
|
|
414
|
+
}
|
|
415
|
+
catch (error) {
|
|
416
|
+
try {
|
|
417
|
+
const preview = approvedProductV1ResetPreview(options, authorization, dependencies);
|
|
418
|
+
const journal = journalFor(preview, "prepared");
|
|
419
|
+
writeJournal(project, journal);
|
|
420
|
+
return { journal, retry: true };
|
|
421
|
+
}
|
|
422
|
+
catch {
|
|
423
|
+
throw new Error(`product-v1 reset journal cannot be recovered after effects may have begun: ${error.message}`);
|
|
424
|
+
}
|
|
425
|
+
}
|
|
426
|
+
}
|
|
427
|
+
const preview = approvedProductV1ResetPreview(options, authorization, dependencies);
|
|
428
|
+
const journal = journalFor(preview, "prepared");
|
|
429
|
+
writeJournal(project, journal);
|
|
430
|
+
return { journal, retry: false };
|
|
431
|
+
}
|
|
432
|
+
function initializeFreshV3(scope) {
|
|
433
|
+
const sourceRoot = resolveSourceRoot();
|
|
434
|
+
applyAppContentRefresh(scope.roots.install_root, sourceRoot);
|
|
435
|
+
const skill = path.join(scope.roots.runtime_home, ".agents", "skills", "agentera");
|
|
436
|
+
assertContained(scope.roots.runtime_home, skill);
|
|
437
|
+
fs.rmSync(skill, { recursive: true, force: true });
|
|
438
|
+
fs.mkdirSync(path.dirname(skill), { recursive: true });
|
|
439
|
+
fs.symlinkSync(path.join(scope.roots.install_root, "skills", "agentera"), skill);
|
|
440
|
+
if (classifyProjectState(scope.roots.project, sourceRoot).state !== "fresh_uninitialized") {
|
|
441
|
+
throw new Error("canonical fresh-v3 project initialization did not produce fresh_uninitialized state");
|
|
442
|
+
}
|
|
443
|
+
}
|
|
444
|
+
export function applyProductV1Reset(options, authorization, dependencies = {}) {
|
|
445
|
+
const roots = resolvedRoots(options);
|
|
446
|
+
let { journal, retry } = loadResetJournal(options, authorization, dependencies, roots.project);
|
|
447
|
+
if (JSON.stringify(journal.preview.roots) !== JSON.stringify(roots)) {
|
|
448
|
+
throw new Error("product-v1 reset retry roots do not match the approved operation");
|
|
449
|
+
}
|
|
450
|
+
if (retry)
|
|
451
|
+
cleanSelectorStaging(journal.selector_states);
|
|
452
|
+
if (!retry) {
|
|
453
|
+
dependencies.afterEffect?.("journal");
|
|
454
|
+
}
|
|
455
|
+
const scope = validatedScope(journal.preview);
|
|
456
|
+
if (journal.stage !== "complete")
|
|
457
|
+
validateRetryState(journal);
|
|
458
|
+
if (journal.stage === "prepared")
|
|
459
|
+
journal = setJournalStage(roots.project, journal, "deleting");
|
|
460
|
+
if (journal.stage === "deleting") {
|
|
461
|
+
for (const deletion of scope.deletions)
|
|
462
|
+
for (const target of deletion.targets) {
|
|
463
|
+
const targetRoot = target.declared.startsWith("{project}") ? scope.roots.project
|
|
464
|
+
: target.declared.startsWith("{install_root}") ? scope.roots.install_root
|
|
465
|
+
: deletion.id === "runtime.resources" ? scope.roots.runtime_home : deletion.root;
|
|
466
|
+
if (target.path)
|
|
467
|
+
assertContained(targetRoot, target.path);
|
|
468
|
+
if (target.operation === "remove_path" && target.path) {
|
|
469
|
+
if (retry)
|
|
470
|
+
validateRemovePath(target, false);
|
|
471
|
+
fs.rmSync(target.path, { recursive: true, force: true });
|
|
472
|
+
dependencies.afterEffect?.(`delete:${deletion.id}:${target.declared}`);
|
|
473
|
+
}
|
|
474
|
+
}
|
|
475
|
+
for (const [target, approvedSelectors] of selectorGroups(scope)) {
|
|
476
|
+
if (retry)
|
|
477
|
+
validateSelectorState(journal.selector_states.find((state) => state.path === target), "deleting");
|
|
478
|
+
removeSelectors(target, approvedSelectors, dependencies.afterEffect);
|
|
479
|
+
dependencies.afterEffect?.(`selectors:${target}`);
|
|
480
|
+
}
|
|
481
|
+
journal = setJournalStage(roots.project, journal, "initializing");
|
|
482
|
+
}
|
|
483
|
+
if (journal.stage === "initializing") {
|
|
484
|
+
initializeFreshV3(scope);
|
|
485
|
+
journal = setJournalStage(roots.project, journal, "complete");
|
|
486
|
+
dependencies.afterEffect?.("initialize:fresh-v3");
|
|
487
|
+
}
|
|
488
|
+
cleanSelectorStaging(journal.selector_states);
|
|
489
|
+
fs.rmSync(journalStagingPath(roots.project), { force: true });
|
|
490
|
+
fs.rmSync(journalPath(roots.project), { force: true });
|
|
491
|
+
return {
|
|
492
|
+
schemaVersion: "agentera.productV1ResetApply.v1",
|
|
493
|
+
status: "complete",
|
|
494
|
+
authorization,
|
|
495
|
+
validated_scope: scope,
|
|
496
|
+
effects_performed: true,
|
|
497
|
+
};
|
|
498
|
+
}
|
|
499
|
+
export function authorizeProductV1Reset(options, authorization, dependencies = {}) {
|
|
500
|
+
const current = approvedProductV1ResetPreview(options, authorization, dependencies);
|
|
501
|
+
return {
|
|
502
|
+
schemaVersion: "agentera.productV1ResetAuthorization.v1",
|
|
503
|
+
status: "authorized",
|
|
504
|
+
authorization,
|
|
505
|
+
validated_scope: validatedScope(current),
|
|
506
|
+
effects_performed: false,
|
|
507
|
+
};
|
|
508
|
+
}
|
|
509
|
+
function approvedProductV1ResetPreview(options, authorization, dependencies) {
|
|
510
|
+
const current = previewProductV1Reset(options, dependencies);
|
|
511
|
+
if (authorization !== current.authorization) {
|
|
512
|
+
throw new Error("product-v1 reset scope changed after preview; run a new preview and review its authorization");
|
|
513
|
+
}
|
|
514
|
+
return current;
|
|
515
|
+
}
|