th-schema-pull: smoo config schema pull — sync the local schema from remote - #493
Merged
Conversation
…remote The write direction (schema add/rm, config push) shipped in #490; this is the read direction. `smoo config schema pull` reconciles the LOCAL schema representation with the org's remote schema, correctly for both consumer kinds: a plain pulled schema.json is overwritten (config pull --force semantics), while a TypeScript consumer (config.ts present) is never rewritten wholesale — remote-only keys become ready-to-paste snippets in the file's own conventions (value-schema names and defineLimit clamp fields derived from how the build serializes them), and --write appends them into the right tier block mechanically, refusing all-or-nothing when a block can't be located unambiguously. Local-only keys are reported, never deleted; tier/type drift on shared keys is reported as tables. Co-Authored-By: Claude Fable 5 <noreply@anthropic.com> Claude-Session: https://claude.ai/code/session_01KF6EFZ3mMGGF4m1543yWQP
brentrager
enabled auto-merge (squash)
August 20, 2026 17:37
🦋 Changeset detectedLatest commit: 2de329f The changes in this PR will be included in the next version bump. This PR includes changesets to release 1 package
Not sure what this means? Click here to learn what changesets are. Click here if you're a maintainer who wants to add another changeset to this PR |
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment
Add this suggestion to a batch that can be applied as a single commit.This suggestion is invalid because no changes were made to the code.Suggestions cannot be applied while the pull request is closed.Suggestions cannot be applied while viewing a subset of changes.Only one suggestion per line can be applied in a batch.Add this suggestion to a batch that can be applied as a single commit.Applying suggestions on deleted lines is not supported.You must change the existing code in this line in order to create a valid suggestion.Outdated suggestions cannot be applied.This suggestion has been applied or marked resolved.Suggestions cannot be applied from pending reviews.Suggestions cannot be applied on multi-line comments.Suggestions cannot be applied while the pull request is queued to merge.Suggestion cannot be applied right now. Please check back later.
What
smoo config schema pull [--schema-name] [--org-id] [--dry-run] [--write] [--json]— the read direction that #490'sschema show|add|rm(write direction) left open: bring the LOCAL schema representation up to date with the org's remote schema, correctly for both kinds of consumer, detected by whether.smooai-config/config.tsexists.Design
config.ts):schema.jsonIS the local representation — overwritten with the remote doc, same effect assmoo config pull --force. Single fetch, dry-run supported.config.tspresent): the TypeScript is the source of truth and is never rewritten wholesale. The diff base is the builtschema.json. Remote-only keys are emitted as ready-to-paste snippets targeted at the right tier block, in the file's own conventions — the JSON-Schema→TS mapping is derived from how the build actually serializes ({"type":"string"}⇄StringSchema,boolean⇄BooleanSchema,number⇄NumberSchema, limitsdefault/minimum/maximum/multipleOf⇄defineLimit({ default, min, max, step })perLimitDefinitionin@smooai/config). Each snippet is headed by// pulled from remote <date> — <remote description | TODO: describe>. A remote type with no clean TS equivalent (object,array, untyped) — or a limit missing thedefaultthatdefineLimitthrows without — is emitted as a fully commented-out block carrying the raw remote spec, never invented syntax.--write: appends the snippets intoconfig.tsmechanically — before the tier block's closing brace, at the block's indentation + 4. All-or-nothing: every insertion is applied in memory first, and the locator refuses (touching nothing) on a missing block, a duplicatednode: {line, or an unbalanced-brace scan. Default is print-only; after a write the hint isth config buildto regenerateschema.json.th config pushwould add them remotely). Tier drift and declared-type drift on shared keys are reported as tables.--dry-runwins over--write;--jsonemits the structured report. The pure core (compute_pull_report,ts_snippet,insert_into_tier_block,flatten_with_specs— a 4-tier flatten, since the existingflatten_schemaskips limits) is fully separated from IO.Live smoke (real org, scratch copy of smooai's .smooai-config)
Dry run — the snippet path fired for real on
hubspotDeltaSyncEnabled(added remotely, missing from local TS), picking up its remote description:--writeon the copy produced this hunk (brace balance verified, real repo untouched):JSON-consumer path also smoked: bootstrap into an empty dir writes the remote doc; re-run reports in-sync.
Tests
16 new colocated tests (all green,
cargo test -p smooai-smooth-cli --features admin config): clap parse; the scalar/limit/description snippet mappings incl. the commented-out fallbacks; pull-report classification (missing/local-only/tier-drift/type-drift, limits included); manifest-shape flatten; and the block locator against a fixture config.ts excerpt — right-tier append with indentation, inlinedefineLimit({...})braces, and refusals for missing/ambiguous/unbalanced blocks.Docs updated in
docs/Engineering/Using-th-CLI.md; changeset minor.🤖 Generated with Claude Code
https://claude.ai/code/session_01KF6EFZ3mMGGF4m1543yWQP