rivet-design 0.27.0 → 0.27.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.
- package/dist/agent-variants/DirectionRefReservations.d.ts +11 -0
- package/dist/agent-variants/DirectionRefReservations.js +47 -0
- package/dist/agent-variants/SessionStore.d.ts +10 -1
- package/dist/agent-variants/SessionStore.js +25 -2
- package/dist/agent-variants/WorkItemRequestTimes.d.ts +6 -0
- package/dist/agent-variants/WorkItemRequestTimes.js +21 -0
- package/dist/agent-variants/WorktreeOrchestrator.d.ts +2 -1
- package/dist/agent-variants/WorktreeOrchestrator.js +92 -78
- package/dist/agent-variants/contracts.d.ts +4 -0
- package/dist/agent-variants/existingStaticEntry.d.ts +34 -0
- package/dist/agent-variants/existingStaticEntry.js +136 -0
- package/dist/agent-variants/staticPreviewFiles.js +1 -1
- package/dist/agent-variants/variant-project-runtime.d.ts +2 -1
- package/dist/agent-variants/variantsTelemetry.d.ts +4 -0
- package/dist/agent-variants/variantsTelemetry.js +2 -0
- package/dist/agent-variants/workItemInput.d.ts +22 -0
- package/dist/agent-variants/workItemInput.js +12 -1
- package/dist/cli/commands/directionTarget.d.ts +23 -0
- package/dist/cli/commands/directionTarget.js +87 -0
- package/dist/cli/commands/open.js +28 -4
- package/dist/cli/commands/variants.js +36 -43
- package/dist/cli/envelope.d.ts +1 -1
- package/dist/cli/envelope.js +1 -0
- package/dist/cli/projectRuntimeUpgrade.d.ts +11 -0
- package/dist/cli/projectRuntimeUpgrade.js +43 -11
- package/dist/config/pluginMetrics.js +2 -0
- package/dist/mcp/explorationSchema.js +1 -1
- package/dist/mcp/getExploration.js +11 -5
- package/dist/proxy-middleware/proxy-config.js +7 -0
- package/dist/routes/agentVariants.js +4 -0
- package/dist/routes/cli.js +10 -1
- package/dist/server.js +12 -6
- package/dist/services/ProjectLibrary.d.ts +4 -1
- package/dist/services/ProjectLibrary.js +14 -9
- package/dist/services/ProjectRuntimeService.d.ts +8 -0
- package/dist/services/ProjectRuntimeService.js +15 -2
- package/dist/services/TelemetryService.d.ts +5 -0
- package/dist/services/TelemetryService.js +19 -0
- package/dist/services/VariantHistoryService.d.ts +8 -0
- package/dist/services/VariantHistoryService.js +40 -0
- package/dist/services/WorktreeManager.d.ts +1 -0
- package/dist/services/WorktreeManager.js +12 -0
- package/dist/services/createAgentVariantsOrchestrator.js +9 -2
- package/dist/services/directionRefs.d.ts +21 -0
- package/dist/services/directionRefs.js +148 -0
- package/dist/services/projectDirections.d.ts +22 -0
- package/dist/services/projectDirections.js +38 -0
- package/dist/types/direction-ref.d.ts +36 -0
- package/dist/types/direction-ref.js +3 -0
- package/dist/types/variant-history.d.ts +3 -1
- package/dist/utils/skills/cli-guidance.js +4 -3
- package/dist/utils/subprocessEnvironment.d.ts +1 -1
- package/dist/utils/subprocessEnvironment.js +0 -1
- package/package.json +3 -3
- package/src/ui/dist/assets/LibraryEntry-BZ5EdFgA.js +37 -0
- package/src/ui/dist/assets/main-MepMmTwb.css +1 -0
- package/src/ui/dist/assets/main-RriU35pI.js +497 -0
- package/src/ui/dist/index.html +2 -2
- package/dist/services/StaticPreviewServer.d.ts +0 -8
- package/dist/services/StaticPreviewServer.js +0 -207
- package/src/ui/dist/assets/LibraryEntry-RI9Lc7P3.js +0 -37
- package/src/ui/dist/assets/main-D0UmAaUe.css +0 -1
- package/src/ui/dist/assets/main-DgrLzS5j.js +0 -497
- package/src/ui/dist/fonts/Goldman-Bold.woff2 +0 -0
- package/src/ui/dist/fonts/Goldman-Regular.woff2 +0 -0
|
@@ -14,7 +14,16 @@ const failureReason_1 = require("../utils/failureReason");
|
|
|
14
14
|
const proxy_1 = require("../config/proxy");
|
|
15
15
|
const MCPVariantsTelemetry_1 = require("./MCPVariantsTelemetry");
|
|
16
16
|
const errorMessage_1 = require("../utils/errorMessage");
|
|
17
|
+
const serverUnavailable_1 = require("../cli/serverUnavailable");
|
|
17
18
|
const log = (0, logger_1.createLogger)('TelemetryService');
|
|
19
|
+
const serverUnavailableReasonProperties = (error) => {
|
|
20
|
+
const reason = typeof error === 'object' && error !== null
|
|
21
|
+
? Reflect.get(error, 'serverUnavailableReason')
|
|
22
|
+
: undefined;
|
|
23
|
+
return (0, serverUnavailable_1.isServerUnavailableReason)(reason)
|
|
24
|
+
? { server_unavailable_reason: reason }
|
|
25
|
+
: {};
|
|
26
|
+
};
|
|
18
27
|
const KNOWN_MCP_EDITORS = new Set([
|
|
19
28
|
'cursor',
|
|
20
29
|
'codex',
|
|
@@ -61,8 +70,15 @@ class TelemetryService {
|
|
|
61
70
|
this.track(`library_${data.operation}_${data.outcome}`, {
|
|
62
71
|
duration_ms: data.durationMs,
|
|
63
72
|
...(0, failureReason_1.failureReasonCodeProperties)(data.error),
|
|
73
|
+
...serverUnavailableReasonProperties(data.error),
|
|
64
74
|
});
|
|
65
75
|
}
|
|
76
|
+
trackRequestRejected(reason) {
|
|
77
|
+
if (this.reportedRequestRejections.has(reason))
|
|
78
|
+
return;
|
|
79
|
+
this.reportedRequestRejections.add(reason);
|
|
80
|
+
this.track('server_request_rejected', { reason });
|
|
81
|
+
}
|
|
66
82
|
hashTelemetryValue(value) {
|
|
67
83
|
return (0, crypto_1.createHash)('sha256')
|
|
68
84
|
.update(value)
|
|
@@ -74,6 +90,7 @@ class TelemetryService {
|
|
|
74
90
|
defaultSource;
|
|
75
91
|
editor;
|
|
76
92
|
identifiedAccounts = new Set();
|
|
93
|
+
reportedRequestRejections = new Set();
|
|
77
94
|
constructor(options = true) {
|
|
78
95
|
const opts = typeof options === 'boolean' ? { enabled: options } : options;
|
|
79
96
|
this.isEnabled = (opts.enabled ?? true) && (0, telemetryPolicy_1.getTelemetryMode)() !== 'off';
|
|
@@ -682,6 +699,7 @@ class TelemetryService {
|
|
|
682
699
|
has_port: data.hasPort,
|
|
683
700
|
port: data.port,
|
|
684
701
|
duration_ms: data.durationMs,
|
|
702
|
+
static_entry_source: data.staticEntrySource,
|
|
685
703
|
source: 'mcp',
|
|
686
704
|
});
|
|
687
705
|
}
|
|
@@ -698,6 +716,7 @@ class TelemetryService {
|
|
|
698
716
|
exit_code: data.exitCode,
|
|
699
717
|
term_signal: data.signal,
|
|
700
718
|
missing_deps: data.missingDeps,
|
|
719
|
+
static_entry_source: data.staticEntrySource,
|
|
701
720
|
...(0, failureReason_1.failureReasonProperties)(data.error),
|
|
702
721
|
source: 'mcp',
|
|
703
722
|
});
|
|
@@ -3,6 +3,7 @@ import type { GuidanceDocument } from '../types/guidance';
|
|
|
3
3
|
import { type ReferenceImage } from './referenceImages';
|
|
4
4
|
import { type VariantReference } from '../types/variant-reference';
|
|
5
5
|
import type { VariantHistoryStatus, VariantHistoryKind, PersistVariantPreview, VariantServeSpec, VariantDesignSource, VariantDeployment, VariantCanvasDeployment, VariantHistoryManifest } from '../types/variant-history';
|
|
6
|
+
import type { DirectionRef } from '../types/direction-ref';
|
|
6
7
|
export type { VariantHistoryStatus, VariantHistoryKind, VariantHistoryPreview, PersistVariantPreview, VariantTreePointer, VariantBasePointer, DevServerRecipe, VariantServeSpec, VariantHistoryArtifact, VariantDesignSource, VariantDeployment, VariantCanvasDeployment, VariantHistoryManifest, VariantHistorySessionFile, } from '../types/variant-history';
|
|
7
8
|
import type { BundleMetadataStore } from '../storage/library/BundleMetadataStore';
|
|
8
9
|
import { TreeStore } from './TreeStore';
|
|
@@ -13,6 +14,7 @@ export interface PersistVariantArgs {
|
|
|
13
14
|
sessionId: string;
|
|
14
15
|
variantId: string;
|
|
15
16
|
requestId?: string;
|
|
17
|
+
directionRef?: DirectionRef;
|
|
16
18
|
label: string;
|
|
17
19
|
brief: string;
|
|
18
20
|
references?: VariantReference[];
|
|
@@ -116,6 +118,12 @@ export declare class VariantHistoryService {
|
|
|
116
118
|
label?: string;
|
|
117
119
|
runLabel?: string;
|
|
118
120
|
}): Promise<void>;
|
|
121
|
+
assignDirectionRef(args: {
|
|
122
|
+
projectPath: string;
|
|
123
|
+
sessionId: string;
|
|
124
|
+
variantId: string;
|
|
125
|
+
directionRef: DirectionRef;
|
|
126
|
+
}): Promise<void>;
|
|
119
127
|
renameRun(args: {
|
|
120
128
|
projectPath: string;
|
|
121
129
|
sessionId: string;
|
|
@@ -203,6 +203,7 @@ class VariantHistoryService {
|
|
|
203
203
|
let preservedDestinationPath;
|
|
204
204
|
let preservedCreatedAt;
|
|
205
205
|
let preservedRequestId;
|
|
206
|
+
let preservedDirectionRef;
|
|
206
207
|
let preservedReferences;
|
|
207
208
|
let preservedPreviewRoutes;
|
|
208
209
|
let preservedTree;
|
|
@@ -219,6 +220,7 @@ class VariantHistoryService {
|
|
|
219
220
|
});
|
|
220
221
|
preservedCreatedAt = prior.createdAt;
|
|
221
222
|
preservedRequestId = prior.requestId;
|
|
223
|
+
preservedDirectionRef = prior.directionRef;
|
|
222
224
|
preservedReferences = prior.references;
|
|
223
225
|
preservedPreviewRoutes = prior.previewRoutes;
|
|
224
226
|
preservedTree = prior.tree;
|
|
@@ -363,6 +365,9 @@ class VariantHistoryService {
|
|
|
363
365
|
...((args.requestId ?? preservedRequestId)
|
|
364
366
|
? { requestId: args.requestId ?? preservedRequestId }
|
|
365
367
|
: {}),
|
|
368
|
+
...((preservedDirectionRef ?? args.directionRef)
|
|
369
|
+
? { directionRef: preservedDirectionRef ?? args.directionRef }
|
|
370
|
+
: {}),
|
|
366
371
|
label: args.label,
|
|
367
372
|
brief: args.brief,
|
|
368
373
|
references: (0, variant_reference_1.mergeVariantReferences)(references),
|
|
@@ -527,6 +532,41 @@ class VariantHistoryService {
|
|
|
527
532
|
manifest,
|
|
528
533
|
});
|
|
529
534
|
}
|
|
535
|
+
async assignDirectionRef(args) {
|
|
536
|
+
assertSafeId(args.sessionId, 'sessionId');
|
|
537
|
+
assertSafeId(args.variantId, 'variantId');
|
|
538
|
+
const bundle = this.bundleFor(args.projectPath);
|
|
539
|
+
if (bundle) {
|
|
540
|
+
bundle.updateVariant({
|
|
541
|
+
...args,
|
|
542
|
+
update: (manifest) => {
|
|
543
|
+
manifest.directionRef ??= args.directionRef;
|
|
544
|
+
},
|
|
545
|
+
});
|
|
546
|
+
return;
|
|
547
|
+
}
|
|
548
|
+
const manifestPath = path_1.default.join(this.variantDir(args.projectPath, args.sessionId, args.variantId), MANIFEST_FILENAME);
|
|
549
|
+
let manifest;
|
|
550
|
+
try {
|
|
551
|
+
const raw = await promises_1.default.readFile(manifestPath, 'utf8');
|
|
552
|
+
manifest = JSON.parse(raw);
|
|
553
|
+
}
|
|
554
|
+
catch (err) {
|
|
555
|
+
const code = (0, errnoCode_1.errnoCode)(err);
|
|
556
|
+
if (code !== 'ENOENT') {
|
|
557
|
+
log.warn(`assignDirectionRef: manifest read failed at ${manifestPath} (session ${args.sessionId} variant ${args.variantId})`, err);
|
|
558
|
+
}
|
|
559
|
+
return;
|
|
560
|
+
}
|
|
561
|
+
if (manifest.directionRef)
|
|
562
|
+
return;
|
|
563
|
+
manifest.directionRef = args.directionRef;
|
|
564
|
+
await writeManifestFile(manifestPath, manifest);
|
|
565
|
+
await this.projectManifestToIndex({
|
|
566
|
+
projectPath: args.projectPath,
|
|
567
|
+
manifest,
|
|
568
|
+
});
|
|
569
|
+
}
|
|
530
570
|
async renameRun(args) {
|
|
531
571
|
const entries = await this.listVariants({ projectPath: args.projectPath });
|
|
532
572
|
const targets = entries.filter((entry) => {
|
|
@@ -23,6 +23,7 @@ export declare class WorktreeManager {
|
|
|
23
23
|
createWorktrees(sessionId: string, count: number, instanceKeyPrefix?: string): Promise<string[]>;
|
|
24
24
|
forkWorktreesFrom(sourceWorktreePath: string, sessionId: string, count: number, instanceKeyPrefix?: string): Promise<string[]>;
|
|
25
25
|
getDiff(worktreePath: string): Promise<string>;
|
|
26
|
+
getChangedFiles(worktreePath: string): Promise<string[]>;
|
|
26
27
|
getFreePort(): Promise<number>;
|
|
27
28
|
findFreePortFrom(startPort: number, scanWindow?: number): Promise<number>;
|
|
28
29
|
releasePort(port: number): void;
|
|
@@ -276,6 +276,18 @@ class WorktreeManager {
|
|
|
276
276
|
await git.raw(['add', '--intent-to-add', '.']).catch(() => { });
|
|
277
277
|
return git.diff(['--binary', '--full-index', 'HEAD']);
|
|
278
278
|
}
|
|
279
|
+
async getChangedFiles(worktreePath) {
|
|
280
|
+
const git = (0, simple_git_1.simpleGit)(worktreePath, GIT_OPTS);
|
|
281
|
+
await git.raw(['add', '--intent-to-add', '.']).catch(() => { });
|
|
282
|
+
const names = await git.raw([
|
|
283
|
+
'diff',
|
|
284
|
+
'--name-only',
|
|
285
|
+
'--diff-filter=d',
|
|
286
|
+
'-z',
|
|
287
|
+
'HEAD',
|
|
288
|
+
]);
|
|
289
|
+
return names.split('\0').filter(Boolean);
|
|
290
|
+
}
|
|
279
291
|
getFreePort() {
|
|
280
292
|
return new Promise((resolve, reject) => {
|
|
281
293
|
const server = net_1.default.createServer();
|
|
@@ -1,6 +1,11 @@
|
|
|
1
1
|
"use strict";
|
|
2
|
+
var __importDefault = (this && this.__importDefault) || function (mod) {
|
|
3
|
+
return (mod && mod.__esModule) ? mod : { "default": mod };
|
|
4
|
+
};
|
|
2
5
|
Object.defineProperty(exports, "__esModule", { value: true });
|
|
3
6
|
exports.createAgentVariantsOrchestrator = exports.withVariantsSessionReplayLinking = void 0;
|
|
7
|
+
const fs_1 = __importDefault(require("fs"));
|
|
8
|
+
const path_1 = __importDefault(require("path"));
|
|
4
9
|
const index_core_1 = require("../index-core");
|
|
5
10
|
const agent_variants_1 = require("../agent-variants");
|
|
6
11
|
const devServerCommand_1 = require("../utils/devServerCommand");
|
|
@@ -69,11 +74,13 @@ const createAgentVariantsOrchestrator = (options) => {
|
|
|
69
74
|
targetPath: projectPath,
|
|
70
75
|
entryPath: options.staticEntry,
|
|
71
76
|
}).entryPath;
|
|
72
|
-
|
|
77
|
+
const hasEntry = options.staticEntry !== undefined ||
|
|
78
|
+
fs_1.default.existsSync(path_1.default.join(projectPath, entryPath));
|
|
79
|
+
log.info(`Resolved env for variants session ${sessionId}: static/${hasEntry ? entryPath : '(no entry page)'}`);
|
|
73
80
|
return {
|
|
74
81
|
projectPath,
|
|
75
82
|
framework,
|
|
76
|
-
entryPath,
|
|
83
|
+
...(hasEntry ? { entryPath } : {}),
|
|
77
84
|
};
|
|
78
85
|
}
|
|
79
86
|
const packageManager = await detection.detectPackageManager(projectPath);
|
|
@@ -0,0 +1,21 @@
|
|
|
1
|
+
import type { DirectionAddress, DirectionCandidate, DirectionRef, DirectionResolution, DirectionSearchAddress } from '../types/direction-ref';
|
|
2
|
+
import type { VariantHistoryManifest, VariantHistoryStatus } from '../types/variant-history';
|
|
3
|
+
export declare const isDirectionActive: (status: VariantHistoryStatus) => boolean;
|
|
4
|
+
type DirectionRefSource = {
|
|
5
|
+
manifest: Pick<VariantHistoryManifest, 'sessionId' | 'variantId' | 'label' | 'createdAt' | 'directionRef'>;
|
|
6
|
+
};
|
|
7
|
+
export declare const slugifyDirectionLabel: (label: string) => string;
|
|
8
|
+
export declare const nextDirectionRef: (args: {
|
|
9
|
+
label: string;
|
|
10
|
+
taken: ReadonlySet<string>;
|
|
11
|
+
}) => DirectionRef;
|
|
12
|
+
export declare const withDirectionRefs: <Entry extends DirectionRefSource>(entries: readonly Entry[]) => Array<Entry & {
|
|
13
|
+
directionRef: DirectionRef;
|
|
14
|
+
}>;
|
|
15
|
+
export declare const parseDirectionAddress: (raw: string) => DirectionAddress | null;
|
|
16
|
+
export declare const resolveDirectionAddress: (args: {
|
|
17
|
+
address: DirectionSearchAddress;
|
|
18
|
+
candidates: readonly DirectionCandidate[];
|
|
19
|
+
}) => DirectionResolution;
|
|
20
|
+
export {};
|
|
21
|
+
//# sourceMappingURL=directionRefs.d.ts.map
|
|
@@ -0,0 +1,148 @@
|
|
|
1
|
+
"use strict";
|
|
2
|
+
Object.defineProperty(exports, "__esModule", { value: true });
|
|
3
|
+
exports.resolveDirectionAddress = exports.parseDirectionAddress = exports.withDirectionRefs = exports.nextDirectionRef = exports.slugifyDirectionLabel = exports.isDirectionActive = void 0;
|
|
4
|
+
const SLUG_MAX_LENGTH = 40;
|
|
5
|
+
const EMPTY_LABEL_SLUG = 'direction';
|
|
6
|
+
const LAST_KEYWORD = 'last';
|
|
7
|
+
const FIRST_COLLISION_SUFFIX = 2;
|
|
8
|
+
const MIN_VARIANT_ID_PREFIX_LENGTH = 4;
|
|
9
|
+
const MAX_UNKNOWN_CANDIDATES = 10;
|
|
10
|
+
const TOKEN_PATTERN = /^[A-Za-z0-9_-]+$/;
|
|
11
|
+
const INACTIVE_STATUSES = new Set([
|
|
12
|
+
'removed',
|
|
13
|
+
'cancelled',
|
|
14
|
+
]);
|
|
15
|
+
const isDirectionActive = (status) => !INACTIVE_STATUSES.has(status);
|
|
16
|
+
exports.isDirectionActive = isDirectionActive;
|
|
17
|
+
const slugifyDirectionLabel = (label) => {
|
|
18
|
+
const slug = label
|
|
19
|
+
.normalize('NFKD')
|
|
20
|
+
.replace(/\p{M}/gu, '')
|
|
21
|
+
.toLowerCase()
|
|
22
|
+
.replace(/[^a-z0-9]+/g, '-')
|
|
23
|
+
.replace(/^-+|-+$/g, '');
|
|
24
|
+
if (!slug)
|
|
25
|
+
return EMPTY_LABEL_SLUG;
|
|
26
|
+
if (slug.length <= SLUG_MAX_LENGTH)
|
|
27
|
+
return slug;
|
|
28
|
+
const boundary = slug.lastIndexOf('-', SLUG_MAX_LENGTH);
|
|
29
|
+
return slug.slice(0, boundary > 0 ? boundary : SLUG_MAX_LENGTH);
|
|
30
|
+
};
|
|
31
|
+
exports.slugifyDirectionLabel = slugifyDirectionLabel;
|
|
32
|
+
const nextDirectionRef = (args) => {
|
|
33
|
+
const slug = (0, exports.slugifyDirectionLabel)(args.label);
|
|
34
|
+
const isTaken = (candidate) => candidate === LAST_KEYWORD || args.taken.has(candidate);
|
|
35
|
+
let candidate = slug;
|
|
36
|
+
for (let suffix = FIRST_COLLISION_SUFFIX; isTaken(candidate); suffix++)
|
|
37
|
+
candidate = `${slug}-${suffix}`;
|
|
38
|
+
return candidate;
|
|
39
|
+
};
|
|
40
|
+
exports.nextDirectionRef = nextDirectionRef;
|
|
41
|
+
const directionKey = (manifest) => `${manifest.sessionId}:${manifest.variantId}`;
|
|
42
|
+
const byCreation = (a, b) => a.manifest.createdAt.localeCompare(b.manifest.createdAt) ||
|
|
43
|
+
a.manifest.sessionId.localeCompare(b.manifest.sessionId) ||
|
|
44
|
+
a.manifest.variantId.localeCompare(b.manifest.variantId);
|
|
45
|
+
const withDirectionRefs = (entries) => {
|
|
46
|
+
const taken = new Set(entries.flatMap(({ manifest }) => manifest.directionRef ? [manifest.directionRef] : []));
|
|
47
|
+
const legacyRefs = new Map();
|
|
48
|
+
const legacyRefOf = (manifest) => {
|
|
49
|
+
const key = directionKey(manifest);
|
|
50
|
+
const known = legacyRefs.get(key);
|
|
51
|
+
if (known)
|
|
52
|
+
return known;
|
|
53
|
+
const directionRef = (0, exports.nextDirectionRef)({ label: manifest.label, taken });
|
|
54
|
+
taken.add(directionRef);
|
|
55
|
+
legacyRefs.set(key, directionRef);
|
|
56
|
+
return directionRef;
|
|
57
|
+
};
|
|
58
|
+
for (const { manifest } of [...entries].sort(byCreation))
|
|
59
|
+
if (!manifest.directionRef)
|
|
60
|
+
legacyRefOf(manifest);
|
|
61
|
+
return entries.map((entry) => ({
|
|
62
|
+
...entry,
|
|
63
|
+
directionRef: entry.manifest.directionRef ?? legacyRefOf(entry.manifest),
|
|
64
|
+
}));
|
|
65
|
+
};
|
|
66
|
+
exports.withDirectionRefs = withDirectionRefs;
|
|
67
|
+
const parseDirectionIds = (raw) => {
|
|
68
|
+
const projectSeparator = raw.indexOf('/');
|
|
69
|
+
const projectId = projectSeparator === -1 ? undefined : raw.slice(0, projectSeparator);
|
|
70
|
+
const direction = projectSeparator === -1 ? raw : raw.slice(projectSeparator + 1);
|
|
71
|
+
if (projectSeparator !== -1 && (!projectId || direction.includes('/')))
|
|
72
|
+
return null;
|
|
73
|
+
const variantSeparator = direction.indexOf(':');
|
|
74
|
+
if (variantSeparator <= 0 || variantSeparator === direction.length - 1)
|
|
75
|
+
return null;
|
|
76
|
+
if (direction.indexOf(':', variantSeparator + 1) !== -1)
|
|
77
|
+
return null;
|
|
78
|
+
const sessionId = direction.slice(0, variantSeparator).trim();
|
|
79
|
+
const variantId = direction.slice(variantSeparator + 1).trim();
|
|
80
|
+
if (!sessionId || !variantId)
|
|
81
|
+
return null;
|
|
82
|
+
return {
|
|
83
|
+
kind: 'ids',
|
|
84
|
+
...(projectId ? { projectId } : {}),
|
|
85
|
+
sessionId,
|
|
86
|
+
variantId,
|
|
87
|
+
};
|
|
88
|
+
};
|
|
89
|
+
const parseDirectionAddress = (raw) => {
|
|
90
|
+
const value = raw.trim();
|
|
91
|
+
if (value.toLowerCase() === LAST_KEYWORD)
|
|
92
|
+
return { kind: 'last' };
|
|
93
|
+
if (value.includes(':') || value.includes('/'))
|
|
94
|
+
return parseDirectionIds(value);
|
|
95
|
+
return TOKEN_PATTERN.test(value) ? { kind: 'token', token: value } : null;
|
|
96
|
+
};
|
|
97
|
+
exports.parseDirectionAddress = parseDirectionAddress;
|
|
98
|
+
const newestFirst = (a, b) => b.createdAt.localeCompare(a.createdAt);
|
|
99
|
+
const notFound = (args) => {
|
|
100
|
+
const candidates = args.newest.slice(0, MAX_UNKNOWN_CANDIDATES);
|
|
101
|
+
const knownRefs = candidates.map((candidate) => candidate.directionRef);
|
|
102
|
+
const knownRefsSentence = knownRefs.length > 0 ? ` Known refs: ${knownRefs.join(', ')}.` : '';
|
|
103
|
+
return {
|
|
104
|
+
isResolved: false,
|
|
105
|
+
code: 'WORK_ITEM_NOT_FOUND',
|
|
106
|
+
message: `No direction matches "${args.input}".${knownRefsSentence}`,
|
|
107
|
+
candidates,
|
|
108
|
+
};
|
|
109
|
+
};
|
|
110
|
+
const resolveToken = (args) => {
|
|
111
|
+
const needle = args.token.toLowerCase();
|
|
112
|
+
const exact = args.newest.filter((candidate) => candidate.directionRef.toLowerCase() === needle);
|
|
113
|
+
const prefixed = needle.length >= MIN_VARIANT_ID_PREFIX_LENGTH
|
|
114
|
+
? args.newest.filter((candidate) => candidate.variantId.toLowerCase().startsWith(needle))
|
|
115
|
+
: [];
|
|
116
|
+
const matches = exact.length > 0 ? exact : prefixed;
|
|
117
|
+
if (matches.length === 1)
|
|
118
|
+
return { isResolved: true, direction: matches[0] };
|
|
119
|
+
if (matches.length === 0)
|
|
120
|
+
return notFound({ input: args.token, newest: args.newest });
|
|
121
|
+
return {
|
|
122
|
+
isResolved: false,
|
|
123
|
+
code: 'DIRECTION_AMBIGUOUS',
|
|
124
|
+
message: `"${args.token}" matches ${matches.length} directions: ${matches
|
|
125
|
+
.map((candidate) => candidate.directionRef)
|
|
126
|
+
.join(', ')}.`,
|
|
127
|
+
candidates: matches,
|
|
128
|
+
};
|
|
129
|
+
};
|
|
130
|
+
const resolveDirectionAddress = (args) => {
|
|
131
|
+
const newest = [...args.candidates].sort(newestFirst);
|
|
132
|
+
switch (args.address.kind) {
|
|
133
|
+
case 'last': {
|
|
134
|
+
const direction = newest.find((candidate) => (0, exports.isDirectionActive)(candidate.status));
|
|
135
|
+
return direction
|
|
136
|
+
? { isResolved: true, direction }
|
|
137
|
+
: notFound({ input: LAST_KEYWORD, newest });
|
|
138
|
+
}
|
|
139
|
+
case 'token':
|
|
140
|
+
return resolveToken({ token: args.address.token, newest });
|
|
141
|
+
default: {
|
|
142
|
+
const unhandled = args.address;
|
|
143
|
+
return unhandled;
|
|
144
|
+
}
|
|
145
|
+
}
|
|
146
|
+
};
|
|
147
|
+
exports.resolveDirectionAddress = resolveDirectionAddress;
|
|
148
|
+
//# sourceMappingURL=directionRefs.js.map
|
|
@@ -0,0 +1,22 @@
|
|
|
1
|
+
import type { ProjectLibrary } from './ProjectLibrary';
|
|
2
|
+
import type { VariantHistoryEntry, VariantHistoryService } from './VariantHistoryService';
|
|
3
|
+
import type { DirectionRef, DirectionResolution, DirectionSearchAddress } from '../types/direction-ref';
|
|
4
|
+
export type ProjectDirectionSource = {
|
|
5
|
+
kind: 'library';
|
|
6
|
+
library: ProjectLibrary;
|
|
7
|
+
projectId: string;
|
|
8
|
+
} | {
|
|
9
|
+
kind: 'history';
|
|
10
|
+
history: VariantHistoryService;
|
|
11
|
+
projectPath: string;
|
|
12
|
+
};
|
|
13
|
+
export type ProjectDirection = VariantHistoryEntry & {
|
|
14
|
+
projectPath: string;
|
|
15
|
+
directionRef: DirectionRef;
|
|
16
|
+
};
|
|
17
|
+
export declare const listProjectDirections: (source: ProjectDirectionSource) => Promise<ProjectDirection[]>;
|
|
18
|
+
export declare const resolveProjectDirection: (args: {
|
|
19
|
+
source: ProjectDirectionSource;
|
|
20
|
+
address: DirectionSearchAddress;
|
|
21
|
+
}) => Promise<DirectionResolution>;
|
|
22
|
+
//# sourceMappingURL=projectDirections.d.ts.map
|
|
@@ -0,0 +1,38 @@
|
|
|
1
|
+
"use strict";
|
|
2
|
+
Object.defineProperty(exports, "__esModule", { value: true });
|
|
3
|
+
exports.resolveProjectDirection = exports.listProjectDirections = void 0;
|
|
4
|
+
const directionRefs_1 = require("./directionRefs");
|
|
5
|
+
const historyRoots_1 = require("./historyRoots");
|
|
6
|
+
const listSourceEntries = async (source) => {
|
|
7
|
+
switch (source.kind) {
|
|
8
|
+
case 'library':
|
|
9
|
+
return source.library.listVariants(source.projectId, {
|
|
10
|
+
isRemovedIncluded: true,
|
|
11
|
+
});
|
|
12
|
+
case 'history':
|
|
13
|
+
return (await Promise.all([
|
|
14
|
+
source.projectPath,
|
|
15
|
+
...(0, historyRoots_1.nestedFreshSessionWorkdirs)(source.projectPath),
|
|
16
|
+
].map(async (projectPath) => (await source.history.listVariants({ projectPath })).map((entry) => ({ ...entry, projectPath }))))).flat();
|
|
17
|
+
default: {
|
|
18
|
+
const unhandled = source;
|
|
19
|
+
return unhandled;
|
|
20
|
+
}
|
|
21
|
+
}
|
|
22
|
+
};
|
|
23
|
+
const listProjectDirections = async (source) => (0, directionRefs_1.withDirectionRefs)(await listSourceEntries(source));
|
|
24
|
+
exports.listProjectDirections = listProjectDirections;
|
|
25
|
+
const directionCandidateOf = (direction) => ({
|
|
26
|
+
directionRef: direction.directionRef,
|
|
27
|
+
sessionId: direction.manifest.sessionId,
|
|
28
|
+
variantId: direction.manifest.variantId,
|
|
29
|
+
label: direction.manifest.label,
|
|
30
|
+
status: direction.manifest.status,
|
|
31
|
+
createdAt: direction.manifest.createdAt,
|
|
32
|
+
});
|
|
33
|
+
const resolveProjectDirection = async (args) => (0, directionRefs_1.resolveDirectionAddress)({
|
|
34
|
+
address: args.address,
|
|
35
|
+
candidates: (await (0, exports.listProjectDirections)(args.source)).map(directionCandidateOf),
|
|
36
|
+
});
|
|
37
|
+
exports.resolveProjectDirection = resolveProjectDirection;
|
|
38
|
+
//# sourceMappingURL=projectDirections.js.map
|
|
@@ -0,0 +1,36 @@
|
|
|
1
|
+
import type { VariantHistoryStatus } from './variant-history';
|
|
2
|
+
export type DirectionRef = string & {
|
|
3
|
+
readonly __brand: 'DirectionRef';
|
|
4
|
+
};
|
|
5
|
+
export type DirectionAddress = {
|
|
6
|
+
kind: 'ids';
|
|
7
|
+
projectId?: string;
|
|
8
|
+
sessionId: string;
|
|
9
|
+
variantId: string;
|
|
10
|
+
} | {
|
|
11
|
+
kind: 'token';
|
|
12
|
+
token: string;
|
|
13
|
+
} | {
|
|
14
|
+
kind: 'last';
|
|
15
|
+
};
|
|
16
|
+
export type DirectionSearchAddress = Exclude<DirectionAddress, {
|
|
17
|
+
kind: 'ids';
|
|
18
|
+
}>;
|
|
19
|
+
export interface DirectionCandidate {
|
|
20
|
+
directionRef: DirectionRef;
|
|
21
|
+
sessionId: string;
|
|
22
|
+
variantId: string;
|
|
23
|
+
label: string;
|
|
24
|
+
status: VariantHistoryStatus;
|
|
25
|
+
createdAt: string;
|
|
26
|
+
}
|
|
27
|
+
export type DirectionResolution = {
|
|
28
|
+
isResolved: true;
|
|
29
|
+
direction: DirectionCandidate;
|
|
30
|
+
} | {
|
|
31
|
+
isResolved: false;
|
|
32
|
+
code: 'WORK_ITEM_NOT_FOUND' | 'DIRECTION_AMBIGUOUS';
|
|
33
|
+
message: string;
|
|
34
|
+
candidates: DirectionCandidate[];
|
|
35
|
+
};
|
|
36
|
+
//# sourceMappingURL=direction-ref.d.ts.map
|
|
@@ -1,3 +1,4 @@
|
|
|
1
|
+
import type { DirectionRef } from './direction-ref';
|
|
1
2
|
import type { VariantReference } from './variant-reference';
|
|
2
3
|
export type { VariantReference } from './variant-reference';
|
|
3
4
|
export type VariantHistoryStatus = 'completed' | 'committed' | 'rejected' | 'cancelled' | 'removed';
|
|
@@ -91,6 +92,7 @@ export interface VariantHistoryManifest {
|
|
|
91
92
|
variantId: string;
|
|
92
93
|
sessionId: string;
|
|
93
94
|
requestId?: string;
|
|
95
|
+
directionRef?: DirectionRef;
|
|
94
96
|
label: string;
|
|
95
97
|
brief: string;
|
|
96
98
|
references?: VariantReference[];
|
|
@@ -120,7 +122,7 @@ export interface VariantHistoryManifest {
|
|
|
120
122
|
deployments?: VariantDeployment[];
|
|
121
123
|
runtime?: import('../agent-variants/contracts').WorkerRuntimeInfo;
|
|
122
124
|
}
|
|
123
|
-
export type VariantHistoryRow = Pick<VariantHistoryManifest, 'sessionId' | 'variantId' | 'requestId' | 'label' | 'brief' | 'references' | 'previewRoutes' | 'runLabel' | 'projectKind' | 'status' | 'createdAt' | 'statusChangedAt' | 'changedFilesCount' | 'preview' | 'artifact' | 'parentVariant' | 'serve' | 'runtime'> & {
|
|
125
|
+
export type VariantHistoryRow = Pick<VariantHistoryManifest, 'sessionId' | 'variantId' | 'requestId' | 'directionRef' | 'label' | 'brief' | 'references' | 'previewRoutes' | 'runLabel' | 'projectKind' | 'status' | 'createdAt' | 'statusChangedAt' | 'changedFilesCount' | 'preview' | 'artifact' | 'parentVariant' | 'serve' | 'runtime'> & {
|
|
124
126
|
kind: VariantHistoryKind;
|
|
125
127
|
hasStaticPreview: boolean;
|
|
126
128
|
hasTree: boolean;
|
|
@@ -28,7 +28,7 @@ exports.CLI_GUIDANCE_BODY = `Rivet helps you **explore multiple design direction
|
|
|
28
28
|
|
|
29
29
|
Use these independently exposed tools for their named purposes:
|
|
30
30
|
|
|
31
|
-
- \`rivet_explore_designs\` starts directions with \`project\`, \`instruction\`, \`runLabel\`, and one authored \`briefs\` entry per direction. Use \`baseDirectionId
|
|
31
|
+
- \`rivet_explore_designs\` starts directions with \`project\`, \`instruction\`, \`runLabel\`, and one authored \`briefs\` entry per direction. Use \`baseDirectionId\` with a direction's \`directionRef\` (for example \`"warm-editorial-green"\`) or \`"sessionId:variantId"\` to vary a result.
|
|
32
32
|
- \`rivet_get_exploration\` reads progress and results with \`project\`. Add \`sessionId\`, \`variantId\`, \`includeHistory\`, or the start response's \`workId\` for recorded context receipts.
|
|
33
33
|
- \`rivet_cancel_exploration\` cancels the named \`project\` and \`sessionId\` only when the user asks.
|
|
34
34
|
- \`rivet_find_references\` searches retained titles, text, notes, and analysis with \`query\`, optional \`sourceId\`, and optional \`limit\`. Its \`saved_text\` ranking is lexical. It does not start workers, create an index, or perform semantic model search.
|
|
@@ -95,12 +95,13 @@ The export returns \`{checks:[{id,status:"pass"|"fail"|"blocked",priority:"high"
|
|
|
95
95
|
- \`rivet open [--project <path>] [--agent claude|codex|cursor] [--rivet-port N] [--user-port N] [--framework nextjs|vite|cra|remix|svelte|static] [--entry <path>] [--no-browser] [--no-git]\` — start or attach the project's editor server (idempotent; returns \`editorUrl\`). It detects the app, attaches to an already-running dev server, or starts one from the app's standard \`dev\`/\`start\`/\`serve\`/\`storybook\` script when possible. Follow the browser behavior above for interactive work.
|
|
96
96
|
- **Attach, don't rebuild.** If the user's dev server is already running (including Storybook — component-library teams often run only Storybook), pass \`--user-port <port>\` to attach directly: this skips detection and never starts a second server. Auto-detection scans common ports (3000, 5173, 6006, …), but an explicit \`--user-port\` is always the most reliable path — when in doubt, ask the user which port their app is on, or start the dev server yourself first and pass its port.
|
|
97
97
|
- **Rivet never installs dependencies.** If \`open\` fails because the app's start command failed, the error carries the exact command and its output. YOU own the fix: diagnose the output, run the project's install yourself if dependencies are missing, or start the dev server yourself — then re-run \`rivet open --user-port <port>\`. Do not retry \`rivet open\` unchanged expecting a different result.
|
|
98
|
-
- \`rivet variants start --project <path> --instruction <text> [--run-label <text>] [--briefs <json>] [--count N] [--fidelity low|medium|high] [--element <selector>] [--files <json>] [--fresh] [--profile auto|off] [--context-images <json>] [--reference-pages <json>] [--reference-videos <json>] [--target <sessionId>:<variantId>] [--worker-provider claude|codex|cursor] [--worker-model <id>]\` — explore design directions. For every start, including fresh apps and \`--target\` requests, agent invocations MUST pass an AI-authored 1–3 word batch label through \`rivet_explore_designs\` \`runLabel\` or CLI \`--run-label\`, plus one AI-authored brief per direction; \`briefs.length\` sets the count. Fresh starts use the same host-authored briefs and batch label; Rivet prepares reference context for the workers without calling a planning model. Use \`--files\` for already-known project paths and \`--target\` to Vary an existing direction. Returns a \`workId\` and \`nextAction\` after workspace provisioning.
|
|
98
|
+
- \`rivet variants start --project <path> --instruction <text> [--run-label <text>] [--briefs <json>] [--count N] [--fidelity low|medium|high] [--element <selector>] [--files <json>] [--fresh] [--profile auto|off] [--context-images <json>] [--reference-pages <json>] [--reference-videos <json>] [--target <directionRef>|<sessionId>:<variantId>] [--worker-provider claude|codex|cursor] [--worker-model <id>]\` — explore design directions. For every start, including fresh apps and \`--target\` requests, agent invocations MUST pass an AI-authored 1–3 word batch label through \`rivet_explore_designs\` \`runLabel\` or CLI \`--run-label\`, plus one AI-authored brief per direction; \`briefs.length\` sets the count. Fresh starts use the same host-authored briefs and batch label; Rivet prepares reference context for the workers without calling a planning model. Use \`--files\` for already-known project paths and \`--target\` to Vary an existing direction. Returns a \`workId\` and \`nextAction\` after workspace provisioning.
|
|
99
99
|
- \`rivet variants complete <workId> --project <path> [--session <sessionId>] [--status succeeded|failed|cancelled] [--output <json>] [--error <message>]\` — report one host-agent work item complete after you edit its assigned workspace. Static artifacts are read from disk; do not send them through \`--output\`.
|
|
100
100
|
- \`rivet wait <workId> --project <path> [--timeout <seconds>]\` — bounded block until a work id settles (exit 5 on timeout; re-issue or check status).
|
|
101
101
|
- \`rivet status --project <path> [--watch]\` — session, resolved runner, active run, and the variants snapshot. \`--watch\` streams NDJSON.
|
|
102
102
|
- \`rivet variants status --project <path>\` / \`rivet variants list --project <path> [--history]\` — inspect live or past directions.
|
|
103
103
|
- \`rivet variants get <projectId>/<sessionId>:<variantId> [--detail]\` — resolve a copied direction from any working directory through the local project library, even when its editor is closed. The default response is compact metadata and an artifact path; add \`--detail\` for the full diff, file list, and design notes.
|
|
104
|
+
- \`rivet variants get <directionRef>|last --project <path> [--detail]\` — resolve a direction by the short \`directionRef\` shown in status, history, and \`nextAction\` work items (for example \`warm-editorial-green\`), or the newest direction with \`last\`. Refs never change once assigned. An ambiguous or unknown ref fails with \`DIRECTION_AMBIGUOUS\` or \`WORK_ITEM_NOT_FOUND\` and lists the candidate refs in \`error.details.candidates\`.
|
|
104
105
|
- \`rivet variants cancel <sessionId> --project <path>\` — cancel a running variants session.
|
|
105
106
|
- \`rivet evidence capture --url <url>\` — rendered design evidence (root variables, element styles, fonts) for a reference URL.
|
|
106
107
|
- \`rivet reference fetch <url>\` — Pinterest / Are.na reference data via the user's connected account. Accepts full pin/board URLs and \`pin.it\` share links. Pinterest images are downloaded into \`.rivet/references/\` and returned as absolute paths (\`data.images\`, plus \`local_path\` per pin) — view them directly and pass them to variants via \`--context-images\` instead of relaying URLs. If Pinterest returns \`status: not_connected\`, present the returned \`authUrl\` to the user and retry after they authorize. On failure the error message says exactly what to tell the user (e.g. save the pin to a board first).
|
|
@@ -125,7 +126,7 @@ Existing app, using CLI commands when MCP is unavailable. With MCP use \`rivet_g
|
|
|
125
126
|
|
|
126
127
|
Fresh 0-to-1: with MCP use \`rivet_explore_designs\` with \`fresh: true\` after reading \`rivet_get_design_context\`. For the CLI flow, create or use an empty directory and run \`rivet open --project <path> ...\`. Resolve the selected saved instructions with \`rivet context resolve\`, then author a batch label and one distinct brief per direction from the user's request, supplied references, and saved instructions. Include concrete section, layout, typography, and interaction choices in each brief's notes. Run \`rivet variants start --project <path> --fresh --instruction "build a SaaS landing page" --run-label "Landing layouts" --briefs '<json>' ...\`, omitting \`--count\` because the briefs set the count. Rivet uses those briefs directly without a hosted planning call. Pass local reference images via \`--context-images '["/abs/path.png"]'\` (\`rivet_explore_designs\` \`contextImages\`) — Rivet copies them into the run context and every worker views them natively. Pass reference page URLs via \`--reference-pages '["https://example.com"]'\` (\`referencePages\`) — Rivet renders each page server-side for design evidence + a screenshot; never capture evidence or screenshot pages yourself. Pass local reference videos via \`--reference-videos '["/abs/clip.mp4"]'\` (\`referenceVideos\`) — Rivet samples keyframes server-side; never run ffmpeg yourself. Never substitute a prose description of media you can pass directly.
|
|
127
128
|
|
|
128
|
-
Vary an existing direction: with MCP read \`rivet_get_exploration\` and pass \`
|
|
129
|
+
Vary an existing direction: with MCP read \`rivet_get_exploration\` and pass the direction's \`directionRef\` as \`baseDirectionId\` to \`rivet_explore_designs\`. For the CLI flow, after status/list gives you its \`directionRef\`, author a batch label and two distinct delta briefs by default, then run \`rivet variants start --project <path> --target <directionRef> --instruction "make this calmer" --run-label "Calmer direction" --briefs '<json>' ...\`. Include \`--files '["src/known-target.tsx"]'\` when the relevant files are already known. Explicit briefs/counts remain authoritative.
|
|
129
130
|
|
|
130
131
|
Rivet owns orchestration; the host agent owns implementation. Do not wait for Rivet to spawn a separate agent. When \`rivet variants start\`, \`rivet status\`, \`rivet_explore_designs\`, or \`rivet_get_exploration\` returns \`nextAction.action="complete_host_variant_work"\`, complete those work items from the current host session. Follow the returned parallelism strategy: direct work stays in the current host; native delegation can be required even for one item with a requested model. Spawn one native worker per delegated workspace in the same turn, and have each worker report its own completion immediately via its \`completeCommand\` (or \`rivet_complete_variant_work\`) — a variant's completion must never wait for its siblings.
|
|
131
132
|
|
|
@@ -1,5 +1,5 @@
|
|
|
1
1
|
type ProviderPurpose = 'claude' | 'codex' | 'cursor' | 'verifier';
|
|
2
|
-
type ChildPurpose = ProviderPurpose | 'devServer' | 'packageManager' | '
|
|
2
|
+
type ChildPurpose = ProviderPurpose | 'devServer' | 'packageManager' | 'profileMemory' | 'git' | 'desktop';
|
|
3
3
|
type SubprocessPurpose = ChildPurpose | 'rivetRuntime';
|
|
4
4
|
export declare const subprocessEnvironment: (purpose: SubprocessPurpose, inherited?: NodeJS.ProcessEnv) => NodeJS.ProcessEnv;
|
|
5
5
|
export {};
|
package/package.json
CHANGED
|
@@ -1,6 +1,6 @@
|
|
|
1
1
|
{
|
|
2
2
|
"name": "rivet-design",
|
|
3
|
-
"version": "0.27.
|
|
3
|
+
"version": "0.27.1",
|
|
4
4
|
"description": "Local visual web development tool with AI-powered code modification",
|
|
5
5
|
"main": "dist/index.js",
|
|
6
6
|
"workspaces": [
|
|
@@ -120,7 +120,7 @@
|
|
|
120
120
|
"eslint": "^9.36.0",
|
|
121
121
|
"eslint-config-prettier": "^10.1.8",
|
|
122
122
|
"eslint-plugin-react": "^7.37.5",
|
|
123
|
-
"eslint-plugin-react-hooks": "^
|
|
123
|
+
"eslint-plugin-react-hooks": "^7.1.1",
|
|
124
124
|
"globals": "^17.14.0",
|
|
125
125
|
"husky": "^9.1.7",
|
|
126
126
|
"jest": "^30.1.3",
|
|
@@ -212,5 +212,5 @@
|
|
|
212
212
|
"rivetPlugin": {
|
|
213
213
|
"toolContract": "intent-v2"
|
|
214
214
|
},
|
|
215
|
-
"gitHead": "
|
|
215
|
+
"gitHead": "4ee9afdfb73764212502fcaa1b21335ad89ab889"
|
|
216
216
|
}
|