@deepseek-harness-tui/dsh-tui 0.6.0 → 0.7.0
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 +74 -21
- package/bin/dsh-tui.js +115 -25
- package/cordis.patch.yml +69 -17
- package/cordis.yml +50 -12
- package/lib/types/activityPrefs.d.ts +1 -1
- package/lib/types/activityPrefs.js +3 -3
- package/lib/types/cc/figures.d.ts +27 -20
- package/lib/types/cc/figures.d.ts.map +1 -1
- package/lib/types/cc/figures.js +43 -34
- package/lib/types/cc/format.d.ts +18 -9
- package/lib/types/cc/format.d.ts.map +1 -1
- package/lib/types/cc/format.js +26 -18
- package/lib/types/cc/markdown.d.ts +31 -16
- package/lib/types/cc/markdown.d.ts.map +1 -1
- package/lib/types/cc/markdown.js +283 -260
- package/lib/types/cc/terminal.d.ts +10 -7
- package/lib/types/cc/terminal.d.ts.map +1 -1
- package/lib/types/cc/terminal.js +62 -50
- package/lib/types/command-trees.d.ts +3 -0
- package/lib/types/command-trees.d.ts.map +1 -0
- package/lib/types/command-trees.js +4 -0
- package/lib/types/commands.d.ts +37 -1
- package/lib/types/commands.d.ts.map +1 -1
- package/lib/types/commands.js +68 -3
- package/lib/types/components/ActivityLine.d.ts +1 -1
- package/lib/types/components/ActivityLine.d.ts.map +1 -1
- package/lib/types/components/ActivityPicker.d.ts.map +1 -1
- package/lib/types/components/ActivityPicker.js +3 -4
- package/lib/types/components/BtwPanel.d.ts +16 -0
- package/lib/types/components/BtwPanel.d.ts.map +1 -0
- package/lib/types/components/BtwPanel.js +47 -0
- package/lib/types/components/CommandSuggestions.d.ts +4 -2
- package/lib/types/components/CommandSuggestions.d.ts.map +1 -1
- package/lib/types/components/CommandSuggestions.js +2 -2
- package/lib/types/components/EffortSlider.d.ts +15 -0
- package/lib/types/components/EffortSlider.d.ts.map +1 -0
- package/lib/types/components/EffortSlider.js +17 -0
- package/lib/types/components/GoalTodoPanel.d.ts +1 -1
- package/lib/types/components/GoalTodoPanel.d.ts.map +1 -1
- package/lib/types/components/HelpMenu.d.ts +5 -2
- package/lib/types/components/HelpMenu.d.ts.map +1 -1
- package/lib/types/components/HelpMenu.js +8 -3
- package/lib/types/components/HistorySearchDialog.d.ts +1 -1
- package/lib/types/components/HistorySearchDialog.d.ts.map +1 -1
- package/lib/types/components/HistorySearchDialog.js +21 -10
- package/lib/types/components/InterruptedByUser.d.ts +2 -2
- package/lib/types/components/InterruptedByUser.d.ts.map +1 -1
- package/lib/types/components/InterruptedByUser.js +4 -3
- package/lib/types/components/LoadedContextPanel.d.ts +1 -1
- package/lib/types/components/LoadedContextPanel.d.ts.map +1 -1
- package/lib/types/components/LogoV2.d.ts.map +1 -1
- package/lib/types/components/LogoV2.js +2 -1
- package/lib/types/components/Markdown.d.ts +11 -11
- package/lib/types/components/Markdown.d.ts.map +1 -1
- package/lib/types/components/Markdown.js +63 -57
- package/lib/types/components/MarkdownTable.d.ts +1 -1
- package/lib/types/components/MarkdownTable.js +2 -2
- package/lib/types/components/MessageList.d.ts +10 -2
- package/lib/types/components/MessageList.d.ts.map +1 -1
- package/lib/types/components/MessageList.js +17 -10
- package/lib/types/components/ModelPicker.d.ts +4 -1
- package/lib/types/components/ModelPicker.d.ts.map +1 -1
- package/lib/types/components/ModelPicker.js +16 -4
- package/lib/types/components/OverlayAbove.d.ts +20 -0
- package/lib/types/components/OverlayAbove.d.ts.map +1 -0
- package/lib/types/components/OverlayAbove.js +18 -0
- package/lib/types/components/PresetPicker.d.ts +1 -1
- package/lib/types/components/PresetPicker.d.ts.map +1 -1
- package/lib/types/components/PresetPicker.js +2 -3
- package/lib/types/components/PromptInput.d.ts +5 -4
- package/lib/types/components/PromptInput.d.ts.map +1 -1
- package/lib/types/components/PromptInput.js +186 -39
- package/lib/types/components/ResumePicker.d.ts +15 -4
- package/lib/types/components/ResumePicker.d.ts.map +1 -1
- package/lib/types/components/ResumePicker.js +25 -9
- package/lib/types/components/RewindPicker.d.ts +1 -1
- package/lib/types/components/RewindPicker.d.ts.map +1 -1
- package/lib/types/components/RewindPicker.js +14 -5
- package/lib/types/components/SearchBox.d.ts +1 -1
- package/lib/types/components/SearchBox.js +1 -1
- package/lib/types/components/Spinner/GlimmerMessage.d.ts +1 -2
- package/lib/types/components/Spinner/GlimmerMessage.d.ts.map +1 -1
- package/lib/types/components/Spinner/GlimmerMessage.js +1 -2
- package/lib/types/components/Spinner/SpinnerAnimationRow.d.ts +1 -1
- package/lib/types/components/Spinner/SpinnerAnimationRow.js +2 -2
- package/lib/types/components/Spinner/SpinnerGlyph.d.ts +1 -1
- package/lib/types/components/Spinner/SpinnerGlyph.js +1 -1
- package/lib/types/components/Spinner/spinnerUtils.d.ts +13 -18
- package/lib/types/components/Spinner/spinnerUtils.d.ts.map +1 -1
- package/lib/types/components/Spinner/spinnerUtils.js +67 -71
- package/lib/types/components/Spinner/useStalledAnimation.d.ts +1 -2
- package/lib/types/components/Spinner/useStalledAnimation.d.ts.map +1 -1
- package/lib/types/components/Spinner/useStalledAnimation.js +1 -2
- package/lib/types/components/StreamingMarkdown.d.ts +1 -1
- package/lib/types/components/StreamingMarkdown.js +1 -1
- package/lib/types/components/ThemePicker.d.ts +13 -9
- package/lib/types/components/ThemePicker.d.ts.map +1 -1
- package/lib/types/components/ThemePicker.js +21 -15
- package/lib/types/components/ThinkingToggle.d.ts +1 -1
- package/lib/types/components/ThinkingToggle.d.ts.map +1 -1
- package/lib/types/components/ThinkingToggle.js +8 -8
- package/lib/types/components/ToolUseLoader.d.ts +1 -1
- package/lib/types/components/ToolUseLoader.js +1 -1
- package/lib/types/components/WorkingSpinner.d.ts +2 -2
- package/lib/types/components/WorkingSpinner.js +2 -2
- package/lib/types/components/WorkspaceFlowPicker.d.ts +15 -0
- package/lib/types/components/WorkspaceFlowPicker.d.ts.map +1 -0
- package/lib/types/components/WorkspaceFlowPicker.js +19 -0
- package/lib/types/components/WorkspacePicker.d.ts +9 -0
- package/lib/types/components/WorkspacePicker.d.ts.map +1 -0
- package/lib/types/components/WorkspacePicker.js +13 -0
- package/lib/types/components/approvals/ApprovalPanel.d.ts +1 -1
- package/lib/types/components/approvals/ApprovalPanel.d.ts.map +1 -1
- package/lib/types/components/approvals/ApprovalPanel.js +2 -1
- package/lib/types/components/design-system/Byline.d.ts +1 -1
- package/lib/types/components/design-system/Byline.js +1 -1
- package/lib/types/components/design-system/Divider.d.ts +1 -1
- package/lib/types/components/design-system/Divider.js +1 -1
- package/lib/types/components/design-system/HintLine.d.ts +12 -0
- package/lib/types/components/design-system/HintLine.d.ts.map +1 -0
- package/lib/types/components/design-system/HintLine.js +15 -0
- package/lib/types/components/design-system/KeyboardShortcutHint.d.ts +1 -1
- package/lib/types/components/design-system/KeyboardShortcutHint.js +1 -1
- package/lib/types/components/design-system/ListItem.d.ts +2 -2
- package/lib/types/components/design-system/ListItem.d.ts.map +1 -1
- package/lib/types/components/design-system/ListItem.js +35 -3
- package/lib/types/components/design-system/LoadingState.d.ts +1 -2
- package/lib/types/components/design-system/LoadingState.d.ts.map +1 -1
- package/lib/types/components/design-system/LoadingState.js +1 -2
- package/lib/types/components/design-system/Pane.d.ts +2 -2
- package/lib/types/components/design-system/Pane.js +2 -2
- package/lib/types/components/design-system/ProgressBar.d.ts +1 -2
- package/lib/types/components/design-system/ProgressBar.d.ts.map +1 -1
- package/lib/types/components/design-system/ProgressBar.js +1 -2
- package/lib/types/components/design-system/StatusIcon.d.ts +2 -2
- package/lib/types/components/design-system/StatusIcon.js +2 -2
- package/lib/types/components/design-system/ThemeProvider.d.ts +1 -1
- package/lib/types/components/design-system/ThemeProvider.d.ts.map +1 -1
- package/lib/types/components/design-system/ThemeProvider.js +87 -26
- package/lib/types/components/design-system/ThemedBox.d.ts +1 -1
- package/lib/types/components/design-system/ThemedBox.js +1 -1
- package/lib/types/components/design-system/ThemedText.d.ts +2 -2
- package/lib/types/components/design-system/ThemedText.js +2 -2
- package/lib/types/components/listWindow.d.ts +26 -0
- package/lib/types/components/listWindow.d.ts.map +1 -0
- package/lib/types/components/listWindow.js +47 -0
- package/lib/types/components/messages/AssistantTextMessage.d.ts +1 -2
- package/lib/types/components/messages/AssistantTextMessage.d.ts.map +1 -1
- package/lib/types/components/messages/AssistantTextMessage.js +1 -2
- package/lib/types/components/messages/AssistantThinkingMessage.d.ts +2 -2
- package/lib/types/components/messages/AssistantThinkingMessage.d.ts.map +1 -1
- package/lib/types/components/messages/AssistantThinkingMessage.js +6 -6
- package/lib/types/components/messages/AssistantToolUseMessage.d.ts +12 -4
- package/lib/types/components/messages/AssistantToolUseMessage.d.ts.map +1 -1
- package/lib/types/components/messages/AssistantToolUseMessage.js +9 -5
- package/lib/types/components/messages/MessageMetadata.d.ts +1 -1
- package/lib/types/components/messages/MessageMetadata.js +1 -1
- package/lib/types/components/messages/UserPromptMessage.d.ts +1 -1
- package/lib/types/components/messages/UserPromptMessage.js +1 -1
- package/lib/types/components/questions/AskUserQuestionPanel.d.ts +5 -1
- package/lib/types/components/questions/AskUserQuestionPanel.d.ts.map +1 -1
- package/lib/types/components/questions/AskUserQuestionPanel.js +11 -9
- package/lib/types/components/questions/PlanReviewPanel.d.ts +1 -1
- package/lib/types/components/questions/PlanReviewPanel.d.ts.map +1 -1
- package/lib/types/components/questions/PlanReviewPanel.js +3 -2
- package/lib/types/components/trajectory/HotspotView.d.ts +14 -0
- package/lib/types/components/trajectory/HotspotView.d.ts.map +1 -0
- package/lib/types/components/trajectory/HotspotView.js +83 -0
- package/lib/types/components/trajectory/Inspector.d.ts +31 -0
- package/lib/types/components/trajectory/Inspector.d.ts.map +1 -0
- package/lib/types/components/trajectory/Inspector.js +67 -0
- package/lib/types/components/trajectory/Ledger.d.ts +20 -0
- package/lib/types/components/trajectory/Ledger.d.ts.map +1 -0
- package/lib/types/components/trajectory/Ledger.js +112 -0
- package/lib/types/components/trajectory/MiniWake.d.ts +24 -0
- package/lib/types/components/trajectory/MiniWake.d.ts.map +1 -0
- package/lib/types/components/trajectory/MiniWake.js +99 -0
- package/lib/types/components/trajectory/WaveBand.d.ts +33 -0
- package/lib/types/components/trajectory/WaveBand.d.ts.map +1 -0
- package/lib/types/components/trajectory/WaveBand.js +145 -0
- package/lib/types/customTheme.d.ts +6 -6
- package/lib/types/customTheme.d.ts.map +1 -1
- package/lib/types/customTheme.js +15 -12
- package/lib/types/dsh-adapter/approvals.d.ts.map +1 -0
- package/lib/types/{channel.d.ts → dsh-adapter/channel.d.ts} +184 -43
- package/lib/types/dsh-adapter/channel.d.ts.map +1 -0
- package/lib/types/{channel.js → dsh-adapter/channel.js} +972 -201
- package/lib/types/dsh-adapter/childStderr.d.ts.map +1 -0
- package/lib/types/{childStderr.js → dsh-adapter/childStderr.js} +1 -1
- package/lib/types/dsh-adapter/command-trees.d.ts +27 -0
- package/lib/types/dsh-adapter/command-trees.d.ts.map +1 -0
- package/lib/types/dsh-adapter/command-trees.js +42 -0
- package/lib/types/dsh-adapter/compat/index.d.ts +22 -0
- package/lib/types/dsh-adapter/compat/index.d.ts.map +1 -0
- package/lib/types/{compat → dsh-adapter/compat}/index.js +7 -4
- package/lib/types/dsh-adapter/compat/sessionLog.d.ts +86 -0
- package/lib/types/dsh-adapter/compat/sessionLog.d.ts.map +1 -0
- package/lib/types/dsh-adapter/compat/sessionLog.js +347 -0
- package/lib/types/dsh-adapter/contract.d.ts +20 -0
- package/lib/types/dsh-adapter/contract.d.ts.map +1 -0
- package/lib/types/dsh-adapter/contract.js +109 -0
- package/lib/types/dsh-adapter/index.d.ts +80 -0
- package/lib/types/dsh-adapter/index.d.ts.map +1 -0
- package/lib/types/dsh-adapter/index.js +45 -0
- package/lib/types/dsh-adapter/invariant.d.ts.map +1 -0
- package/lib/types/dsh-adapter/packaged-skills.d.ts.map +1 -0
- package/lib/types/{plugin.d.ts → dsh-adapter/plugin.d.ts} +17 -0
- package/lib/types/dsh-adapter/plugin.d.ts.map +1 -0
- package/lib/types/{plugin.js → dsh-adapter/plugin.js} +280 -80
- package/lib/types/dsh-adapter/presets.d.ts.map +1 -0
- package/lib/types/dsh-adapter/providerWizard.d.ts +91 -0
- package/lib/types/dsh-adapter/providerWizard.d.ts.map +1 -0
- package/lib/types/dsh-adapter/providerWizard.js +332 -0
- package/lib/types/{questions.d.ts → dsh-adapter/questions.d.ts} +7 -2
- package/lib/types/dsh-adapter/questions.d.ts.map +1 -0
- package/lib/types/{questions.js → dsh-adapter/questions.js} +15 -7
- package/lib/types/dsh-adapter/sideQuestion.d.ts +38 -0
- package/lib/types/dsh-adapter/sideQuestion.d.ts.map +1 -0
- package/lib/types/dsh-adapter/sideQuestion.js +69 -0
- package/lib/types/dsh-adapter/trajectory/aggregate.d.ts +46 -0
- package/lib/types/dsh-adapter/trajectory/aggregate.d.ts.map +1 -0
- package/lib/types/dsh-adapter/trajectory/aggregate.js +207 -0
- package/lib/types/dsh-adapter/trajectory/guards.d.ts +177 -0
- package/lib/types/dsh-adapter/trajectory/guards.d.ts.map +1 -0
- package/lib/types/dsh-adapter/trajectory/guards.js +235 -0
- package/lib/types/dsh-adapter/trajectory/index.d.ts +16 -0
- package/lib/types/dsh-adapter/trajectory/index.d.ts.map +1 -0
- package/lib/types/dsh-adapter/trajectory/index.js +15 -0
- package/lib/types/dsh-adapter/trajectory/inspect.d.ts +40 -0
- package/lib/types/dsh-adapter/trajectory/inspect.d.ts.map +1 -0
- package/lib/types/dsh-adapter/trajectory/inspect.js +160 -0
- package/lib/types/dsh-adapter/trajectory/projection.d.ts +128 -0
- package/lib/types/dsh-adapter/trajectory/projection.d.ts.map +1 -0
- package/lib/types/dsh-adapter/trajectory/projection.js +653 -0
- package/lib/types/dsh-adapter/trajectory/types.d.ts +232 -0
- package/lib/types/dsh-adapter/trajectory/types.d.ts.map +1 -0
- package/lib/types/dsh-adapter/trajectory/types.js +70 -0
- package/lib/types/dsh-adapter/trajectory/wave.d.ts +45 -0
- package/lib/types/dsh-adapter/trajectory/wave.d.ts.map +1 -0
- package/lib/types/dsh-adapter/trajectory/wave.js +210 -0
- package/lib/types/dsh-adapter/types.d.ts +23 -0
- package/lib/types/dsh-adapter/types.d.ts.map +1 -0
- package/lib/types/dsh-adapter/types.js +1 -0
- package/lib/types/dsh-adapter/workspace.d.ts +22 -0
- package/lib/types/dsh-adapter/workspace.d.ts.map +1 -0
- package/lib/types/dsh-adapter/workspace.js +16 -0
- package/lib/types/dsh-adapter/workspaces.d.ts +118 -0
- package/lib/types/dsh-adapter/workspaces.d.ts.map +1 -0
- package/lib/types/dsh-adapter/workspaces.js +290 -0
- package/lib/types/effortPrefs.d.ts +1 -1
- package/lib/types/effortPrefs.js +3 -3
- package/lib/types/history.js +2 -2
- package/lib/types/hooks/useBlink.d.ts +1 -1
- package/lib/types/hooks/useBlink.js +1 -1
- package/lib/types/i18n.d.ts +977 -36
- package/lib/types/i18n.d.ts.map +1 -1
- package/lib/types/i18n.js +307 -30
- package/lib/types/index.d.ts +1 -69
- package/lib/types/index.d.ts.map +1 -1
- package/lib/types/index.js +3 -31
- package/lib/types/ink/components/App.d.ts.map +1 -1
- package/lib/types/ink/components/App.js +33 -19
- package/lib/types/ink/dom.d.ts +15 -0
- package/lib/types/ink/dom.d.ts.map +1 -1
- package/lib/types/ink/dom.js +32 -0
- package/lib/types/ink/hooks/use-input.d.ts.map +1 -1
- package/lib/types/ink/hooks/use-input.js +8 -0
- package/lib/types/ink/hooks/use-terminal-size.d.ts +1 -1
- package/lib/types/ink/hooks/use-terminal-size.js +1 -1
- package/lib/types/ink/ink.d.ts.map +1 -1
- package/lib/types/ink/ink.js +109 -28
- package/lib/types/ink/input-suppression.d.ts +20 -0
- package/lib/types/ink/input-suppression.d.ts.map +1 -0
- package/lib/types/ink/input-suppression.js +26 -0
- package/lib/types/ink/log-update.js +21 -6
- package/lib/types/ink/parse-keypress.d.ts +31 -0
- package/lib/types/ink/parse-keypress.d.ts.map +1 -1
- package/lib/types/ink/parse-keypress.js +442 -8
- package/lib/types/ink/terminal-querier.d.ts +5 -1
- package/lib/types/ink/terminal-querier.d.ts.map +1 -1
- package/lib/types/ink/terminal-querier.js +27 -3
- package/lib/types/ink/terminal.d.ts +18 -0
- package/lib/types/ink/terminal.d.ts.map +1 -1
- package/lib/types/ink/terminal.js +32 -4
- package/lib/types/ink/termio/csi.d.ts +10 -0
- package/lib/types/ink/termio/csi.d.ts.map +1 -1
- package/lib/types/ink/termio/csi.js +20 -0
- package/lib/types/ink/termio/tokenize.js +10 -0
- package/lib/types/modelPrefs.d.ts +1 -1
- package/lib/types/modelPrefs.js +3 -3
- package/lib/types/presetPrefs.d.ts +1 -1
- package/lib/types/presetPrefs.js +3 -3
- package/lib/types/screens/Chat.d.ts +20 -4
- package/lib/types/screens/Chat.d.ts.map +1 -1
- package/lib/types/screens/Chat.js +655 -55
- package/lib/types/screens/StatusLine.d.ts +17 -2
- package/lib/types/screens/StatusLine.d.ts.map +1 -1
- package/lib/types/screens/StatusLine.js +12 -4
- package/lib/types/screens/TrajectoryScene.d.ts +16 -0
- package/lib/types/screens/TrajectoryScene.d.ts.map +1 -0
- package/lib/types/screens/TrajectoryScene.js +305 -0
- package/lib/types/sessionHistory.d.ts +9 -1
- package/lib/types/sessionHistory.d.ts.map +1 -1
- package/lib/types/sessionHistory.js +56 -16
- package/lib/types/sessionModes.d.ts +29 -0
- package/lib/types/sessionModes.d.ts.map +1 -0
- package/lib/types/sessionModes.js +45 -0
- package/lib/types/theme.d.ts +27 -3
- package/lib/types/theme.d.ts.map +1 -1
- package/lib/types/theme.js +48 -4
- package/lib/types/themePrefs.d.ts +3 -3
- package/lib/types/themePrefs.js +5 -5
- package/lib/types/trajectory/format.d.ts +100 -0
- package/lib/types/trajectory/format.d.ts.map +1 -0
- package/lib/types/trajectory/format.js +213 -0
- package/lib/types/trajectory/motion.d.ts +99 -0
- package/lib/types/trajectory/motion.d.ts.map +1 -0
- package/lib/types/trajectory/motion.js +143 -0
- package/lib/types/trajectory/query.d.ts +83 -0
- package/lib/types/trajectory/query.d.ts.map +1 -0
- package/lib/types/trajectory/query.js +187 -0
- package/lib/types/trajectoryPrefs.d.ts +36 -0
- package/lib/types/trajectoryPrefs.d.ts.map +1 -0
- package/lib/types/trajectoryPrefs.js +65 -0
- package/lib/types/update.d.ts +3 -3
- package/lib/types/update.d.ts.map +1 -1
- package/lib/types/update.js +18 -7
- package/lib/types/utils/clipboard.d.ts +101 -29
- package/lib/types/utils/clipboard.d.ts.map +1 -1
- package/lib/types/utils/clipboard.js +533 -55
- package/lib/types/utils/debug.d.ts +1 -1
- package/lib/types/utils/debug.js +2 -2
- package/lib/types/utils/execFileNoThrow.d.ts.map +1 -1
- package/lib/types/utils/execFileNoThrow.js +16 -6
- package/lib/types/utils/externalEditor.d.ts +115 -0
- package/lib/types/utils/externalEditor.d.ts.map +1 -0
- package/lib/types/utils/externalEditor.js +270 -0
- package/lib/types/utils/fullscreen.d.ts +2 -2
- package/lib/types/utils/fullscreen.js +3 -3
- package/lib/types/utils/loaded-context.d.ts +1 -1
- package/lib/types/utils/loaded-context.d.ts.map +1 -1
- package/lib/types/utils/modifiers.d.ts +24 -0
- package/lib/types/utils/modifiers.d.ts.map +1 -1
- package/lib/types/utils/modifiers.js +27 -0
- package/lib/types/utils/paths.d.ts +45 -0
- package/lib/types/utils/paths.d.ts.map +1 -0
- package/lib/types/utils/paths.js +69 -0
- package/lib/types/utils/shellQuote.d.ts +14 -0
- package/lib/types/utils/shellQuote.d.ts.map +1 -0
- package/lib/types/utils/shellQuote.js +39 -0
- package/lib/types/utils/workspaceRoot.d.ts +21 -0
- package/lib/types/utils/workspaceRoot.d.ts.map +1 -0
- package/lib/types/utils/workspaceRoot.js +47 -0
- package/lib/types/workspaces.d.ts +3 -0
- package/lib/types/workspaces.d.ts.map +1 -0
- package/lib/types/workspaces.js +4 -0
- package/package.json +26 -8
- package/lib/types/approvals.d.ts.map +0 -1
- package/lib/types/channel.d.ts.map +0 -1
- package/lib/types/childStderr.d.ts.map +0 -1
- package/lib/types/compat/index.d.ts +0 -20
- package/lib/types/compat/index.d.ts.map +0 -1
- package/lib/types/compat/sessionLog.d.ts +0 -40
- package/lib/types/compat/sessionLog.d.ts.map +0 -1
- package/lib/types/compat/sessionLog.js +0 -226
- package/lib/types/invariant.d.ts.map +0 -1
- package/lib/types/packaged-skills.d.ts.map +0 -1
- package/lib/types/plugin.d.ts.map +0 -1
- package/lib/types/presets.d.ts.map +0 -1
- package/lib/types/questions.d.ts.map +0 -1
- /package/lib/types/{approvals.d.ts → dsh-adapter/approvals.d.ts} +0 -0
- /package/lib/types/{approvals.js → dsh-adapter/approvals.js} +0 -0
- /package/lib/types/{childStderr.d.ts → dsh-adapter/childStderr.d.ts} +0 -0
- /package/lib/types/{invariant.d.ts → dsh-adapter/invariant.d.ts} +0 -0
- /package/lib/types/{invariant.js → dsh-adapter/invariant.js} +0 -0
- /package/lib/types/{packaged-skills.d.ts → dsh-adapter/packaged-skills.d.ts} +0 -0
- /package/lib/types/{packaged-skills.js → dsh-adapter/packaged-skills.js} +0 -0
- /package/lib/types/{presets.d.ts → dsh-adapter/presets.d.ts} +0 -0
- /package/lib/types/{presets.js → dsh-adapter/presets.js} +0 -0
package/lib/types/cc/markdown.js
CHANGED
|
@@ -1,9 +1,16 @@
|
|
|
1
|
-
|
|
2
|
-
|
|
3
|
-
|
|
4
|
-
|
|
5
|
-
|
|
6
|
-
|
|
1
|
+
/**
|
|
2
|
+
* Markdown-to-ANSI renderer over marked's token stream.
|
|
3
|
+
*
|
|
4
|
+
* Converts the shared marked lexer output into styled terminal text: quote
|
|
5
|
+
* gutters, syntax-highlighted fenced blocks, indented list bullets with
|
|
6
|
+
* depth-based numbering, and alignment-padded tables. The visual conventions
|
|
7
|
+
* (▎ bars for blockquotes, theme-colored inline code, OSC 8 hyperlinks) are
|
|
8
|
+
* standard terminal markdown idioms, but this is an independent
|
|
9
|
+
* implementation: a single dispatch switch fans tokens out to dedicated
|
|
10
|
+
* per-type render functions, and all recursive calls thread one immutable
|
|
11
|
+
* RenderState (parent token, list depth, list ordinal, highlighter) instead
|
|
12
|
+
* of passing positional arguments.
|
|
13
|
+
*/
|
|
7
14
|
import chalk from 'chalk';
|
|
8
15
|
import { marked } from 'marked';
|
|
9
16
|
import stripAnsi from 'strip-ansi';
|
|
@@ -13,37 +20,44 @@ import { colorize } from '../ink/colorize.js';
|
|
|
13
20
|
import { getActiveTheme } from '../theme.js';
|
|
14
21
|
import { logForDebugging } from '../utils/debug.js';
|
|
15
22
|
import { createHyperlink } from './hyperlink.js';
|
|
16
|
-
//
|
|
17
|
-
//
|
|
18
|
-
//
|
|
19
|
-
const
|
|
20
|
-
|
|
21
|
-
|
|
22
|
-
|
|
23
|
+
// '\n' is used unconditionally — os.EOL is '\r\n' on Windows, and the stray
|
|
24
|
+
// '\r' breaks the character-to-segment mapping in applyStylesToWrappedText,
|
|
25
|
+
// shifting styled text to the right.
|
|
26
|
+
const EOL = '\n';
|
|
27
|
+
/** Left one-quarter block (U+258E), the blockquote gutter marker. */
|
|
28
|
+
const QUOTE_BAR = '\u258e';
|
|
29
|
+
/** Tool-analysis tag blocks that carry no user-facing content; dropped before lexing. */
|
|
30
|
+
const TOOL_ANALYSIS_TAG_BLOCKS = /<(commit_analysis|context|function_analysis|pr_analysis)>.*?<\/\1>\n?/gs;
|
|
31
|
+
/**
|
|
32
|
+
* Matches `owner/repo#NNN` style GitHub issue/PR references. Only the
|
|
33
|
+
* qualified form is recognized: a bare `#NNN` would guess the current
|
|
34
|
+
* repository and be wrong whenever the assistant discusses a different one.
|
|
35
|
+
* The owner segment excludes dots (GitHub usernames are alphanumerics plus
|
|
36
|
+
* hyphens) so hostnames like docs.example.io/guide#42 don't false-positive;
|
|
37
|
+
* the repo segment allows dots (e.g. cc.kurs.web). Lookbehind is avoided —
|
|
38
|
+
* it defeats YARR JIT in JSC.
|
|
39
|
+
*/
|
|
40
|
+
const ISSUE_REFERENCE_PATTERN = /(^|[^\w./-])([A-Za-z0-9][\w-]*\/[A-Za-z0-9][\w.-]*)#(\d+)\b/g;
|
|
23
41
|
/**
|
|
24
|
-
* Strip tool-analysis XML
|
|
25
|
-
* `<pr_analysis>`) and their contents, then trim
|
|
26
|
-
* @param content - Markdown
|
|
27
|
-
* @returns The content with those blocks removed and
|
|
42
|
+
* Strip tool-analysis XML blocks (`<commit_analysis>`, `<context>`,
|
|
43
|
+
* `<function_analysis>`, `<pr_analysis>`) and their contents, then trim.
|
|
44
|
+
* @param content - Markdown that may wrap the tool-analysis tag blocks.
|
|
45
|
+
* @returns The content with those blocks removed and whitespace trimmed.
|
|
28
46
|
*/
|
|
29
47
|
export function stripPromptXMLTags(content) {
|
|
30
|
-
return content.replace(
|
|
48
|
+
return content.replace(TOOL_ANALYSIS_TAG_BLOCKS, '').trim();
|
|
31
49
|
}
|
|
32
|
-
|
|
33
|
-
// breaks the character-to-segment mapping in applyStylesToWrappedText,
|
|
34
|
-
// causing styled text to shift right.
|
|
35
|
-
const EOL = '\n';
|
|
36
|
-
let markedConfigured = false;
|
|
50
|
+
let markedInitialized = false;
|
|
37
51
|
/**
|
|
38
|
-
* Configure the shared `marked` instance once
|
|
39
|
-
* `~100` renders literally instead of as deleted text
|
|
52
|
+
* Configure the shared `marked` instance once. Strikethrough parsing is
|
|
53
|
+
* disabled so that `~100` renders literally instead of as deleted text —
|
|
54
|
+
* models use `~` far more often for "approximate" than for real
|
|
55
|
+
* strikethrough.
|
|
40
56
|
*/
|
|
41
57
|
export function configureMarked() {
|
|
42
|
-
if (
|
|
58
|
+
if (markedInitialized)
|
|
43
59
|
return;
|
|
44
|
-
|
|
45
|
-
// Disable strikethrough parsing - the model often uses ~ for "approximate"
|
|
46
|
-
// (e.g., ~100) and rarely intends actual strikethrough formatting
|
|
60
|
+
markedInitialized = true;
|
|
47
61
|
marked.use({
|
|
48
62
|
tokenizer: {
|
|
49
63
|
del() {
|
|
@@ -52,6 +66,34 @@ export function configureMarked() {
|
|
|
52
66
|
},
|
|
53
67
|
});
|
|
54
68
|
}
|
|
69
|
+
/** Inline code is painted with the active theme's permission accent. */
|
|
70
|
+
function paintInlineCode(text) {
|
|
71
|
+
return colorize(text, getActiveTheme().permission, 'foreground');
|
|
72
|
+
}
|
|
73
|
+
/** A fresh context for block-level children: list state reset, no parent. */
|
|
74
|
+
function fresh(state) {
|
|
75
|
+
return { highlight: state.highlight, parent: null, listDepth: 0, ordinal: null };
|
|
76
|
+
}
|
|
77
|
+
/** Same context, different parent token. */
|
|
78
|
+
function withParent(state, parent) {
|
|
79
|
+
return { ...state, parent };
|
|
80
|
+
}
|
|
81
|
+
/** Inline-styled children keep the outer parent but shed list context. */
|
|
82
|
+
function inlineChildren(state) {
|
|
83
|
+
return { ...state, listDepth: 0, ordinal: null };
|
|
84
|
+
}
|
|
85
|
+
/**
|
|
86
|
+
* Render one marked token to ANSI text, recursing into child tokens.
|
|
87
|
+
* @param token - The marked token to render.
|
|
88
|
+
* @param listDepth - Nesting depth of the enclosing list; drives indentation and numbering style.
|
|
89
|
+
* @param orderedListNumber - Current ordinal of the enclosing ordered list item, or null for unordered lists.
|
|
90
|
+
* @param parent - The parent token; linkification is skipped inside links and prefixes are added inside list items.
|
|
91
|
+
* @param highlight - Optional cli-highlight surface for code blocks; null disables syntax highlighting.
|
|
92
|
+
* @returns The rendered ANSI string for the token, or '' for unrendered token types.
|
|
93
|
+
*/
|
|
94
|
+
export function formatToken(token, listDepth = 0, orderedListNumber = null, parent = null, highlight = null) {
|
|
95
|
+
return dispatch(token, { highlight, parent, listDepth, ordinal: orderedListNumber });
|
|
96
|
+
}
|
|
55
97
|
/**
|
|
56
98
|
* Render markdown content to ANSI-styled text via the shared `marked` instance.
|
|
57
99
|
* @param content - Markdown source to render.
|
|
@@ -60,231 +102,225 @@ export function configureMarked() {
|
|
|
60
102
|
*/
|
|
61
103
|
export function applyMarkdown(content, highlight = null) {
|
|
62
104
|
configureMarked();
|
|
105
|
+
const rootState = {
|
|
106
|
+
highlight,
|
|
107
|
+
parent: null,
|
|
108
|
+
listDepth: 0,
|
|
109
|
+
ordinal: null,
|
|
110
|
+
};
|
|
63
111
|
return marked
|
|
64
112
|
.lexer(stripPromptXMLTags(content))
|
|
65
|
-
.map(
|
|
113
|
+
.map(token => dispatch(token, rootState))
|
|
66
114
|
.join('')
|
|
67
115
|
.trim();
|
|
68
116
|
}
|
|
69
117
|
/**
|
|
70
|
-
*
|
|
71
|
-
*
|
|
72
|
-
*
|
|
73
|
-
*
|
|
74
|
-
* @param parent - The parent token; linkification is skipped inside links and prefixes are added inside list items.
|
|
75
|
-
* @param highlight - Optional cli-highlight surface for code blocks; null disables syntax highlighting.
|
|
76
|
-
* @returns The rendered ANSI string for the token, or '' for unrendered token types.
|
|
118
|
+
* Type guard that narrows to the concrete marked token of `kind`.
|
|
119
|
+
* Plain `switch` narrowing fails here: Tokens.Generic declares `type: string`,
|
|
120
|
+
* so every case keeps Generic in the union. Guarding against MarkedToken
|
|
121
|
+
* (which excludes Generic) yields exact types for the per-type renderers.
|
|
77
122
|
*/
|
|
78
|
-
|
|
79
|
-
|
|
80
|
-
|
|
81
|
-
|
|
82
|
-
|
|
83
|
-
|
|
84
|
-
|
|
85
|
-
|
|
86
|
-
|
|
87
|
-
|
|
88
|
-
|
|
89
|
-
|
|
90
|
-
|
|
91
|
-
|
|
92
|
-
|
|
93
|
-
|
|
94
|
-
|
|
95
|
-
|
|
96
|
-
|
|
97
|
-
|
|
98
|
-
|
|
99
|
-
|
|
100
|
-
|
|
101
|
-
|
|
102
|
-
|
|
103
|
-
|
|
104
|
-
|
|
105
|
-
|
|
106
|
-
|
|
107
|
-
|
|
108
|
-
|
|
109
|
-
|
|
110
|
-
|
|
111
|
-
|
|
112
|
-
|
|
113
|
-
|
|
114
|
-
|
|
115
|
-
|
|
116
|
-
|
|
117
|
-
|
|
118
|
-
|
|
119
|
-
|
|
120
|
-
|
|
121
|
-
|
|
122
|
-
|
|
123
|
-
|
|
124
|
-
|
|
125
|
-
|
|
126
|
-
|
|
127
|
-
|
|
128
|
-
|
|
129
|
-
|
|
130
|
-
|
|
131
|
-
|
|
132
|
-
|
|
133
|
-
|
|
134
|
-
|
|
135
|
-
|
|
136
|
-
|
|
137
|
-
|
|
138
|
-
|
|
139
|
-
|
|
140
|
-
|
|
141
|
-
return '---';
|
|
142
|
-
case 'image':
|
|
143
|
-
return token.href;
|
|
144
|
-
case 'link': {
|
|
145
|
-
// Prevent mailto links from being displayed as clickable links
|
|
146
|
-
if (token.href.startsWith('mailto:')) {
|
|
147
|
-
// Extract email from mailto: link and display as plain text
|
|
148
|
-
const email = token.href.replace(/^mailto:/, '');
|
|
149
|
-
return email;
|
|
150
|
-
}
|
|
151
|
-
// Extract display text from the link's child tokens
|
|
152
|
-
const linkText = (token.tokens ?? [])
|
|
153
|
-
.map(_ => formatToken(_, 0, null, token, highlight))
|
|
154
|
-
.join('');
|
|
155
|
-
const plainLinkText = stripAnsi(linkText);
|
|
156
|
-
// If the link has meaningful display text (different from the URL),
|
|
157
|
-
// show it as a clickable hyperlink. In terminals that support OSC 8,
|
|
158
|
-
// users see the text and can hover/click to see the URL.
|
|
159
|
-
if (plainLinkText && plainLinkText !== token.href) {
|
|
160
|
-
return createHyperlink(token.href, linkText);
|
|
161
|
-
}
|
|
162
|
-
// When the display text matches the URL (or is empty), just show the URL
|
|
163
|
-
return createHyperlink(token.href);
|
|
164
|
-
}
|
|
165
|
-
case 'list': {
|
|
166
|
-
return token.items
|
|
167
|
-
.map((_, index) => formatToken(_, listDepth, token.ordered ? token.start + index : null, token, highlight))
|
|
168
|
-
.join('');
|
|
123
|
+
function isToken(token, kind) {
|
|
124
|
+
return token.type === kind;
|
|
125
|
+
}
|
|
126
|
+
/** Fan-out point: narrows the token union, then delegates to the per-type render functions. */
|
|
127
|
+
function dispatch(token, state) {
|
|
128
|
+
if (isToken(token, 'blockquote'))
|
|
129
|
+
return renderBlockquote(token, state);
|
|
130
|
+
if (isToken(token, 'code'))
|
|
131
|
+
return renderCodeBlock(token, state);
|
|
132
|
+
if (isToken(token, 'codespan'))
|
|
133
|
+
return paintInlineCode(token.text);
|
|
134
|
+
if (isToken(token, 'em'))
|
|
135
|
+
return renderEmphasis(token, state);
|
|
136
|
+
if (isToken(token, 'strong'))
|
|
137
|
+
return renderStrong(token, state);
|
|
138
|
+
if (isToken(token, 'heading'))
|
|
139
|
+
return renderHeading(token, state);
|
|
140
|
+
if (isToken(token, 'hr'))
|
|
141
|
+
return '---';
|
|
142
|
+
if (isToken(token, 'image'))
|
|
143
|
+
return token.href;
|
|
144
|
+
if (isToken(token, 'link'))
|
|
145
|
+
return renderLink(token, state);
|
|
146
|
+
if (isToken(token, 'list'))
|
|
147
|
+
return renderList(token, state);
|
|
148
|
+
if (isToken(token, 'list_item'))
|
|
149
|
+
return renderListItem(token, state);
|
|
150
|
+
if (isToken(token, 'paragraph'))
|
|
151
|
+
return renderParagraph(token, state);
|
|
152
|
+
if (isToken(token, 'space') || isToken(token, 'br'))
|
|
153
|
+
return EOL;
|
|
154
|
+
if (isToken(token, 'text'))
|
|
155
|
+
return renderText(token, state);
|
|
156
|
+
if (isToken(token, 'table'))
|
|
157
|
+
return renderTable(token, state);
|
|
158
|
+
if (isToken(token, 'escape'))
|
|
159
|
+
return token.text;
|
|
160
|
+
if (isToken(token, 'def') || isToken(token, 'del') || isToken(token, 'html')) {
|
|
161
|
+
// Link definitions, strikethrough, and raw HTML carry no ANSI
|
|
162
|
+
// representation.
|
|
163
|
+
return '';
|
|
164
|
+
}
|
|
165
|
+
// Unknown / extension token types render as nothing.
|
|
166
|
+
return '';
|
|
167
|
+
}
|
|
168
|
+
function renderBlockquote(token, state) {
|
|
169
|
+
const inner = token.tokens.map(child => dispatch(child, fresh(state))).join('');
|
|
170
|
+
// Dim gutter bar per line; keep the text italic but at normal brightness —
|
|
171
|
+
// chalk.dim is nearly invisible on dark themes.
|
|
172
|
+
const gutter = chalk.dim(QUOTE_BAR);
|
|
173
|
+
return inner
|
|
174
|
+
.split(EOL)
|
|
175
|
+
.map(line => (stripAnsi(line).trim() ? `${gutter} ${chalk.italic(line)}` : line))
|
|
176
|
+
.join(EOL);
|
|
177
|
+
}
|
|
178
|
+
function renderCodeBlock(token, state) {
|
|
179
|
+
if (!state.highlight) {
|
|
180
|
+
return token.text + EOL;
|
|
181
|
+
}
|
|
182
|
+
let language = 'plaintext';
|
|
183
|
+
if (token.lang) {
|
|
184
|
+
if (state.highlight.supportsLanguage(token.lang)) {
|
|
185
|
+
language = token.lang;
|
|
169
186
|
}
|
|
170
|
-
|
|
171
|
-
|
|
172
|
-
.map(_ => `${' '.repeat(listDepth)}${formatToken(_, listDepth + 1, orderedListNumber, token, highlight)}`)
|
|
173
|
-
.join('');
|
|
174
|
-
case 'paragraph':
|
|
175
|
-
return ((token.tokens ?? [])
|
|
176
|
-
.map(_ => formatToken(_, 0, null, null, highlight))
|
|
177
|
-
.join('') + EOL);
|
|
178
|
-
case 'space':
|
|
179
|
-
return EOL;
|
|
180
|
-
case 'br':
|
|
181
|
-
return EOL;
|
|
182
|
-
case 'text':
|
|
183
|
-
if (parent?.type === 'link') {
|
|
184
|
-
// Already inside a markdown link — the link handler will wrap this
|
|
185
|
-
// in an OSC 8 hyperlink. Linkifying here would nest a second OSC 8
|
|
186
|
-
// sequence, and terminals honor the innermost one, overriding the
|
|
187
|
-
// link's actual href.
|
|
188
|
-
return token.text;
|
|
189
|
-
}
|
|
190
|
-
if (parent?.type === 'list_item') {
|
|
191
|
-
return `${orderedListNumber === null ? '-' : getListNumber(listDepth, orderedListNumber) + '.'} ${token.tokens ? token.tokens.map(_ => formatToken(_, listDepth, orderedListNumber, token, highlight)).join('') : linkifyIssueReferences(token.text)}${EOL}`;
|
|
192
|
-
}
|
|
193
|
-
return linkifyIssueReferences(token.text);
|
|
194
|
-
case 'table': {
|
|
195
|
-
const tableToken = token;
|
|
196
|
-
// Helper function to get the text content that will be displayed (after stripAnsi)
|
|
197
|
-
function getDisplayText(tokens) {
|
|
198
|
-
return stripAnsi(tokens
|
|
199
|
-
?.map(_ => formatToken(_, 0, null, null, highlight))
|
|
200
|
-
.join('') ?? '');
|
|
201
|
-
}
|
|
202
|
-
// Determine column widths based on displayed content (without formatting)
|
|
203
|
-
const columnWidths = tableToken.header.map((header, index) => {
|
|
204
|
-
let maxWidth = stringWidth(getDisplayText(header.tokens));
|
|
205
|
-
for (const row of tableToken.rows) {
|
|
206
|
-
const cellLength = stringWidth(getDisplayText(row[index]?.tokens));
|
|
207
|
-
maxWidth = Math.max(maxWidth, cellLength);
|
|
208
|
-
}
|
|
209
|
-
return Math.max(maxWidth, 3); // Minimum width of 3
|
|
210
|
-
});
|
|
211
|
-
// Format header row
|
|
212
|
-
let tableOutput = '| ';
|
|
213
|
-
tableToken.header.forEach((header, index) => {
|
|
214
|
-
const content = header.tokens
|
|
215
|
-
?.map(_ => formatToken(_, 0, null, null, highlight))
|
|
216
|
-
.join('') ?? '';
|
|
217
|
-
const displayText = getDisplayText(header.tokens);
|
|
218
|
-
const width = columnWidths[index];
|
|
219
|
-
const align = tableToken.align?.[index];
|
|
220
|
-
tableOutput +=
|
|
221
|
-
padAligned(content, stringWidth(displayText), width, align) + ' | ';
|
|
222
|
-
});
|
|
223
|
-
tableOutput = tableOutput.trimEnd() + EOL;
|
|
224
|
-
// Add separator row
|
|
225
|
-
tableOutput += '|';
|
|
226
|
-
columnWidths.forEach((width) => {
|
|
227
|
-
// Always use dashes, don't show alignment colons in the output
|
|
228
|
-
const separator = '-'.repeat(width + 2); // +2 for spaces on each side
|
|
229
|
-
tableOutput += separator + '|';
|
|
230
|
-
});
|
|
231
|
-
tableOutput += EOL;
|
|
232
|
-
// Format data rows
|
|
233
|
-
tableToken.rows.forEach((row) => {
|
|
234
|
-
tableOutput += '| ';
|
|
235
|
-
row.forEach((cell, index) => {
|
|
236
|
-
const content = cell.tokens
|
|
237
|
-
?.map(_ => formatToken(_, 0, null, null, highlight))
|
|
238
|
-
.join('') ?? '';
|
|
239
|
-
const displayText = getDisplayText(cell.tokens);
|
|
240
|
-
const width = columnWidths[index];
|
|
241
|
-
const align = tableToken.align?.[index];
|
|
242
|
-
tableOutput +=
|
|
243
|
-
padAligned(content, stringWidth(displayText), width, align) + ' | ';
|
|
244
|
-
});
|
|
245
|
-
tableOutput = tableOutput.trimEnd() + EOL;
|
|
246
|
-
});
|
|
247
|
-
return tableOutput + EOL;
|
|
187
|
+
else {
|
|
188
|
+
logForDebugging(`Language not supported while highlighting code, falling back to plaintext: ${token.lang}`);
|
|
248
189
|
}
|
|
249
|
-
case 'escape':
|
|
250
|
-
// Markdown escape: \) → ), \\ → \, etc.
|
|
251
|
-
return token.text;
|
|
252
|
-
case 'def':
|
|
253
|
-
case 'del':
|
|
254
|
-
case 'html':
|
|
255
|
-
// These token types are not rendered
|
|
256
|
-
return '';
|
|
257
190
|
}
|
|
258
|
-
return
|
|
191
|
+
return state.highlight.highlight(token.text, { language }) + EOL;
|
|
192
|
+
}
|
|
193
|
+
function renderEmphasis(token, state) {
|
|
194
|
+
const inner = token.tokens.map(child => dispatch(child, inlineChildren(state))).join('');
|
|
195
|
+
return chalk.italic(inner);
|
|
196
|
+
}
|
|
197
|
+
function renderStrong(token, state) {
|
|
198
|
+
const inner = token.tokens.map(child => dispatch(child, inlineChildren(state))).join('');
|
|
199
|
+
return chalk.bold(inner);
|
|
200
|
+
}
|
|
201
|
+
function renderHeading(token, state) {
|
|
202
|
+
const text = token.tokens.map(child => dispatch(child, fresh(state))).join('');
|
|
203
|
+
// H1 gets the full banner treatment; every deeper level shares the bold style.
|
|
204
|
+
const styled = token.depth === 1 ? chalk.bold.italic.underline(text) : chalk.bold(text);
|
|
205
|
+
return styled + EOL + EOL;
|
|
206
|
+
}
|
|
207
|
+
function renderLink(token, state) {
|
|
208
|
+
// mailto: links are shown as plain email addresses, not clickable links.
|
|
209
|
+
if (token.href.startsWith('mailto:')) {
|
|
210
|
+
return token.href.slice('mailto:'.length);
|
|
211
|
+
}
|
|
212
|
+
const label = token.tokens
|
|
213
|
+
.map(child => dispatch(child, withParent(fresh(state), token)))
|
|
214
|
+
.join('');
|
|
215
|
+
const plainLabel = stripAnsi(label);
|
|
216
|
+
// Meaningful display text (different from the URL) becomes a clickable
|
|
217
|
+
// hyperlink; otherwise just show the URL.
|
|
218
|
+
if (plainLabel && plainLabel !== token.href) {
|
|
219
|
+
return createHyperlink(token.href, label);
|
|
220
|
+
}
|
|
221
|
+
return createHyperlink(token.href);
|
|
222
|
+
}
|
|
223
|
+
function renderList(token, state) {
|
|
224
|
+
// ordered lists always carry a numeric start ("" only occurs for unordered),
|
|
225
|
+
// but the type says otherwise, so coerce defensively.
|
|
226
|
+
const start = typeof token.start === 'number' ? token.start : 1;
|
|
227
|
+
return token.items
|
|
228
|
+
.map((item, index) => {
|
|
229
|
+
const ordinal = token.ordered ? start + index : null;
|
|
230
|
+
return dispatch(item, { ...state, ordinal });
|
|
231
|
+
})
|
|
232
|
+
.join('');
|
|
233
|
+
}
|
|
234
|
+
function renderListItem(token, state) {
|
|
235
|
+
const indent = ' '.repeat(state.listDepth);
|
|
236
|
+
const childState = withParent({ ...state, listDepth: state.listDepth + 1 }, token);
|
|
237
|
+
return token.tokens.map(child => indent + dispatch(child, childState)).join('');
|
|
238
|
+
}
|
|
239
|
+
function renderParagraph(token, state) {
|
|
240
|
+
return token.tokens.map(child => dispatch(child, fresh(state))).join('') + EOL;
|
|
241
|
+
}
|
|
242
|
+
function renderText(token, state) {
|
|
243
|
+
const { parent, listDepth, ordinal } = state;
|
|
244
|
+
if (parent?.type === 'link') {
|
|
245
|
+
// Already inside a link: the link handler wraps everything in one OSC 8
|
|
246
|
+
// sequence, and a nested one would override the real href. Stay plain.
|
|
247
|
+
return token.text;
|
|
248
|
+
}
|
|
249
|
+
if (parent?.type === 'list_item') {
|
|
250
|
+
const bullet = ordinal === null ? '-' : `${formatListMarker(listDepth, ordinal)}.`;
|
|
251
|
+
const body = token.tokens
|
|
252
|
+
? token.tokens.map(child => dispatch(child, withParent(state, token))).join('')
|
|
253
|
+
: linkifyIssueReferences(token.text);
|
|
254
|
+
return `${bullet} ${body}${EOL}`;
|
|
255
|
+
}
|
|
256
|
+
return linkifyIssueReferences(token.text);
|
|
257
|
+
}
|
|
258
|
+
function renderTable(token, state) {
|
|
259
|
+
const rows = [token.header, ...token.rows];
|
|
260
|
+
// Column widths derive from the visible (ANSI-stripped) cell text; 3 is
|
|
261
|
+
// the minimum so a separator row always reads as a table divider.
|
|
262
|
+
const columnWidths = token.header.map((_, colIndex) => {
|
|
263
|
+
let widest = 3;
|
|
264
|
+
for (const row of rows) {
|
|
265
|
+
widest = Math.max(widest, stringWidth(cellDisplayText(row[colIndex], state)));
|
|
266
|
+
}
|
|
267
|
+
return widest;
|
|
268
|
+
});
|
|
269
|
+
const headerLine = renderTableRow(token.header, columnWidths, token.align, state);
|
|
270
|
+
// Dashes only — alignment colons are not echoed into the output.
|
|
271
|
+
const divider = `|${columnWidths.map(width => `${'-'.repeat(width + 2)}|`).join('')}${EOL}`;
|
|
272
|
+
const bodyLines = token.rows
|
|
273
|
+
.map(row => renderTableRow(row, columnWidths, token.align, state))
|
|
274
|
+
.join('');
|
|
275
|
+
return headerLine + divider + bodyLines + EOL;
|
|
276
|
+
}
|
|
277
|
+
/** Rendered cell content, stripped of ANSI codes, for width measurement. */
|
|
278
|
+
function cellDisplayText(cell, state) {
|
|
279
|
+
return stripAnsi(cell.tokens.map(child => dispatch(child, fresh(state))).join(''));
|
|
280
|
+
}
|
|
281
|
+
function renderTableRow(cells, columnWidths, aligns, state) {
|
|
282
|
+
let line = '| ';
|
|
283
|
+
cells.forEach((cell, index) => {
|
|
284
|
+
const content = cell.tokens.map(child => dispatch(child, fresh(state))).join('');
|
|
285
|
+
line +=
|
|
286
|
+
padAligned(content, stringWidth(cellDisplayText(cell, state)), columnWidths[index], aligns[index]) + ' | ';
|
|
287
|
+
});
|
|
288
|
+
return line.trimEnd() + EOL;
|
|
259
289
|
}
|
|
260
|
-
// Matches owner/repo#NNN style GitHub issue/PR references. The qualified form
|
|
261
|
-
// is unambiguous — bare #NNN was removed because it guessed the current repo
|
|
262
|
-
// and was wrong whenever the assistant discussed a different one.
|
|
263
|
-
// Owner segment disallows dots (GitHub usernames are alphanumerics + hyphens
|
|
264
|
-
// only) so hostnames like docs.github.io/guide#42 don't false-positive. Repo
|
|
265
|
-
// segment allows dots (e.g. cc.kurs.web). Lookbehind is avoided — it defeats
|
|
266
|
-
// YARR JIT in JSC.
|
|
267
|
-
const ISSUE_REF_PATTERN = /(^|[^\w./-])([A-Za-z0-9][\w-]*\/[A-Za-z0-9][\w.-]*)#(\d+)\b/g;
|
|
268
290
|
/**
|
|
269
|
-
*
|
|
291
|
+
* Replace `owner/repo#123` references with clickable GitHub links.
|
|
292
|
+
* No-op when the terminal lacks OSC 8 hyperlink support.
|
|
270
293
|
*/
|
|
271
294
|
function linkifyIssueReferences(text) {
|
|
272
295
|
if (!supportsHyperlinks()) {
|
|
273
296
|
return text;
|
|
274
297
|
}
|
|
275
|
-
return text.replace(
|
|
276
|
-
createHyperlink(`https://github.com/${repo}/issues/${
|
|
298
|
+
return text.replace(ISSUE_REFERENCE_PATTERN, (_match, prefix, repo, issueNumber) => prefix +
|
|
299
|
+
createHyperlink(`https://github.com/${repo}/issues/${issueNumber}`, `${repo}#${issueNumber}`));
|
|
277
300
|
}
|
|
278
|
-
|
|
279
|
-
|
|
280
|
-
|
|
281
|
-
|
|
282
|
-
|
|
283
|
-
|
|
301
|
+
/**
|
|
302
|
+
* Ordered-list marker for a given nesting depth: decimal at depth 1,
|
|
303
|
+
* letters at depth 2, roman numerals at depth 3, decimal beyond.
|
|
304
|
+
*/
|
|
305
|
+
function formatListMarker(listDepth, ordinal) {
|
|
306
|
+
switch (listDepth) {
|
|
307
|
+
case 2:
|
|
308
|
+
return toAlphaIndex(ordinal);
|
|
309
|
+
case 3:
|
|
310
|
+
return toRomanNumeral(ordinal);
|
|
311
|
+
default:
|
|
312
|
+
return ordinal.toString();
|
|
284
313
|
}
|
|
285
|
-
return result;
|
|
286
314
|
}
|
|
287
|
-
|
|
315
|
+
/** Bijective base-26 conversion: 1 → a, 26 → z, 27 → aa. */
|
|
316
|
+
function toAlphaIndex(n) {
|
|
317
|
+
if (n <= 0)
|
|
318
|
+
return '';
|
|
319
|
+
const digit = String.fromCharCode(97 + ((n - 1) % 26));
|
|
320
|
+
return toAlphaIndex(Math.floor((n - 1) / 26)) + digit;
|
|
321
|
+
}
|
|
322
|
+
/** Standard greedy roman-numeral symbol table (lowercase). */
|
|
323
|
+
const ROMAN_SYMBOLS = [
|
|
288
324
|
[1000, 'm'],
|
|
289
325
|
[900, 'cm'],
|
|
290
326
|
[500, 'd'],
|
|
@@ -299,33 +335,20 @@ const ROMAN_VALUES = [
|
|
|
299
335
|
[4, 'iv'],
|
|
300
336
|
[1, 'i'],
|
|
301
337
|
];
|
|
302
|
-
function
|
|
303
|
-
let
|
|
304
|
-
for (const [value,
|
|
338
|
+
function toRomanNumeral(n) {
|
|
339
|
+
let out = '';
|
|
340
|
+
for (const [value, glyph] of ROMAN_SYMBOLS) {
|
|
305
341
|
while (n >= value) {
|
|
306
|
-
|
|
342
|
+
out += glyph;
|
|
307
343
|
n -= value;
|
|
308
344
|
}
|
|
309
345
|
}
|
|
310
|
-
return
|
|
311
|
-
}
|
|
312
|
-
function getListNumber(listDepth, orderedListNumber) {
|
|
313
|
-
switch (listDepth) {
|
|
314
|
-
case 0:
|
|
315
|
-
case 1:
|
|
316
|
-
return orderedListNumber.toString();
|
|
317
|
-
case 2:
|
|
318
|
-
return numberToLetter(orderedListNumber);
|
|
319
|
-
case 3:
|
|
320
|
-
return numberToRoman(orderedListNumber);
|
|
321
|
-
default:
|
|
322
|
-
return orderedListNumber.toString();
|
|
323
|
-
}
|
|
346
|
+
return out;
|
|
324
347
|
}
|
|
325
348
|
/**
|
|
326
|
-
* Pad `content` to `targetWidth` according to alignment. `displayWidth` is
|
|
327
|
-
* visible width of `content` (
|
|
328
|
-
*
|
|
349
|
+
* Pad `content` to `targetWidth` according to alignment. `displayWidth` is
|
|
350
|
+
* the visible width of `content` (callers compute it via stringWidth on the
|
|
351
|
+
* ANSI-stripped text, so embedded escape codes don't affect padding).
|
|
329
352
|
* @param content - The text to pad, which may carry ANSI codes.
|
|
330
353
|
* @param displayWidth - Visible width of `content` without ANSI codes.
|
|
331
354
|
* @param targetWidth - Column width to pad `content` to.
|
|
@@ -333,13 +356,13 @@ function getListNumber(listDepth, orderedListNumber) {
|
|
|
333
356
|
* @returns `content` padded with spaces to `targetWidth`.
|
|
334
357
|
*/
|
|
335
358
|
export function padAligned(content, displayWidth, targetWidth, align) {
|
|
336
|
-
const
|
|
359
|
+
const extra = Math.max(0, targetWidth - displayWidth);
|
|
337
360
|
if (align === 'center') {
|
|
338
|
-
const
|
|
339
|
-
return ' '.repeat(
|
|
361
|
+
const left = Math.floor(extra / 2);
|
|
362
|
+
return ' '.repeat(left) + content + ' '.repeat(extra - left);
|
|
340
363
|
}
|
|
341
364
|
if (align === 'right') {
|
|
342
|
-
return ' '.repeat(
|
|
365
|
+
return ' '.repeat(extra) + content;
|
|
343
366
|
}
|
|
344
|
-
return content + ' '.repeat(
|
|
367
|
+
return content + ' '.repeat(extra);
|
|
345
368
|
}
|
|
@@ -1,15 +1,18 @@
|
|
|
1
|
-
/**
|
|
1
|
+
/**
|
|
2
|
+
* The `(ctrl+o to expand)` hint, dimmed.
|
|
2
3
|
* @returns The dim hint text.
|
|
3
4
|
*/
|
|
4
5
|
export declare function ctrlOToExpand(): string;
|
|
5
6
|
/**
|
|
6
|
-
*
|
|
7
|
-
*
|
|
8
|
-
*
|
|
7
|
+
* Render `content` with line-based truncation for terminal display.
|
|
8
|
+
* Content that fits in the visible budget is returned unchanged (modulo
|
|
9
|
+
* trailing whitespace); longer content is folded with an overflow hint.
|
|
9
10
|
* @param content - Text to render; trailing whitespace is trimmed.
|
|
10
|
-
* @param terminalWidth - Terminal width in columns; the wrap width reserves
|
|
11
|
-
*
|
|
12
|
-
* @
|
|
11
|
+
* @param terminalWidth - Terminal width in columns; the wrap width reserves
|
|
12
|
+
* 4 columns of padding.
|
|
13
|
+
* @param suppressExpandHint - When true, omit the `(ctrl+o to expand)`
|
|
14
|
+
* suffix from the overflow hint.
|
|
15
|
+
* @returns The truncated text, or `''` when `content` is blank after trimming.
|
|
13
16
|
*/
|
|
14
17
|
export declare function renderTruncatedContent(content: string, terminalWidth: number, suppressExpandHint?: boolean): string;
|
|
15
18
|
//# sourceMappingURL=terminal.d.ts.map
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"terminal.d.ts","sourceRoot":"","sources":["../../../src/cc/terminal.ts"],"names":[],"mappings":"
|
|
1
|
+
{"version":3,"file":"terminal.d.ts","sourceRoot":"","sources":["../../../src/cc/terminal.ts"],"names":[],"mappings":"AA+DA;;;GAGG;AACH,wBAAgB,aAAa,IAAI,MAAM,CAEtC;AAED;;;;;;;;;;GAUG;AACH,wBAAgB,sBAAsB,CACpC,OAAO,EAAE,MAAM,EACf,aAAa,EAAE,MAAM,EACrB,kBAAkB,UAAQ,GACzB,MAAM,CAuCR"}
|