tjs-lang 0.6.19 → 0.6.26

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 (111) hide show
  1. package/CLAUDE.md +29 -24
  2. package/bin/dev.ts +9 -0
  3. package/demo/docs.json +49 -1
  4. package/demo/src/playground-shared.ts +8 -39
  5. package/demo/src/tjs-playground.ts +8 -0
  6. package/demo/src/tjs-runtime-iframe.ts +10 -0
  7. package/demo/src/ts-playground.ts +8 -0
  8. package/package.json +1 -1
  9. package/src/cli/commands/run.ts +4 -1
  10. package/src/cli/tjs.ts +1 -1
  11. package/src/lang/codegen.test.ts +26 -27
  12. package/src/lang/emitters/dts.test.ts +22 -0
  13. package/src/lang/emitters/dts.ts +5 -1
  14. package/src/lang/emitters/js-tests.ts +13 -19
  15. package/src/lang/emitters/js.ts +39 -7
  16. package/src/lang/parser-transforms.ts +18 -5
  17. package/src/lang/roundtrip.test.ts +1 -1
  18. package/src/lang/runtime.ts +88 -2
  19. package/src/lang/wasm.ts +1 -1
  20. package/dist/bin/benchmarks.d.ts +0 -9
  21. package/dist/bin/dev.d.ts +0 -1
  22. package/dist/bin/docs.d.ts +0 -1
  23. package/dist/bin/select-local-models.d.ts +0 -1
  24. package/dist/examples/modules/dist/main.d.ts +0 -34
  25. package/dist/examples/modules/dist/math.d.ts +0 -120
  26. package/dist/index.js +0 -426
  27. package/dist/index.js.map +0 -45
  28. package/dist/scripts/build-demo.d.ts +0 -2
  29. package/dist/scripts/build.d.ts +0 -11
  30. package/dist/scripts/seed-blog-rules.d.ts +0 -2
  31. package/dist/scripts/seed-stored-function.d.ts +0 -2
  32. package/dist/src/atoms/batteries.d.ts +0 -4
  33. package/dist/src/atoms/browser.d.ts +0 -4
  34. package/dist/src/atoms/index.d.ts +0 -4
  35. package/dist/src/batteries/audit.d.ts +0 -9
  36. package/dist/src/batteries/index.d.ts +0 -28
  37. package/dist/src/batteries/llm.d.ts +0 -18
  38. package/dist/src/batteries/models.d.ts +0 -19
  39. package/dist/src/batteries/store.d.ts +0 -13
  40. package/dist/src/builder.d.ts +0 -127
  41. package/dist/src/bun-plugin/tjs-plugin.d.ts +0 -12
  42. package/dist/src/cli/commands/check.d.ts +0 -4
  43. package/dist/src/cli/commands/convert.d.ts +0 -20
  44. package/dist/src/cli/commands/emit.d.ts +0 -34
  45. package/dist/src/cli/commands/run.d.ts +0 -6
  46. package/dist/src/cli/commands/test.d.ts +0 -21
  47. package/dist/src/cli/commands/types.d.ts +0 -4
  48. package/dist/src/cli/create-app.d.ts +0 -9
  49. package/dist/src/cli/playground.d.ts +0 -9
  50. package/dist/src/cli/tjs.d.ts +0 -15
  51. package/dist/src/cli/tjsx.d.ts +0 -16
  52. package/dist/src/index.d.ts +0 -11
  53. package/dist/src/inference.types.d.ts +0 -1
  54. package/dist/src/lang/core.d.ts +0 -56
  55. package/dist/src/lang/docs.d.ts +0 -69
  56. package/dist/src/lang/emitters/ast.d.ts +0 -24
  57. package/dist/src/lang/emitters/dts.d.ts +0 -48
  58. package/dist/src/lang/emitters/from-ts.d.ts +0 -94
  59. package/dist/src/lang/emitters/js-tests.d.ts +0 -70
  60. package/dist/src/lang/emitters/js-wasm.d.ts +0 -15
  61. package/dist/src/lang/emitters/js.d.ts +0 -175
  62. package/dist/src/lang/eval.d.ts +0 -63
  63. package/dist/src/lang/index.d.ts +0 -216
  64. package/dist/src/lang/inference.d.ts +0 -40
  65. package/dist/src/lang/linter.d.ts +0 -53
  66. package/dist/src/lang/metadata-cache.d.ts +0 -172
  67. package/dist/src/lang/parser-params.d.ts +0 -37
  68. package/dist/src/lang/parser-transforms.d.ts +0 -281
  69. package/dist/src/lang/parser-types.d.ts +0 -175
  70. package/dist/src/lang/parser.d.ts +0 -56
  71. package/dist/src/lang/runtime.d.ts +0 -454
  72. package/dist/src/lang/schema.d.ts +0 -35
  73. package/dist/src/lang/tests.d.ts +0 -94
  74. package/dist/src/lang/transpiler.d.ts +0 -25
  75. package/dist/src/lang/types.d.ts +0 -147
  76. package/dist/src/lang/wasm.d.ts +0 -83
  77. package/dist/src/rbac/index.d.ts +0 -85
  78. package/dist/src/rbac/rules.d.ts +0 -184
  79. package/dist/src/runtime.d.ts +0 -4
  80. package/dist/src/store/index.d.ts +0 -3
  81. package/dist/src/store/indexeddb.d.ts +0 -6
  82. package/dist/src/store/interface.d.ts +0 -90
  83. package/dist/src/store/memory.d.ts +0 -10
  84. package/dist/src/test-examples.d.ts +0 -41
  85. package/dist/src/test-utils.d.ts +0 -86
  86. package/dist/src/transpiler/index.d.ts +0 -6
  87. package/dist/src/transpiler/parser.d.ts +0 -4
  88. package/dist/src/transpiler/transformer.d.ts +0 -4
  89. package/dist/src/transpiler/type-system/inference.d.ts +0 -1
  90. package/dist/src/transpiler/types.d.ts +0 -4
  91. package/dist/src/types/LegalDate.d.ts +0 -241
  92. package/dist/src/types/Timestamp.d.ts +0 -233
  93. package/dist/src/types/Type.d.ts +0 -234
  94. package/dist/src/types/index.d.ts +0 -8
  95. package/dist/src/vm/atoms/batteries.d.ts +0 -6
  96. package/dist/src/vm/atoms/browser.d.ts +0 -18
  97. package/dist/src/vm/atoms/index.d.ts +0 -10
  98. package/dist/src/vm/index.d.ts +0 -12
  99. package/dist/src/vm/runtime.d.ts +0 -333
  100. package/dist/src/vm/vm.d.ts +0 -28
  101. package/dist/src/vm.d.ts +0 -4
  102. package/dist/test-preprocess.d.ts +0 -1
  103. package/dist/tjs-batteries.js +0 -4
  104. package/dist/tjs-batteries.js.map +0 -15
  105. package/dist/tjs-full.js +0 -426
  106. package/dist/tjs-full.js.map +0 -45
  107. package/dist/tjs-src/runtime.d.ts +0 -1
  108. package/dist/tjs-transpiler.js +0 -3
  109. package/dist/tjs-transpiler.js.map +0 -11
  110. package/dist/tjs-vm.js +0 -54
  111. package/dist/tjs-vm.js.map +0 -22
