@fitlab-ai/agent-infra 0.4.5 → 0.5.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.
Files changed (56) hide show
  1. package/README.md +18 -2
  2. package/README.zh-CN.md +18 -2
  3. package/bin/cli.js +19 -0
  4. package/lib/defaults.json +17 -0
  5. package/lib/init.js +1 -0
  6. package/lib/log.js +5 -10
  7. package/lib/merge.js +885 -0
  8. package/lib/sandbox/commands/create.js +1170 -0
  9. package/lib/sandbox/commands/enter.js +64 -0
  10. package/lib/sandbox/commands/ls.js +71 -0
  11. package/lib/sandbox/commands/rebuild.js +102 -0
  12. package/lib/sandbox/commands/rm.js +211 -0
  13. package/lib/sandbox/commands/vm.js +101 -0
  14. package/lib/sandbox/config.js +79 -0
  15. package/lib/sandbox/constants.js +113 -0
  16. package/lib/sandbox/dockerfile.js +95 -0
  17. package/lib/sandbox/engine.js +93 -0
  18. package/lib/sandbox/index.js +64 -0
  19. package/lib/sandbox/runtimes/ai-tools.dockerfile +26 -0
  20. package/lib/sandbox/runtimes/base.dockerfile +30 -0
  21. package/lib/sandbox/runtimes/java17.dockerfile +3 -0
  22. package/lib/sandbox/runtimes/java21.dockerfile +3 -0
  23. package/lib/sandbox/runtimes/node20.dockerfile +3 -0
  24. package/lib/sandbox/runtimes/node22.dockerfile +3 -0
  25. package/lib/sandbox/runtimes/python3.dockerfile +3 -0
  26. package/lib/sandbox/shell.js +48 -0
  27. package/lib/sandbox/task-resolver.js +35 -0
  28. package/lib/sandbox/tools.js +135 -0
  29. package/lib/update.js +16 -2
  30. package/package.json +5 -1
  31. package/templates/.agents/rules/pr-sync.md +110 -0
  32. package/templates/.agents/rules/pr-sync.zh-CN.md +110 -0
  33. package/templates/.agents/scripts/validate-artifact.js +117 -1
  34. package/templates/.agents/skills/archive-tasks/SKILL.md +6 -3
  35. package/templates/.agents/skills/archive-tasks/SKILL.zh-CN.md +6 -3
  36. package/templates/.agents/skills/archive-tasks/scripts/archive-tasks.sh +91 -8
  37. package/templates/.agents/skills/commit/SKILL.md +9 -1
  38. package/templates/.agents/skills/commit/SKILL.zh-CN.md +9 -1
  39. package/templates/.agents/skills/commit/config/verify.json +5 -1
  40. package/templates/.agents/skills/commit/reference/pr-summary-sync.md +21 -0
  41. package/templates/.agents/skills/commit/reference/pr-summary-sync.zh-CN.md +21 -0
  42. package/templates/.agents/skills/commit/reference/task-status-update.md +2 -0
  43. package/templates/.agents/skills/commit/reference/task-status-update.zh-CN.md +2 -0
  44. package/templates/.agents/skills/create-pr/SKILL.md +2 -1
  45. package/templates/.agents/skills/create-pr/SKILL.zh-CN.md +2 -1
  46. package/templates/.agents/skills/create-pr/reference/comment-publish.md +7 -74
  47. package/templates/.agents/skills/create-pr/reference/comment-publish.zh-CN.md +6 -73
  48. package/templates/.agents/skills/create-task/SKILL.md +6 -0
  49. package/templates/.agents/skills/create-task/SKILL.zh-CN.md +6 -0
  50. package/templates/.agents/skills/create-task/config/verify.json +1 -0
  51. package/templates/.agents/skills/import-issue/SKILL.md +2 -0
  52. package/templates/.agents/skills/import-issue/SKILL.zh-CN.md +2 -0
  53. package/templates/.agents/skills/import-issue/config/verify.json +1 -0
  54. package/templates/.agents/skills/update-agent-infra/scripts/sync-templates.js +18 -1
  55. package/templates/.agents/templates/task.md +5 -4
  56. package/templates/.agents/templates/task.zh-CN.md +5 -4
