tjs-lang 0.7.8 → 0.8.1

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 (62) hide show
  1. package/CLAUDE.md +14 -1
  2. package/CONTEXT.md +4 -0
  3. package/demo/docs.json +66 -696
  4. package/demo/src/ts-examples.ts +8 -8
  5. package/dist/eslint.config.d.ts +2 -0
  6. package/dist/index.js +137 -135
  7. package/dist/index.js.map +4 -4
  8. package/dist/src/lang/emitters/js-wasm.d.ts +5 -1
  9. package/dist/src/lang/emitters/js.d.ts +9 -0
  10. package/dist/src/lang/index.d.ts +1 -0
  11. package/dist/src/lang/module-loader.d.ts +125 -0
  12. package/dist/src/lang/parser-transforms.d.ts +79 -0
  13. package/dist/src/lang/parser-types.d.ts +33 -0
  14. package/dist/src/lang/wasm.d.ts +67 -1
  15. package/dist/tjs-batteries.js +2 -2
  16. package/dist/tjs-batteries.js.map +2 -2
  17. package/dist/tjs-eval.js +39 -37
  18. package/dist/tjs-eval.js.map +3 -3
  19. package/dist/tjs-from-ts.js +2 -2
  20. package/dist/tjs-from-ts.js.map +2 -2
  21. package/dist/tjs-lang.js +102 -102
  22. package/dist/tjs-lang.js.map +3 -3
  23. package/dist/tjs-vm.js +50 -48
  24. package/dist/tjs-vm.js.map +3 -3
  25. package/docs/README.md +2 -0
  26. package/docs/lm-studio-setup.md +143 -0
  27. package/docs/universal-endpoint.md +122 -0
  28. package/llms.txt +8 -2
  29. package/package.json +11 -6
  30. package/src/batteries/audit.ts +3 -3
  31. package/src/batteries/llm.ts +8 -3
  32. package/src/builder.ts +0 -3
  33. package/src/cli/commands/test.ts +1 -1
  34. package/src/lang/docs.test.ts +148 -1
  35. package/src/lang/docs.ts +49 -15
  36. package/src/lang/emitters/from-ts.ts +1 -1
  37. package/src/lang/emitters/js-wasm.ts +57 -65
  38. package/src/lang/emitters/js.ts +16 -2
  39. package/src/lang/features.test.ts +4 -3
  40. package/src/lang/index.ts +9 -0
  41. package/src/lang/linter.ts +1 -1
  42. package/src/lang/module-loader.test.ts +322 -0
  43. package/src/lang/module-loader.ts +418 -0
  44. package/src/lang/parser-params.ts +1 -1
  45. package/src/lang/parser-transforms.ts +339 -9
  46. package/src/lang/parser-types.ts +33 -0
  47. package/src/lang/parser.ts +43 -2
  48. package/src/lang/perf.test.ts +10 -4
  49. package/src/lang/runtime.ts +0 -1
  50. package/src/lang/wasm.test.ts +1293 -2
  51. package/src/lang/wasm.ts +470 -87
  52. package/src/linalg/index.tjs +119 -0
  53. package/src/linalg/linalg.test.ts +300 -0
  54. package/src/linalg/vector-search.bench.test.ts +416 -0
  55. package/src/types/Type.ts +6 -6
  56. package/src/use-cases/asymmetric-client-server.test.ts +0 -2
  57. package/src/use-cases/client-server.test.ts +1 -1
  58. package/src/use-cases/unbundled-imports.test.ts +0 -1
  59. package/src/vm/runtime.ts +3 -3
  60. package/src/vm/vm.ts +3 -1
  61. package/dist/examples/modules/dist/main.d.ts +0 -34
  62. package/dist/examples/modules/dist/math.d.ts +0 -120
package/CLAUDE.md CHANGED
@@ -87,7 +87,10 @@ bun run functions:serve # Local functions emulator
87
87
  - `src/lang/json-schema.ts` - JSON Schema generation from TypeDescriptors and example values
88
88
  - `src/lang/linter.ts` - Static analysis (unused vars, unreachable code, no-explicit-new)
89
89
  - `src/lang/runtime.ts` - TJS runtime (monadic errors, type checking, wrapClass)
90
- - `src/lang/wasm.ts` - WASM compiler (opcodes, disassembler, bytecode generation)
90
+ - `src/lang/wasm.ts` - WASM compiler (opcodes, disassembler, bytecode generation; multi-function module composition; wasm-to-wasm `call <index>` resolution)
91
+ - `src/lang/emitters/js-wasm.ts` - JS bootstrap emitter for compiled wasm modules (one `WebAssembly.compile` per file, name→export-index table, type-aware wrappers)
92
+ - `src/lang/module-loader.ts` - Transpile-time `.tjs`/`.ts`/`.js` module loader (Phase 0.75); used by cross-file `wasm function` composition
93
+ - `src/linalg/` - `tjs-lang/linalg` stdlib subpath (f32x4 SIMD vector kernels)
91
94
  - `src/types/` - Type system definitions (Type.ts, Generic.ts)
