@rubytech/create-maxy-lite 0.1.2 → 0.1.3

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/index.mjs CHANGED
@@ -23,7 +23,7 @@ import { fileURLToPath } from 'node:url'
23
23
 
24
24
  import { makeLog } from './lib/log.mjs'
25
25
  import { readPins } from './lib/pins.mjs'
26
- import { PATHS, WEBCHAT_DIR, VALIDATOR_CLI, launcherPath, launcherScript } from './lib/paths.mjs'
26
+ import { PATHS, WEBCHAT_DIR, VALIDATOR_CLI, launcherPath, launcherScript, payloadLayCommand } from './lib/paths.mjs'
27
27
  import { orchestrate, STEP_NAMES } from './lib/orchestrate.mjs'
28
28
  import { claudeOk, validatorOk, vaultOk, webchatOk, healthcheck } from './lib/healthcheck.mjs'
29
29
 
@@ -73,11 +73,9 @@ const runStream = (cmd) => spawnStreaming('bash', ['-lc', cmd])
73
73
  const runInStream = (cmd) => spawnStreaming('proot-distro', ['login', PATHS.distro, '--', 'bash', '-lc', cmd])
74
74
 
75
75
  // ---- filesystem primitives --------------------------------------------------
76
- // The Ubuntu rootfs is a normal directory under the Termux prefix, so the app
77
- // payload is copied into it directly from bionic Node (no proot round-trip).
78
-
79
- const rootfs = `${PREFIX}/var/lib/proot-distro/installed-rootfs/${PATHS.distro}`
80
- const appHostPath = `${rootfs}${PATHS.appDir}` // appDir is absolute inside the rootfs
76
+ // Host-side fs is used only for genuine host paths (the Termux-prefix launcher
77
+ // and the shared-storage vault). The app payload lands inside the rootfs through
78
+ // proot (see layPayload), never via a reconstructed host rootfs path.
81
79
 
82
80
  const existsHost = (p) => fs.existsSync(p)
83
81
  const mkdirHost = (p) => fs.mkdirSync(p, { recursive: true })
@@ -101,10 +99,12 @@ const storageAccessible = () => {
101
99
  const interactive = Boolean(process.stdin.isTTY)
102
100
  const STORAGE_POLL_MS = 3000
103
101
 
104
- /** Copy the bundled app payload into the Ubuntu rootfs (idempotent overwrite). */
102
+ /** Lay the bundled app payload into the guest's appDir through proot (idempotent overwrite). */
103
+ // Delivered via a proot bind + guest-side copy so the payload lands in whatever
104
+ // rootfs proot-distro actually uses — no host-side guess at the rootfs location.
105
105
  const layPayload = () => {
106
- fs.mkdirSync(appHostPath, { recursive: true })
107
- fs.cpSync(PAYLOAD, appHostPath, { recursive: true })
106
+ const r = run(payloadLayCommand({ payloadHost: PAYLOAD }))
107
+ if (r.code !== 0) throw new Error(`payload lay failed: ${r.stderr.replace(/\s+/g, ' ').trim()}`)
108
108
  }
109
109
 
110
110
  /** Install the app deps (validator's js-yaml) and the webchat deps (node-pty, ws). */
package/lib/paths.mjs CHANGED
@@ -21,6 +21,25 @@ export const PATHS = {
21
21
  export const WEBCHAT_DIR = `${PATHS.appDir}/webchat`
22
22
  export const VALIDATOR_CLI = `${PATHS.appDir}/validator/cli.mjs`
23
23
 
24
+ // Where the host payload is bind-mounted inside the guest while it is copied into
25
+ // place. A throwaway path under the rootfs's own /tmp, distinct from the app dir.
26
+ export const PAYLOAD_STAGE = '/tmp/maxy-lite-payload'
27
+
28
+ /**
29
+ * The bare-Termux command that lays the bundled app payload into the guest's
30
+ * `appDir`. It binds the host payload directory into the guest under `stage`,
31
+ * then copies it guest-side — so the payload always lands in whatever rootfs
32
+ * proot-distro actually uses, with no host-side guess at the rootfs location.
33
+ * `payloadHost` is the only environment-dependent path (the npm package's
34
+ * `payload/`), so it is single-quoted; `stage` and `appDir` are pinned constants.
35
+ */
36
+ export function payloadLayCommand({ payloadHost, distro = PATHS.distro, stage = PAYLOAD_STAGE, appDir = PATHS.appDir }) {
37
+ return (
38
+ `proot-distro login ${distro} --bind '${payloadHost}':${stage} -- ` +
39
+ `bash -lc 'mkdir -p ${appDir} && cp -a ${stage}/. ${appDir}/'`
40
+ )
41
+ }
42
+
24
43
  /** Absolute path of the `maxy-lite` launcher in the Termux bin dir. */
25
44
  export function launcherPath(prefix = process.env.PREFIX || '/data/data/com.termux/files/usr') {
26
45
  return `${prefix}/bin/maxy-lite`
package/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "@rubytech/create-maxy-lite",
3
- "version": "0.1.2",
3
+ "version": "0.1.3",
4
4
  "description": "Install maxy-lite on an Android phone: orchestrates proot-distro Ubuntu, glibc Node, claude, the web-chat relay, the vault and its bind-mount — run via npx in bare Termux.",
5
5
  "type": "module",
6
6
  "engines": {