Luigit
repositories / pi-ext

pi-ext

bugabingas pi extensions

owned by admin

extensions/the-system/demo/scene.json

Raw
{
	"title": "the-system",
	"extensions": ["the-system", "footer", "model-info", "nu-bang"],
	"args": ["--extension", "builtin:tool-search", "--tools", "+tool_search"],
	"cols": 100,
	"rows": 30,
	"files": {
		"src/upload.ts": "export async function upload(file: string): Promise<void> {\n\t// TODO retry\n}\n"
	},
	"turns": [
		{
			"text": "Finding System tools.",
			"tool": {
				"name": "tool_search",
				"arguments": {
					"query": "system_bundle_slot system_board_propose system_board_update",
					"limit": 8
				}
			},
			"usage": {
				"input": 4000,
				"output": 20
			}
		},
		{
			"text": "Reserving a phase bundle for stabilize.",
			"tool": {
				"name": "system_bundle_slot",
				"arguments": {
					"type": "phase",
					"title": "Stabilize"
				}
			},
			"usage": {
				"input": 4100,
				"output": 40
			}
		},
		{
			"tool": {
				"name": "write",
				"arguments": {
					"path": "{slot.path}",
					"content": "---\nid: {slot.id}\ntype: phase\ntitle: Stabilize\nlabel: stabilize\n---\n\n## Sub-mission\n\nMake uploads boringly reliable before adding features.\n\n## Ranked priorities\n\n1. No lost uploads.\n2. Clear failure reporting.\n3. Throughput.\n\n## Decision defaults\n\n| Concern | Default |\n| --- | --- |\n| Compatibility | Keep the public upload API unchanged. |\n| Debt | Remove ad-hoc retry loops instead of adding more. |\n\n## Non-goals\n\nNew upload targets.\n\n## Observable exit criteria\n\n- [ ] Flaky-network uploads succeed or fail with one actionable error.\n- [ ] No retry logic outside the retry policy module.\n"
				}
			},
			"usage": {
				"input": 4400,
				"output": 210
			}
		},
		{
			"text": "Phase written. Shall I make it the current phase? I will update config.json only with your confirmation.",
			"tool": {
				"name": "write",
				"arguments": {
					"path": ".system/config.json",
					"content": "{\n\t\"prefix\": \"DEMO\",\n\t\"schemaVersion\": 0,\n\t\"title\": \"the-system\",\n\t\"currentPhase\": \"{slot.id}\"\n}\n"
				}
			},
			"usage": {
				"input": 4700,
				"output": 60
			}
		},
		{
			"text": "Current phase is now stabilize.\n\nView:\n/system view {slot.id}",
			"usage": {
				"input": 4900,
				"output": 20
			}
		},
		{
			"text": "Reserving a spec bundle.",
			"tool": {
				"name": "system_bundle_slot",
				"arguments": {
					"type": "spec",
					"title": "Retry policy for flaky uploads"
				}
			},
			"usage": {
				"input": 5200,
				"output": 30
			}
		},
		{
			"tool": {
				"name": "write",
				"arguments": {
					"path": "{slot.path}",
					"content": "---\nid: {slot.id}\ntype: spec\ntitle: Retry policy for flaky uploads\n---\n\n## Intent\n\nAn upload that fails transiently retries with backoff; one that fails permanently reports once.\n\n## Behavior\n\n```mermaid\nstateDiagram-v2\n  [*] --> Sending\n  Sending --> Done: 2xx\n  Sending --> Backoff: timeout | 5xx\n  Backoff --> Sending: attempt < 4\n  Backoff --> Failed: attempt = 4\n  Sending --> Failed: 4xx\n  Done --> [*]\n  Failed --> [*]\n```\n\n## Constraints\n\n- Backoff doubles from 200 ms, capped at 2 s.\n- 4xx never retries.\n\n## Acceptance criteria\n\n- [ ] Three timeouts then a 2xx completes the upload.\n- [ ] A 400 fails on the first attempt with the server message.\n- [ ] Four timeouts fail with the last error and the attempt count.\n"
				}
			},
			"usage": {
				"input": 5600,
				"output": 260
			}
		},
		{
			"text": "Spec written with one state model and three acceptance criteria.\n\nView:\n/system view {slot.id}",
			"usage": {
				"input": 5900,
				"output": 24
			}
		},
		{
			"text": "Reserving a plan bundle for that spec.",
			"tool": {
				"name": "system_bundle_slot",
				"arguments": {
					"type": "plan",
					"title": "Retry policy slices"
				}
			},
			"usage": {
				"input": 6200,
				"output": 30
			}
		},
		{
			"tool": {
				"name": "write",
				"arguments": {
					"path": "{slot.path}",
					"content": "---\nid: {slot.id}\ntype: plan\ntitle: Retry policy slices\nspec: {spec.id}\nstatus: draft\n---\n\n## Outcome\n\nUploads follow the retry state model; no other retry loop remains.\n\n## Behaviors\n\n```mermaid\nflowchart LR\n  b1[\"1. transient failure retries with backoff\"] --> b2[\"2. permanent failure reports once\"]\n  b2 --> b3[\"3. legacy retry loops removed\"]\n```\n\n## Module structure\n\n- `src/retry.ts` owns the policy and backoff.\n- `src/upload.ts` calls it and stays API-compatible.\n\n## Verification\n\n- [ ] Unit tests for the three acceptance criteria.\n"
				}
			},
			"usage": {
				"input": 6600,
				"output": 200
			}
		},
		{
			"text": "Plan written as status: draft; approval is yours.\n\nView:\n/system view {slot.id}",
			"usage": {
				"input": 6900,
				"output": 24
			}
		},
		{
			"text": "Status: approved needs your explicit approval; I will not set it myself. Approve the plan and I will start exec.",
			"usage": {
				"input": 7200,
				"output": 30
			}
		},
		{
			"text": "Approved by you; marking the plan.",
			"tool": {
				"name": "edit",
				"arguments": {
					"path": "{slot.path}",
					"edits": [
						{
							"oldText": "status: draft",
							"newText": "status: approved"
						}
					]
				}
			},
			"usage": {
				"input": 7500,
				"output": 30
			}
		},
		{
			"text": "Plan approved; exec can start whenever you call it.",
			"usage": {
				"input": 7700,
				"output": 16
			}
		},
		{
			"text": "Slice 1: transient failures retry with backoff.",
			"tool": {
				"name": "write",
				"arguments": {
					"path": "src/retry.ts",
					"content": "export async function withRetry<T>(run: () => Promise<T>): Promise<T> {\n\tlet delay = 200;\n\tfor (let attempt = 1; ; attempt++) {\n\t\ttry {\n\t\t\treturn await run();\n\t\t} catch (error) {\n\t\t\tif (attempt === 4 || !isTransient(error)) throw error;\n\t\t\tawait new Promise((r) => setTimeout(r, delay));\n\t\t\tdelay = Math.min(delay * 2, 2000);\n\t\t}\n\t}\n}\n\nfunction isTransient(error: unknown): boolean {\n\treturn error instanceof Error && /timeout|5\\d\\d/.test(error.message);\n}\n"
				}
			},
			"usage": {
				"input": 7900,
				"output": 180
			}
		},
		{
			"text": "Verified: three timeouts then success completes; a 400 fails once. Recording the proven state.",
			"tool": {
				"name": "system_board_update",
				"arguments": {
					"items": [
						{
							"id": "{slot.id}",
							"state": "done",
							"note": "retry.ts implements all three behaviors; tests green"
						},
						{
							"id": "{spec.id}",
							"state": "done",
							"note": "acceptance criteria verified"
						}
					]
				}
			},
			"usage": {
				"input": 8300,
				"output": 60
			}
		},
		{
			"text": "Board updated.\n\nView:\n/system view {spec.id}",
			"usage": {
				"input": 8500,
				"output": 14
			}
		}
	],
	"steps": [
		{
			"expect": "ctrl\\+o",
			"hold": 6
		},
		{
			"type": "/system init DEMO",
			"key": "enter",
			"expect": "Initialize The System",
			"timeout": 20000,
			"hold": 8
		},
		{
			"key": "enter",
			"fresh": true,
			"expect": "Initialized The System",
			"hold": 10.0
		},
		{
			"type": "/system phase stabilize: reliable uploads first",
			"key": "enter",
			"expect": "Shall I make it the current phase",
			"timeout": 30000,
			"hold": 8
		},
		{
			"expect": "The System phase transition",
			"timeout": 20000,
			"hold": 6
		},
		{
			"key": "enter",
			"fresh": true,
			"expect": "Current phase is now stabilize",
			"timeout": 20000,
			"hold": 10.0
		},
		{
			"type": "/system spec retry policy for flaky uploads",
			"key": "enter",
			"expect": "three acceptance criteria",
			"timeout": 30000,
			"hold": 12
		},
		{
			"type": "/system plan",
			"key": "enter",
			"expect": "approval is yours",
			"timeout": 30000,
			"hold": 10.0
		},
		{
			"type": "/system doctor",
			"key": "enter",
			"expect": "System doctor OK",
			"timeout": 20000,
			"hold": 10.0
		},
		{
			"type": "mark it approved and start exec",
			"key": "enter",
			"expect": "needs your explicit approval",
			"timeout": 30000,
			"hold": 12
		},
		{
			"type": "approved",
			"key": "enter",
			"expect": "The System document approval",
			"timeout": 30000,
			"hold": 8
		},
		{
			"key": "enter",
			"fresh": true,
			"expect": "exec can start",
			"timeout": 20000,
			"hold": 10.0
		},
		{
			"type": "/system exec",
			"key": "enter",
			"expect": "2 board changes applied",
			"timeout": 30000,
			"hold": 12
		},
		{
			"type": "/system doctor",
			"key": "enter",
			"expect": "System doctor OK",
			"timeout": 20000,
			"hold": 8
		},
		{
			"type": "!!ls .system/**/index.md | get name",
			"key": "enter",
			"expect": "plans[\\\\/]DEMO-PLAN",
			"hold": 16
		},
		{
			"key": "ctrl-c",
			"hold": 0.3
		},
		{
			"key": "ctrl-c"
		}
	]
}