@aiti-ai/aiti-containers 0.0.0-stage → 0.1.1

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/AGENTS.md ADDED
@@ -0,0 +1,43 @@
1
+ # AGENTS.md · aiti-containers
2
+
3
+ pi-web 扩展:容器管理面板 + agent 工具(对标 `microsoft/vscode-containers`)。
4
+
5
+ ## 结构
6
+
7
+ | 路径 | 职责 |
8
+ |---|---|
9
+ | `index.ts` | 扩展入口:features / server.api / agentTools(部署时被宿主用 jiti 转译) |
10
+ | `server/runtime.ts` | CLI 探测(docker/podman/nerdctl)、`execFile` 执行器、输出解析、错误映射 |
11
+ | `server/ops.ts` | 资源聚合、动作白名单、危险集合、日志/inspect/动作派发 |
12
+ | `client/src/entry.ts` | 面板 UI(宿主 `h()` 手写,无 JSX、无运行时依赖) |
13
+ | `tools/build.mjs` | esbuild 打包 client → `dist/` |
14
+ | `tools/deploy.mjs` | 构建 + 拷贝 dev 部署目录 + reload dev(**不部署 prod**) |
15
+ | `skills/containers-ops/` | AI 排障手册(ai.manage 帮助点) |
16
+
17
+ ## 硬约束(改代码前看)
18
+
19
+ 1. **永不拼 shell 字符串**:命令行一律 argv 数组 + `execFile`;动作只能走 `BUILDERS` 白名单(`server/ops.ts`)。
20
+ 2. **危险动作必须可确认**:新增危险动作要同时进 `DANGER` 集合;否则 AI 会无确认执行。
21
+ 3. **禁轮询**:面板只在手动刷新 / 动作成功后重取;不要加 `setInterval` 或定时拉取。
22
+ 4. **容量与超时**:`maxBuffer 64MB`、默认 20s(pull/compose up 180s);logs `tail ≤ 2000`,输出截断标注。
23
+ 5. **注释英文**(仓门禁 `check-new-cjk-comments`);UI 文案可中文。
24
+ 6. **feature 只有 boolean / string / textlist**(没有 number);数值用 string 再 `Number()`。
25
+ 7. **client 产物统一 `dist/`**;`index.ts` 的 `client` 字段指向 ll产物,别手改部署目录里的 dist。
26
+ 8. 服务端只用 node 内置模块;不要为了小功能引新依赖。
27
+
28
+ ## 本地验证
29
+
30
+ ```bash
31
+ node tools/build.mjs
32
+ node tools/deploy.mjs
33
+ curl -s http://127.0.0.1:30142/dev/api/extensions/aiti-containers/state | python3 -m json.tool | head -40
34
+ node ../../pi-work/gates/gate-all.mjs --root ../.. # 仓根跑(本目录是 aiti-ai/extensions/aiti-containers)
35
+ ```
36
+
37
+ 真机 UI:dev 实例(30142)打开面板;危险操作走「再点确认」。
38
+
39
+ ## 已知边界
40
+
41
+ - compose 项目仅从容器 label 推导(`com.docker.compose.project.working_dir`);不是本机 compose 起的容器没有项目目录,compose 动作会失败并回传 stderr。
42
+ - podman 的 `{{json .}}` 字段与 docker 略有差异(已兼容 State/Status);更老的 podman 可能不支持 `system df --format`,此时 `usage` 为空但不影响其他视图。
43
+ - 只读 `inspect` 返回原始 JSON(可能很大),截断 200KB。
package/DESC.en.md ADDED
@@ -0,0 +1,3 @@
1
+ Container management panel: containers / images / volumes / networks with compose-project grouping, supporting start-stop, logs, removal, pruning and exec inside a container. The same capabilities are exposed to AI as `aiti_containers_*` tools (destructive actions require confirmation).
2
+
3
+ Auto-detects docker / podman / nerdctl — no configuration needed. Read-only operations (list / logs / inspect) are always available; destructive operations (remove / prune / compose down / exec) require a second confirmation.
package/DESC.md ADDED
@@ -0,0 +1,3 @@
1
+ 容器管理面板:容器 / 镜像 / 卷 / 网络 + compose 项目分组,支持启停、日志、删除、清理与容器内执行;同一套能力以 `aiti_containers_*` 工具暴露给 AI(危险动作需确认)。
2
+
3
+ 自动探测 docker / podman / nerdctl,无需配置。只读操作(列表 / 日志 / inspect)可直接用;危险操作(删除 / 清理 / compose down / 容器内执行)需要二次确认。
package/LICENSE ADDED
@@ -0,0 +1,21 @@
1
+ MIT License
2
+
3
+ Copyright (c) 2026 aiti-ai contributors
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 CHANGED
@@ -1,3 +1,59 @@
1
- # Temporary Holding Version
1
+ # aiti-containers · 容器管理(pi-web 扩展)
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
+ 把 VS Code Container Tools 的核心体验搬进 pi-web AI 窗:一个面板管容器 / 镜像 / 卷 / 网络 / compose 项目,同一套能力以 agent 工具暴露给 AI。
4
+
5
+ 对标 `microsoft/vscode-containers`(调研与设计见 `pi-work/docs/aiti-containers-方案.md`)。
6
+
7
+ ## 功能
8
+
9
+ - **运行时自动探测**:docker / podman / nerdctl(含 compose 子命令),feature `cli` 可覆盖;探测失败给出可操作提示(无权限 / daemon 未启动 / 未安装)。
10
+ - **容器**:列表(运行态/端口/compose 归属)、start / stop / restart / remove、日志查看。
11
+ - **compose 项目**:按 `com.docker.compose.project` 分组,整组 up / restart / down / logs。
12
+ - **镜像**:列表(dangling 标记)、pull / remove / prune。
13
+ - **卷 / 网络**:列表、create / remove / prune。
14
+ - **系统**:`system df` 占用概览 + `system prune`(危险确认)。
15
+ - **容器内执行**:从工具或面板触发(危险确认)。
16
+ - **AI 工具**:`aiti_containers_state` / `aiti_containers_logs` / `aiti_containers_action` / `aiti_containers_exec`,配套 `containers-ops` 排障手册。
17
+
18
+ ## 危险操作确认协议
19
+
20
+ - UI:第一次点击进入「再点确认」(5 秒内有效)。
21
+ - API:未带 `confirm:true` → HTTP 428 + `{ needConfirm: true, danger }`。
22
+ - AI:工具返回同上,要求先把动作原文展示给用户、获得明确同意后再 `confirm:true` 重调。
23
+
24
+ ## API
25
+
26
+ `/api/extensions/aiti-containers/`
27
+
28
+ | 方法 | 路径 | 说明 |
29
+ |---|---|---|
30
+ | GET | `state[?kind=&refresh=1]` | 聚合态(容器/镜像/卷/网络/占用/compose 项目) |
31
+ | GET | `runtime[?refresh=1]` | 运行时探测结果 |
32
+ | GET | `logs?kind=&id=|project=&dir=&tail=` | 日志 |
33
+ | GET | `inspect?kind=&id=` | `docker inspect` 原始 JSON(截断) |
34
+ | POST | `action` | `{ kind, action, id?, ... , confirm? }` |
35
+
36
+ ## features
37
+
38
+ | id | 默认 | 说明 |
39
+ |---|---|---|
40
+ | `cli` | `auto` | auto / docker / podman / nerdctl / 可执行路径 |
41
+ | `showStopped` | on | 是否显示已停止容器 |
42
+ | `logTail` | `200` | 默认日志行数(上限 2000) |
43
+ | `confirmDanger` | on | 危险操作二次确认总开关(不推荐关) |
44
+
45
+ ## 开发与部署
46
+
47
+ ```bash
48
+ node tools/build.mjs # esbuild → dist/aiti-containers-client.mjs
49
+ node tools/deploy.mjs # 构建 + 拷贝到 ~/.pi/web-dev/extensions/ + reload dev
50
+ ```
51
+
52
+ - 只部署 dev(30142);prod 部署需明确同意。
53
+ - 服务端只用 node 内置模块;客户端零运行时依赖(宿主 `h()` 手写)。
54
+
55
+ ## 与原版的取舍
56
+
57
+ 保留:资源浏览、动作、日志、compose 分组、运行时抽象、危险确认、AI 工具。
58
+
59
+ 不做:Dockerfile / compose 语言服务、脚手架、容器内调试、注册表 / ACR、Azure、`containers:` 文件系统 provider。理由见方案文档 §2.2。