next-ai-editor 0.1.3 → 0.2.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 (63) hide show
  1. package/dist/AIEditorProvider-CKA2K_g2.js +1428 -0
  2. package/dist/AIEditorProvider-CKA2K_g2.js.map +1 -0
  3. package/dist/AIEditorProvider-C_zRSAuV.cjs +1427 -0
  4. package/dist/AIEditorProvider-C_zRSAuV.cjs.map +1 -0
  5. package/dist/client/AIEditorProvider.d.ts +1 -33
  6. package/dist/client/AIEditorProvider.d.ts.map +1 -1
  7. package/dist/client/components/ChatPanel.d.ts +18 -0
  8. package/dist/client/components/ChatPanel.d.ts.map +1 -0
  9. package/dist/client/components/ControlPill.d.ts +8 -0
  10. package/dist/client/components/ControlPill.d.ts.map +1 -0
  11. package/dist/client/components/MessageItem.d.ts +7 -0
  12. package/dist/client/components/MessageItem.d.ts.map +1 -0
  13. package/dist/client/components/MessageList.d.ts +7 -0
  14. package/dist/client/components/MessageList.d.ts.map +1 -0
  15. package/dist/client/components/TaskHistoryPanel.d.ts +10 -0
  16. package/dist/client/components/TaskHistoryPanel.d.ts.map +1 -0
  17. package/dist/client/components/index.d.ts +11 -0
  18. package/dist/client/components/index.d.ts.map +1 -0
  19. package/dist/client/hooks/index.d.ts +3 -0
  20. package/dist/client/hooks/index.d.ts.map +1 -0
  21. package/dist/client/hooks/useChatStream.d.ts +66 -0
  22. package/dist/client/hooks/useChatStream.d.ts.map +1 -0
  23. package/dist/client/hooks/useHotReload.d.ts +10 -0
  24. package/dist/client/hooks/useHotReload.d.ts.map +1 -0
  25. package/dist/client/index.d.ts +3 -0
  26. package/dist/client/index.d.ts.map +1 -1
  27. package/dist/client.cjs +7 -1
  28. package/dist/client.cjs.map +1 -1
  29. package/dist/client.js +8 -2
  30. package/dist/client.js.map +1 -1
  31. package/dist/{index-DrmEf13c.js → comments-D3m0RsOO.js} +440 -15
  32. package/dist/comments-D3m0RsOO.js.map +1 -0
  33. package/dist/{index-CNJqd4EQ.cjs → comments-Daur80r4.cjs} +426 -1
  34. package/dist/comments-Daur80r4.cjs.map +1 -0
  35. package/dist/index.cjs +34 -27
  36. package/dist/index.cjs.map +1 -1
  37. package/dist/index.js +22 -15
  38. package/dist/index.js.map +1 -1
  39. package/dist/next-ai-editor.css +880 -0
  40. package/dist/server/agent/sdk-client.d.ts +54 -0
  41. package/dist/server/agent/sdk-client.d.ts.map +1 -0
  42. package/dist/server/agent/session-store.d.ts +101 -0
  43. package/dist/server/agent/session-store.d.ts.map +1 -0
  44. package/dist/server/handlers/chat.d.ts +6 -0
  45. package/dist/server/handlers/chat.d.ts.map +1 -0
  46. package/dist/server/handlers/comments.d.ts +10 -0
  47. package/dist/server/handlers/comments.d.ts.map +1 -0
  48. package/dist/server/handlers/index.d.ts +2 -1
  49. package/dist/server/handlers/index.d.ts.map +1 -1
  50. package/dist/server/index.d.ts +1 -0
  51. package/dist/server/index.d.ts.map +1 -1
  52. package/dist/server.cjs +27 -26
  53. package/dist/server.cjs.map +1 -1
  54. package/dist/server.js +14 -13
  55. package/dist/shared/comment-types.d.ts +140 -0
  56. package/dist/shared/comment-types.d.ts.map +1 -0
  57. package/package.json +13 -4
  58. package/dist/AIEditorProvider-BGHm2xyU.cjs +0 -2167
  59. package/dist/AIEditorProvider-BGHm2xyU.cjs.map +0 -1
  60. package/dist/AIEditorProvider-CxdGjdLL.js +0 -2168
  61. package/dist/AIEditorProvider-CxdGjdLL.js.map +0 -1
  62. package/dist/index-CNJqd4EQ.cjs.map +0 -1
  63. package/dist/index-DrmEf13c.js.map +0 -1
