feat: add --github-order flag to control issue execution order#169
feat: add --github-order flag to control issue execution order#169idorozin wants to merge 4 commits intomichaelshimeles:mainfrom
Conversation
When using GitHub issues as a task source, issues are returned newest-first by the API, which may not match the desired execution order. The new --github-order flag accepts comma-separated issue numbers (e.g. 2,3,4,5,6) to execute issues in a specific sequence. Only the listed issues are executed, and in the exact order specified. Co-Authored-By: Claude Opus 4.6 (1M context) <noreply@anthropic.com>
|
@idorozin is attempting to deploy a commit to the Goshen Labs Team on Vercel. A member of the Team first needs to authorize it. |
Greptile SummaryThis PR adds a The implementation is well-structured — argument parsing correctly handles invalid tokens and empty inputs, the type system is cleanly extended, and the filtering/sorting logic in
Confidence Score: 2/5
Important Files Changed
Sequence DiagramsequenceDiagram
participant CLI as CLI (args.ts)
participant Run as runLoop (run.ts)
participant Factory as createTaskSource (index.ts)
participant GH as GitHubTaskSource (github.ts)
participant API as GitHub API
CLI->>CLI: parse --github-order "2,3,4,5"<br/>→ [2,3,4,5]
CLI->>Run: RuntimeOptions { githubOrder: [2,3,4,5] }
Run->>Factory: createTaskSource({ type:"github", order:[2,3,4,5] })
Factory->>GH: new GitHubTaskSource(repo, label, [2,3,4,5])
Run->>GH: fetchOpenIssues()
GH->>API: listForRepo(state:"open", labels:...)
API-->>GH: all open issues (unordered)
GH->>GH: build orderMap {2→0, 3→1, 4→2, 5→3}
GH->>GH: filter tasks to only issue #s in orderMap
GH->>GH: warn if any order numbers not in open issues
GH->>GH: sort filtered tasks by orderMap index
GH-->>Run: [task#2, task#3, task#4, task#5]
Run->>GH: markComplete("2:title")
GH->>API: update(issue_number:2, state:"closed")
GH->>GH: invalidateCache()
Run->>GH: fetchOpenIssues() [cache miss]
GH->>API: listForRepo(state:"open") — issue#2 now absent
GH->>GH: missing = [2] → ⚠️ false-positive warning fires
|
- Filter out NaN values from parsed --github-order input so that non-numeric tokens (e.g. --github-order 2,abc,4) are silently ignored instead of producing unexpected behavior. - When --github-order is set, countCompleted() now only counts closed issues whose numbers appear in the order list, consistent with fetchOpenIssues() which already filters by order. Co-Authored-By: Claude Opus 4.6 (1M context) <noreply@anthropic.com>
When all tokens in --github-order are invalid (e.g. ",,,"), the filtered result is an empty array. Coerce it to undefined so the behavior falls back to default API order instead of silently producing no tasks. Co-Authored-By: Claude Opus 4.6 (1M context) <noreply@anthropic.com>
- Parse issue number once per task instead of separately in filter and sort, removing the unreachable ?? 0 fallback. - Warn when --github-order specifies issues not found among open issues, so typos and already-closed issues are surfaced to the user. Co-Authored-By: Claude Opus 4.6 (1M context) <noreply@anthropic.com>
| const foundNums = new Set(filtered.map(({ issueNum }) => issueNum)); | ||
| const missing = this.order.filter((n) => !foundNums.has(n)); | ||
| if (missing.length > 0) { | ||
| console.warn( | ||
| `[ralphy] Warning: --github-order specified issues not found among open issues: ${missing.join(", ")}`, | ||
| ); | ||
| } |
There was a problem hiding this comment.
Warning fires as false positive after issues are closed
The missing-issue warning is emitted on every cache refresh, not just the first time. During normal operation, once issue #2 is processed and closed via markComplete(), the cache is invalidated. The next call to fetchOpenIssues() fetches only state: "open" issues, so issue #2 is no longer in the results. The check on line 97 then flags it as missing and emits the warning — even though it was just successfully completed.
This means a user running --github-order 2,3,4,5 will see "Warning: issues not found among open issues: 2" after processing the very first issue, then "...2, 3" after the second, and so on. This is confusing and may cause users to think something went wrong when the workflow is proceeding correctly.
Consider filtering this.order to exclude issues that have already been closed before computing missing. You can cross-reference with the closed-count query, or simply only warn on the first fetch (e.g. when this.cache is null):
// Only warn on the initial fetch, not on subsequent refreshes after issues are closed
const isFirstFetch = !this.cache;
const foundNums = new Set(filtered.map(({ issueNum }) => issueNum));
const missing = this.order.filter((n) => !foundNums.has(n));
if (isFirstFetch && missing.length > 0) {
console.warn(
`[ralphy] Warning: --github-order specified issues not found among open issues: ${missing.join(", ")}`,
);
}Prompt To Fix With AI
This is a comment left during a code review.
Path: cli/src/tasks/github.ts
Line: 96-102
Comment:
**Warning fires as false positive after issues are closed**
The missing-issue warning is emitted on every cache refresh, not just the first time. During normal operation, once issue `#2` is processed and closed via `markComplete()`, the cache is invalidated. The next call to `fetchOpenIssues()` fetches only `state: "open"` issues, so issue `#2` is no longer in the results. The check on line 97 then flags it as missing and emits the warning — even though it was just successfully completed.
This means a user running `--github-order 2,3,4,5` will see "Warning: issues not found among open issues: 2" after processing the very first issue, then "...2, 3" after the second, and so on. This is confusing and may cause users to think something went wrong when the workflow is proceeding correctly.
Consider filtering `this.order` to exclude issues that have already been closed before computing `missing`. You can cross-reference with the closed-count query, or simply only warn on the first fetch (e.g. when `this.cache` is null):
```ts
// Only warn on the initial fetch, not on subsequent refreshes after issues are closed
const isFirstFetch = !this.cache;
const foundNums = new Set(filtered.map(({ issueNum }) => issueNum));
const missing = this.order.filter((n) => !foundNums.has(n));
if (isFirstFetch && missing.length > 0) {
console.warn(
`[ralphy] Warning: --github-order specified issues not found among open issues: ${missing.join(", ")}`,
);
}
```
How can I resolve this? If you propose a fix, please make it concise.
Summary
--github-order <issues>CLI flag that accepts comma-separated issue numbers (e.g.--github-order 2,3,4,5,6)Motivation: When using
--githubto pull tasks from GitHub Issues, the API returns issues newest-first. For sequential workflows where tasks have dependencies (e.g. "project setup" before "database layer" before "API routes"), you need control over execution order.Changes
cli/src/cli/args.ts— new--github-orderoption, parsed intonumber[]with NaN filtering and empty-array coercioncli/src/config/types.ts—githubOrder?: number[]added toRuntimeOptionscli/src/tasks/github.ts— filter and sort fetched issues by the specified order, warn on missing issues, consistentcountCompleted()filteringcli/src/tasks/index.ts— passorderthrough toGitHubTaskSourcecli/src/cli/commands/run.ts— wiregithubOrderintocreateTaskSourceREADME.md— documented in GitHub Issues section and Options tableExample
Test plan
--github-orderwithout--githubis a no-op (flag is only read byGitHubTaskSource)--github-orderpreserves existing behavior (guard checksthis.order && this.order.length > 0)--github-orderare filtered out (NaN filter)--github-order ,,,) coerces toundefined, falls back to default behaviorcountCompleted()only counts closed issues in the order list when--github-orderis set🤖 Generated with Claude Code
Note
Add
--github-orderflag to control GitHub issue execution order--github-order <issues>CLI flag that accepts a comma-separated list of issue numbers, parsed intooptions.githubOrderin args.ts.GitHubTaskSourcein github.ts filters open issues to only those specified and sorts them to match the given order; closed issue counts are also scoped to that list.--github-orderthat are not found among open issues trigger aconsole.warn.Macroscope summarized b1e5a2b.