@chemx/starter-kit 26.9.24-393 → 26.9.25-1337

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 (107) hide show
  1. package/README.md +70 -10
  2. package/blueprints/atoms/a-button.svelte +30 -0
  3. package/blueprints/atoms/a-button.tsx +36 -0
  4. package/blueprints/molecule-capsule/m-chemx-badge/m-chemx-badge.svelte +35 -0
  5. package/blueprints/molecule-capsule/m-sample-card.spec.ts +10 -4
  6. package/blueprints/molecule-capsule/m-sample-card.svelte +58 -0
  7. package/blueprints/molecule-capsule/m-sample-card.tsx +3 -3
  8. package/blueprints/molecule-capsule/m-sample-card.vue +60 -0
  9. package/blueprints/view-template.svelte +18 -0
  10. package/blueprints/view-template.vue +18 -0
  11. package/blueprints/workflows/chemx-audit.yml +36 -0
  12. package/cli/audit/ast-visitors.js +25 -13
  13. package/cli/audit/csharp-analyzer.js +80 -0
  14. package/cli/audit/extended-text-patterns.js +11 -2
  15. package/cli/audit/pattern-detector.js +5 -3
  16. package/cli/audit/pattern-detector.spec.js +17 -0
  17. package/cli/audit/reporter-grades.js +1 -0
  18. package/cli/audit/reporter-markdown.js +2 -0
  19. package/cli/audit/reporter-sections.js +3 -0
  20. package/cli/audit/rules-registry.js +27 -0
  21. package/cli/audit/rules.js +14 -3
  22. package/cli/audit/rules.spec.js +27 -0
  23. package/cli/audit/structural-weight-evaluator.js +121 -0
  24. package/cli/audit/structural-weight.js +92 -0
  25. package/cli/audit/structural-weight.spec.js +116 -0
  26. package/cli/audit-preflight-scope.js +4 -1
  27. package/cli/audit.js +9 -10
  28. package/cli/commands/cmd-audit.js +1 -1
  29. package/cli/commands/cmd-router.js +17 -2
  30. package/cli/commands-schema.js +36 -0
  31. package/cli/config/config.spec.js +51 -0
  32. package/cli/config/index.js +37 -0
  33. package/cli/config/loader.js +83 -0
  34. package/cli/config/profiles.js +56 -0
  35. package/cli/config.spec.js +1 -0
  36. package/cli/create.js +21 -8
  37. package/cli/create.spec.js +91 -0
  38. package/cli/generator-help.js +48 -0
  39. package/cli/generator-indexer.js +41 -0
  40. package/cli/generator.js +8 -43
  41. package/cli/generator.spec.js +29 -0
  42. package/cli/help.d.ts +2 -0
  43. package/cli/help.js +64 -0
  44. package/cli/help.spec.js +54 -1
  45. package/cli/installer-templates.js +8 -3
  46. package/cli/languages.js +122 -0
  47. package/cli/languages.spec.js +44 -0
  48. package/cli/mcp/tools-patch.js +7 -5
  49. package/cli/mcp/tools-team-tasks.js +56 -10
  50. package/cli/polyglot.spec.js +111 -0
  51. package/cli/reader-shorthand.spec.js +2 -2
  52. package/cli/scaffold-frameworks.js +133 -0
  53. package/cli/scaffold.js +102 -41
  54. package/cli/search-ast.js +41 -9
  55. package/cli/search-db.js +2 -8
  56. package/cli/search-queries-semantic.js +28 -9
  57. package/cli/search-tokenizer.js +52 -0
  58. package/cli/search.js +2 -5
  59. package/cli/search.spec.js +51 -3
  60. package/cli/team/team-adversarial-locks.spec.js +71 -0
  61. package/cli/team/team-commands-lock.js +64 -0
  62. package/cli/team/team-commands-vds.js +70 -0
  63. package/cli/team/team-commands.js +86 -24
  64. package/cli/team/team-db-lock-promotion.js +29 -18
  65. package/cli/team/team-db-locks.js +54 -43
  66. package/cli/team/team-db-task-helpers.js +18 -0
  67. package/cli/team/team-db-tasks.js +45 -51
  68. package/cli/team/team-db-transaction.js +52 -0
  69. package/cli/team/team-flags.js +4 -1
  70. package/cli/team/team-format.js +148 -0
  71. package/cli/team/team-memory.js +99 -13
  72. package/cli/team/team-memory.spec.js +49 -0
  73. package/cli/team/team-multiprocess-concurrency.spec.js +193 -0
  74. package/cli/team/team-release-train.js +65 -0
  75. package/cli/team/team-release-train.spec.js +91 -0
  76. package/cli/team/team-schema-vds.js +39 -0
  77. package/cli/team/team-schema.js +21 -23
  78. package/cli/team/team-tasks-asana.spec.js +60 -0
  79. package/cli/team/team-triage.js +12 -0
  80. package/cli/team/team-vds.js +88 -0
  81. package/cli/team/team-vds.spec.js +125 -0
  82. package/cli/team/team-verification-gate.spec.js +27 -0
  83. package/cli/theme.js +1 -0
  84. package/cli/ui-actions-vds.js +48 -0
  85. package/cli/ui-actions.js +1 -0
  86. package/cli/ui-client-api.js +8 -0
  87. package/cli/ui-client-script.js +33 -29
  88. package/cli/ui-dev-watcher.js +61 -0
  89. package/cli/ui-direct-routes.spec.js +55 -0
  90. package/cli/ui-handlers.js +6 -7
  91. package/cli/ui-index.html +416 -26
  92. package/cli/ui-kanban.spec.js +11 -0
  93. package/cli/ui-server-routes.js +14 -6
  94. package/cli/ui-server.js +17 -21
  95. package/cli/ui-sse.js +23 -10
  96. package/cli/ui-sse.spec.js +26 -0
  97. package/cli/ui-styles.js +20 -4
  98. package/cli/ui-template-kanban.js +23 -27
  99. package/cli/ui-template-task-sheet.js +87 -0
  100. package/cli/ui-template-vds-badges.js +34 -0
  101. package/cli/ui-template.js +13 -10
  102. package/cli/verify-helpers.js +192 -0
  103. package/cli/verify.js +132 -176
  104. package/cli/verify.spec.js +96 -0
  105. package/package.json +8 -4
  106. package/scripts/pre-commit.sh +12 -3
  107. package/docs/CHANGELOG.md +0 -332
