@bleedingdev/modern-js-create 3.2.0-ultramodern.6 → 3.2.0-ultramodern.8

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.
Files changed (38) hide show
  1. package/dist/index.js +225 -34
  2. package/package.json +3 -3
  3. package/template/.agents/skills-lock.json +34 -0
  4. package/template/AGENTS.md +20 -0
  5. package/template/api/effect/index.ts.handlebars +7 -39
  6. package/template/modern.config.ts.handlebars +8 -7
  7. package/template/oxfmt.config.ts +7 -0
  8. package/template/oxlint.config.ts +12 -0
  9. package/template/package.json.handlebars +21 -11
  10. package/template/scripts/bootstrap-agent-skills.mjs +103 -0
  11. package/template/scripts/validate-ultramodern.mjs.handlebars +84 -0
  12. package/template/tsconfig.json +106 -2
  13. package/template-workspace/.agents/rstackjs-agent-skills-LICENSE +21 -0
  14. package/template-workspace/.agents/skills/rsbuild-best-practices/SKILL.md +57 -0
  15. package/template-workspace/.agents/skills/rsdoctor-analysis/SKILL.md +96 -0
  16. package/template-workspace/.agents/skills/rsdoctor-analysis/references/command-map.md +113 -0
  17. package/template-workspace/.agents/skills/rsdoctor-analysis/references/common-analysis-patterns.md +190 -0
  18. package/template-workspace/.agents/skills/rsdoctor-analysis/references/install-rsdoctor-common.md +88 -0
  19. package/template-workspace/.agents/skills/rsdoctor-analysis/references/install-rsdoctor-rspack.md +138 -0
  20. package/template-workspace/.agents/skills/rsdoctor-analysis/references/install-rsdoctor-webpack.md +71 -0
  21. package/template-workspace/.agents/skills/rsdoctor-analysis/references/install-rsdoctor.md +39 -0
  22. package/template-workspace/.agents/skills/rsdoctor-analysis/references/rsdoctor-data-types.md +103 -0
  23. package/template-workspace/.agents/skills/rslib-best-practices/SKILL.md +58 -0
  24. package/template-workspace/.agents/skills/rslib-modern-package/SKILL.md +173 -0
  25. package/template-workspace/.agents/skills/rspack-best-practices/SKILL.md +70 -0
  26. package/template-workspace/.agents/skills/rspack-tracing/SKILL.md +75 -0
  27. package/template-workspace/.agents/skills/rspack-tracing/references/bottlenecks.md +47 -0
  28. package/template-workspace/.agents/skills/rspack-tracing/references/tracing-guide.md +38 -0
  29. package/template-workspace/.agents/skills/rspack-tracing/scripts/analyze_trace.js +184 -0
  30. package/template-workspace/.agents/skills/rstest-best-practices/SKILL.md +133 -0
  31. package/template-workspace/.agents/skills-lock.json +95 -0
  32. package/template-workspace/AGENTS.md +45 -0
  33. package/template-workspace/oxfmt.config.ts +7 -0
  34. package/template-workspace/oxlint.config.ts +12 -0
  35. package/template-workspace/pnpm-workspace.yaml +0 -2
  36. package/template-workspace/scripts/bootstrap-agent-skills.mjs +106 -0
  37. package/template-workspace/scripts/validate-ultramodern-workspace.mjs.handlebars +127 -0
  38. package/template/biome.json +0 -41
@@ -0,0 +1,12 @@
1
+ import { defineConfig } from "oxlint";
2
+ import core from "ultracite/oxlint/core";
3
+ import react from "ultracite/oxlint/react";
4
+
5
+ export default defineConfig({
6
+ env: {
7
+ browser: true,
8
+ node: true,
9
+ },
10
+ extends: [core, react],
11
+ ignorePatterns: ["dist", "node_modules", ".modern", ".modernjs", "**/routeTree.gen.ts"],
12
+ });
@@ -6,8 +6,14 @@
6
6
  "dev": "modern dev",
7
7
  "build": "modern build",
8
8
  "serve": "modern serve",
