Add structured sections and hierarchical navigation

Add --section flag to add/update commands for structured node content,
render sections and inline children in show, and add memory children command.
This commit is contained in:
2026-02-02 22:29:23 +01:00
parent f1b59a2d1a
commit 5f7692f5f6
6 changed files with 125 additions and 1 deletions

View File

@@ -23,9 +23,11 @@ Add a node to the knowledge graph.
| `-c, --content <content>` | no | Node content/description |
| `--tags <tags>` | no | Comma-separated tags |
| `--status <status>` | no | Status (e.g. `todo`, `doing`, `done`, `active`, `deprecated`) |
| `--section <section>` | no | Structured section as `"Label: body"` (repeatable) |
```bash
memory add memory -t "Auth flow design" -c "OAuth2 PKCE flow for SPA" --tags auth,security --status active
memory add memory -t "add command" --section "Arguments: <kind> — memory, component, task, decision" --section "Options: -t title, -c content, --tags, --status"
memory add task -t "Implement login page" --status todo
memory add decision -t "Use PostgreSQL" -c "Chose Postgres over MySQL for JSON support"
memory add component -t "UserService" -c "Handles user CRUD operations" --tags backend
@@ -97,6 +99,7 @@ Update an existing node's fields.
| `--status <status>` | no | New status |
| `--tags <tags>` | no | Replace tags (comma-separated) |
| `--stale` | no | Mark as stale |
| `--section <section>` | no | Structured section as `"Label: body"` (repeatable, replaces by label) |
```bash
memory update abc123 --status done
@@ -146,6 +149,22 @@ memory graph
memory graph abc123
```
### `memory children <id>`
List child nodes connected via outgoing `contains` edges from the given node.
| Argument / Option | Required | Description |
|---|---|---|
| `<id>` | yes | Parent node ID or prefix |
| `--kind <kind>` | no | Filter children by kind |
| `--format <fmt>` | no | Output format: `text` or `json` (default: `text`) |
```bash
memory children abc123
memory children abc123 --kind task
memory children abc123 --format json
```
### `memory decay`
Run auto-decay to mark old untouched nodes as stale. Nodes whose `lastAccessedAt` exceeds the threshold are marked stale and hidden from default listings and search.
@@ -197,6 +216,22 @@ memory serve --port 8080
| `supersedes` | Source supersedes/replaces target |
| `about` | Source is about target |
## Structured Sections
Nodes can have structured content via `metadata.sections`. Each section has a `label` and `body`. Use the `--section "Label: body"` flag on `add` or `update` to create sections.
When displayed with `memory show`, sections render as:
```
── Arguments ──
<kind> — memory, component, task, decision
── Options ──
-t title, -c content, --tags, --status
```
The `show` command also displays inline children (nodes linked via `contains` edges). Use `memory children <id>` to list only children.
## Search Scoring
Search combines three signals: