aptly 0.1.9 → 0.1.11

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.
Files changed (70) hide show
  1. package/README.en.md +10 -10
  2. package/README.ja.md +10 -10
  3. package/README.md +10 -10
  4. package/README.zh-CN.md +10 -10
  5. package/dist/bin/aptly-observe.d.ts +2 -0
  6. package/dist/bin/aptly-observe.js +66 -0
  7. package/dist/bin/aptly.js +59 -17
  8. package/dist/src/cli-help.js +18 -11
  9. package/dist/src/cli-input.d.ts +19 -1
  10. package/dist/src/cli-input.js +23 -11
  11. package/dist/src/policy-source.d.ts +3 -0
  12. package/dist/src/policy-source.js +11 -0
  13. package/dist/src/server.d.ts +1 -1
  14. package/dist/src/server.js +44 -2
  15. package/dist/src/setup.d.ts +69 -0
  16. package/dist/src/setup.js +605 -6
  17. package/dist/src/statistics-codex.d.ts +23 -0
  18. package/dist/src/statistics-codex.js +121 -0
  19. package/dist/src/statistics-policy.d.ts +2 -0
  20. package/dist/src/statistics-policy.js +20 -0
  21. package/dist/src/statistics.d.ts +90 -0
  22. package/dist/src/statistics.js +472 -0
  23. package/dist/src/transmission-review-cli.d.ts +11 -0
  24. package/dist/src/transmission-review-cli.js +35 -0
  25. package/dist/src/update-notifier.js +1 -1
  26. package/dist/src/version.d.ts +1 -1
  27. package/dist/src/version.js +1 -1
  28. package/docs/ADVISORY_USAGE.md +1 -1
  29. package/docs/DRAFT_0_1_0.md +1 -1
  30. package/docs/guide/en/advanced.md +217 -0
  31. package/docs/guide/en/benchmarks.md +32 -0
  32. package/docs/guide/en/budget.md +45 -0
  33. package/docs/guide/en/configuration.md +104 -0
  34. package/docs/guide/en/installation.md +114 -0
  35. package/docs/guide/en/routing.md +61 -0
  36. package/docs/guide/en/statistics.md +43 -0
  37. package/docs/guide/en/transmission.md +71 -0
  38. package/docs/guide/en/troubleshooting.md +99 -0
  39. package/docs/guide/en.md +80 -477
  40. package/docs/guide/ja/advanced.md +217 -0
  41. package/docs/guide/ja/benchmarks.md +32 -0
  42. package/docs/guide/ja/budget.md +45 -0
  43. package/docs/guide/ja/configuration.md +104 -0
  44. package/docs/guide/ja/installation.md +114 -0
  45. package/docs/guide/ja/routing.md +61 -0
  46. package/docs/guide/ja/statistics.md +43 -0
  47. package/docs/guide/ja/transmission.md +71 -0
  48. package/docs/guide/ja/troubleshooting.md +99 -0
  49. package/docs/guide/ja.md +80 -477
  50. package/docs/guide/ko/advanced.md +217 -0
  51. package/docs/guide/ko/benchmarks.md +32 -0
  52. package/docs/guide/ko/budget.md +45 -0
  53. package/docs/guide/ko/configuration.md +104 -0
  54. package/docs/guide/ko/installation.md +114 -0
  55. package/docs/guide/ko/routing.md +61 -0
  56. package/docs/guide/ko/statistics.md +43 -0
  57. package/docs/guide/ko/transmission.md +71 -0
  58. package/docs/guide/ko/troubleshooting.md +99 -0
  59. package/docs/guide/ko.md +80 -477
  60. package/docs/guide/zh-CN/advanced.md +217 -0
  61. package/docs/guide/zh-CN/benchmarks.md +32 -0
  62. package/docs/guide/zh-CN/budget.md +45 -0
  63. package/docs/guide/zh-CN/configuration.md +104 -0
  64. package/docs/guide/zh-CN/installation.md +114 -0
  65. package/docs/guide/zh-CN/routing.md +61 -0
  66. package/docs/guide/zh-CN/statistics.md +43 -0
  67. package/docs/guide/zh-CN/transmission.md +71 -0
  68. package/docs/guide/zh-CN/troubleshooting.md +99 -0
  69. package/docs/guide/zh-CN.md +80 -477
  70. package/package.json +3 -2
package/README.en.md CHANGED
@@ -16,7 +16,7 @@
16
16
 
17
17
  Aptly classifies a minimal task summary with the OpenAI Decisions API and recommends an allowlisted execution profile. Its installed Hook can automatically select defaults for fresh, general-purpose subagents without explicit choices. The host retains control of execution and permissions.
18
18
 
