@ycodium-ai/plugin-api 0.2.5557 → 0.2.5751
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/README.md +61 -65
- package/dist/_private/ycodium-attachment-kinds/chatAttachmentKinds.d.ts +34 -0
- package/dist/_private/ycodium-attachment-kinds/chatAttachmentKinds.js +70 -0
- package/dist/_private/ycodium-attachment-kinds/mediaKinds.d.ts +23 -0
- package/dist/_private/ycodium-attachment-kinds/mediaKinds.js +73 -0
- package/dist/_private/ycodium-composer-tokens/approvalFileChanges.d.ts +20 -0
- package/dist/_private/ycodium-composer-tokens/approvalFileChanges.js +45 -0
- package/dist/_private/ycodium-composer-tokens/composerFileLink.d.ts +1 -0
- package/dist/_private/ycodium-composer-tokens/composerFileLink.js +20 -0
- package/dist/_private/ycodium-composer-tokens/composerInlineTokens.d.ts +17 -0
- package/dist/_private/ycodium-composer-tokens/composerInlineTokens.js +91 -0
- package/dist/_private/ycodium-composer-tokens/composerLogic.d.ts +30 -0
- package/dist/_private/ycodium-composer-tokens/composerLogic.js +181 -0
- package/dist/_private/ycodium-composer-tokens/composerMentionDrag.d.ts +40 -0
- package/dist/_private/ycodium-composer-tokens/composerMentionDrag.js +60 -0
- package/dist/_private/ycodium-composer-tokens/composerPromptSegments.d.ts +16 -0
- package/dist/_private/ycodium-composer-tokens/composerPromptSegments.js +142 -0
- package/dist/_private/ycodium-composer-tokens/composerTrigger.d.ts +18 -0
- package/dist/_private/ycodium-composer-tokens/composerTrigger.js +44 -0
- package/dist/_private/ycodium-composer-tokens/contextWindowFormat.d.ts +2 -0
- package/dist/_private/ycodium-composer-tokens/contextWindowFormat.js +16 -0
- package/dist/_private/ycodium-composer-tokens/diffCount.d.ts +2 -0
- package/dist/_private/ycodium-composer-tokens/diffCount.js +15 -0
- package/dist/_private/ycodium-composer-tokens/pendingUserInput.d.ts +48 -0
- package/dist/_private/ycodium-composer-tokens/pendingUserInput.js +145 -0
- package/dist/_private/ycodium-composer-tokens/promptContextBlocks.d.ts +58 -0
- package/dist/_private/ycodium-composer-tokens/promptContextBlocks.js +121 -0
- package/dist/_private/ycodium-composer-tokens/proposedPlan.d.ts +21 -0
- package/dist/_private/ycodium-composer-tokens/proposedPlan.js +106 -0
- package/dist/_private/ycodium-composer-tokens/providerSkillSearch.d.ts +3 -0
- package/dist/_private/ycodium-composer-tokens/providerSkillSearch.js +79 -0
- package/dist/_private/ycodium-composer-tokens/providerSkills.d.ts +17 -0
- package/dist/_private/ycodium-composer-tokens/providerSkills.js +57 -0
- package/dist/_private/ycodium-composer-tokens/queueEntry.d.ts +31 -0
- package/dist/_private/ycodium-composer-tokens/queueEntry.js +44 -0
- package/dist/_private/ycodium-composer-tokens/reviewCommentBlocks.d.ts +29 -0
- package/dist/_private/ycodium-composer-tokens/reviewCommentBlocks.js +118 -0
- package/dist/_private/ycodium-composer-tokens/searchRanking.d.ts +27 -0
- package/dist/_private/ycodium-composer-tokens/searchRanking.js +129 -0
- package/dist/_private/ycodium-composer-tokens/skillTokens.d.ts +101 -0
- package/dist/_private/ycodium-composer-tokens/skillTokens.js +148 -0
- package/dist/_private/ycodium-composer-tokens/slashMenu.d.ts +130 -0
- package/dist/_private/ycodium-composer-tokens/slashMenu.js +175 -0
- package/dist/_private/ycodium-composer-tokens/userInputOptionText.d.ts +33 -0
- package/dist/_private/ycodium-composer-tokens/userInputOptionText.js +27 -0
- package/dist/_private/ycodium-credential-account/credentialAccount.d.ts +21 -0
- package/dist/_private/ycodium-credential-account/credentialAccount.js +62 -0
- package/dist/_private/ycodium-credential-account/quotaJson.d.ts +12 -0
- package/dist/_private/ycodium-credential-account/quotaJson.js +14 -0
- package/dist/_private/ycodium-credential-account/quotaRequest.d.ts +32 -0
- package/dist/_private/ycodium-credential-account/quotaRequest.js +60 -0
- package/dist/_private/ycodium-day-format/dayFormat.d.ts +31 -0
- package/dist/_private/ycodium-day-format/dayFormat.js +32 -0
- package/dist/_private/ycodium-day-format/timestampFormat.d.ts +35 -0
- package/dist/_private/ycodium-day-format/timestampFormat.js +119 -0
- package/dist/_private/ycodium-decision-order/decisionOrder.d.ts +19 -0
- package/dist/_private/ycodium-decision-order/decisionOrder.js +38 -0
- package/dist/_private/ycodium-diff-format/diffRendering.d.ts +42 -0
- package/dist/_private/ycodium-diff-format/diffRendering.js +171 -0
- package/dist/_private/ycodium-duration-format/durationFormat.d.ts +20 -0
- package/dist/_private/ycodium-duration-format/durationFormat.js +56 -0
- package/dist/_private/ycodium-fetch-ports/fetchPorts.d.ts +36 -0
- package/dist/_private/ycodium-fetch-ports/fetchPorts.js +69 -0
- package/dist/_private/ycodium-fetch-ports/netFault.d.ts +10 -0
- package/dist/_private/ycodium-fetch-ports/netFault.js +17 -0
- package/dist/_private/ycodium-full-access-mode/fullAccessNativeMode.d.ts +28 -0
- package/dist/_private/ycodium-full-access-mode/fullAccessNativeMode.js +30 -0
- package/dist/_private/ycodium-instance-config/homePath.d.ts +34 -0
- package/dist/_private/ycodium-instance-config/homePath.js +85 -0
- package/dist/_private/ycodium-instance-config/instanceConfig.d.ts +46 -0
- package/dist/_private/ycodium-instance-config/instanceConfig.js +111 -0
- package/dist/_private/ycodium-instance-config/launchArgs.d.ts +5 -0
- package/dist/_private/ycodium-instance-config/launchArgs.js +65 -0
- package/dist/_private/ycodium-instance-config/probeProcess.d.ts +39 -0
- package/dist/_private/ycodium-instance-config/probeProcess.js +55 -0
- package/dist/_private/ycodium-instance-config/programHomeSchema.d.ts +44 -0
- package/dist/_private/ycodium-instance-config/programHomeSchema.js +60 -0
- package/dist/_private/ycodium-instance-config/tomlScalar.d.ts +5 -0
- package/dist/_private/ycodium-instance-config/tomlScalar.js +11 -0
- package/dist/_private/ycodium-jsonl-stream/appendedJsonl.d.ts +47 -0
- package/dist/_private/ycodium-jsonl-stream/appendedJsonl.js +172 -0
- package/dist/_private/ycodium-jsonl-stream/claudeSessions.d.ts +63 -0
- package/dist/_private/ycodium-jsonl-stream/claudeSessions.js +220 -0
- package/dist/_private/ycodium-jsonl-stream/codexSessions.d.ts +41 -0
- package/dist/_private/ycodium-jsonl-stream/codexSessions.js +197 -0
- package/dist/_private/ycodium-jsonl-stream/history.d.ts +6 -0
- package/dist/_private/ycodium-jsonl-stream/history.js +389 -0
- package/dist/_private/ycodium-jsonl-stream/historyErrors.d.ts +6 -0
- package/dist/_private/ycodium-jsonl-stream/historyErrors.js +6 -0
- package/dist/_private/ycodium-jsonl-stream/historyFile.d.ts +19 -0
- package/dist/_private/ycodium-jsonl-stream/historyFile.js +117 -0
- package/dist/_private/ycodium-jsonl-stream/historyRecord.d.ts +31 -0
- package/dist/_private/ycodium-jsonl-stream/historyRecord.js +144 -0
- package/dist/_private/ycodium-jsonl-stream/historyWaiting.d.ts +8 -0
- package/dist/_private/ycodium-jsonl-stream/historyWaiting.js +142 -0
- package/dist/_private/ycodium-jsonl-stream/jsonObjectLine.d.ts +5 -0
- package/dist/_private/ycodium-jsonl-stream/jsonObjectLine.js +18 -0
- package/dist/_private/ycodium-jsonl-stream/jsonlStream.d.ts +79 -0
- package/dist/_private/ycodium-jsonl-stream/jsonlStream.js +603 -0
- package/dist/_private/ycodium-jsonl-stream/scanCache.d.ts +69 -0
- package/dist/_private/ycodium-jsonl-stream/scanCache.js +106 -0
- package/dist/_private/ycodium-jsonl-stream/sessionDirectory.d.ts +5 -0
- package/dist/_private/ycodium-jsonl-stream/sessionDirectory.js +32 -0
- package/dist/_private/ycodium-jsonl-stream/sessionTranscript.d.ts +16 -0
- package/dist/_private/ycodium-jsonl-stream/sessionTranscript.js +112 -0
- package/dist/_private/ycodium-jsonl-stream/usageFields.d.ts +5 -0
- package/dist/_private/ycodium-jsonl-stream/usageFields.js +11 -0
- package/dist/_private/ycodium-markdown-fence/markdownFence.d.ts +6 -0
- package/dist/_private/ycodium-markdown-fence/markdownFence.js +24 -0
- package/dist/_private/ycodium-source-control/pullRequestScope.d.ts +23 -0
- package/dist/_private/ycodium-source-control/pullRequestScope.js +29 -0
- package/dist/_private/ycodium-sse-stream/sseStream.d.ts +37 -0
- package/dist/_private/ycodium-sse-stream/sseStream.js +104 -0
- package/dist/_private/ycodium-system-text/memberInstructions.d.ts +13 -0
- package/dist/_private/ycodium-system-text/memberInstructions.js +9 -0
- package/dist/_private/ycodium-system-text/systemText.d.ts +179 -0
- package/dist/_private/ycodium-system-text/systemText.js +257 -0
- package/dist/_private/ycodium-system-text/threadPreset.d.ts +18 -0
- package/dist/_private/ycodium-system-text/threadPreset.js +21 -0
- package/dist/_private/ycodium-text-generation/branchName.d.ts +6 -0
- package/dist/_private/ycodium-text-generation/branchName.js +26 -0
- package/dist/_private/ycodium-text-generation/prompts.d.ts +70 -0
- package/dist/_private/ycodium-text-generation/prompts.js +266 -0
- package/dist/_private/ycodium-text-generation/sanitize.d.ts +10 -0
- package/dist/_private/ycodium-text-generation/sanitize.js +124 -0
- package/dist/_private/ycodium-text-generation/structuredTextGeneration.d.ts +29 -0
- package/dist/_private/ycodium-text-generation/structuredTextGeneration.js +163 -0
- package/dist/_private/ycodium-tool-label/toolLabel.d.ts +42 -0
- package/dist/_private/ycodium-tool-label/toolLabel.js +249 -0
- package/dist/_private/ycodium-ui-hooks/DiffStatCounts.d.ts +22 -0
- package/dist/_private/ycodium-ui-hooks/DiffStatCounts.js +22 -0
- package/dist/_private/ycodium-ui-hooks/ProviderSignInChallenge.d.ts +29 -0
- package/dist/_private/ycodium-ui-hooks/ProviderSignInChallenge.js +13 -0
- package/dist/_private/ycodium-ui-hooks/RenderErrorBoundary.d.ts +28 -0
- package/dist/_private/ycodium-ui-hooks/RenderErrorBoundary.js +22 -0
- package/dist/_private/ycodium-ui-hooks/RuntimeMaintenanceActions.d.ts +19 -0
- package/dist/_private/ycodium-ui-hooks/RuntimeMaintenanceActions.js +7 -0
- package/dist/_private/ycodium-ui-hooks/SkillInlineText.d.ts +13 -0
- package/dist/_private/ycodium-ui-hooks/SkillInlineText.js +13 -0
- package/dist/_private/ycodium-ui-hooks/bundleStyle.d.ts +4 -0
- package/dist/_private/ycodium-ui-hooks/bundleStyle.js +52 -0
- package/dist/_private/ycodium-ui-hooks/catalogKeys.d.ts +9 -0
- package/dist/_private/ycodium-ui-hooks/catalogKeys.js +1 -0
- package/dist/_private/ycodium-ui-hooks/clipboard.d.ts +22 -0
- package/dist/_private/ycodium-ui-hooks/clipboard.js +149 -0
- package/dist/_private/ycodium-ui-hooks/hostControls.d.ts +24 -0
- package/dist/_private/ycodium-ui-hooks/hostControls.js +25 -0
- package/dist/_private/ycodium-ui-hooks/inlineChips.d.ts +50 -0
- package/dist/_private/ycodium-ui-hooks/inlineChips.js +32 -0
- package/dist/_private/ycodium-ui-hooks/notifyMessages.d.ts +20 -0
- package/dist/_private/ycodium-ui-hooks/notifyMessages.js +26 -0
- package/dist/_private/ycodium-ui-hooks/presenterInputState.d.ts +52 -0
- package/dist/_private/ycodium-ui-hooks/presenterInputState.js +240 -0
- package/dist/_private/ycodium-ui-hooks/processRowHeader.d.ts +6 -0
- package/dist/_private/ycodium-ui-hooks/processRowHeader.js +6 -0
- package/dist/_private/ycodium-ui-hooks/timelineDisclosure.d.ts +5 -0
- package/dist/_private/ycodium-ui-hooks/timelineDisclosure.js +73 -0
- package/dist/_private/ycodium-ui-hooks/useMediaQuery.d.ts +20 -0
- package/dist/_private/ycodium-ui-hooks/useMediaQuery.js +70 -0
- package/dist/_private/ycodium-ui-hooks/workEntryIcons.d.ts +25 -0
- package/dist/_private/ycodium-ui-hooks/workEntryIcons.js +66 -0
- package/dist/_private/ycodium-workspace-path/directoryScope.d.ts +5 -0
- package/dist/_private/ycodium-workspace-path/directoryScope.js +28 -0
- package/dist/_private/ycodium-workspace-path/workspacePath.d.ts +19 -0
- package/dist/_private/ycodium-workspace-path/workspacePath.js +90 -0
- package/dist/cache.d.ts.map +1 -1
- package/dist/cache.js.map +1 -1
- package/dist/capabilityPorts.d.ts.map +1 -1
- package/dist/capabilityPorts.js.map +1 -1
- package/dist/cli.d.ts.map +1 -1
- package/dist/cli.js.map +1 -1
- package/dist/commands.d.ts.map +1 -1
- package/dist/commands.js.map +1 -1
- package/dist/communication-view.d.ts.map +1 -1
- package/dist/communication-view.js.map +1 -1
- package/dist/communication.d.ts.map +1 -1
- package/dist/communication.js.map +1 -1
- package/dist/composer-control.d.ts.map +1 -1
- package/dist/composer-control.js.map +1 -1
- package/dist/composer.d.ts +22 -0
- package/dist/composer.d.ts.map +1 -0
- package/dist/composer.js +22 -0
- package/dist/composer.js.map +1 -0
- package/dist/conversation-queue.d.ts.map +1 -1
- package/dist/conversation-queue.js.map +1 -1
- package/dist/conversation-view.d.ts.map +1 -1
- package/dist/conversation-view.js.map +1 -1
- package/dist/conversation.d.ts.map +1 -1
- package/dist/conversation.js.map +1 -1
- package/dist/conversationAttachments.d.ts.map +1 -1
- package/dist/conversationAttachments.js.map +1 -1
- package/dist/conversationBase.d.ts.map +1 -1
- package/dist/conversationBase.js.map +1 -1
- package/dist/conversationComposerApi.d.ts.map +1 -1
- package/dist/conversationComposerApi.js.map +1 -1
- package/dist/conversationComposerEnvironment.d.ts.map +1 -1
- package/dist/conversationComposerEnvironment.js.map +1 -1
- package/dist/conversationComposerHandle.d.ts.map +1 -1
- package/dist/conversationComposerHandle.js.map +1 -1
- package/dist/conversationComposerParts.d.ts.map +1 -1
- package/dist/conversationComposerParts.js.map +1 -1
- package/dist/conversationDerive.d.ts.map +1 -1
- package/dist/conversationDerive.js.map +1 -1
- package/dist/conversationDrafts.d.ts.map +1 -1
- package/dist/conversationDrafts.js.map +1 -1
- package/dist/conversationForks.d.ts.map +1 -1
- package/dist/conversationForks.js.map +1 -1
- package/dist/conversationHostModels.d.ts.map +1 -1
- package/dist/conversationHostModels.js.map +1 -1
- package/dist/conversationLoadFailure.d.ts.map +1 -1
- package/dist/conversationLoadFailure.js.map +1 -1
- package/dist/conversationMemberMentions.d.ts.map +1 -1
- package/dist/conversationMemberMentions.js.map +1 -1
- package/dist/conversationMessageLinks.d.ts.map +1 -1
- package/dist/conversationMessageLinks.js.map +1 -1
- package/dist/conversationMessageMemory.d.ts.map +1 -1
- package/dist/conversationMessageMemory.js.map +1 -1
- package/dist/conversationPresets.d.ts.map +1 -1
- package/dist/conversationPresets.js.map +1 -1
- package/dist/conversationRows.d.ts.map +1 -1
- package/dist/conversationRows.js.map +1 -1
- package/dist/conversationSessionMessage.d.ts.map +1 -1
- package/dist/conversationSessionMessage.js.map +1 -1
- package/dist/conversationSkills.d.ts.map +1 -1
- package/dist/conversationSkills.js.map +1 -1
- package/dist/conversationTrajectory.d.ts.map +1 -1
- package/dist/conversationTrajectory.js.map +1 -1
- package/dist/conversationTranscript.d.ts.map +1 -1
- package/dist/conversationTranscript.js.map +1 -1
- package/dist/conversationTurnSummaries.d.ts.map +1 -1
- package/dist/conversationTurnSummaries.js.map +1 -1
- package/dist/conversationViewProps.d.ts.map +1 -1
- package/dist/conversationViewProps.js.map +1 -1
- package/dist/conversationWorkEntry.d.ts.map +1 -1
- package/dist/conversationWorkEntry.js.map +1 -1
- package/dist/credential-account.d.ts +4 -0
- package/dist/credential-account.d.ts.map +1 -0
- package/dist/credential-account.js +4 -0
- package/dist/credential-account.js.map +1 -0
- package/dist/dataPorts.gen.d.ts +312 -2
- package/dist/dataPorts.gen.d.ts.map +1 -1
- package/dist/dataPorts.gen.js.map +1 -1
- package/dist/decision-card.d.ts.map +1 -1
- package/dist/decision-card.js.map +1 -1
- package/dist/decisions.d.ts.map +1 -1
- package/dist/decisions.js.map +1 -1
- package/dist/definition.d.ts.map +1 -1
- package/dist/definition.js.map +1 -1
- package/dist/derivedState.d.ts.map +1 -1
- package/dist/derivedState.js.map +1 -1
- package/dist/diagnosticData.d.ts.map +1 -1
- package/dist/diagnosticData.js.map +1 -1
- package/dist/diff-rendering.d.ts +2 -0
- package/dist/diff-rendering.d.ts.map +1 -0
- package/dist/diff-rendering.js +2 -0
- package/dist/diff-rendering.js.map +1 -0
- package/dist/display-format.d.ts +5 -0
- package/dist/display-format.d.ts.map +1 -0
- package/dist/display-format.js +5 -0
- package/dist/display-format.js.map +1 -0
- package/dist/entity-names.d.ts.map +1 -1
- package/dist/entity-names.js.map +1 -1
- package/dist/events.d.ts.map +1 -1
- package/dist/events.js.map +1 -1
- package/dist/executor-mode.d.ts +2 -0
- package/dist/executor-mode.d.ts.map +1 -0
- package/dist/executor-mode.js +2 -0
- package/dist/executor-mode.js.map +1 -0
- package/dist/executor.d.ts +33 -1
- package/dist/executor.d.ts.map +1 -1
- package/dist/executor.js.map +1 -1
- package/dist/executorCapabilities.d.ts.map +1 -1
- package/dist/executorCapabilities.js.map +1 -1
- package/dist/executorCard.d.ts +6 -0
- package/dist/executorCard.d.ts.map +1 -1
- package/dist/executorCard.js.map +1 -1
- package/dist/executorCommandArgv.d.ts.map +1 -1
- package/dist/executorCommandArgv.js.map +1 -1
- package/dist/executorEffective.d.ts.map +1 -1
- package/dist/executorEffective.js.map +1 -1
- package/dist/executorErrors.d.ts.map +1 -1
- package/dist/executorErrors.js.map +1 -1
- package/dist/executorEvents.d.ts.map +1 -1
- package/dist/executorEvents.js.map +1 -1
- package/dist/executorModelOptions.d.ts.map +1 -1
- package/dist/executorModelOptions.js.map +1 -1
- package/dist/executorProcesses.d.ts.map +1 -1
- package/dist/executorProcesses.js.map +1 -1
- package/dist/executorSession.d.ts +8 -2
- package/dist/executorSession.d.ts.map +1 -1
- package/dist/executorSession.js.map +1 -1
- package/dist/executorSpawn.d.ts +5 -4
- package/dist/executorSpawn.d.ts.map +1 -1
- package/dist/executorSpawn.js +20 -7
- package/dist/executorSpawn.js.map +1 -1
- package/dist/fetch-ports.d.ts +2 -0
- package/dist/fetch-ports.d.ts.map +1 -0
- package/dist/fetch-ports.js +2 -0
- package/dist/fetch-ports.js.map +1 -0
- package/dist/file-preview.d.ts.map +1 -1
- package/dist/file-preview.js.map +1 -1
- package/dist/index.d.ts.map +1 -1
- package/dist/index.js.map +1 -1
- package/dist/inline-tag.d.ts.map +1 -1
- package/dist/inline-tag.js.map +1 -1
- package/dist/instance-config.d.ts +7 -0
- package/dist/instance-config.d.ts.map +1 -0
- package/dist/instance-config.js +7 -0
- package/dist/instance-config.js.map +1 -0
- package/dist/interval.d.ts.map +1 -1
- package/dist/interval.js.map +1 -1
- package/dist/jsonl.d.ts +6 -0
- package/dist/jsonl.d.ts.map +1 -0
- package/dist/jsonl.js +6 -0
- package/dist/jsonl.js.map +1 -0
- package/dist/keyedSubscribers.d.ts.map +1 -1
- package/dist/keyedSubscribers.js.map +1 -1
- package/dist/logger.d.ts.map +1 -1
- package/dist/logger.js.map +1 -1
- package/dist/messages.d.ts.map +1 -1
- package/dist/messages.js.map +1 -1
- package/dist/model-picker.d.ts +1 -1
- package/dist/model-picker.d.ts.map +1 -1
- package/dist/model-picker.js.map +1 -1
- package/dist/modelCatalogNotice.d.ts.map +1 -1
- package/dist/modelCatalogNotice.js.map +1 -1
- package/dist/modelChoice.d.ts +1 -1
- package/dist/modelChoice.d.ts.map +1 -1
- package/dist/modelChoice.js.map +1 -1
- package/dist/modelChoiceOptions.d.ts.map +1 -1
- package/dist/modelChoiceOptions.js.map +1 -1
- package/dist/modelChoiceTraits.d.ts.map +1 -1
- package/dist/modelChoiceTraits.js.map +1 -1
- package/dist/modelDisplayName.d.ts.map +1 -1
- package/dist/modelDisplayName.js.map +1 -1
- package/dist/pending-requests.d.ts.map +1 -1
- package/dist/pending-requests.js.map +1 -1
- package/dist/plugin-tools.d.ts.map +1 -1
- package/dist/plugin-tools.js.map +1 -1
- package/dist/pluginContextCommands.d.ts.map +1 -1
- package/dist/pluginContextCommands.js.map +1 -1
- package/dist/pluginContextProviders.d.ts.map +1 -1
- package/dist/pluginContextProviders.js.map +1 -1
- package/dist/pluginContextThreads.d.ts.map +1 -1
- package/dist/pluginContextThreads.js.map +1 -1
- package/dist/pluginContextWorkspace.d.ts.map +1 -1
- package/dist/pluginContextWorkspace.js.map +1 -1
- package/dist/process-operation.d.ts.map +1 -1
- package/dist/process-operation.js.map +1 -1
- package/dist/process-socket.d.ts.map +1 -1
- package/dist/process-socket.js.map +1 -1
- package/dist/process-stdin.d.ts.map +1 -1
- package/dist/process-stdin.js.map +1 -1
- package/dist/projects.d.ts.map +1 -1
- package/dist/projects.js.map +1 -1
- package/dist/provider-settings.d.ts +44 -0
- package/dist/provider-settings.d.ts.map +1 -1
- package/dist/provider-settings.js +10 -2
- package/dist/provider-settings.js.map +1 -1
- package/dist/providerInstanceSelection.d.ts.map +1 -1
- package/dist/providerInstanceSelection.js.map +1 -1
- package/dist/reasoningLevelFallback.d.ts.map +1 -1
- package/dist/reasoningLevelFallback.js.map +1 -1
- package/dist/runtime-maintenance.d.ts +50 -0
- package/dist/runtime-maintenance.d.ts.map +1 -0
- package/dist/runtime-maintenance.js +246 -0
- package/dist/runtime-maintenance.js.map +1 -0
- package/dist/runtimes.d.ts.map +1 -1
- package/dist/runtimes.js.map +1 -1
- package/dist/selectAllCopy.d.ts.map +1 -1
- package/dist/selectAllCopy.js.map +1 -1
- package/dist/session-history.d.ts +6 -0
- package/dist/session-history.d.ts.map +1 -0
- package/dist/session-history.js +6 -0
- package/dist/session-history.js.map +1 -0
- package/dist/settings-actions.d.ts.map +1 -1
- package/dist/settings-actions.js.map +1 -1
- package/dist/settings-card-shape.d.ts.map +1 -1
- package/dist/settings-card-shape.js.map +1 -1
- package/dist/settings-card.d.ts.map +1 -1
- package/dist/settings-card.js.map +1 -1
- package/dist/settings-ui.d.ts.map +1 -1
- package/dist/settings-ui.js.map +1 -1
- package/dist/sign-in.d.ts.map +1 -1
- package/dist/sign-in.js.map +1 -1
- package/dist/slashCommands.d.ts.map +1 -1
- package/dist/slashCommands.js.map +1 -1
- package/dist/slots.d.ts.map +1 -1
- package/dist/slots.js.map +1 -1
- package/dist/source/_private/ycodium-attachment-kinds/chatAttachmentKinds.ts +105 -0
- package/dist/source/_private/ycodium-attachment-kinds/mediaKinds.ts +83 -0
- package/dist/source/_private/ycodium-composer-tokens/approvalFileChanges.ts +58 -0
- package/dist/source/_private/ycodium-composer-tokens/composerFileLink.ts +23 -0
- package/dist/source/_private/ycodium-composer-tokens/composerInlineTokens.ts +130 -0
- package/dist/source/_private/ycodium-composer-tokens/composerLogic.ts +251 -0
- package/dist/source/_private/ycodium-composer-tokens/composerMentionDrag.ts +98 -0
- package/dist/source/_private/ycodium-composer-tokens/composerPromptSegments.ts +222 -0
- package/dist/source/_private/ycodium-composer-tokens/composerTrigger.ts +64 -0
- package/dist/source/_private/ycodium-composer-tokens/contextWindowFormat.ts +16 -0
- package/dist/source/_private/ycodium-composer-tokens/diffCount.ts +14 -0
- package/dist/source/_private/ycodium-composer-tokens/pendingUserInput.ts +256 -0
- package/dist/source/_private/ycodium-composer-tokens/promptContextBlocks.ts +179 -0
- package/dist/source/_private/ycodium-composer-tokens/proposedPlan.ts +134 -0
- package/dist/source/_private/ycodium-composer-tokens/providerSkillSearch.ts +105 -0
- package/dist/source/_private/ycodium-composer-tokens/providerSkills.ts +86 -0
- package/dist/source/_private/ycodium-composer-tokens/queueEntry.ts +49 -0
- package/dist/source/_private/ycodium-composer-tokens/reviewCommentBlocks.ts +177 -0
- package/dist/source/_private/ycodium-composer-tokens/searchRanking.ts +192 -0
- package/dist/source/_private/ycodium-composer-tokens/skillTokens.ts +192 -0
- package/dist/source/_private/ycodium-composer-tokens/slashMenu.ts +293 -0
- package/dist/source/_private/ycodium-composer-tokens/userInputOptionText.ts +51 -0
- package/dist/source/_private/ycodium-credential-account/credentialAccount.ts +83 -0
- package/dist/source/_private/ycodium-credential-account/quotaJson.ts +25 -0
- package/dist/source/_private/ycodium-credential-account/quotaRequest.ts +79 -0
- package/dist/source/_private/ycodium-day-format/dayFormat.ts +57 -0
- package/dist/source/_private/ycodium-day-format/timestampFormat.ts +165 -0
- package/dist/source/_private/ycodium-decision-order/decisionOrder.ts +54 -0
- package/dist/source/_private/ycodium-diff-format/diffRendering.ts +229 -0
- package/dist/source/_private/ycodium-duration-format/durationFormat.ts +60 -0
- package/dist/source/_private/ycodium-executor-common/catalogModel.ts +40 -0
- package/dist/source/_private/ycodium-executor-common/eventTypes.ts +97 -0
- package/dist/source/_private/ycodium-executor-common/modelSelection.ts +24 -0
- package/dist/source/_private/ycodium-executor-common/nodeStreams.ts +212 -0
- package/dist/source/_private/ycodium-executor-common/raceAbort.ts +25 -0
- package/dist/source/_private/ycodium-executor-common/reasoningLevelFallback.ts +28 -0
- package/dist/source/_private/ycodium-executor-common/stderrTail.ts +27 -0
- package/dist/source/_private/ycodium-executor-common/toolPresentation.ts +268 -0
- package/dist/source/_private/ycodium-fetch-ports/fetchPorts.ts +84 -0
- package/dist/source/_private/ycodium-fetch-ports/netFault.ts +30 -0
- package/dist/source/_private/ycodium-full-access-mode/fullAccessNativeMode.ts +32 -0
- package/dist/source/_private/ycodium-instance-config/homePath.ts +140 -0
- package/dist/source/_private/ycodium-instance-config/instanceConfig.ts +149 -0
- package/dist/source/_private/ycodium-instance-config/launchArgs.ts +60 -0
- package/dist/source/_private/ycodium-instance-config/probeProcess.ts +89 -0
- package/dist/source/_private/ycodium-instance-config/programHomeSchema.ts +74 -0
- package/dist/source/_private/ycodium-instance-config/tomlScalar.ts +10 -0
- package/dist/source/_private/ycodium-jsonl-stream/appendedJsonl.ts +222 -0
- package/dist/source/_private/ycodium-jsonl-stream/claudeSessions.ts +263 -0
- package/dist/source/_private/ycodium-jsonl-stream/codexSessions.ts +254 -0
- package/dist/source/_private/ycodium-jsonl-stream/history.ts +492 -0
- package/dist/source/_private/ycodium-jsonl-stream/historyErrors.ts +6 -0
- package/dist/source/_private/ycodium-jsonl-stream/historyFile.ts +139 -0
- package/dist/source/_private/ycodium-jsonl-stream/historyRecord.ts +180 -0
- package/dist/source/_private/ycodium-jsonl-stream/historyWaiting.ts +140 -0
- package/dist/source/_private/ycodium-jsonl-stream/jsonObjectLine.ts +15 -0
- package/dist/source/_private/ycodium-jsonl-stream/jsonlStream.ts +650 -0
- package/dist/source/_private/ycodium-jsonl-stream/scanCache.ts +163 -0
- package/dist/source/_private/ycodium-jsonl-stream/sessionDirectory.ts +39 -0
- package/dist/source/_private/ycodium-jsonl-stream/sessionTranscript.ts +136 -0
- package/dist/source/_private/ycodium-jsonl-stream/usageFields.ts +13 -0
- package/dist/source/_private/ycodium-markdown-fence/markdownFence.ts +28 -0
- package/dist/source/_private/ycodium-source-control/pullRequestScope.ts +35 -0
- package/dist/source/_private/ycodium-sse-stream/sseStream.ts +118 -0
- package/dist/source/_private/ycodium-system-text/memberInstructions.ts +24 -0
- package/dist/source/_private/ycodium-system-text/systemText.ts +356 -0
- package/dist/source/_private/ycodium-system-text/threadPreset.ts +35 -0
- package/dist/source/_private/ycodium-text-generation/branchName.ts +29 -0
- package/dist/source/_private/ycodium-text-generation/prompts.ts +342 -0
- package/dist/source/_private/ycodium-text-generation/sanitize.ts +125 -0
- package/dist/source/_private/ycodium-text-generation/structuredTextGeneration.ts +237 -0
- package/dist/source/_private/ycodium-tool-label/toolLabel.ts +287 -0
- package/dist/source/_private/ycodium-ui-hooks/DiffStatCounts.tsx +76 -0
- package/dist/source/_private/ycodium-ui-hooks/ProviderSignInChallenge.tsx +115 -0
- package/dist/source/_private/ycodium-ui-hooks/RenderErrorBoundary.tsx +34 -0
- package/dist/source/_private/ycodium-ui-hooks/RuntimeMaintenanceActions.tsx +63 -0
- package/dist/source/_private/ycodium-ui-hooks/SkillInlineText.tsx +28 -0
- package/dist/source/_private/ycodium-ui-hooks/bundleStyle.ts +52 -0
- package/dist/source/_private/ycodium-ui-hooks/catalogKeys.ts +11 -0
- package/dist/source/_private/ycodium-ui-hooks/clipboard.ts +176 -0
- package/dist/source/_private/ycodium-ui-hooks/hostControls.ts +43 -0
- package/dist/source/_private/ycodium-ui-hooks/inlineChips.tsx +114 -0
- package/dist/source/_private/ycodium-ui-hooks/notifyMessages.ts +36 -0
- package/dist/source/_private/ycodium-ui-hooks/presenterInputState.ts +341 -0
- package/dist/source/_private/ycodium-ui-hooks/processRowHeader.ts +7 -0
- package/dist/source/_private/ycodium-ui-hooks/timelineDisclosure.ts +98 -0
- package/dist/source/_private/ycodium-ui-hooks/useMediaQuery.ts +87 -0
- package/dist/source/_private/ycodium-ui-hooks/workEntryIcons.ts +99 -0
- package/dist/source/_private/ycodium-workspace-path/directoryScope.ts +34 -0
- package/dist/source/_private/ycodium-workspace-path/workspacePath.ts +110 -0
- package/dist/source/cache.ts +55 -0
- package/dist/source/capabilityPorts.ts +272 -0
- package/dist/source/cli.ts +69 -0
- package/dist/source/commands.ts +208 -0
- package/dist/source/communication-view.ts +107 -0
- package/dist/source/communication.ts +26 -0
- package/dist/source/composer-control.ts +16 -0
- package/dist/source/composer.ts +108 -0
- package/dist/source/conversation-queue.ts +165 -0
- package/dist/source/conversation-view.ts +49 -0
- package/dist/source/conversation.ts +700 -0
- package/dist/source/conversationAttachments.ts +139 -0
- package/dist/source/conversationBase.ts +128 -0
- package/dist/source/conversationComposerApi.ts +339 -0
- package/dist/source/conversationComposerEnvironment.ts +76 -0
- package/dist/source/conversationComposerHandle.ts +89 -0
- package/dist/source/conversationComposerParts.ts +10 -0
- package/dist/source/conversationDerive.ts +252 -0
- package/dist/source/conversationDrafts.ts +281 -0
- package/dist/source/conversationForks.ts +40 -0
- package/dist/source/conversationHostModels.ts +467 -0
- package/dist/source/conversationLoadFailure.ts +9 -0
- package/dist/source/conversationMemberMentions.ts +63 -0
- package/dist/source/conversationMessageLinks.ts +153 -0
- package/dist/source/conversationMessageMemory.ts +45 -0
- package/dist/source/conversationPresets.ts +15 -0
- package/dist/source/conversationRows.ts +132 -0
- package/dist/source/conversationSessionMessage.ts +18 -0
- package/dist/source/conversationSkills.ts +26 -0
- package/dist/source/conversationTrajectory.ts +116 -0
- package/dist/source/conversationTranscript.ts +33 -0
- package/dist/source/conversationTurnSummaries.ts +57 -0
- package/dist/source/conversationViewProps.ts +486 -0
- package/dist/source/conversationWorkEntry.ts +104 -0
- package/dist/source/credential-account.ts +18 -0
- package/dist/source/dataPorts.gen.ts +2207 -0
- package/dist/source/decision-card.ts +87 -0
- package/dist/source/decisions.ts +43 -0
- package/dist/source/definition.ts +28 -0
- package/dist/source/derivedState.ts +55 -0
- package/dist/source/diagnosticData.ts +238 -0
- package/dist/source/diff-rendering.ts +6 -0
- package/dist/source/display-format.ts +14 -0
- package/dist/source/entity-names.ts +73 -0
- package/dist/source/events.ts +326 -0
- package/dist/source/executor-mode.ts +1 -0
- package/dist/source/executor.ts +623 -0
- package/dist/source/executorCapabilities.ts +89 -0
- package/dist/source/executorCard.ts +426 -0
- package/dist/source/executorCommandArgv.ts +114 -0
- package/dist/source/executorEffective.ts +99 -0
- package/dist/source/executorErrors.ts +73 -0
- package/dist/source/executorEvents.ts +258 -0
- package/dist/source/executorModelOptions.ts +179 -0
- package/dist/source/executorProcesses.ts +43 -0
- package/dist/source/executorSession.ts +508 -0
- package/dist/source/executorSpawn.ts +141 -0
- package/dist/source/fetch-ports.ts +1 -0
- package/dist/source/file-preview.ts +32 -0
- package/dist/source/index.ts +416 -0
- package/dist/source/inline-tag.ts +27 -0
- package/dist/source/instance-config.ts +31 -0
- package/dist/source/interval.ts +32 -0
- package/dist/source/jsonl.ts +21 -0
- package/dist/source/keyedSubscribers.ts +55 -0
- package/dist/source/logger.ts +16 -0
- package/dist/source/messages.ts +27 -0
- package/dist/source/model-picker.ts +82 -0
- package/dist/source/modelCatalogNotice.ts +34 -0
- package/dist/source/modelChoice.ts +371 -0
- package/dist/source/modelChoiceOptions.ts +309 -0
- package/dist/source/modelChoiceTraits.ts +133 -0
- package/dist/source/modelDisplayName.ts +42 -0
- package/dist/source/pending-requests.ts +56 -0
- package/dist/source/plugin-tools.ts +181 -0
- package/dist/source/pluginContextCommands.ts +224 -0
- package/dist/source/pluginContextProviders.ts +136 -0
- package/dist/source/pluginContextThreads.ts +83 -0
- package/dist/source/pluginContextWorkspace.ts +74 -0
- package/dist/source/process-operation.ts +291 -0
- package/dist/source/process-socket.ts +371 -0
- package/dist/source/process-stdin.ts +214 -0
- package/dist/source/projects.ts +31 -0
- package/dist/source/provider-settings.ts +343 -0
- package/dist/source/providerInstanceSelection.ts +72 -0
- package/dist/source/reasoningLevelFallback.ts +13 -0
- package/dist/source/runtime-maintenance.ts +307 -0
- package/dist/source/runtimes.ts +14 -0
- package/dist/source/selectAllCopy.ts +12 -0
- package/dist/source/session-history.ts +45 -0
- package/dist/source/settings-actions.ts +91 -0
- package/dist/source/settings-card-shape.ts +229 -0
- package/dist/source/settings-card.ts +311 -0
- package/dist/source/settings-ui.ts +48 -0
- package/dist/source/sign-in.ts +52 -0
- package/dist/source/slashCommands.ts +36 -0
- package/dist/source/slots.ts +243 -0
- package/dist/source/source-control.ts +5 -0
- package/dist/source/sse.ts +1 -0
- package/dist/source/system-text.ts +18 -0
- package/dist/source/teamView.ts +67 -0
- package/dist/source/testing.ts +203 -0
- package/dist/source/text-generation.ts +5 -0
- package/dist/source/threadAnnotation.ts +12 -0
- package/dist/source/threads.ts +77 -0
- package/dist/source/timeline-process.ts +87 -0
- package/dist/source/timeline-row-error.ts +14 -0
- package/dist/source/tool-display.ts +130 -0
- package/dist/source/traits-picker.ts +84 -0
- package/dist/source/ui-bridge-version.ts +64 -0
- package/dist/source/ui-hooks.ts +26 -0
- package/dist/source/ui-i18n.ts +1 -0
- package/dist/source/ui-media-query.ts +1 -0
- package/dist/source/ui-presenter-state.ts +6 -0
- package/dist/source/ui.ts +671 -0
- package/dist/source/uiHostCapabilities.ts +85 -0
- package/dist/source/uiMachineAdmission.ts +21 -0
- package/dist/source/uiSessionProjections.ts +19 -0
- package/dist/source/usage.ts +225 -0
- package/dist/source/version.ts +30 -0
- package/dist/source/workspace-path.ts +2 -0
- package/dist/source-control.d.ts +3 -0
- package/dist/source-control.d.ts.map +1 -0
- package/dist/source-control.js +3 -0
- package/dist/source-control.js.map +1 -0
- package/dist/sse.d.ts +2 -0
- package/dist/sse.d.ts.map +1 -0
- package/dist/sse.js +2 -0
- package/dist/sse.js.map +1 -0
- package/dist/system-text.d.ts +4 -0
- package/dist/system-text.d.ts.map +1 -0
- package/dist/system-text.js +4 -0
- package/dist/system-text.js.map +1 -0
- package/dist/teamView.d.ts.map +1 -1
- package/dist/teamView.js.map +1 -1
- package/dist/testing.d.ts +1 -1
- package/dist/testing.d.ts.map +1 -1
- package/dist/testing.js.map +1 -1
- package/dist/text-generation.d.ts +3 -0
- package/dist/text-generation.d.ts.map +1 -0
- package/dist/text-generation.js +3 -0
- package/dist/text-generation.js.map +1 -0
- package/dist/threadAnnotation.d.ts.map +1 -1
- package/dist/threadAnnotation.js.map +1 -1
- package/dist/threads.d.ts.map +1 -1
- package/dist/threads.js.map +1 -1
- package/dist/timeline-process.d.ts +32 -0
- package/dist/timeline-process.d.ts.map +1 -1
- package/dist/timeline-process.js.map +1 -1
- package/dist/timeline-row-error.d.ts.map +1 -1
- package/dist/timeline-row-error.js.map +1 -1
- package/dist/tool-display.d.ts.map +1 -1
- package/dist/tool-display.js.map +1 -1
- package/dist/traits-picker.d.ts.map +1 -1
- package/dist/traits-picker.js.map +1 -1
- package/dist/ui-bridge-version.d.ts.map +1 -1
- package/dist/ui-bridge-version.js.map +1 -1
- package/dist/ui-hooks.d.ts +14 -0
- package/dist/ui-hooks.d.ts.map +1 -0
- package/dist/ui-hooks.js +14 -0
- package/dist/ui-hooks.js.map +1 -0
- package/dist/ui-i18n.d.ts +2 -0
- package/dist/ui-i18n.d.ts.map +1 -0
- package/dist/ui-i18n.js +2 -0
- package/dist/ui-i18n.js.map +1 -0
- package/dist/ui-media-query.d.ts +2 -0
- package/dist/ui-media-query.d.ts.map +1 -0
- package/dist/ui-media-query.js +2 -0
- package/dist/ui-media-query.js.map +1 -0
- package/dist/ui-presenter-state.d.ts +2 -0
- package/dist/ui-presenter-state.d.ts.map +1 -0
- package/dist/ui-presenter-state.js +2 -0
- package/dist/ui-presenter-state.js.map +1 -0
- package/dist/ui.d.ts +2 -2
- package/dist/ui.d.ts.map +1 -1
- package/dist/ui.js.map +1 -1
- package/dist/uiHostCapabilities.d.ts.map +1 -1
- package/dist/uiHostCapabilities.js.map +1 -1
- package/dist/uiMachineAdmission.d.ts.map +1 -1
- package/dist/uiMachineAdmission.js.map +1 -1
- package/dist/uiSessionProjections.d.ts.map +1 -1
- package/dist/uiSessionProjections.js.map +1 -1
- package/dist/usage.d.ts.map +1 -1
- package/dist/usage.js.map +1 -1
- package/dist/version.d.ts +2 -2
- package/dist/version.d.ts.map +1 -1
- package/dist/version.js +1 -1
- package/dist/version.js.map +1 -1
- package/dist/workspace-path.d.ts +3 -0
- package/dist/workspace-path.d.ts.map +1 -0
- package/dist/workspace-path.js +3 -0
- package/dist/workspace-path.js.map +1 -0
- package/package.json +118 -3
|
@@ -0,0 +1,177 @@
|
|
|
1
|
+
/**
|
|
2
|
+
* 用户消息里 `<review_comment>` 块的读法:拆成文字与评论段、取评论的属性与正文、把只有 hunk 的
|
|
3
|
+
* diff 补成可渲染的 patch。web 写块(`appendReviewCommentsToPrompt`),`conversation` 插件与
|
|
4
|
+
* mobile 读块。块上没给的 sectionTitle / rangeLabel 读成 null,默认文案由展示处决定。
|
|
5
|
+
*/
|
|
6
|
+
export interface ReviewCommentBlock {
|
|
7
|
+
readonly id: string;
|
|
8
|
+
readonly sectionId: string;
|
|
9
|
+
/** sectionTitle / rangeLabel 块上没给时为 null,默认文案由展示处翻译。 */
|
|
10
|
+
readonly sectionTitle: string | null;
|
|
11
|
+
readonly filePath: string;
|
|
12
|
+
readonly startIndex: number;
|
|
13
|
+
readonly endIndex: number;
|
|
14
|
+
readonly rangeLabel: string | null;
|
|
15
|
+
readonly text: string;
|
|
16
|
+
readonly diff: string;
|
|
17
|
+
readonly fenceLanguage?: string | undefined;
|
|
18
|
+
}
|
|
19
|
+
|
|
20
|
+
export type ReviewCommentMessageSegment =
|
|
21
|
+
| {
|
|
22
|
+
readonly kind: "text";
|
|
23
|
+
readonly id: string;
|
|
24
|
+
readonly text: string;
|
|
25
|
+
}
|
|
26
|
+
| {
|
|
27
|
+
readonly kind: "review-comment";
|
|
28
|
+
readonly comment: ReviewCommentBlock;
|
|
29
|
+
};
|
|
30
|
+
|
|
31
|
+
const REVIEW_COMMENT_BLOCK_PATTERN = /<review_comment\b([^>]*)>\s*([\s\S]*?)<\/review_comment>/g;
|
|
32
|
+
const REVIEW_COMMENT_ATTRIBUTE_PATTERN = /([a-zA-Z][a-zA-Z0-9_-]*)="([^"]*)"/g;
|
|
33
|
+
const REVIEW_COMMENT_FENCE_PATTERN = /(`{3,})([^\s`]*)[^\n]*\n([\s\S]*?)\n\1/g;
|
|
34
|
+
|
|
35
|
+
function unescapeReviewCommentAttribute(value: string): string {
|
|
36
|
+
return value
|
|
37
|
+
.replace(/</g, "<")
|
|
38
|
+
.replace(/>/g, ">")
|
|
39
|
+
.replace(/"/g, '"')
|
|
40
|
+
.replace(/&/g, "&");
|
|
41
|
+
}
|
|
42
|
+
|
|
43
|
+
function readReviewCommentAttributes(rawAttributes: string): Record<string, string> {
|
|
44
|
+
const attributes: Record<string, string> = {};
|
|
45
|
+
for (const match of rawAttributes.matchAll(REVIEW_COMMENT_ATTRIBUTE_PATTERN)) {
|
|
46
|
+
attributes[match[1]!] = unescapeReviewCommentAttribute(match[2] ?? "");
|
|
47
|
+
}
|
|
48
|
+
return attributes;
|
|
49
|
+
}
|
|
50
|
+
|
|
51
|
+
function readNonNegativeInteger(value: string | undefined): number | null {
|
|
52
|
+
if (value === undefined || !/^\d+$/.test(value)) {
|
|
53
|
+
return null;
|
|
54
|
+
}
|
|
55
|
+
return Number(value);
|
|
56
|
+
}
|
|
57
|
+
|
|
58
|
+
function extractReviewCommentBody(rawBody: string): {
|
|
59
|
+
text: string;
|
|
60
|
+
language: string;
|
|
61
|
+
contents: string;
|
|
62
|
+
} {
|
|
63
|
+
const matches = Array.from(rawBody.matchAll(REVIEW_COMMENT_FENCE_PATTERN));
|
|
64
|
+
const match = matches.at(-1);
|
|
65
|
+
const fenceIndex = match?.index;
|
|
66
|
+
return {
|
|
67
|
+
text: rawBody.slice(0, fenceIndex ?? rawBody.length).trim(),
|
|
68
|
+
language: match?.[2]?.trim() || "diff",
|
|
69
|
+
contents: match?.[3] ?? "",
|
|
70
|
+
};
|
|
71
|
+
}
|
|
72
|
+
|
|
73
|
+
function parseReviewCommentContext(
|
|
74
|
+
rawAttributes: string,
|
|
75
|
+
rawBody: string,
|
|
76
|
+
index: number,
|
|
77
|
+
): ReviewCommentBlock | null {
|
|
78
|
+
const attributes = readReviewCommentAttributes(rawAttributes);
|
|
79
|
+
const startIndex = readNonNegativeInteger(attributes.startIndex);
|
|
80
|
+
const endIndex = readNonNegativeInteger(attributes.endIndex);
|
|
81
|
+
const filePath = attributes.filePath?.trim();
|
|
82
|
+
const sectionId = attributes.sectionId?.trim();
|
|
83
|
+
if (!filePath || !sectionId || startIndex === null || endIndex === null) {
|
|
84
|
+
return null;
|
|
85
|
+
}
|
|
86
|
+
const body = extractReviewCommentBody(rawBody);
|
|
87
|
+
|
|
88
|
+
return {
|
|
89
|
+
id: `review-comment:${index}:${sectionId}:${filePath}:${startIndex}:${endIndex}`,
|
|
90
|
+
sectionId,
|
|
91
|
+
sectionTitle: attributes.sectionTitle?.trim() || null,
|
|
92
|
+
filePath,
|
|
93
|
+
startIndex: Math.min(startIndex, endIndex),
|
|
94
|
+
endIndex: Math.max(startIndex, endIndex),
|
|
95
|
+
rangeLabel: attributes.rangeLabel?.trim() || null,
|
|
96
|
+
text: body.text,
|
|
97
|
+
diff: body.contents,
|
|
98
|
+
fenceLanguage: body.language,
|
|
99
|
+
};
|
|
100
|
+
}
|
|
101
|
+
|
|
102
|
+
export function parseReviewCommentMessageSegments(
|
|
103
|
+
value: string,
|
|
104
|
+
): ReadonlyArray<ReviewCommentMessageSegment> {
|
|
105
|
+
const segments: ReviewCommentMessageSegment[] = [];
|
|
106
|
+
let cursor = 0;
|
|
107
|
+
let parsedCommentIndex = 0;
|
|
108
|
+
|
|
109
|
+
for (const match of value.matchAll(REVIEW_COMMENT_BLOCK_PATTERN)) {
|
|
110
|
+
const matchIndex = match.index ?? 0;
|
|
111
|
+
const beforeText = value.slice(cursor, matchIndex);
|
|
112
|
+
if (beforeText.length > 0) {
|
|
113
|
+
segments.push({
|
|
114
|
+
kind: "text",
|
|
115
|
+
id: `review-comment-text:${cursor}`,
|
|
116
|
+
text: beforeText,
|
|
117
|
+
});
|
|
118
|
+
}
|
|
119
|
+
|
|
120
|
+
const comment = parseReviewCommentContext(match[1] ?? "", match[2] ?? "", parsedCommentIndex);
|
|
121
|
+
if (comment) {
|
|
122
|
+
segments.push({ kind: "review-comment", comment });
|
|
123
|
+
parsedCommentIndex += 1;
|
|
124
|
+
} else {
|
|
125
|
+
segments.push({
|
|
126
|
+
kind: "text",
|
|
127
|
+
id: `review-comment-invalid:${matchIndex}`,
|
|
128
|
+
text: match[0],
|
|
129
|
+
});
|
|
130
|
+
}
|
|
131
|
+
|
|
132
|
+
cursor = matchIndex + match[0].length;
|
|
133
|
+
}
|
|
134
|
+
|
|
135
|
+
const rest = value.slice(cursor);
|
|
136
|
+
if (rest.length > 0) {
|
|
137
|
+
segments.push({
|
|
138
|
+
kind: "text",
|
|
139
|
+
id: `review-comment-text:${cursor}`,
|
|
140
|
+
text: rest,
|
|
141
|
+
});
|
|
142
|
+
}
|
|
143
|
+
|
|
144
|
+
return segments;
|
|
145
|
+
}
|
|
146
|
+
|
|
147
|
+
export function formatReviewCommentFence(language: string, contents: string): string {
|
|
148
|
+
const longestBacktickRun = Math.max(
|
|
149
|
+
0,
|
|
150
|
+
...Array.from(contents.matchAll(/`+/g), (match) => match[0].length),
|
|
151
|
+
);
|
|
152
|
+
const fence = "`".repeat(Math.max(3, longestBacktickRun + 1));
|
|
153
|
+
return [`${fence}${language}`, contents.trimEnd(), fence].join("\n");
|
|
154
|
+
}
|
|
155
|
+
|
|
156
|
+
export function buildReviewCommentRenderablePatch(
|
|
157
|
+
comment: Pick<ReviewCommentBlock, "fenceLanguage" | "diff" | "filePath">,
|
|
158
|
+
): string {
|
|
159
|
+
if ((comment.fenceLanguage ?? "diff") !== "diff") {
|
|
160
|
+
return "";
|
|
161
|
+
}
|
|
162
|
+
const diff = comment.diff.trim();
|
|
163
|
+
if (diff.length === 0) {
|
|
164
|
+
return "";
|
|
165
|
+
}
|
|
166
|
+
if (diff.startsWith("diff --git ")) {
|
|
167
|
+
return diff;
|
|
168
|
+
}
|
|
169
|
+
|
|
170
|
+
const normalizedPath = comment.filePath.replaceAll("\\", "/");
|
|
171
|
+
return [
|
|
172
|
+
`diff --git a/${normalizedPath} b/${normalizedPath}`,
|
|
173
|
+
`--- a/${normalizedPath}`,
|
|
174
|
+
`+++ b/${normalizedPath}`,
|
|
175
|
+
diff,
|
|
176
|
+
].join("\n");
|
|
177
|
+
}
|
|
@@ -0,0 +1,192 @@
|
|
|
1
|
+
export type RankedSearchResult<T> = {
|
|
2
|
+
item: T;
|
|
3
|
+
score: number;
|
|
4
|
+
tieBreaker: string;
|
|
5
|
+
};
|
|
6
|
+
|
|
7
|
+
export function normalizeSearchQuery(
|
|
8
|
+
input: string,
|
|
9
|
+
options?: {
|
|
10
|
+
trimLeadingPattern?: RegExp;
|
|
11
|
+
},
|
|
12
|
+
): string {
|
|
13
|
+
const trimmed = input.trim();
|
|
14
|
+
if (!trimmed) {
|
|
15
|
+
return "";
|
|
16
|
+
}
|
|
17
|
+
return options?.trimLeadingPattern
|
|
18
|
+
? trimmed.replace(options.trimLeadingPattern, "").toLowerCase()
|
|
19
|
+
: trimmed.toLowerCase();
|
|
20
|
+
}
|
|
21
|
+
|
|
22
|
+
export function scoreSubsequenceMatch(value: string, query: string): number | null {
|
|
23
|
+
if (!query) return 0;
|
|
24
|
+
|
|
25
|
+
let queryIndex = 0;
|
|
26
|
+
let firstMatchIndex = -1;
|
|
27
|
+
let previousMatchIndex = -1;
|
|
28
|
+
let gapPenalty = 0;
|
|
29
|
+
|
|
30
|
+
for (let valueIndex = 0; valueIndex < value.length; valueIndex += 1) {
|
|
31
|
+
if (value[valueIndex] !== query[queryIndex]) {
|
|
32
|
+
continue;
|
|
33
|
+
}
|
|
34
|
+
|
|
35
|
+
if (firstMatchIndex === -1) {
|
|
36
|
+
firstMatchIndex = valueIndex;
|
|
37
|
+
}
|
|
38
|
+
if (previousMatchIndex !== -1) {
|
|
39
|
+
gapPenalty += valueIndex - previousMatchIndex - 1;
|
|
40
|
+
}
|
|
41
|
+
|
|
42
|
+
previousMatchIndex = valueIndex;
|
|
43
|
+
queryIndex += 1;
|
|
44
|
+
if (queryIndex === query.length) {
|
|
45
|
+
const spanPenalty = valueIndex - firstMatchIndex + 1 - query.length;
|
|
46
|
+
const lengthPenalty = Math.min(64, value.length - query.length);
|
|
47
|
+
return firstMatchIndex * 2 + gapPenalty * 3 + spanPenalty + lengthPenalty;
|
|
48
|
+
}
|
|
49
|
+
}
|
|
50
|
+
|
|
51
|
+
return null;
|
|
52
|
+
}
|
|
53
|
+
|
|
54
|
+
function lengthPenalty(value: string, query: string): number {
|
|
55
|
+
return Math.min(64, Math.max(0, value.length - query.length));
|
|
56
|
+
}
|
|
57
|
+
|
|
58
|
+
function findBoundaryMatchIndex(
|
|
59
|
+
value: string,
|
|
60
|
+
query: string,
|
|
61
|
+
boundaryMarkers: readonly string[],
|
|
62
|
+
): number | null {
|
|
63
|
+
let bestIndex: number | null = null;
|
|
64
|
+
|
|
65
|
+
for (const marker of boundaryMarkers) {
|
|
66
|
+
const index = value.indexOf(`${marker}${query}`);
|
|
67
|
+
if (index === -1) {
|
|
68
|
+
continue;
|
|
69
|
+
}
|
|
70
|
+
|
|
71
|
+
const matchIndex = index + marker.length;
|
|
72
|
+
if (bestIndex === null || matchIndex < bestIndex) {
|
|
73
|
+
bestIndex = matchIndex;
|
|
74
|
+
}
|
|
75
|
+
}
|
|
76
|
+
|
|
77
|
+
return bestIndex;
|
|
78
|
+
}
|
|
79
|
+
|
|
80
|
+
/**
|
|
81
|
+
* Scores how well `value` matches `query` using tiered match strategies.
|
|
82
|
+
*
|
|
83
|
+
* **Expects pre-normalized inputs**: both `value` and `query` must already be
|
|
84
|
+
* trimmed and lowercased (e.g. via {@link normalizeSearchQuery}).
|
|
85
|
+
*/
|
|
86
|
+
export function scoreQueryMatch(input: {
|
|
87
|
+
value: string;
|
|
88
|
+
query: string;
|
|
89
|
+
exactBase: number;
|
|
90
|
+
prefixBase?: number;
|
|
91
|
+
boundaryBase?: number;
|
|
92
|
+
includesBase?: number;
|
|
93
|
+
fuzzyBase?: number;
|
|
94
|
+
boundaryMarkers?: readonly string[];
|
|
95
|
+
}): number | null {
|
|
96
|
+
const { value, query } = input;
|
|
97
|
+
|
|
98
|
+
if (!value || !query) {
|
|
99
|
+
return null;
|
|
100
|
+
}
|
|
101
|
+
|
|
102
|
+
if (value === query) {
|
|
103
|
+
return input.exactBase;
|
|
104
|
+
}
|
|
105
|
+
|
|
106
|
+
if (input.prefixBase !== undefined && value.startsWith(query)) {
|
|
107
|
+
return input.prefixBase + lengthPenalty(value, query);
|
|
108
|
+
}
|
|
109
|
+
|
|
110
|
+
if (input.boundaryBase !== undefined) {
|
|
111
|
+
const boundaryIndex = findBoundaryMatchIndex(
|
|
112
|
+
value,
|
|
113
|
+
query,
|
|
114
|
+
input.boundaryMarkers ?? [" ", "-", "_", "/"],
|
|
115
|
+
);
|
|
116
|
+
if (boundaryIndex !== null) {
|
|
117
|
+
return input.boundaryBase + boundaryIndex * 2 + lengthPenalty(value, query);
|
|
118
|
+
}
|
|
119
|
+
}
|
|
120
|
+
|
|
121
|
+
if (input.includesBase !== undefined) {
|
|
122
|
+
const includesIndex = value.indexOf(query);
|
|
123
|
+
if (includesIndex !== -1) {
|
|
124
|
+
return input.includesBase + includesIndex * 2 + lengthPenalty(value, query);
|
|
125
|
+
}
|
|
126
|
+
}
|
|
127
|
+
|
|
128
|
+
if (input.fuzzyBase !== undefined) {
|
|
129
|
+
const fuzzyScore = scoreSubsequenceMatch(value, query);
|
|
130
|
+
if (fuzzyScore !== null) {
|
|
131
|
+
return input.fuzzyBase + fuzzyScore;
|
|
132
|
+
}
|
|
133
|
+
}
|
|
134
|
+
|
|
135
|
+
return null;
|
|
136
|
+
}
|
|
137
|
+
|
|
138
|
+
export function compareRankedSearchResults<T>(
|
|
139
|
+
left: RankedSearchResult<T>,
|
|
140
|
+
right: RankedSearchResult<T>,
|
|
141
|
+
): number {
|
|
142
|
+
const scoreDelta = left.score - right.score;
|
|
143
|
+
if (scoreDelta !== 0) return scoreDelta;
|
|
144
|
+
return left.tieBreaker.localeCompare(right.tieBreaker);
|
|
145
|
+
}
|
|
146
|
+
|
|
147
|
+
function findInsertionIndex<T>(
|
|
148
|
+
rankedEntries: RankedSearchResult<T>[],
|
|
149
|
+
candidate: RankedSearchResult<T>,
|
|
150
|
+
): number {
|
|
151
|
+
let low = 0;
|
|
152
|
+
let high = rankedEntries.length;
|
|
153
|
+
|
|
154
|
+
while (low < high) {
|
|
155
|
+
const middle = low + Math.floor((high - low) / 2);
|
|
156
|
+
const current = rankedEntries[middle];
|
|
157
|
+
if (!current) {
|
|
158
|
+
break;
|
|
159
|
+
}
|
|
160
|
+
|
|
161
|
+
if (compareRankedSearchResults(candidate, current) < 0) {
|
|
162
|
+
high = middle;
|
|
163
|
+
} else {
|
|
164
|
+
low = middle + 1;
|
|
165
|
+
}
|
|
166
|
+
}
|
|
167
|
+
|
|
168
|
+
return low;
|
|
169
|
+
}
|
|
170
|
+
|
|
171
|
+
export function insertRankedSearchResult<T>(
|
|
172
|
+
rankedEntries: RankedSearchResult<T>[],
|
|
173
|
+
candidate: RankedSearchResult<T>,
|
|
174
|
+
limit: number,
|
|
175
|
+
): void {
|
|
176
|
+
if (limit <= 0) {
|
|
177
|
+
return;
|
|
178
|
+
}
|
|
179
|
+
|
|
180
|
+
const insertionIndex = findInsertionIndex(rankedEntries, candidate);
|
|
181
|
+
if (rankedEntries.length < limit) {
|
|
182
|
+
rankedEntries.splice(insertionIndex, 0, candidate);
|
|
183
|
+
return;
|
|
184
|
+
}
|
|
185
|
+
|
|
186
|
+
if (insertionIndex >= limit) {
|
|
187
|
+
return;
|
|
188
|
+
}
|
|
189
|
+
|
|
190
|
+
rankedEntries.splice(insertionIndex, 0, candidate);
|
|
191
|
+
rankedEntries.pop();
|
|
192
|
+
}
|
|
@@ -0,0 +1,192 @@
|
|
|
1
|
+
/**
|
|
2
|
+
* 技能 token 的写法:`$name` 或 `/name`。输入区菜单与芯片、时间线芯片、宿主的手动调用展开与
|
|
3
|
+
* Claude 的斜杠派发都按这里切,一个 token 在每个入口判成同一个技能。
|
|
4
|
+
*/
|
|
5
|
+
|
|
6
|
+
/** 技能 token 的名字(`$` 或 `/` 之后那段)。 */
|
|
7
|
+
export const SKILL_TOKEN_NAME_PATTERN = "[a-zA-Z][a-zA-Z0-9:_-]*";
|
|
8
|
+
|
|
9
|
+
/** 输入区的基础 token 边界;触发检测与 `/name` 改写默认都用它,编辑器可在此之上扩展。 */
|
|
10
|
+
export function isComposerWhitespace(char: string): boolean {
|
|
11
|
+
return char === " " || char === "\n" || char === "\t" || char === "\r";
|
|
12
|
+
}
|
|
13
|
+
|
|
14
|
+
/**
|
|
15
|
+
* 用户能不能起这个技能:provider 设置里关掉的不会执行,provider 留给 agent 的(Claude 的
|
|
16
|
+
* `user-invocable: false`)拒绝用户调用。其余照常可选,包括 agent 不能自己起的技能:服务端会把
|
|
17
|
+
* 选择改写成 provider 自己的调用形式。输入区菜单、手打改写与发送侧指示行都按它判。
|
|
18
|
+
*/
|
|
19
|
+
export function isProviderSkillUserInvocable(skill: {
|
|
20
|
+
readonly enabled: boolean;
|
|
21
|
+
readonly userInvocable?: boolean | undefined;
|
|
22
|
+
}): boolean {
|
|
23
|
+
return skill.enabled && skill.userInvocable !== false;
|
|
24
|
+
}
|
|
25
|
+
|
|
26
|
+
/**
|
|
27
|
+
* Ycodium 会话技能的命名空间:会话技能目录当插件加载时的插件名(CLI 报上来的名字带 `ycodium:` 前缀),
|
|
28
|
+
* 也是菜单里这些技能的 scope。只有它们认 `ycodium:` 前缀写法。
|
|
29
|
+
*/
|
|
30
|
+
export const SESSION_SKILL_NAMESPACE = "ycodium";
|
|
31
|
+
|
|
32
|
+
const SESSION_SKILL_PREFIX = `${SESSION_SKILL_NAMESPACE}:`;
|
|
33
|
+
|
|
34
|
+
export type SkillTokenSigil = "$" | "/";
|
|
35
|
+
|
|
36
|
+
export interface SkillToken {
|
|
37
|
+
readonly sigil: SkillTokenSigil;
|
|
38
|
+
readonly name: string;
|
|
39
|
+
/** token 在原文里的范围,含开头的 `$` / `/`。 */
|
|
40
|
+
readonly start: number;
|
|
41
|
+
readonly end: number;
|
|
42
|
+
}
|
|
43
|
+
|
|
44
|
+
// 不用后行断言:mobile 的 Hermes 也要跑这份。
|
|
45
|
+
const SKILL_TOKEN_REGEX = new RegExp(
|
|
46
|
+
String.raw`(^|\s)([$/])(${SKILL_TOKEN_NAME_PATTERN})(?=\s|$)`,
|
|
47
|
+
"g",
|
|
48
|
+
);
|
|
49
|
+
|
|
50
|
+
/**
|
|
51
|
+
* 行首或空白之后、到空白或结尾为止的整个 `$name` / `/name`。先读完整个 token 再比对名字,
|
|
52
|
+
* `$reviewExtra`、`/review/notes`、`src/review` 都不会按前缀命中。
|
|
53
|
+
*/
|
|
54
|
+
export function findSkillTokens(text: string): SkillToken[] {
|
|
55
|
+
return [...text.matchAll(SKILL_TOKEN_REGEX)].map((match) => {
|
|
56
|
+
const start = (match.index ?? 0) + (match[1]?.length ?? 0);
|
|
57
|
+
const name = match[3] ?? "";
|
|
58
|
+
return { sigil: match[2] as SkillTokenSigil, name, start, end: start + name.length + 1 };
|
|
59
|
+
});
|
|
60
|
+
}
|
|
61
|
+
|
|
62
|
+
const SKILL_TOKEN_AT = new RegExp(String.raw`([$/])(${SKILL_TOKEN_NAME_PATTERN})(?=\s|$)`, "y");
|
|
63
|
+
|
|
64
|
+
/** 正好从 `index` 开始的技能 token(规则同 {@link findSkillTokens});不是就 undefined。 */
|
|
65
|
+
export function skillTokenAt(text: string, index: number): SkillToken | undefined {
|
|
66
|
+
if (index > 0 && !/\s/.test(text.charAt(index - 1))) return undefined;
|
|
67
|
+
SKILL_TOKEN_AT.lastIndex = index;
|
|
68
|
+
const match = SKILL_TOKEN_AT.exec(text);
|
|
69
|
+
if (match === null) return undefined;
|
|
70
|
+
const name = match[2] ?? "";
|
|
71
|
+
return { sigil: match[1] as SkillTokenSigil, name, start: index, end: index + name.length + 1 };
|
|
72
|
+
}
|
|
73
|
+
|
|
74
|
+
/**
|
|
75
|
+
* `name` 是不是 `known` 里的技能:原样命中,或去掉 `ycodium:` 前缀后命中(菜单按目录名列会话技能,
|
|
76
|
+
* CLI 报的是带前缀的写法)。是就返回 `known` 里的那个名字。区分大小写,与 CLI 一致。
|
|
77
|
+
*/
|
|
78
|
+
export function resolveSkillName(
|
|
79
|
+
name: string,
|
|
80
|
+
known: { readonly has: (name: string) => boolean },
|
|
81
|
+
): string | undefined {
|
|
82
|
+
if (known.has(name)) return name;
|
|
83
|
+
if (!name.startsWith(SESSION_SKILL_PREFIX)) return undefined;
|
|
84
|
+
const bare = name.slice(SESSION_SKILL_PREFIX.length);
|
|
85
|
+
return known.has(bare) ? bare : undefined;
|
|
86
|
+
}
|
|
87
|
+
|
|
88
|
+
/**
|
|
89
|
+
* token 里的名字对应索引里的哪个技能:原样命中;或带 `ycodium:` 前缀、去掉后命中一个会话技能
|
|
90
|
+
* (scope 为 {@link SESSION_SKILL_NAMESPACE})。普通 provider 技能只按完整名字认:用户自己的 `review`
|
|
91
|
+
* 不认 `/ycodium:review`,跟服务端指示行、Claude 派发按完整名字匹配一致。
|
|
92
|
+
*/
|
|
93
|
+
export function lookupSkill<
|
|
94
|
+
Skill extends { readonly name: string; readonly scope?: string | undefined },
|
|
95
|
+
>(name: string, index: ReadonlyMap<string, Skill>): Skill | undefined {
|
|
96
|
+
const exact = index.get(name);
|
|
97
|
+
if (exact !== undefined) return exact;
|
|
98
|
+
if (!name.startsWith(SESSION_SKILL_PREFIX)) return undefined;
|
|
99
|
+
const session = index.get(name.slice(SESSION_SKILL_PREFIX.length));
|
|
100
|
+
return session?.scope === SESSION_SKILL_NAMESPACE ? session : undefined;
|
|
101
|
+
}
|
|
102
|
+
|
|
103
|
+
/**
|
|
104
|
+
* 用户刚在手打的 `/name` 后面敲了一个空白、且 `name` 是索引里的技能(按 {@link lookupSkill} 认):返回把它改写成 `$name` 的
|
|
105
|
+
* 替换(范围含那个空白,替换后光标落在它后面),与从菜单选中同一个结果。只认「这次编辑恰好插入了
|
|
106
|
+
* 一个空白,并由它结束了 token」:粘贴进来的、本来就已结束的 `/name` 保持原样。插入点从前后文字的
|
|
107
|
+
* 差异里取,不要光标:连着的空白里取最左那处,正好紧跟 token。`isBoundary` 与触发检测的
|
|
108
|
+
* `isWhitespaceChar` 是同一条规则(web 的终端上下文占位符也算 token 边界);敲下的那个字符
|
|
109
|
+
* 本身必须是真空白。
|
|
110
|
+
*/
|
|
111
|
+
export function typedSlashSkillCompletion(
|
|
112
|
+
previous: string,
|
|
113
|
+
next: string,
|
|
114
|
+
index: ReadonlyMap<string, { readonly name: string; readonly scope?: string | undefined }>,
|
|
115
|
+
isBoundary: (char: string) => boolean = isComposerWhitespace,
|
|
116
|
+
): { readonly start: number; readonly end: number; readonly replacement: string } | null {
|
|
117
|
+
if (next.length !== previous.length + 1) return null;
|
|
118
|
+
let inserted = 0;
|
|
119
|
+
while (inserted < previous.length && previous[inserted] === next[inserted]) inserted += 1;
|
|
120
|
+
const typed = next.charAt(inserted);
|
|
121
|
+
if (
|
|
122
|
+
!isComposerWhitespace(typed) ||
|
|
123
|
+
(inserted < previous.length && isBoundary(previous.charAt(inserted))) ||
|
|
124
|
+
next.slice(inserted + 1) !== previous.slice(inserted)
|
|
125
|
+
) {
|
|
126
|
+
return null;
|
|
127
|
+
}
|
|
128
|
+
let start = inserted;
|
|
129
|
+
while (start > 0 && !isBoundary(next.charAt(start - 1))) start -= 1;
|
|
130
|
+
const match = SLASH_SKILL_TOKEN.exec(next.slice(start, inserted));
|
|
131
|
+
const name = match?.[1];
|
|
132
|
+
if (name === undefined || lookupSkill(name, index) === undefined) return null;
|
|
133
|
+
return { start, end: inserted + 1, replacement: `$${name}${typed}` };
|
|
134
|
+
}
|
|
135
|
+
|
|
136
|
+
const SLASH_SKILL_TOKEN = new RegExp(String.raw`^/(${SKILL_TOKEN_NAME_PATTERN})$`);
|
|
137
|
+
|
|
138
|
+
/** 技能按名字建的索引;一份清单建一次,同一条消息 / 文档里的各段文字共用。 */
|
|
139
|
+
export function skillIndex<Skill extends { readonly name: string }>(
|
|
140
|
+
skills: ReadonlyArray<Skill>,
|
|
141
|
+
): ReadonlyMap<string, Skill> {
|
|
142
|
+
return new Map(skills.map((skill) => [skill.name, skill]));
|
|
143
|
+
}
|
|
144
|
+
|
|
145
|
+
/** 正文里命中索引的技能 token,带上命中的那个技能;不认识的名字(`$HOME`、`/usr`)跳过。 */
|
|
146
|
+
export function matchSkillTokens<
|
|
147
|
+
Skill extends { readonly name: string; readonly scope?: string | undefined },
|
|
148
|
+
>(text: string, index: ReadonlyMap<string, Skill>): Array<SkillToken & { readonly skill: Skill }> {
|
|
149
|
+
if (index.size === 0) return [];
|
|
150
|
+
return findSkillTokens(text).flatMap((token) => {
|
|
151
|
+
const skill = lookupSkill(token.name, index);
|
|
152
|
+
return skill === undefined ? [] : [{ ...token, skill }];
|
|
153
|
+
});
|
|
154
|
+
}
|
|
155
|
+
|
|
156
|
+
/** 正文按命中的技能 token 切开:文字原样,技能段带原文(`$name` / `/name`)。 */
|
|
157
|
+
export type SkillTextPart<Skill> =
|
|
158
|
+
| { readonly kind: "text"; readonly text: string }
|
|
159
|
+
| { readonly kind: "skill"; readonly key: string; readonly skill: Skill; readonly raw: string };
|
|
160
|
+
|
|
161
|
+
/** 没有命中任何技能时返回 null,调用方原样渲染整段文字。 */
|
|
162
|
+
export function splitTextBySkillTokens<
|
|
163
|
+
Skill extends { readonly name: string; readonly scope?: string | undefined },
|
|
164
|
+
>(text: string, index: ReadonlyMap<string, Skill>): ReadonlyArray<SkillTextPart<Skill>> | null {
|
|
165
|
+
const parts: SkillTextPart<Skill>[] = [];
|
|
166
|
+
let cursor = 0;
|
|
167
|
+
for (const token of matchSkillTokens(text, index)) {
|
|
168
|
+
if (token.start > cursor) parts.push({ kind: "text", text: text.slice(cursor, token.start) });
|
|
169
|
+
parts.push({
|
|
170
|
+
kind: "skill",
|
|
171
|
+
key: `${token.start}:${token.name}`,
|
|
172
|
+
skill: token.skill,
|
|
173
|
+
raw: text.slice(token.start, token.end),
|
|
174
|
+
});
|
|
175
|
+
cursor = token.end;
|
|
176
|
+
}
|
|
177
|
+
if (cursor === 0) return null;
|
|
178
|
+
if (cursor < text.length) parts.push({ kind: "text", text: text.slice(cursor) });
|
|
179
|
+
return parts;
|
|
180
|
+
}
|
|
181
|
+
|
|
182
|
+
/**
|
|
183
|
+
* 「用户在这条消息里点名了这些技能」指示行:既没有原生入口、也没人展开的技能,靠它让模型知道要起。
|
|
184
|
+
* 属于 provider 协议内容,不进 i18n。宿主给各家都加;名片声明 `handlesSkillInvocations` 的执行器
|
|
185
|
+
* 自己处理技能调用,宿主不加,由执行器只给它没处理的那些技能加。
|
|
186
|
+
*/
|
|
187
|
+
export function skillInvocationNotice(names: ReadonlyArray<string>): string {
|
|
188
|
+
return (
|
|
189
|
+
`The user invoked these skills in this message; run them as requested: ` +
|
|
190
|
+
`${names.map((name) => `$${name}`).join(", ")}.`
|
|
191
|
+
);
|
|
192
|
+
}
|