@nogataka/smart-edit 1.0.2 → 1.0.4
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 +201 -65
- package/dist/smart-edit/cli.js +79 -2
- package/dist/smart-edit/dashboard.js +29 -0
- package/dist/smart-edit/instance-registry.d.ts +43 -0
- package/dist/smart-edit/instance-registry.js +272 -0
- package/dist/smart-edit/resources/dashboard/dashboard.js +9 -9
- package/dist/smart-edit/resources/dashboard/index.css +1 -1
- package/dist/smart-edit/standalone-dashboard.d.ts +32 -0
- package/dist/smart-edit/standalone-dashboard.js +223 -0
- package/package.json +1 -1
package/README.md
CHANGED
|
@@ -94,21 +94,104 @@ Smart Edit は、AI の振る舞いをカスタマイズするための柔軟な
|
|
|
94
94
|
| **Statistics** | API 呼び出し統計、トークン使用量チャート、ライブカウンター |
|
|
95
95
|
| **Sessions** | セッション履歴、JSON エクスポート、過去セッション比較 |
|
|
96
96
|
|
|
97
|
-
-
|
|
97
|
+
- `npx @nogataka/smart-edit start-dashboard` で統合ダッシュボードを起動
|
|
98
|
+
- 複数プロジェクトをサイドバーで切り替え管理
|
|
98
99
|
- ダークモード / ライトモード切替対応
|
|
99
|
-
- モバイルレスポンシブ対応
|
|
100
100
|
|
|
101
101
|
## ワークフローツール
|
|
102
102
|
|
|
103
103
|
AI エージェントの作業効率を高めるためのワークフロー支援ツールを提供します。
|
|
104
104
|
|
|
105
|
-
| ツール
|
|
106
|
-
|
|
|
107
|
-
| `Onboarding`
|
|
108
|
-
| `CheckOnboardingPerformed`
|
|
105
|
+
| ツール | 説明 |
|
|
106
|
+
| --------------------------- | -------------------------------------------------------- |
|
|
107
|
+
| `Onboarding` | プロジェクト初回参加時のオンボーディングプロセスを支援 |
|
|
108
|
+
| `CheckOnboardingPerformed` | オンボーディング完了確認 + Git 差分による変更検出 |
|
|
109
|
+
| `CollectProjectSymbols` | プロジェクトシンボル(ユーティリティ、依存関係等)を収集 |
|
|
109
110
|
|
|
110
111
|
オンボーディングでは、プロジェクトの構造理解、コーディング規約の確認、既存メモリの参照などを AI エージェントに案内します。
|
|
111
112
|
|
|
113
|
+
### アクティブ化とオンボーディングの違い
|
|
114
|
+
|
|
115
|
+
Smart Edit では「**アクティブ化**」と「**オンボーディング**」は別の概念です。
|
|
116
|
+
|
|
117
|
+
| 項目 | アクティブ化 (Activation) | オンボーディング (Onboarding) |
|
|
118
|
+
|------|---------------------------|-------------------------------|
|
|
119
|
+
| **目的** | プロジェクトを Smart Edit に登録 | AI がプロジェクトを理解する |
|
|
120
|
+
| **実行タイミング** | 最初の1回(自動または手動) | セッション開始時に推奨 |
|
|
121
|
+
| **結果** | `.smart-edit` ディレクトリ作成、ツールが利用可能に | メモリに情報を保存 |
|
|
122
|
+
| **ツール** | `activate_project` | `onboarding`, `check_onboarding_performed` |
|
|
123
|
+
| **必須か** | **必須**(プロジェクト操作に必要) | 任意(推奨) |
|
|
124
|
+
|
|
125
|
+
**処理の流れ:**
|
|
126
|
+
|
|
127
|
+
```
|
|
128
|
+
1. プロジェクトのアクティブ化
|
|
129
|
+
→ activate_project ツール / --project オプション
|
|
130
|
+
→ .smart-edit ディレクトリ作成
|
|
131
|
+
→ ツールが利用可能になる
|
|
132
|
+
↓
|
|
133
|
+
2. オンボーディング(任意だが推奨)
|
|
134
|
+
→ check_onboarding_performed → onboarding ツール
|
|
135
|
+
→ AI がプロジェクト構造を学習
|
|
136
|
+
→ メモリに情報を保存(project-symbols など)
|
|
137
|
+
↓
|
|
138
|
+
3. 実際の作業
|
|
139
|
+
→ ファイル編集、シンボル検索など
|
|
140
|
+
```
|
|
141
|
+
|
|
142
|
+
- **アクティブ化**は技術的な準備段階(プロジェクトパスの認識、`.smart-edit` ディレクトリ作成、言語サーバー初期化)
|
|
143
|
+
- **オンボーディング**は AI の学習プロセス(プロジェクト構造把握、既存コード・ライブラリの確認、メモリへの保存)
|
|
144
|
+
|
|
145
|
+
アクティブ化なしではオンボーディングはできませんが、オンボーディングなしでもアクティブ化されたプロジェクトで作業は可能です。
|
|
146
|
+
|
|
147
|
+
## 重複定義チェック機能
|
|
148
|
+
|
|
149
|
+
AI エージェントが既存のコードや依存ライブラリと重複する実装を作成することを防ぐための機能です。
|
|
150
|
+
|
|
151
|
+
### 概要
|
|
152
|
+
|
|
153
|
+
| 機能 | 説明 |
|
|
154
|
+
|------|------|
|
|
155
|
+
| **careful-editor モード** | 既存コードを尊重し、重複実装を防ぐ動作モード |
|
|
156
|
+
| **プロジェクトシンボル収集** | ユーティリティ関数、共通コンポーネント、依存ライブラリを記録 |
|
|
157
|
+
| **Git 差分検出** | 前回オンボーディング以降の大きな変更を自動検出し、再オンボーディングを推奨 |
|
|
158
|
+
|
|
159
|
+
### 動作の流れ
|
|
160
|
+
|
|
161
|
+
```
|
|
162
|
+
1. オンボーディング時にプロジェクト構成を収集
|
|
163
|
+
→ CollectProjectSymbols ツールで project-symbols メモリに保存
|
|
164
|
+
↓
|
|
165
|
+
2. 次回セッション開始時
|
|
166
|
+
→ CheckOnboardingPerformed が Git 差分をチェック
|
|
167
|
+
↓
|
|
168
|
+
3. 大きな変更がある場合
|
|
169
|
+
→ 「再オンボーディング推奨」メッセージを表示
|
|
170
|
+
↓
|
|
171
|
+
4. careful-editor モードで実装
|
|
172
|
+
→ 既存のユーティリティ/ライブラリを優先利用
|
|
173
|
+
```
|
|
174
|
+
|
|
175
|
+
### careful-editor モードの使用
|
|
176
|
+
|
|
177
|
+
```bash
|
|
178
|
+
npx @nogataka/smart-edit start-mcp-server \
|
|
179
|
+
--mode careful-editor \
|
|
180
|
+
--transport stdio
|
|
181
|
+
```
|
|
182
|
+
|
|
183
|
+
このモードでは、AI エージェントは実装前に以下を確認します:
|
|
184
|
+
- `project-symbols` メモリから既存のユーティリティ関数一覧
|
|
185
|
+
- `package.json` の依存ライブラリとその用途
|
|
186
|
+
- 類似機能の有無を `find_symbol` ツールで検索
|
|
187
|
+
|
|
188
|
+
### 変更検出の基準
|
|
189
|
+
|
|
190
|
+
以下の条件で「大きな変更」と判定されます:
|
|
191
|
+
- 10 ファイル以上の変更
|
|
192
|
+
- 5 ファイル以上の新規追加
|
|
193
|
+
- `src/` ディレクトリへの新規ファイル追加
|
|
194
|
+
|
|
112
195
|
## 主な構成
|
|
113
196
|
|
|
114
197
|
| ディレクトリ / ファイル | 概要 |
|
|
@@ -155,7 +238,7 @@ CLI は npm パッケージとして公開されており、`npx` または `nod
|
|
|
155
238
|
|
|
156
239
|
```bash
|
|
157
240
|
# npm パッケージを利用する場合(推奨)
|
|
158
|
-
npx @nogataka/smart-edit
|
|
241
|
+
npx @nogataka/smart-edit <command>
|
|
159
242
|
|
|
160
243
|
# ローカル開発時
|
|
161
244
|
node dist/cli.js <command>
|
|
@@ -167,28 +250,28 @@ pnpm exec tsx src/smart-edit/cli.ts <command>
|
|
|
167
250
|
|
|
168
251
|
1. **smart-edit 管理ディレクトリの生成**
|
|
169
252
|
```bash
|
|
170
|
-
npx @nogataka/smart-edit
|
|
253
|
+
npx @nogataka/smart-edit config edit
|
|
171
254
|
```
|
|
172
255
|
初回実行時は `~/.smart-edit/smart_edit_config.yml` をテンプレートから生成し、既定エディタで開きます。
|
|
173
256
|
|
|
174
257
|
2. **プロジェクト設定 (project.yml) の生成**
|
|
175
258
|
```bash
|
|
176
|
-
npx @nogataka/smart-edit
|
|
259
|
+
npx @nogataka/smart-edit project generate-yml /path/to/project
|
|
177
260
|
```
|
|
178
261
|
言語を手動指定したい場合は `--language <lang>` を付与します。生成された YAML をプロジェクトルートに配置してください。
|
|
179
262
|
|
|
180
263
|
3. **モード / コンテキストの確認とカスタマイズ**
|
|
181
264
|
```bash
|
|
182
265
|
# 一覧表示
|
|
183
|
-
npx @nogataka/smart-edit
|
|
184
|
-
npx @nogataka/smart-edit
|
|
266
|
+
npx @nogataka/smart-edit mode list
|
|
267
|
+
npx @nogataka/smart-edit context list
|
|
185
268
|
|
|
186
269
|
# テンプレートからコピー
|
|
187
|
-
npx @nogataka/smart-edit
|
|
270
|
+
npx @nogataka/smart-edit mode create --from-internal default-editor
|
|
188
271
|
|
|
189
272
|
# 編集 / 削除
|
|
190
|
-
npx @nogataka/smart-edit
|
|
191
|
-
npx @nogataka/smart-edit
|
|
273
|
+
npx @nogataka/smart-edit mode edit <name>
|
|
274
|
+
npx @nogataka/smart-edit context delete <name>
|
|
192
275
|
```
|
|
193
276
|
|
|
194
277
|
4. **プロンプトテンプレートの更新**
|
|
@@ -197,7 +280,7 @@ pnpm exec tsx src/smart-edit/cli.ts <command>
|
|
|
197
280
|
### 2. MCP サーバーの起動
|
|
198
281
|
|
|
199
282
|
```bash
|
|
200
|
-
npx @nogataka/smart-edit
|
|
283
|
+
npx @nogataka/smart-edit start-mcp-server \
|
|
201
284
|
--project /path/to/project \
|
|
202
285
|
--context ide-assistant \
|
|
203
286
|
--mode default-editor \
|
|
@@ -206,34 +289,59 @@ npx @nogataka/smart-edit smart-edit start-mcp-server \
|
|
|
206
289
|
|
|
207
290
|
ランタイムの自動インストールをスキップする場合は環境変数を設定します:
|
|
208
291
|
```bash
|
|
209
|
-
SMART_EDIT_SKIP_RUNTIME_INSTALL=1 npx @nogataka/smart-edit
|
|
292
|
+
SMART_EDIT_SKIP_RUNTIME_INSTALL=1 npx @nogataka/smart-edit start-mcp-server ...
|
|
210
293
|
```
|
|
211
294
|
|
|
212
295
|
主なオプション:
|
|
213
296
|
|
|
214
|
-
|
|
215
|
-
|
|
216
|
-
|
|
217
|
-
|
|
218
|
-
|
|
297
|
+
| オプション | 説明 |
|
|
298
|
+
|------------|------|
|
|
299
|
+
| `--project <path>` | アクティブ化するプロジェクトパス(省略時はカレントディレクトリ) |
|
|
300
|
+
| `--no-project` | プロジェクトなしで起動(後から `activate_project` で指定) |
|
|
301
|
+
| `--transport` | `stdio`(既定)/ `sse` / `streamable-http` |
|
|
302
|
+
| `--log-level` | ログレベル(DEBUG / INFO / WARNING / ERROR) |
|
|
303
|
+
| `--tool-timeout <秒>` | ツール実行のタイムアウト |
|
|
304
|
+
| `--instructions-override` | MCP クライアントへの初期インストラクション |
|
|
219
305
|
|
|
220
|
-
|
|
306
|
+
#### Web ダッシュボード
|
|
221
307
|
|
|
222
|
-
|
|
308
|
+
Smart Edit は統合ダッシュボードを提供し、複数プロジェクトのモニタリングと管理を一元化できます。
|
|
223
309
|
|
|
224
|
-
|
|
310
|
+
```bash
|
|
311
|
+
# 統合ダッシュボードを起動
|
|
312
|
+
npx @nogataka/smart-edit start-dashboard
|
|
313
|
+
```
|
|
225
314
|
|
|
226
|
-
|
|
227
|
-
| ---------- | ---------------------------------------------------------------------- |
|
|
228
|
-
| Dashboard | プロジェクト概要、リアルタイムメトリクス、最近のアクティビティ |
|
|
229
|
-
| Logs | ログ検索・フィルタ(レベル別、ツール名別)、リアルタイムストリーミング |
|
|
230
|
-
| Statistics | API 呼び出し統計、トークン使用量チャート、ライブカウンター |
|
|
231
|
-
| Sessions | セッション履歴、JSON エクスポート、過去セッション比較 |
|
|
315
|
+
ダッシュボードは MCP サーバーとは独立して動作します。複数の MCP サーバーを起動していても、1つのダッシュボードですべてのプロジェクトを管理できます。
|
|
232
316
|
|
|
233
|
-
|
|
234
|
-
|
|
317
|
+
```bash
|
|
318
|
+
# 例: 複数プロジェクトの同時利用
|
|
319
|
+
npx @nogataka/smart-edit start-dashboard # ダッシュボード起動
|
|
320
|
+
npx @nogataka/smart-edit start-mcp-server --project ~/projects/app-a # プロジェクトA
|
|
321
|
+
npx @nogataka/smart-edit start-mcp-server --project ~/projects/app-b # プロジェクトB
|
|
322
|
+
```
|
|
323
|
+
|
|
324
|
+
**ダッシュボード機能:**
|
|
325
|
+
|
|
326
|
+
| タブ | 機能 |
|
|
327
|
+
|------|------|
|
|
328
|
+
| Dashboard | プロジェクト概要、リアルタイムメトリクス |
|
|
329
|
+
| Logs | ログ検索・フィルタ、リアルタイムストリーミング |
|
|
330
|
+
| Statistics | ツール呼び出し統計、トークン使用量チャート |
|
|
331
|
+
| Sessions | セッション履歴、JSON エクスポート |
|
|
332
|
+
|
|
333
|
+
**特徴:**
|
|
334
|
+
- サイドバーで複数プロジェクトを切り替え
|
|
335
|
+
- MCP サーバー終了後もダッシュボードは継続動作
|
|
336
|
+
- ダークモード / ライトモード切替
|
|
235
337
|
- モバイルレスポンシブ対応
|
|
236
338
|
|
|
339
|
+
**ダッシュボードオプション:**
|
|
340
|
+
|
|
341
|
+
| オプション | 説明 |
|
|
342
|
+
|------------|------|
|
|
343
|
+
| `--port <port>` | ダッシュボードのポート番号(デフォルト: 24282) |
|
|
344
|
+
|
|
237
345
|
#### MCP クライアント(Codex など)からの接続例
|
|
238
346
|
|
|
239
347
|
`npx` で公開パッケージを取得する場合、`mcp_servers.toml` の設定キーを `smart-edit` に合わせてください。
|
|
@@ -241,7 +349,7 @@ SMART_EDIT_SKIP_RUNTIME_INSTALL=1 npx @nogataka/smart-edit smart-edit start-mcp-
|
|
|
241
349
|
```toml
|
|
242
350
|
[mcp_servers.smart-edit]
|
|
243
351
|
command = "npx"
|
|
244
|
-
args = ["-y", "@nogataka/smart-edit@latest", "
|
|
352
|
+
args = ["-y", "@nogataka/smart-edit@latest", "start-mcp-server", "--context", "codex", "--transport", "stdio"]
|
|
245
353
|
```
|
|
246
354
|
|
|
247
355
|
CLI 側の `--context` や `--mode` は必要に応じて追加してください。`smart-edit` コマンドは `package.json` の `bin.smart-edit` で `./dist/cli.js` にマッピングされています。
|
|
@@ -250,13 +358,13 @@ CLI 側の `--context` や `--mode` は必要に応じて追加してくださ
|
|
|
250
358
|
|
|
251
359
|
```bash
|
|
252
360
|
# プロジェクト設定 YAML の生成
|
|
253
|
-
npx @nogataka/smart-edit
|
|
361
|
+
npx @nogataka/smart-edit project generate-yml /path/to/project
|
|
254
362
|
|
|
255
363
|
# 有効化されているツールを確認
|
|
256
|
-
npx @nogataka/smart-edit
|
|
364
|
+
npx @nogataka/smart-edit tools list
|
|
257
365
|
|
|
258
366
|
# ツールごとの説明を表示
|
|
259
|
-
npx @nogataka/smart-edit
|
|
367
|
+
npx @nogataka/smart-edit tools list
|
|
260
368
|
```
|
|
261
369
|
|
|
262
370
|
### 4. メモリ機能
|
|
@@ -342,20 +450,48 @@ Smart Edit は MCP (Model Context Protocol) サーバーとして動作し、様
|
|
|
342
450
|
|
|
343
451
|
### `--project` オプションについて
|
|
344
452
|
|
|
345
|
-
|
|
453
|
+
**デフォルトでカレントディレクトリがプロジェクトとして自動アクティブ化されます。** `--project` を明示的に指定した場合はそのパスが使用されます。
|
|
346
454
|
|
|
347
|
-
|
|
348
|
-
|
|
455
|
+
| 指定方法 | 動作 |
|
|
456
|
+
|----------|------|
|
|
457
|
+
| オプションなし | カレントディレクトリを自動アクティブ化 |
|
|
458
|
+
| `--project /path/to/project` | 指定したパスをアクティブ化 |
|
|
459
|
+
| `--no-project` | プロジェクトなしで起動(後から `activate_project` で指定可能) |
|
|
349
460
|
|
|
350
461
|
```bash
|
|
351
|
-
#
|
|
352
|
-
npx @nogataka/smart-edit
|
|
462
|
+
# オプションなし(カレントディレクトリを自動使用)
|
|
463
|
+
npx @nogataka/smart-edit start-mcp-server --transport stdio
|
|
353
464
|
|
|
354
|
-
# --project
|
|
355
|
-
npx @nogataka/smart-edit
|
|
465
|
+
# --project あり(特定プロジェクトを指定)
|
|
466
|
+
npx @nogataka/smart-edit start-mcp-server --project /path/to/project --transport stdio
|
|
467
|
+
|
|
468
|
+
# --no-project(プロジェクトなしで起動、後から指定)
|
|
469
|
+
npx @nogataka/smart-edit start-mcp-server --no-project --transport stdio
|
|
356
470
|
```
|
|
357
471
|
|
|
358
|
-
|
|
472
|
+
#### `--no-project` で起動した場合の使い方
|
|
473
|
+
|
|
474
|
+
`--no-project` を指定した場合、最初にプロジェクトをアクティブ化する必要があります。以下のようにチャットで AI に依頼してください:
|
|
475
|
+
|
|
476
|
+
**プロンプト例:**
|
|
477
|
+
```
|
|
478
|
+
現在のディレクトリをプロジェクトとしてアクティブ化して
|
|
479
|
+
```
|
|
480
|
+
|
|
481
|
+
```
|
|
482
|
+
/path/to/my-project をアクティブ化して
|
|
483
|
+
```
|
|
484
|
+
|
|
485
|
+
```
|
|
486
|
+
smart-edit で現在のプロジェクトを登録して
|
|
487
|
+
```
|
|
488
|
+
|
|
489
|
+
AI が `activate_project` ツールを呼び出し、以下が実行されます:
|
|
490
|
+
- `.smart-edit` ディレクトリの作成
|
|
491
|
+
- 言語サーバーの初期化
|
|
492
|
+
- プロジェクト固有のツールが利用可能に
|
|
493
|
+
|
|
494
|
+
以下の各クライアント設定例ではデフォルト動作(カレントディレクトリ自動使用)を利用していますが、必要に応じて `--project` や `--no-project` を追加できます。
|
|
359
495
|
|
|
360
496
|
---
|
|
361
497
|
|
|
@@ -381,16 +517,16 @@ Claude Code ではプロジェクトごとに MCP サーバーを追加します
|
|
|
381
517
|
|
|
382
518
|
```bash
|
|
383
519
|
# プロジェクトのルートディレクトリで実行
|
|
384
|
-
claude mcp add smart-edit -- npx -y @nogataka/smart-edit@latest
|
|
520
|
+
claude mcp add smart-edit -- npx -y @nogataka/smart-edit@latest start-mcp-server --transport stdio
|
|
385
521
|
```
|
|
386
522
|
|
|
387
523
|
**オプション付きの例:**
|
|
388
524
|
```bash
|
|
389
525
|
# プロジェクトを指定する場合
|
|
390
|
-
claude mcp add smart-edit -- npx -y @nogataka/smart-edit@latest
|
|
526
|
+
claude mcp add smart-edit -- npx -y @nogataka/smart-edit@latest start-mcp-server --project "$(pwd)" --transport stdio
|
|
391
527
|
|
|
392
528
|
# コンテキストを指定する場合
|
|
393
|
-
claude mcp add smart-edit -- npx -y @nogataka/smart-edit@latest
|
|
529
|
+
claude mcp add smart-edit -- npx -y @nogataka/smart-edit@latest start-mcp-server --context ide-assistant --transport stdio
|
|
394
530
|
```
|
|
395
531
|
|
|
396
532
|
**管理コマンド:**
|
|
@@ -408,7 +544,7 @@ claude mcp remove smart-edit # サーバー削除
|
|
|
408
544
|
```toml
|
|
409
545
|
[mcp_servers.smart-edit]
|
|
410
546
|
command = "npx"
|
|
411
|
-
args = ["-y", "@nogataka/smart-edit@latest", "
|
|
547
|
+
args = ["-y", "@nogataka/smart-edit@latest", "start-mcp-server", "--context", "codex", "--transport", "stdio"]
|
|
412
548
|
```
|
|
413
549
|
|
|
414
550
|
**使用方法:**
|
|
@@ -416,7 +552,7 @@ args = ["-y", "@nogataka/smart-edit@latest", "smart-edit", "start-mcp-server", "
|
|
|
416
552
|
2. プロジェクトをアクティブ化するとツールが利用可能に
|
|
417
553
|
|
|
418
554
|
> **Note**:
|
|
419
|
-
> -
|
|
555
|
+
> - デフォルトではカレントディレクトリが自動的にプロジェクトとして使用されます(上記「`--project` オプションについて」を参照)
|
|
420
556
|
> - Codex の UI でツール実行が `failed` と表示されても、実際には成功していることがあります。ログ (`~/.codex/log/codex-tui.log`) で確認してください。
|
|
421
557
|
|
|
422
558
|
---
|
|
@@ -430,13 +566,13 @@ Cursor では `~/.cursor/mcp.json` (または Settings → MCP) で設定しま
|
|
|
430
566
|
"mcpServers": {
|
|
431
567
|
"smart-edit": {
|
|
432
568
|
"command": "npx",
|
|
433
|
-
"args": ["-y", "@nogataka/smart-edit@latest", "
|
|
569
|
+
"args": ["-y", "@nogataka/smart-edit@latest", "start-mcp-server", "--transport", "stdio"]
|
|
434
570
|
}
|
|
435
571
|
}
|
|
436
572
|
}
|
|
437
573
|
```
|
|
438
574
|
|
|
439
|
-
>
|
|
575
|
+
> デフォルトでカレントディレクトリが使用されます。特定パスを指定する場合: `args` に `"--project", "/path/to/project"` を追加
|
|
440
576
|
|
|
441
577
|
---
|
|
442
578
|
|
|
@@ -449,13 +585,13 @@ Windsurf では `~/.codeium/windsurf/mcp_config.json` で設定します。
|
|
|
449
585
|
"mcpServers": {
|
|
450
586
|
"smart-edit": {
|
|
451
587
|
"command": "npx",
|
|
452
|
-
"args": ["-y", "@nogataka/smart-edit@latest", "
|
|
588
|
+
"args": ["-y", "@nogataka/smart-edit@latest", "start-mcp-server", "--transport", "stdio"]
|
|
453
589
|
}
|
|
454
590
|
}
|
|
455
591
|
}
|
|
456
592
|
```
|
|
457
593
|
|
|
458
|
-
>
|
|
594
|
+
> デフォルトでカレントディレクトリが使用されます。特定パスを指定する場合: `args` に `"--project", "/path/to/project"` を追加
|
|
459
595
|
|
|
460
596
|
---
|
|
461
597
|
|
|
@@ -471,7 +607,7 @@ Continue では `~/.continue/config.json` の `experimental.modelContextProtocol
|
|
|
471
607
|
"transport": {
|
|
472
608
|
"type": "stdio",
|
|
473
609
|
"command": "npx",
|
|
474
|
-
"args": ["-y", "@nogataka/smart-edit@latest", "
|
|
610
|
+
"args": ["-y", "@nogataka/smart-edit@latest", "start-mcp-server", "--transport", "stdio"]
|
|
475
611
|
}
|
|
476
612
|
}
|
|
477
613
|
]
|
|
@@ -479,7 +615,7 @@ Continue では `~/.continue/config.json` の `experimental.modelContextProtocol
|
|
|
479
615
|
}
|
|
480
616
|
```
|
|
481
617
|
|
|
482
|
-
>
|
|
618
|
+
> デフォルトでカレントディレクトリが使用されます。特定パスを指定する場合: `args` に `"--project", "/path/to/project"` を追加
|
|
483
619
|
|
|
484
620
|
---
|
|
485
621
|
|
|
@@ -492,13 +628,13 @@ Cline では VS Code の設定 (`settings.json`) または Cline の MCP 設定
|
|
|
492
628
|
"cline.mcpServers": {
|
|
493
629
|
"smart-edit": {
|
|
494
630
|
"command": "npx",
|
|
495
|
-
"args": ["-y", "@nogataka/smart-edit@latest", "
|
|
631
|
+
"args": ["-y", "@nogataka/smart-edit@latest", "start-mcp-server", "--transport", "stdio"]
|
|
496
632
|
}
|
|
497
633
|
}
|
|
498
634
|
}
|
|
499
635
|
```
|
|
500
636
|
|
|
501
|
-
>
|
|
637
|
+
> デフォルトでカレントディレクトリが使用されます。特定パスを指定する場合: `args` に `"--project", "/path/to/project"` を追加
|
|
502
638
|
|
|
503
639
|
---
|
|
504
640
|
|
|
@@ -512,14 +648,14 @@ Zed では `~/.config/zed/settings.json` の `context_servers` に追加しま
|
|
|
512
648
|
"smart-edit": {
|
|
513
649
|
"command": {
|
|
514
650
|
"path": "npx",
|
|
515
|
-
"args": ["-y", "@nogataka/smart-edit@latest", "
|
|
651
|
+
"args": ["-y", "@nogataka/smart-edit@latest", "start-mcp-server", "--transport", "stdio"]
|
|
516
652
|
}
|
|
517
653
|
}
|
|
518
654
|
}
|
|
519
655
|
}
|
|
520
656
|
```
|
|
521
657
|
|
|
522
|
-
>
|
|
658
|
+
> デフォルトでカレントディレクトリが使用されます。特定パスを指定する場合: `args` に `"--project", "/path/to/project"` を追加
|
|
523
659
|
|
|
524
660
|
---
|
|
525
661
|
|
|
@@ -536,13 +672,13 @@ GitHub Copilot は VS Code 1.102 以降で MCP を公式サポートしていま
|
|
|
536
672
|
"servers": {
|
|
537
673
|
"smart-edit": {
|
|
538
674
|
"command": "npx",
|
|
539
|
-
"args": ["-y", "@nogataka/smart-edit@latest", "
|
|
675
|
+
"args": ["-y", "@nogataka/smart-edit@latest", "start-mcp-server", "--transport", "stdio"]
|
|
540
676
|
}
|
|
541
677
|
}
|
|
542
678
|
}
|
|
543
679
|
```
|
|
544
680
|
|
|
545
|
-
>
|
|
681
|
+
> デフォルトでカレントディレクトリが使用されます。特定パスを指定する場合: `args` に `"--project", "/path/to/project"` を追加
|
|
546
682
|
|
|
547
683
|
#### JetBrains IDE での設定
|
|
548
684
|
|
|
@@ -564,7 +700,7 @@ Claude Desktop (Windows/macOS) では `claude_desktop_config.json` に MCP サ
|
|
|
564
700
|
"mcpServers": {
|
|
565
701
|
"smart-edit": {
|
|
566
702
|
"command": "npx",
|
|
567
|
-
"args": ["-y", "@nogataka/smart-edit@latest", "
|
|
703
|
+
"args": ["-y", "@nogataka/smart-edit@latest", "start-mcp-server", "--context", "desktop-app", "--transport", "stdio"]
|
|
568
704
|
}
|
|
569
705
|
}
|
|
570
706
|
}
|
|
@@ -582,7 +718,7 @@ Claude Desktop (Windows/macOS) では `claude_desktop_config.json` に MCP サ
|
|
|
582
718
|
}
|
|
583
719
|
```
|
|
584
720
|
- `dist/cli.js` を呼び出す前に `pnpm build` を実行し、`dist/` に成果物を生成しておいてください。
|
|
585
|
-
-
|
|
721
|
+
- デフォルトでカレントディレクトリが使用されます。`--no-project` を指定するとプロジェクトなしで起動できます。
|
|
586
722
|
|
|
587
723
|
- **Docker イメージを使う場合(PoC)**
|
|
588
724
|
```json
|
|
@@ -594,7 +730,7 @@ Claude Desktop (Windows/macOS) では `claude_desktop_config.json` に MCP サ
|
|
|
594
730
|
"run", "--rm", "-i",
|
|
595
731
|
"-v", "/path/to/your/projects:/workspace/projects",
|
|
596
732
|
"ghcr.io/nogataka/smart-edit:latest",
|
|
597
|
-
"
|
|
733
|
+
"start-mcp-server", "--context", "desktop-app", "--transport", "stdio"
|
|
598
734
|
]
|
|
599
735
|
}
|
|
600
736
|
}
|
|
@@ -606,7 +742,7 @@ Claude Desktop (Windows/macOS) では `claude_desktop_config.json` に MCP サ
|
|
|
606
742
|
- Windows でパスを指定する場合はバックスラッシュを二重にする (`\\`) か、スラッシュ (`/`) を利用してください。
|
|
607
743
|
- 設定を保存したら Claude Desktop を完全終了(システムトレイのアイコンも終了)し、再起動すると smart-edit のツールが利用可能になります。
|
|
608
744
|
- `desktop-app` コンテキストは Claude Desktop 向けにチューニングされています。必要に応じて `~/.smart-edit/contexts/` 配下に自作コンテキストを配置し、`--context` で差し替え可能です。
|
|
609
|
-
-
|
|
745
|
+
- ダッシュボードを利用したい場合は別ターミナルで `npx @nogataka/smart-edit start-dashboard` を実行してください。ブラウザで `http://localhost:24282/dashboard/` にアクセスすると統合ダッシュボードが表示されます。
|
|
610
746
|
- MCP サーバーを終了するにはチャットを閉じるだけでなく、別コンソールから `smart-edit` プロセスを停止するか、CLI のログを確認しながら Ctrl+C で停止してください。
|
|
611
747
|
|
|
612
748
|
Claude Desktop の MCP 設定については [公式クイックスタート](https://modelcontextprotocol.io/quickstart/user) も参考になります。
|
package/dist/smart-edit/cli.js
CHANGED
|
@@ -9,6 +9,7 @@ import { ProjectConfig, SmartEditConfig, SmartEditPaths } from './config/smart_e
|
|
|
9
9
|
import { createSmartEditLogger, setConsoleLoggingEnabled } from './util/logging.js';
|
|
10
10
|
import { SmartEditAgent } from './agent.js';
|
|
11
11
|
import { SmartEditMCPFactorySingleProcess, createSmartEditHttpServer, createSmartEditStdioServer } from './mcp.js';
|
|
12
|
+
import { DEFAULT_DASHBOARD_PORT, registerInstance, unregisterInstance, findAvailablePort } from './instance-registry.js';
|
|
12
13
|
import { ToolRegistry } from './tools/tools_base.js';
|
|
13
14
|
import { coerceLanguage } from '../smart-lsp/ls_config.js';
|
|
14
15
|
import { ensureDefaultSubprocessOptions } from '../smart-lsp/util/subprocess_util.js';
|
|
@@ -96,8 +97,25 @@ function normalizeStartMcpServerOptions(raw) {
|
|
|
96
97
|
}
|
|
97
98
|
return undefined;
|
|
98
99
|
};
|
|
100
|
+
// プロジェクトの決定ロジック:
|
|
101
|
+
// 1. --no-project が指定された場合: null(プロジェクトなしで起動)
|
|
102
|
+
// 2. --project が指定された場合: 指定されたパス
|
|
103
|
+
// 3. --project-file が指定された場合: 指定されたパス(後方互換)
|
|
104
|
+
// 4. どれも指定されていない場合: カレントディレクトリを使用
|
|
105
|
+
const resolveProject = () => {
|
|
106
|
+
if (raw.noProject === true) {
|
|
107
|
+
return null;
|
|
108
|
+
}
|
|
109
|
+
if (isNonEmptyString(raw.project)) {
|
|
110
|
+
return raw.project;
|
|
111
|
+
}
|
|
112
|
+
if (isNonEmptyString(raw.projectFile)) {
|
|
113
|
+
return raw.projectFile;
|
|
114
|
+
}
|
|
115
|
+
return process.cwd();
|
|
116
|
+
};
|
|
99
117
|
return {
|
|
100
|
-
project:
|
|
118
|
+
project: resolveProject(),
|
|
101
119
|
projectFile: isNonEmptyString(raw.projectFile) ? raw.projectFile : null,
|
|
102
120
|
context,
|
|
103
121
|
modes: normalizedModes.slice(),
|
|
@@ -222,6 +240,8 @@ async function handleStartMcpServer(options, projectArg) {
|
|
|
222
240
|
memoryLogHandler: agentOptions.memoryLogHandler ?? undefined
|
|
223
241
|
})
|
|
224
242
|
});
|
|
243
|
+
// Track registered instance for cleanup
|
|
244
|
+
let registeredInstance = null;
|
|
225
245
|
try {
|
|
226
246
|
const serverOptions = {
|
|
227
247
|
host: options.host,
|
|
@@ -237,11 +257,26 @@ async function handleStartMcpServer(options, projectArg) {
|
|
|
237
257
|
switch (options.transport) {
|
|
238
258
|
case 'streamable-http': {
|
|
239
259
|
const server = await createSmartEditHttpServer(factory, serverOptions);
|
|
260
|
+
const serverPort = server.url.port ? Number.parseInt(server.url.port, 10) : options.port;
|
|
240
261
|
logger.info(`Streamable HTTP MCP server started: ${server.url.href}`);
|
|
241
262
|
logger.info('Press Ctrl+C to exit.');
|
|
263
|
+
// Register instance (skip in test environment)
|
|
264
|
+
if (!process.env.SMART_EDIT_SKIP_EDITOR) {
|
|
265
|
+
registeredInstance = registerInstance({
|
|
266
|
+
port: serverPort,
|
|
267
|
+
project,
|
|
268
|
+
pid: process.pid,
|
|
269
|
+
transport: 'streamable-http'
|
|
270
|
+
});
|
|
271
|
+
logger.info(`Registered instance ${registeredInstance.id} in registry`);
|
|
272
|
+
}
|
|
242
273
|
await new Promise((resolve) => {
|
|
243
274
|
const shutdown = async () => {
|
|
244
275
|
logger.info('Stopping HTTP MCP server...');
|
|
276
|
+
if (registeredInstance) {
|
|
277
|
+
unregisterInstance(registeredInstance.id);
|
|
278
|
+
logger.info(`Unregistered instance ${registeredInstance.id} from registry`);
|
|
279
|
+
}
|
|
245
280
|
await server.close();
|
|
246
281
|
resolve();
|
|
247
282
|
};
|
|
@@ -257,6 +292,17 @@ async function handleStartMcpServer(options, projectArg) {
|
|
|
257
292
|
case 'stdio': {
|
|
258
293
|
const server = await createSmartEditStdioServer(factory, serverOptions);
|
|
259
294
|
logger.info('STDIO MCP server started. Press Ctrl+C to exit.');
|
|
295
|
+
// For stdio transport, find an available port for the dashboard API (skip in test environment)
|
|
296
|
+
if (!process.env.SMART_EDIT_SKIP_EDITOR) {
|
|
297
|
+
const dashboardPort = findAvailablePort();
|
|
298
|
+
registeredInstance = registerInstance({
|
|
299
|
+
port: dashboardPort,
|
|
300
|
+
project,
|
|
301
|
+
pid: process.pid,
|
|
302
|
+
transport: 'stdio'
|
|
303
|
+
});
|
|
304
|
+
logger.info(`Registered instance ${registeredInstance.id} in registry (dashboard port: ${dashboardPort})`);
|
|
305
|
+
}
|
|
260
306
|
await new Promise((resolve) => {
|
|
261
307
|
let settled = false;
|
|
262
308
|
const finalize = async (reason) => {
|
|
@@ -265,6 +311,10 @@ async function handleStartMcpServer(options, projectArg) {
|
|
|
265
311
|
}
|
|
266
312
|
settled = true;
|
|
267
313
|
logger.info('Stopping STDIO MCP server...');
|
|
314
|
+
if (registeredInstance) {
|
|
315
|
+
unregisterInstance(registeredInstance.id);
|
|
316
|
+
logger.info(`Unregistered instance ${registeredInstance.id} from registry`);
|
|
317
|
+
}
|
|
268
318
|
if (reason === 'signal') {
|
|
269
319
|
await server.close();
|
|
270
320
|
}
|
|
@@ -295,6 +345,11 @@ async function handleStartMcpServer(options, projectArg) {
|
|
|
295
345
|
catch (error) {
|
|
296
346
|
const message = error instanceof Error ? error.message : String(error);
|
|
297
347
|
logger.error(`Smart-Edit MCP サーバーの起動に失敗しました: ${message}`);
|
|
348
|
+
// Unregister instance on error
|
|
349
|
+
if (registeredInstance) {
|
|
350
|
+
unregisterInstance(registeredInstance.id);
|
|
351
|
+
logger.info(`Unregistered instance ${registeredInstance.id} from registry (error cleanup)`);
|
|
352
|
+
}
|
|
298
353
|
throw error;
|
|
299
354
|
}
|
|
300
355
|
finally {
|
|
@@ -379,7 +434,8 @@ export function createSmartEditCli(options = {}) {
|
|
|
379
434
|
}
|
|
380
435
|
const startMcpServerCommand = new Command('start-mcp-server')
|
|
381
436
|
.description('Smart-Edit MCP サーバーを起動します。')
|
|
382
|
-
.option('--project [project]', '
|
|
437
|
+
.option('--project [project]', '起動時にアクティブ化するプロジェクトパス。省略時はカレントディレクトリを使用。')
|
|
438
|
+
.option('--no-project', 'プロジェクトなしで起動。後から activate_project ツールで指定可能。')
|
|
383
439
|
.option('--project-file [project]', '[非推奨] --project の旧名称。')
|
|
384
440
|
.argument('[project]', '[非推奨] プロジェクトの位置引数。')
|
|
385
441
|
.option('--context <context>', 'ビルトインコンテキスト名またはカスタム YAML へのパス。')
|
|
@@ -404,11 +460,32 @@ export function createSmartEditCli(options = {}) {
|
|
|
404
460
|
await handleStartMcpServer(opts, normalizedProjectArg);
|
|
405
461
|
}
|
|
406
462
|
catch (error) {
|
|
463
|
+
// In test environment, rethrow the error so vitest can display it properly
|
|
464
|
+
// (this.error() calls process.exit which vitest intercepts, hiding the actual error)
|
|
465
|
+
if (process.env.SMART_EDIT_SKIP_EDITOR) {
|
|
466
|
+
throw error;
|
|
467
|
+
}
|
|
407
468
|
const message = error instanceof Error ? error.message : String(error);
|
|
408
469
|
this.error(`${message}\n`, { exitCode: 1 });
|
|
409
470
|
}
|
|
410
471
|
});
|
|
411
472
|
program.addCommand(startMcpServerCommand);
|
|
473
|
+
const startDashboardCommand = new Command('start-dashboard')
|
|
474
|
+
.description('統合ダッシュボードを起動します(MCPサーバーなし)。複数のMCPインスタンスを一括管理できます。')
|
|
475
|
+
.option('--port <port>', 'ダッシュボードのポート番号。', (value) => parseInteger(value, '--port'), DEFAULT_DASHBOARD_PORT)
|
|
476
|
+
.action(async function () {
|
|
477
|
+
const opts = this.optsWithGlobals();
|
|
478
|
+
const port = typeof opts.port === 'number' ? opts.port : DEFAULT_DASHBOARD_PORT;
|
|
479
|
+
try {
|
|
480
|
+
const { runStandaloneDashboard } = await import('./standalone-dashboard.js');
|
|
481
|
+
await runStandaloneDashboard({ port });
|
|
482
|
+
}
|
|
483
|
+
catch (error) {
|
|
484
|
+
const message = error instanceof Error ? error.message : String(error);
|
|
485
|
+
this.error(`${message}\n`, { exitCode: 1 });
|
|
486
|
+
}
|
|
487
|
+
});
|
|
488
|
+
program.addCommand(startDashboardCommand);
|
|
412
489
|
const modeCommand = new Command('mode')
|
|
413
490
|
.description('Smart-Edit モードを管理します。');
|
|
414
491
|
modeCommand
|