cobolx-2 1.2.3

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 (284) hide show
  1. package/.github/pull_request_template.md +9 -0
  2. package/.github/workflows/ci.yml +18 -0
  3. package/.vscode/launch.json +19 -0
  4. package/.vscode/tasks.json +14 -0
  5. package/CHANGELOG.md +16 -0
  6. package/CONTRIBUTING.md +23 -0
  7. package/CargoX.lock +2 -0
  8. package/LICENSE +21 -0
  9. package/README.md +164 -0
  10. package/api-demo/CargoX.lock +1 -0
  11. package/api-demo/README.md +3 -0
  12. package/api-demo/benchmarks/arith.cbx +6 -0
  13. package/api-demo/cobolx.toml +6 -0
  14. package/api-demo/docs-output/index.html +1 -0
  15. package/api-demo/generated/LEGACYDEMO.cbx +5 -0
  16. package/api-demo/generated/client-types.ts +2 -0
  17. package/api-demo/generated/deploy.json +12 -0
  18. package/api-demo/generated/flowchart.mmd +4 -0
  19. package/api-demo/migrations/20260411215238_init.sql +1 -0
  20. package/api-demo/src/main.cbx +5 -0
  21. package/api-demo/tests/smoke.cbx +6 -0
  22. package/benchmarks/arithmetic.cbx +6 -0
  23. package/cargox/package.json +11 -0
  24. package/cargox/src/index.d.ts +4 -0
  25. package/cargox/src/index.js +5 -0
  26. package/cargox/src/index.js.map +1 -0
  27. package/cargox/src/index.ts +4 -0
  28. package/cargox/src/lockfile/index.d.ts +1 -0
  29. package/cargox/src/lockfile/index.js +9 -0
  30. package/cargox/src/lockfile/index.js.map +1 -0
  31. package/cargox/src/lockfile/index.ts +9 -0
  32. package/cargox/src/manifest.d.ts +10 -0
  33. package/cargox/src/manifest.js +49 -0
  34. package/cargox/src/manifest.js.map +1 -0
  35. package/cargox/src/manifest.ts +58 -0
  36. package/cargox/src/registry/index.d.ts +4 -0
  37. package/cargox/src/registry/index.js +13 -0
  38. package/cargox/src/registry/index.js.map +1 -0
  39. package/cargox/src/registry/index.ts +13 -0
  40. package/cargox/src/resolver/index.d.ts +5 -0
  41. package/cargox/src/resolver/index.js +4 -0
  42. package/cargox/src/resolver/index.js.map +1 -0
  43. package/cargox/src/resolver/index.ts +8 -0
  44. package/cargox/tsconfig.json +7 -0
  45. package/cli/cobolx-cli/package.json +23 -0
  46. package/cli/cobolx-cli/src/commands/add.ts +18 -0
  47. package/cli/cobolx-cli/src/commands/bench.ts +47 -0
  48. package/cli/cobolx-cli/src/commands/build.ts +74 -0
  49. package/cli/cobolx-cli/src/commands/check.ts +24 -0
  50. package/cli/cobolx-cli/src/commands/debug.ts +15 -0
  51. package/cli/cobolx-cli/src/commands/debug_rewind.ts +16 -0
  52. package/cli/cobolx-cli/src/commands/deploy.ts +18 -0
  53. package/cli/cobolx-cli/src/commands/dev.ts +24 -0
  54. package/cli/cobolx-cli/src/commands/doc.ts +19 -0
  55. package/cli/cobolx-cli/src/commands/fmt.ts +14 -0
  56. package/cli/cobolx-cli/src/commands/fuzz.ts +24 -0
  57. package/cli/cobolx-cli/src/commands/generate.ts +38 -0
  58. package/cli/cobolx-cli/src/commands/install.ts +25 -0
  59. package/cli/cobolx-cli/src/commands/legacy.ts +17 -0
  60. package/cli/cobolx-cli/src/commands/lint.ts +17 -0
  61. package/cli/cobolx-cli/src/commands/migrate.ts +27 -0
  62. package/cli/cobolx-cli/src/commands/new.ts +20 -0
  63. package/cli/cobolx-cli/src/commands/profile.ts +8 -0
  64. package/cli/cobolx-cli/src/commands/publish.ts +16 -0
  65. package/cli/cobolx-cli/src/commands/repl.ts +30 -0
  66. package/cli/cobolx-cli/src/commands/run.ts +22 -0
  67. package/cli/cobolx-cli/src/commands/task.ts +27 -0
  68. package/cli/cobolx-cli/src/commands/test.ts +44 -0
  69. package/cli/cobolx-cli/src/commands/update.ts +30 -0
  70. package/cli/cobolx-cli/src/commands/visualize.ts +25 -0
  71. package/cli/cobolx-cli/src/index.ts +101 -0
  72. package/cli/cobolx-cli/src/project.ts +74 -0
  73. package/cli/cobolx-cli/tsconfig.json +7 -0
  74. package/cobolx.toml +7 -0
  75. package/compiler/package.json +14 -0
  76. package/compiler/src/ast/types.d.ts +87 -0
  77. package/compiler/src/ast/types.js +2 -0
  78. package/compiler/src/ast/types.js.map +1 -0
  79. package/compiler/src/ast/types.ts +329 -0
  80. package/compiler/src/backend/custom.d.ts +8 -0
  81. package/compiler/src/backend/custom.js +12 -0
  82. package/compiler/src/backend/custom.js.map +1 -0
  83. package/compiler/src/backend/custom.ts +21 -0
  84. package/compiler/src/borrow_checker/checker.d.ts +3 -0
  85. package/compiler/src/borrow_checker/checker.js +82 -0
  86. package/compiler/src/borrow_checker/checker.js.map +1 -0
  87. package/compiler/src/borrow_checker/checker.ts +100 -0
  88. package/compiler/src/codegen/javascript.d.ts +2 -0
  89. package/compiler/src/codegen/javascript.js +89 -0
  90. package/compiler/src/codegen/javascript.js.map +1 -0
  91. package/compiler/src/codegen/javascript.ts +175 -0
  92. package/compiler/src/const_eval/evaluator.ts +58 -0
  93. package/compiler/src/diagnostics.d.ts +11 -0
  94. package/compiler/src/diagnostics.js +14 -0
  95. package/compiler/src/diagnostics.js.map +1 -0
  96. package/compiler/src/diagnostics.ts +20 -0
  97. package/compiler/src/hir/lower.d.ts +7 -0
  98. package/compiler/src/hir/lower.js +44 -0
  99. package/compiler/src/hir/lower.js.map +1 -0
  100. package/compiler/src/hir/lower.ts +60 -0
  101. package/compiler/src/hir/types.d.ts +21 -0
  102. package/compiler/src/hir/types.js +2 -0
  103. package/compiler/src/hir/types.js.map +1 -0
  104. package/compiler/src/hir/types.ts +26 -0
  105. package/compiler/src/index.d.ts +22 -0
  106. package/compiler/src/index.js +84 -0
  107. package/compiler/src/index.js.map +1 -0
  108. package/compiler/src/index.ts +122 -0
  109. package/compiler/src/lexer/lexer.d.ts +21 -0
  110. package/compiler/src/lexer/lexer.js +207 -0
  111. package/compiler/src/lexer/lexer.js.map +1 -0
  112. package/compiler/src/lexer/lexer.ts +274 -0
  113. package/compiler/src/lexer/tokens.d.ts +8 -0
  114. package/compiler/src/lexer/tokens.js +18 -0
  115. package/compiler/src/lexer/tokens.js.map +1 -0
  116. package/compiler/src/lexer/tokens.ts +126 -0
  117. package/compiler/src/macros/expand.ts +75 -0
  118. package/compiler/src/main.ts +4 -0
  119. package/compiler/src/mir/lower.d.ts +3 -0
  120. package/compiler/src/mir/lower.js +10 -0
  121. package/compiler/src/mir/lower.js.map +1 -0
  122. package/compiler/src/mir/lower.ts +12 -0
  123. package/compiler/src/mir/types.d.ts +13 -0
  124. package/compiler/src/mir/types.js +2 -0
  125. package/compiler/src/mir/types.js.map +1 -0
  126. package/compiler/src/mir/types.ts +16 -0
  127. package/compiler/src/optimizer/constantFold.d.ts +2 -0
  128. package/compiler/src/optimizer/constantFold.js +61 -0
  129. package/compiler/src/optimizer/constantFold.js.map +1 -0
  130. package/compiler/src/optimizer/constantFold.ts +109 -0
  131. package/compiler/src/parser/parser.d.ts +33 -0
  132. package/compiler/src/parser/parser.js +323 -0
  133. package/compiler/src/parser/parser.js.map +1 -0
  134. package/compiler/src/parser/parser.ts +710 -0
  135. package/compiler/src/plugins/api.ts +8 -0
  136. package/compiler/src/plugins/loader.ts +21 -0
  137. package/compiler/src/semantic/analyzer.d.ts +12 -0
  138. package/compiler/src/semantic/analyzer.js +144 -0
  139. package/compiler/src/semantic/analyzer.js.map +1 -0
  140. package/compiler/src/semantic/analyzer.ts +277 -0
  141. package/compiler/src/type_system/checker.d.ts +7 -0
  142. package/compiler/src/type_system/checker.js +84 -0
  143. package/compiler/src/type_system/checker.js.map +1 -0
  144. package/compiler/src/type_system/checker.ts +108 -0
  145. package/compiler/tsconfig.json +7 -0
  146. package/debugger/package.json +11 -0
  147. package/debugger/src/index.d.ts +1 -0
  148. package/debugger/src/index.js +9 -0
  149. package/debugger/src/index.js.map +1 -0
  150. package/debugger/src/index.ts +9 -0
  151. package/debugger/tsconfig.json +7 -0
  152. package/docs/CHANGELOG.md +11 -0
  153. package/docs/CONTRIBUTING.md +15 -0
  154. package/docs/LICENSE +21 -0
  155. package/docs/architecture.md +29 -0
  156. package/docs/cli.md +58 -0
  157. package/docs/language-spec.md +49 -0
  158. package/docs/packages.md +19 -0
  159. package/docs/platform-systems.md +31 -0
  160. package/docs/release-validation.md +22 -0
  161. package/docs/runtime.md +10 -0
  162. package/docs/tooling.md +17 -0
  163. package/docs/vscode-extension.md +40 -0
  164. package/enterprise-demo/CargoX.lock +2 -0
  165. package/enterprise-demo/README.md +3 -0
  166. package/enterprise-demo/benchmarks/arith.cbx +6 -0
  167. package/enterprise-demo/cobolx.toml +7 -0
  168. package/enterprise-demo/src/main.cbx +5 -0
  169. package/enterprise-demo/tests/smoke.cbx +6 -0
  170. package/examples/README.md +20 -0
  171. package/examples/actors-and-flags.md +8 -0
  172. package/examples/api-server/README.md +9 -0
  173. package/examples/api-server/cobolx.toml +6 -0
  174. package/examples/api-server/src/main.cbx +8 -0
  175. package/examples/debug-replay.md +7 -0
  176. package/examples/debugging-demo/README.md +3 -0
  177. package/examples/debugging-demo/cobolx.toml +6 -0
  178. package/examples/debugging-demo/src/main.cbx +7 -0
  179. package/examples/distributed-service.md +12 -0
  180. package/examples/distributed-system/README.md +3 -0
  181. package/examples/distributed-system/cobolx.toml +6 -0
  182. package/examples/distributed-system/generated/deploy.json +12 -0
  183. package/examples/distributed-system/src/main.cbx +6 -0
  184. package/examples/event-driven.md +5 -0
  185. package/examples/event-system/README.md +3 -0
  186. package/examples/event-system/cobolx.toml +6 -0
  187. package/examples/event-system/src/main.cbx +11 -0
  188. package/examples/functions.cbx +10 -0
  189. package/examples/functions.mjs +12 -0
  190. package/examples/hello.cbx +5 -0
  191. package/examples/hello.mjs +7 -0
  192. package/examples/legacy-sample.cob +5 -0
  193. package/examples/parallel-processing/README.md +3 -0
  194. package/examples/parallel-processing/cobolx.toml +6 -0
  195. package/examples/parallel-processing/src/main.cbx +6 -0
  196. package/examples/parallel-processing.md +8 -0
  197. package/examples/platform-features.cbx +32 -0
  198. package/examples/platform-features.mjs +35 -0
  199. package/examples/service.cbx +10 -0
  200. package/examples/workflow-engine/README.md +3 -0
  201. package/examples/workflow-engine/cobolx.toml +6 -0
  202. package/examples/workflow-engine/generated/flowchart.mmd +8 -0
  203. package/examples/workflow-engine/src/main.cbx +13 -0
  204. package/examples/workflow-engine.md +5 -0
  205. package/formatter/package.json +14 -0
  206. package/formatter/src/index.d.ts +1 -0
  207. package/formatter/src/index.js +59 -0
  208. package/formatter/src/index.js.map +1 -0
  209. package/formatter/src/index.ts +103 -0
  210. package/formatter/tsconfig.json +7 -0
  211. package/generated/LEGACYDEMO.cbx +5 -0
  212. package/install.ps1 +4 -0
  213. package/install.sh +5 -0
  214. package/linter/package.json +14 -0
  215. package/linter/src/index.d.ts +2 -0
  216. package/linter/src/index.js +18 -0
  217. package/linter/src/index.js.map +1 -0
  218. package/linter/src/index.ts +19 -0
  219. package/linter/tsconfig.json +7 -0
  220. package/lsp/server/package.json +16 -0
  221. package/lsp/server/src/index.ts +168 -0
  222. package/lsp/server/tsconfig.json +7 -0
  223. package/package.json +30 -0
  224. package/profiler/package.json +11 -0
  225. package/profiler/src/index.d.ts +5 -0
  226. package/profiler/src/index.js +11 -0
  227. package/profiler/src/index.js.map +1 -0
  228. package/profiler/src/index.ts +11 -0
  229. package/profiler/tsconfig.json +7 -0
  230. package/release.json +10 -0
  231. package/runtime/package.json +14 -0
  232. package/runtime/src/actors/index.ts +27 -0
  233. package/runtime/src/async/futures.ts +11 -0
  234. package/runtime/src/code_as_data/index.ts +5 -0
  235. package/runtime/src/config/index.ts +17 -0
  236. package/runtime/src/distributed/index.ts +13 -0
  237. package/runtime/src/events/index.ts +21 -0
  238. package/runtime/src/feature_flags/index.ts +9 -0
  239. package/runtime/src/gc_or_arc/index.ts +1 -0
  240. package/runtime/src/healing/index.ts +26 -0
  241. package/runtime/src/index.ts +20 -0
  242. package/runtime/src/intents/index.ts +9 -0
  243. package/runtime/src/iterators/index.ts +23 -0
  244. package/runtime/src/memory/arc.ts +22 -0
  245. package/runtime/src/observability/index.ts +23 -0
  246. package/runtime/src/repl/context.ts +7 -0
  247. package/runtime/src/scheduler/taskScheduler.ts +11 -0
  248. package/runtime/src/security/capabilities.ts +15 -0
  249. package/runtime/src/security/secrets.ts +13 -0
  250. package/runtime/src/state/versioned.ts +31 -0
  251. package/runtime/src/std_hooks/audit.ts +23 -0
  252. package/runtime/src/time_travel/index.ts +54 -0
  253. package/runtime/src/workflows/index.ts +35 -0
  254. package/runtime/tsconfig.json +7 -0
  255. package/sample-payroll/README.md +3 -0
  256. package/sample-payroll/cobolx.toml +3 -0
  257. package/sample-payroll/src/main.cbx +5 -0
  258. package/stdlib/business/index.js +15 -0
  259. package/stdlib/core/README.md +8 -0
  260. package/stdlib/core/runtime.js +191 -0
  261. package/stdlib/crypto/index.js +5 -0
  262. package/stdlib/datetime/index.js +3 -0
  263. package/stdlib/fs/index.js +9 -0
  264. package/stdlib/http/index.js +7 -0
  265. package/stdlib/io/index.js +1 -0
  266. package/stdlib/json/index.js +7 -0
  267. package/stdlib/net/index.js +4 -0
  268. package/tests/macros.cbx +10 -0
  269. package/tests/pattern_match.cbx +16 -0
  270. package/tests/smoke.cbx +7 -0
  271. package/tests/validate-release.mjs +54 -0
  272. package/tsconfig.base.json +24 -0
  273. package/vscode-extension/LICENSE +21 -0
  274. package/vscode-extension/README.md +47 -0
  275. package/vscode-extension/cobolx-1.2.0.vsix +0 -0
  276. package/vscode-extension/icon.png +0 -0
  277. package/vscode-extension/icon.svg +15 -0
  278. package/vscode-extension/language-configuration.json +17 -0
  279. package/vscode-extension/package.json +148 -0
  280. package/vscode-extension/snippets/cobolx.code-snippets +49 -0
  281. package/vscode-extension/src/extension.ts +283 -0
  282. package/vscode-extension/syntaxes/cobolx.tmLanguage.json +75 -0
  283. package/vscode-extension/tests/test.cbl +3 -0
  284. package/vscode-extension/tsconfig.json +7 -0
