Skip to content

Commit d659c85

Browse files
mayoalexanderclaude
andcommitted
feat(agents): export an agent as a forkable folder (P4)
`agents pull` writes the raw API row to one .json file. That is right for its job — pull, edit, push against the same install — and wrong for handing to anyone else. The row carries 72 keys and most of them describe THIS install: user_id, bloq_id, stripe_product_id, total_revenue_cents, clone_count, health, google_workspace_*, last_heartbeat_at. Committing that to a public repo publishes a database row, not a shareable agent. `iris agents export <id>` writes a folder instead: agent.md frontmatter (name, model, heartbeat, tools) + the system prompt as the body — the file a person reads, diffs and edits tools.json the allowlist, resolved from all five places it is stored (settings.integrations / agentIntegrations / heartbeat_tools, config.tools, settings.tools) — deduped and sorted agent.json portable fields only, for re-import via `agents push --file` README.md what it is, how to import it, and what was left out Measured on real agents: 7 fields kept and 60 dropped for anomalyco#701, 8 and 60 for anomalyco#604. Two decisions worth stating. The README names every dropped field and why, grouped by reason. An export that silently loses fields is the same shape as a status board that reports success by not looking. Anything upstream adds that is in neither list is reported as "unclassified" at export time, so a new column surfaces as a question rather than vanishing — today that count is zero across all 72 keys. It scans for credential-shaped values before it tells a human to eyeball the folder. A warning nobody can act on is not a control. It WARNS rather than refuses: a false positive that blocks a legitimate export teaches people to reach for a skip flag, and then there is no check at all. Tests plant an api key, a bearer header, an email, a private key block and a long opaque token and assert each one fires — a scanner that could only ever print "nothing found" would be the guard-never-runs bug this repo keeps finding. Verified by running it, not by inspection: `bun run dev -- agents export 701|604` produces the folders above, no instance fields leak into agent.json or agent.md, and 10 unit tests pass. capabilities.json regenerated so the command is discoverable. Co-Authored-By: Claude Opus 5 <[email protected]>
1 parent e124352 commit d659c85

4 files changed

Lines changed: 337 additions & 5 deletions

File tree

‎packages/opencode/capabilities.json‎

