runwork 0.37.0 → 0.38.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/index.js +660 -378
- package/package.json +1 -1
package/dist/index.js
CHANGED
|
@@ -4869,6 +4869,66 @@ function detectionWithIdentity(agent) {
|
|
|
4869
4869
|
const rest = own.filter((d) => !(d.method === "macos-bundle-id" && [d.target].flat().includes(id)));
|
|
4870
4870
|
return { method: "any", target: [byId, ...rest] };
|
|
4871
4871
|
}
|
|
4872
|
+
function ownedPathsOf(agent) {
|
|
4873
|
+
const dirs = new Set;
|
|
4874
|
+
const names = new Set;
|
|
4875
|
+
const declared = [
|
|
4876
|
+
agent.instructionFile?.global,
|
|
4877
|
+
agent.instructionFile?.project,
|
|
4878
|
+
agent.skillsPaths?.global,
|
|
4879
|
+
agent.skillsPaths?.project,
|
|
4880
|
+
agent.mcpConfigPath
|
|
4881
|
+
];
|
|
4882
|
+
for (const raw of declared) {
|
|
4883
|
+
if (typeof raw !== "string" || !raw)
|
|
4884
|
+
continue;
|
|
4885
|
+
const parts = raw.split(/[\\/]/).filter(Boolean);
|
|
4886
|
+
if (parts.length === 0)
|
|
4887
|
+
continue;
|
|
4888
|
+
if (parts[0].startsWith("."))
|
|
4889
|
+
dirs.add(parts[0].toLowerCase());
|
|
4890
|
+
if (parts.length === 1)
|
|
4891
|
+
names.add(parts[0].toLowerCase());
|
|
4892
|
+
else
|
|
4893
|
+
names.add(parts[parts.length - 1].toLowerCase());
|
|
4894
|
+
}
|
|
4895
|
+
for (const raw of agent.projectAssets ?? []) {
|
|
4896
|
+
const parts = raw.split(/[\\/]/).filter(Boolean);
|
|
4897
|
+
if (parts.length === 0)
|
|
4898
|
+
continue;
|
|
4899
|
+
if (parts[0].startsWith("."))
|
|
4900
|
+
dirs.add(parts[0].toLowerCase());
|
|
4901
|
+
if (parts.length === 1)
|
|
4902
|
+
names.add(parts[0].toLowerCase());
|
|
4903
|
+
}
|
|
4904
|
+
return { dirs, names };
|
|
4905
|
+
}
|
|
4906
|
+
function agentForSharedPath(relPath) {
|
|
4907
|
+
const parts = relPath.split(/[\\/]/).filter(Boolean);
|
|
4908
|
+
if (parts.length === 0)
|
|
4909
|
+
return null;
|
|
4910
|
+
const first = parts[0].toLowerCase();
|
|
4911
|
+
const base = parts[parts.length - 1].toLowerCase();
|
|
4912
|
+
if (parts.length === 1 && SHARED_INSTRUCTION_NAMES.has(base))
|
|
4913
|
+
return null;
|
|
4914
|
+
for (const agent of AGENT_REGISTRY) {
|
|
4915
|
+
const owned = ownedPathsOf(agent);
|
|
4916
|
+
if (owned.dirs.has(first))
|
|
4917
|
+
return agent;
|
|
4918
|
+
}
|
|
4919
|
+
for (const agent of AGENT_REGISTRY) {
|
|
4920
|
+
const owned = ownedPathsOf(agent);
|
|
4921
|
+
if (parts.length === 1 && owned.names.has(base) && !SHARED_INSTRUCTION_NAMES.has(base))
|
|
4922
|
+
return agent;
|
|
4923
|
+
}
|
|
4924
|
+
if (SHARED_INSTRUCTION_NAMES.has(base))
|
|
4925
|
+
return null;
|
|
4926
|
+
for (const agent of AGENT_REGISTRY) {
|
|
4927
|
+
if (agent.projectAssetNames?.some((name) => name.toLowerCase() === base))
|
|
4928
|
+
return agent;
|
|
4929
|
+
}
|
|
4930
|
+
return null;
|
|
4931
|
+
}
|
|
4872
4932
|
function getAgent(slug) {
|
|
4873
4933
|
return slugIndex.get(slug);
|
|
4874
4934
|
}
|
|
@@ -6058,7 +6118,7 @@ var init_workspace_server = __esm(() => {
|
|
|
6058
6118
|
});
|
|
6059
6119
|
|
|
6060
6120
|
// src/generated/version.ts
|
|
6061
|
-
var VERSION = "0.
|
|
6121
|
+
var VERSION = "0.38.0";
|
|
6062
6122
|
|
|
6063
6123
|
// ../../shared/agent-instructions/managed-blocks.ts
|
|
6064
6124
|
function stripManagedBlocks(content, markers) {
|
|
@@ -23125,7 +23185,7 @@ function formatBytes(bytes) {
|
|
|
23125
23185
|
return `${(bytes / (1024 * 1024)).toFixed(1)} MB`;
|
|
23126
23186
|
return `${(bytes / (1024 * 1024 * 1024)).toFixed(2)} GB`;
|
|
23127
23187
|
}
|
|
23128
|
-
var SPACE_SIZE_LIMIT_BYTES, SPACE_PUSH_BATCH_BYTES, SPACE_GIT_OBJECT_MAX_BYTES, SPACE_LFS_BINARY_THRESHOLD_BYTES, SPACE_LFS_TEXT_THRESHOLD_BYTES, SPACE_LFS_LIMIT_BYTES, SPACE_LFS_FILE_LIMIT_BYTES, BINARY_SNIFF_BYTES = 8000, SPACE_SETTLE_MS = 90000, SPACE_CLOCK_AHEAD_MS = 2000, SPACE_THUMBNAIL_MAX_BYTES;
|
|
23188
|
+
var SPACE_SIZE_LIMIT_BYTES, SPACE_PUSH_BATCH_BYTES, SPACE_GIT_OBJECT_MAX_BYTES, SPACE_LFS_BINARY_THRESHOLD_BYTES, SPACE_LFS_TEXT_THRESHOLD_BYTES, SPACE_LFS_LIMIT_BYTES, SPACE_LFS_FILE_LIMIT_BYTES, BINARY_SNIFF_BYTES = 8000, SPACE_SETTLE_MS = 90000, SPACE_CLOCK_AHEAD_MS = 2000, SPACE_WALK_MAX_NEW_FILES = 50000, SPACE_WALK_MAX_MS = 20000, SPACE_THUMBNAIL_MAX_BYTES;
|
|
23129
23189
|
var init_limits = __esm(() => {
|
|
23130
23190
|
SPACE_SIZE_LIMIT_BYTES = 300 * 1024 * 1024;
|
|
23131
23191
|
SPACE_PUSH_BATCH_BYTES = 75 * 1024 * 1024;
|
|
@@ -23437,6 +23497,17 @@ function declaredSegments(declared) {
|
|
|
23437
23497
|
function declaredBasenames(declared) {
|
|
23438
23498
|
return declaredSegments(declared).map((parts) => parts[parts.length - 1]);
|
|
23439
23499
|
}
|
|
23500
|
+
function instructionFileAt(entry) {
|
|
23501
|
+
if (entry.kind === "dir" || entry.path !== entry.name)
|
|
23502
|
+
return null;
|
|
23503
|
+
const name = entry.name.toLowerCase();
|
|
23504
|
+
if (name === SPACE_INSTRUCTIONS_FILE.toLowerCase())
|
|
23505
|
+
return { path: entry.path, name: entry.name, agent: null };
|
|
23506
|
+
const agent = agentForSharedPath(entry.path);
|
|
23507
|
+
if (!agent || !BRIEF_NAMES.has(name))
|
|
23508
|
+
return null;
|
|
23509
|
+
return { path: entry.path, name: entry.name, agent: { slug: agent.slug, name: agent.name } };
|
|
23510
|
+
}
|
|
23440
23511
|
function appFolderAt(relDir, read) {
|
|
23441
23512
|
const text = read(relDir ? `${relDir}/${APP_RULE.marker}` : APP_RULE.marker);
|
|
23442
23513
|
return text !== null && APP_RULE.describe(text) !== null;
|
|
@@ -24616,6 +24687,9 @@ import { createHash as createHash4 } from "node:crypto";
|
|
|
24616
24687
|
import { readdirSync as readdirSync21, rmSync as rmSync10, statSync as statSync20 } from "node:fs";
|
|
24617
24688
|
import { homedir as homedir37 } from "node:os";
|
|
24618
24689
|
import { join as join56 } from "node:path";
|
|
24690
|
+
function markStoppedWalk(changes, stopped) {
|
|
24691
|
+
stoppedLists.set(changes, stopped);
|
|
24692
|
+
}
|
|
24619
24693
|
function waitingCacheDir() {
|
|
24620
24694
|
return join56(homedir37(), ".runwork", "waiting");
|
|
24621
24695
|
}
|
|
@@ -24632,12 +24706,13 @@ function includeRulesMtimeMs(folder) {
|
|
|
24632
24706
|
}
|
|
24633
24707
|
function writeWaitingCache(folder, changes, opts) {
|
|
24634
24708
|
const path = normalizeFolder(folder);
|
|
24709
|
+
const stopped = opts.stoppedWalk ?? stoppedLists.get(changes);
|
|
24635
24710
|
const file = {
|
|
24636
24711
|
folder: path,
|
|
24637
24712
|
at: (opts.now ?? new Date).toISOString(),
|
|
24638
24713
|
auto: opts.auto,
|
|
24639
24714
|
rulesMtimeMs: includeRulesMtimeMs(path),
|
|
24640
|
-
...changes.length > WAITING_CACHE_ENTRY_CAP ? { tooManyChanges: changes.length } : { changes: [...changes] }
|
|
24715
|
+
...stopped ? { tooManyChanges: Math.max(stopped.newFiles, changes.length), walkStopped: stopped.reason } : changes.length > WAITING_CACHE_ENTRY_CAP ? { tooManyChanges: changes.length } : { changes: [...changes] }
|
|
24641
24716
|
};
|
|
24642
24717
|
try {
|
|
24643
24718
|
writeJsonAtomic(waitingCachePath(path), file);
|
|
@@ -24680,6 +24755,7 @@ function describeWaitingCache(folder, now = new Date) {
|
|
|
24680
24755
|
bytes,
|
|
24681
24756
|
entries: Array.isArray(file.changes) ? file.changes.length : null,
|
|
24682
24757
|
tooManyChanges: typeof file.tooManyChanges === "number" ? file.tooManyChanges : null,
|
|
24758
|
+
walkStopped: file.walkStopped === "files" || file.walkStopped === "time" ? file.walkStopped : null,
|
|
24683
24759
|
auto: file.auto === true,
|
|
24684
24760
|
rulesMatch: normaliseMtime(file.rulesMtimeMs) === normaliseMtime(includeRulesMtimeMs(path))
|
|
24685
24761
|
};
|
|
@@ -24709,10 +24785,71 @@ function sameFolderPath(a, b) {
|
|
|
24709
24785
|
function normaliseMtime(ms) {
|
|
24710
24786
|
return typeof ms === "number" && Number.isFinite(ms) ? Math.floor(ms) : null;
|
|
24711
24787
|
}
|
|
24712
|
-
var WAITING_CACHE_MAX_AGE_MS = 60000, WAITING_CACHE_ENTRY_CAP = 200000;
|
|
24788
|
+
var WAITING_CACHE_MAX_AGE_MS = 60000, WAITING_CACHE_ENTRY_CAP = 200000, stoppedLists;
|
|
24713
24789
|
var init_waiting_cache = __esm(async () => {
|
|
24714
24790
|
init_atomic_json();
|
|
24715
24791
|
await init_space_mappings();
|
|
24792
|
+
stoppedLists = new WeakMap;
|
|
24793
|
+
});
|
|
24794
|
+
|
|
24795
|
+
// src/spaces/nested-repos.ts
|
|
24796
|
+
import { lstatSync as lstatSync5 } from "node:fs";
|
|
24797
|
+
import { join as join57 } from "node:path";
|
|
24798
|
+
function repoUnits(folder, rules) {
|
|
24799
|
+
const assets = declaredAgentAssets();
|
|
24800
|
+
const lowerAssets = assets.map((asset) => asset.toLowerCase());
|
|
24801
|
+
const anyFolderNames = new Set(declaredAgentAssetNames().map((name) => name.toLowerCase()));
|
|
24802
|
+
const known = new Map;
|
|
24803
|
+
const holdsGit = (relDir) => {
|
|
24804
|
+
let answer = known.get(relDir);
|
|
24805
|
+
if (answer === undefined) {
|
|
24806
|
+
try {
|
|
24807
|
+
lstatSync5(join57(folder, ...relDir.split("/"), ".git"));
|
|
24808
|
+
answer = true;
|
|
24809
|
+
} catch {
|
|
24810
|
+
answer = false;
|
|
24811
|
+
}
|
|
24812
|
+
known.set(relDir, answer);
|
|
24813
|
+
}
|
|
24814
|
+
return answer;
|
|
24815
|
+
};
|
|
24816
|
+
const insideAsset = (inner) => {
|
|
24817
|
+
const path = inner.toLowerCase();
|
|
24818
|
+
return lowerAssets.some((asset) => path.startsWith(`${asset}/`));
|
|
24819
|
+
};
|
|
24820
|
+
const opens = (inner, full, isDirectory) => {
|
|
24821
|
+
if (onAgentAssetPath(inner, assets))
|
|
24822
|
+
return true;
|
|
24823
|
+
if (isExplicitlyIncluded(full, rules))
|
|
24824
|
+
return true;
|
|
24825
|
+
if (isDirectory !== false && !admitsNothingUnder(full, rules))
|
|
24826
|
+
return true;
|
|
24827
|
+
if (isDirectory === true || inner.includes("/"))
|
|
24828
|
+
return false;
|
|
24829
|
+
return anyFolderNames.has(inner.toLowerCase()) || instructionFileAt({ path: inner, name: inner, kind: "file" }) !== null;
|
|
24830
|
+
};
|
|
24831
|
+
return {
|
|
24832
|
+
hides(relPath, isDirectory) {
|
|
24833
|
+
const segments = relPath.split("/").filter(Boolean);
|
|
24834
|
+
let unit = -1;
|
|
24835
|
+
for (let depth = 1;depth <= segments.length; depth++) {
|
|
24836
|
+
const last = depth === segments.length;
|
|
24837
|
+
const full = segments.slice(0, depth).join("/");
|
|
24838
|
+
if (unit >= 0 && !opens(segments.slice(unit, depth).join("/"), full, last ? isDirectory : true))
|
|
24839
|
+
return true;
|
|
24840
|
+
if (last)
|
|
24841
|
+
break;
|
|
24842
|
+
if (holdsGit(full) && !insideAsset(segments.slice(Math.max(unit, 0), depth).join("/")))
|
|
24843
|
+
unit = depth;
|
|
24844
|
+
}
|
|
24845
|
+
return false;
|
|
24846
|
+
},
|
|
24847
|
+
holdsRepo: holdsGit
|
|
24848
|
+
};
|
|
24849
|
+
}
|
|
24850
|
+
var init_nested_repos = __esm(async () => {
|
|
24851
|
+
init_resources();
|
|
24852
|
+
await init_space_sync_rules();
|
|
24716
24853
|
});
|
|
24717
24854
|
|
|
24718
24855
|
// src/spaces/space-git.ts
|
|
@@ -24720,14 +24857,14 @@ import { spawn as spawn5 } from "node:child_process";
|
|
|
24720
24857
|
import { createHash as createHash5 } from "node:crypto";
|
|
24721
24858
|
import { existsSync as existsSync46, mkdirSync as mkdirSync24, statSync as statSync21, writeFileSync as writeFileSync22 } from "node:fs";
|
|
24722
24859
|
import { homedir as homedir38 } from "node:os";
|
|
24723
|
-
import { basename as basename11, join as
|
|
24860
|
+
import { basename as basename11, join as join58, resolve as resolve11 } from "node:path";
|
|
24724
24861
|
function spaceGitdir(folder) {
|
|
24725
24862
|
const normalized = resolve11(folder);
|
|
24726
24863
|
const hash = createHash5("sha256").update(normalized).digest("hex").slice(0, 12);
|
|
24727
|
-
return
|
|
24864
|
+
return join58(spaceReposRoot(), `${basename11(normalized)}-${hash}`);
|
|
24728
24865
|
}
|
|
24729
24866
|
function spaceReposRoot() {
|
|
24730
|
-
return
|
|
24867
|
+
return join58(homedir38(), ".runwork", "space-repos");
|
|
24731
24868
|
}
|
|
24732
24869
|
function gitFailureText(args, code, stderr) {
|
|
24733
24870
|
const said = stderr.split(/\r?\n/).map((line) => line.replace(/\u001b\[[0-9;]*[A-Za-z]/g, "").trim()).filter((line) => line && !/^(hint|remote):/.test(line)).map((line) => line.replace(/^(fatal|error):\s*/, "")).join(`
|
|
@@ -24776,9 +24913,9 @@ function runSpaceGit(target, args, opts = {}) {
|
|
|
24776
24913
|
];
|
|
24777
24914
|
let progressFile = null;
|
|
24778
24915
|
if ((args[0] === "lfs" || args[0] === "checkout") && target.gitdir && existsSync46(target.gitdir)) {
|
|
24779
|
-
progressFile =
|
|
24916
|
+
progressFile = join58(target.gitdir, "lfs", "runwork-progress");
|
|
24780
24917
|
try {
|
|
24781
|
-
mkdirSync24(
|
|
24918
|
+
mkdirSync24(join58(target.gitdir, "lfs"), { recursive: true });
|
|
24782
24919
|
writeFileSync22(progressFile, "");
|
|
24783
24920
|
env.GIT_LFS_PROGRESS = progressFile;
|
|
24784
24921
|
} catch {
|
|
@@ -24801,6 +24938,18 @@ function runSpaceGit(target, args, opts = {}) {
|
|
|
24801
24938
|
let exitCode;
|
|
24802
24939
|
let settled = false;
|
|
24803
24940
|
let progressSize = 0;
|
|
24941
|
+
const recordLimit = opts.stopAfter?.records;
|
|
24942
|
+
let records = 0;
|
|
24943
|
+
let wantedBytes = 0;
|
|
24944
|
+
let readBytes = 0;
|
|
24945
|
+
let stoppedEarly = null;
|
|
24946
|
+
const stopEarly = (why) => {
|
|
24947
|
+
if (stoppedEarly || exitCode !== undefined)
|
|
24948
|
+
return;
|
|
24949
|
+
stoppedEarly = why;
|
|
24950
|
+
child.kill();
|
|
24951
|
+
};
|
|
24952
|
+
const budgetTimer = opts.stopAfter?.ms !== undefined ? setTimeout(() => stopEarly("time"), Math.max(0, opts.stopAfter.ms)) : null;
|
|
24804
24953
|
const alive = () => {
|
|
24805
24954
|
if (silentFor)
|
|
24806
24955
|
clearTimeout(silentFor);
|
|
@@ -24824,7 +24973,20 @@ function runSpaceGit(target, args, opts = {}) {
|
|
|
24824
24973
|
}, 1000) : null;
|
|
24825
24974
|
alive();
|
|
24826
24975
|
child.stdout.on("data", (chunk) => {
|
|
24976
|
+
if (stoppedEarly)
|
|
24977
|
+
return;
|
|
24827
24978
|
out.push(chunk);
|
|
24979
|
+
if (opts.stopAfter) {
|
|
24980
|
+
for (let at = chunk.indexOf(0);at !== -1; at = chunk.indexOf(0, at + 1)) {
|
|
24981
|
+
if (recordLimit !== undefined && records >= recordLimit) {
|
|
24982
|
+
stopEarly("records");
|
|
24983
|
+
break;
|
|
24984
|
+
}
|
|
24985
|
+
records += 1;
|
|
24986
|
+
wantedBytes = readBytes + at + 1;
|
|
24987
|
+
}
|
|
24988
|
+
readBytes += chunk.length;
|
|
24989
|
+
}
|
|
24828
24990
|
alive();
|
|
24829
24991
|
});
|
|
24830
24992
|
child.stderr.on("data", (chunk) => {
|
|
@@ -24839,6 +25001,8 @@ function runSpaceGit(target, args, opts = {}) {
|
|
|
24839
25001
|
clearTimeout(silentFor);
|
|
24840
25002
|
if (watch)
|
|
24841
25003
|
clearInterval(watch);
|
|
25004
|
+
if (budgetTimer)
|
|
25005
|
+
clearTimeout(budgetTimer);
|
|
24842
25006
|
};
|
|
24843
25007
|
const finish = (code) => {
|
|
24844
25008
|
if (settled)
|
|
@@ -24852,6 +25016,10 @@ function runSpaceGit(target, args, opts = {}) {
|
|
|
24852
25016
|
fail(new SpaceGitError(args, code, stderr, `git ${args[0] ?? ""} went ${Math.round(silenceMs / 1000)} seconds without a sign of progress and was stopped`));
|
|
24853
25017
|
return;
|
|
24854
25018
|
}
|
|
25019
|
+
if (stoppedEarly) {
|
|
25020
|
+
done({ code: code ?? -1, stdout: Buffer.concat(out).subarray(0, wantedBytes), stderr, stopped: stoppedEarly });
|
|
25021
|
+
return;
|
|
25022
|
+
}
|
|
24855
25023
|
const result = { code: code ?? -1, stdout: Buffer.concat(out), stderr };
|
|
24856
25024
|
if (code !== null && okCodes.includes(code))
|
|
24857
25025
|
done(result);
|
|
@@ -24867,7 +25035,7 @@ function runSpaceGit(target, args, opts = {}) {
|
|
|
24867
25035
|
});
|
|
24868
25036
|
child.on("exit", (code) => {
|
|
24869
25037
|
exitCode = code;
|
|
24870
|
-
if (stoppedForSilence)
|
|
25038
|
+
if (stoppedForSilence || stoppedEarly)
|
|
24871
25039
|
finish(code);
|
|
24872
25040
|
});
|
|
24873
25041
|
child.on("close", (code) => finish(code));
|
|
@@ -24933,8 +25101,8 @@ var init_space_git = __esm(() => {
|
|
|
24933
25101
|
|
|
24934
25102
|
// src/spaces/space-repo.ts
|
|
24935
25103
|
import { createHash as createHash6 } from "node:crypto";
|
|
24936
|
-
import { createReadStream, existsSync as existsSync47, lstatSync as
|
|
24937
|
-
import { dirname as dirname15, isAbsolute as isAbsolute11, join as
|
|
25104
|
+
import { createReadStream, existsSync as existsSync47, lstatSync as lstatSync6, mkdirSync as mkdirSync25, openSync as openSync3, readFileSync as readFileSync34, readSync as readSync2, closeSync as closeSync3, readdirSync as readdirSync22, readlinkSync as readlinkSync2, realpathSync as realpathSync6, renameSync as renameSync8, rmSync as rmSync11, statSync as statSync22, writeFileSync as writeFileSync23 } from "node:fs";
|
|
25105
|
+
import { dirname as dirname15, isAbsolute as isAbsolute11, join as join59, posix as posix4, relative as relative7, sep as sep9, win32 as win324 } from "node:path";
|
|
24938
25106
|
function isUnreadableStorage(reading) {
|
|
24939
25107
|
return "unreadable" in reading;
|
|
24940
25108
|
}
|
|
@@ -24981,7 +25149,7 @@ async function foreignSpaceHistory(folder, spaceRemoteUrl) {
|
|
|
24981
25149
|
}
|
|
24982
25150
|
async function historyRemoteUrl(gitdir) {
|
|
24983
25151
|
try {
|
|
24984
|
-
const plain = runworkRemoteUrlInConfig(readFileSync34(
|
|
25152
|
+
const plain = runworkRemoteUrlInConfig(readFileSync34(join59(gitdir, "config"), "utf-8"));
|
|
24985
25153
|
if (plain && !/["\\]/.test(plain))
|
|
24986
25154
|
return plain;
|
|
24987
25155
|
} catch {
|
|
@@ -25007,13 +25175,13 @@ function directoryWeight(dir) {
|
|
|
25007
25175
|
continue;
|
|
25008
25176
|
}
|
|
25009
25177
|
for (const entry of entries) {
|
|
25010
|
-
const full =
|
|
25178
|
+
const full = join59(current, entry.name);
|
|
25011
25179
|
if (entry.isDirectory()) {
|
|
25012
25180
|
pending.push(full);
|
|
25013
25181
|
continue;
|
|
25014
25182
|
}
|
|
25015
25183
|
try {
|
|
25016
|
-
const stats =
|
|
25184
|
+
const stats = lstatSync6(full);
|
|
25017
25185
|
if (stats.isFile()) {
|
|
25018
25186
|
bytes += stats.size;
|
|
25019
25187
|
files++;
|
|
@@ -25119,12 +25287,12 @@ async function unreadableHistory(folder) {
|
|
|
25119
25287
|
}
|
|
25120
25288
|
function refInFiles(gitdir, ref) {
|
|
25121
25289
|
try {
|
|
25122
|
-
const loose = readFileSync34(
|
|
25290
|
+
const loose = readFileSync34(join59(gitdir, ...ref.split("/")), "utf-8").trim();
|
|
25123
25291
|
if (/^[0-9a-f]{40}$/.test(loose))
|
|
25124
25292
|
return loose;
|
|
25125
25293
|
} catch {}
|
|
25126
25294
|
try {
|
|
25127
|
-
for (const line of readFileSync34(
|
|
25295
|
+
for (const line of readFileSync34(join59(gitdir, "packed-refs"), "utf-8").split(`
|
|
25128
25296
|
`)) {
|
|
25129
25297
|
const [oid, name] = line.trim().split(" ");
|
|
25130
25298
|
if (name === ref && /^[0-9a-f]{40}$/.test(oid))
|
|
@@ -25155,8 +25323,8 @@ async function setAsideUnreadableHistory(folder, why) {
|
|
|
25155
25323
|
}
|
|
25156
25324
|
async function healSpaceConfig(folder, spaceRemoteUrl, current) {
|
|
25157
25325
|
const gitdir = spaceGitdir(folder);
|
|
25158
|
-
mkdirSync25(
|
|
25159
|
-
mkdirSync25(
|
|
25326
|
+
mkdirSync25(join59(gitdir, "info"), { recursive: true });
|
|
25327
|
+
mkdirSync25(join59(gitdir, "hooks"), { recursive: true });
|
|
25160
25328
|
for (const [key, value] of wantedSpaceConfig(gitdir, spaceRemoteUrl, current)) {
|
|
25161
25329
|
if (current.get(configKey(key)) === value)
|
|
25162
25330
|
continue;
|
|
@@ -25171,12 +25339,12 @@ function wantedSpaceConfig(gitdir, spaceRemoteUrl, current) {
|
|
|
25171
25339
|
const url = existingUrl && normalizeUrl(existingUrl) === normalizeUrl(spaceRemoteUrl) ? existingUrl : spaceRemoteUrl;
|
|
25172
25340
|
const lfsUrl = spaceLfsUrl(url);
|
|
25173
25341
|
const windows = process.platform === "win32";
|
|
25174
|
-
const ignoreCase = existsSync47(
|
|
25342
|
+
const ignoreCase = existsSync47(join59(gitdir, "CoNfIg")) ? [["core.ignorecase", "true"]] : current.has("core.ignorecase") ? [["core.ignorecase", "false"]] : [];
|
|
25175
25343
|
return [
|
|
25176
25344
|
["core.bare", "false"],
|
|
25177
25345
|
["core.autocrlf", "false"],
|
|
25178
25346
|
["core.precomposeunicode", "false"],
|
|
25179
|
-
["core.hooksPath",
|
|
25347
|
+
["core.hooksPath", join59(gitdir, "hooks")],
|
|
25180
25348
|
["core.symlinks", windows ? "false" : "true"],
|
|
25181
25349
|
["core.filemode", windows ? "false" : "true"],
|
|
25182
25350
|
...ignoreCase,
|
|
@@ -25242,7 +25410,7 @@ function configHeaderText(section) {
|
|
|
25242
25410
|
return `[${section.section} "${section.subsection.replace(/\\/g, "\\\\").replace(/"/g, "\\\"")}"]`;
|
|
25243
25411
|
}
|
|
25244
25412
|
function seedSpaceConfig(gitdir, wanted) {
|
|
25245
|
-
const file =
|
|
25413
|
+
const file = join59(gitdir, "config");
|
|
25246
25414
|
let sections;
|
|
25247
25415
|
try {
|
|
25248
25416
|
sections = parseInitConfig(readFileSync34(file, "utf-8"));
|
|
@@ -25273,7 +25441,7 @@ function seedSpaceConfig(gitdir, wanted) {
|
|
|
25273
25441
|
const text = sections.filter((one) => one.entries.length > 0).map((one) => [configHeaderText(one), ...one.entries.map(([name, value]) => ` ${name} = ${configValueText(value)}`)].join(`
|
|
25274
25442
|
`)).join(`
|
|
25275
25443
|
`);
|
|
25276
|
-
const temp =
|
|
25444
|
+
const temp = join59(gitdir, `config.runwork-${process.pid}.tmp`);
|
|
25277
25445
|
try {
|
|
25278
25446
|
writeFileSync23(temp, `${text}
|
|
25279
25447
|
`);
|
|
@@ -25288,18 +25456,18 @@ function spaceLfsUrl(spaceRemoteUrl) {
|
|
|
25288
25456
|
return `${spaceRemoteUrl.replace(/\/+$/, "").replace(/\.git$/, "")}/info/lfs`;
|
|
25289
25457
|
}
|
|
25290
25458
|
function migrateLegacyInFolderRepo(folder, gitdir) {
|
|
25291
|
-
const inFolder =
|
|
25292
|
-
if (!existsSync47(inFolder) || !statSync22(inFolder).isDirectory() ||
|
|
25459
|
+
const inFolder = join59(folder, ".git");
|
|
25460
|
+
if (!existsSync47(inFolder) || !statSync22(inFolder).isDirectory() || lstatSync6(inFolder).isSymbolicLink())
|
|
25293
25461
|
return;
|
|
25294
25462
|
try {
|
|
25295
|
-
const config = readFileSync34(
|
|
25463
|
+
const config = readFileSync34(join59(inFolder, "config"), "utf-8");
|
|
25296
25464
|
const remotes = [...config.matchAll(/\[remote "([^"]+)"\]/g)].map((m) => m[1]);
|
|
25297
25465
|
if (remotes.length !== 1 || remotes[0] !== RUNWORK_REMOTE)
|
|
25298
25466
|
return;
|
|
25299
25467
|
const url = runworkRemoteUrlInConfig(config);
|
|
25300
25468
|
if (!url || spaceIdFromRemoteUrl(url) === null)
|
|
25301
25469
|
return;
|
|
25302
|
-
mkdirSync25(
|
|
25470
|
+
mkdirSync25(join59(gitdir, ".."), mkdirOptions(join59(gitdir, "..")));
|
|
25303
25471
|
renameSync8(inFolder, gitdir);
|
|
25304
25472
|
} catch {}
|
|
25305
25473
|
}
|
|
@@ -25313,10 +25481,10 @@ function runworkRemoteUrlInConfig(config) {
|
|
|
25313
25481
|
return line ? line[1] : null;
|
|
25314
25482
|
}
|
|
25315
25483
|
function excludeFromTheirGit(folder, relPath) {
|
|
25316
|
-
const info =
|
|
25317
|
-
const file =
|
|
25484
|
+
const info = join59(folder, ".git", "info");
|
|
25485
|
+
const file = join59(info, "exclude");
|
|
25318
25486
|
try {
|
|
25319
|
-
if (!existsSync47(
|
|
25487
|
+
if (!existsSync47(join59(folder, ".git")) || !statSync22(join59(folder, ".git")).isDirectory())
|
|
25320
25488
|
return;
|
|
25321
25489
|
const current = existsSync47(file) ? readFileSync34(file) : Buffer.alloc(0);
|
|
25322
25490
|
const seen = current.toString("latin1");
|
|
@@ -25343,7 +25511,7 @@ function checkoutPlace(folder, platform) {
|
|
|
25343
25511
|
return { platform, rootLength: folder.length + 1 };
|
|
25344
25512
|
}
|
|
25345
25513
|
function unwritableRecordPath(folder) {
|
|
25346
|
-
return
|
|
25514
|
+
return join59(spaceGitdir(folder), UNWRITABLE_RECORD);
|
|
25347
25515
|
}
|
|
25348
25516
|
function writeUnwritableRecord(folder, entries, platform) {
|
|
25349
25517
|
const path = unwritableRecordPath(folder);
|
|
@@ -25375,7 +25543,7 @@ function foldName(name) {
|
|
|
25375
25543
|
function nameTakenByFoldedTwin(folder, filepath) {
|
|
25376
25544
|
const slash = filepath.lastIndexOf("/");
|
|
25377
25545
|
const base = slash < 0 ? filepath : filepath.slice(slash + 1);
|
|
25378
|
-
const dir = slash < 0 ? folder :
|
|
25546
|
+
const dir = slash < 0 ? folder : join59(folder, filepath.slice(0, slash));
|
|
25379
25547
|
let entries;
|
|
25380
25548
|
try {
|
|
25381
25549
|
entries = readdirSync22(dir);
|
|
@@ -25404,7 +25572,7 @@ function readSkipRecord(folder, platform) {
|
|
|
25404
25572
|
out.floor.add(path);
|
|
25405
25573
|
continue;
|
|
25406
25574
|
}
|
|
25407
|
-
if (existsSync47(
|
|
25575
|
+
if (existsSync47(join59(folder, path)))
|
|
25408
25576
|
continue;
|
|
25409
25577
|
if (reasons[path] === "excluded") {
|
|
25410
25578
|
out.excluded.add(path);
|
|
@@ -25604,7 +25772,7 @@ async function writeLfsAttributes(folder, extra) {
|
|
|
25604
25772
|
const lines = [...paths].sort().map((path) => `${attributesPattern(path)} filter=lfs diff=lfs merge=lfs -text
|
|
25605
25773
|
`);
|
|
25606
25774
|
const content = `${ATTRIBUTES_HEADER}${lines.join("")}`;
|
|
25607
|
-
const file =
|
|
25775
|
+
const file = join59(spaceGitdir(folder), "info", "attributes");
|
|
25608
25776
|
try {
|
|
25609
25777
|
if (readFileSync34(file, "utf-8") === content)
|
|
25610
25778
|
return;
|
|
@@ -25613,10 +25781,10 @@ async function writeLfsAttributes(folder, extra) {
|
|
|
25613
25781
|
writeFileSync23(file, content);
|
|
25614
25782
|
}
|
|
25615
25783
|
function lfsObjectPresent(folder, oid) {
|
|
25616
|
-
return existsSync47(
|
|
25784
|
+
return existsSync47(join59(spaceGitdir(folder), "lfs", "objects", oid.slice(0, 2), oid.slice(2, 4), oid));
|
|
25617
25785
|
}
|
|
25618
25786
|
function readNotInSpace(folder) {
|
|
25619
|
-
const record = readJsonOrNull(
|
|
25787
|
+
const record = readJsonOrNull(join59(spaceGitdir(folder), NOT_IN_SPACE_RECORD));
|
|
25620
25788
|
const oids = record && Array.isArray(record.oids) ? record.oids : [];
|
|
25621
25789
|
return new Set(oids.filter((oid) => typeof oid === "string" && isLfsOid(oid)));
|
|
25622
25790
|
}
|
|
@@ -25624,7 +25792,7 @@ function rememberNotInSpace(folder, oids) {
|
|
|
25624
25792
|
const kept = [...readNotInSpace(folder)].filter((oid) => !oids.includes(oid));
|
|
25625
25793
|
const record = { at: new Date().toISOString(), oids: [...kept, ...oids].slice(-NOT_IN_SPACE_KEPT) };
|
|
25626
25794
|
try {
|
|
25627
|
-
writeJsonAtomic(
|
|
25795
|
+
writeJsonAtomic(join59(spaceGitdir(folder), NOT_IN_SPACE_RECORD), record);
|
|
25628
25796
|
} catch {}
|
|
25629
25797
|
}
|
|
25630
25798
|
async function lfsObjectVouchedFor(folder) {
|
|
@@ -25642,7 +25810,7 @@ function pointerInFile(path) {
|
|
|
25642
25810
|
async function fileHoldsObject(folder, path, pointer) {
|
|
25643
25811
|
let stats;
|
|
25644
25812
|
try {
|
|
25645
|
-
stats =
|
|
25813
|
+
stats = lstatSync6(join59(folder, path));
|
|
25646
25814
|
} catch {
|
|
25647
25815
|
return false;
|
|
25648
25816
|
}
|
|
@@ -25650,7 +25818,7 @@ async function fileHoldsObject(folder, path, pointer) {
|
|
|
25650
25818
|
return false;
|
|
25651
25819
|
const hash = createHash6("sha256");
|
|
25652
25820
|
try {
|
|
25653
|
-
for await (const chunk of createReadStream(
|
|
25821
|
+
for await (const chunk of createReadStream(join59(folder, path)))
|
|
25654
25822
|
hash.update(chunk);
|
|
25655
25823
|
} catch {
|
|
25656
25824
|
return false;
|
|
@@ -25659,7 +25827,7 @@ async function fileHoldsObject(folder, path, pointer) {
|
|
|
25659
25827
|
}
|
|
25660
25828
|
function lstatOrNull(path) {
|
|
25661
25829
|
try {
|
|
25662
|
-
return
|
|
25830
|
+
return lstatSync6(path);
|
|
25663
25831
|
} catch {
|
|
25664
25832
|
return null;
|
|
25665
25833
|
}
|
|
@@ -25673,7 +25841,7 @@ function thingsInTheWay(folder, writes, index, tree) {
|
|
|
25673
25841
|
const current = pending.pop();
|
|
25674
25842
|
let entries;
|
|
25675
25843
|
try {
|
|
25676
|
-
entries = readdirSync22(
|
|
25844
|
+
entries = readdirSync22(join59(folder, current), { withFileTypes: true });
|
|
25677
25845
|
} catch {
|
|
25678
25846
|
return false;
|
|
25679
25847
|
}
|
|
@@ -25696,7 +25864,7 @@ function thingsInTheWay(folder, writes, index, tree) {
|
|
|
25696
25864
|
const parts = path.split("/");
|
|
25697
25865
|
for (let i = 1;i < parts.length; i++) {
|
|
25698
25866
|
const ancestor = parts.slice(0, i).join("/");
|
|
25699
|
-
const stats = lstatOrNull(
|
|
25867
|
+
const stats = lstatOrNull(join59(folder, ancestor));
|
|
25700
25868
|
if (!stats)
|
|
25701
25869
|
break;
|
|
25702
25870
|
if (stats.isDirectory())
|
|
@@ -25707,7 +25875,7 @@ function thingsInTheWay(folder, writes, index, tree) {
|
|
|
25707
25875
|
}
|
|
25708
25876
|
break;
|
|
25709
25877
|
}
|
|
25710
|
-
const stats = lstatOrNull(
|
|
25878
|
+
const stats = lstatOrNull(join59(folder, path));
|
|
25711
25879
|
if (stats?.isDirectory() && !onlyLeaving(path) && !reported.has(path)) {
|
|
25712
25880
|
reported.add(path);
|
|
25713
25881
|
problems.push(`${path} is a folder here and a file in the space`);
|
|
@@ -25735,7 +25903,7 @@ function linkIsTheSpaces(folder, path, index, tree) {
|
|
|
25735
25903
|
if (!had || had.mode !== SYMLINK_MODE || theirs && theirs.mode !== SYMLINK_MODE)
|
|
25736
25904
|
return false;
|
|
25737
25905
|
try {
|
|
25738
|
-
return had.oid === blobOid(linkBlob(
|
|
25906
|
+
return had.oid === blobOid(linkBlob(join59(folder, path)));
|
|
25739
25907
|
} catch {
|
|
25740
25908
|
return false;
|
|
25741
25909
|
}
|
|
@@ -25743,20 +25911,20 @@ function linkIsTheSpaces(folder, path, index, tree) {
|
|
|
25743
25911
|
function personsLink(folder, path, index, tree) {
|
|
25744
25912
|
if (path === SPACE_INSTRUCTIONS_FILE && placeholderTarget(folder) !== null)
|
|
25745
25913
|
return true;
|
|
25746
|
-
return lstatOrNull(
|
|
25914
|
+
return lstatOrNull(join59(folder, path))?.isSymbolicLink() === true && !linkIsTheSpaces(folder, path, index, tree);
|
|
25747
25915
|
}
|
|
25748
25916
|
function rememberHeldBrief(folder, spaceOid) {
|
|
25749
25917
|
try {
|
|
25750
|
-
writeJsonAtomic(
|
|
25918
|
+
writeJsonAtomic(join59(spaceGitdir(folder), HELD_BRIEF_RECORD), { at: new Date().toISOString(), spaceOid });
|
|
25751
25919
|
} catch {}
|
|
25752
25920
|
}
|
|
25753
25921
|
function forgetHeldBrief(folder) {
|
|
25754
25922
|
try {
|
|
25755
|
-
rmSync11(
|
|
25923
|
+
rmSync11(join59(spaceGitdir(folder), HELD_BRIEF_RECORD), { force: true });
|
|
25756
25924
|
} catch {}
|
|
25757
25925
|
}
|
|
25758
25926
|
async function briefHeldAgainstSpace(folder) {
|
|
25759
|
-
const record = readJsonOrNull(
|
|
25927
|
+
const record = readJsonOrNull(join59(spaceGitdir(folder), HELD_BRIEF_RECORD));
|
|
25760
25928
|
if (!record || typeof record.spaceOid !== "string")
|
|
25761
25929
|
return false;
|
|
25762
25930
|
const entry = (await indexEntries(folder, [`:(top,literal)${SPACE_INSTRUCTIONS_FILE}`])).get(SPACE_INSTRUCTIONS_FILE);
|
|
@@ -25775,8 +25943,8 @@ async function takeBriefThroughLink(folder, index, tree, pointers) {
|
|
|
25775
25943
|
if (!theirs)
|
|
25776
25944
|
return;
|
|
25777
25945
|
const text = (bytes) => bytes.toString("latin1").trimEnd();
|
|
25778
|
-
const full =
|
|
25779
|
-
const own =
|
|
25946
|
+
const full = join59(folder, SPACE_INSTRUCTIONS_FILE);
|
|
25947
|
+
const own = lstatSync6(full).isSymbolicLink() ? linkBlob(full) : readFileSync34(full);
|
|
25780
25948
|
if (text(theirs) === text(own))
|
|
25781
25949
|
return;
|
|
25782
25950
|
const mine = text(spaceCopyBytes(readFileSync34(linked.target)));
|
|
@@ -25811,7 +25979,7 @@ async function linksLeftAlone(folder, paths, tree) {
|
|
|
25811
25979
|
let same = false;
|
|
25812
25980
|
try {
|
|
25813
25981
|
const blob = blobs.get(oid);
|
|
25814
|
-
same = path === SPACE_INSTRUCTIONS_FILE && blob ? spaceDocMatchesBlob(folder, path, blob) : blobOid(linkBlob(
|
|
25982
|
+
same = path === SPACE_INSTRUCTIONS_FILE && blob ? spaceDocMatchesBlob(folder, path, blob) : blobOid(linkBlob(join59(folder, path))) === oid;
|
|
25815
25983
|
} catch {}
|
|
25816
25984
|
if (!same)
|
|
25817
25985
|
held.push({ path, kind: "update" });
|
|
@@ -25863,7 +26031,7 @@ async function checkoutSpaceFiles(folder, opts) {
|
|
|
25863
26031
|
skipped.push({ path, mode: entry.mode, reason: "lfs" });
|
|
25864
26032
|
}
|
|
25865
26033
|
const goneAndExcluded = [...index.keys()].filter((path) => !tree.has(path) && (isRelPathIgnored(path, floor) || path !== SPACE_INCLUDE_FILE && !isIncluded(path, rules)));
|
|
25866
|
-
const remembered = skipped.filter((entry) => entry.reason !== "excluded" || !existsSync47(
|
|
26034
|
+
const remembered = skipped.filter((entry) => entry.reason !== "excluded" || !existsSync47(join59(folder, entry.path)));
|
|
25867
26035
|
writeUnwritableRecord(folder, remembered, opts.platform);
|
|
25868
26036
|
await writeLfsAttributes(folder, pointers.keys());
|
|
25869
26037
|
const flagged = [...index].filter(([, entry]) => entry.skipWorktree).map(([path]) => path);
|
|
@@ -25943,7 +26111,7 @@ async function bringDownLfsPaths(folder, platform, auth) {
|
|
|
25943
26111
|
const tree = await treeEntriesAt(folder, commit);
|
|
25944
26112
|
const pointers = await pointersIn(folder, tree);
|
|
25945
26113
|
const index = await indexEntries(folder);
|
|
25946
|
-
const linked = [...pending].filter((path) => pointers.has(path) && lstatOrNull(
|
|
26114
|
+
const linked = [...pending].filter((path) => pointers.has(path) && lstatOrNull(join59(folder, path))?.isSymbolicLink() === true);
|
|
25947
26115
|
const retry = [...pending].filter((path) => pointers.has(path) && !linked.includes(path));
|
|
25948
26116
|
await writeLfsAttributes(folder, []);
|
|
25949
26117
|
const alreadyHere = [];
|
|
@@ -25979,6 +26147,10 @@ async function bringDownLfsPaths(folder, platform, auth) {
|
|
|
25979
26147
|
}
|
|
25980
26148
|
return lfs.failure;
|
|
25981
26149
|
}
|
|
26150
|
+
function walkStoppedSentence(stopped) {
|
|
26151
|
+
const where = stopped.reason === "files" ? `after ${stopped.newFiles} new files` : `at the time limit, with ${stopped.newFiles} new files found`;
|
|
26152
|
+
return `too large to read on every sync, so reading stopped ${where}; they wait until you share them by name, and \`${SPACE_EXCLUDE_COMMAND} <path>\` keeps out what this folder should not share`;
|
|
26153
|
+
}
|
|
25982
26154
|
function skippedFileReason(skipped) {
|
|
25983
26155
|
if (skipped.reason === "lfs")
|
|
25984
26156
|
return LFS_UNAVAILABLE_SENTENCE;
|
|
@@ -25990,6 +26162,24 @@ function skippedFileReason(skipped) {
|
|
|
25990
26162
|
return LINK_UNSHARED_SKIP_SENTENCE;
|
|
25991
26163
|
return "above the per-file limit";
|
|
25992
26164
|
}
|
|
26165
|
+
function openWalkBudget(limits) {
|
|
26166
|
+
return { files: limits.files, deadline: Date.now() + limits.ms, found: 0, stopped: null };
|
|
26167
|
+
}
|
|
26168
|
+
function walkSpent(budget) {
|
|
26169
|
+
if (budget.stopped === null && Date.now() >= budget.deadline)
|
|
26170
|
+
budget.stopped = "time";
|
|
26171
|
+
return budget.stopped !== null;
|
|
26172
|
+
}
|
|
26173
|
+
function spendOnFile(budget) {
|
|
26174
|
+
if (budget.stopped !== null)
|
|
26175
|
+
return false;
|
|
26176
|
+
if (budget.found >= budget.files) {
|
|
26177
|
+
budget.stopped = "files";
|
|
26178
|
+
return false;
|
|
26179
|
+
}
|
|
26180
|
+
budget.found += 1;
|
|
26181
|
+
return true;
|
|
26182
|
+
}
|
|
25993
26183
|
function excludeLiteral(name) {
|
|
25994
26184
|
let literal = name.replace(/[\\*?[]/g, (c) => `\\${c}`);
|
|
25995
26185
|
if (literal.startsWith("#") || literal.startsWith("!"))
|
|
@@ -26006,7 +26196,7 @@ function writeSpaceExcludes(folder, ignoreSets, rules, floor) {
|
|
|
26006
26196
|
lines.add(`/${excludeLiteral(deny)}`);
|
|
26007
26197
|
const content = `${EXCLUDE_HEADER}${[...lines].sort().map((line) => `${line}
|
|
26008
26198
|
`).join("")}`;
|
|
26009
|
-
const file =
|
|
26199
|
+
const file = join59(spaceGitdir(folder), "info", "exclude");
|
|
26010
26200
|
try {
|
|
26011
26201
|
if (readFileSync34(file, "utf-8") === content)
|
|
26012
26202
|
return;
|
|
@@ -26022,31 +26212,47 @@ function includeNarrowing(rules) {
|
|
|
26022
26212
|
const specs = [...rules.directories, ...rules.paths, SPACE_INCLUDE_FILE].map((path) => `:(top,literal)${path}`);
|
|
26023
26213
|
return specs.reduce((sum, spec) => sum + spec.length + 1, 0) > PATHSPEC_BUDGET ? null : specs;
|
|
26024
26214
|
}
|
|
26025
|
-
function filesUnder(folder, relDir,
|
|
26215
|
+
function filesUnder(folder, relDir, enter, keep, budget) {
|
|
26026
26216
|
const found = [];
|
|
26027
26217
|
const pending = [relDir];
|
|
26028
26218
|
while (pending.length > 0) {
|
|
26219
|
+
if (walkSpent(budget))
|
|
26220
|
+
break;
|
|
26029
26221
|
const current = pending.pop();
|
|
26030
26222
|
let entries;
|
|
26031
26223
|
try {
|
|
26032
|
-
entries = readdirSync22(
|
|
26224
|
+
entries = readdirSync22(join59(folder, current), { withFileTypes: true });
|
|
26033
26225
|
} catch {
|
|
26034
26226
|
continue;
|
|
26035
26227
|
}
|
|
26036
26228
|
for (const entry of entries) {
|
|
26037
26229
|
const rel = `${current}/${entry.name}`;
|
|
26038
26230
|
if (entry.isDirectory()) {
|
|
26039
|
-
if (entry.name !== ".git" &&
|
|
26231
|
+
if (entry.name !== ".git" && enter(rel))
|
|
26040
26232
|
pending.push(rel);
|
|
26041
26233
|
continue;
|
|
26042
26234
|
}
|
|
26235
|
+
if (!keep(rel))
|
|
26236
|
+
continue;
|
|
26237
|
+
if (!spendOnFile(budget))
|
|
26238
|
+
return found;
|
|
26043
26239
|
found.push(rel);
|
|
26044
26240
|
}
|
|
26045
26241
|
}
|
|
26046
26242
|
return found;
|
|
26047
26243
|
}
|
|
26048
|
-
|
|
26244
|
+
function insideRepoUnit(path, units) {
|
|
26245
|
+
const segments = path.split("/");
|
|
26246
|
+
for (let depth = 1;depth < segments.length; depth++) {
|
|
26247
|
+
if (units.holdsRepo(segments.slice(0, depth).join("/")))
|
|
26248
|
+
return true;
|
|
26249
|
+
}
|
|
26250
|
+
return false;
|
|
26251
|
+
}
|
|
26252
|
+
async function folderRows(folder, ignoreSets, rules, floor, units, limits, under = "") {
|
|
26049
26253
|
const skip = (relDir) => spaceSkipsDirectory(relDir, ignoreSets, rules, floor);
|
|
26254
|
+
const enter = (relDir) => !skip(relDir) && !units.hides(relDir, true);
|
|
26255
|
+
const keep = (rel) => !units.hides(rel, false);
|
|
26050
26256
|
const underHead = `${under}/`;
|
|
26051
26257
|
const inside = (path) => under === "" || path.startsWith(underHead);
|
|
26052
26258
|
const level = under === "" ? [] : [`:(top,literal)${under}`];
|
|
@@ -26054,7 +26260,7 @@ async function folderRows(folder, ignoreSets, rules, floor, under = "") {
|
|
|
26054
26260
|
const index = new Map([...await indexEntries(folder, level)].filter(([path]) => inside(path)));
|
|
26055
26261
|
const changes = await workingChanges(folder, level);
|
|
26056
26262
|
const rows = [];
|
|
26057
|
-
const skippedHere = [...index].filter(([path, entry]) => entry.skipWorktree && lstatOrNull(
|
|
26263
|
+
const skippedHere = [...index].filter(([path, entry]) => entry.skipWorktree && lstatOrNull(join59(folder, path)) !== null).map(([path]) => path);
|
|
26058
26264
|
const skippedOids = skippedHere.length > 0 ? await stagedOids(folder, skippedHere) : new Map;
|
|
26059
26265
|
for (const [path, entry] of index) {
|
|
26060
26266
|
if (entry.skipWorktree) {
|
|
@@ -26066,38 +26272,72 @@ async function folderRows(folder, ignoreSets, rules, floor, under = "") {
|
|
|
26066
26272
|
rows.push({ path, tracked: true, state: how === undefined ? "same" : how === "D" ? "gone" : "changed" });
|
|
26067
26273
|
}
|
|
26068
26274
|
const narrowing = under === "" ? includeNarrowing(rules) : level;
|
|
26069
|
-
const
|
|
26275
|
+
const budget = openWalkBudget(limits);
|
|
26070
26276
|
const found = new Set;
|
|
26071
|
-
const
|
|
26072
|
-
|
|
26073
|
-
|
|
26074
|
-
|
|
26075
|
-
|
|
26076
|
-
|
|
26077
|
-
|
|
26078
|
-
|
|
26277
|
+
const take = (path) => {
|
|
26278
|
+
if (found.has(path) || index.has(path))
|
|
26279
|
+
return true;
|
|
26280
|
+
if (!spendOnFile(budget))
|
|
26281
|
+
return false;
|
|
26282
|
+
found.add(path);
|
|
26283
|
+
return true;
|
|
26284
|
+
};
|
|
26285
|
+
const keepNew = (rel) => !found.has(rel) && !index.has(rel) && keep(rel);
|
|
26286
|
+
const listNew = async (args, walkRepo) => {
|
|
26287
|
+
if (walkSpent(budget))
|
|
26288
|
+
return;
|
|
26289
|
+
const listed = await spaceGit2(folder, args, { stopAfter: { records: budget.files - budget.found + 1, ms: Math.max(0, budget.deadline - Date.now()) } });
|
|
26290
|
+
for (const record of nulRecords(listed.stdout)) {
|
|
26291
|
+
if (record.endsWith("/"))
|
|
26292
|
+
walkRepo(record.slice(0, -1));
|
|
26293
|
+
else if (keep(record) && !take(record))
|
|
26294
|
+
break;
|
|
26295
|
+
if (walkSpent(budget))
|
|
26296
|
+
break;
|
|
26079
26297
|
}
|
|
26080
|
-
|
|
26081
|
-
|
|
26298
|
+
if (listed.stopped && budget.stopped === null)
|
|
26299
|
+
budget.stopped = listed.stopped === "time" ? "time" : "files";
|
|
26300
|
+
};
|
|
26301
|
+
const untrackedApp = (dir) => ignoreSets.apps.hides(dir, true) && admitsNothingUnder(dir, rules) && ![...index.keys()].some((path) => path.startsWith(`${dir}/`));
|
|
26302
|
+
await listNew(["ls-files", "-o", "-z", "--exclude-standard", "--", ...narrowing ?? [":/"]], (dir) => {
|
|
26303
|
+
if (!skip(dir) && !untrackedApp(dir) && !units.hides(dir, true))
|
|
26304
|
+
for (const path of filesUnder(folder, dir, enter, keepNew, budget))
|
|
26305
|
+
found.add(path);
|
|
26306
|
+
});
|
|
26082
26307
|
const named = [...rules.directories, ...rules.paths].map((path) => `:(top,literal)${path}`);
|
|
26083
26308
|
if (named.length > 0 && named.reduce((sum, spec) => sum + spec.length + 1, 0) <= PATHSPEC_BUDGET) {
|
|
26084
26309
|
const floorOnly = [...floor.dirs].flatMap((dir) => ["-x", `${excludeLiteral(dir)}/`]);
|
|
26085
|
-
const
|
|
26086
|
-
|
|
26087
|
-
if (
|
|
26088
|
-
for (const path of filesUnder(folder,
|
|
26310
|
+
const enterPastIgnores = (relDir) => !isIgnoredDirectory(relDir, floor) && !units.hides(relDir, true);
|
|
26311
|
+
await listNew(["ls-files", "-o", "-z", ...floorOnly, "--", ...named], (dir) => {
|
|
26312
|
+
if (!units.hides(dir, true))
|
|
26313
|
+
for (const path of filesUnder(folder, dir, enterPastIgnores, keepNew, budget))
|
|
26089
26314
|
found.add(path);
|
|
26090
|
-
|
|
26091
|
-
|
|
26092
|
-
|
|
26315
|
+
});
|
|
26316
|
+
for (const dir of [...rules.directories].filter((path) => insideRepoUnit(path, units))) {
|
|
26317
|
+
if (walkSpent(budget))
|
|
26318
|
+
break;
|
|
26319
|
+
if (!units.hides(dir, true))
|
|
26320
|
+
for (const path of filesUnder(folder, dir, enterPastIgnores, keepNew, budget))
|
|
26321
|
+
found.add(path);
|
|
26322
|
+
}
|
|
26323
|
+
for (const path of [...rules.paths].filter((rel) => insideRepoUnit(rel, units))) {
|
|
26324
|
+
if (walkSpent(budget))
|
|
26325
|
+
break;
|
|
26326
|
+
if (lstatOrNull(join59(folder, ...path.split("/")))?.isFile() && !take(path))
|
|
26327
|
+
break;
|
|
26093
26328
|
}
|
|
26094
26329
|
}
|
|
26095
|
-
if (under
|
|
26330
|
+
if (under !== "" && insideRepoUnit(under, units) && !skip(under) && !units.hides(under, true)) {
|
|
26331
|
+
for (const path of filesUnder(folder, under, enter, keepNew, budget))
|
|
26332
|
+
found.add(path);
|
|
26333
|
+
}
|
|
26334
|
+
if (under === "" && !index.has(SPACE_INCLUDE_FILE) && existsSync47(join59(folder, SPACE_INCLUDE_FILE)))
|
|
26096
26335
|
found.add(SPACE_INCLUDE_FILE);
|
|
26097
26336
|
for (const path of found)
|
|
26098
26337
|
if (!index.has(path) && inside(path))
|
|
26099
26338
|
rows.push({ path, tracked: false, state: "new" });
|
|
26100
|
-
|
|
26339
|
+
rows.sort((a, b) => a.path < b.path ? -1 : a.path > b.path ? 1 : 0);
|
|
26340
|
+
return { rows, stopped: budget.stopped === null ? null : { reason: budget.stopped, newFiles: budget.found } };
|
|
26101
26341
|
}
|
|
26102
26342
|
function unaddressableRefusal(paths) {
|
|
26103
26343
|
const names = paths.map((path) => ` ${path}`).join(`
|
|
@@ -26115,8 +26355,8 @@ function spaceCopyBytes(bytes) {
|
|
|
26115
26355
|
}
|
|
26116
26356
|
function linkedFileInFolder(folder, relPath) {
|
|
26117
26357
|
try {
|
|
26118
|
-
const full =
|
|
26119
|
-
if (!
|
|
26358
|
+
const full = join59(folder, relPath);
|
|
26359
|
+
if (!lstatSync6(full).isSymbolicLink())
|
|
26120
26360
|
return null;
|
|
26121
26361
|
return regularFileInFolder(folder, full);
|
|
26122
26362
|
} catch {
|
|
@@ -26142,9 +26382,9 @@ function regularFileInFolder(folder, path) {
|
|
|
26142
26382
|
}
|
|
26143
26383
|
}
|
|
26144
26384
|
function placeholderTarget(folder) {
|
|
26145
|
-
const full =
|
|
26385
|
+
const full = join59(folder, SPACE_INSTRUCTIONS_FILE);
|
|
26146
26386
|
try {
|
|
26147
|
-
const stats =
|
|
26387
|
+
const stats = lstatSync6(full);
|
|
26148
26388
|
if (!stats.isFile() || stats.size === 0 || stats.size > PLACEHOLDER_MAX_CHARS * 4 + 2)
|
|
26149
26389
|
return null;
|
|
26150
26390
|
const text = readFileSync34(full, "utf-8");
|
|
@@ -26155,7 +26395,7 @@ function placeholderTarget(folder) {
|
|
|
26155
26395
|
return null;
|
|
26156
26396
|
if (posix4.isAbsolute(name) || win324.isAbsolute(name) || /^[A-Za-z]:/.test(name))
|
|
26157
26397
|
return null;
|
|
26158
|
-
const target = regularFileInFolder(folder,
|
|
26398
|
+
const target = regularFileInFolder(folder, join59(folder, name));
|
|
26159
26399
|
return target === null || target === onDiskPath(full) ? null : target;
|
|
26160
26400
|
} catch {
|
|
26161
26401
|
return null;
|
|
@@ -26182,8 +26422,8 @@ function isLinkedDocPath(folder, path, linkedDoc) {
|
|
|
26182
26422
|
if (foldName(path) !== foldName(linkedDoc))
|
|
26183
26423
|
return false;
|
|
26184
26424
|
try {
|
|
26185
|
-
const one = statSync22(
|
|
26186
|
-
const other = statSync22(
|
|
26425
|
+
const one = statSync22(join59(folder, path), { bigint: true });
|
|
26426
|
+
const other = statSync22(join59(folder, linkedDoc), { bigint: true });
|
|
26187
26427
|
return one.ino === other.ino && one.dev === other.dev;
|
|
26188
26428
|
} catch {
|
|
26189
26429
|
return false;
|
|
@@ -26196,15 +26436,15 @@ function linkedDocUnshared(folder, rel, tracked) {
|
|
|
26196
26436
|
return rel !== SPACE_INCLUDE_FILE && !isIncluded(rel, rules);
|
|
26197
26437
|
}
|
|
26198
26438
|
function spaceDocLinksOut(folder, filepath) {
|
|
26199
|
-
return filepath === SPACE_INSTRUCTIONS_FILE && lstatOrNull(
|
|
26439
|
+
return filepath === SPACE_INSTRUCTIONS_FILE && lstatOrNull(join59(folder, filepath))?.isSymbolicLink() === true && linkedFileInFolder(folder, filepath) === null;
|
|
26200
26440
|
}
|
|
26201
26441
|
function spaceDocMatchesBlob(folder, filepath, blob) {
|
|
26202
|
-
const full =
|
|
26442
|
+
const full = join59(folder, filepath);
|
|
26203
26443
|
const theirs = blob.toString("latin1").trimEnd();
|
|
26204
26444
|
const placeholder = filepath === SPACE_INSTRUCTIONS_FILE ? placeholderTarget(folder) : null;
|
|
26205
26445
|
if (placeholder !== null)
|
|
26206
26446
|
return spaceCopyBytes(readFileSync34(placeholder)).toString("latin1").trimEnd() === theirs;
|
|
26207
|
-
if (
|
|
26447
|
+
if (lstatSync6(full).isSymbolicLink()) {
|
|
26208
26448
|
const target = linkedFileInFolder(folder, filepath);
|
|
26209
26449
|
if (target === null)
|
|
26210
26450
|
return linkBlob(full).equals(blob);
|
|
@@ -26247,7 +26487,9 @@ async function planFolderChanges(folder, opts = {}) {
|
|
|
26247
26487
|
const managedInstructionPaths = new Set(agentManagedInstructionPaths());
|
|
26248
26488
|
const includeRules = readIncludeRules(folder);
|
|
26249
26489
|
const floor = buildSpaceFloorSets();
|
|
26250
|
-
const
|
|
26490
|
+
const units = repoUnits(folder, includeRules);
|
|
26491
|
+
const walked = await folderRows(folder, ignoreSets, includeRules, floor, units, opts.walkLimits ?? { files: SPACE_WALK_MAX_NEW_FILES, ms: SPACE_WALK_MAX_MS }, under);
|
|
26492
|
+
const rows = walked.rows;
|
|
26251
26493
|
const canLfs = await lfsReady();
|
|
26252
26494
|
const pointerPaths = new Set([...(await pointersAt(folder, LOCAL_MAIN)).keys(), ...(await pointersAt(folder, REMOTE_MAIN)).keys()]);
|
|
26253
26495
|
const vouchedFor = await lfsObjectVouchedFor(folder);
|
|
@@ -26264,6 +26506,8 @@ async function planFolderChanges(folder, opts = {}) {
|
|
|
26264
26506
|
for (const { path: filepath, tracked, state } of rows) {
|
|
26265
26507
|
if (hiddenFromSpace(filepath, ignoreSets, includeRules, floor, { tracked }))
|
|
26266
26508
|
continue;
|
|
26509
|
+
if (!tracked && units.hides(filepath, false))
|
|
26510
|
+
continue;
|
|
26267
26511
|
if (absentFromCheckout.has(filepath))
|
|
26268
26512
|
continue;
|
|
26269
26513
|
const gone = state === "gone";
|
|
@@ -26288,7 +26532,7 @@ async function planFolderChanges(folder, opts = {}) {
|
|
|
26288
26532
|
continue;
|
|
26289
26533
|
let size = 0;
|
|
26290
26534
|
try {
|
|
26291
|
-
size = statSync22(
|
|
26535
|
+
size = statSync22(join59(folder, filepath)).size;
|
|
26292
26536
|
} catch {}
|
|
26293
26537
|
skipped.push({ path: filepath, bytes: size, reason: "link-out" });
|
|
26294
26538
|
continue;
|
|
@@ -26314,15 +26558,15 @@ async function planFolderChanges(folder, opts = {}) {
|
|
|
26314
26558
|
let mtimeMs = 0;
|
|
26315
26559
|
let link = false;
|
|
26316
26560
|
try {
|
|
26317
|
-
const stat = statSync22(throughLink?.target ??
|
|
26561
|
+
const stat = statSync22(throughLink?.target ?? join59(folder, filepath));
|
|
26318
26562
|
bytes = stat.size;
|
|
26319
26563
|
mtimeMs = stat.mtimeMs;
|
|
26320
|
-
link =
|
|
26564
|
+
link = lstatSync6(join59(folder, filepath)).isSymbolicLink();
|
|
26321
26565
|
} catch {
|
|
26322
26566
|
continue;
|
|
26323
26567
|
}
|
|
26324
26568
|
if (!link && bytes >= LFS_POINTER_MIN_BYTES && bytes < LFS_POINTER_MAX_BYTES) {
|
|
26325
|
-
const pointer = pointerInFile(
|
|
26569
|
+
const pointer = pointerInFile(join59(folder, filepath));
|
|
26326
26570
|
if (pointer && !vouchedFor(pointer.oid)) {
|
|
26327
26571
|
skipped.push({ path: filepath, bytes, reason: "lfs-pointer" });
|
|
26328
26572
|
continue;
|
|
@@ -26331,7 +26575,7 @@ async function planFolderChanges(folder, opts = {}) {
|
|
|
26331
26575
|
let lfs = false;
|
|
26332
26576
|
if (!link && (pointerPaths.has(filepath) || bytes > SPACE_LFS_BINARY_THRESHOLD_BYTES)) {
|
|
26333
26577
|
try {
|
|
26334
|
-
lfs = pointerPaths.has(filepath) || exceedsSpaceLfsThreshold(bytes, fileHead(
|
|
26578
|
+
lfs = pointerPaths.has(filepath) || exceedsSpaceLfsThreshold(bytes, fileHead(join59(folder, filepath)));
|
|
26335
26579
|
} catch {
|
|
26336
26580
|
continue;
|
|
26337
26581
|
}
|
|
@@ -26350,14 +26594,23 @@ async function planFolderChanges(folder, opts = {}) {
|
|
|
26350
26594
|
skipped.push({ path: filepath, bytes });
|
|
26351
26595
|
continue;
|
|
26352
26596
|
}
|
|
26353
|
-
changes.push({
|
|
26597
|
+
changes.push({
|
|
26598
|
+
path: filepath,
|
|
26599
|
+
kind: tracked ? "update" : "add",
|
|
26600
|
+
bytes,
|
|
26601
|
+
mtimeMs,
|
|
26602
|
+
...conflict ? { conflict: true } : {},
|
|
26603
|
+
...walked.stopped && !tracked && filepath !== SPACE_INCLUDE_FILE ? { walkStopped: true } : {}
|
|
26604
|
+
});
|
|
26354
26605
|
addedBytes += bytes;
|
|
26355
26606
|
}
|
|
26356
26607
|
const unaddressable = changes.filter((change) => change.kind !== "remove" && unaddressableSpacePath(change.path) !== null).map((change) => change.path);
|
|
26357
26608
|
if (unaddressable.length > 0)
|
|
26358
26609
|
throw unaddressableRefusal(unaddressable.sort());
|
|
26359
|
-
const plan = { changes, skipped, addedBytes };
|
|
26610
|
+
const plan = { changes, skipped, addedBytes, ...walked.stopped ? { tooLarge: walked.stopped } : {} };
|
|
26360
26611
|
lfsPathsOfPlan.set(plan, lfsPaths);
|
|
26612
|
+
if (walked.stopped)
|
|
26613
|
+
stoppedWalkOfChanges.set(changes, walked.stopped);
|
|
26361
26614
|
return plan;
|
|
26362
26615
|
}
|
|
26363
26616
|
function heaviestShares(changes, limit = 3) {
|
|
@@ -26424,7 +26677,7 @@ function splitPlannedChanges(changes, rules) {
|
|
|
26424
26677
|
split.staging.push(change);
|
|
26425
26678
|
continue;
|
|
26426
26679
|
}
|
|
26427
|
-
if (change.conflict && !namedForSharing(change.path, shareNow)) {
|
|
26680
|
+
if ((change.conflict || change.walkStopped) && !namedForSharing(change.path, shareNow)) {
|
|
26428
26681
|
split.held.push(change.path);
|
|
26429
26682
|
if (change.mtimeMs !== undefined)
|
|
26430
26683
|
split.heldNewestMtimeMs = Math.max(split.heldNewestMtimeMs ?? 0, change.mtimeMs);
|
|
@@ -26454,7 +26707,11 @@ function waitingChanges(changes, split) {
|
|
|
26454
26707
|
state.set(path, "settling");
|
|
26455
26708
|
for (const change of split.staging)
|
|
26456
26709
|
state.set(change.path, "ready");
|
|
26457
|
-
|
|
26710
|
+
const waiting = changes.filter((c) => c.path !== SPACE_INCLUDE_FILE).map((c) => ({ path: c.path, kind: c.kind, bytes: c.bytes, state: state.get(c.path) ?? "ready" }));
|
|
26711
|
+
const stopped = stoppedWalkOfChanges.get(changes);
|
|
26712
|
+
if (stopped)
|
|
26713
|
+
markStoppedWalk(waiting, stopped);
|
|
26714
|
+
return waiting;
|
|
26458
26715
|
}
|
|
26459
26716
|
async function commitFolderChanges(folder, opts) {
|
|
26460
26717
|
const batchLimit = opts.batchBytes ?? SPACE_PUSH_BATCH_BYTES;
|
|
@@ -26518,8 +26775,8 @@ async function stageChanges(folder, changes) {
|
|
|
26518
26775
|
const staged = [];
|
|
26519
26776
|
const fromFiles = [];
|
|
26520
26777
|
for (const path of writes) {
|
|
26521
|
-
const full =
|
|
26522
|
-
const stats =
|
|
26778
|
+
const full = join59(folder, path);
|
|
26779
|
+
const stats = lstatSync6(full);
|
|
26523
26780
|
if (path === SPACE_INSTRUCTIONS_FILE && (stats.isSymbolicLink() || linked !== null)) {
|
|
26524
26781
|
if (linked === null)
|
|
26525
26782
|
continue;
|
|
@@ -26666,7 +26923,7 @@ async function leaveOutDanglingPointers(folder) {
|
|
|
26666
26923
|
}
|
|
26667
26924
|
const tipBefore = await treeEntriesAt(folder, local);
|
|
26668
26925
|
const leftOut = [...tipBefore].filter(([, entry]) => dangling.has(entry.oid)).map(([path]) => path);
|
|
26669
|
-
const scratchIndex = { GIT_INDEX_FILE:
|
|
26926
|
+
const scratchIndex = { GIT_INDEX_FILE: join59(spaceGitdir(folder), "runwork-rewrite-index") };
|
|
26670
26927
|
let parent = chain[0][1] ?? null;
|
|
26671
26928
|
let moved = false;
|
|
26672
26929
|
try {
|
|
@@ -26883,7 +27140,7 @@ function localCopyName(relPath) {
|
|
|
26883
27140
|
function preserveSkippedFiles(folder, skipped) {
|
|
26884
27141
|
const kept = [];
|
|
26885
27142
|
for (const { path } of skipped) {
|
|
26886
|
-
const from =
|
|
27143
|
+
const from = join59(folder, path);
|
|
26887
27144
|
if (!existsSync47(from))
|
|
26888
27145
|
continue;
|
|
26889
27146
|
if (lstatOrNull(from)?.isSymbolicLink())
|
|
@@ -26891,11 +27148,11 @@ function preserveSkippedFiles(folder, skipped) {
|
|
|
26891
27148
|
if (path === SPACE_INSTRUCTIONS_FILE && placeholderTarget(folder) !== null)
|
|
26892
27149
|
continue;
|
|
26893
27150
|
let candidate = localCopyName(path);
|
|
26894
|
-
for (let n = 2;existsSync47(
|
|
27151
|
+
for (let n = 2;existsSync47(join59(folder, candidate)); n++) {
|
|
26895
27152
|
candidate = localCopyName(path).replace(" (local copy)", ` (local copy ${n})`);
|
|
26896
27153
|
}
|
|
26897
27154
|
try {
|
|
26898
|
-
renameSync8(from,
|
|
27155
|
+
renameSync8(from, join59(folder, candidate));
|
|
26899
27156
|
kept.push(candidate);
|
|
26900
27157
|
} catch {}
|
|
26901
27158
|
}
|
|
@@ -26905,11 +27162,11 @@ async function stagedOids(folder, paths) {
|
|
|
26905
27162
|
const oids = new Map;
|
|
26906
27163
|
const files = [];
|
|
26907
27164
|
for (const path of paths) {
|
|
26908
|
-
const stats = lstatOrNull(
|
|
27165
|
+
const stats = lstatOrNull(join59(folder, path));
|
|
26909
27166
|
if (!stats)
|
|
26910
27167
|
continue;
|
|
26911
27168
|
if (stats.isSymbolicLink())
|
|
26912
|
-
oids.set(path, blobOid(linkBlob(
|
|
27169
|
+
oids.set(path, blobOid(linkBlob(join59(folder, path))));
|
|
26913
27170
|
else if (stats.isFile() && !path.includes(`
|
|
26914
27171
|
`))
|
|
26915
27172
|
files.push(path);
|
|
@@ -26960,8 +27217,10 @@ async function dropAlreadyInSpace(folder, plan, ref) {
|
|
|
26960
27217
|
if (change.kind !== "remove")
|
|
26961
27218
|
addedBytes += change.bytes;
|
|
26962
27219
|
}
|
|
26963
|
-
const narrowed = { changes, skipped: plan.skipped, addedBytes };
|
|
27220
|
+
const narrowed = { changes, skipped: plan.skipped, addedBytes, ...plan.tooLarge ? { tooLarge: plan.tooLarge } : {} };
|
|
26964
27221
|
lfsPathsOfPlan.set(narrowed, lfsPathsOfPlan.get(plan) ?? new Set);
|
|
27222
|
+
if (plan.tooLarge)
|
|
27223
|
+
stoppedWalkOfChanges.set(changes, plan.tooLarge);
|
|
26965
27224
|
return narrowed;
|
|
26966
27225
|
}
|
|
26967
27226
|
async function skippedInTheWay(folder, skipped) {
|
|
@@ -27070,6 +27329,8 @@ async function syncSpaceFolder(input) {
|
|
|
27070
27329
|
const firstFromSpace = await resolveOid(input.folder, LOCAL_MAIN) === null && await resolveOid(input.folder, REMOTE_MAIN) !== null;
|
|
27071
27330
|
const plan = firstFromSpace ? await dropAlreadyInSpace(input.folder, walked, REMOTE_MAIN) : walked;
|
|
27072
27331
|
measured = plan;
|
|
27332
|
+
if (plan.tooLarge)
|
|
27333
|
+
base.walkStopped = plan.tooLarge;
|
|
27073
27334
|
const holding = input.auto !== true && !askedToShare(input);
|
|
27074
27335
|
const ceiling = fetchFailure || holding ? { decision: "nothing", refusal: null, unmeasured: null } : await ceilingCheck(input, limits, plan, now);
|
|
27075
27336
|
const refused = ceiling.unmeasured !== null ? unmeasuredMessage(ceiling.unmeasured) : ceiling.refusal ? ceilingMessage(ceiling.refusal) : ceiling.lfsRefusal ?? null;
|
|
@@ -27206,7 +27467,7 @@ function rememberWaitingChanges(folder, plan, result, rules) {
|
|
|
27206
27467
|
const auto = rules.auto === true;
|
|
27207
27468
|
const committed = new Set([...result.commit.added, ...result.commit.removed]);
|
|
27208
27469
|
const waiting = waitingChanges(plan.changes, splitPlannedChanges(plan.changes, { auto, now: rules.now }));
|
|
27209
|
-
writeWaitingCache(folder, committed.size === 0 ? waiting : waiting.filter((c) => !committed.has(c.path)), { auto, now: rules.now });
|
|
27470
|
+
writeWaitingCache(folder, committed.size === 0 ? waiting : waiting.filter((c) => !committed.has(c.path)), { auto, now: rules.now, stoppedWalk: plan.tooLarge });
|
|
27210
27471
|
}
|
|
27211
27472
|
async function onlyTheIncludeList(folder, pending, base) {
|
|
27212
27473
|
if (pending.length === 0)
|
|
@@ -27296,7 +27557,7 @@ function reportHeldLinks(folder, commit, plan, links) {
|
|
|
27296
27557
|
for (const link of fresh) {
|
|
27297
27558
|
let bytes = 0;
|
|
27298
27559
|
try {
|
|
27299
|
-
const stats = statSync22(
|
|
27560
|
+
const stats = statSync22(join59(folder, link.path));
|
|
27300
27561
|
bytes = stats.size;
|
|
27301
27562
|
commit.heldNewestMtimeMs = Math.max(commit.heldNewestMtimeMs ?? 0, stats.mtimeMs);
|
|
27302
27563
|
} catch {}
|
|
@@ -27309,7 +27570,7 @@ function reportLeftOut(folder, commit, paths) {
|
|
|
27309
27570
|
const known = new Set(commit.skipped.map((skipped) => skipped.path));
|
|
27310
27571
|
for (const path of paths) {
|
|
27311
27572
|
if (!known.has(path))
|
|
27312
|
-
commit.skipped.push({ path, bytes: lstatOrNull(
|
|
27573
|
+
commit.skipped.push({ path, bytes: lstatOrNull(join59(folder, path))?.size ?? 0, reason: "lfs-pointer" });
|
|
27313
27574
|
}
|
|
27314
27575
|
commit.added = commit.added.filter((path) => !paths.includes(path));
|
|
27315
27576
|
}
|
|
@@ -27355,7 +27616,7 @@ async function fetchSpace(folder, auth) {
|
|
|
27355
27616
|
}
|
|
27356
27617
|
}
|
|
27357
27618
|
async function pruneLfsObjects(folder) {
|
|
27358
|
-
const objects =
|
|
27619
|
+
const objects = join59(spaceGitdir(folder), "lfs", "objects");
|
|
27359
27620
|
try {
|
|
27360
27621
|
if (!existsSync47(objects) || readdirSync22(objects).length === 0)
|
|
27361
27622
|
return;
|
|
@@ -27431,7 +27692,7 @@ ${err.message}` : err.message;
|
|
|
27431
27692
|
return err.message;
|
|
27432
27693
|
}
|
|
27433
27694
|
var SPACE_BRANCH = "main", REMOTE_MAIN, LOCAL_MAIN, BATCH_REF = "refs/runwork-space/batch", DEFAULT_SPACE_REPO_LIMITS, HISTORY_MARK_KEY = "runwork.spacehistory", HISTORY_MARK = "git", REGULAR_FILE_MODE = 33188, UNWRITABLE_RECORD = "unwritable-paths.json", SYMLINK_MODE = 40960, INDEX_ONLY, UnrecordedPathsError, POINTER_MIN_BYTES, POINTER_MAX_BYTES, pointersByCommit, ATTRIBUTES_HEADER = `# Written by Runwork on every sync: the paths this space keeps in Git LFS. Edits here do not last.
|
|
27434
|
-
`, NOT_IN_SPACE_RECORD = "lfs-not-in-space.json", NOT_IN_SPACE_KEPT = 1000, HELD_BRIEF_RECORD = "linked-brief-held.json", LFS_UNAVAILABLE_SENTENCE, LFS_POINTER_SKIP_SENTENCE = "This file looks like a Git LFS pointer to a file that is not on this computer; run `git lfs pull` in that project to get the real file, or exclude it.", LINK_OUT_SKIP_SENTENCE = "This is a link to a file outside this folder, or to nothing, so it is not shared; put the file itself here to share it.", LINK_UNSHARED_SKIP_SENTENCE = "This is a link to a file this folder does not share, so it is not shared either; link it to a file that is shared, or put the brief itself here.", EXCLUDE_HEADER = `# Written by Runwork on every sync: what git does not look into for this space. Edits here do not last.
|
|
27695
|
+
`, NOT_IN_SPACE_RECORD = "lfs-not-in-space.json", NOT_IN_SPACE_KEPT = 1000, HELD_BRIEF_RECORD = "linked-brief-held.json", LFS_UNAVAILABLE_SENTENCE, LFS_POINTER_SKIP_SENTENCE = "This file looks like a Git LFS pointer to a file that is not on this computer; run `git lfs pull` in that project to get the real file, or exclude it.", LINK_OUT_SKIP_SENTENCE = "This is a link to a file outside this folder, or to nothing, so it is not shared; put the file itself here to share it.", LINK_UNSHARED_SKIP_SENTENCE = "This is a link to a file this folder does not share, so it is not shared either; link it to a file that is shared, or put the brief itself here.", stoppedWalkOfChanges, EXCLUDE_HEADER = `# Written by Runwork on every sync: what git does not look into for this space. Edits here do not last.
|
|
27435
27696
|
`, PATHSPEC_BUDGET = 16000, PLACEHOLDER_MAX_CHARS = 255, lfsPathsOfPlan, REPEATS_THE_FOLDER = 0.95, MESSAGE_VERBS, NAMES_PER_VERB = 3, PART_SUFFIX, refMemos, REF_MOVING_COMMANDS, BAD_KEY_SENTENCE;
|
|
27436
27697
|
var init_space_repo = __esm(async () => {
|
|
27437
27698
|
init_limits();
|
|
@@ -27451,7 +27712,8 @@ var init_space_repo = __esm(async () => {
|
|
|
27451
27712
|
init_space_git();
|
|
27452
27713
|
await __promiseAll([
|
|
27453
27714
|
init_space_sync_rules(),
|
|
27454
|
-
init_waiting_cache()
|
|
27715
|
+
init_waiting_cache(),
|
|
27716
|
+
init_nested_repos()
|
|
27455
27717
|
]);
|
|
27456
27718
|
REMOTE_MAIN = `refs/remotes/${RUNWORK_REMOTE}/${SPACE_BRANCH}`;
|
|
27457
27719
|
LOCAL_MAIN = `refs/heads/${SPACE_BRANCH}`;
|
|
@@ -27467,6 +27729,7 @@ var init_space_repo = __esm(async () => {
|
|
|
27467
27729
|
POINTER_MAX_BYTES = LFS_POINTER_MAX_BYTES - 1;
|
|
27468
27730
|
pointersByCommit = new Map;
|
|
27469
27731
|
LFS_UNAVAILABLE_SENTENCE = `Runwork's git is needed to share files over ${formatBytes(SPACE_LFS_BINARY_THRESHOLD_BYTES)}; run \`runwork git install\`, or unset RUNWORK_GIT.`;
|
|
27732
|
+
stoppedWalkOfChanges = new WeakMap;
|
|
27470
27733
|
lfsPathsOfPlan = new WeakMap;
|
|
27471
27734
|
MESSAGE_VERBS = [
|
|
27472
27735
|
{ kind: "add", verb: "add" },
|
|
@@ -27480,8 +27743,8 @@ var init_space_repo = __esm(async () => {
|
|
|
27480
27743
|
});
|
|
27481
27744
|
|
|
27482
27745
|
// src/sync/space-instructions.ts
|
|
27483
|
-
import { existsSync as existsSync48, lstatSync as
|
|
27484
|
-
import { join as
|
|
27746
|
+
import { existsSync as existsSync48, lstatSync as lstatSync7, realpathSync as realpathSync7 } from "fs";
|
|
27747
|
+
import { join as join60 } from "path";
|
|
27485
27748
|
async function applyToFolder(folder, present, adapters, failed) {
|
|
27486
27749
|
for (const adapter of adapters) {
|
|
27487
27750
|
if (!adapter.linkSpaceInstructions)
|
|
@@ -27494,10 +27757,10 @@ async function applyToFolder(folder, present, adapters, failed) {
|
|
|
27494
27757
|
}
|
|
27495
27758
|
}
|
|
27496
27759
|
function hasInstructions(folder) {
|
|
27497
|
-
return existsSync48(
|
|
27760
|
+
return existsSync48(join60(folder, SPACE_INSTRUCTIONS_FILE));
|
|
27498
27761
|
}
|
|
27499
27762
|
function writeSpaceFolderDoc(folder, mapping, workspaceName) {
|
|
27500
|
-
const own =
|
|
27763
|
+
const own = join60(folder, SPACE_INSTRUCTIONS_FILE);
|
|
27501
27764
|
let file = own;
|
|
27502
27765
|
let root = folder;
|
|
27503
27766
|
let shared = true;
|
|
@@ -27507,7 +27770,7 @@ function writeSpaceFolderDoc(folder, mapping, workspaceName) {
|
|
|
27507
27770
|
file = linked.target;
|
|
27508
27771
|
root = realpathSync7.native(folder);
|
|
27509
27772
|
shared = !linkedDocUnshared(folder, linked.rel, false);
|
|
27510
|
-
} else if (
|
|
27773
|
+
} else if (lstatSync7(own).isSymbolicLink()) {
|
|
27511
27774
|
return;
|
|
27512
27775
|
}
|
|
27513
27776
|
} catch {
|
|
@@ -27559,7 +27822,7 @@ var init_space_instructions = __esm(async () => {
|
|
|
27559
27822
|
|
|
27560
27823
|
// src/git/preflight.ts
|
|
27561
27824
|
import { existsSync as existsSync49 } from "fs";
|
|
27562
|
-
import { join as
|
|
27825
|
+
import { join as join61, resolve as resolve12 } from "path";
|
|
27563
27826
|
function buildMissingGitMessage(commandName, probe) {
|
|
27564
27827
|
const lines = [
|
|
27565
27828
|
`Git is required to run \`runwork ${commandName}\`, but it was not found on PATH.`,
|
|
@@ -27580,7 +27843,7 @@ function buildMissingGitMessage(commandName, probe) {
|
|
|
27580
27843
|
`);
|
|
27581
27844
|
}
|
|
27582
27845
|
function hasOwnRepo(cwd) {
|
|
27583
|
-
if (!existsSync49(
|
|
27846
|
+
if (!existsSync49(join61(cwd, ".git")))
|
|
27584
27847
|
return false;
|
|
27585
27848
|
let prefix;
|
|
27586
27849
|
try {
|
|
@@ -27731,7 +27994,7 @@ var init_identity2 = __esm(() => {
|
|
|
27731
27994
|
// src/sync/space-folders.ts
|
|
27732
27995
|
import { existsSync as existsSync50 } from "node:fs";
|
|
27733
27996
|
import { homedir as homedir39 } from "node:os";
|
|
27734
|
-
import { join as
|
|
27997
|
+
import { join as join62 } from "node:path";
|
|
27735
27998
|
async function syncSpaceFolders(input) {
|
|
27736
27999
|
const author = pickIdentity(input.credentials);
|
|
27737
28000
|
const wanted = input.folder ? normalizeFolder(input.folder) : null;
|
|
@@ -27846,7 +28109,7 @@ function confirmFolderHead(client, mapping, result, now) {
|
|
|
27846
28109
|
const head = refInFiles(gitdir, `refs/remotes/${RUNWORK_REMOTE}/${SPACE_BRANCH}`);
|
|
27847
28110
|
if (!head || refInFiles(gitdir, `refs/heads/${SPACE_BRANCH}`) !== head)
|
|
27848
28111
|
return;
|
|
27849
|
-
const file =
|
|
28112
|
+
const file = join62(gitdir, CONFIRMED_RECORD);
|
|
27850
28113
|
const last = readJsonOrNull(file);
|
|
27851
28114
|
if (last?.spaceId === mapping.spaceId && last.confirmedOid === head)
|
|
27852
28115
|
return;
|
|
@@ -27888,7 +28151,7 @@ function isAccessRemoved(text) {
|
|
|
27888
28151
|
return ACCESS_REMOVED.test(text) && text.includes(NOTHING_CHANGED);
|
|
27889
28152
|
}
|
|
27890
28153
|
function setupStatePath() {
|
|
27891
|
-
return
|
|
28154
|
+
return join62(homedir39(), ".runwork", "setup.json");
|
|
27892
28155
|
}
|
|
27893
28156
|
function isNotVisibleFailure(result) {
|
|
27894
28157
|
return !result.refused && !!result.error && isSpaceNotVisible(result.error);
|
|
@@ -28042,6 +28305,8 @@ function describeFolderSync(r) {
|
|
|
28042
28305
|
parts.push("folder updated from the space");
|
|
28043
28306
|
if (r.commit.held.length)
|
|
28044
28307
|
parts.push(`${r.commit.held.length} change(s) waiting for you to share`);
|
|
28308
|
+
if (r.walkStopped)
|
|
28309
|
+
parts.push(walkStoppedSentence(r.walkStopped));
|
|
28045
28310
|
if (r.commit.settling.length)
|
|
28046
28311
|
parts.push(`${r.commit.settling.length} file(s) still being edited`);
|
|
28047
28312
|
const tooLarge = r.commit.skipped.filter((s) => s.reason === undefined).length;
|
|
@@ -28295,7 +28560,7 @@ var init_restart_stamp = __esm(() => {
|
|
|
28295
28560
|
// src/commands/sync.ts
|
|
28296
28561
|
import { Command } from "commander";
|
|
28297
28562
|
import { readFileSync as readFileSync35, existsSync as existsSync51 } from "fs";
|
|
28298
|
-
import { join as
|
|
28563
|
+
import { join as join63 } from "path";
|
|
28299
28564
|
import { homedir as homedir40 } from "os";
|
|
28300
28565
|
function syncScopes(state) {
|
|
28301
28566
|
return state.scope === "both" ? ["project", "user"] : [state.scope];
|
|
@@ -28402,13 +28667,13 @@ function readLocalSkills(state) {
|
|
|
28402
28667
|
if (!baseDir)
|
|
28403
28668
|
continue;
|
|
28404
28669
|
for (const skillName of skillNames) {
|
|
28405
|
-
const skillMdPath =
|
|
28670
|
+
const skillMdPath = join63(baseDir, skillName, "SKILL.md");
|
|
28406
28671
|
if (existsSync51(skillMdPath)) {
|
|
28407
28672
|
results.push({ name: skillName, content: readFileSync35(skillMdPath, "utf-8") });
|
|
28408
28673
|
continue;
|
|
28409
28674
|
}
|
|
28410
28675
|
const filename = skillName.toLowerCase().replace(/[^a-z0-9]+/g, "-");
|
|
28411
|
-
const flatPath =
|
|
28676
|
+
const flatPath = join63(baseDir, `${filename}.md`);
|
|
28412
28677
|
if (existsSync51(flatPath)) {
|
|
28413
28678
|
results.push({ name: skillName, content: readFileSync35(flatPath, "utf-8") });
|
|
28414
28679
|
}
|
|
@@ -28877,59 +29142,63 @@ This account is not a member of "${state.workspaceName || state.workspaceId}".`)
|
|
|
28877
29142
|
}
|
|
28878
29143
|
}
|
|
28879
29144
|
}
|
|
28880
|
-
|
|
28881
|
-
|
|
28882
|
-
|
|
28883
|
-
|
|
28884
|
-
|
|
28885
|
-
|
|
28886
|
-
|
|
28887
|
-
|
|
28888
|
-
|
|
28889
|
-
|
|
28890
|
-
|
|
28891
|
-
|
|
28892
|
-
|
|
28893
|
-
|
|
28894
|
-
|
|
28895
|
-
|
|
28896
|
-
|
|
28897
|
-
|
|
28898
|
-
|
|
28899
|
-
|
|
28900
|
-
|
|
29145
|
+
if (!opts.toolsOnly) {
|
|
29146
|
+
try {
|
|
29147
|
+
const mappings = loadSpaceMappings().mappings.filter((m) => m.workspaceId === state.workspaceId);
|
|
29148
|
+
const previousFolders = state.spaceInstructionFolders ?? [];
|
|
29149
|
+
if (mappings.length > 0 || previousFolders.length > 0) {
|
|
29150
|
+
const result = await syncSpaceInstructions({
|
|
29151
|
+
adapters: adapters.filter((a) => !isConnectOnlyAgent(getRegistryAgent(a.slug))),
|
|
29152
|
+
mappings,
|
|
29153
|
+
previousFolders
|
|
29154
|
+
});
|
|
29155
|
+
state.spaceInstructionFolders = result.folders;
|
|
29156
|
+
for (const failure of result.failed) {
|
|
29157
|
+
instructionFailedAdapters.add(failure.agent);
|
|
29158
|
+
console.warn(` [${failure.agent}] Failed to link space instructions in ${failure.folder}: ${failure.error}`);
|
|
29159
|
+
}
|
|
29160
|
+
if (result.linked > 0 || result.unlinked > 0 || result.cleaned > 0) {
|
|
29161
|
+
const parts = [`${result.linked} mapped folder(s) linked`];
|
|
29162
|
+
if (result.unlinked > 0)
|
|
29163
|
+
parts.push(`${result.unlinked} waiting for the space's instructions`);
|
|
29164
|
+
if (result.cleaned > 0)
|
|
29165
|
+
parts.push(`${result.cleaned} cleaned`);
|
|
29166
|
+
vlog(` Space instructions: ${parts.join(", ")}`);
|
|
29167
|
+
}
|
|
28901
29168
|
}
|
|
29169
|
+
} catch (err) {
|
|
29170
|
+
console.warn(` Space instructions skipped: ${err instanceof Error ? err.message : err}`);
|
|
28902
29171
|
}
|
|
28903
|
-
} catch (err) {
|
|
28904
|
-
console.warn(` Space instructions skipped: ${err instanceof Error ? err.message : err}`);
|
|
28905
29172
|
}
|
|
28906
|
-
|
|
28907
|
-
|
|
28908
|
-
|
|
28909
|
-
|
|
28910
|
-
|
|
28911
|
-
|
|
28912
|
-
|
|
28913
|
-
|
|
28914
|
-
|
|
28915
|
-
|
|
28916
|
-
|
|
28917
|
-
|
|
28918
|
-
|
|
28919
|
-
|
|
28920
|
-
|
|
28921
|
-
|
|
28922
|
-
|
|
28923
|
-
|
|
28924
|
-
|
|
28925
|
-
|
|
28926
|
-
|
|
28927
|
-
|
|
28928
|
-
|
|
28929
|
-
|
|
29173
|
+
if (!opts.toolsOnly) {
|
|
29174
|
+
try {
|
|
29175
|
+
const mappings = loadSpaceMappings().mappings.filter((m) => m.workspaceId === state.workspaceId);
|
|
29176
|
+
if (mappings.length > 0) {
|
|
29177
|
+
await ensureGitForCommand("sync", {
|
|
29178
|
+
exit: () => {
|
|
29179
|
+
throw new Error("there is no git on this computer to sync them with");
|
|
29180
|
+
}
|
|
29181
|
+
});
|
|
29182
|
+
const folders = await syncSpaceFolders({
|
|
29183
|
+
client,
|
|
29184
|
+
credentials,
|
|
29185
|
+
workspaceId: state.workspaceId,
|
|
29186
|
+
mappings,
|
|
29187
|
+
onFolder: (r) => {
|
|
29188
|
+
const line = ` ${folderSyncLine(r.folder, describeFolderSync(r))}`;
|
|
29189
|
+
if (r.error || r.refused)
|
|
29190
|
+
console.warn(line);
|
|
29191
|
+
else
|
|
29192
|
+
vlog(line);
|
|
29193
|
+
}
|
|
29194
|
+
});
|
|
29195
|
+
state.lastSpaceFolders = folders.lastSpaceFolders;
|
|
29196
|
+
for (const f of folders.missing)
|
|
29197
|
+
vlog(` Space folder ${f} is mapped but missing; skipped`);
|
|
29198
|
+
}
|
|
29199
|
+
} catch (err) {
|
|
29200
|
+
console.warn(` Space folders skipped: ${err instanceof Error ? err.message : err}`);
|
|
28930
29201
|
}
|
|
28931
|
-
} catch (err) {
|
|
28932
|
-
console.warn(` Space folders skipped: ${err instanceof Error ? err.message : err}`);
|
|
28933
29202
|
}
|
|
28934
29203
|
if (agentConfigs) {
|
|
28935
29204
|
for (const adapter of adapters) {
|
|
@@ -29043,7 +29312,7 @@ This account is not a member of "${state.workspaceName || state.workspaceId}".`)
|
|
|
29043
29312
|
}
|
|
29044
29313
|
for (const adapter of adapters) {
|
|
29045
29314
|
if (adapter.registerDesktopWorkspace) {
|
|
29046
|
-
const runworkDir =
|
|
29315
|
+
const runworkDir = join63(homedir40(), ".runwork");
|
|
29047
29316
|
const result = adapter.registerDesktopWorkspace(runworkDir, "Runwork");
|
|
29048
29317
|
if (result === "written") {
|
|
29049
29318
|
vlog(` [${adapter.name}] Registered workspace in the desktop app`);
|
|
@@ -29143,40 +29412,42 @@ This account is not a member of "${state.workspaceName || state.workspaceId}".`)
|
|
|
29143
29412
|
delete mergedHashes[kept.name];
|
|
29144
29413
|
state.skillHashes = mergedHashes;
|
|
29145
29414
|
writeJsonAtomic(statePath, state);
|
|
29146
|
-
|
|
29147
|
-
|
|
29148
|
-
|
|
29149
|
-
|
|
29150
|
-
|
|
29151
|
-
|
|
29152
|
-
|
|
29153
|
-
|
|
29154
|
-
|
|
29155
|
-
|
|
29156
|
-
|
|
29157
|
-
|
|
29158
|
-
|
|
29159
|
-
|
|
29160
|
-
|
|
29161
|
-
|
|
29162
|
-
|
|
29163
|
-
|
|
29164
|
-
|
|
29165
|
-
|
|
29166
|
-
|
|
29167
|
-
|
|
29168
|
-
|
|
29169
|
-
|
|
29170
|
-
|
|
29171
|
-
|
|
29172
|
-
|
|
29173
|
-
|
|
29174
|
-
|
|
29175
|
-
|
|
29176
|
-
|
|
29415
|
+
if (!opts.toolsOnly) {
|
|
29416
|
+
try {
|
|
29417
|
+
const telemetryNow = new Date().toISOString();
|
|
29418
|
+
await uploadTelemetryOutbox(state.workspaceId, async (outbox, batch) => {
|
|
29419
|
+
if (batch > 0) {
|
|
29420
|
+
await client.reportTelemetry(state.workspaceId, outbox.map((e) => e.event));
|
|
29421
|
+
return;
|
|
29422
|
+
}
|
|
29423
|
+
const telemetry = await collectTelemetryEvents({
|
|
29424
|
+
adapters,
|
|
29425
|
+
state,
|
|
29426
|
+
since: resolveTelemetrySince(state, Date.parse(telemetryNow)),
|
|
29427
|
+
syncedSkillsCount: remoteSkills.length,
|
|
29428
|
+
syncedMcpServersCount: mcpEntries.length,
|
|
29429
|
+
teamInstructionsApplied,
|
|
29430
|
+
agentConfigsApplied,
|
|
29431
|
+
outboxEvents: outbox.map((e) => e.event),
|
|
29432
|
+
now: telemetryNow
|
|
29433
|
+
});
|
|
29434
|
+
if (opts.verbose)
|
|
29435
|
+
printTelemetryVerbose(telemetry);
|
|
29436
|
+
await client.reportTelemetry(state.workspaceId, telemetry.events);
|
|
29437
|
+
state.lastTelemetryAt = telemetryNow;
|
|
29438
|
+
if (telemetry.healthReported) {
|
|
29439
|
+
state.lastHealthReportAt = new Date().toISOString();
|
|
29440
|
+
}
|
|
29441
|
+
writeJsonAtomic(statePath, state);
|
|
29442
|
+
updateWorkspaceRecord(state.workspaceId, {
|
|
29443
|
+
workspaceName: state.workspaceName || undefined,
|
|
29444
|
+
workspaceSlug: state.workspaceSlug,
|
|
29445
|
+
lastTelemetryAt: state.lastTelemetryAt,
|
|
29446
|
+
lastHealthReportAt: state.lastHealthReportAt
|
|
29447
|
+
});
|
|
29177
29448
|
});
|
|
29178
|
-
}
|
|
29179
|
-
}
|
|
29449
|
+
} catch {}
|
|
29450
|
+
}
|
|
29180
29451
|
const failedNote = summary.adaptersFailed > 0 ? ` (${summary.adaptersFailed} failed)` : "";
|
|
29181
29452
|
if (isVerbose()) {
|
|
29182
29453
|
const summaryParts = [];
|
|
@@ -29195,13 +29466,15 @@ This account is not a member of "${state.workspaceName || state.workspaceId}".`)
|
|
|
29195
29466
|
console.log(`
|
|
29196
29467
|
${summary.adaptersProcessed} agent${summary.adaptersProcessed === 1 ? "" : "s"} synced${failedNote}.`);
|
|
29197
29468
|
}
|
|
29198
|
-
|
|
29199
|
-
|
|
29200
|
-
|
|
29201
|
-
|
|
29202
|
-
|
|
29203
|
-
|
|
29204
|
-
|
|
29469
|
+
if (!opts.toolsOnly) {
|
|
29470
|
+
try {
|
|
29471
|
+
const cadence = loadCadenceState();
|
|
29472
|
+
const lastMs = cadence.lastReflectedAt ? new Date(cadence.lastReflectedAt).getTime() : 0;
|
|
29473
|
+
if (cadence.enabled && (Date.now() - lastMs) / 3600000 >= COOLDOWN_HOURS) {
|
|
29474
|
+
console.log("\n Reflection is due. Run `runwork reflect` to surface patterns from your recent work.");
|
|
29475
|
+
}
|
|
29476
|
+
} catch {}
|
|
29477
|
+
}
|
|
29205
29478
|
return { needsConnect: toolKeys.needsConnect, revoked: toolKeys.revoked, blocked: toolKeys.blocked };
|
|
29206
29479
|
}
|
|
29207
29480
|
async function runSyncCommand(opts) {
|
|
@@ -29586,7 +29859,8 @@ Syncing workspace data...
|
|
|
29586
29859
|
pullOnly: true,
|
|
29587
29860
|
yes: true,
|
|
29588
29861
|
prefer: "remote",
|
|
29589
|
-
initialSetup: true
|
|
29862
|
+
initialSetup: true,
|
|
29863
|
+
toolsOnly: !!opts.connected
|
|
29590
29864
|
}));
|
|
29591
29865
|
}
|
|
29592
29866
|
console.log("\nSetup complete. Run `runwork sync` anytime to refresh.");
|
|
@@ -29783,7 +30057,7 @@ async function configureTools(adapters, refused, credentials) {
|
|
|
29783
30057
|
state.excludedAgents = [...new Set([...(state.excludedAgents ?? []).filter((slug) => !slugs.includes(slug)), ...left])];
|
|
29784
30058
|
writeJsonAtomic(path, state);
|
|
29785
30059
|
if (adapters.length > 0)
|
|
29786
|
-
reports.push(await syncFromState(state, path, credentials, { dryRun: false, pullOnly: true, yes: true, prefer: "remote" }));
|
|
30060
|
+
reports.push(await syncFromState(state, path, credentials, { dryRun: false, pullOnly: true, yes: true, prefer: "remote", toolsOnly: true }));
|
|
29787
30061
|
}
|
|
29788
30062
|
return mergeSyncReports(reports);
|
|
29789
30063
|
}
|
|
@@ -30049,7 +30323,7 @@ var init_repo_config = __esm(() => {
|
|
|
30049
30323
|
// src/template/manifest.ts
|
|
30050
30324
|
import { createHash as createHash7 } from "crypto";
|
|
30051
30325
|
import { readFileSync as readFileSync36, writeFileSync as writeFileSync25, existsSync as existsSync52, readdirSync as readdirSync23, mkdirSync as mkdirSync26 } from "fs";
|
|
30052
|
-
import { join as
|
|
30326
|
+
import { join as join64, relative as relative8, sep as sep10 } from "path";
|
|
30053
30327
|
function sha256(data) {
|
|
30054
30328
|
return "sha256:" + createHash7("sha256").update(data).digest("hex");
|
|
30055
30329
|
}
|
|
@@ -30066,7 +30340,7 @@ function walkDir(dir, base, sets) {
|
|
|
30066
30340
|
if (dotIndex >= 0 && sets.extensions.has(entry.name.slice(dotIndex)))
|
|
30067
30341
|
continue;
|
|
30068
30342
|
}
|
|
30069
|
-
const fullPath =
|
|
30343
|
+
const fullPath = join64(dir, entry.name);
|
|
30070
30344
|
if (entry.isDirectory()) {
|
|
30071
30345
|
results.push(...walkDir(fullPath, base, sets));
|
|
30072
30346
|
} else if (entry.isFile()) {
|
|
@@ -30080,20 +30354,20 @@ async function generateManifest(dir) {
|
|
|
30080
30354
|
const sets = buildIgnoreSets(dir);
|
|
30081
30355
|
const allFiles = walkDir(dir, dir, sets);
|
|
30082
30356
|
for (const relPath of allFiles) {
|
|
30083
|
-
const content = readFileSync36(
|
|
30357
|
+
const content = readFileSync36(join64(dir, relPath));
|
|
30084
30358
|
files[relPath] = sha256(content);
|
|
30085
30359
|
}
|
|
30086
30360
|
return { version: 1, files };
|
|
30087
30361
|
}
|
|
30088
30362
|
async function saveManifest(dir, manifest) {
|
|
30089
|
-
const manifestDir =
|
|
30363
|
+
const manifestDir = join64(dir, ".runwork");
|
|
30090
30364
|
if (!existsSync52(manifestDir)) {
|
|
30091
30365
|
mkdirSync26(manifestDir, { recursive: true });
|
|
30092
30366
|
}
|
|
30093
|
-
writeFileSync25(
|
|
30367
|
+
writeFileSync25(join64(manifestDir, "template-manifest.json"), JSON.stringify(manifest, null, 2));
|
|
30094
30368
|
}
|
|
30095
30369
|
function loadManifestSync(dir) {
|
|
30096
|
-
const manifestPath =
|
|
30370
|
+
const manifestPath = join64(dir, ".runwork", "template-manifest.json");
|
|
30097
30371
|
if (!existsSync52(manifestPath))
|
|
30098
30372
|
return null;
|
|
30099
30373
|
try {
|
|
@@ -30107,7 +30381,7 @@ function isPristineTemplateFile(dir, relPath, manifest) {
|
|
|
30107
30381
|
if (!expectedHash)
|
|
30108
30382
|
return false;
|
|
30109
30383
|
try {
|
|
30110
|
-
return sha256(readFileSync36(
|
|
30384
|
+
return sha256(readFileSync36(join64(dir, relPath))) === expectedHash;
|
|
30111
30385
|
} catch {
|
|
30112
30386
|
return false;
|
|
30113
30387
|
}
|
|
@@ -30120,7 +30394,7 @@ function normalizeManifest(manifest) {
|
|
|
30120
30394
|
return { ...manifest, files };
|
|
30121
30395
|
}
|
|
30122
30396
|
async function loadManifest(dir) {
|
|
30123
|
-
const manifestPath =
|
|
30397
|
+
const manifestPath = join64(dir, ".runwork", "template-manifest.json");
|
|
30124
30398
|
if (!existsSync52(manifestPath))
|
|
30125
30399
|
return null;
|
|
30126
30400
|
try {
|
|
@@ -30152,7 +30426,7 @@ async function detectUserEdits(dir, manifest) {
|
|
|
30152
30426
|
continue;
|
|
30153
30427
|
const expectedHash = manifest.files[relPath];
|
|
30154
30428
|
if (expectedHash) {
|
|
30155
|
-
const content = readFileSync36(
|
|
30429
|
+
const content = readFileSync36(join64(dir, relPath));
|
|
30156
30430
|
if (sha256(content) === expectedHash)
|
|
30157
30431
|
continue;
|
|
30158
30432
|
}
|
|
@@ -30174,7 +30448,7 @@ async function detectUserEdits(dir, manifest) {
|
|
|
30174
30448
|
continue;
|
|
30175
30449
|
if (trackedFiles.has(relPath))
|
|
30176
30450
|
continue;
|
|
30177
|
-
const filePath =
|
|
30451
|
+
const filePath = join64(dir, relPath);
|
|
30178
30452
|
try {
|
|
30179
30453
|
const content = readFileSync36(filePath);
|
|
30180
30454
|
if (sha256(content) !== expectedHash) {
|
|
@@ -30628,9 +30902,9 @@ var init_session = __esm(() => {
|
|
|
30628
30902
|
// src/apps/checkouts.ts
|
|
30629
30903
|
import { existsSync as existsSync54, readdirSync as readdirSync24, readFileSync as readFileSync38 } from "fs";
|
|
30630
30904
|
import { homedir as homedir42 } from "os";
|
|
30631
|
-
import { join as
|
|
30905
|
+
import { join as join66 } from "path";
|
|
30632
30906
|
function appCheckoutsPath() {
|
|
30633
|
-
return
|
|
30907
|
+
return join66(homedir42(), ".runwork", APP_CHECKOUTS_FILE);
|
|
30634
30908
|
}
|
|
30635
30909
|
function readIndex() {
|
|
30636
30910
|
try {
|
|
@@ -30654,7 +30928,7 @@ function recordAppCheckout(dir, appId) {
|
|
|
30654
30928
|
}
|
|
30655
30929
|
function subdirectories(dir) {
|
|
30656
30930
|
try {
|
|
30657
|
-
return readdirSync24(dir, { withFileTypes: true }).filter((entry) => entry.isDirectory()).map((entry) =>
|
|
30931
|
+
return readdirSync24(dir, { withFileTypes: true }).filter((entry) => entry.isDirectory()).map((entry) => join66(dir, entry.name));
|
|
30658
30932
|
} catch {
|
|
30659
30933
|
return [];
|
|
30660
30934
|
}
|
|
@@ -30664,11 +30938,11 @@ function candidateFolders() {
|
|
|
30664
30938
|
for (const mapping of loadSpaceMappings().mappings) {
|
|
30665
30939
|
candidates.push(mapping.folder, ...subdirectories(mapping.folder));
|
|
30666
30940
|
}
|
|
30667
|
-
candidates.push(...subdirectories(
|
|
30941
|
+
candidates.push(...subdirectories(join66(homedir42(), ".runwork", "apps")));
|
|
30668
30942
|
return candidates;
|
|
30669
30943
|
}
|
|
30670
30944
|
function checkoutAt(dir) {
|
|
30671
|
-
const file =
|
|
30945
|
+
const file = join66(dir, RUNWORK_CONFIG_FILE);
|
|
30672
30946
|
if (!existsSync54(file))
|
|
30673
30947
|
return null;
|
|
30674
30948
|
try {
|
|
@@ -30708,10 +30982,10 @@ var init_checkouts = __esm(async () => {
|
|
|
30708
30982
|
// src/commands/init.ts
|
|
30709
30983
|
import { Command as Command5 } from "commander";
|
|
30710
30984
|
import { writeFileSync as writeFileSync27, existsSync as existsSync55, mkdirSync as mkdirSync28 } from "fs";
|
|
30711
|
-
import { join as
|
|
30985
|
+
import { join as join67, resolve as resolve13 } from "path";
|
|
30712
30986
|
import { homedir as homedir43 } from "os";
|
|
30713
30987
|
function defaultAppsDir() {
|
|
30714
|
-
return
|
|
30988
|
+
return join67(homedir43(), ".runwork", "apps");
|
|
30715
30989
|
}
|
|
30716
30990
|
async function execInit(client, appName, workspace, options = {}, creds) {
|
|
30717
30991
|
const app = await client.initApp(workspace.id, appName, options.space?.id);
|
|
@@ -30720,7 +30994,7 @@ async function execInit(client, appName, workspace, options = {}, creds) {
|
|
|
30720
30994
|
if (!options.here && !existsSync55(parentDir)) {
|
|
30721
30995
|
mkdirSync28(parentDir, { recursive: true });
|
|
30722
30996
|
}
|
|
30723
|
-
const dir =
|
|
30997
|
+
const dir = join67(parentDir, slug);
|
|
30724
30998
|
if (existsSync55(dir)) {
|
|
30725
30999
|
console.error(`Directory "${dir}" already exists.`);
|
|
30726
31000
|
process.exit(1);
|
|
@@ -30746,9 +31020,9 @@ async function execInit(client, appName, workspace, options = {}, creds) {
|
|
|
30746
31020
|
appId: app.id,
|
|
30747
31021
|
appName: app.name
|
|
30748
31022
|
};
|
|
30749
|
-
writeFileSync27(
|
|
31023
|
+
writeFileSync27(join67(dir, ".runwork.json"), JSON.stringify(config, null, 2));
|
|
30750
31024
|
recordAppCheckout(dir, app.id);
|
|
30751
|
-
if (!existsSync55(
|
|
31025
|
+
if (!existsSync55(join67(dir, ".git"))) {
|
|
30752
31026
|
try {
|
|
30753
31027
|
execFileSync5("git", ["init"], { cwd: dir, stdio: "pipe" });
|
|
30754
31028
|
} catch (err) {
|
|
@@ -30766,8 +31040,8 @@ async function execInit(client, appName, workspace, options = {}, creds) {
|
|
|
30766
31040
|
} catch {
|
|
30767
31041
|
execFileSync5("git", ["remote", "set-url", "runwork", remoteUrl], { cwd: dir, stdio: "pipe" });
|
|
30768
31042
|
}
|
|
30769
|
-
if (!existsSync55(
|
|
30770
|
-
writeFileSync27(
|
|
31043
|
+
if (!existsSync55(join67(dir, ".gitignore"))) {
|
|
31044
|
+
writeFileSync27(join67(dir, ".gitignore"), buildInitialGitignore());
|
|
30771
31045
|
}
|
|
30772
31046
|
execFileSync5("git", ["add", "--", ".runwork.json", ".gitignore"], { cwd: dir, stdio: "pipe" });
|
|
30773
31047
|
try {
|
|
@@ -30888,8 +31162,8 @@ var init_init = __esm(async () => {
|
|
|
30888
31162
|
|
|
30889
31163
|
// src/commands/clone.ts
|
|
30890
31164
|
import { Command as Command6 } from "commander";
|
|
30891
|
-
import { writeFileSync as writeFileSync28, mkdirSync as mkdirSync29, existsSync as existsSync56, lstatSync as
|
|
30892
|
-
import { dirname as dirname16, join as
|
|
31165
|
+
import { writeFileSync as writeFileSync28, mkdirSync as mkdirSync29, existsSync as existsSync56, lstatSync as lstatSync8, readdirSync as readdirSync25, readFileSync as readFileSync39, statSync as statSync23 } from "fs";
|
|
31166
|
+
import { dirname as dirname16, join as join68, resolve as resolve14 } from "path";
|
|
30893
31167
|
function cloneTargetProblem(dir, appId) {
|
|
30894
31168
|
const target = resolve14(dir);
|
|
30895
31169
|
if (!existsSync56(target))
|
|
@@ -30909,7 +31183,7 @@ function cloneTargetProblem(dir, appId) {
|
|
|
30909
31183
|
}
|
|
30910
31184
|
function readConfigAppId(dir) {
|
|
30911
31185
|
try {
|
|
30912
|
-
const config = JSON.parse(readFileSync39(
|
|
31186
|
+
const config = JSON.parse(readFileSync39(join68(dir, ".runwork.json"), "utf-8"));
|
|
30913
31187
|
return typeof config.appId === "string" ? config.appId : null;
|
|
30914
31188
|
} catch {
|
|
30915
31189
|
return null;
|
|
@@ -30917,7 +31191,7 @@ function readConfigAppId(dir) {
|
|
|
30917
31191
|
}
|
|
30918
31192
|
function isUnbornRepo(dir) {
|
|
30919
31193
|
try {
|
|
30920
|
-
if (!
|
|
31194
|
+
if (!lstatSync8(join68(dir, ".git")).isDirectory())
|
|
30921
31195
|
return false;
|
|
30922
31196
|
} catch {
|
|
30923
31197
|
return false;
|
|
@@ -30947,7 +31221,7 @@ async function execClone(client, app, directory, creds) {
|
|
|
30947
31221
|
}
|
|
30948
31222
|
const manifest = await generateManifest(dir);
|
|
30949
31223
|
await saveManifest(dir, manifest);
|
|
30950
|
-
if (!existsSync56(
|
|
31224
|
+
if (!existsSync56(join68(dir, ".git"))) {
|
|
30951
31225
|
try {
|
|
30952
31226
|
execFileSync5("git", ["init"], { cwd: dir, stdio: "pipe" });
|
|
30953
31227
|
} catch (err) {
|
|
@@ -30984,12 +31258,12 @@ async function execClone(client, app, directory, creds) {
|
|
|
30984
31258
|
appId: app.id,
|
|
30985
31259
|
appName: app.name
|
|
30986
31260
|
};
|
|
30987
|
-
writeFileSync28(
|
|
31261
|
+
writeFileSync28(join68(dir, ".runwork.json"), JSON.stringify(config, null, 2));
|
|
30988
31262
|
recordAppCheckout(dir, app.id);
|
|
30989
31263
|
try {
|
|
30990
31264
|
const { skill } = await client.getAppSkill(app.id);
|
|
30991
31265
|
if (skill) {
|
|
30992
|
-
writeFileSync28(
|
|
31266
|
+
writeFileSync28(join68(dir, "SKILL.md"), skill, "utf-8");
|
|
30993
31267
|
}
|
|
30994
31268
|
} catch {}
|
|
30995
31269
|
return {
|
|
@@ -31148,7 +31422,7 @@ App "${cloneResult.appName}" cloned to ${cloneResult.directory}`);
|
|
|
31148
31422
|
// src/git/auto-commit.ts
|
|
31149
31423
|
import { readFileSync as readFileSync40 } from "fs";
|
|
31150
31424
|
import { watch } from "chokidar";
|
|
31151
|
-
import { join as
|
|
31425
|
+
import { join as join69, relative as relative9 } from "path";
|
|
31152
31426
|
async function watchAndAutoCommit(directory, client, appId, callbacks) {
|
|
31153
31427
|
activeCallbacks = callbacks;
|
|
31154
31428
|
const ignoreSets = buildIgnoreSets(directory);
|
|
@@ -31208,7 +31482,7 @@ async function executeFastSync(directory, client, appId) {
|
|
|
31208
31482
|
if (BINARY_EXTENSIONS.has(ext.toLowerCase()))
|
|
31209
31483
|
continue;
|
|
31210
31484
|
try {
|
|
31211
|
-
const contents = readFileSync40(
|
|
31485
|
+
const contents = readFileSync40(join69(directory, filePath), "utf-8");
|
|
31212
31486
|
files.push({ filePath, fileContents: contents });
|
|
31213
31487
|
} catch {}
|
|
31214
31488
|
}
|
|
@@ -31382,7 +31656,7 @@ var init_auto_commit = __esm(() => {
|
|
|
31382
31656
|
|
|
31383
31657
|
// src/git/sync.ts
|
|
31384
31658
|
import { unlinkSync as unlinkSync9 } from "fs";
|
|
31385
|
-
import { join as
|
|
31659
|
+
import { join as join70 } from "path";
|
|
31386
31660
|
function hasCommits(cwd) {
|
|
31387
31661
|
try {
|
|
31388
31662
|
execFileSync5("git", ["rev-parse", "HEAD"], { cwd, stdio: "pipe" });
|
|
@@ -31420,7 +31694,7 @@ function removeConflictingUntrackedFiles(cwd) {
|
|
|
31420
31694
|
continue;
|
|
31421
31695
|
if (matchesRemote(cwd, file) || isPristineTemplateFile(cwd, file, manifest)) {
|
|
31422
31696
|
try {
|
|
31423
|
-
unlinkSync9(
|
|
31697
|
+
unlinkSync9(join70(cwd, file));
|
|
31424
31698
|
} catch {}
|
|
31425
31699
|
} else {
|
|
31426
31700
|
kept.push(file);
|
|
@@ -31601,11 +31875,11 @@ var init_sync2 = __esm(() => {
|
|
|
31601
31875
|
|
|
31602
31876
|
// src/git/critical-files.ts
|
|
31603
31877
|
import { readFileSync as readFileSync41, writeFileSync as writeFileSync29, existsSync as existsSync57 } from "fs";
|
|
31604
|
-
import { join as
|
|
31878
|
+
import { join as join71 } from "path";
|
|
31605
31879
|
function snapshotCriticalFiles(cwd) {
|
|
31606
31880
|
const snapshots = [];
|
|
31607
31881
|
for (const rel of CRITICAL_FILES) {
|
|
31608
|
-
const abs =
|
|
31882
|
+
const abs = join71(cwd, rel);
|
|
31609
31883
|
if (!existsSync57(abs))
|
|
31610
31884
|
continue;
|
|
31611
31885
|
try {
|
|
@@ -31617,7 +31891,7 @@ function snapshotCriticalFiles(cwd) {
|
|
|
31617
31891
|
function restoreMissingCriticalFiles(cwd, snapshots) {
|
|
31618
31892
|
const restored = [];
|
|
31619
31893
|
for (const snap of snapshots) {
|
|
31620
|
-
const abs =
|
|
31894
|
+
const abs = join71(cwd, snap.path);
|
|
31621
31895
|
if (existsSync57(abs))
|
|
31622
31896
|
continue;
|
|
31623
31897
|
try {
|
|
@@ -31661,7 +31935,7 @@ function buildStartupSyncSummary(input) {
|
|
|
31661
31935
|
|
|
31662
31936
|
// src/logs/tailer.ts
|
|
31663
31937
|
import { appendFileSync as appendFileSync2, mkdirSync as mkdirSync30, writeFileSync as writeFileSync30 } from "fs";
|
|
31664
|
-
import { join as
|
|
31938
|
+
import { join as join72, dirname as dirname17 } from "path";
|
|
31665
31939
|
function formatTime() {
|
|
31666
31940
|
const now = new Date;
|
|
31667
31941
|
return [
|
|
@@ -31709,7 +31983,7 @@ function startLogTailer(options) {
|
|
|
31709
31983
|
toFile,
|
|
31710
31984
|
intervalMs = 5000
|
|
31711
31985
|
} = options;
|
|
31712
|
-
const logFilePath =
|
|
31986
|
+
const logFilePath = join72(projectDir, LOG_FILE);
|
|
31713
31987
|
if (toFile) {
|
|
31714
31988
|
mkdirSync30(dirname17(logFilePath), { recursive: true });
|
|
31715
31989
|
writeFileSync30(logFilePath, `# Runwork dev logs - started ${new Date().toISOString()}
|
|
@@ -36593,11 +36867,11 @@ export type { ModelMessage, ModelMessage as CoreMessage, Tool, ToolSet, ToolChoi
|
|
|
36593
36867
|
|
|
36594
36868
|
// src/types-manager.ts
|
|
36595
36869
|
import { existsSync as existsSync61, mkdirSync as mkdirSync32, readdirSync as readdirSync26, copyFileSync as copyFileSync3, writeFileSync as writeFileSync31 } from "fs";
|
|
36596
|
-
import { join as
|
|
36870
|
+
import { join as join73 } from "path";
|
|
36597
36871
|
async function populateTypes(projectDir) {
|
|
36598
|
-
const typesDir =
|
|
36872
|
+
const typesDir = join73(projectDir, TYPES_DIR);
|
|
36599
36873
|
mkdirSync32(typesDir, { recursive: true });
|
|
36600
|
-
const frameworkDist =
|
|
36874
|
+
const frameworkDist = join73(projectDir, "node_modules/@runworkai/framework/dist");
|
|
36601
36875
|
if (existsSync61(frameworkDist)) {
|
|
36602
36876
|
copyDtsFiles(frameworkDist, typesDir);
|
|
36603
36877
|
console.log("Types populated from node_modules/@runworkai/framework");
|
|
@@ -36606,7 +36880,7 @@ async function populateTypes(projectDir) {
|
|
|
36606
36880
|
const typeEntries = Object.entries(BUNDLED_TYPES);
|
|
36607
36881
|
if (typeEntries.length > 0) {
|
|
36608
36882
|
for (const [filename, content] of typeEntries) {
|
|
36609
|
-
writeFileSync31(
|
|
36883
|
+
writeFileSync31(join73(typesDir, filename), content);
|
|
36610
36884
|
}
|
|
36611
36885
|
console.log("Types populated from bundled types");
|
|
36612
36886
|
return;
|
|
@@ -36617,7 +36891,7 @@ function copyDtsFiles(srcDir, destDir) {
|
|
|
36617
36891
|
const files = readdirSync26(srcDir);
|
|
36618
36892
|
for (const file of files) {
|
|
36619
36893
|
if (file.endsWith(".d.ts")) {
|
|
36620
|
-
copyFileSync3(
|
|
36894
|
+
copyFileSync3(join73(srcDir, file), join73(destDir, file));
|
|
36621
36895
|
}
|
|
36622
36896
|
}
|
|
36623
36897
|
}
|
|
@@ -36627,8 +36901,8 @@ var init_types_manager = __esm(() => {
|
|
|
36627
36901
|
});
|
|
36628
36902
|
|
|
36629
36903
|
// src/template/refresh.ts
|
|
36630
|
-
import { lstatSync as
|
|
36631
|
-
import { dirname as dirname18, join as
|
|
36904
|
+
import { lstatSync as lstatSync9, readFileSync as readFileSync44, writeFileSync as writeFileSync32 } from "fs";
|
|
36905
|
+
import { dirname as dirname18, join as join74 } from "path";
|
|
36632
36906
|
import { unzipSync as unzipSync2 } from "fflate";
|
|
36633
36907
|
function readTrackedPaths(cwd) {
|
|
36634
36908
|
try {
|
|
@@ -36648,7 +36922,7 @@ function isUnsafePath(relPath) {
|
|
|
36648
36922
|
}
|
|
36649
36923
|
function lstatOrNull2(fullPath) {
|
|
36650
36924
|
try {
|
|
36651
|
-
return
|
|
36925
|
+
return lstatSync9(fullPath);
|
|
36652
36926
|
} catch {
|
|
36653
36927
|
return null;
|
|
36654
36928
|
}
|
|
@@ -36675,7 +36949,7 @@ async function applyTemplateRefresh(options) {
|
|
|
36675
36949
|
continue;
|
|
36676
36950
|
}
|
|
36677
36951
|
files[relPath] = sha256(data);
|
|
36678
|
-
const fullPath =
|
|
36952
|
+
const fullPath = join74(cwd, relPath);
|
|
36679
36953
|
const stat = lstatOrNull2(fullPath);
|
|
36680
36954
|
const tracked = trackedPaths === null || trackedLower.has(relPath.toLowerCase());
|
|
36681
36955
|
if (stat === null) {
|
|
@@ -36941,12 +37215,12 @@ var init_app_connection_lines = __esm(() => {
|
|
|
36941
37215
|
// src/commands/dev.ts
|
|
36942
37216
|
import { Command as Command7, Option } from "commander";
|
|
36943
37217
|
import { writeFileSync as writeFileSync33 } from "fs";
|
|
36944
|
-
import { join as
|
|
37218
|
+
import { join as join75 } from "path";
|
|
36945
37219
|
async function populateSkill(projectDir, client, appId) {
|
|
36946
37220
|
try {
|
|
36947
37221
|
const { skill } = await client.getAppSkill(appId);
|
|
36948
37222
|
if (skill) {
|
|
36949
|
-
writeFileSync33(
|
|
37223
|
+
writeFileSync33(join75(projectDir, "SKILL.md"), skill, "utf-8");
|
|
36950
37224
|
}
|
|
36951
37225
|
} catch {}
|
|
36952
37226
|
}
|
|
@@ -37945,9 +38219,9 @@ var init_dev = __esm(async () => {
|
|
|
37945
38219
|
|
|
37946
38220
|
// src/deploy/deploy-state.ts
|
|
37947
38221
|
import { existsSync as existsSync62, mkdirSync as mkdirSync33, readFileSync as readFileSync45, writeFileSync as writeFileSync34 } from "fs";
|
|
37948
|
-
import { dirname as dirname19, join as
|
|
38222
|
+
import { dirname as dirname19, join as join76 } from "path";
|
|
37949
38223
|
function deployStatePath(cwd) {
|
|
37950
|
-
return
|
|
38224
|
+
return join76(cwd, ".runwork", "last-deploy.json");
|
|
37951
38225
|
}
|
|
37952
38226
|
function getHeadSha(cwd) {
|
|
37953
38227
|
try {
|
|
@@ -38000,7 +38274,7 @@ var init_deploy_state = __esm(() => {
|
|
|
38000
38274
|
|
|
38001
38275
|
// src/deploy/deploy-status.ts
|
|
38002
38276
|
import { existsSync as existsSync63, mkdirSync as mkdirSync34, readFileSync as readFileSync46, writeFileSync as writeFileSync35 } from "fs";
|
|
38003
|
-
import { dirname as dirname20, join as
|
|
38277
|
+
import { dirname as dirname20, join as join77 } from "path";
|
|
38004
38278
|
function evaluateDeployStatus(status, deps = {}) {
|
|
38005
38279
|
if (status.state !== "in-progress") {
|
|
38006
38280
|
return { status, effectiveState: status.state };
|
|
@@ -38016,10 +38290,10 @@ function evaluateDeployStatus(status, deps = {}) {
|
|
|
38016
38290
|
return { status, effectiveState: "in-progress" };
|
|
38017
38291
|
}
|
|
38018
38292
|
function statusPath(cwd) {
|
|
38019
|
-
return
|
|
38293
|
+
return join77(cwd, ".runwork", "deploy-status.json");
|
|
38020
38294
|
}
|
|
38021
38295
|
function deployLogPath(cwd) {
|
|
38022
|
-
return
|
|
38296
|
+
return join77(cwd, ".runwork", "deploy-stdout.log");
|
|
38023
38297
|
}
|
|
38024
38298
|
function writeDeployStatus(cwd, status) {
|
|
38025
38299
|
const path = statusPath(cwd);
|
|
@@ -38050,7 +38324,7 @@ var init_deploy_status = __esm(() => {
|
|
|
38050
38324
|
// src/deploy/detach.ts
|
|
38051
38325
|
import * as fs5 from "fs";
|
|
38052
38326
|
import * as child_process2 from "child_process";
|
|
38053
|
-
import { join as
|
|
38327
|
+
import { join as join78 } from "path";
|
|
38054
38328
|
function isInternalDeployChild(argv = process.argv) {
|
|
38055
38329
|
return argv.includes(DEPLOY_DETACHED_CHILD_FLAG);
|
|
38056
38330
|
}
|
|
@@ -38065,10 +38339,10 @@ function buildDeployChildArgs(parentArgv) {
|
|
|
38065
38339
|
return [...filtered, DEPLOY_DETACHED_CHILD_FLAG];
|
|
38066
38340
|
}
|
|
38067
38341
|
function spawnDetachedDeploy(childArgs, cwd) {
|
|
38068
|
-
const dir =
|
|
38342
|
+
const dir = join78(cwd, ".runwork");
|
|
38069
38343
|
fs5.mkdirSync(dir, { recursive: true });
|
|
38070
|
-
const stdoutFd = fs5.openSync(
|
|
38071
|
-
const stderrFd = fs5.openSync(
|
|
38344
|
+
const stdoutFd = fs5.openSync(join78(dir, "deploy-stdout.log"), "w");
|
|
38345
|
+
const stderrFd = fs5.openSync(join78(dir, "deploy-stderr.log"), "w");
|
|
38072
38346
|
try {
|
|
38073
38347
|
const proc = child_process2.spawn(process.execPath, childArgs, {
|
|
38074
38348
|
cwd,
|
|
@@ -38776,7 +39050,7 @@ import { Command as Command11 } from "commander";
|
|
|
38776
39050
|
import { execFileSync as execFileSync6 } from "child_process";
|
|
38777
39051
|
import { platform as osPlatform2, tmpdir as tmpdir7 } from "os";
|
|
38778
39052
|
import { mkdtempSync as mkdtempSync3, writeFileSync as writeFileSync36, rmSync as rmSync12 } from "fs";
|
|
38779
|
-
import { join as
|
|
39053
|
+
import { join as join79 } from "path";
|
|
38780
39054
|
function execPackageManager(tool, args) {
|
|
38781
39055
|
const spec = toSpawnSpec(tool, args);
|
|
38782
39056
|
execFileSync6(spec.command, spec.args, {
|
|
@@ -38830,8 +39104,8 @@ Upgrading via PowerShell installer...
|
|
|
38830
39104
|
throw new Error(`Failed to download install.ps1: HTTP ${response.status}`);
|
|
38831
39105
|
}
|
|
38832
39106
|
const script = await response.text();
|
|
38833
|
-
const tmpDir = mkdtempSync3(
|
|
38834
|
-
const scriptPath =
|
|
39107
|
+
const tmpDir = mkdtempSync3(join79(tmpdir7(), "runwork-upgrade-"));
|
|
39108
|
+
const scriptPath = join79(tmpDir, "install.ps1");
|
|
38835
39109
|
try {
|
|
38836
39110
|
writeFileSync36(scriptPath, script);
|
|
38837
39111
|
execFileSync6("powershell", ["-NoProfile", "-ExecutionPolicy", "Bypass", "-File", scriptPath], { stdio: "inherit" });
|
|
@@ -40114,7 +40388,7 @@ var init_app_info = __esm(() => {
|
|
|
40114
40388
|
// src/commands/info.ts
|
|
40115
40389
|
import { Command as Command16 } from "commander";
|
|
40116
40390
|
import { readFileSync as readFileSync48, existsSync as existsSync67 } from "fs";
|
|
40117
|
-
import { join as
|
|
40391
|
+
import { join as join80 } from "path";
|
|
40118
40392
|
function readLocalDevSession(appDir, appId) {
|
|
40119
40393
|
if (!appId)
|
|
40120
40394
|
return { state: "none" };
|
|
@@ -40137,7 +40411,7 @@ function tryReadConfig() {
|
|
|
40137
40411
|
return project.kind === "ok" ? project.config : null;
|
|
40138
40412
|
}
|
|
40139
40413
|
function readBlueprint(cwd) {
|
|
40140
|
-
const blueprintPath =
|
|
40414
|
+
const blueprintPath = join80(cwd, "blueprint.json");
|
|
40141
40415
|
if (!existsSync67(blueprintPath))
|
|
40142
40416
|
return null;
|
|
40143
40417
|
try {
|
|
@@ -40910,10 +41184,10 @@ var init_insight_id = () => {};
|
|
|
40910
41184
|
|
|
40911
41185
|
// src/reflect/insight-store.ts
|
|
40912
41186
|
import { existsSync as existsSync69, readFileSync as readFileSync50 } from "fs";
|
|
40913
|
-
import { join as
|
|
41187
|
+
import { join as join81 } from "path";
|
|
40914
41188
|
import { homedir as homedir44 } from "os";
|
|
40915
41189
|
function storePath2() {
|
|
40916
|
-
return
|
|
41190
|
+
return join81(homedir44(), ".runwork", "insights.json");
|
|
40917
41191
|
}
|
|
40918
41192
|
function readAll() {
|
|
40919
41193
|
const path = storePath2();
|
|
@@ -41229,7 +41503,7 @@ var init_session_summary = __esm(async () => {
|
|
|
41229
41503
|
|
|
41230
41504
|
// src/reflect/pattern-store.ts
|
|
41231
41505
|
import { createHash as createHash10 } from "crypto";
|
|
41232
|
-
import { join as
|
|
41506
|
+
import { join as join82 } from "path";
|
|
41233
41507
|
import { homedir as homedir45 } from "os";
|
|
41234
41508
|
function addBuckets(a, b) {
|
|
41235
41509
|
if (!a)
|
|
@@ -41470,7 +41744,7 @@ function buildPatternEvent(payload, nowISO) {
|
|
|
41470
41744
|
};
|
|
41471
41745
|
}
|
|
41472
41746
|
function storePath3() {
|
|
41473
|
-
return
|
|
41747
|
+
return join82(homedir45(), ".runwork", "pattern-store.json");
|
|
41474
41748
|
}
|
|
41475
41749
|
function loadPatternStore() {
|
|
41476
41750
|
const parsed = readJsonOrNull(storePath3());
|
|
@@ -41497,10 +41771,10 @@ var init_pattern_store = __esm(async () => {
|
|
|
41497
41771
|
|
|
41498
41772
|
// src/reflect/run-log.ts
|
|
41499
41773
|
import { existsSync as existsSync70, mkdirSync as mkdirSync36, readFileSync as readFileSync51, readdirSync as readdirSync27, statSync as statSync25, unlinkSync as unlinkSync10, writeFileSync as writeFileSync37 } from "fs";
|
|
41500
|
-
import { dirname as dirname21, join as
|
|
41774
|
+
import { dirname as dirname21, join as join83 } from "path";
|
|
41501
41775
|
import { homedir as homedir46 } from "os";
|
|
41502
41776
|
function runLogPath() {
|
|
41503
|
-
return
|
|
41777
|
+
return join83(homedir46(), ".runwork", "reflect-runs.json");
|
|
41504
41778
|
}
|
|
41505
41779
|
function loadRunLog() {
|
|
41506
41780
|
try {
|
|
@@ -41602,13 +41876,13 @@ function resolveBlockedRuns(insights) {
|
|
|
41602
41876
|
return closed;
|
|
41603
41877
|
}
|
|
41604
41878
|
function pendingPromptDir() {
|
|
41605
|
-
return
|
|
41879
|
+
return join83(homedir46(), ".runwork", "reflect-pending");
|
|
41606
41880
|
}
|
|
41607
41881
|
function pendingPromptFileName(runId) {
|
|
41608
41882
|
return `${runId.replace(/[<>:"/\\|?*\x00-\x1f]/g, "-")}.md`;
|
|
41609
41883
|
}
|
|
41610
41884
|
function pendingPromptPath(runId) {
|
|
41611
|
-
return
|
|
41885
|
+
return join83(pendingPromptDir(), pendingPromptFileName(runId));
|
|
41612
41886
|
}
|
|
41613
41887
|
function savePendingPrompt(runId, prompt) {
|
|
41614
41888
|
const path = pendingPromptPath(runId);
|
|
@@ -41623,13 +41897,13 @@ function savePendingPrompt(runId, prompt) {
|
|
|
41623
41897
|
live.add(pendingPromptFileName(runId));
|
|
41624
41898
|
for (const file of readdirSync27(pendingPromptDir())) {
|
|
41625
41899
|
if (file.endsWith(".md") && !live.has(file))
|
|
41626
|
-
unlinkSync10(
|
|
41900
|
+
unlinkSync10(join83(pendingPromptDir(), file));
|
|
41627
41901
|
}
|
|
41628
41902
|
} catch {}
|
|
41629
41903
|
return path;
|
|
41630
41904
|
}
|
|
41631
41905
|
function lockPath2() {
|
|
41632
|
-
return
|
|
41906
|
+
return join83(homedir46(), ".runwork", "reflect-run.lock");
|
|
41633
41907
|
}
|
|
41634
41908
|
function acquireRunLock(nowMs = Date.now()) {
|
|
41635
41909
|
const p = lockPath2();
|
|
@@ -41677,13 +41951,13 @@ var init_run_log = __esm(() => {
|
|
|
41677
41951
|
|
|
41678
41952
|
// src/reflect/conversation-queue.ts
|
|
41679
41953
|
import { existsSync as existsSync71, readFileSync as readFileSync52 } from "fs";
|
|
41680
|
-
import { join as
|
|
41954
|
+
import { join as join84 } from "path";
|
|
41681
41955
|
import { homedir as homedir47 } from "os";
|
|
41682
41956
|
function conversationKey(c) {
|
|
41683
41957
|
return c.transcriptPath ?? `${c.agentSlug}:${c.sessionId}`;
|
|
41684
41958
|
}
|
|
41685
41959
|
function queuePath() {
|
|
41686
|
-
return
|
|
41960
|
+
return join84(homedir47(), ".runwork", "reflect-queue.json");
|
|
41687
41961
|
}
|
|
41688
41962
|
function loadQueueState() {
|
|
41689
41963
|
try {
|
|
@@ -41905,7 +42179,7 @@ function parseHandoffResult(kind, text) {
|
|
|
41905
42179
|
// src/commands/reflect.ts
|
|
41906
42180
|
import { Command as Command18 } from "commander";
|
|
41907
42181
|
import { writeFileSync as writeFileSync38, mkdirSync as mkdirSync37 } from "fs";
|
|
41908
|
-
import { join as
|
|
42182
|
+
import { join as join85 } from "path";
|
|
41909
42183
|
import { basename as basename13 } from "path";
|
|
41910
42184
|
function cap(names) {
|
|
41911
42185
|
return names.length > MAX_NAMES ? [...names.slice(0, MAX_NAMES), `(+${names.length - MAX_NAMES} more)`] : names;
|
|
@@ -42565,7 +42839,7 @@ var init_reflect = __esm(async () => {
|
|
|
42565
42839
|
if (!outDir)
|
|
42566
42840
|
return;
|
|
42567
42841
|
mkdirSync37(outDir, { recursive: true });
|
|
42568
|
-
writeFileSync38(
|
|
42842
|
+
writeFileSync38(join85(outDir, file), content);
|
|
42569
42843
|
};
|
|
42570
42844
|
const census = loadCensusStore();
|
|
42571
42845
|
const windowChats = periodicWindowChats(census, sinceISO);
|
|
@@ -42896,7 +43170,7 @@ Wrote summary.md, prompt.md, reflection.md, evidence.json, insights.json to ${ou
|
|
|
42896
43170
|
try {
|
|
42897
43171
|
workspaceId = requireAuth().defaultWorkspaceId;
|
|
42898
43172
|
} catch {}
|
|
42899
|
-
const projectWorkspaceId = readJsonOrNull(
|
|
43173
|
+
const projectWorkspaceId = readJsonOrNull(join85(process.cwd(), ".runwork.json"))?.workspaceId;
|
|
42900
43174
|
if (id) {
|
|
42901
43175
|
const insight = getInsight(id, { workspaceIds: [projectWorkspaceId, workspaceId] });
|
|
42902
43176
|
if (!insight) {
|
|
@@ -42934,9 +43208,9 @@ ${all.length} insight(s) from your recent work:
|
|
|
42934
43208
|
|
|
42935
43209
|
// src/agents/claude/config-dir.ts
|
|
42936
43210
|
import { homedir as homedir48 } from "os";
|
|
42937
|
-
import { join as
|
|
43211
|
+
import { join as join86 } from "path";
|
|
42938
43212
|
function claudeConfigDir() {
|
|
42939
|
-
return process.env.CLAUDE_CONFIG_DIR ||
|
|
43213
|
+
return process.env.CLAUDE_CONFIG_DIR || join86(homedir48(), ".claude");
|
|
42940
43214
|
}
|
|
42941
43215
|
var init_config_dir = () => {};
|
|
42942
43216
|
|
|
@@ -42960,7 +43234,7 @@ var init_transcript_store_input = __esm(() => {
|
|
|
42960
43234
|
|
|
42961
43235
|
// src/agents/store-census.ts
|
|
42962
43236
|
import { readdirSync as readdirSync28, statSync as statSync26, existsSync as existsSync72, openSync as openSync7, readSync as readSync4, closeSync as closeSync7 } from "fs";
|
|
42963
|
-
import { join as
|
|
43237
|
+
import { join as join87 } from "path";
|
|
42964
43238
|
function sanitizeMarker(raw) {
|
|
42965
43239
|
const cleaned = raw.replace(/[^\x20-\x7E]/g, "").trim();
|
|
42966
43240
|
return cleaned.length > 64 ? `${cleaned.slice(0, 63)}…` : cleaned;
|
|
@@ -42997,7 +43271,7 @@ function collect(dir, def, out, budget) {
|
|
|
42997
43271
|
for (const e of entries) {
|
|
42998
43272
|
if (budget.left <= 0)
|
|
42999
43273
|
return;
|
|
43000
|
-
const full =
|
|
43274
|
+
const full = join87(dir, e.name);
|
|
43001
43275
|
if (e.isDirectory()) {
|
|
43002
43276
|
try {
|
|
43003
43277
|
collect(full, def, out, budget);
|
|
@@ -43284,9 +43558,9 @@ var init_conversation_registry = __esm(async () => {
|
|
|
43284
43558
|
// src/reflect/desk-backfill.ts
|
|
43285
43559
|
import { existsSync as existsSync73 } from "fs";
|
|
43286
43560
|
import { homedir as homedir50 } from "os";
|
|
43287
|
-
import { join as
|
|
43561
|
+
import { join as join88 } from "path";
|
|
43288
43562
|
function deskBackfillPath() {
|
|
43289
|
-
return
|
|
43563
|
+
return join88(homedir50(), ".runwork", "desk-backfill.json");
|
|
43290
43564
|
}
|
|
43291
43565
|
function loadDeskBackfillWorkspace() {
|
|
43292
43566
|
const path = deskBackfillPath();
|
|
@@ -43315,10 +43589,10 @@ var init_desk_backfill = __esm(async () => {
|
|
|
43315
43589
|
|
|
43316
43590
|
// src/reflect/chat-index.ts
|
|
43317
43591
|
import { existsSync as existsSync74, mkdirSync as mkdirSync38 } from "fs";
|
|
43318
|
-
import { dirname as dirname22, join as
|
|
43592
|
+
import { dirname as dirname22, join as join89 } from "path";
|
|
43319
43593
|
import { homedir as homedir51 } from "os";
|
|
43320
43594
|
function chatIndexPath() {
|
|
43321
|
-
return
|
|
43595
|
+
return join89(homedir51(), ".runwork", "chat-index.sqlite");
|
|
43322
43596
|
}
|
|
43323
43597
|
function chatIndexHasChats() {
|
|
43324
43598
|
const path = chatIndexPath();
|
|
@@ -44616,7 +44890,7 @@ var PERSONAL_SPACE_LABEL = "My Desk";
|
|
|
44616
44890
|
// src/commands/conversations.ts
|
|
44617
44891
|
import { Command as Command19 } from "commander";
|
|
44618
44892
|
import { existsSync as existsSync76, readFileSync as readFileSync53 } from "fs";
|
|
44619
|
-
import { join as
|
|
44893
|
+
import { join as join90 } from "path";
|
|
44620
44894
|
import { homedir as homedir52 } from "os";
|
|
44621
44895
|
function sinceFromDays(days) {
|
|
44622
44896
|
if (days <= 0)
|
|
@@ -44630,7 +44904,7 @@ function parseDays(raw) {
|
|
|
44630
44904
|
return Math.floor(n);
|
|
44631
44905
|
}
|
|
44632
44906
|
function snapshotPath() {
|
|
44633
|
-
return
|
|
44907
|
+
return join90(homedir52(), ".runwork", "conversations.json");
|
|
44634
44908
|
}
|
|
44635
44909
|
function rewriteSnapshotRow(key, spaceId) {
|
|
44636
44910
|
const path = snapshotPath();
|
|
@@ -45387,18 +45661,18 @@ var init_default_folder = __esm(async () => {
|
|
|
45387
45661
|
});
|
|
45388
45662
|
|
|
45389
45663
|
// src/spaces/folder-listing.ts
|
|
45390
|
-
import { lstatSync as
|
|
45391
|
-
import { basename as basename15, join as
|
|
45664
|
+
import { lstatSync as lstatSync10, readFileSync as readFileSync54, readdirSync as readdirSync29, statSync as statSync28 } from "node:fs";
|
|
45665
|
+
import { basename as basename15, join as join91, relative as relative10, sep as sep11 } from "node:path";
|
|
45392
45666
|
function listMappedFolder(folder, at = "") {
|
|
45393
45667
|
const rules = readIncludeRules(folder);
|
|
45394
45668
|
const sight = listingSight(folder, rules);
|
|
45395
45669
|
const hidden = sight.hidden;
|
|
45396
45670
|
const managedPaths = new Set(agentManagedInstructionPaths());
|
|
45397
|
-
const target = at ?
|
|
45671
|
+
const target = at ? join91(folder, at) : folder;
|
|
45398
45672
|
const found = [];
|
|
45399
45673
|
const appDirs = [];
|
|
45400
45674
|
for (const name of safeReadDir(target)) {
|
|
45401
|
-
const full =
|
|
45675
|
+
const full = join91(target, name);
|
|
45402
45676
|
const rel = relative10(folder, full).split(sep11).join("/");
|
|
45403
45677
|
if (hidden(rel))
|
|
45404
45678
|
continue;
|
|
@@ -45432,7 +45706,7 @@ function resourcesOnDisk(folder, root, appDirs, rules, sight, budget) {
|
|
|
45432
45706
|
if (left.left <= 0)
|
|
45433
45707
|
return;
|
|
45434
45708
|
left.left -= 1;
|
|
45435
|
-
const full =
|
|
45709
|
+
const full = join91(dir, name);
|
|
45436
45710
|
const rel = relative10(folder, full).split(sep11).join("/");
|
|
45437
45711
|
if (hidden(rel))
|
|
45438
45712
|
continue;
|
|
@@ -45453,7 +45727,7 @@ function resourcesOnDisk(folder, root, appDirs, rules, sight, budget) {
|
|
|
45453
45727
|
const onDisk = rootDirs.get(first.toLowerCase());
|
|
45454
45728
|
if (!onDisk || hidden([onDisk, ...rest].join("/"), true))
|
|
45455
45729
|
continue;
|
|
45456
|
-
walk(
|
|
45730
|
+
walk(join91(folder, onDisk, ...rest), 0);
|
|
45457
45731
|
}
|
|
45458
45732
|
for (const marker of locations.markers) {
|
|
45459
45733
|
const atRoot = root.find((entry) => entry.kind === "file" && entry.name.toLowerCase() === marker.toLowerCase());
|
|
@@ -45461,7 +45735,7 @@ function resourcesOnDisk(folder, root, appDirs, rules, sight, budget) {
|
|
|
45461
45735
|
found.push({ path: atRoot.path, name: atRoot.name, kind: "file" });
|
|
45462
45736
|
for (const dir of [...rootDirs.values(), ...appDirs]) {
|
|
45463
45737
|
const rel = `${dir}/${marker}`;
|
|
45464
|
-
if (isFile(
|
|
45738
|
+
if (isFile(join91(folder, dir, marker)) && !sight.markerHidden(rel))
|
|
45465
45739
|
found.push({ path: rel, name: marker, kind: "file" });
|
|
45466
45740
|
}
|
|
45467
45741
|
}
|
|
@@ -45498,7 +45772,7 @@ function isFile(path) {
|
|
|
45498
45772
|
}
|
|
45499
45773
|
}
|
|
45500
45774
|
function readMarker(folder, rel) {
|
|
45501
|
-
const full =
|
|
45775
|
+
const full = join91(folder, ...rel.split("/"));
|
|
45502
45776
|
try {
|
|
45503
45777
|
if (statSync28(full).size > MAX_MARKER_BYTES)
|
|
45504
45778
|
return null;
|
|
@@ -45507,9 +45781,13 @@ function readMarker(folder, rel) {
|
|
|
45507
45781
|
return null;
|
|
45508
45782
|
}
|
|
45509
45783
|
}
|
|
45510
|
-
function hiddenPredicate(ignoreSets, rules) {
|
|
45784
|
+
function hiddenPredicate(folder, ignoreSets, rules) {
|
|
45511
45785
|
const floor = buildSpaceFloorSets();
|
|
45512
|
-
|
|
45786
|
+
const units = repoUnits(folder, rules);
|
|
45787
|
+
return (rel, isDirectory = false) => hiddenFromSpace(rel, ignoreSets, rules, floor, { isDirectory }) || unitHides(units, rel, isDirectory);
|
|
45788
|
+
}
|
|
45789
|
+
function unitHides(units, rel, isDirectory) {
|
|
45790
|
+
return units.hides(rel, isDirectory ? true : undefined);
|
|
45513
45791
|
}
|
|
45514
45792
|
function listingSight(folder, rules) {
|
|
45515
45793
|
const sets = {
|
|
@@ -45522,8 +45800,9 @@ function listingSight(folder, rules) {
|
|
|
45522
45800
|
};
|
|
45523
45801
|
const gitignored = (rel, isDirectory = false) => gitignoredAgentAsset(rel, sets, isDirectory);
|
|
45524
45802
|
const withoutApps = { ...sets.ignore, apps: NO_APP_FOLDERS };
|
|
45803
|
+
const units = repoUnits(folder, rules);
|
|
45525
45804
|
return {
|
|
45526
|
-
hidden: (rel, isDirectory = false) => hiddenFromSpace(rel, sets.ignore, rules, sets.floor, { isDirectory }) && !gitignored(rel, isDirectory),
|
|
45805
|
+
hidden: (rel, isDirectory = false) => hiddenFromSpace(rel, sets.ignore, rules, sets.floor, { isDirectory }) && !gitignored(rel, isDirectory) || unitHides(units, rel, isDirectory),
|
|
45527
45806
|
gitignored,
|
|
45528
45807
|
leadsToAsset: (rel) => onAgentAssetPath(rel, sets.assets),
|
|
45529
45808
|
markerHidden: (rel, isDirectory = false) => hiddenFromSpace(rel, withoutApps, rules, sets.floor, { isDirectory }) && !gitignored(rel, isDirectory)
|
|
@@ -45542,7 +45821,7 @@ function sharedNow(rel, kind, rules, sight, folder, budget) {
|
|
|
45542
45821
|
if (kind === "file")
|
|
45543
45822
|
return isIncluded(rel, rules) ? "all" : "none";
|
|
45544
45823
|
const shares = (path) => !sight.gitignored(path) && isIncluded(path, rules);
|
|
45545
|
-
const counted = countUnder(
|
|
45824
|
+
const counted = countUnder(join91(folder, rel), folder, sight.hidden, shares, {
|
|
45546
45825
|
maxDepth: MAX_DEPTH,
|
|
45547
45826
|
budget,
|
|
45548
45827
|
followLinks: true
|
|
@@ -45562,7 +45841,7 @@ function countUnder(dir, folder, hidden, shares, limits, depth = 0) {
|
|
|
45562
45841
|
if (limits.budget.left <= 0)
|
|
45563
45842
|
return { shared, total, complete: false };
|
|
45564
45843
|
limits.budget.left -= 1;
|
|
45565
|
-
const full =
|
|
45844
|
+
const full = join91(dir, name);
|
|
45566
45845
|
const rel = relative10(folder, full).split(sep11).join("/");
|
|
45567
45846
|
if (hidden(rel))
|
|
45568
45847
|
continue;
|
|
@@ -45591,13 +45870,13 @@ function scopeOfMappedFolder(folder, opts = {}) {
|
|
|
45591
45870
|
const ignoreSets = buildSpaceIgnoreSets(folder);
|
|
45592
45871
|
const rules = readIncludeRules(folder);
|
|
45593
45872
|
const shares = at ? () => true : (rel) => rel === SPACE_INCLUDE_FILE || isIncluded(rel, rules);
|
|
45594
|
-
const hidden = hiddenPredicate(ignoreSets, rules);
|
|
45873
|
+
const hidden = hiddenPredicate(folder, ignoreSets, rules);
|
|
45595
45874
|
const outOfSight = at ? hidden : (rel, isDirectory = false) => hidden(rel, isDirectory) || sharesNothingUnder(rel, rules);
|
|
45596
45875
|
const groups = new Map;
|
|
45597
45876
|
let files = 0;
|
|
45598
45877
|
let bytes = 0;
|
|
45599
45878
|
const groupPrefix = at ? `${at}/` : "";
|
|
45600
|
-
countUnder(at ?
|
|
45879
|
+
countUnder(at ? join91(folder, at) : folder, folder, outOfSight, shares, {
|
|
45601
45880
|
maxDepth: Number.POSITIVE_INFINITY,
|
|
45602
45881
|
budget: { left: Number.POSITIVE_INFINITY },
|
|
45603
45882
|
followLinks: false,
|
|
@@ -45617,11 +45896,11 @@ function scopeOfMappedFolder(folder, opts = {}) {
|
|
|
45617
45896
|
return { folder, files, bytes, largest };
|
|
45618
45897
|
}
|
|
45619
45898
|
function holdsMoreFilesThan(folder, max) {
|
|
45620
|
-
const hidden = hiddenPredicate(buildSpaceIgnoreSets(folder), readIncludeRules(folder));
|
|
45899
|
+
const hidden = hiddenPredicate(folder, buildSpaceIgnoreSets(folder), readIncludeRules(folder));
|
|
45621
45900
|
let found = 0;
|
|
45622
45901
|
const walk = (dir) => {
|
|
45623
45902
|
for (const name of safeReadDir(dir)) {
|
|
45624
|
-
const full =
|
|
45903
|
+
const full = join91(dir, name);
|
|
45625
45904
|
const rel = relative10(folder, full).split(sep11).join("/");
|
|
45626
45905
|
if (hidden(rel))
|
|
45627
45906
|
continue;
|
|
@@ -45641,8 +45920,8 @@ function holdsMoreFilesThan(folder, max) {
|
|
|
45641
45920
|
return walk(folder);
|
|
45642
45921
|
}
|
|
45643
45922
|
function topLevelSpaceEntries(folder) {
|
|
45644
|
-
const hidden = hiddenPredicate(buildSpaceIgnoreSets(folder), readIncludeRules(folder));
|
|
45645
|
-
return safeReadDir(folder).filter((name) => !hidden(name) && !(hidden(name, true) && weigh(
|
|
45923
|
+
const hidden = hiddenPredicate(folder, buildSpaceIgnoreSets(folder), readIncludeRules(folder));
|
|
45924
|
+
return safeReadDir(folder).filter((name) => !hidden(name) && !(hidden(name, true) && weigh(join91(folder, name), false).directory)).sort();
|
|
45646
45925
|
}
|
|
45647
45926
|
function safeReadDir(dir) {
|
|
45648
45927
|
try {
|
|
@@ -45653,7 +45932,7 @@ function safeReadDir(dir) {
|
|
|
45653
45932
|
}
|
|
45654
45933
|
function weigh(path, followLinks) {
|
|
45655
45934
|
try {
|
|
45656
|
-
const stat = followLinks ? statSync28(path) :
|
|
45935
|
+
const stat = followLinks ? statSync28(path) : lstatSync10(path);
|
|
45657
45936
|
return { directory: stat.isDirectory(), bytes: stat.isDirectory() ? 0 : stat.size };
|
|
45658
45937
|
} catch {
|
|
45659
45938
|
return { directory: false, bytes: 0 };
|
|
@@ -45672,7 +45951,10 @@ function measure(path) {
|
|
|
45672
45951
|
var MAX_RESOURCE_ENTRIES = 2000, MAX_DEPTH = 6, MAX_COUNTED_ENTRIES = 20000;
|
|
45673
45952
|
var init_folder_listing = __esm(async () => {
|
|
45674
45953
|
init_resources();
|
|
45675
|
-
await
|
|
45954
|
+
await __promiseAll([
|
|
45955
|
+
init_space_sync_rules(),
|
|
45956
|
+
init_nested_repos()
|
|
45957
|
+
]);
|
|
45676
45958
|
});
|
|
45677
45959
|
|
|
45678
45960
|
// ../../shared/spaces/map-scope.ts
|
|
@@ -45823,17 +46105,17 @@ var init_data_input = () => {};
|
|
|
45823
46105
|
|
|
45824
46106
|
// src/commands/spaces.ts
|
|
45825
46107
|
import { Command as Command20 } from "commander";
|
|
45826
|
-
import { basename as basename16, dirname as dirname23, join as
|
|
46108
|
+
import { basename as basename16, dirname as dirname23, join as join92, sep as sep12 } from "path";
|
|
45827
46109
|
import { homedir as homedir53 } from "os";
|
|
45828
|
-
import { existsSync as existsSync78, lstatSync as
|
|
46110
|
+
import { existsSync as existsSync78, lstatSync as lstatSync11, mkdirSync as mkdirSync39, readFileSync as readFileSync56, readdirSync as readdirSync30, statSync as statSync29, writeFileSync as writeFileSync39 } from "fs";
|
|
45829
46111
|
function readFolderInstructions(folder) {
|
|
45830
|
-
const file =
|
|
46112
|
+
const file = join92(folder, SPACE_INSTRUCTIONS_FILE);
|
|
45831
46113
|
if (!existsSync78(file))
|
|
45832
46114
|
return null;
|
|
45833
46115
|
const linked = linkedSpaceDoc(folder);
|
|
45834
46116
|
if (linked && linkedDocUnshared(folder, linked.rel, false))
|
|
45835
46117
|
return null;
|
|
45836
|
-
if (!linked &&
|
|
46118
|
+
if (!linked && lstatSync11(file).isSymbolicLink())
|
|
45837
46119
|
return null;
|
|
45838
46120
|
try {
|
|
45839
46121
|
const own = stripSpaceBlock(readFileSync56(linked ? linked.target : file, "utf-8"));
|
|
@@ -45882,7 +46164,7 @@ function mappedFolderFor(target, mappings = loadSpaceMappings().mappings) {
|
|
|
45882
46164
|
return { folder, rel, mapping: best };
|
|
45883
46165
|
}
|
|
45884
46166
|
function writeIncludeRules(folder, rules) {
|
|
45885
|
-
const file =
|
|
46167
|
+
const file = join92(folder, SPACE_INCLUDE_FILE);
|
|
45886
46168
|
let existing = null;
|
|
45887
46169
|
try {
|
|
45888
46170
|
existing = readFileSync56(file, "utf-8");
|
|
@@ -45943,11 +46225,11 @@ async function findOrphanRepos() {
|
|
|
45943
46225
|
for (const name of readdirSync30(root).sort()) {
|
|
45944
46226
|
if (mapped.has(name))
|
|
45945
46227
|
continue;
|
|
45946
|
-
const gitdir =
|
|
46228
|
+
const gitdir = join92(root, name);
|
|
45947
46229
|
if (dirname23(gitdir) !== root)
|
|
45948
46230
|
continue;
|
|
45949
46231
|
try {
|
|
45950
|
-
if (!
|
|
46232
|
+
if (!lstatSync11(gitdir).isDirectory())
|
|
45951
46233
|
continue;
|
|
45952
46234
|
} catch {
|
|
45953
46235
|
continue;
|
|
@@ -46171,7 +46453,7 @@ function relForSharing(folder, path, platform = hostPathPlatform()) {
|
|
|
46171
46453
|
const abs = on.isAbsolute(path) ? on.resolve(path) : on.join(folder, path);
|
|
46172
46454
|
const root = trimTrailing(on.resolve(folder), on.sep);
|
|
46173
46455
|
const rel = includeRulePath(isUnder(abs, root, on.sep) ? abs.slice(root.length) : path);
|
|
46174
|
-
const full =
|
|
46456
|
+
const full = join92(folder, rel);
|
|
46175
46457
|
return existsSync78(full) && statSync29(full).isDirectory() ? `${rel}/` : rel;
|
|
46176
46458
|
}
|
|
46177
46459
|
function trimTrailing(path, separator) {
|
|
@@ -46367,7 +46649,7 @@ var init_spaces2 = __esm(async () => {
|
|
|
46367
46649
|
}
|
|
46368
46650
|
}
|
|
46369
46651
|
const folderInstructions = readFolderInstructions(target);
|
|
46370
|
-
const localList =
|
|
46652
|
+
const localList = join92(target, SPACE_INCLUDE_FILE);
|
|
46371
46653
|
const spaceInstructionsRead = folderInstructions ? client.getSpaceInstructions(workspaceId, space.id).catch(() => null) : null;
|
|
46372
46654
|
const spaceIncludeRead = existsSync78(localList) ? null : client.getSpaceFile(workspaceId, space.id, SPACE_INCLUDE_FILE).catch(() => null);
|
|
46373
46655
|
let adopted = false;
|
|
@@ -46383,7 +46665,7 @@ var init_spaces2 = __esm(async () => {
|
|
|
46383
46665
|
console.error(`Error: ${target} has its own ${SPACE_INSTRUCTIONS_FILE} and ${decision.because}.`);
|
|
46384
46666
|
console.error(`Keeping both would rename one of them on the first sync. Merge them yourself into either file, then map again.`);
|
|
46385
46667
|
console.error(dim(` the space's: runwork spaces list, then open it on the web`));
|
|
46386
|
-
console.error(dim(` this folder's: ${
|
|
46668
|
+
console.error(dim(` this folder's: ${join92(target, SPACE_INSTRUCTIONS_FILE)}`));
|
|
46387
46669
|
process.exit(1);
|
|
46388
46670
|
}
|
|
46389
46671
|
if (decision.action === "adopt-folder") {
|
|
@@ -46521,7 +46803,7 @@ var init_spaces2 = __esm(async () => {
|
|
|
46521
46803
|
console.error(`Error: --at must name a directory inside ${target}.`);
|
|
46522
46804
|
process.exit(1);
|
|
46523
46805
|
}
|
|
46524
|
-
const inside =
|
|
46806
|
+
const inside = join92(target, at);
|
|
46525
46807
|
if (!existsSync78(inside) || !statSync29(inside).isDirectory()) {
|
|
46526
46808
|
console.error(`Error: ${at} is not a directory in ${target}.`);
|
|
46527
46809
|
process.exit(1);
|
|
@@ -46844,11 +47126,11 @@ var init_spaces2 = __esm(async () => {
|
|
|
46844
47126
|
console.error(`Error: ${normalizeFolder(target)} is not a path inside a folder mapped to a space. See: runwork spaces mappings`);
|
|
46845
47127
|
process.exit(1);
|
|
46846
47128
|
}
|
|
46847
|
-
if (!existsSync78(
|
|
47129
|
+
if (!existsSync78(join92(found.folder, found.rel))) {
|
|
46848
47130
|
console.error(`Error: ${normalizeFolder(target)} does not exist.`);
|
|
46849
47131
|
process.exit(1);
|
|
46850
47132
|
}
|
|
46851
|
-
const isDir = statSync29(
|
|
47133
|
+
const isDir = statSync29(join92(found.folder, found.rel)).isDirectory();
|
|
46852
47134
|
const rules = includePath(readIncludeRules(found.folder), found.rel, isDir);
|
|
46853
47135
|
writeIncludeRules(found.folder, rules);
|
|
46854
47136
|
if (json) {
|
|
@@ -47010,7 +47292,7 @@ var init_spaces2 = __esm(async () => {
|
|
|
47010
47292
|
console.error("Error: name paths as arguments or pass --paths-stdin, not both.");
|
|
47011
47293
|
process.exit(1);
|
|
47012
47294
|
}
|
|
47013
|
-
const named = fromStdin ? await readStdinPaths() : paths.length > 0 ? paths : found.rel && existsSync78(
|
|
47295
|
+
const named = fromStdin ? await readStdinPaths() : paths.length > 0 ? paths : found.rel && existsSync78(join92(found.folder, found.rel)) && !statSync29(join92(found.folder, found.rel)).isDirectory() ? [found.rel] : [];
|
|
47014
47296
|
const broken = named.filter((one) => one.includes(`
|
|
47015
47297
|
`) || one.includes("\r"));
|
|
47016
47298
|
if (broken.length > 0) {
|
|
@@ -47132,7 +47414,7 @@ var init_spaces2 = __esm(async () => {
|
|
|
47132
47414
|
if (!history)
|
|
47133
47415
|
return;
|
|
47134
47416
|
if (history.removed) {
|
|
47135
|
-
console.log(dim(` ${formatBytes(history.bytes)} of space history moved to ${
|
|
47417
|
+
console.log(dim(` ${formatBytes(history.bytes)} of space history moved to ${join92(homedir53(), ".runwork", "trash")}`));
|
|
47136
47418
|
return;
|
|
47137
47419
|
}
|
|
47138
47420
|
if (refusedUnpushed) {
|
|
@@ -47291,7 +47573,7 @@ var init_spaces2 = __esm(async () => {
|
|
|
47291
47573
|
process.exitCode = 1;
|
|
47292
47574
|
return;
|
|
47293
47575
|
}
|
|
47294
|
-
console.log(green(`Removed ${results.size} space histor${results.size === 1 ? "y" : "ies"}, freeing ${formatBytes(bytesFreed)}.`) + dim(` Moved to ${
|
|
47576
|
+
console.log(green(`Removed ${results.size} space histor${results.size === 1 ? "y" : "ies"}, freeing ${formatBytes(bytesFreed)}.`) + dim(` Moved to ${join92(homedir53(), ".runwork", "trash")}`));
|
|
47295
47577
|
if (failed.length > 0) {
|
|
47296
47578
|
console.error(red(`Could not move ${failed.length} of them out of ${root}; they are still there: ${failed.join(", ")}`));
|
|
47297
47579
|
process.exitCode = 1;
|
|
@@ -49845,7 +50127,7 @@ var init_workspace = __esm(async () => {
|
|
|
49845
50127
|
// src/git/inspect.ts
|
|
49846
50128
|
import { execFile as cpExecFile } from "child_process";
|
|
49847
50129
|
import { existsSync as existsSync81, readFileSync as readFileSync59 } from "fs";
|
|
49848
|
-
import { basename as basename18, join as
|
|
50130
|
+
import { basename as basename18, join as join95 } from "path";
|
|
49849
50131
|
function runGitVersion(binary) {
|
|
49850
50132
|
return new Promise((resolve) => {
|
|
49851
50133
|
cpExecFile(binary, ["--version"], { timeout: 15000, windowsHide: true, encoding: "utf-8" }, (error, stdout, stderr) => {
|
|
@@ -49870,7 +50152,7 @@ async function runLfsVersion(binary, env) {
|
|
|
49870
50152
|
}
|
|
49871
50153
|
function readCurrent(root) {
|
|
49872
50154
|
try {
|
|
49873
|
-
return readFileSync59(
|
|
50155
|
+
return readFileSync59(join95(root, "current"), "utf-8").trim();
|
|
49874
50156
|
} catch {
|
|
49875
50157
|
return null;
|
|
49876
50158
|
}
|
|
@@ -49888,7 +50170,7 @@ async function inspectBuild(root, name, platform, arch, runVersion, runHttps) {
|
|
|
49888
50170
|
problemKind: "missing"
|
|
49889
50171
|
};
|
|
49890
50172
|
}
|
|
49891
|
-
const dir =
|
|
50173
|
+
const dir = join95(root, name);
|
|
49892
50174
|
const binary = gitBinaryPath(dir, platform, arch);
|
|
49893
50175
|
const pinned = name === PINNED_GIT_BUILD;
|
|
49894
50176
|
if (!existsSync81(binary)) {
|
|
@@ -50190,7 +50472,7 @@ var init_windows_path = __esm(() => {
|
|
|
50190
50472
|
|
|
50191
50473
|
// src/health/checks.ts
|
|
50192
50474
|
import { existsSync as existsSync82, readFileSync as readFileSync60 } from "fs";
|
|
50193
|
-
import { basename as basename20, join as
|
|
50475
|
+
import { basename as basename20, join as join96, sep as sep13 } from "path";
|
|
50194
50476
|
import { homedir as homedir55, platform as osPlatform4, arch as osArch } from "os";
|
|
50195
50477
|
function detectPlatform() {
|
|
50196
50478
|
const rawOs = osPlatform4();
|
|
@@ -50519,8 +50801,8 @@ async function checkCliArtifactReachable() {
|
|
|
50519
50801
|
async function checkCliInstallLocation() {
|
|
50520
50802
|
const isWindows = osPlatform4() === "win32";
|
|
50521
50803
|
const home = homedir55();
|
|
50522
|
-
const canonicalDir =
|
|
50523
|
-
const canonicalBinary = isWindows ?
|
|
50804
|
+
const canonicalDir = join96(home, ".runwork", "bin");
|
|
50805
|
+
const canonicalBinary = isWindows ? join96(canonicalDir, "runwork.exe") : join96(canonicalDir, "runwork");
|
|
50524
50806
|
const candidates = [process.execPath, process.argv[1] || ""].filter(Boolean);
|
|
50525
50807
|
const runsFromCanonical = candidates.some((p) => normalizePath(p) === normalizePath(canonicalBinary));
|
|
50526
50808
|
if (runsFromCanonical) {
|
|
@@ -50760,7 +51042,7 @@ async function checkGitCredentialHelper(ctx) {
|
|
|
50760
51042
|
};
|
|
50761
51043
|
}
|
|
50762
51044
|
async function checkProjectConfig(ctx) {
|
|
50763
|
-
const configPath =
|
|
51045
|
+
const configPath = join96(ctx.cwd, RUNWORK_CONFIG_FILE);
|
|
50764
51046
|
if (!existsSync82(configPath)) {
|
|
50765
51047
|
if (!ctx.credentials) {
|
|
50766
51048
|
return { name: "project-config", status: "skip", message: "no project (not logged in)" };
|
|
@@ -50823,7 +51105,7 @@ async function checkGitRemote(ctx) {
|
|
|
50823
51105
|
if (!ctx.config) {
|
|
50824
51106
|
return { name: "git-remote", status: "skip", message: "skipped (no project)" };
|
|
50825
51107
|
}
|
|
50826
|
-
if (!existsSync82(
|
|
51108
|
+
if (!existsSync82(join96(ctx.cwd, ".git"))) {
|
|
50827
51109
|
return {
|
|
50828
51110
|
name: "git-remote",
|
|
50829
51111
|
status: "fail",
|
|
@@ -50952,7 +51234,7 @@ async function checkAgentSetup() {
|
|
|
50952
51234
|
const missingSkills = state.skills.filter((name) => {
|
|
50953
51235
|
if (isCoveredByMcp(name))
|
|
50954
51236
|
return false;
|
|
50955
|
-
const skillPath =
|
|
51237
|
+
const skillPath = join96(skillsDir, name, "SKILL.md");
|
|
50956
51238
|
return !existsSync82(skillPath);
|
|
50957
51239
|
});
|
|
50958
51240
|
if (missingSkills.length > 0) {
|
|
@@ -50983,7 +51265,7 @@ async function checkAgentSetup() {
|
|
|
50983
51265
|
};
|
|
50984
51266
|
}
|
|
50985
51267
|
async function checkWorkspacePointers() {
|
|
50986
|
-
const userStatePath =
|
|
51268
|
+
const userStatePath = join96(homedir55(), ".runwork", "setup.json");
|
|
50987
51269
|
const state = existsSync82(userStatePath) ? (() => {
|
|
50988
51270
|
try {
|
|
50989
51271
|
return JSON.parse(readFileSync60(userStatePath, "utf-8"));
|
|
@@ -51021,7 +51303,7 @@ async function checkToolCredentials(ctx, api = ctx.client) {
|
|
|
51021
51303
|
return { name, status: "skip", message: "skipped (not logged in)" };
|
|
51022
51304
|
if (process.env.RUNWORK_API_KEY)
|
|
51023
51305
|
return { name, status: "skip", message: "skipped (signed in through RUNWORK_API_KEY)" };
|
|
51024
|
-
const userStatePath =
|
|
51306
|
+
const userStatePath = join96(homedir55(), ".runwork", "setup.json");
|
|
51025
51307
|
const state = existsSync82(userStatePath) ? (() => {
|
|
51026
51308
|
try {
|
|
51027
51309
|
return JSON.parse(readFileSync60(userStatePath, "utf-8"));
|
|
@@ -51285,7 +51567,7 @@ var init_runner = __esm(async () => {
|
|
|
51285
51567
|
|
|
51286
51568
|
// src/health/fix.ts
|
|
51287
51569
|
import { existsSync as existsSync83 } from "fs";
|
|
51288
|
-
import { join as
|
|
51570
|
+
import { join as join97 } from "path";
|
|
51289
51571
|
import { homedir as homedir56 } from "os";
|
|
51290
51572
|
async function applyDoctorFixes(ctx, failingNames, deps = {}) {
|
|
51291
51573
|
const failing = new Set(failingNames);
|
|
@@ -51313,7 +51595,7 @@ async function applyDoctorFixes(ctx, failingNames, deps = {}) {
|
|
|
51313
51595
|
applied: false,
|
|
51314
51596
|
message: "no project config -- run inside an app directory"
|
|
51315
51597
|
});
|
|
51316
|
-
} else if (!existsSync83(
|
|
51598
|
+
} else if (!existsSync83(join97(ctx.cwd, ".git"))) {
|
|
51317
51599
|
outcomes.push({
|
|
51318
51600
|
name: "git-remote",
|
|
51319
51601
|
applied: false,
|
|
@@ -51387,7 +51669,7 @@ async function repairEveryToolsKeyExposures(credentials) {
|
|
|
51387
51669
|
return repairRunworkKeyExposures(getAllAdapters(), knownRunworkOrigins(credentials));
|
|
51388
51670
|
}
|
|
51389
51671
|
async function syncMachineTools(credentials) {
|
|
51390
|
-
const statePath =
|
|
51672
|
+
const statePath = join97(homedir56(), ".runwork", "setup.json");
|
|
51391
51673
|
const state = readJsonOrNull(statePath);
|
|
51392
51674
|
if (!state)
|
|
51393
51675
|
throw new Error("setup has not run on this machine");
|
|
@@ -51932,8 +52214,8 @@ var init_cloud2 = __esm(async () => {
|
|
|
51932
52214
|
|
|
51933
52215
|
// src/commands/uninstall.ts
|
|
51934
52216
|
import { Command as Command39 } from "commander";
|
|
51935
|
-
import { existsSync as existsSync85, readFileSync as readFileSync62, writeFileSync as writeFileSync42, readdirSync as readdirSync32, rmSync as rmSync13, unlinkSync as unlinkSync11, lstatSync as
|
|
51936
|
-
import { dirname as dirname25, join as
|
|
52217
|
+
import { existsSync as existsSync85, readFileSync as readFileSync62, writeFileSync as writeFileSync42, readdirSync as readdirSync32, rmSync as rmSync13, unlinkSync as unlinkSync11, lstatSync as lstatSync12, readlinkSync as readlinkSync3 } from "fs";
|
|
52218
|
+
import { dirname as dirname25, join as join99, resolve as resolve16, relative as relative11, isAbsolute as isAbsolute14 } from "path";
|
|
51937
52219
|
import { homedir as homedir58 } from "os";
|
|
51938
52220
|
function loadSetupState4(filePath) {
|
|
51939
52221
|
if (!existsSync85(filePath))
|
|
@@ -51985,7 +52267,7 @@ function holdsRunworkCredentials(path) {
|
|
|
51985
52267
|
}
|
|
51986
52268
|
function linkTarget(path) {
|
|
51987
52269
|
try {
|
|
51988
|
-
if (!
|
|
52270
|
+
if (!lstatSync12(path).isSymbolicLink())
|
|
51989
52271
|
return null;
|
|
51990
52272
|
const target = resolve16(dirname25(path), readlinkSync3(path));
|
|
51991
52273
|
return existsSync85(target) ? target : null;
|
|
@@ -52009,7 +52291,7 @@ function removeRunworkState(stateDir, opts) {
|
|
|
52009
52291
|
return result;
|
|
52010
52292
|
}
|
|
52011
52293
|
for (const entry of entries) {
|
|
52012
|
-
const target =
|
|
52294
|
+
const target = join99(stateDir, entry);
|
|
52013
52295
|
if (preserve.has(entry)) {
|
|
52014
52296
|
if (existsSync85(target))
|
|
52015
52297
|
result.preserved.push(target);
|
|
@@ -52087,7 +52369,7 @@ function stripRunworkPathLines(file) {
|
|
|
52087
52369
|
}
|
|
52088
52370
|
}
|
|
52089
52371
|
function cleanShellProfilePathEntries() {
|
|
52090
|
-
return SHELL_PROFILES.map((name) =>
|
|
52372
|
+
return SHELL_PROFILES.map((name) => join99(homedir58(), name)).filter(stripRunworkPathLines);
|
|
52091
52373
|
}
|
|
52092
52374
|
function cleanPowerShellProfilePathEntries() {
|
|
52093
52375
|
if (process.platform !== "win32")
|
|
@@ -52130,7 +52412,7 @@ function uninstallWindowsPathEntry(probe = defaultWindowsPathProbe()) {
|
|
|
52130
52412
|
function removeRunworkSymlink(linkPath) {
|
|
52131
52413
|
let stat;
|
|
52132
52414
|
try {
|
|
52133
|
-
stat =
|
|
52415
|
+
stat = lstatSync12(linkPath);
|
|
52134
52416
|
} catch {
|
|
52135
52417
|
return false;
|
|
52136
52418
|
}
|
|
@@ -52142,7 +52424,7 @@ function removeRunworkSymlink(linkPath) {
|
|
|
52142
52424
|
} catch {
|
|
52143
52425
|
return false;
|
|
52144
52426
|
}
|
|
52145
|
-
const ours = resolve16(
|
|
52427
|
+
const ours = resolve16(join99(homedir58(), ".runwork", "bin"));
|
|
52146
52428
|
const rel = relative11(ours, resolve16(target));
|
|
52147
52429
|
const insideOurs = rel === "" || !rel.startsWith("..") && !isAbsolute14(rel);
|
|
52148
52430
|
if (!insideOurs)
|
|
@@ -52312,7 +52594,7 @@ This will remove all Runwork configuration from your local agents:
|
|
|
52312
52594
|
errors++;
|
|
52313
52595
|
}
|
|
52314
52596
|
}
|
|
52315
|
-
const stateDir = label === "project" ?
|
|
52597
|
+
const stateDir = label === "project" ? join99(process.cwd(), ".runwork") : join99(homedir58(), ".runwork");
|
|
52316
52598
|
if (existsSync85(stateDir)) {
|
|
52317
52599
|
const outcome = removeRunworkState(stateDir, {
|
|
52318
52600
|
keepAuth: Boolean(opts.keepAuth) && label === "user"
|
|
@@ -53001,7 +53283,7 @@ var init_capture_plan = __esm(() => {
|
|
|
53001
53283
|
|
|
53002
53284
|
// src/debug/node-port.ts
|
|
53003
53285
|
import { closeSync as closeSync8, fsyncSync, mkdirSync as mkdirSync41, openSync as openSync8, readSync as readSync5, readdirSync as readdirSync33, statSync as statSync31, writeSync as writeSync2 } from "fs";
|
|
53004
|
-
import { dirname as dirname26, join as
|
|
53286
|
+
import { dirname as dirname26, join as join100 } from "path";
|
|
53005
53287
|
function truncate4(text, maxBytes) {
|
|
53006
53288
|
return text.length > maxBytes ? { text: text.slice(0, maxBytes), truncated: true } : { text, truncated: false };
|
|
53007
53289
|
}
|
|
@@ -53044,7 +53326,7 @@ function createNodeCapturePort(outputPath) {
|
|
|
53044
53326
|
for (const name of names) {
|
|
53045
53327
|
if (out.length >= maxEntries)
|
|
53046
53328
|
break;
|
|
53047
|
-
const full =
|
|
53329
|
+
const full = join100(dir, name);
|
|
53048
53330
|
const kind = entryKind(full);
|
|
53049
53331
|
let bytes;
|
|
53050
53332
|
let modifiedAt;
|
|
@@ -53118,10 +53400,10 @@ var init_node_port = __esm(() => {
|
|
|
53118
53400
|
import { Command as Command46 } from "commander";
|
|
53119
53401
|
import { readFileSync as readFileSync64 } from "fs";
|
|
53120
53402
|
import { homedir as homedir59, platform as platform9, release, arch, type as osType } from "os";
|
|
53121
|
-
import { join as
|
|
53403
|
+
import { join as join101 } from "path";
|
|
53122
53404
|
function defaultOutputPath(now) {
|
|
53123
53405
|
const stamp = now.toISOString().replace(/[:.]/g, "-").replace("T", "_").slice(0, 19);
|
|
53124
|
-
return
|
|
53406
|
+
return join101(homedir59(), ".runwork", "debug", `runwork-debug-${stamp}.jsonl`);
|
|
53125
53407
|
}
|
|
53126
53408
|
async function detectionByRung(detection) {
|
|
53127
53409
|
const rungs = detectionRungs(detection);
|
|
@@ -53285,7 +53567,7 @@ function spaceFoldersClaim() {
|
|
|
53285
53567
|
}
|
|
53286
53568
|
function readSetupOutcomes() {
|
|
53287
53569
|
try {
|
|
53288
|
-
const state = JSON.parse(readFileSync64(
|
|
53570
|
+
const state = JSON.parse(readFileSync64(join101(homedir59(), ".runwork", "setup.json"), "utf-8"));
|
|
53289
53571
|
return state.lastSpaceFolders ?? {};
|
|
53290
53572
|
} catch {
|
|
53291
53573
|
return {};
|
|
@@ -53555,7 +53837,7 @@ var init_config = __esm(() => {
|
|
|
53555
53837
|
// src/commands/share-convo.ts
|
|
53556
53838
|
import { Command as Command48 } from "commander";
|
|
53557
53839
|
import { readFileSync as readFileSync65, writeFileSync as writeFileSync43, existsSync as existsSync87, mkdtempSync as mkdtempSync4 } from "fs";
|
|
53558
|
-
import { join as
|
|
53840
|
+
import { join as join102 } from "path";
|
|
53559
53841
|
import { tmpdir as tmpdir8 } from "os";
|
|
53560
53842
|
import { createHash as createHash11 } from "crypto";
|
|
53561
53843
|
function updateConflict(opts, isPersonalAlias) {
|
|
@@ -53586,8 +53868,8 @@ function resolveLocalSessionShare(opts, conversation) {
|
|
|
53586
53868
|
console.error("Error: this conversation has no shareable content.");
|
|
53587
53869
|
process.exit(1);
|
|
53588
53870
|
}
|
|
53589
|
-
const tempDir = mkdtempSync4(
|
|
53590
|
-
const transcriptFile =
|
|
53871
|
+
const tempDir = mkdtempSync4(join102(tmpdir8(), "runwork-share-"));
|
|
53872
|
+
const transcriptFile = join102(tempDir, "transcript.md");
|
|
53591
53873
|
writeFileSync43(transcriptFile, markdown);
|
|
53592
53874
|
opts.transcriptFile = transcriptFile;
|
|
53593
53875
|
if (adapter?.nativeTranscript && conversation.transcriptPath) {
|
|
@@ -54085,7 +54367,7 @@ import { spawn as cpSpawn3 } from "child_process";
|
|
|
54085
54367
|
import { Command as Command52 } from "commander";
|
|
54086
54368
|
import { existsSync as existsSync88, readFileSync as readFileSync66 } from "fs";
|
|
54087
54369
|
import { constants as osConstants } from "os";
|
|
54088
|
-
import { basename as basename21, join as
|
|
54370
|
+
import { basename as basename21, join as join103 } from "path";
|
|
54089
54371
|
function gitPassthroughArgs(argv) {
|
|
54090
54372
|
if (argv[0] !== "git" || argv[1] === "install")
|
|
54091
54373
|
return null;
|
|
@@ -54101,10 +54383,10 @@ function printLicence() {
|
|
|
54101
54383
|
console.log(`Runwork git is not installed under ${root}. Run \`runwork git install\` to install it.`);
|
|
54102
54384
|
return;
|
|
54103
54385
|
}
|
|
54104
|
-
const copying =
|
|
54386
|
+
const copying = join103(build, "COPYING");
|
|
54105
54387
|
console.log(existsSync88(copying) ? `Git's licence (GPL-2.0): ${copying}` : `Git's licence is not in ${build}. Run \`runwork git install --force\` to install it again.`);
|
|
54106
54388
|
try {
|
|
54107
|
-
const notice = readFileSync66(
|
|
54389
|
+
const notice = readFileSync66(join103(build, "NOTICE"), "utf-8").trimEnd();
|
|
54108
54390
|
console.log("");
|
|
54109
54391
|
console.log(notice);
|
|
54110
54392
|
} catch {
|
|
@@ -54227,7 +54509,7 @@ function forPersonGlobal(git, args) {
|
|
|
54227
54509
|
return git;
|
|
54228
54510
|
const env = { ...git.env };
|
|
54229
54511
|
delete env.GIT_CONFIG_GLOBAL;
|
|
54230
|
-
const theirs = personEnv(process.env,
|
|
54512
|
+
const theirs = personEnv(process.env, join103(portableGitRoot(), "config"), process.platform).GIT_CONFIG_GLOBAL;
|
|
54231
54513
|
if (theirs)
|
|
54232
54514
|
env.GIT_CONFIG_GLOBAL = theirs;
|
|
54233
54515
|
return { ...git, env };
|