buninu 0.3.0 → 0.4.0

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 (142) hide show
  1. package/CHANGELOG.md +71 -0
  2. package/README.md +334 -37
  3. package/apps/bunmsh/CHANGELOG.md +262 -0
  4. package/apps/bunmsh/LICENSE +21 -0
  5. package/apps/bunmsh/LICENSE-MKSH +295 -0
  6. package/apps/bunmsh/PORTING.md +192 -0
  7. package/apps/bunmsh/README.md +801 -0
  8. package/apps/bunmsh/bunmsh +7 -0
  9. package/apps/bunmsh/bunshell.md +61 -0
  10. package/apps/bunmsh/help/README.md +1945 -0
  11. package/apps/bunmsh/help/alias.md +22 -0
  12. package/apps/bunmsh/help/basename.md +38 -0
  13. package/apps/bunmsh/help/builtin.md +25 -0
  14. package/apps/bunmsh/help/bun.md +27 -0
  15. package/apps/bunmsh/help/bunmsh.md +47 -0
  16. package/apps/bunmsh/help/cat.md +31 -0
  17. package/apps/bunmsh/help/catfancy.md +35 -0
  18. package/apps/bunmsh/help/cd.md +22 -0
  19. package/apps/bunmsh/help/chmod.md +27 -0
  20. package/apps/bunmsh/help/clear.md +21 -0
  21. package/apps/bunmsh/help/colon.md +22 -0
  22. package/apps/bunmsh/help/command.md +27 -0
  23. package/apps/bunmsh/help/cp.md +28 -0
  24. package/apps/bunmsh/help/cut.md +25 -0
  25. package/apps/bunmsh/help/date.md +25 -0
  26. package/apps/bunmsh/help/dirname.md +25 -0
  27. package/apps/bunmsh/help/echo.md +25 -0
  28. package/apps/bunmsh/help/env.md +27 -0
  29. package/apps/bunmsh/help/eval.md +22 -0
  30. package/apps/bunmsh/help/exec.md +22 -0
  31. package/apps/bunmsh/help/exit.md +21 -0
  32. package/apps/bunmsh/help/export.md +22 -0
  33. package/apps/bunmsh/help/false.md +22 -0
  34. package/apps/bunmsh/help/find.md +33 -0
  35. package/apps/bunmsh/help/getopts.md +28 -0
  36. package/apps/bunmsh/help/grep.md +34 -0
  37. package/apps/bunmsh/help/head.md +27 -0
  38. package/apps/bunmsh/help/kill.md +27 -0
  39. package/apps/bunmsh/help/ln.md +28 -0
  40. package/apps/bunmsh/help/ls.md +37 -0
  41. package/apps/bunmsh/help/lsbun.md +29 -0
  42. package/apps/bunmsh/help/lsfancy.md +37 -0
  43. package/apps/bunmsh/help/md5sum.md +21 -0
  44. package/apps/bunmsh/help/mkdir.md +27 -0
  45. package/apps/bunmsh/help/mktemp.md +26 -0
  46. package/apps/bunmsh/help/mv.md +26 -0
  47. package/apps/bunmsh/help/print.md +30 -0
  48. package/apps/bunmsh/help/printf.md +25 -0
  49. package/apps/bunmsh/help/pwd.md +21 -0
  50. package/apps/bunmsh/help/read.md +27 -0
  51. package/apps/bunmsh/help/readonly.md +27 -0
  52. package/apps/bunmsh/help/realpath.md +21 -0
  53. package/apps/bunmsh/help/rm.md +33 -0
  54. package/apps/bunmsh/help/rmdir.md +27 -0
  55. package/apps/bunmsh/help/sed.md +29 -0
  56. package/apps/bunmsh/help/seq.md +29 -0
  57. package/apps/bunmsh/help/serve.md +50 -0
  58. package/apps/bunmsh/help/set.md +26 -0
  59. package/apps/bunmsh/help/sha256sum.md +21 -0
  60. package/apps/bunmsh/help/shift.md +23 -0
  61. package/apps/bunmsh/help/sleep.md +25 -0
  62. package/apps/bunmsh/help/sort.md +29 -0
  63. package/apps/bunmsh/help/source.md +23 -0
  64. package/apps/bunmsh/help/tab.md +30 -0
  65. package/apps/bunmsh/help/tac.md +29 -0
  66. package/apps/bunmsh/help/tail.md +27 -0
  67. package/apps/bunmsh/help/tee.md +25 -0
  68. package/apps/bunmsh/help/test.md +30 -0
  69. package/apps/bunmsh/help/time.md +29 -0
  70. package/apps/bunmsh/help/touch.md +26 -0
  71. package/apps/bunmsh/help/tr.md +26 -0
  72. package/apps/bunmsh/help/true.md +22 -0
  73. package/apps/bunmsh/help/type.md +21 -0
  74. package/apps/bunmsh/help/umask.md +22 -0
  75. package/apps/bunmsh/help/unalias.md +28 -0
  76. package/apps/bunmsh/help/uname.md +31 -0
  77. package/apps/bunmsh/help/unset.md +28 -0
  78. package/apps/bunmsh/help/wc.md +27 -0
  79. package/apps/bunmsh/help/whence.md +26 -0
  80. package/apps/bunmsh/help/which.md +41 -0
  81. package/apps/bunmsh/help/yes.md +23 -0
  82. package/apps/bunmsh/package.json +26 -0
  83. package/apps/bunmsh/serve.js +468 -0
  84. package/apps/bunmsh/single-exe/README.md +402 -0
  85. package/apps/bunmsh/single-exe/assetsHelper.js +371 -0
  86. package/apps/bunmsh/single-exe/assetsLoader.mjs +85 -0
  87. package/apps/bunmsh/single-exe/assetsPacker.js +218 -0
  88. package/apps/bunmsh/single-exe/compiled.js +527 -0
  89. package/apps/bunmsh/single-exe/entry.mjs +17 -0
  90. package/apps/bunmsh/src/cat-fancy.js +117 -0
  91. package/apps/bunmsh/src/cat-operands.js +31 -0
  92. package/apps/bunmsh/src/completion.js +247 -0
  93. package/apps/bunmsh/src/environment.js +61 -0
  94. package/apps/bunmsh/src/fancy-ls.js +186 -0
  95. package/apps/bunmsh/src/find.js +119 -0
  96. package/apps/bunmsh/src/history.js +198 -0
  97. package/apps/bunmsh/src/main.js +776 -0
  98. package/apps/bunmsh/src/mouse.js +103 -0
  99. package/apps/bunmsh/src/shell.js +3557 -0
  100. package/apps/bunmsh/test/catfancy.test.js +102 -0
  101. package/apps/bunmsh/test/reference-source.sh +1 -0
  102. package/apps/bunmsh/test/reference.test.js +677 -0
  103. package/apps/bunmsh/test/serve/README.md +3 -0
  104. package/apps/bunmsh/test/serve/bad.json +1 -0
  105. package/apps/bunmsh/test/serve/data.json +1 -0
  106. package/apps/bunmsh/test/serve/data.json5 +1 -0
  107. package/apps/bunmsh/test/serve/data.jsonc +2 -0
  108. package/apps/bunmsh/test/serve/data.jsonl +2 -0
  109. package/apps/bunmsh/test/serve/data.ndjson +1 -0
  110. package/apps/bunmsh/test/serve/data.toml +3 -0
  111. package/apps/bunmsh/test/serve/data.ts +15 -0
  112. package/apps/bunmsh/test/serve/data.xml +1 -0
  113. package/apps/bunmsh/test/serve/data.yaml +3 -0
  114. package/apps/bunmsh/test/serve/data.yml +1 -0
  115. package/apps/bunmsh/test/serve.test.js +241 -0
  116. package/apps/bunmsh/test/shell.test.js +1778 -0
  117. package/apps/bunmsh/test/t.sh +12 -0
  118. package/apps/cmdlist +6 -1
  119. package/apps/jsgotty/gotty.js +65 -76
  120. package/apps/jsgotty/package.json +6 -1
  121. package/apps/jsgotty/single-exe/README.md +358 -54
  122. package/apps/jsgotty/single-exe/assetsHelper.js +293 -12
  123. package/apps/jsgotty/single-exe/assetsLoader.mjs +1 -1
  124. package/apps/jsgotty/single-exe/assetsPacker.js +218 -0
  125. package/apps/jsgotty/single-exe/compiled.js +379 -19
  126. package/apps/jsgotty/single-exe/entry.mjs +16 -2
  127. package/apps/jsgotty/zmodem-node.js +14 -12
  128. package/apps/jsmdcui/CHANGELOG.md +56 -0
  129. package/apps/jsmdcui/package.json +12 -2
  130. package/apps/jsmdcui/single-exe/README.md +298 -375
  131. package/apps/jsmdcui/single-exe/assetsHelper.js +198 -18
  132. package/apps/jsmdcui/single-exe/assetsLoader.mjs +1 -1
  133. package/apps/jsmdcui/single-exe/assetsPacker.js +218 -0
  134. package/apps/jsmdcui/single-exe/compiled.js +291 -5
  135. package/apps/jsmdcui/single-exe/entry.mjs +7 -0
  136. package/apps/jsmdcui/src/index.js +11 -8
  137. package/apps/jsmdcui/tests/jmigt.js +16 -0
  138. package/bin/bunmsh.bat +3 -0
  139. package/bin/bunmsh.sh +5 -0
  140. package/bin/init.js +48 -5
  141. package/bin/install.js +541 -0
  142. package/package.json +4 -2