@@ -0,0 +1,54 @@
1
+ import { type SDKMessage } from "@anthropic-ai/claude-agent-sdk";
2
+ /**
3
+ * Configuration for the AI editor agent
4
+ */
5
+ export interface AIEditorAgentConfig {
6
+ apiKey: string;
7
+ projectRoot: string;
8
+ sessionId?: string;
9
+ allowedTools?: string[];
10
+ disallowedTools?: string[];
11
+ }
12
+ /**
13
+ * Context about the selected component (optional)
14
+ */
15
+ export interface ComponentContext {
16
+ filePath: string;
17
+ lineNumber: number;
18
+ componentName: string;
19
+ elementContext?: {
20
+ tagName?: string;
21
+ className?: string;
22
+ textContent?: string;
23
+ [key: string]: any;
24
+ };
25
+ }
26
+ /**
27
+ * Wrapper around Claude Agent SDK for the AI editor
28
+ */
29
+ export declare class AIEditorAgent {
30
+ private session;
31
+ private projectRoot;
32
+ private constructor();
33
+ /**
34
+ * Create a new agent instance
35
+ */
36
+ static create(config: AIEditorAgentConfig): Promise<AIEditorAgent>;
37
+ /**
38
+ * Send a message to the agent and stream responses
39
+ */
40
+ sendMessage(message: string, componentContext?: ComponentContext): AsyncGenerator<SDKMessage, void, unknown>;
41
+ /**
42
+ * Get the session ID
43
+ */
44
+ getSessionId(): string;
45
+ /**
46
+ * Close the session
47
+ */
48
+ close(): void;
49
+ /**
50
+ * Async disposal support
51
+ */
52
+ [Symbol.asyncDispose](): Promise<void>;
53
+ }
54
+ //# sourceMappingURL=sdk-client.d.ts.map
@@ -0,0 +1 @@
1
+ {"version":3,"file":"sdk-client.d.ts","sourceRoot":"","sources":["../../../src/server/agent/sdk-client.ts"],"names":[],"mappings":"AAAA,OAAO,EAKL,KAAK,UAAU,EAChB,MAAM,gCAAgC,CAAC;AAExC;;GAEG;AACH,MAAM,WAAW,mBAAmB;IAClC,MAAM,EAAE,MAAM,CAAC;IACf,WAAW,EAAE,MAAM,CAAC;IACpB,SAAS,CAAC,EAAE,MAAM,CAAC;IACnB,YAAY,CAAC,EAAE,MAAM,EAAE,CAAC;IACxB,eAAe,CAAC,EAAE,MAAM,EAAE,CAAC;CAC5B;AAED;;GAEG;AACH,MAAM,WAAW,gBAAgB;IAC/B,QAAQ,EAAE,MAAM,CAAC;IACjB,UAAU,EAAE,MAAM,CAAC;IACnB,aAAa,EAAE,MAAM,CAAC;IACtB,cAAc,CAAC,EAAE;QACf,OAAO,CAAC,EAAE,MAAM,CAAC;QACjB,SAAS,CAAC,EAAE,MAAM,CAAC;QACnB,WAAW,CAAC,EAAE,MAAM,CAAC;QACrB,CAAC,GAAG,EAAE,MAAM,GAAG,GAAG,CAAC;KACpB,CAAC;CACH;AAED;;GAEG;AACH,qBAAa,aAAa;IACxB,OAAO,CAAC,OAAO,CAAa;IAC5B,OAAO,CAAC,WAAW,CAAS;IAE5B,OAAO;IAKP;;OAEG;WACU,MAAM,CAAC,MAAM,EAAE,mBAAmB,GAAG,OAAO,CAAC,aAAa,CAAC;IA4BxE;;OAEG;IACI,WAAW,CAChB,OAAO,EAAE,MAAM,EACf,gBAAgB,CAAC,EAAE,gBAAgB,GAClC,cAAc,CAAC,UAAU,EAAE,IAAI,EAAE,OAAO,CAAC;IA6B5C;;OAEG;IACH,YAAY,IAAI,MAAM;IAItB;;OAEG;IACH,KAAK,IAAI,IAAI;IAIb;;OAEG;IACG,CAAC,MAAM,CAAC,YAAY,CAAC,IAAI,OAAO,CAAC,IAAI,CAAC;CAG7C"}
@@ -0,0 +1,101 @@
1
+ import { AIEditorAgent } from "./sdk-client.js";
2
+ /**
3
+ * Represents an active agent session
4
+ */
5
+ export interface AgentSession {
6
+ sessionId: string;
7
+ threadId: string;
8
+ agent: AIEditorAgent;
9
+ createdAt: number;
10
+ lastActive: number;
11
+ isLocked: boolean;
12
+ }
13
+ /**
14
+ * Configuration for creating a new session
15
+ */
16
+ export interface CreateSessionConfig {
17
+ sessionId?: string;
18
+ threadId: string;
19
+ apiKey: string;
20
+ projectRoot: string;
21
+ allowedTools?: string[];
22
+ disallowedTools?: string[];
23
+ }
24
+ /**
25
+ * Manages agent sessions across requests
26
+ * Sessions are stored in-memory and automatically cleaned up after inactivity
27
+ */
28
+ export declare class AgentSessionStore {
29
+ private sessions;
30
+ private readonly SESSION_TIMEOUT;
31
+ private readonly CLEANUP_INTERVAL;
32
+ constructor();
33
+ /**
34
+ * Create or resume a session
35
+ */
36
+ createSession(config: CreateSessionConfig): Promise<AgentSession>;
37
+ /**
38
+ * Get a session by ID
39
+ */
40
+ getSession(sessionId: string): AgentSession | undefined;
41
+ /**
42
+ * Acquire a lock on a session to prevent concurrent edits
43
+ * Returns true if lock was acquired, false if already locked
44
+ */
45
+ acquireLock(sessionId: string): boolean;
46
+ /**
47
+ * Release a lock on a session
48
+ */
49
+ releaseLock(sessionId: string): void;
50
+ /**
51
+ * Check if any session is currently locked (to prevent concurrent edits)
52
+ */
53
+ hasActiveLock(): boolean;
54
+ /**
55
+ * Get all active sessions for a thread
56
+ */
57
+ getSessionsByThread(threadId: string): AgentSession[];
58
+ /**
59
+ * Delete a session
60
+ */
61
+ deleteSession(sessionId: string): void;
62
+ /**
63
+ * Delete all sessions for a thread
64
+ */
65
+ deleteSessionsByThread(threadId: string): void;
66
+ /**
67
+ * Get all active sessions
68
+ */
69
+ getAllSessions(): AgentSession[];
70
+ /**
71
+ * Clean up expired sessions
72
+ */
73
+ private cleanupExpiredSessions;
74
+ /**
75
+ * Start periodic cleanup timer
76
+ */
77
+ private startCleanupTimer;
78
+ /**
79
+ * Generate a unique session ID
80
+ */
81
+ private generateSessionId;
82
+ /**
83
+ * Get statistics about the session store
84
+ */
85
+ getStats(): {
86
+ totalSessions: number;
87
+ lockedSessions: number;
88
+ sessions: {
89
+ sessionId: string;
90
+ threadId: string;
91
+ isLocked: boolean;
92
+ ageMinutes: number;
93
+ inactiveMinutes: number;
94
+ }[];
95
+ };
96
+ }
97
+ /**
98
+ * Get the global session store instance
99
+ */
100
+ export declare function getSessionStore(): AgentSessionStore;
101
+ //# sourceMappingURL=session-store.d.ts.map
@@ -0,0 +1 @@
1
+ {"version":3,"file":"session-store.d.ts","sourceRoot":"","sources":["../../../src/server/agent/session-store.ts"],"names":[],"mappings":"AAAA,OAAO,EAAE,aAAa,EAA4B,MAAM,iBAAiB,CAAC;AAE1E;;GAEG;AACH,MAAM,WAAW,YAAY;IAC3B,SAAS,EAAE,MAAM,CAAC;IAClB,QAAQ,EAAE,MAAM,CAAC;IACjB,KAAK,EAAE,aAAa,CAAC;IACrB,SAAS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EG;AACH,wBAAgB,eAAe,IAAI,iBAAiB,CAKnD"}
@@ -0,0 +1,6 @@
1
+ import { NextRequest } from "next/server";
2
+ /**
3
+ * Handle chat requests with SSE streaming
4
+ */
5
+ export declare function handleChat(req: NextRequest): Promise<Response>;
6
+ //# sourceMappingURL=chat.d.ts.map
@@ -0,0 +1 @@
1
+ {"version":3,"file":"chat.d.ts","sourceRoot":"","sources":["../../../src/server/handlers/chat.ts"],"names":[],"mappings":"AAKA,OAAO,EAAE,WAAW,EAAgB,MAAM,aAAa,CAAC;AAYxD;;GAEG;AACH,wBAAsB,UAAU,CAAC,GAAG,EAAE,WAAW,GAAG,OAAO,CAAC,QAAQ,CAAC,CAgHpE"}
@@ -0,0 +1,10 @@
1
+ /**
2
+ * Comment persistence handler
3
+ * Saves/loads comments to/from .ai-editor/comments.json
4
+ */
5
+ import { NextRequest, NextResponse } from "next/server";
6
+ /**
7
+ * Handle comment persistence requests
8
+ */
9
+ export declare function handleCommentsRequest(request: NextRequest): Promise<NextResponse>;
10
+ //# sourceMappingURL=comments.d.ts.map
@@ -0,0 +1 @@
1
+ {"version":3,"file":"comments.d.ts","sourceRoot":"","sources":["../../../src/server/handlers/comments.ts"],"names":[],"mappings":"AAAA;;;GAGG;AAEH,OAAO,EAAE,WAAW,EAAE,YAAY,EAAE,MAAM,aAAa,CAAC;AAgCxD;;GAEG;AACH,wBAAsB,qBAAqB,CACzC,OAAO,EAAE,WAAW,GACnB,OAAO,CAAC,YAAY,CAAC,CAmEvB"}
@@ -10,10 +10,11 @@ import { NextRequest, NextResponse } from "next/server";
10
10
  * - GET /api/ai-editor/absolute-path -> handleAbsolutePath
