@adhdev/daemon-standalone 0.9.81-rc.1 → 0.9.81
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/dist/index.js +267 -191
- package/dist/index.js.map +1 -1
- package/package.json +4 -4
- package/public/assets/{index-DeQox3MP.js → index-BU3NAjAr.js} +4 -4
- package/public/index.html +1 -1
- package/vendor/mcp-server/index.js +32 -3
- package/vendor/mcp-server/index.js.map +1 -1
- package/vendor/mcp-server/package.json +1 -1
- package/vendor/session-host-daemon/index.js +0 -0
- package/vendor/session-host-daemon/index.mjs +0 -0
package/dist/index.js
CHANGED
|
@@ -22155,6 +22155,217 @@ var require_dist2 = __commonJS({
|
|
|
22155
22155
|
};
|
|
22156
22156
|
}
|
|
22157
22157
|
});
|
|
22158
|
+
var git_executor_exports = {};
|
|
22159
|
+
__export2(git_executor_exports, {
|
|
22160
|
+
GitCommandError: () => GitCommandError,
|
|
22161
|
+
isPathInside: () => isPathInside,
|
|
22162
|
+
normalizeGitOutput: () => normalizeGitOutput,
|
|
22163
|
+
resolveGitRepository: () => resolveGitRepository,
|
|
22164
|
+
runGit: () => runGit
|
|
22165
|
+
});
|
|
22166
|
+
async function resolveGitRepository(workspace, options = {}) {
|
|
22167
|
+
const normalizedWorkspace = await validateWorkspace(workspace);
|
|
22168
|
+
const result = await execGitRaw(normalizedWorkspace, ["rev-parse", "--show-toplevel"], options, {
|
|
22169
|
+
mapNotGitRepo: true
|
|
22170
|
+
});
|
|
22171
|
+
const repoRoot = path5.resolve(result.stdout.trim());
|
|
22172
|
+
if (!repoRoot) {
|
|
22173
|
+
throw new GitCommandError("not_git_repo", "Git did not return a repository root", {
|
|
22174
|
+
stdout: result.stdout,
|
|
22175
|
+
stderr: result.stderr,
|
|
22176
|
+
argv: ["rev-parse", "--show-toplevel"],
|
|
22177
|
+
cwd: normalizedWorkspace
|
|
22178
|
+
});
|
|
22179
|
+
}
|
|
22180
|
+
return {
|
|
22181
|
+
workspace: normalizedWorkspace,
|
|
22182
|
+
repoRoot,
|
|
22183
|
+
isGitRepo: true
|
|
22184
|
+
};
|
|
22185
|
+
}
|
|
22186
|
+
async function runGit(repoOrWorkspace, argv, options = {}) {
|
|
22187
|
+
validateGitArgv(argv);
|
|
22188
|
+
const repo = typeof repoOrWorkspace === "string" ? await resolveGitRepository(repoOrWorkspace, options) : repoOrWorkspace;
|
|
22189
|
+
if (!repo.repoRoot || !repo.isGitRepo) {
|
|
22190
|
+
throw new GitCommandError("not_git_repo", "Workspace is not a Git repository", {
|
|
22191
|
+
argv,
|
|
22192
|
+
cwd: repo.workspace
|
|
22193
|
+
});
|
|
22194
|
+
}
|
|
22195
|
+
const cwd = options.cwd ? await validateWorkspace(options.cwd) : await validateWorkspace(repo.workspace);
|
|
22196
|
+
const canonicalRepoRoot = await (0, import_promises.realpath)(repo.repoRoot);
|
|
22197
|
+
const canonicalCwd = await (0, import_promises.realpath)(cwd);
|
|
22198
|
+
if (!isPathInside(canonicalRepoRoot, canonicalCwd)) {
|
|
22199
|
+
throw new GitCommandError("path_outside_repo", "Git cwd is outside the repository root", {
|
|
22200
|
+
argv,
|
|
22201
|
+
cwd
|
|
22202
|
+
});
|
|
22203
|
+
}
|
|
22204
|
+
return execGitRaw(cwd, argv, options);
|
|
22205
|
+
}
|
|
22206
|
+
function normalizeGitOutput(value) {
|
|
22207
|
+
if (typeof value === "string") return value.replace(/\r\n/g, "\n");
|
|
22208
|
+
if (Buffer.isBuffer(value)) return value.toString("utf8").replace(/\r\n/g, "\n");
|
|
22209
|
+
if (value == null) return "";
|
|
22210
|
+
return String(value).replace(/\r\n/g, "\n");
|
|
22211
|
+
}
|
|
22212
|
+
function isPathInside(parent, child) {
|
|
22213
|
+
const relative3 = path5.relative(path5.resolve(parent), path5.resolve(child));
|
|
22214
|
+
return relative3 === "" || !relative3.startsWith("..") && !path5.isAbsolute(relative3);
|
|
22215
|
+
}
|
|
22216
|
+
async function validateWorkspace(workspace) {
|
|
22217
|
+
if (typeof workspace !== "string" || workspace.length === 0 || workspace.includes("\0")) {
|
|
22218
|
+
throw new GitCommandError("invalid_args", "Workspace must be a non-empty path");
|
|
22219
|
+
}
|
|
22220
|
+
if (!path5.isAbsolute(workspace)) {
|
|
22221
|
+
throw new GitCommandError("invalid_args", "Workspace must be an absolute path", { cwd: workspace });
|
|
22222
|
+
}
|
|
22223
|
+
const normalizedWorkspace = path5.resolve(workspace);
|
|
22224
|
+
try {
|
|
22225
|
+
const info = await (0, import_promises.stat)(normalizedWorkspace);
|
|
22226
|
+
if (!info.isDirectory()) {
|
|
22227
|
+
throw new GitCommandError("invalid_args", "Workspace must be an existing directory", {
|
|
22228
|
+
cwd: normalizedWorkspace
|
|
22229
|
+
});
|
|
22230
|
+
}
|
|
22231
|
+
await (0, import_promises.access)(normalizedWorkspace, import_node_fs.constants.R_OK);
|
|
22232
|
+
} catch (error48) {
|
|
22233
|
+
if (error48 instanceof GitCommandError) throw error48;
|
|
22234
|
+
throw new GitCommandError("invalid_args", "Workspace must be an existing directory", {
|
|
22235
|
+
cwd: normalizedWorkspace,
|
|
22236
|
+
cause: error48
|
|
22237
|
+
});
|
|
22238
|
+
}
|
|
22239
|
+
return normalizedWorkspace;
|
|
22240
|
+
}
|
|
22241
|
+
function validateGitArgv(argv) {
|
|
22242
|
+
if (!Array.isArray(argv) || argv.length === 0) {
|
|
22243
|
+
throw new GitCommandError("invalid_args", "Git argv must be a non-empty string array", { argv });
|
|
22244
|
+
}
|
|
22245
|
+
for (const arg of argv) {
|
|
22246
|
+
if (typeof arg !== "string" || arg.length === 0 || arg.includes("\0")) {
|
|
22247
|
+
throw new GitCommandError("invalid_args", "Git argv contains an invalid argument", { argv });
|
|
22248
|
+
}
|
|
22249
|
+
}
|
|
22250
|
+
if (argv.includes("-C") || argv.some((arg) => arg.startsWith("--git-dir") || arg.startsWith("--work-tree"))) {
|
|
22251
|
+
throw new GitCommandError("invalid_args", "Git argv contains unsafe repository override arguments", {
|
|
22252
|
+
argv
|
|
22253
|
+
});
|
|
22254
|
+
}
|
|
22255
|
+
}
|
|
22256
|
+
async function execGitRaw(cwd, argv, options, behavior = {}) {
|
|
22257
|
+
validateGitArgv(argv);
|
|
22258
|
+
try {
|
|
22259
|
+
const result = await execFileAsync("git", [...argv], {
|
|
22260
|
+
cwd,
|
|
22261
|
+
encoding: "utf8",
|
|
22262
|
+
timeout: options.timeoutMs ?? DEFAULT_TIMEOUT_MS,
|
|
22263
|
+
maxBuffer: options.maxBuffer ?? DEFAULT_MAX_BUFFER,
|
|
22264
|
+
windowsHide: true
|
|
22265
|
+
});
|
|
22266
|
+
return {
|
|
22267
|
+
stdout: normalizeGitOutput(result.stdout),
|
|
22268
|
+
stderr: normalizeGitOutput(result.stderr)
|
|
22269
|
+
};
|
|
22270
|
+
} catch (error48) {
|
|
22271
|
+
throw mapExecError(error48, cwd, argv, behavior);
|
|
22272
|
+
}
|
|
22273
|
+
}
|
|
22274
|
+
function mapExecError(error48, cwd, argv, behavior) {
|
|
22275
|
+
const execError = error48;
|
|
22276
|
+
const stdout = normalizeGitOutput(execError.stdout);
|
|
22277
|
+
const stderr = normalizeGitOutput(execError.stderr);
|
|
22278
|
+
const code = execError.code;
|
|
22279
|
+
const signal = execError.signal;
|
|
22280
|
+
const message = [stderr.trim(), execError.message].filter(Boolean).join("\n");
|
|
22281
|
+
if (code === "ENOENT") {
|
|
22282
|
+
return new GitCommandError("git_not_installed", "Git executable was not found", {
|
|
22283
|
+
stdout,
|
|
22284
|
+
stderr,
|
|
22285
|
+
exitCode: code,
|
|
22286
|
+
signal,
|
|
22287
|
+
argv,
|
|
22288
|
+
cwd,
|
|
22289
|
+
cause: error48
|
|
22290
|
+
});
|
|
22291
|
+
}
|
|
22292
|
+
if (execError.killed || /timed out/i.test(execError.message)) {
|
|
22293
|
+
return new GitCommandError("timeout", "Git command timed out", {
|
|
22294
|
+
stdout,
|
|
22295
|
+
stderr,
|
|
22296
|
+
exitCode: code,
|
|
22297
|
+
signal,
|
|
22298
|
+
argv,
|
|
22299
|
+
cwd,
|
|
22300
|
+
cause: error48
|
|
22301
|
+
});
|
|
22302
|
+
}
|
|
22303
|
+
if (behavior.mapNotGitRepo && /not a git repository/i.test(stderr + "\n" + execError.message)) {
|
|
22304
|
+
return new GitCommandError("not_git_repo", "Workspace is not a Git repository", {
|
|
22305
|
+
stdout,
|
|
22306
|
+
stderr,
|
|
22307
|
+
exitCode: code,
|
|
22308
|
+
signal,
|
|
22309
|
+
argv,
|
|
22310
|
+
cwd,
|
|
22311
|
+
cause: error48
|
|
22312
|
+
});
|
|
22313
|
+
}
|
|
22314
|
+
return new GitCommandError("git_command_failed", message || "Git command failed", {
|
|
22315
|
+
stdout,
|
|
22316
|
+
stderr,
|
|
22317
|
+
exitCode: code,
|
|
22318
|
+
signal,
|
|
22319
|
+
argv,
|
|
22320
|
+
cwd,
|
|
22321
|
+
cause: error48
|
|
22322
|
+
});
|
|
22323
|
+
}
|
|
22324
|
+
var import_node_child_process;
|
|
22325
|
+
var import_node_fs;
|
|
22326
|
+
var import_promises;
|
|
22327
|
+
var path5;
|
|
22328
|
+
var import_node_util;
|
|
22329
|
+
var execFileAsync;
|
|
22330
|
+
var DEFAULT_TIMEOUT_MS;
|
|
22331
|
+
var DEFAULT_MAX_BUFFER;
|
|
22332
|
+
var GitCommandError;
|
|
22333
|
+
var init_git_executor = __esm2({
|
|
22334
|
+
"src/git/git-executor.ts"() {
|
|
22335
|
+
"use strict";
|
|
22336
|
+
import_node_child_process = require("child_process");
|
|
22337
|
+
import_node_fs = require("fs");
|
|
22338
|
+
import_promises = require("fs/promises");
|
|
22339
|
+
path5 = __toESM2(require("path"));
|
|
22340
|
+
import_node_util = require("util");
|
|
22341
|
+
execFileAsync = (0, import_node_util.promisify)(import_node_child_process.execFile);
|
|
22342
|
+
DEFAULT_TIMEOUT_MS = 5e3;
|
|
22343
|
+
DEFAULT_MAX_BUFFER = 1024 * 1024;
|
|
22344
|
+
GitCommandError = class extends Error {
|
|
22345
|
+
reason;
|
|
22346
|
+
stdout;
|
|
22347
|
+
stderr;
|
|
22348
|
+
exitCode;
|
|
22349
|
+
signal;
|
|
22350
|
+
argv;
|
|
22351
|
+
cwd;
|
|
22352
|
+
constructor(reason, message, details = {}) {
|
|
22353
|
+
super(message);
|
|
22354
|
+
if (details.cause !== void 0) {
|
|
22355
|
+
this.cause = details.cause;
|
|
22356
|
+
}
|
|
22357
|
+
this.name = "GitCommandError";
|
|
22358
|
+
this.reason = reason;
|
|
22359
|
+
this.stdout = normalizeGitOutput(details.stdout);
|
|
22360
|
+
this.stderr = normalizeGitOutput(details.stderr);
|
|
22361
|
+
this.exitCode = details.exitCode;
|
|
22362
|
+
this.signal = details.signal;
|
|
22363
|
+
this.argv = details.argv ? [...details.argv] : void 0;
|
|
22364
|
+
this.cwd = details.cwd;
|
|
22365
|
+
}
|
|
22366
|
+
};
|
|
22367
|
+
}
|
|
22368
|
+
});
|
|
22158
22369
|
var git_worktree_exports = {};
|
|
22159
22370
|
__export2(git_worktree_exports, {
|
|
22160
22371
|
createWorktree: () => createWorktree,
|
|
@@ -27844,203 +28055,21 @@ ${lastSnapshot}`;
|
|
|
27844
28055
|
});
|
|
27845
28056
|
module2.exports = __toCommonJS2(index_exports);
|
|
27846
28057
|
init_repo_mesh_types();
|
|
27847
|
-
|
|
27848
|
-
|
|
27849
|
-
var import_promises = require("fs/promises");
|
|
27850
|
-
var path5 = __toESM2(require("path"));
|
|
27851
|
-
var import_node_util = require("util");
|
|
27852
|
-
var execFileAsync = (0, import_node_util.promisify)(import_node_child_process.execFile);
|
|
27853
|
-
var DEFAULT_TIMEOUT_MS = 5e3;
|
|
27854
|
-
var DEFAULT_MAX_BUFFER = 1024 * 1024;
|
|
27855
|
-
var GitCommandError = class extends Error {
|
|
27856
|
-
reason;
|
|
27857
|
-
stdout;
|
|
27858
|
-
stderr;
|
|
27859
|
-
exitCode;
|
|
27860
|
-
signal;
|
|
27861
|
-
argv;
|
|
27862
|
-
cwd;
|
|
27863
|
-
constructor(reason, message, details = {}) {
|
|
27864
|
-
super(message);
|
|
27865
|
-
if (details.cause !== void 0) {
|
|
27866
|
-
this.cause = details.cause;
|
|
27867
|
-
}
|
|
27868
|
-
this.name = "GitCommandError";
|
|
27869
|
-
this.reason = reason;
|
|
27870
|
-
this.stdout = normalizeGitOutput(details.stdout);
|
|
27871
|
-
this.stderr = normalizeGitOutput(details.stderr);
|
|
27872
|
-
this.exitCode = details.exitCode;
|
|
27873
|
-
this.signal = details.signal;
|
|
27874
|
-
this.argv = details.argv ? [...details.argv] : void 0;
|
|
27875
|
-
this.cwd = details.cwd;
|
|
27876
|
-
}
|
|
27877
|
-
};
|
|
27878
|
-
async function resolveGitRepository(workspace, options = {}) {
|
|
27879
|
-
const normalizedWorkspace = await validateWorkspace(workspace);
|
|
27880
|
-
const result = await execGitRaw(normalizedWorkspace, ["rev-parse", "--show-toplevel"], options, {
|
|
27881
|
-
mapNotGitRepo: true
|
|
27882
|
-
});
|
|
27883
|
-
const repoRoot = path5.resolve(result.stdout.trim());
|
|
27884
|
-
if (!repoRoot) {
|
|
27885
|
-
throw new GitCommandError("not_git_repo", "Git did not return a repository root", {
|
|
27886
|
-
stdout: result.stdout,
|
|
27887
|
-
stderr: result.stderr,
|
|
27888
|
-
argv: ["rev-parse", "--show-toplevel"],
|
|
27889
|
-
cwd: normalizedWorkspace
|
|
27890
|
-
});
|
|
27891
|
-
}
|
|
27892
|
-
return {
|
|
27893
|
-
workspace: normalizedWorkspace,
|
|
27894
|
-
repoRoot,
|
|
27895
|
-
isGitRepo: true
|
|
27896
|
-
};
|
|
27897
|
-
}
|
|
27898
|
-
async function runGit(repoOrWorkspace, argv, options = {}) {
|
|
27899
|
-
validateGitArgv(argv);
|
|
27900
|
-
const repo = typeof repoOrWorkspace === "string" ? await resolveGitRepository(repoOrWorkspace, options) : repoOrWorkspace;
|
|
27901
|
-
if (!repo.repoRoot || !repo.isGitRepo) {
|
|
27902
|
-
throw new GitCommandError("not_git_repo", "Workspace is not a Git repository", {
|
|
27903
|
-
argv,
|
|
27904
|
-
cwd: repo.workspace
|
|
27905
|
-
});
|
|
27906
|
-
}
|
|
27907
|
-
const cwd = options.cwd ? await validateWorkspace(options.cwd) : await validateWorkspace(repo.workspace);
|
|
27908
|
-
const canonicalRepoRoot = await (0, import_promises.realpath)(repo.repoRoot);
|
|
27909
|
-
const canonicalCwd = await (0, import_promises.realpath)(cwd);
|
|
27910
|
-
if (!isPathInside(canonicalRepoRoot, canonicalCwd)) {
|
|
27911
|
-
throw new GitCommandError("path_outside_repo", "Git cwd is outside the repository root", {
|
|
27912
|
-
argv,
|
|
27913
|
-
cwd
|
|
27914
|
-
});
|
|
27915
|
-
}
|
|
27916
|
-
return execGitRaw(cwd, argv, options);
|
|
27917
|
-
}
|
|
27918
|
-
function normalizeGitOutput(value) {
|
|
27919
|
-
if (typeof value === "string") return value.replace(/\r\n/g, "\n");
|
|
27920
|
-
if (Buffer.isBuffer(value)) return value.toString("utf8").replace(/\r\n/g, "\n");
|
|
27921
|
-
if (value == null) return "";
|
|
27922
|
-
return String(value).replace(/\r\n/g, "\n");
|
|
27923
|
-
}
|
|
27924
|
-
function isPathInside(parent, child) {
|
|
27925
|
-
const relative3 = path5.relative(path5.resolve(parent), path5.resolve(child));
|
|
27926
|
-
return relative3 === "" || !relative3.startsWith("..") && !path5.isAbsolute(relative3);
|
|
27927
|
-
}
|
|
27928
|
-
async function validateWorkspace(workspace) {
|
|
27929
|
-
if (typeof workspace !== "string" || workspace.length === 0 || workspace.includes("\0")) {
|
|
27930
|
-
throw new GitCommandError("invalid_args", "Workspace must be a non-empty path");
|
|
27931
|
-
}
|
|
27932
|
-
if (!path5.isAbsolute(workspace)) {
|
|
27933
|
-
throw new GitCommandError("invalid_args", "Workspace must be an absolute path", { cwd: workspace });
|
|
27934
|
-
}
|
|
27935
|
-
const normalizedWorkspace = path5.resolve(workspace);
|
|
27936
|
-
try {
|
|
27937
|
-
const info = await (0, import_promises.stat)(normalizedWorkspace);
|
|
27938
|
-
if (!info.isDirectory()) {
|
|
27939
|
-
throw new GitCommandError("invalid_args", "Workspace must be an existing directory", {
|
|
27940
|
-
cwd: normalizedWorkspace
|
|
27941
|
-
});
|
|
27942
|
-
}
|
|
27943
|
-
await (0, import_promises.access)(normalizedWorkspace, import_node_fs.constants.R_OK);
|
|
27944
|
-
} catch (error48) {
|
|
27945
|
-
if (error48 instanceof GitCommandError) throw error48;
|
|
27946
|
-
throw new GitCommandError("invalid_args", "Workspace must be an existing directory", {
|
|
27947
|
-
cwd: normalizedWorkspace,
|
|
27948
|
-
cause: error48
|
|
27949
|
-
});
|
|
27950
|
-
}
|
|
27951
|
-
return normalizedWorkspace;
|
|
27952
|
-
}
|
|
27953
|
-
function validateGitArgv(argv) {
|
|
27954
|
-
if (!Array.isArray(argv) || argv.length === 0) {
|
|
27955
|
-
throw new GitCommandError("invalid_args", "Git argv must be a non-empty string array", { argv });
|
|
27956
|
-
}
|
|
27957
|
-
for (const arg of argv) {
|
|
27958
|
-
if (typeof arg !== "string" || arg.length === 0 || arg.includes("\0")) {
|
|
27959
|
-
throw new GitCommandError("invalid_args", "Git argv contains an invalid argument", { argv });
|
|
27960
|
-
}
|
|
27961
|
-
}
|
|
27962
|
-
if (argv.includes("-C") || argv.some((arg) => arg.startsWith("--git-dir") || arg.startsWith("--work-tree"))) {
|
|
27963
|
-
throw new GitCommandError("invalid_args", "Git argv contains unsafe repository override arguments", {
|
|
27964
|
-
argv
|
|
27965
|
-
});
|
|
27966
|
-
}
|
|
27967
|
-
}
|
|
27968
|
-
async function execGitRaw(cwd, argv, options, behavior = {}) {
|
|
27969
|
-
validateGitArgv(argv);
|
|
27970
|
-
try {
|
|
27971
|
-
const result = await execFileAsync("git", [...argv], {
|
|
27972
|
-
cwd,
|
|
27973
|
-
encoding: "utf8",
|
|
27974
|
-
timeout: options.timeoutMs ?? DEFAULT_TIMEOUT_MS,
|
|
27975
|
-
maxBuffer: options.maxBuffer ?? DEFAULT_MAX_BUFFER,
|
|
27976
|
-
windowsHide: true
|
|
27977
|
-
});
|
|
27978
|
-
return {
|
|
27979
|
-
stdout: normalizeGitOutput(result.stdout),
|
|
27980
|
-
stderr: normalizeGitOutput(result.stderr)
|
|
27981
|
-
};
|
|
27982
|
-
} catch (error48) {
|
|
27983
|
-
throw mapExecError(error48, cwd, argv, behavior);
|
|
27984
|
-
}
|
|
27985
|
-
}
|
|
27986
|
-
function mapExecError(error48, cwd, argv, behavior) {
|
|
27987
|
-
const execError = error48;
|
|
27988
|
-
const stdout = normalizeGitOutput(execError.stdout);
|
|
27989
|
-
const stderr = normalizeGitOutput(execError.stderr);
|
|
27990
|
-
const code = execError.code;
|
|
27991
|
-
const signal = execError.signal;
|
|
27992
|
-
const message = [stderr.trim(), execError.message].filter(Boolean).join("\n");
|
|
27993
|
-
if (code === "ENOENT") {
|
|
27994
|
-
return new GitCommandError("git_not_installed", "Git executable was not found", {
|
|
27995
|
-
stdout,
|
|
27996
|
-
stderr,
|
|
27997
|
-
exitCode: code,
|
|
27998
|
-
signal,
|
|
27999
|
-
argv,
|
|
28000
|
-
cwd,
|
|
28001
|
-
cause: error48
|
|
28002
|
-
});
|
|
28003
|
-
}
|
|
28004
|
-
if (execError.killed || /timed out/i.test(execError.message)) {
|
|
28005
|
-
return new GitCommandError("timeout", "Git command timed out", {
|
|
28006
|
-
stdout,
|
|
28007
|
-
stderr,
|
|
28008
|
-
exitCode: code,
|
|
28009
|
-
signal,
|
|
28010
|
-
argv,
|
|
28011
|
-
cwd,
|
|
28012
|
-
cause: error48
|
|
28013
|
-
});
|
|
28014
|
-
}
|
|
28015
|
-
if (behavior.mapNotGitRepo && /not a git repository/i.test(stderr + "\n" + execError.message)) {
|
|
28016
|
-
return new GitCommandError("not_git_repo", "Workspace is not a Git repository", {
|
|
28017
|
-
stdout,
|
|
28018
|
-
stderr,
|
|
28019
|
-
exitCode: code,
|
|
28020
|
-
signal,
|
|
28021
|
-
argv,
|
|
28022
|
-
cwd,
|
|
28023
|
-
cause: error48
|
|
28024
|
-
});
|
|
28025
|
-
}
|
|
28026
|
-
return new GitCommandError("git_command_failed", message || "Git command failed", {
|
|
28027
|
-
stdout,
|
|
28028
|
-
stderr,
|
|
28029
|
-
exitCode: code,
|
|
28030
|
-
signal,
|
|
28031
|
-
argv,
|
|
28032
|
-
cwd,
|
|
28033
|
-
cause: error48
|
|
28034
|
-
});
|
|
28035
|
-
}
|
|
28058
|
+
init_git_executor();
|
|
28059
|
+
init_git_executor();
|
|
28036
28060
|
async function getGitRepoStatus(workspace, options = {}) {
|
|
28037
28061
|
const lastCheckedAt = Date.now();
|
|
28062
|
+
const includeSubmodules = options.includeSubmodules !== false;
|
|
28038
28063
|
try {
|
|
28039
28064
|
const repo = await resolveGitRepository(workspace, options);
|
|
28040
28065
|
const statusOutput = await runGit(repo, ["status", "--porcelain=v2", "--branch"], options);
|
|
28041
28066
|
const parsed = parsePorcelainV2Status(statusOutput.stdout);
|
|
28042
28067
|
const head = await readHead(repo, options);
|
|
28043
28068
|
const stashCount = await readStashCount(repo, options);
|
|
28069
|
+
let submodules;
|
|
28070
|
+
if (includeSubmodules) {
|
|
28071
|
+
submodules = await getSubmoduleStatuses(repo, options);
|
|
28072
|
+
}
|
|
28044
28073
|
return {
|
|
28045
28074
|
workspace: repo.workspace,
|
|
28046
28075
|
repoRoot: repo.repoRoot,
|
|
@@ -28059,7 +28088,8 @@ ${lastSnapshot}`;
|
|
|
28059
28088
|
hasConflicts: parsed.conflictFiles.length > 0,
|
|
28060
28089
|
conflictFiles: parsed.conflictFiles,
|
|
28061
28090
|
stashCount,
|
|
28062
|
-
lastCheckedAt
|
|
28091
|
+
lastCheckedAt,
|
|
28092
|
+
submodules
|
|
28063
28093
|
};
|
|
28064
28094
|
} catch (error48) {
|
|
28065
28095
|
if (error48 instanceof GitCommandError) {
|
|
@@ -28181,8 +28211,40 @@ ${lastSnapshot}`;
|
|
|
28181
28211
|
reason: error48.reason
|
|
28182
28212
|
};
|
|
28183
28213
|
}
|
|
28214
|
+
async function getSubmoduleStatuses(repo, options) {
|
|
28215
|
+
if (!repo.repoRoot) return [];
|
|
28216
|
+
try {
|
|
28217
|
+
const result = await runGit(repo, ["submodule", "status", "--recursive"], options);
|
|
28218
|
+
return parseSubmoduleStatusOutput(result.stdout, repo.repoRoot, options.submoduleIgnorePaths);
|
|
28219
|
+
} catch {
|
|
28220
|
+
return [];
|
|
28221
|
+
}
|
|
28222
|
+
}
|
|
28223
|
+
function parseSubmoduleStatusOutput(output, repoRoot, ignorePaths) {
|
|
28224
|
+
const submodules = [];
|
|
28225
|
+
const ignoreSet = new Set(ignorePaths || []);
|
|
28226
|
+
for (const line of output.split("\n")) {
|
|
28227
|
+
if (!line.trim()) continue;
|
|
28228
|
+
const match = line.match(/^([\-+\s])([0-9a-f]{40})\s+(\S+)(?:\s+\(([^)]+)\))?/);
|
|
28229
|
+
if (!match) continue;
|
|
28230
|
+
const prefix = match[1];
|
|
28231
|
+
const commit = match[2];
|
|
28232
|
+
const path28 = match[3];
|
|
28233
|
+
if (ignoreSet.has(path28)) continue;
|
|
28234
|
+
submodules.push({
|
|
28235
|
+
path: path28,
|
|
28236
|
+
commit,
|
|
28237
|
+
repoPath: repoRoot + "/" + path28,
|
|
28238
|
+
dirty: prefix === "+",
|
|
28239
|
+
outOfSync: prefix === "-",
|
|
28240
|
+
lastCheckedAt: Date.now()
|
|
28241
|
+
});
|
|
28242
|
+
}
|
|
28243
|
+
return submodules;
|
|
28244
|
+
}
|
|
28184
28245
|
var import_promises2 = require("fs/promises");
|
|
28185
28246
|
var path23 = __toESM2(require("path"));
|
|
28247
|
+
init_git_executor();
|
|
28186
28248
|
var DEFAULT_MAX_FILES = 200;
|
|
28187
28249
|
var DEFAULT_MAX_BYTES = 2e5;
|
|
28188
28250
|
async function getGitDiffSummary(workspace, options = {}) {
|
|
@@ -28703,6 +28765,7 @@ ${lastSnapshot}`;
|
|
|
28703
28765
|
return new GitWorkspaceMonitor(options);
|
|
28704
28766
|
}
|
|
28705
28767
|
var path32 = __toESM2(require("path"));
|
|
28768
|
+
init_git_executor();
|
|
28706
28769
|
var GIT_COMMAND_NAMES = /* @__PURE__ */ new Set([
|
|
28707
28770
|
"git_status",
|
|
28708
28771
|
"git_diff_summary",
|
|
@@ -47579,12 +47642,25 @@ ${(0, import_node_path.resolve)(workspace || os17.tmpdir())}`;
|
|
|
47579
47642
|
});
|
|
47580
47643
|
if (!node) return { success: false, error: "Failed to register worktree node" };
|
|
47581
47644
|
}
|
|
47645
|
+
const initSubmodules = sourceNode.policy?.initSubmodulesOnClone !== false;
|
|
47646
|
+
if (initSubmodules) {
|
|
47647
|
+
try {
|
|
47648
|
+
const { runGit: runGit2 } = await Promise.resolve().then(() => (init_git_executor(), git_executor_exports));
|
|
47649
|
+
await runGit2(
|
|
47650
|
+
{ workspace: result.worktreePath, repoRoot: result.worktreePath, isGitRepo: true },
|
|
47651
|
+
["submodule", "update", "--init", "--recursive"],
|
|
47652
|
+
{ timeoutMs: 12e4 }
|
|
47653
|
+
);
|
|
47654
|
+
} catch (subErr) {
|
|
47655
|
+
console.warn("[mesh] Submodule init failed for worktree:", subErr.message);
|
|
47656
|
+
}
|
|
47657
|
+
}
|
|
47582
47658
|
try {
|
|
47583
47659
|
const { appendLedgerEntry: appendLedgerEntry2 } = await Promise.resolve().then(() => (init_mesh_ledger(), mesh_ledger_exports));
|
|
47584
47660
|
appendLedgerEntry2(meshId, {
|
|
47585
47661
|
kind: "node_cloned",
|
|
47586
47662
|
nodeId: node.id,
|
|
47587
|
-
payload: { sourceNodeId, branch: result.branch, worktreePath: result.worktreePath }
|
|
47663
|
+
payload: { sourceNodeId, branch: result.branch, worktreePath: result.worktreePath, submodulesInitialized: initSubmodules }
|
|
47588
47664
|
});
|
|
47589
47665
|
} catch {
|
|
47590
47666
|
}
|