Repository navigation
fix(links,notes): id-form backlinks, a way to fix a title, and stop eating one - #166
Merged
Merged
Conversation
…ating one Tier 1 of the field-test backlog — four interlocking problems about titles and links, all of which ended in something unrecoverable. **`[[<id>]]` produced no backlink**, though SKILL.md promises "[[note-slug]] or [[<id>]] … backlinks are found automatically" and Resolve accepts the 6-char short id nt prints at creation, in index, search and recall. references() only ever matched the full ULID, so an id-form link resolved FORWARD while the target showed "linked from: (none)" and `nt links --orphans` called it an orphan. Backlink discovery now accepts the short form too, restricted to Crockford base32 (the ULID alphabet, no I/L/O/U) so an ordinary slug can't be misread as an id suffix — Resolve disambiguates against the real note list, this function can't, so it errs narrow. The candidate scan also runs for an id-only target now, so short-id links to TASKS are found as well. **A path-style title silently overrode --kind and deleted a word.** The guard only rejected prefixes containing whitespace, so any title opening with a bare directory token — "internal/cli test-gap audit", "README/SPEC drift", "CI/CD" — was read as filing syntax: filed under internal/, with "internal" stripped from the title for good. Three of five field-test agents hit this independently. An explicit --kind (like --folder already did) now suppresses the inference, and when the shorthand does fire it says so on stderr instead of leaving the created path as the only clue. `nt note "custom/x"` with no flags is unchanged. **There was no way to fix a title from the CLI.** `nt edit` had --desc but no --title, and `nt mv` pins the OLD title into frontmatter where it beats the body H1 — so editing the H1 changed nothing visible and the only escape was --supersede (new id, every inbound link broken) or hand-editing frontmatter. `nt edit --title` sets both, rewriting a leading H1 only when it still carries the previous title. This is also the recovery path for the truncation above. **`nt mv` didn't slug its destination**, so a human-readable name produced the one file in the store with literal spaces in it, unlike `nt note` which always slugs. Regression tests for all four; the backlink one was confirmed to fail against the unfixed code. TestNotePathStyleTitleBeatsKindFolder is replaced by two tests stating the new precedence, since it pinned the behavior being changed. Co-Authored-By: Claude Opus 5 <noreply@anthropic.com> Claude-Session: https://claude.ai/code/session_01FgqQf7Lvou5F5as9aNmagu
Co-Authored-By: Claude Opus 5 <noreply@anthropic.com> Claude-Session: https://claude.ai/code/session_01FgqQf7Lvou5F5as9aNmagu
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment
Add this suggestion to a batch that can be applied as a single commit.This suggestion is invalid because no changes were made to the code.Suggestions cannot be applied while the pull request is closed.Suggestions cannot be applied while viewing a subset of changes.Only one suggestion per line can be applied in a batch.Add this suggestion to a batch that can be applied as a single commit.Applying suggestions on deleted lines is not supported.You must change the existing code in this line in order to create a valid suggestion.Outdated suggestions cannot be applied.This suggestion has been applied or marked resolved.Suggestions cannot be applied from pending reviews.Suggestions cannot be applied on multi-line comments.Suggestions cannot be applied while the pull request is queued to merge.Suggestion cannot be applied right now. Please check back later.
Tier 1 of the field-test backlog — four interlocking problems about titles and links. They belong together because each one made the others unrecoverable.
1.
[[<id>]]produced no backlinkSKILL.md promises, verbatim: "Use
[[note-slug]]or[[<id>]]… backlinks are found automatically." AndResolveaccepts the 6-char short id — which is what nt prints at creation, innt index,nt searchandnt recall.But
references()matched only the full ULID. So an id-form link resolved forward while the target reportedlinked from: (none), andnt links --orphanscalled it an orphan.Backlink discovery now accepts the short form, restricted to Crockford base32 (the ULID alphabet — no
I/L/O/U) so an ordinary slug can't be misread as an id suffix.Resolvegets to disambiguate against the real note list; this function doesn't, so it deliberately errs narrow. The candidate scan also runs for an id-only target now, so short-id links to tasks are found too.2. A path-style title silently overrode
--kindand deleted a wordThe guard rejected a slash only when the prefix contained whitespace. So any title opening with a bare directory token was read as filing syntax:
Filed under
internal/— notref/— with "internal" stripped from the title permanently.94e0ab1fixed the whitespace case; this is the other half.Three of five field-test agents hit this independently, which is the strongest signal in the whole exercise.
Now: an explicit
--kindsuppresses the inference, the way--folderalready did. And when the shorthand does fire it says so on stderr, rather than leaving the created path as the only clue.nt note "custom/x"with no flags is unchanged.TestNotePathStyleTitleBeatsKindFolderpinned path-style beating--kindas deliberate, so it's replaced by two tests stating the new precedence. The justification is that the old rule didn't just choose a folder — it destroyed part of the title, with no way to put it back (see #3).3. There was no way to fix a title from the CLI
nt edithad--descbut no--title. Andnt mvpins the old title into frontmatter, where it beats the body H1 — so editing the H1 changed nothing visible. The only escapes were--supersede(new id, every inbound link broken) or hand-editing frontmatter, which is what one field-test agent actually resorted to.nt edit --titlesets both, rewriting a leading H1 only when it still carries the previous title (an H1 the author chose independently is left alone). This is also the recovery path for #2.4.
nt mvdidn't slug its destinationnt mv <note> "ref/My Long Name"wrote a file with literal spaces — the only file in the store nt hadn't slugged, unlikent note, which always does.Tests
Regression tests for all four. The backlink test was confirmed to fail against the unfixed code before committing. A companion test pins that a non-id slug link does not create a spurious backlink, covering the Crockford guard.
go build,go vet ./...,go test ./...all clean.Generated by Claude Code