Skip to content

Establish CLI behavior contract#266

Merged
nicosuave merged 6 commits into
mainfrom
t1-cli-contract
Jul 19, 2026
Merged

Establish CLI behavior contract#266
nicosuave merged 6 commits into
mainfrom
t1-cli-contract

Conversation

@nicosuave

@nicosuave nicosuave commented Jul 19, 2026

Copy link
Copy Markdown
Member

Establishes a consistent CLI contract across Sidemantic.

  • Adds standard help entry points and nested command help.
  • Centralizes errors, exit codes, debug behavior, and stdout/stderr handling.
  • Adds JSON output and stdin/stdout support to structured CLI workflows.
  • Adds file/stdin credential inputs for PostgreSQL passwords and API tokens.
  • Updates documentation, examples, bundled skills, and behavioral coverage.

Shared downstream extension points live in sidemantic/cli_contract.py: CLIState, cli_state(), ContractGroup, result and diagnostic emitters, and stream/secret helpers.

Inline configuration secrets remain supported. Only direct --password and --auth-token arguments are deprecated through 0.x, with removal eligible in 1.0 after a documented release cycle.

Known limitations: global --debug must precede the subcommand, and multi-file generators cannot write to stdout.

@chatgpt-codex-connector chatgpt-codex-connector Bot left a comment

Copy link
Copy Markdown

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

💡 Codex Review

Here are some automated review suggestions for this pull request.

Reviewed commit: 7f52648436

ℹ️ About Codex in GitHub

Your team has set up Codex to review pull requests in this repo. Reviews are triggered when you

  • Open a pull request for review
  • Mark a draft as ready
  • Comment "@codex review".

If Codex has suggestions, it will comment; otherwise it will react with 👍.

Codex can also answer questions or update the PR. Try commenting "@codex address that feedback".

Comment thread sidemantic/cli.py
Comment on lines +266 to +268
@app.command("help", context_settings=CLI_CONTEXT_SETTINGS)
def help_command(
command: list[str] = typer.Argument(None, metavar="[COMMAND]...", help="Command or nested subcommand path"),

Copy link
Copy Markdown

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

P2 Badge Bypass project loading for the help command

Because this is registered as an ordinary command, Typer runs the root callback before help_command, so any malformed sidemantic.yaml in the current project makes sidemantic help and sidemantic help info exit with a config error instead of showing help. This breaks the documented equivalence with sidemantic --help exactly when users may need help to recover from a bad config; the help path should avoid project discovery or be handled before the root callback.

Useful? React with 👍 / 👎.

@chatgpt-codex-connector chatgpt-codex-connector Bot left a comment

Copy link
Copy Markdown

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

💡 Codex Review

Here are some automated review suggestions for this pull request.

Reviewed commit: 348697de63

ℹ️ About Codex in GitHub

Your team has set up Codex to review pull requests in this repo. Reviews are triggered when you

  • Open a pull request for review
  • Mark a draft as ready
  • Comment "@codex review".

If Codex has suggestions, it will comment; otherwise it will react with 👍.

Codex can also answer questions or update the PR. Try commenting "@codex address that feedback".

Comment thread sidemantic/cli.py Outdated
Comment on lines +889 to +890
suffix = source_spec.extensions[0] if source_spec.extensions else ".txt"
source = temp_root / f"stdin{suffix}"

Copy link
Copy Markdown

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

P2 Badge Preserve stdin source extensions for SQL models

When a user streams a native Sidemantic SQL definition, e.g. cat model.sql | sidemantic convert - --from sidemantic --to sidemantic --output -, this always materializes stdin as the first registered extension (.yml). SidemanticAdapter.parse() dispatches SQL handling based on the .sql suffix, so the streamed SQL is parsed as YAML instead and fails with a non-actionable error like 'str' object has no attribute 'get'; stdin conversion should let users select or infer the correct suffix for multi-extension formats.

Useful? React with 👍 / 👎.

@chatgpt-codex-connector chatgpt-codex-connector Bot left a comment

Copy link
Copy Markdown

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

💡 Codex Review

Here are some automated review suggestions for this pull request.

Reviewed commit: ad184e8bc0

ℹ️ About Codex in GitHub

Your team has set up Codex to review pull requests in this repo. Reviews are triggered when you

  • Open a pull request for review
  • Mark a draft as ready
  • Comment "@codex review".

If Codex has suggestions, it will comment; otherwise it will react with 👍.

Codex can also answer questions or update the PR. Try commenting "@codex address that feedback".

Comment thread sidemantic/cli.py
}
)
else:
emit_error(e)