92
95
  - `src/transpiler/` - AJS transpiler (source → AST)
93
96
  - `src/batteries/` - LM Studio integration (lazy init, model audit, vector search)
@@ -136,6 +139,7 @@ import { tjs, transpile } from 'tjs-lang/lang' // Language tools only
136
139
  import { fromTS } from 'tjs-lang/lang/from-ts' // TypeScript transpilation
137
140
  import { AgentVM } from 'tjs-lang/vm' // VM only (smaller bundle)
138
141
  import { batteryAtoms } from 'tjs-lang/batteries' // LM Studio batteries
142
+ import { dot, norm_sq } from 'tjs-lang/linalg' // SIMD linear-algebra kernels
139
143
  // Editor integrations: 'tjs-lang/editors/monaco', '/codemirror', '/ace'
140
144
  ```
141
145
 
@@ -246,6 +250,7 @@ AJS expressions behave differently from JavaScript in several important ways:
246
250
  - Integration tests in `src/use-cases/` (RAG, orchestration, malicious actors)
247
251
  - Security tests in `src/use-cases/malicious-actor.test.ts`
248
252
  - Language tests split across 17 files in `src/lang/` (lang.test.ts, features.test.ts, codegen.test.ts, parser.test.ts, from-ts.test.ts, wasm.test.ts, etc.)
253
+ - LLM integration tests (run via full `bun test`, skipped by `SKIP_LLM_TESTS`) need a local **LM Studio** server with a chat + embedding model loaded. Setup and the hard-won gotchas (model load failures, leaked-VRAM stray `node` worker, updating runtimes, CORS, the audit-cache parallel race) are in [`docs/lm-studio-setup.md`](docs/lm-studio-setup.md).
249
254
 
250
255
  Coverage targets: 98% lines on `src/vm/runtime.ts` (security-critical), 80%+ overall.
251
256
 
@@ -426,6 +431,12 @@ Explain the concept here. Use markdown freely.
426
431
  // Then the actual TJS code
427
432
  function demo() { ... }
428
433
 
434
+ /**
435
+ * JSDoc-style /** ... *​/ blocks are also extracted as docs.
436
+ * Leading ` * ` is stripped from each line; the rest renders as markdown.
437
+ * Use this when porting TS source where JSDoc is already idiomatic.
438
+ */
439
+
429
440
  test 'a description' {
430
441
  expect(...).toBe(...)
431
442
  }
@@ -479,6 +490,8 @@ The CLI (`bun src/cli/tjs.ts run`) does NOT inject the test-block `expect` harne
479
490
  - `AGENTS.md` — Agent workflow instructions (session-completion checklist, push-before-done rule)
480
491
  - `TODO.md` — Open work, organized by area; move items to the **Completed** section when done
481
492
  - `PLAN.md` — Roadmap
493
+ - `DOCS-WASM.md` — Canonical WASM reference: inline blocks, `wasm function` declarations, memory model, cross-file composition, `tjs-lang/linalg`, current limitations
494
+ - `wasm-library-plan.md` — Cross-file WASM library design (composable `wasm function` declarations, transpile-time module composition, linalg stdlib). **Shipped in v0.8.0** — all phases (0.5, 0.75, 1, 1.5, 2, 3, 4, 5 MVP, 6) complete. See the plan for what's deferred (linalg expansion, i32/f32/v128 return types, etc.).
482
495
  - `MANIFESTO-BUILDER.md` / `MANIFESTO-ENTERPRISE.md` — Positioning docs (audience-targeted pitches)
483
496
  - `benchmarks.md` — Top-level benchmark results (separate from `guides/benchmarks.md`)
484
497
 
package/CONTEXT.md CHANGED
@@ -320,6 +320,10 @@ const registerCallback = ajs`
320
320
 
321
321
  ## 5. Production Considerations
322
322
 
323
+ ### Isomorphic Deployment (Universal Endpoint)
324
+
325
+ Because the VM is environment-agnostic and all IO is injected via capabilities, the _same_ agent program runs unchanged in the data center and in the browser client — with **one security model spanning both** (capabilities + fuel + portable TJS RBAC rules). Atoms are the seam: a client `getRecords` can serve already-loaded data and fall back to the server-side `getRecords` only on a miss, eliminating round-trips. This emerged for free from the sandboxing design rather than being built for. See [`docs/universal-endpoint.md`](docs/universal-endpoint.md).
326
+
323
327
  ### Recursive Agent Fuel
324
328
 
325
329
  When an agent calls sub-agents via `agentRun`, each sub-agent gets its own fuel budget (passed via the capability). Fuel is **not shared** across the call tree by default.