fly-to-mars 0.1.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 (4) hide show
  1. package/LICENSE +21 -0
  2. package/README.md +237 -0
  3. package/dist/cli.mjs +3374 -0
  4. package/package.json +51 -0
package/LICENSE ADDED
@@ -0,0 +1,21 @@
1
+ MIT License
2
+
3
+ Copyright (c) 2026 Kun Chen
4
+
5
+ Permission is hereby granted, free of charge, to any person obtaining a copy
6
+ of this software and associated documentation files (the "Software"), to deal
7
+ in the Software without restriction, including without limitation the rights
8
+ to use, copy, modify, merge, publish, distribute, sublicense, and/or sell
9
+ copies of the Software, and to permit persons to whom the Software is
10
+ furnished to do so, subject to the following conditions:
11
+
12
+ The above copyright notice and this permission notice shall be included in all
13
+ copies or substantial portions of the Software.
14
+
15
+ THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR
16
+ IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY,
17
+ FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE
18
+ AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER
19
+ LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM,
20
+ OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE
21
+ SOFTWARE.
package/README.md ADDED
@@ -0,0 +1,237 @@
1
+ <p align="center">Humans fly to space. AI does the work.</p>
2
+ <h1 align="center">Fly to the Moon, Fly to Mars</h1>
3
+
4
+ <p align="center">
5
+ <a href="https://www.npmjs.com/package/fttm"
6
+ ><img
7
+ alt="npm"
8
+ src="https://img.shields.io/npm/v/fttm?style=flat-square"
9
+ /></a>
10
+ <a
11
+ href="https://img.shields.io/badge/platform-macOS%20%7C%20Linux%20%7C%20Windows-blue?style=flat-square"
12
+ ><img
13
+ alt="Platform"
14
+ src="https://img.shields.io/badge/platform-macOS%20%7C%20Linux%20%7C%20Windows-blue?style=flat-square"
15
+ /></a>
16
+ </p>
17
+
18
+ <p align="center">
19
+ <img src="docs/splash.png" alt="fttm — Fly to the Moon" width="800">
20
+ </p>
21
+
22
+ Never wake up empty-handed.
23
+
24
+ fttm is an autonomous coding agent orchestrator — each iteration makes one small, committed, documented change towards an objective while you sleep. You wake up to a branch full of clean work and a log of everything that happened.
25
+
26
+ - **Dead simple** — one command starts an autonomous loop that runs until you Ctrl+C or a configured runtime cap is reached
27
+ - **Long running** — each iteration is committed on success, rolled back on failure, with sensible retries and exponential backoff
28
+ - **Agent-agnostic** — works with Claude Code, Codex, Rovo Dev, or OpenCode out of the box
29
+
30
+ ## Quick Start
31
+
32
+ ```sh
33
+ $ fttm "reduce complexity of the codebase without changing functionality"
34
+ # have a good sleep
35
+ ```
36
+
37
+ ```sh
38
+ $ fttm "reduce complexity of the codebase without changing functionality" \
39
+ --max-iterations 10 \
40
+ --max-tokens 5000000
41
+ # have a good nap
42
+ ```
43
+
44
+ ### OpenCode with Specific Model
45
+
46
+ ```sh
47
+ $ fttm "implement a new feature" \
48
+ --agent opencode \
49
+ --model minimax-cn-coding-plan/MiniMax-M2.7
50
+ # foreground mode, model displayed in UI
51
+ ```
52
+
53
+ ### Background/Daemon Mode
54
+
55
+ ```sh
56
+ $ fttm "implement a new feature" \
57
+ --agent opencode \
58
+ --model minimax-cn-coding-plan/MiniMax-M2.7 \
59
+ --max-iterations 50 \
60
+ --detach
61
+ # runs in background, returns immediately to terminal
62
+ ```
63
+
64
+ Run `fttm` from inside a Git repository with a clean working tree. If you are starting from a plain directory, run `git init` first.
65
+ `fttm` supports macOS, Linux, and Windows.
66
+
67
+ ## Install
68
+
69
+ **npm**
70
+
71
+ ```sh
72
+ npm install -g fttm
73
+ ```
74
+
75
+ **From source**
76
+
77
+ ```sh
78
+ git clone https://github.com/YOUR_USERNAME/fttm.git
79
+ cd fttm
80
+ npm install
81
+ npm run build
82
+ npm link
83
+ ```
84
+
85
+ ## How It Works
86
+
87
+ ```
88
+ ┌─────────────┐
89
+ │ fttm start │
90
+ └──────┬──────┘
91
+
92
+ ┌──────────────────────┐
93
+ │ validate clean git │
94
+ │ create fttm/ branch │
95
+ │ write prompt.md │
96
+ └──────────┬───────────┘
97
+
98
+ ┌────────────────────────────┐
99
+ │ build iteration prompt │◄──────────────┐
100
+ │ (inject notes.md context) │ │
101
+ └────────────┬───────────────┘ │
102
+ ▼ │
103
+ ┌────────────────────────────┐ │
104
+ │ invoke your agent │ │
105
+ │ (non-interactive mode) │ │
106
+ └────────────┬───────────────┘ │
107
+ ▼ │
108
+ ┌─────────────┐ │
109
+ │ success? │ │
110
+ └──┬──────┬───┘ │
111
+ yes │ │ no │
112
+ ▼ ▼ │
113
+ ┌──────────┐ ┌───────────┐ │
114
+ │ commit │ │ git reset │ │
115
+ │ append │ │ --hard │ │
116
+ │ notes.md │ │ backoff │ │
117
+ └────┬─────┘ └─────┬─────┘ │
118
+ │ │ │
119
+ │ ┌──────────┘ │
120
+ ▼ ▼ │
121
+ ┌────────────┐ yes ┌──────────┐ │
122
+ │ 3 consec. ├─────────►│ abort │ │
123
+ │ failures? │ └──────────┘ │
124
+ └─────┬──────┘ │
125
+ no │ │
126
+ └──────────────────────────────────────┘
127
+ ```
128
+
129
+ - **Incremental commits** — each successful iteration is a separate git commit, so you can cherry-pick or revert individual changes
130
+ - **Runtime caps** — `--max-iterations` stops before the next iteration begins, while `--max-tokens` can abort mid-iteration once reported usage reaches the cap; uncommitted work is rolled back in either case
131
+ - **Shared memory** — the agent reads `notes.md` (built up from prior iterations) to communicate across iterations
132
+ - **Local run metadata** — fttm stores prompt, notes, and resume metadata under `.fttm/runs/` and ignores it locally, so your branch only contains intentional work
133
+ - **Resume support** — run `fttm` while on an existing `fttm/` branch to pick up where a previous run left off
134
+
135
+ ## CLI Reference
136
+
137
+ | Command | Description |
138
+ | ------------------------- | ----------------------------------------------- |
139
+ | `fttm "<prompt>"` | Start a new run with the given objective |
140
+ | `fttm` | Resume a run (when on an existing fttm/ branch) |
141
+ | `echo "<prompt>" \| fttm` | Pipe prompt via stdin |
142
+ | `cat prd.md \| fttm` | Pipe a large spec or PRD via stdin |
143
+
144
+ ### Flags
145
+
146
+ | Flag | Description | Default |
147
+ | ------------------------ | ------------------------------------------------------------------------------ | ---------------------- |
148
+ | `--agent <agent>` | Agent to use (`claude`, `codex`, `rovodev`, or `opencode`) | config file (`claude`) |
149
+ | `--model <model>` | Model to use with opencode agent (e.g., `minimax-cn-coding-plan/MiniMax-M2.7`) | agent default |
150
+ | `--max-iterations <n>` | Abort after `n` total iterations | unlimited |
151
+ | `--max-tokens <n>` | Abort after `n` total input+output tokens | unlimited |
152
+ | `--detach` | Run in daemon mode (background execution with `--max-iterations`) | `false` (foreground) |
153
+ | `--prevent-sleep <mode>` | Prevent system sleep during the run (`on`/`off` or `true`/`false`) | config file (`on`) |
154
+ | `--version` | Show version | |
155
+
156
+ ## Configuration
157
+
158
+ Config lives at `~/.fttm/config.yml`:
159
+
160
+ ```yaml
161
+ # Agent to use by default (claude, codex, rovodev, or opencode)
162
+ agent: claude
163
+
164
+ # Custom paths to agent binaries (optional)
165
+ # agentPathOverride:
166
+ # claude: /path/to/custom-claude
167
+ # codex: /path/to/custom-codex
168
+
169
+ # Abort after this many consecutive failures
170
+ maxConsecutiveFailures: 3
171
+
172
+ # Prevent the machine from sleeping during a run
173
+ preventSleep: true
174
+ ```
175
+
176
+ If the file does not exist yet, `fttm` creates it on first run using the resolved defaults.
177
+
178
+ CLI flags override config file values. `--prevent-sleep` accepts `on`/`off` as well as `true`/`false`; the config file always uses a boolean.
179
+ The iteration and token caps are runtime-only flags and are not persisted in `config.yml`.
180
+
181
+ ### Custom Agent Paths
182
+
183
+ Use `agentPathOverride` to point any agent at a custom binary — useful for wrappers like Claude Code Switch or custom Codex builds that accept the same flags and arguments as the original:
184
+
185
+ ```yaml
186
+ agentPathOverride:
187
+ claude: ~/bin/claude-code-switch
188
+ codex: /usr/local/bin/my-codex-wrapper
189
+ ```
190
+
191
+ Paths may be absolute, bare executable names already on your `PATH`, `~`-prefixed, or relative to the config directory (`~/.fttm/`). The override replaces only the binary name; all standard arguments are preserved, so the replacement must be CLI-compatible with the original agent. On Windows, `.cmd` and `.bat` wrappers are supported, including bare names resolved from `PATH`. For `rovodev`, the override must point to an `acli`-compatible binary since fttm invokes it as `<bin> rovodev serve ...`.
192
+ When sleep prevention is enabled, `fttm` uses the native mechanism for your OS: `caffeinate` on macOS, `systemd-inhibit` on Linux, and a small PowerShell helper backed by `SetThreadExecutionState` on Windows.
193
+
194
+ ## Debug Logs
195
+
196
+ Set `FTtm_DEBUG_LOG_PATH` to capture lifecycle events as JSONL while debugging a run:
197
+
198
+ ```sh
199
+ FTtm_DEBUG_LOG_PATH=/tmp/fttm-debug.jsonl fttm "ship it"
200
+ ```
201
+
202
+ ## UI Display
203
+
204
+ The terminal UI shows real-time information about the run:
205
+
206
+ - **Top bar**: Displays the agent being used (e.g., `fttm · opencode`)
207
+ - **Bottom bar**: Shows the model name (for opencode) and resume hint (`[ctrl+c to stop, fttm again to resume]`)
208
+ - **Stats line**: Shows elapsed time, iteration count (`iter X/Y` or `iter X/∞` if unlimited), token usage, and commit count
209
+ - **Moon phases**: Visual representation of iteration progress
210
+
211
+ ## Agents
212
+
213
+ `fttm` supports four agents:
214
+
215
+ | Agent | Flag | Requirements | Notes |
216
+ | ----------- | ------------------ | -------------------------------------------------------------------------- | -------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------- |
217
+ | Claude Code | `--agent claude` | Install Anthropic's `claude` CLI and sign in first. | `fttm` invokes `claude` directly in non-interactive mode. |
218
+ | Codex | `--agent codex` | Install OpenAI's `codex` CLI and sign in first. | `fttm` invokes `codex exec` directly in non-interactive mode. |
219
+ | Rovo Dev | `--agent rovodev` | Install Atlassian's `acli` and authenticate it with Rovo Dev first. | `fttm` starts a local `acli rovodev serve --disable-session-token <port>` process automatically in the repo workspace. |
220
+ | OpenCode | `--agent opencode` | Install `opencode` and configure at least one usable model provider first. | `fttm` starts a local `opencode serve --hostname 127.0.0.1 --port <port> --print-logs` process automatically, creates a per-run session, and applies a blanket allow rule so tool calls do not block on prompts. Use `--model` to specify a model (format: `provider/model`, e.g., `minimax-cn-coding-plan/MiniMax-M2.7`). |
221
+
222
+ ## Acknowledgments
223
+
224
+ fttm is inspired by and built upon the pioneering work of [gnhf](https://github.com/kunchenguid/gnhf) — "Good Night, Have Fun". The original project proved that autonomous coding agents can be both practical and delightful.
225
+
226
+ Special thanks to the open-source community and all the developers who make tools like this possible.
227
+
228
+ ## Development
229
+
230
+ ```sh
231
+ npm run build # Build with tsdown
232
+ npm run dev # Watch mode
233
+ npm test # Build, then run unit tests (vitest)
234
+ npm run test:e2e # Build, then run end-to-end tests against the mock opencode executable
235
+ npm run lint # ESLint
236
+ npm run format # Prettier
237
+ ```