11
11
  * - POST /api/ai-editor/validate-session -> handleValidateSession
12
12
  * - GET /api/ai-editor/suggestions -> handleSuggestions
13
+ * - POST /api/ai-editor/chat -> handleChat (SSE)
13
14
  */
14
15
  export declare function handleAIEditorRequest(req: NextRequest, context: {
15
16
  params: Promise<{
16
17
  path: string[];
17
18
  }>;
18
- }): Promise<NextResponse>;
19
+ }): Promise<NextResponse | Response>;
19
20
  //# sourceMappingURL=index.d.ts.map
@@ -1 +1 @@
1
- {"version":3,"file":"index.d.ts","sourceRoot":"","sources":["../../../src/server/handlers/index.ts"],"names":[],"mappings":"AAKA,OAAO,EAAE,WAAW,EAAE,YAAY,EAAE,MAAM,aAAa,CAAC;AASxD;;;;;;;;;;;GAWG;AACH,wBAAsB,qBAAqB,CACzC,GAAG,EAAE,WAAW,EAChB,OAAO,EAAE;IAAE,MAAM,EAAE,OAAO,CAAC;QAAE,IAAI,EAAE,MAAM,EAAE,CAAA;KAAE,CAAC,CAAA;CAAE,GAC/C,OAAO,CAAC,YAAY,CAAC,CAiCvB"}
1
+ {"version":3,"file":"index.d.ts","sourceRoot":"","sources":["../../../src/server/handlers/index.ts"],"names":[],"mappings":"AAKA,OAAO,EAAE,WAAW,EAAE,YAAY,EAAE,MAAM,aAAa,CAAC;AAUxD;;;;;;;;;;;;GAYG;AACH,wBAAsB,qBAAqB,CACzC,GAAG,EAAE,WAAW,EAChB,OAAO,EAAE;IAAE,MAAM,EAAE,OAAO,CAAC;QAAE,IAAI,EAAE,MAAM,EAAE,CAAA;KAAE,CAAC,CAAA;CAAE,GAC/C,OAAO,CAAC,YAAY,GAAG,QAAQ,CAAC,CAoClC"}
@@ -6,6 +6,7 @@ export { handleResolve } from "./handlers/resolve";
6
6
  export { handleAbsolutePath } from "./handlers/absolute-path";
