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
|
@@ -0,0 +1,211 @@
|
|
|
1
|
+
import path from "node:path";
|
|
2
|
+
import { PROFILE_SIGNAL_TYPES, profileSufficiency, } from "../registries/evidenceTierContract.js";
|
|
3
|
+
import { readCurrentPointer, readSignalTier, resolveEvidenceAnchor, } from "./extractCorpus/evidenceTiers.js";
|
|
4
|
+
import { assessTiers, recoveryForState, resolveTiersDir, } from "./extractCorpus/tierReader.js";
|
|
5
|
+
const PROFILE_TYPES_SET = new Set(PROFILE_SIGNAL_TYPES);
|
|
6
|
+
/** Resolve the absolute signal tier file path from the current generation. */
|
|
7
|
+
function signalTierPath(tiersDir) {
|
|
8
|
+
const pointer = readCurrentPointer(tiersDir);
|
|
9
|
+
if (!pointer)
|
|
10
|
+
return null;
|
|
11
|
+
return path.join(tiersDir, "generations", pointer.generation, "signal.json");
|
|
12
|
+
}
|
|
13
|
+
/** Resolve the co-located corpus path for legacy compatibility assessment. */
|
|
14
|
+
function corpusPathFromTiersDir(tiersDir) {
|
|
15
|
+
const idx = tiersDir.lastIndexOf(path.sep + "tiers");
|
|
16
|
+
if (idx === -1)
|
|
17
|
+
return undefined;
|
|
18
|
+
return path.join(tiersDir.slice(0, idx), "corpus.json");
|
|
19
|
+
}
|
|
20
|
+
/**
|
|
21
|
+
* Assess whether the retained profile-relevant signal distribution is
|
|
22
|
+
* sufficient against the contract threshold. The prior intended distribution
|
|
23
|
+
* is reconstructed from the signal tier's selection report (total per
|
|
24
|
+
* family); the retained distribution from the published signal records.
|
|
25
|
+
* No separate full-corpus read is needed — the selection report carries both.
|
|
26
|
+
*
|
|
27
|
+
* When the tier is uncapped, retained == total, so the bounded and intended
|
|
28
|
+
* distributions are identical and sufficiency is trivially met. When capped,
|
|
29
|
+
* the selection report's per-family total/retained is the authoritative prior
|
|
30
|
+
* distribution; the profile-relevant intended count is scaled from the
|
|
31
|
+
* retained profile-relevant count by the family's overall retention ratio.
|
|
32
|
+
*/
|
|
33
|
+
export function assessProfileSufficiency(selection, signals, contractPath) {
|
|
34
|
+
const suff = profileSufficiency(contractPath);
|
|
35
|
+
const threshold = suff.minimumFamilyRetention;
|
|
36
|
+
const profileRetainedPerFamily = new Map();
|
|
37
|
+
for (const sig of signals) {
|
|
38
|
+
const family = sig.source_product || "unknown";
|
|
39
|
+
profileRetainedPerFamily.set(family, (profileRetainedPerFamily.get(family) ?? 0) + 1);
|
|
40
|
+
}
|
|
41
|
+
const profileIntendedPerFamily = new Map();
|
|
42
|
+
if (!selection.capped) {
|
|
43
|
+
// Uncapped: retained == intended, so the retained counts ARE the intended.
|
|
44
|
+
for (const [family, retained] of profileRetainedPerFamily) {
|
|
45
|
+
profileIntendedPerFamily.set(family, retained);
|
|
46
|
+
}
|
|
47
|
+
}
|
|
48
|
+
else {
|
|
49
|
+
// Capped: the selection report's per_family is the authoritative source
|
|
50
|
+
// of which families had records. For families with profile-relevant
|
|
51
|
+
// retained signals, scale the intended count by the family's overall
|
|
52
|
+
// retention ratio. For families where all records were capped
|
|
53
|
+
// (retained=0, total>0), flag them as insufficient — no data survived
|
|
54
|
+
// to contribute to the profile.
|
|
55
|
+
for (const sel of selection.per_family) {
|
|
56
|
+
if (sel.total === 0)
|
|
57
|
+
continue;
|
|
58
|
+
const profileRetained = profileRetainedPerFamily.get(sel.family) ?? 0;
|
|
59
|
+
if (sel.retained > 0 && profileRetained > 0) {
|
|
60
|
+
profileIntendedPerFamily.set(sel.family, Math.round(profileRetained * (sel.total / sel.retained)));
|
|
61
|
+
}
|
|
62
|
+
else if (sel.retained === 0 && sel.total > 0) {
|
|
63
|
+
// All records for this family were capped — insufficient by definition.
|
|
64
|
+
profileIntendedPerFamily.set(sel.family, sel.total);
|
|
65
|
+
}
|
|
66
|
+
// If sel.retained > 0 but profileRetained == 0, the family's retained
|
|
67
|
+
// records were simply non-profile-relevant; leave it as sufficient.
|
|
68
|
+
}
|
|
69
|
+
// Also include any family that appears in retained signals but not in the
|
|
70
|
+
// selection report (should not normally happen, but handle gracefully).
|
|
71
|
+
for (const [family, retained] of profileRetainedPerFamily) {
|
|
72
|
+
if (!profileIntendedPerFamily.has(family)) {
|
|
73
|
+
profileIntendedPerFamily.set(family, retained);
|
|
74
|
+
}
|
|
75
|
+
}
|
|
76
|
+
}
|
|
77
|
+
const perFamily = [];
|
|
78
|
+
const allFamilies = new Set([...profileIntendedPerFamily.keys(), ...profileRetainedPerFamily.keys()]);
|
|
79
|
+
for (const family of [...allFamilies].sort()) {
|
|
80
|
+
const intended = profileIntendedPerFamily.get(family) ?? 0;
|
|
81
|
+
const retained = profileRetainedPerFamily.get(family) ?? 0;
|
|
82
|
+
const retention = intended > 0 ? retained / intended : 1;
|
|
83
|
+
const sufficient = intended === 0 || retention >= threshold;
|
|
84
|
+
perFamily.push({ family, intended, retained, retention, sufficient });
|
|
85
|
+
}
|
|
86
|
+
const insufficientFamilies = perFamily.filter((f) => !f.sufficient);
|
|
87
|
+
const sufficient = !selection.capped || insufficientFamilies.length === 0;
|
|
88
|
+
const reason = sufficient
|
|
89
|
+
? selection.capped
|
|
90
|
+
? "signal tier capped but per-family retention meets threshold"
|
|
91
|
+
: "signal tier uncapped; bounded and intended distributions identical"
|
|
92
|
+
: `insufficient retention for families: ${insufficientFamilies.map((f) => `${f.family} (${f.retained}/${f.intended}, ${(f.retention * 100).toFixed(0)}%)`).join(", ")}`;
|
|
93
|
+
return { sufficient, reason, threshold, capped: selection.capped, per_family: perFamily };
|
|
94
|
+
}
|
|
95
|
+
/**
|
|
96
|
+
* Read the bounded signal tier and return profile-relevant signals with a
|
|
97
|
+
* sufficiency assessment. This is the bounded profile-synthesis input: it
|
|
98
|
+
* loads only the signal tier (bounded by construction), never the full-
|
|
99
|
+
* evidence shards. Each signal's `evidence_anchor` resolves to retained full
|
|
100
|
+
* evidence via resolveProfileEvidence.
|
|
101
|
+
*/
|
|
102
|
+
export function readProfileSignals(tiersDir, corpusPath, contractPath) {
|
|
103
|
+
const assessment = assessTiers(tiersDir, corpusPath);
|
|
104
|
+
const recovery = recoveryForState(assessment.state);
|
|
105
|
+
const threshold = profileSufficiency(contractPath).minimumFamilyRetention;
|
|
106
|
+
if (!assessment.analyzable) {
|
|
107
|
+
return {
|
|
108
|
+
state: assessment.state,
|
|
109
|
+
tiers_dir: tiersDir,
|
|
110
|
+
signal_path: null,
|
|
111
|
+
signals: [],
|
|
112
|
+
profile_signal_count: 0,
|
|
113
|
+
sufficiency: {
|
|
114
|
+
sufficient: false,
|
|
115
|
+
reason: assessment.state === "missing"
|
|
116
|
+
? "no evidence tiers published"
|
|
117
|
+
: assessment.state === "legacy"
|
|
118
|
+
? "legacy monolithic state; refresh required"
|
|
119
|
+
: `tier state ${assessment.state}; ${recovery ?? "recovery unavailable"}`,
|
|
120
|
+
threshold,
|
|
121
|
+
capped: false,
|
|
122
|
+
per_family: [],
|
|
123
|
+
},
|
|
124
|
+
recovery,
|
|
125
|
+
};
|
|
126
|
+
}
|
|
127
|
+
const tier = readSignalTier(tiersDir);
|
|
128
|
+
if (!tier) {
|
|
129
|
+
return {
|
|
130
|
+
state: "corrupt",
|
|
131
|
+
tiers_dir: tiersDir,
|
|
132
|
+
signal_path: null,
|
|
133
|
+
signals: [],
|
|
134
|
+
profile_signal_count: 0,
|
|
135
|
+
sufficiency: {
|
|
136
|
+
sufficient: false,
|
|
137
|
+
reason: "signal tier unreadable or not found",
|
|
138
|
+
threshold,
|
|
139
|
+
capped: false,
|
|
140
|
+
per_family: [],
|
|
141
|
+
},
|
|
142
|
+
recovery,
|
|
143
|
+
};
|
|
144
|
+
}
|
|
145
|
+
const profileSignals = tier.records.filter((s) => PROFILE_TYPES_SET.has(s.signal_type));
|
|
146
|
+
const sufficiency = assessProfileSufficiency(tier.manifest.signal.selection, profileSignals, contractPath);
|
|
147
|
+
return {
|
|
148
|
+
state: assessment.state,
|
|
149
|
+
tiers_dir: tiersDir,
|
|
150
|
+
signal_path: signalTierPath(tiersDir),
|
|
151
|
+
signals: profileSignals,
|
|
152
|
+
profile_signal_count: profileSignals.length,
|
|
153
|
+
sufficiency,
|
|
154
|
+
recovery,
|
|
155
|
+
};
|
|
156
|
+
}
|
|
157
|
+
/**
|
|
158
|
+
* Resolve a synthesized claim's evidence anchor to its retained full-evidence
|
|
159
|
+
* record. Loads only the owning shard, never the whole tier. Returns null
|
|
160
|
+
* when the anchor does not resolve (the claim cannot be checked).
|
|
161
|
+
*/
|
|
162
|
+
export function resolveProfileEvidence(anchor, tiersDir) {
|
|
163
|
+
return resolveEvidenceAnchor(anchor, tiersDir);
|
|
164
|
+
}
|
|
165
|
+
/**
|
|
166
|
+
* Lightweight status for profile_context — assesses the tiers, reads the
|
|
167
|
+
* signal tier, and computes sufficiency. The signal records are counted but
|
|
168
|
+
* not returned in the status payload (the synthesis step reads them via
|
|
169
|
+
* readProfileSignals or the signal_path). This status tells the agent
|
|
170
|
+
* whether synthesis can proceed and where to read.
|
|
171
|
+
*/
|
|
172
|
+
export function profileSignalsStatus(env = process.env, platform = process.platform, contractPath) {
|
|
173
|
+
const tiersDir = resolveTiersDir(env, platform);
|
|
174
|
+
const corpusPath = corpusPathFromTiersDir(tiersDir);
|
|
175
|
+
const assessment = assessTiers(tiersDir, corpusPath);
|
|
176
|
+
const recovery = recoveryForState(assessment.state);
|
|
177
|
+
if (!assessment.analyzable) {
|
|
178
|
+
return {
|
|
179
|
+
state: assessment.state,
|
|
180
|
+
tiers_dir: tiersDir,
|
|
181
|
+
signal_path: null,
|
|
182
|
+
signal_count: 0,
|
|
183
|
+
profile_signal_count: 0,
|
|
184
|
+
sufficiency: null,
|
|
185
|
+
recovery,
|
|
186
|
+
};
|
|
187
|
+
}
|
|
188
|
+
const tier = readSignalTier(tiersDir);
|
|
189
|
+
if (!tier) {
|
|
190
|
+
return {
|
|
191
|
+
state: "corrupt",
|
|
192
|
+
tiers_dir: tiersDir,
|
|
193
|
+
signal_path: null,
|
|
194
|
+
signal_count: 0,
|
|
195
|
+
profile_signal_count: 0,
|
|
196
|
+
sufficiency: null,
|
|
197
|
+
recovery,
|
|
198
|
+
};
|
|
199
|
+
}
|
|
200
|
+
const profileSignals = tier.records.filter((s) => PROFILE_TYPES_SET.has(s.signal_type));
|
|
201
|
+
const sufficiency = assessProfileSufficiency(tier.manifest.signal.selection, profileSignals, contractPath);
|
|
202
|
+
return {
|
|
203
|
+
state: assessment.state,
|
|
204
|
+
tiers_dir: tiersDir,
|
|
205
|
+
signal_path: signalTierPath(tiersDir),
|
|
206
|
+
signal_count: tier.records.length,
|
|
207
|
+
profile_signal_count: profileSignals.length,
|
|
208
|
+
sufficiency,
|
|
209
|
+
recovery,
|
|
210
|
+
};
|
|
211
|
+
}
|
|
@@ -1,10 +1,13 @@
|
|
|
1
1
|
import fs from "node:fs";
|
|
2
2
|
import os from "node:os";
|
|
3
3
|
import path from "node:path";
|
|
4
|
+
import { resolveProfileDirOverride, resolveXdgDataHome } from "../core/envPaths.js";
|
|
5
|
+
import { expanduser } from "../core/paths.js";
|
|
6
|
+
import { tiersDirForCorpusPath, assessTiers, iterBoundedRecords, readTierCorpusMetadata } from "./extractCorpus/index.js";
|
|
4
7
|
export const EXIT_STATUSES = new Set(["complete", "flagged", "stuck", "waiting"]);
|
|
5
8
|
export const TRIGGER_SLASH = "slash";
|
|
6
9
|
export const TRIGGER_NATURAL = "natural";
|
|
7
|
-
const MARKER_RE = /─{2,}\s+(\S)\s+(
|
|
10
|
+
const MARKER_RE = /─{2,}\s+(\S)\s+(status|vision|discuss|research|plan|build|optimize|audit|document|profile|design|orchestrate)\s+·\s+([a-z]+(?:\s+\d+)?)\s+─{2,}/g;
|
|
8
11
|
function newInvocation(init) {
|
|
9
12
|
return {
|
|
10
13
|
skill: init.skill,
|
|
@@ -18,6 +21,9 @@ function newInvocation(init) {
|
|
|
18
21
|
exit_timestamp: init.exit_timestamp ?? null,
|
|
19
22
|
trigger: init.trigger ?? TRIGGER_NATURAL,
|
|
20
23
|
project_id: init.project_id ?? "",
|
|
24
|
+
source_class: init.source_class ?? "active_runtime",
|
|
25
|
+
source_product: init.source_product ?? "unknown",
|
|
26
|
+
active_runtime: init.active_runtime ?? true,
|
|
21
27
|
};
|
|
22
28
|
}
|
|
23
29
|
export function findMarkers(text) {
|
|
@@ -101,7 +107,7 @@ export function pairInvocations(turns) {
|
|
|
101
107
|
for (const turn of turns) {
|
|
102
108
|
const sid = String(turn.source_id ?? "");
|
|
103
109
|
const ts = String(turn.timestamp ?? "");
|
|
104
|
-
const text = (isMapping(turn.data) ? turn.data.content : "") || "";
|
|
110
|
+
const text = ((isMapping(turn.data) ? turn.data.content : "") || ""); // cast: corpus record content from JSON.parse IO boundary
|
|
105
111
|
for (const marker of findMarkers(text)) {
|
|
106
112
|
if (marker.kind === "intro") {
|
|
107
113
|
if (!pending.has(marker.skill))
|
|
@@ -113,6 +119,9 @@ export function pairInvocations(turns) {
|
|
|
113
119
|
intro_source_id: sid,
|
|
114
120
|
intro_timestamp: ts,
|
|
115
121
|
completed: false,
|
|
122
|
+
source_class: String(turn.source_class ?? "active_runtime"),
|
|
123
|
+
source_product: String(turn.source_product ?? turn.runtime ?? "unknown"),
|
|
124
|
+
active_runtime: turn.active_runtime !== false && turn.source_class !== "historical_import",
|
|
116
125
|
}));
|
|
117
126
|
}
|
|
118
127
|
else {
|
|
@@ -150,12 +159,13 @@ function stableSort(items, key) {
|
|
|
150
159
|
})
|
|
151
160
|
.map(([item]) => item);
|
|
152
161
|
}
|
|
153
|
-
|
|
162
|
+
// Retained only to classify command markup in consent-gated historical imports.
|
|
163
|
+
const HISTORICAL_COMMAND_XML_RE = /<command-name>\s*\/[A-Za-z0-9._:-]+\s*<\/command-name>/;
|
|
154
164
|
const BARE_SLASH_RE = /^\s*\/[A-Za-z0-9._:-]+(?:\s|$)/m;
|
|
155
165
|
export function classifyTrigger(userTurnText) {
|
|
156
166
|
if (!userTurnText)
|
|
157
167
|
return TRIGGER_NATURAL;
|
|
158
|
-
if (
|
|
168
|
+
if (HISTORICAL_COMMAND_XML_RE.test(userTurnText))
|
|
159
169
|
return TRIGGER_SLASH;
|
|
160
170
|
if (BARE_SLASH_RE.test(userTurnText))
|
|
161
171
|
return TRIGGER_SLASH;
|
|
@@ -226,13 +236,70 @@ function accumulate(bucket, inv) {
|
|
|
226
236
|
bucket[inv.completed ? "completed" : "incomplete"] += 1;
|
|
227
237
|
bucket[inv.trigger === TRIGGER_SLASH ? "trigger_slash" : "trigger_natural"] += 1;
|
|
228
238
|
}
|
|
229
|
-
|
|
230
|
-
|
|
231
|
-
|
|
232
|
-
|
|
233
|
-
|
|
239
|
+
function activeAnalyticsRecord(record) {
|
|
240
|
+
if (record.active_runtime === false || record.source_class === "historical_import")
|
|
241
|
+
return false;
|
|
242
|
+
return record.runtime !== "claude" && record.runtime !== "claude-code";
|
|
243
|
+
}
|
|
244
|
+
export function analyzeCorpus(corpus, projectFilter = null, sourceView = "active") {
|
|
245
|
+
const rawRecords = (isMapping(corpus) ? (corpus.records ?? []) : []); // cast: corpus records from JSON.parse IO boundary
|
|
246
|
+
return analyzeRecords(rawRecords, projectFilter, sourceView);
|
|
247
|
+
}
|
|
248
|
+
/**
|
|
249
|
+
* Single-pass analysis over a record iterable. Bounded consumers feed the
|
|
250
|
+
* tiered shard iterator here so non-conversation records (instruction documents,
|
|
251
|
+
* project config signals, tool calls) are counted for provenance and discarded
|
|
252
|
+
* rather than materialized; only conversation turns are retained as the analysis
|
|
253
|
+
* working set. Mirrors `analyzeCorpus` exactly when given the full record array.
|
|
254
|
+
*/
|
|
255
|
+
export function analyzeRecords(records, projectFilter = null, sourceView = "active") {
|
|
256
|
+
const provenanceCounts = new Map();
|
|
257
|
+
const userTurnsByConv = new Map();
|
|
258
|
+
const assistantByConv = new Map();
|
|
259
|
+
for (const record of records) {
|
|
260
|
+
if (!isMapping(record))
|
|
261
|
+
continue;
|
|
262
|
+
const isActive = activeAnalyticsRecord(record);
|
|
263
|
+
if (sourceView === "active" && !isActive)
|
|
264
|
+
continue;
|
|
265
|
+
if (projectFilter !== null) {
|
|
266
|
+
const pid = record.project_id ?? "";
|
|
267
|
+
if (!(typeof pid === "string" && projectMatch(pid, projectFilter)))
|
|
268
|
+
continue;
|
|
269
|
+
}
|
|
270
|
+
const sourceClass = String(record.source_class ?? (isActive ? "active_runtime" : "historical_import"));
|
|
271
|
+
const sourceProduct = String(record.source_product ?? record.runtime ?? "unknown");
|
|
272
|
+
const activeRuntime = isActive;
|
|
273
|
+
const key = `${sourceClass}\0${sourceProduct}\0${activeRuntime}`;
|
|
274
|
+
const current = provenanceCounts.get(key) ?? { source_class: sourceClass, source_product: sourceProduct, active_runtime: activeRuntime, records: 0 };
|
|
275
|
+
current.records += 1;
|
|
276
|
+
provenanceCounts.set(key, current);
|
|
277
|
+
if (record.source_kind !== "conversation_turn")
|
|
278
|
+
continue;
|
|
279
|
+
const data = record.data;
|
|
280
|
+
if (!isMapping(data))
|
|
281
|
+
continue;
|
|
282
|
+
const ckey = conversationKey(record);
|
|
283
|
+
if (ckey === null)
|
|
284
|
+
continue;
|
|
285
|
+
const actor = data.actor;
|
|
286
|
+
if (actor === "user") {
|
|
287
|
+
if (!userTurnsByConv.has(ckey))
|
|
288
|
+
userTurnsByConv.set(ckey, []);
|
|
289
|
+
userTurnsByConv.get(ckey).push(record);
|
|
290
|
+
}
|
|
291
|
+
else if (actor === "assistant") {
|
|
292
|
+
if (!assistantByConv.has(ckey))
|
|
293
|
+
assistantByConv.set(ckey, []);
|
|
294
|
+
assistantByConv.get(ckey).push(record);
|
|
295
|
+
}
|
|
296
|
+
}
|
|
297
|
+
for (const items of userTurnsByConv.values())
|
|
298
|
+
stableSortByTimestamp(items);
|
|
299
|
+
for (const items of assistantByConv.values())
|
|
300
|
+
stableSortByTimestamp(items);
|
|
234
301
|
const invocations = [];
|
|
235
|
-
for (const [sid, turns] of
|
|
302
|
+
for (const [sid, turns] of assistantByConv) {
|
|
236
303
|
const tsToProject = new Map();
|
|
237
304
|
for (const t of turns) {
|
|
238
305
|
tsToProject.set(String(t.timestamp ?? ""), String(t.project_id ?? ""));
|
|
@@ -243,7 +310,7 @@ export function analyzeCorpus(corpus, projectFilter = null) {
|
|
|
243
310
|
let precedingText = "";
|
|
244
311
|
if (preceding !== null) {
|
|
245
312
|
const data = isMapping(preceding.data) ? preceding.data : {};
|
|
246
|
-
precedingText = data.content || "";
|
|
313
|
+
precedingText = (data.content || ""); // cast: corpus record content from JSON.parse IO boundary
|
|
247
314
|
}
|
|
248
315
|
inv.trigger = classifyTrigger(precedingText);
|
|
249
316
|
invocations.push(inv);
|
|
@@ -264,34 +331,40 @@ export function analyzeCorpus(corpus, projectFilter = null) {
|
|
|
264
331
|
accumulate(perProject[inv.project_id][inv.skill], inv);
|
|
265
332
|
}
|
|
266
333
|
}
|
|
267
|
-
return {
|
|
334
|
+
return {
|
|
335
|
+
invocations: sorted,
|
|
336
|
+
skills,
|
|
337
|
+
project_filter: projectFilter,
|
|
338
|
+
per_project: perProject,
|
|
339
|
+
source_view: sourceView,
|
|
340
|
+
source_provenance: [...provenanceCounts.values()].sort((a, b) => `${a.source_class}:${a.source_product}`.localeCompare(`${b.source_class}:${b.source_product}`)),
|
|
341
|
+
};
|
|
268
342
|
}
|
|
269
343
|
// --- Paths -----------------------------------------------------------------
|
|
270
|
-
export const CORPUS_GUIDANCE = "
|
|
344
|
+
export const CORPUS_GUIDANCE = "Publish bounded tiers with `agentera stats refresh --consent local-history`; `--corpus PATH` points at a legacy corpus.json whose sibling `tiers/` is preferred when published.";
|
|
271
345
|
function homeDir(env) {
|
|
272
346
|
return env.HOME ?? os.homedir();
|
|
273
347
|
}
|
|
274
348
|
export function defaultUsageDir(env = process.env, platform = process.platform) {
|
|
275
349
|
const override = env.AGENTERA_USAGE_DIR;
|
|
276
350
|
if (override)
|
|
277
|
-
return override;
|
|
278
|
-
const
|
|
279
|
-
if (
|
|
280
|
-
return
|
|
351
|
+
return expanduser(override);
|
|
352
|
+
const profileOverride = resolveProfileDirOverride(env);
|
|
353
|
+
if (profileOverride)
|
|
354
|
+
return expanduser(profileOverride);
|
|
281
355
|
const home = homeDir(env);
|
|
282
356
|
if (platform === "darwin")
|
|
283
357
|
return path.join(home, "Library", "Application Support", "agentera");
|
|
284
358
|
if (platform === "win32") {
|
|
285
359
|
const appdata = env.APPDATA ?? path.join(home, "AppData", "Roaming");
|
|
286
|
-
return path.join(appdata, "agentera");
|
|
360
|
+
return path.join(expanduser(appdata), "agentera");
|
|
287
361
|
}
|
|
288
|
-
|
|
289
|
-
return path.join(xdg, "agentera");
|
|
362
|
+
return path.join(resolveXdgDataHome(env, home), "agentera");
|
|
290
363
|
}
|
|
291
364
|
export function defaultCorpusPath(env = process.env, platform = process.platform) {
|
|
292
|
-
const
|
|
293
|
-
if (
|
|
294
|
-
return path.join(
|
|
365
|
+
const profileOverride = resolveProfileDirOverride(env);
|
|
366
|
+
if (profileOverride)
|
|
367
|
+
return path.join(expanduser(profileOverride), "intermediate", "corpus.json");
|
|
295
368
|
const home = homeDir(env);
|
|
296
369
|
let base;
|
|
297
370
|
if (platform === "darwin") {
|
|
@@ -299,11 +372,10 @@ export function defaultCorpusPath(env = process.env, platform = process.platform
|
|
|
299
372
|
}
|
|
300
373
|
else if (platform === "win32") {
|
|
301
374
|
const appdata = env.APPDATA ?? path.join(home, "AppData", "Roaming");
|
|
302
|
-
base = path.join(appdata, "agentera");
|
|
375
|
+
base = path.join(expanduser(appdata), "agentera");
|
|
303
376
|
}
|
|
304
377
|
else {
|
|
305
|
-
|
|
306
|
-
base = path.join(xdg, "agentera");
|
|
378
|
+
base = path.join(resolveXdgDataHome(env, home), "agentera");
|
|
307
379
|
}
|
|
308
380
|
return path.join(base, "intermediate", "corpus.json");
|
|
309
381
|
}
|
|
@@ -319,7 +391,7 @@ export function corpusTooLargeReason(corpusPath) {
|
|
|
319
391
|
const size = fs.statSync(corpusPath).size;
|
|
320
392
|
if (size <= MAX_CORPUS_READ_BYTES)
|
|
321
393
|
return null;
|
|
322
|
-
return `corpus is too large to load (${size} bytes; max ${MAX_CORPUS_READ_BYTES}).
|
|
394
|
+
return `corpus is too large to load (${size} bytes; max ${MAX_CORPUS_READ_BYTES}). Refresh bounded tiers with agentera stats refresh --consent local-history, or pass --corpus PATH to a smaller legacy extract (its sibling tiers/ is preferred when published).`;
|
|
323
395
|
}
|
|
324
396
|
catch {
|
|
325
397
|
return null;
|
|
@@ -340,18 +412,20 @@ export function loadCorpusOrRaise(corpusPath) {
|
|
|
340
412
|
catch (exc) {
|
|
341
413
|
throw new CorpusUnavailable(`corpus is not readable JSON: ${exc.message}`);
|
|
342
414
|
}
|
|
343
|
-
const records = isMapping(corpus) ? (corpus.records ?? []) : [];
|
|
415
|
+
const records = (isMapping(corpus) ? (corpus.records ?? []) : []); // cast: corpus records from JSON.parse IO boundary
|
|
344
416
|
const hasTurn = Array.isArray(records) && records.some((r) => isMapping(r) && r.source_kind === "conversation_turn");
|
|
345
417
|
if (!hasTurn) {
|
|
346
418
|
throw new CorpusUnavailable(`corpus at ${corpusPath} contains no conversation_turn records. ${CORPUS_GUIDANCE}`);
|
|
347
419
|
}
|
|
348
|
-
return corpus;
|
|
420
|
+
return corpus; // cast: corpus from JSON.parse IO boundary
|
|
349
421
|
}
|
|
350
422
|
export function buildJsonPayload(analysis, opts) {
|
|
351
423
|
return {
|
|
352
424
|
generated_at: opts.generatedAt,
|
|
353
425
|
extracted_at: opts.extractedAt,
|
|
354
426
|
project_filter: analysis.project_filter,
|
|
427
|
+
source_view: analysis.source_view,
|
|
428
|
+
source_provenance: analysis.source_provenance,
|
|
355
429
|
skills: analysis.skills,
|
|
356
430
|
per_project: analysis.per_project,
|
|
357
431
|
invocations: analysis.invocations.map((inv) => ({ ...inv })),
|
|
@@ -381,7 +455,10 @@ export function renderMarkdown(analysis, opts) {
|
|
|
381
455
|
const scope = analysis.project_filter || "all projects";
|
|
382
456
|
const extractedLine = opts.extractedAt || "unknown (corpus omitted extracted_at)";
|
|
383
457
|
const lines = [];
|
|
384
|
-
lines.push("# Suite Usage", "", `- Generated: ${opts.generatedAt}`, `- Corpus extracted: ${extractedLine}`, `- Scope: ${scope}`, "");
|
|
458
|
+
lines.push("# Suite Usage", "", `- Generated: ${opts.generatedAt}`, `- Corpus extracted: ${extractedLine}`, `- Scope: ${scope}`, `- Sources: ${analysis.source_view}`, "");
|
|
459
|
+
if (analysis.source_view === "all") {
|
|
460
|
+
lines.push("## Source provenance", "", "| Source class | Source product | Active runtime | Records |", "| --- | --- | --- | --- |", ...analysis.source_provenance.map((item) => `| ${item.source_class} | ${item.source_product} | ${item.active_runtime ? "yes" : "no"} | ${item.records} |`), "");
|
|
461
|
+
}
|
|
385
462
|
if (Object.keys(analysis.skills).length === 0) {
|
|
386
463
|
lines.push("No skill invocations found in the corpus for this scope.", "");
|
|
387
464
|
return lines.join("\n");
|
|
@@ -468,6 +545,7 @@ export function usageMain(argv, io = {}) {
|
|
|
468
545
|
let corpus = null;
|
|
469
546
|
let project = null;
|
|
470
547
|
let emitJson = false;
|
|
548
|
+
let sourceView = "active";
|
|
471
549
|
for (let i = 0; i < argv.length; i++) {
|
|
472
550
|
const a = argv[i];
|
|
473
551
|
if (a === "--corpus")
|
|
@@ -480,23 +558,61 @@ export function usageMain(argv, io = {}) {
|
|
|
480
558
|
project = a.slice("--project=".length);
|
|
481
559
|
else if (a === "--json")
|
|
482
560
|
emitJson = true;
|
|
561
|
+
else if (a === "--sources" || a.startsWith("--sources=")) {
|
|
562
|
+
const value = a === "--sources" ? argv[++i] : a.slice("--sources=".length);
|
|
563
|
+
if (value !== "active" && value !== "all") {
|
|
564
|
+
err(`usage_stats: unsupported --sources '${value}'; choose active or all`);
|
|
565
|
+
return 2;
|
|
566
|
+
}
|
|
567
|
+
sourceView = value;
|
|
568
|
+
}
|
|
483
569
|
}
|
|
484
570
|
const corpusPath = corpus ?? defaultCorpusPath(env, platform);
|
|
485
|
-
|
|
486
|
-
|
|
487
|
-
|
|
488
|
-
|
|
489
|
-
|
|
490
|
-
|
|
491
|
-
|
|
571
|
+
// Bounded tier path: analyze real-scale evidence by streaming one bounded
|
|
572
|
+
// shard at a time instead of materializing the monolithic corpus envelope.
|
|
573
|
+
// Falls back to the legacy corpus.json read only when no tiers were published
|
|
574
|
+
// (legacy state) so existing small-envelope consumers keep working.
|
|
575
|
+
const tiersDir = tiersDirForCorpusPath(corpusPath);
|
|
576
|
+
const assessment = assessTiers(tiersDir, corpusPath);
|
|
577
|
+
let analysis;
|
|
578
|
+
let extractedAt = null;
|
|
579
|
+
if (assessment.analyzable) {
|
|
580
|
+
const records = iterBoundedRecords(tiersDir);
|
|
581
|
+
if (records === null) {
|
|
582
|
+
err(tierUnavailableMessage(assessment, corpusPath));
|
|
492
583
|
return 2;
|
|
493
584
|
}
|
|
494
|
-
|
|
585
|
+
analysis = analyzeRecords(records, project, sourceView);
|
|
586
|
+
const metadata = readTierCorpusMetadata(tiersDir);
|
|
587
|
+
extractedAt = metadata?.extracted_at ?? null;
|
|
588
|
+
}
|
|
589
|
+
else if (assessment.state === "corrupt" || assessment.state === "oversized") {
|
|
590
|
+
// Tier-level failure: the published tier is unreadable or a shard exceeds the
|
|
591
|
+
// reader cap. Project actionable recovery from the authority contract rather
|
|
592
|
+
// than silently falling back to the corpus envelope.
|
|
593
|
+
err(tierUnavailableMessage(assessment, corpusPath));
|
|
594
|
+
return 2;
|
|
595
|
+
}
|
|
596
|
+
else {
|
|
597
|
+
// Legacy or missing: delegate to the corpus-envelope reader, which preserves
|
|
598
|
+
// the existing too-large / not-found degradation and message contract.
|
|
599
|
+
let corpusData;
|
|
600
|
+
try {
|
|
601
|
+
corpusData = loadCorpusOrRaise(corpusPath);
|
|
602
|
+
}
|
|
603
|
+
catch (e) {
|
|
604
|
+
if (e instanceof CorpusUnavailable) {
|
|
605
|
+
err(String(e.message));
|
|
606
|
+
return 2;
|
|
607
|
+
}
|
|
608
|
+
throw e;
|
|
609
|
+
}
|
|
610
|
+
analysis = analyzeCorpus(corpusData, project, sourceView);
|
|
611
|
+
const md = corpusData.metadata;
|
|
612
|
+
extractedAt =
|
|
613
|
+
md && typeof md === "object" && !Array.isArray(md) ? (md.extracted_at ?? null) : null;
|
|
495
614
|
}
|
|
496
|
-
const analysis = analyzeCorpus(corpusData, project);
|
|
497
615
|
const generatedAt = nowIso();
|
|
498
|
-
const md = corpusData.metadata;
|
|
499
|
-
const extractedAt = md && typeof md === "object" && !Array.isArray(md) ? (md.extracted_at ?? null) : null;
|
|
500
616
|
if (emitJson) {
|
|
501
617
|
out(renderJson(analysis, { generatedAt, extractedAt }));
|
|
502
618
|
return 0;
|
|
@@ -506,4 +622,15 @@ export function usageMain(argv, io = {}) {
|
|
|
506
622
|
out(renderStdoutSummary(analysis, { generatedAt, extractedAt, reportPath: outPath }));
|
|
507
623
|
return 0;
|
|
508
624
|
}
|
|
509
|
-
|
|
625
|
+
/** Compose the degrade message for a non-analyzable tier state. */
|
|
626
|
+
function tierUnavailableMessage(assessment, corpusPath) {
|
|
627
|
+
const recovery = assessment.recovery;
|
|
628
|
+
const where = `tiers at ${assessment.tiersDir}${corpusPath ? ` (corpus=${corpusPath})` : ""}`;
|
|
629
|
+
if (assessment.state === "oversized") {
|
|
630
|
+
return `evidence tier is oversized at ${assessment.artifact ?? where}. ${recovery ?? ""}`.trim();
|
|
631
|
+
}
|
|
632
|
+
if (assessment.state === "corrupt") {
|
|
633
|
+
return `evidence tier is unreadable at ${where}. ${recovery ?? ""}`.trim();
|
|
634
|
+
}
|
|
635
|
+
return `evidence tier is ${assessment.state} at ${where}. ${recovery ?? ""}`.trim();
|
|
636
|
+
}
|