@yadsh/dsh-git-readonly 0.2.0 → 0.2.2
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 +34 -5
- package/compatibility.json +2 -6
- package/lib/config.d.ts +1 -1
- package/lib/config.d.ts.map +1 -1
- package/lib/config.js +22 -19
- package/lib/config.js.map +1 -1
- package/lib/errors.d.ts +1 -1
- package/lib/errors.js +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 +8 -6
- package/lib/git/repo.d.ts.map +1 -1
- package/lib/git/repo.js +110 -44
- 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 +60 -54
- 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 +45 -43
- 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 +92 -78
- package/lib/tools/history.js.map +1 -1
- package/lib/tools/shared.d.ts +5 -5
- package/lib/tools/shared.d.ts.map +1 -1
- package/lib/tools/shared.js +16 -15
- 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 +86 -63
- package/lib/tools/show.js.map +1 -1
- package/package.json +4 -4
package/README.md
CHANGED
|
@@ -32,8 +32,12 @@ branch → history → blame → commit — without ever receiving a command lin
|
|
|
32
32
|
tools use the session working directory. An explicit directory must remain
|
|
33
33
|
inside that directory or an operator-configured `repositoryRoots` entry,
|
|
34
34
|
both before and after Git resolves the work-tree root. Canonical-path checks
|
|
35
|
-
reject traversal and symlink escapes.
|
|
36
|
-
no
|
|
35
|
+
reject traversal and symlink escapes. A selection that names the session
|
|
36
|
+
directory itself counts as no selection: a session pinned to a directory
|
|
37
|
+
that is not a repository resolves through the configured root instead of
|
|
38
|
+
failing, which is what a model echoing its own cwd depends on. Nothing
|
|
39
|
+
writes to the repository, and no network git command exists in the tool
|
|
40
|
+
surface.
|
|
37
41
|
- **Bounded, structured output.** Commits, files, blame lines and patches
|
|
38
42
|
come back as structured fields with explicit `truncated` flags, sized so
|
|
39
43
|
one call cannot flood the model context.
|
|
@@ -97,9 +101,34 @@ For a QA session rooted at `E:/qa-assistant/workspaces/work` that must inspect
|
|
|
97
101
|
the sibling checkout, configure the plugin with
|
|
98
102
|
`repositoryRoots: ["E:/qa-assistant/workspaces/code"]`. Because this is the
|
|
99
103
|
only configured root, `dsh_git_context {}` automatically uses it when the
|
|
100
|
-
session cwd is not itself a repository
|
|
101
|
-
|
|
102
|
-
|
|
104
|
+
session cwd is not itself a repository — and so does a call that names the
|
|
105
|
+
session cwd, which is what a model reciting its own working directory sends.
|
|
106
|
+
The model can also pass the absolute path explicitly. With multiple configured
|
|
107
|
+
roots the model must select one; the tool parameter and the typed error both
|
|
108
|
+
list the available roots.
|
|
109
|
+
|
|
110
|
+
**Configure the row that mounts the tools.** A deployment can mount this
|
|
111
|
+
plugin more than once, and each mount is its own instance with its own
|
|
112
|
+
configuration. An agent preset is the usual second mount: a preset row is
|
|
113
|
+
composed under the session's own scope, so the tools a chat calls are the
|
|
114
|
+
preset instance's — a `repositoryRoots` entry in the profile patch configures
|
|
115
|
+
the operator's harness sessions and is invisible to a preset session. Put the
|
|
116
|
+
roots on the preset's row:
|
|
117
|
+
|
|
118
|
+
```yaml
|
|
119
|
+
# <DSH_HOME>/.agent-presets/<preset>/agent.cordis.yml
|
|
120
|
+
- id: dsh-git-readonly
|
|
121
|
+
name: '@yadsh/dsh-git-readonly'
|
|
122
|
+
config:
|
|
123
|
+
repositoryRoots:
|
|
124
|
+
- E:/qa-assistant/workspaces/code
|
|
125
|
+
```
|
|
126
|
+
|
|
127
|
+
A missing entry is recognizable from the tool itself: the `repository`
|
|
128
|
+
parameter description reports the roots that instance actually has, and a
|
|
129
|
+
refusal says `this row exposes no repository roots`. Editing a live preset
|
|
130
|
+
takes effect for new chats — an already mounted session keeps the composition
|
|
131
|
+
it was created with.
|
|
103
132
|
|
|
104
133
|
## Security model
|
|
105
134
|
|
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. */
|
package/lib/config.d.ts.map
CHANGED
|
@@ -1 +1 @@
|
|
|
1
|
-
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B;AAED,eAAO,MAAM,qBAAqB,EAAE,yBASnC,CAAC;AAYF,eAAO,MAAM,uBAAuB,EAAE,CAAC,CAAC,iBAAiB,CAmDR,CAAC;AAElD,qEAAqE;AACrE,wBAAgB,wBAAwB,CACtC,GAAG,CAAC,EAAE,iBAAiB,GAAG,OAAO,GAChC,yBAAyB,CAoD3B"}
|
package/lib/config.js
CHANGED
|
@@ -7,11 +7,11 @@
|
|
|
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 path from
|
|
11
|
-
import z from
|
|
10
|
+
import path from "node:path";
|
|
11
|
+
import z from "@deepseek-ai/schemastery";
|
|
12
12
|
export const GIT_READONLY_DEFAULTS = {
|
|
13
13
|
enabled: true,
|
|
14
|
-
gitPath:
|
|
14
|
+
gitPath: "git",
|
|
15
15
|
repositoryRoots: [],
|
|
16
16
|
timeoutMs: 15_000,
|
|
17
17
|
historyDefaultLimit: 20,
|
|
@@ -20,65 +20,68 @@ export const GIT_READONLY_DEFAULTS = {
|
|
|
20
20
|
patchBytes: 200_000,
|
|
21
21
|
};
|
|
22
22
|
function clampInteger(value, min, max, fallback) {
|
|
23
|
-
if (typeof value !==
|
|
23
|
+
if (typeof value !== "number" || !Number.isFinite(value))
|
|
24
24
|
return fallback;
|
|
25
25
|
return Math.min(max, Math.max(min, Math.floor(value)));
|
|
26
26
|
}
|
|
27
27
|
export const GitReadonlyConfigSchema = z
|
|
28
28
|
.object({
|
|
29
|
-
enabled: z
|
|
29
|
+
enabled: z
|
|
30
|
+
.boolean()
|
|
31
|
+
.default(true)
|
|
32
|
+
.description("Register the read-only git tools."),
|
|
30
33
|
gitPath: z
|
|
31
34
|
.string()
|
|
32
|
-
.default(
|
|
33
|
-
.description(
|
|
35
|
+
.default("git")
|
|
36
|
+
.description("Git executable used for the read-only inspections."),
|
|
34
37
|
repositoryRoots: z
|
|
35
38
|
.array(z.string())
|
|
36
39
|
.default([])
|
|
37
|
-
.description(
|
|
40
|
+
.description("Absolute directory roots that tools may select with the repository argument."),
|
|
38
41
|
timeoutMs: z
|
|
39
42
|
.number()
|
|
40
43
|
.default(GIT_READONLY_DEFAULTS.timeoutMs)
|
|
41
|
-
.description(
|
|
44
|
+
.description("Wall-clock budget per git invocation in milliseconds (1000-30000)."),
|
|
42
45
|
history: z
|
|
43
46
|
.object({
|
|
44
47
|
defaultLimit: z
|
|
45
48
|
.number()
|
|
46
49
|
.default(GIT_READONLY_DEFAULTS.historyDefaultLimit)
|
|
47
|
-
.description(
|
|
50
|
+
.description("History page size when the model omits limit (1-50)."),
|
|
48
51
|
maxLimit: z
|
|
49
52
|
.number()
|
|
50
53
|
.default(GIT_READONLY_DEFAULTS.historyMaxLimit)
|
|
51
|
-
.description(
|
|
54
|
+
.description("Hard upper bound for one history page (1-200)."),
|
|
52
55
|
})
|
|
53
|
-
.description(
|
|
56
|
+
.description("Limits for dsh_git_history."),
|
|
54
57
|
blame: z
|
|
55
58
|
.object({
|
|
56
59
|
maxLines: z
|
|
57
60
|
.number()
|
|
58
61
|
.default(GIT_READONLY_DEFAULTS.blameMaxLines)
|
|
59
|
-
.description(
|
|
62
|
+
.description("Maximum lines attributed by one dsh_git_blame call (1-1000)."),
|
|
60
63
|
})
|
|
61
|
-
.description(
|
|
64
|
+
.description("Limits for dsh_git_blame."),
|
|
62
65
|
patchBytes: z
|
|
63
66
|
.number()
|
|
64
67
|
.default(GIT_READONLY_DEFAULTS.patchBytes)
|
|
65
|
-
.description(
|
|
68
|
+
.description("Maximum patch bytes returned by dsh_git_show (4096-1048576)."),
|
|
66
69
|
})
|
|
67
|
-
.description(
|
|
70
|
+
.description("Read-only git provenance tools.");
|
|
68
71
|
/** Normalize and clamp raw configuration into the resolved shape. */
|
|
69
72
|
export function resolveGitReadonlyConfig(raw) {
|
|
70
73
|
const config = (raw ?? {});
|
|
71
74
|
const repositoryRoots = [
|
|
72
75
|
...new Set((config.repositoryRoots ?? [])
|
|
73
76
|
.map((value) => value.trim())
|
|
74
|
-
.filter((value) => value !==
|
|
77
|
+
.filter((value) => value !== "")),
|
|
75
78
|
];
|
|
76
79
|
if (repositoryRoots.some((value) => !path.isAbsolute(value))) {
|
|
77
|
-
throw new TypeError(
|
|
80
|
+
throw new TypeError("dsh-git-readonly: repositoryRoots must contain only absolute paths");
|
|
78
81
|
}
|
|
79
82
|
return {
|
|
80
83
|
enabled: config.enabled ?? GIT_READONLY_DEFAULTS.enabled,
|
|
81
|
-
gitPath: typeof config.gitPath ===
|
|
84
|
+
gitPath: typeof config.gitPath === "string" && config.gitPath.trim() !== ""
|
|
82
85
|
? config.gitPath.trim()
|
|
83
86
|
: GIT_READONLY_DEFAULTS.gitPath,
|
|
84
87
|
repositoryRoots,
|
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,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,
|
|
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,EAA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CAAC,IAAI,EAAE;YACvB,CAAC,CAAC,qBAAqB,CAAC,OAAO;QACnC,eAAe;QACf,SAAS,EAAE,YAAY,CACrB,MAAM,CAAC,SAAS,EAChB,KAAK,EACL,MAAM,EACN,qBAAqB,CAAC,SAAS,CAChC;QACD,mBAAmB,EAAE,YAAY,CAC/B,MAAM,CAAC,OAAO,EAAE,YAAY,EAC5B,CAAC,EACD,EAAE,EACF,qBAAqB,CAAC,mBAAmB,CAC1C;QACD,eAAe,EAAE,YAAY,CAC3B,MAAM,CAAC,OAAO,EAAE,QAAQ,EACxB,CAAC,EACD,GAAG,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.js
CHANGED
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,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D,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,QAAQ,WAAS,CAAC;AAE/B,qEAAqE;AACrE,eAAO,MAAM,cAAc,
|
|
1
|
+
{"version":3,"file":"format.d.ts","sourceRoot":"","sources":["../../src/git/format.ts"],"names":[],"mappings":"AAAA;;;;;;;GAOG;AAEH,eAAO,MAAM,QAAQ,WAAS,CAAC;AAE/B,qEAAqE;AACrE,eAAO,MAAM,cAAc,QAE1B,CAAC;AAEF,uEAAuE;AACvE,eAAO,MAAM,gBAAgB,QAQb,CAAC;AAEjB;;;GAGG;AACH,wBAAgB,iBAAiB,CAC/B,MAAM,EAAE,MAAM,EACd,UAAU,EAAE,MAAM,GACjB,MAAM,EAAE,CAWV;AAED,mFAAmF;AACnF,wBAAgB,gBAAgB,CAAC,WAAW,EAAE,MAAM,GAAG,MAAM,EAAE,CAc9D;AAED,MAAM,WAAW,WAAW;IAC1B,QAAQ,CAAC,IAAI,EAAE,MAAM,CAAC;IACtB,oDAAoD;IACpD,QAAQ,CAAC,SAAS,CAAC,EAAE,MAAM,CAAC;IAC5B,QAAQ,CAAC,SAAS,CAAC,EAAE,MAAM,CAAC;CAC7B;AAED,0DAA0D;AAC1D,wBAAgB,YAAY,CAAC,MAAM,EAAE,MAAM,GAAG,WAAW,EAAE,CAmB1D;AAED,MAAM,WAAW,SAAS;IACxB,QAAQ,CAAC,IAAI,EAAE,MAAM,CAAC;IACtB,QAAQ,CAAC,GAAG,EAAE,MAAM,CAAC;IACrB,QAAQ,CAAC,MAAM,EAAE,MAAM,CAAC;IACxB,kDAAkD;IAClD,QAAQ,CAAC,UAAU,EAAE,MAAM,CAAC;IAC5B,QAAQ,CAAC,OAAO,EAAE,MAAM,CAAC;IACzB,sEAAsE;IACtE,QAAQ,CAAC,OAAO,EAAE,MAAM,CAAC;CAC1B;AAED;;;;;;GAMG;AACH,wBAAgB,mBAAmB,CAAC,MAAM,EAAE,MAAM,GAAG,SAAS,EAAE,CAqD/D"}
|
package/lib/git/format.js
CHANGED
|
@@ -6,11 +6,19 @@
|
|
|
6
6
|
* 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,MA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AAC;gBAC3B,IAAI,CAAC,UAAU,GAAG,IAAI,IAAI,CAAC,KAAK,GAAG,IAAI,CAAC,CAAC,WAAW,EAAE,CAAC;YACzD,CAAC;QACH,CAAC;aAAM,IAAI,IAAI,CAAC,UAAU,CAAC,UAAU,CAAC,EAAE,CAAC;YACvC,IAAI,CAAC,OAAO,GAAG,IAAI,CAAC,KAAK,CAAC,UAAU,CAAC,MAAM,CAAC,CAAC;QAC/C,CAAC;IACH,CAAC;IAED,OAAO,KAAK,CAAC;AACf,CAAC"}
|
package/lib/git/repo.d.ts
CHANGED
|
@@ -6,10 +6,10 @@
|
|
|
6
6
|
* fallback to the host process cwd — a session without a pinned cwd fails
|
|
7
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;
|
|
@@ -25,9 +25,11 @@ export declare function resolveRepositoryRoot(run: GitRunner, sessionCwd: string
|
|
|
25
25
|
/**
|
|
26
26
|
* Resolve the repository selected by one tool call without granting a general
|
|
27
27
|
* filesystem path escape. Omitting `requested` prefers the session repository
|
|
28
|
-
* and falls back only when there is exactly one configured root
|
|
29
|
-
*
|
|
30
|
-
* directory
|
|
28
|
+
* and falls back only when there is exactly one configured root; naming the
|
|
29
|
+
* session directory means the same default, which is what a session that is
|
|
30
|
+
* not itself a repository — a QA scratch directory — relies on. An explicit
|
|
31
|
+
* path elsewhere and its resolved work-tree root must both remain inside the
|
|
32
|
+
* session directory or an operator-configured root.
|
|
31
33
|
*/
|
|
32
34
|
export declare function resolveToolRepository(run: GitRunner, exec: ToolExec, requested: unknown, options: {
|
|
33
35
|
readonly timeoutMs: number;
|
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;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;
|
|
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,CAgB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