@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.
- package/README.md +70 -10
- package/blueprints/atoms/a-button.svelte +30 -0
- package/blueprints/atoms/a-button.tsx +36 -0
- package/blueprints/molecule-capsule/m-chemx-badge/m-chemx-badge.svelte +35 -0
- package/blueprints/molecule-capsule/m-sample-card.spec.ts +10 -4
- package/blueprints/molecule-capsule/m-sample-card.svelte +58 -0
- package/blueprints/molecule-capsule/m-sample-card.tsx +3 -3
- package/blueprints/molecule-capsule/m-sample-card.vue +60 -0
- package/blueprints/view-template.svelte +18 -0
- package/blueprints/view-template.vue +18 -0
- package/blueprints/workflows/chemx-audit.yml +36 -0
- package/cli/audit/ast-visitors.js +25 -13
- package/cli/audit/csharp-analyzer.js +80 -0
- package/cli/audit/extended-text-patterns.js +11 -2
- package/cli/audit/pattern-detector.js +5 -3
- package/cli/audit/pattern-detector.spec.js +17 -0
- package/cli/audit/reporter-grades.js +1 -0
- package/cli/audit/reporter-markdown.js +2 -0
- package/cli/audit/reporter-sections.js +3 -0
- package/cli/audit/rules-registry.js +27 -0
- package/cli/audit/rules.js +14 -3
- package/cli/audit/rules.spec.js +27 -0
- package/cli/audit/structural-weight-evaluator.js +121 -0
- package/cli/audit/structural-weight.js +92 -0
- package/cli/audit/structural-weight.spec.js +116 -0
- package/cli/audit-preflight-scope.js +4 -1
- package/cli/audit.js +9 -10
- package/cli/commands/cmd-audit.js +1 -1
- package/cli/commands/cmd-router.js +17 -2
- package/cli/commands-schema.js +36 -0
- package/cli/config/config.spec.js +51 -0
- package/cli/config/index.js +37 -0
- package/cli/config/loader.js +83 -0
- package/cli/config/profiles.js +56 -0
- package/cli/config.spec.js +1 -0
- package/cli/create.js +21 -8
- package/cli/create.spec.js +91 -0
- package/cli/generator-help.js +48 -0
- package/cli/generator-indexer.js +41 -0
- package/cli/generator.js +8 -43
- package/cli/generator.spec.js +29 -0
- package/cli/help.d.ts +2 -0
- package/cli/help.js +64 -0
- package/cli/help.spec.js +54 -1
- package/cli/installer-templates.js +8 -3
- package/cli/languages.js +122 -0
- package/cli/languages.spec.js +44 -0
- package/cli/mcp/tools-patch.js +7 -5
- package/cli/mcp/tools-team-tasks.js +56 -10
- package/cli/polyglot.spec.js +111 -0
- package/cli/reader-shorthand.spec.js +2 -2
- package/cli/scaffold-frameworks.js +133 -0
- package/cli/scaffold.js +102 -41
- package/cli/search-ast.js +41 -9
- package/cli/search-db.js +2 -8
- package/cli/search-queries-semantic.js +28 -9
- package/cli/search-tokenizer.js +52 -0
- package/cli/search.js +2 -5
- package/cli/search.spec.js +51 -3
- package/cli/team/team-adversarial-locks.spec.js +71 -0
- package/cli/team/team-commands-lock.js +64 -0
- package/cli/team/team-commands-vds.js +70 -0
- package/cli/team/team-commands.js +86 -24
- package/cli/team/team-db-lock-promotion.js +29 -18
- package/cli/team/team-db-locks.js +54 -43
- package/cli/team/team-db-task-helpers.js +18 -0
- package/cli/team/team-db-tasks.js +45 -51
- package/cli/team/team-db-transaction.js +52 -0
- package/cli/team/team-flags.js +4 -1
- package/cli/team/team-format.js +148 -0
- package/cli/team/team-memory.js +99 -13
- package/cli/team/team-memory.spec.js +49 -0
- package/cli/team/team-multiprocess-concurrency.spec.js +193 -0
- package/cli/team/team-release-train.js +65 -0
- package/cli/team/team-release-train.spec.js +91 -0
- package/cli/team/team-schema-vds.js +39 -0
- package/cli/team/team-schema.js +21 -23
- package/cli/team/team-tasks-asana.spec.js +60 -0
- package/cli/team/team-triage.js +12 -0
- package/cli/team/team-vds.js +88 -0
- package/cli/team/team-vds.spec.js +125 -0
- package/cli/team/team-verification-gate.spec.js +27 -0
- package/cli/theme.js +1 -0
- package/cli/ui-actions-vds.js +48 -0
- package/cli/ui-actions.js +1 -0
- package/cli/ui-client-api.js +8 -0
- package/cli/ui-client-script.js +33 -29
- package/cli/ui-dev-watcher.js +61 -0
- package/cli/ui-direct-routes.spec.js +55 -0
- package/cli/ui-handlers.js +6 -7
- package/cli/ui-index.html +416 -26
- package/cli/ui-kanban.spec.js +11 -0
- package/cli/ui-server-routes.js +14 -6
- package/cli/ui-server.js +17 -21
- package/cli/ui-sse.js +23 -10
- package/cli/ui-sse.spec.js +26 -0
- package/cli/ui-styles.js +20 -4
- package/cli/ui-template-kanban.js +23 -27
- package/cli/ui-template-task-sheet.js +87 -0
- package/cli/ui-template-vds-badges.js +34 -0
- package/cli/ui-template.js +13 -10
- package/cli/verify-helpers.js +192 -0
- package/cli/verify.js +132 -176
- package/cli/verify.spec.js +96 -0
- package/package.json +8 -4
- package/scripts/pre-commit.sh +12 -3
- package/docs/CHANGELOG.md +0 -332
package/cli/help.js
CHANGED
|
@@ -54,3 +54,67 @@ export const printHelp = () => {
|
|
|
54
54
|
|
|
55
55
|
process.stdout.write(lines.join('\n'));
|
|
56
56
|
};
|
|
57
|
+
|
|
58
|
+
export const printInitHelp = () => {
|
|
59
|
+
renderBanner('Chemical X: In-Repo Capsule Drop-in (chemx init)');
|
|
60
|
+
|
|
61
|
+
const BOLD = '\x1b[1m';
|
|
62
|
+
const CYAN = '\x1b[36m';
|
|
63
|
+
const RESET = '\x1b[0m';
|
|
64
|
+
|
|
65
|
+
const lines = [
|
|
66
|
+
`${BOLD}USAGE${RESET}`,
|
|
67
|
+
` ${CYAN}npx chemx init${RESET} [directory] [options]`,
|
|
68
|
+
'',
|
|
69
|
+
`${BOLD}DESCRIPTION${RESET}`,
|
|
70
|
+
' Unpack Chemical X blueprints and molecular architecture drop-in files',
|
|
71
|
+
' into an existing codebase (defaults to src/chemical-x).',
|
|
72
|
+
'',
|
|
73
|
+
`${BOLD}OPTIONS${RESET}`,
|
|
74
|
+
` ${CYAN}-h, --help${RESET} Show this help message`,
|
|
75
|
+
` ${CYAN}--license=<key>${RESET} Provide commercial license key for enterprise starter kit assets`,
|
|
76
|
+
'',
|
|
77
|
+
`${BOLD}EXAMPLES${RESET}`,
|
|
78
|
+
` ${CYAN}npx chemx init${RESET}`,
|
|
79
|
+
` ${CYAN}npx chemx init src/chemical-x${RESET}`,
|
|
80
|
+
` ${CYAN}npx chemx init packages/ui/src/modules${RESET}`,
|
|
81
|
+
''
|
|
82
|
+
];
|
|
83
|
+
|
|
84
|
+
process.stdout.write(lines.join('\n'));
|
|
85
|
+
};
|
|
86
|
+
|
|
87
|
+
export const printScaffoldHelp = () => {
|
|
88
|
+
renderBanner('Chemical X: Project Scaffolder (npm create chemx)');
|
|
89
|
+
|
|
90
|
+
const BOLD = '\x1b[1m';
|
|
91
|
+
const CYAN = '\x1b[36m';
|
|
92
|
+
const RESET = '\x1b[0m';
|
|
93
|
+
|
|
94
|
+
const lines = [
|
|
95
|
+
`${BOLD}USAGE${RESET}`,
|
|
96
|
+
` ${CYAN}npm create chemx${RESET} [directory] [options]`,
|
|
97
|
+
` ${CYAN}npx create-chemx${RESET} [directory] [options]`,
|
|
98
|
+
` ${CYAN}npx chemx create${RESET} [directory] [options]`,
|
|
99
|
+
'',
|
|
100
|
+
`${BOLD}DESCRIPTION${RESET}`,
|
|
101
|
+
' Scaffold a complete new Chemical X Molecular Architecture application.',
|
|
102
|
+
'',
|
|
103
|
+
`${BOLD}OPTIONS${RESET}`,
|
|
104
|
+
` ${CYAN}--framework=<id>${RESET} Framework flavor: react (default), vue, svelte`,
|
|
105
|
+
` ${CYAN}--install${RESET} Auto-install dependencies after scaffolding`,
|
|
106
|
+
` ${CYAN}--skip-install${RESET} Skip installing dependencies`,
|
|
107
|
+
` ${CYAN}--yes, -y${RESET} Skip interactive prompts and scaffold Community Edition immediately`,
|
|
108
|
+
` ${CYAN}--headless${RESET} Run in headless mode for CI/CD and AI agent automation`,
|
|
109
|
+
` ${CYAN}-h, --help${RESET} Show this help message`,
|
|
110
|
+
` ${CYAN}-v, --version${RESET} Show version number`,
|
|
111
|
+
'',
|
|
112
|
+
`${BOLD}EXAMPLES${RESET}`,
|
|
113
|
+
` ${CYAN}npm create chemx my-molecular-app --framework=react${RESET}`,
|
|
114
|
+
` ${CYAN}npx create-chemx my-vue-app --framework=vue --yes${RESET}`,
|
|
115
|
+
` ${CYAN}npx chemx create my-app --framework=svelte --install${RESET}`,
|
|
116
|
+
''
|
|
117
|
+
];
|
|
118
|
+
|
|
119
|
+
process.stdout.write(lines.join('\n'));
|
|
120
|
+
};
|
package/cli/help.spec.js
CHANGED
|
@@ -4,7 +4,7 @@ import { spawnSync } from 'node:child_process';
|
|
|
4
4
|
import fs from 'node:fs';
|
|
5
5
|
import path from 'node:path';
|
|
6
6
|
import { COMMANDS_SCHEMA } from './commands-schema.js';
|
|
7
|
-
import { printHelp } from './help.js';
|
|
7
|
+
import { printHelp, printInitHelp, printScaffoldHelp } from './help.js';
|
|
8
8
|
|
|
9
9
|
test('commands-schema: contains all 9 core chemical-x CLI commands', () => {
|
|
10
10
|
const expected = ['search', 'read', 'patch', 'mcp', 'build', 'audit', 'generate', 'team', 'verify'];
|
|
@@ -54,3 +54,56 @@ test('cli: unknown command exits immediately with code 1 and error message', ()
|
|
|
54
54
|
);
|
|
55
55
|
}
|
|
56
56
|
});
|
|
57
|
+
|
|
58
|
+
test('help: printInitHelp and printScaffoldHelp render without throwing', () => {
|
|
59
|
+
assert.doesNotThrow(() => {
|
|
60
|
+
printInitHelp();
|
|
61
|
+
});
|
|
62
|
+
assert.doesNotThrow(() => {
|
|
63
|
+
printScaffoldHelp();
|
|
64
|
+
});
|
|
65
|
+
});
|
|
66
|
+
|
|
67
|
+
test('cli: chemx init --help and -h display usage and do not scaffold /--help/ on disk', () => {
|
|
68
|
+
const cliPath = path.resolve('cli/index.js');
|
|
69
|
+
const helpFlags = ['--help', '-h', 'help'];
|
|
70
|
+
|
|
71
|
+
for (const flag of helpFlags) {
|
|
72
|
+
const res = spawnSync(process.execPath, [cliPath, 'init', flag], {
|
|
73
|
+
encoding: 'utf8',
|
|
74
|
+
timeout: 5000
|
|
75
|
+
});
|
|
76
|
+
|
|
77
|
+
assert.strictEqual(res.status, 0, `chemx init ${flag} should exit with code 0`);
|
|
78
|
+
assert.ok(
|
|
79
|
+
res.stdout.includes('chemx init') && res.stdout.includes('USAGE'),
|
|
80
|
+
`chemx init ${flag} output should include usage instructions`
|
|
81
|
+
);
|
|
82
|
+
assert.strictEqual(
|
|
83
|
+
fs.existsSync(path.resolve(flag)),
|
|
84
|
+
false,
|
|
85
|
+
`chemx init ${flag} must not create directory "${flag}" on disk`
|
|
86
|
+
);
|
|
87
|
+
}
|
|
88
|
+
});
|
|
89
|
+
|
|
90
|
+
test('cli: chemx create --help and scaffold -h display usage', () => {
|
|
91
|
+
const cliPath = path.resolve('cli/index.js');
|
|
92
|
+
const commands = [
|
|
93
|
+
['create', '--help'],
|
|
94
|
+
['scaffold', '-h']
|
|
95
|
+
];
|
|
96
|
+
|
|
97
|
+
for (const [cmd, flag] of commands) {
|
|
98
|
+
const res = spawnSync(process.execPath, [cliPath, cmd, flag], {
|
|
99
|
+
encoding: 'utf8',
|
|
100
|
+
timeout: 5000
|
|
101
|
+
});
|
|
102
|
+
|
|
103
|
+
assert.strictEqual(res.status, 0, `chemx ${cmd} ${flag} should exit with code 0`);
|
|
104
|
+
assert.ok(
|
|
105
|
+
res.stdout.includes('USAGE') && (res.stdout.includes('create chemx') || res.stdout.includes('chemx create')),
|
|
106
|
+
`chemx ${cmd} ${flag} output should include scaffolder usage instructions`
|
|
107
|
+
);
|
|
108
|
+
}
|
|
109
|
+
});
|
|
@@ -98,15 +98,20 @@ elif command -v npx >/dev/null 2>&1; then
|
|
|
98
98
|
fi
|
|
99
99
|
|
|
100
100
|
if [ -n "\$AUDIT_BIN" ]; then
|
|
101
|
-
|
|
102
|
-
|
|
101
|
+
if [ "\$CHEMX_VERBOSE" = "1" ]; then
|
|
102
|
+
printf "%s[Chemical X] Verifying architectural health (Min Grade: %s, Min Score: %s)...%s\\n" "\$C_BLUE" "\$MIN_GRADE" "\$MIN_SCORE" "\$C_RESET"
|
|
103
|
+
fi
|
|
104
|
+
if ! AUDIT_OUT=\$(eval "\$AUDIT_BIN audit --git --min-grade=\$MIN_GRADE --min-score=\$MIN_SCORE --non-interactive" < /dev/null 2>&1); then
|
|
103
105
|
printf "\\n%s%s[Chemical X] Commit Blocked: Architectural health verification failed%s\\n" "\$C_BOLD" "\$C_RED" "\$C_RESET"
|
|
106
|
+
printf "%s\\n\\n" "\$AUDIT_OUT"
|
|
104
107
|
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
108
|
exit 1
|
|
106
109
|
fi
|
|
107
110
|
fi
|
|
108
111
|
|
|
109
|
-
|
|
112
|
+
if [ "\$CHEMX_VERBOSE" = "1" ]; then
|
|
113
|
+
printf "%s✔ [Chemical X] Pre-commit architectural guardrails passed.%s\\n" "\$C_GREEN" "\$C_RESET"
|
|
114
|
+
fi
|
|
110
115
|
exit 0
|
|
111
116
|
`;
|
|
112
117
|
|
package/cli/languages.js
ADDED
|
@@ -0,0 +1,122 @@
|
|
|
1
|
+
/**
|
|
2
|
+
* Chemical X Language Registry
|
|
3
|
+
* Central authority for language classification, file extension routing, and parser selection.
|
|
4
|
+
*/
|
|
5
|
+
import path from 'node:path';
|
|
6
|
+
|
|
7
|
+
export const LANGUAGE_DEFINITIONS = {
|
|
8
|
+
typescript: {
|
|
9
|
+
id: 'typescript',
|
|
10
|
+
name: 'TypeScript',
|
|
11
|
+
extensions: new Set(['.ts', '.tsx']),
|
|
12
|
+
parser: 'babel',
|
|
13
|
+
commentPrefix: '//',
|
|
14
|
+
blockComment: { start: '/*', end: '*/' }
|
|
15
|
+
},
|
|
16
|
+
javascript: {
|
|
17
|
+
id: 'javascript',
|
|
18
|
+
name: 'JavaScript',
|
|
19
|
+
extensions: new Set(['.js', '.jsx', '.mjs', '.cjs']),
|
|
20
|
+
parser: 'babel',
|
|
21
|
+
commentPrefix: '//',
|
|
22
|
+
blockComment: { start: '/*', end: '*/' }
|
|
23
|
+
},
|
|
24
|
+
vue: {
|
|
25
|
+
id: 'vue',
|
|
26
|
+
name: 'Vue SFC',
|
|
27
|
+
extensions: new Set(['.vue']),
|
|
28
|
+
parser: 'babel',
|
|
29
|
+
commentPrefix: '//',
|
|
30
|
+
blockComment: { start: '/*', end: '*/' }
|
|
31
|
+
},
|
|
32
|
+
svelte: {
|
|
33
|
+
id: 'svelte',
|
|
34
|
+
name: 'Svelte',
|
|
35
|
+
extensions: new Set(['.svelte']),
|
|
36
|
+
parser: 'babel',
|
|
37
|
+
commentPrefix: '//',
|
|
38
|
+
blockComment: { start: '/*', end: '*/' }
|
|
39
|
+
},
|
|
40
|
+
csharp: {
|
|
41
|
+
id: 'csharp',
|
|
42
|
+
name: 'C# / .NET',
|
|
43
|
+
extensions: new Set(['.cs']),
|
|
44
|
+
parser: 'csharp',
|
|
45
|
+
commentPrefix: '//',
|
|
46
|
+
blockComment: { start: '/*', end: '*/' }
|
|
47
|
+
},
|
|
48
|
+
python: {
|
|
49
|
+
id: 'python',
|
|
50
|
+
name: 'Python',
|
|
51
|
+
extensions: new Set(['.py']),
|
|
52
|
+
parser: 'python',
|
|
53
|
+
commentPrefix: '#',
|
|
54
|
+
blockComment: { start: '"""', end: '"""' }
|
|
55
|
+
},
|
|
56
|
+
go: {
|
|
57
|
+
id: 'go',
|
|
58
|
+
name: 'Go',
|
|
59
|
+
extensions: new Set(['.go']),
|
|
60
|
+
parser: 'go',
|
|
61
|
+
commentPrefix: '//',
|
|
62
|
+
blockComment: { start: '/*', end: '*/' }
|
|
63
|
+
},
|
|
64
|
+
rust: {
|
|
65
|
+
id: 'rust',
|
|
66
|
+
name: 'Rust',
|
|
67
|
+
extensions: new Set(['.rs']),
|
|
68
|
+
parser: 'rust',
|
|
69
|
+
commentPrefix: '//',
|
|
70
|
+
blockComment: { start: '/*', end: '*/' }
|
|
71
|
+
},
|
|
72
|
+
jvm: {
|
|
73
|
+
id: 'jvm',
|
|
74
|
+
name: 'Java / Kotlin',
|
|
75
|
+
extensions: new Set(['.java', '.kt']),
|
|
76
|
+
parser: 'jvm',
|
|
77
|
+
commentPrefix: '//',
|
|
78
|
+
blockComment: { start: '/*', end: '*/' }
|
|
79
|
+
}
|
|
80
|
+
};
|
|
81
|
+
|
|
82
|
+
const ALL_EXTENSIONS = new Set(
|
|
83
|
+
Object.values(LANGUAGE_DEFINITIONS).flatMap((lang) => Array.from(lang.extensions))
|
|
84
|
+
);
|
|
85
|
+
|
|
86
|
+
const EXCLUDED_NAME_PATTERNS = ['.min.'];
|
|
87
|
+
|
|
88
|
+
export const getLanguageByExtension = (ext) => {
|
|
89
|
+
const normalized = ext.toLowerCase();
|
|
90
|
+
for (const lang of Object.values(LANGUAGE_DEFINITIONS)) {
|
|
91
|
+
if (lang.extensions.has(normalized)) return lang;
|
|
92
|
+
}
|
|
93
|
+
return null;
|
|
94
|
+
};
|
|
95
|
+
|
|
96
|
+
export const getLanguageForFile = (filePath) => {
|
|
97
|
+
const ext = path.extname(filePath);
|
|
98
|
+
return getLanguageByExtension(ext);
|
|
99
|
+
};
|
|
100
|
+
|
|
101
|
+
export const isSourceFile = (name, options = {}) => {
|
|
102
|
+
const { includeTests = true } = options;
|
|
103
|
+
const ext = path.extname(name).toLowerCase();
|
|
104
|
+
if (!ALL_EXTENSIONS.has(ext)) return false;
|
|
105
|
+
if (name.endsWith('.d.ts')) return false;
|
|
106
|
+
|
|
107
|
+
if (EXCLUDED_NAME_PATTERNS.some((pat) => name.includes(pat))) {
|
|
108
|
+
return false;
|
|
109
|
+
}
|
|
110
|
+
|
|
111
|
+
if (!includeTests) {
|
|
112
|
+
const isTest = name.includes('.test.') || name.includes('.spec.') || name.endsWith('Test.cs') || name.endsWith('Tests.cs');
|
|
113
|
+
if (isTest) return false;
|
|
114
|
+
}
|
|
115
|
+
|
|
116
|
+
return true;
|
|
117
|
+
};
|
|
118
|
+
|
|
119
|
+
export const isBabelParsable = (filePath) => {
|
|
120
|
+
const lang = getLanguageForFile(filePath);
|
|
121
|
+
return lang?.parser === 'babel';
|
|
122
|
+
};
|
|
@@ -0,0 +1,44 @@
|
|
|
1
|
+
import test from 'node:test';
|
|
2
|
+
import assert from 'node:assert/strict';
|
|
3
|
+
import {
|
|
4
|
+
isSourceFile,
|
|
5
|
+
getLanguageForFile,
|
|
6
|
+
isBabelParsable,
|
|
7
|
+
LANGUAGE_DEFINITIONS
|
|
8
|
+
} from './languages.js';
|
|
9
|
+
|
|
10
|
+
test('languages: recognizes polyglot source extensions', () => {
|
|
11
|
+
assert.equal(isSourceFile('Program.cs'), true);
|
|
12
|
+
assert.equal(isSourceFile('main.py'), true);
|
|
13
|
+
assert.equal(isSourceFile('server.go'), true);
|
|
14
|
+
assert.equal(isSourceFile('lib.rs'), true);
|
|
15
|
+
assert.equal(isSourceFile('App.tsx'), true);
|
|
16
|
+
assert.equal(isSourceFile('Component.vue'), true);
|
|
17
|
+
assert.equal(isSourceFile('Widget.svelte'), true);
|
|
18
|
+
assert.equal(isSourceFile('Service.java'), true);
|
|
19
|
+
});
|
|
20
|
+
|
|
21
|
+
test('languages: rejects minified and declaration files', () => {
|
|
22
|
+
assert.equal(isSourceFile('bundle.min.js'), false);
|
|
23
|
+
assert.equal(isSourceFile('types.d.ts'), false);
|
|
24
|
+
assert.equal(isSourceFile('readme.md'), false);
|
|
25
|
+
assert.equal(isSourceFile('data.json'), false);
|
|
26
|
+
});
|
|
27
|
+
|
|
28
|
+
test('languages: resolves parser capabilities correctly', () => {
|
|
29
|
+
assert.equal(isBabelParsable('App.tsx'), true);
|
|
30
|
+
assert.equal(isBabelParsable('Component.vue'), true);
|
|
31
|
+
assert.equal(isBabelParsable('Program.cs'), false);
|
|
32
|
+
assert.equal(isBabelParsable('main.py'), false);
|
|
33
|
+
assert.equal(isBabelParsable('server.go'), false);
|
|
34
|
+
});
|
|
35
|
+
|
|
36
|
+
test('languages: resolves language metadata', () => {
|
|
37
|
+
const cs = getLanguageForFile('src/Services/ConsentService.cs');
|
|
38
|
+
assert.equal(cs.id, 'csharp');
|
|
39
|
+
assert.equal(cs.parser, 'csharp');
|
|
40
|
+
|
|
41
|
+
const py = getLanguageForFile('scripts/process.py');
|
|
42
|
+
assert.equal(py.id, 'python');
|
|
43
|
+
assert.equal(py.commentPrefix, '#');
|
|
44
|
+
});
|
package/cli/mcp/tools-patch.js
CHANGED
|
@@ -28,9 +28,11 @@ export const formatPatchWarnings = (result) => {
|
|
|
28
28
|
};
|
|
29
29
|
|
|
30
30
|
export const handleChemxPatch = (args = {}, cwd = process.cwd()) => {
|
|
31
|
+
const targetContent = args.targetContent ?? args.target ?? args.search;
|
|
32
|
+
const replacementContent = args.replacementContent ?? args.replacement ?? args.replace;
|
|
31
33
|
const hasPath = Boolean(args.path);
|
|
32
|
-
const hasTargetContent =
|
|
33
|
-
const hasReplacementContent =
|
|
34
|
+
const hasTargetContent = targetContent !== undefined;
|
|
35
|
+
const hasReplacementContent = replacementContent !== undefined;
|
|
34
36
|
const hasRequiredArgs = hasPath && hasTargetContent && hasReplacementContent;
|
|
35
37
|
|
|
36
38
|
if (!hasRequiredArgs) {
|
|
@@ -39,9 +41,9 @@ export const handleChemxPatch = (args = {}, cwd = process.cwd()) => {
|
|
|
39
41
|
|
|
40
42
|
const targetPath = path.isAbsolute(args.path) ? args.path : path.resolve(cwd, args.path);
|
|
41
43
|
const result = patchFile(targetPath, {
|
|
42
|
-
targetContent
|
|
43
|
-
replacementContent
|
|
44
|
-
allowMultiple: Boolean(args.allowMultiple),
|
|
44
|
+
targetContent,
|
|
45
|
+
replacementContent,
|
|
46
|
+
allowMultiple: Boolean(args.allowMultiple || args.multiple),
|
|
45
47
|
cwd
|
|
46
48
|
});
|
|
47
49
|
|
|
@@ -1,20 +1,18 @@
|
|
|
1
1
|
import { openIndexDb } from '../search-db.js';
|
|
2
2
|
import { toColumnar } from '../columnar.js';
|
|
3
3
|
import {
|
|
4
|
-
listTasks,
|
|
5
|
-
|
|
6
|
-
claimTask,
|
|
7
|
-
updateTaskStatus,
|
|
8
|
-
registerAgent,
|
|
9
|
-
postFeedEvent
|
|
4
|
+
listTasks, getTask, queryFeed, createTask,
|
|
5
|
+
claimTask, updateTaskStatus, registerAgent, postFeedEvent
|
|
10
6
|
} from '../team/team-db.js';
|
|
11
7
|
import { completeTaskWithAudit, autoGenerateTasksFromAudit } from '../team/team-triage.js';
|
|
12
|
-
import { formatTaskListCard } from '../team/team-format.js';
|
|
8
|
+
import { formatTaskListCard, formatTaskDetailCard } from '../team/team-format.js';
|
|
9
|
+
import { enforceSingleSlot, verifyTraceability, generateTaskPermalink } from '../team/team-vds.js';
|
|
10
|
+
import { freezeReleaseTrain } from '../team/team-release-train.js';
|
|
13
11
|
|
|
14
12
|
export const handleChemxTeamTask = async (args = {}, cwd = process.cwd()) => {
|
|
15
13
|
const db = openIndexDb(cwd);
|
|
16
14
|
if (!db) return { error: 'sqlite_unavailable' };
|
|
17
|
-
const action = args.action || 'list';
|
|
15
|
+
const action = args.action || args.subAction || 'list';
|
|
18
16
|
|
|
19
17
|
if (action === 'list') {
|
|
20
18
|
const parentId = args.parentId !== undefined ? args.parentId : args.parent;
|
|
@@ -23,6 +21,29 @@ export const handleChemxTeamTask = async (args = {}, cwd = process.cwd()) => {
|
|
|
23
21
|
const col = toColumnar(tasks, ['id', 'title', 'tier', 'status', 'priority', 'assigned_agent_id', 'target_path', 'parent_id']);
|
|
24
22
|
return { ...col, total: tasks.length, card: formatTaskListCard(tasks) };
|
|
25
23
|
}
|
|
24
|
+
const isShowAction = action === 'show' || action === 'view' || action === 'get';
|
|
25
|
+
if (isShowAction) {
|
|
26
|
+
const task = getTask(db, args.taskId || args.id);
|
|
27
|
+
if (!task) return { error: `Task #${args.taskId || args.id} not found` };
|
|
28
|
+
const events = queryFeed(db, { task_id: args.taskId || args.id });
|
|
29
|
+
return {
|
|
30
|
+
task,
|
|
31
|
+
events,
|
|
32
|
+
activityCount: events.length,
|
|
33
|
+
card: formatTaskDetailCard(task, events)
|
|
34
|
+
};
|
|
35
|
+
}
|
|
36
|
+
const isCommentAction = action === 'comment' || action === 'post';
|
|
37
|
+
if (isCommentAction) {
|
|
38
|
+
const authorHandle = args.agentId || '@agent';
|
|
39
|
+
registerAgent(db, { id: authorHandle, role: 'contributor' });
|
|
40
|
+
return postFeedEvent(db, {
|
|
41
|
+
author_id: authorHandle,
|
|
42
|
+
task_id: Number(args.taskId || args.id),
|
|
43
|
+
event_type: args.type || 'status_update',
|
|
44
|
+
message: args.message || 'Status update'
|
|
45
|
+
});
|
|
46
|
+
}
|
|
26
47
|
if (action === 'create' || action === 'add') {
|
|
27
48
|
const authorHandle = args.agentId || '@agent';
|
|
28
49
|
registerAgent(db, { id: authorHandle, role: 'contributor' });
|
|
@@ -56,7 +77,7 @@ export const handleChemxTeamTask = async (args = {}, cwd = process.cwd()) => {
|
|
|
56
77
|
if (action === 'done' || action === 'complete') {
|
|
57
78
|
const agentHandle = args.agentId || '@agent';
|
|
58
79
|
registerAgent(db, { id: agentHandle, role: 'executor' });
|
|
59
|
-
return completeTaskWithAudit(db, args.taskId, agentHandle, { cwd, force: args.force, noTargetConfirm: args.noTargetConfirm, tokens: args.tokens });
|
|
80
|
+
return completeTaskWithAudit(db, args.taskId, agentHandle, { cwd, target: args.target || args.targetPath, force: args.force, noTargetConfirm: args.noTargetConfirm, tokens: args.tokens });
|
|
60
81
|
}
|
|
61
82
|
if (action === 'block') {
|
|
62
83
|
return updateTaskStatus(db, args.taskId, 'blocked', { blockedReason: args.blockedReason || 'Blocked' });
|
|
@@ -66,7 +87,7 @@ export const handleChemxTeamTask = async (args = {}, cwd = process.cwd()) => {
|
|
|
66
87
|
const agentHandle = args.agentId || '@agent';
|
|
67
88
|
registerAgent(db, { id: agentHandle, role: 'executor' });
|
|
68
89
|
if (targetStatus === 'done' || targetStatus === 'completed') {
|
|
69
|
-
return completeTaskWithAudit(db, args.taskId, agentHandle, { cwd, force: args.force, noTargetConfirm: args.noTargetConfirm, tokens: args.tokens });
|
|
90
|
+
return completeTaskWithAudit(db, args.taskId, agentHandle, { cwd, target: args.target || args.targetPath, force: args.force, noTargetConfirm: args.noTargetConfirm, tokens: args.tokens });
|
|
70
91
|
}
|
|
71
92
|
return updateTaskStatus(db, args.taskId, targetStatus, { blockedReason: args.blockedReason || '' });
|
|
72
93
|
}
|
|
@@ -81,5 +102,30 @@ export const handleChemxTeamTask = async (args = {}, cwd = process.cwd()) => {
|
|
|
81
102
|
if (action === 'triage') {
|
|
82
103
|
return autoGenerateTasksFromAudit(db, { cwd, maxTasks: args.maxTasks || 10 });
|
|
83
104
|
}
|
|
105
|
+
const isSlotAction = action === 'slot' || action === 'vds-slot';
|
|
106
|
+
if (isSlotAction) {
|
|
107
|
+
const taskId = Number(args.taskId || args.id);
|
|
108
|
+
return enforceSingleSlot(db, taskId, args.moscow || 'must', args.priority || args.vdsPriority || 'critical');
|
|
109
|
+
}
|
|
110
|
+
const isTraceAction = action === 'trace';
|
|
111
|
+
if (isTraceAction) {
|
|
112
|
+
const taskId = Number(args.taskId || args.id);
|
|
113
|
+
const permalink = args.url || args.taskUrl || generateTaskPermalink(taskId);
|
|
114
|
+
const check = verifyTraceability(permalink);
|
|
115
|
+
if (!check.valid) return { error: check.error };
|
|
116
|
+
db.prepare('UPDATE agent_tasks SET task_url = ?, updated_at = ? WHERE id = ?').run(check.permalink, Date.now(), taskId);
|
|
117
|
+
postFeedEvent(db, {
|
|
118
|
+
author_id: args.agentId || '@stream_guard',
|
|
119
|
+
task_id: taskId,
|
|
120
|
+
event_type: 'task_traceability_anchored',
|
|
121
|
+
message: `Anchored canonical task permalink: ${check.permalink}`,
|
|
122
|
+
metadata: { permalink: check.permalink }
|
|
123
|
+
});
|
|
124
|
+
return { success: true, taskId, permalink: check.permalink };
|
|
125
|
+
}
|
|
126
|
+
const isFreezeAction = action === 'train_freeze' || action === 'freeze';
|
|
127
|
+
if (isFreezeAction) {
|
|
128
|
+
return freezeReleaseTrain(db, args);
|
|
129
|
+
}
|
|
84
130
|
return { error: `Unknown task action: ${action}` };
|
|
85
131
|
};
|
|
@@ -0,0 +1,111 @@
|
|
|
1
|
+
import test from 'node:test';
|
|
2
|
+
import assert from 'node:assert/strict';
|
|
3
|
+
import { auditCode } from './audit/rules.js';
|
|
4
|
+
import { resolveArchitectureTier, extractAstMetadata } from './search-ast.js';
|
|
5
|
+
import { isSourceFile, getLanguageForFile } from './languages.js';
|
|
6
|
+
|
|
7
|
+
test('polyglot: C# source file recognition and tier mapping', () => {
|
|
8
|
+
assert.equal(isSourceFile('ConsentService.cs'), true);
|
|
9
|
+
assert.equal(getLanguageForFile('ConsentService.cs').id, 'csharp');
|
|
10
|
+
|
|
11
|
+
const serviceTier = resolveArchitectureTier('Services/ConsentService.cs');
|
|
12
|
+
assert.equal(serviceTier, 'organism');
|
|
13
|
+
|
|
14
|
+
const controllerTier = resolveArchitectureTier('Controllers/ConsentController.cs');
|
|
15
|
+
assert.equal(controllerTier, 'view');
|
|
16
|
+
|
|
17
|
+
const domainTier = resolveArchitectureTier('Domain/ConsentLedger.cs');
|
|
18
|
+
assert.equal(domainTier, 'atom');
|
|
19
|
+
|
|
20
|
+
const dtoTier = resolveArchitectureTier('Dtos/ConsentRequestDto.cs');
|
|
21
|
+
assert.equal(dtoTier, 'type');
|
|
22
|
+
});
|
|
23
|
+
|
|
24
|
+
test('polyglot: extracts C# classes and using imports into AST metadata', () => {
|
|
25
|
+
const csharpCode = `
|
|
26
|
+
using System;
|
|
27
|
+
using System.Threading.Tasks;
|
|
28
|
+
using MediatR;
|
|
29
|
+
|
|
30
|
+
namespace Nadena.Services;
|
|
31
|
+
|
|
32
|
+
public class ConsentRevocationHandler : IRequestHandler<RevokeConsentCommand, Result>
|
|
33
|
+
{
|
|
34
|
+
public async Task<Result> Handle(RevokeConsentCommand request)
|
|
35
|
+
{
|
|
36
|
+
return Result.Success();
|
|
37
|
+
}
|
|
38
|
+
}
|
|
39
|
+
`;
|
|
40
|
+
|
|
41
|
+
const meta = extractAstMetadata(csharpCode, 'Services/ConsentRevocationHandler.cs');
|
|
42
|
+
assert.ok(meta.symbols.some((s) => s.name === 'ConsentRevocationHandler'));
|
|
43
|
+
assert.ok(meta.imports.some((i) => i.sourceModule === 'MediatR'));
|
|
44
|
+
});
|
|
45
|
+
|
|
46
|
+
test('polyglot: audits C# code for mock data, slop catch, and fake green assertions without syntax errors', () => {
|
|
47
|
+
const dirtyCSharp = `
|
|
48
|
+
using System;
|
|
49
|
+
using Xunit;
|
|
50
|
+
|
|
51
|
+
public class SimulatedConsentService
|
|
52
|
+
{
|
|
53
|
+
public void Execute()
|
|
54
|
+
{
|
|
55
|
+
var email = "user@example.com";
|
|
56
|
+
try
|
|
57
|
+
{
|
|
58
|
+
// Do work
|
|
59
|
+
}
|
|
60
|
+
catch (Exception)
|
|
61
|
+
{
|
|
62
|
+
}
|
|
63
|
+
}
|
|
64
|
+
|
|
65
|
+
[Fact]
|
|
66
|
+
public void Test_Fake_Green()
|
|
67
|
+
{
|
|
68
|
+
Assert.True(true);
|
|
69
|
+
}
|
|
70
|
+
}
|
|
71
|
+
`;
|
|
72
|
+
|
|
73
|
+
const violations = auditCode(dirtyCSharp, 'Services/SimulatedConsentService.cs', 'Services/SimulatedConsentService.cs');
|
|
74
|
+
|
|
75
|
+
// Must NOT emit SYNTAX_PARSE_ERROR on C#
|
|
76
|
+
const hasSyntaxError = violations.some((v) => v.rule === 'SYNTAX_PARSE_ERROR');
|
|
77
|
+
assert.equal(hasSyntaxError, false, 'C# code must not trigger Babel SYNTAX_PARSE_ERROR');
|
|
78
|
+
|
|
79
|
+
// Must detect Synthetic Mock Data
|
|
80
|
+
const hasMockData = violations.some((v) => v.rule === 'SYNTHETIC_MOCK_DATA');
|
|
81
|
+
assert.equal(hasMockData, true, 'Must detect user@example.com in C# code');
|
|
82
|
+
|
|
83
|
+
// Must detect Shallow Catch
|
|
84
|
+
const hasShallowCatch = violations.some((v) => v.rule === 'AI_SLOP_SHALLOW_CATCH');
|
|
85
|
+
assert.equal(hasShallowCatch, true, 'Must detect empty catch (Exception) in C#');
|
|
86
|
+
|
|
87
|
+
// Must detect Fake Green Assertion
|
|
88
|
+
const hasFakeGreen = violations.some((v) => v.rule === 'TEST_FAKE_GREEN');
|
|
89
|
+
assert.equal(hasFakeGreen, true, 'Must detect Assert.True(true) in C# test');
|
|
90
|
+
});
|
|
91
|
+
|
|
92
|
+
test('polyglot: audits Python and Go without syntax errors and flags polyglot rules', () => {
|
|
93
|
+
const pythonCode = `
|
|
94
|
+
def test_something():
|
|
95
|
+
assert True
|
|
96
|
+
`;
|
|
97
|
+
const pyViolations = auditCode(pythonCode, 'tests/test_flow.py', 'tests/test_flow.py');
|
|
98
|
+
assert.equal(pyViolations.some((v) => v.rule === 'SYNTAX_PARSE_ERROR'), false);
|
|
99
|
+
assert.equal(pyViolations.some((v) => v.rule === 'TEST_FAKE_GREEN'), true);
|
|
100
|
+
|
|
101
|
+
const goCode = `
|
|
102
|
+
package main
|
|
103
|
+
import "testing"
|
|
104
|
+
func TestDummy(t *testing.T) {
|
|
105
|
+
var email = "fake@example.com"
|
|
106
|
+
}
|
|
107
|
+
`;
|
|
108
|
+
const goViolations = auditCode(goCode, 'pkg/service/service.go', 'pkg/service/service.go');
|
|
109
|
+
assert.equal(goViolations.some((v) => v.rule === 'SYNTAX_PARSE_ERROR'), false);
|
|
110
|
+
assert.equal(goViolations.some((v) => v.rule === 'SYNTHETIC_MOCK_DATA'), true);
|
|
111
|
+
});
|
|
@@ -49,12 +49,12 @@ describe('Reader Shorthand Syntax', () => {
|
|
|
49
49
|
it('supports MCP chemx({ action: "r" })', async () => {
|
|
50
50
|
const output = await handleChemx({ action: 'r', params: { path: 'package.json:1-3' } });
|
|
51
51
|
assert.ok(output.includes('package.json'));
|
|
52
|
-
assert.ok(output.includes('"name":
|
|
52
|
+
assert.ok(output.includes('"name":'));
|
|
53
53
|
});
|
|
54
54
|
|
|
55
55
|
it('supports MCP chemx({ command: "r path:1-3" })', async () => {
|
|
56
56
|
const output = await handleChemx({ command: 'r package.json:1-3' });
|
|
57
57
|
assert.ok(output.includes('package.json'));
|
|
58
|
-
assert.ok(output.includes('"name":
|
|
58
|
+
assert.ok(output.includes('"name":'));
|
|
59
59
|
});
|
|
60
60
|
});
|