Copy link
Copy Markdown

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

P2 Badge Honor --debug in validate failures

With the new global --debug contract, sidemantic --debug validate ./models should expose tracebacks for unexpected validation crashes, but this non-JSON exception path still emits a concise error and then exits. If validate_directory() raises due to an internal loader/validator bug, users get the same suppressed traceback as normal mode instead of the debug behavior implemented via fail(e) in the other commands.

Useful? React with 👍 / 👎.

@chatgpt-codex-connector chatgpt-codex-connector Bot left a comment

Copy link
Copy Markdown

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

💡 Codex Review

Here are some automated review suggestions for this pull request.

Reviewed commit: a06db680ee

ℹ️ About Codex in GitHub

Your team has set up Codex to review pull requests in this repo. Reviews are triggered when you

  • Open a pull request for review
  • Mark a draft as ready
  • Comment "@codex review".

If Codex has suggestions, it will comment; otherwise it will react with 👍.

Codex can also answer questions or update the PR. Try commenting "@codex address that feedback".

Comment thread sidemantic/cli.py Outdated
Comment on lines +263 to +264
if ctx.invoked_subcommand == "help":
return

Copy link
Copy Markdown

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

P2 Badge Skip project loading for all help paths

When a malformed sidemantic.yaml is present and the user asks for conventional subcommand help such as sidemantic info --help, sidemantic migrate generate -h, or a no-args subgroup help like sidemantic migrate, ctx.invoked_subcommand is the real command/group rather than "help", so the callback still runs ProjectContext.discover() and exits with a config error instead of showing help. This leaves the documented --help/-h help paths unavailable in exactly the recovery scenario this guard is meant to handle; the skip needs to cover Click's help/no-args-help parsing as well as the custom help command.

Useful? React with 👍 / 👎.

@chatgpt-codex-connector chatgpt-codex-connector Bot left a comment

Copy link
Copy Markdown

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

💡 Codex Review

Here are some automated review suggestions for this pull request.

Reviewed commit: ef92d73424

ℹ️ About Codex in GitHub

Your team has set up Codex to review pull requests in this repo. Reviews are triggered when you

  • Open a pull request for review
  • Mark a draft as ready
  • Comment "@codex review".

If Codex has suggestions, it will comment; otherwise it will react with 👍.

Codex can also answer questions or update the PR. Try commenting "@codex address that feedback".

Comment thread README.md Outdated
**HTTP API server** (JSON or Arrow):
```bash
uvx --from "sidemantic[api]" sidemantic api-serve --demo --port 4400 --auth-token secret
uvx --from "sidemantic[api]" sidemantic server api --demo --port 4400 --auth-token-file .secrets/api-token

Copy link
Copy Markdown

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

P2 Badge Make the API demo command self-contained

When a user copies this demo command in a fresh checkout, server api now tries to read .secrets/api-token and exits before starting because that file is not created anywhere in the demo instructions. Since the token is optional for local demos, either omit this flag here or add the credential-file creation step so the documented demo remains runnable.

Useful? React with 👍 / 👎.

@nicosuave
nicosuave merged commit 6b5e3fa into main Jul 19, 2026
19 of 22 checks passed
@nicosuave
nicosuave deleted the t1-cli-contract branch July 19, 2026 14:21
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

None yet

Projects

None yet

Development

Successfully merging this pull request may close these issues.

1 participant