nexus-agents 8.54.12 → 8.54.13

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.
@@ -11,7 +11,7 @@ import {
11
11
  NODE_ENGINE_RANGE,
12
12
  VERSION,
13
13
  isNodeVersionSupported
14
- } from "./chunk-KJ3FETDF.js";
14
+ } from "./chunk-F5W2ULJZ.js";
15
15
  import {
16
16
  claimGlobalRegistry
17
17
  } from "./chunk-WE7A4SRC.js";
@@ -1314,7 +1314,7 @@ async function runDoctorFix(result) {
1314
1314
  writeLine2("\u2500".repeat(40));
1315
1315
  let fixCount = 0;
1316
1316
  if (!result.dataDirectory.rootExists || result.dataDirectory.subdirectories.some((d) => !d.exists || !d.writable)) {
1317
- const { initDataDirectories: initDataDirectories2, describeDataDirFix: describeDataDirFix2 } = await import("./setup-data-dir-4Y6GFNXN.js");
1317
+ const { initDataDirectories: initDataDirectories2, describeDataDirFix: describeDataDirFix2 } = await import("./setup-data-dir-KFSR7X2F.js");
1318
1318
  const outcome = describeDataDirFix2(initDataDirectories2());
1319
1319
  writeLine2(outcome.line);
1320
1320
  if (outcome.counted) fixCount++;
@@ -1416,4 +1416,4 @@ export {
1416
1416
  startStdioServer,
1417
1417
  closeServer
1418
1418
  };
1419
- //# sourceMappingURL=chunk-7D6ZUDNF.js.map
1419
+ //# sourceMappingURL=chunk-C4HYXB6P.js.map
@@ -7,7 +7,7 @@ import {
7
7
  toolStructuredError,
8
8
  toolSuccessStructured,
9
9
  wrapToolWithTimeout
10
- } from "./chunk-445EVQYF.js";
10
+ } from "./chunk-MPFPHE65.js";
11
11
  import {
12
12
  JsonlStore,
13
13
  SECURITY_KEYWORDS,
@@ -27,9 +27,7 @@ import {
27
27
  } from "./chunk-BTYRPZON.js";
28
28
 
29
29
  // src/mcp/tools/improvement-review.ts
30
- import { execFile as execFile2 } from "node:child_process";
31
30
  import { readFile } from "node:fs/promises";
32
- import { promisify as promisify2 } from "node:util";
33
31
  import { z as z3 } from "zod";
34
32
 
35
33
  // src/mcp/middleware/tool-prerequisites.ts
@@ -1569,6 +1567,10 @@ function createRemediationSoakCollector(metaFor, sink = getRemediationSoakSink()
1569
1567
  };
1570
1568
  }
1571
1569
 
1570
+ // src/mcp/tools/improvement-review-issue-filing.ts
1571
+ import { execFile as execFile2 } from "node:child_process";
1572
+ import { promisify as promisify2 } from "node:util";
1573
+
1572
1574
  // src/mcp/tools/remediation-priority.ts
1573
1575
  function priorityLabel(priority) {
1574
1576
  return priority;
@@ -1595,8 +1597,180 @@ function classifySignalPriority(signal) {
1595
1597
  }
1596
1598
  }
1597
1599
 
1598
- // src/mcp/tools/improvement-review.ts
1600
+ // src/mcp/tools/improvement-review-issue-filing.ts
1599
1601
  var execFileAsync2 = promisify2(execFile2);
1602
+ var MAX_ISSUES_PER_RUN = 5;
1603
+ var defaultGhExec = async (args) => execFileAsync2("gh", [...args]);
1604
+ var LABEL_LIST_LIMIT = 1e3;
1605
+ var NOT_FILING = { repo: null, source: "not-filing" };
1606
+ async function maybeFileIssues(signals, opts) {
1607
+ if (!opts.fileIssues) return { issuesFiled: [], issuesSkipped: [], issueTarget: NOT_FILING };
1608
+ return fileSignalsAsIssues(signals, {
1609
+ logger: opts.logger,
1610
+ ghExec: opts.ghExec,
1611
+ ...opts.targetRepo === void 0 ? {} : { targetRepo: opts.targetRepo }
1612
+ });
1613
+ }
1614
+ function repoArgs(target) {
1615
+ return target.repo === null ? [] : ["--repo", target.repo];
1616
+ }
1617
+ async function resolveIssueTarget(deps) {
1618
+ if (deps.targetRepo !== void 0) return { repo: deps.targetRepo, source: "input" };
1619
+ try {
1620
+ const { stdout } = await deps.ghExec(["repo", "view", "--json", "nameWithOwner"]);
1621
+ const parsed = JSON.parse(stdout);
1622
+ if (typeof parsed.nameWithOwner === "string" && parsed.nameWithOwner.length > 0) {
1623
+ return { repo: parsed.nameWithOwner, source: "cwd-remote" };
1624
+ }
1625
+ return { repo: null, source: "unresolved" };
1626
+ } catch (caught) {
1627
+ deps.logger.warn("improvement_review: target repo lookup failed; gh will resolve from cwd", {
1628
+ error: getErrorMessage(caught)
1629
+ });
1630
+ return { repo: null, source: "unresolved" };
1631
+ }
1632
+ }
1633
+ async function fetchRepoLabels(deps, target) {
1634
+ try {
1635
+ const { stdout } = await deps.ghExec([
1636
+ "label",
1637
+ "list",
1638
+ "--json",
1639
+ "name",
1640
+ "--limit",
1641
+ String(LABEL_LIST_LIMIT),
1642
+ ...repoArgs(target)
1643
+ ]);
1644
+ const parsed = JSON.parse(stdout);
1645
+ if (parsed.length >= LABEL_LIST_LIMIT) {
1646
+ deps.logger.warn("improvement_review: gh label list filled its page; filing unfiltered", {
1647
+ returned: parsed.length,
1648
+ limit: LABEL_LIST_LIMIT
1649
+ });
1650
+ return { status: "truncated" };
1651
+ }
1652
+ return {
1653
+ status: "ok",
1654
+ names: new Set(parsed.flatMap((l) => typeof l.name === "string" ? [l.name] : []))
1655
+ };
1656
+ } catch (caught) {
1657
+ deps.logger.warn("improvement_review: gh label list failed; filing without labels", {
1658
+ error: getErrorMessage(caught)
1659
+ });
1660
+ return { status: "unavailable" };
1661
+ }
1662
+ }
1663
+ async function existingIssueForSignal(signalKey, ghExec, target) {
1664
+ try {
1665
+ const searchTerm = signalKey.replace(/"/g, "");
1666
+ const { stdout } = await ghExec([
1667
+ "issue",
1668
+ "list",
1669
+ "--state",
1670
+ "open",
1671
+ "--search",
1672
+ `"${searchTerm}" in:body`,
1673
+ "--json",
1674
+ "number,url",
1675
+ "--limit",
1676
+ "5",
1677
+ ...repoArgs(target)
1678
+ ]);
1679
+ const parsed = JSON.parse(stdout);
1680
+ if (parsed.length > 0 && typeof parsed[0]?.url === "string") {
1681
+ return parsed[0].url;
1682
+ }
1683
+ return null;
1684
+ } catch {
1685
+ return null;
1686
+ }
1687
+ }
1688
+ function issueLabelsForSignal(signal) {
1689
+ return [priorityLabel(classifySignalPriority(signal)), signal.category];
1690
+ }
1691
+ function partitionLabels(requested, labels) {
1692
+ switch (labels.status) {
1693
+ case "unavailable":
1694
+ return { kept: [], labelsDropped: [...requested], labelCheck: "unavailable" };
1695
+ case "truncated":
1696
+ return { kept: [...requested], labelsDropped: [], labelCheck: "truncated" };
1697
+ case "ok":
1698
+ return {
1699
+ kept: requested.filter((l) => labels.names.has(l)),
1700
+ labelsDropped: requested.filter((l) => !labels.names.has(l)),
1701
+ labelCheck: "ok"
1702
+ };
1703
+ }
1704
+ }
1705
+ async function fileIssueForSignal(signal, kept, ghExec, target) {
1706
+ const body = `${signal.body}
1707
+
1708
+ ---
1709
+
1710
+ _Signal key (do not edit): \`${signal.signalKey}\` \xB7 Generated by \`improvement_review\` (#2402) \xB7 Severity: ${signal.severity}_`;
1711
+ try {
1712
+ const { stdout } = await ghExec([
1713
+ "issue",
1714
+ "create",
1715
+ "--title",
1716
+ signal.title,
1717
+ "--body",
1718
+ body,
1719
+ ...kept.length > 0 ? ["--label", kept.join(",")] : [],
1720
+ ...repoArgs(target)
1721
+ ]);
1722
+ const url = stdout.trim();
1723
+ if (!url.startsWith("https://")) {
1724
+ return { ok: false, error: `gh returned unexpected output: ${stdout.slice(0, 200)}` };
1725
+ }
1726
+ return { ok: true, url };
1727
+ } catch (caught) {
1728
+ const message = caught instanceof Error ? caught.message : String(caught);
1729
+ return { ok: false, error: message };
1730
+ }
1731
+ }
1732
+ async function fileSignalsAsIssues(signals, deps) {
1733
+ const issuesFiled = [];
1734
+ const issuesSkipped = [];
1735
+ const target = await resolveIssueTarget(deps);
1736
+ let labelsOnce;
1737
+ const repoLabels = () => labelsOnce ??= fetchRepoLabels(deps, target);
1738
+ for (const signal of signals) {
1739
+ if (issuesFiled.length >= MAX_ISSUES_PER_RUN) {
1740
+ issuesSkipped.push({ signalKey: signal.signalKey, reason: "rate-limit" });
1741
+ continue;
1742
+ }
1743
+ const existing = await existingIssueForSignal(signal.signalKey, deps.ghExec, target);
1744
+ if (existing !== null) {
1745
+ issuesSkipped.push({ signalKey: signal.signalKey, reason: `dup:${existing}` });
1746
+ continue;
1747
+ }
1748
+ const { kept, labelsDropped, labelCheck } = partitionLabels(
1749
+ issueLabelsForSignal(signal),
1750
+ await repoLabels()
1751
+ );
1752
+ const result = await fileIssueForSignal(signal, kept, deps.ghExec, target);
1753
+ if (result.ok) {
1754
+ issuesFiled.push({
1755
+ signalKey: signal.signalKey,
1756
+ issueUrl: result.url,
1757
+ labelsDropped,
1758
+ labelCheck
1759
+ });
1760
+ deps.logger.info("improvement signal filed", {
1761
+ signalKey: signal.signalKey,
1762
+ url: result.url,
1763
+ labelsDropped,
1764
+ labelCheck
1765
+ });
1766
+ } else {
1767
+ issuesSkipped.push({ signalKey: signal.signalKey, reason: `error:${result.error}` });
1768
+ }
1769
+ }
1770
+ return { issuesFiled, issuesSkipped, issueTarget: target };
1771
+ }
1772
+
1773
+ // src/mcp/tools/improvement-review.ts
1600
1774
  var TARGET_REPO_PATTERN = /^[A-Za-z0-9_.-]+\/[A-Za-z0-9_.-]+$/;
1601
1775
  var ImprovementReviewInputSchema = z3.object({
1602
1776
  lookbackDays: z3.number().int().min(1).max(90).optional().default(7).describe("Lookback window for outcome data, in days. Default 7."),
@@ -1612,7 +1786,6 @@ var ImprovementReviewInputSchema = z3.object({
1612
1786
  "Repository (`owner/repo`) to file issues against when fileIssues=true. Absent \u2192 the cwd remote (via `gh repo view`); the resolved target is reported as `issueTarget` (#6112)."
1613
1787
  )
1614
1788
  });
1615
- var MAX_ISSUES_PER_RUN = 5;
1616
1789
  var HOUR_MS = 60 * 60 * 1e3;
1617
1790
  var DAY_MS = 24 * HOUR_MS;
1618
1791
  function filterByLookback(outcomes, lookbackDays, now) {
@@ -1944,135 +2117,6 @@ async function loadSelfEvalSignals(reportPath, windowLabel, logger) {
1944
2117
  return [];
1945
2118
  }
1946
2119
  }
1947
- var defaultGhExec = async (args) => execFileAsync2("gh", [...args]);
1948
- var LABEL_LIST_LIMIT = 1e3;
1949
- var NOT_FILING = { repo: null, source: "not-filing" };
1950
- async function maybeFileIssues(signals, opts) {
1951
- if (!opts.fileIssues) return { issuesFiled: [], issuesSkipped: [], issueTarget: NOT_FILING };
1952
- return fileSignalsAsIssues(signals, {
1953
- logger: opts.logger,
1954
- ghExec: opts.ghExec,
1955
- ...opts.targetRepo === void 0 ? {} : { targetRepo: opts.targetRepo }
1956
- });
1957
- }
1958
- function repoArgs(target) {
1959
- return target.repo === null ? [] : ["--repo", target.repo];
1960
- }
1961
- async function resolveIssueTarget(deps) {
1962
- if (deps.targetRepo !== void 0) return { repo: deps.targetRepo, source: "input" };
1963
- try {
1964
- const { stdout } = await deps.ghExec(["repo", "view", "--json", "nameWithOwner"]);
1965
- const parsed = JSON.parse(stdout);
1966
- if (typeof parsed.nameWithOwner === "string" && parsed.nameWithOwner.length > 0) {
1967
- return { repo: parsed.nameWithOwner, source: "cwd-remote" };
1968
- }
1969
- return { repo: null, source: "unresolved" };
1970
- } catch (caught) {
1971
- deps.logger.warn("improvement_review: target repo lookup failed; gh will resolve from cwd", {
1972
- error: getErrorMessage(caught)
1973
- });
1974
- return { repo: null, source: "unresolved" };
1975
- }
1976
- }
1977
- async function fetchRepoLabels(deps, target) {
1978
- try {
1979
- const { stdout } = await deps.ghExec([
1980
- "label",
1981
- "list",
1982
- "--json",
1983
- "name",
1984
- "--limit",
1985
- String(LABEL_LIST_LIMIT),
1986
- ...repoArgs(target)
1987
- ]);
1988
- const parsed = JSON.parse(stdout);
1989
- if (parsed.length >= LABEL_LIST_LIMIT) {
1990
- deps.logger.warn("improvement_review: gh label list filled its page; filing unfiltered", {
1991
- returned: parsed.length,
1992
- limit: LABEL_LIST_LIMIT
1993
- });
1994
- return { status: "truncated" };
1995
- }
1996
- return {
1997
- status: "ok",
1998
- names: new Set(parsed.flatMap((l) => typeof l.name === "string" ? [l.name] : []))
1999
- };
2000
- } catch (caught) {
2001
- deps.logger.warn("improvement_review: gh label list failed; filing without labels", {
2002
- error: getErrorMessage(caught)
2003
- });
2004
- return { status: "unavailable" };
2005
- }
2006
- }
2007
- async function existingIssueForSignal(signalKey, ghExec, target) {
2008
- try {
2009
- const searchTerm = signalKey.replace(/"/g, "");
2010
- const { stdout } = await ghExec([
2011
- "issue",
2012
- "list",
2013
- "--state",
2014
- "open",
2015
- "--search",
2016
- `"${searchTerm}" in:body`,
2017
- "--json",
2018
- "number,url",
2019
- "--limit",
2020
- "5",
2021
- ...repoArgs(target)
2022
- ]);
2023
- const parsed = JSON.parse(stdout);
2024
- if (parsed.length > 0 && typeof parsed[0]?.url === "string") {
2025
- return parsed[0].url;
2026
- }
2027
- return null;
2028
- } catch {
2029
- return null;
2030
- }
2031
- }
2032
- function issueLabelsForSignal(signal) {
2033
- return [priorityLabel(classifySignalPriority(signal)), signal.category];
2034
- }
2035
- function partitionLabels(requested, labels) {
2036
- switch (labels.status) {
2037
- case "unavailable":
2038
- return { kept: [], labelsDropped: [...requested], labelCheck: "unavailable" };
2039
- case "truncated":
2040
- return { kept: [...requested], labelsDropped: [], labelCheck: "truncated" };
2041
- case "ok":
2042
- return {
2043
- kept: requested.filter((l) => labels.names.has(l)),
2044
- labelsDropped: requested.filter((l) => !labels.names.has(l)),
2045
- labelCheck: "ok"
2046
- };
2047
- }
2048
- }
2049
- async function fileIssueForSignal(signal, kept, ghExec, target) {
2050
- const body = `${signal.body}
2051
-
2052
- ---
2053
-
2054
- _Signal key (do not edit): \`${signal.signalKey}\` \xB7 Generated by \`improvement_review\` (#2402) \xB7 Severity: ${signal.severity}_`;
2055
- try {
2056
- const { stdout } = await ghExec([
2057
- "issue",
2058
- "create",
2059
- "--title",
2060
- signal.title,
2061
- "--body",
2062
- body,
2063
- ...kept.length > 0 ? ["--label", kept.join(",")] : [],
2064
- ...repoArgs(target)
2065
- ]);
2066
- const url = stdout.trim();
2067
- if (!url.startsWith("https://")) {
2068
- return { ok: false, error: `gh returned unexpected output: ${stdout.slice(0, 200)}` };
2069
- }
2070
- return { ok: true, url };
2071
- } catch (caught) {
2072
- const message = caught instanceof Error ? caught.message : String(caught);
2073
- return { ok: false, error: message };
2074
- }
2075
- }
2076
2120
  function safeFitnessAudit(now, ctx) {
2077
2121
  try {
2078
2122
  return calculateFitnessScore("improvement-review");
@@ -2094,46 +2138,6 @@ var SEVERITY_ORDER = {
2094
2138
  warning: 1,
2095
2139
  info: 2
2096
2140
  };
2097
- async function fileSignalsAsIssues(signals, deps) {
2098
- const issuesFiled = [];
2099
- const issuesSkipped = [];
2100
- const target = await resolveIssueTarget(deps);
2101
- let labelsOnce;
2102
- const repoLabels = () => labelsOnce ??= fetchRepoLabels(deps, target);
2103
- for (const signal of signals) {
2104
- if (issuesFiled.length >= MAX_ISSUES_PER_RUN) {
2105
- issuesSkipped.push({ signalKey: signal.signalKey, reason: "rate-limit" });
2106
- continue;
2107
- }
2108
- const existing = await existingIssueForSignal(signal.signalKey, deps.ghExec, target);
2109
- if (existing !== null) {
2110
- issuesSkipped.push({ signalKey: signal.signalKey, reason: `dup:${existing}` });
2111
- continue;
2112
- }
2113
- const { kept, labelsDropped, labelCheck } = partitionLabels(
2114
- issueLabelsForSignal(signal),
2115
- await repoLabels()
2116
- );
2117
- const result = await fileIssueForSignal(signal, kept, deps.ghExec, target);
2118
- if (result.ok) {
2119
- issuesFiled.push({
2120
- signalKey: signal.signalKey,
2121
- issueUrl: result.url,
2122
- labelsDropped,
2123
- labelCheck
2124
- });
2125
- deps.logger.info("improvement signal filed", {
2126
- signalKey: signal.signalKey,
2127
- url: result.url,
2128
- labelsDropped,
2129
- labelCheck
2130
- });
2131
- } else {
2132
- issuesSkipped.push({ signalKey: signal.signalKey, reason: `error:${result.error}` });
2133
- }
2134
- }
2135
- return { issuesFiled, issuesSkipped, issueTarget: target };
2136
- }
2137
2141
  function readBufferedVoteRejections(now, lookbackDays) {
2138
2142
  const cutoff = now - lookbackDays * DAY_MS;
2139
2143
  return getPipelineEventBus().query({ type: "signal.vote_rejected" }).filter((e) => e.type === "signal.vote_rejected").filter((e) => e.timestamp >= cutoff);
@@ -2271,8 +2275,7 @@ export {
2271
2275
  detectFitnessSignals,
2272
2276
  detectSelfEvalSignals,
2273
2277
  loadSelfEvalSignals,
2274
- issueLabelsForSignal,
2275
2278
  runImprovementReview,
2276
2279
  registerImprovementReviewTool
2277
2280
  };
2278
- //# sourceMappingURL=chunk-QQIGJICQ.js.map
2281
+ //# sourceMappingURL=chunk-D5U2I6EE.js.map