Add examples/ invoice PDF generator skill and actor demonstrating gated script execution #187

Closed
opened 2026-11-24 19:28:50 +00:00 by CoreRasurae · 0 comments
Member

Metadata

Commit Message: feat(examples): add invoice PDF generator skill and actor example
Branch: feature/m1-invoice-pdf-skill-example

Background and context

Epic #160 (Agent Skills — Full Resource Support and Safe Execution) delivered
the mechanics for bundling and gate-executing a skill's scripts/ resource
(issues #161-#171), but examples/ has no runnable actor that actually
exercises execute: true end-to-end and produces a real, useful artifact.
The existing examples/ demonstration (issue #148, calculator app) uses a
skill only for its reference instructions (the programming-patterns
skill has no scripts/ resource at all) — it never drives the script-
execution gate.

This issue adds a second, independent examples/ demonstration: an
"invoice clerk" LLM agent that extracts plain text/numeric fields from a
user's request and runs a bundled skill script that builds a real PDF
invoice document, showing a genuine real-world use of execute: true
alongside the calculator app's instructions-only skill usage.

Current behavior

No example in examples/packages/ bundles or executes a skill script. A
developer looking for a worked, runnable reference for the ADR-2034 D-10
script-execution path (double-safety gate, ephemeral workspace, args
passthrough) has only the unit/integration test suite to read, not a
runnable demonstration.

Expected behavior

A new, independently runnable actor in examples/packages/ whose agent
loads a skill bundling exactly one script, dispatches it via the skill
tool's execute: true path with only plain text/numeric arguments, and
whose script writes a real PDF file to disk — illustrating the full
discovery → activation → execution progressive-disclosure flow (§4.4.8)
end-to-end with a tangible, inspectable result (a PDF a human can open),
not just a text response.

Acceptance criteria

  • examples/packages/invoice-pdf-generator.yaml is a skill-type package
    that validates against cleveractors.agents.skill_schema.SkillValidator,
    declares safe_mode: false, and bundles exactly one resource,
    scripts/generate_invoice.py.
  • scripts/generate_invoice.py accepts only plain text/numeric CLI flags
    (invoice number/date, seller/customer name+address, one or more
    --item description:quantity:unit_price entries, tax rate, currency,
    notes, an optional output filename), computes the subtotal/tax/total, and
    writes a real, valid, single-page PDF — built from the Python standard
    library only, no third-party PDF dependency. Malformed/missing/non-ASCII
    input is rejected with a clear error and a non-zero exit code before any
    file is written.
  • examples/packages/invoice-agent.yaml is a type: llm agent
    (skills: ["local:invoice-pdf-generator.yaml"], safe_mode: false,
    allow_shell: true) whose system prompt never drafts PDF content itself —
    it only extracts plain text/numeric field values from the user's message
    and dispatches the skill tool with execute: true.
  • examples/packages/invoice-actor.yaml declares
    context.global.unsafe: true, resolves through LocalPackageStore/
    PackageContentResolver, and builds a real cleveractors.runtime.Executor
    without error (mirroring the issue #148 precedent).
  • Running the bundled script through the real execute: true gate (host
    --unsafe + skill safe_mode: false + agent allow_shell: true all
    satisfied) writes the generated PDF under an invoices/ folder resolved
    from the CLEVERACTORS_PROJECT_ROOT environment variable — which
    examples/test_app.py sets to its own launch directory — not inside the
    script's own ephemeral execution workspace (deleted immediately after the
    script exits per ADR-2034 D-10).
  • With the host not started in unsafe mode, building and running the
    actor refuses with UnsafeConfigurationError before any agent or script
    runs, per the actor's context.global.unsafe: true declaration.
  • examples/README.md documents the new example: what it does, its
    prerequisites, and an example test_app.py invocation.

Supporting information

  • Builds on Epic #160's script-execution gate (issues #161, #162, #163,
    #164, #165, #170, #171).
  • Mirrors the composition style and examples/ conventions issue #148
    established (local agent/skill packages, LocalPackageStore-resolved
    actor, README documentation, a .gitignore entry for generated output).
  • docs/actor-registry-standard.md §16 (Skill Package Schema) and
    docs/index.md §4.4.8 (Skill-loaded LLM agents, the double-safety gate)
    are the specification sections this example exercises.

Subtasks

  • Add invoice-pdf-generator.yaml skill package bundling
    scripts/generate_invoice.py (stdlib-only PDF writer) with a full
    SKILL.md-equivalent instructions field documenting the CLI.
  • Add invoice-agent.yaml LLM agent package that extracts plain
    text/numeric fields and dispatches the skill tool.
  • Add invoice-actor.yaml actor package wiring the agent into a
    single-node route with context.global.unsafe: true.
  • Wire CLEVERACTORS_PROJECT_ROOT into examples/test_app.py so the
    bundled script can resolve the project base path from inside its
    ephemeral execution workspace.
  • Document the example in examples/README.md; ignore its generated
    invoices/ output in .gitignore.
  • Validate: ruff/pyright clean on the script; the skill YAML passes
    SkillValidator; the full actor/agent/skill chain builds a real
    Executor; the skill's execute: true path runs through the real
    ToolAgent._skill_tool production code and produces a valid PDF; the
    actor correctly refuses without --unsafe.

Definition of Done

This issue is complete when:

  • All subtasks above are completed and checked off.
  • A Git commit is created where the first line matches the Commit Message
    in Metadata exactly.
  • The commit is pushed to the branch matching the Branch in Metadata
    exactly.
  • The commit is submitted as a PR to develop (this repository's actual
    integration branch — see recent merged PRs), reviewed, and merged.
## Metadata Commit Message: `feat(examples): add invoice PDF generator skill and actor example` Branch: feature/m1-invoice-pdf-skill-example ## Background and context Epic #160 (Agent Skills — Full Resource Support and Safe Execution) delivered the mechanics for bundling and gate-executing a skill's `scripts/` resource (issues #161-#171), but `examples/` has no runnable actor that actually exercises `execute: true` end-to-end and produces a real, useful artifact. The existing `examples/` demonstration (issue #148, calculator app) uses a skill only for its reference `instructions` (the `programming-patterns` skill has no `scripts/` resource at all) — it never drives the script- execution gate. This issue adds a second, independent `examples/` demonstration: an "invoice clerk" LLM agent that extracts plain text/numeric fields from a user's request and runs a bundled skill script that builds a real PDF invoice document, showing a genuine real-world use of `execute: true` alongside the calculator app's `instructions`-only skill usage. ## Current behavior No example in `examples/packages/` bundles or executes a skill script. A developer looking for a worked, runnable reference for the ADR-2034 D-10 script-execution path (double-safety gate, ephemeral workspace, `args` passthrough) has only the unit/integration test suite to read, not a runnable demonstration. ## Expected behavior A new, independently runnable actor in `examples/packages/` whose agent loads a skill bundling exactly one script, dispatches it via the `skill` tool's `execute: true` path with only plain text/numeric arguments, and whose script writes a real PDF file to disk — illustrating the full discovery → activation → execution progressive-disclosure flow (§4.4.8) end-to-end with a tangible, inspectable result (a PDF a human can open), not just a text response. ## Acceptance criteria - `examples/packages/invoice-pdf-generator.yaml` is a `skill`-type package that validates against `cleveractors.agents.skill_schema.SkillValidator`, declares `safe_mode: false`, and bundles exactly one resource, `scripts/generate_invoice.py`. - `scripts/generate_invoice.py` accepts only plain text/numeric CLI flags (invoice number/date, seller/customer name+address, one or more `--item description:quantity:unit_price` entries, tax rate, currency, notes, an optional output filename), computes the subtotal/tax/total, and writes a real, valid, single-page PDF — built from the Python standard library only, no third-party PDF dependency. Malformed/missing/non-ASCII input is rejected with a clear error and a non-zero exit code before any file is written. - `examples/packages/invoice-agent.yaml` is a `type: llm` agent (`skills: ["local:invoice-pdf-generator.yaml"]`, `safe_mode: false`, `allow_shell: true`) whose system prompt never drafts PDF content itself — it only extracts plain text/numeric field values from the user's message and dispatches the skill tool with `execute: true`. - `examples/packages/invoice-actor.yaml` declares `context.global.unsafe: true`, resolves through `LocalPackageStore`/ `PackageContentResolver`, and builds a real `cleveractors.runtime.Executor` without error (mirroring the issue #148 precedent). - Running the bundled script through the real `execute: true` gate (host `--unsafe` + skill `safe_mode: false` + agent `allow_shell: true` all satisfied) writes the generated PDF under an `invoices/` folder resolved from the `CLEVERACTORS_PROJECT_ROOT` environment variable — which `examples/test_app.py` sets to its own launch directory — not inside the script's own ephemeral execution workspace (deleted immediately after the script exits per ADR-2034 D-10). - With the host *not* started in unsafe mode, building and running the actor refuses with `UnsafeConfigurationError` before any agent or script runs, per the actor's `context.global.unsafe: true` declaration. - `examples/README.md` documents the new example: what it does, its prerequisites, and an example `test_app.py` invocation. ## Supporting information - Builds on Epic #160's script-execution gate (issues #161, #162, #163, #164, #165, #170, #171). - Mirrors the composition style and `examples/` conventions issue #148 established (local agent/skill packages, `LocalPackageStore`-resolved actor, README documentation, a `.gitignore` entry for generated output). - `docs/actor-registry-standard.md` §16 (Skill Package Schema) and `docs/index.md` §4.4.8 (Skill-loaded LLM agents, the double-safety gate) are the specification sections this example exercises. ## Subtasks - [x] Add `invoice-pdf-generator.yaml` skill package bundling `scripts/generate_invoice.py` (stdlib-only PDF writer) with a full `SKILL.md`-equivalent `instructions` field documenting the CLI. - [x] Add `invoice-agent.yaml` LLM agent package that extracts plain text/numeric fields and dispatches the skill tool. - [x] Add `invoice-actor.yaml` actor package wiring the agent into a single-node route with `context.global.unsafe: true`. - [x] Wire `CLEVERACTORS_PROJECT_ROOT` into `examples/test_app.py` so the bundled script can resolve the project base path from inside its ephemeral execution workspace. - [x] Document the example in `examples/README.md`; ignore its generated `invoices/` output in `.gitignore`. - [x] Validate: `ruff`/`pyright` clean on the script; the skill YAML passes `SkillValidator`; the full actor/agent/skill chain builds a real `Executor`; the skill's `execute: true` path runs through the real `ToolAgent._skill_tool` production code and produces a valid PDF; the actor correctly refuses without `--unsafe`. ## Definition of Done This issue is complete when: - All subtasks above are completed and checked off. - A Git commit is created where the first line matches the Commit Message in Metadata exactly. - The commit is pushed to the branch matching the Branch in Metadata exactly. - The commit is submitted as a PR to `develop` (this repository's actual integration branch — see recent merged PRs), reviewed, and merged.
CoreRasurae added this to the v2.1.0 milestone 2026-11-24 19:28:50 +00:00
Sign in to join this conversation.
No milestone
No project
No assignees
1 participant
Notifications
Due date
The due date is invalid or out of range. Please use the format "yyyy-mm-dd".

No due date set.

Reference
cleveragents/cleveractors-core#187
No description provided.