Skip to content

node create takes a markdown document: the first line is the title, the rest is parsed into child nodes; import no longer takes front matter as the title #4237

Done

Description

@malibio

Overview

A node can be created from a markdown document in three ways today, and none of them gives a node of a chosen type with a short title and a parsed body. nodespace node create --type <type> --content "<markdown>" stores the whole text as the node's content (one node, no children, and a title that is the whole text flattened to one line). nodespace import file parses the body into child nodes, but it makes the root a plain text node and has no way to name the type or the parent. The local agent's create_nodes_from_markdown can attach a parsed body under a parent, but only in the in-app agent. This issue makes node create take the document as markdown the way a file is imported: the first line is the node's title and the rest is parsed into child nodes. It also fixes the import of a file that starts with front matter.

Problem Statement

What exists today, checked against a scratch database:

  • node create --type decision --content "<multi-block markdown>" creates one decision node with the whole markdown as content (359 characters in the test) and no children. Its title, read from a query, is the whole content with the markup stripped, on one line.
  • import file strips the heading syntax from the root's content (a root starting # Title, ## Title, a plain paragraph or a setext heading all come out as a clean title) and parses the body into header, text, ordered-list and code-block children, but the root is always a text node, and the import request (import_service.proto: file path and options) carries no type and no parent.
  • A file that starts with YAML front matter imports with a root whose content is ---, the front matter fields as a separate text child, a horizontal-line child, and the real # Heading as a header child with its # prefix kept. Of 226 non-archived pages in the docs repository, 2 start with front matter.
  • The in-app agent's create_nodes_from_markdown takes markdown, parent_id and collection and parses under a parent, but there is no CLI or external-agent equivalent, so the CLI cannot create a typed root with a parsed body.

Proposed Solution

  • node create --content takes a document. When the content has more than one block, the first non-empty line becomes the node's own content, with a leading heading marker (# to ######) stripped as the importer strips it from a file's first heading, and the remaining blocks are parsed into child nodes under the new node by the importer's parser (prepare_nodes_from_markdown). Content that is a single block behaves as today, so the existing single-line calls do not change.
  • The type is given by --type. It is not read from the content.
  • Which types split. Only types whose node is a document root take part (the types a document can be, such as decision, spec, plan, task and text). The markup types keep multi-line content as it is: code-block, quote-block, table and the other block types. The exact list is settled in the implementation and stated in the acceptance criteria.
  • A type whose name comes from a title template (such as person) keeps rejecting content.
  • Front matter in an imported file becomes properties of the root. Front matter is metadata about the document, and a node's properties are how NodeSpace holds metadata. A block is front matter when the file's first line is exactly ---, a later line is exactly --- (or ...), and the lines between them parse as a YAML mapping. Each top-level key is stored on the root with its value kept as the JSON type it has (a string, a number, a boolean, a list, or a nested object). A key that is the exact name of a field the root's type declares is set as that field, validated against the type's rules (for a decision, decision_status and one of proposed, accepted, superseded). Any other key is stored as custom:<key>, because a core type takes only declared fields and custom: is the namespace for one a user adds to it. The root's type is known when the front matter arrives through node create --type <type> --content; an imported file's root is always text, so its keys are all custom:<key>. The first heading (or first line) after the block is the root's title, and no --- node or text node is created for the block. A --- that does not meet this rule is a horizontal line, as today, and a --- anywhere after the first line is always a horizontal line.
  • A YAML parser is added to core for this (core has none today), and the import result reports how many front matter keys were stored, so a file whose block did not parse is visible.
  • The agent's create_node tool gets the same behaviour, so the in-app agent and the CLI agree.
  • Guidance changes in the same issue, because the input of node create changes: the shipped skill's SKILL.md and references/cli.md (and its minimum CLI version stamp), the seeded rules that describe node create, and the graph skills built from them.

Documentation

The decision to keep a node's title as its own content and the body as children is already how a Decision is recorded (the "Recording a Decision" skill). Update components/seeded-nodes.md if the seeded rules change, and the node-type reference only if a type's rules change; this issue adds no node type.

Architecture Impact