9
- "ultramodern:check": "node ./scripts/validate-ultramodern.mjs"{{#unless isSubproject}},
10
- "lint": "biome check",
9
+ "typecheck": "node -e \"const fs = require('node:fs'); const { execFileSync, spawnSync } = require('node:child_process'); const bin = execFileSync('effect-tsgo', ['get-exe-path'], { encoding: 'utf8' }).trim(); if (process.platform !== 'win32') fs.chmodSync(bin, 0o755); const result = spawnSync(bin, ['--noEmit', '-p', 'tsconfig.json'], { stdio: 'inherit' }); process.exit(result.status ?? 1);\"",
10
+ "skills:install": "node ./scripts/bootstrap-agent-skills.mjs",
11
+ "skills:check": "node ./scripts/bootstrap-agent-skills.mjs --check",
12
+ "ultramodern:check": "{{#unless isSubproject}}pnpm format:check && pnpm lint && {{/unless}}pnpm typecheck{{#unless isSubproject}} && pnpm skills:check{{/unless}} && node ./scripts/validate-ultramodern.mjs"{{#unless isSubproject}},
13
+ "format": "oxfmt .",
14
+ "format:check": "oxfmt --check .",
15
+ "lint": "oxlint .",
16
+ "lint:fix": "oxlint . --fix",
11
17
  "prepare": "simple-git-hooks"{{/unless}}
12
18
  },
13
19
  "engines": {
@@ -15,31 +21,35 @@
15
21
  }{{#unless isSubproject}},
16
22
  "lint-staged": {
17
23
  "*.{js,ts,cjs,mjs,d.cts,d.mts,jsx,tsx,json,jsonc}": [
18
- "biome check --files-ignore-unknown=true"
24
+ "oxfmt --write",
25
+ "oxlint --fix"
19
26
  ]
20
27
  },
21
28
  "simple-git-hooks": {
22
29
  "pre-commit": "npx lint-staged"
23
30
  }{{/unless}},
24
31
  "dependencies": {
25
- "@modern-js/runtime": "{{version}}"{{#if isTanstackRouter}},
26
- "@modern-js/plugin-tanstack": "{{version}}",
32
+ "@modern-js/runtime": "{{runtimeVersion}}"{{#if isTanstackRouter}},
33
+ "@modern-js/plugin-tanstack": "{{pluginTanstackVersion}}",
27
34
  "@tanstack/react-router": "1.170.1"{{/if}},
28
35
  "react": "^19.2.3",
29
36
  "react-dom": "^19.2.0"
30
37
  },
31
38
  "devDependencies": {
32
- "@modern-js/app-tools": "{{version}}",
33
- "@modern-js/tsconfig": "{{version}}"{{#if enableBff}},
34
- "@modern-js/plugin-bff": "{{version}}"{{/if}}{{#if enableTailwind}},
39
+ "@modern-js/app-tools": "{{appToolsVersion}}",
40
+ "@modern-js/tsconfig": "{{tsconfigVersion}}"{{#if enableBff}},
41
+ "@modern-js/plugin-bff": "{{pluginBffVersion}}"{{/if}}{{#if enableTailwind}},
35
42
  "@tailwindcss/postcss": "^4.1.18",
36
43
  "postcss": "^8.5.6",
37
- "tailwindcss": "^4.1.18"{{/if}}{{#unless isSubproject}},
38
- "@biomejs/biome": "1.9.4"{{/unless}},
39
- "@typescript/native-preview": "7.0.0-dev.20260516.1",
44
+ "tailwindcss": "^4.1.18"{{/if}},
45
+ "@effect/tsgo": "0.7.3",
46
+ "@typescript/native-preview": "7.0.0-dev.20260518.1",
40
47
  "@types/node": "^20",
41
48
  "@types/react": "^19.1.8",
42
49
  "@types/react-dom": "^19.1.6"{{#unless isSubproject}},
50
+ "oxlint": "1.65.0",
51
+ "oxfmt": "0.50.0",
52
+ "ultracite": "7.7.0",
43
53
  "lint-staged": "~15.4.0",
44
54
  "simple-git-hooks": "^2.11.1"{{/unless}},
45
55
  "rimraf": "^6.0.1"
@@ -0,0 +1,103 @@
1
+ import { execFileSync } from 'node:child_process';
2
+ import fs from 'node:fs';
3
+ import os from 'node:os';
4
+ import path from 'node:path';
5
+
6
+ const root = process.cwd();
7
+ const lockPath = path.join(root, '.agents/skills-lock.json');
8
+ const checkOnly = process.argv.includes('--check');
9
+ const force = process.argv.includes('--force');
10
+
11
+ function readJson(filePath) {
12
+ return JSON.parse(fs.readFileSync(filePath, 'utf8'));
13
+ }
14
+
15
+ function run(command, args, options = {}) {
16
+ return execFileSync(command, args, {
17
+ cwd: options.cwd ?? root,
18
+ encoding: 'utf8',
19
+ stdio: options.stdio ?? ['ignore', 'pipe', 'pipe'],
20
+ });
21
+ }
22
+
23
+ function cloneSource(source, targetDir) {
24
+ const repo = source.repository.replace(/^https:\/\/github.com\//, '');
25
+ try {
26
+ run('gh', ['repo', 'clone', repo, targetDir, '--', '--depth', '1'], {
27
+ stdio: 'inherit',
28
+ });
29
+ return;
30
+ } catch {
31
+ run('git', ['clone', '--depth', '1', source.repository, targetDir], {
32
+ stdio: 'inherit',
33
+ });
34
+ }
35
+ }
36
+
37
+ function resolveSkillDir(sourceRoot, skillName) {
38
+ const candidates = [
39
+ path.join(sourceRoot, skillName),
40
+ path.join(sourceRoot, 'skills', skillName),
41
+ path.join(sourceRoot, 'skills', 'engineering', skillName),
42
+ path.join(sourceRoot, 'skills', 'productivity', skillName),
43
+ ];
44
+ return candidates.find(candidate =>
45
+ fs.existsSync(path.join(candidate, 'SKILL.md')),
46
+ );
47
+ }
48
+
49
+ if (!fs.existsSync(lockPath)) {
50
+ console.error('Missing .agents/skills-lock.json');
51
+ process.exit(1);
52
+ }
53
+
54
+ const lock = readJson(lockPath);
55
+ const installDir = path.join(root, lock.installDir ?? '.agents/skills');
56
+ const privateSources = (lock.sources ?? []).filter(
57
+ source => source.install === 'clone-if-authorized',
58
+ );
59
+
60
+ if (checkOnly) {
61
+ const missing = privateSources.flatMap(source =>
62
+ (source.baseline ?? [])
63
+ .map(skill => skill.name)
64
+ .filter(skillName => !fs.existsSync(path.join(installDir, skillName, 'SKILL.md'))),
65
+ );
66
+ if (missing.length > 0) {
67
+ console.warn(
68
+ `Private skills not installed: ${missing.join(', ')}. Run pnpm skills:install if you have access.`,
69
+ );
70
+ } else {
71
+ console.log('Agent skills are installed.');
72
+ }
73
+ process.exit(0);
74
+ }
75
+
76
+ fs.mkdirSync(installDir, { recursive: true });
77
+
78
+ for (const source of privateSources) {
79
+ const tempDir = fs.mkdtempSync(path.join(os.tmpdir(), 'ultramodern-skills-'));
80
+ try {
81
+ cloneSource(source, tempDir);
82
+ for (const skill of source.baseline ?? []) {
83
+ const sourceSkillDir = resolveSkillDir(tempDir, skill.name);
84
+ if (!sourceSkillDir) {
85
+ throw new Error(
86
+ `Skill ${skill.name} not found in ${source.repository}`,
87
+ );
88
+ }
89
+ const targetSkillDir = path.join(installDir, skill.name);
90
+ if (fs.existsSync(targetSkillDir)) {
91
+ if (!force) {
92
+ console.log(`Skipping existing ${skill.name}`);
93
+ continue;
94
+ }
95
+ fs.rmSync(targetSkillDir, { recursive: true, force: true });
96
+ }
97
+ fs.cpSync(sourceSkillDir, targetSkillDir, { recursive: true });
98
+ console.log(`Installed ${skill.name}`);
99
+ }
100
+ } finally {
101
+ fs.rmSync(tempDir, { recursive: true, force: true });
102
+ }
103
+ }
@@ -52,8 +52,22 @@ const requiredPostMaterialization = [
52
52
  'dependency-install-with-lifecycle-deny',
53
53
  'template-manifest-retained',
54
54
  ];
55
+ const requiredPaths = [
56
+ 'AGENTS.md',
57
+ '.agents/skills-lock.json',
58
+ 'oxlint.config.ts',
59
+ 'oxfmt.config.ts',
60
+ 'scripts/bootstrap-agent-skills.mjs',
61
+ ];
55
62
  const manifestErrors = [];
56
63
 
64
+ for (const requiredPath of requiredPaths) {
65
+ if (!fs.existsSync(path.resolve(process.cwd(), requiredPath))) {
66
+ console.error(`${requiredPath} not found`);
67
+ process.exit(1);
68
+ }
69
+ }
70
+
57
71
  if (templateManifest.schemaVersion !== 1) {
58
72
  manifestErrors.push('schemaVersion');
59
73
  }
@@ -99,4 +113,74 @@ if (manifestErrors.length > 0) {
99
113
  process.exit(1);
100
114
  }
101
115
 
116
+ const packageJson = JSON.parse(
117
+ fs.readFileSync(path.resolve(process.cwd(), 'package.json'), 'utf8'),
118
+ );
119
+ const unresolvedTemplateMarker = '{' + '{';
120
+ if (JSON.stringify(packageJson).includes(unresolvedTemplateMarker)) {
121
+ console.error('package.json contains unresolved template markers');
122
+ process.exit(1);
123
+ }
124
+ const skillsLock = JSON.parse(
125
+ fs.readFileSync(
126
+ path.resolve(process.cwd(), '.agents/skills-lock.json'),
127
+ 'utf8',
128
+ ),
129
+ );
130
+ const requiredScripts = {
131
+ format: 'oxfmt .',
132
+ 'format:check': 'oxfmt --check .',
133
+ lint: 'oxlint .',
134
+ 'lint:fix': 'oxlint . --fix',
135
+ 'skills:install': 'node ./scripts/bootstrap-agent-skills.mjs',
136
+ 'skills:check': 'node ./scripts/bootstrap-agent-skills.mjs --check',
137
+ };
138
+
139
+ for (const [scriptName, scriptCommand] of Object.entries(requiredScripts)) {
140
+ if (packageJson.scripts?.[scriptName] !== scriptCommand) {
141
+ console.error(`Missing or invalid package script: ${scriptName}`);
142
+ process.exit(1);
143
+ }
144
+ }
145
+
146
+ if (
147
+ !packageJson.scripts?.typecheck?.includes('effect-tsgo') ||
148
+ !packageJson.scripts.typecheck.includes('get-exe-path')
149
+ ) {
150
+ console.error('typecheck must use effect-tsgo as the TypeScript checker');
151
+ process.exit(1);
152
+ }
153
+
154
+ for (const dependency of [
155
+ '@effect/tsgo',
156
+ '@typescript/native-preview',
157
+ 'oxlint',
158
+ 'oxfmt',
159
+ 'ultracite',
160
+ ]) {
161
+ if (!packageJson.devDependencies?.[dependency]) {
162
+ console.error(`Missing devDependency: ${dependency}`);
163
+ process.exit(1);
164
+ }
165
+ }
166
+
167
+ const privateSource = skillsLock.sources?.find(
168
+ source => source.repository === 'https://github.com/TechsioCZ/skills',
169
+ );
170
+ const privateSkills = new Set(
171
+ privateSource?.baseline?.map(skill => skill.name) ?? [],
172
+ );
173
+ for (const skillName of [
174
+ 'plan-graph',
175
+ 'dag',
176
+ 'subagent-graph',
177
+ 'helm',
178
+ 'debugger-mode',
179
+ ]) {
180
+ if (!privateSkills.has(skillName)) {
181
+ console.error(`Missing private skill allowlist entry: ${skillName}`);
182
+ process.exit(1);
183
+ }
184
+ }
185
+
102
186
  console.log('Ultramodern contract check passed.');
@@ -3,13 +3,117 @@
3
3
  "compilerOptions": {
4
4
  "declaration": false,
5
5
  "jsx": "preserve",
6
- "baseUrl": "./",
6
+ "target": "ESNext",
7
+ "lib": ["ESNext", "DOM", "DOM.Iterable"],
8
+ "module": "preserve",
9
+ "moduleResolution": "Bundler",
10
+ "moduleDetection": "force",
11
+ "isolatedModules": true,
12
+ "verbatimModuleSyntax": true,
13
+ "noEmit": true,
14
+ "allowJs": true,
15
+ "resolveJsonModule": true,
16
+ "esModuleInterop": true,
17
+ "skipLibCheck": true,
18
+ "strict": true,
19
+ "noUncheckedIndexedAccess": true,
20
+ "exactOptionalPropertyTypes": true,
21
+ "noImplicitOverride": true,
22
+ "noFallthroughCasesInSwitch": true,
23
+ "noPropertyAccessFromIndexSignature": true,
24
+ "noImplicitReturns": true,
7
25
  "paths": {
8
26
  "@/*": ["./src/*"],
9
27
  "@api/*": ["./api/*"],
10
28
  "@shared/*": ["./shared/*"]
11
29
  },
12
- "rootDir": "./src"
30
+ "rootDir": ".",
31
+ "plugins": [
32
+ {
33
+ "name": "@effect/language-service",
34
+ "diagnostics": true,
35
+ "includeSuggestionsInTsc": true,
36
+ "ignoreEffectSuggestionsInTscExitCode": false,
37
+ "ignoreEffectWarningsInTscExitCode": false,
38
+ "ignoreEffectErrorsInTscExitCode": false,
39
+ "skipDisabledOptimization": true,
40
+ "diagnosticSeverity": {
41
+ "anyUnknownInErrorContext": "error",
42
+ "classSelfMismatch": "error",
43
+ "duplicatePackage": "error",
44
+ "effectFnImplicitAny": "error",
45
+ "floatingEffect": "error",
46
+ "genericEffectServices": "error",
47
+ "missingEffectContext": "error",
48
+ "missingEffectError": "error",
49
+ "missingLayerContext": "error",
50
+ "missingReturnYieldStar": "error",
51
+ "missingStarInYieldEffectGen": "error",
52
+ "nonObjectEffectServiceType": "error",
53
+ "outdatedApi": "error",
54
+ "overriddenSchemaConstructor": "error",
55
+ "catchUnfailableEffect": "error",
56
+ "effectFnIife": "error",
57
+ "effectGenUsesAdapter": "error",
58
+ "effectInFailure": "error",
59
+ "effectInVoidSuccess": "error",
60
+ "globalErrorInEffectCatch": "error",
61
+ "globalErrorInEffectFailure": "error",
62
+ "layerMergeAllWithDependencies": "error",
63
+ "lazyPromiseInEffectSync": "error",
64
+ "leakingRequirements": "error",
65
+ "multipleEffectProvide": "error",
66
+ "returnEffectInGen": "error",
67
+ "runEffectInsideEffect": "error",
68
+ "schemaSyncInEffect": "error",
69
+ "scopeInLayerEffect": "error",
70
+ "strictEffectProvide": "error",
71
+ "tryCatchInEffectGen": "error",
72
+ "unknownInEffectCatch": "error",
73
+ "asyncFunction": "error",
74
+ "cryptoRandomUUID": "error",
75
+ "cryptoRandomUUIDInEffect": "error",
76
+ "extendsNativeError": "error",
77
+ "globalConsole": "error",
78
+ "globalConsoleInEffect": "error",
79
+ "globalDate": "error",
80
+ "globalDateInEffect": "error",
81
+ "globalFetch": "error",
82
+ "globalFetchInEffect": "error",
83
+ "globalRandom": "error",
84
+ "globalRandomInEffect": "error",
85
+ "globalTimers": "error",
86
+ "globalTimersInEffect": "error",
87
+ "instanceOfSchema": "error",
88
+ "newPromise": "error",
89
+ "nodeBuiltinImport": "error",
90
+ "preferSchemaOverJson": "error",
91
+ "processEnv": "error",
92
+ "processEnvInEffect": "error",
93
+ "unsafeEffectTypeAssertion": "error",
94
+ "catchAllToMapError": "error",
95
+ "deterministicKeys": "error",
96
+ "effectDoNotation": "error",
97
+ "effectFnOpportunity": "error",
98
+ "effectMapFlatten": "error",
99
+ "effectMapVoid": "error",
100
+ "effectSucceedWithVoid": "error",
101
+ "missedPipeableOpportunity": "error",
102
+ "missingEffectServiceDependency": "error",
103
+ "nestedEffectGenYield": "error",
104
+ "redundantSchemaTagIdentifier": "error",
105
+ "schemaStructWithTag": "error",
106
+ "schemaUnionOfLiterals": "error",
107
+ "serviceNotAsClass": "error",
108
+ "strictBooleanExpressions": "error",
109
+ "unnecessaryArrowBlock": "error",
110
+ "unnecessaryEffectGen": "error",
111
+ "unnecessaryFailYieldableError": "error",
112
+ "unnecessaryPipe": "error",
113
+ "unnecessaryPipeChain": "error"
114
+ }
115
+ }
116
+ ]
13
117
  },
14
118
  "include": ["src", "api", "shared", "config", "modern.config.ts"],
15
119
  "exclude": ["**/node_modules"]
@@ -0,0 +1,21 @@
1
+ MIT License
2
+
3
+ Copyright (c) 2026 RstackJS 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.
@@ -0,0 +1,57 @@
1
+ ---
2
+ name: rsbuild-best-practices
3
+ description: Rsbuild best practices for config, CLI workflow, type checking, bundle optimization, assets, and debugging. Use when writing, reviewing, or troubleshooting Rsbuild projects.
4
+ ---
5
+
6
+ # Rsbuild Best Practices
7
+
8
+ Apply these rules when writing or reviewing Rsbuild projects.
9
+
10
+ ## Configuration
11
+
12
+ - Use `rsbuild.config.ts` and `defineConfig`
13
+ - Use `tools.rspack` or `tools.bundlerChain` only when no first-class Rsbuild option exists
14
+ - Define explicit `source.entry` values for multi-page applications
15
+ - In TypeScript projects, prefer `tsconfig.json` path aliases first
16
+
17
+ ## CLI
18
+
19
+ - Use `rsbuild` for local development
20
+ - Use `rsbuild build` for production build
21
+ - Use `rsbuild preview` only for local production preview
22
+ - Use `rsbuild inspect` to inspect final Rsbuild/Rspack configs
23
+
24
+ ## Type checking
25
+
26
+ - Use `@rsbuild/plugin-type-check` for integrated dev/build type checks
27
+ - Or run `tsc --noEmit`/`vue-tsc --noEmit` as an explicit script step
28
+
29
+ ## Bundle size optimization
30
+
31
+ - Prefer dynamic `import()` for non-critical code paths
32
+ - Prefer lightweight libraries where possible
33
+ - Keep browserslist aligned with real compatibility requirements
34
+
35
+ ## Asset management
36
+
37
+ - Import source-managed assets from project source directories, not from `public`
38
+ - Reference `public` files by absolute URL path
39
+
40
+ ## Security
41
+
42
+ - Do not publish `.map` files to public servers/CDNs when production source maps are enabled
43
+
44
+ ## Debugging
45
+
46
+ - Run with `DEBUG=rsbuild` when diagnosing config resolution or plugin behavior
47
+ - Read generated files in `dist/.rsbuild` to confirm final config, not assumed config
48
+
49
+ ## Profiling
50
+
51
+ - Use Node CPU profiling (`--cpu-prof`) when JavaScript-side overhead is suspected
52
+ - Use `RSPACK_PROFILE=OVERVIEW` and analyze trace output for compiler-phase bottlenecks
53
+
54
+ ## Documentation
55
+
56
+ - For the latest (v2) docs, read http://rsbuild.rs/llms.txt
57
+ - For Rsbuild v1 docs, read http://v1.rsbuild.rs/llms.txt
@@ -0,0 +1,96 @@
1
+ ---
2
+ name: rsdoctor-analysis
3
+ description: Use when analyzing Rspack/Webpack bundles from local `rsdoctor-data.json` and producing evidence-based optimization recommendations.
4
+ ---
5
+
6
+ # Rsdoctor Analysis Assistant Skill
7
+
8
+ Use the globally installed `rsdoctor-agent` CLI from `@rsdoctor/agent-cli` only after a real `rsdoctor-data.json` path exists. Keep analysis read-only unless the user explicitly asks for install/config setup.
9
+
10
+ Response order (required): High-Priority Issues -> Proposed Solutions -> Optional Reference-Chain Follow-up Choices -> Next Deep-Dive Issue Categories (Not commands).
11
+
12
+ ## Core Workflow
13
+
14
+ 1. Reuse current-session results and valid `.rsdoctor-analysis-cache.json` entries before doing new work.
15
+ 2. Locate `rsdoctor-data.json` fast: user-provided path, then `dist/rsdoctor-data.json`, `output/rsdoctor-data.json`, `static/rsdoctor-data.json`, `.rsdoctor/rsdoctor-data.json`, then one bounded `rg --files` search excluding `node_modules` and `.git`. Treat `manifest.json` only as an index.
16
+ 3. If data exists, skip all plugin version/config/build generation logic. Update cache when useful.
17
+ 4. If data is missing, stop analysis: do not run `rsdoctor-agent` analysis commands, do not run the Analysis Gate, and either ask for the data path or run the Generation Gate below only when setup/generation is required.
18
+ 5. After a real data file exists, run Analysis Gate at most once before the first `rsdoctor-agent` data-fetch command: verify global `@rsdoctor/agent-cli` with `npm view @rsdoctor/agent-cli version` and `rsdoctor-agent --version`; install latest only if missing/outdated, a version-related error occurs, or the user asks to refresh.
19
+ 6. Fetch only the Default Evidence Set first; run independent fetches in parallel when possible; synthesize findings in the required response order.
20
+
21
+ Performance rules: parallelize independent checks, cache only derived facts (`dataFile`, `dataFileMtime`, `pluginName`, `pluginVersion`, dependency/config/plugin modification times), and invalidate cache when paths disappear, modification times change, the user asks to refresh, or cached values fail. Speculative plugin checks must not trigger generation; use them only after confirming the data file is missing.
22
+
23
+ ## Generation Gate
24
+
25
+ Identify `pluginName` (`@rsdoctor/rspack-plugin` or `@rsdoctor/webpack-plugin`) and determine `pluginVersion` from local files first: `package.json`, lockfile, then `node_modules/<plugin>/package.json`; use `pnpm why` / `npm ls` only as fallback.
26
+
27
+ Use this exact if/else decision tree; do not merge branches:
28
+
29
+ ```text
30
+ if pluginName is missing:
31
+ install/register the matching Rsdoctor plugin, then configure output.mode='brief' and output.options.type=['json']; build with RSDOCTOR=true only
32
+ else if pluginVersion is unknown:
33
+ resolve pluginVersion first; if still unknown, configure output.mode='brief' and output.options.type=['json']; build with RSDOCTOR=true only
34
+ else if pluginVersion >= 1.5.11:
35
+ do not edit plugin config just for JSON; build with RSDOCTOR_OUTPUT=json and RSDOCTOR=true if needed
36
+ else: # pluginVersion < 1.5.11
37
+ MUST configure output.mode='brief' and output.options.type=['json']; build with RSDOCTOR=true only
38
+ ```
39
+
40
+ Preflight every build command: `RSDOCTOR_OUTPUT=json` is allowed only in the `pluginVersion >= 1.5.11` branch. For missing, unknown, or `< 1.5.11`, it is forbidden. For `< 1.5.11`, generating `rsdoctor-data.json` requires the plugin config below:
41
+
42
+ ```ts
43
+ output: {
44
+ mode: 'brief',
45
+ options: {
46
+ type: ['json'],
47
+ },
48
+ }
49
+ ```
50
+
51
+ ## Evidence and Command Bounds
52
+
53
+ Default Evidence Set:
54
+
55
+ | Summary key | Evidence source | Bounds |
56
+ | -------------------- | ------------------------------------------ | --------------------------------------------- |
57
+ | `buildCost` | `build summary` | filtered fields only |
58
+ | `assetsTop` | top assets by raw/gzip size | fixed Top-N |
59
+ | `packagesTop` | top packages by gzip size | fixed Top-N; avoid full `packages list` pages |
60
+ | `duplicatePackages` | E1001 duplicate package summary | first-pass summary only |
61
+ | `crossChunkPackages` | E1002 cross-chunk duplication summary | first-pass summary only |
62
+ | `retainedModulesTop` | `tree-shaking retained-modules --limit 10` | filtered fields only; no `--compact` |
63
+
64
+ Scope rules:
65
+
66
+ - Use `rsdoctor-agent` for bundle data access only after `rsdoctor-data.json` exists; prefer parallel independent fetches; bound output with `--filter`, pagination, and `--limit`.
67
+ - Default analysis stays within the Default Evidence Set. For non-default analysis, choose minimal fields from [references/rsdoctor-data-types.md](references/rsdoctor-data-types.md) and patterns from [references/common-analysis-patterns.md](references/common-analysis-patterns.md).
68
+ - Treat chain tracing, broad commands, optimization edits, splitChunks experiments, and build re-runs as opt-in follow-ups that require user confirmation.
69
+ - For duplicate packages and tree-shaking issues, identify issues first; trace reference/import chains only after user confirmation.
70
+ - Prefer `tree-shaking retained-modules --emitted-only --category side-effects --limit 10` with narrow `--filter` for side-effects investigations.
71
+ - For retained emitted modules, use `tree-shaking retained-modules` with `--emitted-only`, bounded `--category`, `--sort gzipSize`, `--limit`, and narrow `--filter`; do not pass `--compact`.
72
+ - Use `tree-shaking summary` only as fallback for missing fields or aggregate context. Treat `tree-shaking bailout-reasons` as high-volume; run it only when explicitly requested and pass target `--modules` (max 100).
73
+ - If any command exceeds `5k` tokens, `500 KB` raw output, or a few hundred transcript lines, stop broad fetching and switch to targeted compact queries.
74
+
75
+ ## Output and Recovery
76
+
77
+ Output format:
78
+
79
+ 1. Issues found in the current build and recommended fixes:
80
+ - Group each issue with its fix recommendation.
81
+ - Include concrete evidence (size/time/count/path/rule code) and priority.
82
+ - For duplicate packages and tree-shaking issues, include a short "continue tracing vs stop here" choice.
83
+ 2. Whether deeper analysis is still needed:
84
+ - List remaining issue categories only, not commands.
85
+
86
+ For Top-N insights, prefer a table: `Name | Volume/Time | Count | Recommendation`.
87
+
88
+ Recovery rules:
89
+
90
+ - `rsdoctor-data.json` missing: do not run `rsdoctor-agent`; ask for the data path or run Generation Gate, then use the matching install reference if setup is needed.
91
+ - Command not found: run Analysis Gate, then retry with `rsdoctor-agent`.
92
+ - `query` reports unknown tool: run `list` and use a catalog tool name, or switch to direct `<group> <subcommand>` mode.
93
+ - JSON read error: verify file path, JSON validity, and permissions.
94
+ - In Codex, do not run `install`, `build`, global CLI installation, version checks, or `rsdoctor-agent...` inside sandbox. Run Rsdoctor CLI setup and data-fetch commands outside sandbox so they can access project files and dependencies normally.
95
+
96
+ References: commands/options [references/command-map.md](references/command-map.md); install/config/data location [references/install-rsdoctor.md](references/install-rsdoctor.md), [references/install-rsdoctor-rspack.md](references/install-rsdoctor-rspack.md), [references/install-rsdoctor-webpack.md](references/install-rsdoctor-webpack.md), [references/install-rsdoctor-common.md](references/install-rsdoctor-common.md); raw data fields [references/rsdoctor-data-types.md](references/rsdoctor-data-types.md); common patterns [references/common-analysis-patterns.md](references/common-analysis-patterns.md).