---
# harness/code.yaml — code agent with pre/post script pipeline.
#
# Flow: pre_script → sandbox (agent) → post_script
#   pre_script  : validates inputs on the runner BEFORE sandbox creation
#   agent       : reads the issue, implements, tests, scans, commits locally
#   post_script : protected-path check, secret scan, push branch, create PR
#
# The agent NEVER pushes or creates PRs (disallowedTools enforces this).
# Only the post-script, running on the runner with PUSH_TOKEN, can write.
agent: agents/code.md
doc: docs/agents/code.md
model: opus
image: ghcr.io/fullsend-ai/fullsend-code:latest
policy: policies/code.yaml

role: coder
slug: fullsend-ai-coder

host_files:
  - src: env/gcp-vertex.env
    dest: /sandbox/workspace/.env.d/gcp-vertex.env
    expand: true
  - src: env/code-agent.env
    dest: /sandbox/workspace/.env.d/code-agent.env
    expand: true
  - src: ${GOOGLE_APPLICATION_CREDENTIALS}
    dest: /tmp/.gcp-credentials.json
  - src: ${GCP_OIDC_TOKEN_FILE}
    dest: /sandbox/workspace/.gcp-oidc-token
    optional: true

pre_script: scripts/pre-code.sh
post_script: scripts/post-code.sh

skills:
  - skills/code-implementation

plugins:
  - plugins/gopls-lsp

# Environment variables available to pre/post scripts on the runner.
# These are expanded from the runner environment and NEVER enter the sandbox.
runner_env:
  CODE_ALLOWED_TARGET_BRANCHES: "${CODE_ALLOWED_TARGET_BRANCHES}"
  FULLSEND_OUTPUT_SCHEMA: ${FULLSEND_DIR}/schemas/code-result.schema.json
  FULLSEND_OUTPUT_FILE: code-result.json

timeout_minutes: 35

forge:
  github:
    pre_script: scripts/pre-code.sh
    post_script: scripts/post-code.sh
    runner_env:
      PUSH_TOKEN: "${PUSH_TOKEN}"
      PUSH_TOKEN_SOURCE: "${PUSH_TOKEN_SOURCE}"
      REPO_FULL_NAME: "${REPO_FULL_NAME}"
      ISSUE_NUMBER: "${ISSUE_NUMBER}"
      REPO_DIR: "${GITHUB_WORKSPACE}/target-repo"
