@inspecto-dev/cli 0.2.0-alpha.4 → 0.2.0-alpha.6
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 +8 -8
- package/.turbo/turbo-test.log +16 -21
- package/CHANGELOG.md +12 -0
- package/README.md +58 -11
- package/bin/inspecto.js +5 -1
- package/dist/bin.d.ts +5 -1
- package/dist/bin.js +89 -50
- package/dist/{chunk-EUCQCD3Y.js → chunk-PDDFPQJS.js} +1954 -1053
- package/dist/index.d.ts +128 -2
- package/dist/index.js +15 -3
- package/package.json +2 -1
- package/src/bin.ts +139 -67
- package/src/commands/apply.ts +114 -0
- package/src/commands/detect.ts +59 -0
- package/src/commands/doctor.ts +225 -72
- package/src/commands/init.ts +106 -183
- package/src/commands/plan.ts +41 -0
- package/src/detect/build-tool.ts +107 -3
- package/src/index.ts +13 -2
- package/src/inject/ast-injector.ts +20 -9
- package/src/inject/extension.ts +3 -1
- package/src/inject/strategies/vite.ts +2 -1
- package/src/instructions.ts +60 -46
- package/src/onboarding/apply.ts +325 -0
- package/src/onboarding/context.ts +36 -0
- package/src/onboarding/planner.ts +278 -0
- package/src/prompts.ts +54 -11
- package/src/types.ts +95 -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 +537 -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 +333 -0
- package/tests/instructions.test.ts +61 -0
- package/tests/logger.test.ts +100 -0
- package/tests/plan.test.ts +713 -0
- package/tests/workspace-build-tool.test.ts +75 -0
package/.turbo/turbo-build.log
CHANGED
|
@@ -1,6 +1,6 @@
|
|
|
1
1
|
|
|
2
2
|
|
|
3
|
-
> @inspecto-dev/cli@0.2.0-alpha.
|
|
3
|
+
> @inspecto-dev/cli@0.2.0-alpha.5 build /Users/bytedance/Works/hugo.felix/inspecto/packages/cli
|
|
4
4
|
> tsup
|
|
5
5
|
|
|
6
6
|
[34mCLI[39m Building entry: src/bin.ts, src/index.ts
|
|
@@ -10,11 +10,11 @@
|
|
|
10
10
|
[34mCLI[39m Target: node18
|
|
11
11
|
[34mCLI[39m Cleaning output folder
|
|
12
12
|
[34mESM[39m Build start
|
|
13
|
-
[32mESM[39m [1mdist/
|
|
14
|
-
[32mESM[39m [1mdist/chunk-
|
|
15
|
-
[32mESM[39m [1mdist/
|
|
16
|
-
[32mESM[39m ⚡️ Build success in
|
|
13
|
+
[32mESM[39m [1mdist/bin.js [22m[32m4.61 KB[39m
|
|
14
|
+
[32mESM[39m [1mdist/chunk-PDDFPQJS.js [22m[32m85.74 KB[39m
|
|
15
|
+
[32mESM[39m [1mdist/index.js [22m[32m297.00 B[39m
|
|
16
|
+
[32mESM[39m ⚡️ Build success in 43ms
|
|
17
17
|
DTS Build start
|
|
18
|
-
DTS ⚡️ Build success in
|
|
19
|
-
DTS dist/bin.d.ts
|
|
20
|
-
DTS dist/index.d.ts
|
|
18
|
+
DTS ⚡️ Build success in 1330ms
|
|
19
|
+
DTS dist/bin.d.ts 184.00 B
|
|
20
|
+
DTS dist/index.d.ts 4.90 KB
|
package/.turbo/turbo-test.log
CHANGED
|
@@ -1,21 +1,16 @@
|
|
|
1
|
-
|
|
2
|
-
|
|
3
|
-
>
|
|
4
|
-
|
|
5
|
-
|
|
6
|
-
|
|
7
|
-
|
|
8
|
-
|
|
9
|
-
|
|
10
|
-
|
|
11
|
-
|
|
12
|
-
|
|
13
|
-
|
|
14
|
-
|
|
15
|
-
|
|
16
|
-
|
|
17
|
-
[2m Tests [22m [1m[32m13 passed[39m[22m[90m (13)[39m
|
|
18
|
-
[2m Start at [22m 11:27:40
|
|
19
|
-
[2m Duration [22m 548ms[2m (transform 85ms, setup 0ms, collect 131ms, tests 15ms, environment 0ms, prepare 374ms)[22m
|
|
20
|
-
|
|
21
|
-
[?25h[?25h
|
|
1
|
+
|
|
2
|
+
> @inspecto-dev/cli@0.2.0-alpha.4 test /Users/bytedance/Works/hugo.felix/inspecto/packages/cli
|
|
3
|
+
> vitest run --passWithNoTests
|
|
4
|
+
|
|
5
|
+
|
|
6
|
+
RUN v1.6.1 /Users/bytedance/Works/hugo.felix/inspecto/packages/cli
|
|
7
|
+
|
|
8
|
+
✓ tests/framework.test.ts (5 tests) 4ms
|
|
9
|
+
✓ tests/build-tool.test.ts (2 tests) 9ms
|
|
10
|
+
✓ tests/ide.test.ts (6 tests) 8ms
|
|
11
|
+
|
|
12
|
+
Test Files 3 passed (3)
|
|
13
|
+
Tests 13 passed (13)
|
|
14
|
+
Start at 15:41:01
|
|
15
|
+
Duration 771ms (transform 133ms, setup 1ms, collect 221ms, tests 21ms, environment 0ms, prepare 367ms)
|
|
16
|
+
|
package/CHANGELOG.md
CHANGED
package/README.md
CHANGED
|
@@ -1,6 +1,23 @@
|
|
|
1
1
|
# @inspecto-dev/cli
|
|
2
2
|
|
|
3
|
-
The official command-line interface for Inspecto. This tool automates the process of
|
|
3
|
+
The official command-line interface for Inspecto. This tool automates the process of detecting, planning, applying, and maintaining the Inspecto setup within your project.
|
|
4
|
+
|
|
5
|
+
## Onboarding Flow
|
|
6
|
+
|
|
7
|
+
For agent-capable environments, the preferred setup path is structured and machine-readable:
|
|
8
|
+
|
|
9
|
+
1. `inspecto detect --json`
|
|
10
|
+
2. `inspecto plan --json`
|
|
11
|
+
3. `inspecto apply`
|
|
12
|
+
4. `inspecto doctor --json`
|
|
13
|
+
|
|
14
|
+
See the public onboarding contract for response shapes and field semantics:
|
|
15
|
+
`packages/docs/integrations/onboarding-contract.md`
|
|
16
|
+
|
|
17
|
+
Assistant-specific onboarding entrypoints are documented in:
|
|
18
|
+
`packages/docs/integrations/onboarding-skills.md`
|
|
19
|
+
|
|
20
|
+
Use `inspecto init` when you want a guided manual setup in the terminal, or when the structured flow is not available.
|
|
4
21
|
|
|
5
22
|
## Installation
|
|
6
23
|
|
|
@@ -18,20 +35,34 @@ npm install -D @inspecto-dev/cli
|
|
|
18
35
|
|
|
19
36
|
## Commands
|
|
20
37
|
|
|
21
|
-
### `inspecto
|
|
38
|
+
### `inspecto detect`
|
|
22
39
|
|
|
23
|
-
|
|
40
|
+
Detects whether the current project can be onboarded automatically.
|
|
24
41
|
|
|
25
42
|
**Features:**
|
|
26
43
|
|
|
27
|
-
-
|
|
28
|
-
-
|
|
29
|
-
|
|
30
|
-
|
|
31
|
-
|
|
32
|
-
|
|
33
|
-
|
|
34
|
-
|
|
44
|
+
- Detects the package manager, build tool/framework, IDE, and available AI tools.
|
|
45
|
+
- Produces structured output for agent-driven setup flows.
|
|
46
|
+
|
|
47
|
+
### `inspecto plan`
|
|
48
|
+
|
|
49
|
+
Previews the onboarding plan for the current project.
|
|
50
|
+
|
|
51
|
+
**Features:**
|
|
52
|
+
|
|
53
|
+
- Summarizes the proposed setup strategy and actions.
|
|
54
|
+
- Produces structured output that agents can inspect before applying changes.
|
|
55
|
+
|
|
56
|
+
### `inspecto apply`
|
|
57
|
+
|
|
58
|
+
Applies the onboarding plan to the current project.
|
|
59
|
+
|
|
60
|
+
**Features:**
|
|
61
|
+
|
|
62
|
+
- Installs the required `@inspecto-dev/plugin` dependencies.
|
|
63
|
+
- Injects the plugin into supported build configurations.
|
|
64
|
+
- Installs or configures the selected IDE extension when needed.
|
|
65
|
+
- Writes `.inspecto/settings.local.json` and updates `.gitignore` when appropriate.
|
|
35
66
|
|
|
36
67
|
### `inspecto doctor`
|
|
37
68
|
|
|
@@ -43,6 +74,22 @@ A diagnostic command to verify your current environment.
|
|
|
43
74
|
- Verifies if the IDE is supported.
|
|
44
75
|
- Scans for available AI tools (both CLI and Plugin modes).
|
|
45
76
|
- Validates the current Inspecto installation and configuration.
|
|
77
|
+
- Supports `--json` for agent-friendly diagnostics.
|
|
78
|
+
|
|
79
|
+
### `inspecto init`
|
|
80
|
+
|
|
81
|
+
The guided/manual fallback for scaffolding Inspecto into a project. It performs a comprehensive environmental analysis and automatically configures Inspecto in one step.
|
|
82
|
+
|
|
83
|
+
**Features:**
|
|
84
|
+
|
|
85
|
+
- **Package Manager Detection:** Auto-detects `npm`, `pnpm`, `yarn`, or `bun`.
|
|
86
|
+
- **Build Tool / Framework Detection:** Detects Vite, Webpack, Rspack, Rsbuild, and others. Supports legacy versions (e.g., `@rspack/cli < 0.4.0`).
|
|
87
|
+
- **IDE Detection:** Prioritizes environment variables, then falls back to directory structures to accurately detect VS Code, Cursor, Trae, Windsurf, or WebStorm.
|
|
88
|
+
- **AI Tool Detection:** Scans for both CLI-based tools (Claude, Coco, CodeX, Gemini) and IDE Plugins (GitHub Copilot, Claude Code, Gemini, CodeX).
|
|
89
|
+
- **Interactive Prompts:** If multiple build configurations or AI tools are detected, it presents an interactive prompt for you to select your preferred configuration.
|
|
90
|
+
- **AST Injection:** Safely injects the `@inspecto-dev/plugin` into your Vite configuration file (`vite.config.ts`, etc.) using AST transformation, preventing duplicate injections. Manual setup is required for other build tools.
|
|
91
|
+
- **IDE Extension Installation:** Uses a robust 4-level waterfall strategy to install the necessary IDE extension.
|
|
92
|
+
- **Configuration Scaffolding:** Generates the `.inspecto/settings.local.json` file tailored to your detected or selected AI tools, and updates `.gitignore` to prevent committing local settings.
|
|
46
93
|
|
|
47
94
|
### `inspecto teardown`
|
|
48
95
|
|
package/bin/inspecto.js
CHANGED
package/dist/bin.d.ts
CHANGED
package/dist/bin.js
CHANGED
|
@@ -1,65 +1,104 @@
|
|
|
1
1
|
import {
|
|
2
|
+
apply,
|
|
3
|
+
detect,
|
|
2
4
|
doctor,
|
|
3
5
|
init,
|
|
4
|
-
|
|
6
|
+
plan,
|
|
7
|
+
reportCommandError,
|
|
5
8
|
teardown
|
|
6
|
-
} from "./chunk-
|
|
9
|
+
} from "./chunk-PDDFPQJS.js";
|
|
7
10
|
|
|
8
11
|
// src/bin.ts
|
|
9
12
|
import { cac } from "cac";
|
|
13
|
+
import { fileURLToPath } from "url";
|
|
10
14
|
import { createRequire } from "module";
|
|
11
15
|
var require2 = createRequire(import.meta.url);
|
|
12
16
|
var { version } = require2("../package.json");
|
|
13
|
-
|
|
14
|
-
|
|
15
|
-
|
|
16
|
-
|
|
17
|
-
|
|
18
|
-
|
|
19
|
-
|
|
20
|
-
|
|
21
|
-
|
|
22
|
-
|
|
23
|
-
|
|
24
|
-
|
|
25
|
-
|
|
26
|
-
|
|
27
|
-
|
|
28
|
-
|
|
29
|
-
|
|
30
|
-
|
|
31
|
-
|
|
17
|
+
function exitWithError(error, options = {}) {
|
|
18
|
+
reportCommandError(error, {
|
|
19
|
+
debug: options.debug ?? false,
|
|
20
|
+
json: options.json ?? false
|
|
21
|
+
});
|
|
22
|
+
process.exit(1);
|
|
23
|
+
}
|
|
24
|
+
function createCli(argv = process.argv) {
|
|
25
|
+
const cli = cac("inspecto");
|
|
26
|
+
cli.command("init", "Set up Inspecto in your project").option("--shared", "Share .inspecto/settings.json with your team via Git", { default: false }).option("--skip-install", "Skip npm dependency installation", { default: false }).option("--dry-run", "Preview changes without modifying files", { default: false }).option("--provider <provider>", "Set default provider (e.g. copilot, claude-code)").option("--no-extension", "Skip VS Code extension installation", { default: false }).option("--packages <names>", "(Monorepo) Comma-separated list of packages to inject").option("--force", "Force initialization even if environment is unsupported", { default: false }).option("--debug", "Enable debug mode to show full error traces", { default: false }).action(async (options) => {
|
|
27
|
+
try {
|
|
28
|
+
await init({
|
|
29
|
+
shared: options.shared ?? false,
|
|
30
|
+
skipInstall: options.skipInstall ?? false,
|
|
31
|
+
dryRun: options.dryRun ?? false,
|
|
32
|
+
...options.provider && { provider: options.provider },
|
|
33
|
+
noExtension: options.noExtension ?? false,
|
|
34
|
+
...options.packages && {
|
|
35
|
+
packages: options.packages.split(",").map((s) => s.trim())
|
|
36
|
+
},
|
|
37
|
+
force: options.force ?? false
|
|
38
|
+
});
|
|
39
|
+
} catch (error) {
|
|
40
|
+
exitWithError(error, options);
|
|
32
41
|
}
|
|
33
|
-
|
|
34
|
-
}
|
|
35
|
-
|
|
36
|
-
|
|
37
|
-
|
|
38
|
-
|
|
39
|
-
} catch (err) {
|
|
40
|
-
log.error(err instanceof Error ? err.message : String(err));
|
|
41
|
-
if (options.debug && err instanceof Error && err.stack) {
|
|
42
|
-
console.error(err.stack);
|
|
42
|
+
});
|
|
43
|
+
cli.command("doctor", "Diagnose your Inspecto installation").option("--json", "Print machine-readable JSON output", { default: false }).option("--debug", "Enable debug mode to show full error traces", { default: false }).action(async (options) => {
|
|
44
|
+
try {
|
|
45
|
+
await doctor({ json: options.json ?? false });
|
|
46
|
+
} catch (error) {
|
|
47
|
+
exitWithError(error, options);
|
|
43
48
|
}
|
|
44
|
-
|
|
45
|
-
}
|
|
46
|
-
|
|
47
|
-
|
|
48
|
-
|
|
49
|
-
|
|
50
|
-
} catch (err) {
|
|
51
|
-
log.error(err instanceof Error ? err.message : String(err));
|
|
52
|
-
if (options.debug && err instanceof Error && err.stack) {
|
|
53
|
-
console.error(err.stack);
|
|
49
|
+
});
|
|
50
|
+
cli.command("detect", "Detect whether the current project can be onboarded automatically").option("--json", "Print machine-readable JSON output", { default: false }).option("--debug", "Enable debug mode to show full error traces", { default: false }).action(async (options) => {
|
|
51
|
+
try {
|
|
52
|
+
await detect(options.json ?? false);
|
|
53
|
+
} catch (error) {
|
|
54
|
+
exitWithError(error, options);
|
|
54
55
|
}
|
|
55
|
-
|
|
56
|
+
});
|
|
57
|
+
cli.command("plan", "Preview the onboarding plan for the current project").option("--json", "Print machine-readable JSON output", { default: false }).option("--debug", "Enable debug mode to show full error traces", { default: false }).action(async (options) => {
|
|
58
|
+
try {
|
|
59
|
+
await plan(options.json ?? false);
|
|
60
|
+
} catch (error) {
|
|
61
|
+
exitWithError(error, options);
|
|
62
|
+
}
|
|
63
|
+
});
|
|
64
|
+
cli.command("apply", "Apply the onboarding plan to the current project").option("--json", "Print machine-readable JSON output", { default: false }).option("--shared", "Write shared Inspecto settings instead of local-only settings").option("--skip-install", "Skip npm dependency installation").option("--dry-run", "Preview changes without modifying files").option("--no-extension", "Skip IDE extension installation").option("--debug", "Enable debug mode to show full error traces", { default: false }).action(async (options) => {
|
|
65
|
+
try {
|
|
66
|
+
await apply({
|
|
67
|
+
json: options.json ?? false,
|
|
68
|
+
...options.shared !== void 0 && { shared: options.shared },
|
|
69
|
+
...options.skipInstall !== void 0 && { skipInstall: options.skipInstall },
|
|
70
|
+
...options.dryRun !== void 0 && { dryRun: options.dryRun },
|
|
71
|
+
...options.extension === false && { noExtension: true }
|
|
72
|
+
});
|
|
73
|
+
} catch (error) {
|
|
74
|
+
exitWithError(error, options);
|
|
75
|
+
}
|
|
76
|
+
});
|
|
77
|
+
cli.command("teardown", "Remove Inspecto from your project").option("--debug", "Enable debug mode to show full error traces", { default: false }).action(async (options) => {
|
|
78
|
+
try {
|
|
79
|
+
await teardown();
|
|
80
|
+
} catch (error) {
|
|
81
|
+
exitWithError(error, options);
|
|
82
|
+
}
|
|
83
|
+
});
|
|
84
|
+
cli.help();
|
|
85
|
+
cli.version(version);
|
|
86
|
+
return cli;
|
|
87
|
+
}
|
|
88
|
+
async function runCli(argv = process.argv) {
|
|
89
|
+
const cli = createCli(argv);
|
|
90
|
+
const parsedArgv = [...argv];
|
|
91
|
+
try {
|
|
92
|
+
await cli.parse(parsedArgv);
|
|
93
|
+
} catch (error) {
|
|
94
|
+
exitWithError(error, { json: argv.includes("--json") });
|
|
56
95
|
}
|
|
57
|
-
});
|
|
58
|
-
cli.help();
|
|
59
|
-
cli.version(version);
|
|
60
|
-
try {
|
|
61
|
-
cli.parse();
|
|
62
|
-
} catch (err) {
|
|
63
|
-
log.error(err instanceof Error ? err.message : String(err));
|
|
64
|
-
process.exit(1);
|
|
65
96
|
}
|
|
97
|
+
var entryPath = process.argv[1];
|
|
98
|
+
if (entryPath && fileURLToPath(import.meta.url) === entryPath) {
|
|
99
|
+
void runCli();
|
|
100
|
+
}
|
|
101
|
+
export {
|
|
102
|
+
createCli,
|
|
103
|
+
runCli
|
|
104
|
+
};
|