qaa-agent 1.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.
Files changed (56) hide show
  1. package/.claude/commands/create-test.md +40 -0
  2. package/.claude/commands/qa-analyze.md +60 -0
  3. package/.claude/commands/qa-audit.md +37 -0
  4. package/.claude/commands/qa-blueprint.md +54 -0
  5. package/.claude/commands/qa-fix.md +36 -0
  6. package/.claude/commands/qa-from-ticket.md +88 -0
  7. package/.claude/commands/qa-gap.md +54 -0
  8. package/.claude/commands/qa-pom.md +36 -0
  9. package/.claude/commands/qa-pyramid.md +37 -0
  10. package/.claude/commands/qa-report.md +38 -0
  11. package/.claude/commands/qa-start.md +33 -0
  12. package/.claude/commands/qa-testid.md +54 -0
  13. package/.claude/commands/qa-validate.md +54 -0
  14. package/.claude/commands/update-test.md +58 -0
  15. package/.claude/settings.json +19 -0
  16. package/.claude/skills/qa-bug-detective/SKILL.md +122 -0
  17. package/.claude/skills/qa-repo-analyzer/SKILL.md +88 -0
  18. package/.claude/skills/qa-self-validator/SKILL.md +109 -0
  19. package/.claude/skills/qa-template-engine/SKILL.md +113 -0
  20. package/.claude/skills/qa-testid-injector/SKILL.md +93 -0
  21. package/.claude/skills/qa-workflow-documenter/SKILL.md +87 -0
  22. package/CLAUDE.md +543 -0
  23. package/README.md +418 -0
  24. package/agents/qa-pipeline-orchestrator.md +1217 -0
  25. package/agents/qaa-analyzer.md +508 -0
  26. package/agents/qaa-bug-detective.md +444 -0
  27. package/agents/qaa-executor.md +618 -0
  28. package/agents/qaa-planner.md +374 -0
  29. package/agents/qaa-scanner.md +422 -0
  30. package/agents/qaa-testid-injector.md +583 -0
  31. package/agents/qaa-validator.md +450 -0
  32. package/bin/install.cjs +176 -0
  33. package/bin/lib/commands.cjs +709 -0
  34. package/bin/lib/config.cjs +307 -0
  35. package/bin/lib/core.cjs +497 -0
  36. package/bin/lib/frontmatter.cjs +299 -0
  37. package/bin/lib/init.cjs +989 -0
  38. package/bin/lib/milestone.cjs +241 -0
  39. package/bin/lib/model-profiles.cjs +60 -0
  40. package/bin/lib/phase.cjs +911 -0
  41. package/bin/lib/roadmap.cjs +306 -0
  42. package/bin/lib/state.cjs +748 -0
  43. package/bin/lib/template.cjs +222 -0
  44. package/bin/lib/verify.cjs +842 -0
  45. package/bin/qaa-tools.cjs +607 -0
  46. package/package.json +34 -0
  47. package/templates/failure-classification.md +391 -0
  48. package/templates/gap-analysis.md +409 -0
  49. package/templates/pr-template.md +48 -0
  50. package/templates/qa-analysis.md +381 -0
  51. package/templates/qa-audit-report.md +465 -0
  52. package/templates/qa-repo-blueprint.md +636 -0
  53. package/templates/scan-manifest.md +312 -0
  54. package/templates/test-inventory.md +582 -0
  55. package/templates/testid-audit-report.md +354 -0
  56. package/templates/validation-report.md +243 -0
