@loucompanion/forge-bridge 0.1.4-dev.e1b4f55fb18d → 0.1.4-dev.e3697e9f5c98
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/README.md +42 -0
- package/dist/bridge/bridge.base.d.ts +9 -0
- package/dist/bridge/bridge.service.d.ts +70 -1
- package/dist/bridge/bridge.service.js +278 -4
- package/dist/bridge/bridge.types.d.ts +11 -0
- package/dist/bridge/local-yield-flag.d.ts +6 -0
- package/dist/bridge/local-yield-flag.js +34 -0
- package/dist/cleanup/cleanup.service.js +15 -9
- package/dist/cleanup/forge-owned-paths.d.ts +9 -0
- package/dist/cleanup/forge-owned-paths.js +53 -0
- package/dist/cli/cli.help.js +18 -0
- package/dist/cli/cli.service.d.ts +16 -0
- package/dist/cli/cli.service.js +132 -14
- package/dist/cli/local-config.d.ts +4 -0
- package/dist/cli/local-config.js +26 -4
- package/dist/runtime/aspnet-runtime-prebuild.js +94 -6
- package/dist/runtime/host-load-admission.d.ts +9 -1
- package/dist/runtime/host-load-admission.js +19 -4
- package/dist/runtime/host-load-child-environment.js +3 -1
- package/dist/runtime/host-load-governor-config.d.ts +9 -0
- package/dist/runtime/host-load-governor-config.js +30 -0
- package/dist/runtime/host-load-governor.d.ts +2 -0
- package/dist/runtime/host-load-governor.js +23 -1
- package/dist/runtime/host-load-runtime-settings.d.ts +25 -0
- package/dist/runtime/host-load-runtime-settings.js +78 -0
- package/dist/runtime/host-runtime-lease.d.ts +58 -2
- package/dist/runtime/host-runtime-lease.js +198 -7
- package/dist/runtime/host-runtime-promotion.d.ts +23 -0
- package/dist/runtime/host-runtime-promotion.js +36 -0
- package/dist/runtime/playwright-host-runtime-adapter.d.ts +7 -0
- package/dist/runtime/playwright-host-runtime-adapter.js +13 -1
- package/dist/runtime/runner-settings.d.ts +100 -0
- package/dist/runtime/runner-settings.js +214 -0
- package/dist/session/pre-publication-pass.d.ts +60 -0
- package/dist/session/pre-publication-pass.js +145 -0
- package/dist/session/pre-publication-validation.d.ts +21 -11
- package/dist/session/pre-publication-validation.js +149 -104
- package/dist/session/provider-cli/pre-publication-repair.d.ts +40 -0
- package/dist/session/provider-cli/pre-publication-repair.js +243 -0
- package/dist/session/provider-cli/provider-cli.prompts.js +4 -1
- package/dist/session/provider-cli/provider-cli.service.d.ts +4 -1
- package/dist/session/provider-cli/provider-cli.service.js +72 -143
- package/dist/session/provider-cli/provider-cli.types.d.ts +26 -0
- package/dist/session/session.base.d.ts +6 -1
- package/dist/session/session.service.d.ts +7 -2
- package/dist/session/session.service.js +100 -2
- package/dist/session/session.types.js +2 -2
- package/dist/session/workspace-runtime-fingerprint.d.ts +32 -0
- package/dist/session/workspace-runtime-fingerprint.js +138 -0
- package/dist/shared/provider-capabilities.js +5 -6
- package/dist/version.d.ts +1 -1
- package/dist/version.js +1 -1
- package/package.json +2 -2
|
@@ -0,0 +1,138 @@
|
|
|
1
|
+
import { createHash } from "node:crypto";
|
|
2
|
+
import fs from "node:fs/promises";
|
|
3
|
+
import path from "node:path";
|
|
4
|
+
import { GitClient } from "../shared/git/git.js";
|
|
5
|
+
import { loadHostRuntimeContract } from "../runtime/host-runtime-contract.js";
|
|
6
|
+
import { hostRuntimeContractFingerprint } from "../runtime/host-runtime-promotion.js";
|
|
7
|
+
import { isRuntimeOnlyPath } from "./publishable-worktree-changes.js";
|
|
8
|
+
/** Untracked files up to this size are hashed by content; larger ones by size and mtime. */
|
|
9
|
+
const untrackedContentHashLimitBytes = 1024 * 1024;
|
|
10
|
+
/**
|
|
11
|
+
* Forge's own runtime output never changes what the application runs, and Forge
|
|
12
|
+
* rewrites some of it (readiness manifests, completion artifacts) between passes.
|
|
13
|
+
*/
|
|
14
|
+
const runtimeOnlyPathspecs = [
|
|
15
|
+
":(exclude).local",
|
|
16
|
+
":(exclude).forge/work-items",
|
|
17
|
+
":(exclude).forge/stories",
|
|
18
|
+
];
|
|
19
|
+
export async function readWorkspaceRuntimeFingerprint(worktreePath, git = new GitClient()) {
|
|
20
|
+
const headSha = (await git.run(worktreePath, ["rev-parse", "--verify", "HEAD^{commit}"])).trim().toLowerCase();
|
|
21
|
+
const mergeHead = await readMergeHead(git, worktreePath);
|
|
22
|
+
// A mode change (chmod +x on a launch script) changes what runs. The repository may set
|
|
23
|
+
// core.fileMode=false, which would drop it from the diff, so this read always records modes.
|
|
24
|
+
const diff = await git.run(worktreePath, ["-c", "core.fileMode=true", "diff", "HEAD", "--binary", "--no-ext-diff", "--no-textconv", "--", ".", ...runtimeOnlyPathspecs]);
|
|
25
|
+
const diffDigest = sha256(diff);
|
|
26
|
+
const untracked = (await git.run(worktreePath, [
|
|
27
|
+
"ls-files", "--others", "--exclude-standard", "-z", "--", ".", ...runtimeOnlyPathspecs,
|
|
28
|
+
]))
|
|
29
|
+
.split("\0")
|
|
30
|
+
.filter(entry => entry.length > 0 && !isRuntimeOnlyPath(entry))
|
|
31
|
+
.sort((left, right) => left.localeCompare(right));
|
|
32
|
+
const untrackedHash = createHash("sha256");
|
|
33
|
+
for (const relative of untracked) {
|
|
34
|
+
untrackedHash.update(relative).update("\0");
|
|
35
|
+
const absolute = path.join(worktreePath, relative);
|
|
36
|
+
const stat = await fs.lstat(absolute).catch(() => null);
|
|
37
|
+
if (!stat) {
|
|
38
|
+
untrackedHash.update("missing\0");
|
|
39
|
+
continue;
|
|
40
|
+
}
|
|
41
|
+
// Like git, record the executable bit: chmod changes what runs without touching content or mtime.
|
|
42
|
+
untrackedHash.update(stat.isFile() && (stat.mode & 0o111) !== 0 ? "exec\0" : "plain\0");
|
|
43
|
+
if (stat.isFile() && stat.size <= untrackedContentHashLimitBytes) {
|
|
44
|
+
const content = await fs.readFile(absolute).catch(() => null);
|
|
45
|
+
untrackedHash.update(content ? `content:${sha256(content)}\0` : `unreadable:${stat.size}:${stat.mtimeMs}\0`);
|
|
46
|
+
}
|
|
47
|
+
else {
|
|
48
|
+
untrackedHash.update(`stat:${stat.size}:${stat.mtimeMs}\0`);
|
|
49
|
+
}
|
|
50
|
+
}
|
|
51
|
+
const untrackedDigest = `sha256:${untrackedHash.digest("hex")}`;
|
|
52
|
+
const runtimeInputsDigest = await readRuntimeInputsDigest(worktreePath);
|
|
53
|
+
const digest = sha256(JSON.stringify({ headSha, mergeHead, diffDigest, untrackedDigest, runtimeInputsDigest }));
|
|
54
|
+
return { headSha, mergeHead, diffDigest, untrackedDigest, runtimeInputsDigest, digest };
|
|
55
|
+
}
|
|
56
|
+
export function sameWorkspaceRuntimeFingerprint(left, right) {
|
|
57
|
+
return left !== null && right !== null && left.digest === right.digest;
|
|
58
|
+
}
|
|
59
|
+
/** Names what changed between two fingerprints, for the restart checkpoint. */
|
|
60
|
+
export function workspaceRuntimeFingerprintChanges(previous, current) {
|
|
61
|
+
if (!previous)
|
|
62
|
+
return ["unrecorded"];
|
|
63
|
+
const changes = [];
|
|
64
|
+
if (previous.headSha !== current.headSha)
|
|
65
|
+
changes.push("head");
|
|
66
|
+
if (previous.mergeHead !== current.mergeHead)
|
|
67
|
+
changes.push("merge_head");
|
|
68
|
+
if (previous.diffDigest !== current.diffDigest)
|
|
69
|
+
changes.push("tracked_changes");
|
|
70
|
+
if (previous.untrackedDigest !== current.untrackedDigest)
|
|
71
|
+
changes.push("untracked_files");
|
|
72
|
+
if (previous.runtimeInputsDigest !== current.runtimeInputsDigest)
|
|
73
|
+
changes.push("runtime_inputs");
|
|
74
|
+
return changes;
|
|
75
|
+
}
|
|
76
|
+
/**
|
|
77
|
+
* The loaded runtime contract (project file or derived) and each regular file inside the worktree
|
|
78
|
+
* that a configured launch names as its command or an argument, by executable bit and content.
|
|
79
|
+
* Ignored or not: these are exactly what the stack was launched from. Nothing else ignored is read.
|
|
80
|
+
*/
|
|
81
|
+
async function readRuntimeInputsDigest(worktreePath) {
|
|
82
|
+
const hash = createHash("sha256");
|
|
83
|
+
let contract;
|
|
84
|
+
try {
|
|
85
|
+
contract = await loadHostRuntimeContract(worktreePath);
|
|
86
|
+
}
|
|
87
|
+
catch (error) {
|
|
88
|
+
// An unloadable contract is a state of its own; the restart reports why it cannot load.
|
|
89
|
+
const message = error instanceof Error ? error.message : String(error);
|
|
90
|
+
return sha256(`unloadable:${message.split(":", 1)[0]}`);
|
|
91
|
+
}
|
|
92
|
+
hash.update(`contract:${hostRuntimeContractFingerprint(contract)}\0`);
|
|
93
|
+
const root = await fs.realpath(worktreePath);
|
|
94
|
+
const named = new Set();
|
|
95
|
+
for (const port of contract.contract.runtime.ports) {
|
|
96
|
+
if (!port.launch)
|
|
97
|
+
continue;
|
|
98
|
+
const workingDirectory = path.resolve(root, port.launch.workingDirectory);
|
|
99
|
+
for (const candidate of [port.launch.command, ...port.launch.args]) {
|
|
100
|
+
if (!candidate || candidate.startsWith("-"))
|
|
101
|
+
continue;
|
|
102
|
+
const absolute = path.resolve(workingDirectory, candidate);
|
|
103
|
+
const relative = path.relative(root, absolute);
|
|
104
|
+
if (relative === "" || relative.startsWith("..") || path.isAbsolute(relative))
|
|
105
|
+
continue;
|
|
106
|
+
named.add(relative);
|
|
107
|
+
}
|
|
108
|
+
}
|
|
109
|
+
for (const relative of [...named].sort((left, right) => left.localeCompare(right))) {
|
|
110
|
+
const stat = await fs.stat(path.join(root, relative)).catch(() => null);
|
|
111
|
+
if (!stat?.isFile())
|
|
112
|
+
continue;
|
|
113
|
+
hash.update(relative).update("\0").update((stat.mode & 0o111) !== 0 ? "exec\0" : "plain\0");
|
|
114
|
+
if (stat.size <= untrackedContentHashLimitBytes) {
|
|
115
|
+
const content = await fs.readFile(path.join(root, relative)).catch(() => null);
|
|
116
|
+
hash.update(content ? `content:${sha256(content)}\0` : `unreadable:${stat.size}:${stat.mtimeMs}\0`);
|
|
117
|
+
}
|
|
118
|
+
else {
|
|
119
|
+
hash.update(`stat:${stat.size}:${stat.mtimeMs}\0`);
|
|
120
|
+
}
|
|
121
|
+
}
|
|
122
|
+
return `sha256:${hash.digest("hex")}`;
|
|
123
|
+
}
|
|
124
|
+
async function readMergeHead(git, worktreePath) {
|
|
125
|
+
const relative = (await git.run(worktreePath, ["rev-parse", "--git-path", "MERGE_HEAD"])).trim();
|
|
126
|
+
if (!relative)
|
|
127
|
+
return null;
|
|
128
|
+
const mergeHeadPath = path.resolve(worktreePath, relative);
|
|
129
|
+
const content = await fs.readFile(mergeHeadPath, "utf8").catch((error) => {
|
|
130
|
+
if (error.code === "ENOENT")
|
|
131
|
+
return null;
|
|
132
|
+
throw error;
|
|
133
|
+
});
|
|
134
|
+
return content === null ? null : content.trim().toLowerCase();
|
|
135
|
+
}
|
|
136
|
+
function sha256(value) {
|
|
137
|
+
return `sha256:${createHash("sha256").update(value).digest("hex")}`;
|
|
138
|
+
}
|
|
@@ -40,8 +40,12 @@ function chatProviderEntries(cliProviders, providerStatuses) {
|
|
|
40
40
|
const providerKind = provider.trim().toLowerCase();
|
|
41
41
|
if (providerKind.length === 0)
|
|
42
42
|
continue;
|
|
43
|
-
statuses.set(providerKind, {
|
|
43
|
+
statuses.set(providerKind, { status });
|
|
44
44
|
}
|
|
45
|
+
// Only configured CLI providers can run a Bridge Chat turn. A status entry for a
|
|
46
|
+
// provider that is not in cliProviders (for example a leftover entry in
|
|
47
|
+
// bridge.json for a CLI that is no longer installed) annotates nothing and must
|
|
48
|
+
// not be advertised as a chat provider.
|
|
45
49
|
const providers = new Map();
|
|
46
50
|
for (const provider of cliProviders) {
|
|
47
51
|
const providerKind = provider.trim().toLowerCase();
|
|
@@ -52,11 +56,6 @@ function chatProviderEntries(cliProviders, providerStatuses) {
|
|
|
52
56
|
status: statuses.get(providerKind)?.status,
|
|
53
57
|
});
|
|
54
58
|
}
|
|
55
|
-
for (const [providerKind, entry] of statuses) {
|
|
56
|
-
if (!providers.has(providerKind)) {
|
|
57
|
-
providers.set(providerKind, entry);
|
|
58
|
-
}
|
|
59
|
-
}
|
|
60
59
|
return [...providers.values()].sort((left, right) => compareStable(left.providerKind, right.providerKind));
|
|
61
60
|
}
|
|
62
61
|
function sortedUniqueStrings(values, lower) {
|
package/dist/version.d.ts
CHANGED
|
@@ -1 +1 @@
|
|
|
1
|
-
export declare const forgeBridgeVersion = "0.1.4-dev.
|
|
1
|
+
export declare const forgeBridgeVersion = "0.1.4-dev.e3697e9f5c98";
|
package/dist/version.js
CHANGED
|
@@ -1 +1 @@
|
|
|
1
|
-
export const forgeBridgeVersion = "0.1.4-dev.
|
|
1
|
+
export const forgeBridgeVersion = "0.1.4-dev.e3697e9f5c98";
|
package/package.json
CHANGED
|
@@ -1,6 +1,6 @@
|
|
|
1
1
|
{
|
|
2
2
|
"name": "@loucompanion/forge-bridge",
|
|
3
|
-
"version": "0.1.4-dev.
|
|
3
|
+
"version": "0.1.4-dev.e3697e9f5c98",
|
|
4
4
|
"description": "Forge runner bridge CLI for connecting local developer machines to Forge dispatch.",
|
|
5
5
|
"license": "UNLICENSED",
|
|
6
6
|
"type": "module",
|
|
@@ -43,7 +43,7 @@
|
|
|
43
43
|
"test:residue": "node scripts/run-owned-residue-gate.mjs",
|
|
44
44
|
"test:watch": "vitest",
|
|
45
45
|
"smoke:package": "tsc -p tsconfig.json && node scripts/smoke-package.mjs",
|
|
46
|
-
"lint": "eslint \"src/**/*.ts\" \"scripts/**/*.mjs\" \"vitest.config.ts\" \"vitest.setup.ts\""
|
|
46
|
+
"lint": "eslint \"src/**/*.ts\" \"scripts/**/*.mjs\" \"vitest.config.ts\" \"vitest.setup.ts\" && node ../../scripts/class-design/check-eslint-ratchet.mjs bridge"
|
|
47
47
|
},
|
|
48
48
|
"dependencies": {
|
|
49
49
|
"@microsoft/signalr": "^8.0.17",
|