rename

package
v0.3.2 Latest Latest
Warning

This package is not in the latest version of its module.

Go to latest
Published: Sep 6, 2026 License: Apache-2.0 Imports: 8 Imported by: 0

Documentation

Overview

Package rename moves every trace of a project from one name to another, so that renaming a project is an ordinary edit rather than an event that costs you your history.

Why this exists: a project name is derived from the folder you are standing in (see internal/scope), and folders get renamed. Before this, renaming one silently forked the work — the new name had no checkpoints, the old name had all of them, and nothing anywhere said so. The workaround was to pin the old name with a .logos-project marker, which is a fine answer to "these two names are the same work" and a bad answer to "I changed my mind about the name". Changing a name should not be a thing you avoid doing.

A name is written down in five places, and a rename that misses one leaves history split in a way that is harder to notice than a clean break:

sessions/<name>/            the vault directory checkpoints are filed under
  ...*.md frontmatter       project: <name>, and a [[<name>]] relation
memories/<kind>.md          project=<name> in each line's trailing comment
activity/*.jsonl            "project":"<name>" on each event
index.db                    memories.project, memory_log.project,
                            sessions.project

The vault is rewritten first and the index second, in that order and never the reverse: the vault is the truth and the index is a cache that `brain index` can rebuild from it. A crash between the two leaves a stale cache, which is recoverable; a crash the other way would leave an index pointing at a name the vault no longer uses, which is not.

Index

Constants

This section is empty.

Variables

This section is empty.

Functions

This section is empty.

Types

type Result

type Result struct {
	Checkpoints int // vault session notes rewritten
	Memories    int // memory lines rewritten in memories/*.md
	Events      int // activity log events rewritten
	Rows        int // index rows updated
	Dir         string
	NewDir      string
}

Result counts what a rename touched, so the caller can report it rather than claiming success in the abstract. A rename that reports "0 checkpoints" when the user expected forty is the failure worth surfacing, and it is only visible if the numbers are.

func Run

func Run(db *sql.DB, vaultDir, from, to string, dryRun bool) (Result, error)

Run renames project `from` to `to` across the vault and then the index.

dryRun does every read and no write, returning the same counts the real run would produce. It exists because this rewrites files in the user's vault, and "show me what you would touch" has to be available without asking the user to trust a description of it.

func (Result) Empty

func (r Result) Empty() bool

Empty reports whether the rename found nothing at all under the old name — almost always a typo in the name, and worth saying so instead of printing a row of zeroes that reads like success.

Jump to

Keyboard shortcuts

? : This menu
/ : Search site
f or F : Jump to
y or Y : Canonical URL