Skip to content

feat(cli): add vouch new scaffold command#333

Merged
plind-junior merged 2 commits into
vouchdev:testfrom
jsdevninja:feat/cli-new-scaffold
Jul 3, 2026
Merged

feat(cli): add vouch new scaffold command#333
plind-junior merged 2 commits into
vouchdev:testfrom
jsdevninja:feat/cli-new-scaffold

Conversation

@jsdevninja

@jsdevninja jsdevninja commented Jul 1, 2026

Copy link
Copy Markdown
Contributor

Summary

Test plan

  • pytest tests/test_new_scaffold.py -q (11 tests)
  • ruff check src/vouch/cli.py tests/test_new_scaffold.py
  • vouch new decision --title "pick X" creates a pending page proposal
  • vouch new person --name alice-example creates a pending entity proposal
  • vouch new meeting-notes --title Sync --dry-run prints missing fields without writing

Closes #330

Summary by CodeRabbit

  • New Features

    • Added a vouch new command to scaffold new page or entity proposals from configured kinds.
    • Supports --field key=value, --interactive, --dry-run, and --json for more flexible proposal creation.
    • Added clearer validation and feedback for required frontmatter fields, citations, and unknown kinds.
  • Bug Fixes

    • Improved parsing errors for malformed metadata input, with messages that now reference the relevant flag.

@coderabbitai

coderabbitai Bot commented Jul 1, 2026

Copy link
Copy Markdown

Review Change Stack

Important

Review skipped

Auto reviews are disabled on base/target branches other than the default branch.

Please check the settings in the CodeRabbit UI or the .coderabbit.yaml file in this repository. To trigger a single review, invoke the @coderabbitai review command.

⚙️ Run configuration

Configuration used: defaults

Review profile: CHILL

Plan: Pro Plus

Run ID: 5010260e-2832-4552-badc-08575f7d86c0

You can disable this status message by setting the reviews.review_status to false in the CodeRabbit configuration file.

Use the checkbox below for a quick retry:

  • 🔍 Trigger review
📝 Walkthrough

Walkthrough

Adds a vouch new <kind> CLI command that scaffolds typed page or entity proposals using the page-kind registry, with --field, --interactive, --dry-run, --json flags, entity/page routing and citation reminders, plus updated _parse_meta, corresponding tests, and a changelog entry.

Changes

vouch new command

Layer / File(s) Summary
Metadata parsing helper update
src/vouch/cli.py
Adds Literal import and updates _parse_meta to accept a keyword-only flag label used in BadParameter error messages.
Scaffolding helpers and constants
src/vouch/cli.py
Adds a scaffoldable entity-type allowlist, _resolve_new_kind for page/entity routing (with --entity force path), _field_missing, _stub_page_frontmatter, and interactive-prompt/dry-run draft printing helpers.
vouch new command implementation
src/vouch/cli.py
Implements the new click command branching between entity and page scaffolding, validating --name/--title, parsing --body/--field, stubbing/prompting required frontmatter, appending citation reminders or erroring when citations are required, and supporting --dry-run/--json output.
Scaffold command tests
tests/test_cli.py
Adds imports and a new vouch new test suite covering page/entity creation, YAML field parsing, interactive prompting, dry-run behavior and JSON output, collision routing, unknown-kind errors, invalid YAML, and citation enforcement.
Changelog entry
CHANGELOG.md
Documents the vouch new <kind> command, its flags, and routing/precedence rules in the Unreleased section.

Estimated code review effort: 3 (Moderate) | ~25 minutes

Sequence Diagram(s)

sequenceDiagram
  participant User
  participant CLI as new_cmd
  participant Registry as page_kind_registry
  participant Proposals as propose_page/propose_entity

  User->>CLI: vouch new <kind> [--field ...] [--dry-run] [--json]
  CLI->>Registry: resolve(kind)
  Registry-->>CLI: required_fields, schema, required_citations
  CLI->>CLI: stub/prompt missing required fields
  alt dry-run
    CLI-->>User: print draft / JSON
  else create
    CLI->>Proposals: propose_page(...) or propose_entity(...)
    Proposals-->>CLI: proposal_id
    CLI-->>User: print result / JSON
  end
