Skip to main content

Module draft

Module draft 

Source
Expand description

Shared plumbing for the claude-assisted draft/init verbs (roba alias draft, roba profile draft, roba config init).

All three verbs use the same deterministic bookends: build a prompt from the bundled, parse-tested config schema + the user’s words, make ONE lean claude call, then validate the output with roba’s REAL deserializer (deny_unknown_fields). The type-specific parts – which schema section, which deserializer, how to render – live in the calling module (crate::aliases, crate::profile, crate::config). The generic parts – the claude call, fence-stripping, and block-appending – live here, so there is one shared core rather than parallel copies.

Functions§

append_block
Append a blank line + the block to path, creating the file (and any missing parent dirs) if absent.
generate
Make the single lean generation call and return claude’s raw result text for the caller to validate.
generate_inspecting
Like generate, but lets the call SEE the current project: a read-only Read/Glob/Grep tool posture so claude can skim the README / manifest / layout before drafting, bounded by a turn cap so a bootstrap skims rather than spelunks. Used by roba config init, which fits a whole-file config to what it observes in the cwd.
strip_code_fences
Strip a single surrounding markdown code fence if present, so output wrapped in toml ... still parses. Fence-free input is returned trimmed but otherwise untouched.