@ryuenn3123/agentic-senior-core 2.0.5 → 2.0.7

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 (121) hide show
  1. package/.agent-context/blueprints/mobile-app.md +91 -21
  2. package/.agent-context/profiles/platform.md +13 -13
  3. package/.agent-context/profiles/regulated.md +13 -13
  4. package/.agent-context/profiles/startup.md +13 -13
  5. package/.agent-context/review-checklists/frontend-skill-parity.md +28 -28
  6. package/.agent-context/review-checklists/frontend-usability.md +33 -33
  7. package/.agent-context/review-checklists/release-operations.md +29 -29
  8. package/.agent-context/skills/README.md +62 -62
  9. package/.agent-context/skills/backend/README.md +67 -67
  10. package/.agent-context/skills/backend/architecture.md +360 -360
  11. package/.agent-context/skills/backend/compatibility-manifest.json +8 -8
  12. package/.agent-context/skills/backend/data-access.md +230 -230
  13. package/.agent-context/skills/backend/errors.md +137 -137
  14. package/.agent-context/skills/backend/validation.md +116 -116
  15. package/.agent-context/skills/backend.md +28 -28
  16. package/.agent-context/skills/cli/README.md +55 -49
  17. package/.agent-context/skills/cli/compatibility-manifest.json +8 -8
  18. package/.agent-context/skills/cli/init.md +37 -37
  19. package/.agent-context/skills/cli/output.md +35 -35
  20. package/.agent-context/skills/cli/safety-telemetry.md +39 -0
  21. package/.agent-context/skills/cli/upgrade.md +37 -37
  22. package/.agent-context/skills/cli.md +31 -28
  23. package/.agent-context/skills/distribution/.evidence/compatibility-manifest.json +9 -0
  24. package/.agent-context/skills/distribution/.evidence/sbom-excerpt.json +6 -0
  25. package/.agent-context/skills/distribution/.evidence/test-report.json +8 -0
  26. package/.agent-context/skills/distribution/CHANGELOG.md +7 -0
  27. package/.agent-context/skills/distribution/README.md +27 -19
  28. package/.agent-context/skills/distribution/compatibility-manifest.json +8 -8
  29. package/.agent-context/skills/distribution/compatibility.md +31 -31
  30. package/.agent-context/skills/distribution/package.json +5 -0
  31. package/.agent-context/skills/distribution/provenance-attestation.md +47 -0
  32. package/.agent-context/skills/distribution/publish.md +36 -36
  33. package/.agent-context/skills/distribution/rollback.md +31 -31
  34. package/.agent-context/skills/distribution/tests/.gitkeep +1 -0
  35. package/.agent-context/skills/distribution.md +31 -28
  36. package/.agent-context/skills/frontend/.evidence/compatibility-manifest.json +9 -0
  37. package/.agent-context/skills/frontend/.evidence/sbom-excerpt.json +6 -0
  38. package/.agent-context/skills/frontend/.evidence/test-report.json +8 -0
  39. package/.agent-context/skills/frontend/CHANGELOG.md +7 -0
  40. package/.agent-context/skills/frontend/README.md +49 -36
  41. package/.agent-context/skills/frontend/accessibility.md +107 -107
  42. package/.agent-context/skills/frontend/compatibility-manifest.json +8 -8
  43. package/.agent-context/skills/frontend/conversion-clarity.md +51 -0
  44. package/.agent-context/skills/frontend/motion.md +66 -66
  45. package/.agent-context/skills/frontend/package.json +5 -0
  46. package/.agent-context/skills/frontend/performance.md +62 -62
  47. package/.agent-context/skills/frontend/responsive-delivery.md +41 -0
  48. package/.agent-context/skills/frontend/tests/.gitkeep +1 -0
  49. package/.agent-context/skills/frontend/ui-architecture.md +128 -128
  50. package/.agent-context/skills/frontend.md +35 -29
  51. package/.agent-context/skills/fullstack/.evidence/compatibility-manifest.json +9 -0
  52. package/.agent-context/skills/fullstack/.evidence/sbom-excerpt.json +6 -0
  53. package/.agent-context/skills/fullstack/.evidence/test-report.json +8 -0
  54. package/.agent-context/skills/fullstack/CHANGELOG.md +7 -0
  55. package/.agent-context/skills/fullstack/README.md +27 -19
  56. package/.agent-context/skills/fullstack/compatibility-manifest.json +8 -8
  57. package/.agent-context/skills/fullstack/contracts.md +52 -52
  58. package/.agent-context/skills/fullstack/end-to-end.md +41 -41
  59. package/.agent-context/skills/fullstack/feature-slicing.md +64 -64
  60. package/.agent-context/skills/fullstack/package.json +5 -0
  61. package/.agent-context/skills/fullstack/release-coordination.md +51 -0
  62. package/.agent-context/skills/fullstack/tests/.gitkeep +1 -0
  63. package/.agent-context/skills/fullstack.md +29 -26
  64. package/.agent-context/skills/index.json +107 -107
  65. package/.agent-context/skills/review-quality/.evidence/compatibility-manifest.json +9 -0
  66. package/.agent-context/skills/review-quality/.evidence/sbom-excerpt.json +6 -0
  67. package/.agent-context/skills/review-quality/.evidence/test-report.json +8 -0
  68. package/.agent-context/skills/review-quality/CHANGELOG.md +7 -0
  69. package/.agent-context/skills/review-quality/README.md +27 -19
  70. package/.agent-context/skills/review-quality/benchmark.md +29 -29
  71. package/.agent-context/skills/review-quality/compatibility-manifest.json +8 -8
  72. package/.agent-context/skills/review-quality/package.json +5 -0
  73. package/.agent-context/skills/review-quality/planning.md +37 -37
  74. package/.agent-context/skills/review-quality/release-decision.md +49 -0
  75. package/.agent-context/skills/review-quality/security.md +33 -33
  76. package/.agent-context/skills/review-quality/tests/.gitkeep +1 -0
  77. package/.agent-context/skills/review-quality.md +30 -27
  78. package/.agent-context/stacks/flutter.md +16 -16
  79. package/.agent-context/stacks/react-native.md +16 -16
  80. package/.agent-context/state/architecture-map.md +25 -25
  81. package/.agent-context/state/benchmark-analysis.json +431 -431
  82. package/.agent-context/state/benchmark-thresholds.json +10 -10
  83. package/.agent-context/state/benchmark-watchlist.json +19 -19
  84. package/.agent-context/state/dependency-map.md +32 -32
  85. package/.agent-context/state/quality-trend-report.json +16 -6
  86. package/.agent-context/state/skill-platform.json +38 -38
  87. package/.agent-context/state/weekly-governance-report.json +126 -0
  88. package/.agent-override.md +36 -36
  89. package/.cursorrules +1 -1
  90. package/.gemini/instructions.md +20 -20
  91. package/.github/ISSUE_TEMPLATE/v1.7-frontend-work-item.yml +54 -54
  92. package/.github/copilot-instructions.md +20 -20
  93. package/.github/workflows/benchmark-detection.yml +38 -38
  94. package/.github/workflows/benchmark-intelligence.yml +50 -50
  95. package/.github/workflows/frontend-usability-gate.yml +36 -36
  96. package/.github/workflows/governance-weekly-report.yml +43 -0
  97. package/.github/workflows/release-gate.yml +32 -32
  98. package/.github/workflows/sbom-compliance.yml +32 -32
  99. package/.windsurfrules +1 -1
  100. package/AGENTS.md +27 -27
  101. package/README.md +383 -368
  102. package/lib/cli/commands/optimize.mjs +171 -171
  103. package/lib/cli/compatibility.mjs +124 -124
  104. package/lib/cli/constants.mjs +35 -0
  105. package/lib/cli/token-optimization.mjs +275 -275
  106. package/lib/cli/utils.mjs +4 -1
  107. package/mcp.json +92 -92
  108. package/package.json +2 -1
  109. package/scripts/benchmark-gate.mjs +121 -121
  110. package/scripts/benchmark-intelligence.mjs +140 -140
  111. package/scripts/detection-benchmark.mjs +138 -138
  112. package/scripts/frontend-usability-audit.mjs +87 -87
  113. package/scripts/generate-sbom.mjs +61 -61
  114. package/scripts/governance-weekly-report.mjs +293 -0
  115. package/scripts/init-project.ps1 +104 -104
  116. package/scripts/llm-judge.mjs +664 -664
  117. package/scripts/quality-trend-report.mjs +288 -288
  118. package/scripts/release-gate.mjs +261 -259
  119. package/scripts/skill-tier-policy.mjs +75 -75
  120. package/scripts/token-optimization-benchmark.mjs +252 -252
  121. package/scripts/validate.mjs +874 -865
