Commit Graph

44 Commits

Author SHA1 Message Date
lerko 564039112a feat(export): add HTML card deck export
CI / test (pull_request) Failing after 10s
Self-contained single-file HTML export for cards. Mobile-first,
dark theme, zero dependencies. Each card type gets its own
interactive treatment: snippet tap-to-copy, template slot filling,
checklist with progress bar, decision structured layout, link
tap targets. Filter chips by type, search across all cards.

Usage: nib export -f html -o deck.html
       nib export -f html -t triage -o triage.html
2026-05-20 21:49:19 -04:00
lerko 2152baeb4f feat: add export and backup commands
- nib export: dump all entities to JSON (stdout or --output file)
- nib backup: atomic SQLite backup via VACUUM INTO (WAL-safe)
- Store.Backup() method on db layer
- Tests for both commands
2026-05-20 20:54:44 -04:00
lerko d715b053e7 refactor(db): thread context.Context through all Store methods
Enables request-scoped cancellation, timeouts, and graceful shutdown
for all database operations across API handlers, CLI commands, and TUI.
2026-05-20 20:51:51 -04:00
lerko 8663beeb96 fix: harden API, DB, and web layer from audit findings
- Cap list API limit at 200 to prevent unbounded queries
- Sanitize markdown output with DOMPurify to prevent XSS
- Add v4 migration with indexes on deleted_at and modified_at
- Fix v2 migration swallowed ALTER TABLE errors
- Tighten ~/.nib directory permissions to 0o700
2026-05-20 20:41:53 -04:00
lerko a96c1a52f4 feat(tui): add 13 preloaded themes matching web design system
Port all web CSS token themes to TUI via shared vocabulary (accent, dim,
muted, ok, todo, event, remind, danger). Styles rebuild from active
theme on switch. Press T to cycle, persists to ~/.nib/theme. Glamour
markdown renderer respects light/dark per theme.
2026-05-20 20:13:21 -04:00
lerko 533e086ffb fix(tui): esc closes detail split when list is focused
Previously esc in split view with list focus fell through to capture
focus. Now closes the detail pane and stays in stream browse mode.
2026-05-20 18:57:15 -04:00
lerko 989aa86679 fix(tui): compute truncation budget from actual overhead, not magic numbers
Tags wrapped past pane edge when detail split narrowed the list.
Truncation used fixed constants that didn't account for real tag width.
Now measures everything-except-body and gives body exactly what remains.
2026-05-20 18:49:38 -04:00
lerko 3eb778f31b fix(tui): clean up stream row density — drop ID, fix newline leak, align margins
ID cluttered rows and caused wrapping on long entries. Body newlines
leaked into stream rendering extra unindented lines. Cursor glyph
shifted selected rows 1 col right of unselected.

Remove ID from all row renderers (detail pane already shows it),
collapse multiline body to first line, cap tags to 2 in stream,
and reserve cursor column on unselected rows for consistent alignment.
2026-05-20 18:12:18 -04:00
lerko a567b2ce73 feat(tui): stumble mode — resurface stale entries card by card
Card-by-card walkthrough of entries untouched for 30+ days.
Prevents write-mostly decay by bringing old entries back to attention.

- S from list triggers stumble, loads entries where modified_at < 30d
- Single-card view with markdown body, glyph, tags, age indicator
- Actions: n skip, d dismiss, ! pin, p promote, m absorb, esc exit
- Progress indicator: stumble [3/12]
- After promote/absorb from stumble, returns to deck (not list)
- "All caught up" screen when deck exhausted
- DB: add ModifiedBefore to ListParams, modified_at sort column
2026-05-20 16:40:40 -04:00
lerko 60705463c1 fix(tui): simplify focus model — tab toggles capture ↔ list only
Tag rail removed from tab cycle to reduce focus confusion.
Rail is now ambient-by-default, focusable via h from list (spatial).

- Tab: capture ↔ list (no rail, no detail in cycle)
- h from list: focus tag rail (when visible)
- l from rail: back to list
- Split detail reachable via l/enter, not tab
- Remove nextFocusFromCapture helper
2026-05-20 15:08:11 -04:00
lerko b5b7f6b6ee feat(tui): collapsible tag rail with ambient tag awareness
Persistent left panel showing tags with counts. Provides ambient
awareness of tag landscape without requiring a modal.

- New tagRailModel in tagrail.go: tag list with cursor, scroll, counts
- Rail visible at >=100 cols width, 18% width (min 16 chars)
- ctrl+b toggles rail visibility
- focusTagRail added to focus cycle: capture → tags → list → detail
- j/k navigates, enter filters/unfilters by tag
- Active filter tag highlighted bold in rail
- Tags refresh after entity create/delete/absorb
- Rail auto-hides on narrow terminals, # modal still works as fallback
- Width allocation accounts for rail in split and non-split layouts
2026-05-20 14:32:32 -04:00
lerko a2dac64d1f feat(tui): always-visible capture bar with focus cycling
Replace drawer-based input with permanent capture bar at bottom.
Focus defaults to capture on startup — open nib, start typing.

