patchwork-os 1.1.0-beta.3.canary.409 → 1.1.0-beta.3.canary.411
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.
|
@@ -25,6 +25,13 @@ export interface LockDiscoveryDeps {
|
|
|
25
25
|
*/
|
|
26
26
|
cwd?: string;
|
|
27
27
|
}
|
|
28
|
+
/**
|
|
29
|
+
* True when `cwd` is the workspace root or a descendant of it. Exported for
|
|
30
|
+
* direct unit testing of the cross-platform (case/slash) comparison rules —
|
|
31
|
+
* `findBridgeLock`'s own tests otherwise depend on non-deterministic
|
|
32
|
+
* `readdir` ordering to observe which candidate wins.
|
|
33
|
+
*/
|
|
34
|
+
export declare function cwdInWorkspace(cwd: string, workspace: string): boolean;
|
|
28
35
|
/**
|
|
29
36
|
* Scan ~/.claude/ide/*.lock and return one running patchwork bridge
|
|
30
37
|
* (isBridge:true + live PID). Port is parsed from the lockfile name.
|
|
@@ -1,12 +1,29 @@
|
|
|
1
1
|
import fs from "node:fs";
|
|
2
2
|
import os from "node:os";
|
|
3
3
|
import path from "node:path";
|
|
4
|
-
/**
|
|
5
|
-
|
|
4
|
+
/**
|
|
5
|
+
* Normalize a path for cross-platform comparison: resolve it, convert
|
|
6
|
+
* backslashes to forward slashes, and (on Windows only) lowercase it — NTFS
|
|
7
|
+
* paths are case-insensitive but VS Code / a terminal-spawned process can
|
|
8
|
+
* report the same path with different drive-letter/segment casing.
|
|
9
|
+
*/
|
|
10
|
+
function normalizePathForComparison(p) {
|
|
11
|
+
const resolved = path.resolve(p).replace(/\\/g, "/");
|
|
12
|
+
return process.platform === "win32" ? resolved.toLowerCase() : resolved;
|
|
13
|
+
}
|
|
14
|
+
/**
|
|
15
|
+
* True when `cwd` is the workspace root or a descendant of it. Exported for
|
|
16
|
+
* direct unit testing of the cross-platform (case/slash) comparison rules —
|
|
17
|
+
* `findBridgeLock`'s own tests otherwise depend on non-deterministic
|
|
18
|
+
* `readdir` ordering to observe which candidate wins.
|
|
19
|
+
*/
|
|
20
|
+
export function cwdInWorkspace(cwd, workspace) {
|
|
6
21
|
if (!workspace)
|
|
7
22
|
return false;
|
|
8
|
-
const
|
|
9
|
-
|
|
23
|
+
const normCwd = normalizePathForComparison(cwd);
|
|
24
|
+
const normWorkspace = normalizePathForComparison(workspace);
|
|
25
|
+
const rel = path.posix.relative(normWorkspace, normCwd);
|
|
26
|
+
return rel === "" || (!rel.startsWith("..") && !path.posix.isAbsolute(rel));
|
|
10
27
|
}
|
|
11
28
|
function defaultIsLive(pid) {
|
|
12
29
|
try {
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"bridgeLockDiscovery.js","sourceRoot":"","sources":["../src/bridgeLockDiscovery.ts"],"names":[],"mappings":"AAAA,OAAO,EAAE,MAAM,SAAS,CAAC;AACzB,OAAO,EAAE,MAAM,SAAS,CAAC;AACzB,OAAO,IAAI,MAAM,WAAW,CAAC;AA+B7B
|
|
1
|
+
{"version":3,"file":"bridgeLockDiscovery.js","sourceRoot":"","sources":["../src/bridgeLockDiscovery.ts"],"names":[],"mappings":"AAAA,OAAO,EAAE,MAAM,SAAS,CAAC;AACzB,OAAO,EAAE,MAAM,SAAS,CAAC;AACzB,OAAO,IAAI,MAAM,WAAW,CAAC;AA+B7B;;;;;GAKG;AACH,SAAS,0BAA0B,CAAC,CAAS;IAC3C,MAAM,QAAQ,GAAG,IAAI,CAAC,OAAO,CAAC,CAAC,CAAC,CAAC,OAAO,CAAC,KAAK,EAAE,GAAG,CAAC,CAAC;IACrD,OAAO,OAAO,CAAC,QAAQ,KAAK,OAAO,CAAC,CAAC,CAAC,QAAQ,CAAC,WAAW,EAAE,CAAC,CAAC,CAAC,QAAQ,CAAC;AAC1E,CAAC;AAED;;;;;GAKG;AACH,MAAM,UAAU,cAAc,CAAC,GAAW,EAAE,SAAiB;IAC3D,IAAI,CAAC,SAAS;QAAE,OAAO,KAAK,CAAC;IAC7B,MAAM,OAAO,GAAG,0BAA0B,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AAC,IAAI,KAAK,OAAO,CAAC;YAC7D,CAAC;YACD,IAAI,CAAC,IAAI;gBAAE,SAAS;YACpB,MAAM,IAAI,GAAG,MAAM,CAAC,QAAQ,CAAC,CAAC,CAAC,OAAO,CAAC,SAAS,EAAE,EAAE,CAAC,EAAE,EAAE,CAAC,CAAC;YAC3D,IAAI,CAAC,MAAM,CAAC,QAAQ,CAAC,IAAI,CAAC;gBAAE,SAAS;YACrC,GAAG,CAAC,IAAI,CAAC;gBACP,IAAI;gBACJ,SAAS,EAAE,MAAM,CAAC,SAAS,IAAI,EAAE;gBACjC,GAAG,EAAE,MAAM,CAAC,GAAG;gBACf,SAAS,EAAE,MAAM,CAAC,SAAS,IAAI,EAAE;aAClC,CAAC,CAAC;QACL,CAAC;QAAC,MAAM,CAAC;YACP,sBAAsB;QACxB,CAAC;IACH,CAAC;IACD,OAAO,GAAG,CAAC;AACb,CAAC"}
|
package/package.json
CHANGED
|
@@ -1,6 +1,6 @@
|
|
|
1
1
|
{
|
|
2
2
|
"name": "patchwork-os",
|
|
3
|
-
"version": "1.1.0-beta.3.canary.
|
|
3
|
+
"version": "1.1.0-beta.3.canary.411",
|
|
4
4
|
"description": "Your personal AI runtime, local-first. Patchwork OS gives any AI model a consistent set of tools, YAML recipes, a delegation policy with approval queue, and a durable trace memory — all on your machine, all under your policy.",
|
|
5
5
|
"type": "module",
|
|
6
6
|
"main": "dist/index.js",
|
|
@@ -51,14 +51,26 @@ function isAlive(pid) {
|
|
|
51
51
|
// rather than on every poll tick.
|
|
52
52
|
let lastSelectedLockPath = null;
|
|
53
53
|
|
|
54
|
+
// Normalize a path for cross-platform comparison: resolve it, convert
|
|
55
|
+
// backslashes to forward slashes, and (on Windows only) lowercase it — NTFS
|
|
56
|
+
// paths are case-insensitive but a VS Code-spawned bridge and a
|
|
57
|
+
// terminal-spawned shim can report the same path with different casing.
|
|
58
|
+
// Mirrors normalizePathForComparison() in src/bridgeLockDiscovery.ts.
|
|
59
|
+
function normalizePathForComparison(p) {
|
|
60
|
+
const resolved = path.resolve(p).replace(/\\/g, "/");
|
|
61
|
+
return process.platform === "win32" ? resolved.toLowerCase() : resolved;
|
|
62
|
+
}
|
|
63
|
+
|
|
54
64
|
// True when `cwd` is the workspace root or a descendant of it. Used (only when
|
|
55
65
|
// no --workspace filter is set) to prefer the bridge for the project the shim is
|
|
56
66
|
// actually running in, rather than whichever lock has the newest mtime. Mirrors
|
|
57
67
|
// cwdInWorkspace() in src/bridgeLockDiscovery.ts (unit-tested there).
|
|
58
68
|
function cwdInWorkspace(cwd, workspace) {
|
|
59
69
|
if (!workspace) return false;
|
|
60
|
-
const
|
|
61
|
-
|
|
70
|
+
const normCwd = normalizePathForComparison(cwd);
|
|
71
|
+
const normWorkspace = normalizePathForComparison(workspace);
|
|
72
|
+
const rel = path.posix.relative(normWorkspace, normCwd);
|
|
73
|
+
return rel === "" || (!rel.startsWith("..") && !path.posix.isAbsolute(rel));
|
|
62
74
|
}
|
|
63
75
|
|
|
64
76
|
function findLockFile() {
|
|
@@ -93,7 +105,14 @@ function findLockFile() {
|
|
|
93
105
|
// When a workspace filter is set, require an EXACT workspace match — a
|
|
94
106
|
// lock with a missing/blank workspace field must not be picked under the
|
|
95
107
|
// filter (otherwise the shim can latch onto an unrelated bridge).
|
|
96
|
-
|
|
108
|
+
// Normalized so a --workspace flag with different drive-letter casing
|
|
109
|
+
// than the lock file's recorded path still matches on Windows.
|
|
110
|
+
if (
|
|
111
|
+
workspaceFilter &&
|
|
112
|
+
(!data?.workspace ||
|
|
113
|
+
normalizePathForComparison(data.workspace) !==
|
|
114
|
+
normalizePathForComparison(workspaceFilter))
|
|
115
|
+
)
|
|
97
116
|
continue;
|
|
98
117
|
const isBridge = data ? data.isBridge === true : false;
|
|
99
118
|
const isOrchestrator = data ? data.orchestrator === true : false;
|