@@ -1,140 +1,140 @@
1
- #!/usr/bin/env node
2
-
3
- /**
4
- * benchmark-intelligence.mjs
5
- *
6
- * Competitive intelligence cadence validator.
7
- * Ensures benchmark watchlist coverage and review freshness.
8
- */
9
-
10
- import { existsSync, readFileSync } from 'node:fs';
11
- import { dirname, join, resolve } from 'node:path';
12
- import { fileURLToPath } from 'node:url';
13
-
14
- const SCRIPT_FILE_PATH = fileURLToPath(import.meta.url);
15
- const SCRIPT_DIR = dirname(SCRIPT_FILE_PATH);
16
- const REPOSITORY_ROOT = resolve(SCRIPT_DIR, '..');
17
- const WATCHLIST_PATH = join(REPOSITORY_ROOT, '.agent-context', 'state', 'benchmark-watchlist.json');
18
- const REVIEW_SLA_DAYS = 14;
19
- const REQUIRED_BENCHMARK_REPOSITORIES = new Set([
20
- 'sickn33/antigravity-awesome-skills',
21
- 'github/awesome-copilot',
22
- 'MiniMax-AI/skills',
23
- ]);
24
-
25
- function parseDateOrNull(rawDateValue) {
26
- if (typeof rawDateValue !== 'string') {
27
- return null;
28
- }
29
-
30
- if (!/^\d{4}-\d{2}-\d{2}$/.test(rawDateValue)) {
31
- return null;
32
- }
33
-
34
- const parsedDate = new Date(`${rawDateValue}T00:00:00.000Z`);
35
- return Number.isNaN(parsedDate.getTime()) ? null : parsedDate;
36
- }
37
-
38
- function calculateAgeInDays(referenceDate, targetDate) {
39
- const ageInMilliseconds = referenceDate.getTime() - targetDate.getTime();
40
- return Math.floor(ageInMilliseconds / (1000 * 60 * 60 * 24));
41
- }
42
-
43
- function loadWatchlistConfiguration() {
44
- if (!existsSync(WATCHLIST_PATH)) {
45
- return { repositories: [] };
46
- }
47
-
48
- return JSON.parse(readFileSync(WATCHLIST_PATH, 'utf8'));
49
- }
50
-
51
- function runIntelligenceValidation() {
52
- const watchlistConfiguration = loadWatchlistConfiguration();
53
- const watchlistEntries = Array.isArray(watchlistConfiguration.repositories)
54
- ? watchlistConfiguration.repositories
55
- : [];
56
- const validationResults = [];
57
- const currentDate = new Date();
58
-
59
- const trackedRepositoryNames = new Set();
60
- for (const watchlistEntry of watchlistEntries) {
61
- trackedRepositoryNames.add(watchlistEntry.repository);
62
- }
63
-
64
- for (const requiredRepositoryName of REQUIRED_BENCHMARK_REPOSITORIES) {
65
- const hasRequiredRepository = trackedRepositoryNames.has(requiredRepositoryName);
66
- validationResults.push({
67
- checkName: 'required-benchmark-repository',
68
- repository: requiredRepositoryName,
69
- passed: hasRequiredRepository,
70
- details: hasRequiredRepository
71
- ? `${requiredRepositoryName} is present in watchlist`
72
- : `${requiredRepositoryName} is missing from watchlist`,
73
- });
74
- }
75
-
76
- const watchlistReport = watchlistEntries.map((watchlistEntry) => {
77
- const repositoryName = watchlistEntry.repository;
78
- const repositoryOwner = watchlistEntry.owner;
79
- const lastReviewedDate = parseDateOrNull(watchlistEntry.lastReviewedAt);
80
-
81
- const hasOwner = typeof repositoryOwner === 'string' && repositoryOwner.trim().length > 0;
82
- validationResults.push({
83
- checkName: 'watchlist-owner-defined',
84
- repository: repositoryName,
85
- passed: hasOwner,
86
- details: hasOwner ? `Owner ${repositoryOwner} is defined` : 'Owner is missing',
87
- });
88
-
89
- if (!lastReviewedDate) {
90
- validationResults.push({
91
- checkName: 'review-date-format',
92
- repository: repositoryName,
93
- passed: false,
94
- details: `Invalid or missing lastReviewedAt: ${String(watchlistEntry.lastReviewedAt)}`,
95
- });
96
-
97
- return {
98
- repository: repositoryName,
99
- owner: repositoryOwner,
100
- lastReviewedAt: watchlistEntry.lastReviewedAt,
101
- ageInDays: null,
102
- stale: true,
103
- };
104
- }
105
-
106
- const reviewAgeInDays = calculateAgeInDays(currentDate, lastReviewedDate);
107
- const reviewWithinSla = reviewAgeInDays <= REVIEW_SLA_DAYS;
108
-
109
- validationResults.push({
110
- checkName: 'review-sla-compliance',
111
- repository: repositoryName,
112
- passed: reviewWithinSla,
113
- details: `ageInDays=${reviewAgeInDays} slaDays=${REVIEW_SLA_DAYS}`,
114
- });
115
-
116
- return {
117
- repository: repositoryName,
118
- owner: repositoryOwner,
119
- lastReviewedAt: watchlistEntry.lastReviewedAt,
120
- ageInDays: reviewAgeInDays,
121
- stale: !reviewWithinSla,
122
- };
123
- });
124
-
125
- const failedCheckCount = validationResults.filter((validationResult) => !validationResult.passed).length;
126
- const intelligenceReport = {
127
- generatedAt: new Date().toISOString(),
128
- reportName: 'benchmark-intelligence',
129
- passed: failedCheckCount === 0,
130
- failureCount: failedCheckCount,
131
- reviewSlaDays: REVIEW_SLA_DAYS,
132
- watchlist: watchlistReport,
133
- results: validationResults,
134
- };
135
-
136
- console.log(JSON.stringify(intelligenceReport, null, 2));
137
- process.exit(intelligenceReport.passed ? 0 : 1);
138
- }
139
-
140
- runIntelligenceValidation();
1
+ #!/usr/bin/env node
2
+
3
+ /**
4
+ * benchmark-intelligence.mjs
5
+ *
6
+ * Competitive intelligence cadence validator.
7
+ * Ensures benchmark watchlist coverage and review freshness.
8
+ */
9
+
10
+ import { existsSync, readFileSync } from 'node:fs';
11
+ import { dirname, join, resolve } from 'node:path';
12
+ import { fileURLToPath } from 'node:url';
13
+
14
+ const SCRIPT_FILE_PATH = fileURLToPath(import.meta.url);
15
+ const SCRIPT_DIR = dirname(SCRIPT_FILE_PATH);
16
+ const REPOSITORY_ROOT = resolve(SCRIPT_DIR, '..');
17
+ const WATCHLIST_PATH = join(REPOSITORY_ROOT, '.agent-context', 'state', 'benchmark-watchlist.json');
18
+ const REVIEW_SLA_DAYS = 14;
19
+ const REQUIRED_BENCHMARK_REPOSITORIES = new Set([
20
+ 'sickn33/antigravity-awesome-skills',
21
+ 'github/awesome-copilot',
22
+ 'MiniMax-AI/skills',
23
+ ]);
24
+
25
+ function parseDateOrNull(rawDateValue) {
26
+ if (typeof rawDateValue !== 'string') {
27
+ return null;
28
+ }
29
+
30
+ if (!/^\d{4}-\d{2}-\d{2}$/.test(rawDateValue)) {
31
+ return null;
32
+ }
33
+
34
+ const parsedDate = new Date(`${rawDateValue}T00:00:00.000Z`);
35
+ return Number.isNaN(parsedDate.getTime()) ? null : parsedDate;
36
+ }
37
+
38
+ function calculateAgeInDays(referenceDate, targetDate) {
39
+ const ageInMilliseconds = referenceDate.getTime() - targetDate.getTime();
40
+ return Math.floor(ageInMilliseconds / (1000 * 60 * 60 * 24));
41
+ }
42
+
43
+ function loadWatchlistConfiguration() {
44
+ if (!existsSync(WATCHLIST_PATH)) {
45
+ return { repositories: [] };
46
+ }
47
+
48
+ return JSON.parse(readFileSync(WATCHLIST_PATH, 'utf8'));
49
+ }
50
+
51
+ function runIntelligenceValidation() {
52
+ const watchlistConfiguration = loadWatchlistConfiguration();
53
+ const watchlistEntries = Array.isArray(watchlistConfiguration.repositories)
54
+ ? watchlistConfiguration.repositories
55
+ : [];
56
+ const validationResults = [];
57
+ const currentDate = new Date();
58
+
59
+ const trackedRepositoryNames = new Set();
60
+ for (const watchlistEntry of watchlistEntries) {
61
+ trackedRepositoryNames.add(watchlistEntry.repository);
62
+ }
63
+
64
+ for (const requiredRepositoryName of REQUIRED_BENCHMARK_REPOSITORIES) {
65
+ const hasRequiredRepository = trackedRepositoryNames.has(requiredRepositoryName);
66
+ validationResults.push({
67
+ checkName: 'required-benchmark-repository',
68
+ repository: requiredRepositoryName,
69
+ passed: hasRequiredRepository,
70
+ details: hasRequiredRepository
71
+ ? `${requiredRepositoryName} is present in watchlist`
72
+ : `${requiredRepositoryName} is missing from watchlist`,
73
+ });
74
+ }
75
+
76
+ const watchlistReport = watchlistEntries.map((watchlistEntry) => {
77
+ const repositoryName = watchlistEntry.repository;
78
+ const repositoryOwner = watchlistEntry.owner;
79
+ const lastReviewedDate = parseDateOrNull(watchlistEntry.lastReviewedAt);
80
+
81
+ const hasOwner = typeof repositoryOwner === 'string' && repositoryOwner.trim().length > 0;
82
+ validationResults.push({
83
+ checkName: 'watchlist-owner-defined',
84
+ repository: repositoryName,
85
+ passed: hasOwner,
86
+ details: hasOwner ? `Owner ${repositoryOwner} is defined` : 'Owner is missing',
87
+ });
88
+
89
+ if (!lastReviewedDate) {
90
+ validationResults.push({
91
+ checkName: 'review-date-format',
92
+ repository: repositoryName,
93
+ passed: false,
94
+ details: `Invalid or missing lastReviewedAt: ${String(watchlistEntry.lastReviewedAt)}`,
95
+ });
96
+
97
+ return {
98
+ repository: repositoryName,
99
+ owner: repositoryOwner,
100
+ lastReviewedAt: watchlistEntry.lastReviewedAt,
101
+ ageInDays: null,
102
+ stale: true,
103
+ };
104
+ }
105
+
106
+ const reviewAgeInDays = calculateAgeInDays(currentDate, lastReviewedDate);
107
+ const reviewWithinSla = reviewAgeInDays <= REVIEW_SLA_DAYS;
108
+
109
+ validationResults.push({
110
+ checkName: 'review-sla-compliance',
111
+ repository: repositoryName,
112
+ passed: reviewWithinSla,
113
+ details: `ageInDays=${reviewAgeInDays} slaDays=${REVIEW_SLA_DAYS}`,
114
+ });
115
+
116
+ return {
117
+ repository: repositoryName,
118
+ owner: repositoryOwner,
119
+ lastReviewedAt: watchlistEntry.lastReviewedAt,
120
+ ageInDays: reviewAgeInDays,
121
+ stale: !reviewWithinSla,
122
+ };
123
+ });
124
+
125
+ const failedCheckCount = validationResults.filter((validationResult) => !validationResult.passed).length;
126
+ const intelligenceReport = {
127
+ generatedAt: new Date().toISOString(),
128
+ reportName: 'benchmark-intelligence',
129
+ passed: failedCheckCount === 0,
130
+ failureCount: failedCheckCount,
131
+ reviewSlaDays: REVIEW_SLA_DAYS,
132
+ watchlist: watchlistReport,
133
+ results: validationResults,
134
+ };
135
+
136
+ console.log(JSON.stringify(intelligenceReport, null, 2));
137
+ process.exit(intelligenceReport.passed ? 0 : 1);
138
+ }
139
+
140
+ runIntelligenceValidation();
@@ -1,138 +1,138 @@
1
- #!/usr/bin/env node
2
-
3
- /**
4
- * detection-benchmark.mjs
5
- *
6
- * Lightweight benchmark for stack detection heuristics used by the CLI.
7
- * Publishes top-1 accuracy and manual-correction-rate proxy.
8
- */
9
-
10
- const BLUEPRINT_RECOMMENDATIONS = {
11
- 'typescript.md': 'api-nextjs.md',
12
- 'python.md': 'fastapi-service.md',
13
- 'java.md': 'spring-boot-api.md',
14
- 'php.md': 'laravel-api.md',
15
- 'go.md': 'go-service.md',
16
- 'csharp.md': 'aspnet-api.md',
17
- };
18
-
19
- const AMBIGUITY_THRESHOLD = 0.08;
20
-
21
- const BENCHMARK_FIXTURES = [
22
- { fixtureName: 'typescript-basic', markers: ['package.json', 'tsconfig.json'], expectedStack: 'typescript.md' },
23
- { fixtureName: 'typescript-next', markers: ['package.json', 'tsconfig.json', 'next.config.js'], expectedStack: 'typescript.md' },
24
- { fixtureName: 'python-poetry', markers: ['pyproject.toml'], expectedStack: 'python.md' },
25
- { fixtureName: 'python-requirements', markers: ['requirements.txt'], expectedStack: 'python.md' },
26
- { fixtureName: 'java-maven', markers: ['pom.xml'], expectedStack: 'java.md' },
27
- { fixtureName: 'java-gradle', markers: ['build.gradle'], expectedStack: 'java.md' },
28
- { fixtureName: 'php-composer', markers: ['composer.json'], expectedStack: 'php.md' },
29
- { fixtureName: 'go-module', markers: ['go.mod'], expectedStack: 'go.md' },
30
- { fixtureName: 'dotnet-solution', markers: ['app.sln'], expectedStack: 'csharp.md' },
31
- { fixtureName: 'rust-cargo', markers: ['Cargo.toml'], expectedStack: 'rust.md' },
32
- { fixtureName: 'ruby-gemfile', markers: ['Gemfile'], expectedStack: 'ruby.md' },
33
- { fixtureName: 'mixed-ts-python', markers: ['package.json', 'tsconfig.json', 'pyproject.toml'], expectedStack: 'typescript.md' },
34
- ];
35
-
36
- function detectProjectFromMarkers(markers) {
37
- const markerNames = new Set(markers);
38
- const candidates = [];
39
-
40
- if (markerNames.has('package.json') || markerNames.has('tsconfig.json') || markerNames.has('next.config.js') || markerNames.has('next.config.mjs')) {
41
- let confidenceScore = 0.7;
42
- if (markerNames.has('package.json')) confidenceScore += 0.12;
43
- if (markerNames.has('tsconfig.json')) confidenceScore += 0.12;
44
- if (markerNames.has('next.config.js') || markerNames.has('next.config.mjs')) confidenceScore += 0.05;
45
- candidates.push({ stackFileName: 'typescript.md', confidenceScore: Math.min(confidenceScore, 0.97) });
46
- }
47
-
48
- if (markerNames.has('pyproject.toml') || markerNames.has('requirements.txt')) {
49
- candidates.push({
50
- stackFileName: 'python.md',
51
- confidenceScore: markerNames.has('pyproject.toml') ? 0.96 : 0.78,
52
- });
53
- }
54
-
55
- if (markerNames.has('pom.xml') || markerNames.has('build.gradle') || markerNames.has('build.gradle.kts')) {
56
- candidates.push({
57
- stackFileName: 'java.md',
58
- confidenceScore: markerNames.has('pom.xml') ? 0.95 : 0.84,
59
- });
60
- }
61
-
62
- if (markerNames.has('composer.json')) candidates.push({ stackFileName: 'php.md', confidenceScore: 0.95 });
63
- if (markerNames.has('go.mod')) candidates.push({ stackFileName: 'go.md', confidenceScore: 0.96 });
64
- if (markerNames.has('Cargo.toml')) candidates.push({ stackFileName: 'rust.md', confidenceScore: 0.96 });
65
- if (markerNames.has('Gemfile')) candidates.push({ stackFileName: 'ruby.md', confidenceScore: 0.95 });
66
-
67
- const hasDotNetMarker = Array.from(markerNames).some((markerName) => markerName.endsWith('.sln') || markerName.endsWith('.csproj'));
68
- if (hasDotNetMarker) {
69
- candidates.push({ stackFileName: 'csharp.md', confidenceScore: 0.95 });
70
- }
71
-
72
- if (candidates.length === 0) {
73
- return {
74
- recommendedStack: null,
75
- recommendedBlueprint: null,
76
- confidenceScore: 0,
77
- confidenceGap: 0,
78
- needsManualCorrection: true,
79
- };
80
- }
81
-
82
- candidates.sort((leftCandidate, rightCandidate) => rightCandidate.confidenceScore - leftCandidate.confidenceScore);
83
- const strongestCandidate = candidates[0];
84
- const secondStrongestCandidate = candidates[1];
85
- const confidenceGap = secondStrongestCandidate
86
- ? Number((strongestCandidate.confidenceScore - secondStrongestCandidate.confidenceScore).toFixed(2))
87
- : Number(strongestCandidate.confidenceScore.toFixed(2));
88
-
89
- return {
90
- recommendedStack: strongestCandidate.stackFileName,
91
- recommendedBlueprint: BLUEPRINT_RECOMMENDATIONS[strongestCandidate.stackFileName] || null,
92
- confidenceScore: strongestCandidate.confidenceScore,
93
- confidenceGap,
94
- needsManualCorrection: confidenceGap < AMBIGUITY_THRESHOLD,
95
- };
96
- }
97
-
98
- function runBenchmark() {
99
- let passingFixtureCount = 0;
100
- let manualCorrectionCount = 0;
101
-
102
- const fixtureResults = BENCHMARK_FIXTURES.map((benchmarkFixture) => {
103
- const detectionResult = detectProjectFromMarkers(benchmarkFixture.markers);
104
- const isCorrect = detectionResult.recommendedStack === benchmarkFixture.expectedStack;
105
-
106
- if (isCorrect) {
107
- passingFixtureCount += 1;
108
- }
109
-
110
- if (detectionResult.needsManualCorrection) {
111
- manualCorrectionCount += 1;
112
- }
113
-
114
- return {
115
- fixtureName: benchmarkFixture.fixtureName,
116
- expectedStack: benchmarkFixture.expectedStack,
117
- detectedStack: detectionResult.recommendedStack,
118
- confidenceGap: detectionResult.confidenceGap,
119
- needsManualCorrection: detectionResult.needsManualCorrection,
120
- isCorrect,
121
- };
122
- });
123
-
124
- const totalFixtureCount = BENCHMARK_FIXTURES.length;
125
- const top1Accuracy = Number((passingFixtureCount / totalFixtureCount).toFixed(4));
126
- const manualCorrectionRate = Number((manualCorrectionCount / totalFixtureCount).toFixed(4));
127
-
128
- return {
129
- generatedAt: new Date().toISOString(),
130
- fixtureCount: totalFixtureCount,
131
- top1Accuracy,
132
- manualCorrectionRate,
133
- fixtures: fixtureResults,
134
- };
135
- }
136
-
137
- const benchmarkResult = runBenchmark();
138
- console.log(JSON.stringify(benchmarkResult, null, 2));
1
+ #!/usr/bin/env node
2
+
3
+ /**
4
+ * detection-benchmark.mjs
5
+ *
6
+ * Lightweight benchmark for stack detection heuristics used by the CLI.
7
+ * Publishes top-1 accuracy and manual-correction-rate proxy.
8
+ */
9
+
10
+ const BLUEPRINT_RECOMMENDATIONS = {
11
+ 'typescript.md': 'api-nextjs.md',
12
+ 'python.md': 'fastapi-service.md',
13
+ 'java.md': 'spring-boot-api.md',
14
+ 'php.md': 'laravel-api.md',
15
+ 'go.md': 'go-service.md',
16
+ 'csharp.md': 'aspnet-api.md',
17
+ };
18
+
19
+ const AMBIGUITY_THRESHOLD = 0.08;
20
+
21
+ const BENCHMARK_FIXTURES = [
22
+ { fixtureName: 'typescript-basic', markers: ['package.json', 'tsconfig.json'], expectedStack: 'typescript.md' },
23
+ { fixtureName: 'typescript-next', markers: ['package.json', 'tsconfig.json', 'next.config.js'], expectedStack: 'typescript.md' },
24
+ { fixtureName: 'python-poetry', markers: ['pyproject.toml'], expectedStack: 'python.md' },
25
+ { fixtureName: 'python-requirements', markers: ['requirements.txt'], expectedStack: 'python.md' },
26
+ { fixtureName: 'java-maven', markers: ['pom.xml'], expectedStack: 'java.md' },
27
+ { fixtureName: 'java-gradle', markers: ['build.gradle'], expectedStack: 'java.md' },
28
+ { fixtureName: 'php-composer', markers: ['composer.json'], expectedStack: 'php.md' },
29
+ { fixtureName: 'go-module', markers: ['go.mod'], expectedStack: 'go.md' },
30
+ { fixtureName: 'dotnet-solution', markers: ['app.sln'], expectedStack: 'csharp.md' },
31
+ { fixtureName: 'rust-cargo', markers: ['Cargo.toml'], expectedStack: 'rust.md' },
32
+ { fixtureName: 'ruby-gemfile', markers: ['Gemfile'], expectedStack: 'ruby.md' },
33
+ { fixtureName: 'mixed-ts-python', markers: ['package.json', 'tsconfig.json', 'pyproject.toml'], expectedStack: 'typescript.md' },
34
+ ];
35
+
36
+ function detectProjectFromMarkers(markers) {
37
+ const markerNames = new Set(markers);
38
+ const candidates = [];
39
+
40
+ if (markerNames.has('package.json') || markerNames.has('tsconfig.json') || markerNames.has('next.config.js') || markerNames.has('next.config.mjs')) {
41
+ let confidenceScore = 0.7;
42
+ if (markerNames.has('package.json')) confidenceScore += 0.12;
43
+ if (markerNames.has('tsconfig.json')) confidenceScore += 0.12;
44
+ if (markerNames.has('next.config.js') || markerNames.has('next.config.mjs')) confidenceScore += 0.05;
45
+ candidates.push({ stackFileName: 'typescript.md', confidenceScore: Math.min(confidenceScore, 0.97) });
46
+ }
47
+
48
+ if (markerNames.has('pyproject.toml') || markerNames.has('requirements.txt')) {
49
+ candidates.push({
50
+ stackFileName: 'python.md',
51
+ confidenceScore: markerNames.has('pyproject.toml') ? 0.96 : 0.78,
52
+ });
53
+ }
54
+
55
+ if (markerNames.has('pom.xml') || markerNames.has('build.gradle') || markerNames.has('build.gradle.kts')) {
56
+ candidates.push({
57
+ stackFileName: 'java.md',
58
+ confidenceScore: markerNames.has('pom.xml') ? 0.95 : 0.84,
59
+ });
60
+ }
61
+
62
+ if (markerNames.has('composer.json')) candidates.push({ stackFileName: 'php.md', confidenceScore: 0.95 });
63
+ if (markerNames.has('go.mod')) candidates.push({ stackFileName: 'go.md', confidenceScore: 0.96 });
64
+ if (markerNames.has('Cargo.toml')) candidates.push({ stackFileName: 'rust.md', confidenceScore: 0.96 });
65
+ if (markerNames.has('Gemfile')) candidates.push({ stackFileName: 'ruby.md', confidenceScore: 0.95 });
66
+
67
+ const hasDotNetMarker = Array.from(markerNames).some((markerName) => markerName.endsWith('.sln') || markerName.endsWith('.csproj'));
68
+ if (hasDotNetMarker) {
69
+ candidates.push({ stackFileName: 'csharp.md', confidenceScore: 0.95 });
70
+ }
71
+
72
+ if (candidates.length === 0) {
73
+ return {
74
+ recommendedStack: null,
75
+ recommendedBlueprint: null,
76
+ confidenceScore: 0,
77
+ confidenceGap: 0,
78
+ needsManualCorrection: true,
79
+ };
80
+ }
81
+
82
+ candidates.sort((leftCandidate, rightCandidate) => rightCandidate.confidenceScore - leftCandidate.confidenceScore);
83
+ const strongestCandidate = candidates[0];
84
+ const secondStrongestCandidate = candidates[1];
85
+ const confidenceGap = secondStrongestCandidate
86
+ ? Number((strongestCandidate.confidenceScore - secondStrongestCandidate.confidenceScore).toFixed(2))
87
+ : Number(strongestCandidate.confidenceScore.toFixed(2));
88
+
89
+ return {
90
+ recommendedStack: strongestCandidate.stackFileName,
91
+ recommendedBlueprint: BLUEPRINT_RECOMMENDATIONS[strongestCandidate.stackFileName] || null,
92
+ confidenceScore: strongestCandidate.confidenceScore,
93
+ confidenceGap,
94
+ needsManualCorrection: confidenceGap < AMBIGUITY_THRESHOLD,
95
+ };
96
+ }
97
+
98
+ function runBenchmark() {
99
+ let passingFixtureCount = 0;
100
+ let manualCorrectionCount = 0;
101
+
102
+ const fixtureResults = BENCHMARK_FIXTURES.map((benchmarkFixture) => {
103
+ const detectionResult = detectProjectFromMarkers(benchmarkFixture.markers);
104
+ const isCorrect = detectionResult.recommendedStack === benchmarkFixture.expectedStack;
105
+
106
+ if (isCorrect) {
107
+ passingFixtureCount += 1;
108
+ }
109
+
110
+ if (detectionResult.needsManualCorrection) {
111
+ manualCorrectionCount += 1;
112
+ }
113
+
114
+ return {
115
+ fixtureName: benchmarkFixture.fixtureName,
116
+ expectedStack: benchmarkFixture.expectedStack,
117
+ detectedStack: detectionResult.recommendedStack,
118
+ confidenceGap: detectionResult.confidenceGap,
119
+ needsManualCorrection: detectionResult.needsManualCorrection,
120
+ isCorrect,
121
+ };
122
+ });
123
+
124
+ const totalFixtureCount = BENCHMARK_FIXTURES.length;
125
+ const top1Accuracy = Number((passingFixtureCount / totalFixtureCount).toFixed(4));
126
+ const manualCorrectionRate = Number((manualCorrectionCount / totalFixtureCount).toFixed(4));
127
+
128
+ return {
129
+ generatedAt: new Date().toISOString(),
130
+ fixtureCount: totalFixtureCount,
131
+ top1Accuracy,
132
+ manualCorrectionRate,
133
+ fixtures: fixtureResults,
134
+ };
135
+ }
136
+
137
+ const benchmarkResult = runBenchmark();
138
+ console.log(JSON.stringify(benchmarkResult, null, 2));