19
- Our own tests showed **about 52–58% lower API-equivalent costs**. See the [test conditions and detailed results](docs/guide/en.md#cost-benchmark).
19
+ Our own tests showed **about 52–58% lower API-equivalent costs**. See the [test conditions and detailed results](docs/guide/en/benchmarks.md#guide-cost-benchmarks).
20
20
 
21
21
  ## Quick start
22
22
 
@@ -29,15 +29,15 @@ aptly set env OPENAI_API_KEY
29
29
  aptly --version
30
30
  ```
31
31
 
32
- Check the installed version with `aptly --version`. On supported npm versions, `--allow-scripts=aptly` allows Aptly’s installation script. If your npm does not support this option, follow the explicit installation and setup steps in the [installation guide](docs/guide/en.md#installation). From Aptly 0.1.7, new registrations make no automatic transmission until you select an OpenAI Decisions API transmission scope with `aptly set default`.
32
+ Check the installed version with `aptly --version`. On supported npm versions, `--allow-scripts=aptly` allows Aptly’s installation script. If your npm does not support this option, follow the explicit installation and setup steps in the [installation guide](docs/guide/en/installation.md#guide-installation). From Aptly 0.1.7, new registrations make no automatic transmission until you select an OpenAI Decisions API transmission scope with `aptly set default`.
33
33
 
34
34
  During installation, `postinstall` registers the MCP server and a `PreToolUse` Hook in existing host configuration directories. Run `setup` explicitly if automatic registration was skipped or a host has no configuration directory yet. Other settings and Hooks, and any existing Aptly launch command and environment, are preserved.
35
35
 
36
- Store the classification key, `OPENAI_API_KEY`, in the OS credential store using the hidden prompt in `aptly set env OPENAI_API_KEY`, or pass it to the MCP process through a secure execution environment. Do not put it in command arguments, requests, configuration JSON, or the repository. Restart the host or MCP server, then **review and trust the new Hook through `/hooks` in Codex**. See [installation, keys, and registration](docs/guide/en.md#installation).
36
+ Store the classification key, `OPENAI_API_KEY`, in the OS credential store using the hidden prompt in `aptly set env OPENAI_API_KEY`, or pass it to the MCP process through a secure execution environment. Do not put it in command arguments, requests, configuration JSON, or the repository. Restart the host or MCP server, then **review and trust the new Hook through `/hooks` in Codex**. See [installation, keys, and registration](docs/guide/en/installation.md#guide-installation).
37
37
 
38
38
  ## Update
39
39
 
40
- To update an existing global npm installation running Aptly 0.1.3 or later, stop all related host, MCP, and CLI writers and review ledger migration and the manual fallback in the [installation and upgrade guide](docs/guide/en.md#installation). Existing key settings are preserved, so there is no need to re-enter the key. Restart afterward.
40
+ To update an existing global npm installation running Aptly 0.1.3 or later, stop all related host, MCP, and CLI writers and review ledger migration and the manual fallback in the [installation and upgrade guide](docs/guide/en/installation.md#guide-installation). Existing key settings are preserved, so there is no need to re-enter the key. Restart afterward.
41
41
 
42
42
  ```sh
43
43
  aptly update
@@ -52,16 +52,16 @@ aptly setup --client all
52
52
  | Direct recommendation | Returns a profile through `recommend_agent` or `aptly recommend`; review it and decide separately whether to run it in the host |
53
53
  | fixture | Tests recommendations generated by local rules without a key or network access; these are not actual Decisions results |
54
54
 
55
- From Aptly 0.1.4, inherited calls also reach recommendation. Application still requires explicit `fork_turns: "none"` in Codex or a general-purpose Claude Code call without history constraints; specified fields are preserved. Recommendation, Hook argument updates and child execution are separate facts. See the [guide](docs/guide/en.md#automatic-hook) for application conditions.
55
+ From Aptly 0.1.4, inherited calls also reach recommendation. Application still requires explicit `fork_turns: "none"` in Codex or a general-purpose Claude Code call without history constraints; specified fields are preserved. Recommendation, Hook argument updates and child execution are separate facts. See the [guide](docs/guide/en/routing.md#guide-automatic-routing) for application conditions.
56
56
 
57
57
  ## Documentation
58
58
 
59
59
  - [User guide](docs/guide/en.md): installation and removal, keys, Hooks, direct recommendations, and error recovery
60
- - [Installation and removal](docs/guide/en.md#installation) and [CLI configuration](docs/guide/en.md#configure-with-the-cli): global npm installation, host registration, restarting, and trust review
61
- - [Models and environment variables](docs/guide/en.md#models-and-environment-variables): six default profiles and candidate configuration
62
- - [Providing context](docs/guide/en.md#providing-context): encrypted messages and repository URL limitations
63
- - [Cost benchmark](docs/guide/en.md#cost-benchmark): tokens, converted costs, and measurement scope for a README translation review
64
- - [Diagnostics and development](docs/guide/en.md#diagnostics-and-development): local reports and checks without paid API calls
60
+ - [Installation and removal](docs/guide/en/installation.md#guide-installation) and [CLI configuration](docs/guide/en/configuration.md#guide-cli-configuration): global npm installation, host registration, restarting, and trust review
61
+ - [Models and environment variables](docs/guide/en/configuration.md#guide-models-and-environment): six default profiles and candidate configuration
62
+ - [Providing context](docs/guide/en/advanced.md#guide-context-delivery): encrypted messages and repository URL limitations
63
+ - [Cost benchmark](docs/guide/en/benchmarks.md#guide-cost-benchmarks): tokens, converted costs, and measurement scope for a README translation review
64
+ - [Diagnostics and development](docs/guide/en/advanced.md#guide-diagnostics-and-development): local reports and checks without paid API calls
65
65
 
66
66
  Korean is the canonical documentation. The English, Simplified Chinese, and Japanese documents cover the same usage scope. Choosing a documentation language does not change the language of CLI or MCP output.
67
67
 
package/README.ja.md CHANGED
@@ -16,7 +16,7 @@
16
16
 
17
17
  Aptly は必要最小限のタスク要約を OpenAI Decisions API で分類し、あらかじめ許可された実行プロファイルを推薦します。インストールした Hook は、明示的な指定のない新しい汎用サブエージェントのデフォルト値を自動で選択できます。サブエージェントの実行と権限に関する判断は、既存のホストが行います。
18
18
 
19
- 独自テストでは、**API 換算コストが約 52~58% 減少しました**。[測定条件と詳細結果](docs/guide/ja.md#費用実測)をご覧ください。
19
+ 独自テストでは、**API 換算コストが約 52~58% 減少しました**。[測定条件と詳細結果](docs/guide/ja/benchmarks.md#guide-cost-benchmarks)をご覧ください。
20
20
 
21
21
  ## クイックスタート
22
22
 
@@ -29,15 +29,15 @@ aptly set env OPENAI_API_KEY
29
29
  aptly --version
30
30
  ```
31
31
 
32
- `aptly --version` でインストール済みのバージョンを確認してください。対応する npm では、`--allow-scripts=aptly` で Aptly のインストールスクリプトを許可します。このオプションに対応していない npm では、[インストール案内](docs/guide/ja.md#インストール)の明示的なインストール・設定手順に従ってください。 Aptly 0.1.7 以降、新規登録は自動送信せず、`aptly set default` で OpenAI Decisions API への送信範囲を選択します。
32
+ `aptly --version` でインストール済みのバージョンを確認してください。対応する npm では、`--allow-scripts=aptly` で Aptly のインストールスクリプトを許可します。このオプションに対応していない npm では、[インストール案内](docs/guide/ja/installation.md#guide-installation)の明示的なインストール・設定手順に従ってください。 Aptly 0.1.7 以降、新規登録は自動送信せず、`aptly set default` で OpenAI Decisions API への送信範囲を選択します。
33
33
 
34
34
  インストール時の `postinstall` は、既存のホスト設定ディレクトリに MCP と `PreToolUse` Hook を登録します。自動登録をスキップした場合や、ホストに設定ディレクトリがまだない場合も、`setup` を明示的に実行して登録できます。他の既存設定・Hook と、既存の Aptly の実行コマンド・環境は保持します。
35
35
 
36
- 分類用の `OPENAI_API_KEY` は、`aptly set env OPENAI_API_KEY` の非表示入力で OS の資格情報ストアに保存するか、安全な実行環境から MCP プロセスに渡してください。キーをコマンドライン・リクエスト・設定 JSON・リポジトリに記載しないでください。ホストまたは MCP を再起動した後、**Codex では `/hooks` で新しい Hook を確認し、信頼を承認**してください。[インストール・キー・登録の詳細](docs/guide/ja.md#インストール)を確認してください。
36
+ 分類用の `OPENAI_API_KEY` は、`aptly set env OPENAI_API_KEY` の非表示入力で OS の資格情報ストアに保存するか、安全な実行環境から MCP プロセスに渡してください。キーをコマンドライン・リクエスト・設定 JSON・リポジトリに記載しないでください。ホストまたは MCP を再起動した後、**Codex では `/hooks` で新しい Hook を確認し、信頼を承認**してください。[インストール・キー・登録の詳細](docs/guide/ja/installation.md#guide-installation)を確認してください。
37
37
 
38
38
  ## 更新
39
39
 
40
- npm でグローバルインストール済みの Aptly 0.1.3 以降を更新するには、関連するホスト・MCP・CLI の書き込みプロセスをすべて停止し、[インストールとアップグレードの案内](docs/guide/ja.md#インストール)で台帳の移行と手動での代替手順を確認してください。既存のキー設定は保持されるため、キーの再入力は不要です。コマンド実行後に再起動してください。
40
+ npm でグローバルインストール済みの Aptly 0.1.3 以降を更新するには、関連するホスト・MCP・CLI の書き込みプロセスをすべて停止し、[インストールとアップグレードの案内](docs/guide/ja/installation.md#guide-installation)で台帳の移行と手動での代替手順を確認してください。既存のキー設定は保持されるため、キーの再入力は不要です。コマンド実行後に再起動してください。
41
41
 
42
42
  ```sh
43
43
  aptly update
@@ -52,16 +52,16 @@ aptly setup --client all
52
52
  | 直接推薦 | `recommend_agent` または `aptly recommend` でプロファイルを受け取り、実行するかどうかをホストで明示的に判断します |
53
53
  | fixture | キーやネットワークを使わず、ローカルで生成した試験用の推薦を確認できます。実際の Decisions の結果ではありません |
54
54
 
55
- Aptly 0.1.4 以降では継承呼び出しも推薦を評価します。適用には Codex の明示的な `fork_turns: "none"`、または履歴制約のない Claude Code の汎用呼び出しが必要で、指定済みフィールドは保持します。推薦・Hook 引数更新・実際の子の実行は別です。適用条件は[ガイド](docs/guide/ja.md#自動-hook)を参照してください。
55
+ Aptly 0.1.4 以降では継承呼び出しも推薦を評価します。適用には Codex の明示的な `fork_turns: "none"`、または履歴制約のない Claude Code の汎用呼び出しが必要で、指定済みフィールドは保持します。推薦・Hook 引数更新・実際の子の実行は別です。適用条件は[ガイド](docs/guide/ja/routing.md#guide-automatic-routing)を参照してください。
56
56
 
57
57
  ## ドキュメント
58
58
 
59
59
  - [使用ガイド](docs/guide/ja.md): インストール・削除、キー、Hook、直接推薦、エラー復旧
60
- - [インストール・削除](docs/guide/ja.md#インストール)と [CLI 設定](docs/guide/ja.md#cli-による設定): npm のグローバルインストール、ホスト登録、再起動と信頼の承認
61
- - [モデルと環境変数](docs/guide/ja.md#モデルと環境変数): 6 つのデフォルトプロファイルと候補の設定
62
- - [コンテキストの提供](docs/guide/ja.md#コンテキストの提供): 暗号化されたメッセージとリポジトリ URL の制約
63
- - [費用実測](docs/guide/ja.md#費用実測): README 翻訳レビューのトークン・換算費用と測定範囲
64
- - [診断・開発](docs/guide/ja.md#診断と開発): ローカル report と無料の検証コマンド
60
+ - [インストール・削除](docs/guide/ja/installation.md#guide-installation)と [CLI 設定](docs/guide/ja/configuration.md#guide-cli-configuration): npm のグローバルインストール、ホスト登録、再起動と信頼の承認
61
+ - [モデルと環境変数](docs/guide/ja/configuration.md#guide-models-and-environment): 6 つのデフォルトプロファイルと候補の設定
62
+ - [コンテキストの提供](docs/guide/ja/advanced.md#guide-context-delivery): 暗号化されたメッセージとリポジトリ URL の制約
63
+ - [費用実測](docs/guide/ja/benchmarks.md#guide-cost-benchmarks): README 翻訳レビューのトークン・換算費用と測定範囲
64
+ - [診断・開発](docs/guide/ja/advanced.md#guide-diagnostics-and-development): ローカル report と無料の検証コマンド
65
65
 
66
66
  韓国語版が正本です。英語・簡体字中国語・日本語のドキュメントは同じ使用範囲を説明しており、ドキュメントの言語を選んでも CLI・MCP の出力言語は変わりません。
67
67
 
package/README.md CHANGED
@@ -16,7 +16,7 @@
16
16
 
17
17
  Aptly는 최소한의 작업 요약을 OpenAI Decisions API로 분류하고 허용된 실행 프로필을 추천합니다. 설치한 Hook은 명시 선택이 없는 새 일반 서브에이전트의 기본값을 자동으로 선택할 수 있습니다. 실제 실행과 권한 결정은 기존 호스트가 담당합니다.
18
18
 
19
- 자체 테스트에서 **API 환산 비용이 약 52~58% 감소했습니다**. [측정 조건과 상세 결과](docs/guide/ko.md#비용-실측)를 확인하세요.
19
+ 자체 테스트에서 **API 환산 비용이 약 52~58% 감소했습니다**. [측정 조건과 상세 결과](docs/guide/ko/benchmarks.md#guide-cost-benchmarks)를 확인하세요.
20
20
 
21
21
  ## 빠른 시작
22
22
 
@@ -29,15 +29,15 @@ aptly set env OPENAI_API_KEY
29
29
  aptly --version
30
30
  ```
31
31
 
32
- `aptly --version`으로 설치된 버전을 확인하십시오. `--allow-scripts=aptly`는 지원하는 npm에서 Aptly의 설치 스크립트를 허용합니다. 이 옵션을 지원하지 않는 npm은 [설치 안내](docs/guide/ko.md#설치)의 명시적 설치·설정 절차를 따르십시오. Aptly 0.1.7부터 신규 등록의 자동 전송을 보류하며 `aptly set default`에서 OpenAI Decisions API 전송 범위를 선택합니다.
32
+ `aptly --version`으로 설치된 버전을 확인하십시오. `--allow-scripts=aptly`는 지원하는 npm에서 Aptly의 설치 스크립트를 허용합니다. 이 옵션을 지원하지 않는 npm은 [설치 안내](docs/guide/ko/installation.md#guide-installation)의 명시적 설치·설정 절차를 따르십시오. Aptly 0.1.7부터 신규 등록의 자동 전송을 보류하며 `aptly set default`에서 OpenAI Decisions API 전송 범위를 선택합니다.
33
33
 
34
34
  설치 시 `postinstall`은 기존 호스트 설정 디렉터리에 MCP와 `PreToolUse` Hook을 등록합니다. 명시적인 `setup`은 자동 등록을 건너뛰었거나 아직 설정 디렉터리가 없는 호스트에도 사용할 수 있습니다. 기존 다른 설정·Hook과 기존 Aptly 실행 명령·환경은 보존합니다.
35
35
 
36
- 분류용 `OPENAI_API_KEY`는 `aptly set env OPENAI_API_KEY`의 숨김 입력으로 OS 자격 저장소에 보관하거나 안전한 실행 환경에서 MCP 프로세스에 전달하십시오. 키를 명령행·요청·설정 JSON·저장소에 기록하지 마십시오. 호스트 또는 MCP를 재시작한 뒤, **Codex에서는 `/hooks`에서 새 Hook을 검토하고 신뢰를 승인하십시오.** [설치·키·등록 상세](docs/guide/ko.md#설치)를 참고하십시오.
36
+ 분류용 `OPENAI_API_KEY`는 `aptly set env OPENAI_API_KEY`의 숨김 입력으로 OS 자격 저장소에 보관하거나 안전한 실행 환경에서 MCP 프로세스에 전달하십시오. 키를 명령행·요청·설정 JSON·저장소에 기록하지 마십시오. 호스트 또는 MCP를 재시작한 뒤, **Codex에서는 `/hooks`에서 새 Hook을 검토하고 신뢰를 승인하십시오.** [설치·키·등록 상세](docs/guide/ko/installation.md#guide-installation)를 참고하십시오.
37
37
 
38
38
  ## 업데이트
39
39
 
40
- 기존 전역 npm 설치의 Aptly 0.1.3 이상을 업데이트하려면 관련 호스트·MCP·CLI 쓰기 프로세스를 모두 중지하고 [설치·업그레이드 안내](docs/guide/ko.md#설치)의 원장 전환 및 수동 대체 절차를 확인하십시오. 기존 키 설정은 유지하므로 다시 입력할 필요가 없습니다. 명령 실행 후 재시작하십시오.
40
+ 기존 전역 npm 설치의 Aptly 0.1.3 이상을 업데이트하려면 관련 호스트·MCP·CLI 쓰기 프로세스를 모두 중지하고 [설치·업그레이드 안내](docs/guide/ko/installation.md#guide-installation)의 원장 전환 및 수동 대체 절차를 확인하십시오. 기존 키 설정은 유지하므로 다시 입력할 필요가 없습니다. 명령 실행 후 재시작하십시오.
41
41
 
42
42
  ```sh
43
43
  aptly update
@@ -52,16 +52,16 @@ aptly setup --client all
52
52
  | 직접 추천 | `recommend_agent` 또는 `aptly recommend`로 프로필을 받고 호스트에서 명시적으로 실행합니다 |
53
53
  | fixture | 키·네트워크 없이 시험용 추천을 확인합니다. 실제 Decisions 결과가 아닙니다 |
54
54
 
55
- Aptly 0.1.4부터 상속 호출도 추천을 평가합니다. Codex의 적용은 명시적인 `fork_turns: "none"`, Claude Code는 이력 제약 없는 일반 호출로 제한하며 명시한 필드는 보존합니다. 추천·Hook 인자 변경·실제 자식 실행은 별개입니다. 적용 조건은 [가이드](docs/guide/ko.md#자동-hook)에서 확인하십시오.
55
+ Aptly 0.1.4부터 상속 호출도 추천을 평가합니다. Codex의 적용은 명시적인 `fork_turns: "none"`, Claude Code는 이력 제약 없는 일반 호출로 제한하며 명시한 필드는 보존합니다. 추천·Hook 인자 변경·실제 자식 실행은 별개입니다. 적용 조건은 [가이드](docs/guide/ko/routing.md#guide-automatic-routing)에서 확인하십시오.
56
56
 
57
57
  ## 문서
58
58
 
59
59
  - [사용 가이드](docs/guide/ko.md): 설치·제거, 키, Hook, 직접 추천, 오류 복구
60
- - [설치·제거](docs/guide/ko.md#설치) 및 [CLI 설정](docs/guide/ko.md#cli로-설정하기): npm 전역 설치, 호스트 등록, 재시작과 신뢰 승인
61
- - [모델과 환경변수](docs/guide/ko.md#모델과-환경변수): 여섯 기본 프로필과 후보 설정
62
- - [맥락 전달](docs/guide/ko.md#맥락-전달): 암호화된 메시지와 저장소 URL의 한계
63
- - [비용 실측](docs/guide/ko.md#비용-실측): README 번역 검토의 토큰·환산 비용과 측정 범위
64
- - [진단·개발](docs/guide/ko.md#진단과-개발): 로컬 진단 보고서와 무료 검증 명령
60
+ - [설치·제거](docs/guide/ko/installation.md#guide-installation) 및 [CLI 설정](docs/guide/ko/configuration.md#guide-cli-configuration): npm 전역 설치, 호스트 등록, 재시작과 신뢰 승인
61
+ - [모델과 환경변수](docs/guide/ko/configuration.md#guide-models-and-environment): 여섯 기본 프로필과 후보 설정
62
+ - [맥락 전달](docs/guide/ko/advanced.md#guide-context-delivery): 암호화된 메시지와 저장소 URL의 한계
63
+ - [비용 실측](docs/guide/ko/benchmarks.md#guide-cost-benchmarks): README 번역 검토의 토큰·환산 비용과 측정 범위
64
+ - [진단·개발](docs/guide/ko/advanced.md#guide-diagnostics-and-development): 로컬 진단 보고서와 무료 검증 명령
65
65
 
66
66
  한국어가 정본입니다. 영어·중국어 간체·일본어 문서는 같은 사용 범위를 설명하며, 문서 언어가 CLI·MCP 출력 언어를 바꾸지는 않습니다.
67
67
 
package/README.zh-CN.md CHANGED
@@ -16,7 +16,7 @@
16
16
 
17
17
  Aptly 使用 OpenAI Decisions API 对简要任务摘要进行分类,并推荐允许使用的执行配置。安装 Hook 后,可为未明确指定配置的新建通用子代理自动选择默认值。实际执行与权限决策仍由宿主(Claude Code 或 Codex)负责。
18
18
 
19
- 在我们的测试中,**API 折算成本降低了约 52%~58%**。详见[测试条件与详细结果](docs/guide/zh-CN.md#成本实测)。
19
+ 在我们的测试中,**API 折算成本降低了约 52%~58%**。详见[测试条件与详细结果](docs/guide/zh-CN/benchmarks.md#guide-cost-benchmarks)。
20
20
 
21
21
  ## 快速开始
22
22
 
@@ -29,15 +29,15 @@ aptly set env OPENAI_API_KEY
29
29
  aptly --version
30
30
  ```
31
31
 
32
- 请使用 `aptly --version` 确认已安装的版本。在支持此选项的 npm 中,`--allow-scripts=aptly` 允许执行 Aptly 的安装脚本。如果 npm 不支持此选项,请按照[安装指南](docs/guide/zh-CN.md#安装)中的显式安装与配置步骤操作。 从 Aptly 0.1.7 起,新注册不会自动传输;请通过 `aptly set default` 选择向 OpenAI Decisions API 传输的范围。
32
+ 请使用 `aptly --version` 确认已安装的版本。在支持此选项的 npm 中,`--allow-scripts=aptly` 允许执行 Aptly 的安装脚本。如果 npm 不支持此选项,请按照[安装指南](docs/guide/zh-CN/installation.md#guide-installation)中的显式安装与配置步骤操作。 从 Aptly 0.1.7 起,新注册不会自动传输;请通过 `aptly set default` 选择向 OpenAI Decisions API 传输的范围。
33
33
 
34
34
  安装时的 `postinstall` 会在现有宿主配置目录中注册 MCP 和 `PreToolUse` Hook。如果跳过了自动注册,或宿主尚无配置目录,也可以显式运行 `setup`。其他现有配置与 Hook,以及 Aptly 原有的启动命令和环境均会保留。
35
35
 
36
- 请通过 `aptly set env OPENAI_API_KEY` 的隐藏输入,将分类用的 `OPENAI_API_KEY` 存入系统凭据存储,或通过安全的运行环境传递给 MCP 进程。不要将密钥写入命令行、请求、配置 JSON 或代码仓库。重启宿主或 MCP 后,**请在 Codex 的 `/hooks` 中审核新 Hook 并批准信任**。详见[安装、密钥与注册](docs/guide/zh-CN.md#安装)。
36
+ 请通过 `aptly set env OPENAI_API_KEY` 的隐藏输入,将分类用的 `OPENAI_API_KEY` 存入系统凭据存储,或通过安全的运行环境传递给 MCP 进程。不要将密钥写入命令行、请求、配置 JSON 或代码仓库。重启宿主或 MCP 后,**请在 Codex 的 `/hooks` 中审核新 Hook 并批准信任**。详见[安装、密钥与注册](docs/guide/zh-CN/installation.md#guide-installation)。
37
37
 
38
38
  ## 更新
39
39
 
40
- 如需更新通过 npm 全局安装的 Aptly 0.1.3 或更高版本,请先停止所有相关宿主、MCP 和 CLI 写入进程,并查阅[安装与升级指南](docs/guide/zh-CN.md#安装)中的账本迁移和手动备用步骤。现有密钥设置会保留,无需重新输入密钥。执行命令后请重启。
40
+ 如需更新通过 npm 全局安装的 Aptly 0.1.3 或更高版本,请先停止所有相关宿主、MCP 和 CLI 写入进程,并查阅[安装与升级指南](docs/guide/zh-CN/installation.md#guide-installation)中的账本迁移和手动备用步骤。现有密钥设置会保留,无需重新输入密钥。执行命令后请重启。
41
41
 
42
42
  ```sh
43
43
  aptly update
@@ -52,16 +52,16 @@ aptly setup --client all
52
52
  | 直接推荐 | 通过 `recommend_agent` 或 `aptly recommend` 获取执行配置,再在宿主中明确选择并执行 |
53
53
  | fixture | 无需密钥或网络即可测试本地模拟推荐;结果并非实际 Decisions 判断 |
54
54
 
55
- Aptly 0.1.4 起也会为继承调用评估推荐。应用仍要求 Codex 显式指定 `fork_turns: "none"`,或 Claude Code 使用无历史约束的通用调用;已指定字段会保留。推荐、Hook 参数更新与实际子代理执行是不同事实。应用条件详见[指南](docs/guide/zh-CN.md#自动-hook)。
55
+ Aptly 0.1.4 起也会为继承调用评估推荐。应用仍要求 Codex 显式指定 `fork_turns: "none"`,或 Claude Code 使用无历史约束的通用调用;已指定字段会保留。推荐、Hook 参数更新与实际子代理执行是不同事实。应用条件详见[指南](docs/guide/zh-CN/routing.md#guide-automatic-routing)。
56
56
 
57
57
  ## 文档
58
58
 
59
59
  - [使用指南](docs/guide/zh-CN.md):安装与移除、密钥、Hook、直接推荐、错误恢复
60
- - [安装与移除](docs/guide/zh-CN.md#安装)及 [CLI 配置](docs/guide/zh-CN.md#使用-cli-设置):npm 全局安装、宿主注册、重启与信任批准
61
- - [模型与环境变量](docs/guide/zh-CN.md#模型与环境变量):六个默认配置与候选设置
62
- - [提供上下文](docs/guide/zh-CN.md#提供上下文):加密消息与仓库 URL 的限制
63
- - [成本实测](docs/guide/zh-CN.md#成本实测):README 翻译审阅的 token、换算成本与测量范围
64
- - [诊断与开发](docs/guide/zh-CN.md#诊断与开发):本地诊断报告与免费验证命令
60
+ - [安装与移除](docs/guide/zh-CN/installation.md#guide-installation)及 [CLI 配置](docs/guide/zh-CN/configuration.md#guide-cli-configuration):npm 全局安装、宿主注册、重启与信任批准
61
+ - [模型与环境变量](docs/guide/zh-CN/configuration.md#guide-models-and-environment):六个默认配置与候选设置
62
+ - [提供上下文](docs/guide/zh-CN/advanced.md#guide-context-delivery):加密消息与仓库 URL 的限制
63
+ - [成本实测](docs/guide/zh-CN/benchmarks.md#guide-cost-benchmarks):README 翻译审阅的 token、换算成本与测量范围
64
+ - [诊断与开发](docs/guide/zh-CN/advanced.md#guide-diagnostics-and-development):本地诊断报告与免费验证命令
65
65
 
66
66
  韩语文档为正本,英语、简体中文和日语文档与其保持相同的使用范围。选择文档语言不会改变 CLI 或 MCP 的输出语言。
67
67
 
@@ -0,0 +1,2 @@
1
+ #!/usr/bin/env node
2
+ export {};
@@ -0,0 +1,66 @@
1
+ #!/usr/bin/env node
2
+ // Internal command Hook. It never emits decisions/context, calls a provider or loads credentials.
3
+ import { readSync } from 'node:fs';
4
+ async function observe() {
5
+ try {
6
+ if (process.platform === 'win32')
7
+ return;
8
+ const args = process.argv.slice(2);
9
+ let client, policyPath;
10
+ const seen = new Set();
11
+ for (let n = 0; n < args.length; n += 2) {
12
+ const flag = args[n], value = args[n + 1];
13
+ if (seen.has(flag) || !value)
14
+ return;
15
+ seen.add(flag);
16
+ if (flag === '--client' && (value === 'codex' || value === 'claude'))
17
+ client = value;
18
+ else if (flag === '--policy-path')
19
+ policyPath = value;
20
+ else
21
+ return;
22
+ }
23
+ if (!client || !policyPath)
24
+ return;
25
+ const buffer = Buffer.alloc(65537);
26
+ let size = 0;
27
+ while (size < buffer.length) {
28
+ const count = readSync(0, buffer, size, buffer.length - size, null);
29
+ if (!count)
30
+ break;
31
+ size += count;
32
+ }
33
+ if (size > 65536)
34
+ return;
35
+ const event = JSON.parse(buffer.subarray(0, size).toString('utf8'));
36
+ if (!event || typeof event !== 'object' || Array.isArray(event))
37
+ return;
38
+ const value = event;
39
+ if (!['PostToolUse', 'SubagentStart', 'SubagentStop', 'PostModelRequest'].includes(String(value.hook_event_name)))
40
+ return;
41
+ if (value.hook_event_name === 'PostModelRequest' && typeof value.agent_id !== 'string')
42
+ return;
43
+ const { statisticsState } = await import('../src/statistics-policy.js');
44
+ const state = statisticsState(policyPath);
45
+ if (!state)
46
+ return;
47
+ const options = { stateDirectory: state };
48
+ const stats = await import('../src/statistics.js');
49
+ const config = stats.loadStatisticsConfig(options);
50
+ if (!config?.enabled_clients.includes(client))
51
+ return;
52
+ let bridge;
53
+ if (client === 'codex' && config.codex_native_metadata && config.codex_home && typeof value.agent_id === 'string' && typeof value.session_id === 'string') {
54
+ const hash = stats.loadStatisticsHash(options);
55
+ if (hash) {
56
+ const { resolveCodexStatisticsBridge } = await import('../src/statistics-codex.js');
57
+ const result = resolveCodexStatisticsBridge({ codexHome: config.codex_home, childId: value.agent_id, parentId: value.session_id, hash });
58
+ if (result.status === 'matched')
59
+ bridge = result;
60
+ }
61
+ }
62
+ stats.observeStatistics(options, { client, event: value }, bridge);
63
+ }
64
+ catch { /* Statistics never steer the host or expose raw errors. */ }
65
+ }
66
+ await observe();
package/dist/bin/aptly.js CHANGED
@@ -10,13 +10,14 @@ import { exportDiagnosticReport } from '../src/report.js';
10
10
  import { fetchModelInfo, saveModelInfo } from '../src/model-info.js';
11
11
  import { errorCode } from '../src/types.js';
12
12
  import { budgetErrorDetails } from '../src/budget.js';
13
- import { checkSetup, setupHosts, removeSetup, setDefaults, setEnvironment, configurableEnvironmentKeys, migrateLauncher, setTransmission, showTransmission, showBudgetStatus } from '../src/setup.js';
14
- import { readEnvironmentValue, readTransmissionChoice } from '../src/cli-input.js';
13
+ import { checkSetup, setupHosts, removeSetup, setDefaults, setEnvironment, configurableEnvironmentKeys, migrateLauncher, setPolicySource, setTransmission, showTransmission, showBudgetStatus, showStatistics, setStatisticsCollection } from '../src/setup.js';
14
+ import { readEnvironmentValue } from '../src/cli-input.js';
15
15
  import { prepareApiKey } from '../src/credential-setup.js';
16
16
  import { linuxStoreReadiness } from '../src/linux-store-readiness.js';
17
17
  import { updateGlobalInstallation } from '../src/update.js';
18
18
  import { updateNotification } from '../src/update-notifier.js';
19
19
  import { resolveCliHelp } from '../src/cli-help.js';
20
+ import { runTransmissionReview, reviewAfterSetup } from '../src/transmission-review-cli.js';
20
21
  const [command = 'serve', ...args] = process.argv.slice(2);
21
22
  const output = (value) => process.stdout.write(JSON.stringify(value, null, 2) + '\n');
22
23
  let helpHandled = false;
@@ -36,9 +37,48 @@ try {
36
37
  throw new Error('update_invalid_options');
37
38
  const packageRoot = fileURLToPath(new URL(import.meta.url.endsWith('.ts') ? '../' : '../../', import.meta.url));
38
39
  const result = updateGlobalInstallation({ packageRoot });
39
- output(result);
40
+ output(result.status === 'complete' ? { ...result, next_steps: ['aptly setup', 'aptly set transmission --review'] } : result);
40
41
  if (result.status === 'error')
41
42
  process.exitCode = 1;
43
+ else if (process.stderr.isTTY && !process.env.CI)
44
+ process.stderr.write('Run aptly setup after updating; its first interactive run reviews transmission scope. Use aptly set transmission --review for an explicit review, then restart MCP.\n');
45
+ }
46
+ else if (command === 'stats') {
47
+ let action, start = 0;
48
+ if (args[0] === 'enable' || args[0] === 'disable') {
49
+ action = args[0];
50
+ start = 1;
51
+ }
52
+ let clients = ['codex', 'claude'];
53
+ let today = false, native = false;
54
+ const seen = new Set();
55
+ for (let n = start; n < args.length; n++) {
56
+ const flag = args[n];
57
+ if (seen.has(flag))
58
+ throw new Error('statistics_invalid_options');
59
+ seen.add(flag);
60
+ if (flag === '--today' && !action) {
61
+ today = true;
62
+ continue;
63
+ }
64
+ if (flag === '--codex-native-metadata' && action === 'enable') {
65
+ native = true;
66
+ continue;
67
+ }
68
+ if (flag === '--client' && ['codex', 'claude', 'all'].includes(args[n + 1])) {
69
+ const v = args[++n];
70
+ clients = v === 'all' ? ['codex', 'claude'] : [v];
71
+ continue;
72
+ }
73
+ throw new Error('statistics_invalid_options');
74
+ }
75
+ if (native && !clients.includes('codex'))
76
+ throw new Error('statistics_invalid_options');
77
+ const packageRoot = fileURLToPath(new URL(import.meta.url.endsWith('.ts') ? '../' : '../../', import.meta.url));
78
+ const result = action ? setStatisticsCollection(action === 'enable', { clients, packageRoot, ...(native ? { codexNativeMetadata: true } : {}) }) : showStatistics({ clients }, today);
79
+ output(result);
80
+ if ('status' in result && result.status === 'partial')
81
+ process.exitCode = 1;
42
82
  }
43
83
  else if (command === 'budget') {
44
84
  if (args[0] !== 'status')
@@ -73,7 +113,7 @@ try {
73
113
  else if (command === 'set') {
74
114
  if (args[0] === 'transmission') {
75
115
  const scope = args[1];
76
- if (!['none', 'description', 'excerpt', '--show'].includes(scope))
116
+ if (!['none', 'description', 'excerpt', '--show', '--review'].includes(scope))
77
117
  throw new Error('set_invalid_options');
78
118
  let clients = ['codex', 'claude'];
79
119
  if (args.length !== 2) {
@@ -82,7 +122,7 @@ try {
82
122
  clients = args[3] === 'all' ? ['codex', 'claude'] : [args[3]];
83
123
  }
84
124
  const packageRoot = fileURLToPath(new URL(import.meta.url.endsWith('.ts') ? '../' : '../../', import.meta.url));
85
- const result = scope === '--show' ? showTransmission({ clients }) : setTransmission(scope, { clients, packageRoot });
125
+ const result = scope === '--show' ? showTransmission({ clients }) : scope === '--review' ? await runTransmissionReview({ clients, packageRoot }, true) : setTransmission(scope, { clients, packageRoot });
86
126
  output(result);
87
127
  if ('status' in result && result.status === 'partial')
88
128
  process.exitCode = 1;
@@ -146,14 +186,8 @@ try {
146
186
  if (action === 'env')
147
187
  value = await readEnvironmentValue({ key: key, fromStdin });
148
188
  let result = action === 'default' ? setDefaults({ clients, packageRoot }) : key === 'OPENAI_API_KEY' ? credential.apply(value) : setEnvironment(key, value, { clients, packageRoot });
149
- if (action === 'default' && result.status === 'complete' && process.stdin.isTTY && process.stdout.isTTY) {
150
- const pending = result.clients.filter(client => client.transmission === 'unselected').map(client => client.client);
151
- if (pending.length) {
152
- const scope = await readTransmissionChoice();
153
- const selected = setTransmission(scope, { clients: pending, packageRoot, selectUnselectedOnly: true });
154
- result = { status: selected.status, clients: result.clients.map(client => selected.clients.find(item => item.client === client.client) ?? client) };
155
- }
156
- }
189
+ if (action === 'default')
190
+ result = await reviewAfterSetup(result, { clients, packageRoot });
157
191
  output(result);
158
192
  if (result.status === 'partial')
159
193
  process.exitCode = 1;
@@ -172,6 +206,7 @@ try {
172
206
  let migrate = false;
173
207
  let dryRun = false;
174
208
  let includeExisting = false;
209
+ let policySource = false;
175
210
  const seen = new Set();
176
211
  for (let i = 0; i < args.length; i++) {
177
212
  const flag = args[i];
@@ -201,6 +236,8 @@ try {
201
236
  const value = args[++i];
202
237
  if (flag === '--client' && ['codex', 'claude', 'all'].includes(value))
203
238
  clients = value === 'all' ? ['codex', 'claude'] : [value];
239
+ else if (flag === '--policy-source' && command === 'setup' && value === 'codex-home')
240
+ policySource = true;
204
241
  else if (flag === '--transmission' && command === 'setup' && ['none', 'description', 'excerpt'].includes(value))
205
242
  transmission = value;
206
243
  else if (flag === '--mode' && command === 'setup' && ['defaults', 'advisory'].includes(value))
@@ -209,10 +246,14 @@ try {
209
246
  throw new Error('setup_invalid_options');
210
247
  }
211
248
  const packageRoot = fileURLToPath(new URL(import.meta.url.endsWith('.ts') ? '../' : '../../', import.meta.url));
212
- if ((check && [...seen].some(flag => !['--check', '--client'].includes(flag))) || (migrate && (clients.length !== 1 || automatic || seen.has('--mode') || seen.has('--transmission'))) || ((dryRun || includeExisting) && !migrate))
249
+ if ((check && [...seen].some(flag => !['--check', '--client'].includes(flag))) || (migrate && (clients.length !== 1 || automatic || seen.has('--mode') || seen.has('--transmission'))) || (policySource && (clients.length !== 1 || clients[0] !== 'codex' || [...seen].some(flag => !['--client', '--policy-source', '--dry-run'].includes(flag)))) || (dryRun && !migrate && !policySource) || (includeExisting && !migrate))
213
250
  throw new Error('setup_invalid_options');
214
- const result = check ? checkSetup({ clients, packageRoot }) : migrate ? migrateLauncher({ clients, packageRoot }, dryRun, includeExisting) : command === 'setup' ? setupHosts({ clients, mode, automatic, packageRoot, transmission }) : removeSetup({ clients });
251
+ let result = policySource ? setPolicySource({ clients, packageRoot }, dryRun) : check ? checkSetup({ clients, packageRoot }) : migrate ? migrateLauncher({ clients, packageRoot }, dryRun, includeExisting) : command === 'setup' ? setupHosts({ clients, mode, automatic, packageRoot, transmission }) : removeSetup({ clients });
252
+ if (command === 'setup' && !check && !migrate && !policySource && !automatic && transmission === undefined)
253
+ result = await reviewAfterSetup(result, { clients, packageRoot });
215
254
  output(result);
255
+ if (command === 'setup' && automatic && result.status === 'complete' && result.clients.some(client => client.transmission_review === 'required'))
256
+ process.stderr.write('Aptly transmission review pending. Run aptly set transmission --review in the intended host environment. No transmission choice was made by installation.\n');
216
257
  if (result.status === 'partial' && !automatic)
217
258
  process.exitCode = 1;
218
259
  }
@@ -261,13 +302,14 @@ catch (error) {
261
302
  const budgetCode = [caughtCode, message].find(value => typeof value === 'string' && ['invalid_budget_configuration', 'budget_invalid_options'].includes(value));
262
303
  const configCode = [caughtCode, message].find(value => typeof value === 'string' && safeConfigurationCodes.includes(value));
263
304
  const setCodes = ['set_environment_key_unsupported', 'set_invalid_options', 'set_value_too_large', 'set_interactive_input_required', 'set_input_cancelled'];
264
- const code = command === 'update' ? (message === 'update_invalid_options' ? message : 'update_failed') : command === 'set' ? (setCodes.includes(message ?? '') ? message : 'set_failed') : command === 'report' ? (caughtCode && codes.includes(caughtCode) ? caughtCode : 'report_failed') : budgetCode ?? configCode ?? 'operation_failed';
305
+ const inputCode = ['set_input_cancelled', 'set_interactive_input_required'].includes(message ?? '') ? message : undefined;
306
+ const code = command === 'stats' ? 'statistics_invalid_options' : command === 'update' ? (message === 'update_invalid_options' ? message : 'update_failed') : command === 'set' ? (setCodes.includes(message ?? '') ? message : 'set_failed') : command === 'report' ? (caughtCode && codes.includes(caughtCode) ? caughtCode : 'report_failed') : inputCode ?? budgetCode ?? configCode ?? 'operation_failed';
265
307
  const budgetDetails = budgetErrorDetails(error);
266
308
  process.stderr.write('aptly: ' + code + (budgetDetails.invalid_budget_keys?.length ? ' [' + budgetDetails.invalid_budget_keys.join(', ') + ']' : '') + (budgetDetails.budget_error ? ' (' + budgetDetails.budget_error + ')' : '') + '\n');
267
309
  process.exitCode = 1;
268
310
  }
269
311
  finally {
270
- if (!process.exitCode && !helpHandled) {
312
+ if (!process.exitCode && !helpHandled && command !== 'stats') {
271
313
  try {
272
314
  const hint = await updateNotification({ command, args, env: process.env, stdinIsTTY: !!process.stdin.isTTY, stderrIsTTY: !!process.stderr.isTTY, stdoutIsTTY: !!process.stdout.isTTY, currentVersion: VERSION });
273
315
  if (hint)
@@ -3,7 +3,7 @@ import { budgetEnvironmentDefaults } from './budget.js';
3
3
  const client = ['codex', 'claude', 'all'];
4
4
  const scope = ['none', 'description', 'excerpt'];
5
5
  const entries = {
6
- '': { usage: 'aptly <command> [options]', description: 'Aptly — subagent profile recommendations\n\nCommands:\n serve Start the stdio MCP server.\n capabilities Print catalog and local limits without an API call.\n catalog [refresh] Inspect the catalog or refresh official model descriptions.\n recommend Read task JSON from stdin and return advice.\n inspect CLIENT FILE Inspect an explicit settings inventory.\n config CLIENT Print an MCP registration fragment.\n set default Fill missing settings; select transmission scope interactively.\n set env ENV_KEY Set a supported environment value.\n set transmission Select or show Decisions API transmission scope.\n budget status Inspect local budget limits and usage.\n setup Register MCP and PreToolUse Hooks.\n remove Remove unchanged Aptly-owned registration.\n update Update a verified global npm installation.\n report Write redacted local diagnostic attachments.\n\nGlobal options:\n --help, -h Show help without executing a command.\n --version Print the package version.\n\nUse aptly COMMAND --help or aptly help COMMAND for details.', options: { '--version': true } },
6
+ '': { usage: 'aptly <command> [options]', description: 'Aptly — subagent profile recommendations\n\nCommands:\n serve Start the stdio MCP server.\n capabilities Print catalog and local limits without an API call.\n catalog [refresh] Inspect the catalog or refresh official model descriptions.\n recommend Read task JSON from stdin and return advice.\n inspect CLIENT FILE Inspect an explicit settings inventory.\n config CLIENT Print an MCP registration fragment.\n set default Fill missing settings; review transmission scope interactively.\n set env ENV_KEY Set a supported environment value.\n set transmission Select, review or show Decisions API transmission scope.\n budget status Inspect local budget limits and usage.\n stats [enable|disable] Inspect or control opt-in local execution statistics.\n setup Register MCP and PreToolUse Hooks.\n remove Remove unchanged Aptly-owned registration.\n update Update a verified global npm installation.\n report Write redacted local diagnostic attachments.\n\nGlobal options:\n --help, -h Show help without executing a command.\n --version Print the package version.\n\nUse aptly COMMAND --help or aptly help COMMAND for details.', options: { '--version': true } },
7
7
  serve: { usage: 'aptly serve', description: 'Start the stdio MCP server (default: fixture/shadow).\nDecisions mode requires ROUTER_PROVIDER=decisions, an absolute private ROUTER_LEDGER_PATH and a configured API key. Use aptly set env OPENAI_API_KEY for OS credential storage. Never put keys in request JSON or command arguments.' },
8
8
  capabilities: { usage: 'aptly capabilities', description: 'Print the active catalog, local limits and configuration metadata. No classification API call. Reads runtime configuration and credential availability; help does neither.' },
9
9
  catalog: { usage: 'aptly catalog\n aptly catalog refresh --output ABS_PATH', description: 'Print the active catalog without classification. Refresh is a separate explicit network operation; use aptly catalog refresh --help.' },
@@ -11,15 +11,18 @@ const entries = {
11
11
  recommend: { usage: 'aptly recommend < request.json', description: 'Read request JSON from stdin. Required: request_id, client (codex|claude), task {summary, operation, context_sufficient}.\nOptional: eligible_profile_ids and caller-declared constraints. Results are advisory_only; no host settings are inspected or changed. Permissions and history remain with the host. Decisions mode may make a paid classification.\nExamples: examples/recommend.codex.json and examples/recommend.claude.json.' },
12
12
  inspect: { usage: 'aptly inspect codex|claude FILE', description: 'Read an explicit JSON settings inventory and explain precedence. Does not discover the running host or call an API.', positional: ['client', 'file'] },
13
13
  config: { usage: 'aptly config codex|claude', description: 'Print a registration fragment only. Does not edit host configuration or classify. Preserve existing launchers and merge settings as described in the guide.', positional: ['client'] },
14
- set: { usage: 'aptly set default [--client codex|claude|all]\n aptly set env ENV_KEY [--client codex|claude|all] [--stdin | --check]\n aptly set transmission none|description|excerpt [--client codex|claude|all]\n aptly set transmission --show [--client codex|claude|all]', description: 'Set operator-controlled defaults, environment values or transmission scope. Use the subcommand help for input, preservation and restart details.' },
15
- 'set default': { usage: 'aptly set default [--client codex|claude|all]', description: 'Fill missing MCP environment defaults for both clients by default. Preserve existing values, inherited budget bindings and launchers. Does not reset budget usage or caches. Interactive runs ask only for unselected transmission scope (Enter: none); noninteractive runs do not opt in. Restart MCP after changes.', options: { '--client': client } },
14
+ set: { usage: 'aptly set default [--client codex|claude|all]\n aptly set env ENV_KEY [--client codex|claude|all] [--stdin | --check]\n aptly set transmission none|description|excerpt [--client codex|claude|all]\n aptly set transmission --show [--client codex|claude|all]\n aptly set transmission --review [--client codex|claude|all]', description: 'Set operator-controlled defaults, environment values or transmission scope. Use the subcommand help for input, preservation and restart details.' },
15
+ 'set default': { usage: 'aptly set default [--client codex|claude|all]', description: 'Fill missing MCP environment defaults for both clients by default. Preserve existing values, inherited budget bindings and launchers. Does not reset budget usage or caches. Eligible interactive runs review each client/home once, including existing scopes. Excerpt is recommended; Enter keeps configured choices and sets unselected to none. Noninteractive, CI and lifecycle runs do not opt in. Prompts use stderr; stdout remains JSON. Restart MCP after changes.', options: { '--client': client } },
16
16
  'set env': { usage: 'aptly set env ENV_KEY [--client codex|claude|all] [--stdin | --check]', description: 'Set a supported value using hidden input; --stdin explicitly reads standard input. --client defaults to all. --check is only for OPENAI_API_KEY and checks registration and Linux store readiness without reading/storing a key.\nOPENAI_API_KEY uses OS credential storage; host files contain references only. Values are never accepted as command arguments. Existing launchers are preserved. Restart MCP after changes.\nBudget defaults: ' + Object.entries(budgetEnvironmentDefaults).map(([key, value]) => key + '=' + value).join(', ') + '. Only literal 0 disables a ceiling; the per-call rate stays positive.\nSupported environment keys: $ENV_KEYS', options: { '--client': client, '--stdin': true, '--check': true }, positional: ['environment'] },
17
- 'set transmission': { usage: 'aptly set transmission none|description|excerpt [--client codex|claude|all]\n aptly set transmission --show [--client codex|claude|all]', description: 'Control automatic task-data transmission to OpenAI Decisions, not developer telemetry. none disables automatic transmission; description permits caller-provided descriptions only; excerpt permits native excerpts. Direct recommendations remain separate explicit requests. --show reads redacted registration state. Restart MCP after changes.', options: { '--client': client, '--show': true }, positional: ['scope'] },
17
+ 'set transmission': { usage: 'aptly set transmission none|description|excerpt [--client codex|claude|all]\n aptly set transmission --show [--client codex|claude|all]\n aptly set transmission --review [--client codex|claude|all]', description: 'Control automatic task-data transmission to OpenAI Decisions, not developer telemetry. none disables automatic transmission; description permits caller-provided descriptions only; excerpt permits native excerpts. Direct recommendations remain separate explicit requests. --show reads redacted registration/review state. --review explicitly asks again for configured clients; requires eligible interactive terminal streams and never repairs missing setup. Enter keeps each existing scope and selects none for unselected clients; excerpt is recommended, not the Enter default. Review completion is remembered per client/home, independently of package version, mode or statistics. Restart MCP after changes.', options: { '--client': client, '--show': true, '--review': true }, positional: ['scope'] },
18
+ stats: { usage: 'aptly stats [--client codex|claude|all] [--today]\n aptly stats enable [--client codex|claude|all] [--codex-native-metadata]\n aptly stats disable [--client codex|claude|all]', description: 'Read retained local execution statistics without provider, credential or network access, state creation or update notification. Collection is disabled by default. --today uses UTC binding creation, not completion time. Model matches are host-reported model evidence, not user consent, quality, effective effort or billing. Aliases without canonical evidence remain unknown.', options: { '--client': client, '--today': true } },
19
+ 'stats enable': { usage: 'aptly stats enable [--client codex|claude|all] [--codex-native-metadata]', description: 'Explicitly register local statistics observers and enable collection after existing Aptly setup. Initial support is POSIX only. Preserve routing, credentials, budget ledger, custom launchers and Hooks. Restart MCP/host and review new Codex Hooks with /hooks; trust is never written automatically. --codex-native-metadata additionally permits exact-child native SQLite metadata reads; existing SHM read marks may change, no row/schema writes or new sidecar files are intended. Unsupported/ambiguous evidence remains unknown.', options: { '--client': client, '--codex-native-metadata': true } },
20
+ 'stats disable': { usage: 'aptly stats disable [--client codex|claude|all]', description: 'Disable Aptly collection and remove unchanged product-owned observer definitions. Preserve statistics/key/history, custom or modified observers and all routing settings. Retained modified definitions are reported for local review.', options: { '--client': client } },
18
21
  budget: { usage: 'aptly budget status [--client codex|claude|all]', description: 'Inspect local per-ledger budget limits and reserved usage. No reset/refill command is provided.' },
19
22
  'budget status': { usage: 'aptly budget status [--client codex|claude|all]', description: 'Read registered host budget settings and ledger metadata; defaults to both clients. No credentials, provider calls, configuration writes or ledger/gate initialization.\nLiteral 0 ceilings display Unlimited; reservations are not OpenAI billing. This is a registration/permitted-environment snapshot, not verification of running custom launchers. An existing gate is held briefly and can be busy.', options: { '--client': client } },
20
- setup: { usage: 'aptly setup [--client codex|claude|all] [--mode defaults|advisory] [--transmission none|description|excerpt] [--automatic]\n aptly setup --check [--client codex|claude|all]\n aptly setup --client codex|claude --migrate-launcher [--include-existing] [--dry-run]', description: 'Register MCP and PreToolUse Hooks while preserving unrelated settings and existing launchers. Omitted --mode preserves an existing mode; a new policy defaults to defaults. New transmission remains unselected unless explicitly chosen.\n--check snapshots the normal setup plan without writing; only --client may be combined with it. It does not verify a running host.\n--automatic skips CI, APTLY_SKIP_SETUP=1 and absent host directories.\n--migrate-launcher reviews a single owned standard launcher; --include-existing explicitly includes an eligible preserved registration. --dry-run validates migration without writing. Do not combine migration with --automatic, --mode or --transmission. --include-existing and --dry-run require --migrate-launcher.\nNo keys are stored. Restart the host/MCP; Codex requires native /hooks trust review.', options: { '--client': client, '--mode': ['defaults', 'advisory'], '--transmission': scope, '--automatic': true, '--check': true, '--migrate-launcher': true, '--include-existing': true, '--dry-run': true } },
23
+ setup: { usage: 'aptly setup [--client codex|claude|all] [--mode defaults|advisory] [--transmission none|description|excerpt] [--automatic]\n aptly setup --check [--client codex|claude|all]\n aptly setup --client codex|claude --migrate-launcher [--include-existing] [--dry-run]\n aptly setup --client codex --policy-source codex-home [--dry-run]', description: 'Register MCP and PreToolUse Hooks while preserving unrelated settings and existing launchers. Omitted --mode preserves an existing mode; a new policy defaults to defaults. New transmission remains unselected unless explicitly chosen.\n--check snapshots the normal setup plan without writing; only --client may be combined with it. It does not verify a running host.\n--automatic skips CI, APTLY_SKIP_SETUP=1 and absent host directories.\n--migrate-launcher reviews a single owned standard launcher; --include-existing explicitly includes an eligible preserved registration. --dry-run validates migration without writing. Do not combine migration with --automatic, --mode or --transmission. --include-existing requires --migrate-launcher. --policy-source codex-home explicitly binds an existing owned Codex setup to the runtime CODEX_HOME using a reserved selector and forwarded CODEX_HOME; it preserves policy, ledger and statistics state. CODEX_HOME must be explicitly set to an absolute directory at migration and server startup, including the default home; missing values fail closed. Use it in the canonical registration and intended account homes when a manager mirrors MCP tables. --dry-run validates either migration without writing. Policy-source migration requires --client codex and cannot combine with other setup actions. Upgrade all MCP backends first; restart MCP afterward.\nOrdinary interactive setup reviews unreviewed transmission choices, including existing registrations; Enter keeps configured scopes or selects none for unselected clients. --automatic, --check and launcher migration never prompt. Explicit --transmission records that choice without asking. No keys are stored. Restart the host/MCP; Codex requires native /hooks trust review.', options: { '--client': client, '--mode': ['defaults', 'advisory'], '--transmission': scope, '--automatic': true, '--check': true, '--migrate-launcher': true, '--policy-source': ['codex-home'], '--include-existing': true, '--dry-run': true } },
21
24
  remove: { usage: 'aptly remove [--client codex|claude|all]', description: 'Remove only unchanged Aptly-owned registration for both clients by default. Preserve modified/user-owned entries, keys and ledger history. Restart host/MCP after removal.', options: { '--client': client } },
22
- update: { usage: 'aptly update', description: 'Update this verified global npm installation within the same prefix. Stop other hosts/MCP/CLI writers first. Local/source/unverified installations are rejected. Lifecycle setup is not run: run aptly setup and restart hosts afterward. Existing launchers and keys are preserved.' },
25
+ update: { usage: 'aptly update', description: 'Update this verified global npm installation within the same prefix. Stop other hosts/MCP/CLI writers first. Local/source/unverified installations are rejected. Lifecycle setup is not run: run aptly setup and restart hosts afterward. Existing launchers and keys are preserved. Update does not run setup or a new CLI process: next interactive setup/set default reviews pending transmission choices; use aptly set transmission --review for an explicit review. The first upgrade from older code requires a subsequent setup/default command to load this behavior.' },
23
26
  report: { usage: 'aptly report [--format md|json|both] [--output-dir DIR]', description: 'Write redacted local diagnostic attachments. Default format: both; directory: reports. No uploads or classification API probes. Review attachments before sharing.', options: { '--format': ['md', 'json', 'both'], '--output-dir': 'path' } },
24
27
  };
25
28
  const helpFlag = (value) => value === '--help' || value === '-h';
@@ -35,7 +38,7 @@ export function resolveCliHelp(argv, { environmentKeys = [] } = {}) {
35
38
  return { kind: 'error', code: 'invalid_help_options' };
36
39
  path = clean[0];
37
40
  count = 1;
38
- if (['set', 'catalog', 'budget'].includes(path) && clean[1] && Object.hasOwn(entries, path + ' ' + clean[1])) {
41
+ if (['set', 'catalog', 'budget', 'stats'].includes(path) && clean[1] && Object.hasOwn(entries, path + ' ' + clean[1])) {
39
42
  path += ' ' + clean[1];
40
43
  count = 2;
41
44
  }
@@ -58,7 +61,7 @@ export function resolveCliHelp(argv, { environmentKeys = [] } = {}) {
58
61
  if (token.startsWith('-') && !filePosition) {
59
62
  if (!Object.hasOwn(options, token) || seen.has(token))
60
63
  return { kind: 'error', code: 'invalid_help_options' };
61
- if (path === 'set transmission' && token === '--show' && (seen.size || positionals.length))
64
+ if (path === 'set transmission' && ['--show', '--review'].includes(token) && (seen.size || positionals.length))
62
65
  return { kind: 'error', code: 'invalid_help_options' };
63
66
  seen.add(token);
64
67
  const type = options[token];
@@ -86,13 +89,17 @@ export function resolveCliHelp(argv, { environmentKeys = [] } = {}) {
86
89
  }
87
90
  if (path === 'set env' && seen.has('--check') && (seen.has('--stdin') || (positionals[0] !== undefined && positionals[0] !== 'OPENAI_API_KEY')))
88
91
  return { kind: 'error', code: 'invalid_help_options' };
89
- if (path === 'set transmission' && seen.has('--show') && positionals.length)
92
+ if (path === 'set transmission' && (seen.has('--show') || seen.has('--review')) && positionals.length)
93
+ return { kind: 'error', code: 'invalid_help_options' };
94
+ if (path === 'stats enable' && seen.has('--codex-native-metadata') && values.get('--client') === 'claude')
90
95
  return { kind: 'error', code: 'invalid_help_options' };
91
96
  if (path === 'setup') {
92
- const migrate = seen.has('--migrate-launcher');
97
+ const migrate = seen.has('--migrate-launcher'), policySource = seen.has('--policy-source');
93
98
  if (seen.has('--check') && [...seen].some(flag => !['--check', '--client'].includes(flag)))
94
99
  return { kind: 'error', code: 'invalid_help_options' };
95
- if ((seen.has('--dry-run') || seen.has('--include-existing')) && !migrate)
100
+ if ((seen.has('--dry-run') && !migrate && !policySource) || (seen.has('--include-existing') && !migrate))
101
+ return { kind: 'error', code: 'invalid_help_options' };
102
+ if (policySource && (values.get('--client') !== 'codex' || [...seen].some(flag => !['--client', '--policy-source', '--dry-run'].includes(flag))))
96
103
  return { kind: 'error', code: 'invalid_help_options' };
97
104
  if (migrate && (seen.has('--automatic') || seen.has('--mode') || seen.has('--transmission') || values.get('--client') === 'all'))
98
105
  return { kind: 'error', code: 'invalid_help_options' };
@@ -3,5 +3,23 @@ export declare function readEnvironmentValue({ key, fromStdin }: {
3
3
  key: string;
4
4
  fromStdin?: boolean;
5
5
  }): Promise<string>;
6
- /** Operator choice of external transmission scope; Enter selects no automatic transmission. */
6
+ export type TransmissionReviewChoice = 'keep' | 'none' | 'description' | 'excerpt';
7
+ export interface TransmissionPromptCandidate {
8
+ client: 'codex' | 'claude';
9
+ transmission: 'none' | 'description' | 'excerpt' | 'unselected';
10
+ transmission_source: 'legacy' | 'explicit' | 'unselected';
11
+ selected_home_source: 'default' | 'override';
12
+ application_mode: 'defaults' | 'advisory';
13
+ enabled: boolean;
14
+ }
15
+ /** Lifecycle, CI and redirected output are never interactive consent. */
16
+ export declare function canPromptTransmission({ env, stdinIsTTY, stdoutIsTTY, stderrIsTTY }?: {
17
+ env?: NodeJS.ProcessEnv;
18
+ stdinIsTTY?: boolean;
19
+ stdoutIsTTY?: boolean;
20
+ stderrIsTTY?: boolean;
21
+ }): boolean;
22
+ /** Read one actual operator answer. Prompts/terminal echo stay on stderr, JSON on stdout. */
23
+ export declare function readTransmissionReviewChoice(candidates: readonly TransmissionPromptCandidate[]): Promise<TransmissionReviewChoice>;
24
+ /** Compatibility for the former initial-only input helper. */
7
25
  export declare function readTransmissionChoice(): Promise<'none' | 'description' | 'excerpt'>;