@sagmans/dsh-tui 0.2.0 → 0.4.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.
Files changed (174) hide show
  1. package/README.md +282 -25
  2. package/cordis.patch.yml +14 -0
  3. package/lib/agent/model.d.ts +26 -0
  4. package/lib/agent/model.d.ts.map +1 -1
  5. package/lib/agent/model.js +41 -0
  6. package/lib/agent/model.js.map +1 -1
  7. package/lib/agent/projections.d.ts +22 -6
  8. package/lib/agent/projections.d.ts.map +1 -1
  9. package/lib/agent/projections.js +21 -10
  10. package/lib/agent/projections.js.map +1 -1
  11. package/lib/agent/prompt-history.d.ts +89 -0
  12. package/lib/agent/prompt-history.d.ts.map +1 -0
  13. package/lib/agent/prompt-history.js +380 -0
  14. package/lib/agent/prompt-history.js.map +1 -0
  15. package/lib/agent/status.d.ts +16 -0
  16. package/lib/agent/status.d.ts.map +1 -1
  17. package/lib/agent/status.js +3 -0
  18. package/lib/agent/status.js.map +1 -1
  19. package/lib/cards.d.ts +1 -1
  20. package/lib/cards.d.ts.map +1 -1
  21. package/lib/cards.js +4 -3
  22. package/lib/cards.js.map +1 -1
  23. package/lib/gates.d.ts +145 -2
  24. package/lib/gates.d.ts.map +1 -1
  25. package/lib/gates.js +335 -40
  26. package/lib/gates.js.map +1 -1
  27. package/lib/herdr/client.d.ts +57 -0
  28. package/lib/herdr/client.d.ts.map +1 -0
  29. package/lib/herdr/client.js +218 -0
  30. package/lib/herdr/client.js.map +1 -0
  31. package/lib/herdr/constants.d.ts +93 -0
  32. package/lib/herdr/constants.d.ts.map +1 -0
  33. package/lib/herdr/constants.js +79 -0
  34. package/lib/herdr/constants.js.map +1 -0
  35. package/lib/herdr/reporter.d.ts +60 -0
  36. package/lib/herdr/reporter.d.ts.map +1 -0
  37. package/lib/herdr/reporter.js +217 -0
  38. package/lib/herdr/reporter.js.map +1 -0
  39. package/lib/herdr/state.d.ts +57 -0
  40. package/lib/herdr/state.d.ts.map +1 -0
  41. package/lib/herdr/state.js +62 -0
  42. package/lib/herdr/state.js.map +1 -0
  43. package/lib/index.d.ts.map +1 -1
  44. package/lib/index.js +631 -118
  45. package/lib/index.js.map +1 -1
  46. package/lib/input/actions.d.ts +136 -0
  47. package/lib/input/actions.d.ts.map +1 -0
  48. package/lib/input/actions.js +743 -0
  49. package/lib/input/actions.js.map +1 -0
  50. package/lib/input/ghost.d.ts +46 -0
  51. package/lib/input/ghost.d.ts.map +1 -0
  52. package/lib/input/ghost.js +58 -0
  53. package/lib/input/ghost.js.map +1 -0
  54. package/lib/input/keymap-settings.d.ts +21 -0
  55. package/lib/input/keymap-settings.d.ts.map +1 -0
  56. package/lib/input/keymap-settings.js +28 -0
  57. package/lib/input/keymap-settings.js.map +1 -0
  58. package/lib/input/keymap.d.ts +91 -0
  59. package/lib/input/keymap.d.ts.map +1 -0
  60. package/lib/input/keymap.js +172 -0
  61. package/lib/input/keymap.js.map +1 -0
  62. package/lib/input/match.d.ts +10 -0
  63. package/lib/input/match.d.ts.map +1 -0
  64. package/lib/input/match.js +83 -0
  65. package/lib/input/match.js.map +1 -0
  66. package/lib/input/submission.d.ts +29 -1
  67. package/lib/input/submission.d.ts.map +1 -1
  68. package/lib/input/submission.js +33 -2
  69. package/lib/input/submission.js.map +1 -1
  70. package/lib/input.d.ts +17 -0
  71. package/lib/input.d.ts.map +1 -0
  72. package/lib/input.js +27 -0
  73. package/lib/input.js.map +1 -0
  74. package/lib/keys-command.d.ts +16 -0
  75. package/lib/keys-command.d.ts.map +1 -0
  76. package/lib/keys-command.js +60 -0
  77. package/lib/keys-command.js.map +1 -0
  78. package/lib/queue.d.ts +6 -0
  79. package/lib/queue.d.ts.map +1 -0
  80. package/lib/queue.js +68 -0
  81. package/lib/queue.js.map +1 -0
  82. package/lib/settings-notice.d.ts +19 -0
  83. package/lib/settings-notice.d.ts.map +1 -0
  84. package/lib/settings-notice.js +30 -0
  85. package/lib/settings-notice.js.map +1 -0
  86. package/lib/stash/lock.d.ts +72 -0
  87. package/lib/stash/lock.d.ts.map +1 -0
  88. package/lib/stash/lock.js +374 -0
  89. package/lib/stash/lock.js.map +1 -0
  90. package/lib/stash/paths.d.ts +22 -0
  91. package/lib/stash/paths.d.ts.map +1 -0
  92. package/lib/stash/paths.js +83 -0
  93. package/lib/stash/paths.js.map +1 -0
  94. package/lib/stash/private-fs.d.ts +61 -0
  95. package/lib/stash/private-fs.d.ts.map +1 -0
  96. package/lib/stash/private-fs.js +379 -0
  97. package/lib/stash/private-fs.js.map +1 -0
  98. package/lib/stash/schema.d.ts +57 -0
  99. package/lib/stash/schema.d.ts.map +1 -0
  100. package/lib/stash/schema.js +127 -0
  101. package/lib/stash/schema.js.map +1 -0
  102. package/lib/stash/store.d.ts +92 -0
  103. package/lib/stash/store.d.ts.map +1 -0
  104. package/lib/stash/store.js +262 -0
  105. package/lib/stash/store.js.map +1 -0
  106. package/lib/stash.d.ts +91 -0
  107. package/lib/stash.d.ts.map +1 -0
  108. package/lib/stash.js +296 -0
  109. package/lib/stash.js.map +1 -0
  110. package/lib/theme-settings.d.ts +72 -8
  111. package/lib/theme-settings.d.ts.map +1 -1
  112. package/lib/theme-settings.js +125 -5
  113. package/lib/theme-settings.js.map +1 -1
  114. package/lib/theme-tokens.d.ts +4 -4
  115. package/lib/theme-tokens.d.ts.map +1 -1
  116. package/lib/theme-tokens.js +39 -5
  117. package/lib/theme-tokens.js.map +1 -1
  118. package/lib/todo-guard.d.ts +116 -0
  119. package/lib/todo-guard.d.ts.map +1 -0
  120. package/lib/todo-guard.js +259 -0
  121. package/lib/todo-guard.js.map +1 -0
  122. package/lib/ui/editor.d.ts +58 -1
  123. package/lib/ui/editor.d.ts.map +1 -1
  124. package/lib/ui/editor.js +174 -19
  125. package/lib/ui/editor.js.map +1 -1
  126. package/lib/ui/frame.d.ts +54 -0
  127. package/lib/ui/frame.d.ts.map +1 -0
  128. package/lib/ui/frame.js +79 -0
  129. package/lib/ui/frame.js.map +1 -0
  130. package/lib/ui/gate-input.d.ts +20 -0
  131. package/lib/ui/gate-input.d.ts.map +1 -0
  132. package/lib/ui/gate-input.js +96 -0
  133. package/lib/ui/gate-input.js.map +1 -0
  134. package/lib/ui/history-picker.d.ts +15 -0
  135. package/lib/ui/history-picker.d.ts.map +1 -0
  136. package/lib/ui/history-picker.js +26 -0
  137. package/lib/ui/history-picker.js.map +1 -0
  138. package/lib/ui/markdown.d.ts +11 -2
  139. package/lib/ui/markdown.d.ts.map +1 -1
  140. package/lib/ui/markdown.js +25 -6
  141. package/lib/ui/markdown.js.map +1 -1
  142. package/lib/ui/mermaid.d.ts +44 -0
  143. package/lib/ui/mermaid.d.ts.map +1 -0
  144. package/lib/ui/mermaid.js +178 -0
  145. package/lib/ui/mermaid.js.map +1 -0
  146. package/lib/ui/picker.d.ts +40 -8
  147. package/lib/ui/picker.d.ts.map +1 -1
  148. package/lib/ui/picker.js +79 -24
  149. package/lib/ui/picker.js.map +1 -1
  150. package/lib/ui/prompt.d.ts +32 -0
  151. package/lib/ui/prompt.d.ts.map +1 -0
  152. package/lib/ui/prompt.js +49 -0
  153. package/lib/ui/prompt.js.map +1 -0
  154. package/lib/ui/queue.d.ts +24 -0
  155. package/lib/ui/queue.d.ts.map +1 -0
  156. package/lib/ui/queue.js +57 -0
  157. package/lib/ui/queue.js.map +1 -0
  158. package/lib/ui/stash-picker.d.ts +43 -0
  159. package/lib/ui/stash-picker.d.ts.map +1 -0
  160. package/lib/ui/stash-picker.js +78 -0
  161. package/lib/ui/stash-picker.js.map +1 -0
  162. package/lib/ui/status.d.ts +6 -0
  163. package/lib/ui/status.d.ts.map +1 -1
  164. package/lib/ui/status.js +15 -0
  165. package/lib/ui/status.js.map +1 -1
  166. package/lib/ui/view.d.ts +22 -2
  167. package/lib/ui/view.d.ts.map +1 -1
  168. package/lib/ui/view.js +84 -24
  169. package/lib/ui/view.js.map +1 -1
  170. package/lib/work.d.ts +51 -1
  171. package/lib/work.d.ts.map +1 -1
  172. package/lib/work.js +53 -1
  173. package/lib/work.js.map +1 -1
  174. package/package.json +7 -2