Loading
🚥 Pre-merge checks | ✅ 4 | ❌ 1

❌ Failed checks (1 warning)

Check name Status Explanation Resolution
Docstring Coverage ⚠️ Warning Docstring coverage is 10.26% which is insufficient. The required threshold is 80.00%. Write docstrings for the functions missing them to satisfy the coverage threshold.
✅ Passed checks (4 passed)
Check name Status Explanation
Description Check ✅ Passed Check skipped - CodeRabbit’s high-level summary is enabled.
Title check ✅ Passed The title clearly names the new vouch new scaffold command and matches the main change in the PR.
Linked Issues check ✅ Passed The new command, flags, collision handling, citation reminder, and tests align with #330's scaffold requirements.
Out of Scope Changes check ✅ Passed Only related changelog and CLI test updates are present; no unrelated features or behaviors stand out.
✨ Finishing Touches
🧪 Generate unit tests (beta)
  • Create PR with unit tests

Thanks for using CodeRabbit! It's free for OSS, and your support helps us grow. If you like it, consider giving us a shout-out.

❤️ Share

Comment @coderabbitai help to get the list of available commands.

@github-actions github-actions Bot added docs documentation, specs, examples, and repo guidance cli command line interface tests tests and fixtures size: M 200-499 changed non-doc lines labels Jul 1, 2026

@coderabbitai coderabbitai 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.

Actionable comments posted: 3

🧹 Nitpick comments (3)
tests/test_new_scaffold.py (2)

1-158: 📐 Maintainability & Code Quality | 🔵 Trivial | 💤 Low value

Test file name doesn't mirror the module under test.

This file exercises the new command defined in src/vouch/cli.py, not a new_scaffold module. Per coding guidelines, test filenames should mirror module names as tests/test_<module>.py — these cases likely belong in tests/test_cli.py (or the file should be renamed to reflect cli).

As per coding guidelines, "Test file names must mirror module names using the tests/test_<module>.py convention."

🤖 Prompt for AI Agents
Verify each finding against current code. Fix only still-valid issues, skip the
rest with a brief reason, keep changes minimal, and validate.

In `@tests/test_new_scaffold.py` around lines 1 - 158, The test file name does not
match the module being exercised; these tests target the cli entrypoint in
vouch.cli, not a new_scaffold module. Rename or relocate the suite to follow the
tests/test_<module>.py convention, and keep the existing test functions (such as
test_new_decision_page_stubs_frontmatter and test_new_pending_not_approved)
under the cli-focused test file name.

Source: Coding guidelines


32-158: 📐 Maintainability & Code Quality | 🔵 Trivial | ⚡ Quick win

No coverage for --interactive prompting path.

The PR objectives call out --interactive support for missing fields, but none of the added tests exercise it (e.g. via CliRunner(input=...)). Consider adding a case that confirms prompted values land in payload["metadata"].

🤖 Prompt for AI Agents
Verify each finding against current code. Fix only still-valid issues, skip the
rest with a brief reason, keep changes minimal, and validate.

In `@tests/test_new_scaffold.py` around lines 32 - 158, Add test coverage for the
`--interactive` path in the `new` command, since the current cases in
`test_new_scaffold.py` only cover direct flags and dry-run behavior. Create a
`CliRunner` invocation with `input=...` for a kind with required fields, and
assert the prompted answers are stored in `pr.payload["metadata"]` after `cli`
runs. Use the existing `test_new_field_prefill_parsed_as_yaml` and
`test_new_dry_run_writes_nothing` patterns as a guide, and keep the assertion
focused on the interactive prompt flow for `new`.
src/vouch/cli.py (1)

1033-1033: 📐 Maintainability & Code Quality | 🔵 Trivial | ⚡ Quick win

Make the allowlist comment explain why it exists.

The current comment restates the constant instead of documenting the constraint.

