@exla/rudder 5.0.5 → 5.0.10
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/auth.js +9 -0
- package/dist/auth.js.map +1 -1
- package/dist/cloud.js +2 -1
- package/dist/cloud.js.map +1 -1
- package/dist/codex-config.js +3 -0
- package/dist/codex-config.js.map +1 -1
- package/dist/graph.d.ts +2 -1
- package/dist/graph.js +2 -3
- package/dist/graph.js.map +1 -1
- package/dist/jj.d.ts +11 -26
- package/dist/jj.js +26 -53
- package/dist/jj.js.map +1 -1
- package/dist/main.js +31 -24
- package/dist/main.js.map +1 -1
- package/dist/models.d.ts +9 -1
- package/dist/models.js +353 -228
- package/dist/models.js.map +1 -1
- package/dist/native/darwin-arm64/native-manifest.json +3 -3
- package/dist/native/darwin-arm64/rudder-native +0 -0
- package/dist/native/linux-x64/native-manifest.json +5 -5
- package/dist/native/linux-x64/rudder-jj +0 -0
- package/dist/native/linux-x64/rudder-native +0 -0
- package/dist/onboarding.d.ts +10 -0
- package/dist/onboarding.js +29 -0
- package/dist/onboarding.js.map +1 -1
- package/dist/planner.js +8 -79
- package/dist/planner.js.map +1 -1
- package/dist/private-access/home.js +5 -0
- package/dist/private-access/home.js.map +1 -1
- package/dist/project-files/engine.d.ts +22 -3
- package/dist/project-files/engine.js +27 -11
- package/dist/project-files/engine.js.map +1 -1
- package/dist/project-files/notes.d.ts +64 -0
- package/dist/project-files/notes.js +212 -0
- package/dist/project-files/notes.js.map +1 -0
- package/dist/run-manager.js +4 -4
- package/dist/run-manager.js.map +1 -1
- package/dist/scheduler.d.ts +8 -7
- package/dist/scheduler.js +115 -157
- package/dist/scheduler.js.map +1 -1
- package/dist/state.d.ts +5 -0
- package/dist/state.js +11 -1
- package/dist/state.js.map +1 -1
- package/dist/types.d.ts +2 -2
- package/dist/types.js.map +1 -1
- package/dist/util.d.ts +2 -0
- package/dist/util.js +14 -3
- package/dist/util.js.map +1 -1
- package/package.json +2 -1
|
@@ -11,11 +11,10 @@ export function sameFileScope(a, b) {
|
|
|
11
11
|
* The native App only snapshots bindings. Filesystem IO stays in this helper.
|
|
12
12
|
*/
|
|
13
13
|
export async function engineFileGrants(repo, signal, nativeBinary = resolveNativeBinaryPath()) {
|
|
14
|
-
const {
|
|
14
|
+
const { raw, status } = await queryOwnerSurface(repo, "files", signal, nativeBinary);
|
|
15
15
|
const grants = JSON.parse(raw).file_grants;
|
|
16
|
-
if (!
|
|
17
|
-
|
|
18
|
-
throw new ProjectFileError("denied", "Project file authority is unavailable");
|
|
16
|
+
if (!Array.isArray(grants) || grants.length > 16) {
|
|
17
|
+
throw new ProjectFileError("denied", "The project owner sent an invalid file grant list");
|
|
19
18
|
}
|
|
20
19
|
const result = grants.map((item) => {
|
|
21
20
|
const grant = item;
|
|
@@ -29,24 +28,41 @@ export async function engineFileGrants(repo, signal, nativeBinary = resolveNativ
|
|
|
29
28
|
signal.throwIfAborted();
|
|
30
29
|
return result;
|
|
31
30
|
}
|
|
32
|
-
/** Queries only the authenticated native owner
|
|
33
|
-
*
|
|
31
|
+
/** Queries only the authenticated native owner: the Fabric engine or a
|
|
32
|
+
* dashboard (legacy-native), which answer the same control socket. Responses
|
|
33
|
+
* are bounded and the actual canonical checkout must match before
|
|
34
|
+
* caller-specific data is used. */
|
|
34
35
|
export async function queryOwnerSurface(repo, operation, signal, nativeBinary = resolveNativeBinaryPath(), runId) {
|
|
35
36
|
signal.throwIfAborted();
|
|
36
37
|
if (!nativeBinary)
|
|
37
|
-
throw new ProjectFileError("denied", "
|
|
38
|
+
throw new ProjectFileError("denied", "Rudder's native binary is missing from this install");
|
|
38
39
|
const root = await realpath(repo);
|
|
39
40
|
const args = ["engine", operation, "--repo", root, "--json"];
|
|
40
41
|
if (runId !== undefined)
|
|
41
42
|
args.push("--run", runId);
|
|
42
43
|
const raw = await new Promise((resolve, reject) => {
|
|
43
|
-
execFile(nativeBinary, args, { cwd: root, signal, timeout: 3000, maxBuffer: 128 * 1024 }, (error, stdout) => error ? reject(new ProjectFileError("denied",
|
|
44
|
+
execFile(nativeBinary, args, { cwd: root, signal, timeout: 3000, maxBuffer: 128 * 1024 }, (error, stdout, stderr) => error ? reject(new ProjectFileError("denied", ownerFailure(error, stderr))) : resolve(stdout));
|
|
44
45
|
});
|
|
45
46
|
const status = parseEngineStatus(raw);
|
|
46
|
-
if (!status.running
|
|
47
|
-
throw new ProjectFileError("denied", "
|
|
47
|
+
if (!status.running)
|
|
48
|
+
throw new ProjectFileError("denied", "No dashboard or engine owns this project right now");
|
|
49
|
+
if (status.authority === "legacy-ts") {
|
|
50
|
+
throw new ProjectFileError("denied", "This project's owner is an old Rudder scheduler; open the project in a current dashboard");
|
|
51
|
+
}
|
|
52
|
+
if (await realpath(status.repo) !== root)
|
|
53
|
+
throw new ProjectFileError("denied", "The project owner names a different checkout");
|
|
54
|
+
const owner = status.owner;
|
|
55
|
+
if (!owner || typeof owner.project_id !== "string" || !owner.project_id || !Number.isSafeInteger(owner.epoch) || owner.epoch < 1) {
|
|
56
|
+
throw new ProjectFileError("denied", "The project owner did not report its identity");
|
|
48
57
|
}
|
|
49
58
|
signal.throwIfAborted();
|
|
50
|
-
return { root, raw, status };
|
|
59
|
+
return { root, raw, status: { ...status, owner } };
|
|
60
|
+
}
|
|
61
|
+
/** The native owner's own reason, first line only and bounded. */
|
|
62
|
+
function ownerFailure(error, stderr) {
|
|
63
|
+
if (error.killed || error.name === "AbortError")
|
|
64
|
+
return "The project owner did not answer in time";
|
|
65
|
+
const line = stderr.split("\n").map((text) => text.trim()).find(Boolean)?.replace(/^Error:\s*/, "");
|
|
66
|
+
return (line || error.message.split("\n")[0]).slice(0, 300);
|
|
51
67
|
}
|
|
52
68
|
//# sourceMappingURL=engine.js.map
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"engine.js","sourceRoot":"","sources":["../../src/project-files/engine.ts"],"names":[],"mappings":"AAAA,OAAO,EAAE,QAAQ,
|
|
1
|
+
{"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,cAAc,EAAE,CAAC;IACxB,OAAO,EAAE,IAAI,EAAE,GAAG,EAAE,MAAM,EAAE,EAAE,GAAG,MAAM,EAAE,KAAK,EAAE,EAAE,CAAC;AACrD,CAAC;AAED,kEAAkE;AAClE,SAAS,YAAY,CAAC,KAAwB,EAAE,MAAc;IAC5D,IAAI,KAAK,CAAC,MAAM,IAAI,KAAK,CAAC,IAAI,KAAK,YAAY;QAAE,OAAO,0CAA0C,CAAC;IACnG,MAAM,IAAI,GAAG,MAAM,CAAC,KAAK,CAAC,IAAI,CAAC,CAAC,GAAG,CAAC,CAAC,IAAI,EAAE,EAAE,CAAC,IAAI,CAAC,IAAI,EAAE,CAAC,CAAC,IAAI,CAAC,OAAO,CAAC,EAAE,OAAO,CAAC,YAAY,EAAE,EAAE,CAAC,CAAC;IACpG,OAAO,CAAC,IAAI,IAAI,KAAK,CAAC,OAAO,CAAC,KAAK,CAAC,IAAI,CAAC,CAAC,CAAC,CAAC,CAAC,CAAC,KAAK,CAAC,CAAC,EAAE,GAAG,CAAC,CAAC;AAC9D,CAAC"}
|
|
@@ -0,0 +1,64 @@
|
|
|
1
|
+
/** The user's notes for a project: RUDDER_NOTES.md at the root of the
|
|
2
|
+
* checkout on the home. Only the user writes it, from the app's Notes editor.
|
|
3
|
+
* Agents are not told about it and nothing else in Rudder writes it.
|
|
4
|
+
*
|
|
5
|
+
* Reads and saves go through ProjectFileService, narrowed to this one file:
|
|
6
|
+
* a symlink or anything but a regular file is refused, and a save is swapped
|
|
7
|
+
* in by rename only while the file still holds the revision the editor loaded,
|
|
8
|
+
* so two devices never overwrite each other silently. A missing file reads as
|
|
9
|
+
* empty; the first save creates it.
|
|
10
|
+
*
|
|
11
|
+
* Git: a new notes file is kept out of Git by a line in the repository's
|
|
12
|
+
* local exclude (.git/info/exclude), never the tracked .gitignore. The line
|
|
13
|
+
* goes in before the file exists, so no jj snapshot in between picks it up;
|
|
14
|
+
* jj honours that file for untracked paths. "Keep out of Git" off removes the
|
|
15
|
+
* line, and the file shows up to commit like any other (jj tracks it at its
|
|
16
|
+
* next snapshot). Back on, the line returns and a file that is not committed
|
|
17
|
+
* yet is untracked again: an ignore rule alone never untracks a path jj
|
|
18
|
+
* already tracks. A committed file, or one the repository's own ignore rules
|
|
19
|
+
* cover, is reported as it is and left alone.
|
|
20
|
+
*/
|
|
21
|
+
export declare const NOTES_FILE = "RUDDER_NOTES.md";
|
|
22
|
+
/** excluded: our exclude line keeps it out. included: it shows up in the
|
|
23
|
+
* repository like any other file. committed: it is in HEAD. ignored: the
|
|
24
|
+
* repository's own ignore rules (`by`) cover it. */
|
|
25
|
+
export type NotesGit = {
|
|
26
|
+
state: "excluded" | "included" | "committed";
|
|
27
|
+
} | {
|
|
28
|
+
state: "ignored";
|
|
29
|
+
by: string;
|
|
30
|
+
};
|
|
31
|
+
export type ProjectNotes = {
|
|
32
|
+
text: string;
|
|
33
|
+
revision: string | null;
|
|
34
|
+
git: NotesGit;
|
|
35
|
+
};
|
|
36
|
+
export type NotesRequest = {
|
|
37
|
+
version: 1;
|
|
38
|
+
operation: "read";
|
|
39
|
+
} | {
|
|
40
|
+
version: 1;
|
|
41
|
+
operation: "write";
|
|
42
|
+
baseRevision: string | null;
|
|
43
|
+
text: string;
|
|
44
|
+
} | {
|
|
45
|
+
version: 1;
|
|
46
|
+
operation: "git";
|
|
47
|
+
keepOut: boolean;
|
|
48
|
+
};
|
|
49
|
+
/** `git` comes back when the save created the file. A conflict carries what is on disk now. */
|
|
50
|
+
export type NotesSaved = {
|
|
51
|
+
outcome: "saved";
|
|
52
|
+
revision: string;
|
|
53
|
+
git?: NotesGit;
|
|
54
|
+
} | ({
|
|
55
|
+
outcome: "conflict";
|
|
56
|
+
} & ProjectNotes);
|
|
57
|
+
export type NotesReply = ProjectNotes | NotesSaved | {
|
|
58
|
+
git: NotesGit;
|
|
59
|
+
};
|
|
60
|
+
/** The one entry point of the home RPC, for a project directory the home chose. */
|
|
61
|
+
export declare function projectNotes(dir: string, request: NotesRequest): Promise<NotesReply>;
|
|
62
|
+
/** Where RUDDER_NOTES.md stands. In a colocated jj repository Git's index
|
|
63
|
+
* follows jj's working copy (files jj tracks in @ are intent-to-add there). */
|
|
64
|
+
export declare function gitState(root: string): Promise<NotesGit>;
|
|
@@ -0,0 +1,212 @@
|
|
|
1
|
+
import { constants } from "node:fs";
|
|
2
|
+
import { appendFile, lstat, mkdir, open, readFile, realpath, writeFile } from "node:fs/promises";
|
|
3
|
+
import { createHash } from "node:crypto";
|
|
4
|
+
import { homedir } from "node:os";
|
|
5
|
+
import path from "node:path";
|
|
6
|
+
import { runCommand } from "../util.js";
|
|
7
|
+
import { FILE_LIMITS, ProjectFileError, ProjectFileService } from "./service.js";
|
|
8
|
+
/** The user's notes for a project: RUDDER_NOTES.md at the root of the
|
|
9
|
+
* checkout on the home. Only the user writes it, from the app's Notes editor.
|
|
10
|
+
* Agents are not told about it and nothing else in Rudder writes it.
|
|
11
|
+
*
|
|
12
|
+
* Reads and saves go through ProjectFileService, narrowed to this one file:
|
|
13
|
+
* a symlink or anything but a regular file is refused, and a save is swapped
|
|
14
|
+
* in by rename only while the file still holds the revision the editor loaded,
|
|
15
|
+
* so two devices never overwrite each other silently. A missing file reads as
|
|
16
|
+
* empty; the first save creates it.
|
|
17
|
+
*
|
|
18
|
+
* Git: a new notes file is kept out of Git by a line in the repository's
|
|
19
|
+
* local exclude (.git/info/exclude), never the tracked .gitignore. The line
|
|
20
|
+
* goes in before the file exists, so no jj snapshot in between picks it up;
|
|
21
|
+
* jj honours that file for untracked paths. "Keep out of Git" off removes the
|
|
22
|
+
* line, and the file shows up to commit like any other (jj tracks it at its
|
|
23
|
+
* next snapshot). Back on, the line returns and a file that is not committed
|
|
24
|
+
* yet is untracked again: an ignore rule alone never untracks a path jj
|
|
25
|
+
* already tracks. A committed file, or one the repository's own ignore rules
|
|
26
|
+
* cover, is reported as it is and left alone.
|
|
27
|
+
*/
|
|
28
|
+
export const NOTES_FILE = "RUDDER_NOTES.md";
|
|
29
|
+
const EXCLUDE_LINE = `/${NOTES_FILE}`;
|
|
30
|
+
const SCOPE = { projectId: "notes", workspaceId: "notes", attemptId: "notes", ownerEpoch: 0 };
|
|
31
|
+
const REVISION = /^[a-f0-9]{64}$/;
|
|
32
|
+
const CONTROL = /[\x00-\x08\x0b\x0c\x0e-\x1f]/;
|
|
33
|
+
/** The one entry point of the home RPC, for a project directory the home chose. */
|
|
34
|
+
export async function projectNotes(dir, request) {
|
|
35
|
+
if (request?.version !== 1)
|
|
36
|
+
throw new ProjectFileError("invalid", "Unsupported notes request");
|
|
37
|
+
const root = await realpath(dir);
|
|
38
|
+
switch (request.operation) {
|
|
39
|
+
case "read": return readNotes(root);
|
|
40
|
+
case "write": {
|
|
41
|
+
const { baseRevision, text } = request;
|
|
42
|
+
if (!(baseRevision === null || (typeof baseRevision === "string" && REVISION.test(baseRevision))) || typeof text !== "string") {
|
|
43
|
+
throw new ProjectFileError("invalid", "Invalid notes save");
|
|
44
|
+
}
|
|
45
|
+
if (Buffer.byteLength(text) > FILE_LIMITS.writeBytes)
|
|
46
|
+
throw new ProjectFileError("large", "Notes over 1 MiB cannot be saved here");
|
|
47
|
+
if (CONTROL.test(text))
|
|
48
|
+
throw new ProjectFileError("invalid", "The text contains control characters");
|
|
49
|
+
return baseRevision === null ? createNotes(root, text) : saveNotes(root, baseRevision, text);
|
|
50
|
+
}
|
|
51
|
+
case "git":
|
|
52
|
+
if (typeof request.keepOut !== "boolean")
|
|
53
|
+
throw new ProjectFileError("invalid", "Invalid notes request");
|
|
54
|
+
return { git: await keepOutOfGit(root, request.keepOut) };
|
|
55
|
+
default: throw new ProjectFileError("invalid", "Unsupported notes request");
|
|
56
|
+
}
|
|
57
|
+
}
|
|
58
|
+
const files = (root) => new ProjectFileService(async () => ({ scope: SCOPE, root, access: { kind: "host" }, only: NOTES_FILE }));
|
|
59
|
+
const missing = (error) => error instanceof ProjectFileError && error.code === "missing";
|
|
60
|
+
async function readNotes(root) {
|
|
61
|
+
const git = await gitState(root);
|
|
62
|
+
let doc;
|
|
63
|
+
try {
|
|
64
|
+
doc = await files(root).dispatch({ version: 1, operation: "read", scope: SCOPE, path: NOTES_FILE });
|
|
65
|
+
}
|
|
66
|
+
catch (error) {
|
|
67
|
+
if (missing(error))
|
|
68
|
+
return { text: "", revision: null, git };
|
|
69
|
+
throw error;
|
|
70
|
+
}
|
|
71
|
+
if (typeof doc.text !== "string")
|
|
72
|
+
throw new ProjectFileError("unsupported", `${NOTES_FILE} is not UTF-8 text`);
|
|
73
|
+
return { text: doc.text, revision: doc.revision, git };
|
|
74
|
+
}
|
|
75
|
+
async function saveNotes(root, baseRevision, text) {
|
|
76
|
+
let result;
|
|
77
|
+
try {
|
|
78
|
+
result = await files(root).dispatch({ version: 1, operation: "write", scope: SCOPE, path: NOTES_FILE, baseRevision, text });
|
|
79
|
+
}
|
|
80
|
+
catch (error) {
|
|
81
|
+
if (missing(error))
|
|
82
|
+
return { outcome: "conflict", ...(await readNotes(root)) };
|
|
83
|
+
throw error;
|
|
84
|
+
}
|
|
85
|
+
if ("outcome" in result && result.outcome === "saved")
|
|
86
|
+
return { outcome: "saved", revision: result.revision };
|
|
87
|
+
return { outcome: "conflict", ...(await readNotes(root)) };
|
|
88
|
+
}
|
|
89
|
+
/** The first save. Out of Git by default: the exclude line is written before
|
|
90
|
+
* the file exists. Another device creating it first is a conflict. */
|
|
91
|
+
async function createNotes(root, text) {
|
|
92
|
+
if ((await gitState(root)).state === "included")
|
|
93
|
+
await setExcludeLine(root, true);
|
|
94
|
+
let file;
|
|
95
|
+
try {
|
|
96
|
+
file = await open(path.join(root, NOTES_FILE), constants.O_WRONLY | constants.O_CREAT | constants.O_EXCL | constants.O_NOFOLLOW, 0o644);
|
|
97
|
+
}
|
|
98
|
+
catch (error) {
|
|
99
|
+
if (error.code === "EEXIST")
|
|
100
|
+
return { outcome: "conflict", ...(await readNotes(root)) };
|
|
101
|
+
throw error;
|
|
102
|
+
}
|
|
103
|
+
try {
|
|
104
|
+
await file.writeFile(text);
|
|
105
|
+
await file.sync();
|
|
106
|
+
}
|
|
107
|
+
finally {
|
|
108
|
+
await file.close();
|
|
109
|
+
}
|
|
110
|
+
return { outcome: "saved", revision: createHash("sha256").update(text).digest("hex"), git: await gitState(root) };
|
|
111
|
+
}
|
|
112
|
+
async function keepOutOfGit(root, keepOut) {
|
|
113
|
+
const now = await gitState(root);
|
|
114
|
+
if (now.state === "committed")
|
|
115
|
+
throw new ProjectFileError("invalid", `${NOTES_FILE} is committed in this repository, so Git keeps it either way`);
|
|
116
|
+
if (now.state === "ignored")
|
|
117
|
+
throw new ProjectFileError("invalid", `${now.by} already ignores ${NOTES_FILE}. Change it there.`);
|
|
118
|
+
await setExcludeLine(root, keepOut);
|
|
119
|
+
if (keepOut && now.state === "included")
|
|
120
|
+
await untrack(root);
|
|
121
|
+
return gitState(root);
|
|
122
|
+
}
|
|
123
|
+
const git = (root, args) => runCommand("git", args, { cwd: root, allowFailure: true });
|
|
124
|
+
async function gitOut(root, args) {
|
|
125
|
+
const result = await git(root, args);
|
|
126
|
+
if (result.code !== 0)
|
|
127
|
+
throw new Error(`git ${args[0]} failed in ${root}: ${result.stderr.trim()}`);
|
|
128
|
+
return result.stdout;
|
|
129
|
+
}
|
|
130
|
+
/** The repository's local exclude file. Every home project is a Git repository. */
|
|
131
|
+
async function excludeFile(root) {
|
|
132
|
+
return path.resolve(root, (await gitOut(root, ["rev-parse", "--git-path", "info/exclude"])).trim());
|
|
133
|
+
}
|
|
134
|
+
/** Where RUDDER_NOTES.md stands. In a colocated jj repository Git's index
|
|
135
|
+
* follows jj's working copy (files jj tracks in @ are intent-to-add there). */
|
|
136
|
+
export async function gitState(root) {
|
|
137
|
+
const exclude = await excludeFile(root);
|
|
138
|
+
const head = await git(root, ["rev-parse", "-q", "--verify", "HEAD^{commit}"]);
|
|
139
|
+
if (head.code === 0 && (await gitOut(root, ["ls-tree", "--name-only", "HEAD", "--", NOTES_FILE])).trim())
|
|
140
|
+
return { state: "committed" };
|
|
141
|
+
// Tracked but not committed yet: staged in Git, or tracked by jj in @.
|
|
142
|
+
if ((await gitOut(root, ["ls-files", "--", NOTES_FILE])).trim())
|
|
143
|
+
return { state: "included" };
|
|
144
|
+
const rule = await git(root, ["check-ignore", "-v", "--no-index", "--", NOTES_FILE]);
|
|
145
|
+
if (rule.code === 1)
|
|
146
|
+
return { state: "included" };
|
|
147
|
+
if (rule.code !== 0)
|
|
148
|
+
throw new Error(`git check-ignore failed in ${root}: ${rule.stderr.trim()}`);
|
|
149
|
+
// "<source>:<line>:<pattern>\t<path>". A negated pattern means not ignored.
|
|
150
|
+
const match = /^(.+?):(\d+):(.*)\t/.exec(rule.stdout);
|
|
151
|
+
if (!match)
|
|
152
|
+
throw new Error(`git check-ignore printed an unexpected line in ${root}: ${rule.stdout.trim()}`);
|
|
153
|
+
const [, source, , pattern] = match;
|
|
154
|
+
if (pattern.startsWith("!"))
|
|
155
|
+
return { state: "included" };
|
|
156
|
+
if (path.resolve(root, source) === exclude && pattern === EXCLUDE_LINE)
|
|
157
|
+
return { state: "excluded" };
|
|
158
|
+
return { state: "ignored", by: shownSource(root, source) };
|
|
159
|
+
}
|
|
160
|
+
function shownSource(root, source) {
|
|
161
|
+
if (source.startsWith("~"))
|
|
162
|
+
return source;
|
|
163
|
+
const at = path.resolve(root, source);
|
|
164
|
+
if (at.startsWith(`${root}/`))
|
|
165
|
+
return path.relative(root, at);
|
|
166
|
+
const home = homedir();
|
|
167
|
+
return at.startsWith(`${home}/`) ? `~/${path.relative(home, at)}` : at;
|
|
168
|
+
}
|
|
169
|
+
async function setExcludeLine(root, present) {
|
|
170
|
+
const file = await excludeFile(root);
|
|
171
|
+
let text = "";
|
|
172
|
+
try {
|
|
173
|
+
text = await readFile(file, "utf8");
|
|
174
|
+
}
|
|
175
|
+
catch (error) {
|
|
176
|
+
if (error.code !== "ENOENT")
|
|
177
|
+
throw error;
|
|
178
|
+
}
|
|
179
|
+
const lines = text.split("\n");
|
|
180
|
+
if (lines.some((line) => line.trim() === EXCLUDE_LINE) === present)
|
|
181
|
+
return;
|
|
182
|
+
if (present) {
|
|
183
|
+
await mkdir(path.dirname(file), { recursive: true });
|
|
184
|
+
await appendFile(file, `${text && !text.endsWith("\n") ? "\n" : ""}${EXCLUDE_LINE}\n`);
|
|
185
|
+
}
|
|
186
|
+
else {
|
|
187
|
+
await writeFile(file, lines.filter((line) => line.trim() !== EXCLUDE_LINE).join("\n"));
|
|
188
|
+
}
|
|
189
|
+
}
|
|
190
|
+
/** A notes file that is not committed but still tracked: jj tracks it in @
|
|
191
|
+
* once a snapshot saw it, and only `jj file untrack` lets go (it needs the
|
|
192
|
+
* exclude line in place first). Without jj, Git's index holds it only when
|
|
193
|
+
* someone staged it. */
|
|
194
|
+
async function untrack(root) {
|
|
195
|
+
let jj = false;
|
|
196
|
+
try {
|
|
197
|
+
jj = (await lstat(path.join(root, ".jj"))).isDirectory();
|
|
198
|
+
}
|
|
199
|
+
catch (error) {
|
|
200
|
+
if (error.code !== "ENOENT")
|
|
201
|
+
throw error;
|
|
202
|
+
}
|
|
203
|
+
if (jj) {
|
|
204
|
+
const tracked = await runCommand("jj", ["file", "list", "--ignore-working-copy", "-r", "@", "--", NOTES_FILE], { cwd: root });
|
|
205
|
+
if (tracked.stdout.trim())
|
|
206
|
+
await runCommand("jj", ["file", "untrack", "--", NOTES_FILE], { cwd: root });
|
|
207
|
+
return;
|
|
208
|
+
}
|
|
209
|
+
if ((await gitOut(root, ["ls-files", "--", NOTES_FILE])).trim())
|
|
210
|
+
await gitOut(root, ["rm", "--cached", "-q", "--", NOTES_FILE]);
|
|
211
|
+
}
|
|
212
|
+
//# sourceMappingURL=notes.js.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"notes.js","sourceRoot":"","sources":["../../src/project-files/notes.ts"],"names":[],"mappings":"AAAA,OAAO,EAAE,SAAS,EAAE,MAAM,SAAS,CAAC;AACpC,OAAO,EAAE,UAAU,EAAE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IAAY;IACjC,IAAI,EAAE,GAAG,KAAK,CAAC;IACf,IAAI,CAAC;QAAC,EAAE,GAAG,CAAC,MAAM,KAAK,CAAC,IAAI,CAAC,IAAI,CAAC,IAAI,EAAE,KAAK,CAAC,CAAC,CAAC,CAAC,WAAW,EAAE,CAAC;IAAC,CAAC;IACjE,OAAO,KAAK,EAAE,CAAC;QAAC,IAAK,KAA+B,CAAC,IAAI,KAAK,QAAQ;YAAE,MAAM,KAAK,CAAC;IAAC,CAAC;IACtF,IAAI,EAAE,EAAE,CAAC;QACP,MAAM,OAAO,GAAG,MAAM,UAAU,CAAC,IAAI,EAAE,CAAC,MAAM,EAAE,MAAM,EAAE,uBAAuB,EAAE,IAAI,EAAE,GAAG,EAAE,IAAI,EAAE,UAAU,CAAC,EAAE,EAAE,GAAG,EAAE,IAAI,EAAE,CAAC,CAAC;QAC9H,IAAI,OAAO,CAAC,MAAM,CAAC,IAAI,EAAE;YAAE,MAAM,UAAU,CAAC,IAAI,EAAE,CAAC,MAAM,EAAE,SAAS,EAAE,IAAI,EAAE,UAAU,CAAC,EAAE,EAAE,GAAG,EAAE,IAAI,EAAE,CAAC,CAAC;QACxG,OAAO;IACT,CAAC;IACD,IAAI,CAAC,MAAM,MAAM,CAAC,IAAI,EAAE,CAAC,UAAU,EAAE,IAAI,EAAE,UAAU,CAAC,CAAC,CAAC,CAAC,IAAI,EAAE;QAAE,MAAM,MAAM,CAAC,IAAI,EAAE,CAAC,IAAI,EAAE,UAAU,EAAE,IAAI,EAAE,IAAI,EAAE,UAAU,CAAC,CAAC,CAAC;AAClI,CAAC"}
|
package/dist/run-manager.js
CHANGED
|
@@ -12,7 +12,7 @@ import { efficiencyContext, learnIntegratedRun } from "./agent-efficiency/produc
|
|
|
12
12
|
import { toolCacheEnv } from "./tool-cache.js";
|
|
13
13
|
import { homeScratchEnv } from "./home-scratch.js";
|
|
14
14
|
import { mergeGeneratedRudderMd, withRudderMdLock } from "./rudder-md.js";
|
|
15
|
-
import { createRunRecord, agentContextPath, ensureProjectRuntimeIgnored, eventsPath, listRuns, loadConfig, loadRunRecord, outputPath, registerProject, rememberBackendSelection, resolveRun, runDir, runRecordPath, saveRunRecord, stopRequestPath, } from "./state.js";
|
|
15
|
+
import { createRunRecord, agentContextPath, configuredBackend, ensureProjectRuntimeIgnored, eventsPath, listRuns, loadConfig, loadRunRecord, outputPath, registerProject, rememberBackendSelection, resolveRun, runDir, runRecordPath, saveRunRecord, stopRequestPath, } from "./state.js";
|
|
16
16
|
import { readGraph, updateGraph } from "./graph.js";
|
|
17
17
|
import { appendEvent, } from "./state.js";
|
|
18
18
|
import { activeRunsForCheckout, currentBranch, findRepoRoot, processAlive, runProcessAlive, } from "./git.js";
|
|
@@ -55,7 +55,7 @@ export async function startRun(params) {
|
|
|
55
55
|
await registerProject(repoRoot).catch(() => undefined);
|
|
56
56
|
await captureSharedContextFromInput(repoRoot, params.task).catch(() => false);
|
|
57
57
|
const config = await loadConfig();
|
|
58
|
-
const backend = params.backend ?? config
|
|
58
|
+
const backend = params.backend ?? configuredBackend(config);
|
|
59
59
|
if (!commandExists(backend)) {
|
|
60
60
|
throw new MissingToolError(backend);
|
|
61
61
|
}
|
|
@@ -1496,8 +1496,8 @@ async function autoIntegrateFinishedWorker(repoRoot, run) {
|
|
|
1496
1496
|
return;
|
|
1497
1497
|
try {
|
|
1498
1498
|
// Planned nodes integrate through the scheduler's trunk, not here.
|
|
1499
|
-
const graph = await readGraph(repoRoot)
|
|
1500
|
-
if (
|
|
1499
|
+
const graph = await readGraph(repoRoot);
|
|
1500
|
+
if (Object.values(graph.nodes ?? {}).some((node) => node.runId === run.id))
|
|
1501
1501
|
return;
|
|
1502
1502
|
const failed = runProjectCheck(repoRoot, run);
|
|
1503
1503
|
if (failed !== undefined) {
|