agentera 3.0.0-dev.7 → 3.0.0-dev.74
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 +229 -22
- package/bundle/.agentera-build-source.json +8 -0
- 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 +484 -0
- package/bundle/references/adapters/package-registry.yaml +439 -188
- package/bundle/references/adapters/package-surface-characterization.md +68 -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 +559 -0
- package/bundle/references/analysis/personal-glossary-evaluation-authority.yaml +175 -0
- package/bundle/references/analysis/personal-glossary-evaluation-corpus.yaml +291 -0
- package/bundle/references/analysis/personal-glossary-holdout.yaml +192 -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 +2752 -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 +6 -4
- package/bundle/references/cli/vocabulary-index.yaml +5 -7
- package/bundle/references/cli/vocabulary.md +52 -94
- package/bundle/references/meta/retained-reference-authority.yaml +166 -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 +13 -4
- package/bundle/skills/agentera/capabilities/profile/schemas/exit.yaml +8 -5
- package/bundle/skills/agentera/capabilities/profile/schemas/triggers.yaml +8 -37
- package/bundle/skills/agentera/capabilities/profile/schemas/validation.yaml +67 -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 +87 -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 +464 -32
- package/bundle/skills/agentera/schemas/artifacts/progress.yaml +131 -18
- package/bundle/skills/agentera/schemas/artifacts/todo.yaml +302 -7
- package/dist/.agentera-build-source.json +8 -0
- package/dist/analytics/extractCorpus/cli.js +52 -11
- package/dist/analytics/extractCorpus/copilotSessions.js +19 -8
- package/dist/analytics/extractCorpus/core.js +262 -14
- package/dist/analytics/extractCorpus/corpus.js +57 -18
- package/dist/analytics/extractCorpus/coverageAudit.js +44 -45
- package/dist/analytics/extractCorpus/cursorSessions.js +28 -8
- package/dist/analytics/extractCorpus/evidenceTiers.js +709 -0
- package/dist/analytics/extractCorpus/extractCorpusParity.js +4 -4
- package/dist/analytics/extractCorpus/filesystemSources.js +5 -5
- package/dist/analytics/extractCorpus/index.js +4 -2
- package/dist/analytics/extractCorpus/jsonlSessions.js +76 -8
- package/dist/analytics/extractCorpus/sqliteCaps.js +0 -1
- package/dist/analytics/extractCorpus/sqliteSessions.js +12 -4
- 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 +113 -0
- package/dist/analytics/personalGlossaryCandidateProjection.js +692 -0
- package/dist/analytics/personalGlossaryCandidateProjectionExcerpts.js +144 -0
- package/dist/analytics/personalGlossaryCandidateReadView.js +23 -0
- package/dist/analytics/personalGlossaryCurrentGeneration.js +25 -0
- package/dist/analytics/personalGlossaryDecision.js +203 -0
- package/dist/analytics/personalGlossaryExplicit.js +788 -0
- package/dist/analytics/personalGlossaryExplicitMining.js +285 -0
- package/dist/analytics/personalGlossaryExplicitScope.js +41 -0
- package/dist/analytics/personalGlossaryExplicitSegments.js +418 -0
- package/dist/analytics/personalGlossaryExplicitTypes.js +26 -0
- package/dist/analytics/personalGlossaryLexicalClassifier.js +175 -0
- package/dist/analytics/personalGlossaryProfile.js +229 -0
- package/dist/analytics/personalGlossaryRecurrence.js +618 -0
- package/dist/analytics/personalGlossaryReviewRecordStorage.js +428 -0
- package/dist/analytics/personalGlossaryReviewRecords.js +332 -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 +20 -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 +104 -5
- 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/personalGlossaryCandidateReads.js +744 -0
- package/dist/cli/commands/personalGlossaryDecision.js +349 -0
- package/dist/cli/commands/personalGlossaryPublish.js +484 -0
- package/dist/cli/commands/personalGlossaryReviewRecordReads.js +209 -0
- package/dist/cli/commands/personalGlossaryReviewRecords.js +623 -0
- package/dist/cli/commands/prime/briefOrientation.js +845 -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 +91 -21
- package/dist/cli/commands/route.js +142 -0
- package/dist/cli/commands/schema.js +436 -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 +73 -16
- 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 +162 -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 +404 -39
- package/dist/cli/migrationRequired.js +125 -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 +23 -0
- package/dist/core/developmentChannel.js +1 -0
- package/dist/core/developmentInvocation.js +377 -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 +61 -2
- package/dist/eval/evalSkills.js +13 -14
- package/dist/eval/glossaryEvaluation.js +751 -0
- package/dist/eval/glossaryEvaluationProcess.js +29 -0
- package/dist/eval/glossaryEvaluationRunner.js +571 -0
- package/dist/eval/glossaryEvaluationSuccessReport.js +297 -0
- 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 +136 -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 +375 -0
- package/dist/registries/explicitSegmentGrammarContract.js +619 -0
- package/dist/registries/glossaryAdviceContract.js +79 -0
- package/dist/registries/glossaryCandidateContractPaths.js +6 -0
- package/dist/registries/glossaryCandidateContracts.js +820 -0
- package/dist/registries/glossaryCandidateDecisionAuthority.js +119 -0
- package/dist/registries/glossaryCandidateDecisionContract.js +62 -0
- package/dist/registries/glossaryCandidateProjectionAuthority.js +197 -0
- package/dist/registries/glossaryCandidateProjectionContract.js +104 -0
- package/dist/registries/glossaryCaveatContract.js +67 -0
- package/dist/registries/glossaryConsumerContractValidation.js +787 -0
- package/dist/registries/glossaryEntryContract.js +759 -0
- package/dist/registries/glossaryEntryTemporal.js +12 -0
- package/dist/registries/glossaryMiningAuthority.js +764 -0
- package/dist/registries/glossaryProfileFullContract.js +24 -0
- package/dist/registries/glossaryReviewRecordsAuthority.js +426 -0
- package/dist/registries/glossaryReviewRecordsContract.js +129 -0
- package/dist/registries/glossaryTermIdentity.js +139 -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/personalGlossaryContracts.js +1 -0
- 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 +167 -10
- 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 +2 -2
- package/dist/upgrade/projectIntegration.js +128 -160
- 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 +866 -0
- package/dist/validate/activationArtifactEvidenceTypes.js +12 -0
- package/dist/validate/activationConjunction.js +816 -0
- package/dist/validate/activationEvidenceManifest.js +610 -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 +39 -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,788 @@
|
|
|
1
|
+
import { loadYamlMappingFile } from "../core/yaml.js";
|
|
2
|
+
import { glossaryEntryAuthorityPath } from "../registries/glossaryEntryContract.js";
|
|
3
|
+
import { loadExplicitSegmentGrammarContract } from "../registries/explicitSegmentGrammarContract.js";
|
|
4
|
+
import { compareGlossaryUnicodeStrings, stableGlossaryTermIdentity, } from "../registries/glossaryTermIdentity.js";
|
|
5
|
+
import { EXPLICIT_GLOSSARY_REASONS, } from "./personalGlossaryExplicitTypes.js";
|
|
6
|
+
import { segmentAndBindExplicitCues } from "./personalGlossaryExplicitSegments.js";
|
|
7
|
+
import { adjacentScopeTexts, contextText } from "./personalGlossaryExplicitScope.js";
|
|
8
|
+
export * from "./personalGlossaryExplicitTypes.js";
|
|
9
|
+
const OPEN_TO_CLOSE = new Map([
|
|
10
|
+
['"', '"'],
|
|
11
|
+
["'", "'"],
|
|
12
|
+
["`", "`"],
|
|
13
|
+
["“", "”"],
|
|
14
|
+
["‘", "’"],
|
|
15
|
+
["«", "»"],
|
|
16
|
+
["「", "」"],
|
|
17
|
+
["『", "』"],
|
|
18
|
+
]);
|
|
19
|
+
const CLOSE_TO_OPEN = new Map([...OPEN_TO_CLOSE.entries()].map(([open, close]) => [close, open]));
|
|
20
|
+
const SENTENCE_TERMINATORS = new Set([".", "!", "?"]);
|
|
21
|
+
const TERM_EDGE_RE = /[\s,;:()[\]{}]/u;
|
|
22
|
+
const LETTER_OR_NUMBER_RE = /[\p{L}\p{N}]/u;
|
|
23
|
+
const ACRONYM_RE = /^[\p{Lu}\p{N}][\p{Lu}\p{N}._-]{1,31}$/u;
|
|
24
|
+
const DEFINITION_LIST_MARKER_RE = /^(?:definition|term)$/iu;
|
|
25
|
+
const DEFINITION_LIST_PREFIX_RE = /^\s*(?:[-*+]\s+)?/u;
|
|
26
|
+
const EXAMPLE_RE = /\b(?:for\s+example|e\.g\.?|example|such\s+as)\b/iu;
|
|
27
|
+
const HYPOTHETICAL_RE = /\b(?:if|when|unless|whenever|suppose|assuming|hypothetically|imagine|would|could|might|may)\b/iu;
|
|
28
|
+
const QUESTION_RE = /\?|^\s*(?:does|do|did|can|could|would|should|what|why|how)\b/iu;
|
|
29
|
+
const INDIRECT_QUESTION_RE = /\b(?:i\s+(?:wonder|ask|want\s+to\s+know)|tell\s+me|whether|what|why|how)\b/iu;
|
|
30
|
+
const FUTURE_RE = /\b(?:will|shall|going\s+to|plan\s+to|intend\s+to|in\s+the\s+future|from\s+now\s+on|later)\b/iu;
|
|
31
|
+
const NEGATION_RE = /\b(?:does\s+not|doesn['’]t|do\s+not|don['’]t|did\s+not|never|isn['’]t|is\s+not)\b/iu;
|
|
32
|
+
const SARCASM_RE = /(?:\b(?:sarcasm|sarcastically|just\s+kidding|jk)\b|\/s(?:\b|$))/iu;
|
|
33
|
+
const ATTRIBUTION_RE = /(?:\b(?:according\s+to|quoted\s+from|as\s+stated\s+by|the\s+(?:agent|assistant|docs?|documentation)\s+(?:says?|defines?)|[A-Z][\p{L}\p{M}'-]{1,31}\s+(?:says?|defines?|said|wrote|called))\b|^\s*(?!(?:correction|definition|example|note|term|meaning)\b)[\p{L}][\p{L}\p{M}'-]{1,31}\s*:\s*["'“‘`])/iu;
|
|
34
|
+
const RETRACTION_RE = /\b(?:i\s+retract|retract(?:ed|ion)?|withdraw(?:n|al)?|supersed(?:e|ed|es)|no\s+longer|disregard|take\s+back|replace(?:d|ment)?)\b/iu;
|
|
35
|
+
const CORRECTION_RE = /\b(?:actually|correction|not\s+quite|instead|rather)\b/iu;
|
|
36
|
+
const PROJECT_SCOPE_RE = /\b(?:in|within|for)\s+(?:this|the|our)\s+(?:repo(?:sitory)?|project|codebase)\b|\b(?:repo(?:sitory)?|project|codebase)[ -]only\b|\b(?:project|repo(?:sitory)?|codebase)\s+(?:term|meaning|definition)\b/iu;
|
|
37
|
+
const DIRECT_SCOPE_REFERENCE_RE = /\b(?:this|that|the\s+(?:following|above|below)|following|above|below)\s+(?:term|meaning|definition|usage|entry)\b/iu;
|
|
38
|
+
const PERSONAL_SCOPE_RE = /\b(?:i|we)\s+(?:use|mean|call|define)\b|\bmy\s+(?:term|meaning|definition)\b|\bfor\s+me\b|\bpersonally\b/iu;
|
|
39
|
+
export function dataObject(record) {
|
|
40
|
+
const data = record.data;
|
|
41
|
+
return data !== null && typeof data === "object" && !Array.isArray(data)
|
|
42
|
+
? data
|
|
43
|
+
: {};
|
|
44
|
+
}
|
|
45
|
+
export function compareText(left, right) {
|
|
46
|
+
return compareGlossaryUnicodeStrings(left, right);
|
|
47
|
+
}
|
|
48
|
+
export function utf8Span(text, start, end) {
|
|
49
|
+
return {
|
|
50
|
+
start: Buffer.byteLength(text.slice(0, start), "utf8"),
|
|
51
|
+
end: Buffer.byteLength(text.slice(0, end), "utf8"),
|
|
52
|
+
};
|
|
53
|
+
}
|
|
54
|
+
function scalarAt(text, index) {
|
|
55
|
+
const value = text.codePointAt(index);
|
|
56
|
+
return value === undefined ? "" : String.fromCodePoint(value);
|
|
57
|
+
}
|
|
58
|
+
function isApostropheInWord(text, index) {
|
|
59
|
+
return (text[index] === "'" &&
|
|
60
|
+
LETTER_OR_NUMBER_RE.test(scalarAt(text, index - 1)) &&
|
|
61
|
+
LETTER_OR_NUMBER_RE.test(scalarAt(text, index + 1)));
|
|
62
|
+
}
|
|
63
|
+
function delimitedRanges(text) {
|
|
64
|
+
const ranges = [];
|
|
65
|
+
const stack = [];
|
|
66
|
+
for (let index = 0; index < text.length; index += 1) {
|
|
67
|
+
const character = text[index];
|
|
68
|
+
if (isApostropheInWord(text, index))
|
|
69
|
+
continue;
|
|
70
|
+
const current = stack.at(-1);
|
|
71
|
+
if (current) {
|
|
72
|
+
if (character === current.close &&
|
|
73
|
+
!(current.open === current.close && index === current.start)) {
|
|
74
|
+
stack.pop();
|
|
75
|
+
ranges.push({ start: current.start, end: index });
|
|
76
|
+
}
|
|
77
|
+
continue;
|
|
78
|
+
}
|
|
79
|
+
const close = OPEN_TO_CLOSE.get(character);
|
|
80
|
+
if (close)
|
|
81
|
+
stack.push({ open: character, close, start: index });
|
|
82
|
+
}
|
|
83
|
+
return ranges.sort((left, right) => left.start - right.start);
|
|
84
|
+
}
|
|
85
|
+
function insideRange(index, ranges) {
|
|
86
|
+
for (const range of ranges) {
|
|
87
|
+
if (range.start >= index)
|
|
88
|
+
break;
|
|
89
|
+
if (index < range.end)
|
|
90
|
+
return true;
|
|
91
|
+
}
|
|
92
|
+
return false;
|
|
93
|
+
}
|
|
94
|
+
function sentenceBoundaries(text, ranges) {
|
|
95
|
+
const boundaries = [];
|
|
96
|
+
for (let index = 0; index < text.length; index += 1) {
|
|
97
|
+
const character = text[index];
|
|
98
|
+
if (!SENTENCE_TERMINATORS.has(character) || insideRange(index, ranges))
|
|
99
|
+
continue;
|
|
100
|
+
if (character === "." &&
|
|
101
|
+
((/[\p{N}]/u.test(text[index - 1] ?? "") && /[\p{N}]/u.test(text[index + 1] ?? "")) ||
|
|
102
|
+
(text[index + 1] !== "" && !/[\s"'”’)]/u.test(text[index + 1] ?? "")))) {
|
|
103
|
+
continue;
|
|
104
|
+
}
|
|
105
|
+
boundaries.push(index + 1);
|
|
106
|
+
}
|
|
107
|
+
return boundaries;
|
|
108
|
+
}
|
|
109
|
+
function previousBoundary(boundaries, index) {
|
|
110
|
+
let result = 0;
|
|
111
|
+
for (const boundary of boundaries) {
|
|
112
|
+
if (boundary > index)
|
|
113
|
+
break;
|
|
114
|
+
result = boundary;
|
|
115
|
+
}
|
|
116
|
+
return result;
|
|
117
|
+
}
|
|
118
|
+
function nextBoundary(text, boundaries, index) {
|
|
119
|
+
for (const boundary of boundaries) {
|
|
120
|
+
if (boundary > index)
|
|
121
|
+
return boundary;
|
|
122
|
+
}
|
|
123
|
+
return text.length;
|
|
124
|
+
}
|
|
125
|
+
function trimWhitespace(text, start, end) {
|
|
126
|
+
while (start < end && /\s/u.test(text[start]))
|
|
127
|
+
start += 1;
|
|
128
|
+
while (end > start && /\s/u.test(text[end - 1]))
|
|
129
|
+
end -= 1;
|
|
130
|
+
return [start, end];
|
|
131
|
+
}
|
|
132
|
+
function trimTerm(text, start, end) {
|
|
133
|
+
[start, end] = trimWhitespace(text, start, end);
|
|
134
|
+
while (start < end && TERM_EDGE_RE.test(text[start]))
|
|
135
|
+
start += 1;
|
|
136
|
+
while (end > start && TERM_EDGE_RE.test(text[end - 1]))
|
|
137
|
+
end -= 1;
|
|
138
|
+
return trimWhitespace(text, start, end);
|
|
139
|
+
}
|
|
140
|
+
function trimMeaning(text, start, end) {
|
|
141
|
+
[start, end] = trimWhitespace(text, start, end);
|
|
142
|
+
while (end > start && (SENTENCE_TERMINATORS.has(text[end - 1]) || text[end - 1] === ";")) {
|
|
143
|
+
end -= 1;
|
|
144
|
+
}
|
|
145
|
+
return trimWhitespace(text, start, end);
|
|
146
|
+
}
|
|
147
|
+
function lastIndexOutsideRanges(text, character, start, end, ranges) {
|
|
148
|
+
for (let index = end - 1; index >= start; index -= 1) {
|
|
149
|
+
if (text[index] === character && !insideRange(index, ranges))
|
|
150
|
+
return index;
|
|
151
|
+
}
|
|
152
|
+
return -1;
|
|
153
|
+
}
|
|
154
|
+
function delimitedTermBefore(text, end, floor) {
|
|
155
|
+
while (end > floor && /[\s,;:]/u.test(text[end - 1]))
|
|
156
|
+
end -= 1;
|
|
157
|
+
const close = text[end - 1];
|
|
158
|
+
if (!close || !CLOSE_TO_OPEN.has(close))
|
|
159
|
+
return null;
|
|
160
|
+
const open = CLOSE_TO_OPEN.get(close);
|
|
161
|
+
const openIndex = text.lastIndexOf(open, end - 2);
|
|
162
|
+
if (openIndex < floor || openIndex >= end - 1)
|
|
163
|
+
return null;
|
|
164
|
+
const [start, finish] = trimWhitespace(text, openIndex + 1, end - 1);
|
|
165
|
+
return finish > start ? [start, finish] : [start, finish];
|
|
166
|
+
}
|
|
167
|
+
function lastWordIndex(text, word, start, end) {
|
|
168
|
+
const expression = new RegExp(`(?:^|[^\\p{L}\\p{N}_])${word}(?=$|[^\\p{L}\\p{N}_])`, "giu");
|
|
169
|
+
let result = -1;
|
|
170
|
+
for (const match of text.slice(start, end).matchAll(expression)) {
|
|
171
|
+
result = start + (match.index ?? 0) + (match[0].length - word.length);
|
|
172
|
+
}
|
|
173
|
+
return result;
|
|
174
|
+
}
|
|
175
|
+
function removeLeadingTermLabel(text, start, end) {
|
|
176
|
+
const value = text.slice(start, end);
|
|
177
|
+
const match = /^(?:the\s+)?(?:term|word|phrase|concept)\s*[:=]?\s+/iu.exec(value);
|
|
178
|
+
return match ? start + match[0].length : start;
|
|
179
|
+
}
|
|
180
|
+
function unquotedTermBefore(text, cueStart, segmentStart, kind, ranges) {
|
|
181
|
+
let start = segmentStart;
|
|
182
|
+
const prefixEnd = cueStart;
|
|
183
|
+
const prefix = text.slice(segmentStart, prefixEnd);
|
|
184
|
+
if (kind === "by_i_mean") {
|
|
185
|
+
const by = lastWordIndex(text, "by", segmentStart, prefixEnd);
|
|
186
|
+
if (by >= 0)
|
|
187
|
+
start = by + 2;
|
|
188
|
+
}
|
|
189
|
+
else if (kind === "use_for" || kind === "use_to_mean") {
|
|
190
|
+
const use = lastWordIndex(text, "use", segmentStart, prefixEnd);
|
|
191
|
+
if (use >= 0)
|
|
192
|
+
start = use + 3;
|
|
193
|
+
}
|
|
194
|
+
else {
|
|
195
|
+
const directives = [
|
|
196
|
+
"to clarify",
|
|
197
|
+
"prefer",
|
|
198
|
+
"please use",
|
|
199
|
+
"i use",
|
|
200
|
+
"use",
|
|
201
|
+
"actually",
|
|
202
|
+
"correction",
|
|
203
|
+
"not quite",
|
|
204
|
+
"instead",
|
|
205
|
+
"rather",
|
|
206
|
+
];
|
|
207
|
+
let directiveEnd = -1;
|
|
208
|
+
for (const directive of directives) {
|
|
209
|
+
const expression = new RegExp(`(?:^|[^\\p{L}\\p{N}_])${directive}(?=$|[^\\p{L}\\p{N}_])`, "giu");
|
|
210
|
+
for (const match of prefix.matchAll(expression)) {
|
|
211
|
+
const end = segmentStart + (match.index ?? 0) + match[0].length;
|
|
212
|
+
if (end > directiveEnd)
|
|
213
|
+
directiveEnd = end;
|
|
214
|
+
}
|
|
215
|
+
}
|
|
216
|
+
if (directiveEnd >= 0)
|
|
217
|
+
start = directiveEnd;
|
|
218
|
+
const separator = Math.max(lastIndexOutsideRanges(text, ",", start, prefixEnd, ranges), lastIndexOutsideRanges(text, ";", start, prefixEnd, ranges), lastIndexOutsideRanges(text, ":", start, prefixEnd, ranges));
|
|
219
|
+
if (separator >= start)
|
|
220
|
+
start = separator + 1;
|
|
221
|
+
}
|
|
222
|
+
start = removeLeadingTermLabel(text, start, prefixEnd);
|
|
223
|
+
let result = trimTerm(text, start, cueStart);
|
|
224
|
+
return result;
|
|
225
|
+
}
|
|
226
|
+
function matchingClose(text, openIndex) {
|
|
227
|
+
const open = text[openIndex];
|
|
228
|
+
const close = open ? OPEN_TO_CLOSE.get(open) : undefined;
|
|
229
|
+
if (!close)
|
|
230
|
+
return -1;
|
|
231
|
+
let depth = 0;
|
|
232
|
+
for (let index = openIndex; index < text.length; index += 1) {
|
|
233
|
+
if (text[index] === open)
|
|
234
|
+
depth += 1;
|
|
235
|
+
else if (text[index] === close) {
|
|
236
|
+
depth -= 1;
|
|
237
|
+
if (depth === 0)
|
|
238
|
+
return index;
|
|
239
|
+
}
|
|
240
|
+
}
|
|
241
|
+
return -1;
|
|
242
|
+
}
|
|
243
|
+
function meaningSpan(text, cueEnd, sentenceEnd, ranges) {
|
|
244
|
+
let start = cueEnd;
|
|
245
|
+
while (start < sentenceEnd && /[\s:,-]/u.test(text[start]))
|
|
246
|
+
start += 1;
|
|
247
|
+
let end = sentenceEnd;
|
|
248
|
+
for (let index = cueEnd; index < sentenceEnd; index += 1) {
|
|
249
|
+
if (text[index] !== "\n" || insideRange(index, ranges))
|
|
250
|
+
continue;
|
|
251
|
+
const nextLineStart = index + 1;
|
|
252
|
+
const nextLineEnd = text.indexOf("\n", nextLineStart) < 0 ? sentenceEnd : text.indexOf("\n", nextLineStart);
|
|
253
|
+
if (looksLikeDefinitionLine(text, nextLineStart, nextLineEnd, ranges)) {
|
|
254
|
+
end = index;
|
|
255
|
+
break;
|
|
256
|
+
}
|
|
257
|
+
}
|
|
258
|
+
return trimMeaning(text, start, end);
|
|
259
|
+
}
|
|
260
|
+
function unwrapMeaning(text, start, end) {
|
|
261
|
+
[start, end] = trimMeaning(text, start, end);
|
|
262
|
+
const open = text[start];
|
|
263
|
+
if (!open || !OPEN_TO_CLOSE.has(open))
|
|
264
|
+
return [start, end];
|
|
265
|
+
const close = matchingClose(text, start);
|
|
266
|
+
if (close !== end - 1)
|
|
267
|
+
return [start, end];
|
|
268
|
+
return trimWhitespace(text, start + 1, close);
|
|
269
|
+
}
|
|
270
|
+
function parseWordCue(text, cueStart, cueEnd, kind, boundaries, ranges, termEndForParsing = cueStart) {
|
|
271
|
+
const sentenceStart = previousBoundary(boundaries, cueStart);
|
|
272
|
+
const sentenceBoundary = nextBoundary(text, boundaries, cueStart);
|
|
273
|
+
const term = delimitedTermBefore(text, termEndForParsing, sentenceStart);
|
|
274
|
+
const [termStart, termEnd] = term ?? unquotedTermBefore(text, termEndForParsing, sentenceStart, kind, ranges);
|
|
275
|
+
const [meaningStart, meaningEnd] = unwrapMeaning(text, ...meaningSpan(text, cueEnd, sentenceBoundary, ranges));
|
|
276
|
+
return {
|
|
277
|
+
kind,
|
|
278
|
+
termStart,
|
|
279
|
+
termEnd,
|
|
280
|
+
meaningStart,
|
|
281
|
+
meaningEnd,
|
|
282
|
+
sentenceStart,
|
|
283
|
+
sentenceEnd: sentenceBoundary,
|
|
284
|
+
};
|
|
285
|
+
}
|
|
286
|
+
function wordCues(text, boundaries, ranges) {
|
|
287
|
+
const patterns = [
|
|
288
|
+
{ kind: "means", expression: /\bmeans\b/giu },
|
|
289
|
+
{ kind: "refers_to", expression: /\brefers\s+to\b/giu },
|
|
290
|
+
{ kind: "stands_for", expression: /\bstands\s+for\b/giu },
|
|
291
|
+
{ kind: "use_to_mean", expression: /\bto\s+mean\b/giu },
|
|
292
|
+
{ kind: "by_i_mean", expression: /\bi\s+mean\b/giu },
|
|
293
|
+
];
|
|
294
|
+
const cues = [];
|
|
295
|
+
for (const pattern of patterns) {
|
|
296
|
+
for (const match of text.matchAll(pattern.expression)) {
|
|
297
|
+
const start = match.index ?? 0;
|
|
298
|
+
if (insideRange(start, ranges))
|
|
299
|
+
continue;
|
|
300
|
+
if (pattern.kind === "by_i_mean") {
|
|
301
|
+
const sentenceStart = previousBoundary(boundaries, start);
|
|
302
|
+
if (lastWordIndex(text, "by", sentenceStart, start) < 0)
|
|
303
|
+
continue;
|
|
304
|
+
}
|
|
305
|
+
cues.push(parseWordCue(text, start, start + match[0].length, pattern.kind, boundaries, ranges));
|
|
306
|
+
}
|
|
307
|
+
}
|
|
308
|
+
for (const match of text.matchAll(/\bfor\b/giu)) {
|
|
309
|
+
const start = match.index ?? 0;
|
|
310
|
+
if (insideRange(start, ranges))
|
|
311
|
+
continue;
|
|
312
|
+
const sentenceStart = previousBoundary(boundaries, start);
|
|
313
|
+
if (lastWordIndex(text, "use", sentenceStart, start) < 0)
|
|
314
|
+
continue;
|
|
315
|
+
cues.push(parseWordCue(text, start, start + match[0].length, "use_for", boundaries, ranges));
|
|
316
|
+
}
|
|
317
|
+
for (const match of text.matchAll(/\bmean\b/giu)) {
|
|
318
|
+
const start = match.index ?? 0;
|
|
319
|
+
if (insideRange(start, ranges))
|
|
320
|
+
continue;
|
|
321
|
+
const sentenceStart = previousBoundary(boundaries, start);
|
|
322
|
+
const sentenceEnd = nextBoundary(text, boundaries, start);
|
|
323
|
+
const prefix = text.slice(sentenceStart, start);
|
|
324
|
+
const sentence = text.slice(sentenceStart, sentenceEnd);
|
|
325
|
+
if (lastWordIndex(text, "by", sentenceStart, start) >= 0 ||
|
|
326
|
+
(!NEGATION_RE.test(prefix) &&
|
|
327
|
+
!QUESTION_RE.test(sentence) &&
|
|
328
|
+
!/^\s*(?:does|do|did|can|could|would|should|when|may)\b/iu.test(prefix))) {
|
|
329
|
+
continue;
|
|
330
|
+
}
|
|
331
|
+
const negation = /(?:does\s+not|doesn['’]t|do\s+not|don['’]t|did\s+not|never)\s*$/iu.exec(prefix);
|
|
332
|
+
cues.push(parseWordCue(text, start, start + match[0].length, "special_mean", boundaries, ranges, negation ? sentenceStart + negation.index : start));
|
|
333
|
+
}
|
|
334
|
+
return cues;
|
|
335
|
+
}
|
|
336
|
+
function lineRanges(text) {
|
|
337
|
+
const lines = [];
|
|
338
|
+
let start = 0;
|
|
339
|
+
for (let index = 0; index <= text.length; index += 1) {
|
|
340
|
+
if (index !== text.length && text[index] !== "\n")
|
|
341
|
+
continue;
|
|
342
|
+
lines.push({ start, end: index });
|
|
343
|
+
start = index + 1;
|
|
344
|
+
}
|
|
345
|
+
return lines;
|
|
346
|
+
}
|
|
347
|
+
function commentStart(text, line, ranges) {
|
|
348
|
+
const firstNonWhitespace = text.slice(line.start, line.end).search(/\S/u);
|
|
349
|
+
if (firstNonWhitespace >= 0) {
|
|
350
|
+
const index = line.start + firstNonWhitespace;
|
|
351
|
+
if (text[index] === "#" && !insideRange(index, ranges))
|
|
352
|
+
return index;
|
|
353
|
+
}
|
|
354
|
+
for (let index = line.start; index < line.end; index += 1) {
|
|
355
|
+
if (text[index] !== "#" || insideRange(index, ranges))
|
|
356
|
+
continue;
|
|
357
|
+
if (index === line.start || /\s/u.test(text[index - 1] ?? ""))
|
|
358
|
+
return index;
|
|
359
|
+
}
|
|
360
|
+
return -1;
|
|
361
|
+
}
|
|
362
|
+
function segmentFloorBefore(text, end, floor, ranges) {
|
|
363
|
+
for (let index = end - 1; index >= floor; index -= 1) {
|
|
364
|
+
if (!insideRange(index, ranges) && /[;,.!?]/u.test(text[index]))
|
|
365
|
+
return index + 1;
|
|
366
|
+
}
|
|
367
|
+
return floor;
|
|
368
|
+
}
|
|
369
|
+
function colonOutsideRanges(text, start, end, ranges) {
|
|
370
|
+
for (let index = start; index < end; index += 1) {
|
|
371
|
+
if (text[index] === ":" && !insideRange(index, ranges))
|
|
372
|
+
return index;
|
|
373
|
+
}
|
|
374
|
+
return -1;
|
|
375
|
+
}
|
|
376
|
+
function acronymInitials(value) {
|
|
377
|
+
const initials = [];
|
|
378
|
+
for (const word of value.trim().split(/\s+/u).filter(Boolean)) {
|
|
379
|
+
const letters = [...word].filter((character) => LETTER_OR_NUMBER_RE.test(character));
|
|
380
|
+
if (letters.length === 0)
|
|
381
|
+
continue;
|
|
382
|
+
const capitals = letters.filter((character) => character.toUpperCase() === character && character.toLowerCase() !== character);
|
|
383
|
+
if (capitals.length > 1)
|
|
384
|
+
initials.push(...capitals);
|
|
385
|
+
else
|
|
386
|
+
initials.push(letters[0]);
|
|
387
|
+
}
|
|
388
|
+
return initials.join("");
|
|
389
|
+
}
|
|
390
|
+
function acronymExpansionMatches(term, meaning) {
|
|
391
|
+
if (!ACRONYM_RE.test(term) || Buffer.byteLength(term, "utf8") > 32)
|
|
392
|
+
return false;
|
|
393
|
+
const words = meaning.trim().split(/\s+/u).filter(Boolean);
|
|
394
|
+
return (words.length > 0 &&
|
|
395
|
+
words.length <= 32 &&
|
|
396
|
+
acronymInitials(meaning).toLowerCase() === term.toLowerCase());
|
|
397
|
+
}
|
|
398
|
+
function safeDefinitionListTerm(text, lineStart, termFloor, colon, termStart, termEnd, meaningStart, meaningEnd, marked) {
|
|
399
|
+
const term = text.slice(termStart, termEnd);
|
|
400
|
+
const meaning = text.slice(meaningStart, meaningEnd);
|
|
401
|
+
const delimited = delimitedTermBefore(text, colon, termFloor);
|
|
402
|
+
const exactlyDelimited = delimited?.[0] === termStart &&
|
|
403
|
+
delimited[1] === termEnd &&
|
|
404
|
+
text.slice(termFloor, Math.max(termFloor, termStart - 1)).trim().length === 0 &&
|
|
405
|
+
text.slice(termEnd + 1, colon).trim().length === 0;
|
|
406
|
+
if (text.slice(lineStart, termStart).includes("#"))
|
|
407
|
+
return false;
|
|
408
|
+
if (/[/\\=@#[\]{}]/u.test(term) ||
|
|
409
|
+
/:\/\//u.test(text.slice(lineStart, meaningEnd)) ||
|
|
410
|
+
/^(?:https?|ftp):\/\//iu.test(meaning.trim()))
|
|
411
|
+
return false;
|
|
412
|
+
if (/^\d{1,2}:\d{2}(?::\d{2})?$/u.test(`${term}:${meaning}`.split(/\s+/u)[0]))
|
|
413
|
+
return false;
|
|
414
|
+
if (marked)
|
|
415
|
+
return LETTER_OR_NUMBER_RE.test(term);
|
|
416
|
+
if (exactlyDelimited)
|
|
417
|
+
return true;
|
|
418
|
+
if (acronymExpansionMatches(term, meaning))
|
|
419
|
+
return true;
|
|
420
|
+
return false;
|
|
421
|
+
}
|
|
422
|
+
function looksLikeDefinitionLine(text, start, end, ranges) {
|
|
423
|
+
const colon = colonOutsideRanges(text, start, end, ranges);
|
|
424
|
+
if (colon < 0)
|
|
425
|
+
return false;
|
|
426
|
+
const [termStart, termEnd] = trimTerm(text, start, colon);
|
|
427
|
+
const term = text
|
|
428
|
+
.slice(termStart, termEnd)
|
|
429
|
+
.replace(/^[-*+]\s+/u, "")
|
|
430
|
+
.trim();
|
|
431
|
+
return term.length > 0;
|
|
432
|
+
}
|
|
433
|
+
function listCues(text, ranges, boundaries) {
|
|
434
|
+
const cues = [];
|
|
435
|
+
const lines = lineRanges(text);
|
|
436
|
+
for (const line of lines) {
|
|
437
|
+
const comment = commentStart(text, line, ranges);
|
|
438
|
+
const scanEnd = comment < 0 ? line.end : comment;
|
|
439
|
+
const prefixMatch = DEFINITION_LIST_PREFIX_RE.exec(text.slice(line.start, scanEnd));
|
|
440
|
+
const contentStart = line.start + (prefixMatch?.[0].length ?? 0);
|
|
441
|
+
const colons = [];
|
|
442
|
+
for (let index = contentStart; index < scanEnd; index += 1) {
|
|
443
|
+
if (text[index] === ":" && !insideRange(index, ranges))
|
|
444
|
+
colons.push(index);
|
|
445
|
+
}
|
|
446
|
+
if (colons.length === 0)
|
|
447
|
+
continue;
|
|
448
|
+
for (const firstColon of colons) {
|
|
449
|
+
const segmentFloor = segmentFloorBefore(text, firstColon, contentStart, ranges);
|
|
450
|
+
const [firstStart, firstEnd] = trimTerm(text, segmentFloor, firstColon);
|
|
451
|
+
const firstValue = text.slice(firstStart, firstEnd);
|
|
452
|
+
if (DEFINITION_LIST_MARKER_RE.test(firstValue)) {
|
|
453
|
+
const termColon = colons.find((candidate) => candidate > firstColon);
|
|
454
|
+
if (termColon === undefined)
|
|
455
|
+
continue;
|
|
456
|
+
const [termStart, termEnd] = trimTerm(text, firstColon + 1, termColon);
|
|
457
|
+
const [meaningStart, meaningEnd] = trimMeaning(text, termColon + 1, scanEnd);
|
|
458
|
+
const safe = safeDefinitionListTerm(text, line.start, firstColon + 1, termColon, termStart, termEnd, meaningStart, meaningEnd, true);
|
|
459
|
+
cues.push({
|
|
460
|
+
kind: "definition_list",
|
|
461
|
+
termStart,
|
|
462
|
+
termEnd,
|
|
463
|
+
meaningStart: termColon + 1,
|
|
464
|
+
meaningEnd: scanEnd,
|
|
465
|
+
sentenceStart: previousBoundary(boundaries, termStart),
|
|
466
|
+
sentenceEnd: nextBoundary(text, boundaries, termColon),
|
|
467
|
+
...(safe ? {} : { rejectionReason: EXPLICIT_GLOSSARY_REASONS.unsafeSyntax }),
|
|
468
|
+
});
|
|
469
|
+
continue;
|
|
470
|
+
}
|
|
471
|
+
const delimited = delimitedTermBefore(text, firstColon, segmentFloor);
|
|
472
|
+
const [termStart, termEnd] = delimited ?? trimTerm(text, segmentFloor, firstColon);
|
|
473
|
+
const term = text.slice(termStart, termEnd);
|
|
474
|
+
if (!delimited && !ACRONYM_RE.test(term))
|
|
475
|
+
continue;
|
|
476
|
+
const [meaningStart, meaningEnd] = trimMeaning(text, firstColon + 1, scanEnd);
|
|
477
|
+
const safe = safeDefinitionListTerm(text, line.start, segmentFloor, firstColon, termStart, termEnd, meaningStart, meaningEnd, false);
|
|
478
|
+
cues.push({
|
|
479
|
+
kind: "definition_list",
|
|
480
|
+
termStart,
|
|
481
|
+
termEnd,
|
|
482
|
+
meaningStart: firstColon + 1,
|
|
483
|
+
meaningEnd: scanEnd,
|
|
484
|
+
sentenceStart: previousBoundary(boundaries, termStart),
|
|
485
|
+
sentenceEnd: nextBoundary(text, boundaries, firstColon),
|
|
486
|
+
...(safe ? {} : { rejectionReason: EXPLICIT_GLOSSARY_REASONS.unsafeSyntax }),
|
|
487
|
+
});
|
|
488
|
+
}
|
|
489
|
+
}
|
|
490
|
+
return cues;
|
|
491
|
+
}
|
|
492
|
+
function phraseBefore(text, start, ranges) {
|
|
493
|
+
let floor = 0;
|
|
494
|
+
for (let index = start - 1; index >= 0; index -= 1) {
|
|
495
|
+
if (text[index] === "\n" ||
|
|
496
|
+
text[index] === "." ||
|
|
497
|
+
text[index] === "!" ||
|
|
498
|
+
text[index] === "?" ||
|
|
499
|
+
text[index] === ",") {
|
|
500
|
+
if (!insideRange(index, ranges)) {
|
|
501
|
+
floor = index + 1;
|
|
502
|
+
break;
|
|
503
|
+
}
|
|
504
|
+
}
|
|
505
|
+
}
|
|
506
|
+
return trimTerm(text, floor, start);
|
|
507
|
+
}
|
|
508
|
+
function acronymCues(text, ranges, boundaries) {
|
|
509
|
+
const cues = [];
|
|
510
|
+
for (let index = 0; index < text.length; index += 1) {
|
|
511
|
+
if (text[index] !== "(" || insideRange(index, ranges))
|
|
512
|
+
continue;
|
|
513
|
+
const close = text.indexOf(")", index + 1);
|
|
514
|
+
if (close < 0 || insideRange(close, ranges))
|
|
515
|
+
continue;
|
|
516
|
+
const [innerStart, innerEnd] = trimWhitespace(text, index + 1, close);
|
|
517
|
+
const inner = text.slice(innerStart, innerEnd);
|
|
518
|
+
const [leftStart, leftEnd] = phraseBefore(text, index, ranges);
|
|
519
|
+
const left = text.slice(leftStart, leftEnd);
|
|
520
|
+
const sentenceStart = previousBoundary(boundaries, index);
|
|
521
|
+
const sentenceEnd = nextBoundary(text, boundaries, index);
|
|
522
|
+
if (ACRONYM_RE.test(left) && acronymExpansionMatches(left, inner)) {
|
|
523
|
+
cues.push({
|
|
524
|
+
kind: "acronym_parenthetical",
|
|
525
|
+
termStart: leftStart,
|
|
526
|
+
termEnd: leftEnd,
|
|
527
|
+
meaningStart: innerStart,
|
|
528
|
+
meaningEnd: innerEnd,
|
|
529
|
+
sentenceStart,
|
|
530
|
+
sentenceEnd,
|
|
531
|
+
});
|
|
532
|
+
}
|
|
533
|
+
else if (ACRONYM_RE.test(inner) && acronymExpansionMatches(inner, left)) {
|
|
534
|
+
cues.push({
|
|
535
|
+
kind: "acronym_parenthetical",
|
|
536
|
+
termStart: innerStart,
|
|
537
|
+
termEnd: innerEnd,
|
|
538
|
+
meaningStart: leftStart,
|
|
539
|
+
meaningEnd: leftEnd,
|
|
540
|
+
sentenceStart,
|
|
541
|
+
sentenceEnd,
|
|
542
|
+
});
|
|
543
|
+
}
|
|
544
|
+
index = close;
|
|
545
|
+
}
|
|
546
|
+
return cues;
|
|
547
|
+
}
|
|
548
|
+
function rawCueKey(cue) {
|
|
549
|
+
return [cue.termStart, cue.termEnd, cue.meaningStart, cue.meaningEnd, cue.kind].join(":");
|
|
550
|
+
}
|
|
551
|
+
function rawCueOrder(left, right, text) {
|
|
552
|
+
return (left.termStart - right.termStart ||
|
|
553
|
+
left.meaningStart - right.meaningStart ||
|
|
554
|
+
compareText(text.slice(left.termStart, left.termEnd), text.slice(right.termStart, right.termEnd)) ||
|
|
555
|
+
compareText(text.slice(left.meaningStart, left.meaningEnd), text.slice(right.meaningStart, right.meaningEnd)) ||
|
|
556
|
+
compareText(left.kind, right.kind));
|
|
557
|
+
}
|
|
558
|
+
export function rawCues(text) {
|
|
559
|
+
const ranges = delimitedRanges(text);
|
|
560
|
+
const boundaries = sentenceBoundaries(text, ranges);
|
|
561
|
+
const grammar = loadExplicitSegmentGrammarContract();
|
|
562
|
+
const initial = [
|
|
563
|
+
...wordCues(text, boundaries, ranges),
|
|
564
|
+
...listCues(text, ranges, boundaries),
|
|
565
|
+
...acronymCues(text, ranges, boundaries),
|
|
566
|
+
];
|
|
567
|
+
const unique = new Map();
|
|
568
|
+
for (const cue of initial)
|
|
569
|
+
unique.set(rawCueKey(cue), cue);
|
|
570
|
+
return segmentAndBindExplicitCues(text, [...unique.values()], ranges, grammar, {
|
|
571
|
+
lineRanges,
|
|
572
|
+
commentStart,
|
|
573
|
+
colonOutsideRanges,
|
|
574
|
+
sentenceBoundaries,
|
|
575
|
+
rawCueOrder,
|
|
576
|
+
trimMeaning,
|
|
577
|
+
unwrapMeaning,
|
|
578
|
+
closeToOpen: CLOSE_TO_OPEN,
|
|
579
|
+
});
|
|
580
|
+
}
|
|
581
|
+
function cueValue(text, cue) {
|
|
582
|
+
return {
|
|
583
|
+
term: text.slice(cue.termStart, cue.termEnd),
|
|
584
|
+
meaning: text.slice(cue.meaningStart, cue.meaningEnd),
|
|
585
|
+
};
|
|
586
|
+
}
|
|
587
|
+
function termOccurs(text, term) {
|
|
588
|
+
const escaped = term.replace(/[.*+?^${}()|[\]\\]/g, "\\$&");
|
|
589
|
+
if (!escaped)
|
|
590
|
+
return false;
|
|
591
|
+
return new RegExp(`(?<![\\p{ID_Continue}$\\u200C\\u200D])${escaped}(?![\\p{ID_Continue}$\\u200C\\u200D])`, "iu").test(text);
|
|
592
|
+
}
|
|
593
|
+
function scopeReason(text, cue, record) {
|
|
594
|
+
const dataScope = String(dataObject(record ?? {}).scope ?? "").toLowerCase();
|
|
595
|
+
const sentences = adjacentScopeTexts(text, cue);
|
|
596
|
+
const term = text.slice(cue.termStart, cue.termEnd).trim();
|
|
597
|
+
const project = dataScope === "project" ||
|
|
598
|
+
dataScope === "project_only" ||
|
|
599
|
+
sentences.some((sentence, index) => PROJECT_SCOPE_RE.test(sentence) &&
|
|
600
|
+
(index === 1 ||
|
|
601
|
+
termOccurs(sentence, term) ||
|
|
602
|
+
DIRECT_SCOPE_REFERENCE_RE.test(sentence) ||
|
|
603
|
+
/:\s*$/u.test(sentence)));
|
|
604
|
+
const personal = sentences.some((sentence) => PERSONAL_SCOPE_RE.test(sentence) && termOccurs(sentence, term));
|
|
605
|
+
if (project && personal)
|
|
606
|
+
return EXPLICIT_GLOSSARY_REASONS.uncertainScope;
|
|
607
|
+
if (project)
|
|
608
|
+
return EXPLICIT_GLOSSARY_REASONS.projectOnlyScope;
|
|
609
|
+
return null;
|
|
610
|
+
}
|
|
611
|
+
function pureCueReason(text, cue, record) {
|
|
612
|
+
const value = cueValue(text, cue);
|
|
613
|
+
if (!value.term.trim())
|
|
614
|
+
return EXPLICIT_GLOSSARY_REASONS.emptyTerm;
|
|
615
|
+
if (!value.meaning.trim())
|
|
616
|
+
return EXPLICIT_GLOSSARY_REASONS.emptyMeaning;
|
|
617
|
+
if ((value.term.startsWith('"') ||
|
|
618
|
+
value.term.startsWith("'") ||
|
|
619
|
+
value.term.startsWith("`") ||
|
|
620
|
+
value.term.startsWith("“") ||
|
|
621
|
+
value.term.startsWith("‘")) &&
|
|
622
|
+
!value.term.endsWith('"') &&
|
|
623
|
+
!value.term.endsWith("'") &&
|
|
624
|
+
!value.term.endsWith("`") &&
|
|
625
|
+
!value.term.endsWith("”") &&
|
|
626
|
+
!value.term.endsWith("’")) {
|
|
627
|
+
return EXPLICIT_GLOSSARY_REASONS.malformedSpan;
|
|
628
|
+
}
|
|
629
|
+
const sentence = contextText(text, cue);
|
|
630
|
+
const beforeCue = text.slice(cue.sentenceStart, cue.termStart);
|
|
631
|
+
if (EXAMPLE_RE.test(sentence))
|
|
632
|
+
return EXPLICIT_GLOSSARY_REASONS.exampleContext;
|
|
633
|
+
if (NEGATION_RE.test(sentence))
|
|
634
|
+
return EXPLICIT_GLOSSARY_REASONS.negatedDefinition;
|
|
635
|
+
if (HYPOTHETICAL_RE.test(sentence))
|
|
636
|
+
return EXPLICIT_GLOSSARY_REASONS.hypotheticalDefinition;
|
|
637
|
+
if (QUESTION_RE.test(sentence))
|
|
638
|
+
return EXPLICIT_GLOSSARY_REASONS.questionDefinition;
|
|
639
|
+
if (INDIRECT_QUESTION_RE.test(beforeCue))
|
|
640
|
+
return EXPLICIT_GLOSSARY_REASONS.indirectQuestion;
|
|
641
|
+
if (FUTURE_RE.test(beforeCue))
|
|
642
|
+
return EXPLICIT_GLOSSARY_REASONS.futureDefinition;
|
|
643
|
+
if (SARCASM_RE.test(sentence))
|
|
644
|
+
return EXPLICIT_GLOSSARY_REASONS.sarcasmMarker;
|
|
645
|
+
if (ATTRIBUTION_RE.test(sentence))
|
|
646
|
+
return EXPLICIT_GLOSSARY_REASONS.attributedQuotation;
|
|
647
|
+
if (RETRACTION_RE.test(beforeCue) && !CORRECTION_RE.test(beforeCue)) {
|
|
648
|
+
return EXPLICIT_GLOSSARY_REASONS.retractedDefinition;
|
|
649
|
+
}
|
|
650
|
+
const scope = scopeReason(text, cue, record);
|
|
651
|
+
if (scope)
|
|
652
|
+
return scope;
|
|
653
|
+
return null;
|
|
654
|
+
}
|
|
655
|
+
export function candidateBounds() {
|
|
656
|
+
const authority = loadYamlMappingFile(glossaryEntryAuthorityPath());
|
|
657
|
+
const bounds = authority.candidate_contracts?.bounds;
|
|
658
|
+
const value = (field) => {
|
|
659
|
+
const number = Number(bounds?.[field]);
|
|
660
|
+
if (!Number.isInteger(number) || number <= 0) {
|
|
661
|
+
throw new TypeError(`candidate contract bound ${field} is invalid`);
|
|
662
|
+
}
|
|
663
|
+
return number;
|
|
664
|
+
};
|
|
665
|
+
return {
|
|
666
|
+
term: value("term_max_utf8_bytes"),
|
|
667
|
+
meaning: value("meaning_max_utf8_bytes"),
|
|
668
|
+
binding: value("binding_max_utf8_bytes"),
|
|
669
|
+
};
|
|
670
|
+
}
|
|
671
|
+
export function validCue(text, cue, bounds, record) {
|
|
672
|
+
if (cue.rejectionReason)
|
|
673
|
+
return { cue: null, reason: cue.rejectionReason };
|
|
674
|
+
const reason = pureCueReason(text, cue, record);
|
|
675
|
+
if (reason)
|
|
676
|
+
return { cue: null, reason };
|
|
677
|
+
const [termStart, termEnd] = trimTerm(text, cue.termStart, cue.termEnd);
|
|
678
|
+
const [meaningStart, meaningEnd] = trimMeaning(text, cue.meaningStart, cue.meaningEnd);
|
|
679
|
+
const term = text.slice(termStart, termEnd);
|
|
680
|
+
const meaning = text.slice(meaningStart, meaningEnd);
|
|
681
|
+
if (!term)
|
|
682
|
+
return { cue: null, reason: EXPLICIT_GLOSSARY_REASONS.emptyTerm };
|
|
683
|
+
if (!meaning)
|
|
684
|
+
return { cue: null, reason: EXPLICIT_GLOSSARY_REASONS.emptyMeaning };
|
|
685
|
+
if (!LETTER_OR_NUMBER_RE.test(term))
|
|
686
|
+
return { cue: null, reason: EXPLICIT_GLOSSARY_REASONS.malformedSpan };
|
|
687
|
+
if (!LETTER_OR_NUMBER_RE.test(meaning))
|
|
688
|
+
return { cue: null, reason: EXPLICIT_GLOSSARY_REASONS.malformedSpan };
|
|
689
|
+
if (cue.kind === "stands_for" && !acronymExpansionMatches(term, meaning)) {
|
|
690
|
+
return { cue: null, reason: EXPLICIT_GLOSSARY_REASONS.unsafeSyntax };
|
|
691
|
+
}
|
|
692
|
+
if (Buffer.byteLength(term, "utf8") > bounds.term) {
|
|
693
|
+
return { cue: null, reason: EXPLICIT_GLOSSARY_REASONS.termBoundExceeded };
|
|
694
|
+
}
|
|
695
|
+
if (Buffer.byteLength(meaning, "utf8") > bounds.meaning) {
|
|
696
|
+
return { cue: null, reason: EXPLICIT_GLOSSARY_REASONS.meaningBoundExceeded };
|
|
697
|
+
}
|
|
698
|
+
return {
|
|
699
|
+
cue: { ...cue, termStart, termEnd, meaningStart, meaningEnd, term, meaning },
|
|
700
|
+
reason: null,
|
|
701
|
+
};
|
|
702
|
+
}
|
|
703
|
+
export function retractionInvalidatesCue(text, cue, otherCues) {
|
|
704
|
+
const nextSameTerm = otherCues.find((other) => other.termStart > cue.termStart &&
|
|
705
|
+
other.termEnd > other.termStart &&
|
|
706
|
+
stableGlossaryTermIdentity(text.slice(other.termStart, other.termEnd).trim()) ===
|
|
707
|
+
stableGlossaryTermIdentity(cue.term));
|
|
708
|
+
const limit = nextSameTerm
|
|
709
|
+
? nextSameTerm.termStart
|
|
710
|
+
: Math.min(text.length, cue.sentenceEnd + 512);
|
|
711
|
+
const suffix = text.slice(cue.meaningEnd, limit);
|
|
712
|
+
const marker = RETRACTION_RE.exec(suffix);
|
|
713
|
+
if (marker) {
|
|
714
|
+
const after = suffix.slice(marker.index);
|
|
715
|
+
const sameSentence = marker.index < Math.max(0, cue.sentenceEnd - cue.meaningEnd);
|
|
716
|
+
if (termOccurs(after, cue.term) ||
|
|
717
|
+
/\b(?:that|the\s+(?:previous|earlier|above))\s+(?:definition|meaning|term)\b/iu.test(after) ||
|
|
718
|
+
(sameSentence && /\b(?:it|that)\b\s*(?:$|[.!?,;:])/iu.test(after))) {
|
|
719
|
+
return true;
|
|
720
|
+
}
|
|
721
|
+
}
|
|
722
|
+
if (!nextSameTerm)
|
|
723
|
+
return false;
|
|
724
|
+
return CORRECTION_RE.test(contextText(text, nextSameTerm));
|
|
725
|
+
}
|
|
726
|
+
/**
|
|
727
|
+
* Recognize explicit definitions in one source string without provenance or
|
|
728
|
+
* downstream admission. The returned text is copied exactly, while spans use
|
|
729
|
+
* UTF-8 byte offsets like the other deterministic source-span contracts.
|
|
730
|
+
*/
|
|
731
|
+
export function discoverExplicitGlossaryCues(text) {
|
|
732
|
+
const bounds = candidateBounds();
|
|
733
|
+
const raws = rawCues(text);
|
|
734
|
+
const valid = [];
|
|
735
|
+
for (const raw of raws) {
|
|
736
|
+
const result = validCue(text, raw, bounds);
|
|
737
|
+
if (!result.cue)
|
|
738
|
+
continue;
|
|
739
|
+
if (retractionInvalidatesCue(text, result.cue, raws))
|
|
740
|
+
continue;
|
|
741
|
+
valid.push({ raw, cue: result.cue });
|
|
742
|
+
}
|
|
743
|
+
const grouped = new Map();
|
|
744
|
+
for (const item of valid) {
|
|
745
|
+
const identity = stableGlossaryTermIdentity(item.cue.term);
|
|
746
|
+
const group = grouped.get(identity) ?? [];
|
|
747
|
+
group.push(item);
|
|
748
|
+
grouped.set(identity, group);
|
|
749
|
+
}
|
|
750
|
+
const output = [];
|
|
751
|
+
for (const group of grouped.values()) {
|
|
752
|
+
if (new Set(group.map((item) => item.cue.meaning)).size > 1)
|
|
753
|
+
continue;
|
|
754
|
+
const item = [...group].sort((left, right) => rawCueOrder(left.raw, right.raw, text))[0];
|
|
755
|
+
const cue = item.cue;
|
|
756
|
+
output.push({
|
|
757
|
+
term: cue.term,
|
|
758
|
+
meaning: cue.meaning,
|
|
759
|
+
term_span: utf8Span(text, cue.termStart, cue.termEnd),
|
|
760
|
+
meaning_span: utf8Span(text, cue.meaningStart, cue.meaningEnd),
|
|
761
|
+
});
|
|
762
|
+
}
|
|
763
|
+
const unique = new Map();
|
|
764
|
+
for (const cue of output) {
|
|
765
|
+
unique.set(`${stableGlossaryTermIdentity(cue.term)}:${cue.meaning}:${cue.term_span.start}:${cue.meaning_span.start}`, cue);
|
|
766
|
+
}
|
|
767
|
+
return [...unique.values()].sort((left, right) => compareText(left.term, right.term) ||
|
|
768
|
+
compareText(left.meaning, right.meaning) ||
|
|
769
|
+
left.term_span.start - right.term_span.start);
|
|
770
|
+
}
|
|
771
|
+
/** Backwards-compatible narrow classifier, now backed by the deterministic cue parser. */
|
|
772
|
+
export function classifyExplicitGlossaryLanguage(text) {
|
|
773
|
+
const cues = discoverExplicitGlossaryCues(text);
|
|
774
|
+
if (cues.length === 0)
|
|
775
|
+
return null;
|
|
776
|
+
const identities = new Map();
|
|
777
|
+
for (const cue of cues) {
|
|
778
|
+
const identity = stableGlossaryTermIdentity(cue.term);
|
|
779
|
+
const meanings = identities.get(identity) ?? new Set();
|
|
780
|
+
meanings.add(cue.meaning);
|
|
781
|
+
identities.set(identity, meanings);
|
|
782
|
+
}
|
|
783
|
+
if ([...identities.values()].some((meanings) => meanings.size > 1))
|
|
784
|
+
return null;
|
|
785
|
+
const first = cues[0];
|
|
786
|
+
return { term: first.term, meaning: first.meaning };
|
|
787
|
+
}
|
|
788
|
+
export { mineExplicitGlossaryCandidates, mineExplicitGlossaryEvidence, minePersonalExplicitGlossaryCandidates, } from "./personalGlossaryExplicitMining.js";
|