@helpfeel/cosense-cli 1.5.0 → 1.5.1

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/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "@helpfeel/cosense-cli",
3
- "version": "1.5.0",
3
+ "version": "1.5.1",
4
4
  "description": "Cosense (旧Scrapbox) のページを読み・調べ・編集するAgent Skill用のCLI",
5
5
  "homepage": "https://github.com/helpfeel/cosense-cli",
6
6
  "license": "MIT",
@@ -16,9 +16,9 @@ import {
16
16
  import { resolveCredential } from '../lib/settings.ts';
17
17
 
18
18
  export const browsePageSummary =
19
- '単一ページを読む。メタデータ+アイコン記法+テロメア+本文をAIが読みやすい形式で出力する。行permalink (`#<lineId>`) 付きなら該当行をマークする';
19
+ '単一ページを読む。メタデータ+アイコン記法+テロメア+Infobox+本文をAIが読みやすい形式で出力する。行permalink (`#<lineId>`) 付きなら該当行をマークする';
20
20
 
21
- export const browsePageHelp = `browsePage - 単一ページを読む。メタデータ+アイコン記法+テロメア+本文をAIが読みやすい形式で出力する。行permalink (#<lineId>) 付きなら該当行をマークする
21
+ export const browsePageHelp = `browsePage - 単一ページを読む。メタデータ+アイコン記法+テロメア+Infobox+本文をAIが読みやすい形式で出力する。行permalink (#<lineId>) 付きなら該当行をマークする
22
22
 
23
23
  Usage:
24
24
  cosense browsePage <pageUrl>
@@ -46,6 +46,12 @@ Usage:
46
46
  lines[] を最終更新者でグルーピングし、 displayName 更新期間 YYYY/M/D 〜 YYYY/M/D N行更新
47
47
  の形式で行数降順に全員出力
48
48
 
49
+ ## Infobox
50
+ このページ本文から抜き出された Infobox を出力する。各 Infobox を ### <title> の
51
+ 見出しと - キー: 値 の箇条書きで表す。値はCosense記法のまま。
52
+ hallucination または truncated と判定された Infobox は除外する。
53
+ 0件の場合はセクションごと省略
54
+
49
55
  ## 本文
50
56
  各行の text を改行で結合。fragment 指定行のみ末尾に #<lineId> を付与
51
57
 
@@ -56,7 +62,7 @@ Usage:
56
62
  このページの 1-hop 近傍ページタイトル一覧。 1-hop が 0 件なら区切り線ごと省略
57
63
 
58
64
  persistent: false の時:
59
- メタデータ・アイコン・テロメアは省略。 (このページはまだ作成されていません) と
65
+ メタデータ・アイコン・テロメア・Infoboxは省略。 (このページはまだ作成されていません) と
60
66
  本文(テンプレート)と Related Pages を出力する
61
67
 
62
68
  URLに #<lineId> fragmentが指定された時:
@@ -81,6 +87,13 @@ interface UserRef {
81
87
  displayName?: string;
82
88
  }
83
89
 
90
+ interface InfoboxResult {
91
+ title?: string;
92
+ infobox?: Record<string, string>;
93
+ hallucination?: boolean;
94
+ truncated?: boolean;
95
+ }
96
+
84
97
  interface PageData {
85
98
  id?: string;
86
99
  commitId?: string;
@@ -102,6 +115,7 @@ interface PageData {
102
115
  users?: UserRef[];
103
116
  lines?: PageLine[];
104
117
  icons?: string[];
118
+ infoboxResult?: InfoboxResult[];
105
119
  }
106
120
 
107
121
  const LINE_ID_PATTERN = /^[0-9a-f]{24}$/;
@@ -224,6 +238,23 @@ const renderTelomere = (
224
238
  return `## テロメアのサマリー\n\n${lines.join('\n')}`;
225
239
  };
226
240
 
241
+ const renderInfobox = (results: InfoboxResult[] | undefined): string | null => {
242
+ if (!results) return null;
243
+ const blocks: string[] = [];
244
+ for (const result of results) {
245
+ // hallucination=AI補完の不確実値、truncated=抽出失敗で値が不完全。どちらも
246
+ // 信頼できないので丸ごと除外する
247
+ if (result.hallucination || result.truncated) continue;
248
+ const rows = Object.entries(result.infobox ?? {}).map(
249
+ ([key, value]) => `- ${key}: ${value}`
250
+ );
251
+ if (rows.length === 0) continue;
252
+ blocks.push(`### ${result.title ?? ''}\n\n${rows.join('\n')}`);
253
+ }
254
+ if (blocks.length === 0) return null;
255
+ return `## Infobox\n\n${blocks.join('\n\n')}`;
256
+ };
257
+
227
258
  interface BodyRender {
228
259
  body: string;
229
260
  matchedFragment: boolean;
@@ -324,6 +355,9 @@ export const browsePage = async (args: string[]): Promise<void> => {
324
355
  const telomereSection = renderTelomere(telomere, userMap);
325
356
  if (telomereSection) sections.push(telomereSection);
326
357
 
358
+ const infoboxSection = renderInfobox(page.infoboxResult);
359
+ if (infoboxSection) sections.push(infoboxSection);
360
+
327
361
  sections.push(`## 本文\n\n${body}`);
328
362
 
329
363
  const related = renderRelatedPages(hopValue);