automata-cli 0.3.0 → 0.4.0-develop.124

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 (2) hide show
  1. package/dist/index.js +80 -18
  2. package/package.json +1 -1
package/dist/index.js CHANGED
@@ -1510,6 +1510,7 @@ minor segment is incremented (e.g. 1.2.0 \u2192 1.3.0).`
1510
1510
  var gitCommand = new Command2("git").description("Git workflow commands (some require gh CLI)").addCommand(getPrInfoCmd).addCommand(getPrCommentsCmd).addCommand(finishFeatureCmd).addCommand(publishReleaseCmd);
1511
1511
 
1512
1512
  // src/commands/getReady.ts
1513
+ import { createInterface as createInterface2 } from "readline";
1513
1514
  import { Command as Command3 } from "commander";
1514
1515
 
1515
1516
  // src/config/githubService.ts
@@ -1529,14 +1530,14 @@ function run3(cmd, args) {
1529
1530
  status: result.status ?? 1
1530
1531
  };
1531
1532
  }
1532
- function listIssues(technique, value) {
1533
+ function listIssues(technique, value, limit = 10) {
1533
1534
  const baseArgs = [
1534
1535
  "issue",
1535
1536
  "list",
1536
1537
  "--state",
1537
1538
  "open",
1538
1539
  "--limit",
1539
- "1",
1540
+ String(limit),
1540
1541
  "--json",
1541
1542
  "number,title,body,url"
1542
1543
  ];
@@ -1556,11 +1557,7 @@ function listIssues(technique, value) {
1556
1557
  if (status !== 0) {
1557
1558
  throw new Error(stderr.trim() || "Failed to query GitHub issues. Is `gh` installed and authenticated?");
1558
1559
  }
1559
- const issues = JSON.parse(stdout);
1560
- if (issues.length === 0) {
1561
- return null;
1562
- }
1563
- return issues[0];
1560
+ return JSON.parse(stdout);
1564
1561
  }
1565
1562
  function postComment(issueNumber, body) {
1566
1563
  const { stderr, status } = run3("gh", ["issue", "comment", String(issueNumber), "--body", body]);
@@ -1753,8 +1750,37 @@ function invokeCodexCodeSync(prompt, yolo) {
1753
1750
  }
1754
1751
 
1755
1752
  // src/commands/getReady.ts
1756
- var implementNextCommand = new Command3("implement-next").description("Find the next open GitHub issue matching the configured filter, claim it, and invoke the AI code assistant (Claude or Codex)").option("--json", "Output issue details as JSON").option("--no-claude", "Skip all AI invocation (Claude or Codex) after claiming the issue").option("--codex", "Use Codex CLI instead of Claude Code").option("--query-only", "Print issue content and exit without claiming or invoking any AI tools").option("--yolo", "Launch with --dangerously-skip-permissions (Claude) or --dangerously-bypass-approvals-and-sandbox (Codex)").option("--verbose", "Show step-by-step progress summary and final result").option("--opus", "Use claude-opus-4-6").option("--sonnet", "Use claude-sonnet-4-6").option("--haiku", "Use claude-haiku-4-5-20251001").action(async (options) => {
1757
- const config = readConfig();
1753
+ function writeOverflowHint(output, issues, limit) {
1754
+ if (issues.length === limit) {
1755
+ output.write(`(Showing first ${limit} matching issues \u2014 there may be more. Use --limit to fetch more.)
1756
+ `);
1757
+ }
1758
+ }
1759
+ function writeIssueList(output, issues, limit) {
1760
+ output.write("\nAvailable issues:\n");
1761
+ for (let i = 0; i < issues.length; i++) {
1762
+ output.write(` [${i + 1}] #${issues[i].number} - ${issues[i].title}
1763
+ `);
1764
+ }
1765
+ writeOverflowHint(output, issues, limit);
1766
+ }
1767
+ async function promptSelection(issues, limit, output) {
1768
+ writeIssueList(output, issues, limit);
1769
+ const rl = createInterface2({ input: process.stdin, output });
1770
+ const answer = await new Promise(
1771
+ (resolve3) => rl.question(`
1772
+ Select issue (1-${issues.length}): `, resolve3)
1773
+ );
1774
+ rl.close();
1775
+ const n = Number.parseInt(answer.trim(), 10);
1776
+ if (Number.isNaN(n) || n < 1 || n > issues.length) {
1777
+ process.stderr.write(`Error: Invalid selection "${answer.trim()}". Enter a number between 1 and ${issues.length}.
1778
+ `);
1779
+ process.exit(1);
1780
+ }
1781
+ return issues[n - 1];
1782
+ }
1783
+ function validateConfig(config) {
1758
1784
  if (config.remoteType !== "gh") {
1759
1785
  process.stderr.write(
1760
1786
  "Error: implement-next is not supported in Azure DevOps mode. Work item discovery is not available in azdo-cli. See docs/azdo-gap.md for details.\n"
@@ -1773,24 +1799,58 @@ var implementNextCommand = new Command3("implement-next").description("Find the
1773
1799
  );
1774
1800
  process.exit(1);
1775
1801
  }
1802
+ }
1803
+ async function resolveIssue(issues, options, limit) {
1804
+ const selectionOutput = options.json ? process.stderr : process.stdout;
1805
+ if (issues.length === 0) {
1806
+ process.stdout.write("No issues found matching the configured filter.\n");
1807
+ process.exit(0);
1808
+ }
1809
+ if (issues.length > 1 && options.queryOnly) {
1810
+ writeIssueList(selectionOutput, issues, limit);
1811
+ process.exit(0);
1812
+ }
1776
1813
  let issue;
1814
+ if (issues.length === 1) {
1815
+ issue = issues[0];
1816
+ selectionOutput.write(`Issue: #${issue.number}
1817
+ Title: ${issue.title}
1818
+ `);
1819
+ } else if (options.takeFirst) {
1820
+ issue = issues[0];
1821
+ selectionOutput.write(`Selecting issue #${issue.number}: ${issue.title}
1822
+ `);
1823
+ } else {
1824
+ issue = await promptSelection(issues, limit, selectionOutput);
1825
+ selectionOutput.write(`
1826
+ Issue: #${issue.number}
1827
+ Title: ${issue.title}
1828
+ `);
1829
+ }
1830
+ return issue;
1831
+ }
1832
+ var implementNextCommand = new Command3("implement-next").description("Find the next open GitHub issue matching the configured filter, claim it, and invoke the AI code assistant (Claude or Codex)").option("--json", "Output issue details as JSON").option("--no-claude", "Skip all AI invocation (Claude or Codex) after claiming the issue").option("--codex", "Use Codex CLI instead of Claude Code").option("--query-only", "Print issue content and exit without claiming or invoking any AI tools").option("--yolo", "Launch with --dangerously-skip-permissions (Claude) or --dangerously-bypass-approvals-and-sandbox (Codex)").option("--verbose", "Show step-by-step progress summary and final result").option("--opus", "Use claude-opus-4-6").option("--sonnet", "Use claude-sonnet-4-6").option("--haiku", "Use claude-haiku-4-5-20251001").option("--take-first", "When multiple issues match, pick the first without prompting").option("--limit <n>", "Max issues to fetch and display (default: 10)", "10").action(async (options) => {
1833
+ const config = readConfig();
1834
+ validateConfig(config);
1835
+ const limit = Number.parseInt(options.limit, 10);
1836
+ if (Number.isNaN(limit) || limit <= 0) {
1837
+ process.stderr.write(`Error: --limit must be a positive integer (got "${options.limit}").
1838
+ `);
1839
+ process.exit(1);
1840
+ }
1841
+ let issues;
1777
1842
  try {
1778
- issue = listIssues(config.issueDiscoveryTechnique, config.issueDiscoveryValue);
1843
+ issues = listIssues(config.issueDiscoveryTechnique, config.issueDiscoveryValue, limit);
1779
1844
  } catch (err) {
1780
1845
  process.stderr.write(`Error: ${err.message}
