* test(3727): add failing test for --fix flag dispatch in code-review workflow Adds bug-3727-code-review-fix-flag-dispatch.test.cjs with: - Pure-function tests on parseCodeReviewFlags() / resolveCodeReviewWorkflow() from new code-review-flags.cjs typed IR module - Structural docs-parity tests asserting dispatch_fix step exists in code-review.md and that initialize step references code-review-flags.cjs Structural tests FAIL today (RED): workflow has no dispatch_fix step and no reference to code-review-flags.cjs in initialize. IR-level tests pass because the lib module is introduced in this commit as the typed seam. Fixes #3727 Co-Authored-By: Claude Sonnet 4.6 <noreply@anthropic.com> * fix(3727): wire --fix/--all/--auto flags through code-review workflow The initialize step now parses --fix, --all, and --auto from argv (via the code-review-flags parser seam added in the previous test commit) and the workflow dispatches gsd-code-fixer when --fix is truthy and the review returned findings. Fixes the regression introduced when PR #2947 closed #2946 without actually shipping the workflow dispatch. Fixes #3727 * chore(3727): update changeset to reference PR #3743 The fix commit landed with the linked-issue number as the pr: field placeholder. Updating to the actual PR number now that the PR is open. * fix(3727): register code-review-flags.cjs in INVENTORY.md and manifest Add missing row for get-shit-done/bin/lib/code-review-flags.cjs to the CLI Modules table in docs/INVENTORY.md (count 72→73) and regenerate docs/INVENTORY-MANIFEST.json to fix three failing CI tests: - cli-modules-doc-parity: every CLI module must have a row in INVENTORY.md - inventory-counts: headline "CLI Modules (N shipped)" must match file count - inventory-manifest-sync: INVENTORY-MANIFEST.json must match filesystem Co-Authored-By: Claude Sonnet 4.6 <noreply@anthropic.com> --------- Co-authored-by: Claude Sonnet 4.6 <noreply@anthropic.com>
75 lines
2.3 KiB
JavaScript
75 lines
2.3 KiB
JavaScript
'use strict';
|
|
|
|
/**
|
|
* Typed flag parser for the /gsd:code-review command.
|
|
*
|
|
* This is the canonical IR for code-review argument parsing. The workflow
|
|
* (code-review.md) delegates flag dispatch logic to this module so that:
|
|
* 1. Tests assert on a structured IR rather than on rendered bash text.
|
|
* 2. The dispatch decision is testable without instantiating the workflow.
|
|
*
|
|
* @typedef {Object} CodeReviewFlags
|
|
* @property {boolean} fix - true when --fix is present in argv
|
|
* @property {boolean} all - true when --all is present in argv (implies fix)
|
|
* @property {boolean} auto - true when --auto is present in argv (implies fix)
|
|
* @property {string} depth - depth override value, or '' if not supplied
|
|
* @property {string} files - files override value, or '' if not supplied
|
|
*/
|
|
|
|
/**
|
|
* Parse code-review flags from an argv array.
|
|
*
|
|
* The first positional argument (phase number) is ignored by this function —
|
|
* phase validation is handled by `gsd-sdk query init.phase-op`.
|
|
*
|
|
* @param {string[]} argv - Array of argument strings, e.g. ['2', '--fix', '--all']
|
|
* @returns {CodeReviewFlags}
|
|
*/
|
|
function parseCodeReviewFlags(argv) {
|
|
const flags = {
|
|
fix: false,
|
|
all: false,
|
|
auto: false,
|
|
depth: '',
|
|
files: '',
|
|
};
|
|
|
|
for (const arg of argv) {
|
|
if (arg === '--fix') {
|
|
flags.fix = true;
|
|
} else if (arg === '--all') {
|
|
flags.all = true;
|
|
} else if (arg === '--auto') {
|
|
flags.auto = true;
|
|
} else if (arg.startsWith('--depth=')) {
|
|
flags.depth = arg.slice('--depth='.length);
|
|
} else if (arg.startsWith('--files=')) {
|
|
flags.files = arg.slice('--files='.length);
|
|
}
|
|
}
|
|
|
|
// --all and --auto imply --fix
|
|
if (flags.all || flags.auto) {
|
|
flags.fix = true;
|
|
}
|
|
|
|
return flags;
|
|
}
|
|
|
|
/**
|
|
* Determine which workflow to dispatch based on parsed flags.
|
|
*
|
|
* Returns the workflow filename (relative to workflows/) that the orchestrator
|
|
* should load:
|
|
* - 'code-review-fix.md' when fix=true (--fix, --all, or --auto present)
|
|
* - 'code-review.md' otherwise (review-only pass)
|
|
*
|
|
* @param {CodeReviewFlags} flags
|
|
* @returns {'code-review.md' | 'code-review-fix.md'}
|
|
*/
|
|
function resolveCodeReviewWorkflow(flags) {
|
|
return flags.fix ? 'code-review-fix.md' : 'code-review.md';
|
|
}
|
|
|
|
module.exports = { parseCodeReviewFlags, resolveCodeReviewWorkflow };
|