@@ -222,5 +222,41 @@ export const COMMANDS_SCHEMA = [
222
222
  'npx chemx tesseract',
223
223
  'npx chemx tesseract --json'
224
224
  ]
225
+ },
226
+ {
227
+ name: 'init',
228
+ aliases: [],
229
+ usage: 'npx chemx init [directory] [options]',
230
+ summary: 'Unpack blueprints and molecular architecture drop-in files into an existing codebase.',
231
+ description: 'Installs blueprints, domain hooks, and foundation capsules into target directory (default: src/chemical-x).',
232
+ flags: [
233
+ { flag: '-h, --help', desc: 'Show this help message' },
234
+ { flag: '--license=<key>', desc: 'Provide commercial license key for enterprise starter kit assets' }
235
+ ],
236
+ examples: [
237
+ 'npx chemx init',
238
+ 'npx chemx init src/chemical-x',
239
+ 'npx chemx init packages/ui/src/modules'
240
+ ]
241
+ },
242
+ {
243
+ name: 'create',
244
+ aliases: ['scaffold'],
245
+ usage: 'npm create chemx [directory] [options]',
246
+ summary: 'Scaffold a complete new Chemical X Molecular Architecture application.',
247
+ description: 'Generates a full starter project configured with Chemical X molecular architecture, framework presets, and agent steering directives.',
248
+ flags: [
249
+ { flag: '--framework=<id>', desc: 'Framework flavor: react (default), vue, svelte' },
250
+ { flag: '--yes, -y', desc: 'Skip interactive prompts and scaffold Community Edition immediately' },
251
+ { flag: '--install', desc: 'Auto-install dependencies after scaffolding' },
252
+ { flag: '--headless', desc: 'Run in headless mode for CI/CD and AI agent automation' },
253
+ { flag: '-h, --help', desc: 'Show this help message' },
254
+ { flag: '-v, --version', desc: 'Show version number' }
255
+ ],
256
+ examples: [
257
+ 'npm create chemx my-molecular-app --framework=react',
258
+ 'npx create-chemx my-vue-app --framework=vue --yes',
259
+ 'npx chemx create my-app --framework=svelte --install'
260
+ ]
225
261
  }
226
262
  ];
