@synap-core/cli 1.6.0 → 1.7.0

This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
@@ -48,6 +48,58 @@ Synap is a typed knowledge graph. Six layers you need:
48
48
  | **Threads** | Channel conversations, optional entity context | Posting to the user's personal AI channel |
49
49
  | **Proposals** | Writes queued for human approval | Governance for some mutations (not an error — see below) |
50
50
 
51
+ ## Quick reference — 90% of tasks in 30 lines
52
+
53
+ ```bash
54
+ # CLI (preferred — auth automatic, --json = clean output)
55
+ synap orient --json # discover userId + workspaces
56
+ synap use <workspace-name-or-id> # set active workspace
57
+ synap create entity --profile=task --name="…" --props='{"status":"todo","priority":"high"}' --json
58
+ synap set entity <id> --props='{"status":"done"}' --json # merge-patch (only changed keys)
59
+ synap search "query" --json
60
+ synap remember "fact about the user" --json
61
+ synap recall "query" --json
62
+ ```
63
+
64
+ ```bash
65
+ # REST (when no Bash access)
66
+ POST /api/hub/entities body: { userId, workspaceId?, profileSlug, title, properties }
67
+ PATCH /api/hub/entities/{id} body: { userId, properties } ← deep-merges, send only changed keys
68
+ POST /api/hub/documents body: { userId, workspaceId?, title, content, entityId? }
69
+ PATCH /api/hub/documents/{id} body: { userId, title?, content? } ← full content replacement
70
+ POST /api/hub/relations body: { userId, sourceEntityId, targetEntityId, type }
71
+ GET /api/hub/entities?q=…&profileSlug=task&workspaceId=…
72
+ GET /api/hub/entities/{id}/connections?userId=…
73
+ POST /api/hub/memory body: { userId, fact }
74
+ GET /api/hub/memory?userId=…&query=…
75
+ ```
76
+
77
+ **Profile schemas are runtime-discovered — never hardcoded:**
78
+
79
+ ```bash
80
+ synap discover --json # CLI: full profile tree with property schemas + command map
81
+ synap discover --profiles --json # CLI: profiles only
82
+ ```
83
+
84
+ ```
85
+ GET /api/hub/discover?userId={userId}&workspaceId={workspaceId}
86
+ → { profiles: [{ slug, displayName, scope, properties: [{ slug, type, options? }], createCommand }], commands: {...} }
87
+ ```
88
+
89
+ Call this once at session start. The response includes every system profile and any custom workspace profiles the user has created, each with its full property schema. Use `createCommand` per profile as a copy-paste template. Do not rely on a static property list — it will drift.
90
+
91
+ **Load more detail on demand** (`GET /api/hub/skills/system?sections=<id>`):
92
+
93
+ | Section ID | When to load |
94
+ | ------------------------- | ------------------------------------------------------ |
95
+ | `synap:capture` | User pastes multi-entity text (email, transcript, bio) |
96
+ | `synap:governance` | Write was proposed or denied; need to explain policy |
97
+ | `synap:linking` | Custom relation types, auto-sync edge cases |
98
+ | `synap-ui:SKILL` | Building views, bento dashboards, workspaces |
99
+ | `synap-ui:view-types` | Specific view type config shapes |
100
+ | `synap-ui:widget-catalog` | Available widget kinds and their configSchema |
101
+ | `synap-schema:SKILL` | Creating custom profiles or property definitions |
102
+
51
103
  ## Synap-first operating mode
52
104
 
53
105
  > **MCP clients** (Claude Desktop, Raycast, OpenClaw with MCP): use `synap_*` tool names — they wrap auth and governance automatically. **REST / HTTP clients**: use the endpoints below.
@@ -67,12 +119,14 @@ GET /api/hub/users/me
67
119
  GET /api/hub/workspaces
68
120
  → [{ id, name, role }] ← workspaces[0].id if only one
69
121
 
