@feigi/fleet-ctl 3.60.0 → 3.61.1

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.
@@ -90,17 +90,26 @@ export function briefText(issue) {
90
90
  return String(issue.body ?? "");
91
91
  }
92
92
 
93
- /** The metric columns for a parsed `gh issue view --json title,body,comments,labels,createdAt`, or null when it is not one. */
94
- export function issueMetrics(issue, now = Date.now()) {
95
- if (issue === null || typeof issue !== "object" || Array.isArray(issue) || typeof issue.body !== "string") return null;
96
- const brief = briefText(issue).trim();
97
- const lines = brief.split(/\r?\n/);
93
+ /**
94
+ * The file paths a brief names: every backticked token without whitespace that
95
+ * holds a `/` or ends in an extension, in first-seen order, each once.
96
+ */
97
+ export function briefPaths(brief) {
98
98
  const paths = new Set();
99
99
  for (const m of brief.matchAll(/`([^`\n]+)`/g)) {
100
100
  const tok = m[1];
101
101
  if (/\s/.test(tok)) continue;
102
102
  if (tok.includes("/") || /\.[A-Za-z][A-Za-z0-9]*$/.test(tok)) paths.add(tok);
103
103
  }
104
+ return [...paths];
105
+ }
106
+
107
+ /** The metric columns for a parsed `gh issue view --json title,body,comments,labels,createdAt`, or null when it is not one. */
108
+ export function issueMetrics(issue, now = Date.now()) {
109
+ if (issue === null || typeof issue !== "object" || Array.isArray(issue) || typeof issue.body !== "string") return null;
110
+ const brief = briefText(issue).trim();
111
+ const lines = brief.split(/\r?\n/);
112
+ const paths = briefPaths(brief);
104
113
  const created = Date.parse(issue.createdAt ?? "");
105
114
  const kind = (Array.isArray(issue.labels) ? issue.labels : []).map((l) => l?.name).find((n) => KINDS.has(n)) ?? "";
106
115
  return {
@@ -108,8 +117,8 @@ export function issueMetrics(issue, now = Date.now()) {
108
117
  criteria: String(lines.filter((l) => /^\s*[-*]\s*\[[ xX]\]/.test(l)).length),
109
118
  comments: String(Array.isArray(issue.comments) ? issue.comments.length : 0),
110
119
  age_days: Number.isFinite(created) ? String(Math.max(0, Math.floor((now - created) / DAY_MS))) : "",
111
- paths: String(paths.size),
112
- test_paths: String([...paths].filter((p) => /\.test\.|(^|\/)tests?\//.test(p)).length),
120
+ paths: String(paths.length),
121
+ test_paths: String(paths.filter((p) => /\.test\.|(^|\/)tests?\//.test(p)).length),
113
122
  xrefs: String(new Set([...brief.matchAll(/#(\d+)/g)].map((m) => m[1])).size),
114
123
  kind,
115
124
  };