@inspecto-dev/types 0.2.0-alpha.4 → 0.3.0

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/index.cjs CHANGED
@@ -27,83 +27,7 @@ __export(index_exports, {
27
27
  });
28
28
  module.exports = __toCommonJS(index_exports);
29
29
 
30
- // src/intents.ts
31
- var DEFAULT_INTENTS = [
32
- // ── 1. Explain Component ─────────────────────────────────────────────────
33
- // Frequency: ★★★★★ — Most common action when navigating unfamiliar codebases
34
- {
35
- id: "explain",
36
- label: "Explain Component",
37
- prompt: `The following is a {{framework}} component from \`{{file}}\` (line {{line}}).
38
-
39
- Please explain:
40
-
41
- 1. What this component does and its responsibility in the UI
42
- 2. Key props and their purpose
43
- 3. Important state or side effects (if applicable)
44
- 4. Any non-obvious logic or edge cases worth noting`
45
- },
46
- // ── 2. Fix Bug ───────────────────────────────────────────────────────────
47
- // Frequency: ★★★★★ — Debugging is the highest time-cost activity in frontend dev
48
- {
49
- id: "fix-bug",
50
- label: "Fix Bug",
51
- prompt: `I found a bug in the following {{framework}} component from \`{{file}}\` (line {{line}}).
52
-
53
- Please:
54
-
55
- 1. Identify potential bugs or issues in this code
56
- 2. Explain the root cause of each issue
57
- 3. Provide a fixed version with minimal changes
58
-
59
- If you need more context (e.g. parent component, API response shape),
60
- please ask before suggesting a fix.`
61
- },
62
- // ── 3. Fix Styles ────────────────────────────────────────────────────────
63
- // Frequency: ★★★★ — Styling issues are top-3 daily pain points for frontend devs
64
- {
65
- id: "fix-styles",
66
- label: "Fix Styles",
67
- prompt: `The following component from \`{{file}}\` (line {{line}}) has a styling issue.
68
-
69
- Please:
70
-
71
- 1. Review the current styles (className / inline styles / CSS-in-JS / Style blocks)
72
- 2. Identify common issues: layout shifts, overflow, z-index conflicts,
73
- responsive breakpoints, or visual inconsistencies
74
- 3. Suggest fixes using the same styling approach already in use
75
-
76
- Note: Maintain the existing styling conventions (e.g. Tailwind, CSS Modules, scoped styles).`
77
- },
78
- // ── 4. Refactor Component ────────────────────────────────────────────────
79
- // Frequency: ★★★★ — Sustained demand after features stabilize; large component splits
80
- {
81
- id: "refactor",
82
- label: "Refactor Component",
83
- prompt: `Please refactor the following {{framework}} component from \`{{file}}\` (line {{line}}).
84
-
85
- Refactoring goals (apply as relevant):
86
-
87
- - Extract reusable sub-components or composables/hooks
88
- - Improve readability and reduce complexity
89
- - Remove redundant state or unnecessary re-renders
90
- - Apply {{framework}} best practices
91
- - Maintain existing behavior \u2014 no functional changes
92
-
93
- Please show the refactored version with a brief explanation of each change.`
94
- },
95
- // ── 5. Open in Editor ────────────────────────────────────────────────────
96
- // Type: local action (no AI prompt) — jumps directly to source in IDE
97
- {
98
- id: "open-in-editor",
99
- label: "Open in Editor",
100
- prompt: "",
101
- // unused — isAction handles this
102
- isAction: true
103
- }
104
- ];
105
-
106
- // src/index.ts
30
+ // src/providers.ts
107
31
  var VALID_MODES = {
108
32
  copilot: ["extension"],
109
33
  "claude-code": ["extension", "cli"],
@@ -122,6 +46,8 @@ var DEFAULT_PROVIDER_MODE = {
122
46
  trae: "builtin",
123
47
  cursor: "builtin"
124
48
  };
49
+
50
+ // src/api.ts
125
51
  var INSPECTO_API_PATHS = {
126
52
  HEALTH: "/inspecto/api/v1/health",
127
53
  CLIENT_CONFIG: "/inspecto/api/v1/client/config",
@@ -129,9 +55,55 @@ var INSPECTO_API_PATHS = {
129
55
  IDE_OPEN: "/inspecto/api/v1/ide/open",
130
56
  PROJECT_SNIPPET: "/inspecto/api/v1/project/snippet",
131
57
  AI_DISPATCH: "/inspecto/api/v1/ai/dispatch",
58
+ AI_BATCH_DISPATCH: "/inspecto/api/v1/ai/dispatch/annotations",
132
59
  AI_TICKET: "/inspecto/api/v1/ai/ticket"
133
- // Usage: /inspecto/api/v1/ai/ticket/:id
134
60
  };
61
+
62
+ // src/intents.ts
63
+ var DEFAULT_INTENTS = [
64
+ {
65
+ id: "explain",
66
+ label: "Explain",
67
+ aiIntent: "ask",
68
+ prompt: `Explain what this {{framework}} component from \`{{file}}\` (line {{line}}) does.
69
+
70
+ Focus on:
71
+ - its UI responsibility
72
+ - key props, state, or side effects
73
+ - any non-obvious logic worth noticing`
74
+ },
75
+ {
76
+ id: "fix-bug",
77
+ label: "Fix Bug",
78
+ aiIntent: "fix",
79
+ prompt: `Help fix a bug in this {{framework}} component from \`{{file}}\` (line {{line}}).
80
+
81
+ Please:
82
+ - identify the most likely root cause
83
+ - explain why it happens
84
+ - suggest the smallest safe fix
85
+
86
+ If important context is missing, ask for it before proposing broader changes.`
87
+ },
88
+ {
89
+ id: "fix-ui",
90
+ label: "Fix UI",
91
+ aiIntent: "fix",
92
+ prompt: `Help fix a UI issue in this {{framework}} component from \`{{file}}\` (line {{line}}).
93
+
94
+ Please review layout, spacing, overflow, alignment, layering, and visual consistency,
95
+ then suggest fixes using the same styling approach already used in this codebase.`
96
+ },
97
+ {
98
+ id: "improve",
99
+ label: "Improve",
100
+ aiIntent: "review",
101
+ prompt: `Review this {{framework}} component from \`{{file}}\` (line {{line}}) and suggest practical improvements.
102
+
103
+ Focus on readability, maintainability, and small structural cleanups.
104
+ Keep behavior unchanged unless a change is clearly justified.`
105
+ }
106
+ ];
135
107
  // Annotate the CommonJS export names for ESM import in node:
136
108
  0 && (module.exports = {
137
109
  DEFAULT_INTENTS,
package/dist/index.d.cts CHANGED
@@ -1,119 +1,36 @@
1
- declare const DEFAULT_INTENTS: ({
2
- id: string;
3
- label: string;
4
- prompt: string;
5
- isAction?: never;
6
- } | {
7
- id: string;
8
- label: string;
9
- prompt: string;
10
- isAction: boolean;
11
- })[];
12
-
13
- /** Modifier keys that can be used as inspector activation hotkeys */
14
1
  type HotKey = 'ctrlKey' | 'altKey' | 'metaKey' | 'shiftKey';
15
- /**
16
- * Hotkey configuration strings.
17
- * E.g. "alt", "cmd+shift", or false to disable.
18
- */
19
2
  type HotKeyString = 'alt' | 'shift' | 'ctrl' | 'meta' | 'cmd' | 'alt+shift' | 'ctrl+shift' | 'meta+shift' | 'cmd+shift';
20
- /**
21
- * Hotkey configuration.
22
- * - String: modifier key or combo (e.g., "alt", "cmd+shift")
23
- * - false: disable hotkey activation entirely
24
- */
25
3
  type HotKeys = HotKeyString | false;
26
- /** Parsed source location from the data-inspecto attribute */
27
4
  interface SourceLocation {
28
- /** Absolute or relative file path depending on pathType config */
29
5
  file: string;
30
- /** 1-based line number */
31
6
  line: number;
32
- /** 1-based column number */
33
7
  column: number;
34
- /** Optional: component or element name for display */
35
8
  name?: string;
36
9
  }
37
- /** Format of the data-inspecto attribute value: "filepath:line:col" */
38
10
  type SourceAttrValue = string;
39
- /**
40
- * Path type injected into data-inspecto attributes.
41
- * - 'absolute': full filesystem path (default) — safe across monorepo aliases
42
- * - 'relative': path relative to project root — shorter, but may break with pnpm virtual store
43
- */
44
11
  type PathType = 'relative' | 'absolute';
45
- /** Configuration for the @inspecto-dev/plugin build plugin */
12
+ type LogLevel = 'info' | 'warn' | 'error' | 'silent';
46
13
  interface UnpluginOptions {
47
- /**
48
- * Additional file extensions to transform beyond .jsx/.tsx/.js/.ts
49
- * @default []
50
- */
51
14
  include?: string[];
52
- /**
53
- * File path patterns to exclude from transform
54
- * Matched against absolute file path using picomatch
55
- * node_modules and dist are always excluded
56
- * @default []
57
- */
58
15
  exclude?: string[];
59
- /**
60
- * Element tag names to skip source injection.
61
- * Useful for framework-internal elements that should not carry source data.
62
- * @default ['template', 'script', 'style', 'Transition', 'TransitionGroup',
63
- * 'KeepAlive', 'Teleport', 'Suspense', 'Fragment']
64
- */
65
16
  escapeTags?: string[];
66
- /**
67
- * Path type for the injected data-inspecto attribute value.
68
- * Use 'absolute' (default) to avoid issues with monorepo path aliases
69
- * and pnpm virtual store symlinks.
70
- * @default 'absolute'
71
- */
72
17
  pathType?: PathType;
73
- /**
74
- * The attribute name injected on JSX elements.
75
- * Change only if 'data-inspecto' conflicts with another tool.
76
- * @default 'data-inspecto'
77
- */
78
18
  attributeName?: string;
79
- /**
80
- * Console log level for the plugin.
81
- * - 'info': Print startup info, warnings, and errors
82
- * - 'warn': Print warnings and errors only
83
- * - 'error': Print errors only
84
- * - 'silent': Disable all console output
85
- * @default 'warn'
86
- */
87
19
  logLevel?: LogLevel;
88
20
  }
89
- type LogLevel = 'info' | 'warn' | 'error' | 'silent';
90
- /** Supported IDEs */
21
+
91
22
  type IdeType = 'vscode' | 'trae' | 'trae-cn' | 'cursor' | 'unknown';
92
- /** All supported AI tool providers */
93
23
  type Provider = 'copilot' | 'claude-code' | 'gemini' | 'codex' | 'coco' | 'trae' | 'cursor';
94
- /** Whether the AI provider is an editor extension, CLI tool, or clipboard fallback */
95
24
  type ProviderMode = 'extension' | 'cli' | 'clipboard' | 'builtin';
96
25
  interface InspectoSettings {
97
26
  ide?: IdeType;
98
- /** Flat namespaced configuration (e.g. `provider.default`, `provider.claude-code.cli.bin`) */
99
27
  [key: `provider.${string}`]: string | string[] | boolean | undefined;
100
28
  'inspector.hotKey'?: HotKeys;
101
- /**
102
- * Theme for the inspector panel.
103
- */
104
29
  'inspector.theme'?: 'light' | 'dark' | 'auto';
105
- /**
106
- * Whether to inject the raw code snippet into the prompt.
107
- * Default is false (saves tokens, lets IDE AI read the file directly).
108
- */
109
30
  'prompt.includeSnippet'?: boolean;
110
- /**
111
- * Whether to automatically send the prompt when opened in the AI tool.
112
- * Default is false (user must manually hit send).
113
- */
114
31
  'prompt.autoSend'?: boolean;
32
+ 'prompt.annotationResponseMode'?: 'unified' | 'per-annotation';
115
33
  }
116
- /** Static mapping: which modes each tool actually supports */
117
34
  declare const VALID_MODES: Record<Provider, ProviderMode[]>;
118
35
  declare const DEFAULT_PROVIDER_MODE: Record<Provider, ProviderMode>;
119
36
  interface ToolOverrides {
@@ -132,203 +49,260 @@ interface AiPayload {
132
49
  line?: number;
133
50
  column?: number;
134
51
  snippet?: string;
52
+ screenshotContext?: ScreenshotContext;
135
53
  overrides?: ToolOverrides;
136
54
  autoSend?: boolean;
137
- /** Added in v2: Unique ticket ID for the IDE to fetch this payload from the local server to bypass URI length limits */
138
55
  ticket?: string;
139
56
  }
140
57
  interface ChannelDef {
141
58
  type: ProviderMode;
142
59
  execute: (payload: AiPayload) => Promise<void>;
143
60
  }
61
+ interface ProviderInfo {
62
+ mode: ProviderMode;
63
+ installed: boolean;
64
+ }
65
+ interface IdeInfo {
66
+ ide: IdeType;
67
+ scheme: string;
68
+ workspaceRoot?: string;
69
+ providers: Record<Provider, ProviderInfo>;
70
+ }
71
+ interface InspectoConfig {
72
+ ide: IdeType;
73
+ providers?: Record<Provider, ProviderInfo>;
74
+ prompts?: IntentConfig[];
75
+ hotKeys?: HotKeys;
76
+ theme?: 'light' | 'dark' | 'auto';
77
+ includeSnippet?: boolean;
78
+ annotationResponseMode?: 'unified' | 'per-annotation';
79
+ runtimeContext?: RuntimeContextConfig;
80
+ screenshotContext?: ScreenshotContextConfig;
81
+ }
82
+ interface ServerState {
83
+ port: number | null;
84
+ running: boolean;
85
+ projectRoot: string;
86
+ configRoot: string;
87
+ cwd: string;
88
+ ideInfo?: IdeInfo | null;
89
+ }
90
+
91
+ type AiIntent = 'ask' | 'fix' | 'review' | 'redesign';
92
+ type AnnotationIntent = AiIntent;
144
93
  type IntentLabels = Partial<Record<Provider | 'clipboard', string>>;
145
- /**
146
- * Configuration for a custom intent in the AI menu.
147
- */
148
- interface IntentConfig {
149
- /** Unique identifier for this intent */
150
- id?: string;
151
- /** The text displayed on the intent button */
94
+ interface IntentConfigBase {
95
+ id: string;
152
96
  label?: string;
153
- /**
154
- * Prepend text to the prompt template.
155
- * Useful for extending built-in prompts without rewriting the whole template.
156
- */
157
97
  prependPrompt?: string;
158
- /**
159
- * Append text to the prompt template.
160
- * Useful for extending built-in prompts (e.g. "Please reply in Chinese").
161
- */
162
98
  appendPrompt?: string;
163
99
  prompt?: string;
164
- /**
165
- * If true, this intent doesn't send a prompt to AI,
166
- * but rather triggers a built-in action (like 'open-in-editor').
167
- * @internal For built-in intents only.
168
- */
169
- isAction?: boolean;
170
- /**
171
- * Enabled status.
172
- * If false, this item is explicitly hidden from the menu without having to remove its configuration.
173
- */
174
100
  enabled?: boolean;
175
101
  }
102
+ interface AiIntentConfig extends IntentConfigBase {
103
+ aiIntent: AiIntent;
104
+ }
105
+ type IntentConfig = AiIntentConfig;
176
106
  type InspectoPromptsConfig = (string | IntentConfig)[] | {
177
107
  $replace: true;
178
108
  items: (string | IntentConfig)[];
179
109
  };
180
- /** Configuration for the browser-side inspector component */
181
110
  interface InspectorOptions {
182
- /**
183
- * Hotkeys to hold while clicking to activate inspector.
184
- * Pass false to disable hotkey activation.
185
- * @default ['altKey']
186
- */
187
111
  hotKeys?: HotKeys;
188
- /**
189
- * Custom labels for each AI target button.
190
- * Useful for localization or branding.
191
- */
192
112
  labels?: IntentLabels;
193
- /**
194
- * Placeholder text for the "Ask AI" input box.
195
- */
196
113
  askPlaceholder?: string;
197
- /**
198
- * Base URL of the local HTTP server spun up by the unplugin.
199
- * Usually auto-detected via the injected __AI_INSPECTOR_PORT__ global.
200
- * Override only if running in a non-standard setup.
201
- */
202
114
  serverUrl?: string;
203
- /**
204
- * Maximum number of lines to include in the extracted code snippet.
205
- * Larger values provide more context but may hit AI token limits.
206
- * @default 100
207
- */
208
115
  maxSnippetLines?: number;
209
- /**
210
- * Whether the inspector panel is visible/active on mount.
211
- * @default false
212
- */
213
116
  defaultActive?: boolean;
214
- /**
215
- * Theme for the inspector panel.
216
- * If 'auto' or undefined, it relies on CSS media queries (prefers-color-scheme)
217
- * or inherits from the host environment if manually managed.
218
- */
219
117
  theme?: 'light' | 'dark' | 'auto';
220
- /**
221
- * Whether to inject the raw code snippet into the prompt.
222
- * Default is false (saves tokens, lets IDE AI read the file directly).
223
- */
224
118
  includeSnippet?: boolean;
119
+ annotationResponseMode?: 'unified' | 'per-annotation';
120
+ runtimeContext?: RuntimeContextConfig;
121
+ screenshotContext?: ScreenshotContextConfig;
122
+ }
123
+ interface SendToAiRequest {
124
+ location: SourceLocation;
125
+ snippet: string;
126
+ prompt?: string;
127
+ target?: Provider;
128
+ runtimeContext?: RuntimeContextEnvelope;
129
+ screenshotContext?: ScreenshotContext;
130
+ }
131
+ interface SendToAiResponse {
132
+ success: boolean;
133
+ error?: string;
134
+ errorCode?: AiErrorCode;
135
+ fallbackPayload?: {
136
+ prompt: string;
137
+ file: string;
138
+ };
139
+ }
140
+ interface AiStrategyContext {
141
+ location: SourceLocation;
142
+ snippet: string;
143
+ fileUri: string;
144
+ prompt: string;
145
+ }
146
+ interface AiStrategyResult {
147
+ success: boolean;
148
+ error?: string;
149
+ errorCode?: AiErrorCode;
225
150
  }
226
151
 
227
- declare const INSPECTO_API_PATHS: {
228
- readonly HEALTH: "/inspecto/api/v1/health";
229
- readonly CLIENT_CONFIG: "/inspecto/api/v1/client/config";
230
- readonly IDE_INFO: "/inspecto/api/v1/ide/info";
231
- readonly IDE_OPEN: "/inspecto/api/v1/ide/open";
232
- readonly PROJECT_SNIPPET: "/inspecto/api/v1/project/snippet";
233
- readonly AI_DISPATCH: "/inspecto/api/v1/ai/dispatch";
234
- readonly AI_TICKET: "/inspecto/api/v1/ai/ticket";
235
- };
236
- /** POST /open — browser asks server to open file in IDE */
152
+ type RuntimeEvidenceKind = 'runtime-error' | 'promise-rejection' | 'console-error' | 'failed-request';
153
+ type RuntimeEvidenceLevel = 'high' | 'medium' | 'low';
154
+ interface RuntimeEvidenceRecord {
155
+ id: string;
156
+ kind: RuntimeEvidenceKind;
157
+ timestamp: number;
158
+ message: string;
159
+ stack?: string;
160
+ sourceUrl?: string;
161
+ sourceFile?: string;
162
+ route?: string;
163
+ componentHints?: string[];
164
+ occurrenceCount: number;
165
+ relevanceScore: number;
166
+ relevanceLevel: RuntimeEvidenceLevel;
167
+ relevanceReasons: string[];
168
+ request?: {
169
+ method?: string;
170
+ url?: string;
171
+ pathname?: string;
172
+ status?: number;
173
+ responseSummary?: string;
174
+ };
175
+ }
176
+ interface RuntimeContextSummary {
177
+ runtimeErrorCount: number;
178
+ failedRequestCount: number;
179
+ includedRecordIds: string[];
180
+ }
181
+ interface RuntimeContextEnvelope {
182
+ summary: RuntimeContextSummary;
183
+ records: RuntimeEvidenceRecord[];
184
+ }
185
+ interface RuntimeContextConfig {
186
+ enabled?: boolean;
187
+ preview?: boolean;
188
+ maxRuntimeErrors?: number;
189
+ maxFailedRequests?: number;
190
+ }
191
+ interface ScreenshotContext {
192
+ enabled: boolean;
193
+ capturedAt: string;
194
+ mimeType: string;
195
+ imageDataUrl?: string;
196
+ imageAssetId?: string;
197
+ }
198
+ interface ScreenshotContextConfig {
199
+ enabled?: boolean;
200
+ }
237
201
  interface OpenFileRequest {
238
202
  file: string;
239
203
  line: number;
240
204
  column: number;
241
205
  }
242
- /** GET /snippet — browser asks server for source code context */
243
206
  interface SnippetRequest {
244
207
  file: string;
245
208
  line: number;
246
209
  column: number;
247
- /** Max lines to return in snippet, default 100 */
248
210
  maxLines?: number;
249
211
  }
250
212
  interface SnippetResponse {
251
- /** Extracted code snippet (trimmed to maxSnippetLines) */
252
213
  snippet: string;
253
- /** Actual start line of the returned snippet (1-based) */
254
214
  startLine: number;
255
- /** File path echoed back */
256
215
  file: string;
257
- /** Component or element name if detectable */
258
216
  name?: string;
259
217
  }
260
- /** POST /send-to-ai — browser asks server to dispatch context to an AI tool */
261
- interface SendToAiRequest {
218
+ interface AnnotationTarget {
219
+ id: string;
262
220
  location: SourceLocation;
263
- snippet: string;
264
- /** Prompt template. Server may override with its own template. */
265
- prompt?: string;
266
- /** Target AI tool. If not provided, server will resolve it based on config */
267
- target?: Provider;
268
- }
269
- interface SendToAiResponse {
270
- success: boolean;
271
- error?: string;
272
- /** Error code for structured error handling in the browser */
273
- errorCode?: AiErrorCode;
274
- /** Payload for client-side fallback (e.g. copying to clipboard if IDE fails to handle URI) */
275
- fallbackPayload?: {
276
- prompt: string;
277
- file: string;
221
+ label: string;
222
+ selector?: string;
223
+ rect: {
224
+ x: number;
225
+ y: number;
226
+ width: number;
227
+ height: number;
278
228
  };
229
+ snippet?: string;
279
230
  }
280
- /** Standard error codes returned by the local HTTP server */
281
- type AiErrorCode = 'IDE_NOT_FOUND' | 'EXTENSION_NOT_INSTALLED' | 'CLIPBOARD_WRITE_FAILED' | 'SNIPPET_TOO_LARGE' | 'FILE_NOT_FOUND' | 'UNKNOWN';
282
- interface ProviderInfo {
283
- mode: ProviderMode;
284
- installed: boolean;
231
+ interface FeedbackRecord {
232
+ id: string;
233
+ displayOrder: number;
234
+ target: AnnotationTarget;
235
+ note: string;
236
+ intent: AnnotationIntent;
237
+ cssContextEnabled?: boolean;
285
238
  }
286
- interface IdeInfo {
287
- ide: IdeType;
288
- scheme: string;
289
- workspaceRoot?: string;
290
- providers: Record<Provider, ProviderInfo>;
239
+ interface FeedbackRecordDraft {
240
+ id: string;
241
+ displayOrder?: number;
242
+ target: AnnotationTarget | null;
243
+ note: string;
244
+ intent: AnnotationIntent;
245
+ cssContextEnabled?: boolean;
291
246
  }
292
- /** GET /config response — browser-facing runtime configuration */
293
- interface InspectoConfig {
294
- ide: IdeType;
295
- /** List of AI targets available in the environment to show/enable in UI */
296
- providers?: Record<Provider, ProviderInfo>;
297
- /** Fully resolved and merged list of intent configurations for the UI to display */
298
- prompts?: IntentConfig[];
299
- hotKeys?: HotKeys;
300
- theme?: 'light' | 'dark' | 'auto';
301
- includeSnippet?: boolean;
247
+ interface FeedbackRecordSession {
248
+ current: FeedbackRecordDraft;
249
+ records: FeedbackRecord[];
302
250
  }
303
- /** Shared mutable state managed by the local HTTP server module */
304
- interface ServerState {
305
- /** Port the HTTP server is currently listening on */
306
- port: number | null;
307
- /** Whether the server is currently running */
308
- running: boolean;
309
- /** Absolute path to project root (from git rev-parse or process.cwd()) */
310
- projectRoot: string;
311
- /** Absolute path to the config root (where .inspecto lives) */
312
- configRoot: string;
313
- /** The directory where the bundler is running (process.cwd()) */
314
- cwd: string;
315
- /** Cached IDE info pushed from the extension */
316
- ideInfo?: IdeInfo | null;
251
+ interface Annotation {
252
+ id: string;
253
+ note: string;
254
+ intent: AnnotationIntent;
255
+ targets: AnnotationTarget[];
317
256
  }
318
- /** Context passed to each AI strategy when sending code context */
319
- interface AiStrategyContext {
257
+ interface AnnotationSession {
258
+ current: Annotation | null;
259
+ queue: Annotation[];
260
+ }
261
+ interface AnnotationTransportTarget {
320
262
  location: SourceLocation;
321
- snippet: string;
322
- /** Resolved absolute file URI (file:///...) */
323
- fileUri: string;
324
- /** Human-readable prompt constructed from location + snippet */
325
- prompt: string;
263
+ label?: string;
264
+ selector?: string;
265
+ snippet?: string;
326
266
  }
327
- /** Result of executing an AI strategy */
328
- interface AiStrategyResult {
267
+ interface AnnotationTransport {
268
+ note: string;
269
+ intent: AnnotationIntent;
270
+ targets: AnnotationTransportTarget[];
271
+ }
272
+ interface SendAnnotationsToAiRequest {
273
+ instruction?: string;
274
+ annotations: AnnotationTransport[];
275
+ responseMode?: 'unified' | 'per-annotation';
276
+ runtimeContext?: RuntimeContextEnvelope;
277
+ screenshotContext?: ScreenshotContext;
278
+ cssContextPrompt?: string;
279
+ }
280
+ interface SendAnnotationsToAiResponse {
329
281
  success: boolean;
330
282
  error?: string;
331
283
  errorCode?: AiErrorCode;
284
+ fallbackPayload?: {
285
+ prompt: string;
286
+ };
332
287
  }
288
+ type AiErrorCode = 'INVALID_REQUEST' | 'FORBIDDEN_PATH' | 'IDE_NOT_FOUND' | 'EXTENSION_NOT_INSTALLED' | 'CLIPBOARD_WRITE_FAILED' | 'SNIPPET_TOO_LARGE' | 'FILE_NOT_FOUND' | 'UNKNOWN';
289
+
290
+ declare const INSPECTO_API_PATHS: {
291
+ readonly HEALTH: "/inspecto/api/v1/health";
292
+ readonly CLIENT_CONFIG: "/inspecto/api/v1/client/config";
293
+ readonly IDE_INFO: "/inspecto/api/v1/ide/info";
294
+ readonly IDE_OPEN: "/inspecto/api/v1/ide/open";
295
+ readonly PROJECT_SNIPPET: "/inspecto/api/v1/project/snippet";
296
+ readonly AI_DISPATCH: "/inspecto/api/v1/ai/dispatch";
297
+ readonly AI_BATCH_DISPATCH: "/inspecto/api/v1/ai/dispatch/annotations";
298
+ readonly AI_TICKET: "/inspecto/api/v1/ai/ticket";
299
+ };
300
+
301
+ declare const DEFAULT_INTENTS: {
302
+ id: string;
303
+ label: string;
304
+ aiIntent: string;
305
+ prompt: string;
306
+ }[];
333
307
 
334
- export { type AiErrorCode, type AiPayload, type AiStrategyContext, type AiStrategyResult, type ChannelDef, DEFAULT_INTENTS, DEFAULT_PROVIDER_MODE, type HotKey, type HotKeyString, type HotKeys, INSPECTO_API_PATHS, type IdeInfo, type IdeType, type InspectoConfig, type InspectoPromptsConfig, type InspectoSettings, type InspectorOptions, type IntentConfig, type IntentLabels, type LogLevel, type OpenFileRequest, type PathType, type Provider, type ProviderInfo, type ProviderMode, type SendToAiRequest, type SendToAiResponse, type ServerState, type SnippetRequest, type SnippetResponse, type SourceAttrValue, type SourceLocation, type ToolOverrides, type UnpluginOptions, VALID_MODES };
308
+ export { type AiErrorCode, type AiIntent, type AiIntentConfig, type AiPayload, type AiStrategyContext, type AiStrategyResult, type Annotation, type AnnotationIntent, type AnnotationSession, type AnnotationTarget, type AnnotationTransport, type AnnotationTransportTarget, type ChannelDef, DEFAULT_INTENTS, DEFAULT_PROVIDER_MODE, type FeedbackRecord, type FeedbackRecordDraft, type FeedbackRecordSession, type HotKey, type HotKeyString, type HotKeys, INSPECTO_API_PATHS, type IdeInfo, type IdeType, type InspectoConfig, type InspectoPromptsConfig, type InspectoSettings, type InspectorOptions, type IntentConfig, type IntentConfigBase, type IntentLabels, type LogLevel, type OpenFileRequest, type PathType, type Provider, type ProviderInfo, type ProviderMode, type RuntimeContextConfig, type RuntimeContextEnvelope, type RuntimeContextSummary, type RuntimeEvidenceKind, type RuntimeEvidenceLevel, type RuntimeEvidenceRecord, type ScreenshotContext, type ScreenshotContextConfig, type SendAnnotationsToAiRequest, type SendAnnotationsToAiResponse, type SendToAiRequest, type SendToAiResponse, type ServerState, type SnippetRequest, type SnippetResponse, type SourceAttrValue, type SourceLocation, type ToolOverrides, type UnpluginOptions, VALID_MODES };
package/dist/index.d.ts CHANGED
@@ -1,119 +1,36 @@
1
- declare const DEFAULT_INTENTS: ({
2
- id: string;
3
- label: string;
4
- prompt: string;
5
- isAction?: never;
6
- } | {
7
- id: string;
8
- label: string;
9
- prompt: string;
10
- isAction: boolean;
11
- })[];
12
-
13
- /** Modifier keys that can be used as inspector activation hotkeys */
14
1
  type HotKey = 'ctrlKey' | 'altKey' | 'metaKey' | 'shiftKey';
15
- /**
16
- * Hotkey configuration strings.
17
- * E.g. "alt", "cmd+shift", or false to disable.
18
- */
19
2
  type HotKeyString = 'alt' | 'shift' | 'ctrl' | 'meta' | 'cmd' | 'alt+shift' | 'ctrl+shift' | 'meta+shift' | 'cmd+shift';
20
- /**
21
- * Hotkey configuration.
22
- * - String: modifier key or combo (e.g., "alt", "cmd+shift")
23
- * - false: disable hotkey activation entirely
24
- */
25
3
  type HotKeys = HotKeyString | false;
26
- /** Parsed source location from the data-inspecto attribute */
27
4
  interface SourceLocation {
28
- /** Absolute or relative file path depending on pathType config */
29
5
  file: string;
30
- /** 1-based line number */
31
6
  line: number;
32
- /** 1-based column number */
33
7
  column: number;
34
- /** Optional: component or element name for display */
35
8
  name?: string;
36
9
  }
37
- /** Format of the data-inspecto attribute value: "filepath:line:col" */
38
10
  type SourceAttrValue = string;
39
- /**
40
- * Path type injected into data-inspecto attributes.
41
- * - 'absolute': full filesystem path (default) — safe across monorepo aliases
42
- * - 'relative': path relative to project root — shorter, but may break with pnpm virtual store
43
- */
44
11
  type PathType = 'relative' | 'absolute';
45
- /** Configuration for the @inspecto-dev/plugin build plugin */
12
+ type LogLevel = 'info' | 'warn' | 'error' | 'silent';
46
13
  interface UnpluginOptions {
47
- /**
48
- * Additional file extensions to transform beyond .jsx/.tsx/.js/.ts
49
- * @default []
50
- */
51
14
  include?: string[];
52
- /**
53
- * File path patterns to exclude from transform
54
- * Matched against absolute file path using picomatch
55
- * node_modules and dist are always excluded
56
- * @default []
57
- */
58
15
  exclude?: string[];
59
- /**
60
- * Element tag names to skip source injection.
61
- * Useful for framework-internal elements that should not carry source data.
62
- * @default ['template', 'script', 'style', 'Transition', 'TransitionGroup',
63
- * 'KeepAlive', 'Teleport', 'Suspense', 'Fragment']
64
- */
65
16
  escapeTags?: string[];
66
- /**
67
- * Path type for the injected data-inspecto attribute value.
68
- * Use 'absolute' (default) to avoid issues with monorepo path aliases
69
- * and pnpm virtual store symlinks.
70
- * @default 'absolute'
71
- */
72
17
  pathType?: PathType;
73
- /**
74
- * The attribute name injected on JSX elements.
75
- * Change only if 'data-inspecto' conflicts with another tool.
76
- * @default 'data-inspecto'
77
- */
78
18
  attributeName?: string;
79
- /**
80
- * Console log level for the plugin.
81
- * - 'info': Print startup info, warnings, and errors
82
- * - 'warn': Print warnings and errors only
83
- * - 'error': Print errors only
84
- * - 'silent': Disable all console output
85
- * @default 'warn'
86
- */
87
19
  logLevel?: LogLevel;
88
20
  }
89
- type LogLevel = 'info' | 'warn' | 'error' | 'silent';
90
- /** Supported IDEs */
21
+
91
22
  type IdeType = 'vscode' | 'trae' | 'trae-cn' | 'cursor' | 'unknown';
92
- /** All supported AI tool providers */
93
23
  type Provider = 'copilot' | 'claude-code' | 'gemini' | 'codex' | 'coco' | 'trae' | 'cursor';
94
- /** Whether the AI provider is an editor extension, CLI tool, or clipboard fallback */
95
24
  type ProviderMode = 'extension' | 'cli' | 'clipboard' | 'builtin';
96
25
  interface InspectoSettings {
97
26
  ide?: IdeType;
98
- /** Flat namespaced configuration (e.g. `provider.default`, `provider.claude-code.cli.bin`) */
99
27
  [key: `provider.${string}`]: string | string[] | boolean | undefined;
100
28
  'inspector.hotKey'?: HotKeys;
101
- /**
102
- * Theme for the inspector panel.
103
- */
104
29
  'inspector.theme'?: 'light' | 'dark' | 'auto';
105
- /**
106
- * Whether to inject the raw code snippet into the prompt.
107
- * Default is false (saves tokens, lets IDE AI read the file directly).
108
- */
109
30
  'prompt.includeSnippet'?: boolean;
110
- /**
111
- * Whether to automatically send the prompt when opened in the AI tool.
112
- * Default is false (user must manually hit send).
113
- */
114
31
  'prompt.autoSend'?: boolean;
32
+ 'prompt.annotationResponseMode'?: 'unified' | 'per-annotation';
115
33
  }
116
- /** Static mapping: which modes each tool actually supports */
117
34
  declare const VALID_MODES: Record<Provider, ProviderMode[]>;
118
35
  declare const DEFAULT_PROVIDER_MODE: Record<Provider, ProviderMode>;
119
36
  interface ToolOverrides {
@@ -132,203 +49,260 @@ interface AiPayload {
132
49
  line?: number;
133
50
  column?: number;
134
51
  snippet?: string;
52
+ screenshotContext?: ScreenshotContext;
135
53
  overrides?: ToolOverrides;
136
54
  autoSend?: boolean;
137
- /** Added in v2: Unique ticket ID for the IDE to fetch this payload from the local server to bypass URI length limits */
138
55
  ticket?: string;
139
56
  }
140
57
  interface ChannelDef {
141
58
  type: ProviderMode;
142
59
  execute: (payload: AiPayload) => Promise<void>;
143
60
  }
61
+ interface ProviderInfo {
62
+ mode: ProviderMode;
63
+ installed: boolean;
64
+ }
65
+ interface IdeInfo {
66
+ ide: IdeType;
67
+ scheme: string;
68
+ workspaceRoot?: string;
69
+ providers: Record<Provider, ProviderInfo>;
70
+ }
71
+ interface InspectoConfig {
72
+ ide: IdeType;
73
+ providers?: Record<Provider, ProviderInfo>;
74
+ prompts?: IntentConfig[];
75
+ hotKeys?: HotKeys;
76
+ theme?: 'light' | 'dark' | 'auto';
77
+ includeSnippet?: boolean;
78
+ annotationResponseMode?: 'unified' | 'per-annotation';
79
+ runtimeContext?: RuntimeContextConfig;
80
+ screenshotContext?: ScreenshotContextConfig;
81
+ }
82
+ interface ServerState {
83
+ port: number | null;
84
+ running: boolean;
85
+ projectRoot: string;
86
+ configRoot: string;
87
+ cwd: string;
88
+ ideInfo?: IdeInfo | null;
89
+ }
90
+
91
+ type AiIntent = 'ask' | 'fix' | 'review' | 'redesign';
92
+ type AnnotationIntent = AiIntent;
144
93
  type IntentLabels = Partial<Record<Provider | 'clipboard', string>>;
145
- /**
146
- * Configuration for a custom intent in the AI menu.
147
- */
148
- interface IntentConfig {
149
- /** Unique identifier for this intent */
150
- id?: string;
151
- /** The text displayed on the intent button */
94
+ interface IntentConfigBase {
95
+ id: string;
152
96
  label?: string;
153
- /**
154
- * Prepend text to the prompt template.
155
- * Useful for extending built-in prompts without rewriting the whole template.
156
- */
157
97
  prependPrompt?: string;
158
- /**
159
- * Append text to the prompt template.
160
- * Useful for extending built-in prompts (e.g. "Please reply in Chinese").
161
- */
162
98
  appendPrompt?: string;
163
99
  prompt?: string;
164
- /**
165
- * If true, this intent doesn't send a prompt to AI,
166
- * but rather triggers a built-in action (like 'open-in-editor').
167
- * @internal For built-in intents only.
168
- */
169
- isAction?: boolean;
170
- /**
171
- * Enabled status.
172
- * If false, this item is explicitly hidden from the menu without having to remove its configuration.
173
- */
174
100
  enabled?: boolean;
175
101
  }
102
+ interface AiIntentConfig extends IntentConfigBase {
103
+ aiIntent: AiIntent;
104
+ }
105
+ type IntentConfig = AiIntentConfig;
176
106
  type InspectoPromptsConfig = (string | IntentConfig)[] | {
177
107
  $replace: true;
178
108
  items: (string | IntentConfig)[];
179
109
  };
180
- /** Configuration for the browser-side inspector component */
181
110
  interface InspectorOptions {
182
- /**
183
- * Hotkeys to hold while clicking to activate inspector.
184
- * Pass false to disable hotkey activation.
185
- * @default ['altKey']
186
- */
187
111
  hotKeys?: HotKeys;
188
- /**
189
- * Custom labels for each AI target button.
190
- * Useful for localization or branding.
191
- */
192
112
  labels?: IntentLabels;
193
- /**
194
- * Placeholder text for the "Ask AI" input box.
195
- */
196
113
  askPlaceholder?: string;
197
- /**
198
- * Base URL of the local HTTP server spun up by the unplugin.
199
- * Usually auto-detected via the injected __AI_INSPECTOR_PORT__ global.
200
- * Override only if running in a non-standard setup.
201
- */
202
114
  serverUrl?: string;
203
- /**
204
- * Maximum number of lines to include in the extracted code snippet.
205
- * Larger values provide more context but may hit AI token limits.
206
- * @default 100
207
- */
208
115
  maxSnippetLines?: number;
209
- /**
210
- * Whether the inspector panel is visible/active on mount.
211
- * @default false
212
- */
213
116
  defaultActive?: boolean;
214
- /**
215
- * Theme for the inspector panel.
216
- * If 'auto' or undefined, it relies on CSS media queries (prefers-color-scheme)
217
- * or inherits from the host environment if manually managed.
218
- */
219
117
  theme?: 'light' | 'dark' | 'auto';
220
- /**
221
- * Whether to inject the raw code snippet into the prompt.
222
- * Default is false (saves tokens, lets IDE AI read the file directly).
223
- */
224
118
  includeSnippet?: boolean;
119
+ annotationResponseMode?: 'unified' | 'per-annotation';
120
+ runtimeContext?: RuntimeContextConfig;
121
+ screenshotContext?: ScreenshotContextConfig;
122
+ }
123
+ interface SendToAiRequest {
124
+ location: SourceLocation;
125
+ snippet: string;
126
+ prompt?: string;
127
+ target?: Provider;
128
+ runtimeContext?: RuntimeContextEnvelope;
129
+ screenshotContext?: ScreenshotContext;
130
+ }
131
+ interface SendToAiResponse {
132
+ success: boolean;
133
+ error?: string;
134
+ errorCode?: AiErrorCode;
135
+ fallbackPayload?: {
136
+ prompt: string;
137
+ file: string;
138
+ };
139
+ }
140
+ interface AiStrategyContext {
141
+ location: SourceLocation;
142
+ snippet: string;
143
+ fileUri: string;
144
+ prompt: string;
145
+ }
146
+ interface AiStrategyResult {
147
+ success: boolean;
148
+ error?: string;
149
+ errorCode?: AiErrorCode;
225
150
  }
226
151
 
227
- declare const INSPECTO_API_PATHS: {
228
- readonly HEALTH: "/inspecto/api/v1/health";
229
- readonly CLIENT_CONFIG: "/inspecto/api/v1/client/config";
230
- readonly IDE_INFO: "/inspecto/api/v1/ide/info";
231
- readonly IDE_OPEN: "/inspecto/api/v1/ide/open";
232
- readonly PROJECT_SNIPPET: "/inspecto/api/v1/project/snippet";
233
- readonly AI_DISPATCH: "/inspecto/api/v1/ai/dispatch";
234
- readonly AI_TICKET: "/inspecto/api/v1/ai/ticket";
235
- };
236
- /** POST /open — browser asks server to open file in IDE */
152
+ type RuntimeEvidenceKind = 'runtime-error' | 'promise-rejection' | 'console-error' | 'failed-request';
153
+ type RuntimeEvidenceLevel = 'high' | 'medium' | 'low';
154
+ interface RuntimeEvidenceRecord {
155
+ id: string;
156
+ kind: RuntimeEvidenceKind;
157
+ timestamp: number;
158
+ message: string;
159
+ stack?: string;
160
+ sourceUrl?: string;
161
+ sourceFile?: string;
162
+ route?: string;
163
+ componentHints?: string[];
164
+ occurrenceCount: number;
165
+ relevanceScore: number;
166
+ relevanceLevel: RuntimeEvidenceLevel;
167
+ relevanceReasons: string[];
168
+ request?: {
169
+ method?: string;
170
+ url?: string;
171
+ pathname?: string;
172
+ status?: number;
173
+ responseSummary?: string;
174
+ };
175
+ }
176
+ interface RuntimeContextSummary {
177
+ runtimeErrorCount: number;
178
+ failedRequestCount: number;
179
+ includedRecordIds: string[];
180
+ }
181
+ interface RuntimeContextEnvelope {
182
+ summary: RuntimeContextSummary;
183
+ records: RuntimeEvidenceRecord[];
184
+ }
185
+ interface RuntimeContextConfig {
186
+ enabled?: boolean;
187
+ preview?: boolean;
188
+ maxRuntimeErrors?: number;
189
+ maxFailedRequests?: number;
190
+ }
191
+ interface ScreenshotContext {
192
+ enabled: boolean;
193
+ capturedAt: string;
194
+ mimeType: string;
195
+ imageDataUrl?: string;
196
+ imageAssetId?: string;
197
+ }
198
+ interface ScreenshotContextConfig {
199
+ enabled?: boolean;
200
+ }
237
201
  interface OpenFileRequest {
238
202
  file: string;
239
203
  line: number;
240
204
  column: number;
241
205
  }
242
- /** GET /snippet — browser asks server for source code context */
243
206
  interface SnippetRequest {
244
207
  file: string;
245
208
  line: number;
246
209
  column: number;
247
- /** Max lines to return in snippet, default 100 */
248
210
  maxLines?: number;
249
211
  }
250
212
  interface SnippetResponse {
251
- /** Extracted code snippet (trimmed to maxSnippetLines) */
252
213
  snippet: string;
253
- /** Actual start line of the returned snippet (1-based) */
254
214
  startLine: number;
255
- /** File path echoed back */
256
215
  file: string;
257
- /** Component or element name if detectable */
258
216
  name?: string;
259
217
  }
260
- /** POST /send-to-ai — browser asks server to dispatch context to an AI tool */
261
- interface SendToAiRequest {
218
+ interface AnnotationTarget {
219
+ id: string;
262
220
  location: SourceLocation;
263
- snippet: string;
264
- /** Prompt template. Server may override with its own template. */
265
- prompt?: string;
266
- /** Target AI tool. If not provided, server will resolve it based on config */
267
- target?: Provider;
268
- }
269
- interface SendToAiResponse {
270
- success: boolean;
271
- error?: string;
272
- /** Error code for structured error handling in the browser */
273
- errorCode?: AiErrorCode;
274
- /** Payload for client-side fallback (e.g. copying to clipboard if IDE fails to handle URI) */
275
- fallbackPayload?: {
276
- prompt: string;
277
- file: string;
221
+ label: string;
222
+ selector?: string;
223
+ rect: {
224
+ x: number;
225
+ y: number;
226
+ width: number;
227
+ height: number;
278
228
  };
229
+ snippet?: string;
279
230
  }
280
- /** Standard error codes returned by the local HTTP server */
281
- type AiErrorCode = 'IDE_NOT_FOUND' | 'EXTENSION_NOT_INSTALLED' | 'CLIPBOARD_WRITE_FAILED' | 'SNIPPET_TOO_LARGE' | 'FILE_NOT_FOUND' | 'UNKNOWN';
282
- interface ProviderInfo {
283
- mode: ProviderMode;
284
- installed: boolean;
231
+ interface FeedbackRecord {
232
+ id: string;
233
+ displayOrder: number;
234
+ target: AnnotationTarget;
235
+ note: string;
236
+ intent: AnnotationIntent;
237
+ cssContextEnabled?: boolean;
285
238
  }
286
- interface IdeInfo {
287
- ide: IdeType;
288
- scheme: string;
289
- workspaceRoot?: string;
290
- providers: Record<Provider, ProviderInfo>;
239
+ interface FeedbackRecordDraft {
240
+ id: string;
241
+ displayOrder?: number;
242
+ target: AnnotationTarget | null;
243
+ note: string;
244
+ intent: AnnotationIntent;
245
+ cssContextEnabled?: boolean;
291
246
  }
292
- /** GET /config response — browser-facing runtime configuration */
293
- interface InspectoConfig {
294
- ide: IdeType;
295
- /** List of AI targets available in the environment to show/enable in UI */
296
- providers?: Record<Provider, ProviderInfo>;
297
- /** Fully resolved and merged list of intent configurations for the UI to display */
298
- prompts?: IntentConfig[];
299
- hotKeys?: HotKeys;
300
- theme?: 'light' | 'dark' | 'auto';
301
- includeSnippet?: boolean;
247
+ interface FeedbackRecordSession {
248
+ current: FeedbackRecordDraft;
249
+ records: FeedbackRecord[];
302
250
  }
303
- /** Shared mutable state managed by the local HTTP server module */
304
- interface ServerState {
305
- /** Port the HTTP server is currently listening on */
306
- port: number | null;
307
- /** Whether the server is currently running */
308
- running: boolean;
309
- /** Absolute path to project root (from git rev-parse or process.cwd()) */
310
- projectRoot: string;
311
- /** Absolute path to the config root (where .inspecto lives) */
312
- configRoot: string;
313
- /** The directory where the bundler is running (process.cwd()) */
314
- cwd: string;
315
- /** Cached IDE info pushed from the extension */
316
- ideInfo?: IdeInfo | null;
251
+ interface Annotation {
252
+ id: string;
253
+ note: string;
254
+ intent: AnnotationIntent;
255
+ targets: AnnotationTarget[];
317
256
  }
318
- /** Context passed to each AI strategy when sending code context */
319
- interface AiStrategyContext {
257
+ interface AnnotationSession {
258
+ current: Annotation | null;
259
+ queue: Annotation[];
260
+ }
261
+ interface AnnotationTransportTarget {
320
262
  location: SourceLocation;
321
- snippet: string;
322
- /** Resolved absolute file URI (file:///...) */
323
- fileUri: string;
324
- /** Human-readable prompt constructed from location + snippet */
325
- prompt: string;
263
+ label?: string;
264
+ selector?: string;
265
+ snippet?: string;
326
266
  }
327
- /** Result of executing an AI strategy */
328
- interface AiStrategyResult {
267
+ interface AnnotationTransport {
268
+ note: string;
269
+ intent: AnnotationIntent;
270
+ targets: AnnotationTransportTarget[];
271
+ }
272
+ interface SendAnnotationsToAiRequest {
273
+ instruction?: string;
274
+ annotations: AnnotationTransport[];
275
+ responseMode?: 'unified' | 'per-annotation';
276
+ runtimeContext?: RuntimeContextEnvelope;
277
+ screenshotContext?: ScreenshotContext;
278
+ cssContextPrompt?: string;
279
+ }
280
+ interface SendAnnotationsToAiResponse {
329
281
  success: boolean;
330
282
  error?: string;
331
283
  errorCode?: AiErrorCode;
284
+ fallbackPayload?: {
285
+ prompt: string;
286
+ };
332
287
  }
288
+ type AiErrorCode = 'INVALID_REQUEST' | 'FORBIDDEN_PATH' | 'IDE_NOT_FOUND' | 'EXTENSION_NOT_INSTALLED' | 'CLIPBOARD_WRITE_FAILED' | 'SNIPPET_TOO_LARGE' | 'FILE_NOT_FOUND' | 'UNKNOWN';
289
+
290
+ declare const INSPECTO_API_PATHS: {
291
+ readonly HEALTH: "/inspecto/api/v1/health";
292
+ readonly CLIENT_CONFIG: "/inspecto/api/v1/client/config";
293
+ readonly IDE_INFO: "/inspecto/api/v1/ide/info";
294
+ readonly IDE_OPEN: "/inspecto/api/v1/ide/open";
295
+ readonly PROJECT_SNIPPET: "/inspecto/api/v1/project/snippet";
296
+ readonly AI_DISPATCH: "/inspecto/api/v1/ai/dispatch";
297
+ readonly AI_BATCH_DISPATCH: "/inspecto/api/v1/ai/dispatch/annotations";
298
+ readonly AI_TICKET: "/inspecto/api/v1/ai/ticket";
299
+ };
300
+
301
+ declare const DEFAULT_INTENTS: {
302
+ id: string;
303
+ label: string;
304
+ aiIntent: string;
305
+ prompt: string;
306
+ }[];
333
307
 
334
- export { type AiErrorCode, type AiPayload, type AiStrategyContext, type AiStrategyResult, type ChannelDef, DEFAULT_INTENTS, DEFAULT_PROVIDER_MODE, type HotKey, type HotKeyString, type HotKeys, INSPECTO_API_PATHS, type IdeInfo, type IdeType, type InspectoConfig, type InspectoPromptsConfig, type InspectoSettings, type InspectorOptions, type IntentConfig, type IntentLabels, type LogLevel, type OpenFileRequest, type PathType, type Provider, type ProviderInfo, type ProviderMode, type SendToAiRequest, type SendToAiResponse, type ServerState, type SnippetRequest, type SnippetResponse, type SourceAttrValue, type SourceLocation, type ToolOverrides, type UnpluginOptions, VALID_MODES };
308
+ export { type AiErrorCode, type AiIntent, type AiIntentConfig, type AiPayload, type AiStrategyContext, type AiStrategyResult, type Annotation, type AnnotationIntent, type AnnotationSession, type AnnotationTarget, type AnnotationTransport, type AnnotationTransportTarget, type ChannelDef, DEFAULT_INTENTS, DEFAULT_PROVIDER_MODE, type FeedbackRecord, type FeedbackRecordDraft, type FeedbackRecordSession, type HotKey, type HotKeyString, type HotKeys, INSPECTO_API_PATHS, type IdeInfo, type IdeType, type InspectoConfig, type InspectoPromptsConfig, type InspectoSettings, type InspectorOptions, type IntentConfig, type IntentConfigBase, type IntentLabels, type LogLevel, type OpenFileRequest, type PathType, type Provider, type ProviderInfo, type ProviderMode, type RuntimeContextConfig, type RuntimeContextEnvelope, type RuntimeContextSummary, type RuntimeEvidenceKind, type RuntimeEvidenceLevel, type RuntimeEvidenceRecord, type ScreenshotContext, type ScreenshotContextConfig, type SendAnnotationsToAiRequest, type SendAnnotationsToAiResponse, type SendToAiRequest, type SendToAiResponse, type ServerState, type SnippetRequest, type SnippetResponse, type SourceAttrValue, type SourceLocation, type ToolOverrides, type UnpluginOptions, VALID_MODES };
package/dist/index.js CHANGED
@@ -1,80 +1,4 @@
1
- // src/intents.ts
2
- var DEFAULT_INTENTS = [
3
- // ── 1. Explain Component ─────────────────────────────────────────────────
4
- // Frequency: ★★★★★ — Most common action when navigating unfamiliar codebases
5
- {
6
- id: "explain",
7
- label: "Explain Component",
8
- prompt: `The following is a {{framework}} component from \`{{file}}\` (line {{line}}).
9
-
10
- Please explain:
11
-
12
- 1. What this component does and its responsibility in the UI
13
- 2. Key props and their purpose
14
- 3. Important state or side effects (if applicable)
15
- 4. Any non-obvious logic or edge cases worth noting`
16
- },
17
- // ── 2. Fix Bug ───────────────────────────────────────────────────────────
18
- // Frequency: ★★★★★ — Debugging is the highest time-cost activity in frontend dev
19
- {
20
- id: "fix-bug",
21
- label: "Fix Bug",
22
- prompt: `I found a bug in the following {{framework}} component from \`{{file}}\` (line {{line}}).
23
-
24
- Please:
25
-
26
- 1. Identify potential bugs or issues in this code
27
- 2. Explain the root cause of each issue
28
- 3. Provide a fixed version with minimal changes
29
-
30
- If you need more context (e.g. parent component, API response shape),
31
- please ask before suggesting a fix.`
32
- },
33
- // ── 3. Fix Styles ────────────────────────────────────────────────────────
34
- // Frequency: ★★★★ — Styling issues are top-3 daily pain points for frontend devs
35
- {
36
- id: "fix-styles",
37
- label: "Fix Styles",
38
- prompt: `The following component from \`{{file}}\` (line {{line}}) has a styling issue.
39
-
40
- Please:
41
-
42
- 1. Review the current styles (className / inline styles / CSS-in-JS / Style blocks)
43
- 2. Identify common issues: layout shifts, overflow, z-index conflicts,
44
- responsive breakpoints, or visual inconsistencies
45
- 3. Suggest fixes using the same styling approach already in use
46
-
47
- Note: Maintain the existing styling conventions (e.g. Tailwind, CSS Modules, scoped styles).`
48
- },
49
- // ── 4. Refactor Component ────────────────────────────────────────────────
50
- // Frequency: ★★★★ — Sustained demand after features stabilize; large component splits
51
- {
52
- id: "refactor",
53
- label: "Refactor Component",
54
- prompt: `Please refactor the following {{framework}} component from \`{{file}}\` (line {{line}}).
55
-
56
- Refactoring goals (apply as relevant):
57
-
58
- - Extract reusable sub-components or composables/hooks
59
- - Improve readability and reduce complexity
60
- - Remove redundant state or unnecessary re-renders
61
- - Apply {{framework}} best practices
62
- - Maintain existing behavior \u2014 no functional changes
63
-
64
- Please show the refactored version with a brief explanation of each change.`
65
- },
66
- // ── 5. Open in Editor ────────────────────────────────────────────────────
67
- // Type: local action (no AI prompt) — jumps directly to source in IDE
68
- {
69
- id: "open-in-editor",
70
- label: "Open in Editor",
71
- prompt: "",
72
- // unused — isAction handles this
73
- isAction: true
74
- }
75
- ];
76
-
77
- // src/index.ts
1
+ // src/providers.ts
78
2
  var VALID_MODES = {
79
3
  copilot: ["extension"],
80
4
  "claude-code": ["extension", "cli"],
@@ -93,6 +17,8 @@ var DEFAULT_PROVIDER_MODE = {
93
17
  trae: "builtin",
94
18
  cursor: "builtin"
95
19
  };
20
+
21
+ // src/api.ts
96
22
  var INSPECTO_API_PATHS = {
97
23
  HEALTH: "/inspecto/api/v1/health",
98
24
  CLIENT_CONFIG: "/inspecto/api/v1/client/config",
@@ -100,9 +26,55 @@ var INSPECTO_API_PATHS = {
100
26
  IDE_OPEN: "/inspecto/api/v1/ide/open",
101
27
  PROJECT_SNIPPET: "/inspecto/api/v1/project/snippet",
102
28
  AI_DISPATCH: "/inspecto/api/v1/ai/dispatch",
29
+ AI_BATCH_DISPATCH: "/inspecto/api/v1/ai/dispatch/annotations",
103
30
  AI_TICKET: "/inspecto/api/v1/ai/ticket"
104
- // Usage: /inspecto/api/v1/ai/ticket/:id
105
31
  };
32
+
33
+ // src/intents.ts
34
+ var DEFAULT_INTENTS = [
35
+ {
36
+ id: "explain",
37
+ label: "Explain",
38
+ aiIntent: "ask",
39
+ prompt: `Explain what this {{framework}} component from \`{{file}}\` (line {{line}}) does.
40
+
41
+ Focus on:
42
+ - its UI responsibility
43
+ - key props, state, or side effects
44
+ - any non-obvious logic worth noticing`
45
+ },
46
+ {
47
+ id: "fix-bug",
48
+ label: "Fix Bug",
49
+ aiIntent: "fix",
50
+ prompt: `Help fix a bug in this {{framework}} component from \`{{file}}\` (line {{line}}).
51
+
52
+ Please:
53
+ - identify the most likely root cause
54
+ - explain why it happens
55
+ - suggest the smallest safe fix
56
+
57
+ If important context is missing, ask for it before proposing broader changes.`
58
+ },
59
+ {
60
+ id: "fix-ui",
61
+ label: "Fix UI",
62
+ aiIntent: "fix",
63
+ prompt: `Help fix a UI issue in this {{framework}} component from \`{{file}}\` (line {{line}}).
64
+
65
+ Please review layout, spacing, overflow, alignment, layering, and visual consistency,
66
+ then suggest fixes using the same styling approach already used in this codebase.`
67
+ },
68
+ {
69
+ id: "improve",
70
+ label: "Improve",
71
+ aiIntent: "review",
72
+ prompt: `Review this {{framework}} component from \`{{file}}\` (line {{line}}) and suggest practical improvements.
73
+
74
+ Focus on readability, maintainability, and small structural cleanups.
75
+ Keep behavior unchanged unless a change is clearly justified.`
76
+ }
77
+ ];
106
78
  export {
107
79
  DEFAULT_INTENTS,
108
80
  DEFAULT_PROVIDER_MODE,
package/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "@inspecto-dev/types",
3
- "version": "0.2.0-alpha.4",
3
+ "version": "0.3.0",
4
4
  "description": "Shared TypeScript definitions for the Inspecto monorepo",
5
5
  "license": "MIT",
6
6
  "type": "module",