@carlesandres/house 0.4.7 → 0.4.9

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.
@@ -1,12 +1,14 @@
1
1
  /**
2
2
  * CommandPalette — modal overlay for searching and running commands.
3
3
  *
4
- * Render-only: state lives in Browser.tsx alongside helpVisible / filterOpen
4
+ * Render-only: state lives in Browser.tsx alongside filterOpen
5
5
  * (#70 design log §state location). Key handling sits in Browser.tsx's
6
6
  * `useKeyboard` palette-branch, mirroring the filterOpen pattern.
7
7
  *
8
- * V1 ships a flat list in `browserBindings` order no category headers,
9
- * no mouse, no recency. See #91/#93/#94/#95/#96 for the follow-ups.
8
+ * Commands are grouped by semantic category while preserving command order
9
+ * inside each group. Browser.tsx owns the query and selected command index;
10
+ * this component turns those commands into render rows and keeps the selected
11
+ * row visible when the list is taller than the modal body.
10
12
  */
11
13
 
12
14
  import { RGBA } from "@opentui/core"
@@ -29,6 +31,52 @@ export interface CommandPaletteProps {
29
31
  }
30
32
 
31
33
  const FOOTER_HINT = "↑↓ select enter run esc close"
34
+ const CATEGORY_ORDER = ["Navigation", "View", "File", "Appearance", "App"] as const
35
+
36
+ type PaletteRow =
37
+ | { readonly kind: "spacer"; readonly key: string }
38
+ | { readonly kind: "header"; readonly key: string; readonly text: string }
39
+ | {
40
+ readonly kind: "command"
41
+ readonly key: string
42
+ readonly command: AppCommand
43
+ readonly commandIndex: number
44
+ }
45
+
46
+ export const orderCommandsForPalette = (commands: readonly AppCommand[]): readonly AppCommand[] => {
47
+ const grouped = new Map<string, AppCommand[]>()
48
+ for (const command of commands) {
49
+ const category = command.category ?? "Other"
50
+ const list = grouped.get(category)
51
+ if (list) list.push(command)
52
+ else grouped.set(category, [command])
53
+ }
54
+
55
+ const orderedCategories = [
56
+ ...CATEGORY_ORDER.filter((category) => grouped.has(category)),
57
+ ...Array.from(grouped.keys()).filter((category) => !CATEGORY_ORDER.includes(category as never)),
58
+ ]
59
+
60
+ return orderedCategories.flatMap((category) => grouped.get(category) ?? [])
61
+ }
62
+
63
+ const buildRows = (commands: readonly AppCommand[]): readonly PaletteRow[] => {
64
+ const orderedCommands = orderCommandsForPalette(commands)
65
+ const rows: PaletteRow[] = []
66
+ let previousCategory: string | null = null
67
+ let commandIndex = 0
68
+ for (const command of orderedCommands) {
69
+ const category = command.category ?? "Other"
70
+ if (category !== previousCategory) {
71
+ if (previousCategory !== null) rows.push({ kind: "spacer", key: `spacer-${category}` })
72
+ rows.push({ kind: "header", key: `header-${category}`, text: category })
73
+ previousCategory = category
74
+ }
75
+ rows.push({ kind: "command", key: command.id, command, commandIndex })
76
+ commandIndex += 1
77
+ }
78
+ return rows
79
+ }
32
80
 
