@gobi-ai/cli 1.3.7 → 2.0.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.
Files changed (37) hide show
  1. package/.claude-plugin/marketplace.json +6 -7
  2. package/.claude-plugin/plugin.json +4 -5
  3. package/README.md +78 -89
  4. package/commands/space-explore.md +10 -10
  5. package/commands/space-share.md +13 -7
  6. package/dist/commands/draft.js +213 -0
  7. package/dist/commands/global.js +205 -70
  8. package/dist/commands/init.js +5 -5
  9. package/dist/commands/{notes.js → saved.js} +112 -19
  10. package/dist/commands/space.js +92 -97
  11. package/dist/commands/sync.js +2 -56
  12. package/dist/commands/vault.js +113 -0
  13. package/dist/main.js +6 -10
  14. package/package.json +2 -2
  15. package/skills/gobi-core/SKILL.md +5 -7
  16. package/skills/gobi-core/references/space.md +18 -19
  17. package/skills/gobi-draft/SKILL.md +74 -0
  18. package/skills/gobi-draft/references/draft.md +109 -0
  19. package/skills/gobi-homepage/SKILL.md +16 -16
  20. package/skills/gobi-saved/SKILL.md +59 -0
  21. package/skills/gobi-saved/references/saved.md +52 -0
  22. package/skills/gobi-space/SKILL.md +34 -31
  23. package/skills/gobi-space/references/global.md +84 -24
  24. package/skills/gobi-space/references/space.md +45 -57
  25. package/skills/gobi-vault/SKILL.md +92 -0
  26. package/skills/{gobi-core/references/sync.md → gobi-vault/references/vault.md} +41 -2
  27. package/dist/commands/brain.js +0 -141
  28. package/dist/commands/feed.js +0 -148
  29. package/dist/commands/proposal.js +0 -185
  30. package/skills/gobi-brain/SKILL.md +0 -100
  31. package/skills/gobi-brain/references/brain.md +0 -66
  32. package/skills/gobi-feed/SKILL.md +0 -43
  33. package/skills/gobi-feed/references/feed.md +0 -80
  34. package/skills/gobi-notes/SKILL.md +0 -52
  35. package/skills/gobi-notes/references/notes.md +0 -82
  36. package/skills/gobi-proposal/SKILL.md +0 -66
  37. package/skills/gobi-proposal/references/proposal.md +0 -116
@@ -3,80 +3,140 @@
3
3
  ```
4
4
  Usage: gobi global [options] [command]
5
5
 
6
- Global thread space commands (no slug; visible across all spaces).
6
+ Global commands (posts and replies in the public feed across all vaults).
7
7
 
8
8
  Options:
9
9
  -h, --help display help for command
10
10
 
11
11
  Commands:
12
- messages [options] List the global unified message feed (threads and replies, newest first).
13
- get-thread [options] <threadId> Get a global thread and its direct replies (paginated).
14
- ancestors <threadId> Show the ancestor lineage of a global thread or reply (root immediate parent).
15
- create-thread [options] Create a thread in the global space.
16
- reply [options] <threadId> Reply to a thread in the global space.
12
+ feed [options] List the global public feed (posts and replies, newest first).
13
+ list-posts [options] List posts in the global feed (paginated). Pass --mine to limit to your own posts.
14
+ get-post [options] <postId> Get a global post with its ancestors and replies (paginated).
15
+ create-post [options] Create a post in the global feed (publishes from your vault).
16
+ edit-post [options] <postId> Edit a post you authored in the global feed.
17
+ delete-post <postId> Delete a post you authored in the global feed.
18
+ create-reply [options] <postId> Reply to a post in the global feed.
19
+ edit-reply [options] <replyId> Edit a reply you authored in the global feed.
20
+ delete-reply <replyId> Delete a reply you authored in the global feed.
17
21
  help [command] display help for command
18
22
  ```
19
23
 
20
- ## messages
24
+ ## feed
21
25
 
22
26
  ```
23
- Usage: gobi global messages [options]
27
+ Usage: gobi global feed [options]
24
28
 
25
- List the global unified message feed (threads and replies, newest first).
29
+ List the global public feed (posts and replies, newest first).
26
30
 
27
31
  Options:
28
32
  --limit <number> Items per page (default: "20")
29
33
  --cursor <string> Pagination cursor from previous response
34
+ --following Only include posts from authors you follow
30
35
  -h, --help display help for command
31
36
  ```
