@cortexkit/aft-bridge 0.39.3 → 0.40.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.
Files changed (56) hide show
  1. package/dist/bash-format.d.ts +0 -1
  2. package/dist/bash-format.d.ts.map +1 -1
  3. package/dist/bash-format.js +0 -3
  4. package/dist/bash-format.js.map +1 -1
  5. package/dist/bash-hints.js +97 -9
  6. package/dist/bash-hints.js.map +1 -1
  7. package/dist/bridge.d.ts +23 -1
  8. package/dist/bridge.d.ts.map +1 -1
  9. package/dist/bridge.js +63 -43
  10. package/dist/bridge.js.map +1 -1
  11. package/dist/callgraph-format.d.ts.map +1 -1
  12. package/dist/callgraph-format.js +27 -14
  13. package/dist/callgraph-format.js.map +1 -1
  14. package/dist/coerce.d.ts +39 -0
  15. package/dist/coerce.d.ts.map +1 -1
  16. package/dist/coerce.js +82 -0
  17. package/dist/coerce.js.map +1 -1
  18. package/dist/command-timeouts.d.ts.map +1 -1
  19. package/dist/command-timeouts.js +1 -0
  20. package/dist/command-timeouts.js.map +1 -1
  21. package/dist/config-tiers.d.ts +19 -0
  22. package/dist/config-tiers.d.ts.map +1 -0
  23. package/dist/config-tiers.js +45 -0
  24. package/dist/config-tiers.js.map +1 -0
  25. package/dist/edit-summary.d.ts +5 -0
  26. package/dist/edit-summary.d.ts.map +1 -1
  27. package/dist/edit-summary.js +12 -2
  28. package/dist/edit-summary.js.map +1 -1
  29. package/dist/index.d.ts +11 -9
  30. package/dist/index.d.ts.map +1 -1
  31. package/dist/index.js +8 -6
  32. package/dist/index.js.map +1 -1
  33. package/dist/migration.d.ts +27 -0
  34. package/dist/migration.d.ts.map +1 -1
  35. package/dist/migration.js +384 -2
  36. package/dist/migration.js.map +1 -1
  37. package/dist/onnx-runtime.d.ts +4 -6
  38. package/dist/onnx-runtime.d.ts.map +1 -1
  39. package/dist/onnx-runtime.js +13 -15
  40. package/dist/onnx-runtime.js.map +1 -1
  41. package/dist/paths.d.ts +17 -0
  42. package/dist/paths.d.ts.map +1 -1
  43. package/dist/paths.js +52 -1
  44. package/dist/paths.js.map +1 -1
  45. package/dist/pool.d.ts.map +1 -1
  46. package/dist/pool.js +15 -16
  47. package/dist/pool.js.map +1 -1
  48. package/dist/project-identity.d.ts +30 -0
  49. package/dist/project-identity.d.ts.map +1 -0
  50. package/dist/project-identity.js +69 -0
  51. package/dist/project-identity.js.map +1 -0
  52. package/package.json +1 -1
  53. package/dist/pipe-strip.d.ts +0 -7
  54. package/dist/pipe-strip.d.ts.map +0 -1
  55. package/dist/pipe-strip.js +0 -688
  56. package/dist/pipe-strip.js.map +0 -1
