just-bash 2.4.4 → 2.5.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 (91) hide show
  1. package/README.md +42 -4
  2. package/dist/AGENTS.md +2 -2
  3. package/dist/bin/chunks/base64-O7TCK5TL.js +6 -0
  4. package/dist/bin/{shell/chunks/cat-ZEMMQGY5.js → chunks/cat-AJXZOSPN.js} +1 -1
  5. package/dist/bin/chunks/{chunk-45SNFRCY.js → chunk-5WFYIUU2.js} +2 -2
  6. package/dist/bin/chunks/chunk-CTLU5QUH.js +17 -0
  7. package/dist/bin/{shell/chunks/chunk-GX4MPCG6.js → chunks/chunk-Y5QKO4KO.js} +5 -5
  8. package/dist/bin/chunks/{cut-WWPJ2PYT.js → cut-IHF6BEOO.js} +1 -1
  9. package/dist/bin/chunks/grep-QCXXYC54.js +9 -0
  10. package/dist/bin/{shell/chunks/gzip-MNCJB6OR.js → chunks/gzip-YXK3WZQL.js} +22 -22
  11. package/dist/bin/{shell/chunks/jq-XH2PXRWE.js → chunks/jq-XXZPU5CA.js} +1 -1
  12. package/dist/bin/chunks/{md5sum-VGXAOUBA.js → md5sum-2VAAFCTS.js} +1 -1
  13. package/dist/bin/chunks/rg-GVIT6FTE.js +33 -0
  14. package/dist/bin/chunks/{sha1sum-BIUH233Z.js → sha1sum-67P4ME4N.js} +1 -1
  15. package/dist/bin/{shell/chunks/sha256sum-SUIK2MT2.js → chunks/sha256sum-MV3WQ4QF.js} +1 -1
  16. package/dist/bin/{shell/chunks/sort-C3F6LCNY.js → chunks/sort-KUHOCH5S.js} +1 -1
  17. package/dist/bin/chunks/tar-C27YYUAS.js +63 -0
  18. package/dist/bin/{shell/chunks/uniq-DKS7RIAE.js → chunks/uniq-IXHB2FVS.js} +1 -1
  19. package/dist/bin/chunks/{wc-4LMTC3QD.js → wc-QSBRKIF5.js} +1 -1
  20. package/dist/bin/chunks/{xan-WNN2ZOAX.js → xan-6K2NGTHM.js} +1 -1
  21. package/dist/bin/just-bash.js +78 -78
  22. package/dist/bin/shell/chunks/base64-O7TCK5TL.js +6 -0
  23. package/dist/bin/{chunks/cat-ZEMMQGY5.js → shell/chunks/cat-AJXZOSPN.js} +1 -1
  24. package/dist/bin/shell/chunks/{chunk-45SNFRCY.js → chunk-5WFYIUU2.js} +2 -2
  25. package/dist/bin/shell/chunks/chunk-CTLU5QUH.js +17 -0
  26. package/dist/bin/{chunks/chunk-GX4MPCG6.js → shell/chunks/chunk-Y5QKO4KO.js} +5 -5
  27. package/dist/bin/shell/chunks/{cut-WWPJ2PYT.js → cut-IHF6BEOO.js} +1 -1
  28. package/dist/bin/shell/chunks/grep-QCXXYC54.js +9 -0
  29. package/dist/bin/{chunks/gzip-MNCJB6OR.js → shell/chunks/gzip-YXK3WZQL.js} +22 -22
  30. package/dist/bin/{chunks/jq-XH2PXRWE.js → shell/chunks/jq-XXZPU5CA.js} +1 -1
  31. package/dist/bin/shell/chunks/{md5sum-VGXAOUBA.js → md5sum-2VAAFCTS.js} +1 -1
  32. package/dist/bin/shell/chunks/rg-GVIT6FTE.js +33 -0
  33. package/dist/bin/shell/chunks/{sha1sum-BIUH233Z.js → sha1sum-67P4ME4N.js} +1 -1
  34. package/dist/bin/{chunks/sha256sum-SUIK2MT2.js → shell/chunks/sha256sum-MV3WQ4QF.js} +1 -1
  35. package/dist/bin/{chunks/sort-C3F6LCNY.js → shell/chunks/sort-KUHOCH5S.js} +1 -1
  36. package/dist/bin/shell/chunks/tar-C27YYUAS.js +63 -0
  37. package/dist/bin/{chunks/uniq-DKS7RIAE.js → shell/chunks/uniq-IXHB2FVS.js} +1 -1
  38. package/dist/bin/shell/chunks/{wc-4LMTC3QD.js → wc-QSBRKIF5.js} +1 -1
  39. package/dist/bin/shell/chunks/{xan-WNN2ZOAX.js → xan-6K2NGTHM.js} +1 -1
  40. package/dist/bin/shell/shell.js +100 -100
  41. package/dist/bundle/browser.js +557 -517
  42. package/dist/bundle/chunks/base64-3BME25ON.js +5 -0
  43. package/dist/bundle/chunks/{cat-W5XITXDC.js → cat-MV4K6AUA.js} +1 -1
  44. package/dist/bundle/chunks/{chunk-4ACWXGKW.js → chunk-7L36YK2X.js} +2 -2
  45. package/dist/bundle/chunks/{chunk-46TSKXFW.js → chunk-GFLIVSUW.js} +5 -5
  46. package/dist/bundle/chunks/chunk-OHJS5H37.js +16 -0
  47. package/dist/bundle/chunks/{cut-KKAAQJVD.js → cut-NVKWEAZF.js} +1 -1
  48. package/dist/bundle/chunks/grep-TUWLGQC2.js +8 -0
  49. package/dist/bundle/chunks/{gzip-7QAS5P2Y.js → gzip-L3NDJG3F.js} +22 -22
  50. package/dist/bundle/chunks/{jq-AAWVUTC4.js → jq-3YU5HRKE.js} +1 -1
  51. package/dist/bundle/chunks/{md5sum-LJHKXLVT.js → md5sum-KLHZSRUA.js} +1 -1
  52. package/dist/bundle/chunks/rg-KTCMPGU6.js +32 -0
  53. package/dist/bundle/chunks/{sha1sum-NRUZZ4Q6.js → sha1sum-WKWTIZGQ.js} +1 -1
  54. package/dist/bundle/chunks/{sha256sum-5ZGJ4NJL.js → sha256sum-IUVNMBTA.js} +1 -1
  55. package/dist/bundle/chunks/{sort-JHO22QVO.js → sort-EJUT5LXD.js} +1 -1
  56. package/dist/bundle/chunks/tar-QWBXMF7K.js +62 -0
  57. package/dist/bundle/chunks/{uniq-SEKCFR7B.js → uniq-47QVBRNC.js} +1 -1
  58. package/dist/bundle/chunks/{wc-52FZ4QGS.js → wc-DFQKWSIZ.js} +1 -1
  59. package/dist/bundle/chunks/{xan-ZHXYF6B4.js → xan-2R2APJJ4.js} +1 -1
  60. package/dist/bundle/index.js +119 -119
  61. package/dist/commands/registry.d.ts +1 -1
  62. package/dist/commands/rg/file-types.d.ts +49 -0
  63. package/dist/commands/rg/gitignore.d.ts +98 -0
  64. package/dist/commands/rg/rg-options.d.ts +61 -0
  65. package/dist/commands/rg/rg-parser.d.ts +20 -0
  66. package/dist/commands/rg/rg-search.d.ts +15 -0
  67. package/dist/commands/rg/rg.d.ts +12 -0
  68. package/dist/commands/search-engine/index.d.ts +10 -0
  69. package/dist/commands/search-engine/matcher.d.ts +57 -0
  70. package/dist/commands/search-engine/regex.d.ts +27 -0
  71. package/dist/commands/tar/archive.d.ts +107 -0
  72. package/dist/commands/tar/tar.d.ts +8 -0
  73. package/dist/fs/in-memory-fs/in-memory-fs.d.ts +51 -0
  74. package/dist/fs/in-memory-fs/index.d.ts +1 -0
  75. package/dist/fs/init.d.ts +12 -0
  76. package/dist/fs/interface.d.ts +203 -0
  77. package/dist/fs/mountable-fs/index.d.ts +1 -0
  78. package/dist/fs/mountable-fs/mountable-fs.d.ts +108 -0
  79. package/dist/fs/overlay-fs/index.d.ts +1 -0
  80. package/dist/fs/overlay-fs/overlay-fs.d.ts +107 -0
  81. package/dist/fs/read-write-fs/index.d.ts +1 -0
  82. package/dist/fs/read-write-fs/read-write-fs.d.ts +47 -0
  83. package/dist/fs/utils.d.ts +17 -0
  84. package/dist/index.d.ts +1 -0
  85. package/package.json +12 -7
  86. package/dist/bin/chunks/base64-RJX7MYGG.js +0 -6
  87. package/dist/bin/chunks/grep-U2RCKOEG.js +0 -15
  88. package/dist/bin/shell/chunks/base64-RJX7MYGG.js +0 -6
  89. package/dist/bin/shell/chunks/grep-U2RCKOEG.js +0 -15
  90. package/dist/bundle/chunks/base64-F5R4G5EG.js +0 -5
  91. package/dist/bundle/chunks/grep-CTJRP2G3.js +0 -14
