qualiow-exploratory-testing 1.3.0 → 2.0.0
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/.claude-plugin/plugin.json +22 -0
- package/.env.example +27 -0
- package/CHANGELOG.md +194 -0
- package/README.md +362 -205
- package/agents/qa-gather-agent.md +24 -0
- package/{scripts → bin}/doctor-mobile.sh +57 -18
- package/bin/mcli +15 -9
- package/bin/mobile-cli.mjs +574 -286
- package/{scripts → bin}/setup-mobile.sh +56 -19
- package/bin/wadb +10 -4
- package/bin/wk-ios +29 -17
- package/bin/wkeval.mjs +7 -1
- package/data/domains/_default.yml +1 -1
- package/data/knowledge/changelog.yml +30 -12
- package/data/knowledge/manifest.yml +333 -127
- package/data/knowledge/releases/v0.1.0/entries/technique-business-logic-race-conditions.yml +1 -1
- package/data/knowledge/releases/v0.1.0/release.yml +8 -1
- package/data/knowledge/releases/v0.6.0/entries/technique-async-callback-contracts.yml +98 -0
- package/data/knowledge/releases/v0.6.0/entries/technique-exactly-once-verification.yml +116 -0
- package/data/knowledge/releases/v0.6.0/release.yml +30 -0
- package/data/security/SECURITY-POLICY.md +273 -0
- package/data/targets/_default.yml +1 -1
- package/data/targets/_example-api-only.yml +80 -0
- package/data/targets/_example-mobile-emulation.yml +2 -2
- package/data/targets/_example-native-mobile.yml +2 -2
- package/data/targets/_example-sim-android-chrome.yml +1 -1
- package/data/targets/_example-sim-ios-safari.yml +1 -1
- package/data/templates/api-probe-matrix.md +3 -3
- package/data/templates/bug-report.md +29 -151
- package/data/templates/coverage-map.md +9 -6
- package/data/templates/expected-behaviour.md +3 -2
- package/data/templates/session-charter.md +3 -0
- package/data/templates/session-report.md +57 -80
- package/dist/cli/index.js +1452 -700
- package/dist/index.d.ts +589 -81
- package/dist/index.js +1612 -227
- package/docs/BACKEND-VERIFICATION.md +39 -9
- package/docs/GETTING-STARTED.md +188 -128
- package/docs/MOBILE-SETUP.md +149 -18
- package/package.json +32 -18
- package/skills/qa-explore/SKILL.md +31 -25
- package/skills/qa-explore/phases/00-setup.md +67 -41
- package/skills/qa-explore/phases/01-auth.md +32 -15
- package/skills/qa-explore/phases/02-charter.md +16 -5
- package/skills/qa-explore/phases/03-discovery.md +50 -26
- package/skills/qa-explore/phases/04-journeys.md +2 -2
- package/skills/qa-explore/phases/05-features.md +39 -24
- package/skills/qa-explore/phases/06-edge-cases.md +24 -13
- package/skills/qa-explore/phases/07-reporting.md +79 -140
- package/skills/qa-explore/references/context-integration.md +1 -1
- package/skills/qa-explore/references/output-contract.md +187 -0
- package/skills/qa-explore/references/paths.md +84 -0
- package/skills/qa-explore/references/playwright-agents-integration.md +61 -84
- package/skills/qa-explore/references/security-rules.md +66 -25
- package/skills/qa-explore/references/severity-guide.md +31 -4
- package/skills/qa-explore-cleanup/SKILL.md +17 -6
- package/skills/qa-explore-feedback/SKILL.md +18 -5
- package/skills/qa-explore-mobile/SKILL.md +86 -64
- package/skills/qa-explore-mobile/phases/00-setup.md +71 -62
- package/skills/qa-explore-mobile/phases/01-auth.md +28 -31
- package/skills/qa-explore-mobile/phases/02-charter.md +8 -4
- package/skills/qa-explore-mobile/phases/03-discovery.md +17 -11
- package/skills/qa-explore-mobile/phases/04-journeys.md +6 -6
- package/skills/qa-explore-mobile/phases/05-features.md +9 -9
- package/skills/qa-explore-mobile/phases/06-edge-cases.md +35 -40
- package/skills/qa-explore-mobile/phases/07-reporting.md +82 -56
- package/skills/qa-explore-mobile/references/mobile-edges.md +26 -26
- package/skills/qa-explore-quick/SKILL.md +60 -25
- package/skills/qa-explore-report/SKILL.md +40 -34
- package/skills/qa-gather/SKILL.md +17 -2
- package/skills/qa-knowledge-add/SKILL.md +20 -9
- package/skills/qa-knowledge-list/SKILL.md +12 -3
- package/skills/qa-target-setup/SKILL.md +63 -41
- package/skills/qa-verify-backend/SKILL.md +26 -17
- package/skills/qa-verify-backend/phases/00-setup.md +57 -12
- package/skills/qa-verify-backend/phases/01-ac-decomposition.md +2 -2
- package/skills/qa-verify-backend/phases/03-live-verification.md +3 -3
- package/skills/qa-verify-backend/phases/03b-api-verification.md +22 -9
- package/skills/qa-verify-backend/phases/04-e2e-trigger.md +18 -2
- package/skills/qa-verify-backend/phases/05-reporting.md +38 -10
- package/skills/qa-verify-backend/references/api-probes.md +28 -1
- package/skills/qa-verify-backend/references/payload-verification.md +1 -1
- package/skills/qa-verify-backend/references/release-readiness.md +1 -1
- package/skills/qa-verify-backend/references/safety-rules.md +13 -8
- package/data/domains/_default.md +0 -181
- package/data/domains/ecommerce.md +0 -192
- package/data/domains/fintech.md +0 -200
- package/data/domains/identity.md +0 -88
- package/data/domains/marketing.md +0 -194
- package/data/domains/saas.md +0 -197
- package/dist/cli/index.d.ts +0 -1
- package/dist/cli/index.js.map +0 -1
- package/dist/index.js.map +0 -1
package/dist/cli/index.js
CHANGED
|
@@ -5,64 +5,145 @@ import { Command as Command7 } from "commander";
|
|
|
5
5
|
|
|
6
6
|
// src/cli/commands/init.ts
|
|
7
7
|
import { Command } from "commander";
|
|
8
|
-
import {
|
|
9
|
-
import { dirname, resolve, join } from "path";
|
|
8
|
+
import { resolve as resolve2, join as join2, relative, dirname as dirname2 } from "path";
|
|
10
9
|
import {
|
|
11
|
-
existsSync,
|
|
12
|
-
readFileSync,
|
|
10
|
+
existsSync as existsSync2,
|
|
11
|
+
readFileSync as readFileSync2,
|
|
13
12
|
writeFileSync,
|
|
14
13
|
mkdirSync,
|
|
15
|
-
readdirSync
|
|
14
|
+
readdirSync,
|
|
15
|
+
statSync,
|
|
16
|
+
copyFileSync,
|
|
17
|
+
chmodSync
|
|
16
18
|
} from "fs";
|
|
17
|
-
import { cp } from "fs/promises";
|
|
18
19
|
import chalk from "chalk";
|
|
19
|
-
|
|
20
|
-
|
|
21
|
-
|
|
20
|
+
|
|
21
|
+
// src/utils/paths.ts
|
|
22
|
+
import { fileURLToPath } from "url";
|
|
23
|
+
import { dirname, resolve, join, basename } from "path";
|
|
24
|
+
import { existsSync, readFileSync } from "fs";
|
|
25
|
+
var HERE = dirname(fileURLToPath(import.meta.url));
|
|
26
|
+
function getPackageRoot() {
|
|
27
|
+
let current = HERE;
|
|
22
28
|
for (let i = 0; i < 10; i++) {
|
|
23
29
|
if (existsSync(join(current, "data")) && existsSync(join(current, "package.json"))) {
|
|
24
30
|
return current;
|
|
25
31
|
}
|
|
26
|
-
|
|
32
|
+
const parent = dirname(current);
|
|
33
|
+
if (parent === current) break;
|
|
34
|
+
current = parent;
|
|
27
35
|
}
|
|
28
|
-
return resolve(
|
|
36
|
+
return resolve(HERE, "..", "..");
|
|
37
|
+
}
|
|
38
|
+
function getPackageVersion(pkgRoot = getPackageRoot()) {
|
|
39
|
+
try {
|
|
40
|
+
const pkg = JSON.parse(
|
|
41
|
+
readFileSync(join(pkgRoot, "package.json"), "utf-8")
|
|
42
|
+
);
|
|
43
|
+
return pkg.version ?? "0.0.0";
|
|
44
|
+
} catch {
|
|
45
|
+
return "0.0.0";
|
|
46
|
+
}
|
|
47
|
+
}
|
|
48
|
+
function resolveSkillsSource(pkgRoot) {
|
|
49
|
+
const shipped = join(pkgRoot, "skills");
|
|
50
|
+
if (existsSync(shipped)) return shipped;
|
|
51
|
+
const canonical = join(pkgRoot, ".claude", "skills");
|
|
52
|
+
if (existsSync(canonical)) return canonical;
|
|
53
|
+
return null;
|
|
54
|
+
}
|
|
55
|
+
function resolveTargetPath(cwd, name, pkgRoot = getPackageRoot()) {
|
|
56
|
+
if (name) {
|
|
57
|
+
const candidates = [
|
|
58
|
+
resolve(cwd, "data", "targets", `${name}.yml`),
|
|
59
|
+
resolve(pkgRoot, "data", "targets", `${name}.yml`)
|
|
60
|
+
];
|
|
61
|
+
return candidates.find((p) => existsSync(p)) ?? candidates[0];
|
|
62
|
+
}
|
|
63
|
+
const projectLocal = resolve(cwd, "qa", "target.yml");
|
|
64
|
+
if (existsSync(projectLocal)) return projectLocal;
|
|
65
|
+
const cwdDefault = resolve(cwd, "data", "targets", "_default.yml");
|
|
66
|
+
if (existsSync(cwdDefault)) return cwdDefault;
|
|
67
|
+
return resolve(pkgRoot, "data", "targets", "_default.yml");
|
|
68
|
+
}
|
|
69
|
+
|
|
70
|
+
// src/utils/index-files.ts
|
|
71
|
+
var INDEX_COLUMNS = [
|
|
72
|
+
"Date",
|
|
73
|
+
"Kind",
|
|
74
|
+
"Target",
|
|
75
|
+
"Bugs",
|
|
76
|
+
"Duration",
|
|
77
|
+
"Status",
|
|
78
|
+
"Report"
|
|
79
|
+
];
|
|
80
|
+
var ALL_BUGS_COLUMNS = [
|
|
81
|
+
"ID",
|
|
82
|
+
"Session",
|
|
83
|
+
"Title",
|
|
84
|
+
"Severity",
|
|
85
|
+
"Status",
|
|
86
|
+
"Report"
|
|
87
|
+
];
|
|
88
|
+
function table(title, note, columns) {
|
|
89
|
+
const header = `| ${columns.join(" | ")} |`;
|
|
90
|
+
const sep = `|${columns.map(() => "---").join("|")}|`;
|
|
91
|
+
return `# ${title}
|
|
92
|
+
|
|
93
|
+
${note}
|
|
94
|
+
|
|
95
|
+
${header}
|
|
96
|
+
${sep}
|
|
97
|
+
`;
|
|
29
98
|
}
|
|
30
|
-
var
|
|
31
|
-
"",
|
|
32
|
-
"
|
|
99
|
+
var INDEX_MD_HEADER = table(
|
|
100
|
+
"Exploratory Testing Sessions",
|
|
101
|
+
"_Index of exploratory testing sessions. Newest last._",
|
|
102
|
+
INDEX_COLUMNS
|
|
103
|
+
);
|
|
104
|
+
var ALL_BUGS_MD_HEADER = table(
|
|
105
|
+
"All Bugs Found",
|
|
106
|
+
"_Consolidated index across all exploratory testing sessions._",
|
|
107
|
+
ALL_BUGS_COLUMNS
|
|
108
|
+
);
|
|
109
|
+
|
|
110
|
+
// src/utils/gitignore.ts
|
|
111
|
+
var QUALIOW_GITIGNORE_HEADER = "# Qualiow";
|
|
112
|
+
var QUALIOW_GITIGNORE_ENTRIES = [
|
|
33
113
|
".auth/",
|
|
34
114
|
".env",
|
|
115
|
+
"qa/.env",
|
|
35
116
|
"output/sessions/*/",
|
|
117
|
+
"!output/sessions/INDEX.md",
|
|
118
|
+
"output/context/*.md",
|
|
119
|
+
"data/targets/local-*.yml",
|
|
36
120
|
".playwright-cli/",
|
|
37
121
|
"*.trace.zip",
|
|
38
|
-
"*.webm"
|
|
39
|
-
"dist/"
|
|
122
|
+
"*.webm"
|
|
40
123
|
];
|
|
41
|
-
|
|
42
|
-
|
|
43
|
-
|
|
44
|
-
|
|
45
|
-
|
|
46
|
-
|
|
47
|
-
|
|
48
|
-
|
|
49
|
-
|
|
50
|
-
|
|
51
|
-
|
|
52
|
-
|
|
53
|
-
|
|
54
|
-
|
|
55
|
-
|
|
56
|
-
|
|
57
|
-
|
|
124
|
+
function mergeGitignore(existing) {
|
|
125
|
+
const existingLines = new Set(
|
|
126
|
+
existing.split("\n").map((l) => l.replace(/\s+$/, ""))
|
|
127
|
+
);
|
|
128
|
+
const missing = QUALIOW_GITIGNORE_ENTRIES.filter(
|
|
129
|
+
(e) => !existingLines.has(e)
|
|
130
|
+
);
|
|
131
|
+
if (missing.length === 0) return null;
|
|
132
|
+
const block = [];
|
|
133
|
+
if (!existingLines.has(QUALIOW_GITIGNORE_HEADER)) {
|
|
134
|
+
block.push(QUALIOW_GITIGNORE_HEADER);
|
|
135
|
+
}
|
|
136
|
+
block.push(...missing);
|
|
137
|
+
const prefix = existing.length === 0 || existing.endsWith("\n") ? "" : "\n";
|
|
138
|
+
const leadingBlank = existing.length > 0 ? "\n" : "";
|
|
139
|
+
return existing + prefix + leadingBlank + block.join("\n") + "\n";
|
|
140
|
+
}
|
|
58
141
|
|
|
59
|
-
|
|
60
|
-
# HEADLESS=false
|
|
61
|
-
`;
|
|
142
|
+
// src/cli/commands/init.ts
|
|
62
143
|
function initCommand() {
|
|
63
|
-
const cmd = new Command("init").description("Initialize qualiow in the current project").option("--include-examples", "
|
|
144
|
+
const cmd = new Command("init").description("Initialize qualiow in the current project").option("--include-examples", "Also install the _example-* and testers-ai target configs", false).option("--force", "Overwrite files that already exist and differ", false).option("--dry-run", "Print what would be written without writing anything", false).action(async (options) => {
|
|
64
145
|
try {
|
|
65
|
-
await runInit(options);
|
|
146
|
+
await runInit(options, { cwd: process.cwd() });
|
|
66
147
|
} catch (err) {
|
|
67
148
|
console.error(chalk.red("Error during init:"), err instanceof Error ? err.message : err);
|
|
68
149
|
process.exit(1);
|
|
@@ -70,159 +151,191 @@ function initCommand() {
|
|
|
70
151
|
});
|
|
71
152
|
return cmd;
|
|
72
153
|
}
|
|
73
|
-
|
|
74
|
-
|
|
75
|
-
|
|
76
|
-
|
|
77
|
-
|
|
78
|
-
|
|
79
|
-
|
|
80
|
-
|
|
81
|
-
|
|
82
|
-
|
|
83
|
-
|
|
154
|
+
function sameContent(a, b) {
|
|
155
|
+
try {
|
|
156
|
+
return readFileSync2(a).equals(readFileSync2(b));
|
|
157
|
+
} catch {
|
|
158
|
+
return false;
|
|
159
|
+
}
|
|
160
|
+
}
|
|
161
|
+
function copyEntry(src, dest, opts) {
|
|
162
|
+
let status;
|
|
163
|
+
if (!existsSync2(dest)) {
|
|
164
|
+
status = "installed";
|
|
165
|
+
} else if (sameContent(src, dest)) {
|
|
166
|
+
status = "unchanged";
|
|
167
|
+
} else {
|
|
168
|
+
status = opts.force ? "overwritten" : "skipped";
|
|
169
|
+
}
|
|
170
|
+
if (!opts.dryRun && (status === "installed" || status === "overwritten")) {
|
|
171
|
+
mkdirSync(dirname2(dest), { recursive: true });
|
|
172
|
+
copyFileSync(src, dest);
|
|
173
|
+
chmodSync(dest, statSync(src).mode & 511);
|
|
84
174
|
}
|
|
85
|
-
|
|
86
|
-
|
|
87
|
-
|
|
88
|
-
|
|
89
|
-
|
|
90
|
-
|
|
91
|
-
|
|
92
|
-
|
|
93
|
-
|
|
175
|
+
return { dest, status };
|
|
176
|
+
}
|
|
177
|
+
function listFiles(dir, filter) {
|
|
178
|
+
const out = [];
|
|
179
|
+
const walk = (current) => {
|
|
180
|
+
for (const entry of readdirSync(current, { withFileTypes: true })) {
|
|
181
|
+
const full = join2(current, entry.name);
|
|
182
|
+
if (entry.isDirectory()) {
|
|
183
|
+
walk(full);
|
|
94
184
|
} else {
|
|
95
|
-
|
|
185
|
+
const rel = relative(dir, full).split("\\").join("/");
|
|
186
|
+
if (!filter || filter(rel)) out.push(rel);
|
|
96
187
|
}
|
|
97
|
-
} else {
|
|
98
|
-
console.log(chalk.cyan(" \u25CB Skills directory is the same as source \u2014 skipped"));
|
|
99
188
|
}
|
|
189
|
+
};
|
|
190
|
+
walk(dir);
|
|
191
|
+
return out.sort();
|
|
192
|
+
}
|
|
193
|
+
function copyTree(srcDir, destDir, opts) {
|
|
194
|
+
if (!existsSync2(srcDir)) return [];
|
|
195
|
+
return listFiles(srcDir, opts.filter).map(
|
|
196
|
+
(rel) => copyEntry(join2(srcDir, rel), join2(destDir, rel), opts)
|
|
197
|
+
);
|
|
198
|
+
}
|
|
199
|
+
async function runInit(options, ctx) {
|
|
200
|
+
const cwd = ctx.cwd;
|
|
201
|
+
const pkgRoot = ctx.pkgRoot ?? getPackageRoot();
|
|
202
|
+
const log = ctx.log ?? ((line) => console.log(line));
|
|
203
|
+
const copyOpts = { force: options.force, dryRun: options.dryRun };
|
|
204
|
+
const copies = [];
|
|
205
|
+
const createdDirs = [];
|
|
206
|
+
const createdFiles = [];
|
|
207
|
+
if (options.dryRun) log(chalk.cyan.bold("Dry run \u2014 nothing will be written\n"));
|
|
208
|
+
if (resolve2(pkgRoot) === resolve2(cwd)) {
|
|
209
|
+
log(chalk.yellow(" \u25CB Running inside the package itself \u2014 skills and data are already in place"));
|
|
100
210
|
} else {
|
|
101
|
-
|
|
102
|
-
|
|
103
|
-
|
|
104
|
-
|
|
105
|
-
|
|
106
|
-
|
|
107
|
-
|
|
108
|
-
|
|
109
|
-
|
|
110
|
-
|
|
111
|
-
|
|
112
|
-
|
|
113
|
-
|
|
114
|
-
|
|
115
|
-
|
|
116
|
-
|
|
117
|
-
|
|
118
|
-
|
|
119
|
-
|
|
120
|
-
|
|
121
|
-
|
|
122
|
-
|
|
123
|
-
|
|
124
|
-
|
|
125
|
-
|
|
126
|
-
|
|
127
|
-
|
|
128
|
-
|
|
129
|
-
|
|
130
|
-
|
|
131
|
-
|
|
132
|
-
|
|
133
|
-
|
|
134
|
-
|
|
135
|
-
|
|
136
|
-
|
|
137
|
-
|
|
138
|
-
|
|
139
|
-
|
|
140
|
-
const targetFiles = readdirSync(targetsSrc).filter(
|
|
141
|
-
(f) => f.endsWith(".yml") && f !== "_default.yml"
|
|
142
|
-
);
|
|
143
|
-
for (const file of targetFiles) {
|
|
144
|
-
const content = readFileSync(join(targetsSrc, file), "utf-8");
|
|
145
|
-
writeFileSync(join(targetsDest, file), content);
|
|
146
|
-
}
|
|
147
|
-
console.log(chalk.green(" \u2713 Target configs installed to data/targets/ (with examples)"));
|
|
148
|
-
} else {
|
|
149
|
-
console.log(chalk.green(" \u2713 Default target config installed to data/targets/"));
|
|
211
|
+
const skillsSrc = resolveSkillsSource(pkgRoot);
|
|
212
|
+
if (!skillsSrc) {
|
|
213
|
+
throw new Error(`No skills directory found under ${pkgRoot}`);
|
|
214
|
+
}
|
|
215
|
+
copies.push(
|
|
216
|
+
...copyTree(skillsSrc, join2(cwd, ".claude", "skills"), {
|
|
217
|
+
...copyOpts,
|
|
218
|
+
filter: (rel2) => rel2.startsWith("qa-")
|
|
219
|
+
})
|
|
220
|
+
);
|
|
221
|
+
const agentCandidates = [
|
|
222
|
+
join2(pkgRoot, "agents", "qa-gather-agent.md"),
|
|
223
|
+
join2(pkgRoot, ".claude", "agents", "qa-gather-agent.md")
|
|
224
|
+
];
|
|
225
|
+
const agentSrc = agentCandidates.find((p) => existsSync2(p));
|
|
226
|
+
if (agentSrc) {
|
|
227
|
+
copies.push(
|
|
228
|
+
copyEntry(agentSrc, join2(cwd, ".claude", "agents", "qa-gather-agent.md"), copyOpts)
|
|
229
|
+
);
|
|
230
|
+
}
|
|
231
|
+
const dataSrc = join2(pkgRoot, "data");
|
|
232
|
+
copies.push(...copyTree(join2(dataSrc, "knowledge"), join2(cwd, "data", "knowledge"), copyOpts));
|
|
233
|
+
copies.push(
|
|
234
|
+
...copyTree(join2(dataSrc, "domains"), join2(cwd, "data", "domains"), {
|
|
235
|
+
...copyOpts,
|
|
236
|
+
filter: (rel2) => rel2.endsWith(".yml")
|
|
237
|
+
})
|
|
238
|
+
);
|
|
239
|
+
copies.push(...copyTree(join2(dataSrc, "templates"), join2(cwd, "data", "templates"), copyOpts));
|
|
240
|
+
copies.push(...copyTree(join2(dataSrc, "security"), join2(cwd, "data", "security"), copyOpts));
|
|
241
|
+
copies.push(
|
|
242
|
+
...copyTree(join2(dataSrc, "targets"), join2(cwd, "data", "targets"), {
|
|
243
|
+
...copyOpts,
|
|
244
|
+
filter: (rel2) => {
|
|
245
|
+
if (!rel2.endsWith(".yml") || rel2.includes("/")) return false;
|
|
246
|
+
if (rel2.startsWith("local-")) return false;
|
|
247
|
+
if (rel2 === "_default.yml") return true;
|
|
248
|
+
if (!options.includeExamples) return false;
|
|
249
|
+
return rel2.startsWith("_example-") || rel2 === "testers-ai.yml";
|
|
150
250
|
}
|
|
251
|
+
})
|
|
252
|
+
);
|
|
253
|
+
const binSrc = join2(pkgRoot, "bin");
|
|
254
|
+
copies.push(...copyTree(binSrc, join2(cwd, "qa", "bin"), copyOpts));
|
|
255
|
+
if (existsSync2(binSrc)) {
|
|
256
|
+
const versionPath = join2(cwd, "qa", "bin", "VERSION");
|
|
257
|
+
const version = `${getPackageVersion(pkgRoot)}
|
|
258
|
+
`;
|
|
259
|
+
const exists = existsSync2(versionPath);
|
|
260
|
+
const same = exists && readFileSync2(versionPath, "utf-8") === version;
|
|
261
|
+
const status = !exists ? "installed" : same ? "unchanged" : options.force ? "overwritten" : "skipped";
|
|
262
|
+
if (!options.dryRun && (status === "installed" || status === "overwritten")) {
|
|
263
|
+
mkdirSync(dirname2(versionPath), { recursive: true });
|
|
264
|
+
writeFileSync(versionPath, version);
|
|
151
265
|
}
|
|
152
|
-
|
|
153
|
-
|
|
154
|
-
|
|
155
|
-
|
|
156
|
-
|
|
157
|
-
|
|
158
|
-
|
|
159
|
-
|
|
160
|
-
|
|
161
|
-
|
|
162
|
-
|
|
163
|
-
|
|
164
|
-
|
|
165
|
-
|
|
166
|
-
|
|
167
|
-
|
|
168
|
-
|
|
169
|
-
|
|
170
|
-
|
|
171
|
-
|
|
172
|
-
|
|
173
|
-
|
|
174
|
-
|
|
175
|
-
|
|
176
|
-
const envExamplePath = join(cwd, ".env.example");
|
|
177
|
-
if (!existsSync(envExamplePath)) {
|
|
178
|
-
writeFileSync(envExamplePath, ENV_EXAMPLE);
|
|
179
|
-
console.log(chalk.green(" \u2713 Created .env.example"));
|
|
180
|
-
}
|
|
181
|
-
const gitignorePath = join(cwd, ".gitignore");
|
|
182
|
-
let gitignoreContent = "";
|
|
183
|
-
if (existsSync(gitignorePath)) {
|
|
184
|
-
gitignoreContent = readFileSync(gitignorePath, "utf-8");
|
|
185
|
-
}
|
|
186
|
-
const linesToAdd = [];
|
|
187
|
-
for (const entry of GITIGNORE_ENTRIES) {
|
|
188
|
-
if (entry === "" || entry.startsWith("#")) {
|
|
189
|
-
if (!gitignoreContent.includes("# Qualiow") && entry === "# Qualiow") {
|
|
190
|
-
linesToAdd.push(entry);
|
|
191
|
-
} else if (entry === "" && linesToAdd.length === 0) {
|
|
192
|
-
linesToAdd.push(entry);
|
|
266
|
+
copies.push({ dest: versionPath, status });
|
|
267
|
+
}
|
|
268
|
+
const envExampleSrc = join2(pkgRoot, ".env.example");
|
|
269
|
+
if (existsSync2(envExampleSrc)) {
|
|
270
|
+
copies.push(copyEntry(envExampleSrc, join2(cwd, "qa", ".env.example"), copyOpts));
|
|
271
|
+
}
|
|
272
|
+
}
|
|
273
|
+
for (const dir of ["output/sessions", "output/bugs", "output/context", ".auth", "qa"]) {
|
|
274
|
+
const full = join2(cwd, dir);
|
|
275
|
+
if (!existsSync2(full)) {
|
|
276
|
+
createdDirs.push(full);
|
|
277
|
+
if (!options.dryRun) mkdirSync(full, { recursive: true });
|
|
278
|
+
}
|
|
279
|
+
}
|
|
280
|
+
for (const [rel2, content] of [
|
|
281
|
+
["output/sessions/INDEX.md", INDEX_MD_HEADER],
|
|
282
|
+
["output/bugs/all-bugs.md", ALL_BUGS_MD_HEADER]
|
|
283
|
+
]) {
|
|
284
|
+
const full = join2(cwd, rel2);
|
|
285
|
+
if (!existsSync2(full)) {
|
|
286
|
+
createdFiles.push(full);
|
|
287
|
+
if (!options.dryRun) {
|
|
288
|
+
mkdirSync(dirname2(full), { recursive: true });
|
|
289
|
+
writeFileSync(full, content);
|
|
193
290
|
}
|
|
194
|
-
continue;
|
|
195
|
-
}
|
|
196
|
-
if (!gitignoreContent.includes(entry)) {
|
|
197
|
-
linesToAdd.push(entry);
|
|
198
291
|
}
|
|
199
292
|
}
|
|
200
|
-
|
|
201
|
-
|
|
202
|
-
|
|
203
|
-
|
|
293
|
+
const gitignorePath = join2(cwd, ".gitignore");
|
|
294
|
+
const existing = existsSync2(gitignorePath) ? readFileSync2(gitignorePath, "utf-8") : "";
|
|
295
|
+
const merged = mergeGitignore(existing);
|
|
296
|
+
const gitignoreUpdated = merged !== null;
|
|
297
|
+
if (merged !== null && !options.dryRun) {
|
|
298
|
+
writeFileSync(gitignorePath, merged);
|
|
204
299
|
}
|
|
205
|
-
|
|
206
|
-
|
|
207
|
-
|
|
208
|
-
|
|
209
|
-
|
|
210
|
-
|
|
211
|
-
|
|
212
|
-
|
|
300
|
+
const counts = { installed: 0, unchanged: 0, overwritten: 0, skipped: 0 };
|
|
301
|
+
for (const c of copies) counts[c.status]++;
|
|
302
|
+
const rel = (p) => relative(cwd, p) || ".";
|
|
303
|
+
if (copies.length) {
|
|
304
|
+
log(
|
|
305
|
+
chalk.green(` \u2713 Files: ${counts.installed} installed, ${counts.unchanged} unchanged` + (counts.overwritten ? `, ${counts.overwritten} overwritten` : "") + (counts.skipped ? chalk.yellow(`, ${counts.skipped} skipped (exist and differ \u2014 use --force)`) : ""))
|
|
306
|
+
);
|
|
307
|
+
for (const c of copies.filter((x) => x.status === "skipped")) {
|
|
308
|
+
log(chalk.yellow(` skipped ${rel(c.dest)}`));
|
|
309
|
+
}
|
|
310
|
+
}
|
|
311
|
+
for (const d of createdDirs) log(chalk.green(` \u2713 Created ${rel(d)}/`));
|
|
312
|
+
for (const f of createdFiles) log(chalk.green(` \u2713 Created ${rel(f)}`));
|
|
313
|
+
log(
|
|
314
|
+
gitignoreUpdated ? chalk.green(" \u2713 Updated .gitignore (Qualiow block)") : chalk.cyan(" \u25CB .gitignore already up to date")
|
|
315
|
+
);
|
|
316
|
+
log("");
|
|
317
|
+
log(chalk.cyan.bold(options.dryRun ? "Dry run complete." : "Qualiow initialized."));
|
|
318
|
+
log("");
|
|
319
|
+
log(chalk.white("Next steps:"));
|
|
320
|
+
log(chalk.white(" 1. npx playwright-cli install --skills # official Playwright skill, next to qualiow"));
|
|
321
|
+
log(chalk.white(" 2. cp qa/.env.example qa/.env # credentials by env var name only"));
|
|
322
|
+
log(chalk.white(" 3. /qa-target-setup or /qa-explore https://your-app.com"));
|
|
323
|
+
log(chalk.white(" 4. mobile: qa/bin/doctor-mobile.sh # then /qa-explore-mobile --target <id>"));
|
|
324
|
+
log("");
|
|
325
|
+
return { copies, createdDirs, createdFiles, gitignoreUpdated };
|
|
213
326
|
}
|
|
214
327
|
|
|
215
328
|
// src/cli/commands/validate.ts
|
|
216
329
|
import { Command as Command2 } from "commander";
|
|
217
|
-
import { resolve as
|
|
218
|
-
import { existsSync as
|
|
219
|
-
import { globSync as
|
|
330
|
+
import { resolve as resolve4, relative as relative3, join as join5 } from "path";
|
|
331
|
+
import { existsSync as existsSync5 } from "fs";
|
|
332
|
+
import { globSync as globSync3 } from "glob";
|
|
220
333
|
import chalk2 from "chalk";
|
|
221
334
|
|
|
222
335
|
// src/utils/validate.ts
|
|
223
|
-
import { readFileSync as
|
|
224
|
-
import { resolve as
|
|
225
|
-
import { parse as
|
|
336
|
+
import { readFileSync as readFileSync4, existsSync as existsSync4 } from "fs";
|
|
337
|
+
import { resolve as resolve3, join as join4, basename as basename3 } from "path";
|
|
338
|
+
import { parse as parseYaml2 } from "yaml";
|
|
226
339
|
import { ZodError } from "zod";
|
|
227
340
|
|
|
228
341
|
// src/schemas/target.schema.ts
|
|
@@ -244,42 +357,43 @@ var AuthConfigSchema = z.object({
|
|
|
244
357
|
credentials: z.object({
|
|
245
358
|
username: z.string(),
|
|
246
359
|
password: z.string()
|
|
247
|
-
}).optional(),
|
|
360
|
+
}).strict().optional(),
|
|
248
361
|
token: z.string().optional(),
|
|
249
362
|
identity_provider: z.string().optional(),
|
|
250
363
|
// Staging builds sometimes accept a fixed OTP — recorded so the auth phase can
|
|
251
364
|
// use it instead of waiting for a real code. Never a real credential.
|
|
252
365
|
static_otp: z.string().optional(),
|
|
253
|
-
test_email_pattern: z.string().optional()
|
|
254
|
-
|
|
366
|
+
test_email_pattern: z.string().optional(),
|
|
367
|
+
notes: z.string().optional()
|
|
368
|
+
}).strict();
|
|
255
369
|
var BrowserConfigSchema = z.object({
|
|
256
370
|
headless: z.boolean(),
|
|
257
371
|
viewport: z.object({
|
|
258
372
|
width: z.number().int().positive(),
|
|
259
373
|
height: z.number().int().positive()
|
|
260
|
-
}),
|
|
374
|
+
}).strict(),
|
|
261
375
|
// Optional engine selection + Playwright device descriptor for mobile-web
|
|
262
376
|
// emulation targets (e.g. engine: webkit, device: "iPhone 15").
|
|
263
377
|
engine: z.enum(["chromium", "webkit", "firefox"]).optional(),
|
|
264
378
|
channel: z.string().optional(),
|
|
265
379
|
device: z.string().optional()
|
|
266
|
-
});
|
|
380
|
+
}).strict();
|
|
267
381
|
var ScopeConfigSchema = z.object({
|
|
268
382
|
start_pages: z.array(z.string()).optional(),
|
|
269
383
|
max_depth: z.number().int().min(0),
|
|
270
384
|
include_patterns: z.array(z.string()).optional(),
|
|
271
385
|
exclude_patterns: z.array(z.string()).optional()
|
|
272
|
-
});
|
|
386
|
+
}).strict();
|
|
273
387
|
var SafetyConfigSchema = z.object({
|
|
274
388
|
read_only: z.boolean(),
|
|
275
389
|
no_form_submit: z.boolean(),
|
|
276
390
|
no_file_upload: z.boolean().optional(),
|
|
277
391
|
no_delete_actions: z.boolean().optional()
|
|
278
|
-
});
|
|
392
|
+
}).strict();
|
|
279
393
|
var EnvironmentConfigSchema = z.object({
|
|
280
394
|
kind: z.enum(["dev", "ephemeral", "staging", "production"]),
|
|
281
395
|
destroyed_automatically: z.boolean().optional()
|
|
282
|
-
});
|
|
396
|
+
}).strict();
|
|
283
397
|
var BackendConfigSchema = z.object({
|
|
284
398
|
provider: z.enum(["aws"]).optional(),
|
|
285
399
|
aws_profile_env: z.string().optional(),
|
|
@@ -292,13 +406,17 @@ var BackendConfigSchema = z.object({
|
|
|
292
406
|
// Free-form logical name -> deployed resource name (config_table, dlq, ...).
|
|
293
407
|
resources: z.record(z.string(), z.string()).optional(),
|
|
294
408
|
notes: z.string().optional()
|
|
295
|
-
});
|
|
409
|
+
}).strict();
|
|
296
410
|
var ApiSurfaceConfigSchema = z.object({
|
|
297
411
|
// Defaults to the target's base_url when omitted.
|
|
298
412
|
base_url: z.string().optional(),
|
|
299
|
-
auth: z.enum(["session-cookie", "bearer-env", "none"]).optional(),
|
|
300
|
-
// NAME of the env var holding
|
|
413
|
+
auth: z.enum(["session-cookie", "bearer-env", "api-key-env", "none"]).optional(),
|
|
414
|
+
// NAME of the env var holding the credential, for `auth: bearer-env` (a bearer
|
|
415
|
+
// token) or `auth: api-key-env` (a static API key sent in its own header).
|
|
301
416
|
token_env: z.string().optional(),
|
|
417
|
+
// Header carrying the credential for `auth: api-key-env`. Defaults to
|
|
418
|
+
// `X-Api-Key`. The VALUE always comes from `token_env`, never from here.
|
|
419
|
+
header_name: z.string().optional(),
|
|
302
420
|
// Persistent browser profile directory holding the authenticated session,
|
|
303
421
|
// e.g. `.auth/my-service-dev-profile`. Gitignored.
|
|
304
422
|
browser_profile: z.string().optional(),
|
|
@@ -308,19 +426,23 @@ var ApiSurfaceConfigSchema = z.object({
|
|
|
308
426
|
endpoints: z.record(z.string(), z.string()).optional(),
|
|
309
427
|
// The ONLY endpoints the read-only API lane may call without asking.
|
|
310
428
|
probe_allowlist: z.array(z.string()).optional(),
|
|
429
|
+
// The ONLY endpoints phase 4 may call through the real write path, and only in
|
|
430
|
+
// a dev or ephemeral environment. Empty or absent means the API lane is
|
|
431
|
+
// read-only here and every state-changing AC needs a different channel.
|
|
432
|
+
write_allowlist: z.array(z.string()).optional(),
|
|
311
433
|
// Other target ids to run the same matrix against, for parity comparison.
|
|
312
434
|
parity_targets: z.array(z.string()).optional(),
|
|
313
435
|
// Flag name -> where its deployed value is declared for this environment.
|
|
314
436
|
// A flag can select between two implementations inside one identical build.
|
|
315
437
|
feature_flags: z.record(z.string(), z.string()).optional(),
|
|
316
438
|
notes: z.string().optional()
|
|
317
|
-
});
|
|
439
|
+
}).strict();
|
|
318
440
|
var SourceBranchConfigSchema = z.object({
|
|
319
441
|
repo_path: z.string(),
|
|
320
442
|
branch: z.string(),
|
|
321
443
|
base_branch: z.string().optional(),
|
|
322
444
|
components: z.record(z.string(), z.string()).optional()
|
|
323
|
-
});
|
|
445
|
+
}).strict();
|
|
324
446
|
var WebTargetConfigSchema = z.object({
|
|
325
447
|
id: z.string().min(1),
|
|
326
448
|
name: z.string().min(1),
|
|
@@ -339,7 +461,7 @@ var WebTargetConfigSchema = z.object({
|
|
|
339
461
|
api: ApiSurfaceConfigSchema.optional(),
|
|
340
462
|
source: SourceBranchConfigSchema.optional(),
|
|
341
463
|
notes: z.string().optional()
|
|
342
|
-
});
|
|
464
|
+
}).strict();
|
|
343
465
|
var MobileDeviceConfigSchema = z.object({
|
|
344
466
|
name: z.string().optional(),
|
|
345
467
|
// iOS simulator name (portable across machines)
|
|
@@ -349,7 +471,7 @@ var MobileDeviceConfigSchema = z.object({
|
|
|
349
471
|
// Android AVD name
|
|
350
472
|
serial: z.string().optional()
|
|
351
473
|
// Android serial once booted (e.g. emulator-5554)
|
|
352
|
-
});
|
|
474
|
+
}).strict();
|
|
353
475
|
var MobileAppConfigSchema = z.object({
|
|
354
476
|
bundle_id: z.string().optional(),
|
|
355
477
|
// iOS bundle id (or browser bundle in web mode)
|
|
@@ -359,21 +481,21 @@ var MobileAppConfigSchema = z.object({
|
|
|
359
481
|
// iOS .app artifact(s) — native mode
|
|
360
482
|
apk_paths: z.array(z.string()).optional()
|
|
361
483
|
// Android APK(s) — native mode
|
|
362
|
-
});
|
|
484
|
+
}).strict();
|
|
363
485
|
var MobileWebConfigSchema = z.object({
|
|
364
486
|
base_url: z.string().url(),
|
|
365
487
|
start_url: z.string().url().optional()
|
|
366
|
-
});
|
|
488
|
+
}).strict();
|
|
367
489
|
var SourceRepoConfigSchema = z.object({
|
|
368
490
|
path: z.string(),
|
|
369
491
|
build_commands: z.record(z.string(), z.string()).optional()
|
|
370
|
-
});
|
|
492
|
+
}).strict();
|
|
371
493
|
var MobileScopeConfigSchema = z.object({
|
|
372
494
|
start_screen: z.string().optional(),
|
|
373
495
|
start_url: z.string().optional(),
|
|
374
496
|
include_patterns: z.array(z.string()).optional(),
|
|
375
497
|
exclude_patterns: z.array(z.string()).optional()
|
|
376
|
-
});
|
|
498
|
+
}).strict();
|
|
377
499
|
var MobileTargetConfigSchema = z.object({
|
|
378
500
|
id: z.string().min(1),
|
|
379
501
|
name: z.string().min(1),
|
|
@@ -389,15 +511,22 @@ var MobileTargetConfigSchema = z.object({
|
|
|
389
511
|
safety: SafetyConfigSchema.optional(),
|
|
390
512
|
source_repo: SourceRepoConfigSchema.optional(),
|
|
391
513
|
notes: z.string().optional()
|
|
392
|
-
});
|
|
393
|
-
var TargetConfigSchema = z.
|
|
394
|
-
|
|
514
|
+
}).strict();
|
|
515
|
+
var TargetConfigSchema = z.unknown().transform((data, ctx) => {
|
|
516
|
+
if (typeof data !== "object" || data === null || Array.isArray(data)) {
|
|
517
|
+
ctx.addIssue({ code: "custom", message: "Expected a target config object" });
|
|
518
|
+
return z.NEVER;
|
|
519
|
+
}
|
|
520
|
+
const isMobile = "platform" in data;
|
|
395
521
|
const branch = isMobile ? MobileTargetConfigSchema : WebTargetConfigSchema;
|
|
396
522
|
const result = branch.safeParse(data);
|
|
397
523
|
if (!result.success) {
|
|
398
|
-
for (const issue of result.error.issues)
|
|
524
|
+
for (const issue of result.error.issues) {
|
|
399
525
|
ctx.addIssue(issue);
|
|
526
|
+
}
|
|
527
|
+
return z.NEVER;
|
|
400
528
|
}
|
|
529
|
+
return result.data;
|
|
401
530
|
});
|
|
402
531
|
|
|
403
532
|
// src/schemas/knowledge-entry.schema.ts
|
|
@@ -422,30 +551,193 @@ var KnowledgeEntrySchema = z2.object({
|
|
|
422
551
|
|
|
423
552
|
// src/schemas/domain-config.schema.ts
|
|
424
553
|
import { z as z3 } from "zod";
|
|
554
|
+
var RiskRankingSchema = z3.object({
|
|
555
|
+
p0: z3.array(z3.string()).min(1),
|
|
556
|
+
p1: z3.array(z3.string()).min(1),
|
|
557
|
+
p2: z3.array(z3.string()).min(1),
|
|
558
|
+
p3: z3.array(z3.string()).min(1)
|
|
559
|
+
}).strict();
|
|
425
560
|
var JourneySchema = z3.object({
|
|
426
|
-
id: z3.string().min(1),
|
|
427
561
|
name: z3.string().min(1),
|
|
428
|
-
|
|
429
|
-
|
|
430
|
-
risk: z3.enum(["high", "medium", "low"])
|
|
431
|
-
});
|
|
562
|
+
steps: z3.array(z3.string()).min(1)
|
|
563
|
+
}).strict();
|
|
432
564
|
var DomainConfigSchema = z3.object({
|
|
433
565
|
id: z3.string().min(1),
|
|
434
566
|
name: z3.string().min(1),
|
|
435
|
-
risk_ranking:
|
|
567
|
+
risk_ranking: RiskRankingSchema,
|
|
436
568
|
completeness_checklist: z3.array(z3.string()).min(1),
|
|
437
569
|
data_integrity_checks: z3.array(z3.string()).min(1),
|
|
438
570
|
journeys: z3.array(JourneySchema).min(1),
|
|
439
|
-
|
|
571
|
+
must_test_patterns: z3.record(z3.string(), z3.array(z3.string())),
|
|
572
|
+
common_bugs: z3.array(z3.string()).min(1),
|
|
573
|
+
compliance: z3.array(z3.string()).min(1),
|
|
574
|
+
guidance: z3.string().min(1)
|
|
575
|
+
}).strict();
|
|
576
|
+
|
|
577
|
+
// src/schemas/knowledge-manifest.schema.ts
|
|
578
|
+
import { z as z4 } from "zod";
|
|
579
|
+
var KnowledgeManifestStatsSchema = z4.object({
|
|
580
|
+
total_entries: z4.number().int().min(0),
|
|
581
|
+
heuristics: z4.number().int().min(0),
|
|
582
|
+
techniques: z4.number().int().min(0),
|
|
583
|
+
checklists: z4.number().int().min(0),
|
|
584
|
+
references: z4.number().int().min(0),
|
|
585
|
+
domain_profiles: z4.number().int().min(0),
|
|
586
|
+
custom_entries: z4.number().int().min(0)
|
|
587
|
+
});
|
|
588
|
+
var KnowledgeManifestEntrySchema = z4.object({
|
|
589
|
+
id: z4.string().min(1),
|
|
590
|
+
file: z4.string().min(1),
|
|
591
|
+
type: z4.string().min(1),
|
|
592
|
+
priority: z4.enum(["high", "medium", "low"]),
|
|
593
|
+
tags: z4.array(z4.string()),
|
|
594
|
+
domains: z4.array(z4.string())
|
|
595
|
+
});
|
|
596
|
+
var LoadingStrategySchema = z4.object({
|
|
597
|
+
always: z4.array(z4.string()),
|
|
598
|
+
by_domain: z4.record(z4.string(), z4.array(z4.string())),
|
|
599
|
+
by_tag: z4.record(z4.string(), z4.array(z4.string()))
|
|
600
|
+
});
|
|
601
|
+
var KnowledgeManifestSchema = z4.object({
|
|
602
|
+
version: z4.string().min(1),
|
|
603
|
+
last_updated: z4.string().min(1),
|
|
604
|
+
active_releases: z4.array(z4.string()).min(1),
|
|
605
|
+
stats: KnowledgeManifestStatsSchema,
|
|
606
|
+
loading_strategy: LoadingStrategySchema,
|
|
607
|
+
entries: z4.array(KnowledgeManifestEntrySchema).min(1)
|
|
440
608
|
});
|
|
441
609
|
|
|
442
|
-
// src/
|
|
610
|
+
// src/schemas/knowledge-release.schema.ts
|
|
611
|
+
import { z as z5 } from "zod";
|
|
612
|
+
var KnowledgeReleaseSchema = z5.object({
|
|
613
|
+
version: z5.string().min(1),
|
|
614
|
+
date: z5.string().min(1),
|
|
615
|
+
author: z5.string().min(1),
|
|
616
|
+
status: z5.enum(["active", "deprecated"]),
|
|
617
|
+
notes: z5.string().min(1),
|
|
618
|
+
entry_count: z5.number().int().min(0),
|
|
619
|
+
entries: z5.array(z5.string().min(1)).min(1)
|
|
620
|
+
}).strict().refine((r) => r.entry_count === r.entries.length, {
|
|
621
|
+
message: "entry_count must equal the number of listed entries",
|
|
622
|
+
path: ["entry_count"]
|
|
623
|
+
});
|
|
624
|
+
|
|
625
|
+
// src/schemas/knowledge-changelog.schema.ts
|
|
626
|
+
import { z as z6 } from "zod";
|
|
627
|
+
var ChangelogEntrySchema = z6.object({
|
|
628
|
+
id: z6.string().min(1),
|
|
629
|
+
type: z6.enum(["heuristic", "technique", "checklist", "reference"]),
|
|
630
|
+
name: z6.string().min(1),
|
|
631
|
+
description: z6.string().min(1)
|
|
632
|
+
}).strict();
|
|
633
|
+
var ChangelogReleaseSchema = z6.object({
|
|
634
|
+
version: z6.string().min(1),
|
|
635
|
+
date: z6.string().min(1),
|
|
636
|
+
summary: z6.string().min(1),
|
|
637
|
+
entries_added: z6.array(ChangelogEntrySchema),
|
|
638
|
+
entries_modified: z6.array(z6.string()).default([]),
|
|
639
|
+
entries_removed: z6.array(z6.string()).default([]),
|
|
640
|
+
origin: z6.string().optional()
|
|
641
|
+
}).strict();
|
|
642
|
+
var KnowledgeChangelogSchema = z6.object({
|
|
643
|
+
releases: z6.array(ChangelogReleaseSchema).min(1)
|
|
644
|
+
}).strict();
|
|
645
|
+
|
|
646
|
+
// src/utils/kb-sync.ts
|
|
647
|
+
import { readFileSync as readFileSync3, writeFileSync as writeFileSync2, existsSync as existsSync3, readdirSync as readdirSync2 } from "fs";
|
|
648
|
+
import { join as join3, relative as relative2, basename as basename2 } from "path";
|
|
649
|
+
import { parse as parseYaml, parseDocument } from "yaml";
|
|
443
650
|
import { globSync } from "glob";
|
|
651
|
+
var TYPE_TO_STAT = {
|
|
652
|
+
heuristic: "heuristics",
|
|
653
|
+
technique: "techniques",
|
|
654
|
+
checklist: "checklists",
|
|
655
|
+
reference: "references"
|
|
656
|
+
};
|
|
657
|
+
function listReleaseDirs(knowledgeDir) {
|
|
658
|
+
const releasesDir = join3(knowledgeDir, "releases");
|
|
659
|
+
if (!existsSync3(releasesDir)) return [];
|
|
660
|
+
return readdirSync2(releasesDir, { withFileTypes: true }).filter((d) => d.isDirectory() && /^v\d+\.\d+\.\d+$/.test(d.name)).map((d) => d.name).sort(compareVersions);
|
|
661
|
+
}
|
|
662
|
+
function compareVersions(a, b) {
|
|
663
|
+
const pa = a.replace(/^v/, "").split(".").map(Number);
|
|
664
|
+
const pb = b.replace(/^v/, "").split(".").map(Number);
|
|
665
|
+
for (let i = 0; i < 3; i++) {
|
|
666
|
+
if (pa[i] !== pb[i]) return pa[i] - pb[i];
|
|
667
|
+
}
|
|
668
|
+
return 0;
|
|
669
|
+
}
|
|
670
|
+
function buildManifestRegistry(dataDir) {
|
|
671
|
+
const knowledgeDir = join3(dataDir, "knowledge");
|
|
672
|
+
const registry = [];
|
|
673
|
+
for (const rel of listReleaseDirs(knowledgeDir)) {
|
|
674
|
+
const files = globSync(join3(knowledgeDir, "releases", rel, "entries", "*.yml")).sort();
|
|
675
|
+
for (const file of files) {
|
|
676
|
+
const entry = parseYaml(readFileSync3(file, "utf-8"));
|
|
677
|
+
registry.push({
|
|
678
|
+
id: entry.id,
|
|
679
|
+
file: relative2(knowledgeDir, file).split("\\").join("/"),
|
|
680
|
+
type: entry.type,
|
|
681
|
+
priority: entry.priority,
|
|
682
|
+
tags: entry.tags,
|
|
683
|
+
domains: entry.domains
|
|
684
|
+
});
|
|
685
|
+
}
|
|
686
|
+
}
|
|
687
|
+
return registry;
|
|
688
|
+
}
|
|
689
|
+
function computeStats(dataDir, registry) {
|
|
690
|
+
const stats = {
|
|
691
|
+
total_entries: registry.length,
|
|
692
|
+
heuristics: 0,
|
|
693
|
+
techniques: 0,
|
|
694
|
+
checklists: 0,
|
|
695
|
+
references: 0,
|
|
696
|
+
domain_profiles: 0,
|
|
697
|
+
custom_entries: 0
|
|
698
|
+
};
|
|
699
|
+
for (const e of registry) {
|
|
700
|
+
const key = TYPE_TO_STAT[e.type];
|
|
701
|
+
if (key) stats[key]++;
|
|
702
|
+
}
|
|
703
|
+
const domainsDir = join3(dataDir, "domains");
|
|
704
|
+
if (existsSync3(domainsDir)) {
|
|
705
|
+
stats.domain_profiles = readdirSync2(domainsDir).filter(
|
|
706
|
+
(f) => f.endsWith(".yml")
|
|
707
|
+
).length;
|
|
708
|
+
}
|
|
709
|
+
const customDir = join3(dataDir, "knowledge", "custom");
|
|
710
|
+
if (existsSync3(customDir)) {
|
|
711
|
+
stats.custom_entries = readdirSync2(customDir).filter(
|
|
712
|
+
(f) => f.endsWith(".yml")
|
|
713
|
+
).length;
|
|
714
|
+
}
|
|
715
|
+
return stats;
|
|
716
|
+
}
|
|
717
|
+
function syncKnowledgeManifest(dataDir, opts = {}) {
|
|
718
|
+
const manifestPath = join3(dataDir, "knowledge", "manifest.yml");
|
|
719
|
+
const raw = readFileSync3(manifestPath, "utf-8");
|
|
720
|
+
const doc = parseDocument(raw);
|
|
721
|
+
const registry = buildManifestRegistry(dataDir);
|
|
722
|
+
const stats = computeStats(dataDir, registry);
|
|
723
|
+
const current = parseYaml(raw);
|
|
724
|
+
const inSync = JSON.stringify(current.entries) === JSON.stringify(registry) && JSON.stringify(current.stats) === JSON.stringify(stats);
|
|
725
|
+
if (!opts.check && !inSync) {
|
|
726
|
+
doc.set("stats", stats);
|
|
727
|
+
doc.set("entries", registry);
|
|
728
|
+
doc.set("last_updated", (/* @__PURE__ */ new Date()).toISOString().slice(0, 10));
|
|
729
|
+
writeFileSync2(manifestPath, doc.toString(), "utf-8");
|
|
730
|
+
}
|
|
731
|
+
return { changed: !inSync, stats, entryCount: registry.length };
|
|
732
|
+
}
|
|
733
|
+
|
|
734
|
+
// src/utils/validate.ts
|
|
735
|
+
import { globSync as globSync2 } from "glob";
|
|
444
736
|
function validateYamlFile(filePath, schema) {
|
|
445
|
-
const absPath =
|
|
737
|
+
const absPath = resolve3(filePath);
|
|
446
738
|
try {
|
|
447
|
-
const raw =
|
|
448
|
-
const data =
|
|
739
|
+
const raw = readFileSync4(absPath, "utf-8");
|
|
740
|
+
const data = parseYaml2(raw);
|
|
449
741
|
schema.parse(data);
|
|
450
742
|
return { file: absPath, valid: true };
|
|
451
743
|
} catch (err) {
|
|
@@ -471,21 +763,136 @@ function validateYamlFile(filePath, schema) {
|
|
|
471
763
|
};
|
|
472
764
|
}
|
|
473
765
|
}
|
|
766
|
+
function validateWithId(filePath, schema) {
|
|
767
|
+
const result = validateYamlFile(filePath, schema);
|
|
768
|
+
if (!result.valid) return result;
|
|
769
|
+
try {
|
|
770
|
+
const data = parseYaml2(readFileSync4(filePath, "utf-8"));
|
|
771
|
+
const stem = basename3(filePath, ".yml");
|
|
772
|
+
if (data.id !== stem) {
|
|
773
|
+
return {
|
|
774
|
+
file: resolve3(filePath),
|
|
775
|
+
valid: false,
|
|
776
|
+
errors: [
|
|
777
|
+
{
|
|
778
|
+
path: "id",
|
|
779
|
+
message: `id "${data.id}" must equal the file name "${stem}"`
|
|
780
|
+
}
|
|
781
|
+
]
|
|
782
|
+
};
|
|
783
|
+
}
|
|
784
|
+
} catch {
|
|
785
|
+
}
|
|
786
|
+
return result;
|
|
787
|
+
}
|
|
474
788
|
function validateTargetConfig(filePath) {
|
|
475
|
-
return
|
|
789
|
+
return validateWithId(filePath, TargetConfigSchema);
|
|
476
790
|
}
|
|
477
791
|
function validateKnowledgeEntry(filePath) {
|
|
478
792
|
return validateYamlFile(filePath, KnowledgeEntrySchema);
|
|
479
793
|
}
|
|
480
794
|
function validateDomainConfig(filePath) {
|
|
481
|
-
return
|
|
795
|
+
return validateWithId(filePath, DomainConfigSchema);
|
|
796
|
+
}
|
|
797
|
+
function validateKnowledgeBase(dataDir) {
|
|
798
|
+
const results = [];
|
|
799
|
+
const knowledgeDir = resolve3(dataDir, "knowledge");
|
|
800
|
+
const manifestPath = join4(knowledgeDir, "manifest.yml");
|
|
801
|
+
const changelogPath = join4(knowledgeDir, "changelog.yml");
|
|
802
|
+
results.push(validateYamlFile(manifestPath, KnowledgeManifestSchema));
|
|
803
|
+
results.push(validateYamlFile(changelogPath, KnowledgeChangelogSchema));
|
|
804
|
+
const releaseDirs = listReleaseDirs(knowledgeDir);
|
|
805
|
+
for (const rel of releaseDirs) {
|
|
806
|
+
const releasePath = join4(knowledgeDir, "releases", rel, "release.yml");
|
|
807
|
+
const schemaResult = validateYamlFile(releasePath, KnowledgeReleaseSchema);
|
|
808
|
+
const errors = schemaResult.errors ?? [];
|
|
809
|
+
if (schemaResult.valid || errors.length === 0) {
|
|
810
|
+
try {
|
|
811
|
+
const release = parseYaml2(readFileSync4(releasePath, "utf-8"));
|
|
812
|
+
if (`v${release.version}` !== rel) {
|
|
813
|
+
errors.push({
|
|
814
|
+
path: "version",
|
|
815
|
+
message: `version "${release.version}" does not match directory "${rel}"`
|
|
816
|
+
});
|
|
817
|
+
}
|
|
818
|
+
const entryDir = join4(knowledgeDir, "releases", rel, "entries");
|
|
819
|
+
const filesOnDisk = existsSync4(entryDir) ? globSync2(join4(entryDir, "*.yml")).map((f) => basename3(f, ".yml")) : [];
|
|
820
|
+
for (const id of release.entries) {
|
|
821
|
+
if (!filesOnDisk.includes(id)) {
|
|
822
|
+
errors.push({ path: "entries", message: `declared entry "${id}" has no file` });
|
|
823
|
+
}
|
|
824
|
+
}
|
|
825
|
+
for (const id of filesOnDisk) {
|
|
826
|
+
if (!release.entries.includes(id)) {
|
|
827
|
+
errors.push({ path: "entries", message: `entry file "${id}" is not declared` });
|
|
828
|
+
}
|
|
829
|
+
}
|
|
830
|
+
} catch {
|
|
831
|
+
}
|
|
832
|
+
}
|
|
833
|
+
results.push(
|
|
834
|
+
errors.length ? { file: resolve3(releasePath), valid: false, errors } : { file: resolve3(releasePath), valid: true }
|
|
835
|
+
);
|
|
836
|
+
}
|
|
837
|
+
const crossErrors = [];
|
|
838
|
+
try {
|
|
839
|
+
const manifest = parseYaml2(readFileSync4(manifestPath, "utf-8"));
|
|
840
|
+
const registry = buildManifestRegistry(dataDir);
|
|
841
|
+
const stats = computeStats(dataDir, registry);
|
|
842
|
+
const registryIds = new Set(registry.map((e) => e.id));
|
|
843
|
+
if (JSON.stringify(manifest.entries) !== JSON.stringify(registry)) {
|
|
844
|
+
crossErrors.push({
|
|
845
|
+
path: "entries",
|
|
846
|
+
message: "registry is out of sync with the entry files (run `qualiow kb sync`)"
|
|
847
|
+
});
|
|
848
|
+
}
|
|
849
|
+
if (JSON.stringify(manifest.stats) !== JSON.stringify(stats)) {
|
|
850
|
+
crossErrors.push({
|
|
851
|
+
path: "stats",
|
|
852
|
+
message: `stats out of sync (expected total_entries ${stats.total_entries})`
|
|
853
|
+
});
|
|
854
|
+
}
|
|
855
|
+
const activeExpected = [...listReleaseDirs(knowledgeDir)].sort();
|
|
856
|
+
if (JSON.stringify([...manifest.active_releases].sort()) !== JSON.stringify(activeExpected)) {
|
|
857
|
+
crossErrors.push({ path: "active_releases", message: "does not match the release directories" });
|
|
858
|
+
}
|
|
859
|
+
const ls = manifest.loading_strategy;
|
|
860
|
+
const allRefs = [
|
|
861
|
+
...ls.always,
|
|
862
|
+
...Object.values(ls.by_domain).flat(),
|
|
863
|
+
...Object.values(ls.by_tag).flat()
|
|
864
|
+
];
|
|
865
|
+
for (const id of allRefs) {
|
|
866
|
+
if (!registryIds.has(id)) {
|
|
867
|
+
crossErrors.push({ path: "loading_strategy", message: `references unknown entry "${id}"` });
|
|
868
|
+
}
|
|
869
|
+
}
|
|
870
|
+
const changelog = parseYaml2(readFileSync4(changelogPath, "utf-8"));
|
|
871
|
+
for (const r of changelog.releases) {
|
|
872
|
+
for (const e of r.entries_added) {
|
|
873
|
+
if (!registryIds.has(e.id)) {
|
|
874
|
+
crossErrors.push({ path: "changelog", message: `entry "${e.id}" is not in the registry` });
|
|
875
|
+
}
|
|
876
|
+
}
|
|
877
|
+
}
|
|
878
|
+
} catch (err) {
|
|
879
|
+
crossErrors.push({
|
|
880
|
+
path: "",
|
|
881
|
+
message: err instanceof Error ? err.message : "cross-check failed"
|
|
882
|
+
});
|
|
883
|
+
}
|
|
884
|
+
results.push(
|
|
885
|
+
crossErrors.length ? { file: join4(knowledgeDir, "(cross-check)"), valid: false, errors: crossErrors } : { file: join4(knowledgeDir, "(cross-check)"), valid: true }
|
|
886
|
+
);
|
|
887
|
+
return results;
|
|
482
888
|
}
|
|
483
889
|
|
|
484
890
|
// src/cli/commands/validate.ts
|
|
485
891
|
function validateCommand() {
|
|
486
|
-
const cmd = new Command2("validate").description("Validate
|
|
892
|
+
const cmd = new Command2("validate").description("Validate configuration files (targets, domains, knowledge entries, knowledge base)").option("--targets", "Validate target configurations (data/targets/*.yml and qa/target.yml)").option("--knowledge", "Validate knowledge entries").option("--domains", "Validate domain configurations").option("--kb", "Cross-check the knowledge base (manifest, releases, changelog)").option("--all", "Validate everything (default)").action(async (options) => {
|
|
487
893
|
try {
|
|
488
|
-
runValidate(options);
|
|
894
|
+
const failed = runValidate(options, process.cwd());
|
|
895
|
+
if (failed > 0) process.exit(1);
|
|
489
896
|
} catch (err) {
|
|
490
897
|
console.error(chalk2.red("Error during validation:"), err instanceof Error ? err.message : err);
|
|
491
898
|
process.exit(1);
|
|
@@ -493,58 +900,47 @@ function validateCommand() {
|
|
|
493
900
|
});
|
|
494
901
|
return cmd;
|
|
495
902
|
}
|
|
496
|
-
function runValidate(options) {
|
|
497
|
-
const
|
|
498
|
-
const
|
|
499
|
-
|
|
500
|
-
|
|
501
|
-
console.error(chalk2.red("Error: data/ directory not found. Run `npx qualiow init` first."));
|
|
502
|
-
process.exit(1);
|
|
903
|
+
function runValidate(options, cwd) {
|
|
904
|
+
const dataDir = resolve4(cwd, "data");
|
|
905
|
+
const runAll = options.all || !options.targets && !options.knowledge && !options.domains && !options.kb;
|
|
906
|
+
if (!existsSync5(dataDir)) {
|
|
907
|
+
throw new Error("data/ directory not found. Run `npx qualiow init` first.");
|
|
503
908
|
}
|
|
504
909
|
const results = [];
|
|
505
|
-
|
|
506
|
-
|
|
507
|
-
|
|
508
|
-
|
|
509
|
-
|
|
510
|
-
|
|
511
|
-
|
|
512
|
-
const result = validateTargetConfig(file);
|
|
513
|
-
results.push(result);
|
|
514
|
-
printResult(result, cwd);
|
|
515
|
-
}
|
|
516
|
-
} else {
|
|
517
|
-
console.log(chalk2.yellow("\n No targets/ directory found"));
|
|
910
|
+
const section = (title, files, fn) => {
|
|
911
|
+
console.log(chalk2.cyan.bold(`
|
|
912
|
+
${title} (${files.length} files):`));
|
|
913
|
+
for (const file of files) {
|
|
914
|
+
const result = fn(file);
|
|
915
|
+
results.push(result);
|
|
916
|
+
printResult(result, cwd);
|
|
518
917
|
}
|
|
918
|
+
};
|
|
919
|
+
if (runAll || options.targets) {
|
|
920
|
+
const files = globSync3(resolve4(dataDir, "targets", "*.yml")).sort();
|
|
921
|
+
const projectLocal = join5(cwd, "qa", "target.yml");
|
|
922
|
+
if (existsSync5(projectLocal)) files.unshift(projectLocal);
|
|
923
|
+
section("Targets", files, validateTargetConfig);
|
|
924
|
+
}
|
|
925
|
+
if (runAll || options.domains) {
|
|
926
|
+
section("Domains", globSync3(resolve4(dataDir, "domains", "*.yml")).sort(), validateDomainConfig);
|
|
519
927
|
}
|
|
520
928
|
if (runAll || options.knowledge) {
|
|
521
|
-
|
|
522
|
-
|
|
523
|
-
|
|
524
|
-
|
|
525
|
-
|
|
526
|
-
for (const file of files) {
|
|
527
|
-
const result = validateKnowledgeEntry(file);
|
|
528
|
-
results.push(result);
|
|
529
|
-
printResult(result, cwd);
|
|
530
|
-
}
|
|
531
|
-
} else {
|
|
532
|
-
console.log(chalk2.yellow("\n No knowledge/ directory found"));
|
|
533
|
-
}
|
|
929
|
+
section(
|
|
930
|
+
"Knowledge entries",
|
|
931
|
+
globSync3(resolve4(dataDir, "knowledge", "releases", "**", "entries", "*.yml")).sort(),
|
|
932
|
+
validateKnowledgeEntry
|
|
933
|
+
);
|
|
534
934
|
}
|
|
535
|
-
if (runAll || options.
|
|
536
|
-
|
|
537
|
-
|
|
538
|
-
const
|
|
539
|
-
console.log(chalk2.cyan.bold(`
|
|
540
|
-
Domains (${files.length} files):`));
|
|
541
|
-
for (const file of files) {
|
|
542
|
-
const result = validateDomainConfig(file);
|
|
935
|
+
if (runAll || options.kb) {
|
|
936
|
+
if (existsSync5(join5(dataDir, "knowledge", "manifest.yml"))) {
|
|
937
|
+
console.log(chalk2.cyan.bold("\nKnowledge base:"));
|
|
938
|
+
for (const result of validateKnowledgeBase(dataDir)) {
|
|
543
939
|
results.push(result);
|
|
544
940
|
printResult(result, cwd);
|
|
545
941
|
}
|
|
546
942
|
} else {
|
|
547
|
-
console.log(chalk2.yellow("\n No
|
|
943
|
+
console.log(chalk2.yellow("\n No knowledge/manifest.yml found"));
|
|
548
944
|
}
|
|
549
945
|
}
|
|
550
946
|
const total = results.length;
|
|
@@ -553,38 +949,121 @@ Domains (${files.length} files):`));
|
|
|
553
949
|
console.log("");
|
|
554
950
|
console.log(chalk2.bold("Summary:"));
|
|
555
951
|
console.log(
|
|
556
|
-
` ${total}
|
|
952
|
+
` ${total} checks, ${chalk2.green(`${passed} passed`)}, ${failed > 0 ? chalk2.red(`${failed} failed`) : chalk2.green("0 failed")}`
|
|
557
953
|
);
|
|
558
954
|
console.log("");
|
|
559
|
-
|
|
560
|
-
process.exit(1);
|
|
561
|
-
}
|
|
955
|
+
return failed;
|
|
562
956
|
}
|
|
563
957
|
function printResult(result, cwd) {
|
|
564
|
-
const relPath =
|
|
958
|
+
const relPath = relative3(cwd, result.file);
|
|
565
959
|
if (result.valid) {
|
|
566
960
|
console.log(` ${chalk2.green("PASS")} ${relPath}`);
|
|
567
961
|
} else {
|
|
568
962
|
console.log(` ${chalk2.red("FAIL")} ${relPath}`);
|
|
569
|
-
|
|
570
|
-
|
|
571
|
-
|
|
572
|
-
console.log(` ${chalk2.red("\u2192")} ${pathStr}${err.message}`);
|
|
573
|
-
}
|
|
963
|
+
for (const err of result.errors ?? []) {
|
|
964
|
+
const pathStr = err.path ? `[${err.path}] ` : "";
|
|
965
|
+
console.log(` ${chalk2.red("\u2192")} ${pathStr}${err.message}`);
|
|
574
966
|
}
|
|
575
967
|
}
|
|
576
968
|
}
|
|
577
969
|
|
|
578
970
|
// src/cli/commands/list.ts
|
|
579
971
|
import { Command as Command3 } from "commander";
|
|
580
|
-
import { resolve as
|
|
581
|
-
import { existsSync as
|
|
582
|
-
import { parse as
|
|
972
|
+
import { resolve as resolve5, join as join6, basename as basename4 } from "path";
|
|
973
|
+
import { existsSync as existsSync6, readFileSync as readFileSync5, readdirSync as readdirSync3 } from "fs";
|
|
974
|
+
import { parse as parseYaml3 } from "yaml";
|
|
975
|
+
import { globSync as globSync4 } from "glob";
|
|
583
976
|
import chalk3 from "chalk";
|
|
977
|
+
|
|
978
|
+
// src/utils/markdown-table.ts
|
|
979
|
+
function splitRow(line) {
|
|
980
|
+
const cells = line.split("|").map((c) => c.trim());
|
|
981
|
+
if (cells.length && cells[0] === "") cells.shift();
|
|
982
|
+
if (cells.length && cells[cells.length - 1] === "") cells.pop();
|
|
983
|
+
return cells;
|
|
984
|
+
}
|
|
985
|
+
function isSeparator(line) {
|
|
986
|
+
return /^\s*\|?\s*:?-{2,}/.test(line) && /-\s*\|/.test(line + "|");
|
|
987
|
+
}
|
|
988
|
+
function parseMarkdownTable(md, opts = {}) {
|
|
989
|
+
const lines = md.split("\n");
|
|
990
|
+
let start = 0;
|
|
991
|
+
if (opts.headingPrefix) {
|
|
992
|
+
const prefix = opts.headingPrefix.toLowerCase();
|
|
993
|
+
let found = -1;
|
|
994
|
+
for (let i = 0; i < lines.length; i++) {
|
|
995
|
+
const h = lines[i].match(/^#{1,6}\s+(.*)$/);
|
|
996
|
+
if (h && h[1].trim().toLowerCase().startsWith(prefix)) {
|
|
997
|
+
found = i + 1;
|
|
998
|
+
break;
|
|
999
|
+
}
|
|
1000
|
+
}
|
|
1001
|
+
if (found === -1) return null;
|
|
1002
|
+
start = found;
|
|
1003
|
+
}
|
|
1004
|
+
let headerIdx = -1;
|
|
1005
|
+
for (let i = start; i < lines.length - 1; i++) {
|
|
1006
|
+
const line = lines[i];
|
|
1007
|
+
if (line.includes("|") && isSeparator(lines[i + 1])) {
|
|
1008
|
+
headerIdx = i;
|
|
1009
|
+
break;
|
|
1010
|
+
}
|
|
1011
|
+
if (opts.headingPrefix && /^#{1,6}\s/.test(line) && i > start) {
|
|
1012
|
+
return null;
|
|
1013
|
+
}
|
|
1014
|
+
}
|
|
1015
|
+
if (headerIdx === -1) return null;
|
|
1016
|
+
const headers = splitRow(lines[headerIdx]);
|
|
1017
|
+
const keys = headers.map((h) => h.toLowerCase());
|
|
1018
|
+
const rows = [];
|
|
1019
|
+
for (let i = headerIdx + 2; i < lines.length; i++) {
|
|
1020
|
+
const line = lines[i];
|
|
1021
|
+
if (!line.includes("|")) break;
|
|
1022
|
+
if (isSeparator(line)) continue;
|
|
1023
|
+
const cells = splitRow(line);
|
|
1024
|
+
if (cells.every((c) => c === "")) continue;
|
|
1025
|
+
const row = {};
|
|
1026
|
+
keys.forEach((k, idx) => {
|
|
1027
|
+
row[k] = cells[idx] ?? "";
|
|
1028
|
+
});
|
|
1029
|
+
rows.push(row);
|
|
1030
|
+
}
|
|
1031
|
+
return { headers, rows };
|
|
1032
|
+
}
|
|
1033
|
+
|
|
1034
|
+
// src/utils/session-dir.ts
|
|
1035
|
+
var SESSION_DIR_RE = /^(\d{4}-\d{2}-\d{2}-\d{4})-(explore|quick|mobile|backend)-([a-z0-9][a-z0-9-]*)$/;
|
|
1036
|
+
function slugify(input) {
|
|
1037
|
+
let s = (input ?? "").trim();
|
|
1038
|
+
try {
|
|
1039
|
+
if (/^[a-z][a-z0-9+.-]*:\/\//i.test(s)) {
|
|
1040
|
+
s = new URL(s).hostname;
|
|
1041
|
+
}
|
|
1042
|
+
} catch {
|
|
1043
|
+
}
|
|
1044
|
+
s = s.toLowerCase().replace(/^_+/, "").replace(/[^a-z0-9]+/g, "-").replace(/^-+|-+$/g, "").slice(0, 40).replace(/-+$/g, "");
|
|
1045
|
+
return s || "session";
|
|
1046
|
+
}
|
|
1047
|
+
function pad(n) {
|
|
1048
|
+
return String(n).padStart(2, "0");
|
|
1049
|
+
}
|
|
1050
|
+
function sessionTimestamp(date = /* @__PURE__ */ new Date()) {
|
|
1051
|
+
return `${date.getFullYear()}-${pad(date.getMonth() + 1)}-${pad(date.getDate())}-${pad(date.getHours())}${pad(date.getMinutes())}`;
|
|
1052
|
+
}
|
|
1053
|
+
function sessionDirName(kind, target, date = /* @__PURE__ */ new Date()) {
|
|
1054
|
+
return `${sessionTimestamp(date)}-${kind}-${slugify(target)}`;
|
|
1055
|
+
}
|
|
1056
|
+
function parseSessionDirName(name) {
|
|
1057
|
+
const m = SESSION_DIR_RE.exec(name);
|
|
1058
|
+
if (!m) return null;
|
|
1059
|
+
return { timestamp: m[1], kind: m[2], slug: m[3] };
|
|
1060
|
+
}
|
|
1061
|
+
|
|
1062
|
+
// src/cli/commands/list.ts
|
|
584
1063
|
function listCommand() {
|
|
585
1064
|
const cmd = new Command3("list").description("List sessions, knowledge, targets, or domains").argument("<type>", "What to list: sessions, knowledge, targets, domains").action(async (type) => {
|
|
586
1065
|
try {
|
|
587
|
-
await runList(type);
|
|
1066
|
+
await runList(type, process.cwd());
|
|
588
1067
|
} catch (err) {
|
|
589
1068
|
console.error(chalk3.red("Error:"), err instanceof Error ? err.message : err);
|
|
590
1069
|
process.exit(1);
|
|
@@ -592,8 +1071,7 @@ function listCommand() {
|
|
|
592
1071
|
});
|
|
593
1072
|
return cmd;
|
|
594
1073
|
}
|
|
595
|
-
async function runList(type) {
|
|
596
|
-
const cwd = process.cwd();
|
|
1074
|
+
async function runList(type, cwd) {
|
|
597
1075
|
switch (type) {
|
|
598
1076
|
case "sessions":
|
|
599
1077
|
listSessions(cwd);
|
|
@@ -608,54 +1086,81 @@ async function runList(type) {
|
|
|
608
1086
|
listDomains(cwd);
|
|
609
1087
|
break;
|
|
610
1088
|
default:
|
|
611
|
-
|
|
612
|
-
process.exit(1);
|
|
1089
|
+
throw new Error(`Unknown type: "${type}". Choose from: sessions, knowledge, targets, domains`);
|
|
613
1090
|
}
|
|
614
1091
|
}
|
|
1092
|
+
function readSessionIndex(indexPath) {
|
|
1093
|
+
if (!existsSync6(indexPath)) return [];
|
|
1094
|
+
const table2 = parseMarkdownTable(readFileSync5(indexPath, "utf-8"));
|
|
1095
|
+
if (!table2) return [];
|
|
1096
|
+
const rows = [];
|
|
1097
|
+
for (const row of table2.rows) {
|
|
1098
|
+
const date = row["date"] ?? "";
|
|
1099
|
+
if (!date || date.startsWith("_")) continue;
|
|
1100
|
+
rows.push({
|
|
1101
|
+
date,
|
|
1102
|
+
kind: row["kind"] ?? "",
|
|
1103
|
+
target: row["target"] ?? "",
|
|
1104
|
+
bugs: row["bugs"] ?? "",
|
|
1105
|
+
duration: row["duration"] ?? "",
|
|
1106
|
+
status: row["status"] ?? "",
|
|
1107
|
+
report: row["report"] ?? row["session directory"] ?? ""
|
|
1108
|
+
});
|
|
1109
|
+
}
|
|
1110
|
+
return rows;
|
|
1111
|
+
}
|
|
615
1112
|
function listSessions(cwd) {
|
|
616
|
-
const
|
|
617
|
-
|
|
618
|
-
|
|
1113
|
+
const sessionsDir = resolve5(cwd, "output", "sessions");
|
|
1114
|
+
const indexPath = join6(sessionsDir, "INDEX.md");
|
|
1115
|
+
if (!existsSync6(sessionsDir)) {
|
|
1116
|
+
console.log(chalk3.yellow("No sessions directory. Run `npx qualiow init` first, then start a session."));
|
|
619
1117
|
return;
|
|
620
1118
|
}
|
|
621
|
-
const
|
|
622
|
-
const
|
|
623
|
-
const
|
|
624
|
-
|
|
625
|
-
);
|
|
626
|
-
if (
|
|
627
|
-
console.log(chalk3.cyan("\nSessions:"));
|
|
1119
|
+
const rows = readSessionIndex(indexPath);
|
|
1120
|
+
const indexedDirs = new Set(rows.map((r) => basename4(r.report.replace(/\/session-report\.md$/, ""))));
|
|
1121
|
+
const unindexed = readdirSync3(sessionsDir, { withFileTypes: true }).filter((d) => d.isDirectory() && SESSION_DIR_RE.test(d.name) && !indexedDirs.has(d.name)).map((d) => d.name).sort();
|
|
1122
|
+
console.log(chalk3.cyan.bold("\nSessions:"));
|
|
1123
|
+
console.log("");
|
|
1124
|
+
if (rows.length === 0 && unindexed.length === 0) {
|
|
628
1125
|
console.log(chalk3.yellow(" No sessions recorded yet."));
|
|
629
|
-
console.log(chalk3.white(" Start one with:
|
|
1126
|
+
console.log(chalk3.white(" Start one with: /qa-explore <url>"));
|
|
1127
|
+
console.log("");
|
|
630
1128
|
return;
|
|
631
1129
|
}
|
|
632
|
-
|
|
633
|
-
|
|
634
|
-
|
|
635
|
-
console.log(
|
|
636
|
-
|
|
637
|
-
|
|
638
|
-
|
|
639
|
-
|
|
640
|
-
|
|
641
|
-
|
|
642
|
-
|
|
643
|
-
}
|
|
1130
|
+
const widths = [16, 8, 22, 5, 9, 12];
|
|
1131
|
+
const header = INDEX_COLUMNS.map((c, i) => i < widths.length ? pad2(c, widths[i]) : c).join(" ");
|
|
1132
|
+
console.log(chalk3.bold(` ${header}`));
|
|
1133
|
+
console.log(` ${widths.map((w) => "\u2500".repeat(w)).join(" ")} ${"\u2500".repeat(30)}`);
|
|
1134
|
+
for (const r of rows) {
|
|
1135
|
+
console.log(
|
|
1136
|
+
` ${pad2(r.date, 16)} ${pad2(r.kind, 8)} ${pad2(r.target, 22)} ${pad2(r.bugs, 5)} ${pad2(r.duration, 9)} ${pad2(r.status, 12)} ${r.report}`
|
|
1137
|
+
);
|
|
1138
|
+
}
|
|
1139
|
+
for (const d of unindexed) {
|
|
1140
|
+
console.log(chalk3.gray(` ${pad2(d.slice(0, 15), 16)} ${pad2("", 8)} ${pad2("", 22)} ${pad2("", 5)} ${pad2("", 9)} ${pad2("unindexed", 12)} ${d}`));
|
|
644
1141
|
}
|
|
645
1142
|
console.log("");
|
|
646
|
-
console.log(chalk3.white(` Total: ${
|
|
1143
|
+
console.log(chalk3.white(` Total: ${rows.length} session(s)` + (unindexed.length ? chalk3.gray(` (+${unindexed.length} unindexed)`) : "")));
|
|
647
1144
|
console.log("");
|
|
648
1145
|
}
|
|
649
1146
|
function listKnowledge(cwd) {
|
|
650
|
-
const
|
|
651
|
-
|
|
1147
|
+
const knowledgeDir = resolve5(cwd, "data", "knowledge");
|
|
1148
|
+
const manifestPath = join6(knowledgeDir, "manifest.yml");
|
|
1149
|
+
if (!existsSync6(manifestPath)) {
|
|
652
1150
|
console.log(chalk3.yellow("No knowledge base found. Run `npx qualiow init` first."));
|
|
653
1151
|
return;
|
|
654
1152
|
}
|
|
655
|
-
const
|
|
656
|
-
const
|
|
1153
|
+
const manifest = parseYaml3(readFileSync5(manifestPath, "utf-8"));
|
|
1154
|
+
const filesOnDisk = globSync4(join6(knowledgeDir, "releases", "*", "entries", "*.yml")).length;
|
|
657
1155
|
console.log(chalk3.cyan.bold("\nKnowledge Base:"));
|
|
658
|
-
console.log(chalk3.white(` Version: ${manifest.version} | Entries: ${manifest.
|
|
1156
|
+
console.log(chalk3.white(` Version: ${manifest.version} | Entries: ${manifest.entries.length}`));
|
|
1157
|
+
if (filesOnDisk !== manifest.entries.length || manifest.stats.total_entries !== filesOnDisk) {
|
|
1158
|
+
console.log(
|
|
1159
|
+
chalk3.yellow(
|
|
1160
|
+
` \u26A0 Registry (${manifest.entries.length}) / stats (${manifest.stats.total_entries}) disagree with ${filesOnDisk} entry files \u2014 run: npx qualiow kb sync`
|
|
1161
|
+
)
|
|
1162
|
+
);
|
|
1163
|
+
}
|
|
659
1164
|
console.log("");
|
|
660
1165
|
const grouped = /* @__PURE__ */ new Map();
|
|
661
1166
|
for (const entry of manifest.entries) {
|
|
@@ -668,68 +1173,67 @@ function listKnowledge(cwd) {
|
|
|
668
1173
|
for (const entry of entries) {
|
|
669
1174
|
const priorityColor = entry.priority === "high" ? chalk3.red : entry.priority === "medium" ? chalk3.yellow : chalk3.white;
|
|
670
1175
|
const tags = entry.tags.map((t) => chalk3.gray(t)).join(", ");
|
|
671
|
-
console.log(
|
|
672
|
-
` ${priorityColor(`[${entry.priority}]`)} ${entry.id} ${chalk3.gray("tags:")} ${tags}`
|
|
673
|
-
);
|
|
1176
|
+
console.log(` ${priorityColor(`[${entry.priority}]`)} ${entry.id} ${chalk3.gray("tags:")} ${tags}`);
|
|
674
1177
|
}
|
|
675
1178
|
console.log("");
|
|
676
1179
|
}
|
|
677
1180
|
}
|
|
678
1181
|
function listTargets(cwd) {
|
|
679
|
-
const targetsDir =
|
|
680
|
-
if (!
|
|
1182
|
+
const targetsDir = resolve5(cwd, "data", "targets");
|
|
1183
|
+
if (!existsSync6(targetsDir)) {
|
|
681
1184
|
console.log(chalk3.yellow("No targets found. Run `npx qualiow init` first."));
|
|
682
1185
|
return;
|
|
683
1186
|
}
|
|
684
|
-
const files =
|
|
685
|
-
|
|
1187
|
+
const files = readdirSync3(targetsDir).filter((f) => f.endsWith(".yml")).sort();
|
|
1188
|
+
const projectLocal = resolve5(cwd, "qa", "target.yml");
|
|
1189
|
+
if (files.length === 0 && !existsSync6(projectLocal)) {
|
|
686
1190
|
console.log(chalk3.yellow("No target configurations found."));
|
|
687
1191
|
return;
|
|
688
1192
|
}
|
|
689
1193
|
console.log(chalk3.cyan.bold("\nTargets:"));
|
|
690
1194
|
console.log("");
|
|
691
|
-
const header = ` ${
|
|
1195
|
+
const header = ` ${pad2("File", 34)} ${pad2("Name", 32)} ${pad2("Domain", 11)} ${pad2("Auth", 16)} Base URL`;
|
|
692
1196
|
console.log(chalk3.bold(header));
|
|
693
|
-
console.log(` ${"\u2500".repeat(
|
|
694
|
-
|
|
1197
|
+
console.log(` ${"\u2500".repeat(34)} ${"\u2500".repeat(32)} ${"\u2500".repeat(11)} ${"\u2500".repeat(16)} ${"\u2500".repeat(30)}`);
|
|
1198
|
+
const printTarget = (label, path) => {
|
|
695
1199
|
try {
|
|
696
|
-
const
|
|
697
|
-
const
|
|
1200
|
+
const target = parseYaml3(readFileSync5(path, "utf-8"));
|
|
1201
|
+
const url = target.base_url || target.web?.base_url || chalk3.gray("(none)");
|
|
698
1202
|
console.log(
|
|
699
|
-
` ${
|
|
1203
|
+
` ${pad2(label, 34)} ${pad2(target.name, 32)} ${pad2(target.domain, 11)} ${pad2(target.auth?.strategy ?? "", 16)} ${url}`
|
|
700
1204
|
);
|
|
701
1205
|
} catch {
|
|
702
|
-
console.log(` ${chalk3.red("ERROR")} Could not parse ${
|
|
1206
|
+
console.log(` ${chalk3.red("ERROR")} Could not parse ${label}`);
|
|
703
1207
|
}
|
|
704
|
-
}
|
|
1208
|
+
};
|
|
1209
|
+
if (existsSync6(projectLocal)) printTarget("qa/target.yml", projectLocal);
|
|
1210
|
+
for (const file of files) printTarget(`data/targets/${file}`, join6(targetsDir, file));
|
|
705
1211
|
console.log("");
|
|
706
|
-
console.log(chalk3.white(` Total: ${files.length} target(s)`));
|
|
1212
|
+
console.log(chalk3.white(` Total: ${files.length + (existsSync6(projectLocal) ? 1 : 0)} target(s)`));
|
|
707
1213
|
console.log("");
|
|
708
1214
|
}
|
|
709
1215
|
function listDomains(cwd) {
|
|
710
|
-
const domainsDir =
|
|
711
|
-
if (!
|
|
1216
|
+
const domainsDir = resolve5(cwd, "data", "domains");
|
|
1217
|
+
if (!existsSync6(domainsDir)) {
|
|
712
1218
|
console.log(chalk3.yellow("No domain configs found. Run `npx qualiow init` first."));
|
|
713
1219
|
return;
|
|
714
1220
|
}
|
|
715
|
-
const files =
|
|
1221
|
+
const files = readdirSync3(domainsDir).filter((f) => f.endsWith(".yml")).sort();
|
|
716
1222
|
if (files.length === 0) {
|
|
717
1223
|
console.log(chalk3.yellow("No domain configurations found."));
|
|
718
1224
|
return;
|
|
719
1225
|
}
|
|
720
1226
|
console.log(chalk3.cyan.bold("\nDomains:"));
|
|
721
1227
|
console.log("");
|
|
722
|
-
const header = ` ${
|
|
1228
|
+
const header = ` ${pad2("File", 18)} ${pad2("Name", 32)} ${pad2("Checklist", 10)} ${pad2("Journeys", 9)} ${pad2("Patterns", 9)}`;
|
|
723
1229
|
console.log(chalk3.bold(header));
|
|
724
|
-
console.log(` ${"\u2500".repeat(
|
|
1230
|
+
console.log(` ${"\u2500".repeat(18)} ${"\u2500".repeat(32)} ${"\u2500".repeat(10)} ${"\u2500".repeat(9)} ${"\u2500".repeat(9)}`);
|
|
725
1231
|
for (const file of files) {
|
|
726
1232
|
try {
|
|
727
|
-
const
|
|
728
|
-
const
|
|
729
|
-
const checklistCount = domain.completeness_checklist?.length ?? 0;
|
|
730
|
-
const journeyCount = domain.journeys?.length ?? 0;
|
|
1233
|
+
const domain = parseYaml3(readFileSync5(join6(domainsDir, file), "utf-8"));
|
|
1234
|
+
const patterns = Object.values(domain.must_test_patterns ?? {}).reduce((n, arr) => n + arr.length, 0);
|
|
731
1235
|
console.log(
|
|
732
|
-
` ${
|
|
1236
|
+
` ${pad2(file, 18)} ${pad2(domain.name, 32)} ${pad2(String(domain.completeness_checklist?.length ?? 0), 10)} ${pad2(String(domain.journeys?.length ?? 0), 9)} ${pad2(String(patterns), 9)}`
|
|
733
1237
|
);
|
|
734
1238
|
} catch {
|
|
735
1239
|
console.log(` ${chalk3.red("ERROR")} Could not parse ${file}`);
|
|
@@ -739,25 +1243,23 @@ function listDomains(cwd) {
|
|
|
739
1243
|
console.log(chalk3.white(` Total: ${files.length} domain(s)`));
|
|
740
1244
|
console.log("");
|
|
741
1245
|
}
|
|
742
|
-
function
|
|
743
|
-
if (str.length >= len)
|
|
744
|
-
return str.slice(0, len);
|
|
745
|
-
}
|
|
1246
|
+
function pad2(str, len) {
|
|
1247
|
+
if (str.length >= len) return str.slice(0, len);
|
|
746
1248
|
return str + " ".repeat(len - str.length);
|
|
747
1249
|
}
|
|
748
1250
|
|
|
749
1251
|
// src/cli/commands/report.ts
|
|
750
1252
|
import { Command as Command4 } from "commander";
|
|
751
|
-
import { resolve as
|
|
752
|
-
import { existsSync as
|
|
1253
|
+
import { resolve as resolve6, join as join9, basename as basename6, relative as relative4 } from "path";
|
|
1254
|
+
import { existsSync as existsSync9, readdirSync as readdirSync5, readFileSync as readFileSync8, writeFileSync as writeFileSync3 } from "fs";
|
|
753
1255
|
import chalk4 from "chalk";
|
|
754
1256
|
|
|
755
1257
|
// src/formatters/html-report.ts
|
|
756
1258
|
import Handlebars from "handlebars";
|
|
757
1259
|
|
|
758
1260
|
// src/utils/parse-session.ts
|
|
759
|
-
import { readFileSync as
|
|
760
|
-
import { join as
|
|
1261
|
+
import { readFileSync as readFileSync6, readdirSync as readdirSync4, existsSync as existsSync7 } from "fs";
|
|
1262
|
+
import { join as join7, basename as basename5 } from "path";
|
|
761
1263
|
var SEVERITY_ORDER = {
|
|
762
1264
|
critical: 0,
|
|
763
1265
|
high: 1,
|
|
@@ -811,33 +1313,48 @@ function extractNumberedList(text) {
|
|
|
811
1313
|
}
|
|
812
1314
|
return steps;
|
|
813
1315
|
}
|
|
1316
|
+
function cleanValue(v) {
|
|
1317
|
+
return v.trim().replace(/^`|`$/g, "").trim();
|
|
1318
|
+
}
|
|
814
1319
|
function extractEvidence(content) {
|
|
815
|
-
const
|
|
816
|
-
|
|
1320
|
+
const evidence = {
|
|
1321
|
+
screenshots: [],
|
|
1322
|
+
videos: [],
|
|
1323
|
+
logs: [],
|
|
1324
|
+
console_errors: [],
|
|
1325
|
+
network_failures: []
|
|
1326
|
+
};
|
|
817
1327
|
const evidenceText = extractSection(content, "Evidence");
|
|
818
|
-
if (!evidenceText)
|
|
819
|
-
return { screenshots, console_errors };
|
|
820
|
-
}
|
|
1328
|
+
if (!evidenceText) return evidence;
|
|
821
1329
|
for (const line of evidenceText.split("\n")) {
|
|
822
1330
|
const trimmed = line.replace(/^[-*]\s*/, "").trim();
|
|
823
|
-
|
|
824
|
-
const
|
|
825
|
-
|
|
826
|
-
|
|
827
|
-
|
|
828
|
-
|
|
829
|
-
|
|
830
|
-
|
|
831
|
-
|
|
832
|
-
|
|
833
|
-
|
|
834
|
-
}
|
|
835
|
-
|
|
836
|
-
|
|
1331
|
+
const value = () => {
|
|
1332
|
+
const m = trimmed.match(/:\s*(.+)/);
|
|
1333
|
+
return m ? cleanValue(m[1]) : "";
|
|
1334
|
+
};
|
|
1335
|
+
const nonEmpty = (v) => v && !/^none\b/i.test(v);
|
|
1336
|
+
if (/^screenshot/i.test(trimmed)) {
|
|
1337
|
+
const v = value();
|
|
1338
|
+
if (nonEmpty(v)) evidence.screenshots.push(v);
|
|
1339
|
+
} else if (/^video/i.test(trimmed)) {
|
|
1340
|
+
const v = value();
|
|
1341
|
+
if (nonEmpty(v)) evidence.videos.push(v);
|
|
1342
|
+
} else if (/^log\b/i.test(trimmed)) {
|
|
1343
|
+
const v = value();
|
|
1344
|
+
if (nonEmpty(v)) evidence.logs.push(v);
|
|
1345
|
+
} else if (/console\s*(error|log)/i.test(trimmed)) {
|
|
1346
|
+
const v = value();
|
|
1347
|
+
if (nonEmpty(v)) evidence.console_errors.push(v);
|
|
1348
|
+
} else if (/network\s*(failure|error|request)/i.test(trimmed)) {
|
|
1349
|
+
const v = value();
|
|
1350
|
+
if (nonEmpty(v)) evidence.network_failures.push(v);
|
|
1351
|
+
}
|
|
1352
|
+
}
|
|
1353
|
+
return evidence;
|
|
837
1354
|
}
|
|
838
1355
|
async function parseBugReport(filePath) {
|
|
839
|
-
const content =
|
|
840
|
-
const filename =
|
|
1356
|
+
const content = readFileSync6(filePath, "utf-8");
|
|
1357
|
+
const filename = basename5(filePath, ".md");
|
|
841
1358
|
const id = filename;
|
|
842
1359
|
let title = "";
|
|
843
1360
|
let component = "";
|
|
@@ -850,6 +1367,10 @@ async function parseBugReport(filePath) {
|
|
|
850
1367
|
component = componentMatch[1];
|
|
851
1368
|
title = title.replace(/^\[[^\]]+\]\s*/, "").trim();
|
|
852
1369
|
}
|
|
1370
|
+
const componentField = content.match(/\*\*Component:\*\*\s*(.+)/i);
|
|
1371
|
+
if (componentField) {
|
|
1372
|
+
component = cleanValue(componentField[1]);
|
|
1373
|
+
}
|
|
853
1374
|
if (!component) {
|
|
854
1375
|
const categoryMatch = content.match(/\|\s*Category\s*\|\s*(.+?)\s*\|/i);
|
|
855
1376
|
if (categoryMatch) {
|
|
@@ -864,8 +1385,14 @@ async function parseBugReport(filePath) {
|
|
|
864
1385
|
let url = "";
|
|
865
1386
|
const urlMatch = content.match(/\*\*URL:\*\*\s*(.+)/i) ?? content.match(/URL:\s*(https?:\/\/[^\s]+)/i);
|
|
866
1387
|
if (urlMatch) {
|
|
867
|
-
url = urlMatch[1]
|
|
1388
|
+
url = cleanValue(urlMatch[1]);
|
|
868
1389
|
}
|
|
1390
|
+
const priority = cleanValue(content.match(/\*\*Priority:\*\*\s*(.+)/i)?.[1] ?? "");
|
|
1391
|
+
const environment = cleanValue(content.match(/\*\*Environment:\*\*\s*(.+)/i)?.[1] ?? "");
|
|
1392
|
+
const reproduction_rate = cleanValue(
|
|
1393
|
+
content.match(/\*\*Reproduction rate:\*\*\s*(.+)/i)?.[1] ?? ""
|
|
1394
|
+
);
|
|
1395
|
+
const summary = extractSection(content, "Summary").replace(/^>\s*/gm, "").trim();
|
|
869
1396
|
const expected = extractSection(content, "Expected").replace(/^_.*_\n?/, "").replace(/^>\s*/gm, "").trim();
|
|
870
1397
|
const actual = extractSection(content, "Actual").replace(/^_.*_\n?/, "").replace(/^>\s*/gm, "").trim();
|
|
871
1398
|
const stepsSection = extractSection(content, "Steps to Reproduce");
|
|
@@ -876,8 +1403,12 @@ async function parseBugReport(filePath) {
|
|
|
876
1403
|
id,
|
|
877
1404
|
title,
|
|
878
1405
|
severity,
|
|
1406
|
+
priority,
|
|
879
1407
|
component,
|
|
880
1408
|
url,
|
|
1409
|
+
environment,
|
|
1410
|
+
reproduction_rate,
|
|
1411
|
+
summary,
|
|
881
1412
|
expected,
|
|
882
1413
|
actual,
|
|
883
1414
|
steps,
|
|
@@ -886,33 +1417,33 @@ async function parseBugReport(filePath) {
|
|
|
886
1417
|
};
|
|
887
1418
|
}
|
|
888
1419
|
async function parseSession(sessionDir) {
|
|
889
|
-
const id =
|
|
1420
|
+
const id = basename5(sessionDir);
|
|
890
1421
|
let charter;
|
|
891
|
-
const charterPath =
|
|
892
|
-
if (
|
|
893
|
-
charter =
|
|
1422
|
+
const charterPath = join7(sessionDir, "charter.md");
|
|
1423
|
+
if (existsSync7(charterPath)) {
|
|
1424
|
+
charter = readFileSync6(charterPath, "utf-8");
|
|
894
1425
|
}
|
|
895
1426
|
let report;
|
|
896
|
-
const reportPath =
|
|
897
|
-
if (
|
|
898
|
-
report =
|
|
1427
|
+
const reportPath = join7(sessionDir, "session-report.md");
|
|
1428
|
+
if (existsSync7(reportPath)) {
|
|
1429
|
+
report = readFileSync6(reportPath, "utf-8");
|
|
899
1430
|
}
|
|
900
1431
|
const phases = [];
|
|
901
|
-
if (
|
|
902
|
-
const files =
|
|
1432
|
+
if (existsSync7(sessionDir)) {
|
|
1433
|
+
const files = readdirSync4(sessionDir);
|
|
903
1434
|
const phaseFiles = files.filter((f) => /^phase-\d+/i.test(f)).sort();
|
|
904
1435
|
for (const file of phaseFiles) {
|
|
905
|
-
const content =
|
|
1436
|
+
const content = readFileSync6(join7(sessionDir, file), "utf-8");
|
|
906
1437
|
const name = file.replace(/\.md$/, "");
|
|
907
1438
|
phases.push({ name, content });
|
|
908
1439
|
}
|
|
909
1440
|
}
|
|
910
|
-
const bugsDir =
|
|
1441
|
+
const bugsDir = join7(sessionDir, "bugs");
|
|
911
1442
|
const bugs = [];
|
|
912
|
-
if (
|
|
913
|
-
const bugFiles =
|
|
1443
|
+
if (existsSync7(bugsDir)) {
|
|
1444
|
+
const bugFiles = readdirSync4(bugsDir).filter((f) => /^BUG-.*\.md$/i.test(f)).sort();
|
|
914
1445
|
for (const file of bugFiles) {
|
|
915
|
-
const bug = await parseBugReport(
|
|
1446
|
+
const bug = await parseBugReport(join7(bugsDir, file));
|
|
916
1447
|
bugs.push(bug);
|
|
917
1448
|
}
|
|
918
1449
|
}
|
|
@@ -926,7 +1457,164 @@ async function parseSession(sessionDir) {
|
|
|
926
1457
|
};
|
|
927
1458
|
}
|
|
928
1459
|
|
|
929
|
-
// src/
|
|
1460
|
+
// src/utils/redact.ts
|
|
1461
|
+
var EMAIL_ALLOW = /(?:@|\.)(?:example\.(?:com|org|net)|localhost)$/i;
|
|
1462
|
+
function luhnValid(digits) {
|
|
1463
|
+
let sum = 0;
|
|
1464
|
+
let alt = false;
|
|
1465
|
+
for (let i = digits.length - 1; i >= 0; i--) {
|
|
1466
|
+
let d = digits.charCodeAt(i) - 48;
|
|
1467
|
+
if (d < 0 || d > 9) return false;
|
|
1468
|
+
if (alt) {
|
|
1469
|
+
d *= 2;
|
|
1470
|
+
if (d > 9) d -= 9;
|
|
1471
|
+
}
|
|
1472
|
+
sum += d;
|
|
1473
|
+
alt = !alt;
|
|
1474
|
+
}
|
|
1475
|
+
return sum % 10 === 0;
|
|
1476
|
+
}
|
|
1477
|
+
var RULES = [
|
|
1478
|
+
{
|
|
1479
|
+
name: "Private key",
|
|
1480
|
+
pattern: /-----BEGIN (?:[A-Z0-9 ]+ )?PRIVATE KEY-----[\s\S]*?-----END (?:[A-Z0-9 ]+ )?PRIVATE KEY-----/g,
|
|
1481
|
+
replacement: "[PRIVATE_KEY_REDACTED]"
|
|
1482
|
+
},
|
|
1483
|
+
{
|
|
1484
|
+
name: "JWT",
|
|
1485
|
+
pattern: /\beyJ[A-Za-z0-9_-]{8,}\.[A-Za-z0-9_-]{6,}\.[A-Za-z0-9_-]{6,}\b/g,
|
|
1486
|
+
replacement: "[JWT_REDACTED]"
|
|
1487
|
+
},
|
|
1488
|
+
{
|
|
1489
|
+
name: "Authorization header",
|
|
1490
|
+
pattern: /(authorization)(\s*[:=]\s*)(\S[^\n\r]*)/gi,
|
|
1491
|
+
replace: (m, k, sep, value) => /_REDACTED\]/.test(value) ? m : `${k}${sep}[REDACTED]`
|
|
1492
|
+
},
|
|
1493
|
+
{
|
|
1494
|
+
name: "Cookie header",
|
|
1495
|
+
pattern: /^(set-cookie|cookie)(\s*:\s*).+$/gim,
|
|
1496
|
+
replace: (_m, k, sep) => `${k}${sep}[REDACTED]`
|
|
1497
|
+
},
|
|
1498
|
+
{
|
|
1499
|
+
name: "AWS access key id",
|
|
1500
|
+
pattern: /\b(?:AKIA|ASIA|AROA|AIDA)[0-9A-Z]{16}\b/g,
|
|
1501
|
+
replacement: "[AWS_KEY_REDACTED]"
|
|
1502
|
+
},
|
|
1503
|
+
{
|
|
1504
|
+
name: "AWS secret access key",
|
|
1505
|
+
pattern: /(aws_secret_access_key)(\s*[:=]\s*)\S+/gi,
|
|
1506
|
+
replace: (_m, k, sep) => `${k}${sep}[REDACTED]`
|
|
1507
|
+
},
|
|
1508
|
+
{
|
|
1509
|
+
name: "OpenAI-style key",
|
|
1510
|
+
pattern: /\bsk-(?:proj-)?[A-Za-z0-9_-]{20,}\b/g,
|
|
1511
|
+
replacement: "[SK_KEY_REDACTED]"
|
|
1512
|
+
},
|
|
1513
|
+
{
|
|
1514
|
+
name: "GitHub token",
|
|
1515
|
+
pattern: /\b(?:gh[pousr]_[A-Za-z0-9]{20,}|github_pat_[A-Za-z0-9_]{20,})\b/g,
|
|
1516
|
+
replacement: "[GITHUB_TOKEN_REDACTED]"
|
|
1517
|
+
},
|
|
1518
|
+
{
|
|
1519
|
+
name: "Slack token",
|
|
1520
|
+
pattern: /\bxox[abposr]-[A-Za-z0-9-]{10,}\b/g,
|
|
1521
|
+
replacement: "[SLACK_TOKEN_REDACTED]"
|
|
1522
|
+
},
|
|
1523
|
+
{
|
|
1524
|
+
name: "API key",
|
|
1525
|
+
pattern: /(x-api-key|api[_-]?key)(\s*[:=]\s*)["']?[A-Za-z0-9._-]{8,}["']?/gi,
|
|
1526
|
+
replace: (_m, k, sep) => `${k}${sep}[REDACTED]`
|
|
1527
|
+
},
|
|
1528
|
+
{
|
|
1529
|
+
name: "Password",
|
|
1530
|
+
pattern: /(password|passwd|pwd)(\s*[:=]\s*)["']?[^\s,}"']+["']?/gi,
|
|
1531
|
+
replace: (_m, k, sep) => `${k}${sep}[REDACTED]`
|
|
1532
|
+
},
|
|
1533
|
+
{
|
|
1534
|
+
name: "Token",
|
|
1535
|
+
pattern: /(access[_-]?token|refresh[_-]?token|token)(\s*[:=]\s*)["']?[A-Za-z0-9._-]{8,}["']?/gi,
|
|
1536
|
+
replace: (_m, k, sep) => `${k}${sep}[REDACTED]`
|
|
1537
|
+
},
|
|
1538
|
+
{
|
|
1539
|
+
name: "Secret",
|
|
1540
|
+
pattern: /([a-z_]*secret)(\s*[:=]\s*)["']?[^\s,}"']+["']?/gi,
|
|
1541
|
+
replace: (_m, k, sep) => `${k}${sep}[REDACTED]`
|
|
1542
|
+
},
|
|
1543
|
+
{
|
|
1544
|
+
name: "SSN",
|
|
1545
|
+
pattern: /\b\d{3}-\d{2}-\d{4}\b/g,
|
|
1546
|
+
replacement: "[SSN_REDACTED]"
|
|
1547
|
+
},
|
|
1548
|
+
{
|
|
1549
|
+
name: "Credit card number",
|
|
1550
|
+
pattern: /\b\d(?:[ -]?\d){12,18}\b/g,
|
|
1551
|
+
replace: (match) => {
|
|
1552
|
+
const digits = match.replace(/\D/g, "");
|
|
1553
|
+
if (digits.length < 13 || digits.length > 19) return match;
|
|
1554
|
+
if (!/^[3-6]/.test(digits)) return match;
|
|
1555
|
+
return luhnValid(digits) ? "[CARD_NUMBER_REDACTED]" : match;
|
|
1556
|
+
}
|
|
1557
|
+
}
|
|
1558
|
+
];
|
|
1559
|
+
function redact(text, opts = {}) {
|
|
1560
|
+
const redactions = /* @__PURE__ */ new Set();
|
|
1561
|
+
let result = text;
|
|
1562
|
+
const rules = RULES.slice();
|
|
1563
|
+
if (opts.emails !== false) {
|
|
1564
|
+
rules.push({
|
|
1565
|
+
name: "Email",
|
|
1566
|
+
pattern: /\b[A-Za-z0-9._%+-]+@[A-Za-z0-9.-]+\.[A-Za-z]{2,}\b/g,
|
|
1567
|
+
replace: (match) => EMAIL_ALLOW.test(match) ? match : "[EMAIL_REDACTED]"
|
|
1568
|
+
});
|
|
1569
|
+
}
|
|
1570
|
+
for (const rule of rules) {
|
|
1571
|
+
rule.pattern.lastIndex = 0;
|
|
1572
|
+
let fired = false;
|
|
1573
|
+
result = result.replace(rule.pattern, (...args) => {
|
|
1574
|
+
const match = args[0];
|
|
1575
|
+
const groups = args.slice(1, -2);
|
|
1576
|
+
const out = rule.replace ? rule.replace(match, ...groups) : rule.replacement;
|
|
1577
|
+
if (out !== match) fired = true;
|
|
1578
|
+
return out;
|
|
1579
|
+
});
|
|
1580
|
+
if (fired) redactions.add(rule.name);
|
|
1581
|
+
}
|
|
1582
|
+
return { text: result, redactions: [...redactions] };
|
|
1583
|
+
}
|
|
1584
|
+
var REDACTION_CATEGORIES = RULES.map((r) => r.name).concat("Email");
|
|
1585
|
+
|
|
1586
|
+
// src/formatters/common.ts
|
|
1587
|
+
function redactString(s) {
|
|
1588
|
+
return s ? redact(s).text : s;
|
|
1589
|
+
}
|
|
1590
|
+
function redactBug(bug) {
|
|
1591
|
+
return {
|
|
1592
|
+
...bug,
|
|
1593
|
+
title: redactString(bug.title),
|
|
1594
|
+
url: redactString(bug.url),
|
|
1595
|
+
environment: redactString(bug.environment),
|
|
1596
|
+
summary: redactString(bug.summary),
|
|
1597
|
+
expected: redactString(bug.expected),
|
|
1598
|
+
actual: redactString(bug.actual),
|
|
1599
|
+
steps: bug.steps.map(redactString),
|
|
1600
|
+
business_impact: redactString(bug.business_impact),
|
|
1601
|
+
evidence: {
|
|
1602
|
+
screenshots: bug.evidence.screenshots.map(redactString),
|
|
1603
|
+
videos: bug.evidence.videos.map(redactString),
|
|
1604
|
+
logs: bug.evidence.logs.map(redactString),
|
|
1605
|
+
console_errors: bug.evidence.console_errors.map(redactString),
|
|
1606
|
+
network_failures: bug.evidence.network_failures.map(redactString)
|
|
1607
|
+
}
|
|
1608
|
+
};
|
|
1609
|
+
}
|
|
1610
|
+
async function loadSessionForOutput(sessionDir) {
|
|
1611
|
+
const session = await parseSession(sessionDir);
|
|
1612
|
+
const report = session.report ? redact(session.report).text : "";
|
|
1613
|
+
return {
|
|
1614
|
+
session: { ...session, bugs: session.bugs.map(redactBug), report },
|
|
1615
|
+
report
|
|
1616
|
+
};
|
|
1617
|
+
}
|
|
930
1618
|
function extractReportMeta(report, sessionId) {
|
|
931
1619
|
const meta = {
|
|
932
1620
|
target: sessionId,
|
|
@@ -941,40 +1629,34 @@ function extractReportMeta(report, sessionId) {
|
|
|
941
1629
|
if (durationMatch) meta.duration = durationMatch[1].trim();
|
|
942
1630
|
const targetMatch = report.match(/\*\*Application:\*\*\s*(.+)/i) ?? report.match(/\*\*Target:\*\*\s*(.+)/i) ?? report.match(/\|\s*Target\s*\|\s*(.+?)\s*\|/i);
|
|
943
1631
|
if (targetMatch) meta.target = targetMatch[1].trim();
|
|
944
|
-
const summaryMatch = report.match(
|
|
1632
|
+
const summaryMatch = report.match(
|
|
1633
|
+
/##\s+Executive Summary\s*\n+([\s\S]*?)(?=\n##\s|\n---|$)/i
|
|
1634
|
+
);
|
|
945
1635
|
if (summaryMatch) meta.summary = summaryMatch[1].trim();
|
|
946
1636
|
return meta;
|
|
947
1637
|
}
|
|
948
1638
|
function extractCoverage(report) {
|
|
949
|
-
const
|
|
950
|
-
|
|
951
|
-
|
|
952
|
-
|
|
953
|
-
|
|
954
|
-
|
|
955
|
-
|
|
956
|
-
|
|
957
|
-
|
|
958
|
-
entries.push({
|
|
959
|
-
area: cells[0] || "",
|
|
960
|
-
status: cells[1] || "",
|
|
961
|
-
bugsFound: cells[3] || "0",
|
|
962
|
-
notes: cells[4] || ""
|
|
963
|
-
});
|
|
964
|
-
}
|
|
965
|
-
}
|
|
966
|
-
return entries;
|
|
1639
|
+
const table2 = parseMarkdownTable(report, { headingPrefix: "Coverage" });
|
|
1640
|
+
if (!table2) return [];
|
|
1641
|
+
return table2.rows.map((row) => ({
|
|
1642
|
+
area: row["area"] ?? "",
|
|
1643
|
+
risk: row["risk"] ?? "",
|
|
1644
|
+
status: row["status"] ?? row["tested?"] ?? row["tested"] ?? "",
|
|
1645
|
+
bugsFound: row["bugs"] ?? row["bugs found"] ?? row["findings"] ?? "0",
|
|
1646
|
+
notes: row["notes"] ?? ""
|
|
1647
|
+
}));
|
|
967
1648
|
}
|
|
968
1649
|
function extractListSection(report, heading) {
|
|
969
1650
|
const items = [];
|
|
970
|
-
const regex = new RegExp(
|
|
1651
|
+
const regex = new RegExp(
|
|
1652
|
+
`##\\s+${heading}\\s*\\n+([\\s\\S]*?)(?=\\n##\\s|\\n---|$)`,
|
|
1653
|
+
"i"
|
|
1654
|
+
);
|
|
971
1655
|
const match = report.match(regex);
|
|
972
1656
|
if (!match) return items;
|
|
973
1657
|
for (const line of match[1].split("\n")) {
|
|
974
1658
|
const itemMatch = line.match(/^[-*]\s+(?:\[.\]\s+)?(.+)/);
|
|
975
|
-
if (itemMatch)
|
|
976
|
-
items.push(itemMatch[1].trim());
|
|
977
|
-
}
|
|
1659
|
+
if (itemMatch) items.push(itemMatch[1].trim());
|
|
978
1660
|
const numberedMatch = line.match(/^\d+\.\s+\*\*(.+?)\*\*\s*(.+)?/);
|
|
979
1661
|
if (numberedMatch) {
|
|
980
1662
|
const text = numberedMatch[2] ? `${numberedMatch[1]} ${numberedMatch[2]}` : numberedMatch[1];
|
|
@@ -983,11 +1665,25 @@ function extractListSection(report, heading) {
|
|
|
983
1665
|
}
|
|
984
1666
|
return items;
|
|
985
1667
|
}
|
|
1668
|
+
|
|
1669
|
+
// src/utils/confidentiality.ts
|
|
1670
|
+
var CONFIDENTIALITY_LINES = [
|
|
1671
|
+
"CONFIDENTIAL: This report may contain internal URLs, security vulnerabilities,",
|
|
1672
|
+
"and application details. Do not share outside your organization without review."
|
|
1673
|
+
];
|
|
1674
|
+
var CONFIDENTIALITY_HEADER_MD = CONFIDENTIALITY_LINES.map(
|
|
1675
|
+
(l) => `> ${l}`
|
|
1676
|
+
).join("\n");
|
|
1677
|
+
var CONFIDENTIALITY_NOTICE = CONFIDENTIALITY_LINES.join(" ");
|
|
1678
|
+
|
|
1679
|
+
// src/formatters/html-report.ts
|
|
986
1680
|
var HTML_TEMPLATE = `<!DOCTYPE html>
|
|
987
1681
|
<html lang="en">
|
|
988
1682
|
<head>
|
|
989
1683
|
<meta charset="UTF-8">
|
|
990
1684
|
<meta name="viewport" content="width=device-width, initial-scale=1.0">
|
|
1685
|
+
<meta http-equiv="Content-Security-Policy" content="default-src 'none'; style-src 'unsafe-inline'; img-src data:">
|
|
1686
|
+
<meta name="robots" content="noindex, nofollow">
|
|
991
1687
|
<title>Qualiow Report \u2014 {{meta.target}}</title>
|
|
992
1688
|
<style>
|
|
993
1689
|
*, *::before, *::after { box-sizing: border-box; margin: 0; padding: 0; }
|
|
@@ -1181,6 +1877,18 @@ var HTML_TEMPLATE = `<!DOCTYPE html>
|
|
|
1181
1877
|
margin-bottom: 0.35rem;
|
|
1182
1878
|
}
|
|
1183
1879
|
|
|
1880
|
+
/* Confidentiality banner */
|
|
1881
|
+
.confidential {
|
|
1882
|
+
background: #2a1a1a;
|
|
1883
|
+
border: 1px solid #663333;
|
|
1884
|
+
color: #e0b0b0;
|
|
1885
|
+
border-radius: 6px;
|
|
1886
|
+
padding: 0.6rem 1rem;
|
|
1887
|
+
font-size: 0.8rem;
|
|
1888
|
+
margin-bottom: 1.5rem;
|
|
1889
|
+
letter-spacing: 0.02em;
|
|
1890
|
+
}
|
|
1891
|
+
|
|
1184
1892
|
/* Footer */
|
|
1185
1893
|
.footer {
|
|
1186
1894
|
margin-top: 3rem;
|
|
@@ -1227,6 +1935,8 @@ var HTML_TEMPLATE = `<!DOCTYPE html>
|
|
|
1227
1935
|
<body>
|
|
1228
1936
|
<div class="container">
|
|
1229
1937
|
|
|
1938
|
+
<div class="confidential">{{confidentialityNotice}}</div>
|
|
1939
|
+
|
|
1230
1940
|
<div class="header">
|
|
1231
1941
|
<h1>Exploratory Testing Report</h1>
|
|
1232
1942
|
<div class="meta">
|
|
@@ -1347,7 +2057,7 @@ var HTML_TEMPLATE = `<!DOCTYPE html>
|
|
|
1347
2057
|
{{/if}}
|
|
1348
2058
|
|
|
1349
2059
|
<div class="footer">
|
|
1350
|
-
Generated by Qualiow Exploratory Testing
|
|
2060
|
+
Generated by Qualiow Exploratory Testing \xB7 CONFIDENTIAL \u2014 internal use only
|
|
1351
2061
|
</div>
|
|
1352
2062
|
|
|
1353
2063
|
</div>
|
|
@@ -1355,8 +2065,7 @@ var HTML_TEMPLATE = `<!DOCTYPE html>
|
|
|
1355
2065
|
</html>`;
|
|
1356
2066
|
var compiledTemplate = Handlebars.compile(HTML_TEMPLATE);
|
|
1357
2067
|
async function generateHtmlReport(sessionDir) {
|
|
1358
|
-
const session = await
|
|
1359
|
-
const report = session.report ?? "";
|
|
2068
|
+
const { session, report } = await loadSessionForOutput(sessionDir);
|
|
1360
2069
|
const meta = extractReportMeta(report, session.id);
|
|
1361
2070
|
const coverage = extractCoverage(report);
|
|
1362
2071
|
const observations = extractListSection(report, "Observations");
|
|
@@ -1372,6 +2081,7 @@ async function generateHtmlReport(sessionDir) {
|
|
|
1372
2081
|
}));
|
|
1373
2082
|
const html = compiledTemplate({
|
|
1374
2083
|
meta,
|
|
2084
|
+
confidentialityNotice: CONFIDENTIALITY_NOTICE,
|
|
1375
2085
|
totalBugs: session.bugs.length,
|
|
1376
2086
|
criticalCount: counts.critical,
|
|
1377
2087
|
highCount: counts.high,
|
|
@@ -1401,8 +2111,7 @@ function summarizeBusinessImpact(impact) {
|
|
|
1401
2111
|
function extractTarget(report, sessionId) {
|
|
1402
2112
|
const match = report.match(/\*\*Application:\*\*\s*(.+)/i) ?? report.match(/\*\*Target:\*\*\s*(.+)/i) ?? report.match(/\|\s*Target\s*\|\s*(.+?)\s*\|/i);
|
|
1403
2113
|
if (match) return match[1].trim();
|
|
1404
|
-
|
|
1405
|
-
return parts[parts.length - 1] || sessionId;
|
|
2114
|
+
return parseSessionDirName(sessionId)?.slug ?? sessionId;
|
|
1406
2115
|
}
|
|
1407
2116
|
function extractDate(report) {
|
|
1408
2117
|
const match = report.match(/\*\*Date:\*\*\s*(\d{4}-\d{2}-\d{2})/i) ?? report.match(/\|\s*Date\s*\|\s*(\d{4}-\d{2}-\d{2})\s*\|/i);
|
|
@@ -1416,64 +2125,33 @@ function extractPagesExplored(report) {
|
|
|
1416
2125
|
const match = report.match(/Pages\s+Explored\s*\|\s*(\d+)/i);
|
|
1417
2126
|
return match ? parseInt(match[1], 10) : 0;
|
|
1418
2127
|
}
|
|
1419
|
-
function extractCoverage2(report) {
|
|
1420
|
-
const entries = [];
|
|
1421
|
-
const tableMatch = report.match(
|
|
1422
|
-
/\|\s*Area\s*\|\s*Status\s*\|[\s\S]*?\n((?:\|.+\|.+\n?)+)/i
|
|
1423
|
-
);
|
|
1424
|
-
if (!tableMatch) return entries;
|
|
1425
|
-
const rows = tableMatch[1].split("\n").filter((r) => r.trim().startsWith("|"));
|
|
1426
|
-
for (const row of rows) {
|
|
1427
|
-
const cells = row.split("|").map((c) => c.trim()).filter(Boolean);
|
|
1428
|
-
if (cells.length >= 2 && !cells[0].startsWith("---")) {
|
|
1429
|
-
entries.push({
|
|
1430
|
-
area: cells[0] || "",
|
|
1431
|
-
status: cells[1] || "",
|
|
1432
|
-
bugs_found: parseInt(cells[3] || "0", 10) || 0,
|
|
1433
|
-
notes: cells[4] || ""
|
|
1434
|
-
});
|
|
1435
|
-
}
|
|
1436
|
-
}
|
|
1437
|
-
return entries;
|
|
1438
|
-
}
|
|
1439
|
-
function extractListSection2(report, heading) {
|
|
1440
|
-
const items = [];
|
|
1441
|
-
const regex = new RegExp(`##\\s+${heading}\\s*\\n+([\\s\\S]*?)(?=\\n##\\s|\\n---|$)`, "i");
|
|
1442
|
-
const match = report.match(regex);
|
|
1443
|
-
if (!match) return items;
|
|
1444
|
-
for (const line of match[1].split("\n")) {
|
|
1445
|
-
const itemMatch = line.match(/^[-*]\s+(?:\[.\]\s+)?(.+)/);
|
|
1446
|
-
if (itemMatch) {
|
|
1447
|
-
items.push(itemMatch[1].trim());
|
|
1448
|
-
}
|
|
1449
|
-
const numberedMatch = line.match(/^\d+\.\s+\*\*(.+?)\*\*\s*(.+)?/);
|
|
1450
|
-
if (numberedMatch) {
|
|
1451
|
-
const text = numberedMatch[2] ? `${numberedMatch[1]} ${numberedMatch[2]}` : numberedMatch[1];
|
|
1452
|
-
items.push(text.replace(/\s*--\s*/, " -- "));
|
|
1453
|
-
}
|
|
1454
|
-
}
|
|
1455
|
-
return items;
|
|
1456
|
-
}
|
|
1457
2128
|
async function generateJsonReport(sessionDir) {
|
|
1458
|
-
const session = await
|
|
1459
|
-
const report = session.report ?? "";
|
|
1460
|
-
const target = extractTarget(report, session.id);
|
|
1461
|
-
const date = extractDate(report);
|
|
1462
|
-
const duration_min = extractDuration(report);
|
|
1463
|
-
const pages_explored = extractPagesExplored(report);
|
|
2129
|
+
const { session, report } = await loadSessionForOutput(sessionDir);
|
|
1464
2130
|
const counts = { critical: 0, high: 0, medium: 0, low: 0 };
|
|
1465
2131
|
for (const bug of session.bugs) {
|
|
1466
2132
|
counts[bug.severity]++;
|
|
1467
2133
|
}
|
|
1468
|
-
const coverage =
|
|
1469
|
-
|
|
1470
|
-
|
|
2134
|
+
const coverage = extractCoverage(report).map((c) => ({
|
|
2135
|
+
area: c.area,
|
|
2136
|
+
risk: c.risk,
|
|
2137
|
+
status: c.status,
|
|
2138
|
+
bugs_found: parseInt(c.bugsFound, 10) || 0,
|
|
2139
|
+
notes: c.notes
|
|
2140
|
+
}));
|
|
1471
2141
|
return {
|
|
2142
|
+
meta: {
|
|
2143
|
+
classification: "CONFIDENTIAL",
|
|
2144
|
+
notice: CONFIDENTIALITY_NOTICE,
|
|
2145
|
+
generated_by: `qualiow-exploratory-testing ${getPackageVersion()}`,
|
|
2146
|
+
generated_at: (/* @__PURE__ */ new Date()).toISOString(),
|
|
2147
|
+
redacted: true
|
|
2148
|
+
},
|
|
1472
2149
|
session: {
|
|
1473
2150
|
id: session.id,
|
|
1474
|
-
|
|
1475
|
-
|
|
1476
|
-
|
|
2151
|
+
kind: parseSessionDirName(session.id)?.kind ?? null,
|
|
2152
|
+
target: extractTarget(report, session.id),
|
|
2153
|
+
date: extractDate(report),
|
|
2154
|
+
duration_min: extractDuration(report)
|
|
1477
2155
|
},
|
|
1478
2156
|
summary: {
|
|
1479
2157
|
total_bugs: session.bugs.length,
|
|
@@ -1481,21 +2159,25 @@ async function generateJsonReport(sessionDir) {
|
|
|
1481
2159
|
high: counts.high,
|
|
1482
2160
|
medium: counts.medium,
|
|
1483
2161
|
low: counts.low,
|
|
1484
|
-
pages_explored
|
|
2162
|
+
pages_explored: extractPagesExplored(report)
|
|
1485
2163
|
},
|
|
1486
2164
|
bugs: session.bugs.map((bug) => ({
|
|
1487
2165
|
id: bug.id,
|
|
1488
2166
|
title: bug.title,
|
|
1489
2167
|
severity: bug.severity,
|
|
2168
|
+
priority: bug.priority,
|
|
1490
2169
|
component: bug.component,
|
|
1491
2170
|
url: bug.url,
|
|
2171
|
+
environment: bug.environment,
|
|
2172
|
+
reproduction_rate: bug.reproduction_rate,
|
|
2173
|
+
summary: bug.summary,
|
|
1492
2174
|
business_impact: bug.business_impact,
|
|
1493
2175
|
steps: bug.steps,
|
|
1494
2176
|
evidence: bug.evidence
|
|
1495
2177
|
})),
|
|
1496
2178
|
coverage,
|
|
1497
|
-
observations,
|
|
1498
|
-
recommendations
|
|
2179
|
+
observations: extractListSection(report, "Observations"),
|
|
2180
|
+
recommendations: extractListSection(report, "Recommendations")
|
|
1499
2181
|
};
|
|
1500
2182
|
}
|
|
1501
2183
|
|
|
@@ -1508,53 +2190,49 @@ var SEVERITY_TO_JIRA_PRIORITY = {
|
|
|
1508
2190
|
};
|
|
1509
2191
|
function csvEscape(value) {
|
|
1510
2192
|
if (!value) return '""';
|
|
1511
|
-
|
|
1512
|
-
|
|
2193
|
+
let v = value;
|
|
2194
|
+
if (/^[=+\-@\t\r]/.test(v)) v = `'${v}`;
|
|
2195
|
+
return `"${v.replace(/"/g, '""')}"`;
|
|
1513
2196
|
}
|
|
1514
2197
|
function formatDescription(bug) {
|
|
1515
2198
|
const parts = [];
|
|
2199
|
+
if (bug.summary) {
|
|
2200
|
+
parts.push(bug.summary, "");
|
|
2201
|
+
}
|
|
1516
2202
|
if (bug.steps.length > 0) {
|
|
1517
2203
|
parts.push("h3. Steps to Reproduce");
|
|
1518
|
-
for (const step of bug.steps) {
|
|
1519
|
-
parts.push(`# ${step}`);
|
|
1520
|
-
}
|
|
2204
|
+
for (const step of bug.steps) parts.push(`# ${step}`);
|
|
1521
2205
|
parts.push("");
|
|
1522
2206
|
}
|
|
1523
2207
|
if (bug.expected) {
|
|
1524
|
-
parts.push(
|
|
1525
|
-
parts.push(bug.expected);
|
|
1526
|
-
parts.push("");
|
|
2208
|
+
parts.push("h3. Expected Behavior", bug.expected, "");
|
|
1527
2209
|
}
|
|
1528
2210
|
if (bug.actual) {
|
|
1529
|
-
parts.push(
|
|
1530
|
-
parts.push(bug.actual);
|
|
1531
|
-
parts.push("");
|
|
2211
|
+
parts.push("h3. Actual Behavior", bug.actual, "");
|
|
1532
2212
|
}
|
|
1533
2213
|
if (bug.business_impact) {
|
|
1534
|
-
parts.push("h3. Business Impact");
|
|
1535
|
-
|
|
1536
|
-
|
|
2214
|
+
parts.push("h3. Business Impact", bug.business_impact, "");
|
|
2215
|
+
}
|
|
2216
|
+
if (bug.environment) {
|
|
2217
|
+
parts.push("h3. Environment", bug.environment, "");
|
|
1537
2218
|
}
|
|
1538
2219
|
if (bug.url) {
|
|
1539
|
-
parts.push(
|
|
1540
|
-
parts.push(bug.url);
|
|
2220
|
+
parts.push("h3. URL", bug.url, "");
|
|
1541
2221
|
}
|
|
2222
|
+
parts.push(`_${CONFIDENTIALITY_NOTICE}_`);
|
|
1542
2223
|
return parts.join("\n");
|
|
1543
2224
|
}
|
|
1544
|
-
function extractDomain(sessionId) {
|
|
1545
|
-
return "general";
|
|
1546
|
-
}
|
|
1547
2225
|
async function generateJiraExport(sessionDir) {
|
|
1548
|
-
const session = await
|
|
2226
|
+
const { session } = await loadSessionForOutput(sessionDir);
|
|
1549
2227
|
const headers = ["Summary", "Priority", "Description", "Component", "Labels"];
|
|
1550
2228
|
const rows = [headers.join(",")];
|
|
1551
|
-
const
|
|
2229
|
+
const kind = parseSessionDirName(session.id)?.kind ?? "";
|
|
1552
2230
|
for (const bug of session.bugs) {
|
|
1553
2231
|
const summary = `${bug.id}: ${bug.title}`;
|
|
1554
2232
|
const priority = SEVERITY_TO_JIRA_PRIORITY[bug.severity] ?? "Major";
|
|
1555
2233
|
const description = formatDescription(bug);
|
|
1556
2234
|
const component = bug.component || "";
|
|
1557
|
-
const labels = ["qualiow", "exploratory-testing",
|
|
2235
|
+
const labels = ["qualiow", "exploratory-testing", kind].filter(Boolean).join(" ");
|
|
1558
2236
|
rows.push(
|
|
1559
2237
|
[
|
|
1560
2238
|
csvEscape(summary),
|
|
@@ -1568,11 +2246,139 @@ async function generateJiraExport(sessionDir) {
|
|
|
1568
2246
|
return rows.join("\n");
|
|
1569
2247
|
}
|
|
1570
2248
|
|
|
2249
|
+
// src/formatters/markdown-summary.ts
|
|
2250
|
+
var SEVERITY_LABEL = {
|
|
2251
|
+
critical: "Critical",
|
|
2252
|
+
high: "High",
|
|
2253
|
+
medium: "Medium",
|
|
2254
|
+
low: "Low"
|
|
2255
|
+
};
|
|
2256
|
+
async function generateMarkdownSummary(sessionDir) {
|
|
2257
|
+
const { session, report } = await loadSessionForOutput(sessionDir);
|
|
2258
|
+
const meta = extractReportMeta(report, session.id);
|
|
2259
|
+
const counts = { critical: 0, high: 0, medium: 0, low: 0 };
|
|
2260
|
+
for (const bug of session.bugs) counts[bug.severity]++;
|
|
2261
|
+
const lines = [];
|
|
2262
|
+
lines.push(CONFIDENTIALITY_HEADER_MD, "");
|
|
2263
|
+
lines.push(`# Session Summary \u2014 ${meta.target}`, "");
|
|
2264
|
+
lines.push("| Field | Value |", "|---|---|");
|
|
2265
|
+
lines.push(`| Session | ${session.id} |`);
|
|
2266
|
+
if (meta.date) lines.push(`| Date | ${meta.date} |`);
|
|
2267
|
+
if (meta.duration) lines.push(`| Duration | ${meta.duration} |`);
|
|
2268
|
+
lines.push(
|
|
2269
|
+
`| Bugs | ${session.bugs.length} (Critical ${counts.critical} \xB7 High ${counts.high} \xB7 Medium ${counts.medium} \xB7 Low ${counts.low}) |`,
|
|
2270
|
+
""
|
|
2271
|
+
);
|
|
2272
|
+
if (meta.summary) {
|
|
2273
|
+
lines.push("## Executive Summary", "", meta.summary, "");
|
|
2274
|
+
}
|
|
2275
|
+
if (session.bugs.length) {
|
|
2276
|
+
lines.push("## Bugs", "", "| ID | Severity | Component | Title |", "|---|---|---|---|");
|
|
2277
|
+
for (const bug of session.bugs) {
|
|
2278
|
+
lines.push(
|
|
2279
|
+
`| ${bug.id} | ${SEVERITY_LABEL[bug.severity]} | ${bug.component || "\u2014"} | ${bug.title} |`
|
|
2280
|
+
);
|
|
2281
|
+
}
|
|
2282
|
+
lines.push("");
|
|
2283
|
+
}
|
|
2284
|
+
const coverage = extractCoverage(report);
|
|
2285
|
+
if (coverage.length) {
|
|
2286
|
+
lines.push("## Coverage", "", "| Area | Risk | Status | Bugs | Notes |", "|---|---|---|---|---|");
|
|
2287
|
+
for (const c of coverage) {
|
|
2288
|
+
lines.push(`| ${c.area} | ${c.risk} | ${c.status} | ${c.bugsFound} | ${c.notes} |`);
|
|
2289
|
+
}
|
|
2290
|
+
lines.push("");
|
|
2291
|
+
}
|
|
2292
|
+
const recommendations = extractListSection(report, "Recommendations");
|
|
2293
|
+
if (recommendations.length) {
|
|
2294
|
+
lines.push("## Recommendations", "");
|
|
2295
|
+
for (const r of recommendations) lines.push(`- ${r}`);
|
|
2296
|
+
lines.push("");
|
|
2297
|
+
}
|
|
2298
|
+
return lines.join("\n");
|
|
2299
|
+
}
|
|
2300
|
+
|
|
2301
|
+
// src/schemas/session-metrics.schema.ts
|
|
2302
|
+
import { z as z7 } from "zod";
|
|
2303
|
+
var SeverityCountsSchema = z7.object({
|
|
2304
|
+
critical: z7.number().int().min(0),
|
|
2305
|
+
high: z7.number().int().min(0),
|
|
2306
|
+
medium: z7.number().int().min(0),
|
|
2307
|
+
low: z7.number().int().min(0)
|
|
2308
|
+
});
|
|
2309
|
+
var SessionMetricsSchema = z7.object({
|
|
2310
|
+
session_id: z7.string().min(1),
|
|
2311
|
+
target: z7.string().min(1),
|
|
2312
|
+
date: z7.string().min(1),
|
|
2313
|
+
duration_min: z7.number().min(0),
|
|
2314
|
+
bugs_found: z7.number().int().min(0),
|
|
2315
|
+
severity_counts: SeverityCountsSchema,
|
|
2316
|
+
pages_explored: z7.number().int().min(0),
|
|
2317
|
+
// Optional context.
|
|
2318
|
+
kind: z7.enum(["explore", "quick", "mobile", "backend"]).optional(),
|
|
2319
|
+
domain: z7.string().optional(),
|
|
2320
|
+
started_at: z7.string().optional(),
|
|
2321
|
+
completed_at: z7.string().optional(),
|
|
2322
|
+
phases_completed: z7.number().int().min(0).optional(),
|
|
2323
|
+
total_phases: z7.number().int().min(0).optional(),
|
|
2324
|
+
coverage: z7.record(z7.string(), z7.unknown()).optional(),
|
|
2325
|
+
evidence: z7.record(z7.string(), z7.unknown()).optional(),
|
|
2326
|
+
areas_not_tested: z7.array(z7.string()).optional(),
|
|
2327
|
+
blocked_by: z7.string().nullable().optional()
|
|
2328
|
+
});
|
|
2329
|
+
|
|
2330
|
+
// src/utils/metrics.ts
|
|
2331
|
+
import { readFileSync as readFileSync7, appendFileSync, existsSync as existsSync8, mkdirSync as mkdirSync2 } from "fs";
|
|
2332
|
+
import { join as join8, dirname as dirname3 } from "path";
|
|
2333
|
+
var METRICS_FILENAME = "metrics.jsonl";
|
|
2334
|
+
function appendSessionMetrics(outputDir, metrics) {
|
|
2335
|
+
SessionMetricsSchema.parse(metrics);
|
|
2336
|
+
const filePath = join8(outputDir, METRICS_FILENAME);
|
|
2337
|
+
const dir = dirname3(filePath);
|
|
2338
|
+
if (!existsSync8(dir)) {
|
|
2339
|
+
mkdirSync2(dir, { recursive: true });
|
|
2340
|
+
}
|
|
2341
|
+
const line = JSON.stringify(metrics) + "\n";
|
|
2342
|
+
appendFileSync(filePath, line, "utf-8");
|
|
2343
|
+
}
|
|
2344
|
+
function readAllMetrics(outputDir) {
|
|
2345
|
+
const filePath = join8(outputDir, METRICS_FILENAME);
|
|
2346
|
+
if (!existsSync8(filePath)) {
|
|
2347
|
+
return [];
|
|
2348
|
+
}
|
|
2349
|
+
const content = readFileSync7(filePath, "utf-8").trim();
|
|
2350
|
+
if (!content) {
|
|
2351
|
+
return [];
|
|
2352
|
+
}
|
|
2353
|
+
const lines = content.split("\n");
|
|
2354
|
+
const results = [];
|
|
2355
|
+
for (const line of lines) {
|
|
2356
|
+
if (!line.trim()) continue;
|
|
2357
|
+
let parsed;
|
|
2358
|
+
try {
|
|
2359
|
+
parsed = JSON.parse(line);
|
|
2360
|
+
} catch {
|
|
2361
|
+
continue;
|
|
2362
|
+
}
|
|
2363
|
+
const result = SessionMetricsSchema.safeParse(parsed);
|
|
2364
|
+
if (result.success) results.push(result.data);
|
|
2365
|
+
}
|
|
2366
|
+
return results;
|
|
2367
|
+
}
|
|
2368
|
+
function appendSessionMetricsDeduped(outputDir, metrics) {
|
|
2369
|
+
const existing = readAllMetrics(outputDir);
|
|
2370
|
+
if (existing.some((m) => m.session_id === metrics.session_id)) {
|
|
2371
|
+
return false;
|
|
2372
|
+
}
|
|
2373
|
+
appendSessionMetrics(outputDir, metrics);
|
|
2374
|
+
return true;
|
|
2375
|
+
}
|
|
2376
|
+
|
|
1571
2377
|
// src/cli/commands/report.ts
|
|
1572
2378
|
function reportCommand() {
|
|
1573
|
-
const cmd = new Command4("report").description("Generate a report from a session").option("-s, --session <id>", 'Session
|
|
2379
|
+
const cmd = new Command4("report").description("Generate a report (md summary, html, json or jira csv) from a session").option("-s, --session <id>", 'Session directory name, a unique substring, or "latest"', "latest").option("-f, --format <format>", "Output format: md, html, json, jira", "md").option("-o, --output <file>", "Write to this file instead of the session directory").option("--stdout", "Print to stdout instead of writing a file", false).action(async (options) => {
|
|
1574
2380
|
try {
|
|
1575
|
-
await runReport(options);
|
|
2381
|
+
await runReport(options, { cwd: process.cwd() });
|
|
1576
2382
|
} catch (err) {
|
|
1577
2383
|
console.error(chalk4.red("Error:"), err instanceof Error ? err.message : err);
|
|
1578
2384
|
process.exit(1);
|
|
@@ -1580,90 +2386,93 @@ function reportCommand() {
|
|
|
1580
2386
|
});
|
|
1581
2387
|
return cmd;
|
|
1582
2388
|
}
|
|
1583
|
-
|
|
1584
|
-
|
|
1585
|
-
|
|
1586
|
-
|
|
1587
|
-
|
|
1588
|
-
|
|
2389
|
+
var DEFAULT_FILENAMES = {
|
|
2390
|
+
md: "session-summary.md",
|
|
2391
|
+
html: "session-report.html",
|
|
2392
|
+
json: "session-report.json",
|
|
2393
|
+
jira: "jira-export.csv"
|
|
2394
|
+
};
|
|
2395
|
+
async function runReport(options, ctx) {
|
|
2396
|
+
const cwd = ctx.cwd;
|
|
2397
|
+
const log = ctx.log ?? ((line) => console.log(line));
|
|
2398
|
+
const sessionsDir = resolve6(cwd, "output", "sessions");
|
|
2399
|
+
if (!existsSync9(sessionsDir)) {
|
|
2400
|
+
throw new Error("No output/sessions directory found. Run `npx qualiow init` first.");
|
|
1589
2401
|
}
|
|
1590
2402
|
const sessionDir = resolveSessionDir(sessionsDir, options.session);
|
|
1591
|
-
|
|
1592
|
-
console.error(chalk4.red("No session found. Run an exploratory testing session first."));
|
|
1593
|
-
process.exit(1);
|
|
1594
|
-
}
|
|
1595
|
-
const sessionName = basename2(sessionDir);
|
|
1596
|
-
console.log(chalk4.cyan(`
|
|
1597
|
-
Session: ${sessionName}`));
|
|
2403
|
+
const sessionName = basename6(sessionDir);
|
|
1598
2404
|
const format = options.format.toLowerCase();
|
|
2405
|
+
let content;
|
|
1599
2406
|
switch (format) {
|
|
1600
|
-
case "md":
|
|
1601
|
-
|
|
1602
|
-
if (existsSync5(reportPath)) {
|
|
1603
|
-
console.log(chalk4.green(`
|
|
1604
|
-
Report: ${reportPath}`));
|
|
1605
|
-
} else {
|
|
1606
|
-
console.log(chalk4.yellow(" No session-report.md found in this session."));
|
|
1607
|
-
}
|
|
2407
|
+
case "md":
|
|
2408
|
+
content = await generateMarkdownSummary(sessionDir);
|
|
1608
2409
|
break;
|
|
1609
|
-
|
|
1610
|
-
|
|
1611
|
-
const html = await generateHtmlReport(sessionDir);
|
|
1612
|
-
const outputPath = join5(sessionDir, "session-report.html");
|
|
1613
|
-
writeFileSync2(outputPath, html);
|
|
1614
|
-
console.log(chalk4.green(`
|
|
1615
|
-
HTML report saved: ${outputPath}`));
|
|
2410
|
+
case "html":
|
|
2411
|
+
content = await generateHtmlReport(sessionDir);
|
|
1616
2412
|
break;
|
|
1617
|
-
|
|
1618
|
-
|
|
1619
|
-
const data = await generateJsonReport(sessionDir);
|
|
1620
|
-
const outputPath = join5(sessionDir, "session-report.json");
|
|
1621
|
-
writeFileSync2(outputPath, JSON.stringify(data, null, 2));
|
|
1622
|
-
console.log(chalk4.green(`
|
|
1623
|
-
JSON report saved: ${outputPath}`));
|
|
2413
|
+
case "json":
|
|
2414
|
+
content = JSON.stringify(await generateJsonReport(sessionDir), null, 2);
|
|
1624
2415
|
break;
|
|
1625
|
-
|
|
1626
|
-
|
|
1627
|
-
const csv = await generateJiraExport(sessionDir);
|
|
1628
|
-
const outputPath = join5(sessionDir, "jira-export.csv");
|
|
1629
|
-
writeFileSync2(outputPath, csv);
|
|
1630
|
-
console.log(chalk4.green(`
|
|
1631
|
-
Jira export saved: ${outputPath}`));
|
|
2416
|
+
case "jira":
|
|
2417
|
+
content = await generateJiraExport(sessionDir);
|
|
1632
2418
|
break;
|
|
1633
|
-
}
|
|
1634
2419
|
default:
|
|
1635
|
-
|
|
1636
|
-
process.exit(1);
|
|
2420
|
+
throw new Error(`Unknown format: "${format}". Choose from: md, html, json, jira`);
|
|
1637
2421
|
}
|
|
1638
|
-
|
|
2422
|
+
if (options.stdout) {
|
|
2423
|
+
process.stdout.write(content.endsWith("\n") ? content : content + "\n");
|
|
2424
|
+
return { content };
|
|
2425
|
+
}
|
|
2426
|
+
const outputPath = options.output ? resolve6(cwd, options.output) : join9(sessionDir, DEFAULT_FILENAMES[format]);
|
|
2427
|
+
writeFileSync3(outputPath, content);
|
|
2428
|
+
log(chalk4.cyan(`
|
|
2429
|
+
Session: ${sessionName}`));
|
|
2430
|
+
log(chalk4.green(` ${format.toUpperCase()} written: ${relative4(cwd, outputPath)}`));
|
|
2431
|
+
const statsPath = join9(sessionDir, "stats.json");
|
|
2432
|
+
if (existsSync9(statsPath)) {
|
|
2433
|
+
try {
|
|
2434
|
+
const stats = SessionMetricsSchema.parse(JSON.parse(readFileSync8(statsPath, "utf-8")));
|
|
2435
|
+
if (appendSessionMetricsDeduped(resolve6(cwd, "output"), stats)) {
|
|
2436
|
+
log(chalk4.green(" \u2713 Metrics appended to output/metrics.jsonl"));
|
|
2437
|
+
}
|
|
2438
|
+
} catch {
|
|
2439
|
+
log(chalk4.yellow(" \u26A0 stats.json present but not in the expected shape \u2014 metrics not recorded"));
|
|
2440
|
+
}
|
|
2441
|
+
}
|
|
2442
|
+
log("");
|
|
2443
|
+
return { outputPath, content };
|
|
1639
2444
|
}
|
|
1640
2445
|
function resolveSessionDir(sessionsDir, sessionId) {
|
|
2446
|
+
const dirs = readdirSync5(sessionsDir, { withFileTypes: true }).filter((d) => d.isDirectory()).map((d) => d.name).sort();
|
|
1641
2447
|
if (sessionId === "latest") {
|
|
1642
|
-
const
|
|
1643
|
-
|
|
1644
|
-
|
|
1645
|
-
|
|
1646
|
-
|
|
1647
|
-
if (
|
|
1648
|
-
|
|
1649
|
-
|
|
1650
|
-
|
|
1651
|
-
|
|
1652
|
-
|
|
2448
|
+
const canonical = dirs.filter((d) => SESSION_DIR_RE.test(d));
|
|
2449
|
+
const pool = canonical.length ? canonical : dirs;
|
|
2450
|
+
if (pool.length === 0) throw new Error("No sessions found. Run an exploratory testing session first.");
|
|
2451
|
+
return join9(sessionsDir, pool[pool.length - 1]);
|
|
2452
|
+
}
|
|
2453
|
+
if (dirs.includes(sessionId)) return join9(sessionsDir, sessionId);
|
|
2454
|
+
const matches = dirs.filter((d) => d.includes(sessionId));
|
|
2455
|
+
if (matches.length === 1) return join9(sessionsDir, matches[0]);
|
|
2456
|
+
if (matches.length > 1) {
|
|
2457
|
+
throw new Error(
|
|
2458
|
+
`"${sessionId}" matches ${matches.length} sessions \u2014 be more specific:
|
|
2459
|
+
${matches.join("\n ")}`
|
|
2460
|
+
);
|
|
1653
2461
|
}
|
|
1654
|
-
|
|
2462
|
+
throw new Error(`No session matches "${sessionId}". List them with: npx qualiow list sessions`);
|
|
1655
2463
|
}
|
|
1656
2464
|
|
|
1657
2465
|
// src/cli/commands/explore.ts
|
|
1658
2466
|
import { Command as Command5 } from "commander";
|
|
1659
|
-
import { resolve as
|
|
1660
|
-
import { existsSync as
|
|
1661
|
-
import { execSync } from "child_process";
|
|
2467
|
+
import { resolve as resolve7, join as join10, relative as relative5 } from "path";
|
|
2468
|
+
import { existsSync as existsSync10, mkdirSync as mkdirSync3, writeFileSync as writeFileSync4 } from "fs";
|
|
1662
2469
|
import chalk5 from "chalk";
|
|
1663
2470
|
function exploreCommand() {
|
|
1664
|
-
const cmd = new Command5("explore").description(
|
|
2471
|
+
const cmd = new Command5("explore").description(
|
|
2472
|
+
"Pre-flight for an exploratory session: validates inputs and creates the session directory. The session itself runs in Claude Code via /qa-explore."
|
|
2473
|
+
).argument("[url]", "Target URL to explore").option("-t, --target <name>", "Target configuration name (data/targets/<name>.yml)").option("-c, --context <file>", "Context file path").option("--time-box <duration>", "Time box, e.g. 45m (max 45m)", "45m").option("--dry-run", "Validate inputs and show what would happen", false).action(async (url, options) => {
|
|
1665
2474
|
try {
|
|
1666
|
-
await runExplore(url, options);
|
|
2475
|
+
await runExplore(url, options, { cwd: process.cwd() });
|
|
1667
2476
|
} catch (err) {
|
|
1668
2477
|
console.error(chalk5.red("Error:"), err instanceof Error ? err.message : err);
|
|
1669
2478
|
process.exit(1);
|
|
@@ -1671,86 +2480,85 @@ function exploreCommand() {
|
|
|
1671
2480
|
});
|
|
1672
2481
|
return cmd;
|
|
1673
2482
|
}
|
|
1674
|
-
|
|
1675
|
-
const
|
|
2483
|
+
function parseTimeBox(value) {
|
|
2484
|
+
const m = /^(\d+)m$/.exec(value.trim());
|
|
2485
|
+
if (!m) throw new Error(`Invalid --time-box "${value}": use minutes like 30m or 45m`);
|
|
2486
|
+
const minutes = parseInt(m[1], 10);
|
|
2487
|
+
if (minutes < 1 || minutes > 45) {
|
|
2488
|
+
throw new Error(`--time-box must be between 1m and 45m (got ${value})`);
|
|
2489
|
+
}
|
|
2490
|
+
return minutes;
|
|
2491
|
+
}
|
|
2492
|
+
async function runExplore(url, options, ctx) {
|
|
2493
|
+
const cwd = ctx.cwd;
|
|
2494
|
+
const now = ctx.now ?? /* @__PURE__ */ new Date();
|
|
2495
|
+
const log = ctx.log ?? ((line) => console.log(line));
|
|
1676
2496
|
if (url) {
|
|
1677
2497
|
try {
|
|
1678
2498
|
new URL(url);
|
|
1679
2499
|
} catch {
|
|
1680
|
-
|
|
1681
|
-
process.exit(1);
|
|
2500
|
+
throw new Error(`Invalid URL: "${url}". Provide a full URL such as https://example.com`);
|
|
1682
2501
|
}
|
|
1683
2502
|
}
|
|
1684
|
-
|
|
1685
|
-
|
|
1686
|
-
|
|
1687
|
-
|
|
1688
|
-
|
|
1689
|
-
|
|
2503
|
+
const minutes = parseTimeBox(options.timeBox);
|
|
2504
|
+
const targetPath = resolveTargetPath(cwd, options.target);
|
|
2505
|
+
let targetLabel = options.target ?? "adhoc";
|
|
2506
|
+
if (options.target || existsSync10(targetPath)) {
|
|
2507
|
+
if (!existsSync10(targetPath)) {
|
|
2508
|
+
throw new Error(
|
|
2509
|
+
`Target config not found: ${relative5(cwd, targetPath)}
|
|
2510
|
+
Available targets: npx qualiow list targets`
|
|
1690
2511
|
);
|
|
1691
|
-
console.error(chalk5.white(" Available targets: npx qualiow list targets"));
|
|
1692
|
-
process.exit(1);
|
|
1693
2512
|
}
|
|
1694
2513
|
const result = validateTargetConfig(targetPath);
|
|
1695
2514
|
if (!result.valid) {
|
|
1696
|
-
|
|
1697
|
-
|
|
1698
|
-
|
|
1699
|
-
}
|
|
1700
|
-
process.exit(1);
|
|
2515
|
+
const details = (result.errors ?? []).map((e) => ` \u2192 ${e.path ? `[${e.path}] ` : ""}${e.message}`).join("\n");
|
|
2516
|
+
throw new Error(`Target config ${relative5(cwd, targetPath)} is invalid:
|
|
2517
|
+
${details}`);
|
|
1701
2518
|
}
|
|
1702
|
-
|
|
1703
|
-
|
|
2519
|
+
if (!options.target) targetLabel = url ? slugify(url) : "adhoc";
|
|
2520
|
+
log(chalk5.green(` \u2713 Target config valid: ${relative5(cwd, targetPath)}`));
|
|
2521
|
+
} else if (url) {
|
|
2522
|
+
targetLabel = slugify(url);
|
|
1704
2523
|
}
|
|
1705
2524
|
if (options.context) {
|
|
1706
|
-
const contextPath =
|
|
1707
|
-
if (!
|
|
1708
|
-
|
|
1709
|
-
process.exit(1);
|
|
2525
|
+
const contextPath = resolve7(cwd, options.context);
|
|
2526
|
+
if (!existsSync10(contextPath)) {
|
|
2527
|
+
throw new Error(`Context file not found: ${contextPath}`);
|
|
1710
2528
|
}
|
|
1711
|
-
|
|
1712
|
-
}
|
|
1713
|
-
const
|
|
1714
|
-
const
|
|
1715
|
-
now.getFullYear(),
|
|
1716
|
-
String(now.getMonth() + 1).padStart(2, "0"),
|
|
1717
|
-
String(now.getDate()).padStart(2, "0"),
|
|
1718
|
-
"-",
|
|
1719
|
-
String(now.getHours()).padStart(2, "0"),
|
|
1720
|
-
String(now.getMinutes()).padStart(2, "0")
|
|
1721
|
-
].join("");
|
|
1722
|
-
const sessionName = `${timestamp}-${targetName}`;
|
|
1723
|
-
const sessionDir = resolve6(cwd, "output", "sessions", sessionName);
|
|
2529
|
+
log(chalk5.green(` \u2713 Context file found: ${options.context}`));
|
|
2530
|
+
}
|
|
2531
|
+
const sessionName = sessionDirName("explore", targetLabel, now);
|
|
2532
|
+
const sessionDir = resolve7(cwd, "output", "sessions", sessionName);
|
|
1724
2533
|
if (options.dryRun) {
|
|
1725
|
-
|
|
1726
|
-
|
|
1727
|
-
|
|
1728
|
-
|
|
1729
|
-
|
|
1730
|
-
|
|
1731
|
-
|
|
1732
|
-
|
|
1733
|
-
|
|
1734
|
-
|
|
1735
|
-
|
|
1736
|
-
console.log("");
|
|
1737
|
-
console.log(chalk5.green(" \u2713 All inputs valid"));
|
|
1738
|
-
return;
|
|
2534
|
+
log("");
|
|
2535
|
+
log(chalk5.cyan.bold("Dry run \u2014 no files created"));
|
|
2536
|
+
log(chalk5.white(` Session directory: ${relative5(cwd, sessionDir)}`));
|
|
2537
|
+
log(chalk5.white(` URL: ${url ?? "(none \u2014 /qa-explore will ask)"}`));
|
|
2538
|
+
log(chalk5.white(` Target: ${options.target ?? relative5(cwd, targetPath)}`));
|
|
2539
|
+
log(chalk5.white(` Context: ${options.context ?? "(none)"}`));
|
|
2540
|
+
log(chalk5.white(` Time box: ${minutes} min`));
|
|
2541
|
+
return { sessionDir };
|
|
2542
|
+
}
|
|
2543
|
+
for (const sub of ["", "screenshots", "bugs", "videos"]) {
|
|
2544
|
+
mkdirSync3(join10(sessionDir, sub), { recursive: true });
|
|
1739
2545
|
}
|
|
1740
|
-
|
|
1741
|
-
|
|
1742
|
-
|
|
1743
|
-
|
|
2546
|
+
const date = now.toISOString().slice(0, 10);
|
|
2547
|
+
writeFileSync4(
|
|
2548
|
+
join10(sessionDir, "charter.md"),
|
|
2549
|
+
`${CONFIDENTIALITY_HEADER_MD}
|
|
2550
|
+
|
|
2551
|
+
# Exploratory Testing Charter
|
|
1744
2552
|
|
|
1745
2553
|
**Session:** ${sessionName}
|
|
1746
|
-
**Date:** ${
|
|
1747
|
-
**Target:** ${options.target ??
|
|
2554
|
+
**Date:** ${date}
|
|
2555
|
+
**Target:** ${options.target ?? targetLabel}
|
|
1748
2556
|
**URL:** ${url ?? "TBD"}
|
|
1749
|
-
**Time Box:** ${
|
|
2557
|
+
**Time Box:** ${minutes} min
|
|
1750
2558
|
|
|
1751
2559
|
## Mission
|
|
1752
2560
|
|
|
1753
|
-
>
|
|
2561
|
+
> Filled in by /qa-explore phase 2.
|
|
1754
2562
|
|
|
1755
2563
|
## Areas of Focus
|
|
1756
2564
|
|
|
@@ -1759,131 +2567,75 @@ async function runExplore(url, options) {
|
|
|
1759
2567
|
## Risks & Concerns
|
|
1760
2568
|
|
|
1761
2569
|
-
|
|
2570
|
+
`
|
|
2571
|
+
);
|
|
2572
|
+
writeFileSync4(
|
|
2573
|
+
join10(sessionDir, "session-log.md"),
|
|
2574
|
+
`${CONFIDENTIALITY_HEADER_MD}
|
|
1762
2575
|
|
|
1763
|
-
|
|
2576
|
+
# Session Log \u2014 ${sessionName}
|
|
1764
2577
|
|
|
1765
|
-
-
|
|
1766
|
-
|
|
1767
|
-
|
|
1768
|
-
|
|
1769
|
-
|
|
1770
|
-
|
|
1771
|
-
|
|
1772
|
-
|
|
1773
|
-
|
|
1774
|
-
|
|
1775
|
-
|
|
1776
|
-
|
|
1777
|
-
console.log(chalk5.white(` Directory: ${sessionDir}`));
|
|
1778
|
-
console.log("");
|
|
1779
|
-
let claudeAvailable = false;
|
|
1780
|
-
try {
|
|
1781
|
-
execSync("which claude", { stdio: "pipe" });
|
|
1782
|
-
claudeAvailable = true;
|
|
1783
|
-
} catch {
|
|
1784
|
-
}
|
|
1785
|
-
if (claudeAvailable) {
|
|
1786
|
-
console.log(chalk5.cyan(" Claude Code detected! To start exploring:"));
|
|
1787
|
-
console.log("");
|
|
1788
|
-
console.log(chalk5.white(` /qa-explore ${url ?? "<url>"}`));
|
|
1789
|
-
} else {
|
|
1790
|
-
console.log(chalk5.cyan(" Next steps:"));
|
|
1791
|
-
console.log(chalk5.white(" 1. Install Claude Code (https://docs.anthropic.com/en/docs/claude-code)"));
|
|
1792
|
-
console.log(chalk5.white(` 2. Run: /qa-explore ${url ?? "<url>"}`));
|
|
1793
|
-
}
|
|
1794
|
-
console.log("");
|
|
1795
|
-
console.log(chalk5.gray(` Session directory: ${sessionDir}`));
|
|
1796
|
-
console.log("");
|
|
2578
|
+
[${now.toISOString()}] [PRE-FLIGHT] Session directory created by \`qualiow explore\`
|
|
2579
|
+
`
|
|
2580
|
+
);
|
|
2581
|
+
log("");
|
|
2582
|
+
log(chalk5.green.bold("Session skeleton created (pre-flight only \u2014 no browser was launched)."));
|
|
2583
|
+
log(chalk5.white(` Directory: ${relative5(cwd, sessionDir)}`));
|
|
2584
|
+
log("");
|
|
2585
|
+
log(chalk5.cyan(" Run the session in Claude Code:"));
|
|
2586
|
+
const args = [url ?? "<url>", options.target ? `--target ${options.target}` : "", options.context ? `--context ${options.context}` : ""].filter(Boolean).join(" ");
|
|
2587
|
+
log(chalk5.white(` /qa-explore ${args} --session output/sessions/${sessionName}`));
|
|
2588
|
+
log("");
|
|
2589
|
+
return { sessionDir };
|
|
1797
2590
|
}
|
|
1798
2591
|
|
|
1799
|
-
// src/cli/commands/
|
|
2592
|
+
// src/cli/commands/kb.ts
|
|
1800
2593
|
import { Command as Command6 } from "commander";
|
|
1801
|
-
import { resolve as
|
|
1802
|
-
import { existsSync as
|
|
1803
|
-
import { execSync as execSync2 } from "child_process";
|
|
2594
|
+
import { resolve as resolve8 } from "path";
|
|
2595
|
+
import { existsSync as existsSync11 } from "fs";
|
|
1804
2596
|
import chalk6 from "chalk";
|
|
1805
|
-
function
|
|
1806
|
-
const cmd = new Command6("
|
|
2597
|
+
function kbCommand() {
|
|
2598
|
+
const cmd = new Command6("kb").description("Knowledge-base maintenance");
|
|
2599
|
+
cmd.command("sync").description("Regenerate data/knowledge/manifest.yml entries and stats from the release files").action(() => {
|
|
1807
2600
|
try {
|
|
1808
|
-
|
|
2601
|
+
const result = runKb("sync", process.cwd());
|
|
2602
|
+
console.log(
|
|
2603
|
+
result.changed ? chalk6.green(` \u2713 manifest.yml updated (${result.entryCount} entries)`) : chalk6.cyan(` \u25CB manifest.yml already in sync (${result.entryCount} entries)`)
|
|
2604
|
+
);
|
|
1809
2605
|
} catch (err) {
|
|
1810
2606
|
console.error(chalk6.red("Error:"), err instanceof Error ? err.message : err);
|
|
1811
2607
|
process.exit(1);
|
|
1812
2608
|
}
|
|
1813
2609
|
});
|
|
1814
|
-
|
|
1815
|
-
|
|
1816
|
-
|
|
1817
|
-
|
|
1818
|
-
|
|
1819
|
-
|
|
1820
|
-
|
|
1821
|
-
|
|
1822
|
-
|
|
1823
|
-
|
|
1824
|
-
}
|
|
1825
|
-
if (isUrl) {
|
|
1826
|
-
console.log(chalk6.green(` \u2713 Source is a URL: ${source}`));
|
|
1827
|
-
} else {
|
|
1828
|
-
console.log(chalk6.green(` \u2713 Source file found: ${resolve7(cwd, source)}`));
|
|
1829
|
-
}
|
|
1830
|
-
if (options.domain) {
|
|
1831
|
-
const domainPath = resolve7(cwd, "data", "domains", `${options.domain}.yml`);
|
|
1832
|
-
if (!existsSync7(domainPath)) {
|
|
1833
|
-
console.error(chalk6.red(`Domain config not found: ${domainPath}`));
|
|
1834
|
-
console.error(chalk6.white(" Available domains: npx qualiow list domains"));
|
|
2610
|
+
cmd.command("check").description("Exit 1 if manifest.yml is out of sync with the release files").action(() => {
|
|
2611
|
+
try {
|
|
2612
|
+
const result = runKb("check", process.cwd());
|
|
2613
|
+
if (result.changed) {
|
|
2614
|
+
console.error(chalk6.red(" \u2717 manifest.yml is out of sync \u2014 run: npx qualiow kb sync"));
|
|
2615
|
+
process.exit(1);
|
|
2616
|
+
}
|
|
2617
|
+
console.log(chalk6.green(` \u2713 manifest.yml in sync (${result.entryCount} entries)`));
|
|
2618
|
+
} catch (err) {
|
|
2619
|
+
console.error(chalk6.red("Error:"), err instanceof Error ? err.message : err);
|
|
1835
2620
|
process.exit(1);
|
|
1836
2621
|
}
|
|
1837
|
-
|
|
1838
|
-
|
|
1839
|
-
const outputDir = resolve7(cwd, "output", "context");
|
|
1840
|
-
mkdirSync3(outputDir, { recursive: true });
|
|
1841
|
-
if (options.output) {
|
|
1842
|
-
console.log(chalk6.green(` \u2713 Output will be saved to: ${resolve7(cwd, options.output)}`));
|
|
1843
|
-
} else {
|
|
1844
|
-
console.log(chalk6.green(` \u2713 Output directory ready: ${outputDir}`));
|
|
1845
|
-
}
|
|
1846
|
-
let claudeAvailable = false;
|
|
1847
|
-
try {
|
|
1848
|
-
execSync2("which claude", { stdio: "pipe" });
|
|
1849
|
-
claudeAvailable = true;
|
|
1850
|
-
} catch {
|
|
1851
|
-
}
|
|
1852
|
-
console.log("");
|
|
1853
|
-
console.log(chalk6.cyan.bold("Ready to gather context!"));
|
|
1854
|
-
console.log("");
|
|
1855
|
-
if (claudeAvailable) {
|
|
1856
|
-
console.log(chalk6.cyan(" Claude Code detected! To gather context:"));
|
|
1857
|
-
console.log("");
|
|
1858
|
-
console.log(chalk6.white(` /qa-gather ${source}`));
|
|
1859
|
-
} else {
|
|
1860
|
-
console.log(chalk6.cyan(" Next steps:"));
|
|
1861
|
-
console.log(chalk6.white(" 1. Install Claude Code (https://docs.anthropic.com/en/docs/claude-code)"));
|
|
1862
|
-
console.log(chalk6.white(` 2. Run: /qa-gather ${source}`));
|
|
1863
|
-
}
|
|
1864
|
-
console.log("");
|
|
1865
|
-
console.log(chalk6.gray(" The /qa-gather skill will:"));
|
|
1866
|
-
console.log(chalk6.gray(" - Analyze the source for testable requirements"));
|
|
1867
|
-
console.log(chalk6.gray(" - Generate testing context and risk assessment"));
|
|
1868
|
-
console.log(chalk6.gray(" - Save output to output/context/"));
|
|
1869
|
-
console.log("");
|
|
2622
|
+
});
|
|
2623
|
+
return cmd;
|
|
1870
2624
|
}
|
|
1871
|
-
function
|
|
1872
|
-
|
|
1873
|
-
|
|
1874
|
-
|
|
1875
|
-
} catch {
|
|
1876
|
-
return false;
|
|
2625
|
+
function runKb(mode, cwd) {
|
|
2626
|
+
const dataDir = resolve8(cwd, "data");
|
|
2627
|
+
if (!existsSync11(resolve8(dataDir, "knowledge", "manifest.yml"))) {
|
|
2628
|
+
throw new Error("data/knowledge/manifest.yml not found. Run `npx qualiow init` first.");
|
|
1877
2629
|
}
|
|
2630
|
+
return syncKnowledgeManifest(dataDir, { check: mode === "check" });
|
|
1878
2631
|
}
|
|
1879
2632
|
|
|
1880
2633
|
// src/cli/index.ts
|
|
1881
|
-
var program = new Command7().name("qualiow").description("qualiow \u2014 AI-powered exploratory testing").version(
|
|
2634
|
+
var program = new Command7().name("qualiow").description("qualiow \u2014 AI-powered exploratory testing (web, mobile, backend)").version(getPackageVersion());
|
|
1882
2635
|
program.addCommand(initCommand());
|
|
1883
2636
|
program.addCommand(validateCommand());
|
|
1884
2637
|
program.addCommand(listCommand());
|
|
1885
2638
|
program.addCommand(reportCommand());
|
|
1886
2639
|
program.addCommand(exploreCommand());
|
|
1887
|
-
program.addCommand(
|
|
2640
|
+
program.addCommand(kbCommand());
|
|
1888
2641
|
program.parse();
|
|
1889
|
-
//# sourceMappingURL=index.js.map
|