@arcforge/types 2.0.141 → 2.0.143
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/package.json +1 -1
- package/src/blueprint.ts +11 -0
- package/src/index.ts +1 -0
- package/src/kernel/abi.ts +128 -0
- package/src/kernel/index.ts +1 -1
- package/src/knowledge.ts +36 -0
- package/src/session/events/cognet.ts +16 -0
- package/src/tui-contract.ts +1 -1
- package/src/tui.ts +841 -22
package/src/tui.ts
CHANGED
|
@@ -242,7 +242,35 @@ export type PaletteApi = {
|
|
|
242
242
|
*/
|
|
243
243
|
export type CommandPath = string | readonly string[]
|
|
244
244
|
|
|
245
|
-
|
|
245
|
+
/**
|
|
246
|
+
* What a command IS — its behaviour and how it presents.
|
|
247
|
+
*
|
|
248
|
+
* ── Why a definition object rather than trailing options ────────────────────
|
|
249
|
+
*
|
|
250
|
+
* The alternative was `register(path, action, options?)`, and it loses for the
|
|
251
|
+
* same reason positional hook arguments do. A third parameter is a fixed slot:
|
|
252
|
+
* the day a command needs a fourth thing, it is either a fourth positional
|
|
253
|
+
* nobody discovers or a breaking change. And `register("x", fn, {...})` reads
|
|
254
|
+
* as a function with some settings bolted on, when the truth is that the
|
|
255
|
+
* behaviour and the presentation are one declaration.
|
|
256
|
+
*
|
|
257
|
+
* It also matches `palette.create(name, definition)`, which already takes its
|
|
258
|
+
* work verb (`list`) inside the object. Two registration APIs shaped
|
|
259
|
+
* differently is a thing to remember for no reason.
|
|
260
|
+
*
|
|
261
|
+
* The verb is `run` because that is what a command does. `action` was the
|
|
262
|
+
* internal name and it describes a slot in a data structure, not the thing a
|
|
263
|
+
* user is writing.
|
|
264
|
+
*/
|
|
265
|
+
export type CommandDefinition = {
|
|
266
|
+
/**
|
|
267
|
+
* The command's behaviour.
|
|
268
|
+
*
|
|
269
|
+
* A returned promise holds the palette in its working state until it
|
|
270
|
+
* settles. The signal aborts when the user escapes mid-flight — a command
|
|
271
|
+
* that cannot be cancelled may ignore it.
|
|
272
|
+
*/
|
|
273
|
+
run: (signal: AbortSignal) => void | Promise<void>
|
|
246
274
|
/** Shown beside the command in the palette. */
|
|
247
275
|
description?: string
|
|
248
276
|
/** Shown in the working row while an async command runs. */
|
|
@@ -253,10 +281,26 @@ export type CommandsApi = {
|
|
|
253
281
|
/**
|
|
254
282
|
* Add a command to the `:` tree.
|
|
255
283
|
*
|
|
284
|
+
* Two forms, and the short one is not a legacy shape to be migrated off:
|
|
285
|
+
*
|
|
286
|
+
* commands.register("deploy", async () => { ... })
|
|
287
|
+
* commands.register("deploy", {
|
|
288
|
+
* async run() { ... },
|
|
289
|
+
* description: "Restart and redeploy",
|
|
290
|
+
* })
|
|
291
|
+
*
|
|
292
|
+
* A command with nothing to configure is genuinely just its behaviour, and
|
|
293
|
+
* making that case carry `{ run }` would be ceremony charged to the most
|
|
294
|
+
* common thing anyone writes. The moment there IS configuration, the object
|
|
295
|
+
* form keeps it in one declaration instead of trailing off the end.
|
|
296
|
+
*
|
|
256
297
|
* Built-in commands always win a collision, and two extensions colliding is
|
|
257
298
|
* first-registered-wins with a warning naming both — never silent shadowing.
|
|
258
299
|
*/
|
|
259
|
-
register:
|
|
300
|
+
register: {
|
|
301
|
+
(path: CommandPath, run: (signal: AbortSignal) => void | Promise<void>): Disposer
|
|
302
|
+
(path: CommandPath, definition: CommandDefinition): Disposer
|
|
303
|
+
}
|
|
260
304
|
|
|
261
305
|
/**
|
|
262
306
|
* Run a command by path, exactly as pressing Enter on it would.
|
|
@@ -265,7 +309,7 @@ export type CommandsApi = {
|
|
|
265
309
|
* dedicated API — one verb instead of re-exposing every command's
|
|
266
310
|
* implementation. Throws if the path resolves to nothing.
|
|
267
311
|
*/
|
|
268
|
-
run: (path: CommandPath) => Promise<void>
|
|
312
|
+
run: (path: CommandName | CommandPath) => Promise<void>
|
|
269
313
|
|
|
270
314
|
/** Every registered command path, built-in and user. */
|
|
271
315
|
list: () => readonly string[][]
|
|
@@ -773,6 +817,444 @@ export type BundledSyntax =
|
|
|
773
817
|
/** Axon's own, and the default. */
|
|
774
818
|
| "arcnight"
|
|
775
819
|
|
|
820
|
+
// ── lines ───────────────────────────────────────────────────────────────────
|
|
821
|
+
|
|
822
|
+
/**
|
|
823
|
+
* One live value on a line — a name, when it changes, and what it says.
|
|
824
|
+
*
|
|
825
|
+
* THE TRIGGER IS DECLARED, and that is the whole design. A bare `() => string`
|
|
826
|
+
* would leave the terminal with no idea when to call it: re-running every
|
|
827
|
+
* component on every frame makes one slow component stall the paint, and the
|
|
828
|
+
* alternative — asking users to wire their own reactivity — is the thing this
|
|
829
|
+
* API exists to avoid. So a component states what wakes it and the renderer
|
|
830
|
+
* evaluates it then and never otherwise.
|
|
831
|
+
*
|
|
832
|
+
* `render` is SYNCHRONOUS by contract. A frame cannot await, and a component
|
|
833
|
+
* that needs real work (a git branch, a network call) does that work in its
|
|
834
|
+
* trigger and returns the cached value here — the same discipline lualine
|
|
835
|
+
* settles on, arrived at from the render loop rather than from convention.
|
|
836
|
+
*
|
|
837
|
+
* A component with neither `on` nor `every` renders once and stays put, which
|
|
838
|
+
* is the right shape for something static.
|
|
839
|
+
*/
|
|
840
|
+
export type LineComponent = {
|
|
841
|
+
/**
|
|
842
|
+
* A glyph shown before the value — a NAME from the catalogue, or a literal.
|
|
843
|
+
*
|
|
844
|
+
* A NAME resolves through the active icon set, so one setting swaps every
|
|
845
|
+
* icon at once — which is what makes a shared component work on a machine
|
|
846
|
+
* without a patched font. A literal glyph is the escape hatch for
|
|
847
|
+
* something the catalogue does not name, and it does NOT respond to the
|
|
848
|
+
* setting: an author writing a raw character has said they know what
|
|
849
|
+
* appears.
|
|
850
|
+
*
|
|
851
|
+
* The author's, not the config's — an icon is part of what a component
|
|
852
|
+
* MEANS (a git component without its branch glyph is a worse git
|
|
853
|
+
* component), where colour is part of how a LINE looks and belongs to
|
|
854
|
+
* whoever composes the row.
|
|
855
|
+
*
|
|
856
|
+
* Rendered only when the component has something to say: an icon beside an
|
|
857
|
+
* empty value is a glyph floating on its own.
|
|
858
|
+
*/
|
|
859
|
+
icon?: IconName | (string & {})
|
|
860
|
+
/**
|
|
861
|
+
* Hook events that change this value — the same names `tui.hook` takes.
|
|
862
|
+
*
|
|
863
|
+
* Reusing that vocabulary is deliberate: the terminal already emits a
|
|
864
|
+
* precise event for everything it does, so a component author picks from a
|
|
865
|
+
* list they have already learned rather than inventing a subscription.
|
|
866
|
+
*/
|
|
867
|
+
on?: readonly TuiHookName[]
|
|
868
|
+
/**
|
|
869
|
+
* Re-render every N milliseconds — for values that change with time rather
|
|
870
|
+
* than with anything the terminal does. A clock is the case; there is no
|
|
871
|
+
* event for "a second passed".
|
|
872
|
+
*
|
|
873
|
+
* Taken as written, with no floor. Painting a string is cheap and the
|
|
874
|
+
* renderer diffs frames for exactly this; a component doing heavy work on
|
|
875
|
+
* a fast interval is the author's call, the same as a slow hook handler.
|
|
876
|
+
*/
|
|
877
|
+
every?: number
|
|
878
|
+
/**
|
|
879
|
+
* Run when the user clicks this component.
|
|
880
|
+
*
|
|
881
|
+
* Named for what the AUTHOR does, not for the event vterm dispatches
|
|
882
|
+
* (`@press`). A config says "when this is clicked"; the transport's name
|
|
883
|
+
* for that is an implementation detail of the layer below.
|
|
884
|
+
*
|
|
885
|
+
* What turns a status line into a control surface: a row of agent names
|
|
886
|
+
* becomes a nav bar, a branch indicator becomes a branch picker. Without
|
|
887
|
+
* it a line can only report, and reporting is the smaller half of what a
|
|
888
|
+
* bar sitting in front of you all day could do.
|
|
889
|
+
*
|
|
890
|
+
* Unawaited by the terminal — a handler that takes a second must not hold
|
|
891
|
+
* the frame — and a failure is reported like any other config fault rather
|
|
892
|
+
* than surfacing as a click that silently did nothing.
|
|
893
|
+
*/
|
|
894
|
+
click?: () => void | Promise<void>
|
|
895
|
+
/**
|
|
896
|
+
* What to show, coerced to text.
|
|
897
|
+
*
|
|
898
|
+
* Primitives only, deliberately. `string` alone forced `String(count)` on
|
|
899
|
+
* the most ordinary component there is; `unknown` would accept an object,
|
|
900
|
+
* an array or a promise and render `[object Object]` silently — and an
|
|
901
|
+
* author who slipped an `async` onto this would get `[object Promise]` on
|
|
902
|
+
* their line with nothing to explain it. Widening removes ceremony, not
|
|
903
|
+
* the errors the type was catching.
|
|
904
|
+
*
|
|
905
|
+
* `null`/`undefined` are the honest way to say "nothing right now", and
|
|
906
|
+
* render as empty rather than as the text "null".
|
|
907
|
+
*/
|
|
908
|
+
render: () => string | number | null | undefined
|
|
909
|
+
}
|
|
910
|
+
|
|
911
|
+
/**
|
|
912
|
+
* A line's content — up to three slots, laid out by the terminal.
|
|
913
|
+
*
|
|
914
|
+
* Axon owns spacing, separators, truncation and colour; a config supplies text
|
|
915
|
+
* and its order. That split is the product decision: every layout knob is a
|
|
916
|
+
* way for two configs to disagree, and the failure mode it prevents is a
|
|
917
|
+
* handful of beautiful setups surrounded by mediocre ones. Users theme,
|
|
918
|
+
* Axon lays out.
|
|
919
|
+
*
|
|
920
|
+
* `left` and `right` push apart. `middle` centres on the LINE, not on the gap
|
|
921
|
+
* between the sides, and truncates when there is no room — one rule, so a
|
|
922
|
+
* three-slot line never needs a negotiation nobody can predict.
|
|
923
|
+
*/
|
|
924
|
+
export type LineContent = {
|
|
925
|
+
left?: LineSlot
|
|
926
|
+
middle?: LineSlot
|
|
927
|
+
right?: LineSlot
|
|
928
|
+
/**
|
|
929
|
+
* The style this line was DESIGNED for — a default, not a decree.
|
|
930
|
+
*
|
|
931
|
+
* An author knows what their line is meant to look like, so declaring it
|
|
932
|
+
* here means a shared line arrives looking right with no configuration.
|
|
933
|
+
* But the placement wins: a user who wants it plain says so in
|
|
934
|
+
* `lines.set()` and never has to fork the line to restyle it.
|
|
935
|
+
*
|
|
936
|
+
* Precedence, narrowest first: placement → this → `lines.style()`.
|
|
937
|
+
*/
|
|
938
|
+
style?: LineStyle
|
|
939
|
+
}
|
|
940
|
+
|
|
941
|
+
/**
|
|
942
|
+
* One slot's contents: a flat list of components, or a list of SECTIONS.
|
|
943
|
+
*
|
|
944
|
+
* A section is the unit a separator divides and a background fills — which is
|
|
945
|
+
* why the nesting exists at all. Inside one section every component shares a
|
|
946
|
+
* ground, so the divider between them is a hairline; between sections the
|
|
947
|
+
* ground changes, so the divider is a filled arrow. That is the whole
|
|
948
|
+
* distinction lualine draws with `component_separators` and
|
|
949
|
+
* `section_separators`, and it cannot be expressed on a flat list.
|
|
950
|
+
*
|
|
951
|
+
* A flat array is one section. Nothing already written changes meaning.
|
|
952
|
+
*/
|
|
953
|
+
export type LineSlot = readonly ComponentName[] | readonly (readonly ComponentName[])[]
|
|
954
|
+
|
|
955
|
+
/**
|
|
956
|
+
* A component's name — the catalogue Axon ships, or one you registered.
|
|
957
|
+
*
|
|
958
|
+
* The built-ins are enumerated so an editor completes them and a typo is a
|
|
959
|
+
* compile error rather than a gap you find on screen. `(string & {})` keeps
|
|
960
|
+
* that completion while still accepting names this union cannot know: a
|
|
961
|
+
* component from an extension, or one the same config declared a few lines up.
|
|
962
|
+
*
|
|
963
|
+
* The same shape `ThemeColor` uses, for the same reason — a closed union would
|
|
964
|
+
* make the escape hatch impossible, and an open `string` would make the
|
|
965
|
+
* catalogue undiscoverable.
|
|
966
|
+
*/
|
|
967
|
+
export type ComponentName = RegistryName<AxonComponentRegistry>
|
|
968
|
+
|
|
969
|
+
/**
|
|
970
|
+
* A generated registry's names — CLOSED once the registry has entries.
|
|
971
|
+
*
|
|
972
|
+
* ── Why this is not simply `keyof R | (string & {})` ────────────────────────
|
|
973
|
+
*
|
|
974
|
+
* That shape gives completion but never rejects anything: the open arm accepts
|
|
975
|
+
* every string, so a typo typechecks and only fails at runtime — which is the
|
|
976
|
+
* bug the generator exists to remove.
|
|
977
|
+
*
|
|
978
|
+
* An empty registry still has to accept anything, though. A profile before its
|
|
979
|
+
* first `axon prepare` has no generated file, and every name in it would be an
|
|
980
|
+
* error against a `never` union — a config that was fine yesterday would light
|
|
981
|
+
* up red because a build step had not run yet.
|
|
982
|
+
*
|
|
983
|
+
* So the union closes only when it has something to close AROUND: empty means
|
|
984
|
+
* open, populated means exact. A name the generator genuinely cannot see (one
|
|
985
|
+
* computed at runtime) is cast at the call site, which is the honest signal
|
|
986
|
+
* that it is unverifiable rather than a hole left open for every name.
|
|
987
|
+
*/
|
|
988
|
+
export type RegistryName<R> = keyof R extends never ? string : keyof R & string
|
|
989
|
+
|
|
990
|
+
/**
|
|
991
|
+
* Every line name known at generation time.
|
|
992
|
+
*
|
|
993
|
+
* Same mechanism as AxonComponentRegistry — see that interface for why these
|
|
994
|
+
* are generated rather than written by hand.
|
|
995
|
+
*/
|
|
996
|
+
export type LineName = RegistryName<AxonLineRegistry>
|
|
997
|
+
|
|
998
|
+
/**
|
|
999
|
+
* Every palette name known at generation time.
|
|
1000
|
+
*/
|
|
1001
|
+
export type PaletteName = RegistryName<AxonPaletteRegistry>
|
|
1002
|
+
|
|
1003
|
+
/**
|
|
1004
|
+
* Every command path known at generation time, space-joined.
|
|
1005
|
+
*/
|
|
1006
|
+
export type CommandName = RegistryName<AxonCommandRegistry>
|
|
1007
|
+
|
|
1008
|
+
/**
|
|
1009
|
+
* The registries `axon prepare` fills in.
|
|
1010
|
+
*
|
|
1011
|
+
* ── Generated, not hand-written ─────────────────────────────────────────────
|
|
1012
|
+
*
|
|
1013
|
+
* These were a hand-maintained union of the built-in names, which drifted the
|
|
1014
|
+
* first time someone added a component and forgot to update it. The generator
|
|
1015
|
+
* reads the actual catalogue AND every config's own `create` calls, so what an
|
|
1016
|
+
* editor completes is what is really registered — including the component you
|
|
1017
|
+
* declared four lines above the line using it.
|
|
1018
|
+
*
|
|
1019
|
+
* ── Why an interface rather than a type alias ───────────────────────────────
|
|
1020
|
+
*
|
|
1021
|
+
* Declaration merging. A generated `.d.ts` reopens the interface and adds its
|
|
1022
|
+
* keys, which means built-ins, extension contributions and a user's own
|
|
1023
|
+
* registrations all land in one union with no privileged tier. An alias could
|
|
1024
|
+
* only be replaced, not extended, so every source would need its own name and
|
|
1025
|
+
* the consumer would have to union them by hand.
|
|
1026
|
+
*
|
|
1027
|
+
* Empty here by design: a profile with no generated types still typechecks,
|
|
1028
|
+
* because every consuming alias keeps a `(string & {})` arm.
|
|
1029
|
+
*/
|
|
1030
|
+
// eslint-disable-next-line @typescript-eslint/no-empty-object-type
|
|
1031
|
+
export interface AxonComponentRegistry {}
|
|
1032
|
+
// eslint-disable-next-line @typescript-eslint/no-empty-object-type
|
|
1033
|
+
export interface AxonLineRegistry {}
|
|
1034
|
+
// eslint-disable-next-line @typescript-eslint/no-empty-object-type
|
|
1035
|
+
export interface AxonPaletteRegistry {}
|
|
1036
|
+
// eslint-disable-next-line @typescript-eslint/no-empty-object-type
|
|
1037
|
+
export interface AxonCommandRegistry {}
|
|
1038
|
+
|
|
1039
|
+
/**
|
|
1040
|
+
* How a line draws its separators and shades its sections.
|
|
1041
|
+
*
|
|
1042
|
+
* A preset, never individual glyphs. Axon owning the glyph set is the line
|
|
1043
|
+
* between "every config looks like Axon" and "everyone invents their own bar"
|
|
1044
|
+
* — and a config that picked its own would be choosing a look that has to hold
|
|
1045
|
+
* against every theme, which is not a decision anyone should have to make
|
|
1046
|
+
* per row.
|
|
1047
|
+
*
|
|
1048
|
+
* Backgrounds step from the EDGE INWARD: the outermost section takes the
|
|
1049
|
+
* accent, each step inward is softer, and the innermost sits on the terminal's
|
|
1050
|
+
* own ground. Position in the array is the section, so there is no background
|
|
1051
|
+
* to configure — which is what stops two configs disagreeing about what a
|
|
1052
|
+
* status bar looks like.
|
|
1053
|
+
*/
|
|
1054
|
+
export type LineStyle =
|
|
1055
|
+
/** No glyphs. Components separated by spacing alone — the default. */
|
|
1056
|
+
| "plain"
|
|
1057
|
+
/** Filled arrows between sections, hairlines within. Needs a Nerd Font. */
|
|
1058
|
+
| "powerline"
|
|
1059
|
+
/** The same, with round caps. Needs a Nerd Font. */
|
|
1060
|
+
| "rounded"
|
|
1061
|
+
/**
|
|
1062
|
+
* Square edges: a flat boundary between fills and a vertical bar within.
|
|
1063
|
+
*
|
|
1064
|
+
* The same section model as `powerline`, without the arrow's implied
|
|
1065
|
+
* direction — which reads as calmer beside a busy conversation, and is
|
|
1066
|
+
* what you want when the bar should sit still rather than point at
|
|
1067
|
+
* something. Needs a Nerd Font.
|
|
1068
|
+
*/
|
|
1069
|
+
| "block"
|
|
1070
|
+
/** A thin middle dot between components, no section fills. */
|
|
1071
|
+
| "minimal"
|
|
1072
|
+
|
|
1073
|
+
/**
|
|
1074
|
+
* A line's definition: the full three-slot form, or a bare array.
|
|
1075
|
+
*
|
|
1076
|
+
* The array means LEFT, always — never auto-distributed. Both built-in lines
|
|
1077
|
+
* are left-aligned, so it is the common case worth a shorthand, and a rule
|
|
1078
|
+
* that reads the same every time beats one that guesses.
|
|
1079
|
+
*/
|
|
1080
|
+
export type LineDefinition = LineContent | readonly string[]
|
|
1081
|
+
|
|
1082
|
+
/**
|
|
1083
|
+
* One entry in the stack: a name, or a name with placement overrides.
|
|
1084
|
+
*
|
|
1085
|
+
* The bare string is the common case and stays the common case — an object is
|
|
1086
|
+
* only needed when this particular placement differs from what the line
|
|
1087
|
+
* declared.
|
|
1088
|
+
*/
|
|
1089
|
+
export type LineEntry = LineName | LinePlacement
|
|
1090
|
+
|
|
1091
|
+
/**
|
|
1092
|
+
* How ONE line is placed in ONE stack.
|
|
1093
|
+
*
|
|
1094
|
+
* ── Why placement owns style ────────────────────────────────────────────────
|
|
1095
|
+
*
|
|
1096
|
+
* Three layers, three owners: a COMPONENT is what the data is (an extension
|
|
1097
|
+
* author's), a LINE is what sits where (shared or personal), and a PLACEMENT
|
|
1098
|
+
* is how it looks in this stack (always the user's).
|
|
1099
|
+
*
|
|
1100
|
+
* Style began on the line and that was the wrong layer. A shared line would
|
|
1101
|
+
* ship with its look baked in, so anyone installing `@cody/git-line` had to
|
|
1102
|
+
* fork it to restyle — which is the coupling that stops a registry being
|
|
1103
|
+
* worth having. A line may still declare a default, because an author knows
|
|
1104
|
+
* what their line was designed to look like; the placement wins when it says
|
|
1105
|
+
* otherwise.
|
|
1106
|
+
*
|
|
1107
|
+
* Precedence, narrowest first: this placement → the line's own default →
|
|
1108
|
+
* `lines.style()`.
|
|
1109
|
+
*/
|
|
1110
|
+
export type LinePlacement = {
|
|
1111
|
+
/** The registered line this entry places. */
|
|
1112
|
+
line: LineName
|
|
1113
|
+
/** How it draws here, overriding the line's default and the stack's. */
|
|
1114
|
+
style?: LineStyle
|
|
1115
|
+
/**
|
|
1116
|
+
* Start hidden, keeping its place in the stack.
|
|
1117
|
+
*
|
|
1118
|
+
* Declared here rather than left to a `hide()` call afterwards, so the
|
|
1119
|
+
* stack is one description instead of a description plus a sequence of
|
|
1120
|
+
* mutations. `toggle()` still flips it at runtime.
|
|
1121
|
+
*/
|
|
1122
|
+
hidden?: boolean
|
|
1123
|
+
}
|
|
1124
|
+
|
|
1125
|
+
/**
|
|
1126
|
+
* Where a line moves to. `"up"`/`"down"` are relative; a number is an absolute
|
|
1127
|
+
* index in the stack, clamped rather than throwing — a keybind that walks a
|
|
1128
|
+
* line to the top should stop there, not fail on the last press.
|
|
1129
|
+
*/
|
|
1130
|
+
export type LinePosition = "up" | "down" | number
|
|
1131
|
+
|
|
1132
|
+
/** A registered line, as `lines.list()` reports it. */
|
|
1133
|
+
export type Line = {
|
|
1134
|
+
/**
|
|
1135
|
+
* Unique within the stack — the name is NOT an identity, since a line may
|
|
1136
|
+
* be placed more than once (comparing two styles side by side is a real
|
|
1137
|
+
* thing to want).
|
|
1138
|
+
*/
|
|
1139
|
+
id: string
|
|
1140
|
+
name: string
|
|
1141
|
+
content: LineContent
|
|
1142
|
+
/** How it draws. Falls back to the stack default when the line declared none. */
|
|
1143
|
+
style: LineStyle
|
|
1144
|
+
/** False when hidden. A hidden line keeps its place in the stack. */
|
|
1145
|
+
visible: boolean
|
|
1146
|
+
}
|
|
1147
|
+
|
|
1148
|
+
/**
|
|
1149
|
+
* Components — the live values a line can show.
|
|
1150
|
+
*
|
|
1151
|
+
* Axon ships a catalogue under the `axon:` prefix (`axon:token/counter` and
|
|
1152
|
+
* friends), and anything else registers here. The two are the same kind of
|
|
1153
|
+
* thing: a built-in is a component the terminal registered against its own
|
|
1154
|
+
* hooks, with no privilege a user's cannot have.
|
|
1155
|
+
*
|
|
1156
|
+
* Names are `provider:name` rather than a package specifier. A package ships
|
|
1157
|
+
* many things; a component comes from one provider — conflating the two would
|
|
1158
|
+
* make every component name read like an import path.
|
|
1159
|
+
*/
|
|
1160
|
+
export type ComponentsApi = {
|
|
1161
|
+
/**
|
|
1162
|
+
* Register a component. Throws if the name is taken. Returns a disposer.
|
|
1163
|
+
*
|
|
1164
|
+
* A `render` that throws costs that component and nothing else: it renders
|
|
1165
|
+
* empty and the fault is reported, the same containment the config loader
|
|
1166
|
+
* applies per file. One bad value must not take down the line around it.
|
|
1167
|
+
*/
|
|
1168
|
+
create: (name: string, component: LineComponent) => Disposer
|
|
1169
|
+
|
|
1170
|
+
/** Every registered component name, built-ins included. */
|
|
1171
|
+
list: () => readonly string[]
|
|
1172
|
+
}
|
|
1173
|
+
|
|
1174
|
+
/**
|
|
1175
|
+
* Lines — the configurable rows above the input bar.
|
|
1176
|
+
*
|
|
1177
|
+
* The terminal ships two of its own and they stay its: the cwd/token row and
|
|
1178
|
+
* the voice row. A user's lines sit between them, which is the one layout
|
|
1179
|
+
* decision Axon does not delegate — the rows that must always be readable are
|
|
1180
|
+
* not ones a config can push off screen.
|
|
1181
|
+
*
|
|
1182
|
+
* Registration and placement are SEPARATE VERBS, and that is what makes the
|
|
1183
|
+
* surface extensible: an extension `create`s lines without deciding where they
|
|
1184
|
+
* go, and the user `set`s the stack without knowing who authored what.
|
|
1185
|
+
*/
|
|
1186
|
+
export type LinesApi = {
|
|
1187
|
+
/**
|
|
1188
|
+
* Register a line. Throws if the name is taken, or if it names a component
|
|
1189
|
+
* that does not exist — a config error the loader can contain, reported
|
|
1190
|
+
* where it can be fixed rather than rendered as a blank row.
|
|
1191
|
+
*/
|
|
1192
|
+
create: (name: string, definition: LineDefinition) => Disposer
|
|
1193
|
+
|
|
1194
|
+
/**
|
|
1195
|
+
* The default style for every line that does not declare one.
|
|
1196
|
+
*
|
|
1197
|
+
* A stack-wide setting because a bar with one powerline row among plain
|
|
1198
|
+
* ones reads as a mistake, not a choice — and because the common case is
|
|
1199
|
+
* wanting ALL of them to match. A line that genuinely differs still says so
|
|
1200
|
+
* itself, which is the rarer thing and reads as deliberate at the call site.
|
|
1201
|
+
*
|
|
1202
|
+
* Called with no argument, returns the current default.
|
|
1203
|
+
*/
|
|
1204
|
+
style: {
|
|
1205
|
+
(style: LineStyle): void
|
|
1206
|
+
(): LineStyle
|
|
1207
|
+
}
|
|
1208
|
+
|
|
1209
|
+
/**
|
|
1210
|
+
* The single line ABOVE the conversation, or null to clear it.
|
|
1211
|
+
*
|
|
1212
|
+
* One line, not a stack. The room above the conversation is scarce in a
|
|
1213
|
+
* way the room below it is not — the bottom already holds the input bar
|
|
1214
|
+
* and its own rows, so a stack there is bounded by something. A second
|
|
1215
|
+
* unbounded stack at the top could push the conversation off screen, and
|
|
1216
|
+
* the constraint costs nothing: nobody has wanted two.
|
|
1217
|
+
*
|
|
1218
|
+
* Takes the same placement object as `set`, so a top line styles itself
|
|
1219
|
+
* the same way any other does.
|
|
1220
|
+
*/
|
|
1221
|
+
top: {
|
|
1222
|
+
/** Set it by name, with placement options. */
|
|
1223
|
+
(name: LineName, options?: Omit<LinePlacement, "line">): void
|
|
1224
|
+
/** Set it from a placement object, or clear it with null. */
|
|
1225
|
+
(entry: LineEntry | null): void
|
|
1226
|
+
/** Read what is currently set. */
|
|
1227
|
+
(): Line | null
|
|
1228
|
+
}
|
|
1229
|
+
|
|
1230
|
+
/**
|
|
1231
|
+
* Set the whole stack, top to bottom. Declarative and idempotent: this is
|
|
1232
|
+
* the one place order lives, so reordering is calling it again.
|
|
1233
|
+
*
|
|
1234
|
+
* An entry is a bare name, or an object when this placement differs from
|
|
1235
|
+
* the line's own defaults — see LinePlacement. Registered lines left out
|
|
1236
|
+
* of the array are not shown; an unknown name is reported.
|
|
1237
|
+
*/
|
|
1238
|
+
set: (entries: readonly LineEntry[]) => void
|
|
1239
|
+
|
|
1240
|
+
/**
|
|
1241
|
+
* Move one line within the stack. Addressed by NAME, never by index —
|
|
1242
|
+
* an index shifts when anything above it moves, so a keybind written today
|
|
1243
|
+
* would quietly mean something else tomorrow.
|
|
1244
|
+
*/
|
|
1245
|
+
move: (name: string, position: LinePosition) => void
|
|
1246
|
+
|
|
1247
|
+
/** Hide a line. It keeps its place, so showing it again returns it there. */
|
|
1248
|
+
hide: (name: string) => void
|
|
1249
|
+
/** Show a hidden line, back where it was. */
|
|
1250
|
+
show: (name: string) => void
|
|
1251
|
+
/** Flip visibility — the verb a keybind wants. */
|
|
1252
|
+
toggle: (name: string) => void
|
|
1253
|
+
|
|
1254
|
+
/** Every registered line, in stack order. What a picker palette reads. */
|
|
1255
|
+
list: () => readonly Line[]
|
|
1256
|
+
}
|
|
1257
|
+
|
|
776
1258
|
/**
|
|
777
1259
|
* Themes — the terminal's colours, and switching between them.
|
|
778
1260
|
*
|
|
@@ -806,6 +1288,12 @@ export type ThemeApi = {
|
|
|
806
1288
|
* above. Kept deliberately thin — a verb with a natural home in `palette`,
|
|
807
1289
|
* `commands`, `keys`, `mode`, `input` or `agents` belongs there.
|
|
808
1290
|
*/
|
|
1291
|
+
/** Trailing options for `tui.info` / `warn` / `error`. */
|
|
1292
|
+
export type NoticeOptions = {
|
|
1293
|
+
/** How long the notice holds the row, in milliseconds. Clamped to a few seconds. */
|
|
1294
|
+
ms: number
|
|
1295
|
+
}
|
|
1296
|
+
|
|
809
1297
|
export type TuiApi = {
|
|
810
1298
|
/**
|
|
811
1299
|
* Go to an agent: focus the instance the user was last on, booting one if
|
|
@@ -831,7 +1319,7 @@ export type TuiApi = {
|
|
|
831
1319
|
* path.
|
|
832
1320
|
*
|
|
833
1321
|
* tui.info("deployed")
|
|
834
|
-
* tui.warn("nothing to do", 600)
|
|
1322
|
+
* tui.warn("nothing to do", { ms: 600 })
|
|
835
1323
|
* tui.error("command failed")
|
|
836
1324
|
*
|
|
837
1325
|
* ── A reaction, not a message ───────────────────────────────────────────
|
|
@@ -846,17 +1334,29 @@ export type TuiApi = {
|
|
|
846
1334
|
* here. Throw instead: it lands in the config error list on the chat page,
|
|
847
1335
|
* which is scrollable and stays put.
|
|
848
1336
|
*
|
|
849
|
-
*
|
|
850
|
-
*
|
|
1337
|
+
* Takes any number of values and joins them with a space, the way
|
|
1338
|
+
* `console.log` does — so a config building a label from several pieces
|
|
1339
|
+
* does not have to concatenate first. Non-strings are stringified;
|
|
1340
|
+
* objects and arrays go through JSON so a stray value reads as data
|
|
1341
|
+
* rather than as `[object Object]`.
|
|
1342
|
+
*
|
|
1343
|
+
* The terminal's own hints outrank all three verbs — one fired during the
|
|
851
1344
|
* ctrl+c window waits rather than displacing the exit ladder.
|
|
1345
|
+
*
|
|
1346
|
+
* Duration is a trailing `{ ms }` rather than a bare number, because
|
|
1347
|
+
* under variadic args a trailing number is DATA: `tui.info("saved", 500)`
|
|
1348
|
+
* has to mean "saved 500", not "show this for half a second".
|
|
1349
|
+
*
|
|
1350
|
+
* tui.info("[", keys.join(" "), "]")
|
|
1351
|
+
* tui.warn("nothing to do", { ms: 600 })
|
|
852
1352
|
*/
|
|
853
|
-
info: (
|
|
1353
|
+
info: (...args: unknown[]) => void
|
|
854
1354
|
|
|
855
1355
|
/** As `info`, in the warning colour. */
|
|
856
|
-
warn: (
|
|
1356
|
+
warn: (...args: unknown[]) => void
|
|
857
1357
|
|
|
858
1358
|
/** As `info`, in the error colour. For "that failed" — never for why. */
|
|
859
|
-
error: (
|
|
1359
|
+
error: (...args: unknown[]) => void
|
|
860
1360
|
|
|
861
1361
|
readonly size: TuiSize
|
|
862
1362
|
|
|
@@ -904,9 +1404,183 @@ export type TuiApi = {
|
|
|
904
1404
|
*/
|
|
905
1405
|
export type TuiGateHooks = {
|
|
906
1406
|
/** Before the TUI becomes interactive. Registration is done; the screen is not up. */
|
|
907
|
-
"tui:boot": () => void | Promise<void>
|
|
1407
|
+
"tui:boot": (payload: TuiBootPayload) => void | Promise<void>
|
|
908
1408
|
/** Before shutdown proceeds. The last point at which anything can be flushed to disk. */
|
|
909
|
-
"tui:shutdown": () => void | Promise<void>
|
|
1409
|
+
"tui:shutdown": (payload: TuiShutdownPayload) => void | Promise<void>
|
|
1410
|
+
}
|
|
1411
|
+
|
|
1412
|
+
// ── Hook payloads ────────────────────────────────────────────────────────────
|
|
1413
|
+
//
|
|
1414
|
+
// EVERY hook takes exactly one object, always — including the ones that have
|
|
1415
|
+
// nothing to say. `tui.hook(name, ({ x }) => ...)` is the shape throughout, so
|
|
1416
|
+
// a handler is written the same way whichever event it listens to, and reading
|
|
1417
|
+
// one tells you nothing about which.
|
|
1418
|
+
//
|
|
1419
|
+
// Positional arguments were the alternative and they lose on every axis that
|
|
1420
|
+
// matters here. They fix an order, so adding a field is a choice between a
|
|
1421
|
+
// trailing bag nobody discovers and a breaking change; they cannot be
|
|
1422
|
+
// destructured by name, so `(a, b)` at a call site says nothing about what a
|
|
1423
|
+
// and b are; and they make the empty case a THIRD spelling (`() => {}` beside
|
|
1424
|
+
// `(x) => {}` beside `(x, y) => {}`) for no gain. An empty object costs a
|
|
1425
|
+
// handler nothing — `() => {}` still type-checks, because a function may always
|
|
1426
|
+
// ignore parameters it was handed.
|
|
1427
|
+
//
|
|
1428
|
+
// So the rule is mechanical and has no exceptions: one payload object per hook,
|
|
1429
|
+
// named fields, and a payload type declared here even when it is empty. An
|
|
1430
|
+
// empty payload is where a field will go, and having the type already named is
|
|
1431
|
+
// what makes adding one a non-event.
|
|
1432
|
+
|
|
1433
|
+
/**
|
|
1434
|
+
* `tui:boot` — nothing yet.
|
|
1435
|
+
*
|
|
1436
|
+
* Empty rather than absent: the parameter exists so a later field arrives
|
|
1437
|
+
* without changing any handler's shape, and so boot is written exactly like
|
|
1438
|
+
* every other hook.
|
|
1439
|
+
*/
|
|
1440
|
+
export type TuiBootPayload = {}
|
|
1441
|
+
|
|
1442
|
+
/** `tui:shutdown` — nothing yet. Empty for the same reason as boot. */
|
|
1443
|
+
export type TuiShutdownPayload = {}
|
|
1444
|
+
|
|
1445
|
+
/** `tui:reloaded` — nothing yet. Empty for the same reason as boot. */
|
|
1446
|
+
export type TuiReloadedPayload = {}
|
|
1447
|
+
|
|
1448
|
+
/** `tui:resize` — the terminal's new dimensions, in cells. */
|
|
1449
|
+
export type TuiResizePayload = {
|
|
1450
|
+
/** Columns. */
|
|
1451
|
+
width: number
|
|
1452
|
+
/** Rows. */
|
|
1453
|
+
height: number
|
|
1454
|
+
}
|
|
1455
|
+
|
|
1456
|
+
/**
|
|
1457
|
+
* `tui:copy` — the text that was copied.
|
|
1458
|
+
*
|
|
1459
|
+
* The text is CARRIED rather than left for the handler to read back off the
|
|
1460
|
+
* selection: copying does not clear the selection, but nothing stops the user
|
|
1461
|
+
* (or another handler) from clearing it before this one runs, and a handler
|
|
1462
|
+
* that re-read it would then see an empty string for a copy that plainly
|
|
1463
|
+
* happened. What is passed is exactly what reached the clipboard.
|
|
1464
|
+
*
|
|
1465
|
+
* Never empty — an empty selection copies nothing and fires nothing.
|
|
1466
|
+
*/
|
|
1467
|
+
export type TuiCopyPayload = {
|
|
1468
|
+
/** The copied text, verbatim: original line breaks, no trimming. */
|
|
1469
|
+
text: string
|
|
1470
|
+
}
|
|
1471
|
+
|
|
1472
|
+
/**
|
|
1473
|
+
* `key:pressed` — one keystroke the TUI did not act on.
|
|
1474
|
+
*
|
|
1475
|
+
* `mode` rides along because "was a palette open when this fired" is the first
|
|
1476
|
+
* question a handler asks, and reading it back through `mode.get()` would race
|
|
1477
|
+
* the very transition that may have been caused by this key.
|
|
1478
|
+
*/
|
|
1479
|
+
export type KeyPressedPayload = {
|
|
1480
|
+
/**
|
|
1481
|
+
* The chord, in the spelling `keys.register()` accepts — `"a"`, `"ctrl+o"`,
|
|
1482
|
+
* `"shift+tab"`. Round-trips deliberately: a handler that decides to claim
|
|
1483
|
+
* a key can pass this string straight to `keys.register`.
|
|
1484
|
+
*/
|
|
1485
|
+
key: string
|
|
1486
|
+
/** The mode that was active when the key arrived. */
|
|
1487
|
+
mode: ModeName
|
|
1488
|
+
}
|
|
1489
|
+
|
|
1490
|
+
/** `palette:opened` / `palette:closed` — which palette. */
|
|
1491
|
+
export type PalettePayload = {
|
|
1492
|
+
/** The palette's mode name — `"command"`, `"agent"`, or a user palette's. */
|
|
1493
|
+
name: ModeName
|
|
1494
|
+
}
|
|
1495
|
+
|
|
1496
|
+
/** What one instance hook reports. */
|
|
1497
|
+
export type AgentPayload = {
|
|
1498
|
+
instance: AgentInstance
|
|
1499
|
+
}
|
|
1500
|
+
|
|
1501
|
+
/** `message:sent` — the text, and where it went. */
|
|
1502
|
+
export type MessageSentPayload = {
|
|
1503
|
+
content: string
|
|
1504
|
+
instance: AgentInstance
|
|
1505
|
+
}
|
|
1506
|
+
|
|
1507
|
+
/** `message:received` — see the hook for why there is no content. */
|
|
1508
|
+
export type MessageReceivedPayload = {
|
|
1509
|
+
instance: AgentInstance
|
|
1510
|
+
}
|
|
1511
|
+
|
|
1512
|
+
/** `mode:changed` — the transition, both ends. */
|
|
1513
|
+
export type ModeChangedPayload = {
|
|
1514
|
+
from: ModeName
|
|
1515
|
+
to: ModeName
|
|
1516
|
+
}
|
|
1517
|
+
|
|
1518
|
+
/** `command:ran` / `command:failed` — which command, and how it was reached. */
|
|
1519
|
+
export type CommandPayload = {
|
|
1520
|
+
/**
|
|
1521
|
+
* Where the command sits in the command TREE, one segment per level —
|
|
1522
|
+
* `["ext", "update"]`, `["theme", "set", "gruvbox"]`.
|
|
1523
|
+
*
|
|
1524
|
+
* An array rather than a space-joined string because the segments are what
|
|
1525
|
+
* both call sites already hold (`[...breadcrumb, node.label]` in the
|
|
1526
|
+
* palette, `toPath(path)` in `commands.run()`) and what registration,
|
|
1527
|
+
* lookup and COMMAND_NOT_FOUND all use. The string was a lossy projection
|
|
1528
|
+
* at one boundary: `split(" ")` is not its inverse once an argument
|
|
1529
|
+
* contains a space, so the commands most worth reacting to — a pasted key,
|
|
1530
|
+
* a path with spaces — were exactly the ones a handler mis-parsed.
|
|
1531
|
+
*
|
|
1532
|
+
* A list-backed group puts its chosen row here, not in `arg`: a theme name
|
|
1533
|
+
* is a NODE the palette listed, from a closed set, so `:theme set gruvbox`
|
|
1534
|
+
* is three segments. That makes every pick a distinct path, which is how a
|
|
1535
|
+
* handler knows WHICH theme — so match a namespace with `path[0]`, not a
|
|
1536
|
+
* whole-array compare.
|
|
1537
|
+
*/
|
|
1538
|
+
path: string[]
|
|
1539
|
+
|
|
1540
|
+
/**
|
|
1541
|
+
* The raw text typed after an input command, or undefined when the command
|
|
1542
|
+
* takes none — `"/some/dir"` for `:watch /some/dir`.
|
|
1543
|
+
*
|
|
1544
|
+
* Separate from `path` because it is a different KIND of thing: a segment
|
|
1545
|
+
* comes from a closed set and is matchable, an argument is arbitrary user
|
|
1546
|
+
* text. Folding it in would turn "did watch run" from an equality check
|
|
1547
|
+
* into a prefix test, and make every invocation its own path.
|
|
1548
|
+
*
|
|
1549
|
+
* ── The invariant this field rests on ───────────────────────────────────
|
|
1550
|
+
*
|
|
1551
|
+
* An input node TERMINATES traversal — `CommandInput` has no children, and
|
|
1552
|
+
* everything after it is taken as the argument verbatim, spaces included
|
|
1553
|
+
* (traverse.ts: `rawSegments.slice(i + 1).join(" ")`). So there is at most
|
|
1554
|
+
* one per path and it is always the tail, at whatever depth the input node
|
|
1555
|
+
* sits: `:watch <dir>` is depth 1, `:provider openrouter connect <key>` is
|
|
1556
|
+
* depth 3, and both put the whole remainder here.
|
|
1557
|
+
*
|
|
1558
|
+
* If the grammar ever admits MID-PATH arguments (`:agent <name> rename
|
|
1559
|
+
* <new>`), this field must change shape — one string cannot represent two.
|
|
1560
|
+
* That is a parser change, so it will be caught here rather than silently
|
|
1561
|
+
* producing a wrong `arg`.
|
|
1562
|
+
*/
|
|
1563
|
+
arg?: string
|
|
1564
|
+
/**
|
|
1565
|
+
* How it was invoked: chosen in the command palette, or run by
|
|
1566
|
+
* `commands.run()`.
|
|
1567
|
+
*
|
|
1568
|
+
* Present so a handler can tell the user's action from its own — an
|
|
1569
|
+
* extension that reacts to every command by running another would otherwise
|
|
1570
|
+
* have no way to avoid recursing into itself.
|
|
1571
|
+
*
|
|
1572
|
+
* There is deliberately no `"key"`. A key bound to a command calls
|
|
1573
|
+
* `commands.run()` from its handler, so it IS an api call and reporting it
|
|
1574
|
+
* as its own source would be inventing a distinction the runtime cannot
|
|
1575
|
+
* actually make — a handler that checked for it would never match.
|
|
1576
|
+
*/
|
|
1577
|
+
source: "palette" | "api"
|
|
1578
|
+
}
|
|
1579
|
+
|
|
1580
|
+
/** `command:failed` — the above, plus what went wrong. */
|
|
1581
|
+
export type CommandFailedPayload = CommandPayload & {
|
|
1582
|
+
/** The thrown value, exactly as it was thrown. */
|
|
1583
|
+
error: unknown
|
|
910
1584
|
}
|
|
911
1585
|
|
|
912
1586
|
/**
|
|
@@ -917,11 +1591,14 @@ export type TuiGateHooks = {
|
|
|
917
1591
|
* "does the TUI block on this?" is answered by the type instead of by reading
|
|
918
1592
|
* the runtime. A handler needing async work owns it (`void doThing()`), which
|
|
919
1593
|
* keeps the fire-and-forget visible at the call site.
|
|
1594
|
+
*
|
|
1595
|
+
* There is deliberately no `tui:ready`. It existed, was typed, was documented,
|
|
1596
|
+
* and never fired — and the moment it is wired it is indistinguishable from
|
|
1597
|
+
* `tui:boot`, which already runs once registration is complete and gates the
|
|
1598
|
+
* terminal becoming interactive. Two hooks separated only by whether the screen
|
|
1599
|
+
* has painted is a distinction nothing in this API can act on.
|
|
920
1600
|
*/
|
|
921
1601
|
export type TuiNotifyHooks = {
|
|
922
|
-
/** The TUI is live and interactive. */
|
|
923
|
-
"tui:ready": () => void
|
|
924
|
-
|
|
925
1602
|
/**
|
|
926
1603
|
* The config was reloaded — `:reload`, or a file change.
|
|
927
1604
|
*
|
|
@@ -933,17 +1610,95 @@ export type TuiNotifyHooks = {
|
|
|
933
1610
|
* boot for setup that must finish first; use this to react to having been
|
|
934
1611
|
* reloaded — refreshing a cached palette, re-reading a file on disk.
|
|
935
1612
|
*/
|
|
936
|
-
"tui:reloaded": () => void
|
|
1613
|
+
"tui:reloaded": (payload: TuiReloadedPayload) => void
|
|
1614
|
+
|
|
1615
|
+
/**
|
|
1616
|
+
* The terminal was resized.
|
|
1617
|
+
*
|
|
1618
|
+
* Fires after the new size is in effect, so `tui.size` and this payload
|
|
1619
|
+
* always agree. Coalesced by the underlying watcher: a drag produces the
|
|
1620
|
+
* sizes the terminal actually reported, not one event per column.
|
|
1621
|
+
*/
|
|
1622
|
+
"tui:resize": (payload: TuiResizePayload) => void
|
|
1623
|
+
|
|
1624
|
+
/**
|
|
1625
|
+
* Text was copied to the system clipboard.
|
|
1626
|
+
*
|
|
1627
|
+
* Fires after the copy is dispatched (OSC 52 plus the native fallback), for
|
|
1628
|
+
* a selection copy the user made in the terminal. Observational, like every
|
|
1629
|
+
* notify hook: a handler cannot alter or veto what was copied, and the
|
|
1630
|
+
* clipboard has already been written by the time it runs.
|
|
1631
|
+
*
|
|
1632
|
+
* It does NOT fire for an empty selection — copying nothing is not an
|
|
1633
|
+
* event — nor for text the user pastes, which is the opposite direction and
|
|
1634
|
+
* would need its own hook.
|
|
1635
|
+
*/
|
|
1636
|
+
"tui:copy": (payload: TuiCopyPayload) => void
|
|
1637
|
+
|
|
1638
|
+
/**
|
|
1639
|
+
* A key the TUI did not handle.
|
|
1640
|
+
*
|
|
1641
|
+
* ── Unhandled only, and never consumable ────────────────────────────────
|
|
1642
|
+
*
|
|
1643
|
+
* This fires at the END of dispatch — after reserved chords, after
|
|
1644
|
+
* `keys.register()` bindings, after mode keys. A key that did something
|
|
1645
|
+
* does not arrive here.
|
|
1646
|
+
*
|
|
1647
|
+
* That is not a limitation to route around; it is the only shape that can
|
|
1648
|
+
* be safe. User key handling is mounted as a WILDCARD, and wildcards fire
|
|
1649
|
+
* before exact-key handlers — so a hook able to consume a press would beat
|
|
1650
|
+
* every built-in binding, including the ctrl+c exit ladder. The reserved
|
|
1651
|
+
* list refuses those chords at registration precisely because a check at
|
|
1652
|
+
* press time is already too late.
|
|
1653
|
+
*
|
|
1654
|
+
* So there is no return value and no consumption: this observes, exactly
|
|
1655
|
+
* like every other notify hook. To OWN a key, register it —
|
|
1656
|
+
* `keys.register("ctrl+o", ...)` — which is checked against the reserved
|
|
1657
|
+
* set and cannot break the terminal.
|
|
1658
|
+
*/
|
|
1659
|
+
"key:pressed": (payload: KeyPressedPayload) => void
|
|
1660
|
+
|
|
1661
|
+
/**
|
|
1662
|
+
* A palette opened.
|
|
1663
|
+
*
|
|
1664
|
+
* Narrower than `mode:changed`, and deliberately its own event: not every
|
|
1665
|
+
* mode is a palette. `loading` is a spinner and `voice` is a capture state,
|
|
1666
|
+
* and an extension gating on "is the user picking something" has to exclude
|
|
1667
|
+
* them — a derivation every consumer would otherwise write, and get wrong
|
|
1668
|
+
* the same way.
|
|
1669
|
+
*/
|
|
1670
|
+
"palette:opened": (payload: PalettePayload) => void
|
|
1671
|
+
|
|
1672
|
+
/** A palette closed. Fires for whichever palette was open. */
|
|
1673
|
+
"palette:closed": (payload: PalettePayload) => void
|
|
1674
|
+
|
|
1675
|
+
/**
|
|
1676
|
+
* A command finished successfully.
|
|
1677
|
+
*
|
|
1678
|
+
* Covers built-ins and user commands alike, however they were reached —
|
|
1679
|
+
* `source` says which. Fires AFTER the action resolves, so an async command
|
|
1680
|
+
* reports when it is genuinely done rather than when it started.
|
|
1681
|
+
*/
|
|
1682
|
+
"command:ran": (payload: CommandPayload) => void
|
|
1683
|
+
|
|
1684
|
+
/**
|
|
1685
|
+
* A command threw.
|
|
1686
|
+
*
|
|
1687
|
+
* Its own event rather than a field on `command:ran`, so a handler that
|
|
1688
|
+
* only cares about failures does not have to filter — and so the success
|
|
1689
|
+
* payload never carries an error slot that is null almost always.
|
|
1690
|
+
*/
|
|
1691
|
+
"command:failed": (payload: CommandFailedPayload) => void
|
|
937
1692
|
|
|
938
1693
|
/** An instance finished booting. */
|
|
939
|
-
"agent:ready": (
|
|
1694
|
+
"agent:ready": (payload: AgentPayload) => void
|
|
940
1695
|
/** An instance shut down. */
|
|
941
|
-
"agent:stopped": (
|
|
1696
|
+
"agent:stopped": (payload: AgentPayload) => void
|
|
942
1697
|
/** A different instance came on screen. */
|
|
943
|
-
"agent:focused": (
|
|
1698
|
+
"agent:focused": (payload: AgentPayload) => void
|
|
944
1699
|
|
|
945
1700
|
/** The user sent a message. Fires once it is delivered. */
|
|
946
|
-
"message:sent": (payload:
|
|
1701
|
+
"message:sent": (payload: MessageSentPayload) => void
|
|
947
1702
|
/**
|
|
948
1703
|
* The agent finished a wake.
|
|
949
1704
|
*
|
|
@@ -952,10 +1707,16 @@ export type TuiNotifyHooks = {
|
|
|
952
1707
|
* reacting to WHAT was said is writing an agent, which is a cognet's job.
|
|
953
1708
|
* This says only THAT a wake completed.
|
|
954
1709
|
*/
|
|
955
|
-
"message:received": (payload:
|
|
1710
|
+
"message:received": (payload: MessageReceivedPayload) => void
|
|
956
1711
|
|
|
957
|
-
/**
|
|
958
|
-
|
|
1712
|
+
/**
|
|
1713
|
+
* The active mode changed.
|
|
1714
|
+
*
|
|
1715
|
+
* The general event; `palette:opened`/`closed` are the specific ones. Use
|
|
1716
|
+
* this to observe every transition (including `loading` and `voice`), those
|
|
1717
|
+
* to react to the user opening something to pick from.
|
|
1718
|
+
*/
|
|
1719
|
+
"mode:changed": (payload: ModeChangedPayload) => void
|
|
959
1720
|
}
|
|
960
1721
|
|
|
961
1722
|
/** Every lifecycle hook, gating and notifying. */
|
|
@@ -1084,6 +1845,29 @@ export type VerbosityProfile = {
|
|
|
1084
1845
|
export type ProfileSettings = {
|
|
1085
1846
|
/** The active theme, by the name it was registered under. */
|
|
1086
1847
|
theme?: string
|
|
1848
|
+
/**
|
|
1849
|
+
* Which glyph set line components draw their icons from.
|
|
1850
|
+
*
|
|
1851
|
+
* ── Why this is a SETTING and not code ──────────────────────────────────
|
|
1852
|
+
*
|
|
1853
|
+
* It answers "what does this machine's font support", which is a property
|
|
1854
|
+
* of the terminal rather than of the config. A shared line should look
|
|
1855
|
+
* right on a laptop with a patched font and on a server without one, and
|
|
1856
|
+
* that cannot be true if the answer is compiled into the line.
|
|
1857
|
+
*
|
|
1858
|
+
* ── Why the default is "auto" ───────────────────────────────────────────
|
|
1859
|
+
*
|
|
1860
|
+
* Nerd Fonts are the de facto standard — lualine, starship, powerlevel10k
|
|
1861
|
+
* and oh-my-posh all assume one — so defaulting them OFF would give the
|
|
1862
|
+
* majority a plainer bar than they installed a patched font for.
|
|
1863
|
+
*
|
|
1864
|
+
* But a font cannot be detected from inside a terminal, so "auto" is a
|
|
1865
|
+
* heuristic, not a fact: it reads the same environment the ecosystem uses
|
|
1866
|
+
* (TERM_PROGRAM, and whether a font name mentions "Nerd"), and falls back
|
|
1867
|
+
* to unicode when nothing says yes. Someone seeing boxes sets "unicode" and
|
|
1868
|
+
* is done; someone seeing plain text sets "nerd".
|
|
1869
|
+
*/
|
|
1870
|
+
icons?: IconSet
|
|
1087
1871
|
/**
|
|
1088
1872
|
* Extra directories scanned for agent projects, beyond
|
|
1089
1873
|
* `profiles/<email>/agents/`. `~` expands to the home directory.
|
|
@@ -1155,6 +1939,41 @@ export type ProfileConfig = {
|
|
|
1155
1939
|
[extension: `@${string}/${string}`]: unknown
|
|
1156
1940
|
}
|
|
1157
1941
|
|
|
1942
|
+
/**
|
|
1943
|
+
* A glyph vocabulary.
|
|
1944
|
+
*
|
|
1945
|
+
* `nerd` is the full Nerd Font range — branch symbols, folder icons, the lot.
|
|
1946
|
+
* `unicode` is the subset present in essentially every font (▸ ● ◆), which
|
|
1947
|
+
* renders everywhere and reads as deliberate rather than degraded. `none`
|
|
1948
|
+
* drops icons entirely, for a bar that should be text and nothing else.
|
|
1949
|
+
*/
|
|
1950
|
+
export type IconSet = "auto" | "nerd" | "unicode" | "none"
|
|
1951
|
+
|
|
1952
|
+
/**
|
|
1953
|
+
* The named icons every set provides.
|
|
1954
|
+
*
|
|
1955
|
+
* Deliberately small and semantic: a component says what its value MEANS, and
|
|
1956
|
+
* the set decides what that looks like. Naming them after appearance
|
|
1957
|
+
* ("triangle") would tie every component to one set's vocabulary and defeat
|
|
1958
|
+
* the swap.
|
|
1959
|
+
*/
|
|
1960
|
+
export type IconName =
|
|
1961
|
+
| "agent"
|
|
1962
|
+
| "model"
|
|
1963
|
+
| "session"
|
|
1964
|
+
| "tokens"
|
|
1965
|
+
| "messages"
|
|
1966
|
+
| "modules"
|
|
1967
|
+
| "branch"
|
|
1968
|
+
| "changes"
|
|
1969
|
+
| "ahead"
|
|
1970
|
+
| "behind"
|
|
1971
|
+
| "folder"
|
|
1972
|
+
| "clock"
|
|
1973
|
+
| "user"
|
|
1974
|
+
| "warning"
|
|
1975
|
+
| "error"
|
|
1976
|
+
|
|
1158
1977
|
/** What `defineProfile()` returns. */
|
|
1159
1978
|
export type ProfileDefinition = {
|
|
1160
1979
|
_kind: "profile"
|