ticketlens 0.38.46 → 0.38.47

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/README.md CHANGED
@@ -456,13 +456,13 @@ Every note is scanned before saving — anything shaped like a real secret (API
456
456
 
457
457
  **Removing a note:** `ticketlens note delete --id="..." [--ticket=KEY]` removes a note from your local vault. Local only — if it was already pushed to a team, teammates who pulled it keep their copy; deleting it there too is a manager action from the Console (Admin > Recall).
458
458
 
459
- **Any MCP-capable AI harness:** `ticketlens mcp` starts a stdio [MCP](https://modelcontextprotocol.io) server exposing `fetch`, `triage`, `compliance`, `review`, `standup`, `pr`, `stats`, `issue_types`, `history`, `collisions`, `ledger`, `doctor`, `recall_add`, `recall_update`, `recall_delete`, `recall_search`, `ticket_comment`, `ticket_transition`, `ticket_assign`, `ticket_duplicates`, `ticket_link`, `ticket_update`, and `ticket_create` as native tools — every CLI action now has an MCP tool, so any MCP-compatible AI assistant, not just Claude Code, can call them directly instead of constructing a shell command. It's a thin adapter over the exact same code as the CLI commands above — same license gate per tool, same secret scan/local vault/tracker writes, same team sync — nothing is reimplemented. `fetch`, `doctor`, and `standup` are Free; `triage`'s base scan is Free with some options gated Pro/Team, same as the CLI (`ticketlens triage --help`); `compliance` and `pr` are Free, sharing a 3-checks/month cap on their requirements-coverage section, Pro unlimited; `review` is Free for branch/files/ticket context, with its coverage/focus section requiring Pro as a plain license check — it does not draw from that same monthly counter; `stats` is Free with a 7-day lookback cap, Pro extends it to 30 days, same split as the CLI (`ticketlens stats --help`); `issue_types` is Free and Jira-only — pre-fetches and caches a profile's real creatable projects and issue types ahead of a `ticket_create` attempt, sharing its cache with that tool's own reactive enrichment; Linear/GitHub profiles get a clear "not available" instead of an empty result; `history` reads local triage history only (zero network) and requires Pro; `collisions` requires `ticketlens login` (Console access) plus a Team license; `ledger` exports the local, signed compliance audit trail (zero network) and requires Pro; every other tool needs Pro. `recall_update` overwrites an existing Recall note's body — internal plumbing for the note quality loop, not typically called directly. `recall_delete` is destructive and local-vault-only — requires `confirm: true` alongside `id` to actually execute; there is no interactive y/N prompt under MCP (no real terminal to prompt against), so omitting it always fails rather than silently blocking. Point your harness's MCP config at it: `{ "command": "ticketlens", "args": ["mcp"] }` — or run `ticketlens mcp install` in a project to write that entry into its `.mcp.json` for you (creates the file if it doesn't exist, merges in if it does — never touches any other entry already there; `--dry-run` to preview first).
459
+ **Any MCP-capable AI harness:** `ticketlens mcp` starts a stdio [MCP](https://modelcontextprotocol.io) server exposing `fetch`, `triage`, `compliance`, `review`, `standup`, `pr`, `stats`, `issue_types`, `history`, `collisions`, `ledger`, `doctor`, `recall_add`, `recall_update`, `recall_delete`, `recall_search`, `ticket_comment`, `ticket_transition`, `ticket_assign`, `ticket_duplicates`, `ticket_link`, `ticket_update`, and `ticket_create` as native tools — every CLI action now has an MCP tool, so any MCP-compatible AI assistant, not just Claude Code, can call them directly instead of constructing a shell command. It's a thin adapter over the exact same code as the CLI commands above — same license gate per tool, same secret scan/local vault/tracker writes, same team sync — nothing is reimplemented. `fetch`, `doctor`, and `standup` are Free; `triage`'s base scan is Free with some options gated Pro/Team, same as the CLI (`ticketlens triage --help`); `compliance` and `pr` are Free, sharing a 3-checks/month cap on their requirements-coverage section, Pro unlimited; `review` is Free for branch/files/ticket context, with its coverage/focus section requiring Pro as a plain license check — it does not draw from that same monthly counter; `stats` is Free with a 7-day lookback cap, Pro extends it to 30 days, same split as the CLI (`ticketlens stats --help`); `issue_types` is Free and Jira-only — pre-fetches and caches a profile's real creatable projects and issue types ahead of a `ticket_create` attempt, sharing its cache with that tool's own reactive enrichment; Linear/GitHub profiles get a clear "not available" instead of an empty result; `history` reads local triage history only (zero network) and requires Pro; `collisions` requires `ticketlens login` (Console access) plus a Team license; `ledger` exports the local, signed compliance audit trail (zero network) and requires Pro; every other tool needs Pro. `recall_update` overwrites an existing Recall note's body — internal plumbing for the note quality loop, not typically called directly; its `attachments` array appends new files to whatever the note already has, same as `recall_add`'s, never replacing existing ones. `recall_delete` is destructive and local-vault-only — requires `confirm: true` alongside `id` to actually execute; there is no interactive y/N prompt under MCP (no real terminal to prompt against), so omitting it always fails rather than silently blocking. Point your harness's MCP config at it: `{ "command": "ticketlens", "args": ["mcp"] }` — or run `ticketlens mcp install` in a project to write that entry into its `.mcp.json` for you (creates the file if it doesn't exist, merges in if it does — never touches any other entry already there; `--dry-run` to preview first).
460
460
 
461
461
  `note add`'s save confirmation and `recall`'s search results are styled by default in a terminal; add `--plain` to either for bare, pipe-safe output. `recall` always shows each note's file ID (e.g. `[1784135399545-fe01c4.md]`) so you can open it directly (`cat ~/.ticketlens/recall/<PREFIX>/<id>`), or pass `--full` to print the full body content inline instead. Each result shows a relative time (`2h ago`, `3d ago`) rather than a bare date — the full-precision timestamp is always in the note file's own frontmatter.
462
462
 
463
463
  **Tags matter for search relevance.** `--tags=a,b` accepts anything, but a generic tag (the project name, "gotcha", "bug") gives future search almost nothing to match on. Tag with what the note is actually *about* — the specific technology, error type, or root cause (`retry-backoff`, `null-pointer`, `auth-middleware`) — so it surfaces when someone else hits the same problem.
464
464
 
465
- **Local file attachments.** `note add --attach=path1,path2` (or the `recall_add` MCP tool's `attachments` array) saves a screenshot or file alongside the note, in your local vault (`~/.ticketlens/recall/<PREFIX>/<note-id>/`) — same 10 MB/file, 50 MB/call, 20-file caps as ticket attachments for the local save. With Team Recall sync active, the attachment syncs too — visible and downloadable from Console > Admin > Recall — but the sync path caps at 12 MB/call (the backend's request-size limit, lower than the 50 MB local-save cap). Going over it fails the whole push, not just the attachment — the note stays saved locally, but neither its text nor the attachment reaches the team until it's pushed within the cap. Attachments with plain-text content (detected from the actual bytes, not the filename) go through the same secret scan as the note body before syncing; a rejected scan blocks the whole push the same way.
465
+ **Local file attachments.** `note add --attach=path1,path2` (or the `recall_add` MCP tool's `attachments` array) saves a screenshot or file alongside the note, in your local vault (`~/.ticketlens/recall/<PREFIX>/<note-id>/`) — same 10 MB/file, 50 MB/call, 20-file caps as ticket attachments for the local save. `note patch --attach=path1,path2` (or `recall_update`'s `attachments` array) attaches more files to an existing note later — appended to what's already there, never replacing it; patch is local-vault only, so these are never pushed even if the note's original attachments were. With Team Recall sync active, the attachment syncs too — visible and downloadable from Console > Admin > Recall — but the sync path caps at 12 MB/call (the backend's request-size limit, lower than the 50 MB local-save cap). Going over it fails the whole push, not just the attachment — the note stays saved locally, but neither its text nor the attachment reaches the team until it's pushed within the cap. Attachments with plain-text content (detected from the actual bytes, not the filename) go through the same secret scan as the note body before syncing; a rejected scan blocks the whole push the same way.
466
466
 
467
467
  **Gaps** — every `ticketlens PROJ-123` brief also diffs the ticket's own description against its linked tickets (from the depth traversal you already requested) and its own downloaded attachments, looking for requirements mentioned there but missing here. Anything uncovered shows up under a `## Gaps` section, citing exactly where it came from — a linked ticket key or an attachment filename — as evidence, never an instruction to act on. Nothing is saved anywhere; it's recomputed fresh on every fetch. Requires a Pro license, same as Recall. No network call beyond what the brief already made.
468
468
 
package/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "ticketlens",
3
- "version": "0.38.46",
3
+ "version": "0.38.47",
4
4
  "description": "Jira CLI for developers — fetch ticket context, triage your queue, and stop tab-switching. Zero dependencies, all local.",
5
5
  "type": "module",
6
6
  "bin": {
@@ -1,4 +1,4 @@
1
- <!-- jtb-skill-version: 0.42.5 -->
1
+ <!-- jtb-skill-version: 0.42.6 -->
2
2
  ---
3
3
  name: jtb
4
4
  description: Fetch a Jira ticket's full context (description, comments, linked issues, code references) and assemble a structured TicketBrief for implementation planning. Use when user types /jtb, mentions a Jira ticket key, or wants to plan work from a Jira ticket.
@@ -397,7 +397,9 @@ When it does apply, run up to 3 rounds:
397
397
  ```
398
398
  `--expect-mtime` is what keeps this safe: if the file changed since step 1 (the user hand-edited it while you were drafting), the patch silently no-ops and prints "not found or already changed" — the user's own edit always wins, never gets clobbered by a stale background draft.
399
399
 
400
- If this harness has TicketLens's MCP server configured (a tool named `recall_update` — often shown as `mcp__ticketlens__recall_update` — visible in your tool list), prefer it over the bash form: same license gate, same structural/secret-scan checks, same optimistic-concurrency behavior via `expectMtime` — just no shell command or stdin piping to construct. It accepts `id`/`body`/`ticket`/`expectMtime`.
400
+ `note patch` also takes `--attach=path1,path2` (Pro), same caps and secret-scan treatment as `note add`'s — new files are appended to whatever the note already has, never replacing existing attachments.
401
+
402
+ If this harness has TicketLens's MCP server configured (a tool named `recall_update` — often shown as `mcp__ticketlens__recall_update` — visible in your tool list), prefer it over the bash form: same license gate, same structural/secret-scan checks, same optimistic-concurrency behavior via `expectMtime` — just no shell command or stdin piping to construct. It accepts `id`/`body`/`ticket`/`expectMtime`/`attachments`.
401
403
  5. Repeat from step 1 (re-capture mtime/body fresh each round) up to 3 total rounds. If no round ever produces a fully-passing draft, patch in whichever round scored highest across all attempts, and let the "not found or already changed" message stand if that patch itself loses a late race — don't retry past round 3.
402
404
 
403
405
  This never calls any external API or bills any tokens beyond the session you already have open — the generator and validator are subagents inside your own Claude Code session, not a TicketLens server call.
@@ -3,7 +3,7 @@
3
3
  * Centralised here to avoid triplicating the regex and warning logic.
4
4
  */
5
5
 
6
- export const DEFAULT_API_BASE = 'https://api.ticketlens.app';
6
+ export const DEFAULT_API_BASE = 'http://api.ticketlens.test';
7
7
  export const DEFAULT_SITE_BASE = 'https://ticketlens.app';
8
8
 
9
9
  // Matches localhost, 127.0.0.1, and any hostname ending in .test or .local,
@@ -393,11 +393,14 @@ async function callRecallAdd(args, { configDir, runNoteAddFn }) {
393
393
  * as buildNoteAddArgs above. `expectMtime` is optimistic-concurrency: a
394
394
  * caller that fetched a note via recall_search and wants to refine it
395
395
  * without racing a concurrent edit passes back the mtime it observed.
396
+ * `attachments` (backlog #21) is appended to whatever the note already has,
397
+ * same as buildNoteAddArgs's — never a replace.
396
398
  */
397
- function buildNotePatchArgs({ id, ticket, expectMtime }) {
399
+ function buildNotePatchArgs({ id, ticket, expectMtime, attachments }) {
398
400
  const args = [`--id=${id}`];
399
401
  if (ticket) args.push(`--ticket=${ticket}`);
400
402
  if (expectMtime !== undefined) args.push(`--expect-mtime=${expectMtime}`);
403
+ if (Array.isArray(attachments) && attachments.length > 0) args.push(`--attach=${attachments.join(',')}`);
401
404
  return args;
402
405
  }
403
406
 
@@ -180,6 +180,7 @@ export const TOOLS = [
180
180
  body: { type: 'string', description: 'The replacement note body — brief, not a paragraph. ~20 (strict), 30 (balanced), or 50 (loose) words max — scales with recallStrictness — going over doesn\'t block the update, but prints a non-blocking warning.' },
181
181
  ticket: { type: 'string', description: 'Ticket key the note is about, e.g. PROJ-123. Optional — narrows the search when omitted, the vault is searched across all ticket prefixes.' },
182
182
  expectMtime: { type: 'number', description: 'The note file\'s mtime (ms) last observed by the caller. If the note changed since then, the patch is a no-op rather than an overwrite — optimistic concurrency, not a hard requirement.' },
183
+ attachments: { type: 'array', items: { type: 'string' }, description: 'Local file paths to attach (screenshots, logs, etc.) — appended to whatever the note already has, never replacing existing attachments. Same 10MB/file, 50MB/call, 20-file caps as recall_add. Local vault only — recall_update never syncs to a team backend, so this never pushes.' },
183
184
  },
184
185
  required: ['id', 'body'],
185
186
  },
@@ -228,7 +228,9 @@ export async function runNoteAdd(cmdArgs, {
228
228
  * meant to be typed by hand): the loop's generator subagent produces a body,
229
229
  * SKILL.md's orchestration pipes it through this command, and the new body
230
230
  * gets exactly the same structural and secret gates a user-typed body gets —
231
- * there is no weaker path here for AI-authored content.
231
+ * there is no weaker path here for AI-authored content. `--attach` works the
232
+ * same as `note add`'s — files are appended to whatever the note already has,
233
+ * never replacing them.
232
234
  *
233
235
  * @param {string[]} cmdArgs
234
236
  * @returns {Promise<{ patched: boolean }>}
@@ -245,6 +247,7 @@ export async function runNotePatch(cmdArgs, {
245
247
  resolveEffectiveRecallStrictnessFn = resolveEffectiveRecallStrictness,
246
248
  scanForSecretsFn = scanForSecrets,
247
249
  patchNoteBodyFn = patchNoteBody,
250
+ readAttachmentsFn = readAttachments,
248
251
  } = {}) {
249
252
  if (!isLicensedFn('pro', configDir)) {
250
253
  showUpgradePrompt('pro', 'ticketlens note', { stream });
@@ -253,7 +256,7 @@ export async function runNotePatch(cmdArgs, {
253
256
 
254
257
  const id = parseFlag(cmdArgs, 'id');
255
258
  if (!id) {
256
- stream.write('Usage: ticketlens note patch --id="..." [--ticket=KEY]\n');
259
+ stream.write('Usage: ticketlens note patch --id="..." [--ticket=KEY] [--attach=path1,path2]\n');
257
260
  return { patched: false };
258
261
  }
259
262
 
@@ -288,11 +291,18 @@ export async function runNotePatch(cmdArgs, {
288
291
  stream.write(` Warning: ${warning}\n`);
289
292
  }
290
293
 
294
+ const attachPaths = parseAttachPaths(cmdArgs);
295
+ const { saved: attachments, warnings: attachWarnings } = attachPaths.length > 0
296
+ ? summarizeAttachments(readAttachmentsFn(attachPaths))
297
+ : { saved: [], warnings: [] };
298
+ for (const warning of attachWarnings) stream.write(warning);
299
+
291
300
  const ticketKeys = ticketKey ? [ticketKey] : [];
292
301
  const expectMtimeArg = parseFlag(cmdArgs, 'expect-mtime');
293
302
  const expectedMtimeMs = expectMtimeArg !== undefined ? Number(expectMtimeArg) : undefined;
294
- const { patched } = patchNoteBodyFn({ id, ticketKeys, body, expectedMtimeMs }, { configDir });
295
- stream.write(patched ? ` Updated note (${id})\n` : ` Note not updated — (${id}) not found or already changed.\n`);
303
+ const { patched } = patchNoteBodyFn({ id, ticketKeys, body, expectedMtimeMs, attachments }, { configDir });
304
+ const attachSuffix = patched && attachments.length > 0 ? ` + ${attachments.length} attachment(s)` : '';
305
+ stream.write(patched ? ` Updated note (${id})${attachSuffix}\n` : ` Note not updated — (${id}) not found or already changed.\n`);
296
306
  return { patched };
297
307
  }
298
308
 
@@ -90,7 +90,10 @@ function writeAttachments(noteDir, id, attachments) {
90
90
  if (attachments.length === 0) return [];
91
91
  const attachDir = attachmentsDirFor(noteDir, id);
92
92
  fs.mkdirSync(attachDir, { recursive: true });
93
- const used = new Set();
93
+ // Seeded from what's already on disk, not just this call's batch — patchNoteBody
94
+ // can call this a second time against the same note id, and a same-named file
95
+ // from an earlier add/patch must count toward uniqueness too.
96
+ const used = new Set(fs.readdirSync(attachDir));
94
97
  const saved = [];
95
98
  for (const { filename, buffer } of attachments) {
96
99
  const uniqueName = uniquifyFilename(filename, used);
@@ -248,8 +251,10 @@ export function deleteNoteAnyPrefix(externalId, { configDir = DEFAULT_CONFIG_DIR
248
251
  * Overwrites an existing local note's body in place — used by the jtb skill's
249
252
  * generator/validator quality loop to swap in a better draft after `note add`
250
253
  * already saved the original. Patch-only: never creates a note, and every
251
- * frontmatter field except body is carried over unchanged, so this can never
252
- * become a covert way to retitle/retag/re-tie a note to a different ticket.
254
+ * frontmatter field except body and attachments is carried over unchanged, so
255
+ * this can never become a covert way to retitle/retag/re-tie a note to a
256
+ * different ticket. New attachments are appended to whatever the note already
257
+ * has — a patch refines a note, it never discards what's already attached.
253
258
  *
254
259
  * Guards, same failure-mode split as deleteNote: a malformed id or ticket key
255
260
  * is a caller bug (throw); a missing file, an externalId that doesn't match
@@ -257,17 +262,18 @@ export function deleteNoteAnyPrefix(externalId, { configDir = DEFAULT_CONFIG_DIR
257
262
  * (expectedMtimeMs) are all best-effort no-ops, not errors — the original
258
263
  * note is always left exactly as-is on any of these.
259
264
  *
260
- * @param {{ id: string, ticketKeys?: string[], body: string, expectedMtimeMs?: number }} params
265
+ * @param {{ id: string, ticketKeys?: string[], body: string, expectedMtimeMs?: number, attachments?: Array<{ filename: string, buffer: Buffer }> }} params
261
266
  * @param {{ configDir?: string }} [opts]
262
267
  * @returns {{ patched: boolean, path: string|null }}
263
268
  */
264
- export function patchNoteBody({ id, ticketKeys = [], body, expectedMtimeMs }, { configDir = DEFAULT_CONFIG_DIR } = {}) {
269
+ export function patchNoteBody({ id, ticketKeys = [], body, expectedMtimeMs, attachments = [] }, { configDir = DEFAULT_CONFIG_DIR } = {}) {
265
270
  if (!EXTERNAL_ID_PATTERN.test(id)) {
266
271
  throw new Error(`Invalid note id: "${id}"`);
267
272
  }
268
273
 
269
274
  const prefix = resolvePrefix(ticketKeys[0]);
270
- const notePath = path.join(prefixDir(configDir, prefix), id);
275
+ const dir = prefixDir(configDir, prefix);
276
+ const notePath = path.join(dir, id);
271
277
 
272
278
  if (!fs.existsSync(notePath)) {
273
279
  return { patched: false, path: null };
@@ -281,6 +287,13 @@ export function patchNoteBody({ id, ticketKeys = [], body, expectedMtimeMs }, {
281
287
  return { patched: false, path: notePath };
282
288
  }
283
289
 
290
+ // existing.attachments is the full list already on disk (from add and/or a
291
+ // prior patch) — carried forward here, or the drop bug returns: patch would
292
+ // silently strip the attachments: key, orphaning files that stay on disk but
293
+ // become permanently unlisted and unpushable.
294
+ const savedAttachments = writeAttachments(dir, id, attachments);
295
+ const mergedAttachments = [...existing.attachments, ...savedAttachments];
296
+
284
297
  const data = {
285
298
  title: existing.title,
286
299
  aliases: existing.aliases,
@@ -291,6 +304,7 @@ export function patchNoteBody({ id, ticketKeys = [], body, expectedMtimeMs }, {
291
304
  status: existing.status,
292
305
  sources: existing.sources,
293
306
  externalId: existing.externalId,
307
+ ...(mergedAttachments.length > 0 ? { attachments: mergedAttachments } : {}),
294
308
  };
295
309
 
296
310
  writeFileAtomically(notePath, serializeFrontmatter(data, body));