|
| 1 | +# Transfer TUI Wizard Design |
| 2 | + |
| 3 | +## Status |
| 4 | + |
| 5 | +Approved direction: `agentic-stack transfer` opens a TUI wizard that matches the existing onboarding wizard style. The generated curl command is an output of the wizard, not the primary interface. |
| 6 | + |
| 7 | +## Problem |
| 8 | + |
| 9 | +Users want to move their agentic-stack memory and setup instructions across Codex, Cursor, Windsurf, and plain terminal environments without learning each tool's memory and rules file conventions. A one-line curl command is useful for moving the bundle into another project or machine, but the decision process is too sensitive for a raw command: users need to see what memory will move, which target harness files will be installed, and what will be merged before anything writes to disk. |
| 10 | + |
| 11 | +## Research Findings |
| 12 | + |
| 13 | +- Codex reads `AGENTS.md` guidance before work and supports layered global/project instruction discovery. Required team guidance should live in `AGENTS.md` or checked-in docs, not in generated Codex memory files. |
| 14 | +- Codex skills are discovered from `.agents/skills` along the current directory to repository root path, and symlinked skill folders are supported. |
| 15 | +- Codex memories are generated local state under `~/.codex/memories/`; importing agentic-stack memory should not edit those files. |
| 16 | +- Cursor supports project rules in `.cursor/rules/*.mdc` with frontmatter, and root `AGENTS.md` is also supported for simple project instructions. |
| 17 | +- Windsurf supports root and nested `AGENTS.md` files, workspace rules in `.windsurf/rules/*.md`, and generated/local memories. Durable shareable guidance should be represented as rules or `AGENTS.md`, not auto-generated Windsurf memories. |
| 18 | +- Current `origin/master` already includes the manifest-driven `harness_manager/`, adapter manifests, and a Codex adapter. The transfer feature should build on that architecture instead of extending the older bash case statement installer. |
| 19 | + |
| 20 | +Primary sources checked: |
| 21 | + |
| 22 | +- <https://developers.openai.com/codex/guides/agents-md> |
| 23 | +- <https://developers.openai.com/codex/memories> |
| 24 | +- <https://developers.openai.com/codex/skills> |
| 25 | +- <https://docs.cursor.com/en/context> |
| 26 | +- <https://docs.windsurf.com/windsurf/cascade/memories> |
| 27 | +- <https://docs.windsurf.com/windsurf/cascade/agents-md> |
| 28 | + |
| 29 | +## Goals |
| 30 | + |
| 31 | +1. Add an onboarding-style transfer TUI wizard launched by `agentic-stack transfer`. |
| 32 | +2. Let users describe the transfer in natural language, then confirm or edit the parsed target and scope. |
| 33 | +3. Export a portable, signed memory bundle that can be imported through a generated curl command. |
| 34 | +4. Apply the transfer locally when requested, using the existing harness manager adapter installation path. |
| 35 | +5. Preserve privacy by default: accepted lessons and preferences transfer; episodic logs, working memory, rejected candidates, and raw traces stay out unless explicitly selected. |
| 36 | +6. Keep merge behavior transparent and reversible through preview, checksums, and existing git workflows. |
| 37 | + |
| 38 | +## Non-Goals |
| 39 | + |
| 40 | +- Do not write directly into `~/.codex/memories/`, Windsurf auto-generated memory files, Cursor generated memories, or any other tool-owned generated memory store. |
| 41 | +- Do not build a hosted sync service. |
| 42 | +- Do not require an LLM call for intent parsing in v1. |
| 43 | +- Do not transfer secrets, raw shell history, raw prompts, unredacted run traces, or ignored runtime indexes. |
| 44 | +- Do not replace the existing onboarding wizard. |
| 45 | + |
| 46 | +## User Experience |
| 47 | + |
| 48 | +Command: |
| 49 | + |
| 50 | +```bash |
| 51 | +agentic-stack transfer |
| 52 | +``` |
| 53 | + |
| 54 | +The command opens a terminal wizard using the same visual language as `onboard.py`: |
| 55 | + |
| 56 | +- `print_banner()` header with the agentic-stack wordmark. |
| 57 | +- `intro()` section title for the transfer flow. |
| 58 | +- `note()` blocks for explanations, warnings, and previews. |
| 59 | +- `ask_text()`, `ask_select()`, `ask_multiselect()`, and `ask_confirm()` controls. |
| 60 | +- `step_done()` collapsed summaries after each answer. |
| 61 | +- `outro()` final result block with generated commands and verification steps. |
| 62 | + |
| 63 | +The wizard is sequential, not full-screen. Each step should feel like the onboarding wizard: one focused question or preview at a time, a muted vertical rail, purple/blue/green/orange status colors, and no new TUI framework. |
| 64 | + |
| 65 | +### Step 1: Intent |
| 66 | + |
| 67 | +The user types a natural-language request, for example: |
| 68 | + |
| 69 | +- `move my memory into Codex` |
| 70 | +- `make this work in Cursor and Windsurf` |
| 71 | +- `transfer preferences and lessons to another terminal` |
| 72 | + |
| 73 | +The parser detects: |
| 74 | + |
| 75 | +- targets: `codex`, `cursor`, `windsurf`, `terminal`, `all` |
| 76 | +- operation: `apply-here`, `generate-curl`, `both` |
| 77 | +- scope hints: `preferences`, `lessons`, `skills`, `working`, `episodic` |
| 78 | + |
| 79 | +If parsing is uncertain, the wizard defaults to `all` targets only after showing a warning and requiring confirmation. |
| 80 | + |
| 81 | +### Step 2: Target |
| 82 | + |
| 83 | +The user edits detected targets through a multi-select list: |
| 84 | + |
| 85 | +- Codex |
| 86 | +- Cursor |
| 87 | +- Windsurf |
| 88 | +- Terminal / AGENTS.md only |
| 89 | + |
| 90 | +`all` selects every target. The wizard shows exactly which adapter manifests will run. |
| 91 | + |
| 92 | +### Step 3: Scope |
| 93 | + |
| 94 | +Default selected: |
| 95 | + |
| 96 | +- `.agent/memory/personal/PREFERENCES.md` |
| 97 | +- accepted rows from `.agent/memory/semantic/lessons.jsonl` |
| 98 | +- rendered semantic fallback from `.agent/memory/semantic/LESSONS.md` only when `lessons.jsonl` is missing |
| 99 | +- `.agent/skills/` metadata and skill folders, excluding runtime stores |
| 100 | + |
| 101 | +Default unselected: |
| 102 | + |
| 103 | +- `.agent/memory/working/WORKSPACE.md` |
| 104 | +- `.agent/memory/episodic/AGENT_LEARNINGS.jsonl` |
| 105 | +- staged/rejected candidates |
| 106 | +- `.agent/data-layer/` |
| 107 | +- `.agent/flywheel/` |
| 108 | +- `.agent/memory/.index/` |
| 109 | +- skill-local runtime stores such as tldraw snapshots |
| 110 | + |
| 111 | +Selecting a sensitive scope opens a privacy confirmation pane that explains the consequence and shows record counts. |
| 112 | + |
| 113 | +### Step 4: Privacy |
| 114 | + |
| 115 | +The wizard performs deterministic checks before export: |
| 116 | + |
| 117 | +- file allowlist validation |
| 118 | +- max bundle size check |
| 119 | +- secret pattern scan for common tokens and private keys |
| 120 | +- JSONL parse validation for structured memory |
| 121 | +- redaction status check for flywheel records if a future version allows them |
| 122 | + |
| 123 | +If a high-risk item is detected, the default action is to exclude it. The user can override only for files inside `.agent/` and only after a confirmation prompt. |
| 124 | + |
| 125 | +### Step 5: Preview |
| 126 | + |
| 127 | +The preview is the most important screen. It shows: |
| 128 | + |
| 129 | +- files to create |
| 130 | +- files to merge |
| 131 | +- files to leave alone |
| 132 | +- adapters to install |
| 133 | +- skills link strategy for Codex: `.agents/skills -> .agent/skills` |
| 134 | +- generated bundle digest |
| 135 | +- generated curl command |
| 136 | +- local apply command equivalent |
| 137 | + |
| 138 | +No files are written before this screen is confirmed. |
| 139 | + |
| 140 | +### Step 6: Apply |
| 141 | + |
| 142 | +The user chooses one: |
| 143 | + |
| 144 | +- `Apply here now` |
| 145 | +- `Generate curl command` |
| 146 | +- `Both` |
| 147 | + |
| 148 | +The final screen shows: |
| 149 | + |
| 150 | +- success or failure status for each action |
| 151 | +- copied/generated curl command |
| 152 | +- verification commands |
| 153 | +- artifact path for the bundle manifest |
| 154 | + |
| 155 | +Example final command: |
| 156 | + |
| 157 | +```bash |
| 158 | +curl -fsSL https://raw.githubusercontent.com/codejunkie99/agentic-stack/vX.Y.Z/scripts/import-transfer.sh | sh -s -- --target codex --payload '<base64-gz-json>' --sha256 '<digest>' |
| 159 | +``` |
| 160 | + |
| 161 | +## Architecture |
| 162 | + |
| 163 | +The feature has four layers: |
| 164 | + |
| 165 | +1. Onboarding-style TUI orchestration. |
| 166 | +2. Deterministic intent parsing and transfer planning. |
| 167 | +3. Bundle export/import. |
| 168 | +4. Adapter application through `harness_manager`. |
| 169 | + |
| 170 | +### TUI Layer |
| 171 | + |
| 172 | +Add a new module: |
| 173 | + |
| 174 | +- `harness_manager/transfer_tui.py` |
| 175 | + |
| 176 | +Responsibilities: |
| 177 | + |
| 178 | +- render the onboarding-style transfer wizard |
| 179 | +- manage sequential step state |
| 180 | +- call pure planning/export/import functions |
| 181 | +- show progress or status notes for operations over one second |
| 182 | +- preserve terminal cursor visibility around arrow-key widgets |
| 183 | + |
| 184 | +Toolkit: reuse the existing stdlib onboarding UI primitives in `onboard_ui.py` and `onboard_widgets.py`. If sharing those modules directly would create awkward imports, extract common display and input helpers into a small shared module and keep onboarding behavior unchanged. Do not add Textual, curses, Rich, prompt-toolkit, or any other new runtime TUI dependency for v1. The core import/export modules must remain dependency-light so non-interactive commands can run in CI and scripts. |
| 185 | + |
| 186 | +### Planning Layer |
| 187 | + |
| 188 | +Add: |
| 189 | + |
| 190 | +- `harness_manager/transfer_plan.py` |
| 191 | + |
| 192 | +Responsibilities: |
| 193 | + |
| 194 | +- parse natural-language intent with deterministic keyword rules |
| 195 | +- normalize target aliases |
| 196 | +- define selected memory scopes |
| 197 | +- produce a previewable transfer plan |
| 198 | +- compute the files each target will install by reading existing adapter manifests |
| 199 | + |
| 200 | +Intent parsing is intentionally simple in v1. The parser should prefer conservative uncertainty over pretending to understand ambiguous input. |
| 201 | + |
| 202 | +### Bundle Layer |
| 203 | + |
| 204 | +Add: |
| 205 | + |
| 206 | +- `harness_manager/transfer_bundle.py` |
| 207 | + |
| 208 | +Bundle format: |
| 209 | + |
| 210 | +```json |
| 211 | +{ |
| 212 | + "schema_version": 1, |
| 213 | + "created_at": "2026-05-02T00:00:00Z", |
| 214 | + "source": { |
| 215 | + "agentic_stack_version": "0.13.0", |
| 216 | + "project_name": "example" |
| 217 | + }, |
| 218 | + "targets": ["codex"], |
| 219 | + "scopes": ["preferences", "accepted_lessons", "skills"], |
| 220 | + "files": [ |
| 221 | + { |
| 222 | + "path": ".agent/memory/personal/PREFERENCES.md", |
| 223 | + "encoding": "utf-8", |
| 224 | + "content_b64": "..." |
| 225 | + } |
| 226 | + ], |
| 227 | + "lessons": [ |
| 228 | + { |
| 229 | + "id": "lesson_...", |
| 230 | + "claim": "...", |
| 231 | + "conditions": ["..."], |
| 232 | + "status": "accepted" |
| 233 | + } |
| 234 | + ], |
| 235 | + "warnings": [] |
| 236 | +} |
| 237 | +``` |
| 238 | + |
| 239 | +Transport encoding: |
| 240 | + |
| 241 | +- canonical JSON |
| 242 | +- gzip |
| 243 | +- base64url or shell-safe base64 |
| 244 | +- SHA-256 digest over compressed bytes |
| 245 | + |
| 246 | +Import behavior: |
| 247 | + |
| 248 | +- create `.agent/` if missing by using the agentic-stack template |
| 249 | +- merge preferences under an `## Imported Preferences` section if the destination preferences file has custom content |
| 250 | +- append accepted lessons idempotently into `lessons.jsonl` |
| 251 | +- run `render_lessons.py` after lesson import |
| 252 | +- copy or sync selected skills into `.agent/skills/` |
| 253 | +- never overwrite `.agent/protocols/permissions.md` |
| 254 | + |
| 255 | +### Curl Bootstrap Layer |
| 256 | + |
| 257 | +Add: |
| 258 | + |
| 259 | +- `scripts/import-transfer.sh` |
| 260 | +- `scripts/import-transfer.ps1` |
| 261 | + |
| 262 | +Responsibilities: |
| 263 | + |
| 264 | +- decode payload |
| 265 | +- verify digest |
| 266 | +- locate or fetch agentic-stack |
| 267 | +- call the Python importer |
| 268 | +- install selected adapters through `harness_manager` |
| 269 | + |
| 270 | +The shell and PowerShell scripts must fail closed: digest mismatch, unsupported schema, invalid target, or secret scan failure returns non-zero and writes no memory files. |
| 271 | + |
| 272 | +## CLI Surface |
| 273 | + |
| 274 | +Interactive: |
| 275 | + |
| 276 | +```bash |
| 277 | +agentic-stack transfer |
| 278 | +``` |
| 279 | + |
| 280 | +Non-interactive support for generated scripts and tests: |
| 281 | + |
| 282 | +```bash |
| 283 | +agentic-stack transfer --intent "move my memory into Codex" --target codex --print-curl |
| 284 | +agentic-stack transfer import --payload-file bundle.txt --sha256 <digest> --target codex |
| 285 | +agentic-stack transfer export --target codex --scope preferences --scope accepted-lessons --json |
| 286 | +``` |
| 287 | + |
| 288 | +Non-interactive commands are supporting surfaces, not the main UX. |
| 289 | + |
| 290 | +## Adapter Behavior |
| 291 | + |
| 292 | +### Codex |
| 293 | + |
| 294 | +Install or merge: |
| 295 | + |
| 296 | +- `AGENTS.md` |
| 297 | +- `.agents/skills` symlink or sync from `.agent/skills` |
| 298 | + |
| 299 | +Do not edit `~/.codex/memories/`. |
| 300 | + |
| 301 | +### Cursor |
| 302 | + |
| 303 | +Install: |
| 304 | + |
| 305 | +- `.cursor/rules/agentic-stack.mdc` |
| 306 | + |
| 307 | +If root `AGENTS.md` is already shared by another adapter and references `.agent/`, leave it alone. |
| 308 | + |
| 309 | +### Windsurf |
| 310 | + |
| 311 | +Preferred modern target: |
| 312 | + |
| 313 | +- `.windsurf/rules/agentic-stack.md` |
| 314 | + |
| 315 | +Legacy compatibility: |
| 316 | + |
| 317 | +- keep `.windsurfrules` support until a later breaking release |
| 318 | + |
| 319 | +The wizard should preview both if the current adapter manifest still installs `.windsurfrules`. |
| 320 | + |
| 321 | +### Terminal |
| 322 | + |
| 323 | +Install or merge: |
| 324 | + |
| 325 | +- `AGENTS.md` |
| 326 | + |
| 327 | +No tool-specific hooks. |
| 328 | + |
| 329 | +## Packaging |
| 330 | + |
| 331 | +The implementation must preserve the current dependency posture: |
| 332 | + |
| 333 | +- Do not add a new runtime dependency for the wizard. |
| 334 | +- Update Homebrew Formula packaging only to include any new Python modules and scripts. |
| 335 | +- Keep core import/export code usable without the interactive wizard for scripts and tests. |
| 336 | +- On non-TTY shells, never try to start the interactive wizard; print usage and suggest the non-interactive flags. |
| 337 | +- On terminals without raw-key support, show an actionable error with fallback commands. |
| 338 | + |
| 339 | +## Error Handling |
| 340 | + |
| 341 | +- Ctrl-C or Escape exits without writing unless an apply operation has already begun. |
| 342 | +- Apply operations write through temp files and atomic rename where possible. |
| 343 | +- Import records a local manifest under `.agent/transfer/imports/`. |
| 344 | +- Export records a local manifest under `.agent/transfer/exports/`. |
| 345 | +- If adapter installation fails after memory import succeeds, the final screen must show partial success and the exact recovery command. |
| 346 | +- Digest mismatch aborts before decode/import. |
| 347 | +- Unsupported schema aborts with an upgrade hint. |
| 348 | + |
| 349 | +## Testing |
| 350 | + |
| 351 | +Unit tests: |
| 352 | + |
| 353 | +- intent parsing |
| 354 | +- target alias normalization |
| 355 | +- scope defaults |
| 356 | +- bundle canonicalization and digest verification |
| 357 | +- preferences merge |
| 358 | +- accepted lesson idempotency |
| 359 | +- secret scan exclusion |
| 360 | +- adapter plan preview |
| 361 | + |
| 362 | +Integration tests: |
| 363 | + |
| 364 | +- export then import into a temp repo for Codex |
| 365 | +- export then import into a temp repo for Cursor |
| 366 | +- export then import into a temp repo for Windsurf |
| 367 | +- generated curl script path with a local file URL or fixture server |
| 368 | +- non-TTY fallback behavior |
| 369 | + |
| 370 | +TUI tests: |
| 371 | + |
| 372 | +- wizard flow moves through every step |
| 373 | +- cancellation before apply writes nothing |
| 374 | +- preview note reflects selected targets and scopes |
| 375 | +- collapsed step summaries render selected values |
| 376 | +- final outro shows generated commands |
| 377 | + |
| 378 | +Packaging tests: |
| 379 | + |
| 380 | +- Homebrew formula test exercises `agentic-stack transfer --help` or a non-interactive export path |
| 381 | +- PowerShell dispatch recognizes the transfer verb |
| 382 | + |
| 383 | +## Resolved Implementation Decisions |
| 384 | + |
| 385 | +1. Use the same stdlib, clack-style terminal UI as the onboarding wizard. |
| 386 | +2. Generate a PowerShell-native transfer command on Windows instead of asking users to run `curl | sh`. |
| 387 | +3. Modernize the Windsurf adapter inside this feature by adding `.windsurf/rules/agentic-stack.md`, while preserving `.windsurfrules` as a legacy compatibility output until a later breaking release. |
| 388 | + |
| 389 | +## Success Criteria |
| 390 | + |
| 391 | +- Running `agentic-stack transfer` opens an onboarding-style wizard in an interactive terminal. |
| 392 | +- A user can export preferences, accepted lessons, and skills to a generated curl command. |
| 393 | +- Pasting the curl command in a fresh project installs the selected adapter and imports memory into `.agent/`. |
| 394 | +- Codex sees root `AGENTS.md` and `.agents/skills`. |
| 395 | +- Cursor sees `.cursor/rules/agentic-stack.mdc`. |
| 396 | +- Windsurf sees either modern `.windsurf/rules/agentic-stack.md` or the existing legacy `.windsurfrules`, with the chosen behavior shown in preview. |
| 397 | +- No generated tool memory stores are edited directly. |
| 398 | +- Non-sensitive scopes are default; sensitive scopes require explicit opt-in. |
0 commit comments