32
37
 
33
- ## get-thread
38
+ ## list-posts
34
39
 
35
40
  ```
36
- Usage: gobi global get-thread [options] <threadId>
41
+ Usage: gobi global list-posts [options]
37
42
 
38
- Get a global thread and its direct replies (paginated).
43
+ List posts in the global feed (paginated). Pass --mine to limit to your own posts.
44
+
45
+ Options:
46
+ --limit <number> Items per page (default: "20")
47
+ --cursor <string> Pagination cursor from previous response
48
+ --mine Only include posts authored by you
49
+ --vault-slug <vaultSlug> Filter by author vault slug
50
+ -h, --help display help for command
51
+ ```
52
+
53
+ ## get-post
54
+
55
+ ```
56
+ Usage: gobi global get-post [options] <postId>
57
+
58
+ Get a global post with its ancestors and replies (paginated).
39
59
 
40
60
  Options:
41
61
  --limit <number> Replies per page (default: "20")
42
62
  --cursor <string> Pagination cursor from previous response
63
+ --full Show full reply content without truncation
43
64
  -h, --help display help for command
44
65
  ```
45
66
 
46
- ## ancestors
67
+ ## create-post
47
68
 
48
69
  ```
49
- Usage: gobi global ancestors [options] <threadId>
70
+ Usage: gobi global create-post [options]
50
71
 
51
- Show the ancestor lineage of a global thread or reply (root immediate parent).
72
+ Create a post in the global feed (publishes from your vault).
52
73
 
53
74
  Options:
54
- -h, --help display help for command
75
+ --title <title> Title of the post
76
+ --content <content> Post content (markdown supported, use "-" for stdin)
77
+ --rich-text <richText> Rich-text JSON array (mutually exclusive with --content)
78
+ --vault-slug <vaultSlug> Author vault slug (overrides .gobi/settings.yaml)
79
+ --auto-attachments Upload wiki-linked [[files]] to webdrive before posting
80
+ -h, --help display help for command
55
81
  ```
56
82
 
57
- ## create-thread
83
+ ## edit-post
58
84
 
59
85
  ```
60
- Usage: gobi global create-thread [options]
86
+ Usage: gobi global edit-post [options] <postId>
61
87
 
62
- Create a thread in the global space.
88
+ Edit a post you authored in the global feed.
63
89
 
64
90
  Options:
65
- --title <title> Title of the thread
66
- --content <content> Thread content (markdown supported, use "-" for stdin)
91
+ --title <title> New title
92
+ --content <content> New content (markdown supported, use "-" for stdin)
67
93
  --rich-text <richText> Rich-text JSON array (mutually exclusive with --content)
68
94
  -h, --help display help for command
69
95
  ```
70
96
 
71
- ## reply
97
+ ## delete-post
98
+
99
+ ```
100
+ Usage: gobi global delete-post [options] <postId>
101
+
102
+ Delete a post you authored in the global feed.
103
+
104
+ Options:
105
+ -h, --help display help for command
106
+ ```
107
+
108
+ ## create-reply
72
109
 
73
110
  ```
74
- Usage: gobi global reply [options] <threadId>
111
+ Usage: gobi global create-reply [options] <postId>
75
112
 
76
- Reply to a thread in the global space.
113
+ Reply to a post in the global feed.
77
114
 
78
115
  Options:
79
116
  --content <content> Reply content (markdown supported, use "-" for stdin)
80
117
  --rich-text <richText> Rich-text JSON array (mutually exclusive with --content)
81
118
  -h, --help display help for command
82
119
  ```
