aranea-sdk-cli 0.1.3 → 0.3.0

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 CHANGED
@@ -28,11 +28,74 @@ aranea-sdk register --type aranea_ar-is04a --mac AABBCCDDEEFF --dry-run
28
28
 
29
29
  # スキーマ取得
30
30
  aranea-sdk schema get --type aranea_ar-is04a
31
+
32
+ # AIアシスタントに質問
33
+ aranea-sdk metatron ask "State Reportの送信方法は?"
31
34
  ```
32
35
 
33
36
  ## コマンド一覧
34
37
 
35
- ### test - 接続・認証テスト
38
+ | コマンド | 説明 | 認証 |
39
+ |---------|------|------|
40
+ | `test` | 接続・認証テスト | 不要 |
41
+ | `register` | デバイス登録 | 不要(テストテナント) |
42
+ | `schema` | スキーマ取得・State Report検証 | 不要 |
43
+ | `validate` | Type名検証 | 不要 |
44
+ | `simulate` | 状態レポートシミュレーション | 不要 |
45
+ | `mqtt` | コマンド送信・ACKモニタリング | **必要** |
46
+ | `knowledge` | ナレッジベース管理 | **必要** |
47
+ | `metatron` | AI対話アシスタント | **必要** |
48
+
49
+ ---
50
+
51
+ ## 認証設定
52
+
53
+ ### 認証が必要なコマンド
54
+
55
+ `mqtt`, `knowledge`, `metatron` コマンドは Firebase Auth IDトークンが必要です。
56
+
57
+ ### 認証方法 (3つの選択肢)
58
+
59
+ #### 1. 環境変数で設定 (推奨)
60
+
61
+ ```bash
62
+ # Firebase IDトークンを環境変数に設定
63
+ export ARANEA_AUTH_TOKEN="eyJhbGciOiJSUzI1NiIsInR5..."
64
+ # または
65
+ export FIREBASE_AUTH_TOKEN="eyJhbGciOiJSUzI1NiIsInR5..."
66
+
67
+ # コマンド実行
68
+ aranea-sdk metatron ask "State Reportの送信方法は?"
69
+ ```
70
+
71
+ #### 2. --token オプションで指定
72
+
73
+ ```bash
74
+ aranea-sdk metatron ask "質問内容" --token "eyJhbGciOiJSUzI1NiIsInR5..."
75
+ ```
76
+
77
+ #### 3. サービスアカウント (mqtt コマンドのみ)
78
+
79
+ ```bash
80
+ # サービスアカウントキーを環境変数に設定
81
+ export GOOGLE_APPLICATION_CREDENTIALS="/path/to/serviceAccountKey.json"
82
+ # オプション: カスタムAPIキー (未設定時はデフォルト値を使用)
83
+ export FIREBASE_API_KEY="AIzaSy..."
84
+
85
+ aranea-sdk mqtt send-command -l 3004AABBCCDDEEFF0001 -t relay -p '{"channel":1,"state":true}'
86
+ ```
87
+
88
+ ### Firebase IDトークンの取得方法
89
+
90
+ ```javascript
91
+ // Firebase Auth からIDトークンを取得
92
+ const token = await firebase.auth().currentUser.getIdToken();
93
+ console.log(token);
94
+ ```
95
+
96
+ ---
97
+
98
+ ## test - 接続・認証テスト
36
99
 
37
100
  ```bash
38
101
  # API接続テスト
@@ -45,7 +108,9 @@ aranea-sdk test auth
45
108
  aranea-sdk test auth --tid T123... --lacis-id 173... --cic 022029
46
109
  ```
47
110
 
48
- ### register - デバイス登録
111
+ ---
112
+
113
+ ## register - デバイス登録
49
114
 
50
115
  ```bash
51
116
  # ドライラン (登録せずに検証)
@@ -63,7 +128,7 @@ aranea-sdk register \
63
128
  --cic 022029
64
129
  ```
65
130
 
66
- #### オプション
131
+ ### オプション
67
132
 
68
133
  | オプション | 説明 | デフォルト |
69
134
  |-----------|------|-----------|
@@ -75,17 +140,40 @@ aranea-sdk register \
75
140
  | `-d, --dry-run` | 検証のみ | false |
76
141
  | `-e, --endpoint` | 環境 | production |
77
142
 
78
- ### schema - スキーマ操作
143
+ ---
144
+
145
+ ## schema - スキーマ操作
79
146
 
80
147
  ```bash
