ai-agentmanager 1.0.1 → 1.1.0

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/src/tracker.js CHANGED
@@ -95,6 +95,12 @@ export function bugFromRef(ref, source) {
95
95
  return { key: ref, url: null, source };
96
96
  }
97
97
 
98
+ /** The Jira key when the text starts with a Jira link ("https://x.atlassian.net/browse/ABC-1 fix it" → "ABC-1"). */
99
+ export function leadingJiraKey(text) {
100
+ const first = String(text ?? '').trimStart().match(/^<?(https?:\/\/\S+)/);
101
+ return first?.[1].match(JIRA_KEY)?.[1] ?? null;
102
+ }
103
+
98
104
  /** Extract PR and bug references from free text. */
99
105
  export function extractRefs(text, bugPatterns = []) {
100
106
  const prs = [];
@@ -132,7 +138,7 @@ function textOf(content) {
132
138
  * subsequent calls only parse newly appended lines.
133
139
  */
134
140
  export function scanTranscript(file, cursor, bugPatterns = []) {
135
- const result = { prs: [], bugs: [], title: null, lastPrompt: null, cost: null, lastActivity: null };
141
+ const result = { prs: [], bugs: [], title: null, lastPrompt: null, cost: null, lastActivity: null, lastMessageAt: null };
136
142
  // Token usage per API response, kept on the cursor so incremental scans accumulate.
137
143
  cursor.usage ??= new Map();
138
144
  let fd;
@@ -160,6 +166,10 @@ export function scanTranscript(file, cursor, bugPatterns = []) {
160
166
  } catch {
161
167
  continue;
162
168
  }
169
+ // The last real message: resuming a session appends bookkeeping lines, which have no timestamp.
170
+ if ((rec.type === 'user' || rec.type === 'assistant') && !rec.isMeta && rec.timestamp > (result.lastMessageAt ?? '')) {
171
+ result.lastMessageAt = rec.timestamp;
172
+ }
163
173
  switch (rec.type) {
164
174
  case 'pr-link':
165
175
  if (rec.prUrl) result.prs.push({ ...prFromUrl(rec.prUrl, 'session'), number: rec.prNumber ?? null });