@@ -0,0 +1,54 @@
1
+ import fs from "node:fs";
2
+
3
+ export interface TimelineEntry {
4
+ step: number;
5
+ action: string;
6
+ state: Record<string, unknown>;
7
+ at: string;
8
+ }
9
+
10
+ export class TimeTravelDebugger {
11
+ private readonly timeline: TimelineEntry[] = [];
12
+ private state: Record<string, unknown> = {};
13
+ private step = 0;
14
+
15
+ constructor(private readonly traceFile?: string) {}
16
+
17
+ set(name: string, value: unknown): void {
18
+ this.state = { ...this.state, [name]: value };
19
+ this.record(`set:${name}`);
20
+ }
21
+
22
+ record(action: string): void {
23
+ this.timeline.push({
24
+ step: this.step,
25
+ action,
26
+ state: structuredClone(this.state),
27
+ at: new Date().toISOString()
28
+ });
29
+ this.step += 1;
30
+ this.flush();
31
+ }
32
+
33
+ snapshot(): TimelineEntry[] {
34
+ return [...this.timeline];
35
+ }
36
+
37
+ rewind(step: number): TimelineEntry | undefined {
38
+ return this.timeline.find((entry) => entry.step === step);
39
+ }
40
+
41
+ latest(): TimelineEntry | undefined {
42
+ return this.timeline.at(-1);
43
+ }
44
+
45
+ private flush(): void {
46
+ if (!this.traceFile) return;
47
+ fs.writeFileSync(this.traceFile, JSON.stringify(this.timeline, null, 2), "utf8");
48
+ }
49
+ }
50
+
51
+ export function loadTimeline(traceFile: string): TimelineEntry[] {
52
+ if (!fs.existsSync(traceFile)) return [];
53
+ return JSON.parse(fs.readFileSync(traceFile, "utf8")) as TimelineEntry[];
54
+ }
@@ -0,0 +1,35 @@
1
+ export interface WorkflowStepContext {
2
+ attempts: number;
3
+ }
4
+
5
+ export interface WorkflowStep {
6
+ name: string;
7
+ timeoutMs?: number;
8
+ retries?: number;
9
+ run: (context: WorkflowStepContext) => Promise<void> | void;
10
+ }
11
+
12
+ export class WorkflowEngine {
13
+ constructor(private readonly steps: WorkflowStep[]) {}
14
+
15
+ async execute(): Promise<void> {
16
+ for (const step of this.steps) {
17
+ let attempts = 0;
18
+ const retries = step.retries ?? 0;
19
+ while (true) {
20
+ attempts += 1;
21
+ try {
22
+ await Promise.race([
23
+ Promise.resolve(step.run({ attempts })),
24
+ new Promise((_, reject) =>
25
+ step.timeoutMs ? setTimeout(() => reject(new Error(`Workflow step '${step.name}' timed out`)), step.timeoutMs) : undefined
26
+ )
27
+ ]);
28
+ break;
29
+ } catch (error) {
30
+ if (attempts > retries + 1) throw error;
31
+ }
32
+ }
33
+ }
34
+ }
35
+ }
@@ -0,0 +1,7 @@
1
+ {
2
+ "extends": "../tsconfig.base.json",
3
+ "compilerOptions": {
4
+ "outDir": "dist"
5
+ },
6
+ "include": ["src/**/*.ts"]
7
+ }
@@ -0,0 +1,3 @@
1
+ # sample-payroll
2
+
3
+ Generated with COBOLX.
@@ -0,0 +1,3 @@
1
+ name = "sample-payroll"
2
+ version = "0.1.0"
3
+ entry = "src/main.cbx"
@@ -0,0 +1,5 @@
1
+ PROGRAM samplepayroll
2
+
3
+ BEGIN
4
+ DISPLAY "Hello from COBOLX"
5
+ END
@@ -0,0 +1,15 @@
1
+ import { audit } from "../../runtime/dist/index.js";
2
+
3
+ export function requireRole(activeRoles, requiredRole) {
4
+ const allowed = activeRoles.includes(requiredRole);
5
+ audit("security", "role-check", { requiredRole, allowed });
6
+ if (!allowed) {
7
+ throw new Error(`Missing required role: ${requiredRole}`);
8
+ }
9
+ }
10
+
11
+ export function evaluateRule(name, predicate) {
12
+ const outcome = Boolean(predicate());
13
+ audit("business-rule", name, { outcome });
14
+ return outcome;
15
+ }
@@ -0,0 +1,8 @@
1
+ # COBOLX Core Standard Library
2
+
3
+ Runtime helpers exposed to generated JavaScript:
4
+
5
+ - `display(value)`
6
+ - `input(promptText?)`
7
+ - `math.abs`, `math.floor`, `math.ceil`, `math.round`, `math.max`, `math.min`, `math.sqrt`, `math.pow`
8
+ - `strings.length`, `strings.upper`, `strings.lower`, `strings.concat`
@@ -0,0 +1,191 @@
1
+ import fs from "node:fs";
2
+
3
+ export function display(value) {
4
+ console.log(value);
5
+ }
6
+
7
+ export function input(promptText = "") {
8
+ if (promptText) {
9
+ process.stdout.write(String(promptText));
10
+ }
11
+ const buffer = fs.readFileSync(0, "utf8");
12
+ return buffer.toString().trimEnd();
13
+ }
14
+
15
+ export const math = {
16
+ abs: Math.abs,
17
+ floor: Math.floor,
18
+ ceil: Math.ceil,
19
+ round: Math.round,
20
+ max: Math.max,
21
+ min: Math.min,
22
+ sqrt: Math.sqrt,
23
+ pow: Math.pow
24
+ };
25
+
26
+ export const strings = {
27
+ length(value) {
28
+ return String(value).length;
29
+ },
30
+ upper(value) {
31
+ return String(value).toUpperCase();
32
+ },
33
+ lower(value) {
34
+ return String(value).toLowerCase();
35
+ },
36
+ concat(...values) {
37
+ return values.map((value) => String(value)).join("");
38
+ }
39
+ };
40
+
41
+ export const Result = {
42
+ ok(value) {
43
+ return { tag: "OK", values: [value] };
44
+ },
45
+ err(error) {
46
+ return { tag: "ERR", values: [error] };
47
+ }
48
+ };
49
+
50
+ export const Option = {
51
+ some(value) {
52
+ return { tag: "SOME", values: [value] };
53
+ },
54
+ none() {
55
+ return { tag: "NONE", values: [] };
56
+ }
57
+ };
58
+
59
+ export function iter(items) {
60
+ return {
61
+ items: [...items],
62
+ map(fn) {
63
+ return iter(this.items.map(fn));
64
+ },
65
+ filter(fn) {
66
+ return iter(this.items.filter(fn));
67
+ },
68
+ reduce(fn, initial) {
69
+ return this.items.reduce(fn, initial);
70
+ },
71
+ collect() {
72
+ return [...this.items];
73
+ }
74
+ };
75
+ }
76
+
77
+ export function spawn(task) {
78
+ return Promise.resolve().then(() => task());
79
+ }
80
+
81
+ export function channel() {
82
+ const queue = [];
83
+ return {
84
+ send(value) {
85
+ queue.push(value);
86
+ },
87
+ receive() {
88
+ return queue.shift();
89
+ }
90
+ };
91
+ }
92
+
93
+ export function createDebuggerContext(traceFile = process.env.COBOLX_DEBUG_TRACE_FILE) {
94
+ const timeline = [];
95
+ const state = {};
96
+ return {
97
+ set(name, value) {
98
+ state[name] = value;
99
+ this.record(`set:${name}`);
100
+ },
101
+ record(action) {
102
+ timeline.push({
103
+ step: timeline.length,
104
+ action,
105
+ state: structuredClone(state),
106
+ at: new Date().toISOString()
107
+ });
108
+ if (traceFile) {
109
+ fs.writeFileSync(traceFile, JSON.stringify(timeline, null, 2), "utf8");
110
+ }
111
+ },
112
+ timeline() {
113
+ return [...timeline];
114
+ }
115
+ };
116
+ }
117
+
118
+ export function createEventBus() {
119
+ const handlers = new Map();
120
+ return {
121
+ on(name, handler) {
122
+ handlers.set(name, [...(handlers.get(name) ?? []), handler]);
123
+ },
124
+ async emit(name, payload) {
125
+ for (const handler of handlers.get(name) ?? []) {
126
+ await handler(payload);
127
+ }
128
+ }
129
+ };
130
+ }
131
+
132
+ export function createWorkflow(steps) {
133
+ return {
134
+ async run() {
135
+ for (const step of steps) {
136
+ let attempts = 0;
137
+ const retries = step.retries ?? 0;
138
+ while (true) {
139
+ attempts += 1;
140
+ try {
141
+ await Promise.resolve(step.run({ attempts }));
142
+ break;
143
+ } catch (error) {
144
+ if (attempts > retries + 1) throw error;
145
+ }
146
+ }
147
+ }
148
+ }
149
+ };
150
+ }
151
+
152
+ export function createVersionedState(initial) {
153
+ const history = [];
154
+ let version = 0;
155
+ const push = (value) => {
156
+ history.push({ version, value: structuredClone(value), at: new Date().toISOString() });
157
+ version += 1;
158
+ };
159
+ push(initial);
160
+ return {
161
+ set(value) {
162
+ push(value);
163
+ },
164
+ current() {
165
+ return history[history.length - 1];
166
+ },
167
+ rollback(targetVersion) {
168
+ return history.find((item) => item.version === targetVersion);
169
+ },
170
+ timeline() {
171
+ return [...history];
172
+ }
173
+ };
174
+ }
175
+
176
+ export function createSupervisor(maxRetries = 3) {
177
+ return {
178
+ async run(name, task) {
179
+ let attempt = 0;
180
+ while (attempt <= maxRetries) {
181
+ try {
182
+ await Promise.resolve(task());
183
+ return;
184
+ } catch (error) {
185
+ attempt += 1;
186
+ if (attempt > maxRetries) throw new Error(`Supervisor failed ${name}: ${String(error)}`);
187
+ }
188
+ }
189
+ }
190
+ };
191
+ }
@@ -0,0 +1,5 @@
1
+ import crypto from "node:crypto";
2
+
3
+ export function sha256(value) {
4
+ return crypto.createHash("sha256").update(String(value)).digest("hex");
5
+ }
@@ -0,0 +1,3 @@
1
+ export function nowIso() {
2
+ return new Date().toISOString();
3
+ }
@@ -0,0 +1,9 @@
1
+ import fs from "node:fs";
2
+
3
+ export function readText(path) {
4
+ return fs.readFileSync(path, "utf8");
5
+ }
6
+
7
+ export function writeText(path, contents) {
8
+ fs.writeFileSync(path, contents, "utf8");
9
+ }
@@ -0,0 +1,7 @@
1
+ import http from "node:http";
2
+
3
+ export function createServer(port, handler) {
4
+ const server = http.createServer((req, res) => handler(req, res));
5
+ server.listen(port);
6
+ return server;
7
+ }
@@ -0,0 +1 @@
1
+ export { display, input } from "../core/runtime.js";
@@ -0,0 +1,7 @@
1
+ export function encode(value) {
2
+ return JSON.stringify(value);
3
+ }
4
+
5
+ export function decode(text) {
6
+ return JSON.parse(text);
7
+ }
@@ -0,0 +1,4 @@
1
+ export async function getJson(url) {
2
+ const response = await fetch(url);
3
+ return await response.json();
4
+ }
@@ -0,0 +1,10 @@
1
+ PROGRAM Macros
2
+
3
+ MACRO announce(value)
4
+ BEGIN
5
+ DISPLAY value
6
+ END-MACRO
7
+
8
+ BEGIN
9
+ announce!("macro works")
10
+ END
@@ -0,0 +1,16 @@
1
+ PROGRAM PatternMatch
2
+
3
+ ENUM Result:
4
+ OK(value)
5
+ ERR(message)
6
+ END
7
+
8
+ BEGIN
9
+ LET result = OK(7)
10
+ MATCH result:
11
+ OK(value):
12
+ DISPLAY value
13
+ ERR(problem):
14
+ DISPLAY problem
15
+ END-MATCH
16
+ END
@@ -0,0 +1,7 @@
1
+ PROGRAM Smoke
2
+
3
+ BEGIN
4
+ SET left = 10
5
+ SET right = 20
6
+ DISPLAY left + right
7
+ END
@@ -0,0 +1,54 @@
1
+ import { mkdtempSync, rmSync, existsSync, readFileSync } from "node:fs";
2
+ import { tmpdir } from "node:os";
3
+ import path from "node:path";
4
+ import { spawnSync } from "node:child_process";
5
+
6
+ const root = process.cwd();
7
+ const cli = path.join(root, "cli", "cobolx-cli", "dist", "index.js");
8
+ const tempRoot = mkdtempSync(path.join(tmpdir(), "cobolx-validate-"));
9
+
10
+ function run(command, args, cwd = root) {
11
+ const result = spawnSync(process.execPath, [cli, command, ...args], {
12
+ cwd,
13
+ encoding: "utf8",
14
+ stdio: "pipe"
15
+ });
16
+ if ((result.status ?? 1) !== 0) {
17
+ throw new Error(`Command failed: cobolx ${command} ${args.join(" ")}\n${result.stdout}\n${result.stderr}`);
18
+ }
19
+ return `${result.stdout}${result.stderr}`;
20
+ }
21
+
22
+ try {
23
+ run("build", []);
24
+ run("test", []);
25
+ run("bench", []);
26
+
27
+ const projectDir = path.join(tempRoot, "release-app");
28
+ run("new", [projectDir, "api"]);
29
+ run("add", ["ledger", "1.2.3"], projectDir);
30
+ run("install", [], projectDir);
31
+ run("update", [], projectDir);
32
+ run("check", [], projectDir);
33
+ run("build", ["--release"], projectDir);
34
+ run("run", [], projectDir);
35
+ run("doc", [], projectDir);
36
+ run("generate", ["api"], projectDir);
37
+ run("generate", ["client", "typescript"], projectDir);
38
+ run("migrate", ["create", "init"], projectDir);
39
+ run("migrate", ["run"], projectDir);
40
+ run("visualize", [], projectDir);
41
+ run("deploy", [], projectDir);
42
+ run("debug", ["--rewind"], projectDir);
43
+
44
+ if (!existsSync(path.join(projectDir, "dist", "main.mjs"))) throw new Error("Missing built main.mjs");
45
+ if (!existsSync(path.join(projectDir, "dist", "debug-timeline.json"))) throw new Error("Missing debug timeline");
46
+ if (!existsSync(path.join(projectDir, "docs-output", "index.html"))) throw new Error("Missing generated docs");
47
+ if (!existsSync(path.join(projectDir, "generated", "deploy.json"))) throw new Error("Missing deploy metadata");
48
+ const deploy = JSON.parse(readFileSync(path.join(projectDir, "generated", "deploy.json"), "utf8"));
49
+ if (!deploy.service) throw new Error("Deploy metadata missing service name");
50
+
51
+ console.log("Release validation completed successfully");
52
+ } finally {
53
+ rmSync(tempRoot, { recursive: true, force: true });
54
+ }
@@ -0,0 +1,24 @@
1
+ {
2
+ "compilerOptions": {
3
+ "baseUrl": ".",
4
+ "target": "ES2022",
5
+ "module": "NodeNext",
6
+ "moduleResolution": "NodeNext",
7
+ "lib": ["ES2022"],
8
+ "strict": true,
9
+ "esModuleInterop": true,
10
+ "forceConsistentCasingInFileNames": true,
11
+ "skipLibCheck": true,
12
+ "declaration": true,
13
+ "paths": {
14
+ "@cobolx/compiler": ["compiler/src/index.ts"],
15
+ "@cobolx/cargox": ["cargox/src/index.ts"],
16
+ "@cobolx/runtime": ["runtime/src/index.ts"],
17
+ "@cobolx/formatter": ["formatter/src/index.ts"],
18
+ "@cobolx/linter": ["linter/src/index.ts"],
19
+ "@cobolx/debugger": ["debugger/src/index.ts"],
20
+ "@cobolx/profiler": ["profiler/src/index.ts"]
21
+ },
22
+ "sourceMap": true
23
+ }
24
+ }
@@ -0,0 +1,21 @@
1
+ MIT License
2
+
3
+ Copyright (c) 2026 COBOL-X
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.
@@ -0,0 +1,47 @@
1
+ # COBOL-X VS Code Extension
2
+
3
+ COBOL-X language support for Visual Studio Code.
4
+
5
+ ## Features
6
+
7
+ - Language registration for `.cbx`, `.cob`, and `.col`
8
+ - Syntax highlighting for COBOL-X keywords, functions, types, strings, comments, and numbers
9
+ - LSP-backed diagnostics, hover information, and keyword completions
10
+ - Snippets for common program, function, enum, and match scaffolds
11
+ - Commands:
12
+ - `COBOL-X: Run File`
13
+ - `COBOL-X: Build Project`
14
+ - `COBOL-X: Open REPL`
15
+ - `COBOL-X: Debug Current Project`
16
+
17
+ ## Development
18
+
19
+ ```powershell
20
+ npm install
21
+ npm run build
22
+ ```
23
+
24
+ Open the repository in VS Code and launch the extension development host with `F5`.
25
+
26
+ Command execution uses the local repo CLI when the workspace contains the COBOL-X monorepo. In standalone projects, it falls back to a `cobolx` executable on your `PATH`.
27
+
28
+ ## Packaging
29
+
30
+ ```powershell
31
+ npm install -g vsce
32
+ cd vscode-extension
33
+ npx @vscode/vsce package
34
+ ```
35
+
36
+ Install the generated `.vsix` with:
37
+
38
+ ```powershell
39
+ code --install-extension cobolx-1.0.0.vsix
40
+ ```
41
+
42
+ ## Publishing
43
+
44
+ 1. Create a publisher in Azure DevOps.
45
+ 2. Generate a Personal Access Token with Marketplace permissions.
46
+ 3. Login with `vsce login Magnexis`
47
+ 4. Publish with `vsce publish`
Binary file
@@ -0,0 +1,15 @@
1
+ <svg xmlns="http://www.w3.org/2000/svg" viewBox="0 0 256 256" role="img" aria-labelledby="title desc">
2
+ <title>COBOL-X VS Code Extension Icon</title>
3
+ <desc>Rounded square logo with a C and X monogram over a blue-green gradient and a COBOL-X label.</desc>
4
+ <defs>
5
+ <linearGradient id="bg" x1="0%" y1="0%" x2="100%" y2="100%">
6
+ <stop offset="0%" stop-color="#0b3558"/>
7
+ <stop offset="100%" stop-color="#00a78b"/>
8
+ </linearGradient>
9
+ </defs>
10
+ <rect x="12" y="12" width="232" height="232" rx="52" fill="url(#bg)" stroke="rgba(255,255,255,0.45)" stroke-width="6"/>
11
+ <path d="M151 73c-14-14-38-17-57-7-20 10-33 31-33 54 0 24 13 45 33 55 19 10 43 7 57-7" fill="none" stroke="#fff0ad" stroke-width="18" stroke-linecap="round"/>
12
+ <path d="M136 73 208 183M208 73l-72 110" fill="none" stroke="#f5c14e" stroke-width="20" stroke-linecap="round"/>
13
+ <rect x="42" y="186" width="172" height="34" rx="17" fill="#071827" fill-opacity="0.88"/>
14
+ <text x="128" y="209" text-anchor="middle" font-family="Segoe UI, Arial, sans-serif" font-size="18" font-weight="700" fill="#ffffff">COBOL-X</text>
15
+ </svg>
@@ -0,0 +1,17 @@
1
+ {
2
+ "comments": {
3
+ "lineComment": "*>"
4
+ },
5
+ "brackets": [["(", ")"], ["[", "]"]],
6
+ "autoClosingPairs": [
7
+ ["(", ")"],
8
+ ["[", "]"],
9
+ ["\"", "\""]
10
+ ],
11
+ "surroundingPairs": [
12
+ ["(", ")"],
13
+ ["[", "]"],
14
+ ["\"", "\""]
15
+ ],
16
+ "wordPattern": "(-?\\d*\\.\\d\\w*)|([A-Za-z_][A-Za-z0-9_-]*)"
17
+ }