@@ -1,6 +1,6 @@
1
1
  import type { Command } from "../types.js";
2
2
  /** All available built-in command names (excludes network commands) */
3
- export type CommandName = "echo" | "cat" | "printf" | "ls" | "mkdir" | "touch" | "rm" | "cp" | "mv" | "ln" | "chmod" | "pwd" | "readlink" | "head" | "tail" | "wc" | "stat" | "grep" | "fgrep" | "egrep" | "sed" | "awk" | "sort" | "uniq" | "comm" | "cut" | "paste" | "tr" | "rev" | "nl" | "fold" | "expand" | "unexpand" | "strings" | "split" | "column" | "join" | "tee" | "find" | "basename" | "dirname" | "tree" | "du" | "env" | "printenv" | "alias" | "unalias" | "history" | "xargs" | "true" | "false" | "clear" | "bash" | "sh" | "jq" | "base64" | "diff" | "date" | "sleep" | "timeout" | "seq" | "expr" | "md5sum" | "sha1sum" | "sha256sum" | "file" | "html-to-markdown" | "help" | "which" | "tac" | "hostname" | "od" | "gzip" | "gunzip" | "zcat" | "yq" | "xan" | "sqlite3";
3
+ export type CommandName = "echo" | "cat" | "printf" | "ls" | "mkdir" | "touch" | "rm" | "cp" | "mv" | "ln" | "chmod" | "pwd" | "readlink" | "head" | "tail" | "wc" | "stat" | "grep" | "fgrep" | "egrep" | "rg" | "sed" | "awk" | "sort" | "uniq" | "comm" | "cut" | "paste" | "tr" | "rev" | "nl" | "fold" | "expand" | "unexpand" | "strings" | "split" | "column" | "join" | "tee" | "find" | "basename" | "dirname" | "tree" | "du" | "env" | "printenv" | "alias" | "unalias" | "history" | "xargs" | "true" | "false" | "clear" | "bash" | "sh" | "jq" | "base64" | "diff" | "date" | "sleep" | "timeout" | "seq" | "expr" | "md5sum" | "sha1sum" | "sha256sum" | "file" | "html-to-markdown" | "help" | "which" | "tac" | "hostname" | "od" | "gzip" | "gunzip" | "zcat" | "tar" | "yq" | "xan" | "sqlite3";
4
4
  /** Network command names (only available when network is configured) */
