@fitlab-ai/agent-infra 0.9.2 → 0.9.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.
- package/README.md +12 -9
- package/README.zh-CN.md +12 -9
- package/bin/cli.ts +12 -0
- package/dist/bin/cli.js +14 -0
- package/dist/bin/internal-cli.js +134 -108
- package/dist/lib/agent-clients/adapter.js +137 -4
- package/dist/lib/agent-clients/adapters/antigravity-cli.js +64 -0
- package/dist/lib/{sandbox/credentials.js → agent-clients/adapters/claude-code-credentials.js} +4 -14
- package/dist/lib/agent-clients/adapters/claude-code-refresh.js +85 -0
- package/dist/lib/agent-clients/adapters/claude-code-sandbox.js +247 -0
- package/dist/lib/agent-clients/adapters/claude-code.js +27 -4
- package/dist/lib/agent-clients/adapters/codex.js +9 -0
- package/dist/lib/agent-clients/adapters/index.js +2 -2
- package/dist/lib/agent-clients/adapters/opencode-sandbox.js +108 -0
- package/dist/lib/agent-clients/adapters/opencode.js +24 -3
- package/dist/lib/agent-clients/adapters/runtimes/claude-code.dockerfile +65 -0
- package/dist/lib/agent-clients/config.js +42 -4
- package/dist/lib/agent-clients/next-steps.js +11 -2
- package/dist/lib/agent-clients/reconcile.js +2 -1
- package/dist/lib/agent-clients/registry.js +16 -2
- package/dist/lib/agent-clients/schema.js +18 -0
- package/dist/lib/agent-clients/tokens.js +49 -0
- package/dist/lib/agent-clients/types.js +1 -1
- package/dist/lib/defaults.json +1 -1
- package/dist/lib/git/workflow.js +54 -1
- package/dist/lib/internal/agent-client.js +61 -4
- package/dist/lib/internal/git-workflow.js +6 -1
- package/dist/lib/internal/platform-checks.js +3 -3
- package/dist/lib/internal/platform-comment.js +29 -2
- package/dist/lib/internal/platform-issue.js +7 -0
- package/dist/lib/internal/platform-pr-review.js +132 -0
- package/dist/lib/internal/platform-pr.js +20 -2
- package/dist/lib/internal/platform-release-notes.js +52 -16
- package/dist/lib/internal/pr-review-grade.js +140 -0
- package/dist/lib/internal/release-workflow.js +13 -6
- package/dist/lib/internal/sandbox-control.js +24 -0
- package/dist/lib/internal/task-activity.js +105 -0
- package/dist/lib/internal/task-event.js +17 -1
- package/dist/lib/internal/task-ledger.js +12 -3
- package/dist/lib/internal/task-lifecycle.js +26 -1
- package/dist/lib/internal/task-orchestration.js +167 -18
- package/dist/lib/internal/task-review.js +8 -3
- package/dist/lib/platform/adapters.js +8 -1
- package/dist/lib/platform/completion-backfill.js +122 -0
- package/dist/lib/platform/github-client.js +19 -2
- package/dist/lib/platform/issue-comments.js +3 -2
- package/dist/lib/platform/merged-pr-equivalence.js +115 -5
- package/dist/lib/platform/pr-checks.js +65 -42
- package/dist/lib/platform/pr-review.js +166 -0
- package/dist/lib/platform/pull-requests.js +371 -4
- package/dist/lib/platform/release-notes.js +85 -3
- package/dist/lib/platform/releases.js +13 -5
- package/dist/lib/pr-review/evidence-grading.js +229 -0
- package/dist/lib/process-data/index.js +239 -0
- package/dist/lib/process-data/normalize.js +198 -0
- package/dist/lib/process-data/privacy.js +33 -0
- package/dist/lib/process-data/reconcile.js +95 -0
- package/dist/lib/process-data/repair.js +58 -0
- package/dist/lib/process-data/sources.js +345 -0
- package/dist/lib/process-data/store.js +282 -0
- package/dist/lib/process-data/types.js +2 -0
- package/dist/lib/run/index.js +4 -3
- package/dist/lib/run/tui.js +10 -13
- package/dist/lib/sandbox/agent-client-reconciler.js +26 -2
- package/dist/lib/sandbox/capture.js +7 -2
- package/dist/lib/sandbox/commands/create.js +109 -248
- package/dist/lib/sandbox/commands/enter.js +15 -47
- package/dist/lib/sandbox/commands/list-running.js +16 -6
- package/dist/lib/sandbox/commands/ls.js +10 -6
- package/dist/lib/sandbox/commands/rebuild.js +4 -3
- package/dist/lib/sandbox/commands/refresh.js +4 -84
- package/dist/lib/sandbox/commands/rm.js +24 -3
- package/dist/lib/sandbox/commands/show.js +13 -4
- package/dist/lib/sandbox/commands/start.js +7 -4
- package/dist/lib/sandbox/config.js +2 -0
- package/dist/lib/sandbox/constants.js +6 -0
- package/dist/lib/sandbox/control/client.js +44 -0
- package/dist/lib/sandbox/control/protocol.js +35 -0
- package/dist/lib/sandbox/control/server.js +109 -0
- package/dist/lib/sandbox/dockerfile.js +36 -13
- package/dist/lib/sandbox/mounts.js +17 -4
- package/dist/lib/sandbox/recovery.js +128 -5
- package/dist/lib/sandbox/redaction.js +12 -0
- package/dist/lib/sandbox/runtimes/base.dockerfile +24 -74
- package/dist/lib/sandbox/workspace-identity.js +95 -0
- package/dist/lib/sandbox/workspace-view.js +103 -0
- package/dist/lib/task/activity-intent.js +307 -0
- package/dist/lib/task/artifact-lifecycle.js +2 -1
- package/dist/lib/task/commands/log.js +15 -14
- package/dist/lib/task/commit-finalization.js +267 -0
- package/dist/lib/task/commit-intent.js +165 -0
- package/dist/lib/task/decision-intents.js +31 -17
- package/dist/lib/task/delegation-receipts.js +25 -4
- package/dist/lib/task/events.js +67 -28
- package/dist/lib/task/finalization-artifacts.js +35 -0
- package/dist/lib/task/implementation-inputs.js +54 -7
- package/dist/lib/task/ledger-intents.js +35 -1
- package/dist/lib/task/lifecycle-execution.js +46 -0
- package/dist/lib/task/orchestration.js +753 -54
- package/dist/lib/task/resolve-ref.js +41 -1
- package/dist/lib/task/review-finalization.js +29 -9
- package/dist/lib/task/task-execution-lock.js +231 -0
- package/dist/lib/task/verification-checks.js +1 -1
- package/dist/lib/task/verification-engine.js +218 -2
- package/dist/lib/task/verification.js +4 -3
- package/dist/lib/task/workspace-snapshot.js +17 -5
- package/lib/agent-clients/adapter.ts +201 -4
- package/lib/agent-clients/adapters/antigravity-cli.ts +65 -0
- package/lib/{sandbox/credentials.ts → agent-clients/adapters/claude-code-credentials.ts} +3 -18
- package/lib/agent-clients/adapters/claude-code-refresh.ts +128 -0
- package/lib/agent-clients/adapters/claude-code-sandbox.ts +295 -0
- package/lib/agent-clients/adapters/claude-code.ts +31 -4
- package/lib/agent-clients/adapters/codex.ts +9 -0
- package/lib/agent-clients/adapters/index.ts +2 -2
- package/lib/agent-clients/adapters/opencode-sandbox.ts +136 -0
- package/lib/agent-clients/adapters/opencode.ts +27 -3
- package/lib/agent-clients/adapters/runtimes/claude-code.dockerfile +65 -0
- package/lib/agent-clients/config.ts +49 -4
- package/lib/agent-clients/next-steps.ts +15 -2
- package/lib/agent-clients/reconcile.ts +2 -1
- package/lib/agent-clients/registry.ts +19 -1
- package/lib/agent-clients/schema.ts +18 -0
- package/lib/agent-clients/tokens.ts +53 -0
- package/lib/agent-clients/types.ts +15 -1
- package/lib/defaults.json +1 -1
- package/lib/git/workflow.ts +66 -2
- package/lib/internal/agent-client.ts +59 -4
- package/lib/internal/git-workflow.ts +5 -1
- package/lib/internal/platform-checks.ts +4 -4
- package/lib/internal/platform-comment.ts +17 -2
- package/lib/internal/platform-issue.ts +4 -0
- package/lib/internal/platform-pr-review.ts +104 -0
- package/lib/internal/platform-pr.ts +14 -1
- package/lib/internal/platform-release-notes.ts +59 -16
- package/lib/internal/pr-review-grade.ts +130 -0
- package/lib/internal/release-workflow.ts +13 -6
- package/lib/internal/sandbox-control.ts +24 -0
- package/lib/internal/task-activity.ts +91 -0
- package/lib/internal/task-event.ts +9 -1
- package/lib/internal/task-ledger.ts +12 -3
- package/lib/internal/task-lifecycle.ts +26 -1
- package/lib/internal/task-orchestration.ts +123 -14
- package/lib/internal/task-review.ts +8 -3
- package/lib/platform/adapters.ts +29 -2
- package/lib/platform/completion-backfill.ts +134 -0
- package/lib/platform/github-client.ts +20 -2
- package/lib/platform/issue-comments.ts +3 -2
- package/lib/platform/merged-pr-equivalence.ts +127 -5
- package/lib/platform/pr-checks.ts +73 -46
- package/lib/platform/pr-review.ts +201 -0
- package/lib/platform/pull-requests.ts +444 -3
- package/lib/platform/release-notes.ts +100 -4
- package/lib/platform/releases.ts +16 -4
- package/lib/pr-review/evidence-grading.ts +318 -0
- package/lib/process-data/index.ts +224 -0
- package/lib/process-data/normalize.ts +202 -0
- package/lib/process-data/privacy.ts +41 -0
- package/lib/process-data/reconcile.ts +110 -0
- package/lib/process-data/repair.ts +64 -0
- package/lib/process-data/sources.ts +354 -0
- package/lib/process-data/store.ts +315 -0
- package/lib/process-data/types.ts +135 -0
- package/lib/run/index.ts +5 -3
- package/lib/run/tui.ts +14 -12
- package/lib/sandbox/agent-client-reconciler.ts +44 -2
- package/lib/sandbox/capture.ts +9 -2
- package/lib/sandbox/commands/create.ts +126 -280
- package/lib/sandbox/commands/enter.ts +13 -59
- package/lib/sandbox/commands/list-running.ts +23 -6
- package/lib/sandbox/commands/ls.ts +22 -6
- package/lib/sandbox/commands/rebuild.ts +4 -3
- package/lib/sandbox/commands/refresh.ts +4 -126
- package/lib/sandbox/commands/rm.ts +24 -3
- package/lib/sandbox/commands/show.ts +30 -4
- package/lib/sandbox/commands/start.ts +6 -4
- package/lib/sandbox/config.ts +4 -0
- package/lib/sandbox/constants.ts +8 -0
- package/lib/sandbox/control/client.ts +55 -0
- package/lib/sandbox/control/protocol.ts +75 -0
- package/lib/sandbox/control/server.ts +117 -0
- package/lib/sandbox/dockerfile.ts +66 -13
- package/lib/sandbox/mounts.ts +24 -4
- package/lib/sandbox/recovery.ts +163 -6
- package/lib/sandbox/redaction.ts +14 -0
- package/lib/sandbox/runtimes/base.dockerfile +24 -74
- package/lib/sandbox/tool-types.ts +16 -0
- package/lib/sandbox/workspace-identity.ts +123 -0
- package/lib/sandbox/workspace-view.ts +143 -0
- package/lib/server/server.schema.json +2 -2
- package/lib/task/activity-intent.ts +417 -0
- package/lib/task/artifact-lifecycle.ts +2 -1
- package/lib/task/commands/log.ts +15 -14
- package/lib/task/commit-finalization.ts +356 -0
- package/lib/task/commit-intent.ts +230 -0
- package/lib/task/decision-intents.ts +32 -12
- package/lib/task/delegation-receipts.ts +34 -5
- package/lib/task/events.ts +75 -30
- package/lib/task/finalization-artifacts.ts +58 -0
- package/lib/task/implementation-inputs.ts +62 -8
- package/lib/task/ledger-intents.ts +43 -3
- package/lib/task/lifecycle-execution.ts +106 -0
- package/lib/task/orchestration.ts +1019 -72
- package/lib/task/resolve-ref.ts +46 -1
- package/lib/task/review-finalization.ts +40 -9
- package/lib/task/task-execution-lock.ts +296 -0
- package/lib/task/verification-checks.ts +1 -1
- package/lib/task/verification-engine.ts +249 -2
- package/lib/task/verification.ts +5 -3
- package/lib/task/workspace-snapshot.ts +26 -5
- package/package.json +3 -3
- package/templates/.agents/QUICKSTART.en.md +25 -8
- package/templates/.agents/QUICKSTART.zh-CN.md +25 -8
- package/templates/.agents/README.en.md +10 -7
- package/templates/.agents/README.zh-CN.md +10 -7
- package/templates/.agents/hooks/lifecycle-delegation.js +15 -4
- package/templates/.agents/rules/README.en.md +1 -1
- package/templates/.agents/rules/README.zh-CN.md +1 -1
- package/templates/.agents/rules/create-issue.github.en.md +4 -2
- package/templates/.agents/rules/create-issue.github.zh-CN.md +4 -2
- package/templates/.agents/rules/human-decision-context.en.md +11 -2
- package/templates/.agents/rules/human-decision-context.zh-CN.md +11 -2
- package/templates/.agents/rules/issue-fields.github.en.md +3 -1
- package/templates/.agents/rules/issue-fields.github.zh-CN.md +3 -1
- package/templates/.agents/rules/issue-pr-commands.en.md +5 -3
- package/templates/.agents/rules/issue-pr-commands.github.en.md +5 -3
- package/templates/.agents/rules/issue-pr-commands.github.zh-CN.md +5 -3
- package/templates/.agents/rules/issue-pr-commands.zh-CN.md +5 -3
- package/templates/.agents/rules/issue-sync.github.en.md +7 -3
- package/templates/.agents/rules/issue-sync.github.zh-CN.md +8 -4
- package/templates/.agents/rules/lifecycle-orchestration.en.md +5 -2
- package/templates/.agents/rules/lifecycle-orchestration.zh-CN.md +5 -2
- package/templates/.agents/rules/milestone-inference.github.en.md +4 -2
- package/templates/.agents/rules/milestone-inference.github.zh-CN.md +4 -2
- package/templates/.agents/rules/next-step-output.en.md +3 -1
- package/templates/.agents/rules/next-step-output.zh-CN.md +3 -1
- package/templates/.agents/rules/no-mid-flow-questions.en.md +17 -0
- package/templates/.agents/rules/no-mid-flow-questions.zh-CN.md +17 -0
- package/templates/.agents/rules/pr-checks-commands.en.md +3 -3
- package/templates/.agents/rules/pr-checks-commands.github.en.md +2 -2
- package/templates/.agents/rules/pr-checks-commands.github.zh-CN.md +3 -3
- package/templates/.agents/rules/pr-checks-commands.zh-CN.md +3 -3
- package/templates/.agents/rules/pr-sync.en.md +3 -1
- package/templates/.agents/rules/pr-sync.github.en.md +11 -1
- package/templates/.agents/rules/pr-sync.github.zh-CN.md +11 -1
- package/templates/.agents/rules/pr-sync.zh-CN.md +3 -1
- package/templates/.agents/rules/release-commands.en.md +1 -1
- package/templates/.agents/rules/release-commands.github.en.md +12 -2
- package/templates/.agents/rules/release-commands.github.zh-CN.md +12 -2
- package/templates/.agents/rules/release-commands.zh-CN.md +1 -1
- package/templates/.agents/rules/review-handshake.zh-CN.md +1 -1
- package/templates/.agents/rules/task-management.en.md +13 -0
- package/templates/.agents/rules/task-management.zh-CN.md +13 -0
- package/templates/.agents/skills/analyze-task/SKILL.en.md +10 -7
- package/templates/.agents/skills/analyze-task/SKILL.zh-CN.md +10 -7
- package/templates/.agents/skills/block-task/SKILL.en.md +7 -5
- package/templates/.agents/skills/block-task/SKILL.zh-CN.md +7 -5
- package/templates/.agents/skills/cancel-task/SKILL.en.md +6 -4
- package/templates/.agents/skills/cancel-task/SKILL.zh-CN.md +6 -4
- package/templates/.agents/skills/close-codescan/SKILL.en.md +3 -1
- package/templates/.agents/skills/close-codescan/SKILL.zh-CN.md +3 -1
- package/templates/.agents/skills/close-dependabot/SKILL.en.md +3 -1
- package/templates/.agents/skills/close-dependabot/SKILL.zh-CN.md +3 -1
- package/templates/.agents/skills/code-task/SKILL.en.md +10 -7
- package/templates/.agents/skills/code-task/SKILL.zh-CN.md +12 -9
- package/templates/.agents/skills/commit/SKILL.en.md +23 -11
- package/templates/.agents/skills/commit/SKILL.zh-CN.md +29 -11
- package/templates/.agents/skills/commit/reference/commit-message.en.md +1 -1
- package/templates/.agents/skills/commit/reference/commit-message.zh-CN.md +1 -1
- package/templates/.agents/skills/commit/reference/commit-orchestration.en.md +49 -0
- package/templates/.agents/skills/commit/reference/commit-orchestration.zh-CN.md +55 -0
- package/templates/.agents/skills/commit/reference/issue-metadata-sync.en.md +1 -1
- package/templates/.agents/skills/commit/reference/issue-metadata-sync.zh-CN.md +1 -1
- package/templates/.agents/skills/commit/reference/pr-summary-sync.en.md +1 -1
- package/templates/.agents/skills/commit/reference/pr-summary-sync.zh-CN.md +1 -1
- package/templates/.agents/skills/commit/reference/task-status-update.en.md +4 -4
- package/templates/.agents/skills/commit/reference/task-status-update.zh-CN.md +4 -4
- package/templates/.agents/skills/complete-manual-validation/SKILL.en.md +6 -4
- package/templates/.agents/skills/complete-manual-validation/SKILL.zh-CN.md +6 -4
- package/templates/.agents/skills/complete-manual-validation/reference/summary-update.en.md +1 -1
- package/templates/.agents/skills/complete-manual-validation/reference/summary-update.zh-CN.md +1 -1
- package/templates/.agents/skills/complete-task/SKILL.en.md +22 -7
- package/templates/.agents/skills/complete-task/SKILL.zh-CN.md +22 -7
- package/templates/.agents/skills/complete-task/config/verify.en.json +1 -0
- package/templates/.agents/skills/complete-task/config/verify.zh-CN.json +1 -0
- package/templates/.agents/skills/complete-task/reference/external-delivery.en.md +17 -0
- package/templates/.agents/skills/complete-task/reference/external-delivery.zh-CN.md +17 -0
- package/templates/.agents/skills/create-pr/SKILL.en.md +7 -5
- package/templates/.agents/skills/create-pr/SKILL.zh-CN.md +7 -5
- package/templates/.agents/skills/create-pr/reference/comment-publish.en.md +1 -1
- package/templates/.agents/skills/create-pr/reference/comment-publish.zh-CN.md +1 -1
- package/templates/.agents/skills/create-release-note/SKILL.en.md +17 -16
- package/templates/.agents/skills/create-release-note/SKILL.zh-CN.md +17 -16
- package/templates/.agents/skills/create-task/SKILL.en.md +5 -3
- package/templates/.agents/skills/create-task/SKILL.zh-CN.md +5 -3
- package/templates/.agents/skills/create-task/reference/context-capture.en.md +34 -0
- package/templates/.agents/skills/create-task/reference/context-capture.zh-CN.md +34 -0
- package/templates/.agents/skills/import-issue/SKILL.en.md +5 -3
- package/templates/.agents/skills/import-issue/SKILL.zh-CN.md +5 -3
- package/templates/.agents/skills/plan-task/SKILL.en.md +8 -5
- package/templates/.agents/skills/plan-task/SKILL.zh-CN.md +8 -5
- package/templates/.agents/skills/post-release/SKILL.en.md +2 -0
- package/templates/.agents/skills/post-release/SKILL.zh-CN.md +2 -0
- package/templates/.agents/skills/release/SKILL.en.md +16 -10
- package/templates/.agents/skills/release/SKILL.zh-CN.md +16 -10
- package/templates/.agents/skills/restore-task/SKILL.en.md +4 -1
- package/templates/.agents/skills/restore-task/SKILL.zh-CN.md +4 -1
- package/templates/.agents/skills/review-analysis/SKILL.en.md +7 -4
- package/templates/.agents/skills/review-analysis/SKILL.zh-CN.md +7 -4
- package/templates/.agents/skills/review-code/SKILL.en.md +11 -8
- package/templates/.agents/skills/review-code/SKILL.zh-CN.md +11 -8
- package/templates/.agents/skills/review-code/reference/output-templates.en.md +1 -1
- package/templates/.agents/skills/review-code/reference/output-templates.zh-CN.md +1 -1
- package/templates/.agents/skills/review-plan/SKILL.en.md +7 -4
- package/templates/.agents/skills/review-plan/SKILL.zh-CN.md +7 -4
- package/templates/.agents/skills/review-pr/SKILL.en.md +186 -0
- package/templates/.agents/skills/review-pr/SKILL.zh-CN.md +186 -0
- package/templates/.agents/skills/review-pr/config/verify.en.json +37 -0
- package/templates/.agents/skills/review-pr/config/verify.zh-CN.json +37 -0
- package/templates/.agents/skills/review-pr/reference/evidence-grading.en.md +65 -0
- package/templates/.agents/skills/review-pr/reference/evidence-grading.zh-CN.md +65 -0
- package/templates/.agents/skills/review-pr/reference/output-guidance.en.md +18 -0
- package/templates/.agents/skills/review-pr/reference/output-guidance.zh-CN.md +18 -0
- package/templates/.agents/skills/review-pr/reference/report-template.en.md +85 -0
- package/templates/.agents/skills/review-pr/reference/report-template.zh-CN.md +85 -0
- package/templates/.agents/skills/run-task/SKILL.en.md +8 -8
- package/templates/.agents/skills/run-task/SKILL.zh-CN.md +8 -8
- package/templates/.agents/skills/run-task/config/verify.en.json +2 -1
- package/templates/.agents/skills/run-task/config/verify.zh-CN.json +2 -1
- package/templates/.agents/skills/run-task/reference/host-validation.en.md +20 -0
- package/templates/.agents/skills/run-task/reference/host-validation.zh-CN.md +20 -0
- package/templates/.agents/skills/update-agent-infra/scripts/sync-templates.js +98 -107
- package/templates/.agents/skills/watch-pr/SKILL.en.md +13 -13
- package/templates/.agents/skills/watch-pr/SKILL.zh-CN.md +13 -13
- package/templates/.agents/skills/watch-pr/reference/monitor-and-heal.en.md +27 -6
- package/templates/.agents/skills/watch-pr/reference/monitor-and-heal.zh-CN.md +26 -5
- package/templates/.agents/templates/task.en.md +2 -2
- package/templates/.agents/templates/task.zh-CN.md +2 -2
- package/templates/.agents/workflows/bug-fix.en.yaml +3 -3
- package/templates/.agents/workflows/bug-fix.zh-CN.yaml +3 -3
- package/templates/.agents/workflows/code-review.en.yaml +1 -1
- package/templates/.agents/workflows/code-review.zh-CN.yaml +1 -1
- package/templates/.agents/workflows/feature-development.en.yaml +4 -4
- package/templates/.agents/workflows/feature-development.zh-CN.yaml +4 -4
- package/templates/.agents/workflows/refactoring.en.yaml +3 -3
- package/templates/.agents/workflows/refactoring.zh-CN.yaml +3 -3
- package/templates/.claude/commands/post-release.en.md +1 -0
- package/templates/.claude/commands/post-release.zh-CN.md +1 -0
- package/templates/.claude/commands/review-pr.en.md +8 -0
- package/templates/.claude/commands/review-pr.zh-CN.md +8 -0
- package/templates/.claude/commands/watch-pr.en.md +1 -1
- package/templates/.claude/commands/watch-pr.zh-CN.md +1 -1
- package/templates/.claude/rules/tool-preferences.en.md +20 -0
- package/templates/.claude/rules/tool-preferences.zh-CN.md +20 -0
- package/templates/.opencode/commands/post-release.en.md +2 -0
- package/templates/.opencode/commands/post-release.zh-CN.md +2 -0
- package/templates/.opencode/commands/review-pr.en.md +11 -0
- package/templates/.opencode/commands/review-pr.zh-CN.md +11 -0
- package/templates/.opencode/commands/watch-pr.en.md +1 -1
- package/templates/.opencode/commands/watch-pr.zh-CN.md +1 -1
- package/dist/lib/agent-clients/adapters/gemini-cli.js +0 -64
- package/lib/agent-clients/adapters/gemini-cli.ts +0 -65
- package/templates/.gemini/commands/_project_/analyze-task.en.toml +0 -10
- package/templates/.gemini/commands/_project_/analyze-task.zh-CN.toml +0 -10
- package/templates/.gemini/commands/_project_/archive-tasks.en.toml +0 -10
- package/templates/.gemini/commands/_project_/archive-tasks.zh-CN.toml +0 -10
- package/templates/.gemini/commands/_project_/block-task.en.toml +0 -10
- package/templates/.gemini/commands/_project_/block-task.zh-CN.toml +0 -10
- package/templates/.gemini/commands/_project_/cancel-task.en.toml +0 -10
- package/templates/.gemini/commands/_project_/cancel-task.zh-CN.toml +0 -10
- package/templates/.gemini/commands/_project_/check-task.en.toml +0 -10
- package/templates/.gemini/commands/_project_/check-task.zh-CN.toml +0 -10
- package/templates/.gemini/commands/_project_/close-codescan.en.toml +0 -8
- package/templates/.gemini/commands/_project_/close-codescan.zh-CN.toml +0 -8
- package/templates/.gemini/commands/_project_/close-dependabot.en.toml +0 -8
- package/templates/.gemini/commands/_project_/close-dependabot.zh-CN.toml +0 -8
- package/templates/.gemini/commands/_project_/code-task.en.toml +0 -10
- package/templates/.gemini/commands/_project_/code-task.zh-CN.toml +0 -10
- package/templates/.gemini/commands/_project_/commit.en.toml +0 -10
- package/templates/.gemini/commands/_project_/commit.zh-CN.toml +0 -10
- package/templates/.gemini/commands/_project_/complete-manual-validation.en.toml +0 -10
- package/templates/.gemini/commands/_project_/complete-manual-validation.zh-CN.toml +0 -10
- package/templates/.gemini/commands/_project_/complete-task.en.toml +0 -10
- package/templates/.gemini/commands/_project_/complete-task.zh-CN.toml +0 -10
- package/templates/.gemini/commands/_project_/create-pr.en.toml +0 -10
- package/templates/.gemini/commands/_project_/create-pr.zh-CN.toml +0 -10
- package/templates/.gemini/commands/_project_/create-release-note.en.toml +0 -8
- package/templates/.gemini/commands/_project_/create-release-note.zh-CN.toml +0 -8
- package/templates/.gemini/commands/_project_/create-task.en.toml +0 -8
- package/templates/.gemini/commands/_project_/create-task.zh-CN.toml +0 -8
- package/templates/.gemini/commands/_project_/import-codescan.en.toml +0 -8
- package/templates/.gemini/commands/_project_/import-codescan.zh-CN.toml +0 -8
- package/templates/.gemini/commands/_project_/import-dependabot.en.toml +0 -8
- package/templates/.gemini/commands/_project_/import-dependabot.zh-CN.toml +0 -8
- package/templates/.gemini/commands/_project_/import-issue.en.toml +0 -8
- package/templates/.gemini/commands/_project_/import-issue.zh-CN.toml +0 -8
- package/templates/.gemini/commands/_project_/init-labels.en.toml +0 -8
- package/templates/.gemini/commands/_project_/init-labels.zh-CN.toml +0 -8
- package/templates/.gemini/commands/_project_/init-milestones.en.toml +0 -10
- package/templates/.gemini/commands/_project_/init-milestones.zh-CN.toml +0 -10
- package/templates/.gemini/commands/_project_/plan-task.en.toml +0 -10
- package/templates/.gemini/commands/_project_/plan-task.zh-CN.toml +0 -10
- package/templates/.gemini/commands/_project_/post-release.en.toml +0 -6
- package/templates/.gemini/commands/_project_/post-release.zh-CN.toml +0 -6
- package/templates/.gemini/commands/_project_/refine-title.en.toml +0 -8
- package/templates/.gemini/commands/_project_/refine-title.zh-CN.toml +0 -8
- package/templates/.gemini/commands/_project_/release.en.toml +0 -8
- package/templates/.gemini/commands/_project_/release.zh-CN.toml +0 -8
- package/templates/.gemini/commands/_project_/restore-task.en.toml +0 -8
- package/templates/.gemini/commands/_project_/restore-task.zh-CN.toml +0 -8
- package/templates/.gemini/commands/_project_/review-analysis.en.toml +0 -10
- package/templates/.gemini/commands/_project_/review-analysis.zh-CN.toml +0 -10
- package/templates/.gemini/commands/_project_/review-code.en.toml +0 -10
- package/templates/.gemini/commands/_project_/review-code.zh-CN.toml +0 -10
- package/templates/.gemini/commands/_project_/review-plan.en.toml +0 -10
- package/templates/.gemini/commands/_project_/review-plan.zh-CN.toml +0 -10
- package/templates/.gemini/commands/_project_/run-task.en.toml +0 -8
- package/templates/.gemini/commands/_project_/run-task.zh-CN.toml +0 -8
- package/templates/.gemini/commands/_project_/test-integration.en.toml +0 -6
- package/templates/.gemini/commands/_project_/test-integration.zh-CN.toml +0 -6
- package/templates/.gemini/commands/_project_/test.en.toml +0 -6
- package/templates/.gemini/commands/_project_/test.zh-CN.toml +0 -6
- package/templates/.gemini/commands/_project_/update-agent-infra.en.toml +0 -6
- package/templates/.gemini/commands/_project_/update-agent-infra.zh-CN.toml +0 -6
- package/templates/.gemini/commands/_project_/upgrade-dependency.en.toml +0 -8
- package/templates/.gemini/commands/_project_/upgrade-dependency.zh-CN.toml +0 -8
- package/templates/.gemini/commands/_project_/watch-pr.en.toml +0 -10
- package/templates/.gemini/commands/_project_/watch-pr.zh-CN.toml +0 -10
- package/templates/.gemini/settings.json +0 -3
|
@@ -0,0 +1,64 @@
|
|
|
1
|
+
import { defineAgentClientAdapter } from '../adapter.js';
|
|
2
|
+
import { hostJoin } from '../../sandbox/engines/wsl2-paths.js';
|
|
3
|
+
const antigravityCliAdapter = defineAgentClientAdapter({
|
|
4
|
+
id: 'antigravity-cli',
|
|
5
|
+
displayName: 'Antigravity CLI',
|
|
6
|
+
invocation: '/${skillName}',
|
|
7
|
+
capabilities: {
|
|
8
|
+
instructions: { level: 'compatible' },
|
|
9
|
+
skills: { level: 'integrated' },
|
|
10
|
+
commands: { level: 'integrated' },
|
|
11
|
+
hooks: { level: 'compatible' },
|
|
12
|
+
subagents: { level: 'unsupported' },
|
|
13
|
+
orchestration: { level: 'unsupported' },
|
|
14
|
+
sandbox: { level: 'integrated' },
|
|
15
|
+
verification: { level: 'compatible' }
|
|
16
|
+
},
|
|
17
|
+
modelSelection: {
|
|
18
|
+
kind: 'interactive-only',
|
|
19
|
+
command: '/model',
|
|
20
|
+
guidance: 'Use the host model picker for the complete model and reasoning-effort catalog.'
|
|
21
|
+
},
|
|
22
|
+
delegationEvidence: {
|
|
23
|
+
actualModel: 'unavailable',
|
|
24
|
+
actualReasoningEffort: 'unavailable'
|
|
25
|
+
},
|
|
26
|
+
project: {
|
|
27
|
+
ownedPathPrefixes: [],
|
|
28
|
+
managed: [],
|
|
29
|
+
merged: [],
|
|
30
|
+
ejected: [],
|
|
31
|
+
seedCommands: []
|
|
32
|
+
},
|
|
33
|
+
sandbox: {
|
|
34
|
+
createTool: ({ home }) => ({
|
|
35
|
+
id: 'antigravity-cli',
|
|
36
|
+
name: 'Antigravity CLI',
|
|
37
|
+
install: {
|
|
38
|
+
type: 'shell',
|
|
39
|
+
cmd: 'curl -fsSL https://antigravity.google/cli/install.sh | bash -s -- --dir /home/devuser/.npm-global/bin'
|
|
40
|
+
},
|
|
41
|
+
sandboxBase: hostJoin(home, '.agent-infra', 'sandboxes', 'antigravity-cli'),
|
|
42
|
+
containerMount: '/home/devuser/.gemini',
|
|
43
|
+
versionCmd: 'agy --version',
|
|
44
|
+
setupHint: 'Run agy inside the container to finish authentication.',
|
|
45
|
+
hostPreSeedFiles: [
|
|
46
|
+
{
|
|
47
|
+
hostPath: hostJoin(home, '.gemini', 'antigravity-cli', 'keybindings.json'),
|
|
48
|
+
sandboxName: 'antigravity-cli/keybindings.json'
|
|
49
|
+
},
|
|
50
|
+
{
|
|
51
|
+
hostPath: hostJoin(home, '.gemini', 'config', 'mcp_config.json'),
|
|
52
|
+
sandboxName: 'config/mcp_config.json'
|
|
53
|
+
}
|
|
54
|
+
]
|
|
55
|
+
}),
|
|
56
|
+
aliases: [
|
|
57
|
+
{ name: 'antigravity-yolo', command: 'agy --dangerously-skip-permissions; tput ed' },
|
|
58
|
+
{ name: 'agy-yolo', command: 'agy --dangerously-skip-permissions; tput ed' }
|
|
59
|
+
],
|
|
60
|
+
hooks: []
|
|
61
|
+
}
|
|
62
|
+
});
|
|
63
|
+
export { antigravityCliAdapter };
|
|
64
|
+
//# sourceMappingURL=antigravity-cli.js.map
|
package/dist/lib/{sandbox/credentials.js → agent-clients/adapters/claude-code-credentials.js}
RENAMED
|
@@ -2,15 +2,10 @@ import { execFileSync } from 'node:child_process';
|
|
|
2
2
|
import { randomBytes } from 'node:crypto';
|
|
3
3
|
import fs from 'node:fs';
|
|
4
4
|
import path from 'node:path';
|
|
5
|
-
import { hostJoin } from '
|
|
5
|
+
import { hostJoin } from '../../sandbox/engines/wsl2-paths.js';
|
|
6
|
+
import { redactCommandError } from '../../sandbox/redaction.js';
|
|
6
7
|
const LOCKED_PATTERN = /errSecInteractionNotAllowed|User interaction is not allowed/i;
|
|
7
8
|
const NOT_FOUND_PATTERN = /errSecItemNotFound|specified item could not be found/i;
|
|
8
|
-
const REDACTION_PATTERNS = [
|
|
9
|
-
{ pattern: /\{[^{}]*"claudeAiOauth"[\s\S]*?\}\s*\}/g, replacement: '[REDACTED credentials blob]' },
|
|
10
|
-
{ pattern: /sk-ant-[A-Za-z0-9_-]{20,}/g, replacement: '[REDACTED claude token]' },
|
|
11
|
-
{ pattern: /gh[psoru]_[A-Za-z0-9]{30,}/g, replacement: '[REDACTED github token]' },
|
|
12
|
-
{ pattern: /Bearer\s+[A-Za-z0-9._~+/=-]{20,}/gi, replacement: 'Bearer [REDACTED]' }
|
|
13
|
-
];
|
|
14
9
|
function isRecord(value) {
|
|
15
10
|
return typeof value === 'object' && value !== null && !Array.isArray(value);
|
|
16
11
|
}
|
|
@@ -20,13 +15,8 @@ function hasNonEmptyString(value) {
|
|
|
20
15
|
function errorMessage(error) {
|
|
21
16
|
return error instanceof Error ? error.message : 'unknown error';
|
|
22
17
|
}
|
|
23
|
-
export function redactCommandError(text) {
|
|
24
|
-
if (!text || typeof text !== 'string') {
|
|
25
|
-
return '';
|
|
26
|
-
}
|
|
27
|
-
return REDACTION_PATTERNS.reduce((result, { pattern, replacement }) => result.replace(pattern, replacement), text);
|
|
28
|
-
}
|
|
29
18
|
export const redactSecurityOutput = redactCommandError;
|
|
19
|
+
export { redactCommandError };
|
|
30
20
|
function extractStderrSafely(error) {
|
|
31
21
|
const stderr = typeof error === 'object' && error !== null && 'stderr' in error
|
|
32
22
|
? error.stderr
|
|
@@ -492,4 +482,4 @@ export function prepareClaudeCredentials(home, project, resolvedTools, extractFn
|
|
|
492
482
|
writeFn(home, project, blob);
|
|
493
483
|
return { status: 'OK' };
|
|
494
484
|
}
|
|
495
|
-
//# sourceMappingURL=credentials.js.map
|
|
485
|
+
//# sourceMappingURL=claude-code-credentials.js.map
|
|
@@ -0,0 +1,85 @@
|
|
|
1
|
+
import { homedir } from 'node:os';
|
|
2
|
+
import { parseArgs } from 'node:util';
|
|
3
|
+
import { buildLockedGuidance, discoverProjects, formatCredentialWarnings, formatRemaining, reconcileClaudeCredentials, redactCommandError, validateClaudeCredentialsEnvOverride } from './claude-code-credentials.js';
|
|
4
|
+
import { runProbe } from '../../sandbox/shell.js';
|
|
5
|
+
const USAGE = 'Usage: ai sandbox refresh';
|
|
6
|
+
export function probeClaudeStatus(spawnFn = runProbe) {
|
|
7
|
+
const result = spawnFn('claude', ['/status'], {
|
|
8
|
+
encoding: 'utf8',
|
|
9
|
+
stdio: ['ignore', 'pipe', 'pipe'],
|
|
10
|
+
timeout: 30_000
|
|
11
|
+
});
|
|
12
|
+
return {
|
|
13
|
+
ok: result.status === 0,
|
|
14
|
+
stderr: result.stderr?.toString() ?? '',
|
|
15
|
+
error: result.error?.message ?? null
|
|
16
|
+
};
|
|
17
|
+
}
|
|
18
|
+
export async function runClaudeCodeRefresh(args, deps = {}) {
|
|
19
|
+
const { spawnFn = runProbe, execFn, readFn, existsFn, writeFn, writeHostFn, discoverFn = discoverProjects, writeStdout = (chunk) => process.stdout.write(chunk), writeStderr = (chunk) => process.stderr.write(chunk) } = deps;
|
|
20
|
+
if (args[0] === '--help' || args[0] === '-h' || args[0] === 'help') {
|
|
21
|
+
writeStdout(`${USAGE}\n`);
|
|
22
|
+
return 0;
|
|
23
|
+
}
|
|
24
|
+
const { positionals } = parseArgs({ args, allowPositionals: true, strict: true });
|
|
25
|
+
if (positionals.length > 0) {
|
|
26
|
+
throw new Error(USAGE);
|
|
27
|
+
}
|
|
28
|
+
validateClaudeCredentialsEnvOverride();
|
|
29
|
+
const home = homedir();
|
|
30
|
+
if (!home) {
|
|
31
|
+
throw new Error('sandbox: home directory is required');
|
|
32
|
+
}
|
|
33
|
+
const projects = discoverFn(home);
|
|
34
|
+
if (projects.length === 0) {
|
|
35
|
+
writeStdout('No project credentials to refresh.\n');
|
|
36
|
+
return 0;
|
|
37
|
+
}
|
|
38
|
+
const reconcileOptions = { execFn, readFn, existsFn, writeFn, writeHostFn, projects };
|
|
39
|
+
let result = reconcileClaudeCredentials(home, reconcileOptions);
|
|
40
|
+
if (result.status === 'STALE_ACCESS' && result.authoritative === null) {
|
|
41
|
+
writeStdout('Host credentials appear stale; probing claude /status to trigger refresh...\n');
|
|
42
|
+
const probe = probeClaudeStatus(spawnFn);
|
|
43
|
+
if (!probe.ok) {
|
|
44
|
+
writeStderr(`Probe failed: ${redactCommandError(probe.stderr || probe.error || 'unknown error')}\n`);
|
|
45
|
+
writeStderr('Run "claude /login" on the host to renew credentials.\n');
|
|
46
|
+
return 1;
|
|
47
|
+
}
|
|
48
|
+
writeStdout('Probe succeeded; re-inspecting host credentials.\n');
|
|
49
|
+
result = reconcileClaudeCredentials(home, reconcileOptions);
|
|
50
|
+
}
|
|
51
|
+
if (result.status === 'MISSING') {
|
|
52
|
+
writeStderr('No Claude Code credentials found on host.\n');
|
|
53
|
+
writeStderr('Run "claude /login" on the host to authenticate.\n');
|
|
54
|
+
return 1;
|
|
55
|
+
}
|
|
56
|
+
if (result.status === 'KEYCHAIN_LOCKED') {
|
|
57
|
+
writeStderr(`${buildLockedGuidance()}\n`);
|
|
58
|
+
return 1;
|
|
59
|
+
}
|
|
60
|
+
if (result.status === 'KEYCHAIN_ERROR') {
|
|
61
|
+
writeStderr(`Host keychain error: ${redactCommandError(result.detail || 'unknown error')}\n`);
|
|
62
|
+
writeStderr(`${buildLockedGuidance()}\n`);
|
|
63
|
+
return 1;
|
|
64
|
+
}
|
|
65
|
+
if (result.status === 'KEYCHAIN_WRITE_FAILED') {
|
|
66
|
+
writeStderr(`[host] keychain write failed: ${formatCredentialWarnings(result.warnings) || 'unknown error'}\n`);
|
|
67
|
+
return 1;
|
|
68
|
+
}
|
|
69
|
+
if (result.status !== 'OK') {
|
|
70
|
+
writeStderr('Host credentials still invalid after probe; run "claude /login".\n');
|
|
71
|
+
return 1;
|
|
72
|
+
}
|
|
73
|
+
if (result.authoritative && result.authoritative !== 'host' && result.hostWritten) {
|
|
74
|
+
writeStdout(`[host] reconciled from ${result.authoritative}\n`);
|
|
75
|
+
}
|
|
76
|
+
for (const project of projects) {
|
|
77
|
+
const action = result.filesWritten.includes(project) ? 'updated' : 'unchanged';
|
|
78
|
+
writeStdout(`[${project}] ${action}; expires in ${formatRemaining(result.expiresAt)}\n`);
|
|
79
|
+
}
|
|
80
|
+
for (const failure of result.fileErrors) {
|
|
81
|
+
writeStderr(`[${failure.project}] sync failed: ${failure.error}\n`);
|
|
82
|
+
}
|
|
83
|
+
return result.fileErrors.length > 0 ? 1 : 0;
|
|
84
|
+
}
|
|
85
|
+
//# sourceMappingURL=claude-code-refresh.js.map
|
|
@@ -0,0 +1,247 @@
|
|
|
1
|
+
import fs from 'node:fs';
|
|
2
|
+
import path from 'node:path';
|
|
3
|
+
import { formatCredentialWarnings, formatRemaining, hasClaudeProviderAuth, inspectClaudeKeychainStatus, prepareClaudeCredentials, reconcileClaudeCredentials, redactCommandError, validateClaudeCredentialsEnvOverride } from './claude-code-credentials.js';
|
|
4
|
+
function readHostJsonSafe(filePath) {
|
|
5
|
+
if (!filePath || !fs.existsSync(filePath))
|
|
6
|
+
return null;
|
|
7
|
+
try {
|
|
8
|
+
const parsed = JSON.parse(fs.readFileSync(filePath, 'utf8'));
|
|
9
|
+
return parsed && typeof parsed === 'object' && !Array.isArray(parsed)
|
|
10
|
+
? parsed
|
|
11
|
+
: null;
|
|
12
|
+
}
|
|
13
|
+
catch {
|
|
14
|
+
return null;
|
|
15
|
+
}
|
|
16
|
+
}
|
|
17
|
+
const CLAUDE_SETTINGS_INHERIT_TOP_LEVEL_KEYS = [
|
|
18
|
+
'model',
|
|
19
|
+
'fallbackModel',
|
|
20
|
+
'availableModels',
|
|
21
|
+
'modelOverrides',
|
|
22
|
+
'enforceAvailableModels',
|
|
23
|
+
'advisorModel',
|
|
24
|
+
'apiKeyHelper',
|
|
25
|
+
'effortLevel'
|
|
26
|
+
];
|
|
27
|
+
function isJsonObjectRecord(value) {
|
|
28
|
+
return value !== null && typeof value === 'object' && !Array.isArray(value);
|
|
29
|
+
}
|
|
30
|
+
function mergeMissingStringEnvFields(target, source) {
|
|
31
|
+
if (!isJsonObjectRecord(source.env))
|
|
32
|
+
return false;
|
|
33
|
+
if (Object.hasOwn(target, 'env') && !isJsonObjectRecord(target.env))
|
|
34
|
+
return false;
|
|
35
|
+
let targetEnv = target.env;
|
|
36
|
+
let changed = false;
|
|
37
|
+
for (const [key, value] of Object.entries(source.env)) {
|
|
38
|
+
if (typeof value !== 'string' || value === '')
|
|
39
|
+
continue;
|
|
40
|
+
if (!targetEnv) {
|
|
41
|
+
targetEnv = {};
|
|
42
|
+
target.env = targetEnv;
|
|
43
|
+
}
|
|
44
|
+
if (!Object.hasOwn(targetEnv, key)) {
|
|
45
|
+
targetEnv[key] = value;
|
|
46
|
+
changed = true;
|
|
47
|
+
}
|
|
48
|
+
}
|
|
49
|
+
return changed;
|
|
50
|
+
}
|
|
51
|
+
function mergeMissingTopLevelSettings(target, source) {
|
|
52
|
+
let changed = false;
|
|
53
|
+
for (const key of CLAUDE_SETTINGS_INHERIT_TOP_LEVEL_KEYS) {
|
|
54
|
+
if (!Object.hasOwn(source, key) || Object.hasOwn(target, key))
|
|
55
|
+
continue;
|
|
56
|
+
const value = source[key];
|
|
57
|
+
if (value === null || value === undefined || value === '')
|
|
58
|
+
continue;
|
|
59
|
+
target[key] = value;
|
|
60
|
+
changed = true;
|
|
61
|
+
}
|
|
62
|
+
return changed;
|
|
63
|
+
}
|
|
64
|
+
function requireCreateContext(context, hookId) {
|
|
65
|
+
if (!context)
|
|
66
|
+
throw new Error(`${hookId} requires create context`);
|
|
67
|
+
return context;
|
|
68
|
+
}
|
|
69
|
+
function requireEnterContext(context, hookId) {
|
|
70
|
+
if (!context)
|
|
71
|
+
throw new Error(`${hookId} requires enter context`);
|
|
72
|
+
return context;
|
|
73
|
+
}
|
|
74
|
+
export function ensureClaudeOnboarding(toolDir, hostHomeDir) {
|
|
75
|
+
const claudeJsonPath = path.join(toolDir, '.claude.json');
|
|
76
|
+
let data = {};
|
|
77
|
+
if (fs.existsSync(claudeJsonPath)) {
|
|
78
|
+
try {
|
|
79
|
+
data = JSON.parse(fs.readFileSync(claudeJsonPath, 'utf8'));
|
|
80
|
+
}
|
|
81
|
+
catch {
|
|
82
|
+
// Malformed JSON is replaced with a valid managed sandbox baseline.
|
|
83
|
+
}
|
|
84
|
+
}
|
|
85
|
+
let changed = false;
|
|
86
|
+
if (!data.hasCompletedOnboarding) {
|
|
87
|
+
data.hasCompletedOnboarding = true;
|
|
88
|
+
changed = true;
|
|
89
|
+
}
|
|
90
|
+
if (!data.projects) {
|
|
91
|
+
data.projects = {};
|
|
92
|
+
changed = true;
|
|
93
|
+
}
|
|
94
|
+
if (!data.projects['/workspace']) {
|
|
95
|
+
data.projects['/workspace'] = {};
|
|
96
|
+
changed = true;
|
|
97
|
+
}
|
|
98
|
+
if (!data.projects['/workspace'].hasTrustDialogAccepted) {
|
|
99
|
+
data.projects['/workspace'].hasTrustDialogAccepted = true;
|
|
100
|
+
changed = true;
|
|
101
|
+
}
|
|
102
|
+
if (hostHomeDir) {
|
|
103
|
+
const hostClaudeJson = readHostJsonSafe(path.join(hostHomeDir, '.claude.json'));
|
|
104
|
+
if (hostClaudeJson
|
|
105
|
+
&& typeof hostClaudeJson.model === 'string'
|
|
106
|
+
&& hostClaudeJson.model !== ''
|
|
107
|
+
&& !Object.hasOwn(data, 'model')) {
|
|
108
|
+
data.model = hostClaudeJson.model;
|
|
109
|
+
changed = true;
|
|
110
|
+
}
|
|
111
|
+
if (hostClaudeJson) {
|
|
112
|
+
for (const key of Object.keys(hostClaudeJson)) {
|
|
113
|
+
if (/^unpin.*LaunchEffort$/.test(key)
|
|
114
|
+
&& hostClaudeJson[key] === true
|
|
115
|
+
&& !Object.hasOwn(data, key)) {
|
|
116
|
+
data[key] = true;
|
|
117
|
+
changed = true;
|
|
118
|
+
}
|
|
119
|
+
}
|
|
120
|
+
}
|
|
121
|
+
}
|
|
122
|
+
if (changed)
|
|
123
|
+
fs.writeFileSync(claudeJsonPath, JSON.stringify(data, null, 4), 'utf8');
|
|
124
|
+
}
|
|
125
|
+
export function ensureClaudeSettings(toolDir, hostHomeDir) {
|
|
126
|
+
const settingsPath = path.join(toolDir, 'settings.json');
|
|
127
|
+
let data = {};
|
|
128
|
+
if (fs.existsSync(settingsPath)) {
|
|
129
|
+
try {
|
|
130
|
+
data = JSON.parse(fs.readFileSync(settingsPath, 'utf8'));
|
|
131
|
+
}
|
|
132
|
+
catch {
|
|
133
|
+
// Malformed JSON is replaced with a valid managed sandbox baseline.
|
|
134
|
+
}
|
|
135
|
+
}
|
|
136
|
+
let changed = false;
|
|
137
|
+
if (data.skipDangerousModePermissionPrompt !== true) {
|
|
138
|
+
data.skipDangerousModePermissionPrompt = true;
|
|
139
|
+
changed = true;
|
|
140
|
+
}
|
|
141
|
+
if (hostHomeDir) {
|
|
142
|
+
const hostSettings = readHostJsonSafe(path.join(hostHomeDir, '.claude', 'settings.json'));
|
|
143
|
+
if (hostSettings) {
|
|
144
|
+
changed = mergeMissingStringEnvFields(data, hostSettings) || changed;
|
|
145
|
+
changed = mergeMissingTopLevelSettings(data, hostSettings) || changed;
|
|
146
|
+
}
|
|
147
|
+
}
|
|
148
|
+
if (changed)
|
|
149
|
+
fs.writeFileSync(settingsPath, JSON.stringify(data, null, 4), 'utf8');
|
|
150
|
+
}
|
|
151
|
+
export function formatCredentialSyncStatus(result, isTTY = process.stderr.isTTY, providerAuthAvailable = false) {
|
|
152
|
+
if (providerAuthAvailable && (result.status === 'STALE_ACCESS' || result.status === 'MISSING'))
|
|
153
|
+
return null;
|
|
154
|
+
if (result.status === 'STALE_ACCESS') {
|
|
155
|
+
return 'Warning: Claude Code credentials on host appear stale. Run "ai sandbox refresh" or "claude /login" to renew.\n';
|
|
156
|
+
}
|
|
157
|
+
if (result.status === 'MISSING') {
|
|
158
|
+
return 'Warning: Claude Code credentials missing on host. Run "claude /login" to authenticate.\n';
|
|
159
|
+
}
|
|
160
|
+
if (result.status === 'KEYCHAIN_WRITE_FAILED') {
|
|
161
|
+
return `Warning: A sandbox refresh produced newer credentials but host Keychain write failed (${formatCredentialWarnings(result.warnings)}). Run "ai sandbox refresh" again or "claude /status" on the host to retry.\n`;
|
|
162
|
+
}
|
|
163
|
+
if (result.status === 'KEYCHAIN_LOCKED' || result.status === 'KEYCHAIN_ERROR') {
|
|
164
|
+
return 'Warning: Host keychain is unavailable; Claude credential sync skipped. Run "ai sandbox refresh" for details.\n';
|
|
165
|
+
}
|
|
166
|
+
if (result.status === 'OK' && result.authoritative !== 'host') {
|
|
167
|
+
const message = `Synced Claude Code credentials from sandbox refresh back to host (expires in ${formatRemaining(result.expiresAt)})`;
|
|
168
|
+
return isTTY ? `\x1b[2m${message}\x1b[0m\n` : `${message}\n`;
|
|
169
|
+
}
|
|
170
|
+
if (result.status === 'OK' && result.filesWritten.length > 0) {
|
|
171
|
+
const message = `Synced Claude Code credentials from host Keychain (expires in ${formatRemaining(result.expiresAt)})`;
|
|
172
|
+
return isTTY ? `\x1b[2m${message}\x1b[0m\n` : `${message}\n`;
|
|
173
|
+
}
|
|
174
|
+
return null;
|
|
175
|
+
}
|
|
176
|
+
const claudeCodeCredentialPreflightHook = {
|
|
177
|
+
id: 'claude-code-credential-preflight',
|
|
178
|
+
phase: 'prepare',
|
|
179
|
+
run: async ({ create }) => {
|
|
180
|
+
const { hostHome, hostEnv, project, resolvedTools } = requireCreateContext(create, 'claude-code-credential-preflight');
|
|
181
|
+
try {
|
|
182
|
+
validateClaudeCredentialsEnvOverride(hostEnv);
|
|
183
|
+
const outcome = prepareClaudeCredentials(hostHome, project, [...resolvedTools], undefined, undefined, (home) => inspectClaudeKeychainStatus(home, undefined, { envFn: () => ({ ...hostEnv }) }));
|
|
184
|
+
if (outcome.status === 'SKIPPED') {
|
|
185
|
+
return {
|
|
186
|
+
status: 'warning',
|
|
187
|
+
message: 'Claude Code credentials not found on host - creating this sandbox WITHOUT Claude Code credentials.\n'
|
|
188
|
+
+ ' Claude Code is still installed in the image but will not be authenticated.\n'
|
|
189
|
+
+ ' To enable it: run "claude" once on the host to complete login, then re-run "ai sandbox create".'
|
|
190
|
+
};
|
|
191
|
+
}
|
|
192
|
+
return { status: 'ready' };
|
|
193
|
+
}
|
|
194
|
+
catch (error) {
|
|
195
|
+
return {
|
|
196
|
+
status: 'fatal',
|
|
197
|
+
message: redactCommandError(error instanceof Error ? error.message : 'unknown credential error')
|
|
198
|
+
};
|
|
199
|
+
}
|
|
200
|
+
}
|
|
201
|
+
};
|
|
202
|
+
const claudeCodeBeforeContainerCreateHook = {
|
|
203
|
+
id: 'claude-code-before-container-create',
|
|
204
|
+
phase: 'before-container-create',
|
|
205
|
+
run: async ({ create }) => {
|
|
206
|
+
const { hostHome, resolvedTools } = requireCreateContext(create, 'claude-code-before-container-create');
|
|
207
|
+
const claudeCodeEntry = resolvedTools.find(({ tool }) => tool.id === 'claude-code');
|
|
208
|
+
if (claudeCodeEntry) {
|
|
209
|
+
ensureClaudeOnboarding(claudeCodeEntry.dir, hostHome);
|
|
210
|
+
ensureClaudeSettings(claudeCodeEntry.dir, hostHome);
|
|
211
|
+
}
|
|
212
|
+
return { status: 'ready' };
|
|
213
|
+
}
|
|
214
|
+
};
|
|
215
|
+
const claudeCodeBeforeEnterHook = {
|
|
216
|
+
id: 'claude-code-before-enter',
|
|
217
|
+
phase: 'before-enter',
|
|
218
|
+
run: async ({ enter }) => {
|
|
219
|
+
const { hostHome, hostEnv } = requireEnterContext(enter, 'claude-code-before-enter');
|
|
220
|
+
try {
|
|
221
|
+
validateClaudeCredentialsEnvOverride(hostEnv);
|
|
222
|
+
}
|
|
223
|
+
catch (error) {
|
|
224
|
+
return {
|
|
225
|
+
status: 'fatal',
|
|
226
|
+
message: redactCommandError(error instanceof Error ? error.message : 'invalid credentials override')
|
|
227
|
+
};
|
|
228
|
+
}
|
|
229
|
+
try {
|
|
230
|
+
const providerAuthAvailable = hasClaudeProviderAuth(hostHome);
|
|
231
|
+
const result = reconcileClaudeCredentials(hostHome, { envFn: () => ({ ...hostEnv }) });
|
|
232
|
+
const message = formatCredentialSyncStatus(result, process.stderr.isTTY, providerAuthAvailable);
|
|
233
|
+
return {
|
|
234
|
+
status: 'ready',
|
|
235
|
+
...(message === null ? {} : { message })
|
|
236
|
+
};
|
|
237
|
+
}
|
|
238
|
+
catch (error) {
|
|
239
|
+
return {
|
|
240
|
+
status: 'warning',
|
|
241
|
+
message: `Failed to sync Claude Code credentials: ${redactCommandError(error instanceof Error ? error.message : 'unknown error')}`
|
|
242
|
+
};
|
|
243
|
+
}
|
|
244
|
+
}
|
|
245
|
+
};
|
|
246
|
+
export { claudeCodeBeforeContainerCreateHook, claudeCodeBeforeEnterHook, claudeCodeCredentialPreflightHook };
|
|
247
|
+
//# sourceMappingURL=claude-code-sandbox.js.map
|
|
@@ -1,5 +1,6 @@
|
|
|
1
1
|
import { defineAgentClientAdapter } from '../adapter.js';
|
|
2
2
|
import { hostJoin } from '../../sandbox/engines/wsl2-paths.js';
|
|
3
|
+
import { claudeCodeBeforeContainerCreateHook, claudeCodeBeforeEnterHook, claudeCodeCredentialPreflightHook } from './claude-code-sandbox.js';
|
|
3
4
|
const claudeCodeAdapter = defineAgentClientAdapter({
|
|
4
5
|
id: 'claude-code',
|
|
5
6
|
displayName: 'Claude Code',
|
|
@@ -10,13 +11,22 @@ const claudeCodeAdapter = defineAgentClientAdapter({
|
|
|
10
11
|
commands: { level: 'integrated' },
|
|
11
12
|
hooks: { level: 'integrated' },
|
|
12
13
|
subagents: { level: 'experimental' },
|
|
13
|
-
orchestration: { level: '
|
|
14
|
+
orchestration: { level: 'unsupported' },
|
|
14
15
|
sandbox: { level: 'integrated' },
|
|
15
16
|
verification: { level: 'compatible' }
|
|
16
17
|
},
|
|
18
|
+
modelSelection: {
|
|
19
|
+
kind: 'interactive-only',
|
|
20
|
+
command: '/model',
|
|
21
|
+
guidance: 'Use the host model picker for the complete model and reasoning-effort catalog.'
|
|
22
|
+
},
|
|
23
|
+
delegationEvidence: {
|
|
24
|
+
actualModel: 'unavailable',
|
|
25
|
+
actualReasoningEffort: 'unavailable'
|
|
26
|
+
},
|
|
17
27
|
project: {
|
|
18
28
|
ownedPathPrefixes: ['.claude/'],
|
|
19
|
-
managed: ['.claude/commands/', '.claude/agents/'],
|
|
29
|
+
managed: ['.claude/commands/', '.claude/agents/', '.claude/rules/'],
|
|
20
30
|
merged: ['.claude/settings.json'],
|
|
21
31
|
ejected: [],
|
|
22
32
|
seedCommands: [{
|
|
@@ -25,9 +35,18 @@ const claudeCodeAdapter = defineAgentClientAdapter({
|
|
|
25
35
|
'zh-CN': '.claude/commands/update-agent-infra.zh-CN.md'
|
|
26
36
|
},
|
|
27
37
|
target: '.claude/commands/update-agent-infra.md'
|
|
28
|
-
}]
|
|
38
|
+
}],
|
|
39
|
+
customCommand: {
|
|
40
|
+
target: '.claude/commands/${skillName}.md',
|
|
41
|
+
frontmatter: {},
|
|
42
|
+
includeUsage: true,
|
|
43
|
+
inheritDisableModelInvocation: true
|
|
44
|
+
}
|
|
29
45
|
},
|
|
30
46
|
sandbox: {
|
|
47
|
+
image: {
|
|
48
|
+
dockerfileFragment: 'claude-code'
|
|
49
|
+
},
|
|
31
50
|
createTool: ({ home, project }) => ({
|
|
32
51
|
id: 'claude-code',
|
|
33
52
|
name: 'Claude Code',
|
|
@@ -55,7 +74,11 @@ const claudeCodeAdapter = defineAgentClientAdapter({
|
|
|
55
74
|
{ name: 'claude-yolo', command: 'claude --dangerously-skip-permissions; tput ed' },
|
|
56
75
|
{ name: 'cy', command: 'claude --dangerously-skip-permissions; tput ed' }
|
|
57
76
|
],
|
|
58
|
-
hooks: [
|
|
77
|
+
hooks: [
|
|
78
|
+
claudeCodeCredentialPreflightHook,
|
|
79
|
+
claudeCodeBeforeContainerCreateHook,
|
|
80
|
+
claudeCodeBeforeEnterHook
|
|
81
|
+
]
|
|
59
82
|
}
|
|
60
83
|
});
|
|
61
84
|
export { claudeCodeAdapter };
|
|
@@ -15,6 +15,15 @@ const codexAdapter = defineAgentClientAdapter({
|
|
|
15
15
|
sandbox: { level: 'integrated' },
|
|
16
16
|
verification: { level: 'compatible' }
|
|
17
17
|
},
|
|
18
|
+
modelSelection: {
|
|
19
|
+
kind: 'interactive-only',
|
|
20
|
+
command: '/model',
|
|
21
|
+
guidance: 'Use the host model picker for the complete model and reasoning-effort catalog.'
|
|
22
|
+
},
|
|
23
|
+
delegationEvidence: {
|
|
24
|
+
actualModel: 'unavailable',
|
|
25
|
+
actualReasoningEffort: 'unavailable'
|
|
26
|
+
},
|
|
18
27
|
project: {
|
|
19
28
|
ownedPathPrefixes: ['.codex/'],
|
|
20
29
|
managed: ['.codex/hooks.json', '.codex/agents/'],
|
|
@@ -1,12 +1,12 @@
|
|
|
1
1
|
import { AGENT_CLIENT_IDS } from '../types.js';
|
|
2
2
|
import { claudeCodeAdapter } from './claude-code.js';
|
|
3
3
|
import { codexAdapter } from './codex.js';
|
|
4
|
-
import {
|
|
4
|
+
import { antigravityCliAdapter } from './antigravity-cli.js';
|
|
5
5
|
import { opencodeAdapter } from './opencode.js';
|
|
6
6
|
const adaptersById = new Map([
|
|
7
7
|
claudeCodeAdapter,
|
|
8
8
|
codexAdapter,
|
|
9
|
-
|
|
9
|
+
antigravityCliAdapter,
|
|
10
10
|
opencodeAdapter
|
|
11
11
|
].map((adapter) => [adapter.id, adapter]));
|
|
12
12
|
const BUILTIN_AGENT_CLIENT_ADAPTERS = Object.freeze(AGENT_CLIENT_IDS.map((id) => {
|
|
@@ -0,0 +1,108 @@
|
|
|
1
|
+
import fs from 'node:fs';
|
|
2
|
+
import path from 'node:path';
|
|
3
|
+
function readJsonObject(filePath) {
|
|
4
|
+
try {
|
|
5
|
+
const parsed = JSON.parse(fs.readFileSync(filePath, 'utf8'));
|
|
6
|
+
return parsed !== null && typeof parsed === 'object' && !Array.isArray(parsed)
|
|
7
|
+
? parsed
|
|
8
|
+
: null;
|
|
9
|
+
}
|
|
10
|
+
catch {
|
|
11
|
+
return null;
|
|
12
|
+
}
|
|
13
|
+
}
|
|
14
|
+
function resolveXdgRoot(value, fallback) {
|
|
15
|
+
return typeof value === 'string' && value !== '' && path.isAbsolute(value)
|
|
16
|
+
? value
|
|
17
|
+
: fallback;
|
|
18
|
+
}
|
|
19
|
+
function ensureOpenCodeSandboxState(toolDir, hostHome, hostEnv = {}) {
|
|
20
|
+
const canonicalConfigDir = path.join(toolDir, '.xdg', 'config', 'opencode');
|
|
21
|
+
const canonicalStateDir = path.join(toolDir, '.xdg', 'state', 'opencode');
|
|
22
|
+
const canonicalConfigPath = path.join(canonicalConfigDir, 'opencode.json');
|
|
23
|
+
const legacyConfigPath = path.join(toolDir, 'opencode.json');
|
|
24
|
+
fs.mkdirSync(canonicalConfigDir, { recursive: true });
|
|
25
|
+
fs.mkdirSync(canonicalStateDir, { recursive: true });
|
|
26
|
+
if (!fs.existsSync(canonicalConfigPath) && fs.existsSync(legacyConfigPath)) {
|
|
27
|
+
fs.copyFileSync(legacyConfigPath, canonicalConfigPath, fs.constants.COPYFILE_EXCL);
|
|
28
|
+
}
|
|
29
|
+
const hostConfigRoot = resolveXdgRoot(hostEnv.XDG_CONFIG_HOME, path.join(hostHome, '.config'));
|
|
30
|
+
const hostConfig = readJsonObject(path.join(hostConfigRoot, 'opencode', 'opencode.json'));
|
|
31
|
+
if (!hostConfig) {
|
|
32
|
+
return;
|
|
33
|
+
}
|
|
34
|
+
let sandboxConfig = {};
|
|
35
|
+
if (fs.existsSync(canonicalConfigPath)) {
|
|
36
|
+
const existing = readJsonObject(canonicalConfigPath);
|
|
37
|
+
if (!existing) {
|
|
38
|
+
return;
|
|
39
|
+
}
|
|
40
|
+
sandboxConfig = existing;
|
|
41
|
+
}
|
|
42
|
+
let changed = false;
|
|
43
|
+
for (const key of ['model', 'small_model']) {
|
|
44
|
+
if (Object.hasOwn(sandboxConfig, key)) {
|
|
45
|
+
continue;
|
|
46
|
+
}
|
|
47
|
+
const value = hostConfig[key];
|
|
48
|
+
if (typeof value === 'string' && value !== '') {
|
|
49
|
+
sandboxConfig[key] = value;
|
|
50
|
+
changed = true;
|
|
51
|
+
}
|
|
52
|
+
}
|
|
53
|
+
if (changed) {
|
|
54
|
+
fs.writeFileSync(canonicalConfigPath, JSON.stringify(sandboxConfig, null, 2), 'utf8');
|
|
55
|
+
}
|
|
56
|
+
}
|
|
57
|
+
const opencodeBeforeContainerCreateHook = {
|
|
58
|
+
id: 'opencode-before-container-create',
|
|
59
|
+
phase: 'before-container-create',
|
|
60
|
+
async run(context) {
|
|
61
|
+
const create = context.create;
|
|
62
|
+
const entry = create?.resolvedTools.find(({ tool }) => tool.id === 'opencode');
|
|
63
|
+
if (!create || !entry) {
|
|
64
|
+
return {
|
|
65
|
+
status: 'fatal',
|
|
66
|
+
message: 'OpenCode sandbox hook requires its resolved tool state.'
|
|
67
|
+
};
|
|
68
|
+
}
|
|
69
|
+
ensureOpenCodeSandboxState(entry.dir, create.hostHome, create.hostEnv);
|
|
70
|
+
return { status: 'ready' };
|
|
71
|
+
}
|
|
72
|
+
};
|
|
73
|
+
const opencodeRecoveryChecks = [
|
|
74
|
+
{
|
|
75
|
+
id: 'command-available',
|
|
76
|
+
probe: { script: 'command -v "$1"', args: ['opencode'] },
|
|
77
|
+
finding: {
|
|
78
|
+
repairKind: 'hard-failure',
|
|
79
|
+
message: 'OpenCode is not available on PATH inside the sandbox.'
|
|
80
|
+
}
|
|
81
|
+
},
|
|
82
|
+
{
|
|
83
|
+
id: 'config-writable',
|
|
84
|
+
probe: {
|
|
85
|
+
script: 'probe="$1/.agent-infra-opencode-config-$$"; trap \'rm -f -- "$probe"\' EXIT; : > "$probe"',
|
|
86
|
+
args: ['/home/devuser/.local/share/opencode/.xdg/config/opencode']
|
|
87
|
+
},
|
|
88
|
+
finding: {
|
|
89
|
+
repairKind: 'permissions',
|
|
90
|
+
message: 'OpenCode config directory is not writable by devuser.',
|
|
91
|
+
path: '/home/devuser/.local/share/opencode/.xdg/config/opencode'
|
|
92
|
+
}
|
|
93
|
+
},
|
|
94
|
+
{
|
|
95
|
+
id: 'state-writable',
|
|
96
|
+
probe: {
|
|
97
|
+
script: 'probe="$1/.agent-infra-opencode-state-$$"; trap \'rm -f -- "$probe"\' EXIT; : > "$probe"',
|
|
98
|
+
args: ['/home/devuser/.local/share/opencode/.xdg/state/opencode']
|
|
99
|
+
},
|
|
100
|
+
finding: {
|
|
101
|
+
repairKind: 'permissions',
|
|
102
|
+
message: 'OpenCode state directory is not writable by devuser.',
|
|
103
|
+
path: '/home/devuser/.local/share/opencode/.xdg/state/opencode'
|
|
104
|
+
}
|
|
105
|
+
}
|
|
106
|
+
];
|
|
107
|
+
export { ensureOpenCodeSandboxState, opencodeBeforeContainerCreateHook, opencodeRecoveryChecks };
|
|
108
|
+
//# sourceMappingURL=opencode-sandbox.js.map
|