dsh-code 0.9.1 → 1.0.1
This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
- package/README.en.md +278 -249
- package/README.md +131 -102
- package/bin/deepseek.mjs +100 -6
- package/cordis.patch.yml +36 -1
- package/lib/index.mjs +3055 -819
- package/lib/startup.mjs +21 -11
- package/lib/{theme-BEi4i_aN.mjs → theme-DCT8Y2xf.mjs} +13 -9
- package/lib/types/app.d.ts +84 -16
- package/lib/types/attachments.d.ts +20 -0
- package/lib/types/authorization-panel.d.ts +22 -0
- package/lib/types/authorization.d.ts +36 -0
- package/lib/types/editor.d.ts +6 -0
- package/lib/types/fork.d.ts +8 -0
- package/lib/types/git-workflow.d.ts +23 -0
- package/lib/types/index.d.ts +6 -0
- package/lib/types/kernel-panels.d.ts +39 -0
- package/lib/types/keyboard.d.ts +41 -0
- package/lib/types/mentions.d.ts +30 -38
- package/lib/types/models.d.ts +3 -1
- package/lib/types/permissions.d.ts +4 -14
- package/lib/types/presets.d.ts +5 -20
- package/lib/types/provider-settings.d.ts +16 -0
- package/lib/types/render/animations.d.ts +10 -39
- package/lib/types/render/editor.d.ts +137 -0
- package/lib/types/render/export.d.ts +1 -1
- package/lib/types/render/lines.d.ts +6 -2
- package/lib/types/render/markdown.d.ts +3 -1
- package/lib/types/render/projection.d.ts +29 -3
- package/lib/types/render/status.d.ts +6 -13
- package/lib/types/session-directory.d.ts +1 -3
- package/lib/types/startup.d.ts +14 -11
- package/lib/types/store.d.ts +11 -9
- package/lib/types/subagents.d.ts +3 -3
- package/lib/types/theme.d.ts +14 -1
- package/lib/types/version.d.ts +15 -2
- package/package.json +159 -141
- package/src/app.ts +1490 -663
- package/src/attachments.ts +128 -0
- package/src/authorization-panel.ts +285 -0
- package/src/authorization.ts +147 -0
- package/src/editor.ts +51 -0
- package/src/fork.ts +31 -0
- package/src/git-workflow.ts +87 -0
- package/src/index.ts +1523 -1374
- package/src/internals.ts +14 -1
- package/src/kernel-panels.ts +914 -798
- package/src/keyboard.ts +126 -0
- package/src/mentions.ts +78 -117
- package/src/models.ts +20 -14
- package/src/permissions.ts +5 -13
- package/src/presets.ts +6 -22
- package/src/provider-settings.ts +95 -1
- package/src/render/animations.ts +420 -450
- package/src/render/editor.ts +398 -0
- package/src/render/export.ts +79 -79
- package/src/render/lines.ts +342 -236
- package/src/render/markdown.ts +99 -26
- package/src/render/projection.ts +106 -19
- package/src/render/status.ts +713 -650
- package/src/render/text.ts +150 -150
- package/src/render/tool-detail.ts +3 -1
- package/src/session-directory.ts +4 -4
- package/src/startup.ts +136 -119
- package/src/store.ts +23 -11
- package/src/subagents.ts +13 -5
- package/src/theme.ts +214 -206
- package/src/version.ts +58 -1
|
@@ -0,0 +1,87 @@
|
|
|
1
|
+
/** Read-only Git inspection used by /diff and /review. */
|
|
2
|
+
|
|
3
|
+
import { execFile } from 'node:child_process'
|
|
4
|
+
|
|
5
|
+
export interface GitDiffSpec {
|
|
6
|
+
readonly label: string
|
|
7
|
+
readonly args: readonly string[]
|
|
8
|
+
}
|
|
9
|
+
|
|
10
|
+
/** One file section from a unified diff, retained in source order. */
|
|
11
|
+
export interface GitDiffFile {
|
|
12
|
+
readonly path: string
|
|
13
|
+
readonly lines: readonly string[]
|
|
14
|
+
}
|
|
15
|
+
|
|
16
|
+
/** A parsed diff ready for a file-oriented terminal viewport. */
|
|
17
|
+
export interface GitDiffView {
|
|
18
|
+
readonly title: string
|
|
19
|
+
readonly files: readonly GitDiffFile[]
|
|
20
|
+
}
|
|
21
|
+
|
|
22
|
+
/** Split Git's stable `diff --git` framing without interpreting patch content. */
|
|
23
|
+
export function parseGitDiffFiles(text: string): readonly GitDiffFile[] {
|
|
24
|
+
if (text === '') return []
|
|
25
|
+
const chunks = text.split(/(?=^diff --git )/mu).filter(chunk => chunk !== '')
|
|
26
|
+
return chunks.map((chunk, index) => {
|
|
27
|
+
const lines = chunk.replace(/\n$/u, '').split('\n')
|
|
28
|
+
const plus = lines.find(line => line.startsWith('+++ b/'))
|
|
29
|
+
const minus = lines.find(line => line.startsWith('--- a/'))
|
|
30
|
+
const header = /^diff --git a\/(.+) b\/(.+)$/u.exec(lines[0] ?? '')
|
|
31
|
+
const path = plus?.slice(6) || minus?.slice(6) || header?.[2] || header?.[1] || `file ${index + 1}`
|
|
32
|
+
return { path, lines }
|
|
33
|
+
})
|
|
34
|
+
}
|
|
35
|
+
|
|
36
|
+
/** Parse the intentionally small, option-safe /diff argument vocabulary. */
|
|
37
|
+
export function parseGitDiffSpec(argument: string): GitDiffSpec {
|
|
38
|
+
const value = argument.trim()
|
|
39
|
+
if (value === '') return { label: 'working tree vs HEAD', args: ['diff', '--no-ext-diff', '--unified=3', 'HEAD', '--'] }
|
|
40
|
+
if (value === '--staged' || value === '--cached') {
|
|
41
|
+
return { label: 'staged changes', args: ['diff', '--no-ext-diff', '--unified=3', '--cached', '--'] }
|
|
42
|
+
}
|
|
43
|
+
if (value.startsWith('-') || /\s/u.test(value)) throw new Error('usage: /diff [--staged|git-ref]')
|
|
44
|
+
return { label: `changes since ${value}`, args: ['diff', '--no-ext-diff', '--unified=3', value, '--'] }
|
|
45
|
+
}
|
|
46
|
+
|
|
47
|
+
function executeGit(cwd: string, args: readonly string[]): Promise<string> {
|
|
48
|
+
return new Promise((resolve, reject) => {
|
|
49
|
+
execFile('git', [...args], { cwd, encoding: 'utf8', maxBuffer: 16 * 1024 * 1024, windowsHide: true }, (error, stdout, stderr) => {
|
|
50
|
+
if (error !== null) {
|
|
51
|
+
reject(new Error(stderr.trim() || error.message))
|
|
52
|
+
return
|
|
53
|
+
}
|
|
54
|
+
resolve(stdout.replace(/\r\n/gu, '\n'))
|
|
55
|
+
})
|
|
56
|
+
})
|
|
57
|
+
}
|
|
58
|
+
|
|
59
|
+
/** Load one complete textual diff without invoking external diff drivers. */
|
|
60
|
+
export async function loadGitDiff(cwd: string, argument: string): Promise<GitDiffView> {
|
|
61
|
+
const spec = parseGitDiffSpec(argument)
|
|
62
|
+
try {
|
|
63
|
+
const text = await executeGit(cwd, spec.args)
|
|
64
|
+
return { title: `git diff - ${spec.label}`, files: parseGitDiffFiles(text) }
|
|
65
|
+
} catch (error: unknown) {
|
|
66
|
+
// An unborn repository has no HEAD. Preserve useful unstaged output for
|
|
67
|
+
// the default form while still surfacing all other Git failures.
|
|
68
|
+
if (argument.trim() !== '') throw error
|
|
69
|
+
const text = await executeGit(cwd, ['diff', '--no-ext-diff', '--unified=3', '--'])
|
|
70
|
+
return { title: 'git diff - working tree', files: parseGitDiffFiles(text) }
|
|
71
|
+
}
|
|
72
|
+
}
|
|
73
|
+
|
|
74
|
+
/** Review prompt capped before it reaches a provider context window. */
|
|
75
|
+
export function buildReviewPrompt(diff: string, label: string, maxChars = 200_000): string {
|
|
76
|
+
const truncated = diff.length > maxChars
|
|
77
|
+
const body = truncated ? diff.slice(0, maxChars) : diff
|
|
78
|
+
return [
|
|
79
|
+
'Review the following Git changes. Do not modify files or run write operations.',
|
|
80
|
+
'Lead with concrete bugs, regressions, security risks, and missing tests, ordered by severity.',
|
|
81
|
+
`Scope: ${label}${truncated ? ' (diff truncated by CLI)' : ''}`,
|
|
82
|
+
'',
|
|
83
|
+
'```diff',
|
|
84
|
+
body,
|
|
85
|
+
'```',
|
|
86
|
+
].join('\n')
|
|
87
|
+
}
|