5
5
  export type NetworkCommandName = "curl";
6
6
  /** All command names including network commands */
@@ -0,0 +1,49 @@
1
+ /**
2
+ * Built-in file type definitions for rg
3
+ *
4
+ * Maps type names to file extensions and glob patterns.
5
+ * Based on ripgrep's default type definitions.
6
+ */
7
+ export interface FileType {
8
+ extensions: string[];
9
+ globs: string[];
10
+ }
11
+ /**
12
+ * Mutable file type registry for runtime type modifications
13
+ * Supports --type-add and --type-clear flags
14
+ */
15
+ export declare class FileTypeRegistry {
16
+ private types;
17
+ constructor();
18
+ /**
19
+ * Add a type definition
20
+ * Format: "name:pattern" where pattern can be:
21
+ * - "*.ext" - glob pattern
22
+ * - "include:other" - include patterns from another type
23
+ */
24
+ addType(spec: string): void;
25
+ /**
26
+ * Clear all patterns from a type
27
+ */
28
+ clearType(name: string): void;
29
+ /**
30
+ * Get a type by name
31
+ */
32
+ getType(name: string): FileType | undefined;
33
+ /**
34
+ * Get all type names
35
+ */
36
+ getAllTypes(): Map<string, FileType>;
37
+ /**
38
+ * Check if a filename matches any of the specified types
39
+ */
40
+ matchesType(filename: string, typeNames: string[]): boolean;
41
+ /**
42
+ * Check if a filename matches any recognized type
43
+ */
44
+ private matchesAnyType;
45
+ }
46
+ /**
47
+ * Format type list for --type-list output
48
+ */
49
+ export declare function formatTypeList(): string;
@@ -0,0 +1,98 @@
1
+ /**
2
+ * .gitignore parser for rg
3
+ *
4
+ * Handles:
5
+ * - Simple patterns (*.log, node_modules/)
6
+ * - Negation patterns (!important.log)
7
+ * - Directory-only patterns (build/)
8
+ * - Rooted patterns (/root-only)
9
+ * - Double-star patterns (for matching across directories)
10
+ */
11
+ import type { IFileSystem } from "../../fs/interface.js";
12
+ export declare class GitignoreParser {
13
+ private patterns;
14
+ private basePath;
15
+ constructor(basePath?: string);
16
+ /**
17
+ * Parse .gitignore content and add patterns
18
+ */
19
+ parse(content: string): void;
20
+ /**
21
+ * Convert a gitignore pattern to a regex
22
+ */
23
+ private patternToRegex;
24
+ /**
25
+ * Check if a path should be ignored
26
+ *
27
+ * @param relativePath Path relative to the gitignore location
28
+ * @param isDirectory Whether the path is a directory
29
+ * @returns true if the path should be ignored
30
+ */
31
+ matches(relativePath: string, isDirectory: boolean): boolean;
32
+ /**
33
+ * Check if a path is explicitly whitelisted by a negation pattern
34
+ *
35
+ * @param relativePath Path relative to the gitignore location
36
+ * @param isDirectory Whether the path is a directory
37
+ * @returns true if the path is whitelisted by a negation pattern
38
+ */
39
+ isWhitelisted(relativePath: string, isDirectory: boolean): boolean;
40
+ /**
41
+ * Get the base path for this gitignore
42
+ */
43
+ getBasePath(): string;
44
+ }
45
+ /**
46
+ * Hierarchical gitignore manager
47
+ *
48
+ * Loads .gitignore and .ignore files from the root down to the current directory,
49
+ * applying patterns in order (child patterns override parent patterns).
50
+ */
51
+ export declare class GitignoreManager {
52
+ private parsers;
53
+ private fs;
54
+ private skipDotIgnore;
55
+ private skipVcsIgnore;
56
+ private loadedDirs;
57
+ constructor(fs: IFileSystem, _rootPath: string, skipDotIgnore?: boolean, skipVcsIgnore?: boolean);
58
+ /**
59
+ * Load all .gitignore and .ignore files from root to the specified path
60
+ */
61
+ load(targetPath: string): Promise<void>;
62
+ /**
63
+ * Load ignore files for a directory during traversal.
64
+ * Only loads if the directory hasn't been loaded before.
65
+ */
66
+ loadForDirectory(dir: string): Promise<void>;
67
+ /**
68
+ * Add patterns from raw content at the specified base path.
69
+ * Used for --ignore-file flag.
70
+ */
71
+ addPatternsFromContent(content: string, basePath: string): void;
72
+ /**
73
+ * Check if a path should be ignored
74
+ *
75
+ * @param absolutePath Absolute path to check
76
+ * @param isDirectory Whether the path is a directory
77
+ * @returns true if the path should be ignored
78
+ */
79
+ matches(absolutePath: string, isDirectory: boolean): boolean;
80
+ /**
81
+ * Check if a path is explicitly whitelisted by a negation pattern.
82
+ * Used to include hidden files that have negation patterns like "!.foo"
83
+ *
84
+ * @param absolutePath Absolute path to check
85
+ * @param isDirectory Whether the path is a directory
86
+ * @returns true if the path is whitelisted by a negation pattern
87
+ */
88
+ isWhitelisted(absolutePath: string, isDirectory: boolean): boolean;
89
+ /**
90
+ * Quick check for common ignored directories
91
+ * Used for early pruning during traversal
92
+ */
93
+ static isCommonIgnored(name: string): boolean;
94
+ }
95
+ /**
96
+ * Load gitignore files for a search starting at the given path
97
+ */
98
+ export declare function loadGitignores(fs: IFileSystem, startPath: string, skipDotIgnore?: boolean, skipVcsIgnore?: boolean, customIgnoreFiles?: string[]): Promise<GitignoreManager>;
@@ -0,0 +1,61 @@
1
+ /**
2
+ * RgOptions interface and default values
3
+ */
4
+ export interface RgOptions {
5
+ ignoreCase: boolean;
6
+ caseSensitive: boolean;
7
+ smartCase: boolean;
8
+ fixedStrings: boolean;
9
+ wordRegexp: boolean;
10
+ lineRegexp: boolean;
11
+ invertMatch: boolean;
12
+ multiline: boolean;
13
+ multilineDotall: boolean;
14
+ patterns: string[];
15
+ patternFiles: string[];
16
+ count: boolean;
17
+ countMatches: boolean;
18
+ files: boolean;
19
+ filesWithMatches: boolean;
20
+ filesWithoutMatch: boolean;
21
+ stats: boolean;
22
+ onlyMatching: boolean;
23
+ maxCount: number;
24
+ lineNumber: boolean;
25
+ noFilename: boolean;
26
+ withFilename: boolean;
27
+ nullSeparator: boolean;
28
+ byteOffset: boolean;
29
+ column: boolean;
30
+ vimgrep: boolean;
31
+ replace: string | null;
32
+ afterContext: number;
33
+ beforeContext: number;
34
+ contextSeparator: string;
35
+ quiet: boolean;
36
+ heading: boolean;
37
+ passthru: boolean;
38
+ includeZero: boolean;
39
+ sort: "path" | "none";
40
+ json: boolean;
41
+ globs: string[];
42
+ iglobs: string[];
43
+ globCaseInsensitive: boolean;
44
+ types: string[];
45
+ typesNot: string[];
46
+ typeAdd: string[];
47
+ typeClear: string[];
48
+ hidden: boolean;
49
+ noIgnore: boolean;
50
+ noIgnoreDot: boolean;
51
+ noIgnoreVcs: boolean;
52
+ ignoreFiles: string[];
53
+ maxDepth: number;
54
+ maxFilesize: number;
55
+ followSymlinks: boolean;
56
+ searchZip: boolean;
57
+ searchBinary: boolean;
58
+ preprocessor: string | null;
59
+ preprocessorGlobs: string[];
60
+ }
61
+ export declare function createDefaultOptions(): RgOptions;
@@ -0,0 +1,20 @@
1
+ /**
2
+ * Argument parsing for rg command - Declarative approach
3
+ */
4
+ import type { ExecResult } from "../../types.js";
5
+ import { type RgOptions } from "./rg-options.js";
6
+ export interface ParseResult {
7
+ success: true;
8
+ options: RgOptions;
9
+ paths: string[];
10
+ explicitLineNumbers: boolean;
11
+ }
12
+ export interface ParseError {
13
+ success: false;
14
+ error: ExecResult;
15
+ }
16
+ export type ParseArgsResult = ParseResult | ParseError;
17
+ /**
18
+ * Parse rg command arguments
19
+ */
20
+ export declare function parseArgs(args: string[]): ParseArgsResult;
@@ -0,0 +1,15 @@
1
+ /**
2
+ * Core search logic for rg command
3
+ */
4
+ import type { CommandContext, ExecResult } from "../../types.js";
5
+ import type { RgOptions } from "./rg-options.js";
6
+ export interface SearchContext {
7
+ ctx: CommandContext;
8
+ options: RgOptions;
9
+ paths: string[];
10
+ explicitLineNumbers: boolean;
11
+ }
12
+ /**
13
+ * Execute the search with parsed options
14
+ */
15
+ export declare function executeSearch(searchCtx: SearchContext): Promise<ExecResult>;
@@ -0,0 +1,12 @@
1
+ /**
2
+ * rg - ripgrep-like recursive search
3
+ *
4
+ * Fast recursive search with smart defaults:
5
+ * - Recursive by default (unlike grep)
6
+ * - Respects .gitignore
7
+ * - Skips hidden files by default
8
+ * - Skips binary files by default
9
+ * - Smart case sensitivity (case-insensitive unless pattern has uppercase)
10
+ */
11
+ import type { Command } from "../../types.js";
12
+ export declare const rgCommand: Command;
@@ -0,0 +1,10 @@
1
+ /**
2
+ * Shared search engine for grep and rg commands
3
+ *
4
+ * Provides core text searching functionality:
5
+ * - Line-by-line content matching
6
+ * - Context lines (before/after)
7
+ * - Regex building for different modes (basic, extended, fixed, perl)
8
+ */
9
+ export { type SearchOptions, type SearchResult, searchContent, } from "./matcher.js";
10
+ export { buildRegex, convertReplacement, type RegexMode, type RegexOptions, } from "./regex.js";
@@ -0,0 +1,57 @@
1
+ /**
2
+ * Core content matching logic for search commands
3
+ */
4
+ export interface SearchOptions {
5
+ /** Select non-matching lines */
6
+ invertMatch?: boolean;
7
+ /** Print line number with output lines */
8
+ showLineNumbers?: boolean;
9
+ /** Print only a count of matching lines */
10
+ countOnly?: boolean;
11
+ /** Count individual matches instead of lines (--count-matches) */
12
+ countMatches?: boolean;
13
+ /** Filename prefix for output (empty string for no prefix) */
14
+ filename?: string;
15
+ /** Show only the matching parts of lines */
16
+ onlyMatching?: boolean;
17
+ /** Print NUM lines of leading context */
18
+ beforeContext?: number;
19
+ /** Print NUM lines of trailing context */
20
+ afterContext?: number;
21
+ /** Stop after NUM matches (0 = unlimited) */
22
+ maxCount?: number;
23
+ /** Separator between context groups (default: --) */
24
+ contextSeparator?: string;
25
+ /** Show column number of first match */
26
+ showColumn?: boolean;
27
+ /** Output each match separately (vimgrep format) */
28
+ vimgrep?: boolean;
29
+ /** Show byte offset of each match */
30
+ showByteOffset?: boolean;
31
+ /** Replace matched text with this string */
32
+ replace?: string | null;
33
+ /** Print all lines (matches use :, non-matches use -) */
34
+ passthru?: boolean;
35
+ /** Enable multiline matching (patterns can span lines) */
36
+ multiline?: boolean;
37
+ }
38
+ export interface SearchResult {
39
+ /** The formatted output string */
40
+ output: string;
41
+ /** Whether any matches were found */
42
+ matched: boolean;
43
+ /** Number of matches found */
44
+ matchCount: number;
45
+ }
46
+ /**
47
+ * Search content for regex matches and format output
48
+ *
49
+ * Handles:
50
+ * - Count only mode (-c)
51
+ * - Line numbers (-n)
52
+ * - Invert match (-v)
53
+ * - Only matching (-o)
54
+ * - Context lines (-A, -B, -C)
55
+ * - Max count (-m)
56
+ */
57
+ export declare function searchContent(content: string, regex: RegExp, options?: SearchOptions): SearchResult;
@@ -0,0 +1,27 @@
1
+ /**
2
+ * Regex building utilities for search commands
3
+ */
4
+ export type RegexMode = "basic" | "extended" | "fixed" | "perl";
5
+ export interface RegexOptions {
6
+ mode: RegexMode;
7
+ ignoreCase?: boolean;
8
+ wholeWord?: boolean;
9
+ lineRegexp?: boolean;
10
+ multiline?: boolean;
11
+ /** Makes . match newlines in multiline mode (ripgrep --multiline-dotall) */
12
+ multilineDotall?: boolean;
13
+ }
14
+ /**
15
+ * Build a JavaScript RegExp from a pattern with the specified mode
16
+ */
17
+ export declare function buildRegex(pattern: string, options: RegexOptions): RegExp;
18
+ /**
19
+ * Convert replacement string syntax to JavaScript's String.replace format
20
+ *
21
+ * Conversions:
22
+ * - $0 and ${0} -> $& (full match)
23
+ * - $name -> $<name> (named capture groups)
24
+ * - ${name} -> $<name> (braced named capture groups)
25
+ * - Preserves $1, $2, etc. for numbered groups
26
+ */
27
+ export declare function convertReplacement(replacement: string): string;
@@ -0,0 +1,107 @@
1
+ /**
2
+ * Tar archive utilities using modern-tar
3
+ *
4
+ * Provides helpers for creating and extracting tar archives
5
+ * with optional gzip, bzip2, and xz compression.
6
+ */
7
+ import { type ParsedTarEntryWithData, type TarEntry, type TarHeader } from "modern-tar";
8
+ export type { TarEntry, TarHeader, ParsedTarEntryWithData };
9
+ /**
10
+ * Entry for creating a tar archive
11
+ */
12
+ export interface TarCreateEntry {
13
+ name: string;
14
+ content?: Uint8Array | string;
15
+ mode?: number;
16
+ mtime?: Date;
17
+ isDirectory?: boolean;
18
+ isSymlink?: boolean;
19
+ linkTarget?: string;
20
+ uid?: number;
21
+ gid?: number;
22
+ }
23
+ /**
24
+ * Create a tar archive from entries
25
+ */
26
+ export declare function createArchive(entries: TarCreateEntry[]): Promise<Uint8Array>;
27
+ /**
28
+ * Create a gzip-compressed tar archive from entries
29
+ */
30
+ export declare function createCompressedArchive(entries: TarCreateEntry[]): Promise<Uint8Array>;
31
+ /**
32
+ * Parsed tar entry for extraction
33
+ */
34
+ export interface ParsedEntry {
35
+ name: string;
36
+ mode: number;
37
+ uid: number;
38
+ gid: number;
39
+ size: number;
40
+ mtime: Date;
41
+ type: "file" | "directory" | "symlink" | "hardlink" | "other";
42
+ linkTarget?: string;
43
+ content: Uint8Array;
44
+ }
45
+ /**
46
+ * Parse a tar archive and return entries
47
+ */
48
+ export declare function parseArchive(data: Uint8Array): Promise<{
49
+ entries: ParsedEntry[];
50
+ error?: string;
51
+ }>;
52
+ /**
53
+ * Parse a gzip-compressed tar archive
54
+ */
55
+ export declare function parseCompressedArchive(data: Uint8Array): Promise<{
56
+ entries: ParsedEntry[];
57
+ error?: string;
58
+ }>;
59
+ /**
60
+ * Check if data is gzip compressed (magic bytes 0x1f 0x8b)
61
+ */
62
+ export declare function isGzipCompressed(data: Uint8Array): boolean;
63
+ /**
64
+ * Check if data is bzip2 compressed (magic bytes "BZh")
65
+ */
66
+ export declare function isBzip2Compressed(data: Uint8Array): boolean;
67
+ /**
68
+ * Check if data is xz compressed (magic bytes 0xFD 0x37 0x7A 0x58 0x5A 0x00)
69
+ */
70
+ export declare function isXzCompressed(data: Uint8Array): boolean;
71
+ /**
72
+ * Create a bzip2-compressed tar archive from entries
73
+ */
74
+ export declare function createBzip2CompressedArchive(entries: TarCreateEntry[]): Promise<Uint8Array>;
75
+ /**
76
+ * Create an xz-compressed tar archive from entries
77
+ */
78
+ export declare function createXzCompressedArchive(entries: TarCreateEntry[]): Promise<Uint8Array>;
79
+ /**
80
+ * Parse a bzip2-compressed tar archive
81
+ */
82
+ export declare function parseBzip2CompressedArchive(data: Uint8Array): Promise<{
83
+ entries: ParsedEntry[];
84
+ error?: string;
85
+ }>;
86
+ /**
87
+ * Parse an xz-compressed tar archive
88
+ */
89
+ export declare function parseXzCompressedArchive(data: Uint8Array): Promise<{
90
+ entries: ParsedEntry[];
91
+ error?: string;
92
+ }>;
93
+ /**
94
+ * Check if data is zstd compressed (magic number 0x28 0xB5 0x2F 0xFD)
95
+ */
96
+ export declare function isZstdCompressed(data: Uint8Array): boolean;
97
+ /**
98
+ * Create a zstd-compressed tar archive from entries
99
+ */
100
+ export declare function createZstdCompressedArchive(entries: TarCreateEntry[]): Promise<Uint8Array>;
101
+ /**
102
+ * Parse a zstd-compressed tar archive
103
+ */
104
+ export declare function parseZstdCompressedArchive(data: Uint8Array): Promise<{
105
+ entries: ParsedEntry[];
106
+ error?: string;
107
+ }>;
@@ -0,0 +1,8 @@
1
+ /**
2
+ * tar - manipulate tape archives
3
+ *
4
+ * Supports creating, extracting, and listing tar archives
5
+ * with optional gzip, bzip2, and xz compression.
6
+ */
7
+ import type { Command } from "../../types.js";
8
+ export declare const tarCommand: Command;
@@ -0,0 +1,51 @@
1
+ import type { BufferEncoding, CpOptions, DirectoryEntry, DirentEntry, FileContent, FileEntry, FsEntry, FsStat, IFileSystem, InitialFiles, MkdirOptions, ReadFileOptions, RmOptions, SymlinkEntry, WriteFileOptions } from "../interface.js";
2
+ export type { BufferEncoding, FileContent, FileEntry, DirectoryEntry, SymlinkEntry, FsEntry, FsStat, IFileSystem, };
3
+ export interface FsData {
4
+ [path: string]: FsEntry;
5
+ }
6
+ export declare class InMemoryFs implements IFileSystem {
7
+ private data;
8
+ constructor(initialFiles?: InitialFiles);
9
+ private normalizePath;
10
+ private dirname;
11
+ private ensureParentDirs;
12
+ writeFileSync(path: string, content: FileContent, options?: WriteFileOptions | BufferEncoding, metadata?: {
13
+ mode?: number;
14
+ mtime?: Date;
15
+ }): void;
16
+ readFile(path: string, options?: ReadFileOptions | BufferEncoding): Promise<string>;
17
+ readFileBuffer(path: string): Promise<Uint8Array>;
18
+ writeFile(path: string, content: FileContent, options?: WriteFileOptions | BufferEncoding): Promise<void>;
19
+ appendFile(path: string, content: FileContent, options?: WriteFileOptions | BufferEncoding): Promise<void>;
20
+ exists(path: string): Promise<boolean>;
21
+ stat(path: string): Promise<FsStat>;
22
+ lstat(path: string): Promise<FsStat>;
23
+ private resolveSymlink;
24
+ /**
25
+ * Resolve symlinks in intermediate path components only (not the final component).
26
+ * Used by lstat which should not follow the final symlink.
27
+ */
28
+ private resolveIntermediateSymlinks;
29
+ /**
30
+ * Resolve all symlinks in a path, including intermediate components.
31
+ * For example: /home/user/linkdir/file.txt where linkdir is a symlink to "subdir"
32
+ * would resolve to /home/user/subdir/file.txt
33
+ */
34
+ private resolvePathWithSymlinks;
35
+ mkdir(path: string, options?: MkdirOptions): Promise<void>;
36
+ /**
37
+ * Synchronous version of mkdir
38
+ */
39
+ mkdirSync(path: string, options?: MkdirOptions): void;
40
+ readdir(path: string): Promise<string[]>;
41
+ readdirWithFileTypes(path: string): Promise<DirentEntry[]>;
42
+ rm(path: string, options?: RmOptions): Promise<void>;
43
+ cp(src: string, dest: string, options?: CpOptions): Promise<void>;
44
+ mv(src: string, dest: string): Promise<void>;
45
+ getAllPaths(): string[];
46
+ resolvePath(base: string, path: string): string;
47
+ chmod(path: string, mode: number): Promise<void>;
48
+ symlink(target: string, linkPath: string): Promise<void>;
49
+ link(existingPath: string, newPath: string): Promise<void>;
50
+ readlink(path: string): Promise<string>;
51
+ }
@@ -0,0 +1 @@
1
+ export { InMemoryFs } from "./in-memory-fs.js";
@@ -0,0 +1,12 @@
1
+ /**
2
+ * Filesystem Initialization
3
+ *
4
+ * Sets up the default filesystem structure for the bash environment
5
+ * including /dev, /proc, and common directories.
6
+ */
7
+ import type { IFileSystem } from "./interface.js";
8
+ /**
9
+ * Initialize the filesystem with standard directories and files
10
+ * Works with both InMemoryFs and OverlayFs (both write to memory)
11
+ */
12
+ export declare function initFilesystem(fs: IFileSystem, useDefaultLayout: boolean): void;