fix: add missing sync-x-bookmarks.sh + clips template
Closes #1 — sync-x-bookmarks.sh was referenced in README but missing from vault-template/scripts/. Added: - vault-template/scripts/sync-x-bookmarks.sh (X bookmark auto-sync) - vault-template/scripts/ios-clip-shortcut.md (iOS Shortcut guide) - vault-template/clips/{_index.md,tags.md,x/,articles/} (Clips structure) Co-Authored-By: Claude Opus 4.6 (1M context) <noreply@anthropic.com>
This commit is contained in:
parent
d68b199abf
commit
0d1545b62e
6 changed files with 193 additions and 0 deletions
20
vault-template/clips/_index.md
Normal file
20
vault-template/clips/_index.md
Normal file
|
|
@ -0,0 +1,20 @@
|
||||||
|
---
|
||||||
|
date: 2026-04-08
|
||||||
|
type: index
|
||||||
|
---
|
||||||
|
|
||||||
|
# Clips
|
||||||
|
|
||||||
|
> AI が自動生成するクリッピング一覧。`/clip` スキルまたはXブックマーク自動同期で追加される。
|
||||||
|
|
||||||
|
## Recent
|
||||||
|
|
||||||
|
- [[clips/x/2026-04-08_google-chrome-vertical-tabs]] — Chrome vertical tabs リリース (#chrome #ux)
|
||||||
|
- [[clips/x/2026-04-07_umiyuki-agent-harness]] — エージェントハーネスにクローズドソースは不適 (#ai #agent)
|
||||||
|
- [[clips/x/2026-03-01_masahirochaen-ai-brain-book]] — 初著書『AI脳』KADOKAWA出版 (#ai #book)
|
||||||
|
|
||||||
|
## Stats
|
||||||
|
|
||||||
|
- Total: 3
|
||||||
|
- X: 3
|
||||||
|
- Articles: 0
|
||||||
0
vault-template/clips/articles/.gitkeep
Normal file
0
vault-template/clips/articles/.gitkeep
Normal file
17
vault-template/clips/tags.md
Normal file
17
vault-template/clips/tags.md
Normal file
|
|
@ -0,0 +1,17 @@
|
||||||
|
---
|
||||||
|
date: 2026-04-08
|
||||||
|
type: index
|
||||||
|
---
|
||||||
|
|
||||||
|
# Clips by Tag
|
||||||
|
|
||||||
|
> タグ別クリップ分類。Dataview対応。
|
||||||
|
|
||||||
|
```dataview
|
||||||
|
TABLE rows.date, rows.source, rows.author
|
||||||
|
FROM "clips"
|
||||||
|
WHERE type = "clip"
|
||||||
|
FLATTEN tags as tag
|
||||||
|
GROUP BY tag
|
||||||
|
SORT rows.date DESC
|
||||||
|
```
|
||||||
0
vault-template/clips/x/.gitkeep
Normal file
0
vault-template/clips/x/.gitkeep
Normal file
82
vault-template/scripts/ios-clip-shortcut.md
Normal file
82
vault-template/scripts/ios-clip-shortcut.md
Normal file
|
|
@ -0,0 +1,82 @@
|
||||||
|
---
|
||||||
|
date: 2026-04-08
|
||||||
|
type: guide
|
||||||
|
---
|
||||||
|
|
||||||
|
# iOS Shortcut: Clip to Vault
|
||||||
|
|
||||||
|
Safari/Chrome の共有メニューから1タップでvaultにクリップ。
|
||||||
|
|
||||||
|
## 仕組み
|
||||||
|
|
||||||
|
```
|
||||||
|
Safari → 共有 → "Clip" ショートカット → Slack DM送信 → OpenClaw検知 → vault保存
|
||||||
|
```
|
||||||
|
|
||||||
|
## ショートカット作成手順
|
||||||
|
|
||||||
|
### Step 1: ショートカットアプリを開く
|
||||||
|
|
||||||
|
1. iPhoneの「ショートカット」アプリを開く
|
||||||
|
2. 右上の「+」で新規作成
|
||||||
|
3. 名前: **Clip**
|
||||||
|
|
||||||
|
### Step 2: アクションを追加
|
||||||
|
|
||||||
|
以下のアクションを順番に追加:
|
||||||
|
|
||||||
|
1. **「共有シートの入力を受け取る」** — 種類: URL
|
||||||
|
2. **「テキスト」** — 内容: `📎 (共有シートの入力)`
|
||||||
|
3. **「Slackでメッセージを送信」**
|
||||||
|
- 宛先: 自分のSlack DMチャンネル(ロブ男のDM)
|
||||||
|
- メッセージ: 上のテキスト変数
|
||||||
|
|
||||||
|
### Step 3: 共有シートに表示
|
||||||
|
|
||||||
|
1. ショートカット設定(ⓘ)を開く
|
||||||
|
2. 「共有シートに表示」をオン
|
||||||
|
3. 入力タイプ: URL のみにチェック
|
||||||
|
|
||||||
|
### 代替: Slack Webhook版
|
||||||
|
|
||||||
|
Slackアプリのアクションが使いにくい場合、Webhook経由:
|
||||||
|
|
||||||
|
1. **「URLの内容を取得」** アクション
|
||||||
|
- URL: `https://slack.com/api/chat.postMessage`
|
||||||
|
- メソッド: POST
|
||||||
|
- ヘッダー: `Authorization: Bearer xoxb-YOUR-BOT-TOKEN`
|
||||||
|
- 本文: JSON
|
||||||
|
```json
|
||||||
|
{
|
||||||
|
"channel": "YOUR_DM_CHANNEL_ID",
|
||||||
|
"text": "📎 (共有シートの入力)"
|
||||||
|
}
|
||||||
|
```
|
||||||
|
|
||||||
|
### 代替: OpenClaw Gateway版
|
||||||
|
|
||||||
|
OpenClawのHTTP Gatewayを直接叩く:
|
||||||
|
|
||||||
|
1. **「URLの内容を取得」** アクション
|
||||||
|
- URL: `http://YOUR_MAC_IP:18789/api/message`
|
||||||
|
- メソッド: POST
|
||||||
|
- ヘッダー: `Authorization: Bearer YOUR_GATEWAY_TOKEN`
|
||||||
|
- 本文: JSON
|
||||||
|
```json
|
||||||
|
{
|
||||||
|
"message": "📎 clip this: (共有シートの入力)"
|
||||||
|
}
|
||||||
|
```
|
||||||
|
|
||||||
|
## 使い方
|
||||||
|
|
||||||
|
1. Safariで記事を開く
|
||||||
|
2. 共有ボタンをタップ
|
||||||
|
3. 「Clip」を選択
|
||||||
|
4. 自動でSlack DMに送信 → OpenClawがクリップ → vault保存
|
||||||
|
|
||||||
|
## 注意
|
||||||
|
|
||||||
|
- Slack Webhook版は外部からの送信になるため、ボットトークンの管理に注意
|
||||||
|
- OpenClaw Gateway版はMacが起動している必要がある
|
||||||
|
- 📎 プレフィックスを付けてクリップ意図を明確にする(通常のURL送信と区別)
|
||||||
74
vault-template/scripts/sync-x-bookmarks.sh
Executable file
74
vault-template/scripts/sync-x-bookmarks.sh
Executable file
|
|
@ -0,0 +1,74 @@
|
||||||
|
#!/bin/bash
|
||||||
|
# sync-x-bookmarks.sh — X ブックマーク自動同期
|
||||||
|
# OpenClaw cron (4時間おき) または手動実行
|
||||||
|
# 最新ブックマークを取得して vault/clips/x/ に保存
|
||||||
|
|
||||||
|
set -euo pipefail
|
||||||
|
|
||||||
|
VAULT_DIR="$HOME/vault"
|
||||||
|
CLIPS_DIR="$VAULT_DIR/clips/x"
|
||||||
|
INDEX_FILE="$VAULT_DIR/clips/_index.md"
|
||||||
|
TODAY=$(date +%Y-%m-%d)
|
||||||
|
LOG_FILE="$VAULT_DIR/.sync.log"
|
||||||
|
|
||||||
|
log() { echo "[$(date '+%Y-%m-%d %H:%M:%S')] [sync-x-bookmarks] $*" >> "$LOG_FILE"; }
|
||||||
|
|
||||||
|
# 依存コマンド確認
|
||||||
|
for cmd in xurl jq; do
|
||||||
|
if ! command -v "$cmd" &>/dev/null; then
|
||||||
|
log "ERROR: $cmd not found in PATH"
|
||||||
|
exit 1
|
||||||
|
fi
|
||||||
|
done
|
||||||
|
|
||||||
|
log "Starting X bookmark sync for $TODAY"
|
||||||
|
|
||||||
|
# ブックマークを取得(--auth oauth2 が必須)
|
||||||
|
if ! BOOKMARKS=$(xurl bookmarks -n 20 --auth oauth2 2>&1); then
|
||||||
|
log "ERROR: xurl bookmarks failed: $BOOKMARKS"
|
||||||
|
exit 1
|
||||||
|
fi
|
||||||
|
|
||||||
|
if [ -z "$BOOKMARKS" ]; then
|
||||||
|
log "No bookmarks found (empty response)"
|
||||||
|
exit 0
|
||||||
|
fi
|
||||||
|
|
||||||
|
# JSONバリデーション + ブックマーク数カウント
|
||||||
|
if ! COUNT=$(echo "$BOOKMARKS" | jq -r '.data | length' 2>&1); then
|
||||||
|
log "ERROR: invalid JSON from xurl: $COUNT"
|
||||||
|
exit 1
|
||||||
|
fi
|
||||||
|
|
||||||
|
log "Found $COUNT bookmarks"
|
||||||
|
|
||||||
|
if [ "$COUNT" = "0" ]; then
|
||||||
|
log "No bookmarks to process"
|
||||||
|
exit 0
|
||||||
|
fi
|
||||||
|
|
||||||
|
# includes.users から author_id → username マッピングを構築
|
||||||
|
USER_MAP=$(echo "$BOOKMARKS" | jq -r '[.includes.users[]? | {(.id): .username}] | add // {}')
|
||||||
|
|
||||||
|
# 各ブックマークを処理
|
||||||
|
# スクリプト単体ではJSON出力のみ。要約・タグ生成はLLMが行う
|
||||||
|
NEW_COUNT=0
|
||||||
|
echo "$BOOKMARKS" | jq -c '.data[]' | while read -r tweet; do
|
||||||
|
TWEET_ID=$(echo "$tweet" | jq -r '.id')
|
||||||
|
TWEET_TEXT=$(echo "$tweet" | jq -r '.text // empty')
|
||||||
|
AUTHOR_ID=$(echo "$tweet" | jq -r '.author_id // "unknown"')
|
||||||
|
# includes.users からユーザー名を解決
|
||||||
|
AUTHOR=$(echo "$USER_MAP" | jq -r --arg id "$AUTHOR_ID" '.[$id] // "unknown"')
|
||||||
|
|
||||||
|
# 既にクリップ済みか確認
|
||||||
|
if grep -rq "status/$TWEET_ID" "$CLIPS_DIR/" 2>/dev/null; then
|
||||||
|
log "Skip: tweet $TWEET_ID already clipped"
|
||||||
|
continue
|
||||||
|
fi
|
||||||
|
|
||||||
|
NEW_COUNT=$((NEW_COUNT + 1))
|
||||||
|
log "New bookmark: $TWEET_ID by @$AUTHOR"
|
||||||
|
echo "{\"id\":\"$TWEET_ID\",\"text\":$(echo "$TWEET_TEXT" | jq -Rs .),\"author\":\"@$AUTHOR\"}"
|
||||||
|
done
|
||||||
|
|
||||||
|
log "Sync complete (new: $NEW_COUNT)"
|
||||||
Loading…
Add table
Add a link
Reference in a new issue