integrationsdotsh 0.0.1-beta.0 → 0.0.1-beta.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.
Files changed (2) hide show
  1. package/dist/cli.js +70 -16
  2. package/package.json +1 -1
package/dist/cli.js CHANGED
@@ -1,7 +1,7 @@
1
1
  #!/usr/bin/env node
2
2
 
3
3
  // src/cli.ts
4
- var VERSION = "0.0.1-beta.0";
4
+ var VERSION = "0.0.1-beta.1";
5
5
  var BASE = (process.env.INTEGRATIONS_BASE ?? "https://integrations.sh").replace(/\/$/, "");
6
6
  var KIND_ORDER = ["mcp", "openapi", "graphql", "cli"];
7
7
  var TAG = { mcp: "mcp", openapi: "rest", graphql: "graphql", cli: "cli" };
@@ -113,33 +113,87 @@ ${dim(SECTION[kind])}
113
113
  process.stdout.write(`
114
114
  `);
115
115
  }
116
- function help() {
117
- process.stdout.write(`integrations — the registry of agent integrations (integrations.sh)
116
+ async function loadOps() {
117
+ try {
118
+ const res = await fetch(`${BASE}/openapi.json`, { headers: { accept: "application/json" } });
119
+ if (!res.ok)
120
+ return [];
121
+ const spec = await res.json();
122
+ const ops = [];
123
+ for (const [path, methods] of Object.entries(spec.paths ?? {})) {
124
+ for (const [method, op] of Object.entries(methods ?? {})) {
125
+ if (op?.operationId) {
126
+ ops.push({
127
+ id: op.operationId,
128
+ cmd: op.operationId.split(".").pop(),
129
+ method: method.toUpperCase(),
130
+ path,
131
+ params: [...path.matchAll(/\{(\w+)\}/g)].map((m) => m[1]),
132
+ desc: op.summary || op.description || ""
133
+ });
134
+ }
135
+ }
136
+ }
137
+ return ops;
138
+ } catch {
139
+ return [];
140
+ }
141
+ }
142
+ async function invokeOp(op, args) {
143
+ if (args.length < op.params.length) {
144
+ fail(`usage: integrations ${op.cmd} ${op.params.map((p) => `<${p}>`).join(" ")}`);
145
+ }
146
+ let path = op.path;
147
+ op.params.forEach((p, i) => {
148
+ path = path.replace(`{${p}}`, encodeURIComponent(args[i]));
149
+ });
150
+ const res = await fetch(`${BASE}${path}`, { method: op.method, headers: { accept: "application/json" } });
151
+ const text = await res.text();
152
+ if (!res.ok)
153
+ fail(`${op.cmd} → ${res.status}: ${clip(text, 200)}`);
154
+ try {
155
+ process.stdout.write(JSON.stringify(JSON.parse(text), null, 2) + `
156
+ `);
157
+ } catch {
158
+ process.stdout.write(text + `
159
+ `);
160
+ }
161
+ }
162
+ function help(ops) {
163
+ let s = `integrations — the registry of agent integrations (integrations.sh)
118
164
 
119
165
  usage:
120
- integrations search <query> search the catalog
121
- integrations <domain> show everything a domain exposes
122
- integrations help show this help
123
- integrations --version print version
124
-
125
- examples:
126
- integrations search slack
127
- integrations stripe.com
128
- integrations notion
166
+ `;
167
+ s += ` ${bold("integrations search <query>")} search the catalog
168
+ `;
169
+ s += ` ${bold("integrations <domain>")} show everything a domain exposes
170
+ `;
171
+ for (const o of ops) {
172
+ const sig = `integrations ${o.cmd} ${o.params.map((p) => `<${p}>`).join(" ")}`.trim();
173
+ s += ` ${bold(sig.padEnd(28))} ${dim(clip(o.desc, 46) || "API operation")}
174
+ `;
175
+ }
176
+ s += ` ${bold("integrations help")}
177
+ ${bold("integrations --version")}
129
178
 
130
179
  env:
131
- INTEGRATIONS_BASE registry host (default https://integrations.sh)
132
- `);
180
+ INTEGRATIONS_BASE registry host (default ${BASE})
181
+ `;
182
+ process.stdout.write(s);
133
183
  }
134
184
  async function main() {
135
185
  const [, , cmd, ...rest] = process.argv;
136
- if (!cmd || cmd === "help" || cmd === "--help" || cmd === "-h")
137
- return help();
138
186
  if (cmd === "--version" || cmd === "-v")
139
187
  return void process.stdout.write(`${VERSION}
140
188
  `);
189
+ const ops = await loadOps();
190
+ if (!cmd || cmd === "help" || cmd === "--help" || cmd === "-h")
191
+ return help(ops);
141
192
  if (cmd === "search")
142
193
  return cmdSearch(rest.join(" "));
194
+ const op = ops.find((o) => o.cmd === cmd);
195
+ if (op)
196
+ return invokeOp(op, rest);
143
197
  return cmdDomain(cmd);
144
198
  }
145
199
  main().catch((e) => fail(e?.message ?? String(e)));
package/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "integrationsdotsh",
3
- "version": "0.0.1-beta.0",
3
+ "version": "0.0.1-beta.1",
4
4
  "description": "CLI for integrations.sh — search the registry of agent integrations and read a domain's surface.",
5
5
  "type": "module",
6
6
  "bin": {