Skip to content

feat(templates): agent-provided data schema (no human note) + paste-able reuse prompt#184

Merged
ivanmkc merged 2 commits into
masterfrom
feat/templates-schema
Jun 11, 2026
Merged

feat(templates): agent-provided data schema (no human note) + paste-able reuse prompt#184
ivanmkc merged 2 commits into
masterfrom
feat/templates-schema

Conversation

@ivanmkc

@ivanmkc ivanmkc commented Jun 11, 2026

Copy link
Copy Markdown
Owner

Why

Two pieces of user feedback:

  1. Don't make the human write a "Note for your agent." A board should arrive already decomposed — the agent attaches a data schema when it pushes — and "save as template" captures that automatically.
  2. Make reuse + the library discoverable ("how do I make an agent reuse this? where's my library?").

What

Schema on push (no human note):

  • core: TemplateSchema + validateTemplateSchema — lightweight, optional: { summary?, fields:[{name, description, type?, example?}] }.
  • server: asPayload carries optional schema; push 400s a malformed one; save captures board.schema (not a request field).
  • state/template-store: Payload.schema, Template.schema; create() takes the schema (drops hints); legacy hints still read.
  • CLI: push --schema <file>; template get prints the SCHEMA (fields) before the example; save drops --hints.

UI (the Templates popover):

  • Save panel: no note textarea — shows "✓ Data schema captured (N fields)" (or a hint to push with --schema).
  • After save: a ready-to-paste reuse prompt (copied): "Reuse termchart template <id> (a <type>): run termchart template get <id> … build a new diagram with my data that fits the schema and push it."
  • Library = the Saved templates list with a sub-label ("your library — paste a template's reuse prompt to an agent…"); each row has Copy reuse prompt + Schema (renders the fields) + Delete.

Docs: SKILL + diagram-remote — attach --schema at push; reuse = read schema, author a conforming diagram, push.

Compatibility

Schema is optional everywhere; legacy templates (free-text hints) and plain pushes still work. Reuse stays agent-authored (no server-side merge).

Verification

  • Unit: viewer 458, CLI 172 (new validateTemplateSchema; store/server round-trip schema + read legacy hints; CLI save(no hints)/get(schema)).
  • e2e: template 17/17 (no note field; schema captured + returned; paste-able reuse prompt; library row affordance) + rich 62, board-sort 12, responsive 20. Build exit 0; NUL-byte check clean. Screenshotted the new popover.

Rebased on #183 (responsive). Supersedes the note flow from #182.

…"note"

User feedback: don't make the human write a "Note for your agent" when saving a
template. Instead, a board arrives already decomposed — the agent attaches a data
SCHEMA (the data fields + descriptions) when it pushes — and "save as template"
captures that automatically.

- core: `TemplateSchema` type + `validateTemplateSchema` (optional, lightweight:
  { summary?, fields:[{name, description, type?, example?}] }).
- server: `asPayload` carries an optional `schema`; the push handler 400s a
  malformed one; "save template" captures `board.schema` (not a request field).
- state/template-store: `Payload.schema`, `Template.schema`; `create()` takes the
  schema (drops the `hints` param); legacy `hints` still read for back-compat.
- CLI: `push --schema <file>`; `template get` prints the SCHEMA (fields) before
  the example; `save` no longer takes `--hints`.
- UI: the Save-as-template popover removes the note textarea entirely — it shows
  "✓ Data schema captured (N fields)" (or a hint to push with --schema), and the
  library row's action is "Schema" (renders the fields, or a legacy note).
- docs: SKILL + diagram-remote — attach `--schema` at push; reuse = read schema,
  author a conforming diagram, push. (Removes the WHAT/DATA-SLOTS human scaffold.)

Backward compatible: schema optional everywhere; legacy templates + plain pushes
still work. Reuse stays agent-authored (no server-side merge).

Tests: core validateTemplateSchema; store/server carry + round-trip schema +
read legacy hints; CLI save(no hints)/get(schema); template.e2e (no note field,
schema captured + returned). viewer 458, CLI 172, e2e template 16/16.
Answer two user questions in the UI itself:
- "how do I make an agent reuse this?" — after saving, the result now shows a
  ready-to-paste instruction (copied to the clipboard): "Reuse termchart template
  <id> (a <type>): run `termchart template get <id>` … build a new diagram with my
  data that fits the schema and push it." Each library row gets a "Copy reuse
  prompt" action with the same.
- "where's my library?" — the Saved-templates list (in the Templates popover) now
  has a sub-label: "your library — paste a template's reuse prompt to an agent to
  rebuild it with new data."

e2e: assert the paste-able prompt on save + the row affordance.
@ivanmkc ivanmkc merged commit 3500d57 into master Jun 11, 2026
5 checks passed
@ivanmkc ivanmkc deleted the feat/templates-schema branch June 11, 2026 20:36
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.

2 participants