@ihyeon/flow-qa 0.10.7 → 0.10.9
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/src/cli.js +14 -8
- package/dist/src/ui/public/app.js +30 -2
- package/dist/src/ui/server.js +16 -11
- package/dist/src/workspace.js +86 -0
- package/docs/releases.md +5 -1
- package/package.json +1 -1
package/dist/src/cli.js
CHANGED
|
@@ -6,7 +6,7 @@ import { fileURLToPath } from 'node:url';
|
|
|
6
6
|
import { parseArgs } from 'node:util';
|
|
7
7
|
import { localeFromEnv, localized, localizeProductMessage } from "./i18n.js";
|
|
8
8
|
import { configSchema, idSchema, modelSchema, targetSchema } from "./schema.js";
|
|
9
|
-
import { initWorkspace, readConfig, readSuite, sha256, verifySuiteSource, writeConfig, writeJSON } from "./workspace.js";
|
|
9
|
+
import { initWorkspace, readConfig, readSuite, sha256, verifySuiteSource, withConfigLock, writeConfig, writeJSON } from "./workspace.js";
|
|
10
10
|
import { buildPlanningPrompt, planFlow } from "./planner.js";
|
|
11
11
|
import { compileSuite } from "./compiler.js";
|
|
12
12
|
import { CaseSelectionError, isReportSelectionValid, selectCases } from "./case-selection.js";
|
|
@@ -192,7 +192,6 @@ export async function main(args) {
|
|
|
192
192
|
return;
|
|
193
193
|
}
|
|
194
194
|
if (command === 'connect') {
|
|
195
|
-
const config = await readConfig(workspace);
|
|
196
195
|
const name = idSchema.parse(required(arg, localized(locale, 'Target name', '대상 이름'), locale));
|
|
197
196
|
const platform = values.platform ?? 'web';
|
|
198
197
|
if (!['web', 'ios', 'android'].includes(platform))
|
|
@@ -203,18 +202,25 @@ export async function main(args) {
|
|
|
203
202
|
const target = targetSchema.parse(platform === 'web'
|
|
204
203
|
? { url: required(values.url, '--url', locale) }
|
|
205
204
|
: { kind: 'mobile', platform, bundleId: required(values['bundle-id'], '--bundle-id', locale), device: required(values.device, '--device', locale) });
|
|
206
|
-
|
|
207
|
-
|
|
208
|
-
|
|
205
|
+
const saved = await withConfigLock(workspace, async () => {
|
|
206
|
+
const config = await readConfig(workspace);
|
|
207
|
+
config.targets[name] = registrationTarget(target, config.targets[name]);
|
|
208
|
+
await writeConfig(workspace, config);
|
|
209
|
+
return config.targets[name];
|
|
210
|
+
});
|
|
211
|
+
console.log(localized(locale, `Target ${name} saved: ${targetLabel(saved)}. No app has been launched.`, `대상 ${name} 저장: ${targetLabel(saved)}. 앱은 실행하지 않았습니다.`));
|
|
209
212
|
return;
|
|
210
213
|
}
|
|
211
214
|
if (command === 'model') {
|
|
212
215
|
if (arg !== 'planner' && arg !== 'agent')
|
|
213
216
|
throw new Error(localized(locale, 'Model role must be planner or agent.', '모델 종류는 planner 또는 agent여야 합니다.'));
|
|
214
|
-
const config = await readConfig(workspace);
|
|
215
217
|
const base = { baseURL: required(values.url, '--url', locale), model: required(values.model, '--model', locale), ...(values['key-env'] ? { apiKeyEnv: values['key-env'] } : {}) };
|
|
216
|
-
|
|
217
|
-
await
|
|
218
|
+
const connection = modelSchema.parse(base);
|
|
219
|
+
await withConfigLock(workspace, async () => {
|
|
220
|
+
const config = await readConfig(workspace);
|
|
221
|
+
config[arg] = connection;
|
|
222
|
+
await writeConfig(workspace, config);
|
|
223
|
+
});
|
|
218
224
|
console.log(localized(locale, `${arg} model connection saved. No model call has been made. API key values are not saved in the configuration file.`, `${arg} 모델 연결 설정 저장. 실제 호출 전입니다. API 키 값은 설정 파일에 저장하지 않습니다.`));
|
|
219
225
|
return;
|
|
220
226
|
}
|
|
@@ -5,7 +5,7 @@
|
|
|
5
5
|
const t = i18n.t;
|
|
6
6
|
const names = { scenario: 'nav.scenario', library: 'nav.library', history: 'nav.history', settings: 'nav.settings' };
|
|
7
7
|
const defaultReportFilter = () => ({ search: '', status: 'all', sort: 'recorded', repeatedOnly: false });
|
|
8
|
-
const app = { state: null, connected: false, displayTargets: [], draft: null, selectedCaseIds: new Set(), script: '', neutralScript: '', scriptRevision: 0, savedFile: '', savedHash: '', origin: 'none', sourceFlow: '', boundSource: null, stale: false, dirty: false, busy: false, planning: false, planRequest: 0, stopping: false, report: null, reportParent: null, reportMarkdown: '', selectedRun: '', reportFilter: defaultReportFilter(), rerunOrigin: null, rerunTargetMismatch: false, navigationVersion: 0, comparison: null, comparisonRequest: 0, comparisonBusy: false, comparisonStatus: 'comparison.selectBoth', comparisonPins: { baseline: null, current: null }, comparisonSelectionGeneration: 0, comparisonValidation: null, history: { runs: [], nextCursor: null, pagesLoaded: 0, loaded: false, loading: false, request: 0, debounce: null, kind: null, error: null, updatesAvailable: false, pendingRecentUpdate: false, parentRunId: '' }, view: 'scenario' };
|
|
8
|
+
const app = { state: null, connected: false, displayTargets: [], draft: null, selectedCaseIds: new Set(), script: '', neutralScript: '', scriptRevision: 0, savedFile: '', savedHash: '', origin: 'none', sourceFlow: '', boundSource: null, stale: false, dirty: false, busy: false, planning: false, planRequest: 0, stopping: false, report: null, reportParent: null, reportMarkdown: '', selectedRun: '', reportRequest: 0, reportLoading: false, reportFilter: defaultReportFilter(), rerunOrigin: null, rerunTargetMismatch: false, navigationVersion: 0, comparison: null, comparisonRequest: 0, comparisonBusy: false, comparisonStatus: 'comparison.selectBoth', comparisonPins: { baseline: null, current: null }, comparisonSelectionGeneration: 0, comparisonValidation: null, history: { runs: [], nextCursor: null, pagesLoaded: 0, loaded: false, loading: false, request: 0, debounce: null, kind: null, error: null, updatesAvailable: false, pendingRecentUpdate: false, parentRunId: '' }, view: 'scenario' };
|
|
9
9
|
|
|
10
10
|
function el(tag, className, value) {
|
|
11
11
|
const node = document.createElement(tag);
|
|
@@ -732,7 +732,35 @@
|
|
|
732
732
|
catch (error) { showError(error); }
|
|
733
733
|
finally { app.stopping = false; readiness(); }
|
|
734
734
|
}
|
|
735
|
-
async function loadReport(runId) {
|
|
735
|
+
async function loadReport(runId) {
|
|
736
|
+
if (app.busy && !app.reportLoading) return;
|
|
737
|
+
const request = ++app.reportRequest;
|
|
738
|
+
app.reportLoading = true;
|
|
739
|
+
app.busy = true;
|
|
740
|
+
readiness();
|
|
741
|
+
notice('');
|
|
742
|
+
try {
|
|
743
|
+
const result = await api(`/api/report?runId=${encodeURIComponent(runId)}`);
|
|
744
|
+
if (request !== app.reportRequest) return;
|
|
745
|
+
if (app.selectedRun !== runId) app.reportFilter = defaultReportFilter();
|
|
746
|
+
app.report = result.report;
|
|
747
|
+
app.reportParent = result.parentRun || null;
|
|
748
|
+
app.reportMarkdown = result.markdown;
|
|
749
|
+
app.selectedRun = runId;
|
|
750
|
+
renderReport();
|
|
751
|
+
readiness();
|
|
752
|
+
$('report-panel').hidden = false;
|
|
753
|
+
$('report-panel').scrollIntoView({ behavior: 'smooth', block: 'start' });
|
|
754
|
+
} catch (error) {
|
|
755
|
+
if (request === app.reportRequest) showError(error);
|
|
756
|
+
} finally {
|
|
757
|
+
if (request === app.reportRequest) {
|
|
758
|
+
app.reportLoading = false;
|
|
759
|
+
app.busy = false;
|
|
760
|
+
readiness();
|
|
761
|
+
}
|
|
762
|
+
}
|
|
763
|
+
}
|
|
736
764
|
async function prepareFailedCases() { await work(async () => {
|
|
737
765
|
const runId = app.selectedRun;
|
|
738
766
|
const report = app.report;
|
package/dist/src/ui/server.js
CHANGED
|
@@ -24,7 +24,7 @@ import { MAX_SAVED_REPORT_BYTES, RUN_ID, parseArchivedReportEnvelope, renderSave
|
|
|
24
24
|
import { compareReports, ComparisonError, renderComparisonMarkdown } from "../run-comparison.js";
|
|
25
25
|
import { configSchema, idSchema, modelSchema, suiteSchema, targetSchema } from "../schema.js";
|
|
26
26
|
import { registrationTarget, targetFingerprint } from "../targets.js";
|
|
27
|
-
import { CONFIG_FILE, sha256 } from "../workspace.js";
|
|
27
|
+
import { CONFIG_FILE, sha256, withConfigLock } from "../workspace.js";
|
|
28
28
|
const MAX_BODY = 256 * 1024;
|
|
29
29
|
const MAX_FLOW = 128 * 1024;
|
|
30
30
|
const MAX_CONFIG = 256 * 1024;
|
|
@@ -851,9 +851,11 @@ export async function startUIServer(options) {
|
|
|
851
851
|
z.object({ name: idSchema, kind: z.literal('web').optional(), url: z.string(), description: z.string().optional() }).strict(),
|
|
852
852
|
]), body);
|
|
853
853
|
const target = parse(targetSchema, input);
|
|
854
|
-
|
|
855
|
-
|
|
856
|
-
|
|
854
|
+
await withConfigLock(workspace, async () => {
|
|
855
|
+
const settings = await config();
|
|
856
|
+
settings.targets[name] = registrationTarget(target, settings.targets[name]);
|
|
857
|
+
await updateConfig(settings);
|
|
858
|
+
}, false);
|
|
857
859
|
});
|
|
858
860
|
sendJSON(response, 200, { ok: true });
|
|
859
861
|
return;
|
|
@@ -864,13 +866,16 @@ export async function startUIServer(options) {
|
|
|
864
866
|
z.object({ role: z.enum(['planner', 'agent']), clear: z.literal(true) }).strict(),
|
|
865
867
|
z.object({ role: z.enum(['planner', 'agent']), baseURL: z.string(), model: z.string(), apiKeyEnv: z.string().optional() }).strict(),
|
|
866
868
|
]), body);
|
|
867
|
-
const
|
|
868
|
-
|
|
869
|
-
|
|
870
|
-
|
|
871
|
-
|
|
872
|
-
|
|
873
|
-
|
|
869
|
+
const connection = 'clear' in change ? undefined : parse(modelSchema, { baseURL: change.baseURL, model: change.model,
|
|
870
|
+
...(change.apiKeyEnv === undefined ? {} : { apiKeyEnv: change.apiKeyEnv }) });
|
|
871
|
+
await withConfigLock(workspace, async () => {
|
|
872
|
+
const settings = await config();
|
|
873
|
+
if (connection)
|
|
874
|
+
settings[change.role] = connection;
|
|
875
|
+
else
|
|
876
|
+
delete settings[change.role];
|
|
877
|
+
await updateConfig(settings);
|
|
878
|
+
}, false);
|
|
874
879
|
});
|
|
875
880
|
sendJSON(response, 200, { ok: true });
|
|
876
881
|
return;
|
package/dist/src/workspace.js
CHANGED
|
@@ -1,8 +1,94 @@
|
|
|
1
|
+
import { constants } from 'node:fs';
|
|
1
2
|
import { lstat, mkdir, open, readFile, realpath, rename, unlink, writeFile } from 'node:fs/promises';
|
|
2
3
|
import { resolve, dirname } from 'node:path';
|
|
3
4
|
import { createHash, randomUUID } from 'node:crypto';
|
|
5
|
+
import { setTimeout as delay } from 'node:timers/promises';
|
|
4
6
|
import { configSchema, suiteSchema } from "./schema.js";
|
|
5
7
|
export const CONFIG_FILE = 'flowqa.config.json';
|
|
8
|
+
const localConfigWriters = new Map();
|
|
9
|
+
/** Serialize read-modify-write changes from CLI processes and the local UI. */
|
|
10
|
+
export async function withConfigLock(workspace, change, allowSymlink = true) {
|
|
11
|
+
const alias = resolve(workspace, CONFIG_FILE);
|
|
12
|
+
if (!allowSymlink && (await lstat(alias)).isSymbolicLink())
|
|
13
|
+
throw new Error('Invalid configuration file path.');
|
|
14
|
+
let file;
|
|
15
|
+
try {
|
|
16
|
+
file = await realpath(alias);
|
|
17
|
+
}
|
|
18
|
+
catch (error) {
|
|
19
|
+
if (error.code === 'ENOENT')
|
|
20
|
+
throw new Error('flowqa.config.json is missing. Run flow-qa init first.');
|
|
21
|
+
throw error;
|
|
22
|
+
}
|
|
23
|
+
const lockDirectory = resolve(dirname(file), '.flowqa');
|
|
24
|
+
await mkdir(lockDirectory, { recursive: true, mode: 0o700 });
|
|
25
|
+
const directoryInfo = await lstat(lockDirectory);
|
|
26
|
+
if (!directoryInfo.isDirectory() || directoryInfo.isSymbolicLink() || await realpath(lockDirectory) !== lockDirectory) {
|
|
27
|
+
throw new Error('Invalid configuration lock path.');
|
|
28
|
+
}
|
|
29
|
+
const lockFile = resolve(lockDirectory, `config-lock-${sha256(file)}.sqlite`);
|
|
30
|
+
const previous = localConfigWriters.get(lockFile);
|
|
31
|
+
let releaseLocal;
|
|
32
|
+
const localTurn = new Promise(resolveTurn => { releaseLocal = resolveTurn; });
|
|
33
|
+
localConfigWriters.set(lockFile, localTurn);
|
|
34
|
+
if (previous)
|
|
35
|
+
await previous;
|
|
36
|
+
try {
|
|
37
|
+
const noFollow = process.platform === 'win32' ? 0 : constants.O_NOFOLLOW;
|
|
38
|
+
let handle;
|
|
39
|
+
try {
|
|
40
|
+
handle = await open(lockFile, constants.O_CREAT | constants.O_EXCL | constants.O_RDWR | noFollow, 0o600);
|
|
41
|
+
}
|
|
42
|
+
catch (error) {
|
|
43
|
+
if (error.code !== 'EEXIST')
|
|
44
|
+
throw error;
|
|
45
|
+
handle = await open(lockFile, constants.O_RDWR | noFollow);
|
|
46
|
+
}
|
|
47
|
+
try {
|
|
48
|
+
const opened = await handle.stat();
|
|
49
|
+
const pathInfo = await lstat(lockFile);
|
|
50
|
+
if (!opened.isFile() || !pathInfo.isFile() || pathInfo.isSymbolicLink() || pathInfo.nlink !== 1 ||
|
|
51
|
+
opened.dev !== pathInfo.dev || opened.ino !== pathInfo.ino ||
|
|
52
|
+
process.platform !== 'win32' && (opened.mode & 0o077) !== 0) {
|
|
53
|
+
throw new Error('Invalid configuration lock file.');
|
|
54
|
+
}
|
|
55
|
+
}
|
|
56
|
+
finally {
|
|
57
|
+
await handle.close();
|
|
58
|
+
}
|
|
59
|
+
const { DatabaseSync } = await import('node:sqlite');
|
|
60
|
+
const database = new DatabaseSync(lockFile);
|
|
61
|
+
const deadline = Date.now() + 20_000;
|
|
62
|
+
let acquired = false;
|
|
63
|
+
try {
|
|
64
|
+
database.exec('PRAGMA busy_timeout = 0');
|
|
65
|
+
while (!acquired) {
|
|
66
|
+
try {
|
|
67
|
+
database.exec('BEGIN IMMEDIATE');
|
|
68
|
+
acquired = true;
|
|
69
|
+
}
|
|
70
|
+
catch (error) {
|
|
71
|
+
if (error.errcode !== 5)
|
|
72
|
+
throw error;
|
|
73
|
+
if (Date.now() >= deadline)
|
|
74
|
+
throw new Error('Could not update configuration while another process is saving it. Retry the command.');
|
|
75
|
+
await delay(40);
|
|
76
|
+
}
|
|
77
|
+
}
|
|
78
|
+
return await change();
|
|
79
|
+
}
|
|
80
|
+
finally {
|
|
81
|
+
if (acquired)
|
|
82
|
+
database.exec('ROLLBACK');
|
|
83
|
+
database.close();
|
|
84
|
+
}
|
|
85
|
+
}
|
|
86
|
+
finally {
|
|
87
|
+
releaseLocal();
|
|
88
|
+
if (localConfigWriters.get(lockFile) === localTurn)
|
|
89
|
+
localConfigWriters.delete(lockFile);
|
|
90
|
+
}
|
|
91
|
+
}
|
|
6
92
|
export async function readConfig(workspace) {
|
|
7
93
|
try {
|
|
8
94
|
return configSchema.parse(JSON.parse(await readFile(resolve(workspace, CONFIG_FILE), 'utf8')));
|
package/docs/releases.md
CHANGED
|
@@ -1,5 +1,9 @@
|
|
|
1
1
|
# Releases and verification
|
|
2
2
|
|
|
3
|
+
## 0.10.8 — Concurrent configuration updates
|
|
4
|
+
|
|
5
|
+
CLI `connect` and `model` commands and the local UI's target and model settings now lock the same canonical configuration file before reading and saving it. Concurrent commands that update different targets or model roles retain every successful change. The lock is stored in the private `.flowqa` directory beside the actual configuration file, including when a CLI workspace uses a symlink to that file. A terminated writer releases its SQLite lock automatically, so another command can retry. Each save still replaces the complete JSON file after it is written.
|
|
6
|
+
|
|
3
7
|
## 0.10.1 — Hyeonse Design System 0.5.0
|
|
4
8
|
|
|
5
9
|
The local UI packages the CSS, preference module, and MIT license from the public Hyeonse Design System 0.5.0 archive. The installed Flow QA package serves byte-identical copies of these files.
|
|
@@ -347,7 +351,7 @@ The npm trusted publisher is configured for GitHub repository `hyeonse-swing/flo
|
|
|
347
351
|
## 0.1.3
|
|
348
352
|
|
|
349
353
|
- `doctor` reports whether each configured planner or agent key environment variable is present, missing, or not configured. English and Korean diagnostics show no credential values and make no model requests. The command remains informational.
|
|
350
|
-
- CLI target and model configuration updates
|
|
354
|
+
- At this release, CLI target and model configuration updates wrote a private temporary file, synchronized it, and replaced the configuration only after the new JSON was complete. Existing initialization and exclusive case-file creation behavior were preserved. This protected against partially written configuration during process interruption. Concurrent CLI updates were not serialized at this release, and rename durability after power loss was not guaranteed.
|
|
351
355
|
- CI runs the existing test, browser, UI, and package-install checks on Ubuntu and macOS before publishing. Successful npm publication and its consumer smoke check now also create the corresponding GitHub release.
|
|
352
356
|
|
|
353
357
|
- Package: [`@ihyeon/flow-qa@0.1.3`](https://www.npmjs.com/package/@ihyeon/flow-qa/v/0.1.3)
|