dsh-3d-magic-house 0.0.0-stage → 0.2.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.
package/CHANGELOG.md ADDED
@@ -0,0 +1,39 @@
1
+ # Changelog
2
+
3
+ ## 0.2.0
4
+
5
+ - The panel is now **five pages** behind a tab bar — Overview, Ideas, Design, Projects, Printer —
6
+ instead of one long scroll. The last page is remembered, the tab that still needs work is marked,
7
+ and each tab follows the same five-step order as before.
8
+ - Overview page: dashboard with the project in progress, a live progress ring, the next step and the
9
+ finished list.
10
+ - Design page: the 3D view now auto-frames the design itself, progress is drawn as one glowing plane
11
+ instead of a second solid, and volume / weight / fit sit in a HUD strip.
12
+ - Printer page: device console with a radial progress ring, temperature bars with target ticks,
13
+ layer and job metrics, and a read-only footer.
14
+ - Ideas page: difficulty filter, equal-height cards with bottom-anchored actions, and adding a card
15
+ now jumps straight to Design.
16
+ - Visual pass: monospace numerals and kickers, corner brackets, a masked micro-grid background,
17
+ viewport scanline and HUD corners, a pulsing status dot and tab ticks. All motion respects
18
+ `prefers-reduced-motion`.
19
+ - The render suite now drives every page: navigation, per-page content, canvas painting on Design,
20
+ the live console on Printer, and an all-routes-down fallback.
21
+
22
+ ## 0.1.0
23
+
24
+ First public version.
25
+
26
+ - Left-sidebar entry **3D magic house / 3D魔法屋** with a five-step workshop:
27
+ ideas → sizing → queue → print → stars.
28
+ - Idea spinner (subject × job × limit) and ten curated kid-sized project cards.
29
+ - Dependency-free 3D view of the 256 mm build volume with box/cylinder/sphere/cone/ring,
30
+ live volume, solid-PLA weight guess, oversize warning, and a progress sketch while printing.
31
+ - Project board with idea → design → printing → done, one star per finished print,
32
+ an in-progress project shared by every step, and a six-item pre-print checklist.
33
+ - Bambu Lab P2S over LAN: MQTT over TLS (8883, user `bblp`), read-only status, automatic reconnect.
34
+ The access code is stored in `data/printer.json` with `0600` permissions.
35
+ - `magic_house` agent tool: `read`, `ideas`, `printer`, `add`, `status`, `remove`.
36
+ - One-click handoff of an idea or an exact 3D size to a new conversation.
37
+ - Verified against a real P2S over LAN: status reads (progress, layers, temperatures, job name).
38
+ - `npm test`: four dependency-free suites (MQTT over a local TLS printer, the link, and the panel in a React shim).
39
+ - Published to npm as `dsh-3d-magic-house`, and submitted to the awesome-dsh-plugin catalog.
package/LICENSE ADDED
@@ -0,0 +1,21 @@
1
+ MIT License
2
+
3
+ Copyright (c) 2026 挖宝的瓦力
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/PUBLISHING.md ADDED
@@ -0,0 +1,63 @@
1
+ # 发布到 GitHub
2
+
3
+ 这个目录已经是"仓库就绪"的状态:README(英文 + 中文)、LICENSE、.gitignore、package.json 元数据都在,运行时数据(`data/state.json`、`data/printer.json`)已被忽略。
4
+
5
+ ## 1. 先看一眼要提交什么
6
+
7
+ ```sh
8
+ cd /path/to/3d-magic-house
9
+ git status --short # 只应该有源码和文档,不应该出现 data/state.json、data/printer.json
10
+ ```
11
+
12
+ 如果 `data/printer.json` 出现在列表里,说明 `.gitignore` 没生效——**别提交**,那里面有访问码。
13
+
14
+ ## 2. 初始化并提交
15
+
16
+ ```sh
17
+ git init
18
+ git add .
19
+ git commit -m "feat: 3D magic house — five-step print workshop for kids"
20
+ ```
21
+
22
+ ## 3. 建远程仓库并推送
23
+
24
+ 有 `gh`(GitHub CLI):
25
+
26
+ ```sh
27
+ gh repo create 3d-magic-house --public --source=. --remote=origin --push
28
+ ```
29
+
30
+ 没有 `gh`:先去 GitHub 网页建一个空仓库(不要勾 README / .gitignore),然后:
31
+
32
+ ```sh
33
+ git remote add origin git@github.com:<你的账号>/3d-magic-house.git
34
+ git branch -M main
35
+ git push -u origin main
36
+ ```
37
+
38
+ ## 4. 推上去之后建议补两处
39
+
40
+ - `package.json` 加 `"repository": "github:<你的账号>/3d-magic-house"`(如果打算发 npm 也一并加 `"homepage"`)。
41
+ - LICENSE 里的版权人现在是 `挖宝的瓦力`,想换成真名就改那一行。
42
+
43
+ ## 5. 可选:截图
44
+
45
+ README 里目前没有截图。你可以在面板上截图(「3D 视图」和「打印机」两块最值得拍),放进 `docs/` 后在 README 里加:
46
+
47
+ ```markdown
48
+ ![The 3D view](docs/panel.png)
49
+ ```
50
+
51
+ ## 6. 发版
52
+
53
+ ```sh
54
+ # 改 package.json 的 version,然后
55
+ git tag v0.1.0 && git push --tags
56
+ ```
57
+
58
+ CHANGELOG.md 里记一句改了什么。
59
+
60
+ ## 注意
61
+
62
+ - 这个目录现在在另一个 vault 里面。**如果之后把它搬走**,已经装好的插件会失效(它是指向绝对路径的软链)。搬完在应用里删掉旧插件、重新 Add plugin 指向新路径即可。
63
+ - 不要提交 `data/state.json`:那是孩子自己的清单。插件缺这个文件时会从空清单开始,这正是新用户想要的状态。
package/README.md CHANGED
@@ -1,3 +1,109 @@
1
- # Temporary Holding Version
1
+ # 3D magic house · 3D魔法屋
2
2
 