Lines changed: 45 additions & 5 deletions
Original file line numberDiff line numberDiff line change
@@ -1,11 +1,11 @@
11
{
22
"generated_note": "GENERATED by script/build-capabilities.ts — do not edit by hand. Run `bun run capabilities` to refresh.",
33
"counts": {
4-
"command": 1259,
4+
"command": 1264,
55
"how-to": 39,
66
"playbook": 55,
77
"skill": 54,
8-
"total": 1407
8+
"total": 1412
99
},
1010
"terms": {
1111
"bespoke": [
@@ -142,7 +142,7 @@
142142
"describe": "manage IRIS platform agents — pull, push, diff, CRUD, assign",
143143
"aliases": [],
144144
"run": "iris agents",
145-
"haystack": "agents manage iris platform agents — pull, push, diff, crud, assign list get create update pull push diff delete bulk-delete chat assign message inbox thread bench list show compare record note ai agent assistant bot"
145+
"haystack": "agents manage iris platform agents — pull, push, diff, crud, assign list get create update pull push diff delete bulk-delete chat assign message inbox thread export bench list show compare record note ai agent assistant bot"
146146
},
147147
{
148148
"kind": "command",
@@ -240,6 +240,14 @@
240240
"run": "iris agents diff <id>",
241241
"haystack": "agents diff compare local agent json vs live api"
242242
},
243+
{
244+
"kind": "command",
245+
"name": "agents export",
246+
"describe": "export an agent as a forkable folder (portable fields only)",
247+
"aliases": [],
248+
"run": "iris agents export <id>",
249+
"haystack": "agents export export an agent as a forkable folder (portable fields only)"
250+
},
243251
{
244252
"kind": "command",
245253
"name": "agents get",
@@ -7121,7 +7129,7 @@
71217129
"describe": "IRIS Mint — budgets vs actuals for personal and business money",
71227130
"aliases": [],
71237131
"run": "iris mint",
7124-
"haystack": "mint iris mint — budgets vs actuals for personal and business money spend budgets status scope import scan merchants snapshot trend audit verify"
7132+
"haystack": "mint iris mint — budgets vs actuals for personal and business money spend budgets status scope import scan merchants snapshot trend audit verify scenario list show score"
71257133
},
71267134
{
71277135
"kind": "command",
@@ -7163,6 +7171,38 @@
71637171
"run": "iris mint scan",
71647172
"haystack": "mint scan audit audit local disk usage (read-only — never deletes anything)"
71657173
},
7174+
{
7175+
"kind": "command",
7176+
"name": "mint scenario",
7177+
"describe": "financial scenarios — model a distribution, then score it against actuals",
7178+
"aliases": [],
7179+
"run": "iris mint scenario",
7180+
"haystack": "mint scenario scenarios sim financial scenarios — model a distribution, then score it against actuals list show score"
7181+
},
7182+
{
7183+
"kind": "command",
7184+
"name": "mint scenario list",
7185+
"describe": "list events",
7186+
"aliases": [],
7187+
"run": "iris mint scenario list",
7188+
"haystack": "mint scenario list ls list events"
7189+
},
7190+
{
7191+
"kind": "command",
7192+
"name": "mint scenario score",
7193+
"describe": "compare a scenario's lines against actual booked revenue",
7194+
"aliases": [],
7195+
"run": "iris mint scenario score <name>",
7196+
"haystack": "mint scenario score compare a scenario's lines against actual booked revenue"
7197+
},
7198+
{
7199+
"kind": "command",
7200+
"name": "mint scenario show",
7201+
"describe": "one agreement with its full audit trail",
7202+
"aliases": [],
7203+
"run": "iris mint scenario show <id>",
7204+
"haystack": "mint scenario show get one agreement with its full audit trail"
7205+
},
71667206
{
71677207
"kind": "command",
71687208
"name": "mint scope",
@@ -10736,7 +10776,7 @@
1073610776
"describe": "Ship a bespoke (custom-HTML) Genesis /p/ page — a hand-designed HTML+CSS document published through the composable page builder. Two lanes — the CustomHtml component (raw HTML inside a composable page) and the standalone html template (full document via public-html blade). Handles the whole pipeline — write scoped HTML, build the page JSON, batch-publish, and verify the live /p/ render. Pass a subject brief or a slug as argument.",
1073710777
"aliases": [],
1073810778
"run": "iris playbook run bespoke",
10739-
"haystack": "bespoke ship a bespoke (custom-html) genesis /p/ page — a hand-designed html+css document published through the composable page builder. two lanes — the customhtml component (raw html inside a composable page) and the standalone html template (full document via public-html blade). handles the whole pipeline — write scoped html, build the page json, batch-publish, and verify the live /p/ render. pass a subject brief or a slug as argument. ---\nname: bespoke\ndescription: ship a bespoke (custom-html) genesis /p/ page — a hand-designed html+css document published through the composable page builder. two lanes — the customhtml component (raw html inside a composable page) and the standalone html template (full document via public-html blade). handles the whole pipeline — write scoped html, build the page json, batch-publish, and verify the live /p/ render. pass a subject brief or a slug as argument.\nallowed-tools:\n - read\n - edit\n - write\n - grep\n - glob\n - bash\n---\n\n# bespoke — custom-html genesis pages\n\n> ## stop — read the design standard before writing any html\n> `iris how-to view genesis-design-standard` · https://heyiris.io/p/design-philosophy-and-page-audit\n>\n> score the page against the **10-point audit** before publishing (9–10 ship · 6–8 revise · 0–5 redesign).\n> **check 01 predicts the rest:** could this design be moved onto a different subject unchanged?\n> if yes it is a template — restart from the subject, local fixes will not save it.\n>\n> three that silently break a genesis page:\n> 1. switch themes on **`html.dark`**, never `@media (prefers-color-scheme)` — the host owns the\n> theme, and a block that follows the os renders dark inside a light page.\n> 2. a customhtml block must **not paint its own `background`** — it becomes a floating slab.\n> 3. **namespace every selector** — `v-html` gives no isolation; bare `body`/`section`/`table` leak.\n>\n> and point 10: **render-verify in a browser.** grepping the served html is not verification.\n\n\npublish a hand-designed html page (audit report, one-pager, animated landing, spec sheet) as a live\ngenesis page at `https://heyiris.io/p/<slug>`. use this when the composable component catalog can't\nexpress the design and you want full html+css freedom.\n\n## arguments\n\n`$arguments` — a subject/brief (`\"bug-bounty payout audit\"`) or an existing slug to update.\n\n## two lanes — pick one\n\n| lane | what | when | how it renders |\n|------|------|------|----------------|\n| **customhtml component** | a raw-html block *inside* an otherwise-composable page (`components:[{type:customhtml,props:{html}}]`) | you want one bespoke section, or a full doc, but keep it in the normal page pipeline (tailwind loaded, theme toggle works) | iris-api renders the page; `customhtml.vue` injects your html via `v-html` **inline, no isolation** |\n| **standalone `html` template** | a *full* html document (`render_mode=html`, `iris pages create --template=html`) served by `public-html.blade.php` | a truly standalone page — arbitrary `<head>`, no framework, your own everything | the blade outputs your html with only a minimal baseline reset injected before your css |\n\ndefault to the **customhtml component** lane — it's what `pages:batch` supports cleanly and it inherits\nthe page shell + theme. reach for the standalone lane only when you need a bare document.\n\n## the recipe (customhtml lane) — proven\n\n### 1. write the html — scope every selector under a wrapper class\n\n`customhtml` injects via `v-html` **with no shadow dom / iframe**, so unscoped rules collide with the\ngenesis page shell in *both* directions. common class names (`.card`, `.tag`, `.status`, `.step`,\n`.meta`) and bare element selectors (`body`, `*`, `h1`, `table`) will clash.\n\n- wrap all content in one class: `<div class=\"xx\">…</div>`.\n- prefix **every** selector: `.xx .card{…}`, `.xx h2{…}`, `.xx *{box-sizing:border-box}`.\n- put css variables + base font/color on the wrapper: `.xx{--bg:…;background:var(--bg);…}` — **not** `:root`/`body`.\n- theme both modes at the wrapper: `@media (prefers-color-scheme:dark){.xx{--bg:…}}` **plus**\n `:root[data-theme=\"dark\"] .xx{…}` / `:root[data-theme=\"light\"] .xx{…}` (the viewer toggle stamps\n `data-theme` on the root).\n- fonts: **csp blocks font cdns** — use system stacks (`ui-monospace,…` / `-apple-system,…`), never a\n webfont `<link>`. use `font-variant-numeric:tabular-nums` for any column of figures.\n- design both light + dark; give heading custom html hand-designed page artifact branded page one-pager landing page report page custom css custom html hand-designed page artifact branded page one-pager landing page report page custom css custom html hand-designed page artifact branded page one-pager landing page report page custom css custom html hand-designed page artifact branded page one-pager landing page report page custom css custom html hand-designed page artifact branded page one-pager landing page report page custom css custom html hand-designed page artifact branded page one-pager landing page report page custom css custom html hand-designed page artifact branded page one-pager landing page report page custom css custom html hand-designed page artifact branded page one-pager landing page report page custom css custom html hand-designed page artifact branded page one-pager landing page report page custom css"
10779+
"haystack": "bespoke ship a bespoke (custom-html) genesis /p/ page — a hand-designed html+css document published through the composable page builder. two lanes — the customhtml component (raw html inside a composable page) and the standalone html template (full document via public-html blade). handles the whole pipeline — write scoped html, build the page json, batch-publish, and verify the live /p/ render. pass a subject brief or a slug as argument. ---\nname: bespoke\ndescription: ship a bespoke (custom-html) genesis /p/ page — a hand-designed html+css document published through the composable page builder. two lanes — the customhtml component (raw html inside a composable page) and the standalone html template (full document via public-html blade). handles the whole pipeline — write scoped html, build the page json, batch-publish, and verify the live /p/ render. pass a subject brief or a slug as argument.\nallowed-tools:\n - read\n - edit\n - write\n - grep\n - glob\n - bash\n---\n\n# bespoke — custom-html genesis pages\n\n> ## stop — read the design standard before writing any html\n> `iris how-to view genesis-design-standard` · https://heyiris.io/p/design-philosophy-and-page-audit\n>\n> score the page against the **10-point audit** before publishing (9–10 ship · 6–8 revise · 0–5 redesign).\n> **check 01 predicts the rest:** could this design be moved onto a different subject unchanged?\n> if yes it is a template — restart from the subject, local fixes will not save it.\n>\n> three that silently break a genesis page:\n> 1. switch themes on **`html.dark`**, never `@media (prefers-color-scheme)` — the host owns the\n> theme, and a block that follows the os renders dark inside a light page.\n> 2. a customhtml block must **not paint its own `background`** — it becomes a floating slab.\n> 3. **namespace every selector** — `v-html` gives no isolation; bare `body`/`section`/`table` leak.\n>\n> and point 10: **render-verify in a browser.** grepping the served html is not verification.\n\n\npublish a hand-designed html page (audit report, one-pager, animated landing, spec sheet) as a live\ngenesis page at `https://heyiris.io/p/<slug>`. use this when the composable component catalog can't\nexpress the design and you want full html+css freedom.\n\n## arguments\n\n`$arguments` — a subject/brief (`\"bug-bounty payout audit\"`) or an existing slug to update.\n\n## two lanes — pick one\n\n| lane | what | when | how it renders |\n|------|------|------|----------------|\n| **customhtml component** | a raw-html block *inside* an otherwise-composable page (`components:[{type:customhtml,props:{html}}]`) | you want one bespoke section, or a full doc, but keep it in the normal page pipeline (tailwind loaded, theme toggle works) | iris-api renders the page; `customhtml.vue` injects your html via `v-html` **inline, no isolation** |\n| **standalone `html` template** | a *full* html document (`render_mode=html`, `iris pages create --template=html`) served by `public-html.blade.php` | a truly standalone page — arbitrary `<head>`, no framework, your own everything | the blade outputs your html with only a minimal baseline reset injected before your css |\n\ndefault to the **customhtml component** lane — it's what `pages:batch` supports cleanly and it inherits\nthe page shell + theme. reach for the standalone lane only when you need a bare document.\n\n## the recipe (customhtml lane) — proven\n\n### 1. write the html — scope every selector under a wrapper class\n\n`customhtml` injects via `v-html` **with no shadow dom / iframe**, so unscoped rules collide with the\ngenesis page shell in *both* directions. common class names (`.card`, `.tag`, `.status`, `.step`,\n`.meta`) and bare element selectors (`body`, `*`, `h1`, `table`) will clash.\n\n- wrap all content in one class: `<div class=\"xx\">…</div>`.\n- prefix **every** selector: `.xx .card{…}`, `.xx h2{…}`, `.xx *{box-sizing:border-box}`.\n- put css variables + base font/color on the wrapper: `.xx{--bg:…;background:var(--bg);…}` — **not** `:root`/`body`.\n- theme both modes at the wrapper: `@media (prefers-color-scheme:dark){.xx{--bg:…}}` **plus**\n `:root[data-theme=\"dark\"] .xx{…}` / `:root[data-theme=\"light\"] .xx{…}` (the viewer toggle stamps\n `data-theme` on the root).\n- fonts: **csp blocks font cdns** — use system stacks (`ui-monospace,…` / `-apple-system,…`), never a\n webfont `<link>`. use `font-variant-numeric:tabular-nums` for any column of figures.\n- design both light + dark; give heading custom html hand-designed page artifact branded page one-pager landing page report page custom css custom html hand-designed page artifact branded page one-pager landing page report page custom css custom html hand-designed page artifact branded page one-pager landing page report page custom css custom html hand-designed page artifact branded page one-pager landing page report page custom css custom html hand-designed page artifact branded page one-pager landing page report page custom css custom html hand-designed page artifact branded page one-pager landing page report page custom css custom html hand-designed page artifact branded page one-pager landing page report page custom css custom html hand-designed page artifact branded page one-pager landing page report page custom css custom html hand-designed page artifact branded page one-pager landing page report page custom css custom html hand-designed page artifact branded page one-pager landing page report page custom css"
1074010780
},
1074110781
{
1074210782
"kind": "playbook",
Lines changed: 54 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,54 @@
1+
import { describe, expect, test } from "bun:test"
2+
import { scanForSecrets, collectTools, PORTABLE, DROPPED } from "./platform-agents-export"
3+
4+
/**
5+
* The scanner's whole job is to fire. A "no secrets found" line that could never say
6+
* anything else is the guard-reports-success-by-never-running shape this repo keeps
7+
* finding, so these plant each class and assert it is caught.
8+
*/
9+
describe("scanForSecrets", () => {
10+
test("catches an api key field", () => {
11+
expect(scanForSecrets('{"api_key":"sk-live-9s8d7f6g5h4j3k2l"}').length).toBeGreaterThan(0)
12+
})
13+
test("catches a bearer header", () => {
14+
expect(scanForSecrets("Authorization: Bearer eyJhbGciOiJIUzI1NiJ9abc").length).toBeGreaterThan(0)
15+
})
16+
test("catches an email address", () => {
17+
expect(scanForSecrets("escalate to [email protected]").some((h) => h.startsWith("email"))).toBe(true)
18+
})
19+
test("catches a private key block", () => {
20+
expect(scanForSecrets("-----BEGIN RSA PRIVATE KEY-----").length).toBeGreaterThan(0)
21+
})
22+
test("catches a long opaque token", () => {
23+
expect(scanForSecrets('{"x":"AKIAIOSFODNN7EXAMPLEAKIAIOSFODNN7EXAMPLE"}').length).toBeGreaterThan(0)
24+
})
25+
test("stays quiet on an ordinary prompt", () => {
26+
expect(scanForSecrets("You are a helpful chief of staff. Summarise the week.")).toEqual([])
27+
})
28+
})
29+
30+
describe("collectTools", () => {
31+
test("merges every place an allowlist is stored, dedupes and sorts", () => {
32+
expect(
33+
collectTools({
34+
settings: { integrations: ["b", "a"], agentIntegrations: [{ type: "c" }], heartbeat_tools: ["a"] },
35+
config: { tools: ["d"] },
36+
}),
37+
).toEqual(["a", "b", "c", "d"])
38+
})
39+
test("survives an agent with no tools anywhere", () => {
40+
expect(collectTools({})).toEqual([])
41+
})
42+
})
43+
44+
describe("field classification", () => {
45+
test("no field is both portable and dropped", () => {
46+
const dropped = new Set(Object.values(DROPPED).flat())
47+
expect(PORTABLE.filter((k) => dropped.has(k))).toEqual([])
48+
})
49+
test("instance-only fields are never portable", () => {
50+
for (const k of ["user_id", "bloq_id", "stripe_price_id", "total_revenue_cents", "health"]) {
51+
expect(PORTABLE).not.toContain(k as any)
52+
}
53+
})
54+
})

0 commit comments

Comments
 (0)