rivet-design 0.8.7 → 0.9.2

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 (96) hide show
  1. package/bin/rivet.js +11 -0
  2. package/dist/config/evaluateFlags.d.ts +6 -2
  3. package/dist/config/evaluateFlags.d.ts.map +1 -1
  4. package/dist/config/evaluateFlags.js +4 -4
  5. package/dist/config/evaluateFlags.js.map +1 -1
  6. package/dist/config/featureFlagUserKey.d.ts +11 -0
  7. package/dist/config/featureFlagUserKey.d.ts.map +1 -0
  8. package/dist/config/featureFlagUserKey.js +21 -0
  9. package/dist/config/featureFlagUserKey.js.map +1 -0
  10. package/dist/config/flags.d.ts +6 -0
  11. package/dist/config/flags.d.ts.map +1 -1
  12. package/dist/config/flags.js +2 -0
  13. package/dist/config/flags.js.map +1 -1
  14. package/dist/index.js +198 -12
  15. package/dist/index.js.map +1 -1
  16. package/dist/mcp/agent-variants/SessionStore.d.ts +121 -0
  17. package/dist/mcp/agent-variants/SessionStore.d.ts.map +1 -0
  18. package/dist/mcp/agent-variants/SessionStore.js +480 -0
  19. package/dist/mcp/agent-variants/SessionStore.js.map +1 -0
  20. package/dist/mcp/agent-variants/WorktreeOrchestrator.d.ts +187 -0
  21. package/dist/mcp/agent-variants/WorktreeOrchestrator.d.ts.map +1 -0
  22. package/dist/mcp/agent-variants/WorktreeOrchestrator.js +482 -0
  23. package/dist/mcp/agent-variants/WorktreeOrchestrator.js.map +1 -0
  24. package/dist/mcp/agent-variants/contracts.d.ts +373 -0
  25. package/dist/mcp/agent-variants/contracts.d.ts.map +1 -0
  26. package/dist/mcp/agent-variants/contracts.js +134 -0
  27. package/dist/mcp/agent-variants/contracts.js.map +1 -0
  28. package/dist/mcp/agent-variants/errors.d.ts +8 -0
  29. package/dist/mcp/agent-variants/errors.d.ts.map +1 -0
  30. package/dist/mcp/agent-variants/errors.js +30 -0
  31. package/dist/mcp/agent-variants/errors.js.map +1 -0
  32. package/dist/mcp/agent-variants/index.d.ts +11 -0
  33. package/dist/mcp/agent-variants/index.d.ts.map +1 -0
  34. package/dist/mcp/agent-variants/index.js +15 -0
  35. package/dist/mcp/agent-variants/index.js.map +1 -0
  36. package/dist/mcp/agent-variants/pendingChangesAdapter.d.ts +38 -0
  37. package/dist/mcp/agent-variants/pendingChangesAdapter.d.ts.map +1 -0
  38. package/dist/mcp/agent-variants/pendingChangesAdapter.js +79 -0
  39. package/dist/mcp/agent-variants/pendingChangesAdapter.js.map +1 -0
  40. package/dist/mcp/agent-variants/tools.d.ts +8 -0
  41. package/dist/mcp/agent-variants/tools.d.ts.map +1 -0
  42. package/dist/mcp/agent-variants/tools.js +221 -0
  43. package/dist/mcp/agent-variants/tools.js.map +1 -0
  44. package/dist/mcp/server.d.ts.map +1 -1
  45. package/dist/mcp/server.js +51 -34
  46. package/dist/mcp/server.js.map +1 -1
  47. package/dist/proxy-middleware/proxy-config.d.ts +4 -1
  48. package/dist/proxy-middleware/proxy-config.d.ts.map +1 -1
  49. package/dist/proxy-middleware/proxy-config.js +34 -5
  50. package/dist/proxy-middleware/proxy-config.js.map +1 -1
  51. package/dist/routes/agentVariants.d.ts +16 -0
  52. package/dist/routes/agentVariants.d.ts.map +1 -0
  53. package/dist/routes/agentVariants.js +234 -0
  54. package/dist/routes/agentVariants.js.map +1 -0
  55. package/dist/server.d.ts +3 -0
  56. package/dist/server.d.ts.map +1 -1
  57. package/dist/server.js +24 -8
  58. package/dist/server.js.map +1 -1
  59. package/dist/services/FeatureFlagService.d.ts +9 -5
  60. package/dist/services/FeatureFlagService.d.ts.map +1 -1
  61. package/dist/services/FeatureFlagService.js +16 -7
  62. package/dist/services/FeatureFlagService.js.map +1 -1
  63. package/dist/services/SessionBridgeService.d.ts +22 -0
  64. package/dist/services/SessionBridgeService.d.ts.map +1 -1
  65. package/dist/services/SessionBridgeService.js +58 -1
  66. package/dist/services/SessionBridgeService.js.map +1 -1
  67. package/dist/services/TelemetryService.d.ts.map +1 -1
  68. package/dist/services/TelemetryService.js +6 -1
  69. package/dist/services/TelemetryService.js.map +1 -1
  70. package/dist/services/WorktreeManager.d.ts +42 -3
  71. package/dist/services/WorktreeManager.d.ts.map +1 -1
  72. package/dist/services/WorktreeManager.js +149 -6
  73. package/dist/services/WorktreeManager.js.map +1 -1
  74. package/dist/types/change-request-types.d.ts +36 -1
  75. package/dist/types/change-request-types.d.ts.map +1 -1
  76. package/dist/utils/devServerCommand.d.ts +19 -0
  77. package/dist/utils/devServerCommand.d.ts.map +1 -0
  78. package/dist/utils/devServerCommand.js +38 -0
  79. package/dist/utils/devServerCommand.js.map +1 -0
  80. package/dist/utils/skills/claude-skill.d.ts +2 -2
  81. package/dist/utils/skills/claude-skill.d.ts.map +1 -1
  82. package/dist/utils/skills/claude-skill.js +87 -4
  83. package/dist/utils/skills/claude-skill.js.map +1 -1
  84. package/dist/utils/skills/cursor-rules.d.ts +2 -2
  85. package/dist/utils/skills/cursor-rules.d.ts.map +1 -1
  86. package/dist/utils/skills/cursor-rules.js +87 -4
  87. package/dist/utils/skills/cursor-rules.js.map +1 -1
  88. package/dist/utils/variantPreviewPort.d.ts +18 -0
  89. package/dist/utils/variantPreviewPort.d.ts.map +1 -0
  90. package/dist/utils/variantPreviewPort.js +28 -0
  91. package/dist/utils/variantPreviewPort.js.map +1 -0
  92. package/package.json +1 -1
  93. package/src/ui/dist/assets/{main-HqOyJspz.js → main-AsPCtLsx.js} +119 -119
  94. package/src/ui/dist/assets/main-BzmseUDd.css +1 -0
  95. package/src/ui/dist/index.html +2 -2
  96. package/src/ui/dist/assets/main-DytMB3Wi.css +0 -1
