@lightdash-tools/mcp 0.13.2 → 0.16.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 (137) hide show
  1. package/README.md +54 -18
  2. package/dist/auth/oauth-broker/lightdash-token.d.ts +6 -5
  3. package/dist/auth/oauth-broker/lightdash-token.js +6 -10
  4. package/dist/auth/oauth-broker/mcp-access-token.d.ts +31 -0
  5. package/dist/auth/oauth-broker/mcp-access-token.js +109 -0
  6. package/dist/auth/oauth-broker/mcp-access-token.test.d.ts +1 -0
  7. package/dist/auth/oauth-broker/mcp-access-token.test.js +61 -0
  8. package/dist/auth/oauth-broker/pending-store.d.ts +9 -3
  9. package/dist/auth/oauth-broker/pending-store.js +5 -3
  10. package/dist/auth/oauth-broker/pending-store.test.js +28 -44
  11. package/dist/auth/oauth-broker/routes.d.ts +2 -1
  12. package/dist/auth/oauth-broker/routes.js +97 -45
  13. package/dist/auth/oauth-broker/routes.test.js +81 -13
  14. package/dist/auth/request-state-key.d.ts +1 -1
  15. package/dist/auth/request-state-key.js +1 -1
  16. package/dist/auth/resource-server/lightdash-oauth-middleware.d.ts +2 -0
  17. package/dist/auth/resource-server/lightdash-oauth-middleware.js +58 -37
  18. package/dist/auth/resource-server/lightdash-oauth-middleware.test.js +59 -57
  19. package/dist/auth/resource-server/oauth-protected-resource.d.ts +2 -2
  20. package/dist/auth/resource-server/oauth-protected-resource.js +10 -9
  21. package/dist/bin.js +34 -8
  22. package/dist/config/enabled-profiles.d.ts +23 -0
  23. package/dist/config/enabled-profiles.js +57 -0
  24. package/dist/config/enabled-profiles.test.d.ts +1 -0
  25. package/dist/config/enabled-profiles.test.js +62 -0
  26. package/dist/config/env.d.ts +7 -0
  27. package/dist/config/env.js +8 -1
  28. package/dist/config/load-mcp-config.d.ts +15 -1
  29. package/dist/config/load-mcp-config.js +21 -9
  30. package/dist/config/load-mcp-config.test.js +61 -0
  31. package/dist/config/prompt-context-policy.d.ts +18 -0
  32. package/dist/config/prompt-context-policy.js +40 -0
  33. package/dist/config/prompt-context-policy.test.d.ts +4 -0
  34. package/dist/config/prompt-context-policy.test.js +35 -0
  35. package/dist/config/test-mcp-http-config.js +4 -1
  36. package/dist/governance/mcp-post-factory-context.d.ts +2 -0
  37. package/dist/http.d.ts +7 -1
  38. package/dist/http.integration.test.js +102 -44
  39. package/dist/http.js +10 -1
  40. package/dist/index.d.ts +6 -1
  41. package/dist/index.integration.test.js +3 -12
  42. package/dist/index.js +6 -3
  43. package/dist/policy/content-developer.d.ts +5 -0
  44. package/dist/policy/content-developer.js +25 -1
  45. package/dist/policy/content-developer.test.js +29 -0
  46. package/dist/profiles/ai-agent-ops/v1/invariants.d.ts +27 -0
  47. package/dist/profiles/ai-agent-ops/v1/invariants.js +39 -0
  48. package/dist/profiles/ai-agent-ops/v1/prompts.d.ts +3 -2
  49. package/dist/profiles/ai-agent-ops/v1/prompts.js +67 -41
  50. package/dist/profiles/ai-agent-ops/v1/resources/playbooks.d.ts +2 -1
  51. package/dist/profiles/ai-agent-ops/v1/resources/playbooks.js +10 -3
  52. package/dist/profiles/content-developer/v1/invariants.d.ts +69 -0
  53. package/dist/profiles/content-developer/v1/invariants.js +95 -0
  54. package/dist/profiles/content-developer/v1/prompt-specs.d.ts +32 -0
  55. package/dist/profiles/content-developer/v1/prompt-specs.js +56 -0
  56. package/dist/profiles/content-developer/v1/prompts.d.ts +4 -3
  57. package/dist/profiles/content-developer/v1/prompts.js +65 -71
  58. package/dist/profiles/content-developer/v1/prompts.test.js +61 -7
  59. package/dist/profiles/content-developer/v1/resources/playbooks/chart-types.md +2 -1
  60. package/dist/profiles/content-developer/v1/resources/playbooks/core.md +3 -1
  61. package/dist/profiles/content-developer/v1/resources/playbooks/dashboard-design.md +11 -1
  62. package/dist/profiles/content-developer/v1/resources/playbooks/dashboards.md +1 -1
  63. package/dist/profiles/content-developer/v1/resources/playbooks/index.md +11 -8
  64. package/dist/profiles/content-developer/v1/resources/playbooks/recovery/dashboard-diff.md +15 -0
  65. package/dist/profiles/content-developer/v1/resources/playbooks/recovery/preview-required.md +14 -0
  66. package/dist/profiles/content-developer/v1/resources/playbooks/recovery/preview-stale.md +21 -0
  67. package/dist/profiles/content-developer/v1/resources/playbooks/table-calculations.md +15 -3
  68. package/dist/profiles/content-developer/v1/resources/playbooks.d.ts +3 -2
  69. package/dist/profiles/content-developer/v1/resources/playbooks.js +35 -21
  70. package/dist/profiles/content-governance/v1/invariants.d.ts +27 -0
  71. package/dist/profiles/content-governance/v1/invariants.js +39 -0
  72. package/dist/profiles/content-governance/v1/prompts.d.ts +4 -2
  73. package/dist/profiles/content-governance/v1/prompts.js +31 -19
  74. package/dist/profiles/content-governance/v1/resources/playbooks.d.ts +2 -1
  75. package/dist/profiles/content-governance/v1/resources/playbooks.js +8 -9
  76. package/dist/profiles/content-reader/v1/index.js +1 -0
  77. package/dist/profiles/content-reader/v1/invariants.d.ts +33 -0
  78. package/dist/profiles/content-reader/v1/invariants.js +47 -0
  79. package/dist/profiles/content-reader/v1/prompt-specs.d.ts +18 -0
  80. package/dist/profiles/content-reader/v1/prompt-specs.js +33 -0
  81. package/dist/profiles/content-reader/v1/prompts.d.ts +3 -2
  82. package/dist/profiles/content-reader/v1/prompts.js +69 -75
  83. package/dist/profiles/content-reader/v1/resources/playbooks/compare.md +1 -1
  84. package/dist/profiles/content-reader/v1/resources/playbooks/core.md +1 -0
  85. package/dist/profiles/content-reader/v1/resources/playbooks/discover.md +12 -3
  86. package/dist/profiles/content-reader/v1/resources/playbooks/explain-run.md +2 -1
  87. package/dist/profiles/content-reader/v1/resources/playbooks.d.ts +2 -1
  88. package/dist/profiles/content-reader/v1/resources/playbooks.js +10 -11
  89. package/dist/profiles/data-analyst/v1/invariants.d.ts +21 -0
  90. package/dist/profiles/data-analyst/v1/invariants.js +31 -0
  91. package/dist/profiles/data-analyst/v1/prompts.d.ts +3 -2
  92. package/dist/profiles/data-analyst/v1/prompts.js +17 -9
  93. package/dist/profiles/data-analyst/v1/resources/playbooks.d.ts +2 -1
  94. package/dist/profiles/data-analyst/v1/resources/playbooks.js +6 -7
  95. package/dist/profiles/index.d.ts +2 -1
  96. package/dist/profiles/index.js +2 -1
  97. package/dist/profiles/index.test.js +2 -1
  98. package/dist/profiles/lib/playbook-resources.d.ts +16 -34
  99. package/dist/profiles/lib/playbook-resources.js +55 -76
  100. package/dist/profiles/lib/prompt-context.d.ts +71 -0
  101. package/dist/profiles/lib/prompt-context.js +205 -0
  102. package/dist/profiles/lib/prompt-context.test.d.ts +4 -0
  103. package/dist/profiles/lib/prompt-context.test.js +154 -0
  104. package/dist/profiles/lib/prompt-invariants.d.ts +20 -0
  105. package/dist/profiles/lib/prompt-invariants.js +54 -0
  106. package/dist/profiles/organization-audit/v1/invariants.d.ts +24 -0
  107. package/dist/profiles/organization-audit/v1/invariants.js +35 -0
  108. package/dist/profiles/organization-audit/v1/prompts.d.ts +3 -2
  109. package/dist/profiles/organization-audit/v1/prompts.js +44 -28
  110. package/dist/profiles/organization-audit/v1/resources/playbooks.d.ts +2 -1
  111. package/dist/profiles/organization-audit/v1/resources/playbooks.js +10 -3
  112. package/dist/profiles/semantic-layer/v1/invariants.d.ts +27 -0
  113. package/dist/profiles/semantic-layer/v1/invariants.js +39 -0
  114. package/dist/profiles/semantic-layer/v1/prompts.d.ts +3 -2
  115. package/dist/profiles/semantic-layer/v1/prompts.js +37 -26
  116. package/dist/profiles/semantic-layer/v1/resources/playbooks.d.ts +2 -4
  117. package/dist/profiles/semantic-layer/v1/resources/playbooks.js +8 -7
  118. package/dist/profiles/test-support/prompt-context-budget.test.d.ts +5 -0
  119. package/dist/profiles/test-support/prompt-context-budget.test.js +72 -0
  120. package/dist/profiles/types.d.ts +6 -1
  121. package/dist/server/capabilities.d.ts +3 -0
  122. package/dist/server/capabilities.js +4 -2
  123. package/dist/stdio.process.test.js +2 -1
  124. package/dist/tools/lib/schema-fields.d.ts +4 -0
  125. package/dist/tools/lib/schema-fields.js +8 -1
  126. package/dist/tools/project/developer-content-preview.js +1 -1
  127. package/dist/tools/project/developer-content.js +2 -2
  128. package/dist/tools/project/reader-content.d.ts +2 -0
  129. package/dist/tools/project/reader-content.js +28 -1
  130. package/dist/tools/query/reader-tool-helpers.d.ts +2 -2
  131. package/dist/tools/query/reader-tool-helpers.js +2 -2
  132. package/dist/tools/query/reader-tool-helpers.test.js +1 -0
  133. package/dist/tools/shared.d.ts +6 -1
  134. package/dist/tools/shared.js +12 -2
  135. package/dist/transports/streamable-http.js +16 -6
  136. package/dist/transports/streamable-http.test.js +16 -0
  137. package/package.json +3 -3
