@helpfeel/cosense-cli 1.3.1 → 1.4.2

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/README.md CHANGED
@@ -1,17 +1,10 @@
1
1
  # @helpfeel/cosense-cli
2
2
 
3
- Cosenseのページを読み・調べ・編集する為のCLIとAgent Skill
3
+ Cosenseのページを読み・調べ・編集するAgent SkillとCLI
4
4
 
5
- ## Install
5
+ ## Install Agent Skill
6
6
 
7
- ### CLI
8
-
9
- ```bash
10
- npm install -g @helpfeel/cosense-cli
11
- cosense --help
12
- ```
13
-
14
- ### Claude Code Agent Skill
7
+ ### for Claude Code
15
8
 
16
9
  ```
17
10
  /plugin marketplace add helpfeel/cosense-cli
@@ -21,7 +14,20 @@ cosense --help
21
14
  /plugin install cosense-cli@cosense-cli
22
15
  ```
23
16
 
24
- Skillの実行にはCLIが必要
17
+ ### for Codex
18
+
19
+ ```
20
+ $skill-installer https://github.com/helpfeel/cosense-cli
21
+ ```
22
+
23
+ ## Install CLI
24
+
25
+ Skillの実行にはCLIが必要です
26
+
27
+ ```bash
28
+ npm install -g @helpfeel/cosense-cli
29
+ cosense --help
30
+ ```
25
31
 
26
32
  ## 開発
27
33
 
package/package.json CHANGED
@@ -1,15 +1,15 @@
1
1
  {
2
2
  "name": "@helpfeel/cosense-cli",
3
- "version": "1.3.1",
4
- "description": "Cosense (旧Scrapbox) のページを読み・調べ・編集するCLI",
3
+ "version": "1.4.2",
4
+ "description": "Cosense (旧Scrapbox) のページを読み・調べ・編集するAgent Skill用のCLI",
5
5
  "homepage": "https://github.com/helpfeel/cosense-cli",
6
6
  "license": "MIT",
7
7
  "repository": {
8
8
  "type": "git",
9
- "url": "https://github.com/helpfeel/cosense-cli.git"
9
+ "url": "git+https://github.com/helpfeel/cosense-cli.git"
10
10
  },
11
11
  "bin": {
12
- "cosense": "./bin/cosense"
12
+ "cosense": "bin/cosense"
13
13
  },
14
14
  "files": [
15
15
  "bin",
@@ -38,6 +38,6 @@
38
38
  },
39
39
  "publishConfig": {
40
40
  "access": "public",
41
- "registry": "https://registry.npmjs.com/"
41
+ "registry": "https://registry.npmjs.org/"
42
42
  }
43
43
  }
@@ -52,7 +52,7 @@ Usage:
52
52
  ## 1 hop link
53
53
  このページの 1-hop 近傍ページタイトル一覧。 1-hop が 0 件なら区切り線ごと省略
54
54
 
55
- 非存在ページ (persistent: false):
55
+ persistent: false の時:
56
56
  メタデータ・アイコン・テロメアは省略。 (このページはまだ作成されていません) と
57
57
  本文(テンプレート)と Related Pages を出力する
58
58
 
