@inteeka/task-cli 0.1.5 → 0.1.6

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.
package/dist/cli.js CHANGED
@@ -2012,7 +2012,13 @@ function parseStructuredJson(raw) {
2012
2012
  function registerScan(program2) {
2013
2013
  program2.command("scan").description(
2014
2014
  "Drive the AI fix-prompt autopilot loop locally \u2014 same flow as the /task-autopilot skill, run by the CLI binary"
2015
- ).option("--project <slugOrId>", "Restrict to one project (default: every visible project)").option("--max <n>", "Max submissions per project token", "50").option("--batch <n>", "Tickets per /prepare batch (1-10)", "5").option("--api-url <url>", "Override TASK_API_URL").option("--silent", "Suppress per-ticket progress chrome").action(async (opts) => {
2015
+ ).option(
2016
+ "--project <slugOrId>",
2017
+ "Restrict to one project (default: the linked project from .task/config.json, falling back to every visible project if the repo is not linked)"
2018
+ ).option(
2019
+ "--all-projects",
2020
+ "Override the linked-project default and scan every CLI-eligible project the admin token can see"
2021
+ ).option("--max <n>", "Max submissions per project token", "50").option("--batch <n>", "Tickets per /prepare batch (1-10)", "5").option("--api-url <url>", "Override TASK_API_URL").option("--silent", "Suppress per-ticket progress chrome").action(async (opts) => {
2016
2022
  await runScan(opts);
2017
2023
  });
2018
2024
  }
@@ -2034,10 +2040,26 @@ async function runScan(opts) {
2034
2040
  );
2035
2041
  }
2036
2042
  const localCfg = await readLocalConfig();
2037
- const apiUrl = (opts.apiUrl ?? process.env["TASK_API_URL"] ?? localCfg.api_url ?? "http://localhost:3400").replace(/\/$/, "");
2043
+ const linkedProject = await readProjectConfig(findRepoRoot());
2044
+ const apiUrl = (opts.apiUrl ?? process.env["TASK_API_URL"] ?? localCfg.api_url ?? linkedProject?.api_url ?? "http://localhost:3400").replace(/\/$/, "");
2038
2045
  const max = clampInt(opts.max, 1, 500, 50);
2039
2046
  const batchSize = clampInt(opts.batch, 1, 10, 5);
2040
2047
  const silent = !!opts.silent || localCfg.silent;
2048
+ if (opts.project && opts.allProjects) {
2049
+ throw new CliError(
2050
+ CLI_EXIT_CODES.MISCONFIGURATION,
2051
+ "--project and --all-projects are mutually exclusive"
2052
+ );
2053
+ }
2054
+ let projectFilter = null;
2055
+ let filterSource = null;
2056
+ if (opts.project) {
2057
+ projectFilter = opts.project;
2058
+ filterSource = "flag";
2059
+ } else if (linkedProject && !opts.allProjects) {
2060
+ projectFilter = linkedProject.project_id;
2061
+ filterSource = "link";
2062
+ }
2041
2063
  const api = new AutopilotApi({ apiUrl, apiKey, actorEmail });
2042
2064
  if (!silent) process.stdout.write(`${c.dim("Discovering eligible projects\u2026")}
2043
2065
  `);
@@ -2046,15 +2068,33 @@ async function runScan(opts) {
2046
2068
  process.stdout.write(c.dim("No CLI-eligible tickets across any visible project.\n"));
2047
2069
  return;
2048
2070
  }
2049
- const projects = opts.project ? all.filter(
2050
- (p) => p.project_id === opts.project || p.project_slug === opts.project || `${p.organisation_slug}/${p.project_slug}` === opts.project
2071
+ const projects = projectFilter ? all.filter(
2072
+ (p) => p.project_id === projectFilter || p.project_slug === projectFilter || `${p.organisation_slug}/${p.project_slug}` === projectFilter
2051
2073
  ) : all;
2052
2074
  if (projects.length === 0) {
2075
+ if (filterSource === "link" && linkedProject) {
2076
+ throw new CliError(
2077
+ CLI_EXIT_CODES.GENERIC_ERROR,
2078
+ `Linked project ${linkedProject.organisation_slug}/${linkedProject.project_slug} has no CLI-eligible tickets right now`,
2079
+ "Mark a ticket as CLI-eligible from the dashboard, or pass --all-projects to scan everything the admin token can see."
2080
+ );
2081
+ }
2053
2082
  throw new CliError(
2054
2083
  CLI_EXIT_CODES.GENERIC_ERROR,
2055
2084
  `Project "${opts.project}" not found among eligible projects`
2056
2085
  );
2057
2086
  }
2087
+ if (!silent && filterSource === "link" && linkedProject) {
2088
+ process.stdout.write(
2089
+ `${c.dim("Scanning linked project")} ${c.bold(`${linkedProject.organisation_slug}/${linkedProject.project_slug}`)}${c.dim(" \u2014 pass --all-projects to scan every visible project.")}
2090
+ `
2091
+ );
2092
+ } else if (!silent && filterSource === null && !linkedProject) {
2093
+ process.stdout.write(
2094
+ `${c.dim("Repo is not linked. Scanning every visible project \u2014 run")} ${c.cyan("task link")} ${c.dim("to scope future runs to one project.")}
2095
+ `
2096
+ );
2097
+ }
2058
2098
  const aggregates = [];
2059
2099
  const claudePath = localCfg.claude_path ?? void 0;
2060
2100
  let interrupted = false;
@@ -3293,7 +3333,7 @@ function checkBinary(name, command) {
3293
3333
  }
3294
3334
 
3295
3335
  // src/commands/version.ts
3296
- var CLI_VERSION = true ? "0.1.5" : "0.0.0-dev";
3336
+ var CLI_VERSION = true ? "0.1.6" : "0.0.0-dev";
3297
3337
  function registerVersion(program2) {
3298
3338
  program2.command("version").description("Print the CLI version").action(() => {
3299
3339
  process.stdout.write(CLI_VERSION + "\n");