|
| 1 | +'use client'; |
| 2 | + |
| 3 | +import { useState } from 'react'; |
| 4 | + |
| 5 | +const MIGRATION_PROMPT = ` |
| 6 | +FULL Agentuity v0 → v1 Migration (Side-by-Side Project) |
| 7 | +You are a migration coding agent. Your task is to migrate an Agentuity v0 example project into a new Agentuity v1 project using the official "Migrating from v0 to v1" guide as the single source of truth. |
| 8 | +
|
| 9 | +Project Context |
| 10 | + The v0 project to migrate is located at: @<V0_PROJECT_FOLDER> |
| 11 | + This repository may contain multiple examples. |
| 12 | + You must only read files that belong to this v0 project. |
| 13 | + You must create the new v1 Agentuity project at the same directory level as the v0 project (a sibling folder). |
| 14 | + Do NOT modify or delete the v0 project. |
| 15 | +
|
| 16 | +High-Level Goal |
| 17 | +Migrate an Agentuity v0 example project into a new Agentuity v1 project using a strict, phase-based process. |
| 18 | +All project creation and filesystem changes must occur only when explicitly instructed in the relevant phase. |
| 19 | +
|
| 20 | +CRITICAL RULES (DO NOT VIOLATE) |
| 21 | + Do NOT edit any files in the v0 project |
| 22 | + Do NOT guess CLI prompt answers |
| 23 | + Do NOT invent APIs, patterns, or abstractions not present in the migration guide |
| 24 | + All new code must live only inside the newly created v1 project |
| 25 | + Follow migration phases in order |
| 26 | + Preserve behavior exactly unless a change is explicitly required by v1 |
| 27 | +
|
| 28 | +
|
| 29 | +Phase 0 — Authentication & CLI Readiness (REQUIRED) |
| 30 | +This phase is a PASS/FAIL gate. |
| 31 | +You are NOT allowed to debug, repair, or modify the environment. |
| 32 | +
|
| 33 | +ABSOLUTE RULES: |
| 34 | + Do NOT inspect node_modules |
| 35 | + Do NOT uninstall packages |
| 36 | + Do NOT reinstall more than once |
| 37 | + Do NOT attempt root-cause analysis |
| 38 | + Do NOT retry failed commands |
| 39 | + Do NOT infer fixes |
| 40 | + Do NOT modify the filesystem |
| 41 | +
|
| 42 | +Steps (in order): |
| 43 | + Check that the Agentuity CLI is available |
| 44 | + Run: agentuity --version |
| 45 | + If command is not found, install with full permissions via: |
| 46 | + curl -sSL https://agentuity.sh | sh |
| 47 | + Re-check version |
| 48 | + Ensure the CLI is up to date. |
| 49 | + If the CLI was installed via the Agentuity installer: |
| 50 | + Run: agentuity upgrade |
| 51 | + If the CLI reports it is installed as a project dependency: |
| 52 | + Run: bun add @agentuity/cli@latest |
| 53 | + If the upgrade fails, surface the error and stop. |
| 54 | + Do not force reinstall unless explicitly instructed |
| 55 | + Confirm authentication |
| 56 | + Run: agentuity auth whoami |
| 57 | + If not authenticated: |
| 58 | + Run: agentuity auth login |
| 59 | + Wait for the user to complete browser login |
| 60 | + Re-run agentuity auth whoami |
| 61 | + Once authenticated, proceed immediately |
| 62 | + Do not retry |
| 63 | + Do not re-check |
| 64 | + Do not reinstall again |
| 65 | +
|
| 66 | +That's it. |
| 67 | +No filesystem changes. No heuristics. |
| 68 | +
|
| 69 | +
|
| 70 | +Phase 1 — Comprehensive v0 Project Scan |
| 71 | +Recursively scan all files and folders that belong to the v0 project, including (but not limited to): |
| 72 | + src/agent*, src/agents* |
| 73 | + src/api*, src/routes* |
| 74 | + src/tools/ |
| 75 | + src/utils/, src/helpers/, src/lib/ |
| 76 | + Any other files contributing to runtime behavior or business logic |
| 77 | +
|
| 78 | +Identify and Categorize |
| 79 | + Agent handlers using @agentuity/sdk or AgentHandler |
| 80 | + HTTP endpoints or request parsing logic |
| 81 | + Tooling modules (tools/, utils/, helpers/, etc.) |
| 82 | + Shared helpers or services used by agents |
| 83 | + Any usage of: |
| 84 | + context.runId |
| 85 | + context.getAgent |
| 86 | + context.objectstore |
| 87 | + KV / Vector stores |
| 88 | + Cron, email, or SMS triggers |
| 89 | +
|
| 90 | +
|
| 91 | +Output Required |
| 92 | +Produce a complete migration inventory listing: |
| 93 | + Agents found (with file paths) |
| 94 | + Routes / endpoints found |
| 95 | + Tool / helper modules and where they're used |
| 96 | + Cross-agent calls |
| 97 | + Services used |
| 98 | +
|
| 99 | +Do NOT begin migration until this inventory is shown. |
| 100 | +
|
| 101 | +
|
| 102 | +Phase 2 — Create Fresh v1 Project (CLI-Driven) |
| 103 | +Rules for Phase 2 |
| 104 | + Do NOT prompt for region |
| 105 | + Do NOT prompt for template |
| 106 | + Do NOT prompt for org |
| 107 | + Do NOT retry creation |
| 108 | + Do NOT auto-detect templates |
| 109 | +
|
| 110 | +Canonical command |
| 111 | + agentuity create \\ |
| 112 | + --name <v1-project-name> \\ |
| 113 | + --region use \\ |
| 114 | + --template default |
| 115 | +
|
| 116 | +Where: |
| 117 | +<v1-project-name> = <v0-project-name>-v1 |
| 118 | +
|
| 119 | +Example: |
| 120 | +tool-calling → tool-calling-v1 |
| 121 | +
|
| 122 | +That's it. If this fails, surface the error and stop. |
| 123 | +
|
| 124 | +Directory Semantics (CRITICAL) |
| 125 | +The Agentuity CLI creates a new project directory inside the directory passed to it. Therefore: |
| 126 | + The directory you pass must be the parent directory, not the final project directory |
| 127 | + Do NOT pre-create the v1 project folder |
| 128 | + Expect the CLI to create the project folder itself |
| 129 | + If the CLI creates a nested directory, detect it and treat the inner folder as the project root |
| 130 | +
|
| 131 | +Project Creation Rules |
| 132 | + Create the v1 project at the same directory level as the v0 project |
| 133 | + Since the user is authenticated, the project must be created and registered with Agentuity Cloud |
| 134 | +
|
| 135 | +Dependency Installation Caveat |
| 136 | +If dependency installation fails inside the sandbox (for example, due to Bun temp directory permissions): |
| 137 | + Explicitly note the failure |
| 138 | + Re-run dependency installation outside the sandbox |
| 139 | + Continue only once dependencies install successfully |
| 140 | +
|
| 141 | +
|
| 142 | +Phase 3 — Prepare v1 Structure |
| 143 | +Confirm the new v1 project contains: |
| 144 | + src/agent/ |
| 145 | + src/api/index.ts |
| 146 | + v1 runtime dependencies from the scaffold (for example: @agentuity/runtime, @agentuity/schema) |
| 147 | +
|
| 148 | +Exception: |
| 149 | +If the v1 scaffold includes a default demo agent or frontend (for example, a "translate" agent) that was not part of the v0 project: |
| 150 | + Remove the unused demo agent folder. |
| 151 | + Update the existing frontend to match the migrated v0 agent's actual functionality. |
| 152 | +
|
| 153 | +Otherwise, do NOT modify the scaffold files. |
| 154 | +
|
| 155 | +
|
| 156 | +Phase 4 — Migrate Agents (Guide Steps 2 + 3) |
| 157 | +For each v0 agent, create the file: |
| 158 | + src/agent/<agent-name>/agent.ts |
| 159 | +
|
| 160 | +Convert |
| 161 | + AgentHandler → createAgent() |
| 162 | + (request, response, context) → (ctx, input) |
| 163 | + response.*() → direct return values |
| 164 | +
|
| 165 | +Replace context usage |
| 166 | + context.runId → ctx.sessionId |
| 167 | + context.logger → ctx.logger |
| 168 | + context.kv → ctx.kv |
| 169 | +
|
| 170 | +Schema Rules (IMPORTANT — Type Safety) |
| 171 | + Define explicit input and output schemas for every migrated agent |
| 172 | + Prefer using @agentuity/schema for schema definitions, as it is the v1-native, type-safe approach |
| 173 | + Fall back to Zod only when a schema cannot be reasonably expressed using @agentuity/schema |
| 174 | + If the v0 agent did not define schemas explicitly, infer the minimal correct schema from actual usage without changing behavior |
| 175 | +
|
| 176 | +Additional Rules |
| 177 | + Remove all request parsing logic from agent files |
| 178 | + Preserve original business logic exactly unless a change is explicitly required by v1 |
| 179 | + If deprecated imports are detected, replace them with the correct v1-compatible alternatives and explicitly note why the change was required |
| 180 | +
|
| 181 | +
|
| 182 | +Phase 5 — Migrate Supporting Files (Tools, Utils, Helpers) |
| 183 | +For each non-agent functional file identified in Phase 1: |
| 184 | + Recreate the file inside the new v1 project (for example: src/tools/, src/utils/) |
| 185 | + Update imports to match the new structure |
| 186 | + Do NOT change behavior unless required for v1 compatibility |
| 187 | + Ensure all agents and routes reference these files correctly |
| 188 | +
|
| 189 | +
|
| 190 | +Phase 6 — Migrate Dependencies |
| 191 | +Inspect the v0 project's package.json and extract dependencies and devDependencies. |
| 192 | +Cross-reference them against actual imports found in: |
| 193 | + Agents |
| 194 | + Routes |
| 195 | + Tools / utils / helpers |
| 196 | +
|
| 197 | +Rules |
| 198 | + v0-only dependencies (for example: @agentuity/sdk) must NOT be migrated |
| 199 | + If a dependency has a v1 replacement, use the v1 equivalent |
| 200 | + If a dependency is general-purpose and still used, add it to the v1 project |
| 201 | + Do NOT copy the v0 package.json wholesale |
| 202 | + Do NOT remove scaffold dependencies unless you confirm they are unused |
| 203 | + Prefer bun install or bun add unless the scaffold indicates otherwise |
| 204 | +
|
| 205 | +Output Required |
| 206 | +Provide a summary listing: |
| 207 | + Removed dependencies |
| 208 | + Replaced dependencies |
| 209 | + Added dependencies |
| 210 | +
|
| 211 | +
|
| 212 | +Phase 7 — Migrate Routes (Guide Steps 4 + 5) |
| 213 | +In src/api/index.ts: |
| 214 | + Import agents using @agent/<agent-name> |
| 215 | + Parse input via c.req.json() or agent.validator() |
| 216 | + Call agents using agent.run(input) |
| 217 | + Return responses using c.json(), c.text(), or c.body() |
| 218 | +
|
| 219 | +If the generated v1 build or type registry fails due to unresolved agent imports |
| 220 | +(for example, missing 'index' in generated import paths): |
| 221 | + Add a minimal barrel re-export file at src/agent/<agent-name>.ts that re-exports the agent's index module. |
| 222 | + Do NOT change the agent implementation itself. |
| 223 | +
|
| 224 | +
|
| 225 | +Phase 8 — Migrate Services (Guide Step 6) |
| 226 | + KV / Vector storage remains unchanged |
| 227 | + Replace context.objectstore with Bun S3 |
| 228 | + Replace expiresDuration with expiresIn |
| 229 | + Migrate database usage only if the v0 project already used one |
| 230 | +
|
| 231 | +
|
| 232 | +Phase 9 — Agent-to-Agent Communication (Guide Step 7) |
| 233 | + Replace context.getAgent with direct imports |
| 234 | + Call other agents using otherAgent.run(input) |
| 235 | + Remove JSON stringification and manual parsing |
| 236 | +
|
| 237 | +
|
| 238 | +Phase 10 — Final Validation |
| 239 | +Provide a checklist confirming: |
| 240 | + v0 project remains untouched |
| 241 | + New v1 project created successfully |
| 242 | + All functional files (agents, tools, helpers) migrated |
| 243 | + No @agentuity/sdk imports remain |
| 244 | + No request/response usage inside agents |
| 245 | + Routes live in src/api/index.ts |
| 246 | + Services migrated correctly |
| 247 | + Typecheck passes |
| 248 | + Build passes |
| 249 | +
|
| 250 | +Output Requirements |
| 251 | + Show progress phase by phase |
| 252 | + Include full file contents for any files created or modified |
| 253 | + Clearly indicate when user input is required in the terminal |
| 254 | +
|
| 255 | +
|
| 256 | +Begin Now |
| 257 | + Start with Phase 0 (Authentication & CLI Readiness), then proceed to Phase 1 by scanning the v0 project located at: |
| 258 | + @<V0_PROJECT_FOLDER>`; |
| 259 | + |
| 260 | +export function CopyMigrationPrompt() { |
| 261 | + const [copied, setCopied] = useState(false); |
| 262 | + |
| 263 | + async function handleCopy() { |
| 264 | + try { |
| 265 | + await navigator.clipboard.writeText(MIGRATION_PROMPT); |
| 266 | + setCopied(true); |
| 267 | + setTimeout(() => setCopied(false), 2000); |
| 268 | + } catch (error) { |
| 269 | + console.error('Failed to copy to clipboard:', error); |
| 270 | + } |
| 271 | + } |
| 272 | + |
| 273 | + return ( |
| 274 | + <div className="my-4 flex items-center"> |
| 275 | + <button |
| 276 | + type="button" |
| 277 | + onClick={handleCopy} |
| 278 | + className=" |
| 279 | + inline-flex items-center gap-2 |
| 280 | + rounded-md px-3 py-1.5 |
| 281 | + text-sm font-medium |
| 282 | + border |
| 283 | + border-[color:var(--color-cyan-700)] |
| 284 | + text-[color:var(--color-cyan-700)] |
| 285 | + hover:bg-[color:var(--color-cyan-50)] |
| 286 | + hover:text-[color:var(--color-cyan-800)] |
| 287 | + transition |
| 288 | + dark:border-[color:var(--color-cyan-500)] |
| 289 | + dark:text-[color:var(--color-cyan-500)] |
| 290 | + dark:hover:bg-[rgba(0,255,255,0.08)] |
| 291 | + " |
| 292 | + > |
| 293 | + {copied ? 'Copied ✓' : 'Copy Migration Prompt'} |
| 294 | + </button> |
| 295 | + </div> |
| 296 | + ); |
| 297 | +} |
0 commit comments