@qodalis/cli-files 2.0.0-beta.8 → 2.0.0-rc.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.
package/public-api.d.mts CHANGED
@@ -1,5 +1,5 @@
1
- import * as _qodalis_cli_core from '@qodalis/cli-core';
2
- import { ICliOwnership, ICliCommandProcessor, CliProcessCommand, ICliExecutionContext, ICliFileTransferService, ICliFileEntry, ICliCompletionProvider, ICliCompletionContext, ICliModule } from '@qodalis/cli-core';
1
+ import { ICliOwnership, CliAccessAction, ICliCommandProcessor, CliProcessCommand, ICliExecutionContext, CliHeadersProvider, ICliFileTransferService, ICliFileEntry, ICliCompletionProvider, ICliCompletionContext, ICliConfigurableModule } from '@qodalis/cli-core';
2
+ import { Subscription } from 'rxjs';
3
3
 
4
4
  /**
5
5
  * Represents a node in the virtual filesystem (file or directory).
@@ -27,7 +27,18 @@ interface IFileNode {
27
27
  linkTarget?: string;
28
28
  }
29
29
 
30
- declare const IFileSystemService_TOKEN = "cli-file-system-service";
30
+ declare const IFileSystemService_TOKEN: any;
31
+ /**
32
+ * Decides whether the current principal may act on a node. Set by the files
33
+ * module from the generic authorization layer (`cliCanAccess`); when no policy
34
+ * is set (no auth module loaded) every operation is allowed.
35
+ */
36
+ interface CliFileAccessPolicy {
37
+ /** rwx check on a file or directory */
38
+ canAccess(node: IFileNode, action: CliAccessAction): boolean;
39
+ /** May the principal chmod/chown this node (owner, or `files:chown` / `files:admin`) */
40
+ canChangeOwnership(node: IFileNode, newOwnership?: ICliOwnership): boolean;
41
+ }
31
42
  /**
32
43
  * Abstraction for virtual filesystem operations.
33
44
  */
@@ -51,6 +62,17 @@ interface IFileSystemService {
51
62
  move(src: string, dest: string): void;
52
63
  chmod(path: string, permissions: string): void;
53
64
  chown(path: string, ownership: ICliOwnership): void;
65
+ setAccessPolicy?(policy?: CliFileAccessPolicy): void;
66
+ /** False when the current principal may not reach `path` (needs `x` on every parent) */
67
+ canTraverse?(path: string): boolean;
68
+ /** Run `fn` without access checks (system tasks such as creating home directories) */
69
+ runAsSystem?<T>(fn: () => T): T;
70
+ /**
71
+ * System task (no access checks): give every node owned by `fromUid`
72
+ * (case-insensitive) to `toUid`, e.g. after a user was renamed or deleted.
73
+ * Returns the number of nodes changed.
74
+ */
75
+ reassignOwner?(fromUid: string, toUid: string): number;
54
76
  initialize(): Promise<void>;
55
77
  persist(): Promise<void>;
56
78
  }