@@ -1,20 +1,31 @@
1
1
  "use strict";
2
2
  Object.defineProperty(exports, "__esModule", { value: true });
3
3
  exports.CURSOR_RULES_CONTENT = exports.CURSOR_RULES_FILENAME = exports.CURSOR_RULES_VERSION = void 0;
4
- exports.CURSOR_RULES_VERSION = 7;
4
+ exports.CURSOR_RULES_VERSION = 12;
5
5
  exports.CURSOR_RULES_FILENAME = 'rivet.mdc';
6
6
  const CURSOR_RULES_VERSION_MARKER = `rivet-rules-version: ${exports.CURSOR_RULES_VERSION}`;
7
7
  exports.CURSOR_RULES_CONTENT = `---
8
- description: Rivet visual editor — apply when the user says "open rivet", "open the visual editor", or wants to make visual/UI changes to their web app
8
+ description: Rivet — apply when the user says "open rivet", "open the visual editor", "create variants", "show me options for X", "build me X from scratch", "create a new Y app", or wants to make visual/UI changes or explore design directions
9
9
  alwaysApply: false
10
10
  ---
11
11
  <!-- ${CURSOR_RULES_VERSION_MARKER} -->
12
- # Rivet Visual Editor
12
+ # Rivet
13
13
 
14
- Use these tools to make visual changes to a running web app and apply them to source code.
14
+ Two flows: the **visual editor** (point-and-click changes to a running web app) and the **agent-variants flow** (explore N parallel design directions before committing).
15
15
 
16
16
  > Tip: type \`@rivet.mdc\` in chat to invoke this rule manually.
17
17
 
18
+ ## Picking the flow
19
+
20
+ | User says | Flow |
21
+ |---|---|
22
+ | "open rivet", "make a visual change to X" | **Visual editor** (below) |
23
+ | "create variants of X", "show me 3-5 options for X", "explore approaches to X" | **Agent variants** |
24
+ | "build me a settings page from scratch", "add a feature for Y" | **Agent variants** (no \`target\`) |
25
+ | "create a new Vite todo app", "scaffold a Next.js dashboard" | **Agent variants** (\`projectContext.kind=fresh\`) |
26
+
27
+ ## Visual Editor flow
28
+
18
29
  ## Starting a session
19
30
 
20
31
  1. Call \`detect_project\` — returns project info including \`framework\` and \`projectPath\`
@@ -44,5 +55,77 @@ When the user says they're done, call \`close_visual_editor({ sessionId })\`.
44
55
  - **Never auto-commit** after applying visual changes — let the user decide
45
56
  - Always stop and ask before re-entering the watch loop
46
57
  - The dev server stays running after \`close_visual_editor\`
58
+
59
+ ---
60
+
61
+ ## Agent Variants flow
62
+
63
+ For requests like *"create variants of X"*, *"show me 3-5 options for the dropdown"*, *"build me a settings page"*, or *"create a new Vite todo app"* — DO NOT generate variants natively via parallel tool calls. Use this protocol so the user reviews design directions in chat, sees the actual code variants render in parallel, and picks based on the rendered code.
64
+
65
+ ### Step-by-step
66
+
67
+ 1. **Call \`propose_variants\`** with:
68
+ - \`prompt\`: the user's request verbatim
69
+ - \`count\`: 3-5 (default 4)
70
+ - \`target\` (optional): \`{ type: 'element'|'file'|'route', ref }\` — set this for refinement requests pinned to a specific element/file/route
71
+ - \`projectContext\` (optional):
72
+ - For brand-new projects: \`{ kind: 'fresh', workspacePath: '/abs/path', framework: 'vite'|'next'|'astro'|'remix' }\`
73
+ - Otherwise omit (defaults to existing project)
74
+
75
+ Response: \`{ sessionId, briefWorkItem }\`. The brief work item carries an \`input\` blob; you must run it next.
76
+
77
+ 2. **Run the brief work item using YOUR own LLM** — generate \`count\` design briefs as \`{ briefId, label, body }\`. Label is short (≤ 4 words). Body is 1-2 sentences describing the design direction. Do NOT call any Rivet tool; this is your LLM doing creative work.
78
+
79
+ 3. **Call \`report_variant_briefs\`** with the briefs, plus the \`workItemId\` and \`attempt: 0\`.
80
+
81
+ 3.5. **Ensure the Rivet visual editor is open.** If you haven't already opened it in this session, call \`detect_project\` then \`open_visual_editor({ projectPath, framework })\` now — DON'T wait for the user to ask. The user will need the iframe open to see variants render. If a session is already active (\`open_visual_editor\` returns a friendly error), just continue. Once the editor opens, the chip at the bottom-center of the iframe will show generation progress.
82
+
83
+ 4. **Show the briefs to the user IN CHAT** as a numbered list. Ask "Look good or want me to adjust any of them?" — DO NOT ask which one to pick. The pick happens AFTER they've seen the actual code.
84
+ Example:
85
+ > Here are 4 directions:
86
+ > 1. **Spring blur** — Apple-style spring with ambient blur and soft edges
87
+ > 2. **Linear sharp** — Crisp, fast, minimal padding
88
+ > 3. **Notion soft** — Rounded, calm, neutral palette
89
+ > 4. **Monoline editorial** — Tight typography, single accent color
90
+ > Look good, or want me to adjust any of them?
91
+
92
+ 5. **Wait for the user's reply.** Affirmative ("looks good", "go", "yep") → proceed with all briefs. Tweak request ("make #2 feel more like Linear") → call \`approve_variant_briefs\` with \`selections\` containing \`bodyOverride\` per brief, OR re-run the brief work item with new framing. Reject all → call \`cancel_variants\` and start over.
93
+
94
+ 6. **Call \`approve_variant_briefs({ sessionId, briefIds: [all chosen briefs] })\`**. Response: \`{ stage: 'work_items_ready', codeGenWorkItemIds: [...] }\` — one work item per approved brief.
95
+
96
+ 7. **Lease the work** with \`continue_variants({ sessionId, action: 'request_work' })\`. Response has \`leaseId\`, \`leaseTtlMs\`, and \`leasedWorkItems[]\` — one per approved brief (plus a preceding \`scaffold_base\` for fresh-project; lease scaffold first, succeed it, then re-lease for the code-gens).
97
+
98
+ 8. **Run all leased code-gen items IN PARALLEL** via parallel tool calls in a single response. For each:
99
+ - Read \`input.briefBody\` and \`input.target\`
100
+ - Edit files in \`input.worktreePath\` (each variant has its own isolated worktree)
101
+ - Call \`report_variant_complete({ sessionId, workItemId, leaseId, attempt, status: 'succeeded' })\`. On failure, status \`'failed'\` with error description.
102
+
103
+ 9. **When all variants are done (\`stage: 'ready'\` or \`'degraded'\`), tell the user the variants are ready and explain how to compare them.** Each variant has its own dev server running in an isolated worktree. The Rivet iframe shows a chip at the bottom-center: prev/label/next/check/dismiss. The user cycles between the live, running variants by clicking prev/next (the iframe re-mounts onto the variant's dev server in ~50ms via proxy retarget). When they like one, they click the check on the chip — that commits the variant.
104
+ Example reply:
105
+ > Variants are ready — open the Rivet preview and use the chip at the bottom of the iframe to cycle between them. Click the checkmark on the one you want and I'll apply it.
106
+
107
+ You do NOT need to print diffs in chat. The user picks visually in the iframe.
108
+
109
+ 10. **Watch for the user's pick.** Either:
110
+ a) Use \`watch_for_changes({ sessionId })\` (existing tool) which blocks until the user clicks the check on the chip, OR
111
+ b) Poll \`get_pending_changes({ sessionId })\` periodically.
112
+ When \`hasChanges: true\`, you'll see a \`VariantChangeItem\` in \`changes[]\`.
113
+
114
+ 11. **Apply the variant.** From the \`VariantChangeItem\` payload:
115
+ - \`payload.kind === 'diff'\` → \`git apply\` the unified diff against the user's project root
116
+ - \`payload.kind === 'new-project'\` → copy the contents of \`payload.sourceWorktreePath\` to \`destinationPath\`
117
+ Tell the user which variant you applied (use \`variantLabel\` from the change item).
118
+
119
+ You can also call \`commit_variant({ sessionId, variantId })\` yourself if the user expressed their pick in chat instead of clicking the chip ("go with #2", "the spring one") — same effect, just routed through the agent rather than the chip.
120
+
121
+ ### Rules
122
+
123
+ - **Never** generate variants natively (Task tool, parallel tool calls, your own creative process) without going through \`propose_variants\` first.
124
+ - Always pass the user's prompt verbatim — don't paraphrase.
125
+ - Briefs are shown as PLAIN TEXT in chat. Do not render UI, open a browser tab, or fabricate a URL.
126
+ - The user picks AFTER seeing the variants render LIVE in the iframe, not before. Step 4 is "look good or adjust the briefs?"; step 9 hands off to the iframe chip for visual cycling + commit.
127
+ - Don't dump diffs in chat by default. The iframe chip is the primary review surface. If the user explicitly asks "show me the diffs", then print them.
128
+ - Step 8 (parallel code-gen) is the only step where you fan out — every other step is one tool call.
129
+ - For fresh-project, \`scaffold_base\` runs first; only after it succeeds are the \`code_gen\` items leasable. Loop \`continue_variants(action='request_work')\` after each transition.
47
130
  `;
