@qulib/core 0.3.1 → 0.4.1
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/dist/analyze.d.ts +2 -0
- package/dist/analyze.d.ts.map +1 -1
- package/dist/analyze.js +29 -1
- package/dist/harness/decision-logger.d.ts +1 -0
- package/dist/harness/decision-logger.d.ts.map +1 -1
- package/dist/harness/decision-logger.js +15 -22
- package/dist/harness/run-options.d.ts +3 -0
- package/dist/harness/run-options.d.ts.map +1 -1
- package/dist/harness/state-manager.d.ts +3 -0
- package/dist/harness/state-manager.d.ts.map +1 -1
- package/dist/harness/state-manager.js +15 -18
- package/dist/index.d.ts +9 -1
- package/dist/index.d.ts.map +1 -1
- package/dist/index.js +5 -0
- package/dist/llm/cost-intelligence.d.ts +13 -0
- package/dist/llm/cost-intelligence.d.ts.map +1 -1
- package/dist/llm/cost-intelligence.js +13 -0
- package/dist/llm/provider-registry.d.ts +9 -0
- package/dist/llm/provider-registry.d.ts.map +1 -0
- package/dist/llm/provider-registry.js +15 -0
- package/dist/llm/provider.d.ts +9 -11
- package/dist/llm/provider.d.ts.map +1 -1
- package/dist/llm/provider.interface.d.ts +16 -0
- package/dist/llm/provider.interface.d.ts.map +1 -0
- package/dist/llm/provider.interface.js +1 -0
- package/dist/llm/provider.js +8 -51
- package/dist/llm/providers/anthropic.d.ts +16 -0
- package/dist/llm/providers/anthropic.d.ts.map +1 -0
- package/dist/llm/providers/anthropic.js +104 -0
- package/dist/phases/act.d.ts.map +1 -1
- package/dist/phases/act.js +20 -6
- package/dist/phases/observe.d.ts.map +1 -1
- package/dist/phases/observe.js +20 -2
- package/dist/phases/think-finalize.d.ts.map +1 -1
- package/dist/phases/think-finalize.js +12 -3
- package/dist/phases/think.d.ts.map +1 -1
- package/dist/phases/think.js +14 -2
- package/dist/schemas/automation-maturity.schema.d.ts +78 -0
- package/dist/schemas/automation-maturity.schema.d.ts.map +1 -0
- package/dist/schemas/automation-maturity.schema.js +24 -0
- package/dist/schemas/config.schema.d.ts +266 -73
- package/dist/schemas/config.schema.d.ts.map +1 -1
- package/dist/schemas/config.schema.js +30 -18
- package/dist/schemas/gap-analysis.schema.d.ts +6 -6
- package/dist/schemas/index.d.ts +2 -1
- package/dist/schemas/index.d.ts.map +1 -1
- package/dist/schemas/index.js +2 -1
- package/dist/schemas/public-surface.schema.d.ts +4 -4
- package/dist/schemas/repo-analysis.schema.d.ts +134 -0
- package/dist/schemas/repo-analysis.schema.d.ts.map +1 -1
- package/dist/schemas/repo-analysis.schema.js +29 -0
- package/dist/telemetry/emit.d.ts +3 -0
- package/dist/telemetry/emit.d.ts.map +1 -0
- package/dist/telemetry/emit.js +11 -0
- package/dist/telemetry/telemetry.interface.d.ts +13 -0
- package/dist/telemetry/telemetry.interface.d.ts.map +1 -0
- package/dist/telemetry/telemetry.interface.js +3 -0
- package/dist/tools/auth-detector.d.ts.map +1 -1
- package/dist/tools/auth-detector.js +205 -26
- package/dist/tools/auth-surface-analyzer.d.ts.map +1 -1
- package/dist/tools/auth-surface-analyzer.js +26 -10
- package/dist/tools/automation-maturity.d.ts +4 -0
- package/dist/tools/automation-maturity.d.ts.map +1 -0
- package/dist/tools/automation-maturity.js +163 -0
- package/dist/tools/framework-detector.d.ts +15 -0
- package/dist/tools/framework-detector.d.ts.map +1 -0
- package/dist/tools/framework-detector.js +153 -0
- package/dist/tools/gap-engine.d.ts +1 -1
- package/dist/tools/gap-engine.d.ts.map +1 -1
- package/dist/tools/gap-engine.js +13 -3
- package/dist/tools/repo-scanner.d.ts +16 -0
- package/dist/tools/repo-scanner.d.ts.map +1 -1
- package/dist/tools/repo-scanner.js +31 -2
- package/package.json +11 -1
|
@@ -0,0 +1,163 @@
|
|
|
1
|
+
import { existsSync, readdirSync, statSync } from 'node:fs';
|
|
2
|
+
import { join } from 'node:path';
|
|
3
|
+
import { AutomationMaturitySchema } from '../schemas/automation-maturity.schema.js';
|
|
4
|
+
/**
|
|
5
|
+
* Dimension weights (sum = 1). Breadth + harness adoption dominate: shipping risk is mostly
|
|
6
|
+
* untested routes and missing Playwright/Cypress-level coverage.
|
|
7
|
+
*/
|
|
8
|
+
const W_TEST_BREADTH = 0.28;
|
|
9
|
+
const W_FRAMEWORK = 0.22;
|
|
10
|
+
const W_TEST_ID = 0.18;
|
|
11
|
+
const W_CI = 0.14;
|
|
12
|
+
const W_AUTH_TESTS = 0.1;
|
|
13
|
+
const W_COMPONENT_RATIO = 0.08;
|
|
14
|
+
function hasCiAtRoot(repoPath) {
|
|
15
|
+
const ev = [];
|
|
16
|
+
const gh = join(repoPath, '.github', 'workflows');
|
|
17
|
+
if (existsSync(gh) && statSync(gh).isDirectory()) {
|
|
18
|
+
try {
|
|
19
|
+
const files = readdirSync(gh).filter((f) => f.endsWith('.yml') || f.endsWith('.yaml'));
|
|
20
|
+
if (files.length > 0) {
|
|
21
|
+
ev.push(`.github/workflows (${files.length} workflow file(s))`);
|
|
22
|
+
return { ok: true, evidence: ev };
|
|
23
|
+
}
|
|
24
|
+
}
|
|
25
|
+
catch {
|
|
26
|
+
/* ignore */
|
|
27
|
+
}
|
|
28
|
+
}
|
|
29
|
+
if (existsSync(join(repoPath, '.circleci'))) {
|
|
30
|
+
ev.push('.circleci/ present');
|
|
31
|
+
return { ok: true, evidence: ev };
|
|
32
|
+
}
|
|
33
|
+
for (const f of ['.gitlab-ci.yml', 'Jenkinsfile']) {
|
|
34
|
+
if (existsSync(join(repoPath, f))) {
|
|
35
|
+
ev.push(`${f} present`);
|
|
36
|
+
return { ok: true, evidence: ev };
|
|
37
|
+
}
|
|
38
|
+
}
|
|
39
|
+
return { ok: false, evidence: ['No GitHub Actions, CircleCI, GitLab CI, or Jenkinsfile detected at repo root'] };
|
|
40
|
+
}
|
|
41
|
+
function scoreLevel(overall) {
|
|
42
|
+
if (overall < 20)
|
|
43
|
+
return { level: 1, label: 'L1 — nascent automation' };
|
|
44
|
+
if (overall < 40)
|
|
45
|
+
return { level: 2, label: 'L2 — emerging coverage' };
|
|
46
|
+
if (overall < 60)
|
|
47
|
+
return { level: 3, label: 'L3 — building maturity' };
|
|
48
|
+
if (overall < 80)
|
|
49
|
+
return { level: 4, label: 'L4 — strong automation' };
|
|
50
|
+
return { level: 5, label: 'L5 — advanced QA automation' };
|
|
51
|
+
}
|
|
52
|
+
export function computeAutomationMaturity(repo) {
|
|
53
|
+
const routePaths = [...new Set(repo.routes.map((r) => r.path))];
|
|
54
|
+
let coveredRoutes = 0;
|
|
55
|
+
for (const p of routePaths) {
|
|
56
|
+
const covered = repo.testFiles.some((tf) => tf.coveredPaths.some((c) => p === c || (c !== '/' && p.startsWith(c))));
|
|
57
|
+
if (covered)
|
|
58
|
+
coveredRoutes++;
|
|
59
|
+
}
|
|
60
|
+
const breadthScore = routePaths.length === 0 ? 100 : Math.round((100 * coveredRoutes) / routePaths.length);
|
|
61
|
+
const breadthDim = {
|
|
62
|
+
dimension: 'test-coverage-breadth',
|
|
63
|
+
score: breadthScore,
|
|
64
|
+
weight: W_TEST_BREADTH,
|
|
65
|
+
evidence: routePaths.length === 0
|
|
66
|
+
? ['No static routes inferred from repo layout']
|
|
67
|
+
: [
|
|
68
|
+
`${coveredRoutes}/${routePaths.length} inferred routes appear in at least one test coveredPaths`,
|
|
69
|
+
],
|
|
70
|
+
recommendations: breadthScore >= 80
|
|
71
|
+
? []
|
|
72
|
+
: ['Add route-level smoke tests that assert critical paths referenced in production URLs.'],
|
|
73
|
+
};
|
|
74
|
+
const types = new Set(repo.testFiles.map((t) => t.type));
|
|
75
|
+
let frameworkScore = 0;
|
|
76
|
+
const fwEvidence = [`Test runners seen: ${[...types].join(', ') || 'none'}`];
|
|
77
|
+
if (types.has('playwright') || types.has('cypress-e2e') || types.has('cypress-component')) {
|
|
78
|
+
frameworkScore = 100;
|
|
79
|
+
fwEvidence.push('Playwright or Cypress present — good browser harness signal.');
|
|
80
|
+
}
|
|
81
|
+
else if (types.has('jest') || types.has('vitest')) {
|
|
82
|
+
frameworkScore = 55;
|
|
83
|
+
fwEvidence.push('Jest/Vitest only — add Playwright or Cypress for deployment-facing checks.');
|
|
84
|
+
}
|
|
85
|
+
else if (repo.testFiles.length > 0) {
|
|
86
|
+
frameworkScore = 30;
|
|
87
|
+
fwEvidence.push('Tests exist but no recognized browser harness in scanned files.');
|
|
88
|
+
}
|
|
89
|
+
else {
|
|
90
|
+
frameworkScore = 0;
|
|
91
|
+
fwEvidence.push('No test files matched qulib scan globs.');
|
|
92
|
+
}
|
|
93
|
+
const frameworkDim = {
|
|
94
|
+
dimension: 'framework-adoption',
|
|
95
|
+
score: frameworkScore,
|
|
96
|
+
weight: W_FRAMEWORK,
|
|
97
|
+
evidence: fwEvidence,
|
|
98
|
+
recommendations: frameworkScore >= 80 ? [] : ['Standardize on Playwright or Cypress for E2E against deployed URLs.'],
|
|
99
|
+
};
|
|
100
|
+
const hygienePenalty = Math.min(100, repo.missingTestIds.length * 6);
|
|
101
|
+
const hygieneScore = Math.max(0, 100 - hygienePenalty);
|
|
102
|
+
const hygieneDim = {
|
|
103
|
+
dimension: 'test-id-hygiene',
|
|
104
|
+
score: hygieneScore,
|
|
105
|
+
weight: W_TEST_ID,
|
|
106
|
+
evidence: [
|
|
107
|
+
`${repo.missingTestIds.length} TSX file(s) with interactive markup but no data-testid (heuristic scan).`,
|
|
108
|
+
],
|
|
109
|
+
recommendations: hygieneScore >= 85 ? [] : ['Add stable data-testid (or role-based selectors) on interactive components used in tests.'],
|
|
110
|
+
};
|
|
111
|
+
const ci = hasCiAtRoot(repo.repoPath);
|
|
112
|
+
const ciDim = {
|
|
113
|
+
dimension: 'ci-integration',
|
|
114
|
+
score: ci.ok ? 100 : 0,
|
|
115
|
+
weight: W_CI,
|
|
116
|
+
evidence: ci.evidence,
|
|
117
|
+
recommendations: ci.ok ? [] : ['Add a CI workflow that runs unit/E2E tests on every PR.'],
|
|
118
|
+
};
|
|
119
|
+
const authRe = /\/(login|auth|signin)(\/|$)/i;
|
|
120
|
+
const authCovered = repo.testFiles.some((tf) => tf.coveredPaths.some((c) => authRe.test(c)));
|
|
121
|
+
const authScore = authCovered ? 90 : 25;
|
|
122
|
+
const authDim = {
|
|
123
|
+
dimension: 'auth-test-coverage',
|
|
124
|
+
score: authScore,
|
|
125
|
+
weight: W_AUTH_TESTS,
|
|
126
|
+
evidence: authCovered
|
|
127
|
+
? ['At least one test references /login, /auth, or /signin in coveredPaths.']
|
|
128
|
+
: ['No obvious auth-route coverage in extracted test path strings.'],
|
|
129
|
+
recommendations: authCovered ? [] : ['Add focused tests for sign-in and post-auth landing behavior.'],
|
|
130
|
+
};
|
|
131
|
+
const cypressE2e = repo.testFiles.filter((t) => t.type === 'cypress-e2e').length;
|
|
132
|
+
const cypressComp = repo.testFiles.filter((t) => t.type === 'cypress-component').length;
|
|
133
|
+
const cypressTotal = cypressE2e + cypressComp;
|
|
134
|
+
const compRatioScore = cypressTotal === 0 ? 50 : Math.round((100 * cypressComp) / cypressTotal);
|
|
135
|
+
const compDim = {
|
|
136
|
+
dimension: 'component-test-ratio',
|
|
137
|
+
score: compRatioScore,
|
|
138
|
+
weight: W_COMPONENT_RATIO,
|
|
139
|
+
evidence: [
|
|
140
|
+
`Cypress e2e files (matched): ${cypressE2e}, component: ${cypressComp}.`,
|
|
141
|
+
],
|
|
142
|
+
recommendations: cypressComp === 0 || cypressTotal === 0
|
|
143
|
+
? []
|
|
144
|
+
: ['Balance component vs E2E Cypress tests so critical flows stay fast in CI.'],
|
|
145
|
+
};
|
|
146
|
+
const dimensions = [breadthDim, frameworkDim, hygieneDim, ciDim, authDim, compDim];
|
|
147
|
+
const overallScore = Math.round(dimensions.reduce((s, d) => s + d.score * d.weight, 0));
|
|
148
|
+
const { level, label } = scoreLevel(overallScore);
|
|
149
|
+
const topRecommendations = [...dimensions]
|
|
150
|
+
.sort((a, b) => a.score - b.score)
|
|
151
|
+
.flatMap((d) => d.recommendations)
|
|
152
|
+
.filter(Boolean)
|
|
153
|
+
.slice(0, 8);
|
|
154
|
+
return AutomationMaturitySchema.parse({
|
|
155
|
+
computedAt: new Date().toISOString(),
|
|
156
|
+
repoPath: repo.repoPath,
|
|
157
|
+
overallScore,
|
|
158
|
+
level,
|
|
159
|
+
label,
|
|
160
|
+
dimensions,
|
|
161
|
+
topRecommendations,
|
|
162
|
+
});
|
|
163
|
+
}
|
|
@@ -0,0 +1,15 @@
|
|
|
1
|
+
/**
|
|
2
|
+
* @module framework-detector
|
|
3
|
+
* @packageBoundary @qulib/core (candidate: @qulib/analyzer)
|
|
4
|
+
*
|
|
5
|
+
* Framework detection runs during the observe phase as part of repo scanning.
|
|
6
|
+
* It is a pure static analysis operation with no browser or LLM dependency.
|
|
7
|
+
* Move this to @qulib/analyzer when that package is created.
|
|
8
|
+
*
|
|
9
|
+
* // TODO(@qulib/analyzer): When @qulib/analyzer is extracted, this module should move there.
|
|
10
|
+
* // It is currently embedded in @qulib/core because repo scanning is part of the observe phase.
|
|
11
|
+
* // The package boundary decision: core = runtime QA analysis, analyzer = static repo intelligence.
|
|
12
|
+
*/
|
|
13
|
+
import { type FrameworkDetectionResult } from '../schemas/repo-analysis.schema.js';
|
|
14
|
+
export declare function detectFramework(repoPath: string): Promise<FrameworkDetectionResult>;
|
|
15
|
+
//# sourceMappingURL=framework-detector.d.ts.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"framework-detector.d.ts","sourceRoot":"","sources":["../../src/tools/framework-detector.ts"],"names":[],"mappings":"AAAA;;;;;;;;;;;GAWG;AAKH,OAAO,EAA4B,KAAK,wBAAwB,EAAE,MAAM,oCAAoC,CAAC;AAuB7G,wBAAsB,eAAe,CAAC,QAAQ,EAAE,MAAM,GAAG,OAAO,CAAC,wBAAwB,CAAC,CA4GzF"}
|
|
@@ -0,0 +1,153 @@
|
|
|
1
|
+
/**
|
|
2
|
+
* @module framework-detector
|
|
3
|
+
* @packageBoundary @qulib/core (candidate: @qulib/analyzer)
|
|
4
|
+
*
|
|
5
|
+
* Framework detection runs during the observe phase as part of repo scanning.
|
|
6
|
+
* It is a pure static analysis operation with no browser or LLM dependency.
|
|
7
|
+
* Move this to @qulib/analyzer when that package is created.
|
|
8
|
+
*
|
|
9
|
+
* // TODO(@qulib/analyzer): When @qulib/analyzer is extracted, this module should move there.
|
|
10
|
+
* // It is currently embedded in @qulib/core because repo scanning is part of the observe phase.
|
|
11
|
+
* // The package boundary decision: core = runtime QA analysis, analyzer = static repo intelligence.
|
|
12
|
+
*/
|
|
13
|
+
import { access, readFile } from 'node:fs/promises';
|
|
14
|
+
import { constants } from 'node:fs';
|
|
15
|
+
import { join } from 'node:path';
|
|
16
|
+
import { FrameworkDetectionSchema } from '../schemas/repo-analysis.schema.js';
|
|
17
|
+
async function fileExists(repoPath, rel) {
|
|
18
|
+
try {
|
|
19
|
+
await access(join(repoPath, rel), constants.F_OK);
|
|
20
|
+
return true;
|
|
21
|
+
}
|
|
22
|
+
catch {
|
|
23
|
+
return false;
|
|
24
|
+
}
|
|
25
|
+
}
|
|
26
|
+
function depNames(pkg) {
|
|
27
|
+
return new Set([
|
|
28
|
+
...Object.keys(pkg.dependencies ?? {}),
|
|
29
|
+
...Object.keys(pkg.devDependencies ?? {}),
|
|
30
|
+
]);
|
|
31
|
+
}
|
|
32
|
+
export async function detectFramework(repoPath) {
|
|
33
|
+
const evidence = [];
|
|
34
|
+
const testFrameworks = new Set();
|
|
35
|
+
let pkg = {};
|
|
36
|
+
try {
|
|
37
|
+
const raw = await readFile(join(repoPath, 'package.json'), 'utf8');
|
|
38
|
+
pkg = JSON.parse(raw);
|
|
39
|
+
evidence.push('read package.json');
|
|
40
|
+
}
|
|
41
|
+
catch {
|
|
42
|
+
evidence.push('package.json missing or unreadable');
|
|
43
|
+
}
|
|
44
|
+
const deps = depNames(pkg);
|
|
45
|
+
const has = (n) => deps.has(n);
|
|
46
|
+
if (has('@playwright/test') || has('playwright')) {
|
|
47
|
+
testFrameworks.add('playwright');
|
|
48
|
+
evidence.push('dependency: @playwright/test or playwright');
|
|
49
|
+
}
|
|
50
|
+
if (has('cypress')) {
|
|
51
|
+
testFrameworks.add('cypress-e2e');
|
|
52
|
+
evidence.push('dependency: cypress');
|
|
53
|
+
}
|
|
54
|
+
if (has('jest')) {
|
|
55
|
+
testFrameworks.add('jest');
|
|
56
|
+
evidence.push('dependency: jest');
|
|
57
|
+
}
|
|
58
|
+
if (has('vitest')) {
|
|
59
|
+
testFrameworks.add('vitest');
|
|
60
|
+
evidence.push('dependency: vitest');
|
|
61
|
+
}
|
|
62
|
+
if (testFrameworks.size === 0) {
|
|
63
|
+
testFrameworks.add('other');
|
|
64
|
+
}
|
|
65
|
+
const nextCfg = (await fileExists(repoPath, 'next.config.js')) ||
|
|
66
|
+
(await fileExists(repoPath, 'next.config.mjs')) ||
|
|
67
|
+
(await fileExists(repoPath, 'next.config.ts'));
|
|
68
|
+
const nuxtCfg = await fileExists(repoPath, 'nuxt.config.ts');
|
|
69
|
+
const svelteCfg = await fileExists(repoPath, 'svelte.config.js');
|
|
70
|
+
const astroCfg = await fileExists(repoPath, 'astro.config.mjs');
|
|
71
|
+
const remixCfg = await fileExists(repoPath, 'remix.config.js');
|
|
72
|
+
const viteCfg = await fileExists(repoPath, 'vite.config.ts');
|
|
73
|
+
if (nextCfg)
|
|
74
|
+
evidence.push('found next.config.*');
|
|
75
|
+
if (nuxtCfg)
|
|
76
|
+
evidence.push('found nuxt.config.ts');
|
|
77
|
+
if (svelteCfg)
|
|
78
|
+
evidence.push('found svelte.config.js');
|
|
79
|
+
if (astroCfg)
|
|
80
|
+
evidence.push('found astro.config.mjs');
|
|
81
|
+
if (remixCfg)
|
|
82
|
+
evidence.push('found remix.config.js');
|
|
83
|
+
if (viteCfg)
|
|
84
|
+
evidence.push('found vite.config.ts');
|
|
85
|
+
const hasAppDir = await fileExists(repoPath, 'app');
|
|
86
|
+
const hasPagesDir = await fileExists(repoPath, 'pages');
|
|
87
|
+
if (has('next') && hasAppDir)
|
|
88
|
+
evidence.push('Next.js app/ directory present');
|
|
89
|
+
if (has('next') && hasPagesDir)
|
|
90
|
+
evidence.push('Next.js pages/ directory present');
|
|
91
|
+
if (has('@remix-run/react') || has('@remix-run/node'))
|
|
92
|
+
evidence.push('Remix packages in package.json');
|
|
93
|
+
if (has('nuxt') || has('nuxt3'))
|
|
94
|
+
evidence.push('Nuxt in package.json');
|
|
95
|
+
if (has('@sveltejs/kit'))
|
|
96
|
+
evidence.push('@sveltejs/kit in package.json');
|
|
97
|
+
if (has('astro'))
|
|
98
|
+
evidence.push('astro in package.json');
|
|
99
|
+
if (has('vite') && !has('next'))
|
|
100
|
+
evidence.push('vite in package.json (non-Next)');
|
|
101
|
+
let primary = 'unknown';
|
|
102
|
+
let confidence = 'low';
|
|
103
|
+
if (has('next')) {
|
|
104
|
+
if (hasAppDir && (await fileExists(repoPath, join('app', 'layout.tsx')))) {
|
|
105
|
+
primary = 'nextjs-app-router';
|
|
106
|
+
confidence = nextCfg || hasAppDir ? 'high' : 'medium';
|
|
107
|
+
}
|
|
108
|
+
else if (hasPagesDir) {
|
|
109
|
+
primary = 'nextjs-pages-router';
|
|
110
|
+
confidence = nextCfg || hasPagesDir ? 'high' : 'medium';
|
|
111
|
+
}
|
|
112
|
+
else {
|
|
113
|
+
primary = 'nextjs-app-router';
|
|
114
|
+
confidence = 'medium';
|
|
115
|
+
evidence.push('next detected without clear app/ vs pages/ layout');
|
|
116
|
+
}
|
|
117
|
+
}
|
|
118
|
+
else if (has('@remix-run/react') || remixCfg) {
|
|
119
|
+
primary = 'remix';
|
|
120
|
+
confidence = remixCfg ? 'high' : 'medium';
|
|
121
|
+
}
|
|
122
|
+
else if (has('nuxt') || nuxtCfg) {
|
|
123
|
+
primary = 'nuxt';
|
|
124
|
+
confidence = nuxtCfg ? 'high' : 'medium';
|
|
125
|
+
}
|
|
126
|
+
else if (has('@sveltejs/kit') || svelteCfg) {
|
|
127
|
+
primary = 'sveltekit';
|
|
128
|
+
confidence = svelteCfg ? 'high' : 'medium';
|
|
129
|
+
}
|
|
130
|
+
else if (has('astro') || astroCfg) {
|
|
131
|
+
primary = 'astro';
|
|
132
|
+
confidence = astroCfg ? 'high' : 'medium';
|
|
133
|
+
}
|
|
134
|
+
else if (viteCfg && !has('next')) {
|
|
135
|
+
primary = 'vite';
|
|
136
|
+
confidence = 'medium';
|
|
137
|
+
}
|
|
138
|
+
else if (has('express')) {
|
|
139
|
+
primary = 'express';
|
|
140
|
+
confidence = 'medium';
|
|
141
|
+
evidence.push('express listed in dependencies');
|
|
142
|
+
}
|
|
143
|
+
else {
|
|
144
|
+
/* keep unknown */
|
|
145
|
+
}
|
|
146
|
+
const raw = {
|
|
147
|
+
primary,
|
|
148
|
+
confidence,
|
|
149
|
+
evidence,
|
|
150
|
+
testFrameworks: [...testFrameworks],
|
|
151
|
+
};
|
|
152
|
+
return FrameworkDetectionSchema.parse(raw);
|
|
153
|
+
}
|
|
@@ -2,7 +2,7 @@ import { type GapAnalysis, type Gap } from '../schemas/gap-analysis.schema.js';
|
|
|
2
2
|
import type { RouteInventory } from '../schemas/route-inventory.schema.js';
|
|
3
3
|
import type { RepoAnalysis } from '../schemas/repo-analysis.schema.js';
|
|
4
4
|
import type { HarnessConfig } from '../schemas/config.schema.js';
|
|
5
|
-
export declare function computeQualityScoreFromGaps(gaps: Gap[]): number;
|
|
5
|
+
export declare function computeQualityScoreFromGaps(gaps: Gap[], scoringWeights?: HarnessConfig['scoringWeights']): number;
|
|
6
6
|
export declare function computeCoverageScore(routes: RouteInventory): number | null;
|
|
7
7
|
export declare function analyzeGaps(routes: RouteInventory, repo: RepoAnalysis | null, mode: 'url-only' | 'url-repo', config: HarnessConfig): Omit<GapAnalysis, 'scenarios' | 'generatedTests'>;
|
|
8
8
|
//# sourceMappingURL=gap-engine.d.ts.map
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"gap-engine.d.ts","sourceRoot":"","sources":["../../src/tools/gap-engine.ts"],"names":[],"mappings":"AACA,OAAO,EAAa,KAAK,WAAW,EAAE,KAAK,GAAG,EAAE,MAAM,mCAAmC,CAAC;AAC1F,OAAO,KAAK,EAAE,cAAc,EAAE,MAAM,sCAAsC,CAAC;AAC3E,OAAO,KAAK,EAAE,YAAY,EAAE,MAAM,oCAAoC,CAAC;AACvE,OAAO,KAAK,EAAE,aAAa,EAAE,MAAM,6BAA6B,CAAC;
|
|
1
|
+
{"version":3,"file":"gap-engine.d.ts","sourceRoot":"","sources":["../../src/tools/gap-engine.ts"],"names":[],"mappings":"AACA,OAAO,EAAa,KAAK,WAAW,EAAE,KAAK,GAAG,EAAE,MAAM,mCAAmC,CAAC;AAC1F,OAAO,KAAK,EAAE,cAAc,EAAE,MAAM,sCAAsC,CAAC;AAC3E,OAAO,KAAK,EAAE,YAAY,EAAE,MAAM,oCAAoC,CAAC;AACvE,OAAO,KAAK,EAAE,aAAa,EAAE,MAAM,6BAA6B,CAAC;AAQjE,wBAAgB,2BAA2B,CACzC,IAAI,EAAE,GAAG,EAAE,EACX,cAAc,CAAC,EAAE,aAAa,CAAC,gBAAgB,CAAC,GAC/C,MAAM,CAkBR;AAED,wBAAgB,oBAAoB,CAAC,MAAM,EAAE,cAAc,GAAG,MAAM,GAAG,IAAI,CAa1E;AAED,wBAAgB,WAAW,CACzB,MAAM,EAAE,cAAc,EACtB,IAAI,EAAE,YAAY,GAAG,IAAI,EACzB,IAAI,EAAE,UAAU,GAAG,UAAU,EAC7B,MAAM,EAAE,aAAa,GACpB,IAAI,CAAC,WAAW,EAAE,WAAW,GAAG,gBAAgB,CAAC,CAqGnD"}
|
package/dist/tools/gap-engine.js
CHANGED
|
@@ -1,6 +1,10 @@
|
|
|
1
1
|
import { randomUUID } from 'node:crypto';
|
|
2
2
|
import { GapSchema } from '../schemas/gap-analysis.schema.js';
|
|
3
|
-
|
|
3
|
+
// TODO: Add category-specific weight overrides (e.g., auth-surface gaps should cost more than untested-route gaps by default).
|
|
4
|
+
// Requires a 2D weight matrix: { [severity]: { [category]: number } }.
|
|
5
|
+
// Deferred until there is empirical data from real scan runs to calibrate.
|
|
6
|
+
const DEFAULT_SCORING_WEIGHTS = { critical: 25, high: 20, medium: 8, low: 3 };
|
|
7
|
+
export function computeQualityScoreFromGaps(gaps, scoringWeights) {
|
|
4
8
|
let critical = 0;
|
|
5
9
|
let high = 0;
|
|
6
10
|
let medium = 0;
|
|
@@ -15,7 +19,13 @@ export function computeQualityScoreFromGaps(gaps) {
|
|
|
15
19
|
else
|
|
16
20
|
low++;
|
|
17
21
|
}
|
|
18
|
-
|
|
22
|
+
const w = {
|
|
23
|
+
critical: scoringWeights?.critical ?? DEFAULT_SCORING_WEIGHTS.critical,
|
|
24
|
+
high: scoringWeights?.high ?? DEFAULT_SCORING_WEIGHTS.high,
|
|
25
|
+
medium: scoringWeights?.medium ?? DEFAULT_SCORING_WEIGHTS.medium,
|
|
26
|
+
low: scoringWeights?.low ?? DEFAULT_SCORING_WEIGHTS.low,
|
|
27
|
+
};
|
|
28
|
+
return Math.max(0, 100 - critical * w.critical - high * w.high - medium * w.medium - low * w.low);
|
|
19
29
|
}
|
|
20
30
|
export function computeCoverageScore(routes) {
|
|
21
31
|
const scanned = routes.routes.length;
|
|
@@ -104,7 +114,7 @@ export function analyzeGaps(routes, repo, mode, config) {
|
|
|
104
114
|
});
|
|
105
115
|
}
|
|
106
116
|
}
|
|
107
|
-
const releaseConfidence = computeQualityScoreFromGaps(gaps);
|
|
117
|
+
const releaseConfidence = computeQualityScoreFromGaps(gaps, config.scoringWeights);
|
|
108
118
|
const pagesScanned = routes.routes.length;
|
|
109
119
|
let coverageWarning;
|
|
110
120
|
if (routes.budgetExceeded) {
|
|
@@ -1,3 +1,19 @@
|
|
|
1
|
+
/**
|
|
2
|
+
* @module repo-scanner
|
|
3
|
+
* @packageBoundary @qulib/core (candidate: @qulib/analyzer)
|
|
4
|
+
*
|
|
5
|
+
* This module performs static analysis of a repository's file structure.
|
|
6
|
+
* It is currently embedded in @qulib/core because repo scanning is part of
|
|
7
|
+
* the observe phase and @qulib/core is the only consumer.
|
|
8
|
+
*
|
|
9
|
+
* Extraction to @qulib/analyzer is appropriate when:
|
|
10
|
+
* 1. A consumer needs repo analysis without URL crawling
|
|
11
|
+
* 2. The module grows to include PRD/Jira/Confluence ingestion
|
|
12
|
+
* 3. A standalone CLI command `qulib analyze-repo` is needed
|
|
13
|
+
*
|
|
14
|
+
* Before extraction: ensure RepoAnalysis schema is re-exported from @qulib/analyzer
|
|
15
|
+
* and @qulib/core depends on @qulib/analyzer (not the reverse).
|
|
16
|
+
*/
|
|
1
17
|
import { type RepoAnalysis } from '../schemas/repo-analysis.schema.js';
|
|
2
18
|
export declare function scanRepo(repoPath: string): Promise<RepoAnalysis>;
|
|
3
19
|
//# sourceMappingURL=repo-scanner.d.ts.map
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"repo-scanner.d.ts","sourceRoot":"","sources":["../../src/tools/repo-scanner.ts"],"names":[],"mappings":"
|
|
1
|
+
{"version":3,"file":"repo-scanner.d.ts","sourceRoot":"","sources":["../../src/tools/repo-scanner.ts"],"names":[],"mappings":"AAAA;;;;;;;;;;;;;;;GAeG;AAKH,OAAO,EAAsB,KAAK,YAAY,EAAE,MAAM,oCAAoC,CAAC;AAmC3F,wBAAsB,QAAQ,CAAC,QAAQ,EAAE,MAAM,GAAG,OAAO,CAAC,YAAY,CAAC,CAyItE"}
|
|
@@ -1,7 +1,25 @@
|
|
|
1
|
+
/**
|
|
2
|
+
* @module repo-scanner
|
|
3
|
+
* @packageBoundary @qulib/core (candidate: @qulib/analyzer)
|
|
4
|
+
*
|
|
5
|
+
* This module performs static analysis of a repository's file structure.
|
|
6
|
+
* It is currently embedded in @qulib/core because repo scanning is part of
|
|
7
|
+
* the observe phase and @qulib/core is the only consumer.
|
|
8
|
+
*
|
|
9
|
+
* Extraction to @qulib/analyzer is appropriate when:
|
|
10
|
+
* 1. A consumer needs repo analysis without URL crawling
|
|
11
|
+
* 2. The module grows to include PRD/Jira/Confluence ingestion
|
|
12
|
+
* 3. A standalone CLI command `qulib analyze-repo` is needed
|
|
13
|
+
*
|
|
14
|
+
* Before extraction: ensure RepoAnalysis schema is re-exported from @qulib/analyzer
|
|
15
|
+
* and @qulib/core depends on @qulib/analyzer (not the reverse).
|
|
16
|
+
*/
|
|
1
17
|
import { readFile } from 'node:fs/promises';
|
|
2
18
|
import { relative, basename } from 'node:path';
|
|
3
19
|
import glob from 'fast-glob';
|
|
4
20
|
import { RepoAnalysisSchema } from '../schemas/repo-analysis.schema.js';
|
|
21
|
+
import { detectFramework } from './framework-detector.js';
|
|
22
|
+
import { computeAutomationMaturity } from './automation-maturity.js';
|
|
5
23
|
const IGNORE_PATTERNS = ['**/node_modules/**', '**/.next/**', '**/dist/**', '**/build/**'];
|
|
6
24
|
function toPosix(path) {
|
|
7
25
|
return path.split('\\').join('/');
|
|
@@ -127,7 +145,7 @@ export async function scanRepo(repoPath) {
|
|
|
127
145
|
missingTestIds.push(rel);
|
|
128
146
|
}
|
|
129
147
|
}
|
|
130
|
-
|
|
148
|
+
const base = {
|
|
131
149
|
scannedAt: new Date().toISOString(),
|
|
132
150
|
repoPath,
|
|
133
151
|
routes,
|
|
@@ -143,5 +161,16 @@ export async function scanRepo(repoPath) {
|
|
|
143
161
|
existingE2eFiles,
|
|
144
162
|
existingComponentFiles,
|
|
145
163
|
},
|
|
146
|
-
}
|
|
164
|
+
};
|
|
165
|
+
let parsed = RepoAnalysisSchema.parse(base);
|
|
166
|
+
try {
|
|
167
|
+
const framework = await detectFramework(repoPath);
|
|
168
|
+
parsed = RepoAnalysisSchema.parse({ ...parsed, framework });
|
|
169
|
+
}
|
|
170
|
+
catch (error) {
|
|
171
|
+
const msg = error instanceof Error ? error.message : String(error);
|
|
172
|
+
console.warn(`[qulib] framework detection failed for ${repoPath}: ${msg}`);
|
|
173
|
+
}
|
|
174
|
+
const automationMaturity = computeAutomationMaturity(parsed);
|
|
175
|
+
return RepoAnalysisSchema.parse({ ...parsed, automationMaturity });
|
|
147
176
|
}
|
package/package.json
CHANGED
|
@@ -1,6 +1,6 @@
|
|
|
1
1
|
{
|
|
2
2
|
"name": "@qulib/core",
|
|
3
|
-
"version": "0.
|
|
3
|
+
"version": "0.4.1",
|
|
4
4
|
"description": "Qulib — analyze deployed web apps for honest quality gaps (CLI + programmatic API)",
|
|
5
5
|
"license": "MIT",
|
|
6
6
|
"author": "Tapesh Nagarwal",
|
|
@@ -13,6 +13,16 @@
|
|
|
13
13
|
"bugs": {
|
|
14
14
|
"url": "https://github.com/TapeshN/qulib/issues"
|
|
15
15
|
},
|
|
16
|
+
"keywords": [
|
|
17
|
+
"qa",
|
|
18
|
+
"quality",
|
|
19
|
+
"accessibility",
|
|
20
|
+
"gap-analysis",
|
|
21
|
+
"release-confidence",
|
|
22
|
+
"playwright",
|
|
23
|
+
"mcp",
|
|
24
|
+
"ai"
|
|
25
|
+
],
|
|
16
26
|
"publishConfig": {
|
|
17
27
|
"access": "public"
|
|
18
28
|
},
|