Skip to content

claudian: 田中雄一郎OS保管庫の場所とフォルダ構成を設定で解決する - #1

Merged
tanakauo merged 3 commits into
mainfrom
claude/claude-obsidian-integration-t0mkex
Aug 6, 2026
Merged

claudian: 田中雄一郎OS保管庫の場所とフォルダ構成を設定で解決する#1
tanakauo merged 3 commits into
mainfrom
claude/claude-obsidian-integration-t0mkex

Conversation

@tanakauo

@tanakauo tanakauo commented Aug 6, 2026

Copy link
Copy Markdown
Owner

MacBook Air M1 / M5 の2台で claudian(Obsidian 連携)が同じように動くようにし、保管庫の再編にコード修正なしで追従できるようにします。

背景

obsidian-save.mjs は保存先が /Users/nesty/TANAKA-BRAIN/田中雄一郎OS保管庫 にハードコードされており、

  • ユーザー名や保管庫の置き場所が違うマシンでは動かない
  • 保管庫が見つからない場合も mkdir -p で空のディレクトリを作り、「保存しました」と表示していた
  • フォルダ構成(00_INBOX など)がコード内にあるため、保管庫を再編するたびにスクリプト修正が必要

という状態でした。

変更内容

1. 保管庫の場所をマシンごとに解決(419c96f)

優先順: --vaultCLAUDIAN_VAULT_ROOT~/.claudian/config.jsonvaultRoot → 自動検出(~/TANAKA-BRAIN~~/Documents、Obsidian/iCloud Drive、Dropbox、Google Drive 配下の 田中雄一郎OS保管庫)。

