agentera 3.0.0-dev.5 → 3.0.0-dev.51
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 +119 -22
- package/bundle/CHANGELOG.md +1351 -0
- package/bundle/DESIGN.md +229 -0
- package/bundle/LICENSE +201 -0
- package/bundle/README.md +143 -0
- package/bundle/UPGRADE.md +236 -0
- package/bundle/extract-corpus-parity.json +21 -0
- package/bundle/fixtures/routing/hybrid-corpus.yaml +154 -0
- package/bundle/references/adapters/package-publication.json +437 -0
- package/bundle/references/adapters/package-registry.yaml +435 -189
- package/bundle/references/adapters/package-surface-characterization.md +66 -35
- 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 +191 -0
- package/bundle/references/artifacts/artifact-registry-interface-model.yaml +20 -10
- package/bundle/references/artifacts/glossary-entry-contract.yaml +1254 -0
- package/bundle/references/artifacts/state-storage-authority.yaml +3022 -0
- package/bundle/references/artifacts/verbosity-budget-authority.yaml +42 -0
- package/bundle/references/cli/app-lifecycle-vocabulary.yaml +7 -8
- 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 +155 -0
- package/bundle/references/cli/trigger-schema-enrichment.md +147 -0
- package/bundle/references/cli/update-channels.yaml +19 -1
- package/bundle/references/cli/vocabulary-index.yaml +20 -17
- package/bundle/references/cli/vocabulary.md +326 -361
- package/bundle/references/meta/retained-reference-authority.yaml +151 -0
- package/bundle/registry.json +13 -13
- package/bundle/skills/agentera/SKILL.md +224 -422
- package/bundle/skills/agentera/capabilities/audit/schemas/artifacts.yaml +84 -0
- package/bundle/skills/agentera/capabilities/{inspektera → audit}/schemas/exit.yaml +2 -2
- package/bundle/skills/agentera/capabilities/audit/schemas/triggers.yaml +25 -0
- package/bundle/skills/agentera/capabilities/{inspektera → audit}/schemas/validation.yaml +37 -18
- package/bundle/skills/agentera/capabilities/build/schemas/artifacts.yaml +102 -0
- package/bundle/skills/agentera/capabilities/{realisera → build}/schemas/exit.yaml +6 -5
- package/bundle/skills/agentera/capabilities/build/schemas/triggers.yaml +27 -0
- package/bundle/skills/agentera/capabilities/build/schemas/validation.yaml +176 -0
- package/bundle/skills/agentera/capabilities/{visualisera → design}/schemas/artifacts.yaml +12 -12
- package/bundle/skills/agentera/capabilities/{visualisera → design}/schemas/exit.yaml +5 -5
- package/bundle/skills/agentera/capabilities/design/schemas/triggers.yaml +16 -0
- package/bundle/skills/agentera/capabilities/{visualisera → design}/schemas/validation.yaml +7 -7
- package/bundle/skills/agentera/capabilities/discuss/schemas/artifacts.yaml +51 -0
- package/bundle/skills/agentera/capabilities/{resonera → discuss}/schemas/exit.yaml +2 -2
- package/bundle/skills/agentera/capabilities/discuss/schemas/triggers.yaml +20 -0
- package/bundle/skills/agentera/capabilities/discuss/schemas/validation.yaml +144 -0
- package/bundle/skills/agentera/capabilities/document/schemas/artifacts.yaml +80 -0
- package/bundle/skills/agentera/capabilities/document/schemas/triggers.yaml +16 -0
- package/bundle/skills/agentera/capabilities/{dokumentera → document}/schemas/validation.yaml +18 -18
- package/bundle/skills/agentera/capabilities/{optimera → optimize}/schemas/artifacts.yaml +18 -18
- package/bundle/skills/agentera/capabilities/{optimera → optimize}/schemas/exit.yaml +2 -2
- package/bundle/skills/agentera/capabilities/optimize/schemas/triggers.yaml +16 -0
- package/bundle/skills/agentera/capabilities/{optimera → optimize}/schemas/validation.yaml +9 -9
- package/bundle/skills/agentera/capabilities/orchestrate/schemas/artifacts.yaml +76 -0
- package/bundle/skills/agentera/capabilities/{orkestrera → orchestrate}/schemas/exit.yaml +9 -7
- package/bundle/skills/agentera/capabilities/orchestrate/schemas/triggers.yaml +23 -0
- package/bundle/skills/agentera/capabilities/orchestrate/schemas/validation.yaml +121 -0
- package/bundle/skills/agentera/capabilities/plan/schemas/artifacts.yaml +66 -0
- package/bundle/skills/agentera/capabilities/{planera → plan}/schemas/exit.yaml +2 -2
- package/bundle/skills/agentera/capabilities/plan/schemas/triggers.yaml +23 -0
- package/bundle/skills/agentera/capabilities/plan/schemas/validation.yaml +121 -0
- package/bundle/skills/agentera/capabilities/profile/schemas/artifacts.yaml +23 -0
- package/bundle/skills/agentera/capabilities/{profilera → profile}/schemas/exit.yaml +6 -5
- package/bundle/skills/agentera/capabilities/profile/schemas/triggers.yaml +20 -0
- package/bundle/skills/agentera/capabilities/profile/schemas/validation.yaml +115 -0
- package/bundle/skills/agentera/capabilities/research/schemas/artifacts.yaml +24 -0
- package/bundle/skills/agentera/capabilities/research/schemas/triggers.yaml +16 -0
- package/bundle/skills/agentera/capabilities/{inspirera → research}/schemas/validation.yaml +2 -2
- package/bundle/skills/agentera/capabilities/status/schemas/artifacts.yaml +73 -0
- package/bundle/skills/agentera/capabilities/status/schemas/triggers.yaml +22 -0
- package/bundle/skills/agentera/capabilities/{hej → status}/schemas/validation.yaml +5 -5
- package/bundle/skills/agentera/capabilities/{visionera → vision}/schemas/artifacts.yaml +16 -16
- package/bundle/skills/agentera/capabilities/{visionera → vision}/schemas/exit.yaml +7 -6
- package/bundle/skills/agentera/capabilities/vision/schemas/triggers.yaml +23 -0
- package/bundle/skills/agentera/capabilities/{visionera → vision}/schemas/validation.yaml +18 -20
- package/bundle/skills/agentera/capability_schema_contract.yaml +178 -34
- package/bundle/skills/agentera/protocol.yaml +31 -31
- package/bundle/skills/agentera/route-phrases.yaml +81 -0
- package/bundle/skills/agentera/schemas/artifacts/changelog.yaml +5 -4
- package/bundle/skills/agentera/schemas/artifacts/decisions.yaml +39 -21
- package/bundle/skills/agentera/schemas/artifacts/design.yaml +5 -4
- package/bundle/skills/agentera/schemas/artifacts/docs.yaml +15 -19
- package/bundle/skills/agentera/schemas/artifacts/experiments.yaml +145 -14
- package/bundle/skills/agentera/schemas/artifacts/glossary.yaml +82 -0
- package/bundle/skills/agentera/schemas/artifacts/health.yaml +58 -21
- package/bundle/skills/agentera/schemas/artifacts/objective.yaml +22 -8
- package/bundle/skills/agentera/schemas/artifacts/plan.yaml +458 -36
- package/bundle/skills/agentera/schemas/artifacts/progress.yaml +128 -17
- package/bundle/skills/agentera/schemas/artifacts/todo.yaml +342 -42
- package/bundle/skills/agentera/schemas/artifacts/vision.yaml +3 -3
- package/dist/analytics/extractCorpus/cli.js +190 -0
- package/dist/analytics/extractCorpus/copilotSessions.js +275 -0
- package/dist/analytics/extractCorpus/core.js +392 -0
- package/dist/analytics/extractCorpus/corpus.js +167 -0
- package/dist/analytics/extractCorpus/coverageAudit.js +260 -0
- package/dist/analytics/extractCorpus/cursorSessions.js +425 -0
- package/dist/analytics/extractCorpus/evidenceTiers.js +603 -0
- package/dist/analytics/extractCorpus/extractCorpusParity.js +105 -0
- package/dist/analytics/extractCorpus/filesystemSources.js +118 -0
- package/dist/analytics/extractCorpus/index.js +14 -0
- package/dist/analytics/extractCorpus/jsonlSessions.js +204 -0
- package/dist/analytics/extractCorpus/sqliteCaps.js +43 -0
- package/dist/analytics/extractCorpus/sqliteSessions.js +367 -0
- package/dist/analytics/extractCorpus/tierReader.js +108 -0
- package/dist/analytics/extractCorpus.js +2 -1791
- 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 +169 -42
- package/dist/audit/terminologyDrift.js +281 -0
- package/dist/bin/agentera.js +3 -2
- package/dist/capabilities/audit/instructions.js +16 -0
- package/dist/capabilities/build/instructions.js +56 -0
- package/dist/capabilities/design/instructions.js +4 -0
- package/dist/capabilities/discuss/instructions.js +29 -0
- package/dist/capabilities/document/instructions.js +11 -0
- package/dist/capabilities/index.js +29 -27
- package/dist/capabilities/optimize/instructions.js +14 -0
- package/dist/capabilities/orchestrate/instructions.js +42 -0
- package/dist/capabilities/plan/instructions.js +33 -0
- package/dist/capabilities/profile/instructions.js +70 -0
- package/dist/capabilities/research/instructions.js +5 -0
- package/dist/capabilities/status/instructions.js +15 -0
- package/dist/capabilities/status/startupInstructions.js +34 -0
- package/dist/capabilities/vision/instructions.js +4 -0
- package/dist/cli/appContext.js +30 -24
- package/dist/cli/argvalidate.js +0 -1
- package/dist/cli/capabilityContext/benchmark.js +565 -0
- package/dist/cli/capabilityContext/bespoke.js +44 -0
- package/dist/cli/capabilityContext/build.js +242 -0
- package/dist/cli/capabilityContext/closeout.js +233 -0
- package/dist/cli/capabilityContext/contract.js +179 -0
- package/dist/cli/capabilityContext/evidence.js +463 -0
- package/dist/cli/capabilityContext/index.js +3 -0
- package/dist/cli/capabilityContext/orchestration.js +131 -0
- package/dist/cli/capabilityContext/planState.js +260 -0
- package/dist/cli/capabilityContext/progress.js +142 -0
- package/dist/cli/capabilityContext/projectVerification.js +409 -0
- package/dist/cli/capabilityContext/shared.js +83 -0
- package/dist/cli/capabilityContext/slim.js +152 -0
- package/dist/cli/capabilityContext/startup.js +150 -0
- package/dist/cli/capabilityContext/startupAggregation.js +68 -0
- package/dist/cli/capabilityContext/types.js +56 -0
- package/dist/cli/capabilityContext.js +1 -2487
- package/dist/cli/commands/appHome.js +22 -0
- package/dist/cli/commands/capability.js +4 -4
- package/dist/cli/commands/compact.js +164 -14
- package/dist/cli/commands/doctor.js +122 -97
- package/dist/cli/commands/durability.js +81 -0
- package/dist/cli/commands/glossaryAdvice.js +138 -0
- package/dist/cli/commands/lint.js +26 -44
- package/dist/cli/commands/personalGlossary.js +176 -0
- package/dist/cli/commands/prime/briefOrientation.js +747 -0
- package/dist/cli/commands/prime/buildExecutionRequest.js +165 -0
- package/dist/cli/commands/prime/bundleStatus.js +190 -0
- package/dist/cli/commands/prime/collectEntityOrientation.js +326 -0
- package/dist/cli/commands/prime/collectOrientationState.js +212 -0
- package/dist/cli/commands/prime/orientationOutput.js +399 -0
- package/dist/cli/commands/prime/types.js +1 -0
- package/dist/cli/commands/prime/v1Migration.js +38 -0
- package/dist/cli/commands/prime.js +80 -558
- package/dist/cli/commands/profileGrounding.js +55 -0
- package/dist/cli/commands/query.js +78 -53
- package/dist/cli/commands/report.js +96 -25
- package/dist/cli/commands/route.js +142 -0
- package/dist/cli/commands/schema.js +266 -143
- package/dist/cli/commands/state/decisions.js +387 -0
- package/dist/cli/commands/state/docs.js +70 -0
- package/dist/cli/commands/state/experimentRecords.js +151 -0
- package/dist/cli/commands/state/experiments.js +14 -0
- package/dist/cli/commands/state/get.js +129 -0
- package/dist/cli/commands/state/health.js +14 -0
- package/dist/cli/commands/state/index.js +16 -0
- package/dist/cli/commands/state/list.js +194 -0
- package/dist/cli/commands/state/objective.js +25 -0
- package/dist/cli/commands/state/plan.js +14 -0
- 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 +13 -0
- package/dist/cli/commands/state/shared.js +14 -0
- package/dist/cli/commands/state/todo.js +42 -0
- package/dist/cli/commands/state/write.js +430 -0
- package/dist/cli/commands/upgrade.js +146 -5
- package/dist/cli/commands/upgradeVerify.js +118 -0
- package/dist/cli/commands/validate.js +272 -223
- package/dist/cli/commands/verify.js +24 -9
- package/dist/cli/contracts/bundleStatus.js +1 -0
- package/dist/cli/contracts/orientationState.js +1 -0
- package/dist/cli/dispatch/argvParser.js +32 -0
- package/dist/cli/dispatch/check.js +372 -0
- package/dist/cli/dispatch/commands.js +27 -0
- package/dist/cli/dispatch/index.js +207 -0
- package/dist/cli/dispatch/lifecycle.js +652 -0
- package/dist/cli/dispatch/prime.js +139 -0
- package/dist/cli/dispatch/projections.js +17 -0
- package/dist/cli/dispatch/shared.js +63 -0
- package/dist/cli/dispatch/state.js +140 -0
- package/dist/cli/dispatch.js +1 -1294
- package/dist/cli/errors.js +16 -17
- package/dist/cli/help.js +394 -43
- package/dist/cli/migrationRequired.js +87 -0
- package/dist/cli/orientation/attention.js +61 -0
- package/dist/cli/orientation/corpusCoverage.js +102 -0
- package/dist/cli/orientation.js +438 -170
- 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 +59 -0
- package/dist/cli/stateQuery.js +56 -14
- 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 +18 -0
- 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 +20 -0
- package/dist/core/jsonValue.js +5 -0
- package/dist/core/paths.js +0 -1
- package/dist/core/pyjson.js +67 -3
- 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 +30 -26
- package/dist/eval/hybridRouteEvaluation.js +155 -0
- package/dist/eval/semanticEval.js +43 -20
- package/dist/eval/semanticFixtures.js +16 -5
- package/dist/hooks/common.js +11 -79
- package/dist/hooks/compaction/apply.js +446 -0
- package/dist/hooks/compaction/dryRun.js +184 -0
- package/dist/hooks/compaction/index.js +22 -0
- package/dist/hooks/compaction/parse.js +325 -0
- package/dist/hooks/compaction/retention.js +202 -0
- package/dist/hooks/compaction/status.js +360 -0
- package/dist/hooks/compaction/types.js +5 -0
- package/dist/hooks/validateArtifact/agentFacing.js +9 -0
- package/dist/hooks/validateArtifact/index.js +92 -0
- package/dist/hooks/validateArtifact/markdown.js +145 -0
- package/dist/hooks/validateArtifact/schema.js +546 -0
- package/dist/hooks/validateArtifact/traversal.js +107 -0
- package/dist/hooks/validateArtifact/violations.js +107 -0
- package/dist/migrate/v2HandoffManifest.js +452 -0
- package/dist/registries/activationContract.js +2 -0
- package/dist/registries/activationTuples.js +107 -0
- package/dist/registries/artifactProtocolIds.js +78 -0
- package/dist/registries/artifactRegistry.js +224 -63
- package/dist/registries/artifactSchemaProjection.js +45 -0
- package/dist/registries/capabilityContract.js +129 -2
- package/dist/registries/evaluatorHandoffContract.js +2 -3
- 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 +229 -0
- package/dist/registries/packageRegistry.js +187 -211
- package/dist/registries/todoReadinessContract.js +448 -0
- package/dist/registries/triggerLoader.js +174 -0
- package/dist/registries/verbosityBudgetContract.js +205 -0
- package/dist/release/releaseMetadata.js +385 -0
- 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 -0
- package/dist/setup/opencodeConstants.js +1 -0
- package/dist/setup/sharedSkill.js +45 -0
- package/dist/setup/smokeChecks.js +21 -82
- 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 +846 -0
- package/dist/state/entityMigrationTodo.js +133 -0
- package/dist/state/entityPublicationContext.js +806 -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 +64 -25
- 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 +982 -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/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 +432 -0
- package/dist/state/startupAnalysis/contract.js +160 -0
- package/dist/state/startupAnalysis/helpers.js +286 -0
- package/dist/state/startupAnalysis/index.js +6 -0
- package/dist/state/startupAnalysis/metrics.js +340 -0
- package/dist/state/startupAnalysis/records.js +198 -0
- package/dist/state/startupAnalysis/report.js +111 -0
- package/dist/state/startupAnalysis/threshold.js +512 -0
- package/dist/state/startupAnalysis.js +2 -1953
- package/dist/state/startupProjection.js +499 -0
- package/dist/state/stateMode.js +85 -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 +1069 -0
- package/dist/state/todoDocsEntityValidation.js +158 -0
- package/dist/state/todoMarkdownProjection.js +51 -0
- package/dist/state/todoReconciliationActivation.js +140 -0
- package/dist/state/todoReconciliationInspection.js +169 -0
- package/dist/state/todoReconciliationRepair.js +170 -0
- package/dist/state/todoReconciliationTransaction.js +582 -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 +363 -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 +367 -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 +144 -0
- package/dist/state/write/serialize.js +1 -0
- package/dist/state/write/transaction.js +52 -0
- package/dist/state/write/validate.js +7 -0
- package/dist/upgrade/appContentRefresh.js +383 -0
- package/dist/upgrade/appModel.js +8 -7
- package/dist/upgrade/atomicWriter.js +1 -0
- package/dist/upgrade/bundleEvidence.js +33 -0
- package/dist/upgrade/channels.js +12 -8
- package/dist/upgrade/compatibility.js +56 -21
- package/dist/upgrade/doctor.js +197 -192
- package/dist/upgrade/doctorClassifier.js +187 -0
- package/dist/upgrade/installedHooksRetirement.js +196 -0
- package/dist/upgrade/legacyAgentCleanup.js +282 -0
- package/dist/upgrade/lifecycleUpgrade.js +113 -0
- package/dist/upgrade/migrateArtifactsV2ToV3.js +367 -149
- package/dist/upgrade/migrationPublication.js +122 -0
- package/dist/upgrade/nextMajorDoctor.js +42 -8
- package/dist/upgrade/npxPlatformStatus.js +22 -0
- package/dist/upgrade/projectIntegration.js +145 -187
- package/dist/upgrade/projectIntegrationDecision.js +50 -0
- package/dist/upgrade/retiredResourceDiagnostics.js +117 -0
- package/dist/upgrade/runtimeMigration.js +273 -363
- 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 +14 -0
- package/dist/upgrade/versionResolution.js +8 -1
- package/dist/validate/activationArtifactEvidence.js +844 -0
- package/dist/validate/activationConjunction.js +816 -0
- package/dist/validate/activationEvidenceManifest.js +515 -0
- package/dist/validate/activationPackageSemantics.js +29 -0
- package/dist/validate/appHomeContract.js +5 -11
- package/dist/validate/bootstrapAuthority.js +44 -0
- package/dist/validate/capability.js +133 -12
- package/dist/validate/crossCapability.js +15 -10
- package/dist/validate/retainedReferenceAuthority.js +879 -0
- package/dist/validate/selfAudit.js +73 -37
- package/dist/validate/v1LegacyCruft.js +131 -0
- package/dist/validate/vocabularyAuthority.js +303 -0
- package/package.json +53 -27
- package/bundle/references/adapters/cursor.md +0 -213
- 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 -548
- 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 -355
- package/bundle/references/cli/bundle-skill-vocabulary.yaml +0 -278
- package/bundle/references/cli/capability-tool-classification.yaml +0 -53
- package/bundle/references/cli/routing-execution-vocabulary.yaml +0 -281
- package/bundle/references/meta/documentation-inventory.md +0 -43
- package/bundle/references/v1-section-mapping.md +0 -47
- package/bundle/skills/agentera/.claude-plugin/plugin.json +0 -27
- package/bundle/skills/agentera/agents/dokumentera.toml +0 -6
- package/bundle/skills/agentera/agents/hej.toml +0 -6
- package/bundle/skills/agentera/agents/inspektera.toml +0 -6
- package/bundle/skills/agentera/agents/inspirera.toml +0 -6
- package/bundle/skills/agentera/agents/optimera.toml +0 -6
- package/bundle/skills/agentera/agents/orkestrera.toml +0 -6
- package/bundle/skills/agentera/agents/planera.toml +0 -6
- package/bundle/skills/agentera/agents/profilera.toml +0 -6
- package/bundle/skills/agentera/agents/realisera.toml +0 -6
- package/bundle/skills/agentera/agents/resonera.toml +0 -6
- package/bundle/skills/agentera/agents/visionera.toml +0 -6
- package/bundle/skills/agentera/agents/visualisera.toml +0 -6
- package/bundle/skills/agentera/capabilities/dokumentera/schemas/artifacts.yaml +0 -73
- package/bundle/skills/agentera/capabilities/dokumentera/schemas/triggers.yaml +0 -35
- package/bundle/skills/agentera/capabilities/hej/schemas/artifacts.yaml +0 -69
- package/bundle/skills/agentera/capabilities/hej/schemas/triggers.yaml +0 -58
- package/bundle/skills/agentera/capabilities/inspektera/schemas/artifacts.yaml +0 -76
- package/bundle/skills/agentera/capabilities/inspektera/schemas/triggers.yaml +0 -38
- package/bundle/skills/agentera/capabilities/inspirera/schemas/artifacts.yaml +0 -24
- package/bundle/skills/agentera/capabilities/inspirera/schemas/triggers.yaml +0 -34
- package/bundle/skills/agentera/capabilities/optimera/schemas/triggers.yaml +0 -39
- package/bundle/skills/agentera/capabilities/orkestrera/schemas/artifacts.yaml +0 -64
- package/bundle/skills/agentera/capabilities/orkestrera/schemas/triggers.yaml +0 -42
- package/bundle/skills/agentera/capabilities/orkestrera/schemas/validation.yaml +0 -120
- package/bundle/skills/agentera/capabilities/planera/schemas/artifacts.yaml +0 -62
- package/bundle/skills/agentera/capabilities/planera/schemas/triggers.yaml +0 -34
- package/bundle/skills/agentera/capabilities/planera/schemas/validation.yaml +0 -61
- package/bundle/skills/agentera/capabilities/profilera/schemas/artifacts.yaml +0 -18
- package/bundle/skills/agentera/capabilities/profilera/schemas/triggers.yaml +0 -45
- package/bundle/skills/agentera/capabilities/profilera/schemas/validation.yaml +0 -57
- package/bundle/skills/agentera/capabilities/realisera/schemas/artifacts.yaml +0 -80
- package/bundle/skills/agentera/capabilities/realisera/schemas/triggers.yaml +0 -39
- package/bundle/skills/agentera/capabilities/realisera/schemas/validation.yaml +0 -110
- package/bundle/skills/agentera/capabilities/resonera/schemas/artifacts.yaml +0 -47
- package/bundle/skills/agentera/capabilities/resonera/schemas/triggers.yaml +0 -46
- package/bundle/skills/agentera/capabilities/resonera/schemas/validation.yaml +0 -77
- package/bundle/skills/agentera/capabilities/visionera/schemas/triggers.yaml +0 -41
- package/bundle/skills/agentera/capabilities/visualisera/schemas/triggers.yaml +0 -33
- package/bundle/skills/agentera/references/contract.md +0 -1039
- package/bundle/skills/hej/.claude-plugin/plugin.json +0 -6
- package/bundle/skills/hej/SKILL.md +0 -69
- package/bundle/skills/hej/agents/hej.toml +0 -11
- package/bundle/skills/hej/agents/openai.yaml +0 -8
- 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/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/orkestrera/instructions.js +0 -6
- package/dist/capabilities/orkestrera/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/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/resonera/instructions.js +0 -6
- package/dist/capabilities/resonera/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 -6
- 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.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.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.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/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.js.map +0 -1
- package/dist/cli/prime-blob.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/core/difflib.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.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 -71
- package/dist/hooks/cursorSessionStart.js.map +0 -1
- package/dist/hooks/sessionStart.js +0 -209
- package/dist/hooks/sessionStart.js.map +0 -1
- package/dist/hooks/sessionStop.js +0 -212
- package/dist/hooks/sessionStop.js.map +0 -1
- package/dist/hooks/validateArtifact.js +0 -935
- package/dist/hooks/validateArtifact.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 -315
- package/dist/registries/runtimeAdapterRegistry.js.map +0 -1
- package/dist/setup/codex.js +0 -1197
- 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 -127
- package/dist/setup/cursor.js.map +0 -1
- package/dist/setup/doctor.js +0 -1297
- package/dist/setup/doctor.js.map +0 -1
- package/dist/setup/smokeChecks.js.map +0 -1
- package/dist/state/installRoot.js.map +0 -1
- package/dist/state/startupAnalysis.js.map +0 -1
- package/dist/upgrade/appModel.js.map +0 -1
- package/dist/upgrade/channels.js.map +0 -1
- package/dist/upgrade/compatibility.js.map +0 -1
- package/dist/upgrade/doctor.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/projectIntegration.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/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.js +0 -772
- package/dist/validate/lifecycleAdapters.js.map +0 -1
- package/dist/validate/selfAudit.js.map +0 -1
- /package/bundle/skills/agentera/capabilities/{dokumentera → document}/schemas/exit.yaml +0 -0
- /package/bundle/skills/agentera/capabilities/{inspirera → research}/schemas/exit.yaml +0 -0
- /package/bundle/skills/agentera/capabilities/{hej → status}/schemas/exit.yaml +0 -0
|
@@ -0,0 +1,546 @@
|
|
|
1
|
+
/**
|
|
2
|
+
* Schema-driven validation helpers for the v2 artifact protocol.
|
|
3
|
+
*
|
|
4
|
+
* Walks the schema (skills/agentera/schemas/artifacts/<name>.yaml) and
|
|
5
|
+
* a parsed artifact mapping, producing a list of human-readable
|
|
6
|
+
* violation strings. The helpers in this file are pure (no I/O) and
|
|
7
|
+
* are orchestrated by `violations.ts` for the YAML side and by
|
|
8
|
+
* `markdown.ts` for the human-facing side.
|
|
9
|
+
*/
|
|
10
|
+
export function isMapping(v) {
|
|
11
|
+
return v !== null && typeof v === "object" && !Array.isArray(v);
|
|
12
|
+
}
|
|
13
|
+
export function pyTypeName(v) {
|
|
14
|
+
if (v === null || v === undefined)
|
|
15
|
+
return "NoneType";
|
|
16
|
+
if (typeof v === "boolean")
|
|
17
|
+
return "bool";
|
|
18
|
+
if (typeof v === "number")
|
|
19
|
+
return Number.isInteger(v) ? "int" : "float";
|
|
20
|
+
if (typeof v === "string")
|
|
21
|
+
return "str";
|
|
22
|
+
if (Array.isArray(v))
|
|
23
|
+
return "list";
|
|
24
|
+
if (typeof v === "object")
|
|
25
|
+
return "dict";
|
|
26
|
+
return typeof v;
|
|
27
|
+
}
|
|
28
|
+
export function wordCount(text) {
|
|
29
|
+
return (text.match(/\S+/g) ?? []).length;
|
|
30
|
+
}
|
|
31
|
+
const SKIP_META = new Set([
|
|
32
|
+
"meta",
|
|
33
|
+
"GROUP_PREFIXES",
|
|
34
|
+
"BUDGET",
|
|
35
|
+
"COMPACTION",
|
|
36
|
+
"VALIDATION",
|
|
37
|
+
"CONVENTION",
|
|
38
|
+
]);
|
|
39
|
+
const LIST_INDICATORS = new Set(["number", "entry", "summary"]);
|
|
40
|
+
const SEQUENCE_KEYS_BY_ARTIFACT = {
|
|
41
|
+
decisions: { DECISION: "decisions", ARCHIVE: "archive" },
|
|
42
|
+
docs: { MAPPING: "mapping", INDEX: "index", AUDIT_LOG: "audit_log" },
|
|
43
|
+
experiments: { EXPERIMENT: "experiments", ARCHIVE: "archive" },
|
|
44
|
+
health: { AUDIT: "audits", ARCHIVE: "archive" },
|
|
45
|
+
plan: { TASK: "tasks", UNKNOWN: "unknowns", REJECTED: "rejected" },
|
|
46
|
+
progress: { CYCLE: "cycles", ARCHIVE: "archive" },
|
|
47
|
+
session: { BOOKMARK: "bookmarks" },
|
|
48
|
+
vision: { PERSONA: "personas", PRINCIPLE: "principles" },
|
|
49
|
+
};
|
|
50
|
+
const NESTED_SEQUENCE_KEYS = [
|
|
51
|
+
[["DECISION", "ALTERNATIVE"], "alternatives"],
|
|
52
|
+
];
|
|
53
|
+
const SEQUENCE_ORDER_BY_ARTIFACT = { "progress\0cycles": "descending" };
|
|
54
|
+
export function collectSingletonGroups(schema) {
|
|
55
|
+
const result = [];
|
|
56
|
+
for (const [gk, gv] of Object.entries(schema)) {
|
|
57
|
+
if (SKIP_META.has(gk) || !isMapping(gv))
|
|
58
|
+
continue;
|
|
59
|
+
let isListOrSub = false;
|
|
60
|
+
for (const e of Object.values(gv)) {
|
|
61
|
+
if (isMapping(e) && (LIST_INDICATORS.has(String(e.field)) || e.parent)) {
|
|
62
|
+
isListOrSub = true;
|
|
63
|
+
break;
|
|
64
|
+
}
|
|
65
|
+
}
|
|
66
|
+
if (isListOrSub)
|
|
67
|
+
continue;
|
|
68
|
+
const fields = [];
|
|
69
|
+
for (const e of Object.values(gv)) {
|
|
70
|
+
if (isMapping(e) && e.required && "field" in e)
|
|
71
|
+
fields.push(String(e.field));
|
|
72
|
+
}
|
|
73
|
+
if (fields.length > 0)
|
|
74
|
+
result.push([gk, gk.toLowerCase(), fields]);
|
|
75
|
+
}
|
|
76
|
+
return result;
|
|
77
|
+
}
|
|
78
|
+
export function isEmptyRequired(value) {
|
|
79
|
+
if (value === null || value === undefined)
|
|
80
|
+
return true;
|
|
81
|
+
if (typeof value === "string")
|
|
82
|
+
return !value.trim();
|
|
83
|
+
if (Array.isArray(value))
|
|
84
|
+
return value.length === 0;
|
|
85
|
+
if (typeof value === "object")
|
|
86
|
+
return Object.keys(value).length === 0;
|
|
87
|
+
return false;
|
|
88
|
+
}
|
|
89
|
+
export function* iterGroupEntries(schema, group) {
|
|
90
|
+
const gv = schema[group];
|
|
91
|
+
if (!isMapping(gv))
|
|
92
|
+
return;
|
|
93
|
+
for (const entry of Object.values(gv)) {
|
|
94
|
+
if (isMapping(entry) && "field" in entry)
|
|
95
|
+
yield entry;
|
|
96
|
+
}
|
|
97
|
+
}
|
|
98
|
+
export function validateField(violations, name, scope, field, p) {
|
|
99
|
+
const fullPath = p ? `${p}.${field}` : field;
|
|
100
|
+
if (!(field in scope)) {
|
|
101
|
+
violations.push(`${name}: missing required field '${fullPath}'`);
|
|
102
|
+
}
|
|
103
|
+
else if (isEmptyRequired(scope[field])) {
|
|
104
|
+
violations.push(`${name}: empty required field '${fullPath}'`);
|
|
105
|
+
}
|
|
106
|
+
}
|
|
107
|
+
export function allowedValues(entry) {
|
|
108
|
+
// cast: schema `validation` rules parsed from a YAML artifact schema file
|
|
109
|
+
for (const rule of entry.validation ?? []) {
|
|
110
|
+
if (typeof rule === "string" && rule.startsWith("Must be one of: ")) {
|
|
111
|
+
return rule
|
|
112
|
+
.slice("Must be one of: ".length)
|
|
113
|
+
.split(",")
|
|
114
|
+
.map((v) => v.trim());
|
|
115
|
+
}
|
|
116
|
+
}
|
|
117
|
+
return [];
|
|
118
|
+
}
|
|
119
|
+
export function validateAllowedValue(violations, name, scope, entry, p) {
|
|
120
|
+
const field = String(entry.field);
|
|
121
|
+
const allowed = allowedValues(entry);
|
|
122
|
+
if (!field || allowed.length === 0 || !(field in scope) || isEmptyRequired(scope[field]))
|
|
123
|
+
return;
|
|
124
|
+
const value = scope[field];
|
|
125
|
+
if (typeof value === "string" && !allowed.includes(value)) {
|
|
126
|
+
violations.push(`${name}: invalid value '${value}' for '${p}.${field}' (expected one of: ${allowed.join(", ")})`);
|
|
127
|
+
}
|
|
128
|
+
}
|
|
129
|
+
export function validateFieldType(violations, name, scope, entry, p) {
|
|
130
|
+
const field = String(entry.field);
|
|
131
|
+
if (!field || !(field in scope))
|
|
132
|
+
return true;
|
|
133
|
+
const value = scope[field];
|
|
134
|
+
const expectedType = entry.type;
|
|
135
|
+
if (!expectedType || isEmptyRequired(value))
|
|
136
|
+
return true;
|
|
137
|
+
const fullPath = p ? `${p}.${field}` : field;
|
|
138
|
+
let isValid = true;
|
|
139
|
+
if (expectedType === "integer") {
|
|
140
|
+
if (typeof value === "boolean" || !(typeof value === "number" && Number.isInteger(value))) {
|
|
141
|
+
violations.push(`${name}: '${fullPath}' must be an integer, got ${pyTypeName(value)}`);
|
|
142
|
+
isValid = false;
|
|
143
|
+
}
|
|
144
|
+
}
|
|
145
|
+
else if (expectedType === "string") {
|
|
146
|
+
if (typeof value !== "string") {
|
|
147
|
+
violations.push(`${name}: '${fullPath}' must be a string, got ${pyTypeName(value)}`);
|
|
148
|
+
isValid = false;
|
|
149
|
+
}
|
|
150
|
+
}
|
|
151
|
+
else if (expectedType === "map") {
|
|
152
|
+
if (!isMapping(value)) {
|
|
153
|
+
violations.push(`${name}: '${fullPath}' must be a mapping, got ${pyTypeName(value)}`);
|
|
154
|
+
isValid = false;
|
|
155
|
+
}
|
|
156
|
+
}
|
|
157
|
+
else if (expectedType === "list[string]") {
|
|
158
|
+
if (!Array.isArray(value) || !value.every((x) => typeof x === "string")) {
|
|
159
|
+
violations.push(`${name}: '${fullPath}' must be a list of strings`);
|
|
160
|
+
isValid = false;
|
|
161
|
+
}
|
|
162
|
+
}
|
|
163
|
+
else if (expectedType === "list[integer|string]") {
|
|
164
|
+
if (!Array.isArray(value) || !value.every((x) => typeof x === "string" || (typeof x === "number" && Number.isInteger(x)))) {
|
|
165
|
+
violations.push(`${name}: '${fullPath}' must be a list of integers or strings`);
|
|
166
|
+
isValid = false;
|
|
167
|
+
}
|
|
168
|
+
}
|
|
169
|
+
else if (expectedType === "list[map]") {
|
|
170
|
+
if (!Array.isArray(value) || !value.every((x) => isMapping(x))) {
|
|
171
|
+
violations.push(`${name}: '${fullPath}' must be a list of mappings`);
|
|
172
|
+
isValid = false;
|
|
173
|
+
}
|
|
174
|
+
}
|
|
175
|
+
return isValid;
|
|
176
|
+
}
|
|
177
|
+
export function validateFieldConstraints(violations, name, scope, entry, p) {
|
|
178
|
+
const field = String(entry.field);
|
|
179
|
+
if (!field || !(field in scope))
|
|
180
|
+
return;
|
|
181
|
+
const value = scope[field];
|
|
182
|
+
// cast: schema `validation` rules parsed from a YAML artifact schema file
|
|
183
|
+
for (const rule of entry.validation ?? []) {
|
|
184
|
+
if (typeof rule !== "string")
|
|
185
|
+
continue;
|
|
186
|
+
if (rule === "Must be a positive integer") {
|
|
187
|
+
if (typeof value === "boolean" ||
|
|
188
|
+
!(typeof value === "number" && Number.isInteger(value)) ||
|
|
189
|
+
value <= 0) {
|
|
190
|
+
const fullPath = p ? `${p}.${field}` : field;
|
|
191
|
+
violations.push(`${name}: '${fullPath}' must be a positive integer`);
|
|
192
|
+
}
|
|
193
|
+
}
|
|
194
|
+
}
|
|
195
|
+
}
|
|
196
|
+
export function validateRequiredFields(violations, name, schema, group, scope, p) {
|
|
197
|
+
for (const entry of iterGroupEntries(schema, group)) {
|
|
198
|
+
const field = String(entry.field);
|
|
199
|
+
if (entry.parent || field === "entry")
|
|
200
|
+
continue;
|
|
201
|
+
if (entry.required)
|
|
202
|
+
validateField(violations, name, scope, field, p);
|
|
203
|
+
if (field in scope && !isEmptyRequired(scope[field])) {
|
|
204
|
+
if (validateFieldType(violations, name, scope, entry, p)) {
|
|
205
|
+
validateAllowedValue(violations, name, scope, entry, p);
|
|
206
|
+
validateFieldConstraints(violations, name, scope, entry, p);
|
|
207
|
+
}
|
|
208
|
+
}
|
|
209
|
+
const value = scope[field];
|
|
210
|
+
if (isMapping(value)) {
|
|
211
|
+
// cast: schema `children` list parsed from a YAML artifact schema file
|
|
212
|
+
for (const child of entry.children ?? []) {
|
|
213
|
+
if (isMapping(child) && child.field) {
|
|
214
|
+
const childField = String(child.field);
|
|
215
|
+
const childPath = p ? `${p}.${field}` : field;
|
|
216
|
+
if (child.required)
|
|
217
|
+
validateField(violations, name, value, childField, childPath);
|
|
218
|
+
if (childField in value && !isEmptyRequired(value[childField])) {
|
|
219
|
+
if (validateFieldType(violations, name, value, child, childPath)) {
|
|
220
|
+
validateAllowedValue(violations, name, value, child, childPath);
|
|
221
|
+
validateFieldConstraints(violations, name, value, child, childPath);
|
|
222
|
+
}
|
|
223
|
+
}
|
|
224
|
+
}
|
|
225
|
+
}
|
|
226
|
+
}
|
|
227
|
+
}
|
|
228
|
+
}
|
|
229
|
+
export function validateSingletonGroup(violations, name, schema, group, scope, p) {
|
|
230
|
+
for (const entry of iterGroupEntries(schema, group)) {
|
|
231
|
+
const field = String(entry.field);
|
|
232
|
+
if (entry.parent || field === "entry")
|
|
233
|
+
continue;
|
|
234
|
+
if (entry.required)
|
|
235
|
+
validateField(violations, name, scope, field, p);
|
|
236
|
+
if (field in scope && !isEmptyRequired(scope[field])) {
|
|
237
|
+
if (validateFieldType(violations, name, scope, entry, p)) {
|
|
238
|
+
validateAllowedValue(violations, name, scope, entry, p);
|
|
239
|
+
validateFieldConstraints(violations, name, scope, entry, p);
|
|
240
|
+
}
|
|
241
|
+
}
|
|
242
|
+
}
|
|
243
|
+
}
|
|
244
|
+
export function schemaFieldNames(schema, group) {
|
|
245
|
+
const out = new Set();
|
|
246
|
+
for (const entry of iterGroupEntries(schema, group)) {
|
|
247
|
+
if (entry.field && !entry.parent && entry.field !== "entry")
|
|
248
|
+
out.add(String(entry.field));
|
|
249
|
+
}
|
|
250
|
+
return out;
|
|
251
|
+
}
|
|
252
|
+
export function validateUnknownFields(violations, name, scope, allowed, p) {
|
|
253
|
+
for (const field of Object.keys(scope)) {
|
|
254
|
+
if (!allowed.has(field)) {
|
|
255
|
+
const fullPath = p ? `${p}.${field}` : field;
|
|
256
|
+
violations.push(`${name}: unsupported field '${fullPath}'`);
|
|
257
|
+
}
|
|
258
|
+
}
|
|
259
|
+
}
|
|
260
|
+
export function validatePlanKnownFields(data, schema, violations) {
|
|
261
|
+
const groupedScopes = { header: "HEADER", scope: "SCOPE" };
|
|
262
|
+
const sequenceKeys = new Set(Object.values(SEQUENCE_KEYS_BY_ARTIFACT.plan ?? {}));
|
|
263
|
+
const allowedTopLevel = new Set([
|
|
264
|
+
...schemaFieldNames(schema, "PLAN"),
|
|
265
|
+
...Object.keys(groupedScopes),
|
|
266
|
+
...sequenceKeys,
|
|
267
|
+
]);
|
|
268
|
+
validateUnknownFields(violations, "plan", data, allowedTopLevel, "");
|
|
269
|
+
for (const [key, group] of Object.entries(groupedScopes)) {
|
|
270
|
+
const scope = data[key];
|
|
271
|
+
if (isMapping(scope)) {
|
|
272
|
+
validateUnknownFields(violations, "plan", scope, schemaFieldNames(schema, group), key);
|
|
273
|
+
}
|
|
274
|
+
}
|
|
275
|
+
}
|
|
276
|
+
export function validateFullPlanContract(data, violations) {
|
|
277
|
+
const header = isMapping(data.header) ? data.header : {};
|
|
278
|
+
if (String(header.level ?? "").toLowerCase() !== "full")
|
|
279
|
+
return;
|
|
280
|
+
for (const field of ["reviewed", "critic_issues"]) {
|
|
281
|
+
validateField(violations, "plan", header, field, "header");
|
|
282
|
+
}
|
|
283
|
+
validateField(violations, "plan", data, "design", "");
|
|
284
|
+
const unknowns = data.unknowns;
|
|
285
|
+
if (!Array.isArray(unknowns) || unknowns.length === 0) {
|
|
286
|
+
violations.push("plan: full plans require at least one 'unknowns' entry");
|
|
287
|
+
}
|
|
288
|
+
const criticIssues = header.critic_issues;
|
|
289
|
+
if (!isEmptyRequired(criticIssues)) {
|
|
290
|
+
const match = /^\s*(\d+)\s+found,\s*(\d+)\s+addressed,\s*(\d+)\s+dismissed\s*$/.exec(String(criticIssues));
|
|
291
|
+
if (!match) {
|
|
292
|
+
violations.push("plan: header.critic_issues must match 'N found, M addressed, K dismissed'");
|
|
293
|
+
}
|
|
294
|
+
else {
|
|
295
|
+
const [found, addressed, dismissed] = [match[1], match[2], match[3]].map((v) => parseInt(v, 10));
|
|
296
|
+
if (found < 1)
|
|
297
|
+
violations.push("plan: header.critic_issues must record at least 1 found issue");
|
|
298
|
+
if (addressed + dismissed !== found) {
|
|
299
|
+
violations.push("plan: header.critic_issues counts must satisfy addressed + dismissed == found");
|
|
300
|
+
}
|
|
301
|
+
}
|
|
302
|
+
}
|
|
303
|
+
const tasks = data.tasks;
|
|
304
|
+
if (!Array.isArray(tasks))
|
|
305
|
+
return;
|
|
306
|
+
tasks.forEach((task, index) => {
|
|
307
|
+
if (isMapping(task))
|
|
308
|
+
validateField(violations, "plan", task, "acceptance", `tasks[${index}]`);
|
|
309
|
+
});
|
|
310
|
+
}
|
|
311
|
+
export function entryMinCount(schema, group) {
|
|
312
|
+
for (const entry of iterGroupEntries(schema, group)) {
|
|
313
|
+
if (entry.field === "entry" && entry.required)
|
|
314
|
+
return entry.min_count || 1;
|
|
315
|
+
}
|
|
316
|
+
return null;
|
|
317
|
+
}
|
|
318
|
+
export function parentRequirements(schema, parentGroup) {
|
|
319
|
+
const requirements = {};
|
|
320
|
+
const prefix = `${parentGroup}.`;
|
|
321
|
+
for (const group of Object.keys(schema)) {
|
|
322
|
+
if (SKIP_META.has(group))
|
|
323
|
+
continue;
|
|
324
|
+
for (const entry of iterGroupEntries(schema, group)) {
|
|
325
|
+
const parent = entry.parent;
|
|
326
|
+
if (typeof parent === "string" &&
|
|
327
|
+
parent.startsWith(prefix) &&
|
|
328
|
+
parent !== `${group}.entry` &&
|
|
329
|
+
entry.required &&
|
|
330
|
+
entry.field) {
|
|
331
|
+
const parentField = parent.slice(prefix.length);
|
|
332
|
+
const fields = requirements[parentField] ?? [];
|
|
333
|
+
fields.push(String(entry.field));
|
|
334
|
+
requirements[parentField] = fields;
|
|
335
|
+
}
|
|
336
|
+
}
|
|
337
|
+
}
|
|
338
|
+
return requirements;
|
|
339
|
+
}
|
|
340
|
+
export function entryRequirements(schema, group) {
|
|
341
|
+
const parent = `${group}.entry`;
|
|
342
|
+
const out = [];
|
|
343
|
+
for (const entry of iterGroupEntries(schema, group)) {
|
|
344
|
+
if (entry.parent === parent && entry.required && entry.field)
|
|
345
|
+
out.push(String(entry.field));
|
|
346
|
+
}
|
|
347
|
+
return out;
|
|
348
|
+
}
|
|
349
|
+
export function validateSequences(data, schema, name, violations) {
|
|
350
|
+
for (const [group, key] of Object.entries(SEQUENCE_KEYS_BY_ARTIFACT[name] ?? {})) {
|
|
351
|
+
const seq = data[key];
|
|
352
|
+
if (seq === null || seq === undefined)
|
|
353
|
+
continue;
|
|
354
|
+
if (!Array.isArray(seq)) {
|
|
355
|
+
violations.push(`${name}: '${key}' must be a list`);
|
|
356
|
+
continue;
|
|
357
|
+
}
|
|
358
|
+
if (seq.length === 0) {
|
|
359
|
+
violations.push(`${name}: '${key}' requires at least 1 entry`);
|
|
360
|
+
continue;
|
|
361
|
+
}
|
|
362
|
+
const childRequirements = parentRequirements(schema, group);
|
|
363
|
+
seq.forEach((item, index) => {
|
|
364
|
+
const p = `${key}[${index}]`;
|
|
365
|
+
if (name === "health" && group === "ARCHIVE" && typeof item === "string")
|
|
366
|
+
return;
|
|
367
|
+
if (!isMapping(item)) {
|
|
368
|
+
violations.push(`${name}: '${p}' must be a mapping`);
|
|
369
|
+
return;
|
|
370
|
+
}
|
|
371
|
+
validateRequiredFields(violations, name, schema, group, item, p);
|
|
372
|
+
for (const [parentField, childFields] of Object.entries(childRequirements)) {
|
|
373
|
+
const childScope = item[parentField];
|
|
374
|
+
if (!isMapping(childScope))
|
|
375
|
+
continue;
|
|
376
|
+
for (const childField of childFields) {
|
|
377
|
+
validateField(violations, name, childScope, childField, `${p}.${parentField}`);
|
|
378
|
+
}
|
|
379
|
+
}
|
|
380
|
+
for (const [[parentGroup, childGroup], childKey] of NESTED_SEQUENCE_KEYS) {
|
|
381
|
+
if (parentGroup !== group)
|
|
382
|
+
continue;
|
|
383
|
+
const childSeq = item[childKey];
|
|
384
|
+
const minCount = entryMinCount(schema, childGroup);
|
|
385
|
+
if (minCount && (!Array.isArray(childSeq) || childSeq.length < minCount)) {
|
|
386
|
+
violations.push(`${name}: '${p}.${childKey}' requires at least ${minCount} entry`);
|
|
387
|
+
continue;
|
|
388
|
+
}
|
|
389
|
+
if (!Array.isArray(childSeq))
|
|
390
|
+
continue;
|
|
391
|
+
const required = entryRequirements(schema, childGroup);
|
|
392
|
+
childSeq.forEach((child, childIndex) => {
|
|
393
|
+
const childPath = `${p}.${childKey}[${childIndex}]`;
|
|
394
|
+
if (!isMapping(child)) {
|
|
395
|
+
violations.push(`${name}: '${childPath}' must be a mapping`);
|
|
396
|
+
return;
|
|
397
|
+
}
|
|
398
|
+
for (const field of required)
|
|
399
|
+
validateField(violations, name, child, field, childPath);
|
|
400
|
+
});
|
|
401
|
+
}
|
|
402
|
+
});
|
|
403
|
+
}
|
|
404
|
+
}
|
|
405
|
+
export function validatePlanDependencies(data, violations) {
|
|
406
|
+
if (!Array.isArray(data.tasks))
|
|
407
|
+
return;
|
|
408
|
+
const tasks = data.tasks.filter((task) => isMapping(task));
|
|
409
|
+
const byRef = new Map();
|
|
410
|
+
tasks.forEach((task, index) => {
|
|
411
|
+
if (task.number !== null && task.number !== undefined)
|
|
412
|
+
byRef.set(String(task.number), index);
|
|
413
|
+
const name = String(task.name ?? "").trim();
|
|
414
|
+
if (name && !byRef.has(name))
|
|
415
|
+
byRef.set(name, index);
|
|
416
|
+
});
|
|
417
|
+
const edges = tasks.map(() => []);
|
|
418
|
+
tasks.forEach((task, index) => {
|
|
419
|
+
if (!Array.isArray(task.depends_on))
|
|
420
|
+
return;
|
|
421
|
+
for (const dependency of task.depends_on) {
|
|
422
|
+
const dependencyRef = String(dependency);
|
|
423
|
+
const target = byRef.get(dependencyRef);
|
|
424
|
+
if (target === undefined) {
|
|
425
|
+
violations.push(`plan: 'tasks[${index}].depends_on' references unknown task '${dependencyRef}' (PV4)`);
|
|
426
|
+
}
|
|
427
|
+
else {
|
|
428
|
+
edges[index].push(target);
|
|
429
|
+
}
|
|
430
|
+
}
|
|
431
|
+
});
|
|
432
|
+
const state = tasks.map(() => 0);
|
|
433
|
+
const stack = [];
|
|
434
|
+
const visit = (index) => {
|
|
435
|
+
state[index] = 1;
|
|
436
|
+
stack.push(index);
|
|
437
|
+
for (const target of edges[index]) {
|
|
438
|
+
if (state[target] === 0 && visit(target))
|
|
439
|
+
return true;
|
|
440
|
+
if (state[target] === 1) {
|
|
441
|
+
const cycleStart = stack.indexOf(target);
|
|
442
|
+
const cycle = [...stack.slice(cycleStart), target]
|
|
443
|
+
.map((taskIndex) => String(tasks[taskIndex]?.number ?? taskIndex + 1))
|
|
444
|
+
.join(" -> ");
|
|
445
|
+
violations.push(`plan: circular dependency chain ${cycle} (PV4)`);
|
|
446
|
+
return true;
|
|
447
|
+
}
|
|
448
|
+
}
|
|
449
|
+
stack.pop();
|
|
450
|
+
state[index] = 2;
|
|
451
|
+
return false;
|
|
452
|
+
};
|
|
453
|
+
for (let index = 0; index < tasks.length; index += 1) {
|
|
454
|
+
if (state[index] === 0 && visit(index))
|
|
455
|
+
break;
|
|
456
|
+
}
|
|
457
|
+
}
|
|
458
|
+
export function validateDecisionAlternatives(data, name) {
|
|
459
|
+
const violations = [];
|
|
460
|
+
// cast: `decisions` read from a parsed YAML artifact mapping
|
|
461
|
+
(data.decisions ?? []).forEach((decision, index) => {
|
|
462
|
+
if (!isMapping(decision))
|
|
463
|
+
return;
|
|
464
|
+
const alternatives = decision.alternatives ?? [];
|
|
465
|
+
if (!Array.isArray(alternatives))
|
|
466
|
+
return;
|
|
467
|
+
const chosen = alternatives.filter((alt) => isMapping(alt) && alt.status === "chosen");
|
|
468
|
+
if (chosen.length !== 1) {
|
|
469
|
+
violations.push(`${name}: 'decisions[${index}].alternatives' must have exactly one chosen entry`);
|
|
470
|
+
}
|
|
471
|
+
});
|
|
472
|
+
return violations;
|
|
473
|
+
}
|
|
474
|
+
export function validateDecisionSatisfaction(data, name) {
|
|
475
|
+
const violations = [];
|
|
476
|
+
const allowedStates = new Set(["open", "provisionally_satisfied", "user_confirmed_satisfied"]);
|
|
477
|
+
const entries = [
|
|
478
|
+
...(data.decisions ?? []).map((d, i) => [
|
|
479
|
+
`decisions[${i}]`,
|
|
480
|
+
d,
|
|
481
|
+
]),
|
|
482
|
+
...(data.archive ?? []).map((d, i) => [
|
|
483
|
+
`archive[${i}]`,
|
|
484
|
+
d,
|
|
485
|
+
]),
|
|
486
|
+
];
|
|
487
|
+
for (const [entryPath, decision] of entries) {
|
|
488
|
+
if (!isMapping(decision) || !("satisfaction" in decision))
|
|
489
|
+
continue;
|
|
490
|
+
const p = `${entryPath}.satisfaction`;
|
|
491
|
+
const satisfaction = decision.satisfaction;
|
|
492
|
+
if (!isMapping(satisfaction)) {
|
|
493
|
+
violations.push(`${name}: '${p}' must be a mapping`);
|
|
494
|
+
continue;
|
|
495
|
+
}
|
|
496
|
+
validateUnknownFields(violations, name, satisfaction, new Set(["state", "evidence", "user_confirmation"]), p);
|
|
497
|
+
const state = satisfaction.state;
|
|
498
|
+
if (typeof state !== "string" || !state.trim()) {
|
|
499
|
+
violations.push(`${name}: missing required field '${p}.state'`);
|
|
500
|
+
continue;
|
|
501
|
+
}
|
|
502
|
+
if (!allowedStates.has(state)) {
|
|
503
|
+
violations.push(`${name}: invalid value '${state}' for '${p}.state' (expected one of: open, provisionally_satisfied, user_confirmed_satisfied)`);
|
|
504
|
+
continue;
|
|
505
|
+
}
|
|
506
|
+
if (state === "provisionally_satisfied" && isEmptyRequired(satisfaction.evidence)) {
|
|
507
|
+
violations.push(`${name}: '${p}.evidence' is required for provisionally_satisfied`);
|
|
508
|
+
}
|
|
509
|
+
if (state === "user_confirmed_satisfied") {
|
|
510
|
+
const confirmation = satisfaction.user_confirmation;
|
|
511
|
+
if (confirmation === null || confirmation === undefined) {
|
|
512
|
+
violations.push(`${name}: '${p}.user_confirmation' is required for user_confirmed_satisfied`);
|
|
513
|
+
continue;
|
|
514
|
+
}
|
|
515
|
+
if (!isMapping(confirmation)) {
|
|
516
|
+
violations.push(`${name}: '${p}.user_confirmation' must be a mapping with confirmed_by and confirmed_at, got ${pyTypeName(confirmation)}`);
|
|
517
|
+
continue;
|
|
518
|
+
}
|
|
519
|
+
for (const field of ["confirmed_by", "confirmed_at"]) {
|
|
520
|
+
if (isEmptyRequired(confirmation[field])) {
|
|
521
|
+
violations.push(`${name}: missing required field '${p}.user_confirmation.${field}'`);
|
|
522
|
+
}
|
|
523
|
+
}
|
|
524
|
+
}
|
|
525
|
+
}
|
|
526
|
+
return violations;
|
|
527
|
+
}
|
|
528
|
+
export function validationRuleSeverity(schema, rule) {
|
|
529
|
+
for (const groupKey of ["VALIDATION", "VALIDATION_RULES"]) {
|
|
530
|
+
for (const entry of Object.values(schema[groupKey] ?? {})) {
|
|
531
|
+
if (isMapping(entry) && entry.rule === rule) {
|
|
532
|
+
const severity = entry.severity;
|
|
533
|
+
return severity ? String(severity) : null;
|
|
534
|
+
}
|
|
535
|
+
}
|
|
536
|
+
}
|
|
537
|
+
return null;
|
|
538
|
+
}
|
|
539
|
+
export function expectedSequenceOrder(name, key) {
|
|
540
|
+
return SEQUENCE_ORDER_BY_ARTIFACT[`${name}\0${key}`] ?? "ascending";
|
|
541
|
+
}
|
|
542
|
+
export function sequenceInOrder(nums, direction) {
|
|
543
|
+
const reverse = direction === "descending";
|
|
544
|
+
const sorted = [...nums].sort((a, b) => (reverse ? b - a : a - b));
|
|
545
|
+
return nums.length === sorted.length && nums.every((n, i) => n === sorted[i]);
|
|
546
|
+
}
|
|
@@ -0,0 +1,107 @@
|
|
|
1
|
+
/**
|
|
2
|
+
* Path resolution and artifact identification.
|
|
3
|
+
*
|
|
4
|
+
* Given an arbitrary `cwd` and a candidate write path, decide which
|
|
5
|
+
* (if any) protocol-tracked artifact the write targets, applying
|
|
6
|
+
* `.agentera/docs.yaml` path overrides when present.
|
|
7
|
+
*/
|
|
8
|
+
import fs from "node:fs";
|
|
9
|
+
import path from "node:path";
|
|
10
|
+
import { resolvePath } from "../../core/paths.js";
|
|
11
|
+
import { loadYamlMapping } from "../../core/yaml.js";
|
|
12
|
+
import { ARTIFACT_PROTOCOL_PATHS, HUMAN_FACING_ARTIFACT_IDS, normalizeArtifactProtocolId, } from "../../registries/artifactProtocolIds.js";
|
|
13
|
+
import { DEFAULT_ARTIFACT_PATHS } from "../common.js";
|
|
14
|
+
import { COMPACTABLE_YAML_ARTIFACTS, compactFile, compactYamlFile } from "../compaction/index.js";
|
|
15
|
+
import { withStateMutation } from "../../state/write/mutation.js";
|
|
16
|
+
import { isMapping } from "./schema.js";
|
|
17
|
+
const AGENT_YAML_RE = /\.agentera\/([a-z_]+)\.yaml$/;
|
|
18
|
+
function resolvePathRel(fp, cwd) {
|
|
19
|
+
return path.isAbsolute(fp) ? fp : path.join(cwd, fp);
|
|
20
|
+
}
|
|
21
|
+
function docsPathOverrides(cwd) {
|
|
22
|
+
const docsPath = path.join(cwd, ARTIFACT_PROTOCOL_PATHS.docs);
|
|
23
|
+
if (!fs.existsSync(docsPath) || !fs.statSync(docsPath).isFile())
|
|
24
|
+
return {};
|
|
25
|
+
let data;
|
|
26
|
+
try {
|
|
27
|
+
// cast: docs.yaml path-override mapping parsed from a YAML file
|
|
28
|
+
data = loadYamlMapping(fs.readFileSync(docsPath, "utf8"));
|
|
29
|
+
}
|
|
30
|
+
catch (exc) {
|
|
31
|
+
process.stderr.write(`warning: failed to load docs path overrides: ${exc.message}\n`);
|
|
32
|
+
return {};
|
|
33
|
+
}
|
|
34
|
+
const mapping = data.mapping;
|
|
35
|
+
if (!Array.isArray(mapping))
|
|
36
|
+
return {};
|
|
37
|
+
const overrides = {};
|
|
38
|
+
for (const entry of mapping) {
|
|
39
|
+
if (!isMapping(entry))
|
|
40
|
+
continue;
|
|
41
|
+
const artifact = entry.artifact;
|
|
42
|
+
const p = entry.path;
|
|
43
|
+
if (typeof artifact === "string" && typeof p === "string")
|
|
44
|
+
overrides[artifact] = p;
|
|
45
|
+
}
|
|
46
|
+
return overrides;
|
|
47
|
+
}
|
|
48
|
+
export function defaultArtifactPath(artifact, cwd) {
|
|
49
|
+
const rel = docsPathOverrides(cwd)[artifact] ?? DEFAULT_ARTIFACT_PATHS[artifact] ?? "";
|
|
50
|
+
return rel ? resolvePathRel(rel, cwd) : "";
|
|
51
|
+
}
|
|
52
|
+
export function artifactPaths(cwd) {
|
|
53
|
+
const paths = { ...DEFAULT_ARTIFACT_PATHS, ...docsPathOverrides(cwd) };
|
|
54
|
+
const resolved = {};
|
|
55
|
+
for (const [artifact, p] of Object.entries(paths))
|
|
56
|
+
resolved[artifact] = resolvePathRel(p, cwd);
|
|
57
|
+
return resolved;
|
|
58
|
+
}
|
|
59
|
+
function samePath(left, right) {
|
|
60
|
+
return resolvePath(left) === resolvePath(right);
|
|
61
|
+
}
|
|
62
|
+
export function artifactForWrite(absPath, relPath, basename, cwd) {
|
|
63
|
+
for (const [artifact, mappedPath] of Object.entries(artifactPaths(cwd))) {
|
|
64
|
+
if (samePath(absPath, mappedPath))
|
|
65
|
+
return artifact;
|
|
66
|
+
}
|
|
67
|
+
const match = AGENT_YAML_RE.exec(relPath);
|
|
68
|
+
if (match) {
|
|
69
|
+
const id = match[1];
|
|
70
|
+
return id in ARTIFACT_PROTOCOL_PATHS ? id : null;
|
|
71
|
+
}
|
|
72
|
+
if (HUMAN_FACING_ARTIFACT_IDS.has(normalizeArtifactProtocolId(basename) ?? "")) {
|
|
73
|
+
return normalizeArtifactProtocolId(basename);
|
|
74
|
+
}
|
|
75
|
+
return null;
|
|
76
|
+
}
|
|
77
|
+
function readIfNeeded(content, absPath) {
|
|
78
|
+
if (content !== null && content !== undefined)
|
|
79
|
+
return content;
|
|
80
|
+
try {
|
|
81
|
+
return fs.readFileSync(absPath, "utf8");
|
|
82
|
+
}
|
|
83
|
+
catch {
|
|
84
|
+
return null;
|
|
85
|
+
}
|
|
86
|
+
}
|
|
87
|
+
function compactAfterValidWrite(artifact, absPath, projectRoot) {
|
|
88
|
+
if (!fs.existsSync(absPath))
|
|
89
|
+
return [];
|
|
90
|
+
try {
|
|
91
|
+
if (artifact !== "todo" && !(artifact in COMPACTABLE_YAML_ARTIFACTS))
|
|
92
|
+
return [];
|
|
93
|
+
withStateMutation(projectRoot, (transaction) => {
|
|
94
|
+
if (artifact === "todo") {
|
|
95
|
+
transaction.mutateProjection(absPath, (stage) => compactFile(stage, "todo-resolved"));
|
|
96
|
+
}
|
|
97
|
+
else {
|
|
98
|
+
transaction.mutateProjection(absPath, (stage) => compactYamlFile(stage, artifact, projectRoot));
|
|
99
|
+
}
|
|
100
|
+
});
|
|
101
|
+
}
|
|
102
|
+
catch (exc) {
|
|
103
|
+
return [`${artifact}: compaction failed: ${exc.message}`];
|
|
104
|
+
}
|
|
105
|
+
return [];
|
|
106
|
+
}
|
|
107
|
+
export { readIfNeeded, compactAfterValidWrite };
|