package/CHANGELOG.md CHANGED
@@ -1,5 +1,76 @@
1
1
  # Changelog
2
2
 
3
+ ## 0.4.0 - 2026-08-30
4
+
5
+ ### Added
6
+
7
+ - `--install [dir]` (`-i`) and `--strip-install [dir]` (`-si`) copy the running
8
+ installation into a directory that outlives the `npx` cache. `--install`
9
+ creates `<dir>/buninu` as the new `BUNINU_HOME`, `--strip-install` makes
10
+ `<dir>` itself that root, and both default to the current directory. The
11
+ implementation is `bin/install.js`, which runs on its own as well as being
12
+ imported by `bin/init.js`; run directly with no arguments it installs.
13
+ Relative symbolic links are recreated exactly as stored rather than followed,
14
+ so `bin/androidNativeLibs -> ../..` stays a link instead of dragging the
15
+ parent tree into the copy. `cp -a` is used when `cp` is on `PATH`, and an
16
+ equivalent `node:fs` walk otherwise; the two were verified to agree on
17
+ content, link targets, permissions and whole-second timestamps across every
18
+ entry of the tree.
19
+ - Installing over an existing Buninu updates it in place. The copy only ever
20
+ adds and overwrites, so `apps/<name>/` commands, `bin/*.sh` overrides and the
21
+ Bun binaries `bin/bun.sh` extracted are left alone, and the three files that
22
+ belong to the package and to the user at once are merged: the local `buninu`
23
+ section of `package.json` is kept, command names added to `apps/cmdlist` are
24
+ kept, and `.bashrc` is kept whenever it only adds lines to the shipped one,
25
+ including lines inserted in the middle. A `.bashrc` that cannot be merged
26
+ that way is left exactly as it is, with the shipped version written beside it
27
+ as `.bashrc.dist`.
28
+ - Before replacing the package's own files, an update runs `bun pm diff`
29
+ against the version the installation reports and lists the files that no
30
+ longer match it, then asks before continuing. Nothing is recorded inside the
31
+ installation to make this work — the published package is the reference — so
32
+ the check needs the network, and when it cannot run, or does not finish
33
+ within 60 seconds, it asks rather than assuming there was nothing to lose.
34
+ `--yes` answers ahead of time, which a run without a terminal needs;
35
+ `--force` replaces everything without merging or checking. An existing
36
+ installation is always named by absolute path before anything is written.
37
+
38
+ - `buninu.xdgDataHome` points `XDG_DATA_HOME` at a directory of your choosing:
39
+ `true` puts it inside the installation at `$BUNINU_HOME/.local/share`, and a
40
+ string names one outright, resolved from the `package.json` directory when it
41
+ is relative. The directory is created at startup. What this moves in practice
42
+ is bunmsh's command history, which lives at `$XDG_DATA_HOME/bunmsh/history`,
43
+ so `true` is what makes a shell's history travel with a copied installation
44
+ instead of staying on the machine it was typed on. `HOME` is deliberately not
45
+ touched by it, so SSH keys and Git configuration in the user's own home keep
46
+ working and bunmsh can still import an existing `~/.bash_history`.
47
+
48
+ - Refusing to install into an occupied directory now says which check the
49
+ directory failed — no readable `package.json`, or one naming a different
50
+ package — instead of reporting every case as "is not a buninu installation".
51
+ Whether a directory is an installation to update is decided by that name
52
+ alone: a Buninu missing `bin/init.js` is a damaged installation rather than
53
+ somebody else's directory, so an update repairs it, merging the local
54
+ configuration back in, where before `--force` was the only way through and
55
+ took that configuration with it. Every refusal names the directory by
56
+ absolute path.
57
+
58
+ ### Fixed
59
+
60
+ - `HOME` no longer falls back to the package directory when the environment
61
+ does not set it. Windows does not set `HOME`, so a Windows session had its
62
+ home pointed at the disposable `npx` cache, taking anything written there —
63
+ bunmsh's command history included — with it when the cache was cleared. It
64
+ now falls back to the operating system's own home directory for the user.
65
+
66
+ ## 0.3.2 - 2026-08-29
67
+
68
+ - Added bunmsh to bin and cmdlist
69
+
70
+ ## 0.3.1 - 2026-08-29
71
+
72
+ - Added bunmsh to buninu
73
+
3
74
  ## 0.3.0 - 2026-08-21