@@ -58,7 +80,7 @@ interface IFileSystemService {
58
80
  declare class CliLsCommandProcessor implements ICliCommandProcessor {
59
81
  command: string;
60
82
  description: string;
61
- author: _qodalis_cli_core.ICliCommandAuthor;
83
+ author: any;
62
84
  version: string;
63
85
  acceptsRawInput: boolean;
64
86
  metadata: {
@@ -75,38 +97,42 @@ declare class CliLsCommandProcessor implements ICliCommandProcessor {
75
97
  processCommand(command: CliProcessCommand, context: ICliExecutionContext): Promise<void>;
76
98
  writeDescription(context: ICliExecutionContext): void;
77
99
  private writeLongFormat;
100
+ private humanReadable;
101
+ private formatSize;
78
102
  private writeShortFormat;
79
103
  }
80
104
 
81
105
  declare class CliCdCommandProcessor implements ICliCommandProcessor {
82
106
  command: string;
83
107
  description: string;
84
- author: _qodalis_cli_core.ICliCommandAuthor;
108
+ author: any;
85
109
  version: string;
86
110
  acceptsRawInput: boolean;
87
111
  metadata: {
88
112
  icon: string;
89
113
  module: string;
90
114
  };
115
+ writeDescription(context: ICliExecutionContext): void;
91
116
  processCommand(command: CliProcessCommand, context: ICliExecutionContext): Promise<void>;
92
117
  }
93
118
 
94
119
  declare class CliPwdCommandProcessor implements ICliCommandProcessor {
95
120
  command: string;
96
121
  description: string;
97
- author: _qodalis_cli_core.ICliCommandAuthor;
122
+ author: any;
98
123
  version: string;
99
124
  metadata: {
100
125
  icon: string;
101
126
  module: string;
102
127
  };
128
+ writeDescription(context: ICliExecutionContext): void;
103
129
  processCommand(command: CliProcessCommand, context: ICliExecutionContext): Promise<void>;
104
130
  }
105
131
 
106
132
  declare class CliMkdirCommandProcessor implements ICliCommandProcessor {
107
133
  command: string;
108
134
  description: string;
109
- author: _qodalis_cli_core.ICliCommandAuthor;
135
+ author: any;
110
136
  version: string;
111
137
  acceptsRawInput: boolean;
112
138
  valueRequired: boolean;
@@ -121,13 +147,14 @@ declare class CliMkdirCommandProcessor implements ICliCommandProcessor {
121
147
  required: boolean;
122
148
  type: "boolean";
123
149
  }[];
150
+ writeDescription(context: ICliExecutionContext): void;
124
151
  processCommand(command: CliProcessCommand, context: ICliExecutionContext): Promise<void>;
125
152
  }
126
153
 
127
154
  declare class CliRmdirCommandProcessor implements ICliCommandProcessor {
128
155
  command: string;
129
156
  description: string;
130
- author: _qodalis_cli_core.ICliCommandAuthor;
157
+ author: any;
131
158
  version: string;
132
159
  acceptsRawInput: boolean;
133
160
  valueRequired: boolean;
@@ -135,13 +162,14 @@ declare class CliRmdirCommandProcessor implements ICliCommandProcessor {
135
162
  icon: string;
136
163
  module: string;
137
164
  };
165
+ writeDescription(context: ICliExecutionContext): void;
138
166
  processCommand(command: CliProcessCommand, context: ICliExecutionContext): Promise<void>;
139
167
  }
140
168
 
141
169
  declare class CliTouchCommandProcessor implements ICliCommandProcessor {
142
170
  command: string;
143
171
  description: string;
144
- author: _qodalis_cli_core.ICliCommandAuthor;
172
+ author: any;
145
173
  version: string;
146
174
  acceptsRawInput: boolean;
147
175
  valueRequired: boolean;
@@ -149,13 +177,14 @@ declare class CliTouchCommandProcessor implements ICliCommandProcessor {
149
177
  icon: string;
150
178
  module: string;
151
179
  };
180
+ writeDescription(context: ICliExecutionContext): void;
152
181
  processCommand(command: CliProcessCommand, context: ICliExecutionContext): Promise<void>;
153
182
  }
154
183
 
155
184
  declare class CliCatCommandProcessor implements ICliCommandProcessor {
156
185
  command: string;
157
186
  description: string;
158
- author: _qodalis_cli_core.ICliCommandAuthor;
187
+ author: any;
159
188
  version: string;
160
189
  acceptsRawInput: boolean;
161
190
  valueRequired: boolean;
@@ -163,13 +192,14 @@ declare class CliCatCommandProcessor implements ICliCommandProcessor {
163
192
  icon: string;
164
193
  module: string;
165
194
  };
195
+ writeDescription(context: ICliExecutionContext): void;
166
196
  processCommand(command: CliProcessCommand, context: ICliExecutionContext): Promise<void>;
167
197
  }
168
198
 
169
199
  declare class CliEchoCommandProcessor implements ICliCommandProcessor {
170
200
  command: string;
171
201
  description: string;
172
- author: _qodalis_cli_core.ICliCommandAuthor;
202
+ author: any;
173
203
  version: string;
174
204
  acceptsRawInput: boolean;
175
205
  extendsProcessor: boolean;
@@ -178,13 +208,14 @@ declare class CliEchoCommandProcessor implements ICliCommandProcessor {
178
208
  icon: string;
179
209
  module: string;
180
210
  };
211
+ writeDescription(context: ICliExecutionContext): void;
181
212
  processCommand(command: CliProcessCommand, context: ICliExecutionContext): Promise<void>;
182
213
  }
183
214
 
184
215
  declare class CliRmCommandProcessor implements ICliCommandProcessor {
185
216
  command: string;
186
217
  description: string;
187
- author: _qodalis_cli_core.ICliCommandAuthor;
218
+ author: any;
188
219
  version: string;
189
220
  acceptsRawInput: boolean;
190
221
  valueRequired: boolean;
@@ -199,13 +230,14 @@ declare class CliRmCommandProcessor implements ICliCommandProcessor {
199
230
  required: boolean;
200
231
  type: "boolean";
201
232
  }[];
233
+ writeDescription(context: ICliExecutionContext): void;
202
234
  processCommand(command: CliProcessCommand, context: ICliExecutionContext): Promise<void>;
203
235
  }
204
236
 
205
237
  declare class CliCpCommandProcessor implements ICliCommandProcessor {
206
238
  command: string;
207
239
  description: string;
208
- author: _qodalis_cli_core.ICliCommandAuthor;
240
+ author: any;
209
241
  version: string;
210
242
  acceptsRawInput: boolean;
211
243
  metadata: {
@@ -219,6 +251,7 @@ declare class CliCpCommandProcessor implements ICliCommandProcessor {
219
251
  required: boolean;
220
252
  type: "boolean";
221
253
  }[];
254
+ writeDescription(context: ICliExecutionContext): void;
222
255
  processCommand(command: CliProcessCommand, context: ICliExecutionContext): Promise<void>;
223
256
  private parseArgs;
224
257
  }
@@ -226,13 +259,14 @@ declare class CliCpCommandProcessor implements ICliCommandProcessor {
226
259
  declare class CliMvCommandProcessor implements ICliCommandProcessor {
227
260
  command: string;
228
261
  description: string;
229
- author: _qodalis_cli_core.ICliCommandAuthor;
262
+ author: any;
230
263
  version: string;
231
264
  acceptsRawInput: boolean;
232
265
  metadata: {
233
266
  icon: string;
234
267
  module: string;
235
268
  };
269
+ writeDescription(context: ICliExecutionContext): void;
236
270
  processCommand(command: CliProcessCommand, context: ICliExecutionContext): Promise<void>;
237
271
  private parseArgs;
238
272
  }
@@ -240,7 +274,7 @@ declare class CliMvCommandProcessor implements ICliCommandProcessor {
240
274
  declare class CliTreeCommandProcessor implements ICliCommandProcessor {
241
275
  command: string;
242
276
  description: string;
243
- author: _qodalis_cli_core.ICliCommandAuthor;
277
+ author: any;
244
278
  version: string;
245
279
  acceptsRawInput: boolean;
246
280
  metadata: {
@@ -254,14 +288,17 @@ declare class CliTreeCommandProcessor implements ICliCommandProcessor {
254
288
  required: boolean;
255
289
  type: "number";
256
290
  }[];
291
+ writeDescription(context: ICliExecutionContext): void;
257
292
  processCommand(command: CliProcessCommand, context: ICliExecutionContext): Promise<void>;
293
+ /** File system of the running command (listing goes through access checks) */
294
+ private fs?;
258
295
  private printTree;
259
296
  }
260
297
 
261
298
  declare class CliHeadCommandProcessor implements ICliCommandProcessor {
262
299
  command: string;
263
300
  description: string;
264
- author: _qodalis_cli_core.ICliCommandAuthor;
301
+ author: any;
265
302
  version: string;
266
303
  acceptsRawInput: boolean;
267
304
  valueRequired: boolean;
@@ -276,6 +313,7 @@ declare class CliHeadCommandProcessor implements ICliCommandProcessor {
276
313
  required: boolean;
277
314
  type: "number";
278
315
  }[];
316
+ writeDescription(context: ICliExecutionContext): void;
279
317
  processCommand(command: CliProcessCommand, context: ICliExecutionContext): Promise<void>;
280
318
  private parsePaths;
281
319
  }
@@ -283,7 +321,7 @@ declare class CliHeadCommandProcessor implements ICliCommandProcessor {
283
321
  declare class CliTailCommandProcessor implements ICliCommandProcessor {
284
322
  command: string;
285
323
  description: string;
286
- author: _qodalis_cli_core.ICliCommandAuthor;
324
+ author: any;
287
325
  version: string;
288
326
  acceptsRawInput: boolean;
289
327
  valueRequired: boolean;
@@ -298,6 +336,7 @@ declare class CliTailCommandProcessor implements ICliCommandProcessor {
298
336
  required: boolean;
299
337
  type: "number";
300
338
  }[];
339
+ writeDescription(context: ICliExecutionContext): void;
301
340
  processCommand(command: CliProcessCommand, context: ICliExecutionContext): Promise<void>;
302
341
  private parsePaths;
303
342
  }
@@ -305,7 +344,7 @@ declare class CliTailCommandProcessor implements ICliCommandProcessor {
305
344
  declare class CliWcCommandProcessor implements ICliCommandProcessor {
306
345
  command: string;
307
346
  description: string;
308
- author: _qodalis_cli_core.ICliCommandAuthor;
347
+ author: any;
309
348
  version: string;
310
349
  acceptsRawInput: boolean;
311
350
  valueRequired: boolean;
@@ -320,14 +359,17 @@ declare class CliWcCommandProcessor implements ICliCommandProcessor {
320
359
  required: boolean;
321
360
  type: "boolean";
322
361
  }[];
362
+ writeDescription(context: ICliExecutionContext): void;
323
363
  processCommand(command: CliProcessCommand, context: ICliExecutionContext): Promise<void>;
364
+ /** Counts like Unix wc: lines are newline characters. */
365
+ private count;
324
366
  private parsePaths;
325
367
  }
326
368
 
327
369
  declare class CliFindCommandProcessor implements ICliCommandProcessor {
328
370
  command: string;
329
371
  description: string;
330
- author: _qodalis_cli_core.ICliCommandAuthor;
372
+ author: any;
331
373
  version: string;
332
374
  acceptsRawInput: boolean;
333
375
  metadata: {
@@ -345,16 +387,23 @@ declare class CliFindCommandProcessor implements ICliCommandProcessor {
345
387
  required: boolean;
346
388
  type: "number";
347
389
  })[];
390
+ writeDescription(context: ICliExecutionContext): void;
348
391
  processCommand(command: CliProcessCommand, context: ICliExecutionContext): Promise<void>;
392
+ /** `--name` matches case-sensitively, `--iname` ignoring case. */
393
+ private nameRegex;
394
+ private matches;
349
395
  private parseSearchPath;
350
396
  private globToRegex;
397
+ /** File system of the running command (listing goes through access checks) */
398
+ private fs?;
399
+ /** Lists the children of `node`, which are at `depth` (1 = direct children). */
351
400
  private walk;
352
401
  }
353
402
 
354
403
  declare class CliGrepCommandProcessor implements ICliCommandProcessor {
355
404
  command: string;
356
405
  description: string;
357
- author: _qodalis_cli_core.ICliCommandAuthor;
406
+ author: any;
358
407
  version: string;
359
408
  acceptsRawInput: boolean;
360
409
  metadata: {
@@ -368,7 +417,13 @@ declare class CliGrepCommandProcessor implements ICliCommandProcessor {
368
417
  required: boolean;
369
418
  type: "boolean";
370
419
  }[];
420
+ writeDescription(context: ICliExecutionContext): void;
371
421
  processCommand(command: CliProcessCommand, context: ICliExecutionContext): Promise<void>;
422
+ /**
423
+ * As Unix grep: 0 when a line matched, 1 when none did, 2 after an
424
+ * error (so `if grep -q ...` and `grep x f && ...` work).
425
+ */
426
+ private exitStatus;
372
427
  private grepContent;
373
428
  private parseArgs;
374
429
  private collectFiles;
@@ -377,7 +432,7 @@ declare class CliGrepCommandProcessor implements ICliCommandProcessor {
377
432
  declare class CliTacCommandProcessor implements ICliCommandProcessor {
378
433
  command: string;
379
434
  description: string;
380
- author: _qodalis_cli_core.ICliCommandAuthor;
435
+ author: any;
381
436
  version: string;
382
437
  acceptsRawInput: boolean;
383
438
  valueRequired: boolean;
@@ -385,6 +440,7 @@ declare class CliTacCommandProcessor implements ICliCommandProcessor {
385
440
  icon: string;
386
441
  module: string;
387
442
  };
443
+ writeDescription(context: ICliExecutionContext): void;
388
444
  processCommand(command: CliProcessCommand, context: ICliExecutionContext): Promise<void>;
389
445
  private parsePaths;
390
446
  }
@@ -392,7 +448,7 @@ declare class CliTacCommandProcessor implements ICliCommandProcessor {
392
448
  declare class CliBasenameCommandProcessor implements ICliCommandProcessor {
393
449
  command: string;
394
450
  description: string;
395
- author: _qodalis_cli_core.ICliCommandAuthor;
451
+ author: any;
396
452
  version: string;
397
453
  acceptsRawInput: boolean;
398
454
  valueRequired: boolean;
@@ -400,6 +456,7 @@ declare class CliBasenameCommandProcessor implements ICliCommandProcessor {
400
456
  icon: string;
401
457
  module: string;
402
458
  };
459
+ writeDescription(context: ICliExecutionContext): void;
403
460
  processCommand(command: CliProcessCommand, context: ICliExecutionContext): Promise<void>;
404
461
  private parseTokens;
405
462
  }
@@ -407,7 +464,7 @@ declare class CliBasenameCommandProcessor implements ICliCommandProcessor {
407
464
  declare class CliDirnameCommandProcessor implements ICliCommandProcessor {
408
465
  command: string;
409
466
  description: string;
410
- author: _qodalis_cli_core.ICliCommandAuthor;
467
+ author: any;
411
468
  version: string;
412
469
  acceptsRawInput: boolean;
413
470
  valueRequired: boolean;
@@ -415,6 +472,7 @@ declare class CliDirnameCommandProcessor implements ICliCommandProcessor {
415
472
  icon: string;
416
473
  module: string;
417
474
  };
475
+ writeDescription(context: ICliExecutionContext): void;
418
476
  processCommand(command: CliProcessCommand, context: ICliExecutionContext): Promise<void>;
419
477
  private parseTokens;
420
478
  }
@@ -422,7 +480,7 @@ declare class CliDirnameCommandProcessor implements ICliCommandProcessor {
422
480
  declare class CliSortCommandProcessor implements ICliCommandProcessor {
423
481
  command: string;
424
482
  description: string;
425
- author: _qodalis_cli_core.ICliCommandAuthor;
483
+ author: any;
426
484
  version: string;
427
485
  acceptsRawInput: boolean;
428
486
  valueRequired: boolean;
@@ -443,6 +501,7 @@ declare class CliSortCommandProcessor implements ICliCommandProcessor {
443
501
  required: boolean;
444
502
  type: "string";
445
503
  })[];
504
+ writeDescription(context: ICliExecutionContext): void;
446
505
  processCommand(command: CliProcessCommand, context: ICliExecutionContext): Promise<void>;
447
506
  private parsePaths;
448
507
  }
@@ -450,7 +509,7 @@ declare class CliSortCommandProcessor implements ICliCommandProcessor {
450
509
  declare class CliUniqCommandProcessor implements ICliCommandProcessor {
451
510
  command: string;
452
511
  description: string;
453
- author: _qodalis_cli_core.ICliCommandAuthor;
512
+ author: any;
454
513
  version: string;
455
514
  acceptsRawInput: boolean;
456
515
  valueRequired: boolean;
@@ -465,6 +524,7 @@ declare class CliUniqCommandProcessor implements ICliCommandProcessor {
465
524
  required: boolean;
466
525
  type: "boolean";
467
526
  }[];
527
+ writeDescription(context: ICliExecutionContext): void;
468
528
  processCommand(command: CliProcessCommand, context: ICliExecutionContext): Promise<void>;
469
529
  private parsePaths;
470
530
  }
@@ -472,7 +532,7 @@ declare class CliUniqCommandProcessor implements ICliCommandProcessor {
472
532
  declare class CliCutCommandProcessor implements ICliCommandProcessor {
473
533
  command: string;
474
534
  description: string;
475
- author: _qodalis_cli_core.ICliCommandAuthor;
535
+ author: any;
476
536
  version: string;
477
537
  acceptsRawInput: boolean;
478
538
  valueRequired: boolean;
@@ -487,6 +547,7 @@ declare class CliCutCommandProcessor implements ICliCommandProcessor {
487
547
  required: boolean;
488
548
  type: "string";
489
549
  }[];
550
+ writeDescription(context: ICliExecutionContext): void;
490
551
  processCommand(command: CliProcessCommand, context: ICliExecutionContext): Promise<void>;
491
552
  private parseSpec;
492
553
  private resolveIndices;
@@ -496,7 +557,7 @@ declare class CliCutCommandProcessor implements ICliCommandProcessor {
496
557
  declare class CliPasteCommandProcessor implements ICliCommandProcessor {
497
558
  command: string;
498
559
  description: string;
499
- author: _qodalis_cli_core.ICliCommandAuthor;
560
+ author: any;
500
561
  version: string;
501
562
  acceptsRawInput: boolean;
502
563
  valueRequired: boolean;
@@ -517,14 +578,21 @@ declare class CliPasteCommandProcessor implements ICliCommandProcessor {
517
578
  required: boolean;
518
579
  type: "boolean";
519
580
  })[];
581
+ writeDescription(context: ICliExecutionContext): void;
520
582
  processCommand(command: CliProcessCommand, context: ICliExecutionContext): Promise<void>;
583
+ /** `-d` list: each character in turn, with \t, \n, \\ and \0 (empty) escapes. */
584
+ private parseDelimiters;
585
+ /**
586
+ * The file operands. The engine drops a lone `-` from the value, so with
587
+ * piped input they are read from the raw command line to keep it.
588
+ */
521
589
  private parsePaths;
522
590
  }
523
591
 
524
592
  declare class CliTrCommandProcessor implements ICliCommandProcessor {
525
593
  command: string;
526
594
  description: string;
527
- author: _qodalis_cli_core.ICliCommandAuthor;
595
+ author: any;
528
596
  version: string;
529
597
  acceptsRawInput: boolean;
530
598
  valueRequired: boolean;
@@ -534,11 +602,14 @@ declare class CliTrCommandProcessor implements ICliCommandProcessor {
534
602
  };
535
603
  parameters: {
536
604
  name: string;
605
+ aliases: string[];
537
606
  description: string;
538
607
  required: boolean;
539
608
  type: "boolean";
540
609
  }[];
610
+ writeDescription(context: ICliExecutionContext): void;
541
611
  processCommand(command: CliProcessCommand, context: ICliExecutionContext): Promise<void>;
612
+ private fail;
542
613
  private deleteChars;
543
614
  private squeezeChars;
544
615
  private translateChars;
@@ -547,7 +618,7 @@ declare class CliTrCommandProcessor implements ICliCommandProcessor {
547
618
  declare class CliStatCommandProcessor implements ICliCommandProcessor {
548
619
  command: string;
549
620
  description: string;
550
- author: _qodalis_cli_core.ICliCommandAuthor;
621
+ author: any;
551
622
  version: string;
552
623
  acceptsRawInput: boolean;
553
624
  valueRequired: boolean;
@@ -556,6 +627,7 @@ declare class CliStatCommandProcessor implements ICliCommandProcessor {
556
627
  module: string;
557
628
  };
558
629
  parameters: never[];
630
+ writeDescription(context: ICliExecutionContext): void;
559
631
  processCommand(command: CliProcessCommand, context: ICliExecutionContext): Promise<void>;
560
632
  private parsePaths;
561
633
  }
@@ -563,7 +635,7 @@ declare class CliStatCommandProcessor implements ICliCommandProcessor {
563
635
  declare class CliChmodCommandProcessor implements ICliCommandProcessor {
564
636
  command: string;
565
637
  description: string;
566
- author: _qodalis_cli_core.ICliCommandAuthor;
638
+ author: any;
567
639
  version: string;
568
640
  acceptsRawInput: boolean;
569
641
  valueRequired: boolean;
@@ -577,6 +649,7 @@ declare class CliChmodCommandProcessor implements ICliCommandProcessor {
577
649
  required: boolean;
578
650
  type: "boolean";
579
651
  }[];
652
+ writeDescription(context: ICliExecutionContext): void;
580
653
  processCommand(command: CliProcessCommand, context: ICliExecutionContext): Promise<void>;
581
654
  private parseArgs;
582
655
  private resolvePermissions;
@@ -587,7 +660,7 @@ declare class CliChmodCommandProcessor implements ICliCommandProcessor {
587
660
  declare class CliChownCommandProcessor implements ICliCommandProcessor {
588
661
  command: string;
589
662
  description: string;
590
- author: _qodalis_cli_core.ICliCommandAuthor;
663
+ author: any;
591
664
  version: string;
592
665
  acceptsRawInput: boolean;
593
666
  valueRequired: boolean;
@@ -601,6 +674,7 @@ declare class CliChownCommandProcessor implements ICliCommandProcessor {
601
674
  required: boolean;
602
675
  type: "boolean";
603
676
  }[];
677
+ writeDescription(context: ICliExecutionContext): void;
604
678
  processCommand(command: CliProcessCommand, context: ICliExecutionContext): Promise<void>;
605
679
  private parseArgs;
606
680
  /** Parse "user:group", "user:", ":group", or "user" */
@@ -611,10 +685,9 @@ declare class CliChownCommandProcessor implements ICliCommandProcessor {
611
685
  declare class CliDuCommandProcessor implements ICliCommandProcessor {
612
686
  command: string;
613
687
  description: string;
614
- author: _qodalis_cli_core.ICliCommandAuthor;
688
+ author: any;
615
689
  version: string;
616
690
  acceptsRawInput: boolean;
617
- valueRequired: boolean;
618
691
  metadata: {
619
692
  icon: string;
620
693
  module: string;
@@ -632,8 +705,11 @@ declare class CliDuCommandProcessor implements ICliCommandProcessor {
632
705
  required: boolean;
633
706
  type: "number";
634
707
  })[];
708
+ writeDescription(context: ICliExecutionContext): void;
635
709
  processCommand(command: CliProcessCommand, context: ICliExecutionContext): Promise<void>;
636
710
  private parseArgs;
711
+ /** File system of the running command (listing goes through access checks) */
712
+ private fs?;
637
713
  private collectSizes;
638
714
  private formatSize;
639
715
  }
@@ -641,7 +717,7 @@ declare class CliDuCommandProcessor implements ICliCommandProcessor {
641
717
  declare class CliLnCommandProcessor implements ICliCommandProcessor {
642
718
  command: string;
643
719
  description: string;
644
- author: _qodalis_cli_core.ICliCommandAuthor;
720
+ author: any;
645
721
  version: string;
646
722
  acceptsRawInput: boolean;
647
723
  valueRequired: boolean;
@@ -649,12 +725,20 @@ declare class CliLnCommandProcessor implements ICliCommandProcessor {
649
725
  icon: string;
650
726
  module: string;
651
727
  };
652
- parameters: {
728
+ parameters: ({
653
729
  name: string;
654
730
  description: string;
655
731
  required: boolean;
656
732
  type: "boolean";
657
- }[];
733
+ aliases?: undefined;
734
+ } | {
735
+ name: string;
736
+ aliases: string[];
737
+ description: string;
738
+ required: boolean;
739
+ type: "boolean";
740
+ })[];
741
+ writeDescription(context: ICliExecutionContext): void;
658
742
  processCommand(command: CliProcessCommand, context: ICliExecutionContext): Promise<void>;
659
743
  private parseArgs;
660
744
  }
@@ -662,7 +746,7 @@ declare class CliLnCommandProcessor implements ICliCommandProcessor {
662
746
  declare class CliSedCommandProcessor implements ICliCommandProcessor {
663
747
  command: string;
664
748
  description: string;
665
- author: _qodalis_cli_core.ICliCommandAuthor;
749
+ author: any;
666
750
  version: string;
667
751
  acceptsRawInput: boolean;
668
752
  metadata: {
@@ -680,21 +764,41 @@ declare class CliSedCommandProcessor implements ICliCommandProcessor {
680
764
  aliases: string[];
681
765
  description: string;
682
766
  required: boolean;
683
- type: "string";
767
+ type: "array";
684
768
  })[];
769
+ writeDescription(context: ICliExecutionContext): void;
685
770
  processCommand(command: CliProcessCommand, context: ICliExecutionContext): Promise<void>;
771
+ private writeLines;
772
+ /** Runs the script over the lines and returns the output lines. */
773
+ private run;
774
+ /** `&` is the match, `\1`..`\9` the groups, `\n` a newline, `\x` a literal x. */
775
+ private expandReplacement;
686
776
  private parseRawCommand;
687
777
  private tokenize;
688
- private parseExpression;
778
+ /** Commands of a script, separated by `;` or newlines. */
779
+ private parseScript;
780
+ private parseCommand;
689
781
  private parseAddress;
782
+ /**
783
+ * Text up to the next unescaped delimiter, escapes kept (an escaped
784
+ * delimiter becomes the plain character when it has no regex meaning).
785
+ */
786
+ private readDelimited;
787
+ /**
788
+ * Basic regular expressions use \( \) \{ \} \+ \? \| for groups and
789
+ * operators. When a pattern uses them (or never in -E mode), they are
790
+ * turned into the JavaScript form and the bare characters made literal.
791
+ */
792
+ private toJsRegex;
690
793
  private parseSubstitution;
691
794
  private addressMatches;
795
+ private singleMatches;
692
796
  }
693
797
 
694
798
  declare class CliAwkCommandProcessor implements ICliCommandProcessor {
695
799
  command: string;
696
800
  description: string;
697
- author: _qodalis_cli_core.ICliCommandAuthor;
801
+ author: any;
698
802
  version: string;
699
803
  acceptsRawInput: boolean;
700
804
  metadata: {
@@ -708,8 +812,16 @@ declare class CliAwkCommandProcessor implements ICliCommandProcessor {
708
812
  required: boolean;
709
813
  type: "string";
710
814
  }[];
815
+ writeDescription(context: ICliExecutionContext): void;
711
816
  processCommand(command: CliProcessCommand, context: ICliExecutionContext): Promise<void>;
817
+ /**
818
+ * The program is the first operand, usually quoted. Unquoted, it may span
819
+ * several words (`awk {print $1} file`): it is then everything before the
820
+ * trailing operands that are existing files, or the whole value with
821
+ * piped input.
822
+ */
712
823
  private parseArgs;
824
+ private bracesBalanced;
713
825
  private parseProgram;
714
826
  private findMatchingBrace;
715
827
  private matchesPattern;
@@ -729,7 +841,7 @@ declare class CliAwkCommandProcessor implements ICliCommandProcessor {
729
841
  declare class CliDiffCommandProcessor implements ICliCommandProcessor {
730
842
  command: string;
731
843
  description: string;
732
- author: _qodalis_cli_core.ICliCommandAuthor;
844
+ author: any;
733
845
  version: string;
734
846
  acceptsRawInput: boolean;
735
847
  valueRequired: boolean;
@@ -744,6 +856,7 @@ declare class CliDiffCommandProcessor implements ICliCommandProcessor {
744
856
  required: boolean;
745
857
  type: "boolean";
746
858
  }[];
859
+ writeDescription(context: ICliExecutionContext): void;
747
860
  processCommand(command: CliProcessCommand, context: ICliExecutionContext): Promise<void>;
748
861
  private linesEqual;
749
862
  private computeLCS;
@@ -755,7 +868,7 @@ declare class CliDiffCommandProcessor implements ICliCommandProcessor {
755
868
  declare class CliTeeCommandProcessor implements ICliCommandProcessor {
756
869
  command: string;
757
870
  description: string;
758
- author: _qodalis_cli_core.ICliCommandAuthor;
871
+ author: any;
759
872
  version: string;
760
873
  acceptsRawInput: boolean;
761
874
  valueRequired: boolean;
@@ -770,15 +883,15 @@ declare class CliTeeCommandProcessor implements ICliCommandProcessor {
770
883
  required: boolean;
771
884
  type: "boolean";
772
885
  }[];
886
+ writeDescription(context: ICliExecutionContext): void;
773
887
  processCommand(command: CliProcessCommand, context: ICliExecutionContext): Promise<void>;
774
888
  private getAllPaths;
775
- private parseArgs;
776
889
  }
777
890
 
778
891
  declare class CliXargsCommandProcessor implements ICliCommandProcessor {
779
892
  command: string;
780
893
  description: string;
781
- author: _qodalis_cli_core.ICliCommandAuthor;
894
+ author: any;
782
895
  version: string;
783
896
  acceptsRawInput: boolean;
784
897
  valueRequired: boolean;
@@ -799,28 +912,24 @@ declare class CliXargsCommandProcessor implements ICliCommandProcessor {
799
912
  required: boolean;
800
913
  type: "number";
801
914
  })[];
915
+ writeDescription(context: ICliExecutionContext): void;
802
916
  processCommand(command: CliProcessCommand, context: ICliExecutionContext): Promise<void>;
803
- private getAllNonFlagTokens;
804
917
  private escapeRegex;
805
- private parseArgs;
806
918
  }
807
919
 
808
920
  /**
809
921
  * Execute a script file containing CLI commands.
810
922
  *
811
- * Supported syntax inside scripts:
812
- * - One command per line (pipes, operators, redirects all work)
813
- * - `# comment` lines and blank lines are ignored
814
- * - `set -e` (default) — stop on first error
815
- * - `set +e` — continue on errors
816
- * - `VAR=value` — variable assignment (script-scoped)
817
- * - `$VAR` / `${VAR}` — variable substitution
923
+ * Scripts run through the engine's shell runner (`@qodalis/cli`
924
+ * `runScript`): commands, `;`, comments, `set -e`/`set +e`, `VAR=value`,
925
+ * `if`/`elif`/`else`/`fi`, `for`/`while`/`until` loops, `break`/`continue`,
926
+ * `exit`, and `test`/`[ ]` conditions.
818
927
  */
819
928
  declare class CliShCommandProcessor implements ICliCommandProcessor {
820
929
  command: string;
821
930
  aliases: string[];
822
931
  description: string;
823
- author: _qodalis_cli_core.ICliCommandAuthor;
932
+ author: any;
824
933
  version: string;
825
934
  acceptsRawInput: boolean;
826
935
  metadata: {
@@ -838,18 +947,38 @@ declare class CliShCommandProcessor implements ICliCommandProcessor {
838
947
  writeDescription(context: ICliExecutionContext): void;
839
948
  }
840
949
  /**
841
- * Parse and execute script content line by line.
842
- *
843
- * Exported so the executor can reuse it for `./script.sh` execution.
950
+ * Execute script content with the engine's shell runner (control flow,
951
+ * variables, `set -e`), the same one used for `./script.sh`.
844
952
  */
845
953
  declare function executeScript(content: string, context: ICliExecutionContext): Promise<void>;
846
954
 
955
+ /** Owner of system directories and of legacy nodes created without an owner */
956
+ declare const SYSTEM_OWNERSHIP: ICliOwnership;
957
+ /** Owner of files created while nobody is signed in */
958
+ declare const ANONYMOUS_OWNERSHIP: ICliOwnership;
847
959
  declare class IndexedDbFileSystemService implements IFileSystemService {
848
960
  private root;
849
961
  private cwd;
850
962
  private homePath;
851
963
  private currentUid;
852
964
  private currentGroups;
965
+ private accessPolicy?;
966
+ private systemDepth;
967
+ setAccessPolicy(policy?: CliFileAccessPolicy): void;
968
+ runAsSystem<T>(fn: () => T): T;
969
+ reassignOwner(fromUid: string, toUid: string): number;
970
+ canTraverse(path: string): boolean;
971
+ private get enforcing();
972
+ private deny;
973
+ /** `x` on every existing directory on the way to `resolved` (excluding the target). */
974
+ private assertTraverse;
975
+ private assertAccess;
976
+ /** Recursive delete: every directory inside must allow removing its entries (`w` + `x`, readable). */
977
+ private assertRemovableTree;
978
+ /** Copying reads everything it copies: `r` on every file, `r` + `x` on every directory. */
979
+ private assertReadableTree;
980
+ /** Creating/removing entries needs `w` and `x` on the containing directory. */
981
+ private assertModifyDir;
853
982
  setCurrentUser(uid: string, groups: string[]): void;
854
983
  private getDefaultOwnership;
855
984
  getCurrentDirectory(): string;
@@ -872,6 +1001,8 @@ declare class IndexedDbFileSystemService implements IFileSystemService {
872
1001
  chown(path: string, ownership: ICliOwnership): void;
873
1002
  initialize(): Promise<void>;
874
1003
  persist(): Promise<void>;
1004
+ /** A copy belongs to whoever made it (like `cp` without `-p`) */
1005
+ private ownedByCurrentUser;
875
1006
  private cloneNode;
876
1007
  private openDb;
877
1008
  private idbGet;
@@ -883,6 +1014,8 @@ declare class IndexedDbFileSystemService implements IFileSystemService {
883
1014
  interface ServerFileSystemOptions {
884
1015
  /** Base URL of the CLI server, e.g. 'http://localhost:8047' */
885
1016
  baseUrl: string;
1017
+ /** Custom headers sent with every request (e.g. auth tokens) */
1018
+ headers?: CliHeadersProvider;
886
1019
  }
887
1020
  /**
888
1021
  * IFileSystemService implementation that delegates operations to a CLI server's
@@ -901,6 +1034,7 @@ declare class ServerFileSystemService implements IFileSystemService {
901
1034
  private currentUid;
902
1035
  private currentGroups;
903
1036
  private readonly baseUrl;
1037
+ private readonly headersProvider;
904
1038
  constructor(options: ServerFileSystemOptions);
905
1039
  setCurrentUser(uid: string, groups: string[]): void;
906
1040
  private getDefaultOwnership;
@@ -965,6 +1099,35 @@ declare class VirtualFsFileTransferService implements ICliFileTransferService {
965
1099
  } | null>;
966
1100
  }
967
1101
 
1102
+ /** Permissions the files module understands. */
1103
+ declare const CliFilesPermissions: {
1104
+ /** Bypass all file permission checks */
1105
+ readonly Admin: "files:admin";
1106
+ /** chmod/chown files you do not own */
1107
+ readonly Chown: "files:chown";
1108
+ };
1109
+ /** Mode for newly created home directories (owner full, group read/traverse) */
1110
+ declare const HOME_DIR_PERMISSIONS = "rwxr-x---";
1111
+ /**
1112
+ * Access policy built on the generic authorization layer. Allows everything
1113
+ * when no authorization service is registered (no auth module loaded).
1114
+ */
1115
+ declare function createFileAccessPolicy(context: ICliExecutionContext): CliFileAccessPolicy;
1116
+ /**
1117
+ * Follow the signed-in user (from any auth module that provides
1118
+ * {@link ICliUserSessionService}): ownership for new files, home directory
1119
+ * creation and `~`, and moving to the home directory when the user changes.
1120
+ */
1121
+ declare function followUserSession(context: ICliExecutionContext, fs: IFileSystemService): Subscription | undefined;
1122
+ /**
1123
+ * Keep file ownership (stored by login name) in step with the accounts of
1124
+ * any auth module that emits {@link ICliUserEventService} events: a rename
1125
+ * moves the user's files to the new name, a deletion gives them to `root`, so
1126
+ * a later account with the same name never inherits them. Runs as a system
1127
+ * task (no rwx checks for the acting user). No-op without such a module.
1128
+ */
1129
+ declare function followUserAccounts(context: ICliExecutionContext, fs: IFileSystemService): Subscription | undefined;
1130
+
968
1131
  /**
969
1132
  * Provides tab-completion for file and directory names from the virtual filesystem.
970
1133
  * Priority 50 (checked before command/parameter providers for file-related commands).
@@ -987,9 +1150,15 @@ interface CliFilesModuleConfig {
987
1150
  */
988
1151
  showPathInPrompt?: boolean;
989
1152
  }
990
- interface ICliFilesModule extends ICliModule {
991
- configure(config: CliFilesModuleConfig): ICliModule;
1153
+ interface ICliFilesModule extends ICliConfigurableModule<CliFilesModuleConfig> {
1154
+ /** Subscription for drag-and-drop file uploads, cleaned up in onDestroy */
1155
+ _dragDropSubscription?: Subscription;
1156
+ /** Subscription following the signed-in user, cleaned up in onDestroy */
1157
+ _sessionSubscription?: Subscription;
1158
+ /** Subscription following account renames/deletions, cleaned up in onDestroy */
1159
+ _accountsSubscription?: Subscription;
992
1160
  }
993
1161
  declare const filesModule: ICliFilesModule;
994
1162
 
995
- export { CliAwkCommandProcessor, CliBasenameCommandProcessor, CliCatCommandProcessor, CliCdCommandProcessor, CliChmodCommandProcessor, CliChownCommandProcessor, CliCpCommandProcessor, CliCutCommandProcessor, CliDiffCommandProcessor, CliDirnameCommandProcessor, CliDuCommandProcessor, CliEchoCommandProcessor, type CliFilesModuleConfig, CliFindCommandProcessor, CliGrepCommandProcessor, CliHeadCommandProcessor, CliLnCommandProcessor, CliLsCommandProcessor, CliMkdirCommandProcessor, CliMvCommandProcessor, CliPasteCommandProcessor, CliPwdCommandProcessor, CliRmCommandProcessor, CliRmdirCommandProcessor, CliSedCommandProcessor, CliShCommandProcessor, CliSortCommandProcessor, CliStatCommandProcessor, CliTacCommandProcessor, CliTailCommandProcessor, CliTeeCommandProcessor, CliTouchCommandProcessor, CliTrCommandProcessor, CliTreeCommandProcessor, CliUniqCommandProcessor, CliWcCommandProcessor, CliXargsCommandProcessor, FilePathCompletionProvider, type IFileNode, type IFileSystemService, IFileSystemService_TOKEN, IndexedDbFileSystemService, type ServerFileSystemOptions, ServerFileSystemService, VirtualFsFileTransferService, executeScript, filesModule };
1163
+ export { ANONYMOUS_OWNERSHIP, CliAwkCommandProcessor, CliBasenameCommandProcessor, CliCatCommandProcessor, CliCdCommandProcessor, CliChmodCommandProcessor, CliChownCommandProcessor, CliCpCommandProcessor, CliCutCommandProcessor, CliDiffCommandProcessor, CliDirnameCommandProcessor, CliDuCommandProcessor, CliEchoCommandProcessor, CliFilesPermissions, CliFindCommandProcessor, CliGrepCommandProcessor, CliHeadCommandProcessor, CliLnCommandProcessor, CliLsCommandProcessor, CliMkdirCommandProcessor, CliMvCommandProcessor, CliPasteCommandProcessor, CliPwdCommandProcessor, CliRmCommandProcessor, CliRmdirCommandProcessor, CliSedCommandProcessor, CliShCommandProcessor, CliSortCommandProcessor, CliStatCommandProcessor, CliTacCommandProcessor, CliTailCommandProcessor, CliTeeCommandProcessor, CliTouchCommandProcessor, CliTrCommandProcessor, CliTreeCommandProcessor, CliUniqCommandProcessor, CliWcCommandProcessor, CliXargsCommandProcessor, FilePathCompletionProvider, HOME_DIR_PERMISSIONS, IFileSystemService_TOKEN, IndexedDbFileSystemService, SYSTEM_OWNERSHIP, ServerFileSystemService, VirtualFsFileTransferService, createFileAccessPolicy, executeScript, filesModule, followUserAccounts, followUserSession };
1164
+ export type { CliFileAccessPolicy, CliFilesModuleConfig, IFileNode, IFileSystemService, ServerFileSystemOptions };