feat: workspace context CLI and API-first data model docs#52
feat: workspace context CLI and API-first data model docs#52eddietejeda merged 6 commits intomainfrom
Conversation
Wire workspace /v1/context to local ./<NAME>.md in the current directory. Validate names with the same rules as SQL table identifiers (aligned with runtimedb validate_table_name). Pull refuses to overwrite without --force; push and pull support --dry-run.
Document context list/show/pull/push, DATAMODEL convention, agent workflow (show before work, push after edits), optional pull sync, and sandbox promotion to workspace context.
Remove legacy local-path guidance. SKILL, WORKFLOWS, MODEL_BUILD, and DATA_MODEL.template now treat DATAMODEL workspace context as authoritative; ./DATAMODEL.md is only a CLI push/pull surface.
Codecov Report❌ Patch coverage is
📢 Thoughts on this report? Let us know! |
| ); | ||
| } | ||
|
|
||
| #[cfg(test)] |
There was a problem hiding this comment.
nit: the test suite only covers three validate_context_stem paths. A few cheap additions would meaningfully raise confidence: a name starting with a digit (should fail), a name starting with underscore (should succeed), the exact 128-char boundary (should succeed), a 129-char name (should fail), and a reserved word in uppercase e.g. SELECT (should fail via the lowercase check). (not blocking)
Address PR review: skip GET when non-dry-run pull would refuse overwrite. Add validate_context_stem tests for leading digit, underscore, length boundary, and uppercase reserved word.
| ); | ||
| eprintln!( | ||
| "{}", | ||
| format!("Create ./{name}.md locally, then run: hotdata context push {name}") |
There was a problem hiding this comment.
nit: Err(_) => unreachable!() silently depends on the invariant that fetch_context only ever returns Err(NOT_FOUND) — all other non-OK statuses currently call process::exit before returning. That invariant is not encoded in the type, so a future change to fetch_context (e.g. propagating additional status codes as Err) would cause a panic with no useful diagnostic here and in the equivalent arm in pull. A named panic message like panic!("unexpected error status from fetch_context") would at least surface a clear message. Same applies to the analogous arm in pull. (not blocking)
| if dry_run { | ||
| eprintln!( | ||
| "{}", | ||
| format!("would write {} chars to {}", n_chars, path.display()).dark_grey() |
There was a problem hiding this comment.
super nit: path.parent() here is always current_dir() (since local_md_path returns <cwd>/<name>.md), so create_dir_all is a guaranteed no-op — the current directory always exists. The block can be removed. (not blocking)
…kdir Replace unreachable Err arms with explicit panic message if fetch_context ever returns a non-404 error. Remove create_dir_all on pull (path is always cwd + single filename segment).
Summary
Adds
hotdata contextcommands to sync workspace Markdown with the context API, and updates skill + README so the API is the source of truth for the data model (DATAMODEL) and related docs.CLI
context list— list named contexts; optional--prefixcontext show <name>— print Markdown to stdout (no local file)context pull <name>— write./<name>.mdfrom API (--force,--dry-run)context push <name>— upsert from./<name>.md(--dry-run)Name validation matches SQL table identifier rules (aligned with runtimedb
validate_table_name).Documentation
./DATAMODEL.mddescribed as push/pull transport / agent edit surfaceBranch
feat/context-cli