@anybuild-ai/ab 0.1.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 (260) hide show
  1. package/CHANGELOG.md +20 -0
  2. package/LICENSE +21 -0
  3. package/README.md +197 -0
  4. package/dist/api/factory.d.ts +8 -0
  5. package/dist/api/factory.d.ts.map +1 -0
  6. package/dist/api/factory.js +9 -0
  7. package/dist/api/factory.js.map +1 -0
  8. package/dist/api/index.d.ts +4 -0
  9. package/dist/api/index.d.ts.map +1 -0
  10. package/dist/api/index.js +3 -0
  11. package/dist/api/index.js.map +1 -0
  12. package/dist/api/stub.d.ts +7 -0
  13. package/dist/api/stub.d.ts.map +1 -0
  14. package/dist/api/stub.js +30 -0
  15. package/dist/api/stub.js.map +1 -0
  16. package/dist/api/types.d.ts +16 -0
  17. package/dist/api/types.d.ts.map +1 -0
  18. package/dist/api/types.js +2 -0
  19. package/dist/api/types.js.map +1 -0
  20. package/dist/artifacts/baseline-types.d.ts +10 -0
  21. package/dist/artifacts/baseline-types.d.ts.map +1 -0
  22. package/dist/artifacts/baseline-types.js +2 -0
  23. package/dist/artifacts/baseline-types.js.map +1 -0
  24. package/dist/artifacts/baseline.d.ts +4 -0
  25. package/dist/artifacts/baseline.d.ts.map +1 -0
  26. package/dist/artifacts/baseline.js +55 -0
  27. package/dist/artifacts/baseline.js.map +1 -0
  28. package/dist/artifacts/canonical-json.d.ts +3 -0
  29. package/dist/artifacts/canonical-json.d.ts.map +1 -0
  30. package/dist/artifacts/canonical-json.js +13 -0
  31. package/dist/artifacts/canonical-json.js.map +1 -0
  32. package/dist/artifacts/disk.d.ts +6 -0
  33. package/dist/artifacts/disk.d.ts.map +1 -0
  34. package/dist/artifacts/disk.js +45 -0
  35. package/dist/artifacts/disk.js.map +1 -0
  36. package/dist/artifacts/hash-content.d.ts +4 -0
  37. package/dist/artifacts/hash-content.d.ts.map +1 -0
  38. package/dist/artifacts/hash-content.js +14 -0
  39. package/dist/artifacts/hash-content.js.map +1 -0
  40. package/dist/artifacts/locations.d.ts +3 -0
  41. package/dist/artifacts/locations.d.ts.map +1 -0
  42. package/dist/artifacts/locations.js +9 -0
  43. package/dist/artifacts/locations.js.map +1 -0
  44. package/dist/artifacts/pull.d.ts +4 -0
  45. package/dist/artifacts/pull.d.ts.map +1 -0
  46. package/dist/artifacts/pull.js +36 -0
  47. package/dist/artifacts/pull.js.map +1 -0
  48. package/dist/artifacts/status.d.ts +7 -0
  49. package/dist/artifacts/status.d.ts.map +1 -0
  50. package/dist/artifacts/status.js +47 -0
  51. package/dist/artifacts/status.js.map +1 -0
  52. package/dist/auth/endpoint-url.d.ts +11 -0
  53. package/dist/auth/endpoint-url.d.ts.map +1 -0
  54. package/dist/auth/endpoint-url.js +32 -0
  55. package/dist/auth/endpoint-url.js.map +1 -0
  56. package/dist/auth/index.d.ts +5 -0
  57. package/dist/auth/index.d.ts.map +1 -0
  58. package/dist/auth/index.js +5 -0
  59. package/dist/auth/index.js.map +1 -0
  60. package/dist/auth/login-url.d.ts +9 -0
  61. package/dist/auth/login-url.d.ts.map +1 -0
  62. package/dist/auth/login-url.js +12 -0
  63. package/dist/auth/login-url.js.map +1 -0
  64. package/dist/auth/logout-url.d.ts +9 -0
  65. package/dist/auth/logout-url.d.ts.map +1 -0
  66. package/dist/auth/logout-url.js +12 -0
  67. package/dist/auth/logout-url.js.map +1 -0
  68. package/dist/auth/perform-login.d.ts +7 -0
  69. package/dist/auth/perform-login.d.ts.map +1 -0
  70. package/dist/auth/perform-login.js +53 -0
  71. package/dist/auth/perform-login.js.map +1 -0
  72. package/dist/auth/perform-logout.d.ts +7 -0
  73. package/dist/auth/perform-logout.d.ts.map +1 -0
  74. package/dist/auth/perform-logout.js +67 -0
  75. package/dist/auth/perform-logout.js.map +1 -0
  76. package/dist/auth/refresh.d.ts +10 -0
  77. package/dist/auth/refresh.d.ts.map +1 -0
  78. package/dist/auth/refresh.js +64 -0
  79. package/dist/auth/refresh.js.map +1 -0
  80. package/dist/auth/session.d.ts +19 -0
  81. package/dist/auth/session.d.ts.map +1 -0
  82. package/dist/auth/session.js +59 -0
  83. package/dist/auth/session.js.map +1 -0
  84. package/dist/auth/token-response.d.ts +9 -0
  85. package/dist/auth/token-response.d.ts.map +1 -0
  86. package/dist/auth/token-response.js +48 -0
  87. package/dist/auth/token-response.js.map +1 -0
  88. package/dist/cli.d.ts +3 -0
  89. package/dist/cli.d.ts.map +1 -0
  90. package/dist/cli.js +4 -0
  91. package/dist/cli.js.map +1 -0
  92. package/dist/clone-url.d.ts +19 -0
  93. package/dist/clone-url.d.ts.map +1 -0
  94. package/dist/clone-url.js +51 -0
  95. package/dist/clone-url.js.map +1 -0
  96. package/dist/commands/clone.d.ts +3 -0
  97. package/dist/commands/clone.d.ts.map +1 -0
  98. package/dist/commands/clone.js +96 -0
  99. package/dist/commands/clone.js.map +1 -0
  100. package/dist/commands/index.d.ts +4 -0
  101. package/dist/commands/index.d.ts.map +1 -0
  102. package/dist/commands/index.js +17 -0
  103. package/dist/commands/index.js.map +1 -0
  104. package/dist/commands/login.d.ts +3 -0
  105. package/dist/commands/login.d.ts.map +1 -0
  106. package/dist/commands/login.js +32 -0
  107. package/dist/commands/login.js.map +1 -0
  108. package/dist/commands/logout.d.ts +3 -0
  109. package/dist/commands/logout.d.ts.map +1 -0
  110. package/dist/commands/logout.js +29 -0
  111. package/dist/commands/logout.js.map +1 -0
  112. package/dist/commands/pull.d.ts +3 -0
  113. package/dist/commands/pull.d.ts.map +1 -0
  114. package/dist/commands/pull.js +53 -0
  115. package/dist/commands/pull.js.map +1 -0
  116. package/dist/commands/push.d.ts +3 -0
  117. package/dist/commands/push.d.ts.map +1 -0
  118. package/dist/commands/push.js +32 -0
  119. package/dist/commands/push.js.map +1 -0
  120. package/dist/commands/status.d.ts +3 -0
  121. package/dist/commands/status.d.ts.map +1 -0
  122. package/dist/commands/status.js +82 -0
  123. package/dist/commands/status.js.map +1 -0
  124. package/dist/commands/types.d.ts +2 -0
  125. package/dist/commands/types.d.ts.map +1 -0
  126. package/dist/commands/types.js +2 -0
  127. package/dist/commands/types.js.map +1 -0
  128. package/dist/commands/validate.d.ts +3 -0
  129. package/dist/commands/validate.d.ts.map +1 -0
  130. package/dist/commands/validate.js +31 -0
  131. package/dist/commands/validate.js.map +1 -0
  132. package/dist/config/cwd.d.ts +6 -0
  133. package/dist/config/cwd.d.ts.map +1 -0
  134. package/dist/config/cwd.js +23 -0
  135. package/dist/config/cwd.js.map +1 -0
  136. package/dist/config/global-config.d.ts +8 -0
  137. package/dist/config/global-config.d.ts.map +1 -0
  138. package/dist/config/global-config.js +70 -0
  139. package/dist/config/global-config.js.map +1 -0
  140. package/dist/config/index.d.ts +7 -0
  141. package/dist/config/index.d.ts.map +1 -0
  142. package/dist/config/index.js +6 -0
  143. package/dist/config/index.js.map +1 -0
  144. package/dist/config/normalize-url.d.ts +5 -0
  145. package/dist/config/normalize-url.d.ts.map +1 -0
  146. package/dist/config/normalize-url.js +23 -0
  147. package/dist/config/normalize-url.js.map +1 -0
  148. package/dist/config/paths.d.ts +8 -0
  149. package/dist/config/paths.d.ts.map +1 -0
  150. package/dist/config/paths.js +32 -0
  151. package/dist/config/paths.js.map +1 -0
  152. package/dist/config/project-config.d.ts +8 -0
  153. package/dist/config/project-config.d.ts.map +1 -0
  154. package/dist/config/project-config.js +77 -0
  155. package/dist/config/project-config.js.map +1 -0
  156. package/dist/config/session-key.d.ts +3 -0
  157. package/dist/config/session-key.d.ts.map +1 -0
  158. package/dist/config/session-key.js +10 -0
  159. package/dist/config/session-key.js.map +1 -0
  160. package/dist/config/types.d.ts +18 -0
  161. package/dist/config/types.d.ts.map +1 -0
  162. package/dist/config/types.js +2 -0
  163. package/dist/config/types.js.map +1 -0
  164. package/dist/errors.d.ts +11 -0
  165. package/dist/errors.d.ts.map +1 -0
  166. package/dist/errors.js +17 -0
  167. package/dist/errors.js.map +1 -0
  168. package/dist/export/be-plv8-identity.d.ts +13 -0
  169. package/dist/export/be-plv8-identity.d.ts.map +1 -0
  170. package/dist/export/be-plv8-identity.js +37 -0
  171. package/dist/export/be-plv8-identity.js.map +1 -0
  172. package/dist/export/canonical-json.d.ts +5 -0
  173. package/dist/export/canonical-json.d.ts.map +1 -0
  174. package/dist/export/canonical-json.js +26 -0
  175. package/dist/export/canonical-json.js.map +1 -0
  176. package/dist/export/checksum-diagnostics.d.ts +7 -0
  177. package/dist/export/checksum-diagnostics.d.ts.map +1 -0
  178. package/dist/export/checksum-diagnostics.js +43 -0
  179. package/dist/export/checksum-diagnostics.js.map +1 -0
  180. package/dist/export/checksum.d.ts +3 -0
  181. package/dist/export/checksum.d.ts.map +1 -0
  182. package/dist/export/checksum.js +6 -0
  183. package/dist/export/checksum.js.map +1 -0
  184. package/dist/export/export-api.d.ts +12 -0
  185. package/dist/export/export-api.d.ts.map +1 -0
  186. package/dist/export/export-api.js +155 -0
  187. package/dist/export/export-api.js.map +1 -0
  188. package/dist/export/file-content.d.ts +14 -0
  189. package/dist/export/file-content.d.ts.map +1 -0
  190. package/dist/export/file-content.js +39 -0
  191. package/dist/export/file-content.js.map +1 -0
  192. package/dist/export/file-state.d.ts +5 -0
  193. package/dist/export/file-state.d.ts.map +1 -0
  194. package/dist/export/file-state.js +51 -0
  195. package/dist/export/file-state.js.map +1 -0
  196. package/dist/export/import-batch.d.ts +19 -0
  197. package/dist/export/import-batch.d.ts.map +1 -0
  198. package/dist/export/import-batch.js +404 -0
  199. package/dist/export/import-batch.js.map +1 -0
  200. package/dist/export/import-files-api.d.ts +14 -0
  201. package/dist/export/import-files-api.d.ts.map +1 -0
  202. package/dist/export/import-files-api.js +85 -0
  203. package/dist/export/import-files-api.js.map +1 -0
  204. package/dist/export/manifest-io.d.ts +4 -0
  205. package/dist/export/manifest-io.d.ts.map +1 -0
  206. package/dist/export/manifest-io.js +31 -0
  207. package/dist/export/manifest-io.js.map +1 -0
  208. package/dist/export/path-based-status.d.ts +16 -0
  209. package/dist/export/path-based-status.d.ts.map +1 -0
  210. package/dist/export/path-based-status.js +104 -0
  211. package/dist/export/path-based-status.js.map +1 -0
  212. package/dist/export/path-sanitize.d.ts +3 -0
  213. package/dist/export/path-sanitize.d.ts.map +1 -0
  214. package/dist/export/path-sanitize.js +20 -0
  215. package/dist/export/path-sanitize.js.map +1 -0
  216. package/dist/export/status.d.ts +37 -0
  217. package/dist/export/status.d.ts.map +1 -0
  218. package/dist/export/status.js +485 -0
  219. package/dist/export/status.js.map +1 -0
  220. package/dist/export/sync.d.ts +20 -0
  221. package/dist/export/sync.d.ts.map +1 -0
  222. package/dist/export/sync.js +160 -0
  223. package/dist/export/sync.js.map +1 -0
  224. package/dist/export/types.d.ts +65 -0
  225. package/dist/export/types.d.ts.map +1 -0
  226. package/dist/export/types.js +2 -0
  227. package/dist/export/types.js.map +1 -0
  228. package/dist/export/ui-component-identity.d.ts +22 -0
  229. package/dist/export/ui-component-identity.d.ts.map +1 -0
  230. package/dist/export/ui-component-identity.js +84 -0
  231. package/dist/export/ui-component-identity.js.map +1 -0
  232. package/dist/export/working-dirs.d.ts +12 -0
  233. package/dist/export/working-dirs.d.ts.map +1 -0
  234. package/dist/export/working-dirs.js +44 -0
  235. package/dist/export/working-dirs.js.map +1 -0
  236. package/dist/export/working-tree-validation.d.ts +15 -0
  237. package/dist/export/working-tree-validation.d.ts.map +1 -0
  238. package/dist/export/working-tree-validation.js +159 -0
  239. package/dist/export/working-tree-validation.js.map +1 -0
  240. package/dist/http/client.d.ts +26 -0
  241. package/dist/http/client.d.ts.map +1 -0
  242. package/dist/http/client.js +59 -0
  243. package/dist/http/client.js.map +1 -0
  244. package/dist/http/index.d.ts +2 -0
  245. package/dist/http/index.d.ts.map +1 -0
  246. package/dist/http/index.js +2 -0
  247. package/dist/http/index.js.map +1 -0
  248. package/dist/io/read-credentials.d.ts +5 -0
  249. package/dist/io/read-credentials.d.ts.map +1 -0
  250. package/dist/io/read-credentials.js +71 -0
  251. package/dist/io/read-credentials.js.map +1 -0
  252. package/dist/progress.d.ts +4 -0
  253. package/dist/progress.d.ts.map +1 -0
  254. package/dist/progress.js +11 -0
  255. package/dist/progress.js.map +1 -0
  256. package/dist/router.d.ts +2 -0
  257. package/dist/router.d.ts.map +1 -0
  258. package/dist/router.js +53 -0
  259. package/dist/router.js.map +1 -0
  260. package/package.json +48 -0