1781
1846
  `);
1782
1847
  process.exit(1);
1783
1848
  }
1784
- if (issue === null) {
1785
- process.stdout.write("No issues found matching the configured filter.\n");
1786
- process.exit(0);
1787
- }
1849
+ const issue = await resolveIssue(issues, options, limit);
1788
1850
  if (options.json) {
1789
1851
  process.stdout.write(JSON.stringify({ number: issue.number, title: issue.title, body: issue.body, url: issue.url }, null, 2) + "\n");
1790
1852
  } else {
1791
- process.stdout.write(`Issue: #${issue.number}
1792
- Title: ${issue.title}
1793
- URL: ${issue.url}
1853
+ process.stdout.write(`URL: ${issue.url}
1794
1854
 
1795
1855
  ${issue.body}
1796
1856
  `);
@@ -1807,7 +1867,9 @@ ${issue.body}
1807
1867
  }
1808
1868
  if (options.claude !== false) {
1809
1869
  const systemPrompt = config.claudeSystemPrompt ?? DEFAULT_CLAUDE_SYSTEM_PROMPT;
1810
- const prompt = `${systemPrompt}
1870
+ const prompt = `Resolving issue #${issue.number}:
1871
+
1872
+ ${systemPrompt}
1811
1873
 
1812
1874
  ${issue.body}`;
1813
1875
  if (options.codex) {
package/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "automata-cli",
3
- "version": "0.3.0",
3
+ "version": "0.4.0-develop.124",
4
4
  "description": "Automata CLI tool",
5
5
  "type": "module",
6
6
  "bin": {