@@ -0,0 +1,95 @@
1
+ "use strict";
2
+ /**
3
+ * Content-developer structured prompt invariants (SSOT for capsules + HARD_BANS projection).
4
+ */
5
+ Object.defineProperty(exports, "__esModule", { value: true });
6
+ exports.CONTENT_DEVELOPER_DEFAULT_INVARIANT_IDS = exports.CONTENT_DEVELOPER_HARD_BANS = exports.CONTENT_DEVELOPER_INVARIANTS = void 0;
7
+ const prompt_invariants_js_1 = require("../../lib/prompt-invariants.js");
8
+ exports.CONTENT_DEVELOPER_INVARIANTS = [
9
+ {
10
+ id: 'no-arbitrary-sql',
11
+ short: 'Do not execute arbitrary metric queries, raw SQL, warehouse runs, or saved-chart execution.',
12
+ },
13
+ {
14
+ id: 'no-sql-charts',
15
+ short: 'Do not author or upsert SQL charts.',
16
+ },
17
+ {
18
+ id: 'no-hard-delete-promote',
19
+ short: 'Do not hard-delete, rollback, or promote content (use content-governance for promote).',
20
+ },
21
+ {
22
+ id: 'no-org-admin',
23
+ short: 'Do not perform organization administration or list org-wide projects.',
24
+ },
25
+ {
26
+ id: 'no-space-crud',
27
+ short: 'Do not create or update spaces — spaces are Terraform / out-of-band; use existing spaces only.',
28
+ },
29
+ {
30
+ id: 'no-space-only-charts',
31
+ short: 'Do not create space-only charts for dashboard work — set dashboardSlug to the dashboard shell already created.',
32
+ },
33
+ {
34
+ id: 'design-approval',
35
+ short: 'Do not call preview_* or write tools for a new dashboard or a material dashboard redesign until a Design Spec (with settled Objective) was presented and the user approved or amended it in-thread.',
36
+ },
37
+ {
38
+ id: 'objective-first',
39
+ short: 'Do not start writes from a viz-type or all-chart-types checklist alone — settle Objective and insight questions first (an explicit user all-types ask may be the Objective after a one-line restatement).',
40
+ },
41
+ {
42
+ id: 'project-scope',
43
+ short: 'Do not call confirm_preview without projectUuid when there is no HTTP X-Lightdash-Project pin (PROJECT_SCOPE_REQUIRED).',
44
+ },
45
+ {
46
+ id: 'tile-targets-filters',
47
+ short: 'Do not attach dashboard filters whose target.tableName is absent from a tile explore without excluding that tile (or remapping) via tileTargets.',
48
+ },
49
+ {
50
+ id: 'dashboard-shell-first',
51
+ short: 'Do not treat chart create as done without a dashboard shell and tiles.',
52
+ },
53
+ {
54
+ id: 'no-invent-field-ids',
55
+ short: 'Do not invent fieldIds — clone via get_chart_as_code / get_chart or use semantic-layer.',
56
+ },
57
+ {
58
+ id: 'no-skinny-chart-config',
59
+ short: 'Do not invent skinny chartConfig — clone a working as-code body and keep series/layout/encode.',
60
+ },
61
+ {
62
+ id: 'no-verify-unless-asked',
63
+ short: 'Do not set chart verified or dashboard preserveVerification unless the user explicitly asks (verify permission required).',
64
+ },
65
+ {
66
+ id: 'preview-confirm-apply',
67
+ short: 'Do not apply a write tool without a confirmed, unexpired HMAC previewToken from the matching preview_* tool (confirm_preview unlocks every write; use the new validated token).',
68
+ },
69
+ {
70
+ id: 'immutable-preview-payload',
71
+ short: 'Do not mutate the proposed payload after preview_* (description/name/SQL/metrics/tiles) — apply must reuse the identical proposed body or PREVIEW_STALE (content hash mismatch); any edit requires a new preview_*.',
72
+ },
73
+ {
74
+ id: 'preview-kind-key-match',
75
+ short: "Do not unlock with a different resource's preview — resourceKind / resourceKey must match the preview exactly.",
76
+ },
77
+ {
78
+ id: 'validate-not-unlock',
79
+ short: 'Do not treat validate_chart / validate_dashboard as a preview unlock — they are saved-UUID health checks only (validate_chart needs chartUuid).',
80
+ },
81
+ {
82
+ id: 'no-reuse-draft-token',
83
+ short: 'Do not reuse a draft previewToken after confirm; re-run preview if the resource drifts (PREVIEW_STALE).',
84
+ },
85
+ {
86
+ id: 'no-sdd-mcp-click-loops',
87
+ short: 'Do not use subagent-driven-development or multi-task writing-plans solely to click MCP preview/confirm/apply for lab boards (e.g. experiments) — after Design Spec approval, run Batch SOP inline in the same session.',
88
+ },
89
+ {
90
+ id: 'no-secrets',
91
+ short: 'Do not reveal secrets, warehouse credentials, or saved SQL chart bodies.',
92
+ },
93
+ ];
94
+ exports.CONTENT_DEVELOPER_HARD_BANS = (0, prompt_invariants_js_1.formatHardBansProjection)(exports.CONTENT_DEVELOPER_INVARIANTS);
95
+ exports.CONTENT_DEVELOPER_DEFAULT_INVARIANT_IDS = (0, prompt_invariants_js_1.allInvariantIds)(exports.CONTENT_DEVELOPER_INVARIANTS);
@@ -0,0 +1,32 @@
1
+ /**
2
+ * Pure PromptContextSpec builders for content-developer prompts.
3
+ * Shared by registerContentDeveloperPrompts and budget gates.
4
+ */
5
+ import type { ContentDeveloperPlaybookTopic } from './resources/playbooks.js';
6
+ import type { PromptContextSpec } from '../../lib/prompt-context.js';
7
+ /** Topics for create/improve dashboard prompts (shell + design + viz). */
8
+ export declare const DASHBOARD_CHART_TOPIC_IDS: readonly ["dashboards", "dashboard-design", "chart-types"];
9
+ /** Topics for refactor (shell + design). */
10
+ export declare const DASHBOARD_TOPIC_IDS: readonly ["dashboards", "dashboard-design"];
11
+ /** Topics for publish (shell + viz). */
12
+ export declare const DASHBOARD_PUBLISH_TOPIC_IDS: readonly ["dashboards", "chart-types"];
13
+ /** Manifest `when` comes from TOPIC_META.useWhen (optional `when` on entries). */
14
+ export declare const WRITE_RECOVERY_TOPICS: readonly [{
15
+ readonly topic: "recovery/preview-stale";
16
+ }, {
17
+ readonly topic: "recovery/preview-required";
18
+ }, {
19
+ readonly topic: "recovery/dashboard-diff";
20
+ }];
21
+ /** Thin stop gate — Phase Design / Objective detail lives in dashboard-design playbook. */
22
+ export declare const DESIGN_SPEC_STOP = "Emit a Design Spec (dashboard-design Phase Design: Objective + tiles with tableName citing insights + filter apply/exclude plan), then **stop until the user proceeds / approves / amends** before any preview_* or write. If the user already gave an explicit all-chart-types (or multi-viz) checklist + goal + projectUuid, a one-line Objective restatement is enough \u2014 treat that as approval after restating once. Always pass projectUuid on confirm_preview and apply when there is no HTTP pin.";
23
+ export type CreateDashboardPromptArgs = {
24
+ goal: string;
25
+ projectUuid?: string;
26
+ spaceUuid?: string;
27
+ chartReferences?: string;
28
+ };
29
+ /**
30
+ * Production PromptContextSpec for `create_dashboard` (task + topics + recovery).
31
+ */
32
+ export declare function buildCreateDashboardPromptSpec(args: CreateDashboardPromptArgs): PromptContextSpec<ContentDeveloperPlaybookTopic>;
@@ -0,0 +1,56 @@
1
+ "use strict";
2
+ /**
3
+ * Pure PromptContextSpec builders for content-developer prompts.
4
+ * Shared by registerContentDeveloperPrompts and budget gates.
5
+ */
6
+ Object.defineProperty(exports, "__esModule", { value: true });
7
+ exports.DESIGN_SPEC_STOP = exports.WRITE_RECOVERY_TOPICS = exports.DASHBOARD_PUBLISH_TOPIC_IDS = exports.DASHBOARD_TOPIC_IDS = exports.DASHBOARD_CHART_TOPIC_IDS = void 0;
8
+ exports.buildCreateDashboardPromptSpec = buildCreateDashboardPromptSpec;
9
+ const schema_fields_js_1 = require("../../../tools/lib/schema-fields.js");
10
+ const invariants_js_1 = require("./invariants.js");
11
+ const TOPIC_DASHBOARDS = 'dashboards';
12
+ const TOPIC_DASHBOARD_DESIGN = 'dashboard-design';
13
+ const TOPIC_CHART_TYPES = 'chart-types';
14
+ /** Topics for create/improve dashboard prompts (shell + design + viz). */
15
+ exports.DASHBOARD_CHART_TOPIC_IDS = [
16
+ TOPIC_DASHBOARDS,
17
+ TOPIC_DASHBOARD_DESIGN,
18
+ TOPIC_CHART_TYPES,
19
+ ];
20
+ /** Topics for refactor (shell + design). */
21
+ exports.DASHBOARD_TOPIC_IDS = [TOPIC_DASHBOARDS, TOPIC_DASHBOARD_DESIGN];
22
+ /** Topics for publish (shell + viz). */
23
+ exports.DASHBOARD_PUBLISH_TOPIC_IDS = [TOPIC_DASHBOARDS, TOPIC_CHART_TYPES];
24
+ /** Manifest `when` comes from TOPIC_META.useWhen (optional `when` on entries). */
25
+ exports.WRITE_RECOVERY_TOPICS = [
26
+ { topic: 'recovery/preview-stale' },
27
+ { topic: 'recovery/preview-required' },
28
+ { topic: 'recovery/dashboard-diff' },
29
+ ];
30
+ /** Thin stop gate — Phase Design / Objective detail lives in dashboard-design playbook. */
31
+ exports.DESIGN_SPEC_STOP = 'Emit a Design Spec (dashboard-design Phase Design: Objective + tiles with tableName citing insights + filter apply/exclude plan), then **stop until the user proceeds / approves / amends** before any preview_* or write. If the user already gave an explicit all-chart-types (or multi-viz) checklist + goal + projectUuid, a one-line Objective restatement is enough — treat that as approval after restating once. Always pass projectUuid on confirm_preview and apply when there is no HTTP pin.';
32
+ /**
33
+ * Production PromptContextSpec for `create_dashboard` (task + topics + recovery).
34
+ */
35
+ function buildCreateDashboardPromptSpec(args) {
36
+ const { goal, projectUuid, spaceUuid, chartReferences } = args;
37
+ return {
38
+ task: `Create a new dashboard for this goal:
39
+
40
+ ${goal}
41
+
42
+ ${(0, schema_fields_js_1.formatPromptProjectUuidLine)(projectUuid)}
43
+
44
+ Target existing space: ${spaceUuid !== null && spaceUuid !== void 0 ? spaceUuid : '(resolve with lightdash_list_spaces / lightdash_get_space — never create a space)'}.
45
+ Chart hints: ${chartReferences !== null && chartReferences !== void 0 ? chartReferences : '(none provided — discover seeds via get_space / short search_content, then get_chart_as_code)'}.
46
+
47
+ 1. If the goal is vague on audience / decisions / what to understand: ask **2–4 clarifying questions** before a Spec (do not invent a viz-type checklist).
48
+ 2. Read-only discovery only (project/space/seeds).
49
+ 3. ${exports.DESIGN_SPEC_STOP} Multi-viz / all chart types only if the user explicitly asked (see dashboards + chart-types playbooks). For explicit all-types work, keep primary insights decision-oriented and place redundant required forms in a labeled validation appendix; never weaken semantic field requirements.
50
+ 4. After approval: follow playbooks (preview→confirm→apply; reuse the **exact** preview payload on apply — do not tidy description/name between confirm and create).
51
+ 5. Report dashboard UUID/slug, tiles, filters, chart UUIDs — reject space-only orphans or untiled dashboard-owned charts.`,
52
+ invariantIds: invariants_js_1.CONTENT_DEVELOPER_DEFAULT_INVARIANT_IDS,
53
+ requiredTopics: exports.DASHBOARD_CHART_TOPIC_IDS,
54
+ recoveryTopics: exports.WRITE_RECOVERY_TOPICS,
55
+ };
56
+ }
@@ -1,8 +1,9 @@
1
1
  /**
2
- * MCP prompts for content-developer workflows.
2
+ * MCP prompts for content-developer workflows (progressive-disclosure context).
3
3
  *
4
- * Procedure detail lives in playbooks (embedded via createPromptPlaybookEmbedder).
4
+ * Procedure detail lives in playbooks (manifest / selective embed via policy).
5
5
  * Prompt bodies stay goal/input-specific — do not restate entire SOPs here.
6
6
  */
