@gobi-ai/cli 0.4.1 → 0.5.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.
- package/dist/commands/space.js +10 -4
- package/package.json +2 -2
package/dist/commands/space.js
CHANGED
|
@@ -1,6 +1,12 @@
|
|
|
1
|
+
import { readFileSync } from "fs";
|
|
1
2
|
import { apiGet, apiPost, apiPatch, apiDelete } from "../client.js";
|
|
2
3
|
import { selectSpace, writeSpaceSetting } from "./init.js";
|
|
3
4
|
import { isJsonMode, jsonOut, resolveSpaceSlug, unwrapResp } from "./utils.js";
|
|
5
|
+
function readContent(value) {
|
|
6
|
+
if (value === "-")
|
|
7
|
+
return readFileSync("/dev/stdin", "utf8");
|
|
8
|
+
return value;
|
|
9
|
+
}
|
|
4
10
|
export function registerSpaceCommand(program) {
|
|
5
11
|
const space = program
|
|
6
12
|
.command("space")
|
|
@@ -142,7 +148,7 @@ export function registerSpaceCommand(program) {
|
|
|
142
148
|
const spaceSlug = resolveSpaceSlug(space);
|
|
143
149
|
const resp = (await apiPost(`/spaces/${spaceSlug}/threads`, {
|
|
144
150
|
title: opts.title,
|
|
145
|
-
content: opts.content,
|
|
151
|
+
content: readContent(opts.content),
|
|
146
152
|
}));
|
|
147
153
|
const thread = unwrapResp(resp);
|
|
148
154
|
if (isJsonMode(space)) {
|
|
@@ -168,7 +174,7 @@ export function registerSpaceCommand(program) {
|
|
|
168
174
|
if (opts.title != null)
|
|
169
175
|
body.title = opts.title;
|
|
170
176
|
if (opts.content != null)
|
|
171
|
-
body.content = opts.content;
|
|
177
|
+
body.content = readContent(opts.content);
|
|
172
178
|
const resp = (await apiPatch(`/spaces/${spaceSlug}/threads/${threadId}`, body));
|
|
173
179
|
const thread = unwrapResp(resp);
|
|
174
180
|
if (isJsonMode(space)) {
|
|
@@ -199,7 +205,7 @@ export function registerSpaceCommand(program) {
|
|
|
199
205
|
.requiredOption("--content <content>", "Reply content (markdown supported)")
|
|
200
206
|
.action(async (threadId, opts) => {
|
|
201
207
|
const spaceSlug = resolveSpaceSlug(space);
|
|
202
|
-
const resp = (await apiPost(`/spaces/${spaceSlug}/threads/${threadId}/replies`, { content: opts.content }));
|
|
208
|
+
const resp = (await apiPost(`/spaces/${spaceSlug}/threads/${threadId}/replies`, { content: readContent(opts.content) }));
|
|
203
209
|
const msg = unwrapResp(resp);
|
|
204
210
|
if (isJsonMode(space)) {
|
|
205
211
|
jsonOut(msg);
|
|
@@ -213,7 +219,7 @@ export function registerSpaceCommand(program) {
|
|
|
213
219
|
.requiredOption("--content <content>", "New content for the reply (markdown supported)")
|
|
214
220
|
.action(async (replyId, opts) => {
|
|
215
221
|
const spaceSlug = resolveSpaceSlug(space);
|
|
216
|
-
const resp = (await apiPatch(`/spaces/${spaceSlug}/replies/${replyId}`, { content: opts.content }));
|
|
222
|
+
const resp = (await apiPatch(`/spaces/${spaceSlug}/replies/${replyId}`, { content: readContent(opts.content) }));
|
|
217
223
|
const msg = unwrapResp(resp);
|
|
218
224
|
if (isJsonMode(space)) {
|
|
219
225
|
jsonOut(msg);
|
package/package.json
CHANGED
|
@@ -1,6 +1,6 @@
|
|
|
1
1
|
{
|
|
2
2
|
"name": "@gobi-ai/cli",
|
|
3
|
-
"version": "0.
|
|
3
|
+
"version": "0.5.0",
|
|
4
4
|
"description": "CLI client for the Gobi collaborative knowledge platform",
|
|
5
5
|
"license": "MIT",
|
|
6
6
|
"type": "module",
|
|
@@ -37,7 +37,7 @@
|
|
|
37
37
|
"dev": "tsx src/index.ts",
|
|
38
38
|
"start": "node dist/index.js",
|
|
39
39
|
"test": "node --test dist/*.test.js",
|
|
40
|
-
"generate-skill-docs": "npm run build && npx tsx skills/gobi
|
|
40
|
+
"generate-skill-docs": "npm run build && npx tsx skills/gobi/scripts/generate-docs.ts",
|
|
41
41
|
"prepare": "npm run build",
|
|
42
42
|
"prepublishOnly": "npm run build"
|
|
43
43
|
},
|