@graphit/cli 0.2.330 → 0.2.348

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 (52) hide show
  1. package/.claude-plugin/marketplace.json +3 -3
  2. package/.claude-plugin/plugin.json +1 -1
  3. package/.codex-plugin/plugin.json +1 -1
  4. package/README.md +1 -1
  5. package/bin/graphit +1 -1
  6. package/bin/graphit.ps1 +1 -1
  7. package/commands/align.md +31 -10
  8. package/dist/api/client.d.ts +8 -0
  9. package/dist/api/client.js +24 -2
  10. package/dist/api/client.js.map +1 -1
  11. package/dist/commands/connector/ui-only.d.ts +12 -0
  12. package/dist/commands/connector/ui-only.js +28 -0
  13. package/dist/commands/connector/ui-only.js.map +1 -0
  14. package/dist/commands/connector.js +2 -14
  15. package/dist/commands/connector.js.map +1 -1
  16. package/dist/commands/dashboard.d.ts +14 -0
  17. package/dist/commands/dashboard.js +52 -1
  18. package/dist/commands/dashboard.js.map +1 -1
  19. package/dist/commands/kb-repo-token.d.ts +17 -0
  20. package/dist/commands/kb-repo-token.js +122 -0
  21. package/dist/commands/kb-repo-token.js.map +1 -0
  22. package/dist/commands/kb-repo.d.ts +29 -0
  23. package/dist/commands/kb-repo.js +407 -0
  24. package/dist/commands/kb-repo.js.map +1 -0
  25. package/dist/commands/kb.js +133 -0
  26. package/dist/commands/kb.js.map +1 -1
  27. package/dist/output/format.js +77 -1
  28. package/dist/output/format.js.map +1 -1
  29. package/dist/skill-guard.js +5 -1
  30. package/dist/skill-guard.js.map +1 -1
  31. package/dist/update-check.d.ts +18 -0
  32. package/dist/update-check.js +54 -4
  33. package/dist/update-check.js.map +1 -1
  34. package/package.json +1 -1
  35. package/scripts/generate-tool-manifest.mjs +1 -1
  36. package/scripts/verb-policy-source.json +138 -2
  37. package/skills/graphit/SKILL.md +26 -6
  38. package/skills/graphit/VERSION.json +1 -1
  39. package/skills/graphit/references/alignment.md +34 -12
  40. package/skills/graphit/references/chart-patterns.md +1 -5
  41. package/skills/graphit/references/chart-selection.md +1 -1
  42. package/skills/graphit/references/data-sources.md +7 -3
  43. package/skills/graphit/references/filters.md +1 -1
  44. package/skills/graphit/references/kb-actions.md +4 -0
  45. package/skills/graphit/references/kb-scope.md +4 -0
  46. package/skills/graphit/references/onboarding.md +1 -1
  47. package/skills/graphit/references/operations.md +1 -1
  48. package/skills/graphit/references/repo-kb.md +101 -0
  49. package/skills/graphit/references/runtime.md +1 -1
  50. package/skills/graphit/references/semantic-authoring.md +3 -1
  51. package/skills/graphit/references/state-contract.md +2 -2
  52. package/skills/graphit/references/templates.md +68 -0
@@ -25,7 +25,7 @@ Fix it by wrapping the control (`filters.md` has the attribute table) and saving
25
25
 
26
26
  - Dashboards that already register at runtime. The rule stops the set of undeclared keys from GROWING; an existing violation keeps saving unrelated edits, and a partial fix always passes.
27
27
  - Dynamic keys - `graphit.filter(someVariable)` or a template literal. A key the platform cannot read lexically is never gated.
28
- - State a saved template registers. Template code is not in your stored HTML.
28
+ - State inside a template fragment: a template cannot declare state (`templates.md`).
29
29
  - Reading state: `graphit.state.get('k')` on a key someone else declared.
30
30
 
31
31
  ## Declare Kind and Default Together
@@ -52,7 +52,7 @@ Either repair is legal: put the kind and default in the markup, or drop the decl
52
52
 
53
53
  ## graphit.filter(id, options) as the Escape Hatch
54
54
 
55
- The API keeps working, it is just no longer the default. Use it for keys you cannot write as markup: a key computed at runtime, or state a template registers.
55
+ The API keeps working, it is just no longer the default. Use it for keys you cannot write as markup: a key computed at runtime.
56
56
 
