@commandgarden/cli 2.14.2 → 2.15.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/node_modules/@commandgarden/app/dist/client/assets/Slides-5KujoV-w.js +30 -0
- package/node_modules/@commandgarden/app/dist/client/assets/index-2gEJ4GIc.js +521 -0
- package/node_modules/@commandgarden/app/dist/client/assets/{index-rHqHbsBw.css → index-CHt4v0FJ.css} +1 -1
- package/node_modules/@commandgarden/app/dist/client/index.html +2 -2
- package/node_modules/@commandgarden/app/dist/server/routes/ai-news-cache.d.ts +3 -0
- package/node_modules/@commandgarden/app/dist/server/routes/ai-news-cache.js +17 -0
- package/node_modules/@commandgarden/app/dist/server/routes/connectors.js +4 -0
- package/node_modules/@commandgarden/app/dist/server/routes/index.js +4 -0
- package/node_modules/@commandgarden/app/dist/server/routes/roles-cache.d.ts +3 -0
- package/node_modules/@commandgarden/app/dist/server/routes/roles-cache.js +17 -0
- package/node_modules/@commandgarden/app/dist/server/store.d.ts +12 -0
- package/node_modules/@commandgarden/app/dist/server/store.js +44 -0
- package/node_modules/@commandgarden/app/package.json +0 -3
- package/node_modules/@commandgarden/app/skills/cg/SKILL.md +89 -0
- package/node_modules/@commandgarden/app/skills/connector-authoring/RECON-PLAYBOOK.md +364 -0
- package/node_modules/@commandgarden/app/skills/connector-authoring/SKILL.md +160 -0
- package/node_modules/@commandgarden/chrome/dist/service-worker.js +1 -1
- package/node_modules/@commandgarden/chrome/dist/service-worker.js.map +2 -2
- package/node_modules/@commandgarden/chrome/package.json +0 -3
- package/node_modules/@commandgarden/daemon/connectors/alice-role-list.yaml +62 -0
- package/node_modules/@commandgarden/daemon/connectors/every-newsletter.eval.js +87 -0
- package/node_modules/@commandgarden/daemon/connectors/every-newsletter.yaml +40 -0
- package/node_modules/@commandgarden/daemon/connectors/simonwillison-blog.eval.js +39 -0
- package/node_modules/@commandgarden/daemon/connectors/simonwillison-blog.yaml +39 -0
- package/node_modules/@commandgarden/daemon/connectors/uis-mic-user-information.eval.js +22 -0
- package/node_modules/@commandgarden/daemon/connectors/uis-mic-user-information.yaml +54 -0
- package/node_modules/@commandgarden/daemon/package.json +0 -4
- package/node_modules/@commandgarden/shared/package.json +0 -3
- package/package.json +1 -1
- package/node_modules/@commandgarden/app/dist/client/assets/Slides-DMIm_HgI.js +0 -21
- package/node_modules/@commandgarden/app/dist/client/assets/index-CupEN1w-.js +0 -511
|
@@ -0,0 +1,160 @@
|
|
|
1
|
+
---
|
|
2
|
+
name: connector-authoring
|
|
3
|
+
description: "Connector authoring for commandGarden. Use when creating a new connector YAML, adding a data source, or debugging why a connector returns 0 rows."
|
|
4
|
+
---
|
|
5
|
+
|
|
6
|
+
Build a new commandGarden connector from recon through polish. Each step has a checkable completion criterion.
|
|
7
|
+
|
|
8
|
+
## Step 1: Recon the target site
|
|
9
|
+
|
|
10
|
+
Open the target site in Chrome with DevTools. Goal: find where the data lives and which extraction pattern fits.
|
|
11
|
+
|
|
12
|
+
**Check in this order (cheapest capability first):**
|
|
13
|
+
|
|
14
|
+
1. **Network tab → XHR/Fetch** — filter requests while using the UI. JSON API responses → **`fetch → map`** (capabilities: `navigate`, `cookie_read`). Safest pattern — prefer it.
|
|
15
|
+
|
|
16
|
+
2. **Elements tab → DOM** — repeating elements (table rows, cards) → **`extract`** (`navigate`, `dom_read`). Nested tree (sidebar nav) → **`extract_tree`** (add `dom_write` if collapsed sections need `click_all`).
|
|
17
|
+
|
|
18
|
+
3. **Network tab → page-initiated requests** — data from requests the page makes on its own (GraphQL, polling) → **`intercept`** step with `urlPattern` (`navigate`, `intercept_response`). Middle ground between `fetch` and `js_evaluate`.
|
|
19
|
+
|
|
20
|
+
4. **Source tab → `<script id="__NEXT_DATA__">`** or `__remixContext` — framework-embedded page data → **`js_evaluate`** parsing the script tag.
|
|
21
|
+
|
|
22
|
+
5. **Console → `sessionStorage`** — MSAL/OAuth tokens needed as Bearer for API calls → **`js_evaluate`** polling sessionStorage then calling fetch with the token.
|
|
23
|
+
|
|
24
|
+
6. **Network tab → invisible transports** — requests missing from `window.fetch` interception (MCAS proxy, Service Workers) → **`js_evaluate`** with fetch interception, potentially requiring CDP `Fetch.enable`. Read [`RECON-PLAYBOOK.md`](RECON-PLAYBOOK.md) technique 5 before going this route.
|
|
25
|
+
|
|
26
|
+
**Record during recon:**
|
|
27
|
+
- Exact hostname(s) → `domains`
|
|
28
|
+
- API endpoint or DOM selectors
|
|
29
|
+
- Response shape (field names, types) → `columns`
|
|
30
|
+
- Auth mechanism (SSO redirect, MFA, token polling, session cookies)
|
|
31
|
+
- Proxy layers (MCAS `*.mcas.ms`, Cloudflare, etc.)
|
|
32
|
+
|
|
33
|
+
**Completion:** You can name the pattern and have the target URL, data shape, and auth mechanism documented.
|
|
34
|
+
|
|
35
|
+
---
|
|
36
|
+
|
|
37
|
+
## Step 2: Scaffold the YAML
|
|
38
|
+
|
|
39
|
+
Create the `.yaml` file in `~/.commandgarden/connectors/` for rapid iteration (daemon loads this directory without rebuild).
|
|
40
|
+
|
|
41
|
+
```yaml
|
|
42
|
+
site: <sitename>
|
|
43
|
+
name: <command-name>
|
|
44
|
+
version: "1.0"
|
|
45
|
+
description: "<what data this connector returns>"
|
|
46
|
+
access: read
|
|
47
|
+
|
|
48
|
+
domains:
|
|
49
|
+
- "<exact hostname from recon>"
|
|
50
|
+
capabilities:
|
|
51
|
+
- navigate
|
|
52
|
+
# add others based on chosen pattern
|
|
53
|
+
|
|
54
|
+
args:
|
|
55
|
+
- name: <argname>
|
|
56
|
+
type: string
|
|
57
|
+
required: true
|
|
58
|
+
help: "<what this arg does>"
|
|
59
|
+
# optional: pattern, enum, default
|
|
60
|
+
|
|
61
|
+
columns:
|
|
62
|
+
- name: <fieldname>
|
|
63
|
+
type: string # or number, boolean
|
|
64
|
+
|
|
65
|
+
pipeline: []
|
|
66
|
+
```
|
|
67
|
+
|
|
68
|
+
The full connector schema is defined in `shared/src/connector.ts` (Zod). Validation rules:
|
|
69
|
+
- Every hostname in `navigate`/`fetch`/`cookie` URLs must appear in `domains`.
|
|
70
|
+
- Every pipeline step's required capability must appear in `capabilities`.
|
|
71
|
+
- `js_evaluate` steps require either `code` or `file`.
|
|
72
|
+
|
|
73
|
+
Run `cg validate <path>` — it should report only the empty-pipeline error, nothing else.
|
|
74
|
+
|
|
75
|
+
**Completion:** `cg validate` reports only the pipeline-length schema error.
|
|
76
|
+
|
|
77
|
+
---
|
|
78
|
+
|
|
79
|
+
## Step 3: Implement the pipeline
|
|
80
|
+
|
|
81
|
+
Fill in `pipeline` based on the pattern from recon.
|
|
82
|
+
|
|
83
|
+
Read [`docs/connector-authoring.md`](../../docs/connector-authoring.md) for pattern templates (fetch→map, extract, extract_tree, js_evaluate, __NEXT_DATA__) and [`docs/pipeline-reference.md`](../../docs/pipeline-reference.md) for the full step reference.
|
|
84
|
+
|
|
85
|
+
**Key rules for `js_evaluate` eval.js files:**
|
|
86
|
+
|
|
87
|
+
- **No IIFE wrapper.** The runner wraps code in `new AsyncFunction()`. A `return` inside `(function(){ ... })()` exits the inner function — the outer function gets `undefined` and the pipeline silently produces 0 rows.
|
|
88
|
+
- **`await` works** at the top level.
|
|
89
|
+
- **Template variables** `${{ args.name }}` are interpolated before execution. Quote them: `const x = '${{ args.date }}'`.
|
|
90
|
+
- **Return** an array of objects to set pipeline data. Or use `as:` on the step to store a single value as a variable.
|
|
91
|
+
- **Poll for auth** — SSO redirects take time. Poll `sessionStorage` or a DOM signal in a loop with a 30–60s deadline.
|
|
92
|
+
|
|
93
|
+
Create the `.eval.js` file **next to** the YAML. See existing examples in `connectors/` for each pattern.
|
|
94
|
+
|
|
95
|
+
**Completion:** `cg validate <path>` passes clean. If using `js_evaluate`, the `.eval.js` file exists.
|
|
96
|
+
|
|
97
|
+
---
|
|
98
|
+
|
|
99
|
+
## Step 4: Debug loop
|
|
100
|
+
|
|
101
|
+
The loop: **run → read audit → probe → fix → repeat.**
|
|
102
|
+
|
|
103
|
+
### First run
|
|
104
|
+
|
|
105
|
+
```bash
|
|
106
|
+
# Approve if using js_evaluate
|
|
107
|
+
cg config set security.approvedHighRisk <site>/<name>
|
|
108
|
+
|
|
109
|
+
cg run <site>/<name> --format json
|
|
110
|
+
```
|
|
111
|
+
|
|
112
|
+
### Read the audit log (always do this first)
|
|
113
|
+
|
|
114
|
+
```bash
|
|
115
|
+
cg audit export --format json --since 5m
|
|
116
|
+
```
|
|
117
|
+
|
|
118
|
+
Check `steps[]` — per-step timing and errors. See the symptom→cause table in [`docs/connector-authoring.md` § Debugging Connectors](../../docs/connector-authoring.md#debugging-connectors).
|
|
119
|
+
|
|
120
|
+
### When the audit log isn't enough
|
|
121
|
+
|
|
122
|
+
Read [`RECON-PLAYBOOK.md`](RECON-PLAYBOOK.md) for ground-layer probing:
|
|
123
|
+
|
|
124
|
+
- **Strip the pipeline** — remove steps from the end until data flows, add back one at a time.
|
|
125
|
+
- **Raw output** — remove `map` step, run with `--format json` to see actual field names.
|
|
126
|
+
- **Console injection** — `console.log()` in eval.js, watch in DevTools.
|
|
127
|
+
- **window.fetch interception** — capture requests the page makes on its own.
|
|
128
|
+
- **CDP Fetch.enable** — when `window.fetch` misses requests (MCAS, Service Workers).
|
|
129
|
+
|
|
130
|
+
### Reload cycle
|
|
131
|
+
|
|
132
|
+
The daemon caches eval.js contents at startup via `ConnectorRegistry.resolveFileRefs()`.
|
|
133
|
+
|
|
134
|
+
| What changed | Minimum reload |
|
|
135
|
+
|---|---|
|
|
136
|
+
| WIP YAML/eval.js in `~/.commandgarden/connectors/` | Restart daemon: `cg down && cg up` |
|
|
137
|
+
| Source YAML only (in `connectors/`) | `npm run build -w daemon && cg down && cg up` |
|
|
138
|
+
| Source YAML + eval.js | `npm run build -w daemon && cg down && cg up` |
|
|
139
|
+
| Extension code (chrome-adapter.ts) | `npm run build && cg down && cg up` + reload at `chrome://extensions` |
|
|
140
|
+
|
|
141
|
+
**Fastest path:** Put WIP connector in `~/.commandgarden/connectors/`. Edit → restart daemon → test. No build step.
|
|
142
|
+
|
|
143
|
+
**Completion:** `cg run` returns expected data rows consistently across 3+ runs. Audit log shows no unexpected step errors or delays.
|
|
144
|
+
|
|
145
|
+
---
|
|
146
|
+
|
|
147
|
+
## Step 5: Polish
|
|
148
|
+
|
|
149
|
+
1. **Args** — add `pattern` for format validation (`"^\\d{4}-\\d{2}$"`), `enum` for fixed choices, `default` for optional args.
|
|
150
|
+
2. **Columns** — declare every output field with correct `type`. Drives CLI table formatting.
|
|
151
|
+
3. **Error messages** — in eval.js, throw with actionable text: `'Not signed in — log in and retry'`, `'No results for "${query}"'`.
|
|
152
|
+
4. **Description** — one line: what data the connector returns, not how.
|
|
153
|
+
5. **Validate + inspect:**
|
|
154
|
+
```bash
|
|
155
|
+
cg validate <path>
|
|
156
|
+
cg list # shows in connector list
|
|
157
|
+
cg inspect <site>/<name> # shows full definition with args
|
|
158
|
+
```
|
|
159
|
+
|
|
160
|
+
**Completion:** `cg validate` passes. `cg list` shows the connector. `cg inspect` shows args with help text. Bad args produce a helpful error. `cg run` with `--format table` formats columns correctly.
|
|
@@ -6928,7 +6928,7 @@ var PipelineContext = class {
|
|
|
6928
6928
|
applyFilter(field, operator, value) {
|
|
6929
6929
|
this.data = this.data.filter((row) => {
|
|
6930
6930
|
const actual = row[field];
|
|
6931
|
-
const expected = isNaN(Number(value)) ? value : Number(value);
|
|
6931
|
+
const expected = value === "" || isNaN(Number(value)) ? value : Number(value);
|
|
6932
6932
|
switch (operator) {
|
|
6933
6933
|
case "eq":
|
|
6934
6934
|
return actual === expected;
|