Summary
cortex memory write computes the note file path from --type alone (naive type + "s"), so:
- It ignores
--category entirely when building the target directory.
- Naive pluralization produces wrong dir names (
entity -> entitys, knowledge -> knowledges).
--update therefore cannot find existing notes created by the encoder/import, which live under <type-plural>/<category>/<id>.md (e.g. entities/systems/, knowledge/api/).
Net effect: --update fails with "Note does not exist" for notes that clearly exist (cortex memory get <id> returns them), and fresh writes land in a flat, wrong directory (I found a stranded knowledges/cortex-lint-fix-...md from an earlier write).
Repro
# Note exists and is readable:
cortex memory get jira # works -> entities/systems/jira.md
# But update fails:
cortex memory write --update --title "jira" --type entity --category systems \
--tier skill:jira --body-file ./x.md --no-encode
# -> "Note does not exist at <vault>/entitys/jira.md"
# (wrong: naive plural 'entitys', and category 'systems' dropped)
Same for --type knowledge --category api -> looks in knowledges/ instead of knowledge/api/.
Root cause
cortex/cli/main.py:1133-1137:
type_dir_name = note_type + ("s" if not note_type.endswith("s") else "")
target_dir = vault_path / type_dir_name # <-- --category never used
target_dir.mkdir(parents=True, exist_ok=True)
note_path = target_dir / f"{note_id}.md"
entity + "s" -> entitys (should be entities).
--category is accepted as an option but never contributes to the path.
Suggested fix
The encoder already solves this correctly for the update case — cortex/encoder/core.py:897-901 does a recursive lookup by id before falling back to a type dir:
for md in vault_root.rglob("*.md"):
meta, _ = parse_frontmatter(md.read_text(...))
if meta.get("id") == note_id:
local_path = md
break
memory write should do the same:
- On
--update: locate the existing note by id via rglob (matching the encoder), regardless of directory, instead of reconstructing the path from --type.
- On create: build the path as
<type-plural>/<category>/<id>.md using --category, and use a correct pluralization map (entity -> entities, knowledge -> knowledge/knowledges per convention) rather than blind + "s".
Workaround
Edit the note files directly in the vault (preserve frontmatter, bump updated), then run cortex encode.
Environment
- cortex-ai 2.0.0 (uv tool install from
~/Projects/Cortex-AI)
- macOS (darwin), Python 3.12
Summary
cortex memory writecomputes the note file path from--typealone (naivetype + "s"), so:--categoryentirely when building the target directory.entity->entitys,knowledge->knowledges).--updatetherefore cannot find existing notes created by the encoder/import, which live under<type-plural>/<category>/<id>.md(e.g.entities/systems/,knowledge/api/).Net effect:
--updatefails with "Note does not exist" for notes that clearly exist (cortex memory get <id>returns them), and fresh writes land in a flat, wrong directory (I found a strandedknowledges/cortex-lint-fix-...mdfrom an earlier write).Repro
Same for
--type knowledge --category api-> looks inknowledges/instead ofknowledge/api/.Root cause
cortex/cli/main.py:1133-1137:entity + "s"->entitys(should beentities).--categoryis accepted as an option but never contributes to the path.Suggested fix
The encoder already solves this correctly for the update case —
cortex/encoder/core.py:897-901does a recursive lookup byidbefore falling back to a type dir:memory writeshould do the same:--update: locate the existing note byidviarglob(matching the encoder), regardless of directory, instead of reconstructing the path from--type.<type-plural>/<category>/<id>.mdusing--category, and use a correct pluralization map (entity -> entities,knowledge -> knowledge/knowledgesper convention) rather than blind+ "s".Workaround
Edit the note files directly in the vault (preserve frontmatter, bump
updated), then runcortex encode.Environment
~/Projects/Cortex-AI)