-
Notifications
You must be signed in to change notification settings - Fork 355
feat: add single-task repeat mode and code cleanup #166
New issue
Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.
Already on GitHub? Sign in to your account
Open
KLIEBHAN
wants to merge
20
commits into
michaelshimeles:main
Choose a base branch
from
KLIEBHAN:main
base: main
Could not load branches
Branch not found: {{ refName }}
Loading
Could not load tags
Nothing to show
Loading
Are you sure you want to change the base?
Some commits from the old base branch may be removed from the timeline,
and old review comments may become outdated.
Open
Changes from 16 commits
Commits
Show all changes
20 commits
Select commit
Hold shift + click to select a range
a063b27
feat: add single-task repeat mode with --repeat and --continue-on-fai…
KLIEBHAN 837bf8f
fix: adjust codex engine for repeat mode compatibility
KLIEBHAN 39a8303
feat: align bash CLI parity with npm CLI
KLIEBHAN e984745
docs: update README and add example PRD/tasks files
KLIEBHAN 05ade13
refactor: simplify args parsing and deduplicate task error handling
KLIEBHAN 45bff6d
fix: address PR review feedback
KLIEBHAN a0bf467
fix: add --repeat upper bound and bash CLI parity warning
KLIEBHAN e6a3e22
fix: enforce --repeat upper bound in bash CLI and add boundary test
KLIEBHAN a5f2cdd
fix: address PR review feedback
KLIEBHAN 71f5ca2
fix: show skipped count in repeat loop summary
KLIEBHAN 1bc3373
fix: show skipped count in bash repeat loop summary
KLIEBHAN a20b9c5
fix: add warning test and forward --model to all codex invocations
KLIEBHAN f387ef0
fix: show skipped count in desktop notification for repeat mode
KLIEBHAN 44f6a83
fix: run dry-run only once regardless of --repeat count
KLIEBHAN baf3f56
fix: add dry-run guard to bash brownfield task execution
KLIEBHAN 4e05f85
fix: reject scientific notation in --repeat and add dry-run test
KLIEBHAN f7474df
fix: disable browser automation by default (opt-in via --browser)
KLIEBHAN 76a326d
fix: align bash browser default with TS CLI (remove auto mode)
KLIEBHAN a77835b
fix: suppress streaming output in repeat mode for cleaner terminal
KLIEBHAN 66ceb9f
fix: log failed progress on engine unavailability and reorder validation
KLIEBHAN File filter
Filter by extension
Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
There are no files selected for viewing
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
| Original file line number | Diff line number | Diff line change |
|---|---|---|
| @@ -0,0 +1,27 @@ | ||
| # Example Project PRD | ||
|
|
||
| Ein einfaches Beispiel-Projekt, um Ralphy zu demonstrieren. | ||
|
|
||
| ## Kontext | ||
|
|
||
| Wir bauen eine kleine CLI-Anwendung, die Markdown-Dateien in HTML konvertiert. | ||
|
|
||
| ## Tasks | ||
|
|
||
| - [ ] Projekt-Setup: package.json erstellen mit TypeScript und Vitest | ||
| - [ ] Funktion schreiben, die Markdown-Headings (#, ##, ###) in HTML-Tags konvertiert | ||
| - [ ] Funktion schreiben, die **bold** und *italic* Text konvertiert | ||
| - [ ] Funktion schreiben, die Listen (- item) in HTML-Listen konvertiert | ||
| - [ ] CLI-Entry-Point erstellen, der eine Datei einliest und konvertiert | ||
| - [ ] README.md mit Nutzungsanleitung schreiben | ||
|
|
||
| ## Akzeptanzkriterien | ||
|
|
||
| - Alle Tests gruen | ||
| - TypeScript kompiliert ohne Fehler | ||
| - CLI kann mit `npx ts-node src/index.ts input.md` ausgefuehrt werden | ||
|
|
||
| ## Notizen | ||
|
|
||
| - Keine externen Markdown-Libraries verwenden (Lernzweck) | ||
| - Einfache Regex-basierte Konvertierung reicht aus |
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
| Original file line number | Diff line number | Diff line change |
|---|---|---|
| @@ -0,0 +1,94 @@ | ||
| import { beforeAll, describe, expect, it, mock, spyOn } from "bun:test"; | ||
|
|
||
| let parseArgs: typeof import("../args.ts").parseArgs; | ||
|
|
||
| beforeAll(async () => { | ||
| mock.module("../../version.ts", () => ({ | ||
| VERSION: "test", | ||
| })); | ||
| ({ parseArgs } = await import("../args.ts")); | ||
| }); | ||
|
|
||
| function parseCliArgs(args: string[]) { | ||
| return parseArgs(["bun", "ralphy", ...args]); | ||
| } | ||
|
|
||
| describe("parseArgs repeat options", () => { | ||
| it("parses --repeat 5 with task", () => { | ||
| const { options, task } = parseCliArgs(["--repeat", "5", "do something"]); | ||
| expect(task).toBe("do something"); | ||
| expect(options.repeatCount).toBe(5); | ||
| expect(options.continueOnFailure).toBe(false); | ||
| }); | ||
|
|
||
| it("throws on --repeat 0", () => { | ||
| expect(() => parseCliArgs(["--repeat", "0", "task"])).toThrow( | ||
| "--repeat must be an integer between 1 and 10000", | ||
| ); | ||
| }); | ||
|
|
||
| it("throws on --repeat -1", () => { | ||
| expect(() => parseCliArgs(["--repeat", "-1", "task"])).toThrow( | ||
| "--repeat must be an integer between 1 and 10000", | ||
| ); | ||
| }); | ||
|
|
||
| it("throws on --repeat abc", () => { | ||
| expect(() => parseCliArgs(["--repeat", "abc", "task"])).toThrow( | ||
| "--repeat must be an integer between 1 and 10000", | ||
| ); | ||
| }); | ||
|
|
||
| it("throws on --repeat 1.5", () => { | ||
| expect(() => parseCliArgs(["--repeat", "1.5", "task"])).toThrow( | ||
| "--repeat must be an integer between 1 and 10000", | ||
| ); | ||
| }); | ||
|
|
||
| it("throws on --repeat 10001", () => { | ||
| expect(() => parseCliArgs(["--repeat", "10001", "task"])).toThrow( | ||
| "--repeat must be an integer between 1 and 10000", | ||
| ); | ||
| }); | ||
|
|
||
| it("parses --repeat with --continue-on-failure", () => { | ||
| const { options } = parseCliArgs(["--repeat", "3", "--continue-on-failure", "task"]); | ||
| expect(options.repeatCount).toBe(3); | ||
| expect(options.continueOnFailure).toBe(true); | ||
| }); | ||
|
|
||
| it("throws when --repeat is used without task", () => { | ||
| expect(() => parseCliArgs(["--repeat", "3"])).toThrow( | ||
| "--repeat and --continue-on-failure require a task argument", | ||
| ); | ||
| }); | ||
|
|
||
| it("throws when --continue-on-failure is used without task", () => { | ||
| expect(() => parseCliArgs(["--continue-on-failure"])).toThrow( | ||
| "--repeat and --continue-on-failure require a task argument", | ||
| ); | ||
| }); | ||
|
|
||
| it("warns when --continue-on-failure is used without --repeat but with a task", () => { | ||
| const warnSpy = spyOn(console, "warn"); | ||
| const { options } = parseCliArgs(["--continue-on-failure", "do something"]); | ||
| expect(options.continueOnFailure).toBe(true); | ||
| expect(options.repeatCount).toBe(1); | ||
| expect(warnSpy).toHaveBeenCalledWith( | ||
| "Warning: --continue-on-failure has no effect without --repeat", | ||
| ); | ||
| warnSpy.mockRestore(); | ||
| }); | ||
|
|
||
| it("throws when repeat options are combined with task source flags", () => { | ||
| expect(() => parseCliArgs(["--repeat", "3", "--yaml", "tasks.yaml", "task"])).toThrow( | ||
| "--repeat and --continue-on-failure cannot be used with --prd, --yaml, --json, or --github", | ||
| ); | ||
| }); | ||
|
|
||
| it("defaults to repeatCount 1", () => { | ||
| const { options } = parseCliArgs(["task"]); | ||
| expect(options.repeatCount).toBe(1); | ||
| expect(options.continueOnFailure).toBe(false); | ||
| }); | ||
| }); | ||
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
| Original file line number | Diff line number | Diff line change |
|---|---|---|
| @@ -0,0 +1,99 @@ | ||
| import { describe, expect, it } from "bun:test"; | ||
| import { DEFAULT_OPTIONS } from "../../config/types.ts"; | ||
| import { runSingleTaskLoop } from "./single-task-loop.ts"; | ||
|
|
||
|
greptile-apps[bot] marked this conversation as resolved.
|
||
| describe("runSingleTaskLoop", () => { | ||
| it("stops on first non-fatal failure in fail-fast mode", async () => { | ||
| let calls = 0; | ||
| const result = await runSingleTaskLoop( | ||
| "task", | ||
| { | ||
| ...DEFAULT_OPTIONS, | ||
| repeatCount: 3, | ||
| continueOnFailure: false, | ||
| }, | ||
| { | ||
| runTaskFn: async () => { | ||
| calls++; | ||
| return { success: false, fatal: false, error: "boom" }; | ||
| }, | ||
| logInfoFn: () => {}, | ||
| }, | ||
| ); | ||
|
|
||
| expect(calls).toBe(1); | ||
| expect(result.completed).toBe(0); | ||
| expect(result.failed).toBe(1); | ||
| expect(result.total).toBe(3); | ||
| }); | ||
|
|
||
| it("continues on non-fatal failures when continue-on-failure is enabled", async () => { | ||
| let call = 0; | ||
| const sequence = [ | ||
| { success: false, fatal: false, error: "first" }, | ||
| { success: true, fatal: false }, | ||
| { success: false, fatal: false, error: "last" }, | ||
| ] as const; | ||
|
|
||
| const result = await runSingleTaskLoop( | ||
| "task", | ||
| { | ||
| ...DEFAULT_OPTIONS, | ||
| repeatCount: 3, | ||
| continueOnFailure: true, | ||
| }, | ||
| { | ||
| runTaskFn: async () => sequence[call++] ?? sequence[sequence.length - 1], | ||
| logInfoFn: () => {}, | ||
| }, | ||
| ); | ||
|
|
||
| expect(call).toBe(3); | ||
| expect(result.completed).toBe(1); | ||
| expect(result.failed).toBe(2); | ||
| expect(result.total).toBe(3); | ||
| }); | ||
|
|
||
| it("always stops on fatal failures", async () => { | ||
| let calls = 0; | ||
| const result = await runSingleTaskLoop( | ||
| "task", | ||
| { | ||
| ...DEFAULT_OPTIONS, | ||
| repeatCount: 5, | ||
| continueOnFailure: true, | ||
| }, | ||
| { | ||
| runTaskFn: async () => { | ||
| calls++; | ||
| return { success: false, fatal: true, error: "auth failed" }; | ||
| }, | ||
| logInfoFn: () => {}, | ||
| }, | ||
| ); | ||
|
|
||
| expect(calls).toBe(1); | ||
| expect(result.completed).toBe(0); | ||
| expect(result.failed).toBe(1); | ||
| expect(result.total).toBe(5); | ||
| }); | ||
|
|
||
| it("calls runTaskFn exactly once in dry-run mode regardless of repeatCount", async () => { | ||
| let calls = 0; | ||
| const result = await runSingleTaskLoop( | ||
| "task", | ||
| { ...DEFAULT_OPTIONS, dryRun: true, repeatCount: 5 }, | ||
| { | ||
| runTaskFn: async () => { | ||
| calls++; | ||
| return { success: true, fatal: false }; | ||
| }, | ||
| logInfoFn: () => {}, | ||
| }, | ||
| ); | ||
| expect(calls).toBe(1); | ||
| expect(result.total).toBe(5); | ||
| expect(result.completed).toBe(0); | ||
| expect(result.failed).toBe(0); | ||
| }); | ||
| }); | ||
Oops, something went wrong.
Add this suggestion to a batch that can be applied as a single commit.
This suggestion is invalid because no changes were made to the code.
Suggestions cannot be applied while the pull request is closed.
Suggestions cannot be applied while viewing a subset of changes.
Only one suggestion per line can be applied in a batch.
Add this suggestion to a batch that can be applied as a single commit.
Applying suggestions on deleted lines is not supported.
You must change the existing code in this line in order to create a valid suggestion.
Outdated suggestions cannot be applied.
This suggestion has been applied or marked resolved.
Suggestions cannot be applied from pending reviews.
Suggestions cannot be applied on multi-line comments.
Suggestions cannot be applied while the pull request is queued to merge.
Suggestion cannot be applied right now. Please check back later.
Uh oh!
There was an error while loading. Please reload this page.