nastech-tui 0.0.1
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/.prettierrc +11 -0
- package/README.md +346 -0
- package/eslint.config.mjs +111 -0
- package/package.json +51 -0
- package/packages/nastech-ink/ambient.d.ts +83 -0
- package/packages/nastech-ink/index.d.ts +40 -0
- package/packages/nastech-ink/index.js +1 -0
- package/packages/nastech-ink/nastech-ink/ambient.d.ts +83 -0
- package/packages/nastech-ink/nastech-ink/index.d.ts +40 -0
- package/packages/nastech-ink/nastech-ink/index.js +1 -0
- package/packages/nastech-ink/nastech-ink/package.json +54 -0
- package/packages/nastech-ink/nastech-ink/src/bootstrap/state.ts +9 -0
- package/packages/nastech-ink/nastech-ink/src/entry-exports.ts +32 -0
- package/packages/nastech-ink/nastech-ink/src/hooks/use-stderr.ts +15 -0
- package/packages/nastech-ink/nastech-ink/src/hooks/use-stdout.ts +15 -0
- package/packages/nastech-ink/nastech-ink/src/ink/Ansi.tsx +435 -0
- package/packages/nastech-ink/nastech-ink/src/ink/app-mouse.test.ts +123 -0
- package/packages/nastech-ink/nastech-ink/src/ink/bidi.ts +145 -0
- package/packages/nastech-ink/nastech-ink/src/ink/cache-eviction.ts +45 -0
- package/packages/nastech-ink/nastech-ink/src/ink/clearTerminal.ts +68 -0
- package/packages/nastech-ink/nastech-ink/src/ink/colorize.test.ts +60 -0
- package/packages/nastech-ink/nastech-ink/src/ink/colorize.ts +277 -0
- package/packages/nastech-ink/nastech-ink/src/ink/components/AlternateScreen.tsx +133 -0
- package/packages/nastech-ink/nastech-ink/src/ink/components/App.tsx +830 -0
- package/packages/nastech-ink/nastech-ink/src/ink/components/AppContext.ts +20 -0
- package/packages/nastech-ink/nastech-ink/src/ink/components/Box.tsx +294 -0
- package/packages/nastech-ink/nastech-ink/src/ink/components/Button.tsx +236 -0
- package/packages/nastech-ink/nastech-ink/src/ink/components/ClockContext.tsx +133 -0
- package/packages/nastech-ink/nastech-ink/src/ink/components/CursorAdvanceContext.ts +35 -0
- package/packages/nastech-ink/nastech-ink/src/ink/components/CursorDeclarationContext.ts +28 -0
- package/packages/nastech-ink/nastech-ink/src/ink/components/ErrorOverview.tsx +130 -0
- package/packages/nastech-ink/nastech-ink/src/ink/components/Link.tsx +38 -0
- package/packages/nastech-ink/nastech-ink/src/ink/components/Newline.tsx +43 -0
- package/packages/nastech-ink/nastech-ink/src/ink/components/NoSelect.tsx +73 -0
- package/packages/nastech-ink/nastech-ink/src/ink/components/RawAnsi.tsx +61 -0
- package/packages/nastech-ink/nastech-ink/src/ink/components/ScrollBox.tsx +290 -0
- package/packages/nastech-ink/nastech-ink/src/ink/components/Spacer.tsx +23 -0
- package/packages/nastech-ink/nastech-ink/src/ink/components/StdinContext.ts +25 -0
- package/packages/nastech-ink/nastech-ink/src/ink/components/TerminalFocusContext.tsx +63 -0
- package/packages/nastech-ink/nastech-ink/src/ink/components/TerminalSizeContext.tsx +7 -0
- package/packages/nastech-ink/nastech-ink/src/ink/components/Text.test.ts +38 -0
- package/packages/nastech-ink/nastech-ink/src/ink/components/Text.tsx +336 -0
- package/packages/nastech-ink/nastech-ink/src/ink/constants.ts +6 -0
- package/packages/nastech-ink/nastech-ink/src/ink/cursor.ts +5 -0
- package/packages/nastech-ink/nastech-ink/src/ink/devtools.ts +2 -0
- package/packages/nastech-ink/nastech-ink/src/ink/dom.ts +495 -0
- package/packages/nastech-ink/nastech-ink/src/ink/events/click-event.ts +38 -0
- package/packages/nastech-ink/nastech-ink/src/ink/events/cmd-shortcuts.test.ts +65 -0
- package/packages/nastech-ink/nastech-ink/src/ink/events/dispatcher.ts +242 -0
- package/packages/nastech-ink/nastech-ink/src/ink/events/emitter.ts +40 -0
- package/packages/nastech-ink/nastech-ink/src/ink/events/event-handlers.ts +84 -0
- package/packages/nastech-ink/nastech-ink/src/ink/events/event.ts +11 -0
- package/packages/nastech-ink/nastech-ink/src/ink/events/focus-event.ts +18 -0
- package/packages/nastech-ink/nastech-ink/src/ink/events/input-event.ts +176 -0
- package/packages/nastech-ink/nastech-ink/src/ink/events/keyboard-event.ts +57 -0
- package/packages/nastech-ink/nastech-ink/src/ink/events/mouse-event.ts +18 -0
- package/packages/nastech-ink/nastech-ink/src/ink/events/paste-event.ts +10 -0
- package/packages/nastech-ink/nastech-ink/src/ink/events/resize-event.ts +12 -0
- package/packages/nastech-ink/nastech-ink/src/ink/events/terminal-event.ts +107 -0
- package/packages/nastech-ink/nastech-ink/src/ink/events/terminal-focus-event.ts +19 -0
- package/packages/nastech-ink/nastech-ink/src/ink/focus.ts +219 -0
- package/packages/nastech-ink/nastech-ink/src/ink/frame.ts +124 -0
- package/packages/nastech-ink/nastech-ink/src/ink/get-max-width.ts +27 -0
- package/packages/nastech-ink/nastech-ink/src/ink/global.d.ts +1 -0
- package/packages/nastech-ink/nastech-ink/src/ink/hit-test.test.ts +38 -0
- package/packages/nastech-ink/nastech-ink/src/ink/hit-test.ts +224 -0
- package/packages/nastech-ink/nastech-ink/src/ink/hooks/use-animation-frame.ts +62 -0
- package/packages/nastech-ink/nastech-ink/src/ink/hooks/use-app.ts +9 -0
- package/packages/nastech-ink/nastech-ink/src/ink/hooks/use-cursor-advance.ts +33 -0
- package/packages/nastech-ink/nastech-ink/src/ink/hooks/use-declared-cursor.ts +75 -0
- package/packages/nastech-ink/nastech-ink/src/ink/hooks/use-external-process.ts +27 -0
- package/packages/nastech-ink/nastech-ink/src/ink/hooks/use-input.ts +95 -0
- package/packages/nastech-ink/nastech-ink/src/ink/hooks/use-interval.ts +71 -0
- package/packages/nastech-ink/package.json +57 -0
- package/packages/nastech-ink/src/bootstrap/state.ts +9 -0
- package/packages/nastech-ink/src/entry-exports.ts +32 -0
- package/packages/nastech-ink/src/hooks/use-stderr.ts +15 -0
- package/packages/nastech-ink/src/hooks/use-stdout.ts +15 -0
- package/packages/nastech-ink/src/ink/Ansi.tsx +435 -0
- package/packages/nastech-ink/src/ink/app-mouse.test.ts +123 -0
- package/packages/nastech-ink/src/ink/app-rawmode-mouse.test.ts +91 -0
- package/packages/nastech-ink/src/ink/bidi.ts +145 -0
- package/packages/nastech-ink/src/ink/cache-eviction.ts +45 -0
- package/packages/nastech-ink/src/ink/clearTerminal.ts +68 -0
- package/packages/nastech-ink/src/ink/colorize.test.ts +60 -0
- package/packages/nastech-ink/src/ink/colorize.ts +277 -0
- package/packages/nastech-ink/src/ink/components/AlternateScreen.tsx +133 -0
- package/packages/nastech-ink/src/ink/components/App.tsx +855 -0
- package/packages/nastech-ink/src/ink/components/AppContext.ts +20 -0
- package/packages/nastech-ink/src/ink/components/Box.tsx +294 -0
- package/packages/nastech-ink/src/ink/components/Button.tsx +236 -0
- package/packages/nastech-ink/src/ink/components/ClockContext.tsx +133 -0
- package/packages/nastech-ink/src/ink/components/CursorAdvanceContext.ts +35 -0
- package/packages/nastech-ink/src/ink/components/CursorDeclarationContext.ts +28 -0
- package/packages/nastech-ink/src/ink/components/ErrorOverview.tsx +130 -0
- package/packages/nastech-ink/src/ink/components/Link.tsx +38 -0
- package/packages/nastech-ink/src/ink/components/Newline.tsx +43 -0
- package/packages/nastech-ink/src/ink/components/NoSelect.tsx +73 -0
- package/packages/nastech-ink/src/ink/components/RawAnsi.tsx +61 -0
- package/packages/nastech-ink/src/ink/components/ScrollBox.tsx +290 -0
- package/packages/nastech-ink/src/ink/components/Spacer.tsx +23 -0
- package/packages/nastech-ink/src/ink/components/StdinContext.ts +25 -0
- package/packages/nastech-ink/src/ink/components/TerminalFocusContext.tsx +63 -0
- package/packages/nastech-ink/src/ink/components/TerminalSizeContext.tsx +7 -0
- package/packages/nastech-ink/src/ink/components/Text.test.ts +38 -0
- package/packages/nastech-ink/src/ink/components/Text.tsx +336 -0
- package/packages/nastech-ink/src/ink/constants.ts +6 -0
- package/packages/nastech-ink/src/ink/cursor.ts +5 -0
- package/packages/nastech-ink/src/ink/devtools.ts +2 -0
- package/packages/nastech-ink/src/ink/dom.ts +495 -0
- package/packages/nastech-ink/src/ink/events/click-event.ts +38 -0
- package/packages/nastech-ink/src/ink/events/cmd-shortcuts.test.ts +65 -0
- package/packages/nastech-ink/src/ink/events/dispatcher.ts +242 -0
- package/packages/nastech-ink/src/ink/events/emitter.ts +40 -0
- package/packages/nastech-ink/src/ink/events/event-handlers.ts +84 -0
- package/packages/nastech-ink/src/ink/events/event.ts +11 -0
- package/packages/nastech-ink/src/ink/events/focus-event.ts +18 -0
- package/packages/nastech-ink/src/ink/events/input-event.ts +176 -0
- package/packages/nastech-ink/src/ink/events/keyboard-event.ts +57 -0
- package/packages/nastech-ink/src/ink/events/mouse-event.ts +18 -0
- package/packages/nastech-ink/src/ink/events/paste-event.ts +10 -0
- package/packages/nastech-ink/src/ink/events/resize-event.ts +12 -0
- package/packages/nastech-ink/src/ink/events/terminal-event.ts +107 -0
- package/packages/nastech-ink/src/ink/events/terminal-focus-event.ts +19 -0
- package/packages/nastech-ink/src/ink/focus.ts +219 -0
- package/packages/nastech-ink/src/ink/frame.ts +124 -0
- package/packages/nastech-ink/src/ink/get-max-width.ts +27 -0
- package/packages/nastech-ink/src/ink/global.d.ts +1 -0
- package/packages/nastech-ink/src/ink/hit-test.test.ts +38 -0
- package/packages/nastech-ink/src/ink/hit-test.ts +224 -0
- package/packages/nastech-ink/src/ink/hooks/use-animation-frame.ts +62 -0
- package/packages/nastech-ink/src/ink/hooks/use-app.ts +9 -0
- package/packages/nastech-ink/src/ink/hooks/use-cursor-advance.ts +33 -0
- package/packages/nastech-ink/src/ink/hooks/use-declared-cursor.ts +75 -0
- package/packages/nastech-ink/src/ink/hooks/use-external-process.ts +27 -0
- package/packages/nastech-ink/src/ink/hooks/use-input.ts +95 -0
- package/packages/nastech-ink/src/ink/hooks/use-interval.ts +71 -0
- package/packages/nastech-ink/src/ink/hooks/use-search-highlight.ts +56 -0
- package/packages/nastech-ink/src/ink/hooks/use-selection.ts +101 -0
- package/packages/nastech-ink/src/ink/hooks/use-stdin.ts +9 -0
- package/packages/nastech-ink/src/ink/hooks/use-tab-status.ts +71 -0
- package/packages/nastech-ink/src/ink/hooks/use-terminal-focus.ts +18 -0
- package/packages/nastech-ink/src/ink/hooks/use-terminal-title.ts +34 -0
- package/packages/nastech-ink/src/ink/hooks/use-terminal-viewport.ts +100 -0
- package/packages/nastech-ink/src/ink/hyperlinkHover.ts +52 -0
- package/packages/nastech-ink/src/ink/ink-cursor-advance.test.ts +234 -0
- package/packages/nastech-ink/src/ink/ink-resize.test.ts +50 -0
- package/packages/nastech-ink/src/ink/ink.tsx +2705 -0
- package/packages/nastech-ink/src/ink/instances.ts +10 -0
- package/packages/nastech-ink/src/ink/layout/engine.ts +6 -0
- package/packages/nastech-ink/src/ink/layout/geometry.ts +98 -0
- package/packages/nastech-ink/src/ink/layout/node.ts +145 -0
- package/packages/nastech-ink/src/ink/layout/yoga.ts +313 -0
- package/packages/nastech-ink/src/ink/line-width-cache.ts +38 -0
- package/packages/nastech-ink/src/ink/log-update.test.ts +223 -0
- package/packages/nastech-ink/src/ink/log-update.ts +752 -0
- package/packages/nastech-ink/src/ink/lru.ts +14 -0
- package/packages/nastech-ink/src/ink/measure-element.ts +23 -0
- package/packages/nastech-ink/src/ink/measure-text.ts +50 -0
- package/packages/nastech-ink/src/ink/node-cache.ts +53 -0
- package/packages/nastech-ink/src/ink/optimizer.ts +99 -0
- package/packages/nastech-ink/src/ink/output.ts +845 -0
- package/packages/nastech-ink/src/ink/parse-keypress.test.ts +133 -0
- package/packages/nastech-ink/src/ink/parse-keypress.ts +848 -0
- package/packages/nastech-ink/src/ink/reconciler.ts +382 -0
- package/packages/nastech-ink/src/ink/render-border.ts +206 -0
- package/packages/nastech-ink/src/ink/render-node-to-output.ts +1582 -0
- package/packages/nastech-ink/src/ink/render-to-screen.ts +236 -0
- package/packages/nastech-ink/src/ink/renderer.ts +169 -0
- package/packages/nastech-ink/src/ink/root.ts +204 -0
- package/packages/nastech-ink/src/ink/screen.ts +1590 -0
- package/packages/nastech-ink/src/ink/searchHighlight.ts +91 -0
- package/packages/nastech-ink/src/ink/selection.test.ts +82 -0
- package/packages/nastech-ink/src/ink/selection.ts +1143 -0
- package/packages/nastech-ink/src/ink/squash-text-nodes.ts +74 -0
- package/packages/nastech-ink/src/ink/stringWidth.ts +341 -0
- package/packages/nastech-ink/src/ink/styles.ts +750 -0
- package/packages/nastech-ink/src/ink/supports-hyperlinks.ts +51 -0
- package/packages/nastech-ink/src/ink/tabstops.ts +44 -0
- package/packages/nastech-ink/src/ink/terminal-focus-state.ts +52 -0
- package/packages/nastech-ink/src/ink/terminal-querier.ts +222 -0
- package/packages/nastech-ink/src/ink/terminal.test.ts +15 -0
- package/packages/nastech-ink/src/ink/terminal.ts +299 -0
- package/packages/nastech-ink/src/ink/termio/ansi.ts +75 -0
- package/packages/nastech-ink/src/ink/termio/csi.ts +334 -0
- package/packages/nastech-ink/src/ink/termio/dec.ts +99 -0
- package/packages/nastech-ink/src/ink/termio/esc.ts +69 -0
- package/packages/nastech-ink/src/ink/termio/osc.test.ts +191 -0
- package/packages/nastech-ink/src/ink/termio/osc.ts +724 -0
- package/packages/nastech-ink/src/ink/termio/parser.ts +467 -0
- package/packages/nastech-ink/src/ink/termio/sgr.ts +362 -0
- package/packages/nastech-ink/src/ink/termio/tokenize.test.ts +185 -0
- package/packages/nastech-ink/src/ink/termio/tokenize.ts +350 -0
- package/packages/nastech-ink/src/ink/termio/types.ts +230 -0
- package/packages/nastech-ink/src/ink/termio.ts +42 -0
- package/packages/nastech-ink/src/ink/useTerminalNotification.ts +110 -0
- package/packages/nastech-ink/src/ink/warn.ts +15 -0
- package/packages/nastech-ink/src/ink/widest-line.ts +22 -0
- package/packages/nastech-ink/src/ink/wrap-text.test.ts +17 -0
- package/packages/nastech-ink/src/ink/wrap-text.ts +144 -0
- package/packages/nastech-ink/src/ink/wrapAnsi.ts +13 -0
- package/packages/nastech-ink/src/native-ts/yoga-layout/enums.ts +112 -0
- package/packages/nastech-ink/src/native-ts/yoga-layout/index.ts +2326 -0
- package/packages/nastech-ink/src/utils/debug.ts +6 -0
- package/packages/nastech-ink/src/utils/earlyInput.ts +131 -0
- package/packages/nastech-ink/src/utils/env.ts +66 -0
- package/packages/nastech-ink/src/utils/envUtils.ts +13 -0
- package/packages/nastech-ink/src/utils/execFileNoThrow.test.ts +146 -0
- package/packages/nastech-ink/src/utils/execFileNoThrow.ts +115 -0
- package/packages/nastech-ink/src/utils/fullscreen.ts +3 -0
- package/packages/nastech-ink/src/utils/intl.ts +87 -0
- package/packages/nastech-ink/src/utils/log.ts +7 -0
- package/packages/nastech-ink/src/utils/semver.ts +57 -0
- package/packages/nastech-ink/src/utils/sliceAnsi.ts +106 -0
- package/packages/nastech-ink/text-input.d.ts +2 -0
- package/packages/nastech-ink/text-input.js +1 -0
- package/scripts/build.mjs +61 -0
- package/scripts/profile-tui.mjs +121 -0
- package/src/__tests__/activeSessionSwitcher.test.ts +157 -0
- package/src/__tests__/appChromeStatusRule.test.tsx +84 -0
- package/src/__tests__/appChromeStatusRuleDevCredits.test.tsx +73 -0
- package/src/__tests__/approvalAction.test.ts +50 -0
- package/src/__tests__/asCommandDispatch.test.ts +27 -0
- package/src/__tests__/blockLayout.test.ts +122 -0
- package/src/__tests__/clipboard.test.ts +369 -0
- package/src/__tests__/constants.test.ts +53 -0
- package/src/__tests__/createGatewayEventHandler.test.ts +1091 -0
- package/src/__tests__/createSlashHandler.test.ts +822 -0
- package/src/__tests__/creditsCommand.test.ts +144 -0
- package/src/__tests__/cursorDriftRegression.test.ts +114 -0
- package/src/__tests__/details.test.ts +115 -0
- package/src/__tests__/emoji.test.ts +64 -0
- package/src/__tests__/externalLink.test.ts +144 -0
- package/src/__tests__/forceTruecolor.test.ts +191 -0
- package/src/__tests__/gatewayClient.test.ts +394 -0
- package/src/__tests__/gatewayRecovery.test.ts +47 -0
- package/src/__tests__/markdown.test.ts +331 -0
- package/src/__tests__/mathUnicode.test.ts +293 -0
- package/src/__tests__/memoryMonitor.test.ts +102 -0
- package/src/__tests__/messageLine.test.ts +19 -0
- package/src/__tests__/messages.test.ts +92 -0
- package/src/__tests__/orchestratorPromptSession.test.ts +64 -0
- package/src/__tests__/osc52.test.ts +67 -0
- package/src/__tests__/parentLog.test.ts +75 -0
- package/src/__tests__/paths.test.ts +70 -0
- package/src/__tests__/platform.test.ts +556 -0
- package/src/__tests__/precisionWheel.test.ts +44 -0
- package/src/__tests__/prompt.test.ts +31 -0
- package/src/__tests__/providers.test.ts +65 -0
- package/src/__tests__/reasoning.test.ts +76 -0
- package/src/__tests__/rpc.test.ts +27 -0
- package/src/__tests__/scroll.test.ts +99 -0
- package/src/__tests__/slashParity.test.ts +123 -0
- package/src/__tests__/spawnHistoryStore.test.ts +46 -0
- package/src/__tests__/stateIsolation.test.ts +46 -0
- package/src/__tests__/statusBarTicker.test.ts +18 -0
- package/src/__tests__/statusRule.test.ts +32 -0
- package/src/__tests__/streamingMarkdown.test.ts +121 -0
- package/src/__tests__/subagentTree.test.ts +407 -0
- package/src/__tests__/syntax.test.ts +45 -0
- package/src/__tests__/terminalModes.test.ts +39 -0
- package/src/__tests__/terminalParity.test.ts +77 -0
- package/src/__tests__/terminalSetup.test.ts +386 -0
- package/src/__tests__/termux.test.ts +35 -0
- package/src/__tests__/termuxComposerLayout.test.ts +40 -0
- package/src/__tests__/text.test.ts +233 -0
- package/src/__tests__/textInputBurstInput.test.ts +40 -0
- package/src/__tests__/textInputCursorSourceOfTruth.test.ts +50 -0
- package/src/__tests__/textInputFastEcho.test.ts +200 -0
- package/src/__tests__/textInputLineNav.test.ts +55 -0
- package/src/__tests__/textInputPassThrough.test.ts +59 -0
- package/src/__tests__/textInputRightClick.test.ts +48 -0
- package/src/__tests__/textInputWrap.test.ts +151 -0
- package/src/__tests__/theme.test.ts +311 -0
- package/src/__tests__/turnControllerNotice.test.ts +43 -0
- package/src/__tests__/turnStore.test.ts +66 -0
- package/src/__tests__/useCompletion.test.ts +35 -0
- package/src/__tests__/useComposerState.test.ts +59 -0
- package/src/__tests__/useConfigSync.test.ts +460 -0
- package/src/__tests__/useInputHandlers.test.ts +77 -0
- package/src/__tests__/useQueue.test.ts +28 -0
- package/src/__tests__/useSessionLifecycle.test.ts +60 -0
- package/src/__tests__/useVirtualHistoryHeights.test.ts +39 -0
- package/src/__tests__/viewport.test.ts +58 -0
- package/src/__tests__/viewportStore.test.ts +85 -0
- package/src/__tests__/virtualHeights.test.ts +96 -0
- package/src/__tests__/virtualHistoryClamp.test.ts +19 -0
- package/src/__tests__/virtualHistoryOffsetCache.test.ts +282 -0
- package/src/__tests__/wheelAccel.test.ts +138 -0
- package/src/app/createGatewayEventHandler.ts +833 -0
- package/src/app/createSlashHandler.ts +130 -0
- package/src/app/delegationStore.ts +77 -0
- package/src/app/gatewayContext.tsx +19 -0
- package/src/app/gatewayRecovery.ts +35 -0
- package/src/app/inputSelectionStore.ts +15 -0
- package/src/app/interfaces.ts +394 -0
- package/src/app/overlayStore.ts +53 -0
- package/src/app/scroll.ts +71 -0
- package/src/app/setupHandoff.ts +54 -0
- package/src/app/slash/commands/core.ts +648 -0
- package/src/app/slash/commands/credits.ts +57 -0
- package/src/app/slash/commands/debug.ts +48 -0
- package/src/app/slash/commands/ops.ts +717 -0
- package/src/app/slash/commands/session.ts +554 -0
- package/src/app/slash/commands/setup.ts +20 -0
- package/src/app/slash/registry.ts +20 -0
- package/src/app/slash/types.ts +21 -0
- package/src/app/spawnHistoryStore.ts +159 -0
- package/src/app/turnController.ts +866 -0
- package/src/app/turnStore.ts +85 -0
- package/src/app/uiStore.ts +44 -0
- package/src/app/useComposerState.ts +367 -0
- package/src/app/useConfigSync.ts +288 -0
- package/src/app/useInputHandlers.ts +576 -0
- package/src/app/useLongRunToolCharms.ts +69 -0
- package/src/app/useMainApp.ts +1039 -0
- package/src/app/useSessionLifecycle.ts +366 -0
- package/src/app/useSubmission.ts +429 -0
- package/src/app.tsx +25 -0
- package/src/banner.ts +93 -0
- package/src/components/activeSessionSwitcher.tsx +635 -0
- package/src/components/agentsOverlay.tsx +1073 -0
- package/src/components/appChrome.tsx +554 -0
- package/src/components/appLayout.tsx +444 -0
- package/src/components/appOverlays.tsx +254 -0
- package/src/components/branding.tsx +466 -0
- package/src/components/fpsOverlay.tsx +30 -0
- package/src/components/helpHint.tsx +73 -0
- package/src/components/markdown.tsx +1119 -0
- package/src/components/maskedPrompt.tsx +34 -0
- package/src/components/messageLine.tsx +237 -0
- package/src/components/modelPicker.tsx +527 -0
- package/src/components/overlayControls.tsx +50 -0
- package/src/components/pluginsHub.tsx +238 -0
- package/src/components/prompts.tsx +276 -0
- package/src/components/queuedMessages.tsx +64 -0
- package/src/components/sessionPicker.tsx +227 -0
- package/src/components/skillsHub.tsx +308 -0
- package/src/components/streamingAssistant.tsx +110 -0
- package/src/components/streamingMarkdown.tsx +174 -0
- package/src/components/textInput.tsx +1340 -0
- package/src/components/themed.tsx +30 -0
- package/src/components/thinking.tsx +1224 -0
- package/src/components/todoPanel.tsx +93 -0
- package/src/config/env.ts +64 -0
- package/src/config/limits.ts +13 -0
- package/src/config/timing.ts +6 -0
- package/src/content/charms.ts +1 -0
- package/src/content/faces.ts +17 -0
- package/src/content/fortunes.ts +30 -0
- package/src/content/hotkeys.ts +37 -0
- package/src/content/placeholders.ts +13 -0
- package/src/content/setup.ts +17 -0
- package/src/content/verbs.ts +38 -0
- package/src/domain/blockLayout.ts +146 -0
- package/src/domain/details.ts +76 -0
- package/src/domain/messages.ts +91 -0
- package/src/domain/paths.ts +16 -0
- package/src/domain/providers.ts +11 -0
- package/src/domain/roles.ts +9 -0
- package/src/domain/slash.ts +10 -0
- package/src/domain/usage.ts +3 -0
- package/src/domain/viewport.ts +51 -0
- package/src/entry.tsx +104 -0
- package/src/gatewayClient.ts +730 -0
- package/src/gatewayTypes.ts +568 -0
- package/src/hooks/useCompletion.ts +112 -0
- package/src/hooks/useGitBranch.ts +72 -0
- package/src/hooks/useInputHistory.ts +11 -0
- package/src/hooks/useQueue.ts +76 -0
- package/src/hooks/useVirtualHistory.ts +554 -0
- package/src/lib/circularBuffer.ts +48 -0
- package/src/lib/clipboard.ts +182 -0
- package/src/lib/editor.test.ts +74 -0
- package/src/lib/editor.ts +47 -0
- package/src/lib/emoji.ts +55 -0
- package/src/lib/externalCli.ts +16 -0
- package/src/lib/externalLink.ts +435 -0
- package/src/lib/forceTruecolor.ts +60 -0
- package/src/lib/fpsStore.ts +51 -0
- package/src/lib/fuzzy.test.ts +109 -0
- package/src/lib/fuzzy.ts +177 -0
- package/src/lib/gracefulExit.ts +47 -0
- package/src/lib/history.ts +82 -0
- package/src/lib/inputMetrics.ts +203 -0
- package/src/lib/liveProgress.test.ts +116 -0
- package/src/lib/liveProgress.ts +79 -0
- package/src/lib/mathUnicode.ts +770 -0
- package/src/lib/memory.test.ts +155 -0
- package/src/lib/memory.ts +188 -0
- package/src/lib/memoryMonitor.ts +109 -0
- package/src/lib/messages.test.ts +29 -0
- package/src/lib/messages.ts +8 -0
- package/src/lib/openExternalUrl.test.ts +217 -0
- package/src/lib/openExternalUrl.ts +158 -0
- package/src/lib/osc52.ts +73 -0
- package/src/lib/parentLog.ts +57 -0
- package/src/lib/perfPane.tsx +107 -0
- package/src/lib/platform.ts +409 -0
- package/src/lib/precisionWheel.ts +48 -0
- package/src/lib/prompt.ts +35 -0
- package/src/lib/reasoning.ts +55 -0
- package/src/lib/rpc.ts +41 -0
- package/src/lib/subagentTree.ts +355 -0
- package/src/lib/syntax.ts +117 -0
- package/src/lib/terminalModes.ts +51 -0
- package/src/lib/terminalParity.ts +78 -0
- package/src/lib/terminalSetup.ts +444 -0
- package/src/lib/termux.ts +29 -0
- package/src/lib/text.test.ts +18 -0
- package/src/lib/text.ts +339 -0
- package/src/lib/todo.test.ts +21 -0
- package/src/lib/todo.ts +9 -0
- package/src/lib/viewportStore.ts +124 -0
- package/src/lib/virtualHeights.ts +145 -0
- package/src/lib/wheelAccel.ts +190 -0
- package/src/protocol/interpolation.ts +3 -0
- package/src/protocol/paste.ts +1 -0
- package/src/theme.ts +589 -0
- package/src/types/nastech-ink.d.ts +176 -0
- package/src/types.ts +212 -0
- package/tsconfig.build.json +9 -0
- package/tsconfig.json +19 -0
- package/vitest.config.ts +7 -0
|
@@ -0,0 +1,648 @@
|
|
|
1
|
+
import { forceRedraw, type MouseTrackingMode } from '@nastechai/ink'
|
|
2
|
+
|
|
3
|
+
import { NO_CONFIRM_DESTRUCTIVE } from '../../../config/env.js'
|
|
4
|
+
import { dailyFortune, randomFortune } from '../../../content/fortunes.js'
|
|
5
|
+
import { HOTKEYS } from '../../../content/hotkeys.js'
|
|
6
|
+
import { isSectionName, nextDetailsMode, parseDetailsMode, SECTION_NAMES } from '../../../domain/details.js'
|
|
7
|
+
import type {
|
|
8
|
+
ConfigGetValueResponse,
|
|
9
|
+
ConfigSetResponse,
|
|
10
|
+
SessionSaveResponse,
|
|
11
|
+
SessionStatusResponse,
|
|
12
|
+
SessionSteerResponse,
|
|
13
|
+
SessionTitleResponse,
|
|
14
|
+
SessionUndoResponse
|
|
15
|
+
} from '../../../gatewayTypes.js'
|
|
16
|
+
import { writeClipboardText } from '../../../lib/clipboard.js'
|
|
17
|
+
import { writeOsc52Clipboard } from '../../../lib/osc52.js'
|
|
18
|
+
import { configureDetectedTerminalKeybindings, configureTerminalKeybindings } from '../../../lib/terminalSetup.js'
|
|
19
|
+
import type { Msg, PanelSection } from '../../../types.js'
|
|
20
|
+
import type { StatusBarMode } from '../../interfaces.js'
|
|
21
|
+
import { patchOverlayState } from '../../overlayStore.js'
|
|
22
|
+
import { patchUiState } from '../../uiStore.js'
|
|
23
|
+
import type { SlashCommand } from '../types.js'
|
|
24
|
+
|
|
25
|
+
const flagFromArg = (arg: string, current: boolean): boolean | null => {
|
|
26
|
+
if (!arg) {
|
|
27
|
+
return !current
|
|
28
|
+
}
|
|
29
|
+
|
|
30
|
+
const mode = arg.trim().toLowerCase()
|
|
31
|
+
|
|
32
|
+
if (mode === 'on') {
|
|
33
|
+
return true
|
|
34
|
+
}
|
|
35
|
+
|
|
36
|
+
if (mode === 'off') {
|
|
37
|
+
return false
|
|
38
|
+
}
|
|
39
|
+
|
|
40
|
+
if (mode === 'toggle') {
|
|
41
|
+
return !current
|
|
42
|
+
}
|
|
43
|
+
|
|
44
|
+
return null
|
|
45
|
+
}
|
|
46
|
+
|
|
47
|
+
// `/mouse` toggles between full tracking and off when called bare so the
|
|
48
|
+
// old binary muscle-memory still works. Explicit presets (wheel / buttons /
|
|
49
|
+
// all) target the tmux-friendly hover-free subsets.
|
|
50
|
+
const MOUSE_MODE_ALIASES: Record<string, MouseTrackingMode> = {
|
|
51
|
+
all: 'all',
|
|
52
|
+
any: 'all',
|
|
53
|
+
button: 'buttons',
|
|
54
|
+
buttons: 'buttons',
|
|
55
|
+
click: 'buttons',
|
|
56
|
+
full: 'all',
|
|
57
|
+
off: 'off',
|
|
58
|
+
on: 'all',
|
|
59
|
+
scroll: 'wheel',
|
|
60
|
+
wheel: 'wheel'
|
|
61
|
+
}
|
|
62
|
+
|
|
63
|
+
const mouseModeFromArg = (arg: string, current: MouseTrackingMode): MouseTrackingMode | null => {
|
|
64
|
+
if (!arg || arg.trim().toLowerCase() === 'toggle') {
|
|
65
|
+
return current === 'off' ? 'all' : 'off'
|
|
66
|
+
}
|
|
67
|
+
|
|
68
|
+
return MOUSE_MODE_ALIASES[arg.trim().toLowerCase()] ?? null
|
|
69
|
+
}
|
|
70
|
+
|
|
71
|
+
const RESET_WORDS = new Set(['reset', 'clear', 'default'])
|
|
72
|
+
const CYCLE_WORDS = new Set(['cycle', 'toggle'])
|
|
73
|
+
|
|
74
|
+
const DETAILS_USAGE =
|
|
75
|
+
'usage: /details [hidden|collapsed|expanded|cycle] or /details <section> [hidden|collapsed|expanded|reset]'
|
|
76
|
+
|
|
77
|
+
const DETAILS_SECTION_USAGE = 'usage: /details <section> [hidden|collapsed|expanded|reset]'
|
|
78
|
+
|
|
79
|
+
export const coreCommands: SlashCommand[] = [
|
|
80
|
+
{
|
|
81
|
+
help: 'list commands + hotkeys',
|
|
82
|
+
name: 'help',
|
|
83
|
+
run: (_arg, ctx) => {
|
|
84
|
+
const sections: PanelSection[] = (ctx.local.catalog?.categories ?? []).map(cat => ({
|
|
85
|
+
rows: cat.pairs,
|
|
86
|
+
title: cat.name
|
|
87
|
+
}))
|
|
88
|
+
|
|
89
|
+
if (ctx.local.catalog?.skillCount) {
|
|
90
|
+
sections.push({ text: `${ctx.local.catalog.skillCount} skill commands available — /skills to browse` })
|
|
91
|
+
}
|
|
92
|
+
|
|
93
|
+
sections.push(
|
|
94
|
+
{
|
|
95
|
+
rows: [
|
|
96
|
+
['/details [hidden|collapsed|expanded|cycle]', 'set global agent detail visibility mode'],
|
|
97
|
+
[
|
|
98
|
+
'/details <section> [hidden|collapsed|expanded|reset]',
|
|
99
|
+
'override one section (thinking/tools/subagents/activity)'
|
|
100
|
+
],
|
|
101
|
+
['/fortune [random|daily]', 'show a random or daily local fortune']
|
|
102
|
+
],
|
|
103
|
+
title: 'TUI'
|
|
104
|
+
},
|
|
105
|
+
{ rows: HOTKEYS, title: 'Hotkeys' }
|
|
106
|
+
)
|
|
107
|
+
|
|
108
|
+
ctx.transcript.panel(ctx.ui.theme.brand.helpHeader, sections)
|
|
109
|
+
}
|
|
110
|
+
},
|
|
111
|
+
|
|
112
|
+
{
|
|
113
|
+
aliases: ['exit'],
|
|
114
|
+
help: 'exit nastech',
|
|
115
|
+
name: 'quit',
|
|
116
|
+
run: (_arg, ctx) => ctx.session.die()
|
|
117
|
+
},
|
|
118
|
+
|
|
119
|
+
{
|
|
120
|
+
help: 'update NasTech Agent to the latest version (exits TUI)',
|
|
121
|
+
name: 'update',
|
|
122
|
+
run: (_arg, ctx) => {
|
|
123
|
+
ctx.transcript.sys('exiting TUI to run update...')
|
|
124
|
+
// Exit code 42 signals the Python wrapper to exec `nastech update`.
|
|
125
|
+
// Use dieWithCode for proper cleanup (gateway kill + Ink unmount).
|
|
126
|
+
setTimeout(() => ctx.session.dieWithCode(42), 100)
|
|
127
|
+
}
|
|
128
|
+
},
|
|
129
|
+
|
|
130
|
+
{
|
|
131
|
+
aliases: ['scroll'],
|
|
132
|
+
help: 'set mouse tracking preset [on|off|toggle|wheel|buttons|all]',
|
|
133
|
+
name: 'mouse',
|
|
134
|
+
run: (arg, ctx) => {
|
|
135
|
+
const current = ctx.ui.mouseTracking
|
|
136
|
+
const next = mouseModeFromArg(arg, current)
|
|
137
|
+
|
|
138
|
+
if (next === null) {
|
|
139
|
+
return ctx.transcript.sys('usage: /mouse [on|off|toggle|wheel|buttons|all]')
|
|
140
|
+
}
|
|
141
|
+
|
|
142
|
+
patchUiState({ mouseTracking: next })
|
|
143
|
+
ctx.gateway.rpc<ConfigSetResponse>('config.set', { key: 'mouse', value: next }).catch(() => {})
|
|
144
|
+
|
|
145
|
+
queueMicrotask(() => ctx.transcript.sys(`mouse tracking ${next}`))
|
|
146
|
+
}
|
|
147
|
+
},
|
|
148
|
+
|
|
149
|
+
{
|
|
150
|
+
aliases: ['new'],
|
|
151
|
+
help: 'start a new session',
|
|
152
|
+
name: 'clear',
|
|
153
|
+
run: (arg, ctx, cmd) => {
|
|
154
|
+
if (ctx.session.guardBusySessionSwitch('switch sessions')) {
|
|
155
|
+
return
|
|
156
|
+
}
|
|
157
|
+
|
|
158
|
+
const isNew = cmd.startsWith('/new')
|
|
159
|
+
const requestedTitle = isNew ? arg.trim() : ''
|
|
160
|
+
|
|
161
|
+
const commit = () => {
|
|
162
|
+
patchUiState({ status: 'forging session…' })
|
|
163
|
+
ctx.session.newSession(isNew ? 'new session started' : undefined, requestedTitle || undefined)
|
|
164
|
+
}
|
|
165
|
+
|
|
166
|
+
if (NO_CONFIRM_DESTRUCTIVE) {
|
|
167
|
+
return commit()
|
|
168
|
+
}
|
|
169
|
+
|
|
170
|
+
patchOverlayState({
|
|
171
|
+
confirm: {
|
|
172
|
+
cancelLabel: 'No, keep going',
|
|
173
|
+
confirmLabel: isNew ? 'Yes, start a new session' : 'Yes, clear the session',
|
|
174
|
+
danger: true,
|
|
175
|
+
detail: 'This ends the current conversation and clears the transcript.',
|
|
176
|
+
onConfirm: commit,
|
|
177
|
+
title: isNew ? 'Start a new session?' : 'Clear the current session?'
|
|
178
|
+
}
|
|
179
|
+
})
|
|
180
|
+
}
|
|
181
|
+
},
|
|
182
|
+
|
|
183
|
+
{
|
|
184
|
+
help: 'force a full UI repaint',
|
|
185
|
+
name: 'redraw',
|
|
186
|
+
run: (_arg, ctx) => {
|
|
187
|
+
forceRedraw(process.stdout)
|
|
188
|
+
ctx.transcript.sys('ui redrawn')
|
|
189
|
+
}
|
|
190
|
+
},
|
|
191
|
+
|
|
192
|
+
{
|
|
193
|
+
help: 'show live session info',
|
|
194
|
+
name: 'status',
|
|
195
|
+
run: (_arg, ctx) => {
|
|
196
|
+
if (!ctx.sid) {
|
|
197
|
+
return ctx.transcript.sys('no active session')
|
|
198
|
+
}
|
|
199
|
+
|
|
200
|
+
ctx.gateway
|
|
201
|
+
.rpc<SessionStatusResponse>('session.status', { session_id: ctx.sid })
|
|
202
|
+
.then(ctx.guarded<SessionStatusResponse>(r => ctx.transcript.page(r.output || '(no status)', 'Status')))
|
|
203
|
+
.catch(ctx.guardedErr)
|
|
204
|
+
}
|
|
205
|
+
},
|
|
206
|
+
|
|
207
|
+
{
|
|
208
|
+
help: 'resume a prior session',
|
|
209
|
+
name: 'resume',
|
|
210
|
+
run: (arg, ctx) => {
|
|
211
|
+
if (ctx.session.guardBusySessionSwitch('switch sessions')) {
|
|
212
|
+
return
|
|
213
|
+
}
|
|
214
|
+
|
|
215
|
+
arg ? ctx.session.resumeById(arg) : patchOverlayState({ picker: true })
|
|
216
|
+
}
|
|
217
|
+
},
|
|
218
|
+
|
|
219
|
+
{
|
|
220
|
+
help: 'set or show current session title',
|
|
221
|
+
name: 'title',
|
|
222
|
+
run: (arg, ctx) => {
|
|
223
|
+
if (!ctx.sid) {
|
|
224
|
+
return ctx.transcript.sys('no active session')
|
|
225
|
+
}
|
|
226
|
+
|
|
227
|
+
const title = arg.trim()
|
|
228
|
+
|
|
229
|
+
if (!arg) {
|
|
230
|
+
ctx.gateway
|
|
231
|
+
.rpc<SessionTitleResponse>('session.title', { session_id: ctx.sid })
|
|
232
|
+
.then(
|
|
233
|
+
ctx.guarded<SessionTitleResponse>(r => {
|
|
234
|
+
const current = (r?.title ?? '').trim()
|
|
235
|
+
ctx.transcript.sys(current ? `title: ${current}` : 'no title set')
|
|
236
|
+
})
|
|
237
|
+
)
|
|
238
|
+
.catch(ctx.guardedErr)
|
|
239
|
+
|
|
240
|
+
return
|
|
241
|
+
}
|
|
242
|
+
|
|
243
|
+
if (!title) {
|
|
244
|
+
return ctx.transcript.sys('usage: /title <your session title>')
|
|
245
|
+
}
|
|
246
|
+
|
|
247
|
+
ctx.gateway
|
|
248
|
+
.rpc<SessionTitleResponse>('session.title', { session_id: ctx.sid, title })
|
|
249
|
+
.then(
|
|
250
|
+
ctx.guarded<SessionTitleResponse>(r => {
|
|
251
|
+
const next = (r?.title ?? title).trim()
|
|
252
|
+
const suffix = r?.pending ? ' (queued while session initializes)' : ''
|
|
253
|
+
ctx.transcript.sys(`session title set: ${next}${suffix}`)
|
|
254
|
+
})
|
|
255
|
+
)
|
|
256
|
+
.catch(ctx.guardedErr)
|
|
257
|
+
}
|
|
258
|
+
},
|
|
259
|
+
|
|
260
|
+
{
|
|
261
|
+
help: 'toggle compact transcript',
|
|
262
|
+
name: 'compact',
|
|
263
|
+
run: (arg, ctx) => {
|
|
264
|
+
const next = flagFromArg(arg, ctx.ui.compact)
|
|
265
|
+
|
|
266
|
+
if (next === null) {
|
|
267
|
+
return ctx.transcript.sys('usage: /compact [on|off|toggle]')
|
|
268
|
+
}
|
|
269
|
+
|
|
270
|
+
patchUiState({ compact: next })
|
|
271
|
+
ctx.gateway.rpc<ConfigSetResponse>('config.set', { key: 'compact', value: next ? 'on' : 'off' }).catch(() => {})
|
|
272
|
+
|
|
273
|
+
queueMicrotask(() => ctx.transcript.sys(`compact ${next ? 'on' : 'off'}`))
|
|
274
|
+
}
|
|
275
|
+
},
|
|
276
|
+
|
|
277
|
+
{
|
|
278
|
+
aliases: ['detail'],
|
|
279
|
+
help: 'control agent detail visibility (global or per-section)',
|
|
280
|
+
name: 'details',
|
|
281
|
+
run: (arg, ctx) => {
|
|
282
|
+
const { gateway, transcript, ui } = ctx
|
|
283
|
+
|
|
284
|
+
if (!arg) {
|
|
285
|
+
gateway
|
|
286
|
+
.rpc<ConfigGetValueResponse>('config.get', { key: 'details_mode' })
|
|
287
|
+
.then(r => {
|
|
288
|
+
if (ctx.stale()) {
|
|
289
|
+
return
|
|
290
|
+
}
|
|
291
|
+
|
|
292
|
+
const mode = parseDetailsMode(r?.value) ?? ui.detailsMode
|
|
293
|
+
patchUiState({ detailsMode: mode, detailsModeCommandOverride: false })
|
|
294
|
+
|
|
295
|
+
const overrides = SECTION_NAMES.filter(s => ui.sections[s])
|
|
296
|
+
.map(s => `${s}=${ui.sections[s]}`)
|
|
297
|
+
.join(' ')
|
|
298
|
+
|
|
299
|
+
transcript.sys(`details: ${mode}${overrides ? ` (${overrides})` : ''}`)
|
|
300
|
+
})
|
|
301
|
+
.catch(() => !ctx.stale() && transcript.sys(`details: ${ui.detailsMode}`))
|
|
302
|
+
|
|
303
|
+
return
|
|
304
|
+
}
|
|
305
|
+
|
|
306
|
+
const [first, second] = arg.trim().toLowerCase().split(/\s+/)
|
|
307
|
+
|
|
308
|
+
if (second && isSectionName(first)) {
|
|
309
|
+
const reset = RESET_WORDS.has(second)
|
|
310
|
+
const mode = reset ? null : parseDetailsMode(second)
|
|
311
|
+
|
|
312
|
+
if (!reset && !mode) {
|
|
313
|
+
return transcript.sys(DETAILS_SECTION_USAGE)
|
|
314
|
+
}
|
|
315
|
+
|
|
316
|
+
const { [first]: _drop, ...rest } = ui.sections
|
|
317
|
+
|
|
318
|
+
patchUiState({ sections: mode ? { ...rest, [first]: mode } : rest })
|
|
319
|
+
gateway
|
|
320
|
+
.rpc<ConfigSetResponse>('config.set', { key: `details_mode.${first}`, value: mode ?? '' })
|
|
321
|
+
.catch(() => {})
|
|
322
|
+
transcript.sys(`details ${first}: ${mode ?? 'reset'}`)
|
|
323
|
+
|
|
324
|
+
return
|
|
325
|
+
}
|
|
326
|
+
|
|
327
|
+
const next = CYCLE_WORDS.has(first ?? '') ? nextDetailsMode(ui.detailsMode) : parseDetailsMode(first)
|
|
328
|
+
|
|
329
|
+
if (!next) {
|
|
330
|
+
return transcript.sys(DETAILS_USAGE)
|
|
331
|
+
}
|
|
332
|
+
|
|
333
|
+
const sections = Object.fromEntries(SECTION_NAMES.map(section => [section, next]))
|
|
334
|
+
|
|
335
|
+
patchUiState({ detailsMode: next, detailsModeCommandOverride: true, sections })
|
|
336
|
+
gateway.rpc<ConfigSetResponse>('config.set', { key: 'details_mode', value: next }).catch(() => {})
|
|
337
|
+
transcript.sys(`details: ${next}`)
|
|
338
|
+
}
|
|
339
|
+
},
|
|
340
|
+
|
|
341
|
+
{
|
|
342
|
+
help: 'local fortune',
|
|
343
|
+
name: 'fortune',
|
|
344
|
+
run: (arg, ctx) => {
|
|
345
|
+
const key = arg.trim().toLowerCase()
|
|
346
|
+
|
|
347
|
+
if (!arg || key === 'random') {
|
|
348
|
+
return ctx.transcript.sys(randomFortune())
|
|
349
|
+
}
|
|
350
|
+
|
|
351
|
+
if (['daily', 'stable', 'today'].includes(key)) {
|
|
352
|
+
return ctx.transcript.sys(dailyFortune(ctx.sid))
|
|
353
|
+
}
|
|
354
|
+
|
|
355
|
+
ctx.transcript.sys('usage: /fortune [random|daily]')
|
|
356
|
+
}
|
|
357
|
+
},
|
|
358
|
+
|
|
359
|
+
{
|
|
360
|
+
help: 'copy selection or assistant message',
|
|
361
|
+
name: 'copy',
|
|
362
|
+
run: async (arg, ctx) => {
|
|
363
|
+
const { sys } = ctx.transcript
|
|
364
|
+
|
|
365
|
+
if (!arg && ctx.composer.hasSelection) {
|
|
366
|
+
const text = await ctx.composer.selection.copySelection()
|
|
367
|
+
|
|
368
|
+
if (text) {
|
|
369
|
+
return sys(`copied ${text.length} characters`)
|
|
370
|
+
} else {
|
|
371
|
+
return sys(
|
|
372
|
+
'clipboard copy failed — try NASTECH_TUI_FORCE_OSC52=1 to force the escape sequence'
|
|
373
|
+
)
|
|
374
|
+
}
|
|
375
|
+
}
|
|
376
|
+
|
|
377
|
+
if (arg && Number.isNaN(parseInt(arg, 10))) {
|
|
378
|
+
return sys('usage: /copy [number]')
|
|
379
|
+
}
|
|
380
|
+
|
|
381
|
+
const all = ctx.local.getHistoryItems().filter(m => m.role === 'assistant')
|
|
382
|
+
const target = all[arg ? Math.min(parseInt(arg, 10), all.length) - 1 : all.length - 1]
|
|
383
|
+
|
|
384
|
+
if (!target) {
|
|
385
|
+
return sys('nothing to copy — start a conversation first')
|
|
386
|
+
}
|
|
387
|
+
|
|
388
|
+
void writeClipboardText(target.text)
|
|
389
|
+
.then(nativeOk => {
|
|
390
|
+
if (ctx.stale()) {
|
|
391
|
+
return
|
|
392
|
+
}
|
|
393
|
+
|
|
394
|
+
if (nativeOk) {
|
|
395
|
+
sys('copied to clipboard')
|
|
396
|
+
} else {
|
|
397
|
+
writeOsc52Clipboard(target.text)
|
|
398
|
+
sys('sent OSC52 copy sequence (terminal support required)')
|
|
399
|
+
}
|
|
400
|
+
})
|
|
401
|
+
.catch(error => {
|
|
402
|
+
if (!ctx.stale()) {
|
|
403
|
+
sys(`copy failed: ${String(error)}`)
|
|
404
|
+
}
|
|
405
|
+
})
|
|
406
|
+
}
|
|
407
|
+
},
|
|
408
|
+
|
|
409
|
+
{
|
|
410
|
+
help: 'attach clipboard image',
|
|
411
|
+
name: 'paste',
|
|
412
|
+
run: (arg, ctx) => (arg ? ctx.transcript.sys('usage: /paste') : ctx.composer.paste())
|
|
413
|
+
},
|
|
414
|
+
|
|
415
|
+
{
|
|
416
|
+
help: 'configure IDE terminal keybindings for multiline + undo/redo',
|
|
417
|
+
name: 'terminal-setup',
|
|
418
|
+
run: (arg, ctx) => {
|
|
419
|
+
const target = arg.trim().toLowerCase()
|
|
420
|
+
|
|
421
|
+
if (target && !['auto', 'cursor', 'vscode', 'windsurf'].includes(target)) {
|
|
422
|
+
return ctx.transcript.sys('usage: /terminal-setup [auto|vscode|cursor|windsurf]')
|
|
423
|
+
}
|
|
424
|
+
|
|
425
|
+
const runner =
|
|
426
|
+
!target || target === 'auto'
|
|
427
|
+
? configureDetectedTerminalKeybindings()
|
|
428
|
+
: configureTerminalKeybindings(target as 'cursor' | 'vscode' | 'windsurf')
|
|
429
|
+
|
|
430
|
+
void runner
|
|
431
|
+
.then(result => {
|
|
432
|
+
if (ctx.stale()) {
|
|
433
|
+
return
|
|
434
|
+
}
|
|
435
|
+
|
|
436
|
+
ctx.transcript.sys(result.message)
|
|
437
|
+
|
|
438
|
+
if (result.success && result.requiresRestart) {
|
|
439
|
+
ctx.transcript.sys('restart the IDE terminal for the new keybindings to take effect')
|
|
440
|
+
}
|
|
441
|
+
})
|
|
442
|
+
.catch(error => {
|
|
443
|
+
if (!ctx.stale()) {
|
|
444
|
+
ctx.transcript.sys(`terminal setup failed: ${String(error)}`)
|
|
445
|
+
}
|
|
446
|
+
})
|
|
447
|
+
}
|
|
448
|
+
},
|
|
449
|
+
|
|
450
|
+
{
|
|
451
|
+
help: 'view gateway logs',
|
|
452
|
+
name: 'logs',
|
|
453
|
+
run: (arg, ctx) => {
|
|
454
|
+
const text = ctx.gateway.gw.getLogTail(Math.min(80, Math.max(1, parseInt(arg, 10) || 20)))
|
|
455
|
+
|
|
456
|
+
text ? ctx.transcript.page(text, 'Logs') : ctx.transcript.sys('no gateway logs')
|
|
457
|
+
}
|
|
458
|
+
},
|
|
459
|
+
|
|
460
|
+
{
|
|
461
|
+
help: 'view current transcript (user + assistant messages)',
|
|
462
|
+
name: 'history',
|
|
463
|
+
run: (arg, ctx) => {
|
|
464
|
+
// The CLI-side `/history` runs in a detached slash-worker subprocess
|
|
465
|
+
// that never sees the TUI's turns — it only surfaces whatever was
|
|
466
|
+
// persisted before this process started. Render the TUI's own
|
|
467
|
+
// transcript so `/history` actually reflects what the user just did.
|
|
468
|
+
const items = ctx.local.getHistoryItems().filter(m => m.role === 'user' || m.role === 'assistant')
|
|
469
|
+
|
|
470
|
+
if (!items.length) {
|
|
471
|
+
return ctx.transcript.sys('no conversation yet')
|
|
472
|
+
}
|
|
473
|
+
|
|
474
|
+
const preview = Math.max(80, parseInt(arg, 10) || 400)
|
|
475
|
+
|
|
476
|
+
const lines = items.map((m, i) => {
|
|
477
|
+
const tag = m.role === 'user' ? `You #${i + 1}` : `NasTech #${i + 1}`
|
|
478
|
+
const body = m.text.trim() || (m.tools?.length ? `(${m.tools.length} tool calls)` : '(empty)')
|
|
479
|
+
const clipped = body.length > preview ? `${body.slice(0, preview).trimEnd()}…` : body
|
|
480
|
+
|
|
481
|
+
return `[${tag}]\n${clipped}`
|
|
482
|
+
})
|
|
483
|
+
|
|
484
|
+
ctx.transcript.page(lines.join('\n\n'), 'History')
|
|
485
|
+
}
|
|
486
|
+
},
|
|
487
|
+
|
|
488
|
+
{
|
|
489
|
+
help: 'save the current transcript to JSON',
|
|
490
|
+
name: 'save',
|
|
491
|
+
run: (_arg, ctx) => {
|
|
492
|
+
const hasConversation = ctx.local
|
|
493
|
+
.getHistoryItems()
|
|
494
|
+
.some(m => m.role === 'user' || m.role === 'assistant' || m.role === 'tool')
|
|
495
|
+
|
|
496
|
+
if (!hasConversation) {
|
|
497
|
+
return ctx.transcript.sys('no conversation yet')
|
|
498
|
+
}
|
|
499
|
+
|
|
500
|
+
if (!ctx.sid) {
|
|
501
|
+
return ctx.transcript.sys('no active session — nothing to save')
|
|
502
|
+
}
|
|
503
|
+
|
|
504
|
+
ctx.gateway
|
|
505
|
+
.rpc<SessionSaveResponse>('session.save', { session_id: ctx.sid })
|
|
506
|
+
.then(
|
|
507
|
+
ctx.guarded<SessionSaveResponse>(r => {
|
|
508
|
+
const file = r?.file
|
|
509
|
+
|
|
510
|
+
if (file) {
|
|
511
|
+
ctx.transcript.sys(`conversation saved to: ${file}`)
|
|
512
|
+
} else {
|
|
513
|
+
ctx.transcript.sys('failed to save')
|
|
514
|
+
}
|
|
515
|
+
})
|
|
516
|
+
)
|
|
517
|
+
.catch(ctx.guardedErr)
|
|
518
|
+
}
|
|
519
|
+
},
|
|
520
|
+
|
|
521
|
+
{
|
|
522
|
+
aliases: ['sb'],
|
|
523
|
+
help: 'status bar position (on|off|top|bottom)',
|
|
524
|
+
name: 'statusbar',
|
|
525
|
+
run: (arg, ctx) => {
|
|
526
|
+
const mode = arg.trim().toLowerCase()
|
|
527
|
+
const toggle: StatusBarMode = ctx.ui.statusBar === 'off' ? 'top' : 'off'
|
|
528
|
+
|
|
529
|
+
const next: null | StatusBarMode =
|
|
530
|
+
!mode || mode === 'toggle'
|
|
531
|
+
? toggle
|
|
532
|
+
: mode === 'on' || mode === 'top'
|
|
533
|
+
? 'top'
|
|
534
|
+
: mode === 'off' || mode === 'bottom'
|
|
535
|
+
? mode
|
|
536
|
+
: null
|
|
537
|
+
|
|
538
|
+
if (!next) {
|
|
539
|
+
return ctx.transcript.sys('usage: /statusbar [on|off|top|bottom|toggle]')
|
|
540
|
+
}
|
|
541
|
+
|
|
542
|
+
patchUiState({ statusBar: next })
|
|
543
|
+
ctx.gateway.rpc<ConfigSetResponse>('config.set', { key: 'statusbar', value: next }).catch(() => {})
|
|
544
|
+
|
|
545
|
+
queueMicrotask(() => ctx.transcript.sys(`status bar ${next}`))
|
|
546
|
+
}
|
|
547
|
+
},
|
|
548
|
+
|
|
549
|
+
{
|
|
550
|
+
aliases: ['q'],
|
|
551
|
+
help: 'inspect or enqueue a message',
|
|
552
|
+
name: 'queue',
|
|
553
|
+
run: (arg, ctx) => {
|
|
554
|
+
if (!arg) {
|
|
555
|
+
return ctx.transcript.sys(`${ctx.composer.queueRef.current.length} queued message(s)`)
|
|
556
|
+
}
|
|
557
|
+
|
|
558
|
+
ctx.composer.enqueue(arg)
|
|
559
|
+
ctx.transcript.sys(`queued: "${arg.slice(0, 50)}${arg.length > 50 ? '…' : ''}"`)
|
|
560
|
+
}
|
|
561
|
+
},
|
|
562
|
+
|
|
563
|
+
{
|
|
564
|
+
help: 'inject a message after the next tool call (no interrupt)',
|
|
565
|
+
name: 'steer',
|
|
566
|
+
run: (arg, ctx) => {
|
|
567
|
+
const payload = arg?.trim() ?? ''
|
|
568
|
+
|
|
569
|
+
if (!payload) {
|
|
570
|
+
return ctx.transcript.sys('usage: /steer <prompt>')
|
|
571
|
+
}
|
|
572
|
+
|
|
573
|
+
// If the agent isn't running, fall back to the queue so the user's
|
|
574
|
+
// message isn't lost — identical semantics to the gateway handler.
|
|
575
|
+
if (!ctx.ui.busy || !ctx.sid) {
|
|
576
|
+
ctx.composer.enqueue(payload)
|
|
577
|
+
ctx.transcript.sys(
|
|
578
|
+
`no active turn — queued for next: "${payload.slice(0, 50)}${payload.length > 50 ? '…' : ''}"`
|
|
579
|
+
)
|
|
580
|
+
|
|
581
|
+
return
|
|
582
|
+
}
|
|
583
|
+
|
|
584
|
+
ctx.gateway
|
|
585
|
+
.rpc<SessionSteerResponse>('session.steer', { session_id: ctx.sid, text: payload })
|
|
586
|
+
.then(
|
|
587
|
+
ctx.guarded<SessionSteerResponse>(r => {
|
|
588
|
+
if (r?.status === 'queued') {
|
|
589
|
+
ctx.transcript.sys(
|
|
590
|
+
`steer queued — arrives after next tool call: "${payload.slice(0, 50)}${payload.length > 50 ? '…' : ''}"`
|
|
591
|
+
)
|
|
592
|
+
} else {
|
|
593
|
+
ctx.transcript.sys('steer rejected')
|
|
594
|
+
}
|
|
595
|
+
})
|
|
596
|
+
)
|
|
597
|
+
.catch(ctx.guardedErr)
|
|
598
|
+
}
|
|
599
|
+
},
|
|
600
|
+
|
|
601
|
+
{
|
|
602
|
+
help: 'undo last exchange',
|
|
603
|
+
name: 'undo',
|
|
604
|
+
run: (_arg, ctx) => {
|
|
605
|
+
if (!ctx.sid) {
|
|
606
|
+
return ctx.transcript.sys('nothing to undo')
|
|
607
|
+
}
|
|
608
|
+
|
|
609
|
+
ctx.gateway.rpc<SessionUndoResponse>('session.undo', { session_id: ctx.sid }).then(
|
|
610
|
+
ctx.guarded<SessionUndoResponse>(r => {
|
|
611
|
+
if ((r.removed ?? 0) > 0) {
|
|
612
|
+
ctx.transcript.setHistoryItems((prev: Msg[]) => ctx.transcript.trimLastExchange(prev))
|
|
613
|
+
ctx.transcript.sys(`undid ${r.removed} messages`)
|
|
614
|
+
} else {
|
|
615
|
+
ctx.transcript.sys('nothing to undo')
|
|
616
|
+
}
|
|
617
|
+
})
|
|
618
|
+
)
|
|
619
|
+
}
|
|
620
|
+
},
|
|
621
|
+
|
|
622
|
+
{
|
|
623
|
+
help: 'retry last user message',
|
|
624
|
+
name: 'retry',
|
|
625
|
+
run: (_arg, ctx) => {
|
|
626
|
+
const last = ctx.local.getLastUserMsg()
|
|
627
|
+
|
|
628
|
+
if (!last) {
|
|
629
|
+
return ctx.transcript.sys('nothing to retry')
|
|
630
|
+
}
|
|
631
|
+
|
|
632
|
+
if (!ctx.sid) {
|
|
633
|
+
return ctx.transcript.send(last)
|
|
634
|
+
}
|
|
635
|
+
|
|
636
|
+
ctx.gateway.rpc<SessionUndoResponse>('session.undo', { session_id: ctx.sid }).then(
|
|
637
|
+
ctx.guarded<SessionUndoResponse>(r => {
|
|
638
|
+
if ((r.removed ?? 0) <= 0) {
|
|
639
|
+
return ctx.transcript.sys('nothing to retry')
|
|
640
|
+
}
|
|
641
|
+
|
|
642
|
+
ctx.transcript.setHistoryItems((prev: Msg[]) => ctx.transcript.trimLastExchange(prev))
|
|
643
|
+
ctx.transcript.send(last)
|
|
644
|
+
})
|
|
645
|
+
)
|
|
646
|
+
}
|
|
647
|
+
}
|
|
648
|
+
]
|
|
@@ -0,0 +1,57 @@
|
|
|
1
|
+
import type { CreditsViewResponse } from '../../../gatewayTypes.js'
|
|
2
|
+
import { openExternalUrl } from '../../../lib/openExternalUrl.js'
|
|
3
|
+
import { patchOverlayState } from '../../overlayStore.js'
|
|
4
|
+
import type { SlashCommand } from '../types.js'
|
|
5
|
+
|
|
6
|
+
export const creditsCommands: SlashCommand[] = [
|
|
7
|
+
{
|
|
8
|
+
help: 'Show NasTech credit balance and top up',
|
|
9
|
+
name: 'credits',
|
|
10
|
+
run: (_arg, ctx) => {
|
|
11
|
+
ctx.gateway
|
|
12
|
+
.rpc<CreditsViewResponse>('credits.view', { session_id: ctx.sid })
|
|
13
|
+
.then(
|
|
14
|
+
ctx.guarded<CreditsViewResponse>(view => {
|
|
15
|
+
if (!view.logged_in) {
|
|
16
|
+
ctx.transcript.sys('💳 Not logged into NasTech Portal — run /portal to log in.')
|
|
17
|
+
return
|
|
18
|
+
}
|
|
19
|
+
|
|
20
|
+
const lines = ['💳 NasTech credits', ...view.balance_lines]
|
|
21
|
+
|
|
22
|
+
if (view.identity_line) {
|
|
23
|
+
lines.push('', view.identity_line)
|
|
24
|
+
}
|
|
25
|
+
|
|
26
|
+
if (view.topup_url) {
|
|
27
|
+
lines.push('', `Top up: ${view.topup_url}`)
|
|
28
|
+
}
|
|
29
|
+
|
|
30
|
+
ctx.transcript.sys(lines.join('\n'))
|
|
31
|
+
|
|
32
|
+
const url = view.topup_url
|
|
33
|
+
|
|
34
|
+
if (url) {
|
|
35
|
+
patchOverlayState({
|
|
36
|
+
confirm: {
|
|
37
|
+
cancelLabel: 'Cancel',
|
|
38
|
+
confirmLabel: 'Open top-up in browser',
|
|
39
|
+
detail: url,
|
|
40
|
+
onConfirm: () => {
|
|
41
|
+
const ok = openExternalUrl(url)
|
|
42
|
+
ctx.transcript.sys(
|
|
43
|
+
ok
|
|
44
|
+
? 'Complete your top-up in the browser — credits will appear in /credits shortly.'
|
|
45
|
+
: `Open this URL to top up: ${url}`
|
|
46
|
+
)
|
|
47
|
+
},
|
|
48
|
+
title: 'Add credits?'
|
|
49
|
+
}
|
|
50
|
+
})
|
|
51
|
+
}
|
|
52
|
+
})
|
|
53
|
+
)
|
|
54
|
+
.catch(ctx.guardedErr)
|
|
55
|
+
}
|
|
56
|
+
}
|
|
57
|
+
]
|