120
+
121
+ ## edit-reply
122
+
123
+ ```
124
+ Usage: gobi global edit-reply [options] <replyId>
125
+
126
+ Edit a reply you authored in the global feed.
127
+
128
+ Options:
129
+ --content <content> New reply content (markdown supported, use "-" for stdin)
130
+ -h, --help display help for command
131
+ ```
132
+
133
+ ## delete-reply
134
+
135
+ ```
136
+ Usage: gobi global delete-reply [options] <replyId>
137
+
138
+ Delete a reply you authored in the global feed.
139
+
140
+ Options:
141
+ -h, --help display help for command
142
+ ```
@@ -3,29 +3,28 @@
3
3
  ```
4
4
  Usage: gobi space [options] [command]
5
5
 
6
- Space commands (threads, replies). Space and member admin is web-UI only.
6
+ Space commands (posts, replies). Space and member admin is web-UI only.
7
7
 
8
8
  Options:
9
- --space-slug <slug> Space slug (overrides .gobi/settings.yaml)
10
- -h, --help display help for command
9
+ --space-slug <slug> Space slug (overrides .gobi/settings.yaml)
10
+ -h, --help display help for command
11
11
 
12
12
  Commands:
13
- list List spaces you are a member of.
14
- get [spaceSlug] Get details for a space. Pass a slug or omit to use the current space (from .gobi/settings.yaml or --space-slug).
15
- warp [spaceSlug] Select the active space. Pass a slug to warp directly, or omit for interactive selection.
16
- list-topics [options] List topics in a space, ordered by most recent content linkage.
17
- list-topic-threads [options] <topicSlug> List threads tagged with a topic in a space (cursor-paginated).
18
- messages [options] List the unified message feed (threads and replies, newest first) in a space.
19
- ancestors <threadId> Show the ancestor lineage of a thread or reply (root → immediate parent).
20
- get-thread [options] <threadId> Get a thread and its replies (paginated).
21
- list-threads [options] List threads in a space (paginated).
22
- create-thread [options] Create a thread in a space.
23
- edit-thread [options] <threadId> Edit a thread. You must be the author.
24
- delete-thread <threadId> Delete a thread. You must be the author.
25
- create-reply [options] <threadId> Create a reply to a thread in a space.
26
- edit-reply [options] <replyId> Edit a reply. You must be the author.
27
- delete-reply <replyId> Delete a reply. You must be the author.
28
- help [command] display help for command
13
+ list List spaces you are a member of.
14
+ get [spaceSlug] Get details for a space. Pass a slug or omit to use the current space (from .gobi/settings.yaml or --space-slug).
15
+ warp [spaceSlug] Select the active space. Pass a slug to warp directly, or omit for interactive selection.
16
+ list-topics [options] List topics in a space, ordered by most recent content linkage.
17
+ list-topic-posts [options] <topicSlug> List posts tagged with a topic in a space (cursor-paginated).
18
+ feed [options] List the unified feed (posts and replies, newest first) in a space.
19
+ get-post [options] <postId> Get a post with its ancestors and replies (paginated).
20
+ list-posts [options] List posts in a space (paginated).
21
+ create-post [options] Create a post in a space.
22
+ edit-post [options] <postId> Edit a post. You must be the author.
23
+ delete-post <postId> Delete a post. You must be the author.
24
+ create-reply [options] <postId> Create a reply to a post in a space.
25
+ edit-reply [options] <replyId> Edit a reply. You must be the author.
26
+ delete-reply <replyId> Delete a reply. You must be the author.
27
+ help [command] display help for command
29
28
  ```
30
29
 
31
30
  ## get
@@ -51,12 +50,12 @@ Options:
51
50
  -h, --help display help for command
52
51
  ```
53
52
 
54
- ## list-topic-threads
53
+ ## list-topic-posts
55
54
 
56
55
  ```
57
- Usage: gobi space list-topic-threads [options] <topicSlug>
56
+ Usage: gobi space list-topic-posts [options] <topicSlug>
58
57
 
59
- List threads tagged with a topic in a space (cursor-paginated).
58
+ List posts tagged with a topic in a space (cursor-paginated).
60
59
 
61
60
  Options:
62
61
  --limit <number> Items per page (default: "20")
@@ -64,12 +63,12 @@ Options:
64
63
  -h, --help display help for command
65
64
  ```
66
65
 
67
- ## messages
66
+ ## feed
68
67
 
69
68
  ```
70
- Usage: gobi space messages [options]
69
+ Usage: gobi space feed [options]
71
70
 
72
- List the unified message feed (threads and replies, newest first) in a space.
71
+ List the unified feed (posts and replies, newest first) in a space.
73
72
 
