@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/lib/git/repo.js
CHANGED
|
@@ -6,109 +6,175 @@
|
|
|
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 { realpath, stat } from
|
|
10
|
-
import path from
|
|
11
|
-
import { GitToolError } from
|
|
12
|
-
import { FULL_OID_PATTERN } from
|
|
9
|
+
import { realpath, stat } from "node:fs/promises";
|
|
10
|
+
import path from "node:path";
|
|
11
|
+
import { GitToolError } from "../errors.js";
|
|
12
|
+
import { FULL_OID_PATTERN } from "./validate.js";
|
|
13
13
|
/** Extract the calling session's working directory, failing closed. */
|
|
14
14
|
export function requireSessionCwd(exec) {
|
|
15
15
|
const agent = exec.agent;
|
|
16
16
|
if (agent === undefined) {
|
|
17
|
-
throw new GitToolError(
|
|
17
|
+
throw new GitToolError("no-session-cwd", "this tool requires a calling agent session");
|
|
18
18
|
}
|
|
19
19
|
const cwd = agent.session.header.cwd;
|
|
20
|
-
if (typeof cwd !==
|
|
21
|
-
throw new GitToolError(
|
|
20
|
+
if (typeof cwd !== "string" || cwd.trim() === "") {
|
|
21
|
+
throw new GitToolError("no-session-cwd", "this session has no working directory; git inspection is not available");
|
|
22
22
|
}
|
|
23
23
|
return cwd;
|
|
24
24
|
}
|
|
25
25
|
/** Resolve the work-tree root containing `sessionCwd`, failing closed. */
|
|
26
26
|
export async function resolveRepositoryRoot(run, sessionCwd, options) {
|
|
27
|
-
const result = await run([
|
|
27
|
+
const result = await run(["rev-parse", "--show-toplevel"], {
|
|
28
28
|
cwd: sessionCwd,
|
|
29
29
|
timeoutMs: options.timeoutMs,
|
|
30
30
|
maxBytes: 64 * 1024,
|
|
31
31
|
});
|
|
32
32
|
const root = result.stdout.trim();
|
|
33
|
-
if (result.exitCode !== 0 || root ===
|
|
34
|
-
throw new GitToolError(
|
|
35
|
-
|
|
33
|
+
if (result.exitCode !== 0 || root === "") {
|
|
34
|
+
throw new GitToolError("not-a-git-repository", `the selected directory is not inside a git work tree (${sessionCwd}); ` +
|
|
35
|
+
"pass repository to select a repository inside the session directory or an operator-configured repository root");
|
|
36
36
|
}
|
|
37
37
|
return root;
|
|
38
38
|
}
|
|
39
39
|
function pathIsInside(target, root) {
|
|
40
40
|
const relative = path.relative(root, target);
|
|
41
|
-
return (relative ===
|
|
42
|
-
(!relative.startsWith(`..${path.sep}`) &&
|
|
41
|
+
return (relative === "" ||
|
|
42
|
+
(!relative.startsWith(`..${path.sep}`) &&
|
|
43
|
+
relative !== ".." &&
|
|
44
|
+
!path.isAbsolute(relative)));
|
|
45
|
+
}
|
|
46
|
+
/** Whether two canonical directories are the same directory. */
|
|
47
|
+
function sameDirectory(left, right) {
|
|
48
|
+
return pathIsInside(left, right) && pathIsInside(right, left);
|
|
43
49
|
}
|
|
44
50
|
async function canonicalDirectory(input, label) {
|
|
45
51
|
try {
|
|
46
52
|
const canonical = await realpath(input);
|
|
47
53
|
if (!(await stat(canonical)).isDirectory())
|
|
48
|
-
throw new Error(
|
|
54
|
+
throw new Error("not a directory");
|
|
49
55
|
return canonical;
|
|
50
56
|
}
|
|
51
57
|
catch {
|
|
52
|
-
throw new GitToolError(
|
|
58
|
+
throw new GitToolError("invalid-repository", `${label} is not an existing directory (${input})`);
|
|
53
59
|
}
|
|
54
60
|
}
|
|
55
61
|
/**
|
|
56
62
|
* Resolve the repository selected by one tool call without granting a general
|
|
57
63
|
* filesystem path escape. Omitting `requested` prefers the session repository
|
|
58
|
-
* and falls back only when there is exactly one configured root
|
|
59
|
-
*
|
|
60
|
-
* directory
|
|
64
|
+
* and falls back only when there is exactly one configured root; naming the
|
|
65
|
+
* session directory means the same default, which is what a session that is
|
|
66
|
+
* not itself a repository — a QA scratch directory — relies on. An explicit
|
|
67
|
+
* path elsewhere and its resolved work-tree root must both remain inside the
|
|
68
|
+
* session directory or an operator-configured root.
|
|
61
69
|
*/
|
|
62
70
|
export async function resolveToolRepository(run, exec, requested, options) {
|
|
63
71
|
const sessionCwd = requireSessionCwd(exec);
|
|
64
72
|
if (requested === undefined || requested === null) {
|
|
65
|
-
|
|
66
|
-
return await resolveRepositoryRoot(run, sessionCwd, { timeoutMs: options.timeoutMs });
|
|
67
|
-
}
|
|
68
|
-
catch (error) {
|
|
69
|
-
if (!(error instanceof GitToolError) || error.code !== 'not-a-git-repository')
|
|
70
|
-
throw error;
|
|
71
|
-
if (options.repositoryRoots.length === 1) {
|
|
72
|
-
return resolveToolRepository(run, exec, options.repositoryRoots[0], options);
|
|
73
|
-
}
|
|
74
|
-
if (options.repositoryRoots.length > 1) {
|
|
75
|
-
throw new GitToolError('not-a-git-repository', `the session directory is not inside a git work tree (${sessionCwd}); ` +
|
|
76
|
-
`select one configured repository root: ${options.repositoryRoots.join(', ')}`);
|
|
77
|
-
}
|
|
78
|
-
throw error;
|
|
79
|
-
}
|
|
73
|
+
return resolveDefaultRepository(run, sessionCwd, options);
|
|
80
74
|
}
|
|
81
|
-
if (typeof requested !==
|
|
82
|
-
throw new GitToolError(
|
|
75
|
+
if (typeof requested !== "string" || requested.trim() === "") {
|
|
76
|
+
throw new GitToolError("invalid-repository", "repository must be a non-empty path");
|
|
83
77
|
}
|
|
84
|
-
const canonicalSession = await canonicalDirectory(sessionCwd,
|
|
85
|
-
const configuredRoots = await Promise.all(options.repositoryRoots.map((root) => canonicalDirectory(root,
|
|
78
|
+
const canonicalSession = await canonicalDirectory(sessionCwd, "the session working directory");
|
|
79
|
+
const configuredRoots = await Promise.all(options.repositoryRoots.map((root) => canonicalDirectory(root, "a configured repository root")));
|
|
86
80
|
const allowedRoots = [canonicalSession, ...configuredRoots];
|
|
87
|
-
const selected = await canonicalDirectory(path.resolve(sessionCwd, requested.trim()),
|
|
81
|
+
const selected = await canonicalDirectory(path.resolve(sessionCwd, requested.trim()), "repository");
|
|
88
82
|
if (!allowedRoots.some((root) => pathIsInside(selected, root))) {
|
|
89
|
-
throw new GitToolError(
|
|
83
|
+
throw new GitToolError("repository-not-allowed", "repository is outside the session directory and configured repository roots");
|
|
90
84
|
}
|
|
91
|
-
|
|
92
|
-
|
|
85
|
+
// Naming the session directory is not a repository choice: it is the default
|
|
86
|
+
// a model that echoes its own working directory asks for, and it resolves
|
|
87
|
+
// exactly like an omitted argument.
|
|
88
|
+
if (sameDirectory(selected, canonicalSession)) {
|
|
89
|
+
return resolveDefaultRepository(run, sessionCwd, options);
|
|
90
|
+
}
|
|
91
|
+
return resolveSelectedRepository(run, selected, allowedRoots, options);
|
|
92
|
+
}
|
|
93
|
+
/**
|
|
94
|
+
* The default selection: the session repository, and only when the session
|
|
95
|
+
* directory is not one, the single configured root. Multiple roots require the
|
|
96
|
+
* model to choose, and no root at all is a plain refusal.
|
|
97
|
+
*/
|
|
98
|
+
async function resolveDefaultRepository(run, sessionCwd, options) {
|
|
99
|
+
try {
|
|
100
|
+
return await resolveRepositoryRoot(run, sessionCwd, {
|
|
101
|
+
timeoutMs: options.timeoutMs,
|
|
102
|
+
});
|
|
103
|
+
}
|
|
104
|
+
catch (error) {
|
|
105
|
+
if (!(error instanceof GitToolError) ||
|
|
106
|
+
error.code !== "not-a-git-repository") {
|
|
107
|
+
throw error;
|
|
108
|
+
}
|
|
109
|
+
const [only] = options.repositoryRoots;
|
|
110
|
+
if (only === undefined) {
|
|
111
|
+
throw new GitToolError("not-a-git-repository", selectionRefusal(sessionCwd, options.repositoryRoots));
|
|
112
|
+
}
|
|
113
|
+
if (options.repositoryRoots.length > 1) {
|
|
114
|
+
throw new GitToolError("not-a-git-repository", `the session directory is not inside a git work tree (${sessionCwd}); ` +
|
|
115
|
+
`select one configured repository root: ${options.repositoryRoots.join(", ")}`);
|
|
116
|
+
}
|
|
117
|
+
const [canonicalSession, canonicalRoot] = await Promise.all([
|
|
118
|
+
canonicalDirectory(sessionCwd, "the session working directory"),
|
|
119
|
+
canonicalDirectory(only, "a configured repository root"),
|
|
120
|
+
]);
|
|
121
|
+
// The operator pointed the root at the session directory itself: there is
|
|
122
|
+
// nothing else to resolve, and retrying the same directory would loop.
|
|
123
|
+
if (sameDirectory(canonicalRoot, canonicalSession)) {
|
|
124
|
+
throw new GitToolError("not-a-git-repository", selectionRefusal(sessionCwd, options.repositoryRoots));
|
|
125
|
+
}
|
|
126
|
+
return resolveSelectedRepository(run, canonicalRoot, [canonicalSession, canonicalRoot], options);
|
|
127
|
+
}
|
|
128
|
+
}
|
|
129
|
+
/** One explicit selection: it must be a work tree inside an allowed root. */
|
|
130
|
+
async function resolveSelectedRepository(run, selected, allowedRoots, options) {
|
|
131
|
+
let repoRoot;
|
|
132
|
+
try {
|
|
133
|
+
repoRoot = await resolveRepositoryRoot(run, selected, {
|
|
134
|
+
timeoutMs: options.timeoutMs,
|
|
135
|
+
});
|
|
136
|
+
}
|
|
137
|
+
catch (error) {
|
|
138
|
+
if (!(error instanceof GitToolError) ||
|
|
139
|
+
error.code !== "not-a-git-repository") {
|
|
140
|
+
throw error;
|
|
141
|
+
}
|
|
142
|
+
throw new GitToolError("not-a-git-repository", selectionRefusal(selected, options.repositoryRoots));
|
|
143
|
+
}
|
|
144
|
+
const canonicalRepoRoot = await canonicalDirectory(repoRoot, "the resolved repository root");
|
|
93
145
|
if (!allowedRoots.some((root) => pathIsInside(canonicalRepoRoot, root))) {
|
|
94
|
-
throw new GitToolError(
|
|
146
|
+
throw new GitToolError("repository-not-allowed", "the resolved git work tree escapes the allowed repository root");
|
|
95
147
|
}
|
|
96
148
|
return canonicalRepoRoot;
|
|
97
149
|
}
|
|
150
|
+
/**
|
|
151
|
+
* The refusal for a directory that names no repository. A deployment that
|
|
152
|
+
* configured roots gets them named: they are the only directories the model
|
|
153
|
+
* may select instead, and the tool parameter promises the same list. Without
|
|
154
|
+
* roots the refusal says so — the usual cause is a row that carries no
|
|
155
|
+
* `repositoryRoots`, which is what a preset-mounted instance of this plugin is
|
|
156
|
+
* until the operator configures the row that mounts it.
|
|
157
|
+
*/
|
|
158
|
+
function selectionRefusal(selected, repositoryRoots) {
|
|
159
|
+
const recovery = repositoryRoots.length === 0
|
|
160
|
+
? "this row exposes no repository roots, so only a repository inside the session directory can be read"
|
|
161
|
+
: `pass repository to select one of the configured repository roots: ${repositoryRoots.join(", ")}`;
|
|
162
|
+
return `the selected directory is not inside a git work tree (${selected}); ${recovery}`;
|
|
163
|
+
}
|
|
98
164
|
/**
|
|
99
165
|
* Canonicalize a validated hexadecimal commit id to the full object id of an
|
|
100
166
|
* existing commit. The `^{commit}` peel plus `--end-of-options` mean the
|
|
101
167
|
* model can only ever name a commit that git itself resolves.
|
|
102
168
|
*/
|
|
103
169
|
export async function canonicalizeCommit(run, repoRoot, oid, options) {
|
|
104
|
-
const result = await run([
|
|
170
|
+
const result = await run(["rev-parse", "--verify", "--end-of-options", `${oid}^{commit}`], {
|
|
105
171
|
cwd: repoRoot,
|
|
106
172
|
timeoutMs: options.timeoutMs,
|
|
107
173
|
maxBytes: 64 * 1024,
|
|
108
174
|
});
|
|
109
175
|
const full = result.stdout.trim();
|
|
110
176
|
if (result.exitCode !== 0 || !FULL_OID_PATTERN.test(full)) {
|
|
111
|
-
throw new GitToolError(
|
|
177
|
+
throw new GitToolError("invalid-oid", `no commit matches "${oid}" in this repository`);
|
|
112
178
|
}
|
|
113
179
|
return full;
|
|
114
180
|
}
|
package/lib/git/repo.js.map
CHANGED
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"repo.js","sourceRoot":"","sources":["../../src/git/repo.ts"],"names":[],"mappings":"AAAA;;;;;;;GAOG;AAEH,OAAO,EAAE,QAAQ,EAAE,IAAI,EAAE,MAAM,kBAAkB,CAAC;AAClD,OAAO,IAAI,MAAM,WAAW,CAAC;AAI7B,OAAO,EAAE,YAAY,EAAE,MAAM,cAAc,CAAC;AAC5C,OAAO,EAAE,gBAAgB,EAAE,MAAM,eAAe,CAAC;
|
|
1
|
+
{"version":3,"file":"repo.js","sourceRoot":"","sources":["../../src/git/repo.ts"],"names":[],"mappings":"AAAA;;;;;;;G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C9C,QAAQ,CAAC,QAAQ,EAAE,OAAO,CAAC;CAC5B;AAKD,wBAAsB,MAAM,CAC1B,IAAI,EAAE,SAAS,MAAM,EAAE,EACvB,OAAO,EAAE,aAAa,GACrB,OAAO,CAAC,YAAY,CAAC,CA2HvB"}
|
package/lib/git/runner.js
CHANGED
|
@@ -12,21 +12,21 @@
|
|
|
12
12
|
* - output is byte-capped and the process is killed when the cap or the
|
|
13
13
|
* timeout hits, with the truncation surfaced to the caller.
|
|
14
14
|
*/
|
|
15
|
-
import { spawn } from
|
|
16
|
-
import { GitToolError } from
|
|
17
|
-
import { buildGitEnv } from
|
|
15
|
+
import { spawn } from "node:child_process";
|
|
16
|
+
import { GitToolError } from "../errors.js";
|
|
17
|
+
import { buildGitEnv } from "./env.js";
|
|
18
18
|
/** Hardening arguments prepended to every git invocation. */
|
|
19
19
|
export const GIT_HARDENING_PREFIX = [
|
|
20
|
-
|
|
21
|
-
|
|
22
|
-
|
|
23
|
-
|
|
24
|
-
|
|
20
|
+
"--no-pager",
|
|
21
|
+
"-c",
|
|
22
|
+
"core.fsmonitor=false",
|
|
23
|
+
"-c",
|
|
24
|
+
"core.quotepath=false",
|
|
25
25
|
];
|
|
26
26
|
const DEFAULT_STDERR_MAX_BYTES = 16 * 1024;
|
|
27
27
|
const KILL_ESCALATION_MS = 500;
|
|
28
28
|
export async function runGit(argv, options) {
|
|
29
|
-
const program = options.program ??
|
|
29
|
+
const program = options.program ?? "git";
|
|
30
30
|
const args = [
|
|
31
31
|
...(options.programPrefixArgs ?? []),
|
|
32
32
|
...GIT_HARDENING_PREFIX,
|
|
@@ -38,12 +38,12 @@ export async function runGit(argv, options) {
|
|
|
38
38
|
child = spawn(program, [...args], {
|
|
39
39
|
cwd: options.cwd,
|
|
40
40
|
env: buildGitEnv(),
|
|
41
|
-
stdio: [
|
|
41
|
+
stdio: ["ignore", "pipe", "pipe"],
|
|
42
42
|
windowsHide: true,
|
|
43
43
|
});
|
|
44
44
|
}
|
|
45
45
|
catch (error) {
|
|
46
|
-
reject(new GitToolError(
|
|
46
|
+
reject(new GitToolError("git-failed", `git executable "${program}" could not be spawned: ${error.message}`));
|
|
47
47
|
return;
|
|
48
48
|
}
|
|
49
49
|
let settled = false;
|
|
@@ -61,7 +61,7 @@ export async function runGit(argv, options) {
|
|
|
61
61
|
child.kill();
|
|
62
62
|
const escalation = setTimeout(() => {
|
|
63
63
|
if (child.exitCode === null && child.signalCode === null)
|
|
64
|
-
child.kill(
|
|
64
|
+
child.kill("SIGKILL");
|
|
65
65
|
}, KILL_ESCALATION_MS);
|
|
66
66
|
escalation.unref?.();
|
|
67
67
|
};
|
|
@@ -71,8 +71,8 @@ export async function runGit(argv, options) {
|
|
|
71
71
|
}, Math.max(1, Math.floor(options.timeoutMs)));
|
|
72
72
|
timer.unref?.();
|
|
73
73
|
const onAbort = () => kill();
|
|
74
|
-
options.signal?.addEventListener(
|
|
75
|
-
child.stdout?.on(
|
|
74
|
+
options.signal?.addEventListener("abort", onAbort, { once: true });
|
|
75
|
+
child.stdout?.on("data", (chunk) => {
|
|
76
76
|
if (stdoutBytes >= stdoutCap) {
|
|
77
77
|
truncated = true;
|
|
78
78
|
kill();
|
|
@@ -89,7 +89,7 @@ export async function runGit(argv, options) {
|
|
|
89
89
|
stdoutChunks.push(chunk);
|
|
90
90
|
stdoutBytes += chunk.length;
|
|
91
91
|
});
|
|
92
|
-
child.stderr?.on(
|
|
92
|
+
child.stderr?.on("data", (chunk) => {
|
|
93
93
|
if (stderrBytes >= stderrCap)
|
|
94
94
|
return;
|
|
95
95
|
const remaining = stderrCap - stderrBytes;
|
|
@@ -106,24 +106,24 @@ export async function runGit(argv, options) {
|
|
|
106
106
|
return;
|
|
107
107
|
settled = true;
|
|
108
108
|
clearTimeout(timer);
|
|
109
|
-
options.signal?.removeEventListener(
|
|
109
|
+
options.signal?.removeEventListener("abort", onAbort);
|
|
110
110
|
resolve({
|
|
111
|
-
stdout: Buffer.concat(stdoutChunks).toString(
|
|
112
|
-
stderr: Buffer.concat(stderrChunks).toString(
|
|
111
|
+
stdout: Buffer.concat(stdoutChunks).toString("utf8"),
|
|
112
|
+
stderr: Buffer.concat(stderrChunks).toString("utf8"),
|
|
113
113
|
exitCode,
|
|
114
114
|
truncated,
|
|
115
115
|
timedOut,
|
|
116
116
|
});
|
|
117
117
|
};
|
|
118
|
-
child.on(
|
|
118
|
+
child.on("error", (error) => {
|
|
119
119
|
if (settled)
|
|
120
120
|
return;
|
|
121
121
|
settled = true;
|
|
122
122
|
clearTimeout(timer);
|
|
123
|
-
options.signal?.removeEventListener(
|
|
124
|
-
reject(new GitToolError(
|
|
123
|
+
options.signal?.removeEventListener("abort", onAbort);
|
|
124
|
+
reject(new GitToolError("git-failed", `git executable "${program}" could not be spawned: ${error.message}`));
|
|
125
125
|
});
|
|
126
|
-
child.on(
|
|
126
|
+
child.on("close", (code) => {
|
|
127
127
|
finish(code);
|
|
128
128
|
});
|
|
129
129
|
});
|
package/lib/git/runner.js.map
CHANGED
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"runner.js","sourceRoot":"","sources":["../../src/git/runner.ts"],"names":[],"mappings":"AAAA;;;;;;;;;;;;;GAaG;AAEH,OAAO,EAAE,KAAK,EAAE,MAAM,oBAAoB,CAAC;AAE3C,OAAO,EAAE,YAAY,EAAE,MAAM,cAAc,CAAC;AAC5C,OAAO,EAAE,WAAW,EAAE,MAAM,UAAU,CAAC;AAEvC,6DAA6D;AAC7D,MAAM,CAAC,MAAM,oBAAoB,GAAsB;IACrD,YAAY;IACZ,IAAI;IACJ,sBAAsB;IACtB,IAAI;IACJ,sBAAsB;CACvB,CAAC;AAiCF,MAAM,wBAAwB,GAAG,EAAE,GAAG,IAAI,CAAC;AAC3C,MAAM,kBAAkB,GAAG,GAAG,CAAC;AAE/B,MAAM,CAAC,KAAK,UAAU,MAAM,
|
|
1
|
+
{"version":3,"file":"runner.js","sourceRoot":"","sources":["../../src/git/runner.ts"],"names":[],"mappings":"AAA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
6
|
* repository-relative paths, and (c) literal search strings passed as single
|
|
7
7
|
* argv elements. Everything else is rejected before a process is spawned.
|
|
8
8
|
*/
|
|
9
|
-
import { GitToolError } from
|
|
9
|
+
import { GitToolError } from "../errors.js";
|
|
10
10
|
/** Abbreviated (7+) or full (40/64) hexadecimal commit id; nothing else. */
|
|
11
11
|
export const COMMIT_OID_PATTERN = /^[0-9a-fA-F]{7,64}$/;
|
|
12
12
|
/** Canonical full id as printed by `git rev-parse --verify`. */
|
|
@@ -20,13 +20,13 @@ export const MAX_LITERAL_LENGTH = 256;
|
|
|
20
20
|
* structurally impossible for a revision string to become a git option
|
|
21
21
|
* (`-p`, `--help`, `--upload-pack=...` all fail here).
|
|
22
22
|
*/
|
|
23
|
-
export function validateCommitOid(input, field =
|
|
24
|
-
if (typeof input !==
|
|
25
|
-
throw new GitToolError(
|
|
23
|
+
export function validateCommitOid(input, field = "oid") {
|
|
24
|
+
if (typeof input !== "string") {
|
|
25
|
+
throw new GitToolError("invalid-oid", `${field} must be a hexadecimal commit id`);
|
|
26
26
|
}
|
|
27
27
|
const value = input.trim();
|
|
28
28
|
if (!COMMIT_OID_PATTERN.test(value)) {
|
|
29
|
-
throw new GitToolError(
|
|
29
|
+
throw new GitToolError("invalid-oid", `${field} must be a hexadecimal commit id (7-64 hex chars), got something else`);
|
|
30
30
|
}
|
|
31
31
|
return value;
|
|
32
32
|
}
|
|
@@ -40,46 +40,46 @@ export function validateCommitOid(input, field = 'oid') {
|
|
|
40
40
|
*/
|
|
41
41
|
export function validateRepoRelativePath(input, field, options = {}) {
|
|
42
42
|
const required = options.required ?? false;
|
|
43
|
-
if (input === undefined || input === null || input ===
|
|
43
|
+
if (input === undefined || input === null || input === "") {
|
|
44
44
|
if (required) {
|
|
45
|
-
throw new GitToolError(
|
|
45
|
+
throw new GitToolError("invalid-path", `${field} is required`);
|
|
46
46
|
}
|
|
47
47
|
return undefined;
|
|
48
48
|
}
|
|
49
|
-
if (typeof input !==
|
|
50
|
-
throw new GitToolError(
|
|
49
|
+
if (typeof input !== "string") {
|
|
50
|
+
throw new GitToolError("invalid-path", `${field} must be a string`);
|
|
51
51
|
}
|
|
52
|
-
if (input.includes(
|
|
53
|
-
throw new GitToolError(
|
|
52
|
+
if (input.includes("\0")) {
|
|
53
|
+
throw new GitToolError("invalid-path", `${field} must not contain NUL bytes`);
|
|
54
54
|
}
|
|
55
55
|
if (input.length > MAX_PATH_LENGTH) {
|
|
56
|
-
throw new GitToolError(
|
|
56
|
+
throw new GitToolError("invalid-path", `${field} is longer than ${MAX_PATH_LENGTH} characters`);
|
|
57
57
|
}
|
|
58
|
-
const normalized = input.replaceAll(
|
|
59
|
-
if (normalized.startsWith(
|
|
60
|
-
throw new GitToolError(
|
|
58
|
+
const normalized = input.replaceAll("\\", "/").replaceAll(/\/+/g, "/");
|
|
59
|
+
if (normalized.startsWith("/")) {
|
|
60
|
+
throw new GitToolError("invalid-path", `${field} must be repository-relative, not absolute`);
|
|
61
61
|
}
|
|
62
62
|
if (/^[a-zA-Z]:/.test(normalized)) {
|
|
63
|
-
throw new GitToolError(
|
|
63
|
+
throw new GitToolError("invalid-path", `${field} must be repository-relative, not a drive path`);
|
|
64
64
|
}
|
|
65
65
|
const segments = normalized
|
|
66
|
-
.split(
|
|
67
|
-
.filter((segment) => segment !==
|
|
66
|
+
.split("/")
|
|
67
|
+
.filter((segment) => segment !== "" && segment !== ".");
|
|
68
68
|
if (segments.length === 0) {
|
|
69
69
|
if (required) {
|
|
70
|
-
throw new GitToolError(
|
|
70
|
+
throw new GitToolError("invalid-path", `${field} is required`);
|
|
71
71
|
}
|
|
72
72
|
return undefined;
|
|
73
73
|
}
|
|
74
74
|
for (const segment of segments) {
|
|
75
|
-
if (segment ===
|
|
76
|
-
throw new GitToolError(
|
|
75
|
+
if (segment === "..") {
|
|
76
|
+
throw new GitToolError("invalid-path", `${field} must not traverse outside the repository`);
|
|
77
77
|
}
|
|
78
|
-
if (segment.startsWith(
|
|
79
|
-
throw new GitToolError(
|
|
78
|
+
if (segment.startsWith("-")) {
|
|
79
|
+
throw new GitToolError("invalid-path", `${field} segments must not start with "-"`);
|
|
80
80
|
}
|
|
81
81
|
}
|
|
82
|
-
return segments.join(
|
|
82
|
+
return segments.join("/");
|
|
83
83
|
}
|
|
84
84
|
/**
|
|
85
85
|
* Validate a literal search string (commit-message grep, pickaxe, author).
|
|
@@ -88,24 +88,24 @@ export function validateRepoRelativePath(input, field, options = {}) {
|
|
|
88
88
|
* be reached through it; the caps only keep pathological input cheap.
|
|
89
89
|
*/
|
|
90
90
|
export function validateSearchLiteral(input, field) {
|
|
91
|
-
if (typeof input !==
|
|
92
|
-
throw new GitToolError(
|
|
91
|
+
if (typeof input !== "string") {
|
|
92
|
+
throw new GitToolError("invalid-argument", `${field} must be a string`);
|
|
93
93
|
}
|
|
94
|
-
if (input.includes(
|
|
95
|
-
throw new GitToolError(
|
|
94
|
+
if (input.includes("\0")) {
|
|
95
|
+
throw new GitToolError("invalid-argument", `${field} must not contain NUL bytes`);
|
|
96
96
|
}
|
|
97
97
|
const value = input.trim();
|
|
98
|
-
if (value ===
|
|
99
|
-
throw new GitToolError(
|
|
98
|
+
if (value === "") {
|
|
99
|
+
throw new GitToolError("invalid-argument", `${field} must not be empty`);
|
|
100
100
|
}
|
|
101
101
|
if (value.length > MAX_LITERAL_LENGTH) {
|
|
102
|
-
throw new GitToolError(
|
|
102
|
+
throw new GitToolError("invalid-argument", `${field} is longer than ${MAX_LITERAL_LENGTH} characters`);
|
|
103
103
|
}
|
|
104
104
|
return value;
|
|
105
105
|
}
|
|
106
106
|
/** Escape regex metacharacters so `--author=<literal>` stays a literal. */
|
|
107
107
|
export function escapeRegExpLiteral(value) {
|
|
108
|
-
return value.replace(/[.*+?^${}()|[\]\\]/g,
|
|
108
|
+
return value.replace(/[.*+?^${}()|[\]\\]/g, "\\$&");
|
|
109
109
|
}
|
|
110
110
|
/**
|
|
111
111
|
* Clamp a 1-based inclusive line range for blame.
|
|
@@ -117,11 +117,11 @@ export function escapeRegExpLiteral(value) {
|
|
|
117
117
|
export function clampLineRange(fromLine, toLine, maxSpan) {
|
|
118
118
|
const from = Math.floor(fromLine ?? 1);
|
|
119
119
|
if (!Number.isFinite(from) || from < 1) {
|
|
120
|
-
throw new GitToolError(
|
|
120
|
+
throw new GitToolError("invalid-argument", "fromLine must be a positive integer");
|
|
121
121
|
}
|
|
122
122
|
let to = toLine === undefined ? from + maxSpan - 1 : Math.floor(toLine);
|
|
123
123
|
if (!Number.isFinite(to) || to < from) {
|
|
124
|
-
throw new GitToolError(
|
|
124
|
+
throw new GitToolError("invalid-argument", "toLine must be an integer greater than or equal to fromLine");
|
|
125
125
|
}
|
|
126
126
|
let truncated = false;
|
|
127
127
|
if (to - from + 1 > maxSpan) {
|
package/lib/git/validate.js.map
CHANGED
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"validate.js","sourceRoot":"","sources":["../../src/git/validate.ts"],"names":[],"mappings":"AAAA;;;;;;;GAOG;AAEH,OAAO,EAAE,YAAY,EAAE,MAAM,cAAc,CAAC;AAE5C,4EAA4E;AAC5E,MAAM,CAAC,MAAM,kBAAkB,GAAG,qBAAqB,CAAC;AAExD,gEAAgE;AAChE,MAAM,CAAC,MAAM,gBAAgB,GAAG,mBAAmB,CAAC;AAEpD,MAAM,CAAC,MAAM,eAAe,GAAG,IAAI,CAAC;AAEpC,MAAM,CAAC,MAAM,kBAAkB,GAAG,GAAG,CAAC;AAEtC;;;;;;GAMG;AACH,MAAM,UAAU,iBAAiB,CAAC,KAAc,EAAE,KAAK,GAAG,KAAK;IAC7D,IAAI,OAAO,KAAK,KAAK,QAAQ,EAAE,CAAC;QAC9B,MAAM,IAAI,YAAY,
|
|
1
|
+
{"version":3,"file":"validate.js","sourceRoot":"","sources":["../../src/git/validate.ts"],"names":[],"mappings":"AAAA;;;;;;;GAOG;AAEH,OAAO,EAAE,YAAY,EAAE,MAAM,cAAc,CAAC;AAE5C,4EAA4E;AAC5E,MA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AAC,CAAC,CAAC;IACvC,IAAI,CAAC,MAAM,CAAC,QAAQ,CAAC,IAAI,CAAC,IAAI,IAAI,GAAG,CAAC,EAAE,CAAC;QACvC,MAAM,IAAI,YAAY,CACpB,kBAAkB,EAClB,qCAAqC,CACtC,CAAC;IACJ,CAAC;IACD,IAAI,EAAE,GAAG,MAAM,KAAK,SAAS,CAAC,CAAC,CAAC,IAAI,GAAG,OAAO,GAAG,CAAC,CAAC,CAAC,CAAC,IAAI,CAAC,KAAK,CAAC,MAAM,CAAC,CAAC;IACxE,IAAI,CAAC,MAAM,CAAC,QAAQ,CAAC,EAAE,CAAC,IAAI,EAAE,GAAG,IAAI,EAAE,CAAC;QACtC,MAAM,IAAI,YAAY,CACpB,kBAAkB,EAClB,6DAA6D,CAC9D,CAAC;IACJ,CAAC;IACD,IAAI,SAAS,GAAG,KAAK,CAAC;IACtB,IAAI,EAAE,GAAG,IAAI,GAAG,CAAC,GAAG,OAAO,EAAE,CAAC;QAC5B,EAAE,GAAG,IAAI,GAAG,OAAO,GAAG,CAAC,CAAC;QACxB,SAAS,GAAG,IAAI,CAAC;IACnB,CAAC;IACD,OAAO,EAAE,IAAI,EAAE,EAAE,EAAE,SAAS,EAAE,CAAC;AACjC,CAAC"}
|
package/lib/index.d.ts
CHANGED
|
@@ -8,24 +8,24 @@
|
|
|
8
8
|
* this plugin, hardened against repo-controlled config and ambient
|
|
9
9
|
* environment, byte-capped and time-boxed (SPEC §1, §6).
|
|
10
10
|
*/
|
|
11
|
-
import { type GitReadonlyConfig } from
|
|
12
|
-
export { GIT_READONLY_DEFAULTS, GitReadonlyConfigSchema, resolveGitReadonlyConfig, type GitReadonlyConfig, type ResolvedGitReadonlyConfig, } from
|
|
13
|
-
export { GitToolError, type GitToolErrorCode } from
|
|
14
|
-
export { buildGitEnv, FORCED_ENV_VALUES, REMOVED_ENV_KEYS } from
|
|
15
|
-
export { parseDecorations, parseFormatRecord, parseNumstat, parsePorcelainBlame, type BlameLine, type NumstatFile, } from
|
|
16
|
-
export { runGit, GIT_HARDENING_PREFIX, type GitRunOptions, type GitRunResult } from
|
|
17
|
-
export { canonicalizeCommit, requireSessionCwd, resolveRepositoryRoot, resolveToolRepository, type ToolExec, } from
|
|
18
|
-
export { clampLineRange, escapeRegExpLiteral, validateCommitOid, validateRepoRelativePath, validateSearchLiteral, } from
|
|
19
|
-
export { silentPluginLogger, type PluginLoggerLike } from
|
|
20
|
-
export { createGitBlameTool, type GitBlameResult } from
|
|
21
|
-
export { createGitContextTool, type GitContextResult } from
|
|
22
|
-
export { createGitHistoryTool, type GitHistoryResult } from
|
|
23
|
-
export { createGitShowTool, type GitShowResult } from
|
|
24
|
-
export type { GitToolDeps } from
|
|
11
|
+
import { type GitReadonlyConfig } from "./config.js";
|
|
12
|
+
export { GIT_READONLY_DEFAULTS, GitReadonlyConfigSchema, resolveGitReadonlyConfig, type GitReadonlyConfig, type ResolvedGitReadonlyConfig, } from "./config.js";
|
|
13
|
+
export { GitToolError, type GitToolErrorCode } from "./errors.js";
|
|
14
|
+
export { buildGitEnv, FORCED_ENV_VALUES, REMOVED_ENV_KEYS } from "./git/env.js";
|
|
15
|
+
export { parseDecorations, parseFormatRecord, parseNumstat, parsePorcelainBlame, type BlameLine, type NumstatFile, } from "./git/format.js";
|
|
16
|
+
export { runGit, GIT_HARDENING_PREFIX, type GitRunOptions, type GitRunResult, } from "./git/runner.js";
|
|
17
|
+
export { canonicalizeCommit, requireSessionCwd, resolveRepositoryRoot, resolveToolRepository, type ToolExec, } from "./git/repo.js";
|
|
18
|
+
export { clampLineRange, escapeRegExpLiteral, validateCommitOid, validateRepoRelativePath, validateSearchLiteral, } from "./git/validate.js";
|
|
19
|
+
export { silentPluginLogger, type PluginLoggerLike } from "./logging.js";
|
|
20
|
+
export { createGitBlameTool, type GitBlameResult } from "./tools/blame.js";
|
|
21
|
+
export { createGitContextTool, type GitContextResult, } from "./tools/context.js";
|
|
22
|
+
export { createGitHistoryTool, type GitHistoryResult, } from "./tools/history.js";
|
|
23
|
+
export { createGitShowTool, type GitShowResult } from "./tools/show.js";
|
|
24
|
+
export type { GitToolDeps } from "./tools/shared.js";
|
|
25
25
|
/** Cordis plugin name. */
|
|
26
26
|
export declare const name = "dsh-git-readonly";
|
|
27
27
|
/** The tools service is the only required host service. */
|
|
28
|
-
export declare const inject: readonly [
|
|
28
|
+
export declare const inject: readonly ["tools"];
|
|
29
29
|
/** Schemastery configuration contract (Cordis fills it before `apply`). */
|
|
30
30
|
export declare const Config: import("@deepseek-ai/schemastery").default<GitReadonlyConfig>;
|
|
31
31
|
/** Structural view of the host surface the plugin needs. */
|
package/lib/index.d.ts.map
CHANGED
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"index.d.ts","sourceRoot":"","sources":["../src/index.ts"],"names":[],"mappings":"AAAA;;;;;;;;;GASG;AAIH,OAAO,EAGL,KAAK,iBAAiB,EACvB,MAAM,aAAa,CAAC;AAOrB,OAAO,EACL,qBAAqB,EACrB,uBAAuB,EACvB,wBAAwB,EACxB,KAAK,iBAAiB,EACtB,KAAK,yBAAyB,GAC/B,MAAM,aAAa,CAAC;AACrB,OAAO,EAAE,YAAY,EAAE,KAAK,gBAAgB,EAAE,MAAM,aAAa,CAAC;AAClE,OAAO,EAAE,WAAW,EAAE,iBAAiB,EAAE,gBAAgB,EAAE,MAAM,cAAc,CAAC;AAChF,OAAO,EACL,gBAAgB,EAChB,iBAAiB,EACjB,YAAY,EACZ,mBAAmB,EACnB,KAAK,SAAS,EACd,KAAK,WAAW,GACjB,MAAM,iBAAiB,CAAC;AACzB,OAAO,
|
|
1
|
+
{"version":3,"file":"index.d.ts","sourceRoot":"","sources":["../src/index.ts"],"names":[],"mappings":"AAAA;;;;;;;;;GASG;AAIH,OAAO,EAGL,KAAK,iBAAiB,EACvB,MAAM,aAAa,CAAC;AAOrB,OAAO,EACL,qBAAqB,EACrB,uBAAuB,EACvB,wBAAwB,EACxB,KAAK,iBAAiB,EACtB,KAAK,yBAAyB,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