@cortexmemory/cli 0.26.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.
Files changed (71) hide show
  1. package/dist/commands/db.d.ts.map +1 -1
  2. package/dist/commands/db.js +2 -18
  3. package/dist/commands/db.js.map +1 -1
  4. package/dist/commands/dev.d.ts.map +1 -1
  5. package/dist/commands/dev.js +153 -17
  6. package/dist/commands/dev.js.map +1 -1
  7. package/dist/commands/init.d.ts.map +1 -1
  8. package/dist/commands/init.js +373 -70
  9. package/dist/commands/init.js.map +1 -1
  10. package/dist/commands/setup.d.ts.map +1 -1
  11. package/dist/commands/setup.js +102 -46
  12. package/dist/commands/setup.js.map +1 -1
  13. package/dist/commands/status.d.ts.map +1 -1
  14. package/dist/commands/status.js +94 -7
  15. package/dist/commands/status.js.map +1 -1
  16. package/dist/index.js +1 -1
  17. package/dist/types.d.ts +23 -0
  18. package/dist/types.d.ts.map +1 -1
  19. package/dist/utils/config.d.ts +11 -0
  20. package/dist/utils/config.d.ts.map +1 -1
  21. package/dist/utils/config.js +20 -0
  22. package/dist/utils/config.js.map +1 -1
  23. package/dist/utils/init/convex-setup.d.ts +58 -6
  24. package/dist/utils/init/convex-setup.d.ts.map +1 -1
  25. package/dist/utils/init/convex-setup.js +261 -57
  26. package/dist/utils/init/convex-setup.js.map +1 -1
  27. package/dist/utils/init/env-generator.d.ts.map +1 -1
  28. package/dist/utils/init/env-generator.js +12 -2
  29. package/dist/utils/init/env-generator.js.map +1 -1
  30. package/dist/utils/init/graph-setup.d.ts.map +1 -1
  31. package/dist/utils/init/graph-setup.js +12 -0
  32. package/dist/utils/init/graph-setup.js.map +1 -1
  33. package/dist/utils/init/quickstart-setup.d.ts +87 -0
  34. package/dist/utils/init/quickstart-setup.d.ts.map +1 -0
  35. package/dist/utils/init/quickstart-setup.js +462 -0
  36. package/dist/utils/init/quickstart-setup.js.map +1 -0
  37. package/dist/utils/init/types.d.ts +4 -0
  38. package/dist/utils/init/types.d.ts.map +1 -1
  39. package/dist/utils/schema-sync.d.ts.map +1 -1
  40. package/dist/utils/schema-sync.js +27 -21
  41. package/dist/utils/schema-sync.js.map +1 -1
  42. package/package.json +3 -2
  43. package/templates/vercel-ai-quickstart/.env.local.example +45 -0
  44. package/templates/vercel-ai-quickstart/README.md +280 -0
  45. package/templates/vercel-ai-quickstart/app/api/chat/route.ts +196 -0
  46. package/templates/vercel-ai-quickstart/app/api/facts/route.ts +39 -0
  47. package/templates/vercel-ai-quickstart/app/api/health/route.ts +99 -0
  48. package/templates/vercel-ai-quickstart/app/api/memories/route.ts +37 -0
  49. package/templates/vercel-ai-quickstart/app/globals.css +114 -0
  50. package/templates/vercel-ai-quickstart/app/layout.tsx +19 -0
  51. package/templates/vercel-ai-quickstart/app/page.tsx +131 -0
  52. package/templates/vercel-ai-quickstart/components/ChatInterface.tsx +237 -0
  53. package/templates/vercel-ai-quickstart/components/ConvexClientProvider.tsx +21 -0
  54. package/templates/vercel-ai-quickstart/components/DataPreview.tsx +57 -0
  55. package/templates/vercel-ai-quickstart/components/HealthStatus.tsx +214 -0
  56. package/templates/vercel-ai-quickstart/components/LayerCard.tsx +263 -0
  57. package/templates/vercel-ai-quickstart/components/LayerFlowDiagram.tsx +195 -0
  58. package/templates/vercel-ai-quickstart/components/MemorySpaceSwitcher.tsx +93 -0
  59. package/templates/vercel-ai-quickstart/convex/conversations.ts +67 -0
  60. package/templates/vercel-ai-quickstart/convex/facts.ts +131 -0
  61. package/templates/vercel-ai-quickstart/convex/health.ts +15 -0
  62. package/templates/vercel-ai-quickstart/convex/memories.ts +104 -0
  63. package/templates/vercel-ai-quickstart/convex/schema.ts +20 -0
  64. package/templates/vercel-ai-quickstart/convex/users.ts +105 -0
  65. package/templates/vercel-ai-quickstart/lib/animations.ts +146 -0
  66. package/templates/vercel-ai-quickstart/lib/layer-tracking.ts +214 -0
  67. package/templates/vercel-ai-quickstart/next.config.js +7 -0
  68. package/templates/vercel-ai-quickstart/package.json +41 -0
  69. package/templates/vercel-ai-quickstart/postcss.config.js +5 -0
  70. package/templates/vercel-ai-quickstart/tailwind.config.js +37 -0
  71. package/templates/vercel-ai-quickstart/tsconfig.json +33 -0
