@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,295 @@
|
|
|
1
|
+
import fs from 'node:fs';
|
|
2
|
+
import path from 'node:path';
|
|
3
|
+
import type {
|
|
4
|
+
AgentClientSandboxHook,
|
|
5
|
+
SandboxHookCreateContext,
|
|
6
|
+
SandboxHookEnterContext
|
|
7
|
+
} from '../../sandbox/tool-types.ts';
|
|
8
|
+
import {
|
|
9
|
+
formatCredentialWarnings,
|
|
10
|
+
formatRemaining,
|
|
11
|
+
hasClaudeProviderAuth,
|
|
12
|
+
inspectClaudeKeychainStatus,
|
|
13
|
+
prepareClaudeCredentials,
|
|
14
|
+
reconcileClaudeCredentials,
|
|
15
|
+
redactCommandError,
|
|
16
|
+
validateClaudeCredentialsEnvOverride
|
|
17
|
+
} from './claude-code-credentials.ts';
|
|
18
|
+
|
|
19
|
+
type JsonObject = Record<string, unknown>;
|
|
20
|
+
|
|
21
|
+
function readHostJsonSafe(filePath: string): JsonObject | null {
|
|
22
|
+
if (!filePath || !fs.existsSync(filePath)) return null;
|
|
23
|
+
try {
|
|
24
|
+
const parsed = JSON.parse(fs.readFileSync(filePath, 'utf8')) as unknown;
|
|
25
|
+
return parsed && typeof parsed === 'object' && !Array.isArray(parsed)
|
|
26
|
+
? parsed as JsonObject
|
|
27
|
+
: null;
|
|
28
|
+
} catch {
|
|
29
|
+
return null;
|
|
30
|
+
}
|
|
31
|
+
}
|
|
32
|
+
|
|
33
|
+
const CLAUDE_SETTINGS_INHERIT_TOP_LEVEL_KEYS = [
|
|
34
|
+
'model',
|
|
35
|
+
'fallbackModel',
|
|
36
|
+
'availableModels',
|
|
37
|
+
'modelOverrides',
|
|
38
|
+
'enforceAvailableModels',
|
|
39
|
+
'advisorModel',
|
|
40
|
+
'apiKeyHelper',
|
|
41
|
+
'effortLevel'
|
|
42
|
+
];
|
|
43
|
+
|
|
44
|
+
function isJsonObjectRecord(value: unknown): value is JsonObject {
|
|
45
|
+
return value !== null && typeof value === 'object' && !Array.isArray(value);
|
|
46
|
+
}
|
|
47
|
+
|
|
48
|
+
function mergeMissingStringEnvFields(target: JsonObject, source: JsonObject): boolean {
|
|
49
|
+
if (!isJsonObjectRecord(source.env)) return false;
|
|
50
|
+
if (Object.hasOwn(target, 'env') && !isJsonObjectRecord(target.env)) return false;
|
|
51
|
+
|
|
52
|
+
let targetEnv = target.env as JsonObject | undefined;
|
|
53
|
+
let changed = false;
|
|
54
|
+
for (const [key, value] of Object.entries(source.env)) {
|
|
55
|
+
if (typeof value !== 'string' || value === '') continue;
|
|
56
|
+
if (!targetEnv) {
|
|
57
|
+
targetEnv = {};
|
|
58
|
+
target.env = targetEnv;
|
|
59
|
+
}
|
|
60
|
+
if (!Object.hasOwn(targetEnv, key)) {
|
|
61
|
+
targetEnv[key] = value;
|
|
62
|
+
changed = true;
|
|
63
|
+
}
|
|
64
|
+
}
|
|
65
|
+
return changed;
|
|
66
|
+
}
|
|
67
|
+
|
|
68
|
+
function mergeMissingTopLevelSettings(target: JsonObject, source: JsonObject): boolean {
|
|
69
|
+
let changed = false;
|
|
70
|
+
for (const key of CLAUDE_SETTINGS_INHERIT_TOP_LEVEL_KEYS) {
|
|
71
|
+
if (!Object.hasOwn(source, key) || Object.hasOwn(target, key)) continue;
|
|
72
|
+
const value = source[key];
|
|
73
|
+
if (value === null || value === undefined || value === '') continue;
|
|
74
|
+
target[key] = value;
|
|
75
|
+
changed = true;
|
|
76
|
+
}
|
|
77
|
+
return changed;
|
|
78
|
+
}
|
|
79
|
+
|
|
80
|
+
function requireCreateContext(
|
|
81
|
+
context: SandboxHookCreateContext | undefined,
|
|
82
|
+
hookId: string
|
|
83
|
+
): SandboxHookCreateContext {
|
|
84
|
+
if (!context) throw new Error(`${hookId} requires create context`);
|
|
85
|
+
return context;
|
|
86
|
+
}
|
|
87
|
+
|
|
88
|
+
function requireEnterContext(
|
|
89
|
+
context: SandboxHookEnterContext | undefined,
|
|
90
|
+
hookId: string
|
|
91
|
+
): SandboxHookEnterContext {
|
|
92
|
+
if (!context) throw new Error(`${hookId} requires enter context`);
|
|
93
|
+
return context;
|
|
94
|
+
}
|
|
95
|
+
|
|
96
|
+
export function ensureClaudeOnboarding(toolDir: string, hostHomeDir?: string): void {
|
|
97
|
+
const claudeJsonPath = path.join(toolDir, '.claude.json');
|
|
98
|
+
let data: JsonObject & {
|
|
99
|
+
hasCompletedOnboarding?: boolean;
|
|
100
|
+
projects?: Record<string, { hasTrustDialogAccepted?: boolean }>;
|
|
101
|
+
model?: string;
|
|
102
|
+
} = {};
|
|
103
|
+
if (fs.existsSync(claudeJsonPath)) {
|
|
104
|
+
try {
|
|
105
|
+
data = JSON.parse(fs.readFileSync(claudeJsonPath, 'utf8')) as typeof data;
|
|
106
|
+
} catch {
|
|
107
|
+
// Malformed JSON is replaced with a valid managed sandbox baseline.
|
|
108
|
+
}
|
|
109
|
+
}
|
|
110
|
+
let changed = false;
|
|
111
|
+
if (!data.hasCompletedOnboarding) {
|
|
112
|
+
data.hasCompletedOnboarding = true;
|
|
113
|
+
changed = true;
|
|
114
|
+
}
|
|
115
|
+
if (!data.projects) {
|
|
116
|
+
data.projects = {};
|
|
117
|
+
changed = true;
|
|
118
|
+
}
|
|
119
|
+
if (!data.projects['/workspace']) {
|
|
120
|
+
data.projects['/workspace'] = {};
|
|
121
|
+
changed = true;
|
|
122
|
+
}
|
|
123
|
+
if (!data.projects['/workspace'].hasTrustDialogAccepted) {
|
|
124
|
+
data.projects['/workspace'].hasTrustDialogAccepted = true;
|
|
125
|
+
changed = true;
|
|
126
|
+
}
|
|
127
|
+
if (hostHomeDir) {
|
|
128
|
+
const hostClaudeJson = readHostJsonSafe(path.join(hostHomeDir, '.claude.json'));
|
|
129
|
+
if (
|
|
130
|
+
hostClaudeJson
|
|
131
|
+
&& typeof hostClaudeJson.model === 'string'
|
|
132
|
+
&& hostClaudeJson.model !== ''
|
|
133
|
+
&& !Object.hasOwn(data, 'model')
|
|
134
|
+
) {
|
|
135
|
+
data.model = hostClaudeJson.model;
|
|
136
|
+
changed = true;
|
|
137
|
+
}
|
|
138
|
+
if (hostClaudeJson) {
|
|
139
|
+
for (const key of Object.keys(hostClaudeJson)) {
|
|
140
|
+
if (
|
|
141
|
+
/^unpin.*LaunchEffort$/.test(key)
|
|
142
|
+
&& hostClaudeJson[key] === true
|
|
143
|
+
&& !Object.hasOwn(data, key)
|
|
144
|
+
) {
|
|
145
|
+
data[key] = true;
|
|
146
|
+
changed = true;
|
|
147
|
+
}
|
|
148
|
+
}
|
|
149
|
+
}
|
|
150
|
+
}
|
|
151
|
+
if (changed) fs.writeFileSync(claudeJsonPath, JSON.stringify(data, null, 4), 'utf8');
|
|
152
|
+
}
|
|
153
|
+
|
|
154
|
+
export function ensureClaudeSettings(toolDir: string, hostHomeDir?: string): void {
|
|
155
|
+
const settingsPath = path.join(toolDir, 'settings.json');
|
|
156
|
+
let data: JsonObject & { skipDangerousModePermissionPrompt?: boolean } = {};
|
|
157
|
+
if (fs.existsSync(settingsPath)) {
|
|
158
|
+
try {
|
|
159
|
+
data = JSON.parse(fs.readFileSync(settingsPath, 'utf8')) as typeof data;
|
|
160
|
+
} catch {
|
|
161
|
+
// Malformed JSON is replaced with a valid managed sandbox baseline.
|
|
162
|
+
}
|
|
163
|
+
}
|
|
164
|
+
let changed = false;
|
|
165
|
+
if (data.skipDangerousModePermissionPrompt !== true) {
|
|
166
|
+
data.skipDangerousModePermissionPrompt = true;
|
|
167
|
+
changed = true;
|
|
168
|
+
}
|
|
169
|
+
if (hostHomeDir) {
|
|
170
|
+
const hostSettings = readHostJsonSafe(path.join(hostHomeDir, '.claude', 'settings.json'));
|
|
171
|
+
if (hostSettings) {
|
|
172
|
+
changed = mergeMissingStringEnvFields(data, hostSettings) || changed;
|
|
173
|
+
changed = mergeMissingTopLevelSettings(data, hostSettings) || changed;
|
|
174
|
+
}
|
|
175
|
+
}
|
|
176
|
+
if (changed) fs.writeFileSync(settingsPath, JSON.stringify(data, null, 4), 'utf8');
|
|
177
|
+
}
|
|
178
|
+
|
|
179
|
+
export function formatCredentialSyncStatus(
|
|
180
|
+
result: ReturnType<typeof reconcileClaudeCredentials>,
|
|
181
|
+
isTTY = process.stderr.isTTY,
|
|
182
|
+
providerAuthAvailable = false
|
|
183
|
+
): string | null {
|
|
184
|
+
if (providerAuthAvailable && (result.status === 'STALE_ACCESS' || result.status === 'MISSING')) return null;
|
|
185
|
+
if (result.status === 'STALE_ACCESS') {
|
|
186
|
+
return 'Warning: Claude Code credentials on host appear stale. Run "ai sandbox refresh" or "claude /login" to renew.\n';
|
|
187
|
+
}
|
|
188
|
+
if (result.status === 'MISSING') {
|
|
189
|
+
return 'Warning: Claude Code credentials missing on host. Run "claude /login" to authenticate.\n';
|
|
190
|
+
}
|
|
191
|
+
if (result.status === 'KEYCHAIN_WRITE_FAILED') {
|
|
192
|
+
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`;
|
|
193
|
+
}
|
|
194
|
+
if (result.status === 'KEYCHAIN_LOCKED' || result.status === 'KEYCHAIN_ERROR') {
|
|
195
|
+
return 'Warning: Host keychain is unavailable; Claude credential sync skipped. Run "ai sandbox refresh" for details.\n';
|
|
196
|
+
}
|
|
197
|
+
if (result.status === 'OK' && result.authoritative !== 'host') {
|
|
198
|
+
const message = `Synced Claude Code credentials from sandbox refresh back to host (expires in ${formatRemaining(result.expiresAt)})`;
|
|
199
|
+
return isTTY ? `\x1b[2m${message}\x1b[0m\n` : `${message}\n`;
|
|
200
|
+
}
|
|
201
|
+
if (result.status === 'OK' && result.filesWritten.length > 0) {
|
|
202
|
+
const message = `Synced Claude Code credentials from host Keychain (expires in ${formatRemaining(result.expiresAt)})`;
|
|
203
|
+
return isTTY ? `\x1b[2m${message}\x1b[0m\n` : `${message}\n`;
|
|
204
|
+
}
|
|
205
|
+
return null;
|
|
206
|
+
}
|
|
207
|
+
|
|
208
|
+
const claudeCodeCredentialPreflightHook: AgentClientSandboxHook = {
|
|
209
|
+
id: 'claude-code-credential-preflight',
|
|
210
|
+
phase: 'prepare',
|
|
211
|
+
run: async ({ create }) => {
|
|
212
|
+
const { hostHome, hostEnv, project, resolvedTools } = requireCreateContext(
|
|
213
|
+
create,
|
|
214
|
+
'claude-code-credential-preflight'
|
|
215
|
+
);
|
|
216
|
+
try {
|
|
217
|
+
validateClaudeCredentialsEnvOverride(hostEnv);
|
|
218
|
+
const outcome = prepareClaudeCredentials(
|
|
219
|
+
hostHome,
|
|
220
|
+
project,
|
|
221
|
+
[...resolvedTools],
|
|
222
|
+
undefined,
|
|
223
|
+
undefined,
|
|
224
|
+
(home) => inspectClaudeKeychainStatus(home, undefined, { envFn: () => ({ ...hostEnv }) })
|
|
225
|
+
);
|
|
226
|
+
if (outcome.status === 'SKIPPED') {
|
|
227
|
+
return {
|
|
228
|
+
status: 'warning',
|
|
229
|
+
message: 'Claude Code credentials not found on host - creating this sandbox WITHOUT Claude Code credentials.\n'
|
|
230
|
+
+ ' Claude Code is still installed in the image but will not be authenticated.\n'
|
|
231
|
+
+ ' To enable it: run "claude" once on the host to complete login, then re-run "ai sandbox create".'
|
|
232
|
+
};
|
|
233
|
+
}
|
|
234
|
+
return { status: 'ready' };
|
|
235
|
+
} catch (error) {
|
|
236
|
+
return {
|
|
237
|
+
status: 'fatal',
|
|
238
|
+
message: redactCommandError(error instanceof Error ? error.message : 'unknown credential error')
|
|
239
|
+
};
|
|
240
|
+
}
|
|
241
|
+
}
|
|
242
|
+
};
|
|
243
|
+
|
|
244
|
+
const claudeCodeBeforeContainerCreateHook: AgentClientSandboxHook = {
|
|
245
|
+
id: 'claude-code-before-container-create',
|
|
246
|
+
phase: 'before-container-create',
|
|
247
|
+
run: async ({ create }) => {
|
|
248
|
+
const { hostHome, resolvedTools } = requireCreateContext(
|
|
249
|
+
create,
|
|
250
|
+
'claude-code-before-container-create'
|
|
251
|
+
);
|
|
252
|
+
const claudeCodeEntry = resolvedTools.find(({ tool }) => tool.id === 'claude-code');
|
|
253
|
+
if (claudeCodeEntry) {
|
|
254
|
+
ensureClaudeOnboarding(claudeCodeEntry.dir, hostHome);
|
|
255
|
+
ensureClaudeSettings(claudeCodeEntry.dir, hostHome);
|
|
256
|
+
}
|
|
257
|
+
return { status: 'ready' };
|
|
258
|
+
}
|
|
259
|
+
};
|
|
260
|
+
|
|
261
|
+
const claudeCodeBeforeEnterHook: AgentClientSandboxHook = {
|
|
262
|
+
id: 'claude-code-before-enter',
|
|
263
|
+
phase: 'before-enter',
|
|
264
|
+
run: async ({ enter }) => {
|
|
265
|
+
const { hostHome, hostEnv } = requireEnterContext(enter, 'claude-code-before-enter');
|
|
266
|
+
try {
|
|
267
|
+
validateClaudeCredentialsEnvOverride(hostEnv);
|
|
268
|
+
} catch (error) {
|
|
269
|
+
return {
|
|
270
|
+
status: 'fatal',
|
|
271
|
+
message: redactCommandError(error instanceof Error ? error.message : 'invalid credentials override')
|
|
272
|
+
};
|
|
273
|
+
}
|
|
274
|
+
try {
|
|
275
|
+
const providerAuthAvailable = hasClaudeProviderAuth(hostHome);
|
|
276
|
+
const result = reconcileClaudeCredentials(hostHome, { envFn: () => ({ ...hostEnv }) });
|
|
277
|
+
const message = formatCredentialSyncStatus(result, process.stderr.isTTY, providerAuthAvailable);
|
|
278
|
+
return {
|
|
279
|
+
status: 'ready',
|
|
280
|
+
...(message === null ? {} : { message })
|
|
281
|
+
};
|
|
282
|
+
} catch (error) {
|
|
283
|
+
return {
|
|
284
|
+
status: 'warning',
|
|
285
|
+
message: `Failed to sync Claude Code credentials: ${redactCommandError(error instanceof Error ? error.message : 'unknown error')}`
|
|
286
|
+
};
|
|
287
|
+
}
|
|
288
|
+
}
|
|
289
|
+
};
|
|
290
|
+
|
|
291
|
+
export {
|
|
292
|
+
claudeCodeBeforeContainerCreateHook,
|
|
293
|
+
claudeCodeBeforeEnterHook,
|
|
294
|
+
claudeCodeCredentialPreflightHook
|
|
295
|
+
};
|
|
@@ -1,5 +1,10 @@
|
|
|
1
1
|
import { defineAgentClientAdapter } from '../adapter.ts';
|
|
2
2
|
import { hostJoin } from '../../sandbox/engines/wsl2-paths.ts';
|
|
3
|
+
import {
|
|
4
|
+
claudeCodeBeforeContainerCreateHook,
|
|
5
|
+
claudeCodeBeforeEnterHook,
|
|
6
|
+
claudeCodeCredentialPreflightHook
|
|
7
|
+
} from './claude-code-sandbox.ts';
|
|
3
8
|
|
|
4
9
|
const claudeCodeAdapter = defineAgentClientAdapter({
|
|
5
10
|
id: 'claude-code',
|
|
@@ -11,13 +16,22 @@ const claudeCodeAdapter = defineAgentClientAdapter({
|
|
|
11
16
|
commands: { level: 'integrated' },
|
|
12
17
|
hooks: { level: 'integrated' },
|
|
13
18
|
subagents: { level: 'experimental' },
|
|
14
|
-
orchestration: { level: '
|
|
19
|
+
orchestration: { level: 'unsupported' },
|
|
15
20
|
sandbox: { level: 'integrated' },
|
|
16
21
|
verification: { level: 'compatible' }
|
|
17
22
|
},
|
|
23
|
+
modelSelection: {
|
|
24
|
+
kind: 'interactive-only',
|
|
25
|
+
command: '/model',
|
|
26
|
+
guidance: 'Use the host model picker for the complete model and reasoning-effort catalog.'
|
|
27
|
+
},
|
|
28
|
+
delegationEvidence: {
|
|
29
|
+
actualModel: 'unavailable',
|
|
30
|
+
actualReasoningEffort: 'unavailable'
|
|
31
|
+
},
|
|
18
32
|
project: {
|
|
19
33
|
ownedPathPrefixes: ['.claude/'],
|
|
20
|
-
managed: ['.claude/commands/', '.claude/agents/'],
|
|
34
|
+
managed: ['.claude/commands/', '.claude/agents/', '.claude/rules/'],
|
|
21
35
|
merged: ['.claude/settings.json'],
|
|
22
36
|
ejected: [],
|
|
23
37
|
seedCommands: [{
|
|
@@ -26,9 +40,18 @@ const claudeCodeAdapter = defineAgentClientAdapter({
|
|
|
26
40
|
'zh-CN': '.claude/commands/update-agent-infra.zh-CN.md'
|
|
27
41
|
},
|
|
28
42
|
target: '.claude/commands/update-agent-infra.md'
|
|
29
|
-
}]
|
|
43
|
+
}],
|
|
44
|
+
customCommand: {
|
|
45
|
+
target: '.claude/commands/${skillName}.md',
|
|
46
|
+
frontmatter: {},
|
|
47
|
+
includeUsage: true,
|
|
48
|
+
inheritDisableModelInvocation: true
|
|
49
|
+
}
|
|
30
50
|
},
|
|
31
51
|
sandbox: {
|
|
52
|
+
image: {
|
|
53
|
+
dockerfileFragment: 'claude-code'
|
|
54
|
+
},
|
|
32
55
|
createTool: ({ home, project }) => ({
|
|
33
56
|
id: 'claude-code',
|
|
34
57
|
name: 'Claude Code',
|
|
@@ -63,7 +86,11 @@ const claudeCodeAdapter = defineAgentClientAdapter({
|
|
|
63
86
|
{ name: 'claude-yolo', command: 'claude --dangerously-skip-permissions; tput ed' },
|
|
64
87
|
{ name: 'cy', command: 'claude --dangerously-skip-permissions; tput ed' }
|
|
65
88
|
],
|
|
66
|
-
hooks: [
|
|
89
|
+
hooks: [
|
|
90
|
+
claudeCodeCredentialPreflightHook,
|
|
91
|
+
claudeCodeBeforeContainerCreateHook,
|
|
92
|
+
claudeCodeBeforeEnterHook
|
|
93
|
+
]
|
|
67
94
|
}
|
|
68
95
|
});
|
|
69
96
|
|
|
@@ -19,6 +19,15 @@ const codexAdapter = defineAgentClientAdapter({
|
|
|
19
19
|
sandbox: { level: 'integrated' },
|
|
20
20
|
verification: { level: 'compatible' }
|
|
21
21
|
},
|
|
22
|
+
modelSelection: {
|
|
23
|
+
kind: 'interactive-only',
|
|
24
|
+
command: '/model',
|
|
25
|
+
guidance: 'Use the host model picker for the complete model and reasoning-effort catalog.'
|
|
26
|
+
},
|
|
27
|
+
delegationEvidence: {
|
|
28
|
+
actualModel: 'unavailable',
|
|
29
|
+
actualReasoningEffort: 'unavailable'
|
|
30
|
+
},
|
|
22
31
|
project: {
|
|
23
32
|
ownedPathPrefixes: ['.codex/'],
|
|
24
33
|
managed: ['.codex/hooks.json', '.codex/agents/'],
|
|
@@ -2,14 +2,14 @@ import { AGENT_CLIENT_IDS } from '../types.ts';
|
|
|
2
2
|
import type { AgentClientAdapter } from '../adapter.ts';
|
|
3
3
|
import { claudeCodeAdapter } from './claude-code.ts';
|
|
4
4
|
import { codexAdapter } from './codex.ts';
|
|
5
|
-
import {
|
|
5
|
+
import { antigravityCliAdapter } from './antigravity-cli.ts';
|
|
6
6
|
import { opencodeAdapter } from './opencode.ts';
|
|
7
7
|
|
|
8
8
|
const adaptersById = new Map(
|
|
9
9
|
[
|
|
10
10
|
claudeCodeAdapter,
|
|
11
11
|
codexAdapter,
|
|
12
|
-
|
|
12
|
+
antigravityCliAdapter,
|
|
13
13
|
opencodeAdapter
|
|
14
14
|
].map((adapter) => [adapter.id, adapter])
|
|
15
15
|
);
|
|
@@ -0,0 +1,136 @@
|
|
|
1
|
+
import fs from 'node:fs';
|
|
2
|
+
import path from 'node:path';
|
|
3
|
+
|
|
4
|
+
import type {
|
|
5
|
+
AgentClientSandboxHook,
|
|
6
|
+
AgentClientSandboxRecoveryCheck
|
|
7
|
+
} from '../../sandbox/tool-types.ts';
|
|
8
|
+
|
|
9
|
+
type JsonObject = Record<string, unknown>;
|
|
10
|
+
|
|
11
|
+
function readJsonObject(filePath: string): JsonObject | null {
|
|
12
|
+
try {
|
|
13
|
+
const parsed = JSON.parse(fs.readFileSync(filePath, 'utf8')) as unknown;
|
|
14
|
+
return parsed !== null && typeof parsed === 'object' && !Array.isArray(parsed)
|
|
15
|
+
? parsed as JsonObject
|
|
16
|
+
: null;
|
|
17
|
+
} catch {
|
|
18
|
+
return null;
|
|
19
|
+
}
|
|
20
|
+
}
|
|
21
|
+
|
|
22
|
+
function resolveXdgRoot(value: string | undefined, fallback: string): string {
|
|
23
|
+
return typeof value === 'string' && value !== '' && path.isAbsolute(value)
|
|
24
|
+
? value
|
|
25
|
+
: fallback;
|
|
26
|
+
}
|
|
27
|
+
|
|
28
|
+
function ensureOpenCodeSandboxState(
|
|
29
|
+
toolDir: string,
|
|
30
|
+
hostHome: string,
|
|
31
|
+
hostEnv: Readonly<NodeJS.ProcessEnv> = {}
|
|
32
|
+
): void {
|
|
33
|
+
const canonicalConfigDir = path.join(toolDir, '.xdg', 'config', 'opencode');
|
|
34
|
+
const canonicalStateDir = path.join(toolDir, '.xdg', 'state', 'opencode');
|
|
35
|
+
const canonicalConfigPath = path.join(canonicalConfigDir, 'opencode.json');
|
|
36
|
+
const legacyConfigPath = path.join(toolDir, 'opencode.json');
|
|
37
|
+
fs.mkdirSync(canonicalConfigDir, { recursive: true });
|
|
38
|
+
fs.mkdirSync(canonicalStateDir, { recursive: true });
|
|
39
|
+
|
|
40
|
+
if (!fs.existsSync(canonicalConfigPath) && fs.existsSync(legacyConfigPath)) {
|
|
41
|
+
fs.copyFileSync(legacyConfigPath, canonicalConfigPath, fs.constants.COPYFILE_EXCL);
|
|
42
|
+
}
|
|
43
|
+
|
|
44
|
+
const hostConfigRoot = resolveXdgRoot(
|
|
45
|
+
hostEnv.XDG_CONFIG_HOME,
|
|
46
|
+
path.join(hostHome, '.config')
|
|
47
|
+
);
|
|
48
|
+
const hostConfig = readJsonObject(
|
|
49
|
+
path.join(hostConfigRoot, 'opencode', 'opencode.json')
|
|
50
|
+
);
|
|
51
|
+
if (!hostConfig) {
|
|
52
|
+
return;
|
|
53
|
+
}
|
|
54
|
+
|
|
55
|
+
let sandboxConfig: JsonObject = {};
|
|
56
|
+
if (fs.existsSync(canonicalConfigPath)) {
|
|
57
|
+
const existing = readJsonObject(canonicalConfigPath);
|
|
58
|
+
if (!existing) {
|
|
59
|
+
return;
|
|
60
|
+
}
|
|
61
|
+
sandboxConfig = existing;
|
|
62
|
+
}
|
|
63
|
+
|
|
64
|
+
let changed = false;
|
|
65
|
+
for (const key of ['model', 'small_model']) {
|
|
66
|
+
if (Object.hasOwn(sandboxConfig, key)) {
|
|
67
|
+
continue;
|
|
68
|
+
}
|
|
69
|
+
const value = hostConfig[key];
|
|
70
|
+
if (typeof value === 'string' && value !== '') {
|
|
71
|
+
sandboxConfig[key] = value;
|
|
72
|
+
changed = true;
|
|
73
|
+
}
|
|
74
|
+
}
|
|
75
|
+
if (changed) {
|
|
76
|
+
fs.writeFileSync(canonicalConfigPath, JSON.stringify(sandboxConfig, null, 2), 'utf8');
|
|
77
|
+
}
|
|
78
|
+
}
|
|
79
|
+
|
|
80
|
+
const opencodeBeforeContainerCreateHook: AgentClientSandboxHook = {
|
|
81
|
+
id: 'opencode-before-container-create',
|
|
82
|
+
phase: 'before-container-create',
|
|
83
|
+
async run(context) {
|
|
84
|
+
const create = context.create;
|
|
85
|
+
const entry = create?.resolvedTools.find(({ tool }) => tool.id === 'opencode');
|
|
86
|
+
if (!create || !entry) {
|
|
87
|
+
return {
|
|
88
|
+
status: 'fatal',
|
|
89
|
+
message: 'OpenCode sandbox hook requires its resolved tool state.'
|
|
90
|
+
};
|
|
91
|
+
}
|
|
92
|
+
ensureOpenCodeSandboxState(entry.dir, create.hostHome, create.hostEnv);
|
|
93
|
+
return { status: 'ready' };
|
|
94
|
+
}
|
|
95
|
+
};
|
|
96
|
+
|
|
97
|
+
const opencodeRecoveryChecks: readonly AgentClientSandboxRecoveryCheck[] = [
|
|
98
|
+
{
|
|
99
|
+
id: 'command-available',
|
|
100
|
+
probe: { script: 'command -v "$1"', args: ['opencode'] },
|
|
101
|
+
finding: {
|
|
102
|
+
repairKind: 'hard-failure',
|
|
103
|
+
message: 'OpenCode is not available on PATH inside the sandbox.'
|
|
104
|
+
}
|
|
105
|
+
},
|
|
106
|
+
{
|
|
107
|
+
id: 'config-writable',
|
|
108
|
+
probe: {
|
|
109
|
+
script: 'probe="$1/.agent-infra-opencode-config-$$"; trap \'rm -f -- "$probe"\' EXIT; : > "$probe"',
|
|
110
|
+
args: ['/home/devuser/.local/share/opencode/.xdg/config/opencode']
|
|
111
|
+
},
|
|
112
|
+
finding: {
|
|
113
|
+
repairKind: 'permissions',
|
|
114
|
+
message: 'OpenCode config directory is not writable by devuser.',
|
|
115
|
+
path: '/home/devuser/.local/share/opencode/.xdg/config/opencode'
|
|
116
|
+
}
|
|
117
|
+
},
|
|
118
|
+
{
|
|
119
|
+
id: 'state-writable',
|
|
120
|
+
probe: {
|
|
121
|
+
script: 'probe="$1/.agent-infra-opencode-state-$$"; trap \'rm -f -- "$probe"\' EXIT; : > "$probe"',
|
|
122
|
+
args: ['/home/devuser/.local/share/opencode/.xdg/state/opencode']
|
|
123
|
+
},
|
|
124
|
+
finding: {
|
|
125
|
+
repairKind: 'permissions',
|
|
126
|
+
message: 'OpenCode state directory is not writable by devuser.',
|
|
127
|
+
path: '/home/devuser/.local/share/opencode/.xdg/state/opencode'
|
|
128
|
+
}
|
|
129
|
+
}
|
|
130
|
+
];
|
|
131
|
+
|
|
132
|
+
export {
|
|
133
|
+
ensureOpenCodeSandboxState,
|
|
134
|
+
opencodeBeforeContainerCreateHook,
|
|
135
|
+
opencodeRecoveryChecks
|
|
136
|
+
};
|
|
@@ -1,5 +1,9 @@
|
|
|
1
1
|
import { defineAgentClientAdapter } from '../adapter.ts';
|
|
2
2
|
import { hostJoin } from '../../sandbox/engines/wsl2-paths.ts';
|
|
3
|
+
import {
|
|
4
|
+
opencodeBeforeContainerCreateHook,
|
|
5
|
+
opencodeRecoveryChecks
|
|
6
|
+
} from './opencode-sandbox.ts';
|
|
3
7
|
|
|
4
8
|
const YOLO_PERMISSION = '{"*":"allow","read":"allow","bash":"allow","edit":"allow","webfetch":"allow","external_directory":"allow","doom_loop":"allow"}';
|
|
5
9
|
|
|
@@ -17,6 +21,15 @@ const opencodeAdapter = defineAgentClientAdapter({
|
|
|
17
21
|
sandbox: { level: 'integrated' },
|
|
18
22
|
verification: { level: 'compatible' }
|
|
19
23
|
},
|
|
24
|
+
modelSelection: {
|
|
25
|
+
kind: 'interactive-only',
|
|
26
|
+
command: '/models',
|
|
27
|
+
guidance: 'Use the host model picker for the complete model and reasoning-effort catalog.'
|
|
28
|
+
},
|
|
29
|
+
delegationEvidence: {
|
|
30
|
+
actualModel: 'unavailable',
|
|
31
|
+
actualReasoningEffort: 'unavailable'
|
|
32
|
+
},
|
|
20
33
|
project: {
|
|
21
34
|
ownedPathPrefixes: ['.opencode/'],
|
|
22
35
|
managed: ['.opencode/commands/'],
|
|
@@ -28,9 +41,17 @@ const opencodeAdapter = defineAgentClientAdapter({
|
|
|
28
41
|
'zh-CN': '.opencode/commands/update-agent-infra.zh-CN.md'
|
|
29
42
|
},
|
|
30
43
|
target: '.opencode/commands/update-agent-infra.md'
|
|
31
|
-
}]
|
|
44
|
+
}],
|
|
45
|
+
customCommand: {
|
|
46
|
+
target: '.opencode/commands/${skillName}.md',
|
|
47
|
+
frontmatter: { agent: 'general', subtask: false },
|
|
48
|
+
argumentsToken: '$ARGUMENTS'
|
|
49
|
+
}
|
|
32
50
|
},
|
|
33
51
|
sandbox: {
|
|
52
|
+
image: {
|
|
53
|
+
dotfilesExclusions: ['.config/opencode']
|
|
54
|
+
},
|
|
34
55
|
createTool: ({ home }) => ({
|
|
35
56
|
id: 'opencode',
|
|
36
57
|
name: 'OpenCode',
|
|
@@ -40,7 +61,9 @@ const opencodeAdapter = defineAgentClientAdapter({
|
|
|
40
61
|
versionCmd: 'opencode --version',
|
|
41
62
|
setupHint: 'Configure OpenCode credentials inside the container before first use.',
|
|
42
63
|
envVars: {
|
|
43
|
-
|
|
64
|
+
XDG_DATA_HOME: '/home/devuser/.local/share',
|
|
65
|
+
XDG_CONFIG_HOME: '/home/devuser/.local/share/opencode/.xdg/config',
|
|
66
|
+
XDG_STATE_HOME: '/home/devuser/.local/share/opencode/.xdg/state'
|
|
44
67
|
},
|
|
45
68
|
hostLiveMounts: [
|
|
46
69
|
{
|
|
@@ -59,7 +82,8 @@ const opencodeAdapter = defineAgentClientAdapter({
|
|
|
59
82
|
command: `OPENCODE_PERMISSION='${YOLO_PERMISSION}' opencode; tput ed`
|
|
60
83
|
}
|
|
61
84
|
],
|
|
62
|
-
hooks: []
|
|
85
|
+
hooks: [opencodeBeforeContainerCreateHook],
|
|
86
|
+
recoveryChecks: opencodeRecoveryChecks
|
|
63
87
|
}
|
|
64
88
|
});
|
|
65
89
|
|
|
@@ -0,0 +1,65 @@
|
|
|
1
|
+
RUN cat > /usr/local/bin/cc-token-status <<'SCRIPT' && chmod +x /usr/local/bin/cc-token-status
|
|
2
|
+
#!/bin/sh
|
|
3
|
+
set -eu
|
|
4
|
+
|
|
5
|
+
SETTINGS_FILE="/home/devuser/.claude/settings.json"
|
|
6
|
+
if [ -r "$SETTINGS_FILE" ] && jq -e '
|
|
7
|
+
def has_nonempty($v):
|
|
8
|
+
if ($v | type) == "string" then ($v | gsub("^\\s+|\\s+$"; "") | length) > 0 else false end;
|
|
9
|
+
(if type == "object" then . else {} end) as $settings
|
|
10
|
+
| (if ($settings.env | type) == "object" then $settings.env else {} end) as $env
|
|
11
|
+
| has_nonempty($env.ANTHROPIC_AUTH_TOKEN)
|
|
12
|
+
or has_nonempty($env.ANTHROPIC_API_KEY)
|
|
13
|
+
or has_nonempty($settings.apiKeyHelper)
|
|
14
|
+
' "$SETTINGS_FILE" >/dev/null 2>&1; then
|
|
15
|
+
exit 0
|
|
16
|
+
fi
|
|
17
|
+
|
|
18
|
+
CRED_FILE="/home/devuser/.claude/.credentials.json"
|
|
19
|
+
[ -r "$CRED_FILE" ] || exit 0
|
|
20
|
+
|
|
21
|
+
EXPIRES_MS=$(jq -r '(.claudeAiOauth.expiresAt // .expiresAt) // empty' "$CRED_FILE" 2>/dev/null || true)
|
|
22
|
+
case "$EXPIRES_MS" in
|
|
23
|
+
''|*[!0-9]*) exit 0 ;;
|
|
24
|
+
esac
|
|
25
|
+
|
|
26
|
+
NOW_MS=$(($(date +%s) * 1000))
|
|
27
|
+
DIFF_MS=$((EXPIRES_MS - NOW_MS))
|
|
28
|
+
DIFF_S=$((DIFF_MS / 1000))
|
|
29
|
+
|
|
30
|
+
DIM='#[fg=colour245]'
|
|
31
|
+
YELLOW='#[fg=yellow]'
|
|
32
|
+
YELLOW_BOLD='#[fg=yellow,bold]'
|
|
33
|
+
RED_BOLD='#[fg=red,bold]'
|
|
34
|
+
RED_REV='#[fg=red,reverse]'
|
|
35
|
+
RESET='#[default]'
|
|
36
|
+
|
|
37
|
+
if [ "$DIFF_S" -le 0 ]; then
|
|
38
|
+
ELAPSED=$(( -DIFF_S ))
|
|
39
|
+
M=$((ELAPSED / 60))
|
|
40
|
+
printf '%sClaude Code auth EXPIRED %dm ago%s' "$RED_REV" "$M" "$RESET"
|
|
41
|
+
elif [ "$DIFF_S" -lt 60 ]; then
|
|
42
|
+
printf '%sClaude Code auth expires in %ds%s' "$RED_BOLD" "$DIFF_S" "$RESET"
|
|
43
|
+
elif [ "$DIFF_S" -lt 300 ]; then
|
|
44
|
+
M=$((DIFF_S / 60))
|
|
45
|
+
S=$((DIFF_S % 60))
|
|
46
|
+
printf '%sClaude Code auth expires in %dm %ds%s' "$RED_BOLD" "$M" "$S" "$RESET"
|
|
47
|
+
elif [ "$DIFF_S" -lt 1800 ]; then
|
|
48
|
+
M=$((DIFF_S / 60))
|
|
49
|
+
printf '%sClaude Code auth expires in %dm%s' "$YELLOW_BOLD" "$M" "$RESET"
|
|
50
|
+
elif [ "$DIFF_S" -lt 3600 ]; then
|
|
51
|
+
M=$((DIFF_S / 60))
|
|
52
|
+
printf '%sClaude Code auth expires in %dm%s' "$YELLOW" "$M" "$RESET"
|
|
53
|
+
else
|
|
54
|
+
TOTAL_M=$((DIFF_S / 60))
|
|
55
|
+
H=$((TOTAL_M / 60))
|
|
56
|
+
M=$((TOTAL_M % 60))
|
|
57
|
+
printf '%sClaude Code auth expires in %dh %dm%s' "$DIM" "$H" "$M" "$RESET"
|
|
58
|
+
fi
|
|
59
|
+
SCRIPT
|
|
60
|
+
|
|
61
|
+
RUN test -s /usr/local/bin/cc-token-status && test -x /usr/local/bin/cc-token-status
|
|
62
|
+
|
|
63
|
+
RUN printf '%s\n' \
|
|
64
|
+
"set -g status-right '#(/usr/local/bin/cc-token-status) | %H:%M'" \
|
|
65
|
+
>> /etc/tmux.conf
|