package/README.md CHANGED
@@ -133,10 +133,18 @@ npm install -g @fitlab-ai/agent-infra
133
133
  curl -fsSL https://raw.githubusercontent.com/fitlab-ai/agent-infra/main/install.sh | sh
134
134
  ```
135
135
 
136
+ **Option C - Homebrew (macOS)**
137
+
138
+ ```bash
139
+ brew install fitlab-ai/tap/agent-infra
140
+ ```
141
+
136
142
  ### Updating agent-infra
137
143
 
138
144
  ```bash
139
145
  npm update -g @fitlab-ai/agent-infra
146
+ # or, if installed via Homebrew:
147
+ brew upgrade agent-infra
140
148
  ```
141
149
 
142
150
  Check your current version:
@@ -171,6 +179,14 @@ Open the project in any AI TUI and run `update-agent-infra`:
171
179
 
172
180
  This detects the packaged template version and renders all managed files. The same command is used both for first-time setup and for future template upgrades.
173
181
 
182
+ ### Sandbox aliases and GitHub CLI
183
+
184
+ `ai sandbox create` now bootstraps the host-side aliases file at `~/.agent-infra/aliases/sandbox.sh` on first run. The generated file includes ready-to-edit yolo shortcuts for Claude, Codex, Gemini CLI, and OpenCode, and every sandbox syncs that file into `/home/devuser/.bash_aliases`.
185
+
186
+ The sandbox image also preinstalls `gh`. When `gh auth token` succeeds on the host, `ai sandbox create` injects the token into the container as `GH_TOKEN`, so `gh` commands work inside the sandbox without extra setup.
187
+
188
+ `ai sandbox exec` also forwards a small terminal-detection whitelist (`TERM_PROGRAM`, `TERM_PROGRAM_VERSION`, `LC_TERMINAL`, `LC_TERMINAL_VERSION`) into the container. This keeps interactive TUIs aligned with the host terminal for behaviors such as Claude Code's Shift+Enter newline support, without passing through the full host environment.
189
+
174
190
  <a id="architecture-overview"></a>
175
191
 
176
192
  ## Architecture Overview
@@ -179,7 +195,7 @@ agent-infra is intentionally simple: a bootstrap CLI creates the seed configurat
179
195
 
180
196
  ### End-to-End Flow
181
197
 
182
- 1. **Install** — `npm install -g @fitlab-ai/agent-infra` (or use the shell script wrapper)
198
+ 1. **Install** — `npm install -g @fitlab-ai/agent-infra` (or `brew install fitlab-ai/tap/agent-infra` on macOS, or use the shell script wrapper)
183
199
  2. **Initialize** — `ai init` in the project root to generate `.agents/.airc.json` and install the seed command
184
200
  3. **Render** — run `update-agent-infra` in any AI TUI to detect the bundled template version and generate all managed files
185
201
  4. **Develop** — use built-in skills to drive the full lifecycle: `analysis → design → implementation → review → fix → commit`
@@ -380,7 +396,7 @@ The generated `.agents/.airc.json` file is the central contract between the boot
380
396
  "project": "my-project",
381
397
  "org": "my-org",
382
398
  "language": "en",
383
- "templateVersion": "v0.4.5",
399
+ "templateVersion": "v0.5.1",
384
400
  "files": {
385
401
  "managed": [
386
402
  ".agents/workspace/README.md",
package/README.zh-CN.md CHANGED
@@ -133,10 +133,18 @@ npm install -g @fitlab-ai/agent-infra
133
133
  curl -fsSL https://raw.githubusercontent.com/fitlab-ai/agent-infra/main/install.sh | sh
134
134
  ```
135
135
 
