qualiow-exploratory-testing 1.2.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 +428 -179
- 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/domains/identity.yml +138 -0
- package/data/knowledge/changelog.yml +104 -0
- package/data/knowledge/learned-patterns.md +172 -86
- package/data/knowledge/manifest.yml +481 -70
- 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.2.0/entries/technique-contract-narrowing.yml +150 -0
- package/data/knowledge/releases/v0.2.0/entries/technique-test-suite-audit.yml +116 -0
- package/data/knowledge/releases/v0.2.0/release.yml +20 -0
- package/data/knowledge/releases/v0.3.0/entries/technique-functional-diff-analysis.yml +119 -0
- package/data/knowledge/releases/v0.3.0/entries/technique-llm-output-verification.yml +102 -0
- package/data/knowledge/releases/v0.3.0/entries/technique-verification-mode-selection.yml +153 -0
- package/data/knowledge/releases/v0.3.0/release.yml +25 -0
- package/data/knowledge/releases/v0.4.0/entries/technique-authenticated-api-probing.yml +137 -0
- package/data/knowledge/releases/v0.4.0/entries/technique-environment-fingerprinting.yml +113 -0
- package/data/knowledge/releases/v0.4.0/entries/technique-silent-failure-audit.yml +86 -0
- package/data/knowledge/releases/v0.4.0/entries/technique-ui-api-differential.yml +97 -0
- package/data/knowledge/releases/v0.4.0/release.yml +28 -0
- package/data/knowledge/releases/v0.5.0/entries/technique-config-surface-verification.yml +77 -0
- package/data/knowledge/releases/v0.5.0/entries/technique-derived-value-verification.yml +81 -0
- package/data/knowledge/releases/v0.5.0/entries/technique-expected-behaviour-specification.yml +97 -0
- package/data/knowledge/releases/v0.5.0/entries/technique-presentation-integrity.yml +78 -0
- package/data/knowledge/releases/v0.5.0/entries/technique-release-readiness-verification.yml +110 -0
- package/data/knowledge/releases/v0.5.0/release.yml +33 -0
- 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-backend.yml +123 -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 +99 -0
- package/data/templates/bug-report.md +29 -151
- package/data/templates/coverage-map.md +23 -6
- package/data/templates/expected-behaviour.md +94 -0
- package/data/templates/session-charter.md +3 -0
- package/data/templates/session-report.md +57 -80
- package/dist/cli/index.js +1500 -739
- package/dist/index.d.ts +673 -75
- package/dist/index.js +1664 -270
- package/docs/BACKEND-VERIFICATION.md +307 -0
- package/docs/GETTING-STARTED.md +188 -128
- package/docs/MOBILE-SETUP.md +149 -18
- package/package.json +32 -16
- 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 +172 -0
- package/skills/qa-verify-backend/phases/00-setup.md +142 -0
- package/skills/qa-verify-backend/phases/01-ac-decomposition.md +58 -0
- package/skills/qa-verify-backend/phases/02-static-review.md +71 -0
- package/skills/qa-verify-backend/phases/03-live-verification.md +62 -0
- package/skills/qa-verify-backend/phases/03b-api-verification.md +170 -0
- package/skills/qa-verify-backend/phases/04-e2e-trigger.md +82 -0
- package/skills/qa-verify-backend/phases/05-reporting.md +163 -0
- package/skills/qa-verify-backend/references/api-probes.md +168 -0
- package/skills/qa-verify-backend/references/aws-readonly-probes.md +156 -0
- package/skills/qa-verify-backend/references/environment-fingerprinting.md +104 -0
- package/skills/qa-verify-backend/references/payload-verification.md +112 -0
- package/skills/qa-verify-backend/references/release-readiness.md +97 -0
- package/skills/qa-verify-backend/references/safety-rules.md +95 -0
- 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,38 +17,92 @@ 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();
|
|
53
|
+
var EnvironmentConfigSchema = z.object({
|
|
54
|
+
kind: z.enum(["dev", "ephemeral", "staging", "production"]),
|
|
55
|
+
destroyed_automatically: z.boolean().optional()
|
|
56
|
+
}).strict();
|
|
57
|
+
var BackendConfigSchema = z.object({
|
|
58
|
+
provider: z.enum(["aws"]).optional(),
|
|
59
|
+
aws_profile_env: z.string().optional(),
|
|
60
|
+
region_env: z.string().optional(),
|
|
61
|
+
region: z.string().optional(),
|
|
62
|
+
// Expected account. The skill compares it to `sts get-caller-identity` and
|
|
63
|
+
// stops the live lane on a mismatch rather than probing someone else's account.
|
|
64
|
+
account_id: z.string().optional(),
|
|
65
|
+
env_suffix: z.string().optional(),
|
|
66
|
+
// Free-form logical name -> deployed resource name (config_table, dlq, ...).
|
|
67
|
+
resources: z.record(z.string(), z.string()).optional(),
|
|
68
|
+
notes: z.string().optional()
|
|
69
|
+
}).strict();
|
|
70
|
+
var ApiSurfaceConfigSchema = z.object({
|
|
71
|
+
// Defaults to the target's base_url when omitted.
|
|
72
|
+
base_url: z.string().optional(),
|
|
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).
|
|
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(),
|
|
80
|
+
// Persistent browser profile directory holding the authenticated session,
|
|
81
|
+
// e.g. `.auth/my-service-dev-profile`. Gitignored.
|
|
82
|
+
browser_profile: z.string().optional(),
|
|
83
|
+
// Endpoint returning the deployed build, used to fingerprint the environment.
|
|
84
|
+
version_endpoint: z.string().optional(),
|
|
85
|
+
// Logical name -> "VERB /path", e.g. search: "POST /api/v1/search".
|
|
86
|
+
endpoints: z.record(z.string(), z.string()).optional(),
|
|
87
|
+
// The ONLY endpoints the read-only API lane may call without asking.
|
|
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(),
|
|
93
|
+
// Other target ids to run the same matrix against, for parity comparison.
|
|
94
|
+
parity_targets: z.array(z.string()).optional(),
|
|
95
|
+
// Flag name -> where its deployed value is declared for this environment.
|
|
96
|
+
// A flag can select between two implementations inside one identical build.
|
|
97
|
+
feature_flags: z.record(z.string(), z.string()).optional(),
|
|
98
|
+
notes: z.string().optional()
|
|
99
|
+
}).strict();
|
|
100
|
+
var SourceBranchConfigSchema = z.object({
|
|
101
|
+
repo_path: z.string(),
|
|
102
|
+
branch: z.string(),
|
|
103
|
+
base_branch: z.string().optional(),
|
|
104
|
+
components: z.record(z.string(), z.string()).optional()
|
|
105
|
+
}).strict();
|
|
52
106
|
var WebTargetConfigSchema = z.object({
|
|
53
107
|
id: z.string().min(1),
|
|
54
108
|
name: z.string().min(1),
|
|
@@ -60,8 +114,14 @@ var WebTargetConfigSchema = z.object({
|
|
|
60
114
|
browser: BrowserConfigSchema,
|
|
61
115
|
scope: ScopeConfigSchema,
|
|
62
116
|
safety: SafetyConfigSchema.optional(),
|
|
117
|
+
// Optional blocks consumed by /qa-verify-backend. A target without them is
|
|
118
|
+
// still a valid /qa-explore target.
|
|
119
|
+
environment: EnvironmentConfigSchema.optional(),
|
|
120
|
+
backend: BackendConfigSchema.optional(),
|
|
121
|
+
api: ApiSurfaceConfigSchema.optional(),
|
|
122
|
+
source: SourceBranchConfigSchema.optional(),
|
|
63
123
|
notes: z.string().optional()
|
|
64
|
-
});
|
|
124
|
+
}).strict();
|
|
65
125
|
var MobileDeviceConfigSchema = z.object({
|
|
66
126
|
name: z.string().optional(),
|
|
67
127
|
// iOS simulator name (portable across machines)
|
|
@@ -71,7 +131,7 @@ var MobileDeviceConfigSchema = z.object({
|
|
|
71
131
|
// Android AVD name
|
|
72
132
|
serial: z.string().optional()
|
|
73
133
|
// Android serial once booted (e.g. emulator-5554)
|
|
74
|
-
});
|
|
134
|
+
}).strict();
|
|
75
135
|
var MobileAppConfigSchema = z.object({
|
|
76
136
|
bundle_id: z.string().optional(),
|
|
77
137
|
// iOS bundle id (or browser bundle in web mode)
|
|
@@ -81,21 +141,21 @@ var MobileAppConfigSchema = z.object({
|
|
|
81
141
|
// iOS .app artifact(s) — native mode
|
|
82
142
|
apk_paths: z.array(z.string()).optional()
|
|
83
143
|
// Android APK(s) — native mode
|
|
84
|
-
});
|
|
144
|
+
}).strict();
|
|
85
145
|
var MobileWebConfigSchema = z.object({
|
|
86
146
|
base_url: z.string().url(),
|
|
87
147
|
start_url: z.string().url().optional()
|
|
88
|
-
});
|
|
148
|
+
}).strict();
|
|
89
149
|
var SourceRepoConfigSchema = z.object({
|
|
90
150
|
path: z.string(),
|
|
91
151
|
build_commands: z.record(z.string(), z.string()).optional()
|
|
92
|
-
});
|
|
152
|
+
}).strict();
|
|
93
153
|
var MobileScopeConfigSchema = z.object({
|
|
94
154
|
start_screen: z.string().optional(),
|
|
95
155
|
start_url: z.string().optional(),
|
|
96
156
|
include_patterns: z.array(z.string()).optional(),
|
|
97
157
|
exclude_patterns: z.array(z.string()).optional()
|
|
98
|
-
});
|
|
158
|
+
}).strict();
|
|
99
159
|
var MobileTargetConfigSchema = z.object({
|
|
100
160
|
id: z.string().min(1),
|
|
101
161
|
name: z.string().min(1),
|
|
@@ -111,15 +171,22 @@ var MobileTargetConfigSchema = z.object({
|
|
|
111
171
|
safety: SafetyConfigSchema.optional(),
|
|
112
172
|
source_repo: SourceRepoConfigSchema.optional(),
|
|
113
173
|
notes: z.string().optional()
|
|
114
|
-
});
|
|
115
|
-
var TargetConfigSchema = z.
|
|
116
|
-
|
|
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;
|
|
117
181
|
const branch = isMobile ? MobileTargetConfigSchema : WebTargetConfigSchema;
|
|
118
182
|
const result = branch.safeParse(data);
|
|
119
183
|
if (!result.success) {
|
|
120
|
-
for (const issue of result.error.issues)
|
|
184
|
+
for (const issue of result.error.issues) {
|
|
121
185
|
ctx.addIssue(issue);
|
|
186
|
+
}
|
|
187
|
+
return z.NEVER;
|
|
122
188
|
}
|
|
189
|
+
return result.data;
|
|
123
190
|
});
|
|
124
191
|
|
|
125
192
|
// src/schemas/knowledge-entry.schema.ts
|
|
@@ -177,22 +244,28 @@ var KnowledgeManifestSchema = z3.object({
|
|
|
177
244
|
|
|
178
245
|
// src/schemas/domain-config.schema.ts
|
|
179
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();
|
|
180
253
|
var JourneySchema = z4.object({
|
|
181
|
-
id: z4.string().min(1),
|
|
182
254
|
name: z4.string().min(1),
|
|
183
|
-
|
|
184
|
-
|
|
185
|
-
risk: z4.enum(["high", "medium", "low"])
|
|
186
|
-
});
|
|
255
|
+
steps: z4.array(z4.string()).min(1)
|
|
256
|
+
}).strict();
|
|
187
257
|
var DomainConfigSchema = z4.object({
|
|
188
258
|
id: z4.string().min(1),
|
|
189
259
|
name: z4.string().min(1),
|
|
190
|
-
risk_ranking:
|
|
260
|
+
risk_ranking: RiskRankingSchema,
|
|
191
261
|
completeness_checklist: z4.array(z4.string()).min(1),
|
|
192
262
|
data_integrity_checks: z4.array(z4.string()).min(1),
|
|
193
263
|
journeys: z4.array(JourneySchema).min(1),
|
|
194
|
-
|
|
195
|
-
|
|
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();
|
|
196
269
|
|
|
197
270
|
// src/schemas/session-metrics.schema.ts
|
|
198
271
|
import { z as z5 } from "zod";
|
|
@@ -209,35 +282,138 @@ var SessionMetricsSchema = z5.object({
|
|
|
209
282
|
duration_min: z5.number().min(0),
|
|
210
283
|
bugs_found: z5.number().int().min(0),
|
|
211
284
|
severity_counts: SeverityCountsSchema,
|
|
212
|
-
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"]
|
|
213
312
|
});
|
|
214
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
|
+
|
|
215
335
|
// src/utils/redact.ts
|
|
216
|
-
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
|
+
},
|
|
217
378
|
{
|
|
218
|
-
name: "
|
|
219
|
-
pattern: /
|
|
220
|
-
|
|
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]"
|
|
221
397
|
},
|
|
222
398
|
{
|
|
223
399
|
name: "API key",
|
|
224
|
-
pattern: /api[_
|
|
225
|
-
|
|
400
|
+
pattern: /(x-api-key|api[_-]?key)(\s*[:=]\s*)["']?[A-Za-z0-9._-]{8,}["']?/gi,
|
|
401
|
+
replace: (_m, k, sep) => `${k}${sep}[REDACTED]`
|
|
226
402
|
},
|
|
227
403
|
{
|
|
228
404
|
name: "Password",
|
|
229
|
-
pattern: /password[
|
|
230
|
-
|
|
405
|
+
pattern: /(password|passwd|pwd)(\s*[:=]\s*)["']?[^\s,}"']+["']?/gi,
|
|
406
|
+
replace: (_m, k, sep) => `${k}${sep}[REDACTED]`
|
|
231
407
|
},
|
|
232
408
|
{
|
|
233
409
|
name: "Token",
|
|
234
|
-
pattern: /token[
|
|
235
|
-
|
|
410
|
+
pattern: /(access[_-]?token|refresh[_-]?token|token)(\s*[:=]\s*)["']?[A-Za-z0-9._-]{8,}["']?/gi,
|
|
411
|
+
replace: (_m, k, sep) => `${k}${sep}[REDACTED]`
|
|
236
412
|
},
|
|
237
413
|
{
|
|
238
414
|
name: "Secret",
|
|
239
|
-
pattern: /secret[
|
|
240
|
-
|
|
415
|
+
pattern: /([a-z_]*secret)(\s*[:=]\s*)["']?[^\s,}"']+["']?/gi,
|
|
416
|
+
replace: (_m, k, sep) => `${k}${sep}[REDACTED]`
|
|
241
417
|
},
|
|
242
418
|
{
|
|
243
419
|
name: "SSN",
|
|
@@ -246,44 +422,146 @@ var REDACTION_PATTERNS = [
|
|
|
246
422
|
},
|
|
247
423
|
{
|
|
248
424
|
name: "Credit card number",
|
|
249
|
-
pattern: /\b\d{
|
|
250
|
-
|
|
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
|
+
}
|
|
251
432
|
}
|
|
252
433
|
];
|
|
253
|
-
function redact(text) {
|
|
254
|
-
const redactions =
|
|
434
|
+
function redact(text, opts = {}) {
|
|
435
|
+
const redactions = /* @__PURE__ */ new Set();
|
|
255
436
|
let result = text;
|
|
256
|
-
|
|
257
|
-
|
|
258
|
-
|
|
259
|
-
|
|
260
|
-
pattern.
|
|
261
|
-
|
|
262
|
-
}
|
|
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
|
+
});
|
|
444
|
+
}
|
|
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);
|
|
263
456
|
}
|
|
264
|
-
return { text: result, redactions };
|
|
457
|
+
return { text: result, redactions: [...redactions] };
|
|
265
458
|
}
|
|
266
459
|
function containsSecrets(text) {
|
|
267
|
-
|
|
268
|
-
pattern.lastIndex = 0;
|
|
269
|
-
if (pattern.test(text)) {
|
|
270
|
-
return true;
|
|
271
|
-
}
|
|
272
|
-
}
|
|
273
|
-
return false;
|
|
460
|
+
return redact(text).redactions.length > 0;
|
|
274
461
|
}
|
|
462
|
+
var REDACTION_CATEGORIES = RULES.map((r) => r.name).concat("Email");
|
|
275
463
|
|
|
276
464
|
// src/utils/validate.ts
|
|
277
|
-
import { readFileSync } from "fs";
|
|
278
|
-
import { resolve, join } from "path";
|
|
279
|
-
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";
|
|
280
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";
|
|
281
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";
|
|
282
560
|
function validateYamlFile(filePath, schema) {
|
|
283
561
|
const absPath = resolve(filePath);
|
|
284
562
|
try {
|
|
285
|
-
const raw =
|
|
286
|
-
const data =
|
|
563
|
+
const raw = readFileSync2(absPath, "utf-8");
|
|
564
|
+
const data = parseYaml2(raw);
|
|
287
565
|
schema.parse(data);
|
|
288
566
|
return { file: absPath, valid: true };
|
|
289
567
|
} catch (err) {
|
|
@@ -309,68 +587,433 @@ function validateYamlFile(filePath, schema) {
|
|
|
309
587
|
};
|
|
310
588
|
}
|
|
311
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
|
+
}
|
|
312
612
|
function validateTargetConfig(filePath) {
|
|
313
|
-
return
|
|
613
|
+
return validateWithId(filePath, TargetConfigSchema);
|
|
314
614
|
}
|
|
315
615
|
function validateKnowledgeEntry(filePath) {
|
|
316
616
|
return validateYamlFile(filePath, KnowledgeEntrySchema);
|
|
317
617
|
}
|
|
318
618
|
function validateDomainConfig(filePath) {
|
|
319
|
-
return
|
|
619
|
+
return validateWithId(filePath, DomainConfigSchema);
|
|
620
|
+
}
|
|
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;
|
|
320
712
|
}
|
|
321
|
-
function validateAllConfigs(dataDir) {
|
|
713
|
+
function validateAllConfigs(dataDir, opts = {}) {
|
|
322
714
|
const results = [];
|
|
323
715
|
const absDir = resolve(dataDir);
|
|
324
|
-
const
|
|
325
|
-
for (const file of targetFiles) {
|
|
716
|
+
for (const file of globSync2(join2(absDir, "targets", "*.yml"))) {
|
|
326
717
|
results.push(validateTargetConfig(file));
|
|
327
718
|
}
|
|
328
|
-
|
|
329
|
-
|
|
330
|
-
|
|
331
|
-
|
|
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
|
+
)) {
|
|
332
731
|
results.push(validateKnowledgeEntry(file));
|
|
333
732
|
}
|
|
733
|
+
if (existsSync2(join2(absDir, "knowledge", "manifest.yml"))) {
|
|
734
|
+
results.push(...validateKnowledgeBase(absDir));
|
|
735
|
+
}
|
|
334
736
|
return results;
|
|
335
737
|
}
|
|
336
738
|
|
|
337
739
|
// src/utils/metrics.ts
|
|
338
|
-
import { readFileSync as
|
|
339
|
-
import { join as
|
|
740
|
+
import { readFileSync as readFileSync3, appendFileSync, existsSync as existsSync3, mkdirSync } from "fs";
|
|
741
|
+
import { join as join3, dirname } from "path";
|
|
340
742
|
var METRICS_FILENAME = "metrics.jsonl";
|
|
341
743
|
function appendSessionMetrics(outputDir, metrics) {
|
|
342
744
|
SessionMetricsSchema.parse(metrics);
|
|
343
|
-
const filePath =
|
|
745
|
+
const filePath = join3(outputDir, METRICS_FILENAME);
|
|
344
746
|
const dir = dirname(filePath);
|
|
345
|
-
if (!
|
|
747
|
+
if (!existsSync3(dir)) {
|
|
346
748
|
mkdirSync(dir, { recursive: true });
|
|
347
749
|
}
|
|
348
750
|
const line = JSON.stringify(metrics) + "\n";
|
|
349
751
|
appendFileSync(filePath, line, "utf-8");
|
|
350
752
|
}
|
|
351
753
|
function readAllMetrics(outputDir) {
|
|
352
|
-
const filePath =
|
|
353
|
-
if (!
|
|
754
|
+
const filePath = join3(outputDir, METRICS_FILENAME);
|
|
755
|
+
if (!existsSync3(filePath)) {
|
|
354
756
|
return [];
|
|
355
757
|
}
|
|
356
|
-
const content =
|
|
758
|
+
const content = readFileSync3(filePath, "utf-8").trim();
|
|
357
759
|
if (!content) {
|
|
358
760
|
return [];
|
|
359
761
|
}
|
|
360
762
|
const lines = content.split("\n");
|
|
361
763
|
const results = [];
|
|
362
764
|
for (const line of lines) {
|
|
363
|
-
if (line.trim())
|
|
364
|
-
|
|
365
|
-
|
|
765
|
+
if (!line.trim()) continue;
|
|
766
|
+
let parsed;
|
|
767
|
+
try {
|
|
768
|
+
parsed = JSON.parse(line);
|
|
769
|
+
} catch {
|
|
770
|
+
continue;
|
|
366
771
|
}
|
|
772
|
+
const result = SessionMetricsSchema.safeParse(parsed);
|
|
773
|
+
if (result.success) results.push(result.data);
|
|
367
774
|
}
|
|
368
775
|
return results;
|
|
369
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
|
+
}
|
|
370
1013
|
|
|
371
1014
|
// src/utils/parse-session.ts
|
|
372
|
-
import { readFileSync as
|
|
373
|
-
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";
|
|
374
1017
|
var SEVERITY_ORDER = {
|
|
375
1018
|
critical: 0,
|
|
376
1019
|
high: 1,
|
|
@@ -424,33 +1067,48 @@ function extractNumberedList(text) {
|
|
|
424
1067
|
}
|
|
425
1068
|
return steps;
|
|
426
1069
|
}
|
|
1070
|
+
function cleanValue(v) {
|
|
1071
|
+
return v.trim().replace(/^`|`$/g, "").trim();
|
|
1072
|
+
}
|
|
427
1073
|
function extractEvidence(content) {
|
|
428
|
-
const
|
|
429
|
-
|
|
1074
|
+
const evidence = {
|
|
1075
|
+
screenshots: [],
|
|
1076
|
+
videos: [],
|
|
1077
|
+
logs: [],
|
|
1078
|
+
console_errors: [],
|
|
1079
|
+
network_failures: []
|
|
1080
|
+
};
|
|
430
1081
|
const evidenceText = extractSection(content, "Evidence");
|
|
431
|
-
if (!evidenceText)
|
|
432
|
-
return { screenshots, console_errors };
|
|
433
|
-
}
|
|
1082
|
+
if (!evidenceText) return evidence;
|
|
434
1083
|
for (const line of evidenceText.split("\n")) {
|
|
435
1084
|
const trimmed = line.replace(/^[-*]\s*/, "").trim();
|
|
436
|
-
|
|
437
|
-
const
|
|
438
|
-
|
|
439
|
-
|
|
440
|
-
|
|
441
|
-
|
|
442
|
-
|
|
443
|
-
|
|
444
|
-
|
|
445
|
-
|
|
446
|
-
|
|
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);
|
|
447
1105
|
}
|
|
448
1106
|
}
|
|
449
|
-
return
|
|
1107
|
+
return evidence;
|
|
450
1108
|
}
|
|
451
1109
|
async function parseBugReport(filePath) {
|
|
452
|
-
const content =
|
|
453
|
-
const filename =
|
|
1110
|
+
const content = readFileSync5(filePath, "utf-8");
|
|
1111
|
+
const filename = basename4(filePath, ".md");
|
|
454
1112
|
const id = filename;
|
|
455
1113
|
let title = "";
|
|
456
1114
|
let component = "";
|
|
@@ -463,6 +1121,10 @@ async function parseBugReport(filePath) {
|
|
|
463
1121
|
component = componentMatch[1];
|
|
464
1122
|
title = title.replace(/^\[[^\]]+\]\s*/, "").trim();
|
|
465
1123
|
}
|
|
1124
|
+
const componentField = content.match(/\*\*Component:\*\*\s*(.+)/i);
|
|
1125
|
+
if (componentField) {
|
|
1126
|
+
component = cleanValue(componentField[1]);
|
|
1127
|
+
}
|
|
466
1128
|
if (!component) {
|
|
467
1129
|
const categoryMatch = content.match(/\|\s*Category\s*\|\s*(.+?)\s*\|/i);
|
|
468
1130
|
if (categoryMatch) {
|
|
@@ -477,8 +1139,14 @@ async function parseBugReport(filePath) {
|
|
|
477
1139
|
let url = "";
|
|
478
1140
|
const urlMatch = content.match(/\*\*URL:\*\*\s*(.+)/i) ?? content.match(/URL:\s*(https?:\/\/[^\s]+)/i);
|
|
479
1141
|
if (urlMatch) {
|
|
480
|
-
url = urlMatch[1]
|
|
1142
|
+
url = cleanValue(urlMatch[1]);
|
|
481
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();
|
|
482
1150
|
const expected = extractSection(content, "Expected").replace(/^_.*_\n?/, "").replace(/^>\s*/gm, "").trim();
|
|
483
1151
|
const actual = extractSection(content, "Actual").replace(/^_.*_\n?/, "").replace(/^>\s*/gm, "").trim();
|
|
484
1152
|
const stepsSection = extractSection(content, "Steps to Reproduce");
|
|
@@ -489,8 +1157,12 @@ async function parseBugReport(filePath) {
|
|
|
489
1157
|
id,
|
|
490
1158
|
title,
|
|
491
1159
|
severity,
|
|
1160
|
+
priority,
|
|
492
1161
|
component,
|
|
493
1162
|
url,
|
|
1163
|
+
environment,
|
|
1164
|
+
reproduction_rate,
|
|
1165
|
+
summary,
|
|
494
1166
|
expected,
|
|
495
1167
|
actual,
|
|
496
1168
|
steps,
|
|
@@ -499,33 +1171,33 @@ async function parseBugReport(filePath) {
|
|
|
499
1171
|
};
|
|
500
1172
|
}
|
|
501
1173
|
async function parseSession(sessionDir) {
|
|
502
|
-
const id =
|
|
1174
|
+
const id = basename4(sessionDir);
|
|
503
1175
|
let charter;
|
|
504
|
-
const charterPath =
|
|
505
|
-
if (
|
|
506
|
-
charter =
|
|
1176
|
+
const charterPath = join5(sessionDir, "charter.md");
|
|
1177
|
+
if (existsSync5(charterPath)) {
|
|
1178
|
+
charter = readFileSync5(charterPath, "utf-8");
|
|
507
1179
|
}
|
|
508
1180
|
let report;
|
|
509
|
-
const reportPath =
|
|
510
|
-
if (
|
|
511
|
-
report =
|
|
1181
|
+
const reportPath = join5(sessionDir, "session-report.md");
|
|
1182
|
+
if (existsSync5(reportPath)) {
|
|
1183
|
+
report = readFileSync5(reportPath, "utf-8");
|
|
512
1184
|
}
|
|
513
1185
|
const phases = [];
|
|
514
|
-
if (
|
|
515
|
-
const files =
|
|
1186
|
+
if (existsSync5(sessionDir)) {
|
|
1187
|
+
const files = readdirSync2(sessionDir);
|
|
516
1188
|
const phaseFiles = files.filter((f) => /^phase-\d+/i.test(f)).sort();
|
|
517
1189
|
for (const file of phaseFiles) {
|
|
518
|
-
const content =
|
|
1190
|
+
const content = readFileSync5(join5(sessionDir, file), "utf-8");
|
|
519
1191
|
const name = file.replace(/\.md$/, "");
|
|
520
1192
|
phases.push({ name, content });
|
|
521
1193
|
}
|
|
522
1194
|
}
|
|
523
|
-
const bugsDir =
|
|
1195
|
+
const bugsDir = join5(sessionDir, "bugs");
|
|
524
1196
|
const bugs = [];
|
|
525
|
-
if (
|
|
526
|
-
const bugFiles =
|
|
1197
|
+
if (existsSync5(bugsDir)) {
|
|
1198
|
+
const bugFiles = readdirSync2(bugsDir).filter((f) => /^BUG-.*\.md$/i.test(f)).sort();
|
|
527
1199
|
for (const file of bugFiles) {
|
|
528
|
-
const bug = await parseBugReport(
|
|
1200
|
+
const bug = await parseBugReport(join5(bugsDir, file));
|
|
529
1201
|
bugs.push(bug);
|
|
530
1202
|
}
|
|
531
1203
|
}
|
|
@@ -540,9 +1212,40 @@ async function parseSession(sessionDir) {
|
|
|
540
1212
|
}
|
|
541
1213
|
|
|
542
1214
|
// src/formatters/html-report.ts
|
|
543
|
-
import { readFileSync as readFileSync4, existsSync as existsSync3 } from "fs";
|
|
544
|
-
import { resolve as resolve2, extname } from "path";
|
|
545
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
|
+
}
|
|
546
1249
|
function extractReportMeta(report, sessionId) {
|
|
547
1250
|
const meta = {
|
|
548
1251
|
target: sessionId,
|
|
@@ -557,40 +1260,34 @@ function extractReportMeta(report, sessionId) {
|
|
|
557
1260
|
if (durationMatch) meta.duration = durationMatch[1].trim();
|
|
558
1261
|
const targetMatch = report.match(/\*\*Application:\*\*\s*(.+)/i) ?? report.match(/\*\*Target:\*\*\s*(.+)/i) ?? report.match(/\|\s*Target\s*\|\s*(.+?)\s*\|/i);
|
|
559
1262
|
if (targetMatch) meta.target = targetMatch[1].trim();
|
|
560
|
-
const summaryMatch = report.match(
|
|
1263
|
+
const summaryMatch = report.match(
|
|
1264
|
+
/##\s+Executive Summary\s*\n+([\s\S]*?)(?=\n##\s|\n---|$)/i
|
|
1265
|
+
);
|
|
561
1266
|
if (summaryMatch) meta.summary = summaryMatch[1].trim();
|
|
562
1267
|
return meta;
|
|
563
1268
|
}
|
|
564
1269
|
function extractCoverage(report) {
|
|
565
|
-
const
|
|
566
|
-
|
|
567
|
-
|
|
568
|
-
|
|
569
|
-
|
|
570
|
-
|
|
571
|
-
|
|
572
|
-
|
|
573
|
-
|
|
574
|
-
entries.push({
|
|
575
|
-
area: cells[0] || "",
|
|
576
|
-
status: cells[1] || "",
|
|
577
|
-
bugsFound: cells[3] || "0",
|
|
578
|
-
notes: cells[4] || ""
|
|
579
|
-
});
|
|
580
|
-
}
|
|
581
|
-
}
|
|
582
|
-
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
|
+
}));
|
|
583
1279
|
}
|
|
584
1280
|
function extractListSection(report, heading) {
|
|
585
1281
|
const items = [];
|
|
586
|
-
const regex = new RegExp(
|
|
1282
|
+
const regex = new RegExp(
|
|
1283
|
+
`##\\s+${heading}\\s*\\n+([\\s\\S]*?)(?=\\n##\\s|\\n---|$)`,
|
|
1284
|
+
"i"
|
|
1285
|
+
);
|
|
587
1286
|
const match = report.match(regex);
|
|
588
1287
|
if (!match) return items;
|
|
589
1288
|
for (const line of match[1].split("\n")) {
|
|
590
1289
|
const itemMatch = line.match(/^[-*]\s+(?:\[.\]\s+)?(.+)/);
|
|
591
|
-
if (itemMatch)
|
|
592
|
-
items.push(itemMatch[1].trim());
|
|
593
|
-
}
|
|
1290
|
+
if (itemMatch) items.push(itemMatch[1].trim());
|
|
594
1291
|
const numberedMatch = line.match(/^\d+\.\s+\*\*(.+?)\*\*\s*(.+)?/);
|
|
595
1292
|
if (numberedMatch) {
|
|
596
1293
|
const text = numberedMatch[2] ? `${numberedMatch[1]} ${numberedMatch[2]}` : numberedMatch[1];
|
|
@@ -599,11 +1296,15 @@ function extractListSection(report, heading) {
|
|
|
599
1296
|
}
|
|
600
1297
|
return items;
|
|
601
1298
|
}
|
|
1299
|
+
|
|
1300
|
+
// src/formatters/html-report.ts
|
|
602
1301
|
var HTML_TEMPLATE = `<!DOCTYPE html>
|
|
603
1302
|
<html lang="en">
|
|
604
1303
|
<head>
|
|
605
1304
|
<meta charset="UTF-8">
|
|
606
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">
|
|
607
1308
|
<title>Qualiow Report \u2014 {{meta.target}}</title>
|
|
608
1309
|
<style>
|
|
609
1310
|
*, *::before, *::after { box-sizing: border-box; margin: 0; padding: 0; }
|
|
@@ -619,17 +1320,6 @@ var HTML_TEMPLATE = `<!DOCTYPE html>
|
|
|
619
1320
|
a { color: #3498db; text-decoration: none; }
|
|
620
1321
|
a:hover { text-decoration: underline; }
|
|
621
1322
|
|
|
622
|
-
.screenshot-container { margin: 0.75rem 0; }
|
|
623
|
-
.screenshot-img {
|
|
624
|
-
max-width: 100%;
|
|
625
|
-
border-radius: 6px;
|
|
626
|
-
border: 1px solid #1e2a3a;
|
|
627
|
-
cursor: pointer;
|
|
628
|
-
transition: transform 0.2s;
|
|
629
|
-
}
|
|
630
|
-
.screenshot-img:hover { transform: scale(1.02); }
|
|
631
|
-
.screenshot-label { font-size: 0.8rem; color: #8899aa; margin-top: 0.25rem; }
|
|
632
|
-
|
|
633
1323
|
.container { max-width: 960px; margin: 0 auto; }
|
|
634
1324
|
|
|
635
1325
|
/* Header */
|
|
@@ -808,6 +1498,18 @@ var HTML_TEMPLATE = `<!DOCTYPE html>
|
|
|
808
1498
|
margin-bottom: 0.35rem;
|
|
809
1499
|
}
|
|
810
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
|
+
|
|
811
1513
|
/* Footer */
|
|
812
1514
|
.footer {
|
|
813
1515
|
margin-top: 3rem;
|
|
@@ -854,6 +1556,8 @@ var HTML_TEMPLATE = `<!DOCTYPE html>
|
|
|
854
1556
|
<body>
|
|
855
1557
|
<div class="container">
|
|
856
1558
|
|
|
1559
|
+
<div class="confidential">{{confidentialityNotice}}</div>
|
|
1560
|
+
|
|
857
1561
|
<div class="header">
|
|
858
1562
|
<h1>Exploratory Testing Report</h1>
|
|
859
1563
|
<div class="meta">
|
|
@@ -917,11 +1621,8 @@ var HTML_TEMPLATE = `<!DOCTYPE html>
|
|
|
917
1621
|
|
|
918
1622
|
{{#if this.hasEvidence}}
|
|
919
1623
|
<div class="bug-section-label">Evidence</div>
|
|
920
|
-
{{#each this.
|
|
921
|
-
<
|
|
922
|
-
<img src="{{this.dataUri}}" alt="{{this.filename}}" class="screenshot-img" />
|
|
923
|
-
<p class="screenshot-label">{{this.filename}}</p>
|
|
924
|
-
</div>
|
|
1624
|
+
{{#each this.evidence.screenshots}}
|
|
1625
|
+
<p class="evidence-item">Screenshot: {{this}}</p>
|
|
925
1626
|
{{/each}}
|
|
926
1627
|
{{#each this.evidence.console_errors}}
|
|
927
1628
|
<p class="evidence-item">Console: {{this}}</p>
|
|
@@ -977,7 +1678,7 @@ var HTML_TEMPLATE = `<!DOCTYPE html>
|
|
|
977
1678
|
{{/if}}
|
|
978
1679
|
|
|
979
1680
|
<div class="footer">
|
|
980
|
-
Generated by Qualiow Exploratory Testing
|
|
1681
|
+
Generated by Qualiow Exploratory Testing \xB7 CONFIDENTIAL \u2014 internal use only
|
|
981
1682
|
</div>
|
|
982
1683
|
|
|
983
1684
|
</div>
|
|
@@ -985,8 +1686,7 @@ var HTML_TEMPLATE = `<!DOCTYPE html>
|
|
|
985
1686
|
</html>`;
|
|
986
1687
|
var compiledTemplate = Handlebars.compile(HTML_TEMPLATE);
|
|
987
1688
|
async function generateHtmlReport(sessionDir) {
|
|
988
|
-
const session = await
|
|
989
|
-
const report = session.report ?? "";
|
|
1689
|
+
const { session, report } = await loadSessionForOutput(sessionDir);
|
|
990
1690
|
const meta = extractReportMeta(report, session.id);
|
|
991
1691
|
const coverage = extractCoverage(report);
|
|
992
1692
|
const observations = extractListSection(report, "Observations");
|
|
@@ -995,39 +1695,14 @@ async function generateHtmlReport(sessionDir) {
|
|
|
995
1695
|
for (const bug of session.bugs) {
|
|
996
1696
|
counts[bug.severity]++;
|
|
997
1697
|
}
|
|
998
|
-
const bugsForTemplate = session.bugs.map((bug) => {
|
|
999
|
-
|
|
1000
|
-
|
|
1001
|
-
|
|
1002
|
-
|
|
1003
|
-
resolve2(sessionDir, "screenshots", cleaned),
|
|
1004
|
-
resolve2(sessionDir, cleaned.replace(/^screenshots\//, "")),
|
|
1005
|
-
resolve2(sessionDir, "screenshots", cleaned.replace(/^screenshots\//, ""))
|
|
1006
|
-
];
|
|
1007
|
-
for (const imgPath of possiblePaths) {
|
|
1008
|
-
if (existsSync3(imgPath)) {
|
|
1009
|
-
try {
|
|
1010
|
-
const ext = extname(imgPath).toLowerCase().replace(".", "");
|
|
1011
|
-
const mime = ext === "jpg" ? "image/jpeg" : `image/${ext || "png"}`;
|
|
1012
|
-
const data = readFileSync4(imgPath).toString("base64");
|
|
1013
|
-
const filename = imgPath.split("/").pop() || screenshotRef;
|
|
1014
|
-
return { dataUri: `data:${mime};base64,${data}`, filename };
|
|
1015
|
-
} catch {
|
|
1016
|
-
return null;
|
|
1017
|
-
}
|
|
1018
|
-
}
|
|
1019
|
-
}
|
|
1020
|
-
return null;
|
|
1021
|
-
}).filter(Boolean);
|
|
1022
|
-
return {
|
|
1023
|
-
...bug,
|
|
1024
|
-
business_impact_summary: summarizeBusinessImpact(bug.business_impact),
|
|
1025
|
-
hasEvidence: embeddedScreenshots.length > 0 || bug.evidence.console_errors.length > 0,
|
|
1026
|
-
embeddedScreenshots
|
|
1027
|
-
};
|
|
1028
|
-
});
|
|
1698
|
+
const bugsForTemplate = session.bugs.map((bug) => ({
|
|
1699
|
+
...bug,
|
|
1700
|
+
business_impact_summary: summarizeBusinessImpact(bug.business_impact),
|
|
1701
|
+
hasEvidence: bug.evidence.screenshots.length > 0 || bug.evidence.console_errors.length > 0
|
|
1702
|
+
}));
|
|
1029
1703
|
const html = compiledTemplate({
|
|
1030
1704
|
meta,
|
|
1705
|
+
confidentialityNotice: CONFIDENTIALITY_NOTICE,
|
|
1031
1706
|
totalBugs: session.bugs.length,
|
|
1032
1707
|
criticalCount: counts.critical,
|
|
1033
1708
|
highCount: counts.high,
|
|
@@ -1057,8 +1732,7 @@ function summarizeBusinessImpact(impact) {
|
|
|
1057
1732
|
function extractTarget(report, sessionId) {
|
|
1058
1733
|
const match = report.match(/\*\*Application:\*\*\s*(.+)/i) ?? report.match(/\*\*Target:\*\*\s*(.+)/i) ?? report.match(/\|\s*Target\s*\|\s*(.+?)\s*\|/i);
|
|
1059
1734
|
if (match) return match[1].trim();
|
|
1060
|
-
|
|
1061
|
-
return parts[parts.length - 1] || sessionId;
|
|
1735
|
+
return parseSessionDirName(sessionId)?.slug ?? sessionId;
|
|
1062
1736
|
}
|
|
1063
1737
|
function extractDate(report) {
|
|
1064
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);
|
|
@@ -1072,64 +1746,33 @@ function extractPagesExplored(report) {
|
|
|
1072
1746
|
const match = report.match(/Pages\s+Explored\s*\|\s*(\d+)/i);
|
|
1073
1747
|
return match ? parseInt(match[1], 10) : 0;
|
|
1074
1748
|
}
|
|
1075
|
-
function extractCoverage2(report) {
|
|
1076
|
-
const entries = [];
|
|
1077
|
-
const tableMatch = report.match(
|
|
1078
|
-
/\|\s*Area\s*\|\s*Status\s*\|[\s\S]*?\n((?:\|.+\|.+\n?)+)/i
|
|
1079
|
-
);
|
|
1080
|
-
if (!tableMatch) return entries;
|
|
1081
|
-
const rows = tableMatch[1].split("\n").filter((r) => r.trim().startsWith("|"));
|
|
1082
|
-
for (const row of rows) {
|
|
1083
|
-
const cells = row.split("|").map((c) => c.trim()).filter(Boolean);
|
|
1084
|
-
if (cells.length >= 2 && !cells[0].startsWith("---")) {
|
|
1085
|
-
entries.push({
|
|
1086
|
-
area: cells[0] || "",
|
|
1087
|
-
status: cells[1] || "",
|
|
1088
|
-
bugs_found: parseInt(cells[3] || "0", 10) || 0,
|
|
1089
|
-
notes: cells[4] || ""
|
|
1090
|
-
});
|
|
1091
|
-
}
|
|
1092
|
-
}
|
|
1093
|
-
return entries;
|
|
1094
|
-
}
|
|
1095
|
-
function extractListSection2(report, heading) {
|
|
1096
|
-
const items = [];
|
|
1097
|
-
const regex = new RegExp(`##\\s+${heading}\\s*\\n+([\\s\\S]*?)(?=\\n##\\s|\\n---|$)`, "i");
|
|
1098
|
-
const match = report.match(regex);
|
|
1099
|
-
if (!match) return items;
|
|
1100
|
-
for (const line of match[1].split("\n")) {
|
|
1101
|
-
const itemMatch = line.match(/^[-*]\s+(?:\[.\]\s+)?(.+)/);
|
|
1102
|
-
if (itemMatch) {
|
|
1103
|
-
items.push(itemMatch[1].trim());
|
|
1104
|
-
}
|
|
1105
|
-
const numberedMatch = line.match(/^\d+\.\s+\*\*(.+?)\*\*\s*(.+)?/);
|
|
1106
|
-
if (numberedMatch) {
|
|
1107
|
-
const text = numberedMatch[2] ? `${numberedMatch[1]} ${numberedMatch[2]}` : numberedMatch[1];
|
|
1108
|
-
items.push(text.replace(/\s*--\s*/, " -- "));
|
|
1109
|
-
}
|
|
1110
|
-
}
|
|
1111
|
-
return items;
|
|
1112
|
-
}
|
|
1113
1749
|
async function generateJsonReport(sessionDir) {
|
|
1114
|
-
const session = await
|
|
1115
|
-
const report = session.report ?? "";
|
|
1116
|
-
const target = extractTarget(report, session.id);
|
|
1117
|
-
const date = extractDate(report);
|
|
1118
|
-
const duration_min = extractDuration(report);
|
|
1119
|
-
const pages_explored = extractPagesExplored(report);
|
|
1750
|
+
const { session, report } = await loadSessionForOutput(sessionDir);
|
|
1120
1751
|
const counts = { critical: 0, high: 0, medium: 0, low: 0 };
|
|
1121
1752
|
for (const bug of session.bugs) {
|
|
1122
1753
|
counts[bug.severity]++;
|
|
1123
1754
|
}
|
|
1124
|
-
const coverage =
|
|
1125
|
-
|
|
1126
|
-
|
|
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
|
+
}));
|
|
1127
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
|
+
},
|
|
1128
1770
|
session: {
|
|
1129
1771
|
id: session.id,
|
|
1130
|
-
|
|
1131
|
-
|
|
1132
|
-
|
|
1772
|
+
kind: parseSessionDirName(session.id)?.kind ?? null,
|
|
1773
|
+
target: extractTarget(report, session.id),
|
|
1774
|
+
date: extractDate(report),
|
|
1775
|
+
duration_min: extractDuration(report)
|
|
1133
1776
|
},
|
|
1134
1777
|
summary: {
|
|
1135
1778
|
total_bugs: session.bugs.length,
|
|
@@ -1137,21 +1780,25 @@ async function generateJsonReport(sessionDir) {
|
|
|
1137
1780
|
high: counts.high,
|
|
1138
1781
|
medium: counts.medium,
|
|
1139
1782
|
low: counts.low,
|
|
1140
|
-
pages_explored
|
|
1783
|
+
pages_explored: extractPagesExplored(report)
|
|
1141
1784
|
},
|
|
1142
1785
|
bugs: session.bugs.map((bug) => ({
|
|
1143
1786
|
id: bug.id,
|
|
1144
1787
|
title: bug.title,
|
|
1145
1788
|
severity: bug.severity,
|
|
1789
|
+
priority: bug.priority,
|
|
1146
1790
|
component: bug.component,
|
|
1147
1791
|
url: bug.url,
|
|
1792
|
+
environment: bug.environment,
|
|
1793
|
+
reproduction_rate: bug.reproduction_rate,
|
|
1794
|
+
summary: bug.summary,
|
|
1148
1795
|
business_impact: bug.business_impact,
|
|
1149
1796
|
steps: bug.steps,
|
|
1150
1797
|
evidence: bug.evidence
|
|
1151
1798
|
})),
|
|
1152
1799
|
coverage,
|
|
1153
|
-
observations,
|
|
1154
|
-
recommendations
|
|
1800
|
+
observations: extractListSection(report, "Observations"),
|
|
1801
|
+
recommendations: extractListSection(report, "Recommendations")
|
|
1155
1802
|
};
|
|
1156
1803
|
}
|
|
1157
1804
|
|
|
@@ -1164,53 +1811,49 @@ var SEVERITY_TO_JIRA_PRIORITY = {
|
|
|
1164
1811
|
};
|
|
1165
1812
|
function csvEscape(value) {
|
|
1166
1813
|
if (!value) return '""';
|
|
1167
|
-
|
|
1168
|
-
|
|
1814
|
+
let v = value;
|
|
1815
|
+
if (/^[=+\-@\t\r]/.test(v)) v = `'${v}`;
|
|
1816
|
+
return `"${v.replace(/"/g, '""')}"`;
|
|
1169
1817
|
}
|
|
1170
1818
|
function formatDescription(bug) {
|
|
1171
1819
|
const parts = [];
|
|
1820
|
+
if (bug.summary) {
|
|
1821
|
+
parts.push(bug.summary, "");
|
|
1822
|
+
}
|
|
1172
1823
|
if (bug.steps.length > 0) {
|
|
1173
1824
|
parts.push("h3. Steps to Reproduce");
|
|
1174
|
-
for (const step of bug.steps) {
|
|
1175
|
-
parts.push(`# ${step}`);
|
|
1176
|
-
}
|
|
1825
|
+
for (const step of bug.steps) parts.push(`# ${step}`);
|
|
1177
1826
|
parts.push("");
|
|
1178
1827
|
}
|
|
1179
1828
|
if (bug.expected) {
|
|
1180
|
-
parts.push(
|
|
1181
|
-
parts.push(bug.expected);
|
|
1182
|
-
parts.push("");
|
|
1829
|
+
parts.push("h3. Expected Behavior", bug.expected, "");
|
|
1183
1830
|
}
|
|
1184
1831
|
if (bug.actual) {
|
|
1185
|
-
parts.push(
|
|
1186
|
-
parts.push(bug.actual);
|
|
1187
|
-
parts.push("");
|
|
1832
|
+
parts.push("h3. Actual Behavior", bug.actual, "");
|
|
1188
1833
|
}
|
|
1189
1834
|
if (bug.business_impact) {
|
|
1190
|
-
parts.push("h3. Business Impact");
|
|
1191
|
-
|
|
1192
|
-
|
|
1835
|
+
parts.push("h3. Business Impact", bug.business_impact, "");
|
|
1836
|
+
}
|
|
1837
|
+
if (bug.environment) {
|
|
1838
|
+
parts.push("h3. Environment", bug.environment, "");
|
|
1193
1839
|
}
|
|
1194
1840
|
if (bug.url) {
|
|
1195
|
-
parts.push(
|
|
1196
|
-
parts.push(bug.url);
|
|
1841
|
+
parts.push("h3. URL", bug.url, "");
|
|
1197
1842
|
}
|
|
1843
|
+
parts.push(`_${CONFIDENTIALITY_NOTICE}_`);
|
|
1198
1844
|
return parts.join("\n");
|
|
1199
1845
|
}
|
|
1200
|
-
function extractDomain(sessionId) {
|
|
1201
|
-
return "general";
|
|
1202
|
-
}
|
|
1203
1846
|
async function generateJiraExport(sessionDir) {
|
|
1204
|
-
const session = await
|
|
1847
|
+
const { session } = await loadSessionForOutput(sessionDir);
|
|
1205
1848
|
const headers = ["Summary", "Priority", "Description", "Component", "Labels"];
|
|
1206
1849
|
const rows = [headers.join(",")];
|
|
1207
|
-
const
|
|
1850
|
+
const kind = parseSessionDirName(session.id)?.kind ?? "";
|
|
1208
1851
|
for (const bug of session.bugs) {
|
|
1209
1852
|
const summary = `${bug.id}: ${bug.title}`;
|
|
1210
1853
|
const priority = SEVERITY_TO_JIRA_PRIORITY[bug.severity] ?? "Major";
|
|
1211
1854
|
const description = formatDescription(bug);
|
|
1212
1855
|
const component = bug.component || "";
|
|
1213
|
-
const labels = ["qualiow", "exploratory-testing",
|
|
1856
|
+
const labels = ["qualiow", "exploratory-testing", kind].filter(Boolean).join(" ");
|
|
1214
1857
|
rows.push(
|
|
1215
1858
|
[
|
|
1216
1859
|
csvEscape(summary),
|
|
@@ -1223,22 +1866,741 @@ async function generateJiraExport(sessionDir) {
|
|
|
1223
1866
|
}
|
|
1224
1867
|
return rows.join("\n");
|
|
1225
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
|
+
}
|
|
1226
2574
|
export {
|
|
2575
|
+
ALL_BUGS_COLUMNS,
|
|
2576
|
+
ALL_BUGS_MD_HEADER,
|
|
1227
2577
|
AuthConfigSchema,
|
|
1228
2578
|
BrowserConfigSchema,
|
|
2579
|
+
CONFIDENTIALITY_HEADER_MD,
|
|
2580
|
+
CONFIDENTIALITY_LINES,
|
|
2581
|
+
CONFIDENTIALITY_NOTICE,
|
|
1229
2582
|
DomainConfigSchema,
|
|
2583
|
+
INDEX_COLUMNS,
|
|
2584
|
+
INDEX_MD_HEADER,
|
|
1230
2585
|
JourneySchema,
|
|
2586
|
+
KnowledgeChangelogSchema,
|
|
1231
2587
|
KnowledgeEntryContentSchema,
|
|
1232
2588
|
KnowledgeEntrySchema,
|
|
1233
2589
|
KnowledgeManifestEntrySchema,
|
|
1234
2590
|
KnowledgeManifestSchema,
|
|
1235
2591
|
KnowledgeManifestStatsSchema,
|
|
2592
|
+
KnowledgeReleaseSchema,
|
|
1236
2593
|
LoadingStrategySchema,
|
|
1237
2594
|
MobileAppConfigSchema,
|
|
1238
2595
|
MobileDeviceConfigSchema,
|
|
1239
2596
|
MobileScopeConfigSchema,
|
|
1240
2597
|
MobileTargetConfigSchema,
|
|
1241
2598
|
MobileWebConfigSchema,
|
|
2599
|
+
QUALIOW_GITIGNORE_ENTRIES,
|
|
2600
|
+
QUALIOW_GITIGNORE_HEADER,
|
|
2601
|
+
REDACTION_CATEGORIES,
|
|
2602
|
+
SESSION_DIR_RE,
|
|
2603
|
+
SESSION_KINDS,
|
|
1242
2604
|
SafetyConfigSchema,
|
|
1243
2605
|
ScopeConfigSchema,
|
|
1244
2606
|
SessionMetricsSchema,
|
|
@@ -1247,17 +2609,49 @@ export {
|
|
|
1247
2609
|
TargetConfigSchema,
|
|
1248
2610
|
WebTargetConfigSchema,
|
|
1249
2611
|
appendSessionMetrics,
|
|
2612
|
+
appendSessionMetricsDeduped,
|
|
2613
|
+
buildManifestRegistry,
|
|
2614
|
+
computeStats,
|
|
1250
2615
|
containsSecrets,
|
|
2616
|
+
csvEscape,
|
|
2617
|
+
extractCoverage,
|
|
2618
|
+
extractListSection,
|
|
2619
|
+
extractReportMeta,
|
|
1251
2620
|
generateHtmlReport,
|
|
1252
2621
|
generateJiraExport,
|
|
1253
2622
|
generateJsonReport,
|
|
2623
|
+
generateMarkdownSummary,
|
|
2624
|
+
getPackageRoot,
|
|
2625
|
+
getPackageVersion,
|
|
2626
|
+
hasConfidentialityHeader,
|
|
2627
|
+
listReleaseDirs,
|
|
2628
|
+
loadSessionForOutput,
|
|
2629
|
+
mergeGitignore,
|
|
1254
2630
|
parseBugReport,
|
|
2631
|
+
parseMarkdownTable,
|
|
1255
2632
|
parseSession,
|
|
2633
|
+
parseSessionDirName,
|
|
2634
|
+
parseTimeBox,
|
|
1256
2635
|
readAllMetrics,
|
|
2636
|
+
readSessionIndex,
|
|
1257
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,
|
|
1258
2652
|
validateAllConfigs,
|
|
1259
2653
|
validateDomainConfig,
|
|
2654
|
+
validateKnowledgeBase,
|
|
1260
2655
|
validateKnowledgeEntry,
|
|
1261
2656
|
validateTargetConfig
|
|
1262
2657
|
};
|
|
1263
|
-
//# sourceMappingURL=index.js.map
|