@inspecto-dev/types 0.2.0-alpha.0 → 0.2.0-alpha.2

This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
package/LICENSE ADDED
@@ -0,0 +1,21 @@
1
+ MIT License
2
+
3
+ Copyright (c) 2026 Inspecto Contributors
4
+
5
+ Permission is hereby granted, free of charge, to any person obtaining a copy
6
+ of this software and associated documentation files (the "Software"), to deal
7
+ in the Software without restriction, including without limitation the rights
8
+ to use, copy, modify, merge, publish, distribute, sublicense, and/or sell
9
+ copies of the Software, and to permit persons to whom the Software is
10
+ furnished to do so, subject to the following conditions:
11
+
12
+ The above copyright notice and this permission notice shall be included in all
13
+ copies or substantial portions of the Software.
14
+
15
+ THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR
16
+ IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY,
17
+ FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE
18
+ AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER
19
+ LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM,
20
+ OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE
21
+ SOFTWARE.
package/README.md CHANGED
@@ -1,6 +1,6 @@
1
- # @inspecto/types
1
+ # @inspecto-dev/types
2
2
 
3
- `@inspecto/types` contains all shared TypeScript definitions for the Inspecto monorepo.
3
+ `@inspecto-dev/types` contains all shared TypeScript definitions for the Inspecto monorepo.
4
4
 
5
5
  ## Overview
6
6
 
@@ -9,6 +9,6 @@ This package serves as the single source of truth for all types and interfaces u
9
9
  ## Core Implementation
10
10
 
11
11
  - **Protocol Types**: Defines the request/response shapes for the local HTTP server (`OpenFileRequest`, `SnippetResponse`, `SendToAiRequest`).
12
- - **Configuration Types**: Defines the user configuration structure (`InspectoUserConfig`, `UnpluginOptions`, `InspectorOptions`).
13
- - **Domain Models**: Contains definitions for AI targets (`AiTool`), tool modes (`ToolMode`), and IDE types (`IdeType`).
12
+ - **Configuration Types**: Defines the user configuration structure (`InspectoSettings`, `UnpluginOptions`, `InspectorOptions`).
13
+ - **Domain Models**: Contains definitions for AI targets (`Provider`), tool modes (`ProviderMode`), and IDE types (`IdeType`).
14
14
  - **Constants**: Provides shared constants like `DEFAULT_INTENTS` and tool mode mappings to keep behavior consistent across packages.