57
57
  ```js
58
58
  const country = graphit.filter('country', { label: 'Country', field: 'COUNTRY', default: 'US' })
@@ -0,0 +1,68 @@
1
+ # Chart Templates
2
+
3
+ **Load when:** reusing a chart across dashboards as a template, or expanding one on a host.
4
+
5
+ A template is a reusable HTML fragment saved to the org's Knowledge Base: markup plus its own `<script>` and `<style>`. A dashboard adopts it by naming it on a **host entity**; the canvas expands the fragment into the host when the page opens. Editing the template changes every adopting dashboard on its next open.
6
+
7
+ ## The host owns the query
8
+
9
+ The host is an ordinary entity, authored empty, on a block container (`div`, `section`, `article`, `aside`, `main` or `figure`):
10
+
11
+ ```html
12
+ <div data-graphit-id="rev-trend" data-graphit-label="Revenue trend"
13
+ data-graphit-ds="UA_DS"
14
+ data-graphit-sql="SELECT day, {{ Metric('revenue') }} AS revenue FROM UA_DS WHERE (:channel = 'ALL' OR channel = :channel) GROUP BY 1"
15
+ data-graphit-vocab="metric:revenue"
16
+ data-graphit-template="TREND_HEADLINE"
17
+ data-graphit-params='{"label":"Revenue","format":"currency"}'></div>
18
+ ```
19
+
20
+ Every query fact - id, label, SQL, data source, vocab, the `:params` the SQL binds - lives on the host, so pre-flight, the details panel, usage and governance see one ordinary entity. The fragment contributes presentation and behavior only. Anything already inside the host stays after the inserted content.
21
+
22
+ ## What a fragment may carry
23
+
24
+ | Allowed | Refused at save and again at expansion |
25
+ |---|---|
26
+ | Markup, `<script>`, `<style>` | `data-graphit-id`, `-label`, `-sql`, `-ds`, `-vocab`, `-field`, `-kb`, any `data-graphit-state*` |
27
+ | `{{name}}` placeholders in markup text and attribute values | `html`, `head`, `body`, `template`, `noscript`, `iframe`, `plaintext`, `xmp`, `base`, `frameset`, `noembed`, `noframes` |
28
+ | A nested host (`data-graphit-template` on an inner element; chains stop at three) | `{{...}}` inside a nested host's `data-graphit-params` |
29
+
30
+ Placeholders are never substituted inside scripts or styles: a script reads its params instead. A template cannot declare state, so filter controls stay page markup (`filters.md`).
31
+
32
+ ## Script rules
33
+
34
+ ```html
35
+ <h3>{{label}}</h3><div class="v"></div>
36
+ <script>
37
+ var host = document.currentScript.closest('[data-graphit-template]');
38
+ var p = graphit._utils.templateParams(host);
39
+ graphit.bind(host, { params: graphit._utils.hostParams(host), render: function (res) {
40
+ host.querySelector('.v').textContent = graphit._utils.fmt(res.data[0].revenue, p.format);
41
+ }});
42
+ </script>
43
+ ```
44
+
45
+ - Find the host through `document.currentScript`; query with `host.querySelector`, never `getElementById`. Two instances of one template must not share ids or global names.
46
+ - A filtered card binds through the host: `hostParams(host)` reads the host SQL's `:names` and serves them from dashboard state, so the fragment works on any dashboard that declares those keys. A static card calls `graphit.resolve({target: host})`.
47
+ - Read params with `templateParams(host)`; a missing param falls back to its schema default. Format, escape and color with `graphit._utils.fmt`, `esc` and `color`; `graphit._utils.tip.show(text, x, y)` and `tip.hide()` are the shared tooltip.
48
+ - A page script that runs at parse time cannot see template content; only a `DOMContentLoaded` listener can. The kebab, trust dot and details panel belong to the host - markup a template inserts is never its own entity.
49
+
50
+ ## Params
51
+
52
+ `params_schema` declares what a host may pass: `{"label": {"type": "string", "required": true, "default": "Revenue", "description": "Card title"}}`. Values are strings, numbers or booleans and names are identifiers; an unknown name substitutes to empty.
53
+
54
+ ## Commands
55
+
56
+ | Command | Does |
57
+ |---|---|
58
+ | `graphit kb template list` | Names, descriptions and params - not the HTML |
59
+ | `graphit kb template get NAME` | The fragment exactly as it expands everywhere |
60
+ | `graphit kb template create --name NAME --file card.html --description "..." --params '{...}'` | Create; `--file` is CLI-only |
61
+ | `graphit kb template update NAME --file card.html` | Replace the fragment; adopters change on next open |
62
+ | `graphit kb template delete NAME --yes` | Delete; adopting hosts render a missing marker |
63
+
64
+ In-app agents pass the fragment through `--json '{"html": "...", "description": "...", "params_schema": {...}}'`. Read a template in full before pushing one you did not write this session: its script runs for everyone who opens an adopting dashboard.
65
+
66
+ ## Live update and copies
67
+
68
+ An edit reaches every adopting dashboard when it is next opened; nothing is re-saved. "Copy entity HTML" of a host yields a frozen copy - the expanded markup, the script and a stamp that stops it expanding again - so a copy is a copy, not a live host.