7
+ import type { RegisterPromptsOptions } from '../../types.js';
7
8
  import type { McpServer } from '@modelcontextprotocol/server';
8
- export declare function registerContentDeveloperPrompts(server: McpServer): void;
9
+ export declare function registerContentDeveloperPrompts(server: McpServer, options?: RegisterPromptsOptions): void;
@@ -1,8 +1,8 @@
1
1
  "use strict";
2
2
  /**
3
- * MCP prompts for content-developer workflows.
3
+ * MCP prompts for content-developer workflows (progressive-disclosure context).
4
4
  *
5
- * Procedure detail lives in playbooks (embedded via createPromptPlaybookEmbedder).
5
+ * Procedure detail lives in playbooks (manifest / selective embed via policy).
6
6
  * Prompt bodies stay goal/input-specific — do not restate entire SOPs here.
7
7
  */
8
8
  Object.defineProperty(exports, "__esModule", { value: true });
@@ -10,149 +10,143 @@ exports.registerContentDeveloperPrompts = registerContentDeveloperPrompts;
10
10
  /* eslint-disable @typescript-eslint/no-deprecated -- matches content-reader prompt registration pattern */
11
11
  const zod_1 = require("zod");
12
12
  const schema_fields_js_1 = require("../../../tools/lib/schema-fields.js");
