agentera 3.0.0-dev.7 → 3.0.0-dev.72
This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
- package/LICENSE +201 -0
- package/README.md +118 -22
- package/bundle/CHANGELOG.md +1361 -0
- package/bundle/DESIGN.md +229 -0
- package/bundle/LICENSE +201 -0
- package/bundle/README.md +143 -0
- package/bundle/UPGRADE.md +252 -0
- package/bundle/extract-corpus-parity.json +2 -4
- package/bundle/fixtures/routing/hybrid-corpus.yaml +154 -0
- package/bundle/references/adapters/package-publication.json +488 -0
- package/bundle/references/adapters/package-registry.yaml +435 -188
- package/bundle/references/adapters/package-surface-characterization.md +66 -34
- package/bundle/references/adapters/runtime-lifecycle-adapters.yaml +74 -0
- package/bundle/references/adapters/runtime-lifecycle-authority.yaml +62 -0
- package/bundle/references/adapters/runtime-lifecycle-operation-contract.yaml +84 -0
- package/bundle/references/adapters/runtime-retired-resources.yaml +333 -0
- package/bundle/references/analysis/evidence-tier-authority.yaml +518 -0
- package/bundle/references/analysis/verification-policy.yaml +266 -0
- package/bundle/references/artifacts/artifact-registry-interface-model.yaml +17 -8
- package/bundle/references/artifacts/glossary-entry-contract.yaml +1254 -0
- package/bundle/references/artifacts/state-storage-authority.yaml +3061 -0
- package/bundle/references/artifacts/verbosity-budget-authority.yaml +42 -0
- package/bundle/references/cli/app-lifecycle-vocabulary.yaml +3 -4
- package/bundle/references/cli/capability-instruction-contract.yaml +11 -14
- package/bundle/references/cli/hybrid-route-contract.yaml +438 -0
- package/bundle/references/cli/routing-model.md +152 -93
- package/bundle/references/cli/trigger-schema-enrichment.md +57 -46
- package/bundle/references/cli/update-channels.yaml +4 -2
- package/bundle/references/cli/vocabulary-index.yaml +5 -7
- package/bundle/references/cli/vocabulary.md +51 -93
- package/bundle/references/meta/retained-reference-authority.yaml +151 -0
- package/bundle/skills/agentera/SKILL.md +183 -63
- package/bundle/skills/agentera/capabilities/audit/schemas/artifacts.yaml +27 -19
- package/bundle/skills/agentera/capabilities/audit/schemas/exit.yaml +2 -2
- package/bundle/skills/agentera/capabilities/audit/schemas/triggers.yaml +13 -35
- package/bundle/skills/agentera/capabilities/audit/schemas/validation.yaml +30 -11
- package/bundle/skills/agentera/capabilities/build/schemas/artifacts.yaml +44 -21
- package/bundle/skills/agentera/capabilities/build/schemas/exit.yaml +8 -6
- package/bundle/skills/agentera/capabilities/build/schemas/triggers.yaml +14 -36
- package/bundle/skills/agentera/capabilities/build/schemas/validation.yaml +95 -21
- package/bundle/skills/agentera/capabilities/design/schemas/artifacts.yaml +6 -6
- package/bundle/skills/agentera/capabilities/design/schemas/exit.yaml +5 -5
- package/bundle/skills/agentera/capabilities/design/schemas/triggers.yaml +5 -34
- package/bundle/skills/agentera/capabilities/design/schemas/validation.yaml +2 -2
- package/bundle/skills/agentera/capabilities/discuss/schemas/artifacts.yaml +17 -13
- package/bundle/skills/agentera/capabilities/discuss/schemas/exit.yaml +2 -2
- package/bundle/skills/agentera/capabilities/discuss/schemas/triggers.yaml +6 -40
- package/bundle/skills/agentera/capabilities/discuss/schemas/validation.yaml +72 -5
- package/bundle/skills/agentera/capabilities/document/schemas/artifacts.yaml +24 -17
- package/bundle/skills/agentera/capabilities/document/schemas/triggers.yaml +5 -35
- package/bundle/skills/agentera/capabilities/document/schemas/validation.yaml +13 -13
- package/bundle/skills/agentera/capabilities/optimize/schemas/artifacts.yaml +10 -10
- package/bundle/skills/agentera/capabilities/optimize/schemas/exit.yaml +2 -2
- package/bundle/skills/agentera/capabilities/optimize/schemas/triggers.yaml +4 -35
- package/bundle/skills/agentera/capabilities/optimize/schemas/validation.yaml +3 -3
- package/bundle/skills/agentera/capabilities/orchestrate/schemas/artifacts.yaml +34 -22
- package/bundle/skills/agentera/capabilities/orchestrate/schemas/exit.yaml +9 -7
- package/bundle/skills/agentera/capabilities/orchestrate/schemas/triggers.yaml +5 -37
- package/bundle/skills/agentera/capabilities/orchestrate/schemas/validation.yaml +38 -37
- package/bundle/skills/agentera/capabilities/plan/schemas/artifacts.yaml +20 -16
- package/bundle/skills/agentera/capabilities/plan/schemas/triggers.yaml +8 -31
- package/bundle/skills/agentera/capabilities/plan/schemas/validation.yaml +66 -6
- package/bundle/skills/agentera/capabilities/profile/schemas/artifacts.yaml +9 -4
- package/bundle/skills/agentera/capabilities/profile/schemas/exit.yaml +4 -4
- package/bundle/skills/agentera/capabilities/profile/schemas/triggers.yaml +8 -37
- package/bundle/skills/agentera/capabilities/profile/schemas/validation.yaml +61 -3
- package/bundle/skills/agentera/capabilities/research/schemas/artifacts.yaml +6 -6
- package/bundle/skills/agentera/capabilities/research/schemas/triggers.yaml +5 -29
- package/bundle/skills/agentera/capabilities/status/schemas/artifacts.yaml +13 -12
- package/bundle/skills/agentera/capabilities/status/schemas/triggers.yaml +7 -49
- package/bundle/skills/agentera/capabilities/vision/schemas/artifacts.yaml +8 -8
- package/bundle/skills/agentera/capabilities/vision/schemas/exit.yaml +7 -6
- package/bundle/skills/agentera/capabilities/vision/schemas/triggers.yaml +7 -39
- package/bundle/skills/agentera/capabilities/vision/schemas/validation.yaml +14 -16
- package/bundle/skills/agentera/capability_schema_contract.yaml +32 -32
- package/bundle/skills/agentera/protocol.yaml +4 -4
- package/bundle/skills/agentera/route-phrases.yaml +81 -0
- package/bundle/skills/agentera/schemas/artifacts/changelog.yaml +1 -0
- package/bundle/skills/agentera/schemas/artifacts/decisions.yaml +30 -12
- package/bundle/skills/agentera/schemas/artifacts/design.yaml +1 -0
- package/bundle/skills/agentera/schemas/artifacts/docs.yaml +7 -12
- package/bundle/skills/agentera/schemas/artifacts/experiments.yaml +140 -9
- package/bundle/skills/agentera/schemas/artifacts/glossary.yaml +82 -0
- package/bundle/skills/agentera/schemas/artifacts/health.yaml +56 -19
- package/bundle/skills/agentera/schemas/artifacts/objective.yaml +18 -4
- package/bundle/skills/agentera/schemas/artifacts/plan.yaml +457 -32
- package/bundle/skills/agentera/schemas/artifacts/progress.yaml +131 -18
- package/bundle/skills/agentera/schemas/artifacts/todo.yaml +302 -7
- package/dist/analytics/extractCorpus/cli.js +52 -11
- package/dist/analytics/extractCorpus/copilotSessions.js +6 -4
- package/dist/analytics/extractCorpus/core.js +40 -12
- package/dist/analytics/extractCorpus/corpus.js +39 -17
- package/dist/analytics/extractCorpus/coverageAudit.js +44 -45
- package/dist/analytics/extractCorpus/cursorSessions.js +6 -4
- package/dist/analytics/extractCorpus/evidenceTiers.js +603 -0
- package/dist/analytics/extractCorpus/extractCorpusParity.js +4 -4
- package/dist/analytics/extractCorpus/filesystemSources.js +1 -5
- package/dist/analytics/extractCorpus/index.js +3 -1
- package/dist/analytics/extractCorpus/jsonlSessions.js +24 -5
- package/dist/analytics/extractCorpus/sqliteCaps.js +0 -1
- package/dist/analytics/extractCorpus/sqliteSessions.js +0 -1
- package/dist/analytics/extractCorpus/tierReader.js +108 -0
- package/dist/analytics/extractCorpus.js +0 -1
- package/dist/analytics/glossaryAdviceResolution.js +166 -0
- package/dist/analytics/glossaryInputAcquisition.js +319 -0
- package/dist/analytics/personalGlossaryAdmission.js +133 -0
- package/dist/analytics/personalGlossaryProfile.js +219 -0
- package/dist/analytics/profileSignals.js +211 -0
- package/dist/analytics/usageStats.js +150 -23
- package/dist/audit/terminologyDrift.js +281 -0
- package/dist/bin/agentera.js +3 -2
- package/dist/capabilities/audit/instructions.js +16 -6
- package/dist/capabilities/build/instructions.js +59 -6
- package/dist/capabilities/design/instructions.js +3 -4
- package/dist/capabilities/discuss/instructions.js +29 -6
- package/dist/capabilities/document/instructions.js +11 -6
- package/dist/capabilities/index.js +16 -14
- package/dist/capabilities/optimize/instructions.js +14 -6
- package/dist/capabilities/orchestrate/instructions.js +42 -6
- package/dist/capabilities/plan/instructions.js +30 -3
- package/dist/capabilities/profile/instructions.js +70 -6
- package/dist/capabilities/research/instructions.js +4 -5
- package/dist/capabilities/status/instructions.js +15 -6
- package/dist/capabilities/status/startupInstructions.js +34 -0
- package/dist/capabilities/vision/instructions.js +3 -5
- package/dist/cli/appContext.js +14 -7
- package/dist/cli/argvalidate.js +0 -1
- package/dist/cli/capabilityContext/benchmark.js +5 -4
- package/dist/cli/capabilityContext/bespoke.js +14 -6
- package/dist/cli/capabilityContext/build.js +116 -42
- package/dist/cli/capabilityContext/closeout.js +30 -27
- package/dist/cli/capabilityContext/contract.js +18 -27
- package/dist/cli/capabilityContext/evidence.js +84 -77
- package/dist/cli/capabilityContext/index.js +0 -1
- package/dist/cli/capabilityContext/orchestration.js +42 -18
- package/dist/cli/capabilityContext/planState.js +89 -96
- package/dist/cli/capabilityContext/progress.js +51 -12
- package/dist/cli/capabilityContext/projectVerification.js +409 -0
- package/dist/cli/capabilityContext/shared.js +9 -20
- package/dist/cli/capabilityContext/slim.js +52 -8
- package/dist/cli/capabilityContext/startup.js +51 -114
- package/dist/cli/capabilityContext/startupAggregation.js +68 -0
- package/dist/cli/capabilityContext/types.js +26 -10
- package/dist/cli/capabilityContext.js +0 -1
- package/dist/cli/commands/appHome.js +0 -1
- package/dist/cli/commands/capability.js +2 -2
- package/dist/cli/commands/compact.js +163 -13
- package/dist/cli/commands/doctor.js +117 -11
- package/dist/cli/commands/durability.js +81 -0
- package/dist/cli/commands/glossaryAdvice.js +138 -0
- package/dist/cli/commands/lint.js +22 -8
- package/dist/cli/commands/personalGlossary.js +176 -0
- package/dist/cli/commands/prime/briefOrientation.js +746 -0
- package/dist/cli/commands/prime/buildExecutionRequest.js +165 -0
- package/dist/cli/commands/prime/bundleStatus.js +54 -4
- package/dist/cli/commands/prime/collectEntityOrientation.js +326 -0
- package/dist/cli/commands/prime/collectOrientationState.js +126 -63
- package/dist/cli/commands/prime/orientationOutput.js +267 -56
- package/dist/cli/commands/prime/types.js +0 -1
- package/dist/cli/commands/prime/v1Migration.js +0 -1
- package/dist/cli/commands/prime.js +76 -11
- package/dist/cli/commands/profileGrounding.js +55 -0
- package/dist/cli/commands/query.js +74 -52
- package/dist/cli/commands/report.js +73 -19
- package/dist/cli/commands/route.js +142 -0
- package/dist/cli/commands/schema.js +257 -138
- package/dist/cli/commands/state/decisions.js +40 -56
- package/dist/cli/commands/state/docs.js +58 -85
- package/dist/cli/commands/state/experimentRecords.js +151 -0
- package/dist/cli/commands/state/experiments.js +11 -65
- package/dist/cli/commands/state/get.js +129 -0
- package/dist/cli/commands/state/health.js +11 -113
- package/dist/cli/commands/state/index.js +6 -41
- package/dist/cli/commands/state/list.js +194 -0
- package/dist/cli/commands/state/objective.js +21 -65
- package/dist/cli/commands/state/plan.js +11 -170
- package/dist/cli/commands/state/planTasks.js +154 -0
- package/dist/cli/commands/state/plans.js +154 -0
- package/dist/cli/commands/state/progress.js +11 -45
- package/dist/cli/commands/state/shared.js +0 -1
- package/dist/cli/commands/state/todo.js +28 -107
- package/dist/cli/commands/state/write.js +433 -0
- package/dist/cli/commands/upgrade.js +146 -5
- package/dist/cli/commands/upgradeVerify.js +118 -0
- package/dist/cli/commands/validate.js +235 -136
- package/dist/cli/commands/verify.js +23 -8
- package/dist/cli/contracts/bundleStatus.js +0 -1
- package/dist/cli/contracts/orientationState.js +0 -1
- package/dist/cli/dispatch/argvParser.js +0 -1
- package/dist/cli/dispatch/check.js +84 -40
- package/dist/cli/dispatch/commands.js +3 -3
- package/dist/cli/dispatch/index.js +77 -52
- package/dist/cli/dispatch/lifecycle.js +117 -62
- package/dist/cli/dispatch/prime.js +37 -2
- package/dist/cli/dispatch/projections.js +17 -0
- package/dist/cli/dispatch/shared.js +1 -2
- package/dist/cli/dispatch/state.js +62 -66
- package/dist/cli/dispatch.js +0 -1
- package/dist/cli/errors.js +16 -17
- package/dist/cli/help.js +358 -39
- package/dist/cli/migrationRequired.js +122 -0
- package/dist/cli/orientation/attention.js +19 -19
- package/dist/cli/orientation/corpusCoverage.js +32 -1
- package/dist/cli/orientation.js +346 -129
- package/dist/cli/planArtifacts.js +350 -0
- package/dist/cli/planEvidence.js +157 -0
- package/dist/cli/planLifecycleState.js +36 -0
- package/dist/cli/planTaskIndex.js +11 -0
- package/dist/cli/preCutoverCommand.js +32 -0
- package/dist/cli/prime-blob.js +71 -3
- package/dist/cli/profileAcquisition.js +167 -0
- package/dist/cli/startupCompletenessContract.js +11 -8
- package/dist/cli/stateQuery.js +47 -12
- package/dist/cli/structured.js +0 -1
- package/dist/cli/todoMarkdown.js +25 -12
- package/dist/cli/todoReadinessSelection.js +192 -0
- package/dist/cli/todoSeverity.js +0 -1
- package/dist/core/atomicWriter.js +20 -0
- package/dist/core/developmentChannel.js +1 -0
- package/dist/core/developmentInvocation.js +374 -0
- package/dist/core/difflib.js +0 -1
- package/dist/core/envPaths.js +0 -1
- package/dist/core/jsonValue.js +0 -1
- package/dist/core/paths.js +0 -1
- package/dist/core/pyjson.js +0 -1
- package/dist/core/shell.js +4 -0
- package/dist/core/skillIdentity.js +23 -0
- package/dist/core/sourceRoot.js +9 -12
- package/dist/core/text.js +10 -0
- package/dist/core/toml.js +0 -1
- package/dist/core/yaml.js +8 -1
- package/dist/eval/evalSkills.js +13 -14
- package/dist/eval/hybridRouteEvaluation.js +155 -0
- package/dist/eval/semanticEval.js +0 -1
- package/dist/eval/semanticFixtures.js +0 -1
- package/dist/hooks/common.js +3 -56
- package/dist/hooks/compaction/apply.js +224 -47
- package/dist/hooks/compaction/dryRun.js +2 -1
- package/dist/hooks/compaction/index.js +5 -6
- package/dist/hooks/compaction/parse.js +73 -6
- package/dist/hooks/compaction/retention.js +28 -25
- package/dist/hooks/compaction/status.js +145 -26
- package/dist/hooks/compaction/types.js +0 -1
- package/dist/hooks/validateArtifact/agentFacing.js +0 -1
- package/dist/hooks/validateArtifact/index.js +6 -65
- package/dist/hooks/validateArtifact/markdown.js +9 -10
- package/dist/hooks/validateArtifact/schema.js +96 -9
- package/dist/hooks/validateArtifact/traversal.js +12 -11
- package/dist/hooks/validateArtifact/violations.js +5 -3
- package/dist/migrate/v2HandoffManifest.js +8 -3
- package/dist/registries/activationContract.js +2 -0
- package/dist/registries/activationTuples.js +108 -0
- package/dist/registries/artifactProtocolIds.js +2 -1
- package/dist/registries/artifactRegistry.js +207 -60
- package/dist/registries/artifactSchemaProjection.js +45 -0
- package/dist/registries/capabilityContract.js +5 -21
- package/dist/registries/evaluatorHandoffContract.js +0 -1
- package/dist/registries/evidenceTierContract.js +371 -0
- package/dist/registries/glossaryAdviceContract.js +79 -0
- package/dist/registries/glossaryCaveatContract.js +67 -0
- package/dist/registries/glossaryConsumerContractValidation.js +787 -0
- package/dist/registries/glossaryEntryContract.js +757 -0
- package/dist/registries/glossaryTermIdentity.js +17 -0
- package/dist/registries/glossaryTermOccurrence.js +20 -0
- package/dist/registries/hybridRoute.js +274 -0
- package/dist/registries/hybridRouteReceipt.js +221 -0
- package/dist/registries/packagePublication.js +273 -0
- package/dist/registries/packageRegistry.js +184 -209
- package/dist/registries/todoReadinessContract.js +448 -0
- package/dist/registries/triggerLoader.js +7 -44
- package/dist/registries/verbosityBudgetContract.js +205 -0
- package/dist/release/releaseMetadata.js +155 -5
- package/dist/runtime/lifecycleAdapterContract.js +457 -0
- package/dist/runtime/lifecycleAdapters.js +777 -0
- package/dist/runtime/lifecycleAuthority.js +453 -0
- package/dist/runtime/lifecycleOperationContract.js +123 -0
- package/dist/runtime/lifecycleOperations.js +634 -0
- package/dist/runtime/lifecycleOwnershipJournal.js +622 -0
- package/dist/runtime/lifecyclePublication.js +415 -0
- package/dist/runtime/lifecycleSnapshot.js +438 -0
- package/dist/runtime/nativeResourceCleanup.js +502 -0
- package/dist/setup/opencode.js +20 -13
- package/dist/setup/opencodeConstants.js +1 -0
- package/dist/setup/sharedSkill.js +45 -0
- package/dist/setup/smokeChecks.js +14 -75
- package/dist/state/archiveDiscovery.js +580 -0
- package/dist/state/archivePublication.js +225 -0
- package/dist/state/archiveRecovery.js +237 -0
- package/dist/state/archiveReplay.js +53 -0
- package/dist/state/canonicalMigrationRecord.js +36 -0
- package/dist/state/changelog.js +221 -0
- package/dist/state/decisionEntities.js +367 -0
- package/dist/state/decisionLegacyValidation.js +215 -0
- package/dist/state/decisionMigrationProvenance.js +199 -0
- package/dist/state/decisionOverlay.js +254 -0
- package/dist/state/decisionRevision.js +256 -0
- package/dist/state/decisionRevisionMigration.js +89 -0
- package/dist/state/directRetrieval.js +323 -0
- package/dist/state/durability.js +324 -0
- package/dist/state/entityCutover.js +459 -0
- package/dist/state/entityCutoverGit.js +127 -0
- package/dist/state/entityGlossaryAuthority.js +13 -0
- package/dist/state/entityListProjection.js +187 -0
- package/dist/state/entityListRuntimeRegistry.js +85 -0
- package/dist/state/entityMigrationCausality.js +97 -0
- package/dist/state/entityMigrationIdentity.js +5 -0
- package/dist/state/entityMigrationPreview.js +840 -0
- package/dist/state/entityMigrationTodo.js +133 -0
- package/dist/state/entityPublicationContext.js +859 -0
- package/dist/state/entityRetrievalHelp.js +506 -0
- package/dist/state/entityStorage.js +899 -0
- package/dist/state/exactReplacementRecovery.js +18 -0
- package/dist/state/experimentArchive.js +63 -0
- package/dist/state/experimentIdentity.js +202 -0
- package/dist/state/healthEntities.js +262 -0
- package/dist/state/healthEntityValidation.js +18 -0
- package/dist/state/healthRepair.js +69 -0
- package/dist/state/installRoot.js +15 -7
- package/dist/state/legacyEntityCutoverEvidence.js +65 -0
- package/dist/state/legacyIdentity.js +47 -0
- package/dist/state/legacySummaryRecord.js +6 -0
- package/dist/state/listAccounting.js +54 -0
- package/dist/state/listClassification.js +17 -0
- package/dist/state/listCursor.js +42 -0
- package/dist/state/listRetrieval.js +781 -0
- package/dist/state/migrationSourceBinding.js +30 -0
- package/dist/state/objectiveExperimentEntities.js +322 -0
- package/dist/state/planEntities.js +1027 -0
- package/dist/state/planIdentity.js +47 -0
- package/dist/state/planLineageValidation.js +52 -0
- package/dist/state/planReplacementTransaction.js +475 -0
- package/dist/state/planRetrieval.js +313 -0
- package/dist/state/planTaskRetrieval.js +294 -0
- package/dist/state/progressEntities.js +512 -0
- package/dist/state/progressGlossaryCaveat.js +168 -0
- package/dist/state/progressPublicationOrder.js +19 -0
- package/dist/state/progressWritePolicy.js +33 -0
- package/dist/state/projectRoot.js +62 -0
- package/dist/state/projectionPolicy.js +190 -0
- package/dist/state/retrievalAuthority.js +156 -0
- package/dist/state/safeProjectFile.js +155 -0
- package/dist/state/startupAnalysis/benchmark.js +70 -9
- package/dist/state/startupAnalysis/contract.js +44 -10
- package/dist/state/startupAnalysis/helpers.js +1 -2
- package/dist/state/startupAnalysis/index.js +0 -1
- package/dist/state/startupAnalysis/metrics.js +0 -1
- package/dist/state/startupAnalysis/records.js +0 -1
- package/dist/state/startupAnalysis/report.js +0 -1
- package/dist/state/startupAnalysis/threshold.js +13 -1
- package/dist/state/startupAnalysis.js +0 -1
- package/dist/state/startupProjection.js +499 -0
- package/dist/state/stateMode.js +222 -0
- package/dist/state/stateStorageAuthority.js +47 -0
- package/dist/state/summaryEntityRead.js +25 -0
- package/dist/state/summaryMigrationProvenance.js +66 -0
- package/dist/state/summarySourceRowAuthority.js +36 -0
- package/dist/state/todoActivationSafety.js +58 -0
- package/dist/state/todoDocsEntities.js +1124 -0
- package/dist/state/todoDocsEntityValidation.js +158 -0
- package/dist/state/todoMarkdownProjection.js +51 -0
- package/dist/state/todoReconciliationActivation.js +182 -0
- package/dist/state/todoReconciliationInspection.js +171 -0
- package/dist/state/todoReconciliationRepair.js +318 -0
- package/dist/state/todoReconciliationTransaction.js +595 -0
- package/dist/state/write/assign.js +20 -0
- package/dist/state/write/candidateMutation.js +269 -0
- package/dist/state/write/errors.js +11 -0
- package/dist/state/write/experimentPublication.js +192 -0
- package/dist/state/write/explain.js +377 -0
- package/dist/state/write/fields.js +61 -0
- package/dist/state/write/glossaryPublication.js +263 -0
- package/dist/state/write/grammar.js +285 -0
- package/dist/state/write/helpers.js +29 -0
- package/dist/state/write/index.js +12 -0
- package/dist/state/write/input.js +391 -0
- package/dist/state/write/lock.js +837 -0
- package/dist/state/write/mutation.js +234 -0
- package/dist/state/write/operations.js +170 -0
- package/dist/state/write/planEvaluation.js +128 -0
- package/dist/state/write/planPublication.js +179 -0
- package/dist/state/write/runtimeOperations.js +146 -0
- package/dist/state/write/serialize.js +1 -0
- package/dist/state/write/transaction.js +57 -0
- package/dist/state/write/validate.js +7 -0
- package/dist/upgrade/appContentRefresh.js +77 -36
- package/dist/upgrade/appModel.js +0 -1
- package/dist/upgrade/atomicWriter.js +1 -0
- package/dist/upgrade/bundleEvidence.js +0 -1
- package/dist/upgrade/channels.js +6 -9
- package/dist/upgrade/compatibility.js +43 -17
- package/dist/upgrade/doctor.js +55 -32
- package/dist/upgrade/doctorClassifier.js +11 -1
- package/dist/upgrade/installedHooksRetirement.js +46 -40
- package/dist/upgrade/legacyAgentCleanup.js +187 -21
- package/dist/upgrade/lifecycleUpgrade.js +113 -0
- package/dist/upgrade/migrateArtifactsV2ToV3.js +334 -64
- package/dist/upgrade/migrationPublication.js +122 -0
- package/dist/upgrade/nextMajorDoctor.js +0 -1
- package/dist/upgrade/npxPlatformStatus.js +0 -1
- package/dist/upgrade/projectIntegration.js +121 -159
- package/dist/upgrade/projectIntegrationDecision.js +42 -85
- package/dist/upgrade/retiredResourceDiagnostics.js +117 -0
- package/dist/upgrade/runtimeMigration.js +262 -453
- package/dist/upgrade/upgradeCommands.js +14 -1
- package/dist/upgrade/upgradeLock.js +85 -0
- package/dist/upgrade/upgradeOrchestrator.js +263 -59
- package/dist/upgrade/v3CapabilitySurface.js +2 -3
- package/dist/upgrade/versionResolution.js +0 -1
- package/dist/validate/activationArtifactEvidence.js +852 -0
- package/dist/validate/activationArtifactEvidenceTypes.js +12 -0
- package/dist/validate/activationConjunction.js +816 -0
- package/dist/validate/activationEvidenceManifest.js +531 -0
- package/dist/validate/activationPackageSemantics.js +29 -0
- package/dist/validate/appHomeContract.js +1 -7
- package/dist/validate/bootstrapAuthority.js +44 -0
- package/dist/validate/capability.js +11 -3
- package/dist/validate/crossCapability.js +14 -9
- package/dist/validate/retainedReferenceAuthority.js +879 -0
- package/dist/validate/selfAudit.js +39 -45
- package/dist/validate/v1LegacyCruft.js +131 -0
- package/dist/validate/vocabularyAuthority.js +8 -8
- package/package.json +41 -13
- package/bundle/references/adapters/cursor.md +0 -214
- package/bundle/references/adapters/opencode.md +0 -530
- package/bundle/references/adapters/package-manifest-interface-model.yaml +0 -337
- package/bundle/references/adapters/runtime-adapter-characterization.md +0 -79
- package/bundle/references/adapters/runtime-adapter-interface-model.yaml +0 -200
- package/bundle/references/adapters/runtime-adapter-registry.yaml +0 -554
- package/bundle/references/adapters/runtime-feature-parity.md +0 -189
- package/bundle/references/analysis/benchmark.md +0 -267
- package/bundle/references/analysis/startup-measurement-contract.yaml +0 -424
- package/bundle/references/cli/agent-ready-state-contract.yaml +0 -953
- package/bundle/references/cli/audience-namespace-cli-migration.yaml +0 -369
- package/bundle/references/cli/bundle-skill-vocabulary.yaml +0 -250
- package/bundle/references/cli/capability-tool-classification.yaml +0 -53
- package/bundle/references/cli/coexistence-probe.yaml +0 -13
- package/bundle/references/cli/parity-expected-actual-template.md +0 -30
- package/bundle/references/cli/routing-execution-vocabulary.yaml +0 -281
- package/bundle/references/cli/single-name-protocol.yaml +0 -42
- package/bundle/references/cli/upgrade-repair-wording.md +0 -45
- package/bundle/references/cli/v3-handoff-manifest.schema.yaml +0 -98
- package/bundle/references/meta/documentation-inventory.md +0 -49
- package/bundle/skills/agentera/.claude-plugin/plugin.json +0 -27
- package/bundle/skills/agentera/agents/audit.toml +0 -6
- package/bundle/skills/agentera/agents/build.toml +0 -6
- package/bundle/skills/agentera/agents/design.toml +0 -6
- package/bundle/skills/agentera/agents/discuss.toml +0 -6
- package/bundle/skills/agentera/agents/document.toml +0 -6
- package/bundle/skills/agentera/agents/optimize.toml +0 -6
- package/bundle/skills/agentera/agents/orchestrate.toml +0 -6
- package/bundle/skills/agentera/agents/plan.toml +0 -6
- package/bundle/skills/agentera/agents/profile.toml +0 -6
- package/bundle/skills/agentera/agents/research.toml +0 -6
- package/bundle/skills/agentera/agents/status.toml +0 -6
- package/bundle/skills/agentera/agents/vision.toml +0 -6
- package/bundle/skills/agentera/references/contract.md +0 -1048
- package/dist/analytics/extractCorpus/cli.js.map +0 -1
- package/dist/analytics/extractCorpus/copilotSessions.js.map +0 -1
- package/dist/analytics/extractCorpus/core.js.map +0 -1
- package/dist/analytics/extractCorpus/corpus.js.map +0 -1
- package/dist/analytics/extractCorpus/coverageAudit.js.map +0 -1
- package/dist/analytics/extractCorpus/cursorSessions.js.map +0 -1
- package/dist/analytics/extractCorpus/extractCorpusParity.js.map +0 -1
- package/dist/analytics/extractCorpus/filesystemSources.js.map +0 -1
- package/dist/analytics/extractCorpus/index.js.map +0 -1
- package/dist/analytics/extractCorpus/jsonlSessions.js.map +0 -1
- package/dist/analytics/extractCorpus/sqliteCaps.js.map +0 -1
- package/dist/analytics/extractCorpus/sqliteSessions.js.map +0 -1
- package/dist/analytics/extractCorpus.js.map +0 -1
- package/dist/analytics/usageStats.js.map +0 -1
- package/dist/bin/agentera.js.map +0 -1
- package/dist/capabilities/audit/instructions.js.map +0 -1
- package/dist/capabilities/build/instructions.js.map +0 -1
- package/dist/capabilities/design/instructions.js.map +0 -1
- package/dist/capabilities/discuss/instructions.js.map +0 -1
- package/dist/capabilities/document/instructions.js.map +0 -1
- package/dist/capabilities/dokumentera/instructions.js +0 -6
- package/dist/capabilities/dokumentera/instructions.js.map +0 -1
- package/dist/capabilities/hej/instructions.js +0 -6
- package/dist/capabilities/hej/instructions.js.map +0 -1
- package/dist/capabilities/index.js.map +0 -1
- package/dist/capabilities/inspektera/instructions.js +0 -6
- package/dist/capabilities/inspektera/instructions.js.map +0 -1
- package/dist/capabilities/inspirera/instructions.js +0 -6
- package/dist/capabilities/inspirera/instructions.js.map +0 -1
- package/dist/capabilities/optimera/instructions.js +0 -6
- package/dist/capabilities/optimera/instructions.js.map +0 -1
- package/dist/capabilities/optimize/instructions.js.map +0 -1
- package/dist/capabilities/orchestrate/instructions.js.map +0 -1
- package/dist/capabilities/orkestrera/instructions.js +0 -6
- package/dist/capabilities/orkestrera/instructions.js.map +0 -1
- package/dist/capabilities/plan/instructions.js.map +0 -1
- package/dist/capabilities/planera/instructions.js +0 -6
- package/dist/capabilities/planera/instructions.js.map +0 -1
- package/dist/capabilities/profile/instructions.js.map +0 -1
- package/dist/capabilities/profilera/instructions.js +0 -6
- package/dist/capabilities/profilera/instructions.js.map +0 -1
- package/dist/capabilities/realisera/instructions.js +0 -6
- package/dist/capabilities/realisera/instructions.js.map +0 -1
- package/dist/capabilities/research/instructions.js.map +0 -1
- package/dist/capabilities/resonera/instructions.js +0 -6
- package/dist/capabilities/resonera/instructions.js.map +0 -1
- package/dist/capabilities/status/instructions.js.map +0 -1
- package/dist/capabilities/vision/instructions.js.map +0 -1
- package/dist/capabilities/visionera/instructions.js +0 -6
- package/dist/capabilities/visionera/instructions.js.map +0 -1
- package/dist/capabilities/visualisera/instructions.js +0 -5
- package/dist/capabilities/visualisera/instructions.js.map +0 -1
- package/dist/cli/appContext.js.map +0 -1
- package/dist/cli/argvalidate.js.map +0 -1
- package/dist/cli/capabilityContext/benchmark.js.map +0 -1
- package/dist/cli/capabilityContext/bespoke.js.map +0 -1
- package/dist/cli/capabilityContext/build.js.map +0 -1
- package/dist/cli/capabilityContext/closeout.js.map +0 -1
- package/dist/cli/capabilityContext/contract.js.map +0 -1
- package/dist/cli/capabilityContext/evidence.js.map +0 -1
- package/dist/cli/capabilityContext/index.js.map +0 -1
- package/dist/cli/capabilityContext/orchestration.js.map +0 -1
- package/dist/cli/capabilityContext/planState.js.map +0 -1
- package/dist/cli/capabilityContext/progress.js.map +0 -1
- package/dist/cli/capabilityContext/realisera.js +0 -174
- package/dist/cli/capabilityContext/realisera.js.map +0 -1
- package/dist/cli/capabilityContext/shared.js.map +0 -1
- package/dist/cli/capabilityContext/slim.js.map +0 -1
- package/dist/cli/capabilityContext/startup.js.map +0 -1
- package/dist/cli/capabilityContext/types.js.map +0 -1
- package/dist/cli/capabilityContext.js.map +0 -1
- package/dist/cli/commands/appHome.js.map +0 -1
- package/dist/cli/commands/backfill.js +0 -84
- package/dist/cli/commands/backfill.js.map +0 -1
- package/dist/cli/commands/capability.js.map +0 -1
- package/dist/cli/commands/compact.js.map +0 -1
- package/dist/cli/commands/doctor.js.map +0 -1
- package/dist/cli/commands/lint.js.map +0 -1
- package/dist/cli/commands/prime/bundleStatus.js.map +0 -1
- package/dist/cli/commands/prime/collectOrientationState.js.map +0 -1
- package/dist/cli/commands/prime/orientationOutput.js.map +0 -1
- package/dist/cli/commands/prime/routeOutput.js +0 -50
- package/dist/cli/commands/prime/routeOutput.js.map +0 -1
- package/dist/cli/commands/prime/types.js.map +0 -1
- package/dist/cli/commands/prime/v1Migration.js.map +0 -1
- package/dist/cli/commands/prime.js.map +0 -1
- package/dist/cli/commands/query.js.map +0 -1
- package/dist/cli/commands/report.js.map +0 -1
- package/dist/cli/commands/schema.js.map +0 -1
- package/dist/cli/commands/state/decisions.js.map +0 -1
- package/dist/cli/commands/state/docs.js.map +0 -1
- package/dist/cli/commands/state/experiments.js.map +0 -1
- package/dist/cli/commands/state/health.js.map +0 -1
- package/dist/cli/commands/state/index.js.map +0 -1
- package/dist/cli/commands/state/objective.js.map +0 -1
- package/dist/cli/commands/state/plan.js.map +0 -1
- package/dist/cli/commands/state/progress.js.map +0 -1
- package/dist/cli/commands/state/shared.js.map +0 -1
- package/dist/cli/commands/state/todo.js.map +0 -1
- package/dist/cli/commands/state.js +0 -1023
- package/dist/cli/commands/state.js.map +0 -1
- package/dist/cli/commands/upgrade.js.map +0 -1
- package/dist/cli/commands/validate.js.map +0 -1
- package/dist/cli/commands/verify.js.map +0 -1
- package/dist/cli/contracts/bundleStatus.js.map +0 -1
- package/dist/cli/contracts/orientationState.js.map +0 -1
- package/dist/cli/dispatch/argvParser.js.map +0 -1
- package/dist/cli/dispatch/check.js.map +0 -1
- package/dist/cli/dispatch/commands.js.map +0 -1
- package/dist/cli/dispatch/index.js.map +0 -1
- package/dist/cli/dispatch/lifecycle.js.map +0 -1
- package/dist/cli/dispatch/prime.js.map +0 -1
- package/dist/cli/dispatch/shared.js.map +0 -1
- package/dist/cli/dispatch/state.js.map +0 -1
- package/dist/cli/dispatch.js.map +0 -1
- package/dist/cli/errors.js.map +0 -1
- package/dist/cli/help.js.map +0 -1
- package/dist/cli/orientation/attention.js.map +0 -1
- package/dist/cli/orientation/corpusCoverage.js.map +0 -1
- package/dist/cli/orientation.js.map +0 -1
- package/dist/cli/prime-blob.js.map +0 -1
- package/dist/cli/startupCompletenessContract.js.map +0 -1
- package/dist/cli/stateQuery.js.map +0 -1
- package/dist/cli/structured.js.map +0 -1
- package/dist/cli/todoMarkdown.js.map +0 -1
- package/dist/cli/todoSeverity.js.map +0 -1
- package/dist/core/difflib.js.map +0 -1
- package/dist/core/envPaths.js.map +0 -1
- package/dist/core/git.js +0 -43
- package/dist/core/git.js.map +0 -1
- package/dist/core/jsonValue.js.map +0 -1
- package/dist/core/paths.js.map +0 -1
- package/dist/core/pyjson.js.map +0 -1
- package/dist/core/sourceRoot.js.map +0 -1
- package/dist/core/toml.js.map +0 -1
- package/dist/core/yaml.js.map +0 -1
- package/dist/eval/evalSkills.js.map +0 -1
- package/dist/eval/semanticEval.js.map +0 -1
- package/dist/eval/semanticFixtures.js.map +0 -1
- package/dist/hooks/common.js.map +0 -1
- package/dist/hooks/compaction/apply.js.map +0 -1
- package/dist/hooks/compaction/dryRun.js.map +0 -1
- package/dist/hooks/compaction/index.js.map +0 -1
- package/dist/hooks/compaction/parse.js.map +0 -1
- package/dist/hooks/compaction/retention.js.map +0 -1
- package/dist/hooks/compaction/status.js.map +0 -1
- package/dist/hooks/compaction/todoResolved.js +0 -137
- package/dist/hooks/compaction/todoResolved.js.map +0 -1
- package/dist/hooks/compaction/types.js.map +0 -1
- package/dist/hooks/compaction.js +0 -935
- package/dist/hooks/compaction.js.map +0 -1
- package/dist/hooks/cursorPreToolUse.js +0 -19
- package/dist/hooks/cursorPreToolUse.js.map +0 -1
- package/dist/hooks/cursorSessionStart.js +0 -79
- package/dist/hooks/cursorSessionStart.js.map +0 -1
- package/dist/hooks/sessionStart.js +0 -216
- package/dist/hooks/sessionStart.js.map +0 -1
- package/dist/hooks/sessionStop.js +0 -206
- package/dist/hooks/sessionStop.js.map +0 -1
- package/dist/hooks/todoLayout.js +0 -177
- package/dist/hooks/todoLayout.js.map +0 -1
- package/dist/hooks/validateArtifact/agentFacing.js.map +0 -1
- package/dist/hooks/validateArtifact/index.js.map +0 -1
- package/dist/hooks/validateArtifact/markdown.js.map +0 -1
- package/dist/hooks/validateArtifact/runtime.js +0 -86
- package/dist/hooks/validateArtifact/runtime.js.map +0 -1
- package/dist/hooks/validateArtifact/schema.js.map +0 -1
- package/dist/hooks/validateArtifact/traversal.js.map +0 -1
- package/dist/hooks/validateArtifact/violations.js.map +0 -1
- package/dist/hooks/validateArtifact.js +0 -924
- package/dist/hooks/validateArtifact.js.map +0 -1
- package/dist/migrate/v2HandoffManifest.js.map +0 -1
- package/dist/registries/artifactProtocolIds.js.map +0 -1
- package/dist/registries/artifactRegistry.js.map +0 -1
- package/dist/registries/capabilityContract.js.map +0 -1
- package/dist/registries/evaluatorHandoffContract.js.map +0 -1
- package/dist/registries/packageRegistry.js.map +0 -1
- package/dist/registries/runtimeAdapterRegistry.js +0 -316
- package/dist/registries/runtimeAdapterRegistry.js.map +0 -1
- package/dist/registries/triggerLoader.js.map +0 -1
- package/dist/release/releaseMetadata.js.map +0 -1
- package/dist/routing/index.js +0 -2
- package/dist/routing/index.js.map +0 -1
- package/dist/routing/routeEngine.js +0 -189
- package/dist/routing/routeEngine.js.map +0 -1
- package/dist/setup/codex/agents.js +0 -96
- package/dist/setup/codex/agents.js.map +0 -1
- package/dist/setup/codex/cli.js +0 -161
- package/dist/setup/codex/cli.js.map +0 -1
- package/dist/setup/codex/configToml.js +0 -639
- package/dist/setup/codex/configToml.js.map +0 -1
- package/dist/setup/codex/constants.js +0 -29
- package/dist/setup/codex/constants.js.map +0 -1
- package/dist/setup/codex/installRoot.js +0 -64
- package/dist/setup/codex/installRoot.js.map +0 -1
- package/dist/setup/codex/state.js +0 -270
- package/dist/setup/codex/state.js.map +0 -1
- package/dist/setup/codex.js +0 -12
- package/dist/setup/codex.js.map +0 -1
- package/dist/setup/copilot.js +0 -227
- package/dist/setup/copilot.js.map +0 -1
- package/dist/setup/cursor.js +0 -129
- package/dist/setup/cursor.js.map +0 -1
- package/dist/setup/cursorSurfaces.js +0 -67
- package/dist/setup/cursorSurfaces.js.map +0 -1
- package/dist/setup/doctor/core.js +0 -300
- package/dist/setup/doctor/core.js.map +0 -1
- package/dist/setup/doctor/diagnostics.js +0 -240
- package/dist/setup/doctor/diagnostics.js.map +0 -1
- package/dist/setup/doctor/opencode.js +0 -313
- package/dist/setup/doctor/opencode.js.map +0 -1
- package/dist/setup/doctor/report.js +0 -425
- package/dist/setup/doctor/report.js.map +0 -1
- package/dist/setup/doctor.js +0 -10
- package/dist/setup/doctor.js.map +0 -1
- package/dist/setup/opencode.js.map +0 -1
- package/dist/setup/smokeChecks.js.map +0 -1
- package/dist/state/installRoot.js.map +0 -1
- package/dist/state/progressCommit.js +0 -289
- package/dist/state/progressCommit.js.map +0 -1
- package/dist/state/startupAnalysis/benchmark.js.map +0 -1
- package/dist/state/startupAnalysis/contract.js.map +0 -1
- package/dist/state/startupAnalysis/helpers.js.map +0 -1
- package/dist/state/startupAnalysis/index.js.map +0 -1
- package/dist/state/startupAnalysis/metrics.js.map +0 -1
- package/dist/state/startupAnalysis/records.js.map +0 -1
- package/dist/state/startupAnalysis/report.js.map +0 -1
- package/dist/state/startupAnalysis/threshold.js.map +0 -1
- package/dist/state/startupAnalysis.js.map +0 -1
- package/dist/upgrade/appContentRefresh.js.map +0 -1
- package/dist/upgrade/appModel.js.map +0 -1
- package/dist/upgrade/bundleEvidence.js.map +0 -1
- package/dist/upgrade/channels.js.map +0 -1
- package/dist/upgrade/cliProbe.js +0 -22
- package/dist/upgrade/cliProbe.js.map +0 -1
- package/dist/upgrade/coexistenceProbe.js +0 -107
- package/dist/upgrade/coexistenceProbe.js.map +0 -1
- package/dist/upgrade/compatibility.js.map +0 -1
- package/dist/upgrade/doctor.js.map +0 -1
- package/dist/upgrade/doctorClassifier.js.map +0 -1
- package/dist/upgrade/installedHooksRetirement.js.map +0 -1
- package/dist/upgrade/legacyAgentCleanup.js.map +0 -1
- package/dist/upgrade/migrateArtifactsV1ToV2.js +0 -570
- package/dist/upgrade/migrateArtifactsV1ToV2.js.map +0 -1
- package/dist/upgrade/migrateArtifactsV2ToV3.js.map +0 -1
- package/dist/upgrade/nextMajorDoctor.js.map +0 -1
- package/dist/upgrade/npxPlatformStatus.js.map +0 -1
- package/dist/upgrade/projectIntegration.js.map +0 -1
- package/dist/upgrade/projectIntegrationDecision.js.map +0 -1
- package/dist/upgrade/runtimeMigration.js.map +0 -1
- package/dist/upgrade/upgradeCommands.js.map +0 -1
- package/dist/upgrade/upgradeOrchestrator.js.map +0 -1
- package/dist/upgrade/v3CapabilitySurface.js.map +0 -1
- package/dist/upgrade/versionResolution.js.map +0 -1
- package/dist/validate/appHomeContract.js.map +0 -1
- package/dist/validate/capability.js.map +0 -1
- package/dist/validate/crossCapability.js.map +0 -1
- package/dist/validate/lifecycleAdapters/legacyPythonParity.js +0 -93
- package/dist/validate/lifecycleAdapters/legacyPythonParity.js.map +0 -1
- package/dist/validate/lifecycleAdapters/nodeFormChecks.js +0 -488
- package/dist/validate/lifecycleAdapters/nodeFormChecks.js.map +0 -1
- package/dist/validate/lifecycleAdapters/shared.js +0 -198
- package/dist/validate/lifecycleAdapters/shared.js.map +0 -1
- package/dist/validate/lifecycleAdapters.js +0 -62
- package/dist/validate/lifecycleAdapters.js.map +0 -1
- package/dist/validate/selfAudit.js.map +0 -1
- package/dist/validate/vocabularyAuthority.js.map +0 -1
|
@@ -0,0 +1,746 @@
|
|
|
1
|
+
import { truncateCodePoints } from "../../../core/text.js";
|
|
2
|
+
import { entityListFamily } from "../../../state/entityRetrievalHelp.js";
|
|
3
|
+
import { preCutoverCommand } from "../../preCutoverCommand.js";
|
|
4
|
+
import { STATE_FAMILY_FALLBACK_COMMANDS } from "../../capabilityContext/types.js";
|
|
5
|
+
/**
|
|
6
|
+
* Bounded default decision brief for the bare `agentera prime --format json`
|
|
7
|
+
* emission (Plan Task 3).
|
|
8
|
+
*
|
|
9
|
+
* The bare default projects the full orientation payload
|
|
10
|
+
* ({@link buildOrientationJsonPayload}) to a bounded decision brief: every
|
|
11
|
+
* required top-level field stays PRESENT (the compatibility boundary asserts
|
|
12
|
+
* the key set), but rich diagnostic/writer detail within those fields is
|
|
13
|
+
* projected to routing-essential leaves plus a named authoritative recovery
|
|
14
|
+
* command for each omitted sub-detail. Dashboard startup independently omits
|
|
15
|
+
* duplicated ordinary history entries; explicit fields and capability contexts
|
|
16
|
+
* retain their separately governed projections.
|
|
17
|
+
*
|
|
18
|
+
* The byte gate is deterministic pretty-JSON UTF-8 measurement
|
|
19
|
+
* (Buffer.byteLength(JSON.stringify(brief, null, 2) + "\n", "utf8")); an
|
|
20
|
+
* over-budget brief is rejected in favor of a bounded degraded envelope.
|
|
21
|
+
* Diagnostics stay on stderr and are measured separately. The state-storage
|
|
22
|
+
* authority owns the briefing budget.
|
|
23
|
+
*/
|
|
24
|
+
/** Authoritative byte budget for the default bare prime decision brief.
|
|
25
|
+
* Mirrors references/artifacts/state-storage-authority.yaml
|
|
26
|
+
* budgets.startup.surfaces.prime_briefing.max_utf8_bytes and
|
|
27
|
+
* scripts/json_output_surface_manifest.yaml prime-briefing byte_budget.
|
|
28
|
+
* archiveAuthority.test.ts binds the authority to the manifest; the
|
|
29
|
+
* primeProjectionContract.test.ts suite binds this constant to the authority
|
|
30
|
+
* so the contract and implementation cannot drift apart. */
|
|
31
|
+
export const PRIME_BRIEF_MAX_UTF8_BYTES = 12000;
|
|
32
|
+
/** Deterministic pretty-JSON UTF-8 byte length (including the trailing newline)
|
|
33
|
+
* used by the brief byte gate. Identical to the projection-policy serializer
|
|
34
|
+
* (serializedProjectionBytes) so measurement is consistent across surfaces. */
|
|
35
|
+
export function briefUtf8Bytes(value) {
|
|
36
|
+
const serialized = JSON.stringify(value, null, 2);
|
|
37
|
+
if (serialized === undefined)
|
|
38
|
+
throw new TypeError("brief value is not JSON serializable");
|
|
39
|
+
return Buffer.byteLength(serialized + "\n", "utf8");
|
|
40
|
+
}
|
|
41
|
+
/** Byte-gate primitive: deterministic UTF-8 measurement + budget comparison.
|
|
42
|
+
* AC5: a passing fixture (bytes <= budget) is accepted; an over-budget fixture
|
|
43
|
+
* (bytes > budget) is rejected. */
|
|
44
|
+
export function briefByteGate(value, budget = PRIME_BRIEF_MAX_UTF8_BYTES) {
|
|
45
|
+
const bytes = briefUtf8Bytes(value);
|
|
46
|
+
return { accepted: bytes <= budget, bytes };
|
|
47
|
+
}
|
|
48
|
+
/** Rich-state sub-detail projected out of the default brief, each with a named
|
|
49
|
+
* authoritative recovery command. */
|
|
50
|
+
const planTaskFamily = entityListFamily("plan_tasks");
|
|
51
|
+
const planTaskListRecovery = preCutoverCommand(`state ${planTaskFamily.commandTokens.join(" ")} list --format json`);
|
|
52
|
+
const OMITTED_RICH_STATE = [
|
|
53
|
+
{ field: "startup.path_diagnostics", reason: "startup_path_diagnostics", recovery: preCutoverCommand("doctor --format json") },
|
|
54
|
+
{ field: "plan.tasks", reason: "plan_task_detail", recovery: planTaskListRecovery },
|
|
55
|
+
{ field: "plan.archived_plans", reason: "archive_catalog", recovery: STATE_FAMILY_FALLBACK_COMMANDS.plan },
|
|
56
|
+
{ field: "plan.diagnostics", reason: "plan_diagnostics", recovery: STATE_FAMILY_FALLBACK_COMMANDS.plan },
|
|
57
|
+
{ field: "history.progress.entries", reason: "startup_history_entries", recovery: STATE_FAMILY_FALLBACK_COMMANDS.progress },
|
|
58
|
+
{ field: "history.decisions.entries", reason: "startup_history_entries", recovery: STATE_FAMILY_FALLBACK_COMMANDS.decisions },
|
|
59
|
+
{ field: "history.health.entries", reason: "startup_history_entries", recovery: STATE_FAMILY_FALLBACK_COMMANDS.health },
|
|
60
|
+
{ field: "project_integration.phases", reason: "phase_blockers", recovery: preCutoverCommand("doctor --format json") },
|
|
61
|
+
{ field: "docs.source_contract", reason: "docs_state_families", recovery: STATE_FAMILY_FALLBACK_COMMANDS.docs },
|
|
62
|
+
{ field: "profile.bounded_signals", reason: "profile_signal_detail", recovery: preCutoverCommand("report profile-grounding --format json") },
|
|
63
|
+
];
|
|
64
|
+
/** Maximum number of ranked next_action alternatives retained in the brief.
|
|
65
|
+
* The recommended entry is always kept; overflow alternatives recover via the
|
|
66
|
+
* state-derived readiness cascade rather than raw artifact access. */
|
|
67
|
+
const BRIEF_NEXT_ACTION_ALTERNATIVES = 3;
|
|
68
|
+
const PATH_DIAGNOSTICS_RECOVERY = preCutoverCommand("doctor --format json");
|
|
69
|
+
/** Code-point cap for routing-essential free-text scalars retained in the brief
|
|
70
|
+
* (e.g. progress.latest.what/next). Matches the boundStartupValue 200-cp
|
|
71
|
+
* limit already applied to context payloads so the brief never lets a single
|
|
72
|
+
* pathological scalar blow the budget; the full value recovers via the named
|
|
73
|
+
* state command. */
|
|
74
|
+
const BRIEF_SCALAR_MAX_CHARS = 200;
|
|
75
|
+
function projectionMaxChars(projection) {
|
|
76
|
+
return projection === "normal" ? BRIEF_SCALAR_MAX_CHARS : projection === "compact" ? 120 : 80;
|
|
77
|
+
}
|
|
78
|
+
function projectionMaxItems(projection) {
|
|
79
|
+
return projection === "normal" ? 10 : projection === "compact" ? 6 : 3;
|
|
80
|
+
}
|
|
81
|
+
/** Keys owned by the state-presence contract. Unknown keys are caller data, not
|
|
82
|
+
* routing signals, so the brief never copies them into a fallback envelope. */
|
|
83
|
+
const STATE_PRESENCE_ACTIVE_KEYS = ["plan", "objective"];
|
|
84
|
+
const STATE_PRESENCE_AVAILABLE_KEYS = ["plan", "docs", "progress", "health", "objective"];
|
|
85
|
+
const STATE_PRESENCE_ABSENCE_KEYS = ["plan", "docs", "progress"];
|
|
86
|
+
const BRIEF_SOURCE_FIELDS_MAX = 64;
|
|
87
|
+
const BRIEF_SOURCE_STRING_MAX_CHARS = 256;
|
|
88
|
+
const BRIEF_COMPACT_SOURCE_FIELDS_MAX = 32;
|
|
89
|
+
const BRIEF_COMPACT_SOURCE_STRING_MAX_CHARS = 96;
|
|
90
|
+
const BRIEF_IRREDUCIBLE_SOURCE_FIELDS_MAX = 32;
|
|
91
|
+
const BRIEF_IRREDUCIBLE_SOURCE_STRING_MAX_CHARS = 64;
|
|
92
|
+
function isObject(value) {
|
|
93
|
+
return value !== null && typeof value === "object" && !Array.isArray(value);
|
|
94
|
+
}
|
|
95
|
+
/** Copy only the listed keys that exist on `source`. Keeps the brief stable when
|
|
96
|
+
* a conditional field is absent (e.g. plan.first_pending on an empty plan). */
|
|
97
|
+
function pick(source, keys) {
|
|
98
|
+
if (!isObject(source))
|
|
99
|
+
return {};
|
|
100
|
+
const out = {};
|
|
101
|
+
for (const key of keys) {
|
|
102
|
+
if (key in source)
|
|
103
|
+
out[key] = source[key];
|
|
104
|
+
}
|
|
105
|
+
return out;
|
|
106
|
+
}
|
|
107
|
+
function boundedString(value, maxChars) {
|
|
108
|
+
return typeof value === "string" ? truncateCodePoints(value, maxChars, "…") : undefined;
|
|
109
|
+
}
|
|
110
|
+
function boundedStringList(value, maxItems, maxChars) {
|
|
111
|
+
if (!Array.isArray(value))
|
|
112
|
+
return undefined;
|
|
113
|
+
return value
|
|
114
|
+
.filter((entry) => typeof entry === "string")
|
|
115
|
+
.slice(0, maxItems)
|
|
116
|
+
.map((entry) => truncateCodePoints(entry, maxChars, "…"));
|
|
117
|
+
}
|
|
118
|
+
function boundedBooleanMap(value, keys) {
|
|
119
|
+
if (!isObject(value))
|
|
120
|
+
return undefined;
|
|
121
|
+
const out = {};
|
|
122
|
+
for (const key of keys) {
|
|
123
|
+
if (typeof value[key] === "boolean")
|
|
124
|
+
out[key] = value[key];
|
|
125
|
+
}
|
|
126
|
+
return out;
|
|
127
|
+
}
|
|
128
|
+
function boundedStringMap(value, keys, maxChars) {
|
|
129
|
+
if (!isObject(value))
|
|
130
|
+
return undefined;
|
|
131
|
+
const out = {};
|
|
132
|
+
for (const key of keys) {
|
|
133
|
+
const bounded = boundedString(value[key], maxChars);
|
|
134
|
+
if (bounded !== undefined)
|
|
135
|
+
out[key] = bounded;
|
|
136
|
+
}
|
|
137
|
+
return out;
|
|
138
|
+
}
|
|
139
|
+
/** Project the presence authority to its finite, contract-owned shape. This is
|
|
140
|
+
* deliberately not a generic object trim: unknown caller keys cannot change
|
|
141
|
+
* routing, and therefore must not be allowed to consume the fallback budget. */
|
|
142
|
+
function briefStatePresence(value, maxChars = BRIEF_SCALAR_MAX_CHARS) {
|
|
143
|
+
if (value === null || value === undefined)
|
|
144
|
+
return value === null ? null : {};
|
|
145
|
+
if (!isObject(value))
|
|
146
|
+
return {};
|
|
147
|
+
const out = {};
|
|
148
|
+
const active = boundedBooleanMap(value.active, STATE_PRESENCE_ACTIVE_KEYS);
|
|
149
|
+
const available = boundedBooleanMap(value.available, STATE_PRESENCE_AVAILABLE_KEYS);
|
|
150
|
+
const absence = boundedStringMap(value.absence, STATE_PRESENCE_ABSENCE_KEYS, maxChars);
|
|
151
|
+
if (active !== undefined)
|
|
152
|
+
out.active = active;
|
|
153
|
+
if (available !== undefined)
|
|
154
|
+
out.available = available;
|
|
155
|
+
if (typeof value.any_active === "boolean")
|
|
156
|
+
out.any_active = value.any_active;
|
|
157
|
+
if (typeof value.absence_explained === "boolean")
|
|
158
|
+
out.absence_explained = value.absence_explained;
|
|
159
|
+
if (absence !== undefined)
|
|
160
|
+
out.absence = absence;
|
|
161
|
+
return out;
|
|
162
|
+
}
|
|
163
|
+
function briefSelectedPlanTask(task, projection) {
|
|
164
|
+
if (task === null)
|
|
165
|
+
return null;
|
|
166
|
+
if (!isObject(task))
|
|
167
|
+
return {};
|
|
168
|
+
const maxChars = projectionMaxChars(projection);
|
|
169
|
+
const maxItems = projectionMaxItems(projection);
|
|
170
|
+
const out = pick(task, [
|
|
171
|
+
"id",
|
|
172
|
+
"artifact",
|
|
173
|
+
"status",
|
|
174
|
+
"dependency_count",
|
|
175
|
+
"omitted_dependency_count",
|
|
176
|
+
"acceptance_count",
|
|
177
|
+
"omitted_acceptance_count",
|
|
178
|
+
]);
|
|
179
|
+
const name = boundedString(task.name ?? task.title, maxChars);
|
|
180
|
+
if (name !== undefined)
|
|
181
|
+
out.name = name;
|
|
182
|
+
const dependencies = boundedStringList(task.depends_on, maxItems, maxChars);
|
|
183
|
+
if (dependencies !== undefined)
|
|
184
|
+
out.depends_on = dependencies;
|
|
185
|
+
const acceptance = boundedStringList(task.acceptance, maxItems, maxChars);
|
|
186
|
+
if (acceptance !== undefined)
|
|
187
|
+
out.acceptance = acceptance;
|
|
188
|
+
if (isObject(task.retrieval)) {
|
|
189
|
+
out.retrieval = pick(task.retrieval, ["get"]);
|
|
190
|
+
}
|
|
191
|
+
return out;
|
|
192
|
+
}
|
|
193
|
+
function briefPlan(plan, projection = "normal") {
|
|
194
|
+
// Keep canonical plan/task identity and the routing-essential summary consumers
|
|
195
|
+
// read plus the selected task's dependencies, acceptance, and exact retrieval.
|
|
196
|
+
// Drop the optional task catalog, archive catalog, diagnostics, and
|
|
197
|
+
// lifecycle_state — each recovers via OMITTED_RICH_STATE.
|
|
198
|
+
const out = pick(plan, [
|
|
199
|
+
"exists",
|
|
200
|
+
"id",
|
|
201
|
+
"artifact",
|
|
202
|
+
"active",
|
|
203
|
+
"status",
|
|
204
|
+
"complete",
|
|
205
|
+
"total",
|
|
206
|
+
"complete_plan",
|
|
207
|
+
"task_count",
|
|
208
|
+
"omitted_task_count",
|
|
209
|
+
]);
|
|
210
|
+
if (isObject(plan)) {
|
|
211
|
+
const title = boundedString(plan.title, projectionMaxChars(projection));
|
|
212
|
+
if (title !== undefined)
|
|
213
|
+
out.title = title;
|
|
214
|
+
if (isObject(plan.source_contract)) {
|
|
215
|
+
out.source_contract = pick(plan.source_contract, ["detail_availability", "retrieval", "raw_archive_records"]);
|
|
216
|
+
}
|
|
217
|
+
}
|
|
218
|
+
if (isObject(plan) && "first_pending" in plan) {
|
|
219
|
+
out.first_pending = briefSelectedPlanTask(plan.first_pending, projection);
|
|
220
|
+
}
|
|
221
|
+
return out;
|
|
222
|
+
}
|
|
223
|
+
function briefHistoryRetrieval(value) {
|
|
224
|
+
return pick(value, ["list", "get"]);
|
|
225
|
+
}
|
|
226
|
+
function briefHistoryCaveats(value, maxChars) {
|
|
227
|
+
if (!Array.isArray(value))
|
|
228
|
+
return undefined;
|
|
229
|
+
return value.slice(0, 4).map((caveat) => {
|
|
230
|
+
if (typeof caveat === "string")
|
|
231
|
+
return truncateCodePoints(caveat, maxChars, "…");
|
|
232
|
+
if (!isObject(caveat))
|
|
233
|
+
return {};
|
|
234
|
+
const out = {};
|
|
235
|
+
for (const key of [
|
|
236
|
+
"class",
|
|
237
|
+
"kind",
|
|
238
|
+
"state",
|
|
239
|
+
"confidence",
|
|
240
|
+
"satisfaction_state",
|
|
241
|
+
"message",
|
|
242
|
+
"reason",
|
|
243
|
+
"detail_availability",
|
|
244
|
+
"compatibility",
|
|
245
|
+
"recovery",
|
|
246
|
+
]) {
|
|
247
|
+
const bounded = boundedString(caveat[key], maxChars);
|
|
248
|
+
if (bounded !== undefined)
|
|
249
|
+
out[key] = bounded;
|
|
250
|
+
}
|
|
251
|
+
if (typeof caveat.review_needed === "boolean")
|
|
252
|
+
out.review_needed = caveat.review_needed;
|
|
253
|
+
return out;
|
|
254
|
+
});
|
|
255
|
+
}
|
|
256
|
+
function briefHistory(history, projection = "normal") {
|
|
257
|
+
if (!isObject(history))
|
|
258
|
+
return {};
|
|
259
|
+
const out = {};
|
|
260
|
+
const maxChars = projectionMaxChars(projection);
|
|
261
|
+
for (const [artifactId, entry] of Object.entries(history)) {
|
|
262
|
+
// Entity startup history owns canonical full/summary counts. Entry detail
|
|
263
|
+
// remains omitted and recovers through exact list/get commands.
|
|
264
|
+
const entryObj = isObject(entry) ? entry : {};
|
|
265
|
+
const counts = isObject(entryObj.counts) ? entryObj.counts : {};
|
|
266
|
+
const projected = {
|
|
267
|
+
...pick(entryObj, [
|
|
268
|
+
"artifact",
|
|
269
|
+
"status",
|
|
270
|
+
"compatibility",
|
|
271
|
+
"detail_availability",
|
|
272
|
+
"omitted",
|
|
273
|
+
"omitted_count",
|
|
274
|
+
"omission_reason",
|
|
275
|
+
]),
|
|
276
|
+
counts: pick(counts, ["total", "returned", "remaining", "full", "summary"]),
|
|
277
|
+
retrieval: briefHistoryRetrieval(entryObj.retrieval),
|
|
278
|
+
};
|
|
279
|
+
const caveats = briefHistoryCaveats(entryObj.caveats, maxChars);
|
|
280
|
+
if (caveats !== undefined)
|
|
281
|
+
projected.caveats = caveats;
|
|
282
|
+
if (isObject(entryObj.degraded_history)) {
|
|
283
|
+
const degraded = pick(entryObj.degraded_history, ["summary_count", "returned_count", "omitted_count"]);
|
|
284
|
+
degraded.retrieval = briefHistoryRetrieval(entryObj.degraded_history.retrieval);
|
|
285
|
+
const degradedCaveats = briefHistoryCaveats(entryObj.degraded_history.caveats, maxChars);
|
|
286
|
+
if (degradedCaveats !== undefined)
|
|
287
|
+
degraded.caveats = degradedCaveats;
|
|
288
|
+
projected.degraded_history = degraded;
|
|
289
|
+
}
|
|
290
|
+
if (isObject(entryObj.source_contract)) {
|
|
291
|
+
projected.source_contract = pick(entryObj.source_contract, ["authority", "detail", "cursor"]);
|
|
292
|
+
}
|
|
293
|
+
out[artifactId] = projected;
|
|
294
|
+
}
|
|
295
|
+
return out;
|
|
296
|
+
}
|
|
297
|
+
function briefProjectIntegration(integration) {
|
|
298
|
+
// Keep the routing recommendation, message, pending counts, channel,
|
|
299
|
+
// aggregate status, and any major-boundary block (which overrides
|
|
300
|
+
// next_action). Upgrade commands are part of the executable upgrade route;
|
|
301
|
+
// preserve them only for that recommendation. Phase blockers and guidance
|
|
302
|
+
// detail recover via doctor.
|
|
303
|
+
const fields = [
|
|
304
|
+
"recommendation",
|
|
305
|
+
"message",
|
|
306
|
+
"update_channel",
|
|
307
|
+
"pending_artifacts",
|
|
308
|
+
"aggregate_status",
|
|
309
|
+
"major_boundary_block",
|
|
310
|
+
];
|
|
311
|
+
if (isObject(integration) && integration.recommendation === "upgrade") {
|
|
312
|
+
fields.push("dry_run_command", "apply_command");
|
|
313
|
+
}
|
|
314
|
+
return pick(integration, fields);
|
|
315
|
+
}
|
|
316
|
+
function briefProfile(profile) {
|
|
317
|
+
// opencode reads profile.status; the dashboard glyph reads profile.status.
|
|
318
|
+
// bounded_signals (a legacy recovery blob) is omitted and recovers via
|
|
319
|
+
// `agentera profile --format json`.
|
|
320
|
+
return pick(profile, [
|
|
321
|
+
"status",
|
|
322
|
+
"validity",
|
|
323
|
+
"freshness",
|
|
324
|
+
"days_since_generated",
|
|
325
|
+
"stale",
|
|
326
|
+
"stale_threshold_days",
|
|
327
|
+
"generated_date",
|
|
328
|
+
"validated_date",
|
|
329
|
+
"suggested_action",
|
|
330
|
+
]);
|
|
331
|
+
}
|
|
332
|
+
function briefApp(app) {
|
|
333
|
+
// `app` is required for app/v1/profile safety, but no default-bare consumer
|
|
334
|
+
// reads its verbose path list (the packaging gate reads app_home.source).
|
|
335
|
+
// Keep safety identity; path diagnostics recover through doctor so checkout
|
|
336
|
+
// depth cannot displace routing or canonical history evidence.
|
|
337
|
+
return pick(app, [
|
|
338
|
+
"status",
|
|
339
|
+
"expectedVersion",
|
|
340
|
+
"updateChannel",
|
|
341
|
+
]);
|
|
342
|
+
}
|
|
343
|
+
function briefAppHome(appHome) {
|
|
344
|
+
return pick(appHome, ["install_track", "status", "source"]);
|
|
345
|
+
}
|
|
346
|
+
function briefSharedSkill(sharedSkill) {
|
|
347
|
+
if (!isObject(sharedSkill))
|
|
348
|
+
return {};
|
|
349
|
+
const out = pick(sharedSkill, ["name", "status", "source", "gap"]);
|
|
350
|
+
const message = boundedString(sharedSkill.message, BRIEF_SCALAR_MAX_CHARS);
|
|
351
|
+
if (message !== undefined)
|
|
352
|
+
out.message = message;
|
|
353
|
+
const details = boundedStringList(sharedSkill.details, 3, BRIEF_SCALAR_MAX_CHARS);
|
|
354
|
+
if (details !== undefined)
|
|
355
|
+
out.details = details;
|
|
356
|
+
return out;
|
|
357
|
+
}
|
|
358
|
+
function briefSource(source) {
|
|
359
|
+
return pick(source, ["artifacts_present"]);
|
|
360
|
+
}
|
|
361
|
+
function briefAttention(attention) {
|
|
362
|
+
// opencode reads the attention array for routing hints, but each entry is an
|
|
363
|
+
// advisory string. Cap each at BRIEF_SCALAR_MAX_CHARS so a pathological
|
|
364
|
+
// lifecycle procedure text cannot blow the budget; the full detail recovers
|
|
365
|
+
// via the named recovery commands in omitted_rich_state.
|
|
366
|
+
if (!Array.isArray(attention))
|
|
367
|
+
return attention ?? [];
|
|
368
|
+
return attention.map((entry) => typeof entry === "string" ? truncateCodePoints(entry, BRIEF_SCALAR_MAX_CHARS, "…") : entry);
|
|
369
|
+
}
|
|
370
|
+
function briefDecisionAttention(attention) {
|
|
371
|
+
if (attention === null)
|
|
372
|
+
return null;
|
|
373
|
+
if (!isObject(attention))
|
|
374
|
+
return {};
|
|
375
|
+
const out = pick(attention, ["type", "count", "states", "max_entries", "bounded"]);
|
|
376
|
+
const summary = boundedString(attention.attention, BRIEF_SCALAR_MAX_CHARS);
|
|
377
|
+
if (summary !== undefined)
|
|
378
|
+
out.attention = summary;
|
|
379
|
+
out.entries = Array.isArray(attention.entries)
|
|
380
|
+
? attention.entries.slice(0, 3).map((entry) => {
|
|
381
|
+
if (!isObject(entry))
|
|
382
|
+
return {};
|
|
383
|
+
const projected = pick(entry, ["id", "artifact", "state"]);
|
|
384
|
+
const title = boundedString(entry.title, BRIEF_SCALAR_MAX_CHARS);
|
|
385
|
+
if (title !== undefined)
|
|
386
|
+
projected.title = title;
|
|
387
|
+
return projected;
|
|
388
|
+
})
|
|
389
|
+
: [];
|
|
390
|
+
return out;
|
|
391
|
+
}
|
|
392
|
+
function briefDocs(docs) {
|
|
393
|
+
// No default-bare consumer reads the docs projection detail. Keep the
|
|
394
|
+
// availability signal and mapping count; the verbose source_contract with
|
|
395
|
+
// state_families recovers via the canonical docs list fallback.
|
|
396
|
+
return pick(docs, ["exists", "status", "mapping_entries", "indexed_documents"]);
|
|
397
|
+
}
|
|
398
|
+
function briefProgress(progress) {
|
|
399
|
+
// opencode reads progress.latest.number/what/next; the brief keeps the
|
|
400
|
+
// latest cycle but caps free-text scalars at BRIEF_SCALAR_MAX_CHARS so a
|
|
401
|
+
// pathological value cannot blow the budget. Full detail recovers via
|
|
402
|
+
// `agentera state progress get --id ID --format json`.
|
|
403
|
+
if (!isObject(progress))
|
|
404
|
+
return {};
|
|
405
|
+
const out = pick(progress, ["exists", "status", "latest_verification", "cycle_count", "degraded_history"]);
|
|
406
|
+
const latest = progress.latest;
|
|
407
|
+
if (isObject(latest)) {
|
|
408
|
+
const boundedLatest = {};
|
|
409
|
+
for (const [key, value] of Object.entries(latest)) {
|
|
410
|
+
boundedLatest[key] = typeof value === "string" ? truncateCodePoints(value, BRIEF_SCALAR_MAX_CHARS, "…") : value;
|
|
411
|
+
}
|
|
412
|
+
out.latest = boundedLatest;
|
|
413
|
+
}
|
|
414
|
+
else {
|
|
415
|
+
out.latest = latest;
|
|
416
|
+
}
|
|
417
|
+
return out;
|
|
418
|
+
}
|
|
419
|
+
function briefHealth(health) {
|
|
420
|
+
return pick(health, ["exists", "id", "artifact", "date", "trajectory", "grade", "degraded_history"]);
|
|
421
|
+
}
|
|
422
|
+
function briefAction(action, maxChars) {
|
|
423
|
+
if (!isObject(action))
|
|
424
|
+
return {};
|
|
425
|
+
const out = pick(action, ["id", "artifact", "outcome", "eligible"]);
|
|
426
|
+
for (const key of ["object", "capability", "reason", "phase"]) {
|
|
427
|
+
const bounded = boundedString(action[key], maxChars);
|
|
428
|
+
if (bounded !== undefined)
|
|
429
|
+
out[key] = bounded;
|
|
430
|
+
}
|
|
431
|
+
if (isObject(action.retrieval))
|
|
432
|
+
out.retrieval = pick(action.retrieval, ["exact", "get"]);
|
|
433
|
+
return out;
|
|
434
|
+
}
|
|
435
|
+
function briefNextAction(nextAction, projection = "normal") {
|
|
436
|
+
if (!isObject(nextAction))
|
|
437
|
+
return {};
|
|
438
|
+
const maxChars = projectionMaxChars(projection);
|
|
439
|
+
const alternativeLimit = projection === "normal"
|
|
440
|
+
? BRIEF_NEXT_ACTION_ALTERNATIVES
|
|
441
|
+
: projection === "compact"
|
|
442
|
+
? 1
|
|
443
|
+
: 0;
|
|
444
|
+
const alternatives = Array.isArray(nextAction.alternatives)
|
|
445
|
+
? nextAction.alternatives.slice(0, alternativeLimit).map((entry) => briefAction(entry, maxChars))
|
|
446
|
+
: [];
|
|
447
|
+
return {
|
|
448
|
+
...briefAction(nextAction, maxChars),
|
|
449
|
+
alternatives,
|
|
450
|
+
};
|
|
451
|
+
}
|
|
452
|
+
function briefCapabilityContext(value, maxChars) {
|
|
453
|
+
if (!isObject(value))
|
|
454
|
+
return {};
|
|
455
|
+
const out = {};
|
|
456
|
+
for (const key of ["capability", "fetch_command", "note"]) {
|
|
457
|
+
const bounded = boundedString(value[key], maxChars);
|
|
458
|
+
if (bounded !== undefined)
|
|
459
|
+
out[key] = bounded;
|
|
460
|
+
}
|
|
461
|
+
if (typeof value.required_before_rendering === "boolean") {
|
|
462
|
+
out.required_before_rendering = value.required_before_rendering;
|
|
463
|
+
}
|
|
464
|
+
return out;
|
|
465
|
+
}
|
|
466
|
+
function briefSourceContract(sourceContract, projection = "normal") {
|
|
467
|
+
if (!isObject(sourceContract))
|
|
468
|
+
return {};
|
|
469
|
+
const maxItems = projection === "normal"
|
|
470
|
+
? BRIEF_SOURCE_FIELDS_MAX
|
|
471
|
+
: projection === "compact"
|
|
472
|
+
? BRIEF_COMPACT_SOURCE_FIELDS_MAX
|
|
473
|
+
: BRIEF_IRREDUCIBLE_SOURCE_FIELDS_MAX;
|
|
474
|
+
const maxChars = projection === "normal"
|
|
475
|
+
? BRIEF_SOURCE_STRING_MAX_CHARS
|
|
476
|
+
: projection === "compact"
|
|
477
|
+
? BRIEF_COMPACT_SOURCE_STRING_MAX_CHARS
|
|
478
|
+
: BRIEF_IRREDUCIBLE_SOURCE_STRING_MAX_CHARS;
|
|
479
|
+
const out = {};
|
|
480
|
+
const fields = boundedStringList(sourceContract.fields, maxItems, maxChars);
|
|
481
|
+
if (fields !== undefined)
|
|
482
|
+
out.fields = fields;
|
|
483
|
+
for (const key of ["render", "access", "empty_state"]) {
|
|
484
|
+
const bounded = boundedString(sourceContract[key], maxChars);
|
|
485
|
+
if (bounded !== undefined)
|
|
486
|
+
out[key] = bounded;
|
|
487
|
+
}
|
|
488
|
+
if (projection !== "irreducible" && isObject(sourceContract.capability_context)) {
|
|
489
|
+
out.capability_context = briefCapabilityContext(sourceContract.capability_context, maxChars);
|
|
490
|
+
}
|
|
491
|
+
else if (projection === "irreducible" && isObject(sourceContract.capability_context)) {
|
|
492
|
+
const capabilityContext = briefCapabilityContext(sourceContract.capability_context, maxChars);
|
|
493
|
+
if ("fetch_command" in capabilityContext) {
|
|
494
|
+
out.capability_context = { fetch_command: capabilityContext.fetch_command };
|
|
495
|
+
}
|
|
496
|
+
}
|
|
497
|
+
return out;
|
|
498
|
+
}
|
|
499
|
+
/** Project the full orientation payload to a bounded decision brief. The brief
|
|
500
|
+
* keeps every required top-level field present (content projected to
|
|
501
|
+
* routing-essential leaves) plus a `brief` meta block that records the budget,
|
|
502
|
+
* measured bytes, status, and omitted rich-state recovery commands.
|
|
503
|
+
*
|
|
504
|
+
* Measurement uses deterministic pretty-JSON UTF-8 byte length including the
|
|
505
|
+
* trailing newline. The reported `utf8_bytes` is settled to a fixed point so
|
|
506
|
+
* it equals the actual emitted byte count (self-measurement otherwise changes
|
|
507
|
+
* its own digit count); the gate then decides on the final form. */
|
|
508
|
+
export function briefOrientationPayload(payload, options = {}) {
|
|
509
|
+
const budget = options.budgetBytes ?? PRIME_BRIEF_MAX_UTF8_BYTES;
|
|
510
|
+
if (!Number.isSafeInteger(budget) || budget < 0) {
|
|
511
|
+
throw new RangeError("brief budget must be a non-negative safe integer");
|
|
512
|
+
}
|
|
513
|
+
const projected = projectBriefBody(payload);
|
|
514
|
+
const finalPayload = withBriefMeta(projected, "ok", budget, null);
|
|
515
|
+
const gate = briefByteGate(finalPayload, budget);
|
|
516
|
+
if (gate.accepted) {
|
|
517
|
+
return finalPayload;
|
|
518
|
+
}
|
|
519
|
+
// Over-budget brief: reject the projected payload and emit a bounded degraded
|
|
520
|
+
// envelope (never emit an over-budget payload). The envelope keeps bounded
|
|
521
|
+
// plan/next-action/history/decision routing evidence, state presence, a brief
|
|
522
|
+
// source contract, and the byte-budget error with a recovery command.
|
|
523
|
+
return degradedBriefEnvelope(payload, budget, gate.bytes, options.degradedMode ?? "minimal");
|
|
524
|
+
}
|
|
525
|
+
/** Attach the brief meta block and settle `utf8_bytes` to a fixed point so the
|
|
526
|
+
* reported size equals the actual emitted byte count (otherwise the digits of
|
|
527
|
+
* `utf8_bytes` itself would change the measurement). */
|
|
528
|
+
function withBriefMeta(body, projection, budget, error) {
|
|
529
|
+
const meta = {
|
|
530
|
+
budget_utf8_bytes: budget,
|
|
531
|
+
projection,
|
|
532
|
+
path_diagnostics_recovery: PATH_DIAGNOSTICS_RECOVERY,
|
|
533
|
+
omitted_rich_state: OMITTED_RICH_STATE.map((entry) => ({ ...entry })),
|
|
534
|
+
};
|
|
535
|
+
if (error)
|
|
536
|
+
meta.error = error;
|
|
537
|
+
return settledBriefEnvelope(body, meta);
|
|
538
|
+
}
|
|
539
|
+
function projectBriefBody(payload) {
|
|
540
|
+
const out = {};
|
|
541
|
+
for (const [key, value] of Object.entries(payload)) {
|
|
542
|
+
switch (key) {
|
|
543
|
+
case "plan":
|
|
544
|
+
out[key] = briefPlan(value);
|
|
545
|
+
break;
|
|
546
|
+
case "history":
|
|
547
|
+
out[key] = briefHistory(value);
|
|
548
|
+
break;
|
|
549
|
+
case "project_integration":
|
|
550
|
+
out[key] = briefProjectIntegration(value);
|
|
551
|
+
break;
|
|
552
|
+
case "profile":
|
|
553
|
+
out[key] = briefProfile(value);
|
|
554
|
+
break;
|
|
555
|
+
case "app":
|
|
556
|
+
out[key] = briefApp(value);
|
|
557
|
+
break;
|
|
558
|
+
case "app_home":
|
|
559
|
+
out[key] = briefAppHome(value);
|
|
560
|
+
break;
|
|
561
|
+
case "shared_skill":
|
|
562
|
+
out[key] = briefSharedSkill(value);
|
|
563
|
+
break;
|
|
564
|
+
case "progress":
|
|
565
|
+
out[key] = briefProgress(value);
|
|
566
|
+
break;
|
|
567
|
+
case "health":
|
|
568
|
+
out[key] = briefHealth(value);
|
|
569
|
+
break;
|
|
570
|
+
case "next_action":
|
|
571
|
+
out[key] = briefNextAction(value);
|
|
572
|
+
break;
|
|
573
|
+
case "attention":
|
|
574
|
+
out[key] = briefAttention(value);
|
|
575
|
+
break;
|
|
576
|
+
case "decision_attention":
|
|
577
|
+
out[key] = briefDecisionAttention(value);
|
|
578
|
+
break;
|
|
579
|
+
case "docs":
|
|
580
|
+
out[key] = briefDocs(value);
|
|
581
|
+
break;
|
|
582
|
+
case "source_contract":
|
|
583
|
+
out[key] = briefSourceContract(value);
|
|
584
|
+
break;
|
|
585
|
+
case "state_presence":
|
|
586
|
+
out[key] = briefStatePresence(value);
|
|
587
|
+
break;
|
|
588
|
+
case "source":
|
|
589
|
+
out[key] = briefSource(value);
|
|
590
|
+
break;
|
|
591
|
+
default:
|
|
592
|
+
// Command/outcome/mode, bounded ordinary state, shared-skill diagnosis,
|
|
593
|
+
// bespoke context pointers, and active conditional fields pass through
|
|
594
|
+
// at full fidelity.
|
|
595
|
+
out[key] = value;
|
|
596
|
+
break;
|
|
597
|
+
}
|
|
598
|
+
}
|
|
599
|
+
return out;
|
|
600
|
+
}
|
|
601
|
+
function boundedEnvelopeScalar(value, fallback) {
|
|
602
|
+
return boundedString(value, BRIEF_SCALAR_MAX_CHARS) ?? fallback;
|
|
603
|
+
}
|
|
604
|
+
function degradedBody(payload, projection) {
|
|
605
|
+
const out = {
|
|
606
|
+
command: boundedEnvelopeScalar(payload.command, "prime"),
|
|
607
|
+
outcome: boundedEnvelopeScalar(payload.outcome, "ok"),
|
|
608
|
+
mode: boundedEnvelopeScalar(payload.mode, "unknown"),
|
|
609
|
+
state_presence: briefStatePresence(payload.state_presence),
|
|
610
|
+
source_contract: briefSourceContract(payload.source_contract, projection),
|
|
611
|
+
};
|
|
612
|
+
if ("app_home" in payload)
|
|
613
|
+
out.app_home = briefAppHome(payload.app_home);
|
|
614
|
+
if ("app" in payload)
|
|
615
|
+
out.app = briefApp(payload.app);
|
|
616
|
+
if ("profile" in payload)
|
|
617
|
+
out.profile = briefProfile(payload.profile);
|
|
618
|
+
if ("shared_skill" in payload)
|
|
619
|
+
out.shared_skill = briefSharedSkill(payload.shared_skill);
|
|
620
|
+
if ("project_integration" in payload)
|
|
621
|
+
out.project_integration = briefProjectIntegration(payload.project_integration);
|
|
622
|
+
if ("todo_reconciliation" in payload)
|
|
623
|
+
out.todo_reconciliation = payload.todo_reconciliation;
|
|
624
|
+
if ("startup" in payload)
|
|
625
|
+
out.startup = payload.startup;
|
|
626
|
+
if ("health" in payload)
|
|
627
|
+
out.health = briefHealth(payload.health);
|
|
628
|
+
if ("todo" in payload)
|
|
629
|
+
out.todo = payload.todo;
|
|
630
|
+
if ("progress" in payload)
|
|
631
|
+
out.progress = briefProgress(payload.progress);
|
|
632
|
+
if ("attention" in payload)
|
|
633
|
+
out.attention = briefAttention(payload.attention);
|
|
634
|
+
if ("source" in payload)
|
|
635
|
+
out.source = briefSource(payload.source);
|
|
636
|
+
for (const conditional of ["v1_migration", "docs", "objective"]) {
|
|
637
|
+
if (conditional in payload)
|
|
638
|
+
out[conditional] = payload[conditional];
|
|
639
|
+
}
|
|
640
|
+
if (isObject(payload.plan))
|
|
641
|
+
out.plan = briefPlan(payload.plan, projection);
|
|
642
|
+
if (isObject(payload.next_action))
|
|
643
|
+
out.next_action = briefNextAction(payload.next_action, projection);
|
|
644
|
+
if (isObject(payload.history))
|
|
645
|
+
out.history = briefHistory(payload.history, projection);
|
|
646
|
+
if (payload.decision_attention === null)
|
|
647
|
+
out.decision_attention = null;
|
|
648
|
+
else if (isObject(payload.decision_attention))
|
|
649
|
+
out.decision_attention = briefDecisionAttention(payload.decision_attention);
|
|
650
|
+
return out;
|
|
651
|
+
}
|
|
652
|
+
function statusRoutingDegradedBody(payload, projection) {
|
|
653
|
+
return {
|
|
654
|
+
...degradedBody(payload, projection),
|
|
655
|
+
todo: payload.todo,
|
|
656
|
+
attention: briefAttention(payload.attention),
|
|
657
|
+
};
|
|
658
|
+
}
|
|
659
|
+
/** Settle the self-measuring byte field and return only at a fixed point. The
|
|
660
|
+
* serialized value and the reported value therefore use the same pretty UTF-8
|
|
661
|
+
* plus newline accounting as emitStructured. */
|
|
662
|
+
function settledBriefEnvelope(body, meta) {
|
|
663
|
+
let brief = { ...meta, utf8_bytes: 0 };
|
|
664
|
+
let envelope = { ...body, brief };
|
|
665
|
+
for (let guard = 0; guard < 32; guard += 1) {
|
|
666
|
+
const bytes = briefUtf8Bytes(envelope);
|
|
667
|
+
if (brief.utf8_bytes === bytes)
|
|
668
|
+
return envelope;
|
|
669
|
+
brief = { ...brief, utf8_bytes: bytes };
|
|
670
|
+
envelope = { ...body, brief };
|
|
671
|
+
}
|
|
672
|
+
throw new Error("brief UTF-8 byte measurement did not settle");
|
|
673
|
+
}
|
|
674
|
+
export class BriefBudgetError extends Error {
|
|
675
|
+
budgetBytes;
|
|
676
|
+
minimumBytes;
|
|
677
|
+
constructor(budgetBytes, minimumBytes) {
|
|
678
|
+
super(`brief budget ${budgetBytes} bytes cannot contain the minimum routing envelope (${minimumBytes} bytes); increase the budget or use prime --context status`);
|
|
679
|
+
this.name = "BriefBudgetError";
|
|
680
|
+
this.budgetBytes = budgetBytes;
|
|
681
|
+
this.minimumBytes = minimumBytes;
|
|
682
|
+
}
|
|
683
|
+
}
|
|
684
|
+
function degradedBriefEnvelope(payload, budget, attemptedBytes, mode) {
|
|
685
|
+
const detailedMeta = {
|
|
686
|
+
budget_utf8_bytes: budget,
|
|
687
|
+
projection: "degraded",
|
|
688
|
+
attempted_utf8_bytes: attemptedBytes,
|
|
689
|
+
path_diagnostics_recovery: PATH_DIAGNOSTICS_RECOVERY,
|
|
690
|
+
omitted_rich_state: OMITTED_RICH_STATE.map((entry) => ({ ...entry })),
|
|
691
|
+
error: {
|
|
692
|
+
class: "brief_output_budget",
|
|
693
|
+
message: "the projected decision brief exceeded the authority byte budget; a bounded degraded envelope was emitted instead of the over-budget payload",
|
|
694
|
+
recovery: `Run \`${preCutoverCommand("prime --context status --format json")}\` for status startup, or \`${preCutoverCommand("state <artifact> list --format json")}\` for a specific record family.`,
|
|
695
|
+
},
|
|
696
|
+
};
|
|
697
|
+
const body = (projection) => mode === "status_routing"
|
|
698
|
+
? statusRoutingDegradedBody(payload, projection)
|
|
699
|
+
: degradedBody(payload, projection);
|
|
700
|
+
const detailed = settledBriefEnvelope(body("normal"), detailedMeta);
|
|
701
|
+
if (briefByteGate(detailed, budget).accepted)
|
|
702
|
+
return detailed;
|
|
703
|
+
// A smaller deterministic fallback drops the recovery catalog but retains the
|
|
704
|
+
// bounded state-presence and source-contract projections plus one recovery
|
|
705
|
+
// command. This is what lets a configured 7KB gate remain enforceable even
|
|
706
|
+
// when caller data would make the detailed degraded envelope too large.
|
|
707
|
+
const compactMeta = {
|
|
708
|
+
budget_utf8_bytes: budget,
|
|
709
|
+
projection: "degraded",
|
|
710
|
+
attempted_utf8_bytes: attemptedBytes,
|
|
711
|
+
path_diagnostics_recovery: PATH_DIAGNOSTICS_RECOVERY,
|
|
712
|
+
error: {
|
|
713
|
+
class: "brief_output_budget",
|
|
714
|
+
message: "the projected decision brief exceeded the authority byte budget; compact recovery metadata was emitted",
|
|
715
|
+
recovery: `Run \`${preCutoverCommand("prime --context status --format json")}\` for status startup.`,
|
|
716
|
+
},
|
|
717
|
+
};
|
|
718
|
+
const compact = settledBriefEnvelope(body("compact"), compactMeta);
|
|
719
|
+
if (briefByteGate(compact, budget).accepted)
|
|
720
|
+
return compact;
|
|
721
|
+
if (mode === "status_routing") {
|
|
722
|
+
const minimum = settledBriefEnvelope(body("irreducible"), compactMeta);
|
|
723
|
+
const minimumBytes = briefUtf8Bytes(minimum);
|
|
724
|
+
if (minimumBytes <= budget)
|
|
725
|
+
return minimum;
|
|
726
|
+
throw new BriefBudgetError(budget, minimumBytes);
|
|
727
|
+
}
|
|
728
|
+
// The irreducible form is intentionally finite and contains only the routing
|
|
729
|
+
// contract. If even this cannot fit, throwing is explicit: returning an
|
|
730
|
+
// over-budget JSON document would violate the public output contract.
|
|
731
|
+
const minimumMeta = {
|
|
732
|
+
budget_utf8_bytes: budget,
|
|
733
|
+
projection: "degraded",
|
|
734
|
+
attempted_utf8_bytes: attemptedBytes,
|
|
735
|
+
error: {
|
|
736
|
+
class: "brief_output_budget",
|
|
737
|
+
message: "the configured budget cannot contain the detailed recovery envelope",
|
|
738
|
+
recovery: `Increase the budget or run \`${preCutoverCommand("prime --context status --format json")}\`.`,
|
|
739
|
+
},
|
|
740
|
+
};
|
|
741
|
+
const minimum = settledBriefEnvelope(body("irreducible"), minimumMeta);
|
|
742
|
+
const minimumBytes = briefUtf8Bytes(minimum);
|
|
743
|
+
if (minimumBytes <= budget)
|
|
744
|
+
return minimum;
|
|
745
|
+
throw new BriefBudgetError(budget, minimumBytes);
|
|
746
|
+
}
|