- Remove stateInput; route via focusCapture/focusList/focusDetail
- Tab cycles: capture → list → detail (split) → capture
- Esc cascades: clear search → clear filter → focus capture
- Capture bar shows blinking cursor when focused, dims when not
- Intent cycling moved from tab to i (tab now cycles focus)
- Parse preview shown inline in status bar while typing
- Content area constant height (no layout thrash from drawer)
2026-05-20 14:11:46 -04:00
lerko c26e2d2022 feat(tui): status debounce, scroll indicator, drawer label, card grouping
Status messages now use a sequence counter so rapid actions don't
cause premature clearing. Detail pane shows scroll position and
supports pgup/pgdown/g/G. Capture drawer border includes inline
label. Cards view groups by intent (pinned/grab/read/fill) with
gutter labels matching the stream view's date grouping pattern.
2026-05-20 11:49:11 -04:00
lerko cb10d1e93d feat(tui): render entity body as markdown via glamour
Detail pane now pipes entity body through charmbracelet/glamour for
styled markdown output — headers, bold, code blocks, lists. Uses
hardcoded dark style to avoid terminal query freeze in alt screen.
2026-05-20 11:27:40 -04:00
lerko e20fae3543 feat(tui): add broot-style tab affordances to header and footer
Header now renders stream/cards as tabs with keybindings inline —
active tab highlighted, inactive shows the key to switch. Footer
shows a capture tab affordance when in list state. Redundant mode
and capture hints removed from the context hint bar.
2026-05-20 11:16:58 -04:00
lerko 4e0ac8402f fix(tui): pin footer to bottom, style hint bar, auto-clear status
Content area now enforces full height so the context help bar stays
pinned to the terminal bottom. Hint keys rendered with bold highlight
color for scannability. Status messages (created, deleted, etc.)
auto-clear after 2 seconds, reverting to the entity count.
2026-05-20 11:01:13 -04:00
lerko e2d0f3e997 fix(tui): add $VISUAL fallback for editor resolution
Check $EDITOR, then $VISUAL, then fall back to vi.
2026-05-20 10:34:09 -04:00
lerko 476abbed00 test(tui): add tier 1 unit tests for pure logic functions
Cover search filtering, intent matching, card affordances, checklist
parsing, template slot discovery/resolve, date grouping, and truncation.
2026-05-19 21:10:51 -04:00
lerko 39975a6787 chore(tui): remove dead formatPreviewEntity function 2026-05-19 21:01:26 -04:00
lerko f89ca8acb9 feat(tui): add split-pane detail, compact date headers, and input drawer
Three layout improvements for better space utilization:

- Compact date headers: date labels render as left gutter column instead
  of standalone lines, saving one line per date group in stream view
- Input drawer: capture bar expands to 4-line drawer with border, hints,
  and live preview of parsed entity/search query
- Split-pane detail: wide terminals (>=100 cols) show list and detail
  side-by-side with h/l focus switching, falling back to full-screen
  detail on narrow terminals
2026-05-19 19:55:37 -04:00
lerko e09919b679 fix: harden API, DB schema, and CLI safety
- Add 'reminder' to glyph CHECK constraint (was accepted by parser but
  rejected by DB)
- Default serve bind to 127.0.0.1, add --host flag for LAN access
- Validate card_data as JSON in Store.Create/Update/Promote
- Return pagination envelope {data,total,limit,offset} from list endpoint
- Append absorb breadcrumb to source entity before soft-delete
- Add Levenshtein fuzzy match to catch command typos before routing to add
- Replace DDL string-matching migrations with versioned schema_version table
- Update web UI and API tests for envelope response format
2026-05-19 18:30:17 -04:00
lerko babf1d6620 fix(tui): harden EDITOR handling and SQL sort/order validation
Split EDITOR env var on whitespace so multi-word values like
"code --wait" work correctly. Add allow-list switch for sort column
and order direction at the query boundary to prevent future callers
from passing unsanitized values into SQL.
2026-05-17 23:24:58 -04:00
lerko 77222ff1b8 feat(tui): add interactive run mode for checklists and fill mode for templates
Run mode (r key on checklist cards): cursor navigates steps, space
toggles done/undone, r resets all, esc saves changes to DB and exits.
Persists step state — improvement over web which discards on exit.

