agentera 3.0.0-dev.6 → 3.0.0-dev.69
This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
- package/LICENSE +201 -0
- package/README.md +118 -22
- package/bundle/CHANGELOG.md +1361 -0
- package/bundle/DESIGN.md +229 -0
- package/bundle/LICENSE +201 -0
- package/bundle/README.md +143 -0
- package/bundle/UPGRADE.md +252 -0
- package/bundle/extract-corpus-parity.json +21 -0
- package/bundle/fixtures/routing/hybrid-corpus.yaml +154 -0
- package/bundle/references/adapters/package-publication.json +488 -0
- package/bundle/references/adapters/package-registry.yaml +435 -188
- package/bundle/references/adapters/package-surface-characterization.md +66 -34
- package/bundle/references/adapters/runtime-lifecycle-adapters.yaml +74 -0
- package/bundle/references/adapters/runtime-lifecycle-authority.yaml +62 -0
- package/bundle/references/adapters/runtime-lifecycle-operation-contract.yaml +84 -0
- package/bundle/references/adapters/runtime-retired-resources.yaml +333 -0
- package/bundle/references/analysis/evidence-tier-authority.yaml +518 -0
- package/bundle/references/analysis/verification-policy.yaml +266 -0
- package/bundle/references/artifacts/artifact-registry-interface-model.yaml +20 -10
- package/bundle/references/artifacts/glossary-entry-contract.yaml +1254 -0
- package/bundle/references/artifacts/state-storage-authority.yaml +3061 -0
- package/bundle/references/artifacts/verbosity-budget-authority.yaml +42 -0
- package/bundle/references/cli/app-lifecycle-vocabulary.yaml +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 -2
- package/bundle/references/cli/vocabulary-index.yaml +20 -17
- package/bundle/references/cli/vocabulary.md +325 -362
- package/bundle/references/meta/retained-reference-authority.yaml +151 -0
- package/bundle/registry.json +13 -13
- package/bundle/skills/agentera/SKILL.md +226 -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 +103 -0
- package/bundle/skills/agentera/capabilities/{realisera → build}/schemas/exit.yaml +8 -6
- package/bundle/skills/agentera/capabilities/build/schemas/triggers.yaml +27 -0
- package/bundle/skills/agentera/capabilities/build/schemas/validation.yaml +184 -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 +461 -36
- package/bundle/skills/agentera/schemas/artifacts/progress.yaml +133 -20
- 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 +101 -12
- package/dist/analytics/extractCorpus/copilotSessions.js +53 -9
- package/dist/analytics/extractCorpus/core.js +59 -24
- package/dist/analytics/extractCorpus/corpus.js +58 -23
- package/dist/analytics/extractCorpus/coverageAudit.js +260 -0
- package/dist/analytics/extractCorpus/cursorSessions.js +12 -7
- package/dist/analytics/extractCorpus/evidenceTiers.js +603 -0
- package/dist/analytics/extractCorpus/extractCorpusParity.js +105 -0
- package/dist/analytics/extractCorpus/filesystemSources.js +1 -5
- package/dist/analytics/extractCorpus/index.js +6 -1
- package/dist/analytics/extractCorpus/jsonlSessions.js +24 -5
- package/dist/analytics/extractCorpus/sqliteCaps.js +43 -0
- package/dist/analytics/extractCorpus/sqliteSessions.js +98 -6
- package/dist/analytics/extractCorpus/tierReader.js +108 -0
- package/dist/analytics/extractCorpus.js +0 -1
- package/dist/analytics/glossaryAdviceResolution.js +166 -0
- package/dist/analytics/glossaryInputAcquisition.js +319 -0
- package/dist/analytics/personalGlossaryAdmission.js +133 -0
- package/dist/analytics/personalGlossaryProfile.js +219 -0
- package/dist/analytics/profileSignals.js +211 -0
- package/dist/analytics/usageStats.js +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 +59 -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 +25 -17
- package/dist/cli/capabilityContext/bespoke.js +31 -12
- package/dist/cli/capabilityContext/build.js +251 -0
- package/dist/cli/capabilityContext/closeout.js +33 -30
- package/dist/cli/capabilityContext/contract.js +39 -46
- package/dist/cli/capabilityContext/evidence.js +90 -73
- package/dist/cli/capabilityContext/index.js +1 -2
- package/dist/cli/capabilityContext/orchestration.js +45 -21
- package/dist/cli/capabilityContext/planState.js +93 -100
- package/dist/cli/capabilityContext/progress.js +60 -14
- package/dist/cli/capabilityContext/projectVerification.js +409 -0
- package/dist/cli/capabilityContext/shared.js +9 -20
- package/dist/cli/capabilityContext/slim.js +56 -10
- package/dist/cli/capabilityContext/startup.js +57 -115
- package/dist/cli/capabilityContext/startupAggregation.js +68 -0
- package/dist/cli/capabilityContext/types.js +37 -24
- package/dist/cli/capabilityContext.js +1 -2
- package/dist/cli/commands/appHome.js +22 -0
- package/dist/cli/commands/capability.js +4 -4
- package/dist/cli/commands/compact.js +163 -13
- package/dist/cli/commands/doctor.js +122 -114
- package/dist/cli/commands/durability.js +81 -0
- package/dist/cli/commands/glossaryAdvice.js +138 -0
- package/dist/cli/commands/lint.js +22 -8
- package/dist/cli/commands/personalGlossary.js +176 -0
- package/dist/cli/commands/prime/briefOrientation.js +746 -0
- package/dist/cli/commands/prime/buildExecutionRequest.js +165 -0
- package/dist/cli/commands/prime/bundleStatus.js +190 -0
- package/dist/cli/commands/prime/collectEntityOrientation.js +326 -0
- package/dist/cli/commands/prime/collectOrientationState.js +219 -0
- package/dist/cli/commands/prime/orientationOutput.js +421 -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 +77 -52
- package/dist/cli/commands/report.js +88 -26
- package/dist/cli/commands/route.js +142 -0
- package/dist/cli/commands/schema.js +266 -142
- package/dist/cli/commands/state/decisions.js +51 -61
- package/dist/cli/commands/state/docs.js +63 -86
- package/dist/cli/commands/state/experimentRecords.js +151 -0
- package/dist/cli/commands/state/experiments.js +11 -64
- package/dist/cli/commands/state/get.js +129 -0
- package/dist/cli/commands/state/health.js +11 -111
- package/dist/cli/commands/state/index.js +6 -41
- package/dist/cli/commands/state/list.js +194 -0
- package/dist/cli/commands/state/objective.js +21 -64
- package/dist/cli/commands/state/plan.js +11 -169
- package/dist/cli/commands/state/planTasks.js +154 -0
- package/dist/cli/commands/state/plans.js +154 -0
- package/dist/cli/commands/state/progress.js +11 -45
- package/dist/cli/commands/state/shared.js +0 -1
- package/dist/cli/commands/state/todo.js +29 -108
- package/dist/cli/commands/state/write.js +433 -0
- package/dist/cli/commands/upgrade.js +146 -5
- package/dist/cli/commands/upgradeVerify.js +118 -0
- package/dist/cli/commands/validate.js +246 -211
- 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 +94 -50
- package/dist/cli/dispatch/commands.js +27 -0
- package/dist/cli/dispatch/index.js +82 -52
- package/dist/cli/dispatch/lifecycle.js +268 -108
- package/dist/cli/dispatch/prime.js +68 -29
- package/dist/cli/dispatch/projections.js +17 -0
- package/dist/cli/dispatch/shared.js +1 -2
- package/dist/cli/dispatch/state.js +68 -77
- package/dist/cli/dispatch.js +0 -1
- package/dist/cli/errors.js +16 -17
- package/dist/cli/help.js +395 -41
- package/dist/cli/migrationRequired.js +122 -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 +3 -56
- package/dist/hooks/compaction/apply.js +252 -50
- package/dist/hooks/compaction/dryRun.js +7 -4
- package/dist/hooks/compaction/index.js +5 -6
- package/dist/hooks/compaction/parse.js +201 -5
- package/dist/hooks/compaction/retention.js +30 -25
- package/dist/hooks/compaction/status.js +149 -32
- package/dist/hooks/compaction/types.js +0 -1
- package/dist/hooks/validateArtifact/agentFacing.js +0 -1
- package/dist/hooks/validateArtifact/index.js +7 -64
- package/dist/hooks/validateArtifact/markdown.js +57 -7
- package/dist/hooks/validateArtifact/schema.js +110 -19
- package/dist/hooks/validateArtifact/traversal.js +13 -11
- package/dist/hooks/validateArtifact/violations.js +7 -5
- package/dist/migrate/v2HandoffManifest.js +127 -8
- package/dist/registries/activationContract.js +2 -0
- package/dist/registries/activationTuples.js +108 -0
- package/dist/registries/artifactProtocolIds.js +2 -1
- package/dist/registries/artifactRegistry.js +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 +273 -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 +156 -6
- package/dist/runtime/lifecycleAdapterContract.js +457 -0
- package/dist/runtime/lifecycleAdapters.js +777 -0
- package/dist/runtime/lifecycleAuthority.js +453 -0
- package/dist/runtime/lifecycleOperationContract.js +123 -0
- package/dist/runtime/lifecycleOperations.js +634 -0
- package/dist/runtime/lifecycleOwnershipJournal.js +622 -0
- package/dist/runtime/lifecyclePublication.js +415 -0
- package/dist/runtime/lifecycleSnapshot.js +438 -0
- package/dist/runtime/nativeResourceCleanup.js +502 -0
- package/dist/setup/opencode.js +20 -13
- package/dist/setup/opencodeConstants.js +1 -0
- package/dist/setup/sharedSkill.js +45 -0
- package/dist/setup/smokeChecks.js +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 +840 -0
- package/dist/state/entityMigrationTodo.js +133 -0
- package/dist/state/entityPublicationContext.js +859 -0
- package/dist/state/entityRetrievalHelp.js +506 -0
- package/dist/state/entityStorage.js +899 -0
- package/dist/state/exactReplacementRecovery.js +18 -0
- package/dist/state/experimentArchive.js +63 -0
- package/dist/state/experimentIdentity.js +202 -0
- package/dist/state/healthEntities.js +262 -0
- package/dist/state/healthEntityValidation.js +18 -0
- package/dist/state/healthRepair.js +69 -0
- package/dist/state/installRoot.js +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 +1027 -0
- package/dist/state/planIdentity.js +47 -0
- package/dist/state/planLineageValidation.js +52 -0
- package/dist/state/planReplacementTransaction.js +475 -0
- package/dist/state/planRetrieval.js +313 -0
- package/dist/state/planTaskRetrieval.js +294 -0
- package/dist/state/progressEntities.js +512 -0
- package/dist/state/progressGlossaryCaveat.js +168 -0
- package/dist/state/progressPublicationOrder.js +19 -0
- package/dist/state/progressWritePolicy.js +33 -0
- package/dist/state/projectRoot.js +62 -0
- package/dist/state/projectionPolicy.js +190 -0
- package/dist/state/retrievalAuthority.js +156 -0
- package/dist/state/safeProjectFile.js +155 -0
- package/dist/state/startupAnalysis/benchmark.js +92 -27
- package/dist/state/startupAnalysis/contract.js +48 -10
- package/dist/state/startupAnalysis/helpers.js +27 -73
- package/dist/state/startupAnalysis/index.js +0 -1
- package/dist/state/startupAnalysis/metrics.js +25 -19
- package/dist/state/startupAnalysis/records.js +13 -10
- package/dist/state/startupAnalysis/report.js +26 -38
- package/dist/state/startupAnalysis/threshold.js +19 -7
- package/dist/state/startupAnalysis.js +0 -1
- package/dist/state/startupProjection.js +499 -0
- package/dist/state/stateMode.js +222 -0
- package/dist/state/stateStorageAuthority.js +47 -0
- package/dist/state/summaryEntityRead.js +25 -0
- package/dist/state/summaryMigrationProvenance.js +66 -0
- package/dist/state/summarySourceRowAuthority.js +36 -0
- package/dist/state/todoActivationSafety.js +58 -0
- package/dist/state/todoDocsEntities.js +1124 -0
- package/dist/state/todoDocsEntityValidation.js +158 -0
- package/dist/state/todoMarkdownProjection.js +51 -0
- package/dist/state/todoReconciliationActivation.js +182 -0
- package/dist/state/todoReconciliationInspection.js +171 -0
- package/dist/state/todoReconciliationRepair.js +318 -0
- package/dist/state/todoReconciliationTransaction.js +595 -0
- package/dist/state/write/assign.js +20 -0
- package/dist/state/write/candidateMutation.js +269 -0
- package/dist/state/write/errors.js +11 -0
- package/dist/state/write/experimentPublication.js +192 -0
- package/dist/state/write/explain.js +377 -0
- package/dist/state/write/fields.js +61 -0
- package/dist/state/write/glossaryPublication.js +263 -0
- package/dist/state/write/grammar.js +285 -0
- package/dist/state/write/helpers.js +29 -0
- package/dist/state/write/index.js +12 -0
- package/dist/state/write/input.js +391 -0
- package/dist/state/write/lock.js +837 -0
- package/dist/state/write/mutation.js +234 -0
- package/dist/state/write/operations.js +170 -0
- package/dist/state/write/planEvaluation.js +128 -0
- package/dist/state/write/planPublication.js +179 -0
- package/dist/state/write/runtimeOperations.js +146 -0
- package/dist/state/write/serialize.js +1 -0
- package/dist/state/write/transaction.js +57 -0
- package/dist/state/write/validate.js +7 -0
- package/dist/upgrade/appContentRefresh.js +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 +165 -199
- 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 +375 -79
- package/dist/upgrade/migrationPublication.js +122 -0
- package/dist/upgrade/nextMajorDoctor.js +29 -10
- package/dist/upgrade/npxPlatformStatus.js +22 -0
- package/dist/upgrade/projectIntegration.js +145 -189
- package/dist/upgrade/projectIntegrationDecision.js +50 -0
- package/dist/upgrade/retiredResourceDiagnostics.js +117 -0
- package/dist/upgrade/runtimeMigration.js +272 -373
- package/dist/upgrade/upgradeCommands.js +14 -1
- package/dist/upgrade/upgradeLock.js +85 -0
- package/dist/upgrade/upgradeOrchestrator.js +263 -59
- package/dist/upgrade/v3CapabilitySurface.js +2 -3
- package/dist/upgrade/versionResolution.js +2 -3
- package/dist/validate/activationArtifactEvidence.js +852 -0
- package/dist/validate/activationArtifactEvidenceTypes.js +12 -0
- package/dist/validate/activationConjunction.js +816 -0
- package/dist/validate/activationEvidenceManifest.js +531 -0
- package/dist/validate/activationPackageSemantics.js +29 -0
- package/dist/validate/appHomeContract.js +2 -8
- 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 +39 -45
- package/dist/validate/v1LegacyCruft.js +131 -0
- package/dist/validate/vocabularyAuthority.js +18 -13
- package/package.json +60 -29
- 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 -369
- package/bundle/references/cli/bundle-skill-vocabulary.yaml +0 -250
- package/bundle/references/cli/capability-tool-classification.yaml +0 -53
- package/bundle/references/cli/coexistence-probe.yaml +0 -9
- package/bundle/references/cli/routing-execution-vocabulary.yaml +0 -281
- package/bundle/references/cli/single-name-protocol.yaml +0 -42
- package/bundle/references/cli/upgrade-repair-wording.md +0 -31
- package/bundle/references/cli/v3-handoff-manifest.schema.yaml +0 -98
- package/bundle/references/meta/documentation-inventory.md +0 -49
- package/bundle/skills/agentera/.claude-plugin/plugin.json +0 -27
- package/bundle/skills/agentera/agents/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/dist/analytics/extractCorpus/cli.js.map +0 -1
- package/dist/analytics/extractCorpus/copilotSessions.js.map +0 -1
- package/dist/analytics/extractCorpus/core.js.map +0 -1
- package/dist/analytics/extractCorpus/corpus.js.map +0 -1
- package/dist/analytics/extractCorpus/cursorSessions.js.map +0 -1
- package/dist/analytics/extractCorpus/filesystemSources.js.map +0 -1
- package/dist/analytics/extractCorpus/index.js.map +0 -1
- package/dist/analytics/extractCorpus/jsonlSessions.js.map +0 -1
- package/dist/analytics/extractCorpus/sqliteSessions.js.map +0 -1
- package/dist/analytics/extractCorpus.js.map +0 -1
- package/dist/analytics/usageStats.js.map +0 -1
- package/dist/bin/agentera.js.map +0 -1
- package/dist/capabilities/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/benchmark.js.map +0 -1
- package/dist/cli/capabilityContext/bespoke.js.map +0 -1
- package/dist/cli/capabilityContext/closeout.js.map +0 -1
- package/dist/cli/capabilityContext/contract.js.map +0 -1
- package/dist/cli/capabilityContext/evidence.js.map +0 -1
- package/dist/cli/capabilityContext/index.js.map +0 -1
- package/dist/cli/capabilityContext/orchestration.js.map +0 -1
- package/dist/cli/capabilityContext/planState.js.map +0 -1
- package/dist/cli/capabilityContext/progress.js.map +0 -1
- package/dist/cli/capabilityContext/realisera.js +0 -174
- package/dist/cli/capabilityContext/realisera.js.map +0 -1
- package/dist/cli/capabilityContext/shared.js.map +0 -1
- package/dist/cli/capabilityContext/slim.js.map +0 -1
- package/dist/cli/capabilityContext/startup.js.map +0 -1
- package/dist/cli/capabilityContext/types.js.map +0 -1
- package/dist/cli/capabilityContext.js.map +0 -1
- package/dist/cli/commands/backfill.js +0 -84
- package/dist/cli/commands/backfill.js.map +0 -1
- package/dist/cli/commands/capability.js.map +0 -1
- package/dist/cli/commands/compact.js.map +0 -1
- package/dist/cli/commands/doctor.js.map +0 -1
- package/dist/cli/commands/lint.js.map +0 -1
- package/dist/cli/commands/prime.js.map +0 -1
- package/dist/cli/commands/query.js.map +0 -1
- package/dist/cli/commands/report.js.map +0 -1
- package/dist/cli/commands/schema.js.map +0 -1
- package/dist/cli/commands/state/decisions.js.map +0 -1
- package/dist/cli/commands/state/docs.js.map +0 -1
- package/dist/cli/commands/state/experiments.js.map +0 -1
- package/dist/cli/commands/state/health.js.map +0 -1
- package/dist/cli/commands/state/index.js.map +0 -1
- package/dist/cli/commands/state/objective.js.map +0 -1
- package/dist/cli/commands/state/plan.js.map +0 -1
- package/dist/cli/commands/state/progress.js.map +0 -1
- package/dist/cli/commands/state/shared.js.map +0 -1
- package/dist/cli/commands/state/todo.js.map +0 -1
- package/dist/cli/commands/state.js +0 -1023
- package/dist/cli/commands/state.js.map +0 -1
- package/dist/cli/commands/upgrade.js.map +0 -1
- package/dist/cli/commands/validate.js.map +0 -1
- package/dist/cli/commands/verify.js.map +0 -1
- package/dist/cli/dispatch/check.js.map +0 -1
- package/dist/cli/dispatch/index.js.map +0 -1
- package/dist/cli/dispatch/lifecycle.js.map +0 -1
- package/dist/cli/dispatch/prime.js.map +0 -1
- package/dist/cli/dispatch/shared.js.map +0 -1
- package/dist/cli/dispatch/state.js.map +0 -1
- package/dist/cli/dispatch.js.map +0 -1
- package/dist/cli/errors.js.map +0 -1
- package/dist/cli/help.js.map +0 -1
- package/dist/cli/orientation.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/git.js +0 -43
- package/dist/core/git.js.map +0 -1
- package/dist/core/paths.js.map +0 -1
- package/dist/core/pyjson.js.map +0 -1
- package/dist/core/sourceRoot.js.map +0 -1
- package/dist/core/toml.js.map +0 -1
- package/dist/core/yaml.js.map +0 -1
- package/dist/eval/evalSkills.js.map +0 -1
- package/dist/eval/semanticEval.js.map +0 -1
- package/dist/eval/semanticFixtures.js.map +0 -1
- package/dist/hooks/common.js.map +0 -1
- package/dist/hooks/compaction/apply.js.map +0 -1
- package/dist/hooks/compaction/dryRun.js.map +0 -1
- package/dist/hooks/compaction/index.js.map +0 -1
- package/dist/hooks/compaction/parse.js.map +0 -1
- package/dist/hooks/compaction/retention.js.map +0 -1
- package/dist/hooks/compaction/status.js.map +0 -1
- package/dist/hooks/compaction/types.js.map +0 -1
- package/dist/hooks/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 -203
- package/dist/hooks/sessionStop.js.map +0 -1
- package/dist/hooks/validateArtifact/agentFacing.js.map +0 -1
- package/dist/hooks/validateArtifact/index.js.map +0 -1
- package/dist/hooks/validateArtifact/markdown.js.map +0 -1
- package/dist/hooks/validateArtifact/runtime.js +0 -83
- package/dist/hooks/validateArtifact/runtime.js.map +0 -1
- package/dist/hooks/validateArtifact/schema.js.map +0 -1
- package/dist/hooks/validateArtifact/traversal.js.map +0 -1
- package/dist/hooks/validateArtifact/violations.js.map +0 -1
- package/dist/hooks/validateArtifact.js +0 -924
- package/dist/hooks/validateArtifact.js.map +0 -1
- package/dist/migrate/v2HandoffManifest.js.map +0 -1
- package/dist/registries/artifactProtocolIds.js.map +0 -1
- package/dist/registries/artifactRegistry.js.map +0 -1
- package/dist/registries/capabilityContract.js.map +0 -1
- package/dist/registries/evaluatorHandoffContract.js.map +0 -1
- package/dist/registries/packageRegistry.js.map +0 -1
- package/dist/registries/runtimeAdapterRegistry.js +0 -315
- package/dist/registries/runtimeAdapterRegistry.js.map +0 -1
- package/dist/release/releaseMetadata.js.map +0 -1
- package/dist/setup/codex/agents.js +0 -96
- package/dist/setup/codex/agents.js.map +0 -1
- package/dist/setup/codex/cli.js +0 -161
- package/dist/setup/codex/cli.js.map +0 -1
- package/dist/setup/codex/configToml.js +0 -644
- package/dist/setup/codex/configToml.js.map +0 -1
- package/dist/setup/codex/constants.js +0 -29
- package/dist/setup/codex/constants.js.map +0 -1
- package/dist/setup/codex/installRoot.js +0 -64
- package/dist/setup/codex/installRoot.js.map +0 -1
- package/dist/setup/codex/state.js +0 -270
- package/dist/setup/codex/state.js.map +0 -1
- package/dist/setup/codex.js +0 -12
- package/dist/setup/codex.js.map +0 -1
- package/dist/setup/copilot.js +0 -227
- package/dist/setup/copilot.js.map +0 -1
- package/dist/setup/cursor.js +0 -127
- package/dist/setup/cursor.js.map +0 -1
- package/dist/setup/doctor/core.js +0 -300
- package/dist/setup/doctor/core.js.map +0 -1
- package/dist/setup/doctor/diagnostics.js +0 -247
- package/dist/setup/doctor/diagnostics.js.map +0 -1
- package/dist/setup/doctor/opencode.js +0 -281
- package/dist/setup/doctor/opencode.js.map +0 -1
- package/dist/setup/doctor/report.js +0 -474
- package/dist/setup/doctor/report.js.map +0 -1
- package/dist/setup/doctor.js +0 -10
- package/dist/setup/doctor.js.map +0 -1
- package/dist/setup/opencode.js.map +0 -1
- package/dist/setup/smokeChecks.js.map +0 -1
- package/dist/state/installRoot.js.map +0 -1
- package/dist/state/progressCommit.js +0 -289
- package/dist/state/progressCommit.js.map +0 -1
- package/dist/state/startupAnalysis/benchmark.js.map +0 -1
- package/dist/state/startupAnalysis/contract.js.map +0 -1
- package/dist/state/startupAnalysis/helpers.js.map +0 -1
- package/dist/state/startupAnalysis/index.js.map +0 -1
- package/dist/state/startupAnalysis/metrics.js.map +0 -1
- package/dist/state/startupAnalysis/records.js.map +0 -1
- package/dist/state/startupAnalysis/report.js.map +0 -1
- package/dist/state/startupAnalysis/threshold.js.map +0 -1
- package/dist/state/startupAnalysis.js.map +0 -1
- package/dist/upgrade/appModel.js.map +0 -1
- package/dist/upgrade/channels.js.map +0 -1
- package/dist/upgrade/coexistenceProbe.js +0 -83
- package/dist/upgrade/coexistenceProbe.js.map +0 -1
- package/dist/upgrade/compatibility.js.map +0 -1
- package/dist/upgrade/doctor.js.map +0 -1
- package/dist/upgrade/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/v3CapabilitySurface.js.map +0 -1
- package/dist/upgrade/versionResolution.js.map +0 -1
- package/dist/validate/appHomeContract.js.map +0 -1
- package/dist/validate/capability.js.map +0 -1
- package/dist/validate/crossCapability.js.map +0 -1
- package/dist/validate/lifecycleAdapters.js +0 -772
- package/dist/validate/lifecycleAdapters.js.map +0 -1
- package/dist/validate/selfAudit.js.map +0 -1
- package/dist/validate/vocabularyAuthority.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
|
@@ -1,25 +1,10 @@
|
|
|
1
|
-
|
|
2
|
-
|
|
3
|
-
|
|
4
|
-
|
|
5
|
-
|
|
6
|
-
|
|
7
|
-
|
|
8
|
-
*/
|
|
9
|
-
import fs from "node:fs";
|
|
10
|
-
import { emitStateStructured, extractEntries, filterByFieldValue, formatEntry, loadArtifact, printStatusCounts, sourceMetadata, statusCounts, structuredState, } from "../../stateQuery.js";
|
|
11
|
-
import { artifactPath } from "../../appContext.js";
|
|
12
|
-
import { isResolvedTodoMarkdownStatus, parseTodoMarkdownListItem } from "../../todoMarkdown.js";
|
|
13
|
-
import { out, err } from "./shared.js";
|
|
14
|
-
const TODO_SEVERITY_ORDER_KEYS = ["critical", "degraded", "warning", "normal", "info", "annoying"];
|
|
15
|
-
const TODO_SEV_GLYPHS = {
|
|
16
|
-
critical: "⇶",
|
|
17
|
-
degraded: "⇉",
|
|
18
|
-
warning: "⇉",
|
|
19
|
-
normal: "→",
|
|
20
|
-
info: "⇢",
|
|
21
|
-
annoying: "⇢",
|
|
22
|
-
};
|
|
1
|
+
import { emitStructured } from "../../structured.js";
|
|
2
|
+
import { TODO_SEVERITY_ORDER_KEYS } from "../../todoSeverity.js";
|
|
3
|
+
import { renderTodoPublicRecord } from "../../todoMarkdown.js";
|
|
4
|
+
import { StateRetrievalFailure } from "../../../state/directRetrieval.js";
|
|
5
|
+
import { listTodoDocsEntities } from "../../../state/todoDocsEntities.js";
|
|
6
|
+
import YAML from "yaml";
|
|
7
|
+
import { err, out } from "./shared.js";
|
|
23
8
|
export function normalizeSeverity(value, deflt = "normal") {
|
|
24
9
|
const text = String(value || deflt).toLowerCase();
|
|
25
10
|
for (const key of TODO_SEVERITY_ORDER_KEYS) {
|
|
@@ -28,94 +13,30 @@ export function normalizeSeverity(value, deflt = "normal") {
|
|
|
28
13
|
}
|
|
29
14
|
return deflt;
|
|
30
15
|
}
|
|
31
|
-
export function queryTodo(args,
|
|
32
|
-
const
|
|
33
|
-
const info = schemas.todo ?? { path: "TODO.md", record: undefined, schema: {}, fields: {} };
|
|
34
|
-
const todoPath = artifactPath(info, "todo");
|
|
35
|
-
const severity = args.severity ?? null;
|
|
36
|
-
const status = args.status ?? null;
|
|
16
|
+
export function queryTodo(args, _schemas, io, openOnly = false) {
|
|
17
|
+
const output = out(io);
|
|
37
18
|
const format = args.format ?? "text";
|
|
38
|
-
|
|
39
|
-
|
|
40
|
-
|
|
41
|
-
|
|
42
|
-
|
|
43
|
-
}
|
|
44
|
-
|
|
45
|
-
|
|
46
|
-
|
|
47
|
-
|
|
48
|
-
|
|
49
|
-
if (severity)
|
|
50
|
-
entries = filterByFieldValue(entries, "severity", severity);
|
|
51
|
-
if (status)
|
|
52
|
-
entries = filterByFieldValue(entries, "status", status);
|
|
53
|
-
if (openOnly) {
|
|
54
|
-
entries = entries.filter((entry) => !["done", "closed", "resolved"].includes(String(entry.status ?? "open").toLowerCase()));
|
|
55
|
-
}
|
|
56
|
-
if (format !== "text") {
|
|
57
|
-
return emitStateStructured("todo", structuredState("todo", entries, sourceMetadata("todo", todoPath), {
|
|
58
|
-
filters: { severity, status, open_only: openOnly || null },
|
|
59
|
-
}), format, args.fields, o, err(io));
|
|
60
|
-
}
|
|
61
|
-
printStatusCounts("TODO status", statusCounts(entries), o);
|
|
62
|
-
for (const entry of entries) {
|
|
63
|
-
const line = formatEntry(entry, ["severity", "status", "description", "title"]);
|
|
64
|
-
if (line)
|
|
65
|
-
o(line + "\n");
|
|
66
|
-
}
|
|
67
|
-
return 0;
|
|
68
|
-
}
|
|
69
|
-
const text = fs.readFileSync(todoPath, "utf8");
|
|
70
|
-
const marker = severity ? TODO_SEV_GLYPHS[severity.toLowerCase()] ?? severity : null;
|
|
71
|
-
let currentSection = null;
|
|
72
|
-
const markdownEntries = [];
|
|
73
|
-
for (const rawLine of text.split(/\r\n|\r|\n/)) {
|
|
74
|
-
const sline = rawLine.trim();
|
|
75
|
-
if (sline.startsWith("## ")) {
|
|
76
|
-
const section = sline.slice(3).trim();
|
|
77
|
-
if (section.toLowerCase().includes("resolved")) {
|
|
78
|
-
currentSection = null;
|
|
79
|
-
continue;
|
|
19
|
+
try {
|
|
20
|
+
const response = listTodoDocsEntities(process.cwd(), "todo", args.limit ?? undefined, undefined, {
|
|
21
|
+
...(args.severity ? { severity: args.severity } : {}),
|
|
22
|
+
...(args.status ? { status: args.status } : {}),
|
|
23
|
+
...(openOnly ? { status: "open" } : {}),
|
|
24
|
+
}, { format });
|
|
25
|
+
if (format === "json" || format === "yaml")
|
|
26
|
+
emitStructured(response, format, output);
|
|
27
|
+
else
|
|
28
|
+
for (const entry of response.entries) {
|
|
29
|
+
output(`[${entry.record.severity}] ${entry.id} ${entry.record.status}: ${renderTodoPublicRecord(entry.record)}\n`);
|
|
80
30
|
}
|
|
81
|
-
|
|
82
|
-
continue;
|
|
83
|
-
}
|
|
84
|
-
if (currentSection === null)
|
|
85
|
-
continue;
|
|
86
|
-
const parsed = parseTodoMarkdownListItem(sline);
|
|
87
|
-
if (!parsed)
|
|
88
|
-
continue;
|
|
89
|
-
if (marker && !currentSection.includes(marker))
|
|
90
|
-
continue;
|
|
91
|
-
const itemStatus = parsed.status;
|
|
92
|
-
if (openOnly && isResolvedTodoMarkdownStatus(itemStatus))
|
|
93
|
-
continue;
|
|
94
|
-
if (status) {
|
|
95
|
-
const want = status.toLowerCase();
|
|
96
|
-
const have = itemStatus.toLowerCase();
|
|
97
|
-
if (want === "open" || want === "todo") {
|
|
98
|
-
if (isResolvedTodoMarkdownStatus(have))
|
|
99
|
-
continue;
|
|
100
|
-
}
|
|
101
|
-
else if (have !== want) {
|
|
102
|
-
continue;
|
|
103
|
-
}
|
|
104
|
-
}
|
|
105
|
-
markdownEntries.push({
|
|
106
|
-
severity: normalizeSeverity(currentSection),
|
|
107
|
-
status: itemStatus,
|
|
108
|
-
description: parsed.description,
|
|
109
|
-
section: currentSection,
|
|
110
|
-
});
|
|
111
|
-
if (format === "text")
|
|
112
|
-
o(`[${currentSection}] ${parsed.description}\n`);
|
|
31
|
+
return 0;
|
|
113
32
|
}
|
|
114
|
-
|
|
115
|
-
|
|
116
|
-
|
|
117
|
-
|
|
33
|
+
catch (error) {
|
|
34
|
+
if (!(error instanceof StateRetrievalFailure))
|
|
35
|
+
throw error;
|
|
36
|
+
if (format === "json" || format === "yaml")
|
|
37
|
+
emitStructured(error.body, format, output);
|
|
38
|
+
else
|
|
39
|
+
err(io)(YAML.stringify(error.body));
|
|
40
|
+
return error.exitCode;
|
|
118
41
|
}
|
|
119
|
-
return 0;
|
|
120
42
|
}
|
|
121
|
-
//# sourceMappingURL=todo.js.map
|
|
@@ -0,0 +1,433 @@
|
|
|
1
|
+
import path from "node:path";
|
|
2
|
+
import fs from "node:fs";
|
|
3
|
+
import { emitInvalidInput } from "../../errors.js";
|
|
4
|
+
import { emitStructured } from "../../structured.js";
|
|
5
|
+
import { StateRetrievalFailure } from "../../../state/directRetrieval.js";
|
|
6
|
+
import { normalizeArtifactProtocolId, VALIDATE_ARTIFACT_PROTOCOL_IDS, } from "../../../registries/artifactProtocolIds.js";
|
|
7
|
+
import { buildExplain, buildExplainAll, assertMutationGrammarParity, exampleFor, executeStateWrite, isWritableArtifact, loadStructuredInput, operationSpec, projectedFields, renderExplainText, StateWriteInputError, verbsForArtifact, WRITABLE_ARTIFACTS, } from "../../../state/write/index.js";
|
|
8
|
+
function formatFromArgv(argv) {
|
|
9
|
+
for (let i = 0; i < argv.length; i++) {
|
|
10
|
+
if (argv[i] === "--format" && argv[i + 1] === "json")
|
|
11
|
+
return "json";
|
|
12
|
+
if (argv[i] === "--format=json")
|
|
13
|
+
return "json";
|
|
14
|
+
}
|
|
15
|
+
return "text";
|
|
16
|
+
}
|
|
17
|
+
function invalid(body) {
|
|
18
|
+
throw new StateWriteInputError(body);
|
|
19
|
+
}
|
|
20
|
+
function emitRetrievalFailure(error, format, io) {
|
|
21
|
+
if (format === "json") {
|
|
22
|
+
emitStructured(error.body, "json", io.out ?? ((text) => process.stdout.write(text)));
|
|
23
|
+
}
|
|
24
|
+
else {
|
|
25
|
+
const detail = error.body.error;
|
|
26
|
+
(io.err ?? ((text) => process.stderr.write(text)))([
|
|
27
|
+
`Error: ${detail.message}`,
|
|
28
|
+
`Syntax: ${detail.syntax}`,
|
|
29
|
+
`Example: ${detail.example}`,
|
|
30
|
+
`Recovery: ${detail.recovery}`,
|
|
31
|
+
].join("\n") + "\n");
|
|
32
|
+
}
|
|
33
|
+
return error.exitCode;
|
|
34
|
+
}
|
|
35
|
+
function setNested(target, field, value) {
|
|
36
|
+
const parts = field.split(".");
|
|
37
|
+
let cursor = target;
|
|
38
|
+
for (const part of parts.slice(0, -1)) {
|
|
39
|
+
if (!cursor[part] || typeof cursor[part] !== "object" || Array.isArray(cursor[part]))
|
|
40
|
+
cursor[part] = {};
|
|
41
|
+
cursor = cursor[part];
|
|
42
|
+
}
|
|
43
|
+
cursor[parts.at(-1)] = value;
|
|
44
|
+
}
|
|
45
|
+
function hasNested(target, field) {
|
|
46
|
+
let value = target;
|
|
47
|
+
for (const part of field.split(".")) {
|
|
48
|
+
if (!value || typeof value !== "object" || Array.isArray(value))
|
|
49
|
+
return false;
|
|
50
|
+
if (!(part in value))
|
|
51
|
+
return false;
|
|
52
|
+
value = value[part];
|
|
53
|
+
}
|
|
54
|
+
return true;
|
|
55
|
+
}
|
|
56
|
+
function readFlag(argv, index) {
|
|
57
|
+
const token = argv[index];
|
|
58
|
+
const equals = token.indexOf("=");
|
|
59
|
+
if (equals > 0)
|
|
60
|
+
return { name: token.slice(0, equals), value: token.slice(equals + 1), consumed: 1 };
|
|
61
|
+
return { name: token, value: argv[index + 1] ?? null, consumed: 2 };
|
|
62
|
+
}
|
|
63
|
+
function converted(field, raw) {
|
|
64
|
+
if (field.kind === "boolean") {
|
|
65
|
+
if (raw !== "true" && raw !== "false")
|
|
66
|
+
invalid({
|
|
67
|
+
class: "invalid_choice",
|
|
68
|
+
message: `argument ${field.flag}: expected true or false, got '${raw}'`,
|
|
69
|
+
valid_values: ["true", "false"],
|
|
70
|
+
});
|
|
71
|
+
return raw === "true";
|
|
72
|
+
}
|
|
73
|
+
if (field.kind === "integer") {
|
|
74
|
+
const number = Number(raw);
|
|
75
|
+
if (!Number.isInteger(number))
|
|
76
|
+
invalid({
|
|
77
|
+
class: "invalid_int",
|
|
78
|
+
message: `argument ${field.flag}: invalid int value: '${raw}'`,
|
|
79
|
+
syntax: `${field.flag} N`,
|
|
80
|
+
});
|
|
81
|
+
return number;
|
|
82
|
+
}
|
|
83
|
+
if (field.kind === "date" && !/^\d{4}-\d{2}-\d{2}$/.test(raw)) {
|
|
84
|
+
invalid({
|
|
85
|
+
class: "invalid_format",
|
|
86
|
+
message: `argument ${field.flag}: expected YYYY-MM-DD, got '${raw}'`,
|
|
87
|
+
syntax: `${field.flag} YYYY-MM-DD`,
|
|
88
|
+
});
|
|
89
|
+
}
|
|
90
|
+
if (field.kind === "datetime" && !/^\d{4}-\d{2}-\d{2} \d{2}:\d{2}$/.test(raw)) {
|
|
91
|
+
invalid({
|
|
92
|
+
class: "invalid_format",
|
|
93
|
+
message: `argument ${field.flag}: expected YYYY-MM-DD HH:MM, got '${raw}'`,
|
|
94
|
+
syntax: `${field.flag} "YYYY-MM-DD HH:MM"`,
|
|
95
|
+
});
|
|
96
|
+
}
|
|
97
|
+
if (field.validValues && !field.validValues.includes(raw)) {
|
|
98
|
+
const privacySafe = field.field.startsWith("glossary_caveat.");
|
|
99
|
+
invalid({
|
|
100
|
+
class: "invalid_choice",
|
|
101
|
+
message: privacySafe
|
|
102
|
+
? `argument ${field.flag}: invalid bounded glossary caveat value`
|
|
103
|
+
: `argument ${field.flag}: invalid choice: '${raw}' (choose from ${field.validValues.map((v) => `'${v}'`).join(", ")})`,
|
|
104
|
+
valid_values: field.validValues,
|
|
105
|
+
});
|
|
106
|
+
}
|
|
107
|
+
return raw;
|
|
108
|
+
}
|
|
109
|
+
function artifactOrReject(raw) {
|
|
110
|
+
const normalized = normalizeArtifactProtocolId(raw);
|
|
111
|
+
if (normalized === null) {
|
|
112
|
+
invalid({
|
|
113
|
+
class: "unsupported_target",
|
|
114
|
+
message: `unsupported artifact "${raw}"; valid artifact_id values: ${VALIDATE_ARTIFACT_PROTOCOL_IDS.join(", ")}`,
|
|
115
|
+
valid_values: [...WRITABLE_ARTIFACTS],
|
|
116
|
+
});
|
|
117
|
+
}
|
|
118
|
+
if (!isWritableArtifact(normalized)) {
|
|
119
|
+
invalid({
|
|
120
|
+
class: "unsupported_target",
|
|
121
|
+
message: `artifact "${normalized}" is read-only through the state writer`,
|
|
122
|
+
valid_values: [...WRITABLE_ARTIFACTS],
|
|
123
|
+
example: "agentera state progress append --input progress.yaml --format json",
|
|
124
|
+
});
|
|
125
|
+
}
|
|
126
|
+
return normalized;
|
|
127
|
+
}
|
|
128
|
+
function specOrReject(artifact, verb) {
|
|
129
|
+
const spec = operationSpec(artifact, verb);
|
|
130
|
+
if (!spec) {
|
|
131
|
+
const retrievalVerbs = artifact === "plan" ? ["list", "get", "tasks"] : artifact === "experiments" ? ["list", "get"] : [];
|
|
132
|
+
invalid({
|
|
133
|
+
class: "invalid_choice",
|
|
134
|
+
message: `verb "${verb}" does not apply to ${artifact}`,
|
|
135
|
+
valid_values: [...retrievalVerbs, ...verbsForArtifact(artifact)],
|
|
136
|
+
example: artifact === "experiments"
|
|
137
|
+
? "agentera state experiments list --objective OBJECTIVE_ID --format json"
|
|
138
|
+
: `agentera state ${artifact} ${artifact === "plan" ? "list --format json" : "explain --format json"}`,
|
|
139
|
+
});
|
|
140
|
+
}
|
|
141
|
+
return spec;
|
|
142
|
+
}
|
|
143
|
+
function parseWrite(artifactRaw, argv) {
|
|
144
|
+
const artifact = artifactOrReject(artifactRaw);
|
|
145
|
+
const verb = argv[0];
|
|
146
|
+
if (!verb)
|
|
147
|
+
invalid({
|
|
148
|
+
class: "missing_argument",
|
|
149
|
+
message: `write verb is required for ${artifact}`,
|
|
150
|
+
valid_values: verbsForArtifact(artifact),
|
|
151
|
+
});
|
|
152
|
+
const spec = specOrReject(artifact, verb);
|
|
153
|
+
let initialProjectRoot = process.cwd();
|
|
154
|
+
for (let index = 1; index < argv.length; index += 1) {
|
|
155
|
+
const token = argv[index];
|
|
156
|
+
if (token === "--project" && argv[index + 1])
|
|
157
|
+
initialProjectRoot = path.resolve(argv[index + 1]);
|
|
158
|
+
else if (token.startsWith("--project="))
|
|
159
|
+
initialProjectRoot = path.resolve(token.slice("--project=".length));
|
|
160
|
+
}
|
|
161
|
+
const fields = projectedFields(spec);
|
|
162
|
+
const byFlag = new Map(fields.map((field) => [field.flag, field]));
|
|
163
|
+
const values = {};
|
|
164
|
+
const callerPayload = {};
|
|
165
|
+
const occurrences = new Map();
|
|
166
|
+
let format = "text";
|
|
167
|
+
let projectRoot = initialProjectRoot;
|
|
168
|
+
let dryRun = false;
|
|
169
|
+
let force = false;
|
|
170
|
+
let inputSource = null;
|
|
171
|
+
for (let i = 1; i < argv.length;) {
|
|
172
|
+
const token = argv[i];
|
|
173
|
+
if (!token.startsWith("--"))
|
|
174
|
+
invalid({ class: "unrecognized_argument", message: `unrecognized arguments: ${token}` });
|
|
175
|
+
if (token === "--dry-run") {
|
|
176
|
+
dryRun = true;
|
|
177
|
+
i += 1;
|
|
178
|
+
continue;
|
|
179
|
+
}
|
|
180
|
+
if (token === "--force") {
|
|
181
|
+
force = true;
|
|
182
|
+
i += 1;
|
|
183
|
+
continue;
|
|
184
|
+
}
|
|
185
|
+
const bareBoolean = byFlag.get(token);
|
|
186
|
+
if (bareBoolean?.kind === "boolean") {
|
|
187
|
+
if ((occurrences.get(token) ?? 0) > 0)
|
|
188
|
+
invalid({ class: "mutually_exclusive", message: `${token} may only be supplied once` });
|
|
189
|
+
occurrences.set(token, 1);
|
|
190
|
+
setNested(values, bareBoolean.field, true);
|
|
191
|
+
setNested(callerPayload, bareBoolean.field, true);
|
|
192
|
+
i += 1;
|
|
193
|
+
continue;
|
|
194
|
+
}
|
|
195
|
+
const parsed = readFlag(argv, i);
|
|
196
|
+
if (parsed.value === null || parsed.value.startsWith("--"))
|
|
197
|
+
invalid({
|
|
198
|
+
class: "missing_argument",
|
|
199
|
+
message: `${parsed.name} requires a value`,
|
|
200
|
+
syntax: `${parsed.name} VALUE`,
|
|
201
|
+
});
|
|
202
|
+
i += parsed.consumed;
|
|
203
|
+
if (parsed.name === "--format") {
|
|
204
|
+
if (parsed.value !== "text" && parsed.value !== "json")
|
|
205
|
+
invalid({
|
|
206
|
+
class: "invalid_choice",
|
|
207
|
+
message: `argument --format: invalid choice: '${parsed.value}' (choose from 'text', 'json')`,
|
|
208
|
+
valid_values: ["text", "json"],
|
|
209
|
+
});
|
|
210
|
+
format = parsed.value;
|
|
211
|
+
continue;
|
|
212
|
+
}
|
|
213
|
+
if (parsed.name === "--project") {
|
|
214
|
+
projectRoot = path.resolve(parsed.value);
|
|
215
|
+
continue;
|
|
216
|
+
}
|
|
217
|
+
if (parsed.name === "--input") {
|
|
218
|
+
if (inputSource !== null)
|
|
219
|
+
invalid({ class: "mutually_exclusive", message: "--input may only be supplied once" });
|
|
220
|
+
inputSource = parsed.value;
|
|
221
|
+
continue;
|
|
222
|
+
}
|
|
223
|
+
if (artifact === "decisions" && verb === "append" && parsed.name === "--number") {
|
|
224
|
+
invalid({
|
|
225
|
+
class: "unrecognized_argument",
|
|
226
|
+
message: "--number is assigned by the CLI on append and cannot be supplied",
|
|
227
|
+
example: exampleFor(artifact, verb),
|
|
228
|
+
});
|
|
229
|
+
}
|
|
230
|
+
const field = byFlag.get(parsed.name);
|
|
231
|
+
if (!field) {
|
|
232
|
+
if (spec.inputRoot && inputSource)
|
|
233
|
+
invalid({
|
|
234
|
+
class: "mutually_exclusive",
|
|
235
|
+
message: `--input cannot be combined with ${parsed.name}`,
|
|
236
|
+
syntax: "--input PATH",
|
|
237
|
+
example: exampleFor(artifact, verb),
|
|
238
|
+
});
|
|
239
|
+
invalid({
|
|
240
|
+
class: "unrecognized_argument",
|
|
241
|
+
message: `unrecognized arguments: ${parsed.name}`,
|
|
242
|
+
example: exampleFor(artifact, verb),
|
|
243
|
+
});
|
|
244
|
+
}
|
|
245
|
+
const count = (occurrences.get(parsed.name) ?? 0) + 1;
|
|
246
|
+
occurrences.set(parsed.name, count);
|
|
247
|
+
if (!field.repeatable && count > 1) {
|
|
248
|
+
const message = parsed.name === "--alternative-chosen"
|
|
249
|
+
? `exactly one alternative must be chosen (DV3); received ${count} --alternative-chosen flags`
|
|
250
|
+
: `${parsed.name} may only be supplied once`;
|
|
251
|
+
invalid({ class: "mutually_exclusive", message });
|
|
252
|
+
}
|
|
253
|
+
const value = converted(field, parsed.value);
|
|
254
|
+
if (field.repeatable) {
|
|
255
|
+
const current = mappingPath(values, field.field) ?? [];
|
|
256
|
+
setNested(values, field.field, [...current, value]);
|
|
257
|
+
setNested(callerPayload, field.field, [...current, value]);
|
|
258
|
+
}
|
|
259
|
+
else {
|
|
260
|
+
setNested(values, field.field, value);
|
|
261
|
+
setNested(callerPayload, field.field, value);
|
|
262
|
+
}
|
|
263
|
+
}
|
|
264
|
+
if (force && !spec.allowForce)
|
|
265
|
+
invalid({
|
|
266
|
+
class: "unrecognized_argument",
|
|
267
|
+
message: `--force does not apply to ${artifact} ${verb}`,
|
|
268
|
+
});
|
|
269
|
+
if (inputSource && !spec.inputRoot)
|
|
270
|
+
invalid({
|
|
271
|
+
class: "mutually_exclusive",
|
|
272
|
+
message: `${artifact} ${verb} accepts field flags, not --input`,
|
|
273
|
+
example: exampleFor(artifact, verb),
|
|
274
|
+
});
|
|
275
|
+
if (spec.inputRoot && !inputSource && !spec.inputOptional)
|
|
276
|
+
invalid({
|
|
277
|
+
class: "missing_argument",
|
|
278
|
+
message: `--input is required for ${artifact} ${verb}`,
|
|
279
|
+
syntax: "--input PATH",
|
|
280
|
+
example: exampleFor(artifact, verb),
|
|
281
|
+
});
|
|
282
|
+
const selectorFields = new Set(spec.fields.filter((field) => spec.selectors.includes(field.flag)).map((field) => field.field));
|
|
283
|
+
const correctionApplyFields = artifact === "todo" && verb === "correct-owners"
|
|
284
|
+
? new Set(["effect_sha256", "confirmed"])
|
|
285
|
+
: new Set();
|
|
286
|
+
if (spec.inputRoot && Object.keys(values).some((field) => !selectorFields.has(field) && !correctionApplyFields.has(field)))
|
|
287
|
+
invalid({
|
|
288
|
+
class: "mutually_exclusive",
|
|
289
|
+
message: `--input cannot be combined with field flags for ${artifact} ${verb}`,
|
|
290
|
+
});
|
|
291
|
+
for (const field of fields.filter((candidate) => candidate.required)) {
|
|
292
|
+
if (mappingPath(values, field.field) === undefined) {
|
|
293
|
+
invalid({
|
|
294
|
+
class: "missing_argument",
|
|
295
|
+
message: `${field.flag} is required for ${artifact} ${verb}`,
|
|
296
|
+
valid_values: field.validValues,
|
|
297
|
+
syntax: `${field.flag} VALUE`,
|
|
298
|
+
example: exampleFor(artifact, verb),
|
|
299
|
+
});
|
|
300
|
+
}
|
|
301
|
+
}
|
|
302
|
+
if (artifact === "decisions" && (verb === "update" || verb === "amend")) {
|
|
303
|
+
const id = mappingPath(values, "id");
|
|
304
|
+
const number = mappingPath(values, "number");
|
|
305
|
+
if (number !== undefined)
|
|
306
|
+
invalid({ class: "unrecognized_argument", message: "numeric decision selectors are unavailable in entity mode; use --id ID" });
|
|
307
|
+
if (id === undefined)
|
|
308
|
+
invalid({ class: "missing_argument", message: `--id is required for decisions ${verb} in entity mode` });
|
|
309
|
+
if (verb === "amend" && mappingPath(values, "base_sha256") === undefined)
|
|
310
|
+
invalid({ class: "missing_argument", message: "--base-sha256 is required for decisions amend in entity mode" });
|
|
311
|
+
}
|
|
312
|
+
if (artifact === "plan" && verb !== "create") {
|
|
313
|
+
const taskVerb = ["update", "set-status", "supersede", "record-evaluation"].includes(verb);
|
|
314
|
+
const id = mappingPath(values, "id");
|
|
315
|
+
if (taskVerb && id === undefined)
|
|
316
|
+
invalid({ class: "missing_argument", message: `--id is required for plan ${verb} in entity mode` });
|
|
317
|
+
}
|
|
318
|
+
return { artifact, spec, format, projectRoot, dryRun, force, values, callerPayload, inputSource };
|
|
319
|
+
}
|
|
320
|
+
function mappingPath(entry, field) {
|
|
321
|
+
let value = entry;
|
|
322
|
+
for (const part of field.split(".")) {
|
|
323
|
+
if (!value || typeof value !== "object" || Array.isArray(value))
|
|
324
|
+
return undefined;
|
|
325
|
+
value = value[part];
|
|
326
|
+
}
|
|
327
|
+
return value;
|
|
328
|
+
}
|
|
329
|
+
function explainArgs(argv) {
|
|
330
|
+
let format = "text";
|
|
331
|
+
let project = process.cwd();
|
|
332
|
+
let verb = null;
|
|
333
|
+
let all = false;
|
|
334
|
+
for (let i = 1; i < argv.length;) {
|
|
335
|
+
if (argv[i] === "--all") {
|
|
336
|
+
all = true;
|
|
337
|
+
i += 1;
|
|
338
|
+
continue;
|
|
339
|
+
}
|
|
340
|
+
const parsed = readFlag(argv, i);
|
|
341
|
+
if (parsed.value === null || parsed.value.startsWith("--"))
|
|
342
|
+
invalid({ class: "missing_argument", message: `${parsed.name} requires a value` });
|
|
343
|
+
i += parsed.consumed;
|
|
344
|
+
if (parsed.name === "--format") {
|
|
345
|
+
if (parsed.value !== "text" && parsed.value !== "json")
|
|
346
|
+
invalid({
|
|
347
|
+
class: "invalid_choice",
|
|
348
|
+
message: `argument --format: invalid choice: '${parsed.value}' (choose from 'text', 'json')`,
|
|
349
|
+
valid_values: ["text", "json"],
|
|
350
|
+
});
|
|
351
|
+
format = parsed.value;
|
|
352
|
+
}
|
|
353
|
+
else if (parsed.name === "--project")
|
|
354
|
+
project = path.resolve(parsed.value);
|
|
355
|
+
else if (parsed.name === "--verb")
|
|
356
|
+
verb = parsed.value;
|
|
357
|
+
else
|
|
358
|
+
invalid({
|
|
359
|
+
class: "unrecognized_argument",
|
|
360
|
+
message: `unrecognized arguments: ${parsed.name}`,
|
|
361
|
+
});
|
|
362
|
+
}
|
|
363
|
+
if (all && verb)
|
|
364
|
+
invalid({ class: "mutually_exclusive", message: "--all cannot be combined with --verb" });
|
|
365
|
+
return { format, project, verb, all };
|
|
366
|
+
}
|
|
367
|
+
export function runStateWrite(artifactRaw, argv, io) {
|
|
368
|
+
const out = io.out ?? ((text) => process.stdout.write(text));
|
|
369
|
+
const err = io.err ?? ((text) => process.stderr.write(text));
|
|
370
|
+
const detectedFormat = formatFromArgv(argv);
|
|
371
|
+
try {
|
|
372
|
+
const artifact = artifactOrReject(artifactRaw);
|
|
373
|
+
assertMutationGrammarParity();
|
|
374
|
+
if (argv[0] === "explain") {
|
|
375
|
+
const args = explainArgs(argv);
|
|
376
|
+
const explanation = args.all
|
|
377
|
+
? buildExplainAll(artifact, args.project)
|
|
378
|
+
: buildExplain(artifact, args.project, args.verb);
|
|
379
|
+
if (args.format === "json")
|
|
380
|
+
out(JSON.stringify(explanation, null, 2) + "\n");
|
|
381
|
+
else
|
|
382
|
+
out(renderExplainText(explanation));
|
|
383
|
+
return 0;
|
|
384
|
+
}
|
|
385
|
+
const parsed = parseWrite(artifactRaw, argv);
|
|
386
|
+
let input = null;
|
|
387
|
+
if (parsed.inputSource) {
|
|
388
|
+
try {
|
|
389
|
+
input = loadStructuredInput(parsed.inputSource, io.stdin ?? (() => fsStdin()), parsed.spec.inputMaxBytes);
|
|
390
|
+
}
|
|
391
|
+
catch (error) {
|
|
392
|
+
const message = error.message;
|
|
393
|
+
invalid({
|
|
394
|
+
class: message.startsWith("input file") ? "unsupported_target" : message.includes("UTF-8 limit") ? "schema_violation" : "invalid_format",
|
|
395
|
+
message,
|
|
396
|
+
syntax: "--input PATH",
|
|
397
|
+
example: exampleFor(parsed.artifact, parsed.spec.verb),
|
|
398
|
+
...(message.includes("UTF-8 limit") ? { violations: [message] } : {}),
|
|
399
|
+
});
|
|
400
|
+
}
|
|
401
|
+
for (const owned of parsed.spec.cliOwnedFields ?? []) {
|
|
402
|
+
if (hasNested(input, owned))
|
|
403
|
+
invalid({
|
|
404
|
+
class: "schema_violation",
|
|
405
|
+
message: `${parsed.artifact} ${parsed.spec.verb} assigns ${owned}; remove '${owned}' from the input document`,
|
|
406
|
+
violations: [`CLI-owned field: ${owned}`],
|
|
407
|
+
});
|
|
408
|
+
}
|
|
409
|
+
parsed.callerPayload = structuredClone(input);
|
|
410
|
+
}
|
|
411
|
+
const envelope = executeStateWrite({ ...parsed, input });
|
|
412
|
+
if (parsed.format === "json")
|
|
413
|
+
out(JSON.stringify(envelope, null, 2) + "\n");
|
|
414
|
+
else if (parsed.dryRun)
|
|
415
|
+
out(String(envelope.diff ?? "No changes.\n"));
|
|
416
|
+
else {
|
|
417
|
+
const operation = envelope.operation;
|
|
418
|
+
out(`${envelope.command}: ${operation.idempotent_replay ? "idempotent replay" : "wrote"} ${envelope.path}\n`);
|
|
419
|
+
}
|
|
420
|
+
return 0;
|
|
421
|
+
}
|
|
422
|
+
catch (error) {
|
|
423
|
+
if (error instanceof StateWriteInputError)
|
|
424
|
+
return emitInvalidInput(io, { format: detectedFormat, body: error.body });
|
|
425
|
+
if (error instanceof StateRetrievalFailure)
|
|
426
|
+
return emitRetrievalFailure(error, detectedFormat, io);
|
|
427
|
+
err(`Error: ${error.message}\n`);
|
|
428
|
+
return 1;
|
|
429
|
+
}
|
|
430
|
+
}
|
|
431
|
+
function fsStdin() {
|
|
432
|
+
return process.stdin.isTTY ? Buffer.alloc(0) : fs.readFileSync(0);
|
|
433
|
+
}
|