7
7
  export { handleValidateSession } from "./handlers/validate-session";
8
8
  export { handleSuggestions } from "./handlers/suggestions";
9
+ export { handleCommentsRequest } from "./handlers/comments";
9
10
  export * from "./utils/file-system";
10
11
  export * from "./utils/ast";
11
12
  export * from "./utils/source-map";
@@ -1 +1 @@
1
- {"version":3,"file":"index.d.ts","sourceRoot":"","sources":["../../src/server/index.ts"],"names":[],"mappings":"AACA,OAAO,EAAE,qBAAqB,EAAE,MAAM,YAAY,CAAC;AAGnD,OAAO,EAAE,UAAU,EAAE,MAAM,iBAAiB,CAAC;AAC7C,OAAO,EAAE,UAAU,EAAE,MAAM,iBAAiB,CAAC;AAC7C,OAAO,EAAE,UAAU,EAAE,MAAM,iBAAiB,CAAC;AAC7C,OAAO,EAAE,aAAa,EAAE,MAAM,oBAAoB,CAAC;AACnD,OAAO,EAAE,kBAAkB,EAAE,MAAM,0BAA0B,CAAC;AAC9D,OAAO,EAAE,qBAAqB,EAAE,MAAM,6BAA6B,CAAC;AACpE,OAAO,EAAE,iBAAiB,EAAE,MAAM,wBAAwB,CAAC;AAG3D,cAAc,qBAAqB,CAAC;AACpC,cAAc,aAAa,CAAC;AAC5B,cAAc,oBAAoB,CAAC"}
1
+ {"version":3,"file":"index.d.ts","sourceRoot":"","sources":["../../src/server/index.ts"],"names":[],"mappings":"AACA,OAAO,EAAE,qBAAqB,EAAE,MAAM,YAAY,CAAC;AAGnD,OAAO,EAAE,UAAU,EAAE,MAAM,iBAAiB,CAAC;AAC7C,OAAO,EAAE,UAAU,EAAE,MAAM,iBAAiB,CAAC;AAC7C,OAAO,EAAE,UAAU,EAAE,MAAM,iBAAiB,CAAC;AAC7C,OAAO,EAAE,aAAa,EAAE,MAAM,oBAAoB,CAAC;AACnD,OAAO,EAAE,kBAAkB,EAAE,MAAM,0BAA0B,CAAC;AAC9D,OAAO,EAAE,qBAAqB,EAAE,MAAM,6BAA6B,CAAC;AACpE,OAAO,EAAE,iBAAiB,EAAE,MAAM,wBAAwB,CAAC;AAC3D,OAAO,EAAE,qBAAqB,EAAE,MAAM,qBAAqB,CAAC;AAG5D,cAAc,qBAAqB,CAAC;AACpC,cAAc,aAAa,CAAC;AAC5B,cAAc,oBAAoB,CAAC"}
package/dist/server.cjs CHANGED
@@ -1,29 +1,30 @@
1
1
  "use strict";