Fill mode (f key on template cards): tab/shift-tab navigates slots,
type to fill values, enter resolves template and copies to clipboard
with use count increment. Esc cancels without copying.

Both modes are sub-states of detail view, keeping architecture simple.
2026-05-17 21:53:55 -04:00
lerko 1066c0bc7d feat(tui): add search via capture bar and absorb flow
Search uses existing parse grammar ?prefix — type `?query #tag` in
capture bar to filter entities client-side. Substring match on
body+title+description with AND tag filtering. Esc clears search.

Absorb via m key on fluid entities — opens source picker showing all
other entities, enter merges source into target. Uses existing
store.Absorb() backend.
2026-05-17 21:35:44 -04:00
lerko ce335cabd6 feat(tui): add cards view, mode switching, promote picker, and card detail
Stream/cards toggle with 1/2 keys. Cards view with intent filtering
(tab cycles grab/read/fill/all), sort cycling (s key), pinned-first
ordering, and affordance badges. Promote picker (p key) with card type
selection and auto-detection from body content. Detail view renders
card_data per type: checklist steps, template slots, decision fields,
link URLs.

Extracts generateCardData to internal/carddata for reuse across cmd
and tui packages.
2026-05-17 21:14:14 -04:00
lerko c2ea63dd16 feat(tui): add status bar, help overlay, tag filter, and entity actions
Status bar with entity count and context-sensitive key hints. Help
overlay via ? key. Tag filter via # with cursor-navigable tag list.
Todo toggle (x), pin (!), promote (p), demote (D), copy (c), edit (e)
via $EDITOR. Delete confirmation with 3s timeout. Date-grouped list
with completed todo and pinned indicators. Esc clears active tag filter.

Adds CompletedAt/ClearCompleted to EntityUpdate for todo toggling.
2026-05-17 20:33:34 -04:00
lerko 36999cd825 feat(tui): add bubbletea terminal UI with entity list, detail, and capture
Adds `nib tui` command and `make tui` target. Scrollable entity list
with j/k navigation, enter for detail view, `a` to capture new entries
using the existing parse grammar, and `d` to delete.
2026-05-17 20:07:45 -04:00
lerko 4980714583 fix(api): check http errors before using response in tests 2026-05-17 14:10:40 -04:00
lerko 2b177eeae9 feat(cards): add 'note' card type for readable markdown content
New card type renders body as styled markdown with no copy/fill/run
affordance. Glyph: ¶, color: --note.

Migration uses transaction to safely rebuild table constraint.
Checks both 'note' presence and modified_at column to catch
partial migration state.
2026-05-17 12:49:43 -04:00
lerko 8bfa9b15ed fix(ui): tag counts, j/k nav, stream layout, search alignment
- Tag rail counts now reflect cards-only when in cards view
  (ListTags accepts cardsOnly filter, JS passes it per view)
- j/k navigation scoped to visible (intent/search filtered) list
- scrollSelectedIntoView works in both stream and cards view
- Entity items wrap title/desc/preview in .entity-content flex
  container so tags/pills align right consistently
- Title no longer eaten by description/body (flex-shrink + min-width)
- Search bar centered in header with margin auto
- switchView awaits loadEntities+loadTags to fix stale intent counts
2026-05-16 18:42:05 -04:00
lerko b7dd58bf3e feat(ui): absorb button in peek, preserve newlines, demote promoted items
Stream peek now shows absorb button for unpromoted entries. Promoted
items in stream show demote instead of delete. d double-tap demotes
any card_type entity regardless of view. Parsers preserve newlines
from Shift+Enter. Absorb popup truncates to first non-empty line.
2026-05-16 13:00:22 -04:00
lerko 97ad71d66b fix(parser): align Go and JS parsers with capture grammar spec
Kind prefixes now follow the canonical grammar: `-` for todo,
`@time` for event, `!time` for reminder. Removed `*`/`◇`/`▸`
as capture aliases (display-layer only). Added `\` escape prefix,
`?` query mode, `!pin` flag extraction, `##word` hash escape,
and tag lowercasing. Both parsers produce identical results.
2026-05-16 11:12:36 -04:00
lerko c8e18f0bc1 feat: add title and description fields to capture grammar
Implement | prefix for titles and // separator for descriptions
across the full stack: parser, schema, API, CLI, and web frontend.

