@mrmtsu/mcms-cli 0.1.0 → 0.2.1

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.
@@ -0,0 +1,197 @@
1
+ import { createRequire } from "node:module";
2
+ import { EXIT_CODE } from "./exit-codes.js";
3
+ const DEFAULT_VERSION = "0.1.0";
4
+ export function getCliSpec() {
5
+ return {
6
+ name: "microcms",
7
+ version: resolveVersion(),
8
+ jsonContractVersion: "0.x",
9
+ globalOptions: GLOBAL_OPTIONS,
10
+ exitCodes: {
11
+ SUCCESS: EXIT_CODE.SUCCESS,
12
+ UNKNOWN: EXIT_CODE.UNKNOWN,
13
+ INVALID_INPUT: EXIT_CODE.INVALID_INPUT,
14
+ AUTH: EXIT_CODE.AUTH,
15
+ PERMISSION: EXIT_CODE.PERMISSION,
16
+ NETWORK: EXIT_CODE.NETWORK,
17
+ CONFLICT: EXIT_CODE.CONFLICT
18
+ },
19
+ commands: COMMANDS
20
+ };
21
+ }
22
+ function resolveVersion() {
23
+ try {
24
+ const require = createRequire(import.meta.url);
25
+ const pkg = require("../../package.json");
26
+ if (typeof pkg.version === "string" && pkg.version.length > 0) {
27
+ return pkg.version;
28
+ }
29
+ }
30
+ catch {
31
+ // fallback for non-standard runtime layouts
32
+ }
33
+ return DEFAULT_VERSION;
34
+ }
35
+ const GLOBAL_OPTIONS = [
36
+ { name: "--json", description: "machine-readable JSON output" },
37
+ { name: "--plain", description: "human output mode (line-oriented)" },
38
+ { name: "--table", description: "human output mode (table)" },
39
+ { name: "--select <fields>", description: "comma-separated field names for --table output" },
40
+ { name: "--profile <name>", description: "profile name to resolve service domain / keychain key" },
41
+ { name: "--service-domain <serviceDomain>", description: "microCMS service domain" },
42
+ { name: "--api-key <apiKey>", description: "microCMS API key (less secure)" },
43
+ { name: "--api-key-stdin", description: "read microCMS API key from stdin" },
44
+ { name: "--timeout <ms>", description: "request timeout in milliseconds (default: 10000)" },
45
+ { name: "--retry <count>", description: "retry count for retryable failures (default: 2)" },
46
+ { name: "--retry-max-delay <ms>", description: "max retry delay in milliseconds (default: 3000)" },
47
+ { name: "--verbose", description: "verbose error output" },
48
+ { name: "--no-color", description: "disable colorized output" }
49
+ ];
50
+ const COMMANDS = [
51
+ {
52
+ path: "auth login",
53
+ description: "save API key in keychain (OAuth is not supported in MVP)",
54
+ args: [],
55
+ options: ["--profile <name>", "--service-domain <serviceDomain>", "--api-key <apiKey>", "--api-key-stdin", "--prompt"],
56
+ readOnly: false
57
+ },
58
+ {
59
+ path: "auth status",
60
+ description: "show auth resolution status",
61
+ args: [],
62
+ options: [],
63
+ readOnly: true
64
+ },
65
+ {
66
+ path: "auth profile list",
67
+ description: "list configured profiles",
68
+ args: [],
69
+ options: [],
70
+ readOnly: true
71
+ },
72
+ {
73
+ path: "auth profile add",
74
+ description: "add or update a profile",
75
+ args: ["<name>"],
76
+ options: ["--service-domain <serviceDomain>", "--set-default"],
77
+ readOnly: false
78
+ },
79
+ {
80
+ path: "auth profile use",
81
+ description: "set default profile",
82
+ args: ["<name>"],
83
+ options: [],
84
+ readOnly: false
85
+ },
86
+ {
87
+ path: "auth profile remove",
88
+ description: "remove profile from config",
89
+ args: ["<name>"],
90
+ options: [],
91
+ readOnly: false
92
+ },
93
+ { path: "api list", description: "list APIs", args: [], options: [], readOnly: true },
94
+ { path: "api info", description: "show API details", args: ["<endpoint>"], options: [], readOnly: true },
95
+ { path: "config doctor", description: "show resolved auth/config sources and common risks", args: [], options: [], readOnly: true },
96
+ {
97
+ path: "completion install",
98
+ description: "install completion script for your shell",
99
+ args: ["[shell]"],
100
+ options: [],
101
+ readOnly: false
102
+ },
103
+ { path: "completion uninstall", description: "remove installed completion scripts", args: [], options: [], readOnly: false },
104
+ { path: "completion endpoints", description: "print endpoint candidates for shell completion", args: [], options: [], readOnly: true },
105
+ {
106
+ path: "content list",
107
+ description: "list content",
108
+ args: ["<endpoint>"],
109
+ options: ["--limit <limit>", "--offset <offset>", "--orders <orders>", "--q <q>", "--filters <filters>", "--fields <fields>", "--ids <ids>", "--depth <depth>", "--draft-key <draftKey>", "--all"],
110
+ readOnly: true
111
+ },
112
+ {
113
+ path: "content get",
114
+ description: "get content by id",
115
+ args: ["<endpoint>", "<id>"],
116
+ options: ["--draft-key <draftKey>"],
117
+ readOnly: true
118
+ },
119
+ {
120
+ path: "content create",
121
+ description: "create content",
122
+ args: ["<endpoint>"],
123
+ options: ["--file <path>", "--dry-run"],
124
+ readOnly: false
125
+ },
126
+ {
127
+ path: "content update",
128
+ description: "update content",
129
+ args: ["<endpoint>", "<id>"],
130
+ options: ["--file <path>", "--dry-run"],
131
+ readOnly: false
132
+ },
133
+ {
134
+ path: "content delete",
135
+ description: "delete content",
136
+ args: ["<endpoint>", "<id>"],
137
+ options: ["--dry-run"],
138
+ readOnly: false
139
+ },
140
+ {
141
+ path: "media upload",
142
+ description: "upload media",
143
+ args: ["<path>"],
144
+ options: ["--dry-run"],
145
+ readOnly: false
146
+ },
147
+ {
148
+ path: "schema pull",
149
+ description: "fetch API schema metadata and save to file",
150
+ args: [],
151
+ options: ["--out <path>", "--endpoints <list>"],
152
+ readOnly: true
153
+ },
154
+ {
155
+ path: "types generate",
156
+ description: "generate declaration file from schema bundle",
157
+ args: [],
158
+ options: ["--schema <path>", "--out <path>"],
159
+ readOnly: true
160
+ },
161
+ {
162
+ path: "validate",
163
+ description: "run lightweight payload precheck before create/update",
164
+ args: ["<endpoint>"],
165
+ options: ["--file <path>", "--strict-warnings"],
166
+ readOnly: true
167
+ },
168
+ {
169
+ path: "docs list",
170
+ description: "list official documentation metadata",
171
+ args: [],
172
+ options: ["--source <source>", "--category <name>", "--limit <n>"],
173
+ readOnly: true
174
+ },
175
+ {
176
+ path: "docs get",
177
+ description: "get official documentation markdown",
178
+ args: [],
179
+ options: ["--category <name>", "--file <filename>", "--max-chars <n>", "--source <source>"],
180
+ readOnly: true
181
+ },
182
+ {
183
+ path: "search",
184
+ description: "search docs/spec for agent-friendly references",
185
+ args: ["<query>"],
186
+ options: ["--source <source>", "--scope <scope>", "--category <name>", "--limit <n>"],
187
+ readOnly: true
188
+ },
189
+ {
190
+ path: "spec",
191
+ description: "output machine-readable CLI spec",
192
+ args: [],
193
+ options: [],
194
+ readOnly: true
195
+ }
196
+ ];
197
+ //# sourceMappingURL=spec.js.map
@@ -0,0 +1 @@
1
+ {"version":3,"file":"spec.js","sourceRoot":"","sources":["../../src/core/spec.ts"],"names":[],"mappings":"AAAA,OAAO,EAAE,aAAa,EAAE,MAAM,aAAa,CAAC;AAC5C,OAAO,EAAE,SAAS,EAAE,MAAM,iBAAiB,CAAC;AA4B5C,MAAM,eAAe,GAAG,OAAO,CAAC;AAEhC,MAAM,UAAU,UAAU;IACxB,OAAO;QACL,IAAI,EAAE,UAAU;QAChB,OAAO,EAAE,cAAc,EAAE;QACzB,mBAAmB,EAAE,KAAK;QAC1B,aAAa,EAAE,cAAc;QAC7B,SAAS,EAAE;YACT,OAAO,EAAE,SAAS,CAAC,OAAO;YAC1B,OAAO,EAAE,SAAS,CAAC,OAAO;YAC1B,aAAa,EAAE,SAAS,CAAC,aAAa;YACtC,IAAI,EAAE,SAAS,CAAC,IAAI;YACpB,UAAU,EAAE,SAAS,CAAC,UAAU;YAChC,OAAO,EAAE,SAAS,CAAC,OAAO;YAC1B,QAAQ,EAAE,SAAS,CAAC,QAAQ;SAC7B;QACD,QAAQ,EAAE,QAAQ;KACnB,CAAC;AACJ,CAAC;AAED,SAAS,cAAc;IACrB,IAAI,CAAC;QACH,MAAM,OAAO,GAAG,aAAa,CAAC,MAAM,CAAC,IAAI,CAAC,GAAG,CAAC,CAAC;QAC/C,MAAM,GAAG,GAAG,OAAO,CAAC,oBAAoB,CAAgB,CAAC;QACzD,IAAI,OAAO,GAAG,CAAC,OAAO,KAAK,QAAQ,IAAI,GAAG,CAAC,OAAO,CAAC,MAAM,GAAG,CAAC,EAAE,CAAC;YAC9D,OAAO,GAAG,CAAC,OAAO,CAAC;QACrB,CAAC;IACH,C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EAAE,aAAa,CAAC;QACrF,QAAQ,EAAE,IAAI;KACf;IACD;QACE,IAAI,EAAE,MAAM;QACZ,WAAW,EAAE,kCAAkC;QAC/C,IAAI,EAAE,EAAE;QACR,OAAO,EAAE,EAAE;QACX,QAAQ,EAAE,IAAI;KACf;CACF,CAAC"}
package/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "@mrmtsu/mcms-cli",
3
- "version": "0.1.0",
3
+ "version": "0.2.1",
4
4
  "description": "AI/CI friendly CLI for microCMS",
5
5
  "license": "MIT",
6
6
  "type": "module",
@@ -24,6 +24,7 @@
24
24
  },
25
25
  "dependencies": {
26
26
  "commander": "^13.1.0",
27
+ "microcms-document-mcp-server": "0.2.5",
27
28
  "microcms-js-sdk": "^3.1.1",
28
29
  "zod": "^3.24.1"
29
30
  },