As per coding guidelines, src/**/*.py: “Do not use marketing tone like "we" or "let's" in code comments; comments should explain why, not what.”

Proposed refactor
-# Entity kinds `vouch new` can scaffold (issue `#330`).
+# Keep entity scaffolding intentionally narrow because `propose_entity` accepts arbitrary type strings.
🤖 Prompt for AI Agents
Verify each finding against current code. Fix only still-valid issues, skip the
rest with a brief reason, keep changes minimal, and validate.

In `@src/vouch/cli.py` at line 1033, The allowlist comment near the `vouch new`
scaffold kinds is too descriptive and should explain the constraint instead of
restating the constant. Update the comment attached to the entity kinds
allowlist in `cli.py` so it states why only those kinds are permitted for `vouch
new`, and avoid marketing-style wording; keep the guidance tied to the related
`vouch new` scaffolding logic and the allowlist definition.

Source: Coding guidelines

🤖 Prompt for all review comments with AI agents
Verify each finding against current code. Fix only still-valid issues, skip the
rest with a brief reason, keep changes minimal, and validate.

Inline comments:
In `@src/vouch/cli.py`:
- Around line 1204-1206: The citation reminder path in propose_page appends
_CITATION_REMINDER even though the page is going to be rejected for
citation-required kinds without claims or sources. Move the citation gating
before filing so unfileable proposals are rejected first, or make the reminder
draft-only in the propose_page flow and any related submit path around
citation_reminder/body handling.
- Line 1029: The meta parsing and draft preview path is leaking YAML-related
failures: `_parse_meta()` and `_prompt_missing_fields()` should catch
`yaml.safe_load()` exceptions and rethrow them as `click.BadParameter` so
invalid frontmatter is reported cleanly. Update `_print_new_page_draft()` to
avoid `json.dumps()` on `frontmatter`, since YAML-native types like dates can
break the dry-run preview; use a serializer that safely handles YAML values.
Keep the fix localized to `_parse_meta()`, `_prompt_missing_fields()`, and
`_print_new_page_draft()` so malformed input and preview rendering both fail
gracefully.

In `@tests/test_new_scaffold.py`:
- Around line 143-150: The assertion in
test_new_required_citations_reminder_in_body is vacuous because it checks for a
literal token that never appears, so the OR always passes. Update the test to
assert against the actual rendered reminder text produced by the new command
output (via cli/new and _CITATION_REMINDER) and remove the always-true disjunct
so the test verifies the expected citations-required messaging in res.output.

---

Nitpick comments:
In `@src/vouch/cli.py`:
- Line 1033: The allowlist comment near the `vouch new` scaffold kinds is too
descriptive and should explain the constraint instead of restating the constant.
Update the comment attached to the entity kinds allowlist in `cli.py` so it
states why only those kinds are permitted for `vouch new`, and avoid
marketing-style wording; keep the guidance tied to the related `vouch new`
scaffolding logic and the allowlist definition.

In `@tests/test_new_scaffold.py`:
- Around line 1-158: The test file name does not match the module being
exercised; these tests target the cli entrypoint in vouch.cli, not a
new_scaffold module. Rename or relocate the suite to follow the
tests/test_<module>.py convention, and keep the existing test functions (such as
test_new_decision_page_stubs_frontmatter and test_new_pending_not_approved)
under the cli-focused test file name.
- Around line 32-158: Add test coverage for the `--interactive` path in the
`new` command, since the current cases in `test_new_scaffold.py` only cover
direct flags and dry-run behavior. Create a `CliRunner` invocation with
`input=...` for a kind with required fields, and assert the prompted answers are
stored in `pr.payload["metadata"]` after `cli` runs. Use the existing
`test_new_field_prefill_parsed_as_yaml` and `test_new_dry_run_writes_nothing`
patterns as a guide, and keep the assertion focused on the interactive prompt
flow for `new`.
🪄 Autofix (Beta)

Fix all unresolved CodeRabbit comments on this PR:

  • Push a commit to this branch (recommended)
  • Create a new PR with the fixes

