@bismawy/pi-arnative 0.2.0 → 0.2.1

This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
package/README.md CHANGED
@@ -1,89 +1,69 @@
1
- <div align="center">
1
+ # Arnative
2
2
 
3
- # pi-arnative
3
+ A visual layer and tool styling tailored to your vibe coding.
4
4
 
5
- An arnative look for [pi](https://github.com/earendil-works/pi-coding-agent) — 11 warm-neutral themes, rounded tool boxes, a branded header with clickable tabs, a 2-line footer, a transcript clock, and a `/usage` dashboard.
5
+ [![Custom badge](https://shieldcn.dev/badge/pi-%20Packages.svg?variant=outline&size=xs&logo=ri%3APiPiBold)](https://pi.dev/packages/@bismawy/pi-arnative)
6
+ [![badge](https://shieldcn.dev/npm/react.svg?variant=outline&size=xs)](https://www.npmjs.com/package/@bismawy/pi-arnative)
7
+ [![license](https://shieldcn.dev/github/bismawy/pi-arnative/license.svg?variant=outline&size=xs)](https://github.com/bismawy/pi-arnative)
6
8
 
7
- [pi package](https://pi.dev/packages/@bismawy/pi-arnative) · [npm](https://www.npmjs.com/package/@bismawy/pi-arnative) · [Issues](https://github.com/bismawy/pi-arnative/issues)
9
+ ## Overview
8
10
 
9
- ![npm](https://img.shields.io/npm/v/@bismawy/pi-arnative)
10
- ![license](https://img.shields.io/badge/license-MIT-green)
11
+ pi-arnative replaces pi’s default terminal chrome with a unified, cohesive visual aesthetic.
11
12
 
12
- </div>
13
-
14
- ## What it does
15
-
16
- pi-arnative replaces pi's chrome with one visual language — box drawing, dim borders, cyan accent, tint for values — without touching session data.
17
-
18
- - **11 themes, one generator:** `arnative` plus 10 variants (`sun`, `zinc`, `violet`, `emerald`, `matrix`, `cyberpunk`, `synthwave`, `gruvbox`, `nord`, `dracula`), all generated from a single base file so their structure can never drift.
19
- - **Header box with tabs:** replaces pi's stacked resource list with a 5-line box — logo, version + shortcuts, and a clickable `Model / Directory / Context / Skills / Extensions / Themes` tab menu. The `Directory` tab shows the full working directory (wrapped at `/`, never truncated).
20
- - **Tool boxes:** every tool call renders in its own rounded box — spinner while running, then `✓`/`x`, right-aligned duration, and a one-line summary. Click or `ctrl+e` for the full output.
21
- - **2-line footer:** `cwd | duration | branch/tag/status` on the first line, extension status + tok/s + cache + tokens on the second, plus a full-box editor with a `> ` prompt.
22
- - **Transcript clock:** user and assistant messages get a right-aligned time, and the user bubble background is repaired where Markdown resets would otherwise leave black blocks.
23
- - **Render fixes:** hidden reload box, readable drag selection, single-line compaction messages, and a higher-contrast `↓ Jump to latest message` pill.
24
- - **Contrast-checked themes:** the self-check measures every `themes/*.json` against its own canvas, so no variant ships an unreadable box.
13
+ - Warm Themes: Cohesive, contrast-checked color palettes generated without drift.
14
+ - Tabbed Header: Compact box menu with quick access to Model, Skills, Extensions, and Themes.
15
+ - Rounded Tool Boxes: Clear status, spinner, and duration for every tool call.
16
+ - Enhanced Footer: 2-line layout showing directory path, git branch, model, and token metrics.
17
+ - Transcript Clock: Timestamps for messages with clean bubble backgrounds.
18
+ - Usage Dashboard: /usage command to track tokens and session costs.
25
19
 
26
20
  ## Install
27
21
 
28
- **Install [JetBrains Mono Nerd Font](https://www.nerdfonts.com/font-downloads) first.** Every icon in this package (tab icons `󰋖 󰺨 󰰡 󰹲`, tool icons `󰔟 󱞩 ✓`, footer icons `󰃭 󰍛 󰣇`, and the rounded box corners `╭─╮`) is a Nerd Font glyph — without the font they render as empty boxes (□) or random characters.
29
-
30
- 1. Download **JetBrainsMono Nerd Font** from [nerdfonts.com/font-downloads](https://www.nerdfonts.com/font-downloads).
31
- 2. Extract and install it (Linux: copy into `~/.local/share/fonts/` then `fc-cache -f`; Windows: right click → Install).
32
- 3. Set your terminal to **JetBrainsMono NF** (or another Nerd Font) as the primary font.
33
-
34
22
  ```bash
35
23
  pi install npm:@bismawy/pi-arnative
36
24
  ```
37
25
 
38
- Pick a theme in `/settings` > Theme > `arnative` (or any `arnative-*` variant). Everything else — header, footer, tool boxes, clock — turns itself on at session start.
39
-
40
- To try it without installing, from this directory:
26
+ Select a theme via `/settings` → **Theme** → `arnative` (or any `arnative-*` variant).
41
27
 
28
+ To test locally without installing:
42
29
  ```bash
43
30
  pi --extension ./extensions/footer.ts
44
31
  ```
32
+ > **Prerequisite:** Requires a [Nerd Font](https://www.nerdfonts.com/font-downloads) (e.g. JetBrains Mono Nerd Font) for icons and rounded box borders.
45
33
 
46
- ## Commands
47
-
48
- | Command | Action |
49
- | :--- | :--- |
50
- | `/usage` | Token, message & cache usage across all local Pi sessions |
34
+ ## Shortcuts
51
35
 
52
- | Shortcut | Action |
53
- | :--- | :--- |
54
- | `ctrl+alt+t` | Cycle the header tab (Model → Directory → Context → Skills → Extensions → Themes) |
55
- | click a header tab | Open that tab |
56
- | click a tool box / `ctrl+e` | Toggle full title and output |
36
+ | Key / Action | Result |
37
+ | --- | --- |
38
+ | `/usage` | Show session usage & token metrics |
39
+ | `ctrl+alt+t` | Cycle header tabs (Model → Directory → Context → Skills → Extensions → Themes) |
40
+ | `ctrl+alt+r` | Quick reload runtime (`/reload`) |
41
+ | Click tab | Open selected header tab |
42
+ | Click tool / `ctrl+e` | Toggle tool output box |
57
43
 
58
- ## How it works
44
+ ## Architecture
59
45
 
60
46
  <details>
61
47
  <summary><b>Extensions</b></summary>
62
48
 
63
49
  | File | Role |
64
- | :--- | :--- |
65
- | `extensions/tools.ts` | Tool call boxes, summaries, spinner, duration, per-tool backgrounds |
66
- | `extensions/section-headers.ts` | Header box, logo, tab menu, and the interception of pi's resource list |
67
- | `extensions/footer.ts` | 2-line footer and the full-box editor |
68
- | `extensions/timestamps.ts` | Transcript clock and user bubble background repair |
69
- | `extensions/ui-render-tweaks.ts` | Reload box, drag selection, compaction, Jev review box, contrast self-check |
70
- | `extensions/usage.ts` | `/usage` table dashboard |
71
-
72
- `lib/box.ts` and `lib/ansi.ts` hold the single definitions shared by all of them. They live outside `extensions/` so pi never loads them as extensions.
50
+ | --- | --- |
51
+ | `extensions/tools.ts` | Rounded tool boxes, spinners, and duration |
52
+ | `extensions/section-headers.ts` | Tabbed header and resource box |
53
+ | `extensions/footer.ts` | 2-line status footer and boxed editor |
54
+ | `extensions/timestamps.ts` | Message clock and bubble background fixes |
55
+ | `extensions/ui-render-tweaks.ts` | Contrast tweaks, selection style, and UI polish |
56
+ | `extensions/usage.ts` | `/usage` token dashboard |
73
57
 
74
58
  </details>
75
59
 
76
60
  <details>
77
61
  <summary><b>Themes</b></summary>
78
62
 
79
- - `themes/arnative.json` is both the default theme and the structure source of truth — it is never rewritten by the generator.
80
- - `themes/gen-themes.mjs` holds the palette table and writes the variants by text substitution on the base, so the original formatting is preserved.
81
- - `npm run themes` rewrites every variant; `npm test` runs the same generator in `--check` mode, so a hand-edited variant file cannot drift.
82
- - Every variant fills all `vars`/`colors`/`export` keys, so no color can silently inherit the base.
63
+ - `themes/arnative.json` serves as the structure source of truth.
64
+ - `themes/gen-themes.mjs` generates variants with automated contrast checks.
83
65
 
84
- Palette: `sun` warm amber · `zinc` neutral grey · `violet` purple · `emerald` green · `matrix` monochrome phosphor green on near-black · `cyberpunk` neon magenta/cyan on deep indigo · `synthwave` 80s retro · `gruvbox` warm retro · `nord` cool frost blue · `dracula` dark purple.
85
-
86
- Contrast rules enforced by the self-check (measured against each theme's own `userMessageBg` canvas): content ≥ 3.0, secondary text ≥ 2.0, `thinking*` ramp 1.3–4.0, accent pill ≥ 4.5, tool box text ≥ 4.5 on both success and error backgrounds, error box weight matched to the success box, and `scrollbarThumb` / `searchMatchBg` distinguishable from their track / selection.
66
+ **Variants:** `sun` · `zinc` · `violet` · `emerald` · `matrix` · `cyberpunk` · `synthwave` · `gruvbox` · `nord` · `dracula`
87
67
 
88
68
  </details>
89
69
 
@@ -91,18 +71,16 @@ Contrast rules enforced by the self-check (measured against each theme's own `us
91
71
  <summary><b>Development</b></summary>
92
72
 
93
73
  ```bash
94
- npm test # every self-check + theme generator --check
95
- npm run themes # rewrite all theme variants
74
+ npm test # Run self-checks & theme generator check
75
+ npm run themes # Rebuild all theme variants
96
76
  ```
97
77
 
98
- Each extension is also a standalone self-check: `node extensions/tools.ts`.
99
-
100
78
  </details>
101
79
 
102
80
  ## License
103
81
 
104
82
  Distributed under the **MIT** license.
105
83
 
106
- ## Developer
84
+ ## Author
107
85
 
108
- Developed and maintained by [Bisma](https://github.com/bismawy).
86
+ [Bisma](https://github.com/bismawy)
@@ -9,10 +9,14 @@
9
9
  */
10
10
  import type { AssistantMessage } from "@earendil-works/pi-ai";
11
11
  import { CustomEditor, FooterComponent, type ExtensionAPI } from "@earendil-works/pi-coding-agent";
12
- import { truncateToWidth, visibleWidth } from "@earendil-works/pi-tui";
12
+ import { Key, matchesKey, truncateToWidth, visibleWidth } from "@earendil-works/pi-tui";
13
13
  import { execFile } from "node:child_process";
14
14
  import { formatTokens } from "../lib/usage-store.ts";
15
15
 
16
+ // The TUI drops key-release events before handleInput, so press+release cannot
17
+ // fire this twice even when the terminal reports event types (Kitty flag 2).
18
+ const RELOAD_SHORTCUT = Key.ctrlAlt("r");
19
+
16
20
  // Intercept the built-in FooterComponent to force a pure 2-line footer
17
21
  const PATCHED_KEY = Symbol.for("pi-arnative.footer2LinesPatched");
18
22
  if (FooterComponent?.prototype?.render && !(globalThis as Record<symbol, boolean>)[PATCHED_KEY]) {
@@ -471,6 +475,17 @@ export default function (pi: ExtensionAPI) {
471
475
  return super.renderTopBorder(width, hiddenLineCount);
472
476
  }
473
477
 
478
+ handleInput(data: string) {
479
+ if (matchesKey(data, RELOAD_SHORTCUT)) {
480
+ this.setText("");
481
+ if (this.onSubmit) {
482
+ this.onSubmit("/reload");
483
+ }
484
+ return;
485
+ }
486
+ super.handleInput(data);
487
+ }
488
+
474
489
  render(width: number): string[] {
475
490
  // The box eats 5 columns: 2 sides + the 3-column " > " prompt, so the
476
491
  // content is rendered 5 columns narrower.
@@ -643,5 +658,12 @@ if (isMain) {
643
658
  assert(getToolWorkingMessage("mcp", { tool: "fetch_repo" }) === "Fetching", "mcp fetch -> Fetching");
644
659
  assert(boxed.slice(0, 4).every((l) => visibleWidth(l) === visibleWidth(D) + 5), "lebar kotak seragam (sisi+prompt)");
645
660
  assert(boxEditorLines(["\u2500\u2500\u2500\u2500"], 1, plain).length === 1, "terlalu sempit: tak diubah");
661
+
662
+ // Guard: the reload shortcut must match every encoding a terminal can deliver,
663
+ // so a typo in the key id fails here instead of silently doing nothing.
664
+ assert(matchesKey("\x1b\x12", RELOAD_SHORTCUT), "shortcut cocok dgn ctrl+alt+r legacy (ESC + 0x12)");
665
+ assert(matchesKey("\x1b[114;7u", RELOAD_SHORTCUT), "shortcut cocok dgn ctrl+alt+r Kitty CSI-u");
666
+ assert(!matchesKey("\x12", RELOAD_SHORTCUT), "ctrl+r polos tidak memicu reload");
667
+ assert(!matchesKey("r", RELOAD_SHORTCUT), "huruf r tidak memicu reload");
646
668
  console.log("footer.ts self-check OK");
647
669
  }
package/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "@bismawy/pi-arnative",
3
- "version": "0.2.0",
3
+ "version": "0.2.1",
4
4
  "description": "Arnative look for Pi: 11 warm-neutral themes, rounded tool boxes, branded header with tabs, 2-line footer with git/model/status, transcript clock, and a /usage dashboard.",
5
5
  "keywords": [
6
6
  "pi-package",
@@ -37,6 +37,7 @@
37
37
  "@earendil-works/pi-tui": "*"
38
38
  },
39
39
  "scripts": {
40
+ "dev": "pi --extension ./extensions/tools.ts --extension ./extensions/section-headers.ts --extension ./extensions/footer.ts --extension ./extensions/timestamps.ts --extension ./extensions/ui-render-tweaks.ts --extension ./extensions/usage.ts",
40
41
  "test": "node lib/box.ts && node lib/ansi.ts && node themes/gen-themes.mjs --check && node extensions/tools.ts && node extensions/footer.ts && node extensions/timestamps.ts && node extensions/section-headers.ts && node extensions/ui-render-tweaks.ts && node extensions/usage.ts",
41
42
  "themes": "node themes/gen-themes.mjs"
42
43
  }