@xbzbing/dsh-git-panel 1.5.3 → 1.6.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/{README_EN.md → README.en.md} +6 -4
- package/README.md +7 -5
- package/lib/client.js +109 -19
- package/lib/host/actions.d.ts +6 -4
- package/lib/host/actions.js +250 -0
- package/lib/host/core.d.ts +12 -4
- package/lib/host/core.js +305 -0
- package/lib/host/git.js +65 -0
- package/lib/host/index.d.ts +20 -14
- package/lib/host/index.js +45 -1686
- package/lib/host/llm-face.js +0 -0
- package/lib/host/parser.d.ts +1 -1
- package/lib/host/parser.js +213 -0
- package/lib/host/queries.d.ts +2 -2
- package/lib/host/queries.js +499 -0
- package/lib/host/remote.d.ts +1 -1
- package/lib/host/remote.js +48 -0
- package/lib/host/suggest.d.ts +2 -2
- package/lib/host/suggest.js +220 -0
- package/lib/host/types.d.ts +73 -3
- package/lib/host/types.js +36 -0
- package/lib/host/validate.js +26 -0
- package/lib/host/version.js +130 -0
- package/package.json +11 -4
package/lib/host/git.js
ADDED
|
@@ -0,0 +1,65 @@
|
|
|
1
|
+
import { readFile } from "node:fs/promises";
|
|
2
|
+
function createGitRunner(subprocess, timeoutMs, maxBytes) {
|
|
3
|
+
const spillMaxBytes = maxBytes * 16;
|
|
4
|
+
return {
|
|
5
|
+
async run(argv, opts) {
|
|
6
|
+
const controller = new AbortController();
|
|
7
|
+
const timer = setTimeout(() => controller.abort(), timeoutMs);
|
|
8
|
+
try {
|
|
9
|
+
const signal = opts.signal === void 0 ? controller.signal : AbortSignal.any([controller.signal, opts.signal]);
|
|
10
|
+
const handle = subprocess.spawn({
|
|
11
|
+
argv,
|
|
12
|
+
cwd: opts.cwd,
|
|
13
|
+
// Never let a network command (fetch/pull) block on an interactive
|
|
14
|
+
// credential or host-key prompt: with stdin ignored git would hang
|
|
15
|
+
// until the timeout. GIT_TERMINAL_PROMPT=0 makes it fail fast instead,
|
|
16
|
+
// and is harmless for the non-network commands that share this runner.
|
|
17
|
+
env: { GIT_TERMINAL_PROMPT: "0" },
|
|
18
|
+
stdio: {
|
|
19
|
+
stdin: opts.stdinData === void 0 ? "ignore" : { data: opts.stdinData },
|
|
20
|
+
stdout: { collect: { maxBytes, spill: { maxBytes: spillMaxBytes } } },
|
|
21
|
+
stderr: { collect: { maxBytes, spill: { maxBytes: spillMaxBytes } } }
|
|
22
|
+
},
|
|
23
|
+
graceMs: 200,
|
|
24
|
+
signal
|
|
25
|
+
});
|
|
26
|
+
let outcome;
|
|
27
|
+
try {
|
|
28
|
+
outcome = await handle.done;
|
|
29
|
+
} catch (error) {
|
|
30
|
+
const cancelled2 = opts.signal?.aborted === true && !controller.signal.aborted;
|
|
31
|
+
if (controller.signal.aborted || opts.signal?.aborted === true) {
|
|
32
|
+
return { exitCode: null, stdout: "", stderr: "", timedOut: !cancelled2, cancelled: cancelled2, stdoutLossy: false };
|
|
33
|
+
}
|
|
34
|
+
throw error;
|
|
35
|
+
}
|
|
36
|
+
const stdout = handle.collected.stdout?.readFrom(0);
|
|
37
|
+
const stderr = handle.collected.stderr?.readFrom(0);
|
|
38
|
+
const resolved = await resolveStdout(stdout);
|
|
39
|
+
const cancelled = opts.signal?.aborted === true && !controller.signal.aborted;
|
|
40
|
+
return {
|
|
41
|
+
exitCode: outcome.exitCode,
|
|
42
|
+
stdout: resolved.text,
|
|
43
|
+
stderr: stderr?.text ?? "",
|
|
44
|
+
timedOut: controller.signal.aborted,
|
|
45
|
+
cancelled,
|
|
46
|
+
stdoutLossy: resolved.lossy
|
|
47
|
+
};
|
|
48
|
+
} finally {
|
|
49
|
+
clearTimeout(timer);
|
|
50
|
+
}
|
|
51
|
+
}
|
|
52
|
+
};
|
|
53
|
+
}
|
|
54
|
+
async function resolveStdout(read) {
|
|
55
|
+
if (read === void 0) return { text: "", lossy: false };
|
|
56
|
+
if (!read.lossy || read.spillPath === void 0) return { text: read.text, lossy: read.lossy };
|
|
57
|
+
try {
|
|
58
|
+
return { text: await readFile(read.spillPath, "utf8"), lossy: false };
|
|
59
|
+
} catch {
|
|
60
|
+
return { text: read.text, lossy: true };
|
|
61
|
+
}
|
|
62
|
+
}
|
|
63
|
+
export {
|
|
64
|
+
createGitRunner
|
|
65
|
+
};
|
package/lib/host/index.d.ts
CHANGED
|
@@ -9,34 +9,40 @@
|
|
|
9
9
|
import { TypertRemoteService } from '@deepseek-ai/dsh-typert-protocol';
|
|
10
10
|
import type { Context } from '@deepseek-ai/cordis';
|
|
11
11
|
import Schema from '@deepseek-ai/schemastery';
|
|
12
|
-
import type { GitActionRequest, GitActionResult, GitQueryRequest, GitQueryResponse, GitSnapshotRequest, GitSnapshotResult, GitSuggestRequest, GitSuggestResult, GitVersionInfo, GitVersionRequest } from './types.
|
|
13
|
-
export type { GitSnapshot, GitSnapshotResult, GitSnapshotRequest, GitFailure, GitCommit, GraphCommit, GitRef, GitChange, GitChangeStatus, GitAction, GitActionRequest, GitActionResult, GitErrorCode, GitQuery, GitQueryRequest, GitQueryResponse, GitQueryResult, GitBranch, GitFileStat, WorktreeStats, StashEntry, GitVersionRequest, GitVersionInfo, DiffViewMode, GraphStyle, DirEntry, ResetMode, GitSuggestRequest, GitSuggestResult, GitRemote, RemoteHostKind, } from './types.
|
|
14
|
-
export { normalizeConfig, DEFAULT_CONFIG, snapshotForSession, resolveWorkspace, parsePrimaryRemote } from './core.
|
|
15
|
-
export { createGitRunner } from './git.
|
|
16
|
-
export { parseStatus, parseGraphLog, parseBranches, parseNameStatus, parseStashList, parseTags, sumNumstat } from './parser.
|
|
17
|
-
export { parseRemote, classifyHost } from './remote.
|
|
18
|
-
export { isSafePath, planAction, runAction, classifyActionFailure } from './actions.
|
|
19
|
-
export { runQuery } from './queries.
|
|
20
|
-
export { runSuggest } from './suggest.
|
|
21
|
-
export { readVersionInfo, checkLatestVersion, compareVersions, parseRepository } from './version.
|
|
12
|
+
import type { GitActionRequest, GitActionResult, GitQueryRequest, GitQueryResponse, GitSnapshotRequest, GitSnapshotResult, GitSuggestRequest, GitSuggestResult, GitVersionInfo, GitVersionRequest } from './types.js';
|
|
13
|
+
export type { GitSnapshot, GitSnapshotResult, GitSnapshotRequest, GitFailure, GitCommit, GraphCommit, GitRef, GitChange, GitChangeStatus, GitAction, GitActionRequest, GitActionResult, GitErrorCode, GitQuery, GitQueryRequest, GitQueryResponse, GitQueryResult, GitBranch, GitFileStat, WorktreeStats, StashEntry, GitVersionRequest, GitVersionInfo, DiffViewMode, GraphStyle, DirEntry, ResetMode, GitSuggestRequest, GitSuggestResult, GitRemote, RemoteHostKind, } from './types.js';
|
|
14
|
+
export { normalizeConfig, DEFAULT_CONFIG, snapshotForSession, resolveWorkspace, parsePrimaryRemote } from './core.js';
|
|
15
|
+
export { createGitRunner } from './git.js';
|
|
16
|
+
export { parseStatus, parseGraphLog, parseBranches, parseNameStatus, parseStashList, parseTags, sumNumstat } from './parser.js';
|
|
17
|
+
export { parseRemote, classifyHost } from './remote.js';
|
|
18
|
+
export { isSafePath, planAction, runAction, classifyActionFailure } from './actions.js';
|
|
19
|
+
export { runQuery } from './queries.js';
|
|
20
|
+
export { runSuggest } from './suggest.js';
|
|
21
|
+
export { readVersionInfo, checkLatestVersion, compareVersions, parseRepository } from './version.js';
|
|
22
22
|
export declare class GitPanelService extends TypertRemoteService {
|
|
23
23
|
static inject: string[];
|
|
24
24
|
/**
|
|
25
|
-
* Config schema surfaced on the plugin detail page. `showInputPill
|
|
26
|
-
* `defaultDiffView` are `.volatile()`,
|
|
27
|
-
*
|
|
28
|
-
* of the UI form.
|
|
25
|
+
* Config schema surfaced on the plugin detail page. `showInputPill`,
|
|
26
|
+
* `defaultDiffView`, `graphStyle` and the suggest fields are `.volatile()`,
|
|
27
|
+
* so the settings host renders them as live-editable controls; the
|
|
28
|
+
* operational limits stay profile-only and out of the UI form.
|
|
29
29
|
*/
|
|
30
30
|
static Config: Schema<Schemastery.ObjectS<NoInfer<{
|
|
31
31
|
showInputPill: Schema<boolean, boolean, "volatile-defined">;
|
|
32
32
|
defaultDiffView: Schema<"split" | "unified", "split" | "unified", "volatile-defined">;
|
|
33
33
|
graphStyle: Schema<"compact" | "parallel", "compact" | "parallel", "volatile-defined">;
|
|
34
34
|
suggestEnabled: Schema<boolean, boolean, "volatile-defined">;
|
|
35
|
+
suggestMaxBytes: Schema<number, number, "volatile-defined">;
|
|
36
|
+
suggestMaxOutputTokens: Schema<number, number, "volatile-defined">;
|
|
37
|
+
suggestTimeoutMs: Schema<number, number, "volatile-defined">;
|
|
35
38
|
}>>, Schemastery.ObjectT<NoInfer<{
|
|
36
39
|
showInputPill: Schema<boolean, boolean, "volatile-defined">;
|
|
37
40
|
defaultDiffView: Schema<"split" | "unified", "split" | "unified", "volatile-defined">;
|
|
38
41
|
graphStyle: Schema<"compact" | "parallel", "compact" | "parallel", "volatile-defined">;
|
|
39
42
|
suggestEnabled: Schema<boolean, boolean, "volatile-defined">;
|
|
43
|
+
suggestMaxBytes: Schema<number, number, "volatile-defined">;
|
|
44
|
+
suggestMaxOutputTokens: Schema<number, number, "volatile-defined">;
|
|
45
|
+
suggestTimeoutMs: Schema<number, number, "volatile-defined">;
|
|
40
46
|
}>>, "plain">;
|
|
41
47
|
private readonly deps;
|
|
42
48
|
private config;
|