codsh-bundle 0.3.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 +21 -0
- package/README.md +10 -0
- package/agent-presets/code-cli/agent.cordis.yml +322 -0
- package/agent-presets/code-cli/preset.yml +3 -0
- package/cordis.patch.yml +165 -0
- package/lib/index.js +4911 -0
- package/lib/invariant.js +23 -0
- package/lib/startup.js +64 -0
- package/lib/types/approval.d.ts +57 -0
- package/lib/types/banner.d.ts +30 -0
- package/lib/types/completion.d.ts +45 -0
- package/lib/types/console.d.ts +240 -0
- package/lib/types/custom-commands.d.ts +54 -0
- package/lib/types/editor.d.ts +186 -0
- package/lib/types/index.d.ts +48 -0
- package/lib/types/inputbox.d.ts +45 -0
- package/lib/types/invariant.d.ts +15 -0
- package/lib/types/keys.d.ts +123 -0
- package/lib/types/markdown.d.ts +73 -0
- package/lib/types/preset-install.d.ts +34 -0
- package/lib/types/prompt.d.ts +150 -0
- package/lib/types/questions.d.ts +65 -0
- package/lib/types/screen.d.ts +204 -0
- package/lib/types/selector.d.ts +98 -0
- package/lib/types/spinner.d.ts +63 -0
- package/lib/types/startup.d.ts +31 -0
- package/lib/types/status.d.ts +94 -0
- package/lib/types/streaming.d.ts +68 -0
- package/lib/types/theme.d.ts +75 -0
- package/lib/types/transcript.d.ts +129 -0
- package/lib/types/wrap.d.ts +27 -0
- package/package.json +117 -0
|
@@ -0,0 +1,75 @@
|
|
|
1
|
+
/**
|
|
2
|
+
* Terminal styling and display metrics: SGR sequences that degrade to plain
|
|
3
|
+
* text off a TTY, and the display-column width a rendered string occupies.
|
|
4
|
+
* @module codsh-bundle/src/theme
|
|
5
|
+
*/
|
|
6
|
+
/** Style roles the renderer asks for, resolved to SGR codes by {@link createTheme}. */
|
|
7
|
+
export interface Theme {
|
|
8
|
+
/** Whether this theme emits SGR sequences at all. */
|
|
9
|
+
readonly colored: boolean;
|
|
10
|
+
dim(text: string): string;
|
|
11
|
+
bold(text: string): string;
|
|
12
|
+
/** Failures, denied approvals, and removed diff lines. */
|
|
13
|
+
error(text: string): string;
|
|
14
|
+
/** Completed work and added diff lines. */
|
|
15
|
+
success(text: string): string;
|
|
16
|
+
/** Pending state and approval prompts. */
|
|
17
|
+
pending(text: string): string;
|
|
18
|
+
/** Tool names and card titles. */
|
|
19
|
+
tool(text: string): string;
|
|
20
|
+
/** File paths and locations. */
|
|
21
|
+
path(text: string): string;
|
|
22
|
+
/** The user's own echoed input. */
|
|
23
|
+
user(text: string): string;
|
|
24
|
+
/** Roles used inside a fenced code block. */
|
|
25
|
+
readonly syntax: SyntaxTheme;
|
|
26
|
+
}
|
|
27
|
+
/** Styling for the token classes a code block is coloured by. */
|
|
28
|
+
export interface SyntaxTheme {
|
|
29
|
+
keyword(text: string): string;
|
|
30
|
+
string(text: string): string;
|
|
31
|
+
number(text: string): string;
|
|
32
|
+
comment(text: string): string;
|
|
33
|
+
}
|
|
34
|
+
/**
|
|
35
|
+
* Build the theme for one surface.
|
|
36
|
+
*
|
|
37
|
+
* Color is suppressed off a TTY and whenever `NO_COLOR` is set to any value,
|
|
38
|
+
* following the `no-color.org` convention: a redirected transcript stays
|
|
39
|
+
* greppable, and a pipe never receives sequences a reader would have to strip.
|
|
40
|
+
*
|
|
41
|
+
* Secondary text uses a palette gray on a 256-color terminal rather than the
|
|
42
|
+
* `dim` attribute: several terminals render `dim` at full brightness, and a
|
|
43
|
+
* hierarchy nobody can see is no hierarchy — the placeholder, the menu details,
|
|
44
|
+
* and the status row must sit visibly behind what the person typed.
|
|
45
|
+
* @param isTty - whether the output stream is a terminal.
|
|
46
|
+
* @param env - the environment to read `NO_COLOR` and the color depth from.
|
|
47
|
+
* @returns the styling functions for this surface.
|
|
48
|
+
*/
|
|
49
|
+
export declare function createTheme(isTty: boolean, env: Record<string, string | undefined>): Theme;
|
|
50
|
+
/**
|
|
51
|
+
* Display columns a string occupies once printed, ignoring styling sequences.
|
|
52
|
+
*
|
|
53
|
+
* Measured by `string-width` — the width authority cli-table3, ink, and every
|
|
54
|
+
* maintained terminal renderer sit on — so East Asian Wide, emoji presentation
|
|
55
|
+
* (`⚡` included), combining marks, and ZWJ sequences all match what a
|
|
56
|
+
* terminal's cursor actually does. A hand-kept range table here mis-sized `⚡`
|
|
57
|
+
* and sheared a real table's columns; widths are exactly the kind of data
|
|
58
|
+
* nobody should maintain by hand.
|
|
59
|
+
* @param text - the string to measure, possibly carrying SGR sequences.
|
|
60
|
+
* @returns the number of display columns.
|
|
61
|
+
*/
|
|
62
|
+
export declare function displayWidth(text: string): number;
|
|
63
|
+
/**
|
|
64
|
+
* Shorten a string to at most `columns` display columns, marking the cut with
|
|
65
|
+
* an ellipsis when anything was dropped.
|
|
66
|
+
*
|
|
67
|
+
* Styling survives: sequences cost no columns and travel with the text they
|
|
68
|
+
* style, and a cut that kept any styling closes it with a reset before the
|
|
69
|
+
* ellipsis so nothing leaks onto the next row. A string that already fits is
|
|
70
|
+
* returned exactly as it came — a fit is not a licence to restyle it.
|
|
71
|
+
* @param text - the string to shorten, possibly carrying SGR sequences.
|
|
72
|
+
* @param columns - the display-column budget; a budget under 2 yields the empty string.
|
|
73
|
+
* @returns the string, unchanged when it already fits.
|
|
74
|
+
*/
|
|
75
|
+
export declare function truncate(text: string, columns: number): string;
|
|
@@ -0,0 +1,129 @@
|
|
|
1
|
+
/**
|
|
2
|
+
* Session log to terminal lines. One appended {@link SessionEvent} renders to
|
|
3
|
+
* zero or more finished lines; the surface never rewrites a line it has
|
|
4
|
+
* printed, so the transcript scrolls like a shell history.
|
|
5
|
+
*
|
|
6
|
+
* Tool cards come from the registered presenters rather than from tool names:
|
|
7
|
+
* a tool declares its own render intent, and this module switches on the
|
|
8
|
+
* resulting `card` tag.
|
|
9
|
+
* @module codsh-bundle/src/transcript
|
|
10
|
+
*/
|
|
11
|
+
import type { SessionEvent } from '@deepseek-ai/dsh-session';
|
|
12
|
+
import type { ToolCallView, ToolResult, ToolResultView } from '@deepseek-ai/dsh-tools';
|
|
13
|
+
import type { Theme } from './theme.ts';
|
|
14
|
+
/** The registered presenters, resolved against the agent's scope by the caller. */
|
|
15
|
+
export interface ToolPresenters {
|
|
16
|
+
/**
|
|
17
|
+
* Render intent for a pending call.
|
|
18
|
+
* @param name - the tool the model called.
|
|
19
|
+
* @param args - the parsed call arguments.
|
|
20
|
+
* @returns the declared view, or undefined for the generic fallback.
|
|
21
|
+
*/
|
|
22
|
+
call(name: string, args: unknown): ToolCallView | undefined;
|
|
23
|
+
/**
|
|
24
|
+
* Render intent for a completed call.
|
|
25
|
+
* @param name - the tool the model called.
|
|
26
|
+
* @param args - the parsed call arguments.
|
|
27
|
+
* @param result - the completed outcome.
|
|
28
|
+
* @returns the declared view, or undefined for the generic fallback.
|
|
29
|
+
*/
|
|
30
|
+
result(name: string, args: unknown, result: ToolResult): ToolResultView | undefined;
|
|
31
|
+
}
|
|
32
|
+
/** What the renderer needs to know about the surface it writes to. */
|
|
33
|
+
export interface TranscriptOptions {
|
|
34
|
+
theme: Theme;
|
|
35
|
+
/** Display columns available for one line. */
|
|
36
|
+
columns: number;
|
|
37
|
+
/** Session workspace, stripped from absolute paths so cards stay short. */
|
|
38
|
+
cwd: string;
|
|
39
|
+
}
|
|
40
|
+
/** Renders one session's appended events as terminal lines. */
|
|
41
|
+
export declare class Transcript {
|
|
42
|
+
private readonly options;
|
|
43
|
+
private readonly presenters;
|
|
44
|
+
private readonly calls;
|
|
45
|
+
/** The full form of the event just rendered, when its body was collapsed. */
|
|
46
|
+
private fold;
|
|
47
|
+
constructor(options: TranscriptOptions, presenters: ToolPresenters);
|
|
48
|
+
/**
|
|
49
|
+
* Shorten an absolute path inside the workspace to a workspace-relative one.
|
|
50
|
+
* @param path - the model-facing path a card carries.
|
|
51
|
+
* @returns the display path.
|
|
52
|
+
*/
|
|
53
|
+
private relative;
|
|
54
|
+
/**
|
|
55
|
+
* Shorten every workspace path a presenter embedded in free text.
|
|
56
|
+
*
|
|
57
|
+
* A title is prose the tool composed (`Write /abs/path`), so the path inside
|
|
58
|
+
* it needs the same shortening as a structured `locations` entry.
|
|
59
|
+
* @param text - the presenter-supplied line.
|
|
60
|
+
* @returns the line with workspace-rooted paths made relative.
|
|
61
|
+
*/
|
|
62
|
+
private relativizeIn;
|
|
63
|
+
/**
|
|
64
|
+
* Paths worth appending to a title that may already name them.
|
|
65
|
+
* @param title - the presenter's title, already relativized.
|
|
66
|
+
* @param paths - the relativized paths the card covers.
|
|
67
|
+
* @returns the paths the title does not mention, joined for display.
|
|
68
|
+
*/
|
|
69
|
+
private extraPaths;
|
|
70
|
+
/**
|
|
71
|
+
* Render one appended event.
|
|
72
|
+
* @param event - the event exactly as recorded.
|
|
73
|
+
* @returns the lines to append to the transcript, empty when the event shows nothing.
|
|
74
|
+
*/
|
|
75
|
+
render(event: SessionEvent): string[];
|
|
76
|
+
/**
|
|
77
|
+
* Render a pending call as its declared card.
|
|
78
|
+
* @param callId - correlation id, remembered until the result pairs with it.
|
|
79
|
+
* @param name - the tool the model called.
|
|
80
|
+
* @param rawArguments - the unparsed arguments JSON the model produced.
|
|
81
|
+
* @returns the pending card's lines.
|
|
82
|
+
*/
|
|
83
|
+
private renderCall;
|
|
84
|
+
/**
|
|
85
|
+
* Render a completed call, pairing it with the call this transcript recorded.
|
|
86
|
+
* @param data - the `tool/result` payload.
|
|
87
|
+
* @returns the completed card's lines.
|
|
88
|
+
*/
|
|
89
|
+
private renderResult;
|
|
90
|
+
/**
|
|
91
|
+
* The expanded form of the lines {@link render} just returned, when that
|
|
92
|
+
* event's body was collapsed — the whole event re-rendered without its cap,
|
|
93
|
+
* because a fold swaps entire blocks, not just the clipped tail. The full
|
|
94
|
+
* body is kept from the render itself: what a tool truncated before
|
|
95
|
+
* returning is upstream of the log and unrecoverable everywhere.
|
|
96
|
+
* @returns the full lines, or undefined when nothing was collapsed.
|
|
97
|
+
*/
|
|
98
|
+
takeFold(): string[] | undefined;
|
|
99
|
+
/**
|
|
100
|
+
* Render one completed call's status suffix and body from its declared view.
|
|
101
|
+
* @param view - the result view, absent when no presenter answered.
|
|
102
|
+
* @param block - the model-facing result block, used by the generic fallback.
|
|
103
|
+
* @returns the suffix, the (possibly capped) body, and — when the cap dropped
|
|
104
|
+
* lines, or a bodiless card withheld content — the full body for Ctrl-O.
|
|
105
|
+
*/
|
|
106
|
+
private outcome;
|
|
107
|
+
/**
|
|
108
|
+
* Flatten a result's content blocks to displayable text.
|
|
109
|
+
* @param content - the result content blocks.
|
|
110
|
+
* @returns the joined text.
|
|
111
|
+
*/
|
|
112
|
+
private resultText;
|
|
113
|
+
/**
|
|
114
|
+
* Ask a call presenter for its view, absorbing a throwing presenter.
|
|
115
|
+
* @param name - the tool the model called.
|
|
116
|
+
* @param args - the parsed call arguments.
|
|
117
|
+
* @returns the view, or undefined to fall back to the generic line.
|
|
118
|
+
*/
|
|
119
|
+
private safeCall;
|
|
120
|
+
/**
|
|
121
|
+
* Ask a result presenter for its view, absorbing a throwing presenter.
|
|
122
|
+
* @param pending - the recorded call this result pairs with.
|
|
123
|
+
* @param content - the model-facing result content.
|
|
124
|
+
* @param isError - whether the executor reported a failure.
|
|
125
|
+
* @param meta - the tool's private presentation payload, when it attached one.
|
|
126
|
+
* @returns the view, or undefined to fall back to the generic card.
|
|
127
|
+
*/
|
|
128
|
+
private safeResult;
|
|
129
|
+
}
|
|
@@ -0,0 +1,27 @@
|
|
|
1
|
+
/**
|
|
2
|
+
* Display-width wrapping for styled text.
|
|
3
|
+
*
|
|
4
|
+
* Inside the alternate screen the terminal no longer wraps for us: a transcript
|
|
5
|
+
* line longer than the viewport must be broken into rows before it is painted,
|
|
6
|
+
* or it would overwrite the row below. The lines being broken are already
|
|
7
|
+
* styled, so a naive split would cut an escape sequence in half and leak
|
|
8
|
+
* gibberish — and a continuation row would lose the colour its first half set.
|
|
9
|
+
* @module codsh-bundle/src/wrap
|
|
10
|
+
*/
|
|
11
|
+
/**
|
|
12
|
+
* Break one styled line into rows no wider than `columns` display columns.
|
|
13
|
+
*
|
|
14
|
+
* Styles carry across the break: each continuation row re-opens whatever was
|
|
15
|
+
* active where the cut fell, and every row that opened a style closes it.
|
|
16
|
+
* @param text - the styled line, without a terminator.
|
|
17
|
+
* @param columns - display columns available per row.
|
|
18
|
+
* @returns the rows, at least one (an empty line yields one empty row).
|
|
19
|
+
*/
|
|
20
|
+
export declare function wrapStyled(text: string, columns: number): string[];
|
|
21
|
+
/**
|
|
22
|
+
* Wrap many lines, keeping their order.
|
|
23
|
+
* @param lines - styled lines.
|
|
24
|
+
* @param columns - display columns per row.
|
|
25
|
+
* @returns the physical rows they occupy.
|
|
26
|
+
*/
|
|
27
|
+
export declare function wrapAll(lines: readonly string[], columns: number): string[];
|
package/package.json
ADDED
|
@@ -0,0 +1,117 @@
|
|
|
1
|
+
{
|
|
2
|
+
"name": "codsh-bundle",
|
|
3
|
+
"description": "The codsh runtime: the interactive TTY surface and code-cli agent preset, installed into a dsh profile. Users install codsh-cli (the launcher) — this package is what it registers.",
|
|
4
|
+
"version": "0.3.0",
|
|
5
|
+
"type": "module",
|
|
6
|
+
"license": "MIT",
|
|
7
|
+
"main": "lib/index.js",
|
|
8
|
+
"types": "lib/types/index.d.ts",
|
|
9
|
+
"exports": {
|
|
10
|
+
".": {
|
|
11
|
+
"types": "./lib/types/index.d.ts",
|
|
12
|
+
"default": "./lib/index.js"
|
|
13
|
+
},
|
|
14
|
+
"./startup": {
|
|
15
|
+
"types": "./lib/types/startup.d.ts",
|
|
16
|
+
"default": "./lib/startup.js"
|
|
17
|
+
},
|
|
18
|
+
"./invariant": {
|
|
19
|
+
"types": "./lib/types/invariant.d.ts",
|
|
20
|
+
"default": "./lib/invariant.js"
|
|
21
|
+
},
|
|
22
|
+
"./cordis.patch.yml": "./cordis.patch.yml",
|
|
23
|
+
"./package.json": "./package.json",
|
|
24
|
+
"./agent-presets/*": "./agent-presets/*"
|
|
25
|
+
},
|
|
26
|
+
"files": [
|
|
27
|
+
"lib/index.js",
|
|
28
|
+
"lib/invariant.js",
|
|
29
|
+
"lib/startup.js",
|
|
30
|
+
"cordis.patch.yml",
|
|
31
|
+
"agent-presets",
|
|
32
|
+
"lib/types/**/*.d.ts",
|
|
33
|
+
"README.md"
|
|
34
|
+
],
|
|
35
|
+
"dsh": {
|
|
36
|
+
"bundle": {
|
|
37
|
+
"patch": "./cordis.patch.yml"
|
|
38
|
+
}
|
|
39
|
+
},
|
|
40
|
+
"dependencies": {
|
|
41
|
+
"@deepseek-ai/dsh-agent-instructions": "^0.1.0-rc.7",
|
|
42
|
+
"@deepseek-ai/dsh-agent-presets": "^0.1.0-rc.7",
|
|
43
|
+
"@deepseek-ai/dsh-cmdline": "^0.1.0-rc.7",
|
|
44
|
+
"@deepseek-ai/dsh-code-runtime-worker-thread": "^0.1.0-rc.7",
|
|
45
|
+
"@deepseek-ai/dsh-command-compact": "^0.1.0-rc.7",
|
|
46
|
+
"@deepseek-ai/dsh-compaction-basic": "^0.1.0-rc.7",
|
|
47
|
+
"@deepseek-ai/dsh-compaction-tool-result-pruner": "^0.1.0-rc.7",
|
|
48
|
+
"@deepseek-ai/dsh-lsp": "^0.1.0-rc.7",
|
|
49
|
+
"@deepseek-ai/dsh-lsp-stdio": "^0.1.0-rc.7",
|
|
50
|
+
"@deepseek-ai/dsh-persona": "^0.1.0-rc.7",
|
|
51
|
+
"@deepseek-ai/dsh-plan-mode": "^0.1.0-rc.7",
|
|
52
|
+
"@deepseek-ai/dsh-skill-filesystem": "^0.1.0-rc.7",
|
|
53
|
+
"@deepseek-ai/dsh-terminal": "^0.1.0-rc.7",
|
|
54
|
+
"@deepseek-ai/dsh-terminal-bash": "^0.1.0-rc.7",
|
|
55
|
+
"@deepseek-ai/dsh-tool-ask-user": "^0.1.0-rc.7",
|
|
56
|
+
"@deepseek-ai/dsh-tool-bash": "^0.1.0-rc.7",
|
|
57
|
+
"@deepseek-ai/dsh-tool-fs": "^0.1.0-rc.7",
|
|
58
|
+
"@deepseek-ai/dsh-tool-fs-search": "^0.1.0-rc.7",
|
|
59
|
+
"@deepseek-ai/dsh-tool-goal": "^0.1.0-rc.7",
|
|
60
|
+
"@deepseek-ai/dsh-tool-jobs": "^0.1.0-rc.7",
|
|
61
|
+
"@deepseek-ai/dsh-tool-lsp": "^0.1.0-rc.7",
|
|
62
|
+
"@deepseek-ai/dsh-tool-pwsh": "^0.1.0-rc.7",
|
|
63
|
+
"@deepseek-ai/dsh-tool-ralph": "^0.1.0-rc.7",
|
|
64
|
+
"@deepseek-ai/dsh-tool-skill": "^0.1.0-rc.7",
|
|
65
|
+
"@deepseek-ai/dsh-tool-subagent": "^0.1.0-rc.7",
|
|
66
|
+
"@deepseek-ai/dsh-tool-subagent-control": "^0.1.0-rc.7",
|
|
67
|
+
"@deepseek-ai/dsh-tool-terminal": "^0.1.0-rc.7",
|
|
68
|
+
"@deepseek-ai/dsh-tool-todo": "^0.1.0-rc.7",
|
|
69
|
+
"@deepseek-ai/dsh-tool-web": "^0.1.0-rc.7",
|
|
70
|
+
"@deepseek-ai/dsh-tool-workflow": "^0.1.0-rc.7",
|
|
71
|
+
"@deepseek-ai/dsh-workflow-worker-thread": "^0.1.0-rc.7",
|
|
72
|
+
"@deepseek-ai/schemastery": "^3.18.1",
|
|
73
|
+
"commander": "^15.0.0",
|
|
74
|
+
"diff": "^9.0.0",
|
|
75
|
+
"string-width": "^8.2.2"
|
|
76
|
+
},
|
|
77
|
+
"peerDependencies": {
|
|
78
|
+
"@deepseek-ai/cordis": "^4.0.1",
|
|
79
|
+
"@deepseek-ai/cordis-plugin-loader": "^1.0.2",
|
|
80
|
+
"@deepseek-ai/dsh-agent": "^0.1.0-rc.7",
|
|
81
|
+
"@deepseek-ai/dsh-agent-default-model": "^0.1.0-rc.7",
|
|
82
|
+
"@deepseek-ai/dsh-commands": "^0.1.0-rc.7",
|
|
83
|
+
"@deepseek-ai/dsh-home-paths": "^0.1.0-rc.7",
|
|
84
|
+
"@deepseek-ai/dsh-invariants": "^0.1.0-rc.7",
|
|
85
|
+
"@deepseek-ai/dsh-llm": "^0.1.0-rc.7",
|
|
86
|
+
"@deepseek-ai/dsh-permission-presets": "^0.1.0-rc.7",
|
|
87
|
+
"@deepseek-ai/dsh-session": "^0.1.0-rc.7",
|
|
88
|
+
"@deepseek-ai/dsh-session-projection": "^0.1.0-rc.7",
|
|
89
|
+
"@deepseek-ai/dsh-session-query": "^0.1.0-rc.7",
|
|
90
|
+
"@deepseek-ai/dsh-token-meter": "^0.1.0-rc.7",
|
|
91
|
+
"@deepseek-ai/dsh-tools": "^0.1.0-rc.7",
|
|
92
|
+
"@deepseek-ai/dsh-user-approval": "^0.1.0-rc.7",
|
|
93
|
+
"@deepseek-ai/dsh-user-questions": "^0.1.0-rc.7"
|
|
94
|
+
},
|
|
95
|
+
"engines": {
|
|
96
|
+
"node": ">=22.19"
|
|
97
|
+
},
|
|
98
|
+
"repository": {
|
|
99
|
+
"type": "git",
|
|
100
|
+
"url": "git+https://github.com/Blackman99/codsh.git",
|
|
101
|
+
"directory": "packages/bundle"
|
|
102
|
+
},
|
|
103
|
+
"keywords": [
|
|
104
|
+
"cli",
|
|
105
|
+
"coding-agent",
|
|
106
|
+
"terminal",
|
|
107
|
+
"deepseek",
|
|
108
|
+
"dsh",
|
|
109
|
+
"ai",
|
|
110
|
+
"agent"
|
|
111
|
+
],
|
|
112
|
+
"homepage": "https://github.com/Blackman99/codsh#readme",
|
|
113
|
+
"bugs": "https://github.com/Blackman99/codsh/issues",
|
|
114
|
+
"scripts": {
|
|
115
|
+
"build": "tsdown && tsc -p tsconfig.build.json"
|
|
116
|
+
}
|
|
117
|
+
}
|