@onpoint-dev-tools/crewcoder-opentui 0.0.0-stage → 0.1.0
This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
- package/LICENSE +191 -0
- package/README.md +262 -2
- package/THIRD_PARTY_NOTICES.md +51 -0
- package/dist/App.d.ts +16 -0
- package/dist/App.d.ts.map +1 -0
- package/dist/App.js +428 -0
- package/dist/App.js.map +1 -0
- package/dist/Root.d.ts +11 -0
- package/dist/Root.d.ts.map +1 -0
- package/dist/Root.js +13 -0
- package/dist/Root.js.map +1 -0
- package/dist/alert-model.d.ts +31 -0
- package/dist/alert-model.d.ts.map +1 -0
- package/dist/alert-model.js +34 -0
- package/dist/alert-model.js.map +1 -0
- package/dist/args.d.ts +13 -0
- package/dist/args.d.ts.map +1 -0
- package/dist/args.js +63 -0
- package/dist/args.js.map +1 -0
- package/dist/attachments.d.ts +29 -0
- package/dist/attachments.d.ts.map +1 -0
- package/dist/attachments.js +38 -0
- package/dist/attachments.js.map +1 -0
- package/dist/block-panels.d.ts +43 -0
- package/dist/block-panels.d.ts.map +1 -0
- package/dist/block-panels.js +210 -0
- package/dist/block-panels.js.map +1 -0
- package/dist/cli.d.ts +3 -0
- package/dist/cli.d.ts.map +1 -0
- package/dist/cli.js +138 -0
- package/dist/cli.js.map +1 -0
- package/dist/command-format.d.ts +18 -0
- package/dist/command-format.d.ts.map +1 -0
- package/dist/command-format.js +66 -0
- package/dist/command-format.js.map +1 -0
- package/dist/command-runner.d.ts +128 -0
- package/dist/command-runner.d.ts.map +1 -0
- package/dist/command-runner.js +571 -0
- package/dist/command-runner.js.map +1 -0
- package/dist/commands.d.ts +47 -0
- package/dist/commands.d.ts.map +1 -0
- package/dist/commands.js +108 -0
- package/dist/commands.js.map +1 -0
- package/dist/components/AttachmentRow.d.ts +11 -0
- package/dist/components/AttachmentRow.d.ts.map +1 -0
- package/dist/components/AttachmentRow.js +17 -0
- package/dist/components/AttachmentRow.js.map +1 -0
- package/dist/components/Composer.d.ts +23 -0
- package/dist/components/Composer.d.ts.map +1 -0
- package/dist/components/Composer.js +45 -0
- package/dist/components/Composer.js.map +1 -0
- package/dist/components/ExtensionQuestion.d.ts +18 -0
- package/dist/components/ExtensionQuestion.d.ts.map +1 -0
- package/dist/components/ExtensionQuestion.js +45 -0
- package/dist/components/ExtensionQuestion.js.map +1 -0
- package/dist/components/GoalForm.d.ts +18 -0
- package/dist/components/GoalForm.d.ts.map +1 -0
- package/dist/components/GoalForm.js +26 -0
- package/dist/components/GoalForm.js.map +1 -0
- package/dist/components/Home.d.ts +21 -0
- package/dist/components/Home.d.ts.map +1 -0
- package/dist/components/Home.js +48 -0
- package/dist/components/Home.js.map +1 -0
- package/dist/components/MentionList.d.ts +14 -0
- package/dist/components/MentionList.d.ts.map +1 -0
- package/dist/components/MentionList.js +24 -0
- package/dist/components/MentionList.js.map +1 -0
- package/dist/components/SearchBar.d.ts +19 -0
- package/dist/components/SearchBar.d.ts.map +1 -0
- package/dist/components/SearchBar.js +28 -0
- package/dist/components/SearchBar.js.map +1 -0
- package/dist/components/Sidebar.d.ts +19 -0
- package/dist/components/Sidebar.d.ts.map +1 -0
- package/dist/components/Sidebar.js +35 -0
- package/dist/components/Sidebar.js.map +1 -0
- package/dist/components/SummaryEditor.d.ts +16 -0
- package/dist/components/SummaryEditor.d.ts.map +1 -0
- package/dist/components/SummaryEditor.js +21 -0
- package/dist/components/SummaryEditor.js.map +1 -0
- package/dist/components/Transcript.d.ts +37 -0
- package/dist/components/Transcript.d.ts.map +1 -0
- package/dist/components/Transcript.js +314 -0
- package/dist/components/Transcript.js.map +1 -0
- package/dist/components/ui/alert.d.ts +9 -0
- package/dist/components/ui/alert.d.ts.map +1 -0
- package/dist/components/ui/alert.js +18 -0
- package/dist/components/ui/alert.js.map +1 -0
- package/dist/components/ui/command-palette.d.ts +15 -0
- package/dist/components/ui/command-palette.d.ts.map +1 -0
- package/dist/components/ui/command-palette.js +14 -0
- package/dist/components/ui/command-palette.js.map +1 -0
- package/dist/components/ui/confirm.d.ts +12 -0
- package/dist/components/ui/confirm.d.ts.map +1 -0
- package/dist/components/ui/confirm.js +16 -0
- package/dist/components/ui/confirm.js.map +1 -0
- package/dist/components/ui/select.d.ts +11 -0
- package/dist/components/ui/select.d.ts.map +1 -0
- package/dist/components/ui/select.js +29 -0
- package/dist/components/ui/select.js.map +1 -0
- package/dist/components/ui/spinner.d.ts +14 -0
- package/dist/components/ui/spinner.d.ts.map +1 -0
- package/dist/components/ui/spinner.js +17 -0
- package/dist/components/ui/spinner.js.map +1 -0
- package/dist/components/ui/tool-approval.d.ts +14 -0
- package/dist/components/ui/tool-approval.d.ts.map +1 -0
- package/dist/components/ui/tool-approval.js +37 -0
- package/dist/components/ui/tool-approval.js.map +1 -0
- package/dist/components/ui/tool-call.d.ts +12 -0
- package/dist/components/ui/tool-call.d.ts.map +1 -0
- package/dist/components/ui/tool-call.js +69 -0
- package/dist/components/ui/tool-call.js.map +1 -0
- package/dist/components/ui/types.d.ts +82 -0
- package/dist/components/ui/types.d.ts.map +1 -0
- package/dist/components/ui/types.js +2 -0
- package/dist/components/ui/types.js.map +1 -0
- package/dist/crewcoder-cli.d.ts +51 -0
- package/dist/crewcoder-cli.d.ts.map +1 -0
- package/dist/crewcoder-cli.js +26 -0
- package/dist/crewcoder-cli.js.map +1 -0
- package/dist/diff-anchors.d.ts +14 -0
- package/dist/diff-anchors.d.ts.map +1 -0
- package/dist/diff-anchors.js +43 -0
- package/dist/diff-anchors.js.map +1 -0
- package/dist/footer-layout.d.ts +49 -0
- package/dist/footer-layout.d.ts.map +1 -0
- package/dist/footer-layout.js +79 -0
- package/dist/footer-layout.js.map +1 -0
- package/dist/glyphs.d.ts +32 -0
- package/dist/glyphs.d.ts.map +1 -0
- package/dist/glyphs.js +35 -0
- package/dist/glyphs.js.map +1 -0
- package/dist/goal-form.d.ts +47 -0
- package/dist/goal-form.d.ts.map +1 -0
- package/dist/goal-form.js +59 -0
- package/dist/goal-form.js.map +1 -0
- package/dist/hooks/use-animation.d.ts +6 -0
- package/dist/hooks/use-animation.d.ts.map +1 -0
- package/dist/hooks/use-animation.js +52 -0
- package/dist/hooks/use-animation.js.map +1 -0
- package/dist/hooks/use-app-colors.d.ts +6 -0
- package/dist/hooks/use-app-colors.d.ts.map +1 -0
- package/dist/hooks/use-app-colors.js +6 -0
- package/dist/hooks/use-app-colors.js.map +1 -0
- package/dist/hooks/use-glyph-set.d.ts +8 -0
- package/dist/hooks/use-glyph-set.d.ts.map +1 -0
- package/dist/hooks/use-glyph-set.js +22 -0
- package/dist/hooks/use-glyph-set.js.map +1 -0
- package/dist/hooks/use-motion.d.ts +6 -0
- package/dist/hooks/use-motion.d.ts.map +1 -0
- package/dist/hooks/use-motion.js +8 -0
- package/dist/hooks/use-motion.js.map +1 -0
- package/dist/hooks/use-terminal-focus.d.ts +16 -0
- package/dist/hooks/use-terminal-focus.d.ts.map +1 -0
- package/dist/hooks/use-terminal-focus.js +30 -0
- package/dist/hooks/use-terminal-focus.js.map +1 -0
- package/dist/hooks/use-theme.d.ts +6 -0
- package/dist/hooks/use-theme.d.ts.map +1 -0
- package/dist/hooks/use-theme.js +11 -0
- package/dist/hooks/use-theme.js.map +1 -0
- package/dist/hunk.d.ts +27 -0
- package/dist/hunk.d.ts.map +1 -0
- package/dist/hunk.js +43 -0
- package/dist/hunk.js.map +1 -0
- package/dist/image-view.d.ts +33 -0
- package/dist/image-view.d.ts.map +1 -0
- package/dist/image-view.js +51 -0
- package/dist/image-view.js.map +1 -0
- package/dist/keybindings.d.ts +28 -0
- package/dist/keybindings.d.ts.map +1 -0
- package/dist/keybindings.js +105 -0
- package/dist/keybindings.js.map +1 -0
- package/dist/lib/terminal-themes/default.d.ts +3 -0
- package/dist/lib/terminal-themes/default.d.ts.map +1 -0
- package/dist/lib/terminal-themes/default.js +49 -0
- package/dist/lib/terminal-themes/default.js.map +1 -0
- package/dist/logo-pulse.d.ts +23 -0
- package/dist/logo-pulse.d.ts.map +1 -0
- package/dist/logo-pulse.js +30 -0
- package/dist/logo-pulse.js.map +1 -0
- package/dist/markdown-style.d.ts +47 -0
- package/dist/markdown-style.d.ts.map +1 -0
- package/dist/markdown-style.js +138 -0
- package/dist/markdown-style.js.map +1 -0
- package/dist/mentions.d.ts +57 -0
- package/dist/mentions.d.ts.map +1 -0
- package/dist/mentions.js +109 -0
- package/dist/mentions.js.map +1 -0
- package/dist/palette-model.d.ts +42 -0
- package/dist/palette-model.d.ts.map +1 -0
- package/dist/palette-model.js +77 -0
- package/dist/palette-model.js.map +1 -0
- package/dist/path-suggestions.d.ts +50 -0
- package/dist/path-suggestions.d.ts.map +1 -0
- package/dist/path-suggestions.js +99 -0
- package/dist/path-suggestions.js.map +1 -0
- package/dist/picker-flows.d.ts +78 -0
- package/dist/picker-flows.d.ts.map +1 -0
- package/dist/picker-flows.js +444 -0
- package/dist/picker-flows.js.map +1 -0
- package/dist/pickers.d.ts +34 -0
- package/dist/pickers.d.ts.map +1 -0
- package/dist/pickers.js +136 -0
- package/dist/pickers.js.map +1 -0
- package/dist/prompt-history.d.ts +32 -0
- package/dist/prompt-history.d.ts.map +1 -0
- package/dist/prompt-history.js +40 -0
- package/dist/prompt-history.js.map +1 -0
- package/dist/providers/app-theme-provider.d.ts +12 -0
- package/dist/providers/app-theme-provider.d.ts.map +1 -0
- package/dist/providers/app-theme-provider.js +14 -0
- package/dist/providers/app-theme-provider.js.map +1 -0
- package/dist/providers/theme-provider.d.ts +10 -0
- package/dist/providers/theme-provider.d.ts.map +1 -0
- package/dist/providers/theme-provider.js +57 -0
- package/dist/providers/theme-provider.js.map +1 -0
- package/dist/question-model.d.ts +71 -0
- package/dist/question-model.d.ts.map +1 -0
- package/dist/question-model.js +176 -0
- package/dist/question-model.js.map +1 -0
- package/dist/search-controller.d.ts +46 -0
- package/dist/search-controller.d.ts.map +1 -0
- package/dist/search-controller.js +89 -0
- package/dist/search-controller.js.map +1 -0
- package/dist/search-jump.d.ts +27 -0
- package/dist/search-jump.d.ts.map +1 -0
- package/dist/search-jump.js +65 -0
- package/dist/search-jump.js.map +1 -0
- package/dist/session-controller.d.ts +268 -0
- package/dist/session-controller.d.ts.map +1 -0
- package/dist/session-controller.js +941 -0
- package/dist/session-controller.js.map +1 -0
- package/dist/sidebar-model.d.ts +45 -0
- package/dist/sidebar-model.d.ts.map +1 -0
- package/dist/sidebar-model.js +223 -0
- package/dist/sidebar-model.js.map +1 -0
- package/dist/sidebar.d.ts +49 -0
- package/dist/sidebar.d.ts.map +1 -0
- package/dist/sidebar.js +106 -0
- package/dist/sidebar.js.map +1 -0
- package/dist/status-line.d.ts +32 -0
- package/dist/status-line.d.ts.map +1 -0
- package/dist/status-line.js +69 -0
- package/dist/status-line.js.map +1 -0
- package/dist/syntax/filetype.d.ts +12 -0
- package/dist/syntax/filetype.d.ts.map +1 -0
- package/dist/syntax/filetype.js +28 -0
- package/dist/syntax/filetype.js.map +1 -0
- package/dist/syntax/grammars.d.ts +42 -0
- package/dist/syntax/grammars.d.ts.map +1 -0
- package/dist/syntax/grammars.js +52 -0
- package/dist/syntax/grammars.js.map +1 -0
- package/dist/text-offset.d.ts +5 -0
- package/dist/text-offset.d.ts.map +1 -0
- package/dist/text-offset.js +38 -0
- package/dist/text-offset.js.map +1 -0
- package/dist/text-wrap.d.ts +12 -0
- package/dist/text-wrap.d.ts.map +1 -0
- package/dist/text-wrap.js +53 -0
- package/dist/text-wrap.js.map +1 -0
- package/dist/theme-controller.d.ts +77 -0
- package/dist/theme-controller.d.ts.map +1 -0
- package/dist/theme-controller.js +178 -0
- package/dist/theme-controller.js.map +1 -0
- package/dist/theme.d.ts +51 -0
- package/dist/theme.d.ts.map +1 -0
- package/dist/theme.js +86 -0
- package/dist/theme.js.map +1 -0
- package/dist/tmux-check.d.ts +35 -0
- package/dist/tmux-check.d.ts.map +1 -0
- package/dist/tmux-check.js +66 -0
- package/dist/tmux-check.js.map +1 -0
- package/dist/tmux.d.ts +69 -0
- package/dist/tmux.d.ts.map +1 -0
- package/dist/tmux.js +135 -0
- package/dist/tmux.js.map +1 -0
- package/dist/tool-diff.d.ts +51 -0
- package/dist/tool-diff.d.ts.map +1 -0
- package/dist/tool-diff.js +158 -0
- package/dist/tool-diff.js.map +1 -0
- package/dist/tool-presentation.d.ts +46 -0
- package/dist/tool-presentation.d.ts.map +1 -0
- package/dist/tool-presentation.js +148 -0
- package/dist/tool-presentation.js.map +1 -0
- package/dist/tool-renderer-view.d.ts +14 -0
- package/dist/tool-renderer-view.d.ts.map +1 -0
- package/dist/tool-renderer-view.js +10 -0
- package/dist/tool-renderer-view.js.map +1 -0
- package/dist/transcript-search.d.ts +54 -0
- package/dist/transcript-search.d.ts.map +1 -0
- package/dist/transcript-search.js +160 -0
- package/dist/transcript-search.js.map +1 -0
- package/dist/transcript.d.ts +59 -0
- package/dist/transcript.d.ts.map +1 -0
- package/dist/transcript.js +123 -0
- package/dist/transcript.js.map +1 -0
- package/dist/workflow-tools.d.ts +42 -0
- package/dist/workflow-tools.d.ts.map +1 -0
- package/dist/workflow-tools.js +89 -0
- package/dist/workflow-tools.js.map +1 -0
- package/examples/themes/ember.json +75 -0
- package/grammars/bash/LICENSE +21 -0
- package/grammars/bash/highlights.scm +56 -0
- package/grammars/bash/tree-sitter-bash.wasm +0 -0
- package/grammars/css/LICENSE +21 -0
- package/grammars/css/highlights.scm +76 -0
- package/grammars/css/tree-sitter-css.wasm +0 -0
- package/grammars/go/LICENSE +21 -0
- package/grammars/go/highlights.scm +123 -0
- package/grammars/go/tree-sitter-go.wasm +0 -0
- package/grammars/html/LICENSE +21 -0
- package/grammars/html/highlights.scm +13 -0
- package/grammars/html/tree-sitter-html.wasm +0 -0
- package/grammars/json/LICENSE +21 -0
- package/grammars/json/highlights.scm +16 -0
- package/grammars/json/tree-sitter-json.wasm +0 -0
- package/grammars/python/LICENSE +21 -0
- package/grammars/python/highlights.scm +137 -0
- package/grammars/python/tree-sitter-python.wasm +0 -0
- package/grammars/rust/LICENSE +21 -0
- package/grammars/rust/highlights.scm +161 -0
- package/grammars/rust/tree-sitter-rust.wasm +0 -0
- package/grammars/yaml/LICENSE +20 -0
- package/grammars/yaml/highlights.scm +79 -0
- package/grammars/yaml/tree-sitter-yaml.wasm +0 -0
- package/package.json +56 -5
|
@@ -0,0 +1,49 @@
|
|
|
1
|
+
import type { TuiEventBlock } from "@onpoint-dev-tools/crewcoder-tui-core/state/tui-store";
|
|
2
|
+
/** A one-line composer: border (2) + one text line. It grows to MAX_COMPOSER_LINES. */
|
|
3
|
+
export declare const COMPOSER_ROWS = 3;
|
|
4
|
+
export declare const MAX_COMPOSER_LINES = 8;
|
|
5
|
+
/** Footer parts with a variable height, from `SessionController.footerExtras`. */
|
|
6
|
+
export type FooterExtras = {
|
|
7
|
+
/** The status alert above the composer. */
|
|
8
|
+
alertRows?: number;
|
|
9
|
+
/** Composer height including its border; defaults to one line. */
|
|
10
|
+
composerRows?: number;
|
|
11
|
+
/** `@` path suggestion rows under the composer. */
|
|
12
|
+
mentionRows?: number;
|
|
13
|
+
/** The pending-images row above the composer. */
|
|
14
|
+
attachmentRows?: number;
|
|
15
|
+
};
|
|
16
|
+
/**
|
|
17
|
+
* Visual lines of `text` word-wrapped to `columns`, as the composer textarea
|
|
18
|
+
* (`wrapMode="word"`) lays it out. Counted from the text because the
|
|
19
|
+
* textarea's own `virtualLineCount` only covers its current viewport, so it
|
|
20
|
+
* could never report more lines than the composer already shows. Counts code
|
|
21
|
+
* points, so double-width characters can undercount; the textarea then scrolls.
|
|
22
|
+
*/
|
|
23
|
+
export declare function wrappedLineCount(text: string, columns: number): number;
|
|
24
|
+
/** Composer height for this many visual (wrapped) lines. */
|
|
25
|
+
export declare function composerRows(lines: number): number;
|
|
26
|
+
/**
|
|
27
|
+
* The centered welcome screen shows while the session is empty and idle. Any
|
|
28
|
+
* block (even an error from an unported command) ends it, so nothing in the
|
|
29
|
+
* transcript is hidden behind it.
|
|
30
|
+
*/
|
|
31
|
+
export declare function isHome(blocks: readonly TuiEventBlock[], running: boolean): boolean;
|
|
32
|
+
export declare const HOME_COMPOSER_MIN_WIDTH = 24;
|
|
33
|
+
export declare const HOME_LOGO_MIN_WIDTH = 70;
|
|
34
|
+
/** Composer width on the home screen: 62% of the terminal, like the legacy landing page. */
|
|
35
|
+
export declare function homeComposerWidth(width: number): number;
|
|
36
|
+
/** Rows the welcome screen needs below the logo: gap, composer (3), gap, tip, info. */
|
|
37
|
+
export declare const HOME_BODY_ROWS = 8;
|
|
38
|
+
/**
|
|
39
|
+
* The big block wordmark, or nothing. Smaller logo variants are not used: when
|
|
40
|
+
* the wordmark does not fit (narrower than 70 columns, or too short to keep the
|
|
41
|
+
* composer whole), the welcome screen shows only the composer.
|
|
42
|
+
*/
|
|
43
|
+
export declare function homeLogo(width: number, height: number, logo: readonly string[], extraRows?: number): readonly string[] | undefined;
|
|
44
|
+
/**
|
|
45
|
+
* Fit a path into `max` columns: abbreviate the local home directory as `~`
|
|
46
|
+
* (pass no home for remote paths), then keep the end, which names the project.
|
|
47
|
+
*/
|
|
48
|
+
export declare function shortenPath(path: string, max: number, home?: string): string;
|
|
49
|
+
//# sourceMappingURL=footer-layout.d.ts.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"footer-layout.d.ts","sourceRoot":"","sources":["../src/footer-layout.ts"],"names":[],"mappings":"AAAA,OAAO,KAAK,EAAE,aAAa,EAAE,MAAM,uDAAuD,CAAC;AAE3F,uFAAuF;AACvF,eAAO,MAAM,aAAa,IAAI,CAAC;AAC/B,eAAO,MAAM,kBAAkB,IAAI,CAAC;AAEpC,kFAAkF;AAClF,MAAM,MAAM,YAAY,GAAG;IACzB,2CAA2C;IAC3C,SAAS,CAAC,EAAE,MAAM,CAAC;IACnB,kEAAkE;IAClE,YAAY,CAAC,EAAE,MAAM,CAAC;IACtB,mDAAmD;IACnD,WAAW,CAAC,EAAE,MAAM,CAAC;IACrB,iDAAiD;IACjD,cAAc,CAAC,EAAE,MAAM,CAAC;CACzB,CAAC;AAEF;;;;;;GAMG;AACH,wBAAgB,gBAAgB,CAAC,IAAI,EAAE,MAAM,EAAE,OAAO,EAAE,MAAM,GAAG,MAAM,CAwBtE;AAED,4DAA4D;AAC5D,wBAAgB,YAAY,CAAC,KAAK,EAAE,MAAM,GAAG,MAAM,CAElD;AAED;;;;GAIG;AACH,wBAAgB,MAAM,CAAC,MAAM,EAAE,SAAS,aAAa,EAAE,EAAE,OAAO,EAAE,OAAO,GAAG,OAAO,CAElF;AAED,eAAO,MAAM,uBAAuB,KAAK,CAAC;AAC1C,eAAO,MAAM,mBAAmB,KAAK,CAAC;AAEtC,4FAA4F;AAC5F,wBAAgB,iBAAiB,CAAC,KAAK,EAAE,MAAM,GAAG,MAAM,CAGvD;AAED,uFAAuF;AACvF,eAAO,MAAM,cAAc,IAAI,CAAC;AAEhC;;;;GAIG;AACH,wBAAgB,QAAQ,CAAC,KAAK,EAAE,MAAM,EAAE,MAAM,EAAE,MAAM,EAAE,IAAI,EAAE,SAAS,MAAM,EAAE,EAAE,SAAS,SAAI,GAAG,SAAS,MAAM,EAAE,GAAG,SAAS,CAK7H;AAED;;;GAGG;AACH,wBAAgB,WAAW,CAAC,IAAI,EAAE,MAAM,EAAE,GAAG,EAAE,MAAM,EAAE,IAAI,CAAC,EAAE,MAAM,GAAG,MAAM,CAI5E"}
|
|
@@ -0,0 +1,79 @@
|
|
|
1
|
+
/** A one-line composer: border (2) + one text line. It grows to MAX_COMPOSER_LINES. */
|
|
2
|
+
export const COMPOSER_ROWS = 3;
|
|
3
|
+
export const MAX_COMPOSER_LINES = 8;
|
|
4
|
+
/**
|
|
5
|
+
* Visual lines of `text` word-wrapped to `columns`, as the composer textarea
|
|
6
|
+
* (`wrapMode="word"`) lays it out. Counted from the text because the
|
|
7
|
+
* textarea's own `virtualLineCount` only covers its current viewport, so it
|
|
8
|
+
* could never report more lines than the composer already shows. Counts code
|
|
9
|
+
* points, so double-width characters can undercount; the textarea then scrolls.
|
|
10
|
+
*/
|
|
11
|
+
export function wrappedLineCount(text, columns) {
|
|
12
|
+
const width = Math.max(1, Math.floor(columns));
|
|
13
|
+
let lines = 0;
|
|
14
|
+
for (const logical of text.split("\n")) {
|
|
15
|
+
let used = 0;
|
|
16
|
+
let rows = 1;
|
|
17
|
+
for (const word of logical.split(/(\s+)/).filter(Boolean)) {
|
|
18
|
+
let length = [...word].length;
|
|
19
|
+
if (used + length <= width) {
|
|
20
|
+
used += length;
|
|
21
|
+
continue;
|
|
22
|
+
}
|
|
23
|
+
// Whitespace at a break is absorbed; a word moves to the next row, splitting if longer than a row.
|
|
24
|
+
if (/^\s+$/.test(word))
|
|
25
|
+
continue;
|
|
26
|
+
rows += used > 0 ? 1 : 0;
|
|
27
|
+
while (length > width) {
|
|
28
|
+
rows += 1;
|
|
29
|
+
length -= width;
|
|
30
|
+
}
|
|
31
|
+
used = length;
|
|
32
|
+
}
|
|
33
|
+
lines += rows;
|
|
34
|
+
}
|
|
35
|
+
return Math.max(1, lines);
|
|
36
|
+
}
|
|
37
|
+
/** Composer height for this many visual (wrapped) lines. */
|
|
38
|
+
export function composerRows(lines) {
|
|
39
|
+
return Math.max(1, Math.min(MAX_COMPOSER_LINES, lines)) + 2;
|
|
40
|
+
}
|
|
41
|
+
/**
|
|
42
|
+
* The centered welcome screen shows while the session is empty and idle. Any
|
|
43
|
+
* block (even an error from an unported command) ends it, so nothing in the
|
|
44
|
+
* transcript is hidden behind it.
|
|
45
|
+
*/
|
|
46
|
+
export function isHome(blocks, running) {
|
|
47
|
+
return !running && blocks.length === 0;
|
|
48
|
+
}
|
|
49
|
+
export const HOME_COMPOSER_MIN_WIDTH = 24;
|
|
50
|
+
export const HOME_LOGO_MIN_WIDTH = 70;
|
|
51
|
+
/** Composer width on the home screen: 62% of the terminal, like the legacy landing page. */
|
|
52
|
+
export function homeComposerWidth(width) {
|
|
53
|
+
// Clamp last so a terminal narrower than the floor never gets a wider composer.
|
|
54
|
+
return Math.min(width, Math.max(HOME_COMPOSER_MIN_WIDTH, Math.floor(width * 0.62)));
|
|
55
|
+
}
|
|
56
|
+
/** Rows the welcome screen needs below the logo: gap, composer (3), gap, tip, info. */
|
|
57
|
+
export const HOME_BODY_ROWS = 8;
|
|
58
|
+
/**
|
|
59
|
+
* The big block wordmark, or nothing. Smaller logo variants are not used: when
|
|
60
|
+
* the wordmark does not fit (narrower than 70 columns, or too short to keep the
|
|
61
|
+
* composer whole), the welcome screen shows only the composer.
|
|
62
|
+
*/
|
|
63
|
+
export function homeLogo(width, height, logo, extraRows = 0) {
|
|
64
|
+
const logoWidth = Math.max(0, ...logo.map((line) => line.length));
|
|
65
|
+
// extraRows: an alert and composer lines beyond the first also need room.
|
|
66
|
+
const fits = width >= Math.max(HOME_LOGO_MIN_WIDTH, logoWidth + 2) && height >= logo.length + HOME_BODY_ROWS + extraRows + 2;
|
|
67
|
+
return fits ? logo : undefined;
|
|
68
|
+
}
|
|
69
|
+
/**
|
|
70
|
+
* Fit a path into `max` columns: abbreviate the local home directory as `~`
|
|
71
|
+
* (pass no home for remote paths), then keep the end, which names the project.
|
|
72
|
+
*/
|
|
73
|
+
export function shortenPath(path, max, home) {
|
|
74
|
+
const local = home && (path === home || path.startsWith(`${home}/`)) ? `~${path.slice(home.length)}` : path;
|
|
75
|
+
if (local.length <= max)
|
|
76
|
+
return local;
|
|
77
|
+
return max <= 1 ? "…" : `…${local.slice(local.length - max + 1)}`;
|
|
78
|
+
}
|
|
79
|
+
//# sourceMappingURL=footer-layout.js.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"footer-layout.js","sourceRoot":"","sources":["../src/footer-layout.ts"],"names":[],"mappings":"AAEA,uFAAuF;AACvF,MAAM,CAAC,MAAM,aAAa,GAAG,CAAC,CAAC;AAC/B,MAAM,CAAC,MAAM,kBAAkB,GAAG,CAAC,CAAC;AAcpC;;;;;;GAMG;AACH,MAAM,UAAU,gBAAgB,CAAC,IAAY,EAAE,OAAe;IAC5D,MAAM,KAAK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,CAAC,CAAC,IAAI,IAAI,CAAC,KAAK,CAAC,IAAI,CAAC,MAAM,CAAC,EAAE,CAAC,CAAC,CAAC,IAAI,CAAC;IAC5G,IAAI,KAAK,CAAC,MAAM,IAAI,GAAG;QAAE,OAAO,KAAK,CAAC;IACtC,OAAO,GAAG,IAAI,CAAC,CAAC,CAAC,CAAC,GAAG,CAAC,CAAC,CAAC,IAAI,KAAK,CAAC,KAAK,CAAC,KAAK,CAAC,MAAM,GAAG,GAAG,GAAG,CAAC,CAAC,EAAE,CAAC;AACpE,CAAC","sourcesContent":["import type { TuiEventBlock } from \"@onpoint-dev-tools/crewcoder-tui-core/state/tui-store\";\n\n/** A one-line composer: border (2) + one text line. It grows to MAX_COMPOSER_LINES. */\nexport const COMPOSER_ROWS = 3;\nexport const MAX_COMPOSER_LINES = 8;\n\n/** Footer parts with a variable height, from `SessionController.footerExtras`. */\nexport type FooterExtras = {\n /** The status alert above the composer. */\n alertRows?: number;\n /** Composer height including its border; defaults to one line. */\n composerRows?: number;\n /** `@` path suggestion rows under the composer. */\n mentionRows?: number;\n /** The pending-images row above the composer. */\n attachmentRows?: number;\n};\n\n/**\n * Visual lines of `text` word-wrapped to `columns`, as the composer textarea\n * (`wrapMode=\"word\"`) lays it out. Counted from the text because the\n * textarea's own `virtualLineCount` only covers its current viewport, so it\n * could never report more lines than the composer already shows. Counts code\n * points, so double-width characters can undercount; the textarea then scrolls.\n */\nexport function wrappedLineCount(text: string, columns: number): number {\n const width = Math.max(1, Math.floor(columns));\n let lines = 0;\n for (const logical of text.split(\"\\n\")) {\n let used = 0;\n let rows = 1;\n for (const word of logical.split(/(\\s+)/).filter(Boolean)) {\n let length = [...word].length;\n if (used + length <= width) {\n used += length;\n continue;\n }\n // Whitespace at a break is absorbed; a word moves to the next row, splitting if longer than a row.\n if (/^\\s+$/.test(word)) continue;\n rows += used > 0 ? 1 : 0;\n while (length > width) {\n rows += 1;\n length -= width;\n }\n used = length;\n }\n lines += rows;\n }\n return Math.max(1, lines);\n}\n\n/** Composer height for this many visual (wrapped) lines. */\nexport function composerRows(lines: number): number {\n return Math.max(1, Math.min(MAX_COMPOSER_LINES, lines)) + 2;\n}\n\n/**\n * The centered welcome screen shows while the session is empty and idle. Any\n * block (even an error from an unported command) ends it, so nothing in the\n * transcript is hidden behind it.\n */\nexport function isHome(blocks: readonly TuiEventBlock[], running: boolean): boolean {\n return !running && blocks.length === 0;\n}\n\nexport const HOME_COMPOSER_MIN_WIDTH = 24;\nexport const HOME_LOGO_MIN_WIDTH = 70;\n\n/** Composer width on the home screen: 62% of the terminal, like the legacy landing page. */\nexport function homeComposerWidth(width: number): number {\n // Clamp last so a terminal narrower than the floor never gets a wider composer.\n return Math.min(width, Math.max(HOME_COMPOSER_MIN_WIDTH, Math.floor(width * 0.62)));\n}\n\n/** Rows the welcome screen needs below the logo: gap, composer (3), gap, tip, info. */\nexport const HOME_BODY_ROWS = 8;\n\n/**\n * The big block wordmark, or nothing. Smaller logo variants are not used: when\n * the wordmark does not fit (narrower than 70 columns, or too short to keep the\n * composer whole), the welcome screen shows only the composer.\n */\nexport function homeLogo(width: number, height: number, logo: readonly string[], extraRows = 0): readonly string[] | undefined {\n const logoWidth = Math.max(0, ...logo.map((line) => line.length));\n // extraRows: an alert and composer lines beyond the first also need room.\n const fits = width >= Math.max(HOME_LOGO_MIN_WIDTH, logoWidth + 2) && height >= logo.length + HOME_BODY_ROWS + extraRows + 2;\n return fits ? logo : undefined;\n}\n\n/**\n * Fit a path into `max` columns: abbreviate the local home directory as `~`\n * (pass no home for remote paths), then keep the end, which names the project.\n */\nexport function shortenPath(path: string, max: number, home?: string): string {\n const local = home && (path === home || path.startsWith(`${home}/`)) ? `~${path.slice(home.length)}` : path;\n if (local.length <= max) return local;\n return max <= 1 ? \"…\" : `…${local.slice(local.length - max + 1)}`;\n}\n"]}
|
package/dist/glyphs.d.ts
ADDED
|
@@ -0,0 +1,32 @@
|
|
|
1
|
+
import type { TerminalCapabilities } from "@opentui/core";
|
|
2
|
+
/**
|
|
3
|
+
* Which icons the transcript draws. `emoji` is the full-color set (two cells
|
|
4
|
+
* wide); `text` uses single-cell symbols that every terminal draws the same.
|
|
5
|
+
*/
|
|
6
|
+
export type GlyphSet = "emoji" | "text";
|
|
7
|
+
/** Environment override: `emoji`, `text`, or `auto` (default, from the terminal's capabilities). */
|
|
8
|
+
export declare const GLYPHS_ENV = "CREWCODER_TUI_ICONS";
|
|
9
|
+
/**
|
|
10
|
+
* Emoji are two cells wide. When the terminal measures them differently from
|
|
11
|
+
* OpenTUI, the next cell overwrites half the glyph and the icon looks clipped.
|
|
12
|
+
* So emoji are used only when OpenTUI's probe confirmed Unicode width handling
|
|
13
|
+
* (`unicode` / `unicode-wide`, e.g. Ghostty, kitty, WezTerm) and no multiplexer
|
|
14
|
+
* sits in between (tmux, screen, and zellij redraw cells with their own width
|
|
15
|
+
* tables). Before the probe answers, or with plain `wcwidth`, use `text`.
|
|
16
|
+
*/
|
|
17
|
+
export declare function resolveGlyphSet(capabilities: TerminalCapabilities | null | undefined, override: string | undefined): GlyphSet;
|
|
18
|
+
/**
|
|
19
|
+
* Marks the user's own messages, left of the text (owner decision: replaces the `YOU`
|
|
20
|
+
* label). A filled circle in the theme's `primary` color. Single-cell in both glyph sets,
|
|
21
|
+
* so it draws the same under tmux and plain `wcwidth` terminals.
|
|
22
|
+
*/
|
|
23
|
+
export declare const USER_MESSAGE_MARKER = "\u25CF";
|
|
24
|
+
/**
|
|
25
|
+
* Points at the current transcript search match from the transcript's left margin
|
|
26
|
+
* (`docs/TRANSCRIPT.md#search`). U+276F is single-cell (East Asian Width neutral), so
|
|
27
|
+
* it never clips under tmux or `wcwidth`.
|
|
28
|
+
*/
|
|
29
|
+
export declare const SEARCH_MARKER = "\u276F";
|
|
30
|
+
/** The Reasoning panel's header icon. */
|
|
31
|
+
export declare function reasoningIcon(glyphs: GlyphSet): string;
|
|
32
|
+
//# sourceMappingURL=glyphs.d.ts.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"glyphs.d.ts","sourceRoot":"","sources":["../src/glyphs.ts"],"names":[],"mappings":"AAAA,OAAO,KAAK,EAAE,oBAAoB,EAAE,MAAM,eAAe,CAAC;AAE1D;;;GAGG;AACH,MAAM,MAAM,QAAQ,GAAG,OAAO,GAAG,MAAM,CAAC;AAExC,oGAAoG;AACpG,eAAO,MAAM,UAAU,wBAAwB,CAAC;AAEhD;;;;;;;GAOG;AACH,wBAAgB,eAAe,CAAC,YAAY,EAAE,oBAAoB,GAAG,IAAI,GAAG,SAAS,EAAE,QAAQ,EAAE,MAAM,GAAG,SAAS,GAAG,QAAQ,CAK7H;AAED;;;;GAIG;AACH,eAAO,MAAM,mBAAmB,WAAM,CAAC;AAEvC;;;;GAIG;AACH,eAAO,MAAM,aAAa,WAAM,CAAC;AAEjC,yCAAyC;AACzC,wBAAgB,aAAa,CAAC,MAAM,EAAE,QAAQ,GAAG,MAAM,CAEtD"}
|
package/dist/glyphs.js
ADDED
|
@@ -0,0 +1,35 @@
|
|
|
1
|
+
/** Environment override: `emoji`, `text`, or `auto` (default, from the terminal's capabilities). */
|
|
2
|
+
export const GLYPHS_ENV = "CREWCODER_TUI_ICONS";
|
|
3
|
+
/**
|
|
4
|
+
* Emoji are two cells wide. When the terminal measures them differently from
|
|
5
|
+
* OpenTUI, the next cell overwrites half the glyph and the icon looks clipped.
|
|
6
|
+
* So emoji are used only when OpenTUI's probe confirmed Unicode width handling
|
|
7
|
+
* (`unicode` / `unicode-wide`, e.g. Ghostty, kitty, WezTerm) and no multiplexer
|
|
8
|
+
* sits in between (tmux, screen, and zellij redraw cells with their own width
|
|
9
|
+
* tables). Before the probe answers, or with plain `wcwidth`, use `text`.
|
|
10
|
+
*/
|
|
11
|
+
export function resolveGlyphSet(capabilities, override) {
|
|
12
|
+
const forced = override?.trim().toLowerCase();
|
|
13
|
+
if (forced === "emoji" || forced === "text")
|
|
14
|
+
return forced;
|
|
15
|
+
if (!capabilities)
|
|
16
|
+
return "text";
|
|
17
|
+
return capabilities.multiplexer === "none" && capabilities.unicode !== "wcwidth" ? "emoji" : "text";
|
|
18
|
+
}
|
|
19
|
+
/**
|
|
20
|
+
* Marks the user's own messages, left of the text (owner decision: replaces the `YOU`
|
|
21
|
+
* label). A filled circle in the theme's `primary` color. Single-cell in both glyph sets,
|
|
22
|
+
* so it draws the same under tmux and plain `wcwidth` terminals.
|
|
23
|
+
*/
|
|
24
|
+
export const USER_MESSAGE_MARKER = "●";
|
|
25
|
+
/**
|
|
26
|
+
* Points at the current transcript search match from the transcript's left margin
|
|
27
|
+
* (`docs/TRANSCRIPT.md#search`). U+276F is single-cell (East Asian Width neutral), so
|
|
28
|
+
* it never clips under tmux or `wcwidth`.
|
|
29
|
+
*/
|
|
30
|
+
export const SEARCH_MARKER = "❯";
|
|
31
|
+
/** The Reasoning panel's header icon. */
|
|
32
|
+
export function reasoningIcon(glyphs) {
|
|
33
|
+
return glyphs === "emoji" ? "💭" : "∴";
|
|
34
|
+
}
|
|
35
|
+
//# sourceMappingURL=glyphs.js.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"glyphs.js","sourceRoot":"","sources":["../src/glyphs.ts"],"names":[],"mappings":"AAQA,oGAAoG;AACpG,MAAM,CAAC,MAAM,UAAU,GAAG,qBAAqB,CAAC;AAEhD;;;;;;;GAOG;AACH,MAAM,UAAU,eAAe,CAAC,YAAqD,EAAE,QAA4B;IACjH,MAAM,MAAM,GAAG,QAAQ,EAAE,IAAI,EAAE,CAAC,WAAW,EAAE,CAAC;IAC9C,IAAI,MAAM,KAAK,OAAO,IAAI,MAAM,KAAK,MAAM;QAAE,OAAO,MAAM,CAAC;IAC3D,IAAI,CAAC,YAAY;QAAE,OAAO,MAAM,CAAC;IACjC,OAAO,YAAY,CAAC,WAAW,KAAK,MAAM,IAAI,YAAY,CAAC,OAAO,KAAK,SAAS,CAAC,CAAC,CAAC,OAAO,CAAC,CAAC,CAAC,MAAM,CAAC;AACtG,CAAC;AAED;;;;GAIG;AACH,MAAM,CAAC,MAAM,mBAAmB,GAAG,GAAG,CAAC;AAEvC;;;;GAIG;AACH,MAAM,CAAC,MAAM,aAAa,GAAG,GAAG,CAAC;AAEjC,yCAAyC;AACzC,MAAM,UAAU,aAAa,CAAC,MAAgB;IAC5C,OAAO,MAAM,KAAK,OAAO,CAAC,CAAC,CAAC,IAAI,CAAC,CAAC,CAAC,GAAG,CAAC;AACzC,CAAC","sourcesContent":["import type { TerminalCapabilities } from \"@opentui/core\";\n\n/**\n * Which icons the transcript draws. `emoji` is the full-color set (two cells\n * wide); `text` uses single-cell symbols that every terminal draws the same.\n */\nexport type GlyphSet = \"emoji\" | \"text\";\n\n/** Environment override: `emoji`, `text`, or `auto` (default, from the terminal's capabilities). */\nexport const GLYPHS_ENV = \"CREWCODER_TUI_ICONS\";\n\n/**\n * Emoji are two cells wide. When the terminal measures them differently from\n * OpenTUI, the next cell overwrites half the glyph and the icon looks clipped.\n * So emoji are used only when OpenTUI's probe confirmed Unicode width handling\n * (`unicode` / `unicode-wide`, e.g. Ghostty, kitty, WezTerm) and no multiplexer\n * sits in between (tmux, screen, and zellij redraw cells with their own width\n * tables). Before the probe answers, or with plain `wcwidth`, use `text`.\n */\nexport function resolveGlyphSet(capabilities: TerminalCapabilities | null | undefined, override: string | undefined): GlyphSet {\n const forced = override?.trim().toLowerCase();\n if (forced === \"emoji\" || forced === \"text\") return forced;\n if (!capabilities) return \"text\";\n return capabilities.multiplexer === \"none\" && capabilities.unicode !== \"wcwidth\" ? \"emoji\" : \"text\";\n}\n\n/**\n * Marks the user's own messages, left of the text (owner decision: replaces the `YOU`\n * label). A filled circle in the theme's `primary` color. Single-cell in both glyph sets,\n * so it draws the same under tmux and plain `wcwidth` terminals.\n */\nexport const USER_MESSAGE_MARKER = \"●\";\n\n/**\n * Points at the current transcript search match from the transcript's left margin\n * (`docs/TRANSCRIPT.md#search`). U+276F is single-cell (East Asian Width neutral), so\n * it never clips under tmux or `wcwidth`.\n */\nexport const SEARCH_MARKER = \"❯\";\n\n/** The Reasoning panel's header icon. */\nexport function reasoningIcon(glyphs: GlyphSet): string {\n return glyphs === \"emoji\" ? \"💭\" : \"∴\";\n}\n"]}
|
|
@@ -0,0 +1,47 @@
|
|
|
1
|
+
import type { GoalStartInput } from "@onpoint-dev-tools/crewcoder-tui-core/state/command-results";
|
|
2
|
+
/**
|
|
3
|
+
* The bare `/goal` preflight form (`docs/COMMAND_PALETTE.md#goal`), ported from legacy `GoalOverlay`:
|
|
4
|
+
* objective, max turns, check model, and timeout for this goal only, prefilled from
|
|
5
|
+
* `config.goals`. Pure: state, validation, and the start input; `GoalForm` only draws.
|
|
6
|
+
*/
|
|
7
|
+
export type GoalField = "objective" | "maxTurns" | "checkModel" | "timeoutMinutes";
|
|
8
|
+
export declare const GOAL_FIELDS: ReadonlyArray<{
|
|
9
|
+
key: GoalField;
|
|
10
|
+
label: string;
|
|
11
|
+
hint: string;
|
|
12
|
+
}>;
|
|
13
|
+
export declare const MAX_GOAL_TURNS = 10000;
|
|
14
|
+
export declare const MAX_GOAL_TIMEOUT_MINUTES = 43200;
|
|
15
|
+
/** Legacy defaults when `config.goals` is missing. */
|
|
16
|
+
export declare const DEFAULT_GOAL_SETTINGS: {
|
|
17
|
+
readonly maxTurns: 200;
|
|
18
|
+
readonly timeoutMinutes: 480;
|
|
19
|
+
};
|
|
20
|
+
export type GoalFormState = {
|
|
21
|
+
values: Readonly<Record<GoalField, string>>;
|
|
22
|
+
/** Index into `GOAL_FIELDS`. */
|
|
23
|
+
selected: number;
|
|
24
|
+
error?: string;
|
|
25
|
+
};
|
|
26
|
+
export type GoalDefaults = {
|
|
27
|
+
maxTurns: number;
|
|
28
|
+
timeoutMinutes: number;
|
|
29
|
+
checkModel?: string;
|
|
30
|
+
};
|
|
31
|
+
/** `config.goals` from `crewcoder config show --json`, falling back field by field to the legacy defaults. */
|
|
32
|
+
export declare function goalDefaults(config: unknown): GoalDefaults;
|
|
33
|
+
export declare function initialGoalForm(defaults: GoalDefaults): GoalFormState;
|
|
34
|
+
/** Move to another field (clamped); the error clears. */
|
|
35
|
+
export declare function selectGoalField(form: GoalFormState, index: number): GoalFormState;
|
|
36
|
+
/** Set the selected field's text; the error clears. */
|
|
37
|
+
export declare function editGoalField(form: GoalFormState, value: string): GoalFormState;
|
|
38
|
+
/**
|
|
39
|
+
* The goal to start, or the form with an error on the first bad field. A blank check
|
|
40
|
+
* model turns the verifier off for this goal (legacy), not "use the default".
|
|
41
|
+
*/
|
|
42
|
+
export declare function submitGoalForm(form: GoalFormState): {
|
|
43
|
+
start: GoalStartInput;
|
|
44
|
+
} | {
|
|
45
|
+
form: GoalFormState;
|
|
46
|
+
};
|
|
47
|
+
//# sourceMappingURL=goal-form.d.ts.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"goal-form.d.ts","sourceRoot":"","sources":["../src/goal-form.ts"],"names":[],"mappings":"AAAA,OAAO,KAAK,EAAE,cAAc,EAAE,MAAM,6DAA6D,CAAC;AAElG;;;;GAIG;AAEH,MAAM,MAAM,SAAS,GAAG,WAAW,GAAG,UAAU,GAAG,YAAY,GAAG,gBAAgB,CAAC;AAEnF,eAAO,MAAM,WAAW,EAAE,aAAa,CAAC;IAAE,GAAG,EAAE,SAAS,CAAC;IAAC,KAAK,EAAE,MAAM,CAAC;IAAC,IAAI,EAAE,MAAM,CAAA;CAAE,CAKtF,CAAC;AAEF,eAAO,MAAM,cAAc,QAAS,CAAC;AACrC,eAAO,MAAM,wBAAwB,QAAS,CAAC;AAE/C,sDAAsD;AACtD,eAAO,MAAM,qBAAqB;;;CAAkD,CAAC;AAErF,MAAM,MAAM,aAAa,GAAG;IAC1B,MAAM,EAAE,QAAQ,CAAC,MAAM,CAAC,SAAS,EAAE,MAAM,CAAC,CAAC,CAAC;IAC5C,gCAAgC;IAChC,QAAQ,EAAE,MAAM,CAAC;IACjB,KAAK,CAAC,EAAE,MAAM,CAAC;CAChB,CAAC;AAEF,MAAM,MAAM,YAAY,GAAG;IAAE,QAAQ,EAAE,MAAM,CAAC;IAAC,cAAc,EAAE,MAAM,CAAC;IAAC,UAAU,CAAC,EAAE,MAAM,CAAA;CAAE,CAAC;AAE7F,8GAA8G;AAC9G,wBAAgB,YAAY,CAAC,MAAM,EAAE,OAAO,GAAG,YAAY,CAO1D;AAED,wBAAgB,eAAe,CAAC,QAAQ,EAAE,YAAY,GAAG,aAAa,CAKrE;AAED,yDAAyD;AACzD,wBAAgB,eAAe,CAAC,IAAI,EAAE,aAAa,EAAE,KAAK,EAAE,MAAM,GAAG,aAAa,CAEjF;AAED,uDAAuD;AACvD,wBAAgB,aAAa,CAAC,IAAI,EAAE,aAAa,EAAE,KAAK,EAAE,MAAM,GAAG,aAAa,CAG/E;AAED;;;GAGG;AACH,wBAAgB,cAAc,CAAC,IAAI,EAAE,aAAa,GAAG;IAAE,KAAK,EAAE,cAAc,CAAA;CAAE,GAAG;IAAE,IAAI,EAAE,aAAa,CAAA;CAAE,CAUvG"}
|
|
@@ -0,0 +1,59 @@
|
|
|
1
|
+
export const GOAL_FIELDS = [
|
|
2
|
+
{ key: "objective", label: "Objective", hint: "stopping contract and required validation" },
|
|
3
|
+
{ key: "maxTurns", label: "Max turns", hint: "supervisor cycles · 1–10000" },
|
|
4
|
+
{ key: "checkModel", label: "Check model", hint: "same provider · blank disables verifier" },
|
|
5
|
+
{ key: "timeoutMinutes", label: "Timeout", hint: "wall-clock minutes · 1–43200" }
|
|
6
|
+
];
|
|
7
|
+
export const MAX_GOAL_TURNS = 10_000;
|
|
8
|
+
export const MAX_GOAL_TIMEOUT_MINUTES = 43_200;
|
|
9
|
+
/** Legacy defaults when `config.goals` is missing. */
|
|
10
|
+
export const DEFAULT_GOAL_SETTINGS = { maxTurns: 200, timeoutMinutes: 480 };
|
|
11
|
+
/** `config.goals` from `crewcoder config show --json`, falling back field by field to the legacy defaults. */
|
|
12
|
+
export function goalDefaults(config) {
|
|
13
|
+
const goals = config && typeof config === "object" ? config.goals : undefined;
|
|
14
|
+
const record = goals && typeof goals === "object" && !Array.isArray(goals) ? goals : {};
|
|
15
|
+
const maxTurns = boundedInteger(record.maxTurns, MAX_GOAL_TURNS) ?? DEFAULT_GOAL_SETTINGS.maxTurns;
|
|
16
|
+
const timeoutMinutes = boundedInteger(record.timeoutMinutes, MAX_GOAL_TIMEOUT_MINUTES) ?? DEFAULT_GOAL_SETTINGS.timeoutMinutes;
|
|
17
|
+
const checkModel = typeof record.checkModel === "string" && record.checkModel.trim() ? record.checkModel.trim() : undefined;
|
|
18
|
+
return { maxTurns, timeoutMinutes, ...(checkModel ? { checkModel } : {}) };
|
|
19
|
+
}
|
|
20
|
+
export function initialGoalForm(defaults) {
|
|
21
|
+
return {
|
|
22
|
+
values: { objective: "", maxTurns: String(defaults.maxTurns), checkModel: defaults.checkModel ?? "", timeoutMinutes: String(defaults.timeoutMinutes) },
|
|
23
|
+
selected: 0
|
|
24
|
+
};
|
|
25
|
+
}
|
|
26
|
+
/** Move to another field (clamped); the error clears. */
|
|
27
|
+
export function selectGoalField(form, index) {
|
|
28
|
+
return { values: form.values, selected: Math.max(0, Math.min(GOAL_FIELDS.length - 1, index)) };
|
|
29
|
+
}
|
|
30
|
+
/** Set the selected field's text; the error clears. */
|
|
31
|
+
export function editGoalField(form, value) {
|
|
32
|
+
const key = GOAL_FIELDS[form.selected]?.key ?? "objective";
|
|
33
|
+
return { values: { ...form.values, [key]: value }, selected: form.selected };
|
|
34
|
+
}
|
|
35
|
+
/**
|
|
36
|
+
* The goal to start, or the form with an error on the first bad field. A blank check
|
|
37
|
+
* model turns the verifier off for this goal (legacy), not "use the default".
|
|
38
|
+
*/
|
|
39
|
+
export function submitGoalForm(form) {
|
|
40
|
+
const objective = form.values.objective.trim();
|
|
41
|
+
const maxTurns = boundedInteger(form.values.maxTurns.trim(), MAX_GOAL_TURNS);
|
|
42
|
+
const timeoutMinutes = boundedInteger(form.values.timeoutMinutes.trim(), MAX_GOAL_TIMEOUT_MINUTES);
|
|
43
|
+
const invalid = (field, error) => ({ form: { values: form.values, selected: GOAL_FIELDS.findIndex((item) => item.key === field), error } });
|
|
44
|
+
if (!objective)
|
|
45
|
+
return invalid("objective", "Objective is required.");
|
|
46
|
+
if (maxTurns === undefined)
|
|
47
|
+
return invalid("maxTurns", `Max turns must be an integer from 1 to ${MAX_GOAL_TURNS}.`);
|
|
48
|
+
if (timeoutMinutes === undefined)
|
|
49
|
+
return invalid("timeoutMinutes", `Timeout must be an integer from 1 to ${MAX_GOAL_TIMEOUT_MINUTES} minutes.`);
|
|
50
|
+
const checkModel = form.values.checkModel.trim();
|
|
51
|
+
return { start: { objective, maxTurns, timeoutMinutes, ...(checkModel ? { checkModel } : { disableCheckModel: true }) } };
|
|
52
|
+
}
|
|
53
|
+
function boundedInteger(value, maximum) {
|
|
54
|
+
if (value === "" || value === null || value === undefined)
|
|
55
|
+
return undefined;
|
|
56
|
+
const parsed = Number(value);
|
|
57
|
+
return Number.isInteger(parsed) && parsed >= 1 && parsed <= maximum ? parsed : undefined;
|
|
58
|
+
}
|
|
59
|
+
//# sourceMappingURL=goal-form.js.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"goal-form.js","sourceRoot":"","sources":["../src/goal-form.ts"],"names":[],"mappings":"AAUA,MAAM,CAAC,MAAM,WAAW,GAAmE;IACzF,EAAE,GAAG,EAAE,WAAW,EAAE,KAAK,EAAE,WAAW,EAAE,IAAI,EAAE,2CAA2C,EAAE;IAC3F,EAAE,GAAG,EAAE,UAAU,EAAE,KAAK,EAAE,WAAW,EAAE,IAAI,EAAE,6BAA6B,EAAE;IAC5E,EAAE,GAAG,EAAE,YAAY,EAAE,KAAK,EAAE,aAAa,EAAE,IAAI,EAAE,yCAAyC,EAAE;IAC5F,EAAE,GAAG,EAAE,gBAAgB,EAAE,KAAK,EAAE,SAAS,EAAE,IAAI,EAAE,8BAA8B,EAAE;CAClF,CAAC;AAEF,MAAM,CAAC,MAAM,c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AC,MAAM,EAAE,QAAQ,EAAE,WAAW,CAAC,SAAS,CAAC,CAAC,IAAI,EAAE,EAAE,CAAC,IAAI,CAAC,GAAG,KAAK,KAAK,CAAC,EAAE,KAAK,EAAE,EAAE,CAAC,CAAC;IAC/J,IAAI,CAAC,SAAS;QAAE,OAAO,OAAO,CAAC,WAAW,EAAE,wBAAwB,CAAC,CAAC;IACtE,IAAI,QAAQ,KAAK,SAAS;QAAE,OAAO,OAAO,CAAC,UAAU,EAAE,0CAA0C,cAAc,GAAG,CAAC,CAAC;IACpH,IAAI,cAAc,KAAK,SAAS;QAAE,OAAO,OAAO,CAAC,gBAAgB,EAAE,wCAAwC,wBAAwB,WAAW,CAAC,CAAC;IAChJ,MAAM,UAAU,GAAG,IAAI,CAAC,MAAM,CAAC,UAAU,CAAC,IAAI,EAAE,CAAC;IACjD,OAAO,EAAE,KAAK,EAAE,EAAE,SAAS,EAAE,QAAQ,EAAE,cAAc,EAAE,GAAG,CAAC,UAAU,CAAC,CAAC,CAAC,EAAE,UAAU,EAAE,CAAC,CAAC,CAAC,EAAE,iBAAiB,EAAE,IAAI,EAAE,CAAC,EAAE,EAAE,CAAC;AAC5H,CAAC;AAED,SAAS,cAAc,CAAC,KAAc,EAAE,OAAe;IACrD,IAAI,KAAK,KAAK,EAAE,IAAI,KAAK,KAAK,IAAI,IAAI,KAAK,KAAK,SAAS;QAAE,OAAO,SAAS,CAAC;IAC5E,MAAM,MAAM,GAAG,MAAM,CAAC,KAAK,CAAC,CAAC;IAC7B,OAAO,MAAM,CAAC,SAAS,CAAC,MAAM,CAAC,IAAI,MAAM,IAAI,CAAC,IAAI,MAAM,IAAI,OAAO,CAAC,CAAC,CAAC,MAAM,CAAC,CAAC,CAAC,SAAS,CAAC;AAC3F,CAAC","sourcesContent":["import type { GoalStartInput } from \"@onpoint-dev-tools/crewcoder-tui-core/state/command-results\";\n\n/**\n * The bare `/goal` preflight form (`docs/COMMAND_PALETTE.md#goal`), ported from legacy `GoalOverlay`:\n * objective, max turns, check model, and timeout for this goal only, prefilled from\n * `config.goals`. Pure: state, validation, and the start input; `GoalForm` only draws.\n */\n\nexport type GoalField = \"objective\" | \"maxTurns\" | \"checkModel\" | \"timeoutMinutes\";\n\nexport const GOAL_FIELDS: ReadonlyArray<{ key: GoalField; label: string; hint: string }> = [\n { key: \"objective\", label: \"Objective\", hint: \"stopping contract and required validation\" },\n { key: \"maxTurns\", label: \"Max turns\", hint: \"supervisor cycles · 1–10000\" },\n { key: \"checkModel\", label: \"Check model\", hint: \"same provider · blank disables verifier\" },\n { key: \"timeoutMinutes\", label: \"Timeout\", hint: \"wall-clock minutes · 1–43200\" }\n];\n\nexport const MAX_GOAL_TURNS = 10_000;\nexport const MAX_GOAL_TIMEOUT_MINUTES = 43_200;\n\n/** Legacy defaults when `config.goals` is missing. */\nexport const DEFAULT_GOAL_SETTINGS = { maxTurns: 200, timeoutMinutes: 480 } as const;\n\nexport type GoalFormState = {\n values: Readonly<Record<GoalField, string>>;\n /** Index into `GOAL_FIELDS`. */\n selected: number;\n error?: string;\n};\n\nexport type GoalDefaults = { maxTurns: number; timeoutMinutes: number; checkModel?: string };\n\n/** `config.goals` from `crewcoder config show --json`, falling back field by field to the legacy defaults. */\nexport function goalDefaults(config: unknown): GoalDefaults {\n const goals = config && typeof config === \"object\" ? (config as Record<string, unknown>).goals : undefined;\n const record = goals && typeof goals === \"object\" && !Array.isArray(goals) ? goals as Record<string, unknown> : {};\n const maxTurns = boundedInteger(record.maxTurns, MAX_GOAL_TURNS) ?? DEFAULT_GOAL_SETTINGS.maxTurns;\n const timeoutMinutes = boundedInteger(record.timeoutMinutes, MAX_GOAL_TIMEOUT_MINUTES) ?? DEFAULT_GOAL_SETTINGS.timeoutMinutes;\n const checkModel = typeof record.checkModel === \"string\" && record.checkModel.trim() ? record.checkModel.trim() : undefined;\n return { maxTurns, timeoutMinutes, ...(checkModel ? { checkModel } : {}) };\n}\n\nexport function initialGoalForm(defaults: GoalDefaults): GoalFormState {\n return {\n values: { objective: \"\", maxTurns: String(defaults.maxTurns), checkModel: defaults.checkModel ?? \"\", timeoutMinutes: String(defaults.timeoutMinutes) },\n selected: 0\n };\n}\n\n/** Move to another field (clamped); the error clears. */\nexport function selectGoalField(form: GoalFormState, index: number): GoalFormState {\n return { values: form.values, selected: Math.max(0, Math.min(GOAL_FIELDS.length - 1, index)) };\n}\n\n/** Set the selected field's text; the error clears. */\nexport function editGoalField(form: GoalFormState, value: string): GoalFormState {\n const key = GOAL_FIELDS[form.selected]?.key ?? \"objective\";\n return { values: { ...form.values, [key]: value }, selected: form.selected };\n}\n\n/**\n * The goal to start, or the form with an error on the first bad field. A blank check\n * model turns the verifier off for this goal (legacy), not \"use the default\".\n */\nexport function submitGoalForm(form: GoalFormState): { start: GoalStartInput } | { form: GoalFormState } {\n const objective = form.values.objective.trim();\n const maxTurns = boundedInteger(form.values.maxTurns.trim(), MAX_GOAL_TURNS);\n const timeoutMinutes = boundedInteger(form.values.timeoutMinutes.trim(), MAX_GOAL_TIMEOUT_MINUTES);\n const invalid = (field: GoalField, error: string) => ({ form: { values: form.values, selected: GOAL_FIELDS.findIndex((item) => item.key === field), error } });\n if (!objective) return invalid(\"objective\", \"Objective is required.\");\n if (maxTurns === undefined) return invalid(\"maxTurns\", `Max turns must be an integer from 1 to ${MAX_GOAL_TURNS}.`);\n if (timeoutMinutes === undefined) return invalid(\"timeoutMinutes\", `Timeout must be an integer from 1 to ${MAX_GOAL_TIMEOUT_MINUTES} minutes.`);\n const checkModel = form.values.checkModel.trim();\n return { start: { objective, maxTurns, timeoutMinutes, ...(checkModel ? { checkModel } : { disableCheckModel: true }) } };\n}\n\nfunction boundedInteger(value: unknown, maximum: number): number | undefined {\n if (value === \"\" || value === null || value === undefined) return undefined;\n const parsed = Number(value);\n return Number.isInteger(parsed) && parsed >= 1 && parsed <= maximum ? parsed : undefined;\n}\n\n"]}
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"use-animation.d.ts","sourceRoot":"","sources":["../../src/hooks/use-animation.ts"],"names":[],"mappings":"AA+CA,MAAM,WAAW,mBAAmB;IAClC,UAAU,EAAE,MAAM,CAAC;IACnB,QAAQ,CAAC,EAAE,OAAO,CAAC;CACpB;AAED,eAAO,MAAM,YAAY,GACvB,OAAM,MAAM,GAAG,mBAAwB,KACtC,MAsBF,CAAC"}
|
|
@@ -0,0 +1,52 @@
|
|
|
1
|
+
// Adapted from termcn's Ink `use-animation` (the OpenTUI spinner's registry entry
|
|
2
|
+
// points at the Ink hook). Ink's screen-reader check is removed; reduced motion
|
|
3
|
+
// from `use-motion` (NO_MOTION=1 or CI=true) still stops the animation.
|
|
4
|
+
import * as React from "react";
|
|
5
|
+
import { useMotion } from "./use-motion.js";
|
|
6
|
+
const pool = new Map();
|
|
7
|
+
const subscribe = (milliseconds, subscriber) => {
|
|
8
|
+
if (!pool.has(milliseconds)) {
|
|
9
|
+
const entry = {
|
|
10
|
+
id: null,
|
|
11
|
+
subs: new Set(),
|
|
12
|
+
tick: 0,
|
|
13
|
+
};
|
|
14
|
+
entry.id = setInterval(() => {
|
|
15
|
+
entry.tick += 1;
|
|
16
|
+
for (const sub of entry.subs) {
|
|
17
|
+
sub(entry.tick);
|
|
18
|
+
}
|
|
19
|
+
}, milliseconds);
|
|
20
|
+
pool.set(milliseconds, entry);
|
|
21
|
+
}
|
|
22
|
+
pool.get(milliseconds)?.subs.add(subscriber);
|
|
23
|
+
};
|
|
24
|
+
const unsubscribe = (milliseconds, subscriber) => {
|
|
25
|
+
const entry = pool.get(milliseconds);
|
|
26
|
+
if (!entry) {
|
|
27
|
+
return;
|
|
28
|
+
}
|
|
29
|
+
entry.subs.delete(subscriber);
|
|
30
|
+
if (entry.subs.size === 0) {
|
|
31
|
+
clearInterval(entry.id);
|
|
32
|
+
pool.delete(milliseconds);
|
|
33
|
+
}
|
|
34
|
+
};
|
|
35
|
+
export const useAnimation = (rate = 12) => {
|
|
36
|
+
const [frame, setFrame] = React.useState(0);
|
|
37
|
+
const { reduced } = useMotion();
|
|
38
|
+
const milliseconds = typeof rate === "number" ? Math.round(1000 / rate) : rate.intervalMs;
|
|
39
|
+
const isActive = (typeof rate === "number" ? true : (rate.isActive ?? true)) &&
|
|
40
|
+
!reduced;
|
|
41
|
+
React.useEffect(() => {
|
|
42
|
+
if (!isActive) {
|
|
43
|
+
setFrame(0);
|
|
44
|
+
return;
|
|
45
|
+
}
|
|
46
|
+
const callback = (tick) => setFrame(tick);
|
|
47
|
+
subscribe(milliseconds, callback);
|
|
48
|
+
return () => unsubscribe(milliseconds, callback);
|
|
49
|
+
}, [isActive, milliseconds]);
|
|
50
|
+
return frame;
|
|
51
|
+
};
|
|
52
|
+
//# sourceMappingURL=use-animation.js.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"use-animation.js","sourceRoot":"","sources":["../../src/hooks/use-animation.ts"],"names":[],"mappings":"AAAA,kFAAkF;AAClF,gFAAgF;AAChF,wEAAwE;AACxE,OAAO,KAAK,KAAK,MAAM,OAAO,CAAC;AAE/B,OAAO,EAAE,SAAS,EAAE,MAAM,iBAAiB,CAAC;AAG5C,MAAM,IAAI,GAAG,IAAI,GAAG,EAGjB,CAAC;AAEJ,MAAM,SAAS,GAAG,CAAC,YAAoB,EAAE,UAAsB,EAAE,EAAE;IACjE,IAAI,CAAC,IAAI,CAAC,GAAG,CAAC,YAAY,CAAC,EAAE,CAAC;QAC5B,MAAM,KAAK,GAAG;YACZ,EAAE,EAAE,IAAiD;YACrD,IAAI,EAAE,IAAI,GAAG,EAAc;YAC3B,IAAI,EAAE,CAAC;SACR,CAAC;QAEF,KAAK,CAAC,EAAE,GAAG,WAAW,CAAC,GAAG,EAAE;YAC1B,KAAK,CAAC,IAAI,IAAI,CAAC,CAAC;YAChB,KAAK,MAAM,GAAG,IAAI,KAAK,CAAC,IAAI,EAAE,CAAC;gBAC7B,GAAG,CAAC,KAAK,CAAC,IAAI,CAAC,CAAC;YAClB,CAAC;QACH,CAA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EAAE;QACnB,IAAI,CAAC,QAAQ,EAAE,CAAC;YACd,QAAQ,CAAC,CAAC,CAAC,CAAC;YACZ,OAAO;QACT,CAAC;QAED,MAAM,QAAQ,GAAe,CAAC,IAAI,EAAE,EAAE,CAAC,QAAQ,CAAC,IAAI,CAAC,CAAC;QACtD,SAAS,CAAC,YAAY,EAAE,QAAQ,CAAC,CAAC;QAElC,OAAO,GAAG,EAAE,CAAC,WAAW,CAAC,YAAY,EAAE,QAAQ,CAAC,CAAC;IACnD,CAAC,EAAE,CAAC,QAAQ,EAAE,YAAY,CAAC,CAAC,CAAC;IAE7B,OAAO,KAAK,CAAC;AACf,CAAC,CAAC","sourcesContent":["// Adapted from termcn's Ink `use-animation` (the OpenTUI spinner's registry entry\n// points at the Ink hook). Ink's screen-reader check is removed; reduced motion\n// from `use-motion` (NO_MOTION=1 or CI=true) still stops the animation.\nimport * as React from \"react\";\n\nimport { useMotion } from \"./use-motion.js\";\n\ntype Subscriber = (tick: number) => void;\nconst pool = new Map<\n number,\n { id: ReturnType<typeof setInterval>; subs: Set<Subscriber>; tick: number }\n>();\n\nconst subscribe = (milliseconds: number, subscriber: Subscriber) => {\n if (!pool.has(milliseconds)) {\n const entry = {\n id: null as unknown as ReturnType<typeof setInterval>,\n subs: new Set<Subscriber>(),\n tick: 0,\n };\n\n entry.id = setInterval(() => {\n entry.tick += 1;\n for (const sub of entry.subs) {\n sub(entry.tick);\n }\n }, milliseconds);\n\n pool.set(milliseconds, entry);\n }\n\n pool.get(milliseconds)?.subs.add(subscriber);\n};\n\nconst unsubscribe = (milliseconds: number, subscriber: Subscriber) => {\n const entry = pool.get(milliseconds);\n if (!entry) {\n return;\n }\n\n entry.subs.delete(subscriber);\n if (entry.subs.size === 0) {\n clearInterval(entry.id);\n pool.delete(milliseconds);\n }\n};\n\nexport interface UseAnimationOptions {\n intervalMs: number;\n isActive?: boolean;\n}\n\nexport const useAnimation = (\n rate: number | UseAnimationOptions = 12\n): number => {\n const [frame, setFrame] = React.useState(0);\n const { reduced } = useMotion();\n const milliseconds =\n typeof rate === \"number\" ? Math.round(1000 / rate) : rate.intervalMs;\n const isActive =\n (typeof rate === \"number\" ? true : (rate.isActive ?? true)) &&\n !reduced;\n\n React.useEffect(() => {\n if (!isActive) {\n setFrame(0);\n return;\n }\n\n const callback: Subscriber = (tick) => setFrame(tick);\n subscribe(milliseconds, callback);\n\n return () => unsubscribe(milliseconds, callback);\n }, [isActive, milliseconds]);\n\n return frame;\n};\n"]}
|
|
@@ -0,0 +1,6 @@
|
|
|
1
|
+
import { type AppTheme } from "../theme.js";
|
|
2
|
+
export type AppColors = Pick<AppTheme, "diff" | "syntax" | "markdown" | "logo">;
|
|
3
|
+
/** Diff, syntax, markdown, and logo colors; defaults to slate so components render without a provider. */
|
|
4
|
+
export declare const AppColorsContext: import("react").Context<AppColors>;
|
|
5
|
+
export declare const useAppColors: () => AppColors;
|
|
6
|
+
//# sourceMappingURL=use-app-colors.d.ts.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"use-app-colors.d.ts","sourceRoot":"","sources":["../../src/hooks/use-app-colors.ts"],"names":[],"mappings":"AACA,OAAO,EAAiB,KAAK,QAAQ,EAAE,MAAM,aAAa,CAAC;AAE3D,MAAM,MAAM,SAAS,GAAG,IAAI,CAAC,QAAQ,EAAE,MAAM,GAAG,QAAQ,GAAG,UAAU,GAAG,MAAM,CAAC,CAAC;AAEhF,0GAA0G;AAC1G,eAAO,MAAM,gBAAgB,oCAAmJ,CAAC;AAEjL,eAAO,MAAM,YAAY,QAAO,SAAyC,CAAC"}
|
|
@@ -0,0 +1,6 @@
|
|
|
1
|
+
import { createContext, useContext } from "react";
|
|
2
|
+
import { slateAppTheme } from "../theme.js";
|
|
3
|
+
/** Diff, syntax, markdown, and logo colors; defaults to slate so components render without a provider. */
|
|
4
|
+
export const AppColorsContext = createContext({ diff: slateAppTheme.diff, syntax: slateAppTheme.syntax, markdown: slateAppTheme.markdown, logo: slateAppTheme.logo });
|
|
5
|
+
export const useAppColors = () => useContext(AppColorsContext);
|
|
6
|
+
//# sourceMappingURL=use-app-colors.js.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"use-app-colors.js","sourceRoot":"","sources":["../../src/hooks/use-app-colors.ts"],"names":[],"mappings":"AAAA,OAAO,EAAE,aAAa,EAAE,UAAU,EAAE,MAAM,OAAO,CAAC;AAClD,OAAO,EAAE,aAAa,EAAiB,MAAM,aAAa,CAAC;AAI3D,0GAA0G;AAC1G,MAAM,CAAC,MAAM,gBAAgB,GAAG,aAAa,CAAY,EAAE,IAAI,EAAE,aAAa,CAAC,IAAI,EAAE,MAAM,EAAE,aAAa,CAAC,MAAM,EAAE,QAAQ,EAAE,aAAa,CAAC,QAAQ,EAAE,IAAI,EAAE,aAAa,CAAC,IAAI,EAAE,CAAC,CAAC;AAEjL,MAAM,CAAC,MAAM,YAAY,GAAG,GAAc,EAAE,CAAC,UAAU,CAAC,gBAAgB,CAAC,CAAC","sourcesContent":["import { createContext, useContext } from \"react\";\nimport { slateAppTheme, type AppTheme } from \"../theme.js\";\n\nexport type AppColors = Pick<AppTheme, \"diff\" | \"syntax\" | \"markdown\" | \"logo\">;\n\n/** Diff, syntax, markdown, and logo colors; defaults to slate so components render without a provider. */\nexport const AppColorsContext = createContext<AppColors>({ diff: slateAppTheme.diff, syntax: slateAppTheme.syntax, markdown: slateAppTheme.markdown, logo: slateAppTheme.logo });\n\nexport const useAppColors = (): AppColors => useContext(AppColorsContext);\n"]}
|
|
@@ -0,0 +1,8 @@
|
|
|
1
|
+
import { type GlyphSet } from "../glyphs.js";
|
|
2
|
+
/**
|
|
3
|
+
* The icon set this terminal can draw. Follows the renderer's capability
|
|
4
|
+
* probe, which can answer after the first frame (tmux re-reports several times),
|
|
5
|
+
* so icons switch once the terminal is known.
|
|
6
|
+
*/
|
|
7
|
+
export declare function useGlyphSet(): GlyphSet;
|
|
8
|
+
//# sourceMappingURL=use-glyph-set.d.ts.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"use-glyph-set.d.ts","sourceRoot":"","sources":["../../src/hooks/use-glyph-set.ts"],"names":[],"mappings":"AAGA,OAAO,EAA+B,KAAK,QAAQ,EAAE,MAAM,cAAc,CAAC;AAE1E;;;;GAIG;AACH,wBAAgB,WAAW,IAAI,QAAQ,CAYtC"}
|
|
@@ -0,0 +1,22 @@
|
|
|
1
|
+
import { useRenderer } from "@opentui/react";
|
|
2
|
+
import { useEffect, useState } from "react";
|
|
3
|
+
import { GLYPHS_ENV, resolveGlyphSet } from "../glyphs.js";
|
|
4
|
+
/**
|
|
5
|
+
* The icon set this terminal can draw. Follows the renderer's capability
|
|
6
|
+
* probe, which can answer after the first frame (tmux re-reports several times),
|
|
7
|
+
* so icons switch once the terminal is known.
|
|
8
|
+
*/
|
|
9
|
+
export function useGlyphSet() {
|
|
10
|
+
const renderer = useRenderer();
|
|
11
|
+
const [capabilities, setCapabilities] = useState(renderer.capabilities);
|
|
12
|
+
useEffect(() => {
|
|
13
|
+
const update = (next) => setCapabilities(next);
|
|
14
|
+
renderer.on("capabilities", update);
|
|
15
|
+
setCapabilities(renderer.capabilities);
|
|
16
|
+
return () => {
|
|
17
|
+
renderer.off("capabilities", update);
|
|
18
|
+
};
|
|
19
|
+
}, [renderer]);
|
|
20
|
+
return resolveGlyphSet(capabilities, process.env[GLYPHS_ENV]);
|
|
21
|
+
}
|
|
22
|
+
//# sourceMappingURL=use-glyph-set.js.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"use-glyph-set.js","sourceRoot":"","sources":["../../src/hooks/use-glyph-set.ts"],"names":[],"mappings":"AACA,OAAO,EAAE,WAAW,EAAE,MAAM,gBAAgB,CAAC;AAC7C,OAAO,EAAE,SAAS,EAAE,QAAQ,EAAE,MAAM,OAAO,CAAC;AAC5C,OAAO,EAAE,UAAU,EAAE,eAAe,EAAiB,MAAM,cAAc,CAAC;AAE1E;;;;GAIG;AACH,MAAM,UAAU,WAAW;IACzB,MAAM,QAAQ,GAAG,WAAW,EAAE,CAAC;IAC/B,MAAM,CAAC,YAAY,EAAE,eAAe,CAAC,GAAG,QAAQ,CAA8B,QAAQ,CAAC,YAAY,CAAC,CAAC;IACrG,SAAS,CAAC,GAAG,EAAE;QACb,MAAM,MAAM,GAAG,CAAC,IAA0B,EAAQ,EAAE,CAAC,eAAe,CAAC,IAAI,CAAC,CAAC;QAC3E,QAAQ,CAAC,EAAE,CAAC,cAAc,EAAE,MAAM,CAAC,CAAC;QACpC,eAAe,CAAC,QAAQ,CAAC,YAAY,CAAC,CAAC;QACvC,OAAO,GAAG,EAAE;YACV,QAAQ,CAAC,GAAG,CAAC,cAAc,EAAE,MAAM,CAAC,CAAC;QACvC,CAAC,CAAC;IACJ,CAAC,EAAE,CAAC,QAAQ,CAAC,CAAC,CAAC;IACf,OAAO,eAAe,CAAC,YAAY,EAAE,OAAO,CAAC,GAAG,CAAC,UAAU,CAAC,CAAC,CAAC;AAChE,CAAC","sourcesContent":["import type { TerminalCapabilities } from \"@opentui/core\";\nimport { useRenderer } from \"@opentui/react\";\nimport { useEffect, useState } from \"react\";\nimport { GLYPHS_ENV, resolveGlyphSet, type GlyphSet } from \"../glyphs.js\";\n\n/**\n * The icon set this terminal can draw. Follows the renderer's capability\n * probe, which can answer after the first frame (tmux re-reports several times),\n * so icons switch once the terminal is known.\n */\nexport function useGlyphSet(): GlyphSet {\n const renderer = useRenderer();\n const [capabilities, setCapabilities] = useState<TerminalCapabilities | null>(renderer.capabilities);\n useEffect(() => {\n const update = (next: TerminalCapabilities): void => setCapabilities(next);\n renderer.on(\"capabilities\", update);\n setCapabilities(renderer.capabilities);\n return () => {\n renderer.off(\"capabilities\", update);\n };\n }, [renderer]);\n return resolveGlyphSet(capabilities, process.env[GLYPHS_ENV]);\n}\n"]}
|
|
@@ -0,0 +1,6 @@
|
|
|
1
|
+
import * as React from "react";
|
|
2
|
+
import type { MotionContextValue } from "../components/ui/types.js";
|
|
3
|
+
export declare const isReducedMotion: () => boolean;
|
|
4
|
+
export declare const MotionContext: React.Context<MotionContextValue>;
|
|
5
|
+
export declare const useMotion: () => MotionContextValue;
|
|
6
|
+
//# sourceMappingURL=use-motion.d.ts.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"use-motion.d.ts","sourceRoot":"","sources":["../../src/hooks/use-motion.ts"],"names":[],"mappings":"AAAA,OAAO,KAAK,KAAK,MAAM,OAAO,CAAC;AAE/B,OAAO,KAAK,EAAE,kBAAkB,EAAE,MAAM,2BAA2B,CAAC;AAKpE,eAAO,MAAM,eAAe,QAAO,OACqB,CAAC;AAEzD,eAAO,MAAM,aAAa,mCAExB,CAAC;AAEH,eAAO,MAAM,SAAS,QAAO,kBACI,CAAC"}
|
|
@@ -0,0 +1,8 @@
|
|
|
1
|
+
import * as React from "react";
|
|
2
|
+
const getEnv = (name) => typeof process !== "undefined" && process.env ? process.env[name] : undefined;
|
|
3
|
+
export const isReducedMotion = () => getEnv("NO_MOTION") === "1" || getEnv("CI") === "true";
|
|
4
|
+
export const MotionContext = React.createContext({
|
|
5
|
+
reduced: isReducedMotion(),
|
|
6
|
+
});
|
|
7
|
+
export const useMotion = () => React.useContext(MotionContext);
|
|
8
|
+
//# sourceMappingURL=use-motion.js.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"use-motion.js","sourceRoot":"","sources":["../../src/hooks/use-motion.ts"],"names":[],"mappings":"AAAA,OAAO,KAAK,KAAK,MAAM,OAAO,CAAC;AAI/B,MAAM,MAAM,GAAG,CAAC,IAAY,EAAsB,EAAE,CAClD,OAAO,OAAO,KAAK,WAAW,IAAI,OAAO,CAAC,GAAG,CAAC,CAAC,CAAC,OAAO,CAAC,GAAG,CAAC,IAAI,CAAC,CAAC,CAAC,CAAC,SAAS,CAAC;AAEhF,MAAM,CAAC,MAAM,eAAe,GAAG,GAAY,EAAE,CAC3C,MAAM,CAAC,WAAW,CAAC,KAAK,GAAG,IAAI,MAAM,CAAC,IAAI,CAAC,KAAK,MAAM,CAAC;AAEzD,MAAM,CAAC,MAAM,aAAa,GAAG,KAAK,CAAC,aAAa,CAAqB;IACnE,OAAO,EAAE,eAAe,EAAE;CAC3B,CAAC,CAAC;AAEH,MAAM,CAAC,MAAM,SAAS,GAAG,GAAuB,EAAE,CAChD,KAAK,CAAC,UAAU,CAAC,aAAa,CAAC,CAAC","sourcesContent":["import * as React from \"react\";\n\nimport type { MotionContextValue } from \"../components/ui/types.js\";\n\nconst getEnv = (name: string): string | undefined =>\n typeof process !== \"undefined\" && process.env ? process.env[name] : undefined;\n\nexport const isReducedMotion = (): boolean =>\n getEnv(\"NO_MOTION\") === \"1\" || getEnv(\"CI\") === \"true\";\n\nexport const MotionContext = React.createContext<MotionContextValue>({\n reduced: isReducedMotion(),\n});\n\nexport const useMotion = (): MotionContextValue =>\n React.useContext(MotionContext);\n"]}
|
|
@@ -0,0 +1,16 @@
|
|
|
1
|
+
import { type RefObject } from "react";
|
|
2
|
+
/**
|
|
3
|
+
* Whether this terminal surface has focus, from focus reporting (DECSET 1004,
|
|
4
|
+
* which OpenTUI enables itself and turns off on exit).
|
|
5
|
+
*
|
|
6
|
+
* Ported from the legacy `InputFocusGate`: while the tab, pane, or window is
|
|
7
|
+
* unfocused, input is dropped, so input a terminal duplicates to several panes
|
|
8
|
+
* (broadcast input, emulator bugs) cannot reach a second CrewCoder instance.
|
|
9
|
+
* App drops keys with this ref; pastes are dropped here, because global paste
|
|
10
|
+
* listeners run before the focused composer and it honors `preventDefault`.
|
|
11
|
+
*
|
|
12
|
+
* Starts focused: a terminal without focus reporting never sends focus events,
|
|
13
|
+
* so input keeps working there.
|
|
14
|
+
*/
|
|
15
|
+
export declare function useTerminalFocus(): RefObject<boolean>;
|
|
16
|
+
//# sourceMappingURL=use-terminal-focus.d.ts.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"use-terminal-focus.d.ts","sourceRoot":"","sources":["../../src/hooks/use-terminal-focus.ts"],"names":[],"mappings":"AACA,OAAO,EAAU,KAAK,SAAS,EAAE,MAAM,OAAO,CAAC;AAE/C;;;;;;;;;;;;GAYG;AACH,wBAAgB,gBAAgB,IAAI,SAAS,CAAC,OAAO,CAAC,CAYrD"}
|
|
@@ -0,0 +1,30 @@
|
|
|
1
|
+
import { useBlur, useFocus, usePaste } from "@opentui/react";
|
|
2
|
+
import { useRef } from "react";
|
|
3
|
+
/**
|
|
4
|
+
* Whether this terminal surface has focus, from focus reporting (DECSET 1004,
|
|
5
|
+
* which OpenTUI enables itself and turns off on exit).
|
|
6
|
+
*
|
|
7
|
+
* Ported from the legacy `InputFocusGate`: while the tab, pane, or window is
|
|
8
|
+
* unfocused, input is dropped, so input a terminal duplicates to several panes
|
|
9
|
+
* (broadcast input, emulator bugs) cannot reach a second CrewCoder instance.
|
|
10
|
+
* App drops keys with this ref; pastes are dropped here, because global paste
|
|
11
|
+
* listeners run before the focused composer and it honors `preventDefault`.
|
|
12
|
+
*
|
|
13
|
+
* Starts focused: a terminal without focus reporting never sends focus events,
|
|
14
|
+
* so input keeps working there.
|
|
15
|
+
*/
|
|
16
|
+
export function useTerminalFocus() {
|
|
17
|
+
const focused = useRef(true);
|
|
18
|
+
useFocus(() => {
|
|
19
|
+
focused.current = true;
|
|
20
|
+
});
|
|
21
|
+
useBlur(() => {
|
|
22
|
+
focused.current = false;
|
|
23
|
+
});
|
|
24
|
+
usePaste((event) => {
|
|
25
|
+
if (!focused.current)
|
|
26
|
+
event.preventDefault();
|
|
27
|
+
});
|
|
28
|
+
return focused;
|
|
29
|
+
}
|
|
30
|
+
//# sourceMappingURL=use-terminal-focus.js.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"use-terminal-focus.js","sourceRoot":"","sources":["../../src/hooks/use-terminal-focus.ts"],"names":[],"mappings":"AAAA,OAAO,EAAE,OAAO,EAAE,QAAQ,EAAE,QAAQ,EAAE,MAAM,gBAAgB,CAAC;AAC7D,OAAO,EAAE,MAAM,EAAkB,MAAM,OAAO,CAAC;AAE/C;;;;;;;;;;;;GAYG;AACH,MAAM,UAAU,gBAAgB;IAC9B,MAAM,OAAO,GAAG,MAAM,CAAC,IAAI,CAAC,CAAC;IAC7B,QAAQ,CAAC,GAAG,EAAE;QACZ,OAAO,CAAC,OAAO,GAAG,IAAI,CAAC;IACzB,CAAC,CAAC,CAAC;IACH,OAAO,CAAC,GAAG,EAAE;QACX,OAAO,CAAC,OAAO,GAAG,KAAK,CAAC;IAC1B,CAAC,CAAC,CAAC;IACH,QAAQ,CAAC,CAAC,KAAK,EAAE,EAAE;QACjB,IAAI,CAAC,OAAO,CAAC,OAAO;YAAE,KAAK,CAAC,cAAc,EAAE,CAAC;IAC/C,CAAC,CAAC,CAAC;IACH,OAAO,OAAO,CAAC;AACjB,CAAC","sourcesContent":["import { useBlur, useFocus, usePaste } from \"@opentui/react\";\nimport { useRef, type RefObject } from \"react\";\n\n/**\n * Whether this terminal surface has focus, from focus reporting (DECSET 1004,\n * which OpenTUI enables itself and turns off on exit).\n *\n * Ported from the legacy `InputFocusGate`: while the tab, pane, or window is\n * unfocused, input is dropped, so input a terminal duplicates to several panes\n * (broadcast input, emulator bugs) cannot reach a second CrewCoder instance.\n * App drops keys with this ref; pastes are dropped here, because global paste\n * listeners run before the focused composer and it honors `preventDefault`.\n *\n * Starts focused: a terminal without focus reporting never sends focus events,\n * so input keeps working there.\n */\nexport function useTerminalFocus(): RefObject<boolean> {\n const focused = useRef(true);\n useFocus(() => {\n focused.current = true;\n });\n useBlur(() => {\n focused.current = false;\n });\n usePaste((event) => {\n if (!focused.current) event.preventDefault();\n });\n return focused;\n}\n"]}
|
|
@@ -0,0 +1,6 @@
|
|
|
1
|
+
import * as React from "react";
|
|
2
|
+
import type { Theme, ThemeContextValue } from "../components/ui/types.js";
|
|
3
|
+
export declare const ThemeContext: React.Context<ThemeContextValue>;
|
|
4
|
+
export declare const useTheme: () => Theme;
|
|
5
|
+
export declare const useThemeUpdater: () => ((theme: Theme) => void);
|
|
6
|
+
//# sourceMappingURL=use-theme.d.ts.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"use-theme.d.ts","sourceRoot":"","sources":["../../src/hooks/use-theme.ts"],"names":[],"mappings":"AAAA,OAAO,KAAK,KAAK,MAAM,OAAO,CAAC;AAG/B,OAAO,KAAK,EACV,KAAK,EACL,iBAAiB,EAClB,MAAM,2BAA2B,CAAC;AAEnC,eAAO,MAAM,YAAY,kCAKvB,CAAC;AAEH,eAAO,MAAM,QAAQ,QAAO,KAA6C,CAAC;AAE1E,eAAO,MAAM,eAAe,QAAO,CAAC,CAAC,KAAK,EAAE,KAAK,KAAK,IAAI,CACjB,CAAC"}
|