@innovatorved/code-lab 0.7.0 → 0.7.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 (129) hide show
  1. package/ARCHITECTURE.md +2 -2
  2. package/CHANGELOG.md +20 -0
  3. package/README.md +2 -2
  4. package/dist/apps/web/src/index.d.ts +0 -9
  5. package/dist/code-lab-sql.esm.js +19 -19
  6. package/dist/code-lab-sql.umd.js +20 -20
  7. package/dist/code-lab.css +1 -1
  8. package/dist/code-lab.d.ts +1 -1
  9. package/dist/code-lab.esm.js +679 -1439
  10. package/dist/code-lab.js +678 -1438
  11. package/dist/extensions/cpp.esm.js +132 -8760
  12. package/dist/extensions/cpp.js +124 -8770
  13. package/dist/extensions/guided-lab.esm.js +33 -6836
  14. package/dist/extensions/guided-lab.js +33 -6854
  15. package/dist/extensions/javascript.esm.js +1 -36
  16. package/dist/extensions/javascript.js +1 -58
  17. package/dist/extensions/python.esm.js +79 -8118
  18. package/dist/extensions/python.js +79 -8136
  19. package/dist/extensions/typescript.esm.js +1 -55
  20. package/dist/extensions/typescript.js +1 -77
  21. package/dist/modular-kernel.d.ts +0 -4
  22. package/dist/preview-sw.js +1 -1
  23. package/dist/runtime.esm.js +77 -77
  24. package/dist/runtime.js +77 -77
  25. package/dist/schemas.d.ts +9 -0
  26. package/dist/schemas.esm.js +33 -6815
  27. package/dist/schemas.js +33 -6831
  28. package/dist/shell.esm.js +33 -33
  29. package/dist/shell.js +33 -33
  30. package/dist/terminal.esm.js +8 -6
  31. package/dist/terminal.js +6 -6
  32. package/dist/workbench/command-palette.d.ts +0 -4
  33. package/dist/workbench/index.d.ts +0 -20
  34. package/dist/workbench/intellisense.d.ts +1 -7
  35. package/package.json +3 -10
  36. package/src/code-lab.css +4 -502
  37. package/src/extensions/cpp.ts +11 -29
  38. package/src/extensions/guided-lab.ts +6 -2
  39. package/src/extensions/python.ts +9 -3
  40. package/src/modular-kernel.ts +0 -4
  41. package/src/runtime.ts +124 -39
  42. package/src/schemas.ts +2 -2
  43. package/src/shell.ts +3 -0
  44. package/src/terminal.ts +4 -2
  45. package/src/workbench/command-palette.ts +22 -302
  46. package/src/workbench/diff-editor.ts +2 -0
  47. package/src/workbench/icons.ts +1 -1
  48. package/src/workbench/index.ts +0 -15
  49. package/src/workbench/intellisense.ts +17 -4
  50. package/src/workbench.ts +68 -375
  51. package/dist/code-lab.umd.js +0 -6117
  52. package/dist/packages/editor/src/index.d.ts +0 -118
  53. package/dist/packages/preview/src/index.d.ts +0 -34
  54. package/dist/packages/runtime/src/index.d.ts +0 -47
  55. package/dist/packages/terminal/src/index.d.ts +0 -54
  56. package/dist/workbench/drawer.d.ts +0 -18
  57. package/dist/workbench/file-tree.d.ts +0 -11
  58. package/dist/workbench/guided-pane.d.ts +0 -11
  59. package/dist/workbench/styles.d.ts +0 -4
  60. package/dist/workbench/toolbar.d.ts +0 -17
  61. package/packages/commands/README.md +0 -7
  62. package/packages/commands/package.json +0 -16
  63. package/packages/commands/src/index.ts +0 -467
  64. package/packages/commands/tsconfig.json +0 -22
  65. package/packages/core/README.md +0 -12
  66. package/packages/core/package.json +0 -13
  67. package/packages/core/src/di.ts +0 -147
  68. package/packages/core/src/disposable.ts +0 -112
  69. package/packages/core/src/errors.ts +0 -205
  70. package/packages/core/src/events.ts +0 -157
  71. package/packages/core/src/index.ts +0 -49
  72. package/packages/core/src/path.ts +0 -118
  73. package/packages/core/src/registry.ts +0 -61
  74. package/packages/core/tsconfig.json +0 -19
  75. package/packages/editor/README.md +0 -9
  76. package/packages/editor/package.json +0 -18
  77. package/packages/editor/src/index.ts +0 -344
  78. package/packages/editor/tsconfig.json +0 -24
  79. package/packages/fs/README.md +0 -7
  80. package/packages/fs/package.json +0 -16
  81. package/packages/fs/src/backends.ts +0 -301
  82. package/packages/fs/src/index.ts +0 -18
  83. package/packages/fs/src/types.ts +0 -44
  84. package/packages/fs/src/vfs-service.ts +0 -257
  85. package/packages/fs/tsconfig.json +0 -22
  86. package/packages/preview/README.md +0 -3
  87. package/packages/preview/package.json +0 -16
  88. package/packages/preview/src/index.ts +0 -125
  89. package/packages/preview/tsconfig.json +0 -22
  90. package/packages/runtime/README.md +0 -3
  91. package/packages/runtime/package.json +0 -17
  92. package/packages/runtime/src/index.ts +0 -134
  93. package/packages/runtime/tsconfig.json +0 -23
  94. package/packages/settings/README.md +0 -7
  95. package/packages/settings/package.json +0 -16
  96. package/packages/settings/src/builtin-schemas.ts +0 -262
  97. package/packages/settings/src/configuration-service.ts +0 -609
  98. package/packages/settings/src/index.ts +0 -38
  99. package/packages/settings/src/jsonc.ts +0 -189
  100. package/packages/settings/src/schema.ts +0 -164
  101. package/packages/settings/tsconfig.json +0 -22
  102. package/packages/sql/README.md +0 -12
  103. package/packages/sql/package.json +0 -13
  104. package/packages/sql/src/completions.ts +0 -359
  105. package/packages/sql/src/diagnostics.ts +0 -200
  106. package/packages/sql/src/formatter.ts +0 -271
  107. package/packages/sql/src/index.ts +0 -54
  108. package/packages/sql/src/sql-editor.ts +0 -802
  109. package/packages/sql/src/styles.ts +0 -524
  110. package/packages/sql/src/tokenizer.ts +0 -457
  111. package/packages/sql/src/types.ts +0 -148
  112. package/packages/sql/tsconfig.json +0 -19
  113. package/packages/terminal/README.md +0 -3
  114. package/packages/terminal/package.json +0 -16
  115. package/packages/terminal/src/index.ts +0 -183
  116. package/packages/terminal/tsconfig.json +0 -22
  117. package/packages/ui/README.md +0 -8
  118. package/packages/ui/package.json +0 -18
  119. package/packages/ui/src/index.ts +0 -40
  120. package/packages/ui/src/observability.ts +0 -173
  121. package/packages/ui/src/plugin-registry.ts +0 -289
  122. package/packages/ui/src/settings-dialog.ts +0 -939
  123. package/packages/ui/src/themes.ts +0 -333
  124. package/packages/ui/tsconfig.json +0 -24
  125. package/src/workbench/drawer.ts +0 -157
  126. package/src/workbench/file-tree.ts +0 -51
  127. package/src/workbench/guided-pane.ts +0 -43
  128. package/src/workbench/styles.ts +0 -211
  129. package/src/workbench/toolbar.ts +0 -182
