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/index.js
CHANGED
|
@@ -17,42 +17,43 @@ var AuthConfigSchema = z.object({
|
|
|
17
17
|
credentials: z.object({
|
|
18
18
|
username: z.string(),
|
|
19
19
|
password: z.string()
|
|
20
|
-
}).optional(),
|
|
20
|
+
}).strict().optional(),
|
|
21
21
|
token: z.string().optional(),
|
|
22
22
|
identity_provider: z.string().optional(),
|
|
23
23
|
// Staging builds sometimes accept a fixed OTP — recorded so the auth phase can
|
|
24
24
|
// use it instead of waiting for a real code. Never a real credential.
|
|
25
25
|
static_otp: z.string().optional(),
|
|
26
|
-
test_email_pattern: z.string().optional()
|
|
27
|
-
|
|
26
|
+
test_email_pattern: z.string().optional(),
|
|
27
|
+
notes: z.string().optional()
|
|
28
|
+
}).strict();
|
|
28
29
|
var BrowserConfigSchema = z.object({
|
|
29
30
|
headless: z.boolean(),
|
|
30
31
|
viewport: z.object({
|
|
31
32
|
width: z.number().int().positive(),
|
|
32
33
|
height: z.number().int().positive()
|
|
33
|
-
}),
|
|
34
|
+
}).strict(),
|
|
34
35
|
// Optional engine selection + Playwright device descriptor for mobile-web
|
|
35
36
|
// emulation targets (e.g. engine: webkit, device: "iPhone 15").
|
|
36
37
|
engine: z.enum(["chromium", "webkit", "firefox"]).optional(),
|
|
37
38
|
channel: z.string().optional(),
|
|
38
39
|
device: z.string().optional()
|
|
39
|
-
});
|
|
40
|
+
}).strict();
|
|
40
41
|
var ScopeConfigSchema = z.object({
|
|
41
42
|
start_pages: z.array(z.string()).optional(),
|
|
42
43
|
max_depth: z.number().int().min(0),
|
|
43
44
|
include_patterns: z.array(z.string()).optional(),
|
|
44
45
|
exclude_patterns: z.array(z.string()).optional()
|
|
45
|
-
});
|
|
46
|
+
}).strict();
|
|
46
47
|
var SafetyConfigSchema = z.object({
|
|
47
48
|
read_only: z.boolean(),
|
|
48
49
|
no_form_submit: z.boolean(),
|
|
49
50
|
no_file_upload: z.boolean().optional(),
|
|
50
51
|
no_delete_actions: z.boolean().optional()
|
|
51
|
-
});
|
|
52
|
+
}).strict();
|
|
52
53
|
var EnvironmentConfigSchema = z.object({
|
|
53
54
|
kind: z.enum(["dev", "ephemeral", "staging", "production"]),
|
|
54
55
|
destroyed_automatically: z.boolean().optional()
|
|
55
|
-
});
|
|
56
|
+
}).strict();
|
|
56
57
|
var BackendConfigSchema = z.object({
|
|
57
58
|
provider: z.enum(["aws"]).optional(),
|
|
58
59
|
aws_profile_env: z.string().optional(),
|
|
@@ -65,13 +66,17 @@ var BackendConfigSchema = z.object({
|
|
|
65
66
|
// Free-form logical name -> deployed resource name (config_table, dlq, ...).
|
|
66
67
|
resources: z.record(z.string(), z.string()).optional(),
|
|
67
68
|
notes: z.string().optional()
|
|
68
|
-
});
|
|
69
|
+
}).strict();
|
|
69
70
|
var ApiSurfaceConfigSchema = z.object({
|
|
70
71
|
// Defaults to the target's base_url when omitted.
|
|
71
72
|
base_url: z.string().optional(),
|
|
72
|
-
auth: z.enum(["session-cookie", "bearer-env", "none"]).optional(),
|
|
73
|
-
// NAME of the env var holding
|
|
73
|
+
auth: z.enum(["session-cookie", "bearer-env", "api-key-env", "none"]).optional(),
|
|
74
|
+
// NAME of the env var holding the credential, for `auth: bearer-env` (a bearer
|
|
75
|
+
// token) or `auth: api-key-env` (a static API key sent in its own header).
|
|
74
76
|
token_env: z.string().optional(),
|
|
77
|
+
// Header carrying the credential for `auth: api-key-env`. Defaults to
|
|
78
|
+
// `X-Api-Key`. The VALUE always comes from `token_env`, never from here.
|
|
79
|
+
header_name: z.string().optional(),
|
|
75
80
|
// Persistent browser profile directory holding the authenticated session,
|
|
76
81
|
// e.g. `.auth/my-service-dev-profile`. Gitignored.
|
|
77
82
|
browser_profile: z.string().optional(),
|
|
@@ -81,19 +86,23 @@ var ApiSurfaceConfigSchema = z.object({
|
|
|
81
86
|
endpoints: z.record(z.string(), z.string()).optional(),
|
|
82
87
|
// The ONLY endpoints the read-only API lane may call without asking.
|
|
83
88
|
probe_allowlist: z.array(z.string()).optional(),
|
|
89
|
+
// The ONLY endpoints phase 4 may call through the real write path, and only in
|
|
90
|
+
// a dev or ephemeral environment. Empty or absent means the API lane is
|
|
91
|
+
// read-only here and every state-changing AC needs a different channel.
|
|
92
|
+
write_allowlist: z.array(z.string()).optional(),
|
|
84
93
|
// Other target ids to run the same matrix against, for parity comparison.
|
|
85
94
|
parity_targets: z.array(z.string()).optional(),
|
|
86
95
|
// Flag name -> where its deployed value is declared for this environment.
|
|
87
96
|
// A flag can select between two implementations inside one identical build.
|
|
88
97
|
feature_flags: z.record(z.string(), z.string()).optional(),
|
|
89
98
|
notes: z.string().optional()
|
|
90
|
-
});
|
|
99
|
+
}).strict();
|
|
91
100
|
var SourceBranchConfigSchema = z.object({
|
|
92
101
|
repo_path: z.string(),
|
|
93
102
|
branch: z.string(),
|
|
94
103
|
base_branch: z.string().optional(),
|
|
95
104
|
components: z.record(z.string(), z.string()).optional()
|
|
96
|
-
});
|
|
105
|
+
}).strict();
|
|
97
106
|
var WebTargetConfigSchema = z.object({
|
|
98
107
|
id: z.string().min(1),
|
|
99
108
|
name: z.string().min(1),
|
|
@@ -112,7 +121,7 @@ var WebTargetConfigSchema = z.object({
|
|
|
112
121
|
api: ApiSurfaceConfigSchema.optional(),
|
|
113
122
|
source: SourceBranchConfigSchema.optional(),
|
|
114
123
|
notes: z.string().optional()
|
|
115
|
-
});
|
|
124
|
+
}).strict();
|
|
116
125
|
var MobileDeviceConfigSchema = z.object({
|
|
117
126
|
name: z.string().optional(),
|
|
118
127
|
// iOS simulator name (portable across machines)
|
|
@@ -122,7 +131,7 @@ var MobileDeviceConfigSchema = z.object({
|
|
|
122
131
|
// Android AVD name
|
|
123
132
|
serial: z.string().optional()
|
|
124
133
|
// Android serial once booted (e.g. emulator-5554)
|
|
125
|
-
});
|
|
134
|
+
}).strict();
|
|
126
135
|
var MobileAppConfigSchema = z.object({
|
|
127
136
|
bundle_id: z.string().optional(),
|
|
128
137
|
// iOS bundle id (or browser bundle in web mode)
|
|
@@ -132,21 +141,21 @@ var MobileAppConfigSchema = z.object({
|
|
|
132
141
|
// iOS .app artifact(s) — native mode
|
|
133
142
|
apk_paths: z.array(z.string()).optional()
|
|
134
143
|
// Android APK(s) — native mode
|
|
135
|
-
});
|
|
144
|
+
}).strict();
|
|
136
145
|
var MobileWebConfigSchema = z.object({
|
|
137
146
|
base_url: z.string().url(),
|
|
138
147
|
start_url: z.string().url().optional()
|
|
139
|
-
});
|
|
148
|
+
}).strict();
|
|
140
149
|
var SourceRepoConfigSchema = z.object({
|
|
141
150
|
path: z.string(),
|
|
142
151
|
build_commands: z.record(z.string(), z.string()).optional()
|
|
143
|
-
});
|
|
152
|
+
}).strict();
|
|
144
153
|
var MobileScopeConfigSchema = z.object({
|
|
145
154
|
start_screen: z.string().optional(),
|
|
146
155
|
start_url: z.string().optional(),
|
|
147
156
|
include_patterns: z.array(z.string()).optional(),
|
|
148
157
|
exclude_patterns: z.array(z.string()).optional()
|
|
149
|
-
});
|
|
158
|
+
}).strict();
|
|
150
159
|
var MobileTargetConfigSchema = z.object({
|
|
151
160
|
id: z.string().min(1),
|
|
152
161
|
name: z.string().min(1),
|
|
@@ -162,15 +171,22 @@ var MobileTargetConfigSchema = z.object({
|
|
|
162
171
|
safety: SafetyConfigSchema.optional(),
|
|
163
172
|
source_repo: SourceRepoConfigSchema.optional(),
|
|
164
173
|
notes: z.string().optional()
|
|
165
|
-
});
|
|
166
|
-
var TargetConfigSchema = z.
|
|
167
|
-
|
|
174
|
+
}).strict();
|
|
175
|
+
var TargetConfigSchema = z.unknown().transform((data, ctx) => {
|
|
176
|
+
if (typeof data !== "object" || data === null || Array.isArray(data)) {
|
|
177
|
+
ctx.addIssue({ code: "custom", message: "Expected a target config object" });
|
|
178
|
+
return z.NEVER;
|
|
179
|
+
}
|
|
180
|
+
const isMobile = "platform" in data;
|
|
168
181
|
const branch = isMobile ? MobileTargetConfigSchema : WebTargetConfigSchema;
|
|
169
182
|
const result = branch.safeParse(data);
|
|
170
183
|
if (!result.success) {
|
|
171
|
-
for (const issue of result.error.issues)
|
|
184
|
+
for (const issue of result.error.issues) {
|
|
172
185
|
ctx.addIssue(issue);
|
|
186
|
+
}
|
|
187
|
+
return z.NEVER;
|
|
173
188
|
}
|
|
189
|
+
return result.data;
|
|
174
190
|
});
|
|
175
191
|
|
|
176
192
|
// src/schemas/knowledge-entry.schema.ts
|
|
@@ -228,22 +244,28 @@ var KnowledgeManifestSchema = z3.object({
|
|
|
228
244
|
|
|
229
245
|
// src/schemas/domain-config.schema.ts
|
|
230
246
|
import { z as z4 } from "zod";
|
|
247
|
+
var RiskRankingSchema = z4.object({
|
|
248
|
+
p0: z4.array(z4.string()).min(1),
|
|
249
|
+
p1: z4.array(z4.string()).min(1),
|
|
250
|
+
p2: z4.array(z4.string()).min(1),
|
|
251
|
+
p3: z4.array(z4.string()).min(1)
|
|
252
|
+
}).strict();
|
|
231
253
|
var JourneySchema = z4.object({
|
|
232
|
-
id: z4.string().min(1),
|
|
233
254
|
name: z4.string().min(1),
|
|
234
|
-
|
|
235
|
-
|
|
236
|
-
risk: z4.enum(["high", "medium", "low"])
|
|
237
|
-
});
|
|
255
|
+
steps: z4.array(z4.string()).min(1)
|
|
256
|
+
}).strict();
|
|
238
257
|
var DomainConfigSchema = z4.object({
|
|
239
258
|
id: z4.string().min(1),
|
|
240
259
|
name: z4.string().min(1),
|
|
241
|
-
risk_ranking:
|
|
260
|
+
risk_ranking: RiskRankingSchema,
|
|
242
261
|
completeness_checklist: z4.array(z4.string()).min(1),
|
|
243
262
|
data_integrity_checks: z4.array(z4.string()).min(1),
|
|
244
263
|
journeys: z4.array(JourneySchema).min(1),
|
|
245
|
-
|
|
246
|
-
|
|
264
|
+
must_test_patterns: z4.record(z4.string(), z4.array(z4.string())),
|
|
265
|
+
common_bugs: z4.array(z4.string()).min(1),
|
|
266
|
+
compliance: z4.array(z4.string()).min(1),
|
|
267
|
+
guidance: z4.string().min(1)
|
|
268
|
+
}).strict();
|
|
247
269
|
|
|
248
270
|
// src/schemas/session-metrics.schema.ts
|
|
249
271
|
import { z as z5 } from "zod";
|
|
@@ -260,35 +282,138 @@ var SessionMetricsSchema = z5.object({
|
|
|
260
282
|
duration_min: z5.number().min(0),
|
|
261
283
|
bugs_found: z5.number().int().min(0),
|
|
262
284
|
severity_counts: SeverityCountsSchema,
|
|
263
|
-
pages_explored: z5.number().int().min(0)
|
|
285
|
+
pages_explored: z5.number().int().min(0),
|
|
286
|
+
// Optional context.
|
|
287
|
+
kind: z5.enum(["explore", "quick", "mobile", "backend"]).optional(),
|
|
288
|
+
domain: z5.string().optional(),
|
|
289
|
+
started_at: z5.string().optional(),
|
|
290
|
+
completed_at: z5.string().optional(),
|
|
291
|
+
phases_completed: z5.number().int().min(0).optional(),
|
|
292
|
+
total_phases: z5.number().int().min(0).optional(),
|
|
293
|
+
coverage: z5.record(z5.string(), z5.unknown()).optional(),
|
|
294
|
+
evidence: z5.record(z5.string(), z5.unknown()).optional(),
|
|
295
|
+
areas_not_tested: z5.array(z5.string()).optional(),
|
|
296
|
+
blocked_by: z5.string().nullable().optional()
|
|
297
|
+
});
|
|
298
|
+
|
|
299
|
+
// src/schemas/knowledge-release.schema.ts
|
|
300
|
+
import { z as z6 } from "zod";
|
|
301
|
+
var KnowledgeReleaseSchema = z6.object({
|
|
302
|
+
version: z6.string().min(1),
|
|
303
|
+
date: z6.string().min(1),
|
|
304
|
+
author: z6.string().min(1),
|
|
305
|
+
status: z6.enum(["active", "deprecated"]),
|
|
306
|
+
notes: z6.string().min(1),
|
|
307
|
+
entry_count: z6.number().int().min(0),
|
|
308
|
+
entries: z6.array(z6.string().min(1)).min(1)
|
|
309
|
+
}).strict().refine((r) => r.entry_count === r.entries.length, {
|
|
310
|
+
message: "entry_count must equal the number of listed entries",
|
|
311
|
+
path: ["entry_count"]
|
|
264
312
|
});
|
|
265
313
|
|
|
314
|
+
// src/schemas/knowledge-changelog.schema.ts
|
|
315
|
+
import { z as z7 } from "zod";
|
|
316
|
+
var ChangelogEntrySchema = z7.object({
|
|
317
|
+
id: z7.string().min(1),
|
|
318
|
+
type: z7.enum(["heuristic", "technique", "checklist", "reference"]),
|
|
319
|
+
name: z7.string().min(1),
|
|
320
|
+
description: z7.string().min(1)
|
|
321
|
+
}).strict();
|
|
322
|
+
var ChangelogReleaseSchema = z7.object({
|
|
323
|
+
version: z7.string().min(1),
|
|
324
|
+
date: z7.string().min(1),
|
|
325
|
+
summary: z7.string().min(1),
|
|
326
|
+
entries_added: z7.array(ChangelogEntrySchema),
|
|
327
|
+
entries_modified: z7.array(z7.string()).default([]),
|
|
328
|
+
entries_removed: z7.array(z7.string()).default([]),
|
|
329
|
+
origin: z7.string().optional()
|
|
330
|
+
}).strict();
|
|
331
|
+
var KnowledgeChangelogSchema = z7.object({
|
|
332
|
+
releases: z7.array(ChangelogReleaseSchema).min(1)
|
|
333
|
+
}).strict();
|
|
334
|
+
|
|
266
335
|
// src/utils/redact.ts
|
|
267
|
-
var
|
|
336
|
+
var EMAIL_ALLOW = /(?:@|\.)(?:example\.(?:com|org|net)|localhost)$/i;
|
|
337
|
+
function luhnValid(digits) {
|
|
338
|
+
let sum = 0;
|
|
339
|
+
let alt = false;
|
|
340
|
+
for (let i = digits.length - 1; i >= 0; i--) {
|
|
341
|
+
let d = digits.charCodeAt(i) - 48;
|
|
342
|
+
if (d < 0 || d > 9) return false;
|
|
343
|
+
if (alt) {
|
|
344
|
+
d *= 2;
|
|
345
|
+
if (d > 9) d -= 9;
|
|
346
|
+
}
|
|
347
|
+
sum += d;
|
|
348
|
+
alt = !alt;
|
|
349
|
+
}
|
|
350
|
+
return sum % 10 === 0;
|
|
351
|
+
}
|
|
352
|
+
var RULES = [
|
|
353
|
+
{
|
|
354
|
+
name: "Private key",
|
|
355
|
+
pattern: /-----BEGIN (?:[A-Z0-9 ]+ )?PRIVATE KEY-----[\s\S]*?-----END (?:[A-Z0-9 ]+ )?PRIVATE KEY-----/g,
|
|
356
|
+
replacement: "[PRIVATE_KEY_REDACTED]"
|
|
357
|
+
},
|
|
358
|
+
{
|
|
359
|
+
name: "JWT",
|
|
360
|
+
pattern: /\beyJ[A-Za-z0-9_-]{8,}\.[A-Za-z0-9_-]{6,}\.[A-Za-z0-9_-]{6,}\b/g,
|
|
361
|
+
replacement: "[JWT_REDACTED]"
|
|
362
|
+
},
|
|
363
|
+
{
|
|
364
|
+
name: "Authorization header",
|
|
365
|
+
pattern: /(authorization)(\s*[:=]\s*)(\S[^\n\r]*)/gi,
|
|
366
|
+
replace: (m, k, sep, value) => /_REDACTED\]/.test(value) ? m : `${k}${sep}[REDACTED]`
|
|
367
|
+
},
|
|
368
|
+
{
|
|
369
|
+
name: "Cookie header",
|
|
370
|
+
pattern: /^(set-cookie|cookie)(\s*:\s*).+$/gim,
|
|
371
|
+
replace: (_m, k, sep) => `${k}${sep}[REDACTED]`
|
|
372
|
+
},
|
|
373
|
+
{
|
|
374
|
+
name: "AWS access key id",
|
|
375
|
+
pattern: /\b(?:AKIA|ASIA|AROA|AIDA)[0-9A-Z]{16}\b/g,
|
|
376
|
+
replacement: "[AWS_KEY_REDACTED]"
|
|
377
|
+
},
|
|
268
378
|
{
|
|
269
|
-
name: "
|
|
270
|
-
pattern: /
|
|
271
|
-
|
|
379
|
+
name: "AWS secret access key",
|
|
380
|
+
pattern: /(aws_secret_access_key)(\s*[:=]\s*)\S+/gi,
|
|
381
|
+
replace: (_m, k, sep) => `${k}${sep}[REDACTED]`
|
|
382
|
+
},
|
|
383
|
+
{
|
|
384
|
+
name: "OpenAI-style key",
|
|
385
|
+
pattern: /\bsk-(?:proj-)?[A-Za-z0-9_-]{20,}\b/g,
|
|
386
|
+
replacement: "[SK_KEY_REDACTED]"
|
|
387
|
+
},
|
|
388
|
+
{
|
|
389
|
+
name: "GitHub token",
|
|
390
|
+
pattern: /\b(?:gh[pousr]_[A-Za-z0-9]{20,}|github_pat_[A-Za-z0-9_]{20,})\b/g,
|
|
391
|
+
replacement: "[GITHUB_TOKEN_REDACTED]"
|
|
392
|
+
},
|
|
393
|
+
{
|
|
394
|
+
name: "Slack token",
|
|
395
|
+
pattern: /\bxox[abposr]-[A-Za-z0-9-]{10,}\b/g,
|
|
396
|
+
replacement: "[SLACK_TOKEN_REDACTED]"
|
|
272
397
|
},
|
|
273
398
|
{
|
|
274
399
|
name: "API key",
|
|
275
|
-
pattern: /api[_
|
|
276
|
-
|
|
400
|
+
pattern: /(x-api-key|api[_-]?key)(\s*[:=]\s*)["']?[A-Za-z0-9._-]{8,}["']?/gi,
|
|
401
|
+
replace: (_m, k, sep) => `${k}${sep}[REDACTED]`
|
|
277
402
|
},
|
|
278
403
|
{
|
|
279
404
|
name: "Password",
|
|
280
|
-
pattern: /password[
|
|
281
|
-
|
|
405
|
+
pattern: /(password|passwd|pwd)(\s*[:=]\s*)["']?[^\s,}"']+["']?/gi,
|
|
406
|
+
replace: (_m, k, sep) => `${k}${sep}[REDACTED]`
|
|
282
407
|
},
|
|
283
408
|
{
|
|
284
409
|
name: "Token",
|
|
285
|
-
pattern: /token[
|
|
286
|
-
|
|
410
|
+
pattern: /(access[_-]?token|refresh[_-]?token|token)(\s*[:=]\s*)["']?[A-Za-z0-9._-]{8,}["']?/gi,
|
|
411
|
+
replace: (_m, k, sep) => `${k}${sep}[REDACTED]`
|
|
287
412
|
},
|
|
288
413
|
{
|
|
289
414
|
name: "Secret",
|
|
290
|
-
pattern: /secret[
|
|
291
|
-
|
|
415
|
+
pattern: /([a-z_]*secret)(\s*[:=]\s*)["']?[^\s,}"']+["']?/gi,
|
|
416
|
+
replace: (_m, k, sep) => `${k}${sep}[REDACTED]`
|
|
292
417
|
},
|
|
293
418
|
{
|
|
294
419
|
name: "SSN",
|
|
@@ -297,44 +422,146 @@ var REDACTION_PATTERNS = [
|
|
|
297
422
|
},
|
|
298
423
|
{
|
|
299
424
|
name: "Credit card number",
|
|
300
|
-
pattern: /\b\d{
|
|
301
|
-
|
|
425
|
+
pattern: /\b\d(?:[ -]?\d){12,18}\b/g,
|
|
426
|
+
replace: (match) => {
|
|
427
|
+
const digits = match.replace(/\D/g, "");
|
|
428
|
+
if (digits.length < 13 || digits.length > 19) return match;
|
|
429
|
+
if (!/^[3-6]/.test(digits)) return match;
|
|
430
|
+
return luhnValid(digits) ? "[CARD_NUMBER_REDACTED]" : match;
|
|
431
|
+
}
|
|
302
432
|
}
|
|
303
433
|
];
|
|
304
|
-
function redact(text) {
|
|
305
|
-
const redactions =
|
|
434
|
+
function redact(text, opts = {}) {
|
|
435
|
+
const redactions = /* @__PURE__ */ new Set();
|
|
306
436
|
let result = text;
|
|
307
|
-
|
|
308
|
-
|
|
309
|
-
|
|
310
|
-
|
|
311
|
-
pattern.
|
|
312
|
-
|
|
313
|
-
}
|
|
437
|
+
const rules = RULES.slice();
|
|
438
|
+
if (opts.emails !== false) {
|
|
439
|
+
rules.push({
|
|
440
|
+
name: "Email",
|
|
441
|
+
pattern: /\b[A-Za-z0-9._%+-]+@[A-Za-z0-9.-]+\.[A-Za-z]{2,}\b/g,
|
|
442
|
+
replace: (match) => EMAIL_ALLOW.test(match) ? match : "[EMAIL_REDACTED]"
|
|
443
|
+
});
|
|
314
444
|
}
|
|
315
|
-
|
|
445
|
+
for (const rule of rules) {
|
|
446
|
+
rule.pattern.lastIndex = 0;
|
|
447
|
+
let fired = false;
|
|
448
|
+
result = result.replace(rule.pattern, (...args) => {
|
|
449
|
+
const match = args[0];
|
|
450
|
+
const groups = args.slice(1, -2);
|
|
451
|
+
const out = rule.replace ? rule.replace(match, ...groups) : rule.replacement;
|
|
452
|
+
if (out !== match) fired = true;
|
|
453
|
+
return out;
|
|
454
|
+
});
|
|
455
|
+
if (fired) redactions.add(rule.name);
|
|
456
|
+
}
|
|
457
|
+
return { text: result, redactions: [...redactions] };
|
|
316
458
|
}
|
|
317
459
|
function containsSecrets(text) {
|
|
318
|
-
|
|
319
|
-
pattern.lastIndex = 0;
|
|
320
|
-
if (pattern.test(text)) {
|
|
321
|
-
return true;
|
|
322
|
-
}
|
|
323
|
-
}
|
|
324
|
-
return false;
|
|
460
|
+
return redact(text).redactions.length > 0;
|
|
325
461
|
}
|
|
462
|
+
var REDACTION_CATEGORIES = RULES.map((r) => r.name).concat("Email");
|
|
326
463
|
|
|
327
464
|
// src/utils/validate.ts
|
|
328
|
-
import { readFileSync } from "fs";
|
|
329
|
-
import { resolve, join } from "path";
|
|
330
|
-
import { parse as
|
|
465
|
+
import { readFileSync as readFileSync2, existsSync as existsSync2 } from "fs";
|
|
466
|
+
import { resolve, join as join2, basename as basename2 } from "path";
|
|
467
|
+
import { parse as parseYaml2 } from "yaml";
|
|
331
468
|
import { ZodError } from "zod";
|
|
469
|
+
|
|
470
|
+
// src/utils/kb-sync.ts
|
|
471
|
+
import { readFileSync, writeFileSync, existsSync, readdirSync } from "fs";
|
|
472
|
+
import { join, relative, basename } from "path";
|
|
473
|
+
import { parse as parseYaml, parseDocument } from "yaml";
|
|
332
474
|
import { globSync } from "glob";
|
|
475
|
+
var TYPE_TO_STAT = {
|
|
476
|
+
heuristic: "heuristics",
|
|
477
|
+
technique: "techniques",
|
|
478
|
+
checklist: "checklists",
|
|
479
|
+
reference: "references"
|
|
480
|
+
};
|
|
481
|
+
function listReleaseDirs(knowledgeDir) {
|
|
482
|
+
const releasesDir = join(knowledgeDir, "releases");
|
|
483
|
+
if (!existsSync(releasesDir)) return [];
|
|
484
|
+
return readdirSync(releasesDir, { withFileTypes: true }).filter((d) => d.isDirectory() && /^v\d+\.\d+\.\d+$/.test(d.name)).map((d) => d.name).sort(compareVersions);
|
|
485
|
+
}
|
|
486
|
+
function compareVersions(a, b) {
|
|
487
|
+
const pa = a.replace(/^v/, "").split(".").map(Number);
|
|
488
|
+
const pb = b.replace(/^v/, "").split(".").map(Number);
|
|
489
|
+
for (let i = 0; i < 3; i++) {
|
|
490
|
+
if (pa[i] !== pb[i]) return pa[i] - pb[i];
|
|
491
|
+
}
|
|
492
|
+
return 0;
|
|
493
|
+
}
|
|
494
|
+
function buildManifestRegistry(dataDir) {
|
|
495
|
+
const knowledgeDir = join(dataDir, "knowledge");
|
|
496
|
+
const registry = [];
|
|
497
|
+
for (const rel of listReleaseDirs(knowledgeDir)) {
|
|
498
|
+
const files = globSync(join(knowledgeDir, "releases", rel, "entries", "*.yml")).sort();
|
|
499
|
+
for (const file of files) {
|
|
500
|
+
const entry = parseYaml(readFileSync(file, "utf-8"));
|
|
501
|
+
registry.push({
|
|
502
|
+
id: entry.id,
|
|
503
|
+
file: relative(knowledgeDir, file).split("\\").join("/"),
|
|
504
|
+
type: entry.type,
|
|
505
|
+
priority: entry.priority,
|
|
506
|
+
tags: entry.tags,
|
|
507
|
+
domains: entry.domains
|
|
508
|
+
});
|
|
509
|
+
}
|
|
510
|
+
}
|
|
511
|
+
return registry;
|
|
512
|
+
}
|
|
513
|
+
function computeStats(dataDir, registry) {
|
|
514
|
+
const stats = {
|
|
515
|
+
total_entries: registry.length,
|
|
516
|
+
heuristics: 0,
|
|
517
|
+
techniques: 0,
|
|
518
|
+
checklists: 0,
|
|
519
|
+
references: 0,
|
|
520
|
+
domain_profiles: 0,
|
|
521
|
+
custom_entries: 0
|
|
522
|
+
};
|
|
523
|
+
for (const e of registry) {
|
|
524
|
+
const key = TYPE_TO_STAT[e.type];
|
|
525
|
+
if (key) stats[key]++;
|
|
526
|
+
}
|
|
527
|
+
const domainsDir = join(dataDir, "domains");
|
|
528
|
+
if (existsSync(domainsDir)) {
|
|
529
|
+
stats.domain_profiles = readdirSync(domainsDir).filter(
|
|
530
|
+
(f) => f.endsWith(".yml")
|
|
531
|
+
).length;
|
|
532
|
+
}
|
|
533
|
+
const customDir = join(dataDir, "knowledge", "custom");
|
|
534
|
+
if (existsSync(customDir)) {
|
|
535
|
+
stats.custom_entries = readdirSync(customDir).filter(
|
|
536
|
+
(f) => f.endsWith(".yml")
|
|
537
|
+
).length;
|
|
538
|
+
}
|
|
539
|
+
return stats;
|
|
540
|
+
}
|
|
541
|
+
function syncKnowledgeManifest(dataDir, opts = {}) {
|
|
542
|
+
const manifestPath = join(dataDir, "knowledge", "manifest.yml");
|
|
543
|
+
const raw = readFileSync(manifestPath, "utf-8");
|
|
544
|
+
const doc = parseDocument(raw);
|
|
545
|
+
const registry = buildManifestRegistry(dataDir);
|
|
546
|
+
const stats = computeStats(dataDir, registry);
|
|
547
|
+
const current = parseYaml(raw);
|
|
548
|
+
const inSync = JSON.stringify(current.entries) === JSON.stringify(registry) && JSON.stringify(current.stats) === JSON.stringify(stats);
|
|
549
|
+
if (!opts.check && !inSync) {
|
|
550
|
+
doc.set("stats", stats);
|
|
551
|
+
doc.set("entries", registry);
|
|
552
|
+
doc.set("last_updated", (/* @__PURE__ */ new Date()).toISOString().slice(0, 10));
|
|
553
|
+
writeFileSync(manifestPath, doc.toString(), "utf-8");
|
|
554
|
+
}
|
|
555
|
+
return { changed: !inSync, stats, entryCount: registry.length };
|
|
556
|
+
}
|
|
557
|
+
|
|
558
|
+
// src/utils/validate.ts
|
|
559
|
+
import { globSync as globSync2 } from "glob";
|
|
333
560
|
function validateYamlFile(filePath, schema) {
|
|
334
561
|
const absPath = resolve(filePath);
|
|
335
562
|
try {
|
|
336
|
-
const raw =
|
|
337
|
-
const data =
|
|
563
|
+
const raw = readFileSync2(absPath, "utf-8");
|
|
564
|
+
const data = parseYaml2(raw);
|
|
338
565
|
schema.parse(data);
|
|
339
566
|
return { file: absPath, valid: true };
|
|
340
567
|
} catch (err) {
|
|
@@ -360,68 +587,433 @@ function validateYamlFile(filePath, schema) {
|
|
|
360
587
|
};
|
|
361
588
|
}
|
|
362
589
|
}
|
|
590
|
+
function validateWithId(filePath, schema) {
|
|
591
|
+
const result = validateYamlFile(filePath, schema);
|
|
592
|
+
if (!result.valid) return result;
|
|
593
|
+
try {
|
|
594
|
+
const data = parseYaml2(readFileSync2(filePath, "utf-8"));
|
|
595
|
+
const stem = basename2(filePath, ".yml");
|
|
596
|
+
if (data.id !== stem) {
|
|
597
|
+
return {
|
|
598
|
+
file: resolve(filePath),
|
|
599
|
+
valid: false,
|
|
600
|
+
errors: [
|
|
601
|
+
{
|
|
602
|
+
path: "id",
|
|
603
|
+
message: `id "${data.id}" must equal the file name "${stem}"`
|
|
604
|
+
}
|
|
605
|
+
]
|
|
606
|
+
};
|
|
607
|
+
}
|
|
608
|
+
} catch {
|
|
609
|
+
}
|
|
610
|
+
return result;
|
|
611
|
+
}
|
|
363
612
|
function validateTargetConfig(filePath) {
|
|
364
|
-
return
|
|
613
|
+
return validateWithId(filePath, TargetConfigSchema);
|
|
365
614
|
}
|
|
366
615
|
function validateKnowledgeEntry(filePath) {
|
|
367
616
|
return validateYamlFile(filePath, KnowledgeEntrySchema);
|
|
368
617
|
}
|
|
369
618
|
function validateDomainConfig(filePath) {
|
|
370
|
-
return
|
|
619
|
+
return validateWithId(filePath, DomainConfigSchema);
|
|
371
620
|
}
|
|
372
|
-
function
|
|
621
|
+
function validateKnowledgeBase(dataDir) {
|
|
622
|
+
const results = [];
|
|
623
|
+
const knowledgeDir = resolve(dataDir, "knowledge");
|
|
624
|
+
const manifestPath = join2(knowledgeDir, "manifest.yml");
|
|
625
|
+
const changelogPath = join2(knowledgeDir, "changelog.yml");
|
|
626
|
+
results.push(validateYamlFile(manifestPath, KnowledgeManifestSchema));
|
|
627
|
+
results.push(validateYamlFile(changelogPath, KnowledgeChangelogSchema));
|
|
628
|
+
const releaseDirs = listReleaseDirs(knowledgeDir);
|
|
629
|
+
for (const rel of releaseDirs) {
|
|
630
|
+
const releasePath = join2(knowledgeDir, "releases", rel, "release.yml");
|
|
631
|
+
const schemaResult = validateYamlFile(releasePath, KnowledgeReleaseSchema);
|
|
632
|
+
const errors = schemaResult.errors ?? [];
|
|
633
|
+
if (schemaResult.valid || errors.length === 0) {
|
|
634
|
+
try {
|
|
635
|
+
const release = parseYaml2(readFileSync2(releasePath, "utf-8"));
|
|
636
|
+
if (`v${release.version}` !== rel) {
|
|
637
|
+
errors.push({
|
|
638
|
+
path: "version",
|
|
639
|
+
message: `version "${release.version}" does not match directory "${rel}"`
|
|
640
|
+
});
|
|
641
|
+
}
|
|
642
|
+
const entryDir = join2(knowledgeDir, "releases", rel, "entries");
|
|
643
|
+
const filesOnDisk = existsSync2(entryDir) ? globSync2(join2(entryDir, "*.yml")).map((f) => basename2(f, ".yml")) : [];
|
|
644
|
+
for (const id of release.entries) {
|
|
645
|
+
if (!filesOnDisk.includes(id)) {
|
|
646
|
+
errors.push({ path: "entries", message: `declared entry "${id}" has no file` });
|
|
647
|
+
}
|
|
648
|
+
}
|
|
649
|
+
for (const id of filesOnDisk) {
|
|
650
|
+
if (!release.entries.includes(id)) {
|
|
651
|
+
errors.push({ path: "entries", message: `entry file "${id}" is not declared` });
|
|
652
|
+
}
|
|
653
|
+
}
|
|
654
|
+
} catch {
|
|
655
|
+
}
|
|
656
|
+
}
|
|
657
|
+
results.push(
|
|
658
|
+
errors.length ? { file: resolve(releasePath), valid: false, errors } : { file: resolve(releasePath), valid: true }
|
|
659
|
+
);
|
|
660
|
+
}
|
|
661
|
+
const crossErrors = [];
|
|
662
|
+
try {
|
|
663
|
+
const manifest = parseYaml2(readFileSync2(manifestPath, "utf-8"));
|
|
664
|
+
const registry = buildManifestRegistry(dataDir);
|
|
665
|
+
const stats = computeStats(dataDir, registry);
|
|
666
|
+
const registryIds = new Set(registry.map((e) => e.id));
|
|
667
|
+
if (JSON.stringify(manifest.entries) !== JSON.stringify(registry)) {
|
|
668
|
+
crossErrors.push({
|
|
669
|
+
path: "entries",
|
|
670
|
+
message: "registry is out of sync with the entry files (run `qualiow kb sync`)"
|
|
671
|
+
});
|
|
672
|
+
}
|
|
673
|
+
if (JSON.stringify(manifest.stats) !== JSON.stringify(stats)) {
|
|
674
|
+
crossErrors.push({
|
|
675
|
+
path: "stats",
|
|
676
|
+
message: `stats out of sync (expected total_entries ${stats.total_entries})`
|
|
677
|
+
});
|
|
678
|
+
}
|
|
679
|
+
const activeExpected = [...listReleaseDirs(knowledgeDir)].sort();
|
|
680
|
+
if (JSON.stringify([...manifest.active_releases].sort()) !== JSON.stringify(activeExpected)) {
|
|
681
|
+
crossErrors.push({ path: "active_releases", message: "does not match the release directories" });
|
|
682
|
+
}
|
|
683
|
+
const ls = manifest.loading_strategy;
|
|
684
|
+
const allRefs = [
|
|
685
|
+
...ls.always,
|
|
686
|
+
...Object.values(ls.by_domain).flat(),
|
|
687
|
+
...Object.values(ls.by_tag).flat()
|
|
688
|
+
];
|
|
689
|
+
for (const id of allRefs) {
|
|
690
|
+
if (!registryIds.has(id)) {
|
|
691
|
+
crossErrors.push({ path: "loading_strategy", message: `references unknown entry "${id}"` });
|
|
692
|
+
}
|
|
693
|
+
}
|
|
694
|
+
const changelog = parseYaml2(readFileSync2(changelogPath, "utf-8"));
|
|
695
|
+
for (const r of changelog.releases) {
|
|
696
|
+
for (const e of r.entries_added) {
|
|
697
|
+
if (!registryIds.has(e.id)) {
|
|
698
|
+
crossErrors.push({ path: "changelog", message: `entry "${e.id}" is not in the registry` });
|
|
699
|
+
}
|
|
700
|
+
}
|
|
701
|
+
}
|
|
702
|
+
} catch (err) {
|
|
703
|
+
crossErrors.push({
|
|
704
|
+
path: "",
|
|
705
|
+
message: err instanceof Error ? err.message : "cross-check failed"
|
|
706
|
+
});
|
|
707
|
+
}
|
|
708
|
+
results.push(
|
|
709
|
+
crossErrors.length ? { file: join2(knowledgeDir, "(cross-check)"), valid: false, errors: crossErrors } : { file: join2(knowledgeDir, "(cross-check)"), valid: true }
|
|
710
|
+
);
|
|
711
|
+
return results;
|
|
712
|
+
}
|
|
713
|
+
function validateAllConfigs(dataDir, opts = {}) {
|
|
373
714
|
const results = [];
|
|
374
715
|
const absDir = resolve(dataDir);
|
|
375
|
-
const
|
|
376
|
-
for (const file of targetFiles) {
|
|
716
|
+
for (const file of globSync2(join2(absDir, "targets", "*.yml"))) {
|
|
377
717
|
results.push(validateTargetConfig(file));
|
|
378
718
|
}
|
|
379
|
-
|
|
380
|
-
|
|
381
|
-
|
|
382
|
-
|
|
719
|
+
if (opts.cwd) {
|
|
720
|
+
const projectTarget = join2(opts.cwd, "qa", "target.yml");
|
|
721
|
+
if (existsSync2(projectTarget)) {
|
|
722
|
+
results.push(validateYamlFile(projectTarget, TargetConfigSchema));
|
|
723
|
+
}
|
|
724
|
+
}
|
|
725
|
+
for (const file of globSync2(join2(absDir, "domains", "*.yml"))) {
|
|
726
|
+
results.push(validateDomainConfig(file));
|
|
727
|
+
}
|
|
728
|
+
for (const file of globSync2(
|
|
729
|
+
join2(absDir, "knowledge", "releases", "**", "entries", "*.yml")
|
|
730
|
+
)) {
|
|
383
731
|
results.push(validateKnowledgeEntry(file));
|
|
384
732
|
}
|
|
733
|
+
if (existsSync2(join2(absDir, "knowledge", "manifest.yml"))) {
|
|
734
|
+
results.push(...validateKnowledgeBase(absDir));
|
|
735
|
+
}
|
|
385
736
|
return results;
|
|
386
737
|
}
|
|
387
738
|
|
|
388
739
|
// src/utils/metrics.ts
|
|
389
|
-
import { readFileSync as
|
|
390
|
-
import { join as
|
|
740
|
+
import { readFileSync as readFileSync3, appendFileSync, existsSync as existsSync3, mkdirSync } from "fs";
|
|
741
|
+
import { join as join3, dirname } from "path";
|
|
391
742
|
var METRICS_FILENAME = "metrics.jsonl";
|
|
392
743
|
function appendSessionMetrics(outputDir, metrics) {
|
|
393
744
|
SessionMetricsSchema.parse(metrics);
|
|
394
|
-
const filePath =
|
|
745
|
+
const filePath = join3(outputDir, METRICS_FILENAME);
|
|
395
746
|
const dir = dirname(filePath);
|
|
396
|
-
if (!
|
|
747
|
+
if (!existsSync3(dir)) {
|
|
397
748
|
mkdirSync(dir, { recursive: true });
|
|
398
749
|
}
|
|
399
750
|
const line = JSON.stringify(metrics) + "\n";
|
|
400
751
|
appendFileSync(filePath, line, "utf-8");
|
|
401
752
|
}
|
|
402
753
|
function readAllMetrics(outputDir) {
|
|
403
|
-
const filePath =
|
|
404
|
-
if (!
|
|
754
|
+
const filePath = join3(outputDir, METRICS_FILENAME);
|
|
755
|
+
if (!existsSync3(filePath)) {
|
|
405
756
|
return [];
|
|
406
757
|
}
|
|
407
|
-
const content =
|
|
758
|
+
const content = readFileSync3(filePath, "utf-8").trim();
|
|
408
759
|
if (!content) {
|
|
409
760
|
return [];
|
|
410
761
|
}
|
|
411
762
|
const lines = content.split("\n");
|
|
412
763
|
const results = [];
|
|
413
764
|
for (const line of lines) {
|
|
414
|
-
if (line.trim())
|
|
415
|
-
|
|
416
|
-
|
|
765
|
+
if (!line.trim()) continue;
|
|
766
|
+
let parsed;
|
|
767
|
+
try {
|
|
768
|
+
parsed = JSON.parse(line);
|
|
769
|
+
} catch {
|
|
770
|
+
continue;
|
|
417
771
|
}
|
|
772
|
+
const result = SessionMetricsSchema.safeParse(parsed);
|
|
773
|
+
if (result.success) results.push(result.data);
|
|
418
774
|
}
|
|
419
775
|
return results;
|
|
420
776
|
}
|
|
777
|
+
function appendSessionMetricsDeduped(outputDir, metrics) {
|
|
778
|
+
const existing = readAllMetrics(outputDir);
|
|
779
|
+
if (existing.some((m) => m.session_id === metrics.session_id)) {
|
|
780
|
+
return false;
|
|
781
|
+
}
|
|
782
|
+
appendSessionMetrics(outputDir, metrics);
|
|
783
|
+
return true;
|
|
784
|
+
}
|
|
785
|
+
|
|
786
|
+
// src/utils/session-dir.ts
|
|
787
|
+
var SESSION_KINDS = ["explore", "quick", "mobile", "backend"];
|
|
788
|
+
var SESSION_DIR_RE = /^(\d{4}-\d{2}-\d{2}-\d{4})-(explore|quick|mobile|backend)-([a-z0-9][a-z0-9-]*)$/;
|
|
789
|
+
function slugify(input) {
|
|
790
|
+
let s = (input ?? "").trim();
|
|
791
|
+
try {
|
|
792
|
+
if (/^[a-z][a-z0-9+.-]*:\/\//i.test(s)) {
|
|
793
|
+
s = new URL(s).hostname;
|
|
794
|
+
}
|
|
795
|
+
} catch {
|
|
796
|
+
}
|
|
797
|
+
s = s.toLowerCase().replace(/^_+/, "").replace(/[^a-z0-9]+/g, "-").replace(/^-+|-+$/g, "").slice(0, 40).replace(/-+$/g, "");
|
|
798
|
+
return s || "session";
|
|
799
|
+
}
|
|
800
|
+
function pad(n) {
|
|
801
|
+
return String(n).padStart(2, "0");
|
|
802
|
+
}
|
|
803
|
+
function sessionTimestamp(date = /* @__PURE__ */ new Date()) {
|
|
804
|
+
return `${date.getFullYear()}-${pad(date.getMonth() + 1)}-${pad(date.getDate())}-${pad(date.getHours())}${pad(date.getMinutes())}`;
|
|
805
|
+
}
|
|
806
|
+
function sessionDirName(kind, target, date = /* @__PURE__ */ new Date()) {
|
|
807
|
+
return `${sessionTimestamp(date)}-${kind}-${slugify(target)}`;
|
|
808
|
+
}
|
|
809
|
+
function parseSessionDirName(name) {
|
|
810
|
+
const m = SESSION_DIR_RE.exec(name);
|
|
811
|
+
if (!m) return null;
|
|
812
|
+
return { timestamp: m[1], kind: m[2], slug: m[3] };
|
|
813
|
+
}
|
|
814
|
+
|
|
815
|
+
// src/utils/markdown-table.ts
|
|
816
|
+
function splitRow(line) {
|
|
817
|
+
const cells = line.split("|").map((c) => c.trim());
|
|
818
|
+
if (cells.length && cells[0] === "") cells.shift();
|
|
819
|
+
if (cells.length && cells[cells.length - 1] === "") cells.pop();
|
|
820
|
+
return cells;
|
|
821
|
+
}
|
|
822
|
+
function isSeparator(line) {
|
|
823
|
+
return /^\s*\|?\s*:?-{2,}/.test(line) && /-\s*\|/.test(line + "|");
|
|
824
|
+
}
|
|
825
|
+
function parseMarkdownTable(md, opts = {}) {
|
|
826
|
+
const lines = md.split("\n");
|
|
827
|
+
let start = 0;
|
|
828
|
+
if (opts.headingPrefix) {
|
|
829
|
+
const prefix = opts.headingPrefix.toLowerCase();
|
|
830
|
+
let found = -1;
|
|
831
|
+
for (let i = 0; i < lines.length; i++) {
|
|
832
|
+
const h = lines[i].match(/^#{1,6}\s+(.*)$/);
|
|
833
|
+
if (h && h[1].trim().toLowerCase().startsWith(prefix)) {
|
|
834
|
+
found = i + 1;
|
|
835
|
+
break;
|
|
836
|
+
}
|
|
837
|
+
}
|
|
838
|
+
if (found === -1) return null;
|
|
839
|
+
start = found;
|
|
840
|
+
}
|
|
841
|
+
let headerIdx = -1;
|
|
842
|
+
for (let i = start; i < lines.length - 1; i++) {
|
|
843
|
+
const line = lines[i];
|
|
844
|
+
if (line.includes("|") && isSeparator(lines[i + 1])) {
|
|
845
|
+
headerIdx = i;
|
|
846
|
+
break;
|
|
847
|
+
}
|
|
848
|
+
if (opts.headingPrefix && /^#{1,6}\s/.test(line) && i > start) {
|
|
849
|
+
return null;
|
|
850
|
+
}
|
|
851
|
+
}
|
|
852
|
+
if (headerIdx === -1) return null;
|
|
853
|
+
const headers = splitRow(lines[headerIdx]);
|
|
854
|
+
const keys = headers.map((h) => h.toLowerCase());
|
|
855
|
+
const rows = [];
|
|
856
|
+
for (let i = headerIdx + 2; i < lines.length; i++) {
|
|
857
|
+
const line = lines[i];
|
|
858
|
+
if (!line.includes("|")) break;
|
|
859
|
+
if (isSeparator(line)) continue;
|
|
860
|
+
const cells = splitRow(line);
|
|
861
|
+
if (cells.every((c) => c === "")) continue;
|
|
862
|
+
const row = {};
|
|
863
|
+
keys.forEach((k, idx) => {
|
|
864
|
+
row[k] = cells[idx] ?? "";
|
|
865
|
+
});
|
|
866
|
+
rows.push(row);
|
|
867
|
+
}
|
|
868
|
+
return { headers, rows };
|
|
869
|
+
}
|
|
870
|
+
|
|
871
|
+
// src/utils/confidentiality.ts
|
|
872
|
+
var CONFIDENTIALITY_LINES = [
|
|
873
|
+
"CONFIDENTIAL: This report may contain internal URLs, security vulnerabilities,",
|
|
874
|
+
"and application details. Do not share outside your organization without review."
|
|
875
|
+
];
|
|
876
|
+
var CONFIDENTIALITY_HEADER_MD = CONFIDENTIALITY_LINES.map(
|
|
877
|
+
(l) => `> ${l}`
|
|
878
|
+
).join("\n");
|
|
879
|
+
var CONFIDENTIALITY_NOTICE = CONFIDENTIALITY_LINES.join(" ");
|
|
880
|
+
function hasConfidentialityHeader(text) {
|
|
881
|
+
return /CONFIDENTIAL:\s*This report may contain internal URLs/i.test(
|
|
882
|
+
text.slice(0, 400)
|
|
883
|
+
);
|
|
884
|
+
}
|
|
885
|
+
|
|
886
|
+
// src/utils/index-files.ts
|
|
887
|
+
var INDEX_COLUMNS = [
|
|
888
|
+
"Date",
|
|
889
|
+
"Kind",
|
|
890
|
+
"Target",
|
|
891
|
+
"Bugs",
|
|
892
|
+
"Duration",
|
|
893
|
+
"Status",
|
|
894
|
+
"Report"
|
|
895
|
+
];
|
|
896
|
+
var ALL_BUGS_COLUMNS = [
|
|
897
|
+
"ID",
|
|
898
|
+
"Session",
|
|
899
|
+
"Title",
|
|
900
|
+
"Severity",
|
|
901
|
+
"Status",
|
|
902
|
+
"Report"
|
|
903
|
+
];
|
|
904
|
+
function table(title, note, columns) {
|
|
905
|
+
const header = `| ${columns.join(" | ")} |`;
|
|
906
|
+
const sep = `|${columns.map(() => "---").join("|")}|`;
|
|
907
|
+
return `# ${title}
|
|
908
|
+
|
|
909
|
+
${note}
|
|
910
|
+
|
|
911
|
+
${header}
|
|
912
|
+
${sep}
|
|
913
|
+
`;
|
|
914
|
+
}
|
|
915
|
+
var INDEX_MD_HEADER = table(
|
|
916
|
+
"Exploratory Testing Sessions",
|
|
917
|
+
"_Index of exploratory testing sessions. Newest last._",
|
|
918
|
+
INDEX_COLUMNS
|
|
919
|
+
);
|
|
920
|
+
var ALL_BUGS_MD_HEADER = table(
|
|
921
|
+
"All Bugs Found",
|
|
922
|
+
"_Consolidated index across all exploratory testing sessions._",
|
|
923
|
+
ALL_BUGS_COLUMNS
|
|
924
|
+
);
|
|
925
|
+
|
|
926
|
+
// src/utils/gitignore.ts
|
|
927
|
+
var QUALIOW_GITIGNORE_HEADER = "# Qualiow";
|
|
928
|
+
var QUALIOW_GITIGNORE_ENTRIES = [
|
|
929
|
+
".auth/",
|
|
930
|
+
".env",
|
|
931
|
+
"qa/.env",
|
|
932
|
+
"output/sessions/*/",
|
|
933
|
+
"!output/sessions/INDEX.md",
|
|
934
|
+
"output/context/*.md",
|
|
935
|
+
"data/targets/local-*.yml",
|
|
936
|
+
".playwright-cli/",
|
|
937
|
+
"*.trace.zip",
|
|
938
|
+
"*.webm"
|
|
939
|
+
];
|
|
940
|
+
function mergeGitignore(existing) {
|
|
941
|
+
const existingLines = new Set(
|
|
942
|
+
existing.split("\n").map((l) => l.replace(/\s+$/, ""))
|
|
943
|
+
);
|
|
944
|
+
const missing = QUALIOW_GITIGNORE_ENTRIES.filter(
|
|
945
|
+
(e) => !existingLines.has(e)
|
|
946
|
+
);
|
|
947
|
+
if (missing.length === 0) return null;
|
|
948
|
+
const block = [];
|
|
949
|
+
if (!existingLines.has(QUALIOW_GITIGNORE_HEADER)) {
|
|
950
|
+
block.push(QUALIOW_GITIGNORE_HEADER);
|
|
951
|
+
}
|
|
952
|
+
block.push(...missing);
|
|
953
|
+
const prefix = existing.length === 0 || existing.endsWith("\n") ? "" : "\n";
|
|
954
|
+
const leadingBlank = existing.length > 0 ? "\n" : "";
|
|
955
|
+
return existing + prefix + leadingBlank + block.join("\n") + "\n";
|
|
956
|
+
}
|
|
957
|
+
|
|
958
|
+
// src/utils/paths.ts
|
|
959
|
+
import { fileURLToPath } from "url";
|
|
960
|
+
import { dirname as dirname2, resolve as resolve2, join as join4, basename as basename3 } from "path";
|
|
961
|
+
import { existsSync as existsSync4, readFileSync as readFileSync4 } from "fs";
|
|
962
|
+
var HERE = dirname2(fileURLToPath(import.meta.url));
|
|
963
|
+
function getPackageRoot() {
|
|
964
|
+
let current = HERE;
|
|
965
|
+
for (let i = 0; i < 10; i++) {
|
|
966
|
+
if (existsSync4(join4(current, "data")) && existsSync4(join4(current, "package.json"))) {
|
|
967
|
+
return current;
|
|
968
|
+
}
|
|
969
|
+
const parent = dirname2(current);
|
|
970
|
+
if (parent === current) break;
|
|
971
|
+
current = parent;
|
|
972
|
+
}
|
|
973
|
+
return resolve2(HERE, "..", "..");
|
|
974
|
+
}
|
|
975
|
+
function getPackageVersion(pkgRoot = getPackageRoot()) {
|
|
976
|
+
try {
|
|
977
|
+
const pkg = JSON.parse(
|
|
978
|
+
readFileSync4(join4(pkgRoot, "package.json"), "utf-8")
|
|
979
|
+
);
|
|
980
|
+
return pkg.version ?? "0.0.0";
|
|
981
|
+
} catch {
|
|
982
|
+
return "0.0.0";
|
|
983
|
+
}
|
|
984
|
+
}
|
|
985
|
+
function resolveSkillsSource(pkgRoot) {
|
|
986
|
+
const shipped = join4(pkgRoot, "skills");
|
|
987
|
+
if (existsSync4(shipped)) return shipped;
|
|
988
|
+
const canonical = join4(pkgRoot, ".claude", "skills");
|
|
989
|
+
if (existsSync4(canonical)) return canonical;
|
|
990
|
+
return null;
|
|
991
|
+
}
|
|
992
|
+
function resolveTargetPath(cwd, name, pkgRoot = getPackageRoot()) {
|
|
993
|
+
if (name) {
|
|
994
|
+
const candidates = [
|
|
995
|
+
resolve2(cwd, "data", "targets", `${name}.yml`),
|
|
996
|
+
resolve2(pkgRoot, "data", "targets", `${name}.yml`)
|
|
997
|
+
];
|
|
998
|
+
return candidates.find((p) => existsSync4(p)) ?? candidates[0];
|
|
999
|
+
}
|
|
1000
|
+
const projectLocal = resolve2(cwd, "qa", "target.yml");
|
|
1001
|
+
if (existsSync4(projectLocal)) return projectLocal;
|
|
1002
|
+
const cwdDefault = resolve2(cwd, "data", "targets", "_default.yml");
|
|
1003
|
+
if (existsSync4(cwdDefault)) return cwdDefault;
|
|
1004
|
+
return resolve2(pkgRoot, "data", "targets", "_default.yml");
|
|
1005
|
+
}
|
|
1006
|
+
function resolveDomainPath(dataDir, id) {
|
|
1007
|
+
const direct = join4(dataDir, "domains", `${id}.yml`);
|
|
1008
|
+
if (existsSync4(direct)) return direct;
|
|
1009
|
+
const underscored = join4(dataDir, "domains", `_${id}.yml`);
|
|
1010
|
+
if (existsSync4(underscored)) return underscored;
|
|
1011
|
+
return direct;
|
|
1012
|
+
}
|
|
421
1013
|
|
|
422
1014
|
// src/utils/parse-session.ts
|
|
423
|
-
import { readFileSync as
|
|
424
|
-
import { join as
|
|
1015
|
+
import { readFileSync as readFileSync5, readdirSync as readdirSync2, existsSync as existsSync5 } from "fs";
|
|
1016
|
+
import { join as join5, basename as basename4 } from "path";
|
|
425
1017
|
var SEVERITY_ORDER = {
|
|
426
1018
|
critical: 0,
|
|
427
1019
|
high: 1,
|
|
@@ -475,33 +1067,48 @@ function extractNumberedList(text) {
|
|
|
475
1067
|
}
|
|
476
1068
|
return steps;
|
|
477
1069
|
}
|
|
1070
|
+
function cleanValue(v) {
|
|
1071
|
+
return v.trim().replace(/^`|`$/g, "").trim();
|
|
1072
|
+
}
|
|
478
1073
|
function extractEvidence(content) {
|
|
479
|
-
const
|
|
480
|
-
|
|
1074
|
+
const evidence = {
|
|
1075
|
+
screenshots: [],
|
|
1076
|
+
videos: [],
|
|
1077
|
+
logs: [],
|
|
1078
|
+
console_errors: [],
|
|
1079
|
+
network_failures: []
|
|
1080
|
+
};
|
|
481
1081
|
const evidenceText = extractSection(content, "Evidence");
|
|
482
|
-
if (!evidenceText)
|
|
483
|
-
return { screenshots, console_errors };
|
|
484
|
-
}
|
|
1082
|
+
if (!evidenceText) return evidence;
|
|
485
1083
|
for (const line of evidenceText.split("\n")) {
|
|
486
1084
|
const trimmed = line.replace(/^[-*]\s*/, "").trim();
|
|
487
|
-
|
|
488
|
-
const
|
|
489
|
-
|
|
490
|
-
|
|
491
|
-
|
|
492
|
-
|
|
493
|
-
|
|
494
|
-
|
|
495
|
-
|
|
496
|
-
|
|
497
|
-
|
|
1085
|
+
const value = () => {
|
|
1086
|
+
const m = trimmed.match(/:\s*(.+)/);
|
|
1087
|
+
return m ? cleanValue(m[1]) : "";
|
|
1088
|
+
};
|
|
1089
|
+
const nonEmpty = (v) => v && !/^none\b/i.test(v);
|
|
1090
|
+
if (/^screenshot/i.test(trimmed)) {
|
|
1091
|
+
const v = value();
|
|
1092
|
+
if (nonEmpty(v)) evidence.screenshots.push(v);
|
|
1093
|
+
} else if (/^video/i.test(trimmed)) {
|
|
1094
|
+
const v = value();
|
|
1095
|
+
if (nonEmpty(v)) evidence.videos.push(v);
|
|
1096
|
+
} else if (/^log\b/i.test(trimmed)) {
|
|
1097
|
+
const v = value();
|
|
1098
|
+
if (nonEmpty(v)) evidence.logs.push(v);
|
|
1099
|
+
} else if (/console\s*(error|log)/i.test(trimmed)) {
|
|
1100
|
+
const v = value();
|
|
1101
|
+
if (nonEmpty(v)) evidence.console_errors.push(v);
|
|
1102
|
+
} else if (/network\s*(failure|error|request)/i.test(trimmed)) {
|
|
1103
|
+
const v = value();
|
|
1104
|
+
if (nonEmpty(v)) evidence.network_failures.push(v);
|
|
498
1105
|
}
|
|
499
1106
|
}
|
|
500
|
-
return
|
|
1107
|
+
return evidence;
|
|
501
1108
|
}
|
|
502
1109
|
async function parseBugReport(filePath) {
|
|
503
|
-
const content =
|
|
504
|
-
const filename =
|
|
1110
|
+
const content = readFileSync5(filePath, "utf-8");
|
|
1111
|
+
const filename = basename4(filePath, ".md");
|
|
505
1112
|
const id = filename;
|
|
506
1113
|
let title = "";
|
|
507
1114
|
let component = "";
|
|
@@ -514,6 +1121,10 @@ async function parseBugReport(filePath) {
|
|
|
514
1121
|
component = componentMatch[1];
|
|
515
1122
|
title = title.replace(/^\[[^\]]+\]\s*/, "").trim();
|
|
516
1123
|
}
|
|
1124
|
+
const componentField = content.match(/\*\*Component:\*\*\s*(.+)/i);
|
|
1125
|
+
if (componentField) {
|
|
1126
|
+
component = cleanValue(componentField[1]);
|
|
1127
|
+
}
|
|
517
1128
|
if (!component) {
|
|
518
1129
|
const categoryMatch = content.match(/\|\s*Category\s*\|\s*(.+?)\s*\|/i);
|
|
519
1130
|
if (categoryMatch) {
|
|
@@ -528,8 +1139,14 @@ async function parseBugReport(filePath) {
|
|
|
528
1139
|
let url = "";
|
|
529
1140
|
const urlMatch = content.match(/\*\*URL:\*\*\s*(.+)/i) ?? content.match(/URL:\s*(https?:\/\/[^\s]+)/i);
|
|
530
1141
|
if (urlMatch) {
|
|
531
|
-
url = urlMatch[1]
|
|
1142
|
+
url = cleanValue(urlMatch[1]);
|
|
532
1143
|
}
|
|
1144
|
+
const priority = cleanValue(content.match(/\*\*Priority:\*\*\s*(.+)/i)?.[1] ?? "");
|
|
1145
|
+
const environment = cleanValue(content.match(/\*\*Environment:\*\*\s*(.+)/i)?.[1] ?? "");
|
|
1146
|
+
const reproduction_rate = cleanValue(
|
|
1147
|
+
content.match(/\*\*Reproduction rate:\*\*\s*(.+)/i)?.[1] ?? ""
|
|
1148
|
+
);
|
|
1149
|
+
const summary = extractSection(content, "Summary").replace(/^>\s*/gm, "").trim();
|
|
533
1150
|
const expected = extractSection(content, "Expected").replace(/^_.*_\n?/, "").replace(/^>\s*/gm, "").trim();
|
|
534
1151
|
const actual = extractSection(content, "Actual").replace(/^_.*_\n?/, "").replace(/^>\s*/gm, "").trim();
|
|
535
1152
|
const stepsSection = extractSection(content, "Steps to Reproduce");
|
|
@@ -540,8 +1157,12 @@ async function parseBugReport(filePath) {
|
|
|
540
1157
|
id,
|
|
541
1158
|
title,
|
|
542
1159
|
severity,
|
|
1160
|
+
priority,
|
|
543
1161
|
component,
|
|
544
1162
|
url,
|
|
1163
|
+
environment,
|
|
1164
|
+
reproduction_rate,
|
|
1165
|
+
summary,
|
|
545
1166
|
expected,
|
|
546
1167
|
actual,
|
|
547
1168
|
steps,
|
|
@@ -550,33 +1171,33 @@ async function parseBugReport(filePath) {
|
|
|
550
1171
|
};
|
|
551
1172
|
}
|
|
552
1173
|
async function parseSession(sessionDir) {
|
|
553
|
-
const id =
|
|
1174
|
+
const id = basename4(sessionDir);
|
|
554
1175
|
let charter;
|
|
555
|
-
const charterPath =
|
|
556
|
-
if (
|
|
557
|
-
charter =
|
|
1176
|
+
const charterPath = join5(sessionDir, "charter.md");
|
|
1177
|
+
if (existsSync5(charterPath)) {
|
|
1178
|
+
charter = readFileSync5(charterPath, "utf-8");
|
|
558
1179
|
}
|
|
559
1180
|
let report;
|
|
560
|
-
const reportPath =
|
|
561
|
-
if (
|
|
562
|
-
report =
|
|
1181
|
+
const reportPath = join5(sessionDir, "session-report.md");
|
|
1182
|
+
if (existsSync5(reportPath)) {
|
|
1183
|
+
report = readFileSync5(reportPath, "utf-8");
|
|
563
1184
|
}
|
|
564
1185
|
const phases = [];
|
|
565
|
-
if (
|
|
566
|
-
const files =
|
|
1186
|
+
if (existsSync5(sessionDir)) {
|
|
1187
|
+
const files = readdirSync2(sessionDir);
|
|
567
1188
|
const phaseFiles = files.filter((f) => /^phase-\d+/i.test(f)).sort();
|
|
568
1189
|
for (const file of phaseFiles) {
|
|
569
|
-
const content =
|
|
1190
|
+
const content = readFileSync5(join5(sessionDir, file), "utf-8");
|
|
570
1191
|
const name = file.replace(/\.md$/, "");
|
|
571
1192
|
phases.push({ name, content });
|
|
572
1193
|
}
|
|
573
1194
|
}
|
|
574
|
-
const bugsDir =
|
|
1195
|
+
const bugsDir = join5(sessionDir, "bugs");
|
|
575
1196
|
const bugs = [];
|
|
576
|
-
if (
|
|
577
|
-
const bugFiles =
|
|
1197
|
+
if (existsSync5(bugsDir)) {
|
|
1198
|
+
const bugFiles = readdirSync2(bugsDir).filter((f) => /^BUG-.*\.md$/i.test(f)).sort();
|
|
578
1199
|
for (const file of bugFiles) {
|
|
579
|
-
const bug = await parseBugReport(
|
|
1200
|
+
const bug = await parseBugReport(join5(bugsDir, file));
|
|
580
1201
|
bugs.push(bug);
|
|
581
1202
|
}
|
|
582
1203
|
}
|
|
@@ -592,6 +1213,39 @@ async function parseSession(sessionDir) {
|
|
|
592
1213
|
|
|
593
1214
|
// src/formatters/html-report.ts
|
|
594
1215
|
import Handlebars from "handlebars";
|
|
1216
|
+
|
|
1217
|
+
// src/formatters/common.ts
|
|
1218
|
+
function redactString(s) {
|
|
1219
|
+
return s ? redact(s).text : s;
|
|
1220
|
+
}
|
|
1221
|
+
function redactBug(bug) {
|
|
1222
|
+
return {
|
|
1223
|
+
...bug,
|
|
1224
|
+
title: redactString(bug.title),
|
|
1225
|
+
url: redactString(bug.url),
|
|
1226
|
+
environment: redactString(bug.environment),
|
|
1227
|
+
summary: redactString(bug.summary),
|
|
1228
|
+
expected: redactString(bug.expected),
|
|
1229
|
+
actual: redactString(bug.actual),
|
|
1230
|
+
steps: bug.steps.map(redactString),
|
|
1231
|
+
business_impact: redactString(bug.business_impact),
|
|
1232
|
+
evidence: {
|
|
1233
|
+
screenshots: bug.evidence.screenshots.map(redactString),
|
|
1234
|
+
videos: bug.evidence.videos.map(redactString),
|
|
1235
|
+
logs: bug.evidence.logs.map(redactString),
|
|
1236
|
+
console_errors: bug.evidence.console_errors.map(redactString),
|
|
1237
|
+
network_failures: bug.evidence.network_failures.map(redactString)
|
|
1238
|
+
}
|
|
1239
|
+
};
|
|
1240
|
+
}
|
|
1241
|
+
async function loadSessionForOutput(sessionDir) {
|
|
1242
|
+
const session = await parseSession(sessionDir);
|
|
1243
|
+
const report = session.report ? redact(session.report).text : "";
|
|
1244
|
+
return {
|
|
1245
|
+
session: { ...session, bugs: session.bugs.map(redactBug), report },
|
|
1246
|
+
report
|
|
1247
|
+
};
|
|
1248
|
+
}
|
|
595
1249
|
function extractReportMeta(report, sessionId) {
|
|
596
1250
|
const meta = {
|
|
597
1251
|
target: sessionId,
|
|
@@ -606,40 +1260,34 @@ function extractReportMeta(report, sessionId) {
|
|
|
606
1260
|
if (durationMatch) meta.duration = durationMatch[1].trim();
|
|
607
1261
|
const targetMatch = report.match(/\*\*Application:\*\*\s*(.+)/i) ?? report.match(/\*\*Target:\*\*\s*(.+)/i) ?? report.match(/\|\s*Target\s*\|\s*(.+?)\s*\|/i);
|
|
608
1262
|
if (targetMatch) meta.target = targetMatch[1].trim();
|
|
609
|
-
const summaryMatch = report.match(
|
|
1263
|
+
const summaryMatch = report.match(
|
|
1264
|
+
/##\s+Executive Summary\s*\n+([\s\S]*?)(?=\n##\s|\n---|$)/i
|
|
1265
|
+
);
|
|
610
1266
|
if (summaryMatch) meta.summary = summaryMatch[1].trim();
|
|
611
1267
|
return meta;
|
|
612
1268
|
}
|
|
613
1269
|
function extractCoverage(report) {
|
|
614
|
-
const
|
|
615
|
-
|
|
616
|
-
|
|
617
|
-
|
|
618
|
-
|
|
619
|
-
|
|
620
|
-
|
|
621
|
-
|
|
622
|
-
|
|
623
|
-
entries.push({
|
|
624
|
-
area: cells[0] || "",
|
|
625
|
-
status: cells[1] || "",
|
|
626
|
-
bugsFound: cells[3] || "0",
|
|
627
|
-
notes: cells[4] || ""
|
|
628
|
-
});
|
|
629
|
-
}
|
|
630
|
-
}
|
|
631
|
-
return entries;
|
|
1270
|
+
const table2 = parseMarkdownTable(report, { headingPrefix: "Coverage" });
|
|
1271
|
+
if (!table2) return [];
|
|
1272
|
+
return table2.rows.map((row) => ({
|
|
1273
|
+
area: row["area"] ?? "",
|
|
1274
|
+
risk: row["risk"] ?? "",
|
|
1275
|
+
status: row["status"] ?? row["tested?"] ?? row["tested"] ?? "",
|
|
1276
|
+
bugsFound: row["bugs"] ?? row["bugs found"] ?? row["findings"] ?? "0",
|
|
1277
|
+
notes: row["notes"] ?? ""
|
|
1278
|
+
}));
|
|
632
1279
|
}
|
|
633
1280
|
function extractListSection(report, heading) {
|
|
634
1281
|
const items = [];
|
|
635
|
-
const regex = new RegExp(
|
|
1282
|
+
const regex = new RegExp(
|
|
1283
|
+
`##\\s+${heading}\\s*\\n+([\\s\\S]*?)(?=\\n##\\s|\\n---|$)`,
|
|
1284
|
+
"i"
|
|
1285
|
+
);
|
|
636
1286
|
const match = report.match(regex);
|
|
637
1287
|
if (!match) return items;
|
|
638
1288
|
for (const line of match[1].split("\n")) {
|
|
639
1289
|
const itemMatch = line.match(/^[-*]\s+(?:\[.\]\s+)?(.+)/);
|
|
640
|
-
if (itemMatch)
|
|
641
|
-
items.push(itemMatch[1].trim());
|
|
642
|
-
}
|
|
1290
|
+
if (itemMatch) items.push(itemMatch[1].trim());
|
|
643
1291
|
const numberedMatch = line.match(/^\d+\.\s+\*\*(.+?)\*\*\s*(.+)?/);
|
|
644
1292
|
if (numberedMatch) {
|
|
645
1293
|
const text = numberedMatch[2] ? `${numberedMatch[1]} ${numberedMatch[2]}` : numberedMatch[1];
|
|
@@ -648,11 +1296,15 @@ function extractListSection(report, heading) {
|
|
|
648
1296
|
}
|
|
649
1297
|
return items;
|
|
650
1298
|
}
|
|
1299
|
+
|
|
1300
|
+
// src/formatters/html-report.ts
|
|
651
1301
|
var HTML_TEMPLATE = `<!DOCTYPE html>
|
|
652
1302
|
<html lang="en">
|
|
653
1303
|
<head>
|
|
654
1304
|
<meta charset="UTF-8">
|
|
655
1305
|
<meta name="viewport" content="width=device-width, initial-scale=1.0">
|
|
1306
|
+
<meta http-equiv="Content-Security-Policy" content="default-src 'none'; style-src 'unsafe-inline'; img-src data:">
|
|
1307
|
+
<meta name="robots" content="noindex, nofollow">
|
|
656
1308
|
<title>Qualiow Report \u2014 {{meta.target}}</title>
|
|
657
1309
|
<style>
|
|
658
1310
|
*, *::before, *::after { box-sizing: border-box; margin: 0; padding: 0; }
|
|
@@ -846,6 +1498,18 @@ var HTML_TEMPLATE = `<!DOCTYPE html>
|
|
|
846
1498
|
margin-bottom: 0.35rem;
|
|
847
1499
|
}
|
|
848
1500
|
|
|
1501
|
+
/* Confidentiality banner */
|
|
1502
|
+
.confidential {
|
|
1503
|
+
background: #2a1a1a;
|
|
1504
|
+
border: 1px solid #663333;
|
|
1505
|
+
color: #e0b0b0;
|
|
1506
|
+
border-radius: 6px;
|
|
1507
|
+
padding: 0.6rem 1rem;
|
|
1508
|
+
font-size: 0.8rem;
|
|
1509
|
+
margin-bottom: 1.5rem;
|
|
1510
|
+
letter-spacing: 0.02em;
|
|
1511
|
+
}
|
|
1512
|
+
|
|
849
1513
|
/* Footer */
|
|
850
1514
|
.footer {
|
|
851
1515
|
margin-top: 3rem;
|
|
@@ -892,6 +1556,8 @@ var HTML_TEMPLATE = `<!DOCTYPE html>
|
|
|
892
1556
|
<body>
|
|
893
1557
|
<div class="container">
|
|
894
1558
|
|
|
1559
|
+
<div class="confidential">{{confidentialityNotice}}</div>
|
|
1560
|
+
|
|
895
1561
|
<div class="header">
|
|
896
1562
|
<h1>Exploratory Testing Report</h1>
|
|
897
1563
|
<div class="meta">
|
|
@@ -1012,7 +1678,7 @@ var HTML_TEMPLATE = `<!DOCTYPE html>
|
|
|
1012
1678
|
{{/if}}
|
|
1013
1679
|
|
|
1014
1680
|
<div class="footer">
|
|
1015
|
-
Generated by Qualiow Exploratory Testing
|
|
1681
|
+
Generated by Qualiow Exploratory Testing \xB7 CONFIDENTIAL \u2014 internal use only
|
|
1016
1682
|
</div>
|
|
1017
1683
|
|
|
1018
1684
|
</div>
|
|
@@ -1020,8 +1686,7 @@ var HTML_TEMPLATE = `<!DOCTYPE html>
|
|
|
1020
1686
|
</html>`;
|
|
1021
1687
|
var compiledTemplate = Handlebars.compile(HTML_TEMPLATE);
|
|
1022
1688
|
async function generateHtmlReport(sessionDir) {
|
|
1023
|
-
const session = await
|
|
1024
|
-
const report = session.report ?? "";
|
|
1689
|
+
const { session, report } = await loadSessionForOutput(sessionDir);
|
|
1025
1690
|
const meta = extractReportMeta(report, session.id);
|
|
1026
1691
|
const coverage = extractCoverage(report);
|
|
1027
1692
|
const observations = extractListSection(report, "Observations");
|
|
@@ -1037,6 +1702,7 @@ async function generateHtmlReport(sessionDir) {
|
|
|
1037
1702
|
}));
|
|
1038
1703
|
const html = compiledTemplate({
|
|
1039
1704
|
meta,
|
|
1705
|
+
confidentialityNotice: CONFIDENTIALITY_NOTICE,
|
|
1040
1706
|
totalBugs: session.bugs.length,
|
|
1041
1707
|
criticalCount: counts.critical,
|
|
1042
1708
|
highCount: counts.high,
|
|
@@ -1066,8 +1732,7 @@ function summarizeBusinessImpact(impact) {
|
|
|
1066
1732
|
function extractTarget(report, sessionId) {
|
|
1067
1733
|
const match = report.match(/\*\*Application:\*\*\s*(.+)/i) ?? report.match(/\*\*Target:\*\*\s*(.+)/i) ?? report.match(/\|\s*Target\s*\|\s*(.+?)\s*\|/i);
|
|
1068
1734
|
if (match) return match[1].trim();
|
|
1069
|
-
|
|
1070
|
-
return parts[parts.length - 1] || sessionId;
|
|
1735
|
+
return parseSessionDirName(sessionId)?.slug ?? sessionId;
|
|
1071
1736
|
}
|
|
1072
1737
|
function extractDate(report) {
|
|
1073
1738
|
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);
|
|
@@ -1081,64 +1746,33 @@ function extractPagesExplored(report) {
|
|
|
1081
1746
|
const match = report.match(/Pages\s+Explored\s*\|\s*(\d+)/i);
|
|
1082
1747
|
return match ? parseInt(match[1], 10) : 0;
|
|
1083
1748
|
}
|
|
1084
|
-
function extractCoverage2(report) {
|
|
1085
|
-
const entries = [];
|
|
1086
|
-
const tableMatch = report.match(
|
|
1087
|
-
/\|\s*Area\s*\|\s*Status\s*\|[\s\S]*?\n((?:\|.+\|.+\n?)+)/i
|
|
1088
|
-
);
|
|
1089
|
-
if (!tableMatch) return entries;
|
|
1090
|
-
const rows = tableMatch[1].split("\n").filter((r) => r.trim().startsWith("|"));
|
|
1091
|
-
for (const row of rows) {
|
|
1092
|
-
const cells = row.split("|").map((c) => c.trim()).filter(Boolean);
|
|
1093
|
-
if (cells.length >= 2 && !cells[0].startsWith("---")) {
|
|
1094
|
-
entries.push({
|
|
1095
|
-
area: cells[0] || "",
|
|
1096
|
-
status: cells[1] || "",
|
|
1097
|
-
bugs_found: parseInt(cells[3] || "0", 10) || 0,
|
|
1098
|
-
notes: cells[4] || ""
|
|
1099
|
-
});
|
|
1100
|
-
}
|
|
1101
|
-
}
|
|
1102
|
-
return entries;
|
|
1103
|
-
}
|
|
1104
|
-
function extractListSection2(report, heading) {
|
|
1105
|
-
const items = [];
|
|
1106
|
-
const regex = new RegExp(`##\\s+${heading}\\s*\\n+([\\s\\S]*?)(?=\\n##\\s|\\n---|$)`, "i");
|
|
1107
|
-
const match = report.match(regex);
|
|
1108
|
-
if (!match) return items;
|
|
1109
|
-
for (const line of match[1].split("\n")) {
|
|
1110
|
-
const itemMatch = line.match(/^[-*]\s+(?:\[.\]\s+)?(.+)/);
|
|
1111
|
-
if (itemMatch) {
|
|
1112
|
-
items.push(itemMatch[1].trim());
|
|
1113
|
-
}
|
|
1114
|
-
const numberedMatch = line.match(/^\d+\.\s+\*\*(.+?)\*\*\s*(.+)?/);
|
|
1115
|
-
if (numberedMatch) {
|
|
1116
|
-
const text = numberedMatch[2] ? `${numberedMatch[1]} ${numberedMatch[2]}` : numberedMatch[1];
|
|
1117
|
-
items.push(text.replace(/\s*--\s*/, " -- "));
|
|
1118
|
-
}
|
|
1119
|
-
}
|
|
1120
|
-
return items;
|
|
1121
|
-
}
|
|
1122
1749
|
async function generateJsonReport(sessionDir) {
|
|
1123
|
-
const session = await
|
|
1124
|
-
const report = session.report ?? "";
|
|
1125
|
-
const target = extractTarget(report, session.id);
|
|
1126
|
-
const date = extractDate(report);
|
|
1127
|
-
const duration_min = extractDuration(report);
|
|
1128
|
-
const pages_explored = extractPagesExplored(report);
|
|
1750
|
+
const { session, report } = await loadSessionForOutput(sessionDir);
|
|
1129
1751
|
const counts = { critical: 0, high: 0, medium: 0, low: 0 };
|
|
1130
1752
|
for (const bug of session.bugs) {
|
|
1131
1753
|
counts[bug.severity]++;
|
|
1132
1754
|
}
|
|
1133
|
-
const coverage =
|
|
1134
|
-
|
|
1135
|
-
|
|
1755
|
+
const coverage = extractCoverage(report).map((c) => ({
|
|
1756
|
+
area: c.area,
|
|
1757
|
+
risk: c.risk,
|
|
1758
|
+
status: c.status,
|
|
1759
|
+
bugs_found: parseInt(c.bugsFound, 10) || 0,
|
|
1760
|
+
notes: c.notes
|
|
1761
|
+
}));
|
|
1136
1762
|
return {
|
|
1763
|
+
meta: {
|
|
1764
|
+
classification: "CONFIDENTIAL",
|
|
1765
|
+
notice: CONFIDENTIALITY_NOTICE,
|
|
1766
|
+
generated_by: `qualiow-exploratory-testing ${getPackageVersion()}`,
|
|
1767
|
+
generated_at: (/* @__PURE__ */ new Date()).toISOString(),
|
|
1768
|
+
redacted: true
|
|
1769
|
+
},
|
|
1137
1770
|
session: {
|
|
1138
1771
|
id: session.id,
|
|
1139
|
-
|
|
1140
|
-
|
|
1141
|
-
|
|
1772
|
+
kind: parseSessionDirName(session.id)?.kind ?? null,
|
|
1773
|
+
target: extractTarget(report, session.id),
|
|
1774
|
+
date: extractDate(report),
|
|
1775
|
+
duration_min: extractDuration(report)
|
|
1142
1776
|
},
|
|
1143
1777
|
summary: {
|
|
1144
1778
|
total_bugs: session.bugs.length,
|
|
@@ -1146,21 +1780,25 @@ async function generateJsonReport(sessionDir) {
|
|
|
1146
1780
|
high: counts.high,
|
|
1147
1781
|
medium: counts.medium,
|
|
1148
1782
|
low: counts.low,
|
|
1149
|
-
pages_explored
|
|
1783
|
+
pages_explored: extractPagesExplored(report)
|
|
1150
1784
|
},
|
|
1151
1785
|
bugs: session.bugs.map((bug) => ({
|
|
1152
1786
|
id: bug.id,
|
|
1153
1787
|
title: bug.title,
|
|
1154
1788
|
severity: bug.severity,
|
|
1789
|
+
priority: bug.priority,
|
|
1155
1790
|
component: bug.component,
|
|
1156
1791
|
url: bug.url,
|
|
1792
|
+
environment: bug.environment,
|
|
1793
|
+
reproduction_rate: bug.reproduction_rate,
|
|
1794
|
+
summary: bug.summary,
|
|
1157
1795
|
business_impact: bug.business_impact,
|
|
1158
1796
|
steps: bug.steps,
|
|
1159
1797
|
evidence: bug.evidence
|
|
1160
1798
|
})),
|
|
1161
1799
|
coverage,
|
|
1162
|
-
observations,
|
|
1163
|
-
recommendations
|
|
1800
|
+
observations: extractListSection(report, "Observations"),
|
|
1801
|
+
recommendations: extractListSection(report, "Recommendations")
|
|
1164
1802
|
};
|
|
1165
1803
|
}
|
|
1166
1804
|
|
|
@@ -1173,53 +1811,49 @@ var SEVERITY_TO_JIRA_PRIORITY = {
|
|
|
1173
1811
|
};
|
|
1174
1812
|
function csvEscape(value) {
|
|
1175
1813
|
if (!value) return '""';
|
|
1176
|
-
|
|
1177
|
-
|
|
1814
|
+
let v = value;
|
|
1815
|
+
if (/^[=+\-@\t\r]/.test(v)) v = `'${v}`;
|
|
1816
|
+
return `"${v.replace(/"/g, '""')}"`;
|
|
1178
1817
|
}
|
|
1179
1818
|
function formatDescription(bug) {
|
|
1180
1819
|
const parts = [];
|
|
1820
|
+
if (bug.summary) {
|
|
1821
|
+
parts.push(bug.summary, "");
|
|
1822
|
+
}
|
|
1181
1823
|
if (bug.steps.length > 0) {
|
|
1182
1824
|
parts.push("h3. Steps to Reproduce");
|
|
1183
|
-
for (const step of bug.steps) {
|
|
1184
|
-
parts.push(`# ${step}`);
|
|
1185
|
-
}
|
|
1825
|
+
for (const step of bug.steps) parts.push(`# ${step}`);
|
|
1186
1826
|
parts.push("");
|
|
1187
1827
|
}
|
|
1188
1828
|
if (bug.expected) {
|
|
1189
|
-
parts.push(
|
|
1190
|
-
parts.push(bug.expected);
|
|
1191
|
-
parts.push("");
|
|
1829
|
+
parts.push("h3. Expected Behavior", bug.expected, "");
|
|
1192
1830
|
}
|
|
1193
1831
|
if (bug.actual) {
|
|
1194
|
-
parts.push(
|
|
1195
|
-
parts.push(bug.actual);
|
|
1196
|
-
parts.push("");
|
|
1832
|
+
parts.push("h3. Actual Behavior", bug.actual, "");
|
|
1197
1833
|
}
|
|
1198
1834
|
if (bug.business_impact) {
|
|
1199
|
-
parts.push("h3. Business Impact");
|
|
1200
|
-
|
|
1201
|
-
|
|
1835
|
+
parts.push("h3. Business Impact", bug.business_impact, "");
|
|
1836
|
+
}
|
|
1837
|
+
if (bug.environment) {
|
|
1838
|
+
parts.push("h3. Environment", bug.environment, "");
|
|
1202
1839
|
}
|
|
1203
1840
|
if (bug.url) {
|
|
1204
|
-
parts.push(
|
|
1205
|
-
parts.push(bug.url);
|
|
1841
|
+
parts.push("h3. URL", bug.url, "");
|
|
1206
1842
|
}
|
|
1843
|
+
parts.push(`_${CONFIDENTIALITY_NOTICE}_`);
|
|
1207
1844
|
return parts.join("\n");
|
|
1208
1845
|
}
|
|
1209
|
-
function extractDomain(sessionId) {
|
|
1210
|
-
return "general";
|
|
1211
|
-
}
|
|
1212
1846
|
async function generateJiraExport(sessionDir) {
|
|
1213
|
-
const session = await
|
|
1847
|
+
const { session } = await loadSessionForOutput(sessionDir);
|
|
1214
1848
|
const headers = ["Summary", "Priority", "Description", "Component", "Labels"];
|
|
1215
1849
|
const rows = [headers.join(",")];
|
|
1216
|
-
const
|
|
1850
|
+
const kind = parseSessionDirName(session.id)?.kind ?? "";
|
|
1217
1851
|
for (const bug of session.bugs) {
|
|
1218
1852
|
const summary = `${bug.id}: ${bug.title}`;
|
|
1219
1853
|
const priority = SEVERITY_TO_JIRA_PRIORITY[bug.severity] ?? "Major";
|
|
1220
1854
|
const description = formatDescription(bug);
|
|
1221
1855
|
const component = bug.component || "";
|
|
1222
|
-
const labels = ["qualiow", "exploratory-testing",
|
|
1856
|
+
const labels = ["qualiow", "exploratory-testing", kind].filter(Boolean).join(" ");
|
|
1223
1857
|
rows.push(
|
|
1224
1858
|
[
|
|
1225
1859
|
csvEscape(summary),
|
|
@@ -1232,22 +1866,741 @@ async function generateJiraExport(sessionDir) {
|
|
|
1232
1866
|
}
|
|
1233
1867
|
return rows.join("\n");
|
|
1234
1868
|
}
|
|
1869
|
+
|
|
1870
|
+
// src/formatters/markdown-summary.ts
|
|
1871
|
+
var SEVERITY_LABEL = {
|
|
1872
|
+
critical: "Critical",
|
|
1873
|
+
high: "High",
|
|
1874
|
+
medium: "Medium",
|
|
1875
|
+
low: "Low"
|
|
1876
|
+
};
|
|
1877
|
+
async function generateMarkdownSummary(sessionDir) {
|
|
1878
|
+
const { session, report } = await loadSessionForOutput(sessionDir);
|
|
1879
|
+
const meta = extractReportMeta(report, session.id);
|
|
1880
|
+
const counts = { critical: 0, high: 0, medium: 0, low: 0 };
|
|
1881
|
+
for (const bug of session.bugs) counts[bug.severity]++;
|
|
1882
|
+
const lines = [];
|
|
1883
|
+
lines.push(CONFIDENTIALITY_HEADER_MD, "");
|
|
1884
|
+
lines.push(`# Session Summary \u2014 ${meta.target}`, "");
|
|
1885
|
+
lines.push("| Field | Value |", "|---|---|");
|
|
1886
|
+
lines.push(`| Session | ${session.id} |`);
|
|
1887
|
+
if (meta.date) lines.push(`| Date | ${meta.date} |`);
|
|
1888
|
+
if (meta.duration) lines.push(`| Duration | ${meta.duration} |`);
|
|
1889
|
+
lines.push(
|
|
1890
|
+
`| Bugs | ${session.bugs.length} (Critical ${counts.critical} \xB7 High ${counts.high} \xB7 Medium ${counts.medium} \xB7 Low ${counts.low}) |`,
|
|
1891
|
+
""
|
|
1892
|
+
);
|
|
1893
|
+
if (meta.summary) {
|
|
1894
|
+
lines.push("## Executive Summary", "", meta.summary, "");
|
|
1895
|
+
}
|
|
1896
|
+
if (session.bugs.length) {
|
|
1897
|
+
lines.push("## Bugs", "", "| ID | Severity | Component | Title |", "|---|---|---|---|");
|
|
1898
|
+
for (const bug of session.bugs) {
|
|
1899
|
+
lines.push(
|
|
1900
|
+
`| ${bug.id} | ${SEVERITY_LABEL[bug.severity]} | ${bug.component || "\u2014"} | ${bug.title} |`
|
|
1901
|
+
);
|
|
1902
|
+
}
|
|
1903
|
+
lines.push("");
|
|
1904
|
+
}
|
|
1905
|
+
const coverage = extractCoverage(report);
|
|
1906
|
+
if (coverage.length) {
|
|
1907
|
+
lines.push("## Coverage", "", "| Area | Risk | Status | Bugs | Notes |", "|---|---|---|---|---|");
|
|
1908
|
+
for (const c of coverage) {
|
|
1909
|
+
lines.push(`| ${c.area} | ${c.risk} | ${c.status} | ${c.bugsFound} | ${c.notes} |`);
|
|
1910
|
+
}
|
|
1911
|
+
lines.push("");
|
|
1912
|
+
}
|
|
1913
|
+
const recommendations = extractListSection(report, "Recommendations");
|
|
1914
|
+
if (recommendations.length) {
|
|
1915
|
+
lines.push("## Recommendations", "");
|
|
1916
|
+
for (const r of recommendations) lines.push(`- ${r}`);
|
|
1917
|
+
lines.push("");
|
|
1918
|
+
}
|
|
1919
|
+
return lines.join("\n");
|
|
1920
|
+
}
|
|
1921
|
+
|
|
1922
|
+
// src/cli/commands/init.ts
|
|
1923
|
+
import { Command } from "commander";
|
|
1924
|
+
import { resolve as resolve3, join as join6, relative as relative2, dirname as dirname3 } from "path";
|
|
1925
|
+
import {
|
|
1926
|
+
existsSync as existsSync6,
|
|
1927
|
+
readFileSync as readFileSync6,
|
|
1928
|
+
writeFileSync as writeFileSync2,
|
|
1929
|
+
mkdirSync as mkdirSync2,
|
|
1930
|
+
readdirSync as readdirSync3,
|
|
1931
|
+
statSync,
|
|
1932
|
+
copyFileSync,
|
|
1933
|
+
chmodSync
|
|
1934
|
+
} from "fs";
|
|
1935
|
+
import chalk from "chalk";
|
|
1936
|
+
function sameContent(a, b) {
|
|
1937
|
+
try {
|
|
1938
|
+
return readFileSync6(a).equals(readFileSync6(b));
|
|
1939
|
+
} catch {
|
|
1940
|
+
return false;
|
|
1941
|
+
}
|
|
1942
|
+
}
|
|
1943
|
+
function copyEntry(src, dest, opts) {
|
|
1944
|
+
let status;
|
|
1945
|
+
if (!existsSync6(dest)) {
|
|
1946
|
+
status = "installed";
|
|
1947
|
+
} else if (sameContent(src, dest)) {
|
|
1948
|
+
status = "unchanged";
|
|
1949
|
+
} else {
|
|
1950
|
+
status = opts.force ? "overwritten" : "skipped";
|
|
1951
|
+
}
|
|
1952
|
+
if (!opts.dryRun && (status === "installed" || status === "overwritten")) {
|
|
1953
|
+
mkdirSync2(dirname3(dest), { recursive: true });
|
|
1954
|
+
copyFileSync(src, dest);
|
|
1955
|
+
chmodSync(dest, statSync(src).mode & 511);
|
|
1956
|
+
}
|
|
1957
|
+
return { dest, status };
|
|
1958
|
+
}
|
|
1959
|
+
function listFiles(dir, filter) {
|
|
1960
|
+
const out = [];
|
|
1961
|
+
const walk = (current) => {
|
|
1962
|
+
for (const entry of readdirSync3(current, { withFileTypes: true })) {
|
|
1963
|
+
const full = join6(current, entry.name);
|
|
1964
|
+
if (entry.isDirectory()) {
|
|
1965
|
+
walk(full);
|
|
1966
|
+
} else {
|
|
1967
|
+
const rel = relative2(dir, full).split("\\").join("/");
|
|
1968
|
+
if (!filter || filter(rel)) out.push(rel);
|
|
1969
|
+
}
|
|
1970
|
+
}
|
|
1971
|
+
};
|
|
1972
|
+
walk(dir);
|
|
1973
|
+
return out.sort();
|
|
1974
|
+
}
|
|
1975
|
+
function copyTree(srcDir, destDir, opts) {
|
|
1976
|
+
if (!existsSync6(srcDir)) return [];
|
|
1977
|
+
return listFiles(srcDir, opts.filter).map(
|
|
1978
|
+
(rel) => copyEntry(join6(srcDir, rel), join6(destDir, rel), opts)
|
|
1979
|
+
);
|
|
1980
|
+
}
|
|
1981
|
+
async function runInit(options, ctx) {
|
|
1982
|
+
const cwd = ctx.cwd;
|
|
1983
|
+
const pkgRoot = ctx.pkgRoot ?? getPackageRoot();
|
|
1984
|
+
const log = ctx.log ?? ((line) => console.log(line));
|
|
1985
|
+
const copyOpts = { force: options.force, dryRun: options.dryRun };
|
|
1986
|
+
const copies = [];
|
|
1987
|
+
const createdDirs = [];
|
|
1988
|
+
const createdFiles = [];
|
|
1989
|
+
if (options.dryRun) log(chalk.cyan.bold("Dry run \u2014 nothing will be written\n"));
|
|
1990
|
+
if (resolve3(pkgRoot) === resolve3(cwd)) {
|
|
1991
|
+
log(chalk.yellow(" \u25CB Running inside the package itself \u2014 skills and data are already in place"));
|
|
1992
|
+
} else {
|
|
1993
|
+
const skillsSrc = resolveSkillsSource(pkgRoot);
|
|
1994
|
+
if (!skillsSrc) {
|
|
1995
|
+
throw new Error(`No skills directory found under ${pkgRoot}`);
|
|
1996
|
+
}
|
|
1997
|
+
copies.push(
|
|
1998
|
+
...copyTree(skillsSrc, join6(cwd, ".claude", "skills"), {
|
|
1999
|
+
...copyOpts,
|
|
2000
|
+
filter: (rel2) => rel2.startsWith("qa-")
|
|
2001
|
+
})
|
|
2002
|
+
);
|
|
2003
|
+
const agentCandidates = [
|
|
2004
|
+
join6(pkgRoot, "agents", "qa-gather-agent.md"),
|
|
2005
|
+
join6(pkgRoot, ".claude", "agents", "qa-gather-agent.md")
|
|
2006
|
+
];
|
|
2007
|
+
const agentSrc = agentCandidates.find((p) => existsSync6(p));
|
|
2008
|
+
if (agentSrc) {
|
|
2009
|
+
copies.push(
|
|
2010
|
+
copyEntry(agentSrc, join6(cwd, ".claude", "agents", "qa-gather-agent.md"), copyOpts)
|
|
2011
|
+
);
|
|
2012
|
+
}
|
|
2013
|
+
const dataSrc = join6(pkgRoot, "data");
|
|
2014
|
+
copies.push(...copyTree(join6(dataSrc, "knowledge"), join6(cwd, "data", "knowledge"), copyOpts));
|
|
2015
|
+
copies.push(
|
|
2016
|
+
...copyTree(join6(dataSrc, "domains"), join6(cwd, "data", "domains"), {
|
|
2017
|
+
...copyOpts,
|
|
2018
|
+
filter: (rel2) => rel2.endsWith(".yml")
|
|
2019
|
+
})
|
|
2020
|
+
);
|
|
2021
|
+
copies.push(...copyTree(join6(dataSrc, "templates"), join6(cwd, "data", "templates"), copyOpts));
|
|
2022
|
+
copies.push(...copyTree(join6(dataSrc, "security"), join6(cwd, "data", "security"), copyOpts));
|
|
2023
|
+
copies.push(
|
|
2024
|
+
...copyTree(join6(dataSrc, "targets"), join6(cwd, "data", "targets"), {
|
|
2025
|
+
...copyOpts,
|
|
2026
|
+
filter: (rel2) => {
|
|
2027
|
+
if (!rel2.endsWith(".yml") || rel2.includes("/")) return false;
|
|
2028
|
+
if (rel2.startsWith("local-")) return false;
|
|
2029
|
+
if (rel2 === "_default.yml") return true;
|
|
2030
|
+
if (!options.includeExamples) return false;
|
|
2031
|
+
return rel2.startsWith("_example-") || rel2 === "testers-ai.yml";
|
|
2032
|
+
}
|
|
2033
|
+
})
|
|
2034
|
+
);
|
|
2035
|
+
const binSrc = join6(pkgRoot, "bin");
|
|
2036
|
+
copies.push(...copyTree(binSrc, join6(cwd, "qa", "bin"), copyOpts));
|
|
2037
|
+
if (existsSync6(binSrc)) {
|
|
2038
|
+
const versionPath = join6(cwd, "qa", "bin", "VERSION");
|
|
2039
|
+
const version = `${getPackageVersion(pkgRoot)}
|
|
2040
|
+
`;
|
|
2041
|
+
const exists = existsSync6(versionPath);
|
|
2042
|
+
const same = exists && readFileSync6(versionPath, "utf-8") === version;
|
|
2043
|
+
const status = !exists ? "installed" : same ? "unchanged" : options.force ? "overwritten" : "skipped";
|
|
2044
|
+
if (!options.dryRun && (status === "installed" || status === "overwritten")) {
|
|
2045
|
+
mkdirSync2(dirname3(versionPath), { recursive: true });
|
|
2046
|
+
writeFileSync2(versionPath, version);
|
|
2047
|
+
}
|
|
2048
|
+
copies.push({ dest: versionPath, status });
|
|
2049
|
+
}
|
|
2050
|
+
const envExampleSrc = join6(pkgRoot, ".env.example");
|
|
2051
|
+
if (existsSync6(envExampleSrc)) {
|
|
2052
|
+
copies.push(copyEntry(envExampleSrc, join6(cwd, "qa", ".env.example"), copyOpts));
|
|
2053
|
+
}
|
|
2054
|
+
}
|
|
2055
|
+
for (const dir of ["output/sessions", "output/bugs", "output/context", ".auth", "qa"]) {
|
|
2056
|
+
const full = join6(cwd, dir);
|
|
2057
|
+
if (!existsSync6(full)) {
|
|
2058
|
+
createdDirs.push(full);
|
|
2059
|
+
if (!options.dryRun) mkdirSync2(full, { recursive: true });
|
|
2060
|
+
}
|
|
2061
|
+
}
|
|
2062
|
+
for (const [rel2, content] of [
|
|
2063
|
+
["output/sessions/INDEX.md", INDEX_MD_HEADER],
|
|
2064
|
+
["output/bugs/all-bugs.md", ALL_BUGS_MD_HEADER]
|
|
2065
|
+
]) {
|
|
2066
|
+
const full = join6(cwd, rel2);
|
|
2067
|
+
if (!existsSync6(full)) {
|
|
2068
|
+
createdFiles.push(full);
|
|
2069
|
+
if (!options.dryRun) {
|
|
2070
|
+
mkdirSync2(dirname3(full), { recursive: true });
|
|
2071
|
+
writeFileSync2(full, content);
|
|
2072
|
+
}
|
|
2073
|
+
}
|
|
2074
|
+
}
|
|
2075
|
+
const gitignorePath = join6(cwd, ".gitignore");
|
|
2076
|
+
const existing = existsSync6(gitignorePath) ? readFileSync6(gitignorePath, "utf-8") : "";
|
|
2077
|
+
const merged = mergeGitignore(existing);
|
|
2078
|
+
const gitignoreUpdated = merged !== null;
|
|
2079
|
+
if (merged !== null && !options.dryRun) {
|
|
2080
|
+
writeFileSync2(gitignorePath, merged);
|
|
2081
|
+
}
|
|
2082
|
+
const counts = { installed: 0, unchanged: 0, overwritten: 0, skipped: 0 };
|
|
2083
|
+
for (const c of copies) counts[c.status]++;
|
|
2084
|
+
const rel = (p) => relative2(cwd, p) || ".";
|
|
2085
|
+
if (copies.length) {
|
|
2086
|
+
log(
|
|
2087
|
+
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)`) : ""))
|
|
2088
|
+
);
|
|
2089
|
+
for (const c of copies.filter((x) => x.status === "skipped")) {
|
|
2090
|
+
log(chalk.yellow(` skipped ${rel(c.dest)}`));
|
|
2091
|
+
}
|
|
2092
|
+
}
|
|
2093
|
+
for (const d of createdDirs) log(chalk.green(` \u2713 Created ${rel(d)}/`));
|
|
2094
|
+
for (const f of createdFiles) log(chalk.green(` \u2713 Created ${rel(f)}`));
|
|
2095
|
+
log(
|
|
2096
|
+
gitignoreUpdated ? chalk.green(" \u2713 Updated .gitignore (Qualiow block)") : chalk.cyan(" \u25CB .gitignore already up to date")
|
|
2097
|
+
);
|
|
2098
|
+
log("");
|
|
2099
|
+
log(chalk.cyan.bold(options.dryRun ? "Dry run complete." : "Qualiow initialized."));
|
|
2100
|
+
log("");
|
|
2101
|
+
log(chalk.white("Next steps:"));
|
|
2102
|
+
log(chalk.white(" 1. npx playwright-cli install --skills # official Playwright skill, next to qualiow"));
|
|
2103
|
+
log(chalk.white(" 2. cp qa/.env.example qa/.env # credentials by env var name only"));
|
|
2104
|
+
log(chalk.white(" 3. /qa-target-setup or /qa-explore https://your-app.com"));
|
|
2105
|
+
log(chalk.white(" 4. mobile: qa/bin/doctor-mobile.sh # then /qa-explore-mobile --target <id>"));
|
|
2106
|
+
log("");
|
|
2107
|
+
return { copies, createdDirs, createdFiles, gitignoreUpdated };
|
|
2108
|
+
}
|
|
2109
|
+
|
|
2110
|
+
// src/cli/commands/explore.ts
|
|
2111
|
+
import { Command as Command2 } from "commander";
|
|
2112
|
+
import { resolve as resolve4, join as join7, relative as relative3 } from "path";
|
|
2113
|
+
import { existsSync as existsSync7, mkdirSync as mkdirSync3, writeFileSync as writeFileSync3 } from "fs";
|
|
2114
|
+
import chalk2 from "chalk";
|
|
2115
|
+
function parseTimeBox(value) {
|
|
2116
|
+
const m = /^(\d+)m$/.exec(value.trim());
|
|
2117
|
+
if (!m) throw new Error(`Invalid --time-box "${value}": use minutes like 30m or 45m`);
|
|
2118
|
+
const minutes = parseInt(m[1], 10);
|
|
2119
|
+
if (minutes < 1 || minutes > 45) {
|
|
2120
|
+
throw new Error(`--time-box must be between 1m and 45m (got ${value})`);
|
|
2121
|
+
}
|
|
2122
|
+
return minutes;
|
|
2123
|
+
}
|
|
2124
|
+
async function runExplore(url, options, ctx) {
|
|
2125
|
+
const cwd = ctx.cwd;
|
|
2126
|
+
const now = ctx.now ?? /* @__PURE__ */ new Date();
|
|
2127
|
+
const log = ctx.log ?? ((line) => console.log(line));
|
|
2128
|
+
if (url) {
|
|
2129
|
+
try {
|
|
2130
|
+
new URL(url);
|
|
2131
|
+
} catch {
|
|
2132
|
+
throw new Error(`Invalid URL: "${url}". Provide a full URL such as https://example.com`);
|
|
2133
|
+
}
|
|
2134
|
+
}
|
|
2135
|
+
const minutes = parseTimeBox(options.timeBox);
|
|
2136
|
+
const targetPath = resolveTargetPath(cwd, options.target);
|
|
2137
|
+
let targetLabel = options.target ?? "adhoc";
|
|
2138
|
+
if (options.target || existsSync7(targetPath)) {
|
|
2139
|
+
if (!existsSync7(targetPath)) {
|
|
2140
|
+
throw new Error(
|
|
2141
|
+
`Target config not found: ${relative3(cwd, targetPath)}
|
|
2142
|
+
Available targets: npx qualiow list targets`
|
|
2143
|
+
);
|
|
2144
|
+
}
|
|
2145
|
+
const result = validateTargetConfig(targetPath);
|
|
2146
|
+
if (!result.valid) {
|
|
2147
|
+
const details = (result.errors ?? []).map((e) => ` \u2192 ${e.path ? `[${e.path}] ` : ""}${e.message}`).join("\n");
|
|
2148
|
+
throw new Error(`Target config ${relative3(cwd, targetPath)} is invalid:
|
|
2149
|
+
${details}`);
|
|
2150
|
+
}
|
|
2151
|
+
if (!options.target) targetLabel = url ? slugify(url) : "adhoc";
|
|
2152
|
+
log(chalk2.green(` \u2713 Target config valid: ${relative3(cwd, targetPath)}`));
|
|
2153
|
+
} else if (url) {
|
|
2154
|
+
targetLabel = slugify(url);
|
|
2155
|
+
}
|
|
2156
|
+
if (options.context) {
|
|
2157
|
+
const contextPath = resolve4(cwd, options.context);
|
|
2158
|
+
if (!existsSync7(contextPath)) {
|
|
2159
|
+
throw new Error(`Context file not found: ${contextPath}`);
|
|
2160
|
+
}
|
|
2161
|
+
log(chalk2.green(` \u2713 Context file found: ${options.context}`));
|
|
2162
|
+
}
|
|
2163
|
+
const sessionName = sessionDirName("explore", targetLabel, now);
|
|
2164
|
+
const sessionDir = resolve4(cwd, "output", "sessions", sessionName);
|
|
2165
|
+
if (options.dryRun) {
|
|
2166
|
+
log("");
|
|
2167
|
+
log(chalk2.cyan.bold("Dry run \u2014 no files created"));
|
|
2168
|
+
log(chalk2.white(` Session directory: ${relative3(cwd, sessionDir)}`));
|
|
2169
|
+
log(chalk2.white(` URL: ${url ?? "(none \u2014 /qa-explore will ask)"}`));
|
|
2170
|
+
log(chalk2.white(` Target: ${options.target ?? relative3(cwd, targetPath)}`));
|
|
2171
|
+
log(chalk2.white(` Context: ${options.context ?? "(none)"}`));
|
|
2172
|
+
log(chalk2.white(` Time box: ${minutes} min`));
|
|
2173
|
+
return { sessionDir };
|
|
2174
|
+
}
|
|
2175
|
+
for (const sub of ["", "screenshots", "bugs", "videos"]) {
|
|
2176
|
+
mkdirSync3(join7(sessionDir, sub), { recursive: true });
|
|
2177
|
+
}
|
|
2178
|
+
const date = now.toISOString().slice(0, 10);
|
|
2179
|
+
writeFileSync3(
|
|
2180
|
+
join7(sessionDir, "charter.md"),
|
|
2181
|
+
`${CONFIDENTIALITY_HEADER_MD}
|
|
2182
|
+
|
|
2183
|
+
# Exploratory Testing Charter
|
|
2184
|
+
|
|
2185
|
+
**Session:** ${sessionName}
|
|
2186
|
+
**Date:** ${date}
|
|
2187
|
+
**Target:** ${options.target ?? targetLabel}
|
|
2188
|
+
**URL:** ${url ?? "TBD"}
|
|
2189
|
+
**Time Box:** ${minutes} min
|
|
2190
|
+
|
|
2191
|
+
## Mission
|
|
2192
|
+
|
|
2193
|
+
> Filled in by /qa-explore phase 2.
|
|
2194
|
+
|
|
2195
|
+
## Areas of Focus
|
|
2196
|
+
|
|
2197
|
+
-
|
|
2198
|
+
|
|
2199
|
+
## Risks & Concerns
|
|
2200
|
+
|
|
2201
|
+
-
|
|
2202
|
+
`
|
|
2203
|
+
);
|
|
2204
|
+
writeFileSync3(
|
|
2205
|
+
join7(sessionDir, "session-log.md"),
|
|
2206
|
+
`${CONFIDENTIALITY_HEADER_MD}
|
|
2207
|
+
|
|
2208
|
+
# Session Log \u2014 ${sessionName}
|
|
2209
|
+
|
|
2210
|
+
[${now.toISOString()}] [PRE-FLIGHT] Session directory created by \`qualiow explore\`
|
|
2211
|
+
`
|
|
2212
|
+
);
|
|
2213
|
+
log("");
|
|
2214
|
+
log(chalk2.green.bold("Session skeleton created (pre-flight only \u2014 no browser was launched)."));
|
|
2215
|
+
log(chalk2.white(` Directory: ${relative3(cwd, sessionDir)}`));
|
|
2216
|
+
log("");
|
|
2217
|
+
log(chalk2.cyan(" Run the session in Claude Code:"));
|
|
2218
|
+
const args = [url ?? "<url>", options.target ? `--target ${options.target}` : "", options.context ? `--context ${options.context}` : ""].filter(Boolean).join(" ");
|
|
2219
|
+
log(chalk2.white(` /qa-explore ${args} --session output/sessions/${sessionName}`));
|
|
2220
|
+
log("");
|
|
2221
|
+
return { sessionDir };
|
|
2222
|
+
}
|
|
2223
|
+
|
|
2224
|
+
// src/cli/commands/report.ts
|
|
2225
|
+
import { Command as Command3 } from "commander";
|
|
2226
|
+
import { resolve as resolve5, join as join8, basename as basename5, relative as relative4 } from "path";
|
|
2227
|
+
import { existsSync as existsSync8, readdirSync as readdirSync4, readFileSync as readFileSync7, writeFileSync as writeFileSync4 } from "fs";
|
|
2228
|
+
import chalk3 from "chalk";
|
|
2229
|
+
var DEFAULT_FILENAMES = {
|
|
2230
|
+
md: "session-summary.md",
|
|
2231
|
+
html: "session-report.html",
|
|
2232
|
+
json: "session-report.json",
|
|
2233
|
+
jira: "jira-export.csv"
|
|
2234
|
+
};
|
|
2235
|
+
async function runReport(options, ctx) {
|
|
2236
|
+
const cwd = ctx.cwd;
|
|
2237
|
+
const log = ctx.log ?? ((line) => console.log(line));
|
|
2238
|
+
const sessionsDir = resolve5(cwd, "output", "sessions");
|
|
2239
|
+
if (!existsSync8(sessionsDir)) {
|
|
2240
|
+
throw new Error("No output/sessions directory found. Run `npx qualiow init` first.");
|
|
2241
|
+
}
|
|
2242
|
+
const sessionDir = resolveSessionDir(sessionsDir, options.session);
|
|
2243
|
+
const sessionName = basename5(sessionDir);
|
|
2244
|
+
const format = options.format.toLowerCase();
|
|
2245
|
+
let content;
|
|
2246
|
+
switch (format) {
|
|
2247
|
+
case "md":
|
|
2248
|
+
content = await generateMarkdownSummary(sessionDir);
|
|
2249
|
+
break;
|
|
2250
|
+
case "html":
|
|
2251
|
+
content = await generateHtmlReport(sessionDir);
|
|
2252
|
+
break;
|
|
2253
|
+
case "json":
|
|
2254
|
+
content = JSON.stringify(await generateJsonReport(sessionDir), null, 2);
|
|
2255
|
+
break;
|
|
2256
|
+
case "jira":
|
|
2257
|
+
content = await generateJiraExport(sessionDir);
|
|
2258
|
+
break;
|
|
2259
|
+
default:
|
|
2260
|
+
throw new Error(`Unknown format: "${format}". Choose from: md, html, json, jira`);
|
|
2261
|
+
}
|
|
2262
|
+
if (options.stdout) {
|
|
2263
|
+
process.stdout.write(content.endsWith("\n") ? content : content + "\n");
|
|
2264
|
+
return { content };
|
|
2265
|
+
}
|
|
2266
|
+
const outputPath = options.output ? resolve5(cwd, options.output) : join8(sessionDir, DEFAULT_FILENAMES[format]);
|
|
2267
|
+
writeFileSync4(outputPath, content);
|
|
2268
|
+
log(chalk3.cyan(`
|
|
2269
|
+
Session: ${sessionName}`));
|
|
2270
|
+
log(chalk3.green(` ${format.toUpperCase()} written: ${relative4(cwd, outputPath)}`));
|
|
2271
|
+
const statsPath = join8(sessionDir, "stats.json");
|
|
2272
|
+
if (existsSync8(statsPath)) {
|
|
2273
|
+
try {
|
|
2274
|
+
const stats = SessionMetricsSchema.parse(JSON.parse(readFileSync7(statsPath, "utf-8")));
|
|
2275
|
+
if (appendSessionMetricsDeduped(resolve5(cwd, "output"), stats)) {
|
|
2276
|
+
log(chalk3.green(" \u2713 Metrics appended to output/metrics.jsonl"));
|
|
2277
|
+
}
|
|
2278
|
+
} catch {
|
|
2279
|
+
log(chalk3.yellow(" \u26A0 stats.json present but not in the expected shape \u2014 metrics not recorded"));
|
|
2280
|
+
}
|
|
2281
|
+
}
|
|
2282
|
+
log("");
|
|
2283
|
+
return { outputPath, content };
|
|
2284
|
+
}
|
|
2285
|
+
function resolveSessionDir(sessionsDir, sessionId) {
|
|
2286
|
+
const dirs = readdirSync4(sessionsDir, { withFileTypes: true }).filter((d) => d.isDirectory()).map((d) => d.name).sort();
|
|
2287
|
+
if (sessionId === "latest") {
|
|
2288
|
+
const canonical = dirs.filter((d) => SESSION_DIR_RE.test(d));
|
|
2289
|
+
const pool = canonical.length ? canonical : dirs;
|
|
2290
|
+
if (pool.length === 0) throw new Error("No sessions found. Run an exploratory testing session first.");
|
|
2291
|
+
return join8(sessionsDir, pool[pool.length - 1]);
|
|
2292
|
+
}
|
|
2293
|
+
if (dirs.includes(sessionId)) return join8(sessionsDir, sessionId);
|
|
2294
|
+
const matches = dirs.filter((d) => d.includes(sessionId));
|
|
2295
|
+
if (matches.length === 1) return join8(sessionsDir, matches[0]);
|
|
2296
|
+
if (matches.length > 1) {
|
|
2297
|
+
throw new Error(
|
|
2298
|
+
`"${sessionId}" matches ${matches.length} sessions \u2014 be more specific:
|
|
2299
|
+
${matches.join("\n ")}`
|
|
2300
|
+
);
|
|
2301
|
+
}
|
|
2302
|
+
throw new Error(`No session matches "${sessionId}". List them with: npx qualiow list sessions`);
|
|
2303
|
+
}
|
|
2304
|
+
|
|
2305
|
+
// src/cli/commands/list.ts
|
|
2306
|
+
import { Command as Command4 } from "commander";
|
|
2307
|
+
import { resolve as resolve6, join as join9, basename as basename6 } from "path";
|
|
2308
|
+
import { existsSync as existsSync9, readFileSync as readFileSync8, readdirSync as readdirSync5 } from "fs";
|
|
2309
|
+
import { parse as parseYaml3 } from "yaml";
|
|
2310
|
+
import { globSync as globSync3 } from "glob";
|
|
2311
|
+
import chalk4 from "chalk";
|
|
2312
|
+
async function runList(type, cwd) {
|
|
2313
|
+
switch (type) {
|
|
2314
|
+
case "sessions":
|
|
2315
|
+
listSessions(cwd);
|
|
2316
|
+
break;
|
|
2317
|
+
case "knowledge":
|
|
2318
|
+
listKnowledge(cwd);
|
|
2319
|
+
break;
|
|
2320
|
+
case "targets":
|
|
2321
|
+
listTargets(cwd);
|
|
2322
|
+
break;
|
|
2323
|
+
case "domains":
|
|
2324
|
+
listDomains(cwd);
|
|
2325
|
+
break;
|
|
2326
|
+
default:
|
|
2327
|
+
throw new Error(`Unknown type: "${type}". Choose from: sessions, knowledge, targets, domains`);
|
|
2328
|
+
}
|
|
2329
|
+
}
|
|
2330
|
+
function readSessionIndex(indexPath) {
|
|
2331
|
+
if (!existsSync9(indexPath)) return [];
|
|
2332
|
+
const table2 = parseMarkdownTable(readFileSync8(indexPath, "utf-8"));
|
|
2333
|
+
if (!table2) return [];
|
|
2334
|
+
const rows = [];
|
|
2335
|
+
for (const row of table2.rows) {
|
|
2336
|
+
const date = row["date"] ?? "";
|
|
2337
|
+
if (!date || date.startsWith("_")) continue;
|
|
2338
|
+
rows.push({
|
|
2339
|
+
date,
|
|
2340
|
+
kind: row["kind"] ?? "",
|
|
2341
|
+
target: row["target"] ?? "",
|
|
2342
|
+
bugs: row["bugs"] ?? "",
|
|
2343
|
+
duration: row["duration"] ?? "",
|
|
2344
|
+
status: row["status"] ?? "",
|
|
2345
|
+
report: row["report"] ?? row["session directory"] ?? ""
|
|
2346
|
+
});
|
|
2347
|
+
}
|
|
2348
|
+
return rows;
|
|
2349
|
+
}
|
|
2350
|
+
function listSessions(cwd) {
|
|
2351
|
+
const sessionsDir = resolve6(cwd, "output", "sessions");
|
|
2352
|
+
const indexPath = join9(sessionsDir, "INDEX.md");
|
|
2353
|
+
if (!existsSync9(sessionsDir)) {
|
|
2354
|
+
console.log(chalk4.yellow("No sessions directory. Run `npx qualiow init` first, then start a session."));
|
|
2355
|
+
return;
|
|
2356
|
+
}
|
|
2357
|
+
const rows = readSessionIndex(indexPath);
|
|
2358
|
+
const indexedDirs = new Set(rows.map((r) => basename6(r.report.replace(/\/session-report\.md$/, ""))));
|
|
2359
|
+
const unindexed = readdirSync5(sessionsDir, { withFileTypes: true }).filter((d) => d.isDirectory() && SESSION_DIR_RE.test(d.name) && !indexedDirs.has(d.name)).map((d) => d.name).sort();
|
|
2360
|
+
console.log(chalk4.cyan.bold("\nSessions:"));
|
|
2361
|
+
console.log("");
|
|
2362
|
+
if (rows.length === 0 && unindexed.length === 0) {
|
|
2363
|
+
console.log(chalk4.yellow(" No sessions recorded yet."));
|
|
2364
|
+
console.log(chalk4.white(" Start one with: /qa-explore <url>"));
|
|
2365
|
+
console.log("");
|
|
2366
|
+
return;
|
|
2367
|
+
}
|
|
2368
|
+
const widths = [16, 8, 22, 5, 9, 12];
|
|
2369
|
+
const header = INDEX_COLUMNS.map((c, i) => i < widths.length ? pad2(c, widths[i]) : c).join(" ");
|
|
2370
|
+
console.log(chalk4.bold(` ${header}`));
|
|
2371
|
+
console.log(` ${widths.map((w) => "\u2500".repeat(w)).join(" ")} ${"\u2500".repeat(30)}`);
|
|
2372
|
+
for (const r of rows) {
|
|
2373
|
+
console.log(
|
|
2374
|
+
` ${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}`
|
|
2375
|
+
);
|
|
2376
|
+
}
|
|
2377
|
+
for (const d of unindexed) {
|
|
2378
|
+
console.log(chalk4.gray(` ${pad2(d.slice(0, 15), 16)} ${pad2("", 8)} ${pad2("", 22)} ${pad2("", 5)} ${pad2("", 9)} ${pad2("unindexed", 12)} ${d}`));
|
|
2379
|
+
}
|
|
2380
|
+
console.log("");
|
|
2381
|
+
console.log(chalk4.white(` Total: ${rows.length} session(s)` + (unindexed.length ? chalk4.gray(` (+${unindexed.length} unindexed)`) : "")));
|
|
2382
|
+
console.log("");
|
|
2383
|
+
}
|
|
2384
|
+
function listKnowledge(cwd) {
|
|
2385
|
+
const knowledgeDir = resolve6(cwd, "data", "knowledge");
|
|
2386
|
+
const manifestPath = join9(knowledgeDir, "manifest.yml");
|
|
2387
|
+
if (!existsSync9(manifestPath)) {
|
|
2388
|
+
console.log(chalk4.yellow("No knowledge base found. Run `npx qualiow init` first."));
|
|
2389
|
+
return;
|
|
2390
|
+
}
|
|
2391
|
+
const manifest = parseYaml3(readFileSync8(manifestPath, "utf-8"));
|
|
2392
|
+
const filesOnDisk = globSync3(join9(knowledgeDir, "releases", "*", "entries", "*.yml")).length;
|
|
2393
|
+
console.log(chalk4.cyan.bold("\nKnowledge Base:"));
|
|
2394
|
+
console.log(chalk4.white(` Version: ${manifest.version} | Entries: ${manifest.entries.length}`));
|
|
2395
|
+
if (filesOnDisk !== manifest.entries.length || manifest.stats.total_entries !== filesOnDisk) {
|
|
2396
|
+
console.log(
|
|
2397
|
+
chalk4.yellow(
|
|
2398
|
+
` \u26A0 Registry (${manifest.entries.length}) / stats (${manifest.stats.total_entries}) disagree with ${filesOnDisk} entry files \u2014 run: npx qualiow kb sync`
|
|
2399
|
+
)
|
|
2400
|
+
);
|
|
2401
|
+
}
|
|
2402
|
+
console.log("");
|
|
2403
|
+
const grouped = /* @__PURE__ */ new Map();
|
|
2404
|
+
for (const entry of manifest.entries) {
|
|
2405
|
+
const list = grouped.get(entry.type) ?? [];
|
|
2406
|
+
list.push(entry);
|
|
2407
|
+
grouped.set(entry.type, list);
|
|
2408
|
+
}
|
|
2409
|
+
for (const [type, entries] of grouped) {
|
|
2410
|
+
console.log(chalk4.cyan(` ${type.charAt(0).toUpperCase() + type.slice(1)}s (${entries.length}):`));
|
|
2411
|
+
for (const entry of entries) {
|
|
2412
|
+
const priorityColor = entry.priority === "high" ? chalk4.red : entry.priority === "medium" ? chalk4.yellow : chalk4.white;
|
|
2413
|
+
const tags = entry.tags.map((t) => chalk4.gray(t)).join(", ");
|
|
2414
|
+
console.log(` ${priorityColor(`[${entry.priority}]`)} ${entry.id} ${chalk4.gray("tags:")} ${tags}`);
|
|
2415
|
+
}
|
|
2416
|
+
console.log("");
|
|
2417
|
+
}
|
|
2418
|
+
}
|
|
2419
|
+
function listTargets(cwd) {
|
|
2420
|
+
const targetsDir = resolve6(cwd, "data", "targets");
|
|
2421
|
+
if (!existsSync9(targetsDir)) {
|
|
2422
|
+
console.log(chalk4.yellow("No targets found. Run `npx qualiow init` first."));
|
|
2423
|
+
return;
|
|
2424
|
+
}
|
|
2425
|
+
const files = readdirSync5(targetsDir).filter((f) => f.endsWith(".yml")).sort();
|
|
2426
|
+
const projectLocal = resolve6(cwd, "qa", "target.yml");
|
|
2427
|
+
if (files.length === 0 && !existsSync9(projectLocal)) {
|
|
2428
|
+
console.log(chalk4.yellow("No target configurations found."));
|
|
2429
|
+
return;
|
|
2430
|
+
}
|
|
2431
|
+
console.log(chalk4.cyan.bold("\nTargets:"));
|
|
2432
|
+
console.log("");
|
|
2433
|
+
const header = ` ${pad2("File", 34)} ${pad2("Name", 32)} ${pad2("Domain", 11)} ${pad2("Auth", 16)} Base URL`;
|
|
2434
|
+
console.log(chalk4.bold(header));
|
|
2435
|
+
console.log(` ${"\u2500".repeat(34)} ${"\u2500".repeat(32)} ${"\u2500".repeat(11)} ${"\u2500".repeat(16)} ${"\u2500".repeat(30)}`);
|
|
2436
|
+
const printTarget = (label, path) => {
|
|
2437
|
+
try {
|
|
2438
|
+
const target = parseYaml3(readFileSync8(path, "utf-8"));
|
|
2439
|
+
const url = target.base_url || target.web?.base_url || chalk4.gray("(none)");
|
|
2440
|
+
console.log(
|
|
2441
|
+
` ${pad2(label, 34)} ${pad2(target.name, 32)} ${pad2(target.domain, 11)} ${pad2(target.auth?.strategy ?? "", 16)} ${url}`
|
|
2442
|
+
);
|
|
2443
|
+
} catch {
|
|
2444
|
+
console.log(` ${chalk4.red("ERROR")} Could not parse ${label}`);
|
|
2445
|
+
}
|
|
2446
|
+
};
|
|
2447
|
+
if (existsSync9(projectLocal)) printTarget("qa/target.yml", projectLocal);
|
|
2448
|
+
for (const file of files) printTarget(`data/targets/${file}`, join9(targetsDir, file));
|
|
2449
|
+
console.log("");
|
|
2450
|
+
console.log(chalk4.white(` Total: ${files.length + (existsSync9(projectLocal) ? 1 : 0)} target(s)`));
|
|
2451
|
+
console.log("");
|
|
2452
|
+
}
|
|
2453
|
+
function listDomains(cwd) {
|
|
2454
|
+
const domainsDir = resolve6(cwd, "data", "domains");
|
|
2455
|
+
if (!existsSync9(domainsDir)) {
|
|
2456
|
+
console.log(chalk4.yellow("No domain configs found. Run `npx qualiow init` first."));
|
|
2457
|
+
return;
|
|
2458
|
+
}
|
|
2459
|
+
const files = readdirSync5(domainsDir).filter((f) => f.endsWith(".yml")).sort();
|
|
2460
|
+
if (files.length === 0) {
|
|
2461
|
+
console.log(chalk4.yellow("No domain configurations found."));
|
|
2462
|
+
return;
|
|
2463
|
+
}
|
|
2464
|
+
console.log(chalk4.cyan.bold("\nDomains:"));
|
|
2465
|
+
console.log("");
|
|
2466
|
+
const header = ` ${pad2("File", 18)} ${pad2("Name", 32)} ${pad2("Checklist", 10)} ${pad2("Journeys", 9)} ${pad2("Patterns", 9)}`;
|
|
2467
|
+
console.log(chalk4.bold(header));
|
|
2468
|
+
console.log(` ${"\u2500".repeat(18)} ${"\u2500".repeat(32)} ${"\u2500".repeat(10)} ${"\u2500".repeat(9)} ${"\u2500".repeat(9)}`);
|
|
2469
|
+
for (const file of files) {
|
|
2470
|
+
try {
|
|
2471
|
+
const domain = parseYaml3(readFileSync8(join9(domainsDir, file), "utf-8"));
|
|
2472
|
+
const patterns = Object.values(domain.must_test_patterns ?? {}).reduce((n, arr) => n + arr.length, 0);
|
|
2473
|
+
console.log(
|
|
2474
|
+
` ${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)}`
|
|
2475
|
+
);
|
|
2476
|
+
} catch {
|
|
2477
|
+
console.log(` ${chalk4.red("ERROR")} Could not parse ${file}`);
|
|
2478
|
+
}
|
|
2479
|
+
}
|
|
2480
|
+
console.log("");
|
|
2481
|
+
console.log(chalk4.white(` Total: ${files.length} domain(s)`));
|
|
2482
|
+
console.log("");
|
|
2483
|
+
}
|
|
2484
|
+
function pad2(str, len) {
|
|
2485
|
+
if (str.length >= len) return str.slice(0, len);
|
|
2486
|
+
return str + " ".repeat(len - str.length);
|
|
2487
|
+
}
|
|
2488
|
+
|
|
2489
|
+
// src/cli/commands/validate.ts
|
|
2490
|
+
import { Command as Command5 } from "commander";
|
|
2491
|
+
import { resolve as resolve7, relative as relative5, join as join10 } from "path";
|
|
2492
|
+
import { existsSync as existsSync10 } from "fs";
|
|
2493
|
+
import { globSync as globSync4 } from "glob";
|
|
2494
|
+
import chalk5 from "chalk";
|
|
2495
|
+
function runValidate(options, cwd) {
|
|
2496
|
+
const dataDir = resolve7(cwd, "data");
|
|
2497
|
+
const runAll = options.all || !options.targets && !options.knowledge && !options.domains && !options.kb;
|
|
2498
|
+
if (!existsSync10(dataDir)) {
|
|
2499
|
+
throw new Error("data/ directory not found. Run `npx qualiow init` first.");
|
|
2500
|
+
}
|
|
2501
|
+
const results = [];
|
|
2502
|
+
const section = (title, files, fn) => {
|
|
2503
|
+
console.log(chalk5.cyan.bold(`
|
|
2504
|
+
${title} (${files.length} files):`));
|
|
2505
|
+
for (const file of files) {
|
|
2506
|
+
const result = fn(file);
|
|
2507
|
+
results.push(result);
|
|
2508
|
+
printResult(result, cwd);
|
|
2509
|
+
}
|
|
2510
|
+
};
|
|
2511
|
+
if (runAll || options.targets) {
|
|
2512
|
+
const files = globSync4(resolve7(dataDir, "targets", "*.yml")).sort();
|
|
2513
|
+
const projectLocal = join10(cwd, "qa", "target.yml");
|
|
2514
|
+
if (existsSync10(projectLocal)) files.unshift(projectLocal);
|
|
2515
|
+
section("Targets", files, validateTargetConfig);
|
|
2516
|
+
}
|
|
2517
|
+
if (runAll || options.domains) {
|
|
2518
|
+
section("Domains", globSync4(resolve7(dataDir, "domains", "*.yml")).sort(), validateDomainConfig);
|
|
2519
|
+
}
|
|
2520
|
+
if (runAll || options.knowledge) {
|
|
2521
|
+
section(
|
|
2522
|
+
"Knowledge entries",
|
|
2523
|
+
globSync4(resolve7(dataDir, "knowledge", "releases", "**", "entries", "*.yml")).sort(),
|
|
2524
|
+
validateKnowledgeEntry
|
|
2525
|
+
);
|
|
2526
|
+
}
|
|
2527
|
+
if (runAll || options.kb) {
|
|
2528
|
+
if (existsSync10(join10(dataDir, "knowledge", "manifest.yml"))) {
|
|
2529
|
+
console.log(chalk5.cyan.bold("\nKnowledge base:"));
|
|
2530
|
+
for (const result of validateKnowledgeBase(dataDir)) {
|
|
2531
|
+
results.push(result);
|
|
2532
|
+
printResult(result, cwd);
|
|
2533
|
+
}
|
|
2534
|
+
} else {
|
|
2535
|
+
console.log(chalk5.yellow("\n No knowledge/manifest.yml found"));
|
|
2536
|
+
}
|
|
2537
|
+
}
|
|
2538
|
+
const total = results.length;
|
|
2539
|
+
const passed = results.filter((r) => r.valid).length;
|
|
2540
|
+
const failed = total - passed;
|
|
2541
|
+
console.log("");
|
|
2542
|
+
console.log(chalk5.bold("Summary:"));
|
|
2543
|
+
console.log(
|
|
2544
|
+
` ${total} checks, ${chalk5.green(`${passed} passed`)}, ${failed > 0 ? chalk5.red(`${failed} failed`) : chalk5.green("0 failed")}`
|
|
2545
|
+
);
|
|
2546
|
+
console.log("");
|
|
2547
|
+
return failed;
|
|
2548
|
+
}
|
|
2549
|
+
function printResult(result, cwd) {
|
|
2550
|
+
const relPath = relative5(cwd, result.file);
|
|
2551
|
+
if (result.valid) {
|
|
2552
|
+
console.log(` ${chalk5.green("PASS")} ${relPath}`);
|
|
2553
|
+
} else {
|
|
2554
|
+
console.log(` ${chalk5.red("FAIL")} ${relPath}`);
|
|
2555
|
+
for (const err of result.errors ?? []) {
|
|
2556
|
+
const pathStr = err.path ? `[${err.path}] ` : "";
|
|
2557
|
+
console.log(` ${chalk5.red("\u2192")} ${pathStr}${err.message}`);
|
|
2558
|
+
}
|
|
2559
|
+
}
|
|
2560
|
+
}
|
|
2561
|
+
|
|
2562
|
+
// src/cli/commands/kb.ts
|
|
2563
|
+
import { Command as Command6 } from "commander";
|
|
2564
|
+
import { resolve as resolve8 } from "path";
|
|
2565
|
+
import { existsSync as existsSync11 } from "fs";
|
|
2566
|
+
import chalk6 from "chalk";
|
|
2567
|
+
function runKb(mode, cwd) {
|
|
2568
|
+
const dataDir = resolve8(cwd, "data");
|
|
2569
|
+
if (!existsSync11(resolve8(dataDir, "knowledge", "manifest.yml"))) {
|
|
2570
|
+
throw new Error("data/knowledge/manifest.yml not found. Run `npx qualiow init` first.");
|
|
2571
|
+
}
|
|
2572
|
+
return syncKnowledgeManifest(dataDir, { check: mode === "check" });
|
|
2573
|
+
}
|
|
1235
2574
|
export {
|
|
2575
|
+
ALL_BUGS_COLUMNS,
|
|
2576
|
+
ALL_BUGS_MD_HEADER,
|
|
1236
2577
|
AuthConfigSchema,
|
|
1237
2578
|
BrowserConfigSchema,
|
|
2579
|
+
CONFIDENTIALITY_HEADER_MD,
|
|
2580
|
+
CONFIDENTIALITY_LINES,
|
|
2581
|
+
CONFIDENTIALITY_NOTICE,
|
|
1238
2582
|
DomainConfigSchema,
|
|
2583
|
+
INDEX_COLUMNS,
|
|
2584
|
+
INDEX_MD_HEADER,
|
|
1239
2585
|
JourneySchema,
|
|
2586
|
+
KnowledgeChangelogSchema,
|
|
1240
2587
|
KnowledgeEntryContentSchema,
|
|
1241
2588
|
KnowledgeEntrySchema,
|
|
1242
2589
|
KnowledgeManifestEntrySchema,
|
|
1243
2590
|
KnowledgeManifestSchema,
|
|
1244
2591
|
KnowledgeManifestStatsSchema,
|
|
2592
|
+
KnowledgeReleaseSchema,
|
|
1245
2593
|
LoadingStrategySchema,
|
|
1246
2594
|
MobileAppConfigSchema,
|
|
1247
2595
|
MobileDeviceConfigSchema,
|
|
1248
2596
|
MobileScopeConfigSchema,
|
|
1249
2597
|
MobileTargetConfigSchema,
|
|
1250
2598
|
MobileWebConfigSchema,
|
|
2599
|
+
QUALIOW_GITIGNORE_ENTRIES,
|
|
2600
|
+
QUALIOW_GITIGNORE_HEADER,
|
|
2601
|
+
REDACTION_CATEGORIES,
|
|
2602
|
+
SESSION_DIR_RE,
|
|
2603
|
+
SESSION_KINDS,
|
|
1251
2604
|
SafetyConfigSchema,
|
|
1252
2605
|
ScopeConfigSchema,
|
|
1253
2606
|
SessionMetricsSchema,
|
|
@@ -1256,17 +2609,49 @@ export {
|
|
|
1256
2609
|
TargetConfigSchema,
|
|
1257
2610
|
WebTargetConfigSchema,
|
|
1258
2611
|
appendSessionMetrics,
|
|
2612
|
+
appendSessionMetricsDeduped,
|
|
2613
|
+
buildManifestRegistry,
|
|
2614
|
+
computeStats,
|
|
1259
2615
|
containsSecrets,
|
|
2616
|
+
csvEscape,
|
|
2617
|
+
extractCoverage,
|
|
2618
|
+
extractListSection,
|
|
2619
|
+
extractReportMeta,
|
|
1260
2620
|
generateHtmlReport,
|
|
1261
2621
|
generateJiraExport,
|
|
1262
2622
|
generateJsonReport,
|
|
2623
|
+
generateMarkdownSummary,
|
|
2624
|
+
getPackageRoot,
|
|
2625
|
+
getPackageVersion,
|
|
2626
|
+
hasConfidentialityHeader,
|
|
2627
|
+
listReleaseDirs,
|
|
2628
|
+
loadSessionForOutput,
|
|
2629
|
+
mergeGitignore,
|
|
1263
2630
|
parseBugReport,
|
|
2631
|
+
parseMarkdownTable,
|
|
1264
2632
|
parseSession,
|
|
2633
|
+
parseSessionDirName,
|
|
2634
|
+
parseTimeBox,
|
|
1265
2635
|
readAllMetrics,
|
|
2636
|
+
readSessionIndex,
|
|
1266
2637
|
redact,
|
|
2638
|
+
resolveDomainPath,
|
|
2639
|
+
resolveSessionDir,
|
|
2640
|
+
resolveSkillsSource,
|
|
2641
|
+
resolveTargetPath,
|
|
2642
|
+
runExplore,
|
|
2643
|
+
runInit,
|
|
2644
|
+
runKb,
|
|
2645
|
+
runList,
|
|
2646
|
+
runReport,
|
|
2647
|
+
runValidate,
|
|
2648
|
+
sessionDirName,
|
|
2649
|
+
sessionTimestamp,
|
|
2650
|
+
slugify,
|
|
2651
|
+
syncKnowledgeManifest,
|
|
1267
2652
|
validateAllConfigs,
|
|
1268
2653
|
validateDomainConfig,
|
|
2654
|
+
validateKnowledgeBase,
|
|
1269
2655
|
validateKnowledgeEntry,
|
|
1270
2656
|
validateTargetConfig
|
|
1271
2657
|
};
|
|
1272
|
-
//# sourceMappingURL=index.js.map
|