Skip to content

Add script_create: create jobs from scripts with a stable contract - #5

Merged
bmanturner merged 1 commit into
mainfrom
feat/script-create-intent
Nov 5, 2026
Merged

bmanturner merged 1 commit into
mainfrom
feat/script-create-intent

Conversation

@bmanturner

@bmanturner bmanturner commented Nov 5, 2026 •

Copy link
Copy Markdown
Owner

Adds script_create, a new intent kind that gives scripts, CI and other agents a supported way to create jobs. Until now the only route was carly_create, Carly's internal message. Using it marked jobs by Carly, announced them as "Carly scheduled …", and relied on fields that were never meant to be stable.

Credit to @roverdude24: their #4 documented how to create jobs by writing carly_create intents. That showed scripts need a supported way to do this. This PR builds it as a separate public kind, so carly_create stays internal and script-made jobs aren't labelled as Carly's.

Contract (README → "From a script")

  • Write one JSON file to <data folder>/intents/<digits>-<alnum>-<digits>.json. Write it under a temporary name and rename it into place. Agent Scheduler answers in replies/<reply>.json, usually within 2–3 s.
  • Fields:
    • Required: format: 1, kind: "script_create", reply (12 × a-z0-9), prompt, when, folder.
    • Optional: name, role, quiet_ok, only_when (same flat keys as Carly), source (1–24 × [A-Za-z0-9_-]) and expires (unix seconds).
  • Validation is strict. An unknown field such as approval or cwd is refused with Unknown field "…"., and a wrong type gets a specific message. A typo can't quietly produce a Hands-off job.
  • The job is active immediately with the Settings default approval, the same as Carly's jobs. A request can't choose its approval.
  • The manager marks the job by <source>, or by script when there is no source; narrow layouts show ⚙. The toast and desktop notification read " scheduled …", or "A script scheduled …" without a source. The source is stored on the job as created_source and kept through edits and reloads; an invalid hand-edited value is cleared on load.
  • Success reply: job_id, name, when, next, next_at (new; unix seconds), folder, role, approval, only_when, quiet_ok, source. Failure reply: {ok:false, error}, using the same wording the form shows.

Implementation

  • carly_create's body is now a shared create_job(reply, fields, origin, h). carly_create and script_create are thin wrappers around it. Carly keeps her lenient truncation and prompt cap. Her notification text and stored created_by are unchanged.
  • jobs.create takes an optional source. created_by can now be user, carly or script.
  • mgr_common.creator_mark replaces the two copies of the Carly check in the list and live views.
  • AGENTS.md gains a "Public contracts" note: fields may only be added as optional, and format changes only for a breaking change.

Testing

  • bun run test: all files pass. New cases cover:
    • success with and without source
    • default approval, the snapshot, the notification text
    • unknown and mistyped fields
    • expires
    • Carly's marking, which is unchanged
    • the creator toasts
  • A live smoke run against a linked plugin: the README's shell flow got the expected Unknown field "approval". reply.

The version bump and CHANGELOG entry are left for release time.

@bmanturner
bmanturner merged commit f6ac42c into main Nov 5, 2026
1 check passed
@bmanturner
bmanturner deleted the feat/script-create-intent branch November 5, 2026 17:11
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

None yet

Projects

None yet

Development

Successfully merging this pull request may close these issues.

1 participant