あわせて以下も修正:

  • 保管庫が無いときはエラーで停止(作成する場合のみ --create-vault
  • 日付を UTC ではなくローカル日付に。JST 朝 7 時の保存が前日付になる問題を解消
  • 同日・同タイトルのノートを上書きせず _2, _3 と退避
  • 未知のオプションを拒否(--foldr のような打ち間違いが黙って inbox に落ちない)
  • 解決した保管庫パスを stderr に出力(stdout はファイル名のままで既存の呼び出し契約を維持)

2. フォルダ構成を設定データ化(1223294)

alias → directory の対応をレイヤで解決: 組み込みデフォルト → ~/.claudian/config.json<vault>/.claudian.json

保管庫内のファイルが最優先なので、再編内容は保管庫の同期経由で両マシンに反映されます。alias 単位のマージなので触っていない alias はデフォルトのまま、null を指定した alias は削除され、再編で消えたフォルダが保存先として復活しません。

  • --dir <保管庫内の相対パス>: alias 未登録のフォルダへ直接保存(再編途中用)
  • --list-folders: 現在有効な対応と、それがどのファイル由来かを表示
  • 絶対パスと .. を拒否し、保管庫の外に書き出せないよう検証
  • alias は大文字小文字を無視(--folder KEEP が通る)

3. 再編後の構成をスキャンして取り込む(3d299e3)

--scan-folders で保管庫の実構造を読み、.claudian.json の下書きを生成します(表示のみ)。--write を足すと保管庫に保存します。

  • 生きているフォルダを指す alias はそのまま維持
  • 新しいフォルダには名前から alias を生成(20_進行中進行中03_PUBLICpublic
  • フォルダが消えた alias は null として記録
  • --write.claudian.json の他のキーを保持したままマージ

テスト

npm test は 124 件すべてパス(うち claudian 分 33 件を新規追加)。別名の付け替え・削除・入れ子パス・保管庫外への書き出し拒否・CLI の終了コードと出力先を含みます。仮の保管庫を作って --scan-folders--write--list-folders → 保存まで実際に通しています。

ドキュメント

plugins/claudian/README.md を新規追加し、マシンごとのセットアップと再編手順を記載。SKILL / コマンド定義にも「組み込みの表を信用せず --list-folders を見る」「--write は確認してから」と明記しました。

claudian プラグインのバージョンは 1.0.0 → 1.3.0(codex 側のバージョンは変更なし、npm run check-version はパス)。

🤖 Generated with Claude Code

https://claude.ai/code/session_01U2j9ygS1iB3oPmV5QcQqqr


Generated by Claude Code

claude added 3 commits August 6, 2026 01:32
The vault root was hardcoded to one Mac's layout, so the same plugin could
not save on a second machine. Resolve it at runtime instead:
--vault > CLAUDIAN_VAULT_ROOT > ~/.claudian/config.json > auto-detection of
田中雄一郎OS保管庫 under the usual parents (TANAKA-BRAIN, home, Documents,
Obsidian/iCloud Drive, Dropbox, Google Drive).

Also:
- Fail loudly when the vault is missing instead of mkdir -p'ing a stray tree
  that looks like a successful save (--create-vault opts in).
- Date notes by local calendar day, not UTC, so a 07:00 JST note is not filed
  under the previous day.
- Never overwrite a same-day note with the same title (_2, _3, ...).
- Reject unknown CLI flags so a typo like --foldr cannot silently file a note
  into the inbox.
- Print the resolved vault to stderr, keeping the filename on stdout.
- Add plugins/claudian/README.md with per-machine setup and 17 tests.

Co-Authored-By: Claude Opus 5 <noreply@anthropic.com>
Claude-Session: https://claude.ai/code/session_01U2j9ygS1iB3oPmV5QcQqqr
保管庫を再編するたびにスクリプトを直すのを避ける。alias → directory の対応を
設定から読むようにし、レイヤを重ねて解決する:
built-in defaults < ~/.claudian/config.json < <vault>/.claudian.json

The vault-local file wins, so a reorganisation reaches the M1 and the M5
through the vault's own sync instead of being copied to each machine by hand.
Per-alias merge keeps untouched aliases at their defaults, and a null value
removes an alias so a folder deleted by the reorganisation stops being a save
target instead of being silently recreated.

Also:
- --dir <vault-relative path> saves to a folder that has no alias yet, for use
  while the structure is still in flux.
- --list-folders prints the live mapping and which files it came from.
- Folder paths are validated: absolute paths and .. cannot escape the vault.
- An unknown --folder now lists the aliases that do exist.
- Aliases match case-insensitively, so --folder KEEP works.
- Skill and command docs tell Claude to check --list-folders instead of
  trusting the built-in table.

Co-Authored-By: Claude Opus 5 <noreply@anthropic.com>
Claude-Session: https://claude.ai/code/session_01U2j9ygS1iB3oPmV5QcQqqr
Writing .claudian.json by hand means retyping the new structure on the machine
that holds 田中雄一郎OS保管庫. Read the vault instead and draft the file from
what is actually there:

  --scan-folders          print the draft, touch nothing
  --scan-folders --write  save it into <vault>/.claudian.json

Aliases still pointing at a surviving folder are kept as they are, new folders
get an alias derived from their name (20_進行中 → 進行中, 03_PUBLIC → public),
and aliases whose folder is gone are written as null so they stop being save
targets. --write merges into the existing file rather than replacing it.

Also align --list-folders output by display width so CJK aliases line up.

Co-Authored-By: Claude Opus 5 <noreply@anthropic.com>
Claude-Session: https://claude.ai/code/session_01U2j9ygS1iB3oPmV5QcQqqr
@chatgpt-codex-connector

Copy link
Copy Markdown

You have reached your Codex usage limits for code reviews. You can see your limits in the Codex usage dashboard.
To continue using code reviews, you can upgrade your account or add credits to your account and enable them for code reviews in your settings.

@tanakauo
tanakauo merged commit 5702f67 into main Aug 6, 2026
1 check passed
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

None yet

Projects

None yet

Development

Successfully merging this pull request may close these issues.

2 participants