@workit-dev/opencode 2.25.6 → 2.26.0
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 +143 -141
- package/package.json +2 -2
package/dist/plugin.js
CHANGED
|
@@ -32107,7 +32107,7 @@ var PROCESS_START = performance.timeOrigin;
|
|
|
32107
32107
|
// packages/workit-core/src/hooks/run.ts
|
|
32108
32108
|
if (false) {}
|
|
32109
32109
|
// packages/workit-opencode/src/shared/init-apply.ts
|
|
32110
|
-
import
|
|
32110
|
+
import path54 from "node:path";
|
|
32111
32111
|
|
|
32112
32112
|
// packages/workit-core/src/core/gitignore.ts
|
|
32113
32113
|
import { existsSync as existsSync18, readFileSync as readFileSync13, writeFileSync as writeFileSync6 } from "node:fs";
|
|
@@ -32158,26 +32158,131 @@ var ensureProjectGitignore = (workspaceRoot, confirmed) => {
|
|
|
32158
32158
|
};
|
|
32159
32159
|
|
|
32160
32160
|
// packages/workit-core/src/core/hygiene.ts
|
|
32161
|
-
import { existsSync as
|
|
32161
|
+
import { existsSync as existsSync20, readFileSync as readFileSync15, readdirSync as readdirSync7, writeFileSync as writeFileSync8 } from "node:fs";
|
|
32162
|
+
import path51 from "node:path";
|
|
32163
|
+
|
|
32164
|
+
// packages/workit-core/src/git/ops.ts
|
|
32165
|
+
import { spawnSync as spawnSync25 } from "node:child_process";
|
|
32166
|
+
import {
|
|
32167
|
+
copyFileSync as copyFileSync3,
|
|
32168
|
+
existsSync as existsSync19,
|
|
32169
|
+
mkdirSync as mkdirSync6,
|
|
32170
|
+
readdirSync as readdirSync6,
|
|
32171
|
+
readFileSync as readFileSync14,
|
|
32172
|
+
rmSync as rmSync3,
|
|
32173
|
+
writeFileSync as writeFileSync7
|
|
32174
|
+
} from "node:fs";
|
|
32162
32175
|
import path50 from "node:path";
|
|
32176
|
+
var COMMIT_TIMEOUT_MS = 10 * 60000;
|
|
32177
|
+
var git5 = (cwd, args, options = {}) => {
|
|
32178
|
+
const result = spawnSync25("git", args, {
|
|
32179
|
+
cwd,
|
|
32180
|
+
encoding: "utf8",
|
|
32181
|
+
env: { ...options.env ?? process.env, GIT_TERMINAL_PROMPT: "0" },
|
|
32182
|
+
maxBuffer: 64 * 1024 * 1024,
|
|
32183
|
+
timeout: options.timeoutMs ?? GIT_TIMEOUTS.local,
|
|
32184
|
+
killSignal: "SIGKILL",
|
|
32185
|
+
windowsHide: true,
|
|
32186
|
+
...options.input === undefined ? { stdio: ["ignore", "pipe", "pipe"] } : { input: options.input, stdio: ["pipe", "pipe", "pipe"] }
|
|
32187
|
+
});
|
|
32188
|
+
return {
|
|
32189
|
+
ok: result.status === 0,
|
|
32190
|
+
status: result.status,
|
|
32191
|
+
stdout: result.stdout ?? "",
|
|
32192
|
+
stderr: result.stderr ?? "",
|
|
32193
|
+
signal: result.signal
|
|
32194
|
+
};
|
|
32195
|
+
};
|
|
32196
|
+
function operationInProgress(cwd) {
|
|
32197
|
+
const markers = [
|
|
32198
|
+
["rebase-merge", "rebase"],
|
|
32199
|
+
["rebase-apply", "rebase"],
|
|
32200
|
+
["MERGE_HEAD", "merge"],
|
|
32201
|
+
["CHERRY_PICK_HEAD", "cherry-pick"],
|
|
32202
|
+
["REVERT_HEAD", "revert"]
|
|
32203
|
+
];
|
|
32204
|
+
const run = git5(cwd, ["rev-parse", ...markers.flatMap(([name]) => ["--git-path", name])]);
|
|
32205
|
+
if (!run.ok)
|
|
32206
|
+
return null;
|
|
32207
|
+
const found = run.stdout.split(`
|
|
32208
|
+
`).map((line) => path50.resolve(cwd, line.trim()));
|
|
32209
|
+
const conflicted = () => git5(cwd, ["ls-files", "-u"]).stdout.trim() !== "";
|
|
32210
|
+
for (const [index, [, operation]] of markers.entries()) {
|
|
32211
|
+
const marker = found[index];
|
|
32212
|
+
if (!marker || !existsSync19(marker))
|
|
32213
|
+
continue;
|
|
32214
|
+
if (index === 1 && existsSync19(path50.join(marker, "applying")))
|
|
32215
|
+
return { operation: "am", commitAllowed: false, branch: null };
|
|
32216
|
+
if (index === 0 && existsSync19(path50.join(marker, "amend")) && !conflicted()) {
|
|
32217
|
+
let headName = "";
|
|
32218
|
+
try {
|
|
32219
|
+
headName = readFileSync14(path50.join(marker, "head-name"), "utf8").trim();
|
|
32220
|
+
} catch {}
|
|
32221
|
+
const branch = headName.startsWith("refs/heads/") ? headName.slice("refs/heads/".length) : null;
|
|
32222
|
+
return { operation, commitAllowed: branch !== null, branch };
|
|
32223
|
+
}
|
|
32224
|
+
if ((operation === "revert" || operation === "merge") && !conflicted())
|
|
32225
|
+
return { operation, commitAllowed: true, branch: null };
|
|
32226
|
+
return { operation, commitAllowed: false, branch: null };
|
|
32227
|
+
}
|
|
32228
|
+
return null;
|
|
32229
|
+
}
|
|
32230
|
+
function inProgressFailure(operation, verb) {
|
|
32231
|
+
const command = operation === "am" ? "git am" : `git ${operation}`;
|
|
32232
|
+
return failure3("blocked", `${operation.replace("-", "_")}_in_progress: a ${operation === "am" ? "git am" : operation} is in progress; finish or abort it before workit can ${verb}`, `resolve the conflicts, git add <files>, then ${command} --continue # or ${command} --abort to return to where you started`);
|
|
32233
|
+
}
|
|
32234
|
+
var PRIVATE_INDEX_TTL_MS = 60 * 60000;
|
|
32235
|
+
function pushPreflight(cwd, options = {}) {
|
|
32236
|
+
const progress = operationInProgress(cwd);
|
|
32237
|
+
if (progress)
|
|
32238
|
+
return inProgressFailure(progress.operation, "push");
|
|
32239
|
+
const branch = options.branch ?? currentBranch(cwd);
|
|
32240
|
+
if (!branch)
|
|
32241
|
+
return failure3("invalid_input", "HEAD is detached; push a branch");
|
|
32242
|
+
if (isProtectedTarget(cwd, branch))
|
|
32243
|
+
return failure3("blocked", `protected_branch: ${branch} is protected by the workspace branch policy; workit git push never pushes to it`, releaseBranch(cwd, branch) ? `workit git push --release ${branch} # finishing a release or hotfix; needs the release grant` : "workit git branch <feature/name> # push a feature branch and open a PR");
|
|
32244
|
+
const sha = resolveRef(cwd, `refs/heads/${branch}`);
|
|
32245
|
+
if (!sha)
|
|
32246
|
+
return failure3("not_found", `branch ${branch} has no commit to push`);
|
|
32247
|
+
const remote = pushRemoteName(cwd, branch);
|
|
32248
|
+
if (!remote)
|
|
32249
|
+
return failure3("not_found", "no push remote is configured for this branch", "git remote add origin <url>");
|
|
32250
|
+
const raw = pushUrl(cwd, remote);
|
|
32251
|
+
if (!raw)
|
|
32252
|
+
return failure3("blocked", `remote "${remote}" has no single push URL`, `git remote get-url --push --all ${remote} # keep exactly one push URL`);
|
|
32253
|
+
const parsed = parseRemoteUrl(raw);
|
|
32254
|
+
const local = parsed?.protocol === "file";
|
|
32255
|
+
if (!local && !pushTargetIsStable(cwd, raw))
|
|
32256
|
+
return failure3("blocked", `push_target_rewritten: the push URL of "${remote}" is rewritten by a url.*.insteadOf rule, so the destination is not the one checked`, "git config --get-regexp '^url\\.' # remove the rewrite for this remote");
|
|
32257
|
+
return success2({
|
|
32258
|
+
branch,
|
|
32259
|
+
sha,
|
|
32260
|
+
remote,
|
|
32261
|
+
url: redactRemote(raw),
|
|
32262
|
+
rawUrl: raw,
|
|
32263
|
+
local
|
|
32264
|
+
});
|
|
32265
|
+
}
|
|
32266
|
+
|
|
32267
|
+
// packages/workit-core/src/core/hygiene.ts
|
|
32163
32268
|
var repoRoot3 = assetRoot();
|
|
32164
|
-
var templatesDir = () =>
|
|
32269
|
+
var templatesDir = () => path51.join(repoRoot3, "templates", "hygiene");
|
|
32165
32270
|
var packageJson2 = (root) => {
|
|
32166
|
-
if (!
|
|
32271
|
+
if (!existsSync20(path51.join(root, "package.json")))
|
|
32167
32272
|
return null;
|
|
32168
32273
|
try {
|
|
32169
|
-
return JSON.parse(
|
|
32274
|
+
return JSON.parse(readFileSync15(path51.join(root, "package.json"), "utf8"));
|
|
32170
32275
|
} catch {
|
|
32171
32276
|
return null;
|
|
32172
32277
|
}
|
|
32173
32278
|
};
|
|
32174
32279
|
var isOpenSource = (root) => {
|
|
32175
|
-
if (
|
|
32280
|
+
if (existsSync20(path51.join(root, "LICENSE")))
|
|
32176
32281
|
return true;
|
|
32177
32282
|
const pkg = packageJson2(root);
|
|
32178
32283
|
if (pkg && !pkg.private)
|
|
32179
32284
|
return true;
|
|
32180
|
-
return
|
|
32285
|
+
return path51.basename(root) === "workit";
|
|
32181
32286
|
};
|
|
32182
32287
|
var licenseHolder = (root) => {
|
|
32183
32288
|
const pkg = packageJson2(root);
|
|
@@ -32200,13 +32305,13 @@ var planHygieneFiles = (root, opts = {}) => {
|
|
|
32200
32305
|
files.push("LICENSE", "CONTRIBUTING.md");
|
|
32201
32306
|
const planned = [];
|
|
32202
32307
|
for (const file of files) {
|
|
32203
|
-
if (
|
|
32308
|
+
if (existsSync20(path51.join(root, file)))
|
|
32204
32309
|
continue;
|
|
32205
|
-
const tpl =
|
|
32206
|
-
if (!
|
|
32310
|
+
const tpl = path51.join(templatesDir(), file);
|
|
32311
|
+
if (!existsSync20(tpl))
|
|
32207
32312
|
continue;
|
|
32208
|
-
const content =
|
|
32209
|
-
planned.push({ path:
|
|
32313
|
+
const content = readFileSync15(tpl, "utf8").replace(/<PROJECT>/g, path51.basename(root)).replace(/<YEAR>/g, String(new Date().getFullYear())).replace(/<HOLDER>\s*/g, licenseHolder(root));
|
|
32314
|
+
planned.push({ path: path51.join(root, file), content });
|
|
32210
32315
|
}
|
|
32211
32316
|
return planned;
|
|
32212
32317
|
};
|
|
@@ -32215,31 +32320,31 @@ var ensureHygieneFiles = (root, opts) => {
|
|
|
32215
32320
|
return { ok: false, error: "confirmed: true required" };
|
|
32216
32321
|
const created = [];
|
|
32217
32322
|
for (const planned of planHygieneFiles(root, opts)) {
|
|
32218
|
-
|
|
32219
|
-
created.push(
|
|
32323
|
+
writeFileSync8(planned.path, planned.content, "utf8");
|
|
32324
|
+
created.push(path51.basename(planned.path));
|
|
32220
32325
|
}
|
|
32221
32326
|
return { ok: true, created };
|
|
32222
32327
|
};
|
|
32223
32328
|
|
|
32224
32329
|
// packages/workit-core/src/core/init.ts
|
|
32225
32330
|
import fs33 from "node:fs";
|
|
32226
|
-
import
|
|
32227
|
-
import { spawnSync as
|
|
32331
|
+
import path53 from "node:path";
|
|
32332
|
+
import { spawnSync as spawnSync26 } from "node:child_process";
|
|
32228
32333
|
|
|
32229
32334
|
// packages/workit-core/src/core/workspace-branch-policy.ts
|
|
32230
|
-
import { mkdirSync as
|
|
32231
|
-
import
|
|
32335
|
+
import { mkdirSync as mkdirSync7, readFileSync as readFileSync16, renameSync as renameSync5, rmSync as rmSync4, writeFileSync as writeFileSync9 } from "node:fs";
|
|
32336
|
+
import path52 from "node:path";
|
|
32232
32337
|
import { isDeepStrictEqual } from "node:util";
|
|
32233
32338
|
var readFileSafe = (p) => {
|
|
32234
32339
|
try {
|
|
32235
|
-
return
|
|
32340
|
+
return readFileSync16(p, "utf8");
|
|
32236
32341
|
} catch {
|
|
32237
32342
|
return null;
|
|
32238
32343
|
}
|
|
32239
32344
|
};
|
|
32240
32345
|
function applyWorkspaceBranchPolicy(opts) {
|
|
32241
32346
|
const { workspace_root, env = process.env } = opts;
|
|
32242
|
-
const dir =
|
|
32347
|
+
const dir = path52.join(env.WORKIT_CONFIG ?? configDir2());
|
|
32243
32348
|
const {
|
|
32244
32349
|
status,
|
|
32245
32350
|
path: wsPath,
|
|
@@ -32251,7 +32356,7 @@ function applyWorkspaceBranchPolicy(opts) {
|
|
|
32251
32356
|
if (status === "malformed" || status === "invalid")
|
|
32252
32357
|
return { ok: false, error: workspacesError ?? `invalid workspaces.json: ${wsPath}` };
|
|
32253
32358
|
const detection = detectBranchPolicy(workspace_root);
|
|
32254
|
-
const name = String(env.WORKIT_BP_NAME ??
|
|
32359
|
+
const name = String(env.WORKIT_BP_NAME ?? path52.basename(workspace_root));
|
|
32255
32360
|
const integration = env.WORKIT_BP_INTEGRATION ?? detection.integration;
|
|
32256
32361
|
const policy = {
|
|
32257
32362
|
preset: detection.preset,
|
|
@@ -32300,13 +32405,13 @@ function applyWorkspaceBranchPolicy(opts) {
|
|
|
32300
32405
|
ok: false,
|
|
32301
32406
|
error: `workspaces.json changed while applying the branch policy: ${wsPath}`
|
|
32302
32407
|
};
|
|
32303
|
-
|
|
32408
|
+
mkdirSync7(path52.dirname(wsPath), { recursive: true });
|
|
32304
32409
|
const tmp = `${wsPath}.${process.pid}.tmp`;
|
|
32305
32410
|
try {
|
|
32306
|
-
|
|
32411
|
+
writeFileSync9(tmp, JSON.stringify({ ...document, workspaces: next }, null, 2) + `
|
|
32307
32412
|
`, "utf8");
|
|
32308
32413
|
if (workspacesRevision(readFileSafe(wsPath)) !== revision) {
|
|
32309
|
-
|
|
32414
|
+
rmSync4(tmp, { force: true });
|
|
32310
32415
|
return {
|
|
32311
32416
|
ok: false,
|
|
32312
32417
|
error: `workspaces.json changed while applying the branch policy: ${wsPath}`
|
|
@@ -32315,7 +32420,7 @@ function applyWorkspaceBranchPolicy(opts) {
|
|
|
32315
32420
|
renameSync5(tmp, wsPath);
|
|
32316
32421
|
} catch (error) {
|
|
32317
32422
|
try {
|
|
32318
|
-
|
|
32423
|
+
rmSync4(tmp, { force: true });
|
|
32319
32424
|
} catch {}
|
|
32320
32425
|
return {
|
|
32321
32426
|
ok: false,
|
|
@@ -32346,7 +32451,7 @@ var resolveInitProvider = (cwd) => {
|
|
|
32346
32451
|
return env.toLowerCase();
|
|
32347
32452
|
const root = cwd ?? process.env.WORKIT_WORKSPACE_ROOT ?? process.cwd();
|
|
32348
32453
|
try {
|
|
32349
|
-
const out =
|
|
32454
|
+
const out = spawnSync26("git", ["remote", "get-url", "origin"], {
|
|
32350
32455
|
cwd: root,
|
|
32351
32456
|
encoding: "utf8"
|
|
32352
32457
|
});
|
|
@@ -32400,7 +32505,7 @@ function initApplyData(action, env = process.env) {
|
|
|
32400
32505
|
fs33.mkdirSync(dir, { recursive: true });
|
|
32401
32506
|
switch (action) {
|
|
32402
32507
|
case "youtrack_json": {
|
|
32403
|
-
const out =
|
|
32508
|
+
const out = path53.join(dir, "youtrack.json");
|
|
32404
32509
|
fs33.writeFileSync(out, JSON.stringify(youtrackJsonContent(), null, 2) + `
|
|
32405
32510
|
`, "utf8");
|
|
32406
32511
|
return { action, ok: true, path: out };
|
|
@@ -32414,10 +32519,10 @@ function initApplyData(action, env = process.env) {
|
|
|
32414
32519
|
};
|
|
32415
32520
|
}
|
|
32416
32521
|
case "youtrack_scaffold": {
|
|
32417
|
-
const jsonOut =
|
|
32522
|
+
const jsonOut = path53.join(dir, "youtrack.json");
|
|
32418
32523
|
fs33.writeFileSync(jsonOut, JSON.stringify(youtrackJsonContent(), null, 2) + `
|
|
32419
32524
|
`, "utf8");
|
|
32420
|
-
const configPath =
|
|
32525
|
+
const configPath = path53.resolve(jsonOut);
|
|
32421
32526
|
const cfg = readJson3(configPath) ?? {};
|
|
32422
32527
|
const base = String(cfg.baseUrl ?? "").replace(/\/+$/, "");
|
|
32423
32528
|
const meeting = String(cfg.meetingIssue ?? "");
|
|
@@ -32453,10 +32558,10 @@ function initApplyData(action, env = process.env) {
|
|
|
32453
32558
|
};
|
|
32454
32559
|
}
|
|
32455
32560
|
case "vcs_scaffold": {
|
|
32456
|
-
const jsonOut =
|
|
32561
|
+
const jsonOut = path53.join(dir, "vcs.json");
|
|
32457
32562
|
fs33.writeFileSync(jsonOut, JSON.stringify(vcsJsonContent(), null, 2) + `
|
|
32458
32563
|
`, "utf8");
|
|
32459
|
-
const configPath =
|
|
32564
|
+
const configPath = path53.resolve(jsonOut);
|
|
32460
32565
|
const prev = process.env.WORKIT_VCS_CONFIG;
|
|
32461
32566
|
process.env.WORKIT_VCS_CONFIG = configPath;
|
|
32462
32567
|
try {
|
|
@@ -32575,7 +32680,7 @@ var executeInitApply = (args, directory, runtime) => {
|
|
|
32575
32680
|
protectedNames: args.branch_policy_protected
|
|
32576
32681
|
}, current);
|
|
32577
32682
|
writeConfig(next);
|
|
32578
|
-
return output(ok({ action: "config", path:
|
|
32683
|
+
return output(ok({ action: "config", path: path54.join(configDir2(), "config.json"), ...next }));
|
|
32579
32684
|
}
|
|
32580
32685
|
const env = Object.fromEntries(Object.entries({
|
|
32581
32686
|
WORKIT_YT_BASE_URL: args.base_url,
|
|
@@ -32592,14 +32697,14 @@ var executeInitApply = (args, directory, runtime) => {
|
|
|
32592
32697
|
|
|
32593
32698
|
// packages/workit-opencode/src/shared/session.ts
|
|
32594
32699
|
import { realpathSync as realpathSync12 } from "node:fs";
|
|
32595
|
-
import
|
|
32700
|
+
import path55 from "node:path";
|
|
32596
32701
|
var sameWorkspace = (expected, observed) => {
|
|
32597
32702
|
if (typeof observed !== "string" || !observed)
|
|
32598
32703
|
return false;
|
|
32599
32704
|
try {
|
|
32600
32705
|
return realpathSync12(expected) === realpathSync12(observed);
|
|
32601
32706
|
} catch {
|
|
32602
|
-
return
|
|
32707
|
+
return path55.resolve(expected) === path55.resolve(observed);
|
|
32603
32708
|
}
|
|
32604
32709
|
};
|
|
32605
32710
|
|
|
@@ -32671,7 +32776,7 @@ var workitFamilyOf = (toolName) => {
|
|
|
32671
32776
|
|
|
32672
32777
|
// packages/workit-opencode/src/tools/context.ts
|
|
32673
32778
|
import { realpathSync as realpathSync13 } from "node:fs";
|
|
32674
|
-
import
|
|
32779
|
+
import path56 from "node:path";
|
|
32675
32780
|
var createContextTool = () => ({
|
|
32676
32781
|
description: "Read Git, pull request, YouTrack, issue, changelog, release, or affected-file context.",
|
|
32677
32782
|
execute: async (args, context) => {
|
|
@@ -32681,7 +32786,7 @@ var createContextTool = () => ({
|
|
|
32681
32786
|
let root;
|
|
32682
32787
|
try {
|
|
32683
32788
|
const cwd = parsed.data.cwd;
|
|
32684
|
-
root = realpathSync13(cwd ?
|
|
32789
|
+
root = realpathSync13(cwd ? path56.resolve(context.directory, cwd) : context.directory);
|
|
32685
32790
|
} catch {
|
|
32686
32791
|
return JSON.stringify(failure2("invalid_input", "context target directory cannot be resolved"), null, 2);
|
|
32687
32792
|
}
|
|
@@ -32717,7 +32822,7 @@ import fs35 from "node:fs";
|
|
|
32717
32822
|
import path58 from "node:path";
|
|
32718
32823
|
|
|
32719
32824
|
// packages/workit-core/src/fanout-landed.ts
|
|
32720
|
-
import { spawnSync as
|
|
32825
|
+
import { spawnSync as spawnSync27 } from "node:child_process";
|
|
32721
32826
|
function trunkRefresher(cwd, trunk) {
|
|
32722
32827
|
const match = /^refs\/remotes\/([^/]+)\/(.+)$/u.exec(trunk);
|
|
32723
32828
|
if (!match)
|
|
@@ -32806,7 +32911,7 @@ function trunkPatchIds(ctx, fork) {
|
|
|
32806
32911
|
"--"
|
|
32807
32912
|
]);
|
|
32808
32913
|
if (log.ok && log.stdout.trim()) {
|
|
32809
|
-
const run =
|
|
32914
|
+
const run = spawnSync27("git", ["patch-id", "--stable"], {
|
|
32810
32915
|
cwd: ctx.cwd,
|
|
32811
32916
|
input: log.stdout,
|
|
32812
32917
|
encoding: "utf8",
|
|
@@ -32950,109 +33055,6 @@ import { createHash as createHash20, randomBytes as randomBytes4 } from "node:cr
|
|
|
32950
33055
|
import fs34 from "node:fs";
|
|
32951
33056
|
import path57 from "node:path";
|
|
32952
33057
|
|
|
32953
|
-
// packages/workit-core/src/git/ops.ts
|
|
32954
|
-
import { spawnSync as spawnSync27 } from "node:child_process";
|
|
32955
|
-
import {
|
|
32956
|
-
copyFileSync as copyFileSync3,
|
|
32957
|
-
existsSync as existsSync20,
|
|
32958
|
-
mkdirSync as mkdirSync7,
|
|
32959
|
-
readdirSync as readdirSync7,
|
|
32960
|
-
readFileSync as readFileSync16,
|
|
32961
|
-
rmSync as rmSync4,
|
|
32962
|
-
writeFileSync as writeFileSync9
|
|
32963
|
-
} from "node:fs";
|
|
32964
|
-
import path56 from "node:path";
|
|
32965
|
-
var COMMIT_TIMEOUT_MS = 10 * 60000;
|
|
32966
|
-
var git5 = (cwd, args, options = {}) => {
|
|
32967
|
-
const result = spawnSync27("git", args, {
|
|
32968
|
-
cwd,
|
|
32969
|
-
encoding: "utf8",
|
|
32970
|
-
env: { ...options.env ?? process.env, GIT_TERMINAL_PROMPT: "0" },
|
|
32971
|
-
maxBuffer: 64 * 1024 * 1024,
|
|
32972
|
-
timeout: options.timeoutMs ?? GIT_TIMEOUTS.local,
|
|
32973
|
-
killSignal: "SIGKILL",
|
|
32974
|
-
windowsHide: true,
|
|
32975
|
-
...options.input === undefined ? { stdio: ["ignore", "pipe", "pipe"] } : { input: options.input, stdio: ["pipe", "pipe", "pipe"] }
|
|
32976
|
-
});
|
|
32977
|
-
return {
|
|
32978
|
-
ok: result.status === 0,
|
|
32979
|
-
status: result.status,
|
|
32980
|
-
stdout: result.stdout ?? "",
|
|
32981
|
-
stderr: result.stderr ?? "",
|
|
32982
|
-
signal: result.signal
|
|
32983
|
-
};
|
|
32984
|
-
};
|
|
32985
|
-
function operationInProgress(cwd) {
|
|
32986
|
-
const markers = [
|
|
32987
|
-
["rebase-merge", "rebase"],
|
|
32988
|
-
["rebase-apply", "rebase"],
|
|
32989
|
-
["MERGE_HEAD", "merge"],
|
|
32990
|
-
["CHERRY_PICK_HEAD", "cherry-pick"],
|
|
32991
|
-
["REVERT_HEAD", "revert"]
|
|
32992
|
-
];
|
|
32993
|
-
const run = git5(cwd, ["rev-parse", ...markers.flatMap(([name]) => ["--git-path", name])]);
|
|
32994
|
-
if (!run.ok)
|
|
32995
|
-
return null;
|
|
32996
|
-
const found = run.stdout.split(`
|
|
32997
|
-
`).map((line) => path56.resolve(cwd, line.trim()));
|
|
32998
|
-
const conflicted = () => git5(cwd, ["ls-files", "-u"]).stdout.trim() !== "";
|
|
32999
|
-
for (const [index, [, operation]] of markers.entries()) {
|
|
33000
|
-
const marker = found[index];
|
|
33001
|
-
if (!marker || !existsSync20(marker))
|
|
33002
|
-
continue;
|
|
33003
|
-
if (index === 1 && existsSync20(path56.join(marker, "applying")))
|
|
33004
|
-
return { operation: "am", commitAllowed: false, branch: null };
|
|
33005
|
-
if (index === 0 && existsSync20(path56.join(marker, "amend")) && !conflicted()) {
|
|
33006
|
-
let headName = "";
|
|
33007
|
-
try {
|
|
33008
|
-
headName = readFileSync16(path56.join(marker, "head-name"), "utf8").trim();
|
|
33009
|
-
} catch {}
|
|
33010
|
-
const branch = headName.startsWith("refs/heads/") ? headName.slice("refs/heads/".length) : null;
|
|
33011
|
-
return { operation, commitAllowed: branch !== null, branch };
|
|
33012
|
-
}
|
|
33013
|
-
if ((operation === "revert" || operation === "merge") && !conflicted())
|
|
33014
|
-
return { operation, commitAllowed: true, branch: null };
|
|
33015
|
-
return { operation, commitAllowed: false, branch: null };
|
|
33016
|
-
}
|
|
33017
|
-
return null;
|
|
33018
|
-
}
|
|
33019
|
-
function inProgressFailure(operation, verb) {
|
|
33020
|
-
const command = operation === "am" ? "git am" : `git ${operation}`;
|
|
33021
|
-
return failure3("blocked", `${operation.replace("-", "_")}_in_progress: a ${operation === "am" ? "git am" : operation} is in progress; finish or abort it before workit can ${verb}`, `resolve the conflicts, git add <files>, then ${command} --continue # or ${command} --abort to return to where you started`);
|
|
33022
|
-
}
|
|
33023
|
-
var PRIVATE_INDEX_TTL_MS = 60 * 60000;
|
|
33024
|
-
function pushPreflight(cwd, options = {}) {
|
|
33025
|
-
const progress = operationInProgress(cwd);
|
|
33026
|
-
if (progress)
|
|
33027
|
-
return inProgressFailure(progress.operation, "push");
|
|
33028
|
-
const branch = options.branch ?? currentBranch(cwd);
|
|
33029
|
-
if (!branch)
|
|
33030
|
-
return failure3("invalid_input", "HEAD is detached; push a branch");
|
|
33031
|
-
if (isProtectedTarget(cwd, branch))
|
|
33032
|
-
return failure3("blocked", `protected_branch: ${branch} is protected by the workspace branch policy; workit git push never pushes to it`, releaseBranch(cwd, branch) ? `workit git push --release ${branch} # finishing a release or hotfix; needs the release grant` : "workit git branch <feature/name> # push a feature branch and open a PR");
|
|
33033
|
-
const sha = resolveRef(cwd, `refs/heads/${branch}`);
|
|
33034
|
-
if (!sha)
|
|
33035
|
-
return failure3("not_found", `branch ${branch} has no commit to push`);
|
|
33036
|
-
const remote = pushRemoteName(cwd, branch);
|
|
33037
|
-
if (!remote)
|
|
33038
|
-
return failure3("not_found", "no push remote is configured for this branch", "git remote add origin <url>");
|
|
33039
|
-
const raw = pushUrl(cwd, remote);
|
|
33040
|
-
if (!raw)
|
|
33041
|
-
return failure3("blocked", `remote "${remote}" has no single push URL`, `git remote get-url --push --all ${remote} # keep exactly one push URL`);
|
|
33042
|
-
const parsed = parseRemoteUrl(raw);
|
|
33043
|
-
const local = parsed?.protocol === "file";
|
|
33044
|
-
if (!local && !pushTargetIsStable(cwd, raw))
|
|
33045
|
-
return failure3("blocked", `push_target_rewritten: the push URL of "${remote}" is rewritten by a url.*.insteadOf rule, so the destination is not the one checked`, "git config --get-regexp '^url\\.' # remove the rewrite for this remote");
|
|
33046
|
-
return success2({
|
|
33047
|
-
branch,
|
|
33048
|
-
sha,
|
|
33049
|
-
remote,
|
|
33050
|
-
url: redactRemote(raw),
|
|
33051
|
-
rawUrl: raw,
|
|
33052
|
-
local
|
|
33053
|
-
});
|
|
33054
|
-
}
|
|
33055
|
-
|
|
33056
33058
|
// packages/workit-core/src/forge/report.ts
|
|
33057
33059
|
var GITLAB_MERGEABLE = new Set(["mergeable"]);
|
|
33058
33060
|
var GITHUB_MERGEABLE = new Set(["clean", "unstable", "has_hooks"]);
|
package/package.json
CHANGED
|
@@ -1,6 +1,6 @@
|
|
|
1
1
|
{
|
|
2
2
|
"name": "@workit-dev/opencode",
|
|
3
|
-
"version": "2.
|
|
3
|
+
"version": "2.26.0",
|
|
4
4
|
"private": false,
|
|
5
5
|
"description": "Workit OpenCode plugin — native tools, adaptive policy, and sixteen method skills",
|
|
6
6
|
"keywords": [
|
|
@@ -41,7 +41,7 @@
|
|
|
41
41
|
},
|
|
42
42
|
"devDependencies": {
|
|
43
43
|
"@opencode/plugin": "2.3.2",
|
|
44
|
-
"@workit-dev/core": "^2.
|
|
44
|
+
"@workit-dev/core": "^2.26.0"
|
|
45
45
|
},
|
|
46
46
|
"engines": {
|
|
47
47
|
"node": ">=24"
|