- Parser: line-aware extraction for |title, |title // desc,
  // leading desc, body // inline desc. URL-safe (skips :// lines).
  Modifiers (#tag, @time, ^card) extracted from all segments.
- Schema: ALTER TABLE migration adds title, description columns
- DB: Entity/EntityUpdate structs, all CRUD queries updated
- API: title/description on create/update/response, body validation
  relaxed (title-only entries valid)
- CLI: shows title as scan label when present
- Web: parseInput mirrors Go parser, list shows title, detail pane
  renders title + description with double-click inline editing
- Tests: 10 new cases (grammar, entity, API) — 71 total, all pass
2026-05-15 21:19:33 -04:00
lerko 6278cb1022 fix: code principles audit — correctness, security, testability
- Add rows.Err() checks after all scan loops (entities, tags, resolve)
- Surface time.Parse errors instead of silently discarding
- Extract entityRow scan helper to eliminate Get/List duplication
- Cap request body at 1MB via MaxBytesReader
- Stop leaking internal errors to API clients (log server-side only)
- Block javascript: URIs in link card open button (XSS)
- Fix all go vet failures in api_test.go (unchecked http errors)
- Add tests for display package, generateCardData, absorb-source-card
- Run go mod tidy to fix direct/indirect dep markers
2026-05-14 17:41:30 -04:00
lerko aa7c9aef7d feat: implement nib design system — warm amber palette, dual themes, new typography
Replace Tokyonight/Catppuccin blue palette with warm amber/ink identity.
Dual theme support (noir + paper) via data-theme attribute with
localStorage persistence. Space Grotesk for chrome, Monaspace Neon for
content. Updated glyph set (Strokes: — ○ ◇) across web and CLI.
2026-05-14 17:02:11 -04:00
lerko 949ccaca59 feat: add browse-at-scale — date ranges, load more, month navigator
CLI: --month YYYY-MM, --from/--to date range, --limit override
API: from/to query params for date range filtering
Web: load more button for pagination, month nav (◂/▸) in stream view
2026-05-14 14:03:45 -04:00
lerko 7711240d68 feat: add absorb command — merge source entity into target
DB: Absorb() merges body (newline-separated), unions tags, demotes
crystallized sources, soft-deletes source. Rejects crystallized targets.

API: POST /api/entities/:id/absorb { source_id }

CLI: nib absorb <target> <source> with prefix ID resolution

Web: absorb button on fluid entities, 'a' keyboard shortcut,
source picker modal
2026-05-14 13:47:08 -04:00
lerko 03094706c3 fix: batch tag queries, inline edit, delete response, SPA catch-all, link glyph
- Fix N+1 tag query in List() with batched IN clause
- Add inline body editing in web detail pane (dblclick or e key)
- Delete API returns {result: "soft"|"hard"} with 200 instead of 204
- SPA handler serves index.html for all extensionless paths
- Link glyph changed from emoji 🔗 to unicode ↗ for terminal alignment
- Capture bar contrast and hover glow increased
- Comment on load-bearing "--" in root.go
2026-05-14 12:37:13 -04:00
lerko 5b0d0a8f33 feat(web): add vanilla JS/CSS SPA with embed.FS
Stream view with date grouping, card view sorted by usage, capture
bar with client-side grammar parsing, tag rail filter, detail pane
with card affordances (template slot fill, checklist toggle, link
open), promote modal with auto-detect, keyboard shortcuts (j/k/n/p/
Enter/dd/1/2). Dark theme, responsive layout. Embedded in Go binary.
2026-05-14 11:38:45 -04:00
lerko 6de174e474 feat(api): add HTTP server with full REST API
Chi router with all entity CRUD endpoints, promote/demote/use
actions, tag listing. CORS middleware for --dev mode. Graceful
shutdown on SIGINT/SIGTERM. 22 API integration tests via httptest.
2026-05-14 11:30:47 -04:00
lerko c3cc9464b9 feat(cli): add promote, cards, copy, demote, delete, edit commands
Complete CLI crystallization loop. Promote generates card_data
(template slots, checklist steps, link URLs). Cards view sorted by
use_count. Copy increments usage. Demote strips card layer. Delete
does soft then hard. Edit opens $EDITOR.
2026-05-14 11:28:17 -04:00
lerko a6fda5d1ee feat(cli): add nib add + nib ls commands
Default command delegation: `nib "..."` routes to `nib add`. Capture
bar parses grammar, creates entities. `nib ls` lists with date
grouping, tag filter, 48h default window. Display glyphs for all
entity types.
2026-05-14 11:17:27 -04:00
lerko 51cbf86d77 feat(parse): add capture grammar parser
Extracts glyph prefix, @time anchors, #tags, and ^card suffixes from
raw input. Table-driven tests cover all grammar forms including edge
cases. 24 tests passing.
2026-05-14 11:09:27 -04:00
lerko aed38433ae feat(db): add SQLite schema, Store CRUD, ULID generation
Foundation layer: entities table with card support, entity_tags join
table, WAL mode, busy_timeout, full CRUD operations including
promote/demote lifecycle and soft/hard delete. 33 tests passing.
2026-05-14 11:08:33 -04:00