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.
- package/.github/pull_request_template.md +9 -0
- package/.github/workflows/ci.yml +18 -0
- package/.vscode/launch.json +19 -0
- package/.vscode/tasks.json +14 -0
- package/CHANGELOG.md +16 -0
- package/CONTRIBUTING.md +23 -0
- package/CargoX.lock +2 -0
- package/LICENSE +21 -0
- package/README.md +164 -0
- package/api-demo/CargoX.lock +1 -0
- package/api-demo/README.md +3 -0
- package/api-demo/benchmarks/arith.cbx +6 -0
- package/api-demo/cobolx.toml +6 -0
- package/api-demo/docs-output/index.html +1 -0
- package/api-demo/generated/LEGACYDEMO.cbx +5 -0
- package/api-demo/generated/client-types.ts +2 -0
- package/api-demo/generated/deploy.json +12 -0
- package/api-demo/generated/flowchart.mmd +4 -0
- package/api-demo/migrations/20260411215238_init.sql +1 -0
- package/api-demo/src/main.cbx +5 -0
- package/api-demo/tests/smoke.cbx +6 -0
- package/benchmarks/arithmetic.cbx +6 -0
- package/cargox/package.json +11 -0
- package/cargox/src/index.d.ts +4 -0
- package/cargox/src/index.js +5 -0
- package/cargox/src/index.js.map +1 -0
- package/cargox/src/index.ts +4 -0
- package/cargox/src/lockfile/index.d.ts +1 -0
- package/cargox/src/lockfile/index.js +9 -0
- package/cargox/src/lockfile/index.js.map +1 -0
- package/cargox/src/lockfile/index.ts +9 -0
- package/cargox/src/manifest.d.ts +10 -0
- package/cargox/src/manifest.js +49 -0
- package/cargox/src/manifest.js.map +1 -0
- package/cargox/src/manifest.ts +58 -0
- package/cargox/src/registry/index.d.ts +4 -0
- package/cargox/src/registry/index.js +13 -0
- package/cargox/src/registry/index.js.map +1 -0
- package/cargox/src/registry/index.ts +13 -0
- package/cargox/src/resolver/index.d.ts +5 -0
- package/cargox/src/resolver/index.js +4 -0
- package/cargox/src/resolver/index.js.map +1 -0
- package/cargox/src/resolver/index.ts +8 -0
- package/cargox/tsconfig.json +7 -0
- package/cli/cobolx-cli/package.json +23 -0
- package/cli/cobolx-cli/src/commands/add.ts +18 -0
- package/cli/cobolx-cli/src/commands/bench.ts +47 -0
- package/cli/cobolx-cli/src/commands/build.ts +74 -0
- package/cli/cobolx-cli/src/commands/check.ts +24 -0
- package/cli/cobolx-cli/src/commands/debug.ts +15 -0
- package/cli/cobolx-cli/src/commands/debug_rewind.ts +16 -0
- package/cli/cobolx-cli/src/commands/deploy.ts +18 -0
- package/cli/cobolx-cli/src/commands/dev.ts +24 -0
- package/cli/cobolx-cli/src/commands/doc.ts +19 -0
- package/cli/cobolx-cli/src/commands/fmt.ts +14 -0
- package/cli/cobolx-cli/src/commands/fuzz.ts +24 -0
- package/cli/cobolx-cli/src/commands/generate.ts +38 -0
- package/cli/cobolx-cli/src/commands/install.ts +25 -0
- package/cli/cobolx-cli/src/commands/legacy.ts +17 -0
- package/cli/cobolx-cli/src/commands/lint.ts +17 -0
- package/cli/cobolx-cli/src/commands/migrate.ts +27 -0
- package/cli/cobolx-cli/src/commands/new.ts +20 -0
- package/cli/cobolx-cli/src/commands/profile.ts +8 -0
- package/cli/cobolx-cli/src/commands/publish.ts +16 -0
- package/cli/cobolx-cli/src/commands/repl.ts +30 -0
- package/cli/cobolx-cli/src/commands/run.ts +22 -0
- package/cli/cobolx-cli/src/commands/task.ts +27 -0
- package/cli/cobolx-cli/src/commands/test.ts +44 -0
- package/cli/cobolx-cli/src/commands/update.ts +30 -0
- package/cli/cobolx-cli/src/commands/visualize.ts +25 -0
- package/cli/cobolx-cli/src/index.ts +101 -0
- package/cli/cobolx-cli/src/project.ts +74 -0
- package/cli/cobolx-cli/tsconfig.json +7 -0
- package/cobolx.toml +7 -0
- package/compiler/package.json +14 -0
- package/compiler/src/ast/types.d.ts +87 -0
- package/compiler/src/ast/types.js +2 -0
- package/compiler/src/ast/types.js.map +1 -0
- package/compiler/src/ast/types.ts +329 -0
- package/compiler/src/backend/custom.d.ts +8 -0
- package/compiler/src/backend/custom.js +12 -0
- package/compiler/src/backend/custom.js.map +1 -0
- package/compiler/src/backend/custom.ts +21 -0
- package/compiler/src/borrow_checker/checker.d.ts +3 -0
- package/compiler/src/borrow_checker/checker.js +82 -0
- package/compiler/src/borrow_checker/checker.js.map +1 -0
- package/compiler/src/borrow_checker/checker.ts +100 -0
- package/compiler/src/codegen/javascript.d.ts +2 -0
- package/compiler/src/codegen/javascript.js +89 -0
- package/compiler/src/codegen/javascript.js.map +1 -0
- package/compiler/src/codegen/javascript.ts +175 -0
- package/compiler/src/const_eval/evaluator.ts +58 -0
- package/compiler/src/diagnostics.d.ts +11 -0
- package/compiler/src/diagnostics.js +14 -0
- package/compiler/src/diagnostics.js.map +1 -0
- package/compiler/src/diagnostics.ts +20 -0
- package/compiler/src/hir/lower.d.ts +7 -0
- package/compiler/src/hir/lower.js +44 -0
- package/compiler/src/hir/lower.js.map +1 -0
- package/compiler/src/hir/lower.ts +60 -0
- package/compiler/src/hir/types.d.ts +21 -0
- package/compiler/src/hir/types.js +2 -0
- package/compiler/src/hir/types.js.map +1 -0
- package/compiler/src/hir/types.ts +26 -0
- package/compiler/src/index.d.ts +22 -0
- package/compiler/src/index.js +84 -0
- package/compiler/src/index.js.map +1 -0
- package/compiler/src/index.ts +122 -0
- package/compiler/src/lexer/lexer.d.ts +21 -0
- package/compiler/src/lexer/lexer.js +207 -0
- package/compiler/src/lexer/lexer.js.map +1 -0
- package/compiler/src/lexer/lexer.ts +274 -0
- package/compiler/src/lexer/tokens.d.ts +8 -0
- package/compiler/src/lexer/tokens.js +18 -0
- package/compiler/src/lexer/tokens.js.map +1 -0
- package/compiler/src/lexer/tokens.ts +126 -0
- package/compiler/src/macros/expand.ts +75 -0
- package/compiler/src/main.ts +4 -0
- package/compiler/src/mir/lower.d.ts +3 -0
- package/compiler/src/mir/lower.js +10 -0
- package/compiler/src/mir/lower.js.map +1 -0
- package/compiler/src/mir/lower.ts +12 -0
- package/compiler/src/mir/types.d.ts +13 -0
- package/compiler/src/mir/types.js +2 -0
- package/compiler/src/mir/types.js.map +1 -0
- package/compiler/src/mir/types.ts +16 -0
- package/compiler/src/optimizer/constantFold.d.ts +2 -0
- package/compiler/src/optimizer/constantFold.js +61 -0
- package/compiler/src/optimizer/constantFold.js.map +1 -0
- package/compiler/src/optimizer/constantFold.ts +109 -0
- package/compiler/src/parser/parser.d.ts +33 -0
- package/compiler/src/parser/parser.js +323 -0
- package/compiler/src/parser/parser.js.map +1 -0
- package/compiler/src/parser/parser.ts +710 -0
- package/compiler/src/plugins/api.ts +8 -0
- package/compiler/src/plugins/loader.ts +21 -0
- package/compiler/src/semantic/analyzer.d.ts +12 -0
- package/compiler/src/semantic/analyzer.js +144 -0
- package/compiler/src/semantic/analyzer.js.map +1 -0
- package/compiler/src/semantic/analyzer.ts +277 -0
- package/compiler/src/type_system/checker.d.ts +7 -0
- package/compiler/src/type_system/checker.js +84 -0
- package/compiler/src/type_system/checker.js.map +1 -0
- package/compiler/src/type_system/checker.ts +108 -0
- package/compiler/tsconfig.json +7 -0
- package/debugger/package.json +11 -0
- package/debugger/src/index.d.ts +1 -0
- package/debugger/src/index.js +9 -0
- package/debugger/src/index.js.map +1 -0
- package/debugger/src/index.ts +9 -0
- package/debugger/tsconfig.json +7 -0
- package/docs/CHANGELOG.md +11 -0
- package/docs/CONTRIBUTING.md +15 -0
- package/docs/LICENSE +21 -0
- package/docs/architecture.md +29 -0
- package/docs/cli.md +58 -0
- package/docs/language-spec.md +49 -0
- package/docs/packages.md +19 -0
- package/docs/platform-systems.md +31 -0
- package/docs/release-validation.md +22 -0
- package/docs/runtime.md +10 -0
- package/docs/tooling.md +17 -0
- package/docs/vscode-extension.md +40 -0
- package/enterprise-demo/CargoX.lock +2 -0
- package/enterprise-demo/README.md +3 -0
- package/enterprise-demo/benchmarks/arith.cbx +6 -0
- package/enterprise-demo/cobolx.toml +7 -0
- package/enterprise-demo/src/main.cbx +5 -0
- package/enterprise-demo/tests/smoke.cbx +6 -0
- package/examples/README.md +20 -0
- package/examples/actors-and-flags.md +8 -0
- package/examples/api-server/README.md +9 -0
- package/examples/api-server/cobolx.toml +6 -0
- package/examples/api-server/src/main.cbx +8 -0
- package/examples/debug-replay.md +7 -0
- package/examples/debugging-demo/README.md +3 -0
- package/examples/debugging-demo/cobolx.toml +6 -0
- package/examples/debugging-demo/src/main.cbx +7 -0
- package/examples/distributed-service.md +12 -0
- package/examples/distributed-system/README.md +3 -0
- package/examples/distributed-system/cobolx.toml +6 -0
- package/examples/distributed-system/generated/deploy.json +12 -0
- package/examples/distributed-system/src/main.cbx +6 -0
- package/examples/event-driven.md +5 -0
- package/examples/event-system/README.md +3 -0
- package/examples/event-system/cobolx.toml +6 -0
- package/examples/event-system/src/main.cbx +11 -0
- package/examples/functions.cbx +10 -0
- package/examples/functions.mjs +12 -0
- package/examples/hello.cbx +5 -0
- package/examples/hello.mjs +7 -0
- package/examples/legacy-sample.cob +5 -0
- package/examples/parallel-processing/README.md +3 -0
- package/examples/parallel-processing/cobolx.toml +6 -0
- package/examples/parallel-processing/src/main.cbx +6 -0
- package/examples/parallel-processing.md +8 -0
- package/examples/platform-features.cbx +32 -0
- package/examples/platform-features.mjs +35 -0
- package/examples/service.cbx +10 -0
- package/examples/workflow-engine/README.md +3 -0
- package/examples/workflow-engine/cobolx.toml +6 -0
- package/examples/workflow-engine/generated/flowchart.mmd +8 -0
- package/examples/workflow-engine/src/main.cbx +13 -0
- package/examples/workflow-engine.md +5 -0
- package/formatter/package.json +14 -0
- package/formatter/src/index.d.ts +1 -0
- package/formatter/src/index.js +59 -0
- package/formatter/src/index.js.map +1 -0
- package/formatter/src/index.ts +103 -0
- package/formatter/tsconfig.json +7 -0
- package/generated/LEGACYDEMO.cbx +5 -0
- package/install.ps1 +4 -0
- package/install.sh +5 -0
- package/linter/package.json +14 -0
- package/linter/src/index.d.ts +2 -0
- package/linter/src/index.js +18 -0
- package/linter/src/index.js.map +1 -0
- package/linter/src/index.ts +19 -0
- package/linter/tsconfig.json +7 -0
- package/lsp/server/package.json +16 -0
- package/lsp/server/src/index.ts +168 -0
- package/lsp/server/tsconfig.json +7 -0
- package/package.json +30 -0
- package/profiler/package.json +11 -0
- package/profiler/src/index.d.ts +5 -0
- package/profiler/src/index.js +11 -0
- package/profiler/src/index.js.map +1 -0
- package/profiler/src/index.ts +11 -0
- package/profiler/tsconfig.json +7 -0
- package/release.json +10 -0
- package/runtime/package.json +14 -0
- package/runtime/src/actors/index.ts +27 -0
- package/runtime/src/async/futures.ts +11 -0
- package/runtime/src/code_as_data/index.ts +5 -0
- package/runtime/src/config/index.ts +17 -0
- package/runtime/src/distributed/index.ts +13 -0
- package/runtime/src/events/index.ts +21 -0
- package/runtime/src/feature_flags/index.ts +9 -0
- package/runtime/src/gc_or_arc/index.ts +1 -0
- package/runtime/src/healing/index.ts +26 -0
- package/runtime/src/index.ts +20 -0
- package/runtime/src/intents/index.ts +9 -0
- package/runtime/src/iterators/index.ts +23 -0
- package/runtime/src/memory/arc.ts +22 -0
- package/runtime/src/observability/index.ts +23 -0
- package/runtime/src/repl/context.ts +7 -0
- package/runtime/src/scheduler/taskScheduler.ts +11 -0
- package/runtime/src/security/capabilities.ts +15 -0
- package/runtime/src/security/secrets.ts +13 -0
- package/runtime/src/state/versioned.ts +31 -0
- package/runtime/src/std_hooks/audit.ts +23 -0
- package/runtime/src/time_travel/index.ts +54 -0
- package/runtime/src/workflows/index.ts +35 -0
- package/runtime/tsconfig.json +7 -0
- package/sample-payroll/README.md +3 -0
- package/sample-payroll/cobolx.toml +3 -0
- package/sample-payroll/src/main.cbx +5 -0
- package/stdlib/business/index.js +15 -0
- package/stdlib/core/README.md +8 -0
- package/stdlib/core/runtime.js +191 -0
- package/stdlib/crypto/index.js +5 -0
- package/stdlib/datetime/index.js +3 -0
- package/stdlib/fs/index.js +9 -0
- package/stdlib/http/index.js +7 -0
- package/stdlib/io/index.js +1 -0
- package/stdlib/json/index.js +7 -0
- package/stdlib/net/index.js +4 -0
- package/tests/macros.cbx +10 -0
- package/tests/pattern_match.cbx +16 -0
- package/tests/smoke.cbx +7 -0
- package/tests/validate-release.mjs +54 -0
- package/tsconfig.base.json +24 -0
- package/vscode-extension/LICENSE +21 -0
- package/vscode-extension/README.md +47 -0
- package/vscode-extension/cobolx-1.2.0.vsix +0 -0
- package/vscode-extension/icon.png +0 -0
- package/vscode-extension/icon.svg +15 -0
- package/vscode-extension/language-configuration.json +17 -0
- package/vscode-extension/package.json +148 -0
- package/vscode-extension/snippets/cobolx.code-snippets +49 -0
- package/vscode-extension/src/extension.ts +283 -0
- package/vscode-extension/syntaxes/cobolx.tmLanguage.json +75 -0
- package/vscode-extension/tests/test.cbl +3 -0
- 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,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 @@
|
|
|
1
|
+
export { display, input } from "../core/runtime.js";
|
package/tests/macros.cbx
ADDED
package/tests/smoke.cbx
ADDED
|
@@ -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
|
|
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
|
+
}
|