@graphit/cli 0.2.0 → 0.2.40
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/.claude-plugin/marketplace.json +3 -3
- package/.claude-plugin/plugin.json +1 -1
- package/.codex-plugin/plugin.json +1 -1
- package/bin/graphit +1 -1
- package/bin/graphit.ps1 +1 -1
- package/dist/api/client.d.ts +8 -0
- package/dist/api/client.js +41 -0
- package/dist/api/client.js.map +1 -1
- package/dist/commands/dashboard.d.ts +24 -0
- package/dist/commands/dashboard.js +44 -4
- package/dist/commands/dashboard.js.map +1 -1
- package/dist/commands/ds.d.ts +17 -0
- package/dist/commands/ds.js +121 -22
- package/dist/commands/ds.js.map +1 -1
- package/dist/commands/kb.js +47 -3
- package/dist/commands/kb.js.map +1 -1
- package/dist/commands/query-timeout.d.ts +2 -0
- package/dist/commands/query-timeout.js +19 -0
- package/dist/commands/query-timeout.js.map +1 -0
- package/dist/commands/query.js +12 -2
- package/dist/commands/query.js.map +1 -1
- package/package.json +1 -1
- package/skills/graphit/SKILL.md +16 -13
- package/skills/graphit/VERSION.json +1 -1
- package/skills/graphit/references/data-sources.md +5 -3
- package/skills/graphit/references/kb-discovery.md +2 -2
- package/skills/graphit/references/kb-traversal.md +16 -11
- package/skills/graphit/references/operations.md +7 -0
- package/skills/graphit/references/parameterized-metrics.md +3 -3
- package/skills/graphit/references/sql-reference.md +1 -3
|
@@ -50,7 +50,7 @@ A wide or raw source is sometimes the right call - row-level drill-down/export,
|
|
|
50
50
|
|
|
51
51
|
## Creating data sources
|
|
52
52
|
|
|
53
|
-
`graphit ds create` auto-chains: create -> poll until ready -> scan schema -> print verification link.
|
|
53
|
+
`graphit ds create` auto-chains: create -> poll until ready -> scan schema -> print verification link. To activate for KB use, either the user reviews and activates via the link on the platform, or - after you show them the scanned schema and they accept it - run `graphit ds verify <id> --accept-schema` to activate from the CLI.
|
|
54
54
|
|
|
55
55
|
```bash
|
|
56
56
|
# Create with auto-scan (recommended)
|
|
@@ -60,11 +60,13 @@ graphit ds create --name "MY_DS" --sql "SELECT ..." --connection <id>
|
|
|
60
60
|
graphit ds create --name "MY_DS" --sql "SELECT ..." --skip-scan
|
|
61
61
|
```
|
|
62
62
|
|
|
63
|
-
|
|
63
|
+
**From a local file (Excel/CSV):** `graphit ds create --file <path>` uploads the file and creates one data source. Optional: `--name` (defaults to the file name), `--sheet <name>` (only when an Excel workbook has multiple sheets), and `--domain <NAME>` to attach the new table to an existing KB domain (create it first with `graphit kb create domain --name <NAME>` if it doesn't exist). `--file` and `--sql` are mutually exclusive; same auto-scan + verification-link flow as above.
|
|
64
|
+
|
|
65
|
+
For existing unverified sources, `graphit ds verify <id>` scans and shows the schema; add `--accept-schema` to accept the AI schema and activate a warehouse/SQL source from the CLI (file uploads activate automatically).
|
|
64
66
|
|
|
65
67
|
## Refreshing data sources
|
|
66
68
|
|
|
67
|
-
Data sources cache a snapshot of the Snowflake query result. Refresh when you need current data.
|
|
69
|
+
Data sources cache a snapshot of the Snowflake query result. Refresh when you need current data. **File-upload sources can't be refreshed (no query to re-run) - update them by re-uploading with `graphit ds create --file <path>`.**
|
|
68
70
|
|
|
69
71
|
```bash
|
|
70
72
|
# Refresh all data sources and wait for completion (live status table)
|
|
@@ -10,9 +10,9 @@ Work narrow, not broad: **domain -> data source -> assets.** The first move is a
|
|
|
10
10
|
2. **Explore that domain.** `graphit kb explore domain <NAME>` returns the domain's data sources plus the metrics, dimensions, and rules defined on them, in one traversal. This is your working set, and it is the primary discovery call.
|
|
11
11
|
3. **Reuse the assets.** If a metric fits, read its formula with `graphit kb get metric REVENUE` and reference it by name in SQL as `{{metric:REVENUE}}`.
|
|
12
12
|
4. **Handle gaps.** If the domain's data source is missing something, check `graphit kb list relationships` for a connection to another data source you can join; if the data genuinely does not exist, propose creating the asset or a new data source (see below).
|
|
13
|
-
5. **Broaden only as a fallback.** Use `graphit kb search "<concept>"` only when an exploration came up empty or the concept name is too fuzzy to match a domain or topic. Search is semantic (matches by meaning, ranked by a relevance `score`) merged with name/text matching, and capped by `--limit` - the result carries `total` and `truncated`. So an empty or unexpected result means *maybe ranked-out or truncated*, never proof an asset is absent: raise `--limit`, narrow `--type`, or confirm a specific name with `kb get` before concluding it doesn't exist. (`graphit kb list domains` enumerates domain names when you need to pick one; it is a name lookup, not the asset-discovery path - explore the domain to see its assets.)
|
|
13
|
+
5. **Broaden only as a fallback.** Use `graphit kb search "<concept>"` only when an exploration came up empty or the concept name is too fuzzy to match a domain or topic. Search is semantic (matches by meaning, ranked by a relevance `score`) merged with name/text matching, and capped by `--limit` - the result carries `total` and `truncated`. So an empty or unexpected result means *maybe ranked-out or truncated*, never proof an asset is absent: raise `--limit`, narrow `--type`, or confirm a specific name with `kb get` before concluding it doesn't exist. `graphit kb list` carries `total`/`truncated` too - fewer rows than `total` means the list was capped, not that assets are missing; raise `--limit`. (`graphit kb list domains` enumerates domain names when you need to pick one; it is a name lookup, not the asset-discovery path - explore the domain to see its assets.)
|
|
14
14
|
|
|
15
|
-
If a domain has tables but no metrics or dimensions, that is the strongest signal to propose foundational assets before building any graph - this is the KB-readiness gate the build workflow enforces. If the user declines ("just build it", "skip KB"), respect it and work from the table schema.
|
|
15
|
+
If a domain has tables but no metrics or dimensions, that is the strongest signal to propose foundational assets before building any graph - this is the KB-readiness gate the build workflow enforces. If the user declines ("just build it", "skip KB"), respect it and work from the table schema - read it with `graphit kb explore table <NAME>`, which returns the columns (names, types, descriptions).
|
|
16
16
|
|
|
17
17
|
## Metric vs Dimension
|
|
18
18
|
|
|
@@ -2,14 +2,16 @@
|
|
|
2
2
|
|
|
3
3
|
Contents: Which Command (the read-command picker) - Common Queries (worked examples) - Reading the Results - Presenting KB Results (the per-command output templates).
|
|
4
4
|
|
|
5
|
-
Which `graphit kb` read command answers each question, and how to present the result.
|
|
5
|
+
Which `graphit kb` read command answers each question, and how to present the result. Each verb owns one role: `graphit kb list <type>` is the **inventory** (how many, and which, assets of a type exist), `graphit kb get <type> NAME` is one asset's **full definition**, and `graphit kb explore <type> NAME` is the **relationships** call - it walks the graph around one entity and returns its whole neighborhood (and, for a template, its concrete variants) in one call. `graphit kb search "<query>"` is the fallback for semantic discovery when you cannot name the entity. Explore is the primary discovery call.
|
|
6
6
|
|
|
7
7
|
## Which Command
|
|
8
8
|
|
|
9
9
|
| Question | Command |
|
|
10
10
|
|---|---|
|
|
11
|
+
| How many / which assets of a type exist (inventory) | `graphit kb list <type>` (metrics collapse to templates; `--include-variants` for the flat set) |
|
|
11
12
|
| What is inside a domain or topic (the build entry point) | `graphit kb explore domain NAME` / `graphit kb explore topic NAME` |
|
|
12
13
|
| What connects to X (dependencies, joins, topics, domain) | `graphit kb explore <type> NAME` |
|
|
14
|
+
| A template's concrete variants | `graphit kb explore metric NAME` |
|
|
13
15
|
| Get one asset's full details | `graphit kb get metric NAME` |
|
|
14
16
|
| Find things like X when you cannot name it (semantic) | `graphit kb search "X"` (add `--type metric` to narrow) |
|
|
15
17
|
|
|
@@ -24,7 +26,10 @@ Which `graphit kb` read command answers each question, and how to present the re
|
|
|
24
26
|
`graphit kb explore topic REVENUE` returns the assets tagged with that concept across every domain. Fall back to `graphit kb search "revenue" --type metric` only when no topic captures the concept.
|
|
25
27
|
|
|
26
28
|
### "What depends on the ORDERS table?"
|
|
27
|
-
`graphit kb explore table ORDERS` -
|
|
29
|
+
`graphit kb explore table ORDERS` - returns the table's column schema (names, types, descriptions) plus `metric_count`/`dimension_count`/`rule_count` and every bound metric (collapsed to templates, each with a `variant_count`), dimension, and rule whose SQL references ORDERS. The counts include child variants; the lists stay collapsed.
|
|
30
|
+
|
|
31
|
+
### "What columns does this table or data source have?" (read the schema)
|
|
32
|
+
`graphit kb explore table <NAME>` (or `graphit kb get table <NAME>`) returns the column schema - names, types, descriptions - straight from the knowledge base. This is how you read a table's schema; never `DESCRIBE` it (only read-only SELECT runs through `graphit query`, so DESCRIBE/SHOW/DDL are rejected). If a data source was just created and not yet scanned, the KB has no columns for it yet - read its shape with `graphit query "SELECT * FROM <NAME> LIMIT 0" --ds <id>`, or run `graphit ds verify <id>` to scan it into the KB.
|
|
28
33
|
|
|
29
34
|
### "What joins with MARKETING_UA_DS?"
|
|
30
35
|
`graphit kb explore table MARKETING_UA_DS`, then read the relationships in the response (the documented JOINs involving that table).
|
|
@@ -42,18 +47,18 @@ Which `graphit kb` read command answers each question, and how to present the re
|
|
|
42
47
|
|
|
43
48
|
A single `graphit kb explore` call returns one entity's full neighborhood, so it usually answers the question on its own - scan the response and run a second command only if the first does not contain what you need. The user cannot see raw CLI output; render every result with these per-command templates.
|
|
44
49
|
|
|
45
|
-
**After `graphit kb list <type>`** - count summary + table with bold names
|
|
50
|
+
**After `graphit kb list <type>`** - count summary + table with bold names. The list is the **inventory**, and the response carries `total`/`truncated`: if the rows shown are fewer than `total`, the list was capped - raise `--limit` (a missing asset may be truncated, not absent). For metrics the list is **collapsed** - each row is a template or a flat metric, never a child variant; a template's `variant_count` says how many concrete variants it owns. Use `--include-variants` for the full flat set, or `graphit kb explore metric NAME` to enumerate one template's variants.
|
|
46
51
|
|
|
47
52
|
~~~
|
|
48
|
-
**12 metrics** across 3 tables:
|
|
53
|
+
**12 metrics** (10 flat + 2 templates, 38 variants) across 3 tables:
|
|
49
54
|
|
|
50
|
-
| Metric | Table | Calculation | Params |
|
|
51
|
-
|
|
52
|
-
| **CPI** | **MARKETING_UA** | `SUM(spend)/SUM(installs)` | - |
|
|
53
|
-
| **ARPU** | **MARKETING_UA** | `SUM(revenue)/COUNT(...)` | DAY |
|
|
54
|
-
| **RETENTION** | **PLAYER_QUALITY** | `COUNT(CASE WHEN ...)` | DAY |
|
|
55
|
+
| Metric | Table | Calculation | Params | Variants |
|
|
56
|
+
|---|---|---|---|---|
|
|
57
|
+
| **CPI** | **MARKETING_UA** | `SUM(spend)/SUM(installs)` | - | - |
|
|
58
|
+
| **ARPU** | **MARKETING_UA** | `SUM(revenue)/COUNT(...)` | DAY | 18 |
|
|
59
|
+
| **RETENTION** | **PLAYER_QUALITY** | `COUNT(CASE WHEN ...)` | DAY | 20 |
|
|
55
60
|
|
|
56
|
-
|
|
61
|
+
To use a variant, reference `{{metric:ARPU(DAY=7)}}`; to list them, explore the template.
|
|
57
62
|
~~~
|
|
58
63
|
|
|
59
64
|
Adapt columns per type: dimensions include semantic type, rules include constraint count, domains include asset count.
|
|
@@ -101,4 +106,4 @@ Adapt fields per type. Rules: content, constraints, apply-on, override policy. D
|
|
|
101
106
|
- **Domain:** MARKETING
|
|
102
107
|
~~~
|
|
103
108
|
|
|
104
|
-
For domain exploration, show Domain > Table > Asset hierarchy as a tree.
|
|
109
|
+
For domain exploration, show Domain > Table > Asset hierarchy as a tree. For table exploration, list the table's columns first (`NAME - type - description`), then the metrics, dimensions, and rules defined on it.
|
|
@@ -10,6 +10,7 @@ Load this when the concern is the Graphit CLI or plugin itself, not the analysis
|
|
|
10
10
|
- [Legacy copied-file setup](#legacy-copied-file-setup)
|
|
11
11
|
- [Permission errors](#permission-errors)
|
|
12
12
|
- [Output contract](#output-contract)
|
|
13
|
+
- [Working artifacts](#working-artifacts)
|
|
13
14
|
- [Reporting failures and partial results](#reporting-failures-and-partial-results)
|
|
14
15
|
|
|
15
16
|
Governance is enforced server-side by the query gateway. There is no client-side query guard, so never claim to block a query locally; a query is rejected by the platform, not the CLI.
|
|
@@ -78,6 +79,12 @@ Commands write only the result payload to stdout; all decoration (progress, tabl
|
|
|
78
79
|
- Use json for anything you read back, especially nested output (`kb explore`, query rows, `kb get`). `--output table` is a quick flat human view; nested cells render as compact JSON, not `[object Object]`.
|
|
79
80
|
- `--output styled` is the interactive view - never parse it.
|
|
80
81
|
|
|
82
|
+
## Working artifacts
|
|
83
|
+
|
|
84
|
+
Keep every local file you create in one place: a `./.graphit/` directory in the working dir (distinct from the `~/.graphit/` credential store). Scratch HTML written before `graphit dashboard update-html <id> --file`, output redirected from `graphit dashboard get-html`, exported PNG/PDF, throwaway SQL - all under `.graphit/`, never scattered across the user's repo. `graphit dashboard export` already defaults its output there (no `--output` needed) and drops a self-ignoring `.gitignore`, so the dir is never committed.
|
|
85
|
+
|
|
86
|
+
These are ephemeral. The platform dashboard is the source of truth and the durable artifact; anything local re-materializes on demand (`graphit dashboard get-html <id>` for the HTML, `graphit dashboard export <id> --format png|pdf` for a rendered image). When you finish a piece of work, offer to remove `.graphit/` - nothing of value is lost. Keep it a soft suggestion, not a forced step.
|
|
87
|
+
|
|
81
88
|
## Reporting failures and partial results
|
|
82
89
|
|
|
83
90
|
When a command fails or only part of a multi-step task succeeds, report it truthfully. The user cannot see the raw CLI output, so a bare "something went wrong" leaves them stuck. Verify each step before claiming it; never report a step as done that you did not confirm.
|
|
@@ -31,7 +31,7 @@ Paired with a calculation such as `SUM(${PARAM:REVENUE}) / SUM(cost) * 100 ${PAR
|
|
|
31
31
|
|------|--------|
|
|
32
32
|
| Token match | Every `${PARAM:NAME}` token in the calculation needs a matching parameter by name |
|
|
33
33
|
| Empty values | Valid as no-ops (e.g. D0 adds no filter) |
|
|
34
|
-
| Variant cap | Max
|
|
34
|
+
| Variant cap | Max 1000 (the Cartesian product of all parameter values) |
|
|
35
35
|
| Child naming | Auto-generated as `{PARENT}_{VALUE1}_{VALUE2}` (e.g. ROAS_ALL_BOOKINGS_D7) |
|
|
36
36
|
| Validation | Template create skips per-formula validation (children validate on generation) |
|
|
37
37
|
|
|
@@ -52,7 +52,7 @@ If the user targets a child for edit or delete, redirect to the parent: "ROAS_AL
|
|
|
52
52
|
|
|
53
53
|
You never substitute tokens by hand. The server resolves a variant when you reference it with the parameter syntax in SQL.
|
|
54
54
|
|
|
55
|
-
1. Find the template. `graphit kb list metric` shows a `params` column
|
|
55
|
+
1. Find the template. `graphit kb list metric` shows the collapsed inventory - templates and flat metrics only, never child variants - with a `params` column (the required parameter names, e.g. `REVENUE, DN`) and a `variant_count`; an empty `params` cell means the metric is flat. To enumerate a template's concrete variants, `graphit kb explore metric NAME`; reach for `graphit kb list metric --include-variants` only when you truly need every child row flat.
|
|
56
56
|
2. Map the user's words to parameter values: "D7 ROAS for new users" maps to `REVENUE=NEW_BOOKINGS` and `DN=D7`.
|
|
57
57
|
3. Reference it with `{{metric:NAME(K=V)}}` in the query SQL, e.g. `{{metric:ROAS(REVENUE=NEW_BOOKINGS, DN=D7)}}`. The server expands it to the pre-validated child calculation at query time.
|
|
58
58
|
|
|
@@ -62,7 +62,7 @@ graphit query "SELECT {{dim:INSTALL_MONTH}}, {{metric:ROAS(REVENUE=NEW_BOOKINGS,
|
|
|
62
62
|
|
|
63
63
|
Defaults and errors:
|
|
64
64
|
- Omitting a parameter on a required metric returns a clear error naming the parameter and the valid values. Retry with a value or ask the user which one they meant.
|
|
65
|
-
- A pre-baked variant (ROAS_D7, ARPU_D30) has its value hardcoded in the name, so reference it plainly as `{{metric:ROAS_D7}}` with no parameter clause.
|
|
65
|
+
- A pre-baked variant (ROAS_D7, ARPU_D30) has its value hardcoded in the name, so reference it plainly as `{{metric:ROAS_D7}}` with no parameter clause. Find its exact name via `graphit kb explore metric ROAS` (lists the variants) or `graphit kb list metric --include-variants` - the collapsed `kb list` does not show child variant names.
|
|
66
66
|
|
|
67
67
|
## Contrast: Wrong vs Right
|
|
68
68
|
|
|
@@ -1,6 +1,6 @@
|
|
|
1
1
|
# SQL Reference
|
|
2
2
|
|
|
3
|
-
Consult when writing queries. Data source queries (`graphit query --ds`) run DuckDB. Warehouse queries (`graphit query --warehouse`) run Snowflake. You MUST use the correct dialect.
|
|
3
|
+
Consult when writing queries. Data source queries (`graphit query --ds`) run DuckDB. Warehouse queries (`graphit query --warehouse`) run Snowflake. You MUST use the correct dialect. To read a table's columns, use `graphit kb explore table <NAME>` - never `DESCRIBE`/DDL (`graphit query` runs SELECT only).
|
|
4
4
|
|
|
5
5
|
## DuckDB vs Snowflake Translation
|
|
6
6
|
|
|
@@ -192,5 +192,3 @@ For ad-hoc queries, suggest the KB reference equivalent when one exists. This nu
|
|
|
192
192
|
**Always use `--verbose`** to get the resolved SQL. If the user didn't pass it, re-run with `--verbose` so you can show both the reference query and the expanded SQL.
|
|
193
193
|
|
|
194
194
|
Zero rows: explain what you checked and hypothesize why (wrong date range, filter too strict, table empty).
|
|
195
|
-
|
|
196
|
-
The `graphit ds list` output template lives in `data-sources.md`.
|