74
73
  Options:
75
74
  --limit <number> Items per page (default: "20")
@@ -77,23 +76,12 @@ Options:
77
76
  -h, --help display help for command
78
77
  ```
79
78
 
80
- ## ancestors
79
+ ## get-post
81
80
 
82
81
  ```
83
- Usage: gobi space ancestors [options] <threadId>
82
+ Usage: gobi space get-post [options] <postId>
84
83
 
85
- Show the ancestor lineage of a thread or reply (root → immediate parent).
86
-
87
- Options:
88
- -h, --help display help for command
89
- ```
90
-
91
- ## get-thread
92
-
93
- ```
94
- Usage: gobi space get-thread [options] <threadId>
95
-
96
- Get a thread and its replies (paginated).
84
+ Get a post with its ancestors and replies (paginated).
97
85
 
98
86
  Options:
99
87
  --limit <number> Replies per page (default: "20")
@@ -101,12 +89,12 @@ Options:
101
89
  -h, --help display help for command
102
90
  ```
103
91
 
104
- ## list-threads
92
+ ## list-posts
105
93
 
106
94
  ```
107
- Usage: gobi space list-threads [options]
95
+ Usage: gobi space list-posts [options]
108
96
 
109
- List threads in a space (paginated).
97
+ List posts in a space (paginated).
110
98
 
111
99
  Options:
112
100
  --limit <number> Items per page (default: "20")
@@ -114,42 +102,42 @@ Options:
114
102
  -h, --help display help for command
115
103
  ```
116
104
 
117
- ## create-thread
105
+ ## create-post
118
106
 
119
107
  ```
120
- Usage: gobi space create-thread [options]
108
+ Usage: gobi space create-post [options]
121
109
 
122
- Create a thread in a space.
110
+ Create a post in a space.
123
111
 
124
112
  Options:
125
- --title <title> Title of the thread
126
- --content <content> Thread content (markdown supported)
113
+ --title <title> Title of the post
114
+ --content <content> Post content (markdown supported)
127
115
  --auto-attachments Upload wiki-linked [[files]] to webdrive before posting
128
116
  --vault-slug <vaultSlug> Vault slug for attachment uploads (overrides .gobi/settings.yaml)
129
117
  -h, --help display help for command
130
118
  ```
131
119
 
132
- ## edit-thread
120
+ ## edit-post
133
121
 
134
122
  ```
135
- Usage: gobi space edit-thread [options] <threadId>
123
+ Usage: gobi space edit-post [options] <postId>
136
124
 
137
- Edit a thread. You must be the author.
125
+ Edit a post. You must be the author.
138
126
 
139
127
  Options:
140
- --title <title> New title for the thread
141
- --content <content> New content for the thread (markdown supported)
128
+ --title <title> New title for the post
129
+ --content <content> New content for the post (markdown supported)
142
130
  --auto-attachments Upload wiki-linked [[files]] to webdrive before editing
143
131
  --vault-slug <vaultSlug> Vault slug for attachment uploads (overrides .gobi/settings.yaml)
144
132
  -h, --help display help for command
145
133
  ```
146
134
 
147
- ## delete-thread
135
+ ## delete-post
148
136
 
149
137
  ```
150
- Usage: gobi space delete-thread [options] <threadId>
138
+ Usage: gobi space delete-post [options] <postId>
151
139
 
152
- Delete a thread. You must be the author.
140
+ Delete a post. You must be the author.
153
141
 
154
142
  Options:
155
143
  -h, --help display help for command
@@ -158,9 +146,9 @@ Options:
158
146
  ## create-reply
159
147
 