@@ -39,8 +39,36 @@ export type Submission = {
39
39
  readonly kind: 'todo';
40
40
  } | {
41
41
  readonly kind: 'theme';
42
+ } | {
43
+ readonly kind: 'keys';
44
+ readonly argument: string;
42
45
  } | {
43
46
  readonly kind: 'copy';
47
+ } | {
48
+ readonly kind: 'plan';
49
+ } | {
50
+ readonly kind: 'history';
51
+ readonly argument: string;
52
+ } | {
53
+ readonly kind: 'stash';
54
+ readonly argument: string;
55
+ }
56
+ /** The chord: park whatever the editor is holding, which a typed command cannot do. */
57
+ | {
58
+ readonly kind: 'stash-draft';
59
+ } | {
60
+ readonly kind: 'stash-pop';
61
+ readonly selector: string;
62
+ } | {
63
+ readonly kind: 'stash-apply';
64
+ readonly selector: string;
65
+ } | {
66
+ readonly kind: 'stash-list';
67
+ } | {
68
+ readonly kind: 'stash-drop';
69
+ readonly selector: string;
70
+ } | {
71
+ readonly kind: 'stash-clear';
44
72
  } | {
45
73
  readonly kind: 'command';
46
74
  readonly name: string;
@@ -50,7 +78,7 @@ export type Submission = {
50
78
  readonly text: string;
51
79
  };
52
80
  /** Commands the surface answers itself, without a model turn. */
53
- export declare const LOCAL_COMMANDS: readonly ["/help", "/status", "/model", "/preset", "/todo", "/theme", "/jobs", "/subagents", "/fork", "/new", "/rename", "/export", "/copy", "/clear", "/resume", "/quit", "/exit"];
81
+ export declare const LOCAL_COMMANDS: readonly ["/help", "/status", "/model", "/preset", "/todo", "/theme", "/keys", "/jobs", "/subagents", "/fork", "/new", "/rename", "/export", "/copy", "/history", "/clear", "/resume", "/quit", "/exit", "/stash", "/stash-pop", "/stash-apply", "/stash-list", "/stash-drop", "/stash-clear"];
54
82
  /** What each local command does, shown in the editor's completion menu. */
55
83
  export declare const LOCAL_COMMAND_DESCRIPTIONS: Readonly<Record<string, string>>;
56
84
  /**
@@ -1 +1 @@
1
- {"version":3,"file":"submission.d.ts","sourceRoot":"","sources":["../../src/input/submission.ts"],"names":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ChC;IAAE,QAAQ,CAAC,IAAI,EAAE,WAAW,CAAC;IAAC,QAAQ,CAAC,QAAQ,EAAE,MAAM,CAAA;CAAE,GACzD;IAAE,QAAQ,CAAC,IAAI,EAAE,aAAa,CAAC;IAAC,QAAQ,CAAC,QAAQ,EAAE,MAAM,CAAA;CAAE,GAC3D;IAAE,QAAQ,CAAC,IAAI,EAAE,YAAY,CAAA;CAAE,GAC/B;IAAE,QAAQ,CAAC,IAAI,EAAE,YAAY,CAAC;IAAC,QAAQ,CAAC,QAAQ,EAAE,MAAM,CAAA;CAAE,GAC1D;IAAE,QAAQ,CAAC,IAAI,EAAE,aAAa,CAAA;CAAE,GAChC;IAAE,QAAQ,CAAC,IAAI,EAAE,SAAS,CAAC;IAAC,QAAQ,CAAC,IAAI,EAAE,MAAM,CAAC;IAAC,QAAQ,CAAC,IAAI,EAAE,MAAM,CAAA;CAAE,GAC1E;IAAE,QAAQ,CAAC,IAAI,EAAE,QAAQ,CAAC;IAAC,QAAQ,CAAC,IAAI,EAAE,MAAM,CAAA;CAAE,CAAA;AAEtD,iEAAiE;AACjE,eAAO,MAAM,cAAc,gSAGjB,CAAA;AAEV,2EAA2E;AAC3E,eAAO,MAAM,0BAA0B,EAAE,QAAQ,CAAC,MAAM,CAAC,MAAM,EAAE,MAAM,CAAC,CA0BvE,CAAA;AAED;;;;;;GAMG;AACH,wBAAgB,kBAAkB,CAAC,IAAI,EAAE,MAAM,GAAG,UAAU,CA6D3D"}
@@ -1,24 +1,33 @@
1
1
  /** Commands the surface answers itself, without a model turn. */
2
2
  export const LOCAL_COMMANDS = [
3
- '/help', '/status', '/model', '/preset', '/todo', '/theme', '/jobs', '/subagents', '/fork', '/new', '/rename', '/export', '/copy', '/clear', '/resume', '/quit', '/exit',
3
+ '/help', '/status', '/model', '/preset', '/todo', '/theme', '/keys', '/jobs', '/subagents', '/fork', '/new', '/rename', '/export', '/copy', '/history', '/clear', '/resume', '/quit', '/exit',
4
+ '/stash', '/stash-pop', '/stash-apply', '/stash-list', '/stash-drop', '/stash-clear',
4
5
  ];
5
6
  /** What each local command does, shown in the editor's completion menu. */
6
7
  export const LOCAL_COMMAND_DESCRIPTIONS = {
7
8
  '/help': 'list registered and local commands',
8
9
  '/status': 'show the session, model, permissions, and context',
9
- '/model': 'show or switch the model and its reasoning effort for the next step',
10
+ '/model': 'open the model picker (type to filter); /model <provider>/<model> switches directly',
10
11
  '/preset': 'choose the agent preset (mode) this session runs',
11
12
  '/jobs': 'list background jobs, read one, or kill one',
12
13
  '/subagents': 'list delegations; /subagents open <id|last> reads one, /subagents kill <id> stops one',
13
14
  '/todo': 'show the list of tasks the agent is keeping',
14
15
  '/theme': 'list every styled element and the value in force',
16
+ '/keys': 'list every action and the keys in force; /keys <layer> narrows it',
15
17
  '/fork': 'branch this conversation and continue in the branch',
16
18
  '/new': 'start a fresh session without leaving the terminal',
17
19
  '/copy': 'copy the last answer to the clipboard through the terminal',
20
+ '/history': 'show where prompt history is kept; /history clear forgets every prompt',
18
21
  '/rename': 'give this session a title the picker will show',
19
22
  '/export': 'write the visible transcript to a markdown file',
20
23
  '/clear': 'clear the visible transcript',
21
24
  '/resume': 'open another stored session',
25
+ '/stash': 'store the draft typed after it; ctrl+x then s parks the editor',
26
+ '/stash-pop': 'put a stashed draft (newest by default) into the editor and remove it',
27
+ '/stash-apply': 'put a stashed draft (newest by default) into the editor and keep it',
28
+ '/stash-list': 'open the stashes for this directory; enter pops one',
29
+ '/stash-drop': 'delete a stashed draft (newest by default) without using it',
30
+ '/stash-clear': 'delete every stashed draft for this directory after a confirmation',
22
31
  '/quit': 'leave and print the resume command',
23
32
  '/exit': 'leave and print the resume command',
24
33
  };
@@ -68,11 +77,33 @@ export function classifySubmission(text) {
68
77
  return { kind: 'todo' };
69
78
  if (trimmed === '/theme')
70
79
  return { kind: 'theme' };
80
+ if (trimmed === '/keys' || trimmed.startsWith('/keys ')) {
81
+ return { kind: 'keys', argument: trimmed.slice('/keys'.length).trim() };
82
+ }
71
83
  if (trimmed === '/copy')
72
84
  return { kind: 'copy' };
85
+ if (trimmed === '/history' || trimmed.startsWith('/history ')) {
86
+ return { kind: 'history', argument: trimmed.slice('/history'.length).trim() };
87
+ }
73
88
  if (trimmed === '/new' || trimmed.startsWith('/new ')) {
74
89
  return { kind: 'new', title: trimmed.slice('/new'.length).trim() };
75
90
  }
91
+ if (trimmed === '/stash-pop' || trimmed.startsWith('/stash-pop ')) {
92
+ return { kind: 'stash-pop', selector: trimmed.slice('/stash-pop'.length).trim() };
93
+ }
94
+ if (trimmed === '/stash-apply' || trimmed.startsWith('/stash-apply ')) {
95
+ return { kind: 'stash-apply', selector: trimmed.slice('/stash-apply'.length).trim() };
96
+ }
97
+ if (trimmed === '/stash-list')
98
+ return { kind: 'stash-list' };
99
+ if (trimmed === '/stash-drop' || trimmed.startsWith('/stash-drop ')) {
100
+ return { kind: 'stash-drop', selector: trimmed.slice('/stash-drop'.length).trim() };
101
+ }
102
+ if (trimmed === '/stash-clear')
103
+ return { kind: 'stash-clear' };
104
+ if (trimmed === '/stash' || trimmed.startsWith('/stash ')) {
105
+ return { kind: 'stash', argument: trimmed.slice('/stash'.length).trim() };
106
+ }
76
107
  if (trimmed.startsWith('/')) {
77
108
  const [head = ''] = trimmed.slice(1).split(/\s+/u, 1);
78
109
  const name = head.toLowerCase();
@@ -1 +1 @@
1
- {"version":3,"file":"submission.js","sourceRoot":"","sources":["../../src/input/submission.ts"],"names":[],"mappings":"AAsBA,iEAAiE;AACjE,MAAM,CAAC,MAAM,cAAc,GAAG;IAC5B,OAAO,EAAE,SAAS,EAAE,QAAQ,EAAE,SAAS,EAAE,OAAO,EAAE,QAAQ,EAAE,OAAO,EAAE,YAAY,EAAE,OAAO,EAAE,MAAM,EAAE,SAAS,EAAE,SAAS,EAAE,OAAO,EAAE,QAAQ,EAAE,SAAS,EAAE,OAAO,EAAE,OAAO;CAChK,CAAA;AAEV,2EAA2E;AAC3E,MAAM,CAAC,MAAM,0BAA0B,GAAqC;IA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AC,EAAE,CAAC;QACpE,OAAO,EAAE,IAAI,EAAE,YAAY,EAAE,QAAQ,EAAE,OAAO,CAAC,KAAK,CAAC,aAAa,CAAC,MAAM,CAAC,CAAC,IAAI,EAAE,EAAE,CAAA;IACrF,CAAC;IACD,IAAI,OAAO,KAAK,cAAc;QAAE,OAAO,EAAE,IAAI,EAAE,aAAa,EAAE,CAAA;IAC9D,IAAI,OAAO,KAAK,QAAQ,IAAI,OAAO,CAAC,UAAU,CAAC,SAAS,CAAC,EAAE,CAAC;QAC1D,OAAO,EAAE,IAAI,EAAE,OAAO,EAAE,QAAQ,EAAE,OAAO,CAAC,KAAK,CAAC,QAAQ,CAAC,MAAM,CAAC,CAAC,IAAI,EAAE,EAAE,CAAA;IAC3E,CAAC;IACD,IAAI,OAAO,CAAC,UAAU,CAAC,GAAG,CAAC,EAAE,CAAC;QAC5B,MAAM,CAAC,IAAI,GAAG,EAAE,CAAC,GAAG,OAAO,CAAC,KAAK,CAAC,CAAC,CAAC,CAAC,KAAK,CAAC,MAAM,EAAE,CAAC,CAAC,CAAA;QACrD,MAAM,IAAI,GAAG,IAAI,CAAC,WAAW,EAAE,CAAA;QAC/B,OAAO,IAAI,KAAK,EAAE,CAAC,CAAC,CAAC,EAAE,IAAI,EAAE,OAAO,EAAE,CAAC,CAAC,CAAC,EAAE,IAAI,EAAE,SAAS,EAAE,IAAI,EAAE,IAAI,EAAE,OAAO,EAAE,CAAA;IACnF,CAAC;IACD,OAAO,EAAE,IAAI,EAAE,QAAQ,EAAE,IAAI,EAAE,OAAO,EAAE,CAAA;AAC1C,CAAC"}
package/lib/input.d.ts ADDED
@@ -0,0 +1,17 @@
1
+ /**
2
+ * Decoding shared by every surface that reads typed text.
3
+ *
4
+ * The terminal reports a paste as one bracketed run rather than as key presses,
5
+ * so a handler that only knows single characters silently drops what a reader
6
+ * copied; unwrapping it here keeps each surface answering for its own meaning
7
+ * instead of each re-deriving the same markers.
8
+ */
9
+ /**
10
+ * The text a bracketed paste carries, or undefined when the input is a key press.
11
+ *
12
+ * Control bytes are the terminal's, not the reader's: a copied key arrives with
13
+ * the newline that copied it, and keeping that newline would confirm a question
14
+ * before the reader saw what landed.
15
+ */
16
+ export declare function pastedText(data: string): string | undefined;
17
+ //# sourceMappingURL=input.d.ts.map
@@ -0,0 +1 @@
1
+ {"version":3,"file":"input.d.ts","sourceRoot":"","sources":["../src/input.ts"],"names":[],"mappings":"AAAA;;;;;;;GAOG;AAMH;;;;;;GAMG;AACH,wBAAgB,UAAU,CAAC,IAAI,EAAE,MAAM,GAAG,MAAM,GAAG,SAAS,CAM3D"}
package/lib/input.js ADDED
@@ -0,0 +1,27 @@
1
+ /**
2
+ * Decoding shared by every surface that reads typed text.
3
+ *
4
+ * The terminal reports a paste as one bracketed run rather than as key presses,
5
+ * so a handler that only knows single characters silently drops what a reader
6
+ * copied; unwrapping it here keeps each surface answering for its own meaning
7
+ * instead of each re-deriving the same markers.
8
+ */
9
+ /** The markers the surface wraps a paste in once the terminal reports one. */
10
+ const PASTE_START = '\x1b[200~';
11
+ const PASTE_END = '\x1b[201~';
12
+ /**
13
+ * The text a bracketed paste carries, or undefined when the input is a key press.
14
+ *
15
+ * Control bytes are the terminal's, not the reader's: a copied key arrives with
16
+ * the newline that copied it, and keeping that newline would confirm a question
17
+ * before the reader saw what landed.
18
+ */
19
+ export function pastedText(data) {
20
+ const start = data.indexOf(PASTE_START);
21
+ if (start === -1)
22
+ return undefined;
23
+ const rest = data.slice(start + PASTE_START.length);
24
+ const end = rest.indexOf(PASTE_END);
25
+ return (end === -1 ? rest : rest.slice(0, end)).replace(/[\u0000-\u001f\u007f]/gu, '');
26
+ }
27
+ //# sourceMappingURL=input.js.map
@@ -0,0 +1 @@
1
+ {"version":3,"file":"input.js","sourceRoot":"","sources":["../src/input.ts"],"names":[],"mappings":"AAAA;;;;;;;GAOG;AAEH,8EAA8E;AAC9E,MAAM,WAAW,GAAG,WAAW,CAAA;AAC/B,MAAM,SAAS,GAAG,WAAW,CAAA;AAE7B;;;;;;GAMG;AACH,MAAM,UAAU,UAAU,CAAC,IAAY;IACrC,MAAM,KAAK,GAAG,IAAI,CAAC,OAAO,CAAC,WAAW,CAAC,CAAA;IACvC,IAAI,KAAK,KAAK,CAAC,CAAC;QAAE,OAAO,SAAS,CAAA;IAClC,MAAM,IAAI,GAAG,IAAI,CAAC,KAAK,CAAC,KAAK,GAAG,WAAW,CAAC,MAAM,CAAC,CAAA;IACnD,MAAM,GAAG,GAAG,IAAI,CAAC,OAAO,CAAC,SAAS,CAAC,CAAA;IACnC,OAAO,CAAC,GAAG,KAAK,CAAC,CAAC,CAAC,CAAC,CAAC,IAAI,CAAC,CAAC,CAAC,IAAI,CAAC,KAAK,CAAC,CAAC,EAAE,GAAG,CAAC,CAAC,CAAC,OAAO,CAAC,yBAAyB,EAAE,EAAE,CAAC,CAAA;AACxF,CAAC"}
@@ -0,0 +1,16 @@
1
+ import { type ActionLayer, type Keymap } from './input/actions.ts';
2
+ /** The layers a reader may ask for, in the order the table lists them. */
3
+ export declare const KEYMAP_LAYERS: readonly ActionLayer[];
4
+ /** The layer a reader named, or nothing when the name is not one of them. */
5
+ export declare function keymapLayer(name: string): ActionLayer | undefined;
6
+ /**
7
+ * The effective map, one line per action.
8
+ *
9
+ * The id comes first because it is what the reader types into settings.yaml;
10
+ * the keys follow in the order they are read, so a list action answers its
11
+ * first key before its second. A mark says which rows the reader wrote, because
12
+ * a document that no longer matches the shipped map cannot be read off the file
13
+ * once the file grows.
14
+ */
15
+ export declare function renderKeymap(map: Keymap, only?: ActionLayer): string[];
16
+ //# sourceMappingURL=keys-command.d.ts.map
@@ -0,0 +1 @@
1
+ {"version":3,"file":"keys-command.d.ts","sourceRoot":"","sources":["../src/keys-command.ts"],"names":[],"mappings":"AAAA,OAAO,EAA6D,KAAK,WAAW,EAAE,KAAK,MAAM,EAAE,MAAM,oBAAoB,CAAA;AAE7H,0EAA0E;AAC1E,eAAO,MAAM,aAAa,EAAE,SAAS,WAAW,EAA4E,CAAA;AAuB5H,6EAA6E;AAC7E,wBAAgB,WAAW,CAAC,IAAI,EAAE,MAAM,GAAG,WAAW,GAAG,SAAS,CAEjE;AAED;;;;;;;;GAQG;AACH,wBAAgB,YAAY,CAAC,GAAG,EAAE,MAAM,EAAE,IAAI,CAAC,EAAE,WAAW,GAAG,MAAM,EAAE,CAsBtE"}
@@ -0,0 +1,60 @@
1
+ import { ACTION_CATALOG, actionLabel, keyName, keysFor, newShadows } from "./input/actions.js";
2
+ /** The layers a reader may ask for, in the order the table lists them. */
3
+ export const KEYMAP_LAYERS = ['prompt', 'surface', 'chord', 'gate', 'question', 'picker', 'library'];
4
+ /** What each layer is for, so a list of ids reads as a surface rather than a dump. */
5
+ const LAYER_NOTES = {
6
+ prompt: 'the prompt bar',
7
+ surface: 'the surface, answered before the editor',
8
+ chord: 'the prefix first, then the key that follows it',
9
+ gate: 'an approval',
10
+ question: 'a question and its options',
11
+ picker: 'a list',
12
+ library: 'the editor and input pi-tui draws, read from the library',
13
+ };
14
+ /** Where the reader edits the section; the home is a variable, not a fixed path. */
15
+ const SETTINGS_HINT = 'edit $DSH_HOME/settings.yaml (default ~/.dsh/settings.yaml) under "dsh-tui:" · /keys shows the result';
16
+ /** The smallest document that says something, so the shape is never guessed at. */
17
+ const EXAMPLE = [
18
+ 'keys:',
19
+ ' prompt.submit: ctrl+enter # one key, or',
20
+ ' prompt.newLine: [enter, shift+enter, ctrl+j] # a list of them',
21
+ ];
22
+ /** The layer a reader named, or nothing when the name is not one of them. */
23
+ export function keymapLayer(name) {
24
+ return KEYMAP_LAYERS.find(layer => layer === name);
25
+ }
26
+ /**
27
+ * The effective map, one line per action.
28
+ *
29
+ * The id comes first because it is what the reader types into settings.yaml;
30
+ * the keys follow in the order they are read, so a list action answers its
31
+ * first key before its second. A mark says which rows the reader wrote, because
32
+ * a document that no longer matches the shipped map cannot be read off the file
33
+ * once the file grows.
34
+ */
35
+ export function renderKeymap(map, only) {
36
+ const layers = only === undefined ? KEYMAP_LAYERS : [only];
37
+ const actions = ACTION_CATALOG.filter(action => layers.includes(action.layer));
38
+ const lines = [`keys · ${actions.length} actions · ${map.written.size} of them yours`, ''];
39
+ for (const layer of layers) {
40
+ const rows = actions.filter(action => action.layer === layer);
41
+ if (rows.length === 0)
42
+ continue;
43
+ lines.push(`${layer} · ${LAYER_NOTES[layer]}:`);
44
+ for (const action of rows) {
45
+ const keys = keysFor(map, action.id).map(keyName).join(' · ');
46
+ lines.push(` ${action.id} = ${keys === '' ? 'unbound' : keys} · ${actionLabel(action.id)}${map.written.has(action.id) ? ' (yours)' : ''}`);
47
+ }
48
+ lines.push('');
49
+ }
50
+ const shadows = newShadows(map);
51
+ if (shadows.length > 0) {
52
+ lines.push('keys you took from the library:');
53
+ for (const shadow of shadows)
54
+ lines.push(` ${keyName(shadow.key)}: ${shadow.winner} over ${shadow.loser}`);
55
+ lines.push('');
56
+ }
57
+ lines.push(...EXAMPLE, '', SETTINGS_HINT);
58
+ return lines;
59
+ }
60
+ //# sourceMappingURL=keys-command.js.map
@@ -0,0 +1 @@
1
+ {"version":3,"file":"keys-command.js","sourceRoot":"","sources":["../src/keys-command.ts"],"names":[],"mappings":"AAAA,OAAO,EAAE,cAAc,EAAE,WAAW,EAAE,OAAO,EAAE,OAAO,EAAE,UAAU,EAAiC,MAAM,oBAAoB,CAAA;AAE7H,0EAA0E;AAC1E,MAAM,CAAC,MAAM,aAAa,GAA2B,CAAC,QAAQ,EAAE,SAAS,EAAE,OAAO,EAAE,MAAM,EAAE,UAAU,EAAE,QAAQ,EAAE,SAAS,CAAC,CAAA;AAE5H,sFAAsF;AACtF,MAAM,WAAW,GAA0C;IACzD,MAAM,EAAE,gBAAgB;IACxB,OAAO,EAAE,yCAAyC;IAClD,KAAK,EAAE,gDAAgD;IACvD,IAAI,EAAE,aAAa;IACnB,QAAQ,EAAE,4BAA4B;IACtC,MAAM,EAAE,QAAQ;IAChB,OAAO,EAAE,0DAA0D;CACpE,CAAA;AAED,oF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KAAK,CAAC,IAAI,CAAC,KAAK,MAAM,CAAC,EAAE,MAAM,IAAI,KAAK,EAAE,CAAC,CAAC,CAAC,SAAS,CAAC,CAAC,CAAC,IAAI,MAAM,WAAW,CAAC,MAAM,CAAC,EAAE,CAAC,GAAG,GAAG,CAAC,OAAO,CAAC,GAAG,CAAC,MAAM,CAAC,EAAE,CAAC,CAAC,CAAC,CAAC,WAAW,CAAC,CAAC,CAAC,EAAE,EAAE,CAAC,CAAA;QAC9I,CAAC;QACD,KAAK,CAAC,IAAI,CAAC,EAAE,CAAC,CAAA;IAChB,CAAC;IACD,MAAM,OAAO,GAAG,UAAU,CAAC,GAAG,CAAC,CAAA;IAC/B,IAAI,OAAO,CAAC,MAAM,GAAG,CAAC,EAAE,CAAC;QACvB,KAAK,CAAC,IAAI,CAAC,iCAAiC,CAAC,CAAA;QAC7C,KAAK,MAAM,MAAM,IAAI,OAAO;YAAE,KAAK,CAAC,IAAI,CAAC,KAAK,OAAO,CAAC,MAAM,CAAC,GAAG,CAAC,KAAK,MAAM,CAAC,MAAM,SAAS,MAAM,CAAC,KAAK,EAAE,CAAC,CAAA;QAC3G,KAAK,CAAC,IAAI,CAAC,EAAE,CAAC,CAAA;IAChB,CAAC;IACD,KAAK,CAAC,IAAI,CAAC,GAAG,OAAO,EAAE,EAAE,EAAE,aAAa,CAAC,CAAA;IACzC,OAAO,KAAK,CAAA;AACd,CAAC"}
package/lib/queue.d.ts ADDED
@@ -0,0 +1,6 @@
1
+ import type { Context } from '@deepseek-ai/cordis';
2
+ /** The reader's own prompts still waiting in one inbox projection state. */
3
+ export declare function promptsOf(state: unknown): readonly string[];
4
+ /** The prompts one session's agent has not taken yet. */
5
+ export declare function pendingPrompts(ctx: Context, session: unknown): readonly string[];
6
+ //# sourceMappingURL=queue.d.ts.map
@@ -0,0 +1 @@
1
+ {"version":3,"file":"queue.d.ts","sourceRoot":"","sources":["../src/queue.ts"],"names":[],"mappings":"AAAA,OAAO,KAAK,EAAE,OAAO,EAAE,MAAM,qBAAqB,CAAA;AAmDlD,4EAA4E;AAC5E,wBAAgB,SAAS,CAAC,KAAK,EAAE,OAAO,GAAG,SAAS,MAAM,EAAE,CAc3D;AAED,yDAAyD;AACzD,wBAAgB,cAAc,CAAC,GAAG,EAAE,OAAO,EAAE,OAAO,EAAE,OAAO,GAAG,SAAS,MAAM,EAAE,CAEhF"}
package/lib/queue.js ADDED
@@ -0,0 +1,68 @@
1
+ import { projectionState } from "./agent/projections.js";
2
+ /**
3
+ * The prompts an agent has not taken yet.
4
+ *
5
+ * The harness owns pending input and records every append, claim, and
6
+ * cancellation as a durable splice; the `inbox` projection folds those into the
7
+ * two lists a claim drains. Reading that projection rather than keeping a list
8
+ * of our own is what makes a row disappear exactly when the message is taken —
9
+ * including when an interrupt discarded it — and what lets a resumed session
10
+ * show input that is still owed.
11
+ */
12
+ /** What a queued prompt shows when it carries no text block, so its row is never blank. */
13
+ const NO_TEXT = '(no text)';
14
+ /**
15
+ * The pending lists, in the order the harness delivers them.
16
+ *
17
+ * A step boundary claims next-step first and takes a queued turn after it, so
18
+ * this is also the order the reader's own rows reach the transcript in.
19
+ */
20
+ const TARGETS = ['next-step', 'next-turn'];
21
+ function asRecord(value) {
22
+ return typeof value === 'object' && value !== null ? value : undefined;
23
+ }
24
+ /**
25
+ * Whether a pending message is the reader's own input.
26
+ *
27
+ * Next-step also carries the contexts a tool or a plugin injects, which are
28
+ * machinery rather than something the reader is waiting to see delivered.
29
+ */
30
+ function fromHuman(message) {
31
+ return asRecord(message.source)?.kind === 'user';
32
+ }
33
+ /** The text one pending message carries; a thought is the model's, not the reader's words. */
34
+ function textOf(message) {
35
+ const blocks = Array.isArray(message.content) ? message.content : [];
36
+ const texts = [];
37
+ for (const block of blocks) {
38
+ const record = asRecord(block);
39
+ if (record?.type !== 'text' || typeof record.text !== 'string')
40
+ continue;
41
+ texts.push(record.text);
42
+ }
43
+ return texts.length === 0 ? NO_TEXT : texts.join('\n');
44
+ }
45
+ /** The reader's own prompts still waiting in one inbox projection state. */
46
+ export function promptsOf(state) {
47
+ const inbox = asRecord(state);
48
+ if (inbox === undefined)
49
+ return [];
50
+ const prompts = [];
51
+ for (const target of TARGETS) {
52
+ const pending = inbox[target];
53
+ if (!Array.isArray(pending))
54
+ continue;
55
+ for (const entry of pending) {
56
+ const message = asRecord(entry);
57
+ if (message === undefined || !fromHuman(message))
58
+ continue;
59
+ prompts.push(textOf(message));
60
+ }
61
+ }
62
+ return prompts;
63
+ }
64
+ /** The prompts one session's agent has not taken yet. */
65
+ export function pendingPrompts(ctx, session) {
66
+ return session === undefined ? [] : promptsOf(projectionState(ctx, session, 'inbox'));
67
+ }
68
+ //# sourceMappingURL=queue.js.map
@@ -0,0 +1 @@
1
+ {"version":3,"file":"queue.js","sourceRoot":"","sources":["../src/queue.ts"],"names":[],"mappings":"AACA,OAAO,EAAE,eAAe,EAAE,MAAM,wBAAwB,CAAA;AAExD;;;;;;;;;GASG;AAEH,2FAA2F;AAC3F,MAAM,OAAO,GAAG,WAAW,CAAA;AAE3B;;;;;GAKG;AACH,MAAM,OAAO,GAAG,CAAC,WAAW,EAAE,WAAW,CAAU,CAAA;AAEnD,SAAS,QAAQ,CAAC,KAAc;IAC9B,OAAO,OAAO,KAAK,KAAK,QAAQ,IAAI,KAAK,KAAK,IAAI,CAAC,CAAC,CAAC,KAAgC,CAAC,CAAC,CAAC,SAAS,CAAA;AACnG,CAAC;AAED;;;;;GAKG;AACH,SAAS,SAAS,CAAC,OAAgC;IACjD,OAAO,QAAQ,CAAC,OAAO,CAAC,MAAM,CAAC,EAAE,IAAI,KAAK,MAAM,CAAA;AAClD,CAAC;AAED,8FAA8F;AAC9F,SAAS,MAAM,CAAC,OAAgC;IAC9C,MAAM,MAAM,GAAG,KAAK,CAAC,OAAO,CAAC,OAAO,CAAC,OAAO,CAAC,CAAC,CAAC,CAAC,OAAO,CAAC,OAAO,CAAC,CAAC,CAAC,EAAE,CAAA;IACpE,MAAM,KAAK,GAAa,EAA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AAC,CAAC,SAAS,CAAC,eAAe,CAAC,GAAG,EAAE,OAAO,EAAE,OAAO,CAAC,CAAC,CAAA;AACvF,CAAC"}
@@ -0,0 +1,19 @@
1
+ /** Where a deferred notice prints once the surface owns the screen. */
2
+ export type NoticeSink = (message: string) => void;
3
+ /** A notice that waits until the surface can show it. */
4
+ export interface DeferredNotice {
5
+ /** Print through `sink` from now on, starting with anything held back. */
6
+ open(sink: NoticeSink): void;
7
+ /** Print the notice now, or hold it until {@link DeferredNotice.open}. */
8
+ post(message: string): void;
9
+ }
10
+ /**
11
+ * Hold a notice found before the alternate screen exists.
12
+ *
13
+ * The settings scope applies on its own schedule, so a section refused at boot
14
+ * is read either before the surface owns the screen or after it: one holder,
15
+ * opened when the screen is taken, keeps both orders honest — and a notice
16
+ * written to stderr alone would have been buried under the alternate screen.
17
+ */
18
+ export declare function createDeferredNotice(): DeferredNotice;
19
+ //# sourceMappingURL=settings-notice.d.ts.map
@@ -0,0 +1 @@
1
+ {"version":3,"file":"settings-notice.d.ts","sourceRoot":"","sources":["../src/settings-notice.ts"],"names":[],"mappings":"AAAA,uEAAuE;AACvE,MAAM,MAAM,UAAU,GAAG,CAAC,OAAO,EAAE,MAAM,KAAK,IAAI,CAAA;AAElD,yDAAyD;AACzD,MAAM,WAAW,cAAc;IAC7B,0EAA0E;IAC1E,IAAI,CAAC,IAAI,EAAE,UAAU,GAAG,IAAI,CAAA;IAC5B,0EAA0E;IAC1E,IAAI,CAAC,OAAO,EAAE,MAAM,GAAG,IAAI,CAAA;CAC5B;AAED;;;;;;;GAOG;AACH,wBAAgB,oBAAoB,IAAI,cAAc,CAmBrD"}
@@ -0,0 +1,30 @@
1
+ /**
2
+ * Hold a notice found before the alternate screen exists.
3
+ *
4
+ * The settings scope applies on its own schedule, so a section refused at boot
5
+ * is read either before the surface owns the screen or after it: one holder,
6
+ * opened when the screen is taken, keeps both orders honest — and a notice
7
+ * written to stderr alone would have been buried under the alternate screen.
8
+ */
9
+ export function createDeferredNotice() {
10
+ let sink;
11
+ let pending;
12
+ return {
13
+ open(next) {
14
+ sink = next;
15
+ if (pending === undefined)
16
+ return;
17
+ const held = pending;
18
+ pending = undefined;
19
+ next(held);
20
+ },
21
+ post(message) {
22
+ if (sink === undefined) {
23
+ pending = message;
24
+ return;
25
+ }
26
+ sink(message);
27
+ },
28
+ };
29
+ }
30
+ //# sourceMappingURL=settings-notice.js.map
@@ -0,0 +1 @@
1
+ {"version":3,"file":"settings-notice.js","sourceRoot":"","sources":["../src/settings-notice.ts"],"names":[],"mappings":"AAWA;;;;;;;GAOG;AACH,MAAM,UAAU,oBAAoB;IAClC,IAAI,IAA4B,CAAA;IAChC,IAAI,OAA2B,CAAA;IAC/B,OAAO;QACL,IAAI,CAAC,IAAI;YACP,IAAI,GAAG,IAAI,CAAA;YACX,IAAI,OAAO,KAAK,SAAS;gBAAE,OAAM;YACjC,MAAM,IAAI,GAAG,OAAO,CAAA;YACpB,OAAO,GAAG,SAAS,CAAA;YACnB,IAAI,CAAC,IAAI,CAAC,CAAA;QACZ,CAAC;QACD,IAAI,CAAC,OAAO;YACV,IAAI,IAAI,KAAK,SAAS,EAAE,CAAC;gBACvB,OAAO,GAAG,OAAO,CAAA;gBACjB,OAAM;YACR,CAAC;YACD,IAAI,CAAC,OAAO,CAAC,CAAA;QACf,CAAC;KACF,CAAA;AACH,CAAC"}
@@ -0,0 +1,72 @@
1
+ /** Which step failed after a write already committed, so the loss is never implied. */
2
+ export type StashFailurePhase = 'directory-sync' | 'lock-release';
3
+ export interface StashFailure {
4
+ readonly phase: StashFailurePhase;
5
+ readonly error: unknown;
6
+ }
7
+ /**
8
+ * A mutation that landed on disk while a later step failed.
9
+ *
10
+ * The write is not undone — reporting it as a failure would tell the reader
11
+ * their draft was lost when it is readable — so the failure travels beside the
12
+ * result and the caller reports success plus the warning.
13
+ */
14
+ export declare class StashCommittedError<Result = unknown> extends Error {
15
+ readonly committed = true;
16
+ readonly result: Result;
17
+ readonly failure: StashFailure;
18
+ /** Set when the lock could not be released either, so both are reported. */
19
+ readonly releaseFailure: StashFailure | undefined;
20
+ constructor(result: Result, failure: StashFailure, releaseFailure?: StashFailure);
21
+ }
22
+ export interface StashMutationResult<Result> {
23
+ readonly didPersist: boolean;
24
+ readonly result: Result;
25
+ }
26
+ interface LockOwner {
27
+ readonly pid: number;
28
+ readonly host: string;
29
+ readonly token: string;
30
+ readonly createdAt: string;
31
+ }
32
+ /** Take the file lock for a read that must not observe a half-written file. */
33
+ export declare function withStashFileLock<Result>(filePath: string, operation: () => Promise<Result>): Promise<Result>;
34
+ /**
35
+ * Take the lock for a mutation, and classify an unlock failure as committed.
36
+ *
37
+ * Only a callback that reports `didPersist` turns a failed unlock into a
38
+ * committed error: an unlock failure after a refused mutation is an ordinary
39
+ * failure.
40
+ */
41
+ export declare function withStashMutationLock<Result>(filePath: string, operation: () => Promise<StashMutationResult<Result>>): Promise<Result>;
42
+ /**
43
+ * The claim a reclaimer takes, named after the bank whose lock it guards.
44
+ *
45
+ * Exported because it is the path a timeout tells the reader to clear by hand.
46
+ */
47
+ export declare function reclaimMutexPath(lockDir: string): string;
48
+ /**
49
+ * What a reclaim is allowed to act on: one reading of the lock, with the
50
+ * identity of the directory it was read from.
51
+ *
52
+ * The owner bytes alone are not enough, because the directory that held them can
53
+ * be released and replaced between the reading and the removal. A lock is only
54
+ * removed when both the identity and the token still match what was judged.
55
+ */
56
+ export interface LockObservation {
57
+ readonly owner: LockOwner | undefined;
58
+ readonly device: number;
59
+ readonly inode: number;
60
+ readonly modified: number;
61
+ }
62
+ /** Read a lock and the identity of the directory it was read from, in one pass. */
63
+ export declare function observeLock(lockDir: string): Promise<LockObservation | undefined>;
64
+ /**
65
+ * Remove the lock a judgement was made about, and nothing that replaced it.
66
+ *
67
+ * Exported so the race this exists for can be driven from a test: hold an
68
+ * observation, publish a live lock in its place, and the removal has to refuse.
69
+ */
70
+ export declare function removeObservedLock(lockDir: string, observed: LockObservation): Promise<boolean>;
71
+ export {};
72
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