@fitlab-ai/agent-infra 0.6.4 → 0.6.5

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.
@@ -0,0 +1,177 @@
1
+ import fs from 'node:fs';
2
+ import path from 'node:path';
3
+ import { shareBranchDir, shareCommonDir } from './constants.ts';
4
+
5
+ type ScaffoldResult = { created: boolean; path: string };
6
+ type WriteStderr = (chunk: string) => void;
7
+ type ScaffoldFs = Pick<typeof fs, 'mkdirSync' | 'writeFileSync'>;
8
+ type ScaffoldOptions = {
9
+ writeStderr?: WriteStderr;
10
+ fsModule?: ScaffoldFs;
11
+ };
12
+
13
+ const DOTFILES_README = `# User-level dotfiles channel
14
+
15
+ This directory is mounted **read-only** into every sandbox container at
16
+ \`/dotfiles\`. On entry, \`sandbox-dotfiles-link\` mirrors every file here as a
17
+ symlink under \`$HOME\` (e.g. \`.tmux.conf\` -> \`/home/devuser/.tmux.conf\`),
18
+ overriding image defaults so your editor, shell, and tool preferences follow
19
+ you across \`ai sandbox destroy + create\`.
20
+
21
+ See: https://github.com/fitlab-ai/agent-infra/blob/main/README.md#user-level-dotfiles-channel
22
+
23
+ Common usage - drop files or symlinks here:
24
+
25
+ \`\`\`sh
26
+ # Real files
27
+ echo "set -g mouse on" > ~/.agent-infra/dotfiles/.tmux.conf
28
+
29
+ # Symlinks to live host paths
30
+ ln -s ~/.tmux.conf ~/.agent-infra/dotfiles/.tmux.conf
31
+ ln -s ~/.config/lazygit ~/.agent-infra/dotfiles/.config/lazygit
32
+ \`\`\`
33
+
34
+ > Do **not** put secrets here. Use the dedicated SSH / credential mounts.
35
+
36
+ If you delete this file, the next \`ai sandbox create\` will re-create it
37
+ verbatim. To stop seeing it, edit or empty the file in place - the scaffold
38
+ only writes \`README.md\` when it is missing, never when it already exists.
39
+
40
+ ---
41
+
42
+ # 用户级 dotfiles 通道
43
+
44
+ 该目录被以**只读**方式挂载到每个 sandbox 容器的 \`/dotfiles\`。容器启动时,
45
+ \`sandbox-dotfiles-link\` 会把这里的每个文件 \`ln -sfn\` 到 \`$HOME\` 对应路径
46
+ (例如 \`.tmux.conf -> /home/devuser/.tmux.conf\`),覆盖镜像默认值,让你的编辑器、
47
+ shell、工具偏好跨 \`ai sandbox destroy + create\` 持久存在。
48
+
49
+ 参考:https://github.com/fitlab-ai/agent-infra/blob/main/README.zh-CN.md#用户级-dotfiles-通道
50
+
51
+ 常见用法:把文件或符号链接放进来:
52
+
53
+ \`\`\`sh
54
+ # 直接放文件
55
+ echo "set -g mouse on" > ~/.agent-infra/dotfiles/.tmux.conf
56
+
57
+ # 用符号链接指向 host 实际文件
58
+ ln -s ~/.tmux.conf ~/.agent-infra/dotfiles/.tmux.conf
59
+ ln -s ~/.config/lazygit ~/.agent-infra/dotfiles/.config/lazygit
60
+ \`\`\`
61
+
62
+ > **不要**在此放任何凭证。SSH / 凭证请使用专用挂载通道。
63
+
64
+ 如果你删除该文件,下一次 \`ai sandbox create\` 会原样重新生成。如果你不想再
65
+ 看到它,**就地编辑或清空内容**即可:scaffold 仅在 \`README.md\` **缺失**时
66
+ 写入,文件存在(哪怕被清空)就不会被重写。
67
+ `;
68
+
69
+ const SHARE_COMMON_README = `# /share/common - host <-> sandbox shared scratch (cross-branch)
70
+
71
+ This directory is mounted **read-write** into every sandbox container of this
72
+ project at \`/share/common\`, regardless of branch. Drop files here to share
73
+ between host and any sandbox without polluting the git worktree.
74
+
75
+ See: https://github.com/fitlab-ai/agent-infra/blob/main/README.md#host-sandbox-file-exchange
76
+
77
+ This file is safe to delete; the next \`ai sandbox create\` will re-create it.
78
+
79
+ ---
80
+
81
+ # /share/common - 宿主 <-> sandbox 共享暂存(跨分支)
82
+
83
+ 该目录被以**读写**方式挂载到本项目所有 sandbox 容器的 \`/share/common\`,
84
+ 跨分支可见。可用来在宿主和任意 sandbox 之间传文件,无需弄脏 git worktree。
85
+
86
+ 参考:https://github.com/fitlab-ai/agent-infra/blob/main/README.zh-CN.md#宿主-沙箱文件交换
87
+
88
+ 该文件可以安全删除;下一次 \`ai sandbox create\` 会重新生成。
89
+ `;
90
+
91
+ const SHARE_BRANCH_README = `# /share/branch - host <-> sandbox shared scratch (branch-exclusive)
92
+
93
+ This directory is mounted **read-write** into the sandbox container of this
94
+ project's current branch at \`/share/branch\`. Files here are exclusive to this
95
+ branch's sandbox and do not leak across branches.
96
+
97
+ See: https://github.com/fitlab-ai/agent-infra/blob/main/README.md#host-sandbox-file-exchange
98
+
99
+ This file is safe to delete; the next \`ai sandbox create\` will re-create it.
100
+
101
+ ---
102
+
103
+ # /share/branch - 宿主 <-> sandbox 共享暂存(分支独占)
104
+
105
+ 该目录被以**读写**方式挂载到本项目当前分支 sandbox 容器的 \`/share/branch\`,
106
+ 仅当前分支可见,不会跨分支泄漏。
107
+
108
+ 参考:https://github.com/fitlab-ai/agent-infra/blob/main/README.zh-CN.md#宿主-沙箱文件交换
109
+
110
+ 该文件可以安全删除;下一次 \`ai sandbox create\` 会重新生成。
111
+ `;
112
+
113
+ function errorDetail(error: unknown): string {
114
+ return error instanceof Error ? error.message : 'unknown error';
115
+ }
116
+
117
+ function errorCode(error: unknown): string {
118
+ return typeof error === 'object' && error !== null && 'code' in error
119
+ ? String(error.code)
120
+ : '';
121
+ }
122
+
123
+ function ensureFile(target: string, content: string, options: ScaffoldOptions): ScaffoldResult {
124
+ const writeStderr = options.writeStderr ?? ((chunk) => process.stderr.write(chunk));
125
+ const fsModule = options.fsModule ?? fs;
126
+ const result: ScaffoldResult = { created: false, path: target };
127
+
128
+ try {
129
+ fsModule.mkdirSync(path.dirname(target), { recursive: true });
130
+ } catch (error) {
131
+ writeStderr(`sandbox-readme-scaffold: skipping ${target} (${errorDetail(error)})\n`);
132
+ return result;
133
+ }
134
+
135
+ try {
136
+ fsModule.writeFileSync(target, content, { encoding: 'utf8', flag: 'wx' });
137
+ result.created = true;
138
+ } catch (error) {
139
+ if (errorCode(error) === 'EEXIST') {
140
+ return result;
141
+ }
142
+ writeStderr(`sandbox-readme-scaffold: skipping ${target} (${errorDetail(error)})\n`);
143
+ }
144
+
145
+ return result;
146
+ }
147
+
148
+ export function ensureDotfilesReadme(dotfilesDir: string, options: ScaffoldOptions = {}): ScaffoldResult {
149
+ return ensureFile(path.join(dotfilesDir, 'README.md'), DOTFILES_README, options);
150
+ }
151
+
152
+ export function ensureShareCommonReadme(
153
+ config: { shareBase: string },
154
+ options: ScaffoldOptions = {}
155
+ ): ScaffoldResult {
156
+ return ensureFile(path.join(shareCommonDir(config), 'README.md'), SHARE_COMMON_README, options);
157
+ }
158
+
159
+ export function ensureShareBranchReadme(
160
+ config: { shareBase: string },
161
+ branch: string,
162
+ options: ScaffoldOptions = {}
163
+ ): ScaffoldResult {
164
+ return ensureFile(path.join(shareBranchDir(config, branch), 'README.md'), SHARE_BRANCH_README, options);
165
+ }
166
+
167
+ export function ensureSandboxDiscoveryReadmes(
168
+ config: { shareBase: string; dotfilesDir: string },
169
+ branch: string,
170
+ options: ScaffoldOptions = {}
171
+ ): ScaffoldResult[] {
172
+ return [
173
+ ensureDotfilesReadme(config.dotfilesDir, options),
174
+ ensureShareCommonReadme(config, options),
175
+ ensureShareBranchReadme(config, branch, options)
176
+ ];
177
+ }
@@ -1,4 +1,6 @@
1
1
  USER devuser
