# Repo Fix Plan ## Findings ### Medium: Fresh install does not create `/servers` Reference: `install.lua:32-38` `LIST_FILES` downloads files under `servers/`, but `install.lua` only creates `/programs`, `/apis`, and `/startup`. On a fresh ComputerCraft machine, `wget ... servers/ping-server.lua` can fail because the parent directory does not exist. Fix: - Add `fs.makeDir('/servers');` before downloading files. - Bump `install.lua` `_VERSION`. ### Medium: `cube set-boot ` cannot clear boot safely Reference: `programs/cube.lua:177-204`, `servers/cube-server.lua:57-60` The documented behavior says an empty command deletes the boot hook. The client sends `nil` when no command is provided, and the server calls `writeFile('/.cubeboot', startupCommand)`. Writing `nil` can error, and even an empty string currently leaves an empty file instead of deleting `/.cubeboot`. Fix: - In `servers/cube-server.lua`, if `startupCommand == nil or startupCommand == ''`, delete `/.cubeboot` and reply `true`. - Otherwise write the command. - Bump `servers/cube-server.lua` `_VERSION`. - Optionally adjust the client message to say `boot DELETED` only when the server replies successfully. ### Medium: `deploy-file` reports success even when writes fail Reference: `servers/cube-server.lua:62-66`, `programs/cube.lua:242-248` `deploy-file` ignores the return value from `writeFile` and always replies `true`. If a parent directory is missing, the destination is read-only, or `fs.open` fails, the client counts the file as transferred. Fix: - Reply with the boolean result of `writeFile`. - Have the client keep the existing error print when `res` is false. - Bump `servers/cube-server.lua` `_VERSION`. ### Medium: Deployment cannot create new nested directories Reference: `servers/cube-server.lua:24-35`, `programs/cube.lua:20-38` `cube deploy` sends file paths recursively, but the server writes files directly without creating parent directories. This fails for new directories that do not already exist on the target cube. Fix: - Before writing a deployed file, create its parent directory when needed. - Keep behavior minimal: derive the parent path from `payload.path`, call `fs.makeDir(parent)` if not empty and not present, then write. - Return false if `payload` is malformed or the file write fails. ### Low: `set-boot` help says `[command]`, but only one argument is accepted Reference: `programs/cube.lua:6`, `programs/cube.lua:325` `local cubeCommand, firstArg, secondArg = ...` means `cube set-boot 12 mining turtle start` only sends `mining`; extra words are dropped. This matters for shell commands with spaces. Fix: - Use `table.pack(...)` to collect all arguments. - For `set-boot`, concatenate arguments after the machine id with spaces. - Preserve existing aliases and help behavior. - Bump `programs/cube.lua` `_VERSION`. ## Proposed Order 1. Fix `install.lua` to create `/servers`. 2. Fix `cube-server.lua` boot clearing and deploy write reporting. 3. Add parent-directory creation for deployed files. 4. Fix multi-word `cube set-boot` command parsing. 5. Update module versions for changed files. ## Verification Manual/runtime verification is required inside ComputerCraft or CraftOS-PC because this repo has no runnable local test harness. Suggested checks: - On a clean machine, run the installer and confirm `/servers/*.lua` downloads. - Run `cube set-boot ` and confirm `/.cubeboot` is deleted remotely. - Run `cube set-boot program arg` and confirm the full command is stored. - Deploy a file inside a new nested directory and confirm it exists remotely. - Force a bad deploy path or write failure and confirm the client reports an error instead of counting success.