My aggregated monorepo of OCaml code, automaintained
0
fork

Configure Feed

Select the types of activity you want to include in your feed.

rename findlib_index to findlib_index.json, standardise meta_files key

Writers (jtw.ml opam mode, jtw_gen.ml day10 mode): output filename
changed from findlib_index to findlib_index.json, JSON key from
"metas" to "meta_files".

Reader (findlibish.ml): universe link resolution uses .json extension.
Runtime default (impl.ml): changed from "findlib_index" to
"findlib_index.json".

JS client, test fixtures, HTML test pages, and documentation updated
to match.

Co-Authored-By: Claude Opus 4.6 <noreply@anthropic.com>

+540 -45
+3 -3
day10/bin/jtw_gen.ml
··· 46 46 let metas = List.map (fun p -> `String p) meta_paths in 47 47 Yojson.Safe.to_string (`Assoc [ 48 48 ("compiler", compiler); 49 - ("metas", `List metas); 49 + ("meta_files", `List metas); 50 50 ]) 51 51 52 52 (** Recursively collect files matching a predicate, sorted by relative path. *) ··· 165 165 lib/<findlib-name>/ 166 166 META, dynamic_cmis.json, *.cmi, *.cma.js 167 167 u/<universe-hash>/ 168 - findlib_index (JSON: compiler info + META paths to ../../p/...) 168 + findlib_index.json (JSON: compiler info + META paths to ../../p/...) 169 169 v} 170 170 171 171 The findlib_index is the single entry point for clients. It contains: ··· 303 303 ("content_hash", `String compiler_hash); 304 304 ] in 305 305 let findlib_index = generate_findlib_index ~compiler:compiler_json sorted_metas in 306 - Os.write_to_file Path.(u_dir / "findlib_index") findlib_index 306 + Os.write_to_file Path.(u_dir / "findlib_index.json") findlib_index 307 307 end 308 308 ) solutions 309 309
+495
docs/plans/2026-02-20-findlib-index-json-rename.md
··· 1 + # findlib_index.json Rename Implementation Plan 2 + 3 + > **For Claude:** REQUIRED SUB-SKILL: Use superpowers:executing-plans to implement this plan task-by-task. 4 + 5 + **Goal:** Rename `findlib_index` to `findlib_index.json` and standardise the JSON key from `"metas"` to `"meta_files"` across both opam and day10 modes. 6 + 7 + **Architecture:** Atomic rename across writers (jtw.ml, jtw_gen.ml), reader (findlibish.ml), runtime default (impl.ml, toplevel_api.ml), JS client (ocaml-worker.js), and test fixtures. No backward compatibility — clean cut. 8 + 9 + **Tech Stack:** OCaml, JavaScript, HTML 10 + 11 + --- 12 + 13 + ## Task 1: Update opam-mode writer (jtw.ml) 14 + 15 + **Files:** 16 + - Modify: `js_top_worker/bin/jtw.ml` 17 + 18 + **Step 1: Change output filename in `opam` function** 19 + 20 + At line 225, change `"findlib_index"` to `"findlib_index.json"`: 21 + 22 + ```ocaml 23 + (* Before *) 24 + Fpath.(output_dir / "findlib_index" |> to_string) 25 + (* After *) 26 + Fpath.(output_dir / "findlib_index.json" |> to_string) 27 + ``` 28 + 29 + **Step 2: Change JSON key in `opam` function** 30 + 31 + At line 223, change `"metas"` to `"meta_files"`: 32 + 33 + ```ocaml 34 + (* Before *) 35 + let findlib_json = `Assoc [("metas", `List metas_json)] in 36 + (* After *) 37 + let findlib_json = `Assoc [("meta_files", `List metas_json)] in 38 + ``` 39 + 40 + **Step 3: Change output filename and JSON key in `opam_all` function** 41 + 42 + At line 476, change the per-package findlib_index: 43 + 44 + ```ocaml 45 + (* Before *) 46 + let findlib_json = `Assoc [("metas", `List (List.map (fun s -> `String s) all_metas))] in 47 + Out_channel.with_open_bin Fpath.(output_dir / pkg_path / "findlib_index" |> to_string) 48 + (* After *) 49 + let findlib_json = `Assoc [("meta_files", `List (List.map (fun s -> `String s) all_metas))] in 50 + Out_channel.with_open_bin Fpath.(output_dir / pkg_path / "findlib_index.json" |> to_string) 51 + ``` 52 + 53 + At line 486, change the root findlib_index: 54 + 55 + ```ocaml 56 + (* Before *) 57 + let root_index = `Assoc [("metas", `List (List.map (fun s -> `String s) all_metas))] in 58 + Out_channel.with_open_bin Fpath.(output_dir / "findlib_index" |> to_string) 59 + (* After *) 60 + let root_index = `Assoc [("meta_files", `List (List.map (fun s -> `String s) all_metas))] in 61 + Out_channel.with_open_bin Fpath.(output_dir / "findlib_index.json" |> to_string) 62 + ``` 63 + 64 + At line 490, update the log message: 65 + 66 + ```ocaml 67 + (* Before *) 68 + Format.eprintf "Generated root findlib_index with %d META files\n%!" 69 + (* After *) 70 + Format.eprintf "Generated root findlib_index.json with %d META files\n%!" 71 + ``` 72 + 73 + **Step 4: Verify compilation** 74 + 75 + Run: `opam exec -- dune build js_top_worker/bin/jtw.ml` 76 + 77 + Expected: Compiles without errors. 78 + 79 + **Step 5: Commit** 80 + 81 + ```bash 82 + git add js_top_worker/bin/jtw.ml 83 + git commit -m "rename findlib_index to findlib_index.json in opam-mode writer" 84 + ``` 85 + 86 + --- 87 + 88 + ## Task 2: Update day10-mode writer (jtw_gen.ml) 89 + 90 + **Files:** 91 + - Modify: `day10/bin/jtw_gen.ml` 92 + 93 + **Step 1: Change JSON key in `generate_findlib_index`** 94 + 95 + At line 49, change `"metas"` to `"meta_files"`: 96 + 97 + ```ocaml 98 + (* Before *) 99 + let metas = List.map (fun p -> `String p) meta_paths in 100 + Yojson.Safe.to_string (`Assoc [ 101 + ("compiler", compiler); 102 + ("metas", `List metas); 103 + ]) 104 + (* After *) 105 + let metas = List.map (fun p -> `String p) meta_paths in 106 + Yojson.Safe.to_string (`Assoc [ 107 + ("compiler", compiler); 108 + ("meta_files", `List metas); 109 + ]) 110 + ``` 111 + 112 + **Step 2: Change output filename in `assemble_jtw_output`** 113 + 114 + At line 306, change `"findlib_index"` to `"findlib_index.json"`: 115 + 116 + ```ocaml 117 + (* Before *) 118 + Os.write_to_file Path.(u_dir / "findlib_index") findlib_index 119 + (* After *) 120 + Os.write_to_file Path.(u_dir / "findlib_index.json") findlib_index 121 + ``` 122 + 123 + **Step 3: Update the doc comment** 124 + 125 + At line 168, update the directory layout comment: 126 + 127 + ```ocaml 128 + (* Before *) 129 + findlib_index (JSON: compiler info + META paths to ../../p/...) 130 + (* After *) 131 + findlib_index.json (JSON: compiler info + META paths to ../../p/...) 132 + ``` 133 + 134 + **Step 4: Verify compilation** 135 + 136 + Run: `opam exec -- dune build day10/bin/main.ml` 137 + 138 + Expected: Compiles without errors (or may fail if day10 deps aren't installed — that's OK, check for syntax errors only). 139 + 140 + **Step 5: Commit** 141 + 142 + ```bash 143 + git add day10/bin/jtw_gen.ml 144 + git commit -m "rename findlib_index to findlib_index.json in day10-mode writer" 145 + ``` 146 + 147 + --- 148 + 149 + ## Task 3: Update reader and runtime defaults 150 + 151 + **Files:** 152 + - Modify: `js_top_worker/lib/findlibish.ml` 153 + - Modify: `js_top_worker/lib/impl.ml` 154 + - Modify: `js_top_worker/idl/toplevel_api.ml` 155 + 156 + **Step 1: Update universe link resolution in findlibish.ml** 157 + 158 + At line 247, change the hardcoded `"findlib_index"` to `"findlib_index.json"`: 159 + 160 + ```ocaml 161 + (* Before *) 162 + List.map (fun u -> 163 + resolve_from_root ~base:index_url (Filename.concat u "findlib_index")) 164 + (* After *) 165 + List.map (fun u -> 166 + resolve_from_root ~base:index_url (Filename.concat u "findlib_index.json")) 167 + ``` 168 + 169 + **Step 2: Update default path in impl.ml** 170 + 171 + At line 661, change the default: 172 + 173 + ```ocaml 174 + (* Before *) 175 + let findlib_path = Option.value ~default:"findlib_index" init_libs.findlib_index in 176 + (* After *) 177 + let findlib_path = Option.value ~default:"findlib_index.json" init_libs.findlib_index in 178 + ``` 179 + 180 + **Step 3: Update API doc string in toplevel_api.ml** 181 + 182 + At line 192, update the doc comment: 183 + 184 + ```ocaml 185 + (* Before *) 186 + findlib_index : string option; (** URL to the findlib_index file. Defaults to "findlib_index" *) 187 + (* After *) 188 + findlib_index : string option; (** URL to the findlib_index.json file. Defaults to "findlib_index.json" *) 189 + ``` 190 + 191 + **Step 4: Regenerate toplevel_api_gen.ml** 192 + 193 + The `toplevel_api_gen.ml` file is generated from `toplevel_api.ml` via ppx_deriving rpcty. Check whether it needs manual regeneration or is auto-generated by dune. If auto-generated, just rebuild. If checked in, the doc strings in it will be stale but functionally irrelevant (they're embedded in the marshalling code, not user-facing). 194 + 195 + Run: `opam exec -- dune build js_top_worker/idl/` 196 + 197 + If `toplevel_api_gen.ml` is checked in and differs, update its doc strings too. Look for line 1982: 198 + 199 + ```ocaml 200 + (* Before *) 201 + " URL to the findlib_index file. Defaults to \"findlib_index\" "]; 202 + (* After *) 203 + " URL to the findlib_index.json file. Defaults to \"findlib_index.json\" "]; 204 + ``` 205 + 206 + **Step 5: Verify compilation** 207 + 208 + Run: `opam exec -- dune build js_top_worker/` 209 + 210 + Expected: Compiles without errors. 211 + 212 + **Step 6: Commit** 213 + 214 + ```bash 215 + git add js_top_worker/lib/findlibish.ml js_top_worker/lib/impl.ml js_top_worker/idl/toplevel_api.ml 216 + # Also add toplevel_api_gen.ml if it needed updating 217 + git commit -m "update reader defaults and API docs for findlib_index.json" 218 + ``` 219 + 220 + --- 221 + 222 + ## Task 4: Update JS client library 223 + 224 + **Files:** 225 + - Modify: `js_top_worker/client/ocaml-worker.js` 226 + - Modify: `js_top_worker/client/ocaml-worker.d.ts` 227 + 228 + **Step 1: Update example comment in ocaml-worker.js** 229 + 230 + At line 14: 231 + 232 + ```javascript 233 + // Before 234 + * findlib_index: 'findlib_index' 235 + // After 236 + * findlib_index: 'findlib_index.json' 237 + ``` 238 + 239 + **Step 2: Update JSDoc comment** 240 + 241 + At line 26: 242 + 243 + ```javascript 244 + // Before 245 + * @property {string} [findlib_index] - URL to findlib_index file 246 + // After 247 + * @property {string} [findlib_index] - URL to findlib_index.json file 248 + ``` 249 + 250 + **Step 3: Update fromIndex JSDoc** 251 + 252 + At lines 115-118, update the doc comments to reference `findlib_index.json`: 253 + 254 + ```javascript 255 + // Before 256 + * @param {string} indexUrl - URL to findlib_index (e.g., '/jtw-output/u/<hash>/findlib_index') 257 + // After 258 + * @param {string} indexUrl - URL to findlib_index.json (e.g., '/jtw-output/u/<hash>/findlib_index.json') 259 + ``` 260 + 261 + **Step 4: Update error messages** 262 + 263 + At line 125: 264 + 265 + ```javascript 266 + // Before 267 + if (!resp.ok) throw new Error(`Failed to fetch findlib_index: ${resp.status}`); 268 + // After 269 + if (!resp.ok) throw new Error(`Failed to fetch findlib_index.json: ${resp.status}`); 270 + ``` 271 + 272 + At line 128: 273 + 274 + ```javascript 275 + // Before 276 + if (!compiler) throw new Error('No compiler info in findlib_index'); 277 + // After 278 + if (!compiler) throw new Error('No compiler info in findlib_index.json'); 279 + ``` 280 + 281 + **Step 5: Update TypeScript declarations** 282 + 283 + In `ocaml-worker.d.ts` at line 10-11: 284 + 285 + ```typescript 286 + // Before 287 + /** URL to findlib_index file */ 288 + // After 289 + /** URL to findlib_index.json file */ 290 + ``` 291 + 292 + **Step 6: Commit** 293 + 294 + ```bash 295 + git add js_top_worker/client/ocaml-worker.js js_top_worker/client/ocaml-worker.d.ts 296 + git commit -m "update JS client docs and error messages for findlib_index.json" 297 + ``` 298 + 299 + --- 300 + 301 + ## Task 5: Update test expected files and HTML test pages 302 + 303 + **Files:** 304 + - Modify: `js_top_worker/test/node/node_test.expected` 305 + - Modify: `js_top_worker/test/node/node_directive_test.expected` 306 + - Modify: `js_top_worker/test/node/node_dependency_test.expected` 307 + - Modify: `js_top_worker/test/node/node_mime_test.expected` 308 + - Modify: `js_top_worker/test/node/node_ppx_test.expected` 309 + - Modify: `js_top_worker/test/node/node_env_test.expected` 310 + - Modify: `js_top_worker/test/node/node_incremental_test.expected` 311 + - Modify: `js_top_worker/test/ohc-integration/eval-test.html` 312 + - Modify: `js_top_worker/test/ohc-integration/test.html` 313 + - Modify: `js_top_worker/test/ohc-integration/runner.html` 314 + - Modify: `js_top_worker/test/ohc-integration/tutorials/tutorial.html` 315 + 316 + **Step 1: Update all .expected files** 317 + 318 + In every `.expected` file, replace occurrences of `findlib_index` (the filename, not the field name) with `findlib_index.json`. Specifically: 319 + 320 + - `async_get: _opam/findlib_index` → `async_get: _opam/findlib_index.json` 321 + - `Loaded findlib_index findlib_index:` → `Loaded findlib_index findlib_index.json:` 322 + 323 + Note: The first `findlib_index` in `Loaded findlib_index findlib_index.json:` is the function name in the log message (from `Jslib.log "Loaded findlib_index %s:"`), so only the second occurrence (the URL) changes. 324 + 325 + The affected files and lines: 326 + 327 + - `node_test.expected:3` — `_opam/findlib_index` → `_opam/findlib_index.json` 328 + - `node_test.expected:4` — `findlib_index findlib_index:` → `findlib_index findlib_index.json:` 329 + - `node_directive_test.expected:5` — same pattern 330 + - `node_dependency_test.expected:4` — same pattern 331 + - `node_mime_test.expected:5` — same pattern 332 + - `node_ppx_test.expected:5` — same pattern 333 + - `node_env_test.expected:5` — same pattern 334 + - `node_incremental_test.expected:3` — `_opam/findlib_index` → `_opam/findlib_index.json` 335 + - `node_incremental_test.expected:4` — same pattern 336 + 337 + **Step 2: Update ohc-integration HTML test pages** 338 + 339 + In `eval-test.html` at line 33: 340 + 341 + ```javascript 342 + // Before 343 + const indexUrl = `/jtw-output/u/${universe}/findlib_index`; 344 + // After 345 + const indexUrl = `/jtw-output/u/${universe}/findlib_index.json`; 346 + ``` 347 + 348 + In `test.html` at line 35: 349 + 350 + ```javascript 351 + // Before 352 + const indexUrl = `/jtw-output/u/${universe}/findlib_index`; 353 + // After 354 + const indexUrl = `/jtw-output/u/${universe}/findlib_index.json`; 355 + ``` 356 + 357 + In `tutorials/tutorial.html` at line 167: 358 + 359 + ```javascript 360 + // Before 361 + const indexUrl = `/jtw-output/u/${tutorial.universe}/findlib_index`; 362 + // After 363 + const indexUrl = `/jtw-output/u/${tutorial.universe}/findlib_index.json`; 364 + ``` 365 + 366 + In `runner.html` at line 487: 367 + 368 + ```javascript 369 + // Before 370 + const indexUrl = `/jtw-output/u/${universe}/findlib_index`; 371 + // After 372 + const indexUrl = `/jtw-output/u/${universe}/findlib_index.json`; 373 + ``` 374 + 375 + **Step 3: Commit** 376 + 377 + ```bash 378 + git add js_top_worker/test/ 379 + git commit -m "update test fixtures and HTML pages for findlib_index.json" 380 + ``` 381 + 382 + --- 383 + 384 + ## Task 6: Update documentation 385 + 386 + **Files:** 387 + - Modify: `js_top_worker/test/ohc-integration/SETUP.md` 388 + - Modify: `js_top_worker/docs/architecture.md` 389 + - Modify: `js_top_worker/example/README.md` 390 + 391 + **Step 1: Update SETUP.md** 392 + 393 + At line 103, in the directory layout: 394 + 395 + ``` 396 + # Before 397 + findlib_index # JSON: list of META file paths 398 + # After 399 + findlib_index.json # JSON: list of META file paths 400 + ``` 401 + 402 + **Step 2: Update architecture.md** 403 + 404 + At line 187: 405 + 406 + ``` 407 + # Before 408 + │ findlib_index │ (list of META URLs) 409 + # After 410 + │ findlib_index.json │ (list of META URLs) 411 + ``` 412 + 413 + At line 212: 414 + 415 + ``` 416 + # Before 417 + 1. Fetch `findlib_index` (list of META file URLs) 418 + # After 419 + 1. Fetch `findlib_index.json` (list of META file URLs) 420 + ``` 421 + 422 + **Step 3: Update example/README.md** 423 + 424 + At line 53: 425 + 426 + ``` 427 + # Before 428 + - `findlib_index` - Index of available packages 429 + # After 430 + - `findlib_index.json` - Index of available packages 431 + ``` 432 + 433 + At line 80: 434 + 435 + ``` 436 + # Before 437 + │ └── findlib_index # Package index 438 + # After 439 + │ └── findlib_index.json # Package index 440 + ``` 441 + 442 + At line 167: 443 + 444 + ``` 445 + # Before 446 + - Check `findlib_index` file exists 447 + # After 448 + - Check `findlib_index.json` file exists 449 + ``` 450 + 451 + **Step 4: Commit** 452 + 453 + ```bash 454 + git add js_top_worker/test/ohc-integration/SETUP.md js_top_worker/docs/architecture.md js_top_worker/example/README.md 455 + git commit -m "update documentation for findlib_index.json" 456 + ``` 457 + 458 + --- 459 + 460 + ## Task 7: Update x-ocaml client reference 461 + 462 + **Files:** 463 + - Modify: `x-ocaml/src/jtw_client.ml` 464 + 465 + **Step 1: Check if jtw_client.ml has a hardcoded findlib_index path** 466 + 467 + At line 148, `findlib_index = None` — this passes `None` which means the worker uses its default. Since we updated the default in Task 3, this is already correct. No change needed. 468 + 469 + **Step 2: Verify the full build compiles** 470 + 471 + Run: `opam exec -- dune build` 472 + 473 + Expected: Compiles without errors. 474 + 475 + **Step 3: Commit (if any changes were needed)** 476 + 477 + --- 478 + 479 + ## Task 8: Run node tests to verify 480 + 481 + **Step 1: Run the node tests** 482 + 483 + Run: `opam exec -- dune build @js_top_worker/test/node/runtest` 484 + 485 + Expected: The `jtw opam` command in the dune rules will regenerate `_opam/findlib_index.json` (new name), the node tests will run, and the `.out` files should match the updated `.expected` files. 486 + 487 + If tests fail, inspect the diff — the most likely issue is a log message mismatch in `.expected` files. Fix and re-run. 488 + 489 + **Step 2: Run the cram tests** 490 + 491 + Run: `opam exec -- dune build @js_top_worker/test/cram/runtest` 492 + 493 + Expected: Cram tests should pass (they use the unix worker, not the findlib_index path). 494 + 495 + **Step 3: Final commit if any fixups were needed**
+8 -8
js_top_worker/bin/jtw.ml
··· 220 220 in 221 221 (* TODO: dep_paths should also contribute META paths once we have full universe info *) 222 222 let _ = dep_paths in 223 - let findlib_json = `Assoc [("metas", `List metas_json)] in 223 + let findlib_json = `Assoc [("meta_files", `List metas_json)] in 224 224 Out_channel.with_open_bin 225 - Fpath.(output_dir / "findlib_index" |> to_string) 225 + Fpath.(output_dir / "findlib_index.json" |> to_string) 226 226 (fun oc -> Printf.fprintf oc "%s\n" (Yojson.Safe.to_string findlib_json)); 227 227 228 228 (* Compile archives for each library AND its subpackages *) ··· 473 473 deps 474 474 in 475 475 let all_metas = this_meta :: dep_metas in 476 - let findlib_json = `Assoc [("metas", `List (List.map (fun s -> `String s) all_metas))] in 477 - Out_channel.with_open_bin Fpath.(output_dir / pkg_path / "findlib_index" |> to_string) 476 + let findlib_json = `Assoc [("meta_files", `List (List.map (fun s -> `String s) all_metas))] in 477 + Out_channel.with_open_bin Fpath.(output_dir / pkg_path / "findlib_index.json" |> to_string) 478 478 (fun oc -> Printf.fprintf oc "%s\n" (Yojson.Safe.to_string findlib_json))) 479 479 pkg_results; 480 480 481 - (* Generate root findlib_index with all META paths *) 481 + (* Generate root findlib_index.json with all META paths *) 482 482 let all_metas = List.map (fun (pkg_path, local_meta_path, _) -> 483 483 pkg_path ^ "/" ^ local_meta_path) 484 484 pkg_results 485 485 in 486 - let root_index = `Assoc [("metas", `List (List.map (fun s -> `String s) all_metas))] in 487 - Out_channel.with_open_bin Fpath.(output_dir / "findlib_index" |> to_string) 486 + let root_index = `Assoc [("meta_files", `List (List.map (fun s -> `String s) all_metas))] in 487 + Out_channel.with_open_bin Fpath.(output_dir / "findlib_index.json" |> to_string) 488 488 (fun oc -> Printf.fprintf oc "%s\n" (Yojson.Safe.to_string root_index)); 489 489 490 - Format.eprintf "Generated root findlib_index with %d META files\n%!" (List.length pkg_results); 490 + Format.eprintf "Generated root findlib_index.json with %d META files\n%!" (List.length pkg_results); 491 491 492 492 (* Generate worker.js if requested *) 493 493 let () = if no_worker then () else Mk_backend.mk switch output_dir in
+1 -1
js_top_worker/client/ocaml-worker.d.ts
··· 7 7 findlib_requires: string[]; 8 8 /** URL to dynamic CMIs for stdlib */ 9 9 stdlib_dcs?: string; 10 - /** URL to findlib_index file */ 10 + /** URL to findlib_index.json file */ 11 11 findlib_index?: string; 12 12 } 13 13
+7 -7
js_top_worker/client/ocaml-worker.js
··· 11 11 * 12 12 * await worker.init({ 13 13 * findlib_requires: [], 14 - * findlib_index: 'findlib_index' 14 + * findlib_index: 'findlib_index.json' 15 15 * }); 16 16 * 17 17 * const result = await worker.eval('let x = 1 + 2;;'); ··· 23 23 * @typedef {Object} InitConfig 24 24 * @property {string[]} findlib_requires - Findlib packages to require 25 25 * @property {string} [stdlib_dcs] - URL to dynamic CMIs for stdlib 26 - * @property {string} [findlib_index] - URL to findlib_index file 26 + * @property {string} [findlib_index] - URL to findlib_index.json file 27 27 */ 28 28 29 29 /** ··· 112 112 } 113 113 114 114 /** 115 - * Create a worker from a findlib_index URL. 116 - * The findlib_index JSON contains compiler info (version, content_hash) and 115 + * Create a worker from a findlib_index.json URL. 116 + * The findlib_index.json contains compiler info (version, content_hash) and 117 117 * META file paths. This is the single entry point for discovery. 118 - * @param {string} indexUrl - URL to findlib_index (e.g., '/jtw-output/u/<hash>/findlib_index') 118 + * @param {string} indexUrl - URL to findlib_index.json (e.g., '/jtw-output/u/<hash>/findlib_index.json') 119 119 * @param {string} baseOutputUrl - Base URL of the jtw-output directory (e.g., '/jtw-output') 120 120 * @param {Object} [options] - Options passed to OcamlWorker constructor 121 121 * @returns {Promise<{worker: OcamlWorker, findlib_index: string, stdlib_dcs: string}>} 122 122 */ 123 123 static async fromIndex(indexUrl, baseOutputUrl, options = {}) { 124 124 const resp = await fetch(indexUrl); 125 - if (!resp.ok) throw new Error(`Failed to fetch findlib_index: ${resp.status}`); 125 + if (!resp.ok) throw new Error(`Failed to fetch findlib_index.json: ${resp.status}`); 126 126 const index = await resp.json(); 127 127 const compiler = index.compiler; 128 - if (!compiler) throw new Error('No compiler info in findlib_index'); 128 + if (!compiler) throw new Error('No compiler info in findlib_index.json'); 129 129 const ver = compiler.version; 130 130 const hash = compiler.content_hash; 131 131 const workerUrl = `${baseOutputUrl}/compiler/${ver}/${hash}/worker.js`;
+2 -2
js_top_worker/docs/architecture.md
··· 184 184 185 185 ``` 186 186 ┌─────────────────┐ 187 - │ findlib_index │ (list of META URLs) 187 + │ findlib_index.json │ (list of META URLs) 188 188 └────────┬────────┘ 189 189 190 190 ┌──────────────┼──────────────┐ ··· 209 209 210 210 ### Package Loading Process 211 211 212 - 1. Fetch `findlib_index` (list of META file URLs) 212 + 1. Fetch `findlib_index.json` (list of META file URLs) 213 213 2. Parse each META file with `Fl_metascanner` 214 214 3. Build dependency graph 215 215 4. On `#require`:
+3 -3
js_top_worker/example/README.md
··· 50 50 This creates `_build/default/example/_opam/` containing: 51 51 - `worker.js` - The WebWorker toplevel 52 52 - `lib/` - Compiled CMI files and JavaScript-compiled CMA files 53 - - `findlib_index` - Index of available packages 53 + - `findlib_index.json` - Index of available packages 54 54 55 55 ### 3. Start the Web Server 56 56 ··· 77 77 ├── _opam/ # Generated: compiled packages 78 78 │ ├── worker.js # The compiled WebWorker 79 79 │ ├── lib/ # CMI files and .cma.js files 80 - │ └── findlib_index # Package index 80 + │ └── findlib_index.json # Package index 81 81 └── *.html, *.ml # Other example files 82 82 ``` 83 83 ··· 164 164 165 165 - The worker loads files via HTTP; check network tab 166 166 - Ensure `lib/ocaml/` directory has CMI files 167 - - Check `findlib_index` file exists 167 + - Check `findlib_index.json` file exists 168 168 169 169 ### Library not found with #require 170 170
+1 -1
js_top_worker/idl/toplevel_api.ml
··· 189 189 type init_config = { 190 190 findlib_requires : string list; (** Findlib packages to require *) 191 191 stdlib_dcs : string option; (** URL to the dynamic cmis for the OCaml standard library *) 192 - findlib_index : string option; (** URL to the findlib_index file. Defaults to "findlib_index" *) 192 + findlib_index : string option; (** URL to the findlib_index.json file. Defaults to "findlib_index.json" *) 193 193 execute : bool (** Whether this session should support execution or not. *) 194 194 } [@@deriving rpcty] 195 195 type err = InternalError of string [@@deriving rpcty]
+2 -2
js_top_worker/idl/toplevel_api_gen.ml
··· 1979 1979 [@ocaml.doc " URL to the dynamic cmis for the OCaml standard library "]; 1980 1980 findlib_index: string option 1981 1981 [@ocaml.doc 1982 - " URL to the findlib_index file. Defaults to \"findlib_index\" "]; 1982 + " URL to the findlib_index.json file. Defaults to \"findlib_index.json\" "]; 1983 1983 execute: bool 1984 1984 [@ocaml.doc " Whether this session should support execution or not. "]} 1985 1985 [@@deriving rpcty] ··· 2016 2016 (Rpc.Types.Option (let open Rpc.Types in Basic String)); 2017 2017 Rpc.Types.fdefault = None; 2018 2018 Rpc.Types.fdescription = 2019 - ["URL to the findlib_index file. Defaults to \"findlib_index\""]; 2019 + ["URL to the findlib_index.json file. Defaults to \"findlib_index.json\""]; 2020 2020 Rpc.Types.fversion = None; 2021 2021 Rpc.Types.fget = (fun _r -> _r.findlib_index); 2022 2022 Rpc.Types.fset = (fun v _s -> { _s with findlib_index = v })
+1 -1
js_top_worker/lib/findlibish.ml
··· 244 244 (* Resolve universe paths from root (they're already full paths) *) 245 245 let universe_index_urls = 246 246 List.map (fun u -> 247 - resolve_from_root ~base:index_url (Filename.concat u "findlib_index")) 247 + resolve_from_root ~base:index_url (Filename.concat u "findlib_index.json")) 248 248 universes 249 249 in 250 250 let* universe_libs = Lwt_list.map_p load_universe universe_index_urls in
+1 -1
js_top_worker/lib/impl.ml
··· 658 658 Logs.info (fun m -> m "init()"); 659 659 path := Some S.path; 660 660 661 - let findlib_path = Option.value ~default:"findlib_index" init_libs.findlib_index in 661 + let findlib_path = Option.value ~default:"findlib_index.json" init_libs.findlib_index in 662 662 findlib_v := Some (S.findlib_init findlib_path); 663 663 664 664 let stdlib_dcs =
+1 -1
js_top_worker/test/node/node_dependency_test.expected
··· 1 1 === Node.js Cell Dependency Tests === 2 2 3 3 Initializing findlib 4 - Loaded findlib_index findlib_index: 10 META files, 0 universes 4 + Loaded findlib_index findlib_index.json: 10 META files, 0 universes 5 5 Parsed uri: ./lib/stdlib-shims/META 6 6 Reading library: stdlib-shims 7 7 Number of children: 0
+1 -1
js_top_worker/test/node/node_directive_test.expected
··· 2 2 3 3 node_directive_test.js: [INFO] init() 4 4 Initializing findlib 5 - Loaded findlib_index findlib_index: 10 META files, 0 universes 5 + Loaded findlib_index findlib_index.json: 10 META files, 0 universes 6 6 Parsed uri: ./lib/stdlib-shims/META 7 7 Reading library: stdlib-shims 8 8 Number of children: 0
+1 -1
js_top_worker/test/node/node_env_test.expected
··· 2 2 3 3 node_env_test.js: [INFO] init() 4 4 Initializing findlib 5 - Loaded findlib_index findlib_index: 10 META files, 0 universes 5 + Loaded findlib_index findlib_index.json: 10 META files, 0 universes 6 6 Parsed uri: ./lib/stdlib-shims/META 7 7 Reading library: stdlib-shims 8 8 Number of children: 0
+2 -2
js_top_worker/test/node/node_incremental_test.expected
··· 1 1 node_incremental_test.js: [INFO] init() 2 2 Initializing findlib 3 - node_incremental_test.js: [INFO] async_get: _opam/findlib_index 4 - Loaded findlib_index findlib_index: 10 META files, 0 universes 3 + node_incremental_test.js: [INFO] async_get: _opam/findlib_index.json 4 + Loaded findlib_index findlib_index.json: 10 META files, 0 universes 5 5 node_incremental_test.js: [INFO] async_get: _opam/./lib/stdlib-shims/META 6 6 Parsed uri: ./lib/stdlib-shims/META 7 7 Reading library: stdlib-shims
+1 -1
js_top_worker/test/node/node_mime_test.expected
··· 2 2 3 3 node_mime_test.js: [INFO] init() 4 4 Initializing findlib 5 - Loaded findlib_index findlib_index: 10 META files, 0 universes 5 + Loaded findlib_index findlib_index.json: 10 META files, 0 universes 6 6 Parsed uri: ./lib/stdlib-shims/META 7 7 Reading library: stdlib-shims 8 8 Number of children: 0
+1 -1
js_top_worker/test/node/node_ppx_test.expected
··· 2 2 3 3 node_ppx_test.js: [INFO] init() 4 4 Initializing findlib 5 - Loaded findlib_index findlib_index: 10 META files, 0 universes 5 + Loaded findlib_index findlib_index.json: 10 META files, 0 universes 6 6 Parsed uri: ./lib/stdlib-shims/META 7 7 Reading library: stdlib-shims 8 8 Number of children: 0
+2 -2
js_top_worker/test/node/node_test.expected
··· 1 1 node_test.js: [INFO] init() 2 2 Initializing findlib 3 - node_test.js: [INFO] async_get: _opam/findlib_index 4 - Loaded findlib_index findlib_index: 10 META files, 0 universes 3 + node_test.js: [INFO] async_get: _opam/findlib_index.json 4 + Loaded findlib_index findlib_index.json: 10 META files, 0 universes 5 5 node_test.js: [INFO] async_get: _opam/./lib/stdlib-shims/META 6 6 Parsed uri: ./lib/stdlib-shims/META 7 7 Reading library: stdlib-shims
+1 -1
js_top_worker/test/ohc-integration/SETUP.md
··· 100 100 dynamic_cmis.json # Stdlib module index 101 101 *.cmi, stdlib.cma.js # Stdlib artifacts 102 102 u/<universe-hash>/ # One per (package, version) universe 103 - findlib_index # JSON: list of META file paths 103 + findlib_index.json # JSON: list of META file paths 104 104 <pkg>/<ver>/lib/<findlib>/ # Package artifacts 105 105 META, *.cmi, *.cma.js, dynamic_cmis.json 106 106 p/<pkg>/<ver>/lib/... # Blessed packages (same structure)
+2 -2
js_top_worker/test/ohc-integration/eval-test.html
··· 29 29 throw new Error('universe parameter required'); 30 30 } 31 31 32 - status.textContent = 'Fetching findlib_index...'; 33 - const indexUrl = `/jtw-output/u/${universe}/findlib_index`; 32 + status.textContent = 'Fetching findlib_index.json...'; 33 + const indexUrl = `/jtw-output/u/${universe}/findlib_index.json`; 34 34 const { worker, stdlib_dcs, findlib_index } = await OcamlWorker.fromIndex( 35 35 indexUrl, '/jtw-output', { timeout: 120000 }); 36 36
+1 -1
js_top_worker/test/ohc-integration/runner.html
··· 484 484 485 485 async function getWorker(universe) { 486 486 if (workerCache.has(universe)) return workerCache.get(universe); 487 - const indexUrl = `/jtw-output/u/${universe}/findlib_index`; 487 + const indexUrl = `/jtw-output/u/${universe}/findlib_index.json`; 488 488 const { worker: w, stdlib_dcs, findlib_index } = await OcamlWorker.fromIndex( 489 489 indexUrl, '/jtw-output', { timeout: 120000 }); 490 490 await w.init({
+2 -2
js_top_worker/test/ohc-integration/test.html
··· 31 31 throw new Error('universe parameter required'); 32 32 } 33 33 34 - status.textContent = 'Fetching findlib_index...'; 35 - const indexUrl = `/jtw-output/u/${universe}/findlib_index`; 34 + status.textContent = 'Fetching findlib_index.json...'; 35 + const indexUrl = `/jtw-output/u/${universe}/findlib_index.json`; 36 36 const { worker, stdlib_dcs, findlib_index } = await OcamlWorker.fromIndex( 37 37 indexUrl, '/jtw-output', { timeout: 120000 }); 38 38
+1 -1
js_top_worker/test/ohc-integration/tutorials/tutorial.html
··· 164 164 initEl.innerHTML = '<span class="spinner">&#x25E0;</span> Initializing OCaml worker...'; 165 165 let worker; 166 166 try { 167 - const indexUrl = `/jtw-output/u/${tutorial.universe}/findlib_index`; 167 + const indexUrl = `/jtw-output/u/${tutorial.universe}/findlib_index.json`; 168 168 const { worker: w, stdlib_dcs, findlib_index } = await OcamlWorker.fromIndex( 169 169 indexUrl, '/jtw-output', { timeout: 120000 }); 170 170 worker = w;