@inspecto-dev/types 0.2.0-alpha.1 → 0.2.0-alpha.3
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/README.md +2 -2
- package/dist/index.cjs +109 -22
- package/dist/index.d.cts +82 -51
- package/dist/index.d.ts +82 -51
- package/dist/index.js +104 -20
- package/package.json +5 -1
package/README.md
CHANGED
|
@@ -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 (`
|
|
13
|
-
- **Domain Models**: Contains definitions for AI targets (`
|
|
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
|
-
|
|
24
|
-
|
|
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
|
-
|
|
29
|
-
|
|
30
|
-
|
|
31
|
-
|
|
32
|
-
|
|
33
|
-
|
|
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
|
|
36
|
-
|
|
37
|
-
"claude-code": "
|
|
38
|
-
gemini: "
|
|
39
|
-
codex: "
|
|
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
|
|
43
|
-
|
|
44
|
-
|
|
45
|
-
|
|
46
|
-
|
|
47
|
-
|
|
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
|
-
|
|
52
|
-
|
|
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
|
-
* -
|
|
6
|
-
* - false: disable hotkey activation entirely
|
|
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 =
|
|
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 */
|
|
@@ -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
|
|
68
|
-
type
|
|
69
|
-
/**
|
|
70
|
-
type
|
|
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
|
-
|
|
85
|
-
|
|
86
|
-
|
|
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
|
-
|
|
94
|
-
|
|
95
|
-
|
|
96
|
-
|
|
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:
|
|
104
|
-
declare const
|
|
105
|
-
declare const
|
|
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?:
|
|
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:
|
|
119
|
-
targetType:
|
|
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:
|
|
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:
|
|
288
|
+
mode: ProviderMode;
|
|
261
289
|
installed: boolean;
|
|
262
290
|
}
|
|
263
291
|
interface IdeInfo {
|
|
264
292
|
ide: IdeType;
|
|
265
293
|
scheme: string;
|
|
266
|
-
|
|
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
|
-
|
|
272
|
-
|
|
273
|
-
|
|
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 {
|
|
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
|
-
* -
|
|
6
|
-
* - false: disable hotkey activation entirely
|
|
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 =
|
|
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 */
|
|
@@ -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
|
|
68
|
-
type
|
|
69
|
-
/**
|
|
70
|
-
type
|
|
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
|
-
|
|
85
|
-
|
|
86
|
-
|
|
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
|
-
|
|
94
|
-
|
|
95
|
-
|
|
96
|
-
|
|
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:
|
|
104
|
-
declare const
|
|
105
|
-
declare const
|
|
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?:
|
|
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:
|
|
119
|
-
targetType:
|
|
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:
|
|
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:
|
|
288
|
+
mode: ProviderMode;
|
|
261
289
|
installed: boolean;
|
|
262
290
|
}
|
|
263
291
|
interface IdeInfo {
|
|
264
292
|
ide: IdeType;
|
|
265
293
|
scheme: string;
|
|
266
|
-
|
|
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
|
-
|
|
272
|
-
|
|
273
|
-
|
|
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 {
|
|
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
|
|
3
|
-
|
|
4
|
-
"claude-code": "
|
|
5
|
-
gemini: "
|
|
6
|
-
codex: "
|
|
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
|
|
10
|
-
|
|
11
|
-
"claude-code": "
|
|
12
|
-
gemini: "
|
|
13
|
-
codex: "
|
|
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
|
|
17
|
-
|
|
18
|
-
|
|
19
|
-
|
|
20
|
-
|
|
21
|
-
|
|
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
|
-
|
|
25
|
-
|
|
107
|
+
DEFAULT_INTENTS,
|
|
108
|
+
DEFAULT_PROVIDER_MODE,
|
|
109
|
+
INSPECTO_API_PATHS,
|
|
26
110
|
VALID_MODES
|
|
27
111
|
};
|
package/package.json
CHANGED
|
@@ -1,6 +1,6 @@
|
|
|
1
1
|
{
|
|
2
2
|
"name": "@inspecto-dev/types",
|
|
3
|
-
"version": "0.2.0-alpha.
|
|
3
|
+
"version": "0.2.0-alpha.3",
|
|
4
4
|
"description": "Shared TypeScript definitions for the Inspecto monorepo",
|
|
5
5
|
"license": "MIT",
|
|
6
6
|
"type": "module",
|
|
@@ -33,6 +33,10 @@
|
|
|
33
33
|
"main": "./dist/index.cjs",
|
|
34
34
|
"module": "./dist/index.js",
|
|
35
35
|
"types": "./dist/index.d.ts",
|
|
36
|
+
"devDependencies": {
|
|
37
|
+
"tsup": "^8.3.5",
|
|
38
|
+
"typescript": "^5.7.2"
|
|
39
|
+
},
|
|
36
40
|
"publishConfig": {
|
|
37
41
|
"access": "public"
|
|
38
42
|
},
|