@helpfeel/cosense-cli 1.3.0 → 1.4.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/README.md +17 -11
- package/package.json +5 -5
- package/src/commands/browsePage.ts +1 -1
- package/src/commands/browseRelatedPages.ts +2 -2
- package/src/commands/listPages.ts +1 -1
- package/src/commands/previewEdit.ts +9 -24
- package/src/commands/readPage.ts +1 -1
- package/src/commands/search1hopLinks.ts +1 -1
- package/src/commands/search2hopLinks.ts +1 -1
- package/src/commands/searchVector.ts +1 -2
- package/src/commands/submitEdit.ts +1 -3
package/README.md
CHANGED
|
@@ -1,17 +1,10 @@
|
|
|
1
1
|
# @helpfeel/cosense-cli
|
|
2
2
|
|
|
3
|
-
Cosense
|
|
3
|
+
Cosenseのページを読み・調べ・編集するAgent SkillとCLI
|
|
4
4
|
|
|
5
|
-
## Install
|
|
5
|
+
## Install Agent Skill
|
|
6
6
|
|
|
7
|
-
###
|
|
8
|
-
|
|
9
|
-
```bash
|
|
10
|
-
npm install -g https://github.com/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
|
-
|
|
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.
|
|
4
|
-
"description": "Cosense (旧Scrapbox) のページを読み・調べ・編集するCLI",
|
|
3
|
+
"version": "1.4.1",
|
|
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": "
|
|
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.
|
|
41
|
+
"registry": "https://registry.npmjs.org/"
|
|
42
42
|
}
|
|
43
43
|
}
|
|
@@ -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>
|
|
@@ -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
|
|
13
|
-
cosense previewEdit --new <projectUrl> < body.txt
|
|
14
|
-
|
|
15
|
-
|
|
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
|
-
|
|
40
|
-
|
|
41
|
-
anchor
|
|
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 {
|
package/src/commands/readPage.ts
CHANGED
|
@@ -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 の時のみ)
|
|
@@ -19,7 +19,7 @@ Usage:
|
|
|
19
19
|
戻り値(top-levelの主なkey):
|
|
20
20
|
pages Array<Page> 類似度順のヒット結果
|
|
21
21
|
|
|
22
|
-
各
|
|
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 {
|