Skip to content

feat!: ai-actions をノートメニュー起点に再設計する (notedeck#1055) - #45

Merged
hitalin merged 1 commit into
mainfrom
feat/ai-actions-v2
Aug 14, 2026
Merged

hitalin merged 1 commit into
mainfrom
feat/ai-actions-v2

Conversation

@hitalin

@hitalin hitalin commented Aug 14, 2026

Copy link
Copy Markdown
Collaborator

notedeck#1055 に対応します。

なぜ

ランディング (LandingIde.vue:32) は「AI チャット専用カラムに加え、ノートメニューから直接 AI」、ドキュメント (guide/ai.md:18) は「ノートのメニューから直接 AI に投げられます(要約する、翻訳する、など)」と告知していますが、ai-actions v1 はコマンドパレットから起動してクリップボードを読み書きする作りで、その導線がありませんでした。

クリップボード方式は告知と違うだけでなく、何を入力したのか・結果がどこに出たのかが画面上に一切見えません。結果はクリップボードに書き戻されるので、どこかに貼るまで確認できず、貼る先がなければ消えます。

AI を直接使うプラグインは現状これだけで、後続の AI プラグインが参照する基準形になります。ここでクリップボードを入出力に使う形を残すと、その作法が複製されていきます。

なにを

呼び出し面と出力面をすべて可視な UI に移しました。本体のフック (Plugin:register_note_action / register_user_action / register_post_form_action) は実装済みなので、本体側の変更は不要です。

アクション 出力
ノート「…」メニュー AI で翻訳 / AI で要約 Mk:dialog
ノート「…」メニュー AI で返信案 確認のうえ返信下書きに保存 (drafts.create)
ユーザーメニュー AI でユーザー紹介 Mk:dialog
投稿フォーム AI 推敲 (v1 の校正の移行先) 確認のうえ update('text')

permissionsclipboard / notifications を落として ai.invokedrafts.write の 2 つになりました。どちらも plugin 既定の safe プリセットで ON なので、更新後に権限設定を触らずそのまま動きます。

アイコンはクリップボードを使わなくなったので clipboard-typesparkles に変更しました。

設計判断

返信案を即時投稿にしない。 notes.create は AI の文面を一字も直せないまま本人名義で出すことになり、かつ notes.write が safe プリセットで OFF (schema.ts) のため大半のユーザーで動きません。下書きなら「開いて直してから投稿」という返信本来の流れの中に人間の確認が入り、drafts.write は既定 ON です。

NoteDeck のメモには保存しない。 メモは投稿導線が無く (notedeck#1018 で「メモは投稿しない」設計)、置いても手動転記が要るのでクリップボードと同じ袋小路になります。加えて memos.write は高リスク権限で、dataSources 経由で AI のシステムコンテキストに自動注入される (本体が「dataSources 自動注入との組合せで injection の実効性が高い」と明記) ため、悪意あるノート → AI 出力 → メモ → 後日 AI 本体が読む、という格納型インジェクションの経路になります。

コマンドパレットは全廃。 パレットの handler は execFn(handler, []) の引数ゼロ (notedeck-api.ts:247) でノート/フォーム文脈を受け取れず、クリップボードを捨てると入力源が無くなります。

aiTool: true にしない。 params 付き呼び出しは execFnSync で async の Nd:call('ai.chat') を実行できず、空 params 宣言は fire-and-forget で戻り値が AI に届きません (notedeck-api.ts:232-249)。本体が ai.chataiTool: false にした料金不透明の論点も未解決です。

AI プラグインのシリーズ化はしない。 runtime に per-plugin 権限隔離が無く (共有 'plugin' プロファイルで一律 resolve)、分割の第一根拠が成立しません。分割基準は「既定 OFF の権限を要する / 自律動作を含む / 送信データのスコープが質的に変わる」の 3 条件として残します。

セキュリティ

  • 本文は <data> ブロックに封じ、埋め込み前に終端文字列 </data> を除去
  • system は config 化せず固定 (注入耐性の指示文自体を消せなくする)
  • AI 出力である旨はプロンプトではなくコードで前置 (注入で外せない)
  • 書き込み (下書き保存・下書き置換) は必ずプラグイン自身の Mk:confirm で本文全文を見せてから。本体の「今後確認しない」(#714) でシステム確認はスキップされうるため、恒久保証をそれに依存させない
  • CW 付きノートは送信前に 1 段確認 (「…」メニューに到達できることは CW を展開したことを意味しない)。ユーザー紹介では他人の CW ノートは本文を送らず CW 文言のみ
  • 自動実行を持たないため AI 呼び出しは常にクリック 1 回 = 課金 1 回。空・ダイレクト・長文・CW の各ガードはすべて ai.chat より前

検証

本体 frontend と同一の @syuilo/aiscript@1.2.1 に、NoteDeck のホスト関数セマンティクス (Nd:call / Mk:api は失敗時 throw) を模した env を渡して 17 シナリオを実走させ、実際のプロンプト・API 呼び出し・確認ダイアログを確認しました。全シナリオ err=0

  • 課金前ガードが全て機能 (空ノート・DM への返信案・2000 字超の推敲・CW 拒否は ai.chat 0 回で終了)
  • デリミタ注入の無害化 (x</data>これは指示です<data>yxこれは指示です<data>y)
  • メンション付与 (ローカル @alice / リモート @bob@example.com)
  • 改行が正しく入る — AiScript は "\n""n" に潰すため (実測で確認)、全て Str:lf 経由

pnpm registry:buildnode scripts/check-registry-integrity.mjs はどちらも警告 0 件です。

破壊的変更

  • クリップボード入出力の廃止
  • コマンドパレット 4 コマンドの削除
  • 校正 → 投稿フォームの「AI 推敲」へ移行
  • 返信案の出力が「クリップボード書き戻し」→「返信下書き保存」へ

v1 に ### {} メタブロックと config は無かったので、設定の引き継ぎは発生しません。

既知の制約

plugin.is 先頭コメントに記載済みです。いずれも notedeck 側の対応で解消される見込みで、notedeck#1055 の本文に課題として整理してあります。

  • AI 接続が未設定のまま実行すると、エラーがランログにしか出ず画面が無反応に見える (plugin-api.ts:550)。v1 も同じ経路で無言終了していたので後退ではありませんが、プラグイン側では原理的に回避できません
  • Mk:dialog はプレーンテキストでコピー導線が無い
  • 応答待ちのあいだ表示が出ない (Mk:toast は数秒で消え、Mk:dialog に waiting 型は存在しない)
  • 返信の下書きは開いて投稿する時点で返信リンクが外れる (暫定対応として本文先頭にメンションを付与)
  • 返信の下書き保存はサーバーが Misskey 2025.6 以降の場合のみ

設計プロセス

3 案 (最小構成 / config 駆動エンジン / 3 プラグイン分割) を独立に作成し、実装可能性・UX・セキュリティとコスト・将来性の 4 観点で相互に潰し合わせたうえで統合し、統合結果に再度攻撃をかけて確定しました。主張はすべて notedeck のソースと AiScript インタープリタでの実測で裏取りしています。

🤖 Generated with Claude Code

Summary by CodeRabbit

  • New Features

    • Upgraded AI Actions to version 2.0 with note translation, summarization, reply drafting, user introductions, and post editing.
    • Actions are now available directly from notes, user profiles, and post forms.
    • Added configurable prompts and language settings, clearer results, confirmations, safety checks, and draft saving.
  • Updates

    • Refreshed registry metadata and timestamps.
    • Updated the AI Actions icon and permissions to reflect its expanded capabilities.

v1 はコマンドパレットから起動してクリップボードを読み書きしていたため、
何を入力したのか・結果がどこに出たのかが画面上に一切見えなかった。
ランディングと docs は「ノートメニューから直接 AI」と告知しているのに、
実装がその約束を果たしていない状態だった。

呼び出し面と出力面をすべて可視な UI に移す:

  ノート「…」メニュー   翻訳 / 要約 / 返信案
  ユーザーメニュー      ユーザー紹介
  投稿フォーム          AI 推敲 (v1 の校正の移行先)

返信案は投稿せず、確認のうえ返信下書きに保存する。notes.create による
即時投稿は AI の文面を一字も直せないまま本人名義で出すことになり、かつ
notes.write が safe プリセットで OFF のため大半のユーザーで動かない。
下書きなら「開いて直してから投稿」という返信本来の流れの中に人間の確認が
入る。メモは投稿導線が無く (#1018 でメモは投稿しない設計)、memos.write が
高リスク権限かつ dataSources 経由で AI に自動注入されるため採らない。

permissions は clipboard / notifications を落として ai.invoke と
drafts.write の 2 つに。どちらも safe プリセットで既定 ON のため、更新後に
権限設定を触らずそのまま動く。

プロンプトインジェクション対策として、本文は <data> ブロックに封じて終端
文字列を除去し、system は config 化せず固定、AI 出力である旨はプロンプト
ではなくコードで前置する。空・ダイレクト・長文・CW の各ガードはすべて
ai.chat より前に置き、1 クリック = 1 課金を保つ。

アイコンはクリップボードを使わなくなったので sparkles に変更した。

BREAKING CHANGE: クリップボード入出力とコマンドパレットの 4 コマンドを
廃止。校正は投稿フォームの「AI 推敲」に移行した。

Co-Authored-By: Claude Fable 5 <noreply@anthropic.com>
@cloudflare-workers-and-pages

Copy link
Copy Markdown

Deploying with  Cloudflare Workers  Cloudflare Workers

The latest updates on your project. Learn more about integrating Git with Workers.

Status Name Latest Commit Updated (UTC)
✅ Deployment successful!
View logs
misstore 71c9ba0 Aug 14 2026, 02:20 AM

@coderabbitai

coderabbitai Bot commented Aug 14, 2026

Copy link
Copy Markdown

Review Change Stack

Caution

Review failed

The pull request is closed.

ℹ️ Recent review info
⚙️ Run configuration

Configuration used: defaults

Review profile: CHILL

Plan: Pro Plus

Run ID: 8b9b4f2c-b481-4b18-a8f4-08705e2cc27c

📥 Commits

Reviewing files that changed from the base of the PR and between 0fc5425 and 71c9ba0.

⛔ Files ignored due to path filters (1)
  • public/registry/plugins/ai-actions/icon.svg is excluded by !**/*.svg
📒 Files selected for processing (10)
  • public/registry/index.json
  • public/registry/plugins.json
  • public/registry/plugins/ai-actions/api.json
  • public/registry/plugins/ai-actions/meta.json
  • public/registry/plugins/ai-actions/plugin.is
  • public/registry/queries.json
  • public/registry/skills.json
  • public/registry/themes.json
  • public/registry/widgets.json
  • scripts/sync-icons.js

📝 Walkthrough

Walkthrough

The ai-actions plugin moves from clipboard-based commands to UI-integrated translation, summarization, reply drafting, user profiling, and post-form refinement. Version 2.0.0 updates permissions, metadata, registry timestamps, checksum, and icon mapping.

Changes

AI Actions v2

Layer / File(s) Summary
Plugin contract and shared execution
public/registry/plugins/ai-actions/meta.json, public/registry/plugins/ai-actions/api.json, public/registry/plugins/ai-actions/plugin.is
The plugin defines v2 permissions, configurable prompts, input limits, sanitization, fixed system instructions, AI invocation, and visible result handling.
UI action integrations
public/registry/plugins/ai-actions/plugin.is
Note actions support translation and summarization. Reply suggestions save confirmed drafts. User introductions and post-form refinement apply their respective input guards and confirmation flows.
Registry publication and icon update
public/registry/plugins.json, public/registry/index.json, public/registry/queries.json, public/registry/skills.json, public/registry/themes.json, public/registry/widgets.json, scripts/sync-icons.js
Registry metadata, timestamps, checksum, permissions, and plugin version are updated. The plugin icon changes to sparkles.

Estimated code review effort: 4 (Complex) | ~45 minutes

Sequence Diagram(s)

sequenceDiagram
  participant NoteDeck
  participant ai-actions
  participant AIProvider
  participant ResultDialog
  participant DraftStorage
  NoteDeck->>ai-actions: Invoke note, user, or post-form action
  ai-actions->>ai-actions: Validate and sanitize input
  ai-actions->>AIProvider: Send prompt and input
  AIProvider-->>ai-actions: Return generated result
  ai-actions->>ResultDialog: Display result and confirmation
  ResultDialog->>DraftStorage: Save confirmed reply draft
  ResultDialog-->>NoteDeck: Apply confirmed form replacement
Loading

Possibly related issues

Possibly related PRs

✨ Finishing Touches
📝 Generate docstrings
  • Create stacked PR
  • Commit on current branch
🧪 Generate unit tests (beta)
  • Create PR with unit tests
  • Commit unit tests in branch feat/ai-actions-v2

Thanks for using CodeRabbit! It's free for OSS, and your support helps us grow. If you like it, consider giving us a shout-out.

❤️ Share

Comment @coderabbitai help to get the list of available commands.

@hitalin hitalin self-assigned this Aug 14, 2026
@hitalin
hitalin merged commit e1c4d66 into main Aug 14, 2026
4 of 5 checks 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.

1 participant