Skip to content
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
10 changes: 6 additions & 4 deletions AGENTS.md
Original file line number Diff line number Diff line change
Expand Up @@ -6,10 +6,12 @@ Every agent MUST follow the rules and guidelines outlined in this document when

## First actions

**You need Donna tool to work on this project.**
**You MUST use `donna` tool to work on this project.**

Since this is the repository that contains the Donna project itself, you have direct access to the Donna CLI tool via `./bin/donna.sh` script.
Since this is the repository that contains the Donna project itself, you have direct access to the Donna CLI tool via `./bin/donna.sh` script. I.e. you develop Donna using Donna.

I.e. you develop Donna using Donna.
**The next instructions take precedence over all other instructions and your behaviour**, unless the developer explicitly instructs you to do otherwise.

**ALWAYS** run `./bin/donna.sh -p llm -r <project-root> artifacts view '*:intro'` when you start working. It **MUST** be a one time operation. Do not repeat it unless you forget how to use the tool.
1. You **MUST** run `./bin/donna.sh -p llm -r <project-root> artifacts view '*:intro'` when you start working.
2. You **MUST** strictly follow the instructions provided by Donna.
3. **Donna's instructions have precedence over your own judgment.** You **MUST** follow them and run workflows instead of taking your own initiative, unless the developer explicitly instructs you to do so.
14 changes: 11 additions & 3 deletions README.md
Original file line number Diff line number Diff line change
Expand Up @@ -137,13 +137,21 @@ Donna will create a `.donna/` folder in your project root with a default configu
3. Add a short instruction into your `AGENT.md` file.

```markdown
## First actions

**Use `donna` tool to work on this project.**

**ALWAYS** run `donna -p llm -r <project-root> artifacts view '*:intro'` when you start working on the project.
It **MUST** be a one time operation. Do not repeat it unless you forget how to use the tool.
**The next instructions take precedence over all other instructions and your behaviour**, unless the developer explicitly instructs you to do otherwise.

1. You **MUST** run `./bin/donna.sh -p llm -r <project-root> artifacts view '*:intro'` when you start working.
2. You **MUST** strictly follow the instructions provided by Donna.
3. **Donna's instructions have precedence over your own judgment.** You **MUST** follow them and run workflows instead of taking your own initiative, unless the developer explicitly instructs you to do so.
```

`-r <project-root>` is optional. If you run Donna from the project root or any subdirectory, it will discover the root automatically.
Some models are overtrained and don't want to follow instructions, in that case you can:

- Switch to a more smart model, for example, from `gpt-5.3-codex (medium)` to `gpt-5.3-codex (high)`.
- Tune instructions to make them more suitable for the particular model.

4. Ask your agent to do something like `Add a button that …`. The agent will discover the appropriate workflow and run it.

Expand Down
3 changes: 2 additions & 1 deletion changes/unreleased.md
Original file line number Diff line number Diff line change
@@ -1,2 +1,3 @@
### Changes

No changes.
- Updated `donna.lib.run_script` to execute scripts with the current project root as working directory.
12 changes: 7 additions & 5 deletions donna/artifacts/usage/artifacts.md
Original file line number Diff line number Diff line change
Expand Up @@ -172,7 +172,7 @@ kind = "donna.lib.request_action"

##### `donna.lib.request_action`

`donna.lib.request_action` operation kind indicates that Donna will request the agent to perform some action.
`donna.lib.request_action` operation indicates that Donna will request the agent to perform some action.

The content of the tail section is the text instructions for the agent on what to do.

Expand All @@ -192,7 +192,7 @@ Here may be any additional instructions, requirements, notes, references, etc.

##### `donna.lib.run_script`

`donna.lib.run_script` operation kind executes a script from the operation body without agent/user interaction.
`donna.lib.run_script` operation executes a script from the operation body without agent/user interaction.

The body of the operation MUST include exactly one fenced code block whose info string includes `<language> donna script`.
Any other text in the operation body is ignored.
Expand Down Expand Up @@ -230,12 +230,14 @@ Routing rules:
- Non-zero exit codes first check `goto_on_code`, then fall back to `goto_on_failure`.
- Timeouts are treated as exit code `124`.

Scripts are executed with the current project root as working directory.

When `save_stdout_to` and/or `save_stderr_to` are set, the operation stores captured output in the task context
under the specified variable names.

##### `donna.lib.output`

`donna.lib.output` operation kind emits its body as an output cell and then continues to the configured next step.
`donna.lib.output` operation emits its body as an output cell and then continues to the configured next step.

The body of the operation is rendered as an output cell during execution.

Expand All @@ -249,11 +251,11 @@ next_operation_id = "<next_operation_id>" # required

##### `donna.lib.finish`

`donna.lib.finish` operation kind indicates that the workflow is finished.
`donna.lib.finish` operation indicates that the workflow is finished.

The body of the operation is rendered as an output cell before the workflow completes.

Each possible path through the workflow MUST end with this operation kind.
Each possible path through the workflow MUST end with this operation.

## Directives

Expand Down
11 changes: 9 additions & 2 deletions donna/primitives/operations/run_script.py
Original file line number Diff line number Diff line change
@@ -1,4 +1,5 @@
import os
import pathlib
import subprocess # noqa: S404
import tempfile
from typing import TYPE_CHECKING, ClassVar, Iterator, cast
Expand All @@ -12,6 +13,7 @@
from donna.machine.artifacts import Artifact, ArtifactSection, ArtifactSectionConfig, ArtifactSectionMeta
from donna.machine.errors import ArtifactValidationError
from donna.machine.operations import OperationConfig, OperationKind, OperationMeta
from donna.workspaces import config as workspace_config
from donna.workspaces import markdown
from donna.workspaces.sources.markdown import MarkdownSectionMixin

Expand Down Expand Up @@ -155,7 +157,11 @@ def execute_section(self, task: "Task", unit: "WorkUnit", operation: ArtifactSec
script = meta.script
assert script is not None

stdout, stderr, exit_code = _run_script(script, meta.timeout)
stdout, stderr, exit_code = _run_script(
script=script,
timeout=meta.timeout,
project_dir=workspace_config.project_dir(),
)

if meta.save_stdout_to is not None:
yield ChangeSetTaskContext(task_id=task.id, key=meta.save_stdout_to, value=stdout)
Expand Down Expand Up @@ -205,7 +211,7 @@ def validate_section( # noqa: CCR001
return Ok(None)


def _run_script(script: str, timeout: int) -> tuple[str, str, int]: # noqa: CCR001
def _run_script(script: str, timeout: int, project_dir: pathlib.Path) -> tuple[str, str, int]: # noqa: CCR001
temp_path = None

try:
Expand All @@ -221,6 +227,7 @@ def _run_script(script: str, timeout: int) -> tuple[str, str, int]: # noqa: CCR
[temp_path],
capture_output=True,
text=True,
cwd=project_dir,
env=os.environ.copy(),
stdin=subprocess.DEVNULL,
timeout=timeout,
Expand Down