33
81
  export const CommandPalette = ({
34
82
  commands,
@@ -38,11 +86,12 @@ export const CommandPalette = ({
38
86
  viewportHeight,
39
87
  }: CommandPaletteProps) => {
40
88
  const overlayWidth = Math.min(viewportWidth - 4, 64)
89
+ const rows = buildRows(commands)
41
90
  // Reserve: 2 for border (top+bottom), 1 query row, 1 spacer below query,
42
91
  // 1 spacer above footer, 1 footer row. Body gets the rest.
43
92
  const chrome = 2 + 1 + 1 + 1 + 1
44
93
  const maxBody = Math.max(1, viewportHeight - 4 - chrome)
45
- const desiredBody = Math.max(1, commands.length || 1)
94
+ const desiredBody = Math.max(1, rows.length || 1)
46
95
  const bodyHeight = Math.min(desiredBody, maxBody)
47
96
  const overlayHeight = chrome + bodyHeight
48
97
  const left = Math.max(0, Math.floor((viewportWidth - overlayWidth) / 2))
@@ -51,17 +100,19 @@ export const CommandPalette = ({
51
100
  // Inner content width: overlay minus 1-cell border + 1-cell padding on each side.
52
101
  const rowWidth = Math.max(4, overlayWidth - 4)
53
102
 
54
- // Window the visible slice around the selection. With 9 commands in v1
55
- // this is usually a no-op (list fits), but the math is in place for the
56
- // inevitable backlog growth.
103
+ // Window the visible slice around the selected command row. Headers and
104
+ // spacers are render-only rows, so selection still tracks command indexes.
57
105
  const scrollTop = (() => {
58
- if (commands.length <= bodyHeight) return 0
59
- const maxScroll = commands.length - bodyHeight
106
+ if (rows.length <= bodyHeight) return 0
107
+ const maxScroll = rows.length - bodyHeight
60
108
  let s = 0
61
- if (selectedIndex >= bodyHeight) s = selectedIndex - bodyHeight + 1
109
+ const selectedRowIndex = rows.findIndex(
110
+ (row) => row.kind === "command" && row.commandIndex === selectedIndex,
111
+ )
112
+ if (selectedRowIndex >= bodyHeight) s = selectedRowIndex - bodyHeight + 1
62
113
  return Math.max(0, Math.min(s, maxScroll))
63
114
  })()
64
- const visible = commands.slice(scrollTop, scrollTop + bodyHeight)
115
+ const visible = rows.slice(scrollTop, scrollTop + bodyHeight)
65
116
 
66
117
  // Shortcut column width — long enough for `shift+t`-style chords but
67
118
  // trimmed to prevent the title from being squeezed below ~16 cells.
@@ -110,9 +161,22 @@ export const CommandPalette = ({
110
161
  {commands.length === 0 ? (
111
162
  <text wrapMode="none" content=" (no matches)" style={{ fg: colors.textMuted }} />
112
163
  ) : (
113
- visible.map((cmd, i) => {
114
- const realIdx = scrollTop + i
115
- const isSelected = realIdx === selectedIndex
164
+ visible.map((row) => {
165
+ if (row.kind === "spacer") {
166
+ return <text key={row.key} content=" " />
167
+ }
168
+ if (row.kind === "header") {
169
+ return (
170
+ <text
171
+ key={row.key}
172
+ wrapMode="none"
173
+ content={fit(row.text, rowWidth)}
174
+ style={{ fg: colors.textMuted, attributes: 1 }}
175
+ />
176
+ )
177
+ }
178
+ const cmd = row.command
179
+ const isSelected = row.commandIndex === selectedIndex
116
180
  const selector = isSelected ? "▸ " : " "
117
181
  const titleText = fit(cmd.title, titleWidth)
118
182
  const shortcutText = cmd.shortcut
package/src/Footer.tsx CHANGED
@@ -15,12 +15,11 @@
15
15
  * sidebar (see Browser.tsx). The pattern mirrors ghui's PR list, where the
16
16
  * filter is part of the list it filters.
17
17
  *
18
- * Width math assumes hint labels are ASCII plus a small set of single-cell
19
- * BMP glyphs (see `displayKey`). `fitHints` and notice clipping use string
20
- * length as a proxy for cell count; introducing a CJK or emoji label would
21
- * require a real cell-width counter (e.g. East Asian Width).
18
+ * Width math uses terminal-style string width instead of raw string length so
19
+ * ambiguous glyphs such as `↵` don't steal spacing from the label beside them.
22
20
  */
23
21
 
22
+ import stringWidth from "string-width"
24
23
  import type React from "react"
25
24
  import type { KeyBinding } from "./keymap/keymap.ts"
26
25
  import { displayKey } from "./keymap/displayKey.ts"
@@ -40,30 +39,26 @@ export interface FooterProps<C> {
40
39
  * no TTL, cleared by the caller when the underlying activity finishes.
41
40
  * Loses to `notice` when both are set so transient toasts still surface. */
42
41
  readonly discoveryStatus?: string | null
43
- /** When a filter is applied but the input is closed, surface a chip in the
44
- * hint row so the user remembers `[`/`]` walks the filtered set. Pass null
45
- * while the filter input is open (the sidebar already shows the query) or
46
- * when no filter is applied. */
47
- readonly filterQuery?: string | null
48
42
  /** Test seam: override spinner tick speed so tests don't sleep on the full
49
43
  * production interval. Ignored when discoveryStatus is null. */
50
44
  readonly discoverySpinnerIntervalMs?: number
51
45
  readonly discoverySpinnerInitialFrameIndex?: number
52
46
  /** Test seam: deterministic footer spinner driver. */
53
47
  readonly discoverySpinnerRegisterTick?: ((tick: () => void) => void) | null
48
+ /** Optional toggle callback for the discovery-warning popover. */
49
+ readonly onDiscoveryWarningToggle?: () => void
54
50
  }
55
51
 
52
+ const normalizeStatusLine = (status: string): string => status.replace(/\s+/g, " ").trim()
53
+
56
54
  const HINT_SEPARATOR = " "
57
55
 
58
- /** Hint row entries. `key === null` is a standalone chip (e.g. the filter
59
- * chip) and renders as muted text without the key/label split. */
60
56
  interface Hint {
61
- readonly key: string | null
57
+ readonly key: string
62
58
  readonly label: string
63
59
  }
64
60
 
65
- const hintWidth = (h: Hint): number =>
66
- h.key === null ? h.label.length : h.key.length + 1 + h.label.length // key + " " + label
61
+ const hintWidth = (h: Hint): number => stringWidth(h.key) + 1 + stringWidth(h.label) // key + " " + label
67
62
 
68
63
  const formatHint = <C,>(b: KeyBinding<C>): Hint | null => {
69
64
  if (!b.hint) return null
@@ -73,8 +68,8 @@ const formatHint = <C,>(b: KeyBinding<C>): Hint | null => {
73
68
  }
74
69
 
75
70
  /** Drop hints from the end until they fit within `width`. If not even the
76
- * first hint fits, fall back to the bare key (or label chip) truncated to
77
- * width, so the row is never silently blank on tight viewports. */
71
+ * first hint fits, fall back to the bare key truncated to width, so the row
72
+ * is never silently blank on tight viewports. */
78
73
  const fitHints = (hints: readonly Hint[], width: number): Hint[] => {
79
74
  if (width <= 0 || hints.length === 0) return []
80
75
  const acc: Hint[] = []
@@ -87,22 +82,24 @@ const fitHints = (hints: readonly Hint[], width: number): Hint[] => {
87
82
  }
88
83
  if (acc.length > 0) return acc
89
84
  const first = hints[0]!
90
- if (first.key === null) return [{ key: null, label: first.label.slice(0, width) }]
91
85
  return [{ key: first.key.slice(0, width), label: "" }]
92
86
  }
93
87
 
94
88
  const STATUS_SEPARATOR = " · "
95
89
 
90
+ const isPartialDiscoveryWarning = (status: string | null): boolean =>
91
+ status?.startsWith("scan incomplete:") ?? false
92
+
96
93
  export const Footer = <C,>({
97
94
  bindings,
98
95
  ctx,
99
96
  width,
100
97
  notice,
101
98
  discoveryStatus,
102
- filterQuery,
103
99
  discoverySpinnerIntervalMs,
104
100
  discoverySpinnerInitialFrameIndex,
105
101
  discoverySpinnerRegisterTick,
102
+ onDiscoveryWarningToggle,
106
103
  }: FooterProps<C>) => {
107
104
  const usableWidth = Math.max(0, width - 2) // 1-cell horizontal padding each side
108
105
 
@@ -117,13 +114,6 @@ export const Footer = <C,>({
117
114
  } as const
118
115
 
119
116
  const hints: Hint[] = []
120
- // The filter chip prepends to the hint row when a filter is applied and the
121
- // input is closed. Bracketed to avoid looking like a `key:hint` binding —
122
- // "filter" is not a key. Surfaces the otherwise-invisible invariant that
123
- // `[`/`]` walks the filtered set. See DESIGN.md §7.1 Q1.
124
- if (filterQuery && filterQuery.length > 0) {
125
- hints.push({ key: null, label: `[filter: ${filterQuery}]` })
126
- }
127
117
  for (const b of bindings) {
128
118
  // Hint visibility prefers `hintWhen` (binding-specific) over `when`
129
119
  // (dispatch gate). Falling back to `when` keeps the original
@@ -137,14 +127,17 @@ export const Footer = <C,>({
137
127
  // Discovery status sits left of the hints, separated by " · ". On tight
138
128
  // viewports it claims its budget first; hints fit into the remainder so
139
129
  // the indicator stays visible while less-essential hints drop off.
140
- const status = discoveryStatus && discoveryStatus.length > 0 ? discoveryStatus : null
141
- const statusBudget = status ? Math.min(status.length + STATUS_SEPARATOR.length, usableWidth) : 0
130
+ const status =
131
+ discoveryStatus && discoveryStatus.length > 0 ? normalizeStatusLine(discoveryStatus) : null
132
+ const isPartialWarning = isPartialDiscoveryWarning(status)
133
+ const statusBudget = status
134
+ ? Math.min((isPartialWarning ? 1 : status.length) + STATUS_SEPARATOR.length, usableWidth)
135
+ : 0
142
136
  const hintsWidth = Math.max(0, usableWidth - statusBudget)
143
137
  const visibleHints = fitHints(hints, hintsWidth)
144
138
  const statusContent = status
145
139
  ? status.slice(0, Math.max(0, statusBudget - STATUS_SEPARATOR.length))
146
140
  : ""
147
-
148
141
  const noticeContent = notice
149
142
  ? notice.length > usableWidth
150
143
  ? notice.slice(0, usableWidth)
@@ -167,12 +160,6 @@ export const Footer = <C,>({
167
160
  />,
168
161
  ]
169
162
  : []
170
- if (h.key === null) {
171
- return [
172
- ...sep,
173
- <text key={`l${i}`} content={h.label} wrapMode="none" style={{ fg: colors.secondary }} />,
174
- ]
175
- }
176
163
  return [
177
164
  ...sep,
178
165
  <text key={`k${i}`} content={h.key} wrapMode="none" style={{ fg: colors.text }} />,
@@ -195,6 +182,20 @@ export const Footer = <C,>({
195
182
  )
196
183
  }
197
184
 
185
+ const warningTrigger = isPartialWarning ? (
186
+ <box
187
+ {...(onDiscoveryWarningToggle === undefined ? {} : { onMouseUp: onDiscoveryWarningToggle })}
188
+ style={{
189
+ width: 1,
190
+ height: 1,
191
+ flexDirection: "row",
192
+ backgroundColor: colors.backgroundElement,
193
+ }}
194
+ >
195
+ <text content="!" wrapMode="none" style={{ fg: colors.warning, attributes: 1 }} />
196
+ </box>
197
+ ) : null
198
+
198
199
  if (status !== null) {
199
200
  const spinnerProps = {
200
201
  fg: colors.secondary,
@@ -211,9 +212,15 @@ export const Footer = <C,>({
211
212
 
212
213
  return (
213
214
  <box style={rowStyle}>
214
- <Spinner {...spinnerProps} />
215
- <text content=" " wrapMode="none" style={{ fg: colors.textMuted }} />
216
- <text content={statusContent} wrapMode="none" style={{ fg: colors.secondary }} />
215
+ {isPartialWarning ? null : <Spinner {...spinnerProps} />}
216
+ {isPartialWarning ? null : (
217
+ <text content=" " wrapMode="none" style={{ fg: colors.textMuted }} />
218
+ )}
219
+ {isPartialWarning ? (
220
+ warningTrigger
221
+ ) : (
222
+ <text content={statusContent} wrapMode="none" style={{ fg: colors.secondary }} />
223
+ )}
217
224
  <text content={STATUS_SEPARATOR} wrapMode="none" style={{ fg: colors.textMuted }} />
218
225
  {renderHints()}
219
226
  </box>
package/src/Header.tsx CHANGED
@@ -61,7 +61,10 @@ export const Header = ({ width, currentFile, version = pkg.version }: HeaderProp
61
61
  backgroundColor: colors.backgroundPanel,
62
62
  }}
63
63
  >
64
- <text content={left} wrapMode="none" style={{ fg: colors.text }} />
64
+ <text wrapMode="none">
65
+ <span style={{ fg: colors.text }}>{brand}</span>
66
+ {showFile && <span style={{ fg: colors.textMuted }}>{`${FILE_SEPARATOR}${file}`}</span>}
67
+ </text>
65
68
  {showRight && <text content={right} wrapMode="none" style={{ fg: colors.text }} />}
66
69
  </box>
67
70
  )
@@ -0,0 +1,189 @@
1
+ import { useTerminalDimensions } from "@opentui/react"
2
+ import { useMemo, useState } from "react"
3
+ import { colors } from "./theme/colors.ts"
4
+
5
+ export type StatusPopoverVariant = "info" | "warning" | "error" | "success"
6
+
7
+ export interface StatusPopoverProps {
8
+ readonly icon: string
9
+ readonly content: string
10
+ readonly variant?: StatusPopoverVariant
11
+ readonly open?: boolean
12
+ readonly defaultOpen?: boolean
13
+ readonly onOpenChange?: (open: boolean) => void
14
+ readonly showPanel?: boolean
15
+ readonly minWidth?: number
16
+ readonly maxWidth?: number
17
+ readonly maxHeight?: number
18
+ readonly zIndex?: number
19
+ }
20
+
21
+ export interface StatusPopoverPanelProps {
22
+ readonly content: string
23
+ readonly variant?: StatusPopoverVariant
24
+ readonly minWidth?: number
25
+ readonly maxWidth?: number
26
+ readonly maxHeight?: number
27
+ readonly zIndex?: number
28
+ }
29
+
30
+ const clamp = (n: number, min: number, max: number) => Math.max(min, Math.min(max, n))
31
+
32
+ const variantFg = (variant: StatusPopoverVariant): string => {
33
+ switch (variant) {
34
+ case "info":
35
+ return colors.info
36
+ case "warning":
37
+ return colors.warning
38
+ case "error":
39
+ return colors.error
40
+ case "success":
41
+ return colors.success
42
+ }
43
+ }
44
+
45
+ const measureLine = (line: string): number => line.length
46
+
47
+ const wrapLine = (line: string, width: number): string[] => {
48
+ if (width <= 0) return [line]
49
+ if (line.length <= width) return [line]
50
+ const out: string[] = []
51
+ let i = 0
52
+ while (i < line.length) {
53
+ out.push(line.slice(i, i + width))
54
+ i += width
55
+ }
56
+ return out
57
+ }
58
+
59
+ export const StatusPopover = ({
60
+ icon,
61
+ content,
62
+ variant = "warning",
63
+ open,
64
+ defaultOpen = false,
65
+ onOpenChange,
66
+ showPanel = true,
67
+ minWidth = 14,
68
+ maxWidth = 40,
69
+ maxHeight = 12,
70
+ zIndex = 30,
71
+ }: StatusPopoverProps) => {
72
+ const { width: viewportWidth, height: viewportHeight } = useTerminalDimensions()
73
+ const [uncontrolledOpen, setUncontrolledOpen] = useState(defaultOpen)
74
+ const isOpen = open ?? uncontrolledOpen
75
+ const setOpen = (next: boolean) => {
76
+ if (open === undefined) setUncontrolledOpen(next)
77
+ onOpenChange?.(next)
78
+ }
79
+
80
+ const lines = useMemo(() => content.split(/\r?\n/), [content])
81
+ const textWidth = useMemo(() => {
82
+ const widest = Math.max(1, ...lines.map(measureLine))
83
+ return clamp(widest, minWidth, Math.min(maxWidth, Math.max(1, viewportWidth - 4)))
84
+ }, [content, lines, maxWidth, minWidth, viewportWidth])
85
+
86
+ const wrapped = useMemo(
87
+ () => lines.flatMap((line) => wrapLine(line, textWidth)),
88
+ [lines, textWidth],
89
+ )
90
+ const bodyHeight = Math.min(maxHeight, Math.max(1, wrapped.length))
91
+ const popoverWidth = Math.min(textWidth + 2, Math.max(1, viewportWidth - 2))
92
+ const popoverHeight = Math.min(bodyHeight + 2, Math.max(3, viewportHeight - 2))
93
+
94
+ const left = 1
95
+ const top = Math.max(0, viewportHeight - popoverHeight - 2)
96
+
97
+ const linesToRender = wrapped.slice(0, Math.max(0, popoverHeight - 2))
98
+ while (linesToRender.length < popoverHeight - 2) linesToRender.push("")
99
+ const triggerFg = variantFg(variant)
100
+ const borderColor = variantFg(variant)
101
+
102
+ return (
103
+ <>
104
+ <box
105
+ onMouseUp={() => setOpen(!isOpen)}
106
+ style={{
107
+ width: 3,
108
+ height: 1,
109
+ flexDirection: "row",
110
+ backgroundColor: colors.backgroundElement,
111
+ }}
112
+ >
113
+ <text content={` ${icon} `} wrapMode="none" style={{ fg: triggerFg, attributes: 1 }} />
114
+ </box>
115
+ {showPanel && isOpen && (
116
+ <box
117
+ position="absolute"
118
+ left={left}
119
+ top={top}
120
+ width={popoverWidth}
121
+ height={popoverHeight}
122
+ zIndex={zIndex}
123
+ style={{
124
+ border: true,
125
+ borderColor,
126
+ backgroundColor: colors.backgroundPanel,
127
+ flexDirection: "column",
128
+ }}
129
+ >
130
+ <text content="" />
131
+ {linesToRender.map((line, i) => (
132
+ <text key={i} content={line} wrapMode="none" style={{ fg: colors.text }} />
133
+ ))}
134
+ <text content="" />
135
+ </box>
136
+ )}
137
+ </>
138
+ )
139
+ }
140
+
141
+ export const StatusPopoverPanel = ({
142
+ content,
143
+ variant = "warning",
144
+ minWidth = 14,
145
+ maxWidth = 40,
146
+ maxHeight = 12,
147
+ zIndex = 30,
148
+ }: StatusPopoverPanelProps) => {
149
+ const { width: viewportWidth, height: viewportHeight } = useTerminalDimensions()
150
+ const lines = useMemo(() => content.split(/\r?\n/), [content])
151
+ const textWidth = useMemo(() => {
152
+ const widest = Math.max(1, ...lines.map(measureLine))
153
+ return clamp(widest, minWidth, Math.min(maxWidth, Math.max(1, viewportWidth - 4)))
154
+ }, [lines, maxWidth, minWidth, viewportWidth])
155
+ const wrapped = useMemo(
156
+ () => lines.flatMap((line) => wrapLine(line, textWidth)),
157
+ [lines, textWidth],
158
+ )
159
+ const bodyHeight = Math.min(maxHeight, Math.max(1, wrapped.length))
160
+ const popoverWidth = Math.min(textWidth + 2, Math.max(1, viewportWidth - 2))
161
+ const popoverHeight = Math.min(bodyHeight + 2, Math.max(3, viewportHeight - 2))
162
+ const linesToRender = wrapped.slice(0, Math.max(0, popoverHeight - 2))
163
+ while (linesToRender.length < popoverHeight - 2) linesToRender.push("")
164
+
165
+ const borderColor = variantFg(variant)
166
+
167
+ return (
168
+ <box
169
+ position="absolute"
170
+ left={1}
171
+ top={Math.max(0, viewportHeight - popoverHeight - 2)}
172
+ width={popoverWidth}
173
+ height={popoverHeight}
174
+ zIndex={zIndex}
175
+ style={{
176
+ border: true,
177
+ borderColor,
178
+ backgroundColor: colors.backgroundPanel,
179
+ flexDirection: "column",
180
+ }}
181
+ >
182
+ <text content="" />
183
+ {linesToRender.map((line, i) => (
184
+ <text key={i} content={line} wrapMode="none" style={{ fg: colors.text }} />
185
+ ))}
186
+ <text content="" />
187
+ </box>
188
+ )
189
+ }
package/src/cli/argv.ts CHANGED
@@ -12,9 +12,7 @@ export interface ParsedArgs {
12
12
  readonly tone: string | null
13
13
  /** Value of `--width <N>`, or null. Validated by the boot layer (must be a positive integer). */
14
14
  readonly width: string | null
15
- /** Value of `--sort <mode>` (`dirs-first` or `files-first`), or null. Validated by the boot layer. */
16
- readonly sort: string | null
17
- /** True when `--serve` was passed: serve the given file as HTML, skip TUI. */
15
+ /** True when `--serve` was passed: serve the positional path as HTML, skip TUI. */
18
16
  readonly serve: boolean
19
17
  /** Value of `--port <N>`, or null. Validated by the boot layer. */
20
18
  readonly port: string | null
@@ -51,7 +49,6 @@ const createProgram = () =>
51
49
  .option("--theme [id]")
52
50
  .option("--tone [mode]")
53
51
  .option("--width [N]")
54
- .option("--sort [mode]")
55
52
  .option("--serve")
56
53
  .option("--port [N]")
57
54
  .option("--config-path")
@@ -69,7 +66,6 @@ const VALUE_FLAGS: ReadonlySet<string> = new Set([
69
66
  "--theme",
70
67
  "--tone",
71
68
  "--width",
72
- "--sort",
73
69
  "--port",
74
70
  "--sidebar",
75
71
  "--focus",
@@ -77,6 +73,8 @@ const VALUE_FLAGS: ReadonlySet<string> = new Set([
77
73
  "--root",
78
74
  ])
79
75
 
76
+ const REMOVED_VALUE_FLAGS: ReadonlySet<string> = new Set(["--sort"])
77
+
80
78
  const BOOLEAN_FLAGS: ReadonlySet<string> = new Set([
81
79
  "--serve",
82
80
  "--config-path",
@@ -91,7 +89,7 @@ const BOOLEAN_FLAGS: ReadonlySet<string> = new Set([
91
89
  const findPathArg = (argv: readonly string[]): string | null => {
92
90
  for (let i = 0; i < argv.length; i++) {
93
91
  const arg = argv[i]!
94
- if (VALUE_FLAGS.has(arg)) {
92
+ if (VALUE_FLAGS.has(arg) || REMOVED_VALUE_FLAGS.has(arg)) {
95
93
  const next = argv[i + 1]
96
94
  if (next !== undefined && !next.startsWith("-")) i++
97
95
  continue
@@ -123,7 +121,6 @@ export const parseArgv = (argv: readonly string[]): ParsedArgs => {
123
121
  theme: stringOrNull(opts["theme"]),
124
122
  tone: stringOrNull(opts["tone"]),
125
123
  width: stringOrNull(opts["width"]),
126
- sort: stringOrNull(opts["sort"]),
127
124
  serve: opts["serve"] === true,
128
125
  port: stringOrNull(opts["port"]),
129
126
  help: opts["help"] === true,
@@ -139,9 +136,11 @@ export const parseArgv = (argv: readonly string[]): ParsedArgs => {
139
136
 
140
137
  const themeList = themeDefinitions.map((t) => t.id).join(", ")
141
138
 
142
- export const usage = `usage: house [path] [options]
139
+ export const usage = `usage:
140
+ house [query] [options]
141
+ house --serve <path> [--port N]
143
142
 
144
- path file or directory; defaults to the current directory
143
+ query initial filter query; omit to browse the full discovery root
145
144
 
146
145
  options:
147
146
  --theme <id> color theme: ${themeList} (default: opencode)
@@ -149,11 +148,10 @@ options:
149
148
  --width <N> cap rendered markdown width at N columns
150
149
  --show <list> reveal normally-skipped entries; comma-separated subset of:
151
150
  hidden, gitignored. Use --show "" to clear.
152
- --root <dir> discovery root to walk (overrides defaultRoot config)
153
- --sort <mode> sidebar order: dirs-first (default) or files-first
151
+ --root <dir> discovery root to walk (overrides defaultRoot config/env)
154
152
  --sidebar <m> initial sidebar visibility: auto (default), on, or off
155
153
  --focus <m> startup focus: sidebar, reader, or filter (default: filter)
156
- --serve serve the given file as HTML in the browser (skips TUI)
154
+ --serve serve the positional path as HTML in the browser (skips TUI)
157
155
  --port <N> port for --serve (default: OS-assigned)
158
156
  -h, --help show this help and exit
159
157
  -v, --version print version and exit
@@ -161,6 +159,11 @@ options:
161
159
  --no-update-check suppress the "newer version available" check (also via NO_UPDATE_NOTIFIER=1)
162
160
  --no-mdx exclude .mdx files from discovery (default: included)
163
161
 
162
+ examples:
163
+ house README.md
164
+ house --root docs
165
+ house --serve README.md
166
+
164
167
  configuration:
165
168
  file: $XDG_CONFIG_HOME/house/config.toml (default ~/.config/house/config.toml)
166
169
  keys: theme, tone, mdx, show, focus, defaultRoot