@yadsh/dsh-git-readonly 0.1.1 → 0.2.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.md +17 -7
- package/compatibility.json +2 -6
- package/lib/config.d.ts +7 -1
- package/lib/config.d.ts.map +1 -1
- package/lib/config.js +33 -15
- package/lib/config.js.map +1 -1
- package/lib/errors.d.ts +1 -1
- package/lib/errors.d.ts.map +1 -1
- package/lib/errors.js +1 -1
- package/lib/errors.js.map +1 -1
- package/lib/git/env.d.ts.map +1 -1
- package/lib/git/env.js +23 -23
- package/lib/git/env.js.map +1 -1
- package/lib/git/format.d.ts.map +1 -1
- package/lib/git/format.js +41 -31
- package/lib/git/format.js.map +1 -1
- package/lib/git/repo.d.ts +18 -7
- package/lib/git/repo.d.ts.map +1 -1
- package/lib/git/repo.js +83 -14
- package/lib/git/repo.js.map +1 -1
- package/lib/git/runner.d.ts.map +1 -1
- package/lib/git/runner.js +22 -22
- package/lib/git/runner.js.map +1 -1
- package/lib/git/validate.d.ts.map +1 -1
- package/lib/git/validate.js +34 -34
- package/lib/git/validate.js.map +1 -1
- package/lib/index.d.ts +15 -15
- package/lib/index.d.ts.map +1 -1
- package/lib/index.js +27 -27
- package/lib/index.js.map +1 -1
- package/lib/tools/blame.d.ts +2 -2
- package/lib/tools/blame.d.ts.map +1 -1
- package/lib/tools/blame.js +64 -55
- package/lib/tools/blame.js.map +1 -1
- package/lib/tools/context.d.ts +1 -1
- package/lib/tools/context.d.ts.map +1 -1
- package/lib/tools/context.js +52 -46
- package/lib/tools/context.js.map +1 -1
- package/lib/tools/history.d.ts +1 -1
- package/lib/tools/history.d.ts.map +1 -1
- package/lib/tools/history.js +96 -79
- package/lib/tools/history.js.map +1 -1
- package/lib/tools/shared.d.ts +9 -4
- package/lib/tools/shared.d.ts.map +1 -1
- package/lib/tools/shared.js +21 -8
- package/lib/tools/shared.js.map +1 -1
- package/lib/tools/show.d.ts +2 -2
- package/lib/tools/show.d.ts.map +1 -1
- package/lib/tools/show.js +90 -64
- package/lib/tools/show.js.map +1 -1
- package/package.json +2 -2
package/README.md
CHANGED
|
@@ -28,11 +28,12 @@ branch → history → blame → commit — without ever receiving a command lin
|
|
|
28
28
|
`GIT_TERMINAL_PROMPT=0`, `GIT_CONFIG_NOSYSTEM=1` and `LC_ALL=C` are
|
|
29
29
|
forced. The byte-capped, time-boxed process is killed at the limit and
|
|
30
30
|
the truncation is reported in the result.
|
|
31
|
-
- **Fail-closed
|
|
32
|
-
|
|
33
|
-
|
|
34
|
-
|
|
35
|
-
|
|
31
|
+
- **Fail-closed repository selection.** With no `repository` argument the
|
|
32
|
+
tools use the session working directory. An explicit directory must remain
|
|
33
|
+
inside that directory or an operator-configured `repositoryRoots` entry,
|
|
34
|
+
both before and after Git resolves the work-tree root. Canonical-path checks
|
|
35
|
+
reject traversal and symlink escapes. Nothing writes to the repository, and
|
|
36
|
+
no network git command exists in the tool surface.
|
|
36
37
|
- **Bounded, structured output.** Commits, files, blame lines and patches
|
|
37
38
|
come back as structured fields with explicit `truncated` flags, sized so
|
|
38
39
|
one call cannot flood the model context.
|
|
@@ -85,20 +86,29 @@ Configure the plugin under the `git-readonly` key in the DSH profile.
|
|
|
85
86
|
| --- | --- | --- | --- |
|
|
86
87
|
| `enabled` | boolean | `true` | When `false`, the tools are not registered at all. |
|
|
87
88
|
| `gitPath` | string | `"git"` | Git executable used for the inspections. |
|
|
89
|
+
| `repositoryRoots` | string[] | `[]` | Absolute directory roots that tools may select with `repository`, in addition to the session directory. |
|
|
88
90
|
| `timeoutMs` | number | `15000` | Wall-clock budget per git invocation, clamped to 1000–30000 ms. |
|
|
89
91
|
| `history.defaultLimit` | number | `20` | History page size when the model omits `limit` (1–50). |
|
|
90
92
|
| `history.maxLimit` | number | `100` | Hard upper bound for one history page (1–200). |
|
|
91
93
|
| `blame.maxLines` | number | `300` | Maximum lines attributed by one `dsh_git_blame` call (1–1000). |
|
|
92
94
|
| `patchBytes` | number | `200000` | Maximum patch bytes returned by `dsh_git_show` (4096–1048576). |
|
|
93
95
|
|
|
96
|
+
For a QA session rooted at `E:/qa-assistant/workspaces/work` that must inspect
|
|
97
|
+
the sibling checkout, configure the plugin with
|
|
98
|
+
`repositoryRoots: ["E:/qa-assistant/workspaces/code"]`. Because this is the
|
|
99
|
+
only configured root, `dsh_git_context {}` automatically uses it when the
|
|
100
|
+
session cwd is not itself a repository. The model can also pass the absolute
|
|
101
|
+
path explicitly. With multiple configured roots the model must select one;
|
|
102
|
+
the tool parameter and the typed error both list the available roots.
|
|
103
|
+
|
|
94
104
|
## Security model
|
|
95
105
|
|
|
96
106
|
The tools are read-only by construction, not by policy: the git subcommands
|
|
97
107
|
are fixed, every model-supplied string is validated before it reaches the
|
|
98
108
|
process, and the execution environment strips every redirection the parent
|
|
99
109
|
shell or the repository could inject. What remains is *provenance reading* —
|
|
100
|
-
log, show, diff output, blame — of the
|
|
101
|
-
|
|
110
|
+
log, show, diff output, blame — of the session repository or an explicitly
|
|
111
|
+
configured directory root. This is a deliberately narrower authority than a shell with a git
|
|
102
112
|
allow-list and narrower than general git access: there is no fetch, push,
|
|
103
113
|
clone, checkout, config, worktree or hook surface, and no OS-level sandbox
|
|
104
114
|
is required or assumed (SPEC §8).
|
package/compatibility.json
CHANGED
|
@@ -2,12 +2,8 @@
|
|
|
2
2
|
"deepseekHarness": {
|
|
3
3
|
"channel": "next",
|
|
4
4
|
"range": ">=0.1.5-rc.2 <0.2.0",
|
|
5
|
-
"testedReleases": [
|
|
6
|
-
|
|
7
|
-
],
|
|
8
|
-
"requiredHostFeatures": [
|
|
9
|
-
"tools/register"
|
|
10
|
-
]
|
|
5
|
+
"testedReleases": ["0.1.5-rc.2"],
|
|
6
|
+
"requiredHostFeatures": ["tools/register"]
|
|
11
7
|
},
|
|
12
8
|
"node": "^22.19.0 || >=24.0.0"
|
|
13
9
|
}
|
package/lib/config.d.ts
CHANGED
|
@@ -7,7 +7,7 @@
|
|
|
7
7
|
* clamped values, so the tools never deal with optional fields or unsafe
|
|
8
8
|
* limits. Every field is documented — this is the deployment contract.
|
|
9
9
|
*/
|
|
10
|
-
import z from
|
|
10
|
+
import z from "@deepseek-ai/schemastery";
|
|
11
11
|
/** Raw user-facing configuration. */
|
|
12
12
|
export interface GitReadonlyConfig {
|
|
13
13
|
/** Master switch; when false the tools are not registered at all. */
|
|
@@ -17,6 +17,11 @@ export interface GitReadonlyConfig {
|
|
|
17
17
|
* Test seam: stub programs are wired through the runner options, not here.
|
|
18
18
|
*/
|
|
19
19
|
readonly gitPath?: string;
|
|
20
|
+
/**
|
|
21
|
+
* Absolute directories that the model may select with the `repository`
|
|
22
|
+
* tool argument, in addition to the calling session directory.
|
|
23
|
+
*/
|
|
24
|
+
readonly repositoryRoots?: string[];
|
|
20
25
|
/** Wall-clock budget per git invocation, clamped to [1_000, 30_000] ms. */
|
|
21
26
|
readonly timeoutMs?: number;
|
|
22
27
|
readonly history?: {
|
|
@@ -36,6 +41,7 @@ export interface GitReadonlyConfig {
|
|
|
36
41
|
export interface ResolvedGitReadonlyConfig {
|
|
37
42
|
readonly enabled: boolean;
|
|
38
43
|
readonly gitPath: string;
|
|
44
|
+
readonly repositoryRoots: readonly string[];
|
|
39
45
|
readonly timeoutMs: number;
|
|
40
46
|
readonly historyDefaultLimit: number;
|
|
41
47
|
readonly historyMaxLimit: number;
|
package/lib/config.d.ts.map
CHANGED
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"config.d.ts","sourceRoot":"","sources":["../src/config.ts"],"names":[],"mappings":"AAAA;;;;;;;;GAQG;
|
|
1
|
+
{"version":3,"file":"config.d.ts","sourceRoot":"","sources":["../src/config.ts"],"names":[],"mappings":"AAAA;;;;;;;;GAQG;AAIH,OAAO,CAAC,MAAM,0BAA0B,CAAC;AAEzC,qCAAqC;AACrC,MAAM,WAAW,iBAAiB;IAChC,qEAAqE;IACrE,QAAQ,CAAC,OAAO,CAAC,EAAE,OAAO,CAAC;IAC3B;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|
|
|
7
7
|
* clamped values, so the tools never deal with optional fields or unsafe
|
|
8
8
|
* limits. Every field is documented — this is the deployment contract.
|
|
9
9
|
*/
|
|
10
|
-
import
|
|
10
|
+
import path from "node:path";
|
|
11
|
+
import z from "@deepseek-ai/schemastery";
|
|
11
12
|
export const GIT_READONLY_DEFAULTS = {
|
|
12
13
|
enabled: true,
|
|
13
|
-
gitPath:
|
|
14
|
+
gitPath: "git",
|
|
15
|
+
repositoryRoots: [],
|
|
14
16
|
timeoutMs: 15_000,
|
|
15
17
|
historyDefaultLimit: 20,
|
|
16
18
|
historyMaxLimit: 100,
|
|
@@ -18,55 +20,71 @@ export const GIT_READONLY_DEFAULTS = {
|
|
|
18
20
|
patchBytes: 200_000,
|
|
19
21
|
};
|
|
20
22
|
function clampInteger(value, min, max, fallback) {
|
|
21
|
-
if (typeof value !==
|
|
23
|
+
if (typeof value !== "number" || !Number.isFinite(value))
|
|
22
24
|
return fallback;
|
|
23
25
|
return Math.min(max, Math.max(min, Math.floor(value)));
|
|
24
26
|
}
|
|
25
27
|
export const GitReadonlyConfigSchema = z
|
|
26
28
|
.object({
|
|
27
|
-
enabled: z
|
|
29
|
+
enabled: z
|
|
30
|
+
.boolean()
|
|
31
|
+
.default(true)
|
|
32
|
+
.description("Register the read-only git tools."),
|
|
28
33
|
gitPath: z
|
|
29
34
|
.string()
|
|
30
|
-
.default(
|
|
31
|
-
.description(
|
|
35
|
+
.default("git")
|
|
36
|
+
.description("Git executable used for the read-only inspections."),
|
|
37
|
+
repositoryRoots: z
|
|
38
|
+
.array(z.string())
|
|
39
|
+
.default([])
|
|
40
|
+
.description("Absolute directory roots that tools may select with the repository argument."),
|
|
32
41
|
timeoutMs: z
|
|
33
42
|
.number()
|
|
34
43
|
.default(GIT_READONLY_DEFAULTS.timeoutMs)
|
|
35
|
-
.description(
|
|
44
|
+
.description("Wall-clock budget per git invocation in milliseconds (1000-30000)."),
|
|
36
45
|
history: z
|
|
37
46
|
.object({
|
|
38
47
|
defaultLimit: z
|
|
39
48
|
.number()
|
|
40
49
|
.default(GIT_READONLY_DEFAULTS.historyDefaultLimit)
|
|
41
|
-
.description(
|
|
50
|
+
.description("History page size when the model omits limit (1-50)."),
|
|
42
51
|
maxLimit: z
|
|
43
52
|
.number()
|
|
44
53
|
.default(GIT_READONLY_DEFAULTS.historyMaxLimit)
|
|
45
|
-
.description(
|
|
54
|
+
.description("Hard upper bound for one history page (1-200)."),
|
|
46
55
|
})
|
|
47
|
-
.description(
|
|
56
|
+
.description("Limits for dsh_git_history."),
|
|
48
57
|
blame: z
|
|
49
58
|
.object({
|
|
50
59
|
maxLines: z
|
|
51
60
|
.number()
|
|
52
61
|
.default(GIT_READONLY_DEFAULTS.blameMaxLines)
|
|
53
|
-
.description(
|
|
62
|
+
.description("Maximum lines attributed by one dsh_git_blame call (1-1000)."),
|
|
54
63
|
})
|
|
55
|
-
.description(
|
|
64
|
+
.description("Limits for dsh_git_blame."),
|
|
56
65
|
patchBytes: z
|
|
57
66
|
.number()
|
|
58
67
|
.default(GIT_READONLY_DEFAULTS.patchBytes)
|
|
59
|
-
.description(
|
|
68
|
+
.description("Maximum patch bytes returned by dsh_git_show (4096-1048576)."),
|
|
60
69
|
})
|
|
61
|
-
.description(
|
|
70
|
+
.description("Read-only git provenance tools.");
|
|
62
71
|
/** Normalize and clamp raw configuration into the resolved shape. */
|
|
63
72
|
export function resolveGitReadonlyConfig(raw) {
|
|
64
73
|
const config = (raw ?? {});
|
|
74
|
+
const repositoryRoots = [
|
|
75
|
+
...new Set((config.repositoryRoots ?? [])
|
|
76
|
+
.map((value) => value.trim())
|
|
77
|
+
.filter((value) => value !== "")),
|
|
78
|
+
];
|
|
79
|
+
if (repositoryRoots.some((value) => !path.isAbsolute(value))) {
|
|
80
|
+
throw new TypeError("dsh-git-readonly: repositoryRoots must contain only absolute paths");
|
|
81
|
+
}
|
|
65
82
|
return {
|
|
66
83
|
enabled: config.enabled ?? GIT_READONLY_DEFAULTS.enabled,
|
|
67
|
-
gitPath: typeof config.gitPath ===
|
|
84
|
+
gitPath: typeof config.gitPath === "string" && config.gitPath.trim() !== ""
|
|
68
85
|
? config.gitPath.trim()
|
|
69
86
|
: GIT_READONLY_DEFAULTS.gitPath,
|
|
87
|
+
repositoryRoots,
|
|
70
88
|
timeoutMs: clampInteger(config.timeoutMs, 1_000, 30_000, GIT_READONLY_DEFAULTS.timeoutMs),
|
|
71
89
|
historyDefaultLimit: clampInteger(config.history?.defaultLimit, 1, 50, GIT_READONLY_DEFAULTS.historyDefaultLimit),
|
|
72
90
|
historyMaxLimit: clampInteger(config.history?.maxLimit, 1, 200, GIT_READONLY_DEFAULTS.historyMaxLimit),
|
package/lib/config.js.map
CHANGED
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"config.js","sourceRoot":"","sources":["../src/config.ts"],"names":[],"mappings":"AAAA;;;;;;;;GAQG;AAEH,OAAO,CAAC,MAAM,0BAA0B,CAAC;
|
|
1
|
+
{"version":3,"file":"config.js","sourceRoot":"","sources":["../src/config.ts"],"names":[],"mappings":"AAAA;;;;;;;;GAQG;AAEH,OAAO,IAAI,MAAM,WAAW,CAAC;AAE7B,OAAO,CAAC,MAAM,0BAA0B,CAAC;AA4CzC,MAAM,CAAC,MAAM,qBAAqB,GAA8B;IAC9D,OAAO,EAAE,IAAI;IACb,OAAO,EAAE,KAAK;IACd,eAAe,EAAE,EAAE;IACnB,SAAS,EAAE,MAAM;IACjB,mBAAmB,EAAE,EAAE;IACvB,eAAe,EAAE,GAAG;IACpB,aAAa,EAAE,GAAG;IAClB,UAAU,EAAE,OAAO;CACpB,CAAC;AAEF,SAAS,YAAY,CACnB,KAAyB,EACzB,GAAW,EACX,GAAW,EACX,QAAgB;IAEhB,IAAI,OAAO,KAAK,KAAK,QAAQ,IAAI,CAAC,MAAM,CAAC,QAAQ,CAAC,KAAK,CAAC;QAAE,OAAO,QAAQ,CAAC;IAC1E,OAAO,IAAI,CAAC,GAAG,CAAC,GAAG,EAAE,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AG,EACH,qBAAqB,CAAC,eAAe,CACtC;QACD,aAAa,EAAE,YAAY,CACzB,MAAM,CAAC,KAAK,EAAE,QAAQ,EACtB,CAAC,EACD,KAAK,EACL,qBAAqB,CAAC,aAAa,CACpC;QACD,UAAU,EAAE,YAAY,CACtB,MAAM,CAAC,UAAU,EACjB,KAAK,EACL,SAAS,EACT,qBAAqB,CAAC,UAAU,CACjC;KACF,CAAC;AACJ,CAAC"}
|
package/lib/errors.d.ts
CHANGED
|
@@ -5,7 +5,7 @@
|
|
|
5
5
|
* `code`; the message is the human-facing explanation. Codes are never
|
|
6
6
|
* reused for a different meaning.
|
|
7
7
|
*/
|
|
8
|
-
export type GitToolErrorCode =
|
|
8
|
+
export type GitToolErrorCode = "no-session-cwd" | "not-a-git-repository" | "invalid-repository" | "repository-not-allowed" | "invalid-oid" | "invalid-path" | "invalid-argument" | "git-timeout" | "git-failed";
|
|
9
9
|
export declare class GitToolError extends Error {
|
|
10
10
|
readonly code: GitToolErrorCode;
|
|
11
11
|
constructor(code: GitToolErrorCode, message: string);
|
package/lib/errors.d.ts.map
CHANGED
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"errors.d.ts","sourceRoot":"","sources":["../src/errors.ts"],"names":[],"mappings":"AAAA;;;;;;GAMG;AAEH,MAAM,MAAM,gBAAgB,GACxB,gBAAgB,GAChB,sBAAsB,GACtB,aAAa,GACb,cAAc,GACd,kBAAkB,GAClB,aAAa,GACb,YAAY,CAAC;AAEjB,qBAAa,YAAa,SAAQ,KAAK;IACrC,QAAQ,CAAC,IAAI,EAAE,gBAAgB,CAAC;IAEhC,YAAY,IAAI,EAAE,gBAAgB,EAAE,OAAO,EAAE,MAAM,EAIlD;CACF"}
|
|
1
|
+
{"version":3,"file":"errors.d.ts","sourceRoot":"","sources":["../src/errors.ts"],"names":[],"mappings":"AAAA;;;;;;GAMG;AAEH,MAAM,MAAM,gBAAgB,GACxB,gBAAgB,GAChB,sBAAsB,GACtB,oBAAoB,GACpB,wBAAwB,GACxB,aAAa,GACb,cAAc,GACd,kBAAkB,GAClB,aAAa,GACb,YAAY,CAAC;AAEjB,qBAAa,YAAa,SAAQ,KAAK;IACrC,QAAQ,CAAC,IAAI,EAAE,gBAAgB,CAAC;IAEhC,YAAY,IAAI,EAAE,gBAAgB,EAAE,OAAO,EAAE,MAAM,EAIlD;CACF"}
|
package/lib/errors.js
CHANGED
package/lib/errors.js.map
CHANGED
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"errors.js","sourceRoot":"","sources":["../src/errors.ts"],"names":[],"mappings":"AAAA;;;;;;GAMG;
|
|
1
|
+
{"version":3,"file":"errors.js","sourceRoot":"","sources":["../src/errors.ts"],"names":[],"mappings":"AAAA;;;;;;GAMG;AAaH,MAAM,OAAO,YAAa,SAAQ,KAAK;IAC5B,IAAI,CAAmB;IAEhC,YAAY,IAAsB,EAAE,OAAe;QACjD,KAAK,CAAC,qBAAqB,IAAI,MAAM,OAAO,EAAE,CAAC,CAAC;QAChD,IAAI,CAAC,IAAI,GAAG,cAAc,CAAC;QAC3B,IAAI,CAAC,IAAI,GAAG,IAAI,CAAC;IACnB,CAAC;CACF"}
|
package/lib/git/env.d.ts.map
CHANGED
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"env.d.ts","sourceRoot":"","sources":["../../src/git/env.ts"],"names":[],"mappings":"AAAA;;;;;;;GAOG;AACH,eAAO,MAAM,gBAAgB,EAAE,SAAS,MAAM,EAkB7C,CAAC;AAEF;;;;;;;;;;GAUG;AACH,eAAO,MAAM,iBAAiB,EAAE,QAAQ,CAAC,MAAM,CAAC,MAAM,EAAE,MAAM,CAAC,CAO9D,CAAC;AAEF,gFAAgF;AAChF,wBAAgB,WAAW,
|
|
1
|
+
{"version":3,"file":"env.d.ts","sourceRoot":"","sources":["../../src/git/env.ts"],"names":[],"mappings":"AAAA;;;;;;;GAOG;AACH,eAAO,MAAM,gBAAgB,EAAE,SAAS,MAAM,EAkB7C,CAAC;AAEF;;;;;;;;;;GAUG;AACH,eAAO,MAAM,iBAAiB,EAAE,QAAQ,CAAC,MAAM,CAAC,MAAM,EAAE,MAAM,CAAC,CAO9D,CAAC;AAEF,gFAAgF;AAChF,wBAAgB,WAAW,CACzB,IAAI,GAAE,MAAM,CAAC,UAAwB,GACpC,MAAM,CAAC,UAAU,CASnB"}
|
package/lib/git/env.js
CHANGED
|
@@ -7,23 +7,23 @@
|
|
|
7
7
|
* the hardening CLI flags neutralize; this list closes the ambient half.
|
|
8
8
|
*/
|
|
9
9
|
export const REMOVED_ENV_KEYS = [
|
|
10
|
-
|
|
11
|
-
|
|
12
|
-
|
|
13
|
-
|
|
14
|
-
|
|
15
|
-
|
|
16
|
-
|
|
17
|
-
|
|
18
|
-
|
|
19
|
-
|
|
20
|
-
|
|
21
|
-
|
|
22
|
-
|
|
23
|
-
|
|
24
|
-
|
|
25
|
-
|
|
26
|
-
|
|
10
|
+
"GIT_DIR",
|
|
11
|
+
"GIT_WORK_TREE",
|
|
12
|
+
"GIT_INDEX_FILE",
|
|
13
|
+
"GIT_OBJECT_DIRECTORY",
|
|
14
|
+
"GIT_ALTERNATE_OBJECT_DIRECTORIES",
|
|
15
|
+
"GIT_NAMESPACE",
|
|
16
|
+
"GIT_EXTERNAL_DIFF",
|
|
17
|
+
"GIT_DIFF_OPTS",
|
|
18
|
+
"GIT_CONFIG_COUNT",
|
|
19
|
+
"GIT_CONFIG_PARAMETERS",
|
|
20
|
+
"GIT_CONFIG_SYSTEM",
|
|
21
|
+
"GIT_CONFIG_GLOBAL",
|
|
22
|
+
"GIT_ASKPASS",
|
|
23
|
+
"GIT_SSH",
|
|
24
|
+
"GIT_SSH_COMMAND",
|
|
25
|
+
"GIT_PROXY_COMMAND",
|
|
26
|
+
"GIT_PAGER",
|
|
27
27
|
];
|
|
28
28
|
/**
|
|
29
29
|
* Hardened values forced on top of the (filtered) parent environment.
|
|
@@ -37,12 +37,12 @@ export const REMOVED_ENV_KEYS = [
|
|
|
37
37
|
* output regardless of the host locale.
|
|
38
38
|
*/
|
|
39
39
|
export const FORCED_ENV_VALUES = {
|
|
40
|
-
LC_ALL:
|
|
41
|
-
GIT_OPTIONAL_LOCKS:
|
|
42
|
-
GIT_TERMINAL_PROMPT:
|
|
43
|
-
GIT_CONFIG_NOSYSTEM:
|
|
44
|
-
GIT_PAGER:
|
|
45
|
-
PAGER:
|
|
40
|
+
LC_ALL: "C",
|
|
41
|
+
GIT_OPTIONAL_LOCKS: "0",
|
|
42
|
+
GIT_TERMINAL_PROMPT: "0",
|
|
43
|
+
GIT_CONFIG_NOSYSTEM: "1",
|
|
44
|
+
GIT_PAGER: "cat",
|
|
45
|
+
PAGER: "cat",
|
|
46
46
|
};
|
|
47
47
|
/** Build the environment for one git invocation from the parent environment. */
|
|
48
48
|
export function buildGitEnv(base = process.env) {
|
package/lib/git/env.js.map
CHANGED
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"env.js","sourceRoot":"","sources":["../../src/git/env.ts"],"names":[],"mappings":"AAAA;;;;;;;GAOG;AACH,MAAM,CAAC,MAAM,gBAAgB,GAAsB;IACjD,SAAS;IACT,eAAe;IACf,gBAAgB;IAChB,sBAAsB;IACtB,kCAAkC;IAClC,eAAe;IACf,mBAAmB;IACnB,eAAe;IACf,kBAAkB;IAClB,uBAAuB;IACvB,mBAAmB;IACnB,mBAAmB;IACnB,aAAa;IACb,SAAS;IACT,iBAAiB;IACjB,mBAAmB;IACnB,WAAW;CACZ,CAAC;AAEF;;;;;;;;;;GAUG;AACH,MAAM,CAAC,MAAM,iBAAiB,GAAqC;IACjE,MAAM,EAAE,GAAG;IACX,kBAAkB,EAAE,GAAG;IACvB,mBAAmB,EAAE,GAAG;IACxB,mBAAmB,EAAE,GAAG;IACxB,SAAS,EAAE,KAAK;IAChB,KAAK,EAAE,KAAK;CACb,CAAC;AAEF,gFAAgF;AAChF,MAAM,UAAU,WAAW,
|
|
1
|
+
{"version":3,"file":"env.js","sourceRoot":"","sources":["../../src/git/env.ts"],"names":[],"mappings":"AAAA;;;;;;;GAOG;AACH,MAAM,CAAC,MAAM,gBAAgB,GAAsB;IACjD,SAAS;IACT,eAAe;IACf,gBAAgB;IAChB,sBAAsB;IACtB,kCAAkC;IAClC,eAAe;IACf,mBAAmB;IACnB,eAAe;IACf,kBAAkB;IAClB,uBAAuB;IACvB,mBAAmB;IACnB,mBAAmB;IACnB,aAAa;IACb,SAAS;IACT,iBAAiB;IACjB,mBAAmB;IACnB,WAAW;CACZ,CAAC;AAEF;;;;;;;;;;GAUG;AACH,MAAM,CAAC,MAAM,iBAAiB,GAAqC;IACjE,MAAM,EAAE,GAAG;IACX,kBAAkB,EAAE,GAAG;IACvB,mBAAmB,EAAE,GAAG;IACxB,mBAAmB,EAAE,GAAG;IACxB,SAAS,EAAE,KAAK;IAChB,KAAK,EAAE,KAAK;CACb,CAAC;AAEF,gFAAgF;AAChF,MAAM,UAAU,WAAW,CACzB,IAAI,GAAsB,OAAO,CAAC,GAAG;IAErC,MAAM,OAAO,GAAG,IAAI,GAAG,CAAS,gBAAgB,CAAC,CAAC;IAClD,MAAM,GAAG,GAAsB,EAAE,CAAC;IAClC,KAAK,MAAM,CAAC,GAAG,EAAE,KAAK,CAAC,IAAI,MAAM,CAAC,OAAO,CAAC,IAAI,CAAC,EAAE,CAAC;QAChD,IAAI,KAAK,KAAK,SAAS,IAAI,OAAO,CAAC,GAAG,CAAC,GAAG,CAAC;YAAE,SAAS;QACtD,GAAG,CAAC,GAAG,CAAC,GAAG,KAAK,CAAC;IACnB,CAAC;IACD,MAAM,CAAC,MAAM,CAAC,GAAG,EAAE,iBAAiB,CAAC,CAAC;IACtC,OAAO,GAAG,CAAC;AACb,CAAC"}
|
package/lib/git/format.d.ts.map
CHANGED
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"format.d.ts","sourceRoot":"","sources":["../../src/git/format.ts"],"names":[],"mappings":"AAAA;;;;;;;GAOG;AAEH,eAAO,MAAM,QA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
|
* The final field of a template absorbs any separator characters that
|
|
7
7
|
* appear inside it (e.g. newlines in a commit body).
|
|
8
8
|
*/
|
|
9
|
-
export const UNIT_SEP =
|
|
9
|
+
export const UNIT_SEP = "\x1f";
|
|
10
10
|
/** oid, shortOid, author, authoredAt (ISO), subject, decorations. */
|
|
11
|
-
export const HISTORY_FORMAT = [
|
|
11
|
+
export const HISTORY_FORMAT = ["%H", "%h", "%an", "%aI", "%s", "%d"].join(UNIT_SEP);
|
|
12
12
|
/** oid, shortOid, author, authoredAt (ISO), subject, parents, body. */
|
|
13
|
-
export const SHOW_META_FORMAT = [
|
|
13
|
+
export const SHOW_META_FORMAT = [
|
|
14
|
+
"%H",
|
|
15
|
+
"%h",
|
|
16
|
+
"%an",
|
|
17
|
+
"%aI",
|
|
18
|
+
"%s",
|
|
19
|
+
"%P",
|
|
20
|
+
"%b",
|
|
21
|
+
].join(UNIT_SEP);
|
|
14
22
|
/**
|
|
15
23
|
* Split one `--format` record. Fields before `fixedCount` must not contain
|
|
16
24
|
* the separator; the last field is the remainder of the record.
|
|
@@ -20,8 +28,8 @@ export function parseFormatRecord(record, fixedCount) {
|
|
|
20
28
|
if (parts.length <= fixedCount) {
|
|
21
29
|
const padded = [...parts];
|
|
22
30
|
while (padded.length < fixedCount)
|
|
23
|
-
padded.push(
|
|
24
|
-
padded.push(
|
|
31
|
+
padded.push("");
|
|
32
|
+
padded.push("");
|
|
25
33
|
return padded;
|
|
26
34
|
}
|
|
27
35
|
const head = parts.slice(0, fixedCount);
|
|
@@ -31,26 +39,28 @@ export function parseFormatRecord(record, fixedCount) {
|
|
|
31
39
|
/** Parse a `%d` decoration string into ref entries (without parens/tag prefix). */
|
|
32
40
|
export function parseDecorations(decorations) {
|
|
33
41
|
const trimmed = decorations.trim();
|
|
34
|
-
if (trimmed ===
|
|
42
|
+
if (trimmed === "")
|
|
35
43
|
return [];
|
|
36
|
-
const inner = trimmed.startsWith(
|
|
44
|
+
const inner = trimmed.startsWith("(") && trimmed.endsWith(")")
|
|
45
|
+
? trimmed.slice(1, -1)
|
|
46
|
+
: trimmed;
|
|
37
47
|
return inner
|
|
38
|
-
.split(
|
|
48
|
+
.split(",")
|
|
39
49
|
.map((entry) => entry.trim())
|
|
40
|
-
.filter((entry) => entry !==
|
|
41
|
-
.map((entry) =>
|
|
50
|
+
.filter((entry) => entry !== "")
|
|
51
|
+
.map((entry) => entry.startsWith("tag: ") ? entry.slice("tag: ".length) : entry);
|
|
42
52
|
}
|
|
43
53
|
/** Parse `--numstat` output into structured file rows. */
|
|
44
54
|
export function parseNumstat(stdout) {
|
|
45
55
|
const files = [];
|
|
46
|
-
for (const line of stdout.split(
|
|
47
|
-
const trimmed = line.replace(/\r$/,
|
|
48
|
-
if (trimmed ===
|
|
56
|
+
for (const line of stdout.split("\n")) {
|
|
57
|
+
const trimmed = line.replace(/\r$/, "");
|
|
58
|
+
if (trimmed === "")
|
|
49
59
|
continue;
|
|
50
|
-
const tabIndex1 = trimmed.indexOf(
|
|
60
|
+
const tabIndex1 = trimmed.indexOf("\t");
|
|
51
61
|
if (tabIndex1 < 0)
|
|
52
62
|
continue;
|
|
53
|
-
const tabIndex2 = trimmed.indexOf(
|
|
63
|
+
const tabIndex2 = trimmed.indexOf("\t", tabIndex1 + 1);
|
|
54
64
|
if (tabIndex2 < 0)
|
|
55
65
|
continue;
|
|
56
66
|
const additions = trimmed.slice(0, tabIndex1);
|
|
@@ -58,8 +68,8 @@ export function parseNumstat(stdout) {
|
|
|
58
68
|
const path = trimmed.slice(tabIndex2 + 1);
|
|
59
69
|
files.push({
|
|
60
70
|
path,
|
|
61
|
-
additions: additions ===
|
|
62
|
-
deletions: deletions ===
|
|
71
|
+
additions: additions === "-" ? undefined : Number.parseInt(additions, 10),
|
|
72
|
+
deletions: deletions === "-" ? undefined : Number.parseInt(deletions, 10),
|
|
63
73
|
});
|
|
64
74
|
}
|
|
65
75
|
return files;
|
|
@@ -75,23 +85,23 @@ export function parsePorcelainBlame(stdout) {
|
|
|
75
85
|
const lines = [];
|
|
76
86
|
const commitMeta = new Map();
|
|
77
87
|
let current;
|
|
78
|
-
for (const rawLine of stdout.split(
|
|
79
|
-
const line = rawLine.replace(/\r$/,
|
|
80
|
-
if (line.startsWith(
|
|
88
|
+
for (const rawLine of stdout.split("\n")) {
|
|
89
|
+
const line = rawLine.replace(/\r$/, "");
|
|
90
|
+
if (line.startsWith("\t")) {
|
|
81
91
|
if (current === undefined)
|
|
82
92
|
continue;
|
|
83
93
|
const meta = commitMeta.get(current.oid);
|
|
84
94
|
lines.push({
|
|
85
95
|
line: current.finalLine,
|
|
86
96
|
oid: current.oid,
|
|
87
|
-
author: meta?.author ??
|
|
88
|
-
authoredAt: meta?.authoredAt ??
|
|
89
|
-
summary: meta?.summary ??
|
|
97
|
+
author: meta?.author ?? "",
|
|
98
|
+
authoredAt: meta?.authoredAt ?? "",
|
|
99
|
+
summary: meta?.summary ?? "",
|
|
90
100
|
content: line.slice(1),
|
|
91
101
|
});
|
|
92
102
|
continue;
|
|
93
103
|
}
|
|
94
|
-
if (line ===
|
|
104
|
+
if (line === "")
|
|
95
105
|
continue;
|
|
96
106
|
const match = /^([0-9a-f]{40,64}) (\d+) (\d+)(?: \d+)?$/.exec(line);
|
|
97
107
|
if (match) {
|
|
@@ -99,7 +109,7 @@ export function parsePorcelainBlame(stdout) {
|
|
|
99
109
|
const finalLine = Number.parseInt(match[3], 10);
|
|
100
110
|
current = { oid, finalLine };
|
|
101
111
|
if (!commitMeta.has(oid)) {
|
|
102
|
-
commitMeta.set(oid, { author:
|
|
112
|
+
commitMeta.set(oid, { author: "", authoredAt: "", summary: "" });
|
|
103
113
|
}
|
|
104
114
|
continue;
|
|
105
115
|
}
|
|
@@ -108,17 +118,17 @@ export function parsePorcelainBlame(stdout) {
|
|
|
108
118
|
const meta = commitMeta.get(current.oid);
|
|
109
119
|
if (meta === undefined)
|
|
110
120
|
continue;
|
|
111
|
-
if (line.startsWith(
|
|
112
|
-
meta.author = line.slice(
|
|
121
|
+
if (line.startsWith("author ")) {
|
|
122
|
+
meta.author = line.slice("author ".length);
|
|
113
123
|
}
|
|
114
|
-
else if (line.startsWith(
|
|
115
|
-
const epoch = Number.parseInt(line.slice(
|
|
124
|
+
else if (line.startsWith("author-time ")) {
|
|
125
|
+
const epoch = Number.parseInt(line.slice("author-time ".length), 10);
|
|
116
126
|
if (Number.isFinite(epoch)) {
|
|
117
127
|
meta.authoredAt = new Date(epoch * 1000).toISOString();
|
|
118
128
|
}
|
|
119
129
|
}
|
|
120
|
-
else if (line.startsWith(
|
|
121
|
-
meta.summary = line.slice(
|
|
130
|
+
else if (line.startsWith("summary ")) {
|
|
131
|
+
meta.summary = line.slice("summary ".length);
|
|
122
132
|
}
|
|
123
133
|
}
|
|
124
134
|
return lines;
|
package/lib/git/format.js.map
CHANGED
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"format.js","sourceRoot":"","sources":["../../src/git/format.ts"],"names":[],"mappings":"AAAA;;;;;;;GAOG;AAEH,MAAM,CAAC,MAAM,QAAQ,GAAG,MAAM,CAAC;AAE/B,qEAAqE;AACrE,MAAM,CAAC,MAAM,cAAc,GAAG,CAAC,IAAI,EAAE,IAAI,EAAE,KAAK,EAAE,KAAK,EAAE,IAAI,EAAE,IAAI,CAAC,CAAC,IAAI,
|
|
1
|
+
{"version":3,"file":"format.js","sourceRoot":"","sources":["../../src/git/format.ts"],"names":[],"mappings":"AAAA;;;;;;;GAOG;AAEH,MAAM,CAAC,MAAM,QAAQ,GAAG,MAAM,CAAC;AAE/B,qEAAqE;AACrE,MAAM,CAAC,MAAM,cAAc,GAAG,CAAC,IAAI,EAAE,IAAI,EAAE,KAAK,EAAE,KAAK,EAAE,IAAI,EAAE,IAAI,CAAC,CAAC,IAAI,CACvE,QAAQ,CACT,CAAC;AAEF,uEAAuE;AACvE,MAAM,CAAC,MAAM,gBAAgB,GAAG;IAC9B,IAAI;IACJ,IAAI;IACJ,KAAK;IACL,KAAK;IACL,IAAI;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ACf,CAAC"}
|
package/lib/git/repo.d.ts
CHANGED
|
@@ -1,15 +1,15 @@
|
|
|
1
1
|
/**
|
|
2
2
|
* Repository resolution and commit canonicalization.
|
|
3
3
|
*
|
|
4
|
-
* The tools operate on exactly one repository per call: the one
|
|
5
|
-
* the session
|
|
6
|
-
* cwd — a session without a pinned cwd fails
|
|
7
|
-
* gaining git access to wherever the harness
|
|
4
|
+
* The tools operate on exactly one repository per call: the one selected
|
|
5
|
+
* from the session directory or the configured repository roots. There is no
|
|
6
|
+
* fallback to the host process cwd — a session without a pinned cwd fails
|
|
7
|
+
* closed instead of silently gaining git access to wherever the harness runs.
|
|
8
8
|
*/
|
|
9
|
-
import type { ToolRunContext } from
|
|
10
|
-
import type { GitRunResult } from
|
|
9
|
+
import type { ToolRunContext } from "@deepseek-ai/dsh-tools";
|
|
10
|
+
import type { GitRunResult } from "./runner.js";
|
|
11
11
|
/** Execution context handed to tool bodies (structural subset for tests). */
|
|
12
|
-
export type ToolExec = Pick<ToolRunContext,
|
|
12
|
+
export type ToolExec = Pick<ToolRunContext, "agent">;
|
|
13
13
|
/** Runner bound by the tools: argv + working directory in, git result out. */
|
|
14
14
|
export type GitRunner = (argv: readonly string[], options: {
|
|
15
15
|
readonly cwd: string;
|
|
@@ -22,6 +22,17 @@ export declare function requireSessionCwd(exec: ToolExec): string;
|
|
|
22
22
|
export declare function resolveRepositoryRoot(run: GitRunner, sessionCwd: string, options: {
|
|
23
23
|
timeoutMs: number;
|
|
24
24
|
}): Promise<string>;
|
|
25
|
+
/**
|
|
26
|
+
* Resolve the repository selected by one tool call without granting a general
|
|
27
|
+
* filesystem path escape. Omitting `requested` prefers the session repository
|
|
28
|
+
* and falls back only when there is exactly one configured root. An explicit
|
|
29
|
+
* path and its resolved work-tree root must both remain inside the session
|
|
30
|
+
* directory or an operator-configured root.
|
|
31
|
+
*/
|
|
32
|
+
export declare function resolveToolRepository(run: GitRunner, exec: ToolExec, requested: unknown, options: {
|
|
33
|
+
readonly timeoutMs: number;
|
|
34
|
+
readonly repositoryRoots: readonly string[];
|
|
35
|
+
}): Promise<string>;
|
|
25
36
|
/**
|
|
26
37
|
* Canonicalize a validated hexadecimal commit id to the full object id of an
|
|
27
38
|
* existing commit. The `^{commit}` peel plus `--end-of-options` mean the
|
package/lib/git/repo.d.ts.map
CHANGED
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"repo.d.ts","sourceRoot":"","sources":["../../src/git/repo.ts"],"names":[],"mappings":"AAAA;;;;;;;GAOG;
|
|
1
|
+
{"version":3,"file":"repo.d.ts","sourceRoot":"","sources":["../../src/git/repo.ts"],"names":[],"mappings":"AAAA;;;;;;;GAOG;AAKH,OAAO,KAAK,EAAE,cAAc,EAAE,MAAM,wBAAwB,CAAC;AAI7D,OAAO,KAAK,EAAE,YAAY,EAAE,MAAM,aAAa,CAAC;AAEhD,6EAA6E;AAC7E,MAAM,MAAM,QAAQ,GAAG,IAAI,CAAC,cAAc,EAAE,OAAO,CAAC,CAAC;AAErD,8EAA8E;AAC9E,MAAM,MAAM,SAAS,GAAG,CACtB,IAAI,EAAE,SAAS,MAAM,EAAE,EACvB,OAAO,EAAE;IACP,QAAQ,CAAC,GAAG,EAAE,MAAM,CAAC;IACrB,QAAQ,CAAC,SAAS,EAAE,MAAM,CAAC;IAC3B,QAAQ,CAAC,QAAQ,EAAE,MAAM,CAAC;CAC3B,KACE,OAAO,CAAC,YAAY,CAAC,CAAC;AAE3B,uEAAuE;AACvE,wBAAgB,iBAAiB,CAAC,IAAI,EAAE,QAAQ,GAAG,MAAM,CAgBxD;AAED,0EAA0E;AAC1E,wBAAsB,qBAAqB,CACzC,GAAG,EAAE,SAAS,EACd,UAAU,EAAE,MAAM,EAClB,OAAO,EAAE;IAAE,SAAS,EAAE,MAAM,CAAA;CAAE,GAC7B,OAAO,CAAC,MAAM,CAAC,CAejB;AA6BD;;;;;;GAMG;AACH,wBAAsB,qBAAqB,CACzC,GAAG,EAAE,SAAS,EACd,IAAI,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