pi-keyboard 0.1.5 → 0.1.6
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 +19 -1
- package/features/keyboard.feature +4 -0
- package/package.json +4 -1
- package/src/index.ts +10 -9
package/README.md
CHANGED
|
@@ -29,6 +29,24 @@ Supports discrete control for keyboard lighting channels:
|
|
|
29
29
|
|
|
30
30
|
---
|
|
31
31
|
|
|
32
|
+
## Structure
|
|
33
|
+
|
|
34
|
+
```
|
|
35
|
+
keyboard/
|
|
36
|
+
├── index.ts — Package-root extension entry point
|
|
37
|
+
├── src/
|
|
38
|
+
│ ├── config.ts — Keyboard config read/write helpers
|
|
39
|
+
│ ├── driver.ts — via-rgb binary resolution & CLI execution
|
|
40
|
+
│ ├── protocol.ts — VIA RAW HID packet building
|
|
41
|
+
│ ├── state-machine.ts — State transitions and LED apply logic
|
|
42
|
+
│ ├── global-sessions.ts — Per-cwd session glow record registry
|
|
43
|
+
│ ├── types.ts — KeyboardState, KeyboardZone, KeyboardConfig
|
|
44
|
+
│ └── index.ts — Pi lifecycle hooks, /keyboard command
|
|
45
|
+
├── features/ — BDD contract
|
|
46
|
+
├── tests/ — Package E2E tests
|
|
47
|
+
└── README.md
|
|
48
|
+
```
|
|
49
|
+
|
|
32
50
|
## Installation
|
|
33
51
|
|
|
34
52
|
Install from this monorepo or local path:
|
|
@@ -37,7 +55,7 @@ Install from this monorepo or local path:
|
|
|
37
55
|
pi install ~/Developer/FradSer/pi-packages/packages/keyboard
|
|
38
56
|
```
|
|
39
57
|
|
|
40
|
-
|
|
58
|
+
Published on npm:
|
|
41
59
|
|
|
42
60
|
```bash
|
|
43
61
|
pi install npm:pi-keyboard
|
|
@@ -134,3 +134,7 @@ Feature: Pi Keyboard Lighting Indicator
|
|
|
134
134
|
Then all keyboard lighting updates are disabled
|
|
135
135
|
When the user runs "/keyboard test thinking"
|
|
136
136
|
Then the keyboard lighting displays the blue thinking state
|
|
137
|
+
|
|
138
|
+
Scenario: Keyboard state notifications use Pi's native notification surface
|
|
139
|
+
Given the keyboard extension reports an interactive command outcome
|
|
140
|
+
Then it uses ctx.ui.notify without a custom notification renderer
|
package/package.json
CHANGED
|
@@ -1,6 +1,6 @@
|
|
|
1
1
|
{
|
|
2
2
|
"name": "pi-keyboard",
|
|
3
|
-
"version": "0.1.
|
|
3
|
+
"version": "0.1.6",
|
|
4
4
|
"description": "Dynamic VIA/QMK keyboard RGB lighting indicator reflecting Pi states (idle, thinking, unread, need-approval, error)",
|
|
5
5
|
"author": "Frad LEE <fradser@gmail.com>",
|
|
6
6
|
"license": "MIT",
|
|
@@ -36,5 +36,8 @@
|
|
|
36
36
|
"peerDependencies": {
|
|
37
37
|
"@earendil-works/pi-coding-agent": "*",
|
|
38
38
|
"@earendil-works/pi-tui": "*"
|
|
39
|
+
},
|
|
40
|
+
"dependencies": {
|
|
41
|
+
"@fradser/pi-kit": "0.4.2"
|
|
39
42
|
}
|
|
40
43
|
}
|
package/src/index.ts
CHANGED
|
@@ -2,6 +2,7 @@ import type {
|
|
|
2
2
|
ExtensionAPI,
|
|
3
3
|
ExtensionCommandContext,
|
|
4
4
|
} from "@earendil-works/pi-coding-agent";
|
|
5
|
+
import { notifyPi } from "@fradser/pi-kit";
|
|
5
6
|
import { readKeyboardConfig, writeKeyboardConfig } from "./config";
|
|
6
7
|
import { fetchKeyboardStatus } from "./driver";
|
|
7
8
|
import { KeyboardStateMachine } from "./state-machine";
|
|
@@ -147,14 +148,14 @@ export default function (pi: ExtensionAPI): void {
|
|
|
147
148
|
if (trimmed === "on") {
|
|
148
149
|
sm.updateConfig({ enabled: true });
|
|
149
150
|
writeKeyboardConfig(sm.getConfig());
|
|
150
|
-
ctx.ui
|
|
151
|
+
notifyPi(ctx.ui, "Keyboard lighting indicator enabled", "info");
|
|
151
152
|
return;
|
|
152
153
|
}
|
|
153
154
|
|
|
154
155
|
if (trimmed === "off") {
|
|
155
156
|
sm.updateConfig({ enabled: false });
|
|
156
157
|
writeKeyboardConfig(sm.getConfig());
|
|
157
|
-
ctx.ui
|
|
158
|
+
notifyPi(ctx.ui, "Keyboard lighting indicator disabled", "info");
|
|
158
159
|
return;
|
|
159
160
|
}
|
|
160
161
|
|
|
@@ -168,9 +169,9 @@ export default function (pi: ExtensionAPI): void {
|
|
|
168
169
|
const targetState = (parts[1] || "thinking") as KeyboardState;
|
|
169
170
|
if (targetState in KEYBOARD_STATE_DEFINITIONS) {
|
|
170
171
|
await sm.transitionTo(targetState, true);
|
|
171
|
-
ctx.ui
|
|
172
|
+
notifyPi(ctx.ui, `Testing state: ${KEYBOARD_STATE_DEFINITIONS[targetState].labelZh}`, "info");
|
|
172
173
|
} else {
|
|
173
|
-
ctx.ui
|
|
174
|
+
notifyPi(ctx.ui, `Unknown test state. Options: ${Object.keys(KEYBOARD_STATE_DEFINITIONS).join(", ")}`, "error");
|
|
174
175
|
}
|
|
175
176
|
return;
|
|
176
177
|
}
|
|
@@ -194,7 +195,7 @@ async function showStatus(ctx: ExtensionCommandContext, sm: KeyboardStateMachine
|
|
|
194
195
|
`Hardware Status : ${hw.connected ? `Connected (${hw.device?.product || "VIA Keyboard"})` : "Not connected / Not detected"}`,
|
|
195
196
|
];
|
|
196
197
|
|
|
197
|
-
ctx.ui
|
|
198
|
+
notifyPi(ctx.ui, lines.join("\n"), "info");
|
|
198
199
|
}
|
|
199
200
|
|
|
200
201
|
async function openKeyboardMenu(
|
|
@@ -224,7 +225,7 @@ async function openKeyboardMenu(
|
|
|
224
225
|
const next = !config.enabled;
|
|
225
226
|
sm.updateConfig({ enabled: next });
|
|
226
227
|
writeKeyboardConfig(sm.getConfig());
|
|
227
|
-
ctx.ui
|
|
228
|
+
notifyPi(ctx.ui, `Keyboard lighting indicator is now ${next ? "ON" : "OFF"}`, "info");
|
|
228
229
|
return;
|
|
229
230
|
}
|
|
230
231
|
|
|
@@ -237,7 +238,7 @@ async function openKeyboardMenu(
|
|
|
237
238
|
const chosenState = stateKeys[idx];
|
|
238
239
|
if (chosenState) {
|
|
239
240
|
await sm.transitionTo(chosenState, true);
|
|
240
|
-
ctx.ui
|
|
241
|
+
notifyPi(ctx.ui, `Applied state: ${KEYBOARD_STATE_DEFINITIONS[chosenState].labelZh}`, "info");
|
|
241
242
|
}
|
|
242
243
|
}
|
|
243
244
|
return;
|
|
@@ -259,7 +260,7 @@ async function openKeyboardMenu(
|
|
|
259
260
|
const zone = zoneMap[zoneChoice] || "all";
|
|
260
261
|
sm.updateConfig({ zone });
|
|
261
262
|
writeKeyboardConfig(sm.getConfig());
|
|
262
|
-
ctx.ui
|
|
263
|
+
notifyPi(ctx.ui, `Active zone set to: ${zone.toUpperCase()}`, "info");
|
|
263
264
|
}
|
|
264
265
|
return;
|
|
265
266
|
}
|
|
@@ -277,7 +278,7 @@ async function openKeyboardMenu(
|
|
|
277
278
|
const scale = scaleMap[scaleChoice] ?? 1.0;
|
|
278
279
|
sm.updateConfig({ brightnessScale: scale });
|
|
279
280
|
writeKeyboardConfig(sm.getConfig());
|
|
280
|
-
ctx.ui
|
|
281
|
+
notifyPi(ctx.ui, `Brightness scale set to ${Math.round(scale * 100)}%`, "info");
|
|
281
282
|
}
|
|
282
283
|
return;
|
|
283
284
|
}
|