@basou/core 0.20.0 → 0.21.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/dist/index.d.ts CHANGED
@@ -570,10 +570,14 @@ type ClaudeTranscriptToPayloadOptions = {
570
570
  * - `command_executed` from each `Bash` tool use, recorded as `bash -c "<cmd>"`
571
571
  * (the transcript carries the shell line, not a parsed argv).
572
572
  * - `file_changed` from each `Edit` / `Write` / `NotebookEdit` tool use.
573
- * - `decision_recorded` from each `AskUserQuestion` tool use: one decision per
574
- * question, titled `<question> -> <chosen answer>`. The chosen answer is read
575
- * from the paired result record's structured `toolUseResult.answers` map; a
576
- * question with no recorded string answer is skipped.
573
+ * - `decision_recorded` from each `AskUserQuestion` tool use, but ONLY when the
574
+ * recorded answer is a confirmed SELECTION it exactly matches an option the
575
+ * question offered (`input.questions[].options[].label`). One decision per
576
+ * such question, titled `<question> -> <chosen answer>`. The answer is read
577
+ * from the paired result record's `toolUseResult.answers` map; a question with
578
+ * no recorded answer, or a free-text "Other" reply that matches no offered
579
+ * label, is skipped (it is not a decision, and would otherwise pollute
580
+ * decisions.md / orientation's latest-decision surface).
577
581
  *
578
582
  * Exit codes and per-command durations are not present in the transcript, so
579
583
  * `command_executed.exit_code` is `null` and `duration_ms` is `0`.
package/dist/index.js CHANGED
@@ -246,11 +246,16 @@ function claudeTranscriptToImportPayload(records, options) {
246
246
  const useId = readString2(item.id);
247
247
  const answers = useId !== void 0 ? askAnswers.get(useId) : void 0;
248
248
  if (answers !== void 0) {
249
+ const offeredByQuestion = readOfferedOptions(input);
249
250
  for (const [question, answer] of Object.entries(answers)) {
250
251
  if (question.length === 0) continue;
251
252
  const answerStr = typeof answer === "string" && answer.length > 0 ? answer : void 0;
252
- const title = answerStr !== void 0 ? `${question} -> ${answerStr}` : question;
253
- derived.push(decisionRecordedEvent(ts, placeholderSessionId, title));
253
+ if (answerStr === void 0) continue;
254
+ const offered = offeredByQuestion.get(question);
255
+ if (offered === void 0 || !offered.has(answerStr.trim())) continue;
256
+ derived.push(
257
+ decisionRecordedEvent(ts, placeholderSessionId, `${question} -> ${answerStr}`)
258
+ );
254
259
  }
255
260
  }
256
261
  continue;
@@ -410,6 +415,24 @@ function indexAskAnswers(records) {
410
415
  }
411
416
  return byId;
412
417
  }
418
+ function readOfferedOptions(input) {
419
+ const byQuestion = /* @__PURE__ */ new Map();
420
+ const questions = Array.isArray(input.questions) ? input.questions : [];
421
+ for (const q of questions) {
422
+ if (!isObject2(q)) continue;
423
+ const text = readString2(q.question);
424
+ if (text === void 0) continue;
425
+ const labels = /* @__PURE__ */ new Set();
426
+ const options = Array.isArray(q.options) ? q.options : [];
427
+ for (const o of options) {
428
+ if (!isObject2(o)) continue;
429
+ const label = readString2(o.label);
430
+ if (label !== void 0) labels.add(label.trim());
431
+ }
432
+ byQuestion.set(text, labels);
433
+ }
434
+ return byQuestion;
435
+ }
413
436
 
414
437
  // src/adapters/codex/rollout-importer.ts
415
438
  var CODEX_IMPORT_SOURCE = "codex-import";
@@ -4825,6 +4848,11 @@ function formatOrientationBody(summary, opts) {
4825
4848
  lines.push(`> hosts: local, ${summary.hosts.join(", ")}`);
4826
4849
  }
4827
4850
  lines.push("");
4851
+ const banner = stalenessBanner(opts.staleness);
4852
+ if (banner.length > 0) {
4853
+ for (const line of banner) lines.push(line);
4854
+ lines.push("");
4855
+ }
4828
4856
  lines.push("## \u4ECA\u3069\u3053\u306B\u3044\u308B");
4829
4857
  lines.push("");
4830
4858
  if (summary.latestSession !== null) {
@@ -5024,6 +5052,23 @@ function toolDisplayName(kind) {
5024
5052
  return kind ?? "\u4E0D\u660E";
5025
5053
  }
5026
5054
  }
5055
+ function stalenessBanner(staleness) {
5056
+ if (staleness === null) return [];
5057
+ if ((staleness.unverifiableSessions ?? 0) > 0) {
5058
+ return [
5059
+ `> \u26A0\uFE0F **\u6700\u65B0\u3067\u306F\u306A\u3044\u53EF\u80FD\u6027** \u2014 \u5909\u5316\u3057\u305F\u304C\u5B89\u5168\u306B\u53D6\u308A\u8FBC\u3081\u306A\u3044\u30BB\u30C3\u30B7\u30E7\u30F3\u304C ${staleness.unverifiableSessions} \u4EF6\u3042\u308A\u307E\u3059\u3002\u7740\u624B\u524D\u306B \`basou verify\` / \`basou refresh --force\`(\u8A73\u7D30\u306F\u672B\u5C3E\u300C\u3053\u308C\u306F\u6700\u65B0\u304B\u300D)\u3002`
5060
+ ];
5061
+ }
5062
+ if (staleness.newSessions > 0 || staleness.updatedSessions > 0) {
5063
+ const parts = [];
5064
+ if (staleness.newSessions > 0) parts.push(`\u65B0\u898F ${staleness.newSessions} \u4EF6`);
5065
+ if (staleness.updatedSessions > 0) parts.push(`\u66F4\u65B0 ${staleness.updatedSessions} \u4EF6`);
5066
+ return [
5067
+ `> \u26A0\uFE0F **\u53E4\u3044\u304B\u3082\u3057\u308C\u307E\u305B\u3093** \u2014 \u672A\u53D6\u308A\u8FBC\u307F\u306E\u4F5C\u696D\u304C\u3042\u308A\u307E\u3059(${parts.join("\u30FB")})\u3002\u7740\u624B\u524D\u306B \`basou refresh\` \u3067\u66F4\u65B0\u3057\u3066\u304F\u3060\u3055\u3044(\u8A73\u7D30\u306F\u672B\u5C3E\u300C\u3053\u308C\u306F\u6700\u65B0\u304B\u300D)\u3002`
5068
+ ];
5069
+ }
5070
+ return [];
5071
+ }
5027
5072
  function freshnessVerdict(summary, staleness, now) {
5028
5073
  if (staleness !== null && (staleness.unverifiableSessions ?? 0) > 0) {
5029
5074
  return [