2
2
  Object.defineProperty(exports, Symbol.toStringTag, { value: "Module" });
3
- const index = require("./index-CNJqd4EQ.cjs");
4
- exports.extractComponentName = index.extractComponentName;
5
- exports.extractComponentNameFromStack = index.extractComponentNameFromStack;
6
- exports.fileExists = index.fileExists;
7
- exports.findTargetElement = index.findTargetElement;
8
- exports.getAttributeValue = index.getAttributeValue;
9
- exports.getJSXMemberName = index.getJSXMemberName;
10
- exports.getOriginalPositionFromDebugStack = index.getOriginalPositionFromDebugStack;
11
- exports.handleAIEditorRequest = index.handleAIEditorRequest;
12
- exports.handleAbsolutePath = index.handleAbsolutePath;
13
- exports.handleEdit = index.handleEdit;
14
- exports.handleRead = index.handleRead;
15
- exports.handleResolve = index.handleResolve;
16
- exports.handleSuggestions = index.handleSuggestions;
17
- exports.handleUndo = index.handleUndo;
18
- exports.handleValidateSession = index.handleValidateSession;
19
- exports.isPathSecure = index.isPathSecure;
20
- exports.normalizePath = index.normalizePath;
21
- exports.parseDebugStack = index.parseDebugStack;
22
- exports.parseDebugStackFrames = index.parseDebugStackFrames;
23
- exports.parseFile = index.parseFile;
24
- exports.resolveFilePath = index.resolveFilePath;
25
- exports.resolveOriginalPosition = index.resolveOriginalPosition;
26
- exports.scoreElementMatch = index.scoreElementMatch;
27
- exports.validateDevMode = index.validateDevMode;
28
- exports.validateGeneratedCode = index.validateGeneratedCode;
3
+ const comments = require("./comments-Daur80r4.cjs");
4
+ exports.extractComponentName = comments.extractComponentName;
5
+ exports.extractComponentNameFromStack = comments.extractComponentNameFromStack;
6
+ exports.fileExists = comments.fileExists;
7
+ exports.findTargetElement = comments.findTargetElement;
8
+ exports.getAttributeValue = comments.getAttributeValue;
9
+ exports.getJSXMemberName = comments.getJSXMemberName;
10
+ exports.getOriginalPositionFromDebugStack = comments.getOriginalPositionFromDebugStack;
11
+ exports.handleAIEditorRequest = comments.handleAIEditorRequest;
12
+ exports.handleAbsolutePath = comments.handleAbsolutePath;
13
+ exports.handleCommentsRequest = comments.handleCommentsRequest;
14
+ exports.handleEdit = comments.handleEdit;
15
+ exports.handleRead = comments.handleRead;
16
+ exports.handleResolve = comments.handleResolve;
17
+ exports.handleSuggestions = comments.handleSuggestions;
18
+ exports.handleUndo = comments.handleUndo;
19
+ exports.handleValidateSession = comments.handleValidateSession;
20
+ exports.isPathSecure = comments.isPathSecure;
21
+ exports.normalizePath = comments.normalizePath;
22
+ exports.parseDebugStack = comments.parseDebugStack;
23
+ exports.parseDebugStackFrames = comments.parseDebugStackFrames;
24
+ exports.parseFile = comments.parseFile;
25
+ exports.resolveFilePath = comments.resolveFilePath;
26
+ exports.resolveOriginalPosition = comments.resolveOriginalPosition;
27
+ exports.scoreElementMatch = comments.scoreElementMatch;
28
+ exports.validateDevMode = comments.validateDevMode;
29
+ exports.validateGeneratedCode = comments.validateGeneratedCode;
29
30
  //# sourceMappingURL=server.cjs.map
