@inspecto-dev/cli 0.2.0-alpha.5 → 0.3.0-alpha.1
This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
- package/.turbo/turbo-build.log +19 -20
- package/CHANGELOG.md +22 -0
- package/README.md +93 -11
- package/bin/inspecto.js +5 -1
- package/dist/bin.d.ts +5 -1
- package/dist/bin.js +530 -49
- package/dist/chunk-FZS2TLXQ.js +3140 -0
- package/dist/index.d.ts +233 -2
- package/dist/index.js +17 -3
- package/package.json +3 -2
- package/src/bin.ts +286 -66
- package/src/commands/apply.ts +118 -0
- package/src/commands/detect.ts +59 -0
- package/src/commands/doctor.ts +225 -72
- package/src/commands/init.ts +143 -183
- package/src/commands/integration-install.ts +452 -0
- package/src/commands/onboard.ts +50 -0
- package/src/commands/plan.ts +41 -0
- package/src/detect/build-tool.ts +107 -3
- package/src/index.ts +17 -2
- package/src/inject/ast-injector.ts +17 -6
- package/src/inject/extension.ts +40 -22
- package/src/inject/gitignore.ts +10 -3
- package/src/instructions.ts +60 -46
- package/src/onboarding/apply.ts +364 -0
- package/src/onboarding/context.ts +36 -0
- package/src/onboarding/planner.ts +284 -0
- package/src/onboarding/session.ts +434 -0
- package/src/onboarding/target-resolution.ts +116 -0
- package/src/prompts.ts +54 -11
- package/src/types.ts +184 -0
- package/src/utils/fs.ts +2 -1
- package/src/utils/logger.ts +9 -0
- package/src/utils/output.ts +40 -0
- package/tests/apply.test.ts +583 -0
- package/tests/ast-injector.test.ts +50 -0
- package/tests/build-tool.test.ts +3 -5
- package/tests/detect.test.ts +94 -0
- package/tests/doctor.test.ts +224 -0
- package/tests/init.test.ts +364 -0
- package/tests/install-wrapper.test.ts +76 -0
- package/tests/instructions.test.ts +61 -0
- package/tests/integration-install.test.ts +294 -0
- package/tests/logger.test.ts +100 -0
- package/tests/onboard.test.ts +258 -0
- package/tests/plan.test.ts +713 -0
- package/tests/workspace-build-tool.test.ts +75 -0
- package/.turbo/turbo-test.log +0 -16
- package/dist/chunk-MIHQGC3L.js +0 -1720
package/src/types.ts
CHANGED
|
@@ -8,6 +8,30 @@ export type PackageManager = 'bun' | 'pnpm' | 'yarn' | 'npm'
|
|
|
8
8
|
/** Supported build tools (v1) */
|
|
9
9
|
export type BuildTool = 'vite' | 'webpack' | 'rspack' | 'rsbuild' | 'esbuild' | 'rollup'
|
|
10
10
|
|
|
11
|
+
/** Machine-readable status for onboarding commands */
|
|
12
|
+
export type CommandStatus = 'ok' | 'warning' | 'blocked' | 'error'
|
|
13
|
+
|
|
14
|
+
/** Assistant-facing status for single-entry onboarding */
|
|
15
|
+
export type OnboardStatus =
|
|
16
|
+
| 'success'
|
|
17
|
+
| 'partial_success'
|
|
18
|
+
| 'needs_target_selection'
|
|
19
|
+
| 'needs_confirmation'
|
|
20
|
+
| 'error'
|
|
21
|
+
|
|
22
|
+
/** Structured message emitted by onboarding commands */
|
|
23
|
+
export interface CommandMessage {
|
|
24
|
+
code: string
|
|
25
|
+
message: string
|
|
26
|
+
}
|
|
27
|
+
|
|
28
|
+
export interface OnboardingProvider {
|
|
29
|
+
id: string
|
|
30
|
+
label: string
|
|
31
|
+
supported: boolean
|
|
32
|
+
preferredMode: 'cli' | 'extension'
|
|
33
|
+
}
|
|
34
|
+
|
|
11
35
|
/** Detected build tool with its config path */
|
|
12
36
|
export interface BuildToolDetection {
|
|
13
37
|
tool: BuildTool
|
|
@@ -22,6 +46,166 @@ export interface BuildToolDetection {
|
|
|
22
46
|
packagePath?: string
|
|
23
47
|
}
|
|
24
48
|
|
|
49
|
+
/** Normalized onboarding context shared by detection/planning */
|
|
50
|
+
export interface OnboardingContext {
|
|
51
|
+
root: string
|
|
52
|
+
packageManager: PackageManager
|
|
53
|
+
buildTools: {
|
|
54
|
+
supported: BuildToolDetection[]
|
|
55
|
+
unsupported: string[]
|
|
56
|
+
}
|
|
57
|
+
frameworks: {
|
|
58
|
+
supported: string[]
|
|
59
|
+
unsupported: string[]
|
|
60
|
+
}
|
|
61
|
+
ides: Array<{ ide: string; supported: boolean }>
|
|
62
|
+
providers: OnboardingProvider[]
|
|
63
|
+
}
|
|
64
|
+
|
|
65
|
+
export interface OnboardingTargetCandidate {
|
|
66
|
+
packagePath: string
|
|
67
|
+
configPath: string
|
|
68
|
+
buildTool: BuildTool
|
|
69
|
+
frameworks: string[]
|
|
70
|
+
automaticInjection: boolean
|
|
71
|
+
}
|
|
72
|
+
|
|
73
|
+
export interface OnboardingTargetResolution {
|
|
74
|
+
status: 'resolved' | 'needs_selection'
|
|
75
|
+
selected?: OnboardingTargetCandidate
|
|
76
|
+
candidates: OnboardingTargetCandidate[]
|
|
77
|
+
reason: string
|
|
78
|
+
}
|
|
79
|
+
|
|
80
|
+
export interface OnboardingSummary {
|
|
81
|
+
headline: string
|
|
82
|
+
changes: string[]
|
|
83
|
+
risks: string[]
|
|
84
|
+
manualFollowUp: string[]
|
|
85
|
+
}
|
|
86
|
+
|
|
87
|
+
export interface OnboardingConfirmation {
|
|
88
|
+
required: boolean
|
|
89
|
+
reason?: string
|
|
90
|
+
question?: string
|
|
91
|
+
}
|
|
92
|
+
|
|
93
|
+
export interface OnboardingExecutionResult {
|
|
94
|
+
changedFiles: string[]
|
|
95
|
+
installedDependencies: string[]
|
|
96
|
+
selectedProviderDefault?: string
|
|
97
|
+
selectedIDE?: string
|
|
98
|
+
mutations: Mutation[]
|
|
99
|
+
}
|
|
100
|
+
|
|
101
|
+
export interface OnboardingDiagnostics {
|
|
102
|
+
warnings: string[]
|
|
103
|
+
errors: string[]
|
|
104
|
+
nextSteps: string[]
|
|
105
|
+
}
|
|
106
|
+
|
|
107
|
+
export interface OnboardingIdeExtensionStatus {
|
|
108
|
+
required: boolean
|
|
109
|
+
installed: boolean
|
|
110
|
+
manualRequired: boolean
|
|
111
|
+
installCommand?: string
|
|
112
|
+
marketplaceUrl?: string
|
|
113
|
+
openVsxUrl?: string
|
|
114
|
+
}
|
|
115
|
+
|
|
116
|
+
export interface OnboardingVerification {
|
|
117
|
+
available: boolean
|
|
118
|
+
devCommand?: string
|
|
119
|
+
message: string
|
|
120
|
+
}
|
|
121
|
+
|
|
122
|
+
export interface ResolvedOnboardingSession {
|
|
123
|
+
status: OnboardStatus
|
|
124
|
+
target: OnboardingTargetResolution
|
|
125
|
+
summary: OnboardingSummary
|
|
126
|
+
confirmation: OnboardingConfirmation
|
|
127
|
+
verification: OnboardingVerification
|
|
128
|
+
context: OnboardingContext
|
|
129
|
+
plan: PlanResult
|
|
130
|
+
projectRoot: string
|
|
131
|
+
selectedIDE?: { ide: string; supported: boolean } | null
|
|
132
|
+
providerDefault?: string
|
|
133
|
+
}
|
|
134
|
+
|
|
135
|
+
export interface OnboardCommandResult {
|
|
136
|
+
status: OnboardStatus
|
|
137
|
+
target: OnboardingTargetResolution
|
|
138
|
+
summary: OnboardingSummary
|
|
139
|
+
confirmation: OnboardingConfirmation
|
|
140
|
+
ideExtension?: OnboardingIdeExtensionStatus
|
|
141
|
+
verification?: OnboardingVerification
|
|
142
|
+
result?: OnboardingExecutionResult
|
|
143
|
+
diagnostics?: OnboardingDiagnostics
|
|
144
|
+
}
|
|
145
|
+
|
|
146
|
+
/** Machine-readable detection output for skill-first onboarding */
|
|
147
|
+
export interface DetectionResult {
|
|
148
|
+
status: CommandStatus
|
|
149
|
+
warnings: CommandMessage[]
|
|
150
|
+
blockers: CommandMessage[]
|
|
151
|
+
project: {
|
|
152
|
+
root: string
|
|
153
|
+
packageManager: PackageManager
|
|
154
|
+
}
|
|
155
|
+
environment: {
|
|
156
|
+
frameworks: string[]
|
|
157
|
+
unsupportedFrameworks: string[]
|
|
158
|
+
buildTools: BuildToolDetection[]
|
|
159
|
+
unsupportedBuildTools: string[]
|
|
160
|
+
ides: Array<{ ide: string; supported: boolean }>
|
|
161
|
+
providers: OnboardingProvider[]
|
|
162
|
+
}
|
|
163
|
+
}
|
|
164
|
+
|
|
165
|
+
/** Machine-readable onboarding plan output */
|
|
166
|
+
export interface PlanResult {
|
|
167
|
+
status: CommandStatus
|
|
168
|
+
warnings: CommandMessage[]
|
|
169
|
+
blockers: CommandMessage[]
|
|
170
|
+
strategy: 'supported' | 'manual' | 'unsupported'
|
|
171
|
+
actions: Array<{
|
|
172
|
+
type: 'install_dependency' | 'modify_file' | 'install_extension' | 'manual_step'
|
|
173
|
+
target: string
|
|
174
|
+
description: string
|
|
175
|
+
}>
|
|
176
|
+
defaults: {
|
|
177
|
+
provider?: string
|
|
178
|
+
ide?: string
|
|
179
|
+
shared: boolean
|
|
180
|
+
extension: boolean
|
|
181
|
+
}
|
|
182
|
+
}
|
|
183
|
+
|
|
184
|
+
/** A single doctor diagnostic check/result */
|
|
185
|
+
export interface DoctorDiagnostic {
|
|
186
|
+
code: string
|
|
187
|
+
status: 'ok' | 'warning' | 'error'
|
|
188
|
+
message: string
|
|
189
|
+
hints: string[]
|
|
190
|
+
details?: Record<string, unknown>
|
|
191
|
+
}
|
|
192
|
+
|
|
193
|
+
/** Machine-readable diagnostics output for `inspecto doctor` */
|
|
194
|
+
export interface DoctorResult {
|
|
195
|
+
status: CommandStatus
|
|
196
|
+
summary: {
|
|
197
|
+
errors: number
|
|
198
|
+
warnings: number
|
|
199
|
+
}
|
|
200
|
+
project: {
|
|
201
|
+
root: string
|
|
202
|
+
packageManager?: PackageManager
|
|
203
|
+
}
|
|
204
|
+
errors: DoctorDiagnostic[]
|
|
205
|
+
warnings: DoctorDiagnostic[]
|
|
206
|
+
checks: DoctorDiagnostic[]
|
|
207
|
+
}
|
|
208
|
+
|
|
25
209
|
/** Options passed to `inspecto init` */
|
|
26
210
|
export interface InitOptions {
|
|
27
211
|
shared: boolean
|
package/src/utils/fs.ts
CHANGED
|
@@ -55,7 +55,8 @@ export async function removeDir(dirPath: string): Promise<void> {
|
|
|
55
55
|
/** Read and parse JSON file */
|
|
56
56
|
export async function readJSON<T = unknown>(filePath: string): Promise<T | null> {
|
|
57
57
|
const text = await readFile(filePath)
|
|
58
|
-
if (
|
|
58
|
+
if (text === null) return null
|
|
59
|
+
if (text.trim() === '') return {} as T
|
|
59
60
|
try {
|
|
60
61
|
return JSON.parse(text) as T
|
|
61
62
|
} catch {
|
package/src/utils/logger.ts
CHANGED
|
@@ -57,6 +57,15 @@ export const log = {
|
|
|
57
57
|
console.log()
|
|
58
58
|
},
|
|
59
59
|
|
|
60
|
+
/** Copy-friendly code block without box characters */
|
|
61
|
+
copyableCodeBlock(lines: string[]) {
|
|
62
|
+
console.log()
|
|
63
|
+
for (const line of lines) {
|
|
64
|
+
console.log(` ${line}`)
|
|
65
|
+
}
|
|
66
|
+
console.log()
|
|
67
|
+
},
|
|
68
|
+
|
|
60
69
|
/** Dry-run prefix */
|
|
61
70
|
dryRun(text: string) {
|
|
62
71
|
console.log(` ${pc.blue('[dry-run]')} ${text}`)
|
|
@@ -0,0 +1,40 @@
|
|
|
1
|
+
import { log } from './logger.js'
|
|
2
|
+
|
|
3
|
+
interface ReportCommandErrorOptions {
|
|
4
|
+
debug?: boolean
|
|
5
|
+
json?: boolean
|
|
6
|
+
}
|
|
7
|
+
|
|
8
|
+
export function writeCommandOutput<T>(result: T, json: boolean, renderText: (value: T) => void): T {
|
|
9
|
+
if (json) {
|
|
10
|
+
console.log(JSON.stringify(result, null, 2))
|
|
11
|
+
return result
|
|
12
|
+
}
|
|
13
|
+
|
|
14
|
+
renderText(result)
|
|
15
|
+
return result
|
|
16
|
+
}
|
|
17
|
+
|
|
18
|
+
export function reportCommandError(error: unknown, options: ReportCommandErrorOptions = {}): void {
|
|
19
|
+
const message = error instanceof Error ? error.message : String(error)
|
|
20
|
+
const stack = error instanceof Error ? error.stack : undefined
|
|
21
|
+
|
|
22
|
+
if (options.json) {
|
|
23
|
+
const payload = {
|
|
24
|
+
status: 'error' as const,
|
|
25
|
+
error: {
|
|
26
|
+
message,
|
|
27
|
+
...(options.debug && stack ? { stack } : {}),
|
|
28
|
+
},
|
|
29
|
+
}
|
|
30
|
+
|
|
31
|
+
console.error(JSON.stringify(payload, null, 2))
|
|
32
|
+
return
|
|
33
|
+
}
|
|
34
|
+
|
|
35
|
+
log.error(message)
|
|
36
|
+
|
|
37
|
+
if (options.debug && stack) {
|
|
38
|
+
console.error(stack)
|
|
39
|
+
}
|
|
40
|
+
}
|