@dsh-stack/tweak-keybinds 0.0.0-stage → 0.1.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/README.md CHANGED
@@ -1,3 +1,5 @@
1
- # Temporary Holding Version
1
+ # tweak-keybinds
2
2
 
3
- This version is a temporary placeholder for this package. An operational version to replace this has been submitted for review and is awaiting a staged release.
3
+ Keybind settings surface: the tweaks-keybinds section schema and validation consumed by the client.
4
+
5
+ An extension of the `tweaks` settings surface, split out of the bundled `tweaks` package.
package/lib/index.d.ts ADDED
@@ -0,0 +1,27 @@
1
+ /**
2
+ * `tweak-keybinds`: the keybind settings surface — the `tweaks-keybinds`
3
+ * section schema with validation, consumed by the client. Split out of the
4
+ * bundled `tweaks` package.
5
+ * @module tweak-keybinds
6
+ */
7
+ import type { Context } from "@deepseek-ai/cordis";
8
+ import type z from "@deepseek-ai/schemastery";
9
+ import { type KeybindsConfig as KeybindsConfigType } from "./settings.js";
10
+ export { NS_KEYBINDS, KeybindEntry, KeybindsConfig } from "./settings.js";
11
+ export type { KeybindEntry as KeybindEntryType, KeybindsConfig as KeybindsConfigType, } from "./settings.js";
12
+ export { validateKeybinds } from "./keybinds.js";
13
+ export declare const name = "tweak-keybinds";
14
+ export declare const inject: string[];
15
+ /** The keybinds extension config: the keybinds section itself. */
16
+ export type Config = KeybindsConfigType;
17
+ export declare const Config: z<Config>;
18
+ /**
19
+ * apply implementation.
20
+ *
21
+ * The keybind form is the `KeybindsConfig` this plugin already declares, and its
22
+ * namespace is this plugin's entry id, so there is nothing to install. The
23
+ * chord invariants are checked here instead of on write: the settings service
24
+ * validates a write against the schema alone, and an empty chord or an action
25
+ * bound to two chords is a cross-entry rule no field schema can express.
26
+ */
27
+ export declare function apply(ctx: Context, config: Config): void;
package/lib/index.js ADDED
@@ -0,0 +1,31 @@
1
+ /**
2
+ * `tweak-keybinds`: the keybind settings surface — the `tweaks-keybinds`
3
+ * section schema with validation, consumed by the client. Split out of the
4
+ * bundled `tweaks` package.
5
+ * @module tweak-keybinds
6
+ */
7
+ import { declareCustomSettingsPage } from "@dsh-stack/plugin-kit";
8
+ import { validateKeybinds } from "./keybinds.js";
9
+ import { KeybindsConfig, } from "./settings.js";
10
+ export { NS_KEYBINDS, KeybindEntry, KeybindsConfig } from "./settings.js";
11
+ export { validateKeybinds } from "./keybinds.js";
12
+ export const name = "tweak-keybinds";
13
+ export const inject = [];
14
+ export const Config = KeybindsConfig;
15
+ /**
16
+ * apply implementation.
17
+ *
18
+ * The keybind form is the `KeybindsConfig` this plugin already declares, and its
19
+ * namespace is this plugin's entry id, so there is nothing to install. The
20
+ * chord invariants are checked here instead of on write: the settings service
21
+ * validates a write against the schema alone, and an empty chord or an action
22
+ * bound to two chords is a cross-entry rule no field schema can express.
23
+ */
24
+ export function apply(ctx, config) {
25
+ const keybinds = {
26
+ enabled: config?.enabled ?? true,
27
+ keymap: config?.keymap ?? [],
28
+ };
29
+ validateKeybinds(keybinds.keymap);
30
+ declareCustomSettingsPage(ctx);
31
+ }
@@ -0,0 +1,8 @@
1
+ /**
2
+ * tweak-keybinds validation: the settings `validate` hook logic for keybind
3
+ * entries.
4
+ * @module tweak-keybinds/keybinds
5
+ */
6
+ import type { KeybindEntry } from "./settings.js";
7
+ /** Validate a keybind entry list (used by the settings `validate` hook). */
8
+ export declare function validateKeybinds(entries: KeybindEntry[]): void;
@@ -0,0 +1,19 @@
1
+ /**
2
+ * tweak-keybinds validation: the settings `validate` hook logic for keybind
3
+ * entries.
4
+ * @module tweak-keybinds/keybinds
5
+ */
6
+ /** Validate a keybind entry list (used by the settings `validate` hook). */
7
+ export function validateKeybinds(entries) {
8
+ const seen = new Map();
9
+ for (const entry of entries) {
10
+ if (entry.keys.trim().length === 0) {
11
+ throw new Error(`keybind "${entry.action}" has an empty chord`);
12
+ }
13
+ const prior = seen.get(entry.action);
14
+ if (prior !== undefined && prior !== entry.keys) {
15
+ throw new Error(`keybind action "${entry.action}" bound twice (${prior} vs ${entry.keys})`);
16
+ }
17
+ seen.set(entry.action, entry.keys);
18
+ }
19
+ }
@@ -0,0 +1,24 @@
1
+ /**
2
+ * tweak-keybinds settings: the keybind settings surface schema — a keymap of
3
+ * action → chord consumed by the client.
4
+ * @module tweak-keybinds/settings
5
+ */
6
+ import z from "@deepseek-ai/schemastery";
7
+ /** Namespace of the keybind section — this plugin's own Loader entry id. */
8
+ export declare const NS_KEYBINDS: import("@dsh-stack/plugin-kit").SettingsNamespace;
9
+ /** One keybind: a named action bound to a key chord. */
10
+ export interface KeybindEntry {
11
+ /** The action id (e.g. `plan.toggle`, `undo`, `redo`). */
12
+ action: string;
13
+ /** The key chord (e.g. `mod+t`, `alt+u`). */
14
+ keys: string;
15
+ /** Optional per-keymap override (default keymap implied when absent). */
16
+ when?: string;
17
+ }
18
+ export declare const KeybindEntry: z<KeybindEntry>;
19
+ /** The keybind section: a keymap of action → chord. */
20
+ export interface KeybindsConfig {
21
+ enabled: boolean;
22
+ keymap: KeybindEntry[];
23
+ }
24
+ export declare const KeybindsConfig: z<KeybindsConfig>;
@@ -0,0 +1,18 @@
1
+ /**
2
+ * tweak-keybinds settings: the keybind settings surface schema — a keymap of
3
+ * action → chord consumed by the client.
4
+ * @module tweak-keybinds/settings
5
+ */
6
+ import z from "@deepseek-ai/schemastery";
7
+ import { settingsNamespace } from "@dsh-stack/plugin-kit";
8
+ /** Namespace of the keybind section — this plugin's own Loader entry id. */
9
+ export const NS_KEYBINDS = settingsNamespace("tweak-keybinds");
10
+ export const KeybindEntry = z.object({
11
+ action: z.string(),
12
+ keys: z.string(),
13
+ when: z.string(),
14
+ });
15
+ export const KeybindsConfig = z.object({
16
+ enabled: z.boolean().default(true),
17
+ keymap: z.array(KeybindEntry).default([]),
18
+ });
package/package.json CHANGED
@@ -1,6 +1,52 @@
1
1
  {
2
2
  "name": "@dsh-stack/tweak-keybinds",
3
- "version": "0.0.0-stage",
4
- "stub": true,
5
- "description": "Temporary package placeholder for staged publishing"
6
- }
3
+ "version": "0.1.0",
4
+ "description": "Keybind settings surface: the tweaks-keybinds section schema and validation consumed by the client.",
5
+ "license": "MIT",
6
+ "type": "module",
7
+ "main": "lib/index.js",
8
+ "types": "lib/index.d.ts",
9
+ "exports": {
10
+ ".": {
11
+ "types": "./lib/index.d.ts",
12
+ "default": "./lib/index.js"
13
+ }
14
+ },
15
+ "files": [
16
+ "lib",
17
+ "README.md",
18
+ "package.json",
19
+ "stack.json"
20
+ ],
21
+ "publishConfig": {
22
+ "access": "public"
23
+ },
24
+ "stack": {
25
+ "kind": "plugin",
26
+ "id": "stack.tweaks.keybinds"
27
+ },
28
+ "scripts": {
29
+ "build": "tsc -p tsconfig.json",
30
+ "typecheck": "tsc -p tsconfig.json --noEmit",
31
+ "test": "node check-plugin.mjs"
32
+ },
33
+ "peerDependencies": {
34
+ "@deepseek-ai/cordis": "^4.0.1",
35
+ "@deepseek-ai/schemastery": "*",
36
+ "@deepseek-ai/dsh-settings": "0.2.0-rc.2"
37
+ },
38
+ "dependencies": {
39
+ "@dsh-stack/plugin-kit": "0.1.0"
40
+ },
41
+ "devDependencies": {
42
+ "typescript": "^6.0.3",
43
+ "@deepseek-ai/cordis": "^4.0.1",
44
+ "@deepseek-ai/schemastery": "*",
45
+ "@deepseek-ai/dsh-settings": "0.2.0-rc.2"
46
+ },
47
+ "repository": {
48
+ "type": "git",
49
+ "url": "https://github.com/marius-patrik/dsh-stack.git",
50
+ "directory": "plugins/tweak-keybinds"
51
+ }
52
+ }
package/stack.json ADDED
@@ -0,0 +1,10 @@
1
+ {
2
+ "id": "stack.tweaks.keybinds",
3
+ "name": "@dsh-stack/tweak-keybinds",
4
+ "version": "0.1.0",
5
+ "kind": "plugin",
6
+ "description": "Keybind settings surface: the tweaks-keybinds section schema and validation consumed by the client.",
7
+ "files": ["lib", "README.md", "package.json", "stack.json"],
8
+ "dependencies": ["stack.library.plugin-kit"],
9
+ "optionalDependencies": []
10
+ }