@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,104 @@
|
|
|
1
|
+
import { emitTelemetry } from '../../telemetry/emit.js';
|
|
2
|
+
const DEFAULT_MODEL = 'claude-sonnet-4-20250514';
|
|
3
|
+
function estimateTokensFromChars(chars) {
|
|
4
|
+
return Math.max(0, Math.ceil(chars / 4));
|
|
5
|
+
}
|
|
6
|
+
export class AnthropicProvider {
|
|
7
|
+
name = 'anthropic';
|
|
8
|
+
model;
|
|
9
|
+
telemetry;
|
|
10
|
+
sessionId;
|
|
11
|
+
constructor(options) {
|
|
12
|
+
this.model = options?.model ?? DEFAULT_MODEL;
|
|
13
|
+
this.telemetry = options?.telemetry;
|
|
14
|
+
this.sessionId = options?.sessionId ?? 'anonymous';
|
|
15
|
+
}
|
|
16
|
+
async call(prompt, maxOutputTokens) {
|
|
17
|
+
const apiKey = process.env.ANTHROPIC_API_KEY;
|
|
18
|
+
if (!apiKey)
|
|
19
|
+
throw new Error('ANTHROPIC_API_KEY is not set');
|
|
20
|
+
const started = Date.now();
|
|
21
|
+
emitTelemetry(this.telemetry, 'llm.call.started', this.sessionId, {
|
|
22
|
+
model: this.model,
|
|
23
|
+
promptLength: prompt.length,
|
|
24
|
+
provider: this.name,
|
|
25
|
+
});
|
|
26
|
+
try {
|
|
27
|
+
const response = await fetch('https://api.anthropic.com/v1/messages', {
|
|
28
|
+
method: 'POST',
|
|
29
|
+
headers: {
|
|
30
|
+
'x-api-key': apiKey,
|
|
31
|
+
'anthropic-version': '2023-06-01',
|
|
32
|
+
'content-type': 'application/json',
|
|
33
|
+
},
|
|
34
|
+
body: JSON.stringify({
|
|
35
|
+
model: this.model,
|
|
36
|
+
max_tokens: maxOutputTokens,
|
|
37
|
+
messages: [{ role: 'user', content: prompt }],
|
|
38
|
+
}),
|
|
39
|
+
});
|
|
40
|
+
if (!response.ok) {
|
|
41
|
+
const errBody = await response.text();
|
|
42
|
+
emitTelemetry(this.telemetry, 'llm.call.failed', this.sessionId, {
|
|
43
|
+
model: this.model,
|
|
44
|
+
error: `${response.status} ${errBody.slice(0, 500)}`,
|
|
45
|
+
provider: this.name,
|
|
46
|
+
});
|
|
47
|
+
throw new Error(`LLM call failed: ${response.status} ${errBody}`);
|
|
48
|
+
}
|
|
49
|
+
const data = (await response.json());
|
|
50
|
+
const text = data.content.find((b) => b.type === 'text')?.text ?? '';
|
|
51
|
+
const inTok = data.usage?.input_tokens;
|
|
52
|
+
const outTok = data.usage?.output_tokens;
|
|
53
|
+
const durationMs = Date.now() - started;
|
|
54
|
+
let result;
|
|
55
|
+
if (typeof inTok === 'number' && typeof outTok === 'number') {
|
|
56
|
+
result = {
|
|
57
|
+
text,
|
|
58
|
+
usage: {
|
|
59
|
+
provider: this.name,
|
|
60
|
+
model: data.model ?? this.model,
|
|
61
|
+
inputTokens: inTok,
|
|
62
|
+
outputTokens: outTok,
|
|
63
|
+
dataQuality: 'actual',
|
|
64
|
+
},
|
|
65
|
+
};
|
|
66
|
+
}
|
|
67
|
+
else {
|
|
68
|
+
const inputTokens = estimateTokensFromChars(prompt.length);
|
|
69
|
+
const outputTokens = estimateTokensFromChars(text.length);
|
|
70
|
+
result = {
|
|
71
|
+
text,
|
|
72
|
+
usage: {
|
|
73
|
+
provider: this.name,
|
|
74
|
+
model: data.model ?? this.model,
|
|
75
|
+
inputTokens,
|
|
76
|
+
outputTokens,
|
|
77
|
+
dataQuality: 'estimated',
|
|
78
|
+
},
|
|
79
|
+
};
|
|
80
|
+
}
|
|
81
|
+
const u = result.usage;
|
|
82
|
+
emitTelemetry(this.telemetry, 'llm.call.completed', this.sessionId, {
|
|
83
|
+
model: this.model,
|
|
84
|
+
inputTokens: u.inputTokens,
|
|
85
|
+
outputTokens: u.outputTokens,
|
|
86
|
+
durationMs,
|
|
87
|
+
provider: this.name,
|
|
88
|
+
});
|
|
89
|
+
return result;
|
|
90
|
+
}
|
|
91
|
+
catch (err) {
|
|
92
|
+
if (err instanceof Error && err.message.startsWith('LLM call failed:')) {
|
|
93
|
+
throw err;
|
|
94
|
+
}
|
|
95
|
+
const msg = err instanceof Error ? err.message : String(err);
|
|
96
|
+
emitTelemetry(this.telemetry, 'llm.call.failed', this.sessionId, {
|
|
97
|
+
model: this.model,
|
|
98
|
+
error: msg.slice(0, 500),
|
|
99
|
+
provider: this.name,
|
|
100
|
+
});
|
|
101
|
+
throw err;
|
|
102
|
+
}
|
|
103
|
+
}
|
|
104
|
+
}
|
package/dist/phases/act.d.ts.map
CHANGED
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"act.d.ts","sourceRoot":"","sources":["../../src/phases/act.ts"],"names":[],"mappings":"AACA,OAAO,KAAK,EAAE,aAAa,EAAE,MAAM,6BAA6B,CAAC;AACjE,OAAO,KAAK,EAAE,WAAW,EAAE,MAAM,mCAAmC,CAAC;AAIrE,OAAO,KAAK,EAAE,mBAAmB,EAAE,MAAM,2BAA2B,CAAC;
|
|
1
|
+
{"version":3,"file":"act.d.ts","sourceRoot":"","sources":["../../src/phases/act.ts"],"names":[],"mappings":"AACA,OAAO,KAAK,EAAE,aAAa,EAAE,MAAM,6BAA6B,CAAC;AACjE,OAAO,KAAK,EAAE,WAAW,EAAE,MAAM,mCAAmC,CAAC;AAIrE,OAAO,KAAK,EAAE,mBAAmB,EAAE,MAAM,2BAA2B,CAAC;AAIrE,wBAAsB,GAAG,CACvB,QAAQ,EAAE,WAAW,EACrB,MAAM,EAAE,aAAa,EACrB,SAAS,GAAE,mBAA8C,GACxD,OAAO,CAAC,IAAI,CAAC,CA6Df"}
|
package/dist/phases/act.js
CHANGED
|
@@ -2,20 +2,30 @@ import { join } from 'node:path';
|
|
|
2
2
|
import { writeJsonReport } from '../reporters/json-reporter.js';
|
|
3
3
|
import { writeMarkdownReport } from '../reporters/markdown-reporter.js';
|
|
4
4
|
import { logDecision } from '../harness/decision-logger.js';
|
|
5
|
+
import { emitTelemetry } from '../telemetry/emit.js';
|
|
6
|
+
import { resolveScanStateBaseDir } from '../harness/state-manager.js';
|
|
5
7
|
export async function act(analysis, config, artifacts = { writeArtifacts: true }) {
|
|
6
|
-
const
|
|
7
|
-
const
|
|
8
|
+
const sessionId = artifacts.telemetrySessionId ?? 'none';
|
|
9
|
+
const reportDir = join(process.cwd(), 'output');
|
|
10
|
+
const logOpts = {
|
|
11
|
+
persist: artifacts.writeArtifacts,
|
|
12
|
+
memory: artifacts.decisionMemory,
|
|
13
|
+
outputDir: config.outputDir,
|
|
14
|
+
};
|
|
8
15
|
const log = artifacts.writeArtifacts ? console.log : console.error;
|
|
16
|
+
emitTelemetry(artifacts.telemetry, 'phase.act.started', sessionId, {
|
|
17
|
+
writeArtifacts: artifacts.writeArtifacts,
|
|
18
|
+
});
|
|
9
19
|
if (artifacts.writeArtifacts) {
|
|
10
|
-
await writeJsonReport(analysis,
|
|
11
|
-
await writeMarkdownReport(analysis,
|
|
20
|
+
await writeJsonReport(analysis, reportDir);
|
|
21
|
+
await writeMarkdownReport(analysis, reportDir);
|
|
12
22
|
}
|
|
13
23
|
await logDecision({
|
|
14
24
|
timestamp: new Date().toISOString(),
|
|
15
25
|
phase: 'act',
|
|
16
26
|
decision: 'reports-written',
|
|
17
27
|
reason: artifacts.writeArtifacts
|
|
18
|
-
? `Wrote JSON and Markdown reports to ${
|
|
28
|
+
? `Wrote JSON and Markdown reports to ${reportDir}`
|
|
19
29
|
: 'Skipped writing reports (ephemeral run)',
|
|
20
30
|
metadata: {
|
|
21
31
|
gapCount: analysis.gaps.length,
|
|
@@ -24,6 +34,10 @@ export async function act(analysis, config, artifacts = { writeArtifacts: true }
|
|
|
24
34
|
requireHumanReview: config.requireHumanReview,
|
|
25
35
|
},
|
|
26
36
|
}, logOpts);
|
|
37
|
+
emitTelemetry(artifacts.telemetry, 'phase.act.completed', sessionId, {
|
|
38
|
+
gapCount: analysis.gaps.length,
|
|
39
|
+
wroteReports: artifacts.writeArtifacts,
|
|
40
|
+
});
|
|
27
41
|
log('\n[qulib] Analysis complete');
|
|
28
42
|
log(` Gaps found: ${analysis.gaps.length}`);
|
|
29
43
|
log(` Scenarios generated: ${analysis.scenarios.length}`);
|
|
@@ -35,7 +49,7 @@ export async function act(analysis, config, artifacts = { writeArtifacts: true }
|
|
|
35
49
|
log('\n[qulib] Human review required before applying any generated output.');
|
|
36
50
|
if (artifacts.writeArtifacts) {
|
|
37
51
|
log(' Reports: output/report.json and output/report.md');
|
|
38
|
-
log(
|
|
52
|
+
log(` Decisions: ${join(resolveScanStateBaseDir(config.outputDir), 'decision-log.json')}`);
|
|
39
53
|
}
|
|
40
54
|
else {
|
|
41
55
|
log(' Ephemeral run: inspect JSON printed to stdout (no files written).');
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"observe.d.ts","sourceRoot":"","sources":["../../src/phases/observe.ts"],"names":[],"mappings":"AAAA,OAAO,KAAK,EAAE,aAAa,EAAE,MAAM,6BAA6B,CAAC;AACjE,OAAO,EAAwB,KAAK,cAAc,EAAE,MAAM,sCAAsC,CAAC;AACjG,OAAO,EAAsB,KAAK,YAAY,EAAE,MAAM,oCAAoC,CAAC;AAK3F,OAAO,KAAK,EAAE,mBAAmB,EAAE,MAAM,2BAA2B,CAAC;
|
|
1
|
+
{"version":3,"file":"observe.d.ts","sourceRoot":"","sources":["../../src/phases/observe.ts"],"names":[],"mappings":"AAAA,OAAO,KAAK,EAAE,aAAa,EAAE,MAAM,6BAA6B,CAAC;AACjE,OAAO,EAAwB,KAAK,cAAc,EAAE,MAAM,sCAAsC,CAAC;AACjG,OAAO,EAAsB,KAAK,YAAY,EAAE,MAAM,oCAAoC,CAAC;AAK3F,OAAO,KAAK,EAAE,mBAAmB,EAAE,MAAM,2BAA2B,CAAC;AAGrE,MAAM,WAAW,aAAa;IAC5B,MAAM,EAAE,cAAc,CAAC;IACvB,IAAI,EAAE,YAAY,GAAG,IAAI,CAAC;CAC3B;AAED,wBAAsB,OAAO,CAC3B,OAAO,EAAE,MAAM,EACf,QAAQ,EAAE,MAAM,GAAG,SAAS,EAC5B,MAAM,EAAE,aAAa,EACrB,SAAS,GAAE,mBAA8C,GACxD,OAAO,CAAC,aAAa,CAAC,CAuExB"}
|
package/dist/phases/observe.js
CHANGED
|
@@ -4,10 +4,20 @@ import { createExplorer } from '../tools/explorer-factory.js';
|
|
|
4
4
|
import { scanRepo } from '../tools/repo-scanner.js';
|
|
5
5
|
import { StateManager } from '../harness/state-manager.js';
|
|
6
6
|
import { logDecision } from '../harness/decision-logger.js';
|
|
7
|
+
import { emitTelemetry } from '../telemetry/emit.js';
|
|
7
8
|
export async function observe(baseUrl, repoPath, config, artifacts = { writeArtifacts: true }) {
|
|
9
|
+
const sessionId = artifacts.telemetrySessionId ?? 'none';
|
|
8
10
|
const explorer = createExplorer(config.explorer);
|
|
9
|
-
const stateManager = new StateManager();
|
|
10
|
-
const logOpts = {
|
|
11
|
+
const stateManager = new StateManager(config.outputDir);
|
|
12
|
+
const logOpts = {
|
|
13
|
+
persist: artifacts.writeArtifacts,
|
|
14
|
+
memory: artifacts.decisionMemory,
|
|
15
|
+
outputDir: config.outputDir,
|
|
16
|
+
};
|
|
17
|
+
emitTelemetry(artifacts.telemetry, 'phase.observe.started', sessionId, {
|
|
18
|
+
baseUrl,
|
|
19
|
+
hasRepoPath: Boolean(repoPath),
|
|
20
|
+
});
|
|
11
21
|
const rawRoutes = await explorer.explore(baseUrl, config, artifacts);
|
|
12
22
|
const routes = RouteInventorySchema.parse(rawRoutes);
|
|
13
23
|
if (artifacts.writeArtifacts) {
|
|
@@ -29,6 +39,10 @@ export async function observe(baseUrl, repoPath, config, artifacts = { writeArti
|
|
|
29
39
|
if (repoPath) {
|
|
30
40
|
const rawRepo = await scanRepo(repoPath);
|
|
31
41
|
repo = RepoAnalysisSchema.parse(rawRepo);
|
|
42
|
+
emitTelemetry(artifacts.telemetry, 'repo.scanned', sessionId, {
|
|
43
|
+
routeCount: repo.routes.length,
|
|
44
|
+
testFileCount: repo.testFiles.length,
|
|
45
|
+
});
|
|
32
46
|
if (artifacts.writeArtifacts) {
|
|
33
47
|
await stateManager.writeState('repo-inventory.json', repo, RepoAnalysisSchema);
|
|
34
48
|
}
|
|
@@ -44,5 +58,9 @@ export async function observe(baseUrl, repoPath, config, artifacts = { writeArti
|
|
|
44
58
|
},
|
|
45
59
|
}, logOpts);
|
|
46
60
|
}
|
|
61
|
+
emitTelemetry(artifacts.telemetry, 'phase.observe.completed', sessionId, {
|
|
62
|
+
routeCount: routes.routes.length,
|
|
63
|
+
repoScanned: Boolean(repo),
|
|
64
|
+
});
|
|
47
65
|
return { routes, repo };
|
|
48
66
|
}
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"think-finalize.d.ts","sourceRoot":"","sources":["../../src/phases/think-finalize.ts"],"names":[],"mappings":"AAAA,OAAO,EAAoC,KAAK,aAAa,EAAE,MAAM,6BAA6B,CAAC;AACnG,OAAO,EAA4C,KAAK,WAAW,EAAwB,MAAM,mCAAmC,CAAC;AAQrI,OAAO,KAAK,EAAE,mBAAmB,EAAE,MAAM,2BAA2B,CAAC;AAErE,MAAM,MAAM,gBAAgB,GAAG,IAAI,CAAC,WAAW,EAAE,WAAW,GAAG,gBAAgB,GAAG,kBAAkB,CAAC,CAAC;AAEtG,wBAAsB,4BAA4B,CAChD,KAAK,EAAE,gBAAgB,EACvB,MAAM,EAAE,aAAa,EACrB,SAAS,GAAE,mBAA8C,EACzD,WAAW,CAAC,EAAE,IAAI,CAAC,WAAW,EAAE,MAAM,GAAG,sBAAsB,GAAG,mBAAmB,GAAG,MAAM,CAAC,GAC9F,OAAO,CAAC,WAAW,CAAC,
|
|
1
|
+
{"version":3,"file":"think-finalize.d.ts","sourceRoot":"","sources":["../../src/phases/think-finalize.ts"],"names":[],"mappings":"AAAA,OAAO,EAAoC,KAAK,aAAa,EAAE,MAAM,6BAA6B,CAAC;AACnG,OAAO,EAA4C,KAAK,WAAW,EAAwB,MAAM,mCAAmC,CAAC;AAQrI,OAAO,KAAK,EAAE,mBAAmB,EAAE,MAAM,2BAA2B,CAAC;AAErE,MAAM,MAAM,gBAAgB,GAAG,IAAI,CAAC,WAAW,EAAE,WAAW,GAAG,gBAAgB,GAAG,kBAAkB,CAAC,CAAC;AAEtG,wBAAsB,4BAA4B,CAChD,KAAK,EAAE,gBAAgB,EACvB,MAAM,EAAE,aAAa,EACrB,SAAS,GAAE,mBAA8C,EACzD,WAAW,CAAC,EAAE,IAAI,CAAC,WAAW,EAAE,MAAM,GAAG,sBAAsB,GAAG,mBAAmB,GAAG,MAAM,CAAC,GAC9F,OAAO,CAAC,WAAW,CAAC,CAiLtB"}
|
|
@@ -7,8 +7,12 @@ import { buildGapPrompt } from '../llm/context-builder.js';
|
|
|
7
7
|
import { assembleCostIntelligence } from '../llm/cost-intelligence.js';
|
|
8
8
|
import { hashForCostIntelligence } from '../llm/content-hash.js';
|
|
9
9
|
export async function finalizeGapAnalysisFromDraft(draft, config, artifacts = { writeArtifacts: true }, costContext) {
|
|
10
|
-
const stateManager = new StateManager();
|
|
11
|
-
const logOpts = {
|
|
10
|
+
const stateManager = new StateManager(config.outputDir);
|
|
11
|
+
const logOpts = {
|
|
12
|
+
persist: artifacts.writeArtifacts,
|
|
13
|
+
memory: artifacts.decisionMemory,
|
|
14
|
+
outputDir: config.outputDir,
|
|
15
|
+
};
|
|
12
16
|
const partialAnalysis = GapAnalysisSchema.parse({
|
|
13
17
|
...draft,
|
|
14
18
|
scenarios: [],
|
|
@@ -60,7 +64,12 @@ export async function finalizeGapAnalysisFromDraft(draft, config, artifacts = {
|
|
|
60
64
|
const prompt = buildGapPrompt(partialAnalysis.gaps, config.testGenerationLimit);
|
|
61
65
|
const promptHash = hashForCostIntelligence(prompt);
|
|
62
66
|
try {
|
|
63
|
-
const llmResult = await callLLM(prompt, maxOut
|
|
67
|
+
const llmResult = await callLLM(prompt, maxOut, {
|
|
68
|
+
llmProvider: config.llmProvider,
|
|
69
|
+
llmModel: config.llmModel,
|
|
70
|
+
telemetry: artifacts.telemetry,
|
|
71
|
+
telemetrySessionId: artifacts.telemetrySessionId,
|
|
72
|
+
});
|
|
64
73
|
const resultHash = hashForCostIntelligence(llmResult.text);
|
|
65
74
|
const usage = llmResult.usage;
|
|
66
75
|
llmRecords.push({
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"think.d.ts","sourceRoot":"","sources":["../../src/phases/think.ts"],"names":[],"mappings":"AAAA,OAAO,KAAK,EAAE,aAAa,EAAE,MAAM,6BAA6B,CAAC;AACjE,OAAO,EAAqB,KAAK,WAAW,EAAE,MAAM,mCAAmC,CAAC;AACxF,OAAO,KAAK,EAAE,aAAa,EAAE,MAAM,cAAc,CAAC;AAGlD,OAAO,KAAK,EAAE,mBAAmB,EAAE,MAAM,2BAA2B,CAAC;
|
|
1
|
+
{"version":3,"file":"think.d.ts","sourceRoot":"","sources":["../../src/phases/think.ts"],"names":[],"mappings":"AAAA,OAAO,KAAK,EAAE,aAAa,EAAE,MAAM,6BAA6B,CAAC;AACjE,OAAO,EAAqB,KAAK,WAAW,EAAE,MAAM,mCAAmC,CAAC;AACxF,OAAO,KAAK,EAAE,aAAa,EAAE,MAAM,cAAc,CAAC;AAGlD,OAAO,KAAK,EAAE,mBAAmB,EAAE,MAAM,2BAA2B,CAAC;AAIrE,wBAAsB,KAAK,CACzB,QAAQ,EAAE,aAAa,EACvB,MAAM,EAAE,aAAa,EACrB,SAAS,GAAE,mBAA8C,GACxD,OAAO,CAAC,WAAW,CAAC,CAmDtB;AAED,OAAO,EAAE,4BAA4B,EAAE,MAAM,qBAAqB,CAAC;AACnE,YAAY,EAAE,gBAAgB,EAAE,MAAM,qBAAqB,CAAC"}
|
package/dist/phases/think.js
CHANGED
|
@@ -2,9 +2,16 @@ import { GapAnalysisSchema } from '../schemas/gap-analysis.schema.js';
|
|
|
2
2
|
import { analyzeGaps } from '../tools/gap-engine.js';
|
|
3
3
|
import { logDecision } from '../harness/decision-logger.js';
|
|
4
4
|
import { finalizeGapAnalysisFromDraft } from './think-finalize.js';
|
|
5
|
+
import { emitTelemetry } from '../telemetry/emit.js';
|
|
5
6
|
export async function think(observed, config, artifacts = { writeArtifacts: true }) {
|
|
7
|
+
const sessionId = artifacts.telemetrySessionId ?? 'none';
|
|
6
8
|
const mode = observed.repo ? 'url-repo' : 'url-only';
|
|
7
|
-
const logOpts = {
|
|
9
|
+
const logOpts = {
|
|
10
|
+
persist: artifacts.writeArtifacts,
|
|
11
|
+
memory: artifacts.decisionMemory,
|
|
12
|
+
outputDir: config.outputDir,
|
|
13
|
+
};
|
|
14
|
+
emitTelemetry(artifacts.telemetry, 'phase.think.started', sessionId, { mode });
|
|
8
15
|
const gapBlock = analyzeGaps(observed.routes, observed.repo, mode, config);
|
|
9
16
|
const draft = {
|
|
10
17
|
analyzedAt: gapBlock.analyzedAt,
|
|
@@ -31,6 +38,11 @@ export async function think(observed, config, artifacts = { writeArtifacts: true
|
|
|
31
38
|
releaseConfidence: partialAnalysis.releaseConfidence,
|
|
32
39
|
},
|
|
33
40
|
}, logOpts);
|
|
34
|
-
|
|
41
|
+
const finalized = await finalizeGapAnalysisFromDraft(draft, config, artifacts);
|
|
42
|
+
emitTelemetry(artifacts.telemetry, 'phase.think.completed', sessionId, {
|
|
43
|
+
gapCount: finalized.gaps.length,
|
|
44
|
+
mode: finalized.mode,
|
|
45
|
+
});
|
|
46
|
+
return finalized;
|
|
35
47
|
}
|
|
36
48
|
export { finalizeGapAnalysisFromDraft } from './think-finalize.js';
|
|
@@ -0,0 +1,78 @@
|
|
|
1
|
+
import { z } from 'zod';
|
|
2
|
+
export declare const AutomationMaturityDimensionSchema: z.ZodObject<{
|
|
3
|
+
dimension: z.ZodEnum<["test-coverage-breadth", "framework-adoption", "test-id-hygiene", "ci-integration", "auth-test-coverage", "component-test-ratio"]>;
|
|
4
|
+
score: z.ZodNumber;
|
|
5
|
+
weight: z.ZodNumber;
|
|
6
|
+
evidence: z.ZodArray<z.ZodString, "many">;
|
|
7
|
+
recommendations: z.ZodArray<z.ZodString, "many">;
|
|
8
|
+
}, "strip", z.ZodTypeAny, {
|
|
9
|
+
recommendations: string[];
|
|
10
|
+
dimension: "test-coverage-breadth" | "framework-adoption" | "test-id-hygiene" | "ci-integration" | "auth-test-coverage" | "component-test-ratio";
|
|
11
|
+
score: number;
|
|
12
|
+
weight: number;
|
|
13
|
+
evidence: string[];
|
|
14
|
+
}, {
|
|
15
|
+
recommendations: string[];
|
|
16
|
+
dimension: "test-coverage-breadth" | "framework-adoption" | "test-id-hygiene" | "ci-integration" | "auth-test-coverage" | "component-test-ratio";
|
|
17
|
+
score: number;
|
|
18
|
+
weight: number;
|
|
19
|
+
evidence: string[];
|
|
20
|
+
}>;
|
|
21
|
+
export declare const AutomationMaturitySchema: z.ZodObject<{
|
|
22
|
+
computedAt: z.ZodString;
|
|
23
|
+
repoPath: z.ZodString;
|
|
24
|
+
overallScore: z.ZodNumber;
|
|
25
|
+
level: z.ZodNumber;
|
|
26
|
+
label: z.ZodString;
|
|
27
|
+
dimensions: z.ZodArray<z.ZodObject<{
|
|
28
|
+
dimension: z.ZodEnum<["test-coverage-breadth", "framework-adoption", "test-id-hygiene", "ci-integration", "auth-test-coverage", "component-test-ratio"]>;
|
|
29
|
+
score: z.ZodNumber;
|
|
30
|
+
weight: z.ZodNumber;
|
|
31
|
+
evidence: z.ZodArray<z.ZodString, "many">;
|
|
32
|
+
recommendations: z.ZodArray<z.ZodString, "many">;
|
|
33
|
+
}, "strip", z.ZodTypeAny, {
|
|
34
|
+
recommendations: string[];
|
|
35
|
+
dimension: "test-coverage-breadth" | "framework-adoption" | "test-id-hygiene" | "ci-integration" | "auth-test-coverage" | "component-test-ratio";
|
|
36
|
+
score: number;
|
|
37
|
+
weight: number;
|
|
38
|
+
evidence: string[];
|
|
39
|
+
}, {
|
|
40
|
+
recommendations: string[];
|
|
41
|
+
dimension: "test-coverage-breadth" | "framework-adoption" | "test-id-hygiene" | "ci-integration" | "auth-test-coverage" | "component-test-ratio";
|
|
42
|
+
score: number;
|
|
43
|
+
weight: number;
|
|
44
|
+
evidence: string[];
|
|
45
|
+
}>, "many">;
|
|
46
|
+
topRecommendations: z.ZodArray<z.ZodString, "many">;
|
|
47
|
+
}, "strip", z.ZodTypeAny, {
|
|
48
|
+
label: string;
|
|
49
|
+
level: number;
|
|
50
|
+
computedAt: string;
|
|
51
|
+
repoPath: string;
|
|
52
|
+
overallScore: number;
|
|
53
|
+
dimensions: {
|
|
54
|
+
recommendations: string[];
|
|
55
|
+
dimension: "test-coverage-breadth" | "framework-adoption" | "test-id-hygiene" | "ci-integration" | "auth-test-coverage" | "component-test-ratio";
|
|
56
|
+
score: number;
|
|
57
|
+
weight: number;
|
|
58
|
+
evidence: string[];
|
|
59
|
+
}[];
|
|
60
|
+
topRecommendations: string[];
|
|
61
|
+
}, {
|
|
62
|
+
label: string;
|
|
63
|
+
level: number;
|
|
64
|
+
computedAt: string;
|
|
65
|
+
repoPath: string;
|
|
66
|
+
overallScore: number;
|
|
67
|
+
dimensions: {
|
|
68
|
+
recommendations: string[];
|
|
69
|
+
dimension: "test-coverage-breadth" | "framework-adoption" | "test-id-hygiene" | "ci-integration" | "auth-test-coverage" | "component-test-ratio";
|
|
70
|
+
score: number;
|
|
71
|
+
weight: number;
|
|
72
|
+
evidence: string[];
|
|
73
|
+
}[];
|
|
74
|
+
topRecommendations: string[];
|
|
75
|
+
}>;
|
|
76
|
+
export type AutomationMaturityDimension = z.infer<typeof AutomationMaturityDimensionSchema>;
|
|
77
|
+
export type AutomationMaturity = z.infer<typeof AutomationMaturitySchema>;
|
|
78
|
+
//# sourceMappingURL=automation-maturity.schema.d.ts.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"automation-maturity.schema.d.ts","sourceRoot":"","sources":["../../src/schemas/automation-maturity.schema.ts"],"names":[],"mappings":"AAAA,OAAO,EAAE,CAAC,EAAE,MAAM,KAAK,CAAC;AAExB,eAAO,MAAM,iCAAiC;;;;;;;;;;;;;;;;;;EAa5C,CAAC;AAEH,eAAO,MAAM,wBAAwB;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;EAQnC,CAAC;AAEH,MAAM,MAAM,2BAA2B,GAAG,CAAC,CAAC,KAAK,CAAC,OAAO,iCAAiC,CAAC,CAAC;AAC5F,MAAM,MAAM,kBAAkB,GAAG,CAAC,CAAC,KAAK,CAAC,OAAO,wBAAwB,CAAC,CAAC"}
|
|
@@ -0,0 +1,24 @@
|
|
|
1
|
+
import { z } from 'zod';
|
|
2
|
+
export const AutomationMaturityDimensionSchema = z.object({
|
|
3
|
+
dimension: z.enum([
|
|
4
|
+
'test-coverage-breadth',
|
|
5
|
+
'framework-adoption',
|
|
6
|
+
'test-id-hygiene',
|
|
7
|
+
'ci-integration',
|
|
8
|
+
'auth-test-coverage',
|
|
9
|
+
'component-test-ratio',
|
|
10
|
+
]),
|
|
11
|
+
score: z.number().min(0).max(100),
|
|
12
|
+
weight: z.number().min(0).max(1),
|
|
13
|
+
evidence: z.array(z.string()),
|
|
14
|
+
recommendations: z.array(z.string()),
|
|
15
|
+
});
|
|
16
|
+
export const AutomationMaturitySchema = z.object({
|
|
17
|
+
computedAt: z.string().datetime(),
|
|
18
|
+
repoPath: z.string(),
|
|
19
|
+
overallScore: z.number().min(0).max(100),
|
|
20
|
+
level: z.number().int().min(1).max(5),
|
|
21
|
+
label: z.string(),
|
|
22
|
+
dimensions: z.array(AutomationMaturityDimensionSchema),
|
|
23
|
+
topRecommendations: z.array(z.string()),
|
|
24
|
+
});
|