70
- GET /api/hub/profiles?userId={userId}&workspaceId={workspaceId}
71
- → [{ slug, displayName, entityScope, properties }]
122
+ GET /api/hub/discover?userId={userId}&workspaceId={workspaceId}
123
+ { profiles: [{ slug, displayName, scope, properties, createCommand }], commands: {...} }
124
+ ← replaces /profiles — includes property schemas + custom workspace profiles
72
125
  ```
73
126
 
74
- `entityScope: "pod"` = visible across all workspaces (note, task, project, person, company, bookmark, event, contact, article, website).
75
- `entityScope: "workspace"` = scoped to one workspace (deal, file, capture, custom profiles).
127
+ `scope: "pod"` = visible across all workspaces (note, task, project, person, company, bookmark, event, contact, article, website).
128
+ `scope: "workspace"` = scoped to one workspace (deal, file, capture, custom profiles).
129
+ Each profile includes its full property schema. Use `createCommand` as a template.
76
130
 
77
131
  **2. Search before answering**
78
132
  Before answering any question about the user's projects, tasks, contacts, decisions, or anything they might have captured — search Synap first. Do not answer from your training or context window when Synap may have the authoritative answer.
@@ -390,10 +444,12 @@ POST /api/hub/entities
390
444
 
391
445
  ```json
392
446
  PATCH /api/hub/entities/{entityId}
393
- { "title": "…", "properties": { "status": "done" } }
447
+ { "userId": "{userId}", "title": "…", "properties": { "status": "done" } }
394
448
  ```
395
449
 
396
- ### Create a document (markdown, attached to an entity)
450
+ **Properties are deep-merged send only the keys you want to change.** An update with `{ "status": "done" }` leaves all other properties untouched. You never need to re-send the full properties object.
451
+
452
+ ### Create a document (attach to an entity)
397
453
 
398
454
  ```json
399
455
  POST /api/hub/documents
@@ -402,10 +458,52 @@ POST /api/hub/documents
402
458
  "workspaceId": "{workspaceId}",
403
459
  "title": "Meeting notes — 2026-04-20",
404
460
  "content": "# Attendees\n- …\n\n# Decisions\n- …",
405
- "entityId": "ent_event_..." // attach to an entity for context
461
+ "type": "markdown", // "markdown" | "html" | "text" | "code"
462
+ "entityId": "ent_event_..." // attach to an entity for context
406
463
  }
407
464
  ```
408
465
 
466
+ `type: "html"` stores self-contained HTML. The browser renders it via the `html-doc` cell in a sandboxed iframe. Use for AI-generated reports, rich visualisations, custom charts, or anything beyond markdown.
467
+
468
+ **Full HTML cell workflow** (AI → visible custom UI in any bento):
469
+
470
+ ```json
471
+ // 1. Create the HTML document
472
+ POST /api/hub/documents
473
+ { "userId": "{userId}", "workspaceId": "{workspaceId}",
474
+ "title": "Q2 Revenue Report", "type": "html",
475
+ "content": "<!DOCTYPE html><html>…</html>",
476
+ "entityId": "ent_project_..." }
477
+ // → { "document": { "id": "doc_abc" }, ... }
478
+
479
+ // 2. Place the html-doc cell in any bento view
480
+ POST /api/hub/views/{bentoViewId}/arrange
481
+ { "userId": "{userId}", "workspaceId": "{workspaceId}",
482
+ "widgets": [
483
+ { "id": "b1", "kind": "html-doc", "config": { "documentId": "doc_abc" },
484
+ "layout": { "x": 0, "y": 0, "w": 8, "h": 6 } }
485
+ ] }
486
+
487
+ // 3. Update the HTML (cell auto-refreshes)
488
+ PATCH /api/hub/documents/doc_abc
489
+ { "userId": "{userId}", "content": "<!DOCTYPE html>…updated…</html>" }
490
+ ```
491
+
492
+ The iframe uses `sandbox="allow-scripts"` — scripts run but have no same-origin access to the parent app. The HTML is fully isolated.
493
+
494
+ ### Update a document (title and/or content)
495
+
496
+ ```json
497
+ PATCH /api/hub/documents/{documentId}
498
+ {
499
+ "userId": "{userId}",
500
+ "title": "Updated title", // optional
501
+ "content": "# Full replacement\n…" // full string — not a diff
502
+ }
503
+ ```
504
+
505
+ Content is a **full replacement**, not a patch. Fetch the current content first if you want to append: `GET /api/hub/documents/{id}?userId={userId}` → `.content`, append, then PATCH.
506
+
409
507
  The reverse lookup is `entities WHERE documentId = ?`. Always attach the document to a meaningful entity (the meeting event, the project, the person) — a floating document is another orphan.
410
508
 
411
509
  ### Store a fact (memory) — use sparingly