sanduary 1.0.2 → 1.0.4

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.
@@ -38,7 +38,7 @@ RUN apt-get update && apt-get install -y \
38
38
 
39
39
  ENV LANG=ja_JP.UTF-8
40
40
 
41
- # Playwright依存ライブラリ
41
+ # Playwright依存ライブラリ + 日本語フォント
42
42
  RUN apt-get update && apt-get install -y \
43
43
  libatk1.0-0 \
44
44
  libatk-bridge2.0-0 \
@@ -53,6 +53,7 @@ RUN apt-get update && apt-get install -y \
53
53
  libasound2 \
54
54
  libnspr4 \
55
55
  libnss3 \
56
+ fonts-noto-cjk \
56
57
  && apt-get clean \
57
58
  && rm -rf /var/lib/apt/lists/*
58
59
 
@@ -68,5 +69,8 @@ RUN mkdir -p /workspaces/${PROJECT_NAME} && chown node:node /workspaces/${PROJEC
68
69
  # 作業ディレクトリ
69
70
  WORKDIR /workspaces/${PROJECT_NAME}
70
71
 
72
+ # .claudeディレクトリをnodeユーザーの所有で作成(postStartCommandで使用)
73
+ RUN mkdir -p /home/node/.claude/plugins && chown -R node:node /home/node/.claude
74
+
71
75
  # nodeユーザーに切り替え
72
76
  USER node
@@ -4,8 +4,9 @@
4
4
  "workspaceFolder": "/workspaces/${localWorkspaceFolderBasename}",
5
5
  "workspaceMount": "",
6
6
  "updateRemoteUserUID": true,
7
- "initializeCommand": "echo 'PROJECT_ROOT='$(pwd) > .devcontainer/.env && echo 'PROJECT_NAME='$(basename $(pwd)) >> .devcontainer/.env && echo 'GIT_ORIGIN_URL='$(git remote get-url origin 2>/dev/null || echo '') >> .devcontainer/.env && [ -f ~/.claude-sandbox-credentials.json ] || echo '{}' > ~/.claude-sandbox-credentials.json && [ -f ~/.claude-sandbox.json ] || echo '{}' > ~/.claude-sandbox.json",
7
+ "initializeCommand": "echo 'PROJECT_ROOT='$(pwd) > .devcontainer/.env && echo 'PROJECT_NAME='$(basename $(pwd)) >> .devcontainer/.env && echo 'GIT_ORIGIN_URL='$(git remote get-url origin 2>/dev/null || echo '') >> .devcontainer/.env && [ -f ~/.claude-sandbox-credentials.json ] || echo '{}' > ~/.claude-sandbox-credentials.json && [ -f ~/.claude-sandbox.json ] || echo '{}' > ~/.claude-sandbox.json && [ -d ~/.claude/plugins ] || mkdir -p ~/.claude/plugins",
8
8
  "postCreateCommand": "git init && git remote add origin \"${GIT_ORIGIN_URL:-/host-project}\" && git fetch && git checkout $(git -C /host-project branch --show-current) && echo 'alias claude=\"npx claude --dangerously-skip-permissions\"' >> ~/.bashrc",
9
+ "postStartCommand": "cp -rT /home/node/.claude-host-plugins /home/node/.claude/plugins 2>/dev/null || true; [ -f /home/node/.claude/plugins/known_marketplaces.json ] && sed -i 's|/Users/[^/]*/|/home/node/|g' /home/node/.claude/plugins/known_marketplaces.json; [ -f /home/node/.claude/plugins/installed_plugins.json ] && sed -i 's|/Users/[^/]*/|/home/node/|g' /home/node/.claude/plugins/installed_plugins.json; true",
9
10
  "shutdownAction": "stopCompose",
10
11
  "remoteUser": "node",
