Show HN:以 Rust 和 ratatui 開發的終端原生閒置工廠遊戲 Terminactory
Show HN: 一款基于终端原生的闲置工厂类游戏,使用 Rust 语言并借助 ratatui 开发
Terminactory 是以 Rust 和 ratatui 開發的終端閒置工廠遊戲,玩家可採集和加工資源,透過研究逐步解鎖電腦和石油。工廠會在玩家離開時繼續賺取收益,AI Agent 亦可傳送短訊息至遊戲內。遊戲支援 macOS 和 Linux,Windows 用戶可使用 WSL。
Menu
[Get free trial](https://gitlab.com/users/sign_up)[Sign in](https://gitlab.com/users/sign_in?redirect_to_referer=yes)* [Why GitLab](https://about.gitlab.com/why-gitlab)
Search or go to…/
Menu
[Get free trial](https://gitlab.com/-/trial_registrations/new)[Sign in](https://gitlab.com/users/sign_in?redirect_to_referer=yes)* [Why GitLab](https://about.gitlab.com/why-gitlab)
Primary navigation
Project
Pinned
Feature catalog
- Manage
* [Activity](https://gitlab.com/snipedbywifi/terminactory/activity)
* [Members](https://gitlab.com/snipedbywifi/terminactory/-/project_members)
* [Labels](https://gitlab.com/snipedbywifi/terminactory/-/labels)
- Plan
* [Work items -](https://gitlab.com/snipedbywifi/terminactory/-/work_items)
* [Issue boards](https://gitlab.com/snipedbywifi/terminactory/-/boards)
* [Milestones](https://gitlab.com/snipedbywifi/terminactory/-/milestones)
* [Wiki](https://gitlab.com/snipedbywifi/terminactory/-/wikis)
- Code
* [Merge requests -](https://gitlab.com/snipedbywifi/terminactory/-/merge_requests)
* [Repository](https://gitlab.com/snipedbywifi/terminactory/-/tree/main)
* [Branches](https://gitlab.com/snipedbywifi/terminactory/-/branches)
* [Commits](https://gitlab.com/snipedbywifi/terminactory/-/commits/main?ref_type=heads)
* [Tags](https://gitlab.com/snipedbywifi/terminactory/-/tags)
* [Repository graph](https://gitlab.com/snipedbywifi/terminactory/-/network/main?ref_type=heads)
* [Compare revisions](https://gitlab.com/snipedbywifi/terminactory/-/compare?from=main&to=main)
* [Snippets](https://gitlab.com/snipedbywifi/terminactory/-/snippets)
- Build
* [Pipelines](https://gitlab.com/snipedbywifi/terminactory/-/pipelines)
* [Jobs](https://gitlab.com/snipedbywifi/terminactory/-/jobs)
* [Pipeline schedules](https://gitlab.com/snipedbywifi/terminactory/-/pipeline_schedules)
* [Artifacts](https://gitlab.com/snipedbywifi/terminactory/-/artifacts)
- Deploy
* [Releases](https://gitlab.com/snipedbywifi/terminactory/-/releases)
* [Package registry](https://gitlab.com/snipedbywifi/terminactory/-/packages)
* [Container registry](https://gitlab.com/snipedbywifi/terminactory/container_registry)
- Operate
* [Environments](https://gitlab.com/snipedbywifi/terminactory/-/environments)
* [Terraform modules](https://gitlab.com/snipedbywifi/terminactory/-/terraform_module_registry)
- Monitor
* [Incidents](https://gitlab.com/snipedbywifi/terminactory/-/incidents)
* [Service Desk](https://gitlab.com/snipedbywifi/terminactory/-/issues/service_desk)
- Analyze
* [Value stream analytics](https://gitlab.com/snipedbywifi/terminactory/-/value_stream_analytics)
* [Contributor analytics](https://gitlab.com/snipedbywifi/terminactory/-/graphs/main?ref_type=heads)
* [CI/CD analytics](https://gitlab.com/snipedbywifi/terminactory/-/pipelines/charts)
* [Repository analytics](https://gitlab.com/snipedbywifi/terminactory/-/graphs/main/charts)
Help
* [Help](https://gitlab.com/help)* Keyboard shortcuts ?* What's new for you 6
Collapse sidebar
Actions
- Copy project ID: 88858732
T
terminactory
Project information
Project ID: 88858732
Created on
November 12, 2026
main
Select Git revision
- Selected
- main default protected
1 result
Find file
Code
* Clone with SSH* Clone with HTTPSOpen with
Download source code
Actions
- Copy permalink y
A GIF of the running factory, for sharing where WebP is not accepted Most recent commit.
SnipedByWiFi authored 5 hours ago
Co-Authored-By: Claude Sonnet 5.5 <noreply@anthropic.com>
8bde707e
8bde707e5 hours ago
Terminactory
A cozy factory game for your terminal. Dig copper, coal and iron, melt it, press it, sell it, and research your way up to computers and oil. There is nothing to fight and nothing breaks at random: you build at your own pace, and the factory keeps earning while you are away.
It is made to sit in a split next to your AI agents. They can send you short messages that show up in the game, so you can play while they work.
tfac --demo # a small working factory to look at
Install
You need Rust 1.88 or newer and a UTF-8 terminal. macOS and Linux are supported; on Windows, use WSL.
git clone https://gitlab.com/snipedbywifi/terminactory
cd terminactory
cargo install --path .
This installs two commands, terminactory and the shortcut tfac. Make sure ~/.cargo/bin is on your PATH (rustup normally does this), then check it:
tfac --version
tfac --demo
To update, pull and run cargo install --path . --force. To remove it, cargo uninstall terminactory; your saves in ~/.terminactory stay.
Playing
tfac continues the save you played last.
tfac --saves # list your saves
tfac 2 # open save 2
tfac --new # start a fresh save; the others are kept
tfac --help # everything tfac can do
The game looks best in a terminal of at least 120×40. In a narrower or shorter pane, such as a split beside an agent, it switches to a compact view by itself. Mouse works in most terminals (iTerm2, Terminal.app, WezTerm, Kitty). ? shows every key in the game.
The first hour
- Press
1for the Create menu and place a drill on the ground, a furnace in front of it, and a molder after that. Drills mine anywhere;fon a drill picks the ore. - Lay belts (hold Shift with the arrow keys, or drag) to a trade post in the Misc menu. Items sell for money, research, or a split.
- Open research with
tand buy the press. From there it is a tree: new machines open as you research them, or free once you have made enough of an item. - Make a company's key item and it sends you a letter and opens its machines.
Machines need EC (electric charge): solar panels and EC poles first, steam engines later. Idle machines flash a short word saying why (FULL, NEED, EC?, ...).
Keys you will use
| Key | Does |
|---|---|
| arrows / WASD | move the cursor |
1–4, then a number |
pick something to build (Create, Transport, EC, Misc) |
Space or click / x or right-click |
place / remove |
r / f |
rotate / set up a machine (recipe, filter, mode) |
t |
research |
o |
production and earnings history |
b |
the in-game browser, on whatever is under the cursor |
c |
area tool: copy, remove or upgrade a rectangle |
m |
mirror what is in your hand, such as a copied blueprint (Shift: top to bottom) |
g |
settings |
p, [``] |
pause, speed |
? |
help |
| Ctrl+C | save and quit |
Keys can be changed in ~/.terminactory/controls.json.
The browser
b opens termweb, the game's own browser. It has a search page, tabs, bookmarks, history and an address bar. It holds the game's wiki (every item and machine, with recipes, prices and where it sits in the research tree) and a small web of other sites you can look through as you play. Research (t) and production (o) open in it too.
Research (t) and production (o) are sites in the browser, so they sit in their own tabs:
Inside the browser, b opens a new tab, Esc puts it away with your tabs kept, and 1–9 switch tabs. "Copy page" in the bottom bar puts a page's text on your clipboard.
Agent messages
Your AI agents can message you inside the game. A message costs the agent only the words in it, and nothing prints on success. Messages wait while the game is closed.
Claude Code
Add this to ~/.claude/settings.json. When an agent finishes, its last reply becomes a message; when it needs permission or input, you get a "needs you" message.
{
"hooks": {
"Stop": [{ "hooks": [{ "type": "command", "command": "tfac hook" }] }],
"Notification": [{ "hooks": [{ "type": "command", "command": "tfac hook" }] }]
}
}
Test it with the game open:
printf '%s' '{"hook_event_name":"Stop","cwd":"/tmp/demo","last_assistant_message":"## It works\n- a message from the hook"}' | tfac hook
Any other agent
Anything that can run a shell command can send one:
tfac msg --from my-agent "## Tests fixed\n- 3 flaky tests\n- [ ] needs review"
echo "## Done" | tfac msg # or read Markdown from stdin
\n is a line break and --from says who it is from (the default is the current folder's name). Markdown is rendered: headings, lists, checkboxes, quotes, code and tables. You can also drop a *.md file into ~/.terminactory/inbox/.
Either tell the agent to run tfac msg when it finishes (put a line in AGENTS.md or its system prompt), or point the agent's own notify hook at it, which costs no tokens. Only Claude Code's hook has been tested so far.
If nothing shows up, check that tfac --version works in the shell the agent uses and that its PATH includes ~/.cargo/bin. Messages appear at the bottom of the sidebar; in the compact view, a note in the corner. n reads the next one and i opens a log of all of them. Quieter styles are in the settings (g).
Saves and settings
Everything lives in ~/.terminactory: saves in saves/, controls.json, settings.json and your blueprints. The game saves every 30 seconds, when you quit or close the terminal, and with Ctrl+S. A save can be open in one window at a time. Saves carry a format version: a save from an older version of the game is never opened or deleted, and tfac tells you. See CHANGELOG.md for what changed between versions.
More
- docs/REFERENCE.md: every machine, recipe, price and key, written as the game grew.
- The in-game wiki (
b) is the page to trust for current numbers.
Development
cargo run --release # same as tfac, from the source folder
cargo test # simulation tests and screen snapshots
cargo clippy --all-targets
cargo fmt
src/sim.rs: the simulation. 60 ticks per second, no randomness, no drawing.src/content.rs: items, companies, research and recipes, kept apart from mechanics.src/ui.rs,src/app.rs: terminal drawing, and keyboard and mouse.src/web.rs,src/search.rs,src/wiki.rs: the in-game browser's pages and search.src/mail.rs,src/hints.rs: agent messages, and the quiet hints on the status line.wiki/,forums/,sites/,intranets/: Markdown pages for the in-game browser, embedded at build time (build.rs).
The simulation is deterministic and separate from the drawing code, so most changes can be tested without a screen.
License
Apache-2.0. See LICENSE.
來源:Hacker News 熱門(buzzing.cc 中文翻譯) · gitlab.com





