@quandev104/pi-style 0.1.3 → 0.1.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/CHANGELOG.md +30 -0
- package/README.md +8 -4
- package/dist/extensions/pi-style.js +3777 -958
- package/dist/extensions/pi-style.js.map +1 -1
- package/extension-src/pi-style/app/command-service.ts +2 -0
- package/extension-src/pi-style/domain/config-normalization.ts +21 -5
- package/extension-src/pi-style/domain/config-presets.ts +1 -1
- package/extension-src/pi-style/domain/config-types.ts +7 -3
- package/extension-src/pi-style/domain/status.ts +1 -1
- package/extension-src/pi-style/domain/theme.ts +6 -1
- package/extension-src/pi-style/features/editor/index.ts +169 -27
- package/extension-src/pi-style/features/messages/index.ts +66 -0
- package/extension-src/pi-style/features/tools/bash-execution.ts +112 -0
- package/extension-src/pi-style/features/tools/boxed/bash.ts +430 -172
- package/extension-src/pi-style/features/tools/boxed/batch.ts +50 -27
- package/extension-src/pi-style/features/tools/boxed/command-shape.ts +136 -0
- package/extension-src/pi-style/features/tools/boxed/edit.ts +28 -2
- package/extension-src/pi-style/features/tools/boxed/fallback.ts +47 -4
- package/extension-src/pi-style/features/tools/boxed/find.ts +2 -2
- package/extension-src/pi-style/features/tools/boxed/gh.ts +1012 -0
- package/extension-src/pi-style/features/tools/boxed/git.ts +1960 -0
- package/extension-src/pi-style/features/tools/boxed/grep.ts +2 -2
- package/extension-src/pi-style/features/tools/boxed/output-tree.ts +9 -10
- package/extension-src/pi-style/features/tools/boxed/quick-edit.ts +25 -4
- package/extension-src/pi-style/features/tools/boxed/read.ts +3 -3
- package/extension-src/pi-style/features/tools/boxed/session-config.ts +64 -4
- package/extension-src/pi-style/features/tools/boxed/shared.ts +41 -1
- package/extension-src/pi-style/features/tools/boxed/write.ts +19 -2
- package/extension-src/pi-style/pi/compatibility-coordinator.ts +17 -0
- package/extension-src/pi-style/pi/compatibility-probe.ts +104 -10
- package/extension-src/pi-style/pi/compatibility-registry.ts +19 -3
- package/extension-src/pi-style/pi/index.ts +18 -1
- package/extension-src/pi-style/pi/session-coordinator.ts +33 -1
- package/extension-src/pi-style/shared/box.ts +86 -25
- package/extension-src/pi-style/shared/split-diff.ts +9 -9
- package/package.json +1 -1
- package/themes/titanium-light.json +82 -0
- package/themes/titanium.json +79 -0
- package/themes/.gitkeep +0 -0
|
@@ -0,0 +1,112 @@
|
|
|
1
|
+
// Boxed presentation for Pi's native direct bash execution (`!command` /
|
|
2
|
+
// `!!command` prefix in the input box). The native BashExecutionComponent draws
|
|
3
|
+
// plain full-width top/bottom bars; a fingerprint-certified additive render
|
|
4
|
+
// patch (see pi/compatibility-probe.ts) installs an own `render` on the
|
|
5
|
+
// prototype that re-frames the output into the same rounded box used by the
|
|
6
|
+
// boxed tool presentation: `╭─ ➔ Bash ◌ ─╮`, boxed `$ command` + output body,
|
|
7
|
+
// `╰─ Exit 0 ─╯`.
|
|
8
|
+
//
|
|
9
|
+
// The renderer is a pure delegate: it falls back to the native (inherited
|
|
10
|
+
// Container) rendering whenever the theme cache is empty or the component
|
|
11
|
+
// shape is unsupported. Nothing about the native instance is mutated — the
|
|
12
|
+
// box is computed per render from the live component state.
|
|
13
|
+
|
|
14
|
+
import type { BoxTheme } from "../../shared/box.js";
|
|
15
|
+
import {
|
|
16
|
+
boxBlankLine,
|
|
17
|
+
boxInnerWidth,
|
|
18
|
+
boxLabeledBorder,
|
|
19
|
+
boxLine,
|
|
20
|
+
boxWidth,
|
|
21
|
+
formatBoxedRunningStatus,
|
|
22
|
+
} from "../../shared/box.js";
|
|
23
|
+
import { getThemeExtra } from "../../shared/theme-extras.js";
|
|
24
|
+
|
|
25
|
+
let cachedTheme: BoxTheme | undefined;
|
|
26
|
+
|
|
27
|
+
/** Provide the active theme for the boxed bash execution display (session start / theme change). */
|
|
28
|
+
export function setBashExecutionTheme(theme: BoxTheme | undefined): void {
|
|
29
|
+
cachedTheme = theme;
|
|
30
|
+
}
|
|
31
|
+
|
|
32
|
+
/** Structural view of the native BashExecutionComponent as used by the patch. */
|
|
33
|
+
interface BashExecutionInstance {
|
|
34
|
+
command: string;
|
|
35
|
+
status: "running" | "cancelled" | "error" | "complete";
|
|
36
|
+
exitCode?: number | null;
|
|
37
|
+
contentContainer: { render(width: number): string[] };
|
|
38
|
+
/** Wall-clock start captured on the first boxed render for the live `◌ Running · Ns` footer. */
|
|
39
|
+
piStyleStart?: number;
|
|
40
|
+
}
|
|
41
|
+
|
|
42
|
+
const TOP_LEFT = "╭";
|
|
43
|
+
const TOP_RIGHT = "╮";
|
|
44
|
+
const BOTTOM_LEFT = "╰";
|
|
45
|
+
const BOTTOM_RIGHT = "╯";
|
|
46
|
+
|
|
47
|
+
function bashTitleColor(theme: BoxTheme): string {
|
|
48
|
+
// Honors the `bashPromptColor` theme extra, falling back to the bashMode
|
|
49
|
+
// semantic color (the same source the boxed bash tool title uses).
|
|
50
|
+
const extra = getThemeExtra(theme, "bashPromptColor");
|
|
51
|
+
return extra || "bashMode";
|
|
52
|
+
}
|
|
53
|
+
|
|
54
|
+
function boldOf(theme: BoxTheme): (text: string) => string {
|
|
55
|
+
return typeof theme?.bold === "function" ? theme.bold : (text: string) => text;
|
|
56
|
+
}
|
|
57
|
+
|
|
58
|
+
/** `➔ Bash ◌/✓/✗` — the same title language as the boxed bash tool call. */
|
|
59
|
+
function bashBoxTitle(theme: BoxTheme, host: BashExecutionInstance): string {
|
|
60
|
+
const name = "Bash";
|
|
61
|
+
const bold = boldOf(theme);
|
|
62
|
+
const prefix = theme.fg(bashTitleColor(theme), `➔ ${name}`);
|
|
63
|
+
if (host.status === "running") return bold(`${prefix} ${theme.fg("text", "◌")}`);
|
|
64
|
+
if (host.status === "cancelled") return bold(theme.fg("warning", `➔ ${name} ✗`));
|
|
65
|
+
if (host.status === "error") return bold(theme.fg("error", `➔ ${name} ✗`));
|
|
66
|
+
return bold(`${prefix} ${theme.fg("success", "✓")}`);
|
|
67
|
+
}
|
|
68
|
+
|
|
69
|
+
/** Bottom-border label: live running status with elapsed, or the terminal state. */
|
|
70
|
+
function bashBoxFooter(theme: BoxTheme, host: BashExecutionInstance): string {
|
|
71
|
+
if (host.status === "running") {
|
|
72
|
+
const elapsed = typeof host.piStyleStart === "number" ? (Date.now() - host.piStyleStart) / 1000 : undefined;
|
|
73
|
+
return formatBoxedRunningStatus(theme, elapsed);
|
|
74
|
+
}
|
|
75
|
+
if (host.status === "cancelled") return theme.fg("warning", "Cancelled");
|
|
76
|
+
if (host.status === "error") return theme.fg("error", `Exit ${host.exitCode ?? "?"}`);
|
|
77
|
+
return theme.fg("text", "Exit 0");
|
|
78
|
+
}
|
|
79
|
+
|
|
80
|
+
/**
|
|
81
|
+
* Render a BashExecutionComponent as the rounded box. Returns undefined so the
|
|
82
|
+
* caller falls back to the native rendering whenever the theme is unavailable
|
|
83
|
+
* or the component shape is not the certified layout.
|
|
84
|
+
*/
|
|
85
|
+
export function renderBashExecutionBox(instance: unknown, args: unknown[]): string[] | undefined {
|
|
86
|
+
const theme = cachedTheme;
|
|
87
|
+
const width = args[0];
|
|
88
|
+
if (!theme || typeof width !== "number" || !Number.isFinite(width) || width <= 0) return undefined;
|
|
89
|
+
const host = instance as BashExecutionInstance;
|
|
90
|
+
const content = host.contentContainer;
|
|
91
|
+
if (!content || typeof content.render !== "function") return undefined;
|
|
92
|
+
try {
|
|
93
|
+
if (host.piStyleStart === undefined) host.piStyleStart = Date.now();
|
|
94
|
+
const renderedWidth = boxWidth(width);
|
|
95
|
+
const inner = boxInnerWidth(renderedWidth);
|
|
96
|
+
// The native Text children render one leading padding space per line;
|
|
97
|
+
// drop it so boxLine's own side padding produces symmetric borders.
|
|
98
|
+
const wrapped = content
|
|
99
|
+
.render(inner)
|
|
100
|
+
.map((line) => boxLine(theme, line.startsWith(" ") ? line.slice(1) : line, renderedWidth));
|
|
101
|
+
return [
|
|
102
|
+
"",
|
|
103
|
+
boxLabeledBorder(theme, TOP_LEFT, TOP_RIGHT, bashBoxTitle(theme, host), undefined, renderedWidth),
|
|
104
|
+
boxBlankLine(theme, renderedWidth),
|
|
105
|
+
...wrapped,
|
|
106
|
+
boxBlankLine(theme, renderedWidth),
|
|
107
|
+
boxLabeledBorder(theme, BOTTOM_LEFT, BOTTOM_RIGHT, bashBoxFooter(theme, host), undefined, renderedWidth),
|
|
108
|
+
];
|
|
109
|
+
} catch {
|
|
110
|
+
return undefined;
|
|
111
|
+
}
|
|
112
|
+
}
|