@@ -1 +1 @@
1
- {"version":3,"file":"server.cjs","sources":[],"sourcesContent":[],"names":[],"mappings":";;;;;;;;;;;;;;;;;;;;;;;;;;;;"}
1
+ {"version":3,"file":"server.cjs","sources":[],"sourcesContent":[],"names":[],"mappings":";;;;;;;;;;;;;;;;;;;;;;;;;;;;;"}
package/dist/server.js CHANGED
@@ -1,29 +1,30 @@
1
- import { k, u, j, m, q, o, y, h, e, a, b, d, g, c, f, i, n, t, w, p, r, x, s, v, l } from "./index-DrmEf13c.js";
1
+ import { l, w, k, o, t, q, z, h, e, i, a, b, d, g, c, f, j, n, u, x, p, r, y, s, v, m } from "./comments-D3m0RsOO.js";
2
2
  export {
3
- k as extractComponentName,
4
- u as extractComponentNameFromStack,
5
- j as fileExists,
6
- m as findTargetElement,
7
- q as getAttributeValue,
8
- o as getJSXMemberName,
9
- y as getOriginalPositionFromDebugStack,
3
+ l as extractComponentName,
4
+ w as extractComponentNameFromStack,
5
+ k as fileExists,
6
+ o as findTargetElement,
7
+ t as getAttributeValue,
8
+ q as getJSXMemberName,
9
+ z as getOriginalPositionFromDebugStack,
10
10
  h as handleAIEditorRequest,
11
11
  e as handleAbsolutePath,
12
+ i as handleCommentsRequest,
12
13
  a as handleEdit,
13
14
  b as handleRead,
14
15
  d as handleResolve,
15
16
  g as handleSuggestions,
16
17
  c as handleUndo,
17
18
  f as handleValidateSession,
18
- i as isPathSecure,
19
+ j as isPathSecure,
19
20
  n as normalizePath,
20
- t as parseDebugStack,
21
- w as parseDebugStackFrames,
21
+ u as parseDebugStack,
22
+ x as parseDebugStackFrames,
22
23
  p as parseFile,
23
24
  r as resolveFilePath,
24
- x as resolveOriginalPosition,
25
+ y as resolveOriginalPosition,
25
26
  s as scoreElementMatch,
26
27
  v as validateDevMode,
27
- l as validateGeneratedCode
28
+ m as validateGeneratedCode
28
29
  };
