@brimveyn/aimux-config 0.2.6 → 0.3.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 +7 -1
- package/package.json +1 -1
- package/src/actions.ts +5 -0
- package/src/defaults.ts +17 -0
- package/src/keymap-builder.ts +28 -2
- package/src/resolver.ts +1 -0
- package/src/types.ts +26 -1
package/README.md
CHANGED
|
@@ -77,7 +77,13 @@ defineConfig({
|
|
|
77
77
|
```ts
|
|
78
78
|
k.leader(keys) // default: '<Space>'
|
|
79
79
|
.timeout(ms) // default: 300
|
|
80
|
-
.mode(id, configure) // define bindings for a mode
|
|
80
|
+
.mode(id | ids[], configure) // define bindings for a mode (or several at once)
|
|
81
|
+
```
|
|
82
|
+
|
|
83
|
+
Pass an array of `ModeId`s to register the same bindings in every listed mode — handy for actions that should fire in both `navigation` and `terminal-input`, for example:
|
|
84
|
+
|
|
85
|
+
```ts
|
|
86
|
+
k.mode(['navigation', 'terminal-input'], (m) => m.map('<C-s>', actions.snippetPicker))
|
|
81
87
|
```
|
|
82
88
|
|
|
83
89
|
### Mode builder
|
package/package.json
CHANGED
package/src/actions.ts
CHANGED
|
@@ -36,8 +36,13 @@ export const helpModal: KeyResult = r([{ type: 'open-help-modal' }], [], 'modal.
|
|
|
36
36
|
|
|
37
37
|
export const toggleSidebar: KeyResult = r([{ type: 'toggle-sidebar' }])
|
|
38
38
|
export const toggleGitPanel: KeyResult = r([{ type: 'toggle-git-panel' }])
|
|
39
|
+
export const toggleSessionBar: KeyResult = r([{ type: 'toggle-session-bar' }])
|
|
39
40
|
export const enterGitMode: KeyResult = r([{ type: 'enter-git-mode' }], [], 'git-mode')
|
|
40
41
|
|
|
42
|
+
export function switchSessionByIndex(index: number): KeyResult {
|
|
43
|
+
return r([], [{ index, type: 'switch-session-by-index' }])
|
|
44
|
+
}
|
|
45
|
+
|
|
41
46
|
export const splitVertical: KeyResult = r(
|
|
42
47
|
[{ direction: 'vertical', type: 'open-split-picker' }],
|
|
43
48
|
[],
|
package/src/defaults.ts
CHANGED
|
@@ -50,6 +50,23 @@ export function getDefaultKeymapConfig(): ResolvedKeymapConfig {
|
|
|
50
50
|
.map('<C-b>', actions.toggleSidebarFromInput, 'Toggle sidebar')
|
|
51
51
|
)
|
|
52
52
|
|
|
53
|
+
// -----------------------------------------------------------------------
|
|
54
|
+
// Session bar: same chords from nav and while typing in the terminal
|
|
55
|
+
// -----------------------------------------------------------------------
|
|
56
|
+
.mode(['navigation', 'terminal-input'], (m) =>
|
|
57
|
+
m
|
|
58
|
+
.map('<Leader>b', actions.toggleSessionBar, 'Toggle session bar')
|
|
59
|
+
.map('<Leader>1', actions.switchSessionByIndex(1), 'Session 1')
|
|
60
|
+
.map('<Leader>2', actions.switchSessionByIndex(2), 'Session 2')
|
|
61
|
+
.map('<Leader>3', actions.switchSessionByIndex(3), 'Session 3')
|
|
62
|
+
.map('<Leader>4', actions.switchSessionByIndex(4), 'Session 4')
|
|
63
|
+
.map('<Leader>5', actions.switchSessionByIndex(5), 'Session 5')
|
|
64
|
+
.map('<Leader>6', actions.switchSessionByIndex(6), 'Session 6')
|
|
65
|
+
.map('<Leader>7', actions.switchSessionByIndex(7), 'Session 7')
|
|
66
|
+
.map('<Leader>8', actions.switchSessionByIndex(8), 'Session 8')
|
|
67
|
+
.map('<Leader>9', actions.switchSessionByIndex(9), 'Session 9')
|
|
68
|
+
)
|
|
69
|
+
|
|
53
70
|
// -----------------------------------------------------------------------
|
|
54
71
|
// Layout mode
|
|
55
72
|
// -----------------------------------------------------------------------
|
package/src/keymap-builder.ts
CHANGED
|
@@ -99,10 +99,36 @@ export class KeymapBuilder implements KeymapBuilderApi {
|
|
|
99
99
|
return this
|
|
100
100
|
}
|
|
101
101
|
|
|
102
|
-
mode(
|
|
102
|
+
mode(
|
|
103
|
+
id: ModeId | readonly ModeId[],
|
|
104
|
+
configure: (m: ModeBindingBuilderApi) => ModeBindingBuilderApi
|
|
105
|
+
): this {
|
|
103
106
|
const builder = new ModeBindingBuilder()
|
|
104
107
|
configure(builder)
|
|
105
|
-
|
|
108
|
+
const incoming = builder._build()
|
|
109
|
+
const ids = Array.isArray(id) ? id : [id]
|
|
110
|
+
for (const modeId of ids) {
|
|
111
|
+
const existing = this.modes.get(modeId)
|
|
112
|
+
if (!existing) {
|
|
113
|
+
// Fresh mode: clone so later merges don't mutate a shared array.
|
|
114
|
+
this.modes.set(modeId, {
|
|
115
|
+
bindings: [...incoming.bindings],
|
|
116
|
+
isPassthrough: incoming.isPassthrough,
|
|
117
|
+
removals: [...incoming.removals],
|
|
118
|
+
})
|
|
119
|
+
continue
|
|
120
|
+
}
|
|
121
|
+
// Merge: later bindings win over earlier ones sharing the same keys.
|
|
122
|
+
const incomingKeys = new Set(incoming.bindings.map((b) => b.keys))
|
|
123
|
+
this.modes.set(modeId, {
|
|
124
|
+
bindings: [
|
|
125
|
+
...existing.bindings.filter((b) => !incomingKeys.has(b.keys)),
|
|
126
|
+
...incoming.bindings,
|
|
127
|
+
],
|
|
128
|
+
isPassthrough: existing.isPassthrough || incoming.isPassthrough,
|
|
129
|
+
removals: [...existing.removals, ...incoming.removals],
|
|
130
|
+
})
|
|
131
|
+
}
|
|
106
132
|
return this
|
|
107
133
|
}
|
|
108
134
|
|
package/src/resolver.ts
CHANGED
|
@@ -20,6 +20,7 @@ export function resolveConfig(userConfig: AimuxUserConfig): ResolvedConfig {
|
|
|
20
20
|
backends: userConfig.backends ?? {},
|
|
21
21
|
hooks: userConfig.hooks ?? {},
|
|
22
22
|
keymaps,
|
|
23
|
+
sessionBar: userConfig.sessionBar ?? {},
|
|
23
24
|
sidebar: userConfig.sidebar ?? {},
|
|
24
25
|
snippets: userConfig.snippets ?? [],
|
|
25
26
|
theme: userConfig.theme,
|
package/src/types.ts
CHANGED
|
@@ -125,6 +125,7 @@ export interface SessionRecord {
|
|
|
125
125
|
createdAt: string
|
|
126
126
|
updatedAt: string
|
|
127
127
|
lastOpenedAt: string
|
|
128
|
+
order?: number
|
|
128
129
|
workspaceSnapshot?: WorkspaceSnapshotV1
|
|
129
130
|
}
|
|
130
131
|
|
|
@@ -290,6 +291,13 @@ export interface LayoutState {
|
|
|
290
291
|
terminalRows: number
|
|
291
292
|
}
|
|
292
293
|
|
|
294
|
+
export type SessionBarPosition = 'top' | 'bottom'
|
|
295
|
+
|
|
296
|
+
export interface SessionBarState {
|
|
297
|
+
visible: boolean
|
|
298
|
+
position: SessionBarPosition
|
|
299
|
+
}
|
|
300
|
+
|
|
293
301
|
export interface AppState {
|
|
294
302
|
tabs: TabSession[]
|
|
295
303
|
activeTabId: string | null
|
|
@@ -297,6 +305,8 @@ export interface AppState {
|
|
|
297
305
|
tabGroupMap: Record<string, string>
|
|
298
306
|
sessions: SessionRecord[]
|
|
299
307
|
currentSessionId: string | null
|
|
308
|
+
sessionsBusy: Record<string, boolean>
|
|
309
|
+
sessionBar: SessionBarState
|
|
300
310
|
snippets: SnippetRecord[]
|
|
301
311
|
focusMode: FocusMode
|
|
302
312
|
sidebar: SidebarState
|
|
@@ -340,6 +350,8 @@ export type SessionAction =
|
|
|
340
350
|
| { type: 'create-session-record'; session: SessionRecord }
|
|
341
351
|
| { type: 'rename-session-record'; sessionId: string; name: string }
|
|
342
352
|
| { type: 'delete-session-record'; sessionId: string }
|
|
353
|
+
| { type: 'reorder-sessions'; orderedIds: string[] }
|
|
354
|
+
| { type: 'set-session-busy'; sessionId: string; busy: boolean }
|
|
343
355
|
|
|
344
356
|
export type TabAction =
|
|
345
357
|
| { type: 'add-tab'; tab: TabSession }
|
|
@@ -401,6 +413,8 @@ export type UIAction =
|
|
|
401
413
|
| { type: 'toggle-git-panel' }
|
|
402
414
|
| { type: 'resize-git-panel'; delta: number }
|
|
403
415
|
| { type: 'set-pending-chords'; chords: string[] | null }
|
|
416
|
+
| { type: 'toggle-session-bar' }
|
|
417
|
+
| { type: 'set-session-bar-position'; position: SessionBarPosition }
|
|
404
418
|
|
|
405
419
|
export interface GitRefreshPayload {
|
|
406
420
|
branch: string | null
|
|
@@ -477,6 +491,7 @@ export type SideEffect =
|
|
|
477
491
|
| { type: 'git-commit'; title: string; body: string }
|
|
478
492
|
| { type: 'git-push' }
|
|
479
493
|
| { type: 'confirm-update-selection' }
|
|
494
|
+
| { type: 'switch-session-by-index'; index: number }
|
|
480
495
|
|
|
481
496
|
// ─── Key input / KeyResult / ModeContext ──────────────────────────────────────
|
|
482
497
|
|
|
@@ -595,16 +610,25 @@ export interface ModeBindingBuilderApi {
|
|
|
595
610
|
export interface KeymapBuilderApi {
|
|
596
611
|
leader(key: string): KeymapBuilderApi
|
|
597
612
|
timeout(ms: number): KeymapBuilderApi
|
|
598
|
-
mode(
|
|
613
|
+
mode(
|
|
614
|
+
id: ModeId | readonly ModeId[],
|
|
615
|
+
configure: (m: ModeBindingBuilderApi) => ModeBindingBuilderApi
|
|
616
|
+
): KeymapBuilderApi
|
|
599
617
|
}
|
|
600
618
|
|
|
601
619
|
// ─── Top-level user config ────────────────────────────────────────────────────
|
|
602
620
|
|
|
621
|
+
export interface SessionBarConfig {
|
|
622
|
+
visible?: boolean
|
|
623
|
+
position?: SessionBarPosition
|
|
624
|
+
}
|
|
625
|
+
|
|
603
626
|
export interface AimuxUserConfig {
|
|
604
627
|
theme?: ThemeId | ThemeDefinition
|
|
605
628
|
keymaps?: (k: KeymapBuilderApi) => KeymapBuilderApi
|
|
606
629
|
backends?: Record<string, BackendConfig>
|
|
607
630
|
sidebar?: SidebarConfig
|
|
631
|
+
sessionBar?: SessionBarConfig
|
|
608
632
|
hooks?: HooksConfig
|
|
609
633
|
snippets?: SnippetDef[]
|
|
610
634
|
}
|
|
@@ -635,6 +659,7 @@ export interface ResolvedConfig {
|
|
|
635
659
|
keymaps: ResolvedKeymapConfig
|
|
636
660
|
backends: Record<string, BackendConfig>
|
|
637
661
|
sidebar: SidebarConfig
|
|
662
|
+
sessionBar: SessionBarConfig
|
|
638
663
|
hooks: HooksConfig
|
|
639
664
|
snippets: SnippetDef[]
|
|
640
665
|
}
|