@normful/pi-show-theme-colors 0.2.0

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/LICENSE ADDED
@@ -0,0 +1,21 @@
1
+ MIT License
2
+
3
+ Copyright (c) 2025 Norman Sue
4
+
5
+ Permission is hereby granted, free of charge, to any person obtaining a copy
6
+ of this software and associated documentation files (the "Software"), to deal
7
+ in the Software without restriction, including without limitation the rights
8
+ to use, copy, modify, merge, publish, distribute, sublicense, and/or sell
9
+ copies of the Software, and to permit persons to whom the Software is
10
+ furnished to do so, subject to the following conditions:
11
+
12
+ The above copyright notice and this permission notice shall be included in all
13
+ copies or substantial portions of the Software.
14
+
15
+ THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR
16
+ IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY,
17
+ FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE
18
+ AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER
19
+ LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM,
20
+ OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE
21
+ SOFTWARE.
package/README.md ADDED
@@ -0,0 +1,25 @@
1
+ # @normful/pi-show-theme-colors
2
+
3
+ Pi extension that shows available theme colors in the current Pi theme.
4
+
5
+ ## Installation
6
+
7
+ ```bash
8
+ npm install @normful/pi-show-theme-colors
9
+ ```
10
+
11
+ The extension is loaded automatically by Pi when declared in your Pi configuration.
12
+
13
+ ## Usage
14
+
15
+ Once installed, run:
16
+
17
+ ```
18
+ /show-theme-colors
19
+ ```
20
+
21
+ A display of all theme colors available in the current theme will be shown.
22
+
23
+ ## Keywords
24
+
25
+ `pi-extension` `pi-package` `theme` `colors`
package/package.json ADDED
@@ -0,0 +1,42 @@
1
+ {
2
+ "name": "@normful/pi-show-theme-colors",
3
+ "version": "0.2.0",
4
+ "private": false,
5
+ "description": "Pi extension that shows available theme colors",
6
+ "keywords": [
7
+ "pi",
8
+ "pi-coding-agent",
9
+ "pi-extension",
10
+ "pi-package"
11
+ ],
12
+ "bugs": {
13
+ "url": "https://github.com/normful/pi-bakery/issues"
14
+ },
15
+ "license": "MIT",
16
+ "author": "Norman Sue",
17
+ "repository": {
18
+ "type": "git",
19
+ "url": "git+https://github.com/normful/pi-bakery.git",
20
+ "directory": "packages/pi-show-theme-colors"
21
+ },
22
+ "type": "module",
23
+ "dependencies": {
24
+ "@spences10/pi-tui-modal": "0.0.22"
25
+ },
26
+ "devDependencies": {
27
+ "typescript": "7.0.2",
28
+ "vite-plus": "^0.2.5"
29
+ },
30
+ "peerDependencies": {
31
+ "@earendil-works/pi-agent-core": "*",
32
+ "@earendil-works/pi-ai": "*",
33
+ "@earendil-works/pi-coding-agent": "*",
34
+ "@earendil-works/pi-tui": "*"
35
+ },
36
+ "pi": {
37
+ "extensions": [
38
+ "./src/index.ts"
39
+ ],
40
+ "video": "https://www.github.com/normful/pi-bakery/packages/pi-show-theme-colors/demo.mp4"
41
+ }
42
+ }
package/src/index.ts ADDED
@@ -0,0 +1,92 @@
1
+ import type { ExtensionAPI, Theme, ThemeColor } from "@earendil-works/pi-coding-agent";
2
+ import { show_text_modal } from "@spences10/pi-tui-modal";
3
+
4
+ export const ALL_COLORS: ThemeColor[] = [
5
+ "accent",
6
+ "border",
7
+ "borderAccent",
8
+ "borderMuted",
9
+ "success",
10
+ "error",
11
+ "warning",
12
+ "muted",
13
+ "dim",
14
+ "text",
15
+ "thinkingText",
16
+ "userMessageText",
17
+ "customMessageText",
18
+ "customMessageLabel",
19
+ "toolTitle",
20
+ "toolOutput",
21
+ "mdHeading",
22
+ "mdLink",
23
+ "mdLinkUrl",
24
+ "mdCode",
25
+ "mdCodeBlock",
26
+ "mdCodeBlockBorder",
27
+ "mdQuote",
28
+ "mdQuoteBorder",
29
+ "mdHr",
30
+ "mdListBullet",
31
+ "toolDiffAdded",
32
+ "toolDiffRemoved",
33
+ "toolDiffContext",
34
+ "syntaxComment",
35
+ "syntaxKeyword",
36
+ "syntaxFunction",
37
+ "syntaxVariable",
38
+ "syntaxString",
39
+ "syntaxNumber",
40
+ "syntaxType",
41
+ "syntaxOperator",
42
+ "syntaxPunctuation",
43
+ "thinkingOff",
44
+ "thinkingMinimal",
45
+ "thinkingLow",
46
+ "thinkingMedium",
47
+ "thinkingHigh",
48
+ "thinkingXhigh",
49
+ "thinkingMax",
50
+ "bashMode",
51
+ ];
52
+
53
+ const RESET = "\x1b[0m";
54
+ const DEFAULT_SAMPLE = "The quick brown fox";
55
+
56
+ /**
57
+ * Build display lines for theme colors.
58
+ * Pure function — no side effects, no TUI dependency.
59
+ *
60
+ * @param theme - Theme instance with getFgAnsi method
61
+ * @param colors - ThemeColor values to display
62
+ * @param sample - Sample text to render in each color (default: "The quick brown fox")
63
+ * @returns Lines of the form "<color-name> <ANSI-colored-sample>"
64
+ */
65
+ export function buildColorDisplayLines(
66
+ theme: Pick<Theme, "getFgAnsi">,
67
+ colors: ThemeColor[],
68
+ sample = DEFAULT_SAMPLE,
69
+ ): string[] {
70
+ const lines: string[] = [];
71
+ for (const color of colors) {
72
+ const ansi = theme.getFgAnsi(color);
73
+ const colored = `${ansi}${sample}${RESET}`;
74
+ lines.push(`${color.padEnd(24)} ${colored}`);
75
+ }
76
+ return lines;
77
+ }
78
+
79
+ export default function (pi: ExtensionAPI) {
80
+ pi.registerCommand("theme-colors", {
81
+ description: "Show all current theme's colors using sample text",
82
+ handler: async (_args, ctx) => {
83
+ const theme = ctx.ui.theme;
84
+ const themeName = theme.name ?? "(unknown)";
85
+ const lines = buildColorDisplayLines(theme, ALL_COLORS);
86
+ await show_text_modal(ctx, {
87
+ title: `Colors of current theme: ${themeName}`,
88
+ text: lines.join("\n"),
89
+ });
90
+ },
91
+ });
92
+ }