48
131
  //# sourceMappingURL=cursor-rules.js.map
@@ -1 +1 @@
1
- {"version":3,"file":"cursor-rules.js","sourceRoot":"","sources":["../../../src/utils/skills/cursor-rules.ts"],"names":[],"mappings":";;;AAAa,QAAA,oBAAoB,GAAG,CAAC,CAAC;AACzB,QAAA,qBAAqB,GAAG,WAAW,CAAC;AACjD,MAAM,2BAA2B,GAAG,wBAAwB,4BAAoB,EAAE,CAAC;AAEtE,QAAA,oBAAoB,GAAG;;;;OAI7B,2BAA2B;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;CAoCjC,CAAC"}
1
+ {"version":3,"file":"cursor-rules.js","sourceRoot":"","sources":["../../../src/utils/skills/cursor-rules.ts"],"names":[],"mappings":";;;AAAa,QAAA,oBAAoB,GAAG,EAAE,CAAC;AAC1B,QAAA,qBAAqB,GAAG,WAAW,CAAC;AACjD,MAAM,2BAA2B,GAAG,wBAAwB,4BAAoB,EAAE,CAAC;AAEtE,QAAA,oBAAoB,GAAG;;;;OAI7B,2BAA2B;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;CAuHjC,CAAC"}
@@ -0,0 +1,18 @@
1
+ export type PreviewPortResolution = {
2
+ ok: true;
3
+ port: number | null;
4
+ } | {
5
+ ok: false;
6
+ status: number;
7
+ error: string;
8
+ };
9
+ type VariantPreviewSessionGate = {
10
+ isActive(): boolean;
11
+ isVariantPortAllowed(port: number): boolean;
12
+ };
13
+ /**
14
+ * Validate a requested preview port against the active MCP variant session.
15
+ */
16
+ export declare const resolveVariantPreviewPort: (rawPort: unknown, sessionGate: VariantPreviewSessionGate) => PreviewPortResolution;
17
+ export {};
18
+ //# sourceMappingURL=variantPreviewPort.d.ts.map
@@ -0,0 +1 @@
1
+ {"version":3,"file":"variantPreviewPort.d.ts","sourceRoot":"","sources":["../../src/utils/variantPreviewPort.ts"],"names":[],"mappings":"AAAA,MAAM,MAAM,qBAAqB,GAC7B;IAAE,EAAE,EAAE,IAAI,CAAC;IAAC,IAAI,EAAE,MAAM,GAAG,IAAI,CAAA;CAAE,GACjC;IAAE,EAAE,EAAE,KAAK,CAAC;IAAC,MAAM,EAAE,MAAM,CAAC;IAAC,KAAK,EAAE,MAAM,CAAA;CAAE,CAAC;AAEjD,KAAK,yBAAyB,GAAG;IAC/B,QAAQ,IAAI,OAAO,CAAC;IACpB,oBAAoB,CAAC,IAAI,EAAE,MAAM,GAAG,OAAO,CAAC;CAC7C,CAAC;AAEF;;GAEG;AACH,eAAO,MAAM,yBAAyB,GACpC,SAAS,OAAO,EAChB,aAAa,yBAAyB,KACrC,qBAmBF,CAAC"}
@@ -0,0 +1,28 @@
1
+ "use strict";
2
+ Object.defineProperty(exports, "__esModule", { value: true });
3
+ exports.resolveVariantPreviewPort = void 0;
4
+ /**
5
+ * Validate a requested preview port against the active MCP variant session.
6
+ */
7
+ const resolveVariantPreviewPort = (rawPort, sessionGate) => {
8
+ if (rawPort === null || rawPort === undefined) {
9
+ return { ok: true, port: null };
10
+ }
11
+ if (!Number.isInteger(rawPort) || rawPort <= 0) {
12
+ return { ok: false, status: 400, error: 'Invalid preview port' };
13
+ }
14
+ if (!sessionGate.isActive()) {
15
+ return { ok: false, status: 400, error: 'No active MCP session' };
16
+ }
17
+ const port = rawPort;
18
+ if (!sessionGate.isVariantPortAllowed(port)) {
19
+ return {
20
+ ok: false,
21
+ status: 403,
22
+ error: `Preview port ${port} is not registered for this variant session`,
23
+ };
24
+ }
25
+ return { ok: true, port };
26
+ };
27
+ exports.resolveVariantPreviewPort = resolveVariantPreviewPort;
28
+ //# sourceMappingURL=variantPreviewPort.js.map
@@ -0,0 +1 @@
1
+ {"version":3,"file":"variantPreviewPort.js","sourceRoot":"","sources":["../../src/utils/variantPreviewPort.ts"],"names":[],"mappings":";;;AASA;;GAEG;AACI,MAAM,yBAAyB,GAAG,CACvC,OAAgB,EAChB,WAAsC,EACf,EAAE;IACzB,IAAI,OAAO,KAAK,IAAI,IAAI,OAAO,KAAK,SAAS,EAAE,CAAC;QAC9C,OAAO,EAAE,EAAE,EAAE,IAAI,EAAE,IAAI,EAAE,IAAI,EAAE,CAAC;IAClC,CAAC;IACD,IAAI,CAAC,MAAM,CAAC,SAAS,CAAC,OAAO,CAAC,IAAK,OAAkB,IAAI,CAAC,EAAE,CAAC;QAC3D,OAAO,EAAE,EAAE,EAAE,KAAK,EAAE,MAAM,EAAE,GAAG,EAAE,KAAK,EAAE,sBAAsB,EAAE,CAAC;IACnE,CAAC;IACD,IAAI,CAAC,WAAW,CAAC,QAAQ,EAAE,EAAE,CAAC;QAC5B,OAAO,EAAE,EAAE,EAAE,KAAK,EAAE,MAAM,EAAE,GAAG,EAAE,KAAK,EAAE,uBAAuB,EAAE,CAAC;IACpE,CAAC;IACD,MAAM,IAAI,GAAG,OAAiB,CAAC;IAC/B,IAAI,CAAC,WAAW,CAAC,oBAAoB,CAAC,IAAI,CAAC,EAAE,CAAC;QAC5C,OAAO;YACL,EAAE,EAAE,KAAK;YACT,MAAM,EAAE,GAAG;YACX,KAAK,EAAE,gBAAgB,IAAI,6CAA6C;SACzE,CAAC;IACJ,CAAC;IACD,OAAO,EAAE,EAAE,EAAE,IAAI,EAAE,IAAI,EAAE,CAAC;AAC5B,CAAC,CAAC;AAtBW,QAAA,yBAAyB,6BAsBpC"}
package/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "rivet-design",
3
- "version": "0.8.7",
3
+ "version": "0.9.2",
4
4
  "description": "Local visual web development tool with AI-powered code modification",
5
5
  "main": "dist/index.js",
6
6
  "workspaces": [