@@ -1,2 +0,0 @@
1
- #!/usr/bin/env bun
2
- export {};
@@ -1,11 +0,0 @@
1
- #!/usr/bin/env bun
2
- /**
3
- * Build script for TJS bundles
4
- *
5
- * Produces separate bundles for different use cases:
6
- * - tjs-vm.js - VM runtime only (universal endpoint)
7
- * - tjs-batteries.js - LLM, vector, store ops (optional runtime)
8
- * - tjs-transpiler.js - TJS/AJS transpiler (no TS compiler)
9
- * - tjs-full.js - Everything including fromTS + TS compiler
10
- */
11
- export {};
@@ -1,2 +0,0 @@
1
- #!/usr/bin/env bun
2
- export {};
@@ -1,2 +0,0 @@
1
- #!/usr/bin/env bun
2
- export {};
@@ -1,4 +0,0 @@
1
- /**
2
- * @deprecated Import from '../vm/atoms/batteries' instead
3
- */
4
- export * from '../vm/atoms/batteries';
@@ -1,4 +0,0 @@
1
- /**
2
- * @deprecated Import from '../vm/atoms/browser' instead
3
- */
4
- export * from '../vm/atoms/browser';
@@ -1,4 +0,0 @@
1
- /**
2
- * @deprecated Import from '../vm/atoms' instead
3
- */
4
- export * from '../vm/atoms';
@@ -1,9 +0,0 @@
1
- export interface ModelAudit {
2
- id: string;
3
- type: 'LLM' | 'Embedding' | 'Unknown';
4
- structuredOutput: boolean;
5
- vision: boolean;
6
- dimension?: number;
7
- status: string;
8
- }
9
- export declare function auditModels(baseUrl: string): Promise<ModelAudit[]>;
@@ -1,28 +0,0 @@
1
- import { getStoreCapability as getStoreCapabilityDefault } from './store';
2
- import { getLLMCapability } from './llm';
3
- import { LocalModels } from './models';
4
- export declare function getBatteries(): Promise<{
5
- vector: {
6
- embed: (text: string) => Promise<number[]>;
7
- } | undefined;
8
- store: import("./store").StoreCapability;
9
- llmBattery: import("./llm").LLMCapability | null;
10
- models: LocalModels | null;
11
- }>;
12
- export declare function getStandardCapabilities(): Promise<{
13
- vector: {
14
- embed: (text: string) => Promise<number[]>;
15
- } | undefined;
16
- store: import("./store").StoreCapability;
17
- llmBattery: import("./llm").LLMCapability | null;
18
- models: LocalModels | null;
19
- }>;
20
- export { LocalModels, getLLMCapability, getStoreCapabilityDefault };
21
- export declare const batteries: {
22
- store: import("./store").StoreCapability;
23
- llmBattery: ReturnType<typeof getLLMCapability> | null;
24
- vector: {
25
- embed: (text: string) => Promise<number[]>;
26
- } | undefined;
27
- models: LocalModels | null;
28
- };
@@ -1,18 +0,0 @@
1
- import { LocalModels } from './models';
2
- /**
3
- * LLM Capability Battery
4
- * Bridges to local LM Studio instance via HTTP.
5
- */
6
- /**
7
- * User content can be a simple string or multimodal with images.
8
- * Images should be URLs or data URIs (data:image/...;base64,...)
9
- */
10
- export type UserContent = string | {
11
- text: string;
12
- images?: string[];
13
- };
14
- export interface LLMCapability {
15
- predict(system: string, user: UserContent, tools?: any[], responseFormat?: any): Promise<any>;
16
- embed(text: string): Promise<number[]>;
17
- }
18
- export declare function getLLMCapability(models: LocalModels, baseUrl?: string): LLMCapability;
@@ -1,19 +0,0 @@
1
- import { type ModelAudit } from './audit';
2
- export declare class LocalModels {
3
- private baseUrl;
4
- private models;
5
- private defaultLLM;
6
- private defaultEmbedding;
7
- private defaultStructuredLLM;
8
- constructor(baseUrl?: string);
9
- audit(): Promise<void>;
10
- private selectDefaults;
11
- getModels(): ModelAudit[];
12
- private _setDefaultModel;
13
- setDefaultLLM(modelId: string): void;
14
- setDefaultEmbedding(modelId: string): void;
15
- setDefaultStructuredLLM(modelId: string): void;
16
- getLLM(): ModelAudit;
17
- getEmbedding(): ModelAudit;
18
- getStructuredLLM(): ModelAudit;
19
- }
@@ -1,13 +0,0 @@
1
- /**
2
- * Store Capability Battery
3
- * Provides Key-Value storage and lightweight in-memory Vector Search.
4
- */
5
- export interface StoreCapability {
6
- get(key: string): Promise<any>;
7
- set(key: string, val: any): Promise<void>;
8
- createCollection(name: string, schema?: any, dimension?: number): Promise<void>;
9
- vectorAdd(collection: string, doc: any): Promise<void>;
10
- vectorSearch(collection: string, vector: number[], k?: number): Promise<any[]>;
11
- }
12
- export declare function cosineSimilarity(vecA: number[], vecB: number[]): number;
13
- export declare function getStoreCapability(): StoreCapability;
@@ -1,127 +0,0 @@
1
- import { coreAtoms, type Atom, type OpCode } from './runtime';
2
- /**
3
- * VarMapping maps condition variable names to state paths.
4
- * Keys are variable names used in the condition string,
5
- * values are state paths (e.g., { count: 'counter.value' }).
6
- */
7
- type VarMapping = Record<string, string>;
8
- /**
9
- * ItemsRef is a reference to an array in state (string path)
10
- * or a literal array value for iteration atoms.
11
- */
12
- type ItemsRef = string | unknown[];
13
- export interface BaseNode {
14
- op: OpCode;
15
- [key: string]: any;
16
- }
17
- export interface SeqNode extends BaseNode {
18
- op: 'seq';
19
- steps: BaseNode[];
20
- }
21
- export interface ArgRef {
22
- $kind: 'arg';
23
- path: string;
24
- }
25
- type AtomInput<T> = T extends Atom<infer I, any> ? I : never;
26
- type BuilderMethods<M extends Record<string, Atom<any, any>>> = {
27
- [K in keyof M as M[K]['op']]: (input: AtomInput<M[K]>) => BuilderType<M>;
28
- };
29
- interface ControlFlow<M extends Record<string, Atom<any, any>>> {
30
- varsImport(keys: string[] | Record<string, string>): BuilderType<M>;
31
- varsExport(keys: string[] | Record<string, string>): BuilderType<M>;
32
- /**
33
- * Conditional branch. Condition is a JS-like expression string.
34
- * @param condition - Expression like "count > 0 && active"
35
- * @param vars - Map condition vars to state paths: { count: 'state.count' }
36
- * @param thenBranch - Steps to run if condition is true
37
- * @param elseBranch - Optional steps if condition is false
38
- */
39
- if(condition: string, vars: VarMapping, thenBranch: (b: BuilderType<M>) => BuilderType<M>, elseBranch?: (b: BuilderType<M>) => BuilderType<M>): BuilderType<M>;
40
- /**
41
- * Loop while condition is true.
42
- * @param condition - Expression like "count < 10"
43
- * @param vars - Map condition vars to state paths
44
- * @param body - Steps to run each iteration
45
- */
46
- while(condition: string, vars: VarMapping, body: (b: BuilderType<M>) => BuilderType<M>): BuilderType<M>;
47
- scope(steps: (b: BuilderType<M>) => BuilderType<M>): BuilderType<M>;
48
- /**
49
- * Transform each item in array.
50
- * @param items - State path to array or literal array
51
- * @param as - Variable name for current item in scope
52
- * @param steps - Transform steps (result is new item value)
53
- */
54
- map(items: ItemsRef, as: string, steps: (b: BuilderType<M>) => BuilderType<M>): BuilderType<M>;
55
- /**
56
- * Filter array to items matching condition.
57
- * @param items - State path to array or literal array
58
- * @param as - Variable name for current item
59
- * @param condition - Filter expression using 'as' variable
60
- * @param vars - Additional var mappings (optional)
61
- */
62
- filter(items: ItemsRef, as: string, condition: string, vars?: VarMapping): BuilderType<M>;
63
- /**
64
- * Find first item matching condition.
65
- * @param items - State path to array or literal array
66
- * @param as - Variable name for current item
67
- * @param condition - Search expression
68
- * @param vars - Additional var mappings (optional)
69
- */
70
- find(items: ItemsRef, as: string, condition: string, vars?: VarMapping): BuilderType<M>;
71
- /**
72
- * Reduce array to single value.
73
- * @param items - State path to array or literal array
74
- * @param as - Variable name for current item
75
- * @param accumulator - Variable name for running result
76
- * @param initial - Initial accumulator value
77
- * @param steps - Reduction steps (result becomes new accumulator)
78
- */
79
- reduce<T>(items: ItemsRef, as: string, accumulator: string, initial: T, steps: (b: BuilderType<M>) => BuilderType<M>): BuilderType<M>;
80
- memoize(steps: (b: BuilderType<M>) => BuilderType<M>, key?: string): BuilderType<M>;
81
- cache(steps: (b: BuilderType<M>) => BuilderType<M>, key?: string, ttlMs?: number): BuilderType<M>;
82
- try(branches: {
83
- try: (b: BuilderType<M>) => BuilderType<M>;
84
- catch?: (b: BuilderType<M>) => BuilderType<M>;
85
- }): BuilderType<M>;
86
- }
87
- export declare class TypedBuilder<M extends Record<string, Atom<any, any>>> {
88
- steps: BaseNode[];
89
- private atoms;
90
- private proxy;
91
- constructor(atoms: M);
92
- private add;
93
- as(variableName: string): BuilderType<M>;
94
- step(node: BaseNode): BuilderType<M>;
95
- return(schema: any): BuilderType<M>;
96
- toJSON(): SeqNode;
97
- varsImport(keys: string[] | Record<string, string>): BuilderType<M>;
98
- varsExport(keys: string[] | Record<string, string>): BuilderType<M>;
99
- if(condition: string, vars: VarMapping, thenBranch: (b: BuilderType<M>) => BuilderType<M>, elseBranch?: (b: BuilderType<M>) => BuilderType<M>): BuilderType<M>;
100
- while(condition: string, vars: VarMapping, body: (b: BuilderType<M>) => BuilderType<M>): BuilderType<M>;
101
- scope(steps: (b: BuilderType<M>) => BuilderType<M>): BuilderType<M>;
102
- map(items: ItemsRef, as: string, steps: (b: BuilderType<M>) => BuilderType<M>): BuilderType<M>;
103
- filter(items: ItemsRef, as: string, condition: string, vars?: VarMapping): BuilderType<M>;
104
- find(items: ItemsRef, as: string, condition: string, vars?: VarMapping): BuilderType<M>;
105
- reduce<T>(items: ItemsRef, as: string, accumulator: string, initial: T, steps: (b: BuilderType<M>) => BuilderType<M>): BuilderType<M>;
106
- memoize(steps: (b: BuilderType<M>) => BuilderType<M>, key?: string): BuilderType<M>;
107
- cache(steps: (b: BuilderType<M>) => BuilderType<M>, key?: string, ttlMs?: number): BuilderType<M>;
108
- try(branches: {
109
- try: (b: BuilderType<M>) => BuilderType<M>;
110
- catch?: (b: BuilderType<M>) => BuilderType<M>;
111
- }): BuilderType<M>;
112
- }
113
- export type BuilderType<M extends Record<string, Atom<any, any>>> = TypedBuilder<M> & BuilderMethods<M> & ControlFlow<M>;
114
- export declare const Agent: {
115
- take(_schema?: any): BuilderType<typeof coreAtoms>;
116
- custom<M extends Record<string, Atom<any, any>>>(atoms: M): BuilderType<M>;
117
- args(path: string): ArgRef;
118
- val(path: string): string;
119
- };
120
- /** @deprecated Use `Agent` instead */
121
- export declare const A99: {
122
- take(_schema?: any): BuilderType<typeof coreAtoms>;
123
- custom<M extends Record<string, Atom<any, any>>>(atoms: M): BuilderType<M>;
124
- args(path: string): ArgRef;
125
- val(path: string): string;
126
- };
127
- export {};
@@ -1,12 +0,0 @@
1
- /**
2
- * Bun plugin for native .tjs file support
3
- *
4
- * Enables `bun run file.tjs` to work directly.
5
- *
6
- * Register in bunfig.toml:
7
- * preload = ["./src/bun-plugin/tjs-plugin.ts"]
8
- *
9
- * Or programmatically:
10
- * import "./src/bun-plugin/tjs-plugin"
11
- */
12
- export {};
@@ -1,4 +0,0 @@
1
- /**
2
- * tjs check - Parse and type check a TJS file
3
- */
4
- export declare function check(file: string): Promise<void>;
@@ -1,20 +0,0 @@
1
- /**
2
- * tjs convert - Convert TypeScript files to JavaScript (via TJS)
3
- *
4
- * By default, converts TS → JS with runtime type checks and introspection.
5
- * Use --emit-tjs to output the intermediate TJS format instead.
6
- *
7
- * Usage:
8
- * tjs convert <file.ts> Convert single file, output to stdout
9
- * tjs convert <file.ts> -o <out.js> Convert single file to output file
10
- * tjs convert <dir> -o <outdir> Convert all .ts files in directory
11
- * tjs convert --emit-tjs <file.ts> Output intermediate TJS instead of JS
12
- */
13
- export interface ConvertOptions {
14
- output?: string;
15
- recursive?: boolean;
16
- verbose?: boolean;
17
- /** Output intermediate TJS instead of final JS */
18
- emitTJS?: boolean;
19
- }
20
- export declare function convert(input: string, options?: ConvertOptions): Promise<void>;
@@ -1,34 +0,0 @@
1
- /**
2
- * tjs emit - Output transpiled JavaScript
3
- *
4
- * Usage:
5
- * tjs emit <file.tjs> Emit single file to stdout
6
- * tjs emit <file.tjs> -o <out.js> Emit single file to output
7
- * tjs emit <dir> -o <outdir> Emit all .tjs files in directory
8
- * tjs emit --unsafe <file.tjs> Emit without __tjs metadata (production)
9
- * tjs emit --dts <file.tjs> Also generate .d.ts declaration file
10
- * tjs emit --no-docs <file.tjs> Suppress documentation generation
11
- * tjs emit --docs-dir <dir> Output docs to separate directory
12
- * tjs emit --jfdi <file.tjs> Emit even if tests fail (just fucking do it)
13
- */
14
- export interface EmitOptions {
15
- /** Include source locations in __tjs metadata */
16
- debug?: boolean;
17
- /** Output path (file or directory) */
18
- output?: string;
19
- /** Strip __tjs metadata for production builds */
20
- unsafe?: boolean;
21
- /** Recursive directory processing */
22
- recursive?: boolean;
23
- /** Verbose output */
24
- verbose?: boolean;
25
- /** Suppress documentation generation */
26
- noDocs?: boolean;
27
- /** Output docs to separate directory (default: alongside JS) */
28
- docsDir?: string;
29
- /** Emit even if tests fail (just fucking do it) */
30
- jfdi?: boolean;
31
- /** Generate .d.ts TypeScript declaration file alongside JS */
32
- dts?: boolean;
33
- }
34
- export declare function emit(input: string, options?: EmitOptions): Promise<void>;
@@ -1,6 +0,0 @@
1
- /**
2
- * tjs run - Transpile and execute a TJS file
3
- *
4
- * Executes the entire file as a script, with full TJS runtime support.
5
- */
6
- export declare function run(file: string): Promise<void>;
@@ -1,21 +0,0 @@
1
- /**
2
- * tjs test - Run TJS test files
3
- *
4
- * Usage:
5
- * tjs test Run all .test.tjs files
6
- * tjs test <file> Run specific test file
7
- * tjs test <dir> Run all .test.tjs files in directory
8
- * tjs test -t <pattern> Run tests matching pattern
9
- *
10
- * This command wraps `bun test` with the TJS plugin preloaded,
11
- * and generates temporary wrapper files for .test.tjs files since
12
- * Bun's test runner only recognizes standard extensions.
13
- */
14
- export interface TestOptions {
15
- pattern?: string;
16
- timeout?: number;
17
- watch?: boolean;
18
- coverage?: boolean;
19
- bail?: number;
20
- }
21
- export declare function test(input?: string, options?: TestOptions): Promise<void>;
@@ -1,4 +0,0 @@
1
- /**
2
- * tjs types - Output type metadata as JSON
3
- */
4
- export declare function types(file: string): Promise<void>;
@@ -1,9 +0,0 @@
1
- #!/usr/bin/env bun
2
- /**
3
- * create-tjs-app - Scaffold a new TJS project
4
- *
5
- * Usage:
6
- * bun create tjs-app my-app
7
- * bunx create-tjs-app my-app
8
- */
9
- export {};
@@ -1,9 +0,0 @@
1
- #!/usr/bin/env bun
2
- /**
3
- * tjs-playground - Serve the TJS playground locally
4
- *
5
- * Usage:
6
- * tjs-playground [--port 8699]
7
- * bunx tjs-playground
8
- */
9
- export {};
@@ -1,15 +0,0 @@
1
- #!/usr/bin/env bun
2
- /**
3
- * TJS CLI - Command line interface for Typed JavaScript
4
- *
5
- * Commands:
6
- * tjs check <file> - Parse and type check, report errors
7
- * tjs run <file> - Transpile to JS and execute
8
- * tjs types <file> - Output type metadata as JSON
9
- * tjs emit <file> - Output transpiled JavaScript
10
- *
11
- * Options:
12
- * --help, -h - Show help
13
- * --version, -v - Show version
14
- */
15
- export {};
@@ -1,16 +0,0 @@
1
- #!/usr/bin/env bun
2
- /**
3
- * tjsx - Execute TJS files instantly
4
- *
5
- * Like `bun run` but for TJS files. Transpiles and executes in one step.
6
- *
7
- * Usage:
8
- * tjsx script.tjs [args...]
9
- * tjsx --help
10
- *
11
- * Examples:
12
- * tjsx hello.tjs
13
- * tjsx server.tjs --port 3000
14
- * echo '{"name": "World"}' | tjsx greet.tjs
15
- */
16
- export {};
@@ -1,11 +0,0 @@
1
- export * from './lang';
2
- export * from './vm/runtime';
3
- export * from './vm/vm';
4
- export * from './vm/atoms';
5
- export * from './builder';
6
- export * from './batteries';
7
- export * from './types';
8
- export * from './transpiler';
9
- export * from './runtime';
10
- export * from './vm';
11
- export * from './atoms';
@@ -1 +0,0 @@
1
- export {};
@@ -1,56 +0,0 @@
1
- /**
2
- * TJS Core - Essential transpiler functions without TypeScript dependency
3
- *
4
- * This module provides the core AJS transpilation functions.
5
- * Import from here (not ./index) to avoid pulling in the TS compiler.
6
- */
7
- import type { SeqNode } from '../builder';
8
- import type { TranspileOptions, TranspileResult, FunctionSignature } from './types';
9
- import { type TJSTranspileResult, type TJSTranspileOptions } from './emitters/js';
10
- export * from './types';
11
- export { parse, preprocess, extractTDoc, validateSingleFunction, } from './parser';
12
- export { transformFunction } from './emitters/ast';
13
- /**
14
- * Transpile JavaScript source code to Agent99 AST
15
- */
16
- export declare function transpile(source: string, options?: TranspileOptions): TranspileResult;
17
- /**
18
- * Transpile AsyncJS source and return just the AST
19
- */
20
- export declare function ajs(strings: TemplateStringsArray, ...values: any[]): SeqNode;
21
- export declare function ajs(source: string): SeqNode;
22
- /**
23
- * Create a function with attached signature for introspection
24
- */
25
- export declare function createAgent(source: string, vm: {
26
- run: (ast: any, args: any, options?: any) => Promise<any>;
27
- }, runOptions?: {
28
- fuel?: number;
29
- capabilities?: any;
30
- }): ((args: Record<string, any>) => Promise<any>) & {
31
- signature: FunctionSignature;
32
- ast: SeqNode;
33
- };
34
- /**
35
- * Get tool definitions from a set of agent functions
36
- */
37
- export declare function getToolDefinitions(agents: Record<string, {
38
- signature: FunctionSignature;
39
- }>): Array<{
40
- type: 'function';
41
- function: {
42
- name: string;
43
- description?: string;
44
- parameters: {
45
- type: 'object';
46
- properties: Record<string, any>;
47
- required: string[];
48
- };
49
- };
50
- }>;
51
- /**
52
- * Transpile TJS source to JavaScript with type metadata.
53
- * Works as both a function and a tagged template literal.
54
- */
55
- export declare function tjs(strings: TemplateStringsArray, ...values: any[]): TJSTranspileResult;
56
- export declare function tjs(source: string, options?: TJSTranspileOptions): TJSTranspileResult;
@@ -1,69 +0,0 @@
1
- /**
2
- * TJS Documentation Generator
3
- *
4
- * Dead simple: walk source in order, emit what you find.
5
- * - Doc blocks render as markdown
6
- * - Function signatures render as code blocks
7
- *
8
- * No magic pairing. No attachment logic. The signature IS the docs.
9
- * Doc blocks are just editorial commentary when you need it.
10
- */
11
- export interface DocResult {
12
- /** Items in document order */
13
- items: DocItem[];
14
- /** Rendered markdown */
15
- markdown: string;
16
- }
17
- export type DocItem = {
18
- type: 'doc';
19
- content: string;
20
- } | {
21
- type: 'function';
22
- name: string;
23
- signature: string;
24
- };
25
- /**
26
- * Generate documentation from TJS source
27
- *
28
- * Walk source in document order. Emit doc blocks and function signatures.
29
- * Only extracts top-level doc blocks (outside function bodies).
30
- */
31
- export declare function generateDocs(source: string): DocResult;
32
- /**
33
- * Type metadata for a function parameter
34
- */
35
- export interface ParamTypeInfo {
36
- type?: {
37
- kind: string;
38
- };
39
- required?: boolean;
40
- example?: any;
41
- }
42
- /**
43
- * Type metadata for a function
44
- */
45
- export interface FunctionTypeInfo {
46
- params?: Record<string, ParamTypeInfo>;
47
- returns?: {
48
- kind: string;
49
- };
50
- }
51
- /**
52
- * Generate markdown documentation with type metadata
53
- *
54
- * Combines source-level doc blocks with runtime type information.
55
- * Shows everything in document order:
56
- * - /*# ... *\/ comments render as markdown
57
- * - Functions render with signature and detailed type info
58
- *
59
- * @param source - TJS or TypeScript source code
60
- * @param types - Type metadata from transpiler (result.types)
61
- * @returns Formatted markdown documentation
62
- *
63
- * @example
64
- * ```typescript
65
- * const result = tjs(source)
66
- * const docs = generateDocsMarkdown(source, result.types)
67
- * ```
68
- */
69
- export declare function generateDocsMarkdown(source: string, types?: Record<string, FunctionTypeInfo>): string;
@@ -1,24 +0,0 @@
1
- /**
2
- * ESTree to Agent99 AST Transformer
3
- *
4
- * Converts parsed JavaScript into Agent99's JSON AST format.
5
- */
6
- import type { Statement, FunctionDeclaration, BlockStatement } from 'acorn';
7
- import type { BaseNode } from '../../builder';
8
- import type { TransformContext, TranspileOptions, FunctionSignature, TranspileWarning } from '../types';
9
- /**
10
- * Transform a function declaration into Agent99 AST
11
- */
12
- export declare function transformFunction(func: FunctionDeclaration, source: string, returnTypeAnnotation: string | undefined, options?: TranspileOptions, requiredParamsFromPreprocess?: Set<string>): {
13
- ast: BaseNode;
14
- signature: FunctionSignature;
15
- warnings: TranspileWarning[];
16
- };
17
- /**
18
- * Transform a block statement into a list of steps
19
- */
20
- export declare function transformBlock(block: BlockStatement, ctx: TransformContext): BaseNode[];
21
- /**
22
- * Transform a statement
23
- */
24
- export declare function transformStatement(stmt: Statement, ctx: TransformContext): BaseNode | BaseNode[] | null;
@@ -1,48 +0,0 @@
1
- /**
2
- * TJS to .d.ts Emitter
3
- *
4
- * Generates TypeScript declaration files from TJS transpilation results.
5
- * Allows TypeScript consumers to use TJS-authored libraries with full
6
- * type information for functions, and helpful `any`-based stubs for
7
- * classes, generics, and predicate types.
8
- *
9
- * Design principle: emit enough structure for autocomplete/tooltips
10
- * (parameter names, object shapes) but lean on `any` where TJS types
11
- * can't be faithfully expressed in TS (predicate types, generics,
12
- * class instances). This gives developers IDE hints without false
13
- * lint errors from types that don't fully match.
14
- *
15
- * Handles:
16
- * - Exported functions → full param/return types from TJSTypeInfo
17
- * - Exported classes → callable function stub with constructor params, returns any
18
- * - Exported Type declarations → type guard function stubs
19
- * - Exported Generic declarations → factory function stubs
20
- * - Re-exports via `export { Name }` syntax
21
- */
22
- import type { TypeDescriptor } from '../types';
23
- import type { TJSTranspileResult } from './js';
24
- /**
25
- * Convert a TypeDescriptor to a TypeScript type string.
26
- *
27
- * Maps TJS's example-inferred types to the closest TS equivalents:
28
- * integer / non-negative-integer → number (TS has no integer type)
29
- * string / number / boolean / null / undefined / any → themselves
30
- * array + items → T[]
31
- * object + shape → { key: Type; ... }
32
- * union + members → T1 | T2
33
- * nullable → T | null
34
- */
35
- export declare function typeDescriptorToTS(td: TypeDescriptor): string;
36
- export interface GenerateDTSOptions {
37
- /** Module name for ambient declarations (omit for module-mode .d.ts) */
38
- moduleName?: string;
39
- }
40
- /**
41
- * Generate a .d.ts string from TJS transpilation output.
42
- *
43
- * @param result - The TJSTranspileResult from tjs()
44
- * @param source - The original TJS source (needed to detect exports)
45
- * @param options - Generation options
46
- * @returns The .d.ts file content as a string
47
- */
48
- export declare function generateDTS(result: TJSTranspileResult, source: string, options?: GenerateDTSOptions): string;