13
- const playbook_resources_js_1 = require("../../lib/playbook-resources.js");
13
+ const prompt_context_js_1 = require("../../lib/prompt-context.js");
14
+ const invariants_js_1 = require("./invariants.js");
15
+ const prompt_specs_js_1 = require("./prompt-specs.js");
14
16
  const playbooks_js_1 = require("./resources/playbooks.js");
15
- const userMessages = (0, playbook_resources_js_1.createPromptPlaybookEmbedder)({
17
+ const TOPIC_CHART_TYPES = 'chart-types';
18
+ const TOPIC_TABLE_CALCULATIONS = 'table-calculations';
19
+ const TOPIC_CONTENT_MOVE = 'content-move';
20
+ const bindPromptContext = (0, prompt_context_js_1.bindProfilePromptContext)({
21
+ invariants: invariants_js_1.CONTENT_DEVELOPER_INVARIANTS,
16
22
  core: playbooks_js_1.CONTENT_DEVELOPER_CORE_PLAYBOOK,
17
23
  topics: playbooks_js_1.CONTENT_DEVELOPER_TOPIC_PLAYBOOKS,
24
+ topicMeta: playbooks_js_1.CONTENT_DEVELOPER_TOPIC_META,
18
25
  });
19
- const optionalProjectUuid = (0, schema_fields_js_1.projectUuidField)().optional();
20
- const PROJECT_UUID_HINT = '(pass on every tool, or use HTTP pin — else PROJECT_SCOPE_REQUIRED)';
21
- const TOPIC_DASHBOARDS = 'dashboards';
22
- const TOPIC_DASHBOARD_DESIGN = 'dashboard-design';
23
- const TOPIC_CHART_TYPES = 'chart-types';
24
- const TOPIC_TABLE_CALCULATIONS = 'table-calculations';
25
- const DASHBOARD_CHART_TOPIC_IDS = [
26
- TOPIC_DASHBOARDS,
27
- TOPIC_DASHBOARD_DESIGN,
28
- TOPIC_CHART_TYPES,
29
- ];
30
- const DASHBOARD_TOPIC_IDS = [TOPIC_DASHBOARDS, TOPIC_DASHBOARD_DESIGN];
31
- const DASHBOARD_PUBLISH_TOPIC_IDS = [TOPIC_DASHBOARDS, TOPIC_CHART_TYPES];
32
- /** Thin stop gate — Phase Design / Objective detail lives in dashboard-design playbook. */
33
- const DESIGN_SPEC_STOP = 'Emit a Design Spec (dashboard-design Phase Design: Objective + tiles with tableName citing insights + filter apply/exclude plan), then **stop until the user proceeds / approves / amends** before any preview_* or write. If the user already gave an explicit all-chart-types (or multi-viz) checklist + goal + projectUuid, a one-line Objective restatement is enough — treat that as approval after restating once. Always pass projectUuid on confirm_preview and apply when there is no HTTP pin.';
34
- function registerContentDeveloperPrompts(server) {
26
+ function registerContentDeveloperPrompts(server, options) {
27
+ const promptContext = bindPromptContext(options === null || options === void 0 ? void 0 : options.promptContextPolicy);
28
+ const invariantIds = invariants_js_1.CONTENT_DEVELOPER_DEFAULT_INVARIANT_IDS;
35
29
  server.registerPrompt('create_dashboard', {
36
30
  title: 'Create dashboard',
37
31
  description: 'Clarify Objective → Design Spec (await approval) → shell → dashboardSlug charts → tiles / filters',
38
32
  argsSchema: {
39
33
  goal: zod_1.z.string(),
40
- projectUuid: optionalProjectUuid,
34
+ projectUuid: (0, schema_fields_js_1.optionalProjectUuidField)(),
41
35
  spaceUuid: zod_1.z.string().optional(),
42
36
  chartReferences: zod_1.z.string().optional(),
43
37
  },
44
- }, ({ goal, projectUuid, spaceUuid, chartReferences }) => userMessages(`Create a new dashboard for this goal:
45
-
46
- ${goal}
47
-
48
- Project UUID: ${projectUuid !== null && projectUuid !== void 0 ? projectUuid : PROJECT_UUID_HINT}.
49
-
50
- ${playbooks_js_1.CONTENT_DEVELOPER_HARD_BANS}
51
-
52
- Target existing space: ${spaceUuid !== null && spaceUuid !== void 0 ? spaceUuid : '(resolve with lightdash_list_spaces / lightdash_get_space — never create a space)'}.
53
- Chart hints: ${chartReferences !== null && chartReferences !== void 0 ? chartReferences : '(none provided — discover seeds via get_space / short search_content, then get_chart_as_code)'}.
54
-
55
- 1. If the goal is vague on audience / decisions / what to understand: ask **2–4 clarifying questions** before a Spec (do not invent a viz-type checklist).
56
- 2. Read-only discovery only (project/space/seeds).
57
- 3. ${DESIGN_SPEC_STOP} Multi-viz / all chart types only if the user explicitly asked (see dashboards + chart-types playbooks). For explicit all-types work, keep primary insights decision-oriented and place redundant required forms in a labeled validation appendix; never weaken semantic field requirements.
58
- 4. After approval: follow embedded playbooks (preview→confirm→apply; reuse the **exact** preview payload on apply — do not tidy description/name between confirm and create).
59
- 5. Report dashboard UUID/slug, tiles, filters, chart UUIDs — reject space-only orphans or untiled dashboard-owned charts.`, DASHBOARD_CHART_TOPIC_IDS));
38
+ }, ({ goal, projectUuid, spaceUuid, chartReferences }) => promptContext((0, prompt_specs_js_1.buildCreateDashboardPromptSpec)({ goal, projectUuid, spaceUuid, chartReferences })));
60
39
  server.registerPrompt('improve_dashboard', {
61
40
  title: 'Improve dashboard',
62
41
  description: 'Clarify Objective if needed → Design Spec delta (await approval) → layout / filters / tiles',
63
42
  argsSchema: {
64
43
  dashboardUuidOrSlug: zod_1.z.string(),
65
44
  improvementGoal: zod_1.z.string(),
66
- projectUuid: optionalProjectUuid,
45
+ projectUuid: (0, schema_fields_js_1.optionalProjectUuidField)(),
67
46
  },
68
- }, ({ dashboardUuidOrSlug, improvementGoal, projectUuid }) => userMessages(`Improve dashboard ${dashboardUuidOrSlug} for this goal:
47
+ }, ({ dashboardUuidOrSlug, improvementGoal, projectUuid }) => promptContext({
48
+ task: `Improve dashboard ${dashboardUuidOrSlug} for this goal:
69
49
 
70
50
  ${improvementGoal}
71
51
 
72
- Project UUID: ${projectUuid !== null && projectUuid !== void 0 ? projectUuid : PROJECT_UUID_HINT}.
73
-
74
- ${playbooks_js_1.CONTENT_DEVELOPER_HARD_BANS}
52
+ ${(0, schema_fields_js_1.formatPromptProjectUuidLine)(projectUuid)}
75
53
 
76
54
  1. Inspect with lightdash_get_dashboard first (tile x/y/w/h may be missing — rebuild layout intentionally).
77
55
  2. If the improvement goal is vague on decisions / insights: ask **2–4 clarifying questions** before a Spec delta.
78
- 3. For material layout/tile/filter changes (including professionalize): ${DESIGN_SPEC_STOP} Use the **Improve / professionalize Spec delta** (keep / drop / rename + cull) in dashboard-design. Trivial one-shot renames the user already specified may skip the stop. Multi-viz / all chart types only if the user explicitly asked.
79
- 4. After approval: follow embedded playbooks (reuse the **exact** preview payload on apply). New charts: get_chart_as_code + dashboardSlug, then tile. Rename tile titles and chart names when stripping demo prefixes.
80
- Report what changed (tiles, filters, chart UUIDs), any untiled dashboard-owned leftovers (content-governance for soft-delete), and validation warnings.`, DASHBOARD_CHART_TOPIC_IDS));
56
+ 3. For material layout/tile/filter changes (including professionalize): ${prompt_specs_js_1.DESIGN_SPEC_STOP} Use the **Improve / professionalize Spec delta** (keep / drop / rename + cull) in dashboard-design. Trivial one-shot renames the user already specified may skip the stop. Multi-viz / all chart types only if the user explicitly asked.
57
+ 4. After approval: follow playbooks (reuse the **exact** preview payload on apply). New charts: get_chart_as_code + dashboardSlug, then tile. Rename tile titles and chart names when stripping demo prefixes.
58
+ Report what changed (tiles, filters, chart UUIDs), any untiled dashboard-owned leftovers (content-governance for soft-delete), and validation warnings.`,
59
+ invariantIds,
60
+ requiredTopics: prompt_specs_js_1.DASHBOARD_CHART_TOPIC_IDS,
61
+ recoveryTopics: prompt_specs_js_1.WRITE_RECOVERY_TOPICS,
62
+ }));
81
63
  server.registerPrompt('refactor_dashboard', {
82
64
  title: 'Refactor dashboard',
83
65
  description: 'Compare versions; Design Spec delta for material changes (await approval), then reconcile',
84
66
  argsSchema: {
85
67
  dashboardUuidOrSlug: zod_1.z.string(),
86
68
  concern: zod_1.z.string().optional(),
87
- projectUuid: optionalProjectUuid,
69
+ projectUuid: (0, schema_fields_js_1.optionalProjectUuidField)(),
88
70
  },
89
- }, ({ dashboardUuidOrSlug, concern, projectUuid }) => userMessages(`Refactor dashboard ${dashboardUuidOrSlug}.
90
-
91
- Project UUID: ${projectUuid !== null && projectUuid !== void 0 ? projectUuid : PROJECT_UUID_HINT}.
71
+ }, ({ dashboardUuidOrSlug, concern, projectUuid }) => promptContext({
72
+ task: `Refactor dashboard ${dashboardUuidOrSlug}.
92
73
 
93
- ${playbooks_js_1.CONTENT_DEVELOPER_HARD_BANS}
74
+ ${(0, schema_fields_js_1.formatPromptProjectUuidLine)(projectUuid)}
94
75
 
95
76
  Concern: ${concern !== null && concern !== void 0 ? concern : '(general cleanup)'}.
96
77
  1. Use lightdash_compare_dashboard_versions before proposing changes.
97
- 2. For material layout/tile/filter changes: ${DESIGN_SPEC_STOP} Trivial one-shot renames may skip the stop.
98
- 3. After approval: follow embedded dashboards + dashboard-design. Do not remove tiles unless the approved Spec or user request allows it.`, DASHBOARD_TOPIC_IDS));
78
+ 2. For material layout/tile/filter changes: ${prompt_specs_js_1.DESIGN_SPEC_STOP} Trivial one-shot renames may skip the stop.
79
+ 3. After approval: follow dashboards + dashboard-design. Do not remove tiles unless the approved Spec or user request allows it.`,
80
+ invariantIds,
81
+ requiredTopics: prompt_specs_js_1.DASHBOARD_TOPIC_IDS,
82
+ recoveryTopics: prompt_specs_js_1.WRITE_RECOVERY_TOPICS,
83
+ }));
99
84
  server.registerPrompt('author_chart', {
100
85
  title: 'Author chart',
101
86
  description: 'Clone a working seed chart (cartesian encode intact); optional dashboardSlug scoping',
102
87
  argsSchema: {
103
88
  goal: zod_1.z.string(),
104
- projectUuid: optionalProjectUuid,
89
+ projectUuid: (0, schema_fields_js_1.optionalProjectUuidField)(),
105
90
  seedChartUuidOrSlug: zod_1.z.string().optional(),
106
91
  dashboardSlug: zod_1.z.string().optional(),
107
92
  },
108
- }, ({ goal, projectUuid, seedChartUuidOrSlug, dashboardSlug }) => userMessages(`Author a semantic chart for this goal:
93
+ }, ({ goal, projectUuid, seedChartUuidOrSlug, dashboardSlug }) => promptContext({
94
+ task: `Author a semantic chart for this goal:
109
95
 
110
96
  ${goal}
111
97
 
112
- Project UUID: ${projectUuid !== null && projectUuid !== void 0 ? projectUuid : PROJECT_UUID_HINT}.
98
+ ${(0, schema_fields_js_1.formatPromptProjectUuidLine)(projectUuid)}
113
99
  Seed chart: ${seedChartUuidOrSlug !== null && seedChartUuidOrSlug !== void 0 ? seedChartUuidOrSlug : '(find a rendering seed on the same tableName via search_content / get_space)'}.
114
100
  Dashboard slug: ${dashboardSlug !== null && dashboardSlug !== void 0 ? dashboardSlug : '(omit only for intentional space-owned charts; for dashboard work set dashboardSlug to an existing dashboard shell)'}.
115
101
 
116
- ${playbooks_js_1.CONTENT_DEVELOPER_HARD_BANS}
117
-
118
102
  Follow core + chart-types + table-calculations (clone via get_chart_as_code; preview with top-level slug; keep customDimensions when needed; tile if dashboardSlug set).
119
103
  When dashboardSlug is set, the chart must serve a **board insight** from the approved Design Spec — do not invent a viz type for its own sake.
120
- Report UUID/slug from charts[0].data; note this profile cannot run_chart / prove UI render.`, [TOPIC_CHART_TYPES, TOPIC_TABLE_CALCULATIONS]));
104
+ Report UUID/slug from charts[0].data; note this profile cannot run_chart / prove UI render.`,
105
+ invariantIds,
106
+ requiredTopics: [TOPIC_CHART_TYPES, TOPIC_TABLE_CALCULATIONS],
107
+ recoveryTopics: prompt_specs_js_1.WRITE_RECOVERY_TOPICS,
108
+ }));
121
109
  server.registerPrompt('move_content', {
122
110
  title: 'Move content',
123
111
  description: 'Move charts/dashboards into an existing space (no space create/update)',
124
112
  argsSchema: {
125
113
  goal: zod_1.z.string(),
126
- projectUuid: optionalProjectUuid,
114
+ projectUuid: (0, schema_fields_js_1.optionalProjectUuidField)(),
127
115
  spaceReferences: zod_1.z.string().optional(),
128
116
  },
129
- }, ({ goal, projectUuid, spaceReferences }) => userMessages(`Move content between existing spaces for this goal:
117
+ }, ({ goal, projectUuid, spaceReferences }) => promptContext({
118
+ task: `Move content between existing spaces for this goal:
130
119
 
131
120
  ${goal}
132
121
 
133
- Project UUID: ${projectUuid !== null && projectUuid !== void 0 ? projectUuid : PROJECT_UUID_HINT}.
134
-
135
- ${playbooks_js_1.CONTENT_DEVELOPER_HARD_BANS}
122
+ ${(0, schema_fields_js_1.formatPromptProjectUuidLine)(projectUuid)}
136
123
 
137
124
  Space hints: ${spaceReferences !== null && spaceReferences !== void 0 ? spaceReferences : '(discover with lightdash_list_spaces)'}.
138
125
  Follow core + content-move playbooks. Target spaces must already exist.
139
- Report moved items and target space.`, 'content-move'));
126
+ Report moved items and target space.`,
127
+ invariantIds,
128
+ requiredTopics: [TOPIC_CONTENT_MOVE],
129
+ recoveryTopics: prompt_specs_js_1.WRITE_RECOVERY_TOPICS,
130
+ }));
140
131
  server.registerPrompt('publish_content', {
141
132
  title: 'Publish content',
142
133
  description: 'Validate dashboard-scoped authored content before treating it as done',
143
134
  argsSchema: {
144
135
  contentReferences: zod_1.z.string(),
145
- projectUuid: optionalProjectUuid,
136
+ projectUuid: (0, schema_fields_js_1.optionalProjectUuidField)(),
146
137
  },
147
- }, ({ contentReferences, projectUuid }) => userMessages(`Finalize this authored Lightdash content before considering it done:
138
+ }, ({ contentReferences, projectUuid }) => promptContext({
139
+ task: `Finalize this authored Lightdash content before considering it done:
148
140
 
149
141
  ${contentReferences}
150
142
 
151
- Project UUID: ${projectUuid !== null && projectUuid !== void 0 ? projectUuid : PROJECT_UUID_HINT}.
152
-
153
- ${playbooks_js_1.CONTENT_DEVELOPER_HARD_BANS}
143
+ ${(0, schema_fields_js_1.formatPromptProjectUuidLine)(projectUuid)}
154
144
 
155
- Done checklist: markdown/description states the **Objective**; tiles map to approved insight questions; every saved filter matches each tile explore or has explicit tileTargets exclude/remap; dashboardSlug on new charts + tiles present; cartesian encode intact; no invented fieldIds. Report untiled dashboard-owned leftovers (soft-delete via content-governance). Follow embedded playbooks for encode/map/filter detail. UI runtime not verified on this profile.
156
- Optionally validate_* (schema/health only). Promote is content-governance, not this profile.`, DASHBOARD_PUBLISH_TOPIC_IDS));
145
+ Done checklist: markdown/description states the **Objective**; tiles map to approved insight questions; every saved filter matches each tile explore or has explicit tileTargets exclude/remap; dashboardSlug on new charts + tiles present; cartesian encode intact; no invented fieldIds. Report untiled dashboard-owned leftovers (soft-delete via content-governance). Follow playbooks for encode/map/filter detail. UI runtime not verified on this profile.
146
+ Optionally validate_* (schema/health only). Promote is content-governance, not this profile.`,
147
+ invariantIds,
148
+ requiredTopics: prompt_specs_js_1.DASHBOARD_PUBLISH_TOPIC_IDS,
149
+ recoveryTopics: prompt_specs_js_1.WRITE_RECOVERY_TOPICS,
150
+ }));
157
151
  }
