@chemx/starter-kit 26.9.21-8 → 26.9.23-1269
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/cli/audit/ast-visitors.js +10 -17
- package/cli/audit/autofix.js +17 -2
- package/cli/audit/clone-detector.js +64 -0
- package/cli/audit/clone-detector.spec.js +46 -0
- package/cli/audit/hook-shape-validator.js +312 -0
- package/cli/audit/prompts.js +1 -1
- package/cli/audit/reporter-clones.js +33 -0
- package/cli/audit/reporter-hotspot-graph.js +34 -0
- package/cli/audit/rules-registry.js +6 -1
- package/cli/audit/rules.js +10 -2
- package/cli/audit/rules.spec.js +129 -0
- package/cli/audit-stages.spec.js +30 -0
- package/cli/audit.js +12 -3
- package/cli/commands/cmd-audit.js +43 -3
- package/cli/commands/cmd-project.js +100 -0
- package/cli/commands/cmd-router.js +34 -2
- package/cli/commands-schema.js +14 -0
- package/cli/create.spec.js +2 -2
- package/cli/exploder.js +258 -0
- package/cli/exploder.spec.js +99 -0
- package/cli/generator-compact.spec.js +104 -0
- package/cli/generator-framework.spec.js +72 -0
- package/cli/generator-templates/archetypes/collection-archetypes.js +9 -9
- package/cli/generator-templates/archetypes/index.js +34 -4
- package/cli/generator-templates/archetypes/input-archetypes.js +2 -2
- package/cli/generator-templates/archetypes/layout-archetypes.js +2 -2
- package/cli/generator-templates/archetypes/minimal-archetypes.js +131 -0
- package/cli/generator-templates/archetypes/status-archetypes.js +4 -4
- package/cli/generator-templates/archetypes/vector-matcher.js +50 -0
- package/cli/generator-templates/archetypes/vector-matcher.spec.js +25 -0
- package/cli/generator-templates/compact.js +130 -0
- package/cli/generator-templates/controller-converters.js +93 -0
- package/cli/generator-templates/controller.js +2 -64
- package/cli/generator-templates/react.js +1 -1
- package/cli/generator-templates/svelte.js +1 -1
- package/cli/generator-templates/types.js +2 -2
- package/cli/generator-templates/vue.js +1 -1
- package/cli/generator-templates.js +1 -0
- package/cli/generator-templates.spec.js +6 -1
- package/cli/generator.js +94 -7
- package/cli/help.js +1 -1
- package/cli/index.js +21 -8
- package/cli/installer-templates.js +1 -1
- package/cli/mcp/antigravity.js +3 -2
- package/cli/mcp/installer.js +7 -7
- package/cli/mcp/installer.spec.js +3 -3
- package/cli/mcp/manifests.js +3 -2
- package/cli/mcp/prompts.js +1 -1
- package/cli/mcp/server.js +2 -0
- package/cli/mcp/tools-audit.js +95 -0
- package/cli/mcp/tools-generate.js +62 -0
- package/cli/mcp/tools-patch.js +72 -0
- package/cli/mcp/tools-patterns.js +71 -0
- package/cli/mcp/tools-project.js +75 -0
- package/cli/mcp/tools-project.spec.js +51 -0
- package/cli/mcp/tools-q-modes.js +69 -0
- package/cli/mcp/tools-q.js +58 -0
- package/cli/mcp/tools-read.js +69 -0
- package/cli/mcp/tools-search-util.js +35 -0
- package/cli/mcp/tools-search.js +15 -294
- package/cli/mcp/tools-team-feed.js +57 -0
- package/cli/mcp/tools-team-locks.js +63 -0
- package/cli/mcp/tools-team-mailbox.js +32 -0
- package/cli/mcp/tools-team-tasks.js +84 -0
- package/cli/mcp/tools-team.js +37 -183
- package/cli/mcp/tools-verify.js +47 -0
- package/cli/mcp/tools-write.js +33 -0
- package/cli/mcp/tools.js +72 -376
- package/cli/mutators.js +10 -23
- package/cli/pillars-schema.js +3 -3
- package/cli/project-detector.js +47 -0
- package/cli/reader-shorthand.spec.js +60 -0
- package/cli/reader.js +67 -24
- package/cli/search-bulletproof.spec.js +104 -0
- package/cli/search-db.js +33 -5
- package/cli/search-queries-hotspot-graph.js +65 -0
- package/cli/search-queries-hotspot-graph.spec.js +66 -0
- package/cli/search-queries-similar.js +84 -0
- package/cli/search-queries-similar.spec.js +43 -0
- package/cli/search-schema.js +30 -10
- package/cli/search.js +9 -2
- package/cli/team/index.js +9 -0
- package/cli/team/team-commands.js +104 -64
- package/cli/team/team-concurrency-stress.spec.js +95 -0
- package/cli/team/team-db-mailbox.js +86 -0
- package/cli/team/team-db-task-helpers.js +30 -28
- package/cli/team/team-db-tasks.js +13 -5
- package/cli/team/team-flags.js +69 -0
- package/cli/team/team-format.js +87 -46
- package/cli/team/team-mailbox-empirical.spec.js +191 -0
- package/cli/team/team-mailbox.spec.js +93 -0
- package/cli/team/team-memory.js +84 -0
- package/cli/team/team-memory.spec.js +74 -0
- package/cli/team/team-projects-coordinator.js +100 -0
- package/cli/team/team-projects-format.js +45 -0
- package/cli/team/team-projects-memory.js +70 -0
- package/cli/team/team-projects.js +94 -0
- package/cli/team/team-projects.spec.js +116 -0
- package/cli/team/team-schema-memory.js +25 -0
- package/cli/team/team-schema-projects.js +50 -0
- package/cli/team/team-schema.js +33 -14
- package/cli/team/team-tasks-hierarchy.spec.js +80 -0
- package/cli/team/team-tokens.js +95 -0
- package/cli/team/team-triage.js +159 -12
- package/cli/team/team-verification-gate.spec.js +253 -0
- package/cli/team/team.spec.js +1 -1
- package/cli/trend.js +84 -0
- package/cli/trend.spec.js +51 -0
- package/cli/ui-actions-tasks.js +13 -5
- package/cli/ui-actions.js +10 -2
- package/cli/ui-client-api.js +2 -2
- package/cli/ui-client-script.js +12 -15
- package/cli/ui-e2e-verification.spec.js +13 -3
- package/cli/ui-filetree.spec.js +5 -5
- package/cli/ui-handlers.js +10 -2
- package/cli/ui-html.js +26 -34
- package/cli/ui-index.html +905 -0
- package/cli/ui-kanban.spec.js +12 -12
- package/cli/ui-server.js +7 -0
- package/cli/ui-sse.js +57 -0
- package/cli/ui-sse.spec.js +74 -0
- package/cli/ui-styles.js +195 -81
- package/cli/ui-template-kanban.js +15 -1
- package/cli/ui-vbulletin.spec.js +12 -13
- package/cli/ui.spec.js +12 -5
- package/cli/verify.js +19 -8
- package/package.json +3 -1
- package/scripts/check-framework-generation.mjs +195 -0
- package/scripts/pre-commit.sh +2 -7
- package/scripts/publish-both.mjs +4 -0
|
@@ -1,7 +1,7 @@
|
|
|
1
1
|
import { resolveArchetype } from './archetypes/index.js';
|
|
2
2
|
|
|
3
3
|
export const buildPropsType = (name, pascalName, options = {}) => {
|
|
4
|
-
const archetype = resolveArchetype(name, options.description || options.desc);
|
|
4
|
+
const archetype = resolveArchetype(name, options.description || options.desc, options.template || options.archetype);
|
|
5
5
|
if (archetype && typeof archetype.buildProps === 'function') {
|
|
6
6
|
const rawProps = archetype.buildProps(name, pascalName);
|
|
7
7
|
if (!rawProps.includes(`${pascalName}Emits`)) {
|
|
@@ -28,7 +28,7 @@ export interface ${pascalName}Emits {
|
|
|
28
28
|
};
|
|
29
29
|
|
|
30
30
|
export const buildStateType = (name, pascalName, options = {}) => {
|
|
31
|
-
const archetype = resolveArchetype(name, options.description || options.desc);
|
|
31
|
+
const archetype = resolveArchetype(name, options.description || options.desc, options.template || options.archetype);
|
|
32
32
|
if (archetype && typeof archetype.buildState === 'function') {
|
|
33
33
|
return archetype.buildState(name, pascalName);
|
|
34
34
|
}
|
|
@@ -3,7 +3,7 @@ import { resolveArchetype } from './archetypes/index.js';
|
|
|
3
3
|
export const buildVueComponent = (name, pascalName, options = {}) => {
|
|
4
4
|
const atomsPackage = options.atomsPackage || null;
|
|
5
5
|
const hasController = options.hasController !== false;
|
|
6
|
-
const archetype = resolveArchetype(name, options.description || options.desc);
|
|
6
|
+
const archetype = resolveArchetype(name, options.description || options.desc, options.template || options.archetype);
|
|
7
7
|
|
|
8
8
|
const controllerImport = hasController
|
|
9
9
|
? `import { use${pascalName}Controller } from './${name}.controller';\n`
|
|
@@ -161,7 +161,7 @@ test('archetypes: semantic code generation for task-list archetype', () => {
|
|
|
161
161
|
|
|
162
162
|
const react = buildReactComponent('m-task-list', 'TaskList');
|
|
163
163
|
assert.ok(react.includes('useTaskListController'));
|
|
164
|
-
assert.ok(react.includes('items, activeCount, setFilter, toggleItem, removeItem'));
|
|
164
|
+
assert.ok(react.includes('items, filter, activeCount, setFilter, toggleItem, removeItem'));
|
|
165
165
|
assert.ok(react.includes('m-task-list__list'));
|
|
166
166
|
|
|
167
167
|
const withAtoms = buildReactComponent('m-task-list', 'TaskList', { atomsPackage: '@chemx/x-atoms' });
|
|
@@ -180,3 +180,8 @@ test('archetypes: resolveArchetype matches from description keywords', () => {
|
|
|
180
180
|
const cart = resolveArchetype('m-box', 'shopping cart checkout billing payment');
|
|
181
181
|
assert.equal(cart.id, 'cart-billing');
|
|
182
182
|
});
|
|
183
|
+
|
|
184
|
+
test('archetypes: resolveArchetype matches from semantic vector embeddings on unknown slugs', () => {
|
|
185
|
+
const chat = resolveArchetype('m-quantum-nexus', 'live chat messages conversation thread');
|
|
186
|
+
assert.equal(chat.id, 'chat-messaging');
|
|
187
|
+
});
|
package/cli/generator.js
CHANGED
|
@@ -5,6 +5,7 @@ import { checkOrPromptEvaluation } from './license.js';
|
|
|
5
5
|
import {
|
|
6
6
|
toPascalCase,
|
|
7
7
|
toCamelCase,
|
|
8
|
+
resolveArchetype,
|
|
8
9
|
buildReactComponent,
|
|
9
10
|
buildVueComponent,
|
|
10
11
|
buildSvelteComponent,
|
|
@@ -25,9 +26,10 @@ import {
|
|
|
25
26
|
buildSvelteView,
|
|
26
27
|
buildViewParamsType,
|
|
27
28
|
buildViewIndex,
|
|
28
|
-
buildViewSpec
|
|
29
|
+
buildViewSpec,
|
|
30
|
+
buildCompactCapsule
|
|
29
31
|
} from './generator-templates.js';
|
|
30
|
-
import { detectFramework, resolveFramework, detectTierBaseDir, detectInstalledFamily, detectTestRunner } from './project-detector.js';
|
|
32
|
+
import { detectFramework, resolveFramework, detectTierBaseDir, detectInstalledFamily, detectTestRunner, detectStylingStack } from './project-detector.js';
|
|
31
33
|
|
|
32
34
|
const TIERS = [
|
|
33
35
|
{ prefix: 'm-', tier: 'molecule', label: '1. m- Molecule (Self-contained feature block < 100 lines - Recommended)' },
|
|
@@ -82,11 +84,20 @@ export const createCapsuleFiles = ({
|
|
|
82
84
|
cwd = process.cwd(),
|
|
83
85
|
desc = '',
|
|
84
86
|
description = '',
|
|
87
|
+
template = null,
|
|
88
|
+
templateArg = null,
|
|
89
|
+
css = null,
|
|
90
|
+
compact = false,
|
|
91
|
+
flat = false,
|
|
85
92
|
dryRun = false
|
|
86
93
|
}) => {
|
|
87
94
|
const capsuleDesc = desc || description || '';
|
|
88
95
|
const cleanName = (name || 'user-avatar').trim().toLowerCase();
|
|
89
96
|
const selectedTier = resolveSelectedTier(tier, cleanName);
|
|
97
|
+
const explicitTemplate = template || templateArg || null;
|
|
98
|
+
const isCompact = Boolean(compact || flat);
|
|
99
|
+
const styling = detectStylingStack(cwd);
|
|
100
|
+
const wantsNoScss = css === 'none' || css === 'tailwind' || (styling.hasTailwind && css !== 'scss');
|
|
90
101
|
|
|
91
102
|
const resolvedFrameworkId = resolveFramework({ frameworkArg: framework, cwd });
|
|
92
103
|
const selectedFramework = FRAMEWORKS.find(
|
|
@@ -112,6 +123,56 @@ export const createCapsuleFiles = ({
|
|
|
112
123
|
const detectedDir = detectTierBaseDir(selectedTier.tier, cwd);
|
|
113
124
|
const parentDir = targetParent || detectedDir;
|
|
114
125
|
const resolvedParent = path.resolve(cwd, parentDir || '.');
|
|
126
|
+
|
|
127
|
+
const isHookOrView = selectedTier.tier === 'hook' || selectedTier.tier === 'view';
|
|
128
|
+
const canUseCompact = isCompact && !isHookOrView;
|
|
129
|
+
if (canUseCompact) {
|
|
130
|
+
const compFile = `${capsuleName}.${selectedFramework.ext}`;
|
|
131
|
+
const targetFilePath = path.resolve(resolvedParent, compFile);
|
|
132
|
+
|
|
133
|
+
if (!dryRun && fs.existsSync(targetFilePath)) {
|
|
134
|
+
throw new Error(`File ${compFile} already exists at ${targetFilePath}.`);
|
|
135
|
+
}
|
|
136
|
+
|
|
137
|
+
const archetype = resolveArchetype(capsuleName, capsuleDesc, explicitTemplate);
|
|
138
|
+
const installedFamily = detectInstalledFamily(cwd);
|
|
139
|
+
const compactContent = buildCompactCapsule({
|
|
140
|
+
capsuleName,
|
|
141
|
+
pascalName,
|
|
142
|
+
framework: selectedFramework.id,
|
|
143
|
+
archetype,
|
|
144
|
+
atomsPackage: installedFamily.atomsPackage
|
|
145
|
+
});
|
|
146
|
+
|
|
147
|
+
const filesCreated = [compFile];
|
|
148
|
+
const previews = [{ file: compFile, lines: compactContent.split('\n').length }];
|
|
149
|
+
|
|
150
|
+
if (!dryRun) {
|
|
151
|
+
if (!fs.existsSync(resolvedParent)) {
|
|
152
|
+
fs.mkdirSync(resolvedParent, { recursive: true });
|
|
153
|
+
}
|
|
154
|
+
fs.writeFileSync(targetFilePath, compactContent, 'utf-8');
|
|
155
|
+
}
|
|
156
|
+
|
|
157
|
+
const relTargetDir = path.relative(cwd, targetFilePath);
|
|
158
|
+
|
|
159
|
+
return {
|
|
160
|
+
success: true,
|
|
161
|
+
compact: true,
|
|
162
|
+
dryRun: Boolean(dryRun),
|
|
163
|
+
capsuleName,
|
|
164
|
+
pascalName,
|
|
165
|
+
framework: selectedFramework.id,
|
|
166
|
+
tier: selectedTier.tier,
|
|
167
|
+
targetDir: targetFilePath,
|
|
168
|
+
relativeDir: relTargetDir,
|
|
169
|
+
directory: relTargetDir,
|
|
170
|
+
files: filesCreated,
|
|
171
|
+
filesCreated,
|
|
172
|
+
previews
|
|
173
|
+
};
|
|
174
|
+
}
|
|
175
|
+
|
|
115
176
|
const targetDir = path.resolve(resolvedParent, capsuleName);
|
|
116
177
|
const runner = detectTestRunner(targetDir || cwd);
|
|
117
178
|
|
|
@@ -170,24 +231,26 @@ export const createCapsuleFiles = ({
|
|
|
170
231
|
atomsPackage: installedFamily.atomsPackage,
|
|
171
232
|
hasController,
|
|
172
233
|
description: capsuleDesc,
|
|
173
|
-
framework: selectedFramework.id
|
|
234
|
+
framework: selectedFramework.id,
|
|
235
|
+
template: explicitTemplate
|
|
174
236
|
};
|
|
175
237
|
|
|
176
238
|
recordFile(compFile, path.join(targetDir, compFile), selectedFramework.compBuilder(capsuleName, pascalName, templateOpts));
|
|
177
239
|
recordFile('index.ts', path.join(targetDir, 'index.ts'), buildIndex(capsuleName, pascalName, selectedFramework.ext, hasController));
|
|
178
240
|
recordFile(specFile, path.join(targetDir, specFile), buildComponentSpec(capsuleName, pascalName, hasController, runner));
|
|
179
241
|
|
|
180
|
-
|
|
181
|
-
recordFile('types/
|
|
242
|
+
const domainOpts = { description: capsuleDesc, framework: selectedFramework.id, template: explicitTemplate };
|
|
243
|
+
recordFile('types/props.d.ts', path.join(typesDir, 'props.d.ts'), buildPropsType(capsuleName, pascalName, domainOpts));
|
|
244
|
+
recordFile('types/state.d.ts', path.join(typesDir, 'state.d.ts'), buildStateType(capsuleName, pascalName, domainOpts));
|
|
182
245
|
recordFile('types/index.ts', path.join(typesDir, 'index.ts'), buildTypesIndex(['props', 'state']));
|
|
183
246
|
recordFile('types.d.ts', path.join(targetDir, 'types.d.ts'), "export * from './types/index';\n");
|
|
184
247
|
|
|
185
248
|
if (hasController) {
|
|
186
249
|
const controllerFile = `${capsuleName}.controller.ts`;
|
|
187
|
-
recordFile(controllerFile, path.join(targetDir, controllerFile), buildController(capsuleName, pascalName,
|
|
250
|
+
recordFile(controllerFile, path.join(targetDir, controllerFile), buildController(capsuleName, pascalName, domainOpts));
|
|
188
251
|
}
|
|
189
252
|
|
|
190
|
-
if (!isLean) {
|
|
253
|
+
if (!isLean && !wantsNoScss) {
|
|
191
254
|
const scssFile = `_${capsuleName}.scss`;
|
|
192
255
|
recordFile(scssFile, path.join(targetDir, scssFile), buildScss(capsuleName));
|
|
193
256
|
}
|
|
@@ -294,6 +357,27 @@ export const runGenerateWizard = async (rawArgs = []) => {
|
|
|
294
357
|
.replace(/^--(desc|description|prompt)=/, '');
|
|
295
358
|
const isDryRun = rawArgs.includes('--dry-run') || rawArgs.includes('-n');
|
|
296
359
|
|
|
360
|
+
const isBareOrMinimal = rawArgs.includes('--bare') || rawArgs.includes('--minimal');
|
|
361
|
+
const templateFlagMatch = (rawArgs.find((a) => a.startsWith('--template=')) || '').split('=')[1];
|
|
362
|
+
let templateArg = templateFlagMatch || null;
|
|
363
|
+
if (!templateArg && isBareOrMinimal) {
|
|
364
|
+
templateArg = 'minimal';
|
|
365
|
+
} else if (!templateArg && rawArgs.includes('--controls')) {
|
|
366
|
+
templateArg = 'controls';
|
|
367
|
+
} else if (!templateArg && rawArgs.includes('--canvas')) {
|
|
368
|
+
templateArg = 'canvas';
|
|
369
|
+
}
|
|
370
|
+
|
|
371
|
+
const cssFlagMatch = (rawArgs.find((a) => a.startsWith('--css=')) || '').split('=')[1];
|
|
372
|
+
let cssArg = cssFlagMatch || null;
|
|
373
|
+
if (!cssArg && rawArgs.includes('--no-scss')) {
|
|
374
|
+
cssArg = 'none';
|
|
375
|
+
}
|
|
376
|
+
|
|
377
|
+
const hasCompactFlag = rawArgs.includes('--compact');
|
|
378
|
+
const hasFlatFlag = rawArgs.includes('--flat');
|
|
379
|
+
const isCompact = hasCompactFlag || hasFlatFlag;
|
|
380
|
+
|
|
297
381
|
if (!rawName && !isYes) {
|
|
298
382
|
rawName = useGum
|
|
299
383
|
? gumInput('Capsule feature name (e.g. user-avatar, spark-kpi, auth-status):', 'user-avatar')
|
|
@@ -371,6 +455,9 @@ export const runGenerateWizard = async (rawArgs = []) => {
|
|
|
371
455
|
isLean,
|
|
372
456
|
cwd: process.cwd(),
|
|
373
457
|
desc: descArg,
|
|
458
|
+
template: templateArg,
|
|
459
|
+
css: cssArg,
|
|
460
|
+
compact: isCompact,
|
|
374
461
|
dryRun: isDryRun
|
|
375
462
|
});
|
|
376
463
|
} catch (err) {
|
package/cli/help.js
CHANGED
|
@@ -43,7 +43,7 @@ export const printHelp = () => {
|
|
|
43
43
|
lines.push(
|
|
44
44
|
`${BOLD}REACTIVE COMPOSABLE RULES${RESET}`,
|
|
45
45
|
` ${YELLOW}1.${RESET} Return plain objects with individual ref/computed. Never raw reactive().`,
|
|
46
|
-
` ${YELLOW}2.${RESET}
|
|
46
|
+
` ${YELLOW}2.${RESET} Structure returns into flat State, Status, and verb Actions (HOOK_SHAPE_CONTRACT).`,
|
|
47
47
|
` ${YELLOW}3.${RESET} Clean up side-effects automatically onScopeDispose().`,
|
|
48
48
|
'',
|
|
49
49
|
`${BOLD}COMMUNITY & SUPPORT${RESET}`,
|
package/cli/index.js
CHANGED
|
@@ -45,7 +45,7 @@ const loadProjectConfig = () => {
|
|
|
45
45
|
};
|
|
46
46
|
|
|
47
47
|
// ---------------------------------------------------------------------------
|
|
48
|
-
// Public API
|
|
48
|
+
// Public API: lazy proxy exports (zero startup cost for consumers)
|
|
49
49
|
// ---------------------------------------------------------------------------
|
|
50
50
|
|
|
51
51
|
export const runAudit = async (customDir = null, isCli = false) => {
|
|
@@ -67,22 +67,27 @@ export const patchFile = async (...a) => (await import('./patcher.js')).pa
|
|
|
67
67
|
export const runWriterCli = async (...a) => (await import('./patcher.js')).runWriterCli(...a);
|
|
68
68
|
export const writeFile = async (...a) => (await import('./patcher.js')).writeFile(...a);
|
|
69
69
|
export const runTeamCli = async (...a) => (await import('./team/index.js')).runTeamCli(...a);
|
|
70
|
+
export const runTrend = async (...a) => (await import('./trend.js')).runTrend(...a);
|
|
70
71
|
export const runPillarsWizard = async (...a) => (await import('./pillars-wizard.js')).runPillarsWizard(...a);
|
|
71
72
|
export { handleError, withErrorCatcher, publishIssue };
|
|
72
73
|
|
|
73
74
|
// ---------------------------------------------------------------------------
|
|
74
|
-
// Allowed commands guard (exits early
|
|
75
|
+
// Allowed commands guard (exits early before any heavy import)
|
|
75
76
|
// ---------------------------------------------------------------------------
|
|
76
77
|
|
|
77
78
|
export const ALLOWED_COMMANDS = new Set([
|
|
78
79
|
'search', 'q', 'query', 'find',
|
|
79
|
-
'read', 'view',
|
|
80
|
+
'read', 'view', 'r',
|
|
80
81
|
'patch', 'edit',
|
|
81
82
|
'write',
|
|
82
83
|
'generate', 'g', 'gen', 'capsule', 'add',
|
|
84
|
+
'explode', 'unpack',
|
|
83
85
|
'audit',
|
|
86
|
+
'trend', 'trends',
|
|
84
87
|
'verify', 'check:all',
|
|
85
|
-
'team', 'swarm', 'feed',
|
|
88
|
+
'team', 'swarm', 'feed', 'tokens', 'telemetry',
|
|
89
|
+
'project', 'coordinator',
|
|
90
|
+
'benchmark', 'ablation', 'memory',
|
|
86
91
|
'pillars', 'rules', 'config:pillars',
|
|
87
92
|
'mcp', 'mcp-server', 'server', 'install-mcp', 'setup-mcp',
|
|
88
93
|
'build', 'run', 'wrap',
|
|
@@ -100,23 +105,31 @@ export const ALLOWED_COMMANDS = new Set([
|
|
|
100
105
|
]);
|
|
101
106
|
|
|
102
107
|
// ---------------------------------------------------------------------------
|
|
103
|
-
// main
|
|
108
|
+
// main: thin orchestrator; real dispatch lives in cmd-router.js
|
|
104
109
|
// ---------------------------------------------------------------------------
|
|
105
110
|
|
|
111
|
+
const HELP_FLAGS = new Set(['help', '--help', '-h']);
|
|
112
|
+
const VERSION_FLAGS = new Set(['version', '--version', '-v']);
|
|
113
|
+
|
|
106
114
|
const main = async () => {
|
|
107
115
|
const firstArg = rawArgs[0];
|
|
108
116
|
|
|
109
|
-
|
|
117
|
+
const isHelpRequested = !firstArg || HELP_FLAGS.has(firstArg);
|
|
118
|
+
if (isHelpRequested) {
|
|
110
119
|
printHelp();
|
|
111
120
|
return;
|
|
112
121
|
}
|
|
113
122
|
|
|
114
|
-
|
|
123
|
+
const isVersionRequested = VERSION_FLAGS.has(firstArg);
|
|
124
|
+
if (isVersionRequested) {
|
|
115
125
|
process.stdout.write(`create-chemx v${getPackageVersion()}\n`);
|
|
116
126
|
return;
|
|
117
127
|
}
|
|
118
128
|
|
|
119
|
-
|
|
129
|
+
const isAllowedCommand = ALLOWED_COMMANDS.has(firstArg);
|
|
130
|
+
const isCapsuleCmd = isCapsulePrefix(firstArg);
|
|
131
|
+
const isCommandValid = isAllowedCommand || isCapsuleCmd;
|
|
132
|
+
if (!isCommandValid) {
|
|
120
133
|
process.stderr.write(`Unknown command "${firstArg}". Run --help for usage.\n`);
|
|
121
134
|
process.exit(1);
|
|
122
135
|
}
|
|
@@ -99,7 +99,7 @@ fi
|
|
|
99
99
|
|
|
100
100
|
if [ -n "\$AUDIT_BIN" ]; then
|
|
101
101
|
printf "%s[Chemical X] Verifying architectural health (Min Grade: %s, Min Score: %s)...%s\\n" "\$C_BLUE" "\$MIN_GRADE" "\$MIN_SCORE" "\$C_RESET"
|
|
102
|
-
if ! \$AUDIT_BIN audit --min-grade="\$MIN_GRADE" --min-score="\$MIN_SCORE" --non-interactive < /dev/null; then
|
|
102
|
+
if ! \$AUDIT_BIN audit --git --min-grade="\$MIN_GRADE" --min-score="\$MIN_SCORE" --non-interactive < /dev/null; then
|
|
103
103
|
printf "\\n%s%s[Chemical X] Commit Blocked: Architectural health verification failed%s\\n" "\$C_BOLD" "\$C_RED" "\$C_RESET"
|
|
104
104
|
printf "%s💡 Tip: Want crystalline drop-in templates? Run 'npm create chemx' or sponsor at https://github.com/sponsors/Chemical-X-Protocol%s\\n\\n" "\$C_CYAN" "\$C_RESET"
|
|
105
105
|
exit 1
|
package/cli/mcp/antigravity.js
CHANGED
|
@@ -8,8 +8,9 @@ export const buildMcpInstructions = () => {
|
|
|
8
8
|
'# Chemical X Protocol: Master MCP Gateway Guide (chemical-x / chemx)',
|
|
9
9
|
'',
|
|
10
10
|
'MASTER TOOL: "chemx" (chemical-x / chemx)',
|
|
11
|
-
'
|
|
12
|
-
'
|
|
11
|
+
'Provides all Chemical X operations through a single tool. This avoids requiring',
|
|
12
|
+
'separate approval for each sub-operation in MCP clients that gate tool access per-tool.',
|
|
13
|
+
'Pass the desired operation via the action parameter; see action: \'help\' for the full list.',
|
|
13
14
|
'',
|
|
14
15
|
'1. TESTING, BUILDS & VERIFICATION:',
|
|
15
16
|
' - chemx({ action: "test" }) or chemx({ command: "test" })',
|
package/cli/mcp/installer.js
CHANGED
|
@@ -48,10 +48,10 @@ export const resolveMcpServerCommand = (targetDir = '.') => {
|
|
|
48
48
|
const hasScopedChemx = fs.existsSync(localScopedChemx);
|
|
49
49
|
const hasInRepoStarterKit = fs.existsSync(inRepoStarterKit);
|
|
50
50
|
|
|
51
|
-
if (
|
|
51
|
+
if (hasInRepoStarterKit) {
|
|
52
52
|
return {
|
|
53
53
|
command: 'node',
|
|
54
|
-
args: ['./
|
|
54
|
+
args: ['./apps/chemical-x/starter-kit/cli/index.js', 'mcp']
|
|
55
55
|
};
|
|
56
56
|
}
|
|
57
57
|
|
|
@@ -62,16 +62,16 @@ export const resolveMcpServerCommand = (targetDir = '.') => {
|
|
|
62
62
|
};
|
|
63
63
|
}
|
|
64
64
|
|
|
65
|
-
if (
|
|
65
|
+
if (hasCreateChemx) {
|
|
66
66
|
return {
|
|
67
67
|
command: 'node',
|
|
68
|
-
args: ['./
|
|
68
|
+
args: ['./node_modules/create-chemx/cli/index.js', 'mcp']
|
|
69
69
|
};
|
|
70
70
|
}
|
|
71
71
|
|
|
72
72
|
return {
|
|
73
|
-
command: '
|
|
74
|
-
args: ['-y', 'chemx', 'mcp']
|
|
73
|
+
command: 'npm',
|
|
74
|
+
args: ['exec', '-y', '--', 'chemx', 'mcp']
|
|
75
75
|
};
|
|
76
76
|
};
|
|
77
77
|
|
|
@@ -173,7 +173,7 @@ export const installAntigravityMcpConfig = (targetDir = '.', options = {}) => {
|
|
|
173
173
|
|
|
174
174
|
const serverDef = localStarter
|
|
175
175
|
? { command: process.execPath, args: [localStarter, 'mcp'] }
|
|
176
|
-
: { command: '
|
|
176
|
+
: { command: 'npm', args: ['exec', '-y', '--', 'chemx', 'mcp'] };
|
|
177
177
|
|
|
178
178
|
try {
|
|
179
179
|
const existing = fs.existsSync(configFile) ? fs.readFileSync(configFile, 'utf-8') : '';
|
|
@@ -35,12 +35,12 @@ test('mergeMcpServerConfig: preserves existing servers while updating chemical-x
|
|
|
35
35
|
assert.strictEqual(parsed.mcpServers['chemical-x'].command, 'npx');
|
|
36
36
|
});
|
|
37
37
|
|
|
38
|
-
test('resolveMcpServerCommand: falls back to
|
|
38
|
+
test('resolveMcpServerCommand: falls back to npm exec when no local node_modules found', () => {
|
|
39
39
|
const tmpDir = fs.mkdtempSync(path.join(os.tmpdir(), 'chemx-cmd-test-'));
|
|
40
40
|
try {
|
|
41
41
|
const cmd = resolveMcpServerCommand(tmpDir);
|
|
42
|
-
assert.strictEqual(cmd.command, '
|
|
43
|
-
assert.deepStrictEqual(cmd.args, ['-y', 'chemx', 'mcp']);
|
|
42
|
+
assert.strictEqual(cmd.command, 'npm');
|
|
43
|
+
assert.deepStrictEqual(cmd.args, ['exec', '-y', '--', 'chemx', 'mcp']);
|
|
44
44
|
} finally {
|
|
45
45
|
fs.rmSync(tmpDir, { recursive: true, force: true });
|
|
46
46
|
}
|
package/cli/mcp/manifests.js
CHANGED
|
@@ -5,7 +5,7 @@
|
|
|
5
5
|
|
|
6
6
|
export const MASTER_MCP_TOOL = {
|
|
7
7
|
name: 'chemx',
|
|
8
|
-
description:
|
|
8
|
+
description: "Provides all Chemical X operations (search, generate, patch, audit, verify, team) through a single tool. This avoids requiring separate approval for each sub-operation in MCP clients that gate tool access per-tool. Pass the desired operation via the action parameter; see action: 'help' for the full list.",
|
|
9
9
|
inputSchema: {
|
|
10
10
|
type: 'object',
|
|
11
11
|
properties: {
|
|
@@ -32,7 +32,8 @@ export const MASTER_MCP_TOOL = {
|
|
|
32
32
|
'autofix',
|
|
33
33
|
'generate',
|
|
34
34
|
'patterns',
|
|
35
|
-
'issue'
|
|
35
|
+
'issue',
|
|
36
|
+
'project'
|
|
36
37
|
],
|
|
37
38
|
description: 'The Chemical X subsystem action to execute.'
|
|
38
39
|
},
|
package/cli/mcp/prompts.js
CHANGED
|
@@ -72,7 +72,7 @@ export const getMcpPrompt = async (name, args = {}) => {
|
|
|
72
72
|
'2. Molecular Capsule Limit: Maximum 100 lines per molecule capsule file.',
|
|
73
73
|
'3. Table-of-Contents Views: Top-level page views must be 10-20 line declarative templates assembling components via named slots.',
|
|
74
74
|
'4. Two-Stage Atomic Booleans: Break complex multi-clause conditionals into atomic single-concept booleans.',
|
|
75
|
-
'5. Composable Return Contracts:
|
|
75
|
+
'5. Composable Return Contracts: Classify hook/composable returns into flat State, Status, and verb-prefixed Actions buckets (HOOK_SHAPE_CONTRACT).',
|
|
76
76
|
'6. Co-located Types: Co-locate granular types/*.d.ts inside each capsule (< 100 lines). Avoid type monoliths.',
|
|
77
77
|
'7. Zero synthetic or mock data: Return live data or explicit empty states.',
|
|
78
78
|
`8. Framework: Calibrate bindings for ${framework}.`,
|
package/cli/mcp/server.js
CHANGED
|
@@ -4,6 +4,7 @@ import path from 'node:path';
|
|
|
4
4
|
import { MCP_TOOLS, executeMcpTool } from './tools.js';
|
|
5
5
|
import { MCP_RESOURCES, readMcpResource } from './resources.js';
|
|
6
6
|
import { MCP_PROMPTS, getMcpPrompt } from './prompts.js';
|
|
7
|
+
import { warmIndexDb } from '../search-db.js';
|
|
7
8
|
|
|
8
9
|
export const SERVER_INFO = {
|
|
9
10
|
name: 'chemical-x-mcp',
|
|
@@ -34,6 +35,7 @@ export const createMcpHandler = (options = {}) => {
|
|
|
34
35
|
} else if (Array.isArray(params?.workspaceFolders) && params.workspaceFolders[0]?.uri?.startsWith('file://')) {
|
|
35
36
|
cwd = new URL(params.workspaceFolders[0].uri).pathname;
|
|
36
37
|
}
|
|
38
|
+
try { warmIndexDb(cwd); } catch {}
|
|
37
39
|
return {
|
|
38
40
|
jsonrpc: '2.0',
|
|
39
41
|
id,
|
|
@@ -0,0 +1,95 @@
|
|
|
1
|
+
import fs from 'node:fs';
|
|
2
|
+
import path from 'node:path';
|
|
3
|
+
import { runAudit as executeAstAudit, auditFile } from '../audit.js';
|
|
4
|
+
import {
|
|
5
|
+
buildMasterPrompt,
|
|
6
|
+
buildGradeFPrompt,
|
|
7
|
+
buildGradeDPrompt,
|
|
8
|
+
buildGradeCPrompt,
|
|
9
|
+
buildGradeBPrompt,
|
|
10
|
+
buildAiSlopPrompt,
|
|
11
|
+
buildHotspotsPrompt
|
|
12
|
+
} from '../audit/prompts.js';
|
|
13
|
+
import { syncSearchIndex, syncViolationsIndex, recordAuditSnapshot } from '../search.js';
|
|
14
|
+
import { resolveTargetCwd } from './tools-search.js';
|
|
15
|
+
|
|
16
|
+
export const handleAudit = (args = {}, cwd = process.cwd()) => {
|
|
17
|
+
const baseCwd = resolveTargetCwd(cwd);
|
|
18
|
+
const rawTarget = args.path || args.dir || (fs.existsSync(path.resolve(baseCwd, 'src')) ? 'src' : '.');
|
|
19
|
+
const resolvedTarget = path.isAbsolute(rawTarget) ? rawTarget : path.resolve(baseCwd, rawTarget);
|
|
20
|
+
const isFile = fs.existsSync(resolvedTarget) && fs.statSync(resolvedTarget).isFile();
|
|
21
|
+
|
|
22
|
+
if (isFile) {
|
|
23
|
+
const relPath = path.relative(baseCwd, resolvedTarget);
|
|
24
|
+
const violations = auditFile(resolvedTarget, relPath);
|
|
25
|
+
return {
|
|
26
|
+
type: 'file',
|
|
27
|
+
target: relPath,
|
|
28
|
+
violationCount: violations.length,
|
|
29
|
+
violations
|
|
30
|
+
};
|
|
31
|
+
}
|
|
32
|
+
|
|
33
|
+
const options = {
|
|
34
|
+
cwd: baseCwd,
|
|
35
|
+
model: args.model || 'blended',
|
|
36
|
+
outputFile: null
|
|
37
|
+
};
|
|
38
|
+
|
|
39
|
+
const report = executeAstAudit(resolvedTarget, options);
|
|
40
|
+
|
|
41
|
+
try {
|
|
42
|
+
const syncRes = syncSearchIndex(resolvedTarget, baseCwd);
|
|
43
|
+
if (syncRes?.db) {
|
|
44
|
+
syncViolationsIndex(syncRes.db, report.violations);
|
|
45
|
+
recordAuditSnapshot(syncRes.db, report);
|
|
46
|
+
}
|
|
47
|
+
} catch (syncError) {
|
|
48
|
+
process.stderr.write(`[chemx] Search index sync bypassed: ${syncError?.message || String(syncError)}\n`);
|
|
49
|
+
}
|
|
50
|
+
|
|
51
|
+
const isSevereViolation = (v) => v.severity === 'CRITICAL' || v.severity === 'HIGH';
|
|
52
|
+
const hasCriticalOrHigh = report.violations.some(isSevereViolation);
|
|
53
|
+
const isStrictFail = Boolean(args.strict) && report.violations.length > 0;
|
|
54
|
+
const isScoreFail = typeof args.minScore === 'number' && report.health.score < args.minScore;
|
|
55
|
+
const isPassing = !isStrictFail && !isScoreFail && !hasCriticalOrHigh;
|
|
56
|
+
|
|
57
|
+
return {
|
|
58
|
+
type: 'directory',
|
|
59
|
+
target: rawTarget,
|
|
60
|
+
health: report.health,
|
|
61
|
+
metrics: report.metrics,
|
|
62
|
+
aiSlop: report.aiSlop,
|
|
63
|
+
hotspots: report.hotspots,
|
|
64
|
+
totalViolations: report.totalViolations,
|
|
65
|
+
violations: report.violations,
|
|
66
|
+
contextAnalysis: report.contextAnalysis,
|
|
67
|
+
isPassing
|
|
68
|
+
};
|
|
69
|
+
};
|
|
70
|
+
|
|
71
|
+
export const handleGetRefactorPrompt = (args = {}, cwd = process.cwd()) => {
|
|
72
|
+
const targetDir = args.dir || (fs.existsSync(path.resolve(cwd, 'src')) ? 'src' : '.');
|
|
73
|
+
const scope = args.scope || 'master';
|
|
74
|
+
const report = executeAstAudit(targetDir, {});
|
|
75
|
+
|
|
76
|
+
const PROMPT_BUILDERS = {
|
|
77
|
+
'grade-f': buildGradeFPrompt,
|
|
78
|
+
'grade-d': buildGradeDPrompt,
|
|
79
|
+
'grade-c': buildGradeCPrompt,
|
|
80
|
+
'grade-b': buildGradeBPrompt,
|
|
81
|
+
'ai-slop': buildAiSlopPrompt,
|
|
82
|
+
'hotspots': buildHotspotsPrompt,
|
|
83
|
+
'master': buildMasterPrompt
|
|
84
|
+
};
|
|
85
|
+
|
|
86
|
+
const builder = Object.prototype.hasOwnProperty.call(PROMPT_BUILDERS, scope)
|
|
87
|
+
? PROMPT_BUILDERS[scope]
|
|
88
|
+
: buildMasterPrompt;
|
|
89
|
+
|
|
90
|
+
return {
|
|
91
|
+
targetDir,
|
|
92
|
+
scope,
|
|
93
|
+
prompt: builder(report) || 'No violations found for the requested scope.'
|
|
94
|
+
};
|
|
95
|
+
};
|
|
@@ -0,0 +1,62 @@
|
|
|
1
|
+
import { createCapsuleFiles } from '../generator.js';
|
|
2
|
+
import { openIndexDb } from '../search-schema.js';
|
|
3
|
+
import { fetchScoreTrends, formatTrendReport, renderSparkline } from '../trend.js';
|
|
4
|
+
import { resolveTargetCwd } from './tools-search.js';
|
|
5
|
+
|
|
6
|
+
export const handleGenerateCapsule = (args = {}, cwd = process.cwd()) => {
|
|
7
|
+
const { name, framework, tier = 'm', targetDir = null, lean = false, desc = '', description = '', dryRun = false } = args;
|
|
8
|
+
|
|
9
|
+
const hasName = Boolean(name && name.trim());
|
|
10
|
+
const hasValidFramework = Boolean(framework && ['react', 'vue', 'svelte'].includes(framework.toLowerCase()));
|
|
11
|
+
const canGenerate = hasName && hasValidFramework;
|
|
12
|
+
|
|
13
|
+
if (!canGenerate) {
|
|
14
|
+
throw new Error('chemx_generate_capsule requires "name" and "framework" (react, vue, svelte).');
|
|
15
|
+
}
|
|
16
|
+
|
|
17
|
+
const result = createCapsuleFiles({
|
|
18
|
+
name: name.trim(),
|
|
19
|
+
framework: framework.toLowerCase(),
|
|
20
|
+
tier: tier.toLowerCase(),
|
|
21
|
+
targetParent: targetDir,
|
|
22
|
+
isLean: Boolean(lean),
|
|
23
|
+
cwd,
|
|
24
|
+
desc: desc || description,
|
|
25
|
+
dryRun: Boolean(dryRun)
|
|
26
|
+
});
|
|
27
|
+
|
|
28
|
+
return {
|
|
29
|
+
success: true,
|
|
30
|
+
dryRun: result.dryRun,
|
|
31
|
+
capsuleName: result.capsuleName,
|
|
32
|
+
pascalName: result.pascalName,
|
|
33
|
+
framework: result.framework,
|
|
34
|
+
tier: result.tier,
|
|
35
|
+
targetDir: result.targetDir,
|
|
36
|
+
relativeDir: result.relativeDir,
|
|
37
|
+
filesCreated: result.filesCreated,
|
|
38
|
+
previews: result.previews
|
|
39
|
+
};
|
|
40
|
+
};
|
|
41
|
+
|
|
42
|
+
export const handleChemxTrend = async (args = {}, cwd = process.cwd()) => {
|
|
43
|
+
const targetCwd = resolveTargetCwd(args.cwd || cwd);
|
|
44
|
+
const db = openIndexDb(targetCwd);
|
|
45
|
+
const limit = args.limit || 10;
|
|
46
|
+
const snapshots = fetchScoreTrends(db, limit);
|
|
47
|
+
if (args.json) {
|
|
48
|
+
const scores = snapshots.map((s) => s.score);
|
|
49
|
+
const hasScores = snapshots.length > 0;
|
|
50
|
+
const latestScore = hasScores ? snapshots[snapshots.length - 1].score : null;
|
|
51
|
+
const hasDelta = snapshots.length >= 2;
|
|
52
|
+
const delta = hasDelta ? snapshots[snapshots.length - 1].score - snapshots[0].score : 0;
|
|
53
|
+
return {
|
|
54
|
+
count: snapshots.length,
|
|
55
|
+
sparkline: renderSparkline(scores),
|
|
56
|
+
latestScore,
|
|
57
|
+
delta,
|
|
58
|
+
snapshots
|
|
59
|
+
};
|
|
60
|
+
}
|
|
61
|
+
return formatTrendReport(snapshots);
|
|
62
|
+
};
|