@exla/rudder 0.0.0-stage → 3.4.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/LICENSE +100 -0
- package/README.md +733 -2
- package/assets/rudder.icns +0 -0
- package/assets/sounds/NOTICE.md +8 -0
- package/assets/sounds/ping.mp3 +0 -0
- package/dist/agent-attention.d.ts +5 -0
- package/dist/agent-attention.js +54 -0
- package/dist/agent-attention.js.map +1 -0
- package/dist/analytics.d.ts +36 -0
- package/dist/analytics.js +178 -0
- package/dist/analytics.js.map +1 -0
- package/dist/attach-session.d.ts +91 -0
- package/dist/attach-session.js +290 -0
- package/dist/attach-session.js.map +1 -0
- package/dist/auth.d.ts +36 -0
- package/dist/auth.js +392 -0
- package/dist/auth.js.map +1 -0
- package/dist/backends.d.ts +3 -0
- package/dist/backends.js +638 -0
- package/dist/backends.js.map +1 -0
- package/dist/board/board.css +1 -0
- package/dist/board/board.js +2 -0
- package/dist/board/daemon.d.ts +39 -0
- package/dist/board/daemon.js +1510 -0
- package/dist/board/daemon.js.map +1 -0
- package/dist/brain.d.ts +24 -0
- package/dist/brain.js +244 -0
- package/dist/brain.js.map +1 -0
- package/dist/bus.d.ts +9 -0
- package/dist/bus.js +23 -0
- package/dist/bus.js.map +1 -0
- package/dist/checkout-sync.d.ts +35 -0
- package/dist/checkout-sync.js +247 -0
- package/dist/checkout-sync.js.map +1 -0
- package/dist/cloud.d.ts +48 -0
- package/dist/cloud.js +4596 -0
- package/dist/cloud.js.map +1 -0
- package/dist/codex-binary.d.ts +12 -0
- package/dist/codex-binary.js +184 -0
- package/dist/codex-binary.js.map +1 -0
- package/dist/context-audit.d.ts +21 -0
- package/dist/context-audit.js +109 -0
- package/dist/context-audit.js.map +1 -0
- package/dist/daemon.d.ts +27 -0
- package/dist/daemon.js +203 -0
- package/dist/daemon.js.map +1 -0
- package/dist/effort.d.ts +9 -0
- package/dist/effort.js +72 -0
- package/dist/effort.js.map +1 -0
- package/dist/feedback.d.ts +46 -0
- package/dist/feedback.js +173 -0
- package/dist/feedback.js.map +1 -0
- package/dist/gc.d.ts +3 -0
- package/dist/gc.js +262 -0
- package/dist/gc.js.map +1 -0
- package/dist/git.d.ts +31 -0
- package/dist/git.js +455 -0
- package/dist/git.js.map +1 -0
- package/dist/goal.d.ts +33 -0
- package/dist/goal.js +95 -0
- package/dist/goal.js.map +1 -0
- package/dist/graph.d.ts +93 -0
- package/dist/graph.js +372 -0
- package/dist/graph.js.map +1 -0
- package/dist/handoff.d.ts +110 -0
- package/dist/handoff.js +565 -0
- package/dist/handoff.js.map +1 -0
- package/dist/improve/advisor.d.ts +10 -0
- package/dist/improve/advisor.js +115 -0
- package/dist/improve/advisor.js.map +1 -0
- package/dist/improve/collect.d.ts +49 -0
- package/dist/improve/collect.js +274 -0
- package/dist/improve/collect.js.map +1 -0
- package/dist/improve/gate.d.ts +17 -0
- package/dist/improve/gate.js +60 -0
- package/dist/improve/gate.js.map +1 -0
- package/dist/improve/index.d.ts +9 -0
- package/dist/improve/index.js +376 -0
- package/dist/improve/index.js.map +1 -0
- package/dist/improve/judge.d.ts +32 -0
- package/dist/improve/judge.js +114 -0
- package/dist/improve/judge.js.map +1 -0
- package/dist/improve/mine.d.ts +31 -0
- package/dist/improve/mine.js +192 -0
- package/dist/improve/mine.js.map +1 -0
- package/dist/improve/propose.d.ts +51 -0
- package/dist/improve/propose.js +150 -0
- package/dist/improve/propose.js.map +1 -0
- package/dist/improve/rank.d.ts +16 -0
- package/dist/improve/rank.js +49 -0
- package/dist/improve/rank.js.map +1 -0
- package/dist/improve/schedule.d.ts +1 -0
- package/dist/improve/schedule.js +95 -0
- package/dist/improve/schedule.js.map +1 -0
- package/dist/improve/ship.d.ts +25 -0
- package/dist/improve/ship.js +82 -0
- package/dist/improve/ship.js.map +1 -0
- package/dist/improve/state.d.ts +157 -0
- package/dist/improve/state.js +264 -0
- package/dist/improve/state.js.map +1 -0
- package/dist/index.d.ts +2 -0
- package/dist/index.js +88 -0
- package/dist/index.js.map +1 -0
- package/dist/jj-binary.d.ts +36 -0
- package/dist/jj-binary.js +143 -0
- package/dist/jj-binary.js.map +1 -0
- package/dist/jj.d.ts +163 -0
- package/dist/jj.js +926 -0
- package/dist/jj.js.map +1 -0
- package/dist/logger.d.ts +22 -0
- package/dist/logger.js +110 -0
- package/dist/logger.js.map +1 -0
- package/dist/main.d.ts +3 -0
- package/dist/main.js +1366 -0
- package/dist/main.js.map +1 -0
- package/dist/migration.d.ts +82 -0
- package/dist/migration.js +198 -0
- package/dist/migration.js.map +1 -0
- package/dist/models.d.ts +9 -0
- package/dist/models.js +623 -0
- package/dist/models.js.map +1 -0
- package/dist/move-home.d.ts +82 -0
- package/dist/move-home.js +472 -0
- package/dist/move-home.js.map +1 -0
- package/dist/native/darwin-arm64/rudder-native +0 -0
- package/dist/native/darwin-x64/rudder-native +0 -0
- package/dist/native/linux-x64/rudder-native +0 -0
- package/dist/native-agents.d.ts +8 -0
- package/dist/native-agents.js +178 -0
- package/dist/native-agents.js.map +1 -0
- package/dist/native-binary.d.ts +4 -0
- package/dist/native-binary.js +140 -0
- package/dist/native-binary.js.map +1 -0
- package/dist/paste-bridge.d.ts +36 -0
- package/dist/paste-bridge.js +279 -0
- package/dist/paste-bridge.js.map +1 -0
- package/dist/plan-mode.d.ts +2 -0
- package/dist/plan-mode.js +22 -0
- package/dist/plan-mode.js.map +1 -0
- package/dist/planner.d.ts +27 -0
- package/dist/planner.js +587 -0
- package/dist/planner.js.map +1 -0
- package/dist/predict.d.ts +67 -0
- package/dist/predict.js +369 -0
- package/dist/predict.js.map +1 -0
- package/dist/report.d.ts +74 -0
- package/dist/report.js +412 -0
- package/dist/report.js.map +1 -0
- package/dist/rudder-md.d.ts +33 -0
- package/dist/rudder-md.js +142 -0
- package/dist/rudder-md.js.map +1 -0
- package/dist/run-manager.d.ts +62 -0
- package/dist/run-manager.js +1400 -0
- package/dist/run-manager.js.map +1 -0
- package/dist/scheduler.d.ts +128 -0
- package/dist/scheduler.js +955 -0
- package/dist/scheduler.js.map +1 -0
- package/dist/state.d.ts +127 -0
- package/dist/state.js +704 -0
- package/dist/state.js.map +1 -0
- package/dist/surfaces.d.ts +91 -0
- package/dist/surfaces.js +460 -0
- package/dist/surfaces.js.map +1 -0
- package/dist/task-summary.d.ts +30 -0
- package/dist/task-summary.js +472 -0
- package/dist/task-summary.js.map +1 -0
- package/dist/types.d.ts +492 -0
- package/dist/types.js +2 -0
- package/dist/types.js.map +1 -0
- package/dist/usage.d.ts +198 -0
- package/dist/usage.js +830 -0
- package/dist/usage.js.map +1 -0
- package/dist/util.d.ts +73 -0
- package/dist/util.js +399 -0
- package/dist/util.js.map +1 -0
- package/dist/version-check.d.ts +16 -0
- package/dist/version-check.js +269 -0
- package/dist/version-check.js.map +1 -0
- package/package.json +68 -4
- package/scripts/copy-native.mjs +89 -0
- package/scripts/postinstall.mjs +34 -0
|
@@ -0,0 +1,143 @@
|
|
|
1
|
+
import { spawnSync } from "node:child_process";
|
|
2
|
+
import { createHash, randomUUID } from "node:crypto";
|
|
3
|
+
import fs from "node:fs";
|
|
4
|
+
import fsp from "node:fs/promises";
|
|
5
|
+
import path from "node:path";
|
|
6
|
+
import { commandExists, ensureDir, rudderHome } from "./util.js";
|
|
7
|
+
// jj (Jujutsu) is Rudder's workspace engine, and nobody should have to install
|
|
8
|
+
// it as a separate step. When `jj` is not on PATH, Rudder fetches jj's own
|
|
9
|
+
// prebuilt release for this platform (checksum-pinned below) into
|
|
10
|
+
// ~/.rudder/bin/jj/<version>/ and puts that directory on PATH for itself and
|
|
11
|
+
// everything it starts: the native dashboard, workers and agents all inherit
|
|
12
|
+
// it. A jj the user installed (brew, cargo, a distro package) always wins.
|
|
13
|
+
//
|
|
14
|
+
// Not newer on purpose: from 0.46 `jj workspace add` needs git >= 2.42
|
|
15
|
+
// (`git worktree add --orphan`), and stock macOS and Debian 12 ship git 2.39,
|
|
16
|
+
// so every isolated agent would fail to start on exactly the machines that have
|
|
17
|
+
// nothing installed. 0.40.0 is also what the cloud worker image runs.
|
|
18
|
+
export const MANAGED_JJ_VERSION = "0.40.0";
|
|
19
|
+
// sha256 of each release archive, from github.com/jj-vcs/jj/releases/tag/v0.40.0.
|
|
20
|
+
export const MANAGED_JJ_ASSETS = {
|
|
21
|
+
"darwin-arm64": { target: "aarch64-apple-darwin", sha256: "8a1d713103bb968c771617c9b2c48b0b5982193090ee74dec935bff710af2082" },
|
|
22
|
+
"darwin-x64": { target: "x86_64-apple-darwin", sha256: "ce62cf26e3c6c72a295f5917056e33cfa972874f882a2d15b5a3687b3ddce1e5" },
|
|
23
|
+
"linux-x64": { target: "x86_64-unknown-linux-musl", sha256: "5c8979f46873e052f59bdd9535636dca6e6f9f70571b73f6d63c3b92acfaa037" },
|
|
24
|
+
"linux-arm64": { target: "aarch64-unknown-linux-musl", sha256: "b26f24ff7a34838fbafe8788e6a94a9cdcf51601ef8c9af8fab4fa22c06ddbee" },
|
|
25
|
+
};
|
|
26
|
+
const DOWNLOAD_TIMEOUT_MS = 120_000;
|
|
27
|
+
let lastInstallError = null;
|
|
28
|
+
/** Why the last automatic install failed, for the "jj is missing" error. */
|
|
29
|
+
export function managedJjInstallError() {
|
|
30
|
+
return lastInstallError;
|
|
31
|
+
}
|
|
32
|
+
export function managedJjDir(version = MANAGED_JJ_VERSION) {
|
|
33
|
+
return path.join(rudderHome(), "bin", "jj", version);
|
|
34
|
+
}
|
|
35
|
+
export function managedJjPath(version = MANAGED_JJ_VERSION) {
|
|
36
|
+
return path.join(managedJjDir(version), "jj");
|
|
37
|
+
}
|
|
38
|
+
export function managedJjAsset(platform = process.platform, arch = process.arch) {
|
|
39
|
+
const asset = MANAGED_JJ_ASSETS[`${platform}-${arch}`];
|
|
40
|
+
if (!asset)
|
|
41
|
+
return null;
|
|
42
|
+
const tag = `v${MANAGED_JJ_VERSION}`;
|
|
43
|
+
return {
|
|
44
|
+
url: `https://github.com/jj-vcs/jj/releases/download/${tag}/jj-${tag}-${asset.target}.tar.gz`,
|
|
45
|
+
sha256: asset.sha256,
|
|
46
|
+
};
|
|
47
|
+
}
|
|
48
|
+
/** True when the managed jj's directory is already on this process's PATH. */
|
|
49
|
+
export function managedJjOnPath() {
|
|
50
|
+
const dir = managedJjDir();
|
|
51
|
+
return (process.env.PATH ?? "").split(path.delimiter).includes(dir);
|
|
52
|
+
}
|
|
53
|
+
/**
|
|
54
|
+
* Make `jj` resolve for this process and its children. Returns where it comes
|
|
55
|
+
* from, or null when there is none and it could not be installed. Never throws:
|
|
56
|
+
* commands that need jj fail later with MissingToolError, which carries the
|
|
57
|
+
* reason recorded here.
|
|
58
|
+
*/
|
|
59
|
+
export async function ensureJjAvailable(options = {}) {
|
|
60
|
+
if (managedJjOnPath() && isExecutable(managedJjPath()))
|
|
61
|
+
return "managed";
|
|
62
|
+
if (commandExists("jj"))
|
|
63
|
+
return "system";
|
|
64
|
+
if (isExecutable(managedJjPath())) {
|
|
65
|
+
prependPath(managedJjDir());
|
|
66
|
+
return "managed";
|
|
67
|
+
}
|
|
68
|
+
const asset = managedJjAsset();
|
|
69
|
+
if (!asset) {
|
|
70
|
+
lastInstallError = `no prebuilt jj for ${process.platform}/${process.arch}`;
|
|
71
|
+
return null;
|
|
72
|
+
}
|
|
73
|
+
options.onInstall?.(`Setting up jj ${MANAGED_JJ_VERSION}, Rudder's workspace engine (one time, about 10 MB)...`);
|
|
74
|
+
try {
|
|
75
|
+
await installManagedJj({ url: asset.url, sha256: asset.sha256, dest: managedJjPath() });
|
|
76
|
+
}
|
|
77
|
+
catch (error) {
|
|
78
|
+
lastInstallError = error instanceof Error ? error.message : String(error);
|
|
79
|
+
return null;
|
|
80
|
+
}
|
|
81
|
+
lastInstallError = null;
|
|
82
|
+
prependPath(managedJjDir());
|
|
83
|
+
return "managed";
|
|
84
|
+
}
|
|
85
|
+
/**
|
|
86
|
+
* Download a jj release archive, check it against the pinned sha256, unpack the
|
|
87
|
+
* `jj` binary, make sure it runs, then move it into place. Nothing is left at
|
|
88
|
+
* `dest` unless every step passed.
|
|
89
|
+
*/
|
|
90
|
+
export async function installManagedJj(params) {
|
|
91
|
+
const response = await fetch(params.url, {
|
|
92
|
+
redirect: "follow",
|
|
93
|
+
signal: AbortSignal.timeout(params.timeoutMs ?? DOWNLOAD_TIMEOUT_MS),
|
|
94
|
+
});
|
|
95
|
+
if (!response.ok) {
|
|
96
|
+
throw new Error(`could not download jj from ${params.url}: HTTP ${response.status}`);
|
|
97
|
+
}
|
|
98
|
+
const archive = Buffer.from(await response.arrayBuffer());
|
|
99
|
+
const actual = createHash("sha256").update(archive).digest("hex");
|
|
100
|
+
if (actual !== params.sha256) {
|
|
101
|
+
throw new Error(`jj download failed its checksum (expected ${params.sha256}, got ${actual})`);
|
|
102
|
+
}
|
|
103
|
+
const destDir = path.dirname(params.dest);
|
|
104
|
+
await ensureDir(path.dirname(destDir));
|
|
105
|
+
const staging = path.join(path.dirname(destDir), `.install-${process.pid}-${randomUUID().slice(0, 8)}`);
|
|
106
|
+
await ensureDir(staging);
|
|
107
|
+
try {
|
|
108
|
+
const archivePath = path.join(staging, "jj.tar.gz");
|
|
109
|
+
await fsp.writeFile(archivePath, archive);
|
|
110
|
+
const untar = spawnSync("tar", ["-xzf", archivePath, "-C", staging], { encoding: "utf8" });
|
|
111
|
+
if (untar.status !== 0) {
|
|
112
|
+
throw new Error(`could not unpack jj: ${(untar.stderr || untar.error?.message || "tar failed").trim()}`);
|
|
113
|
+
}
|
|
114
|
+
const binary = path.join(staging, "jj");
|
|
115
|
+
if (!fs.existsSync(binary)) {
|
|
116
|
+
throw new Error("the jj archive had no jj binary in it");
|
|
117
|
+
}
|
|
118
|
+
await fsp.chmod(binary, 0o755);
|
|
119
|
+
const probe = spawnSync(binary, ["--version"], { encoding: "utf8" });
|
|
120
|
+
if (probe.status !== 0) {
|
|
121
|
+
throw new Error(`the downloaded jj does not run here: ${(probe.stderr || probe.error?.message || "").trim()}`);
|
|
122
|
+
}
|
|
123
|
+
await ensureDir(destDir);
|
|
124
|
+
await fsp.rename(binary, params.dest);
|
|
125
|
+
}
|
|
126
|
+
finally {
|
|
127
|
+
await fsp.rm(staging, { recursive: true, force: true }).catch(() => undefined);
|
|
128
|
+
}
|
|
129
|
+
}
|
|
130
|
+
function prependPath(dir) {
|
|
131
|
+
const parts = (process.env.PATH ?? "").split(path.delimiter).filter((part) => part && part !== dir);
|
|
132
|
+
process.env.PATH = [dir, ...parts].join(path.delimiter);
|
|
133
|
+
}
|
|
134
|
+
function isExecutable(file) {
|
|
135
|
+
try {
|
|
136
|
+
fs.accessSync(file, fs.constants.X_OK);
|
|
137
|
+
return fs.statSync(file).isFile();
|
|
138
|
+
}
|
|
139
|
+
catch {
|
|
140
|
+
return false;
|
|
141
|
+
}
|
|
142
|
+
}
|
|
143
|
+
//# sourceMappingURL=jj-binary.js.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"jj-binary.js","sourceRoot":"","sources":["../src/jj-binary.ts"],"names":[],"mappings":"AAAA,OAAO,EAAE,SAAS,EAAE,MAAM,oBAAoB,CAAC;AAC/C,OAAO,EAAE,UAAU,EAAE,UAAU,EAAE,MAAM,aAAa,CAAC;AACrD,OAAO,EAAE,MAAM,SAAS,CAAC;AACzB,OAAO,GAAG,MAAM,kBAAkB,CAAC;AACnC,OAAO,IAAI,MAAM,WAAW,CAAC;AAC7B,OAAO,EAAE,aAAa,EAAE,SAAS,EAAE,UAAU,EAAE,MAAM,WAAW,CAAC;AAEjE,+EAA+E;AAC/E,2EAA2E;AAC3E,kEAAkE;AAClE,6EAA6E;AAC7E,6EAA6E;AAC7E,2EAA2E;AAC3E,EAAE;AACF,uEAAuE;AACvE,8EAA8E;AAC9E,gFAAgF;AAChF,sEAAsE;AACtE,MAAM,CAAC,MAAM,kBAAkB,GAAG,QAAQ,CAAC;AAE3C,kFAAkF;AAClF,MAAM,CAAC,MAAM,iBAAiB,GAAuD;IACnF,cAAc,EAAE,EAAE,MAAM,EAAE,sBAA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AAC,CAAC;IACxC,CAAC;YAAS,CAAC;QACT,MAAM,GAAG,CAAC,EAAE,CAAC,OAAO,EAAE,EAAE,SAAS,EAAE,IAAI,EAAE,KAAK,EAAE,IAAI,EAAE,CAAC,CAAC,KAAK,CAAC,GAAG,EAAE,CAAC,SAAS,CAAC,CAAC;IACjF,CAAC;AACH,CAAC;AAED,SAAS,WAAW,CAAC,GAAW;IAC9B,MAAM,KAAK,GAAG,CAAC,OAAO,CAAC,GAAG,CAAC,IAAI,IAAI,EAAE,CAAC,CAAC,KAAK,CAAC,IAAI,CAAC,SAAS,CAAC,CAAC,MAAM,CAAC,CAAC,IAAI,EAAE,EAAE,CAAC,IAAI,IAAI,IAAI,KAAK,GAAG,CAAC,CAAC;IACpG,OAAO,CAAC,GAAG,CAAC,IAAI,GAAG,CAAC,GAAG,EAAE,GAAG,KAAK,CAAC,CAAC,IAAI,CAAC,IAAI,CAAC,SAAS,CAAC,CAAC;AAC1D,CAAC;AAED,SAAS,YAAY,CAAC,IAAY;IAChC,IAAI,CAAC;QACH,EAAE,CAAC,UAAU,CAAC,IAAI,EAAE,EAAE,CAAC,SAAS,CAAC,IAAI,CAAC,CAAC;QACvC,OAAO,EAAE,CAAC,QAAQ,CAAC,IAAI,CAAC,CAAC,MAAM,EAAE,CAAC;IACpC,CAAC;IAAC,MAAM,CAAC;QACP,OAAO,KAAK,CAAC;IACf,CAAC;AACH,CAAC"}
|
package/dist/jj.d.ts
ADDED
|
@@ -0,0 +1,163 @@
|
|
|
1
|
+
import type { RunRecord } from "./types.js";
|
|
2
|
+
export type MergeNodeResult = {
|
|
3
|
+
mergeChangeId: string;
|
|
4
|
+
opId: string;
|
|
5
|
+
conflictedFiles: string[];
|
|
6
|
+
};
|
|
7
|
+
/**
|
|
8
|
+
* Hard requirement: jj must be installed. Throws MissingToolError otherwise.
|
|
9
|
+
*/
|
|
10
|
+
export declare function ensureJj(): void;
|
|
11
|
+
/**
|
|
12
|
+
* Parse `jj --version`. Returns the version string (e.g. "0.40.0") or "".
|
|
13
|
+
* Warns (does not throw) when below MIN_JJ.
|
|
14
|
+
*/
|
|
15
|
+
export declare function jjVersion(): Promise<string>;
|
|
16
|
+
/**
|
|
17
|
+
* Idempotently colocate a jj repo with the git repo at repoRoot. If already a
|
|
18
|
+
* jj repo, no-op. Otherwise runs `jj git init --colocate`.
|
|
19
|
+
*/
|
|
20
|
+
export declare function ensureColocated(repoRoot: string): Promise<void>;
|
|
21
|
+
export declare function isJjRepo(cwd: string): boolean;
|
|
22
|
+
export declare function findJjRoot(cwd: string): string;
|
|
23
|
+
/**
|
|
24
|
+
* The same recovery for a jj command that WRITES.
|
|
25
|
+
*
|
|
26
|
+
* Reads had this and writes did not, which left the main checkout able to wedge
|
|
27
|
+
* every launch in a repo: `jj workspace add` snapshots the workspace it is run
|
|
28
|
+
* FROM, so once a sibling worker's operation left the main checkout stale, every
|
|
29
|
+
* new agent — a typed task, a plan node, a `/resume`, review-all — died on
|
|
30
|
+
* "The working copy is stale" until the user ran `update-stale` by hand. The
|
|
31
|
+
* recovery is exactly what jj's own hint says to do, and it snapshots the
|
|
32
|
+
* working copy rather than discarding it, so nothing on disk is lost.
|
|
33
|
+
*/
|
|
34
|
+
export declare function jjWriteWithStaleRecovery(cwd: string, args: string[]): Promise<{
|
|
35
|
+
stdout: string;
|
|
36
|
+
stderr: string;
|
|
37
|
+
code: number;
|
|
38
|
+
}>;
|
|
39
|
+
/**
|
|
40
|
+
* The change id of `@` (the working-copy commit) in the given workspace.
|
|
41
|
+
*/
|
|
42
|
+
export declare function currentJjChangeId(workspacePath: string): Promise<string>;
|
|
43
|
+
/** The immutable commit id of a workspace's current revision. Prefer this when
|
|
44
|
+
* feeding a finished workspace into a merge: concurrent jj snapshots can make
|
|
45
|
+
* its stable change id divergent, while the workspace's @ commit remains an
|
|
46
|
+
* unambiguous revision. */
|
|
47
|
+
export declare function currentJjCommitId(workspacePath: string): Promise<string>;
|
|
48
|
+
export declare function jjStatus(workspacePath: string): Promise<string[]>;
|
|
49
|
+
export declare function parseJjStatus(stdout: string): string[];
|
|
50
|
+
export declare function jjDiff(workspacePath: string): Promise<string>;
|
|
51
|
+
/**
|
|
52
|
+
* Create a new empty change parented on the given changes. Reads the new change
|
|
53
|
+
* id back by querying a unique marker embedded in the description, never by
|
|
54
|
+
* scraping stdout. Returns the new change id.
|
|
55
|
+
*/
|
|
56
|
+
export declare function createEmptyChange(params: {
|
|
57
|
+
repoRoot: string;
|
|
58
|
+
parents: string[];
|
|
59
|
+
description: string;
|
|
60
|
+
}): Promise<string>;
|
|
61
|
+
export declare function describeChange(repoRoot: string, changeId: string, message: string): Promise<void>;
|
|
62
|
+
/**
|
|
63
|
+
* Create a jj workspace for a node/run. Workspace name matches the original
|
|
64
|
+
* rudder regex `rudder-<id.slice(0,14)>-<shortHash(id).slice(0,6)>`. If
|
|
65
|
+
* `atChangeId` is given, parent the working-copy commit on it; falls back to
|
|
66
|
+
* `jj workspace add` + `jj edit <atChangeId>` if `-r` is unsupported.
|
|
67
|
+
*/
|
|
68
|
+
export declare function createNodeWorkspace(params: {
|
|
69
|
+
repoRoot: string;
|
|
70
|
+
nodeId?: string;
|
|
71
|
+
runId?: string;
|
|
72
|
+
task?: string;
|
|
73
|
+
atChangeId?: string;
|
|
74
|
+
}): Promise<{
|
|
75
|
+
workspaceName: string;
|
|
76
|
+
path: string;
|
|
77
|
+
}>;
|
|
78
|
+
/**
|
|
79
|
+
* Phase-1 entry point used by run-manager. Delegates to createNodeWorkspace.
|
|
80
|
+
*/
|
|
81
|
+
export declare function createRunJjWorkspace(params: {
|
|
82
|
+
repoRoot: string;
|
|
83
|
+
runId: string;
|
|
84
|
+
task: string;
|
|
85
|
+
}): Promise<{
|
|
86
|
+
workspaceName: string;
|
|
87
|
+
path: string;
|
|
88
|
+
}>;
|
|
89
|
+
export declare function workspaceNameFor(id: string): string;
|
|
90
|
+
/**
|
|
91
|
+
* Merge a run's jj change into the current (main) workspace `@`. Captures the
|
|
92
|
+
* operation id before the merge and records it on merge.operationId. On
|
|
93
|
+
* conflict sets merge.status="conflict" + conflictedFiles + mergeChangeId.
|
|
94
|
+
*/
|
|
95
|
+
export declare function mergeJjRunIntoCurrentWorkspace(run: RunRecord, allowDirty?: boolean): Promise<RunRecord>;
|
|
96
|
+
export declare function closestLocalBookmark(repoRoot: string): Promise<string>;
|
|
97
|
+
/**
|
|
98
|
+
* Merge two changes into a new change. Captures the op id (after the merge),
|
|
99
|
+
* returns the new merge change id and any conflicted files. jj merges never
|
|
100
|
+
* fail on conflict; the conflict is recorded in the merge change.
|
|
101
|
+
*/
|
|
102
|
+
export declare function mergeNode(params: {
|
|
103
|
+
repoRoot: string;
|
|
104
|
+
nodeChangeId: string;
|
|
105
|
+
intoChangeId: string;
|
|
106
|
+
message: string;
|
|
107
|
+
}): Promise<MergeNodeResult>;
|
|
108
|
+
export declare function jjConflictedFiles(workspacePath: string): Promise<string[]>;
|
|
109
|
+
/**
|
|
110
|
+
* Alias matching the plan's API name.
|
|
111
|
+
*/
|
|
112
|
+
export declare function listConflicts(workspacePath: string): Promise<string[]>;
|
|
113
|
+
export declare function parseJjConflictedFiles(stdout: string): string[];
|
|
114
|
+
/**
|
|
115
|
+
* The id of the latest operation in the op log. Recovers once from a stale
|
|
116
|
+
* workspace; if the id still cannot be read, warns and returns "" instead of
|
|
117
|
+
* throwing — merges must proceed, they just lose their undo waypoint.
|
|
118
|
+
*/
|
|
119
|
+
export declare function currentOpId(repoRoot: string): Promise<string>;
|
|
120
|
+
/**
|
|
121
|
+
* Restore the repo to an earlier operation. One call rewinds all workspaces and
|
|
122
|
+
* refs atomically (op restore is global).
|
|
123
|
+
*/
|
|
124
|
+
export declare function undoToOp(repoRoot: string, opId: string): Promise<void>;
|
|
125
|
+
export declare function undoLast(repoRoot: string): Promise<void>;
|
|
126
|
+
/**
|
|
127
|
+
* Export jj changes to the colocated git repo. Call after each merge, before
|
|
128
|
+
* opening a diff review, and before a PR.
|
|
129
|
+
*/
|
|
130
|
+
export declare function exportToGit(repoRoot: string): Promise<void>;
|
|
131
|
+
export declare function createBookmark(repoRoot: string, name: string, atChangeId: string): Promise<void>;
|
|
132
|
+
export declare function pushBookmark(repoRoot: string, name: string): Promise<void>;
|
|
133
|
+
/**
|
|
134
|
+
* Forget a jj workspace and remove its directory.
|
|
135
|
+
*/
|
|
136
|
+
export declare function forgetWorkspace(params: {
|
|
137
|
+
repoRoot: string;
|
|
138
|
+
workspaceName: string;
|
|
139
|
+
workspacePath: string;
|
|
140
|
+
}): Promise<void>;
|
|
141
|
+
export declare function removeRunWorkspace(run: RunRecord): Promise<void>;
|
|
142
|
+
/**
|
|
143
|
+
* Rebase a run's node change onto the trunk. jj records conflicts in place and
|
|
144
|
+
* never blocks, so there is no rebase-in-progress dance.
|
|
145
|
+
*/
|
|
146
|
+
export declare function syncRunWorkspace(run: RunRecord, baseBranch: string): Promise<RunRecord>;
|
|
147
|
+
export declare function containsConflictMarkers(content: string): boolean;
|
|
148
|
+
/** The parent revisions of `@`; a merge has two or more. */
|
|
149
|
+
export declare function jjParentRevs(repoRoot: string): Promise<string[]>;
|
|
150
|
+
/** Union of `- ` bullet entries across every side, order-preserving and deduped. */
|
|
151
|
+
export declare function mergeDecisionsSides(sides: string[]): string | undefined;
|
|
152
|
+
/** Deep-union of dependency/script maps; scalar ties keep the earlier side. */
|
|
153
|
+
export declare function mergePackageJsonSides(sides: string[]): string | undefined;
|
|
154
|
+
/**
|
|
155
|
+
* The mechanical resolution for one conflicted path, or undefined to leave it to
|
|
156
|
+
* the LLM resolver. Keyed on file NAME so it works at any depth.
|
|
157
|
+
*/
|
|
158
|
+
export declare function mechanicalMergeFor(fileName: string, sides: string[]): string | undefined;
|
|
159
|
+
/**
|
|
160
|
+
* Resolve every conflict Rudder can settle without judgment, and return what is
|
|
161
|
+
* left. Never writes content that still carries conflict markers.
|
|
162
|
+
*/
|
|
163
|
+
export declare function autoResolveMechanicalConflicts(repoRoot: string): Promise<string[]>;
|