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,102 @@
|
|
|
1
|
+
import { afterEach, beforeEach, describe, expect, it, vi } from 'vitest'
|
|
2
|
+
|
|
3
|
+
// memory.js performs real heap dumps / fs work — stub it so the monitor's
|
|
4
|
+
// dump path is a no-op in tests.
|
|
5
|
+
vi.mock('../lib/memory.js', () => ({
|
|
6
|
+
performHeapDump: vi.fn(async () => null)
|
|
7
|
+
}))
|
|
8
|
+
|
|
9
|
+
// @nastechai/ink is dynamically imported only on the dump path; stub the eviction.
|
|
10
|
+
vi.mock('@nastechai/ink', () => ({ evictInkCaches: vi.fn() }))
|
|
11
|
+
|
|
12
|
+
import { startMemoryMonitor } from '../lib/memoryMonitor.js'
|
|
13
|
+
|
|
14
|
+
const GB = 1024 ** 3
|
|
15
|
+
const MB = 1024 ** 2
|
|
16
|
+
|
|
17
|
+
describe('startMemoryMonitor thresholds (#34095)', () => {
|
|
18
|
+
let stop: (() => void) | undefined
|
|
19
|
+
|
|
20
|
+
beforeEach(() => {
|
|
21
|
+
vi.useFakeTimers()
|
|
22
|
+
})
|
|
23
|
+
|
|
24
|
+
afterEach(() => {
|
|
25
|
+
stop?.()
|
|
26
|
+
stop = undefined
|
|
27
|
+
vi.restoreAllMocks()
|
|
28
|
+
vi.useRealTimers()
|
|
29
|
+
})
|
|
30
|
+
|
|
31
|
+
const withHeap = (heapUsed: number, rss = heapUsed) =>
|
|
32
|
+
vi.spyOn(process, 'memoryUsage').mockReturnValue({
|
|
33
|
+
arrayBuffers: 0,
|
|
34
|
+
external: 0,
|
|
35
|
+
heapTotal: heapUsed,
|
|
36
|
+
heapUsed,
|
|
37
|
+
rss
|
|
38
|
+
} as NodeJS.MemoryUsage)
|
|
39
|
+
|
|
40
|
+
it('does NOT fire onCritical at 2.5GB when the heap ceiling is 8GB', async () => {
|
|
41
|
+
// The old hardcoded 2.5GB constant killed the process at ~31% of the real
|
|
42
|
+
// ceiling. With relative thresholds (~88%), 2.5GB is well within normal.
|
|
43
|
+
const onCritical = vi.fn()
|
|
44
|
+
withHeap(2.5 * GB)
|
|
45
|
+
stop = startMemoryMonitor({ intervalMs: 1, onCritical })
|
|
46
|
+
|
|
47
|
+
await vi.advanceTimersByTimeAsync(5)
|
|
48
|
+
|
|
49
|
+
expect(onCritical).not.toHaveBeenCalled()
|
|
50
|
+
})
|
|
51
|
+
|
|
52
|
+
it('fires onCritical only near the configured ceiling', async () => {
|
|
53
|
+
const onCritical = vi.fn()
|
|
54
|
+
// Explicit small ceiling-derived thresholds via override to keep the test
|
|
55
|
+
// independent of the host V8 heap_size_limit.
|
|
56
|
+
withHeap(7.5 * GB)
|
|
57
|
+
stop = startMemoryMonitor({ criticalBytes: 7 * GB, highBytes: 5 * GB, intervalMs: 1, onCritical })
|
|
58
|
+
|
|
59
|
+
await vi.advanceTimersByTimeAsync(5)
|
|
60
|
+
|
|
61
|
+
expect(onCritical).toHaveBeenCalledTimes(1)
|
|
62
|
+
})
|
|
63
|
+
|
|
64
|
+
it('fires onWarn once on fast sub-threshold heap growth, then re-arms', async () => {
|
|
65
|
+
const onWarn = vi.fn()
|
|
66
|
+
// Start low, then jump >150MB across a tick while above the 600MB floor and
|
|
67
|
+
// below `high` — the silent-death regime.
|
|
68
|
+
const spy = withHeap(100 * MB)
|
|
69
|
+
stop = startMemoryMonitor({ highBytes: 2 * GB, intervalMs: 1, onWarn, warnBytes: 600 * MB })
|
|
70
|
+
|
|
71
|
+
await vi.advanceTimersByTimeAsync(2) // seed lastHeap at 100MB, below floor
|
|
72
|
+
expect(onWarn).not.toHaveBeenCalled()
|
|
73
|
+
|
|
74
|
+
spy.mockReturnValue({ arrayBuffers: 0, external: 0, heapTotal: 800 * MB, heapUsed: 800 * MB, rss: 800 * MB } as NodeJS.MemoryUsage)
|
|
75
|
+
await vi.advanceTimersByTimeAsync(2) // jumped 700MB → above floor + steep
|
|
76
|
+
expect(onWarn).toHaveBeenCalledTimes(1)
|
|
77
|
+
|
|
78
|
+
// Stays elevated but not re-firing.
|
|
79
|
+
await vi.advanceTimersByTimeAsync(2)
|
|
80
|
+
expect(onWarn).toHaveBeenCalledTimes(1)
|
|
81
|
+
|
|
82
|
+
// Falls back below the floor → re-armed, then climbs again → fires again.
|
|
83
|
+
spy.mockReturnValue({ arrayBuffers: 0, external: 0, heapTotal: 100 * MB, heapUsed: 100 * MB, rss: 100 * MB } as NodeJS.MemoryUsage)
|
|
84
|
+
await vi.advanceTimersByTimeAsync(2)
|
|
85
|
+
spy.mockReturnValue({ arrayBuffers: 0, external: 0, heapTotal: 800 * MB, heapUsed: 800 * MB, rss: 800 * MB } as NodeJS.MemoryUsage)
|
|
86
|
+
await vi.advanceTimersByTimeAsync(2)
|
|
87
|
+
expect(onWarn).toHaveBeenCalledTimes(2)
|
|
88
|
+
})
|
|
89
|
+
|
|
90
|
+
it('does not warn on slow growth below the steep-growth step', async () => {
|
|
91
|
+
const onWarn = vi.fn()
|
|
92
|
+
const spy = withHeap(650 * MB)
|
|
93
|
+
stop = startMemoryMonitor({ highBytes: 2 * GB, intervalMs: 1, onWarn, warnBytes: 600 * MB })
|
|
94
|
+
|
|
95
|
+
await vi.advanceTimersByTimeAsync(2)
|
|
96
|
+
// +50MB per tick — above the floor but gentle, not a render-tree blowup.
|
|
97
|
+
spy.mockReturnValue({ arrayBuffers: 0, external: 0, heapTotal: 700 * MB, heapUsed: 700 * MB, rss: 700 * MB } as NodeJS.MemoryUsage)
|
|
98
|
+
await vi.advanceTimersByTimeAsync(2)
|
|
99
|
+
|
|
100
|
+
expect(onWarn).not.toHaveBeenCalled()
|
|
101
|
+
})
|
|
102
|
+
})
|
|
@@ -0,0 +1,19 @@
|
|
|
1
|
+
import { describe, expect, it } from 'vitest'
|
|
2
|
+
|
|
3
|
+
import { shouldShowResponseSeparator } from '../components/messageLine.js'
|
|
4
|
+
|
|
5
|
+
describe('shouldShowResponseSeparator', () => {
|
|
6
|
+
it('separates assistant response text from visible details', () => {
|
|
7
|
+
expect(shouldShowResponseSeparator({ role: 'assistant', text: 'final', thinking: 'plan' }, true)).toBe(true)
|
|
8
|
+
})
|
|
9
|
+
|
|
10
|
+
it('does not add a response separator without details or body text', () => {
|
|
11
|
+
expect(shouldShowResponseSeparator({ role: 'assistant', text: 'final' }, false)).toBe(false)
|
|
12
|
+
expect(shouldShowResponseSeparator({ role: 'assistant', text: ' ', thinking: 'plan' }, true)).toBe(false)
|
|
13
|
+
})
|
|
14
|
+
|
|
15
|
+
it('does not add response separators to non-assistant transcript rows', () => {
|
|
16
|
+
expect(shouldShowResponseSeparator({ role: 'user', text: 'prompt' }, true)).toBe(false)
|
|
17
|
+
expect(shouldShowResponseSeparator({ role: 'system', text: 'note' }, true)).toBe(false)
|
|
18
|
+
})
|
|
19
|
+
})
|
|
@@ -0,0 +1,92 @@
|
|
|
1
|
+
import { renderSync } from '@nastechai/ink'
|
|
2
|
+
import React from 'react'
|
|
3
|
+
import { PassThrough } from 'stream'
|
|
4
|
+
import { describe, expect, it } from 'vitest'
|
|
5
|
+
|
|
6
|
+
import { MessageLine } from '../components/messageLine.js'
|
|
7
|
+
import { toTranscriptMessages } from '../domain/messages.js'
|
|
8
|
+
import { upsert } from '../lib/messages.js'
|
|
9
|
+
import { stripAnsi } from '../lib/text.js'
|
|
10
|
+
import { DEFAULT_THEME } from '../theme.js'
|
|
11
|
+
|
|
12
|
+
describe('toTranscriptMessages', () => {
|
|
13
|
+
it('preserves assistant tool-call rows so resume does not drop prior turns', () => {
|
|
14
|
+
const rows = [
|
|
15
|
+
{ role: 'user', text: 'first prompt' },
|
|
16
|
+
{ role: 'tool', context: 'repo', name: 'search_files', text: 'ignored raw result' },
|
|
17
|
+
{ role: 'assistant', text: 'first answer' },
|
|
18
|
+
{ role: 'user', text: 'second prompt' }
|
|
19
|
+
]
|
|
20
|
+
|
|
21
|
+
expect(toTranscriptMessages(rows).map(msg => [msg.role, msg.text])).toEqual([
|
|
22
|
+
['user', 'first prompt'],
|
|
23
|
+
['assistant', 'first answer'],
|
|
24
|
+
['user', 'second prompt']
|
|
25
|
+
])
|
|
26
|
+
expect(toTranscriptMessages(rows)[1]?.tools?.[0]).toContain('Search Files')
|
|
27
|
+
})
|
|
28
|
+
})
|
|
29
|
+
|
|
30
|
+
describe('MessageLine', () => {
|
|
31
|
+
it('preserves a separator after compound user prompt glyphs in transcript rows', () => {
|
|
32
|
+
const stdout = new PassThrough()
|
|
33
|
+
const stdin = new PassThrough()
|
|
34
|
+
const stderr = new PassThrough()
|
|
35
|
+
let output = ''
|
|
36
|
+
|
|
37
|
+
Object.assign(stdout, { columns: 80, isTTY: false, rows: 24 })
|
|
38
|
+
Object.assign(stdin, { isTTY: false })
|
|
39
|
+
Object.assign(stderr, { isTTY: false })
|
|
40
|
+
stdout.on('data', chunk => {
|
|
41
|
+
output += chunk.toString()
|
|
42
|
+
})
|
|
43
|
+
|
|
44
|
+
const t = {
|
|
45
|
+
...DEFAULT_THEME,
|
|
46
|
+
brand: { ...DEFAULT_THEME.brand, prompt: 'Ψ >' }
|
|
47
|
+
}
|
|
48
|
+
|
|
49
|
+
const instance = renderSync(
|
|
50
|
+
React.createElement(MessageLine, {
|
|
51
|
+
cols: 80,
|
|
52
|
+
msg: { role: 'user', text: 'Okay' },
|
|
53
|
+
t
|
|
54
|
+
}),
|
|
55
|
+
{
|
|
56
|
+
patchConsole: false,
|
|
57
|
+
stderr: stderr as NodeJS.WriteStream,
|
|
58
|
+
stdin: stdin as NodeJS.ReadStream,
|
|
59
|
+
stdout: stdout as NodeJS.WriteStream
|
|
60
|
+
}
|
|
61
|
+
)
|
|
62
|
+
|
|
63
|
+
instance.unmount()
|
|
64
|
+
instance.cleanup()
|
|
65
|
+
|
|
66
|
+
const renderedLine = stripAnsi(output)
|
|
67
|
+
.split('\n')
|
|
68
|
+
.find(line => line.includes('Okay'))
|
|
69
|
+
|
|
70
|
+
expect(renderedLine).toContain('Ψ > Okay')
|
|
71
|
+
})
|
|
72
|
+
})
|
|
73
|
+
|
|
74
|
+
describe('upsert', () => {
|
|
75
|
+
it('appends when last role differs', () => {
|
|
76
|
+
expect(upsert([{ role: 'user', text: 'hi' }], 'assistant', 'hello')).toHaveLength(2)
|
|
77
|
+
})
|
|
78
|
+
|
|
79
|
+
it('replaces when last role matches', () => {
|
|
80
|
+
expect(upsert([{ role: 'assistant', text: 'partial' }], 'assistant', 'full')[0]!.text).toBe('full')
|
|
81
|
+
})
|
|
82
|
+
|
|
83
|
+
it('appends to empty', () => {
|
|
84
|
+
expect(upsert([], 'user', 'first')).toEqual([{ role: 'user', text: 'first' }])
|
|
85
|
+
})
|
|
86
|
+
|
|
87
|
+
it('does not mutate', () => {
|
|
88
|
+
const prev = [{ role: 'user' as const, text: 'hi' }]
|
|
89
|
+
upsert(prev, 'assistant', 'yo')
|
|
90
|
+
expect(prev).toHaveLength(1)
|
|
91
|
+
})
|
|
92
|
+
})
|
|
@@ -0,0 +1,64 @@
|
|
|
1
|
+
import { describe, expect, it } from 'vitest'
|
|
2
|
+
|
|
3
|
+
import { startPromptLiveSession } from '../app/useMainApp.js'
|
|
4
|
+
|
|
5
|
+
describe('startPromptLiveSession', () => {
|
|
6
|
+
it('starts a kept-live session with generated id/title, applies selected model, then dispatches the prompt', async () => {
|
|
7
|
+
const calls: Array<[string, unknown]> = []
|
|
8
|
+
|
|
9
|
+
const sid = await startPromptLiveSession({
|
|
10
|
+
dispatchSubmission: prompt => calls.push(['dispatch', prompt]),
|
|
11
|
+
maybeWarn: value => calls.push(['warn', value]),
|
|
12
|
+
modelArg: 'kimi-k2.6 --provider ollama-cloud',
|
|
13
|
+
newLiveSession: async (message, title) => {
|
|
14
|
+
calls.push(['new', { message, title }])
|
|
15
|
+
|
|
16
|
+
return 'abc123'
|
|
17
|
+
},
|
|
18
|
+
onModelSwitched: (value, result) => calls.push(['model-switched', { result, value }]),
|
|
19
|
+
prompt: ' Build the thing ',
|
|
20
|
+
rpc: async (method, params) => {
|
|
21
|
+
calls.push(['rpc', { method, params }])
|
|
22
|
+
|
|
23
|
+
return { value: 'kimi-k2.6', warning: '' }
|
|
24
|
+
},
|
|
25
|
+
sys: text => calls.push(['sys', text])
|
|
26
|
+
})
|
|
27
|
+
|
|
28
|
+
expect(sid).toBe('abc123')
|
|
29
|
+
expect(calls).toEqual([
|
|
30
|
+
['new', { message: 'new live session started', title: undefined }],
|
|
31
|
+
[
|
|
32
|
+
'rpc',
|
|
33
|
+
{
|
|
34
|
+
method: 'config.set',
|
|
35
|
+
params: { key: 'model', session_id: 'abc123', value: 'kimi-k2.6 --provider ollama-cloud' }
|
|
36
|
+
}
|
|
37
|
+
],
|
|
38
|
+
['sys', 'model → kimi-k2.6'],
|
|
39
|
+
['warn', { value: 'kimi-k2.6', warning: '' }],
|
|
40
|
+
['model-switched', { result: { value: 'kimi-k2.6', warning: '' }, value: 'kimi-k2.6' }],
|
|
41
|
+
['dispatch', 'Build the thing']
|
|
42
|
+
])
|
|
43
|
+
})
|
|
44
|
+
|
|
45
|
+
it('does not start a session for an empty prompt', async () => {
|
|
46
|
+
const calls: string[] = []
|
|
47
|
+
|
|
48
|
+
const sid = await startPromptLiveSession({
|
|
49
|
+
dispatchSubmission: () => calls.push('dispatch'),
|
|
50
|
+
maybeWarn: () => calls.push('warn'),
|
|
51
|
+
newLiveSession: async () => {
|
|
52
|
+
calls.push('new')
|
|
53
|
+
|
|
54
|
+
return 'abc123'
|
|
55
|
+
},
|
|
56
|
+
prompt: ' ',
|
|
57
|
+
rpc: async () => ({ value: 'unused' }),
|
|
58
|
+
sys: () => calls.push('sys')
|
|
59
|
+
})
|
|
60
|
+
|
|
61
|
+
expect(sid).toBeNull()
|
|
62
|
+
expect(calls).toEqual([])
|
|
63
|
+
})
|
|
64
|
+
})
|
|
@@ -0,0 +1,67 @@
|
|
|
1
|
+
import { afterEach, describe, expect, it, vi } from 'vitest'
|
|
2
|
+
|
|
3
|
+
import {
|
|
4
|
+
buildOsc52ClipboardQuery,
|
|
5
|
+
OSC52_CLIPBOARD_QUERY,
|
|
6
|
+
parseOsc52ClipboardData,
|
|
7
|
+
readOsc52Clipboard
|
|
8
|
+
} from '../lib/osc52.js'
|
|
9
|
+
|
|
10
|
+
const envBackup = { ...process.env }
|
|
11
|
+
|
|
12
|
+
afterEach(() => {
|
|
13
|
+
process.env = { ...envBackup }
|
|
14
|
+
})
|
|
15
|
+
|
|
16
|
+
describe('buildOsc52ClipboardQuery', () => {
|
|
17
|
+
it('returns the raw OSC52 query outside multiplexers', () => {
|
|
18
|
+
delete process.env.TMUX
|
|
19
|
+
delete process.env.STY
|
|
20
|
+
|
|
21
|
+
expect(buildOsc52ClipboardQuery()).toBe(OSC52_CLIPBOARD_QUERY)
|
|
22
|
+
})
|
|
23
|
+
|
|
24
|
+
it('wraps the query for tmux passthrough', () => {
|
|
25
|
+
process.env.TMUX = '/tmp/tmux-123/default,1,0'
|
|
26
|
+
|
|
27
|
+
expect(buildOsc52ClipboardQuery()).toContain('\x1bPtmux;')
|
|
28
|
+
expect(buildOsc52ClipboardQuery()).toContain(']52;c;?')
|
|
29
|
+
})
|
|
30
|
+
})
|
|
31
|
+
|
|
32
|
+
describe('parseOsc52ClipboardData', () => {
|
|
33
|
+
it('decodes clipboard payloads', () => {
|
|
34
|
+
const encoded = Buffer.from('hello from osc52', 'utf8').toString('base64')
|
|
35
|
+
|
|
36
|
+
expect(parseOsc52ClipboardData(`c;${encoded}`)).toBe('hello from osc52')
|
|
37
|
+
})
|
|
38
|
+
|
|
39
|
+
it('returns null for empty or query payloads', () => {
|
|
40
|
+
expect(parseOsc52ClipboardData('c;?')).toBeNull()
|
|
41
|
+
expect(parseOsc52ClipboardData('c;')).toBeNull()
|
|
42
|
+
})
|
|
43
|
+
})
|
|
44
|
+
|
|
45
|
+
describe('readOsc52Clipboard', () => {
|
|
46
|
+
it('returns decoded text from a terminal OSC52 response', async () => {
|
|
47
|
+
const send = vi.fn().mockResolvedValue({
|
|
48
|
+
code: 52,
|
|
49
|
+
data: `c;${Buffer.from('queried text', 'utf8').toString('base64')}`,
|
|
50
|
+
type: 'osc'
|
|
51
|
+
})
|
|
52
|
+
|
|
53
|
+
const flush = vi.fn().mockResolvedValue(undefined)
|
|
54
|
+
|
|
55
|
+
await expect(readOsc52Clipboard({ flush, send })).resolves.toBe('queried text')
|
|
56
|
+
expect(send).toHaveBeenCalled()
|
|
57
|
+
expect(flush).toHaveBeenCalled()
|
|
58
|
+
})
|
|
59
|
+
|
|
60
|
+
it('returns null when the querier is missing or unsupported', async () => {
|
|
61
|
+
await expect(readOsc52Clipboard(null)).resolves.toBeNull()
|
|
62
|
+
|
|
63
|
+
const send = vi.fn().mockResolvedValue(undefined)
|
|
64
|
+
const flush = vi.fn().mockResolvedValue(undefined)
|
|
65
|
+
await expect(readOsc52Clipboard({ flush, send })).resolves.toBeNull()
|
|
66
|
+
})
|
|
67
|
+
})
|
|
@@ -0,0 +1,75 @@
|
|
|
1
|
+
import { mkdtempSync, readFileSync, rmSync } from 'node:fs'
|
|
2
|
+
import { tmpdir } from 'node:os'
|
|
3
|
+
import { join } from 'node:path'
|
|
4
|
+
|
|
5
|
+
import { afterEach, beforeEach, describe, expect, it, vi } from 'vitest'
|
|
6
|
+
|
|
7
|
+
// parentLog gates itself off under VITEST so unit tests can't pollute a real
|
|
8
|
+
// ~/.nastech. To exercise the real persistence path we clear that gate, point
|
|
9
|
+
// NASTECH_HOME at a temp dir, and re-import the module fresh (path + enabled
|
|
10
|
+
// flag are captured at module load).
|
|
11
|
+
const loadFresh = async (home: string) => {
|
|
12
|
+
vi.resetModules()
|
|
13
|
+
vi.stubEnv('VITEST', '')
|
|
14
|
+
vi.stubEnv('NASTECH_HOME', home)
|
|
15
|
+
|
|
16
|
+
return import('../lib/parentLog.js')
|
|
17
|
+
}
|
|
18
|
+
|
|
19
|
+
describe('recordParentLifecycle', () => {
|
|
20
|
+
let home: string
|
|
21
|
+
|
|
22
|
+
beforeEach(() => {
|
|
23
|
+
home = mkdtempSync(join(tmpdir(), 'nastech-parentlog-'))
|
|
24
|
+
})
|
|
25
|
+
|
|
26
|
+
afterEach(() => {
|
|
27
|
+
vi.unstubAllEnvs()
|
|
28
|
+
rmSync(home, { force: true, recursive: true })
|
|
29
|
+
})
|
|
30
|
+
|
|
31
|
+
it('appends a timestamped breadcrumb to logs/tui_gateway_crash.log', async () => {
|
|
32
|
+
const { recordParentLifecycle } = await loadFresh(home)
|
|
33
|
+
|
|
34
|
+
recordParentLifecycle('graceful-exit received signal=SIGHUP → killing gateway')
|
|
35
|
+
|
|
36
|
+
const contents = readFileSync(join(home, 'logs', 'tui_gateway_crash.log'), 'utf8')
|
|
37
|
+
|
|
38
|
+
expect(contents).toContain('[tui-parent]')
|
|
39
|
+
expect(contents).toContain('graceful-exit received signal=SIGHUP → killing gateway')
|
|
40
|
+
expect(contents).toMatch(/\d{4}-\d{2}-\d{2}T/)
|
|
41
|
+
})
|
|
42
|
+
|
|
43
|
+
it('collapses embedded newlines so a value stays one breadcrumb', async () => {
|
|
44
|
+
const { recordParentLifecycle } = await loadFresh(home)
|
|
45
|
+
|
|
46
|
+
recordParentLifecycle('uncaughtException: boom\n at foo()\r\n at bar()')
|
|
47
|
+
|
|
48
|
+
const lines = readFileSync(join(home, 'logs', 'tui_gateway_crash.log'), 'utf8').trimEnd().split('\n')
|
|
49
|
+
|
|
50
|
+
expect(lines).toHaveLength(1)
|
|
51
|
+
expect(lines[0]).toContain('boom ↵ at foo() ↵ at bar()')
|
|
52
|
+
})
|
|
53
|
+
|
|
54
|
+
it('caps an oversized breadcrumb so it cannot bloat the shared crash log', async () => {
|
|
55
|
+
const { recordParentLifecycle } = await loadFresh(home)
|
|
56
|
+
|
|
57
|
+
recordParentLifecycle('x'.repeat(10_000))
|
|
58
|
+
|
|
59
|
+
const line = readFileSync(join(home, 'logs', 'tui_gateway_crash.log'), 'utf8')
|
|
60
|
+
|
|
61
|
+
expect(line).toContain('[truncated 10000 chars]')
|
|
62
|
+
expect(line.length).toBeLessThan(4_500)
|
|
63
|
+
})
|
|
64
|
+
|
|
65
|
+
it('is a no-op under VITEST so tests stay hermetic', async () => {
|
|
66
|
+
vi.resetModules()
|
|
67
|
+
vi.stubEnv('VITEST', 'true')
|
|
68
|
+
vi.stubEnv('NASTECH_HOME', home)
|
|
69
|
+
|
|
70
|
+
const { recordParentLifecycle } = await import('../lib/parentLog.js')
|
|
71
|
+
|
|
72
|
+
expect(() => recordParentLifecycle('should not be written')).not.toThrow()
|
|
73
|
+
expect(() => readFileSync(join(home, 'logs', 'tui_gateway_crash.log'), 'utf8')).toThrow()
|
|
74
|
+
})
|
|
75
|
+
})
|
|
@@ -0,0 +1,70 @@
|
|
|
1
|
+
import { afterEach, beforeEach, describe, expect, it } from 'vitest'
|
|
2
|
+
|
|
3
|
+
import { fmtCwdBranch, shortCwd } from '../domain/paths.js'
|
|
4
|
+
|
|
5
|
+
describe('shortCwd', () => {
|
|
6
|
+
const origHome = process.env.HOME
|
|
7
|
+
|
|
8
|
+
beforeEach(() => {
|
|
9
|
+
process.env.HOME = '/Users/bb'
|
|
10
|
+
})
|
|
11
|
+
|
|
12
|
+
afterEach(() => {
|
|
13
|
+
process.env.HOME = origHome
|
|
14
|
+
})
|
|
15
|
+
|
|
16
|
+
it('collapses HOME to ~', () => {
|
|
17
|
+
expect(shortCwd('/Users/bb/proj/repo')).toBe('~/proj/repo')
|
|
18
|
+
})
|
|
19
|
+
|
|
20
|
+
it('leaves non-HOME paths alone', () => {
|
|
21
|
+
expect(shortCwd('/tmp/work')).toBe('/tmp/work')
|
|
22
|
+
})
|
|
23
|
+
|
|
24
|
+
it('truncates long paths from the left with ellipsis', () => {
|
|
25
|
+
const out = shortCwd('/var/long/deeply/nested/workspace/here', 10)
|
|
26
|
+
expect(out.startsWith('…')).toBe(true)
|
|
27
|
+
expect(out.length).toBe(10)
|
|
28
|
+
expect('/var/long/deeply/nested/workspace/here'.endsWith(out.slice(1))).toBe(true)
|
|
29
|
+
})
|
|
30
|
+
|
|
31
|
+
it('keeps paths shorter than max intact', () => {
|
|
32
|
+
expect(shortCwd('/a/b', 10)).toBe('/a/b')
|
|
33
|
+
})
|
|
34
|
+
})
|
|
35
|
+
|
|
36
|
+
describe('fmtCwdBranch', () => {
|
|
37
|
+
const origHome = process.env.HOME
|
|
38
|
+
|
|
39
|
+
beforeEach(() => {
|
|
40
|
+
process.env.HOME = '/Users/bb'
|
|
41
|
+
})
|
|
42
|
+
|
|
43
|
+
afterEach(() => {
|
|
44
|
+
process.env.HOME = origHome
|
|
45
|
+
})
|
|
46
|
+
|
|
47
|
+
it('returns bare cwd when branch is null', () => {
|
|
48
|
+
expect(fmtCwdBranch('/Users/bb/proj', null)).toBe('~/proj')
|
|
49
|
+
})
|
|
50
|
+
|
|
51
|
+
it('returns bare cwd when branch is empty', () => {
|
|
52
|
+
expect(fmtCwdBranch('/Users/bb/proj', '')).toBe('~/proj')
|
|
53
|
+
})
|
|
54
|
+
|
|
55
|
+
it('appends branch in parens', () => {
|
|
56
|
+
expect(fmtCwdBranch('/Users/bb/proj', 'main')).toBe('~/proj (main)')
|
|
57
|
+
})
|
|
58
|
+
|
|
59
|
+
it('truncates the path to keep the branch tag readable', () => {
|
|
60
|
+
const out = fmtCwdBranch('/Users/bb/very/deeply/nested/project/folder', 'feature-branch', 30)
|
|
61
|
+
expect(out).toMatch(/ \(feature-branch\)$/)
|
|
62
|
+
expect(out.length).toBeLessThanOrEqual(30)
|
|
63
|
+
})
|
|
64
|
+
|
|
65
|
+
it('truncates very long branch names from the right', () => {
|
|
66
|
+
const out = fmtCwdBranch('/Users/bb/p', 'a-very-long-feature-branch-name')
|
|
67
|
+
expect(out).toMatch(/^~\/p \(…/)
|
|
68
|
+
expect(out).toContain(')')
|
|
69
|
+
})
|
|
70
|
+
})
|