Implement pipeio flow rename with modkey.bib citekey update¶
Goal¶
Add a pipeio flow rename CLI command and pipeio_flow_rename MCP tool that safely renames a flow within a pipe, updating all pipeio-managed references. Preview-first (dry run by default, --yes to execute).
Scope: flow rename only. Pipe rename is excluded — derivative directories are tied to pipe names via datalad subdatasets, making pipe rename risky and requiring datalad-level coordination.
Context¶
Flow names appear in multiple pipeio-managed entities. A rename must update all of them atomically or provide a clear rollback. The modkey.bib citekeys use the pattern pipe-{pipe}_flow-{flow}_mod-{mod} and are referenced in manuscripts via pandoc-citeproc ([@pipe-X_flow-Y_mod-Z]).
Entities affected by flow rename¶
| Entity | Location | What changes |
|---|---|---|
| Registry | .projio/pipeio/registry.yml |
Key pipe/old_flow → pipe/new_flow, .name field, code_path, config_path, doc_path |
| Code directory | code/pipelines/{pipe}/{old_flow}/ |
mv to {new_flow}/ |
| Docs tree | docs/pipelines/{pipe}/{old_flow}/ |
mv to {new_flow}/ |
| modkey.bib | docs/pipelines/modkey.bib |
All citekeys containing flow-{old_flow} → flow-{new_flow}, plus title and note fields |
| Manuscript/note references | *.md, *.tex files |
[@pipe-X_flow-old_mod-Z] → [@pipe-X_flow-new_mod-Z] |
| MkDocs nav fragment | Generated by pipeio docs nav |
Regenerate after rename |
| notebook.yml | {flow}/notebooks/notebook.yml |
No change (no flow name embedded) |
| Snakefile | {flow}/Snakefile |
No change (no flow name embedded) |
| Flow config | {flow}/config.yml |
No change (no flow name embedded) |
What does NOT change¶
- Pipe name (excluded from scope)
- Mod names within the flow
- Notebook paths within notebook.yml (relative to flow root)
- Snakefile rule names
- Flow config content
Design¶
CLI¶
pipeio flow rename <pipe> <old_flow> <new_flow> # dry-run preview
pipeio flow rename <pipe> <old_flow> <new_flow> --yes # execute
MCP tool¶
pipeio_flow_rename(pipe: str, old_flow: str, new_flow: str, execute: bool = False) -> dict
Returns a plan with all changes that will be made. When execute=False (default), nothing is modified — just the preview. When execute=True, applies all changes.
Implementation steps (inside the tool)¶
- Validate — old flow exists in registry, new flow name doesn't conflict
- Build plan — list all file moves, registry edits, bib rewrites, citekey replacements
- If execute:
a. Move code directory
b. Move docs directory
c. Update registry.yml (rewrite key, name, all paths)
d. Rewrite modkey.bib (string replace on citekeys, titles, notes)
e. Grep-and-replace citekey references in
docs/andnotes/markdown files f. Regenerate MkDocs nav fragment - Return — plan + status (previewed | executed | error)
Citekey replacement¶
Pattern: pipe-{pipe}_flow-{old}_mod-{mod} → pipe-{pipe}_flow-{new}_mod-{mod}
This is a simple string replacement since the flow segment is delimited by _flow- prefix and _mod- suffix. Apply to:
- modkey.bib (citekeys, title fields, note fields)
- All .md files under docs/ and notes/ (pandoc citations [@citekey])
- All .tex files if any
Files to implement in¶
packages/pipeio/src/pipeio/rename.py— new module withflow_rename(root, pipe, old, new, execute)packages/pipeio/src/pipeio/mcp.py—mcp_flow_rename()wrapperpackages/pipeio/src/pipeio/cli.py—pipeio flow renamesubcommandsrc/projio/mcp/pipeio.py—pipeio_flow_rename()wrappersrc/projio/mcp/server.py— tool registration
Acceptance Criteria¶
- [ ]
pipeio flow rename pipe old newshows preview of all changes - [ ]
pipeio flow rename pipe old new --yesexecutes rename - [ ] Registry.yml updated with new flow name and paths
- [ ] Code directory moved
- [ ] Docs directory moved
- [ ] modkey.bib citekeys updated
- [ ] Pandoc citation references updated in docs/*.md
- [ ] MkDocs nav regenerated
- [ ] MCP tool
pipeio_flow_renameworks with execute=False (preview) and execute=True - [ ] All existing tests still pass
Result¶
(Filled in after execution)