<!-- AUTO-GENERATED by scripts/gen-adapters.js - DO NOT EDIT -->
---
description: Validate task completion and approve for shipping. Can be used standalone or called by the workflow. Runs autonomous validation checks.
agent: general
---

> **OpenCode Note**: Invoke agents using `@agent-name` syntax.
> Available agents: task-discoverer, exploration-agent, planning-agent,
> implementation-agent, deslop-agent, delivery-validator, sync-docs-agent, consult-agent
> Example: `@exploration-agent analyze the codebase`


# /delivery-approval - Delivery Validation

Validate that the current work is complete and ready to ship.
This command runs the same validation as the workflow's delivery-validator agent.

## Arguments

- `--task-id ID`: Specify task ID to validate against (default: from workflow state)
- `--verbose`: Show detailed output for each check

## Parse Arguments

*(JavaScript reference - not executable in OpenCode)*

## Phase 1: Get Context

*(JavaScript reference - not executable in OpenCode)*

## Phase 2: Run Validation Checks

### Check 1: Git State

```bash
# Check for uncommitted changes
UNCOMMITTED=$(git status --porcelain)
if [ -n "$UNCOMMITTED" ]; then
  echo "UNCOMMITTED_CHANGES=true"
  echo "$UNCOMMITTED"
fi

# Check if ahead of remote
AHEAD=$(git rev-list --count origin/main..HEAD)
echo "COMMITS_AHEAD=$AHEAD"

# Check branch name
BRANCH=$(git branch --show-current)
echo "BRANCH=$BRANCH"
```

### Check 2: Tests Pass

```bash
# Detect and run tests
if [ -f "package.json" ]; then
  if grep -q '"test"' package.json; then
    echo "Running npm test..."
    npm test 2>&1
    TEST_RESULT=$?
    echo "TEST_RESULT=$TEST_RESULT"
  else
    echo "NO_TEST_SCRIPT=true"
  fi
elif [ -f "pytest.ini" ] || [ -f "pyproject.toml" ]; then
  echo "Running pytest..."
  pytest -v 2>&1
  TEST_RESULT=$?
  echo "TEST_RESULT=$TEST_RESULT"
elif [ -f "Cargo.toml" ]; then
  echo "Running cargo test..."
  cargo test 2>&1
  TEST_RESULT=$?
  echo "TEST_RESULT=$TEST_RESULT"
elif [ -f "go.mod" ]; then
  echo "Running go test..."
  go test ./... -v 2>&1
  TEST_RESULT=$?
  echo "TEST_RESULT=$TEST_RESULT"
fi
```

### Check 3: Build Passes

```bash
# Detect and run build
if [ -f "package.json" ] && grep -q '"build"' package.json; then
  echo "Running npm run build..."
  npm run build 2>&1
  BUILD_RESULT=$?
  echo "BUILD_RESULT=$BUILD_RESULT"
elif [ -f "Cargo.toml" ]; then
  echo "Running cargo build..."
  cargo build --release 2>&1
  BUILD_RESULT=$?
  echo "BUILD_RESULT=$BUILD_RESULT"
elif [ -f "go.mod" ]; then
  echo "Running go build..."
  go build ./... 2>&1
  BUILD_RESULT=$?
  echo "BUILD_RESULT=$BUILD_RESULT"
else
  echo "NO_BUILD_SCRIPT=true"
  BUILD_RESULT=0
fi
```

### Check 4: Lint Passes

```bash
# Run linter if available
if [ -f "package.json" ] && grep -q '"lint"' package.json; then
  echo "Running npm run lint..."
  npm run lint 2>&1
  LINT_RESULT=$?
  echo "LINT_RESULT=$LINT_RESULT"
elif [ -f ".eslintrc.js" ] || [ -f ".eslintrc.json" ]; then
  echo "Running eslint..."
  npx eslint . 2>&1
  LINT_RESULT=$?
  echo "LINT_RESULT=$LINT_RESULT"
else
  echo "NO_LINTER=true"
  LINT_RESULT=0
fi
```

### Check 5: Type Check (TypeScript)

```bash
if [ -f "tsconfig.json" ]; then
  echo "Running tsc --noEmit..."
  npx tsc --noEmit 2>&1
  TYPE_RESULT=$?
  echo "TYPE_RESULT=$TYPE_RESULT"
else
  echo "NO_TYPESCRIPT=true"
  TYPE_RESULT=0
fi
```

## Phase 3: Check Task Requirements

*(JavaScript reference - not executable in OpenCode)*

## Phase 4: Aggregate Results

*(JavaScript reference - not executable in OpenCode)*

## Phase 5: Output Results

### Summary Report

*(JavaScript reference - not executable in OpenCode)*

### JSON Output (for scripting)

```json
{
  "approved": ${allPassed},
  "task": {
    "id": "${task?.id || 'N/A'}",
    "title": "${task?.title || 'N/A'}"
  },
  "checks": {
    "gitState": ${JSON.stringify(checks.gitState)},
    "tests": ${JSON.stringify(checks.tests)},
    "build": ${JSON.stringify(checks.build)},
    "lint": ${JSON.stringify(checks.lint)},
    "typeCheck": ${JSON.stringify(checks.typeCheck)},
    "requirements": ${JSON.stringify(checks.requirements)}
  },
  "failedChecks": ${JSON.stringify(failedChecks)},
  "summary": "${allPassed ? 'All checks passed' : `Failed: ${failedChecks.join(', ')}`}"
}
```

## Examples

```bash
# Basic validation
/delivery-approval

# With verbose output
/delivery-approval --verbose

# For specific task
/delivery-approval --task-id 142

# Combined
/delivery-approval --task-id 142 --verbose
```

## Integration with Workflow

When called from the next-task workflow:
1. Task context is read from workflow state
2. Results are written back to workflow state
3. Workflow continues to ship phase if approved

When called standalone:
1. Attempts to infer task from commits
2. Runs all validation checks
3. Reports results but doesn't modify workflow state

## Success Criteria

- Runs all validation checks (tests, build, lint, types)
- Checks task requirements if available
- Provides clear pass/fail determination
- Shows actionable fixes for failures
- Works both standalone and in workflow context