81
- # スキーマ取得
148
+ # スキーマ一覧表示
149
+ aranea-sdk schema list
150
+
151
+ # スキーマ詳細取得
82
152
  aranea-sdk schema get --type aranea_ar-is04a
153
+ aranea-sdk schema get --type aranea_ar-is04a --json # JSON出力
83
154
 
84
- # スキーマ検証
155
+ # State Report JSONの検証
85
156
  aranea-sdk schema validate --file state.json --type aranea_ar-is04a
86
157
  ```
87
158
 
88
- ### validate - Type名検証
159
+ > **Note**: `schema validate` State Report ペイロードの検証用です。
160
+ > スキーマ定義ファイル自体の静的検証機能は将来バージョンで追加予定です。
161
+
162
+ ### 実装済み vs 計画中
163
+
164
+ | サブコマンド | 状態 | 説明 |
165
+ |-------------|------|------|
166
+ | `list` | ✅ 実装済み | 登録済みスキーマ一覧 |
167
+ | `get` | ✅ 実装済み | スキーマ詳細取得 |
168
+ | `validate` | ✅ 実装済み | State Report 検証 |
169
+ | `create` | 🔜 計画中 | スキーマ新規作成 |
170
+ | `push` | 🔜 計画中 | 開発環境へプッシュ |
171
+ | `promote` | 🔜 計画中 | 本番環境へ昇格 |
172
+ | `rollback` | 🔜 計画中 | バージョンロールバック |
173
+
174
+ ---
175
+
176
+ ## validate - Type名検証
89
177
 
90
178
  ```bash
91
179
  # Type名検証
@@ -95,7 +183,9 @@ aranea-sdk validate type --type aranea_ar-is04a
95
183
  aranea-sdk validate type --type ISMS_ar-is04a
96
184
  ```
97
185
 
98
- ### simulate - 状態レポートシミュレーション
186
+ ---
187
+
188
+ ## simulate - 状態レポートシミュレーション
99
189
 
100
190
  ```bash
101
191
  # ファイルからシミュレーション
@@ -105,16 +195,178 @@ aranea-sdk simulate state-report --file test.json --dry-run
105
195
  aranea-sdk simulate state-report --payload '{"temp": 25.5}'
