File size: 2,076 Bytes
a6b96c2
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
"use strict";
/**
 * Typed flag parser for the /gsd:code-review command (ADR-457 build-at-publish:
 * the hand-written bin/lib/code-review-flags.cjs collapsed to a TypeScript
 * source of truth). Behaviour is preserved byte-for-behaviour from the prior
 * hand-written .cjs; only types are added.
 *
 * This is the canonical IR for code-review argument parsing. The workflow
 * (code-review.md) delegates flag dispatch to this module so that tests assert
 * on a structured IR rather than rendered bash text, and the dispatch decision
 * is testable without instantiating the workflow.
 */
Object.defineProperty(exports, "__esModule", { value: true });
exports.parseCodeReviewFlags = parseCodeReviewFlags;
exports.resolveCodeReviewWorkflow = resolveCodeReviewWorkflow;
/**
 * Parse code-review flags from an argv array. The first positional argument
 * (phase number) is ignored — phase validation is handled by
 * `gsd-tools query init.phase-op`. Unknown flags are silently ignored.
 */
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:
 *  - 'code-review-fix.md' when fix=true (--fix, --all, or --auto present)
 *  - 'code-review.md'     otherwise (review-only pass)
 */
function resolveCodeReviewWorkflow(flags) {
    return flags.fix ? 'code-review-fix.md' : 'code-review.md';
}