@workit-dev/opencode 1.8.0 → 1.8.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/dist/plugin.js +488 -163
- package/package.json +2 -2
package/dist/plugin.js
CHANGED
|
@@ -182,7 +182,7 @@ function define(plugin) {
|
|
|
182
182
|
}
|
|
183
183
|
|
|
184
184
|
// packages/workit-core/src/core.ts
|
|
185
|
-
import { spawnSync as
|
|
185
|
+
import { spawnSync as spawnSync22 } from "node:child_process";
|
|
186
186
|
import { existsSync as existsSync12, realpathSync as realpathSync8 } from "node:fs";
|
|
187
187
|
import path34 from "node:path";
|
|
188
188
|
|
|
@@ -8083,15 +8083,14 @@ var gitContext = (workspaceRoot, paths = []) => {
|
|
|
8083
8083
|
};
|
|
8084
8084
|
|
|
8085
8085
|
// packages/workit-core/src/core/workspaces.ts
|
|
8086
|
-
import { spawnSync as
|
|
8086
|
+
import { spawnSync as spawnSync6 } from "node:child_process";
|
|
8087
8087
|
import { createHash as createHash5 } from "node:crypto";
|
|
8088
|
-
import { existsSync as existsSync2, lstatSync as lstatSync2, readFileSync as
|
|
8088
|
+
import { existsSync as existsSync2, lstatSync as lstatSync2, readFileSync as readFileSync4, realpathSync as realpathSync2 } from "node:fs";
|
|
8089
8089
|
import path9 from "node:path";
|
|
8090
8090
|
|
|
8091
8091
|
// packages/workit-core/src/core/remotes.ts
|
|
8092
|
-
import { lstatSync, readFileSync as
|
|
8093
|
-
import { spawnSync as
|
|
8094
|
-
import os3 from "node:os";
|
|
8092
|
+
import { lstatSync, readFileSync as readFileSync3, realpathSync, statSync } from "node:fs";
|
|
8093
|
+
import { spawnSync as spawnSync5 } from "node:child_process";
|
|
8095
8094
|
import path8 from "node:path";
|
|
8096
8095
|
|
|
8097
8096
|
// packages/workit-core/src/git/rev.ts
|
|
@@ -9046,6 +9045,56 @@ function resolveSshHost(alias, sshConfig) {
|
|
|
9046
9045
|
return { hostname: (hostname ?? alias).replace(/\.$/u, ""), port };
|
|
9047
9046
|
}
|
|
9048
9047
|
|
|
9048
|
+
// packages/workit-core/src/core/account-home.ts
|
|
9049
|
+
import { spawnSync as spawnSync4 } from "node:child_process";
|
|
9050
|
+
import { readFileSync as readFileSync2 } from "node:fs";
|
|
9051
|
+
import os3 from "node:os";
|
|
9052
|
+
var WINDOWS = "C:\\Windows";
|
|
9053
|
+
var SYSTEM32 = `${WINDOWS}\\System32\\`;
|
|
9054
|
+
var PROFILES = "HKLM\\SOFTWARE\\Microsoft\\Windows NT\\CurrentVersion\\ProfileList\\";
|
|
9055
|
+
var childEnv = (platform) => platform === "win32" ? { SystemRoot: WINDOWS } : {};
|
|
9056
|
+
var hostIo = {
|
|
9057
|
+
bun: Boolean(process.versions.bun),
|
|
9058
|
+
uid: process.getuid?.() ?? -1,
|
|
9059
|
+
userInfo: () => os3.userInfo().homedir,
|
|
9060
|
+
passwd: () => readFileSync2("/etc/passwd", "utf8"),
|
|
9061
|
+
run: (file, args) => {
|
|
9062
|
+
const done = spawnSync4(file, args, {
|
|
9063
|
+
encoding: "utf8",
|
|
9064
|
+
env: childEnv(process.platform),
|
|
9065
|
+
timeout: 3000,
|
|
9066
|
+
windowsHide: true
|
|
9067
|
+
});
|
|
9068
|
+
return done.status === 0 ? done.stdout : "";
|
|
9069
|
+
}
|
|
9070
|
+
};
|
|
9071
|
+
var field = (text, uid, at) => text.split(`
|
|
9072
|
+
`).filter((line) => !line.startsWith("#")).map((line) => line.split(":")).find((fields) => fields[2] === uid)?.[at];
|
|
9073
|
+
var profilePath = (raw) => {
|
|
9074
|
+
const value = raw.replaceAll(/%SystemDrive%/giu, WINDOWS.slice(0, 2)).replaceAll(/%SystemRoot%/giu, WINDOWS);
|
|
9075
|
+
return /^[A-Za-z]:\\/u.test(value) && !value.includes("%") ? value : null;
|
|
9076
|
+
};
|
|
9077
|
+
var accountHome = (platform = process.platform, io = hostIo) => {
|
|
9078
|
+
try {
|
|
9079
|
+
if (!io.bun)
|
|
9080
|
+
return io.userInfo() || null;
|
|
9081
|
+
if (platform === "win32") {
|
|
9082
|
+
const sid = /S-1-[\d-]+/u.exec(io.run(`${SYSTEM32}whoami.exe`, ["/user", "/fo", "csv"]));
|
|
9083
|
+
const key = sid && io.run(`${SYSTEM32}reg.exe`, ["query", PROFILES + sid[0], "/v", "ProfileImagePath"]);
|
|
9084
|
+
const raw = /ProfileImagePath\s+REG_\w+\s+(.+)/u.exec(key || "")?.[1]?.trim();
|
|
9085
|
+
return raw ? profilePath(raw) : null;
|
|
9086
|
+
}
|
|
9087
|
+
const uid = String(io.uid);
|
|
9088
|
+
let passwd = "";
|
|
9089
|
+
try {
|
|
9090
|
+
passwd = io.passwd();
|
|
9091
|
+
} catch {}
|
|
9092
|
+
return field(passwd, uid, 5) || (platform === "darwin" ? field(io.run("/usr/bin/id", ["-P"]), uid, 8) : field(io.run("/usr/bin/getent", ["passwd", uid]), uid, 5)) || null;
|
|
9093
|
+
} catch {
|
|
9094
|
+
return null;
|
|
9095
|
+
}
|
|
9096
|
+
};
|
|
9097
|
+
|
|
9049
9098
|
// packages/workit-core/src/core/remotes.ts
|
|
9050
9099
|
var FORGE_SCHEMES = new Set(["ssh", "git", "http", "https", "git+ssh", "ssh+git"]);
|
|
9051
9100
|
var SSH_SCHEMES = new Set(["ssh", "git+ssh", "ssh+git"]);
|
|
@@ -9055,15 +9104,11 @@ var SSH_443 = {
|
|
|
9055
9104
|
};
|
|
9056
9105
|
var WINDOWS_DRIVE = /^[A-Za-z]:[\\/]/u;
|
|
9057
9106
|
var SCP_LIKE = /^(?:[^@/\\]+@)?([^/\\:]+):(.+)$/u;
|
|
9058
|
-
var accountHome = () => {
|
|
9059
|
-
try {
|
|
9060
|
-
return os3.userInfo().homedir;
|
|
9061
|
-
} catch {
|
|
9062
|
-
return os3.homedir();
|
|
9063
|
-
}
|
|
9064
|
-
};
|
|
9065
9107
|
var sshSeam = {
|
|
9066
|
-
read: () =>
|
|
9108
|
+
read: () => {
|
|
9109
|
+
const home = accountHome();
|
|
9110
|
+
return home === null ? { text: "", home: "" } : readSshConfig(home);
|
|
9111
|
+
}
|
|
9067
9112
|
};
|
|
9068
9113
|
var forgeKey = (rawHost, repo, ssh) => {
|
|
9069
9114
|
let host = rawHost.toLowerCase().replace(/\.$/u, "");
|
|
@@ -9110,7 +9155,7 @@ var gitDirAt = (at, depth = 0) => {
|
|
|
9110
9155
|
return null;
|
|
9111
9156
|
try {
|
|
9112
9157
|
if (statSync(real).isFile()) {
|
|
9113
|
-
const pointer = /^gitdir:\s*(.+?)\s*$/mu.exec(
|
|
9158
|
+
const pointer = /^gitdir:\s*(.+?)\s*$/mu.exec(readFileSync3(real, "utf8"))?.[1];
|
|
9114
9159
|
if (!pointer)
|
|
9115
9160
|
return null;
|
|
9116
9161
|
const target = path8.isAbsolute(pointer) ? pointer : `${path8.dirname(real)}/${pointer}`;
|
|
@@ -9118,7 +9163,7 @@ var gitDirAt = (at, depth = 0) => {
|
|
|
9118
9163
|
}
|
|
9119
9164
|
let common;
|
|
9120
9165
|
try {
|
|
9121
|
-
common =
|
|
9166
|
+
common = readFileSync3(`${real}/commondir`, "utf8").trim();
|
|
9122
9167
|
} catch {}
|
|
9123
9168
|
if (common !== undefined) {
|
|
9124
9169
|
lstatSync(`${real}/HEAD`);
|
|
@@ -9222,7 +9267,7 @@ var checkoutRemotes = (cwd) => {
|
|
|
9222
9267
|
const env = { ...process.env };
|
|
9223
9268
|
for (const name of ["GIT_DIR", "GIT_WORK_TREE", "GIT_COMMON_DIR", "GIT_INDEX_FILE"])
|
|
9224
9269
|
delete env[name];
|
|
9225
|
-
const git = (args) =>
|
|
9270
|
+
const git = (args) => spawnSync5("git", args, {
|
|
9226
9271
|
cwd,
|
|
9227
9272
|
env,
|
|
9228
9273
|
encoding: "utf8",
|
|
@@ -9273,6 +9318,8 @@ var userLevel = (scope, origin) => {
|
|
|
9273
9318
|
return false;
|
|
9274
9319
|
const file = realOrSelf(origin.slice("file:".length));
|
|
9275
9320
|
const home = userGitSeam.home();
|
|
9321
|
+
if (home === null)
|
|
9322
|
+
return false;
|
|
9276
9323
|
return [path8.join(home, ".gitconfig"), path8.join(home, ".config", "git", "config")].map(realOrSelf).includes(file);
|
|
9277
9324
|
};
|
|
9278
9325
|
var escapeRegex2 = (value) => value.replace(/[.*+?^${}()|[\]\\]/gu, "\\$&");
|
|
@@ -9283,7 +9330,7 @@ var transportOverride = (git, remote, vars) => {
|
|
|
9283
9330
|
const execPath = vars.GIT_EXEC_PATH;
|
|
9284
9331
|
if (execPath) {
|
|
9285
9332
|
const { GIT_EXEC_PATH: _set, ...rest } = vars;
|
|
9286
|
-
const own =
|
|
9333
|
+
const own = spawnSync5("git", ["--exec-path"], {
|
|
9287
9334
|
env: rest,
|
|
9288
9335
|
encoding: "utf8"
|
|
9289
9336
|
});
|
|
@@ -9319,7 +9366,7 @@ var pushTarget = (cwd, remote, replay = {}) => {
|
|
|
9319
9366
|
delete env[name];
|
|
9320
9367
|
if (!remote || remote.startsWith("-"))
|
|
9321
9368
|
return Error(`push remote ${JSON.stringify(remote)} cannot be resolved`);
|
|
9322
|
-
const git = (args) =>
|
|
9369
|
+
const git = (args) => spawnSync5("git", [...replay.config ?? [], ...args], {
|
|
9323
9370
|
cwd,
|
|
9324
9371
|
env,
|
|
9325
9372
|
encoding: "utf8",
|
|
@@ -9551,7 +9598,7 @@ var readWorkspacesResult = (dir = configDir2()) => {
|
|
|
9551
9598
|
const file = path9.join(dir, "workspaces.json");
|
|
9552
9599
|
let raw;
|
|
9553
9600
|
try {
|
|
9554
|
-
raw =
|
|
9601
|
+
raw = readFileSync4(file, "utf8");
|
|
9555
9602
|
} catch (error) {
|
|
9556
9603
|
if (error.code === "ENOENT")
|
|
9557
9604
|
return {
|
|
@@ -9672,7 +9719,7 @@ var probeCheckout = (cwd) => {
|
|
|
9672
9719
|
for (const name of ["GIT_DIR", "GIT_WORK_TREE", "GIT_COMMON_DIR", "GIT_INDEX_FILE"])
|
|
9673
9720
|
delete env[name];
|
|
9674
9721
|
const git = (args) => {
|
|
9675
|
-
const run =
|
|
9722
|
+
const run = spawnSync6("git", args, {
|
|
9676
9723
|
cwd,
|
|
9677
9724
|
env,
|
|
9678
9725
|
encoding: "utf8",
|
|
@@ -9869,7 +9916,7 @@ var matchRuntimeWorkspace = (cwd, dir = configDir2()) => {
|
|
|
9869
9916
|
const file = path9.join(dir, "workspaces.json");
|
|
9870
9917
|
let raw;
|
|
9871
9918
|
try {
|
|
9872
|
-
raw =
|
|
9919
|
+
raw = readFileSync4(file, "utf8");
|
|
9873
9920
|
} catch (error) {
|
|
9874
9921
|
if (error.code === "ENOENT")
|
|
9875
9922
|
return null;
|
|
@@ -9937,7 +9984,7 @@ var modelSources = (cwd, dir) => {
|
|
|
9937
9984
|
}
|
|
9938
9985
|
} catch {}
|
|
9939
9986
|
try {
|
|
9940
|
-
const document = JSON.parse(
|
|
9987
|
+
const document = JSON.parse(readFileSync4(path9.join(dir ?? configDir2(), "workspaces.json"), "utf8"));
|
|
9941
9988
|
if (document && typeof document === "object" && !Array.isArray(document))
|
|
9942
9989
|
out.push({
|
|
9943
9990
|
name: "global",
|
|
@@ -10003,11 +10050,11 @@ function workspaceDefaultTarget(cwd, globalDefault) {
|
|
|
10003
10050
|
// packages/workit-core/src/core/vcs-config.ts
|
|
10004
10051
|
import fs6 from "node:fs";
|
|
10005
10052
|
import path10 from "node:path";
|
|
10006
|
-
import { spawnSync as
|
|
10053
|
+
import { spawnSync as spawnSync8 } from "node:child_process";
|
|
10007
10054
|
|
|
10008
10055
|
// packages/workit-core/src/core/release-tracks.ts
|
|
10009
10056
|
import { createHash as createHash6 } from "node:crypto";
|
|
10010
|
-
import { spawnSync as
|
|
10057
|
+
import { spawnSync as spawnSync7 } from "node:child_process";
|
|
10011
10058
|
class ReleaseTrackError extends Error {
|
|
10012
10059
|
}
|
|
10013
10060
|
var KNOWN_FIELDS = new Set([
|
|
@@ -10292,7 +10339,7 @@ function resolveReleaseTrack(input) {
|
|
|
10292
10339
|
return fallback(`${branch} has the same or unrelated fork points with ${[...new Set(newest.map((fork) => `${fork.ref} (${fork.track.name === IMPLICIT ? "workspace default" : fork.track.name})`))].join(" and ")}`);
|
|
10293
10340
|
}
|
|
10294
10341
|
var git2 = (cwd, args) => {
|
|
10295
|
-
const run =
|
|
10342
|
+
const run = spawnSync7("git", args, {
|
|
10296
10343
|
cwd,
|
|
10297
10344
|
encoding: "utf8",
|
|
10298
10345
|
timeout: 20000,
|
|
@@ -10441,7 +10488,7 @@ var remoteEndpoint = (remote) => {
|
|
|
10441
10488
|
var configuredSshEndpoint = (host) => {
|
|
10442
10489
|
if (host.startsWith("-"))
|
|
10443
10490
|
return null;
|
|
10444
|
-
const resolved =
|
|
10491
|
+
const resolved = spawnSync8("ssh", ["-G", host], {
|
|
10445
10492
|
encoding: "utf8",
|
|
10446
10493
|
timeout: 5000,
|
|
10447
10494
|
maxBuffer: 1024 * 1024,
|
|
@@ -10655,7 +10702,7 @@ function mergedPrStyle(limit = 6, cwd) {
|
|
|
10655
10702
|
`).filter((l) => l.startsWith("## ")).map((l) => l.trim()),
|
|
10656
10703
|
descriptionPreview: desc.slice(0, 600)
|
|
10657
10704
|
});
|
|
10658
|
-
const remoteResult =
|
|
10705
|
+
const remoteResult = spawnSync8("git", ["remote", "get-url", "--push", "--all", "origin"], {
|
|
10659
10706
|
cwd,
|
|
10660
10707
|
encoding: "utf8"
|
|
10661
10708
|
});
|
|
@@ -10671,7 +10718,7 @@ function mergedPrStyle(limit = 6, cwd) {
|
|
|
10671
10718
|
if (!hostingApiHostMatches(remote, host))
|
|
10672
10719
|
return { ok: false, error: "PR style target does not match the provider host" };
|
|
10673
10720
|
if (provider === "gitlab") {
|
|
10674
|
-
const run = (args) =>
|
|
10721
|
+
const run = (args) => spawnSync8("glab", ["api", ...args], {
|
|
10675
10722
|
cwd,
|
|
10676
10723
|
encoding: "utf8",
|
|
10677
10724
|
env
|
|
@@ -10691,7 +10738,7 @@ function mergedPrStyle(limit = 6, cwd) {
|
|
|
10691
10738
|
});
|
|
10692
10739
|
}
|
|
10693
10740
|
} else if (provider === "github") {
|
|
10694
|
-
const r =
|
|
10741
|
+
const r = spawnSync8("gh", [
|
|
10695
10742
|
"pr",
|
|
10696
10743
|
"list",
|
|
10697
10744
|
"--repo",
|
|
@@ -10958,13 +11005,13 @@ var resolveStateDir = () => stateDir(process.env);
|
|
|
10958
11005
|
var homePattern = new RegExp(`${escapeRegExp2(os4.homedir())}(?=[/\\\\]|$)|\\$HOME(?=[/\\\\]|$)`, "g");
|
|
10959
11006
|
|
|
10960
11007
|
// packages/workit-core/src/store/paths.ts
|
|
10961
|
-
import { spawnSync as
|
|
11008
|
+
import { spawnSync as spawnSync9 } from "node:child_process";
|
|
10962
11009
|
import { createHash as createHash8 } from "node:crypto";
|
|
10963
11010
|
import fs7 from "node:fs";
|
|
10964
11011
|
import path11 from "node:path";
|
|
10965
11012
|
var NOT_A_REPO = /not a git repository \(or any (of the parent directories|parent up to)/u;
|
|
10966
11013
|
var gitRun = (cwd, args) => {
|
|
10967
|
-
const run =
|
|
11014
|
+
const run = spawnSync9("git", args, {
|
|
10968
11015
|
cwd,
|
|
10969
11016
|
encoding: "utf8",
|
|
10970
11017
|
timeout: 20000,
|
|
@@ -12409,7 +12456,7 @@ var assetRoot = () => {
|
|
|
12409
12456
|
};
|
|
12410
12457
|
|
|
12411
12458
|
// packages/workit-core/src/core/store-lock.ts
|
|
12412
|
-
import { spawnSync as
|
|
12459
|
+
import { spawnSync as spawnSync10 } from "node:child_process";
|
|
12413
12460
|
import fs13 from "node:fs";
|
|
12414
12461
|
import { hostname } from "node:os";
|
|
12415
12462
|
var metadataLockSchema = object({
|
|
@@ -12460,7 +12507,7 @@ var readProcStat = (pid) => {
|
|
|
12460
12507
|
};
|
|
12461
12508
|
var psStart = (pid) => {
|
|
12462
12509
|
try {
|
|
12463
|
-
const run =
|
|
12510
|
+
const run = spawnSync10("ps", ["-o", "lstart=", "-p", String(pid)], {
|
|
12464
12511
|
encoding: "utf8",
|
|
12465
12512
|
timeout: 1000,
|
|
12466
12513
|
env: { ...process.env, LC_ALL: "C" }
|
|
@@ -14469,11 +14516,11 @@ var holdsLiveState = (state, dirty) => state === "running" || dirty === true;
|
|
|
14469
14516
|
// packages/workit-core/src/core/task-evaluation.ts
|
|
14470
14517
|
import { createHash as createHash13 } from "node:crypto";
|
|
14471
14518
|
import * as fs18 from "node:fs";
|
|
14472
|
-
import { spawnSync as
|
|
14519
|
+
import { spawnSync as spawnSync15 } from "node:child_process";
|
|
14473
14520
|
import path23 from "node:path";
|
|
14474
14521
|
|
|
14475
14522
|
// packages/workit-core/src/check-config.ts
|
|
14476
|
-
import { spawnSync as
|
|
14523
|
+
import { spawnSync as spawnSync11 } from "node:child_process";
|
|
14477
14524
|
import fs16 from "node:fs";
|
|
14478
14525
|
import path19 from "node:path";
|
|
14479
14526
|
var SCRIPT_CHECKS = ["test", "lint", "typecheck", "check"];
|
|
@@ -14538,7 +14585,7 @@ function splitCommand(command) {
|
|
|
14538
14585
|
return argv.length ? argv : new Error("empty command");
|
|
14539
14586
|
}
|
|
14540
14587
|
var git3 = (cwd, args) => {
|
|
14541
|
-
const run =
|
|
14588
|
+
const run = spawnSync11("git", args, {
|
|
14542
14589
|
cwd,
|
|
14543
14590
|
encoding: "utf8",
|
|
14544
14591
|
timeout: 20000,
|
|
@@ -14915,19 +14962,19 @@ import { existsSync as existsSync7 } from "node:fs";
|
|
|
14915
14962
|
import path22 from "node:path";
|
|
14916
14963
|
|
|
14917
14964
|
// packages/workit-core/src/ledger.ts
|
|
14918
|
-
import { spawnSync as
|
|
14965
|
+
import { spawnSync as spawnSync14 } from "node:child_process";
|
|
14919
14966
|
import { createHash as createHash12, randomBytes as randomBytes3 } from "node:crypto";
|
|
14920
14967
|
import fs17 from "node:fs";
|
|
14921
14968
|
import path21 from "node:path";
|
|
14922
14969
|
|
|
14923
14970
|
// packages/workit-core/src/core/policy/bookkeeping.ts
|
|
14924
|
-
import { spawnSync as
|
|
14971
|
+
import { spawnSync as spawnSync12 } from "node:child_process";
|
|
14925
14972
|
var OID = /^[0-9a-f]{40,64}$/u;
|
|
14926
14973
|
var safe = (value) => value.length > 0 && !value.startsWith("-");
|
|
14927
14974
|
function replayTree(cwd, from, fromFork, toFork) {
|
|
14928
14975
|
if (![from, fromFork, toFork].every(safe))
|
|
14929
14976
|
return null;
|
|
14930
|
-
const run =
|
|
14977
|
+
const run = spawnSync12("git", ["merge-tree", "--write-tree", "--no-messages", `--merge-base=${fromFork}`, toFork, from], {
|
|
14931
14978
|
cwd,
|
|
14932
14979
|
encoding: "utf8",
|
|
14933
14980
|
timeout: GIT_TIMEOUTS.worktree,
|
|
@@ -14998,11 +15045,11 @@ function bookkeepingPaths(cwd, input) {
|
|
|
14998
15045
|
}
|
|
14999
15046
|
|
|
15000
15047
|
// packages/workit-core/src/core/policy/lane.ts
|
|
15001
|
-
import { existsSync as existsSync6, readFileSync as
|
|
15048
|
+
import { existsSync as existsSync6, readFileSync as readFileSync7 } from "node:fs";
|
|
15002
15049
|
import path20 from "node:path";
|
|
15003
15050
|
|
|
15004
15051
|
// packages/workit-core/src/git/default-base.ts
|
|
15005
|
-
import { spawnSync as
|
|
15052
|
+
import { spawnSync as spawnSync13 } from "node:child_process";
|
|
15006
15053
|
var safeRef = (value) => value.length > 0 && !value.startsWith("-");
|
|
15007
15054
|
var trackTrunk = (cwd) => {
|
|
15008
15055
|
try {
|
|
@@ -15052,7 +15099,7 @@ var shorten = (table, full) => {
|
|
|
15052
15099
|
return full;
|
|
15053
15100
|
};
|
|
15054
15101
|
function refTable(cwd) {
|
|
15055
|
-
const run =
|
|
15102
|
+
const run = spawnSync13("git", ["for-each-ref", "--format=%(refname)%00%(objecttype)%00%(*objecttype)%00%(symref)"], { cwd, encoding: "utf8", timeout: 20000, killSignal: "SIGKILL", windowsHide: true });
|
|
15056
15103
|
if (run.status !== 0)
|
|
15057
15104
|
return null;
|
|
15058
15105
|
const refs = new Map;
|
|
@@ -15653,7 +15700,7 @@ function computeLane(input) {
|
|
|
15653
15700
|
}
|
|
15654
15701
|
function untrackedStat(cwd, file) {
|
|
15655
15702
|
try {
|
|
15656
|
-
const bytes =
|
|
15703
|
+
const bytes = readFileSync7(path20.join(cwd, file));
|
|
15657
15704
|
if (bytes.includes(0))
|
|
15658
15705
|
return { path: file, added: 0, deleted: 0, binary: true };
|
|
15659
15706
|
const text = bytes.toString("utf8");
|
|
@@ -15684,7 +15731,7 @@ function cosmeticFiles(cwd, fork, head) {
|
|
|
15684
15731
|
let after = blobs.get(entry.newBlob);
|
|
15685
15732
|
if (!after && head === null && ABSENT.test(entry.newBlob))
|
|
15686
15733
|
try {
|
|
15687
|
-
after =
|
|
15734
|
+
after = readFileSync7(path20.join(cwd, entry.path));
|
|
15688
15735
|
} catch {
|
|
15689
15736
|
after = undefined;
|
|
15690
15737
|
}
|
|
@@ -15861,7 +15908,7 @@ var err = (code, error, unblock) => ({
|
|
|
15861
15908
|
...unblock ? { unblock } : {}
|
|
15862
15909
|
});
|
|
15863
15910
|
var gitRun2 = (cwd, args, timeoutMs = GIT_TIMEOUTS.local) => {
|
|
15864
|
-
const run =
|
|
15911
|
+
const run = spawnSync14("git", args, {
|
|
15865
15912
|
cwd,
|
|
15866
15913
|
encoding: "utf8",
|
|
15867
15914
|
timeout: timeoutMs,
|
|
@@ -17198,7 +17245,7 @@ var compareCodeUnits2 = (left, right) => {
|
|
|
17198
17245
|
return left.length - right.length;
|
|
17199
17246
|
};
|
|
17200
17247
|
var gitPaths = (root) => {
|
|
17201
|
-
const result =
|
|
17248
|
+
const result = spawnSync15("git", ["ls-files", "-z", "--cached", "--others", "--exclude-standard"], {
|
|
17202
17249
|
cwd: root,
|
|
17203
17250
|
encoding: "buffer"
|
|
17204
17251
|
});
|
|
@@ -17211,7 +17258,7 @@ var gitPaths = (root) => {
|
|
|
17211
17258
|
};
|
|
17212
17259
|
}
|
|
17213
17260
|
const paths = result.stdout ? result.stdout.toString("utf8").split("\x00").filter(Boolean).map((item) => item.split(path23.sep).join("/")) : [];
|
|
17214
|
-
const stagedDeleted =
|
|
17261
|
+
const stagedDeleted = spawnSync15("git", ["diff", "--cached", "--name-only", "--diff-filter=D", "-z"], { cwd: root, encoding: "buffer" });
|
|
17215
17262
|
if (stagedDeleted.status !== 0) {
|
|
17216
17263
|
const stderr = stagedDeleted.stderr?.toString("utf8") ?? "";
|
|
17217
17264
|
if (!/not a git repository/i.test(stderr))
|
|
@@ -17342,7 +17389,7 @@ function captureCandidate(root, scope, environment = []) {
|
|
|
17342
17389
|
const values = supplied.toSorted((left, right) => compareCodeUnits2(left.name, right.name)).map(({ name, value }) => ({ name, value, refs: [] }));
|
|
17343
17390
|
if (values.some(({ value }) => value === null))
|
|
17344
17391
|
completeness = "uncertain";
|
|
17345
|
-
const headResult =
|
|
17392
|
+
const headResult = spawnSync15("git", ["rev-parse", "HEAD"], { cwd: checkout, encoding: "utf8" });
|
|
17346
17393
|
if (headResult.status !== 0 && !/not a git repository/i.test(headResult.stderr ?? ""))
|
|
17347
17394
|
completeness = "uncertain";
|
|
17348
17395
|
const head = headResult.status === 0 ? headResult.stdout.trim() : null;
|
|
@@ -17869,7 +17916,7 @@ function boundTaskSummary(summary) {
|
|
|
17869
17916
|
|
|
17870
17917
|
// packages/workit-core/src/core/model-fallback.ts
|
|
17871
17918
|
import { createHash as createHash14 } from "node:crypto";
|
|
17872
|
-
import { mkdirSync as mkdirSync4, readFileSync as
|
|
17919
|
+
import { mkdirSync as mkdirSync4, readFileSync as readFileSync9, renameSync as renameSync3, writeFileSync as writeFileSync4 } from "node:fs";
|
|
17873
17920
|
import path24 from "node:path";
|
|
17874
17921
|
var LIMITS_FILE = "model-limits.json";
|
|
17875
17922
|
var DEFAULT_LIMIT_WINDOW_MS = 5 * 3600000;
|
|
@@ -17896,7 +17943,7 @@ var empty = () => ({ exhausted: {}, seen: {}, redispatched: {} });
|
|
|
17896
17943
|
var storePath = (stateDir) => path24.join(stateDir ?? resolveStateDir(), LIMITS_FILE);
|
|
17897
17944
|
var readStore = (stateDir) => {
|
|
17898
17945
|
try {
|
|
17899
|
-
const parsed = JSON.parse(
|
|
17946
|
+
const parsed = JSON.parse(readFileSync9(storePath(stateDir), "utf8"));
|
|
17900
17947
|
const store = empty();
|
|
17901
17948
|
for (const key of ["exhausted", "seen", "redispatched"])
|
|
17902
17949
|
if (parsed[key] && typeof parsed[key] === "object")
|
|
@@ -18507,19 +18554,18 @@ var exportDigest = (bundle) => sha256({
|
|
|
18507
18554
|
task: bundle.task
|
|
18508
18555
|
});
|
|
18509
18556
|
// packages/workit-core/src/core/route-intent.ts
|
|
18510
|
-
import { spawnSync as
|
|
18557
|
+
import { spawnSync as spawnSync17 } from "node:child_process";
|
|
18511
18558
|
import { existsSync as existsSync10 } from "node:fs";
|
|
18512
18559
|
import path29 from "node:path";
|
|
18513
18560
|
|
|
18514
18561
|
// packages/workit-core/src/hooks/raw-git.ts
|
|
18515
|
-
import { spawnSync as
|
|
18562
|
+
import { spawnSync as spawnSync16 } from "node:child_process";
|
|
18516
18563
|
import { createHash as createHash16 } from "node:crypto";
|
|
18517
18564
|
import fs20 from "node:fs";
|
|
18518
|
-
import
|
|
18565
|
+
import os6 from "node:os";
|
|
18519
18566
|
import path28 from "node:path";
|
|
18520
18567
|
|
|
18521
18568
|
// packages/workit-core/src/autonomy.ts
|
|
18522
|
-
import os6 from "node:os";
|
|
18523
18569
|
import path26 from "node:path";
|
|
18524
18570
|
|
|
18525
18571
|
// packages/workit-core/src/core/eval-world.ts
|
|
@@ -18532,30 +18578,43 @@ var inside2 = (dir, file) => {
|
|
|
18532
18578
|
const rel = path25.relative(dir, file);
|
|
18533
18579
|
return !rel.startsWith("..") && !path25.isAbsolute(rel);
|
|
18534
18580
|
};
|
|
18535
|
-
var
|
|
18581
|
+
var evalWorld = (cwd) => {
|
|
18536
18582
|
const raw = process.env[EVAL_WORLD_ENV];
|
|
18537
18583
|
if (!raw || !path25.isAbsolute(raw))
|
|
18538
18584
|
return null;
|
|
18539
18585
|
try {
|
|
18540
18586
|
const world = realpathSync5(raw);
|
|
18541
|
-
|
|
18542
|
-
return null;
|
|
18543
|
-
return loadWorkspacesFrom(path25.join(world, "config"))[0] ?? null;
|
|
18587
|
+
return inside2(realpathSync5(os5.tmpdir()), world) && inside2(world, realpathSync5(cwd)) && existsSync9(path25.join(world, EVAL_WORLD_MARKER)) ? world : null;
|
|
18544
18588
|
} catch {
|
|
18545
18589
|
return null;
|
|
18546
18590
|
}
|
|
18547
18591
|
};
|
|
18548
|
-
|
|
18549
|
-
|
|
18550
|
-
var accountHome2 = () => {
|
|
18592
|
+
var evalWorldEntry = (cwd) => {
|
|
18593
|
+
const world = evalWorld(cwd);
|
|
18551
18594
|
try {
|
|
18552
|
-
return
|
|
18595
|
+
return world ? loadWorkspacesFrom(path25.join(world, "config"))[0] ?? null : null;
|
|
18553
18596
|
} catch {
|
|
18554
|
-
return
|
|
18597
|
+
return null;
|
|
18555
18598
|
}
|
|
18556
18599
|
};
|
|
18557
|
-
|
|
18558
|
-
|
|
18600
|
+
|
|
18601
|
+
// packages/workit-core/src/autonomy.ts
|
|
18602
|
+
var grantsHome = { resolve: accountHome };
|
|
18603
|
+
var accountDir = () => {
|
|
18604
|
+
const home = grantsHome.resolve();
|
|
18605
|
+
return home === null ? null : configDir({ HOME: home });
|
|
18606
|
+
};
|
|
18607
|
+
var grantsDir = () => accountDir() ?? resolveConfigDir();
|
|
18608
|
+
var NO_ACCOUNT = "no OS account record answered (core/account-home.ts), so no grants are read: the D4 defaults apply";
|
|
18609
|
+
var entriesIn = (dir) => dir === null ? [] : loadWorkspacesFrom(dir);
|
|
18610
|
+
var resolveFrom = (cwd, name) => {
|
|
18611
|
+
const dir = accountDir();
|
|
18612
|
+
return dir === null ? null : resolveWorkspaceFrom(cwd, dir, name);
|
|
18613
|
+
};
|
|
18614
|
+
var shownGrantsDir = () => {
|
|
18615
|
+
const world = evalWorld(process.cwd());
|
|
18616
|
+
return world ? path26.join(world, "config") : accountDir();
|
|
18617
|
+
};
|
|
18559
18618
|
var benchWorld = (cwd) => {
|
|
18560
18619
|
const entry = evalWorldEntry(cwd);
|
|
18561
18620
|
if (!entry)
|
|
@@ -18575,8 +18634,11 @@ var benchWorld = (cwd) => {
|
|
|
18575
18634
|
};
|
|
18576
18635
|
};
|
|
18577
18636
|
var grantsOverride = () => {
|
|
18637
|
+
const shown = shownGrantsDir();
|
|
18638
|
+
if (shown === null)
|
|
18639
|
+
return NO_ACCOUNT;
|
|
18578
18640
|
const configured = path26.resolve(resolveConfigDir());
|
|
18579
|
-
return configured === path26.resolve(
|
|
18641
|
+
return configured === path26.resolve(shown) ? null : `the config directory is redirected to ${configured} (WORKIT_CONFIG, WORKIT_CONFIG_DIR or XDG_CONFIG_HOME), but that override does not apply to grants: grants are read only from ${path26.join(grantsDir(), "workspaces.json")}, so the D4 defaults apply until grants are set there`;
|
|
18580
18642
|
};
|
|
18581
18643
|
var GRANT_KINDS = ["push", "pr", "merge", "release", "rerun"];
|
|
18582
18644
|
var DEFAULT_GRANTS = Object.freeze({
|
|
@@ -18702,7 +18764,7 @@ function capAt(named, where, by, why, main = false) {
|
|
|
18702
18764
|
try {
|
|
18703
18765
|
if (where instanceof Error)
|
|
18704
18766
|
throw where;
|
|
18705
|
-
folder = autonomyOf(typeof where === "string" ?
|
|
18767
|
+
folder = autonomyOf(typeof where === "string" ? resolveFrom(where) : where.entry);
|
|
18706
18768
|
} catch (error) {
|
|
18707
18769
|
none = error.message;
|
|
18708
18770
|
}
|
|
@@ -18746,7 +18808,10 @@ function resolveAutonomy(cwd, target) {
|
|
|
18746
18808
|
if (override)
|
|
18747
18809
|
return { ...autonomyOf(null), note: override };
|
|
18748
18810
|
const name = process.env.WORKIT_WORKSPACE_NAME?.trim() || undefined;
|
|
18749
|
-
|
|
18811
|
+
const real = resolveFrom(cwd, name);
|
|
18812
|
+
let autonomy = autonomyOf(real ?? world);
|
|
18813
|
+
if (!real && world)
|
|
18814
|
+
autonomy.world = evalWorld(cwd) ?? undefined;
|
|
18750
18815
|
if (name)
|
|
18751
18816
|
autonomy = capAt(autonomy, cwd, `WORKIT_WORKSPACE_NAME=${name}`, "a name never raises grants");
|
|
18752
18817
|
const above = checkoutsAbove(cwd);
|
|
@@ -18755,7 +18820,7 @@ function resolveAutonomy(cwd, target) {
|
|
|
18755
18820
|
return capAtRemotes(autonomy, cwd, target);
|
|
18756
18821
|
}
|
|
18757
18822
|
function capAtRemotes(autonomy, cwd, target) {
|
|
18758
|
-
const claiming =
|
|
18823
|
+
const claiming = entriesIn(accountDir()).filter((entry) => entry.remotes?.length);
|
|
18759
18824
|
if (claiming.length === 0)
|
|
18760
18825
|
return autonomy;
|
|
18761
18826
|
const remotes = target === undefined ? checkoutRemotes(cwd) : typeof target === "function" ? target() : target;
|
|
@@ -18770,15 +18835,15 @@ function capAtRemotes(autonomy, cwd, target) {
|
|
|
18770
18835
|
}
|
|
18771
18836
|
return capped;
|
|
18772
18837
|
}
|
|
18773
|
-
var grantsMatter = (kind) => !grantsOverride() &&
|
|
18838
|
+
var grantsMatter = (kind) => !grantsOverride() && entriesIn(accountDir()).some((entry) => {
|
|
18774
18839
|
const autonomy = autonomyOf(entry);
|
|
18775
18840
|
return entry.remotes?.length || autonomy.grants[kind] === false || autonomy.configured.length > 0 && !autonomy.accountConfigured;
|
|
18776
18841
|
});
|
|
18777
|
-
var remotesClaimed = (dir =
|
|
18778
|
-
function targetClaims(target, dir =
|
|
18842
|
+
var remotesClaimed = (dir = accountDir()) => entriesIn(dir).some((entry) => entry.remotes?.length);
|
|
18843
|
+
function targetClaims(target, dir = accountDir()) {
|
|
18779
18844
|
if (target instanceof Error)
|
|
18780
18845
|
return target;
|
|
18781
|
-
const claiming =
|
|
18846
|
+
const claiming = entriesIn(dir).filter((entry) => entry.remotes?.length);
|
|
18782
18847
|
return target.remotes.flatMap((remote) => claiming.flatMap((entry) => {
|
|
18783
18848
|
const pattern = entry.remotes.find((item) => remoteMatches(item, remote.key));
|
|
18784
18849
|
return pattern ? [{ url: remote.url, workspace: entry.name, pattern }] : [];
|
|
@@ -18816,7 +18881,7 @@ function rawGrantDenial(cwd, kind, target) {
|
|
|
18816
18881
|
const claims = targetClaims(lazy());
|
|
18817
18882
|
if (claims instanceof Error)
|
|
18818
18883
|
return { error: `${kind}: ${claims.message}`, unblock: "name a target workit can resolve" };
|
|
18819
|
-
const entries =
|
|
18884
|
+
const entries = entriesIn(accountDir());
|
|
18820
18885
|
const strict = claims.find(({ workspace: name }) => {
|
|
18821
18886
|
const entry = entries.find((item) => item.name === name);
|
|
18822
18887
|
return entry && autonomyOf(entry).grants[kind] === false;
|
|
@@ -19202,7 +19267,9 @@ var tokenize = (command, dialect) => {
|
|
|
19202
19267
|
heredocs.push({ delimiter: text.replace(/^-/, ""), owner: current });
|
|
19203
19268
|
else if (pending === "herestring")
|
|
19204
19269
|
(current.stdin ??= []).push(text);
|
|
19205
|
-
else if (pending
|
|
19270
|
+
else if (pending === "input")
|
|
19271
|
+
(current.inputs ??= []).push(text);
|
|
19272
|
+
else {
|
|
19206
19273
|
const at = current.words.length;
|
|
19207
19274
|
current.words.push(...MARKERS.test(word) ? expandBraces(word) : [word]);
|
|
19208
19275
|
if (expanding || !posix && word.startsWith("@"))
|
|
@@ -19448,7 +19515,7 @@ var joinDir = (base, raw) => {
|
|
|
19448
19515
|
const next = raw.replace(HERE, ".");
|
|
19449
19516
|
if (base === undefined || /[$`*?]/.test(next) || next === "-")
|
|
19450
19517
|
return;
|
|
19451
|
-
const expanded = next === "~" || next.startsWith("~/") ? path28.join(
|
|
19518
|
+
const expanded = next === "~" || next.startsWith("~/") ? path28.join(os6.homedir(), next.slice(1)) : next;
|
|
19452
19519
|
return base === null || isAbsolute(expanded) ? expanded : path28.join(base, expanded);
|
|
19453
19520
|
};
|
|
19454
19521
|
var rebase = (base, inner) => inner === null ? base : inner === undefined ? undefined : joinDir(base, inner);
|
|
@@ -19850,7 +19917,7 @@ function walk2(command, dialect, depth, seen, inherited = {}) {
|
|
|
19850
19917
|
}
|
|
19851
19918
|
if (CD.has(name)) {
|
|
19852
19919
|
const target = cdTarget(words);
|
|
19853
|
-
dir = target === null ?
|
|
19920
|
+
dir = target === null ? os6.homedir() : joinDir(dir, target);
|
|
19854
19921
|
} else if (PUSHD.has(name)) {
|
|
19855
19922
|
const target = cdTarget(words);
|
|
19856
19923
|
stack.push(dir);
|
|
@@ -20393,7 +20460,7 @@ var gitConfig = (dir, invocation, cache) => {
|
|
|
20393
20460
|
if (cached)
|
|
20394
20461
|
return cached;
|
|
20395
20462
|
const config = new Map;
|
|
20396
|
-
const listed =
|
|
20463
|
+
const listed = spawnSync16("git", [...invocation.config ?? [], "config", "-z", "--list"], {
|
|
20397
20464
|
cwd: dir,
|
|
20398
20465
|
encoding: "utf8",
|
|
20399
20466
|
timeout: 3000,
|
|
@@ -20566,7 +20633,7 @@ var refFacts = (repo, remote) => {
|
|
|
20566
20633
|
tags: new Set,
|
|
20567
20634
|
remoteHeads: new Set
|
|
20568
20635
|
};
|
|
20569
|
-
const listed =
|
|
20636
|
+
const listed = spawnSync16("git", ["for-each-ref", "--format=%(refname)", "refs/heads", "refs/tags", `refs/remotes/${remote}`], { cwd: repo.dir, encoding: "utf8", timeout: 5000 });
|
|
20570
20637
|
const remotePrefix = `refs/remotes/${remote}/`;
|
|
20571
20638
|
for (const ref of (listed.stdout ?? "").split(`
|
|
20572
20639
|
`)) {
|
|
@@ -20583,7 +20650,7 @@ var globBranches = (repo, glob) => {
|
|
|
20583
20650
|
const source = glob.source.startsWith("refs/") ? glob.source : `refs/heads/${glob.source}`;
|
|
20584
20651
|
const [sourcePrefix, sourceSuffix = ""] = source.split("*");
|
|
20585
20652
|
const [destinationPrefix, destinationSuffix = ""] = glob.destination.split("*");
|
|
20586
|
-
const listed =
|
|
20653
|
+
const listed = spawnSync16("git", [
|
|
20587
20654
|
"for-each-ref",
|
|
20588
20655
|
"--format=%(refname)",
|
|
20589
20656
|
sourcePrefix.slice(0, sourcePrefix.lastIndexOf("/") + 1)
|
|
@@ -20660,7 +20727,7 @@ var tagRefusal = (action, facts, dir) => {
|
|
|
20660
20727
|
return `workit: raw ${quote(`git push${action.allTags ? " --tags" : ""}`)} of ${tags.length ? `tag ${tags.join(", ")}` : "tags"} bypasses the release grant. Push a release tag with ${quote(`workit git push --release ${named}`)} (${shape} tags whose commit the production branch already has; a tag never moves), under the ${quote("release")} grant (if refused, ask the user to run ${quote("workit grant set <workspace> release=true")}).`;
|
|
20661
20728
|
};
|
|
20662
20729
|
var remoteHeads = (repo, remote) => {
|
|
20663
|
-
const listed =
|
|
20730
|
+
const listed = spawnSync16("git", ["ls-remote", "--heads", remote], {
|
|
20664
20731
|
cwd: repo.dir,
|
|
20665
20732
|
encoding: "utf8",
|
|
20666
20733
|
timeout: 3000,
|
|
@@ -20881,7 +20948,7 @@ var cdCommitCall = (input, command, target, repo) => {
|
|
|
20881
20948
|
if (!messages.length)
|
|
20882
20949
|
return null;
|
|
20883
20950
|
if (!all) {
|
|
20884
|
-
const staged =
|
|
20951
|
+
const staged = spawnSync16("git", ["diff", "--cached", "--quiet"], {
|
|
20885
20952
|
cwd: target,
|
|
20886
20953
|
timeout: 5000
|
|
20887
20954
|
});
|
|
@@ -21042,7 +21109,7 @@ function noteRawCommit(input, command, key) {
|
|
|
21042
21109
|
} catch {}
|
|
21043
21110
|
}
|
|
21044
21111
|
var headCommit = (dir) => {
|
|
21045
|
-
const run =
|
|
21112
|
+
const run = spawnSync16("git", [
|
|
21046
21113
|
"log",
|
|
21047
21114
|
"-1",
|
|
21048
21115
|
"--format=%H%x1f%ct%x1f%s%x1f%(trailers:key=Workit-Session,valueonly,separator=%x2c)"
|
|
@@ -21254,7 +21321,7 @@ var targetsOf = (invocations) => invocations.flatMap((invocation) => invocation.
|
|
|
21254
21321
|
branch,
|
|
21255
21322
|
dir: invocation.dir
|
|
21256
21323
|
})) : []);
|
|
21257
|
-
var localBranchExists = (dir, branch) =>
|
|
21324
|
+
var localBranchExists = (dir, branch) => spawnSync17("git", ["show-ref", "--verify", "--quiet", `refs/heads/${branch}`], {
|
|
21258
21325
|
cwd: dir,
|
|
21259
21326
|
stdio: "ignore",
|
|
21260
21327
|
timeout: 5000
|
|
@@ -23260,8 +23327,8 @@ class WorkitCore {
|
|
|
23260
23327
|
}
|
|
23261
23328
|
}
|
|
23262
23329
|
// packages/workit-core/src/core/repo-context.ts
|
|
23263
|
-
import { spawnSync as
|
|
23264
|
-
import { existsSync as existsSync11, readFileSync as
|
|
23330
|
+
import { spawnSync as spawnSync18 } from "node:child_process";
|
|
23331
|
+
import { existsSync as existsSync11, readFileSync as readFileSync10, readdirSync as readdirSync4 } from "node:fs";
|
|
23265
23332
|
import path30 from "node:path";
|
|
23266
23333
|
var isSafeContextRange = (value) => value.length <= 4096 && (() => {
|
|
23267
23334
|
try {
|
|
@@ -23289,7 +23356,7 @@ var invalidRange = (cwd) => ({
|
|
|
23289
23356
|
cwd
|
|
23290
23357
|
});
|
|
23291
23358
|
var runGit = (cwd, args) => {
|
|
23292
|
-
const result =
|
|
23359
|
+
const result = spawnSync18("git", args, { cwd, encoding: "utf8" });
|
|
23293
23360
|
return {
|
|
23294
23361
|
stdout: (result.stdout ?? "").trimEnd(),
|
|
23295
23362
|
stderr: (result.stderr ?? "").trimEnd(),
|
|
@@ -23446,7 +23513,7 @@ var packageScripts = (cwd, keys) => {
|
|
|
23446
23513
|
if (!existsSync11(pkgPath))
|
|
23447
23514
|
return [];
|
|
23448
23515
|
try {
|
|
23449
|
-
const pkg = JSON.parse(
|
|
23516
|
+
const pkg = JSON.parse(readFileSync10(pkgPath, "utf8"));
|
|
23450
23517
|
return keys.filter((k) => pkg.scripts && typeof pkg.scripts[k] === "string").map((k) => `${k}: ${pkg.scripts?.[k]}`);
|
|
23451
23518
|
} catch {
|
|
23452
23519
|
return [];
|
|
@@ -23480,7 +23547,7 @@ var documentationFiles = (cwd) => {
|
|
|
23480
23547
|
var readTrimmed2 = (file, maxLines) => {
|
|
23481
23548
|
if (!existsSync11(file))
|
|
23482
23549
|
return "";
|
|
23483
|
-
const lines =
|
|
23550
|
+
const lines = readFileSync10(file, "utf8").split(`
|
|
23484
23551
|
`);
|
|
23485
23552
|
return lines.slice(0, maxLines).join(`
|
|
23486
23553
|
`);
|
|
@@ -23668,7 +23735,7 @@ function docsRefreshContext(root, range) {
|
|
|
23668
23735
|
const pkgPath = path30.join(cwd, "package.json");
|
|
23669
23736
|
if (existsSync11(pkgPath)) {
|
|
23670
23737
|
try {
|
|
23671
|
-
const pkg = JSON.parse(
|
|
23738
|
+
const pkg = JSON.parse(readFileSync10(pkgPath, "utf8"));
|
|
23672
23739
|
stdout += JSON.stringify({ name: pkg.name, version: pkg.version, scripts: pkg.scripts }, null, 2) + `
|
|
23673
23740
|
`;
|
|
23674
23741
|
} catch {}
|
|
@@ -23750,12 +23817,12 @@ function releaseNotesContext(root, rangeOrTag) {
|
|
|
23750
23817
|
}
|
|
23751
23818
|
|
|
23752
23819
|
// packages/workit-core/src/core/tracker-issues.ts
|
|
23753
|
-
import { spawnSync as
|
|
23820
|
+
import { spawnSync as spawnSync20 } from "node:child_process";
|
|
23754
23821
|
|
|
23755
23822
|
// packages/workit-core/src/core/pr-create.ts
|
|
23756
23823
|
import fs21 from "node:fs";
|
|
23757
23824
|
import path31 from "node:path";
|
|
23758
|
-
import { spawnSync as
|
|
23825
|
+
import { spawnSync as spawnSync19 } from "node:child_process";
|
|
23759
23826
|
import { pathToFileURL } from "node:url";
|
|
23760
23827
|
// packages/workit-core/src/forge/pr-body.ts
|
|
23761
23828
|
function parseGhIssue(value) {
|
|
@@ -23790,7 +23857,7 @@ function whichOnPath(tool) {
|
|
|
23790
23857
|
}
|
|
23791
23858
|
var hostingCliAvailable = (provider) => whichOnPath(provider === "gitlab" ? "glab" : "gh") !== null;
|
|
23792
23859
|
var pushRemote = (cwd) => {
|
|
23793
|
-
const result =
|
|
23860
|
+
const result = spawnSync19("git", ["remote", "get-url", "--push", "--all", "origin"], {
|
|
23794
23861
|
cwd,
|
|
23795
23862
|
...LOCAL
|
|
23796
23863
|
});
|
|
@@ -23826,7 +23893,7 @@ var pushTargetIsStable = (cwd, remote) => {
|
|
|
23826
23893
|
const target = safePushUrl(remote);
|
|
23827
23894
|
if (!target)
|
|
23828
23895
|
return false;
|
|
23829
|
-
const result =
|
|
23896
|
+
const result = spawnSync19("git", ["config", "--get-regexp", "^url\\..*\\.(insteadof|pushinsteadof)$"], { cwd, ...LOCAL });
|
|
23830
23897
|
if (result.status !== 0 && result.status !== 1)
|
|
23831
23898
|
return false;
|
|
23832
23899
|
const prefixes = (result.stdout ?? "").split(/\r?\n/u).map((line) => line.trim().slice(line.trim().indexOf(" ") + 1)).filter(Boolean);
|
|
@@ -23854,7 +23921,7 @@ var defaultCli = (bin, available) => {
|
|
|
23854
23921
|
if (!available)
|
|
23855
23922
|
return null;
|
|
23856
23923
|
return (args, root) => {
|
|
23857
|
-
const out =
|
|
23924
|
+
const out = spawnSync20(bin, args, {
|
|
23858
23925
|
cwd: root,
|
|
23859
23926
|
encoding: "utf8",
|
|
23860
23927
|
env: { ...process.env, PATH: process.env.PATH ?? "" }
|
|
@@ -23944,7 +24011,7 @@ var ASSET_ROOT = assetRoot();
|
|
|
23944
24011
|
var resolveWorkspaceRoot = (explicit) => explicit || process.cwd();
|
|
23945
24012
|
|
|
23946
24013
|
// packages/workit-core/src/core/youtrack-ytrack.ts
|
|
23947
|
-
import { spawnSync as
|
|
24014
|
+
import { spawnSync as spawnSync21 } from "node:child_process";
|
|
23948
24015
|
|
|
23949
24016
|
// packages/workit-core/src/forge/exec.ts
|
|
23950
24017
|
import fs22 from "node:fs";
|
|
@@ -23986,7 +24053,7 @@ function ytrackRunner(env, host, timeoutMs = TIMEOUT_MS) {
|
|
|
23986
24053
|
const exe = findYtrack(env);
|
|
23987
24054
|
if (!exe)
|
|
23988
24055
|
return { status: null, stdout: "", stderr: "", missing: true };
|
|
23989
|
-
const result =
|
|
24056
|
+
const result = spawnSync21(exe, args, {
|
|
23990
24057
|
encoding: "utf8",
|
|
23991
24058
|
env: { ...env, NO_COLOR: "1", ...host ? { YTRACK_HOST: host } : {} },
|
|
23992
24059
|
timeout: timeoutMs,
|
|
@@ -24469,7 +24536,7 @@ function resolveInside(root, candidate) {
|
|
|
24469
24536
|
}
|
|
24470
24537
|
function run2(root, executable, args, env = {}) {
|
|
24471
24538
|
const cwd = realpathSync8(root);
|
|
24472
|
-
const result =
|
|
24539
|
+
const result = spawnSync22(executable, args, {
|
|
24473
24540
|
cwd,
|
|
24474
24541
|
encoding: "utf8",
|
|
24475
24542
|
env: { ...process.env, ...env }
|
|
@@ -24711,7 +24778,7 @@ var isAllowedWorkitCommand = (command) => {
|
|
|
24711
24778
|
};
|
|
24712
24779
|
// packages/workit-core/src/core/heavy-rules.ts
|
|
24713
24780
|
import fs24 from "node:fs";
|
|
24714
|
-
import
|
|
24781
|
+
import os7 from "node:os";
|
|
24715
24782
|
import path36 from "node:path";
|
|
24716
24783
|
var EMPTY2 = () => ({ deny: [], allow: [] });
|
|
24717
24784
|
var readText3 = (file) => {
|
|
@@ -24769,7 +24836,7 @@ var projectDirs = (cwd) => {
|
|
|
24769
24836
|
return dirs;
|
|
24770
24837
|
}
|
|
24771
24838
|
};
|
|
24772
|
-
var homeOf = (env) => env.HOME ||
|
|
24839
|
+
var homeOf = (env) => env.HOME || os7.homedir();
|
|
24773
24840
|
var CLAUDE_MANAGED = {
|
|
24774
24841
|
linux: "/etc/claude-code/managed-settings.json",
|
|
24775
24842
|
darwin: "/Library/Application Support/ClaudeCode/managed-settings.json",
|
|
@@ -25489,21 +25556,21 @@ function heavyGate(cwd, command, options) {
|
|
|
25489
25556
|
}
|
|
25490
25557
|
}
|
|
25491
25558
|
// packages/workit-core/src/hooks/write-gate.ts
|
|
25492
|
-
import { existsSync as existsSync13, realpathSync as realpathSync9, statSync as statSync5 } from "node:fs";
|
|
25493
|
-
import
|
|
25559
|
+
import { existsSync as existsSync13, readdirSync as readdirSync5, readFileSync as readFileSync11, realpathSync as realpathSync9, statSync as statSync5 } from "node:fs";
|
|
25560
|
+
import os9 from "node:os";
|
|
25494
25561
|
import path40 from "node:path";
|
|
25495
25562
|
|
|
25496
25563
|
// packages/workit-core/src/core/live-session.ts
|
|
25497
|
-
import { spawnSync as
|
|
25564
|
+
import { spawnSync as spawnSync23 } from "node:child_process";
|
|
25498
25565
|
import { createHash as createHash17 } from "node:crypto";
|
|
25499
25566
|
import fs27 from "node:fs";
|
|
25500
|
-
import
|
|
25567
|
+
import os8 from "node:os";
|
|
25501
25568
|
import path39 from "node:path";
|
|
25502
25569
|
var LIVE_SESSION_TTL_MS = 15 * 60000;
|
|
25503
25570
|
var HEARTBEAT_EVERY_MS = 30000;
|
|
25504
25571
|
var liveProbe = {
|
|
25505
25572
|
platform: process.platform,
|
|
25506
|
-
run: (args) =>
|
|
25573
|
+
run: (args) => spawnSync23("ps", args, { encoding: "utf8", timeout: 2000 }).stdout ?? "",
|
|
25507
25574
|
start: (pid) => processStartOf(pid)
|
|
25508
25575
|
};
|
|
25509
25576
|
var leadOf = (session) => session.split(":")[0].replace(/-w-.*$/su, "") || session;
|
|
@@ -25623,7 +25690,7 @@ var isLive = (marker, deps) => {
|
|
|
25623
25690
|
const age = ageOf2(marker, deps.now ?? new Date);
|
|
25624
25691
|
if (age > (deps.ttlMs ?? LIVE_SESSION_TTL_MS))
|
|
25625
25692
|
return false;
|
|
25626
|
-
if (marker.machine !== (deps.machine ??
|
|
25693
|
+
if (marker.machine !== (deps.machine ?? os8.hostname()) || marker.pid === null)
|
|
25627
25694
|
return true;
|
|
25628
25695
|
if (!(deps.alive ?? processAlive)(marker.pid))
|
|
25629
25696
|
return false;
|
|
@@ -25652,7 +25719,7 @@ var liveConflict = (target, owner, deps = {}) => {
|
|
|
25652
25719
|
const marker = readMarker(file);
|
|
25653
25720
|
if (!marker || sameLead(marker, owner) || !isLive(marker, deps))
|
|
25654
25721
|
return null;
|
|
25655
|
-
if (sameOwner(marker, owner, deps.machine ??
|
|
25722
|
+
if (sameOwner(marker, owner, deps.machine ?? os8.hostname()))
|
|
25656
25723
|
return null;
|
|
25657
25724
|
return { marker, file, ageMs: ageOf2(marker, deps.now ?? new Date), checkout };
|
|
25658
25725
|
} catch {
|
|
@@ -25666,7 +25733,7 @@ var claimLiveSession = (target, owner, deps = {}) => {
|
|
|
25666
25733
|
return;
|
|
25667
25734
|
const file = markerFile2(checkout);
|
|
25668
25735
|
const now = deps.now ?? new Date;
|
|
25669
|
-
const machine = deps.machine ??
|
|
25736
|
+
const machine = deps.machine ?? os8.hostname();
|
|
25670
25737
|
const current = readMarker(file);
|
|
25671
25738
|
if (current) {
|
|
25672
25739
|
const age = ageOf2(current, now);
|
|
@@ -25755,9 +25822,9 @@ var editsOf = (input) => {
|
|
|
25755
25822
|
case "cp":
|
|
25756
25823
|
case "ln":
|
|
25757
25824
|
case "install": {
|
|
25758
|
-
const
|
|
25759
|
-
if (
|
|
25760
|
-
return
|
|
25825
|
+
const into = valueOf(args, /^(?:-t|--target-directory=?)(.*)$/s);
|
|
25826
|
+
if (into !== undefined)
|
|
25827
|
+
return [into];
|
|
25761
25828
|
const last = operands(args).at(-1);
|
|
25762
25829
|
return last ? [last] : null;
|
|
25763
25830
|
}
|
|
@@ -25811,6 +25878,84 @@ var editsOf = (input) => {
|
|
|
25811
25878
|
return [];
|
|
25812
25879
|
}
|
|
25813
25880
|
};
|
|
25881
|
+
var WRAPPERS2 = {
|
|
25882
|
+
sudo: "ugCDhpRrTtU",
|
|
25883
|
+
doas: "uC",
|
|
25884
|
+
env: "uCS",
|
|
25885
|
+
nice: "n",
|
|
25886
|
+
ionice: "cnp",
|
|
25887
|
+
timeout: "sk",
|
|
25888
|
+
stdbuf: "ioe",
|
|
25889
|
+
time: "fo",
|
|
25890
|
+
nohup: "",
|
|
25891
|
+
command: "",
|
|
25892
|
+
exec: "a",
|
|
25893
|
+
setsid: "",
|
|
25894
|
+
builtin: "",
|
|
25895
|
+
"!": "",
|
|
25896
|
+
npx: "p",
|
|
25897
|
+
bunx: "p"
|
|
25898
|
+
};
|
|
25899
|
+
var INTERPRETERS = /^(?:python[\d.]*|node|bun|deno|ruby|perl|php|tsx|ts-node)$/;
|
|
25900
|
+
var isConfigDir = (file) => configDirs().some((dir) => canonical3(dir) === canonical3(file));
|
|
25901
|
+
var isRoot = (file) => isConfigDir(file) || /^(?:issued[^\\/]*|approvals)$/.test(path40.relative(canonical3(resolveStateDir()), canonical3(file)));
|
|
25902
|
+
var READ_CALLS = /^(?:print|log|info|warn|error|debug|puts|readdir(?:Sync)?|listdir|scandir|iterdir|glob|l?stat(?:Sync)?|exists(?:Sync)?|isdir|isfile|is_dir|is_file|access(?:Sync)?|realpath(?:Sync)?|dirname|basename|relative|str|repr|len)$/;
|
|
25903
|
+
var MUTATING_CALLS = /^(?:renames?(?:Sync)?|move|copy(?:2|file|tree|File)?(?:Sync)?|cp(?:Sync)?|rm(?:tree|dir|Sync|dirSync)?|unlink(?:Sync)?|remove(?:dirs)?|mkdirs?(?:Sync)?|makedirs|mkdtemp(?:Sync)?|(?:sym|hard)?link(?:Sync|_to)?|write\w*|append\w*|truncate(?:Sync)?|ch(?:mod|own)(?:Sync)?|touch|open(?:Sync)?|dump|save|extractall|unpack_archive|put_contents|mv|FileUtils)$/;
|
|
25904
|
+
var PATH_CALLS = /^(?:join|resolve|normalize|abspath|expanduser|expandvars|Path|PurePath|fspath)$/;
|
|
25905
|
+
var readsRoot = (text, at) => {
|
|
25906
|
+
let call;
|
|
25907
|
+
for (let index = at, depth = 0;index > 0 && call === undefined; index--) {
|
|
25908
|
+
const char = text[index - 1];
|
|
25909
|
+
if (char === ")")
|
|
25910
|
+
depth++;
|
|
25911
|
+
else if (char === "(" && depth-- === 0)
|
|
25912
|
+
call = /([\w$]+)\s*$/.exec(text.slice(0, index - 1))?.[1] ?? "";
|
|
25913
|
+
else if (depth <= 0 && /[;\n]/.test(char))
|
|
25914
|
+
break;
|
|
25915
|
+
}
|
|
25916
|
+
if (call !== undefined && READ_CALLS.test(call))
|
|
25917
|
+
return true;
|
|
25918
|
+
if (call !== undefined && !PATH_CALLS.test(call))
|
|
25919
|
+
return false;
|
|
25920
|
+
return ![...text.matchAll(/([\w$]+)\s*\(/g)].some(([, name]) => MUTATING_CALLS.test(name));
|
|
25921
|
+
};
|
|
25922
|
+
var inertEdit = (command) => command.split("|").every((part) => /^:?(?:se(?:t)?|sy(?:ntax)?|colo(?:rscheme)?)(?:\s|$)|^[/?][^/?]*[/?]?$|^\d+$/.test(part.trim()));
|
|
25923
|
+
var SCRIPT_OPTIONS = [
|
|
25924
|
+
[/^(?:(?:ba|z|k|da)?sh|source|\.)$/, /^(?:[-+][oO]|--(?:rcfile|init-file))$/],
|
|
25925
|
+
[/^python/, /^-[WXQ]$/],
|
|
25926
|
+
[
|
|
25927
|
+
/./,
|
|
25928
|
+
/^(?:-[rCI]|--(?:require|import|(?:experimental-)?loader|preload|input-type|conditions|title|cwd|tsconfig|project|env-file|config))$/
|
|
25929
|
+
]
|
|
25930
|
+
];
|
|
25931
|
+
var PRELOAD = /^(?:-r|--(?:require|import|(?:experimental-)?loader|preload|rcfile|init-file))$/;
|
|
25932
|
+
var scriptArgs = (verb, args) => {
|
|
25933
|
+
const takes = SCRIPT_OPTIONS.find(([family]) => family.test(verb))?.[1] ?? /^$/;
|
|
25934
|
+
const preloads = [];
|
|
25935
|
+
for (let at = 0;at < args.length; at++) {
|
|
25936
|
+
const [option, value] = args[at].split(/=(.*)/s);
|
|
25937
|
+
if (value !== undefined && PRELOAD.test(option))
|
|
25938
|
+
preloads.push(value);
|
|
25939
|
+
else if (/^-[mce]$|^--(?:eval|print)$/.test(option))
|
|
25940
|
+
break;
|
|
25941
|
+
else if (takes.test(option)) {
|
|
25942
|
+
if (PRELOAD.test(option))
|
|
25943
|
+
preloads.push(args[at + 1] ?? "");
|
|
25944
|
+
at++;
|
|
25945
|
+
} else if (!/^[-+]/.test(option) && option !== "run")
|
|
25946
|
+
return { named: args[at], preloads };
|
|
25947
|
+
}
|
|
25948
|
+
return { preloads };
|
|
25949
|
+
};
|
|
25950
|
+
var unwrapped = (words) => {
|
|
25951
|
+
let at = 0;
|
|
25952
|
+
for (let takes;(takes = WRAPPERS2[words[at]?.split(/[\\/]/).at(-1) ?? ""]) !== undefined; ) {
|
|
25953
|
+
at++;
|
|
25954
|
+
while (at < words.length && /^-|^\w+=|^\d[\w.]*$/.test(words[at]))
|
|
25955
|
+
at += words[at].length === 2 && words[at][0] === "-" && takes.includes(words[at][1]) ? 2 : 1;
|
|
25956
|
+
}
|
|
25957
|
+
return at ? words.slice(at) : null;
|
|
25958
|
+
};
|
|
25814
25959
|
var shellScript2 = (words) => {
|
|
25815
25960
|
if (!SCRIPT_SHELLS.has((words[0]?.split(/[\\/]/).at(-1) ?? "").toLowerCase()))
|
|
25816
25961
|
return null;
|
|
@@ -26055,9 +26200,8 @@ var gitOutputs = (args) => {
|
|
|
26055
26200
|
const under = (file) => file === "." ? `${base}/${OPAQUE_TARGET}git` : /^[/~$]|^[A-Za-z]:[\\/]/.test(file) ? file : `${base}/${file}`;
|
|
26056
26201
|
return files.length ? files.map(under) : null;
|
|
26057
26202
|
};
|
|
26058
|
-
var
|
|
26059
|
-
|
|
26060
|
-
].map((match) => match[0]);
|
|
26203
|
+
var PATHS = /(?<![\w.~:/$-])(?:~\/|\/|[A-Za-z]:\/|\.\.(?:\/|$))[^\s'"`$),;:*?<>|\\[\]{}]*/g;
|
|
26204
|
+
var pathsIn = (text) => [...text.matchAll(PATHS)].map((match) => match[0]);
|
|
26061
26205
|
var linkSources = (args, at) => {
|
|
26062
26206
|
const names = operands([...args]);
|
|
26063
26207
|
const into = args.indexOf("-t");
|
|
@@ -26184,16 +26328,16 @@ var CD2 = new Set(["cd", "chdir", "set-location", "sl"]);
|
|
|
26184
26328
|
var PUSHD2 = new Set(["pushd", "push-location"]);
|
|
26185
26329
|
var POPD2 = new Set(["popd", "pop-location"]);
|
|
26186
26330
|
var UNKNOWN_DIR = path40.resolve(path40.parse(process.cwd()).root, ".workit-unknown-dir");
|
|
26187
|
-
var cdInto = (dir, words, strict = false, vars = new Map) => {
|
|
26331
|
+
var cdInto = (dir, words, strict = false, vars = new Map, globs = false) => {
|
|
26188
26332
|
const lost = strict ? UNKNOWN_DIR : undefined;
|
|
26189
26333
|
const found = words.slice(1).find((word) => !word.startsWith("-") || word === "-");
|
|
26190
26334
|
const named = found === undefined ? undefined : expandVars(found, vars);
|
|
26191
26335
|
const target = named === undefined ? undefined : homeExpanded(named);
|
|
26192
|
-
if (target === "-" || target && /^~|[$`*?]
|
|
26336
|
+
if (target === "-" || target && (globs ? /^~|[$`]/ : /^~|[$`*?]/).test(target))
|
|
26193
26337
|
return lost;
|
|
26194
26338
|
if (dir === undefined)
|
|
26195
26339
|
return lost;
|
|
26196
|
-
return target === undefined ?
|
|
26340
|
+
return target === undefined ? os9.homedir() : path40.resolve(dir, target);
|
|
26197
26341
|
};
|
|
26198
26342
|
var quoteWord2 = (word) => /^[\w@%+=:,./-]+$/.test(word) ? word : `'${word.replaceAll("'", "'\\''")}'`;
|
|
26199
26343
|
var expandVars = (text, vars) => vars.size === 0 || !text.includes("$") ? text : text.replace(/\$(?:(\w+)|\{(\w+)\})/g, (whole, bare, braced) => {
|
|
@@ -26212,7 +26356,8 @@ var assignmentsOf = (words) => {
|
|
|
26212
26356
|
var commandWords = (words) => {
|
|
26213
26357
|
let start = 0;
|
|
26214
26358
|
while (start < words.length && COMPOUND.has(words[start]))
|
|
26215
|
-
start
|
|
26359
|
+
if (words[start++] === "function")
|
|
26360
|
+
start++;
|
|
26216
26361
|
return words.slice(start);
|
|
26217
26362
|
};
|
|
26218
26363
|
var REBINDS_ANY = new Set([
|
|
@@ -26364,7 +26509,8 @@ var expansions = (text, vars, loops) => {
|
|
|
26364
26509
|
last = match.index + match[0].length;
|
|
26365
26510
|
const value = vars.get(name);
|
|
26366
26511
|
const values = loops.get(name) ?? (value === undefined ? null : [value]);
|
|
26367
|
-
const
|
|
26512
|
+
const fallback = /^:?[-=](.*)$/s.exec(match[2] ?? "")?.[1];
|
|
26513
|
+
const applied = values?.flatMap((item) => fallback === undefined ? [applyOperator(item, match[2] ?? "")] : item === "" ? expansions(fallback, vars, loops) : [item]);
|
|
26368
26514
|
const fits = applied && results.length * applied.length <= MAX_EXPANSIONS2;
|
|
26369
26515
|
results = fits && applied.every((item) => item !== null) ? results.flatMap((prefix) => applied.map((item) => prefix + literal + item)) : results.map((prefix) => prefix + literal + match[0]);
|
|
26370
26516
|
}
|
|
@@ -26395,7 +26541,7 @@ var mktempPath = (value, dir) => {
|
|
|
26395
26541
|
template = arg;
|
|
26396
26542
|
}
|
|
26397
26543
|
if (base === null && (temp || template === undefined))
|
|
26398
|
-
base =
|
|
26544
|
+
base = os9.tmpdir();
|
|
26399
26545
|
const name = homeExpanded(template ?? "tmp.XXXXXXXXXX");
|
|
26400
26546
|
if (path40.isAbsolute(name))
|
|
26401
26547
|
return name;
|
|
@@ -26406,10 +26552,11 @@ var mktempPath = (value, dir) => {
|
|
|
26406
26552
|
};
|
|
26407
26553
|
var homeExpanded = (file) => {
|
|
26408
26554
|
const match = /^(?:~|\$HOME|\$\{HOME\})(?=\/|$)/.exec(file);
|
|
26409
|
-
return match ? (process.env.HOME ||
|
|
26555
|
+
return match ? (process.env.HOME || os9.homedir()) + file.slice(match[0].length) : file;
|
|
26410
26556
|
};
|
|
26411
26557
|
var segmentTargets = (cwd, command, dialect, depth = 0, strict = false, inherited = new Map) => {
|
|
26412
26558
|
const targets = [];
|
|
26559
|
+
const written = new Map;
|
|
26413
26560
|
let dir = cwd;
|
|
26414
26561
|
let stack = [];
|
|
26415
26562
|
const segments = segmentsOf(command, dialect);
|
|
@@ -26472,6 +26619,8 @@ var segmentTargets = (cwd, command, dialect, depth = 0, strict = false, inherite
|
|
|
26472
26619
|
continue;
|
|
26473
26620
|
}
|
|
26474
26621
|
const body = commandWords(segment.words);
|
|
26622
|
+
const before = segments[segments.indexOf(segment) - 1];
|
|
26623
|
+
const feeder = before?.pipe ? before : undefined;
|
|
26475
26624
|
const keywords = segment.words.length - body.length;
|
|
26476
26625
|
for (const keyword of segment.words.slice(0, keywords))
|
|
26477
26626
|
if (OPENS.has(keyword))
|
|
@@ -26525,7 +26674,7 @@ var segmentTargets = (cwd, command, dialect, depth = 0, strict = false, inherite
|
|
|
26525
26674
|
}
|
|
26526
26675
|
const plain = !segment.conditional;
|
|
26527
26676
|
if (CD2.has(name)) {
|
|
26528
|
-
dir = cdInto(dir, words, strict, vars);
|
|
26677
|
+
dir = cdInto(dir, words, Boolean(strict), vars, strict === "registry");
|
|
26529
26678
|
moved(plain);
|
|
26530
26679
|
continue;
|
|
26531
26680
|
}
|
|
@@ -26536,7 +26685,7 @@ var segmentTargets = (cwd, command, dialect, depth = 0, strict = false, inherite
|
|
|
26536
26685
|
}
|
|
26537
26686
|
if (PUSHD2.has(name)) {
|
|
26538
26687
|
stack.push(dir);
|
|
26539
|
-
dir = cdInto(dir, words, strict, vars);
|
|
26688
|
+
dir = cdInto(dir, words, Boolean(strict), vars, strict === "registry");
|
|
26540
26689
|
moved(plain);
|
|
26541
26690
|
continue;
|
|
26542
26691
|
}
|
|
@@ -26545,15 +26694,94 @@ var segmentTargets = (cwd, command, dialect, depth = 0, strict = false, inherite
|
|
|
26545
26694
|
moved(plain);
|
|
26546
26695
|
continue;
|
|
26547
26696
|
}
|
|
26548
|
-
const
|
|
26697
|
+
const literal = depth < 4 ? wrappedScript(words) ?? (strict ? shellScript2(words) : null) : null;
|
|
26698
|
+
const held = literal !== null && strict === "registry" ? expansions(literal, vars, loops) : [];
|
|
26699
|
+
const inner = held.length === 1 ? held[0] : literal;
|
|
26549
26700
|
const unPwd = () => new Map([...vars].filter(([key]) => key !== "PWD"));
|
|
26550
26701
|
if (inner !== null && dir !== undefined)
|
|
26551
26702
|
for (const runIn of workitRunDir(dir, words, atAll))
|
|
26552
26703
|
targets.push(...segmentTargets(runIn, inner, "posix", depth + 1, strict, runIn === dir ? vars : unPwd()));
|
|
26704
|
+
const bare = strict === "registry" && depth < 4 ? unwrapped(words) : null;
|
|
26705
|
+
if (bare?.length && dir !== undefined)
|
|
26706
|
+
targets.push(...segmentTargets(dir, bare.flatMap((word) => expansions(word, vars, loops)).map(quoteWord2).join(" "), "posix", depth + 1, strict, vars));
|
|
26707
|
+
if (strict === "registry" && dir !== undefined && depth < 4) {
|
|
26708
|
+
const run = words.slice(Math.max(0, words.findIndex((word) => !PREFIXES2.has(word))));
|
|
26709
|
+
const [verb = "", ...args] = run.map((word, index) => index ? word : (word.split(/[\\/]/).at(-1) ?? "").toLowerCase());
|
|
26710
|
+
const fed = segment.stdin?.join(`
|
|
26711
|
+
`);
|
|
26712
|
+
if (fed !== undefined)
|
|
26713
|
+
for (const file of segment.redirects)
|
|
26714
|
+
for (const into of atAll(file))
|
|
26715
|
+
written.set(into, fed);
|
|
26716
|
+
const read = (file) => atAll(file).flatMap((script) => {
|
|
26717
|
+
const made = written.get(script);
|
|
26718
|
+
if (made !== undefined)
|
|
26719
|
+
return [made];
|
|
26720
|
+
try {
|
|
26721
|
+
const stat = statSync5(script);
|
|
26722
|
+
const text = stat.isFile() && stat.size <= 262144 ? readFileSync11(script, "utf8") : "\x00";
|
|
26723
|
+
return text.includes("\x00") ? [] : [text];
|
|
26724
|
+
} catch {
|
|
26725
|
+
return [];
|
|
26726
|
+
}
|
|
26727
|
+
});
|
|
26728
|
+
const { named: operand, preloads } = scriptArgs(verb, args);
|
|
26729
|
+
const named = operand === "/dev/stdin" ? undefined : operand;
|
|
26730
|
+
const maker = feeder ? commandWords(feeder.words) : [];
|
|
26731
|
+
const [format = "", ...values] = maker.slice(1);
|
|
26732
|
+
let filled = 0;
|
|
26733
|
+
const printed = format.replace(/%[sbq]/g, () => values[filled++] ?? "");
|
|
26734
|
+
const piped = /^(?:echo|printf)$/.test(maker[0] ?? "") ? [[maker[0] === "printf" ? printed : format, ...values].join(`
|
|
26735
|
+
`).replaceAll("\\n", `
|
|
26736
|
+
`)] : maker[0] === "cat" ? [...feeder?.stdin ?? [], ...operands(maker.slice(1)).flatMap(read)] : [];
|
|
26737
|
+
const inputs = (segment.inputs ?? []).filter((file) => file !== "/dev/null");
|
|
26738
|
+
const shells = verb === "eval" ? [args.join(" ")] : verb === "trap" ? args.slice(0, 1) : verb === "alias" ? args.map((arg) => arg.replace(/^[^=]*=/, "")) : [];
|
|
26739
|
+
const others = [];
|
|
26740
|
+
if (SCRIPT_SHELLS.has(verb) || verb === "." || verb === "source") {
|
|
26741
|
+
if (named === undefined && shellScript2(run) === null)
|
|
26742
|
+
shells.push(...segment.stdin ?? [], ...inputs.flatMap(read), ...piped);
|
|
26743
|
+
else if (named !== undefined && shellScript2(run) === null)
|
|
26744
|
+
shells.push(...read(named));
|
|
26745
|
+
shells.push(...preloads.flatMap(read));
|
|
26746
|
+
} else if (INTERPRETERS.test(verb)) {
|
|
26747
|
+
const code = args.findIndex((arg) => /^-[a-zA-Z]*[ce]$|^--eval$/.test(arg));
|
|
26748
|
+
if (code >= 0)
|
|
26749
|
+
others.push(...expansions(args[code + 1] ?? "", vars, loops));
|
|
26750
|
+
others.push(...named === undefined ? [...segment.stdin ?? [], ...inputs.flatMap(read), ...piped] : read(named), ...preloads.flatMap(read));
|
|
26751
|
+
} else if (/[\\/]/.test(run[0] ?? ""))
|
|
26752
|
+
for (const text of read(run[0]))
|
|
26753
|
+
(/^#!.*\b(?:python|node|bun|deno|ruby|perl|php)/.test(text) ? others : shells).push(text);
|
|
26754
|
+
for (const script of shells)
|
|
26755
|
+
targets.push(...segmentTargets(dir, script, "posix", depth + 1, strict, vars));
|
|
26756
|
+
for (const raw of others) {
|
|
26757
|
+
const text = raw.replace(/^\s*(?:#(?!!)|\/\/|\/?\*).*$/gm, "");
|
|
26758
|
+
const joined = [
|
|
26759
|
+
...text.matchAll(/(?:["'][^"'\s,*?[]+["']\s*[,/+]\s*)+["'][^"'\s,*?[]+["']/g)
|
|
26760
|
+
].map(({ 0: literals, index }) => ({
|
|
26761
|
+
word: literals.replace(/["']\s*[,/+]\s*["']/g, "/").replace(/["']/g, ""),
|
|
26762
|
+
index
|
|
26763
|
+
}));
|
|
26764
|
+
const homes = /homedir\(|expanduser\(|Path\.home\(|['"]HOME['"]|env\.HOME|\$HOME|~/.test(text);
|
|
26765
|
+
const under = (word) => homes ? [path40.join(homeExpanded("~"), word.replace(/^~/, ""))] : [];
|
|
26766
|
+
const found = [
|
|
26767
|
+
...[...text.matchAll(PATHS)].flatMap(({ 0: word, index }) => [...atAll(word), ...under(word)].map((file) => ({ file, index }))),
|
|
26768
|
+
...joined.flatMap(({ word, index }) => under(word).map((file) => ({ file, index })))
|
|
26769
|
+
];
|
|
26770
|
+
for (const { file, index } of found)
|
|
26771
|
+
if (!isRoot(file) || !readsRoot(text, index))
|
|
26772
|
+
targets.push(file);
|
|
26773
|
+
}
|
|
26774
|
+
if (/^(?:n?vim?|ex|ed|emacs)$/.test(verb) && (segment.stdin || inputs.length > 0 || feeder || args.some((arg, index) => /^(?:-[a-zA-Z]*[se]|--(?:batch|eval|script))$/.test(arg) || /^(?:-c|--cmd)$/.test(arg) && !inertEdit(args[index + 1] ?? "") || arg.startsWith("+") && !inertEdit(arg.slice(1) || "1"))))
|
|
26775
|
+
for (const file of operands(args))
|
|
26776
|
+
targets.push(...atAll(file));
|
|
26777
|
+
if (verb === "cp" && args.some((arg) => /^-[a-zA-Z]*l|^--link$/.test(arg)))
|
|
26778
|
+
for (const file of operands(args).slice(0, -1))
|
|
26779
|
+
targets.push(...atAll(file));
|
|
26780
|
+
}
|
|
26553
26781
|
if (strict && dir !== undefined) {
|
|
26554
26782
|
const runIn = dir;
|
|
26555
26783
|
for (const sub of depth < 4 ? segment.subs ?? [] : [])
|
|
26556
|
-
targets.push(...segmentTargets(runIn, sub, dialect, depth + 1,
|
|
26784
|
+
targets.push(...segmentTargets(runIn, sub, dialect, depth + 1, strict, vars));
|
|
26557
26785
|
const expanding = new Set(segment.expands ?? []);
|
|
26558
26786
|
const scriptOf = (index) => {
|
|
26559
26787
|
const word = body[index];
|
|
@@ -26569,12 +26797,15 @@ var segmentTargets = (cwd, command, dialect, depth = 0, strict = false, inherite
|
|
|
26569
26797
|
if (runner !== undefined && expanding.has(keywords + lead + ran) && unresolvedRefs(homeExpanded(runner)).length > 0)
|
|
26570
26798
|
targets.push(unknownVarTarget(runner));
|
|
26571
26799
|
const here = segment.unanalyzable ? DIR_TARGET : `${OPAQUE_TARGET}${encodeURIComponent(runner?.split(/[\\/]/).at(-1) ?? "a command")}`;
|
|
26800
|
+
const quiet = strict === "registry" && INTERPRETERS.test(runner?.split(/[\\/]/).at(-1) ?? "");
|
|
26572
26801
|
for (const file of opaque ?? [])
|
|
26573
26802
|
for (const resolved of atAll(file))
|
|
26574
|
-
|
|
26803
|
+
if (!quiet || !isRoot(resolved))
|
|
26804
|
+
targets.push(file === "." ? path40.join(resolved, here) : resolved);
|
|
26575
26805
|
const ln = words.findIndex((word) => /^ln$/i.test(word.split(/[\\/]/).at(-1) ?? ""));
|
|
26576
|
-
|
|
26577
|
-
|
|
26806
|
+
const lnArgs = words.slice(ln + 1);
|
|
26807
|
+
if (ln >= 0 && words.slice(0, ln).every((word) => PREFIXES2.has(word)) && (strict !== "registry" || !lnArgs.some((arg) => /^-[a-zA-Z]*s|^--symbolic$/.test(arg))))
|
|
26808
|
+
targets.push(...linkSources(lnArgs, at));
|
|
26578
26809
|
}
|
|
26579
26810
|
for (const file of segment.redirects)
|
|
26580
26811
|
if (!/^\/dev\/(?:null|stdout|stderr|tty)$/.test(file))
|
|
@@ -26609,11 +26840,14 @@ var workitCwd = (dir, args, resolve) => {
|
|
|
26609
26840
|
};
|
|
26610
26841
|
var shellMutationTargets = (cwd, command, dialect = "posix", strict = false) => {
|
|
26611
26842
|
try {
|
|
26843
|
+
const env = new Map(strict === "registry" ? [...command.matchAll(/\$\{?([A-Za-z_]\w*)/g)].filter((match) => !/^(?:OLD)?PWD$/.test(match[1])).map((match) => [match[1], process.env[match[1]] ?? ""]) : []);
|
|
26612
26844
|
return [
|
|
26613
|
-
...segmentTargets(cwd, command, dialect, 0, strict),
|
|
26845
|
+
...segmentTargets(cwd, command, dialect, 0, strict, env),
|
|
26614
26846
|
...gitMutationDirs(cwd, command, dialect).map((dir) => path40.join(dir, DIR_TARGET))
|
|
26615
26847
|
];
|
|
26616
|
-
} catch {
|
|
26848
|
+
} catch (error) {
|
|
26849
|
+
if (strict === "registry")
|
|
26850
|
+
throw error;
|
|
26617
26851
|
return [];
|
|
26618
26852
|
}
|
|
26619
26853
|
};
|
|
@@ -26671,12 +26905,79 @@ var claimAll = (owner, targets, deps) => {
|
|
|
26671
26905
|
};
|
|
26672
26906
|
var liveTargets = (cwd, paths) => paths?.length ? paths.map((file) => path40.resolve(cwd, file)) : [path40.join(cwd, DIR_TARGET)];
|
|
26673
26907
|
var configDirs = () => [resolveConfigDir(), grantsDir()];
|
|
26908
|
+
var globbed = (cwd, target, state, configs) => {
|
|
26909
|
+
if (!/[*?[]/.test(target))
|
|
26910
|
+
return [];
|
|
26911
|
+
const raw = path40.resolve(cwd, target).split(path40.sep);
|
|
26912
|
+
const literal = raw.findIndex((part) => /[*?[]/.test(part));
|
|
26913
|
+
const pattern = [
|
|
26914
|
+
...canonical3(raw.slice(0, literal).join(path40.sep) || path40.sep).replace(/[\\/]+$/, "").split(path40.sep),
|
|
26915
|
+
...raw.slice(literal)
|
|
26916
|
+
];
|
|
26917
|
+
const segment = (glob, name) => {
|
|
26918
|
+
try {
|
|
26919
|
+
return new RegExp(`^${glob.startsWith(".") ? "" : "(?!\\.)"}${glob.replace(/[.+^$(){}|\\]/g, "\\$&").replace(/\[!/g, "[^").replaceAll("*", ".*").replaceAll("?", ".")}$`, CASE_INSENSITIVE ? "i" : "").test(name);
|
|
26920
|
+
} catch {
|
|
26921
|
+
return false;
|
|
26922
|
+
}
|
|
26923
|
+
};
|
|
26924
|
+
const hit = (file, below) => {
|
|
26925
|
+
const parts = canonical3(file).split(path40.sep);
|
|
26926
|
+
return (below ? pattern.length >= parts.length : pattern.length === parts.length) && parts.every((part, index) => segment(pattern[index], part));
|
|
26927
|
+
};
|
|
26928
|
+
let roots = [];
|
|
26929
|
+
try {
|
|
26930
|
+
roots = readdirSync5(state).filter((name) => /^(?:issued|approvals$)/.test(name));
|
|
26931
|
+
} catch {}
|
|
26932
|
+
return [
|
|
26933
|
+
...roots.map((name) => path40.join(state, name)).filter((root) => hit(root, true)),
|
|
26934
|
+
...configs.flatMap((dir) => [dir, path40.join(dir, "workspaces.json")]).filter((file) => hit(file, false))
|
|
26935
|
+
];
|
|
26936
|
+
};
|
|
26937
|
+
var guardedInodes = (state, configs) => {
|
|
26938
|
+
const seen = new Map;
|
|
26939
|
+
let budget = 2000;
|
|
26940
|
+
const add = (file, registry) => {
|
|
26941
|
+
if (budget-- <= 0)
|
|
26942
|
+
return;
|
|
26943
|
+
const stat = statSync5(file, { throwIfNoEntry: false });
|
|
26944
|
+
if (stat?.isFile())
|
|
26945
|
+
seen.set(`${stat.dev}:${stat.ino}`, registry);
|
|
26946
|
+
else if (stat?.isDirectory())
|
|
26947
|
+
for (const name of readdirSync5(file))
|
|
26948
|
+
add(path40.join(file, name), registry);
|
|
26949
|
+
};
|
|
26950
|
+
try {
|
|
26951
|
+
for (const dir of configs)
|
|
26952
|
+
add(path40.join(dir, "workspaces.json"), "grants");
|
|
26953
|
+
for (const name of readdirSync5(state))
|
|
26954
|
+
if (/^(?:issued|approvals$)/.test(name))
|
|
26955
|
+
add(path40.join(state, name), name === "approvals" ? "approvals" : "issued");
|
|
26956
|
+
} catch {}
|
|
26957
|
+
return seen;
|
|
26958
|
+
};
|
|
26959
|
+
var hardLinked = (file, state, configs, inodes) => {
|
|
26960
|
+
try {
|
|
26961
|
+
const stat = statSync5(file, { throwIfNoEntry: false });
|
|
26962
|
+
if (!stat?.isFile() || stat.nlink < 2 || !stat.ino)
|
|
26963
|
+
return;
|
|
26964
|
+
inodes.map ??= guardedInodes(state, configs);
|
|
26965
|
+
return inodes.map.get(`${stat.dev}:${stat.ino}`);
|
|
26966
|
+
} catch {
|
|
26967
|
+
return;
|
|
26968
|
+
}
|
|
26969
|
+
};
|
|
26674
26970
|
var registryTarget = (cwd, targets) => {
|
|
26675
26971
|
const state = resolveStateDir();
|
|
26676
26972
|
const configs = configDirs();
|
|
26973
|
+
const inodes = {};
|
|
26677
26974
|
for (const target of targets) {
|
|
26678
26975
|
const file = homeExpanded(target);
|
|
26679
|
-
const
|
|
26976
|
+
const glob = globbed(cwd, file, state, configs)[0];
|
|
26977
|
+
const viaGlob = glob === undefined ? null : registryTarget(cwd, [glob]);
|
|
26978
|
+
if (viaGlob)
|
|
26979
|
+
return { file: target, registry: viaGlob.registry };
|
|
26980
|
+
const registry = hardLinked(path40.resolve(cwd, file), state, configs, inodes) ?? underRegistry(state, cwd, file, process.platform, canonical3) ?? (configs.some((dir) => underConfig(dir, cwd, file, process.platform, canonical3)) ? "grants" : null);
|
|
26680
26981
|
if (registry)
|
|
26681
26982
|
return { file: target, registry };
|
|
26682
26983
|
}
|
|
@@ -26698,7 +26999,7 @@ var underRegistry = (state, cwd, target, platform = process.platform, real = (fi
|
|
|
26698
26999
|
};
|
|
26699
27000
|
var underConfig = (dir, cwd, target, platform = process.platform, real = (file) => file) => {
|
|
26700
27001
|
const parts = partsUnder(dir, cwd, target, platform, real);
|
|
26701
|
-
return parts?.length === 1 &&
|
|
27002
|
+
return parts?.length === 1 && ["", "workspaces.json", DIR_TARGET].includes(parts[0]);
|
|
26702
27003
|
};
|
|
26703
27004
|
var unquotedWindowsRegistry = (command, platform = process.platform) => {
|
|
26704
27005
|
if (platform !== "win32" || !command.includes("\\"))
|
|
@@ -26706,8 +27007,21 @@ var unquotedWindowsRegistry = (command, platform = process.platform) => {
|
|
|
26706
27007
|
const flat = (value) => value.replaceAll("\\", "/").toLowerCase();
|
|
26707
27008
|
const text = flat(command);
|
|
26708
27009
|
const state = flat(resolveStateDir());
|
|
26709
|
-
const
|
|
26710
|
-
|
|
27010
|
+
const configs = configDirs().map(flat);
|
|
27011
|
+
const registry = text.includes(`${state}/issued`) ? "issued" : text.includes(`${state}/approvals`) ? "approvals" : configs.some((dir) => text.includes(dir)) ? "grants" : null;
|
|
27012
|
+
if (!registry)
|
|
27013
|
+
return null;
|
|
27014
|
+
const spans = command.replace(/[^\s'"|;&<>()]*\\[^\s'"|;&<>()]*/g, (word) => word.replaceAll("\\", "/"));
|
|
27015
|
+
const writes = shellWrites(spans);
|
|
27016
|
+
const moved = [
|
|
27017
|
+
"",
|
|
27018
|
+
...[...spans.matchAll(/(?:^|[;&|(]\s*)(?:cd|pushd|chdir)\s+([^\s;&|)]+)/g)].map((match) => `${match[1]}/`)
|
|
27019
|
+
];
|
|
27020
|
+
const named = (target) => moved.some((dir) => {
|
|
27021
|
+
const at = flat(/^(?:[a-z]:)?\//i.test(target) ? target : dir + target).replace(/\/\.?\//g, "/");
|
|
27022
|
+
return registry === "grants" ? configs.some((cfg) => [cfg, `${cfg}/`, `${cfg}/workspaces.json`].includes(at)) : at.includes(`${state}/${registry}`);
|
|
27023
|
+
});
|
|
27024
|
+
return writes.writes && (writes.targets === null || writes.targets.some(named)) ? registry : null;
|
|
26711
27025
|
};
|
|
26712
27026
|
var REGISTRY_DENY = {
|
|
26713
27027
|
issued: {
|
|
@@ -26728,9 +27042,10 @@ var REGISTRY_DENY = {
|
|
|
26728
27042
|
};
|
|
26729
27043
|
var registryDeny = ({ file, registry }) => {
|
|
26730
27044
|
const { label, what, unblock } = REGISTRY_DENY[registry];
|
|
27045
|
+
const named = path40.basename(file).startsWith(".workit-") ? path40.dirname(file) : file;
|
|
26731
27046
|
return {
|
|
26732
27047
|
kind: "deny",
|
|
26733
|
-
reason: `workit ${label}: ${
|
|
27048
|
+
reason: `workit ${label}: ${named} is under ${what}. ${unblock}`,
|
|
26734
27049
|
unblock
|
|
26735
27050
|
};
|
|
26736
27051
|
};
|
|
@@ -26752,10 +27067,20 @@ function writeGate(cwd, paths, owner, deps) {
|
|
|
26752
27067
|
function shellGate(cwd, command, owner, dialect = "posix", deps) {
|
|
26753
27068
|
try {
|
|
26754
27069
|
const windows = unquotedWindowsRegistry(command);
|
|
26755
|
-
const forged = registryTarget(cwd,
|
|
27070
|
+
const forged = registryTarget(cwd, shellMutationTargets(cwd, command, dialect, "registry")) ?? (windows ? { file: `the ${windows} registry`, registry: windows } : null);
|
|
26756
27071
|
if (forged)
|
|
26757
27072
|
return registryDeny(forged);
|
|
26758
|
-
} catch {
|
|
27073
|
+
} catch {
|
|
27074
|
+
const text = command.replaceAll("\\", "/").replace(/['"]/g, "").toLowerCase();
|
|
27075
|
+
if (/issued|approvals|workspaces\.json|\.config\/workit|state\/workit/.test(text) || [resolveStateDir(), ...configDirs()].some((dir) => text.includes(dir.replaceAll("\\", "/").toLowerCase()))) {
|
|
27076
|
+
const { unblock } = REGISTRY_DENY.grants;
|
|
27077
|
+
return {
|
|
27078
|
+
kind: "deny",
|
|
27079
|
+
reason: `workit registry guard: Workit could not analyse this command, which names a guarded path; split it into plain commands. ${unblock}`,
|
|
27080
|
+
unblock
|
|
27081
|
+
};
|
|
27082
|
+
}
|
|
27083
|
+
}
|
|
26759
27084
|
const writes = shellWrites(command);
|
|
26760
27085
|
let targets = [];
|
|
26761
27086
|
if (owner)
|
|
@@ -26803,7 +27128,7 @@ function beforeWriteGate(cwd, paths) {
|
|
|
26803
27128
|
}
|
|
26804
27129
|
}
|
|
26805
27130
|
// packages/workit-core/src/hooks/stop.ts
|
|
26806
|
-
import { spawnSync as
|
|
27131
|
+
import { spawnSync as spawnSync24 } from "node:child_process";
|
|
26807
27132
|
|
|
26808
27133
|
// packages/workit-core/src/ci-waiter.ts
|
|
26809
27134
|
import fs28 from "node:fs";
|
|
@@ -26902,7 +27227,7 @@ var asksUser = (message) => {
|
|
|
26902
27227
|
};
|
|
26903
27228
|
var short = (sha) => (sha ?? "?").slice(0, 12);
|
|
26904
27229
|
var gitList = (cwd, args) => {
|
|
26905
|
-
const run =
|
|
27230
|
+
const run = spawnSync24("git", args, {
|
|
26906
27231
|
cwd,
|
|
26907
27232
|
encoding: "utf8",
|
|
26908
27233
|
timeout: 3000,
|
|
@@ -28178,7 +28503,7 @@ if (false) {}
|
|
|
28178
28503
|
import path47 from "node:path";
|
|
28179
28504
|
|
|
28180
28505
|
// packages/workit-core/src/core/gitignore.ts
|
|
28181
|
-
import { existsSync as existsSync14, readFileSync as
|
|
28506
|
+
import { existsSync as existsSync14, readFileSync as readFileSync12, writeFileSync as writeFileSync5 } from "node:fs";
|
|
28182
28507
|
import path43 from "node:path";
|
|
28183
28508
|
var GITIGNORE_ENTRIES = [
|
|
28184
28509
|
"# workit: SDD working state (never commit)",
|
|
@@ -28200,7 +28525,7 @@ var ensureProjectGitignore = (workspaceRoot, confirmed) => {
|
|
|
28200
28525
|
if (!confirmed)
|
|
28201
28526
|
return { ok: false, error: "confirmed: true required" };
|
|
28202
28527
|
const file = path43.join(workspaceRoot, ".gitignore");
|
|
28203
|
-
const existing = existsSync14(file) ?
|
|
28528
|
+
const existing = existsSync14(file) ? readFileSync12(file, "utf8") : "";
|
|
28204
28529
|
const existingLines = new Set(existing.split(`
|
|
28205
28530
|
`).map((l) => l.trim()).filter(Boolean));
|
|
28206
28531
|
const added = [];
|
|
@@ -28226,7 +28551,7 @@ var ensureProjectGitignore = (workspaceRoot, confirmed) => {
|
|
|
28226
28551
|
};
|
|
28227
28552
|
|
|
28228
28553
|
// packages/workit-core/src/core/hygiene.ts
|
|
28229
|
-
import { existsSync as existsSync15, readFileSync as
|
|
28554
|
+
import { existsSync as existsSync15, readFileSync as readFileSync13, readdirSync as readdirSync6, writeFileSync as writeFileSync6 } from "node:fs";
|
|
28230
28555
|
import path44 from "node:path";
|
|
28231
28556
|
var repoRoot3 = assetRoot();
|
|
28232
28557
|
var templatesDir = () => path44.join(repoRoot3, "templates", "hygiene");
|
|
@@ -28234,7 +28559,7 @@ var packageJson = (root) => {
|
|
|
28234
28559
|
if (!existsSync15(path44.join(root, "package.json")))
|
|
28235
28560
|
return null;
|
|
28236
28561
|
try {
|
|
28237
|
-
return JSON.parse(
|
|
28562
|
+
return JSON.parse(readFileSync13(path44.join(root, "package.json"), "utf8"));
|
|
28238
28563
|
} catch {
|
|
28239
28564
|
return null;
|
|
28240
28565
|
}
|
|
@@ -28273,7 +28598,7 @@ var planHygieneFiles = (root, opts = {}) => {
|
|
|
28273
28598
|
const tpl = path44.join(templatesDir(), file);
|
|
28274
28599
|
if (!existsSync15(tpl))
|
|
28275
28600
|
continue;
|
|
28276
|
-
const content =
|
|
28601
|
+
const content = readFileSync13(tpl, "utf8").replace(/<PROJECT>/g, path44.basename(root)).replace(/<YEAR>/g, String(new Date().getFullYear())).replace(/<HOLDER>\s*/g, licenseHolder(root));
|
|
28277
28602
|
planned.push({ path: path44.join(root, file), content });
|
|
28278
28603
|
}
|
|
28279
28604
|
return planned;
|
|
@@ -28292,15 +28617,15 @@ var ensureHygieneFiles = (root, opts) => {
|
|
|
28292
28617
|
// packages/workit-core/src/core/init.ts
|
|
28293
28618
|
import fs30 from "node:fs";
|
|
28294
28619
|
import path46 from "node:path";
|
|
28295
|
-
import { spawnSync as
|
|
28620
|
+
import { spawnSync as spawnSync25 } from "node:child_process";
|
|
28296
28621
|
|
|
28297
28622
|
// packages/workit-core/src/core/workspace-branch-policy.ts
|
|
28298
|
-
import { mkdirSync as mkdirSync5, readFileSync as
|
|
28623
|
+
import { mkdirSync as mkdirSync5, readFileSync as readFileSync14, renameSync as renameSync4, rmSync as rmSync3, writeFileSync as writeFileSync7 } from "node:fs";
|
|
28299
28624
|
import path45 from "node:path";
|
|
28300
28625
|
import { isDeepStrictEqual } from "node:util";
|
|
28301
28626
|
var readFileSafe = (p) => {
|
|
28302
28627
|
try {
|
|
28303
|
-
return
|
|
28628
|
+
return readFileSync14(p, "utf8");
|
|
28304
28629
|
} catch {
|
|
28305
28630
|
return null;
|
|
28306
28631
|
}
|
|
@@ -28414,7 +28739,7 @@ var resolveInitProvider = (cwd) => {
|
|
|
28414
28739
|
return env.toLowerCase();
|
|
28415
28740
|
const root = cwd ?? process.env.WORKIT_WORKSPACE_ROOT ?? process.cwd();
|
|
28416
28741
|
try {
|
|
28417
|
-
const out =
|
|
28742
|
+
const out = spawnSync25("git", ["remote", "get-url", "origin"], {
|
|
28418
28743
|
cwd: root,
|
|
28419
28744
|
encoding: "utf8"
|
|
28420
28745
|
});
|
|
@@ -28779,13 +29104,13 @@ var workerCoordinatorFor = (task, worker) => {
|
|
|
28779
29104
|
};
|
|
28780
29105
|
|
|
28781
29106
|
// packages/workit-core/src/fanout.ts
|
|
28782
|
-
import { spawnSync as
|
|
29107
|
+
import { spawnSync as spawnSync29 } from "node:child_process";
|
|
28783
29108
|
import { createHash as createHash19 } from "node:crypto";
|
|
28784
29109
|
import fs32 from "node:fs";
|
|
28785
29110
|
import path52 from "node:path";
|
|
28786
29111
|
|
|
28787
29112
|
// packages/workit-core/src/fanout-landed.ts
|
|
28788
|
-
import { spawnSync as
|
|
29113
|
+
import { spawnSync as spawnSync26 } from "node:child_process";
|
|
28789
29114
|
function trunkRefresher(cwd, trunk) {
|
|
28790
29115
|
const match = /^refs\/remotes\/([^/]+)\/(.+)$/u.exec(trunk);
|
|
28791
29116
|
if (!match)
|
|
@@ -28874,7 +29199,7 @@ function trunkPatchIds(ctx, fork) {
|
|
|
28874
29199
|
"--"
|
|
28875
29200
|
]);
|
|
28876
29201
|
if (log.ok && log.stdout.trim()) {
|
|
28877
|
-
const run =
|
|
29202
|
+
const run = spawnSync26("git", ["patch-id", "--stable"], {
|
|
28878
29203
|
cwd: ctx.cwd,
|
|
28879
29204
|
input: log.stdout,
|
|
28880
29205
|
encoding: "utf8",
|
|
@@ -29009,18 +29334,18 @@ var GRANT_TTL_MS2 = 2 * 3600000;
|
|
|
29009
29334
|
var NOTICE_TTL_MS = 7 * 86400000;
|
|
29010
29335
|
|
|
29011
29336
|
// packages/workit-core/src/stack.ts
|
|
29012
|
-
import { spawnSync as
|
|
29337
|
+
import { spawnSync as spawnSync28 } from "node:child_process";
|
|
29013
29338
|
import { createHash as createHash18, randomBytes as randomBytes4 } from "node:crypto";
|
|
29014
29339
|
import fs31 from "node:fs";
|
|
29015
29340
|
import path51 from "node:path";
|
|
29016
29341
|
|
|
29017
29342
|
// packages/workit-core/src/git/ops.ts
|
|
29018
|
-
import { spawnSync as
|
|
29019
|
-
import { copyFileSync as copyFileSync2, existsSync as existsSync16, readdirSync as
|
|
29343
|
+
import { spawnSync as spawnSync27 } from "node:child_process";
|
|
29344
|
+
import { copyFileSync as copyFileSync2, existsSync as existsSync16, readdirSync as readdirSync7, readFileSync as readFileSync15, rmSync as rmSync4 } from "node:fs";
|
|
29020
29345
|
import path50 from "node:path";
|
|
29021
29346
|
var COMMIT_TIMEOUT_MS = 10 * 60000;
|
|
29022
29347
|
var git5 = (cwd, args, options = {}) => {
|
|
29023
|
-
const result =
|
|
29348
|
+
const result = spawnSync27("git", args, {
|
|
29024
29349
|
cwd,
|
|
29025
29350
|
encoding: "utf8",
|
|
29026
29351
|
env: { ...options.env ?? process.env, GIT_TERMINAL_PROMPT: "0" },
|
|
@@ -29061,7 +29386,7 @@ function operationInProgress(cwd) {
|
|
|
29061
29386
|
if (index === 0 && existsSync16(path50.join(marker, "amend")) && !conflicted()) {
|
|
29062
29387
|
let headName = "";
|
|
29063
29388
|
try {
|
|
29064
|
-
headName =
|
|
29389
|
+
headName = readFileSync15(path50.join(marker, "head-name"), "utf8").trim();
|
|
29065
29390
|
} catch {}
|
|
29066
29391
|
const branch = headName.startsWith("refs/heads/") ? headName.slice("refs/heads/".length) : null;
|
|
29067
29392
|
return { operation, commitAllowed: branch !== null, branch };
|
|
@@ -29127,7 +29452,7 @@ var stackDeps = {
|
|
|
29127
29452
|
rebaseTimeoutMs: Number(process.env.WORKIT_STACK_REBASE_TIMEOUT_MS) || 10 * 60000
|
|
29128
29453
|
};
|
|
29129
29454
|
var gitRun4 = (cwd, args, timeoutMs = GIT_TIMEOUTS.local) => {
|
|
29130
|
-
const run =
|
|
29455
|
+
const run = spawnSync28("git", args, {
|
|
29131
29456
|
cwd,
|
|
29132
29457
|
encoding: "utf8",
|
|
29133
29458
|
timeout: timeoutMs,
|
|
@@ -29358,7 +29683,7 @@ function findCycle(slices) {
|
|
|
29358
29683
|
return null;
|
|
29359
29684
|
}
|
|
29360
29685
|
var gitRun3 = (cwd, args, timeoutMs = GIT_TIMEOUTS.local) => {
|
|
29361
|
-
const run =
|
|
29686
|
+
const run = spawnSync29("git", args, {
|
|
29362
29687
|
cwd,
|
|
29363
29688
|
encoding: "utf8",
|
|
29364
29689
|
timeout: timeoutMs,
|
|
@@ -30687,7 +31012,7 @@ var createStopControl = (root, port) => {
|
|
|
30687
31012
|
};
|
|
30688
31013
|
|
|
30689
31014
|
// packages/workit-opencode/src/v2/registry.ts
|
|
30690
|
-
import { existsSync as existsSync18, readFileSync as
|
|
31015
|
+
import { existsSync as existsSync18, readFileSync as readFileSync16 } from "node:fs";
|
|
30691
31016
|
import path55 from "node:path";
|
|
30692
31017
|
|
|
30693
31018
|
// packages/workit-opencode/src/shared/assets.ts
|
|
@@ -30758,7 +31083,7 @@ var registerSkills = async (ctx) => {
|
|
|
30758
31083
|
for (const [id, file] of packaged) {
|
|
30759
31084
|
if (existing.has(id))
|
|
30760
31085
|
continue;
|
|
30761
|
-
const parsed = parseFrontmatter(
|
|
31086
|
+
const parsed = parseFrontmatter(readFileSync16(file, "utf8"));
|
|
30762
31087
|
editor.add({
|
|
30763
31088
|
id,
|
|
30764
31089
|
name: parsed.name || id,
|
|
@@ -30796,13 +31121,13 @@ var registerCommands = async (ctx, registeredSkills) => {
|
|
|
30796
31121
|
};
|
|
30797
31122
|
|
|
30798
31123
|
// packages/workit-opencode/src/stale-sources.ts
|
|
30799
|
-
import { existsSync as existsSync19, readdirSync as
|
|
31124
|
+
import { existsSync as existsSync19, readdirSync as readdirSync8 } from "node:fs";
|
|
30800
31125
|
import path56 from "node:path";
|
|
30801
31126
|
import { fileURLToPath as fileURLToPath3 } from "node:url";
|
|
30802
31127
|
var typescriptFiles = (directory) => {
|
|
30803
31128
|
if (!existsSync19(directory))
|
|
30804
31129
|
return [];
|
|
30805
|
-
return
|
|
31130
|
+
return readdirSync8(directory, { withFileTypes: true }).flatMap((entry) => {
|
|
30806
31131
|
const file = path56.join(directory, entry.name);
|
|
30807
31132
|
return entry.isDirectory() ? typescriptFiles(file) : entry.isFile() && file.endsWith(".ts") ? [file] : [];
|
|
30808
31133
|
});
|