29
30
  //# sourceMappingURL=server.js.map
@@ -0,0 +1,140 @@
1
+ /**
2
+ * Types for Figma-style comment system
3
+ */
4
+ /**
5
+ * Simple message format for comment chat
6
+ */
7
+ export interface CommentMessage {
8
+ role: "user" | "assistant";
9
+ content: string;
10
+ }
11
+ /**
12
+ * Editor mode - determines click behavior
13
+ */
14
+ export type EditorMode = "select" | "comment" | "area" | "text";
15
+ /**
16
+ * Comment status during lifecycle
17
+ */
18
+ export type CommentStatus = "active" | "streaming" | "done" | "error";
19
+ /**
20
+ * Types of anchors for different selection modes
21
+ */
22
+ export type AnchorType = "coordinate" | "component" | "area" | "text";
23
+ /**
24
+ * Base point in 2D space
25
+ */
26
+ export interface Point {
27
+ x: number;
28
+ y: number;
29
+ }
30
+ /**
31
+ * Coordinate-based anchor (comment mode - click anywhere)
32
+ */
33
+ export interface CoordinateAnchor {
34
+ type: "coordinate";
35
+ x: number;
36
+ y: number;
37
+ pageX: number;
38
+ pageY: number;
39
+ }
40
+ /**
41
+ * Component-based anchor (component selection mode)
42
+ */
43
+ export interface ComponentAnchor {
44
+ type: "component";
45
+ componentName: string;
46
+ filePath: string;
47
+ lineNumber: number;
48
+ elementContext?: {
49
+ tagName?: string;
50
+ className?: string;
51
+ textContent?: string;
52
+ [key: string]: any;
53
+ };
54
+ lastKnownPosition: Point;
55
+ }
56
+ /**
57
+ * Area-based anchor (rectangle selection)
58
+ */
59
+ export interface AreaAnchor {
60
+ type: "area";
61
+ bounds: {
62
+ x: number;
63
+ y: number;
64
+ width: number;
65
+ height: number;
66
+ };
67
+ elements: string[];
68
+ }
69
+ /**
70
+ * Text-based anchor (text selection)
71
+ */
72
+ export interface TextAnchor {
73
+ type: "text";
74
+ selectedText: string;
75
+ containerSelector: string;
76
+ startOffset: number;
77
+ endOffset: number;
78
+ }
79
+ /**
80
+ * Union type for all anchor types
81
+ */
82
+ export type AnchorData = CoordinateAnchor | ComponentAnchor | AreaAnchor | TextAnchor;
83
+ /**
84
+ * Complete comment state
85
+ */
86
+ export interface CommentState {
87
+ id: string;
88
+ position: Point;
89
+ isMinimized: boolean;
90
+ isDragging: boolean;
91
+ anchorType: AnchorType;
92
+ anchorData: AnchorData;
93
+ messages: CommentMessage[];
94
+ sessionId: string;
95
+ threadId: string;
96
+ status: CommentStatus;
97
+ createdAt: number;
98
+ lastActive: number;
99
+ }
100
+ /**
101
+ * Task history item - aggregates messages by user request
102
+ */
103
+ export interface TaskHistoryItem {
104
+ id: string;
105
+ userRequest: string;
106
+ commentId: string;
107
+ status: "pending" | "done" | "failed";
108
+ actions: TaskAction[];
109
+ affectedFiles: string[];
110
+ anchorPosition?: Point;
111
+ createdAt: number;
112
+ completedAt?: number;
113
+ }
114
+ /**
115
+ * Individual action within a task
116
+ */
117
+ export interface TaskAction {
118
+ type: "tool_use" | "result" | "error";
119
+ tool?: string;
120
+ result?: string;
121
+ error?: string;
122
+ timestamp: number;
123
+ }
124
+ /**
125
+ * Editor state shape
126
+ */
127
+ export interface EditorState {
128
+ mode: EditorMode;
129
+ isPillVisible: boolean;
130
+ comments: Map<string, CommentState>;
131
+ taskHistory: TaskHistoryItem[];
132
+ selectedCommentId: string | null;
133
+ }
134
+ /**
135
+ * Serializable comment for file storage
136
+ */
137
+ export interface SerializableComment extends Omit<CommentState, "messages"> {
138
+ messages: any[];
139
+ }
140
+ //# sourceMappingURL=comment-types.d.ts.map
@@ -0,0 +1 @@
1
+ {"version":3,"file":"comment-types.d.ts","sourceRoot":"","sources":["../../src/shared/comment-types.ts"],"names":[],"mappings":"AAAA;;GA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AO,CAAC;IACtC,IAAI,CAAC,EAAE,MAAM,CAAC;IACd,MAAM,CAAC,EAAE,MAAM,CAAC;IAChB,KAAK,CAAC,EAAE,MAAM,CAAC;IACf,SAAS,EAAE,MAAM,CAAC;CACnB;AAED;;GAEG;AACH,MAAM,WAAW,WAAW;IAC1B,IAAI,EAAE,UAAU,CAAC;IACjB,aAAa,EAAE,OAAO,CAAC;IACvB,QAAQ,EAAE,GAAG,CAAC,MAAM,EAAE,YAAY,CAAC,CAAC;IACpC,WAAW,EAAE,eAAe,EAAE,CAAC;IAC/B,iBAAiB,EAAE,MAAM,GAAG,IAAI,CAAC;CAClC;AAED;;GAEG;AACH,MAAM,WAAW,mBAAoB,SAAQ,IAAI,CAAC,YAAY,EAAE,UAAU,CAAC;IAEzE,QAAQ,EAAE,GAAG,EAAE,CAAC;CACjB"}
package/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "next-ai-editor",
3
- "version": "0.1.3",
3
+ "version": "0.2.1",
4
4
  "description": "AI-powered React component editor for Next.js - edit your components with natural language in development mode",
