lsh-framework 1.2.0 → 1.2.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 (73) hide show
  1. package/README.md +40 -3
  2. package/dist/cli.js +104 -486
  3. package/dist/commands/doctor.js +427 -0
  4. package/dist/commands/init.js +371 -0
  5. package/dist/constants/api.js +94 -0
  6. package/dist/constants/commands.js +64 -0
  7. package/dist/constants/config.js +56 -0
  8. package/dist/constants/database.js +21 -0
  9. package/dist/constants/errors.js +79 -0
  10. package/dist/constants/index.js +28 -0
  11. package/dist/constants/paths.js +28 -0
  12. package/dist/constants/ui.js +73 -0
  13. package/dist/constants/validation.js +124 -0
  14. package/dist/daemon/lshd.js +11 -32
  15. package/dist/lib/daemon-client-helper.js +7 -4
  16. package/dist/lib/daemon-client.js +9 -2
  17. package/dist/lib/format-utils.js +163 -0
  18. package/dist/lib/job-manager.js +2 -1
  19. package/dist/lib/platform-utils.js +211 -0
  20. package/dist/lib/secrets-manager.js +11 -1
  21. package/dist/lib/string-utils.js +128 -0
  22. package/dist/services/daemon/daemon-registrar.js +3 -2
  23. package/dist/services/secrets/secrets.js +54 -30
  24. package/package.json +10 -74
  25. package/dist/app.js +0 -33
  26. package/dist/cicd/analytics.js +0 -261
  27. package/dist/cicd/auth.js +0 -269
  28. package/dist/cicd/cache-manager.js +0 -172
  29. package/dist/cicd/data-retention.js +0 -305
  30. package/dist/cicd/performance-monitor.js +0 -224
  31. package/dist/cicd/webhook-receiver.js +0 -640
  32. package/dist/commands/api.js +0 -346
  33. package/dist/commands/theme.js +0 -261
  34. package/dist/commands/zsh-import.js +0 -240
  35. package/dist/components/App.js +0 -1
  36. package/dist/components/Divider.js +0 -29
  37. package/dist/components/REPL.js +0 -43
  38. package/dist/components/Terminal.js +0 -232
  39. package/dist/components/UserInput.js +0 -30
  40. package/dist/daemon/api-server.js +0 -316
  41. package/dist/daemon/monitoring-api.js +0 -220
  42. package/dist/lib/api-error-handler.js +0 -185
  43. package/dist/lib/associative-arrays.js +0 -285
  44. package/dist/lib/base-api-server.js +0 -290
  45. package/dist/lib/brace-expansion.js +0 -160
  46. package/dist/lib/builtin-commands.js +0 -439
  47. package/dist/lib/executors/builtin-executor.js +0 -52
  48. package/dist/lib/extended-globbing.js +0 -411
  49. package/dist/lib/extended-parameter-expansion.js +0 -227
  50. package/dist/lib/interactive-shell.js +0 -460
  51. package/dist/lib/job-builtins.js +0 -582
  52. package/dist/lib/pathname-expansion.js +0 -216
  53. package/dist/lib/script-runner.js +0 -226
  54. package/dist/lib/shell-executor.js +0 -2504
  55. package/dist/lib/shell-parser.js +0 -958
  56. package/dist/lib/shell-types.js +0 -6
  57. package/dist/lib/shell.lib.js +0 -40
  58. package/dist/lib/theme-manager.js +0 -476
  59. package/dist/lib/variable-expansion.js +0 -385
  60. package/dist/lib/zsh-compatibility.js +0 -659
  61. package/dist/lib/zsh-import-manager.js +0 -707
  62. package/dist/lib/zsh-options.js +0 -328
  63. package/dist/pipeline/job-tracker.js +0 -491
  64. package/dist/pipeline/mcli-bridge.js +0 -309
  65. package/dist/pipeline/pipeline-service.js +0 -1119
  66. package/dist/pipeline/workflow-engine.js +0 -870
  67. package/dist/services/api/api.js +0 -58
  68. package/dist/services/api/auth.js +0 -35
  69. package/dist/services/api/config.js +0 -7
  70. package/dist/services/api/file.js +0 -22
  71. package/dist/services/shell/shell.js +0 -28
  72. package/dist/services/zapier.js +0 -16
  73. package/dist/simple-api-server.js +0 -148
