iosm-cli 0.2.7 → 0.2.9

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.
Files changed (149) hide show
  1. package/CHANGELOG.md +61 -1
  2. package/README.md +4 -4
  3. package/dist/cli/args.d.ts.map +1 -1
  4. package/dist/cli/args.js +12 -4
  5. package/dist/cli/args.js.map +1 -1
  6. package/dist/core/agent-profiles.d.ts.map +1 -1
  7. package/dist/core/agent-profiles.js +15 -2
  8. package/dist/core/agent-profiles.js.map +1 -1
  9. package/dist/core/agent-session.d.ts +3 -0
  10. package/dist/core/agent-session.d.ts.map +1 -1
  11. package/dist/core/agent-session.js +214 -2
  12. package/dist/core/agent-session.js.map +1 -1
  13. package/dist/core/sdk.d.ts +2 -2
  14. package/dist/core/sdk.d.ts.map +1 -1
  15. package/dist/core/sdk.js +7 -4
  16. package/dist/core/sdk.js.map +1 -1
  17. package/dist/core/settings-manager.d.ts +57 -0
  18. package/dist/core/settings-manager.d.ts.map +1 -1
  19. package/dist/core/settings-manager.js +197 -0
  20. package/dist/core/settings-manager.js.map +1 -1
  21. package/dist/core/shadow-guard.d.ts.map +1 -1
  22. package/dist/core/shadow-guard.js +12 -1
  23. package/dist/core/shadow-guard.js.map +1 -1
  24. package/dist/core/system-prompt.d.ts.map +1 -1
  25. package/dist/core/system-prompt.js +109 -4
  26. package/dist/core/system-prompt.js.map +1 -1
  27. package/dist/core/tools/db-run.d.ts +84 -0
  28. package/dist/core/tools/db-run.d.ts.map +1 -0
  29. package/dist/core/tools/db-run.js +690 -0
  30. package/dist/core/tools/db-run.js.map +1 -0
  31. package/dist/core/tools/git-common.d.ts +45 -0
  32. package/dist/core/tools/git-common.d.ts.map +1 -0
  33. package/dist/core/tools/git-common.js +185 -0
  34. package/dist/core/tools/git-common.js.map +1 -0
  35. package/dist/core/tools/git-read.d.ts +15 -13
  36. package/dist/core/tools/git-read.d.ts.map +1 -1
  37. package/dist/core/tools/git-read.js +101 -153
  38. package/dist/core/tools/git-read.js.map +1 -1
  39. package/dist/core/tools/git-write.d.ts +75 -0
  40. package/dist/core/tools/git-write.d.ts.map +1 -0
  41. package/dist/core/tools/git-write.js +298 -0
  42. package/dist/core/tools/git-write.js.map +1 -0
  43. package/dist/core/tools/index.d.ts +91 -1
  44. package/dist/core/tools/index.d.ts.map +1 -1
  45. package/dist/core/tools/index.js +26 -0
  46. package/dist/core/tools/index.js.map +1 -1
  47. package/dist/core/tools/lint-run.d.ts +42 -0
  48. package/dist/core/tools/lint-run.d.ts.map +1 -0
  49. package/dist/core/tools/lint-run.js +276 -0
  50. package/dist/core/tools/lint-run.js.map +1 -0
  51. package/dist/core/tools/task.js +1 -1
  52. package/dist/core/tools/task.js.map +1 -1
  53. package/dist/core/tools/test-run.d.ts +36 -0
  54. package/dist/core/tools/test-run.d.ts.map +1 -0
  55. package/dist/core/tools/test-run.js +255 -0
  56. package/dist/core/tools/test-run.js.map +1 -0
  57. package/dist/core/tools/typecheck-run.d.ts +44 -0
  58. package/dist/core/tools/typecheck-run.d.ts.map +1 -0
  59. package/dist/core/tools/typecheck-run.js +343 -0
  60. package/dist/core/tools/typecheck-run.js.map +1 -0
  61. package/dist/core/tools/verification-runner.d.ts +53 -0
  62. package/dist/core/tools/verification-runner.d.ts.map +1 -0
  63. package/dist/core/tools/verification-runner.js +235 -0
  64. package/dist/core/tools/verification-runner.js.map +1 -0
  65. package/dist/core/tools/web-search.d.ts +72 -0
  66. package/dist/core/tools/web-search.d.ts.map +1 -0
  67. package/dist/core/tools/web-search.js +702 -0
  68. package/dist/core/tools/web-search.js.map +1 -0
  69. package/dist/index.d.ts +2 -2
  70. package/dist/index.d.ts.map +1 -1
  71. package/dist/index.js +1 -1
  72. package/dist/index.js.map +1 -1
  73. package/dist/modes/interactive/components/branch-summary-message.d.ts.map +1 -1
  74. package/dist/modes/interactive/components/branch-summary-message.js +2 -1
  75. package/dist/modes/interactive/components/branch-summary-message.js.map +1 -1
  76. package/dist/modes/interactive/components/compaction-summary-message.d.ts.map +1 -1
  77. package/dist/modes/interactive/components/compaction-summary-message.js +2 -1
  78. package/dist/modes/interactive/components/compaction-summary-message.js.map +1 -1
  79. package/dist/modes/interactive/components/config-selector.d.ts.map +1 -1
  80. package/dist/modes/interactive/components/config-selector.js +7 -2
  81. package/dist/modes/interactive/components/config-selector.js.map +1 -1
  82. package/dist/modes/interactive/components/custom-message.d.ts.map +1 -1
  83. package/dist/modes/interactive/components/custom-message.js +2 -1
  84. package/dist/modes/interactive/components/custom-message.js.map +1 -1
  85. package/dist/modes/interactive/components/mcp-selector.d.ts.map +1 -1
  86. package/dist/modes/interactive/components/mcp-selector.js +3 -1
  87. package/dist/modes/interactive/components/mcp-selector.js.map +1 -1
  88. package/dist/modes/interactive/components/model-selector.d.ts.map +1 -1
  89. package/dist/modes/interactive/components/model-selector.js +12 -2
  90. package/dist/modes/interactive/components/model-selector.js.map +1 -1
  91. package/dist/modes/interactive/components/oauth-selector.d.ts.map +1 -1
  92. package/dist/modes/interactive/components/oauth-selector.js +11 -0
  93. package/dist/modes/interactive/components/oauth-selector.js.map +1 -1
  94. package/dist/modes/interactive/components/scoped-models-selector.d.ts.map +1 -1
  95. package/dist/modes/interactive/components/scoped-models-selector.js +16 -5
  96. package/dist/modes/interactive/components/scoped-models-selector.js.map +1 -1
  97. package/dist/modes/interactive/components/session-selector.d.ts.map +1 -1
  98. package/dist/modes/interactive/components/session-selector.js +4 -2
  99. package/dist/modes/interactive/components/session-selector.js.map +1 -1
  100. package/dist/modes/interactive/components/settings-selector.d.ts +25 -0
  101. package/dist/modes/interactive/components/settings-selector.d.ts.map +1 -1
  102. package/dist/modes/interactive/components/settings-selector.js +182 -2
  103. package/dist/modes/interactive/components/settings-selector.js.map +1 -1
  104. package/dist/modes/interactive/components/show-images-selector.d.ts.map +1 -1
  105. package/dist/modes/interactive/components/show-images-selector.js +7 -2
  106. package/dist/modes/interactive/components/show-images-selector.js.map +1 -1
  107. package/dist/modes/interactive/components/skill-invocation-message.d.ts.map +1 -1
  108. package/dist/modes/interactive/components/skill-invocation-message.js +4 -2
  109. package/dist/modes/interactive/components/skill-invocation-message.js.map +1 -1
  110. package/dist/modes/interactive/components/subagent-message.d.ts.map +1 -1
  111. package/dist/modes/interactive/components/subagent-message.js +3 -1
  112. package/dist/modes/interactive/components/subagent-message.js.map +1 -1
  113. package/dist/modes/interactive/components/task-plan-message.d.ts.map +1 -1
  114. package/dist/modes/interactive/components/task-plan-message.js +2 -1
  115. package/dist/modes/interactive/components/task-plan-message.js.map +1 -1
  116. package/dist/modes/interactive/components/theme-selector.d.ts.map +1 -1
  117. package/dist/modes/interactive/components/theme-selector.js +7 -2
  118. package/dist/modes/interactive/components/theme-selector.js.map +1 -1
  119. package/dist/modes/interactive/components/thinking-selector.d.ts.map +1 -1
  120. package/dist/modes/interactive/components/thinking-selector.js +7 -2
  121. package/dist/modes/interactive/components/thinking-selector.js.map +1 -1
  122. package/dist/modes/interactive/components/tool-execution.d.ts.map +1 -1
  123. package/dist/modes/interactive/components/tool-execution.js +25 -7
  124. package/dist/modes/interactive/components/tool-execution.js.map +1 -1
  125. package/dist/modes/interactive/components/tree-selector.d.ts.map +1 -1
  126. package/dist/modes/interactive/components/tree-selector.js +18 -3
  127. package/dist/modes/interactive/components/tree-selector.js.map +1 -1
  128. package/dist/modes/interactive/components/user-message-selector.d.ts.map +1 -1
  129. package/dist/modes/interactive/components/user-message-selector.js +8 -0
  130. package/dist/modes/interactive/components/user-message-selector.js.map +1 -1
  131. package/dist/modes/interactive/components/user-message.d.ts.map +1 -1
  132. package/dist/modes/interactive/components/user-message.js +2 -1
  133. package/dist/modes/interactive/components/user-message.js.map +1 -1
  134. package/dist/modes/interactive/interactive-mode.d.ts +8 -0
  135. package/dist/modes/interactive/interactive-mode.d.ts.map +1 -1
  136. package/dist/modes/interactive/interactive-mode.js +622 -11
  137. package/dist/modes/interactive/interactive-mode.js.map +1 -1
  138. package/dist/modes/interactive/theme/dark.json +39 -38
  139. package/dist/modes/interactive/theme/light.json +29 -29
  140. package/dist/modes/interactive/theme/theme.d.ts.map +1 -1
  141. package/dist/modes/interactive/theme/theme.js +16 -25
  142. package/dist/modes/interactive/theme/theme.js.map +1 -1
  143. package/dist/modes/interactive/theme/universal.json +85 -0
  144. package/docs/cli-reference.md +32 -2
  145. package/docs/configuration.md +86 -2
  146. package/docs/development-and-testing.md +1 -1
  147. package/docs/interactive-mode.md +8 -3
  148. package/docs/rpc-json-sdk.md +1 -1
  149. package/package.json +1 -1