136
+ **方式 C - Homebrew (macOS)**
137
+
138
+ ```bash
139
+ brew install fitlab-ai/tap/agent-infra
140
+ ```
141
+
136
142
  ### 更新 agent-infra
137
143
 
138
144
  ```bash
139
145
  npm update -g @fitlab-ai/agent-infra
146
+ # 或者通过 Homebrew 安装时:
147
+ brew upgrade agent-infra
140
148
  ```
141
149
 
142
150
  查看当前版本:
@@ -171,6 +179,14 @@ CLI 会收集项目元数据,向所有支持的 AI TUI 安装 `update-agent-in
171
179
 
172
180
  该命令会检测当前打包模板版本并渲染所有受管理文件。首次安装和后续升级都使用同一条命令。
173
181
 
182
+ ### 沙箱 aliases 与 GitHub CLI
183
+
184
+ `ai sandbox create` 在首次运行时会自动生成宿主机侧的 `~/.agent-infra/aliases/sandbox.sh`。该文件内置了 Claude、Codex、Gemini CLI 和 OpenCode 的 yolo 快捷命令模板,你可以直接修改;每次创建沙箱时,这个文件都会同步到容器内的 `/home/devuser/.bash_aliases`。
185
+
186
+ 沙箱镜像也会预装 `gh`。如果宿主机上的 `gh auth token` 能成功返回 token,`ai sandbox create` 会把它以 `GH_TOKEN` 环境变量注入容器,让你在沙箱里直接使用 `gh`,无需额外登录配置。
187
+
188
+ `ai sandbox exec` 也会向容器透传一小组终端检测白名单变量(`TERM_PROGRAM`、`TERM_PROGRAM_VERSION`、`LC_TERMINAL`、`LC_TERMINAL_VERSION`)。这样可以让交互式 TUI 保持与宿主终端一致的行为,例如 Claude Code 的 `Shift+Enter` 换行支持,同时避免把整个宿主环境灌入容器。
189
+
174
190
  <a id="architecture-overview"></a>
175
191
 
176
192
  ## 架构概览
@@ -179,7 +195,7 @@ agent-infra 的结构刻意保持简单:引导 CLI 负责生成种子配置,
179
195
 
180
196
  ### 端到端流程
181
197
 
182
- 1. **安装** — `npm install -g @fitlab-ai/agent-infra`(或使用 shell 脚本便捷封装)
198
+ 1. **安装** — `npm install -g @fitlab-ai/agent-infra`(或在 macOS 上使用 `brew install fitlab-ai/tap/agent-infra`,或使用 shell 脚本便捷封装)
183
199
  2. **初始化** — 在项目根目录运行 `ai init`,生成 `.agents/.airc.json` 并安装种子命令
184
200
  3. **渲染** — 在任意 AI TUI 中执行 `update-agent-infra`,检测当前打包模板版本并生成所有受管理文件
185
201
  4. **开发** — 使用内置 skill 驱动完整生命周期:`analysis → design → implementation → review → fix → commit`
@@ -380,7 +396,7 @@ import-issue #42 从 GitHub Issue 导入任务
380
396
  "project": "my-project",
381
397
  "org": "my-org",
382
398
  "language": "en",
383
- "templateVersion": "v0.4.5",
399
+ "templateVersion": "v0.5.1",
384
400
  "files": {
385
401
  "managed": [
386
402
  ".agents/workspace/README.md",
package/bin/cli.js CHANGED
@@ -14,7 +14,9 @@ const USAGE = `agent-infra - bootstrap AI collaboration infrastructure
14
14
 
15
15
  Usage:
16
16
  agent-infra init Initialize a new project with update-agent-infra seed command
17
+ agent-infra merge Merge tasks from another workspace directory (active/blocked/completed/archive)
17
18
  agent-infra update Update seed files and sync file registry for an existing project
19
+ agent-infra sandbox Manage Docker-based AI sandboxes
18
20
  agent-infra version Show version
19
21
  agent-infra help Show this help message
20
22
 
@@ -23,6 +25,7 @@ Shorthand: ai (e.g. ai init)
23
25
  Install methods:
