insightfulpipe 0.2.0 → 0.3.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/CHANGELOG.md +45 -0
- package/README.md +40 -1
- package/package.json +2 -2
- package/src/api.js +86 -72
- package/src/cli/commands/discovery.js +2 -2
- package/src/cli/commands/execution.js +3 -3
- package/src/cli/commands/skills.js +454 -0
- package/src/cli/errors.js +159 -15
- package/src/cli/input.js +6 -0
- package/src/cli/program.js +7 -7
- package/src/cli/query-contexts.js +3 -2
- package/src/http.js +39 -0
- package/src/skills/agents.js +94 -0
- package/src/skills/catalog.js +177 -0
- package/src/skills/installer.js +331 -0
package/CHANGELOG.md
CHANGED
|
@@ -1,5 +1,50 @@
|
|
|
1
1
|
# Changelog
|
|
2
2
|
|
|
3
|
+
## 0.3.0
|
|
4
|
+
|
|
5
|
+
**`insightfulpipe skills`: install InsightfulPipe skills from the terminal.** Modelled on
|
|
6
|
+
`openclaw skills install`, for our catalogue on insightfulpipe.com.
|
|
7
|
+
|
|
8
|
+
- `skills search [words] [--category]`, `skills info <skill>`, and `skills install <skill...>` (or
|
|
9
|
+
`--category <c>`). Install writes into Claude Code's global folder by default; `--agent openclaw |
|
|
10
|
+
codex | cursor | gemini-cli`, `--project` and `--dir` pick another.
|
|
11
|
+
- Before writing, every file is checked against its sha256 and the skill's content version, paths
|
|
12
|
+
that would escape the folder are refused, and SKILL.md must be named after the skill. Files land in
|
|
13
|
+
a staging folder and are renamed into place, so a failure leaves nothing half-written.
|
|
14
|
+
- Each install keeps a `.insightfulpipe-skill.json` marker. `skills list` shows installed skills and
|
|
15
|
+
available updates. `skills update <skill> | --all` keeps local edits unless `--force`. `skills
|
|
16
|
+
remove` only deletes folders this CLI installed and asks first (`--yes` when non-interactive).
|
|
17
|
+
- `skills download <skill>` saves the ZIP for uploading in Claude.ai or Claude Desktop.
|
|
18
|
+
- No login needed. The catalogue never receives the API token. `INSIGHTFULPIPE_SKILLS_URL` accepts only
|
|
19
|
+
insightfulpipe.com, its subdomains or localhost, so installs can't be pointed at a look-alike catalogue.
|
|
20
|
+
- Added CI: unit tests on Node 18, 20 and 22, plus a live install of a real skill into a throwaway
|
|
21
|
+
home folder.
|
|
22
|
+
|
|
23
|
+
**Clearer errors from connected platforms.**
|
|
24
|
+
|
|
25
|
+
- A rejection from a connected platform now reads `Pinterest Pages error 50 (HTTP 404): Pin not
|
|
26
|
+
found.`: the platform (the one named in the response, otherwise the one the command was run for),
|
|
27
|
+
its own error code, the status it answered with and its message. Before, the error read
|
|
28
|
+
`"message": true`. JSON output also carries `api_status_code`, the raw `api_error`, `details`,
|
|
29
|
+
`error_type` and `retry_after`, plus the app's write-outcome fields (`write_state`,
|
|
30
|
+
`ambiguous_write`, `outcome_unknown`, `status_code` and the like) and the response's `http_status`,
|
|
31
|
+
so a script can tell a write may have landed (any of those flags, or a status of 500 or more)
|
|
32
|
+
before it retries. Like the app, an error body with no `status_code` gets the HTTP status as one.
|
|
33
|
+
- `details` that arrive as an object are shown as JSON instead of `[object Object]`; string `details`
|
|
34
|
+
still read as before. A message or any of those fields longer than 2,000 characters is cut with a marker that
|
|
35
|
+
says how much was omitted, and the error is written out whole before the CLI exits, so a piped
|
|
36
|
+
stderr never receives half a JSON document.
|
|
37
|
+
- A 429 keeps `retry_after` in the JSON and adds `Tip: Retry after N seconds.` under `--table`.
|
|
38
|
+
- An error body with no message reports the HTTP status (`Request failed with status 500`).
|
|
39
|
+
- A request that fails after it may have reached the server (connection dropped, response cut off,
|
|
40
|
+
timeout, a 2xx that is not JSON) reports `outcome_unknown: true`, the app's own sign that a write may
|
|
41
|
+
have landed. A request that never left (no connection, a failed certificate check, an invalid
|
|
42
|
+
header) does not, and an invalid header never echoes the token.
|
|
43
|
+
- A response that stops arriving ends after the timeout passes with no new data; a slow but steady
|
|
44
|
+
one is never cut, and query results have no size cap.
|
|
45
|
+
- Requests identify themselves as `insightfulpipe-cli/<version>` (User-Agent).
|
|
46
|
+
- Needs Node.js 18.20 or later: older 18.x releases print a fetch warning on stderr ahead of the JSON.
|
|
47
|
+
|
|
3
48
|
## 0.2.0
|
|
4
49
|
|
|
5
50
|
**JSON is now the default output.** It is read by scripts and agents far more often than by eyes.
|
package/README.md
CHANGED
|
@@ -12,7 +12,7 @@ Recommended workflow:
|
|
|
12
12
|
|
|
13
13
|
## Requirements
|
|
14
14
|
|
|
15
|
-
- Node.js 18+
|
|
15
|
+
- Node.js 18.20+
|
|
16
16
|
- An InsightfulPipe API token starting with `ip_sk_`
|
|
17
17
|
|
|
18
18
|
## Installation
|
|
@@ -46,6 +46,45 @@ The CLI also reads these environment variables:
|
|
|
46
46
|
- `INSIGHTFULPIPE_TOKEN`
|
|
47
47
|
- `INSIGHTFULPIPE_API_URL`
|
|
48
48
|
- `INSIGHTFULPIPE_TIMEOUT_MS`
|
|
49
|
+
- `INSIGHTFULPIPE_SKILLS_URL` (skills catalogue: `https://insightfulpipe.com` by default; only its subdomains or localhost are accepted)
|
|
50
|
+
|
|
51
|
+
## Skills
|
|
52
|
+
|
|
53
|
+
Install InsightfulPipe's marketing skills (Google Ads audits, GA4 reports, SEO and more) into your
|
|
54
|
+
AI agent's skills folder. No login is needed to install: skills are free to download. They read live
|
|
55
|
+
data through the InsightfulPipe MCP once it is connected.
|
|
56
|
+
|
|
57
|
+
```bash
|
|
58
|
+
npx insightfulpipe skills search # browse every skill
|
|
59
|
+
npx insightfulpipe skills search google ads audit # search by words
|
|
60
|
+
npx insightfulpipe skills info google-ads-account-audit
|
|
61
|
+
npx insightfulpipe skills install google-ads-account-audit
|
|
62
|
+
npx insightfulpipe skills install --category seo # every skill in a category
|
|
63
|
+
npx insightfulpipe skills list # installed skills, and which have updates
|
|
64
|
+
npx insightfulpipe skills update --all # keeps your local edits unless --force
|
|
65
|
+
npx insightfulpipe skills remove google-ads-account-audit --yes
|
|
66
|
+
npx insightfulpipe skills download google-ads-account-audit # ZIP for Claude.ai or Claude Desktop
|
|
67
|
+
```
|
|
68
|
+
|
|
69
|
+
Names can be `slug`, `category/slug` or `@insightfulpipe/slug`. A name that exists in two categories
|
|
70
|
+
must be written as `category/slug`.
|
|
71
|
+
|
|
72
|
+
Skills go to Claude Code's global folder by default. Choose another agent with `--agent`, the current
|
|
73
|
+
project with `--project`, or any folder with `--dir`:
|
|
74
|
+
|
|
75
|
+
| `--agent` | Global folder | `--project` folder |
|
|
76
|
+
|---|---|---|
|
|
77
|
+
| `claude-code` (default) | `~/.claude/skills` (or `$CLAUDE_CONFIG_DIR/skills`) | `.claude/skills` |
|
|
78
|
+
| `openclaw` | `~/.openclaw/skills` (or `$OPENCLAW_SKILLS_DIR`) | `skills` |
|
|
79
|
+
| `codex` | `~/.codex/skills` (or `$CODEX_HOME/skills`) | `.agents/skills` |
|
|
80
|
+
| `cursor` | `~/.cursor/skills` | `.agents/skills` |
|
|
81
|
+
| `gemini-cli` | `~/.gemini/skills` | `.agents/skills` |
|
|
82
|
+
|
|
83
|
+
Every file is checked against its sha256 before anything is written, and each installed skill keeps
|
|
84
|
+
a `.insightfulpipe-skill.json` marker. `list`, `update` and `remove` only touch folders that carry it,
|
|
85
|
+
and `update` will not overwrite files you edited unless you add `--force`. The catalogue never
|
|
86
|
+
receives your API token. `INSIGHTFULPIPE_SKILLS_URL` can point the commands at a staging copy on an
|
|
87
|
+
insightfulpipe.com subdomain or at localhost (for testing); any other host is refused.
|
|
49
88
|
|
|
50
89
|
## Core Commands
|
|
51
90
|
|
package/package.json
CHANGED
|
@@ -1,6 +1,6 @@
|
|
|
1
1
|
{
|
|
2
2
|
"name": "insightfulpipe",
|
|
3
|
-
"version": "0.
|
|
3
|
+
"version": "0.3.0",
|
|
4
4
|
"description": "InsightfulPipe CLI \u2014 query your marketing data from the terminal",
|
|
5
5
|
"bin": {
|
|
6
6
|
"insightfulpipe": "bin/cli.js"
|
|
@@ -25,7 +25,7 @@
|
|
|
25
25
|
"test:live": "node --test test/live-smoke.test.js"
|
|
26
26
|
},
|
|
27
27
|
"engines": {
|
|
28
|
-
"node": ">=18"
|
|
28
|
+
"node": ">=18.20"
|
|
29
29
|
},
|
|
30
30
|
"keywords": [
|
|
31
31
|
"insightfulpipe",
|
package/src/api.js
CHANGED
|
@@ -1,7 +1,21 @@
|
|
|
1
|
-
import { fail } from './cli/errors.js';
|
|
1
|
+
import { bounded, fail } from './cli/errors.js';
|
|
2
2
|
import { getApiUrl, getRequestTimeoutMs, getToken } from './config.js';
|
|
3
|
+
import { readBody, USER_AGENT } from './http.js';
|
|
3
4
|
|
|
4
5
|
let _insecureWarned = false;
|
|
6
|
+
// Far above any real error body; past it the body is dropped unread instead of held in memory.
|
|
7
|
+
const MAX_ERROR_BYTES = 10 * 1024 * 1024;
|
|
8
|
+
// Failures before a request could reach the server: nothing can have been written.
|
|
9
|
+
const NOT_SENT_CODES = new Set([
|
|
10
|
+
'ECONNREFUSED',
|
|
11
|
+
'ENOTFOUND',
|
|
12
|
+
'EAI_AGAIN',
|
|
13
|
+
'ENETUNREACH',
|
|
14
|
+
'EHOSTUNREACH',
|
|
15
|
+
'UND_ERR_CONNECT_TIMEOUT',
|
|
16
|
+
]);
|
|
17
|
+
// Certificate checks happen in the handshake, before any request byte is sent.
|
|
18
|
+
const TLS_FAILURE = /^(CERT_|UNABLE_TO_|ERR_TLS_CERT_)|SELF_SIGNED/;
|
|
5
19
|
|
|
6
20
|
function warnIfInsecure() {
|
|
7
21
|
if (_insecureWarned) return;
|
|
@@ -63,13 +77,11 @@ function summarizeTextError(text, res) {
|
|
|
63
77
|
return {
|
|
64
78
|
error: true,
|
|
65
79
|
status: res.status,
|
|
66
|
-
message: text,
|
|
80
|
+
message: bounded(text),
|
|
67
81
|
};
|
|
68
82
|
}
|
|
69
83
|
|
|
70
|
-
|
|
71
|
-
const text = await res.text();
|
|
72
|
-
|
|
84
|
+
function parseJsonResponse(text, res) {
|
|
73
85
|
if (!text.trim()) {
|
|
74
86
|
return {};
|
|
75
87
|
}
|
|
@@ -81,8 +93,9 @@ async function parseJsonResponse(res) {
|
|
|
81
93
|
return {
|
|
82
94
|
error: true,
|
|
83
95
|
status: res.status,
|
|
96
|
+
outcome_unknown: true,
|
|
84
97
|
message: 'Received invalid JSON from server.',
|
|
85
|
-
details: text,
|
|
98
|
+
details: bounded(text),
|
|
86
99
|
};
|
|
87
100
|
}
|
|
88
101
|
|
|
@@ -90,6 +103,64 @@ async function parseJsonResponse(res) {
|
|
|
90
103
|
}
|
|
91
104
|
}
|
|
92
105
|
|
|
106
|
+
/** A request that failed once it may have reached the server is an unknown outcome, never a refusal:
|
|
107
|
+
* a write can land even though no complete answer came back, so a script must not simply resend it. */
|
|
108
|
+
function unanswered(error, res, timeoutMs, method) {
|
|
109
|
+
const cause = error?.cause?.code;
|
|
110
|
+
const notBuilt = !res && error?.name === 'TypeError' && !error.cause;
|
|
111
|
+
const refused = NOT_SENT_CODES.has(cause) || TLS_FAILURE.test(cause ?? '') || error?.cause?.message === 'bad port';
|
|
112
|
+
const neverSent = notBuilt || (!res && refused);
|
|
113
|
+
let message;
|
|
114
|
+
if (error?.name === 'AbortError') {
|
|
115
|
+
message = `Network request timed out after ${timeoutMs} ms`;
|
|
116
|
+
} else if (notBuilt) {
|
|
117
|
+
message = 'The request could not be sent: a header is invalid. Check the API token for line breaks or other control characters.';
|
|
118
|
+
} else if (neverSent) {
|
|
119
|
+
message = `Network request failed: ${error.message} (${cause ?? error.cause?.message})`;
|
|
120
|
+
} else {
|
|
121
|
+
message = `Network request failed before a complete response arrived: ${error?.message}${cause ? ` (${cause})` : ''}`;
|
|
122
|
+
}
|
|
123
|
+
return {
|
|
124
|
+
error: true,
|
|
125
|
+
message,
|
|
126
|
+
...(res ? { status: res.status } : {}),
|
|
127
|
+
...(neverSent || method === 'GET' ? {} : { outcome_unknown: true }),
|
|
128
|
+
};
|
|
129
|
+
}
|
|
130
|
+
|
|
131
|
+
/** One request under the shared timeout. An error body is read under that timeout and capped; a success
|
|
132
|
+
* body has no size or total-time cap (query results are never cut), only an idle timeout, so a stalled
|
|
133
|
+
* server still cannot hold the command open. Every non-2xx result carries its HTTP status. */
|
|
134
|
+
async function send(url, options, timeoutMs) {
|
|
135
|
+
const controller = new AbortController();
|
|
136
|
+
const abort = () => controller.abort();
|
|
137
|
+
const timeout = setTimeout(abort, timeoutMs);
|
|
138
|
+
let res;
|
|
139
|
+
let raw;
|
|
140
|
+
try {
|
|
141
|
+
res = await fetch(url, { ...options, signal: controller.signal });
|
|
142
|
+
if (res.ok) {
|
|
143
|
+
clearTimeout(timeout);
|
|
144
|
+
}
|
|
145
|
+
raw = await readBody(res, res.ok ? { idleMs: timeoutMs, onIdle: abort } : { maxBytes: MAX_ERROR_BYTES });
|
|
146
|
+
} catch (error) {
|
|
147
|
+
return unanswered(error, res, timeoutMs, options.method);
|
|
148
|
+
} finally {
|
|
149
|
+
clearTimeout(timeout);
|
|
150
|
+
}
|
|
151
|
+
|
|
152
|
+
if (res.ok) {
|
|
153
|
+
return parseJsonResponse(new TextDecoder().decode(raw), res);
|
|
154
|
+
}
|
|
155
|
+
const data =
|
|
156
|
+
raw === null
|
|
157
|
+
? { message: `The server sent an error response larger than ${MAX_ERROR_BYTES} bytes.` }
|
|
158
|
+
: parseJsonResponse(new TextDecoder().decode(raw), res);
|
|
159
|
+
const body = data && typeof data === 'object' ? data : { message: String(data) };
|
|
160
|
+
const statusCode = body.status_code || body.api_status_code ? {} : { status_code: res.status };
|
|
161
|
+
return { ...body, ...statusCode, error: body.error || true, status: res.status };
|
|
162
|
+
}
|
|
163
|
+
|
|
93
164
|
async function apiRequest(method, path, body) {
|
|
94
165
|
warnIfInsecure();
|
|
95
166
|
const token = requireAuth();
|
|
@@ -110,6 +181,7 @@ async function apiRequest(method, path, body) {
|
|
|
110
181
|
headers: {
|
|
111
182
|
'Authorization': `Bearer ${token}`,
|
|
112
183
|
'Accept': 'application/json',
|
|
184
|
+
'User-Agent': USER_AGENT,
|
|
113
185
|
},
|
|
114
186
|
};
|
|
115
187
|
|
|
@@ -118,38 +190,7 @@ async function apiRequest(method, path, body) {
|
|
|
118
190
|
options.body = JSON.stringify(body);
|
|
119
191
|
}
|
|
120
192
|
|
|
121
|
-
|
|
122
|
-
const controller = new AbortController();
|
|
123
|
-
const timeout = setTimeout(() => controller.abort(), timeoutMs);
|
|
124
|
-
try {
|
|
125
|
-
res = await fetch(url, { ...options, signal: controller.signal });
|
|
126
|
-
} catch (error) {
|
|
127
|
-
clearTimeout(timeout);
|
|
128
|
-
return {
|
|
129
|
-
error: true,
|
|
130
|
-
message:
|
|
131
|
-
error?.name === 'AbortError'
|
|
132
|
-
? `Network request timed out after ${timeoutMs} ms`
|
|
133
|
-
: `Network request failed: ${error.message}`,
|
|
134
|
-
};
|
|
135
|
-
}
|
|
136
|
-
clearTimeout(timeout);
|
|
137
|
-
|
|
138
|
-
const data = await parseJsonResponse(res);
|
|
139
|
-
|
|
140
|
-
if (data && data.error) {
|
|
141
|
-
return data;
|
|
142
|
-
}
|
|
143
|
-
|
|
144
|
-
if (!res.ok) {
|
|
145
|
-
return {
|
|
146
|
-
error: true,
|
|
147
|
-
status: res.status,
|
|
148
|
-
...(data && typeof data === 'object' ? data : { message: String(data) }),
|
|
149
|
-
};
|
|
150
|
-
}
|
|
151
|
-
|
|
152
|
-
return data;
|
|
193
|
+
return send(url, options, timeoutMs);
|
|
153
194
|
}
|
|
154
195
|
|
|
155
196
|
export async function apiGet(path) {
|
|
@@ -174,43 +215,16 @@ export async function accountSummary() {
|
|
|
174
215
|
};
|
|
175
216
|
}
|
|
176
217
|
|
|
177
|
-
|
|
178
|
-
|
|
179
|
-
|
|
180
|
-
try {
|
|
181
|
-
res = await fetch(url, {
|
|
218
|
+
return send(
|
|
219
|
+
url,
|
|
220
|
+
{
|
|
182
221
|
method: 'GET',
|
|
183
222
|
headers: {
|
|
184
223
|
'Authorization': `Bearer ${token}`,
|
|
185
224
|
'Accept': 'application/json',
|
|
225
|
+
'User-Agent': USER_AGENT,
|
|
186
226
|
},
|
|
187
|
-
|
|
188
|
-
|
|
189
|
-
|
|
190
|
-
clearTimeout(timeout);
|
|
191
|
-
return {
|
|
192
|
-
error: true,
|
|
193
|
-
message:
|
|
194
|
-
error?.name === 'AbortError'
|
|
195
|
-
? `Network request timed out after ${timeoutMs} ms`
|
|
196
|
-
: `Network request failed: ${error.message}`,
|
|
197
|
-
};
|
|
198
|
-
}
|
|
199
|
-
clearTimeout(timeout);
|
|
200
|
-
|
|
201
|
-
const data = await parseJsonResponse(res);
|
|
202
|
-
|
|
203
|
-
if (data && data.error) {
|
|
204
|
-
return data;
|
|
205
|
-
}
|
|
206
|
-
|
|
207
|
-
if (!res.ok) {
|
|
208
|
-
return {
|
|
209
|
-
error: true,
|
|
210
|
-
status: res.status,
|
|
211
|
-
...(data && typeof data === 'object' ? data : { message: String(data) }),
|
|
212
|
-
};
|
|
213
|
-
}
|
|
214
|
-
|
|
215
|
-
return data;
|
|
227
|
+
},
|
|
228
|
+
timeoutMs,
|
|
229
|
+
);
|
|
216
230
|
}
|
|
@@ -7,7 +7,7 @@ import {
|
|
|
7
7
|
parseIntegerOption,
|
|
8
8
|
toPromptDataSource,
|
|
9
9
|
} from '../options.js';
|
|
10
|
-
import { fail, handleApiError } from '../errors.js';
|
|
10
|
+
import { errorMessage, fail, handleApiError } from '../errors.js';
|
|
11
11
|
import {
|
|
12
12
|
fetchBrandMetadata,
|
|
13
13
|
fetchConnectedSources,
|
|
@@ -327,7 +327,7 @@ export function registerDiscoveryCommands(program) {
|
|
|
327
327
|
if (data?.error) {
|
|
328
328
|
connectivity = {
|
|
329
329
|
status: 'error',
|
|
330
|
-
details: data
|
|
330
|
+
details: errorMessage(data),
|
|
331
331
|
};
|
|
332
332
|
} else {
|
|
333
333
|
connectivity = {
|
|
@@ -26,14 +26,14 @@ const SCOPE_OPTIONS = [
|
|
|
26
26
|
export function registerExecutionCommands(program) {
|
|
27
27
|
const readAction = async (platform, opts) => {
|
|
28
28
|
const body = scopedBody(ensureJsonObject(await readJsonInput(opts, true), 'Request body'), opts);
|
|
29
|
-
const data = handleApiError(await apiPost('/', withPlatform(platform, body)));
|
|
29
|
+
const data = handleApiError(await apiPost('/', withPlatform(platform, body)), { platform });
|
|
30
30
|
printJson(data);
|
|
31
31
|
};
|
|
32
32
|
|
|
33
33
|
const writeAction = async (platform, opts) => {
|
|
34
34
|
const body = scopedBody(ensureJsonObject(await readJsonInput(opts, true), 'Request body'), opts);
|
|
35
35
|
await confirmWriteAction(platform, body, opts.yes);
|
|
36
|
-
const data = handleApiError(await apiPost('/', withPlatform(platform, body)));
|
|
36
|
+
const data = handleApiError(await apiPost('/', withPlatform(platform, body)), { platform });
|
|
37
37
|
printJson(data);
|
|
38
38
|
};
|
|
39
39
|
|
|
@@ -85,7 +85,7 @@ export function registerExecutionCommands(program) {
|
|
|
85
85
|
.description('Send a raw request to the universal dispatcher')
|
|
86
86
|
.action(async (opts) => {
|
|
87
87
|
const body = ensureJsonObject(await readJsonInput(opts, true), 'Request body');
|
|
88
|
-
const data = handleApiError(await apiPost('/', body));
|
|
88
|
+
const data = handleApiError(await apiPost('/', body), { platform: body.platform });
|
|
89
89
|
printJson(data);
|
|
90
90
|
});
|
|
91
91
|
}
|