@archildata/just-bash 0.1.13 → 0.8.2

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/README.md CHANGED
@@ -1,155 +1,145 @@
1
1
  # @archildata/just-bash
2
2
 
3
- Archil filesystem adapter for just-bash - run bash commands against Archil distributed filesystems.
3
+ Run bash commands against your cloud storage through [Archil](https://archil.com) no local mount required. Works in scripts, CI pipelines, and interactive sessions.
4
4
 
5
- Launch an interactive shell against your Archil disk:
5
+ ## Quick Start
6
+
7
+ If you already have an Archil disk set up (see [@archildata/client](https://www.npmjs.com/package/@archildata/client) for setup), you can start a shell in one command:
6
8
 
7
9
  ```bash
8
- ARCHIL_TOKEN=adt_xxx npx @archildata/just-bash aws-us-east-1 myaccount/mydisk
10
+ ARCHIL_TOKEN=my-secret-mount-token npx @archildata/just-bash aws-us-east-1 myaccount/my-disk
9
11
  ```
10
12
 
11
- ## Installation
13
+ This drops you into an interactive shell. The files you see are the contents of your cloud bucket:
14
+
15
+ ```
16
+ $ ls
17
+ data/ logs/ config.json
18
+
19
+ $ cat config.json
20
+ {"version": 2, "debug": false}
21
+
22
+ $ echo "hello from archil" > greeting.txt
23
+ ```
24
+
25
+ Everything you do here — reads, writes, renames, deletes — goes through Archil to your bucket.
26
+
27
+ ## Using in Your Code
28
+
29
+ The interactive shell is great for poking around, but you can also run bash commands from your own code. This is useful for scripts, CI pipelines, AI agents, or anywhere you want to run shell commands against your cloud storage.
12
30
 
13
31
  ```bash
14
32
  npm install @archildata/just-bash @archildata/client just-bash
15
33
  ```
16
34
 
17
- ## Quick Start
18
-
19
35
  ```typescript
20
36
  import { ArchilClient } from '@archildata/client';
21
- import { ArchilFs } from '@archildata/just-bash';
37
+ import { ArchilFs, createArchilCommand } from '@archildata/just-bash';
22
38
  import { Bash } from 'just-bash';
23
39
 
24
- // Connect to Archil
40
+ // Connect to your disk
25
41
  const client = await ArchilClient.connect({
26
42
  region: 'aws-us-east-1',
27
- diskName: 'myaccount/mydisk',
28
- authToken: 'adt_xxx', // or omit for IAM auth
43
+ diskName: 'myaccount/my-disk',
44
+ authToken: 'my-secret-mount-token',
29
45
  });
30
46
 
31
- // Create filesystem adapter
32
- const fs = new ArchilFs(client);
33
-
34
- // Use with just-bash
35
- const bash = new Bash({ fs });
47
+ // Create a filesystem adapter and a bash executor
48
+ const fs = await ArchilFs.create(client);
49
+ const bash = new Bash({
50
+ fs,
51
+ customCommands: [createArchilCommand(client, fs)],
52
+ });
36
53
 
37
- // Run commands
54
+ // Run commands just like you would in a terminal
38
55
  const result = await bash.exec('ls -la /');
39
56
  console.log(result.stdout);
40
57
 
41
- // Read files
42
- const content = await bash.exec('cat /myfile.txt');
58
+ // Write a file
59
+ await bash.exec('echo "hello world" > /greeting.txt');
60
+
61
+ // Read it back
62
+ const cat = await bash.exec('cat /greeting.txt');
63
+ console.log(cat.stdout); // "hello world"
43
64
 
44
- // Close when done
65
+ // Clean up
45
66
  await client.close();
46
67
  ```
47
68
 
48
- ## Writing Files (Delegations)
69
+ ## Using the Filesystem Adapter Directly
49
70
 
50
- Archil uses a delegation system for write access. Before writing, you need to "checkout" the directory or file:
71
+ If you don't need bash and just want standard file operations, you can use `ArchilFs` on its own. It works like Node.js `fs`:
51
72
 
52
73
  ```typescript
53
- // Get the inode ID for a path
54
- const inodeId = await fs.resolveInodeId('/mydir');
55
-
56
- // Checkout to get write access
57
- await client.checkout(inodeId);
58
-
59
- // Now you can write
60
- await bash.exec('echo "hello" > /mydir/newfile.txt');
61
-
62
- // Release the delegation when done
63
- await client.checkin(inodeId);
74
+ const fs = await ArchilFs.create(client);
75
+
76
+ await fs.writeFile('/notes.txt', 'some content');
77
+ const content = await fs.readFile('/notes.txt');
78
+ const entries = await fs.readdir('/');
79
+ const stats = await fs.stat('/notes.txt');
80
+ await fs.mkdir('/mydir', { recursive: true });
81
+ await fs.cp('/notes.txt', '/mydir/notes-copy.txt');
82
+ await fs.rm('/notes.txt');
64
83
  ```
65
84
 
66
- For shared/multi-client access, use `force` to revoke existing delegations:
67
-
68
- ```typescript
69
- await client.checkout(inodeId, { force: true });
70
- ```
85
+ ## Writing Files (Delegations)
71
86
 
72
- ## With User Context
87
+ Archil uses a delegation system for writes. When multiple clients connect to the same disk, delegations coordinate who can write to what. Before writing to a file or directory, you "check out" a delegation on it. When you're done, you "check in" to release it.
73
88
 
74
- Specify a Unix user context for permission checks:
89
+ In the interactive shell, use the built-in `archil` command:
75
90
 
76
- ```typescript
77
- const fs = new ArchilFs(client, {
78
- user: { uid: 1000, gid: 1000 }
79
- });
91
+ ```
92
+ $ archil checkout /mydir
93
+ $ echo "hello" > /mydir/newfile.txt
94
+ $ archil checkin /mydir
80
95
  ```
81
96
 
82
- ## Interactive Shell
83
-
84
- The package includes an interactive shell for testing:
85
-
86
- ```bash
87
- # Positional arguments (recommended)
88
- npx @archildata/just-bash aws-us-east-1 myaccount/mydisk
97
+ In code, use the client directly:
89
98
 
90
- # With flags
91
- npx @archildata/just-bash --region aws-us-east-1 --disk myaccount/mydisk
99
+ ```typescript
100
+ const inodeId = await fs.resolveInodeId('/mydir');
101
+ await client.checkout(inodeId);
92
102
 
93
- # With token (use env var to keep out of shell history)
94
- ARCHIL_TOKEN=xxx npx @archildata/just-bash aws-us-east-1 myaccount/mydisk
103
+ await bash.exec('echo "hello" > /mydir/newfile.txt');
95
104
 
96
- # With debug logging
97
- npx @archildata/just-bash aws-us-east-1 myaccount/mydisk --log-level debug
105
+ await client.checkin(inodeId);
98
106
  ```
99
107
 
100
- Shell commands:
101
- - Standard bash commands (`ls`, `cat`, `echo`, etc.)
102
- - `archil checkout [--force] <path>` - Acquire write delegation
103
- - `archil checkin <path>` - Release write delegation
104
- - `archil help` - Show archil commands
105
-
106
- ## API
108
+ ## Subdirectory Mounting
107
109
 
108
- ### `ArchilFs`
110
+ You can mount a subdirectory of a disk instead of the root. This is useful when your bucket has a project nested inside it:
109
111
 
110
- ```typescript
111
- new ArchilFs(client: ArchilClient, options?: { user?: UnixUser })
112
+ ```bash
113
+ ARCHIL_TOKEN=my-secret-mount-token npx @archildata/just-bash aws-us-east-1 myaccount/my-disk:/data/project
112
114
  ```
113
115
 
114
- #### Read Operations
115
- - `readFile(path, encoding?)` - Read file as string
116
- - `readFileBuffer(path)` - Read file as Uint8Array
117
- - `readdir(path)` - List directory entries
118
- - `stat(path)` / `lstat(path)` - Get file stats
119
- - `exists(path)` - Check if path exists
120
- - `readlink(path)` - Read symlink target
116
+ ## Interactive Shell Reference
121
117
 
122
- #### Write Operations
123
- - `writeFile(path, content)` - Write file
124
- - `appendFile(path, content)` - Append to file
125
- - `mkdir(path, options?)` - Create directory
126
- - `rm(path, options?)` - Delete file/directory
127
- - `cp(src, dest, options?)` - Copy
128
- - `mv(src, dest)` - Move/rename
129
- - `symlink(target, path)` - Create symlink
130
-
131
- #### Utilities
132
- - `resolveInodeId(path)` - Get inode ID for delegation operations
133
-
134
- ## Debugging
118
+ ```bash
119
+ # Basic usage
120
+ npx @archildata/just-bash <region> <org>/<disk>
135
121
 
136
- Enable debug logging with the `DEBUG` environment variable:
122
+ # With mount token
123
+ ARCHIL_TOKEN=xxx npx @archildata/just-bash aws-us-east-1 myaccount/my-disk
137
124
 
138
- ```bash
139
- # Enable archil:fs logging
140
- DEBUG=archil:fs node myapp.js
125
+ # With subdirectory
126
+ npx @archildata/just-bash aws-us-east-1 myaccount/my-disk:/path/to/subdir
141
127
 
142
- # Enable all archil debug logging
143
- DEBUG=archil:* node myapp.js
128
+ # With debug logging
129
+ npx @archildata/just-bash aws-us-east-1 myaccount/my-disk --log-level debug
144
130
  ```
145
131
 
146
- ## Performance
132
+ Shell commands:
133
+ - Standard bash commands (`ls`, `cat`, `echo`, `cp`, `mv`, `rm`, etc.)
134
+ - `archil checkout [--force] <path>` — acquire write delegation
135
+ - `archil checkin <path>` — release write delegation
136
+ - `archil list-delegations` — show currently held delegations
137
+ - `archil help` — show archil commands
147
138
 
148
- - **Chunked reads** - Large files read in 4 MiB chunks
149
- - **Native protocol** - Direct Archil protocol access, no FUSE overhead
139
+ ## Platform Support
150
140
 
151
- > **Note:** For best performance, run your application in the same region as your Archil disk (e.g., if your disk is in `aws-us-east-1`, deploy your app to AWS us-east-1).
141
+ Requires **Linux** (x64 or arm64, glibc) or **macOS** (Apple Silicon / arm64) for the native filesystem client.
152
142
 
153
- ## License
143
+ ## Support
154
144
 
155
- MIT
145
+ Questions, feature requests, or issues? Reach us at **support@archil.com**.