24
26
  npm: npm install -g @fitlab-ai/agent-infra
25
27
  npx: npx @fitlab-ai/agent-infra init
28
+ brew: brew install fitlab-ai/tap/agent-infra (macOS)
26
29
  curl: curl -fsSL https://raw.githubusercontent.com/fitlab-ai/agent-infra/main/install.sh | sh (runs npm install -g internally)
27
30
 
28
31
  Examples:
@@ -49,6 +52,22 @@ switch (command) {
49
52
  });
50
53
  break;
51
54
  }
55
+ case 'merge': {
56
+ const { cmdMerge } = await import('../lib/merge.js');
57
+ await cmdMerge(process.argv.slice(3)).catch((e) => {
58
+ process.stderr.write(`Error: ${e.message}\n`);
59
+ process.exitCode = 1;
60
+ });
61
+ break;
62
+ }
63
+ case 'sandbox': {
64
+ const { runSandbox } = await import('../lib/sandbox/index.js');
65
+ await runSandbox(process.argv.slice(3)).catch((e) => {
66
+ process.stderr.write(`Error: ${e.message}\n`);
67
+ process.exitCode = 1;
68
+ });
69
+ break;
70
+ }
52
71
  case 'version': {
53
72
  console.log(`agent-infra ${VERSION}`);
54
73
  break;
package/lib/defaults.json CHANGED
@@ -1,4 +1,21 @@
1
1
  {
2
+ "sandbox": {
3
+ "runtimes": [
4
+ "node20"
5
+ ],
6
+ "tools": [
7
+ "claude-code",
8
+ "codex",
9
+ "opencode",
10
+ "gemini-cli"
11
+ ],
12
+ "dockerfile": null,
13
+ "vm": {
14
+ "cpu": null,
15
+ "memory": null,
16
+ "disk": null
17
+ }
18
+ },
2
19
  "labels": {
3
20
  "in": {}
4
21
  },
package/lib/init.js CHANGED
@@ -162,6 +162,7 @@ async function cmdInit() {
162
162
  org: orgName,
163
163
  language,
164
164
  templateVersion: VERSION,
165
+ sandbox: structuredClone(defaults.sandbox),
165
166
  labels: structuredClone(defaults.labels),
166
167
  files: structuredClone(defaults.files)
167
168
  };
package/lib/log.js CHANGED
@@ -1,27 +1,22 @@
1
- const isTTY = process.stdout.isTTY;
2
- const isTTYErr = process.stderr.isTTY;
3
-
4
- function color(code, text, tty) {
5
- return tty ? `\x1b[${code}m${text}\x1b[0m` : text;
6
- }
1
+ import pc from 'picocolors';
7
2
 
8
3
  function info(...args) {
9
4
  const msg = args.join(' ');
10
- process.stdout.write(` ${color('1;34', '>', isTTY)} ${msg}\n`);
5
+ process.stdout.write(` ${pc.bold(pc.blue('>'))} ${msg}\n`);
11
6
  }
12
7
 
13
8
  function ok(...args) {
14
9
  const msg = args.join(' ');
15
- process.stdout.write(` ${color('1;32', '\u2713', isTTY)} ${msg}\n`);
10
+ process.stdout.write(` ${pc.bold(pc.green('\u2713'))} ${msg}\n`);
16
11
  }
17
12
 
18
13
  function err(...args) {
19
14
  const msg = args.join(' ');
20
- process.stderr.write(` ${color('1;31', '\u2717', isTTYErr)} ${msg}\n`);
15
+ process.stderr.write(` ${pc.bold(pc.red('\u2717'))} ${msg}\n`);
21
16
  }
22
17
 
23
18
  function ask(text) {
24
- process.stdout.write(` ${color('1;33', '?', isTTY)} ${text}`);
19
+ process.stdout.write(` ${pc.bold(pc.yellow('?'))} ${text}`);
25
20
  }
26
21
 
27
22
  export { info, ok, err, ask };