package/dist/index.cjs CHANGED
@@ -20,35 +20,122 @@ var __toCommonJS = (mod) => __copyProps(__defProp({}, "__esModule", { value: tru
20
20
  // src/index.ts
21
21
  var index_exports = {};
22
22
  __export(index_exports, {
23
- AI_TARGET_TYPE: () => AI_TARGET_TYPE,
24
- DEFAULT_TOOL_MODE: () => DEFAULT_TOOL_MODE,
23
+ DEFAULT_INTENTS: () => DEFAULT_INTENTS,
24
+ DEFAULT_PROVIDER_MODE: () => DEFAULT_PROVIDER_MODE,
25
+ INSPECTO_API_PATHS: () => INSPECTO_API_PATHS,
25
26
  VALID_MODES: () => VALID_MODES
26
27
  });
27
28
  module.exports = __toCommonJS(index_exports);
28
- var AI_TARGET_TYPE = {
29
- "github-copilot": "plugin",
30
- "claude-code": "plugin",
31
- gemini: "plugin",
32
- codex: "plugin",
33
- coco: "cli"
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
107
+ var VALID_MODES = {
108
+ copilot: ["extension"],
109
+ "claude-code": ["extension", "cli"],
110
+ gemini: ["extension", "cli"],
111
+ codex: ["extension", "cli"],
112
+ coco: ["cli"],
113
+ trae: ["builtin"],
114
+ cursor: ["builtin"]
34
115
  };
35
- var DEFAULT_TOOL_MODE = {
36
- "github-copilot": "plugin",
37
- "claude-code": "plugin",
38
- gemini: "plugin",
39
- codex: "plugin",
40
- coco: "cli"
116
+ var DEFAULT_PROVIDER_MODE = {
117
+ copilot: "extension",
118
+ "claude-code": "extension",
119
+ gemini: "extension",
120
+ codex: "extension",
121
+ coco: "cli",
122
+ trae: "builtin",
123
+ cursor: "builtin"
41
124
  };
42
- var VALID_MODES = {
43
- "github-copilot": ["plugin"],
44
- "claude-code": ["plugin", "cli"],
45
- gemini: ["plugin", "cli"],
46
- codex: ["plugin", "cli"],
47
- coco: ["cli"]
125
+ var INSPECTO_API_PATHS = {
126
+ HEALTH: "/inspecto/api/v1/health",
127
+ CLIENT_CONFIG: "/inspecto/api/v1/client/config",
128
+ IDE_INFO: "/inspecto/api/v1/ide/info",
129
+ IDE_OPEN: "/inspecto/api/v1/ide/open",
130
+ PROJECT_SNIPPET: "/inspecto/api/v1/project/snippet",
131
+ AI_DISPATCH: "/inspecto/api/v1/ai/dispatch",
132
+ AI_TICKET: "/inspecto/api/v1/ai/ticket"
133
+ // Usage: /inspecto/api/v1/ai/ticket/:id
48
134
  };
49
135
  // Annotate the CommonJS export names for ESM import in node:
50
136
  0 && (module.exports = {
51
- AI_TARGET_TYPE,
52
- DEFAULT_TOOL_MODE,
137
+ DEFAULT_INTENTS,
138
+ DEFAULT_PROVIDER_MODE,
139
+ INSPECTO_API_PATHS,
53
140
  VALID_MODES
54
141
  });
package/dist/index.d.cts CHANGED
@@ -1,13 +1,28 @@
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
+
1
13
  /** Modifier keys that can be used as inspector activation hotkeys */
2
14
  type HotKey = 'ctrlKey' | 'altKey' | 'metaKey' | 'shiftKey';
15
+ /**
16
+ * Hotkey configuration strings.
17
+ * E.g. "alt", "cmd+shift", or false to disable.
18
+ */
19
+ type HotKeyString = 'alt' | 'shift' | 'ctrl' | 'meta' | 'cmd' | 'alt+shift' | 'ctrl+shift' | 'meta+shift' | 'cmd+shift';
3
20
  /**
4
21
  * Hotkey configuration.
5
- * - Array of HotKey: all specified keys must be held simultaneously to activate
6
- * - false: disable hotkey activation entirely (use programmatic toggle only)
7
- * @default ['altKey']
8
- * @example ['ctrlKey', 'shiftKey'] — Ctrl+Shift to activate
22
+ * - String: modifier key or combo (e.g., "alt", "cmd+shift")
23
+ * - false: disable hotkey activation entirely
9
24
  */
10
- type HotKeys = HotKey[] | false;
25
+ type HotKeys = HotKeyString | false;
11
26
  /** Parsed source location from the data-inspecto attribute */
12
27
  interface SourceLocation {
13
28
  /** Absolute or relative file path depending on pathType config */
@@ -27,7 +42,7 @@ type SourceAttrValue = string;
27
42
  * - 'relative': path relative to project root — shorter, but may break with pnpm virtual store
28
43
  */
29
44
  type PathType = 'relative' | 'absolute';
30
- /** Configuration for the @inspecto/plugin build plugin */
45
+ /** Configuration for the @inspecto-dev/plugin build plugin */
31
46
  interface UnpluginOptions {
32
47
  /**
33
48
  * Additional file extensions to transform beyond .jsx/.tsx/.js/.ts
@@ -61,71 +76,69 @@ interface UnpluginOptions {
61
76
  * @default 'data-inspecto'
62
77
  */
63
78
  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
+ logLevel?: LogLevel;
64
88
  }
89
+ type LogLevel = 'info' | 'warn' | 'error' | 'silent';
65
90
  /** Supported IDEs */
66
- type IdeType = 'vscode' | 'unknown';
67
- /** All supported AI tools */
68
- type AiTool = 'github-copilot' | 'claude-code' | 'gemini' | 'codex' | 'coco';
69
- /** Backward compatibility alias */
70
- type AiTarget = AiTool;
71
- /** Whether the AI target is an editor plugin or a CLI tool */
72
- type ToolMode = 'plugin' | 'cli' | 'clipboard';
73
- /** Backward compatibility alias */
74
- type AiTargetType = ToolMode;
75
- interface ProviderConfig {
76
- type?: ToolMode;
77
- autoSend?: boolean;
78
- bin?: string;
79
- args?: string[];
80
- cwd?: string;
81
- }
91
+ type IdeType = 'vscode' | 'trae' | 'trae-cn' | 'cursor' | 'unknown';
92
+ /** All supported AI tool providers */
93
+ 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
+ type ProviderMode = 'extension' | 'cli' | 'clipboard' | 'builtin';
82
96
  interface InspectoSettings {
83
97
  ide?: IdeType;
84
- prefer?: string;
85
- hotKeys?: HotKeys;
86
- providers?: Record<string, ProviderConfig>;
98
+ /** Flat namespaced configuration (e.g. `provider.default`, `provider.claude-code.cli.bin`) */
99
+ [key: `provider.${string}`]: string | string[] | boolean | undefined;
100
+ 'inspector.hotKey'?: HotKeys;
101
+ /**
102
+ * Theme for the inspector panel.
103
+ */
104
+ 'inspector.theme'?: 'light' | 'dark' | 'auto';
87
105
  /**
88
106
  * Whether to inject the raw code snippet into the prompt.
89
107
  * Default is false (saves tokens, lets IDE AI read the file directly).
90
108
  */
91
- includeSnippet?: boolean;
92
- }
93
- /** Legacy configuration structure (for backward compatibility during migration) */
94
- interface LegacyInspectoUserConfig {
95
- defaultTarget?: AiTool;
96
- tools: Partial<Record<AiTool, {
97
- mode: ToolMode;
98
- cliBinary?: string;
99
- cliArgs?: string[];
100
- }>>;
101
- menuOrder?: AiTool[];
109
+ '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
+ 'prompt.autoSend'?: boolean;
102
115
  }
103
- /** Static mapping: target type (DEPRECATED: Use config resolution instead) */
104
- declare const AI_TARGET_TYPE: Record<AiTool, ToolMode>;
105
- declare const DEFAULT_TOOL_MODE: Record<AiTool, ToolMode>;
106
- /** Which modes each tool actually supports */
107
- declare const VALID_MODES: Record<AiTool, ToolMode[]>;
116
+ /** Static mapping: which modes each tool actually supports */
117
+ declare const VALID_MODES: Record<Provider, ProviderMode[]>;
118
+ declare const DEFAULT_PROVIDER_MODE: Record<Provider, ProviderMode>;
108
119
  interface ToolOverrides {
109
- type?: ToolMode;
120
+ type?: ProviderMode;
110
121
  binaryPath?: string;
111
122
  args?: string[];
112
123
  cwd?: string;
113
- autoSend?: boolean;
114
124
  coldStartDelay?: number;
115
125
  }
116
126
  interface AiPayload {
117
127
  ide: IdeType;
118
- target: AiTarget;
119
- targetType: AiTargetType;
128
+ target: Provider;
129
+ targetType: ProviderMode;
120
130
  prompt: string;
121
131
  filePath?: string;
122
132
  line?: number;
123
133
  column?: number;
124
134
  snippet?: string;
125
135
  overrides?: ToolOverrides;
136
+ 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
+ ticket?: string;
126
139
  }
127
140
  interface ChannelDef {
128
- type: ToolMode;
141
+ type: ProviderMode;
129
142
  execute: (payload: AiPayload) => Promise<void>;
130
143
  }
131
144
  interface IntentLabels {
@@ -215,6 +228,16 @@ interface InspectorOptions {
215
228
  */
216
229
  includeSnippet?: boolean;
217
230
  }
231
+
232
+ declare const INSPECTO_API_PATHS: {
233
+ readonly HEALTH: "/inspecto/api/v1/health";
234
+ readonly CLIENT_CONFIG: "/inspecto/api/v1/client/config";
235
+ readonly IDE_INFO: "/inspecto/api/v1/ide/info";
236
+ readonly IDE_OPEN: "/inspecto/api/v1/ide/open";
237
+ readonly PROJECT_SNIPPET: "/inspecto/api/v1/project/snippet";
238
+ readonly AI_DISPATCH: "/inspecto/api/v1/ai/dispatch";
239
+ readonly AI_TICKET: "/inspecto/api/v1/ai/ticket";
240
+ };
218
241
  /** POST /open — browser asks server to open file in IDE */
219
242
  interface OpenFileRequest {
220
243
  file: string;
@@ -253,25 +276,33 @@ interface SendToAiResponse {
253
276
  error?: string;
254
277
  /** Error code for structured error handling in the browser */
255
278
  errorCode?: AiErrorCode;
279
+ /** Payload for client-side fallback (e.g. copying to clipboard if IDE fails to handle URI) */
280
+ fallbackPayload?: {
281
+ prompt: string;
282
+ file: string;
283
+ };
256
284
  }
257
285
  /** Standard error codes returned by the local HTTP server */
258
286
  type AiErrorCode = 'IDE_NOT_FOUND' | 'EXTENSION_NOT_INSTALLED' | 'CLIPBOARD_WRITE_FAILED' | 'SNIPPET_TOO_LARGE' | 'FILE_NOT_FOUND' | 'UNKNOWN';
259
287
  interface ProviderInfo {
260
- mode: ToolMode;
288
+ mode: ProviderMode;
261
289
  installed: boolean;
262
290
  }
263
291
  interface IdeInfo {
264
292
  ide: IdeType;
265
293
  scheme: string;
266
- providers: Record<AiTool, ProviderInfo>;
294
+ workspaceRoot?: string;
295
+ providers: Record<Provider, ProviderInfo>;
267
296
  }
268
297
  /** GET /config response — browser-facing runtime configuration */
269
298
  interface InspectoConfig {
270
299
  ide: IdeType;
271
- providers: Record<AiTool, ProviderInfo>;
272
- providerOverrides?: Partial<Record<AiTool, ToolOverrides>>;
273
- prompts?: InspectoPromptsConfig;
300
+ /** List of AI targets available in the environment to show/enable in UI */
301
+ providers: Record<Provider, ProviderInfo>;
302
+ /** Fully resolved and merged list of intent configurations for the UI to display */
303
+ prompts?: IntentConfig[];
274
304
  hotKeys?: HotKeys;
305
+ theme?: 'light' | 'dark' | 'auto';
275
306
  includeSnippet?: boolean;
276
307
  }
277
308
  /** Shared mutable state managed by the local HTTP server module */
@@ -305,4 +336,4 @@ interface AiStrategyResult {
305
336
  errorCode?: AiErrorCode;
306
337
  }
307
338
 
308
- export { AI_TARGET_TYPE, type AiErrorCode, type AiPayload, type AiStrategyContext, type AiStrategyResult, type AiTarget, type AiTargetType, type AiTool, type ChannelDef, DEFAULT_TOOL_MODE, type HotKey, type HotKeys, type IdeInfo, type IdeType, type InspectoConfig, type InspectoPromptsConfig, type InspectoSettings, type InspectorOptions, type IntentConfig, type IntentLabels, type LegacyInspectoUserConfig, type OpenFileRequest, type PathType, type ProviderConfig, type ProviderInfo, type SendToAiRequest, type SendToAiResponse, type ServerState, type SnippetRequest, type SnippetResponse, type SourceAttrValue, type SourceLocation, type ToolMode, type ToolOverrides, type UnpluginOptions, VALID_MODES };
339
+ 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 };
package/dist/index.d.ts CHANGED
@@ -1,13 +1,28 @@
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
+
1
13
  /** Modifier keys that can be used as inspector activation hotkeys */
2
14
  type HotKey = 'ctrlKey' | 'altKey' | 'metaKey' | 'shiftKey';
15
+ /**
16
+ * Hotkey configuration strings.
17
+ * E.g. "alt", "cmd+shift", or false to disable.
18
+ */
19
+ type HotKeyString = 'alt' | 'shift' | 'ctrl' | 'meta' | 'cmd' | 'alt+shift' | 'ctrl+shift' | 'meta+shift' | 'cmd+shift';
3
20
  /**
4
21
  * Hotkey configuration.
5
- * - Array of HotKey: all specified keys must be held simultaneously to activate
6
- * - false: disable hotkey activation entirely (use programmatic toggle only)
7
- * @default ['altKey']
8
- * @example ['ctrlKey', 'shiftKey'] — Ctrl+Shift to activate
22
+ * - String: modifier key or combo (e.g., "alt", "cmd+shift")
23
+ * - false: disable hotkey activation entirely
9
24
  */
10
- type HotKeys = HotKey[] | false;
25
+ type HotKeys = HotKeyString | false;
11
26
  /** Parsed source location from the data-inspecto attribute */
12
27
  interface SourceLocation {
13
28
  /** Absolute or relative file path depending on pathType config */
@@ -27,7 +42,7 @@ type SourceAttrValue = string;
27
42
  * - 'relative': path relative to project root — shorter, but may break with pnpm virtual store
28
43
  */
29
44
  type PathType = 'relative' | 'absolute';
30
- /** Configuration for the @inspecto/plugin build plugin */
45
+ /** Configuration for the @inspecto-dev/plugin build plugin */
31
46
  interface UnpluginOptions {
32
47
  /**
33
48
  * Additional file extensions to transform beyond .jsx/.tsx/.js/.ts
@@ -61,71 +76,69 @@ interface UnpluginOptions {
61
76
  * @default 'data-inspecto'
62
77
  */
63
78
  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
+ logLevel?: LogLevel;
64
88
  }
89
+ type LogLevel = 'info' | 'warn' | 'error' | 'silent';
65
90
  /** Supported IDEs */
66
- type IdeType = 'vscode' | 'unknown';
67
- /** All supported AI tools */
68
- type AiTool = 'github-copilot' | 'claude-code' | 'gemini' | 'codex' | 'coco';
69
- /** Backward compatibility alias */
70
- type AiTarget = AiTool;
71
- /** Whether the AI target is an editor plugin or a CLI tool */
72
- type ToolMode = 'plugin' | 'cli' | 'clipboard';
73
- /** Backward compatibility alias */
74
- type AiTargetType = ToolMode;
75
- interface ProviderConfig {
76
- type?: ToolMode;
77
- autoSend?: boolean;
78
- bin?: string;
79
- args?: string[];
80
- cwd?: string;
81
- }
91
+ type IdeType = 'vscode' | 'trae' | 'trae-cn' | 'cursor' | 'unknown';
92
+ /** All supported AI tool providers */
93
+ 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
+ type ProviderMode = 'extension' | 'cli' | 'clipboard' | 'builtin';
82
96
  interface InspectoSettings {
83
97
  ide?: IdeType;
84
- prefer?: string;
85
- hotKeys?: HotKeys;
86
- providers?: Record<string, ProviderConfig>;
98
+ /** Flat namespaced configuration (e.g. `provider.default`, `provider.claude-code.cli.bin`) */
99
+ [key: `provider.${string}`]: string | string[] | boolean | undefined;
100
+ 'inspector.hotKey'?: HotKeys;
101
+ /**
102
+ * Theme for the inspector panel.
103
+ */
104
+ 'inspector.theme'?: 'light' | 'dark' | 'auto';
87
105
  /**
88
106
  * Whether to inject the raw code snippet into the prompt.
89
107
  * Default is false (saves tokens, lets IDE AI read the file directly).
90
108
  */
91
- includeSnippet?: boolean;
92
- }
93
- /** Legacy configuration structure (for backward compatibility during migration) */
94
- interface LegacyInspectoUserConfig {
95
- defaultTarget?: AiTool;
96
- tools: Partial<Record<AiTool, {
97
- mode: ToolMode;
98
- cliBinary?: string;
99
- cliArgs?: string[];
100
- }>>;
101
- menuOrder?: AiTool[];
109
+ '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
+ 'prompt.autoSend'?: boolean;
102
115
  }
103
- /** Static mapping: target type (DEPRECATED: Use config resolution instead) */
104
- declare const AI_TARGET_TYPE: Record<AiTool, ToolMode>;
105
- declare const DEFAULT_TOOL_MODE: Record<AiTool, ToolMode>;
106
- /** Which modes each tool actually supports */
107
- declare const VALID_MODES: Record<AiTool, ToolMode[]>;
116
+ /** Static mapping: which modes each tool actually supports */
117
+ declare const VALID_MODES: Record<Provider, ProviderMode[]>;
118
+ declare const DEFAULT_PROVIDER_MODE: Record<Provider, ProviderMode>;
108
119
  interface ToolOverrides {
109
- type?: ToolMode;
120
+ type?: ProviderMode;
110
121
  binaryPath?: string;
111
122
  args?: string[];
112
123
  cwd?: string;
113
- autoSend?: boolean;
114
124
  coldStartDelay?: number;
115
125
  }
116
126
  interface AiPayload {
117
127
  ide: IdeType;
118
- target: AiTarget;
119
- targetType: AiTargetType;
128
+ target: Provider;
129
+ targetType: ProviderMode;
120
130
  prompt: string;
121
131
  filePath?: string;
122
132
  line?: number;
123
133
  column?: number;
124
134
  snippet?: string;
125
135
  overrides?: ToolOverrides;
136
+ 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
+ ticket?: string;
126
139
  }
127
140
  interface ChannelDef {
128
- type: ToolMode;
141
+ type: ProviderMode;
129
142
  execute: (payload: AiPayload) => Promise<void>;
130
143
  }
131
144
  interface IntentLabels {
@@ -215,6 +228,16 @@ interface InspectorOptions {
215
228
  */
216
229
  includeSnippet?: boolean;
217
230
  }
231
+
232
+ declare const INSPECTO_API_PATHS: {
233
+ readonly HEALTH: "/inspecto/api/v1/health";
234
+ readonly CLIENT_CONFIG: "/inspecto/api/v1/client/config";
235
+ readonly IDE_INFO: "/inspecto/api/v1/ide/info";
236
+ readonly IDE_OPEN: "/inspecto/api/v1/ide/open";
237
+ readonly PROJECT_SNIPPET: "/inspecto/api/v1/project/snippet";
238
+ readonly AI_DISPATCH: "/inspecto/api/v1/ai/dispatch";
239
+ readonly AI_TICKET: "/inspecto/api/v1/ai/ticket";
240
+ };
218
241
  /** POST /open — browser asks server to open file in IDE */
219
242
  interface OpenFileRequest {
220
243
  file: string;
@@ -253,25 +276,33 @@ interface SendToAiResponse {
253
276
  error?: string;
254
277
  /** Error code for structured error handling in the browser */
255
278
  errorCode?: AiErrorCode;
279
+ /** Payload for client-side fallback (e.g. copying to clipboard if IDE fails to handle URI) */
280
+ fallbackPayload?: {
281
+ prompt: string;
282
+ file: string;
283
+ };
256
284
  }
257
285
  /** Standard error codes returned by the local HTTP server */
258
286
  type AiErrorCode = 'IDE_NOT_FOUND' | 'EXTENSION_NOT_INSTALLED' | 'CLIPBOARD_WRITE_FAILED' | 'SNIPPET_TOO_LARGE' | 'FILE_NOT_FOUND' | 'UNKNOWN';
259
287
  interface ProviderInfo {
260
- mode: ToolMode;
288
+ mode: ProviderMode;
261
289
  installed: boolean;
262
290
  }
263
291
  interface IdeInfo {
264
292
  ide: IdeType;
265
293
  scheme: string;
266
- providers: Record<AiTool, ProviderInfo>;
294
+ workspaceRoot?: string;
295
+ providers: Record<Provider, ProviderInfo>;
267
296
  }
268
297
  /** GET /config response — browser-facing runtime configuration */
269
298
  interface InspectoConfig {
270
299
  ide: IdeType;
271
- providers: Record<AiTool, ProviderInfo>;
272
- providerOverrides?: Partial<Record<AiTool, ToolOverrides>>;
273
- prompts?: InspectoPromptsConfig;
300
+ /** List of AI targets available in the environment to show/enable in UI */
301
+ providers: Record<Provider, ProviderInfo>;
302
+ /** Fully resolved and merged list of intent configurations for the UI to display */
303
+ prompts?: IntentConfig[];
274
304
  hotKeys?: HotKeys;
305
+ theme?: 'light' | 'dark' | 'auto';
275
306
  includeSnippet?: boolean;
276
307
  }
277
308
  /** Shared mutable state managed by the local HTTP server module */
@@ -305,4 +336,4 @@ interface AiStrategyResult {
305
336
  errorCode?: AiErrorCode;
306
337
  }
307
338
 
308
- export { AI_TARGET_TYPE, type AiErrorCode, type AiPayload, type AiStrategyContext, type AiStrategyResult, type AiTarget, type AiTargetType, type AiTool, type ChannelDef, DEFAULT_TOOL_MODE, type HotKey, type HotKeys, type IdeInfo, type IdeType, type InspectoConfig, type InspectoPromptsConfig, type InspectoSettings, type InspectorOptions, type IntentConfig, type IntentLabels, type LegacyInspectoUserConfig, type OpenFileRequest, type PathType, type ProviderConfig, type ProviderInfo, type SendToAiRequest, type SendToAiResponse, type ServerState, type SnippetRequest, type SnippetResponse, type SourceAttrValue, type SourceLocation, type ToolMode, type ToolOverrides, type UnpluginOptions, VALID_MODES };
339
+ 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 };
package/dist/index.js CHANGED
@@ -1,27 +1,111 @@
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
+
1
77
  // src/index.ts
2
- var AI_TARGET_TYPE = {
3
- "github-copilot": "plugin",
4
- "claude-code": "plugin",
5
- gemini: "plugin",
6
- codex: "plugin",
7
- coco: "cli"
78
+ var VALID_MODES = {
79
+ copilot: ["extension"],
80
+ "claude-code": ["extension", "cli"],
81
+ gemini: ["extension", "cli"],
82
+ codex: ["extension", "cli"],
83
+ coco: ["cli"],
84
+ trae: ["builtin"],
85
+ cursor: ["builtin"]
8
86
  };
9
- var DEFAULT_TOOL_MODE = {
10
- "github-copilot": "plugin",
11
- "claude-code": "plugin",
12
- gemini: "plugin",
13
- codex: "plugin",
14
- coco: "cli"
87
+ var DEFAULT_PROVIDER_MODE = {
88
+ copilot: "extension",
89
+ "claude-code": "extension",
90
+ gemini: "extension",
91
+ codex: "extension",
92
+ coco: "cli",
93
+ trae: "builtin",
94
+ cursor: "builtin"
15
95
  };
16
- var VALID_MODES = {
17
- "github-copilot": ["plugin"],
18
- "claude-code": ["plugin", "cli"],
19
- gemini: ["plugin", "cli"],
20
- codex: ["plugin", "cli"],
21
- coco: ["cli"]
96
+ var INSPECTO_API_PATHS = {
97
+ HEALTH: "/inspecto/api/v1/health",
98
+ CLIENT_CONFIG: "/inspecto/api/v1/client/config",
99
+ IDE_INFO: "/inspecto/api/v1/ide/info",
100
+ IDE_OPEN: "/inspecto/api/v1/ide/open",
101
+ PROJECT_SNIPPET: "/inspecto/api/v1/project/snippet",
102
+ AI_DISPATCH: "/inspecto/api/v1/ai/dispatch",
103
+ AI_TICKET: "/inspecto/api/v1/ai/ticket"
104
+ // Usage: /inspecto/api/v1/ai/ticket/:id
22
105
  };
23
106
  export {
24
- AI_TARGET_TYPE,
25
- DEFAULT_TOOL_MODE,
107
+ DEFAULT_INTENTS,
108
+ DEFAULT_PROVIDER_MODE,
109
+ INSPECTO_API_PATHS,
26
110
  VALID_MODES
27
111
  };
package/package.json CHANGED
@@ -1,12 +1,9 @@
1
1
  {
2
2
  "name": "@inspecto-dev/types",
3
- "version": "0.2.0-alpha.0",
3
+ "version": "0.2.0-alpha.2",
4
4
  "description": "Shared TypeScript definitions for the Inspecto monorepo",
5
5
  "license": "MIT",
6
6
  "type": "module",
7
- "publishConfig": {
8
- "access": "public"
9
- },
10
7
  "repository": {
11
8
  "type": "git",
12
9
  "url": "git+https://github.com/inspecto-dev/inspecto.git",
@@ -36,10 +33,17 @@
36
33
  "main": "./dist/index.cjs",
37
34
  "module": "./dist/index.js",
38
35
  "types": "./dist/index.d.ts",
36
+ "devDependencies": {
37
+ "tsup": "^8.3.5",
38
+ "typescript": "^5.7.2"
39
+ },
40
+ "publishConfig": {
41
+ "access": "public"
42
+ },
39
43
  "scripts": {
40
44
  "build": "tsup src/index.ts --format esm,cjs --dts",
41
45
  "dev": "tsup src/index.ts --format esm,cjs --dts --watch",
42
46
  "typecheck": "tsc --noEmit",
43
47
  "clean": "rm -rf dist"
44
48
  }
45
- }
49
+ }