> ## Documentation Index
> Fetch the complete documentation index at: https://ona.com/docs/llms.txt
> Use this file to discover all available pages before exploring further.

# Dynamic configuration

> Generate tasks and services programmatically based on what agents discover in your codebase.

Create and update tasks and services at runtime using the CLI. When Ona explores a new repository, it can:

* Discover `package.json` scripts and expose them as tasks
* Find services in a monorepo and create start commands for each
* Generate test tasks for different modules it finds
* Adapt the environment to match the project structure

## Creating tasks and services dynamically

Use the CLI to pipe configuration directly:

```bash theme={null}
echo '{"tasks": {"update_deps": {"name": "Update dependencies", "command": "npm update"}}}' | ona automations update -
```

The `-` signals reading from stdin. Task and service IDs can only contain alphanumeric characters, underscores, and hyphens (1-128 characters).

## Example uses

**Expose package.json scripts as tasks:**

```bash theme={null}
jq -r '.scripts | to_entries[] | {(.key | gsub("[^a-zA-Z0-9_-]"; "_")): {"name": .key, "command": .value}}' package.json |
jq -s 'add | {"tasks": .}' |
ona automations update -
```

**Create services for monorepo components:**

```bash theme={null}
find ./components -type d -maxdepth 1 -mindepth 1 |
jq -R '{(. | gsub("[^a-zA-Z0-9_-]"; "_")): {"name": "Start " + ., "command": "cd " + . + " && go run ."}}' |
jq -s 'add | {"services": .}' |
ona automations update -
```

**Load configuration from a remote source:**

```bash theme={null}
curl https://example.com/automations.json | ona automations update -
```

<Warning>
  Only download configuration from sources you trust. Verify integrity before applying.
</Warning>

## Control from outside environments

Manage tasks and services from outside an environment using the CLI on your local machine or in external pipelines.

### Example: create, run task, clean up

```bash theme={null}
# Create environment
ENV_ID=$(ona environment create https://github.com/your-repo/project --dont-wait --class-id <your-env-class-id>)

# Run a task
TASK_ID=$(ona automations task start build-and-test --environment-id $ENV_ID)

# Stream logs
ona automations task logs $TASK_ID --environment-id $ENV_ID

# Check result and clean up
TASK_STATUS=$(ona automations task get $TASK_ID --environment-id $ENV_ID -o json | jq -r .status)

if [ "$TASK_STATUS" = "succeeded" ]; then
    ona environment delete $ENV_ID
else
    echo "Task failed. Environment left for inspection."
fi
```
