@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
package/CHANGELOG.md ADDED
@@ -0,0 +1,20 @@
1
+ # Changelog
2
+
3
+ ## 0.1.0
4
+
5
+ Initial public release of `@anybuild-ai/ab` (Anybuild CLI).
6
+
7
+ ### Commands
8
+
9
+ - `login` / `logout` — host-scoped sessions stored in `~/.ab/config.json`
10
+ - `clone` — export manifest + files from the API
11
+ - `pull` / `push` / `status` / `validate` — sync and local change workflow
12
+
13
+ ### Clone (git-like)
14
+
15
+ - Default target is `./<application_id>/` under the current directory (not cwd itself)
16
+ - Pass `.` to clone into the current directory, or another path for a custom folder name
17
+
18
+ ### Security
19
+
20
+ - Global config directory/file written with restrictive Unix permissions (`0700` / `0600`)
package/LICENSE ADDED
@@ -0,0 +1,21 @@
1
+ MIT License
2
+
3
+ Copyright (c) 2026 Anybuild AI
4
+
5
+ Permission is hereby granted, free of charge, to any person obtaining a copy
6
+ of this software and associated documentation files (the "Software"), to deal
7
+ in the Software without restriction, including without limitation the rights
8
+ to use, copy, modify, merge, publish, distribute, sublicense, and/or sell
9
+ copies of the Software, and to permit persons to whom the Software is
10
+ furnished to do so, subject to the following conditions:
11
+
12
+ The above copyright notice and this permission notice shall be included in all
13
+ copies or substantial portions of the Software.
14
+
15
+ THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR
16
+ IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY,
17
+ FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE
18
+ AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER
19
+ LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM,
20
+ OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE
21
+ SOFTWARE.
package/README.md ADDED
@@ -0,0 +1,197 @@
1
+ # @anybuild-ai/ab
2
+
3
+ > Project-scoped CLI for syncing frontend/UI artifacts with Anybuild.
4
+
5
+ [![npm version](https://img.shields.io/npm/v/@anybuild-ai/ab.svg)](https://www.npmjs.com/package/@anybuild-ai/ab)
6
+ [![Node.js](https://img.shields.io/node/v/@anybuild-ai/ab)](https://nodejs.org)
7
+ [![License: MIT](https://img.shields.io/badge/License-MIT-yellow.svg)](./LICENSE)
8
+
9
+ ## Install
10
+
11
+ ```bash
12
+ npm install -g @anybuild-ai/ab
13
+
14
+ anybuild --version
15
+ anybuild help
16
+ ```
17
+
18
+ Requires **Node.js 20+**.
19
+
20
+ ### Why `anybuild` and not `ab`?
21
+
22
+ On macOS and many Linux installs, the command **`ab` is already taken** by [ApacheBench](https://httpd.apache.org/docs/current/programs/ab.html). Prefer **`anybuild`**. The package also installs an `ab` shim where it does not conflict.
23
+
24
+ ## Quick start
25
+
26
+ ```bash
27
+ anybuild login https://your-host.example.com/api/auth/login
28
+ anybuild clone https://your-host.example.com/<application_id>
29
+ cd <application_id>
30
+ anybuild pull
31
+ anybuild status
32
+ anybuild push
33
+ ```
34
+
35
+ `clone` creates a **`./<application_id>/`** directory (git-like). Pass `.` to clone into the current directory, or another path for a custom folder name.
36
+
37
+ ## Security
38
+
39
+ - **Tokens** (access + refresh) are stored in `~/.ab/config.json`, keyed by API host. The CLI writes this file with restrictive permissions on Unix (`0600`; directory `0700`).
40
+ - **Project config** (`.ab/config.json` in the app tree) holds only `api_url`, `environment`, and `application_id` — no secrets. Do not commit `~/.ab/`.
41
+ - Prefer **HTTPS** login and clone URLs in production. `http://` is allowed for local/dev only.
42
+ - On shared machines, run `anybuild logout <url>` when finished.
43
+ - Do not pipe passwords into non-TTY `anybuild login` (the password may be echoed). Avoid `--debug` in CI logs — it can dump file contents and large API responses on failure.
44
+ - Env overrides (`AB_GLOBAL_DIR`, `AB_GLOBAL_CONFIG`, `AB_AUTH_REFRESH_PATH`) are trusted-environment only.
45
+
46
+ ## Local development (from this repo)
47
+
48
+ ```bash
49
+ npm install
50
+ npm run build
51
+ npm run anybuild -- help
52
+ # or without a prior build:
53
+ npm run dev -- help
54
+ ```
55
+
56
+ ### `npm link`
57
+
58
+ ```bash
59
+ npm run build
60
+ npm link
61
+ ```
62
+
63
+ After source changes, run `npm run build` again. Unlink with:
64
+
65
+ ```bash
66
+ npm unlink -g @anybuild-ai/ab
67
+ ```
68
+
69
+ ## End-to-end flow (conceptual)
70
+
71
+ 1. **Log in** for the API host you use. Each host has its own tokens in the global config.
72
+ 2. **Clone** a project with `anybuild clone <base-url>/<application_id>` (requires login for that host). Creates `./<application_id>/` by default, downloads a **manifest**, then file content in batches.
73
+ 3. **Pull** fetches the latest manifest and downloads files whose **timestamp/checksum** or **path** changed; removes paths dropped from the manifest and **old paths after a server rename**.
74
+ 4. Edit tracked files under the project tree as needed (`ui/lit/components`, `be/plv8`, and `be/node` `.js` only; not `meta/be/*`).
75
+ 5. **Status** compares on-disk file **MD5** checksums to the last manifest (no network).
76
+ 6. **Validate** sends a batch to the import API with **`validate_only`** so the server checks your changes **without** applying them.
77
+ 7. **Push** sends the same kind of batch with **`validate_only` off**. On conflicts the CLI fails; **pull** again, then retry (no merge in the client).
78
+
79
+ `anybuild login`, `anybuild logout`, **clone**, **pull**, **status**, **validate**, and **push** are implemented.
80
+
81
+ ## Configuration
82
+
83
+ | Layer | Path | Purpose |
84
+ | --- | --- | --- |
85
+ | **Global** | `~/.ab/config.json` | Sessions: access/refresh tokens and `expires_at` per `(api_url, environment)` |
86
+ | **Project** | `./.ab/config.json` | `api_url`, `environment`, `application_id` only (no secrets) |
87
+
88
+ Project commands expect to run **inside** a directory tree that contains `./.ab/config.json` (walks up from the current working directory). `login`, `logout`, and `clone` are the exceptions: they do not require an existing project (clone creates one).
89
+
90
+ ## Commands
91
+
92
+ | Command | Role |
93
+ | --- | --- |
94
+ | `anybuild login <login-url>` | POST credentials to the given login URL; store tokens globally. See [Login](#login-anybuild-login) below. |
95
+ | `anybuild logout <logout-url>` | `POST` to the logout URL with current tokens, then delete the local session for that host. See [Logout](#logout-anybuild-logout). |
96
+ | `anybuild clone <url>/<application_id> [--force] [--debug] [directory]` | GET manifest, POST file batches (10 ids at a time), then copy the tree into the target directory (defaults to **`./<application_id>/`**; use `.` for cwd). **`--debug`** adds URL, request/response details on export HTTP errors. See [Clone](#clone-anybuild-clone). |
97
+ | `anybuild pull` | GET manifest, fetch changed files (including **path-only** renames), update `.ab/manifest.json` and `.ab/file-state.json`. Removes server-deleted files and **unlink old paths** when an `id`’s manifest path moved. Optional **`--force`** re-downloads every manifest file. **`--debug`** adds HTTP details on export errors. Progress is printed to **stderr**. |
98
+ | `anybuild status` | **Modified** / **Deleted** / **Added** under `ui/lit/components` (CE / mixin id in `.js`) and backend trees `be/plv8` + `be/node` (`.js` with `const __meta = { thing_id: \`<uuid>\`, ... }`). **Added** = on disk but not in manifest. **Modified** = disk ≠ manifest or (backend trees) manifest ≠ file-state. |
99
+ | `anybuild validate` | Build a batch from local changes vs the manifest and POST it with **`validate_only: true`** (no apply on the server). Optional **paths** limit validation to those files (must be pending changes per `status`). |
100
+ | `anybuild push` | Build and POST the import batch with **`validate_only: false`** (apply). Optional **paths** push only those files; optional **`--debug`**. On failure after a conflict, **pull** then retry. |
101
+
102
+ Global: `anybuild help`, `anybuild -v` / `--version`.
103
+
104
+ **Push / validate specific files:** pass project-relative paths after the command to upload or validate only those pending changes (same paths as `status` — for renames, either the on-disk path or the previous manifest path):
105
+
106
+ ```bash
107
+ anybuild push ui/lit/components/my_widget.js
108
+ anybuild validate be/node/my_handler.js
109
+ anybuild push path/a.js path/b.js --debug
110
+ ```
111
+
112
+ **Progress:** Each command prints short status lines to **stderr** as work starts (and batch steps for large clone/pull/push/validate uploads), so you get immediate feedback after pressing Enter. Final results stay on **stdout** (except errors, which go to stderr).
113
+
114
+ ## Clone (`anybuild clone`)
115
+
116
+ - **URL shape:** `https://<host>/<application_id>` — **`application_id`** is the last path segment (human-readable app name). **You must be logged in** for that host (`anybuild login`).
117
+
118
+ - **API:** `GET /api/cli/v1/export/manifest?application_id=…` then repeated `POST /api/cli/v1/export/files` with JSON `{ "application_id": "<id>", "files": [ … ] }` (up to **10** file ids per request, in order). For each returned file, the CLI checks that **`checksum` in the files response** matches **`checksum` for that file id in the manifest** (no hashing of `content` on the client).
119
+
120
+ - **Target directory (git-like):**
121
+ - `anybuild clone <url>` → creates **`./<application_id>/`** under the current working directory
122
+ - `anybuild clone <url> .` → clones into the **current directory**
123
+ - `anybuild clone <url> my-folder` → clones into `./my-folder/`
124
+
125
+ - **Working directory:** work happens in a sibling temp folder (`ab-clone-*`), then **`--force` clears only the contents** of the target folder (the folder itself stays), and the clone tree is **copied** into it.
126
+
127
+ - **Already cloned:** if `.ab/manifest.json` already exists in the target directory, clone **fails** unless you pass **`--force`** (which deletes and reclones).
128
+
129
+ - **Troubleshooting:** pass **`--debug`** to print full request URL, JSON body, response status, `Content-Type`, and a large response-body dump when manifest or export-files calls fail.
130
+
131
+ - **environment** in `./.ab/config.json` is the URL **hostname** (lowercase), matching `anybuild login`.
132
+
133
+ ```bash
134
+ anybuild clone https://anybuild-dev1.example.com/my-app
135
+ # → ./my-app/
136
+
137
+ anybuild clone https://anybuild-dev1.example.com/my-app .
138
+ # → current directory
139
+
140
+ anybuild clone https://anybuild-dev1.example.com/my-app ./subfolder --force
141
+ ```
142
+
143
+ ## Login (`anybuild login`)
144
+
145
+ ```bash
146
+ anybuild login https://anybuild-dev1.example.com/api/auth/login
147
+ ```
148
+
149
+ You are prompted for **username** and **password** (password is hidden on a TTY). The CLI sends:
150
+
151
+ `POST` to the URL you pass, with JSON body `{ "username": "...", "password": "..." }`.
152
+
153
+ **Session scope:** Tokens are stored under the same key as the rest of the CLI: normalized **`api_url`** (scheme + host + port from the login URL’s origin) and **`environment`**. Here, **`environment` is the deployment hostname** (lowercase, e.g. `anybuild-dev1.example.com`). All applications on that host share this login context.
154
+
155
+ If you pass only an origin (no path), the CLI defaults the path to **`/api/auth/login`**. If you pass a full path (e.g. `/api/login`), that path is used as-is.
156
+
157
+ **Matching a project:** `anybuild clone` writes the same `api_url` and hostname **`environment`** as `anybuild login` for that host, so sessions line up without manual edits.
158
+
159
+ ## Logout (`anybuild logout`)
160
+
161
+ ```bash
162
+ anybuild logout https://anybuild-dev1.example.com/api/auth/logout
163
+ ```
164
+
165
+ Requires an existing stored session for that host (same `api_url` + hostname `environment` as `anybuild login`). The CLI refreshes the access token if needed, then sends **`POST`** to your URL with:
166
+
167
+ - Header `Authorization: Bearer <access_token>`
168
+ - JSON body `{ "refresh_token": "<refresh_token>" }`
169
+
170
+ On **2xx** response, the matching entry is removed from `~/.ab/config.json`. If you pass only an origin (no path), the default path is **`/api/auth/logout`**.
171
+
172
+ ## Authentication (overview)
173
+
174
+ **Model:** Different deployments (different hostnames or API bases) have separate sessions. Your project’s `(api_url, environment)` must match a stored session.
175
+
176
+ **Token refresh:** The HTTP client refreshes the access token when it is near expiry (or after a `401`). Refresh uses `POST /api/auth/refresh` on the same `api_url` unless overridden by `AB_AUTH_REFRESH_PATH`.
177
+
178
+ ## Environment variables (optional)
179
+
180
+ Used for tests or non-default paths:
181
+
182
+ | Variable | Meaning |
183
+ | --- | --- |
184
+ | `AB_GLOBAL_DIR` | Directory for global config (default: `~/.ab`) |
185
+ | `AB_GLOBAL_CONFIG` | Full path to global `config.json` (overrides `AB_GLOBAL_DIR`) |
186
+ | `AB_AUTH_REFRESH_PATH` | Relative path or absolute URL for the refresh endpoint (default: `/api/auth/refresh`) |
187
+
188
+ ## Project layout after clone / pull
189
+
190
+ - `./.ab/config.json` — `api_url`, `environment`, `application_id` (no secrets)
191
+ - `./.ab/manifest.json` — last export manifest from the server (project, folders, files + metadata)
192
+ - `./.ab/file-state.json` — per-file id → path, timestamp, checksum (for pull diffs)
193
+ - **Working tree** — files under paths from the manifest (e.g. `meta/…`, `ui/…`)
194
+
195
+ ## License
196
+
197
+ [MIT](./LICENSE)
@@ -0,0 +1,8 @@
1
+ import type { AbHttpClient } from "../http/client.js";
2
+ import type { AnybuildApi } from "./types.js";
3
+ /**
4
+ * Builds the API adapter used by pull/push flows. Today this always returns the
5
+ * stub implementation; a future HTTP-backed adapter will use `client` and real paths.
6
+ */
7
+ export declare function createAnybuildApi(_client: AbHttpClient): AnybuildApi;
8
+ //# sourceMappingURL=factory.d.ts.map
@@ -0,0 +1 @@
1
+ {"version":3,"file":"factory.d.ts","sourceRoot":"","sources":["../../src/api/factory.ts"],"names":[],"mappings":"AAAA,OAAO,KAAK,EAAE,YAAY,EAAE,MAAM,mBAAmB,CAAC;AAEtD,OAAO,KAAK,EAAE,WAAW,EAAE,MAAM,YAAY,CAAC;AAE9C;;;GAGG;AACH,wBAAgB,iBAAiB,CAAC,OAAO,EAAE,YAAY,GAAG,WAAW,CAEpE"}
@@ -0,0 +1,9 @@
1
+ import { createStubAnybuildApi } from "./stub.js";
2
+ /**
3
+ * Builds the API adapter used by pull/push flows. Today this always returns the
4
+ * stub implementation; a future HTTP-backed adapter will use `client` and real paths.
5
+ */
6
+ export function createAnybuildApi(_client) {
7
+ return createStubAnybuildApi();
8
+ }
9
+ //# sourceMappingURL=factory.js.map
@@ -0,0 +1 @@
1
+ {"version":3,"file":"factory.js","sourceRoot":"","sources":["../../src/api/factory.ts"],"names":[],"mappings":"AACA,OAAO,EAAE,qBAAqB,EAAE,MAAM,WAAW,CAAC;AAGlD;;;GAGG;AACH,MAAM,UAAU,iBAAiB,CAAC,OAAqB;IACrD,OAAO,qBAAqB,EAAE,CAAC;AACjC,CAAC"}
@@ -0,0 +1,4 @@
1
+ export { createAnybuildApi } from "./factory.js";
2
+ export { createStubAnybuildApi } from "./stub.js";
3
+ export type { AnybuildApi, AnybuildApiContext, ServerArtifact, } from "./types.js";
4
+ //# sourceMappingURL=index.d.ts.map
@@ -0,0 +1 @@
1
+ {"version":3,"file":"index.d.ts","sourceRoot":"","sources":["../../src/api/index.ts"],"names":[],"mappings":"AAAA,OAAO,EAAE,iBAAiB,EAAE,MAAM,cAAc,CAAC;AACjD,OAAO,EAAE,qBAAqB,EAAE,MAAM,WAAW,CAAC;AAClD,YAAY,EACV,WAAW,EACX,kBAAkB,EAClB,cAAc,GACf,MAAM,YAAY,CAAC"}
@@ -0,0 +1,3 @@
1
+ export { createAnybuildApi } from "./factory.js";
2
+ export { createStubAnybuildApi } from "./stub.js";
3
+ //# sourceMappingURL=index.js.map
@@ -0,0 +1 @@
1
+ {"version":3,"file":"index.js","sourceRoot":"","sources":["../../src/api/index.ts"],"names":[],"mappings":"AAAA,OAAO,EAAE,iBAAiB,EAAE,MAAM,cAAc,CAAC;AACjD,OAAO,EAAE,qBAAqB,EAAE,MAAM,WAAW,CAAC"}
@@ -0,0 +1,7 @@
1
+ import type { AnybuildApi } from "./types.js";
2
+ /**
3
+ * Stub API for pull until real REST paths exist. Returns fixtures keyed by
4
+ * `application`, or `_default` when unknown.
5
+ */
6
+ export declare function createStubAnybuildApi(): AnybuildApi;
7
+ //# sourceMappingURL=stub.d.ts.map
@@ -0,0 +1 @@
1
+ {"version":3,"file":"stub.d.ts","sourceRoot":"","sources":["../../src/api/stub.ts"],"names":[],"mappings":"AAAA,OAAO,KAAK,EAAE,WAAW,EAAsC,MAAM,YAAY,CAAC;AAmBlF;;;GAGG;AACH,wBAAgB,qBAAqB,IAAI,WAAW,CAQnD"}
@@ -0,0 +1,30 @@
1
+ const DEFAULT_BY_APPLICATION = {
2
+ _default: [
3
+ {
4
+ id: "ui_widget_a",
5
+ type: "ui",
6
+ content: { title: "Widget A", version: 1 },
7
+ modified_on: "2026-01-15T12:00:00.000Z",
8
+ },
9
+ {
10
+ id: "ui_widget_b",
11
+ type: "ui",
12
+ content: { title: "Widget B", labels: ["demo"] },
13
+ modified_on: "2026-01-15T12:00:01.000Z",
14
+ },
15
+ ],
16
+ };
17
+ /**
18
+ * Stub API for pull until real REST paths exist. Returns fixtures keyed by
19
+ * `application`, or `_default` when unknown.
20
+ */
21
+ export function createStubAnybuildApi() {
22
+ return {
23
+ async listArtifacts(ctx) {
24
+ const key = ctx.application.trim();
25
+ const list = DEFAULT_BY_APPLICATION[key] ?? DEFAULT_BY_APPLICATION._default;
26
+ return list.map((a) => ({ ...a }));
27
+ },
28
+ };
29
+ }
30
+ //# sourceMappingURL=stub.js.map
@@ -0,0 +1 @@
1
+ {"version":3,"file":"stub.js","sourceRoot":"","sources":["../../src/api/stub.ts"],"names":[],"mappings":"AAEA,MAAM,sBAAsB,GAAqC;IAC/D,QAAQ,EAAE;QACR;YACE,EAAE,EAAE,aAAa;YACjB,IAAI,EAAE,IAAI;YACV,OAAO,EAAE,EAAE,KAAK,EAAE,UAAU,EAAE,OAAO,EAAE,CAAC,EAAE;YAC1C,WAAW,EAAE,0BAA0B;SACxC;QACD;YACE,EAAE,EAAE,aAAa;YACjB,IAAI,EAAE,IAAI;YACV,OAAO,EAAE,EAAE,KAAK,EAAE,UAAU,EAAE,MAAM,EAAE,CAAC,MAAM,CAAC,EAAE;YAChD,WAAW,EAAE,0BAA0B;SACxC;KACF;CACF,CAAC;AAEF;;;GAGG;AACH,MAAM,UAAU,qBAAqB;IACnC,OAAO;QACL,KAAK,CAAC,aAAa,CAAC,GAAuB;YACzC,MAAM,GAAG,GAAG,GAAG,CAAC,WAAW,CAAC,IAAI,EAAE,CAAC;YACnC,MAAM,IAAI,GAAG,sBAAsB,CAAC,GAAG,CAAC,IAAI,sBAAsB,CAAC,QAAQ,CAAC;YAC5E,OAAO,IAAI,CAAC,GAAG,CAAC,CAAC,CAAC,EAAE,EAAE,CAAC,CAAC,EAAE,GAAG,CAAC,EAAE,CAAC,CAAC,CAAC;QACrC,CAAC;KACF,CAAC;AACJ,CAAC"}
@@ -0,0 +1,16 @@
1
+ import type { ProjectConfig } from "../config/types.js";
2
+ export type AnybuildApiContext = Pick<ProjectConfig, "api_url" | "environment" | "application">;
3
+ /** Artifact as returned by list/pull (before local baseline is updated). */
4
+ export type ServerArtifact = {
5
+ id: string;
6
+ type: string;
7
+ content: unknown;
8
+ /** ISO 8601 instant from the server. */
9
+ modified_on: string;
10
+ /** Optional server hash (hex). If omitted, the client hashes normalized content. */
11
+ hash?: string;
12
+ };
13
+ export type AnybuildApi = {
14
+ listArtifacts(ctx: AnybuildApiContext): Promise<ServerArtifact[]>;
15
+ };
16
+ //# sourceMappingURL=types.d.ts.map
@@ -0,0 +1 @@
1
+ {"version":3,"file":"types.d.ts","sourceRoot":"","sources":["../../src/api/types.ts"],"names":[],"mappings":"AAAA,OAAO,KAAK,EAAE,aAAa,EAAE,MAAM,oBAAoB,CAAC;AAExD,MAAM,MAAM,kBAAkB,GAAG,IAAI,CACnC,aAAa,EACb,SAAS,GAAG,aAAa,GAAG,aAAa,CAC1C,CAAC;AAEF,4EAA4E;AAC5E,MAAM,MAAM,cAAc,GAAG;IAC3B,EAAE,EAAE,MAAM,CAAC;IACX,IAAI,EAAE,MAAM,CAAC;IACb,OAAO,EAAE,OAAO,CAAC;IACjB,wCAAwC;IACxC,WAAW,EAAE,MAAM,CAAC;IACpB,oFAAoF;IACpF,IAAI,CAAC,EAAE,MAAM,CAAC;CACf,CAAC;AAEF,MAAM,MAAM,WAAW,GAAG;IACxB,aAAa,CAAC,GAAG,EAAE,kBAAkB,GAAG,OAAO,CAAC,cAAc,EAAE,CAAC,CAAC;CACnE,CAAC"}
@@ -0,0 +1,2 @@
1
+ export {};
2
+ //# sourceMappingURL=types.js.map
@@ -0,0 +1 @@
1
+ {"version":3,"file":"types.js","sourceRoot":"","sources":["../../src/api/types.ts"],"names":[],"mappings":""}
@@ -0,0 +1,10 @@
1
+ export type BaselineEntry = {
2
+ type: string;
3
+ modified_on: string;
4
+ hash: string;
5
+ };
6
+ export type BaselineFile = {
7
+ version: 1;
8
+ artifacts: Record<string, BaselineEntry>;
9
+ };
10
+ //# sourceMappingURL=baseline-types.d.ts.map
@@ -0,0 +1 @@
1
+ {"version":3,"file":"baseline-types.d.ts","sourceRoot":"","sources":["../../src/artifacts/baseline-types.ts"],"names":[],"mappings":"AAAA,MAAM,MAAM,aAAa,GAAG;IAC1B,IAAI,EAAE,MAAM,CAAC;IACb,WAAW,EAAE,MAAM,CAAC;IACpB,IAAI,EAAE,MAAM,CAAC;CACd,CAAC;AAEF,MAAM,MAAM,YAAY,GAAG;IACzB,OAAO,EAAE,CAAC,CAAC;IACX,SAAS,EAAE,MAAM,CAAC,MAAM,EAAE,aAAa,CAAC,CAAC;CAC1C,CAAC"}
@@ -0,0 +1,2 @@
1
+ export {};
2
+ //# sourceMappingURL=baseline-types.js.map
@@ -0,0 +1 @@
1
+ {"version":3,"file":"baseline-types.js","sourceRoot":"","sources":["../../src/artifacts/baseline-types.ts"],"names":[],"mappings":""}
@@ -0,0 +1,4 @@
1
+ import type { BaselineFile } from "./baseline-types.js";
2
+ export declare function readBaseline(projectRoot: string): BaselineFile | null;
3
+ export declare function writeBaseline(projectRoot: string, baseline: BaselineFile): void;
4
+ //# sourceMappingURL=baseline.d.ts.map
@@ -0,0 +1 @@
1
+ {"version":3,"file":"baseline.d.ts","sourceRoot":"","sources":["../../src/artifacts/baseline.ts"],"names":[],"mappings":"AAIA,OAAO,KAAK,EAAE,YAAY,EAAE,MAAM,qBAAqB,CAAC;AAExD,wBAAgB,YAAY,CAAC,WAAW,EAAE,MAAM,GAAG,YAAY,GAAG,IAAI,CA6CrE;AAED,wBAAgB,aAAa,CAAC,WAAW,EAAE,MAAM,EAAE,QAAQ,EAAE,YAAY,GAAG,IAAI,CAO/E"}
@@ -0,0 +1,55 @@
1
+ import { existsSync, readFileSync, renameSync, writeFileSync } from "node:fs";
2
+ import { dirname, join } from "node:path";
3
+ import { AbCliError } from "../errors.js";
4
+ import { baselinePath } from "./locations.js";
5
+ export function readBaseline(projectRoot) {
6
+ const path = baselinePath(projectRoot);
7
+ if (!existsSync(path)) {
8
+ return null;
9
+ }
10
+ const raw = readFileSync(path, "utf8");
11
+ let parsed;
12
+ try {
13
+ parsed = JSON.parse(raw);
14
+ }
15
+ catch (e) {
16
+ throw new AbCliError("CONFIG", `Invalid baseline JSON: ${e instanceof Error ? e.message : String(e)}`);
17
+ }
18
+ if (typeof parsed !== "object" || parsed === null) {
19
+ throw new AbCliError("CONFIG", "Baseline must be a JSON object.");
20
+ }
21
+ const o = parsed;
22
+ if (o.version !== 1) {
23
+ throw new AbCliError("CONFIG", "Unsupported baseline version.");
24
+ }
25
+ if (typeof o.artifacts !== "object" || o.artifacts === null || Array.isArray(o.artifacts)) {
26
+ throw new AbCliError("CONFIG", "Baseline missing valid artifacts map.");
27
+ }
28
+ const artifacts = {};
29
+ for (const [id, entry] of Object.entries(o.artifacts)) {
30
+ if (typeof entry !== "object" || entry === null) {
31
+ throw new AbCliError("CONFIG", `Invalid baseline entry for "${id}".`);
32
+ }
33
+ const e = entry;
34
+ if (typeof e.type !== "string" ||
35
+ typeof e.modified_on !== "string" ||
36
+ typeof e.hash !== "string") {
37
+ throw new AbCliError("CONFIG", `Baseline entry "${id}" missing type, modified_on, or hash.`);
38
+ }
39
+ artifacts[id] = {
40
+ type: e.type,
41
+ modified_on: e.modified_on,
42
+ hash: e.hash,
43
+ };
44
+ }
45
+ return { version: 1, artifacts };
46
+ }
47
+ export function writeBaseline(projectRoot, baseline) {
48
+ const path = baselinePath(projectRoot);
49
+ const dir = dirname(path);
50
+ const payload = `${JSON.stringify(baseline, null, 2)}\n`;
51
+ const tmp = join(dir, `.baseline.${process.pid}.${Date.now()}.tmp`);
52
+ writeFileSync(tmp, payload, "utf8");
53
+ renameSync(tmp, path);
54
+ }
55
+ //# sourceMappingURL=baseline.js.map
@@ -0,0 +1 @@
1
+ {"version":3,"file":"baseline.js","sourceRoot":"","sources":["../../src/artifacts/baseline.ts"],"names":[],"mappings":"AAAA,OAAO,EAAE,UAA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G,EAAE,aAAa,OAAO,CAAC,GAAG,IAAI,IAAI,CAAC,GAAG,EAAE,MAAM,CAAC,CAAC;IACpE,aAAa,CAAC,GAAG,EAAE,OAAO,EAAE,MAAM,CAAC,CAAC;IACpC,UAAU,CAAC,GAAG,EAAE,IAAI,CAAC,CAAC;AACxB,CAAC"}
@@ -0,0 +1,3 @@
1
+ /** Deterministic JSON string for hashing (sorted object keys, no whitespace). */
2
+ export declare function canonicalJsonStringify(value: unknown): string;
3
+ //# sourceMappingURL=canonical-json.d.ts.map
@@ -0,0 +1 @@
1
+ {"version":3,"file":"canonical-json.d.ts","sourceRoot":"","sources":["../../src/artifacts/canonical-json.ts"],"names":[],"mappings":"AAAA,iFAAiF;AACjF,wBAAgB,sBAAsB,CAAC,KAAK,EAAE,OAAO,GAAG,MAAM,CAU7D"}
@@ -0,0 +1,13 @@
1
+ /** Deterministic JSON string for hashing (sorted object keys, no whitespace). */
2
+ export function canonicalJsonStringify(value) {
3
+ if (value === null || typeof value !== "object") {
4
+ return JSON.stringify(value);
5
+ }
6
+ if (Array.isArray(value)) {
7
+ return `[${value.map((v) => canonicalJsonStringify(v)).join(",")}]`;
8
+ }
9
+ const o = value;
10
+ const keys = Object.keys(o).sort();
11
+ return `{${keys.map((k) => `${JSON.stringify(k)}:${canonicalJsonStringify(o[k])}`).join(",")}}`;
12
+ }
13
+ //# sourceMappingURL=canonical-json.js.map
@@ -0,0 +1 @@
1
+ {"version":3,"file":"canonical-json.js","sourceRoot":"","sources":["../../src/artifacts/canonical-json.ts"],"names":[],"mappings":"AAAA,iFAAiF;AACjF,MAAM,UAAU,sBAAsB,CAAC,KAAc;IACnD,IAAI,KAAK,KAAK,IAAI,IAAI,OAAO,KAAK,KAAK,QAAQ,EAAE,CAAC;QAChD,OAAO,IAAI,CAAC,SAAS,CAAC,KAAK,CAAC,CAAC;IAC/B,CAAC;IACD,IAAI,KAAK,CAAC,OAAO,CAAC,KAAK,CAAC,EAAE,CAAC;QACzB,OAAO,IAAI,KAAK,CAAC,GAAG,CAAC,CAAC,CAAC,EAAE,EAAE,CAAC,sBAAsB,CAAC,CAAC,CAAC,CAAC,CAAC,IAAI,CAAC,GAAG,CAAC,GAAG,CAAC;IACtE,CAAC;IACD,MAAM,CAAC,GAAG,KAAgC,CAAC;IAC3C,MAAM,IAAI,GAAG,MAAM,CAAC,IAAI,CAAC,CAAC,CAAC,CAAC,IAAI,EAAE,CAAC;IACnC,OAAO,IAAI,IAAI,CAAC,GAAG,CAAC,CAAC,CAAC,EAAE,EAAE,CAAC,GAAG,IAAI,CAAC,SAAS,CAAC,CAAC,CAAC,IAAI,sBAAsB,CAAC,CAAC,CAAC,CAAC,CAAC,CAAC,EAAE,CAAC,CAAC,IAAI,CAAC,GAAG,CAAC,GAAG,CAAC;AAClG,CAAC"}
@@ -0,0 +1,6 @@
1
+ export declare function artifactFilePath(projectRoot: string, id: string): string;
2
+ export declare function ensureArtifactsDir(projectRoot: string): void;
3
+ export declare function writeArtifactFile(projectRoot: string, id: string, content: unknown): void;
4
+ export declare function readArtifactContentFromDisk(projectRoot: string, id: string): unknown;
5
+ export declare function listArtifactIdsOnDisk(projectRoot: string): string[];
6
+ //# sourceMappingURL=disk.d.ts.map
@@ -0,0 +1 @@
1
+ {"version":3,"file":"disk.d.ts","sourceRoot":"","sources":["../../src/artifacts/disk.ts"],"names":[],"mappings":"AAOA,wBAAgB,gBAAgB,CAAC,WAAW,EAAE,MAAM,EAAE,EAAE,EAAE,MAAM,GAAG,MAAM,CAQxE;AAED,wBAAgB,kBAAkB,CAAC,WAAW,EAAE,MAAM,GAAG,IAAI,CAE5D;AAED,wBAAgB,iBAAiB,CAAC,WAAW,EAAE,MAAM,EAAE,EAAE,EAAE,MAAM,EAAE,OAAO,EAAE,OAAO,GAAG,IAAI,CAKzF;AAED,wBAAgB,2BAA2B,CAAC,WAAW,EAAE,MAAM,EAAE,EAAE,EAAE,MAAM,GAAG,OAAO,CAQpF;AAED,wBAAgB,qBAAqB,CAAC,WAAW,EAAE,MAAM,GAAG,MAAM,EAAE,CAanE"}
@@ -0,0 +1,45 @@
1
+ import { existsSync, mkdirSync, readFileSync, readdirSync, writeFileSync } from "node:fs";
2
+ import { join } from "node:path";
3
+ import { AbCliError } from "../errors.js";
4
+ import { artifactsDir } from "./locations.js";
5
+ const ARTIFACT_EXT = ".json";
6
+ export function artifactFilePath(projectRoot, id) {
7
+ if (!/^[a-zA-Z0-9_.-]+$/.test(id)) {
8
+ throw new AbCliError("CONFIG", `Artifact id contains unsafe characters for filesystem: ${id}`);
9
+ }
10
+ return join(artifactsDir(projectRoot), `${id}${ARTIFACT_EXT}`);
11
+ }
12
+ export function ensureArtifactsDir(projectRoot) {
13
+ mkdirSync(artifactsDir(projectRoot), { recursive: true });
14
+ }
15
+ export function writeArtifactFile(projectRoot, id, content) {
16
+ ensureArtifactsDir(projectRoot);
17
+ const path = artifactFilePath(projectRoot, id);
18
+ const body = `${JSON.stringify(content, null, 2)}\n`;
19
+ writeFileSync(path, body, "utf8");
20
+ }
21
+ export function readArtifactContentFromDisk(projectRoot, id) {
22
+ const path = artifactFilePath(projectRoot, id);
23
+ const raw = readFileSync(path, "utf8");
24
+ try {
25
+ return JSON.parse(raw);
26
+ }
27
+ catch {
28
+ throw new AbCliError("CONFIG", `Artifact file is not valid JSON: ${path}`);
29
+ }
30
+ }
31
+ export function listArtifactIdsOnDisk(projectRoot) {
32
+ const dir = artifactsDir(projectRoot);
33
+ if (!existsSync(dir)) {
34
+ return [];
35
+ }
36
+ const out = [];
37
+ for (const name of readdirSync(dir)) {
38
+ if (!name.endsWith(ARTIFACT_EXT)) {
39
+ continue;
40
+ }
41
+ out.push(name.slice(0, -ARTIFACT_EXT.length));
42
+ }
43
+ return out.sort();
44
+ }
45
+ //# sourceMappingURL=disk.js.map
@@ -0,0 +1 @@
1
+ {"version":3,"file":"disk.js","sourceRoot":"","sources":["../../src/artifacts/disk.ts"],"names":[],"mappings":"AAAA,OAAO,EAAE,UAAU,EAAE,SAA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AC,CAAC;IACvC,IAAI,CAAC;QACH,OAAO,IAAI,CAAC,KAAK,CAAC,GAAG,CAAY,CAAC;IACpC,CAAC;IAAC,MAAM,CAAC;QACP,MAAM,IAAI,UAAU,CAAC,QAAQ,EAAE,oCAAoC,IAAI,EAAE,CAAC,CAAC;IAC7E,CAAC;AACH,CAAC;AAED,MAAM,UAAU,qBAAqB,CAAC,WAAmB;IACvD,MAAM,GAAG,GAAG,YAAY,CAAC,WAAW,CAAC,CAAC;IACtC,IAAI,CAAC,UAAU,CAAC,GAAG,CAAC,EAAE,CAAC;QACrB,OAAO,EAAE,CAAC;IACZ,CAAC;IACD,MAAM,GAAG,GAAa,EAAE,CAAC;IACzB,KAAK,MAAM,IAAI,IAAI,WAAW,CAAC,GAAG,CAAC,EAAE,CAAC;QACpC,IAAI,CAAC,IAAI,CAAC,QAAQ,CAAC,YAAY,CAAC,EAAE,CAAC;YACjC,SAAS;QACX,CAAC;QACD,GAAG,CAAC,IAAI,CAAC,IAAI,CAAC,KAAK,CAAC,CAAC,EAAE,CAAC,YAAY,CAAC,MAAM,CAAC,CAAC,CAAC;IAChD,CAAC;IACD,OAAO,GAAG,CAAC,IAAI,EAAE,CAAC;AACpB,CAAC"}
@@ -0,0 +1,4 @@
1
+ /** Stable string used for SHA-256 (UTF-8). */
2
+ export declare function normalizeContentForHash(content: unknown): string;
3
+ export declare function sha256HexOfNormalizedContent(content: unknown): string;
4
+ //# sourceMappingURL=hash-content.d.ts.map
@@ -0,0 +1 @@
1
+ {"version":3,"file":"hash-content.d.ts","sourceRoot":"","sources":["../../src/artifacts/hash-content.ts"],"names":[],"mappings":"AAGA,8CAA8C;AAC9C,wBAAgB,uBAAuB,CAAC,OAAO,EAAE,OAAO,GAAG,MAAM,CAKhE;AAED,wBAAgB,4BAA4B,CAAC,OAAO,EAAE,OAAO,GAAG,MAAM,CAGrE"}
@@ -0,0 +1,14 @@
1
+ import { createHash } from "node:crypto";
2
+ import { canonicalJsonStringify } from "./canonical-json.js";
3
+ /** Stable string used for SHA-256 (UTF-8). */
4
+ export function normalizeContentForHash(content) {
5
+ if (typeof content === "string") {
6
+ return content;
7
+ }
8
+ return canonicalJsonStringify(content);
9
+ }
10
+ export function sha256HexOfNormalizedContent(content) {
11
+ const normalized = normalizeContentForHash(content);
12
+ return createHash("sha256").update(normalized, "utf8").digest("hex");
13
+ }
14
+ //# sourceMappingURL=hash-content.js.map
@@ -0,0 +1 @@
1
+ {"version":3,"file":"hash-content.js","sourceRoot":"","sources":["../../src/artifacts/hash-content.ts"],"names":[],"mappings":"AAAA,OAAO,EAAE,UAAU,EAAE,MAAM,aAAa,CAAC;AACzC,OAAO,EAAE,sBAAsB,EAAE,MAAM,qBAAqB,CAAC;AAE7D,8CAA8C;AAC9C,MAAM,UAAU,uBAAuB,CAAC,OAAgB;IACtD,IAAI,OAAO,OAAO,KAAK,QAAQ,EAAE,CAAC;QAChC,OAAO,OAAO,CAAC;IACjB,CAAC;IACD,OAAO,sBAAsB,CAAC,OAAO,CAAC,CAAC;AACzC,CAAC;AAED,MAAM,UAAU,4BAA4B,CAAC,OAAgB;IAC3D,MAAM,UAAU,GAAG,uBAAuB,CAAC,OAAO,CAAC,CAAC;IACpD,OAAO,UAAU,CAAC,QAAQ,CAAC,CAAC,MAAM,CAAC,UAAU,EAAE,MAAM,CAAC,CAAC,MAAM,CAAC,KAAK,CAAC,CAAC;AACvE,CAAC"}
@@ -0,0 +1,3 @@
1
+ export declare function artifactsDir(projectRoot: string): string;
2
+ export declare function baselinePath(projectRoot: string): string;
3
+ //# sourceMappingURL=locations.d.ts.map
@@ -0,0 +1 @@
1
+ {"version":3,"file":"locations.d.ts","sourceRoot":"","sources":["../../src/artifacts/locations.ts"],"names":[],"mappings":"AAGA,wBAAgB,YAAY,CAAC,WAAW,EAAE,MAAM,GAAG,MAAM,CAExD;AAED,wBAAgB,YAAY,CAAC,WAAW,EAAE,MAAM,GAAG,MAAM,CAExD"}
@@ -0,0 +1,9 @@
1
+ import { join } from "node:path";
2
+ import { projectAbDir } from "../config/paths.js";
3
+ export function artifactsDir(projectRoot) {
4
+ return join(projectAbDir(projectRoot), "artifacts");
5
+ }
6
+ export function baselinePath(projectRoot) {
7
+ return join(projectAbDir(projectRoot), "baseline.json");
8
+ }
9
+ //# sourceMappingURL=locations.js.map
@@ -0,0 +1 @@
1
+ {"version":3,"file":"locations.js","sourceRoot":"","sources":["../../src/artifacts/locations.ts"],"names":[],"mappings":"AAAA,OAAO,EAAE,IAAI,EAAE,MAAM,WAAW,CAAC;AACjC,OAAO,EAAE,YAAY,EAAE,MAAM,oBAAoB,CAAC;AAElD,MAAM,UAAU,YAAY,CAAC,WAAmB;IAC9C,OAAO,IAAI,CAAC,YAAY,CAAC,WAAW,CAAC,EAAE,WAAW,CAAC,CAAC;AACtD,CAAC;AAED,MAAM,UAAU,YAAY,CAAC,WAAmB;IAC9C,OAAO,IAAI,CAAC,YAAY,CAAC,WAAW,CAAC,EAAE,eAAe,CAAC,CAAC;AAC1D,CAAC"}
@@ -0,0 +1,4 @@
1
+ import type { AnybuildApi } from "../api/types.js";
2
+ import type { ProjectConfig } from "../config/types.js";
3
+ export declare function pullArtifacts(projectRoot: string, project: ProjectConfig, api: AnybuildApi): Promise<void>;
4
+ //# sourceMappingURL=pull.d.ts.map
@@ -0,0 +1 @@
1
+ {"version":3,"file":"pull.d.ts","sourceRoot":"","sources":["../../src/artifacts/pull.ts"],"names":[],"mappings":"AAEA,OAAO,KAAK,EAAE,WAAW,EAAE,MAAM,iBAAiB,CAAC;AACnD,OAAO,KAAK,EAAE,aAAa,EAAE,MAAM,oBAAoB,CAAC;AAOxD,wBAAsB,aAAa,CACjC,WAAW,EAAE,MAAM,EACnB,OAAO,EAAE,aAAa,EACtB,GAAG,EAAE,WAAW,GACf,OAAO,CAAC,IAAI,CAAC,CAgCf"}