Skip to content

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_flowpipe/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)

  1. Validate — old flow exists in registry, new flow name doesn't conflict
  2. Build plan — list all file moves, registry edits, bib rewrites, citekey replacements
  3. 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/ and notes/ markdown files f. Regenerate MkDocs nav fragment
  4. 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 with flow_rename(root, pipe, old, new, execute)
  • packages/pipeio/src/pipeio/mcp.pymcp_flow_rename() wrapper
  • packages/pipeio/src/pipeio/cli.pypipeio flow rename subcommand
  • src/projio/mcp/pipeio.pypipeio_flow_rename() wrapper
  • src/projio/mcp/server.py — tool registration

Acceptance Criteria

  • [ ] pipeio flow rename pipe old new shows preview of all changes
  • [ ] pipeio flow rename pipe old new --yes executes 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_rename works with execute=False (preview) and execute=True
  • [ ] All existing tests still pass

Result

(Filled in after execution)