@sixb/app 0.2.3 → 0.2.5
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/assets/connector-icons/README.md +1 -0
- package/assets/connector-icons/ctm.png +0 -0
- package/dist/agent/activity-label.d.ts.map +1 -1
- package/dist/agent/agent-chat.d.ts +3 -1
- package/dist/agent/agent-chat.d.ts.map +1 -1
- package/dist/agent/agent-panel.d.ts.map +1 -1
- package/dist/agent/artifact-panel.d.ts +3 -1
- package/dist/agent/artifact-panel.d.ts.map +1 -1
- package/dist/agent/background/background-tool-row.d.ts.map +1 -1
- package/dist/agent/background/interpret.d.ts +1 -1
- package/dist/agent/background/interpret.d.ts.map +1 -1
- package/dist/agent/components/composer-settings.d.ts +1 -1
- package/dist/agent/components/composer-settings.d.ts.map +1 -1
- package/dist/agent/components/composer.d.ts +22 -5
- package/dist/agent/components/composer.d.ts.map +1 -1
- package/dist/agent/components/context-meter.d.ts +1 -1
- package/dist/agent/components/context-meter.d.ts.map +1 -1
- package/dist/agent/components/conversation-panel.d.ts +8 -2
- package/dist/agent/components/conversation-panel.d.ts.map +1 -1
- package/dist/agent/components/message-parts.d.ts +2 -1
- package/dist/agent/components/message-parts.d.ts.map +1 -1
- package/dist/agent/components/message-view.d.ts.map +1 -1
- package/dist/agent/components/pending-messages.d.ts +20 -0
- package/dist/agent/components/pending-messages.d.ts.map +1 -0
- package/dist/agent/components/sandbox-recovery.d.ts +11 -2
- package/dist/agent/components/sandbox-recovery.d.ts.map +1 -1
- package/dist/agent/components/threads-button.d.ts +1 -1
- package/dist/agent/components/threads-button.d.ts.map +1 -1
- package/dist/agent/components/transcript.d.ts +5 -0
- package/dist/agent/components/transcript.d.ts.map +1 -1
- package/dist/agent/conversation.d.ts +3 -6
- package/dist/agent/conversation.d.ts.map +1 -1
- package/dist/agent/delegation/agent-exchange.d.ts +16 -0
- package/dist/agent/delegation/agent-exchange.d.ts.map +1 -0
- package/dist/agent/delegation/child-card.d.ts +3 -3
- package/dist/agent/delegation/child-card.d.ts.map +1 -1
- package/dist/agent/delegation/child-parts.d.ts +1 -10
- package/dist/agent/delegation/child-parts.d.ts.map +1 -1
- package/dist/agent/delegation/child-work.d.ts.map +1 -1
- package/dist/agent/delegation/interpret.d.ts +9 -10
- package/dist/agent/delegation/interpret.d.ts.map +1 -1
- package/dist/agent/delegation/use-children.d.ts.map +1 -1
- package/dist/agent/file-edits/file-edit-tool-view.d.ts +10 -0
- package/dist/agent/file-edits/file-edit-tool-view.d.ts.map +1 -0
- package/dist/agent/file-edits/interpret.d.ts +25 -0
- package/dist/agent/file-edits/interpret.d.ts.map +1 -0
- package/dist/agent/hooks/use-agent-conversation.d.ts +16 -4
- package/dist/agent/hooks/use-agent-conversation.d.ts.map +1 -1
- package/dist/agent/hooks/use-thread-lists.d.ts.map +1 -1
- package/dist/agent/hooks/use-thread-stream.d.ts.map +1 -1
- package/dist/agent/i18n/en.d.ts +114 -5
- package/dist/agent/i18n/en.d.ts.map +1 -1
- package/dist/agent/i18n/fr.d.ts.map +1 -1
- package/dist/agent/i18n/index.d.ts +190 -8
- package/dist/agent/i18n/index.d.ts.map +1 -1
- package/dist/agent/inbox-handoff.d.ts +10 -0
- package/dist/agent/inbox-handoff.d.ts.map +1 -0
- package/dist/agent/live-run.d.ts +8 -1
- package/dist/agent/live-run.d.ts.map +1 -1
- package/dist/agent/message-agent/interpret.d.ts +2 -2
- package/dist/agent/message-agent/interpret.d.ts.map +1 -1
- package/dist/agent/publish-artifact/interpret.d.ts +1 -1
- package/dist/agent/publish-artifact/interpret.d.ts.map +1 -1
- package/dist/agent/questions/interpret.d.ts +31 -0
- package/dist/agent/questions/interpret.d.ts.map +1 -0
- package/dist/agent/questions/question-card.d.ts +16 -0
- package/dist/agent/questions/question-card.d.ts.map +1 -0
- package/dist/agent/questions/question-composer.d.ts +15 -0
- package/dist/agent/questions/question-composer.d.ts.map +1 -0
- package/dist/agent/read/interpret.d.ts +8 -1
- package/dist/agent/read/interpret.d.ts.map +1 -1
- package/dist/agent/read/read-tool-view.d.ts.map +1 -1
- package/dist/agent/search/interpret.d.ts +101 -0
- package/dist/agent/search/interpret.d.ts.map +1 -0
- package/dist/agent/search/search-tool-view.d.ts +10 -0
- package/dist/agent/search/search-tool-view.d.ts.map +1 -0
- package/dist/agent/thread-state.d.ts +26 -0
- package/dist/agent/thread-state.d.ts.map +1 -0
- package/dist/agent/tool-views/built-in.d.ts.map +1 -1
- package/dist/agent/tool-views/registry.d.ts +5 -6
- package/dist/agent/tool-views/registry.d.ts.map +1 -1
- package/dist/agent/types.d.ts +5 -1
- package/dist/agent/types.d.ts.map +1 -1
- package/dist/agent/view-file/view-file-tool-view.d.ts +2 -1
- package/dist/agent/view-file/view-file-tool-view.d.ts.map +1 -1
- package/dist/agent/waits.d.ts +14 -0
- package/dist/agent/waits.d.ts.map +1 -0
- package/dist/artifacts/card-preview.d.ts.map +1 -1
- package/dist/artifacts/edit-session.d.ts +11 -1
- package/dist/artifacts/edit-session.d.ts.map +1 -1
- package/dist/artifacts/editor/block-handle.d.ts +20 -0
- package/dist/artifacts/editor/block-handle.d.ts.map +1 -0
- package/dist/artifacts/editor/blocks.d.ts +34 -0
- package/dist/artifacts/editor/blocks.d.ts.map +1 -0
- package/dist/artifacts/editor/callout-view.d.ts +7 -0
- package/dist/artifacts/editor/callout-view.d.ts.map +1 -0
- package/dist/artifacts/editor/document-editor.d.ts +30 -0
- package/dist/artifacts/editor/document-editor.d.ts.map +1 -0
- package/dist/artifacts/editor/figure-view.d.ts +12 -0
- package/dist/artifacts/editor/figure-view.d.ts.map +1 -0
- package/dist/artifacts/editor/find-blocks.d.ts +6 -0
- package/dist/artifacts/editor/find-blocks.d.ts.map +1 -0
- package/dist/artifacts/editor/markdown-document.d.ts +12 -0
- package/dist/artifacts/editor/markdown-document.d.ts.map +1 -0
- package/dist/artifacts/editor/messages.d.ts +4 -0
- package/dist/artifacts/editor/messages.d.ts.map +1 -0
- package/dist/artifacts/editor/schema.d.ts +21 -0
- package/dist/artifacts/editor/schema.d.ts.map +1 -0
- package/dist/artifacts/editor/selection-toolbar.d.ts +35 -0
- package/dist/artifacts/editor/selection-toolbar.d.ts.map +1 -0
- package/dist/artifacts/editor/slash-menu.d.ts +43 -0
- package/dist/artifacts/editor/slash-menu.d.ts.map +1 -0
- package/dist/artifacts/editor/upload.d.ts +12 -0
- package/dist/artifacts/editor/upload.d.ts.map +1 -0
- package/dist/artifacts/file-source.d.ts +5 -0
- package/dist/artifacts/file-source.d.ts.map +1 -1
- package/dist/artifacts/frame-editor/bundle.d.ts +7 -0
- package/dist/artifacts/frame-editor/bundle.d.ts.map +1 -0
- package/dist/artifacts/frame-editor/commands.d.ts +93 -0
- package/dist/artifacts/frame-editor/commands.d.ts.map +1 -0
- package/dist/artifacts/frame-editor/entry.d.ts +2 -0
- package/dist/artifacts/frame-editor/entry.d.ts.map +1 -0
- package/dist/artifacts/frame-editor/frame.d.ts +5 -0
- package/dist/artifacts/frame-editor/frame.d.ts.map +1 -0
- package/dist/artifacts/frame-editor/keys.d.ts +8 -0
- package/dist/artifacts/frame-editor/keys.d.ts.map +1 -0
- package/dist/artifacts/frame-editor/protocol.d.ts +186 -0
- package/dist/artifacts/frame-editor/protocol.d.ts.map +1 -0
- package/dist/artifacts/frame-editor/schema.d.ts +34 -0
- package/dist/artifacts/frame-editor/schema.d.ts.map +1 -0
- package/dist/artifacts/frame-editor/style.d.ts +2 -0
- package/dist/artifacts/frame-editor/style.d.ts.map +1 -0
- package/dist/artifacts/frame.d.ts +2 -2
- package/dist/artifacts/frame.d.ts.map +1 -1
- package/dist/artifacts/live/boards.d.ts +2 -0
- package/dist/artifacts/live/boards.d.ts.map +1 -1
- package/dist/artifacts/live/document.d.ts +32 -0
- package/dist/artifacts/live/document.d.ts.map +1 -0
- package/dist/artifacts/live/header.d.ts +4 -4
- package/dist/artifacts/live/header.d.ts.map +1 -1
- package/dist/artifacts/live/presence.d.ts.map +1 -1
- package/dist/artifacts/live/session.d.ts +2 -0
- package/dist/artifacts/live/session.d.ts.map +1 -1
- package/dist/artifacts/live/view.d.ts +4 -3
- package/dist/artifacts/live/view.d.ts.map +1 -1
- package/dist/artifacts/messages.d.ts +278 -2
- package/dist/artifacts/messages.d.ts.map +1 -1
- package/dist/artifacts/pdf.d.ts +8 -0
- package/dist/artifacts/pdf.d.ts.map +1 -0
- package/dist/artifacts/queries.d.ts +80 -0
- package/dist/artifacts/queries.d.ts.map +1 -1
- package/dist/artifacts/references/references.d.ts +3 -3
- package/dist/artifacts/references/references.d.ts.map +1 -1
- package/dist/artifacts/renderers/canvas/board-editor.d.ts +11 -4
- package/dist/artifacts/renderers/canvas/board-editor.d.ts.map +1 -1
- package/dist/artifacts/renderers/canvas/board.d.ts +14 -2
- package/dist/artifacts/renderers/canvas/board.d.ts.map +1 -1
- package/dist/artifacts/renderers/canvas/canvas.d.ts +4 -3
- package/dist/artifacts/renderers/canvas/canvas.d.ts.map +1 -1
- package/dist/artifacts/renderers/canvas/comment-pins.d.ts +4 -2
- package/dist/artifacts/renderers/canvas/comment-pins.d.ts.map +1 -1
- package/dist/artifacts/renderers/canvas/comments-panel.d.ts.map +1 -1
- package/dist/artifacts/renderers/canvas/comments.d.ts +2 -1
- package/dist/artifacts/renderers/canvas/comments.d.ts.map +1 -1
- package/dist/artifacts/renderers/canvas/controls.d.ts +15 -4
- package/dist/artifacts/renderers/canvas/controls.d.ts.map +1 -1
- package/dist/artifacts/renderers/canvas/focus.d.ts +19 -5
- package/dist/artifacts/renderers/canvas/focus.d.ts.map +1 -1
- package/dist/artifacts/renderers/canvas/gestures.d.ts +46 -0
- package/dist/artifacts/renderers/canvas/gestures.d.ts.map +1 -0
- package/dist/artifacts/renderers/canvas/page-resize.d.ts +21 -0
- package/dist/artifacts/renderers/canvas/page-resize.d.ts.map +1 -0
- package/dist/artifacts/renderers/canvas/page-size-controls.d.ts +21 -0
- package/dist/artifacts/renderers/canvas/page-size-controls.d.ts.map +1 -0
- package/dist/artifacts/renderers/canvas/page-size.d.ts +93 -0
- package/dist/artifacts/renderers/canvas/page-size.d.ts.map +1 -0
- package/dist/artifacts/renderers/canvas/page-zoom.d.ts +64 -0
- package/dist/artifacts/renderers/canvas/page-zoom.d.ts.map +1 -0
- package/dist/artifacts/renderers/canvas/shown-size.d.ts +26 -0
- package/dist/artifacts/renderers/canvas/shown-size.d.ts.map +1 -0
- package/dist/artifacts/renderers/designed-document.d.ts +28 -0
- package/dist/artifacts/renderers/designed-document.d.ts.map +1 -0
- package/dist/artifacts/renderers/document-tree.d.ts +2 -0
- package/dist/artifacts/renderers/document-tree.d.ts.map +1 -1
- package/dist/artifacts/renderers/document.d.ts +9 -1
- package/dist/artifacts/renderers/document.d.ts.map +1 -1
- package/dist/artifacts/renderers/live-frame.d.ts +145 -0
- package/dist/artifacts/renderers/live-frame.d.ts.map +1 -0
- package/dist/artifacts/renderers/page-editor.d.ts +16 -0
- package/dist/artifacts/renderers/page-editor.d.ts.map +1 -0
- package/dist/artifacts/renderers/page.d.ts +10 -1
- package/dist/artifacts/renderers/page.d.ts.map +1 -1
- package/dist/artifacts/viewer.d.ts.map +1 -1
- package/dist/{chunk-001c4gnk.js → chunk-4fex83k2.js} +19965 -13027
- package/dist/chunk-4fex83k2.js.map +239 -0
- package/dist/{chunk-5crvhjp2.js → chunk-4wm09prf.js} +1633 -1999
- package/dist/chunk-4wm09prf.js.map +27 -0
- package/dist/{chunk-fwb9mxwm.js → chunk-5sgac68y.js} +1 -1
- package/dist/{chunk-kes4ygmz.js → chunk-69qgh20f.js} +1 -1
- package/dist/chunk-y51c4tsz.js +11 -0
- package/dist/chunk-y51c4tsz.js.map +10 -0
- package/dist/index.d.ts +4 -1
- package/dist/index.d.ts.map +1 -1
- package/dist/index.js +13 -6
- package/dist/index.js.map +5 -5
- package/dist/pages/console/data/messages.d.ts +6 -0
- package/dist/pages/console/data/messages.d.ts.map +1 -1
- package/dist/pages/console/data/shared.d.ts.map +1 -1
- package/dist/pages.js +12 -5
- package/dist/pages.js.map +6 -6
- package/dist/shell/search-command.d.ts.map +1 -1
- package/package.json +22 -5
- package/src/agent/activity-label.ts +9 -1
- package/src/agent/agent-chat.tsx +57 -37
- package/src/agent/agent-execution-trace.tsx +2 -2
- package/src/agent/agent-panel.tsx +6 -4
- package/src/agent/agent.css +254 -0
- package/src/agent/artifact-panel.tsx +77 -22
- package/src/agent/background/background-tool-row.tsx +24 -10
- package/src/agent/background/interpret.ts +60 -51
- package/src/agent/components/composer-settings.tsx +20 -10
- package/src/agent/components/composer.tsx +342 -104
- package/src/agent/components/context-meter.tsx +7 -3
- package/src/agent/components/conversation-panel.tsx +96 -37
- package/src/agent/components/message-parts.tsx +390 -64
- package/src/agent/components/message-view.tsx +12 -2
- package/src/agent/components/pending-messages.tsx +338 -0
- package/src/agent/components/sandbox-recovery.tsx +36 -17
- package/src/agent/components/threads-button.tsx +3 -2
- package/src/agent/components/transcript.tsx +92 -45
- package/src/agent/conversation.ts +203 -54
- package/src/agent/delegation/agent-exchange.tsx +53 -0
- package/src/agent/delegation/child-card.tsx +6 -40
- package/src/agent/delegation/child-parts.tsx +1 -84
- package/src/agent/delegation/child-work.tsx +19 -5
- package/src/agent/delegation/interpret.ts +64 -61
- package/src/agent/delegation/model.ts +1 -1
- package/src/agent/file-edits/file-edit-tool-view.tsx +126 -0
- package/src/agent/file-edits/interpret.ts +120 -0
- package/src/agent/hooks/use-agent-conversation.ts +360 -92
- package/src/agent/hooks/use-thread-stream.ts +10 -0
- package/src/agent/i18n/en.ts +134 -16
- package/src/agent/i18n/fr.ts +122 -16
- package/src/agent/inbox-handoff.ts +47 -0
- package/src/agent/live-run.ts +23 -2
- package/src/agent/message-agent/interpret.ts +4 -3
- package/src/agent/publish-artifact/interpret.ts +14 -5
- package/src/agent/publish-artifact/publish-artifact-tool-view.tsx +2 -2
- package/src/agent/questions/interpret.ts +90 -0
- package/src/agent/questions/question-card.tsx +57 -0
- package/src/agent/questions/question-composer.tsx +257 -0
- package/src/agent/react-router.tsx +2 -2
- package/src/agent/read/interpret.ts +34 -1
- package/src/agent/read/read-tool-view.tsx +20 -4
- package/src/agent/search/interpret.ts +367 -0
- package/src/agent/search/search-tool-view.tsx +235 -0
- package/src/agent/thread-state.ts +114 -0
- package/src/agent/tool-views/built-in.tsx +33 -6
- package/src/agent/tool-views/registry.tsx +28 -2
- package/src/agent/types.ts +7 -0
- package/src/agent/view-file/view-file-tool-view.tsx +33 -19
- package/src/agent/waits.ts +50 -0
- package/src/artifacts/artifacts.css +434 -0
- package/src/artifacts/card-preview.tsx +6 -1
- package/src/artifacts/edit-session.tsx +15 -1
- package/src/artifacts/editor/block-handle.tsx +278 -0
- package/src/artifacts/editor/blocks.ts +216 -0
- package/src/artifacts/editor/callout-view.tsx +31 -0
- package/src/artifacts/editor/document-editor.tsx +484 -0
- package/src/artifacts/editor/figure-view.tsx +66 -0
- package/src/artifacts/editor/find-blocks.ts +19 -0
- package/src/artifacts/editor/markdown-document.tsx +72 -0
- package/src/artifacts/editor/messages.ts +4 -0
- package/src/artifacts/editor/schema.ts +159 -0
- package/src/artifacts/editor/selection-toolbar.tsx +364 -0
- package/src/artifacts/editor/slash-menu.tsx +251 -0
- package/src/artifacts/editor/upload.ts +40 -0
- package/src/artifacts/file-source.ts +11 -0
- package/src/artifacts/frame-editor/bundle.ts +8 -0
- package/src/artifacts/frame-editor/commands.ts +565 -0
- package/src/artifacts/frame-editor/entry.ts +6 -0
- package/src/artifacts/frame-editor/frame.ts +847 -0
- package/src/artifacts/frame-editor/generated/editor.txt +149 -0
- package/src/artifacts/frame-editor/generated.d.ts +5 -0
- package/src/artifacts/frame-editor/keys.ts +323 -0
- package/src/artifacts/frame-editor/protocol.ts +151 -0
- package/src/artifacts/frame-editor/schema.ts +293 -0
- package/src/artifacts/frame-editor/style.ts +58 -0
- package/src/artifacts/frame.tsx +14 -5
- package/src/artifacts/live/boards.ts +46 -3
- package/src/artifacts/live/document.ts +89 -0
- package/src/artifacts/live/header.tsx +9 -14
- package/src/artifacts/live/presence.ts +5 -1
- package/src/artifacts/live/session.ts +4 -2
- package/src/artifacts/live/view.ts +14 -8
- package/src/artifacts/messages.ts +192 -2
- package/src/artifacts/pdf.ts +50 -0
- package/src/artifacts/references/references.tsx +46 -11
- package/src/artifacts/renderers/canvas/board-editor.tsx +44 -155
- package/src/artifacts/renderers/canvas/board.tsx +70 -8
- package/src/artifacts/renderers/canvas/canvas.tsx +66 -15
- package/src/artifacts/renderers/canvas/comment-pins.tsx +5 -0
- package/src/artifacts/renderers/canvas/comments-panel.tsx +58 -1
- package/src/artifacts/renderers/canvas/comments.ts +8 -4
- package/src/artifacts/renderers/canvas/controls.tsx +64 -30
- package/src/artifacts/renderers/canvas/focus.tsx +200 -56
- package/src/artifacts/renderers/canvas/gestures.ts +265 -0
- package/src/artifacts/renderers/canvas/page-resize.tsx +542 -0
- package/src/artifacts/renderers/canvas/page-size-controls.tsx +193 -0
- package/src/artifacts/renderers/canvas/page-size.ts +218 -0
- package/src/artifacts/renderers/canvas/page-zoom.ts +280 -0
- package/src/artifacts/renderers/canvas/shown-size.ts +105 -0
- package/src/artifacts/renderers/designed-document.tsx +277 -0
- package/src/artifacts/renderers/document-tree.ts +9 -0
- package/src/artifacts/renderers/document.tsx +13 -102
- package/src/artifacts/renderers/live-frame.ts +163 -0
- package/src/artifacts/renderers/page-editor.tsx +613 -0
- package/src/artifacts/renderers/page.tsx +21 -4
- package/src/artifacts/viewer.tsx +101 -41
- package/src/index.ts +8 -0
- package/src/pages/console/data/messages.ts +6 -0
- package/src/pages/console/data/projections.tsx +4 -0
- package/src/pages/console/data/shared.tsx +1 -0
- package/src/pages/console/ontology/lineage/trail.tsx +3 -0
- package/src/shell/search-command.tsx +2 -0
- package/dist/chunk-001c4gnk.js.map +0 -204
- package/dist/chunk-5crvhjp2.js.map +0 -28
- /package/dist/{chunk-fwb9mxwm.js.map → chunk-5sgac68y.js.map} +0 -0
- /package/dist/{chunk-kes4ygmz.js.map → chunk-69qgh20f.js.map} +0 -0
|
@@ -0,0 +1,367 @@
|
|
|
1
|
+
import { humanize } from "../bash/interpret"
|
|
2
|
+
import { type AgentMessages, en } from "../i18n/en"
|
|
3
|
+
import { memoryFile } from "../memory-paths"
|
|
4
|
+
import type { NormalizedTool } from "../parts"
|
|
5
|
+
|
|
6
|
+
/** What `glob` stores: the files whose path matched, sorted. */
|
|
7
|
+
export interface GlobOutput {
|
|
8
|
+
readonly files: readonly string[]
|
|
9
|
+
/** More files match than the ones listed. */
|
|
10
|
+
readonly truncated: boolean
|
|
11
|
+
/** The search stopped at its deadline. */
|
|
12
|
+
readonly incomplete: boolean
|
|
13
|
+
}
|
|
14
|
+
|
|
15
|
+
export interface GrepMatch {
|
|
16
|
+
readonly path: string
|
|
17
|
+
readonly line: number
|
|
18
|
+
readonly text: string
|
|
19
|
+
}
|
|
20
|
+
|
|
21
|
+
/** What `grep` stores: the matching lines, grouped by file in order. */
|
|
22
|
+
export interface GrepOutput {
|
|
23
|
+
readonly matches: readonly GrepMatch[]
|
|
24
|
+
/** How many files the matches are in. */
|
|
25
|
+
readonly files: number
|
|
26
|
+
/** Matching lines past the ones a file shows, by path. */
|
|
27
|
+
readonly more: Readonly<Record<string, number>>
|
|
28
|
+
/** Another file matches past the lines shown. */
|
|
29
|
+
readonly truncated: boolean
|
|
30
|
+
/** The search stopped at its deadline. */
|
|
31
|
+
readonly incomplete: boolean
|
|
32
|
+
}
|
|
33
|
+
|
|
34
|
+
/**
|
|
35
|
+
* Where a search looked, as the chat names it: the Agent's memory, its guides and its ontology
|
|
36
|
+
* read as themselves, as `read` names their files; anywhere else is files.
|
|
37
|
+
*/
|
|
38
|
+
export type SearchPlace =
|
|
39
|
+
| { readonly kind: "files" }
|
|
40
|
+
| { readonly kind: "memory"; readonly project: boolean }
|
|
41
|
+
| { readonly kind: "guide"; readonly name: string }
|
|
42
|
+
| { readonly kind: "ontology" }
|
|
43
|
+
|
|
44
|
+
export interface SearchDescription {
|
|
45
|
+
readonly place: SearchPlace
|
|
46
|
+
readonly title: string
|
|
47
|
+
readonly runningTitle: string
|
|
48
|
+
readonly failedTitle: string
|
|
49
|
+
/** What came of it, once it has a result: `8 matches in 3 files`. */
|
|
50
|
+
readonly detail?: string
|
|
51
|
+
/** The pattern as the call wrote it, or empty until it streams in. */
|
|
52
|
+
readonly pattern: string
|
|
53
|
+
/** The folder or file it looked in, as the call named it; absent for the working folder. */
|
|
54
|
+
readonly path?: string
|
|
55
|
+
/** The files `grep` was limited to. */
|
|
56
|
+
readonly include?: string
|
|
57
|
+
/** What the results leave out, in plain words. */
|
|
58
|
+
readonly notes: readonly string[]
|
|
59
|
+
}
|
|
60
|
+
|
|
61
|
+
export interface GlobDescription extends SearchDescription {
|
|
62
|
+
/** Relative to the folder searched, which the header names. */
|
|
63
|
+
readonly files: readonly string[]
|
|
64
|
+
}
|
|
65
|
+
|
|
66
|
+
/** The matches of one file, in the order `grep` found them. */
|
|
67
|
+
export interface GrepGroup {
|
|
68
|
+
/** Relative to the folder searched, which the header names. */
|
|
69
|
+
readonly path: string
|
|
70
|
+
readonly matches: readonly Omit<GrepMatch, "path">[]
|
|
71
|
+
/** Matching lines past the ones shown. */
|
|
72
|
+
readonly more: number
|
|
73
|
+
}
|
|
74
|
+
|
|
75
|
+
export interface GrepDescription extends SearchDescription {
|
|
76
|
+
readonly groups: readonly GrepGroup[]
|
|
77
|
+
/** The search as a regular expression, to mark where each line first matched. */
|
|
78
|
+
readonly highlight?: RegExp
|
|
79
|
+
}
|
|
80
|
+
|
|
81
|
+
/** One run of a line's text: what the search matched, or what surrounds it. */
|
|
82
|
+
export interface LineSegment {
|
|
83
|
+
readonly text: string
|
|
84
|
+
readonly match: boolean
|
|
85
|
+
}
|
|
86
|
+
|
|
87
|
+
export function coerceGlobOutput(value: unknown): GlobOutput | null {
|
|
88
|
+
if (
|
|
89
|
+
!isRecord(value) ||
|
|
90
|
+
!Array.isArray(value.files) ||
|
|
91
|
+
!value.files.every((file) => typeof file === "string") ||
|
|
92
|
+
typeof value.truncated !== "boolean"
|
|
93
|
+
) {
|
|
94
|
+
return null
|
|
95
|
+
}
|
|
96
|
+
return { files: value.files, truncated: value.truncated, incomplete: value.incomplete === true }
|
|
97
|
+
}
|
|
98
|
+
|
|
99
|
+
export function coerceGrepOutput(value: unknown): GrepOutput | null {
|
|
100
|
+
if (
|
|
101
|
+
!isRecord(value) ||
|
|
102
|
+
!Array.isArray(value.matches) ||
|
|
103
|
+
!value.matches.every(isGrepMatch) ||
|
|
104
|
+
typeof value.files !== "number" ||
|
|
105
|
+
typeof value.truncated !== "boolean"
|
|
106
|
+
) {
|
|
107
|
+
return null
|
|
108
|
+
}
|
|
109
|
+
|
|
110
|
+
const more = isRecord(value.more)
|
|
111
|
+
? Object.fromEntries(
|
|
112
|
+
Object.entries(value.more).filter(
|
|
113
|
+
(entry): entry is [string, number] => typeof entry[1] === "number"
|
|
114
|
+
)
|
|
115
|
+
)
|
|
116
|
+
: {}
|
|
117
|
+
|
|
118
|
+
return {
|
|
119
|
+
matches: value.matches,
|
|
120
|
+
files: value.files,
|
|
121
|
+
more,
|
|
122
|
+
truncated: value.truncated,
|
|
123
|
+
incomplete: value.incomplete === true,
|
|
124
|
+
}
|
|
125
|
+
}
|
|
126
|
+
|
|
127
|
+
/** A search for files by name: `Found 12 files`, or where it looked when that has a name. */
|
|
128
|
+
export function describeGlob(
|
|
129
|
+
tool: Pick<NormalizedTool, "input" | "output">,
|
|
130
|
+
messages: AgentMessages = en
|
|
131
|
+
): GlobDescription {
|
|
132
|
+
const m = messages.search
|
|
133
|
+
const call = searchCall(tool.input)
|
|
134
|
+
const output = coerceGlobOutput(tool.output)
|
|
135
|
+
const place = searchPlace(call.path)
|
|
136
|
+
const named = placeTitles(place, m)
|
|
137
|
+
|
|
138
|
+
const files = output?.files ?? []
|
|
139
|
+
const shown = output?.truncated ? m.moreFiles(files.length) : m.files(files.length)
|
|
140
|
+
|
|
141
|
+
const title = named
|
|
142
|
+
? named.title
|
|
143
|
+
: !output
|
|
144
|
+
? m.looked
|
|
145
|
+
: output.truncated
|
|
146
|
+
? m.foundMore(files.length)
|
|
147
|
+
: m.found(files.length)
|
|
148
|
+
|
|
149
|
+
return {
|
|
150
|
+
...call,
|
|
151
|
+
place,
|
|
152
|
+
title,
|
|
153
|
+
runningTitle: named?.running ?? m.looking,
|
|
154
|
+
failedTitle: named?.failed ?? m.lookFailed,
|
|
155
|
+
...(named && output ? { detail: shown } : {}),
|
|
156
|
+
notes: [
|
|
157
|
+
...(output?.truncated ? [m.truncatedFiles(files.length)] : []),
|
|
158
|
+
...(output?.incomplete ? [m.incomplete] : []),
|
|
159
|
+
],
|
|
160
|
+
files: files.map((file) => underSearched(file, call.path)),
|
|
161
|
+
}
|
|
162
|
+
}
|
|
163
|
+
|
|
164
|
+
/**
|
|
165
|
+
* A search for text: `Searched for “retries” · 8 matches in 3 files`. The pattern names the step
|
|
166
|
+
* only when it reads as words; a regular expression stays behind the disclosure.
|
|
167
|
+
*/
|
|
168
|
+
export function describeGrep(
|
|
169
|
+
tool: Pick<NormalizedTool, "input" | "output">,
|
|
170
|
+
messages: AgentMessages = en
|
|
171
|
+
): GrepDescription {
|
|
172
|
+
const m = messages.search
|
|
173
|
+
const call = searchCall(tool.input)
|
|
174
|
+
const literal = isRecord(tool.input) && tool.input.literal === true
|
|
175
|
+
const output = coerceGrepOutput(tool.output)
|
|
176
|
+
const place = searchPlace(call.path)
|
|
177
|
+
const named = placeTitles(place, m)
|
|
178
|
+
const term = plainTerm(call.pattern, literal)
|
|
179
|
+
|
|
180
|
+
const extra = Object.values(output?.more ?? {}).reduce((sum, count) => sum + count, 0)
|
|
181
|
+
const total = (output?.matches.length ?? 0) + extra
|
|
182
|
+
const found = !output
|
|
183
|
+
? undefined
|
|
184
|
+
: total === 0
|
|
185
|
+
? m.noMatches
|
|
186
|
+
: output.truncated
|
|
187
|
+
? m.moreMatches(total)
|
|
188
|
+
: m.matches(total, output.files)
|
|
189
|
+
|
|
190
|
+
const detail = named && term && found ? `${m.term(term)} · ${found}` : found
|
|
191
|
+
const highlight = searchRegex(call.pattern, literal)
|
|
192
|
+
|
|
193
|
+
return {
|
|
194
|
+
...call,
|
|
195
|
+
place,
|
|
196
|
+
title: named?.title ?? (term ? m.searchedFor(term) : m.searched),
|
|
197
|
+
runningTitle: named?.running ?? m.searching,
|
|
198
|
+
failedTitle: named?.failed ?? m.searchFailed(term),
|
|
199
|
+
...(detail ? { detail } : {}),
|
|
200
|
+
notes: [
|
|
201
|
+
...(output?.truncated ? [m.truncatedMatches(output.matches.length)] : []),
|
|
202
|
+
...(output?.incomplete ? [m.incomplete] : []),
|
|
203
|
+
],
|
|
204
|
+
groups: output ? grepGroups(output, call.path) : [],
|
|
205
|
+
...(highlight ? { highlight } : {}),
|
|
206
|
+
}
|
|
207
|
+
}
|
|
208
|
+
|
|
209
|
+
/**
|
|
210
|
+
* A line cut where the search first matched it, so the match can be marked. Only the first: it is
|
|
211
|
+
* the work the search did on the line and finished, while matching on through the rest of the line
|
|
212
|
+
* can backtrack without end on a pattern such as `(a|a)+b`, and again on every render.
|
|
213
|
+
*/
|
|
214
|
+
export function highlightLine(text: string, regex: RegExp | undefined): LineSegment[] {
|
|
215
|
+
const found = regex && text ? regex.exec(text) : null
|
|
216
|
+
|
|
217
|
+
// An empty match, as `^` or `x*` gives, marks nothing.
|
|
218
|
+
if (!found || found[0].length === 0) return [{ text, match: false }]
|
|
219
|
+
|
|
220
|
+
const start = found.index
|
|
221
|
+
const end = start + found[0].length
|
|
222
|
+
return [
|
|
223
|
+
...(start > 0 ? [{ text: text.slice(0, start), match: false }] : []),
|
|
224
|
+
{ text: text.slice(start, end), match: true },
|
|
225
|
+
...(end < text.length ? [{ text: text.slice(end), match: false }] : []),
|
|
226
|
+
]
|
|
227
|
+
}
|
|
228
|
+
|
|
229
|
+
/** A path's folder and its name, so the name can stand out. */
|
|
230
|
+
export function splitPath(path: string): { readonly folder: string; readonly name: string } {
|
|
231
|
+
const cut = path.lastIndexOf("/", path.length - 2)
|
|
232
|
+
return cut < 0
|
|
233
|
+
? { folder: "", name: path }
|
|
234
|
+
: { folder: path.slice(0, cut + 1), name: path.slice(cut + 1) }
|
|
235
|
+
}
|
|
236
|
+
|
|
237
|
+
function searchCall(input: unknown): Pick<SearchDescription, "pattern" | "path" | "include"> {
|
|
238
|
+
const record = isRecord(input) ? input : {}
|
|
239
|
+
const pattern = typeof record.pattern === "string" ? record.pattern : ""
|
|
240
|
+
const path = givenString(record.path)
|
|
241
|
+
const include = givenString(record.include)
|
|
242
|
+
return {
|
|
243
|
+
pattern,
|
|
244
|
+
...(path === undefined || path === "." || path === "./" ? {} : { path }),
|
|
245
|
+
...(include === undefined ? {} : { include }),
|
|
246
|
+
}
|
|
247
|
+
}
|
|
248
|
+
|
|
249
|
+
/** A string the call gave: models send `"null"` and `"undefined"` for nothing, as the tools read. */
|
|
250
|
+
function givenString(value: unknown): string | undefined {
|
|
251
|
+
if (typeof value !== "string") return undefined
|
|
252
|
+
const trimmed = value.trim()
|
|
253
|
+
return trimmed === "" || trimmed === "null" || trimmed === "undefined" ? undefined : trimmed
|
|
254
|
+
}
|
|
255
|
+
|
|
256
|
+
function searchPlace(path: string | undefined): SearchPlace {
|
|
257
|
+
if (!path) return { kind: "files" }
|
|
258
|
+
|
|
259
|
+
const memory = memoryFile(path)
|
|
260
|
+
if (memory) return { kind: "memory", project: memory.repo === "project" }
|
|
261
|
+
|
|
262
|
+
const skill = path.match(/(?:^|\/)\.sixb\/agent\/skills(?:\/([^/]+))?/)
|
|
263
|
+
if (skill)
|
|
264
|
+
return { kind: "guide", name: skill[1] ? humanize(skill[1].replace(/^sixb-/, "")) : "" }
|
|
265
|
+
|
|
266
|
+
if (/(?:^|\/)\.sixb\/agent\/ontology(?:\/|$)/.test(path)) return { kind: "ontology" }
|
|
267
|
+
return { kind: "files" }
|
|
268
|
+
}
|
|
269
|
+
|
|
270
|
+
function placeTitles(
|
|
271
|
+
place: SearchPlace,
|
|
272
|
+
m: AgentMessages["search"]
|
|
273
|
+
): { readonly title: string; readonly running: string; readonly failed: string } | null {
|
|
274
|
+
switch (place.kind) {
|
|
275
|
+
case "memory":
|
|
276
|
+
return {
|
|
277
|
+
title: m.memory.title(place.project),
|
|
278
|
+
running: m.memory.running(place.project),
|
|
279
|
+
failed: m.memory.failed(place.project),
|
|
280
|
+
}
|
|
281
|
+
case "guide":
|
|
282
|
+
return {
|
|
283
|
+
title: m.guide.title(place.name),
|
|
284
|
+
running: m.guide.running(place.name),
|
|
285
|
+
failed: m.guide.failed(place.name),
|
|
286
|
+
}
|
|
287
|
+
case "ontology":
|
|
288
|
+
return { title: m.ontology.title, running: m.ontology.running, failed: m.ontology.failed }
|
|
289
|
+
default:
|
|
290
|
+
return null
|
|
291
|
+
}
|
|
292
|
+
}
|
|
293
|
+
|
|
294
|
+
const TERM_MAX = 40
|
|
295
|
+
|
|
296
|
+
/**
|
|
297
|
+
* The pattern as words, when it reads as them: literal text, or a pattern with no regular
|
|
298
|
+
* expression syntax past escaped punctuation. A lone `.` stays, as people write it.
|
|
299
|
+
*/
|
|
300
|
+
function plainTerm(pattern: string, literal: boolean): string | undefined {
|
|
301
|
+
const unescaped = literal ? pattern : pattern.replace(/\\([^A-Za-z0-9])/g, "$1")
|
|
302
|
+
if (!literal && /[\\^$*+?()[\]{}|]/.test(pattern.replace(/\\[^A-Za-z0-9]/g, ""))) {
|
|
303
|
+
return undefined
|
|
304
|
+
}
|
|
305
|
+
|
|
306
|
+
const term = unescaped.replace(/\s+/g, " ").trim()
|
|
307
|
+
if (!term) return undefined
|
|
308
|
+
return term.length > TERM_MAX ? `${term.slice(0, TERM_MAX - 1).trimEnd()}…` : term
|
|
309
|
+
}
|
|
310
|
+
|
|
311
|
+
/** The regular expression `grep` ran, case included, global to find every match of a line. */
|
|
312
|
+
function searchRegex(pattern: string, literal: boolean): RegExp | undefined {
|
|
313
|
+
if (!pattern) return undefined
|
|
314
|
+
|
|
315
|
+
const source = literal ? pattern.replace(/[.*+?^${}()|[\]\\]/g, "\\$&") : pattern
|
|
316
|
+
const written = literal ? pattern : pattern.replace(/\\(?:[pP]\{[^}]*\}|.)/g, "")
|
|
317
|
+
// Not global: a line is matched once, as the search matched it.
|
|
318
|
+
const flags = /\p{Lu}/u.test(written) ? "" : "i"
|
|
319
|
+
|
|
320
|
+
for (const unicode of ["u", ""]) {
|
|
321
|
+
try {
|
|
322
|
+
return new RegExp(source, `${flags}${unicode}`)
|
|
323
|
+
} catch {}
|
|
324
|
+
}
|
|
325
|
+
return undefined
|
|
326
|
+
}
|
|
327
|
+
|
|
328
|
+
function grepGroups(output: GrepOutput, searched: string | undefined): GrepGroup[] {
|
|
329
|
+
const groups: { path: string; matches: Omit<GrepMatch, "path">[]; more: number }[] = []
|
|
330
|
+
for (const { path: found, line, text } of output.matches) {
|
|
331
|
+
const path = underSearched(found, searched)
|
|
332
|
+
const last = groups.at(-1)
|
|
333
|
+
if (last?.path === path) {
|
|
334
|
+
last.matches.push({ line, text })
|
|
335
|
+
} else {
|
|
336
|
+
groups.push({ path, matches: [{ line, text }], more: output.more[found] ?? 0 })
|
|
337
|
+
}
|
|
338
|
+
}
|
|
339
|
+
return groups
|
|
340
|
+
}
|
|
341
|
+
|
|
342
|
+
/**
|
|
343
|
+
* A path a search found, as it reads under the search's header: relative to the folder searched,
|
|
344
|
+
* which the header names once, so `.sixb/agent/ontology/` is not said before every file.
|
|
345
|
+
*/
|
|
346
|
+
function underSearched(path: string, searched: string | undefined): string {
|
|
347
|
+
const folder = searched?.replace(/^(?:\.\/)+/, "").replace(/\/+$/, "")
|
|
348
|
+
if (!folder) return path
|
|
349
|
+
|
|
350
|
+
// The search names its matches by their real path: `/var/…` is `/private/var/…` on a Mac.
|
|
351
|
+
const prefixes = folder.startsWith("/") ? [folder, `/private${folder}`] : [folder]
|
|
352
|
+
const prefix = prefixes.find((candidate) => path.startsWith(`${candidate}/`))
|
|
353
|
+
return prefix ? path.slice(prefix.length + 1) : path
|
|
354
|
+
}
|
|
355
|
+
|
|
356
|
+
function isGrepMatch(value: unknown): value is GrepMatch {
|
|
357
|
+
return (
|
|
358
|
+
isRecord(value) &&
|
|
359
|
+
typeof value.path === "string" &&
|
|
360
|
+
typeof value.line === "number" &&
|
|
361
|
+
typeof value.text === "string"
|
|
362
|
+
)
|
|
363
|
+
}
|
|
364
|
+
|
|
365
|
+
function isRecord(value: unknown): value is Record<string, unknown> {
|
|
366
|
+
return typeof value === "object" && value !== null && !Array.isArray(value)
|
|
367
|
+
}
|
|
@@ -0,0 +1,235 @@
|
|
|
1
|
+
import { Collapsible, CollapsibleContent, CollapsibleTrigger } from "@sixb/ui/components"
|
|
2
|
+
import {
|
|
3
|
+
Bookmark,
|
|
4
|
+
BookOpen,
|
|
5
|
+
Boxes,
|
|
6
|
+
ChevronRight,
|
|
7
|
+
FolderSearch,
|
|
8
|
+
type LucideIcon,
|
|
9
|
+
TextSearch,
|
|
10
|
+
} from "lucide-react"
|
|
11
|
+
import type { ReactNode } from "react"
|
|
12
|
+
import { ActivityStatusText } from "../components/activity-status"
|
|
13
|
+
import { useAgentMessages } from "../i18n"
|
|
14
|
+
import type { NormalizedTool } from "../parts"
|
|
15
|
+
import {
|
|
16
|
+
describeGlob,
|
|
17
|
+
describeGrep,
|
|
18
|
+
type GrepGroup,
|
|
19
|
+
highlightLine,
|
|
20
|
+
type SearchDescription,
|
|
21
|
+
type SearchPlace,
|
|
22
|
+
splitPath,
|
|
23
|
+
} from "./interpret"
|
|
24
|
+
|
|
25
|
+
/** Files the agent found by name: `Found 12 files`, opening to the list. */
|
|
26
|
+
export function GlobToolView({ tool }: { tool: NormalizedTool }) {
|
|
27
|
+
const messages = useAgentMessages()
|
|
28
|
+
const description = describeGlob(tool, messages)
|
|
29
|
+
return (
|
|
30
|
+
<SearchRow
|
|
31
|
+
tool={tool}
|
|
32
|
+
description={description}
|
|
33
|
+
icon={placeIcon(description.place, FolderSearch)}
|
|
34
|
+
>
|
|
35
|
+
{description.files.length > 0 ? (
|
|
36
|
+
<ResultBlock>
|
|
37
|
+
{description.files.map((path) => (
|
|
38
|
+
<div key={path} className="min-w-max px-2.5">
|
|
39
|
+
<PathText path={path} />
|
|
40
|
+
</div>
|
|
41
|
+
))}
|
|
42
|
+
</ResultBlock>
|
|
43
|
+
) : (
|
|
44
|
+
<p className="text-muted-foreground/60">{messages.search.noFiles}</p>
|
|
45
|
+
)}
|
|
46
|
+
</SearchRow>
|
|
47
|
+
)
|
|
48
|
+
}
|
|
49
|
+
|
|
50
|
+
/** Text the agent searched for: `Searched for “retries” · 8 matches in 3 files`, opening to them. */
|
|
51
|
+
export function GrepToolView({ tool }: { tool: NormalizedTool }) {
|
|
52
|
+
const messages = useAgentMessages()
|
|
53
|
+
const description = describeGrep(tool, messages)
|
|
54
|
+
return (
|
|
55
|
+
<SearchRow
|
|
56
|
+
tool={tool}
|
|
57
|
+
description={description}
|
|
58
|
+
icon={placeIcon(description.place, TextSearch)}
|
|
59
|
+
>
|
|
60
|
+
{description.groups.length > 0 ? (
|
|
61
|
+
<ResultBlock>
|
|
62
|
+
{description.groups.map((group) => (
|
|
63
|
+
<MatchGroup
|
|
64
|
+
key={group.path}
|
|
65
|
+
group={group}
|
|
66
|
+
highlight={description.highlight}
|
|
67
|
+
more={messages.search.moreInFile(group.more)}
|
|
68
|
+
/>
|
|
69
|
+
))}
|
|
70
|
+
</ResultBlock>
|
|
71
|
+
) : (
|
|
72
|
+
<p className="text-muted-foreground/60">{messages.search.noLines}</p>
|
|
73
|
+
)}
|
|
74
|
+
</SearchRow>
|
|
75
|
+
)
|
|
76
|
+
}
|
|
77
|
+
|
|
78
|
+
function placeIcon(place: SearchPlace, files: LucideIcon): LucideIcon {
|
|
79
|
+
switch (place.kind) {
|
|
80
|
+
case "memory":
|
|
81
|
+
return Bookmark
|
|
82
|
+
case "guide":
|
|
83
|
+
return BookOpen
|
|
84
|
+
case "ontology":
|
|
85
|
+
return Boxes
|
|
86
|
+
default:
|
|
87
|
+
return files
|
|
88
|
+
}
|
|
89
|
+
}
|
|
90
|
+
|
|
91
|
+
/**
|
|
92
|
+
* The step as one quiet line, as `read` shows; open, what the search was, then what it found, and
|
|
93
|
+
* what that leaves out.
|
|
94
|
+
*/
|
|
95
|
+
function SearchRow({
|
|
96
|
+
tool,
|
|
97
|
+
description,
|
|
98
|
+
icon: Icon,
|
|
99
|
+
children,
|
|
100
|
+
}: {
|
|
101
|
+
tool: NormalizedTool
|
|
102
|
+
description: SearchDescription
|
|
103
|
+
icon: LucideIcon
|
|
104
|
+
children: ReactNode
|
|
105
|
+
}) {
|
|
106
|
+
const messages = useAgentMessages()
|
|
107
|
+
const running = tool.state === "input-streaming" || tool.state === "input-available"
|
|
108
|
+
const error = tool.state === "output-error"
|
|
109
|
+
|
|
110
|
+
if (running) {
|
|
111
|
+
return (
|
|
112
|
+
<div className="flex w-fit max-w-full items-center gap-1.5 text-[13px] leading-normal text-muted-foreground">
|
|
113
|
+
<Icon className="size-3.5 shrink-0" />
|
|
114
|
+
<ActivityStatusText label={description.runningTitle} className="font-medium shimmer" />
|
|
115
|
+
</div>
|
|
116
|
+
)
|
|
117
|
+
}
|
|
118
|
+
|
|
119
|
+
const label = error ? description.failedTitle : description.title
|
|
120
|
+
const query = [
|
|
121
|
+
description.pattern,
|
|
122
|
+
description.include,
|
|
123
|
+
description.path ? messages.search.in(description.path) : undefined,
|
|
124
|
+
].filter(Boolean)
|
|
125
|
+
|
|
126
|
+
return (
|
|
127
|
+
<Collapsible>
|
|
128
|
+
<CollapsibleTrigger className="group flex w-fit max-w-full items-center gap-1.5 text-[13px] leading-normal text-muted-foreground transition-colors hover:text-foreground">
|
|
129
|
+
<Icon className="size-3.5 shrink-0" />
|
|
130
|
+
{/* On a narrow screen the detail gives way first, so the step keeps its name: the name
|
|
131
|
+
shrinks only past the room the icon and the chevron leave. */}
|
|
132
|
+
<span className="max-w-[calc(100%-2.5rem)] shrink-0 truncate font-medium">{label}</span>
|
|
133
|
+
{description.detail && !error ? (
|
|
134
|
+
<span className="min-w-0 shrink truncate text-muted-foreground/60">
|
|
135
|
+
{description.detail}
|
|
136
|
+
</span>
|
|
137
|
+
) : null}
|
|
138
|
+
<ChevronRight className="size-3.5 shrink-0 opacity-0 transition-all group-hover:opacity-100 group-focus-visible:opacity-100 group-data-[state=open]:rotate-90 group-data-[state=open]:opacity-100" />
|
|
139
|
+
</CollapsibleTrigger>
|
|
140
|
+
<CollapsibleContent>
|
|
141
|
+
<div className="mt-3 min-w-0 space-y-2 text-xs">
|
|
142
|
+
{query.length > 0 ? (
|
|
143
|
+
<p className="truncate font-mono text-[10px] text-muted-foreground/60">
|
|
144
|
+
{query.join(" · ")}
|
|
145
|
+
</p>
|
|
146
|
+
) : null}
|
|
147
|
+
{error ? (
|
|
148
|
+
<pre className="scrollbar-thin max-h-60 overflow-auto rounded bg-muted/50 p-2 text-[11px] leading-relaxed whitespace-pre-wrap text-foreground">
|
|
149
|
+
{tool.errorText?.trim() || messages.search.error}
|
|
150
|
+
</pre>
|
|
151
|
+
) : (
|
|
152
|
+
children
|
|
153
|
+
)}
|
|
154
|
+
{error
|
|
155
|
+
? null
|
|
156
|
+
: description.notes.map((note) => (
|
|
157
|
+
<p key={note} className="text-muted-foreground/60">
|
|
158
|
+
{note}
|
|
159
|
+
</p>
|
|
160
|
+
))}
|
|
161
|
+
</div>
|
|
162
|
+
</CollapsibleContent>
|
|
163
|
+
</Collapsible>
|
|
164
|
+
)
|
|
165
|
+
}
|
|
166
|
+
|
|
167
|
+
function ResultBlock({ children }: { children: ReactNode }) {
|
|
168
|
+
return (
|
|
169
|
+
<div className="scrollbar-thin max-h-60 overflow-auto rounded bg-muted/50 py-1.5 font-mono text-[11px] leading-relaxed">
|
|
170
|
+
{children}
|
|
171
|
+
</div>
|
|
172
|
+
)
|
|
173
|
+
}
|
|
174
|
+
|
|
175
|
+
/** A path with its folder quiet, so the file's name is what the eye finds. */
|
|
176
|
+
function PathText({ path }: { path: string }) {
|
|
177
|
+
const { folder, name } = splitPath(path)
|
|
178
|
+
return (
|
|
179
|
+
<>
|
|
180
|
+
{folder ? <span className="text-muted-foreground/70">{folder}</span> : null}
|
|
181
|
+
<span className="text-foreground">{name}</span>
|
|
182
|
+
</>
|
|
183
|
+
)
|
|
184
|
+
}
|
|
185
|
+
|
|
186
|
+
function MatchGroup({
|
|
187
|
+
group,
|
|
188
|
+
highlight,
|
|
189
|
+
more,
|
|
190
|
+
}: {
|
|
191
|
+
group: GrepGroup
|
|
192
|
+
highlight: RegExp | undefined
|
|
193
|
+
more: string
|
|
194
|
+
}) {
|
|
195
|
+
// Every number of the file takes the width of the longest, so the lines start in one column.
|
|
196
|
+
const width = `${String(Math.max(...group.matches.map((match) => match.line))).length}ch`
|
|
197
|
+
return (
|
|
198
|
+
<div className="pb-1.5 last:pb-0">
|
|
199
|
+
<div className="min-w-max px-2.5 font-medium">
|
|
200
|
+
<PathText path={group.path} />
|
|
201
|
+
</div>
|
|
202
|
+
{group.matches.map((match) => (
|
|
203
|
+
<div key={match.line} className="flex min-w-max gap-3 px-2.5">
|
|
204
|
+
<span
|
|
205
|
+
className="shrink-0 select-none text-right text-muted-foreground/50 tabular-nums"
|
|
206
|
+
style={{ width }}
|
|
207
|
+
>
|
|
208
|
+
{match.line}
|
|
209
|
+
</span>
|
|
210
|
+
<span className="whitespace-pre text-foreground/80">
|
|
211
|
+
{highlightLine(match.text, highlight).map((segment, index) =>
|
|
212
|
+
segment.match ? (
|
|
213
|
+
// Runs of one line never reorder: the index is their identity.
|
|
214
|
+
<mark
|
|
215
|
+
key={index}
|
|
216
|
+
className="rounded-[3px] bg-amber-400/30 text-foreground dark:bg-amber-300/25"
|
|
217
|
+
>
|
|
218
|
+
{segment.text}
|
|
219
|
+
</mark>
|
|
220
|
+
) : (
|
|
221
|
+
<span key={index}>{segment.text}</span>
|
|
222
|
+
)
|
|
223
|
+
)}
|
|
224
|
+
</span>
|
|
225
|
+
</div>
|
|
226
|
+
))}
|
|
227
|
+
{group.more > 0 ? (
|
|
228
|
+
<div className="min-w-max px-2.5 text-muted-foreground/60 italic">
|
|
229
|
+
<span className="inline-block select-none" style={{ width, marginRight: "0.75rem" }} />
|
|
230
|
+
{more}
|
|
231
|
+
</div>
|
|
232
|
+
) : null}
|
|
233
|
+
</div>
|
|
234
|
+
)
|
|
235
|
+
}
|