3
- This version is a temporary placeholder for this package. An operational version to replace this has been submitted for review and is awaiting a staged release.
3
+ [![npm](https://img.shields.io/npm/v/dsh-3d-magic-house)](https://www.npmjs.com/package/dsh-3d-magic-house)
4
+ [![license](https://img.shields.io/badge/license-MIT-blue)](LICENSE)
5
+
6
+ A five-step 3D-printing workshop for a child, as a [DeepSeek Harness](https://github.com/deepseek-ai/dsh) plugin. It lives in the left sidebar and walks a kid from *"what should I make"* to *"look, it's done, I got a star"* on a **Bambu Lab P2S**.
7
+
8
+ ![Overview](docs/overview.png)
9
+
10
+ > ⚠️ The panel is a workshop, not a slicer. It never slices, never starts a print, and never talks to Bambu's cloud.
11
+
12
+ [中文说明 →](README.zh.md)
13
+
14
+ ## Five pages, one job each
15
+
16
+ The panel is split the way slicers and printer hosts split their work — Bambu Studio puts setup, preview and monitoring on separate tabs, OctoPrint gives state, files and temperature their own pages. Here each tab is one step of the flow, the tab still needing work is marked, and the last page is remembered.
17
+
18
+ | Page | What actually happens |
19
+ | --- | --- |
20
+ | **Overview** | Dashboard: the project in progress, a live progress ring with nozzle/bed readouts, the next step to take, and the finished prints with the star total. |
21
+ | **Ideas** | Spin a wheel of *subject × job × limit* (dinosaur / it must glow / smaller than a hand), or pick one of ten curated kid-sized projects, filterable by difficulty. Every card carries rough time, rough grams and three steps. |
22
+ | **Design** | A hand-written 3D view. Drag to rotate, scroll to zoom, choose box / cylinder / sphere / cone / ring, set length × width × height; volume, a solid-PLA weight guess and an oversized warning update live, and the size is saved onto the project. While a job runs, the printed height is drawn as a glowing plane. |
23
+ | **Projects** | The board: idea → design → printing → done, one click per stage, Done earning a star. Plus the six-item pre-print checklist and four safety rules. |
24
+ | **Printer** | LAN address + serial + access code, then a read-only device console: progress ring, remaining minutes, layer count, nozzle / bed / chamber temperatures and the job name. |
25
+
26
+ Anything in step 1 or 2 can be handed to a conversation with one click: the prompt is built from the card or from the exact 3D dimensions, so the model starts from "256 × 256 × 256 mm, 0.4 mm nozzle, PLA" instead of guessing.
27
+
28
+ ![Design page](docs/design.png)
29
+
30
+ ## Install
31
+
32
+ The plugin is a plain directory — no build step, no dependencies.
33
+
34
+ **From the app:** Plugins → **Add plugin** → pick this directory. The entry appears in the left sidebar as **Magic house / 3D魔法屋**.
35
+
36
+ **From npm:** the same package is published as [`dsh-3d-magic-house`](https://www.npmjs.com/package/dsh-3d-magic-house) — add that package name the same way.
37
+
38
+ Nothing else is required: the bundle declares no dependencies and has no build step. A saved printer configuration reconnects on the next start.
39
+
40
+ ## Connect the printer (LAN only)
41
+
42
+ On the printer screen: **Settings → Network → LAN Only mode**. Note the **IP** and **serial number** on that page, tap **Access Code** and copy the code. Enter all three in step 4.
43
+
44
+ - Transport: MQTT over TLS on port 8883, user `bblp`, topic `device/<serial>/report`.
45
+ - The only thing ever published is one `pushall` status request. There is no code path that starts, pauses, cancels or rewrites a print.
46
+ - Firmware newer than early 2025 may reject unsigned commands; status pushes usually still arrive. If nothing arrives, enable **Developer mode** too.
47
+ - The access code is stored in plain text in `data/printer.json` with `0600` permissions. It is never returned by a route and never printed by a tool. Delete the file to forget it.
48
+
49
+ ## Privacy
50
+
51
+ - The panel talks only to the printer on your own network, and to the plugin's own host routes.
52
+ - No Bambu account, no cloud, no third-party request, no telemetry.
53
+ - The 3D view renders with a few hundred lines of JavaScript on a 2D canvas: no three.js, no CDN, no network.
54
+
55
+ ## Data
56
+
57
+ | File | Contents |
58
+ | --- | --- |
59
+ | `data/ideas.json` | Shipped idea cards and the spin word lists (edit freely). |
60
+ | `data/state.json` | The board: projects, stages, stars, checklist, the project in progress. Created at runtime, git-ignored. |
61
+ | `data/printer.json` | LAN address, serial, access code (`0600`). Created at runtime, git-ignored. |
62
+
63
+ Both are plain JSON. Back them up or edit them by hand.
64
+
65
+ ## The agent side
66
+
67
+ The host half registers the `magic_house` tool:
68
+
69
+ `read` · `ideas` · `printer` · `add` · `status` · `remove`
70
+
71
+ So a child can ask "打到哪了" (how far along is it) or say "帮我把今天的乌龟存钱罐记下来" (remember today's turtle bank), and the panel reflects the same board. The printer address and access code are only ever entered in the panel — they are deliberately not parameters of the tool.
72
+
73
+ ## Layout
74
+
75
+ ```
76
+ index.js host: same-origin routes + the magic_house tool + JSON storage
77
+ lib/mqtt-lite.js dependency-free MQTT 3.1.1 client (TLS, subscribe, keepalive, reconnect)
78
+ lib/printer-link.js printer config, connection lifecycle, report merging
79
+ client.js sidebar entry + five pages + the 3D renderer (plain JS, only `react`)
80
+ data/ideas.json idea cards and spin words
81
+ locale/{en,zh}.json Plugin Manager title and description
82
+ icon.svg plugin icon
83
+ docs/ the preview images above
84
+ test/ the checks below: `npm test`
85
+ ```
86
+
87
+ The page screenshots in this README are rendered from the panel's own components and stylesheet in a
88
+ headless browser; the data in them is a fixture, not a live printer.
89
+
90
+ ## Tests
91
+
92
+ ```sh
93
+ npm test
94
+ ```
95
+
96
+ Four suites, no dependencies: an MQTT client driven against a local TLS "printer" it starts itself (handshake, subscribe, chunked reports, a rejected access code, an unreachable socket), the printer link (config validation, delta merging, payload splitting, credentials at `0600`, reload), and the panel rendered under a small React shim in both a healthy and a route-down world. The 3D scene is asserted through a recording canvas: it must paint faces, recompute volume, and flag an oversized design.
97
+
98
+ The suite simulates the printer so it runs anywhere. Separately, the transport and the link have been run against a real P2S in LAN-only mode and read live progress, layer counts, nozzle/bed temperatures and the job name — so the protocol fields below are not guesses.
99
+
100
+ ## Notes for contributors
101
+
102
+ - One `connection.fetch.register` per path. A second registration for the same path throws, and that throw also disposes the effect that owns the first — the panel then gets a plain-text `not found` and shows a JSON error.
103
+ - Use `requestBody: 'buffered'`. A streamed GET body is not a valid `Request`.
104
+ - `socket.setTimeout` is an inactivity timeout, not a handshake deadline: use a one-shot timer cleared on CONNACK, or an idle-but-healthy connection dies between reports.
105
+ - Printer reports can arrive as several JSON documents back to back (sometimes NUL-separated, because one MQTT message caps at 16 KB). Split by brace balance, ignoring braces inside strings.
106
+
107
+ ## License
108
+
109
+ MIT. See [LICENSE](LICENSE).
package/README.zh.md ADDED
@@ -0,0 +1,105 @@
1
+ # 3D魔法屋
2
+
3
+ 给孩子的 3D 打印小工坊,一个 [DeepSeek Harness](https://github.com/deepseek-ai/dsh) 插件。入口在左侧菜单,把孩子从「做点什么好」一路带到「打完了,我又得一颗星」,用的是家里的**拓竹 P2S**。
4
+
5
+ > ⚠️ 这是工坊,不是切片器。它不切片、不下达打印任务、不碰拓竹云。
6
+
7
+ [English →](README.md)
8
+
9
+ ![总览](docs/overview.png)
10
+
11
+ ## 五个页面,各干一件事
12
+
13
+ 拆法照着切片器和打印机上位机的成熟做法来——Bambu Studio 把准备、预览、设备监控放在不同标签页,OctoPrint 把状态、文件、温度各占一页。这里每个页面就是流程中的一步,还没做完的那步会标出来,上次停在哪页会记住。
14
+
15
+ | 页面 | 实际发生什么 |
16
+ | --- | --- |
17
+ | **总览** | 仪表盘:正在做的作品、实时进度环 + 喷嘴/热床读数、下一步该做什么、已完成作品和星星总数。 |
18
+ | **灵感** | 转「主题 × 功能 × 限制」的转盘(恐龙 / 必须能发光 / 比手掌小),或从 10 张准备好的灵感卡里挑一张,可按难度筛选。每张卡都有预估时间、预估克数和三步做法。 |
19
+ | **设计** | 自己写的 3D 视图。拖动旋转、滚轮缩放,选方块/圆柱/球/圆锥/圆环,改长宽高;体积、按实心 PLA 估的克数、「装不装得下」实时变,尺寸记在这件作品上。正在打印时,已经打出来的高度会画成一片发光的面。 |
20
+ | **作品** | 清单:想法 → 建模 → 打印 → 完成,点一下往前推,推到完成得一颗星。旁边是六项打印前检查和四条安全须知。 |
21
+ | **打印机** | 填局域网地址、序列号、访问码,然后是只读的设备控制台:进度环、剩余时间、层数、喷嘴/热床/腔温和当前作品名。 |
22
+
23
+ 第一步和第二步都能一键交给对话:提示词里带着卡片内容或你刚设的精确尺寸,模型不用猜「多大、什么喷嘴、什么料」。
24
+
25
+ ![设计页](docs/design.png)
26
+
27
+ ## 安装
28
+
29
+ 插件就是一个目录,没有依赖、没有构建步骤。
30
+
31
+ **在应用里**:插件(Plugins)→ **添加插件** → 选这个目录。左侧菜单会出现「**3D魔法屋**」。
32
+
33
+ **从 npm 装**:同一个包也发布在 [`dsh-3d-magic-house`](https://www.npmjs.com/package/dsh-3d-magic-house),在同一个入口填包名即可。
34
+
35
+ 不用做别的。已经保存过打印机信息的,下次启动会自动重连。
36
+
37
+ ## 连打印机(只用局域网)
38
+
39
+ 打印机屏幕上:**设置 → 网络 → 局域网模式(LAN Only)**。记下同一页的 **IP** 和 **序列号**,点「访问码」拿到那串码,填进第 4 步。
40
+
41
+ - 传输:MQTT over TLS,端口 8883,用户 `bblp`,订阅 `device/<序列号>/report`。
42
+ - 全程只发过一条 `pushall` 状态请求。代码里没有任何开始、暂停、取消或修改打印的通路。
43
+ - 2025 年之后的固件可能拒收未签名指令,状态推送一般照常到;一直收不到就把**开发者模式**也打开。
44
+ - 访问码以明文存在 `data/printer.json`,权限 `0600`。它不会被任何路由返回,也不会被工具打印出来。删掉这个文件就等于忘掉它。
45
+
46
+ ## 隐私
47
+
48
+ - 面板只和你家局域网里的打印机通信,以及插件自己的同源路由。
49
+ - 不登录拓竹账号、不走云端、没有第三方请求、没有遥测。
50
+ - 3D 视图是几百行 JS 在 2D canvas 上自己算的:没有 three.js、没有 CDN、不联网。
51
+
52
+ ## 数据
53
+
54
+ | 文件 | 内容 |
55
+ | --- | --- |
56
+ | `data/ideas.json` | 内置灵感卡和转盘词库(随便改)。 |
57
+ | `data/state.json` | 清单:作品、阶段、星星、检查项、正在做的那件。运行时生成,已 gitignore。 |
58
+ | `data/printer.json` | 局域网地址、序列号、访问码(`0600`)。运行时生成,已 gitignore。 |
59
+
60
+ 都是纯 JSON,可以直接备份或手改。
61
+
62
+ ## 给 AI 的那一半
63
+
64
+ Host 半注册了 `magic_house` 工具:
65
+
66
+ `read` · `ideas` · `printer` · `add` · `status` · `remove`
67
+
68
+ 所以孩子可以问「打到哪了」,也可以说「帮我把今天的乌龟存钱罐记下来」——AI 读写的和面板是同一份。打印机地址和访问码**故意**不是工具参数,只能在面板里填。
69
+
70
+ ## 目录
71
+
72
+ ```
73
+ index.js Host:同源路由 + magic_house 工具 + JSON 存储
74
+ lib/mqtt-lite.js 零依赖 MQTT 3.1.1 客户端(TLS、订阅、心跳、重连)
75
+ lib/printer-link.js 打印机配置、连接生命周期、报告合并
76
+ client.js 侧栏入口 + 面板 + 3D 渲染器(纯 JS,只用 react)
77
+ data/ideas.json 灵感卡与转盘词库
78
+ locale/{en,zh}.json Plugin Manager 里的标题和说明
79
+ icon.svg 插件图标
80
+ docs/ 上面那些预览图
81
+ test/ 下面的检查:`npm test`
82
+ ```
83
+
84
+ README 里的页面截图是用面板自己的组件和样式在无头浏览器里渲染出来的,里面的数据是测试用的假数据,不是真机。
85
+
86
+ ## 测试
87
+
88
+ ```sh
89
+ npm test
90
+ ```
91
+
92
+ 四个套件,零依赖:MQTT 客户端对着自带的本地 TLS 假打印机跑(握手、订阅、分片报告、访问码被拒、端口不通);打印机链路(配置校验、增量合并、载荷切分、凭据 0600、重启复用);面板在一个小 React 垫片里分别跑「正常」和「路由全 404」两种世界;3D 场景用记录型 canvas 断言:真的画面片、真的重算体积、超大尺寸会被标出来。
93
+
94
+ 套件里的打印机是模拟的,所以到处都能跑。分开说一件事:这套传输和链路已经对着一台真的 P2S(局域网模式)跑过——实时进度、层数、喷嘴/热床温度、作品名都读到了,下面的协议字段不是猜的。
95
+
96
+ ## 给改代码的人(四个坑)
97
+
98
+ - **一个路径只能注册一次。** `connection.fetch.register` 对同一个 path 的第二次注册会抛错,而这个异常会连带销毁第一次注册的那个 effect——面板拿到纯文本 `not found`,前端却报 JSON 解析错误。
99
+ - **`requestBody` 用 `buffered`。** GET 走 `streaming` 会构造一个带 body 的 GET,不是合法 `Request`。
100
+ - **`socket.setTimeout` 是空闲超时,不是握手超时。** 用它做连接超时会在两次状态推送之间误杀健康连接;握手要用一次性定时器,收到 CONNACK 就清掉。
101
+ - **打印机报告可能是多个 JSON 首尾相接**(有时用 NUL 分隔,因为单条 MQTT 消息上限 16 KB)。按大括号配平切分,并跳过字符串里的括号。
102
+
103
+ ## 许可
104
+
105
+ MIT,见 [LICENSE](LICENSE)。