158
152
  /* eslint-enable @typescript-eslint/no-deprecated */
@@ -38,7 +38,9 @@ var __importStar = (this && this.__importStar) || (function () {
38
38
  Object.defineProperty(exports, "__esModule", { value: true });
39
39
  const vitest_1 = require("vitest");
40
40
  const index_js_1 = require("../../index.js");
41
+ const playbook_resources_js_1 = require("../../lib/playbook-resources.js");
41
42
  const playbook_invariants_js_1 = require("../../test-support/playbook-invariants.js");
43
+ const invariants_js_1 = require("./invariants.js");
42
44
  const playbooks_js_1 = require("./resources/playbooks.js");
43
45
  (0, vitest_1.describe)('content-developer prompts/playbook', () => {
44
46
  (0, vitest_1.it)('playbooks reference only registered tool short ids', () => {
@@ -47,6 +49,20 @@ const playbooks_js_1 = require("./resources/playbooks.js");
47
49
  (0, vitest_1.expect)(md.toLowerCase()).toContain('hard bans');
48
50
  (0, vitest_1.expect)(playbooks_js_1.CONTENT_DEVELOPER_HARD_BANS.toLowerCase()).toContain('terraform');
49
51
  });
52
+ (0, vitest_1.it)('keeps structured invariants and core.md Hard bans in sync (count + key phrases)', () => {
53
+ var _a, _b;
54
+ const core = playbooks_js_1.CONTENT_DEVELOPER_CORE_PLAYBOOK.getMarkdown();
55
+ const hardBansSection = (_b = (_a = core.split('## Hard bans')[1]) === null || _a === void 0 ? void 0 : _a.split('\n## ')[0]) !== null && _b !== void 0 ? _b : '';
56
+ const coreBullets = hardBansSection
57
+ .split('\n')
58
+ .map((line) => line.trim())
59
+ .filter((line) => line.startsWith('- Do not'));
60
+ (0, vitest_1.expect)(coreBullets).toHaveLength(invariants_js_1.CONTENT_DEVELOPER_INVARIANTS.length);
61
+ (0, vitest_1.expect)(playbooks_js_1.CONTENT_DEVELOPER_HARD_BANS.toLowerCase()).toContain('resourcekind');
62
+ (0, vitest_1.expect)(playbooks_js_1.CONTENT_DEVELOPER_HARD_BANS.toLowerCase()).toContain('subagent-driven-development');
63
+ (0, vitest_1.expect)(hardBansSection.toLowerCase()).toContain('subagent-driven-development');
64
+ (0, vitest_1.expect)(hardBansSection.toLowerCase()).toContain('resourcekind');
65
+ });
50
66
  (0, vitest_1.it)('forbids space create/update and orphan chart publish', () => {
51
67
  const md = (0, playbooks_js_1.getAllPlaybookMarkdown)().toLowerCase();
52
68
  (0, vitest_1.expect)(md).toContain('terraform');
@@ -192,6 +208,7 @@ const playbooks_js_1 = require("./resources/playbooks.js");
192
208
  let authorText = '';
193
209
  let authorUris = [];
194
210
  let refactorText = '';
211
+ let createCompactText = '';
195
212
  const server = {
196
213
  registerPrompt: (name, _meta, handler) => {
197
214
  names.push(name);
@@ -241,7 +258,42 @@ const playbooks_js_1 = require("./resources/playbooks.js");
241
258
  }
242
259
  },
243
260
  };
244
- registerContentDeveloperPrompts(server);
261
+ // embedded keeps legacy resource URI assertions; compact is the package default.
262
+ registerContentDeveloperPrompts(server, { promptContextPolicy: 'embedded' });
263
+ const compactServer = {
264
+ registerPrompt: (name, _meta, handler) => {
265
+ if (name !== 'create_dashboard')
266
+ return;
267
+ const messages = handler({ goal: 'x' }).messages;
268
+ createCompactText = messages
269
+ .filter((m) => m.content.type === 'text')
270
+ .map((m) => { var _a; return (_a = m.content.text) !== null && _a !== void 0 ? _a : ''; })
271
+ .join('\n')
272
+ .toLowerCase();
273
+ (0, vitest_1.expect)(messages.every((m) => m.content.type === 'text')).toBe(true);
274
+ },
275
+ };
276
+ registerContentDeveloperPrompts(compactServer, { promptContextPolicy: 'compact' });
277
+ (0, vitest_1.expect)(createCompactText).toContain('critical invariants:');
278
+ (0, vitest_1.expect)(createCompactText).toContain('previewtoken');
279
+ (0, vitest_1.expect)(createCompactText).toContain((0, playbook_resources_js_1.playbookTopicUri)('content-developer', 'recovery/preview-stale'));
280
+ (0, vitest_1.expect)(createCompactText).not.toContain('## hard bans');
281
+ let moveCompactText = '';
282
+ const moveCompactServer = {
283
+ registerPrompt: (name, _meta, handler) => {
284
+ if (name !== 'move_content')
285
+ return;
286
+ const messages = handler({ goal: 'x' }).messages;
287
+ moveCompactText = messages
288
+ .filter((m) => m.content.type === 'text')
289
+ .map((m) => { var _a; return (_a = m.content.text) !== null && _a !== void 0 ? _a : ''; })
290
+ .join('\n')
291
+ .toLowerCase();
292
+ },
293
+ };
294
+ registerContentDeveloperPrompts(moveCompactServer, { promptContextPolicy: 'compact' });
295
+ (0, vitest_1.expect)(moveCompactText).toContain((0, playbook_resources_js_1.playbookTopicUri)('content-developer', 'recovery/preview-stale'));
296
+ (0, vitest_1.expect)(moveCompactText).toContain((0, playbook_resources_js_1.playbookTopicUri)('content-developer', 'recovery/preview-required'));
245
297
  (0, vitest_1.expect)(names).not.toContain('build_chart');
246
298
  (0, vitest_1.expect)(names).not.toContain('design_dashboard');
247
299
  (0, vitest_1.expect)(names).toContain('author_chart');
@@ -259,18 +311,20 @@ const playbooks_js_1 = require("./resources/playbooks.js");
259
311
  .toLowerCase();
260
312
  (0, vitest_1.expect)(text).toContain('design spec');
261
313
  (0, vitest_1.expect)(text).toMatch(/stop until the user proceeds|proceeds \/ approves/);
314
+ (0, vitest_1.expect)(text).toContain('critical invariants:');
315
+ (0, vitest_1.expect)(text).toContain('previewtoken');
262
316
  const uris = typed
263
317
  .filter((m) => m.content.type === 'resource')
264
318
  .map((m) => { var _a; return (_a = m.content.resource) === null || _a === void 0 ? void 0 : _a.uri; });
265
- (0, vitest_1.expect)(uris).toContain('lightdash://playbooks/content-developer/core');
266
- (0, vitest_1.expect)(uris).toContain('lightdash://playbooks/content-developer/dashboards');
267
- (0, vitest_1.expect)(uris).toContain('lightdash://playbooks/content-developer/dashboard-design');
319
+ (0, vitest_1.expect)(uris).toContain(playbooks_js_1.CONTENT_DEVELOPER_CORE_PLAYBOOK.uri);
320
+ (0, vitest_1.expect)(uris).toContain(playbooks_js_1.CONTENT_DEVELOPER_TOPIC_PLAYBOOKS.dashboards.uri);
321
+ (0, vitest_1.expect)(uris).toContain(playbooks_js_1.CONTENT_DEVELOPER_TOPIC_PLAYBOOKS['dashboard-design'].uri);
268
322
  if (name === 'create_dashboard' || name === 'improve_dashboard') {
269
323
  (0, vitest_1.expect)(text).toContain('objective');
270
324
  (0, vitest_1.expect)(text).toMatch(/clarif/);
271
325
  (0, vitest_1.expect)(text).toMatch(/only if the user explicitly asked/);
272
326
  (0, vitest_1.expect)(text).toMatch(/tablename|filter apply\/exclude|apply\/exclude/);
273
- (0, vitest_1.expect)(uris).toContain('lightdash://playbooks/content-developer/chart-types');
327
+ (0, vitest_1.expect)(uris).toContain(playbooks_js_1.CONTENT_DEVELOPER_TOPIC_PLAYBOOKS['chart-types'].uri);
274
328
  }
275
329
  if (name === 'improve_dashboard') {
276
330
  (0, vitest_1.expect)(text).toMatch(/keep \/ drop \/ rename|professionalize/);
@@ -285,8 +339,8 @@ const playbooks_js_1 = require("./resources/playbooks.js");
285
339
  (0, vitest_1.expect)(publishText).toContain('content-governance');
286
340
  (0, vitest_1.expect)(authorText).toContain('board insight');
287
341
  (0, vitest_1.expect)(authorText).toContain('table-calculations');
288
- (0, vitest_1.expect)(authorUris).toContain('lightdash://playbooks/content-developer/chart-types');
289
- (0, vitest_1.expect)(authorUris).toContain('lightdash://playbooks/content-developer/table-calculations');
342
+ (0, vitest_1.expect)(authorUris).toContain(playbooks_js_1.CONTENT_DEVELOPER_TOPIC_PLAYBOOKS['chart-types'].uri);
343
+ (0, vitest_1.expect)(authorUris).toContain(playbooks_js_1.CONTENT_DEVELOPER_TOPIC_PLAYBOOKS['table-calculations'].uri);
290
344
  (0, vitest_1.expect)(refactorText).toMatch(/approved spec|user request allows/);
291
345
  (0, vitest_1.expect)(refactorText).not.toMatch(/unless explicitly requested/);
292
346
  });
@@ -4,7 +4,7 @@ URI: `lightdash://playbooks/content-developer/chart-types`
4
4
 
5
5
  Pick a viz type to **answer an insight question** from the Design Spec Objective. The table below is a **reference map**, not a build order — do not walk every row unless the user explicitly asked for multi-viz / all chart types. Prefer **clone** (`get_chart_as_code` / `duplicate_chart`) over inventing viz configs. Docs: [overview](https://docs.lightdash.com/references/chart-types/overview).
6
6
 
7
- When the insight needs period-over-period, % of total, rank, or running/rolling windows, append `metricQuery.tableCalculations` per `lightdash://playbooks/content-developer/table-calculations` (do not freestyle warehouse `OVER()` SQL).
7
+ When the insight needs period-over-period, % of total, rank, or running/rolling windows: prefer cloned native PoP metrics (`generationType: periodOverPeriod`) from the seed; otherwise append `metricQuery.tableCalculations` per `lightdash://playbooks/content-developer/table-calculations` (do not freestyle warehouse `OVER()` SQL). See [period-over-period](https://docs.lightdash.com/guides/period-over-period).
8
8
 
9
9
  When the user **does** ask for all types: follow dashboards **Multi-viz batch SOP** (shell → ≤2 concurrent chart creates → one tile update), split the board into a decision-oriented section plus a visualization-validation appendix (see `dashboards` / `dashboard-design`), and check every candidate type against the **semantic fit gate** below before adding it.
10
10
 
@@ -133,6 +133,7 @@ chartConfig:
133
133
  - Clone `chartConfig` from a rendering seed on the same `tableName`; change series `type` / top-level type only when needed.
134
134
  - FieldIds only from seed / `get_chart` / semantic-layer — never invent. this profile has **no** explore/field list tools.
135
135
  - Field IDs shown in the YAML examples below (e.g. `orders_status`) are **illustrative**, not guaranteed to exist on any given explore — verify against a seed via `get_chart_as_code` (or `get_chart`) before use.
136
+ - **Custom fields & tooltips (clone-only):** preserve `metricQuery.customDimensions` and cartesian `eChartsConfig.tooltip` from the seed ([custom fields](https://docs.lightdash.com/guides/custom-fields), [custom tooltips](https://docs.lightdash.com/guides/custom-tooltip)). Do not invent new custom SQL dimensions or freestyle tooltip field names. Metrics reused across boards belong in dbt / semantic-layer, not chart-local custom metrics.
136
137
  - When cloning charts that use SQL/bin custom dims (e.g. coupon flags), copy `metricQuery.customDimensions` verbatim.
137
138
  - Every `metricQuery.dimensions` entry must appear in viz layout / group / sankey source-target / pivot — unused dimensions corrupt GROUP BY (“Results may be incorrect”). **Exception:** a scatter with two metric axes legitimately keeps its grain dimension (e.g. customer id) in `metricQuery.dimensions` to produce one row per entity — `validate_chart` will still flag it as "unused" because the validator only recognizes x/y-axis or group-by references, not grain-only dimensions. That warning is expected on a correct two-metric scatter; do not drop the dimension to silence it.
138
139
  - For dashboard work set `dashboardSlug` **and** tile via `update_dashboard` (ownership alone does not place tiles).
@@ -23,11 +23,13 @@ this profile does **not** execute queries, compile explores, create spaces, or p
23
23
  - Do not treat chart create as done without a dashboard shell and tiles that reference those charts.
24
24
  - Do not invent `fieldId`s. Copy from `get_chart_as_code` / `get_chart` (`includeQueryDefinition`) or semantic-layer.
25
25
  - Do not invent skinny `chartConfig` (e.g. `{ series: [{ type: 'bar' }] }` only) — clone a working as-code body and keep series/layout/encode structure.
26
+ - Do not set chart `verified` or dashboard `preserveVerification` unless the user explicitly asks (requires verify permission; edits can drop the badge — [verified content](https://docs.lightdash.com/guides/verified-content)).
26
27
  - Do not call a write tool without a validated, unexpired HMAC `previewToken` from the matching `preview_*` then `confirm_preview`.
27
28
  - Do not mutate the proposed payload after `preview_*` (no edits to `description`, `name`, SQL, metrics, tiles, or other fields between preview and apply) — apply must reuse the **identical proposed** body or you get `PREVIEW_STALE` (content hash mismatch). Any intentional edit requires a new `preview_*`.
28
29
  - Do not reuse a **draft** token after confirm (confirm returns a **new** validated token) or after payload/baseline drift (`PREVIEW_STALE`).
29
30
  - Do not unlock with a different resource's preview — `resourceKind` / `resourceKey` must match the preview exactly.
30
31
  - Do not treat `validate_chart` / `validate_dashboard` as unlock — saved-UUID health checks only (not UI-render proof).
32
+ - Do not use subagent-driven-development or multi-task writing-plans solely to click MCP preview/confirm/apply for lab boards (e.g. experiments) — after Design Spec approval, run Batch SOP inline in the same session.
31
33
  - Do not reveal secrets, warehouse credentials, or saved SQL **chart** bodies.
32
34
 
33
35
  ## Default budgets (override when the user expands scope)
@@ -107,4 +109,4 @@ Record when a budget stopped you. User-requested “one of every chart type” o
107
109
  - Tile shape: `{ type: 'saved_chart', x, y, w, h, properties: { savedChartUuid, title? } }` — use the UUID from `create_chart` / `duplicate_chart` (36-column grid; half-width ≈ `w: 18`). Optional `chartSlug` is metadata only; do not omit `savedChartUuid`.
108
110
  - `create_chart` response: extract UUID from `charts[0].data.uuid` (not a bare chart object).
109
111
  - Viz shapes: `lightdash://playbooks/content-developer/chart-types`.
110
- - PoP / % of total / rank / running or rolling windows on `metricQuery.tableCalculations`: `lightdash://playbooks/content-developer/table-calculations`.
112
+ - PoP: prefer cloned `generationType: periodOverPeriod` metrics; else % of total / rank / windows via `lightdash://playbooks/content-developer/table-calculations`.
@@ -79,7 +79,7 @@ Skip fancy HTML/iframe unless the user asks. Loom / heading tiles: only if reque
79
79
 
80
80
  ## Filters (optional)
81
81
 
82
- 0–3 shared **dimensions**. Prefer **one explore** for all tiles that share dashboard filters. Filters guide: [Using filters](https://docs.lightdash.com/guides/limiting-data-using-filters). Official as-code targeting: [dashboard-reference `tileTargets`](https://github.com/lightdash/lightdash/blob/main/skills/developing-in-lightdash/resources/dashboard-reference.md).
82
+ 0–3 shared **dimensions**. Prefer **one explore** for all tiles that share dashboard filters. Filters guide: [Using filters](https://docs.lightdash.com/guides/limiting-data-using-filters). Operator catalog (date windows, `is not` + NULL, etc.): [Filters reference](https://docs.lightdash.com/guides/filters). Official as-code targeting: [dashboard-reference `tileTargets`](https://github.com/lightdash/lightdash/blob/main/skills/developing-in-lightdash/resources/dashboard-reference.md).
83
83
 
84
84
  - Prefer **empty-value** saved filters so viewers choose ([saved filters](https://docs.lightdash.com/guides/limiting-data-using-filters#adding-saved-filters-to-your-dashboard)).
85
85
  - Prefer **clone** `filters` from `get_dashboard` on a working board over inventing rules.
@@ -138,6 +138,16 @@ filters:
138
138
 
139
139
  **Apply order:** compose tiles first → if excluding, `get_dashboard` for tile UUIDs → then `preview_dashboard_changes` → `confirm_preview` → `update_dashboard({ dashboard: { filters, tiles?, name?, … } })` (second update is fine when UUIDs were not known on first tile write).
140
140
 
141
+ ## Date zoom (optional)
142
+
143
+ When the Objective needs viewers to change time granularity without editing charts ([date zoom](https://docs.lightdash.com/guides/date-zoom)):
144
+
145
+ 1. Plan in the Design Spec (Default zoom + any named controls; which tiles attach).
146
+ 2. **Clone** dashboard `config` (`dateZoomConfig`, `defaultDateZoomGranularity`, `dateZoomGranularities`, `isDateZoomDisabled`) from a working board via `get_dashboard` — do not invent tile↔field bindings.
147
+ 3. Attach only charts that have a zoomable date/timestamp dimension in results; a chart with no date field cannot join a control.
148
+ 4. Optional labels: `${table_field.granularity}` in axis / big-value labels when cloning charts that already use it.
149
+ 5. Viewer zoom is temporary in the UI; saved defaults live on the dashboard `config` you upsert.
150
+
141
151
  ## Tabs
142
152
 
143
153
  Default: **no tabs**. Use only for themes / audiences / 30+ tiles ([docs tip](https://docs.lightdash.com/get-started/exploring-data/dashboards#add-tabs)).
@@ -19,7 +19,7 @@ get_project → list_spaces → discover seeds (read-only)
19
19
  1. `list_spaces` → existing `spaceUuid` (dashboards) / `spaceSlug` (chart as-code).
20
20
  2. `search_content` with **short** tokens (`orders`, space slug). Multi-word brand phrases often return empty — use `get_space`. Short tokens can also return noisy org-wide hits — prefer `get_space` inventory for seeds.
21
21
  3. Prefer **reuse** of existing charts as tiles when they already fit.
22
- 4. For new charts: find a **working seed** on the same `tableName`; never invent fieldIds.
22
+ 4. For new charts: find a **working seed** on the same `tableName`; never invent fieldIds. For PoP, prefer seeds with `generationType: periodOverPeriod` metrics (see table-calculations).
23
23
  5. Dashboard-owned charts (`dashboardSlug` set) **do not** appear as independent space charts in `get_space` / typical search — keep the UUIDs you create, or re-open the dashboard.
24
24
 
25
25
  ## Create dashboard shell (step 1 — after Design Spec approval)