@takagaki/cortex-decisions-viewer 0.12.83 → 0.12.84

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/build.js CHANGED
@@ -141,6 +141,10 @@ const SANITIZE_OPTIONS = {
141
141
  // タスクリスト `- [ ]` / `- [x]` のチェック状態を残すのに要る。
142
142
  // 落とすと**装飾ではなく情報(未完了/完了の別)が消える**
143
143
  "input",
144
+ // 折りたたみ(#702)。engine が関係者の記録の末尾に「この人が関わった決定」を
145
+ // details で畳んで書く。落とすと一覧が常時展開のベタテキストになる。
146
+ // 属性は 1 つも許可しない(open も通さない=常に閉じた状態で出る)
147
+ "details", "summary",
144
148
  ],
145
149
  allowedAttributes: {
146
150
  a: ["href", "target", "rel"],
@@ -213,6 +217,8 @@ async function renderGroundingSection(markdown) {
213
217
  */
214
218
  function toSearchText(md) {
215
219
  return md
220
+ .replace(/<!--[\s\S]*?-->/g, " ") // HTML コメント(engine の機械ブロックの印など・画面にも出ない)
221
+ .replace(/<\/?(details|summary)>/g, " ") // 折りたたみのタグ(#702)。文字は検索に要らない
216
222
  .replace(/!\[[^\]]*\]\([^)]*\)/g, " ") // 画像
217
223
  .replace(/\[([^\]]*)\]\([^)]*\)/g, "$1") // リンクはラベルだけ残す
218
224
  .replace(/[#>*_~`|]+/g, " ") // markdown記号・表の罫線
@@ -78,6 +78,8 @@ exports.WEIGHTS = Object.freeze({
78
78
  "record.confirmed": 2.0,
79
79
  "record.edited": 2.0,
80
80
  "record.deleted": 0,
81
+ // 本文を取り込んだ(engine #695)。人の行為ではないので 0(話した人は `utterance.spoken` で数える)
82
+ "body.captured": 0,
81
83
  });
82
84
  const DAY_MS = 86400000;
83
85
  const cmp = (a, b) => (a < b ? -1 : a > b ? 1 : 0);
@@ -289,6 +289,41 @@ function normalizeForCompare(text) {
289
289
  * 使われない 1 行(`side: cm`)が移行で消えたことだった。`identities` のような欄が
290
290
  * 足された晩に、説明文が 1 文字も変わっていないのに印を立てない。
291
291
  */
292
+ /** engine が関係者の記録の末尾に毎晩書く「この人が関わった決定」の印(#702) */
293
+ const MEMBER_DECISIONS_START = "<!-- cortex-engine:member-decisions -->";
294
+ const MEMBER_DECISIONS_END = "<!-- /cortex-engine:member-decisions -->";
295
+ /**
296
+ * 本文から engine の機械ブロック(「この人が関わった決定」)を取り除く(#702)。
297
+ *
298
+ * 🔴 **engine の写し(`scripts/rederive/content-sha.mjs`)と同じ規則。** 変えたら両方を変える。
299
+ * 開始の印**だけ**の行(行末の `\r` は無視)から、終了の印**だけ**の行までを(両端を含めて)消す。終了の印が
300
+ * 無ければ本文の終わりまで消す。塊の前後の空行も除き、両側に本文が残れば空行 1 行でつなぐ。そのあと末尾の空行を落とす。ブロックの無い本文は触らない。
301
+ *
302
+ * 毎晩書き換わる機械の一覧を「人が確認した版から中身が変わっています」に数えないため。
303
+ * ブロックの外を人が 1 文字でも直せば、従来どおり指紋は変わる。
304
+ */
305
+ function stripMemberDecisions(body) {
306
+ const lines = body.split("\n");
307
+ // 行末の `\r` は見ない(CRLF の記録でも印の行として当てる。当てないと毎晩印が立つ)
308
+ const is = (marker) => (line) => line.replace(/\r$/, "") === marker;
309
+ const start = lines.findIndex(is(MEMBER_DECISIONS_START));
310
+ if (start < 0)
311
+ return body;
312
+ const endRel = lines.slice(start + 1).findIndex(is(MEMBER_DECISIONS_END));
313
+ const end = endRel < 0 ? lines.length : start + 1 + endRel + 1;
314
+ const isBlank = (line) => line.trim() === "";
315
+ // 塊の前後の空行も一緒に除き、両側に本文が残れば空行 1 行でつなぐ(engine の書き手と同じ規則・#702 実装レビュー R1)
316
+ const before = lines.slice(0, start);
317
+ while (before.length && isBlank(before[before.length - 1]))
318
+ before.pop();
319
+ const after = lines.slice(end);
320
+ while (after.length && isBlank(after[0]))
321
+ after.shift();
322
+ const kept = [...before, ...(before.length && after.length ? [""] : []), ...after];
323
+ while (kept.length && isBlank(kept[kept.length - 1]))
324
+ kept.pop();
325
+ return kept.join("\n");
326
+ }
292
327
  function comparableContent(raw) {
293
328
  let data = {};
294
329
  let content = String(raw ?? "");
@@ -303,7 +338,7 @@ function comparableContent(raw) {
303
338
  }
304
339
  return {
305
340
  description: normalizeForCompare(String(data.description ?? "")),
306
- body: normalizeForCompare(content),
341
+ body: normalizeForCompare(stripMemberDecisions(content)),
307
342
  };
308
343
  }
309
344
  /** 2 つの版で「説明文と本文」が同じか(frontmatter の他の欄の差は見ない) */
package/dist/render.js CHANGED
@@ -5741,6 +5741,10 @@ button.ops-card-btn:disabled { opacity: .6; cursor: default; }
5741
5741
  .body pre code { background: none; padding: 0; color: inherit; }
5742
5742
  .body table { border-collapse: collapse; width: 100%; }
5743
5743
  .body th, .body td { border: 1px solid var(--border); padding: 6px 10px; text-align: left; }
5744
+ /* 本文中の折りたたみ(#702・関係者の記録の「この人が関わった決定」)。見出しの 1 行を押して開く */
5745
+ .body details { margin: 12px 0; }
5746
+ .body details > summary { cursor: pointer; }
5747
+ .body details[open] > summary { margin-bottom: 8px; }
5744
5748
  .body-loading { color: var(--muted); font-size: 13px; padding: 8px 2px; }
5745
5749
 
5746
5750
  /* 一行の結果表示(トースト)。#348 の案件アイコンで使う。
package/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "@takagaki/cortex-decisions-viewer",
3
- "version": "0.12.83",
3
+ "version": "0.12.84",
4
4
  "description": "Cortexの意思決定記録(Decisions/*.md)を静的サイトにビルドして閲覧する。各レコードに「Edit on GitHub」リンクを付与する。",
5
5
  "license": "UNLICENSED",
6
6
  "private": false,