Core, daemon and CLI. The create request stays a content string, so the wire type is unchanged, and the parser already exists in core (prepare_nodes_from_markdown in core/src/markdown/mod.rs, used by import and by seeding). The change is in the create path (NodeService::create_node in core/src/services/node_service/crud.rs and the daemon's create_node in daemon/src/services/node_service.rs), and the importer's title handling for front matter. Seeded rules and skills change, so shape:check needs a reconcile change-log entry for each changed seed.

Acceptance Criteria

  • nodespace node create --type decision --content "# Title\n\nbody with a list and a code block" creates a decision whose content is Title (marker stripped) and whose body is parsed into child nodes (headers, text, ordered lists, code blocks), as import file parses the same text.
  • A single-block --content creates one node exactly as before; the existing node create calls in the seeded rules, SKILL.md and references/cli.md need no change to keep working.
  • The types that split are listed, and code-block, quote-block and table keep multi-line content as one node; a test covers a type from each side of the list.
  • A type with a title template still rejects content.
  • import file on a file that starts with front matter gives a root whose content is the first heading's text (or first line), with each top-level key stored on the root as custom:<key> and its value as the matching JSON type (string, number, boolean, list, nested object); a test covers each type, and no node is created for the block.
  • The import result reports how many front matter keys were stored (a field on the import result in import_service.proto, regenerated, and printed by the CLI), and a block that does not parse as a YAML mapping is imported as the horizontal lines and text it is today.
  • A file that starts with a horizontal line --- that is not followed by a closing --- around a YAML mapping, and a --- after the first line, import as a horizontal-line as today; a test covers each.
  • node create --type decision --content with front matter containing decision_status: accepted creates a decision whose decision_status is accepted; an invalid value is rejected with the field's own message, and nothing is created.
  • A key that is not a declared field of the node's type is stored as custom:<key>, with a test for a string, a list and a nested object.
  • A front matter key that is already namespaced (custom:x) or reserved (a leading _) is handled by a stated rule and a test, and the node-type sequence is not triggered because no field or type is added.
  • A file with no front matter imports unchanged.
  • The first heading's marker is stripped from the root in every shape the importer already handles (#, ##, a plain first paragraph, a setext heading), and a test pins each.
  • The agent's create_node tool takes the same markdown content and produces the same tree as the CLI.
  • The shipped skill (SKILL.md, references/cli.md) describes the new behaviour and its minimum CLI version is raised, and a CLI older than that is flagged by the existing version check.
  • The seeded rules and graph skills that describe node create state the rule once, the prompt snapshots are regenerated and reviewed, and shape:check passes with a reconcile entry per changed seed.
  • A test asserts that a body parsed under a new node produces the same child node types and order as importing the same text as a file.
  • Code passes bun run quality:fix; bun run test:changed passes.

Technical Specifications

Reference Files

  • packages/core/src/markdown/mod.rs - prepare_nodes_from_markdown, parse_markdown and the importer's title handling
  • packages/core/src/services/node_service/crud.rs, packages/daemon/src/services/node_service.rs - the create path
  • packages/cli/src/commands/node.rs - create and its help text
  • packages/agent/src/local_agent/tools.rs - create_node and create_nodes_from_markdown
  • packages/skill/SKILL.md, packages/skill/references/cli.md, scripts/stamp-skill-md.ts
  • packages/agent/src/seeds/rules/skill-md/ - the rules that run nodespace node create

Implementation Details

Reuse the importer's parser; do not write a second one. Do not add a flag: --content keeps its name. No compatibility shim for the old whole-text behaviour on a multi-block content: it changes outright.

Non-Goals

  • A front-matter node type. Front matter is metadata and is stored as properties, so no type is added.
  • Writing properties back out as front matter on export.
  • Aliases between a front matter key and a declared field of a different name (status for decision_status), and declaring the custom: keys in a schema. Only an exact name match is set as a declared field; what to do with other keys beyond custom: is decided later.
  • A --title or --body flag.
  • Changing how a node's title is derived from its content.

Related Issues

Activity

  1. self-assigned this
    on Nov 5, 2026
  2. mstomar125 commented on Nov 5, 2026

    @mstomar125
    Contributor

    Picking this up (sweep drain).

  3. mstomar125 commented on Nov 5, 2026

    @mstomar125
    Contributor

    Merged (cf5a5e8): nodespace node create now takes a markdown document through a new CreateDocument RPC (the first line is the title, the rest is parsed into child nodes; a bad first line or unparseable front matter is refused and nothing is created), and import takes front matter as properties of the root. The generic create RPC, the editor and the agent's tools are unchanged by design.

    Still open, in the agent's lane (packages/agent): the seeded rules, graph skills and prompt snapshots that should teach an agent to use the document create, plus the shape-record reconcile entries they bring. The minimum CLI version for the skill is stamped at release time; a new CLI against an old daemon answers Unimplemented for node create.

    🤖 Generated with Claude Code

  4. mstomar125 commented on Nov 6, 2026

    @mstomar125
    Contributor

    Picking this up again for the agent-lane part (sweep drain).

  5. mstomar125 commented on Nov 13, 2026

    @mstomar125
    Contributor

    Picking up the agent-lane part: making the in-app agent's create_node take document markdown the same way as the CLI (Refs #4237).

  6. mstomar125 commented on Nov 13, 2026

    @mstomar125
    Contributor

    #4275 merged: the in-app agent's create_node now takes a markdown document through the same core function as nodespace node create (first line = title, front matter = fields, rest = child nodes, same type allow-list and caps; non-document types keep content whole). A parity test compares the trees from the agent tool and the CLI path. What is left on this issue: a prompt dump of the changed skills and the new create_node description on the local model, and eval scenarios for creating a task, a decision and a split issue through the CLI form (live model, CPU-only small model is approved). The new tool-description wording has not been measured on a live model yet. Minimum CLI version stamp is set at release time (scripts/stamp-skill-md.ts).

  7. mstomar125 commented on Nov 16, 2026

    @mstomar125
    Contributor

    Picking this up. The in-app agent half is merged (#4275); the remaining work is the YAML front matter parsing on import and on node create, the node create document split, the import result's front matter count, and the skill and seeded-rule guidance.

  8. mstomar125 commented on Nov 16, 2026

    @mstomar125
    Contributor

    Correction to the comment above: the front matter parsing, the node create document split, the import result's front matter count and the skill and seeded-rule guidance are all already on main (#4247 and #4275). Checked against main on 2026-11-16: the create-document tests (19), the front matter unit tests (8), the daemon import tests (47) and the CLI import tests (18) pass. What is left on this issue is only the measurement on the local model: a prompt dump of the changed skills and the new create_node description, and eval scenarios for creating a task, a decision and a split issue through the document form (CPU-only small model).

  9. mstomar125 commented on Nov 16, 2026

    @mstomar125
    Contributor

    Live measurement of the new create_node document form, on 2026-11-16: CPU only, gemma-4-E4B-it Q4_K_M, 4 threads, nomic-embed-text-v1.5 Q8_0, temperature 0.1, 3 repetitions of each scenario. One turn on the real production tool definitions (create_node, create_nodes_from_markdown, create_task) over a real store; the assertion is on what the store holds afterwards (root type, single-line title without the heading marker, nodes below it).

    Scenario Tool the model chose Record stored Right record
    task given as a document create_task (3 of 3) type issue, title 'Fix the login redirect loop', a text child and 3 checkbox children 3 of 3
    the same task, create_task withheld create_node with the whole document in content and node_type task (3 of 3) type task, title 'Fix the login redirect loop', a text node and the list below it (2 nodes) 3 of 3
    decision given as a document create_node (3 of 3) type decision, title 'Use SQLite for the local store', children text, header, header (5 nodes below) 3 of 3
    spec with three sections create_node (3 of 3) type spec, title 'Offline mode for the mobile app', three header children (6 nodes below) 3 of 3

    Nothing failed, so no wording change is proposed. Two observations: when create_task is offered the model prefers it for a task and chose the issue type because the work is a code bug (the tool's own rule); and a paragraph followed by a numbered list nests the list under the paragraph, so a document without headings has one direct child, which is the same split import file makes (the parity test in #4275 pins it).

    The create_node description the model was shown begins: 'Create one new record of a type that already exists. Use for a single instance, never to define a new kind of record. STOP if the record is already listed in MENTIONED ENTITIES with the same name and type … For a text, task, project, spec, plan or decision record, a markdown document with more than one block (or front matter) in content is split, exactly as nodespace node create does: its first line is the title, its front matter becomes its fields, and the rest becomes child nodes in order (the result's child_count says how many), so do not create them again.' The content parameter reads 'The record's title and nothing else: the shortest phrase naming what this record IS …', which does not mention the document form; the model used the document form anyway in 9 of 9 reps where it chose create_node.

    Not measured: the skill text (SKILL.md and the seeded rules) is for external agents and for the in-app loop's skills, and this harness is a single turn without them; a full-loop run with the skills injected would be the next step if the document form is ever mis-chosen. The test is in the PR for this issue.

  10. mstomar125 commented on Nov 16, 2026

    @mstomar125
    Contributor

    Done. The code parts of this issue were already on main (the parser and the front matter rules in #4247, the in-app agent's create_node through the document path in #4275). The remaining measurement is merged as a live check in #4278 (d243081): on CPU gemma-4-E4B, 3 reps per scenario over four scenarios (a task with create_task offered, the same task with create_task withheld, a decision, and a spec with three sections), the model uses the document form in 12 of 12 reps and the store holds the right record (type, title without the heading marker, child count and child types). The create_node description's content parameter text does not mention the document form, yet the model used it in every create_node rep, so no wording change is needed. Not measured: a full-loop run with the skills injected; that is only worth doing if the document form is ever chosen wrongly.

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Metadata

Metadata

Assignees

Labels

Type

No type

Projects

No projects

    Milestone

    No milestone

    Relationships

    None yet

    Development

    No branches or pull requests

    Issue actions