2
+ ENV DISABLE_UPDATES=1
3
+ ENV OPENCODE_DISABLE_AUTOUPDATE=1
2
4
  ENV NPM_CONFIG_PREFIX=/home/devuser/.npm-global
3
5
  ENV PATH="/home/devuser/.npm-global/bin:${PATH}"
4
6
 
@@ -1,4 +1,4 @@
1
- FROM ubuntu:22.04
1
+ FROM ubuntu:24.04
2
2
 
3
3
  LABEL description="AI coding sandbox"
4
4
 
@@ -28,7 +28,7 @@ RUN apt-get update && apt-get install -y \
28
28
  && echo "deb [arch=$(dpkg --print-architecture) signed-by=/usr/share/keyrings/githubcli-archive-keyring.gpg] https://cli.github.com/packages stable main" \
29
29
  > /etc/apt/sources.list.d/github-cli.list \
30
30
  && apt-get update && apt-get install -y gh \
31
- && TMUX_VERSION=3.6a \
31
+ && TMUX_VERSION=3.6b \
32
32
  && wget -qO /tmp/tmux.tar.gz \
33
33
  "https://github.com/tmux/tmux/releases/download/${TMUX_VERSION}/tmux-${TMUX_VERSION}.tar.gz" \
34
34
  && tar xzf /tmp/tmux.tar.gz -C /tmp \
@@ -126,7 +126,7 @@ find . -type f -print | while IFS= read -r rel; do
126
126
  .config/opencode|.config/opencode/*|\
127
127
  .local/share/opencode|.local/share/opencode/*|\
128
128
  .host-shell-config|.host-shell-config/*|\
129
- .gitconfig|.gitignore_global|.stCommitMsg|.bash_aliases)
129
+ .gitconfig|.gitignore_global|.stCommitMsg|.bash_aliases|README.md)
130
130
  continue ;;
131
131
  esac
132
132
 
package/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "@fitlab-ai/agent-infra",
3
- "version": "0.6.4",
3
+ "version": "0.6.5",
4
4
  "description": "Bootstrap tool for AI multi-tool collaboration infrastructure — works with Claude Code, Codex, Gemini CLI, and OpenCode",
5
5
  "license": "MIT",
6
6
  "type": "module",