Repository navigation
Create a node from a markdown document; import takes front matter as properties - #4247
Merged
Merged
Conversation
…properties node_ops::create_node treats the content of a document-type node (text, task, project, spec, plan, decision and their subtypes) given more than one block, or front matter, as a markdown document: the first line (heading marker stripped) is the node's content and the rest is parsed into child nodes by the importer's parser. Markup types and title-template types keep their content as given. A leading front matter block (YAML mapping between --- lines) becomes properties of the root instead of nodes: a key the type declares is set as that field, a namespaced key is kept, a leading-underscore key is dropped, and any other key is stored as custom:<key>. Import applies the same rule to the text root, and the import result reports the stored key count (new front_matter_keys field, printed by the CLI). Co-Authored-By: Claude Sonnet 5.5 <[email protected]>
…matter The split moves out of node_ops::create_node into node_ops::create_document_node, reached by a new CreateDocument RPC that only the CLI's node create calls. CreateNode, the editor and the agent tools store content as given. In the document path: the first line must be a plain line or a heading; a closing-delimited --- block that is not a YAML mapping with unique string keys is refused; content over the markdown size cap is refused before parsing. An empty namespace (custom:) is not a namespace. The importer keeps treating such a block as the lines it is. import_markdown_content takes a DocumentOptions struct instead of eight arguments. Co-Authored-By: Claude Sonnet 5.5 <[email protected]>
Co-Authored-By: Claude Sonnet 5.5 <[email protected]>
mstomar125
force-pushed
the
issue-4237-md-create
branch
from
November 5, 2026 11:39
5f2573c to
8bac840
Compare
17 tasks
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.
Part of #4237. Does not close it: the agent-lane pieces (see "Not done") are left, because they live in
packages/agent.What changed
node_ops::create_document_node, reached by a newCreateDocumentRPC (same request/response types asCreateNode; no existing literal changes) that only the CLI'snode createcalls.node_ops::create_node, theCreateNodeRPC, the editor and every existing agent tool store content exactly as before. (An earlier revision put the split increate_nodeitself, which would have split editor and agent-tool content; that is gone.) For a type that is not a document type, or content that is a single block with no front matter,create_document_nodeiscreate_node.text,task,project,spec,plan,decision,issue,software-projectand user types extending them.code-block,quote-block,table, the other block types and types named otherwise keep multi-line content;personkeeps rejecting content.#..######marker stripped, via the importer's own helper) and the rest is parsed withprepare_nodes_from_markdownand written withbulk_create_hierarchy.InvalidParams, nothing created): the first line must be a plain line or a heading. A code fence, table row, numbered or bullet item, quote, checklist item or---as first line is refused with a message naming the shape.core/src/markdown/document.rs, newserde_yaml_ngdependency): a block is front matter when line 1 is exactly---, a later line is exactly---or..., and the lines between parse as a non-empty YAML mapping with unique string keys. In the document path, a closed---block that does not parse that way (YAML error, list, plain text, repeated or non-string key) is refused with a clear error and nothing is created. In the importer such a block keeps being imported as the lines it is (horizontal lines and text), as today.undeclared_core_keys) is set as that field and validated by the normal create (decision_status: maybeis refused with the field's message); a key already namespaced (custom:,org:,plugin:with a non-empty name) is stored as given; a key starting with_is dropped; a key that names a core type or is an empty namespace is stored ascustom:<key>; any other key on a core type iscustom:<key>. For a type that is not a core type itself (a user subtype),undeclared_core_keysreports nothing and its open bucket takes keys as given, so those keys are stored without the prefix. An explicitpropertiesargument wins over a front matter key. Front matter with no title is refused.create_node(placement, collections, lifecycle, validation) and the body is a second transaction (bulk_create_hierarchy). If the body fails, the root is deleted again and the call fails, so nothing is left; the root is briefly visible and a created then deleted event pair is emitted. Writing both in one transaction would needcreate_placed_node_in_collectionssplit apart, which I judged too large here.create_document_nodeuses the validatingbulk_create_hierarchywhile the importer usesbulk_create_hierarchy_trusted(behaviour validation only), so a body can pass import and be refused by create when the root's type has children rules thetextroot of an import does not; the error surfaces and nothing remains.custom:<key>properties of thetextroot (single-file, batch and--replace), creating no node.FileImportResultgetsfront_matter_keys(proto field 8), printed byimport file, in--jsonand in the daemon summary. Untouched (already imported, no replace) documents report 0. On--replacethe new keys are merged into the root's properties; keys from an earlier version of the file that the new front matter no longer has are not removed.root_content_for_titleandcontent_without_title_linemoved tocore::markdown;import_markdown_contenttakes aDocumentOptionsstruct instead of eight arguments.node create --contenthelp,SKILL.mdandreferences/cli.mddescribe the behaviour (skill:genregenerated,skill:checkclean).Tests
Core (
tests/it/markdown_document_create_test.rs, 18 tests;markdown::documentunit tests, 8): decision title + parsed body; marker stripped in each shape; single block unchanged; markup types keep content;personstill rejects;the_generic_create_does_not_split_a_multi_block_node(text, task, decision, with and without front matter); every refused first-line shape; every malformed front matter shape; declared field and invalid value;custom:for string, list, nested, number, bool; namespaced and_keys; empty namespace; explicit property wins; non-object properties refused; subtype gating in both directions (issue, a user type extendingdecisionsplit; a plain user type does not); node cap and size cap; parent, position and collection kept with a body; a body write that fails leaves no root.Daemon:
CreateNodeRPC stores content as given whileCreateDocumentsplits, setsdecision_status, and returns InvalidArgument without creating anything for a bad title; importer front matter tests (both import paths); created document body equals the same text imported as a file.Mutation checks (production change, intended test fails, reverted):
CreateNodealso splitting (daemon test), title check removed, malformed block ignored, size cap removed, root cleanup removed, front matter winning over explicit properties, non-object properties ignored, document types removed (15 core tests fail), node cap removed, empty-namespace rule removed (unit test), plus the first round (single-block gate,custom:prefix, type gate, marker strip, children insert, import front matter, import key count).Ran:
cargo fmt --check,cargo clippy -p nodespace-core -p nodespace-daemon -p nodespace-cli -p nodespace-proto --all-targets -- -D warnings -D clippy::unused-async, core libmarkdown::(145), core--test it markdown_document_create(18), daemonimport_service(47) and theCreateDocumentRPC test, cliimport(18),bun run skill:check; pre-push lint gate.Not done
create_nodetool does not take documents: it callsnode_ops::create_node, which is deliberately unchanged, andpackages/agentis not touched here. Giving it the behaviour means callingcreate_document_nodefrom the tool (apackages/agentchange). The seeded rules, graph skills, prompt snapshots andshape:checkreconcileentries are inpackages/agenttoo.NODESPACE_HOME.🤖 Generated with Claude Code