11
12
  "remoteEnv": {
@@ -6,9 +6,9 @@
6
6
  "workspaceFolder": "/workspaces/${localWorkspaceFolderBasename}",
7
7
  "workspaceMount": "",
8
8
  "updateRemoteUserUID": true,
9
- "initializeCommand": "echo 'PROJECT_ROOT='$(pwd) > .devcontainer/.env && echo 'PROJECT_NAME='$(basename $(pwd)) >> .devcontainer/.env && echo 'GIT_ORIGIN_URL='$(git remote get-url origin 2>/dev/null || echo '') >> .devcontainer/.env && [ -f ~/.claude-sandbox-credentials.json ] || echo '{}' > ~/.claude-sandbox-credentials.json && [ -f ~/.claude-sandbox.json ] || echo '{}' > ~/.claude-sandbox.json",
9
+ "initializeCommand": "echo 'PROJECT_ROOT='$(pwd) > .devcontainer/.env && echo 'PROJECT_NAME='$(basename $(pwd)) >> .devcontainer/.env && echo 'GIT_ORIGIN_URL='$(git remote get-url origin 2>/dev/null || echo '') >> .devcontainer/.env && [ -f ~/.claude-sandbox-credentials.json ] || echo '{}' > ~/.claude-sandbox-credentials.json && [ -f ~/.claude-sandbox.json ] || echo '{}' > ~/.claude-sandbox.json && [ -d ~/.claude-test-nonexistent/plugins ] || mkdir -p ~/.claude-test-nonexistent/plugins",
10
10
  "postCreateCommand": "git init && git remote add origin \"${GIT_ORIGIN_URL:-/host-project}\" && git fetch && git checkout $(git -C /host-project branch --show-current) && echo 'alias claude=\"npx claude --dangerously-skip-permissions\"' >> ~/.bashrc",
11
- "postStartCommand": "cp -rT /home/node/.claude-host /home/node/.claude && sed -i 's|/Users/[^/]*/|/home/node/|g' /home/node/.claude/plugins/known_marketplaces.json",
11
+ "postStartCommand": "cp -rT /home/node/.claude-host-plugins /home/node/.claude/plugins 2>/dev/null || true; [ -f /home/node/.claude/plugins/known_marketplaces.json ] && sed -i 's|/Users/[^/]*/|/home/node/|g' /home/node/.claude/plugins/known_marketplaces.json; [ -f /home/node/.claude/plugins/installed_plugins.json ] && sed -i 's|/Users/[^/]*/|/home/node/|g' /home/node/.claude/plugins/installed_plugins.json; true",
12
12
  "shutdownAction": "stopCompose",
13
13
  "remoteUser": "node",
14
14
  "remoteEnv": {
@@ -12,6 +12,8 @@ services:
12
12
  - /var/run/docker.sock:/var/run/docker.sock
13
13
  - ${PROJECT_ROOT:-..}:/host-project
14
14
  - ${HOME}/.claude:/home/node/.claude
15
+ - ${HOME}/.claude/plugins:/home/node/.claude-host-plugins:ro
16
+ - /home/node/.claude/plugins
15
17
  - ${HOME}/.claude-sandbox.json:/home/node/.claude.json
16
18
  - ${HOME}/.claude-sandbox-credentials.json:/home/node/.claude/.credentials.json
17
19
  - ${HOME}/.gitconfig:/home/node/.gitconfig
package/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "sanduary",
3
- "version": "1.0.2",
3
+ "version": "1.0.4",
4
4
  "description": "Development sandbox environment for AI agents - A secure sanctuary for running AI coding assistants in Docker DevContainers",
5
5
  "keywords": [
6
6
  "devcontainer",
@@ -31,7 +31,6 @@
31
31
  "dependencies": {
32
32
  "js-yaml": "^4.1.0"
33
33
  },
34
- "main": "index.js",
35
34
  "devDependencies": {
36
35
  "@anthropic-ai/claude-code": "^2.0.72"
37
36
  },
@@ -26,16 +26,11 @@ case "$COMMAND" in
26
26
 
27
27
  cd "$DEVCONTAINER_DIR"
28
28
 
29
- # 認証ファイルが存在しない場合は空のJSONを作成
30
- CREDENTIALS_FILE="$HOME/.claude-sandbox-credentials.json"
31
- if [ ! -f "$CREDENTIALS_FILE" ]; then
32
- echo '{}' > "$CREDENTIALS_FILE"
33
- fi
34
-
35
- # .claude-sandbox.jsonが存在しない場合は空のJSONを作成
36
- CLAUDE_JSON="$HOME/.claude-sandbox.json"
37
- if [ ! -f "$CLAUDE_JSON" ]; then
38
- echo '{}' > "$CLAUDE_JSON"
29
+ # devcontainer.jsonからinitializeCommandを読み取って実行(ホスト側で実行)
30
+ INITIALIZE_CMD=$(jq -r '.initializeCommand // empty' "$DEVCONTAINER_JSON")
31
+ if [ -n "$INITIALIZE_CMD" ]; then
32
+ echo "Running initializeCommand..."
33
+ eval "$INITIALIZE_CMD"
39
34
  fi
40
35
 
41
36
  # 終了時のcleanup関数
@@ -0,0 +1,35 @@
1
+ #!/bin/bash
2
+ set -e
3
+
4
+ SCRIPT_DIR="$(dirname "$(realpath "$0")")"
5
+ PROJECT_ROOT="$(dirname "$SCRIPT_DIR")"
6
+ DEVCONTAINER_DIR="$PROJECT_ROOT/.devcontainer"
7
+
8
+ # 置換対象パターン
9
+ ORIGINAL_PATTERN='${HOME}/.claude'
10
+ TEST_PATTERN='${HOME}/.claude-test-nonexistent'
11
+
12
+ case "${1:-}" in
13
+ replace)
14
+ echo "Replacing .claude paths for testing..."
15
+ # docker-compose.yml: .claude/ または .claude: のみ置換(.claude-sandbox等は除外)
16
+ sed -i.bak 's|\${HOME}/\.claude/|\${HOME}/.claude-test-nonexistent/|g; s|\${HOME}/\.claude:|\${HOME}/.claude-test-nonexistent:|g' "$DEVCONTAINER_DIR/docker-compose.yml"
17
+ # devcontainer.base.json: ~/.claude/ のみ置換(~/.claude-sandbox等は除外)
18
+ sed -i.bak 's|~/\.claude/|~/.claude-test-nonexistent/|g' "$DEVCONTAINER_DIR/devcontainer.base.json"
19
+ echo "Done. Original files backed up with .bak extension."
20
+ echo ""
21
+ echo "Now run: npx sandbox init && npx sandbox"
22
+ ;;
23
+ restore)
24
+ echo "Restoring original .claude paths..."
25
+ mv "$DEVCONTAINER_DIR/docker-compose.yml.bak" "$DEVCONTAINER_DIR/docker-compose.yml"
26
+ mv "$DEVCONTAINER_DIR/devcontainer.base.json.bak" "$DEVCONTAINER_DIR/devcontainer.base.json"
27
+ echo "Done. Original files restored."
28
+ ;;
29
+ *)
30
+ echo "Usage: $0 [replace|restore]"
31
+ echo " replace - Replace .claude paths with test paths"
32
+ echo " restore - Restore original .claude paths from backup"
33
+ exit 1
34
+ ;;
35
+ esac