@@ -0,0 +1,51 @@
1
+ import { describe, it } from 'node:test';
2
+ import assert from 'node:assert';
3
+ import { DEFAULT_PROFILE, getProfileDefaults, loadProjectConfig } from './index.js';
4
+
5
+ describe('Chemical X Configuration & Profiles', () => {
6
+ it('defines pragmatic as the default profile with greybeard staff thresholds', () => {
7
+ assert.strictEqual(DEFAULT_PROFILE, 'pragmatic');
8
+ const defaults = getProfileDefaults('pragmatic');
9
+ assert.strictEqual(defaults.profile, 'pragmatic');
10
+ assert.strictEqual(defaults.enforceFileLength, false);
11
+ assert.strictEqual(defaults.ruleOfThreeAbstractions, true);
12
+ assert.strictEqual(defaults.maxCyclomaticComplexity, 12);
13
+ assert.strictEqual(defaults.maxHookDensity, 4);
14
+ assert.strictEqual(defaults.preferDesignTokens, 'warning');
15
+ });
16
+
17
+ it('defines atomic-strict profile with strict 100-line capsule limit', () => {
18
+ const strict = getProfileDefaults('atomic-strict');
19
+ assert.strictEqual(strict.profile, 'atomic-strict');
20
+ assert.strictEqual(strict.enforceFileLength, true);
21
+ assert.strictEqual(strict.ruleOfThreeAbstractions, false);
22
+ assert.strictEqual(strict.maxLineCountWarning, 100);
23
+ assert.strictEqual(strict.preferDesignTokens, 'error');
24
+ });
25
+
26
+ it('defines loose profile with permissive thresholds', () => {
27
+ const loose = getProfileDefaults('loose');
28
+ assert.strictEqual(loose.profile, 'loose');
29
+ assert.strictEqual(loose.enforceFileLength, false);
30
+ assert.strictEqual(loose.maxCyclomaticComplexity, 25);
31
+ assert.strictEqual(loose.preferDesignTokens, 'off');
32
+ });
33
+
34
+ it('falls back to default profile for unknown profile names', () => {
35
+ const fallback = getProfileDefaults('unknown-profile');
36
+ assert.strictEqual(fallback.profile, 'pragmatic');
37
+ });
38
+
39
+ it('parses --profile CLI argument and overrides file config', () => {
40
+ const cfg = loadProjectConfig(process.cwd(), ['--profile=atomic-strict']);
41
+ assert.strictEqual(cfg.profile, 'atomic-strict');
42
+ assert.strictEqual(cfg.rules.enforceFileLength, true);
43
+ });
44
+
45
+ it('defaults to pragmatic profile when no flags or config files specify otherwise', () => {
46
+ const cfg = loadProjectConfig('/tmp/non-existent-dir-for-chemx-test');
47
+ assert.strictEqual(cfg.profile, 'pragmatic');
48
+ assert.strictEqual(cfg.rules.enforceFileLength, false);
49
+ assert.strictEqual(cfg.rules.maxCyclomaticComplexity, 12);
50
+ });
51
+ });
@@ -0,0 +1,37 @@
1
+ import { PROFILES, DEFAULT_PROFILE, getProfileDefaults } from './profiles.js';
2
+ import { findAndLoadConfigFile } from './loader.js';
3
+
4
+ const parseCliProfile = (rawArgs = []) => {
5
+ const profileArg = rawArgs.find((arg) => arg.startsWith('--profile='));
6
+ if (profileArg) {
7
+ const parts = profileArg.split('=');
8
+ return parts[1]?.trim()?.toLowerCase() || null;
9
+ }
10
+ return null;
11
+ };
12
+
13
+ export const loadProjectConfig = (cwd = process.cwd(), rawArgs = []) => {
14
+ const fileConfig = findAndLoadConfigFile(cwd);
15
+ const cliProfile = parseCliProfile(rawArgs);
16
+
17
+ const isCliProfileExplicit = Boolean(cliProfile);
18
+ const selectedProfile = cliProfile || fileConfig.profile || DEFAULT_PROFILE;
19
+ const profileDefaults = getProfileDefaults(selectedProfile);
20
+
21
+ const effectiveRules = {
22
+ ...profileDefaults,
23
+ ...(isCliProfileExplicit ? {} : fileConfig.rules)
24
+ };
25
+
26
+ return {
27
+ source: fileConfig.source,
28
+ profile: selectedProfile,
29
+ rules: effectiveRules,
30
+ overrides: fileConfig.overrides || [],
31
+ raw: fileConfig.raw || {},
32
+ stage: fileConfig.raw?.stage || 'strict'
33
+ };
34
+ };
35
+
36
+ export { PROFILES, DEFAULT_PROFILE, getProfileDefaults, findAndLoadConfigFile };
37
+ export default loadProjectConfig;
@@ -0,0 +1,83 @@
1
+ import fs from 'node:fs';
2
+ import path from 'node:path';
3
+
4
+ const stripJsonComments = (content) => {
5
+ return content
6
+ .replace(/\/\*[\s\S]*?\*\//g, '')
7
+ .replace(/^\s*\/\/.*$/gm, '');
8
+ };
9
+
10
+ const parseJsonSafe = (raw) => {
11
+ try {
12
+ return JSON.parse(stripJsonComments(raw));
13
+ } catch (parseError) {
14
+ return null;
15
+ }
16
+ };
17
+
18
+ const normalizeRuleKeys = (rules = {}) => {
19
+ const normalized = {};
20
+ const KEY_MAP = {
21
+ 'component-max-complexity': 'maxCyclomaticComplexity',
22
+ 'max-cyclomatic-complexity': 'maxCyclomaticComplexity',
23
+ 'max-hook-density': 'maxHookDensity',
24
+ 'max-render-depth': 'maxRenderDepth',
25
+ 'max-prop-count': 'maxPropCount',
26
+ 'prefer-design-tokens': 'preferDesignTokens',
27
+ 'enforce-file-length': 'enforceFileLength',
28
+ 'rule-of-three-abstractions': 'ruleOfThreeAbstractions',
29
+ 'ai-slop-detection': 'aiSlopDetection',
30
+ 'max-line-count-warning': 'maxLineCountWarning'
31
+ };
32
+
33
+ for (const [key, value] of Object.entries(rules)) {
34
+ const targetKey = KEY_MAP[key] || key;
35
+ normalized[targetKey] = value;
36
+ }
37
+ return normalized;
38
+ };
39
+
40
+ export const findAndLoadConfigFile = (cwd = process.cwd()) => {
41
+ const candidates = [
42
+ path.resolve(cwd, '.chemxrc'),
43
+ path.resolve(cwd, '.chemxrc.json'),
44
+ path.resolve(cwd, '.chemx', 'config.json')
45
+ ];
46
+
47
+ for (const filePath of candidates) {
48
+ if (fs.existsSync(filePath)) {
49
+ const content = fs.readFileSync(filePath, 'utf-8');
50
+ const parsed = parseJsonSafe(content);
51
+ const isObject = parsed !== null && typeof parsed === 'object';
52
+ if (isObject) {
53
+ return {
54
+ source: filePath,
55
+ profile: parsed.profile,
56
+ rules: normalizeRuleKeys(parsed.rules || {}),
57
+ overrides: parsed.overrides || [],
58
+ raw: parsed
59
+ };
60
+ }
61
+ }
62
+ }
63
+
64
+ const pkgPath = path.resolve(cwd, 'package.json');
65
+ if (fs.existsSync(pkgPath)) {
66
+ const rawPkg = fs.readFileSync(pkgPath, 'utf-8');
67
+ const pkg = parseJsonSafe(rawPkg);
68
+ const hasChemxField = Boolean(pkg?.chemx);
69
+ const isChemxObject = typeof pkg?.chemx === 'object';
70
+ const isValidChemxConfig = hasChemxField && isChemxObject;
71
+ if (isValidChemxConfig) {
72
+ return {
73
+ source: pkgPath,
74
+ profile: pkg.chemx.profile,
75
+ rules: normalizeRuleKeys(pkg.chemx.rules || {}),
76
+ overrides: pkg.chemx.overrides || [],
77
+ raw: pkg.chemx
78
+ };
79
+ }
80
+ }
81
+
82
+ return { source: null, profile: null, rules: {}, overrides: [], raw: {} };
83
+ };
@@ -0,0 +1,56 @@
1
+ /**
2
+ * Chemical X Architectural Profiles
3
+ * Defines structural thresholds for Pragmatic, Atomic-Strict, and Loose modes.
4
+ */
5
+
6
+ export const PROFILES = {
7
+ pragmatic: {
8
+ profile: 'pragmatic',
9
+ name: 'Pragmatic Staff Engineer (Default)',
10
+ description: 'Audits structural weight, cyclomatic complexity, hook density, and AI slop without dogmatic line caps.',
11
+ maxCyclomaticComplexity: 12,
12
+ maxHookDensity: 4,
13
+ maxRenderDepth: 4,
14
+ maxPropCount: 7,
15
+ preferDesignTokens: 'warning',
16
+ enforceFileLength: false,
17
+ ruleOfThreeAbstractions: true,
18
+ aiSlopDetection: 'critical',
19
+ maxLineCountWarning: 250
20
+ },
21
+ 'atomic-strict': {
22
+ profile: 'atomic-strict',
23
+ name: 'Atomic-Strict Design System',
24
+ description: 'Original dogmatic 100-line capsule limit and zero-raw-DOM mandate for design system primitives.',
25
+ maxCyclomaticComplexity: 10,
26
+ maxHookDensity: 3,
27
+ maxRenderDepth: 3,
28
+ maxPropCount: 5,
29
+ preferDesignTokens: 'error',
30
+ enforceFileLength: true,
31
+ ruleOfThreeAbstractions: false,
32
+ aiSlopDetection: 'critical',
33
+ maxLineCountWarning: 100
34
+ },
35
+ loose: {
36
+ profile: 'loose',
37
+ name: 'Loose / Rapid Prototyping',
38
+ description: 'Permissive thresholds for hackathons, early prototyping, and legacy codebases.',
39
+ maxCyclomaticComplexity: 25,
40
+ maxHookDensity: 8,
41
+ maxRenderDepth: 6,
42
+ maxPropCount: 12,
43
+ preferDesignTokens: 'off',
44
+ enforceFileLength: false,
45
+ ruleOfThreeAbstractions: true,
46
+ aiSlopDetection: 'medium',
47
+ maxLineCountWarning: 500
48
+ }
49
+ };
50
+
51
+ export const DEFAULT_PROFILE = 'pragmatic';
52
+
53
+ export const getProfileDefaults = (profileName = DEFAULT_PROFILE) => {
54
+ const normalized = String(profileName || DEFAULT_PROFILE).toLowerCase();
55
+ return PROFILES[normalized] || PROFILES[DEFAULT_PROFILE];
56
+ };
@@ -0,0 +1 @@
1
+ import './config/config.spec.js';
package/cli/create.js CHANGED
@@ -20,14 +20,17 @@ USAGE
20
20
  npx create-chemx [directory] [options]
21
21
 
22
22
  OPTIONS
23
- --yes, -y Skip interactive prompts and scaffold Community Edition immediately
24
- --headless Run in headless mode for CI/CD and AI agent automation
25
- -h, --help Show this help message
26
- -v, --version Show version number
23
+ --framework=<id> Framework flavor: react (default), vue, svelte
24
+ --install Auto-install dependencies after scaffolding
25
+ --skip-install Skip installing dependencies (default: prompts in Next Steps)
26
+ --yes, -y Skip interactive prompts and scaffold Community Edition immediately
27
+ --headless Run in headless mode for CI/CD and AI agent automation
28
+ -h, --help Show this help message
29
+ -v, --version Show version number
27
30
 
28
31
  EXAMPLES
29
- npm create chemx my-molecular-app
30
- npx create-chemx my-molecular-app --yes
32
+ npm create chemx my-molecular-app --framework=react
33
+ npx create-chemx my-vue-app --framework=vue --yes
31
34
  pnpm create chemx my-app
32
35
 
33
36
  DOCUMENTATION
@@ -54,11 +57,21 @@ const KNOWN_FLAGS = new Set([
54
57
  '-v', '--version',
55
58
  '--ci',
56
59
  '--non-interactive',
57
- '--no-interactive'
60
+ '--no-interactive',
61
+ '--install',
62
+ '--skip-install',
63
+ '--no-install',
64
+ '--framework'
58
65
  ]);
59
66
 
60
67
  for (const arg of rawArgs) {
61
- if (arg.startsWith('-') && !KNOWN_FLAGS.has(arg)) {
68
+ const isFlag = arg.startsWith('-');
69
+ const isKnownFlag = KNOWN_FLAGS.has(arg);
70
+ const isFrameworkFlag = arg === '--framework' || arg.startsWith('--framework=');
71
+ const isPresetFlag = arg.startsWith('--preset=');
72
+ const isValidOption = isKnownFlag || isFrameworkFlag || isPresetFlag;
73
+
74
+ if (isFlag && !isValidOption) {
62
75
  process.stderr.write(`Unknown option "${arg}". Run --help for usage.\n`);
63
76
  process.exit(1);
64
77
  }
@@ -197,4 +197,95 @@ describe('Scaffolding Entrypoint Invocations', () => {
197
197
  assert.match(result.stderr, /Unknown command "config"/, 'Should report unknown command');
198
198
  assert.ok(!fs.existsSync(path.join(tmpBase, 'config')), 'Must NOT create a config directory when installed under create-chemx path');
199
199
  });
200
+
201
+ const getAllFiles = (dir) => {
202
+ const results = [];
203
+ const walk = (d) => {
204
+ const list = fs.readdirSync(d, { withFileTypes: true });
205
+ for (const item of list) {
206
+ const full = path.join(d, item.name);
207
+ if (item.isDirectory()) {
208
+ walk(full);
209
+ } else {
210
+ results.push(full);
211
+ }
212
+ }
213
+ };
214
+ walk(dir);
215
+ return results;
216
+ };
217
+
218
+ test('framework isolation: --framework=react produces zero .vue and zero .svelte files, and derives react deps', () => {
219
+ const tmpBase = fs.mkdtempSync(path.join(os.tmpdir(), 'chemx-test-react-'));
220
+ cleanupDirs.push(tmpBase);
221
+ const targetDir = path.join(tmpBase, 'react-app');
222
+
223
+ const result = spawnSync('node', [CREATE_BIN, targetDir, '--framework=react', '--yes'], {
224
+ encoding: 'utf-8',
225
+ cwd: tmpBase,
226
+ timeout: 15000
227
+ });
228
+
229
+ assert.equal(result.status, 0, `Failed: ${result.stderr}`);
230
+ const files = getAllFiles(targetDir);
231
+ const vueFiles = files.filter((f) => f.endsWith('.vue'));
232
+ const svelteFiles = files.filter((f) => f.endsWith('.svelte'));
233
+ assert.strictEqual(vueFiles.length, 0, `React app contains .vue files: ${vueFiles.join(', ')}`);
234
+ assert.strictEqual(svelteFiles.length, 0, `React app contains .svelte files: ${svelteFiles.join(', ')}`);
235
+
236
+ const pkg = JSON.parse(fs.readFileSync(path.join(targetDir, 'package.json'), 'utf-8'));
237
+ assert.ok(pkg.dependencies.react, 'Must have react in dependencies');
238
+ assert.ok(pkg.dependencies['react-dom'], 'Must have react-dom in dependencies');
239
+ assert.strictEqual(pkg.dependencies.vue, undefined, 'Must not have vue in dependencies');
240
+ assert.strictEqual(pkg.devDependencies['@vue/test-utils'], undefined, 'Must not have @vue/test-utils in devDependencies');
241
+ });
242
+
243
+ test('framework isolation: --framework=vue produces zero .tsx, .jsx, and zero .svelte files, and derives vue deps', () => {
244
+ const tmpBase = fs.mkdtempSync(path.join(os.tmpdir(), 'chemx-test-vue-'));
245
+ cleanupDirs.push(tmpBase);
246
+ const targetDir = path.join(tmpBase, 'vue-app');
247
+
248
+ const result = spawnSync('node', [CREATE_BIN, targetDir, '--framework=vue', '--yes'], {
249
+ encoding: 'utf-8',
250
+ cwd: tmpBase,
251
+ timeout: 15000
252
+ });
253
+
254
+ assert.equal(result.status, 0, `Failed: ${result.stderr}`);
255
+ const files = getAllFiles(targetDir);
256
+ const tsxFiles = files.filter((f) => f.endsWith('.tsx') || f.endsWith('.jsx'));
257
+ const svelteFiles = files.filter((f) => f.endsWith('.svelte'));
258
+ assert.strictEqual(tsxFiles.length, 0, `Vue app contains .tsx/.jsx files: ${tsxFiles.join(', ')}`);
259
+ assert.strictEqual(svelteFiles.length, 0, `Vue app contains .svelte files: ${svelteFiles.join(', ')}`);
260
+
261
+ const pkg = JSON.parse(fs.readFileSync(path.join(targetDir, 'package.json'), 'utf-8'));
262
+ assert.ok(pkg.dependencies.vue, 'Must have vue in dependencies');
263
+ assert.ok(pkg.devDependencies['@vue/test-utils'], 'Must have @vue/test-utils in devDependencies');
264
+ assert.strictEqual(pkg.dependencies.react, undefined, 'Must not have react in dependencies');
265
+ assert.strictEqual(pkg.devDependencies['@types/react'], undefined, 'Must not have @types/react');
266
+ });
267
+
268
+ test('framework isolation: --framework=svelte produces zero .vue, .tsx, .jsx files, and derives svelte deps', () => {
269
+ const tmpBase = fs.mkdtempSync(path.join(os.tmpdir(), 'chemx-test-svelte-'));
270
+ cleanupDirs.push(tmpBase);
271
+ const targetDir = path.join(tmpBase, 'svelte-app');
272
+
273
+ const result = spawnSync('node', [CREATE_BIN, targetDir, '--framework=svelte', '--yes'], {
274
+ encoding: 'utf-8',
275
+ cwd: tmpBase,
276
+ timeout: 15000
277
+ });
278
+
279
+ assert.equal(result.status, 0, `Failed: ${result.stderr}`);
280
+ const files = getAllFiles(targetDir);
281
+ const vueFiles = files.filter((f) => f.endsWith('.vue'));
282
+ const tsxFiles = files.filter((f) => f.endsWith('.tsx') || f.endsWith('.jsx'));
283
+ assert.strictEqual(vueFiles.length, 0, `Svelte app contains .vue files: ${vueFiles.join(', ')}`);
284
+ assert.strictEqual(tsxFiles.length, 0, `Svelte app contains .tsx/.jsx files: ${tsxFiles.join(', ')}`);
285
+
286
+ const pkg = JSON.parse(fs.readFileSync(path.join(targetDir, 'package.json'), 'utf-8'));
287
+ assert.ok(pkg.dependencies.svelte, 'Must have svelte in dependencies');
288
+ assert.strictEqual(pkg.dependencies.vue, undefined, 'Must not have vue in dependencies');
289
+ assert.strictEqual(pkg.dependencies.react, undefined, 'Must not have react in dependencies');
290
+ });
200
291
  });
@@ -0,0 +1,48 @@
1
+ import { renderBanner } from './terminal.js';
2
+
3
+ export const printGenerateHelp = () => {
4
+ renderBanner('Chemical X: Capsule Generator Usage');
5
+ const BOLD = '\x1b[1m';
6
+ const CYAN = '\x1b[36m';
7
+ const DIM = '\x1b[2m';
8
+ const RESET = '\x1b[0m';
9
+
10
+ const out = [
11
+ `${BOLD}USAGE${RESET}`,
12
+ ` ${CYAN}npx chemx generate${RESET} <name> [options]`,
13
+ ` ${CYAN}npx chemx generate${RESET} <tier> <name> [options]`,
14
+ '',
15
+ `${BOLD}TIERS${RESET}`,
16
+ ` ${CYAN}atom${RESET} (a-) Foundational UI elements (raw HTML permitted)`,
17
+ ` ${CYAN}molecule${RESET} (m-) Groups of atoms (no raw HTML, co-located controller)`,
18
+ ` ${CYAN}organism${RESET} (o-) Complex feature modules`,
19
+ ` ${CYAN}hook${RESET} (use-) Domain state / headless composables (< 5 return properties)`,
20
+ ` ${CYAN}view${RESET} (v-) Declarative Table-of-Contents views`,
21
+ '',
22
+ `${BOLD}OPTIONS${RESET}`,
23
+ ` ${CYAN}--tier=<tier>${RESET} Specify component tier`,
24
+ ` ${CYAN}--framework=<react|vue|svelte>${RESET} Framework flavor (default: auto-detected or react)`,
25
+ ` ${CYAN}--dir=<path>${RESET} Target directory (default: src/components/<tier>s)`,
26
+ ` ${CYAN}--desc="<text>"${RESET} Describe functionality to tailor archetype and state`,
27
+ ` ${CYAN}--dry-run${RESET} Preview planned files and lines without touching disk`,
28
+ ` ${CYAN}--lean${RESET} Generate minimal capsule without controller/spec`,
29
+ ` ${CYAN}--json${RESET} Output result as minified JSON`,
30
+ ` ${CYAN}-y, --yes${RESET} Non-interactive mode with defaults`,
31
+ ` ${CYAN}-h, --help${RESET} Show this help message`,
32
+ '',
33
+ `${BOLD}EXAMPLES${RESET}`,
34
+ ` ${CYAN}npx chemx generate m-task-list --framework=react${RESET}`,
35
+ ` ${CYAN}npx chemx generate m-task-list --desc="add, toggle, remove items"${RESET}`,
36
+ ` ${CYAN}npx chemx generate m-task-list --dry-run${RESET}`,
37
+ ` ${CYAN}npx chemx generate hook use-task-filter${RESET}`,
38
+ ` ${CYAN}npx chemx generate view v-user-profile${RESET}`,
39
+ '',
40
+ `${BOLD}LINE LIMITS${RESET}`,
41
+ ` ${DIM}Molecule capsule template: < 100 lines (outer bound)${RESET}`,
42
+ ` ${DIM}Co-located controller hook: < 100 lines (pure reactive state)${RESET}`,
43
+ ` ${DIM}Table of Contents view: 10-20 lines (declarative slot assembly)${RESET}`,
44
+ ''
45
+ ];
46
+
47
+ process.stdout.write(`${out.join('\n')}\n`);
48
+ };
@@ -0,0 +1,41 @@
1
+ import fs from 'node:fs';
2
+ import path from 'node:path';
3
+ import { isSqliteAvailable, openIndexDb } from './search-schema.js';
4
+ import { upsertFileIndex } from './search-db.js';
5
+ import { resolveArchitectureTier, extractAstMetadata } from './search-ast.js';
6
+
7
+ export const parseFileAst = (absPath, relPath) => {
8
+ const content = fs.readFileSync(absPath, 'utf-8');
9
+ const stat = fs.statSync(absPath);
10
+ const lines = content.split('\n').length;
11
+ const chars = content.length;
12
+ const tier = resolveArchitectureTier(relPath);
13
+ const { symbols, props, hooks, imports } = extractAstMetadata(content, absPath);
14
+ return {
15
+ path: relPath,
16
+ mtime: Math.floor(stat.mtimeMs),
17
+ size: stat.size,
18
+ tier,
19
+ lines,
20
+ chars,
21
+ symbols,
22
+ props,
23
+ hooks,
24
+ imports
25
+ };
26
+ };
27
+
28
+ export const indexGeneratedFiles = (cwd, targetDir, filesCreated = []) => {
29
+ if (!isSqliteAvailable()) return;
30
+ const db = openIndexDb(cwd);
31
+ if (!db) return;
32
+
33
+ for (const relFile of filesCreated) {
34
+ const absPath = path.join(targetDir, relFile);
35
+ const relPath = path.relative(cwd, absPath);
36
+ if (fs.existsSync(absPath)) {
37
+ const astData = parseFileAst(absPath, relPath);
38
+ upsertFileIndex(db, astData);
39
+ }
40
+ }
41
+ };
package/cli/generator.js CHANGED
@@ -30,6 +30,9 @@ import {
30
30
  buildCompactCapsule
31
31
  } from './generator-templates.js';
32
32
  import { detectFramework, resolveFramework, detectTierBaseDir, detectInstalledFamily, detectTestRunner, detectStylingStack } from './project-detector.js';
33
+ import { indexGeneratedFiles } from './generator-indexer.js';
34
+ import { printGenerateHelp } from './generator-help.js';
35
+ export { printGenerateHelp } from './generator-help.js';
33
36
 
34
37
  const TIERS = [
35
38
  { prefix: 'm-', tier: 'molecule', label: '1. m- Molecule (Self-contained feature block < 100 lines - Recommended)' },
@@ -256,6 +259,10 @@ export const createCapsuleFiles = ({
256
259
  }
257
260
  }
258
261
 
262
+ if (!dryRun) {
263
+ indexGeneratedFiles(cwd, targetDir, filesCreated);
264
+ }
265
+
259
266
  const relTargetDir = path.relative(cwd, targetDir);
260
267
 
261
268
  return {
@@ -274,48 +281,6 @@ export const createCapsuleFiles = ({
274
281
  };
275
282
  };
276
283
 
277
- export const printGenerateHelp = () => {
278
- renderBanner('Chemical X: Capsule Generator Usage');
279
- const BOLD = '\x1b[1m';
280
- const CYAN = '\x1b[36m';
281
- const DIM = '\x1b[2m';
282
- const RESET = '\x1b[0m';
283
-
284
- const out = [
285
- `${BOLD}USAGE${RESET}`,
286
- ` ${CYAN}npx chemx generate${RESET} <name> [options]`,
287
- ` ${CYAN}npx chemx generate${RESET} <tier> <name> [options]`,
288
- '',
289
- `${BOLD}TIERS${RESET}`,
290
- ` ${CYAN}atom${RESET} (a-) Foundational UI elements (raw HTML permitted)`,
291
- ` ${CYAN}molecule${RESET} (m-) Groups of atoms (no raw HTML, co-located controller)`,
292
- ` ${CYAN}organism${RESET} (o-) Complex feature modules`,
293
- ` ${CYAN}hook${RESET} (use-) Domain state / headless composables (< 5 return properties)`,
294
- ` ${CYAN}view${RESET} (v-) Declarative Table-of-Contents views`,
295
- '',
296
- `${BOLD}OPTIONS${RESET}`,
297
- ` ${CYAN}--tier=<tier>${RESET} Specify component tier`,
298
- ` ${CYAN}--framework=<react|vue|svelte>${RESET} Framework flavor (default: auto-detected or react)`,
299
- ` ${CYAN}--dir=<path>${RESET} Target directory (default: src/components/<tier>s)`,
300
- ` ${CYAN}--desc="<text>"${RESET} Describe functionality to tailor archetype and state`,
301
- ` ${CYAN}--dry-run${RESET} Preview planned files and lines without touching disk`,
302
- ` ${CYAN}--lean${RESET} Generate minimal capsule without controller/spec`,
303
- ` ${CYAN}--json${RESET} Output result as minified JSON`,
304
- ` ${CYAN}-y, --yes${RESET} Non-interactive mode with defaults`,
305
- ` ${CYAN}-h, --help${RESET} Show this help message`,
306
- '',
307
- `${BOLD}EXAMPLES${RESET}`,
308
- ` ${CYAN}npx chemx generate m-task-list --framework=react${RESET}`,
309
- ` ${CYAN}npx chemx generate m-task-list --desc="add, toggle, remove items"${RESET}`,
310
- ` ${CYAN}npx chemx generate m-task-list --dry-run${RESET}`,
311
- ` ${CYAN}npx chemx generate hook use-task-filter${RESET}`,
312
- ` ${CYAN}npx chemx generate atom badge --dir=src/ui/atoms${RESET}`,
313
- ''
314
- ].join('\n');
315
-
316
- process.stdout.write(out);
317
- };
318
-
319
284
  export const runGenerateWizard = async (rawArgs = []) => {
320
285
  const isHelp = rawArgs.includes('--help') || rawArgs.includes('-h') || rawArgs.includes('help');
321
286
  if (isHelp) {
@@ -453,7 +418,7 @@ export const runGenerateWizard = async (rawArgs = []) => {
453
418
  tier: selectedTier.tier,
454
419
  targetParent,
455
420
  isLean,
456
- cwd: process.cwd(),
421
+ cwd: targetCwd,
457
422
  desc: descArg,
458
423
  template: templateArg,
459
424
  css: cssArg,
@@ -13,6 +13,7 @@ import {
13
13
  } from './generator-templates.js';
14
14
  import { handleCheckCommand } from './search-commands.js';
15
15
  import { obtainLicenseKey } from './license.js';
16
+ import { openIndexDb, getAllIndexedFiles } from './search-db.js';
16
17
 
17
18
  test('generator-templates: toPascalCase and toCamelCase convert slugs correctly', () => {
18
19
  assert.strictEqual(toPascalCase('m-user-avatar'), 'UserAvatar');
@@ -255,5 +256,33 @@ test('runGenerateWizard: spec uses Vitest imports when vitest is declared in pac
255
256
  fs.rmSync(tmpDir, { recursive: true, force: true });
256
257
  });
257
258
 
259
+ test('runGenerateWizard: generated capsule files are automatically indexed in .chemx/index.db', async () => {
260
+ const tmpDir = path.resolve(process.cwd(), 'scratch/test-gen-indexing');
261
+ if (fs.existsSync(tmpDir)) fs.rmSync(tmpDir, { recursive: true, force: true });
262
+ fs.mkdirSync(tmpDir, { recursive: true });
263
+ fs.writeFileSync(path.join(tmpDir, 'package.json'), JSON.stringify({
264
+ name: 'test-indexing',
265
+ type: 'module'
266
+ }));
267
+
268
+ const res = await runGenerateWizard([
269
+ 'molecule',
270
+ 'status-pill',
271
+ '-y',
272
+ `--dir=${tmpDir}`,
273
+ '--framework=react'
274
+ ]);
275
+
276
+ assert.strictEqual(res.success, true);
277
+ const db = openIndexDb(tmpDir);
278
+ assert.ok(db, 'Index db must exist in target directory');
279
+ const files = getAllIndexedFiles(db);
280
+ assert.ok(files.size >= 1, 'Generated files must be automatically indexed');
281
+ const hasCapsule = Array.from(files.keys()).some((p) => p.includes('m-status-pill'));
282
+ assert.ok(hasCapsule, 'Capsule file must be present in index');
283
+
284
+ fs.rmSync(tmpDir, { recursive: true, force: true });
285
+ });
286
+
258
287
 
259
288
 
package/cli/help.d.ts CHANGED
@@ -1 +1,3 @@
1
1
  export declare function printHelp(): void;
2
+ export declare function printInitHelp(): void;
3
+ export declare function printScaffoldHelp(): void;