@fliwright/tdd 0.1.0 → 0.1.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/README.md +25 -3
- package/dist/baseline/BaselineManager.d.ts +3 -3
- package/dist/daemon/FlutterDaemonController.d.ts +1 -0
- package/dist/daemon/FlutterDaemonController.js +13 -2
- package/dist/daemon/SubprocessDaemonTransport.d.ts +3 -0
- package/dist/daemon/SubprocessDaemonTransport.js +25 -9
- package/dist/executor/FocusedRerunRecipe.js +9 -2
- package/dist/executor/PersistentTestExecutor.d.ts +1 -4
- package/dist/executor/PersistentTestExecutor.js +31 -38
- package/dist/executor/TestRunResults.d.ts +13 -0
- package/dist/executor/TestRunResults.js +19 -0
- package/dist/index.d.ts +3 -17
- package/dist/index.js +1 -8
- package/dist/runtime/TddRuntime.d.ts +5 -19
- package/dist/runtime/TddRuntime.js +78 -115
- package/dist/types.d.ts +17 -192
- package/package.json +4 -4
- package/dist/devassist/DevAssistCoordinator.d.ts +0 -74
- package/dist/devassist/DevAssistCoordinator.js +0 -388
- package/dist/executor/ResultReporter.d.ts +0 -23
- package/dist/executor/ResultReporter.js +0 -50
- package/dist/generator/RedFirstTestGenerator.d.ts +0 -32
- package/dist/generator/RedFirstTestGenerator.js +0 -189
- package/dist/repair/TddRepairPlanner.d.ts +0 -54
- package/dist/repair/TddRepairPlanner.js +0 -132
- package/dist/selectors/SelectorSynthesizer.d.ts +0 -34
- package/dist/selectors/SelectorSynthesizer.js +0 -174
- package/dist/spec/InteractionSpec.d.ts +0 -94
- package/dist/spec/InteractionSpec.js +0 -236
- package/dist/spec/InteractionSpecCoverage.d.ts +0 -17
- package/dist/spec/InteractionSpecCoverage.js +0 -69
- package/dist/workflow/RedFirstWorkflow.d.ts +0 -28
- package/dist/workflow/RedFirstWorkflow.js +0 -33
package/README.md
CHANGED
|
@@ -1,8 +1,30 @@
|
|
|
1
1
|
# @fliwright/tdd
|
|
2
2
|
|
|
3
|
-
Experimental persistent
|
|
4
|
-
is published under the npm `next` tag while its Flutter
|
|
5
|
-
compatibility matrix is validated.
|
|
3
|
+
Experimental persistent focused-test execution and Flutter synchronization for
|
|
4
|
+
Fliwright. This package is published under the npm `next` tag while its Flutter
|
|
5
|
+
daemon and restart compatibility matrix is validated.
|
|
6
6
|
|
|
7
7
|
Most users should begin with `@fliwright/cli` and `@fliwright/vitest`. TDD
|
|
8
8
|
commands are available under `fliwright tdd`.
|
|
9
|
+
|
|
10
|
+
The agent follows the TDD skill: author a normal test, confirm its expected
|
|
11
|
+
failure, implement the behavior, then refactor and run regressions. This package
|
|
12
|
+
provides app reload/restart, baseline reset, focused reruns, connection lifecycle
|
|
13
|
+
and execution evidence. It does not generate acceptance tests, maintain a TDD
|
|
14
|
+
readiness state machine, infer requirements or perform AI repairs.
|
|
15
|
+
|
|
16
|
+
Use `fliwright run` for one-shot verification. For repeated work, open a session,
|
|
17
|
+
start the runtime if attaching, explicitly focus an authored test and request
|
|
18
|
+
cycles as needed. `testName` is literal; full names use `Suite > test`. A file
|
|
19
|
+
run aggregates all executed tests and suite errors. Named composed scenarios are
|
|
20
|
+
prepared by Vitest fixtures before every attempt and retry.
|
|
21
|
+
|
|
22
|
+
This revision removes `tdd.prepare`, `tdd.validate-spec`, `tdd.repair`,
|
|
23
|
+
`devassist.cycle`, red-first generation APIs and their workflow metadata.
|
|
24
|
+
Author tests through the skills and use `tdd.focus` plus `tdd.cycle` to execute.
|
|
25
|
+
|
|
26
|
+
For direct API consumers, `Scenario` / `setScenario` become `BaselineConfig` /
|
|
27
|
+
`setBaselineConfig` for low-level resets. Select a declared `TestScenario` by name
|
|
28
|
+
with `defaultScenario` or `setDefaultScenario(name)`; fixtures prepare it per
|
|
29
|
+
attempt. The executor no longer accepts the unused `driverProvider` boot option;
|
|
30
|
+
workers connect through the VM-service URL.
|
|
@@ -1,4 +1,4 @@
|
|
|
1
|
-
import type { ResetAdapterResult, ResetCategory, ResetReport,
|
|
1
|
+
import type { ResetAdapterResult, ResetCategory, ResetReport, BaselineConfig } from '../types.js';
|
|
2
2
|
export interface ResetContext {
|
|
3
3
|
driver: {
|
|
4
4
|
page: {
|
|
@@ -39,7 +39,7 @@ export interface ResetContext {
|
|
|
39
39
|
invoke(capability: string, method: string, input?: unknown): Promise<unknown>;
|
|
40
40
|
};
|
|
41
41
|
};
|
|
42
|
-
scenario:
|
|
42
|
+
scenario: BaselineConfig;
|
|
43
43
|
full: boolean;
|
|
44
44
|
}
|
|
45
45
|
/** Result of a `ext.fliwright.storage.reset` call surfaced through the driver. */
|
|
@@ -61,7 +61,7 @@ export declare class BaselineManager {
|
|
|
61
61
|
constructor(driver: ResetContext['driver']);
|
|
62
62
|
get version(): number;
|
|
63
63
|
registerAdapter(adapter: ResetAdapter): void;
|
|
64
|
-
reset(scenario:
|
|
64
|
+
reset(scenario: BaselineConfig, opts?: {
|
|
65
65
|
full?: boolean;
|
|
66
66
|
}): Promise<ResetReport>;
|
|
67
67
|
}
|
|
@@ -10,6 +10,7 @@ export declare class FlutterDaemonController {
|
|
|
10
10
|
}): Promise<AppHandle>;
|
|
11
11
|
reload(appId: string): Promise<void>;
|
|
12
12
|
restart(appId: string): Promise<void>;
|
|
13
|
+
private syncApp;
|
|
13
14
|
stop(appId: string): Promise<void>;
|
|
14
15
|
dispose(options?: {
|
|
15
16
|
keepAppAlive?: boolean;
|
|
@@ -58,13 +58,24 @@ export class FlutterDaemonController {
|
|
|
58
58
|
}
|
|
59
59
|
async reload(appId) {
|
|
60
60
|
this.require(appId);
|
|
61
|
-
await this.
|
|
61
|
+
await this.syncApp(appId, false);
|
|
62
62
|
}
|
|
63
63
|
async restart(appId) {
|
|
64
64
|
const handle = this.require(appId);
|
|
65
65
|
if (!handle.supportsRestart)
|
|
66
66
|
throw new Error(`Hot restart not supported for app ${appId}`);
|
|
67
|
-
await this.
|
|
67
|
+
await this.syncApp(appId, true);
|
|
68
|
+
}
|
|
69
|
+
async syncApp(appId, fullRestart) {
|
|
70
|
+
const result = await this.transport.request('app.restart', { appId, fullRestart });
|
|
71
|
+
const operation = fullRestart ? 'hot restart' : 'hot reload';
|
|
72
|
+
if (typeof result !== 'object' || result === null || !('code' in result) || !Number.isInteger(result.code)) {
|
|
73
|
+
throw new Error(`Flutter did not confirm ${operation} with an operation code.`);
|
|
74
|
+
}
|
|
75
|
+
if (result.code !== 0) {
|
|
76
|
+
const message = 'message' in result && typeof result.message === 'string' ? result.message.trim() : '';
|
|
77
|
+
throw new Error(`Flutter ${operation} failed with code ${result.code}.${message ? ` ${message}` : ''}`);
|
|
78
|
+
}
|
|
68
79
|
}
|
|
69
80
|
async stop(appId) {
|
|
70
81
|
this.require(appId);
|
|
@@ -17,6 +17,8 @@ export declare class SubprocessDaemonTransport implements DaemonTransport {
|
|
|
17
17
|
private starting?;
|
|
18
18
|
private stderr;
|
|
19
19
|
private startingApp?;
|
|
20
|
+
private closing?;
|
|
21
|
+
private exited?;
|
|
20
22
|
connect(): Promise<void>;
|
|
21
23
|
private launch;
|
|
22
24
|
request<T = unknown>(method: string, params?: Record<string, unknown>): Promise<T>;
|
|
@@ -24,6 +26,7 @@ export declare class SubprocessDaemonTransport implements DaemonTransport {
|
|
|
24
26
|
dispose(options?: {
|
|
25
27
|
keepAppAlive?: boolean;
|
|
26
28
|
}): Promise<void>;
|
|
29
|
+
private close;
|
|
27
30
|
private dispatch;
|
|
28
31
|
private rejectAll;
|
|
29
32
|
}
|
|
@@ -25,6 +25,8 @@ export class SubprocessDaemonTransport {
|
|
|
25
25
|
starting;
|
|
26
26
|
stderr = '';
|
|
27
27
|
startingApp;
|
|
28
|
+
closing;
|
|
29
|
+
exited;
|
|
28
30
|
async connect() { this.connected = true; }
|
|
29
31
|
launch(params) {
|
|
30
32
|
if (this.child)
|
|
@@ -42,6 +44,7 @@ export class SubprocessDaemonTransport {
|
|
|
42
44
|
const child = spawn(bin, args, { cwd: typeof params.projectId === 'string' ? params.projectId : this.opts.cwd,
|
|
43
45
|
stdio: ['pipe', 'pipe', 'pipe'], detached: process.platform !== 'win32' });
|
|
44
46
|
this.child = child;
|
|
47
|
+
this.exited = new Promise(resolve => { child.once('exit', () => resolve()); });
|
|
45
48
|
child.stdout.setEncoding('utf8');
|
|
46
49
|
child.stdout.on('data', (chunk) => {
|
|
47
50
|
this.buffer += chunk;
|
|
@@ -90,19 +93,31 @@ export class SubprocessDaemonTransport {
|
|
|
90
93
|
this.listeners.delete(handler);
|
|
91
94
|
};
|
|
92
95
|
}
|
|
93
|
-
|
|
96
|
+
dispose(options = {}) {
|
|
97
|
+
return this.closing ??= this.close(options);
|
|
98
|
+
}
|
|
99
|
+
async close(options) {
|
|
94
100
|
const child = this.child;
|
|
95
101
|
this.child = undefined;
|
|
96
102
|
this.buffer = '';
|
|
97
103
|
this.rejectAll(new Error('SubprocessDaemonTransport disposed'));
|
|
98
104
|
this.connected = false;
|
|
99
105
|
if (child?.pid && child.exitCode === null && child.signalCode === null) {
|
|
106
|
+
const wait = async () => {
|
|
107
|
+
let timer;
|
|
108
|
+
try {
|
|
109
|
+
return await Promise.race([this.exited.then(() => true), new Promise(resolve => {
|
|
110
|
+
timer = setTimeout(() => resolve(false), 2000);
|
|
111
|
+
})]);
|
|
112
|
+
}
|
|
113
|
+
finally {
|
|
114
|
+
clearTimeout(timer);
|
|
115
|
+
}
|
|
116
|
+
};
|
|
100
117
|
if (options.keepAppAlive) {
|
|
101
118
|
child.stdin.end();
|
|
102
|
-
await
|
|
103
|
-
|
|
104
|
-
child.once('exit', () => { clearTimeout(timer); resolve(); });
|
|
105
|
-
});
|
|
119
|
+
if (await wait())
|
|
120
|
+
return;
|
|
106
121
|
}
|
|
107
122
|
if (child.exitCode === null && child.signalCode === null) {
|
|
108
123
|
const terminate = (signal) => { try {
|
|
@@ -110,10 +125,11 @@ export class SubprocessDaemonTransport {
|
|
|
110
125
|
}
|
|
111
126
|
catch { } };
|
|
112
127
|
terminate('SIGTERM');
|
|
113
|
-
await
|
|
114
|
-
|
|
115
|
-
|
|
116
|
-
|
|
128
|
+
if (!await wait()) {
|
|
129
|
+
terminate('SIGKILL');
|
|
130
|
+
if (!await wait())
|
|
131
|
+
throw new Error('Owned Flutter process termination could not be confirmed.');
|
|
132
|
+
}
|
|
117
133
|
}
|
|
118
134
|
}
|
|
119
135
|
}
|
|
@@ -13,11 +13,18 @@ export async function focusAndRerun(vitest, file, testName) {
|
|
|
13
13
|
const savedPatterns = specifications.map((spec) => spec.testNamePattern);
|
|
14
14
|
try {
|
|
15
15
|
if (testName) {
|
|
16
|
-
|
|
16
|
+
// Names are literal, including punctuation. A leaf name may occur in
|
|
17
|
+
// several suites; the executor aggregates all matching results.
|
|
18
|
+
const escaped = testName.replace(/[.*+?^${}()|[\]\\]/g, '\\$&');
|
|
19
|
+
const pattern = new RegExp(`(?:^| > )${escaped}$`);
|
|
17
20
|
for (const spec of specifications)
|
|
18
21
|
spec.testNamePattern = pattern;
|
|
19
22
|
}
|
|
20
|
-
|
|
23
|
+
const run = await vitest.rerunTestSpecifications(specifications);
|
|
24
|
+
// Vitest returns its accumulated module state, including previously run
|
|
25
|
+
// files. Only this request's files belong to the focused result.
|
|
26
|
+
const moduleIds = new Set(specifications.map((spec) => spec.moduleId));
|
|
27
|
+
return { ...run, testModules: run.testModules.filter((module) => moduleIds.has(module.moduleId)) };
|
|
21
28
|
}
|
|
22
29
|
finally {
|
|
23
30
|
specifications.forEach((spec, index) => {
|
|
@@ -12,7 +12,6 @@ export interface TestRunOutcome {
|
|
|
12
12
|
export interface BootOptions {
|
|
13
13
|
configRoot: string;
|
|
14
14
|
vmServiceUrl?: string;
|
|
15
|
-
driverProvider: () => Promise<unknown>;
|
|
16
15
|
runsRoot?: string;
|
|
17
16
|
sharedConfig?: Partial<import('@fliwright/core').FliwrightProjectConfig>;
|
|
18
17
|
defaultScenario?: string;
|
|
@@ -20,7 +19,6 @@ export interface BootOptions {
|
|
|
20
19
|
}
|
|
21
20
|
export declare class PersistentTestExecutor {
|
|
22
21
|
private vitest?;
|
|
23
|
-
private reporter?;
|
|
24
22
|
private previousDefaultScenario?;
|
|
25
23
|
private previousScenarioMode?;
|
|
26
24
|
private previousVmServiceUrl?;
|
|
@@ -37,7 +35,6 @@ export declare class PersistentTestExecutor {
|
|
|
37
35
|
boot(opts: BootOptions): Promise<void>;
|
|
38
36
|
rerun(file: string, testName?: string): Promise<TestRunOutcome>;
|
|
39
37
|
dispose(): Promise<void>;
|
|
40
|
-
private pickResult;
|
|
41
38
|
private restoreRuntimeEnv;
|
|
42
39
|
private applyRuntimeEnv;
|
|
43
40
|
private snapshotPreviousEnv;
|
|
@@ -48,7 +45,7 @@ export declare class PersistentTestExecutor {
|
|
|
48
45
|
export declare function defaultArtifactsRoot(configRoot: string): string;
|
|
49
46
|
/**
|
|
50
47
|
* Default RuntimeSnapshot status-file path a read-only monitor (e.g. the VS Code TDD Loop panel)
|
|
51
|
-
* polls:
|
|
48
|
+
* polls: `~/.fliwright/<project-path>/runtime/tdd-status.json`. The project root is derived from the same
|
|
52
49
|
* configRoot convention as {@link defaultArtifactsRoot}.
|
|
53
50
|
*/
|
|
54
51
|
export declare function defaultStatusFilePath(configRoot: string): string;
|
|
@@ -1,13 +1,12 @@
|
|
|
1
1
|
import { mkdir, readFile } from 'node:fs/promises';
|
|
2
2
|
import { basename, join, resolve } from 'node:path';
|
|
3
|
-
import { FLIWRIGHT_RUNS_ROOT_ENV, RunArtifactStore, parseTimelineData, resolveFliwrightRunsRoot, resolveFliwrightCacheRoot, mergeFliwrightConfig, readFliwrightEnvironment } from '@fliwright/core';
|
|
3
|
+
import { FLIWRIGHT_RUNS_ROOT_ENV, RunArtifactStore, parseTimelineData, resolveFliwrightRunsRoot, resolveFliwrightRuntimeRoot, resolveFliwrightCacheRoot, mergeFliwrightConfig, readFliwrightEnvironment, writeFliwrightConfigSnapshot } from '@fliwright/core';
|
|
4
4
|
import { fileURLToPath } from 'node:url';
|
|
5
5
|
import { startVitest } from 'vitest/node';
|
|
6
6
|
import { focusAndRerun } from './FocusedRerunRecipe.js';
|
|
7
|
-
import { collectResultsFromModules
|
|
7
|
+
import { collectResultsFromModules } from './TestRunResults.js';
|
|
8
8
|
export class PersistentTestExecutor {
|
|
9
9
|
vitest;
|
|
10
|
-
reporter;
|
|
11
10
|
previousDefaultScenario;
|
|
12
11
|
previousScenarioMode;
|
|
13
12
|
previousVmServiceUrl;
|
|
@@ -28,22 +27,25 @@ export class PersistentTestExecutor {
|
|
|
28
27
|
// left with TDD env vars leaking into unrelated (batch) test runs.
|
|
29
28
|
await this.applyRuntimeEnv(opts);
|
|
30
29
|
try {
|
|
31
|
-
this.reporter = new ResultReporter();
|
|
32
30
|
this.vitest = await startVitest('test', [], {
|
|
33
|
-
|
|
31
|
+
root: looksLikeConfigFile(opts.configRoot) ? undefined : resolve(opts.configRoot),
|
|
32
|
+
config: looksLikeConfigFile(opts.configRoot) ? resolve(opts.configRoot) : undefined,
|
|
34
33
|
watch: true,
|
|
35
34
|
standalone: true,
|
|
36
|
-
reporters: [
|
|
35
|
+
reporters: [],
|
|
37
36
|
pool: 'forks',
|
|
38
37
|
maxWorkers: 1,
|
|
39
38
|
}, {
|
|
40
39
|
// macOS FSEvents can deliver a config write from before boot after a
|
|
41
40
|
// focused run starts, causing Vite to close its active module cache.
|
|
42
41
|
...(process.platform === 'darwin' ? { server: { watch: { usePolling: true } } } : {}),
|
|
43
|
-
plugins: [{
|
|
42
|
+
plugins: [{
|
|
43
|
+
name: 'fliwright-runner',
|
|
44
|
+
config(config) {
|
|
44
45
|
const runtimeConfig = config;
|
|
45
46
|
(runtimeConfig.test ??= {}).runner ??= fileURLToPath(import.meta.resolve('@fliwright/vitest/runner'));
|
|
46
|
-
}
|
|
47
|
+
},
|
|
48
|
+
}],
|
|
47
49
|
});
|
|
48
50
|
if (!this.vitest)
|
|
49
51
|
throw new Error('Failed to start Vitest');
|
|
@@ -58,35 +60,33 @@ export class PersistentTestExecutor {
|
|
|
58
60
|
await this.dispose().catch(() => undefined);
|
|
59
61
|
throw error;
|
|
60
62
|
}
|
|
61
|
-
// The provider is kept for same-process executor experiments. Vitest workers cannot
|
|
62
|
-
// receive live driver objects through process boundaries, so the production path also injects
|
|
63
|
-
// FLIWRIGHT_VM_SERVICE_URL for ordinary @fliwright/vitest fixtures.
|
|
64
|
-
void opts.driverProvider;
|
|
65
63
|
}
|
|
66
64
|
async rerun(file, testName) {
|
|
67
|
-
if (!this.vitest
|
|
65
|
+
if (!this.vitest)
|
|
68
66
|
throw new Error('PersistentTestExecutor not booted');
|
|
69
|
-
this.reporter.drain();
|
|
70
67
|
// The public API returns the exact run we requested. A reporter's next
|
|
71
68
|
// event may instead belong to a watcher refresh (or contain no modules).
|
|
72
69
|
const run = await focusAndRerun(this.vitest, file, testName);
|
|
73
70
|
const files = run.testModules;
|
|
74
71
|
const results = collectResultsFromModules(files);
|
|
75
|
-
const picked =
|
|
76
|
-
const resolvedTestName = picked?.
|
|
72
|
+
const picked = results.find((result) => result.status === 'red') ?? results[0];
|
|
73
|
+
const resolvedTestName = picked?.fullName ?? testName;
|
|
74
|
+
const errors = [
|
|
75
|
+
...results.filter((result) => result.status === 'red').map((result) => result.message ?? `${result.fullName} failed.`),
|
|
76
|
+
...files.flatMap((module) => [module, ...module.children.allSuites()].flatMap((suite) => suite.errors().map((error) => error.message))),
|
|
77
|
+
...run.unhandledErrors.map((error) => error instanceof Error ? error.message
|
|
78
|
+
: error && typeof error === 'object' && 'message' in error ? String(error.message) : String(error)),
|
|
79
|
+
];
|
|
80
|
+
const failed = errors.length > 0 || files.some((module) => module.state() === 'failed') || !picked;
|
|
77
81
|
const timelineArtifacts = await this.readTimelineArtifacts(picked);
|
|
78
82
|
const failureDetails = picked?.status === 'red' && resolvedTestName
|
|
79
83
|
? await this.readFailureDetails(picked)
|
|
80
84
|
: undefined;
|
|
81
85
|
return {
|
|
82
|
-
status:
|
|
86
|
+
status: failed ? 'red' : 'green',
|
|
83
87
|
testName: resolvedTestName,
|
|
84
|
-
failure:
|
|
85
|
-
|
|
86
|
-
if (error && typeof error === 'object' && 'message' in error)
|
|
87
|
-
return String(error.message);
|
|
88
|
-
return JSON.stringify(error);
|
|
89
|
-
}).join('\n') || 'Focused run returned no matching test result.' } : undefined,
|
|
88
|
+
failure: failed ? { message: errors.join('\n') || (!picked
|
|
89
|
+
? 'Focused run returned no matching test result.' : 'Focused test module failed.') } : undefined,
|
|
90
90
|
failureDetails,
|
|
91
91
|
timelinePath: failureDetails?.artifacts?.timelinePath ?? timelineArtifacts.timelinePath,
|
|
92
92
|
timelineNodeId: failureDetails?.artifacts?.timelineNodeId ?? timelineArtifacts.timelineNodeId,
|
|
@@ -98,17 +98,10 @@ export class PersistentTestExecutor {
|
|
|
98
98
|
}
|
|
99
99
|
finally {
|
|
100
100
|
this.vitest = undefined;
|
|
101
|
-
this.reporter = undefined;
|
|
102
101
|
if (this.envApplied)
|
|
103
102
|
this.restoreRuntimeEnv();
|
|
104
103
|
}
|
|
105
104
|
}
|
|
106
|
-
pickResult(results, testName) {
|
|
107
|
-
if (!testName)
|
|
108
|
-
return results.find((result) => result.status === 'red') ?? results[0];
|
|
109
|
-
return results.find((result) => result.testName === testName)
|
|
110
|
-
?? results.find((result) => result.testName.includes(testName));
|
|
111
|
-
}
|
|
112
105
|
restoreRuntimeEnv() {
|
|
113
106
|
restoreEnv('FLIWRIGHT_SCENARIO_MODE', this.previousScenarioMode);
|
|
114
107
|
restoreEnv('FLIWRIGHT_DEFAULT_SCENARIO', this.previousDefaultScenario);
|
|
@@ -119,7 +112,7 @@ export class PersistentTestExecutor {
|
|
|
119
112
|
restoreEnv('FLIWRIGHT_FAILURE_TIMEOUT_MS', this.previousFailureTimeoutMs);
|
|
120
113
|
restoreEnv(FLIWRIGHT_RUNS_ROOT_ENV, this.previousRunsRoot);
|
|
121
114
|
restoreEnv('FLIWRIGHT_RUN_ID', this.previousRunId);
|
|
122
|
-
restoreEnv('
|
|
115
|
+
restoreEnv('FLIWRIGHT_CONFIG_PATH', this.previousSharedConfig);
|
|
123
116
|
restoreEnv('FLIWRIGHT_PROJECT_ROOT', this.previousProjectRoot);
|
|
124
117
|
this.envApplied = false;
|
|
125
118
|
}
|
|
@@ -135,13 +128,13 @@ export class PersistentTestExecutor {
|
|
|
135
128
|
process.env.FLIWRIGHT_VM_URL = opts.vmServiceUrl;
|
|
136
129
|
}
|
|
137
130
|
const projectRoot = looksLikeConfigFile(opts.configRoot) ? resolve(opts.configRoot, '..') : resolve(opts.configRoot);
|
|
138
|
-
const config = mergeFliwrightConfig({ project: opts.sharedConfig, environment: readFliwrightEnvironment(process.env), explicit: { runsRoot: opts.runsRoot } });
|
|
139
|
-
this.runsRoot = resolveFliwrightRunsRoot({ projectRoot, runsRoot: config.runsRoot
|
|
131
|
+
const config = mergeFliwrightConfig({ projectRoot, project: opts.sharedConfig, environment: readFliwrightEnvironment(process.env), explicit: { runsRoot: opts.runsRoot } });
|
|
132
|
+
this.runsRoot = resolveFliwrightRunsRoot({ projectRoot, runsRoot: config.runsRoot });
|
|
140
133
|
await mkdir(this.runsRoot, { recursive: true });
|
|
141
134
|
if (opts.sharedConfig) {
|
|
142
135
|
config.cacheRoot = resolveFliwrightCacheRoot({ projectRoot, cacheRoot: config.cacheRoot });
|
|
143
136
|
config.runsRoot = this.runsRoot;
|
|
144
|
-
process.env.
|
|
137
|
+
process.env.FLIWRIGHT_CONFIG_PATH = writeFliwrightConfigSnapshot(config, { projectRoot, cacheRoot: config.cacheRoot });
|
|
145
138
|
}
|
|
146
139
|
process.env.FLIWRIGHT_PROJECT_ROOT = projectRoot;
|
|
147
140
|
if (config.runsRoot)
|
|
@@ -166,7 +159,7 @@ export class PersistentTestExecutor {
|
|
|
166
159
|
this.previousFailureTimeoutMs = process.env.FLIWRIGHT_FAILURE_TIMEOUT_MS;
|
|
167
160
|
this.previousRunsRoot = process.env[FLIWRIGHT_RUNS_ROOT_ENV];
|
|
168
161
|
this.previousRunId = process.env.FLIWRIGHT_RUN_ID;
|
|
169
|
-
this.previousSharedConfig = process.env.
|
|
162
|
+
this.previousSharedConfig = process.env.FLIWRIGHT_CONFIG_PATH;
|
|
170
163
|
this.previousProjectRoot = process.env.FLIWRIGHT_PROJECT_ROOT;
|
|
171
164
|
}
|
|
172
165
|
attemptDirectory(result) {
|
|
@@ -225,16 +218,16 @@ function restoreEnv(name, value) {
|
|
|
225
218
|
}
|
|
226
219
|
export function defaultArtifactsRoot(configRoot) {
|
|
227
220
|
const root = looksLikeConfigFile(configRoot) ? resolve(configRoot, '..') : resolve(configRoot);
|
|
228
|
-
return
|
|
221
|
+
return resolveFliwrightRunsRoot({ projectRoot: root });
|
|
229
222
|
}
|
|
230
223
|
/**
|
|
231
224
|
* Default RuntimeSnapshot status-file path a read-only monitor (e.g. the VS Code TDD Loop panel)
|
|
232
|
-
* polls:
|
|
225
|
+
* polls: `~/.fliwright/<project-path>/runtime/tdd-status.json`. The project root is derived from the same
|
|
233
226
|
* configRoot convention as {@link defaultArtifactsRoot}.
|
|
234
227
|
*/
|
|
235
228
|
export function defaultStatusFilePath(configRoot) {
|
|
236
229
|
const root = looksLikeConfigFile(configRoot) ? resolve(configRoot, '..') : resolve(configRoot);
|
|
237
|
-
return join(root, '
|
|
230
|
+
return join(resolveFliwrightRuntimeRoot({ projectRoot: root }), 'runtime', 'tdd-status.json');
|
|
238
231
|
}
|
|
239
232
|
function looksLikeConfigFile(configRoot) {
|
|
240
233
|
const name = basename(configRoot);
|
|
@@ -0,0 +1,13 @@
|
|
|
1
|
+
import type { TestModule } from 'vitest/node';
|
|
2
|
+
export interface CollectedResult {
|
|
3
|
+
testName: string;
|
|
4
|
+
fullName: string;
|
|
5
|
+
status: 'red' | 'green';
|
|
6
|
+
message?: string;
|
|
7
|
+
runIdentity?: {
|
|
8
|
+
runId: string;
|
|
9
|
+
testId: string;
|
|
10
|
+
attemptId: string;
|
|
11
|
+
};
|
|
12
|
+
}
|
|
13
|
+
export declare function collectResultsFromModules(modules: TestModule[]): CollectedResult[];
|
|
@@ -0,0 +1,19 @@
|
|
|
1
|
+
export function collectResultsFromModules(modules) {
|
|
2
|
+
const results = [];
|
|
3
|
+
for (const module of modules) {
|
|
4
|
+
for (const testCase of module.children.allTests()) {
|
|
5
|
+
const result = testCase.result();
|
|
6
|
+
if (result.state !== 'passed' && result.state !== 'failed')
|
|
7
|
+
continue;
|
|
8
|
+
const identity = testCase.meta().fliwrightRun;
|
|
9
|
+
results.push({
|
|
10
|
+
...(identity ? { runIdentity: identity } : {}),
|
|
11
|
+
testName: testCase.name,
|
|
12
|
+
fullName: testCase.fullName,
|
|
13
|
+
status: result.state === 'passed' ? 'green' : 'red',
|
|
14
|
+
message: result.errors?.map((error) => error.message).join('\n'),
|
|
15
|
+
});
|
|
16
|
+
}
|
|
17
|
+
}
|
|
18
|
+
return results;
|
|
19
|
+
}
|
package/dist/index.d.ts
CHANGED
|
@@ -10,27 +10,13 @@ export { BaselineManager } from './baseline/BaselineManager.js';
|
|
|
10
10
|
export type { ResetAdapter, ResetContext, StorageResetOutcome, } from './baseline/BaselineManager.js';
|
|
11
11
|
export { AuthTokensResetAdapter, LocalDbResetAdapter, SecureStorageResetAdapter, StorageBackedResetAdapters, StorageResetAdapter, } from './baseline/StorageResetAdapter.js';
|
|
12
12
|
export { AppCapabilityResetAdapters, IsolatesResetAdapter, PermissionsResetAdapter, TimersResetAdapter, WebviewResetAdapter, } from './baseline/AppCapabilityResetAdapter.js';
|
|
13
|
-
export { TddRepairPlanner } from './repair/TddRepairPlanner.js';
|
|
14
|
-
export type { TddRepairPlannerOptions } from './repair/TddRepairPlanner.js';
|
|
15
13
|
export { TddRuntime } from './runtime/TddRuntime.js';
|
|
16
|
-
export { DevAssistCoordinator } from './devassist/DevAssistCoordinator.js';
|
|
17
|
-
export type { DevAssistAction, DevAssistCoordinatorDeps, DevAssistCycleInput, DevAssistCycleResult, DevAssistInferenceResult, DevAssistRuntime, DevAssistStatus, } from './devassist/DevAssistCoordinator.js';
|
|
18
14
|
export { PersistentTestExecutor } from './executor/PersistentTestExecutor.js';
|
|
19
15
|
export type { BootOptions, TestRunOutcome } from './executor/PersistentTestExecutor.js';
|
|
20
16
|
export { defaultArtifactsRoot, defaultStatusFilePath } from './executor/PersistentTestExecutor.js';
|
|
21
17
|
export { focusAndRerun } from './executor/FocusedRerunRecipe.js';
|
|
22
|
-
export {
|
|
23
|
-
export type { CollectedResult } from './executor/
|
|
18
|
+
export { collectResultsFromModules } from './executor/TestRunResults.js';
|
|
19
|
+
export type { CollectedResult } from './executor/TestRunResults.js';
|
|
24
20
|
export { buildTddFailureContext, classifyFailure } from './diagnostics/TddFailureContext.js';
|
|
25
21
|
export type { BuildTddFailureContextInput, TddFailureArtifacts, TddFailureAssertion, TddFailureContext, TddFailureKind, TddRecoveryHint, TddRecoveryHintKind, TddFailureSource, } from './diagnostics/TddFailureContext.js';
|
|
26
|
-
export {
|
|
27
|
-
export type { GenerateRedFirstTestResult, GenerateRedFirstTestSuiteResult, RedFirstTestGeneratorOptions, RedFirstTestSuiteGeneratorOptions, } from './generator/RedFirstTestGenerator.js';
|
|
28
|
-
export { prepareRedFirstWorkflow } from './workflow/RedFirstWorkflow.js';
|
|
29
|
-
export type { PrepareRedFirstWorkflowResult, RedFirstWorkflowContext, RedFirstWorkflowOptions, RedFirstWorkflowPlan, RedFirstWorkflowStatus, } from './workflow/RedFirstWorkflow.js';
|
|
30
|
-
export { bestLocatorHint, synthesizeSelector, synthesizeSelectorsForElements, } from './selectors/SelectorSynthesizer.js';
|
|
31
|
-
export type { SelectorCandidate, SelectorSynthesisResult, SelectorSynthesisStatus, SelectorTraceStep, WidgetCandidate, } from './selectors/SelectorSynthesizer.js';
|
|
32
|
-
export type { InteractionSpec, InteractionSpecValidationIssue, InteractionSpecValidationResult, LocatorHint, SpecAssertion, SpecElement, SpecElementRole, SpecFlow, SpecStep, } from './spec/InteractionSpec.js';
|
|
33
|
-
export { InteractionSpecValidationError, parseInteractionSpec, validateInteractionSpec, } from './spec/InteractionSpec.js';
|
|
34
|
-
export { analyzeInteractionSpecCoverage } from './spec/InteractionSpecCoverage.js';
|
|
35
|
-
export type { InteractionSpecCoverageGap, InteractionSpecCoverageGapKind, InteractionSpecCoverageReport, } from './spec/InteractionSpecCoverage.js';
|
|
36
|
-
export type { CycleOpts, ResetAdapterResult, ResetCategory, ResetReport, RuntimeSnapshot, Scenario, StartOpts, TddCycleResult, TddSyncResult, TddRepairCycleResult, TddRepairOpts, TddRepairPlan, TddRepairPlannerLike, TddRepairProposalEntry, TddRepairStep, TddRepairTrace, TddRuntimeDeps, } from './types.js';
|
|
22
|
+
export type { CycleOpts, ResetAdapterResult, ResetCategory, ResetReport, RuntimeSnapshot, BaselineConfig, StartOpts, TddCycleAttempt, TddCycleResult, TddSyncResult, TddRuntimeDeps, } from './types.js';
|
package/dist/index.js
CHANGED
|
@@ -5,16 +5,9 @@ export { decideSync, isStructuralFileChange, looksStructuralAfterReload, } from
|
|
|
5
5
|
export { BaselineManager } from './baseline/BaselineManager.js';
|
|
6
6
|
export { AuthTokensResetAdapter, LocalDbResetAdapter, SecureStorageResetAdapter, StorageBackedResetAdapters, StorageResetAdapter, } from './baseline/StorageResetAdapter.js';
|
|
7
7
|
export { AppCapabilityResetAdapters, IsolatesResetAdapter, PermissionsResetAdapter, TimersResetAdapter, WebviewResetAdapter, } from './baseline/AppCapabilityResetAdapter.js';
|
|
8
|
-
export { TddRepairPlanner } from './repair/TddRepairPlanner.js';
|
|
9
8
|
export { TddRuntime } from './runtime/TddRuntime.js';
|
|
10
|
-
export { DevAssistCoordinator } from './devassist/DevAssistCoordinator.js';
|
|
11
9
|
export { PersistentTestExecutor } from './executor/PersistentTestExecutor.js';
|
|
12
10
|
export { defaultArtifactsRoot, defaultStatusFilePath } from './executor/PersistentTestExecutor.js';
|
|
13
11
|
export { focusAndRerun } from './executor/FocusedRerunRecipe.js';
|
|
14
|
-
export {
|
|
12
|
+
export { collectResultsFromModules } from './executor/TestRunResults.js';
|
|
15
13
|
export { buildTddFailureContext, classifyFailure } from './diagnostics/TddFailureContext.js';
|
|
16
|
-
export { generateRedFirstTest, generateRedFirstTestSuite } from './generator/RedFirstTestGenerator.js';
|
|
17
|
-
export { prepareRedFirstWorkflow } from './workflow/RedFirstWorkflow.js';
|
|
18
|
-
export { bestLocatorHint, synthesizeSelector, synthesizeSelectorsForElements, } from './selectors/SelectorSynthesizer.js';
|
|
19
|
-
export { InteractionSpecValidationError, parseInteractionSpec, validateInteractionSpec, } from './spec/InteractionSpec.js';
|
|
20
|
-
export { analyzeInteractionSpecCoverage } from './spec/InteractionSpecCoverage.js';
|
|
@@ -1,22 +1,18 @@
|
|
|
1
|
-
import {
|
|
2
|
-
import type { CycleOpts, RuntimeSnapshot, Scenario, StartOpts, TddCycleResult, TddSyncResult, TddRuntimeDeps } from '../types.js';
|
|
1
|
+
import type { CycleOpts, RuntimeSnapshot, BaselineConfig, StartOpts, TddCycleResult, TddSyncResult, TddRuntimeDeps } from '../types.js';
|
|
3
2
|
export declare class TddRuntime {
|
|
4
3
|
private readonly daemon;
|
|
5
4
|
private readonly executor;
|
|
6
5
|
private readonly driverFactory;
|
|
7
6
|
private readonly injectedBaseline?;
|
|
8
7
|
private baseline?;
|
|
9
|
-
/** Optional AI repair planner (design §6.2, wired P3). Absent → no repair loop (additive). */
|
|
10
|
-
private repairPlanner?;
|
|
11
8
|
private driver?;
|
|
12
9
|
private app?;
|
|
13
10
|
private vmServiceUrl?;
|
|
14
11
|
private configRoot?;
|
|
15
12
|
private sharedConfig?;
|
|
16
13
|
private startAppParams?;
|
|
17
|
-
private testScenario?;
|
|
18
14
|
private defaultScenarioName?;
|
|
19
|
-
private
|
|
15
|
+
private baselineConfig;
|
|
20
16
|
private focusedTest?;
|
|
21
17
|
private lastResult?;
|
|
22
18
|
private started;
|
|
@@ -35,8 +31,9 @@ export declare class TddRuntime {
|
|
|
35
31
|
/** Wait for real work, including a cycle whose caller already received timeout. */
|
|
36
32
|
whenIdle(): Promise<void>;
|
|
37
33
|
focus(file: string, testName?: string): Promise<void>;
|
|
38
|
-
|
|
39
|
-
|
|
34
|
+
/** Select the named scenario that Vitest fixtures prepare before every attempt. */
|
|
35
|
+
setDefaultScenario(name: string): Promise<RuntimeSnapshot>;
|
|
36
|
+
setBaselineConfig(config: BaselineConfig): Promise<RuntimeSnapshot>;
|
|
40
37
|
syncApp(sync: Exclude<NonNullable<CycleOpts['sync']>, 'auto'>): Promise<TddSyncResult>;
|
|
41
38
|
cycle(testName?: string, opts?: CycleOpts): Promise<TddCycleResult>;
|
|
42
39
|
/**
|
|
@@ -49,17 +46,6 @@ export declare class TddRuntime {
|
|
|
49
46
|
private reconnectNow;
|
|
50
47
|
private verifyManagedEndpoint;
|
|
51
48
|
private runCycleWithEscalation;
|
|
52
|
-
/**
|
|
53
|
-
* The AI repair closed loop (design §7/§10 P3). Runs serialized inside the cycle chain task after
|
|
54
|
-
* the initial red cycle. Proposes a minimal, guardrail-bounded repair via the wired planner, then
|
|
55
|
-
* (safe-apply only) re-cycles until green or the iteration cap. Never reentrant: the caller has
|
|
56
|
-
* already acquired the chain; this method calls {@link performCycle} directly (not {@link cycle}).
|
|
57
|
-
*
|
|
58
|
-
* In 'suggest' mode it proposes once, attaches the diff as a repair trace, and returns the original
|
|
59
|
-
* red result unchanged (nothing applied). In 'safe-apply' mode it applies only guardrail-safe
|
|
60
|
-
* repairs and re-cycles; reaching the cap still red is a terminal state surfaced via the trace.
|
|
61
|
-
*/
|
|
62
|
-
private runRepairLoop;
|
|
63
49
|
private timeoutResult;
|
|
64
50
|
private performCycle;
|
|
65
51
|
/**
|