@@ -0,0 +1,69 @@
1
+ import { createHash } from "node:crypto";
2
+ import { realpathSync } from "node:fs";
3
+ import { resolve } from "node:path";
4
+ /**
5
+ * The single TypeScript project-root canonicalizer, mirroring the Rust
6
+ * `cortexkit-paths` `ProjectRootId`: resolve symlinks (`realpath`), strip
7
+ * trailing separators, normalize Windows verbatim/UNC prefixes, and uppercase
8
+ * the drive letter. Falls back to lexical resolution for paths that don't
9
+ * exist (so callers that canonicalize a not-yet-created or transient path stay
10
+ * total instead of throwing).
11
+ *
12
+ * Why one canonicalizer: AFT used to derive project-root identity four
13
+ * different ways across the TS layer — bridge routing realpath'd, but RPC
14
+ * port-file scoping (`projectHash`) and the sidebar status gate compared raw
15
+ * strings. That divergence is the bug behind sidebar-shows-wrong-project and
16
+ * stale-port discovery: a symlinked / raw-spelled launch dir hashed to a
17
+ * different port directory than the bridge routed to.
18
+ *
19
+ * TS↔Rust *pixel* parity is NOT required (under the daemon, subc and AFT
20
+ * re-canonicalize the received root authoritatively). What IS required is
21
+ * TS-internal self-consistency: every routing, scoping, and port-file site
22
+ * routes through THIS function, so the bridge routing key and the RPC port
23
+ * scope always agree for the same project.
24
+ */
25
+ export function canonicalizeProjectRoot(dir) {
26
+ const trimmed = dir.replace(/[/\\]+$/, "");
27
+ let canonical;
28
+ try {
29
+ canonical = realpathSync(trimmed);
30
+ }
31
+ catch {
32
+ canonical = resolve(trimmed);
33
+ }
34
+ return normalizeWindowsRoot(canonical);
35
+ }
36
+ /**
37
+ * Strip Windows extended-length verbatim prefixes (`\\?\`, `\\?\UNC\`) and
38
+ * uppercase a lowercase drive letter so `c:\x` and `C:\x` collapse to one
39
+ * identity. Mirrors `cortexkit-paths`' `windows_non_verbatim_path`. No-op off
40
+ * Windows.
41
+ */
42
+ function normalizeWindowsRoot(p) {
43
+ if (process.platform !== "win32")
44
+ return p;
45
+ let s = p;
46
+ if (s.startsWith("\\\\?\\UNC\\")) {
47
+ s = `\\\\${s.slice("\\\\?\\UNC\\".length)}`;
48
+ }
49
+ else if (s.startsWith("\\\\?\\")) {
50
+ s = s.slice("\\\\?\\".length);
51
+ }
52
+ if (s.length >= 2 && s[1] === ":") {
53
+ const drive = s.charCodeAt(0);
54
+ if (drive >= 97 && drive <= 122) {
55
+ s = s[0].toUpperCase() + s.slice(1);
56
+ }
57
+ }
58
+ return s;
59
+ }
60
+ /**
61
+ * Stable 16-hex scope hash of the canonical project root. Used for RPC
62
+ * port-file directory scoping; because it canonicalizes first, the server
63
+ * writing a port file and the client discovering it agree on the directory
64
+ * even when one was handed a symlinked or raw-spelled path.
65
+ */
66
+ export function projectRootKeyHash(dir) {
67
+ return createHash("sha256").update(canonicalizeProjectRoot(dir)).digest("hex").slice(0, 16);
68
+ }
69
+ //# sourceMappingURL=project-identity.js.map
@@ -0,0 +1 @@
1
+ {"version":3,"file":"project-identity.js","sourceRoot":"","sources":["../src/project-identity.ts"],"names":[],"mappings":"AAAA,OAAO,EAAE,UAAU,EAAE,MAAM,aAAa,CAAC;AACzC,OAAO,EAAE,YAAY,EAAE,MAAM,SAAS,CAAC;AACvC,OAAO,EAAE,OAAO,EAAE,MAAM,WAAW,CAAC;AAEpC;;;;;;;;;;;;;;;;;;;;GAoBG;AACH,MAAM,UAAU,uBAAuB,CAAC,GAAW;IACjD,MAAM,OAAO,GAAG,GAAG,CAAC,OAAO,CAAC,S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AC,GAAG,CAAC,CAAC,CAAC,MAAM,CAAC,KAAK,CAAC,CAAC,KAAK,CAAC,CAAC,EAAE,EAAE,CAAC,CAAC;AAC9F,CAAC"}
package/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "@cortexkit/aft-bridge",
3
- "version": "0.39.3",
3
+ "version": "0.40.0",
4
4
  "type": "module",
5
5
  "description": "Shared NDJSON bridge transport, binary resolution, and ONNX runtime helpers for AFT agent-host plugins (OpenCode, Pi)",
6
6
  "license": "MIT",
@@ -1,7 +0,0 @@
1
- export interface PipeStripResult {
2
- command: string;
3
- stripped: boolean;
4
- note?: string;
5
- }
6
- export declare function maybeStripCompressorPipe(command: string, compressionEnabled: boolean): PipeStripResult;
7
- //# sourceMappingURL=pipe-strip.d.ts.map
@@ -1 +0,0 @@
1
- {"version":3,"file":"pipe-strip.d.ts","sourceRoot":"","sources":["../src/pipe-strip.ts"],"names":[],"mappings":"AAAA,MAAM,WAAW,eAAe;IAC9B,OAAO,EAAE,MAAM,CAAC;IAChB,QAAQ,EAAE,OAAO,CAAC;IAClB,IAAI,CAAC,EAAE,MAAM,CAAC;CACf;AAkDD,wBAAgB,wBAAwB,CACtC,OAAO,EAAE,MAAM,EACf,kBAAkB,EAAE,OAAO,GAC1B,eAAe,CA0BjB"}