@@ -1,11 +1,19 @@
1
- import { spawn, spawnSync } from "node:child_process";
2
1
  import { Type } from "@sinclair/typebox";
3
2
  import { resolveToCwd } from "./path-utils.js";
4
- import { DEFAULT_MAX_BYTES, DEFAULT_MAX_LINES, formatSize, truncateHead, } from "./truncate.js";
3
+ import { DEFAULT_GIT_TIMEOUT_SECONDS, normalizePositiveInt, normalizeRefLike, requireRefLike, resolveGitCommandOptions, runGitAndFormatOutput, } from "./git-common.js";
5
4
  const gitReadSchema = Type.Object({
6
- action: Type.Union([Type.Literal("status"), Type.Literal("diff"), Type.Literal("log"), Type.Literal("blame")], { description: "Git action: status | diff | log | blame." }),
5
+ action: Type.Union([
6
+ Type.Literal("status"),
7
+ Type.Literal("diff"),
8
+ Type.Literal("log"),
9
+ Type.Literal("blame"),
10
+ Type.Literal("show"),
11
+ Type.Literal("branch_list"),
12
+ Type.Literal("remote_list"),
13
+ Type.Literal("rev_parse"),
14
+ ], { description: "Git action: status | diff | log | blame | show | branch_list | remote_list | rev_parse." }),
7
15
  path: Type.Optional(Type.String({ description: "Repository working directory (default: current directory)." })),
8
- file: Type.Optional(Type.String({ description: "Optional file path for diff/log, required for blame." })),
16
+ file: Type.Optional(Type.String({ description: "Optional file path for diff/log/show, required for blame." })),
9
17
  base: Type.Optional(Type.String({ description: "Optional base ref/commit for diff." })),
10
18
  head: Type.Optional(Type.String({ description: "Optional head ref/commit for diff (requires base)." })),
11
19
  staged: Type.Optional(Type.Boolean({ description: "For diff action: compare staged changes." })),
@@ -16,116 +24,19 @@ const gitReadSchema = Type.Object({
16
24
  untracked: Type.Optional(Type.Boolean({ description: "For status action: include untracked files (default: true)." })),
17
25
  limit: Type.Optional(Type.Number({ description: "For log action: max entries (default: 20, max: 200)." })),
18
26
  since: Type.Optional(Type.String({ description: "For log action: git --since value (e.g. '2 weeks ago')." })),
19
- ref: Type.Optional(Type.String({ description: "For blame action: optional ref/commit." })),
27
+ ref: Type.Optional(Type.String({ description: "For blame/show action: optional ref/commit (show defaults to HEAD)." })),
20
28
  line_start: Type.Optional(Type.Number({ description: "For blame action: range start line (1-indexed)." })),
21
29
  line_end: Type.Optional(Type.Number({ description: "For blame action: range end line (1-indexed)." })),
30
+ all: Type.Optional(Type.Boolean({ description: "For branch_list action: include remote branches (default: true)." })),
31
+ verbose: Type.Optional(Type.Boolean({
32
+ description: "For branch_list/remote_list action: include verbose output (branch_list default: false, remote_list default: true).",
33
+ })),
34
+ target: Type.Optional(Type.String({ description: "For rev_parse action: ref/commit to resolve (default: HEAD)." })),
35
+ short: Type.Optional(Type.Boolean({ description: "For rev_parse action: output short hash (default: false)." })),
22
36
  timeout: Type.Optional(Type.Number({ description: "Timeout in seconds (default: 30)." })),
23
37
  });
24
- const DEFAULT_TIMEOUT_SECONDS = 30;
25
38
  const DEFAULT_LOG_LIMIT = 20;
26
39
  const MAX_LOG_LIMIT = 200;
27
- const MAX_CAPTURE_BYTES = 512 * 1024;
28
- function commandExists(command) {
29
- try {
30
- const result = spawnSync(command, ["--version"], { stdio: "pipe" });
31
- const err = result.error;
32
- return !err || err.code !== "ENOENT";
33
- }
34
- catch {
35
- return false;
36
- }
37
- }
38
- function normalizePositiveInt(raw, fallback, field) {
39
- if (raw === undefined)
40
- return fallback;
41
- const value = Math.floor(raw);
42
- if (!Number.isFinite(value) || value <= 0) {
43
- throw new Error(`${field} must be a positive number.`);
44
- }
45
- return value;
46
- }
47
- function runGitCommand(args, cwd, timeoutMs, signal) {
48
- return new Promise((resolve, reject) => {
49
- if (signal?.aborted) {
50
- reject(new Error("Operation aborted"));
51
- return;
52
- }
53
- const child = spawn("git", args, {
54
- cwd,
55
- stdio: ["ignore", "pipe", "pipe"],
56
- });
57
- let stdoutChunks = [];
58
- let stderrChunks = [];
59
- let stdoutBytes = 0;
60
- let stderrBytes = 0;
61
- let captureTruncated = false;
62
- let timedOut = false;
63
- let aborted = false;
64
- let settled = false;
65
- const settle = (fn) => {
66
- if (!settled) {
67
- settled = true;
68
- fn();
69
- }
70
- };
71
- const captureChunk = (chunk, chunks, currentBytes) => {
72
- if (currentBytes >= MAX_CAPTURE_BYTES) {
73
- return { nextBytes: currentBytes, truncated: true };
74
- }
75
- const remaining = MAX_CAPTURE_BYTES - currentBytes;
76
- if (chunk.length <= remaining) {
77
- chunks.push(chunk);
78
- return { nextBytes: currentBytes + chunk.length, truncated: false };
79
- }
80
- chunks.push(chunk.subarray(0, remaining));
81
- return { nextBytes: MAX_CAPTURE_BYTES, truncated: true };
82
- };
83
- const timeoutHandle = setTimeout(() => {
84
- timedOut = true;
85
- child.kill("SIGTERM");
86
- }, Math.max(1000, timeoutMs));
87
- const onAbort = () => {
88
- aborted = true;
89
- child.kill("SIGTERM");
90
- };
91
- signal?.addEventListener("abort", onAbort, { once: true });
92
- const cleanup = () => {
93
- clearTimeout(timeoutHandle);
94
- signal?.removeEventListener("abort", onAbort);
95
- };
96
- child.stdout.on("data", (chunk) => {
97
- const captured = captureChunk(chunk, stdoutChunks, stdoutBytes);
98
- stdoutBytes = captured.nextBytes;
99
- captureTruncated = captureTruncated || captured.truncated;
100
- });
101
- child.stderr.on("data", (chunk) => {
102
- const captured = captureChunk(chunk, stderrChunks, stderrBytes);
103
- stderrBytes = captured.nextBytes;
104
- captureTruncated = captureTruncated || captured.truncated;
105
- });
106
- child.on("error", (error) => {
107
- cleanup();
108
- settle(() => reject(new Error(`Failed to run git: ${error.message}`)));
109
- });
110
- child.on("close", (code) => {
111
- cleanup();
112
- if (aborted) {
113
- settle(() => reject(new Error("Operation aborted")));
114
- return;
115
- }
116
- if (timedOut) {
117
- settle(() => reject(new Error(`Command timed out after ${Math.round(timeoutMs / 1000)}s`)));
118
- return;
119
- }
120
- settle(() => resolve({
121
- stdout: Buffer.concat(stdoutChunks).toString("utf-8"),
122
- stderr: Buffer.concat(stderrChunks).toString("utf-8"),
123
- exitCode: code ?? -1,
124
- captureTruncated,
125
- }));
126
- });
127
- });
128
- }
129
40
  function buildStatusArgs(input) {
130
41
  const porcelain = input.porcelain ?? true;
131
42
  const includeUntracked = input.untracked ?? true;
@@ -143,15 +54,17 @@ function buildDiffArgs(input) {
143
54
  throw new Error("git_read diff requires base when head is provided.");
144
55
  }
145
56
  const context = normalizePositiveInt(input.context, 3, "context");
57
+ const base = normalizeRefLike(input.base, "base");
58
+ const head = normalizeRefLike(input.head, "head");
146
59
  const args = ["diff", "--no-color", `--unified=${context}`];
147
60
  if (input.staged) {
148
61
  args.push("--staged");
149
62
  }
150
- if (input.base && input.head) {
151
- args.push(`${input.base}..${input.head}`);
63
+ if (base && head) {
64
+ args.push(`${base}..${head}`);
152
65
  }
153
- else if (input.base) {
154
- args.push(input.base);
66
+ else if (base) {
67
+ args.push(base);
155
68
  }
156
69
  if (input.file) {
157
70
  args.push("--", input.file);
@@ -185,8 +98,9 @@ function buildBlameArgs(input) {
185
98
  throw new Error("git_read blame requires both line_start and line_end when specifying a range.");
186
99
  }
187
100
  const args = ["blame", "--line-porcelain"];
188
- if (input.ref) {
189
- args.push(input.ref);
101
+ const ref = normalizeRefLike(input.ref, "ref");
102
+ if (ref) {
103
+ args.push(ref);
190
104
  }
191
105
  if (hasLineStart && hasLineEnd) {
192
106
  const lineStart = normalizePositiveInt(input.line_start, 1, "line_start");
@@ -199,54 +113,88 @@ function buildBlameArgs(input) {
199
113
  args.push("--", input.file);
200
114
  return args;
201
115
  }
202
- function buildGitArgs(input) {
203
- if (input.action === "status")
204
- return buildStatusArgs(input);
205
- if (input.action === "diff")
206
- return buildDiffArgs(input);
207
- if (input.action === "log")
208
- return buildLogArgs(input);
209
- return buildBlameArgs(input);
116
+ function buildShowArgs(input) {
117
+ const ref = requireRefLike(input.ref ?? "HEAD", "ref");
118
+ const args = ["show", "--no-color", ref];
119
+ if (input.file) {
120
+ args.push("--", input.file);
121
+ }
122
+ return args;
123
+ }
124
+ function buildBranchListArgs(input) {
125
+ const includeAll = input.all ?? true;
126
+ const verbose = input.verbose ?? false;
127
+ const args = ["branch", "--list"];
128
+ if (includeAll) {
129
+ args.push("--all");
130
+ }
131
+ if (verbose) {
132
+ args.push("--verbose");
133
+ }
134
+ return args;
135
+ }
136
+ function buildRemoteListArgs(input) {
137
+ const verbose = input.verbose ?? true;
138
+ const args = ["remote"];
139
+ if (verbose) {
140
+ args.push("-v");
141
+ }
142
+ return args;
143
+ }
144
+ function buildRevParseArgs(input) {
145
+ const target = requireRefLike(input.target ?? "HEAD", "target");
146
+ const args = ["rev-parse"];
147
+ if (input.short) {
148
+ args.push("--short");
149
+ }
150
+ args.push(target);
151
+ return args;
152
+ }
153
+ function buildGitReadArgs(input) {
154
+ switch (input.action) {
155
+ case "status":
156
+ return buildStatusArgs(input);
157
+ case "diff":
158
+ return buildDiffArgs(input);
159
+ case "log":
160
+ return buildLogArgs(input);
161
+ case "blame":
162
+ return buildBlameArgs(input);
163
+ case "show":
164
+ return buildShowArgs(input);
165
+ case "branch_list":
166
+ return buildBranchListArgs(input);
167
+ case "remote_list":
168
+ return buildRemoteListArgs(input);
169
+ case "rev_parse":
170
+ return buildRevParseArgs(input);
171
+ default:
172
+ throw new Error(`Unsupported git_read action: ${input.action}`);
173
+ }
210
174
  }
211
175
  export function createGitReadTool(cwd, options) {
212
- const hasCommand = options?.commandExists ?? commandExists;
213
- const runCommand = options?.runCommand ?? runGitCommand;
176
+ const { hasCommand, runCommand } = resolveGitCommandOptions(options);
214
177
  return {
215
178
  name: "git_read",
216
179
  label: "git_read",
217
- description: "Structured read-only git introspection. Actions: status | diff | log | blame. Uses safe argv execution without shell interpolation.",
180
+ description: "Structured read-only git introspection. Actions: status | diff | log | blame | show | branch_list | remote_list | rev_parse. Uses safe argv execution without shell interpolation.",
218
181
  parameters: gitReadSchema,
219
182
  execute: async (_toolCallId, input, signal) => {
220
183
  if (!hasCommand("git")) {
221
184
  throw new Error("git command is not available.");
222
185
  }
223
186
  const repoCwd = resolveToCwd(input.path || ".", cwd);
224
- const args = buildGitArgs(input);
225
- const timeoutSeconds = normalizePositiveInt(input.timeout, DEFAULT_TIMEOUT_SECONDS, "timeout");
226
- const result = await runCommand(args, repoCwd, timeoutSeconds * 1000, signal);
227
- if (result.exitCode !== 0) {
228
- const errorText = result.stderr.trim() || result.stdout.trim() || `git_read ${input.action} failed with exit code ${result.exitCode}`;
229
- throw new Error(errorText);
230
- }
231
- let output = result.stdout.trimEnd();
232
- if (!output && result.stderr.trim().length > 0) {
233
- output = result.stderr.trimEnd();
234
- }
235
- if (!output) {
236
- output = "No output";
237
- }
238
- const truncation = truncateHead(output);
239
- let finalOutput = truncation.content;
240
- const notices = [];
241
- if (truncation.truncated) {
242
- notices.push(`${formatSize(DEFAULT_MAX_BYTES)} output limit reached`);
243
- }
244
- if (result.captureTruncated) {
245
- notices.push(`capture limit reached (${formatSize(MAX_CAPTURE_BYTES)})`);
246
- }
247
- if (notices.length > 0) {
248
- finalOutput += `\n\n[${notices.join(". ")} · showing up to ${DEFAULT_MAX_LINES} lines]`;
249
- }
187
+ const args = buildGitReadArgs(input);
188
+ const timeoutSeconds = normalizePositiveInt(input.timeout, DEFAULT_GIT_TIMEOUT_SECONDS, "timeout");
189
+ const result = await runGitAndFormatOutput({
190
+ toolName: "git_read",
191
+ action: input.action,
192
+ args,
193
+ cwd: repoCwd,
194
+ timeoutSeconds,
195
+ runCommand,
196
+ signal,
197
+ });
250
198
  const details = {
251
199
  action: input.action,
252
200
  command: "git",
@@ -254,10 +202,10 @@ export function createGitReadTool(cwd, options) {
254
202
  cwd: repoCwd,
255
203
  exitCode: result.exitCode,
256
204
  captureTruncated: result.captureTruncated || undefined,
257
- truncation: truncation.truncated ? truncation : undefined,
205
+ truncation: result.truncation,
258
206
  };
259
207
  return {
260
- content: [{ type: "text", text: finalOutput }],
208
+ content: [{ type: "text", text: result.output }],
261
209
  details,
262
210
  };
263
211
  },
@@ -1 +1 @@
1
- {"version":3,"file":"git-read.js","sourceRoot":"","sources":["../../../src/core/tools/git-read.ts"],"names":[],"mappings":"AAAA,OAAO,EAAE,KAAK,EAAE,SAAS,EAAE,MAAM,oBAAoB,CAAC;AAEtD,OAAO,EAAe,IAAI,EAAE,MAAM,mBAAmB,CAAC;AACtD,OAAO,EAAE,YAAY,EAAE,MAAM,iBAAiB,CAAC;AAC/C,OAAO,EACN,iBAAiB,EACjB,iBAAiB,EACjB,UAAU,EAEV,YAAY,GACZ,MAAM,eAAe,CAAC;AAEvB,MAAM,aAAa,GAAG,IAAI,CAAC,MAAM,CAAC;IACjC,MAAM,EAAE,IAAI,CAAC,KAAK,CACjB,CAAC,IAAI,CAAC,OAAO,CAAC,QAAQ,CAAC,EAAE,IAAI,CAAC,OAAO,CAAC,MAAM,CAAC,EAAE,IAAI,CAAC,OAAO,CAAC,KAAK,CAAC,EAAE,IAAI,CAAC,OAAO,CAAC,OAAO,CAAC,CAAC,EAC1F,EAAE,WAAW,EAAE,0CAA0C,EAAE,CAC3D;IACD,IAAI,EAAE,IAAI,CAAC,QAAQ,CAAC,IAAI,CAAC,MAAM,CAAC,EAAE,WAAW,EAAE,4DAA4D,EAAE,CAAC,CAAC;IAC/G,IAAI,EAAE,IAAI,CAAC,QAAQ,CAAC,IAAI,CAAC,MAAM,CAAC,EAAE,WAAW,EAAE,sDAAsD,EAAE,CAAC,CAAC;IACzG,IAAI,EAAE,IAAI,CAAC,QAAQ,CAAC,IAAI,CAAC,MAAM,CAAC,EAAE,WAAW,EAAE,oCAAoC,EAAE,CAAC,CAAC;IACvF,IAAI,EAAE,IAAI,CAAC,QAAQ,CAAC,IAAI,CAAC,MAAM,CAAC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AAC,IAAI,CAAC,IAAI,CAAC,oBAAoB,iBAAiB,SAAS,CAAC;YACzF,CAAC;YAED,MAAM,OAAO,GAAuB;gBACnC,MAAM,EAAE,KAAK,CAAC,MAAM;gBACpB,OAAO,EAAE,KAAK;gBACd,IAAI;gBACJ,GAAG,EAAE,OAAO;gBACZ,QAAQ,EAAE,MAAM,CAAC,QAAQ;gBACzB,gBAAgB,EAAE,MAAM,CAAC,gBAAgB,IAAI,SAAS;gBACtD,UAAU,EAAE,UAAU,CAAC,SAAS,CAAC,CAAC,CAAC,UAAU,CAAC,CAAC,CAAC,SAAS;aACzD,CAAC;YAEF,OAAO;gBACN,OAAO,EAAE,CAAC,EAAE,IAAI,EAAE,MAAM,EAAE,IAAI,EAAE,WAAW,EAAE,CAAC;gBAC9C,OAAO;aACP,CAAC;QACH,CAAC;KACD,CAAC;AACH,CAAC;AAED,MAAM,CAAC,MAAM,WAAW,GAAG,iBAAiB,CAAC,OAAO,CAAC,GAAG,EAAE,CAAC,CAAC","sourcesContent":["import { spawn, spawnSync } from \"node:child_process\";\nimport type { AgentTool } from \"@mariozechner/pi-agent-core\";\nimport { type Static, Type } from \"@sinclair/typebox\";\nimport { resolveToCwd } from \"./path-utils.js\";\nimport {\n\tDEFAULT_MAX_BYTES,\n\tDEFAULT_MAX_LINES,\n\tformatSize,\n\ttype TruncationResult,\n\ttruncateHead,\n} from \"./truncate.js\";\n\nconst gitReadSchema = Type.Object({\n\taction: Type.Union(\n\t\t[Type.Literal(\"status\"), Type.Literal(\"diff\"), Type.Literal(\"log\"), Type.Literal(\"blame\")],\n\t\t{ description: \"Git action: status | diff | log | blame.\" },\n\t),\n\tpath: Type.Optional(Type.String({ description: \"Repository working directory (default: current directory).\" })),\n\tfile: Type.Optional(Type.String({ description: \"Optional file path for diff/log, required for blame.\" })),\n\tbase: Type.Optional(Type.String({ description: \"Optional base ref/commit for diff.\" })),\n\thead: Type.Optional(Type.String({ description: \"Optional head ref/commit for diff (requires base).\" })),\n\tstaged: Type.Optional(Type.Boolean({ description: \"For diff action: compare staged changes.\" })),\n\tcontext: Type.Optional(Type.Number({ description: \"For diff action: unified context lines (default: 3).\" })),\n\tporcelain: Type.Optional(\n\t\tType.Boolean({\n\t\t\tdescription: \"For status action: use short porcelain format with branch (default: true).\",\n\t\t}),\n\t),\n\tuntracked: Type.Optional(Type.Boolean({ description: \"For status action: include untracked files (default: true).\" })),\n\tlimit: Type.Optional(Type.Number({ description: \"For log action: max entries (default: 20, max: 200).\" })),\n\tsince: Type.Optional(Type.String({ description: \"For log action: git --since value (e.g. '2 weeks ago').\" })),\n\tref: Type.Optional(Type.String({ description: \"For blame action: optional ref/commit.\" })),\n\tline_start: Type.Optional(Type.Number({ description: \"For blame action: range start line (1-indexed).\" })),\n\tline_end: Type.Optional(Type.Number({ description: \"For blame action: range end line (1-indexed).\" })),\n\ttimeout: Type.Optional(Type.Number({ description: \"Timeout in seconds (default: 30).\" })),\n});\n\nexport type GitReadToolInput = Static<typeof gitReadSchema>;\n\nconst DEFAULT_TIMEOUT_SECONDS = 30;\nconst DEFAULT_LOG_LIMIT = 20;\nconst MAX_LOG_LIMIT = 200;\nconst MAX_CAPTURE_BYTES = 512 * 1024;\n\ninterface RunCommandResult {\n\tstdout: string;\n\tstderr: string;\n\texitCode: number;\n\tcaptureTruncated: boolean;\n}\n\nexport interface GitReadToolDetails {\n\taction: \"status\" | \"diff\" | \"log\" | \"blame\";\n\tcommand: string;\n\targs: string[];\n\tcwd: string;\n\texitCode: number;\n\tcaptureTruncated?: boolean;\n\ttruncation?: TruncationResult;\n}\n\nexport interface GitReadToolOptions {\n\tcommandExists?: (command: string) => boolean;\n\trunCommand?: (\n\t\targs: string[],\n\t\tcwd: string,\n\t\ttimeoutMs: number,\n\t\tsignal?: AbortSignal,\n\t) => Promise<RunCommandResult>;\n}\n\nfunction commandExists(command: string): boolean {\n\ttry {\n\t\tconst result = spawnSync(command, [\"--version\"], { stdio: \"pipe\" });\n\t\tconst err = result.error as NodeJS.ErrnoException | undefined;\n\t\treturn !err || err.code !== \"ENOENT\";\n\t} catch {\n\t\treturn false;\n\t}\n}\n\nfunction normalizePositiveInt(raw: number | undefined, fallback: number, field: string): number {\n\tif (raw === undefined) return fallback;\n\tconst value = Math.floor(raw);\n\tif (!Number.isFinite(value) || value <= 0) {\n\t\tthrow new Error(`${field} must be a positive number.`);\n\t}\n\treturn value;\n}\n\nfunction runGitCommand(\n\targs: string[],\n\tcwd: string,\n\ttimeoutMs: number,\n\tsignal?: AbortSignal,\n): Promise<RunCommandResult> {\n\treturn new Promise((resolve, reject) => {\n\t\tif (signal?.aborted) {\n\t\t\treject(new Error(\"Operation aborted\"));\n\t\t\treturn;\n\t\t}\n\n\t\tconst child = spawn(\"git\", args, {\n\t\t\tcwd,\n\t\t\tstdio: [\"ignore\", \"pipe\", \"pipe\"],\n\t\t});\n\n\t\tlet stdoutChunks: Buffer[] = [];\n\t\tlet stderrChunks: Buffer[] = [];\n\t\tlet stdoutBytes = 0;\n\t\tlet stderrBytes = 0;\n\t\tlet captureTruncated = false;\n\t\tlet timedOut = false;\n\t\tlet aborted = false;\n\t\tlet settled = false;\n\n\t\tconst settle = (fn: () => void) => {\n\t\t\tif (!settled) {\n\t\t\t\tsettled = true;\n\t\t\t\tfn();\n\t\t\t}\n\t\t};\n\n\t\tconst captureChunk = (\n\t\t\tchunk: Buffer,\n\t\t\tchunks: Buffer[],\n\t\t\tcurrentBytes: number,\n\t\t): { nextBytes: number; truncated: boolean } => {\n\t\t\tif (currentBytes >= MAX_CAPTURE_BYTES) {\n\t\t\t\treturn { nextBytes: currentBytes, truncated: true };\n\t\t\t}\n\t\t\tconst remaining = MAX_CAPTURE_BYTES - currentBytes;\n\t\t\tif (chunk.length <= remaining) {\n\t\t\t\tchunks.push(chunk);\n\t\t\t\treturn { nextBytes: currentBytes + chunk.length, truncated: false };\n\t\t\t}\n\t\t\tchunks.push(chunk.subarray(0, remaining));\n\t\t\treturn { nextBytes: MAX_CAPTURE_BYTES, truncated: true };\n\t\t};\n\n\t\tconst timeoutHandle = setTimeout(() => {\n\t\t\ttimedOut = true;\n\t\t\tchild.kill(\"SIGTERM\");\n\t\t}, Math.max(1000, timeoutMs));\n\n\t\tconst onAbort = () => {\n\t\t\taborted = true;\n\t\t\tchild.kill(\"SIGTERM\");\n\t\t};\n\t\tsignal?.addEventListener(\"abort\", onAbort, { once: true });\n\n\t\tconst cleanup = () => {\n\t\t\tclearTimeout(timeoutHandle);\n\t\t\tsignal?.removeEventListener(\"abort\", onAbort);\n\t\t};\n\n\t\tchild.stdout.on(\"data\", (chunk: Buffer) => {\n\t\t\tconst captured = captureChunk(chunk, stdoutChunks, stdoutBytes);\n\t\t\tstdoutBytes = captured.nextBytes;\n\t\t\tcaptureTruncated = captureTruncated || captured.truncated;\n\t\t});\n\n\t\tchild.stderr.on(\"data\", (chunk: Buffer) => {\n\t\t\tconst captured = captureChunk(chunk, stderrChunks, stderrBytes);\n\t\t\tstderrBytes = captured.nextBytes;\n\t\t\tcaptureTruncated = captureTruncated || captured.truncated;\n\t\t});\n\n\t\tchild.on(\"error\", (error) => {\n\t\t\tcleanup();\n\t\t\tsettle(() => reject(new Error(`Failed to run git: ${error.message}`)));\n\t\t});\n\n\t\tchild.on(\"close\", (code) => {\n\t\t\tcleanup();\n\t\t\tif (aborted) {\n\t\t\t\tsettle(() => reject(new Error(\"Operation aborted\")));\n\t\t\t\treturn;\n\t\t\t}\n\t\t\tif (timedOut) {\n\t\t\t\tsettle(() => reject(new Error(`Command timed out after ${Math.round(timeoutMs / 1000)}s`)));\n\t\t\t\treturn;\n\t\t\t}\n\t\t\tsettle(() =>\n\t\t\t\tresolve({\n\t\t\t\t\tstdout: Buffer.concat(stdoutChunks).toString(\"utf-8\"),\n\t\t\t\t\tstderr: Buffer.concat(stderrChunks).toString(\"utf-8\"),\n\t\t\t\t\texitCode: code ?? -1,\n\t\t\t\t\tcaptureTruncated,\n\t\t\t\t}),\n\t\t\t);\n\t\t});\n\t});\n}\n\nfunction buildStatusArgs(input: GitReadToolInput): string[] {\n\tconst porcelain = input.porcelain ?? true;\n\tconst includeUntracked = input.untracked ?? true;\n\tconst args = [\"status\"];\n\tif (porcelain) {\n\t\targs.push(\"--short\", \"--branch\");\n\t}\n\tif (!includeUntracked) {\n\t\targs.push(\"--untracked-files=no\");\n\t}\n\treturn args;\n}\n\nfunction buildDiffArgs(input: GitReadToolInput): string[] {\n\tif (input.head && !input.base) {\n\t\tthrow new Error(\"git_read diff requires base when head is provided.\");\n\t}\n\tconst context = normalizePositiveInt(input.context, 3, \"context\");\n\tconst args = [\"diff\", \"--no-color\", `--unified=${context}`];\n\tif (input.staged) {\n\t\targs.push(\"--staged\");\n\t}\n\tif (input.base && input.head) {\n\t\targs.push(`${input.base}..${input.head}`);\n\t} else if (input.base) {\n\t\targs.push(input.base);\n\t}\n\tif (input.file) {\n\t\targs.push(\"--\", input.file);\n\t}\n\treturn args;\n}\n\nfunction buildLogArgs(input: GitReadToolInput): string[] {\n\tconst limit = Math.min(MAX_LOG_LIMIT, normalizePositiveInt(input.limit, DEFAULT_LOG_LIMIT, \"limit\"));\n\tconst args = [\n\t\t\"log\",\n\t\t\"--no-color\",\n\t\t`--max-count=${limit}`,\n\t\t\"--date=iso\",\n\t\t\"--pretty=format:%H%x09%ad%x09%an%x09%s\",\n\t];\n\tif (input.since) {\n\t\targs.push(`--since=${input.since}`);\n\t}\n\tif (input.file) {\n\t\targs.push(\"--\", input.file);\n\t}\n\treturn args;\n}\n\nfunction buildBlameArgs(input: GitReadToolInput): string[] {\n\tif (!input.file) {\n\t\tthrow new Error(\"git_read blame requires file.\");\n\t}\n\tconst hasLineStart = input.line_start !== undefined;\n\tconst hasLineEnd = input.line_end !== undefined;\n\tif (hasLineStart !== hasLineEnd) {\n\t\tthrow new Error(\"git_read blame requires both line_start and line_end when specifying a range.\");\n\t}\n\tconst args = [\"blame\", \"--line-porcelain\"];\n\tif (input.ref) {\n\t\targs.push(input.ref);\n\t}\n\tif (hasLineStart && hasLineEnd) {\n\t\tconst lineStart = normalizePositiveInt(input.line_start, 1, \"line_start\");\n\t\tconst lineEnd = normalizePositiveInt(input.line_end, 1, \"line_end\");\n\t\tif (lineEnd < lineStart) {\n\t\t\tthrow new Error(\"line_end must be greater than or equal to line_start.\");\n\t\t}\n\t\targs.push(\"-L\", `${lineStart},${lineEnd}`);\n\t}\n\targs.push(\"--\", input.file);\n\treturn args;\n}\n\nfunction buildGitArgs(input: GitReadToolInput): string[] {\n\tif (input.action === \"status\") return buildStatusArgs(input);\n\tif (input.action === \"diff\") return buildDiffArgs(input);\n\tif (input.action === \"log\") return buildLogArgs(input);\n\treturn buildBlameArgs(input);\n}\n\nexport function createGitReadTool(cwd: string, options?: GitReadToolOptions): AgentTool<typeof gitReadSchema> {\n\tconst hasCommand = options?.commandExists ?? commandExists;\n\tconst runCommand = options?.runCommand ?? runGitCommand;\n\n\treturn {\n\t\tname: \"git_read\",\n\t\tlabel: \"git_read\",\n\t\tdescription:\n\t\t\t\"Structured read-only git introspection. Actions: status | diff | log | blame. Uses safe argv execution without shell interpolation.\",\n\t\tparameters: gitReadSchema,\n\t\texecute: async (_toolCallId: string, input: GitReadToolInput, signal?: AbortSignal) => {\n\t\t\tif (!hasCommand(\"git\")) {\n\t\t\t\tthrow new Error(\"git command is not available.\");\n\t\t\t}\n\n\t\t\tconst repoCwd = resolveToCwd(input.path || \".\", cwd);\n\t\t\tconst args = buildGitArgs(input);\n\t\t\tconst timeoutSeconds = normalizePositiveInt(input.timeout, DEFAULT_TIMEOUT_SECONDS, \"timeout\");\n\t\t\tconst result = await runCommand(args, repoCwd, timeoutSeconds * 1000, signal);\n\n\t\t\tif (result.exitCode !== 0) {\n\t\t\t\tconst errorText =\n\t\t\t\t\tresult.stderr.trim() || result.stdout.trim() || `git_read ${input.action} failed with exit code ${result.exitCode}`;\n\t\t\t\tthrow new Error(errorText);\n\t\t\t}\n\n\t\t\tlet output = result.stdout.trimEnd();\n\t\t\tif (!output && result.stderr.trim().length > 0) {\n\t\t\t\toutput = result.stderr.trimEnd();\n\t\t\t}\n\t\t\tif (!output) {\n\t\t\t\toutput = \"No output\";\n\t\t\t}\n\n\t\t\tconst truncation = truncateHead(output);\n\t\t\tlet finalOutput = truncation.content;\n\t\t\tconst notices: string[] = [];\n\n\t\t\tif (truncation.truncated) {\n\t\t\t\tnotices.push(`${formatSize(DEFAULT_MAX_BYTES)} output limit reached`);\n\t\t\t}\n\t\t\tif (result.captureTruncated) {\n\t\t\t\tnotices.push(`capture limit reached (${formatSize(MAX_CAPTURE_BYTES)})`);\n\t\t\t}\n\t\t\tif (notices.length > 0) {\n\t\t\t\tfinalOutput += `\\n\\n[${notices.join(\". \")} · showing up to ${DEFAULT_MAX_LINES} lines]`;\n\t\t\t}\n\n\t\t\tconst details: GitReadToolDetails = {\n\t\t\t\taction: input.action,\n\t\t\t\tcommand: \"git\",\n\t\t\t\targs,\n\t\t\t\tcwd: repoCwd,\n\t\t\t\texitCode: result.exitCode,\n\t\t\t\tcaptureTruncated: result.captureTruncated || undefined,\n\t\t\t\ttruncation: truncation.truncated ? truncation : undefined,\n\t\t\t};\n\n\t\t\treturn {\n\t\t\t\tcontent: [{ type: \"text\", text: finalOutput }],\n\t\t\t\tdetails,\n\t\t\t};\n\t\t},\n\t};\n}\n\nexport const gitReadTool = createGitReadTool(process.cwd());\n"]}
1
+ {"version":3,"file":"git-read.js","sourceRoot":"","sources":["../../../src/core/tools/git-read.ts"],"names":[],"mappings":"AACA,OAAO,EAAe,IAAI,EAAE,MAAM,mBAAmB,CAAC;AACtD,OAAO,EAAE,YAAY,EAAE,MAAM,iBAAiB,CAAC;AAC/C,OAAO,EACN,2BAA2B,EAC3B,oBAAoB,EACpB,gBAAgB,EAChB,cAAc,EACd,wBAAwB,EACxB,qBAAqB,GAErB,MAAM,iBAAiB,CAAC;AAGzB,MAAM,aAAa,GAAG,IAAI,CAAC,MAAM,CAAC;IACjC,MAAM,EAAE,IAAI,CAAC,KAAK,CACjB;Q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AAK,CAAC,MAAM;gBACpB,OAAO,EAAE,KAAK;gBACd,IAAI;gBACJ,GAAG,EAAE,OAAO;gBACZ,QAAQ,EAAE,MAAM,CAAC,QAAQ;gBACzB,gBAAgB,EAAE,MAAM,CAAC,gBAAgB,IAAI,SAAS;gBACtD,UAAU,EAAE,MAAM,CAAC,UAAU;aAC7B,CAAC;YAEF,OAAO;gBACN,OAAO,EAAE,CAAC,EAAE,IAAI,EAAE,MAAM,EAAE,IAAI,EAAE,MAAM,CAAC,MAAM,EAAE,CAAC;gBAChD,OAAO;aACP,CAAC;QACH,CAAC;KACD,CAAC;AACH,CAAC;AAED,MAAM,CAAC,MAAM,WAAW,GAAG,iBAAiB,CAAC,OAAO,CAAC,GAAG,EAAE,CAAC,CAAC","sourcesContent":["import type { AgentTool } from \"@mariozechner/pi-agent-core\";\nimport { type Static, Type } from \"@sinclair/typebox\";\nimport { resolveToCwd } from \"./path-utils.js\";\nimport {\n\tDEFAULT_GIT_TIMEOUT_SECONDS,\n\tnormalizePositiveInt,\n\tnormalizeRefLike,\n\trequireRefLike,\n\tresolveGitCommandOptions,\n\trunGitAndFormatOutput,\n\ttype GitCommandOptions,\n} from \"./git-common.js\";\nimport type { TruncationResult } from \"./truncate.js\";\n\nconst gitReadSchema = Type.Object({\n\taction: Type.Union(\n\t\t[\n\t\t\tType.Literal(\"status\"),\n\t\t\tType.Literal(\"diff\"),\n\t\t\tType.Literal(\"log\"),\n\t\t\tType.Literal(\"blame\"),\n\t\t\tType.Literal(\"show\"),\n\t\t\tType.Literal(\"branch_list\"),\n\t\t\tType.Literal(\"remote_list\"),\n\t\t\tType.Literal(\"rev_parse\"),\n\t\t],\n\t\t{ description: \"Git action: status | diff | log | blame | show | branch_list | remote_list | rev_parse.\" },\n\t),\n\tpath: Type.Optional(Type.String({ description: \"Repository working directory (default: current directory).\" })),\n\tfile: Type.Optional(Type.String({ description: \"Optional file path for diff/log/show, required for blame.\" })),\n\tbase: Type.Optional(Type.String({ description: \"Optional base ref/commit for diff.\" })),\n\thead: Type.Optional(Type.String({ description: \"Optional head ref/commit for diff (requires base).\" })),\n\tstaged: Type.Optional(Type.Boolean({ description: \"For diff action: compare staged changes.\" })),\n\tcontext: Type.Optional(Type.Number({ description: \"For diff action: unified context lines (default: 3).\" })),\n\tporcelain: Type.Optional(\n\t\tType.Boolean({\n\t\t\tdescription: \"For status action: use short porcelain format with branch (default: true).\",\n\t\t}),\n\t),\n\tuntracked: Type.Optional(Type.Boolean({ description: \"For status action: include untracked files (default: true).\" })),\n\tlimit: Type.Optional(Type.Number({ description: \"For log action: max entries (default: 20, max: 200).\" })),\n\tsince: Type.Optional(Type.String({ description: \"For log action: git --since value (e.g. '2 weeks ago').\" })),\n\tref: Type.Optional(Type.String({ description: \"For blame/show action: optional ref/commit (show defaults to HEAD).\" })),\n\tline_start: Type.Optional(Type.Number({ description: \"For blame action: range start line (1-indexed).\" })),\n\tline_end: Type.Optional(Type.Number({ description: \"For blame action: range end line (1-indexed).\" })),\n\tall: Type.Optional(Type.Boolean({ description: \"For branch_list action: include remote branches (default: true).\" })),\n\tverbose: Type.Optional(\n\t\tType.Boolean({\n\t\t\tdescription: \"For branch_list/remote_list action: include verbose output (branch_list default: false, remote_list default: true).\",\n\t\t}),\n\t),\n\ttarget: Type.Optional(Type.String({ description: \"For rev_parse action: ref/commit to resolve (default: HEAD).\" })),\n\tshort: Type.Optional(Type.Boolean({ description: \"For rev_parse action: output short hash (default: false).\" })),\n\ttimeout: Type.Optional(Type.Number({ description: \"Timeout in seconds (default: 30).\" })),\n});\n\nexport type GitReadToolInput = Static<typeof gitReadSchema>;\n\nconst DEFAULT_LOG_LIMIT = 20;\nconst MAX_LOG_LIMIT = 200;\n\ntype GitReadAction = GitReadToolInput[\"action\"];\n\nexport interface GitReadToolDetails {\n\taction: GitReadAction;\n\tcommand: string;\n\targs: string[];\n\tcwd: string;\n\texitCode: number;\n\tcaptureTruncated?: boolean;\n\ttruncation?: TruncationResult;\n}\n\nexport interface GitReadToolOptions extends GitCommandOptions {}\n\nfunction buildStatusArgs(input: GitReadToolInput): string[] {\n\tconst porcelain = input.porcelain ?? true;\n\tconst includeUntracked = input.untracked ?? true;\n\tconst args = [\"status\"];\n\tif (porcelain) {\n\t\targs.push(\"--short\", \"--branch\");\n\t}\n\tif (!includeUntracked) {\n\t\targs.push(\"--untracked-files=no\");\n\t}\n\treturn args;\n}\n\nfunction buildDiffArgs(input: GitReadToolInput): string[] {\n\tif (input.head && !input.base) {\n\t\tthrow new Error(\"git_read diff requires base when head is provided.\");\n\t}\n\tconst context = normalizePositiveInt(input.context, 3, \"context\");\n\tconst base = normalizeRefLike(input.base, \"base\");\n\tconst head = normalizeRefLike(input.head, \"head\");\n\tconst args = [\"diff\", \"--no-color\", `--unified=${context}`];\n\tif (input.staged) {\n\t\targs.push(\"--staged\");\n\t}\n\tif (base && head) {\n\t\targs.push(`${base}..${head}`);\n\t} else if (base) {\n\t\targs.push(base);\n\t}\n\tif (input.file) {\n\t\targs.push(\"--\", input.file);\n\t}\n\treturn args;\n}\n\nfunction buildLogArgs(input: GitReadToolInput): string[] {\n\tconst limit = Math.min(MAX_LOG_LIMIT, normalizePositiveInt(input.limit, DEFAULT_LOG_LIMIT, \"limit\"));\n\tconst args = [\n\t\t\"log\",\n\t\t\"--no-color\",\n\t\t`--max-count=${limit}`,\n\t\t\"--date=iso\",\n\t\t\"--pretty=format:%H%x09%ad%x09%an%x09%s\",\n\t];\n\tif (input.since) {\n\t\targs.push(`--since=${input.since}`);\n\t}\n\tif (input.file) {\n\t\targs.push(\"--\", input.file);\n\t}\n\treturn args;\n}\n\nfunction buildBlameArgs(input: GitReadToolInput): string[] {\n\tif (!input.file) {\n\t\tthrow new Error(\"git_read blame requires file.\");\n\t}\n\tconst hasLineStart = input.line_start !== undefined;\n\tconst hasLineEnd = input.line_end !== undefined;\n\tif (hasLineStart !== hasLineEnd) {\n\t\tthrow new Error(\"git_read blame requires both line_start and line_end when specifying a range.\");\n\t}\n\tconst args = [\"blame\", \"--line-porcelain\"];\n\tconst ref = normalizeRefLike(input.ref, \"ref\");\n\tif (ref) {\n\t\targs.push(ref);\n\t}\n\tif (hasLineStart && hasLineEnd) {\n\t\tconst lineStart = normalizePositiveInt(input.line_start, 1, \"line_start\");\n\t\tconst lineEnd = normalizePositiveInt(input.line_end, 1, \"line_end\");\n\t\tif (lineEnd < lineStart) {\n\t\t\tthrow new Error(\"line_end must be greater than or equal to line_start.\");\n\t\t}\n\t\targs.push(\"-L\", `${lineStart},${lineEnd}`);\n\t}\n\targs.push(\"--\", input.file);\n\treturn args;\n}\n\nfunction buildShowArgs(input: GitReadToolInput): string[] {\n\tconst ref = requireRefLike(input.ref ?? \"HEAD\", \"ref\");\n\tconst args = [\"show\", \"--no-color\", ref];\n\tif (input.file) {\n\t\targs.push(\"--\", input.file);\n\t}\n\treturn args;\n}\n\nfunction buildBranchListArgs(input: GitReadToolInput): string[] {\n\tconst includeAll = input.all ?? true;\n\tconst verbose = input.verbose ?? false;\n\tconst args = [\"branch\", \"--list\"];\n\tif (includeAll) {\n\t\targs.push(\"--all\");\n\t}\n\tif (verbose) {\n\t\targs.push(\"--verbose\");\n\t}\n\treturn args;\n}\n\nfunction buildRemoteListArgs(input: GitReadToolInput): string[] {\n\tconst verbose = input.verbose ?? true;\n\tconst args = [\"remote\"];\n\tif (verbose) {\n\t\targs.push(\"-v\");\n\t}\n\treturn args;\n}\n\nfunction buildRevParseArgs(input: GitReadToolInput): string[] {\n\tconst target = requireRefLike(input.target ?? \"HEAD\", \"target\");\n\tconst args = [\"rev-parse\"];\n\tif (input.short) {\n\t\targs.push(\"--short\");\n\t}\n\targs.push(target);\n\treturn args;\n}\n\nfunction buildGitReadArgs(input: GitReadToolInput): string[] {\n\tswitch (input.action) {\n\t\tcase \"status\":\n\t\t\treturn buildStatusArgs(input);\n\t\tcase \"diff\":\n\t\t\treturn buildDiffArgs(input);\n\t\tcase \"log\":\n\t\t\treturn buildLogArgs(input);\n\t\tcase \"blame\":\n\t\t\treturn buildBlameArgs(input);\n\t\tcase \"show\":\n\t\t\treturn buildShowArgs(input);\n\t\tcase \"branch_list\":\n\t\t\treturn buildBranchListArgs(input);\n\t\tcase \"remote_list\":\n\t\t\treturn buildRemoteListArgs(input);\n\t\tcase \"rev_parse\":\n\t\t\treturn buildRevParseArgs(input);\n\t\tdefault:\n\t\t\tthrow new Error(`Unsupported git_read action: ${(input as { action: string }).action}`);\n\t}\n}\n\nexport function createGitReadTool(cwd: string, options?: GitReadToolOptions): AgentTool<typeof gitReadSchema> {\n\tconst { hasCommand, runCommand } = resolveGitCommandOptions(options);\n\n\treturn {\n\t\tname: \"git_read\",\n\t\tlabel: \"git_read\",\n\t\tdescription:\n\t\t\t\"Structured read-only git introspection. Actions: status | diff | log | blame | show | branch_list | remote_list | rev_parse. Uses safe argv execution without shell interpolation.\",\n\t\tparameters: gitReadSchema,\n\t\texecute: async (_toolCallId: string, input: GitReadToolInput, signal?: AbortSignal) => {\n\t\t\tif (!hasCommand(\"git\")) {\n\t\t\t\tthrow new Error(\"git command is not available.\");\n\t\t\t}\n\n\t\t\tconst repoCwd = resolveToCwd(input.path || \".\", cwd);\n\t\t\tconst args = buildGitReadArgs(input);\n\t\t\tconst timeoutSeconds = normalizePositiveInt(input.timeout, DEFAULT_GIT_TIMEOUT_SECONDS, \"timeout\");\n\t\t\tconst result = await runGitAndFormatOutput({\n\t\t\t\ttoolName: \"git_read\",\n\t\t\t\taction: input.action,\n\t\t\t\targs,\n\t\t\t\tcwd: repoCwd,\n\t\t\t\ttimeoutSeconds,\n\t\t\t\trunCommand,\n\t\t\t\tsignal,\n\t\t\t});\n\n\t\t\tconst details: GitReadToolDetails = {\n\t\t\t\taction: input.action,\n\t\t\t\tcommand: \"git\",\n\t\t\t\targs,\n\t\t\t\tcwd: repoCwd,\n\t\t\t\texitCode: result.exitCode,\n\t\t\t\tcaptureTruncated: result.captureTruncated || undefined,\n\t\t\t\ttruncation: result.truncation,\n\t\t\t};\n\n\t\t\treturn {\n\t\t\t\tcontent: [{ type: \"text\", text: result.output }],\n\t\t\t\tdetails,\n\t\t\t};\n\t\t},\n\t};\n}\n\nexport const gitReadTool = createGitReadTool(process.cwd());\n"]}
@@ -0,0 +1,75 @@
1
+ import type { AgentTool } from "@mariozechner/pi-agent-core";
2
+ import { type Static } from "@sinclair/typebox";
3
+ import { type GitCommandOptions } from "./git-common.js";
4
+ import type { ToolPermissionGuard } from "./permissions.js";
5
+ import type { TruncationResult } from "./truncate.js";
6
+ declare const gitWriteSchema: import("@sinclair/typebox").TObject<{
7
+ action: import("@sinclair/typebox").TUnion<[import("@sinclair/typebox").TLiteral<"add">, import("@sinclair/typebox").TLiteral<"restore">, import("@sinclair/typebox").TLiteral<"reset_index">, import("@sinclair/typebox").TLiteral<"commit">, import("@sinclair/typebox").TLiteral<"switch">, import("@sinclair/typebox").TLiteral<"branch_create">, import("@sinclair/typebox").TLiteral<"fetch">, import("@sinclair/typebox").TLiteral<"pull">, import("@sinclair/typebox").TLiteral<"push">, import("@sinclair/typebox").TLiteral<"stash_push">, import("@sinclair/typebox").TLiteral<"stash_pop">, import("@sinclair/typebox").TLiteral<"stash_apply">, import("@sinclair/typebox").TLiteral<"stash_drop">, import("@sinclair/typebox").TLiteral<"stash_list">]>;
8
+ path: import("@sinclair/typebox").TOptional<import("@sinclair/typebox").TString>;
9
+ all: import("@sinclair/typebox").TOptional<import("@sinclair/typebox").TBoolean>;
10
+ update: import("@sinclair/typebox").TOptional<import("@sinclair/typebox").TBoolean>;
11
+ files: import("@sinclair/typebox").TOptional<import("@sinclair/typebox").TArray<import("@sinclair/typebox").TString>>;
12
+ staged: import("@sinclair/typebox").TOptional<import("@sinclair/typebox").TBoolean>;
13
+ source: import("@sinclair/typebox").TOptional<import("@sinclair/typebox").TString>;
14
+ ref: import("@sinclair/typebox").TOptional<import("@sinclair/typebox").TString>;
15
+ message: import("@sinclair/typebox").TOptional<import("@sinclair/typebox").TString>;
16
+ allow_empty: import("@sinclair/typebox").TOptional<import("@sinclair/typebox").TBoolean>;
17
+ branch: import("@sinclair/typebox").TOptional<import("@sinclair/typebox").TString>;
18
+ start_point: import("@sinclair/typebox").TOptional<import("@sinclair/typebox").TString>;
19
+ remote: import("@sinclair/typebox").TOptional<import("@sinclair/typebox").TString>;
20
+ ff_only: import("@sinclair/typebox").TOptional<import("@sinclair/typebox").TBoolean>;
21
+ prune: import("@sinclair/typebox").TOptional<import("@sinclair/typebox").TBoolean>;
22
+ set_upstream: import("@sinclair/typebox").TOptional<import("@sinclair/typebox").TBoolean>;
23
+ tags: import("@sinclair/typebox").TOptional<import("@sinclair/typebox").TBoolean>;
24
+ include_untracked: import("@sinclair/typebox").TOptional<import("@sinclair/typebox").TBoolean>;
25
+ keep_index: import("@sinclair/typebox").TOptional<import("@sinclair/typebox").TBoolean>;
26
+ stash_ref: import("@sinclair/typebox").TOptional<import("@sinclair/typebox").TString>;
27
+ limit: import("@sinclair/typebox").TOptional<import("@sinclair/typebox").TNumber>;
28
+ timeout: import("@sinclair/typebox").TOptional<import("@sinclair/typebox").TNumber>;
29
+ }>;
30
+ export type GitWriteToolInput = Static<typeof gitWriteSchema>;
31
+ type GitWriteAction = GitWriteToolInput["action"];
32
+ export interface GitWriteToolDetails {
33
+ action: GitWriteAction;
34
+ command: string;
35
+ args: string[];
36
+ cwd: string;
37
+ exitCode: number;
38
+ captureTruncated?: boolean;
39
+ truncation?: TruncationResult;
40
+ }
41
+ export interface GitWriteRuntimeConfig {
42
+ networkEnabled: boolean;
43
+ }
44
+ export interface GitWriteToolOptions extends GitCommandOptions {
45
+ permissionGuard?: ToolPermissionGuard;
46
+ resolveRuntimeConfig?: () => Partial<GitWriteRuntimeConfig> | GitWriteRuntimeConfig;
47
+ resolveGithubToken?: () => string | undefined;
48
+ }
49
+ export declare function createGitWriteTool(cwd: string, options?: GitWriteToolOptions): AgentTool<typeof gitWriteSchema>;
50
+ export declare const gitWriteTool: AgentTool<import("@sinclair/typebox").TObject<{
51
+ action: import("@sinclair/typebox").TUnion<[import("@sinclair/typebox").TLiteral<"add">, import("@sinclair/typebox").TLiteral<"restore">, import("@sinclair/typebox").TLiteral<"reset_index">, import("@sinclair/typebox").TLiteral<"commit">, import("@sinclair/typebox").TLiteral<"switch">, import("@sinclair/typebox").TLiteral<"branch_create">, import("@sinclair/typebox").TLiteral<"fetch">, import("@sinclair/typebox").TLiteral<"pull">, import("@sinclair/typebox").TLiteral<"push">, import("@sinclair/typebox").TLiteral<"stash_push">, import("@sinclair/typebox").TLiteral<"stash_pop">, import("@sinclair/typebox").TLiteral<"stash_apply">, import("@sinclair/typebox").TLiteral<"stash_drop">, import("@sinclair/typebox").TLiteral<"stash_list">]>;
52
+ path: import("@sinclair/typebox").TOptional<import("@sinclair/typebox").TString>;
53
+ all: import("@sinclair/typebox").TOptional<import("@sinclair/typebox").TBoolean>;
54
+ update: import("@sinclair/typebox").TOptional<import("@sinclair/typebox").TBoolean>;
55
+ files: import("@sinclair/typebox").TOptional<import("@sinclair/typebox").TArray<import("@sinclair/typebox").TString>>;
56
+ staged: import("@sinclair/typebox").TOptional<import("@sinclair/typebox").TBoolean>;
57
+ source: import("@sinclair/typebox").TOptional<import("@sinclair/typebox").TString>;
58
+ ref: import("@sinclair/typebox").TOptional<import("@sinclair/typebox").TString>;
59
+ message: import("@sinclair/typebox").TOptional<import("@sinclair/typebox").TString>;
60
+ allow_empty: import("@sinclair/typebox").TOptional<import("@sinclair/typebox").TBoolean>;
61
+ branch: import("@sinclair/typebox").TOptional<import("@sinclair/typebox").TString>;
62
+ start_point: import("@sinclair/typebox").TOptional<import("@sinclair/typebox").TString>;
63
+ remote: import("@sinclair/typebox").TOptional<import("@sinclair/typebox").TString>;
64
+ ff_only: import("@sinclair/typebox").TOptional<import("@sinclair/typebox").TBoolean>;
65
+ prune: import("@sinclair/typebox").TOptional<import("@sinclair/typebox").TBoolean>;
66
+ set_upstream: import("@sinclair/typebox").TOptional<import("@sinclair/typebox").TBoolean>;
67
+ tags: import("@sinclair/typebox").TOptional<import("@sinclair/typebox").TBoolean>;
68
+ include_untracked: import("@sinclair/typebox").TOptional<import("@sinclair/typebox").TBoolean>;
69
+ keep_index: import("@sinclair/typebox").TOptional<import("@sinclair/typebox").TBoolean>;
70
+ stash_ref: import("@sinclair/typebox").TOptional<import("@sinclair/typebox").TString>;
71
+ limit: import("@sinclair/typebox").TOptional<import("@sinclair/typebox").TNumber>;
72
+ timeout: import("@sinclair/typebox").TOptional<import("@sinclair/typebox").TNumber>;
73
+ }>, any>;
74
+ export {};
75
+ //# sourceMappingURL=git-write.d.ts.map
@@ -0,0 +1 @@
1
+ {"version":3,"file":"git-write.d.ts","sourceRoot":"","sources":["../../../src/core/tools/git-write.ts"],"names":[],"mappings":"AAAA,OAAO,KAAK,EAAE,SAAS,EAAE,MAAM,6BAA6B,CAAC;AAC7D,OAAO,EAAE,KAAK,MAAM,EAAQ,MAAM,mBAAmB,CAAC;AAEtD,OAAO,EASN,KAAK,iBAAiB,EACtB,MAAM,iBAAiB,CAAC;AACzB,OAAO,KAAK,EAAE,mBAAmB,EAAE,MAAM,kBAAkB,CAAC;AAC5D,OAAO,KAAK,EAAE,gBAAgB,EAAE,MAAM,eAAe,CAAC;AAEtD,QAAA,MAAM,cAAc;;;;;;;;;;;;;;;;;;;;;;;EAgDlB,CAAC;AAEH,MAAM,MAAM,iBAAiB,GAAG,MAAM,CAAC,OAAO,cAAc,CAAC,CAAC;AAO9D,KAAK,cAAc,GAAG,iBAAiB,CAAC,QAAQ,CAAC,CAAC;AAElD,MAAM,WAAW,mBAAmB;IACnC,MAAM,EAAE,cAAc,CAAC;IACvB,OAAO,EAAE,MAAM,CAAC;IAChB,IAAI,EAAE,MAAM,EAAE,CAAC;IACf,GAAG,EAAE,MAAM,CAAC;IACZ,QAAQ,EAAE,MAAM,CAAC;IACjB,gBAAgB,CAAC,EAAE,OAAO,CAAC;IAC3B,UAAU,CAAC,EAAE,gBAAgB,CAAC;CAC9B;AAED,MAAM,WAAW,qBA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