106
196
  ```
107
197
 
198
+ ---
199
+
200
+ ## mqtt - コマンド送信 (認証必要)
201
+
202
+ デバイスへのコマンド送信とACK監視を行います。
203
+
204
+ ### send-command - コマンド送信
205
+
206
+ ```bash
207
+ # リレーON (dry-run)
208
+ aranea-sdk mqtt send-command \
209
+ --lacis-id 3004AABBCCDDEEFF0001 \
210
+ --type relay \
211
+ --params '{"channel":1,"state":true}' \
212
+ --dry-run
213
+
214
+ # 実際に送信 (ACK待機あり)
215
+ aranea-sdk mqtt send-command \
216
+ --lacis-id 3004AABBCCDDEEFF0001 \
217
+ --type relay \
218
+ --params '{"channel":1,"state":true}' \
219
+ --token "$ARANEA_AUTH_TOKEN" \
220
+ --wait
221
+ ```
222
+
223
+ ### オプション
224
+
225
+ | オプション | 説明 | デフォルト |
226
+ |-----------|------|-----------|
227
+ | `-l, --lacis-id` | デバイスLacisID (必須) | - |
228
+ | `-t, --type` | コマンドタイプ (必須) | - |
229
+ | `-p, --params` | パラメータ JSON | `{}` |
230
+ | `--ttl` | TTL秒数 | 30 |
231
+ | `--group-id` | グループID | - |
232
+ | `--token` | 認証トークン | 環境変数から |
233
+ | `-w, --wait` | ACK待機 | false |
234
+ | `--wait-timeout` | ACK待機タイムアウト | 30 |
235
+ | `-d, --dry-run` | リクエスト内容表示のみ | false |
236
+
237
+ ### monitor - ACKモニタリング
238
+
239
+ ```bash
240
+ # 特定コマンドのACK監視
241
+ aranea-sdk mqtt monitor --cmd-id "abc123..." --timeout 60
242
+
243
+ # デバイス単位で監視 (Firestoreリアルタイム)
244
+ aranea-sdk mqtt monitor --lacis-id 3004AABBCCDDEEFF0001 --timeout 120
245
+ ```
246
+
247
+ > **前提**: Firestoreリアルタイム監視には `GOOGLE_APPLICATION_CREDENTIALS` が必要です。
248
+
249
+ ### periodic - 定期送信 (負荷テスト用)
250
+
251
+ ```bash
252
+ # 5秒間隔で10回送信
253
+ aranea-sdk mqtt periodic \
254
+ --lacis-id 3004AABBCCDDEEFF0001 \
255
+ --type ping \
256
+ --interval 5 \
257
+ --count 10 \
258
+ --token "$ARANEA_AUTH_TOKEN"
259
+ ```
260
+
261
+ ---
262
+
263
+ ## knowledge - ナレッジベース管理 (認証必要)
264
+
265
+ AraneaMetatronのナレッジベースを管理します。
266
+
267
+ ### 使用例
268
+
269
+ ```bash
270
+ # ナレッジ一覧
271
+ aranea-sdk knowledge list --token "$ARANEA_AUTH_TOKEN"
272
+
273
+ # カテゴリ別一覧
274
+ aranea-sdk knowledge list --category api
275
+
276
+ # 検索
277
+ aranea-sdk knowledge search --query "state report"
278
+
279
+ # 詳細取得
280
+ aranea-sdk knowledge get --id "entry_id_here"
281
+
282
+ # ナレッジ追加
283
+ aranea-sdk knowledge add \
284
+ --title "State Report送信方法" \
285
+ --category guide \
286
+ --file ./content.md \
287
+ --keywords "state,report,api"
288
+
289
+ # カテゴリ一覧表示
290
+ aranea-sdk knowledge categories
291
+ ```
292
+
293
+ ### カテゴリ
294
+
295
+ | カテゴリ | 説明 |
296
+ |---------|------|
297
+ | `api` | API仕様・エンドポイント |
298
+ | `guide` | 実装ガイド・チュートリアル |
299
+ | `code` | コードサンプル・スニペット |
300
+ | `reference` | リファレンス・仕様書 |
301
+ | `incident` | インシデント・トラブルシューティング |
302
+ | `tip` | Tips・ノウハウ |
303
+
304
+ ---
305
+
306
+ ## metatron - AI対話 (認証必要)
307
+
308
+ AraneaSDK専門のAIアシスタントに質問できます。
309
+
310
+ ### 使用例
311
+
312
+ ```bash
313
+ # 単発質問
314
+ aranea-sdk metatron ask "State Reportの送信方法は?" --token "$ARANEA_AUTH_TOKEN"
315
+
316
+ # JSON出力
317
+ aranea-sdk metatron ask "ESP32のサンプルコードは?" --raw
318
+
319
+ # 対話モード (REPL)
320
+ aranea-sdk metatron chat --token "$ARANEA_AUTH_TOKEN"
321
+
322
+ # 対話可能なトピック一覧
323
+ aranea-sdk metatron topics
324
+
325
+ # 質問例を表示
326
+ aranea-sdk metatron examples
327
+ ```
328
+
329
+ ### 対話可能なトピック
330
+
331
+ - State Report API
332
+ - デバイス登録
333
+ - スキーマ設計
334
+ - MQTT/コマンド
335
+ - ESP32実装
336
+ - デバイスタイプ
337
+ - CelestialGlobe
338
+ - トラブルシューティング
339
+
340
+ ---
341
+
108
342
  ## 対応デバイスType
109
343
 
344
+ ### 新規 (aranea_ar-*)
345
+
110
346
  | Type | ProductType | 説明 |
111
347
  |------|-------------|------|
112
348
  | `aranea_ar-is01` | 001 | AraneaSDK Basic Sensor |
349
+ | `aranea_ar-is02` | 002 | AraneaSDK Standard Sensor |
113
350
  | `aranea_ar-is04a` | 004 | Network Scanner (ESP32) |
114
351
  | `aranea_ar-is05a` | 005 | Environment Sensor (ESP32) |
115
352
  | `aranea_ar-is06a` | 006 | Power Monitor (ESP32) |
116
353
  | `aranea_ar-is10` | 010 | Router Inspector (OpenWrt/AsusWRT) |
117
354
 
355
+ ### レガシー (ISMS_ar-*)
356
+
357
+ | Type | ProductType | 説明 |
358
+ |------|-------------|------|
359
+ | `ISMS_ar-is01` | 001 | Basic Sensor (レガシー) |
360
+ | `ISMS_ar-is02` | 002 | Standard Sensor (レガシー) |
361
+ | `ISMS_ar-is03` | 003 | Advanced Sensor (レガシー) |
362
+ | `ISMS_ar-is04` | 004 | Multi-channel Sensor (レガシー) |
363
+ | `ISMS_ar-is05` | 005 | Environment Sensor (レガシー) |
364
+
365
+ > **Note**: `ISMS_ar-*` プレフィックスは永続的にサポートされます。
366
+ > 登録時に `aranea_ar-*` へ自動変換されます。
367
+
368
+ ---
369
+
118
370
  ## LacisID生成規則
119
371
 
120
372
  AraneaDeviceのLacisIDは以下の形式で自動生成されます:
@@ -131,6 +383,8 @@ ProductCode: 4桁4進数 (枝番から算出)
131
383
  **例**: `aranea_ar-is04a` + MAC `AABBCCDDEEFF`
132
384
  → LacisID: `3004AABBCCDDEEFF1201`
133
385
 
386
+ ---
387
+
134
388
  ## 環境設定
135
389
 
136
390
  | 環境 | Gate API | State API |
@@ -138,6 +392,8 @@ ProductCode: 4桁4進数 (枝番から算出)
138
392
  | production | `asia-northeast1-mobesorder.cloudfunctions.net` | 同左 |
139
393
  | staging | `asia-northeast1-mobesorder-staging.cloudfunctions.net` | 同左 |
140
394
 
395
+ ---
396
+
141
397
  ## テストテナント
142
398
 
143
399
  開発・テスト用に以下のテストテナントが利用可能です:
@@ -147,25 +403,37 @@ ProductCode: 4桁4進数 (枝番から算出)
147
403
 
148
404
  テストテナントを使用する場合、`--tid`, `--lacis-id`, `--cic` オプションは省略可能です。
149
405
 
150
- ## レガシーType名サポート
406
+ ---
151
407
 
152
- `ISMS_ar-*` プレフィックスは永続的にサポートされます:
408
+ ## ヘルプ表示
153
409
 
154
410
  ```bash