160
148
  ```
161
- Usage: gobi space create-reply [options] <threadId>
149
+ Usage: gobi space create-reply [options] <postId>
162
150
 
163
- Create a reply to a thread in a space.
151
+ Create a reply to a post in a space.
164
152
 
165
153
  Options:
166
154
  --content <content> Reply content (markdown supported)
@@ -0,0 +1,92 @@
1
+ ---
2
+ name: gobi-vault
3
+ description: >-
4
+ Gobi vault commands for publishing your vault profile and syncing files:
5
+ publish/unpublish PUBLISH.md and run the local-to-webdrive sync. Use when
6
+ the user wants to publish their vault, unpublish it, or push/pull files.
7
+ allowed-tools: Bash(gobi:*)
8
+ metadata:
9
+ author: gobi-ai
10
+ version: "0.9.13"
11
+ ---
12
+
13
+ # gobi-vault
14
+
15
+ Gobi vault commands for publishing your vault profile and syncing files (v0.9.13).
16
+
17
+ Requires gobi-cli installed and authenticated. See gobi-core skill for setup.
18
+
19
+ ## Gobi Vault
20
+
21
+ A "vault" is your file-backed knowledge home. Public vaults are accessible at `https://gobispace.com/@{vaultSlug}`. Each vault has a profile written to `PUBLISH.md` at its root; publishing pushes that file to webdrive, which then updates vault metadata and the public profile.
22
+
23
+ ## Important: JSON Mode
24
+
25
+ For programmatic/agent usage, always pass `--json` as a **global** option (before the subcommand):
26
+
27
+ ```bash
28
+ gobi --json vault publish
29
+ ```
30
+
31
+ ## Available Commands
32
+
33
+ - `gobi vault publish` — Upload `PUBLISH.md` to the vault root on webdrive. Triggers post-processing (vault profile sync, metadata update, Discord notification).
34
+ - `gobi vault unpublish` — Delete `PUBLISH.md` from the vault on webdrive.
35
+ - `gobi vault sync` — Sync local vault files with Gobi Webdrive. Supports `--upload-only`, `--download-only`, `--conflict <ask|server|client|skip>`, `--dry-run`, `--full`, `--path <p>`, `--plan-file`, `--execute`.
36
+
37
+ ## PUBLISH.md Frontmatter Reference
38
+
39
+ `PUBLISH.md` is the metadata file at the root of every vault. Its YAML frontmatter controls the vault's public profile, homepage, and AI agent behavior. Example:
40
+
41
+ ```yaml
42
+ ---
43
+ title: My Vault
44
+ tags:
45
+ - topic1
46
+ - topic2
47
+ description: A short description of what this vault is about.
48
+ thumbnail: "[[PROFILE.png]]"
49
+ homepage: "[[app/home.html?nav=false]]"
50
+ prompt: "[[system-prompt.md]]"
51
+ ---
52
+ ```
53
+
54
+ ### Fields
55
+
56
+ - **`title`** (required) — Display name of the vault.
57
+ - **`description`** (required for public listing) — Short description shown on the vault card and public profile. Without both `title` and `description`, the vault won't appear in the public catalog.
58
+ - **`tags`** — Tags for categorization and discovery. Supports YAML block list or inline array format:
59
+ ```yaml
60
+ # Block list
61
+ tags:
62
+ - ambient ai
63
+ - wearables
64
+
65
+ # Inline array
66
+ tags: [ambient ai, wearables]
67
+ ```
68
+ - **`thumbnail`** — Profile image for the vault card. Uses wiki-link syntax pointing to an image file in the vault (e.g. `"[[PROFILE.png]]"`).
69
+ - **`homepage`** — Custom HTML page to serve as the vault's public homepage at `gobispace.com/@{vaultSlug}`. Uses wiki-link syntax pointing to an HTML file in the vault. Supports a `nav` query parameter to control Gobi's sidebar navigation:
70
+ - `"[[app/home.html]]"` — Shows the Gobi sidebar alongside the homepage (default)
71
+ - `"[[app/home.html?nav=false]]"` — Full-screen, no Gobi sidebar/chrome
72
+ - **`prompt`** — Wiki-link to a custom system prompt file for the vault's AI agent (e.g. `"[[system-prompt.md]]"`).
73
+
74
+ > For details on building custom HTML homepages and using the `window.gobi` API, see the **gobi-homepage** skill.
75
+
76
+ ## Publishing Workflow
77
+
78
+ After editing `PUBLISH.md` frontmatter, follow these steps to make your changes live:
79
+
80
+ 1. **Edit `PUBLISH.md`** in the vault root with the desired frontmatter fields.
81
+ 2. **Sync referenced files** — if the homepage HTML, thumbnail image, or prompt file is new or updated, upload them first:
82
+ ```bash
83
+ gobi vault sync
84
+ ```
85
+ 3. **Publish the vault**:
86
+ ```bash
87
+ gobi vault publish
88
+ ```
89
+ This uploads `PUBLISH.md` to webdrive, triggers post-processing that extracts metadata (title, description, tags, thumbnail, homepage path), updates the vault's public profile, and sends a Discord notification.
90
+ 4. The vault is now live at `https://gobispace.com/@{vaultSlug}`.
91
+
92
+ > **Important:** Any time you change `PUBLISH.md` frontmatter (e.g. adding or updating `homepage`), you must re-run `gobi vault publish` for the changes to take effect.
@@ -1,7 +1,46 @@
1
- # gobi sync
1
+ # gobi vault
2
2
 