@@ -1,125 +0,0 @@
1
- import {
2
- CodeLabError,
3
- createServiceId,
4
- Emitter,
5
- type Event,
6
- type IDisposable
7
- } from '@code-lab/core';
8
-
9
- export const SAFE_IFRAME_SANDBOX = 'allow-scripts allow-forms allow-modals';
10
-
11
- export interface PreviewPolicyOptions {
12
- readonly allowExternalNetwork?: boolean;
13
- readonly allowedOrigins?: readonly string[];
14
- }
15
-
16
- function sanitizeSourceList(origins: readonly string[] | undefined): string[] {
17
- if (!origins) return [];
18
- const valid: string[] = [];
19
- for (const raw of origins) {
20
- const trimmed = raw.trim();
21
- if (/^https?:\/\/[A-Za-z0-9.-]+(?::\d+)?$/.test(trimmed)) {
22
- valid.push(trimmed);
23
- }
24
- }
25
- return valid;
26
- }
27
-
28
- export function buildPreviewCsp(options: PreviewPolicyOptions = {}): string {
29
- const extra = sanitizeSourceList(options.allowedOrigins);
30
- const netSources = options.allowExternalNetwork
31
- ? ["'self'", 'https:', 'http:', 'ws:', 'wss:', ...extra]
32
- : ["'self'", ...extra];
33
-
34
- return [
35
- "default-src 'self' data: blob:",
36
- `script-src 'self' 'unsafe-inline' 'unsafe-eval' blob: https://esm.sh https://cdn.jsdelivr.net ${extra.join(' ')}`.trim(),
37
- "style-src 'self' 'unsafe-inline' https:",
38
- "img-src 'self' data: blob: https:",
39
- "font-src 'self' data: https:",
40
- `connect-src ${netSources.join(' ')}`,
41
- "frame-ancestors 'self'",
42
- "base-uri 'none'",
43
- "object-src 'none'"
44
- ].join('; ');
45
- }
46
-
47
- export function sanitizePreviewUrl(rawUrl: string): string {
48
- const trimmed = String(rawUrl ?? '').trim();
49
- if (!trimmed) return 'about:blank';
50
- if (/^(?:javascript|vbscript|data):/i.test(trimmed)) {
51
- throw new CodeLabError('ERR_SECURITY_POLICY', `Blocked unsafe preview URL scheme: ${trimmed}`);
52
- }
53
- return trimmed;
54
- }
55
-
56
- export interface PreviewState {
57
- readonly instanceId: string;
58
- readonly port: number;
59
- readonly path: string;
60
- readonly reloadNonce: number;
61
- readonly csp: string;
62
- }
63
-
64
- export interface IPreviewService extends IDisposable {
65
- readonly state: PreviewState;
66
- readonly onDidChangePreview: Event<PreviewState>;
67
- navigate(port: number, path?: string): void;
68
- reload(): void;
69
- updatePolicy(options: PreviewPolicyOptions): void;
70
- }
71
-
72
- export const IPreviewServiceId = createServiceId<IPreviewService>('code-lab.preview');
73
-
74
- export class PreviewService implements IPreviewService {
75
- private current: PreviewState;
76
- private readonly emitter = new Emitter<PreviewState>({ name: 'preview.change' });
77
-
78
- public constructor(instanceId: string, initialPort = 3000, policy: PreviewPolicyOptions = {}) {
79
- this.current = {
80
- instanceId,
81
- port: initialPort,
82
- path: '/',
83
- reloadNonce: 0,
84
- csp: buildPreviewCsp(policy)
85
- };
86
- }
87
-
88
- public get state(): PreviewState {
89
- return this.current;
90
- }
91
-
92
- public get onDidChangePreview(): Event<PreviewState> {
93
- return this.emitter.event;
94
- }
95
-
96
- public navigate(port: number, path = '/'): void {
97
- const cleanPath = sanitizePreviewUrl(path);
98
- this.current = {
99
- ...this.current,
100
- port: Math.max(1, Math.min(65535, Math.trunc(port))),
101
- path: cleanPath.startsWith('/') ? cleanPath : '/' + cleanPath
102
- };
103
- this.emitter.fire(this.current);
104
- }
105
-
106
- public reload(): void {
107
- this.current = {
108
- ...this.current,
109
- reloadNonce: this.current.reloadNonce + 1
110
- };
111
- this.emitter.fire(this.current);
112
- }
113
-
114
- public updatePolicy(options: PreviewPolicyOptions): void {
115
- this.current = {
116
- ...this.current,
117
- csp: buildPreviewCsp(options)
118
- };
119
- this.emitter.fire(this.current);
120
- }
121
-
122
- public dispose(): void {
123
- this.emitter.dispose();
124
- }
125
- }
@@ -1,22 +0,0 @@
1
- {
2
- "compilerOptions": {
3
- "target": "ES2022",
4
- "module": "ESNext",
5
- "moduleResolution": "bundler",
6
- "lib": ["ES2022", "DOM"],
7
- "strict": true,
8
- "noImplicitAny": true,
9
- "strictNullChecks": true,
10
- "noUnusedLocals": true,
11
- "noUnusedParameters": true,
12
- "noImplicitReturns": true,
13
- "noFallthroughCasesInSwitch": true,
14
- "noEmit": true,
15
- "skipLibCheck": true,
16
- "forceConsistentCasingInFileNames": true,
17
- "paths": {
18
- "@code-lab/core": ["../core/src/index.ts"]
19
- }
20
- },
21
- "include": ["src/**/*.ts"]
22
- }
@@ -1,3 +0,0 @@
1
- # `@code-lab/runtime`
2
-
3
- Layer 2 (`services`) sandbox execution contract (`IRuntimeService`) and `WorkerHostSupervisor` managing watchdog timeouts, `AbortController` cancellation, and worker status events.
@@ -1,17 +0,0 @@
1
- {
2
- "name": "@code-lab/runtime",
3
- "version": "0.7.0",
4
- "description": "Typed sandbox execution service & worker host supervisor for CodeLab.",
5
- "type": "module",
6
- "main": "./src/index.ts",
7
- "types": "./src/index.ts",
8
- "exports": {
9
- ".": "./src/index.ts"
10
- },
11
- "dependencies": {
12
- "@code-lab/core": "workspace:*",
13
- "@code-lab/fs": "workspace:*"
14
- },
15
- "sideEffects": false,
16
- "license": "MIT"
17
- }
@@ -1,134 +0,0 @@
1
- import {
2
- CodeLabError,
3
- createServiceId,
4
- Emitter,
5
- type Event,
6
- type IDisposable
7
- } from '@code-lab/core';
8
- import type { IFileSystemService } from '@code-lab/fs';
9
-
10
- export type RuntimeStatus = 'idle' | 'running' | 'stopped' | 'error';
11
-
12
- export interface RuntimeExecutionRequest {
13
- readonly entry: string;
14
- readonly mode?: 'run' | 'test' | 'repl';
15
- readonly cwd?: string;
16
- readonly env?: Readonly<Record<string, string>>;
17
- readonly stdin?: string;
18
- readonly timeoutMs?: number;
19
- }
20
-
21
- export interface RuntimeExecutionResult {
22
- readonly ok: boolean;
23
- readonly exitCode: number;
24
- readonly stdout: string;
25
- readonly stderr: string;
26
- readonly durationMs: number;
27
- readonly timedOut?: boolean;
28
- }
29
-
30
- export type RuntimeExecutorDelegate = (
31
- req: RuntimeExecutionRequest & { files: Record<string, string>; signal: AbortSignal }
32
- ) => Promise<RuntimeExecutionResult>;
33
-
34
- export interface IRuntimeService extends IDisposable {
35
- readonly status: RuntimeStatus;
36
- readonly activeRunCount: number;
37
- readonly onDidChangeStatus: Event<RuntimeStatus>;
38
- execute(request: RuntimeExecutionRequest): Promise<RuntimeExecutionResult>;
39
- cancelAll(): void;
40
- }
41
-
42
- export const IRuntimeServiceId = createServiceId<IRuntimeService>('code-lab.runtime');
43
-
44
- export class WorkerHostSupervisor implements IRuntimeService {
45
- private currentStatus: RuntimeStatus = 'idle';
46
- private readonly activeControllers = new Set<AbortController>();
47
- private readonly statusEmitter = new Emitter<RuntimeStatus>({ name: 'runtime.status' });
48
- private readonly fs: IFileSystemService;
49
- private readonly delegate: RuntimeExecutorDelegate;
50
- private disposed = false;
51
-
52
- public constructor(fs: IFileSystemService, delegate: RuntimeExecutorDelegate) {
53
- this.fs = fs;
54
- this.delegate = delegate;
55
- }
56
-
57
- public get status(): RuntimeStatus {
58
- return this.currentStatus;
59
- }
60
-
61
- public get activeRunCount(): number {
62
- return this.activeControllers.size;
63
- }
64
-
65
- public get onDidChangeStatus(): Event<RuntimeStatus> {
66
- return this.statusEmitter.event;
67
- }
68
-
69
- private setStatus(next: RuntimeStatus): void {
70
- if (this.currentStatus === next) return;
71
- this.currentStatus = next;
72
- this.statusEmitter.fire(next);
73
- }
74
-
75
- public async execute(request: RuntimeExecutionRequest): Promise<RuntimeExecutionResult> {
76
- if (this.disposed) {
77
- throw new CodeLabError('ERR_DISPOSED', 'RuntimeService has been disposed');
78
- }
79
- const controller = new AbortController();
80
- this.activeControllers.add(controller);
81
- this.setStatus('running');
82
-
83
- const timeoutMs = request.timeoutMs ?? 8000;
84
- const start = Date.now();
85
- let timedOut = false;
86
- const timer = setTimeout(() => {
87
- timedOut = true;
88
- controller.abort();
89
- }, timeoutMs);
90
-
91
- try {
92
- const files = this.fs.toRecord('/workspace');
93
- const res = await this.delegate({
94
- ...request,
95
- files,
96
- signal: controller.signal
97
- });
98
- this.setStatus(this.activeControllers.size > 1 ? 'running' : res.ok ? 'idle' : 'error');
99
- return res;
100
- } catch (err) {
101
- this.setStatus('error');
102
- const message = err instanceof Error ? err.message : String(err);
103
- return {
104
- ok: false,
105
- exitCode: timedOut ? 124 : 1,
106
- stdout: '',
107
- stderr: timedOut ? `Execution timed out after ${timeoutMs}ms` : message,
108
- durationMs: Date.now() - start,
109
- timedOut
110
- };
111
- } finally {
112
- clearTimeout(timer);
113
- this.activeControllers.delete(controller);
114
- if (this.activeControllers.size === 0 && this.currentStatus === 'running') {
115
- this.setStatus('idle');
116
- }
117
- }
118
- }
119
-
120
- public cancelAll(): void {
121
- for (const ctrl of this.activeControllers) {
122
- ctrl.abort();
123
- }
124
- this.activeControllers.clear();
125
- this.setStatus('stopped');
126
- }
127
-
128
- public dispose(): void {
129
- if (this.disposed) return;
130
- this.disposed = true;
131
- this.cancelAll();
132
- this.statusEmitter.dispose();
133
- }
134
- }
@@ -1,23 +0,0 @@
1
- {
2
- "compilerOptions": {
3
- "target": "ES2022",
4
- "module": "ESNext",
5
- "moduleResolution": "bundler",
6
- "lib": ["ES2022", "DOM"],
7
- "strict": true,
8
- "noImplicitAny": true,
9
- "strictNullChecks": true,
10
- "noUnusedLocals": true,
11
- "noUnusedParameters": true,
12
- "noImplicitReturns": true,
13
- "noFallthroughCasesInSwitch": true,
14
- "noEmit": true,
15
- "skipLibCheck": true,
16
- "forceConsistentCasingInFileNames": true,
17
- "paths": {
18
- "@code-lab/core": ["../core/src/index.ts"],
19
- "@code-lab/fs": ["../fs/src/index.ts"]
20
- }
21
- },
22
- "include": ["src/**/*.ts"]
23
- }
@@ -1,7 +0,0 @@
1
- # `@code-lab/settings`
2
-
3
- Layer 1 (`platform`) VS Code-inspired configuration system for **CodeLab**:
4
-
5
- - **Layered Precedence**: `default` (plugin/built-in schema defaults) → `user` → `workspace` (`.codelab/settings.json`) → `override` (URL query/embed config).
6
- - **JSONC Parser**: Supports `//` line comments, `/* ... */` block comments, and trailing commas with exact 1-based line/column diagnostics.
7
- - **CSP-Safe JSON Schema Validator**: Validates `.codelab/settings.json`, `.codelab/keybindings.json`, `.codelab/tasks.json`, and `.codelab/extensions.json` without `new Function`, automatically falling back invalid keys to safe defaults while reporting structured diagnostics.
@@ -1,16 +0,0 @@
1
- {
2
- "name": "@code-lab/settings",
3
- "version": "0.7.0",
4
- "description": "Layered configuration service (defaults -> user -> .codelab/settings.json -> URL/embed), JSONC parser, and CSP-safe JSON Schema validator.",
5
- "type": "module",
6
- "main": "./src/index.ts",
7
- "types": "./src/index.ts",
8
- "exports": {
9
- ".": "./src/index.ts"
10
- },
11
- "dependencies": {
12
- "@code-lab/core": "workspace:*"
13
- },
14
- "sideEffects": false,
15
- "license": "MIT"
16
- }
@@ -1,262 +0,0 @@
1
- import type { JsonSchema } from './schema';
2
-
3
- export type SettingCategory =
4
- | 'Editor'
5
- | 'Workbench'
6
- | 'Files'
7
- | 'Terminal'
8
- | 'Preview'
9
- | 'Runtime'
10
- | 'SQL';
11
-
12
- export interface SettingDescriptor<T = unknown> {
13
- readonly key: string;
14
- readonly category: SettingCategory;
15
- readonly title: string;
16
- readonly description: string;
17
- readonly defaultValue: T;
18
- readonly schema: JsonSchema;
19
- }
20
-
21
- export const BUILTIN_SETTINGS: readonly SettingDescriptor[] = [
22
- {
23
- key: 'editor.fontSize',
24
- category: 'Editor',
25
- title: 'Editor Font Size',
26
- description: 'Controls the font size in pixels in the code editor.',
27
- defaultValue: 13,
28
- schema: { type: 'integer', minimum: 10, maximum: 32, default: 13 }
29
- },
30
- {
31
- key: 'editor.tabSize',
32
- category: 'Editor',
33
- title: 'Tab Size',
34
- description: 'The number of spaces a tab is equal to.',
35
- defaultValue: 2,
36
- schema: { type: 'integer', minimum: 1, maximum: 8, default: 2 }
37
- },
38
- {
39
- key: 'editor.wordWrap',
40
- category: 'Editor',
41
- title: 'Word Wrap',
42
- description: 'Controls how lines should wrap in the editor.',
43
- defaultValue: 'off',
44
- schema: { type: 'string', enum: ['off', 'on', 'wordWrapColumn'], default: 'off' }
45
- },
46
- {
47
- key: 'editor.minimap.enabled',
48
- category: 'Editor',
49
- title: 'Minimap Enabled',
50
- description: 'Controls whether the editor minimap is shown.',
51
- defaultValue: false,
52
- schema: { type: 'boolean', default: false }
53
- },
54
- {
55
- key: 'editor.lineNumbers',
56
- category: 'Editor',
57
- title: 'Line Numbers',
58
- description: 'Controls the display of line numbers in the editor gutter.',
59
- defaultValue: 'on',
60
- schema: { type: 'string', enum: ['on', 'off', 'relative'], default: 'on' }
61
- },
62
- {
63
- key: 'editor.formatOnSave',
64
- category: 'Editor',
65
- title: 'Format On Save',
66
- description: 'Format a file automatically when saving.',
67
- defaultValue: false,
68
- schema: { type: 'boolean', default: false }
69
- },
70
- {
71
- key: 'workbench.colorTheme',
72
- category: 'Workbench',
73
- title: 'Color Theme',
74
- description: 'Specifies the color theme used in the workbench (`dark`, `light`, or `high-contrast`).',
75
- defaultValue: 'dark',
76
- schema: { type: 'string', enum: ['dark', 'light', 'high-contrast'], default: 'dark' }
77
- },
78
- {
79
- key: 'workbench.sideBar.visible',
80
- category: 'Workbench',
81
- title: 'Sidebar Visible',
82
- description: 'Controls the visibility of the file explorer / activity sidebar.',
83
- defaultValue: true,
84
- schema: { type: 'boolean', default: true }
85
- },
86
- {
87
- key: 'workbench.sidebar.defaultLocation',
88
- category: 'Workbench',
89
- title: 'Sidebar Location',
90
- description: 'Controls whether the primary sidebar is docked on the left or right.',
91
- defaultValue: 'left',
92
- schema: { type: 'string', enum: ['left', 'right'], default: 'left' }
93
- },
94
- {
95
- key: 'workbench.statusBar.visible',
96
- category: 'Workbench',
97
- title: 'Status Bar Visible',
98
- description: 'Controls the visibility of the status bar at the bottom of the workbench.',
99
- defaultValue: true,
100
- schema: { type: 'boolean', default: true }
101
- },
102
- {
103
- key: 'workbench.panel.defaultTab',
104
- category: 'Workbench',
105
- title: 'Default Bottom Panel Tab',
106
- description: 'Default active tab in the bottom panel.',
107
- defaultValue: 'terminal',
108
- schema: {
109
- type: 'string',
110
- enum: [
111
- 'terminal',
112
- 'problems',
113
- 'tests',
114
- 'stdin',
115
- 'ports',
116
- 'preview',
117
- 'network',
118
- 'inspector',
119
- 'observability',
120
- 'sql-results'
121
- ],
122
- default: 'terminal'
123
- }
124
- },
125
- {
126
- key: 'files.autoSave',
127
- category: 'Files',
128
- title: 'Auto Save',
129
- description: 'Controls automatic persistence of dirty files.',
130
- defaultValue: 'afterDelay',
131
- schema: { type: 'string', enum: ['afterDelay', 'off'], default: 'afterDelay' }
132
- },
133
- {
134
- key: 'files.autoSaveDelay',
135
- category: 'Files',
136
- title: 'Auto Save Delay (ms)',
137
- description: 'Controls the delay in milliseconds after which a dirty file is saved automatically.',
138
- defaultValue: 300,
139
- schema: { type: 'integer', minimum: 50, maximum: 30000, default: 300 }
140
- },
141
- {
142
- key: 'files.exclude',
143
- category: 'Files',
144
- title: 'Excluded File Globs',
145
- description: 'Configure glob patterns for excluding files and folders from the explorer and search.',
146
- defaultValue: ['**/node_modules/**', '**/.git/**'],
147
- schema: { type: 'array', items: { type: 'string' }, default: ['**/node_modules/**', '**/.git/**'] }
148
- },
149
- {
150
- key: 'terminal.fontSize',
151
- category: 'Terminal',
152
- title: 'Terminal Font Size',
153
- description: 'Controls the font size in pixels of the integrated PTY terminal.',
154
- defaultValue: 13,
155
- schema: { type: 'integer', minimum: 10, maximum: 28, default: 13 }
156
- },
157
- {
158
- key: 'terminal.scrollback',
159
- category: 'Terminal',
160
- title: 'Terminal Scrollback',
161
- description: 'Controls the maximum amount of lines the terminal keeps in its buffer.',
162
- defaultValue: 1000,
163
- schema: { type: 'integer', minimum: 100, maximum: 50000, default: 1000 }
164
- },
165
- {
166
- key: 'preview.autoReload',
167
- category: 'Preview',
168
- title: 'Preview Auto Reload',
169
- description: 'Automatically refresh the web preview iframe when workspace files change.',
170
- defaultValue: true,
171
- schema: { type: 'boolean', default: true }
172
- },
173
- {
174
- key: 'runtime.timeoutMs',
175
- category: 'Runtime',
176
- title: 'Execution Watchdog Timeout (ms)',
177
- description: 'Maximum execution time in milliseconds before terminating runaway sandbox workers.',
178
- defaultValue: 8000,
179
- schema: { type: 'integer', minimum: 500, maximum: 120000, default: 8000 }
180
- },
181
- {
182
- key: 'sql.defaultDialect',
183
- category: 'SQL',
184
- title: 'Default SQL Dialect',
185
- description: 'Default SQL dialect used for highlighting, formatting, and completions.',
186
- defaultValue: 'postgres',
187
- schema: { type: 'string', enum: ['postgres', 'sqlite'], default: 'postgres' }
188
- }
189
- ];
190
-
191
- export function buildSettingsJsonSchema(descriptors: readonly SettingDescriptor[]): JsonSchema {
192
- const properties: Record<string, JsonSchema> = {};
193
- for (const d of descriptors) {
194
- properties[d.key] = {
195
- ...d.schema,
196
- title: d.title,
197
- description: d.description,
198
- default: d.defaultValue
199
- };
200
- }
201
- return {
202
- $schema: 'http://json-schema.org/draft-07/schema#',
203
- title: 'CodeLab Workspace & User Settings (.codelab/settings.json)',
204
- type: 'object',
205
- properties,
206
- additionalProperties: true
207
- };
208
- }
209
-
210
- export const KEYBINDINGS_JSON_SCHEMA: JsonSchema = {
211
- $schema: 'http://json-schema.org/draft-07/schema#',
212
- title: 'CodeLab Keybindings (.codelab/keybindings.json)',
213
- type: 'array',
214
- items: {
215
- type: 'object',
216
- required: ['key', 'command'],
217
- properties: {
218
- key: { type: 'string', minLength: 1, description: 'Key chord such as Mod+Enter or Shift+Alt+F' },
219
- command: { type: 'string', minLength: 1, description: 'Command ID (prefix with - to unbind)' },
220
- when: { type: 'string', description: 'Optional context-key expression' }
221
- },
222
- additionalProperties: true
223
- }
224
- };
225
-
226
- export const TASKS_JSON_SCHEMA: JsonSchema = {
227
- $schema: 'http://json-schema.org/draft-07/schema#',
228
- title: 'CodeLab Workspace Tasks (.codelab/tasks.json)',
229
- type: 'object',
230
- required: ['version', 'tasks'],
231
- properties: {
232
- version: { type: 'string', enum: ['1.0', '2.0.0'] },
233
- tasks: {
234
- type: 'array',
235
- items: {
236
- type: 'object',
237
- required: ['label', 'command'],
238
- properties: {
239
- id: { type: 'string' },
240
- label: { type: 'string', minLength: 1 },
241
- command: { type: 'string', minLength: 1 },
242
- group: { type: 'string', enum: ['run', 'build', 'test', 'dev'] },
243
- runOn: { type: 'string', enum: ['manual', 'folderOpen'] },
244
- cwd: { type: 'string' }
245
- },
246
- additionalProperties: true
247
- }
248
- }
249
- },
250
- additionalProperties: true
251
- };
252
-
253
- export const EXTENSIONS_JSON_SCHEMA: JsonSchema = {
254
- $schema: 'http://json-schema.org/draft-07/schema#',
255
- title: 'CodeLab Workspace Extensions (.codelab/extensions.json)',
256
- type: 'object',
257
- properties: {
258
- recommendations: { type: 'array', items: { type: 'string' } },
259
- autoActivate: { type: 'array', items: { type: 'string' } }
260
- },
261
- additionalProperties: true
262
- };