155
- # ISMS_ar-* は aranea_ar-* に自動変換
156
- aranea-sdk register --type ISMS_ar-is04a --mac AABBCCDDEEFF
157
- # → typeWarning.suggestedType: "aranea_ar-is04a" で登録
411
+ # 全体ヘルプ
412
+ aranea-sdk --help
413
+
414
+ # コマンド別ヘルプ
415
+ aranea-sdk schema --help
416
+ aranea-sdk mqtt --help
417
+ aranea-sdk metatron --help
418
+ aranea-sdk knowledge --help
158
419
  ```
159
420
 
421
+ ---
422
+
160
423
  ## 要件
161
424
 
162
425
  - Node.js >= 18.0.0
163
426
 
427
+ ---
428
+
164
429
  ## ライセンス
165
430
 
166
431
  MIT License - see [LICENSE](./LICENSE)
167
432
 
433
+ ---
434
+
168
435
  ## 関連リンク
169
436
 
170
437
  - [AraneaSDK Documentation](https://github.com/warusakudeveroper/mobes2.0/tree/main/doc/APPS/araneaSDK)
438
+ - [AraneaMetatron Architecture](https://github.com/warusakudeveroper/mobes2.0/tree/main/doc/APPS/araneaSDK/headDesign/20_ARANEA_METATRON_ARCHITECTURE.md)
171
439
  - [Issues](https://github.com/warusakudeveroper/mobes2.0/issues)
@@ -0,0 +1,14 @@
1
+ /**
2
+ * knowledge コマンド - ナレッジベース管理
3
+ *
4
+ * Usage:
5
+ * aranea-sdk knowledge add --title "..." --content "..." --category guide
6
+ * aranea-sdk knowledge search --query "state report"
7
+ * aranea-sdk knowledge list --category api
8
+ * aranea-sdk knowledge get --id <id>
9
+ *
10
+ * @see doc/APPS/araneaSDK/headDesign/20_ARANEA_METATRON_ARCHITECTURE.md
11
+ */
12
+ import { Command } from 'commander';
13
+ export declare const knowledgeCommand: Command;
14
+ export default knowledgeCommand;