3
3
  ```
4
- Usage: gobi sync [options]
4
+ Usage: gobi vault [options] [command]
5
+
6
+ Vault commands (publish/unpublish profile, sync files).
7
+
8
+ Options:
9
+ -h, --help display help for command
10
+
11
+ Commands:
12
+ publish Upload PUBLISH.md to the vault root on webdrive. Triggers post-processing (vault sync, metadata update, Discord notification).
13
+ unpublish Delete PUBLISH.md from the vault on webdrive.
14
+ sync [options] Sync local vault files with Gobi Webdrive.
15
+ help [command] display help for command
16
+ ```
17
+
18
+ ## publish
19
+
20
+ ```
21
+ Usage: gobi vault publish [options]
22
+
23
+ Upload PUBLISH.md to the vault root on webdrive. Triggers post-processing (vault sync, metadata update, Discord notification).
24
+
25
+ Options:
26
+ -h, --help display help for command
27
+ ```
28
+
29
+ ## unpublish
30
+
31
+ ```
32
+ Usage: gobi vault unpublish [options]
33
+
34
+ Delete PUBLISH.md from the vault on webdrive.
35
+
36
+ Options:
37
+ -h, --help display help for command
38
+ ```
39
+
40
+ ## sync
41
+
42
+ ```
43
+ Usage: gobi vault sync [options]
5
44
 
6
45
  Sync local vault files with Gobi Webdrive.
7
46
 
@@ -1,141 +0,0 @@
1
- import { existsSync, readFileSync } from "fs";
2
- import { join } from "path";
3
- import { apiGet, apiPost } from "../client.js";
4
- import { WEBDRIVE_BASE_URL } from "../constants.js";
5
- import { getValidToken } from "../auth/manager.js";
6
- import { getVaultSlug } from "./init.js";
7
- import { isJsonMode, jsonOut, unwrapResp } from "./utils.js";
8
- export function registerBrainCommand(program) {
9
- const brain = program
10
- .command("brain")
11
- .description("Brain commands (search, ask, publish, unpublish).");
12
- // ── Search ──
13
- brain
14
- .command("search")
15
- .description("Search public brains by text and semantic similarity.")
16
- .requiredOption("--query <query>", "Search query")
17
- .action(async (opts) => {
18
- const resp = (await apiGet(`/vault/public/search`, {
19
- query: opts.query,
20
- }));
21
- const results = (Array.isArray(resp) ? resp : resp.data || resp);
22
- if (isJsonMode(brain)) {
23
- jsonOut(results || []);
24
- return;
25
- }
26
- if (!results || results.length === 0) {
27
- console.log(`No brains found matching "${opts.query}".`);
28
- return;
29
- }
30
- const lines = [];
31
- for (const entry of results) {
32
- const vault = (entry.vault || entry);
33
- const owner = (entry.owner || {});
34
- const ownerName = owner.name ? ` by ${owner.name}` : "";
35
- const sim = entry.similarity != null
36
- ? ` [similarity: ${entry.similarity.toFixed(3)}]`
37
- : "";
38
- const spaceSlug = (entry.spaceSlug || vault.spaceSlug || "");
39
- const vaultSlug = (vault.slug || vault.vaultSlug || vault.id || "N/A");
40
- lines.push(`- ${vault.name || vault.title || "N/A"} (vault: ${vaultSlug}, space: ${spaceSlug || "N/A"})${ownerName}${sim}`);
41
- }
42
- console.log(`Brains matching "${opts.query}":\n` + lines.join("\n"));
43
- });
44
- // ── Ask ──
45
- brain
46
- .command("ask")
47
- .description("Ask a brain a question. Creates a targeted session (1:1 conversation).")
48
- .requiredOption("--vault-slug <vaultSlug>", "Slug of the brain/vault to ask")
49
- .option("--question <question>", "The question to ask (markdown supported)")
50
- .option("--rich-text <richText>", "Rich-text JSON array (e.g. [{\"type\":\"text\",\"text\":\"hello\"}])")
51
- .option("--mode <mode>", 'Session mode: "auto" or "manual"')
52
- .action(async (opts) => {
53
- if (!opts.question && !opts.richText) {
54
- throw new Error("Provide either --question or --rich-text.");
55
- }
56
- if (opts.question && opts.richText) {
57
- throw new Error("--question and --rich-text are mutually exclusive.");
58
- }
59
- const body = {
60
- vaultSlug: opts.vaultSlug,
61
- };
62
- if (opts.question != null)
63
- body.question = opts.question;
64
- if (opts.richText != null) {
65
- let parsed;
66
- try {
67
- parsed = JSON.parse(opts.richText);
68
- }
69
- catch {
70
- throw new Error("Invalid --rich-text JSON.");
71
- }
72
- body.richText = parsed;
73
- }
74
- if (opts.mode != null)
75
- body.mode = opts.mode;
76
- const resp = (await apiPost(`/chat/targeted`, body));
77
- const data = unwrapResp(resp);
78
- if (isJsonMode(brain)) {
79
- jsonOut(data);
80
- return;
81
- }
82
- const session = (data.session || {});
83
- const members = (data.members || []);
84
- console.log(`Session created!\n` +
85
- ` Session ID: ${session.id}\n` +
86
- ` Mode: ${session.mode}\n` +
87
- ` Members: ${members.length}\n` +
88
- ` Question sent.`);
89
- });
90
- // ── Publish ──
91
- brain
92
- .command("publish")
93
- .description("Upload BRAIN.md to the vault root on webdrive. Triggers post-processing (brain sync, metadata update, Discord notification).")
94
- .action(async () => {
95
- const vaultId = getVaultSlug();
96
- const filePath = join(process.cwd(), "BRAIN.md");
97
- if (!existsSync(filePath)) {
98
- throw new Error(`BRAIN.md not found in ${process.cwd()}`);
99
- }
100
- const content = readFileSync(filePath, "utf-8");
101
- const token = await getValidToken();
102
- const url = `${WEBDRIVE_BASE_URL}/api/v1/vaults/${vaultId}/file/BRAIN.md`;
103
- const res = await fetch(url, {
104
- method: "PUT",
105
- headers: {
106
- Authorization: `Bearer ${token}`,
107
- "Content-Type": "text/markdown",
108
- },
109
- body: content,
110
- });
111
- if (!res.ok) {
112
- throw new Error(`Upload failed: HTTP ${res.status}: ${(await res.text()) || "(no body)"}`);
113
- }
114
- if (isJsonMode(brain)) {
115
- jsonOut({ vaultId });
116
- return;
117
- }
118
- console.log(`Published BRAIN.md to vault "${vaultId}"`);
119
- });
120
- // ── Unpublish ──
121
- brain
122
- .command("unpublish")
123
- .description("Delete BRAIN.md from the vault on webdrive.")
124
- .action(async () => {
125
- const vaultId = getVaultSlug();
126
- const token = await getValidToken();
127
- const url = `${WEBDRIVE_BASE_URL}/api/v1/vaults/${vaultId}/file/BRAIN.md`;
128
- const res = await fetch(url, {
129
- method: "DELETE",
130
- headers: { Authorization: `Bearer ${token}` },
131
- });
132
- if (!res.ok) {
133
- throw new Error(`Delete failed: HTTP ${res.status}: ${(await res.text()) || "(no body)"}`);
134
- }
135
- if (isJsonMode(brain)) {
136
- jsonOut({ vaultId });
137
- return;
138
- }
139
- console.log(`Deleted BRAIN.md from vault "${vaultId}"`);
140
- });
141
- }