@dsh-cc/tui 0.5.0
This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
- package/LICENSE +201 -0
- package/README.md +144 -0
- package/lib/bash-history.d.ts +31 -0
- package/lib/bash-history.d.ts.map +1 -0
- package/lib/bash-history.js +94 -0
- package/lib/bash-history.js.map +1 -0
- package/lib/compact-fold.d.ts +35 -0
- package/lib/compact-fold.d.ts.map +1 -0
- package/lib/compact-fold.js +60 -0
- package/lib/compact-fold.js.map +1 -0
- package/lib/components/arg-completers.d.ts +22 -0
- package/lib/components/arg-completers.d.ts.map +1 -0
- package/lib/components/arg-completers.js +75 -0
- package/lib/components/arg-completers.js.map +1 -0
- package/lib/components/code-theme.d.ts +25 -0
- package/lib/components/code-theme.d.ts.map +1 -0
- package/lib/components/code-theme.js +137 -0
- package/lib/components/code-theme.js.map +1 -0
- package/lib/components/completion.d.ts +50 -0
- package/lib/components/completion.d.ts.map +1 -0
- package/lib/components/completion.js +279 -0
- package/lib/components/completion.js.map +1 -0
- package/lib/components/diff-card.d.ts +29 -0
- package/lib/components/diff-card.d.ts.map +1 -0
- package/lib/components/diff-card.js +175 -0
- package/lib/components/diff-card.js.map +1 -0
- package/lib/components/diff-hunks.d.ts +44 -0
- package/lib/components/diff-hunks.d.ts.map +1 -0
- package/lib/components/diff-hunks.js +188 -0
- package/lib/components/diff-hunks.js.map +1 -0
- package/lib/components/editor-history.d.ts +23 -0
- package/lib/components/editor-history.d.ts.map +1 -0
- package/lib/components/editor-history.js +29 -0
- package/lib/components/editor-history.js.map +1 -0
- package/lib/components/markdown-theme.d.ts +11 -0
- package/lib/components/markdown-theme.d.ts.map +1 -0
- package/lib/components/markdown-theme.js +29 -0
- package/lib/components/markdown-theme.js.map +1 -0
- package/lib/components/masked-input.d.ts +24 -0
- package/lib/components/masked-input.d.ts.map +1 -0
- package/lib/components/masked-input.js +168 -0
- package/lib/components/masked-input.js.map +1 -0
- package/lib/components/overlay-host.d.ts +31 -0
- package/lib/components/overlay-host.d.ts.map +1 -0
- package/lib/components/overlay-host.js +128 -0
- package/lib/components/overlay-host.js.map +1 -0
- package/lib/components/overlays.d.ts +94 -0
- package/lib/components/overlays.d.ts.map +1 -0
- package/lib/components/overlays.js +450 -0
- package/lib/components/overlays.js.map +1 -0
- package/lib/components/provider-box.d.ts +23 -0
- package/lib/components/provider-box.d.ts.map +1 -0
- package/lib/components/provider-box.js +164 -0
- package/lib/components/provider-box.js.map +1 -0
- package/lib/components/read-group.d.ts +51 -0
- package/lib/components/read-group.d.ts.map +1 -0
- package/lib/components/read-group.js +105 -0
- package/lib/components/read-group.js.map +1 -0
- package/lib/components/root-bash.d.ts +36 -0
- package/lib/components/root-bash.d.ts.map +1 -0
- package/lib/components/root-bash.js +112 -0
- package/lib/components/root-bash.js.map +1 -0
- package/lib/components/root-types.d.ts +42 -0
- package/lib/components/root-types.d.ts.map +1 -0
- package/lib/components/root-types.js +8 -0
- package/lib/components/root-types.js.map +1 -0
- package/lib/components/root-utils.d.ts +22 -0
- package/lib/components/root-utils.d.ts.map +1 -0
- package/lib/components/root-utils.js +45 -0
- package/lib/components/root-utils.js.map +1 -0
- package/lib/components/root.d.ts +25 -0
- package/lib/components/root.d.ts.map +1 -0
- package/lib/components/root.js +357 -0
- package/lib/components/root.js.map +1 -0
- package/lib/components/theme.d.ts +61 -0
- package/lib/components/theme.d.ts.map +1 -0
- package/lib/components/theme.js +99 -0
- package/lib/components/theme.js.map +1 -0
- package/lib/components/transcript.d.ts +43 -0
- package/lib/components/transcript.d.ts.map +1 -0
- package/lib/components/transcript.js +203 -0
- package/lib/components/transcript.js.map +1 -0
- package/lib/components/working-line.d.ts +35 -0
- package/lib/components/working-line.d.ts.map +1 -0
- package/lib/components/working-line.js +66 -0
- package/lib/components/working-line.js.map +1 -0
- package/lib/effort-catalog.d.ts +27 -0
- package/lib/effort-catalog.d.ts.map +1 -0
- package/lib/effort-catalog.js +36 -0
- package/lib/effort-catalog.js.map +1 -0
- package/lib/export-markdown.d.ts +18 -0
- package/lib/export-markdown.d.ts.map +1 -0
- package/lib/export-markdown.js +124 -0
- package/lib/export-markdown.js.map +1 -0
- package/lib/harness/approval-preview.d.ts +33 -0
- package/lib/harness/approval-preview.d.ts.map +1 -0
- package/lib/harness/approval-preview.js +179 -0
- package/lib/harness/approval-preview.js.map +1 -0
- package/lib/harness/boot-banner.d.ts +14 -0
- package/lib/harness/boot-banner.d.ts.map +1 -0
- package/lib/harness/boot-banner.js +89 -0
- package/lib/harness/boot-banner.js.map +1 -0
- package/lib/harness/driver-agent.d.ts +78 -0
- package/lib/harness/driver-agent.d.ts.map +1 -0
- package/lib/harness/driver-agent.js +314 -0
- package/lib/harness/driver-agent.js.map +1 -0
- package/lib/harness/driver-agents.d.ts +20 -0
- package/lib/harness/driver-agents.d.ts.map +1 -0
- package/lib/harness/driver-agents.js +123 -0
- package/lib/harness/driver-agents.js.map +1 -0
- package/lib/harness/driver-approvals.d.ts +38 -0
- package/lib/harness/driver-approvals.d.ts.map +1 -0
- package/lib/harness/driver-approvals.js +277 -0
- package/lib/harness/driver-approvals.js.map +1 -0
- package/lib/harness/driver-bash.d.ts +15 -0
- package/lib/harness/driver-bash.d.ts.map +1 -0
- package/lib/harness/driver-bash.js +73 -0
- package/lib/harness/driver-bash.js.map +1 -0
- package/lib/harness/driver-catalog.d.ts +84 -0
- package/lib/harness/driver-catalog.d.ts.map +1 -0
- package/lib/harness/driver-catalog.js +256 -0
- package/lib/harness/driver-catalog.js.map +1 -0
- package/lib/harness/driver-ctx.d.ts +462 -0
- package/lib/harness/driver-ctx.d.ts.map +1 -0
- package/lib/harness/driver-ctx.js +11 -0
- package/lib/harness/driver-ctx.js.map +1 -0
- package/lib/harness/driver-hud.d.ts +31 -0
- package/lib/harness/driver-hud.d.ts.map +1 -0
- package/lib/harness/driver-hud.js +204 -0
- package/lib/harness/driver-hud.js.map +1 -0
- package/lib/harness/driver-live.d.ts +36 -0
- package/lib/harness/driver-live.d.ts.map +1 -0
- package/lib/harness/driver-live.js +44 -0
- package/lib/harness/driver-live.js.map +1 -0
- package/lib/harness/driver-modal.d.ts +52 -0
- package/lib/harness/driver-modal.d.ts.map +1 -0
- package/lib/harness/driver-modal.js +78 -0
- package/lib/harness/driver-modal.js.map +1 -0
- package/lib/harness/driver-mode.d.ts +35 -0
- package/lib/harness/driver-mode.d.ts.map +1 -0
- package/lib/harness/driver-mode.js +84 -0
- package/lib/harness/driver-mode.js.map +1 -0
- package/lib/harness/driver-pickers.d.ts +48 -0
- package/lib/harness/driver-pickers.d.ts.map +1 -0
- package/lib/harness/driver-pickers.js +249 -0
- package/lib/harness/driver-pickers.js.map +1 -0
- package/lib/harness/driver-promote.d.ts +29 -0
- package/lib/harness/driver-promote.d.ts.map +1 -0
- package/lib/harness/driver-promote.js +36 -0
- package/lib/harness/driver-promote.js.map +1 -0
- package/lib/harness/driver-queue.d.ts +19 -0
- package/lib/harness/driver-queue.d.ts.map +1 -0
- package/lib/harness/driver-queue.js +281 -0
- package/lib/harness/driver-queue.js.map +1 -0
- package/lib/harness/driver-run-local.d.ts +32 -0
- package/lib/harness/driver-run-local.d.ts.map +1 -0
- package/lib/harness/driver-run-local.js +366 -0
- package/lib/harness/driver-run-local.js.map +1 -0
- package/lib/harness/driver-sessions.d.ts +28 -0
- package/lib/harness/driver-sessions.d.ts.map +1 -0
- package/lib/harness/driver-sessions.js +386 -0
- package/lib/harness/driver-sessions.js.map +1 -0
- package/lib/harness/driver.d.ts +22 -0
- package/lib/harness/driver.d.ts.map +1 -0
- package/lib/harness/driver.js +459 -0
- package/lib/harness/driver.js.map +1 -0
- package/lib/harness/preset.d.ts +32 -0
- package/lib/harness/preset.d.ts.map +1 -0
- package/lib/harness/preset.js +34 -0
- package/lib/harness/preset.js.map +1 -0
- package/lib/harness/session-list.d.ts +65 -0
- package/lib/harness/session-list.d.ts.map +1 -0
- package/lib/harness/session-list.js +91 -0
- package/lib/harness/session-list.js.map +1 -0
- package/lib/harness/shell-output.d.ts +44 -0
- package/lib/harness/shell-output.d.ts.map +1 -0
- package/lib/harness/shell-output.js +90 -0
- package/lib/harness/shell-output.js.map +1 -0
- package/lib/harness/statusline-cc-transcript.d.ts +51 -0
- package/lib/harness/statusline-cc-transcript.d.ts.map +1 -0
- package/lib/harness/statusline-cc-transcript.js +191 -0
- package/lib/harness/statusline-cc-transcript.js.map +1 -0
- package/lib/harness/statusline-command.d.ts +54 -0
- package/lib/harness/statusline-command.d.ts.map +1 -0
- package/lib/harness/statusline-command.js +161 -0
- package/lib/harness/statusline-command.js.map +1 -0
- package/lib/harness/statusline-payload.d.ts +79 -0
- package/lib/harness/statusline-payload.d.ts.map +1 -0
- package/lib/harness/statusline-payload.js +93 -0
- package/lib/harness/statusline-payload.js.map +1 -0
- package/lib/harness/statusline-settings.d.ts +47 -0
- package/lib/harness/statusline-settings.d.ts.map +1 -0
- package/lib/harness/statusline-settings.js +57 -0
- package/lib/harness/statusline-settings.js.map +1 -0
- package/lib/harness/statusline-wiring.d.ts +45 -0
- package/lib/harness/statusline-wiring.d.ts.map +1 -0
- package/lib/harness/statusline-wiring.js +247 -0
- package/lib/harness/statusline-wiring.js.map +1 -0
- package/lib/harness/usage-view.d.ts +84 -0
- package/lib/harness/usage-view.d.ts.map +1 -0
- package/lib/harness/usage-view.js +199 -0
- package/lib/harness/usage-view.js.map +1 -0
- package/lib/harness/worktree-exit.d.ts +105 -0
- package/lib/harness/worktree-exit.d.ts.map +1 -0
- package/lib/harness/worktree-exit.js +168 -0
- package/lib/harness/worktree-exit.js.map +1 -0
- package/lib/history.d.ts +50 -0
- package/lib/history.d.ts.map +1 -0
- package/lib/history.js +139 -0
- package/lib/history.js.map +1 -0
- package/lib/index.d.ts +63 -0
- package/lib/index.d.ts.map +1 -0
- package/lib/index.js +54 -0
- package/lib/index.js.map +1 -0
- package/lib/input.d.ts +158 -0
- package/lib/input.d.ts.map +1 -0
- package/lib/input.js +400 -0
- package/lib/input.js.map +1 -0
- package/lib/invariant.d.ts +14 -0
- package/lib/invariant.d.ts.map +1 -0
- package/lib/invariant.js +20 -0
- package/lib/invariant.js.map +1 -0
- package/lib/mode-cycle.d.ts +22 -0
- package/lib/mode-cycle.d.ts.map +1 -0
- package/lib/mode-cycle.js +32 -0
- package/lib/mode-cycle.js.map +1 -0
- package/lib/model-catalog.d.ts +22 -0
- package/lib/model-catalog.d.ts.map +1 -0
- package/lib/model-catalog.js +45 -0
- package/lib/model-catalog.js.map +1 -0
- package/lib/packaged-preset.d.ts +32 -0
- package/lib/packaged-preset.d.ts.map +1 -0
- package/lib/packaged-preset.js +94 -0
- package/lib/packaged-preset.js.map +1 -0
- package/lib/plugin.d.ts +11 -0
- package/lib/plugin.d.ts.map +1 -0
- package/lib/plugin.js +88 -0
- package/lib/plugin.js.map +1 -0
- package/lib/profile.d.ts +4 -0
- package/lib/profile.d.ts.map +1 -0
- package/lib/profile.js +7 -0
- package/lib/profile.js.map +1 -0
- package/lib/project-sessions.d.ts +29 -0
- package/lib/project-sessions.d.ts.map +1 -0
- package/lib/project-sessions.js +60 -0
- package/lib/project-sessions.js.map +1 -0
- package/lib/project.d.ts +75 -0
- package/lib/project.d.ts.map +1 -0
- package/lib/project.js +196 -0
- package/lib/project.js.map +1 -0
- package/lib/provider-actions.d.ts +37 -0
- package/lib/provider-actions.d.ts.map +1 -0
- package/lib/provider-actions.js +417 -0
- package/lib/provider-actions.js.map +1 -0
- package/lib/provider-command.d.ts +109 -0
- package/lib/provider-command.d.ts.map +1 -0
- package/lib/provider-command.js +220 -0
- package/lib/provider-command.js.map +1 -0
- package/lib/provider-detail.d.ts +15 -0
- package/lib/provider-detail.d.ts.map +1 -0
- package/lib/provider-detail.js +201 -0
- package/lib/provider-detail.js.map +1 -0
- package/lib/provider-flow.d.ts +191 -0
- package/lib/provider-flow.d.ts.map +1 -0
- package/lib/provider-flow.js +192 -0
- package/lib/provider-flow.js.map +1 -0
- package/lib/provider-presets.d.ts +32 -0
- package/lib/provider-presets.d.ts.map +1 -0
- package/lib/provider-presets.js +105 -0
- package/lib/provider-presets.js.map +1 -0
- package/lib/provider-read.d.ts +63 -0
- package/lib/provider-read.d.ts.map +1 -0
- package/lib/provider-read.js +115 -0
- package/lib/provider-read.js.map +1 -0
- package/lib/provider-settings.d.ts +30 -0
- package/lib/provider-settings.d.ts.map +1 -0
- package/lib/provider-settings.js +65 -0
- package/lib/provider-settings.js.map +1 -0
- package/lib/resume-target.d.ts +59 -0
- package/lib/resume-target.d.ts.map +1 -0
- package/lib/resume-target.js +143 -0
- package/lib/resume-target.js.map +1 -0
- package/lib/slash.d.ts +44 -0
- package/lib/slash.d.ts.map +1 -0
- package/lib/slash.js +81 -0
- package/lib/slash.js.map +1 -0
- package/lib/state/driver-types.d.ts +505 -0
- package/lib/state/driver-types.d.ts.map +1 -0
- package/lib/state/driver-types.js +8 -0
- package/lib/state/driver-types.js.map +1 -0
- package/lib/state/driver-usage-types.d.ts +59 -0
- package/lib/state/driver-usage-types.d.ts.map +1 -0
- package/lib/state/driver-usage-types.js +8 -0
- package/lib/state/driver-usage-types.js.map +1 -0
- package/lib/statusline.d.ts +63 -0
- package/lib/statusline.d.ts.map +1 -0
- package/lib/statusline.js +97 -0
- package/lib/statusline.js.map +1 -0
- package/lib/store/pickers.d.ts +34 -0
- package/lib/store/pickers.d.ts.map +1 -0
- package/lib/store/pickers.js +111 -0
- package/lib/store/pickers.js.map +1 -0
- package/lib/store/provider-panel.d.ts +107 -0
- package/lib/store/provider-panel.d.ts.map +1 -0
- package/lib/store/provider-panel.js +151 -0
- package/lib/store/provider-panel.js.map +1 -0
- package/lib/store/question.d.ts +21 -0
- package/lib/store/question.d.ts.map +1 -0
- package/lib/store/question.js +59 -0
- package/lib/store/question.js.map +1 -0
- package/lib/store/queue.d.ts +27 -0
- package/lib/store/queue.d.ts.map +1 -0
- package/lib/store/queue.js +34 -0
- package/lib/store/queue.js.map +1 -0
- package/lib/store/session.d.ts +73 -0
- package/lib/store/session.d.ts.map +1 -0
- package/lib/store/session.js +172 -0
- package/lib/store/session.js.map +1 -0
- package/lib/store/subagents.d.ts +16 -0
- package/lib/store/subagents.d.ts.map +1 -0
- package/lib/store/subagents.js +44 -0
- package/lib/store/subagents.js.map +1 -0
- package/lib/store/todos.d.ts +35 -0
- package/lib/store/todos.d.ts.map +1 -0
- package/lib/store/todos.js +68 -0
- package/lib/store/todos.js.map +1 -0
- package/lib/store/usage.d.ts +15 -0
- package/lib/store/usage.d.ts.map +1 -0
- package/lib/store/usage.js +27 -0
- package/lib/store/usage.js.map +1 -0
- package/lib/store/views.d.ts +419 -0
- package/lib/store/views.d.ts.map +1 -0
- package/lib/store/views.js +3 -0
- package/lib/store/views.js.map +1 -0
- package/lib/store.d.ts +19 -0
- package/lib/store.d.ts.map +1 -0
- package/lib/store.js +10 -0
- package/lib/store.js.map +1 -0
- package/lib/terminal/lease.d.ts +33 -0
- package/lib/terminal/lease.d.ts.map +1 -0
- package/lib/terminal/lease.js +99 -0
- package/lib/terminal/lease.js.map +1 -0
- package/lib/tool-card.d.ts +75 -0
- package/lib/tool-card.d.ts.map +1 -0
- package/lib/tool-card.js +109 -0
- package/lib/tool-card.js.map +1 -0
- package/lib/tool-verbs.d.ts +12 -0
- package/lib/tool-verbs.d.ts.map +1 -0
- package/lib/tool-verbs.js +29 -0
- package/lib/tool-verbs.js.map +1 -0
- package/lib/transcript.d.ts +40 -0
- package/lib/transcript.d.ts.map +1 -0
- package/lib/transcript.js +413 -0
- package/lib/transcript.js.map +1 -0
- package/lib/working-line.d.ts +44 -0
- package/lib/working-line.d.ts.map +1 -0
- package/lib/working-line.js +56 -0
- package/lib/working-line.js.map +1 -0
- package/package.json +72 -0
- package/presets/cc/.dsh-cc-managed.json +5 -0
- package/presets/cc/agent.cordis.yml +524 -0
- package/presets/cc/preset.yml +3 -0
- package/scripts/stage-preset.mjs +26 -0
|
@@ -0,0 +1,32 @@
|
|
|
1
|
+
/**
|
|
2
|
+
* Pure Shift+Tab cycle over CC permission-rule modes. Browser-safe and
|
|
3
|
+
* harness-free so the cycle cannot drift from the `/permissions` list.
|
|
4
|
+
* @module @dsh-cc/tui/mode-cycle
|
|
5
|
+
*/
|
|
6
|
+
import { PERMISSION_COMMAND_MODES, } from '@dsh-cc/command-permissions';
|
|
7
|
+
export { PERMISSION_COMMAND_MODES };
|
|
8
|
+
/** Cycle order matches `/permissions` advertisement. */
|
|
9
|
+
export const PERMISSION_CYCLE = PERMISSION_COMMAND_MODES;
|
|
10
|
+
/**
|
|
11
|
+
* Advance one step in the CC permission-mode cycle.
|
|
12
|
+
* @param current - the mode currently in force.
|
|
13
|
+
* @param bypassDisabled - when true, `bypassPermissions` is skipped.
|
|
14
|
+
* @returns the next mode (wraps to the first).
|
|
15
|
+
*/
|
|
16
|
+
export function nextPermissionMode(current, bypassDisabled = false) {
|
|
17
|
+
const list = bypassDisabled
|
|
18
|
+
? PERMISSION_CYCLE.filter(mode => mode !== 'bypassPermissions')
|
|
19
|
+
: PERMISSION_CYCLE;
|
|
20
|
+
const index = list.indexOf(current);
|
|
21
|
+
if (index === -1)
|
|
22
|
+
return list[0] ?? 'default';
|
|
23
|
+
return list[(index + 1) % list.length] ?? 'default';
|
|
24
|
+
}
|
|
25
|
+
/**
|
|
26
|
+
* Whether `mode` is one of the advertised CC permission modes.
|
|
27
|
+
* @param mode - untrusted user input.
|
|
28
|
+
*/
|
|
29
|
+
export function isPermissionMode(mode) {
|
|
30
|
+
return PERMISSION_CYCLE.includes(mode);
|
|
31
|
+
}
|
|
32
|
+
//# sourceMappingURL=mode-cycle.js.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"mode-cycle.js","sourceRoot":"","sources":["../src/mode-cycle.ts"],"names":[],"mappings":"AAAA;;;;GAIG;AAEH,OAAO,EACL,wBAAwB,GAEzB,MAAM,6BAA6B,CAAA;AAEpC,OAAO,EAAE,wBAAwB,EAA8B,CAAA;AAE/D,wDAAwD;AACxD,MAAM,CAAC,MAAM,gBAAgB,GAAqC,wBAAwB,CAAA;AAE1F;;;;;GAKG;AACH,MAAM,UAAU,kBAAkB,CAChC,OAAe,EACf,cAAc,GAAG,KAAK;IAEtB,MAAM,IAAI,GAAG,cAAc;QACzB,CAAC,CAAC,gBAAgB,CAAC,MAAM,CAAC,IAAI,CAAC,EAAE,CAAC,IAAI,KAAK,mBAAmB,CAAC;QAC/D,CAAC,CAAC,gBAAgB,CAAA;IACpB,MAAM,KAAK,GAAG,IAAI,CAAC,OAAO,CAAC,OAAgC,CAAC,CAAA;IAC5D,IAAI,KAAK,KAAK,CAAC,CAAC;QAAE,OAAO,IAAI,CAAC,CAAC,CAAC,IAAI,SAAS,CAAA;IAC7C,OAAO,IAAI,CAAC,CAAC,KAAK,GAAG,CAAC,CAAC,GAAG,IAAI,CAAC,MAAM,CAAC,IAAI,SAAS,CAAA;AACrD,CAAC;AAED;;;GAGG;AACH,MAAM,UAAU,gBAAgB,CAAC,IAAY;IAC3C,OAAQ,gBAAsC,CAAC,QAAQ,CAAC,IAAI,CAAC,CAAA;AAC/D,CAAC"}
|
|
@@ -0,0 +1,22 @@
|
|
|
1
|
+
/**
|
|
2
|
+
* Pure LLM catalog formatting and choice parsing for `/model`.
|
|
3
|
+
* @module @dsh-cc/tui/model-catalog
|
|
4
|
+
*/
|
|
5
|
+
export interface CatalogEntry {
|
|
6
|
+
provider: string;
|
|
7
|
+
id: string;
|
|
8
|
+
name: string;
|
|
9
|
+
}
|
|
10
|
+
export interface ModelRoute {
|
|
11
|
+
provider: string;
|
|
12
|
+
model: string;
|
|
13
|
+
}
|
|
14
|
+
/**
|
|
15
|
+
* Render advertised models, starring the live route.
|
|
16
|
+
*/
|
|
17
|
+
export declare function formatModelCatalog(catalog: readonly CatalogEntry[], current: ModelRoute | undefined): string;
|
|
18
|
+
/**
|
|
19
|
+
* Resolve a `/model` argument: 1-based index, `provider/id`, or a unique id.
|
|
20
|
+
*/
|
|
21
|
+
export declare function parseModelChoice(raw: string, catalog: readonly CatalogEntry[]): ModelRoute | undefined;
|
|
22
|
+
//# sourceMappingURL=model-catalog.d.ts.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"model-catalog.d.ts","sourceRoot":"","sources":["../src/model-catalog.ts"],"names":[],"mappings":"AAAA;;;GAGG;AAEH,MAAM,WAAW,YAAY;IAC3B,QAAQ,EAAE,MAAM,CAAA;IAChB,EAAE,EAAE,MAAM,CAAA;IACV,IAAI,EAAE,MAAM,CAAA;CACb;AAED,MAAM,WAAW,UAAU;IACzB,QAAQ,EAAE,MAAM,CAAA;IAChB,KAAK,EAAE,MAAM,CAAA;CACd;AAED;;GAEG;AACH,wBAAgB,kBAAkB,CAChC,OAAO,EAAE,SAAS,YAAY,EAAE,EAChC,OAAO,EAAE,UAAU,GAAG,SAAS,GAC9B,MAAM,CAUR;AAED;;GAEG;AACH,wBAAgB,gBAAgB,CAC9B,GAAG,EAAE,MAAM,EACX,OAAO,EAAE,SAAS,YAAY,EAAE,GAC/B,UAAU,GAAG,SAAS,CAmBxB"}
|
|
@@ -0,0 +1,45 @@
|
|
|
1
|
+
/**
|
|
2
|
+
* Pure LLM catalog formatting and choice parsing for `/model`.
|
|
3
|
+
* @module @dsh-cc/tui/model-catalog
|
|
4
|
+
*/
|
|
5
|
+
/**
|
|
6
|
+
* Render advertised models, starring the live route.
|
|
7
|
+
*/
|
|
8
|
+
export function formatModelCatalog(catalog, current) {
|
|
9
|
+
if (catalog.length === 0)
|
|
10
|
+
return 'No models are advertised by the mounted LLM adapters.';
|
|
11
|
+
return catalog.map((entry, index) => {
|
|
12
|
+
const key = `${entry.provider}/${entry.id}`;
|
|
13
|
+
const star = current !== undefined
|
|
14
|
+
&& current.provider === entry.provider
|
|
15
|
+
&& current.model === entry.id;
|
|
16
|
+
const mark = star ? '*' : ' ';
|
|
17
|
+
return `${mark} ${index + 1}. ${key} — ${entry.name}`;
|
|
18
|
+
}).join('\n');
|
|
19
|
+
}
|
|
20
|
+
/**
|
|
21
|
+
* Resolve a `/model` argument: 1-based index, `provider/id`, or a unique id.
|
|
22
|
+
*/
|
|
23
|
+
export function parseModelChoice(raw, catalog) {
|
|
24
|
+
const token = raw.trim();
|
|
25
|
+
if (token.length === 0)
|
|
26
|
+
return undefined;
|
|
27
|
+
if (/^\d+$/.test(token)) {
|
|
28
|
+
const index = Number.parseInt(token, 10) - 1;
|
|
29
|
+
const entry = catalog[index];
|
|
30
|
+
return entry === undefined ? undefined : { provider: entry.provider, model: entry.id };
|
|
31
|
+
}
|
|
32
|
+
const slash = token.indexOf('/');
|
|
33
|
+
if (slash > 0) {
|
|
34
|
+
const provider = token.slice(0, slash);
|
|
35
|
+
const model = token.slice(slash + 1);
|
|
36
|
+
const entry = catalog.find(item => item.provider === provider && item.id === model);
|
|
37
|
+
return entry === undefined ? undefined : { provider: entry.provider, model: entry.id };
|
|
38
|
+
}
|
|
39
|
+
const matches = catalog.filter(item => item.id === token);
|
|
40
|
+
if (matches.length !== 1)
|
|
41
|
+
return undefined;
|
|
42
|
+
const only = matches[0];
|
|
43
|
+
return { provider: only.provider, model: only.id };
|
|
44
|
+
}
|
|
45
|
+
//# sourceMappingURL=model-catalog.js.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"model-catalog.js","sourceRoot":"","sources":["../src/model-catalog.ts"],"names":[],"mappings":"AAAA;;;GAGG;AAaH;;GAEG;AACH,MAAM,UAAU,kBAAkB,CAChC,OAAgC,EAChC,OAA+B;IAE/B,IAAI,OAAO,CAAC,MAAM,KAAK,CAAC;QAAE,OAAO,uDAAuD,CAAA;IACxF,OAAO,OAAO,CAAC,GAAG,CAAC,CAAC,KAAK,EAAE,KAAK,EAAE,EAAE;QAClC,MAAM,GAAG,GAAG,GAAG,KAAK,CAAC,QAAQ,IAAI,KAAK,CAAC,EAAE,EAAE,CAAA;QAC3C,MAAM,IAAI,GAAG,OAAO,KAAK,SAAS;eAC7B,OAAO,CAAC,QAAQ,KAAK,KAAK,CAAC,QAAQ;eACn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AI,IAAI,CAAC,EAAE,KAAK,KAAK,CAAC,CAAA;QACnF,OAAO,KAAK,KAAK,SAAS,CAAC,CAAC,CAAC,SAAS,CAAC,CAAC,CAAC,EAAE,QAAQ,EAAE,KAAK,CAAC,QAAQ,EAAE,KAAK,EAAE,KAAK,CAAC,EAAE,EAAE,CAAA;IACxF,CAAC;IACD,MAAM,OAAO,GAAG,OAAO,CAAC,MAAM,CAAC,IAAI,CAAC,EAAE,CAAC,IAAI,CAAC,EAAE,KAAK,KAAK,CAAC,CAAA;IACzD,IAAI,OAAO,CAAC,MAAM,KAAK,CAAC;QAAE,OAAO,SAAS,CAAA;IAC1C,MAAM,IAAI,GAAG,OAAO,CAAC,CAAC,CAAE,CAAA;IACxB,OAAO,EAAE,QAAQ,EAAE,IAAI,CAAC,QAAQ,EAAE,KAAK,EAAE,IAAI,CAAC,EAAE,EAAE,CAAA;AACpD,CAAC"}
|
|
@@ -0,0 +1,32 @@
|
|
|
1
|
+
/**
|
|
2
|
+
* Materialize the CC preset into `$DSH_HOME/.agent-presets/cc`. The official
|
|
3
|
+
* launcher replaces system preset roots, so the user root is the supported
|
|
4
|
+
* extension seam (same pattern as dsh-TUI's packaged presets).
|
|
5
|
+
* @module @dsh-cc/tui/packaged-preset
|
|
6
|
+
*/
|
|
7
|
+
export declare const CC_PRESET_ID = "cc";
|
|
8
|
+
export interface ManagedMarker {
|
|
9
|
+
owner: string;
|
|
10
|
+
preset: string;
|
|
11
|
+
revision: string;
|
|
12
|
+
}
|
|
13
|
+
export type PackagedPresetStatus = 'installed' | 'updated' | 'current' | 'conflict' | 'missing-source';
|
|
14
|
+
export interface PackagedPresetResult {
|
|
15
|
+
id: string;
|
|
16
|
+
status: PackagedPresetStatus;
|
|
17
|
+
}
|
|
18
|
+
export interface PackagedPresetOptions {
|
|
19
|
+
dshHome?: string;
|
|
20
|
+
sourceRoot?: string;
|
|
21
|
+
revision?: string;
|
|
22
|
+
}
|
|
23
|
+
/**
|
|
24
|
+
* Resolve the packaged preset directory (src layout or compiled `presets/cc`).
|
|
25
|
+
*/
|
|
26
|
+
export declare function packagedPresetRoot(moduleUrl?: string): string | undefined;
|
|
27
|
+
/**
|
|
28
|
+
* Copy the CC preset into the user root when missing or stale. Never overwrites
|
|
29
|
+
* an unmarked directory (a person authored that id).
|
|
30
|
+
*/
|
|
31
|
+
export declare function ensurePackagedPreset(options?: PackagedPresetOptions): PackagedPresetResult;
|
|
32
|
+
//# sourceMappingURL=packaged-preset.d.ts.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"packaged-preset.d.ts","sourceRoot":"","sources":["../src/packaged-preset.ts"],"names":[],"mappings":"AAAA;;;;;GAKG;AAkBH,eAAO,MAAM,YAAY,OAAO,CAAA;AAEhC,MAAM,WAAW,aAAa;IAC5B,KAAK,EAAE,MAAM,CAAA;IACb,MAAM,EAAE,MAAM,CAAA;IACd,QAAQ,EAAE,MAAM,CAAA;CACjB;AAED,MAAM,MAAM,oBAAoB,GAAG,WAAW,GAAG,SAAS,GAAG,SAAS,GAAG,UAAU,GAAG,gBAAgB,CAAA;AAEtG,MAAM,WAAW,oBAAoB;IACnC,EAAE,EAAE,MAAM,CAAA;IACV,MAAM,EAAE,oBAAoB,CAAA;CAC7B;AAED,MAAM,WAAW,qBAAqB;IACpC,OAAO,CAAC,EAAE,MAAM,CAAA;IAChB,UAAU,CAAC,EAAE,MAAM,CAAA;IACnB,QAAQ,CAAC,EAAE,MAAM,CAAA;CAClB;AAmBD;;GAEG;AACH,wBAAgB,kBAAkB,CAAC,SAAS,GAAE,MAAwB,GAAG,MAAM,GAAG,SAAS,CAS1F;AAOD;;;GAGG;AACH,wBAAgB,oBAAoB,CAAC,OAAO,GAAE,qBAA0B,GAAG,oBAAoB,CA2C9F"}
|
|
@@ -0,0 +1,94 @@
|
|
|
1
|
+
/**
|
|
2
|
+
* Materialize the CC preset into `$DSH_HOME/.agent-presets/cc`. The official
|
|
3
|
+
* launcher replaces system preset roots, so the user root is the supported
|
|
4
|
+
* extension seam (same pattern as dsh-TUI's packaged presets).
|
|
5
|
+
* @module @dsh-cc/tui/packaged-preset
|
|
6
|
+
*/
|
|
7
|
+
import { cpSync, existsSync, mkdirSync, readFileSync, renameSync, rmSync, writeFileSync, } from 'node:fs';
|
|
8
|
+
import { homedir } from 'node:os';
|
|
9
|
+
import { dirname, join } from 'node:path';
|
|
10
|
+
import { fileURLToPath } from 'node:url';
|
|
11
|
+
import { randomUUID } from 'node:crypto';
|
|
12
|
+
const OWNER = '@dsh-cc/tui';
|
|
13
|
+
const MARKER = '.dsh-cc-managed.json';
|
|
14
|
+
export const CC_PRESET_ID = 'cc';
|
|
15
|
+
function readMarker(directory) {
|
|
16
|
+
try {
|
|
17
|
+
const value = JSON.parse(readFileSync(join(directory, MARKER), 'utf8'));
|
|
18
|
+
if (value.owner === OWNER
|
|
19
|
+
&& typeof value.preset === 'string'
|
|
20
|
+
&& typeof value.revision === 'string'
|
|
21
|
+
&& value.revision.length > 0) {
|
|
22
|
+
return value;
|
|
23
|
+
}
|
|
24
|
+
}
|
|
25
|
+
catch {
|
|
26
|
+
// Absent or user-authored marker: not ours.
|
|
27
|
+
}
|
|
28
|
+
return undefined;
|
|
29
|
+
}
|
|
30
|
+
/**
|
|
31
|
+
* Resolve the packaged preset directory (src layout or compiled `presets/cc`).
|
|
32
|
+
*/
|
|
33
|
+
export function packagedPresetRoot(moduleUrl = import.meta.url) {
|
|
34
|
+
const directory = dirname(fileURLToPath(moduleUrl));
|
|
35
|
+
const candidates = [
|
|
36
|
+
join(directory, '../presets', CC_PRESET_ID),
|
|
37
|
+
join(directory, '../../presets', CC_PRESET_ID),
|
|
38
|
+
join(directory, '../../../preset/cc'),
|
|
39
|
+
join(directory, '../../../../preset/cc'),
|
|
40
|
+
];
|
|
41
|
+
return candidates.find(candidate => existsSync(join(candidate, 'agent.cordis.yml')));
|
|
42
|
+
}
|
|
43
|
+
function writeMarker(directory, revision) {
|
|
44
|
+
const marker = { owner: OWNER, preset: CC_PRESET_ID, revision };
|
|
45
|
+
writeFileSync(join(directory, MARKER), `${JSON.stringify(marker, null, 2)}\n`);
|
|
46
|
+
}
|
|
47
|
+
/**
|
|
48
|
+
* Copy the CC preset into the user root when missing or stale. Never overwrites
|
|
49
|
+
* an unmarked directory (a person authored that id).
|
|
50
|
+
*/
|
|
51
|
+
export function ensurePackagedPreset(options = {}) {
|
|
52
|
+
const source = options.sourceRoot ?? packagedPresetRoot();
|
|
53
|
+
if (source === undefined || !existsSync(join(source, 'agent.cordis.yml'))) {
|
|
54
|
+
return { id: CC_PRESET_ID, status: 'missing-source' };
|
|
55
|
+
}
|
|
56
|
+
const revision = options.revision
|
|
57
|
+
?? (existsSync(join(source, MARKER)) ? readMarker(source)?.revision : undefined)
|
|
58
|
+
?? '0.1.0';
|
|
59
|
+
const dshHome = options.dshHome ?? process.env.DSH_HOME ?? join(homedir(), '.dsh');
|
|
60
|
+
const targetRoot = join(dshHome, '.agent-presets');
|
|
61
|
+
const target = join(targetRoot, CC_PRESET_ID);
|
|
62
|
+
if (!existsSync(target)) {
|
|
63
|
+
mkdirSync(targetRoot, { recursive: true });
|
|
64
|
+
cpSync(source, target, { recursive: true, force: false, errorOnExist: true, filter: () => true });
|
|
65
|
+
writeMarker(target, revision);
|
|
66
|
+
return { id: CC_PRESET_ID, status: 'installed' };
|
|
67
|
+
}
|
|
68
|
+
const targetMarker = readMarker(target);
|
|
69
|
+
if (targetMarker === undefined || targetMarker.preset !== CC_PRESET_ID) {
|
|
70
|
+
return { id: CC_PRESET_ID, status: 'conflict' };
|
|
71
|
+
}
|
|
72
|
+
if (targetMarker.revision === revision) {
|
|
73
|
+
return { id: CC_PRESET_ID, status: 'current' };
|
|
74
|
+
}
|
|
75
|
+
const suffix = `${process.pid}-${randomUUID()}`;
|
|
76
|
+
const staged = join(targetRoot, `.${CC_PRESET_ID}.staged-${suffix}`);
|
|
77
|
+
const backup = join(targetRoot, `.${CC_PRESET_ID}.backup-${suffix}`);
|
|
78
|
+
mkdirSync(staged, { recursive: true });
|
|
79
|
+
cpSync(source, staged, { recursive: true, force: true, filter: () => true });
|
|
80
|
+
writeMarker(staged, revision);
|
|
81
|
+
try {
|
|
82
|
+
renameSync(target, backup);
|
|
83
|
+
renameSync(staged, target);
|
|
84
|
+
rmSync(backup, { recursive: true, force: true });
|
|
85
|
+
}
|
|
86
|
+
catch (error) {
|
|
87
|
+
if (!existsSync(target) && existsSync(backup))
|
|
88
|
+
renameSync(backup, target);
|
|
89
|
+
rmSync(staged, { recursive: true, force: true });
|
|
90
|
+
throw error;
|
|
91
|
+
}
|
|
92
|
+
return { id: CC_PRESET_ID, status: 'updated' };
|
|
93
|
+
}
|
|
94
|
+
//# sourceMappingURL=packaged-preset.js.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"packaged-preset.js","sourceRoot":"","sources":["../src/packaged-preset.ts"],"names":[],"mappings":"AAAA;;;;;GAKG;AAEH,OAAO,EACL,MAAM,EACN,UAAU,EACV,SAAS,EACT,YAAY,EACZ,UAAU,EACV,MAAM,EACN,aAAa,GACd,MAAM,SAAS,CAAA;AAChB,OAAO,EAAE,OAAO,EAAE,MAAM,SAAS,CAAA;AACjC,OAAO,EAAE,OAAO,EAAE,IAAI,EAAE,MAAM,WAAW,CAAA;AACzC,OAAO,EAAE,aAAa,EAAE,MAAM,UAAU,CAAA;AACxC,OAAO,EAAE,UAAU,EAAE,MAAM,aAAa,CAAA;AAExC,MAAM,KAAK,GAAG,aAAa,CAAA;AAC3B,MAAM,MAAM,GAAG,sBAAsB,CAAA;AACrC,MAAM,CAAC,MAAM,YAAY,GAAG,IAAI,CAAA;AAqBhC,SAAS,UAAU,CAAC,SAAiB;IACnC,IAAI,CAAC;QACH,MAAM,KAAK,GAAG,IAAI,CAAC,KAAK,CAAC,YAAY,CAAC,IAAI,CAAC,SAAS,EAAE,MAAM,CAAC,EAAE,MAAM,CAAC,CAA2B,CAAA;QACjG,IACE,KAAK,CAAC,K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EAAE,IAAI,EAAE,CAAC,CAAA;QAChD,MAAM,KAAK,CAAA;IACb,CAAC;IACD,OAAO,EAAE,EAAE,EAAE,YAAY,EAAE,MAAM,EAAE,SAAS,EAAE,CAAA;AAChD,CAAC"}
|
package/lib/plugin.d.ts
ADDED
|
@@ -0,0 +1,11 @@
|
|
|
1
|
+
/**
|
|
2
|
+
* Boot wiring: packaged CC preset, TTY lease, driver, pi-tui mount.
|
|
3
|
+
* @module @dsh-cc/tui/plugin
|
|
4
|
+
*/
|
|
5
|
+
import type { Context } from '@deepseek-ai/cordis';
|
|
6
|
+
import type { Config } from './index.ts';
|
|
7
|
+
/**
|
|
8
|
+
* Start the TUI inside a dsh process.
|
|
9
|
+
*/
|
|
10
|
+
export declare function mountTui(ctx: Context, config: Config): Promise<void>;
|
|
11
|
+
//# sourceMappingURL=plugin.d.ts.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"plugin.d.ts","sourceRoot":"","sources":["../src/plugin.ts"],"names":[],"mappings":"AAAA;;;GAGG;AAEH,OAAO,KAAK,EAAE,OAAO,EAAE,MAAM,qBAAqB,CAAA;AAClD,OAAO,KAAK,EAAE,MAAM,EAAE,MAAM,YAAY,CAAA;AAMxC;;GAEG;AACH,wBAAsB,QAAQ,CAAC,GAAG,EAAE,OAAO,EAAE,MAAM,EAAE,MAAM,GAAG,OAAO,CAAC,IAAI,CAAC,CAoF1E"}
|
package/lib/plugin.js
ADDED
|
@@ -0,0 +1,88 @@
|
|
|
1
|
+
/**
|
|
2
|
+
* Boot wiring: packaged CC preset, TTY lease, driver, pi-tui mount.
|
|
3
|
+
* @module @dsh-cc/tui/plugin
|
|
4
|
+
*/
|
|
5
|
+
import { createDriver } from "./harness/driver.js";
|
|
6
|
+
import { ensurePackagedPreset } from "./packaged-preset.js";
|
|
7
|
+
import { acquireTerminal } from "./terminal/lease.js";
|
|
8
|
+
import { buildRoot } from "./components/root.js";
|
|
9
|
+
/**
|
|
10
|
+
* Start the TUI inside a dsh process.
|
|
11
|
+
*/
|
|
12
|
+
export async function mountTui(ctx, config) {
|
|
13
|
+
const packaged = ensurePackagedPreset();
|
|
14
|
+
if (packaged.status === 'conflict') {
|
|
15
|
+
ctx.logger.warn('dsh-cc-tui: ~/.dsh/.agent-presets/cc exists and is not managed by this package; leaving it in place');
|
|
16
|
+
}
|
|
17
|
+
else if (packaged.status === 'missing-source') {
|
|
18
|
+
ctx.logger.warn('dsh-cc-tui: packaged CC preset files were not found next to the plugin; '
|
|
19
|
+
+ 'ensure ~/.dsh/.agent-presets/cc exists (dsh-cc or scripts/sync-cc-preset.sh)');
|
|
20
|
+
}
|
|
21
|
+
const driver = await createDriver(ctx, {
|
|
22
|
+
...config.cwd === undefined ? {} : { cwd: config.cwd },
|
|
23
|
+
...config.agentPreset === undefined ? {} : { agentPreset: config.agentPreset },
|
|
24
|
+
...config.sessionId === undefined
|
|
25
|
+
? {}
|
|
26
|
+
: { sessionId: config.sessionId },
|
|
27
|
+
...config.autoResume === undefined ? {} : { autoResume: config.autoResume },
|
|
28
|
+
...config.continueRequested === undefined ? {} : { continueRequested: config.continueRequested },
|
|
29
|
+
...config.provider === undefined || config.provider.length === 0
|
|
30
|
+
? {}
|
|
31
|
+
: { provider: config.provider },
|
|
32
|
+
...config.model === undefined || config.model.length === 0
|
|
33
|
+
? {}
|
|
34
|
+
: { model: config.model },
|
|
35
|
+
// /copy hands the OSC 52 sequence to the live terminal (`root` is assigned
|
|
36
|
+
// below, before any command can run — same late-binding pattern as the
|
|
37
|
+
// shutdown closure).
|
|
38
|
+
copyWrite: (sequence) => {
|
|
39
|
+
root.tui.terminal.write(sequence);
|
|
40
|
+
},
|
|
41
|
+
// The driver owns the /quit finalizer (worktree-exit decisions included),
|
|
42
|
+
// so process shutdown hooks here as a late-bound closure — `shutdown` is
|
|
43
|
+
// defined just below and not yet assigned, which is safe because this
|
|
44
|
+
// only runs once a quit decision actually settles.
|
|
45
|
+
onQuit: () => {
|
|
46
|
+
shutdown();
|
|
47
|
+
},
|
|
48
|
+
});
|
|
49
|
+
if (process.stdin.isTTY) {
|
|
50
|
+
process.stdin.setEncoding('utf8');
|
|
51
|
+
process.stdin.resume();
|
|
52
|
+
}
|
|
53
|
+
let shuttingDown = false;
|
|
54
|
+
const shutdown = () => {
|
|
55
|
+
if (shuttingDown)
|
|
56
|
+
return;
|
|
57
|
+
shuttingDown = true;
|
|
58
|
+
try {
|
|
59
|
+
root.destroy();
|
|
60
|
+
root.stopForExit();
|
|
61
|
+
}
|
|
62
|
+
catch {
|
|
63
|
+
// best-effort
|
|
64
|
+
}
|
|
65
|
+
void driver.dispose().finally(() => {
|
|
66
|
+
lease.release();
|
|
67
|
+
process.exit(0);
|
|
68
|
+
});
|
|
69
|
+
};
|
|
70
|
+
const lease = acquireTerminal({
|
|
71
|
+
onSignal: () => {
|
|
72
|
+
shutdown();
|
|
73
|
+
},
|
|
74
|
+
});
|
|
75
|
+
const root = buildRoot(driver, {
|
|
76
|
+
onQuit: shutdown,
|
|
77
|
+
...(config.uiMode === undefined ? {} : { uiMode: config.uiMode }),
|
|
78
|
+
...(config.mouse === undefined ? {} : { mouse: config.mouse }),
|
|
79
|
+
...(config.theme === undefined ? {} : { theme: config.theme }),
|
|
80
|
+
});
|
|
81
|
+
root.tui.start();
|
|
82
|
+
ctx.effect(() => () => {
|
|
83
|
+
lease.release();
|
|
84
|
+
root.destroy();
|
|
85
|
+
void driver.dispose();
|
|
86
|
+
});
|
|
87
|
+
}
|
|
88
|
+
//# sourceMappingURL=plugin.js.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"plugin.js","sourceRoot":"","sources":["../src/plugin.ts"],"names":[],"mappings":"AAAA;;;GAGG;AAIH,OAAO,EAAE,YAAY,EAAE,MAAM,qBAAqB,CAAA;AAClD,OAAO,EAAE,oBAAoB,EAAE,MAAM,sBAAsB,CAAA;AAC3D,OAAO,EAAE,eAAe,EAAE,MAAM,qBAAqB,CAAA;AACrD,OAAO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const DSH_PROFILE_ENV = 'DSH_CC_PROFILE';
|
|
2
|
+
export const DEFAULT_DSH_PROFILE = 'tui';
|
|
3
|
+
export function resolveDshProfile(env = process.env) {
|
|
4
|
+
const value = env[DSH_PROFILE_ENV];
|
|
5
|
+
return typeof value === 'string' && value.length > 0 ? value : DEFAULT_DSH_PROFILE;
|
|
6
|
+
}
|
|
7
|
+
//# sourceMappingURL=profile.js.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"profile.js","sourceRoot":"","sources":["../src/profile.ts"],"names":[],"mappings":"AAAA,MAAM,CAAC,MAAM,eAAe,GAAG,gBAAgB,CAAA;AAC/C,MAAM,CAAC,MAAM,mBAAmB,GAAG,KAAK,CAAA;AAExC,MAAM,UAAU,iBAAiB,CAAC,MAAuC,OAAO,CAAC,GAAG;IAClF,MAAM,KAAK,GAAG,GAAG,CAAC,eAAe,CAAC,CAAA;IAClC,OAAO,OAAO,KAAK,KAAK,QAAQ,IAAI,KAAK,CAAC,MAAM,GAAG,CAAC,CAAC,CAAC,CAAC,KAAK,CAAC,CAAC,CAAC,mBAAmB,CAAA;AACpF,CAAC"}
|
|
@@ -0,0 +1,29 @@
|
|
|
1
|
+
/**
|
|
2
|
+
* Per-project session index (sidecar). Session records live in harness
|
|
3
|
+
* persistence and carry only a raw `cwd`; this sidecar pins the sessions a
|
|
4
|
+
* project OWNS without depending on the host for new header fields. One
|
|
5
|
+
* file per project bucket: `$DSH_HOME/tui/projects/<key>/sessions.txt`,
|
|
6
|
+
* one session id per line.
|
|
7
|
+
*
|
|
8
|
+
* Membership in the /resume picker is `id ∈ index ∨ cwd-prefix heuristic`
|
|
9
|
+
* (see session-list): the index is exact for sessions written after it
|
|
10
|
+
* existed, the heuristic covers legacy sessions and worktree cwds. fs
|
|
11
|
+
* access is best-effort throughout — a missing or unwritable file degrades
|
|
12
|
+
* to an empty index and never breaks a session.
|
|
13
|
+
*
|
|
14
|
+
* @module @dsh-cc/tui/project-sessions
|
|
15
|
+
*/
|
|
16
|
+
/** Absolute path of the index file inside a project bucket directory. */
|
|
17
|
+
export declare function projectSessionsFile(bucketDir: string): string;
|
|
18
|
+
/**
|
|
19
|
+
* Read the indexed session ids. Missing or unreadable file → empty set;
|
|
20
|
+
* blank lines are ignored.
|
|
21
|
+
*/
|
|
22
|
+
export declare function readProjectSessionIds(bucketDir: string): Set<string>;
|
|
23
|
+
/**
|
|
24
|
+
* Append a session id to the index unless already present. Best-effort: fs
|
|
25
|
+
* failures are swallowed (the cwd-prefix heuristic still covers the
|
|
26
|
+
* session in the common case).
|
|
27
|
+
*/
|
|
28
|
+
export declare function recordProjectSessionId(bucketDir: string, sessionId: string): void;
|
|
29
|
+
//# sourceMappingURL=project-sessions.d.ts.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"project-sessions.d.ts","sourceRoot":"","sources":["../src/project-sessions.ts"],"names":[],"mappings":"AAAA;;;;;;;;;;;;;;GAcG;AAKH,yEAAyE;AACzE,wBAAgB,mBAAmB,CAAC,SAAS,EAAE,MAAM,GAAG,MAAM,CAE7D;AAED;;;GAGG;AACH,wBAAgB,qBAAqB,CAAC,SAAS,EAAE,MAAM,GAAG,GAAG,CAAC,MAAM,CAAC,CAYpE;AAED;;;;GAIG;AACH,wBAAgB,sBAAsB,CAAC,SAAS,EAAE,MAAM,EAAE,SAAS,EAAE,MAAM,GAAG,IAAI,CAUjF"}
|
|
@@ -0,0 +1,60 @@
|
|
|
1
|
+
/**
|
|
2
|
+
* Per-project session index (sidecar). Session records live in harness
|
|
3
|
+
* persistence and carry only a raw `cwd`; this sidecar pins the sessions a
|
|
4
|
+
* project OWNS without depending on the host for new header fields. One
|
|
5
|
+
* file per project bucket: `$DSH_HOME/tui/projects/<key>/sessions.txt`,
|
|
6
|
+
* one session id per line.
|
|
7
|
+
*
|
|
8
|
+
* Membership in the /resume picker is `id ∈ index ∨ cwd-prefix heuristic`
|
|
9
|
+
* (see session-list): the index is exact for sessions written after it
|
|
10
|
+
* existed, the heuristic covers legacy sessions and worktree cwds. fs
|
|
11
|
+
* access is best-effort throughout — a missing or unwritable file degrades
|
|
12
|
+
* to an empty index and never breaks a session.
|
|
13
|
+
*
|
|
14
|
+
* @module @dsh-cc/tui/project-sessions
|
|
15
|
+
*/
|
|
16
|
+
import { appendFileSync, mkdirSync, readFileSync } from 'node:fs';
|
|
17
|
+
import { join } from 'node:path';
|
|
18
|
+
/** Absolute path of the index file inside a project bucket directory. */
|
|
19
|
+
export function projectSessionsFile(bucketDir) {
|
|
20
|
+
return join(bucketDir, 'sessions.txt');
|
|
21
|
+
}
|
|
22
|
+
/**
|
|
23
|
+
* Read the indexed session ids. Missing or unreadable file → empty set;
|
|
24
|
+
* blank lines are ignored.
|
|
25
|
+
*/
|
|
26
|
+
export function readProjectSessionIds(bucketDir) {
|
|
27
|
+
try {
|
|
28
|
+
const content = readFileSync(projectSessionsFile(bucketDir), 'utf8');
|
|
29
|
+
const ids = new Set();
|
|
30
|
+
for (const line of content.split('\n')) {
|
|
31
|
+
const id = line.trim();
|
|
32
|
+
if (id.length > 0)
|
|
33
|
+
ids.add(id);
|
|
34
|
+
}
|
|
35
|
+
return ids;
|
|
36
|
+
}
|
|
37
|
+
catch {
|
|
38
|
+
return new Set();
|
|
39
|
+
}
|
|
40
|
+
}
|
|
41
|
+
/**
|
|
42
|
+
* Append a session id to the index unless already present. Best-effort: fs
|
|
43
|
+
* failures are swallowed (the cwd-prefix heuristic still covers the
|
|
44
|
+
* session in the common case).
|
|
45
|
+
*/
|
|
46
|
+
export function recordProjectSessionId(bucketDir, sessionId) {
|
|
47
|
+
const id = sessionId.trim();
|
|
48
|
+
if (id.length === 0)
|
|
49
|
+
return;
|
|
50
|
+
try {
|
|
51
|
+
if (readProjectSessionIds(bucketDir).has(id))
|
|
52
|
+
return;
|
|
53
|
+
mkdirSync(bucketDir, { recursive: true });
|
|
54
|
+
appendFileSync(projectSessionsFile(bucketDir), `${id}\n`);
|
|
55
|
+
}
|
|
56
|
+
catch {
|
|
57
|
+
// Best-effort — the index is a picker nicety, never session-critical.
|
|
58
|
+
}
|
|
59
|
+
}
|
|
60
|
+
//# sourceMappingURL=project-sessions.js.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"project-sessions.js","sourceRoot":"","sources":["../src/project-sessions.ts"],"names":[],"mappings":"AAAA;;;;;;;;;;;;;;GAcG;AAEH,OAAO,EAAE,cAAc,EAAE,SAAS,EAAE,YAAY,EAAE,MAAM,SAAS,CAAA;AACjE,OAAO,EAAE,IAAI,EAAE,MAAM,WAAW,CAAA;AAEhC,yEAAyE;AACzE,MAAM,UAAU,mBAAmB,CAAC,SAAiB;IACnD,OAAO,IAAI,CAAC,SAAS,EAAE,cAAc,CAAC,CAAA;AACxC,CAAC;AAED;;;GAGG;AACH,MAAM,UAAU,qBAAqB,CAAC,SAAiB;IACrD,IAAI,CAAC;QACH,MAAM,OAAO,GAAG,YAAY,CAAC,mBAAmB,CAAC,SAAS,CAAC,EAAE,MAAM,CAAC,CAAA;QACpE,MAAM,GAAG,GAAG,IAAI,GAAG,EAAU,CAAA;QAC7B,KAAK,MAAM,IAAI,IAAI,OAAO,CAAC,KAAK,CAAC,IAAI,CAAC,EAAE,CAAC;YACvC,MAAM,EAAE,GAAG,IAAI,CAAC,IAAI,EAAE,CAAA;YACtB,IAAI,EAAE,CAAC,MAAM,GAAG,CAAC;gBAAE,GAAG,CAAC,GAAG,CAAC,EAAE,CAAC,CAAA;QAChC,CAAC;QACD,OAAO,GAAG,CAAA;IACZ,CAAC;IAAC,MAAM,CAAC;QACP,OAAO,IAAI,GAAG,EAAE,CAAA;IAClB,CAAC;AACH,CAAC;AAED;;;;GAIG;AACH,MAAM,UAAU,sBAAsB,CAAC,SAAiB,EAAE,SAAiB;IACzE,MAAM,EAAE,GAAG,SAAS,CAAC,IAAI,EAAE,CAAA;IAC3B,IAAI,EAAE,CAAC,MAAM,KAAK,CAAC;QAAE,OAAM;IAC3B,IAAI,CAAC;QACH,IAAI,qBAAqB,CAAC,SAAS,CAAC,CAAC,GAAG,CAAC,EAAE,CAAC;YAAE,OAAM;QACpD,SAAS,CAAC,SAAS,EAAE,EAAE,SAAS,EAAE,IAAI,EAAE,CAAC,CAAA;QACzC,cAAc,CAAC,mBAAmB,CAAC,SAAS,CAAC,EAAE,GAAG,EAAE,IAAI,CAAC,CAAA;IAC3D,CAAC;IAAC,MAAM,CAAC;QACP,sEAAsE;IACxE,CAAC;AACH,CAAC"}
|
package/lib/project.d.ts
ADDED
|
@@ -0,0 +1,75 @@
|
|
|
1
|
+
/**
|
|
2
|
+
* Project (working-directory identity) resolution for session management.
|
|
3
|
+
*
|
|
4
|
+
* A "project" is the namespace sessions, resume markers, and input history
|
|
5
|
+
* share. For a cwd inside a git repository the project is pinned to the
|
|
6
|
+
* *main repo root*, so an isolation worktree (`--worktree`,
|
|
7
|
+
* `.claude/worktrees/<slug>`) keeps the same project as its main checkout;
|
|
8
|
+
* for a cwd outside git the project is the directory itself. Every member
|
|
9
|
+
* path is `resolve()`d to a canonical absolute form and keyed by a short
|
|
10
|
+
* sha256 of the project root (deliberately not a lossy string encoding like
|
|
11
|
+
* Claude Code's `-` separator scheme — see design).
|
|
12
|
+
*
|
|
13
|
+
* All git probing runs through an injectable synchronous exec so tests never
|
|
14
|
+
* spawn git; any failure or timeout degrades to the directory identity.
|
|
15
|
+
*
|
|
16
|
+
* @module @dsh-cc/tui/project
|
|
17
|
+
*/
|
|
18
|
+
/**
|
|
19
|
+
* Git invocation timeout. A hung git (network FS, broken env) must not block
|
|
20
|
+
* session boot; expiry degrades to the directory identity. Generous for
|
|
21
|
+
* slow repos while still bounding the worst case.
|
|
22
|
+
*/
|
|
23
|
+
export declare const GIT_PROBE_TIMEOUT_MS = 2000;
|
|
24
|
+
/** A successful synchronous git invocation. */
|
|
25
|
+
export interface ProjectExecResult {
|
|
26
|
+
stdout: string;
|
|
27
|
+
}
|
|
28
|
+
/**
|
|
29
|
+
* Run one git argv in `cwd`, synchronously. Returns undefined on spawn
|
|
30
|
+
* failure, non-zero exit, or timeout — the caller treats that as "not a git
|
|
31
|
+
* repository". Injectable so tests script the git conversation.
|
|
32
|
+
*/
|
|
33
|
+
export type ProjectExec = (argv: readonly string[], cwd: string) => ProjectExecResult | undefined;
|
|
34
|
+
/** The default exec: real `git` via spawnSync with a bounded timeout. */
|
|
35
|
+
export declare const gitExecSync: ProjectExec;
|
|
36
|
+
/** Resolved project identity for a cwd. */
|
|
37
|
+
export interface ProjectInfo {
|
|
38
|
+
/**
|
|
39
|
+
* Canonical project root: the main git repo root for a cwd inside a git
|
|
40
|
+
* repository (link worktrees collapse onto their main checkout), else
|
|
41
|
+
* `resolve(cwd)`.
|
|
42
|
+
*/
|
|
43
|
+
readonly projectRoot: string;
|
|
44
|
+
/** `sha256(projectRoot)` first 16 hex chars — the per-project bucket key. */
|
|
45
|
+
readonly projectKey: string;
|
|
46
|
+
/**
|
|
47
|
+
* Every linked worktree of the project's repository, `resolve()`d to an
|
|
48
|
+
* absolute path. `[]` when the repo cannot be enumerated (or is not git).
|
|
49
|
+
*/
|
|
50
|
+
readonly worktrees: string[];
|
|
51
|
+
}
|
|
52
|
+
/**
|
|
53
|
+
* Resolve the project identity for `cwd`. Git is probed via the injectable
|
|
54
|
+
* exec (defaults to real `git`); any failure or timeout degrades to a
|
|
55
|
+
* directory identity (`projectRoot = resolve(cwd)`, no worktrees).
|
|
56
|
+
*
|
|
57
|
+
* Results are memoised per resolved `cwd` so every process probes git at
|
|
58
|
+
* most once per working directory (driver clients call this in hot spots —
|
|
59
|
+
* boot, picker open, history rebind — and reuse the same identity). Only
|
|
60
|
+
* default-exec calls participate: an injected `exec` bypasses the cache
|
|
61
|
+
* entirely, so scripted-exec tests and external probing stay deterministic.
|
|
62
|
+
* {@link __clearProjectCache} resets the memo (used by tests).
|
|
63
|
+
*/
|
|
64
|
+
export declare function resolveProject(cwd: string, exec?: ProjectExec): ProjectInfo;
|
|
65
|
+
/** Test hook: drop the module-level memo (also safe as a no-op cleanup). */
|
|
66
|
+
export declare function __clearProjectCache(): void;
|
|
67
|
+
/**
|
|
68
|
+
* Whether `entryCwd` belongs to the project: it equals the project root or
|
|
69
|
+
* any worktree path, or sits beneath one at a path-separator boundary
|
|
70
|
+
* (`/repo` matches `/repo` and `/repo/x`, never `/repo2`). Both `/` and `\`
|
|
71
|
+
* count as boundary separators so Windows-style recorded cwds are handled
|
|
72
|
+
* regardless of the host separator.
|
|
73
|
+
*/
|
|
74
|
+
export declare function isProjectMember(entryCwd: string, project: Pick<ProjectInfo, 'projectRoot' | 'worktrees'>): boolean;
|
|
75
|
+
//# sourceMappingURL=project.d.ts.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"project.d.ts","sourceRoot":"","sources":["../src/project.ts"],"names":[],"mappings":"AAAA;;;;;;;;;;;;;;;;GAgBG;AAOH;;;;GAIG;AACH,eAAO,MAAM,oBAAoB,OAAO,CAAA;AAExC,+CAA+C;AAC/C,MAAM,WAAW,iBAAiB;IAChC,MAAM,EAAE,MAAM,CAAA;CACf;AAED;;;;GAIG;AACH,MAAM,MAAM,WAAW,GAAG,CAAC,IAAI,EAAE,SAAS,MAAM,EAAE,EAAE,GAAG,EAAE,MAAM,KAAK,iBAAiB,GAAG,SAAS,CAAA;AAEjG,yEAAyE;AACzE,eAAO,MAAM,WAAW,EAAE,WAQzB,CAAA;AAED,2CAA2C;AAC3C,MAAM,WAAW,WAAW;IAC1B;;;;OAIG;IACH,QAAQ,CAAC,WAAW,EAAE,MAAM,CAAA;IAC5B,6EAA6E;IAC7E,QAAQ,CAAC,UAAU,EAAE,MAAM,CAAA;IAC3B;;;OAGG;IACH,QAAQ,CAAC,SAAS,EAAE,MAAM,EAAE,CAAA;CAC7B;AAwCD;;;;;;;;;;;GAWG;AACH,wBAAgB,cAAc,CAAC,GAAG,EAAE,MAAM,EAAE,IAAI,GAAE,WAAyB,GAAG,WAAW,CASxF;AAKD,4EAA4E;AAC5E,wBAAgB,mBAAmB,IAAI,IAAI,CAE1C;AAwDD;;;;;;GAMG;AACH,wBAAgB,eAAe,CAC7B,QAAQ,EAAE,MAAM,EAChB,OAAO,EAAE,IAAI,CAAC,WAAW,EAAE,aAAa,GAAG,WAAW,CAAC,GACtD,OAAO,CAOT"}
|