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,360 @@
|
|
|
1
|
+
/**
|
|
2
|
+
* Compaction status reporting and projection repair.
|
|
3
|
+
*
|
|
4
|
+
* Walks each tracked artifact path, counts active/archive entries, and
|
|
5
|
+
* builds a `CompactionStatus` per artifact plus a per-status operation
|
|
6
|
+
* row in `checkCompaction`/`fixCompaction`. The `fixCompaction` path
|
|
7
|
+
* delegates the actual write to `apply.ts`.
|
|
8
|
+
*/
|
|
9
|
+
import fs from "node:fs";
|
|
10
|
+
import path from "node:path";
|
|
11
|
+
import { DEFAULT_ARTIFACT_PATHS, parseDocsYamlMapping } from "../common.js";
|
|
12
|
+
import { loadYamlMapping } from "../../core/yaml.js";
|
|
13
|
+
import { COMPACTABLE_YAML_ARTIFACTS, NON_COMPACTABLE_ARTIFACTS } from "./dryRun.js";
|
|
14
|
+
import { detectStateMode } from "../../state/stateMode.js";
|
|
15
|
+
import { discoverEntities } from "../../state/entityStorage.js";
|
|
16
|
+
import { decisionProtectedOverflowCount, decisionSatisfiedActiveCount, overLimitCount, yamlArchiveEntries, } from "./retention.js";
|
|
17
|
+
import { compactFile, compactYamlBytes, compactYamlFile } from "./apply.js";
|
|
18
|
+
import { countTodoResolvedEntries, countTodoResolvedSectionHeadings, countTodoPendingSummarization, TODO_DROPPED_RECOVERY_GUIDANCE, } from "./parse.js";
|
|
19
|
+
import { YAML_SPEC_BY_ARTIFACT } from "./dryRun.js";
|
|
20
|
+
import { InjectedMutationFailure, withStateMutation, } from "../../state/write/mutation.js";
|
|
21
|
+
import { hydrateDecisionRecords } from "../../state/decisionOverlay.js";
|
|
22
|
+
import { loadProjectionPolicy } from "../../state/projectionPolicy.js";
|
|
23
|
+
import { ARTIFACT_PROTOCOL_PATHS } from "../../registries/artifactProtocolIds.js";
|
|
24
|
+
function artifactPaths(projectRoot) {
|
|
25
|
+
const paths = { ...DEFAULT_ARTIFACT_PATHS };
|
|
26
|
+
const docsPath = path.join(projectRoot, ARTIFACT_PROTOCOL_PATHS.docs);
|
|
27
|
+
if (fs.existsSync(docsPath)) {
|
|
28
|
+
Object.assign(paths, parseDocsYamlMapping(fs.readFileSync(docsPath, "utf8")));
|
|
29
|
+
}
|
|
30
|
+
const resolved = {};
|
|
31
|
+
for (const [artifact, rel] of Object.entries(paths)) {
|
|
32
|
+
resolved[artifact] = path.join(projectRoot, rel);
|
|
33
|
+
}
|
|
34
|
+
return resolved;
|
|
35
|
+
}
|
|
36
|
+
function missingStatus(artifact, p, classification) {
|
|
37
|
+
return {
|
|
38
|
+
artifact,
|
|
39
|
+
path: p,
|
|
40
|
+
classification,
|
|
41
|
+
active_count: 0,
|
|
42
|
+
archive_count: 0,
|
|
43
|
+
total_count: 0,
|
|
44
|
+
over_limit_count: 0,
|
|
45
|
+
reason: "artifact path is not present",
|
|
46
|
+
protected_overflow_count: 0,
|
|
47
|
+
exists: false,
|
|
48
|
+
};
|
|
49
|
+
}
|
|
50
|
+
function yamlErrorStatus(artifact, p, message) {
|
|
51
|
+
return {
|
|
52
|
+
artifact,
|
|
53
|
+
path: p,
|
|
54
|
+
classification: "error",
|
|
55
|
+
active_count: null,
|
|
56
|
+
archive_count: null,
|
|
57
|
+
total_count: null,
|
|
58
|
+
over_limit_count: null,
|
|
59
|
+
reason: message.trim() || "invalid YAML mapping root",
|
|
60
|
+
protected_overflow_count: 0,
|
|
61
|
+
exists: true,
|
|
62
|
+
};
|
|
63
|
+
}
|
|
64
|
+
function yamlCounts(p, activeKey, archiveKey) {
|
|
65
|
+
const data = loadYamlMapping(fs.readFileSync(p, "utf8"));
|
|
66
|
+
if (!data || typeof data !== "object" || Array.isArray(data))
|
|
67
|
+
return [0, 0];
|
|
68
|
+
const active = data[activeKey] || [];
|
|
69
|
+
const archive = data[archiveKey] || [];
|
|
70
|
+
return [Array.isArray(active) ? active.length : 0, Array.isArray(archive) ? archive.length : 0];
|
|
71
|
+
}
|
|
72
|
+
function yamlLists(p, activeKey, archiveKey) {
|
|
73
|
+
const data = loadYamlMapping(fs.readFileSync(p, "utf8"));
|
|
74
|
+
if (!data || typeof data !== "object" || Array.isArray(data))
|
|
75
|
+
return [[], []];
|
|
76
|
+
const active = data[activeKey] || [];
|
|
77
|
+
const archive = data[archiveKey] || [];
|
|
78
|
+
return [Array.isArray(active) ? active : [], Array.isArray(archive) ? archive : []];
|
|
79
|
+
}
|
|
80
|
+
function countStatus(artifact, p, activeCount, archiveCount, protectedOverflowCount = 0, budgetActiveCount, projectionRecovery, projectionState) {
|
|
81
|
+
const totalCount = activeCount + archiveCount;
|
|
82
|
+
const budgetActive = budgetActiveCount ?? activeCount;
|
|
83
|
+
return {
|
|
84
|
+
artifact,
|
|
85
|
+
path: p,
|
|
86
|
+
classification: "compactable",
|
|
87
|
+
active_count: activeCount,
|
|
88
|
+
archive_count: archiveCount,
|
|
89
|
+
total_count: totalCount,
|
|
90
|
+
over_limit_count: projectionState ? 0 : overLimitCount(budgetActive, archiveCount),
|
|
91
|
+
reason: projectionState
|
|
92
|
+
? projectionState === "over_defaults"
|
|
93
|
+
? "lossless projection exceeds display defaults; numbered archives remain authoritative"
|
|
94
|
+
: "lossless projection is within display defaults"
|
|
95
|
+
: protectedOverflowCount
|
|
96
|
+
? "protected-overflow review pressure"
|
|
97
|
+
: "uniform_10_40_50",
|
|
98
|
+
protected_overflow_count: protectedOverflowCount,
|
|
99
|
+
exists: true,
|
|
100
|
+
...(projectionState ? { projection_state: projectionState } : {}),
|
|
101
|
+
...(projectionRecovery ? { projection_recovery: projectionRecovery } : {}),
|
|
102
|
+
};
|
|
103
|
+
}
|
|
104
|
+
function projectionRecoveryFor(projectRoot, artifact, p) {
|
|
105
|
+
try {
|
|
106
|
+
return compactYamlBytes(fs.readFileSync(p, "utf8"), artifact, projectRoot).result.recovery;
|
|
107
|
+
}
|
|
108
|
+
catch {
|
|
109
|
+
return undefined;
|
|
110
|
+
}
|
|
111
|
+
}
|
|
112
|
+
export function computeCompactionStatus(projectRoot) {
|
|
113
|
+
if (detectStateMode(projectRoot) === "entities") {
|
|
114
|
+
const discovered = discoverEntities(projectRoot);
|
|
115
|
+
const issueCount = discovered.issues.length;
|
|
116
|
+
return [{
|
|
117
|
+
artifact: "entity_state",
|
|
118
|
+
path: path.join(projectRoot, ".agentera", "entities"),
|
|
119
|
+
classification: issueCount ? "error" : "canonical_entities",
|
|
120
|
+
active_count: discovered.entities.length,
|
|
121
|
+
archive_count: 0,
|
|
122
|
+
total_count: discovered.entities.length,
|
|
123
|
+
over_limit_count: 0,
|
|
124
|
+
reason: issueCount
|
|
125
|
+
? `${issueCount} canonical entity validation issue(s); run agentera check validate state --format json`
|
|
126
|
+
: "canonical entity state is independently stored and is not compacted",
|
|
127
|
+
protected_overflow_count: 0,
|
|
128
|
+
exists: true,
|
|
129
|
+
}];
|
|
130
|
+
}
|
|
131
|
+
const paths = artifactPaths(projectRoot);
|
|
132
|
+
const projectionPolicy = loadProjectionPolicy();
|
|
133
|
+
const statuses = [];
|
|
134
|
+
const todoPath = paths.todo;
|
|
135
|
+
if (fs.existsSync(todoPath)) {
|
|
136
|
+
const todoText = fs.readFileSync(todoPath, "utf8");
|
|
137
|
+
const headingCount = countTodoResolvedSectionHeadings(todoText);
|
|
138
|
+
if (headingCount > 1) {
|
|
139
|
+
// Refuse rather than silently process only the first `## ✓ Resolved`
|
|
140
|
+
// section: duplicates hide the trailing entries from the budget and
|
|
141
|
+
// from fix-mode migration. TODO has no lossless numbered archive, so
|
|
142
|
+
// recovery once entries are dropped is Git-only.
|
|
143
|
+
statuses.push({
|
|
144
|
+
artifact: "todo#Resolved",
|
|
145
|
+
path: todoPath,
|
|
146
|
+
classification: "error",
|
|
147
|
+
active_count: null,
|
|
148
|
+
archive_count: null,
|
|
149
|
+
total_count: null,
|
|
150
|
+
over_limit_count: null,
|
|
151
|
+
reason: `TODO.md has ${headingCount} '## ✓ Resolved' sections; merge into exactly one before compacting. ` +
|
|
152
|
+
`Compaction drops oldest resolved entries and is destructive (no lossless archive); ` +
|
|
153
|
+
TODO_DROPPED_RECOVERY_GUIDANCE,
|
|
154
|
+
protected_overflow_count: 0,
|
|
155
|
+
exists: true,
|
|
156
|
+
});
|
|
157
|
+
}
|
|
158
|
+
else if (headingCount === 0) {
|
|
159
|
+
statuses.push({
|
|
160
|
+
artifact: "todo#Resolved",
|
|
161
|
+
path: todoPath,
|
|
162
|
+
classification: "error",
|
|
163
|
+
active_count: null,
|
|
164
|
+
archive_count: null,
|
|
165
|
+
total_count: null,
|
|
166
|
+
over_limit_count: null,
|
|
167
|
+
reason: "TODO.md has no required '## ✓ Resolved' section; add exactly one before compacting.",
|
|
168
|
+
protected_overflow_count: 0,
|
|
169
|
+
exists: true,
|
|
170
|
+
});
|
|
171
|
+
}
|
|
172
|
+
else {
|
|
173
|
+
const counts = countTodoResolvedEntries(todoText);
|
|
174
|
+
const status = countStatus("todo#Resolved", todoPath, counts.full, counts.oneline);
|
|
175
|
+
// Detect in-budget (≤50) TODOs that still need a formatting rewrite:
|
|
176
|
+
// rows 11-50 that are long verbatim headers instead of ≤15-word
|
|
177
|
+
// summaries. This triggers `--mode fix` before entries overflow.
|
|
178
|
+
const pendingSummarization = countTodoPendingSummarization(todoText);
|
|
179
|
+
if (pendingSummarization > 0) {
|
|
180
|
+
status.pending_summarization_count = pendingSummarization;
|
|
181
|
+
}
|
|
182
|
+
statuses.push(status);
|
|
183
|
+
}
|
|
184
|
+
}
|
|
185
|
+
else {
|
|
186
|
+
statuses.push(missingStatus("todo#Resolved", todoPath, "compactable"));
|
|
187
|
+
}
|
|
188
|
+
for (const [artifact, [activeKey, archiveKey]] of Object.entries(COMPACTABLE_YAML_ARTIFACTS)) {
|
|
189
|
+
const p = paths[artifact];
|
|
190
|
+
if (fs.existsSync(p)) {
|
|
191
|
+
let active;
|
|
192
|
+
let archive;
|
|
193
|
+
try {
|
|
194
|
+
[active, archive] = yamlLists(p, activeKey, archiveKey);
|
|
195
|
+
}
|
|
196
|
+
catch (exc) {
|
|
197
|
+
statuses.push(yamlErrorStatus(artifact, p, exc.message));
|
|
198
|
+
continue;
|
|
199
|
+
}
|
|
200
|
+
const protectedOverflowCount = artifact === "decisions"
|
|
201
|
+
? decisionProtectedOverflowCount(hydrateDecisionRecords(active, projectRoot), hydrateDecisionRecords(archive, projectRoot))
|
|
202
|
+
: 0;
|
|
203
|
+
const budgetActiveCount = artifact === "decisions"
|
|
204
|
+
? decisionSatisfiedActiveCount(hydrateDecisionRecords(active, projectRoot))
|
|
205
|
+
: undefined;
|
|
206
|
+
statuses.push(countStatus(artifact, p, active.length, archive.length, protectedOverflowCount, budgetActiveCount, projectionRecoveryFor(projectRoot, artifact, p), active.length > projectionPolicy.activeEntries ||
|
|
207
|
+
archive.length > projectionPolicy.summaryEntries ||
|
|
208
|
+
active.length + archive.length > projectionPolicy.totalEntries
|
|
209
|
+
? "over_defaults"
|
|
210
|
+
: "within_defaults"));
|
|
211
|
+
}
|
|
212
|
+
else {
|
|
213
|
+
statuses.push(missingStatus(artifact, p, "compactable"));
|
|
214
|
+
}
|
|
215
|
+
}
|
|
216
|
+
for (const [artifact, [classification, reason]] of Object.entries(NON_COMPACTABLE_ARTIFACTS)) {
|
|
217
|
+
const p = paths[artifact];
|
|
218
|
+
statuses.push({
|
|
219
|
+
artifact,
|
|
220
|
+
path: p,
|
|
221
|
+
classification,
|
|
222
|
+
active_count: null,
|
|
223
|
+
archive_count: null,
|
|
224
|
+
total_count: null,
|
|
225
|
+
over_limit_count: null,
|
|
226
|
+
reason,
|
|
227
|
+
protected_overflow_count: 0,
|
|
228
|
+
exists: fs.existsSync(p),
|
|
229
|
+
});
|
|
230
|
+
}
|
|
231
|
+
const optimizeDir = path.join(projectRoot, ".agentera", "optimize");
|
|
232
|
+
if (fs.existsSync(optimizeDir) && fs.statSync(optimizeDir).isDirectory()) {
|
|
233
|
+
const experimentPaths = [];
|
|
234
|
+
for (const sub of fs.readdirSync(optimizeDir).sort()) {
|
|
235
|
+
const expPath = path.join(optimizeDir, sub, "experiments.yaml");
|
|
236
|
+
if (fs.existsSync(expPath))
|
|
237
|
+
experimentPaths.push(expPath);
|
|
238
|
+
}
|
|
239
|
+
for (const expPath of experimentPaths) {
|
|
240
|
+
let activeCount;
|
|
241
|
+
let archiveCount;
|
|
242
|
+
try {
|
|
243
|
+
[activeCount, archiveCount] = yamlCounts(expPath, "experiments", "archive");
|
|
244
|
+
}
|
|
245
|
+
catch (exc) {
|
|
246
|
+
statuses.push(yamlErrorStatus("experiments", expPath, exc.message));
|
|
247
|
+
continue;
|
|
248
|
+
}
|
|
249
|
+
statuses.push({
|
|
250
|
+
artifact: "experiments",
|
|
251
|
+
path: expPath,
|
|
252
|
+
classification: "protected",
|
|
253
|
+
active_count: activeCount,
|
|
254
|
+
archive_count: archiveCount,
|
|
255
|
+
total_count: activeCount + archiveCount,
|
|
256
|
+
over_limit_count: overLimitCount(activeCount, archiveCount),
|
|
257
|
+
reason: "objective-state experiment files are classified but skipped by default",
|
|
258
|
+
protected_overflow_count: 0,
|
|
259
|
+
exists: true,
|
|
260
|
+
});
|
|
261
|
+
}
|
|
262
|
+
}
|
|
263
|
+
// Touch yamlArchiveEntries to keep the export alive in dry builds.
|
|
264
|
+
void yamlArchiveEntries;
|
|
265
|
+
return statuses;
|
|
266
|
+
}
|
|
267
|
+
function operationForStatus(status, mode) {
|
|
268
|
+
const base = (action, message) => ({
|
|
269
|
+
status,
|
|
270
|
+
mode,
|
|
271
|
+
action,
|
|
272
|
+
changed: false,
|
|
273
|
+
result: null,
|
|
274
|
+
message,
|
|
275
|
+
});
|
|
276
|
+
if (!status.exists)
|
|
277
|
+
return base("missing", status.reason);
|
|
278
|
+
if (status.classification === "error")
|
|
279
|
+
return base("error", status.reason);
|
|
280
|
+
if (status.classification !== "compactable")
|
|
281
|
+
return base("skipped", status.reason);
|
|
282
|
+
if (status.projection_recovery?.refused_count) {
|
|
283
|
+
return base("refused", `projection retained ${status.projection_recovery.retained_full} full entr${status.projection_recovery.retained_full === 1 ? "y" : "ies"}; archive recovery is required before summarization`);
|
|
284
|
+
}
|
|
285
|
+
if (status.projection_state === "over_defaults") {
|
|
286
|
+
return base(mode === "fix" ? "pending_projection" : "projection", "projection exceeds display defaults; archive history remains lossless");
|
|
287
|
+
}
|
|
288
|
+
if (!status.over_limit_count && !status.pending_summarization_count) {
|
|
289
|
+
return base("ok", status.projection_state === "within_defaults"
|
|
290
|
+
? "within configured lossless projection defaults"
|
|
291
|
+
: "within uniform_10_40_50 limits");
|
|
292
|
+
}
|
|
293
|
+
if (status.over_limit_count) {
|
|
294
|
+
return base(mode === "check" ? "over_limit" : "pending_fix", `over uniform_10_40_50 limit by ${status.over_limit_count}`);
|
|
295
|
+
}
|
|
296
|
+
// pending_summarization_count > 0 but within budget: rows 11-50 need
|
|
297
|
+
// ≤15-word summary formatting, not entry removal.
|
|
298
|
+
const n = status.pending_summarization_count;
|
|
299
|
+
return base(mode === "check" ? "formatting" : "pending_formatting", `${n} resolved entr${n === 1 ? "y" : "ies"} in summary tier need ≤15-word summarization`);
|
|
300
|
+
}
|
|
301
|
+
export function checkCompaction(projectRoot) {
|
|
302
|
+
return computeCompactionStatus(projectRoot).map((status) => operationForStatus(status, "check"));
|
|
303
|
+
}
|
|
304
|
+
function fixCompactionUnlocked(projectRoot, transaction) {
|
|
305
|
+
const operations = [];
|
|
306
|
+
for (const status of computeCompactionStatus(projectRoot)) {
|
|
307
|
+
const baseline = operationForStatus(status, "fix");
|
|
308
|
+
if (baseline.action !== "pending_fix" &&
|
|
309
|
+
baseline.action !== "pending_projection" &&
|
|
310
|
+
baseline.action !== "pending_formatting") {
|
|
311
|
+
operations.push(baseline);
|
|
312
|
+
continue;
|
|
313
|
+
}
|
|
314
|
+
const p = status.path;
|
|
315
|
+
let result;
|
|
316
|
+
try {
|
|
317
|
+
if (status.artifact === "todo#Resolved") {
|
|
318
|
+
result = transaction.mutateProjection(p, (stage) => compactFile(stage, "todo-resolved"));
|
|
319
|
+
}
|
|
320
|
+
else if (status.artifact in YAML_SPEC_BY_ARTIFACT) {
|
|
321
|
+
result = transaction.mutateProjection(p, (stage) => compactYamlFile(stage, status.artifact, projectRoot));
|
|
322
|
+
}
|
|
323
|
+
else {
|
|
324
|
+
operations.push({ status, mode: "fix", action: "skipped", changed: false, result: null, message: `no fixer registered for ${status.artifact}` });
|
|
325
|
+
continue;
|
|
326
|
+
}
|
|
327
|
+
}
|
|
328
|
+
catch (exc) {
|
|
329
|
+
if (exc instanceof InjectedMutationFailure)
|
|
330
|
+
throw exc;
|
|
331
|
+
operations.push({ status, mode: "fix", action: "error", changed: false, result: null, message: exc.message });
|
|
332
|
+
continue;
|
|
333
|
+
}
|
|
334
|
+
operations.push({
|
|
335
|
+
status,
|
|
336
|
+
mode: "fix",
|
|
337
|
+
action: result.changed ? "compacted" : "ok",
|
|
338
|
+
changed: result.changed,
|
|
339
|
+
result,
|
|
340
|
+
message: `full ${result.full_before}->${result.full_after}; ` +
|
|
341
|
+
`archive ${result.oneline_before}->${result.oneline_after}; ` +
|
|
342
|
+
`omitted ${result.omitted_count ?? 0}; dropped ${result.dropped}`,
|
|
343
|
+
});
|
|
344
|
+
}
|
|
345
|
+
return operations;
|
|
346
|
+
}
|
|
347
|
+
export function fixCompaction(projectRoot, options = {}) {
|
|
348
|
+
return withStateMutation(projectRoot, (transaction) => fixCompactionUnlocked(projectRoot, transaction), options);
|
|
349
|
+
}
|
|
350
|
+
export function runCompaction(projectRoot, mode = "check", options = {}) {
|
|
351
|
+
if (mode === "check")
|
|
352
|
+
return checkCompaction(projectRoot);
|
|
353
|
+
if (mode === "fix") {
|
|
354
|
+
if (detectStateMode(projectRoot) === "entities") {
|
|
355
|
+
return computeCompactionStatus(projectRoot).map((status) => operationForStatus(status, "fix"));
|
|
356
|
+
}
|
|
357
|
+
return fixCompaction(projectRoot, options);
|
|
358
|
+
}
|
|
359
|
+
throw new Error(`unknown compaction mode: ${mode}`);
|
|
360
|
+
}
|
|
@@ -0,0 +1,9 @@
|
|
|
1
|
+
/**
|
|
2
|
+
* Re-exports of protocol classification sets used by the validator.
|
|
3
|
+
* Kept as a separate module so the runtime, schema, and orchestrator
|
|
4
|
+
* submodules can all share the same set identity (no duplication of
|
|
5
|
+
* the AGENT_FACING_ARTIFACT_IDS computation across hot paths).
|
|
6
|
+
*/
|
|
7
|
+
import { ARTIFACT_PROTOCOL_PATHS, HUMAN_FACING_ARTIFACT_IDS } from "../../registries/artifactProtocolIds.js";
|
|
8
|
+
export { ARTIFACT_PROTOCOL_PATHS, HUMAN_FACING_ARTIFACT_IDS };
|
|
9
|
+
export const AGENT_FACING_ARTIFACT_IDS = new Set(Object.keys(ARTIFACT_PROTOCOL_PATHS).filter((id) => !HUMAN_FACING_ARTIFACT_IDS.has(id)));
|
|
@@ -0,0 +1,92 @@
|
|
|
1
|
+
/**
|
|
2
|
+
* Artifact validation used by the explicit `agentera check validate artifact`
|
|
3
|
+
* command and state publication.
|
|
4
|
+
*/
|
|
5
|
+
import fs from "node:fs";
|
|
6
|
+
import path from "node:path";
|
|
7
|
+
import { loadYamlMapping } from "../../core/yaml.js";
|
|
8
|
+
import { resolvePath } from "../../core/paths.js";
|
|
9
|
+
import { normalizeArtifactProtocolId } from "../../registries/artifactProtocolIds.js";
|
|
10
|
+
import { DEFAULT_ARTIFACT_PATHS } from "../common.js";
|
|
11
|
+
import { validateMd } from "./markdown.js";
|
|
12
|
+
import { defaultArtifactPath, readIfNeeded, } from "./traversal.js";
|
|
13
|
+
import { schemasDirDefault, validateYamlContent } from "./violations.js";
|
|
14
|
+
import { AGENT_FACING_ARTIFACT_IDS, HUMAN_FACING_ARTIFACT_IDS } from "./agentFacing.js";
|
|
15
|
+
export class ArtifactSchemaValidator {
|
|
16
|
+
schemasDir;
|
|
17
|
+
schemaCache;
|
|
18
|
+
constructor(schemasDir = schemasDirDefault()) {
|
|
19
|
+
this.schemasDir = schemasDir;
|
|
20
|
+
this.schemaCache = new Map();
|
|
21
|
+
}
|
|
22
|
+
loadSchema(name) {
|
|
23
|
+
if (!this.schemaCache.has(name)) {
|
|
24
|
+
const p = path.join(this.schemasDir, `${name}.yaml`);
|
|
25
|
+
if (fs.existsSync(p) && fs.statSync(p).isFile()) {
|
|
26
|
+
// cast: artifact schema parsed from a YAML schema file
|
|
27
|
+
this.schemaCache.set(name, loadYamlMapping(fs.readFileSync(p, "utf8")));
|
|
28
|
+
}
|
|
29
|
+
else {
|
|
30
|
+
this.schemaCache.set(name, null);
|
|
31
|
+
}
|
|
32
|
+
}
|
|
33
|
+
return this.schemaCache.get(name) ?? null;
|
|
34
|
+
}
|
|
35
|
+
validateYaml(content, schema, name) {
|
|
36
|
+
return validateYamlContent(content, schema, name);
|
|
37
|
+
}
|
|
38
|
+
validateMarkdown(content, name, schema = null) {
|
|
39
|
+
return validateMd(content, name, schema);
|
|
40
|
+
}
|
|
41
|
+
validateExplicit(artifact, filePath, cwd) {
|
|
42
|
+
const content = readIfNeeded(null, filePath);
|
|
43
|
+
if (content === null)
|
|
44
|
+
return [`${artifact}: cannot read artifact file '${filePath}'`];
|
|
45
|
+
const protocolId = normalizeArtifactProtocolId(artifact);
|
|
46
|
+
if (protocolId === null) {
|
|
47
|
+
return [`${artifact}: unsupported artifact protocol id`];
|
|
48
|
+
}
|
|
49
|
+
if (AGENT_FACING_ARTIFACT_IDS.has(protocolId)) {
|
|
50
|
+
const schema = this.loadSchema(protocolId);
|
|
51
|
+
if (schema === null)
|
|
52
|
+
return [`${protocolId}: schema '${protocolId}' is not available`];
|
|
53
|
+
if (Object.keys(schema).length === 0) {
|
|
54
|
+
return [`${protocolId}: schema '${protocolId}' file is empty or contains no valid definitions`];
|
|
55
|
+
}
|
|
56
|
+
return this.validateYaml(content, schema, protocolId);
|
|
57
|
+
}
|
|
58
|
+
if (HUMAN_FACING_ARTIFACT_IDS.has(protocolId)) {
|
|
59
|
+
const schema = this.loadSchema(protocolId);
|
|
60
|
+
return this.validateMarkdown(content, artifact, schema);
|
|
61
|
+
}
|
|
62
|
+
return [
|
|
63
|
+
`${artifact}: unsupported artifact; expected one of: ${Object.keys(DEFAULT_ARTIFACT_PATHS).sort().join(", ")}`,
|
|
64
|
+
];
|
|
65
|
+
}
|
|
66
|
+
}
|
|
67
|
+
export function loadSchema(name) {
|
|
68
|
+
return new ArtifactSchemaValidator().loadSchema(name);
|
|
69
|
+
}
|
|
70
|
+
export class ArtifactValidationAdapter {
|
|
71
|
+
validator;
|
|
72
|
+
constructor(validator) {
|
|
73
|
+
this.validator = validator ?? new ArtifactSchemaValidator();
|
|
74
|
+
}
|
|
75
|
+
runExplicit(artifact, filePath, cwd) {
|
|
76
|
+
artifact = artifact.trim();
|
|
77
|
+
const defaultPath = defaultArtifactPath(artifact, cwd);
|
|
78
|
+
const resolvedFile = filePath ? (path.isAbsolute(filePath) ? filePath : path.join(cwd, filePath)) : defaultPath;
|
|
79
|
+
const violations = this.validator.validateExplicit(artifact, resolvedFile, cwd);
|
|
80
|
+
const payload = {
|
|
81
|
+
command: "validate-artifact",
|
|
82
|
+
status: violations.length > 0 ? "fail" : "pass",
|
|
83
|
+
artifact,
|
|
84
|
+
file: resolvedFile,
|
|
85
|
+
docs_mapped_default: defaultPath || null,
|
|
86
|
+
path_source: filePath ? "provided" : "docs_mapped_default",
|
|
87
|
+
violations,
|
|
88
|
+
};
|
|
89
|
+
return violations.length > 0 ? [2, payload] : [0, payload];
|
|
90
|
+
}
|
|
91
|
+
}
|
|
92
|
+
export { resolvePath };
|
|
@@ -0,0 +1,145 @@
|
|
|
1
|
+
/**
|
|
2
|
+
* Markdown validation for human-facing artifacts (TODO.md, CHANGELOG.md,
|
|
3
|
+
* SKILL.md, ...). Walks the artifact's schema looking for any group
|
|
4
|
+
* with required `field` entries and dispatches to the appropriate
|
|
5
|
+
* section check (ITEM, RELEASE, TOKEN).
|
|
6
|
+
*/
|
|
7
|
+
import { parseTodoMarkdownListItem } from "../../cli/todoMarkdown.js";
|
|
8
|
+
import { classifyTodoSectionHeading, countTodoResolvedSectionHeadings, isLegacyStrikethroughTodoLine, } from "../compaction/parse.js";
|
|
9
|
+
import { isMapping } from "./schema.js";
|
|
10
|
+
function validateTodoResolvedPlacement(content, name) {
|
|
11
|
+
const violations = [];
|
|
12
|
+
let section = "other";
|
|
13
|
+
for (const line of content.split(/\r\n|\r|\n/)) {
|
|
14
|
+
const kind = classifyTodoSectionHeading(line);
|
|
15
|
+
if (kind === "resolved") {
|
|
16
|
+
section = "resolved";
|
|
17
|
+
continue;
|
|
18
|
+
}
|
|
19
|
+
if (kind === "severity") {
|
|
20
|
+
section = "severity";
|
|
21
|
+
continue;
|
|
22
|
+
}
|
|
23
|
+
if (/^##\s/.test(line.trim())) {
|
|
24
|
+
section = "other";
|
|
25
|
+
continue;
|
|
26
|
+
}
|
|
27
|
+
const trimmed = line.trim();
|
|
28
|
+
if (!trimmed.startsWith("-"))
|
|
29
|
+
continue;
|
|
30
|
+
const parsed = parseTodoMarkdownListItem(trimmed);
|
|
31
|
+
if (parsed?.status === "resolved") {
|
|
32
|
+
if (section === "severity") {
|
|
33
|
+
violations.push(`${name}: resolved checkbox item must live under '## ✓ Resolved', not in severity bands`);
|
|
34
|
+
break;
|
|
35
|
+
}
|
|
36
|
+
}
|
|
37
|
+
if (isLegacyStrikethroughTodoLine(trimmed)) {
|
|
38
|
+
violations.push(`${name}: legacy strikethrough resolved items are not allowed; use '- [x]' under '## ✓ Resolved'`);
|
|
39
|
+
break;
|
|
40
|
+
}
|
|
41
|
+
}
|
|
42
|
+
// Exactly one section keeps parsing and compaction unambiguous, including
|
|
43
|
+
// before the first item is resolved. See todo.yaml TC8.
|
|
44
|
+
const resolvedHeadingCount = countTodoResolvedSectionHeadings(content);
|
|
45
|
+
if (resolvedHeadingCount === 0) {
|
|
46
|
+
violations.push(`${name}: missing required '## ✓ Resolved' section`);
|
|
47
|
+
}
|
|
48
|
+
else if (resolvedHeadingCount > 1) {
|
|
49
|
+
violations.push(`${name}: ${resolvedHeadingCount} '## ✓ Resolved' sections found; merge into exactly one (duplicate sections hide entries from the compaction gate and parsing processes only the first).`);
|
|
50
|
+
}
|
|
51
|
+
return violations;
|
|
52
|
+
}
|
|
53
|
+
const SKIP_META = new Set(["meta", "GROUP_PREFIXES", "BUDGET", "COMPACTION", "VALIDATION", "CONVENTION"]);
|
|
54
|
+
export function validateMd(content, name, schema = null) {
|
|
55
|
+
const violations = [];
|
|
56
|
+
if (!content.trim())
|
|
57
|
+
violations.push(`${name}: empty content`);
|
|
58
|
+
const fences = (content.match(/^```/gm) ?? []).length;
|
|
59
|
+
if (fences % 2)
|
|
60
|
+
violations.push(`${name}: unclosed code fence`);
|
|
61
|
+
if (schema)
|
|
62
|
+
violations.push(...validateMdSchema(content, name, schema));
|
|
63
|
+
return violations;
|
|
64
|
+
}
|
|
65
|
+
export function validateMdSchema(content, name, schema) {
|
|
66
|
+
const violations = [];
|
|
67
|
+
if (!content.trim())
|
|
68
|
+
return violations;
|
|
69
|
+
for (const [groupKey, groupValue] of Object.entries(schema)) {
|
|
70
|
+
if (SKIP_META.has(groupKey) || !isMapping(groupValue))
|
|
71
|
+
continue;
|
|
72
|
+
const hasRequired = Object.values(groupValue).some((e) => isMapping(e) && e.required && e.field);
|
|
73
|
+
if (!hasRequired)
|
|
74
|
+
continue;
|
|
75
|
+
if (groupKey === "ITEM")
|
|
76
|
+
validateMdItems(content, name, violations);
|
|
77
|
+
else if (groupKey === "RELEASE")
|
|
78
|
+
validateMdReleases(content, name, violations);
|
|
79
|
+
else if (groupKey === "TOKEN")
|
|
80
|
+
validateMdTokens(content, name, violations);
|
|
81
|
+
}
|
|
82
|
+
return violations;
|
|
83
|
+
}
|
|
84
|
+
export function validateMdItems(content, name, violations) {
|
|
85
|
+
const versionHeading = /^##\s+/m.exec(content);
|
|
86
|
+
if (!versionHeading) {
|
|
87
|
+
violations.push(`${name}: missing severity sections (expected '## <glyph> <name>' headings)`);
|
|
88
|
+
return;
|
|
89
|
+
}
|
|
90
|
+
const severityGlyphs = ["⇶", "⇉", "→", "⇢"];
|
|
91
|
+
let found = false;
|
|
92
|
+
for (const glyph of severityGlyphs) {
|
|
93
|
+
const g = glyph.replace(/[.*+?^${}()|[\]\\]/g, "\\$&");
|
|
94
|
+
if (new RegExp(`^##\\s*${g}`, "m").test(content)) {
|
|
95
|
+
found = true;
|
|
96
|
+
const sectionStart = new RegExp(`^##\\s*${g}.+$`, "m").exec(content);
|
|
97
|
+
if (sectionStart) {
|
|
98
|
+
const idx = sectionStart.index + sectionStart[0].length;
|
|
99
|
+
const nextMatch = content.slice(idx).match(/\n##\s/);
|
|
100
|
+
let bodyStart = idx;
|
|
101
|
+
if (content.startsWith("\r\n", bodyStart))
|
|
102
|
+
bodyStart += 2;
|
|
103
|
+
else if (content[bodyStart] === "\n")
|
|
104
|
+
bodyStart += 1;
|
|
105
|
+
const sectionEnd = nextMatch ? idx + nextMatch.index : content.length;
|
|
106
|
+
const sectionBody = content.slice(bodyStart, sectionEnd);
|
|
107
|
+
const headingSlice = content.slice(sectionStart.index, sectionStart.index + sectionStart[0].length);
|
|
108
|
+
const glyphNameMatch = new RegExp(`^##\\s*(${g}.+)$`, "m").exec(headingSlice);
|
|
109
|
+
const headingText = glyphNameMatch ? glyphNameMatch[1] : glyph;
|
|
110
|
+
const gluedNextSection = nextMatch?.index === 0;
|
|
111
|
+
if (gluedNextSection || /^\s*##\s/m.test(sectionBody)) {
|
|
112
|
+
violations.push(`${name}: severity section '${headingText}' body contains a nested heading; add a blank line before the next '##' section`);
|
|
113
|
+
}
|
|
114
|
+
if (glyph === "⇶" && /^\s*-\s+\[x\]/im.test(sectionBody)) {
|
|
115
|
+
violations.push(`${name}: severity section '⇶ Critical' must not contain resolved '- [x]' items; move them to '## ✓ Resolved'`);
|
|
116
|
+
}
|
|
117
|
+
}
|
|
118
|
+
}
|
|
119
|
+
}
|
|
120
|
+
if (name === "TODO.md" || name === "todo") {
|
|
121
|
+
violations.push(...validateTodoResolvedPlacement(content, name));
|
|
122
|
+
}
|
|
123
|
+
if (!found) {
|
|
124
|
+
violations.push(`${name}: missing severity glyph in section headings (expected '## ⇶ Critical', '## ⇉ Degraded', '## → Normal', '## ⇢ Annoying')`);
|
|
125
|
+
}
|
|
126
|
+
}
|
|
127
|
+
export function validateMdReleases(content, name, violations) {
|
|
128
|
+
if (!/^##\s*\[/m.test(content)) {
|
|
129
|
+
violations.push(`${name}: missing version header (expected '## [X.Y.Z]')`);
|
|
130
|
+
}
|
|
131
|
+
const changeSections = new Set(["### Added", "### Changed", "### Fixed", "### Removed"]);
|
|
132
|
+
const lines = new Set(content.split("\n"));
|
|
133
|
+
if (![...changeSections].some((s) => lines.has(s))) {
|
|
134
|
+
violations.push(`${name}: missing change sections (expected '### Added', '### Changed', '### Fixed', or '### Removed')`);
|
|
135
|
+
}
|
|
136
|
+
}
|
|
137
|
+
export function validateMdTokens(content, name, violations) {
|
|
138
|
+
if (!/^##\s/m.test(content)) {
|
|
139
|
+
violations.push(`${name}: missing section heading (expected '## SectionName')`);
|
|
140
|
+
}
|
|
141
|
+
const yamlBlocks = (content.match(/^```yaml\s*$/gm) ?? []).length;
|
|
142
|
+
if (!yamlBlocks) {
|
|
143
|
+
violations.push(`${name}: missing YAML code block with token definitions (expected '\`\`\`yaml')`);
|
|
144
|
+
}
|
|
145
|
+
}
|