agentera 3.0.0-dev.8 → 3.0.0-dev.81
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 +252 -22
- package/bundle/.agentera-build-source.json +8 -0
- package/bundle/CHANGELOG.md +1389 -0
- package/bundle/DESIGN.md +229 -0
- package/bundle/LICENSE +201 -0
- package/bundle/README.md +142 -0
- package/bundle/UPGRADE.md +275 -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 +443 -188
- package/bundle/references/adapters/package-surface-characterization.md +68 -34
- package/bundle/references/adapters/product-v1-reset.yaml +101 -0
- 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 +357 -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 +262 -0
- package/bundle/references/artifacts/artifact-registry-interface-model.yaml +17 -8
- package/bundle/references/artifacts/glossary-entry-contract.yaml +2906 -0
- package/bundle/references/artifacts/state-storage-authority.yaml +3075 -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 +7 -5
- package/bundle/references/cli/vocabulary-index.yaml +7 -9
- package/bundle/references/cli/vocabulary.md +54 -97
- package/bundle/references/meta/retained-reference-authority.yaml +171 -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 +29 -30
- package/bundle/skills/agentera/schemas/artifacts/design.yaml +1 -0
- package/bundle/skills/agentera/schemas/artifacts/docs.yaml +7 -43
- package/bundle/skills/agentera/schemas/artifacts/experiments.yaml +140 -34
- package/bundle/skills/agentera/schemas/artifacts/glossary.yaml +87 -0
- package/bundle/skills/agentera/schemas/artifacts/health.yaml +53 -51
- package/bundle/skills/agentera/schemas/artifacts/objective.yaml +18 -35
- package/bundle/skills/agentera/schemas/artifacts/plan.yaml +453 -55
- package/bundle/skills/agentera/schemas/artifacts/progress.yaml +128 -39
- package/bundle/skills/agentera/schemas/artifacts/todo.yaml +305 -7
- package/bundle/skills/agentera/schemas/artifacts/vision.yaml +0 -19
- 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 +788 -0
- package/dist/analytics/personalGlossaryCandidateProjectionExcerpts.js +144 -0
- package/dist/analytics/personalGlossaryCandidateProjectionModel.js +1 -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/personalGlossaryRefreshProjection.js +351 -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 +52 -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 +162 -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 +755 -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 +338 -0
- package/dist/cli/commands/prime/collectOrientationState.js +124 -68
- package/dist/cli/commands/prime/orientationOutput.js +271 -59
- package/dist/cli/commands/prime/types.js +0 -1
- package/dist/cli/commands/prime.js +89 -11
- package/dist/cli/commands/profileGrounding.js +55 -0
- package/dist/cli/commands/query.js +74 -52
- package/dist/cli/commands/report.js +187 -27
- 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 +459 -0
- package/dist/cli/commands/upgrade.js +176 -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 +84 -52
- package/dist/cli/dispatch/lifecycle.js +182 -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 +419 -41
- package/dist/cli/migrationRequired.js +125 -0
- package/dist/cli/orientation/attention.js +19 -22
- 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/productV1Eol.js +55 -0
- package/dist/cli/profileAcquisition.js +167 -0
- package/dist/cli/startupCompletenessContract.js +11 -9
- 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 +145 -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 +345 -0
- package/dist/registries/glossaryCandidateProjectionContract.js +108 -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 +168 -11
- 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 +618 -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 +894 -0
- package/dist/state/entityWriterLock.js +18 -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/todoCreateBatch.js +69 -0
- package/dist/state/todoDocsEntities.js +1339 -0
- package/dist/state/todoDocsEntityValidation.js +158 -0
- package/dist/state/todoMarkdownProjection.js +63 -0
- package/dist/state/todoReconciliationActivation.js +182 -0
- package/dist/state/todoReconciliationInspection.js +184 -0
- package/dist/state/todoReconciliationRepair.js +320 -0
- package/dist/state/todoReconciliationTransaction.js +628 -0
- package/dist/state/todoSeverityHeadings.js +71 -0
- package/dist/state/todoTransitionBatch.js +65 -0
- package/dist/state/todoUpdateBatch.js +50 -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 +380 -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 +133 -34
- package/dist/upgrade/lifecycleUpgrade.js +126 -0
- package/dist/upgrade/migrateArtifactsV2ToV3.js +325 -82
- package/dist/upgrade/migrationPublication.js +122 -0
- package/dist/upgrade/nextMajorDoctor.js +0 -22
- package/dist/upgrade/npxPlatformStatus.js +2 -2
- package/dist/upgrade/productV1Reset.js +515 -0
- package/dist/upgrade/productV1ResetAuthority.js +139 -0
- package/dist/upgrade/projectIntegration.js +126 -134
- package/dist/upgrade/projectIntegrationDecision.js +21 -13
- package/dist/upgrade/retiredResourceDiagnostics.js +117 -0
- package/dist/upgrade/runtimeMigration.js +210 -430
- package/dist/upgrade/upgradeCommands.js +14 -1
- package/dist/upgrade/upgradeLock.js +85 -0
- package/dist/upgrade/upgradeOrchestrator.js +257 -48
- 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/glossaryVariantGuard.js +96 -0
- package/dist/validate/retainedReferenceAuthority.js +879 -0
- package/dist/validate/selfAudit.js +39 -45
- 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/index.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/plan/instructions.js.map +0 -1
- package/dist/capabilities/profile/instructions.js.map +0 -1
- package/dist/capabilities/research/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/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/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/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/types.js.map +0 -1
- package/dist/cli/commands/prime/v1Migration.js +0 -39
- 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/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/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/types.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/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/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/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/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/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,418 @@
|
|
|
1
|
+
import { EXPLICIT_SEGMENT_REASONS, explicitSegmentTransition, } from "../registries/explicitSegmentGrammarContract.js";
|
|
2
|
+
import { stableGlossaryTermIdentity } from "../registries/glossaryTermIdentity.js";
|
|
3
|
+
import { EXPLICIT_GLOSSARY_REASONS, } from "./personalGlossaryExplicitTypes.js";
|
|
4
|
+
const LETTER_OR_NUMBER_RE = /[\p{L}\p{N}]/u;
|
|
5
|
+
const EXAMPLE_RE = /\b(?:for\s+example|e\.g\.?|example|such\s+as)\b/iu;
|
|
6
|
+
const HYPOTHETICAL_RE = /\b(?:if|when|unless|whenever|suppose|assuming|hypothetically|imagine|would|could|might|may)\b/iu;
|
|
7
|
+
const QUESTION_RE = /\?|^\s*(?:does|do|did|can|could|would|should|what|why|how)\b/iu;
|
|
8
|
+
const INDIRECT_QUESTION_RE = /\b(?:i\s+(?:wonder|ask|want\s+to\s+know)|tell\s+me|whether|what|why|how)\b/iu;
|
|
9
|
+
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;
|
|
10
|
+
const FOLLOWING_CUE_REFERENCE_RE = /\b(?:the\s+)?following\s+(?:definition|term|meaning)\b/iu;
|
|
11
|
+
const PREVIOUS_CUE_REFERENCE_RE = /\bthis\s+(?:definition|term|meaning)\b/iu;
|
|
12
|
+
function lineIndexAt(lines, position) {
|
|
13
|
+
let low = 0;
|
|
14
|
+
let high = lines.length - 1;
|
|
15
|
+
while (low <= high) {
|
|
16
|
+
const middle = Math.floor((low + high) / 2);
|
|
17
|
+
const line = lines[middle];
|
|
18
|
+
if (position < line.start)
|
|
19
|
+
high = middle - 1;
|
|
20
|
+
else if (position > line.end)
|
|
21
|
+
low = middle + 1;
|
|
22
|
+
else
|
|
23
|
+
return middle;
|
|
24
|
+
}
|
|
25
|
+
return Math.max(0, Math.min(lines.length - 1, low));
|
|
26
|
+
}
|
|
27
|
+
function hasListMarker(value) {
|
|
28
|
+
return /^\s*(?:[-*+]\s+|\d+[.)]\s+)/u.test(value) || /^\s*---\s*$/u.test(value);
|
|
29
|
+
}
|
|
30
|
+
function hasBlockScalarHeader(value) {
|
|
31
|
+
return /^\s*[^:#\n][^:\n]*:\s*[|>](?:[1-9])?(?:[+-])?\s*$/u.test(value);
|
|
32
|
+
}
|
|
33
|
+
function hasHeadingMarker(value) {
|
|
34
|
+
return /^\s*#{1,6}(?:\s|$)/u.test(value);
|
|
35
|
+
}
|
|
36
|
+
function safeMarkerPrefix(value) {
|
|
37
|
+
return /^\s*(?:[-*+]\s+)?(?:definition|term|correction|sarcasm)\s*:\s*$/iu.test(value);
|
|
38
|
+
}
|
|
39
|
+
function linePlans(text, raws, ranges, deps) {
|
|
40
|
+
const lines = deps.lineRanges(text);
|
|
41
|
+
const byLine = lines.map(() => []);
|
|
42
|
+
for (const raw of raws) {
|
|
43
|
+
if (raw.termStart === raw.termEnd && raw.meaningStart === raw.meaningEnd)
|
|
44
|
+
continue;
|
|
45
|
+
byLine[lineIndexAt(lines, raw.termStart)].push(raw);
|
|
46
|
+
}
|
|
47
|
+
return lines.map((line, index) => {
|
|
48
|
+
const comment = deps.commentStart(text, line, ranges);
|
|
49
|
+
const scanEnd = comment < 0 ? line.end : comment;
|
|
50
|
+
const value = text.slice(line.start, scanEnd);
|
|
51
|
+
const trimmed = value.trim();
|
|
52
|
+
const rawsOnLine = byLine[index].sort((left, right) => deps.rawCueOrder(left, right, text));
|
|
53
|
+
const firstColon = deps.colonOutsideRanges(text, line.start, scanEnd, ranges);
|
|
54
|
+
const firstRaw = rawsOnLine[0];
|
|
55
|
+
const markerPrefix = firstColon >= 0 && firstRaw !== undefined
|
|
56
|
+
? safeMarkerPrefix(text.slice(line.start, firstColon + 1))
|
|
57
|
+
: false;
|
|
58
|
+
const unsafePrefix = firstColon >= 0 && firstRaw !== undefined && firstColon < firstRaw.termStart && !markerPrefix;
|
|
59
|
+
const leadingWhitespace = /^\s+\S/u.test(value);
|
|
60
|
+
const commentOnly = text.slice(line.start, line.end).trim().startsWith("#");
|
|
61
|
+
const listMarker = hasListMarker(value);
|
|
62
|
+
const heading = hasHeadingMarker(value);
|
|
63
|
+
const blockScalar = hasBlockScalarHeader(value);
|
|
64
|
+
const approved = rawsOnLine.length > 0 &&
|
|
65
|
+
!leadingWhitespace &&
|
|
66
|
+
!commentOnly &&
|
|
67
|
+
!heading &&
|
|
68
|
+
!blockScalar &&
|
|
69
|
+
!unsafePrefix;
|
|
70
|
+
let kind;
|
|
71
|
+
if (commentOnly)
|
|
72
|
+
kind = "comment";
|
|
73
|
+
else if (trimmed.length === 0)
|
|
74
|
+
kind = "blank";
|
|
75
|
+
else if (leadingWhitespace)
|
|
76
|
+
kind = "indentation";
|
|
77
|
+
else if (approved)
|
|
78
|
+
kind = "approved_cue";
|
|
79
|
+
else if (listMarker)
|
|
80
|
+
kind = "list_boundary";
|
|
81
|
+
else if (heading || blockScalar || firstColon >= 0)
|
|
82
|
+
kind = "structural_fragment";
|
|
83
|
+
else
|
|
84
|
+
kind = "prose";
|
|
85
|
+
const input = kind === "blank"
|
|
86
|
+
? "blank_line"
|
|
87
|
+
: kind === "comment"
|
|
88
|
+
? "comment"
|
|
89
|
+
: kind === "indentation"
|
|
90
|
+
? "indentation"
|
|
91
|
+
: kind === "list_boundary"
|
|
92
|
+
? "list_boundary"
|
|
93
|
+
: kind === "structural_fragment"
|
|
94
|
+
? blockScalar
|
|
95
|
+
? "block_scalar"
|
|
96
|
+
: heading || trimmed.startsWith("#")
|
|
97
|
+
? "comment"
|
|
98
|
+
: "structural_fragment"
|
|
99
|
+
: kind === "approved_cue"
|
|
100
|
+
? "approved_cue"
|
|
101
|
+
: "prose";
|
|
102
|
+
return { ...line, scanEnd, kind, input, raws: rawsOnLine };
|
|
103
|
+
});
|
|
104
|
+
}
|
|
105
|
+
function structuralRejection(line, reason) {
|
|
106
|
+
return {
|
|
107
|
+
kind: "structural_fragment",
|
|
108
|
+
termStart: line.start,
|
|
109
|
+
termEnd: line.start,
|
|
110
|
+
meaningStart: line.start,
|
|
111
|
+
meaningEnd: line.start,
|
|
112
|
+
sentenceStart: line.start,
|
|
113
|
+
sentenceEnd: line.end,
|
|
114
|
+
rejectionReason: reason,
|
|
115
|
+
};
|
|
116
|
+
}
|
|
117
|
+
function loadedStructuralReason(transition) {
|
|
118
|
+
return transition.reason === EXPLICIT_SEGMENT_REASONS.structuralFragment
|
|
119
|
+
? transition.reason
|
|
120
|
+
: EXPLICIT_GLOSSARY_REASONS.structuralFragment;
|
|
121
|
+
}
|
|
122
|
+
function segmentRawCues(text, initial, ranges, grammar, deps) {
|
|
123
|
+
const plans = linePlans(text, initial, ranges, deps);
|
|
124
|
+
const accepted = [];
|
|
125
|
+
let state = grammar.initialState;
|
|
126
|
+
for (const plan of plans) {
|
|
127
|
+
if (state === "structural_config") {
|
|
128
|
+
const transition = explicitSegmentTransition(grammar, state, plan.input);
|
|
129
|
+
if (plan.kind === "prose") {
|
|
130
|
+
accepted.push(structuralRejection(plan, loadedStructuralReason(transition)));
|
|
131
|
+
state = transition.to;
|
|
132
|
+
continue;
|
|
133
|
+
}
|
|
134
|
+
if (plan.kind !== "blank" && plan.kind !== "comment") {
|
|
135
|
+
accepted.push(structuralRejection(plan, loadedStructuralReason(transition)));
|
|
136
|
+
}
|
|
137
|
+
continue;
|
|
138
|
+
}
|
|
139
|
+
if (plan.kind === "approved_cue") {
|
|
140
|
+
const transition = explicitSegmentTransition(grammar, state, "approved_cue");
|
|
141
|
+
if (transition.to === "cue")
|
|
142
|
+
accepted.push(...plan.raws);
|
|
143
|
+
continue;
|
|
144
|
+
}
|
|
145
|
+
if (plan.kind === "structural_fragment" || plan.kind === "list_boundary") {
|
|
146
|
+
const transition = explicitSegmentTransition(grammar, state, plan.input);
|
|
147
|
+
if (transition.to === "structural_config") {
|
|
148
|
+
state = transition.to;
|
|
149
|
+
accepted.push(structuralRejection(plan, loadedStructuralReason(transition)));
|
|
150
|
+
}
|
|
151
|
+
}
|
|
152
|
+
else if (plan.kind === "comment" && /:\s*/u.test(text.slice(plan.start, plan.end))) {
|
|
153
|
+
const transition = explicitSegmentTransition(grammar, state, "structural_fragment");
|
|
154
|
+
accepted.push(structuralRejection(plan, loadedStructuralReason(transition)));
|
|
155
|
+
}
|
|
156
|
+
}
|
|
157
|
+
return { raws: accepted, plans };
|
|
158
|
+
}
|
|
159
|
+
function firstRawAfter(plan, position, text, deps) {
|
|
160
|
+
return plan.raws
|
|
161
|
+
.filter((raw) => raw.termStart > position)
|
|
162
|
+
.sort((left, right) => deps.rawCueOrder(left, right, text))[0];
|
|
163
|
+
}
|
|
164
|
+
function cueBoundaryStart(text, cue, closeToOpen) {
|
|
165
|
+
if (cue.kind === "definition_list") {
|
|
166
|
+
const floor = Math.max(text.lastIndexOf("\n", cue.termStart - 1), text.lastIndexOf(";", cue.termStart - 1)) + 1;
|
|
167
|
+
const prefix = text.slice(floor, cue.termStart);
|
|
168
|
+
if (/^\s*(?:[-*+]\s+)?(?:definition|term)\s*:\s*$/iu.test(prefix)) {
|
|
169
|
+
const first = prefix.search(/\S/u);
|
|
170
|
+
if (first >= 0)
|
|
171
|
+
return floor + first;
|
|
172
|
+
}
|
|
173
|
+
}
|
|
174
|
+
const opening = closeToOpen.get(text[cue.termEnd] ?? "");
|
|
175
|
+
if (opening !== undefined) {
|
|
176
|
+
const start = text.lastIndexOf(opening, cue.termStart);
|
|
177
|
+
if (start >= 0)
|
|
178
|
+
return start;
|
|
179
|
+
}
|
|
180
|
+
return cue.termStart;
|
|
181
|
+
}
|
|
182
|
+
function isBoundaryLine(plan) {
|
|
183
|
+
return ["blank", "comment", "indentation", "list_boundary", "structural_fragment"].includes(plan.kind);
|
|
184
|
+
}
|
|
185
|
+
function sentenceRanges(text, ranges, deps) {
|
|
186
|
+
const boundaries = deps.sentenceBoundaries(text, ranges);
|
|
187
|
+
return [0, ...boundaries].map((start, index, starts) => ({
|
|
188
|
+
start,
|
|
189
|
+
end: starts[index + 1] ?? text.length,
|
|
190
|
+
}));
|
|
191
|
+
}
|
|
192
|
+
function nearMissTermOccurs(text, term, start, end) {
|
|
193
|
+
const literal = escapedTerm(term);
|
|
194
|
+
if (!literal)
|
|
195
|
+
return false;
|
|
196
|
+
const identifierContinue = "\\p{ID_Continue}$\\u200C\\u200D";
|
|
197
|
+
return new RegExp(`(?:(?<![${identifierContinue}])${literal}(?=[${identifierContinue}])|(?<=[${identifierContinue}])${literal}(?![${identifierContinue}]))`, "iu").test(text.slice(start, end));
|
|
198
|
+
}
|
|
199
|
+
function referenceLikeQualifierStart(text, line, raws, ranges, deps) {
|
|
200
|
+
for (const sentence of sentenceRanges(text, ranges, deps)) {
|
|
201
|
+
if (sentence.end <= line.start || sentence.start > line.end)
|
|
202
|
+
continue;
|
|
203
|
+
const value = text.slice(sentence.start, sentence.end);
|
|
204
|
+
if (!referenceQualifier(value))
|
|
205
|
+
continue;
|
|
206
|
+
const following = value.match(new RegExp(FOLLOWING_CUE_REFERENCE_RE.source, "iu"));
|
|
207
|
+
if (following?.index !== undefined)
|
|
208
|
+
return Math.max(sentence.start, line.start);
|
|
209
|
+
const previous = value.match(new RegExp(PREVIOUS_CUE_REFERENCE_RE.source, "iu"));
|
|
210
|
+
if (previous?.index !== undefined)
|
|
211
|
+
return Math.max(sentence.start, line.start);
|
|
212
|
+
if (raws.some((raw) => raw.rejectionReason === undefined &&
|
|
213
|
+
raw.termStart >= sentence.start &&
|
|
214
|
+
raw.termStart < sentence.end))
|
|
215
|
+
continue;
|
|
216
|
+
for (const raw of raws) {
|
|
217
|
+
if (raw.rejectionReason !== undefined || raw.termEnd <= raw.termStart)
|
|
218
|
+
continue;
|
|
219
|
+
const term = text.slice(raw.termStart, raw.termEnd).trim();
|
|
220
|
+
const occurrence = exactTermOccurrences(text, term, sentence.start, sentence.end)[0];
|
|
221
|
+
if (occurrence !== undefined ||
|
|
222
|
+
nearMissTermOccurs(text, term, sentence.start, sentence.end)) {
|
|
223
|
+
return Math.max(sentence.start, line.start);
|
|
224
|
+
}
|
|
225
|
+
}
|
|
226
|
+
}
|
|
227
|
+
return null;
|
|
228
|
+
}
|
|
229
|
+
function boundedSegmentCues(text, raws, plans, ranges, grammar, deps) {
|
|
230
|
+
const lines = deps.lineRanges(text);
|
|
231
|
+
const structural = raws.filter((raw) => raw.termStart === raw.termEnd && raw.meaningStart === raw.meaningEnd);
|
|
232
|
+
const usable = raws.filter((raw) => !(raw.termStart === raw.termEnd && raw.meaningStart === raw.meaningEnd));
|
|
233
|
+
const bounded = usable.map((raw) => {
|
|
234
|
+
if (raw.kind === "acronym_parenthetical")
|
|
235
|
+
return raw;
|
|
236
|
+
if (raw.kind !== "definition_list") {
|
|
237
|
+
const line = plans[lineIndexAt(lines, raw.termStart)];
|
|
238
|
+
const next = firstRawAfter(line, raw.termStart, text, deps);
|
|
239
|
+
const boundary = next === undefined ? raw.sentenceEnd : cueBoundaryStart(text, next, deps.closeToOpen);
|
|
240
|
+
const end = boundary < raw.sentenceEnd ? boundary : raw.sentenceEnd;
|
|
241
|
+
const [meaningStart, meaningEnd] = deps.unwrapMeaning(text, ...deps.trimMeaning(text, raw.meaningStart, end));
|
|
242
|
+
return { ...raw, meaningStart, meaningEnd };
|
|
243
|
+
}
|
|
244
|
+
const lineIndex = lineIndexAt(lines, raw.termStart);
|
|
245
|
+
const line = plans[lineIndex];
|
|
246
|
+
const nextOnLine = firstRawAfter(line, raw.termStart, text, deps);
|
|
247
|
+
let end = nextOnLine ? cueBoundaryStart(text, nextOnLine, deps.closeToOpen) : line.scanEnd;
|
|
248
|
+
const referenceStart = referenceLikeQualifierStart(text, line, raws, ranges, deps);
|
|
249
|
+
const sameLineReference = referenceStart !== null && referenceStart > raw.meaningStart ? referenceStart : null;
|
|
250
|
+
if (sameLineReference !== null) {
|
|
251
|
+
end = Math.min(end, sameLineReference);
|
|
252
|
+
}
|
|
253
|
+
let state = "cue";
|
|
254
|
+
const inline = deps.trimMeaning(text, raw.meaningStart, end);
|
|
255
|
+
const inlineNonEmpty = LETTER_OR_NUMBER_RE.test(text.slice(...inline));
|
|
256
|
+
const cueTransition = explicitSegmentTransition(grammar, state, inlineNonEmpty ? "non_empty_inline_meaning" : nextOnLine ? "next_cue" : "blank_line");
|
|
257
|
+
if (!inlineNonEmpty) {
|
|
258
|
+
return {
|
|
259
|
+
...raw,
|
|
260
|
+
meaningStart: inline[0],
|
|
261
|
+
meaningEnd: inline[1],
|
|
262
|
+
...(raw.rejectionReason === undefined
|
|
263
|
+
? { rejectionReason: EXPLICIT_GLOSSARY_REASONS.emptyMeaning }
|
|
264
|
+
: {}),
|
|
265
|
+
};
|
|
266
|
+
}
|
|
267
|
+
state = cueTransition.to;
|
|
268
|
+
let lastIncludedEnd = end;
|
|
269
|
+
for (let index = lineIndex + 1; sameLineReference === null && index < plans.length; index += 1) {
|
|
270
|
+
const nextPlan = plans[index];
|
|
271
|
+
const nextCue = nextPlan.raws.find((candidate) => candidate.termStart > raw.termStart);
|
|
272
|
+
const transition = explicitSegmentTransition(grammar, state, nextPlan.input);
|
|
273
|
+
if (isBoundaryLine(nextPlan)) {
|
|
274
|
+
end = nextPlan.start;
|
|
275
|
+
break;
|
|
276
|
+
}
|
|
277
|
+
if (nextCue !== undefined) {
|
|
278
|
+
end = cueBoundaryStart(text, nextCue, deps.closeToOpen);
|
|
279
|
+
break;
|
|
280
|
+
}
|
|
281
|
+
const referenceStart = referenceLikeQualifierStart(text, nextPlan, raws, ranges, deps);
|
|
282
|
+
if (referenceStart !== null) {
|
|
283
|
+
end = referenceStart;
|
|
284
|
+
break;
|
|
285
|
+
}
|
|
286
|
+
state = transition.to;
|
|
287
|
+
if (state !== "continuation") {
|
|
288
|
+
end = nextPlan.start;
|
|
289
|
+
break;
|
|
290
|
+
}
|
|
291
|
+
lastIncludedEnd = nextPlan.end;
|
|
292
|
+
end = lastIncludedEnd;
|
|
293
|
+
if (nextPlan.kind === "approved_cue") {
|
|
294
|
+
end = nextPlan.start;
|
|
295
|
+
break;
|
|
296
|
+
}
|
|
297
|
+
}
|
|
298
|
+
const [meaningStart, meaningEnd] = deps.unwrapMeaning(text, ...deps.trimMeaning(text, raw.meaningStart, end));
|
|
299
|
+
const overBound = Buffer.byteLength(text.slice(meaningStart, meaningEnd), "utf8") >
|
|
300
|
+
grammar.continuation.maximumUtf8Bytes;
|
|
301
|
+
return {
|
|
302
|
+
...raw,
|
|
303
|
+
meaningStart,
|
|
304
|
+
meaningEnd,
|
|
305
|
+
...(overBound && raw.rejectionReason === undefined
|
|
306
|
+
? { rejectionReason: EXPLICIT_GLOSSARY_REASONS.meaningBoundExceeded }
|
|
307
|
+
: {}),
|
|
308
|
+
};
|
|
309
|
+
});
|
|
310
|
+
return [...bounded, ...structural];
|
|
311
|
+
}
|
|
312
|
+
function escapedTerm(term) {
|
|
313
|
+
return term.replace(/[.*+?^${}()|[\]\\]/g, "\\$&");
|
|
314
|
+
}
|
|
315
|
+
function exactTermOccurrences(text, term, start, end) {
|
|
316
|
+
const literal = escapedTerm(term);
|
|
317
|
+
if (!literal)
|
|
318
|
+
return [];
|
|
319
|
+
const expression = new RegExp(`(?<![\\p{ID_Continue}$\\u200C\\u200D])${literal}(?![\\p{ID_Continue}$\\u200C\\u200D])`, "giu");
|
|
320
|
+
return [...text.slice(start, end).matchAll(expression)].map((match) => start + (match.index ?? 0));
|
|
321
|
+
}
|
|
322
|
+
function occurrenceInsideMeaning(position, raw) {
|
|
323
|
+
return position >= raw.meaningStart && position < raw.meaningEnd;
|
|
324
|
+
}
|
|
325
|
+
function referenceQualifier(text) {
|
|
326
|
+
if (EXAMPLE_RE.test(text))
|
|
327
|
+
return EXPLICIT_GLOSSARY_REASONS.exampleContext;
|
|
328
|
+
if (HYPOTHETICAL_RE.test(text))
|
|
329
|
+
return EXPLICIT_GLOSSARY_REASONS.hypotheticalDefinition;
|
|
330
|
+
if (INDIRECT_QUESTION_RE.test(text) || QUESTION_RE.test(text)) {
|
|
331
|
+
return EXPLICIT_GLOSSARY_REASONS.indirectQuestion;
|
|
332
|
+
}
|
|
333
|
+
if (FUTURE_RE.test(text))
|
|
334
|
+
return EXPLICIT_GLOSSARY_REASONS.futureDefinition;
|
|
335
|
+
return null;
|
|
336
|
+
}
|
|
337
|
+
function applyReferenceBindings(text, raws, ranges, deps) {
|
|
338
|
+
const sentences = sentenceRanges(text, ranges, deps);
|
|
339
|
+
const cues = raws
|
|
340
|
+
.filter((raw) => raw.rejectionReason === undefined &&
|
|
341
|
+
raw.termEnd > raw.termStart &&
|
|
342
|
+
raw.meaningEnd > raw.meaningStart)
|
|
343
|
+
.sort((left, right) => deps.rawCueOrder(left, right, text));
|
|
344
|
+
const rejected = new Map();
|
|
345
|
+
const missing = [];
|
|
346
|
+
const reject = (target, reason) => {
|
|
347
|
+
if (!rejected.has(target))
|
|
348
|
+
rejected.set(target, reason);
|
|
349
|
+
};
|
|
350
|
+
const cueSentence = (cue) => Math.max(0, sentences.findIndex((sentence) => cue.termStart >= sentence.start && cue.termStart < sentence.end));
|
|
351
|
+
const cuesBySentence = sentences.map((_, index) => cues.filter((cue) => cueSentence(cue) === index));
|
|
352
|
+
for (const [sentenceIndex, sentence] of sentences.entries()) {
|
|
353
|
+
const value = text.slice(sentence.start, sentence.end);
|
|
354
|
+
const qualifier = referenceQualifier(value);
|
|
355
|
+
if (!qualifier)
|
|
356
|
+
continue;
|
|
357
|
+
for (const match of value.matchAll(new RegExp(FOLLOWING_CUE_REFERENCE_RE.source, "giu"))) {
|
|
358
|
+
const position = sentence.start + (match.index ?? 0) + match[0].length;
|
|
359
|
+
const target = (cuesBySentence[sentenceIndex + 1] ?? []).find((cue) => cue.termStart >= position);
|
|
360
|
+
if (target)
|
|
361
|
+
reject(target, qualifier);
|
|
362
|
+
else
|
|
363
|
+
missing.push(structuralRejection({ start: sentence.start, end: sentence.end }, EXPLICIT_GLOSSARY_REASONS.ambiguousReference));
|
|
364
|
+
}
|
|
365
|
+
for (const match of value.matchAll(new RegExp(PREVIOUS_CUE_REFERENCE_RE.source, "giu"))) {
|
|
366
|
+
const position = sentence.start + (match.index ?? 0);
|
|
367
|
+
const target = [...(cuesBySentence[sentenceIndex - 1] ?? [])]
|
|
368
|
+
.reverse()
|
|
369
|
+
.find((cue) => cue.termStart < position);
|
|
370
|
+
if (target)
|
|
371
|
+
reject(target, qualifier);
|
|
372
|
+
else
|
|
373
|
+
missing.push(structuralRejection({ start: sentence.start, end: sentence.end }, EXPLICIT_GLOSSARY_REASONS.ambiguousReference));
|
|
374
|
+
}
|
|
375
|
+
if (cues.some((cue) => cue.termStart >= sentence.start && cue.termStart < sentence.end))
|
|
376
|
+
continue;
|
|
377
|
+
const directExactReference = QUESTION_RE.test(value) ||
|
|
378
|
+
EXAMPLE_RE.test(value) ||
|
|
379
|
+
HYPOTHETICAL_RE.test(value) ||
|
|
380
|
+
FUTURE_RE.test(value);
|
|
381
|
+
const nearbyCues = cues.filter((cue) => Math.abs(cueSentence(cue) - sentenceIndex) <= 1);
|
|
382
|
+
const matches = new Map();
|
|
383
|
+
for (const cue of nearbyCues) {
|
|
384
|
+
const term = text.slice(cue.termStart, cue.termEnd).trim();
|
|
385
|
+
const occurrences = exactTermOccurrences(text, term, sentence.start, sentence.end).filter((position) => !nearbyCues.some((other) => other !== cue &&
|
|
386
|
+
other.rejectionReason === undefined &&
|
|
387
|
+
occurrenceInsideMeaning(position, other) &&
|
|
388
|
+
!directExactReference));
|
|
389
|
+
if (occurrences.length > 0) {
|
|
390
|
+
const identity = stableGlossaryTermIdentity(term);
|
|
391
|
+
matches.set(identity, [...(matches.get(identity) ?? []), cue]);
|
|
392
|
+
}
|
|
393
|
+
}
|
|
394
|
+
for (const group of matches.values()) {
|
|
395
|
+
const unique = [...new Map(group.map((cue) => [cue.termStart, cue])).values()];
|
|
396
|
+
if (unique.length > 1) {
|
|
397
|
+
for (const cue of unique)
|
|
398
|
+
reject(cue, EXPLICIT_GLOSSARY_REASONS.ambiguousReference);
|
|
399
|
+
}
|
|
400
|
+
else if (unique[0])
|
|
401
|
+
reject(unique[0], qualifier);
|
|
402
|
+
}
|
|
403
|
+
}
|
|
404
|
+
return [
|
|
405
|
+
...raws.map((raw) => {
|
|
406
|
+
const reason = rejected.get(raw);
|
|
407
|
+
return reason === undefined || raw.rejectionReason !== undefined
|
|
408
|
+
? raw
|
|
409
|
+
: { ...raw, rejectionReason: reason };
|
|
410
|
+
}),
|
|
411
|
+
...missing,
|
|
412
|
+
];
|
|
413
|
+
}
|
|
414
|
+
export function segmentAndBindExplicitCues(text, initial, ranges, grammar, deps) {
|
|
415
|
+
const segmented = segmentRawCues(text, initial, ranges, grammar, deps);
|
|
416
|
+
const bounded = boundedSegmentCues(text, segmented.raws, segmented.plans, ranges, grammar, deps);
|
|
417
|
+
return applyReferenceBindings(text, bounded, ranges, deps).sort((left, right) => deps.rawCueOrder(left, right, text));
|
|
418
|
+
}
|
|
@@ -0,0 +1,26 @@
|
|
|
1
|
+
export const EXPLICIT_GLOSSARY_REASONS = {
|
|
2
|
+
attributedQuotation: "attributed_quotation",
|
|
3
|
+
ambiguousReference: "ambiguous_reference",
|
|
4
|
+
conflictingMeaning: "conflicting_meaning",
|
|
5
|
+
emptyMeaning: "empty_meaning",
|
|
6
|
+
emptyTerm: "empty_term",
|
|
7
|
+
exampleContext: "example_context",
|
|
8
|
+
hypotheticalDefinition: "hypothetical_definition",
|
|
9
|
+
malformedSpan: "malformed_span",
|
|
10
|
+
meaningBoundExceeded: "meaning_bound_exceeded",
|
|
11
|
+
negatedDefinition: "negated_definition",
|
|
12
|
+
indirectQuestion: "indirect_question",
|
|
13
|
+
futureDefinition: "future_definition",
|
|
14
|
+
projectOnlyScope: "project_only_scope",
|
|
15
|
+
questionDefinition: "question_definition",
|
|
16
|
+
retractedDefinition: "retracted_definition",
|
|
17
|
+
sarcasmMarker: "sarcasm_marker",
|
|
18
|
+
staleAnchor: "stale_anchor",
|
|
19
|
+
structuralFragment: "structural_fragment",
|
|
20
|
+
termBoundExceeded: "term_bound_exceeded",
|
|
21
|
+
unsafeSyntax: "unsafe_syntax",
|
|
22
|
+
uncertainScope: "uncertain_scope",
|
|
23
|
+
unresolvedAnchor: "unresolved_anchor",
|
|
24
|
+
provenanceIncomplete: "provenance_incomplete",
|
|
25
|
+
userAuthorshipRequired: "user_authorship_required",
|
|
26
|
+
};
|
|
@@ -0,0 +1,175 @@
|
|
|
1
|
+
const COMMON_GRAMMAR_TERMS = new Set([
|
|
2
|
+
"a",
|
|
3
|
+
"an",
|
|
4
|
+
"and",
|
|
5
|
+
"are",
|
|
6
|
+
"as",
|
|
7
|
+
"at",
|
|
8
|
+
"be",
|
|
9
|
+
"by",
|
|
10
|
+
"can",
|
|
11
|
+
"could",
|
|
12
|
+
"do",
|
|
13
|
+
"each",
|
|
14
|
+
"for",
|
|
15
|
+
"from",
|
|
16
|
+
"has",
|
|
17
|
+
"have",
|
|
18
|
+
"how",
|
|
19
|
+
"if",
|
|
20
|
+
"in",
|
|
21
|
+
"into",
|
|
22
|
+
"is",
|
|
23
|
+
"it",
|
|
24
|
+
"must",
|
|
25
|
+
"no",
|
|
26
|
+
"not",
|
|
27
|
+
"of",
|
|
28
|
+
"on",
|
|
29
|
+
"one",
|
|
30
|
+
"only",
|
|
31
|
+
"or",
|
|
32
|
+
"should",
|
|
33
|
+
"that",
|
|
34
|
+
"the",
|
|
35
|
+
"then",
|
|
36
|
+
"this",
|
|
37
|
+
"to",
|
|
38
|
+
"use",
|
|
39
|
+
"version",
|
|
40
|
+
"when",
|
|
41
|
+
"which",
|
|
42
|
+
"why",
|
|
43
|
+
"with",
|
|
44
|
+
"would",
|
|
45
|
+
"yes",
|
|
46
|
+
"two",
|
|
47
|
+
"three",
|
|
48
|
+
]);
|
|
49
|
+
const ROUTINE_FREQUENCY_TERMS = new Set([
|
|
50
|
+
"always",
|
|
51
|
+
"frequently",
|
|
52
|
+
"generally",
|
|
53
|
+
"never",
|
|
54
|
+
"normally",
|
|
55
|
+
"occasionally",
|
|
56
|
+
"often",
|
|
57
|
+
"rarely",
|
|
58
|
+
"regularly",
|
|
59
|
+
"routinely",
|
|
60
|
+
"seldom",
|
|
61
|
+
"sometimes",
|
|
62
|
+
"typically",
|
|
63
|
+
"usually",
|
|
64
|
+
]);
|
|
65
|
+
const GENERIC_WORKFLOW_TERMS = new Set([
|
|
66
|
+
"change",
|
|
67
|
+
"check",
|
|
68
|
+
"choose",
|
|
69
|
+
"command",
|
|
70
|
+
"configuration",
|
|
71
|
+
"continue",
|
|
72
|
+
"correction",
|
|
73
|
+
"decision",
|
|
74
|
+
"file",
|
|
75
|
+
"keep",
|
|
76
|
+
"make",
|
|
77
|
+
"name",
|
|
78
|
+
"package",
|
|
79
|
+
"personal",
|
|
80
|
+
"project",
|
|
81
|
+
"repository",
|
|
82
|
+
"run",
|
|
83
|
+
"script",
|
|
84
|
+
"scripts",
|
|
85
|
+
]);
|
|
86
|
+
const KNOWN_COMMAND_WORDS = new Set([
|
|
87
|
+
"agentera",
|
|
88
|
+
"bash",
|
|
89
|
+
"build",
|
|
90
|
+
"cargo",
|
|
91
|
+
"cat",
|
|
92
|
+
"cd",
|
|
93
|
+
"check",
|
|
94
|
+
"ci",
|
|
95
|
+
"curl",
|
|
96
|
+
"git",
|
|
97
|
+
"install",
|
|
98
|
+
"lint",
|
|
99
|
+
"ls",
|
|
100
|
+
"make",
|
|
101
|
+
"node",
|
|
102
|
+
"npm",
|
|
103
|
+
"npx",
|
|
104
|
+
"pnpm",
|
|
105
|
+
"python",
|
|
106
|
+
"sh",
|
|
107
|
+
"tcsh",
|
|
108
|
+
"test",
|
|
109
|
+
"tsc",
|
|
110
|
+
"tsx",
|
|
111
|
+
"yarn",
|
|
112
|
+
]);
|
|
113
|
+
const KNOWN_COMMAND_INVOCATIONS = {
|
|
114
|
+
agentera: ["build", "check"],
|
|
115
|
+
cargo: ["build", "test"],
|
|
116
|
+
git: ["add", "branch", "checkout", "commit", "diff", "fetch", "log", "push", "status", "tag"],
|
|
117
|
+
npm: ["install", "test"],
|
|
118
|
+
pnpm: ["build", "install", "lint", "test", "typecheck"],
|
|
119
|
+
yarn: ["build", "install", "lint", "test"],
|
|
120
|
+
};
|
|
121
|
+
const KNOWN_COMMAND_SPELLINGS = new Set(Object.entries(KNOWN_COMMAND_INVOCATIONS).flatMap(([command, actions]) => actions.map((action) => `${command}${action}`)));
|
|
122
|
+
const KNOWN_COMMAND_COMPONENTS = new Set([
|
|
123
|
+
...KNOWN_COMMAND_WORDS,
|
|
124
|
+
...Object.keys(KNOWN_COMMAND_INVOCATIONS),
|
|
125
|
+
...Object.values(KNOWN_COMMAND_INVOCATIONS).flat(),
|
|
126
|
+
]);
|
|
127
|
+
const PATH_COMPONENTS = new Set([
|
|
128
|
+
"dist",
|
|
129
|
+
"home",
|
|
130
|
+
"lib",
|
|
131
|
+
"modules",
|
|
132
|
+
"node",
|
|
133
|
+
"node_modules",
|
|
134
|
+
"path",
|
|
135
|
+
"repo",
|
|
136
|
+
"src",
|
|
137
|
+
"tmp",
|
|
138
|
+
]);
|
|
139
|
+
function isKnownCommandSpelling(value) {
|
|
140
|
+
const lower = value.toLowerCase();
|
|
141
|
+
if (KNOWN_COMMAND_COMPONENTS.has(lower))
|
|
142
|
+
return true;
|
|
143
|
+
const compact = lower.replace(/[\s\-_/\\.:]+/gu, "");
|
|
144
|
+
return KNOWN_COMMAND_SPELLINGS.has(compact);
|
|
145
|
+
}
|
|
146
|
+
function isDirectPathToken(value, text, start, end) {
|
|
147
|
+
if (/[\\/]/u.test(value))
|
|
148
|
+
return true;
|
|
149
|
+
const previous = text[start - 1] ?? "";
|
|
150
|
+
const next = text[end] ?? "";
|
|
151
|
+
const dotIsPathPunctuation = previous === "." || (next === "." && /[\p{L}\p{N}]/u.test(text[end + 1] ?? ""));
|
|
152
|
+
return ["/", "\\"].includes(previous) || ["/", "\\"].includes(next) || dotIsPathPunctuation;
|
|
153
|
+
}
|
|
154
|
+
function isApprovedDerivedPathSpelling(value) {
|
|
155
|
+
const segments = value
|
|
156
|
+
.toLowerCase()
|
|
157
|
+
.split(/[-_.:]+/u)
|
|
158
|
+
.filter(Boolean);
|
|
159
|
+
return segments.length >= 2 && segments.every((segment) => PATH_COMPONENTS.has(segment));
|
|
160
|
+
}
|
|
161
|
+
/** Classify one complete cue without rewriting it or matching arbitrary substrings. */
|
|
162
|
+
export function classifyRecurringLexicalToken(value, text, start, end) {
|
|
163
|
+
const lower = value.toLowerCase();
|
|
164
|
+
if (COMMON_GRAMMAR_TERMS.has(lower) ||
|
|
165
|
+
ROUTINE_FREQUENCY_TERMS.has(lower) ||
|
|
166
|
+
GENERIC_WORKFLOW_TERMS.has(lower)) {
|
|
167
|
+
return "common_term";
|
|
168
|
+
}
|
|
169
|
+
if (isKnownCommandSpelling(value))
|
|
170
|
+
return "known_command";
|
|
171
|
+
if (isDirectPathToken(value, text, start, end) || isApprovedDerivedPathSpelling(value)) {
|
|
172
|
+
return "path_like";
|
|
173
|
+
}
|
|
174
|
+
return null;
|
|
175
|
+
}
|