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,407 @@
|
|
|
1
|
+
import { describe, expect, it } from 'vitest'
|
|
2
|
+
|
|
3
|
+
import {
|
|
4
|
+
buildSubagentTree,
|
|
5
|
+
descendantIds,
|
|
6
|
+
flattenTree,
|
|
7
|
+
fmtCost,
|
|
8
|
+
fmtDuration,
|
|
9
|
+
fmtTokens,
|
|
10
|
+
formatSummary,
|
|
11
|
+
hotnessBucket,
|
|
12
|
+
peakHotness,
|
|
13
|
+
sparkline,
|
|
14
|
+
topLevelSubagents,
|
|
15
|
+
treeTotals,
|
|
16
|
+
widthByDepth
|
|
17
|
+
} from '../lib/subagentTree.js'
|
|
18
|
+
import type { SubagentProgress } from '../types.js'
|
|
19
|
+
|
|
20
|
+
const makeItem = (overrides: Partial<SubagentProgress> & Pick<SubagentProgress, 'id' | 'index'>): SubagentProgress => ({
|
|
21
|
+
depth: 0,
|
|
22
|
+
goal: overrides.id,
|
|
23
|
+
notes: [],
|
|
24
|
+
parentId: null,
|
|
25
|
+
status: 'running',
|
|
26
|
+
taskCount: 1,
|
|
27
|
+
thinking: [],
|
|
28
|
+
toolCount: 0,
|
|
29
|
+
tools: [],
|
|
30
|
+
...overrides
|
|
31
|
+
})
|
|
32
|
+
|
|
33
|
+
describe('aggregate: tokens, cost, files, hotness', () => {
|
|
34
|
+
it('sums tokens and cost across subtree', () => {
|
|
35
|
+
const items = [
|
|
36
|
+
makeItem({ costUsd: 0.01, id: 'p', index: 0, inputTokens: 1000, outputTokens: 500 }),
|
|
37
|
+
makeItem({
|
|
38
|
+
costUsd: 0.005,
|
|
39
|
+
depth: 1,
|
|
40
|
+
id: 'c1',
|
|
41
|
+
index: 0,
|
|
42
|
+
inputTokens: 500,
|
|
43
|
+
outputTokens: 100,
|
|
44
|
+
parentId: 'p'
|
|
45
|
+
}),
|
|
46
|
+
makeItem({
|
|
47
|
+
costUsd: 0.008,
|
|
48
|
+
depth: 1,
|
|
49
|
+
id: 'c2',
|
|
50
|
+
index: 1,
|
|
51
|
+
inputTokens: 300,
|
|
52
|
+
outputTokens: 200,
|
|
53
|
+
parentId: 'p'
|
|
54
|
+
})
|
|
55
|
+
]
|
|
56
|
+
|
|
57
|
+
const tree = buildSubagentTree(items)
|
|
58
|
+
expect(tree[0]!.aggregate).toMatchObject({
|
|
59
|
+
costUsd: 0.023,
|
|
60
|
+
inputTokens: 1800,
|
|
61
|
+
outputTokens: 800
|
|
62
|
+
})
|
|
63
|
+
})
|
|
64
|
+
|
|
65
|
+
it('counts files read + written across subtree', () => {
|
|
66
|
+
const items = [
|
|
67
|
+
makeItem({ filesRead: ['a.ts', 'b.ts'], id: 'p', index: 0 }),
|
|
68
|
+
makeItem({ depth: 1, filesWritten: ['c.ts'], id: 'c', index: 0, parentId: 'p' })
|
|
69
|
+
]
|
|
70
|
+
|
|
71
|
+
const tree = buildSubagentTree(items)
|
|
72
|
+
expect(tree[0]!.aggregate.filesTouched).toBe(3)
|
|
73
|
+
})
|
|
74
|
+
|
|
75
|
+
it('hotness = totalTools / totalDuration', () => {
|
|
76
|
+
const items = [
|
|
77
|
+
makeItem({
|
|
78
|
+
durationSeconds: 10,
|
|
79
|
+
id: 'p',
|
|
80
|
+
index: 0,
|
|
81
|
+
status: 'completed',
|
|
82
|
+
toolCount: 20
|
|
83
|
+
})
|
|
84
|
+
]
|
|
85
|
+
|
|
86
|
+
const tree = buildSubagentTree(items)
|
|
87
|
+
expect(tree[0]!.aggregate.hotness).toBeCloseTo(2)
|
|
88
|
+
})
|
|
89
|
+
|
|
90
|
+
it('hotness is zero when duration is zero', () => {
|
|
91
|
+
const items = [makeItem({ id: 'p', index: 0, toolCount: 10 })]
|
|
92
|
+
const tree = buildSubagentTree(items)
|
|
93
|
+
expect(tree[0]!.aggregate.hotness).toBe(0)
|
|
94
|
+
})
|
|
95
|
+
})
|
|
96
|
+
|
|
97
|
+
describe('hotnessBucket + peakHotness', () => {
|
|
98
|
+
it('peakHotness walks subtree', () => {
|
|
99
|
+
const items = [
|
|
100
|
+
makeItem({ durationSeconds: 100, id: 'p', index: 0, status: 'completed', toolCount: 1 }),
|
|
101
|
+
makeItem({
|
|
102
|
+
depth: 1,
|
|
103
|
+
durationSeconds: 1,
|
|
104
|
+
id: 'c',
|
|
105
|
+
index: 0,
|
|
106
|
+
parentId: 'p',
|
|
107
|
+
status: 'completed',
|
|
108
|
+
toolCount: 5
|
|
109
|
+
})
|
|
110
|
+
]
|
|
111
|
+
|
|
112
|
+
const tree = buildSubagentTree(items)
|
|
113
|
+
expect(peakHotness(tree)).toBeGreaterThan(2)
|
|
114
|
+
})
|
|
115
|
+
|
|
116
|
+
it('hotnessBucket clamps and normalizes', () => {
|
|
117
|
+
expect(hotnessBucket(0, 10, 4)).toBe(0)
|
|
118
|
+
expect(hotnessBucket(10, 10, 4)).toBe(3)
|
|
119
|
+
expect(hotnessBucket(5, 10, 4)).toBe(2)
|
|
120
|
+
expect(hotnessBucket(100, 10, 4)).toBe(3) // clamped
|
|
121
|
+
expect(hotnessBucket(5, 0, 4)).toBe(0) // guard against divide-by-zero
|
|
122
|
+
})
|
|
123
|
+
})
|
|
124
|
+
|
|
125
|
+
describe('fmtCost + fmtTokens', () => {
|
|
126
|
+
it('fmtCost handles ranges', () => {
|
|
127
|
+
expect(fmtCost(0)).toBe('')
|
|
128
|
+
expect(fmtCost(0.001)).toBe('<$0.01')
|
|
129
|
+
expect(fmtCost(0.42)).toBe('$0.42')
|
|
130
|
+
expect(fmtCost(1.23)).toBe('$1.23')
|
|
131
|
+
expect(fmtCost(12.5)).toBe('$12.5')
|
|
132
|
+
})
|
|
133
|
+
|
|
134
|
+
it('fmtTokens handles ranges', () => {
|
|
135
|
+
expect(fmtTokens(0)).toBe('0')
|
|
136
|
+
expect(fmtTokens(542)).toBe('542')
|
|
137
|
+
expect(fmtTokens(1234)).toBe('1.2k')
|
|
138
|
+
expect(fmtTokens(45678)).toBe('46k')
|
|
139
|
+
})
|
|
140
|
+
})
|
|
141
|
+
|
|
142
|
+
describe('formatSummary with tokens + cost', () => {
|
|
143
|
+
it('includes token + cost when present', () => {
|
|
144
|
+
expect(
|
|
145
|
+
formatSummary({
|
|
146
|
+
activeCount: 0,
|
|
147
|
+
costUsd: 0.42,
|
|
148
|
+
descendantCount: 3,
|
|
149
|
+
filesTouched: 0,
|
|
150
|
+
hotness: 0,
|
|
151
|
+
inputTokens: 8000,
|
|
152
|
+
maxDepthFromHere: 2,
|
|
153
|
+
outputTokens: 2000,
|
|
154
|
+
totalDuration: 30,
|
|
155
|
+
totalTools: 14
|
|
156
|
+
})
|
|
157
|
+
).toBe('d2 · 3 agents · 14 tools · 30s · 10k tok · $0.42')
|
|
158
|
+
})
|
|
159
|
+
})
|
|
160
|
+
|
|
161
|
+
describe('buildSubagentTree', () => {
|
|
162
|
+
it('returns empty list for empty input', () => {
|
|
163
|
+
expect(buildSubagentTree([])).toEqual([])
|
|
164
|
+
})
|
|
165
|
+
|
|
166
|
+
it('treats flat list as top-level when no parentId is given', () => {
|
|
167
|
+
const items = [makeItem({ id: 'a', index: 0 }), makeItem({ id: 'b', index: 1 }), makeItem({ id: 'c', index: 2 })]
|
|
168
|
+
|
|
169
|
+
const tree = buildSubagentTree(items)
|
|
170
|
+
expect(tree).toHaveLength(3)
|
|
171
|
+
expect(tree.map(n => n.item.id)).toEqual(['a', 'b', 'c'])
|
|
172
|
+
expect(tree.every(n => n.children.length === 0)).toBe(true)
|
|
173
|
+
})
|
|
174
|
+
|
|
175
|
+
it('nests children under their parent by subagent_id', () => {
|
|
176
|
+
const items = [
|
|
177
|
+
makeItem({ id: 'parent', index: 0 }),
|
|
178
|
+
makeItem({ depth: 1, id: 'child-1', index: 0, parentId: 'parent' }),
|
|
179
|
+
makeItem({ depth: 1, id: 'child-2', index: 1, parentId: 'parent' })
|
|
180
|
+
]
|
|
181
|
+
|
|
182
|
+
const tree = buildSubagentTree(items)
|
|
183
|
+
expect(tree).toHaveLength(1)
|
|
184
|
+
expect(tree[0]!.children).toHaveLength(2)
|
|
185
|
+
expect(tree[0]!.children.map(n => n.item.id)).toEqual(['child-1', 'child-2'])
|
|
186
|
+
})
|
|
187
|
+
|
|
188
|
+
it('builds multi-level nesting', () => {
|
|
189
|
+
const items = [
|
|
190
|
+
makeItem({ id: 'p', index: 0 }),
|
|
191
|
+
makeItem({ depth: 1, id: 'c', index: 0, parentId: 'p' }),
|
|
192
|
+
makeItem({ depth: 2, id: 'gc', index: 0, parentId: 'c' })
|
|
193
|
+
]
|
|
194
|
+
|
|
195
|
+
const tree = buildSubagentTree(items)
|
|
196
|
+
expect(tree[0]!.children[0]!.children[0]!.item.id).toBe('gc')
|
|
197
|
+
expect(tree[0]!.aggregate.maxDepthFromHere).toBe(2)
|
|
198
|
+
expect(tree[0]!.aggregate.descendantCount).toBe(2)
|
|
199
|
+
})
|
|
200
|
+
|
|
201
|
+
it('promotes orphaned children (missing parent) to top level', () => {
|
|
202
|
+
const items = [makeItem({ id: 'a', index: 0 }), makeItem({ depth: 1, id: 'orphan', index: 1, parentId: 'ghost' })]
|
|
203
|
+
|
|
204
|
+
const tree = buildSubagentTree(items)
|
|
205
|
+
expect(tree).toHaveLength(2)
|
|
206
|
+
expect(tree.map(n => n.item.id)).toEqual(['a', 'orphan'])
|
|
207
|
+
})
|
|
208
|
+
|
|
209
|
+
it('stable sort: children ordered by (depth, index) not insert order', () => {
|
|
210
|
+
const items = [
|
|
211
|
+
makeItem({ id: 'p', index: 0 }),
|
|
212
|
+
makeItem({ depth: 1, id: 'c3', index: 2, parentId: 'p' }),
|
|
213
|
+
makeItem({ depth: 1, id: 'c1', index: 0, parentId: 'p' }),
|
|
214
|
+
makeItem({ depth: 1, id: 'c2', index: 1, parentId: 'p' })
|
|
215
|
+
]
|
|
216
|
+
|
|
217
|
+
const tree = buildSubagentTree(items)
|
|
218
|
+
expect(tree[0]!.children.map(n => n.item.id)).toEqual(['c1', 'c2', 'c3'])
|
|
219
|
+
})
|
|
220
|
+
})
|
|
221
|
+
|
|
222
|
+
describe('aggregate', () => {
|
|
223
|
+
it('sums tool counts and durations across subtree', () => {
|
|
224
|
+
const items = [
|
|
225
|
+
makeItem({ durationSeconds: 10, id: 'p', index: 0, status: 'completed', toolCount: 5 }),
|
|
226
|
+
makeItem({ depth: 1, durationSeconds: 4, id: 'c1', index: 0, parentId: 'p', status: 'completed', toolCount: 3 }),
|
|
227
|
+
makeItem({ depth: 1, durationSeconds: 2, id: 'c2', index: 1, parentId: 'p', status: 'completed', toolCount: 1 })
|
|
228
|
+
]
|
|
229
|
+
|
|
230
|
+
const tree = buildSubagentTree(items)
|
|
231
|
+
expect(tree[0]!.aggregate).toMatchObject({
|
|
232
|
+
activeCount: 0,
|
|
233
|
+
descendantCount: 2,
|
|
234
|
+
totalDuration: 16,
|
|
235
|
+
totalTools: 9
|
|
236
|
+
})
|
|
237
|
+
})
|
|
238
|
+
|
|
239
|
+
it('counts queued + running as active', () => {
|
|
240
|
+
const items = [
|
|
241
|
+
makeItem({ id: 'p', index: 0, status: 'running' }),
|
|
242
|
+
makeItem({ depth: 1, id: 'c1', index: 0, parentId: 'p', status: 'queued' }),
|
|
243
|
+
makeItem({ depth: 1, id: 'c2', index: 1, parentId: 'p', status: 'completed' })
|
|
244
|
+
]
|
|
245
|
+
|
|
246
|
+
const tree = buildSubagentTree(items)
|
|
247
|
+
expect(tree[0]!.aggregate.activeCount).toBe(2)
|
|
248
|
+
})
|
|
249
|
+
})
|
|
250
|
+
|
|
251
|
+
describe('widthByDepth', () => {
|
|
252
|
+
it('returns empty array for empty tree', () => {
|
|
253
|
+
expect(widthByDepth([])).toEqual([])
|
|
254
|
+
})
|
|
255
|
+
|
|
256
|
+
it('tallies nodes at each depth', () => {
|
|
257
|
+
const items = [
|
|
258
|
+
makeItem({ id: 'p1', index: 0 }),
|
|
259
|
+
makeItem({ id: 'p2', index: 1 }),
|
|
260
|
+
makeItem({ depth: 1, id: 'c1', index: 0, parentId: 'p1' }),
|
|
261
|
+
makeItem({ depth: 1, id: 'c2', index: 1, parentId: 'p1' }),
|
|
262
|
+
makeItem({ depth: 1, id: 'c3', index: 0, parentId: 'p2' }),
|
|
263
|
+
makeItem({ depth: 2, id: 'gc1', index: 0, parentId: 'c1' })
|
|
264
|
+
]
|
|
265
|
+
|
|
266
|
+
expect(widthByDepth(buildSubagentTree(items))).toEqual([2, 3, 1])
|
|
267
|
+
})
|
|
268
|
+
})
|
|
269
|
+
|
|
270
|
+
describe('treeTotals', () => {
|
|
271
|
+
it('folds a full tree into a single rollup', () => {
|
|
272
|
+
const items = [
|
|
273
|
+
makeItem({ id: 'p1', index: 0, toolCount: 5 }),
|
|
274
|
+
makeItem({ id: 'p2', index: 1, toolCount: 2 }),
|
|
275
|
+
makeItem({ depth: 1, id: 'c', index: 0, parentId: 'p1', toolCount: 3 })
|
|
276
|
+
]
|
|
277
|
+
|
|
278
|
+
const totals = treeTotals(buildSubagentTree(items))
|
|
279
|
+
expect(totals.descendantCount).toBe(3)
|
|
280
|
+
expect(totals.totalTools).toBe(10)
|
|
281
|
+
expect(totals.maxDepthFromHere).toBe(2)
|
|
282
|
+
})
|
|
283
|
+
|
|
284
|
+
it('returns zeros for empty tree', () => {
|
|
285
|
+
expect(treeTotals([])).toEqual({
|
|
286
|
+
activeCount: 0,
|
|
287
|
+
costUsd: 0,
|
|
288
|
+
descendantCount: 0,
|
|
289
|
+
filesTouched: 0,
|
|
290
|
+
hotness: 0,
|
|
291
|
+
inputTokens: 0,
|
|
292
|
+
maxDepthFromHere: 0,
|
|
293
|
+
outputTokens: 0,
|
|
294
|
+
totalDuration: 0,
|
|
295
|
+
totalTools: 0
|
|
296
|
+
})
|
|
297
|
+
})
|
|
298
|
+
})
|
|
299
|
+
|
|
300
|
+
describe('flattenTree + descendantIds', () => {
|
|
301
|
+
const items = [
|
|
302
|
+
makeItem({ id: 'p', index: 0 }),
|
|
303
|
+
makeItem({ depth: 1, id: 'c1', index: 0, parentId: 'p' }),
|
|
304
|
+
makeItem({ depth: 2, id: 'gc', index: 0, parentId: 'c1' }),
|
|
305
|
+
makeItem({ depth: 1, id: 'c2', index: 1, parentId: 'p' })
|
|
306
|
+
]
|
|
307
|
+
|
|
308
|
+
it('flattens in visit order (depth-first, pre-order)', () => {
|
|
309
|
+
const tree = buildSubagentTree(items)
|
|
310
|
+
expect(flattenTree(tree).map(n => n.item.id)).toEqual(['p', 'c1', 'gc', 'c2'])
|
|
311
|
+
})
|
|
312
|
+
|
|
313
|
+
it('collects descendant ids excluding the node itself', () => {
|
|
314
|
+
const tree = buildSubagentTree(items)
|
|
315
|
+
expect(descendantIds(tree[0]!)).toEqual(['c1', 'gc', 'c2'])
|
|
316
|
+
})
|
|
317
|
+
})
|
|
318
|
+
|
|
319
|
+
describe('sparkline', () => {
|
|
320
|
+
it('returns empty string for empty input', () => {
|
|
321
|
+
expect(sparkline([])).toBe('')
|
|
322
|
+
})
|
|
323
|
+
|
|
324
|
+
it('renders zeroes as spaces (not bottom glyph)', () => {
|
|
325
|
+
expect(sparkline([0, 0])).toBe(' ')
|
|
326
|
+
})
|
|
327
|
+
|
|
328
|
+
it('scales to the max value', () => {
|
|
329
|
+
const out = sparkline([1, 8])
|
|
330
|
+
expect(out).toHaveLength(2)
|
|
331
|
+
expect(out[1]).toBe('█')
|
|
332
|
+
})
|
|
333
|
+
|
|
334
|
+
it('sparse widths render as expected', () => {
|
|
335
|
+
const out = sparkline([2, 3, 7, 4])
|
|
336
|
+
expect(out).toHaveLength(4)
|
|
337
|
+
expect([...out].every(ch => /[\s▁-█]/.test(ch))).toBe(true)
|
|
338
|
+
})
|
|
339
|
+
})
|
|
340
|
+
|
|
341
|
+
describe('formatSummary', () => {
|
|
342
|
+
const emptyTotals = {
|
|
343
|
+
activeCount: 0,
|
|
344
|
+
costUsd: 0,
|
|
345
|
+
descendantCount: 0,
|
|
346
|
+
filesTouched: 0,
|
|
347
|
+
hotness: 0,
|
|
348
|
+
inputTokens: 0,
|
|
349
|
+
maxDepthFromHere: 0,
|
|
350
|
+
outputTokens: 0,
|
|
351
|
+
totalDuration: 0,
|
|
352
|
+
totalTools: 0
|
|
353
|
+
}
|
|
354
|
+
|
|
355
|
+
it('collapses zero-valued components', () => {
|
|
356
|
+
expect(formatSummary({ ...emptyTotals, descendantCount: 1 })).toBe('d0 · 1 agent')
|
|
357
|
+
})
|
|
358
|
+
|
|
359
|
+
it('emits rich summary with all pieces', () => {
|
|
360
|
+
expect(
|
|
361
|
+
formatSummary({
|
|
362
|
+
...emptyTotals,
|
|
363
|
+
activeCount: 2,
|
|
364
|
+
descendantCount: 7,
|
|
365
|
+
maxDepthFromHere: 3,
|
|
366
|
+
totalDuration: 134,
|
|
367
|
+
totalTools: 124
|
|
368
|
+
})
|
|
369
|
+
).toBe('d3 · 7 agents · 124 tools · 2m 14s · ⚡2')
|
|
370
|
+
})
|
|
371
|
+
})
|
|
372
|
+
|
|
373
|
+
describe('fmtDuration', () => {
|
|
374
|
+
it('formats under a minute as plain seconds', () => {
|
|
375
|
+
expect(fmtDuration(0)).toBe('0s')
|
|
376
|
+
expect(fmtDuration(42)).toBe('42s')
|
|
377
|
+
expect(fmtDuration(59.4)).toBe('59s')
|
|
378
|
+
})
|
|
379
|
+
|
|
380
|
+
it('formats whole minutes without trailing seconds', () => {
|
|
381
|
+
expect(fmtDuration(60)).toBe('1m')
|
|
382
|
+
expect(fmtDuration(180)).toBe('3m')
|
|
383
|
+
})
|
|
384
|
+
|
|
385
|
+
it('mixes minutes and seconds', () => {
|
|
386
|
+
expect(fmtDuration(134)).toBe('2m 14s')
|
|
387
|
+
expect(fmtDuration(605)).toBe('10m 5s')
|
|
388
|
+
})
|
|
389
|
+
})
|
|
390
|
+
|
|
391
|
+
describe('topLevelSubagents', () => {
|
|
392
|
+
it('returns items with no parent', () => {
|
|
393
|
+
const items = [makeItem({ id: 'a', index: 0 }), makeItem({ id: 'b', index: 1 })]
|
|
394
|
+
expect(topLevelSubagents(items).map(s => s.id)).toEqual(['a', 'b'])
|
|
395
|
+
})
|
|
396
|
+
|
|
397
|
+
it('excludes children whose parent is present', () => {
|
|
398
|
+
const items = [makeItem({ id: 'p', index: 0 }), makeItem({ depth: 1, id: 'c', index: 0, parentId: 'p' })]
|
|
399
|
+
|
|
400
|
+
expect(topLevelSubagents(items).map(s => s.id)).toEqual(['p'])
|
|
401
|
+
})
|
|
402
|
+
|
|
403
|
+
it('promotes orphans whose parent is missing', () => {
|
|
404
|
+
const items = [makeItem({ id: 'a', index: 0 }), makeItem({ depth: 1, id: 'orphan', index: 1, parentId: 'ghost' })]
|
|
405
|
+
expect(topLevelSubagents(items).map(s => s.id)).toEqual(['a', 'orphan'])
|
|
406
|
+
})
|
|
407
|
+
})
|
|
@@ -0,0 +1,45 @@
|
|
|
1
|
+
import { describe, expect, it } from 'vitest'
|
|
2
|
+
|
|
3
|
+
import { highlightLine, isHighlightable } from '../lib/syntax.js'
|
|
4
|
+
import { DEFAULT_THEME } from '../theme.js'
|
|
5
|
+
|
|
6
|
+
const t = DEFAULT_THEME
|
|
7
|
+
|
|
8
|
+
describe('syntax highlighter', () => {
|
|
9
|
+
it('recognizes supported langs and aliases', () => {
|
|
10
|
+
expect(isHighlightable('ts')).toBe(true)
|
|
11
|
+
expect(isHighlightable('js')).toBe(true)
|
|
12
|
+
expect(isHighlightable('python')).toBe(true)
|
|
13
|
+
expect(isHighlightable('rs')).toBe(true)
|
|
14
|
+
expect(isHighlightable('bash')).toBe(true)
|
|
15
|
+
expect(isHighlightable('whatever')).toBe(false)
|
|
16
|
+
expect(isHighlightable('')).toBe(false)
|
|
17
|
+
})
|
|
18
|
+
|
|
19
|
+
it('paints a whole-line comment dim', () => {
|
|
20
|
+
const tokens = highlightLine('// hello', 'ts', t)
|
|
21
|
+
|
|
22
|
+
expect(tokens).toEqual([[t.color.muted, '// hello']])
|
|
23
|
+
})
|
|
24
|
+
|
|
25
|
+
it('paints keywords, strings, and numbers in a ts line', () => {
|
|
26
|
+
const tokens = highlightLine(`const x = 'hi' + 42`, 'ts', t)
|
|
27
|
+
const colors = tokens.map(tok => tok[0])
|
|
28
|
+
|
|
29
|
+
expect(colors).toContain(t.color.border) // const
|
|
30
|
+
expect(colors).toContain(t.color.accent) // 'hi'
|
|
31
|
+
expect(colors).toContain(t.color.text) // 42
|
|
32
|
+
})
|
|
33
|
+
|
|
34
|
+
it('falls through unchanged for unknown langs', () => {
|
|
35
|
+
const tokens = highlightLine(`const x = 1`, 'zzz', t)
|
|
36
|
+
|
|
37
|
+
expect(tokens).toEqual([['', 'const x = 1']])
|
|
38
|
+
})
|
|
39
|
+
|
|
40
|
+
it('treats `#` as a python comment, not a selector', () => {
|
|
41
|
+
const tokens = highlightLine('# comment', 'py', t)
|
|
42
|
+
|
|
43
|
+
expect(tokens).toEqual([[t.color.muted, '# comment']])
|
|
44
|
+
})
|
|
45
|
+
})
|
|
@@ -0,0 +1,39 @@
|
|
|
1
|
+
import { describe, expect, it, vi } from 'vitest'
|
|
2
|
+
|
|
3
|
+
import { resetTerminalModes, TERMINAL_MODE_RESET } from '../lib/terminalModes.js'
|
|
4
|
+
|
|
5
|
+
describe('terminal mode reset', () => {
|
|
6
|
+
it('includes common sticky input modes', () => {
|
|
7
|
+
expect(TERMINAL_MODE_RESET).toContain('\x1b[0\'z')
|
|
8
|
+
expect(TERMINAL_MODE_RESET).toContain('\x1b[0\'{')
|
|
9
|
+
expect(TERMINAL_MODE_RESET).toContain('\x1b[?2029l')
|
|
10
|
+
expect(TERMINAL_MODE_RESET).toContain('\x1b[?1016l')
|
|
11
|
+
expect(TERMINAL_MODE_RESET).toContain('\x1b[?1015l')
|
|
12
|
+
expect(TERMINAL_MODE_RESET).toContain('\x1b[?1006l')
|
|
13
|
+
expect(TERMINAL_MODE_RESET).toContain('\x1b[?1005l')
|
|
14
|
+
expect(TERMINAL_MODE_RESET).toContain('\x1b[?1003l')
|
|
15
|
+
expect(TERMINAL_MODE_RESET).toContain('\x1b[?1002l')
|
|
16
|
+
expect(TERMINAL_MODE_RESET).toContain('\x1b[?1001l')
|
|
17
|
+
expect(TERMINAL_MODE_RESET).toContain('\x1b[?1000l')
|
|
18
|
+
expect(TERMINAL_MODE_RESET).toContain('\x1b[?9l')
|
|
19
|
+
expect(TERMINAL_MODE_RESET).toContain('\x1b[?1004l')
|
|
20
|
+
expect(TERMINAL_MODE_RESET).toContain('\x1b[?2004l')
|
|
21
|
+
expect(TERMINAL_MODE_RESET).toContain('\x1b[?1049l')
|
|
22
|
+
expect(TERMINAL_MODE_RESET).toContain('\x1b[<u')
|
|
23
|
+
expect(TERMINAL_MODE_RESET).toContain('\x1b[>4m')
|
|
24
|
+
})
|
|
25
|
+
|
|
26
|
+
it('writes reset sequence to TTY streams without fds', () => {
|
|
27
|
+
const write = vi.fn()
|
|
28
|
+
|
|
29
|
+
expect(resetTerminalModes({ isTTY: true, write } as unknown as NodeJS.WriteStream)).toBe(true)
|
|
30
|
+
expect(write).toHaveBeenCalledWith(TERMINAL_MODE_RESET)
|
|
31
|
+
})
|
|
32
|
+
|
|
33
|
+
it('skips non-TTY streams', () => {
|
|
34
|
+
const write = vi.fn()
|
|
35
|
+
|
|
36
|
+
expect(resetTerminalModes({ isTTY: false, write } as unknown as NodeJS.WriteStream)).toBe(false)
|
|
37
|
+
expect(write).not.toHaveBeenCalled()
|
|
38
|
+
})
|
|
39
|
+
})
|
|
@@ -0,0 +1,77 @@
|
|
|
1
|
+
import { describe, expect, it, vi } from 'vitest'
|
|
2
|
+
|
|
3
|
+
import { terminalParityHints } from '../lib/terminalParity.js'
|
|
4
|
+
|
|
5
|
+
describe('terminalParityHints', () => {
|
|
6
|
+
it('warns for Apple Terminal and SSH/tmux sessions', async () => {
|
|
7
|
+
const hints = await terminalParityHints({
|
|
8
|
+
TERM_PROGRAM: 'Apple_Terminal',
|
|
9
|
+
TERM_SESSION_ID: 'w0t0p0:123',
|
|
10
|
+
SSH_CONNECTION: '1',
|
|
11
|
+
TMUX: '/tmp/tmux-1/default,1,0'
|
|
12
|
+
} as NodeJS.ProcessEnv)
|
|
13
|
+
|
|
14
|
+
expect(hints.map(h => h.key)).toEqual(expect.arrayContaining(['apple-terminal', 'remote', 'tmux']))
|
|
15
|
+
})
|
|
16
|
+
|
|
17
|
+
it('suggests IDE setup only for VS Code-family terminals that still need bindings', async () => {
|
|
18
|
+
const readFile = vi.fn().mockRejectedValue(Object.assign(new Error('missing'), { code: 'ENOENT' }))
|
|
19
|
+
|
|
20
|
+
const hints = await terminalParityHints({ TERM_PROGRAM: 'vscode' } as NodeJS.ProcessEnv, {
|
|
21
|
+
fileOps: { readFile },
|
|
22
|
+
homeDir: '/tmp/fake-home'
|
|
23
|
+
})
|
|
24
|
+
|
|
25
|
+
expect(hints.some(h => h.key === 'ide-setup')).toBe(true)
|
|
26
|
+
})
|
|
27
|
+
|
|
28
|
+
it('suppresses IDE setup hint when keybindings are already configured', async () => {
|
|
29
|
+
const readFile = vi.fn().mockResolvedValue(
|
|
30
|
+
JSON.stringify([
|
|
31
|
+
{
|
|
32
|
+
key: 'cmd+c',
|
|
33
|
+
command: 'workbench.action.terminal.sendSequence',
|
|
34
|
+
when: 'terminalFocus && terminalTextSelected',
|
|
35
|
+
args: { text: '\u001b[99;13u' }
|
|
36
|
+
},
|
|
37
|
+
{
|
|
38
|
+
key: 'shift+enter',
|
|
39
|
+
command: 'workbench.action.terminal.sendSequence',
|
|
40
|
+
when: 'terminalFocus',
|
|
41
|
+
args: { text: '\\\r\n' }
|
|
42
|
+
},
|
|
43
|
+
{
|
|
44
|
+
key: 'ctrl+enter',
|
|
45
|
+
command: 'workbench.action.terminal.sendSequence',
|
|
46
|
+
when: 'terminalFocus',
|
|
47
|
+
args: { text: '\\\r\n' }
|
|
48
|
+
},
|
|
49
|
+
{
|
|
50
|
+
key: 'cmd+enter',
|
|
51
|
+
command: 'workbench.action.terminal.sendSequence',
|
|
52
|
+
when: 'terminalFocus',
|
|
53
|
+
args: { text: '\\\r\n' }
|
|
54
|
+
},
|
|
55
|
+
{
|
|
56
|
+
key: 'cmd+z',
|
|
57
|
+
command: 'workbench.action.terminal.sendSequence',
|
|
58
|
+
when: 'terminalFocus',
|
|
59
|
+
args: { text: '\u001b[122;9u' }
|
|
60
|
+
},
|
|
61
|
+
{
|
|
62
|
+
key: 'shift+cmd+z',
|
|
63
|
+
command: 'workbench.action.terminal.sendSequence',
|
|
64
|
+
when: 'terminalFocus',
|
|
65
|
+
args: { text: '\u001b[122;10u' }
|
|
66
|
+
}
|
|
67
|
+
])
|
|
68
|
+
)
|
|
69
|
+
|
|
70
|
+
const hints = await terminalParityHints({ TERM_PROGRAM: 'vscode' } as NodeJS.ProcessEnv, {
|
|
71
|
+
fileOps: { readFile },
|
|
72
|
+
homeDir: '/tmp/fake-home'
|
|
73
|
+
})
|
|
74
|
+
|
|
75
|
+
expect(hints.some(h => h.key === 'ide-setup')).toBe(false)
|
|
76
|
+
})
|
|
77
|
+
})
|