@@ -7,9 +7,9 @@ import {
7
7
  import { fetchRelatedPages } from '../lib/relatedPages.ts';
8
8
 
9
9
  export const browseRelatedPagesSummary =
10
- '1-hop+2-hopのタイトル一覧を眺める。単独のページだけを見ていては掴みきれない文脈が浮かび上がる';
10
+ '1-hop+2-hopの関連ページタイトル一覧をAIが読みやすい形式で出力する';
11
11
 
12
- export const browseRelatedPagesHelp = `browseRelatedPages - 1-hop+2-hopのタイトル一覧を眺める。単独のページだけを見ていては掴みきれない文脈が浮かび上がる
12
+ export const browseRelatedPagesHelp = `browseRelatedPages - 1-hop+2-hopの関連ページタイトル一覧をAIが読みやすい形式で出力する
13
13
 
14
14
  Usage:
15
15
  cosense browseRelatedPages <pageUrl>
@@ -52,7 +52,7 @@ User の field(user / lastUpdateUser / users[] で共通):
52
52
  email string? メールアドレス
53
53
 
54
54
  注意:
55
- - ページ本文(lines)は含まれない。本文が必要なら readPage を使う
55
+ - ページ本文(lines)は含まれない
56
56
  - 1000件を超える件数を1リクエストで取ることはできない。--skip でページネーションする
57
57
  `;
58
58
 
@@ -9,14 +9,15 @@ export const previewEditSummary =
9
9
  export const previewEditHelp = `previewEdit - ページ編集opsをdry-runしてpreviewIdを取得する
10
10
 
11
11
  Usage:
12
- cosense previewEdit <projectUrl> <pageId> < ops.json 既存ページの編集 (stdinはops JSON)
13
- cosense previewEdit --new <projectUrl> < body.txt 新規ページ作成 (stdinはプレーンテキスト本文)
14
- echo '<opsJSON>' | cosense previewEdit <projectUrl> <pageId>
15
- echo '<text>' | cosense previewEdit --new <projectUrl>
12
+ cosense previewEdit <projectUrl> <pageId> < ops.json 既存ページの編集 (stdinはops JSON)
13
+ cosense previewEdit --new <projectUrl> < body.txt 新規ページ作成 (stdinはプレーンテキスト本文)
14
+ printf '%s' '<opsJSON>' | cosense previewEdit <projectUrl> <pageId>
15
+ printf '%s' '<text>' | cosense previewEdit --new <projectUrl>
16
16
 
17
17
  引数:
18
18
  <projectUrl> プロジェクトのURL (例: https://scrapbox.io/shokai)。 末尾に余分なpathがあるとerror
19
19
  <pageId> 編集対象ページのID。 readPage 出力の top-level "id" field から取得する
20
+ ops 内の <lineId> は readPage 出力の lines[].id から取得する
20
21
 
21
22
  オプション:
22
23
  --new stdin をプレーンテキスト本文として受け取り、 新規ページを作る。 改行で複数行に分割され、
@@ -36,12 +37,9 @@ stdinから受け取る入力形式(既存ページ編集モード, JSON):
36
37
  replace: <lineId> の本文を置き換える。textは単行のみ。改行を含むtextは拒否される
37
38
  delete: <lineId> の行を削除する
38
39
 
39
- 「特定行を複数行に分割したい」場合は、insertBefore で対象lineIdの直前に複数行を挿入してから、
40
- 対象行を delete する。ops は配列順に適用されるので「先に delete してから insertBefore」 とすると
41
- anchor が消えて 422 になる。
42
-
43
- ops は順次適用される。同じ lineId に対する insertBefore を [A, B, C] の順で並べると、
44
- 適用後の行順は元行の直前に [A, B, C] が並ぶ(入力順が保たれる)。
40
+ ops は配列順に適用される。同じ anchor に対する insertBefore を [A, B, C] の順で並べると、
41
+ 適用後の行順は元行の直前に [A, B, C] が並ぶ(入力順が保たれる)。anchor は適用時点で存在
42
+ する必要がある(消えた lineId を anchor に指定すると 422)。
45
43
 
46
44
  戻り値(plain text):
47
45
  previewId / expireAt / status (create or update) / project / title のヘッダー +
@@ -49,8 +47,7 @@ stdinから受け取る入力形式(既存ページ編集モード, JSON):
49
47
  変更行の頭には > (新規) または * (更新) のマーカーと末尾 # <lineId> が付く。
50
48
  既存行(変更なし)はマーカーなし。
51
49
  preview は dry-run なのでこの段階ではpage URLは確定しない。 確定URLは submitEdit の出力で確認する。
52
-
53
- submitEdit でこのpreviewIdを渡してcommitを確定する。previewIdは5分でexpireする。
50
+ previewId は submitEdit に渡して commit を確定する。5分で expire する。
54
51
 
55
52
  HTTPエラー:
56
53
  HTTP 401 認証なし
@@ -59,18 +56,6 @@ HTTPエラー:
59
56
  HTTP 409 {"error":"NotFastForward","latest":...}
60
57
  preview生成後にページが更新された。最新stateを再取得して ops を作り直す必要がある
61
58
  HTTP 422 ops が不正/存在しないlineId/replace に多行textを渡した等
62
-
63
- ワークフロー例(既存ページの編集):
64
- cosense readPage https://scrapbox.io/shokai/foo > page.json
65
- # page.json から top-level id (pageId) と編集したい行の lineId を把握する
66
- cosense previewEdit https://scrapbox.io/shokai <pageId> < ops.json
67
- # 出力の plain text を読み、適用後の状態を確認してから submit
68
- cosense submitEdit https://scrapbox.io/shokai <previewId>
69
-
70
- ワークフロー例(新規ページ作成):
71
- printf 'ページタイトル\\n本文1行目\\n本文2行目\\n' \\
72
- | cosense previewEdit --new https://scrapbox.io/shokai
73
- cosense submitEdit https://scrapbox.io/shokai <previewId>
74
59
  `;
75
60
 
76
61
  interface InsertBeforeOp {
@@ -16,7 +16,7 @@ Usage:
16
16
 
17
17
  戻り値(top-levelの主なkey):
18
18
  title string ページタイトル
19
- persistent boolean 実体のあるページなら true。false でも関連ページリストは存在する場合がある
19
+ persistent boolean 実体のあるページなら true。false は未作成の新規ページ(関連ページリストは存在する場合がある)
20
20
  id string ページID (persistent: true の時のみ)
21
21
  commitId string 最新コミットID (persistent: true の時のみ)
22
22
  lines Array<Line> 本文の行配列。Line = { id, text, user, created, updated } (id および user/timestamp 系は persistent: true の時のみ)
@@ -22,7 +22,7 @@ Usage:
22
22
  search 検索ハイライト情報
23
23
 
24
24
  検索の制約:
25
- - OR検索不可。複数キーワードを試したい時はクエリを分解して複数回叩く
25
+ - OR検索不可
26
26
  `;
27
27
 
28
28
  export const search1hopLinks = async (args: string[]): Promise<void> => {
@@ -22,7 +22,7 @@ Usage:
22
22
  search 検索ハイライト情報
23
23
 
24
24
  検索の制約:
25
- - OR検索不可。複数キーワードを試したい時はクエリを分解して複数回叩く
25
+ - OR検索不可
26
26
  `;
27
27
 
28
28
  export const search2hopLinks = async (args: string[]): Promise<void> => {
@@ -19,7 +19,7 @@ Usage:
19
19
  戻り値(top-levelの主なkey):
20
20
  pages Array<Page> 類似度順のヒット結果
21
21
 
22
- page の field:
22
+ Page の field:
23
23
  title string ページタイトル
24
24
  image string サムネイル画像URL
25
25
  score number 類似度スコア(高いほど近い)
@@ -47,7 +47,6 @@ User の field(user / lastUpdateUser / users[] で共通):
47
47
  検索対象:
48
48
  - ページタイトル + 本文中のリンク記法([title])のみ
49
49
  - 本文の通常テキストは検索対象外
50
- - 本文の語で検索したい時は searchFullText を使う
51
50
 
52
51
  戻り値のJSON抜粋例:
53
52
  {
@@ -34,9 +34,7 @@ HTTPエラー:
34
34
  HTTP 409 {"error":"DuplicateTitle"}
35
35
  preview→submit の間に他人が同名ページを作った (race condition)
36
36
 
37
- ワークフロー:
38
- previewIdは1回しか使えない (consume-on-submit)。submitに失敗したら previewEdit から
39
- やり直す。previewIdは5分でexpireするので submit は迅速に。
37
+ previewId は1回限り (consume-on-submit)。submit 後・5分 expire 後・consume 済みは HTTP 404。
40
38
  `;
41
39
 
42
40
  interface SubmitResponse {