Skip to content

Add entry clone and delete, tool section removal, and the matching CLI commands - #52

Open
nicoloesch wants to merge 8 commits into
24-reverse-reference-lookupfrom
26-clone-delete
Open

nicoloesch wants to merge 8 commits into
24-reverse-reference-lookupfrom
26-clone-delete

Conversation

@nicoloesch

@nicoloesch nicoloesch commented Oct 27, 2026 •

Copy link
Copy Markdown
Collaborator

Stacked on #49 (24-reverse-reference-lookup) and targets that branch. Retarget to main once #49 has landed.

Summary

Adds clone_entry and delete_entry as library functions, with clone and delete commands for every entry section. Also adds remove_tool_section with tools list and tools remove, so a stale [tools.*] section no longer blocks deletes.

Changes

  • Add library functions in references.py
    • clone_entry(..., overrides=None) copies an entry under a new name and appends it to the section. The source is kept and nothing is repointed. overrides changes fields of the copy and is validated by the entry's class.
    • delete_entry removes an entry only when nothing references it. It lists the referencing fields, counts package fields that refer through their default, including packages with no section, and refuses when a tool section has no known package class. There is no force option.
    • remove_tool_section removes one [tools.*] section. It needs no package class.
    • They share their checks with rename_entry. A rejected candidate is reported from sanitized errors, so no value appears in the message.
  • Add CLI commands
    • <section> clone NAME NEW_NAME for connections, providers, models and vector-stores, and databases clone cdm and databases clone generic. For example, omop-config connections clone prod test creates [connections.test] from [connections.prod]. Flags change the copy. Without flags every field is prompted with the source value as the default.
    • A reference answered with new starts from the entry the source currently points at.
    • <section> delete NAME confirms first, or skips the prompt with --yes. When a tool section's package is unusable it prints why and points to tools remove.
    • tools list and tools remove NAME.
  • Stop showing a stored secret as the prompt default in the shared entry wizard, which affected add on an existing entry as well. Enter keeps the stored value.
  • Update docs/api/stack-config.md. Add library and CLI tests, including a test that fails without the secret fix.

Behaviour

  • The library functions return a new stack and do not alter the original in place or on disk. Callers persist the result with save_stack_config.
  • Existing add and configure prompts no longer print a stored password.
  • clone, delete and tools remove refuse to save over a change made to the file after they read it, like add and configure.
  • delete refuses while a tool section's package is broken or missing. Remove that section with tools remove, or fix the install.

Checklist

  • Applied exactly one label (feature)
  • Tests pass locally (pytest -q): 729 passed
  • Lint and type checks pass (ruff check ., ty check src/ tests/)

@nicoloesch nicoloesch added the feature New backwards-compatible functionality. MINOR: x.y+1.z label Oct 27, 2026
@nicoloesch
nicoloesch marked this pull request as ready for review November 7, 2026 17:39
@nicoloesch nicoloesch linked an issue Nov 7, 2026 that may be closed by this pull request
1 task done
@nicoloesch
nicoloesch marked this pull request as draft November 16, 2026 21:44
@nicoloesch
nicoloesch marked this pull request as ready for review November 16, 2026 22:05
@nicoloesch
nicoloesch added this pull request to stack #60 November 16, 2026 22:05
@nicoloesch nicoloesch added feature New backwards-compatible functionality. MINOR: x.y+1.z and removed feature New backwards-compatible functionality. MINOR: x.y+1.z labels Nov 16, 2026
@nicoloesch nicoloesch added feature New backwards-compatible functionality. MINOR: x.y+1.z and removed feature New backwards-compatible functionality. MINOR: x.y+1.z labels Nov 17, 2026
@gkennos
gkennos self-requested a review November 18, 2026 05:40

@gkennos gkennos left a comment

Copy link
Copy Markdown
Member

Choose a reason for hiding this comment

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

approving with open very minor issue that you can track with new issue and get releasing I think that's more important than iterating again?

choice = typer.prompt(
" Point to an existing entry, or 'new' to create one", default=suggested
)
if choice != "new" and choice in candidates:

Copy link
Copy Markdown
Member

Choose a reason for hiding this comment

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

Minor clone-wizard quirk: after choosing new for a nested reference, pressing Enter accepts the existing reference’s name and reuses it instead of creating a new entry. Entering a distinct name works.

Suggested fix is to leave the new-name prompt blank by default, or reject an already-used name after the user chose new.

Copy link
Copy Markdown
Collaborator Author

Choose a reason for hiding this comment

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

Agreed, folded it in here since we were already in this function. Choosing new now only offers the default name while it is free, and a name that already exists is asked for again, so it can no longer silently reuse an entry. Added a test for it (683728c). Re-requesting review since the change is small.

@nicoloesch
nicoloesch requested a review from gkennos November 19, 2026 21:32

This branch has not been deployed

No deployments
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

feature New backwards-compatible functionality. MINOR: x.y+1.z

Projects

None yet

Development

Successfully merging this pull request may close these issues.

Add named-entry clone and guarded delete

2 participants