stone-lang 0.1.0
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/README.md +52 -0
- package/StoneEngine.js +879 -0
- package/StoneEngineService.js +1727 -0
- package/adapters/FileSystemAdapter.js +230 -0
- package/adapters/OutputAdapter.js +208 -0
- package/adapters/index.js +6 -0
- package/cli/CLIOutputAdapter.js +196 -0
- package/cli/DaemonClient.js +349 -0
- package/cli/JSONOutputAdapter.js +135 -0
- package/cli/ReplSession.js +567 -0
- package/cli/ViewerServer.js +590 -0
- package/cli/commands/check.js +84 -0
- package/cli/commands/daemon.js +189 -0
- package/cli/commands/kill.js +66 -0
- package/cli/commands/package.js +713 -0
- package/cli/commands/ps.js +65 -0
- package/cli/commands/run.js +537 -0
- package/cli/entry.js +169 -0
- package/cli/index.js +14 -0
- package/cli/stonec.js +358 -0
- package/cli/test-compiler.js +181 -0
- package/cli/viewer/index.html +495 -0
- package/daemon/IPCServer.js +455 -0
- package/daemon/ProcessManager.js +327 -0
- package/daemon/ProcessRunner.js +307 -0
- package/daemon/daemon.js +398 -0
- package/daemon/index.js +16 -0
- package/frontend/analysis/index.js +5 -0
- package/frontend/analysis/livenessAnalyzer.js +568 -0
- package/frontend/analysis/treeShaker.js +265 -0
- package/frontend/index.js +20 -0
- package/frontend/parsing/astBuilder.js +2196 -0
- package/frontend/parsing/index.js +7 -0
- package/frontend/parsing/sonParser.js +592 -0
- package/frontend/parsing/stoneAstTypes.js +703 -0
- package/frontend/parsing/terminal-registry.js +435 -0
- package/frontend/parsing/tokenizer.js +692 -0
- package/frontend/type-checker/OverloadedFunctionType.js +43 -0
- package/frontend/type-checker/TypeEnvironment.js +165 -0
- package/frontend/type-checker/bidirectionalInference.js +149 -0
- package/frontend/type-checker/index.js +10 -0
- package/frontend/type-checker/moduleAnalysis.js +248 -0
- package/frontend/type-checker/operatorMappings.js +35 -0
- package/frontend/type-checker/overloadResolution.js +605 -0
- package/frontend/type-checker/typeChecker.js +452 -0
- package/frontend/type-checker/typeCompatibility.js +389 -0
- package/frontend/type-checker/visitors/controlFlow.js +483 -0
- package/frontend/type-checker/visitors/functions.js +604 -0
- package/frontend/type-checker/visitors/index.js +38 -0
- package/frontend/type-checker/visitors/literals.js +341 -0
- package/frontend/type-checker/visitors/modules.js +159 -0
- package/frontend/type-checker/visitors/operators.js +109 -0
- package/frontend/type-checker/visitors/statements.js +768 -0
- package/frontend/types/index.js +5 -0
- package/frontend/types/operatorMap.js +134 -0
- package/frontend/types/types.js +2046 -0
- package/frontend/utils/errorCollector.js +244 -0
- package/frontend/utils/index.js +5 -0
- package/frontend/utils/moduleResolver.js +479 -0
- package/package.json +50 -0
- package/packages/browserCache.js +359 -0
- package/packages/fetcher.js +236 -0
- package/packages/index.js +130 -0
- package/packages/lockfile.js +271 -0
- package/packages/manifest.js +291 -0
- package/packages/packageResolver.js +356 -0
- package/packages/resolver.js +310 -0
- package/packages/semver.js +635 -0
|
@@ -0,0 +1,189 @@
|
|
|
1
|
+
/**
|
|
2
|
+
* daemon command - Manage the Stone daemon
|
|
3
|
+
*
|
|
4
|
+
* Usage:
|
|
5
|
+
* stone daemon status - Check daemon status
|
|
6
|
+
* stone daemon start - Start daemon (usually auto-started)
|
|
7
|
+
* stone daemon stop - Stop daemon
|
|
8
|
+
*/
|
|
9
|
+
|
|
10
|
+
import { spawn } from 'child_process';
|
|
11
|
+
import path from 'path';
|
|
12
|
+
import { fileURLToPath } from 'url';
|
|
13
|
+
import { DaemonClient } from '../DaemonClient.js';
|
|
14
|
+
import { getSocketPath } from '../../daemon/IPCServer.js';
|
|
15
|
+
|
|
16
|
+
const __dirname = path.dirname(fileURLToPath(import.meta.url));
|
|
17
|
+
|
|
18
|
+
/**
|
|
19
|
+
* Daemon management command
|
|
20
|
+
* @param {string} action - Action to perform (status, start, stop)
|
|
21
|
+
* @param {Object} options - Command options
|
|
22
|
+
*/
|
|
23
|
+
export async function daemonCommand(action, options = {}) {
|
|
24
|
+
const { json = false, force = false } = options;
|
|
25
|
+
|
|
26
|
+
switch (action) {
|
|
27
|
+
case 'status':
|
|
28
|
+
await statusAction(json);
|
|
29
|
+
break;
|
|
30
|
+
|
|
31
|
+
case 'start':
|
|
32
|
+
await startAction(json);
|
|
33
|
+
break;
|
|
34
|
+
|
|
35
|
+
case 'stop':
|
|
36
|
+
await stopAction(json, force);
|
|
37
|
+
break;
|
|
38
|
+
|
|
39
|
+
default:
|
|
40
|
+
if (json) {
|
|
41
|
+
console.log(JSON.stringify({ error: `Unknown action: ${action}` }));
|
|
42
|
+
} else {
|
|
43
|
+
console.error(`Unknown action: ${action}`);
|
|
44
|
+
console.log('Usage: stone daemon <status|start|stop>');
|
|
45
|
+
}
|
|
46
|
+
process.exit(1);
|
|
47
|
+
}
|
|
48
|
+
}
|
|
49
|
+
|
|
50
|
+
async function statusAction(json) {
|
|
51
|
+
try {
|
|
52
|
+
const isRunning = await DaemonClient.isDaemonRunning();
|
|
53
|
+
|
|
54
|
+
if (!isRunning) {
|
|
55
|
+
if (json) {
|
|
56
|
+
console.log(JSON.stringify({ running: false }));
|
|
57
|
+
} else {
|
|
58
|
+
console.log('Stone daemon is not running.');
|
|
59
|
+
console.log(`Socket path: ${getSocketPath()}`);
|
|
60
|
+
}
|
|
61
|
+
return;
|
|
62
|
+
}
|
|
63
|
+
|
|
64
|
+
const client = new DaemonClient({ autoStartDaemon: false });
|
|
65
|
+
await client.connect();
|
|
66
|
+
const status = await client.status();
|
|
67
|
+
client.disconnect();
|
|
68
|
+
|
|
69
|
+
if (json) {
|
|
70
|
+
console.log(JSON.stringify({ running: true, ...status }));
|
|
71
|
+
} else {
|
|
72
|
+
console.log('Stone daemon is running.');
|
|
73
|
+
console.log(`Socket path: ${status.socketPath}`);
|
|
74
|
+
console.log(`Connected clients: ${status.clients}`);
|
|
75
|
+
console.log(`Uptime: ${Math.round(status.uptime)}s`);
|
|
76
|
+
console.log(`Processes: ${JSON.stringify(status.processes)}`);
|
|
77
|
+
}
|
|
78
|
+
} catch (err) {
|
|
79
|
+
if (json) {
|
|
80
|
+
console.log(JSON.stringify({ running: false, error: err.message }));
|
|
81
|
+
} else {
|
|
82
|
+
console.error(`Error checking status: ${err.message}`);
|
|
83
|
+
}
|
|
84
|
+
process.exit(1);
|
|
85
|
+
}
|
|
86
|
+
}
|
|
87
|
+
|
|
88
|
+
async function startAction(json) {
|
|
89
|
+
try {
|
|
90
|
+
const isRunning = await DaemonClient.isDaemonRunning();
|
|
91
|
+
|
|
92
|
+
if (isRunning) {
|
|
93
|
+
if (json) {
|
|
94
|
+
console.log(JSON.stringify({ started: false, reason: 'Already running' }));
|
|
95
|
+
} else {
|
|
96
|
+
console.log('Stone daemon is already running.');
|
|
97
|
+
}
|
|
98
|
+
return;
|
|
99
|
+
}
|
|
100
|
+
|
|
101
|
+
// Start daemon
|
|
102
|
+
const daemonPath = path.join(__dirname, '..', '..', 'daemon', 'daemon.js');
|
|
103
|
+
|
|
104
|
+
const daemon = spawn(process.execPath, [daemonPath], {
|
|
105
|
+
detached: true,
|
|
106
|
+
stdio: 'ignore',
|
|
107
|
+
});
|
|
108
|
+
|
|
109
|
+
daemon.unref();
|
|
110
|
+
|
|
111
|
+
// Wait for daemon to start
|
|
112
|
+
let started = false;
|
|
113
|
+
for (let i = 0; i < 20; i++) {
|
|
114
|
+
await new Promise(r => setTimeout(r, 250));
|
|
115
|
+
if (await DaemonClient.isDaemonRunning()) {
|
|
116
|
+
started = true;
|
|
117
|
+
break;
|
|
118
|
+
}
|
|
119
|
+
}
|
|
120
|
+
|
|
121
|
+
if (json) {
|
|
122
|
+
console.log(JSON.stringify({ started }));
|
|
123
|
+
} else {
|
|
124
|
+
if (started) {
|
|
125
|
+
console.log('Stone daemon started.');
|
|
126
|
+
console.log(`Socket path: ${getSocketPath()}`);
|
|
127
|
+
} else {
|
|
128
|
+
console.error('Failed to start daemon.');
|
|
129
|
+
process.exit(1);
|
|
130
|
+
}
|
|
131
|
+
}
|
|
132
|
+
} catch (err) {
|
|
133
|
+
if (json) {
|
|
134
|
+
console.log(JSON.stringify({ started: false, error: err.message }));
|
|
135
|
+
} else {
|
|
136
|
+
console.error(`Error starting daemon: ${err.message}`);
|
|
137
|
+
}
|
|
138
|
+
process.exit(1);
|
|
139
|
+
}
|
|
140
|
+
}
|
|
141
|
+
|
|
142
|
+
async function stopAction(json, force) {
|
|
143
|
+
try {
|
|
144
|
+
const isRunning = await DaemonClient.isDaemonRunning();
|
|
145
|
+
|
|
146
|
+
if (!isRunning) {
|
|
147
|
+
if (json) {
|
|
148
|
+
console.log(JSON.stringify({ stopped: true, reason: 'Was not running' }));
|
|
149
|
+
} else {
|
|
150
|
+
console.log('Stone daemon is not running.');
|
|
151
|
+
}
|
|
152
|
+
return;
|
|
153
|
+
}
|
|
154
|
+
|
|
155
|
+
const client = new DaemonClient({ autoStartDaemon: false });
|
|
156
|
+
await client.connect();
|
|
157
|
+
|
|
158
|
+
try {
|
|
159
|
+
await client.shutdown(force);
|
|
160
|
+
|
|
161
|
+
if (json) {
|
|
162
|
+
console.log(JSON.stringify({ stopped: true }));
|
|
163
|
+
} else {
|
|
164
|
+
console.log('Stone daemon stopped.');
|
|
165
|
+
}
|
|
166
|
+
} catch (err) {
|
|
167
|
+
if (json) {
|
|
168
|
+
console.log(JSON.stringify({ stopped: false, error: err.message }));
|
|
169
|
+
} else {
|
|
170
|
+
console.error(`Failed to stop daemon: ${err.message}`);
|
|
171
|
+
if (err.message.includes('Other clients')) {
|
|
172
|
+
console.log('Use --force to override.');
|
|
173
|
+
}
|
|
174
|
+
}
|
|
175
|
+
process.exit(1);
|
|
176
|
+
}
|
|
177
|
+
|
|
178
|
+
client.disconnect();
|
|
179
|
+
} catch (err) {
|
|
180
|
+
if (json) {
|
|
181
|
+
console.log(JSON.stringify({ stopped: false, error: err.message }));
|
|
182
|
+
} else {
|
|
183
|
+
console.error(`Error: ${err.message}`);
|
|
184
|
+
}
|
|
185
|
+
process.exit(1);
|
|
186
|
+
}
|
|
187
|
+
}
|
|
188
|
+
|
|
189
|
+
export default daemonCommand;
|
|
@@ -0,0 +1,66 @@
|
|
|
1
|
+
/**
|
|
2
|
+
* kill command - Kill a running Stone process
|
|
3
|
+
*
|
|
4
|
+
* Usage:
|
|
5
|
+
* stone kill <processId>
|
|
6
|
+
*/
|
|
7
|
+
|
|
8
|
+
import { DaemonClient } from '../DaemonClient.js';
|
|
9
|
+
|
|
10
|
+
/**
|
|
11
|
+
* Kill a running process
|
|
12
|
+
* @param {string} processId - Process ID to kill
|
|
13
|
+
* @param {Object} options - Command options
|
|
14
|
+
*/
|
|
15
|
+
export async function killCommand(processId, options = {}) {
|
|
16
|
+
const { json = false } = options;
|
|
17
|
+
|
|
18
|
+
if (!processId) {
|
|
19
|
+
if (json) {
|
|
20
|
+
console.log(JSON.stringify({ error: 'Process ID required' }));
|
|
21
|
+
} else {
|
|
22
|
+
console.error('Error: Process ID required');
|
|
23
|
+
console.log('Usage: stone kill <processId>');
|
|
24
|
+
}
|
|
25
|
+
process.exit(1);
|
|
26
|
+
}
|
|
27
|
+
|
|
28
|
+
try {
|
|
29
|
+
const client = new DaemonClient({ autoStartDaemon: false });
|
|
30
|
+
|
|
31
|
+
const isRunning = await DaemonClient.isDaemonRunning();
|
|
32
|
+
if (!isRunning) {
|
|
33
|
+
if (json) {
|
|
34
|
+
console.log(JSON.stringify({ error: 'Daemon not running' }));
|
|
35
|
+
} else {
|
|
36
|
+
console.error('Error: No Stone daemon running.');
|
|
37
|
+
}
|
|
38
|
+
process.exit(1);
|
|
39
|
+
}
|
|
40
|
+
|
|
41
|
+
await client.connect();
|
|
42
|
+
|
|
43
|
+
const killed = await client.kill(processId);
|
|
44
|
+
|
|
45
|
+
if (json) {
|
|
46
|
+
console.log(JSON.stringify({ processId, killed }));
|
|
47
|
+
} else {
|
|
48
|
+
if (killed) {
|
|
49
|
+
console.log(`Killed process ${processId}`);
|
|
50
|
+
} else {
|
|
51
|
+
console.log(`Process ${processId} not found or not running`);
|
|
52
|
+
}
|
|
53
|
+
}
|
|
54
|
+
|
|
55
|
+
client.disconnect();
|
|
56
|
+
} catch (err) {
|
|
57
|
+
if (json) {
|
|
58
|
+
console.log(JSON.stringify({ error: err.message }));
|
|
59
|
+
} else {
|
|
60
|
+
console.error(`Error: ${err.message}`);
|
|
61
|
+
}
|
|
62
|
+
process.exit(1);
|
|
63
|
+
}
|
|
64
|
+
}
|
|
65
|
+
|
|
66
|
+
export default killCommand;
|