@@ -0,0 +1,105 @@
1
+ /**
2
+ * Convex queries for user profile data
3
+ *
4
+ * These queries enable the LayerFlowDiagram to show user context
5
+ * during memory orchestration.
6
+ */
7
+
8
+ import { query } from "./_generated/server";
9
+ import { v } from "convex/values";
10
+
11
+ /**
12
+ * Get user profile by ID
13
+ *
14
+ * Returns user information stored in the Cortex system.
15
+ */
16
+ export const get = query({
17
+ args: {
18
+ userId: v.string(),
19
+ memorySpaceId: v.string(),
20
+ },
21
+ handler: async (ctx, args) => {
22
+ // Query users table (from Cortex SDK schema)
23
+ const user = await ctx.db
24
+ .query("users")
25
+ .filter((q) =>
26
+ q.and(
27
+ q.eq(q.field("userId"), args.userId),
28
+ q.eq(q.field("memorySpaceId"), args.memorySpaceId),
29
+ ),
30
+ )
31
+ .first();
32
+
33
+ return user;
34
+ },
35
+ });
36
+
37
+ /**
38
+ * Get users in a memory space
39
+ */
40
+ export const list = query({
41
+ args: {
42
+ memorySpaceId: v.string(),
43
+ limit: v.optional(v.number()),
44
+ },
45
+ handler: async (ctx, args) => {
46
+ const limit = args.limit ?? 20;
47
+
48
+ const users = await ctx.db
49
+ .query("users")
50
+ .filter((q) => q.eq(q.field("memorySpaceId"), args.memorySpaceId))
51
+ .take(limit);
52
+
53
+ return users;
54
+ },
55
+ });
56
+
57
+ /**
58
+ * Get user stats (memory count, fact count, etc.)
59
+ */
60
+ export const stats = query({
61
+ args: {
62
+ userId: v.string(),
63
+ memorySpaceId: v.string(),
64
+ },
65
+ handler: async (ctx, args) => {
66
+ // Count memories
67
+ const memories = await ctx.db
68
+ .query("memories")
69
+ .filter((q) =>
70
+ q.and(
71
+ q.eq(q.field("userId"), args.userId),
72
+ q.eq(q.field("memorySpaceId"), args.memorySpaceId),
73
+ ),
74
+ )
75
+ .collect();
76
+
77
+ // Count facts
78
+ const facts = await ctx.db
79
+ .query("facts")
80
+ .filter((q) =>
81
+ q.and(
82
+ q.eq(q.field("userId"), args.userId),
83
+ q.eq(q.field("memorySpaceId"), args.memorySpaceId),
84
+ ),
85
+ )
86
+ .collect();
87
+
88
+ // Count conversations
89
+ const conversations = await ctx.db
90
+ .query("conversations")
91
+ .filter((q) =>
92
+ q.and(
93
+ q.eq(q.field("userId"), args.userId),
94
+ q.eq(q.field("memorySpaceId"), args.memorySpaceId),
95
+ ),
96
+ )
97
+ .collect();
98
+
99
+ return {
100
+ memoryCount: memories.length,
101
+ factCount: facts.length,
102
+ conversationCount: conversations.length,
103
+ };
104
+ },
105
+ });
@@ -0,0 +1,146 @@
1
+ import type { Variants } from "framer-motion";
2
+
3
+ /**
4
+ * Framer Motion animation variants for the layer flow visualization
5
+ */
6
+
7
+ // Layer card entrance animation
8
+ export const layerCardVariants: Variants = {
9
+ hidden: {
10
+ opacity: 0,
11
+ x: -20,
12
+ scale: 0.95,
13
+ },
14
+ visible: (i: number) => ({
15
+ opacity: 1,
16
+ x: 0,
17
+ scale: 1,
18
+ transition: {
19
+ delay: i * 0.1,
20
+ duration: 0.3,
21
+ ease: "easeOut",
22
+ },
23
+ }),
24
+ exit: {
25
+ opacity: 0,
26
+ x: 20,
27
+ transition: {
28
+ duration: 0.2,
29
+ },
30
+ },
31
+ };
32
+
33
+ // Status indicator pulse animation
34
+ export const statusPulseVariants: Variants = {
35
+ pending: {
36
+ scale: 1,
37
+ opacity: 0.5,
38
+ },
39
+ processing: {
40
+ scale: [1, 1.2, 1],
41
+ opacity: [0.5, 1, 0.5],
42
+ transition: {
43
+ duration: 1,
44
+ repeat: Infinity,
45
+ ease: "easeInOut",
46
+ },
47
+ },
48
+ complete: {
49
+ scale: [1, 1.3, 1],
50
+ opacity: 1,
51
+ transition: {
52
+ duration: 0.3,
53
+ ease: "easeOut",
54
+ },
55
+ },
56
+ };
57
+
58
+ // Flow line animation
59
+ export const flowLineVariants: Variants = {
60
+ idle: {
61
+ opacity: 0.2,
62
+ pathLength: 0,
63
+ },
64
+ flowing: {
65
+ opacity: [0.2, 1, 0.2],
66
+ pathLength: [0, 1, 0],
67
+ transition: {
68
+ duration: 1.5,
69
+ repeat: Infinity,
70
+ ease: "easeInOut",
71
+ },
72
+ },
73
+ complete: {
74
+ opacity: 1,
75
+ pathLength: 1,
76
+ },
77
+ };
78
+
79
+ // Data preview expand animation
80
+ export const dataPreviewVariants: Variants = {
81
+ collapsed: {
82
+ height: 0,
83
+ opacity: 0,
84
+ },
85
+ expanded: {
86
+ height: "auto",
87
+ opacity: 1,
88
+ transition: {
89
+ height: {
90
+ duration: 0.3,
91
+ ease: "easeOut",
92
+ },
93
+ opacity: {
94
+ duration: 0.2,
95
+ delay: 0.1,
96
+ },
97
+ },
98
+ },
99
+ };
100
+
101
+ // Message animation
102
+ export const messageVariants: Variants = {
103
+ hidden: {
104
+ opacity: 0,
105
+ y: 10,
106
+ scale: 0.95,
107
+ },
108
+ visible: {
109
+ opacity: 1,
110
+ y: 0,
111
+ scale: 1,
112
+ transition: {
113
+ duration: 0.2,
114
+ ease: "easeOut",
115
+ },
116
+ },
117
+ };
118
+
119
+ // Stagger children animation
120
+ export const staggerContainerVariants: Variants = {
121
+ hidden: { opacity: 0 },
122
+ visible: {
123
+ opacity: 1,
124
+ transition: {
125
+ staggerChildren: 0.1,
126
+ delayChildren: 0.2,
127
+ },
128
+ },
129
+ };
130
+
131
+ // Glow effect animation (for completed layers)
132
+ export const glowVariants: Variants = {
133
+ idle: {
134
+ boxShadow: "0 0 0 0 rgba(34, 197, 94, 0)",
135
+ },
136
+ glow: {
137
+ boxShadow: [
138
+ "0 0 0 0 rgba(34, 197, 94, 0.4)",
139
+ "0 0 0 10px rgba(34, 197, 94, 0)",
140
+ ],
141
+ transition: {
142
+ duration: 0.6,
143
+ ease: "easeOut",
144
+ },
145
+ },
146
+ };
@@ -0,0 +1,214 @@
1
+ "use client";
2
+
3
+ import { useState, useCallback } from "react";
4
+
5
+ // Layer types (defined locally to avoid import issues before npm install)
6
+ export type MemoryLayer =
7
+ | "memorySpace"
8
+ | "user"
9
+ | "agent"
10
+ | "conversation"
11
+ | "vector"
12
+ | "facts"
13
+ | "graph";
14
+
15
+ export type LayerStatus =
16
+ | "pending"
17
+ | "in_progress"
18
+ | "complete"
19
+ | "error"
20
+ | "skipped";
21
+
22
+ /**
23
+ * Revision action taken by the belief revision system (v0.24.0+)
24
+ * - ADD: New fact was created (no conflicts)
25
+ * - UPDATE: Existing fact was updated with new information
26
+ * - SUPERSEDE: Old fact was superseded by contradicting information
27
+ * - NONE: No action taken (duplicate or irrelevant)
28
+ */
29
+ export type RevisionAction = "ADD" | "UPDATE" | "SUPERSEDE" | "NONE";
30
+
31
+ export interface LayerState {
32
+ status: LayerStatus;
33
+ latencyMs?: number;
34
+ data?: {
35
+ id?: string;
36
+ preview?: string;
37
+ metadata?: Record<string, unknown>;
38
+ };
39
+ startedAt?: number;
40
+ completedAt?: number;
41
+ /**
42
+ * Revision action taken (v0.24.0+)
43
+ * Only present for facts layer when belief revision is enabled
44
+ */
45
+ revisionAction?: RevisionAction;
46
+ /**
47
+ * Facts that were superseded by this action (v0.24.0+)
48
+ * Only present when revisionAction is "SUPERSEDE"
49
+ */
50
+ supersededFacts?: string[];
51
+ }
52
+
53
+ export interface LayerTrackingState {
54
+ layers: Record<string, LayerState>;
55
+ isOrchestrating: boolean;
56
+ orchestrationStartTime?: number;
57
+ }
58
+
59
+ const initialLayerState: LayerState = {
60
+ status: "pending",
61
+ };
62
+
63
+ const allLayers: MemoryLayer[] = [
64
+ "memorySpace",
65
+ "user",
66
+ "agent",
67
+ "conversation",
68
+ "vector",
69
+ "facts",
70
+ "graph",
71
+ ];
72
+
73
+ export function useLayerTracking() {
74
+ const [state, setState] = useState<LayerTrackingState>({
75
+ layers: Object.fromEntries(
76
+ allLayers.map((layer) => [layer, { ...initialLayerState }]),
77
+ ),
78
+ isOrchestrating: false,
79
+ });
80
+
81
+ const startOrchestration = useCallback(() => {
82
+ const now = Date.now();
83
+ setState({
84
+ layers: Object.fromEntries(
85
+ allLayers.map((layer) => [
86
+ layer,
87
+ { status: "pending" as LayerStatus, startedAt: now },
88
+ ]),
89
+ ),
90
+ isOrchestrating: true,
91
+ orchestrationStartTime: now,
92
+ });
93
+ }, []);
94
+
95
+ const updateLayer = useCallback(
96
+ (
97
+ layer: MemoryLayer,
98
+ status: LayerStatus,
99
+ data?: LayerState["data"],
100
+ revisionInfo?: {
101
+ action?: RevisionAction;
102
+ supersededFacts?: string[];
103
+ },
104
+ ) => {
105
+ setState((prev: LayerTrackingState) => {
106
+ const now = Date.now();
107
+ const layerState = prev.layers[layer];
108
+ const latencyMs = layerState?.startedAt
109
+ ? now - layerState.startedAt
110
+ : prev.orchestrationStartTime
111
+ ? now - prev.orchestrationStartTime
112
+ : undefined;
113
+
114
+ // Check if all layers are complete
115
+ const updatedLayers: Record<string, LayerState> = {
116
+ ...prev.layers,
117
+ [layer]: {
118
+ ...layerState,
119
+ status,
120
+ latencyMs,
121
+ data,
122
+ completedAt: status === "complete" ? now : layerState?.completedAt,
123
+ // Belief revision info (v0.24.0+)
124
+ revisionAction: revisionInfo?.action,
125
+ supersededFacts: revisionInfo?.supersededFacts,
126
+ },
127
+ };
128
+
129
+ const isStillOrchestrating = Object.values(updatedLayers).some(
130
+ (l: LayerState) =>
131
+ l.status === "pending" || l.status === "in_progress",
132
+ );
133
+
134
+ return {
135
+ ...prev,
136
+ layers: updatedLayers,
137
+ isOrchestrating: isStillOrchestrating,
138
+ };
139
+ });
140
+ },
141
+ [],
142
+ );
143
+
144
+ const resetLayers = useCallback(() => {
145
+ setState({
146
+ layers: Object.fromEntries(
147
+ allLayers.map((layer) => [layer, { ...initialLayerState }]),
148
+ ),
149
+ isOrchestrating: false,
150
+ });
151
+ }, []);
152
+
153
+ return {
154
+ layers: state.layers,
155
+ isOrchestrating: state.isOrchestrating,
156
+ startOrchestration,
157
+ updateLayer,
158
+ resetLayers,
159
+ };
160
+ }
161
+
162
+ /**
163
+ * Generate sample data for layer previews (used in demos)
164
+ */
165
+ export function generateSampleLayerData(
166
+ layer: MemoryLayer,
167
+ userMessage?: string,
168
+ ): LayerState["data"] {
169
+ switch (layer) {
170
+ case "memorySpace":
171
+ return {
172
+ id: "quickstart-demo",
173
+ preview: "Memory space for demo",
174
+ metadata: { isolation: "full" },
175
+ };
176
+ case "user":
177
+ return {
178
+ id: "demo-user",
179
+ preview: "Demo User",
180
+ metadata: { memories: 5 },
181
+ };
182
+ case "agent":
183
+ return {
184
+ id: "quickstart-assistant",
185
+ preview: "Cortex Demo Assistant",
186
+ };
187
+ case "conversation":
188
+ return {
189
+ id: `conv-${Date.now()}`,
190
+ preview: userMessage?.slice(0, 50) || "New conversation",
191
+ metadata: { messages: 2 },
192
+ };
193
+ case "vector":
194
+ return {
195
+ id: `mem-${Date.now()}`,
196
+ preview: "Embedded content...",
197
+ metadata: { dimensions: 1536, importance: 75 },
198
+ };
199
+ case "facts":
200
+ return {
201
+ id: `fact-${Date.now()}`,
202
+ preview: "Extracted facts from conversation",
203
+ metadata: { count: 3, types: ["identity", "preference"] },
204
+ };
205
+ case "graph":
206
+ return {
207
+ id: `graph-sync-${Date.now()}`,
208
+ preview: "Entity relationships",
209
+ metadata: { nodes: 4, edges: 3 },
210
+ };
211
+ default:
212
+ return undefined;
213
+ }
214
+ }
@@ -0,0 +1,7 @@
1
+ /** @type {import('next').NextConfig} */
2
+ const nextConfig = {
3
+ transpilePackages: ["@cortexmemory/sdk", "@cortexmemory/vercel-ai-provider"],
4
+ serverExternalPackages: ["convex"],
5
+ };
6
+
7
+ module.exports = nextConfig;
@@ -0,0 +1,41 @@
1
+ {
2
+ "name": "@cortexmemory/vercel-ai-quickstart",
3
+ "version": "1.0.0",
4
+ "private": true,
5
+ "license": "UNLICENSED",
6
+ "description": "Cortex Memory + Vercel AI SDK Quickstart Demo",
7
+ "scripts": {
8
+ "dev": "next dev",
9
+ "build": "next build",
10
+ "start": "next start",
11
+ "lint": "next lint",
12
+ "convex:dev": "convex dev",
13
+ "convex:deploy": "convex deploy"
14
+ },
15
+ "dependencies": {
16
+ "@ai-sdk/openai": "^3.0.1",
17
+ "@ai-sdk/react": "^3.0.3",
18
+ "@anthropic-ai/sdk": "^0.71.2",
19
+ "@cortexmemory/sdk": "file:../../..",
20
+ "@cortexmemory/vercel-ai-provider": "file:..",
21
+ "ai": "^6.0.3",
22
+ "convex": "^1.31.2",
23
+ "framer-motion": "^12.23.26",
24
+ "neo4j-driver": "^6.0.1",
25
+ "next": "^16.1.1",
26
+ "openai": "^6.15.0",
27
+ "react": "^19.2.3",
28
+ "react-dom": "^19.2.3",
29
+ "zod": "^4.2.1"
30
+ },
31
+ "devDependencies": {
32
+ "@tailwindcss/postcss": "^4.1.18",
33
+ "@types/node": "^25.0.3",
34
+ "@types/react": "^19.2.7",
35
+ "@types/react-dom": "^19.2.3",
36
+ "autoprefixer": "^10.4.23",
37
+ "postcss": "^8.5.6",
38
+ "tailwindcss": "^4.1.18",
39
+ "typescript": "^5.9.3"
40
+ }
41
+ }
@@ -0,0 +1,5 @@
1
+ module.exports = {
2
+ plugins: {
3
+ "@tailwindcss/postcss": {},
4
+ },
5
+ };
@@ -0,0 +1,37 @@
1
+ /** @type {import('tailwindcss').Config} */
2
+ module.exports = {
3
+ content: [
4
+ "./app/**/*.{js,ts,jsx,tsx,mdx}",
5
+ "./components/**/*.{js,ts,jsx,tsx,mdx}",
6
+ ],
7
+ theme: {
8
+ extend: {
9
+ colors: {
10
+ cortex: {
11
+ 50: "#f0f7ff",
12
+ 100: "#e0effe",
13
+ 200: "#b9dffc",
14
+ 300: "#7cc5fa",
15
+ 400: "#36a8f5",
16
+ 500: "#0c8ce6",
17
+ 600: "#006fc4",
18
+ 700: "#0159a0",
19
+ 800: "#064b84",
20
+ 900: "#0b3f6d",
21
+ 950: "#072848",
22
+ },
23
+ },
24
+ animation: {
25
+ "pulse-slow": "pulse 3s cubic-bezier(0.4, 0, 0.6, 1) infinite",
26
+ flow: "flow 2s ease-in-out infinite",
27
+ },
28
+ keyframes: {
29
+ flow: {
30
+ "0%, 100%": { opacity: "0.3" },
31
+ "50%": { opacity: "1" },
32
+ },
33
+ },
34
+ },
35
+ },
36
+ plugins: [],
37
+ };
@@ -0,0 +1,33 @@
1
+ {
2
+ "compilerOptions": {
3
+ "target": "ES2020",
4
+ "lib": ["dom", "dom.iterable", "esnext"],
5
+ "allowJs": true,
6
+ "skipLibCheck": true,
7
+ "strict": true,
8
+ "noEmit": true,
9
+ "esModuleInterop": true,
10
+ "module": "esnext",
11
+ "moduleResolution": "bundler",
12
+ "resolveJsonModule": true,
13
+ "isolatedModules": true,
14
+ "jsx": "react-jsx",
15
+ "incremental": true,
16
+ "plugins": [
17
+ {
18
+ "name": "next"
19
+ }
20
+ ],
21
+ "paths": {
22
+ "@/*": ["./*"]
23
+ }
24
+ },
25
+ "include": [
26
+ "next-env.d.ts",
27
+ "**/*.ts",
28
+ "**/*.tsx",
29
+ ".next/types/**/*.ts",
30
+ ".next/dev/types/**/*.ts"
31
+ ],
32
+ "exclude": ["node_modules", "convex"]
33
+ }