5
5
  "author": "Jesse Halpern",
6
6
  "type": "module",
@@ -22,7 +22,8 @@
22
22
  "types": "./dist/server/index.d.ts",
23
23
  "import": "./dist/server.js",
24
24
  "require": "./dist/server.cjs"
25
- }
25
+ },
26
+ "./styles": "./dist/next-ai-editor.css"
26
27
  },
27
28
  "files": [
28
29
  "dist",
@@ -35,6 +36,7 @@
35
36
  "react-dom": ">=18.0.0"
36
37
  },
37
38
  "dependencies": {
39
+ "@anthropic-ai/claude-agent-sdk": "^0.2.3",
38
40
  "@babel/parser": "^7.26.3",
39
41
  "@babel/traverse": "^7.26.5",
40
42
  "@babel/types": "^7.26.5",
@@ -42,12 +44,17 @@
42
44
  "@langchain/anthropic": "^0.3.15",
43
45
  "@langchain/core": "^0.3.58",
44
46
  "@types/react-syntax-highlighter": "^15.5.13",
45
- "react-syntax-highlighter": "^16.1.0"
47
+ "eventsource-parser": "^3.0.6",
48
+ "nanoid": "^5.0.9",
49
+ "react-markdown": "^10.1.0",
50
+ "react-syntax-highlighter": "^16.1.0",
51
+ "remark-gfm": "^4.0.1"
46
52
  },
47
53
  "devDependencies": {
48
54
  "@types/babel__traverse": "^7.20.6",
49
55
  "@types/node": "^20.0.0",
50
56
  "@types/react": "^19.0.0",
57
+ "lucide-react": "^0.562.0",
51
58
  "typescript": "^5.7.2",
52
59
  "vite": "^6.0.7",
53
60
  "vite-plugin-dts": "^4.5.0"
@@ -82,6 +89,8 @@
82
89
  "scripts": {
83
90
  "dev": "vite build --watch",
84
91
  "build": "vite build && tsc --emitDeclarationOnly --declaration --declarationDir dist",
85
- "typecheck": "tsc --noEmit"
92
+ "typecheck": "tsc --noEmit",
93
+ "clean": "rm -rf dist",
94
+ "test:agent": "tsx test-agent.ts"
86
95
  }
87
96
  }