docstar-cli 1.3.1 → 1.4.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/README.md +7 -7
- package/dist/commands/dump-test/parent-page/collection.js +33 -0
- package/package.json +3 -6
- package/oclif.manifest.json +0 -5732
package/README.md
CHANGED
|
@@ -1,12 +1,12 @@
|
|
|
1
1
|
# docstar-cli
|
|
2
2
|
|
|
3
|
-
A CLI for calling published DocStar API endpoints directly from your terminal, without leaving the shell to read docs. Point it at a DocStar docs site, pick which modules (e.g. "Slack") you want, and it turns each published endpoint into a real command you can run. You can install from multiple docs sites/collections at once — each is kept separate under its own **
|
|
3
|
+
A CLI for calling published DocStar API endpoints directly from your terminal, without leaving the shell to read docs. Point it at a DocStar docs site, pick which modules (e.g. "Slack") you want, and it turns each published endpoint into a real command you can run. You can install from multiple docs sites/collections at once — each is kept separate under its own **slug**.
|
|
4
4
|
|
|
5
5
|
## Concepts: collection → module → endpoint
|
|
6
6
|
|
|
7
7
|
Every command follows a fixed three-level hierarchy:
|
|
8
8
|
|
|
9
|
-
1. **Collection** — a docs site, identified by its **
|
|
9
|
+
1. **Collection** — a docs site, identified by its **slug** (e.g. `msg91`). This is what `docstar-cli init` installs.
|
|
10
10
|
2. **Module** — a top-level section within that collection (e.g. `slack`).
|
|
11
11
|
3. **Endpoint** — one published API within a module, turned into a command (e.g. `send-message-1`).
|
|
12
12
|
|
|
@@ -38,10 +38,10 @@ docstar-cli init localhost:3000 --collectionId paM4R4A26Hvb
|
|
|
38
38
|
|
|
39
39
|
This fetches the list of published modules for that collection and shows an interactive checklist (nothing checked by default — press `space` to toggle a module, or select the **"Select all modules"** entry at the bottom of the list to install everything, then `enter` to confirm). For each selected module it:
|
|
40
40
|
|
|
41
|
-
- saves its full endpoint contract to `~/.docstar/modules/<
|
|
42
|
-
- registers a real CLI command for every endpoint: `docstar-cli <
|
|
41
|
+
- saves its full endpoint contract to `~/.docstar/modules/<slug>/<module>.json`
|
|
42
|
+
- registers a real CLI command for every endpoint: `docstar-cli <slug> <module> <command>`
|
|
43
43
|
|
|
44
|
-
The **
|
|
44
|
+
The **slug** is chosen when the collection is created in DocStar (lowercase letters, numbers, `-` and `_` only) and never changes afterwards; the same slug identifies the collection for MCP. Running `init` against a different domain/collection adds it alongside any others already installed — nothing gets overwritten.
|
|
45
45
|
|
|
46
46
|
Everything is saved to `~/.docstar/config.json`, grouped by collection.
|
|
47
47
|
|
|
@@ -128,9 +128,9 @@ there's at least one installed module for `mcp` to expose.
|
|
|
128
128
|
|
|
129
129
|
## How it works
|
|
130
130
|
|
|
131
|
-
- `docstar-cli init` talks to `GET /p/module.json?collectionId=...` (the collection's name,
|
|
131
|
+
- `docstar-cli init` talks to `GET /p/module.json?collectionId=...` (the collection's name, slug, and list of modules) and `GET /p/<module>/module.json?collectionId=...` (a module's endpoint contract) on the docs site.
|
|
132
132
|
- Each endpoint's contract (method, url, base url, headers, body, and CLI parameter names) is saved locally and used to build the real HTTP request when you run its command — no network round-trip to the docs site is needed to run a command once a module is installed.
|
|
133
|
-
- Commands are generated as real files on disk under this repo's `dist/commands/<
|
|
133
|
+
- Commands are generated as real files on disk under this repo's `dist/commands/<slug>/<module>/`, which is why `npm run build` (it wipes `dist/`) requires re-running `docstar-cli init` for each installed collection afterwards to reinstall your modules.
|
|
134
134
|
|
|
135
135
|
## Development
|
|
136
136
|
|
|
@@ -0,0 +1,33 @@
|
|
|
1
|
+
import {Command, Flags} from '@oclif/core'
|
|
2
|
+
import {executeCliCommand} from '../../../lib/http.js'
|
|
3
|
+
import {promptForMissingParams} from '../../../lib/prompt.js'
|
|
4
|
+
|
|
5
|
+
const REQUIRED_PARAMS = ["username","password","this is a"]
|
|
6
|
+
|
|
7
|
+
export default class Generated extends Command {
|
|
8
|
+
static description = "this is the collection for api testing"
|
|
9
|
+
static aliases = []
|
|
10
|
+
static flags = {
|
|
11
|
+
"username": Flags.string({description: "Required parameter"}),
|
|
12
|
+
"password": Flags.string({description: "Required parameter"}),
|
|
13
|
+
"this is a": Flags.string({description: "Required parameter"}),
|
|
14
|
+
"content-type": Flags.string({description: 'Header value'}),
|
|
15
|
+
}
|
|
16
|
+
|
|
17
|
+
async run() {
|
|
18
|
+
const {flags} = await this.parse(Generated)
|
|
19
|
+
const params = {}
|
|
20
|
+
for (const [key, value] of Object.entries(flags)) {
|
|
21
|
+
if (value !== undefined) params[key] = value
|
|
22
|
+
}
|
|
23
|
+
|
|
24
|
+
Object.assign(params, await promptForMissingParams(REQUIRED_PARAMS, params))
|
|
25
|
+
|
|
26
|
+
try {
|
|
27
|
+
const result = await executeCliCommand("dump-test", "parent-page", "collection", params)
|
|
28
|
+
this.log(JSON.stringify(result, null, 2))
|
|
29
|
+
} catch (error) {
|
|
30
|
+
this.error(error.message)
|
|
31
|
+
}
|
|
32
|
+
}
|
|
33
|
+
}
|
package/package.json
CHANGED
|
@@ -1,7 +1,7 @@
|
|
|
1
1
|
{
|
|
2
2
|
"name": "docstar-cli",
|
|
3
3
|
"description": "Call published DocStar API endpoints directly from your terminal, or expose them as MCP tools for AI clients.",
|
|
4
|
-
"version": "1.
|
|
4
|
+
"version": "1.4.0",
|
|
5
5
|
"author": "Swayam Maheshwari",
|
|
6
6
|
"bin": {
|
|
7
7
|
"docstar-cli": "./bin/run.js"
|
|
@@ -27,7 +27,6 @@
|
|
|
27
27
|
"eslint-config-prettier": "^10",
|
|
28
28
|
"mocha": "^11",
|
|
29
29
|
"oclif": "^4",
|
|
30
|
-
"shx": "^0.3.3",
|
|
31
30
|
"ts-node": "^10",
|
|
32
31
|
"typescript": "^5"
|
|
33
32
|
},
|
|
@@ -36,8 +35,7 @@
|
|
|
36
35
|
},
|
|
37
36
|
"files": [
|
|
38
37
|
"./bin",
|
|
39
|
-
"./dist"
|
|
40
|
-
"./oclif.manifest.json"
|
|
38
|
+
"./dist"
|
|
41
39
|
],
|
|
42
40
|
"homepage": "https://github.com/swayammaheshwari/docstar-cli",
|
|
43
41
|
"keywords": [
|
|
@@ -59,9 +57,8 @@
|
|
|
59
57
|
"scripts": {
|
|
60
58
|
"build": "tsc -b",
|
|
61
59
|
"lint": "eslint",
|
|
62
|
-
"postpack": "shx rm -f oclif.manifest.json",
|
|
63
60
|
"posttest": "npm run lint",
|
|
64
|
-
"prepack": "oclif
|
|
61
|
+
"prepack": "oclif readme",
|
|
65
62
|
"test": "mocha --forbid-only \"test/**/*.test.ts\"",
|
|
66
63
|
"version": "oclif readme && git add README.md"
|
|
67
64
|
},
|