@helpfeel/cosense-cli 1.19.0 → 1.20.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/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "@helpfeel/cosense-cli",
3
- "version": "1.19.0",
3
+ "version": "1.20.0",
4
4
  "description": "Cosense (旧Scrapbox) のページを読み・調べ・編集するAgent Skillのハーネス",
5
5
  "homepage": "https://github.com/helpfeel/cosense-cli",
6
6
  "license": "MIT",
@@ -29,8 +29,8 @@
29
29
  "devDependencies": {
30
30
  "@types/node": "24.19.2",
31
31
  "npm-run-all": "4.1.5",
32
- "oxfmt": "0.77.0",
33
- "oxlint": "1.92.0",
32
+ "oxfmt": "0.78.0",
33
+ "oxlint": "1.93.0",
34
34
  "typescript": "7.0.2"
35
35
  },
36
36
  "engines": {
package/src/cli.ts CHANGED
@@ -134,6 +134,8 @@ interface CommandSpec {
134
134
  handler: (args: string[]) => Promise<void>;
135
135
  summary: string;
136
136
  help: string;
137
+ // handlerが、引数の -- より後ろを位置引数として読むコマンド
138
+ acceptsSeparator?: boolean;
137
139
  }
138
140
 
139
141
  const packageJsonPath = join(
@@ -237,17 +239,20 @@ const commands: Record<string, CommandSpec> = {
237
239
  searchFullText: {
238
240
  handler: searchFullText,
239
241
  summary: searchFullTextSummary,
240
- help: searchFullTextHelp
242
+ help: searchFullTextHelp,
243
+ acceptsSeparator: true
241
244
  },
242
245
  search1hopLinks: {
243
246
  handler: search1hopLinks,
244
247
  summary: search1hopLinksSummary,
245
- help: search1hopLinksHelp
248
+ help: search1hopLinksHelp,
249
+ acceptsSeparator: true
246
250
  },
247
251
  search2hopLinks: {
248
252
  handler: search2hopLinks,
249
253
  summary: search2hopLinksSummary,
250
- help: search2hopLinksHelp
254
+ help: search2hopLinksHelp,
255
+ acceptsSeparator: true
251
256
  },
252
257
  previewEdit: {
253
258
  handler: previewEdit,
@@ -313,7 +318,10 @@ if (!spec) {
313
318
  process.exit(2);
314
319
  }
315
320
 
316
- if (rest.includes('--help')) {
321
+ // acceptsSeparatorのコマンドでは、-- より後ろの --help はhandlerに渡す引数である
322
+ const separatorIndex = spec.acceptsSeparator ? rest.indexOf('--') : -1;
323
+ const helpArgs = separatorIndex === -1 ? rest : rest.slice(0, separatorIndex);
324
+ if (helpArgs.includes('--help')) {
317
325
  process.stdout.write(`${spec.help}\n`);
318
326
  process.exit(0);
319
327
  }
@@ -15,16 +15,16 @@ Usage:
15
15
 
16
16
  戻り値(top-levelの主なkey):
17
17
  links1hop Array<Link> 1-hop近傍のページ配列
18
- charsCount number 対象ページの文字数
18
+ charsCount number links1hop のページの文字数の合計
19
19
  hasBackLinksOrIcons boolean 被リンク・アイコン参照があるか
20
20
  kcsControlTagsLc string[] 制御タグ
21
- pagination object ページネーション情報
21
+ pagination object { perPage, total, hasNext, nextId }
22
22
 
23
23
  各 Link の field:
24
- id, title, titleLc, image, descriptions(冒頭数行),
24
+ id, title, titleLc, image, descriptions?(冒頭数行),
25
25
  linksLc(リンク記法のtitleLc配列), linked(被リンク数), pageRank,
26
26
  infoboxDefinition, infoboxDisableLinks,
27
- created, updated, accessed, lastAccessed (string), charsCount,
27
+ created, updated, accessed, lastAccessed? (string | null), charsCount,
28
28
  user (作成者 User), lastUpdateUser (最終更新者 User | null), users (更新者リスト Array<User>),
29
29
  relation 'outgoing' | 'incoming' | 'bidirectional'
30
30
  outgoing 対象ページが参照しているページ(正リンク)
@@ -16,12 +16,12 @@ Usage:
16
16
  戻り値(top-levelの主なkey):
17
17
  links2hop Array<Link> 2-hop近傍のページ配列
18
18
  hiddenHeadwordsLc string[] 非表示のヘッドワード
19
- pagination object ページネーション情報
19
+ pagination object { perPage, total, hasNext, nextId }
20
20
 
21
21
  各 Link の field:
22
22
  id, title, titleLc, image, descriptions, linksLc, linked, pageRank,
23
23
  infoboxDefinition, infoboxDisableLinks,
24
- created, updated, accessed, lastAccessed (string), charsCount,
24
+ created, updated, accessed, lastAccessed? (string | null), charsCount,
25
25
  user (作成者 User), lastUpdateUser (最終更新者 User | null), users (更新者リスト Array<User>)
26
26
 
27
27
  User の field(user / lastUpdateUser / users[] で共通):
@@ -43,7 +43,7 @@ Usage:
43
43
  user (作成者 User), lastUpdateUser (最終更新者 User | null), users (更新者リスト Array<User>),
44
44
  pin (pinned page なら正の値), views, linked,
45
45
  linesCount, charsCount,
46
- created, updated, accessed, lastAccessed (string)
46
+ created, updated, accessed, lastAccessed? (string | null)
47
47
 
48
48
  User の field(user / lastUpdateUser / users[] で共通):
49
49
  id string Cosense内部のID
@@ -24,7 +24,7 @@ Project の field:
24
24
  loginStrategies Array<string> 認証方法(google / microsoft / saml / email 等)
25
25
  plan string? 課金plan名
26
26
  additionalPlans { [planName]: boolean } 追加plan
27
- alert object? project内に表示される通知
27
+ alert string? project内に表示される通知
28
28
  usersCount number メンバー数
29
29
  isMember boolean 自分がメンバーか
30
30
  billingId string? billing ID
@@ -16,7 +16,8 @@ Usage:
16
16
 
17
17
  戻り値(top-levelの主なkey):
18
18
  title string ページタイトル
19
- persistent boolean 実体のあるページなら true。false は未作成の新規ページ(関連ページリストは存在する場合がある)
19
+ persistent boolean 実体のあるページなら true。false は未作成の新規ページ(関連ページリストは存在する場合がある)。
20
+ false の時は、id / commitId / linked / created / updated / accessed / user / lastUpdateUser / users が無い
20
21
  id string ページID (persistent: true の時のみ)
21
22
  commitId string 最新コミットID (persistent: true の時のみ)
22
23
  lines Array<Line> 本文の行配列。Line = { id, text, user, created, updated } (id および user/timestamp 系は persistent: true の時のみ)
@@ -16,16 +16,18 @@ Usage:
16
16
 
17
17
  オプション:
18
18
  --or 複数語のいずれかにマッチするページを返す(既定はAND)
19
+ -- これより後ろを全て位置引数として読む。-- で始まる <query> を渡す時にその前に置き、オプションはこれより前に置く
19
20
 
20
21
  例:
21
22
  cosense search1hopLinks https://scrapbox.io/shokai/カレー "うどん ラーメン" --or
22
23
 
23
24
  戻り値(top-levelの主なkey):
24
- links1hop Array<Link> query を本文に含む1-hop近傍ページ
25
- ほか list1hopLinks と同じ top-level key
25
+ links1hop Array<Link> query にマッチした1-hop近傍ページ
26
+ ほか list1hopLinks と同じ top-level key。charsCount と pagination は、絞り込む前の値
26
27
 
27
- 各 Link の field(list1hopLinksに加えて):
28
- search 検索ハイライト情報
28
+ 各 Link の field(list1hopLinksとの違い):
29
+ descriptions? マッチした箇所がある時は、冒頭数行ではなく、その抜粋
30
+ search? { words, excludes }。query から読み取った、検索の語と除外の語
29
31
  `;
30
32
 
31
33
  const parseArgs = (
@@ -34,11 +36,17 @@ const parseArgs = (
34
36
  const usage = 'Usage: cosense search1hopLinks <pageUrl> <query> [--or]';
35
37
  let or = false;
36
38
  const positional: string[] = [];
37
- for (const arg of args) {
39
+ for (const [i, arg] of args.entries()) {
40
+ if (arg === '--') {
41
+ positional.push(...args.slice(i + 1));
42
+ break;
43
+ }
38
44
  if (arg === '--or') {
39
45
  or = true;
40
46
  } else if (arg.startsWith('--')) {
41
- throw new Error(`Unknown option: ${arg}\n${usage}`);
47
+ throw new Error(
48
+ `Unknown option: ${arg}\nIf <query> starts with --, put -- before <query> and place all options before --.\n${usage}`
49
+ );
42
50
  } else {
43
51
  positional.push(arg);
44
52
  }
@@ -16,16 +16,18 @@ Usage:
16
16
 
17
17
  オプション:
18
18
  --or 複数語のいずれかにマッチするページを返す(既定はAND)
19
+ -- これより後ろを全て位置引数として読む。-- で始まる <query> を渡す時にその前に置き、オプションはこれより前に置く
19
20
 
20
21
  例:
21
22
  cosense search2hopLinks https://scrapbox.io/shokai/カレー "うどん ラーメン" --or
22
23
 
23
24
  戻り値(top-levelの主なkey):
24
- links2hop Array<Link> query を本文に含む2-hop近傍ページ
25
- ほか list2hopLinks と同じ top-level key
25
+ links2hop Array<Link> query にマッチした2-hop近傍ページ
26
+ ほか list2hopLinks と同じ top-level key。pagination は、絞り込む前の値
26
27
 
27
- 各 Link の field(list2hopLinksに加えて):
28
- search 検索ハイライト情報
28
+ 各 Link の field(list2hopLinksとの違い):
29
+ descriptions マッチした箇所がある時は、冒頭数行ではなく、その抜粋
30
+ search? { words, excludes }。query から読み取った、検索の語と除外の語
29
31
  `;
30
32
 
31
33
  const parseArgs = (
@@ -34,11 +36,17 @@ const parseArgs = (
34
36
  const usage = 'Usage: cosense search2hopLinks <pageUrl> <query> [--or]';
35
37
  let or = false;
36
38
  const positional: string[] = [];
37
- for (const arg of args) {
39
+ for (const [i, arg] of args.entries()) {
40
+ if (arg === '--') {
41
+ positional.push(...args.slice(i + 1));
42
+ break;
43
+ }
38
44
  if (arg === '--or') {
39
45
  or = true;
40
46
  } else if (arg.startsWith('--')) {
41
- throw new Error(`Unknown option: ${arg}\n${usage}`);
47
+ throw new Error(
48
+ `Unknown option: ${arg}\nIf <query> starts with --, put -- before <query> and place all options before --.\n${usage}`
49
+ );
42
50
  } else {
43
51
  positional.push(arg);
44
52
  }
@@ -18,15 +18,17 @@ Usage:
18
18
  オプション:
19
19
  --or 複数語のいずれかにマッチするページを返す(既定はAND)
20
20
  --sort <pageRank|updated> 並び順(既定はpageRank)
21
+ -- これより後ろを全て位置引数として読む。-- で始まる <query> を渡す時にその前に置き、オプションはこれより前に置く
21
22
 
22
23
  例:
23
24
  cosense searchFullText https://scrapbox.io/shokai/ "デザイン 設計 design UI UX プロトタイプ" --or
25
+ cosense searchFullText https://scrapbox.io/shokai/ --or -- "--force --no-verify"
24
26
 
25
27
  戻り値(top-levelの主なkey):
26
28
  projectName string プロジェクト名
27
29
  searchQuery string 実行されたクエリ
28
- count number ヒット総数
29
- limit number 1リクエストで返る上限
30
+ count number pages の件数。ヒットの総数ではない
31
+ limit number 検索する件数の上限
30
32
  pages Array<Page> マッチしたページの配列
31
33
  existsExactTitleMatch boolean タイトル完全一致がある場合 true
32
34
 
@@ -43,8 +45,8 @@ Usage:
43
45
  pageRank number PageRank
44
46
  linesCount number 行数
45
47
  charsCount number 文字数
46
- words string[] マッチした語の一覧
47
- lines string[] マッチした本文の行
48
+ words string[] query から読み取った検索の語
49
+ lines string[] マッチした箇所の抜粋。タイトルの行や、本文の要約になる事がある
48
50
 
49
51
  User の field(user / lastUpdateUser / users[] で共通):
50
52
  id string Cosense内部のID
@@ -85,6 +87,10 @@ const parseArgs = (args: string[]): ParsedArgs => {
85
87
  const positional: string[] = [];
86
88
  for (let i = 0; i < args.length; i += 1) {
87
89
  const arg = args[i] as string;
90
+ if (arg === '--') {
91
+ positional.push(...args.slice(i + 1));
92
+ break;
93
+ }
88
94
  if (arg === '--or') {
89
95
  or = true;
90
96
  } else if (arg === '--sort') {
@@ -98,7 +104,9 @@ const parseArgs = (args: string[]): ParsedArgs => {
98
104
  sort = value;
99
105
  i += 1;
100
106
  } else if (arg.startsWith('--')) {
101
- throw new Error(`Unknown option: ${arg}\n${usage}`);
107
+ throw new Error(
108
+ `Unknown option: ${arg}\nIf <query> starts with --, put -- before <query> and place all options before --.\n${usage}`
109
+ );
102
110
  } else {
103
111
  positional.push(arg);
104
112
  }
@@ -15,12 +15,12 @@ Usage:
15
15
 
16
16
  戻り値(top-levelの主なkey):
17
17
  id string Cosense内部のID
18
- name string ログイン名
18
+ name string? ログイン名
19
19
  displayName string 表示名
20
- email string メールアドレス
20
+ email string? メールアドレス
21
21
  photo string アイコン画像URL
22
22
  provider string 認証プロバイダ(google / microsoft / saml 等)
23
- pageFilters Array<{type, value}> page list filter設定
23
+ pageFilters Array<{type, value?}> page list filter設定
24
24
  created string 作成時刻
25
25
  updated string 更新時刻
26
26
  `;