ℹ️ Review info
⚙️ Run configuration

Configuration used: defaults

Review profile: CHILL

Plan: Pro Plus

Run ID: 79c7c58a-790f-4d22-864f-dfec63976dad

📥 Commits

Reviewing files that changed from the base of the PR and between 94e84b1 and cc131a5.

📒 Files selected for processing (3)
  • CHANGELOG.md
  • src/vouch/cli.py
  • tests/test_new_scaffold.py

Comment thread src/vouch/cli.py Outdated
Comment thread src/vouch/cli.py
Comment thread tests/test_new_scaffold.py Outdated

Copilot AI 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.

Pull request overview

This PR adds a new vouch new <kind> CLI command that scaffolds a typed page or entity proposal from the page-kind registry (issue #330). It is a client-side convenience that composes the existing propose_page / propose_entity calls, so it introduces no new kb.* surface and stays fully inside the review gate — a scaffolded draft lands only as a pending proposal that a human still approves. The command resolves the requested <kind> against load_page_kind_registry(store) (page kinds win on name collisions unless --entity is set), stubs required frontmatter fields, and supports --field key=value, --interactive, --body, --claim/--source, --dry-run, and --json.

Changes:

  • New new command plus helpers (_resolve_new_kind, _stub_page_frontmatter, _prompt_missing_fields, draft printers) and a _SCAFFOLD_ENTITY_TYPES allow-list; _parse_meta generalized to accept a flag name for diagnostics and reused for --field.
  • 11 new tests in tests/test_new_scaffold.py covering page/entity scaffolds, YAML --field, dry-run (no write), JSON output, collision dispatch, unknown-kind errors, and citation reminders.
  • CHANGELOG.md entry under [Unreleased] > Added.

Reviewed changes

Copilot reviewed 3 out of 3 changed files in this pull request and generated 2 comments.

File Description
src/vouch/cli.py Adds the vouch new command and supporting helpers; generalizes _parse_meta to be reused by --field.
tests/test_new_scaffold.py New test module exercising the scaffold across page/entity, dry-run, JSON, collision, and citation cases.
CHANGELOG.md Documents the new vouch new feature under the Unreleased/Added section.

💡 Add Copilot custom instructions for smarter, more guided reviews. Learn how to get started.

Comment thread src/vouch/cli.py
Comment thread src/vouch/cli.py
jsdevninja added a commit to jsdevninja/vouch that referenced this pull request Jul 1, 2026
catch invalid yaml in --field and interactive prompts, gate citation-required kinds before filing, unify dry-run json id key, and move new command tests into test_cli.py.

Co-authored-by: Cursor <cursoragent@cursor.com>
@plind-junior plind-junior changed the base branch from main to test July 2, 2026 02:56
@plind-junior

Copy link
Copy Markdown
Collaborator

@copilot resolve the merge conflicts in this pull request

jsdevninja and others added 2 commits July 1, 2026 23:55
scaffold typed page and entity proposals from the page-kind registry so
authors get correctly-shaped drafts through the normal review gate.

Co-authored-by: Cursor <cursoragent@cursor.com>
catch invalid yaml in --field and interactive prompts, gate citation-required kinds before filing, unify dry-run json id key, and move new command tests into test_cli.py.

Co-authored-by: Cursor <cursoragent@cursor.com>
@jsdevninja jsdevninja force-pushed the feat/cli-new-scaffold branch from 2b9ac97 to 079b94e Compare July 2, 2026 04:56
@jsdevninja

Copy link
Copy Markdown
Contributor Author

@plind-junior Resolved conflicts

@plind-junior plind-junior merged commit caec9e5 into vouchdev:test Jul 3, 2026
8 checks passed
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

cli command line interface docs documentation, specs, examples, and repo guidance size: M 200-499 changed non-doc lines tests tests and fixtures

Projects

None yet

Development

Successfully merging this pull request may close these issues.

feat: vouch new <kind> — scaffold a typed page/entity proposal from a template

3 participants