@@ -0,0 +1,104 @@
1
+ import { existsSync, readFileSync } from "node:fs";
2
+ import { md5HexUtf8 } from "./checksum.js";
3
+ import { safeProjectFilePath } from "./path-sanitize.js";
4
+ import { listRelPathsUnderWorkingDirs } from "./working-tree-validation.js";
5
+ import { isUiWorkingTreeJsPath, } from "./ui-component-identity.js";
6
+ function normalizeProjectRelativePath(p) {
7
+ return p.trim().replace(/\\/g, "/").replace(/^\/+/, "");
8
+ }
9
+ /** Manifest entry not yet reflected in `.ab/file-state.json` (e.g. after a local manifest edit). */
10
+ function manifestDiffersFromFileState(entry, fileState) {
11
+ if (fileState === null) {
12
+ return true;
13
+ }
14
+ const prev = fileState.files[entry.id];
15
+ if (prev === undefined) {
16
+ return true;
17
+ }
18
+ return (normalizeProjectRelativePath(prev.path) !==
19
+ normalizeProjectRelativePath(entry.path) ||
20
+ prev.checksum !== entry.checksum ||
21
+ prev.timestamp !== entry.timestamp);
22
+ }
23
+ function diskChecksumForPath(projectRoot, relPath) {
24
+ let abs;
25
+ try {
26
+ abs = safeProjectFilePath(projectRoot, relPath);
27
+ }
28
+ catch {
29
+ return undefined;
30
+ }
31
+ if (!existsSync(abs)) {
32
+ return undefined;
33
+ }
34
+ const content = readFileSync(abs, "utf8");
35
+ return md5HexUtf8(content);
36
+ }
37
+ /**
38
+ * Path-keyed status for backend working trees (`be/plv8`, `be/node` `.js`): compare manifest paths
39
+ * to on-disk checksums; scan disk for unmanifested files.
40
+ */
41
+ export function computePathBasedWorkingTreeStatus(projectRoot, manifestEntries, manifestPaths, diskScanFilter, debug, fileState = null) {
42
+ const debugOut = debug
43
+ ? { modified: [], added: [], deleted: [] }
44
+ : undefined;
45
+ const modified = [];
46
+ const deleted = [];
47
+ for (const m of manifestEntries) {
48
+ const mPath = normalizeProjectRelativePath(m.path);
49
+ const diskChk = diskChecksumForPath(projectRoot, mPath);
50
+ if (diskChk === undefined) {
51
+ deleted.push(m.path);
52
+ if (debugOut) {
53
+ debugOut.deleted.push({
54
+ path: m.path,
55
+ id: m.id,
56
+ manifestChecksum: m.checksum,
57
+ });
58
+ }
59
+ continue;
60
+ }
61
+ const diskChanged = diskChk !== m.checksum;
62
+ const manifestChanged = manifestDiffersFromFileState(m, fileState);
63
+ if (diskChanged || manifestChanged) {
64
+ modified.push(m.path);
65
+ if (debugOut) {
66
+ debugOut.modified.push({
67
+ line: m.path,
68
+ diskPath: mPath,
69
+ id: m.id,
70
+ manifestChecksum: m.checksum,
71
+ diskChecksum: diskChk,
72
+ });
73
+ }
74
+ }
75
+ }
76
+ const added = [];
77
+ for (const rel of listRelPathsUnderWorkingDirs(projectRoot)) {
78
+ const normRel = normalizeProjectRelativePath(rel);
79
+ if (!diskScanFilter(normRel)) {
80
+ continue;
81
+ }
82
+ if (!isUiWorkingTreeJsPath(normRel)) {
83
+ continue;
84
+ }
85
+ if (manifestPaths.has(normRel)) {
86
+ continue;
87
+ }
88
+ const diskChk = diskChecksumForPath(projectRoot, normRel);
89
+ if (diskChk === undefined) {
90
+ continue;
91
+ }
92
+ added.push(normRel);
93
+ if (debugOut) {
94
+ debugOut.added.push({ path: normRel, diskChecksum: diskChk });
95
+ }
96
+ }
97
+ return {
98
+ modified: modified.sort(),
99
+ deleted: deleted.sort(),
100
+ added: added.sort(),
101
+ debug: debugOut,
102
+ };
103
+ }
104
+ //# sourceMappingURL=path-based-status.js.map
@@ -0,0 +1 @@
1
+ {"version":3,"file":"path-based-status.js","sourceRoot":"","sources":["../../src/export/path-based-status.ts"],"names":[],"mappings":"AAAA,OAAO,EAAE,UAAU,EAAE,YAAY,EAAE,MAAM,SAAS,CAAC;AACnD,OAAO,EAAE,UAAU,EAAE,MAAM,e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ths. */
2
+ export declare function safeProjectFilePath(projectRoot: string, relativePath: string): string;
3
+ //# sourceMappingURL=path-sanitize.d.ts.map
@@ -0,0 +1 @@
1
+ {"version":3,"file":"path-sanitize.d.ts","sourceRoot":"","sources":["../../src/export/path-sanitize.ts"],"names":[],"mappings":"AAGA,mFAAmF;AACnF,wBAAgB,mBAAmB,CAAC,WAAW,EAAE,MAAM,EAAE,YAAY,EAAE,MAAM,GAAG,MAAM,CAerF"}
@@ -0,0 +1,20 @@
1
+ import { relative, resolve } from "node:path";
2
+ import { AbCliError } from "../errors.js";
3
+ /** Resolve a relative path under project root; rejects `..` and absolute paths. */
4
+ export function safeProjectFilePath(projectRoot, relativePath) {
5
+ const trimmed = relativePath.trim().replace(/\\/g, "/");
6
+ if (!trimmed || trimmed.includes("..")) {
7
+ throw new AbCliError("CONFIG", `Invalid file path: ${relativePath}`);
8
+ }
9
+ if (trimmed.startsWith("/") || /^[a-zA-Z]:/.test(trimmed)) {
10
+ throw new AbCliError("CONFIG", `Path must be relative: ${relativePath}`);
11
+ }
12
+ const abs = resolve(projectRoot, trimmed);
13
+ const root = resolve(projectRoot);
14
+ const rel = relative(root, abs);
15
+ if (rel.startsWith("..") || rel === "..") {
16
+ throw new AbCliError("CONFIG", `Path escapes project root: ${relativePath}`);
17
+ }
18
+ return abs;
19
+ }
20
+ //# sourceMappingURL=path-sanitize.js.map
@@ -0,0 +1 @@
1
+ {"version":3,"file":"path-sanitize.js","sourceRoot":"","sources":["../../src/export/path-sanitize.ts"],"names":[],"mappings":"AAAA,OAAO,EAAE,QAAQ,EAAE,OAAO,EAAE,MAAM,WAAW,CAAC;AAC9C,OAAO,EAAE,UAAU,EAAE,MAAM,cAAc,CAAC;AAE1C,mFAAmF;AACnF,MAAM,UAAU,mBAAmB,CAAC,WAAmB,EAAE,YAAoB;IAC3E,MAAM,OAAO,GAAG,YAAY,CAAC,IAAI,EAAE,CAAC,OAAO,CAAC,KAAK,EAAE,GAAG,CAAC,CAAC;IACxD,IAAI,CAAC,OAAO,IAAI,OAAO,CAAC,QAAQ,CAAC,IAAI,CAAC,EAAE,CAAC;QACvC,MAAM,IAAI,UAAU,CAAC,QAAQ,EAAE,sBAAsB,YAAY,EAAE,CAAC,CAAC;IACvE,CAAC;IACD,IAAI,OAAO,CAAC,UAAU,CAAC,GAAG,CAAC,IAAI,YAAY,CAAC,IAAI,CAAC,OAAO,CAAC,EAAE,CAAC;QAC1D,MAAM,IAAI,UAAU,CAAC,QAAQ,EAAE,0BAA0B,YAAY,EAAE,CAAC,CAAC;IAC3E,CAAC;IACD,MAAM,GAAG,GAAG,OAAO,CAAC,WAAW,EAAE,OAAO,CAAC,CAAC;IAC1C,MAAM,IAAI,GAAG,OAAO,CAAC,WAAW,CAAC,CAAC;IAClC,MAAM,GAAG,GAAG,QAAQ,CAAC,IAAI,EAAE,GAAG,CAAC,CAAC;IAChC,IAAI,GAAG,CAAC,UAAU,CAAC,IAAI,CAAC,IAAI,GAAG,KAAK,IAAI,EAAE,CAAC;QACzC,MAAM,IAAI,UAAU,CAAC,QAAQ,EAAE,8BAA8B,YAAY,EAAE,CAAC,CAAC;IAC/E,CAAC;IACD,OAAO,GAAG,CAAC;AACb,CAAC"}
@@ -0,0 +1,37 @@
1
+ export type ExportStatusBuckets = {
2
+ modified: string[];
3
+ deleted: string[];
4
+ /** Local paths under configured working dirs not listed in the manifest. */
5
+ added: string[];
6
+ };
7
+ /** When `computeExportStatus(..., { debug: true })`, checksums are MD5 hex (manifest = initial / server snapshot). */
8
+ export type ExportStatusDebug = {
9
+ modified: Array<{
10
+ line: string;
11
+ diskPath: string;
12
+ id?: string;
13
+ manifestChecksum: string;
14
+ diskChecksum: string;
15
+ }>;
16
+ added: Array<{
17
+ path: string;
18
+ diskChecksum: string;
19
+ }>;
20
+ deleted: Array<{
21
+ path: string;
22
+ id?: string;
23
+ manifestChecksum: string;
24
+ }>;
25
+ };
26
+ export type ExportStatusResult = ExportStatusBuckets & {
27
+ debug?: ExportStatusDebug;
28
+ };
29
+ /** Strip ` (was: …)` suffix used for renames when resolving paths for CE validation. */
30
+ export declare function statusLineToDiskPath(line: string): string;
31
+ /** Previous manifest path from a rename status line (`new (was: old)`), if present. */
32
+ export declare function statusLinePreviousPath(line: string): string | undefined;
33
+ export declare function computeExportStatus(projectRoot: string, options?: {
34
+ debug?: boolean;
35
+ onlyPaths?: readonly string[];
36
+ }): ExportStatusResult;
37
+ //# sourceMappingURL=status.d.ts.map
@@ -0,0 +1 @@
1
+ {"version":3,"file":"status.d.ts","sourceRoot":"","sources":["../../src/export/status.ts"],"names":[],"mappings":"AAwBA,MAAM,MAAM,mBAAmB,GAAG;IAChC,QAAQ,EAAE,MAAM,EAAE,CAAC;IACnB,OAAO,EAAE,MAAM,EAAE,CAAC;IAClB,4EAA4E;IAC5E,KAAK,EAAE,MAAM,EAAE,CAAC;CACjB,CAAC;AAEF,sHAAsH;AACtH,MAAM,MAAM,iBAAiB,GAAG;IAC9B,QAAQ,EAAE,KAAK,CAAC;QACd,IAAI,EAAE,MAAM,CAAC;QACb,QAAQ,EAAE,MAAM,CAAC;QACjB,EAAE,CAAC,EAAE,MAAM,CAAC;QACZ,gBAAgB,EAAE,MAAM,CAAC;QACzB,YAAY,EAAE,MAAM,CAAC;KACtB,CAAC,CAAC;IACH,KAAK,EAAE,KAAK,CAAC;QAAE,IAAI,EAAE,MAAM,CAAC;QAAC,YAAY,EAAE,MAAM,CAAA;KAAE,CAAC,CAAC;IACrD,OAAO,EAAE,KAAK,CAAC;QAAE,IAAI,EAAE,MAAM,CAAC;QAAC,EAAE,CAAC,EAAE,MAAM,CAAC;QAAC,gBAAgB,EAAE,MAAM,CAAA;KAAE,CAAC,CAAC;CACzE,CAAC;AAEF,MAAM,MAAM,kBAAkB,GAAG,mBAAmB,GAAG;IACrD,KAAK,CAAC,EAAE,iBAAiB,CAAC;CAC3B,CAAC;AAUF,wFAAwF;AACxF,wBAAgB,oBAAoB,CAAC,IAAI,EAAE,MAAM,GAAG,MAAM,CAGzD;AAED,uFAAuF;AACvF,wBAAgB,sBAAsB,CAAC,IAAI,EAAE,MAAM,GAAG,MAAM,GAAG,SAAS,CAMvE;AAgUD,wBAAgB,mBAAmB,CACjC,WAAW,EAAE,MAAM,EACnB,OAAO,CAAC,EAAE;IAAE,KAAK,CAAC,EAAE,OAAO,CAAC;IAAC,SAAS,CAAC,EAAE,SAAS,MAAM,EAAE,CAAA;CAAE,GAC3D,kBAAkB,CAkRpB"}
@@ -0,0 +1,485 @@
1
+ import { existsSync, readFileSync } from "node:fs";
2
+ import { md5HexUtf8CanonicalJson } from "./canonical-json.js";
3
+ import { md5HexUtf8 } from "./checksum.js";
4
+ import { AbCliError } from "../errors.js";
5
+ import { readFileState } from "./file-state.js";
6
+ import { readManifestJson } from "./manifest-io.js";
7
+ import { safeProjectFilePath } from "./path-sanitize.js";
8
+ import { pathIsUnderBeWorkingTree, pathIsUnderStatusWorkingDirectories, pathIsUnderUiLitWorkingTree, } from "./working-dirs.js";
9
+ import { computePathBasedWorkingTreeStatus } from "./path-based-status.js";
10
+ import { assertUiWorkingTreeValidForStatus, listRelPathsUnderWorkingDirs, } from "./working-tree-validation.js";
11
+ import { isUiWorkingTreeJsPath, isUiWorkingTreeJsonPath, parseCeUuidFromJsSource, } from "./ui-component-identity.js";
12
+ function normalizeProjectRelativePath(p) {
13
+ return p.trim().replace(/\\/g, "/").replace(/^\/+/, "");
14
+ }
15
+ function normId(id) {
16
+ return id.trim().toLowerCase();
17
+ }
18
+ /** Strip ` (was: …)` suffix used for renames when resolving paths for CE validation. */
19
+ export function statusLineToDiskPath(line) {
20
+ const idx = line.indexOf(" (was:");
21
+ return (idx === -1 ? line : line.slice(0, idx)).trim();
22
+ }
23
+ /** Previous manifest path from a rename status line (`new (was: old)`), if present. */
24
+ export function statusLinePreviousPath(line) {
25
+ const m = / \(was: (.+)\)$/.exec(line);
26
+ if (m === null) {
27
+ return undefined;
28
+ }
29
+ return normalizeProjectRelativePath(m[1]);
30
+ }
31
+ function buildManifestJsIndexes(entries) {
32
+ const byId = new Map();
33
+ const byPath = new Map();
34
+ for (const e of entries) {
35
+ const p = normalizeProjectRelativePath(e.path);
36
+ if (!isUiWorkingTreeJsPath(p)) {
37
+ continue;
38
+ }
39
+ byId.set(normId(e.id), e);
40
+ byPath.set(p, e);
41
+ }
42
+ return { byId, byPath };
43
+ }
44
+ function indexWorkingTreeJsFiles(projectRoot, manifestJsByPath) {
45
+ const byId = new Map();
46
+ const noCeByPath = new Map();
47
+ const indexErrors = [];
48
+ for (const rel of listRelPathsUnderWorkingDirs(projectRoot)) {
49
+ const normRel = normalizeProjectRelativePath(rel);
50
+ if (!pathIsUnderUiLitWorkingTree(normRel) || !isUiWorkingTreeJsPath(normRel)) {
51
+ continue;
52
+ }
53
+ let abs;
54
+ try {
55
+ abs = safeProjectFilePath(projectRoot, rel);
56
+ }
57
+ catch {
58
+ continue;
59
+ }
60
+ if (!existsSync(abs)) {
61
+ continue;
62
+ }
63
+ let content;
64
+ try {
65
+ content = readFileSync(abs, "utf8");
66
+ }
67
+ catch {
68
+ continue;
69
+ }
70
+ const checksum = md5HexUtf8(content);
71
+ const parsed = parseCeUuidFromJsSource(content);
72
+ if (!parsed.ok) {
73
+ noCeByPath.set(normRel, checksum);
74
+ continue;
75
+ }
76
+ const idKey = normId(parsed.uuid);
77
+ const atPath = manifestJsByPath.get(normRel);
78
+ if (atPath !== undefined && normId(atPath.id) !== idKey) {
79
+ indexErrors.push(` • ${rel} — file has component id ${parsed.uuid} but manifest expects id ${atPath.id} at this path`);
80
+ continue;
81
+ }
82
+ const existing = byId.get(idKey);
83
+ if (existing !== undefined && existing.path !== normRel) {
84
+ indexErrors.push(` • ${rel} — duplicate component id ${parsed.uuid} (also used by ${existing.path})`);
85
+ continue;
86
+ }
87
+ byId.set(idKey, { path: normRel, checksum });
88
+ }
89
+ return { byId, noCeByPath, indexErrors };
90
+ }
91
+ function formatJsModified(manifestPath, diskPath) {
92
+ const mp = normalizeProjectRelativePath(manifestPath);
93
+ const dp = normalizeProjectRelativePath(diskPath);
94
+ if (dp !== mp) {
95
+ return `${dp} (was: ${mp})`;
96
+ }
97
+ return manifestPath;
98
+ }
99
+ function fileExistsAt(projectRoot, relPath) {
100
+ try {
101
+ const abs = safeProjectFilePath(projectRoot, relPath);
102
+ return existsSync(abs);
103
+ }
104
+ catch {
105
+ return false;
106
+ }
107
+ }
108
+ function computeExportStatusForPaths(projectRoot, onlyPaths, debug) {
109
+ const manifest = readManifestJson(projectRoot);
110
+ if (!manifest) {
111
+ return { modified: [], deleted: [], added: [] };
112
+ }
113
+ const normalized = [...new Set(onlyPaths.map(normalizeProjectRelativePath))];
114
+ const onlySet = new Set(normalized);
115
+ const manifestPaths = new Set(manifest.files.map((f) => normalizeProjectRelativePath(f.path)));
116
+ const fileState = readFileState(projectRoot);
117
+ const modified = [];
118
+ const deleted = [];
119
+ const added = [];
120
+ const debugOut = debug
121
+ ? { modified: [], added: [], deleted: [] }
122
+ : undefined;
123
+ const ceRequiredPaths = new Set();
124
+ const beRequiredPaths = new Set();
125
+ for (const p of normalized) {
126
+ if (!pathIsUnderStatusWorkingDirectories(p)) {
127
+ throw new AbCliError("VALIDATION", `${p} is not under an editable working tree (ui/lit/components, be/plv8, be/node)`);
128
+ }
129
+ if (!isUiWorkingTreeJsPath(p) && !isUiWorkingTreeJsonPath(p)) {
130
+ throw new AbCliError("VALIDATION", `${p} is not a supported working-tree file (.js, or manifest .json under ui/lit)`);
131
+ }
132
+ }
133
+ const beOnly = normalized.filter((p) => pathIsUnderBeWorkingTree(p));
134
+ if (beOnly.length > 0) {
135
+ const beWorkingEntries = manifest.files.filter((f) => {
136
+ const fp = normalizeProjectRelativePath(f.path);
137
+ return (pathIsUnderBeWorkingTree(fp) &&
138
+ isUiWorkingTreeJsPath(fp) &&
139
+ onlySet.has(fp));
140
+ });
141
+ const beSlice = computePathBasedWorkingTreeStatus(projectRoot, beWorkingEntries, manifestPaths, (rel) => {
142
+ const n = normalizeProjectRelativePath(rel);
143
+ return pathIsUnderBeWorkingTree(n) && onlySet.has(n);
144
+ }, debug, fileState);
145
+ modified.push(...beSlice.modified);
146
+ deleted.push(...beSlice.deleted);
147
+ added.push(...beSlice.added);
148
+ if (debugOut && beSlice.debug) {
149
+ debugOut.modified.push(...beSlice.debug.modified);
150
+ debugOut.added.push(...beSlice.debug.added);
151
+ debugOut.deleted.push(...beSlice.debug.deleted);
152
+ }
153
+ for (const line of [...beSlice.added, ...beSlice.modified]) {
154
+ beRequiredPaths.add(normalizeProjectRelativePath(line));
155
+ }
156
+ }
157
+ const uiJsManifest = manifest.files.filter((f) => {
158
+ const fp = normalizeProjectRelativePath(f.path);
159
+ return pathIsUnderUiLitWorkingTree(fp) && isUiWorkingTreeJsPath(fp);
160
+ });
161
+ const { byPath: manifestJsByPath, byId: manifestJsById } = buildManifestJsIndexes(uiJsManifest);
162
+ for (const p of normalized.filter((x) => pathIsUnderUiLitWorkingTree(x) && isUiWorkingTreeJsPath(x))) {
163
+ const manifestByPath = manifestJsByPath.get(p);
164
+ const onDisk = fileExistsAt(projectRoot, p);
165
+ if (onDisk) {
166
+ const abs = safeProjectFilePath(projectRoot, p);
167
+ const content = readFileSync(abs, "utf8");
168
+ const checksum = md5HexUtf8(content);
169
+ const parsed = parseCeUuidFromJsSource(content);
170
+ let entry = manifestByPath;
171
+ if (parsed.ok) {
172
+ entry = manifestJsById.get(normId(parsed.uuid)) ?? entry;
173
+ }
174
+ if (entry === undefined) {
175
+ added.push(p);
176
+ ceRequiredPaths.add(p);
177
+ if (debugOut) {
178
+ debugOut.added.push({ path: p, diskChecksum: checksum });
179
+ }
180
+ continue;
181
+ }
182
+ const mPath = normalizeProjectRelativePath(entry.path);
183
+ const pathChanged = mPath !== p;
184
+ const checksumChanged = checksum !== entry.checksum;
185
+ if (pathChanged || checksumChanged) {
186
+ const line = formatJsModified(entry.path, p);
187
+ modified.push(line);
188
+ ceRequiredPaths.add(p);
189
+ if (debugOut) {
190
+ debugOut.modified.push({
191
+ line,
192
+ diskPath: p,
193
+ id: entry.id,
194
+ manifestChecksum: entry.checksum,
195
+ diskChecksum: checksum,
196
+ });
197
+ }
198
+ }
199
+ continue;
200
+ }
201
+ if (manifestByPath !== undefined) {
202
+ deleted.push(p);
203
+ if (debugOut) {
204
+ debugOut.deleted.push({
205
+ path: p,
206
+ id: manifestByPath.id,
207
+ manifestChecksum: manifestByPath.checksum,
208
+ });
209
+ }
210
+ }
211
+ }
212
+ for (const p of normalized.filter((x) => pathIsUnderUiLitWorkingTree(x) && isUiWorkingTreeJsonPath(x))) {
213
+ const entry = manifest.files.find((f) => normalizeProjectRelativePath(f.path) === p);
214
+ if (entry === undefined) {
215
+ throw new AbCliError("VALIDATION", `${p} is not in the manifest (new JSON files cannot be pushed)`);
216
+ }
217
+ if (!fileExistsAt(projectRoot, p)) {
218
+ deleted.push(p);
219
+ if (debugOut) {
220
+ debugOut.deleted.push({
221
+ path: p,
222
+ id: entry.id,
223
+ manifestChecksum: entry.checksum,
224
+ });
225
+ }
226
+ continue;
227
+ }
228
+ const content = readFileSync(safeProjectFilePath(projectRoot, p), "utf8");
229
+ let diskChk;
230
+ try {
231
+ diskChk = md5HexUtf8CanonicalJson(content);
232
+ }
233
+ catch (e) {
234
+ if (e instanceof AbCliError) {
235
+ throw new AbCliError("VALIDATION", `${p}: ${e.message}`);
236
+ }
237
+ throw e;
238
+ }
239
+ if (diskChk !== entry.checksum) {
240
+ modified.push(p);
241
+ if (debugOut) {
242
+ debugOut.modified.push({
243
+ line: p,
244
+ diskPath: p,
245
+ id: entry.id,
246
+ manifestChecksum: entry.checksum,
247
+ diskChecksum: diskChk,
248
+ });
249
+ }
250
+ }
251
+ }
252
+ assertUiWorkingTreeValidForStatus(projectRoot, manifestPaths, ceRequiredPaths, pathIsUnderUiLitWorkingTree, "UI", onlySet);
253
+ assertUiWorkingTreeValidForStatus(projectRoot, manifestPaths, beRequiredPaths, pathIsUnderBeWorkingTree, "BE", onlySet);
254
+ const result = {
255
+ modified: [...new Set(modified)].sort(),
256
+ deleted: [...new Set(deleted)].sort(),
257
+ added: [...new Set(added)].sort(),
258
+ };
259
+ if (debugOut) {
260
+ debugOut.modified.sort((a, b) => a.line.localeCompare(b.line));
261
+ debugOut.added.sort((a, b) => a.path.localeCompare(b.path));
262
+ debugOut.deleted.sort((a, b) => a.path.localeCompare(b.path));
263
+ result.debug = debugOut;
264
+ }
265
+ return result;
266
+ }
267
+ export function computeExportStatus(projectRoot, options) {
268
+ if (options?.onlyPaths !== undefined && options.onlyPaths.length > 0) {
269
+ return computeExportStatusForPaths(projectRoot, options.onlyPaths, options.debug === true);
270
+ }
271
+ const debug = options?.debug === true;
272
+ const manifest = readManifestJson(projectRoot);
273
+ if (!manifest) {
274
+ return { modified: [], deleted: [], added: [] };
275
+ }
276
+ const debugOut = debug
277
+ ? { modified: [], added: [], deleted: [] }
278
+ : undefined;
279
+ const manifestPaths = new Set(manifest.files.map((f) => normalizeProjectRelativePath(f.path)));
280
+ const workingEntries = manifest.files.filter((f) => pathIsUnderStatusWorkingDirectories(normalizeProjectRelativePath(f.path)));
281
+ const beWorkingEntries = workingEntries.filter((f) => {
282
+ const p = normalizeProjectRelativePath(f.path);
283
+ return pathIsUnderBeWorkingTree(p) && isUiWorkingTreeJsPath(p);
284
+ });
285
+ const uiWorkingEntries = workingEntries.filter((f) => pathIsUnderUiLitWorkingTree(normalizeProjectRelativePath(f.path)));
286
+ const fileState = readFileState(projectRoot);
287
+ const beSlice = computePathBasedWorkingTreeStatus(projectRoot, beWorkingEntries, manifestPaths, pathIsUnderBeWorkingTree, debug, fileState);
288
+ const manifestJs = uiWorkingEntries.filter((f) => isUiWorkingTreeJsPath(normalizeProjectRelativePath(f.path)));
289
+ const manifestJson = uiWorkingEntries.filter((f) => isUiWorkingTreeJsonPath(normalizeProjectRelativePath(f.path)));
290
+ const { byId: manifestJsById, byPath: manifestJsByPath } = buildManifestJsIndexes(manifestJs);
291
+ const { byId: diskJsById, noCeByPath: diskJsNoCeByPath, indexErrors } = indexWorkingTreeJsFiles(projectRoot, manifestJsByPath);
292
+ if (indexErrors.length > 0) {
293
+ throw new AbCliError("VALIDATION", `UI working tree validation failed:\n${indexErrors.join("\n")}`);
294
+ }
295
+ const modified = [];
296
+ const deleted = [];
297
+ for (const m of manifestJs) {
298
+ const idKey = normId(m.id);
299
+ const mPath = normalizeProjectRelativePath(m.path);
300
+ if (diskJsById.has(idKey)) {
301
+ const d = diskJsById.get(idKey);
302
+ const pathChanged = d.path !== mPath;
303
+ const checksumChanged = d.checksum !== m.checksum;
304
+ if (pathChanged || checksumChanged) {
305
+ const line = formatJsModified(m.path, d.path);
306
+ modified.push(line);
307
+ if (debugOut) {
308
+ debugOut.modified.push({
309
+ line,
310
+ diskPath: d.path,
311
+ id: m.id,
312
+ manifestChecksum: m.checksum,
313
+ diskChecksum: d.checksum,
314
+ });
315
+ }
316
+ }
317
+ continue;
318
+ }
319
+ if (diskJsNoCeByPath.has(mPath)) {
320
+ const chk = diskJsNoCeByPath.get(mPath);
321
+ if (chk !== m.checksum) {
322
+ modified.push(m.path);
323
+ if (debugOut) {
324
+ debugOut.modified.push({
325
+ line: m.path,
326
+ diskPath: mPath,
327
+ id: m.id,
328
+ manifestChecksum: m.checksum,
329
+ diskChecksum: chk,
330
+ });
331
+ }
332
+ }
333
+ continue;
334
+ }
335
+ let abs;
336
+ try {
337
+ abs = safeProjectFilePath(projectRoot, m.path);
338
+ }
339
+ catch {
340
+ deleted.push(m.path);
341
+ if (debugOut) {
342
+ debugOut.deleted.push({
343
+ path: m.path,
344
+ id: m.id,
345
+ manifestChecksum: m.checksum,
346
+ });
347
+ }
348
+ continue;
349
+ }
350
+ if (!existsSync(abs)) {
351
+ deleted.push(m.path);
352
+ if (debugOut) {
353
+ debugOut.deleted.push({
354
+ path: m.path,
355
+ id: m.id,
356
+ manifestChecksum: m.checksum,
357
+ });
358
+ }
359
+ }
360
+ }
361
+ for (const m of manifestJson) {
362
+ const mPath = normalizeProjectRelativePath(m.path);
363
+ let abs;
364
+ try {
365
+ abs = safeProjectFilePath(projectRoot, m.path);
366
+ }
367
+ catch {
368
+ deleted.push(m.path);
369
+ if (debugOut) {
370
+ debugOut.deleted.push({
371
+ path: m.path,
372
+ id: m.id,
373
+ manifestChecksum: m.checksum,
374
+ });
375
+ }
376
+ continue;
377
+ }
378
+ if (!existsSync(abs)) {
379
+ deleted.push(m.path);
380
+ if (debugOut) {
381
+ debugOut.deleted.push({
382
+ path: m.path,
383
+ id: m.id,
384
+ manifestChecksum: m.checksum,
385
+ });
386
+ }
387
+ continue;
388
+ }
389
+ const content = readFileSync(abs, "utf8");
390
+ let diskChk;
391
+ try {
392
+ diskChk = md5HexUtf8CanonicalJson(content);
393
+ }
394
+ catch (e) {
395
+ if (e instanceof AbCliError) {
396
+ throw new AbCliError("VALIDATION", `${m.path}: ${e.message}`);
397
+ }
398
+ throw e;
399
+ }
400
+ if (diskChk !== m.checksum) {
401
+ modified.push(m.path);
402
+ if (debugOut) {
403
+ debugOut.modified.push({
404
+ line: m.path,
405
+ diskPath: mPath,
406
+ id: m.id,
407
+ manifestChecksum: m.checksum,
408
+ diskChecksum: diskChk,
409
+ });
410
+ }
411
+ }
412
+ }
413
+ const added = [];
414
+ for (const [idKey, d] of diskJsById) {
415
+ if (!manifestJsById.has(idKey)) {
416
+ added.push(d.path);
417
+ if (debugOut) {
418
+ debugOut.added.push({ path: d.path, diskChecksum: d.checksum });
419
+ }
420
+ }
421
+ }
422
+ for (const p of diskJsNoCeByPath.keys()) {
423
+ if (!manifestPaths.has(p)) {
424
+ added.push(p);
425
+ if (debugOut) {
426
+ debugOut.added.push({
427
+ path: p,
428
+ diskChecksum: diskJsNoCeByPath.get(p),
429
+ });
430
+ }
431
+ }
432
+ }
433
+ const ceRequiredPaths = new Set();
434
+ for (const line of added) {
435
+ if (isUiWorkingTreeJsPath(normalizeProjectRelativePath(line))) {
436
+ ceRequiredPaths.add(normalizeProjectRelativePath(line));
437
+ }
438
+ }
439
+ for (const line of modified) {
440
+ const disk = statusLineToDiskPath(line);
441
+ if (isUiWorkingTreeJsPath(normalizeProjectRelativePath(disk))) {
442
+ ceRequiredPaths.add(normalizeProjectRelativePath(disk));
443
+ }
444
+ }
445
+ assertUiWorkingTreeValidForStatus(projectRoot, manifestPaths, ceRequiredPaths, pathIsUnderUiLitWorkingTree, "UI");
446
+ const beCeRequired = new Set();
447
+ for (const p of beSlice.added) {
448
+ if (isUiWorkingTreeJsPath(normalizeProjectRelativePath(p))) {
449
+ beCeRequired.add(normalizeProjectRelativePath(p));
450
+ }
451
+ }
452
+ for (const p of beSlice.modified) {
453
+ if (isUiWorkingTreeJsPath(normalizeProjectRelativePath(p))) {
454
+ beCeRequired.add(normalizeProjectRelativePath(p));
455
+ }
456
+ }
457
+ assertUiWorkingTreeValidForStatus(projectRoot, manifestPaths, beCeRequired, pathIsUnderBeWorkingTree, "BE");
458
+ const allModified = [...modified, ...beSlice.modified].sort();
459
+ const allDeleted = [...deleted, ...beSlice.deleted].sort();
460
+ const allAdded = [...added, ...beSlice.added].sort();
461
+ const result = {
462
+ modified: allModified,
463
+ deleted: allDeleted,
464
+ added: allAdded,
465
+ };
466
+ if (debugOut || beSlice.debug) {
467
+ const merged = {
468
+ modified: [
469
+ ...(debugOut?.modified ?? []),
470
+ ...(beSlice.debug?.modified ?? []),
471
+ ],
472
+ added: [...(debugOut?.added ?? []), ...(beSlice.debug?.added ?? [])],
473
+ deleted: [
474
+ ...(debugOut?.deleted ?? []),
475
+ ...(beSlice.debug?.deleted ?? []),
476
+ ],
477
+ };
478
+ merged.modified.sort((a, b) => a.line.localeCompare(b.line));
479
+ merged.added.sort((a, b) => a.path.localeCompare(b.path));
480
+ merged.deleted.sort((a, b) => a.path.localeCompare(b.path));
481
+ result.debug = merged;
482
+ }
483
+ return result;
484
+ }
485
+ //# sourceMappingURL=status.js.map