@fnndsc/brasa 0.9.2 → 0.10.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/dist/buildinfo.json +1 -0
- package/dist/builtins/argumentTokens.d.ts +18 -0
- package/dist/builtins/argumentTokens.js +58 -0
- package/dist/builtins/argumentTokens.js.map +1 -0
- package/dist/builtins/executable.d.ts +3 -7
- package/dist/builtins/executable.js +32 -29
- package/dist/builtins/executable.js.map +1 -1
- package/dist/builtins/feedCreation.d.ts +23 -0
- package/dist/builtins/feedCreation.js +45 -0
- package/dist/builtins/feedCreation.js.map +1 -0
- package/dist/builtins/fs/cat.args.d.ts +36 -0
- package/dist/builtins/fs/cat.args.js +63 -0
- package/dist/builtins/fs/cat.args.js.map +1 -0
- package/dist/builtins/fs/cat.d.ts +2 -2
- package/dist/builtins/fs/cat.js +222 -101
- package/dist/builtins/fs/cat.js.map +1 -1
- package/dist/builtins/fs/cd.js +41 -5
- package/dist/builtins/fs/cd.js.map +1 -1
- package/dist/builtins/fs/cp.js +3 -2
- package/dist/builtins/fs/cp.js.map +1 -1
- package/dist/builtins/fs/download.d.ts +1 -1
- package/dist/builtins/fs/download.js +52 -13
- package/dist/builtins/fs/download.js.map +1 -1
- package/dist/builtins/fs/du.js +15 -1
- package/dist/builtins/fs/du.js.map +1 -1
- package/dist/builtins/fs/ls.js +10 -1
- package/dist/builtins/fs/ls.js.map +1 -1
- package/dist/builtins/fs/mv.js +7 -3
- package/dist/builtins/fs/mv.js.map +1 -1
- package/dist/builtins/fs/pull.args.d.ts +14 -1
- package/dist/builtins/fs/pull.args.js +72 -9
- package/dist/builtins/fs/pull.args.js.map +1 -1
- package/dist/builtins/fs/pull.d.ts +1 -0
- package/dist/builtins/fs/pull.js +191 -259
- package/dist/builtins/fs/pull.js.map +1 -1
- package/dist/builtins/fs/rm.js +4 -0
- package/dist/builtins/fs/rm.js.map +1 -1
- package/dist/builtins/fs/tree.js +7 -3
- package/dist/builtins/fs/tree.js.map +1 -1
- package/dist/builtins/fs/upload.js +29 -2
- package/dist/builtins/fs/upload.js.map +1 -1
- package/dist/builtins/help.d.ts +7 -0
- package/dist/builtins/help.js +144 -36
- package/dist/builtins/help.js.map +1 -1
- package/dist/builtins/index.d.ts +1 -0
- package/dist/builtins/index.js +1 -0
- package/dist/builtins/index.js.map +1 -1
- package/dist/builtins/net/cubepath.js +1 -2
- package/dist/builtins/net/cubepath.js.map +1 -1
- package/dist/builtins/net/pacs.d.ts +1 -0
- package/dist/builtins/net/pacs.js +5 -1
- package/dist/builtins/net/pacs.js.map +1 -1
- package/dist/builtins/net/pacsUtils.d.ts +4 -23
- package/dist/builtins/net/pacsUtils.js +11 -32
- package/dist/builtins/net/pacsUtils.js.map +1 -1
- package/dist/builtins/net/query.js +4 -1
- package/dist/builtins/net/query.js.map +1 -1
- package/dist/builtins/net/status.d.ts +14 -0
- package/dist/builtins/net/status.js +210 -0
- package/dist/builtins/net/status.js.map +1 -0
- package/dist/builtins/pluginExecute.d.ts +3 -2
- package/dist/builtins/pluginExecute.js +41 -70
- package/dist/builtins/pluginExecute.js.map +1 -1
- package/dist/builtins/pluginSelector.d.ts +15 -0
- package/dist/builtins/pluginSelector.js +21 -0
- package/dist/builtins/pluginSelector.js.map +1 -0
- package/dist/builtins/proc.js +106 -4
- package/dist/builtins/proc.js.map +1 -1
- package/dist/builtins/res/compute.js +8 -3
- package/dist/builtins/res/compute.js.map +1 -1
- package/dist/builtins/res/feed.js +3 -3
- package/dist/builtins/res/feed.js.map +1 -1
- package/dist/builtins/res/files.js +2 -2
- package/dist/builtins/res/files.js.map +1 -1
- package/dist/builtins/res/group.d.ts +1 -1
- package/dist/builtins/res/group.js +124 -7
- package/dist/builtins/res/group.js.map +1 -1
- package/dist/builtins/res/pipeline.args.d.ts +4 -0
- package/dist/builtins/res/pipeline.args.js +63 -12
- package/dist/builtins/res/pipeline.args.js.map +1 -1
- package/dist/builtins/res/pipeline.d.ts +3 -1
- package/dist/builtins/res/pipeline.js +155 -60
- package/dist/builtins/res/pipeline.js.map +1 -1
- package/dist/builtins/res/pipeline.manifest.d.ts +15 -0
- package/dist/builtins/res/pipeline.manifest.js +93 -0
- package/dist/builtins/res/pipeline.manifest.js.map +1 -0
- package/dist/builtins/res/plugin.js +16 -9
- package/dist/builtins/res/plugin.js.map +1 -1
- package/dist/builtins/res/plugininstance.js +2 -2
- package/dist/builtins/res/plugininstance.js.map +1 -1
- package/dist/builtins/res/pluginmeta.js +2 -2
- package/dist/builtins/res/pluginmeta.js.map +1 -1
- package/dist/builtins/res/tag.js +2 -2
- package/dist/builtins/res/tag.js.map +1 -1
- package/dist/builtins/res/user.d.ts +8 -0
- package/dist/builtins/res/user.js +87 -0
- package/dist/builtins/res/user.js.map +1 -0
- package/dist/builtins/res/workflow.js +2 -2
- package/dist/builtins/res/workflow.js.map +1 -1
- package/dist/builtins/store.js +24 -3
- package/dist/builtins/store.js.map +1 -1
- package/dist/builtins/sys/fortune.d.ts +9 -0
- package/dist/builtins/sys/fortune.js +16 -1
- package/dist/builtins/sys/fortune.js.map +1 -1
- package/dist/builtins/sys/whoami.d.ts +13 -1
- package/dist/builtins/sys/whoami.js +47 -2
- package/dist/builtins/sys/whoami.js.map +1 -1
- package/dist/builtins/utils.d.ts +25 -1
- package/dist/builtins/utils.js +30 -3
- package/dist/builtins/utils.js.map +1 -1
- package/dist/builtins/wildcard.d.ts +31 -0
- package/dist/builtins/wildcard.js +114 -51
- package/dist/builtins/wildcard.js.map +1 -1
- package/dist/command-keys.js +2 -1
- package/dist/command-keys.js.map +1 -1
- package/dist/core/cancellation.d.ts +28 -0
- package/dist/core/cancellation.js +70 -0
- package/dist/core/cancellation.js.map +1 -0
- package/dist/core/dispatch.d.ts +1 -8
- package/dist/core/dispatch.js +82 -82
- package/dist/core/dispatch.js.map +1 -1
- package/dist/core/elevation.d.ts +35 -0
- package/dist/core/elevation.js +77 -0
- package/dist/core/elevation.js.map +1 -0
- package/dist/core/engine.d.ts +12 -0
- package/dist/core/engine.js +35 -8
- package/dist/core/engine.js.map +1 -1
- package/dist/core/preprocess.d.ts +11 -4
- package/dist/core/preprocess.js +43 -10
- package/dist/core/preprocess.js.map +1 -1
- package/dist/core/progress.d.ts +15 -5
- package/dist/core/progress.js +14 -0
- package/dist/core/progress.js.map +1 -1
- package/dist/core/promptContext.d.ts +3 -5
- package/dist/core/promptContext.js +9 -2
- package/dist/core/promptContext.js.map +1 -1
- package/dist/core/sink.d.ts +9 -0
- package/dist/core/sink.js +23 -3
- package/dist/core/sink.js.map +1 -1
- package/dist/core/surface.d.ts +14 -0
- package/dist/core/surface.js +5 -0
- package/dist/core/surface.js.map +1 -1
- package/dist/core/version.d.ts +34 -0
- package/dist/core/version.js +51 -0
- package/dist/core/version.js.map +1 -1
- package/dist/index.d.ts +1 -0
- package/dist/index.js +1 -0
- package/dist/index.js.map +1 -1
- package/dist/lib/completer/index.js +41 -2
- package/dist/lib/completer/index.js.map +1 -1
- package/dist/lib/parser.d.ts +75 -2
- package/dist/lib/parser.js +158 -15
- package/dist/lib/parser.js.map +1 -1
- package/dist/lib/vfs/listing.d.ts +22 -0
- package/dist/lib/vfs/listing.js +14 -0
- package/dist/lib/vfs/listing.js.map +1 -0
- package/dist/lib/vfs/providers/binEntry.d.ts +20 -0
- package/dist/lib/vfs/providers/binEntry.js +47 -0
- package/dist/lib/vfs/providers/binEntry.js.map +1 -0
- package/dist/lib/vfs/providers/static.js +1 -0
- package/dist/lib/vfs/providers/static.js.map +1 -1
- package/dist/lib/vfs/providers/static_content.js +7 -38
- package/dist/lib/vfs/providers/static_content.js.map +1 -1
- package/dist/lib/vfs/vfs.d.ts +7 -0
- package/dist/lib/vfs/vfs.js +28 -2
- package/dist/lib/vfs/vfs.js.map +1 -1
- package/dist/session/index.d.ts +18 -0
- package/dist/session/index.js +29 -1
- package/dist/session/index.js.map +1 -1
- package/package.json +10 -5
package/dist/builtins/utils.js
CHANGED
|
@@ -5,12 +5,34 @@
|
|
|
5
5
|
import * as path from 'path';
|
|
6
6
|
import { context_getSingle } from '@fnndsc/salsa';
|
|
7
7
|
import { session } from '../session/index.js';
|
|
8
|
+
/**
|
|
9
|
+
* Bridges POSIX-parsed builtin arguments to chili's CLI option bag.
|
|
10
|
+
*
|
|
11
|
+
* ParsedArgs and CLIoptions carry incompatible index signatures, so the
|
|
12
|
+
* conversion is a real copy (positional `_` dropped), not a cast.
|
|
13
|
+
*
|
|
14
|
+
* @param parsed - Arguments from `commandArgs_process`.
|
|
15
|
+
* @returns The same flags as a chili CLIoptions object.
|
|
16
|
+
*/
|
|
17
|
+
export function cliOptions_from(parsed) {
|
|
18
|
+
const options = {};
|
|
19
|
+
for (const [key, value] of Object.entries(parsed)) {
|
|
20
|
+
if (key !== '_')
|
|
21
|
+
options[key] = value;
|
|
22
|
+
}
|
|
23
|
+
return options;
|
|
24
|
+
}
|
|
8
25
|
/**
|
|
9
26
|
* Parses raw argument strings into a structured object.
|
|
10
27
|
* Supports `--` as an end-of-options marker (everything after is treated as positional args).
|
|
28
|
+
*
|
|
29
|
+
* @param args - Tokenized command arguments.
|
|
30
|
+
* @param options - Command-specific long-option policy.
|
|
31
|
+
* @returns Parsed option values and positional operands.
|
|
11
32
|
*/
|
|
12
|
-
export function commandArgs_process(args) {
|
|
33
|
+
export function commandArgs_process(args, options = {}) {
|
|
13
34
|
const result = { _: [] };
|
|
35
|
+
const booleanLongOptions = new Set(options.booleanLongOptions);
|
|
14
36
|
let endOfOptions = false;
|
|
15
37
|
for (let i = 0; i < args.length; i++) {
|
|
16
38
|
const arg = args[i];
|
|
@@ -25,8 +47,13 @@ export function commandArgs_process(args) {
|
|
|
25
47
|
continue;
|
|
26
48
|
}
|
|
27
49
|
if (arg.startsWith('--')) {
|
|
28
|
-
const
|
|
29
|
-
|
|
50
|
+
const rawKey = arg.substring(2);
|
|
51
|
+
const separator = rawKey.indexOf('=');
|
|
52
|
+
const key = separator === -1 ? rawKey : rawKey.slice(0, separator);
|
|
53
|
+
if (separator !== -1) {
|
|
54
|
+
result[key] = rawKey.slice(separator + 1);
|
|
55
|
+
}
|
|
56
|
+
else if (!booleanLongOptions.has(key) && args[i + 1] && !args[i + 1].startsWith('-')) {
|
|
30
57
|
result[key] = args[i + 1];
|
|
31
58
|
i++;
|
|
32
59
|
}
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"utils.js","sourceRoot":"","sources":["../../src/builtins/utils.ts"],"names":[],"mappings":"AAAA;;;GAGG;AACH,OAAO,KAAK,IAAI,MAAM,MAAM,CAAC;AAC7B,OAAO,EAAE,iBAAiB,EAAE,MAAM,eAAe,CAAC;AAElD,OAAO,EAAE,OAAO,EAAE,MAAM,qBAAqB,CAAC;
|
|
1
|
+
{"version":3,"file":"utils.js","sourceRoot":"","sources":["../../src/builtins/utils.ts"],"names":[],"mappings":"AAAA;;;GAGG;AACH,OAAO,KAAK,IAAI,MAAM,MAAM,CAAC;AAC7B,OAAO,EAAE,iBAAiB,EAAE,MAAM,eAAe,CAAC;AAElD,OAAO,EAAE,OAAO,EAAE,MAAM,qBAAqB,CAAC;AAY9C;;;;;;;;GAQG;AACH,MAAM,UAAU,eAAe,CAAC,MAAkB;IAChD,MAAM,OAAO,GAAe,EAAE,CAAC;IAC/B,KAAK,MAAM,CAAC,GAAG,EAAE,KAAK,CAAC,IAAI,MAAM,CAAC,OAAO,CAAC,MAAM,CAAC,EAAE,CAAC;QAClD,IAAI,GAAG,KAAK,GAAG;YAAE,OAAO,CAAC,GAAG,CAAC,GAAG,KAAK,CAAC;IACxC,CAAC;IACD,OAAO,OAAO,CAAC;AACjB,CAAC;AAaD;;;;;;;GAOG;AACH,MAAM,UAAU,mBAAmB,CAAC,IAAc,EAAE,UAA8B,EAAE;IAClF,MAAM,MAAM,GAAe,EAAE,CAAC,EAAE,EAAE,EAAE,CAAC;IACrC,MAAM,kBAAkB,GAAgB,IAAI,GAAG,CAAC,OAAO,CAAC,kBAAkB,CAAC,CAAC;IAC5E,IAAI,YA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AE,EAAE,UAAU,CAAC,CAAC;YAEhF,oCAAoC;YACpC,MAAM,IAAI,GAA4B,KAAK,CAAC,IAAI,CAAC,CAAC,CAAc,EAAE,EAAE,CAAC,CAAC,CAAC,IAAI,KAAK,SAAS,CAAC,CAAC;YAE3F,IAAI,IAAI,IAAI,IAAI,CAAC,IAAI,KAAK,MAAM,IAAI,IAAI,CAAC,MAAM,EAAE,CAAC;gBAChD,mCAAmC;gBACnC,IAAI,IAAI,CAAC,MAAM,CAAC,UAAU,CAAC,GAAG,CAAC,EAAE,CAAC;oBAChC,uBAAuB;oBACvB,WAAW,GAAG,IAAI,CAAC,MAAM,CAAC;gBAC5B,CAAC;qBAAM,CAAC;oBACN,uBAAuB;oBACvB,WAAW,GAAG,GAAG,UAAU,IAAI,IAAI,CAAC,MAAM,EAAE,CAAC,OAAO,CAAC,IAAI,EAAE,GAAG,CAAC,CAAC;gBAClE,CAAC;YACH,CAAC;QACH,CAAC;QAAC,OAAO,MAAe,EAAE,CAAC;YACzB,iEAAiE;YACjE,SAAS;QACX,CAAC;IACH,CAAC;IAED,OAAO,WAAW,IAAI,GAAG,CAAC;AAC5B,CAAC;AAED;;;;;;;;;;;GAWG;AACH,MAAM,UAAU,sBAAsB,CAAC,OAAe;IACpD,IAAI,OAAO,CAAC,UAAU,EAAE,MAAM,EAAE,KAAK,EAAE,CAAC;QACtC,OAAO,OAAO,CAAC;IACjB,CAAC;IACD,OAAO,OAAO,CAAC,OAAO,CAAC,qBAAqB,EAAE,EAAE,CAAC,CAAC;AACpD,CAAC"}
|
|
@@ -1,4 +1,6 @@
|
|
|
1
|
+
import type { ListingItem } from '@fnndsc/chili/models/listing.js';
|
|
1
2
|
import { Result } from '@fnndsc/cumin';
|
|
3
|
+
import { ShellWord } from '../lib/parser.js';
|
|
2
4
|
/**
|
|
3
5
|
* Checks if a string contains wildcard characters.
|
|
4
6
|
*
|
|
@@ -6,6 +8,35 @@ import { Result } from '@fnndsc/cumin';
|
|
|
6
8
|
* @returns True if the argument contains wildcards.
|
|
7
9
|
*/
|
|
8
10
|
export declare function string_checkHasWildcard(arg: string): boolean;
|
|
11
|
+
/** A VFS item selected by wildcard expansion. */
|
|
12
|
+
export interface WildcardMatch {
|
|
13
|
+
path: string;
|
|
14
|
+
type: ListingItem['type'];
|
|
15
|
+
}
|
|
16
|
+
/**
|
|
17
|
+
* Expands one quote-aware shell word against the ChRIS filesystem.
|
|
18
|
+
*
|
|
19
|
+
* @param word - Parsed shell word.
|
|
20
|
+
* @returns Expanded words, or the original word when it has no match.
|
|
21
|
+
*/
|
|
22
|
+
export declare function shellWord_expand(word: ShellWord): Promise<Result<ShellWord[]>>;
|
|
23
|
+
/**
|
|
24
|
+
* Expands selected quote-aware shell words in argument order.
|
|
25
|
+
*
|
|
26
|
+
* @param words - Parsed shell words.
|
|
27
|
+
* @param eligible - Predicate that preserves explicit cross-realm operands.
|
|
28
|
+
* @returns Expanded words, retaining literal words when no path matches.
|
|
29
|
+
*/
|
|
30
|
+
export declare function shellWords_expand(words: readonly ShellWord[], eligible: (word: ShellWord, index: number) => boolean): Promise<Result<ShellWord[]>>;
|
|
31
|
+
/**
|
|
32
|
+
* Expands a wildcard pattern against the current directory with item type.
|
|
33
|
+
*
|
|
34
|
+
* @param pattern - The glob pattern (e.g., "*.ts", "test*.json").
|
|
35
|
+
* @returns A Promise resolving to Result<WildcardMatch[]>.
|
|
36
|
+
* Ok([]) = no matches (not an error).
|
|
37
|
+
* Err(...) = couldn't expand (API failure, permission denied, etc.).
|
|
38
|
+
*/
|
|
39
|
+
export declare function wildcard_expandMatches(pattern: string): Promise<Result<WildcardMatch[]>>;
|
|
9
40
|
/**
|
|
10
41
|
* Expands a wildcard pattern against the current directory.
|
|
11
42
|
*
|
|
@@ -6,9 +6,13 @@
|
|
|
6
6
|
* @module
|
|
7
7
|
*/
|
|
8
8
|
import { minimatch } from 'minimatch';
|
|
9
|
+
import { listingItemsFromVfs_make } from '../lib/vfs/listing.js';
|
|
9
10
|
import { session } from '../session/index.js';
|
|
11
|
+
import { path_resolveChrisFs } from '@fnndsc/chili/utils/cli.js';
|
|
10
12
|
import { vfsDispatcher } from '@fnndsc/salsa';
|
|
11
13
|
import { listCache_get, Ok, Err, errorStack } from '@fnndsc/cumin';
|
|
14
|
+
import { shellWord_literal, shellWord_unquoted } from '../lib/parser.js';
|
|
15
|
+
import { path_resolve } from './utils.js';
|
|
12
16
|
/**
|
|
13
17
|
* Checks if a string contains wildcard characters.
|
|
14
18
|
*
|
|
@@ -19,54 +23,49 @@ export function string_checkHasWildcard(arg) {
|
|
|
19
23
|
return /[*?[\]]/.test(arg);
|
|
20
24
|
}
|
|
21
25
|
/**
|
|
22
|
-
* Expands a
|
|
26
|
+
* Expands a rendered pattern and its quote-aware minimatch pattern.
|
|
23
27
|
*
|
|
24
|
-
* @param
|
|
25
|
-
* @
|
|
28
|
+
* @param value - Rendered shell-word value.
|
|
29
|
+
* @param globPattern - Quote-aware minimatch pattern.
|
|
30
|
+
* @returns A Promise resolving to Result<WildcardMatch[]>.
|
|
26
31
|
* Ok([]) = no matches (not an error).
|
|
27
32
|
* Err(...) = couldn't expand (API failure, permission denied, etc.).
|
|
28
33
|
*/
|
|
29
|
-
|
|
30
|
-
// If no wildcard, return as-is
|
|
31
|
-
if (!string_checkHasWildcard(pattern)) {
|
|
32
|
-
return Ok([pattern]);
|
|
33
|
-
}
|
|
34
|
+
async function wildcardMatches_expand(value, globPattern) {
|
|
34
35
|
try {
|
|
35
36
|
// Get current directory
|
|
36
37
|
const cwd = await session.getCWD();
|
|
38
|
+
const resolvedValue = await path_resolve(value);
|
|
39
|
+
const resolvedPattern = await path_resolve(globPattern);
|
|
37
40
|
// Handle patterns with directory components (e.g., "data/*.txt")
|
|
38
41
|
let searchDir = cwd;
|
|
39
|
-
let
|
|
40
|
-
|
|
41
|
-
|
|
42
|
-
|
|
43
|
-
|
|
44
|
-
|
|
45
|
-
|
|
46
|
-
|
|
47
|
-
|
|
48
|
-
|
|
49
|
-
|
|
50
|
-
|
|
51
|
-
}
|
|
52
|
-
else {
|
|
53
|
-
// Relative path - append to cwd
|
|
54
|
-
searchDir = `${cwd}/${dirPart}`.replace(/\/+/g, '/');
|
|
55
|
-
}
|
|
42
|
+
let physicalSearchDir = cwd;
|
|
43
|
+
let matchPattern = resolvedPattern;
|
|
44
|
+
// Resolve the non-wildcard parent directory before listing. This gives
|
|
45
|
+
// `~/...` its normal meaning and follows a CFS `.chrislink` parent while
|
|
46
|
+
// retaining the caller's logical spelling in the expanded result.
|
|
47
|
+
if (resolvedValue.includes('/')) {
|
|
48
|
+
const valueParts = resolvedValue.split('/');
|
|
49
|
+
const patternParts = resolvedPattern.split('/');
|
|
50
|
+
const lastPart = patternParts.pop() || '*';
|
|
51
|
+
valueParts.pop();
|
|
52
|
+
const dirPart = valueParts.join('/');
|
|
53
|
+
searchDir = dirPart || '/';
|
|
54
|
+
physicalSearchDir = await path_resolveChrisFs(searchDir, {});
|
|
56
55
|
matchPattern = lastPart;
|
|
57
56
|
}
|
|
58
57
|
// List files in the directory (check cache first)
|
|
59
58
|
let items = [];
|
|
60
59
|
const listCache = listCache_get();
|
|
61
|
-
const cached = listCache.cache_get(
|
|
60
|
+
const cached = listCache.cache_get(physicalSearchDir);
|
|
62
61
|
if (cached) {
|
|
63
62
|
items = cached.data;
|
|
64
63
|
}
|
|
65
64
|
else {
|
|
66
|
-
const vfsResult = await vfsDispatcher.list(
|
|
65
|
+
const vfsResult = await vfsDispatcher.list(physicalSearchDir);
|
|
67
66
|
if (vfsResult.ok) {
|
|
68
|
-
items = vfsResult.value;
|
|
69
|
-
listCache.cache_set(
|
|
67
|
+
items = listingItemsFromVfs_make(vfsResult.value);
|
|
68
|
+
listCache.cache_set(physicalSearchDir, items);
|
|
70
69
|
}
|
|
71
70
|
else {
|
|
72
71
|
return Err();
|
|
@@ -76,21 +75,96 @@ export async function wildcard_expand(pattern) {
|
|
|
76
75
|
const matches = items
|
|
77
76
|
.filter((item) => minimatch(item.name, matchPattern))
|
|
78
77
|
.map((item) => {
|
|
79
|
-
// Return full path if we searched a different directory
|
|
80
|
-
|
|
81
|
-
|
|
82
|
-
|
|
83
|
-
return
|
|
78
|
+
// Return a full path if we searched a different directory.
|
|
79
|
+
const itemPath = searchDir !== cwd
|
|
80
|
+
? `${searchDir}/${item.name}`.replace(/\/+/g, '/')
|
|
81
|
+
: item.name;
|
|
82
|
+
return {
|
|
83
|
+
path: itemPath,
|
|
84
|
+
type: item.type,
|
|
85
|
+
};
|
|
84
86
|
});
|
|
85
87
|
// Ok([]) for no matches (not an error)
|
|
86
88
|
return Ok(matches);
|
|
87
89
|
}
|
|
88
90
|
catch (error) {
|
|
89
91
|
const errorMsg = error instanceof Error ? error.message : String(error);
|
|
90
|
-
errorStack.stack_push("error", `Failed to expand wildcard '${
|
|
92
|
+
errorStack.stack_push("error", `Failed to expand wildcard '${value}': ${errorMsg}`);
|
|
91
93
|
return Err();
|
|
92
94
|
}
|
|
93
95
|
}
|
|
96
|
+
/**
|
|
97
|
+
* Expands one quote-aware shell word against the ChRIS filesystem.
|
|
98
|
+
*
|
|
99
|
+
* @param word - Parsed shell word.
|
|
100
|
+
* @returns Expanded words, or the original word when it has no match.
|
|
101
|
+
*/
|
|
102
|
+
export async function shellWord_expand(word) {
|
|
103
|
+
if (!word.pathnameExpansion)
|
|
104
|
+
return Ok([word]);
|
|
105
|
+
const result = await wildcardMatches_expand(word.value, word.globPattern);
|
|
106
|
+
if (!result.ok)
|
|
107
|
+
return result;
|
|
108
|
+
if (result.value.length === 0)
|
|
109
|
+
return Ok([word]);
|
|
110
|
+
return Ok(result.value.map((match) => ({
|
|
111
|
+
...shellWord_literal(match.path),
|
|
112
|
+
pathnameExpanded: true,
|
|
113
|
+
})));
|
|
114
|
+
}
|
|
115
|
+
/**
|
|
116
|
+
* Expands selected quote-aware shell words in argument order.
|
|
117
|
+
*
|
|
118
|
+
* @param words - Parsed shell words.
|
|
119
|
+
* @param eligible - Predicate that preserves explicit cross-realm operands.
|
|
120
|
+
* @returns Expanded words, retaining literal words when no path matches.
|
|
121
|
+
*/
|
|
122
|
+
export async function shellWords_expand(words, eligible) {
|
|
123
|
+
const expanded = [];
|
|
124
|
+
for (const [index, word] of words.entries()) {
|
|
125
|
+
if (!eligible(word, index)) {
|
|
126
|
+
expanded.push(word);
|
|
127
|
+
continue;
|
|
128
|
+
}
|
|
129
|
+
const result = await shellWord_expand(word);
|
|
130
|
+
if (!result.ok)
|
|
131
|
+
return result;
|
|
132
|
+
expanded.push(...result.value);
|
|
133
|
+
}
|
|
134
|
+
return Ok(expanded);
|
|
135
|
+
}
|
|
136
|
+
/**
|
|
137
|
+
* Expands a wildcard pattern against the current directory with item type.
|
|
138
|
+
*
|
|
139
|
+
* @param pattern - The glob pattern (e.g., "*.ts", "test*.json").
|
|
140
|
+
* @returns A Promise resolving to Result<WildcardMatch[]>.
|
|
141
|
+
* Ok([]) = no matches (not an error).
|
|
142
|
+
* Err(...) = couldn't expand (API failure, permission denied, etc.).
|
|
143
|
+
*/
|
|
144
|
+
export async function wildcard_expandMatches(pattern) {
|
|
145
|
+
if (!string_checkHasWildcard(pattern))
|
|
146
|
+
return Ok([{ path: pattern, type: 'file' }]);
|
|
147
|
+
return wildcardMatches_expand(pattern, pattern);
|
|
148
|
+
}
|
|
149
|
+
/**
|
|
150
|
+
* Expands a wildcard pattern against the current directory.
|
|
151
|
+
*
|
|
152
|
+
* @param pattern - The glob pattern (e.g., "*.ts", "test*.json").
|
|
153
|
+
* @returns A Promise resolving to Result<string[]>.
|
|
154
|
+
* Ok([]) = no matches (not an error).
|
|
155
|
+
* Err(...) = couldn't expand (API failure, permission denied, etc.).
|
|
156
|
+
*/
|
|
157
|
+
export async function wildcard_expand(pattern) {
|
|
158
|
+
if (!string_checkHasWildcard(pattern))
|
|
159
|
+
return Ok([pattern]);
|
|
160
|
+
const word = shellWord_unquoted(pattern);
|
|
161
|
+
const result = await shellWord_expand(word);
|
|
162
|
+
if (!result.ok)
|
|
163
|
+
return result;
|
|
164
|
+
if (result.value.length === 1 && result.value[0] === word)
|
|
165
|
+
return Ok([]);
|
|
166
|
+
return Ok(result.value.map((match) => match.value));
|
|
167
|
+
}
|
|
94
168
|
/**
|
|
95
169
|
* Expands all wildcards in an argument list.
|
|
96
170
|
*
|
|
@@ -100,21 +174,10 @@ export async function wildcard_expand(pattern) {
|
|
|
100
174
|
* Empty matches return the original pattern.
|
|
101
175
|
*/
|
|
102
176
|
export async function wildcards_expandAll(args) {
|
|
103
|
-
const
|
|
104
|
-
|
|
105
|
-
|
|
106
|
-
|
|
107
|
-
|
|
108
|
-
return result;
|
|
109
|
-
}
|
|
110
|
-
// If no matches, use original pattern (let command handle "not found")
|
|
111
|
-
if (result.value.length === 0) {
|
|
112
|
-
expanded.push(arg);
|
|
113
|
-
}
|
|
114
|
-
else {
|
|
115
|
-
expanded.push(...result.value);
|
|
116
|
-
}
|
|
117
|
-
}
|
|
118
|
-
return Ok(expanded);
|
|
177
|
+
const words = args.map((arg) => shellWord_unquoted(arg));
|
|
178
|
+
const result = await shellWords_expand(words, () => true);
|
|
179
|
+
if (!result.ok)
|
|
180
|
+
return result;
|
|
181
|
+
return Ok(result.value.map((word) => word.value));
|
|
119
182
|
}
|
|
120
183
|
//# sourceMappingURL=wildcard.js.map
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"wildcard.js","sourceRoot":"","sources":["../../src/builtins/wildcard.ts"],"names":[],"mappings":"AAAA;;;;;;GAMG;AACH,OAAO,EAAE,SAAS,EAAE,MAAM,WAAW,CAAC;AACtC,OAAO,EAAE,OAAO,EAAE,MAAM,qBAAqB,CAAC;AAE9C,OAAO,EAAE,aAAa,EAAE,MAAM,eAAe,CAAC;AAC9C,OAAO,EAAE,aAAa,EAAU,EAAE,EAAE,GAAG,EAAE,UAAU,EAAE,MAAM,eAAe,CAAC;
|
|
1
|
+
{"version":3,"file":"wildcard.js","sourceRoot":"","sources":["../../src/builtins/wildcard.ts"],"names":[],"mappings":"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AAM,CAAC,KAAK,CAAC,MAAM,KAAK,CAAC,IAAI,MAAM,CAAC,KAAK,CAAC,CAAC,CAAC,KAAK,IAAI;QAAE,OAAO,EAAE,CAAC,EAAE,CAAC,CAAC;IACzE,OAAO,EAAE,CAAC,MAAM,CAAC,KAAK,CAAC,GAAG,CAAC,CAAC,KAAgB,EAAE,EAAE,CAAC,KAAK,CAAC,KAAK,CAAC,CAAC,CAAC;AACjE,CAAC;AAED;;;;;;;GAOG;AACH,MAAM,CAAC,KAAK,UAAU,mBAAmB,CAAC,IAAc;IACtD,MAAM,KAAK,GAAgB,IAAI,CAAC,GAAG,CAAC,CAAC,GAAW,EAAa,EAAE,CAAC,kBAAkB,CAAC,GAAG,CAAC,CAAC,CAAC;IACzF,MAAM,MAAM,GAAwB,MAAM,iBAAiB,CAAC,KAAK,EAAE,GAAY,EAAE,CAAC,IAAI,CAAC,CAAC;IACxF,IAAI,CAAC,MAAM,CAAC,EAAE;QAAE,OAAO,MAAM,CAAC;IAC9B,OAAO,EAAE,CAAC,MAAM,CAAC,KAAK,CAAC,GAAG,CAAC,CAAC,IAAe,EAAU,EAAE,CAAC,IAAI,CAAC,KAAK,CAAC,CAAC,CAAC;AACvE,CAAC"}
|
package/dist/command-keys.js
CHANGED
|
@@ -12,7 +12,7 @@ export const COMMAND_HANDLERS_KEYS = [
|
|
|
12
12
|
// net
|
|
13
13
|
'connect', 'logout', 'pacs', 'query', 'cubepath',
|
|
14
14
|
// sys
|
|
15
|
-
'context', 'physicalmode', 'prompt', 'timing', 'whoami', 'whereami', 'debug', 'help', 'proc',
|
|
15
|
+
'context', 'physicalmode', 'prompt', 'timing', 'id', 'whoami', 'whereami', 'debug', 'help', 'proc',
|
|
16
16
|
// resources — canonical + aliases
|
|
17
17
|
'plugin', 'plugins',
|
|
18
18
|
'feed', 'feeds',
|
|
@@ -22,6 +22,7 @@ export const COMMAND_HANDLERS_KEYS = [
|
|
|
22
22
|
'store',
|
|
23
23
|
'tag', 'tags',
|
|
24
24
|
'group', 'groups',
|
|
25
|
+
'user', 'users',
|
|
25
26
|
'pluginmeta', 'pluginmetas', 'meta', 'metas',
|
|
26
27
|
'plugininstance', 'plugininstances', 'instance', 'instances', 'job', 'jobs',
|
|
27
28
|
'workflow', 'workflows',
|
package/dist/command-keys.js.map
CHANGED
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"command-keys.js","sourceRoot":"","sources":["../src/command-keys.ts"],"names":[],"mappings":"AAAA;;;;;;GAMG;AAEH,MAAM,CAAC,MAAM,qBAAqB,GAAa;IAC7C,aAAa;IACb,IAAI,EAAE,KAAK,EAAE,IAAI,EAAE,KAAK,EAAE,IAAI,EAAE,IAAI,EAAE,IAAI,EAAE,OAAO,EAAE,OAAO,EAAE,MAAM,EAAE,IAAI;IAC1E,QAAQ,EAAE,UAAU,EAAE,MAAM;IAC5B,MAAM;IACN,SAAS,EAAE,QAAQ,EAAE,MAAM,EAAE,OAAO,EAAE,UAAU;IAChD,MAAM;IACN,SAAS,EAAE,cAAc,EAAE,QAAQ,EAAE,QAAQ,EAAE,QAAQ,EAAE,UAAU,EAAE,OAAO,EAAE,MAAM,EAAE,MAAM;
|
|
1
|
+
{"version":3,"file":"command-keys.js","sourceRoot":"","sources":["../src/command-keys.ts"],"names":[],"mappings":"AAAA;;;;;;GAMG;AAEH,MAAM,CAAC,MAAM,qBAAqB,GAAa;IAC7C,aAAa;IACb,IAAI,EAAE,KAAK,EAAE,IAAI,EAAE,KAAK,EAAE,IAAI,EAAE,IAAI,EAAE,IAAI,EAAE,OAAO,EAAE,OAAO,EAAE,MAAM,EAAE,IAAI;IAC1E,QAAQ,EAAE,UAAU,EAAE,MAAM;IAC5B,MAAM;IACN,SAAS,EAAE,QAAQ,EAAE,MAAM,EAAE,OAAO,EAAE,UAAU;IAChD,MAAM;IACN,SAAS,EAAE,cAAc,EAAE,QAAQ,EAAE,QAAQ,EAAE,IAAI,EAAE,QAAQ,EAAE,UAAU,EAAE,OAAO,EAAE,MAAM,EAAE,MAAM;IAClG,kCAAkC;IAClC,QAAQ,EAAE,SAAS;IACnB,MAAM,EAAE,OAAO;IACf,UAAU,EAAE,WAAW;IACvB,SAAS,EAAE,UAAU;IACrB,OAAO,EAAE,OAAO,EAAE,MAAM;IACxB,OAAO;IACP,KAAK,EAAE,MAAM;IACb,OAAO,EAAE,QAAQ;IACjB,MAAM,EAAE,OAAO;IACf,YAAY,EAAE,aAAa,EAAE,MAAM,EAAE,OAAO;IAC5C,gBAAgB,EAAE,iBAAiB,EAAE,UAAU,EAAE,WAAW,EAAE,KAAK,EAAE,MAAM;IAC3E,UAAU,EAAE,WAAW;IACvB,oBAAoB;IACpB,kBAAkB;IAClB,aAAa,EAAE,aAAa,EAAE,cAAc;CAC7C,CAAC"}
|
|
@@ -0,0 +1,28 @@
|
|
|
1
|
+
/**
|
|
2
|
+
* Runs work inside the foreground-command cancellation scope.
|
|
3
|
+
*
|
|
4
|
+
* Nested line execution retains its parent's scope, so a semicolon batch has
|
|
5
|
+
* one cancellation lifetime rather than one controller per segment.
|
|
6
|
+
*
|
|
7
|
+
* @param operation - Work performed by one command line.
|
|
8
|
+
* @returns The operation result.
|
|
9
|
+
*/
|
|
10
|
+
export declare function commandCancellation_run<T>(operation: () => Promise<T>): Promise<T>;
|
|
11
|
+
/**
|
|
12
|
+
* Marks the current command as able to honor a foreground cancellation.
|
|
13
|
+
*
|
|
14
|
+
* @returns Nothing. Calls outside a command scope have no effect.
|
|
15
|
+
*/
|
|
16
|
+
export declare function commandCancellation_enable(): void;
|
|
17
|
+
/**
|
|
18
|
+
* Gets the abort signal for the command currently running on this async path.
|
|
19
|
+
*
|
|
20
|
+
* @returns The command signal, or undefined outside foreground execution.
|
|
21
|
+
*/
|
|
22
|
+
export declare function commandCancellation_signalGet(): AbortSignal | undefined;
|
|
23
|
+
/**
|
|
24
|
+
* Requests cancellation of the currently running cancellable command.
|
|
25
|
+
*
|
|
26
|
+
* @returns True when a cancellable foreground command was signalled.
|
|
27
|
+
*/
|
|
28
|
+
export declare function commandCancellation_request(): boolean;
|
|
@@ -0,0 +1,70 @@
|
|
|
1
|
+
/**
|
|
2
|
+
* @file Foreground-command cancellation scope.
|
|
3
|
+
*
|
|
4
|
+
* One interactive engine owns one foreground command at a time. This module
|
|
5
|
+
* carries that command's abort signal through asynchronous dispatch without
|
|
6
|
+
* turning cancellation into ambient process state for unrelated work.
|
|
7
|
+
*
|
|
8
|
+
* @module
|
|
9
|
+
*/
|
|
10
|
+
import { AsyncLocalStorage } from 'node:async_hooks';
|
|
11
|
+
const cancellationScope = new AsyncLocalStorage();
|
|
12
|
+
let foreground;
|
|
13
|
+
/**
|
|
14
|
+
* Runs work inside the foreground-command cancellation scope.
|
|
15
|
+
*
|
|
16
|
+
* Nested line execution retains its parent's scope, so a semicolon batch has
|
|
17
|
+
* one cancellation lifetime rather than one controller per segment.
|
|
18
|
+
*
|
|
19
|
+
* @param operation - Work performed by one command line.
|
|
20
|
+
* @returns The operation result.
|
|
21
|
+
*/
|
|
22
|
+
export async function commandCancellation_run(operation) {
|
|
23
|
+
if (cancellationScope.getStore() !== undefined) {
|
|
24
|
+
return await operation();
|
|
25
|
+
}
|
|
26
|
+
const state = {
|
|
27
|
+
controller: new AbortController(),
|
|
28
|
+
cancellable: false,
|
|
29
|
+
};
|
|
30
|
+
const previous = foreground;
|
|
31
|
+
foreground = state;
|
|
32
|
+
try {
|
|
33
|
+
return await cancellationScope.run(state, operation);
|
|
34
|
+
}
|
|
35
|
+
finally {
|
|
36
|
+
if (foreground === state)
|
|
37
|
+
foreground = previous;
|
|
38
|
+
}
|
|
39
|
+
}
|
|
40
|
+
/**
|
|
41
|
+
* Marks the current command as able to honor a foreground cancellation.
|
|
42
|
+
*
|
|
43
|
+
* @returns Nothing. Calls outside a command scope have no effect.
|
|
44
|
+
*/
|
|
45
|
+
export function commandCancellation_enable() {
|
|
46
|
+
const state = cancellationScope.getStore();
|
|
47
|
+
if (state !== undefined)
|
|
48
|
+
state.cancellable = true;
|
|
49
|
+
}
|
|
50
|
+
/**
|
|
51
|
+
* Gets the abort signal for the command currently running on this async path.
|
|
52
|
+
*
|
|
53
|
+
* @returns The command signal, or undefined outside foreground execution.
|
|
54
|
+
*/
|
|
55
|
+
export function commandCancellation_signalGet() {
|
|
56
|
+
return cancellationScope.getStore()?.controller.signal;
|
|
57
|
+
}
|
|
58
|
+
/**
|
|
59
|
+
* Requests cancellation of the currently running cancellable command.
|
|
60
|
+
*
|
|
61
|
+
* @returns True when a cancellable foreground command was signalled.
|
|
62
|
+
*/
|
|
63
|
+
export function commandCancellation_request() {
|
|
64
|
+
if (foreground === undefined || !foreground.cancellable || foreground.controller.signal.aborted) {
|
|
65
|
+
return false;
|
|
66
|
+
}
|
|
67
|
+
foreground.controller.abort();
|
|
68
|
+
return true;
|
|
69
|
+
}
|
|
70
|
+
//# sourceMappingURL=cancellation.js.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"cancellation.js","sourceRoot":"","sources":["../../src/core/cancellation.ts"],"names":[],"mappings":"AAAA;;;;;;;;GAQG;AACH,OAAO,EAAE,iBAAiB,EAAE,MAAM,kBAAkB,CAAC;AAQrD,MAAM,iBAAiB,GACrB,IAAI,iBAAiB,EAA4B,CAAC;AACpD,IAAI,UAAgD,CAAC;AAErD;;;;;;;;GAQG;AACH,MAAM,CAAC,KAAK,UAAU,uBAAuB,CAAI,SAA2B;IAC1E,IAAI,iBAAiB,CAAC,QAAQ,EAAE,KAAK,SAAS,EAAE,CAAC;QAC/C,OAAO,MAAM,SAAS,EAAE,CAAC;IAC3B,CAAC;IAED,MAAM,KAAK,GAA6B;QACtC,UAAU,EAAE,IAAI,eAAe,EAAE;QACjC,WAAW,EAAE,KAAK;KACnB,CAAC;IACF,MAAM,QAAQ,GAAyC,UAAU,CAAC;IAClE,UAAU,GAAG,KAAK,CAAC;IACnB,IAAI,CAAC;QACH,OAAO,MAAM,iBAAiB,CAAC,GAAG,CAAC,KAAK,EAAE,SAAS,CAAC,CAAC;IACvD,CAAC;YAAS,CAAC;QACT,IAAI,UAAU,KAAK,KAAK;YAAE,UAAU,GAAG,QAAQ,CAAC;IAClD,CAAC;AACH,CAAC;AAED;;;;GAIG;AACH,MAAM,UAAU,0BAA0B;IACxC,MAAM,KAAK,GAAyC,iBAAiB,CAAC,QAAQ,EAAE,CAAC;IACjF,IAAI,KAAK,KAAK,SAAS;QAAE,KAAK,CAAC,WAAW,GAAG,IAAI,CAAC;AACpD,CAAC;AAED;;;;GAIG;AACH,MAAM,UAAU,6BAA6B;IAC3C,OAAO,iBAAiB,CAAC,QAAQ,EAAE,EAAE,UAAU,CAAC,MAAM,CAAC;AACzD,CAAC;AAED;;;;GAIG;AACH,MAAM,UAAU,2BAA2B;IACzC,IAAI,UAAU,KAAK,SAAS,IAAI,CAAC,UAAU,CAAC,WAAW,IAAI,UAAU,CAAC,UAAU,CAAC,MAAM,CAAC,OAAO,EAAE,CAAC;QAChG,OAAO,KAAK,CAAC;IACf,CAAC;IACD,UAAU,CAAC,UAAU,CAAC,KAAK,EAAE,CAAC;IAC9B,OAAO,IAAI,CAAC;AACd,CAAC"}
|
package/dist/core/dispatch.d.ts
CHANGED
|
@@ -2,14 +2,7 @@ import type { CommandEnvelope } from '@fnndsc/cumin';
|
|
|
2
2
|
import { type RedirectInfo } from './preprocess.js';
|
|
3
3
|
import { chiliCommand_run } from './chiliDelegate.js';
|
|
4
4
|
export { chiliCommand_run };
|
|
5
|
-
|
|
6
|
-
* Executes a shell command on the host system (shell escape with ! prefix).
|
|
7
|
-
*
|
|
8
|
-
* @param shellCommand - The command to execute on the host shell.
|
|
9
|
-
* @returns A Promise resolving to the command's exit code (1 on spawn failure).
|
|
10
|
-
*/
|
|
11
|
-
export declare function shellCommand_execute(shellCommand: string): Promise<number>;
|
|
12
|
-
type CommandHandler = (args: string[]) => Promise<void>;
|
|
5
|
+
type CommandHandler = (args: string[]) => Promise<void | CommandEnvelope>;
|
|
13
6
|
/**
|
|
14
7
|
* Shape of a converted builtin: returns its outcome as an envelope instead
|
|
15
8
|
* of printing. The engine layer will consume these directly; the dispatch
|