4
75
 
5
76
  ### Added
package/README.md CHANGED
@@ -25,20 +25,6 @@
25
25
  See [ARCHITECTURE.md](ARCHITECTURE.md) for the complete architecture, portability model,
26
26
  and self-bootstrapping design.
27
27
 
28
- ## Differences from upstream
29
-
30
- ### The bundled jsmdcui
31
-
32
- * Is configured editor-first by MDCUI_DEFAULT_EDIT
33
- * The command `jmi` with a Markdown file opens the normal terminal editor.(js micro editor)
34
- * The command `jsmdcui` preserves its original behavior: `apps/jsmdcui/jsmdcui.sh`, which starts its `tui` entry point with `--mdcui` when running markdown Apps, and forwards all command-line arguments.
35
- * Adds the Buninu-only `# syntax: markdown` marker for Markdown highlighting in extensionless files; upstreaming may be considered later.
36
-
37
- ### The bundled jsgotty
38
-
39
- * No longer depends on or ships `node-pty`.
40
- * Its PTY is provided by Bun's terminal API.
41
-
42
28
  ## Install Bun
43
29
 
44
30
  Buninu requires [Bun](https://bun.com). On Android, install Bun in Termux:
@@ -52,12 +38,28 @@ On Linux and Windows, follow the
52
38
 
53
39
  ## Start
54
40
 
55
- Run the npm package:
41
+ ### Start a remote shell in a Browser
42
+
43
+ To try it, run the npm package. This runs Buninu from the `npx` cache, which
44
+ is a fine place to look around in and a bad place to keep anything:
56
45
 
57
46
  ```sh
58
47
  npx buninu
59
48
  ```
60
49
 
50
+ To keep it, install it somewhere of your own first, and start it from there
51
+ from then on. That directory becomes `BUNINU_HOME`: the installation's own
52
+ root, yours to edit and to carry to another machine. See
53
+ [Install and update](#install-and-update):
54
+
55
+ ```sh
56
+ # Creates ~/somewhere/buninu, which is now BUNINU_HOME
57
+ npx buninu --install ~/somewhere
58
+
59
+ # Start it from there from now on
60
+ bun ~/somewhere/buninu/bin/init.js
61
+ ```
62
+
61
63
  Or run it from a source checkout:
62
64
 
63
65
  ```sh
@@ -68,19 +70,194 @@ The launcher automatically chooses a free TCP port and detects an available
68
70
  shell for the current platform. Other arguments are forwarded to jsgotty:
69
71
 
70
72
  ```sh
71
- npx buninu --credential user:pass
73
+ # Serve on port 9000 instead of picking a free one
72
74
  npx buninu --port 9000
73
- npx buninu --jsgotty --help
74
75
 
75
- # public: listen on every interface, reachable from other devices on the network, be cautious!
76
- npx buninu -a 0.0.0.0
76
+ # Ask for a username and password before handing over the terminal
77
+ npx buninu --credential user:pass
78
+
79
+ # Accept connections from other machines, not just this one. By default the
80
+ # terminal is reachable only from the computer it runs on; this opens it to
81
+ # anything that can reach this machine over the network, and the terminal is
82
+ # a working shell, so give it a password at the same time.
83
+ npx buninu -a 0.0.0.0 --credential user:pass
84
+ ```
85
+
86
+ Read [Security](#security) before using that last one.
87
+
88
+ Buninu's own options are listed under
89
+ [Command-line usage](#command-line-usage).
90
+
91
+ ### Start a local shell in a Terminal (experimental)
92
+
93
+ Drops you straight into [bunmsh](apps/bunmsh/README.md) (Bun Modern Shell), a
94
+ dependency-free, mksh-inspired command shell that runs on Bun, without going
95
+ through the browser/jsgotty flow.
96
+
97
+ To try it:
98
+
99
+ ```sh
100
+ npx buninu --local
101
+ ```
102
+
103
+ To keep it, install it the same way as above and pass `--local` to the
104
+ installed copy from then on. See [Install and update](#install-and-update):
105
+
106
+ ```sh
107
+ # Creates ~/somewhere/buninu, which is now BUNINU_HOME
108
+ npx buninu --install ~/somewhere
109
+
110
+ # Start bunmsh from there from now on
111
+ bun ~/somewhere/buninu/bin/init.js --local
112
+ ```
113
+
114
+ Command history is kept in your own home directory either way, so it survives
115
+ `npx`. What does not is anything you add to the installation itself — aliases
116
+ in its `.bashrc`, commands of your own under `apps/` — since that lives in the
117
+ package, and under `npx` the package is a cache directory.
118
+ See [Data & Persistence](#data--persistence).
119
+
120
+ Or run it from a source checkout:
121
+
122
+ ```sh
123
+ bun ./bin/init.js --local
124
+ ```
125
+
126
+ Buninu's own tools (`rz`, `sz`, `showimg`, `tts`, `xdg-open`, `native-bridge`,
127
+ etc.) stay available inside this shell too, same as in the browser session.
128
+
129
+ ## Data & Persistence
130
+
131
+ Running Buninu via `npx` works like a container: `npx` fetches the package into
132
+ a cache directory and runs it from there, which is fine as a temporary working
133
+ directory but isn't guaranteed to survive between runs — version bumps,
134
+ `npx clear-npx-cache`, or normal cache eviction can all wipe it. That directory
135
+ is where the shell starts, so nothing left sitting in it is safe.
136
+
137
+ The answer is to stop running it from there: [install it](#install-and-update)
138
+ into a directory of your own, and `BUNINU_HOME` becomes somewhere you can keep
139
+ things, edit files in, and carry to another machine.
140
+
141
+ Once it is installed, files you leave in `BUNINU_HOME` are safe, updates
142
+ included — an update only adds and overwrites the package's own files and
143
+ never deletes anything else. Your own home directory is untouched and still
144
+ reachable as `~`, so work you would rather keep separate from Buninu, or that
145
+ is too large to carry around with it, can just as well live there.
146
+
147
+ Two things live outside `BUNINU_HOME` either way, because they belong to the
148
+ machine rather than to Buninu:
149
+
150
+ - `HOME` stays your own home directory. Buninu never replaces it, so a shell
151
+ started here still finds your SSH keys, your Git configuration, and anything
152
+ else you keep there.
153
+ - bunmsh writes its command history to `$XDG_DATA_HOME/bunmsh/history`, or
154
+ `$HOME/.local/share/bunmsh/history` when that is unset. It persists between
155
+ sessions, and by default it stays on the machine it was typed on rather than
156
+ travelling with an installation.
157
+
158
+ Set [`buninu.xdgDataHome`](#data-directory-optional) to move that history, and
159
+ anything else written to the XDG data directory, into the installation so it
160
+ travels with it. Keep in mind that a history file records the commands it was
161
+ given, so one carried on removable media carries whatever was typed into it.
162
+
163
+ ## Install and update
164
+
165
+ Copy this installation into a directory that is yours to keep, and run it
166
+ from there instead of from the `npx` cache:
167
+
168
+ ```sh
169
+ # Creates ~/somewhere/buninu as BUNINU_HOME
170
+ npx buninu --install ~/somewhere
171
+
172
+ # Makes ~/buninu itself BUNINU_HOME, with no directory of its own
173
+ npx buninu --strip-install ~/buninu
174
+ ```
175
+
176
+ Both default to the current directory. The two differ only in where
177
+ `BUNINU_HOME` — the installation's own root, see
178
+ [Environment](#environment) — ends up: below the directory you named, or at
179
+ it. `npx buninu --install --help` lists every install option in full.
180
+
181
+ An installation is started the same two ways `npx buninu` is, by running its
182
+ own `bin/init.js` instead of the package name:
183
+
184
+ ```sh
185
+ # Terminal in a browser, as usual
186
+ bun $BUNINU_HOME/bin/init.js
187
+
188
+ # bunmsh in this terminal (experimental)
189
+ bun $BUNINU_HOME/bin/init.js --local
190
+ ```
191
+
192
+ Every option described under [Start](#start) works the same way here, `--local`
193
+ included; nothing about an installed copy behaves differently from the one
194
+ `npx` runs.
195
+
196
+ Installing over an existing Buninu updates it in place. Files are only added
197
+ and overwritten, never deleted, so anything you added of your own is left
198
+ alone: your `apps/<name>/` commands, your `bin/*.sh` overrides, the Bun
199
+ binaries `bin/bun.sh` extracted, and any working file you left in the tree.
200
+
201
+ Three files belong to you and to the package at the same time, and are merged
202
+ rather than replaced:
203
+
204
+ | File | What is kept |
205
+ |---|---|
206
+ | `package.json` | Your `buninu` section. Every other field, `version` included, comes from the new package. |
207
+ | `apps/cmdlist` | Command names you added. They are appended below the shipped list. |
208
+ | `.bashrc` | Your version, whenever it only adds lines to the shipped one — including lines inserted in the middle. |
209
+
210
+ When `.bashrc` cannot be merged that way, because a line the package ships was
211
+ changed or removed rather than added to, your file is left exactly as it is
212
+ and the package's version is written beside it as `.bashrc.dist` for you to
213
+ reconcile by hand. Nothing is overwritten silently.
214
+
215
+ Every other file belongs to the package and is replaced. Before doing that, an
216
+ update asks the registry what the installation originally shipped with and
217
+ lists the files that no longer match, so editing one of the package's own files
218
+ is not quietly undone:
219
+
220
+ ```
221
+ buninu: found buninu@0.3.1 at /home/you/buninu
222
+ buninu: comparing it against the published 0.3.1 for local changes...
223
+ buninu: 1 file(s) differ from buninu@0.3.1 and will be replaced:
224
+ apps/xclip/xclip.js
225
+ Update anyway? (y/N)
77
226
  ```
78
227
 
79
- As the first argument, `--jsgotty`, `--jsmdcui`, or `--musl-la` bypasses the
80
- shell/command startup flow entirely: it spawns that app directly with every
81
- remaining argument forwarded to it, and exits with its exit code. Use this to
82
- reach an app's own options directly, for example `npx buninu --jsgotty --help`
83
- to see jsgotty's actual flag reference instead of Buninu's.
228
+ An existing installation is always named, by absolute path, before anything is
229
+ written to it — `--force` included, since that one replaces it without asking.
230
+
231
+ Only `y` continues; anything else cancels and leaves the installation
232
+ untouched. The three merged files above are left out of that list, since they
233
+ are already kept. `--yes` answers for you, which is also what a script or any
234
+ other run without a terminal needs. Nothing about this is recorded inside the
235
+ installation: the published package is the reference, so the check needs the
236
+ network, and when it cannot run the update says so and goes ahead.
237
+
238
+ Three more things are worth knowing about:
239
+
240
+ - Installing from a checkout that already carries changes made since its
241
+ version was published — that is, while working on Buninu itself — compares
242
+ the installation against a reference its own files no longer match, so the
243
+ list names those unreleased changes rather than anything you did. Cloning it
244
+ and adding your own files on top does not.
245
+ - A file the package **stopped** shipping is not removed from an existing
246
+ installation, because an update never deletes. Stale files accumulate
247
+ across updates.
248
+ - `--force` skips both the merge and the check, and installs the shipped
249
+ versions over yours. It is also what installs into a non-empty directory that
250
+ is not a Buninu installation, which is otherwise refused — by absolute path,
251
+ saying which check the directory failed.
252
+
253
+ Whether a directory counts as an installation to update is decided by the name
254
+ in its `package.json`. An installation that has lost files, `bin/init.js`
255
+ included, is a damaged one rather than somebody else's directory, so installing
256
+ over it repairs it and still merges your configuration back in.
257
+
258
+ A source checkout's own `.git` is never copied into an installation, so
259
+ installing into a directory that is itself a repository leaves that repository
260
+ alone.
84
261
 
85
262
  ## Security
86
263
 
@@ -97,19 +274,48 @@ arguments override the flags baked into `scripts.start`. Also pass
97
274
  are not a substitute for authentication once the server is reachable from
98
275
  outside the machine.
99
276
 
100
- ## Command-line information
277
+ ## Command-line usage
278
+
279
+ These are flags to `bin/init.js` itself, resolved before Buninu starts.
280
+ Everything else on the command line is forwarded to jsgotty.
101
281
 
102
282
  ```text
103
283
  -h, --help Show command-line help
104
284
  -V, --version Show the Buninu, Bun, platform, and architecture versions
105
- --readme Render README.md in the terminal
106
- --changelog Render CHANGELOG.md in the terminal
285
+ --readme Render README.md in the terminal
286
+ --changelog Render CHANGELOG.md in the terminal
287
+ --local Start bunmsh in this terminal instead of a browser terminal
288
+
289
+ -i, --install [dir] Install into <dir>/buninu (default: .)
290
+ -si, --strip-install [dir] Install into <dir> itself
291
+ --export [output.tgz] Export this installation as a tarball
292
+ --export-config [out.json] Export this package.json
293
+
294
+ --shell <path|name> Override buninu.shell for this run
295
+ --command <command> Override buninu.command for this run
296
+ ```
297
+
298
+ `--install --help` lists the install options in full, including `--force` and
299
+ `--yes`; see [Install and update](#install-and-update) for what an update does
300
+ with files you changed. The other groups are covered by
301
+ [Start](#start), [Export](#export), [Shell selection](#shell-selection-optional)
302
+ and [Startup command](#startup-command-optional).
303
+
304
+ ### Launching a bundled app directly
305
+
306
+ As the **first** argument, `--jsgotty`, `--jsmdcui`, or `--musl-la` bypasses the
307
+ shell and startup-command flow entirely: it spawns that app with every
308
+ remaining argument forwarded to it, and exits with its exit code.
309
+
310
+ ```text
107
311
  --jsgotty [args...] Spawn jsgotty directly and exit with its exit code
108
312
  --jsmdcui [args...] Spawn jsmdcui directly and exit with its exit code
109
313
  --musl-la [args...] Spawn musl-la directly and exit with its exit code
110
314
  ```
111
315
 
112
- These are flags to `bin/init.js` itself, resolved before Buninu starts.
316
+ Use it to reach an app's own options, which Buninu would otherwise interpret
317
+ as its own — `npx buninu --jsgotty --help` shows jsgotty's flag reference
318
+ rather than this one.
113
319
 
114
320
  ## Commands inside the shell
115
321
 
@@ -183,8 +389,12 @@ host accepts either and lists both in its `_discover` response, so either name
183
389
  works from the CLI, from `rpcraw`, and as an `import`.
184
390
 
185
391
  ```sh
186
- native-bridge openwv 1 https://example.com # load it, screen unchanged
187
- native-bridge showwv 1 # now bring it to the front
392
+ # Load it, screen unchanged
393
+ native-bridge openwv 1 https://example.com
394
+
395
+ # Now bring it to the front
396
+ native-bridge showwv 1
397
+
188
398
  native-bridge evalwv 1 document.title
189
399
  native-bridge currwv
190
400
  ```
@@ -218,8 +428,11 @@ and a URL is loaded into that WebView and brought to the front (`openWebView`
218
428
  then `showWebView`) instead of being handed to the system's default handler.
219
429
 
220
430
  ```sh
221
- MINAPK_WEBVIEW=1 xdg-open https://example.com # in the app WebView, on screen
222
- export MINAPK_WEBVIEW=1 # ...or for the whole session
431
+ # In the app WebView, on screen
432
+ MINAPK_WEBVIEW=1 xdg-open https://example.com
433
+
434
+ # ...or for the whole session
435
+ export MINAPK_WEBVIEW=1
223
436
  ```
224
437
 
225
438
  `0` is the console, so it navigates the terminal page away -- the back key
@@ -232,13 +445,43 @@ is not a plain integer is reported on stderr and ignored rather than guessed
232
445
  at, an unset or empty value keeps the default behavior, and a WebView the host
233
446
  does not have falls back to the default handler after saying so.
234
447
 
448
+ ## Differences from upstream
449
+
450
+ The versions of jsmdcui and jsgotty bundled here differ from the ones their
451
+ own projects ship.
452
+
453
+ ### The bundled jsmdcui
454
+
455
+ * Is configured editor-first by MDCUI_DEFAULT_EDIT
456
+ * The command `jmi` with a Markdown file opens the normal terminal editor.(js micro editor)
457
+ * The command `jsmdcui` preserves its original behavior: `apps/jsmdcui/jsmdcui.sh`, which starts its `tui` entry point with `--mdcui` when running markdown Apps, and forwards all command-line arguments.
458
+ * Adds the Buninu-only `# syntax: markdown` marker for Markdown highlighting in extensionless files; upstreaming may be considered later.
459
+
460
+ ### The bundled jsgotty
461
+
462
+ * No longer depends on or ships `node-pty`.
463
+ * Its PTY is provided by Bun's terminal API.
464
+
235
465
  ## Export
236
466
 
237
- Export the current Buninu installation as a gzip-compressed tar archive:
467
+ Export a Buninu installation as a gzip-compressed tar archive. What gets
468
+ exported is the installation the command runs from, so run it from your own
469
+ installation to capture your configuration, added commands and edited
470
+ `.bashrc` along with it:
471
+
472
+ ```sh
473
+ # Everything in this installation, as ./buninu.tgz
474
+ bun $BUNINU_HOME/bin/init.js --export
475
+
476
+ # ...to a path of your choosing
477
+ bun $BUNINU_HOME/bin/init.js --export /path/to/buninu.tgz
478
+ ```
479
+
480
+ Run it through `npx` instead and you get an archive of the freshly downloaded
481
+ package, with none of that — useful for a clean copy, not for a backup:
238
482
 
239
483
  ```sh
240
484
  npx buninu@latest --export
241
- npx buninu@latest --export /path/to/buninu.tgz
242
485
  ```
243
486
 
244
487
  The default output is `./buninu.tgz`. The archive contains exactly one
@@ -246,17 +489,29 @@ top-level directory so consumers can remove one component while extracting.
246
489
  Export requires `tar` in `PATH`; when replacing an existing output,
247
490
  Buninu restores the previous file if archive creation or replacement fails.
248
491
 
249
- Export this `package.json` on its own, instead of the whole installation:
492
+ Export this `package.json` on its own, instead of the whole installation. The
493
+ same distinction applies — run it from your installation to get your settings,
494
+ through `npx` to get the defaults:
250
495
 
251
496
  ```sh
497
+ # The buninu section as you have configured it, as ./buninu.json
498
+ bun $BUNINU_HOME/bin/init.js --export-config
499
+
500
+ # ...to a path of your choosing
501
+ bun $BUNINU_HOME/bin/init.js --export-config /path/to/buninu.json
502
+
503
+ # The package's own defaults instead
252
504
  npx buninu@latest --export-config
253
- npx buninu@latest --export-config /path/to/buninu.json
254
505
  ```
255
506
 
256
507
  The default output is `./buninu.json`. This is the full `package.json` (not
257
508
  just the `buninu` section), so the output is ready to use as-is anywhere a
258
509
  complete replacement `package.json` is expected.
259
510
 
511
+ A tarball made this way is also the simplest backup to take before an update
512
+ that is going to replace files you edited; see
513
+ [Install and update](#install-and-update).
514
+
260
515
  ## Environment
261
516
 
262
517
  `BUNINU_HOME` is the absolute path to the installed Buninu package root.
@@ -266,11 +521,15 @@ directory as their working directory. Buninu also appends
266
521
 
267
522
  Buninu preserves inherited environment variables and supplies these fallbacks:
268
523
 
269
- - `HOME`: inherited value, or `BUNINU_HOME` when unset.
524
+ - `HOME`: inherited value; when unset, the operating system's own home
525
+ directory for the current user (`USERPROFILE` on Windows), falling back to
526
+ `BUNINU_HOME` only if that is unavailable too.
270
527
  - `TMPDIR`: inherited value; on Android, use the app cache directory when it
271
528
  exists or `$BUNINU_HOME/tmp` otherwise; on other platforms, use the system
272
529
  temporary directory.
273
530
  - `SHELL`: inherited value, or a detected platform-appropriate shell.
531
+ - `XDG_DATA_HOME`: inherited value, unless `buninu.xdgDataHome` names one; see
532
+ [Data directory](#data-directory-optional).
274
533
  - `TERM`: `xterm-256color` when unset.
275
534
  - `COLORTERM`: `truecolor` when unset.
276
535
 
@@ -403,6 +662,44 @@ from the directory containing `package.json`.
403
662
 
404
663
  Use `--shell <path-or-name>` for a one-time override.
405
664
 
665
+ ## Data directory (optional)
666
+
667
+ Set `buninu.xdgDataHome` in `package.json` to point `XDG_DATA_HOME` somewhere
668
+ of your choosing. `true` puts it inside the installation, at
669
+ `$BUNINU_HOME/.local/share`:
670
+
671
+ ```json
672
+ {
673
+ "buninu": {
674
+ "xdgDataHome": true
675
+ }
676
+ }
677
+ ```
678
+
679
+ A string names a directory instead, resolved from the directory containing
680
+ `package.json` when it is relative:
681
+
682
+ ```json
683
+ {
684
+ "buninu": {
685
+ "xdgDataHome": "/mnt/usb/shared-data"
686
+ }
687
+ }
688
+ ```
689
+
690
+ The directory is created at startup if it does not exist. Leave the setting
691
+ `null` and `XDG_DATA_HOME` is passed through from the environment untouched.
692
+
693
+ What this actually moves is where XDG-aware programs keep their data, and
694
+ **bunmsh's command history is the one that matters here**: it lives at
695
+ `$XDG_DATA_HOME/bunmsh/history`, so `true` is what makes a shell's history
696
+ travel with a copied installation instead of staying on the machine.
697
+
698
+ `HOME` is deliberately left alone by this setting. A shell started under
699
+ Buninu keeps pointing at your own home directory, so SSH keys, Git
700
+ configuration and anything else kept there still work, and bunmsh can still
701
+ import the `~/.bash_history` or fish history you already had.
702
+
406
703
  ## Back key (Android, optional)
407
704
 
408
705
  Set `buninu.backToConsole` in `package.json` to decide what the Android host