@@ -1,439 +0,0 @@
1
- /**
2
- * Shell Builtin Commands
3
- * Extracted from shell-executor.ts for better maintainability
4
- * Contains all POSIX and ZSH builtin command implementations
5
- */
6
- import * as fs from 'fs';
7
- import * as path from 'path';
8
- import { PathnameExpander } from './pathname-expansion.js';
9
- /**
10
- * Manages all shell builtin commands
11
- */
12
- export class BuiltinCommands {
13
- context;
14
- pathExpander;
15
- jobBuiltins;
16
- updateExpander;
17
- constructor(context, pathExpander, jobBuiltins, updateExpander) {
18
- this.context = context;
19
- this.pathExpander = pathExpander;
20
- this.jobBuiltins = jobBuiltins;
21
- this.updateExpander = updateExpander;
22
- }
23
- /**
24
- * Update the path expander reference (called after cd)
25
- */
26
- setPathExpander(expander) {
27
- this.pathExpander = expander;
28
- }
29
- /**
30
- * Execute a builtin command by name
31
- */
32
- async execute(name, args) {
33
- switch (name) {
34
- case 'cd':
35
- return this.builtin_cd(args);
36
- case 'pwd':
37
- return this.builtin_pwd(args);
38
- case 'echo':
39
- return this.builtin_echo(args);
40
- case 'exit':
41
- return this.builtin_exit(args);
42
- case 'export':
43
- return this.builtin_export(args);
44
- case 'unset':
45
- return this.builtin_unset(args);
46
- case 'set':
47
- return this.builtin_set(args);
48
- case 'test':
49
- case '[':
50
- return this.builtin_test(args);
51
- case 'shift':
52
- return this.builtin_shift(args);
53
- case 'source':
54
- case '.':
55
- return this.builtin_source(args);
56
- case 'alias':
57
- return this.builtin_alias(args);
58
- case 'unalias':
59
- return this.builtin_unalias(args);
60
- case 'readonly':
61
- return this.builtin_readonly(args);
62
- case 'local':
63
- return this.builtin_local(args);
64
- case 'return':
65
- return this.builtin_return(args);
66
- case 'typeset':
67
- return this.builtin_typeset(args);
68
- case 'setopt':
69
- return this.builtin_setopt(args);
70
- case 'unsetopt':
71
- return this.builtin_unsetopt(args);
72
- case 'read':
73
- return this.builtin_read(args);
74
- case 'getopts':
75
- return this.builtin_getopts(args);
76
- case 'printf':
77
- return this.builtin_printf(args);
78
- case 'exec':
79
- return this.builtin_exec(args);
80
- case 'eval':
81
- return this.builtin_eval(args);
82
- case 'trap':
83
- return this.builtin_trap(args);
84
- case 'hash':
85
- return this.builtin_hash(args);
86
- case 'type':
87
- return this.builtin_type(args);
88
- // Job control builtins - Placeholder implementations
89
- // TODO: Integrate with JobBuiltins properly
90
- case 'jobs':
91
- case 'fg':
92
- case 'bg':
93
- case 'kill':
94
- case 'wait':
95
- return { stdout: '', stderr: `${name}: not yet implemented`, exitCode: 1, success: false };
96
- // History builtins
97
- case 'history':
98
- return this.builtin_history(args);
99
- case 'fc':
100
- return this.builtin_fc(args);
101
- case 'r':
102
- return this.builtin_r(args);
103
- // Installation builtins
104
- case 'install':
105
- return this.builtin_install(args);
106
- case 'uninstall':
107
- return this.builtin_uninstall(args);
108
- // ZSH migration builtins
109
- case 'zsh-source':
110
- return this.builtin_zsh_source(args);
111
- case 'zsh-migrate':
112
- return this.builtin_zsh_migrate(args);
113
- default:
114
- return null; // Not a builtin
115
- }
116
- }
117
- /**
118
- * Adapt JobBuiltins result format to ExecutionResult
119
- */
120
- adaptJobBuiltinResult(result) {
121
- return {
122
- ...result,
123
- success: result.exitCode === 0,
124
- };
125
- }
126
- // ========================================
127
- // Core Builtin Implementations
128
- // ========================================
129
- async builtin_cd(args) {
130
- const target = args[0] || this.context.env.HOME || '/';
131
- try {
132
- const resolvedPath = path.resolve(this.context.cwd, target);
133
- // Check if directory exists
134
- if (!fs.existsSync(resolvedPath)) {
135
- return {
136
- stdout: '',
137
- stderr: `cd: ${target}: No such file or directory`,
138
- exitCode: 1,
139
- success: false,
140
- };
141
- }
142
- const stats = fs.statSync(resolvedPath);
143
- if (!stats.isDirectory()) {
144
- return {
145
- stdout: '',
146
- stderr: `cd: ${target}: Not a directory`,
147
- exitCode: 1,
148
- success: false,
149
- };
150
- }
151
- // Update context
152
- this.context.cwd = resolvedPath;
153
- process.chdir(resolvedPath);
154
- // Update path expander with new working directory
155
- this.pathExpander = new PathnameExpander(this.context.cwd);
156
- return { stdout: '', stderr: '', exitCode: 0, success: true };
157
- }
158
- catch (error) {
159
- return {
160
- stdout: '',
161
- stderr: `cd: ${target}: ${error.message}`,
162
- exitCode: 1,
163
- success: false,
164
- };
165
- }
166
- }
167
- async builtin_pwd(_args) {
168
- return {
169
- stdout: this.context.cwd,
170
- stderr: '',
171
- exitCode: 0,
172
- success: true,
173
- };
174
- }
175
- async builtin_echo(args) {
176
- let message = args.join(' ');
177
- let newline = true;
178
- if (args[0] === '-n') {
179
- newline = false;
180
- message = args.slice(1).join(' ');
181
- }
182
- return {
183
- stdout: message + (newline ? '\n' : ''),
184
- stderr: '',
185
- exitCode: 0,
186
- success: true,
187
- };
188
- }
189
- async builtin_exit(args) {
190
- const exitCode = args.length > 0 ? parseInt(args[0], 10) : this.context.lastExitCode;
191
- process.exit(isNaN(exitCode) ? 1 : exitCode);
192
- return { stdout: '', stderr: '', exitCode: 0, success: true };
193
- }
194
- async builtin_export(args) {
195
- for (const arg of args) {
196
- if (arg.includes('=')) {
197
- const [key, value] = arg.split('=', 2);
198
- this.context.env[key] = value;
199
- this.context.variables[key] = value;
200
- }
201
- else {
202
- if (arg in this.context.variables) {
203
- this.context.env[arg] = this.context.variables[arg];
204
- }
205
- }
206
- }
207
- this.updateExpander();
208
- return { stdout: '', stderr: '', exitCode: 0, success: true };
209
- }
210
- async builtin_unset(args) {
211
- for (const name of args) {
212
- delete this.context.variables[name];
213
- delete this.context.env[name];
214
- }
215
- this.updateExpander();
216
- return { stdout: '', stderr: '', exitCode: 0, success: true };
217
- }
218
- async builtin_set(args) {
219
- if (args.length === 0) {
220
- // Print all variables
221
- const output = Object.entries(this.context.variables)
222
- .map(([key, value]) => `${key}=${value}`)
223
- .join('\n');
224
- return {
225
- stdout: output,
226
- stderr: '',
227
- exitCode: 0,
228
- success: true,
229
- };
230
- }
231
- for (const arg of args) {
232
- if (arg.startsWith('-')) {
233
- // Enable options
234
- for (let i = 1; i < arg.length; i++) {
235
- const option = arg[i];
236
- switch (option) {
237
- case 'e':
238
- this.context.options.errexit = true;
239
- break;
240
- case 'u':
241
- this.context.options.nounset = true;
242
- break;
243
- case 'x':
244
- this.context.options.xtrace = true;
245
- break;
246
- case 'v':
247
- this.context.options.verbose = true;
248
- break;
249
- case 'f':
250
- this.context.options.noglob = true;
251
- break;
252
- case 'm':
253
- this.context.options.monitor = true;
254
- break;
255
- case 'C':
256
- this.context.options.noclobber = true;
257
- break;
258
- case 'a':
259
- this.context.options.allexport = true;
260
- break;
261
- }
262
- }
263
- }
264
- else if (arg.startsWith('+')) {
265
- // Disable options
266
- for (let i = 1; i < arg.length; i++) {
267
- const option = arg[i];
268
- switch (option) {
269
- case 'e':
270
- this.context.options.errexit = false;
271
- break;
272
- case 'u':
273
- this.context.options.nounset = false;
274
- break;
275
- case 'x':
276
- this.context.options.xtrace = false;
277
- break;
278
- case 'v':
279
- this.context.options.verbose = false;
280
- break;
281
- case 'f':
282
- this.context.options.noglob = false;
283
- break;
284
- case 'm':
285
- this.context.options.monitor = false;
286
- break;
287
- case 'C':
288
- this.context.options.noclobber = false;
289
- break;
290
- case 'a':
291
- this.context.options.allexport = false;
292
- break;
293
- }
294
- }
295
- }
296
- else {
297
- // Set positional parameters
298
- this.context.positionalParams = args;
299
- break;
300
- }
301
- }
302
- return { stdout: '', stderr: '', exitCode: 0, success: true };
303
- }
304
- // Placeholder implementations for remaining builtins
305
- // These will be extracted from shell-executor.ts in the next phase
306
- async builtin_test(args) {
307
- const result = this.evaluateTestExpression(args);
308
- return {
309
- stdout: '',
310
- stderr: '',
311
- exitCode: result ? 0 : 1,
312
- success: result,
313
- };
314
- }
315
- evaluateTestExpression(args) {
316
- // Simplified test implementation - full version to be extracted
317
- if (args.length === 0)
318
- return false;
319
- if (args[args.length - 1] === ']')
320
- args = args.slice(0, -1);
321
- if (args.length === 1)
322
- return args[0] !== '';
323
- // More complex test logic to be extracted
324
- return true;
325
- }
326
- async builtin_shift(args) {
327
- const n = args.length > 0 ? parseInt(args[0], 10) : 1;
328
- this.context.positionalParams = this.context.positionalParams.slice(n);
329
- return { stdout: '', stderr: '', exitCode: 0, success: true };
330
- }
331
- async builtin_source(_args) {
332
- // Placeholder - full implementation to be extracted
333
- return { stdout: '', stderr: 'source: not yet implemented', exitCode: 1, success: false };
334
- }
335
- async builtin_alias(_args) {
336
- // Placeholder - full implementation to be extracted
337
- return { stdout: '', stderr: 'alias: not yet implemented', exitCode: 1, success: false };
338
- }
339
- async builtin_unalias(_args) {
340
- // Placeholder - full implementation to be extracted
341
- return { stdout: '', stderr: 'unalias: not yet implemented', exitCode: 1, success: false };
342
- }
343
- async builtin_readonly(_args) {
344
- // Placeholder - full implementation to be extracted
345
- return { stdout: '', stderr: 'readonly: not yet implemented', exitCode: 1, success: false };
346
- }
347
- async builtin_local(_args) {
348
- // Placeholder - full implementation to be extracted
349
- return { stdout: '', stderr: 'local: not yet implemented', exitCode: 1, success: false };
350
- }
351
- async builtin_return(args) {
352
- const code = args.length > 0 ? parseInt(args[0], 10) : this.context.lastReturnCode;
353
- return { stdout: '', stderr: '', exitCode: isNaN(code) ? 0 : code, success: true };
354
- }
355
- async builtin_typeset(args) {
356
- const result = this.context.arrays.parseTypesetCommand(args);
357
- return {
358
- stdout: '',
359
- stderr: result.success ? '' : result.message,
360
- exitCode: result.success ? 0 : 1,
361
- success: result.success,
362
- };
363
- }
364
- async builtin_setopt(_args) {
365
- // TODO: ZshOptionsManager doesn't have setOption method yet
366
- // for (const opt of args) {
367
- // this.context.zshOptions.setOption(opt, true);
368
- // }
369
- return { stdout: '', stderr: 'setopt: not yet fully implemented', exitCode: 1, success: false };
370
- }
371
- async builtin_unsetopt(_args) {
372
- // TODO: ZshOptionsManager doesn't have setOption method yet
373
- // for (const opt of args) {
374
- // this.context.zshOptions.setOption(opt, false);
375
- // }
376
- return { stdout: '', stderr: 'unsetopt: not yet fully implemented', exitCode: 1, success: false };
377
- }
378
- async builtin_read(_args) {
379
- // Placeholder - full implementation to be extracted
380
- return { stdout: '', stderr: 'read: not yet implemented', exitCode: 1, success: false };
381
- }
382
- async builtin_getopts(_args) {
383
- // Placeholder - full implementation to be extracted
384
- return { stdout: '', stderr: 'getopts: not yet implemented', exitCode: 1, success: false };
385
- }
386
- async builtin_printf(_args) {
387
- // Placeholder - full implementation to be extracted
388
- return { stdout: '', stderr: 'printf: not yet implemented', exitCode: 1, success: false };
389
- }
390
- async builtin_exec(_args) {
391
- // Placeholder - full implementation to be extracted
392
- return { stdout: '', stderr: 'exec: not yet implemented', exitCode: 1, success: false };
393
- }
394
- async builtin_eval(_args) {
395
- // Placeholder - full implementation to be extracted
396
- return { stdout: '', stderr: 'eval: not yet implemented', exitCode: 1, success: false };
397
- }
398
- async builtin_trap(_args) {
399
- // Placeholder - full implementation to be extracted
400
- return { stdout: '', stderr: 'trap: not yet implemented', exitCode: 1, success: false };
401
- }
402
- async builtin_hash(_args) {
403
- // Placeholder - full implementation to be extracted
404
- return { stdout: '', stderr: 'hash: not yet implemented', exitCode: 1, success: false };
405
- }
406
- async builtin_type(_args) {
407
- // Placeholder - full implementation to be extracted
408
- return { stdout: '', stderr: 'type: not yet implemented', exitCode: 1, success: false };
409
- }
410
- async builtin_history(_args) {
411
- // Placeholder - full implementation to be extracted
412
- return { stdout: '', stderr: 'history: not yet implemented', exitCode: 1, success: false };
413
- }
414
- async builtin_fc(_args) {
415
- // Placeholder - full implementation to be extracted
416
- return { stdout: '', stderr: 'fc: not yet implemented', exitCode: 1, success: false };
417
- }
418
- async builtin_r(_args) {
419
- // Placeholder - full implementation to be extracted
420
- return { stdout: '', stderr: 'r: not yet implemented', exitCode: 1, success: false };
421
- }
422
- async builtin_install(_args) {
423
- // Placeholder - full implementation to be extracted
424
- return { stdout: '', stderr: 'install: not yet implemented', exitCode: 1, success: false };
425
- }
426
- async builtin_uninstall(_args) {
427
- // Placeholder - full implementation to be extracted
428
- return { stdout: '', stderr: 'uninstall: not yet implemented', exitCode: 1, success: false };
429
- }
430
- async builtin_zsh_source(_args) {
431
- // Placeholder - full implementation to be extracted
432
- return { stdout: '', stderr: 'zsh-source: not yet implemented', exitCode: 1, success: false };
433
- }
434
- async builtin_zsh_migrate(_args) {
435
- // Placeholder - full implementation to be extracted
436
- return { stdout: '', stderr: 'zsh-migrate: not yet implemented', exitCode: 1, success: false };
437
- }
438
- }
439
- export default BuiltinCommands;
@@ -1,52 +0,0 @@
1
- /**
2
- * Builtin Command Executor
3
- * Handles execution of all POSIX and extended builtin commands
4
- */
5
- export class BuiltinExecutor {
6
- context;
7
- expander;
8
- pathExpander;
9
- jobManager;
10
- jobBuiltins;
11
- constructor(context, expander, pathExpander, jobManager, jobBuiltins) {
12
- this.context = context;
13
- this.expander = expander;
14
- this.pathExpander = pathExpander;
15
- this.jobManager = jobManager;
16
- this.jobBuiltins = jobBuiltins;
17
- }
18
- /**
19
- * Execute a builtin command
20
- * Returns null if the command is not a builtin
21
- */
22
- async execute(name, args) {
23
- const builtinMethod = this.getBuiltinMethod(name);
24
- if (!builtinMethod) {
25
- return null;
26
- }
27
- return builtinMethod.call(this, args);
28
- }
29
- /**
30
- * Get the builtin method for a command name
31
- */
32
- getBuiltinMethod(name) {
33
- const builtins = {
34
- 'cd': this.builtin_cd.bind(this),
35
- 'pwd': this.builtin_pwd.bind(this),
36
- 'echo': this.builtin_echo.bind(this),
37
- // Will add all 38 builtins here
38
- };
39
- return builtins[name] || null;
40
- }
41
- // ========== BUILTIN IMPLEMENTATIONS ==========
42
- async builtin_cd(_args) {
43
- // TODO: Move full implementation from shell-executor.ts
44
- return { stdout: '', stderr: 'cd: stub', exitCode: 1, success: false };
45
- }
46
- async builtin_pwd(_args) {
47
- return { stdout: this.context.cwd + '\n', stderr: '', exitCode: 0, success: true };
48
- }
49
- async builtin_echo(args) {
50
- return { stdout: args.join(' ') + '\n', stderr: '', exitCode: 0, success: true };
51
- }
52
- }