@@ -0,0 +1,307 @@
1
+ /**
2
+ * Config — Planning config CRUD operations
3
+ */
4
+
5
+ const fs = require('fs');
6
+ const path = require('path');
7
+ const { output, error } = require('./core.cjs');
8
+ const {
9
+ VALID_PROFILES,
10
+ getAgentToModelMapForProfile,
11
+ formatAgentToModelMapAsTable,
12
+ } = require('./model-profiles.cjs');
13
+
14
+ const VALID_CONFIG_KEYS = new Set([
15
+ 'mode', 'granularity', 'parallelization', 'commit_docs', 'model_profile',
16
+ 'search_gitignored', 'brave_search',
17
+ 'workflow.research', 'workflow.plan_check', 'workflow.verifier',
18
+ 'workflow.nyquist_validation', 'workflow.ui_phase', 'workflow.ui_safety_gate',
19
+ 'workflow._auto_chain_active',
20
+ 'git.branching_strategy', 'git.phase_branch_template', 'git.milestone_branch_template',
21
+ 'planning.commit_docs', 'planning.search_gitignored',
22
+ ]);
23
+
24
+ const CONFIG_KEY_SUGGESTIONS = {
25
+ 'workflow.nyquist_validation_enabled': 'workflow.nyquist_validation',
26
+ 'agents.nyquist_validation_enabled': 'workflow.nyquist_validation',
27
+ 'nyquist.validation_enabled': 'workflow.nyquist_validation',
28
+ };
29
+
30
+ function validateKnownConfigKeyPath(keyPath) {
31
+ const suggested = CONFIG_KEY_SUGGESTIONS[keyPath];
32
+ if (suggested) {
33
+ error(`Unknown config key: ${keyPath}. Did you mean ${suggested}?`);
34
+ }
35
+ }
36
+
37
+ /**
38
+ * Ensures the config file exists (creates it if needed).
39
+ *
40
+ * Does not call `output()`, so can be used as one step in a command without triggering `exit(0)` in
41
+ * the happy path. But note that `error()` will still `exit(1)` out of the process.
42
+ */
43
+ function ensureConfigFile(cwd) {
44
+ const configPath = path.join(cwd, '.planning', 'config.json');
45
+ const planningDir = path.join(cwd, '.planning');
46
+
47
+ // Ensure .planning directory exists
48
+ try {
49
+ if (!fs.existsSync(planningDir)) {
50
+ fs.mkdirSync(planningDir, { recursive: true });
51
+ }
52
+ } catch (err) {
53
+ error('Failed to create .planning directory: ' + err.message);
54
+ }
55
+
56
+ // Check if config already exists
57
+ if (fs.existsSync(configPath)) {
58
+ return { created: false, reason: 'already_exists' };
59
+ }
60
+
61
+ // Detect Brave Search API key availability
62
+ const homedir = require('os').homedir();
63
+ const braveKeyFile = path.join(homedir, '.qaa', 'brave_api_key');
64
+ const hasBraveSearch = !!(process.env.BRAVE_API_KEY || fs.existsSync(braveKeyFile));
65
+
66
+ // Load user-level defaults from ~/.qaa/defaults.json if available
67
+ const globalDefaultsPath = path.join(homedir, '.qaa', 'defaults.json');
68
+ let userDefaults = {};
69
+ try {
70
+ if (fs.existsSync(globalDefaultsPath)) {
71
+ userDefaults = JSON.parse(fs.readFileSync(globalDefaultsPath, 'utf-8'));
72
+ // Migrate deprecated "depth" key to "granularity"
73
+ if ('depth' in userDefaults && !('granularity' in userDefaults)) {
74
+ const depthToGranularity = { quick: 'coarse', standard: 'standard', comprehensive: 'fine' };
75
+ userDefaults.granularity = depthToGranularity[userDefaults.depth] || userDefaults.depth;
76
+ delete userDefaults.depth;
77
+ try {
78
+ fs.writeFileSync(globalDefaultsPath, JSON.stringify(userDefaults, null, 2), 'utf-8');
79
+ } catch {}
80
+ }
81
+ }
82
+ } catch (err) {
83
+ // Ignore malformed global defaults, fall back to hardcoded
84
+ }
85
+
86
+ // Create default config (user-level defaults override hardcoded defaults)
87
+ const hardcoded = {
88
+ model_profile: 'balanced',
89
+ commit_docs: true,
90
+ search_gitignored: false,
91
+ branching_strategy: 'none',
92
+ phase_branch_template: 'qaa/phase-{phase}-{slug}',
93
+ milestone_branch_template: 'qaa/{milestone}-{slug}',
94
+ workflow: {
95
+ research: true,
96
+ plan_check: true,
97
+ verifier: true,
98
+ nyquist_validation: true,
99
+ },
100
+ parallelization: true,
101
+ brave_search: hasBraveSearch,
102
+ };
103
+ const defaults = {
104
+ ...hardcoded,
105
+ ...userDefaults,
106
+ workflow: { ...hardcoded.workflow, ...(userDefaults.workflow || {}) },
107
+ };
108
+
109
+ try {
110
+ fs.writeFileSync(configPath, JSON.stringify(defaults, null, 2), 'utf-8');
111
+ return { created: true, path: '.planning/config.json' };
112
+ } catch (err) {
113
+ error('Failed to create config.json: ' + err.message);
114
+ }
115
+ }
116
+
117
+ /**
118
+ * Command to ensure the config file exists (creates it if needed).
119
+ *
120
+ * Note that this exits the process (via `output()`) even in the happy path; use
121
+ * `ensureConfigFile()` directly if you need to avoid this.
122
+ */
123
+ function cmdConfigEnsureSection(cwd, raw) {
124
+ const ensureConfigFileResult = ensureConfigFile(cwd);
125
+ if (ensureConfigFileResult.created) {
126
+ output(ensureConfigFileResult, raw, 'created');
127
+ } else {
128
+ output(ensureConfigFileResult, raw, 'exists');
129
+ }
130
+ }
131
+
132
+ /**
133
+ * Sets a value in the config file, allowing nested values via dot notation (e.g.,
134
+ * "workflow.research").
135
+ *
136
+ * Does not call `output()`, so can be used as one step in a command without triggering `exit(0)` in
137
+ * the happy path. But note that `error()` will still `exit(1)` out of the process.
138
+ */
139
+ function setConfigValue(cwd, keyPath, parsedValue) {
140
+ const configPath = path.join(cwd, '.planning', 'config.json');
141
+
142
+ // Load existing config or start with empty object
143
+ let config = {};
144
+ try {
145
+ if (fs.existsSync(configPath)) {
146
+ config = JSON.parse(fs.readFileSync(configPath, 'utf-8'));
147
+ }
148
+ } catch (err) {
149
+ error('Failed to read config.json: ' + err.message);
150
+ }
151
+
152
+ // Set nested value using dot notation (e.g., "workflow.research")
153
+ const keys = keyPath.split('.');
154
+ let current = config;
155
+ for (let i = 0; i < keys.length - 1; i++) {
156
+ const key = keys[i];
157
+ if (current[key] === undefined || typeof current[key] !== 'object') {
158
+ current[key] = {};
159
+ }
160
+ current = current[key];
161
+ }
162
+ const previousValue = current[keys[keys.length - 1]]; // Capture previous value before overwriting
163
+ current[keys[keys.length - 1]] = parsedValue;
164
+
165
+ // Write back
166
+ try {
167
+ fs.writeFileSync(configPath, JSON.stringify(config, null, 2), 'utf-8');
168
+ return { updated: true, key: keyPath, value: parsedValue, previousValue };
169
+ } catch (err) {
170
+ error('Failed to write config.json: ' + err.message);
171
+ }
172
+ }
173
+
174
+ /**
175
+ * Command to set a value in the config file, allowing nested values via dot notation (e.g.,
176
+ * "workflow.research").
177
+ *
178
+ * Note that this exits the process (via `output()`) even in the happy path; use `setConfigValue()`
179
+ * directly if you need to avoid this.
180
+ */
181
+ function cmdConfigSet(cwd, keyPath, value, raw) {
182
+ if (!keyPath) {
183
+ error('Usage: config-set <key.path> <value>');
184
+ }
185
+
186
+ validateKnownConfigKeyPath(keyPath);
187
+
188
+ if (!VALID_CONFIG_KEYS.has(keyPath)) {
189
+ error(`Unknown config key: "${keyPath}". Valid keys: ${[...VALID_CONFIG_KEYS].sort().join(', ')}`);
190
+ }
191
+
192
+ // Parse value (handle booleans and numbers)
193
+ let parsedValue = value;
194
+ if (value === 'true') parsedValue = true;
195
+ else if (value === 'false') parsedValue = false;
196
+ else if (!isNaN(value) && value !== '') parsedValue = Number(value);
197
+
198
+ const setConfigValueResult = setConfigValue(cwd, keyPath, parsedValue);
199
+ output(setConfigValueResult, raw, `${keyPath}=${parsedValue}`);
200
+ }
201
+
202
+ function cmdConfigGet(cwd, keyPath, raw) {
203
+ const configPath = path.join(cwd, '.planning', 'config.json');
204
+
205
+ if (!keyPath) {
206
+ error('Usage: config-get <key.path>');
207
+ }
208
+
209
+ let config = {};
210
+ try {
211
+ if (fs.existsSync(configPath)) {
212
+ config = JSON.parse(fs.readFileSync(configPath, 'utf-8'));
213
+ } else {
214
+ error('No config.json found at ' + configPath);
215
+ }
216
+ } catch (err) {
217
+ if (err.message.startsWith('No config.json')) throw err;
218
+ error('Failed to read config.json: ' + err.message);
219
+ }
220
+
221
+ // Traverse dot-notation path (e.g., "workflow.auto_advance")
222
+ const keys = keyPath.split('.');
223
+ let current = config;
224
+ for (const key of keys) {
225
+ if (current === undefined || current === null || typeof current !== 'object') {
226
+ error(`Key not found: ${keyPath}`);
227
+ }
228
+ current = current[key];
229
+ }
230
+
231
+ if (current === undefined) {
232
+ error(`Key not found: ${keyPath}`);
233
+ }
234
+
235
+ output(current, raw, String(current));
236
+ }
237
+
238
+ /**
239
+ * Command to set the model profile in the config file.
240
+ *
241
+ * Note that this exits the process (via `output()`) even in the happy path.
242
+ */
243
+ function cmdConfigSetModelProfile(cwd, profile, raw) {
244
+ if (!profile) {
245
+ error(`Usage: config-set-model-profile <${VALID_PROFILES.join('|')}>`);
246
+ }
247
+
248
+ const normalizedProfile = profile.toLowerCase().trim();
249
+ if (!VALID_PROFILES.includes(normalizedProfile)) {
250
+ error(`Invalid profile '${profile}'. Valid profiles: ${VALID_PROFILES.join(', ')}`);
251
+ }
252
+
253
+ // Ensure config exists (create if needed)
254
+ ensureConfigFile(cwd);
255
+
256
+ // Set the model profile in the config
257
+ const { previousValue } = setConfigValue(cwd, 'model_profile', normalizedProfile, raw);
258
+ const previousProfile = previousValue || 'balanced';
259
+
260
+ // Build result value / message and return
261
+ const agentToModelMap = getAgentToModelMapForProfile(normalizedProfile);
262
+ const result = {
263
+ updated: true,
264
+ profile: normalizedProfile,
265
+ previousProfile,
266
+ agentToModelMap,
267
+ };
268
+ const rawValue = getCmdConfigSetModelProfileResultMessage(
269
+ normalizedProfile,
270
+ previousProfile,
271
+ agentToModelMap
272
+ );
273
+ output(result, raw, rawValue);
274
+ }
275
+
276
+ /**
277
+ * Returns the message to display for the result of the `config-set-model-profile` command when
278
+ * displaying raw output.
279
+ */
280
+ function getCmdConfigSetModelProfileResultMessage(
281
+ normalizedProfile,
282
+ previousProfile,
283
+ agentToModelMap
284
+ ) {
285
+ const agentToModelTable = formatAgentToModelMapAsTable(agentToModelMap);
286
+ const didChange = previousProfile !== normalizedProfile;
287
+ const paragraphs = didChange
288
+ ? [
289
+ `✓ Model profile set to: ${normalizedProfile} (was: ${previousProfile})`,
290
+ 'Agents will now use:',
291
+ agentToModelTable,
292
+ 'Next spawned agents will use the new profile.',
293
+ ]
294
+ : [
295
+ `✓ Model profile is already set to: ${normalizedProfile}`,
296
+ 'Agents are using:',
297
+ agentToModelTable,
298
+ ];
299
+ return paragraphs.join('\n\n');
300
+ }
301
+
302
+ module.exports = {
303
+ cmdConfigEnsureSection,
304
+ cmdConfigSet,
305
+ cmdConfigGet,
306
+ cmdConfigSetModelProfile,
307
+ };