@robinpath/cli 1.75.0 → 1.76.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.
@@ -1,214 +1,214 @@
1
- /**
2
- * Native process module for RobinPath.
3
- * Exposes Node.js process information and control.
4
- */
5
- import { toStr, toNum } from './_helpers.js';
6
-
7
- export const ProcessFunctions = {
8
-
9
- env: (args) => {
10
- if (args.length === 0) return { ...process.env };
11
- const key = toStr(args[0]);
12
- if (args.length >= 2) {
13
- // Set environment variable
14
- process.env[key] = toStr(args[1]);
15
- return true;
16
- }
17
- return process.env[key] ?? null;
18
- },
19
-
20
- argv: () => {
21
- return process.argv.slice(2);
22
- },
23
-
24
- exit: (args) => {
25
- const code = args.length > 0 ? toNum(args[0], 0) : 0;
26
- process.exit(code);
27
- },
28
-
29
- cwd: () => {
30
- return process.cwd();
31
- },
32
-
33
- chdir: (args) => {
34
- if (args.length < 1) throw new Error('process.chdir requires a directory path');
35
- process.chdir(toStr(args[0]));
36
- return process.cwd();
37
- },
38
-
39
- pid: () => {
40
- return process.pid;
41
- },
42
-
43
- ppid: () => {
44
- return process.ppid;
45
- },
46
-
47
- platform: () => {
48
- return process.platform;
49
- },
50
-
51
- arch: () => {
52
- return process.arch;
53
- },
54
-
55
- version: () => {
56
- return process.version;
57
- },
58
-
59
- versions: () => {
60
- return { ...process.versions };
61
- },
62
-
63
- memoryUsage: () => {
64
- const mem = process.memoryUsage();
65
- return {
66
- rss: mem.rss,
67
- heapTotal: mem.heapTotal,
68
- heapUsed: mem.heapUsed,
69
- external: mem.external,
70
- arrayBuffers: mem.arrayBuffers
71
- };
72
- },
73
-
74
- uptime: () => {
75
- return process.uptime();
76
- },
77
-
78
- hrtime: () => {
79
- const [s, ns] = process.hrtime();
80
- return s * 1e9 + ns;
81
- },
82
-
83
- title: (args) => {
84
- if (args.length > 0) {
85
- process.title = toStr(args[0]);
86
- }
87
- return process.title;
88
- },
89
-
90
- execPath: () => {
91
- return process.execPath;
92
- },
93
-
94
- cpuUsage: () => {
95
- const usage = process.cpuUsage();
96
- return { user: usage.user, system: usage.system };
97
- },
98
-
99
- resourceUsage: () => {
100
- if (typeof process.resourceUsage === 'function') {
101
- return process.resourceUsage();
102
- }
103
- return null;
104
- }
105
- };
106
-
107
- export const ProcessFunctionMetadata = {
108
- env: {
109
- description: 'Get or set environment variables',
110
- parameters: [
111
- { name: 'key', dataType: 'string', description: 'Variable name (omit to get all)', formInputType: 'text', required: false },
112
- { name: 'value', dataType: 'string', description: 'Value to set (omit to get)', formInputType: 'text', required: false }
113
- ],
114
- returnType: 'any', returnDescription: 'Variable value, all variables, or true on set', example: 'process.env "PATH"'
115
- },
116
- argv: {
117
- description: 'Get command-line arguments',
118
- parameters: [],
119
- returnType: 'array', returnDescription: 'Array of argument strings', example: 'process.argv'
120
- },
121
- exit: {
122
- description: 'Exit the process with a code',
123
- parameters: [{ name: 'code', dataType: 'number', description: 'Exit code (default: 0)', formInputType: 'number', required: false, defaultValue: 0 }],
124
- returnType: 'null', returnDescription: 'Does not return', example: 'process.exit 1'
125
- },
126
- cwd: {
127
- description: 'Get current working directory',
128
- parameters: [],
129
- returnType: 'string', returnDescription: 'Current working directory', example: 'process.cwd'
130
- },
131
- chdir: {
132
- description: 'Change current working directory',
133
- parameters: [{ name: 'directory', dataType: 'string', description: 'Directory to change to', formInputType: 'text', required: true }],
134
- returnType: 'string', returnDescription: 'New working directory', example: 'process.chdir "/home/user"'
135
- },
136
- pid: {
137
- description: 'Get process ID',
138
- parameters: [],
139
- returnType: 'number', returnDescription: 'Process ID', example: 'process.pid'
140
- },
141
- ppid: {
142
- description: 'Get parent process ID',
143
- parameters: [],
144
- returnType: 'number', returnDescription: 'Parent process ID', example: 'process.ppid'
145
- },
146
- platform: {
147
- description: 'Get operating system platform',
148
- parameters: [],
149
- returnType: 'string', returnDescription: 'Platform (win32, darwin, linux)', example: 'process.platform'
150
- },
151
- arch: {
152
- description: 'Get CPU architecture',
153
- parameters: [],
154
- returnType: 'string', returnDescription: 'Architecture (x64, arm64, etc.)', example: 'process.arch'
155
- },
156
- version: {
157
- description: 'Get Node.js version',
158
- parameters: [],
159
- returnType: 'string', returnDescription: 'Version string', example: 'process.version'
160
- },
161
- versions: {
162
- description: 'Get version strings of Node.js and its dependencies',
163
- parameters: [],
164
- returnType: 'object', returnDescription: 'Object with version strings', example: 'process.versions'
165
- },
166
- memoryUsage: {
167
- description: 'Get memory usage statistics',
168
- parameters: [],
169
- returnType: 'object', returnDescription: 'Object with rss, heapTotal, heapUsed, external', example: 'process.memoryUsage'
170
- },
171
- uptime: {
172
- description: 'Get process uptime in seconds',
173
- parameters: [],
174
- returnType: 'number', returnDescription: 'Uptime in seconds', example: 'process.uptime'
175
- },
176
- hrtime: {
177
- description: 'Get high-resolution time in nanoseconds',
178
- parameters: [],
179
- returnType: 'number', returnDescription: 'Time in nanoseconds', example: 'process.hrtime'
180
- },
181
- title: {
182
- description: 'Get or set process title',
183
- parameters: [{ name: 'title', dataType: 'string', description: 'New title (omit to get)', formInputType: 'text', required: false }],
184
- returnType: 'string', returnDescription: 'Process title', example: 'process.title "MyApp"'
185
- },
186
- execPath: {
187
- description: 'Get path to the Node.js executable',
188
- parameters: [],
189
- returnType: 'string', returnDescription: 'Executable path', example: 'process.execPath'
190
- },
191
- cpuUsage: {
192
- description: 'Get CPU usage (user and system microseconds)',
193
- parameters: [],
194
- returnType: 'object', returnDescription: 'Object with user and system CPU time', example: 'process.cpuUsage'
195
- },
196
- resourceUsage: {
197
- description: 'Get resource usage statistics',
198
- parameters: [],
199
- returnType: 'object', returnDescription: 'Resource usage object', example: 'process.resourceUsage'
200
- }
201
- };
202
-
203
- export const ProcessModuleMetadata = {
204
- description: 'Process information and control: env, argv, pid, memory, CPU, and more',
205
- methods: Object.keys(ProcessFunctions)
206
- };
207
-
208
- export default {
209
- name: 'process',
210
- functions: ProcessFunctions,
211
- functionMetadata: ProcessFunctionMetadata,
212
- moduleMetadata: ProcessModuleMetadata,
213
- global: false
214
- };
1
+ /**
2
+ * Native process module for RobinPath.
3
+ * Exposes Node.js process information and control.
4
+ */
5
+ import { toStr, toNum } from './_helpers.js';
6
+
7
+ export const ProcessFunctions = {
8
+
9
+ env: (args) => {
10
+ if (args.length === 0) return { ...process.env };
11
+ const key = toStr(args[0]);
12
+ if (args.length >= 2) {
13
+ // Set environment variable
14
+ process.env[key] = toStr(args[1]);
15
+ return true;
16
+ }
17
+ return process.env[key] ?? null;
18
+ },
19
+
20
+ argv: () => {
21
+ return process.argv.slice(2);
22
+ },
23
+
24
+ exit: (args) => {
25
+ const code = args.length > 0 ? toNum(args[0], 0) : 0;
26
+ process.exit(code);
27
+ },
28
+
29
+ cwd: () => {
30
+ return process.cwd();
31
+ },
32
+
33
+ chdir: (args) => {
34
+ if (args.length < 1) throw new Error('process.chdir requires a directory path');
35
+ process.chdir(toStr(args[0]));
36
+ return process.cwd();
37
+ },
38
+
39
+ pid: () => {
40
+ return process.pid;
41
+ },
42
+
43
+ ppid: () => {
44
+ return process.ppid;
45
+ },
46
+
47
+ platform: () => {
48
+ return process.platform;
49
+ },
50
+
51
+ arch: () => {
52
+ return process.arch;
53
+ },
54
+
55
+ version: () => {
56
+ return process.version;
57
+ },
58
+
59
+ versions: () => {
60
+ return { ...process.versions };
61
+ },
62
+
63
+ memoryUsage: () => {
64
+ const mem = process.memoryUsage();
65
+ return {
66
+ rss: mem.rss,
67
+ heapTotal: mem.heapTotal,
68
+ heapUsed: mem.heapUsed,
69
+ external: mem.external,
70
+ arrayBuffers: mem.arrayBuffers
71
+ };
72
+ },
73
+
74
+ uptime: () => {
75
+ return process.uptime();
76
+ },
77
+
78
+ hrtime: () => {
79
+ const [s, ns] = process.hrtime();
80
+ return s * 1e9 + ns;
81
+ },
82
+
83
+ title: (args) => {
84
+ if (args.length > 0) {
85
+ process.title = toStr(args[0]);
86
+ }
87
+ return process.title;
88
+ },
89
+
90
+ execPath: () => {
91
+ return process.execPath;
92
+ },
93
+
94
+ cpuUsage: () => {
95
+ const usage = process.cpuUsage();
96
+ return { user: usage.user, system: usage.system };
97
+ },
98
+
99
+ resourceUsage: () => {
100
+ if (typeof process.resourceUsage === 'function') {
101
+ return process.resourceUsage();
102
+ }
103
+ return null;
104
+ }
105
+ };
106
+
107
+ export const ProcessFunctionMetadata = {
108
+ env: {
109
+ description: 'Get or set environment variables',
110
+ parameters: [
111
+ { name: 'key', dataType: 'string', description: 'Variable name (omit to get all)', formInputType: 'text', required: false },
112
+ { name: 'value', dataType: 'string', description: 'Value to set (omit to get)', formInputType: 'text', required: false }
113
+ ],
114
+ returnType: 'any', returnDescription: 'Variable value, all variables, or true on set', example: 'process.env "PATH"'
115
+ },
116
+ argv: {
117
+ description: 'Get command-line arguments',
118
+ parameters: [],
119
+ returnType: 'array', returnDescription: 'Array of argument strings', example: 'process.argv'
120
+ },
121
+ exit: {
122
+ description: 'Exit the process with a code',
123
+ parameters: [{ name: 'code', dataType: 'number', description: 'Exit code (default: 0)', formInputType: 'number', required: false, defaultValue: 0 }],
124
+ returnType: 'null', returnDescription: 'Does not return', example: 'process.exit 1'
125
+ },
126
+ cwd: {
127
+ description: 'Get current working directory',
128
+ parameters: [],
129
+ returnType: 'string', returnDescription: 'Current working directory', example: 'process.cwd'
130
+ },
131
+ chdir: {
132
+ description: 'Change current working directory',
133
+ parameters: [{ name: 'directory', dataType: 'string', description: 'Directory to change to', formInputType: 'text', required: true }],
134
+ returnType: 'string', returnDescription: 'New working directory', example: 'process.chdir "/home/user"'
135
+ },
136
+ pid: {
137
+ description: 'Get process ID',
138
+ parameters: [],
139
+ returnType: 'number', returnDescription: 'Process ID', example: 'process.pid'
140
+ },
141
+ ppid: {
142
+ description: 'Get parent process ID',
143
+ parameters: [],
144
+ returnType: 'number', returnDescription: 'Parent process ID', example: 'process.ppid'
145
+ },
146
+ platform: {
147
+ description: 'Get operating system platform',
148
+ parameters: [],
149
+ returnType: 'string', returnDescription: 'Platform (win32, darwin, linux)', example: 'process.platform'
150
+ },
151
+ arch: {
152
+ description: 'Get CPU architecture',
153
+ parameters: [],
154
+ returnType: 'string', returnDescription: 'Architecture (x64, arm64, etc.)', example: 'process.arch'
155
+ },
156
+ version: {
157
+ description: 'Get Node.js version',
158
+ parameters: [],
159
+ returnType: 'string', returnDescription: 'Version string', example: 'process.version'
160
+ },
161
+ versions: {
162
+ description: 'Get version strings of Node.js and its dependencies',
163
+ parameters: [],
164
+ returnType: 'object', returnDescription: 'Object with version strings', example: 'process.versions'
165
+ },
166
+ memoryUsage: {
167
+ description: 'Get memory usage statistics',
168
+ parameters: [],
169
+ returnType: 'object', returnDescription: 'Object with rss, heapTotal, heapUsed, external', example: 'process.memoryUsage'
170
+ },
171
+ uptime: {
172
+ description: 'Get process uptime in seconds',
173
+ parameters: [],
174
+ returnType: 'number', returnDescription: 'Uptime in seconds', example: 'process.uptime'
175
+ },
176
+ hrtime: {
177
+ description: 'Get high-resolution time in nanoseconds',
178
+ parameters: [],
179
+ returnType: 'number', returnDescription: 'Time in nanoseconds', example: 'process.hrtime'
180
+ },
181
+ title: {
182
+ description: 'Get or set process title',
183
+ parameters: [{ name: 'title', dataType: 'string', description: 'New title (omit to get)', formInputType: 'text', required: false }],
184
+ returnType: 'string', returnDescription: 'Process title', example: 'process.title "MyApp"'
185
+ },
186
+ execPath: {
187
+ description: 'Get path to the Node.js executable',
188
+ parameters: [],
189
+ returnType: 'string', returnDescription: 'Executable path', example: 'process.execPath'
190
+ },
191
+ cpuUsage: {
192
+ description: 'Get CPU usage (user and system microseconds)',
193
+ parameters: [],
194
+ returnType: 'object', returnDescription: 'Object with user and system CPU time', example: 'process.cpuUsage'
195
+ },
196
+ resourceUsage: {
197
+ description: 'Get resource usage statistics',
198
+ parameters: [],
199
+ returnType: 'object', returnDescription: 'Resource usage object', example: 'process.resourceUsage'
200
+ }
201
+ };
202
+
203
+ export const ProcessModuleMetadata = {
204
+ description: 'Process information and control: env, argv, pid, memory, CPU, and more',
205
+ methods: Object.keys(ProcessFunctions)
206
+ };
207
+
208
+ export default {
209
+ name: 'process',
210
+ functions: ProcessFunctions,
211
+ functionMetadata: ProcessFunctionMetadata,
212
+ moduleMetadata: ProcessModuleMetadata,
213
+ global: false
214
+ };