@distlang/opencode-plugin 0.1.6 → 0.1.7

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.
Files changed (2) hide show
  1. package/package.json +1 -1
  2. package/src/recorder.js +14 -4
package/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "@distlang/opencode-plugin",
3
- "version": "0.1.6",
3
+ "version": "0.1.7",
4
4
  "description": "OpenCode plugin for Distlang AI Debugger",
5
5
  "type": "module",
6
6
  "main": "./src/index.js",
package/src/recorder.js CHANGED
@@ -357,7 +357,8 @@ export function createRecorder({ project, directory }) {
357
357
  }
358
358
 
359
359
  function buildSessionPayload(recorder) {
360
- const interactions = recorder.interactions.map(buildInteractionPayload);
360
+ const sessionTitle = sanitizeDebuggerText(recorder.title);
361
+ const interactions = recorder.interactions.map((interaction) => buildInteractionPayload(interaction, sessionTitle));
361
362
  const allSteps = interactions.flatMap((interaction) => interaction.steps);
362
363
  const llmSteps = allSteps.filter((step) => step.kind === "llm_call");
363
364
  const contextValues = llmSteps.map((step) => step.context_size_tokens).filter((value) => value > 0);
@@ -389,10 +390,14 @@ function buildSessionPayload(recorder) {
389
390
  };
390
391
  }
391
392
 
392
- function buildInteractionPayload(interaction) {
393
+ function buildInteractionPayload(interaction, sessionTitle = "") {
393
394
  const llmSteps = interaction.steps.filter((step) => step.kind === "llm_call");
394
395
  const contextValues = llmSteps.map((step) => step.context_size_tokens).filter((value) => value > 0);
395
- const prompt = configuredValue(interaction.prompt, `Interaction ${interaction.index}`);
396
+ const promptFallback = configuredValue(sessionTitle, `Interaction ${interaction.index}`);
397
+ const rawPrompt = sanitizeDebuggerText(interaction.prompt);
398
+ const rawSummary = sanitizeDebuggerText(interaction.summary);
399
+ const prompt = isGenericInteractionLabel(rawPrompt) ? promptFallback : configuredValue(rawPrompt, promptFallback);
400
+ const summaryFallback = summarizePrompt(prompt, promptFallback);
396
401
  return {
397
402
  id: interaction.id,
398
403
  index: interaction.index,
@@ -402,7 +407,7 @@ function buildInteractionPayload(interaction) {
402
407
  ended_at: interaction.endedAtMs > 0 ? new Date(interaction.endedAtMs).toISOString() : new Date(Date.now()).toISOString(),
403
408
  duration_ms: Math.max(0, (interaction.endedAtMs || Date.now()) - interaction.startedAtMs),
404
409
  status: inferResultStatus(interaction.steps.map((step) => step.status), interaction.status),
405
- summary: configuredValue(interaction.summary, summarizePrompt(prompt, `Interaction ${interaction.index}`)),
410
+ summary: isGenericInteractionLabel(rawSummary) ? summaryFallback : configuredValue(rawSummary, summaryFallback),
406
411
  llm_call_count: llmSteps.length,
407
412
  cost_usd: interaction.steps.reduce((total, step) => total + finiteNumber(step.cost_usd), 0),
408
413
  input_tokens: interaction.steps.reduce((total, step) => total + finiteNumber(step.input_tokens), 0),
@@ -417,6 +422,11 @@ function buildInteractionPayload(interaction) {
417
422
  };
418
423
  }
419
424
 
425
+ function isGenericInteractionLabel(value) {
426
+ const label = String(value || "").trim();
427
+ return /^OpenCode interaction \d+$/i.test(label) || /^Interaction \d+$/i.test(label);
428
+ }
429
+
420
430
  function configuredValue(value, fallback = "") {
421
431
  return typeof value === "string" && value.trim() !== "" ? value.trim() : fallback;
422
432
  }