@thinkingai/ae-cli 6.0.55 → 6.0.57

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 (169) hide show
  1. package/README.md +35 -6
  2. package/README.zh.md +35 -6
  3. package/bin/ae-cli.js +5 -0
  4. package/bin/runtime-capabilities.json +5 -0
  5. package/cli-installation-guide.md +24 -3
  6. package/dist/{auth-RQBO6MTY.js → auth-YEIJLBFY.js} +61 -19
  7. package/dist/{automation-VAAQBM7Y.js → automation-NAR5DDGL.js} +94 -38
  8. package/dist/{capability-JRIFC4AJ.js → capability-P7DD4Q73.js} +50 -21
  9. package/dist/{chunk-5XJYLEVC.js → chunk-72NJKS7O.js} +4 -4
  10. package/dist/chunk-752BSLZC.js +222 -0
  11. package/dist/{chunk-RGYPSEYD.js → chunk-7ABK2PEJ.js} +3 -3
  12. package/dist/{chunk-Q5US7JC5.js → chunk-7JAVT5TK.js} +3 -3
  13. package/dist/{chunk-GHXZK54S.js → chunk-H3K5UGYC.js} +41 -13
  14. package/dist/{chunk-OP44TT4H.js → chunk-IN7KKL6K.js} +4 -2
  15. package/dist/{chunk-VZZNLV3I.js → chunk-JCWM2TYP.js} +61 -15
  16. package/dist/{chunk-S6M42KND.js → chunk-JEUXDY3B.js} +1 -1
  17. package/dist/{chunk-ZL7SGNIA.js → chunk-JNVVJ273.js} +58 -46
  18. package/dist/chunk-N6XBLRB7.js +105 -0
  19. package/dist/{chunk-AP7YP2NX.js → chunk-OAWPT7VP.js} +2 -2
  20. package/dist/{chunk-7KU2WNQE.js → chunk-QEMQKVHW.js} +37 -15
  21. package/dist/{chunk-CT7QDJS6.js → chunk-QVRIDN42.js} +2 -2
  22. package/dist/{chunk-RPBOAQQQ.js → chunk-QZUVLFNR.js} +1 -1
  23. package/dist/{chunk-3YVEAZUN.js → chunk-RJHGDWSC.js} +32 -21
  24. package/dist/{chunk-374V5R6N.js → chunk-TKVVACEJ.js} +6 -4
  25. package/dist/chunk-TULINOLS.js +2283 -0
  26. package/dist/chunk-YVG6QD3V.js +233 -0
  27. package/dist/{chunk-WNGFSIOB.js → chunk-Z3Q2AEIN.js} +237 -86
  28. package/dist/chunk-ZGIYG473.js +132 -0
  29. package/dist/{community-report-client-PEERQCX2.js → community-report-client-TJVCLZ3K.js} +1 -1
  30. package/dist/compat-check-PMEGUPZU.js +32 -0
  31. package/dist/{config-SICKWZ2A.js → config-VWVPR4WW.js} +43 -10
  32. package/dist/{context-NGVFPCBK.js → context-F6FCGTF3.js} +4 -4
  33. package/dist/{data-integration-BCLQFTGU.js → data-integration-6UAZO4GG.js} +207 -24
  34. package/dist/evaluation-4LO2O4AF.js +3714 -0
  35. package/dist/index.js +343 -79
  36. package/dist/{local-data-upload-client-TWMHFLUA.js → local-data-upload-client-KCMG6J62.js} +1 -1
  37. package/dist/{memory-CQKH2JAV.js → memory-HHPX3NF2.js} +6 -6
  38. package/dist/{metadata-EMFGUI2W.js → metadata-HEQQEEG3.js} +17 -9
  39. package/dist/{model-VX5M2CJ6.js → model-7UHGWYVR.js} +4 -4
  40. package/dist/{personal-semantic-preference-SLWVVYZ4.js → personal-semantic-preference-V4L6ZWR2.js} +7 -6
  41. package/dist/{project-semantic-DPSZBKQD.js → project-semantic-NKHKJX6M.js} +7 -6
  42. package/dist/{sync-RZIAV37C.js → sync-ZJMXCRIN.js} +8 -7
  43. package/dist/{te-agent-AORRE2FM.js → te-agent-WBKIFEQD.js} +757 -94
  44. package/dist/{te-analysis-ISXKJKRT.js → te-analysis-ADX7RKO4.js} +578 -94
  45. package/dist/{te-community-42M7ICDO.js → te-community-PREDRXG3.js} +722 -228
  46. package/dist/{te-dataops-BNKNZ4F2.js → te-dataops-ITWJHO2U.js} +9 -6
  47. package/dist/{te-engage-BZE3MBKT.js → te-engage-VE2NUH5V.js} +7 -6
  48. package/dist/{te-kb-ULATOTQ3.js → te-kb-WSMOW7WS.js} +407 -83
  49. package/dist/{te-system-UGHVKBVV.js → te-system-YM657FKO.js} +6 -6
  50. package/dist/{te-team-YA6SNOJ3.js → te-team-T2WRLOOD.js} +64 -41
  51. package/dist/{things-DTCOQIQB.js → things-6QOMFXOG.js} +7 -7
  52. package/dist/{update-ESNYKUVR.js → update-I4MOUYOX.js} +11 -7
  53. package/dist/{workspace-JEOHKFPX.js → workspace-LYDAP647.js} +6 -6
  54. package/package.json +25 -11
  55. package/skills/ae-agent/SKILL.md +20 -3
  56. package/skills/ae-agent/references/command_index.md +8 -0
  57. package/skills/ae-agent/references/resource-package.md +57 -0
  58. package/skills/ae-analysis/SKILL.md +23 -10
  59. package/skills/ae-analysis/references/adhoc_export.md +1 -1
  60. package/skills/ae-analysis/references/agent_review_preflight.md +55 -10
  61. package/skills/ae-analysis/references/agent_review_priorities_comparisons.md +5 -3
  62. package/skills/ae-analysis/references/agent_review_submit_to_page.md +60 -24
  63. package/skills/ae-analysis/references/ai_models/event.md +58 -2
  64. package/skills/ae-analysis/references/ai_models/rank_list.md +1 -0
  65. package/skills/ae-analysis/references/ai_models/retention.md +2 -0
  66. package/skills/ae-analysis/references/ai_models/revenue.md +2 -0
  67. package/skills/ae-analysis/references/analysis_data_export.md +11 -1
  68. package/skills/ae-analysis/references/asset_batch_info_export.md +2 -2
  69. package/skills/ae-analysis/references/asset_batch_sql_export.md +2 -2
  70. package/skills/ae-analysis/references/asset_export.md +1 -1
  71. package/skills/ae-analysis/references/bi_panel_page_data_export.md +1 -1
  72. package/skills/ae-analysis/references/check_export.md +1 -1
  73. package/skills/ae-analysis/references/command_index.md +39 -26
  74. package/skills/ae-analysis/references/dashboard_report_data_export.md +2 -0
  75. package/skills/ae-analysis/references/dashboard_report_get.md +6 -2
  76. package/skills/ae-analysis/references/dashboard_report_update.md +24 -5
  77. package/skills/ae-analysis/references/feedback_submit.md +1 -1
  78. package/skills/ae-analysis/references/governance_recommendation_export.md +40 -18
  79. package/skills/ae-analysis/references/governance_recommendation_run_update.md +13 -0
  80. package/skills/ae-analysis/references/live_data_export.md +1 -1
  81. package/skills/ae-analysis/references/metric_create.md +29 -0
  82. package/skills/ae-analysis/references/metric_get.md +2 -0
  83. package/skills/ae-analysis/references/metric_update.md +2 -0
  84. package/skills/ae-analysis/references/operation_record_export.md +1 -1
  85. package/skills/ae-analysis/references/plan_change_log_export.md +1 -1
  86. package/skills/ae-analysis/references/plan_export.md +1 -1
  87. package/skills/ae-analysis/references/project_info_get.md +4 -0
  88. package/skills/ae-analysis/references/project_member_group_add_members.md +35 -0
  89. package/skills/ae-analysis/references/project_member_group_create.md +25 -0
  90. package/skills/ae-analysis/references/project_member_group_delete.md +34 -0
  91. package/skills/ae-analysis/references/project_member_group_list.md +29 -0
  92. package/skills/ae-analysis/references/project_member_group_members.md +28 -0
  93. package/skills/ae-analysis/references/project_member_group_remove_members.md +35 -0
  94. package/skills/ae-analysis/references/project_member_group_rename.md +26 -0
  95. package/skills/ae-analysis/references/project_semantic_knowledge_wiki.md +9 -1
  96. package/skills/ae-analysis/references/project_semantic_knowledge_wiki_plan_schema.md +6 -1
  97. package/skills/ae-analysis/references/report_data_export.md +1 -1
  98. package/skills/ae-analysis/references/scenario_append.md +31 -0
  99. package/skills/ae-analysis/references/scenario_begin.md +11 -0
  100. package/skills/ae-analysis/references/scenario_collect.md +43 -0
  101. package/skills/ae-analysis/references/scenario_evaluation.md +18 -0
  102. package/skills/ae-analysis/references/scenario_get.md +15 -0
  103. package/skills/ae-analysis/references/scenario_list.md +64 -0
  104. package/skills/ae-analysis/scripts/project-semantic-knowledge-wiki/build-project-semantic-wiki.mjs +73 -4
  105. package/skills/ae-analysis/scripts/project-semantic-knowledge-wiki/company-kb.mjs +14 -1
  106. package/skills/ae-analysis/scripts/project-semantic-knowledge-wiki/default-compile-schema.md +5 -1
  107. package/skills/ae-analysis/scripts/project-semantic-knowledge-wiki/execution-contract.mjs +173 -0
  108. package/skills/ae-analysis/scripts/project-semantic-knowledge-wiki/generate-build-ir.mjs +109 -64
  109. package/skills/ae-automation/SKILL.md +2 -2
  110. package/skills/ae-automation/references/cli.md +18 -1
  111. package/skills/ae-capability/SKILL.md +7 -3
  112. package/skills/ae-community/SKILL.md +77 -27
  113. package/skills/ae-community/references/community-analyzing-theme-comment.md +10 -8
  114. package/skills/ae-community/references/community-data-quality.md +68 -0
  115. package/skills/ae-community/references/community-query-evidence.md +85 -0
  116. package/skills/ae-community/references/community-scenario-capabilities.md +137 -0
  117. package/skills/ae-community/references/community-weekly-report.md +6 -3
  118. package/skills/ae-community/references/get_channel_info.md +7 -4
  119. package/skills/ae-community/references/get_comment_tag_analysis.md +3 -3
  120. package/skills/ae-community/references/get_comments_summary.md +4 -4
  121. package/skills/ae-community/references/get_corpus_tags.md +3 -3
  122. package/skills/ae-community/references/get_daily_summary.md +3 -3
  123. package/skills/ae-community/references/get_hot_topics.md +3 -3
  124. package/skills/ae-community/references/get_livestream_analysis.md +3 -3
  125. package/skills/ae-community/references/get_livestream_detail.md +4 -4
  126. package/skills/ae-community/references/get_livestream_list.md +3 -3
  127. package/skills/ae-community/references/get_livestream_overview.md +3 -3
  128. package/skills/ae-community/references/get_livestream_room_metrics.md +3 -3
  129. package/skills/ae-community/references/get_livestream_rooms.md +3 -3
  130. package/skills/ae-community/references/get_overview_metrics.md +3 -3
  131. package/skills/ae-community/references/get_post_detail.md +4 -4
  132. package/skills/ae-community/references/get_risk_content.md +5 -5
  133. package/skills/ae-community/references/get_sentiment_overview.md +4 -4
  134. package/skills/ae-community/references/get_tag_trends.md +3 -3
  135. package/skills/ae-community/references/get_topic_detail.md +3 -3
  136. package/skills/ae-community/references/list_sources.md +28 -0
  137. package/skills/ae-community/references/list_spaces.md +39 -0
  138. package/skills/ae-community/references/search_posts.md +21 -7
  139. package/skills/ae-data-integration/SKILL.md +6 -4
  140. package/skills/ae-data-integration/references/error-handling.md +1 -0
  141. package/skills/ae-data-integration/references/handoff.md +1 -1
  142. package/skills/ae-data-integration/references/sink-upload.md +11 -0
  143. package/skills/ae-data-integration/references/source-inspect.md +2 -1
  144. package/skills/ae-data-integration/references/transform.md +1 -1
  145. package/skills/ae-data-integration/references/ue-mapping.md +1 -1
  146. package/skills/ae-evaluation/SKILL.md +83 -0
  147. package/skills/ae-evaluation/references/access-and-members.md +55 -0
  148. package/skills/ae-evaluation/references/connections.md +78 -0
  149. package/skills/ae-evaluation/references/datasets.md +57 -0
  150. package/skills/ae-evaluation/references/evaluators.md +81 -0
  151. package/skills/ae-evaluation/references/files.md +33 -0
  152. package/skills/ae-evaluation/references/integrations.md +39 -0
  153. package/skills/ae-evaluation/references/runs.md +160 -0
  154. package/skills/ae-evaluation/references/schedules.md +31 -0
  155. package/skills/ae-kb/SKILL.md +33 -6
  156. package/skills/ae-kb/references/publication.md +81 -0
  157. package/skills/ae-kb/references/query-workflow.md +14 -1
  158. package/skills/ae-metadata/SKILL.md +3 -2
  159. package/skills/ae-metadata/references/metadata_data_table_download.md +7 -1
  160. package/skills/ae-metadata/references/metadata_data_table_get.md +37 -0
  161. package/skills/ae-team/SKILL.md +2 -2
  162. package/skills/ae-team/references/run-start.md +1 -0
  163. package/skills/ae-team/references/run-watch.md +7 -5
  164. package/skills/ae-things/SKILL.md +53 -51
  165. package/skills/ae-things/references/cli.md +56 -54
  166. package/skills/ae-things-progress/SKILL.md +20 -20
  167. package/skills/ae-things-review/SKILL.md +19 -19
  168. package/dist/chunk-6VNIR4AP.js +0 -1422
  169. package/dist/chunk-CI24BDR2.js +0 -43
package/README.md CHANGED
@@ -17,7 +17,6 @@ The CLI is designed around:
17
17
  - Node.js 20 or later.
18
18
  - macOS, Linux, or native Windows (PowerShell / Command Prompt); WSL is optional.
19
19
  - Access to the npm registry for CLI installation.
20
- - Access to GitHub only when the bundled Skills source cannot be used.
21
20
 
22
21
  ## Installation
23
22
 
@@ -30,7 +29,7 @@ npx @thinkingai/ae-cli@latest install
30
29
  npx @thinkingai/ae-cli@latest install --format json
31
30
  ```
32
31
 
33
- The installer checks Node.js 20+, installs and verifies the CLI, then installs matching Skills globally in `~/.agents/skills`, writing the shared files once before automatically distributing copies to clients that need their own directory. No Agent selection is needed; Codex and Cursor can share these Skills even when installed later. `--dry-run`, `--format json`, and optional `--host <AE_HOST>` are supported. Unrelated project-only client warnings are hidden after successful verification; missing files and YAML errors remain failures. Being logged out is not an installation failure. See the [installation guide](./cli-installation-guide.md).
32
+ The installer checks Node.js 20+, installs and verifies the CLI, then uses the bundled Skills tool to install matching global Skills for supported clients. First installation includes all bundled Skills when no business state has been confirmed. `--dry-run`, `--format json`, and optional `--host <AE_HOST>` are supported. Being logged out is not an installation failure. See the [installation guide](./cli-installation-guide.md).
34
33
 
35
34
  The Skills teach supported coding Agents, including Claude Code, Codex, Cursor, and similar tools, how to discover and call `ae-cli`.
36
35
 
@@ -51,6 +50,10 @@ ae-cli auth status
51
50
 
52
51
  Use the AE URL supplied by your AgenticEngine administrator. If no Host is configured, `ae-cli` guides existing customers to obtain that URL first. Only users without an AgenticEngine environment are directed to [request a trial](https://thinkingai.cn/request-demo).
53
52
 
53
+ Business-based command filtering and Skill selection apply only to local CLI use by external Agents; built-in TE Agent sandboxes keep the complete command and Skill sets. After successful login, the CLI filters `--help` and capability discovery by the active environment’s enabled businesses and synchronizes managed global Skills. Analysis remains available by default. Run `ae-cli config refresh` after enabling a business to fetch its state and restore its Skills. Switching the active environment or account synchronizes again; a one-off `--host` query does not change global Skills.
54
+
55
+ Only explicitly disabled businesses are removed. Older servers, missing states, and network failures do not trigger removal. Legacy client links to a verified, unmodified managed shared Skill are migrated automatically; other modified or unrecognized copies are preserved and reported. Start a new Agent session after synchronization; existing conversation context is retained.
56
+
54
57
  ## Environment-Bound Updates
55
58
 
56
59
  Each AE environment returns the exact `aeCliVersion` it expects. Use the unified update command to install that CLI version and its matching Skills:
@@ -62,11 +65,11 @@ ae-cli update --dry-run
62
65
 
63
66
  Updates use the same global Skills installation and verification as `install`. Older packages need no installer or generated manifest: their bundled Skills define the expected contents. If Skills fail after the CLI installs, the result reports partial completion and can be retried.
64
67
 
65
- Automatic synchronization runs during normal commands after login; host version checks are cached for up to 24 hours. `ae-cli update --host <AE_HOST>` checks immediately. After a downgrade, future updates run the older CLI's own updater, including its historical limitations. To use the new installer logic while following an older host, run `npx @thinkingai/ae-cli@latest update --host <AE_HOST>`; the target remains the host-required version.
68
+ Automatic synchronization runs during normal commands after login; host version checks are cached for up to one hour. `ae-cli update --host <AE_HOST>` checks immediately. After a downgrade, future updates run the older CLI's own updater, including its historical limitations. To use the new installer logic while following an older host, run `npx @thinkingai/ae-cli@latest update --host <AE_HOST>`; the target remains the host-required version.
66
69
 
67
- `ae-cli update` installs the exact version required by the active host rather than npm `latest`. It synchronizes Skills from the installed npm package first and uses the matching GitHub tag only as a fallback.
70
+ `ae-cli update` installs the exact version required by the active host rather than npm `latest`. Skills are synchronized from the verified target package; modified or unrecognized copies are preserved and reported.
68
71
 
69
- Starting with the `6.0.37` and `6.1.9` release lines, ordinary business commands can automatically upgrade or downgrade the CLI to the host-required version. After a successful synchronization, the old process exits with `AE_CLI_VERSION_SYNCED`; re-run the original command so it executes with the new CLI and Skills. Installation failures are reported without replacing the business command's JSON output.
72
+ Starting with the `6.0.37` and `6.1.9` release lines, ordinary business commands can automatically upgrade or downgrade the CLI to the host-required version, including switching from `6.0.x` to `6.1.x`. Automatic synchronization requires stable `major.minor.patch` versions at both ends; development and other nonstandard versions are skipped. After successful synchronization, the new CLI automatically executes the original command once and returns its result and exit code. Arguments, piped input, working directory, and confirmation behavior are preserved. If the new CLI cannot start, `AE_CLI_VERSION_SYNCED` asks you to re-run manually; an executed command is never retried automatically. Installation failures are reported without replacing the business command's JSON output.
70
73
 
71
74
  Useful controls:
72
75
 
@@ -143,6 +146,7 @@ The table covers every current root command individually. Use `ae-cli --help` fo
143
146
  | Agent platform | `context` | Read the current product-page context authorized for the active Agent Run |
144
147
  | Agent platform | `memory` | AgentSpace memory, drafts, shared review, extraction jobs, revisions, and state transitions |
145
148
  | Agent platform | `team` | Agent Team and TeamRun execution, chat, results, and artifacts |
149
+ | Agent platform | `evaluation` | Agent Evaluation datasets, LLM judge evaluators, runs, case results, exports, schedules, and model/agent configs |
146
150
  | Agent platform | `system` | Root/admin management of members, sandboxes, tools, models, usage, quotas, and channels |
147
151
  | General tools | `capability` | Capability discovery, schema inspection, validation, dry-run, and generic execution |
148
152
  | General tools | `auth` | Host-scoped login, status, and multi-account management |
@@ -156,6 +160,10 @@ The table covers every current root command individually. Use `ae-cli --help` fo
156
160
  | Agent platform | `automation` | Automation configuration, execution, history, and results |
157
161
  <!-- root-command-surface:end -->
158
162
 
163
+ Review collected analysis questions with `ae-cli analysis scenario list --project-id 1 --days 7`. The `ae-analysis` Skill can deduplicate questions and assess badcases with concise, evidence-based reasons. See the [scenario review guide](skills/ae-analysis/references/scenario_list.md). Answers can include elapsed time; use `ae-cli analysis scenario get --help` to query linked command execution details.
164
+
165
+ Evaluation commands follow the current AE Host in personal terminals and sandboxes; use `--host` to select another host. Evaluation requests use the HTTP or HTTPS scheme configured for that AE Host, consistent with other AE commands. Legacy `--endpoint` and `AE_EVAL_BASE_URL` values may only match the current AE Host; other values fail before credentials are sent. Remove these settings and use `--host` to select a host. Outside a sandbox, export `AE_EVAL_ACCESS_TOKEN` with a platform session token; sandboxes can obtain a session automatically. See [endpoint and authentication rules](skills/ae-evaluation/SKILL.md#endpoint-and-authentication).
166
+
159
167
  ## Capability Gateway
160
168
 
161
169
  Capability Gateway is the preferred entry point for operations that do not need a dedicated curated command:
@@ -169,6 +177,10 @@ ae-cli capability dry-run analysis.report.list --input input.json
169
177
  ae-cli capability run analysis.report.list --input input.json
170
178
  ```
171
179
 
180
+ Administrators can set each member's daily CLI call limit in External Access Management.
181
+
182
+ For asynchronous exports, omit `--timeout-seconds` to use the server's default timeout. See the [export guide](skills/ae-analysis/references/analysis_data_export.md) for submitting, waiting for, and downloading results.
183
+
172
184
  `--input` accepts inline JSON, a JSON file path, `@<path>`, or `-` for stdin.
173
185
 
174
186
  Use `validate` while fixing complex nested input. Use `dry-run` when you need the final risk, output mode, cancellation support, or delete confirmation preview. Do not stack `validate` and `dry-run` for the same final payload by default; `dry-run` already validates it.
@@ -194,7 +206,7 @@ ae-cli auth status --host https://host-a.example.com
194
206
  # Import a CLI token copied from External Access Management (hidden prompt)
195
207
  ae-cli auth set-token --host https://host-a.example.com
196
208
  # Non-interactive input for local scripts or tests
197
- printf '%s' "$AE_CLI_TOKEN" | ae-cli auth set-token --host https://host-a.example.com --token-stdin
209
+ printf '%s' "$IMPORTED_CLI_TOKEN" | ae-cli auth set-token --host https://host-a.example.com --token-stdin
198
210
  # For the uncommon case where one Host needs multiple accounts
199
211
  ae-cli auth login --host https://host-a.example.com --add
200
212
  ae-cli auth list --host https://host-a.example.com
@@ -216,6 +228,20 @@ A regular `auth login` keeps the simple one-Host/one-account behavior and replac
216
228
 
217
229
  `auth set-token` is for local use with a `cli_` token copied from External Access Management. It prompts without echo by default; `--token-stdin` supports non-interactive local testing. The CLI validates the token against the target Host before replacing the stored credential, encrypts it in the existing per-Host vault, and never includes the value in command output. Add `--add` to retain other accounts for the same Host.
218
230
 
231
+ Inject credentials into the current CLI invocation through environment variables or a specified file without changing stored machine accounts. This supports automation scripts, CI/CD, shared Agents, and other workflows:
232
+
233
+ ```bash
234
+ AE_CLI_TOKEN="$CALLER_CLI_TOKEN" AE_CLI_TOKEN_HOST=https://host-a.example.com ae-cli auth status
235
+ AE_CLI_TOKEN_FILE=/secure/caller-token.json ae-cli auth status
236
+ ae-cli --cli-token-file /secure/caller-token.json auth status
237
+ ```
238
+
239
+ The token file is a read-only JSON object: `{"url":"https://host-a.example.com","token":"cli_REPLACE_WITH_USER_TOKEN"}`. The historical `cli-token` key is also accepted. Keep the file private to its owner (for example, mode `600`). Files must be regular JSON files no larger than 64 KiB. The file URL or `AE_CLI_TOKEN_HOST` selects the host for this invocation; an explicit `--host` must match it. External tokens are sent only to that origin; alternate service origins and HTTP redirects are rejected.
240
+
241
+ Credential precedence is `--cli-token-file` > `AE_CLI_TOKEN` with required `AE_CLI_TOKEN_HOST` > `AE_CLI_TOKEN_FILE` > the existing stored-account/sandbox sources. An explicitly selected source that is empty, malformed, unreadable, or bound to a different host returns `EXTERNAL_CLI_TOKEN_INVALID`; it never falls back to another identity. External credentials also take precedence over sandbox identity headers for Agent calls. `auth status` reports `environment-cli-token` or `file-cli-token`, account and expiration when available, and never reveals the token. Authentication failures do not replace or delete stored credentials.
242
+
243
+ External mode does not write the token or renewal state to the local credential vault. Renewal is best effort, uses the `cli-token` header, and is limited per host/token per process day; older servers without header-based renewal can still authenticate business calls but cannot automatically extend external tokens. `auth`, `auth login`, `auth set-token`, `auth use`, and `auth logout` return `EXTERNAL_CLI_TOKEN_ACTIVE` while external credentials are selected. Remove these process settings before managing machine accounts; `auth list` continues to list local accounts.
244
+
219
245
  The new CLI persists only CLI tokens, never access or refresh tokens. Multiple accounts live in an encrypted V1 vault while the active account is projected into the historical file shape for automatic downgrades. When the CLI upgrades again, it reconciles login, switch, or logout changes made by the old CLI.
220
246
 
221
247
  Login uses a cross-platform device-code flow. Use `--no-browser` when the environment cannot open a browser.
@@ -245,6 +271,9 @@ JSON flags generally accept inline JSON, `@file`, a file path, or `-` for stdin.
245
271
 
246
272
  ## Knowledge Bases
247
273
 
274
+ Use `ae-cli kb candidate changes --name <name> --candidate <id>` to review changed sources, Wiki and Index before approving a company compilation. See [Publication previews](skills/ae-kb/references/publication.md) for entry details and bounded text diffs.
275
+ For large approval previews, use `kb candidate changes --group wiki --search payment --offset 0 --limit 50`. The first successful compilation publishes automatically; later company KB updates require approval.
276
+
248
277
  Manage the server-side knowledge-base lifecycle:
249
278
 
250
279
  ```bash
package/README.zh.md CHANGED
@@ -17,7 +17,6 @@ CLI 的核心设计包括:
17
17
  - Node.js 20 或更高版本。
18
18
  - 支持 macOS、Linux 和原生 Windows(PowerShell / CMD),无需安装 WSL。
19
19
  - 安装 CLI 时能够访问 npm 仓库。
20
- - 内置 Skills 来源不可用时,能够访问 GitHub。
21
20
 
22
21
  ## 安装
23
22
 
@@ -34,7 +33,7 @@ npx @thinkingai/ae-cli@latest install
34
33
  npx @thinkingai/ae-cli@latest install --format json
35
34
  ```
36
35
 
37
- 安装器检查 Node.js 20+、安装并验证 CLI,再将同版本 Skills 全局安装到 `~/.agents/skills`,公共文件只写入一次,再自动向需要独立目录的客户端分发副本,无需选择 Agent;之后安装的 Codex、Cursor 也可共享这些 Skills。支持 `--dry-run`、`--format json` 和可选的 `--host <AE_HOST>`。验证成功后不显示无关的项目级客户端告警;文件缺失和 YAML 错误仍判为失败。未登录不算安装失败。详见[安装指南](./cli-installation-guide.md)。
36
+ 安装器检查 Node.js 20+、安装并验证 CLI,再通过内置的 Skills 工具向支持的客户端安装同版本全局 Skills。首次安装且尚无已确认业务状态时安装全量内置 Skills。支持 `--dry-run`、`--format json` 和可选的 `--host <AE_HOST>`。未登录不算安装失败。详见[安装指南](./cli-installation-guide.md)。
38
37
 
39
38
  Skills 会帮助 Claude Code、Codex、Cursor 等编码 Agent 理解、发现并调用 `ae-cli`。
40
39
 
@@ -55,6 +54,10 @@ ae-cli auth status
55
54
 
56
55
  请使用 AgenticEngine 管理员提供的 AE 地址。未配置 Host 时,`ae-cli` 会先引导已有客户向管理员获取地址;只有确认尚无 AgenticEngine 环境的用户,才会看到[申请试用](https://thinkingai.cn/request-demo)入口。
57
56
 
57
+ 按业务过滤命令和剪裁 Skills 仅适用于外部 Agent 使用的本机 CLI;TE Agent 内置沙箱始终保留完整命令与全部 Skills。登录成功后,CLI 按当前环境已开通的业务过滤 `--help` 和能力发现,并同步受管的全局 Skills;分析能力默认保留。后续开通业务时,执行 `ae-cli config refresh` 即可重新获取状态并补装对应 Skills。切换活动环境或账号会重新同步;单次 `--host` 查询不改变全局 Skills。
58
+
59
+ 仅明确关闭的业务会被移除;旧服务端、缺失状态或网络失败不会触发删除。指向已核验、未修改的受管共享 Skill 的客户端历史链接会自动迁移;其他用户修改和来源不明的副本保留并报告。同步后请新开 Agent 会话,已有会话的上下文不会被撤回。
60
+
58
61
  ## 环境版本同步
59
62
 
60
63
  每个 AE 环境都会返回其要求的精确 `aeCliVersion`。使用统一更新命令安装对应版本的 CLI 和 Skills:
@@ -66,11 +69,11 @@ ae-cli update --dry-run
66
69
 
67
70
  更新与 `install` 复用全局 Skills 安装和校验。旧包无需包含安装器或生成的清单,直接以目标包内置 Skills 为准。CLI 安装后 Skills 失败会返回部分成功信息,修复后可重复执行。
68
71
 
69
- 自动同步在登录后的普通命令中触发,集群版本检查最长缓存 24 小时;`ae-cli update --host <AE_HOST>` 可立即查询。降级后,后续更新由旧版 CLI 自身执行,也受旧版实现限制。需要用新安装逻辑匹配旧集群时,可运行 `npx @thinkingai/ae-cli@latest update --host <AE_HOST>`,目标仍是集群要求的版本。
72
+ 自动同步在登录后的普通命令中触发,集群版本检查最长缓存 1 小时;`ae-cli update --host <AE_HOST>` 可立即查询。降级后,后续更新由旧版 CLI 自身执行,也受旧版实现限制。需要用新安装逻辑匹配旧集群时,可运行 `npx @thinkingai/ae-cli@latest update --host <AE_HOST>`,目标仍是集群要求的版本。
70
73
 
71
- `ae-cli update` 安装当前 Host 要求的精确版本,不依赖 npm `latest`。更新时优先从已安装的 npm 包同步 Skills,本地来源失败后才回退到对应的 GitHub tag。
74
+ `ae-cli update` 安装当前 Host 要求的精确版本,不依赖 npm `latest`。Skills 从已验证的目标包同步;用户修改或来源不明的副本会保留并报告。
72
75
 
73
- 从 `6.0.37` 和 `6.1.9` 维护线开始,普通业务命令可以自动升级或降级到环境要求的版本。同步成功后,旧进程会返回 `AE_CLI_VERSION_SYNCED`;重新执行原命令,即可使用新的 CLI 和 Skills。安装失败会给出提示,但不会用安装输出污染业务命令的 JSON 结果。
76
+ 从 `6.0.37` 和 `6.1.9` 维护线开始,普通业务命令可以自动升级或降级到环境要求的版本,包括从 `6.0.x` 切换到 `6.1.x`。自动同步要求本地和目标均为 `主版本.次版本.补丁号` 格式的正式版本,开发版等不规则版本会跳过。同步成功后,新版 CLI 会自动执行原命令一次,并返回该命令的结果和退出码;参数、管道输入、工作目录和确认行为保持不变。如果新版 CLI 无法启动,会返回 `AE_CLI_VERSION_SYNCED` 并提示手动重跑;已经执行的命令不会自动重试。安装失败会给出提示,但不会用安装输出污染业务命令的 JSON 结果。
74
77
 
75
78
  常用控制方式:
76
79
 
@@ -147,6 +150,7 @@ ae-cli capability list --domain analysis --jq '.data.capabilities[] | .id'
147
150
  | Agent 平台 | `context` | 读取当前 Agent Run 已授权的产品页面上下文 |
148
151
  | Agent 平台 | `memory` | AgentSpace 记忆、草稿、共享审核、提取任务、版本与状态治理 |
149
152
  | Agent 平台 | `team` | Agent Team 和 TeamRun 的执行、对话、结果及产物 |
153
+ | Agent 平台 | `evaluation` | Agent Evaluation 评测数据集、LLM 裁判、评测任务、用例结果、导出、调度,以及模型/Agent 配置 |
150
154
  | Agent 平台 | `system` | root/admin 的成员、沙盒、工具、模型、用量、配额和渠道管理 |
151
155
  | 通用工具 | `capability` | 能力发现、Schema 查看、参数校验、dry-run 和通用执行 |
152
156
  | 通用工具 | `auth` | 按 Host 登录、查看状态及管理同一 Host 的多个账号 |
@@ -160,6 +164,10 @@ ae-cli capability list --domain analysis --jq '.data.capabilities[] | .id'
160
164
  | Agent 平台 | `automation` | 自动化配置、执行、历史和结果 |
161
165
  <!-- root-command-surface:end -->
162
166
 
167
+ 使用 `ae-cli analysis scenario list --project-id 1 --days 7` 查询已采集的分析问题,由 `ae-analysis` Skill 指导 Agent 去重、判断 badcase 并简要说明原因和证据。详见[分析问题复盘指南](skills/ae-analysis/references/scenario_list.md)。 回答可附带耗时;使用 `ae-cli analysis scenario get --help` 查看关联命令执行明细的查询方式。
168
+
169
+ 评测命令在普通终端和沙箱中均跟随当前 AE Host,可通过 `--host` 切换。评测请求沿用该 AE Host 配置的 HTTP 或 HTTPS 协议,与其他 AE 命令一致。旧 `--endpoint` 和 `AE_EVAL_BASE_URL` 只能与当前 AE Host 一致,其他值会在发送凭证前报错;请移除这些配置,统一使用 `--host` 切换。沙箱外需设置 `AE_EVAL_ACCESS_TOKEN` 平台 session token,沙箱内可自动获取会话。详见 [地址与鉴权规则](skills/ae-evaluation/SKILL.md#endpoint-and-authentication)。
170
+
163
171
  ## Capability Gateway
164
172
 
165
173
  不需要独立精选命令的能力,应优先通过 Capability Gateway 调用:
@@ -173,6 +181,10 @@ ae-cli capability dry-run analysis.report.list --input input.json
173
181
  ae-cli capability run analysis.report.list --input input.json
174
182
  ```
175
183
 
184
+ 管理员可在“外部访问管理”为成员配置每日 CLI 调用限额。
185
+
186
+ 异步导出时,省略 `--timeout-seconds` 即使用服务端默认超时。提交、等待和下载结果的方法见[导出使用指南](skills/ae-analysis/references/analysis_data_export.md)。
187
+
176
188
  `--input` 支持内联 JSON、JSON 文件路径、`@<path>`,或通过 `-` 从 stdin 读取。
177
189
 
178
190
  复杂嵌套参数尚在调整时使用 `validate`;需要确认最终风险等级、输出模式、取消能力或删除门禁时使用 `dry-run`。默认不要对同一份最终入参连续执行 `validate` 和 `dry-run`,因为 `dry-run` 已包含参数校验。
@@ -198,7 +210,7 @@ ae-cli auth status --host https://host-a.example.com
198
210
  # 导入从“外部访问管理”复制的 CLI Token(隐藏输入)
199
211
  ae-cli auth set-token --host https://host-a.example.com
200
212
  # 本地脚本或测试使用非交互输入
201
- printf '%s' "$AE_CLI_TOKEN" | ae-cli auth set-token --host https://host-a.example.com --token-stdin
213
+ printf '%s' "$IMPORTED_CLI_TOKEN" | ae-cli auth set-token --host https://host-a.example.com --token-stdin
202
214
  # 少量需要同一 Host 多账号的场景
203
215
  ae-cli auth login --host https://host-a.example.com --add
204
216
  ae-cli auth list --host https://host-a.example.com
@@ -220,6 +232,20 @@ ae-cli config remove pre-production --yes
220
232
 
221
233
  `auth set-token` 用于在本地导入从“外部访问管理”复制的 `cli_` Token。默认使用不回显的隐藏输入,`--token-stdin` 支持本地测试等非交互场景。CLI 会先向目标 Host 校验 Token,再替换本地凭证,并写入现有的按 Host 加密凭据库;命令输出不会包含 Token。需要保留同一 Host 的其他账号时增加 `--add`。
222
234
 
235
+ 支持通过环境变量或指定文件,为当前 CLI 调用注入凭证,不改变机器上已保存的账号;适用于自动化脚本、CI/CD、公共Agent等场景。
236
+
237
+ ```bash
238
+ AE_CLI_TOKEN="$CALLER_CLI_TOKEN" AE_CLI_TOKEN_HOST=https://host-a.example.com ae-cli auth status
239
+ AE_CLI_TOKEN_FILE=/secure/caller-token.json ae-cli auth status
240
+ ae-cli --cli-token-file /secure/caller-token.json auth status
241
+ ```
242
+
243
+ Token 文件是只读 JSON 对象:`{"url":"https://host-a.example.com","token":"cli_REPLACE_WITH_USER_TOKEN"}`,也兼容历史字段 `cli-token`。文件应仅允许所有者读取,例如权限 `600`;必须是大小不超过 64 KiB 的普通 JSON 文件。文件中的 URL 或 `AE_CLI_TOKEN_HOST` 决定本次调用的 Host;显式 `--host` 必须与之匹配。外部 Token 仅发送到该 Origin,拒绝其他服务 Origin 和 HTTP 重定向。
244
+
245
+ 凭证优先级为 `--cli-token-file` > `AE_CLI_TOKEN`(必须同时提供 `AE_CLI_TOKEN_HOST`)> `AE_CLI_TOKEN_FILE` > 现有本地账号或沙箱来源。显式来源为空、格式错误、无法读取或 Host 不匹配时返回 `EXTERNAL_CLI_TOKEN_INVALID`,不会回退到其他身份。外部凭证也优先于 Agent 调用的沙箱身份头。`auth status` 的来源为 `environment-cli-token` 或 `file-cli-token`,并在后端支持时展示账号与到期时间,不输出 Token。认证失败不会替换或删除本地凭证。
246
+
247
+ 外部模式不将 Token 或续期状态写入本地凭据库。自动续期使用 `cli-token` 请求头,失败不阻断业务请求,每个进程按 Host、Token 和当天日期限频;旧后端不支持请求头续期时仍可认证业务请求,但不能自动延长外部 Token。选择外部凭证时,`auth`、`auth login`、`auth set-token`、`auth use` 和 `auth logout` 返回 `EXTERNAL_CLI_TOKEN_ACTIVE`。管理机器账号前先移除这些进程设置;`auth list` 仍只列出本地账号。
248
+
223
249
  新版 CLI 只持久化 CLI Token,不保存 access token 或 refresh token。多账号保存在加密的 V1 凭据文件中,同时维护旧文件格式的当前账号投影,保证 CLI 自动降级后仍可登录;再次升级时会合并旧 CLI 对投影的登录、切换或退出变更。
224
250
 
225
251
  登录使用跨平台设备码流程。当前环境无法打开浏览器时,可使用 `--no-browser`。
@@ -249,6 +275,9 @@ JSON 参数通常支持内联 JSON、`@file`、文件路径或通过 `-` 从 std
249
275
 
250
276
  ## 知识库
251
277
 
278
+ 公司知识库编译审批前,可用 `ae-cli kb candidate changes --name <name> --candidate <id>` 查看数据源、Wiki 和 Index 的变化。条目详情和文本差异用法见[审批预览](skills/ae-kb/references/publication.md)。
279
+ 审批变化较多时,可用 `kb candidate changes --group wiki --search payment --offset 0 --limit 50` 分页检索;首次成功编译自动发布,后续公司知识库更新进入审批。
280
+
252
281
  管理服务端知识库生命周期:
253
282
 
254
283
  ```bash
package/bin/ae-cli.js CHANGED
@@ -1,7 +1,12 @@
1
1
  #!/usr/bin/env node
2
+ import { readFileSync } from 'node:fs';
2
3
  if (Number(process.versions.node.split('.')[0]) < 20) {
3
4
  console.error('AE CLI requires Node.js 20 or later. Select a supported Node.js runtime and rerun.');
4
5
  process.exitCode = 1;
6
+ } else if (process.argv.length === 3 && process.argv[2] === '--runtime-capabilities') {
7
+ // Keep discovery independent of application imports and credential initialization.
8
+ const capabilities = JSON.parse(readFileSync(new URL('./runtime-capabilities.json', import.meta.url), 'utf8'));
9
+ process.stdout.write(JSON.stringify(capabilities) + '\n');
5
10
  } else {
6
11
  await import('../dist/index.js');
7
12
  }
@@ -0,0 +1,5 @@
1
+ {
2
+ "protocol": "ae-cli-runtime-capabilities",
3
+ "version": 1,
4
+ "features": ["kb_read_context_v1"]
5
+ }
@@ -20,13 +20,13 @@ Node.js 20 or later, npm, and npx must be available. The installer does not chan
20
20
 
21
21
  The running package determines the exact CLI version to install. The global executable is verified with `ae-cli --version`; PATH problems include the verified absolute path. Local npm links are protected by a small guard. Other installation conflicts use normal npm errors; the installer does not migrate existing installations.
22
22
 
23
- Skills are installed globally in `~/.agents/skills`. The shared files are installed once, then the Skills tool automatically distributes copies to detected clients that require their own directory. Shared-directory targets are skipped during distribution. Existing per-Skill links are replaced with copies when needed. Codex and Cursor support this shared directory, so installing Cursor later does not require a separate copy of the Skills. A client that only reads its own directory may need the same install command run again after that client is installed. User-global installation does not promise availability in remote/cloud clients or for every future client.
23
+ The pinned Skills tool resolves supported global client directories, including the shared `~/.agents/skills` directory. AE does not maintain a separate client path table. A client that only reads its own directory may need the same install command run again after that client is installed. Project-only clients, unknown clients, remote/cloud clients, and manually imported Skills are outside automatic global synchronization. Overlapping source directories and unverified links are protected rather than replaced.
24
24
 
25
25
  The external tool is pinned to `skills@1.5.12` to preserve Node 20 support and skip copying a Skill onto its own source directory. The installer does not maintain its own Agent catalog, ask users to select clients, or select clients based on the invoking AI. Unrelated user Skills are retained.
26
26
 
27
27
  ## Verification and output
28
28
 
29
- The installed CLI package's `skills/` directory defines the expected Skills and contents at runtime, including for historical packages without an installer or generated manifest. A failed shared-directory installation can retry the exact release tag `ThinkingAIAgenticEngine/ae-cli#v<CLI_VERSION>`; it never falls back to the default branch. Missing or invalid bundled Skills are reported rather than guessing the expected set from another version. Client distribution failures do not trigger a source download retry. If the local source and fallback both fail, the top-level error retains the first cause, and `skills.attempts` records both attempts with their stage, source, cause, and failures.
29
+ The verified target CLI package's complete `skills/` directory defines the expected contents, including for historical packages without an installer or generated manifest. The synchronizer uses this source for installation and restoration. Missing or invalid package sources, modified copies, ownership conflicts, and tool failures are reported; they do not trigger an unrestricted remote installation retry. `skills.attempts` retains the attempted source and failure details.
30
30
 
31
31
  Verification parses YAML/frontmatter and compares expected files in the shared global directory with the target package. Merely finding a directory, an `ae-*` name, or an exit code of zero is insufficient. Failures reported by the pinned tool for supported clients are also treated as failures, even when shared files exist.
32
32
 
@@ -37,6 +37,12 @@ Verification parses YAML/frontmatter and compares expected files in the shared g
37
37
 
38
38
  `--format json` emits one report on stdout. Progress goes to stderr; raw subprocess logs are not forwarded. Reports include `ok`, `dry_run`, `cli.package/version/path/verified`, `skills.directory/expected_count/installed_count/missing/source/version/failures/attempts`, `auth.host/authenticated`, and `next_steps`. Counts refer to unique Skills in the global directory. Use `--format table` for a human summary. Dry runs make no subprocess calls or installation/configuration writes.
39
39
 
40
+ `install --dry-run --format json` returns that report directly, with a root-level `commands` array. `update --dry-run --format json` keeps the command envelope (`ok` and `data`); its `data` includes `action`, `dryRun`, `target`, optional `host`, `commands`, and `skillsSources`.
41
+
42
+ Each `commands` array describes the current installation plan; `skillsSources` lists the current source choices. Array lengths and contents can change with the installer. Automation should run the complete `install` or `update` command, check its exit code and `ok`, and inspect the installation report. Do not depend on fixed array indexes or execute individual entries as a replacement for the installer.
43
+
44
+ The managed synchronizer uses the verified package source. Replaying historical GitHub fallback or `skills add --copy` commands would bypass business selection and copy protection.
45
+
40
46
  ## Host and login
41
47
 
42
48
  `--host` is optional. It delegates status checks to the existing auth command; it does not independently save credentials or change the active host. Being logged out does not make a verified installation fail.
@@ -54,6 +60,21 @@ ae-cli auth status --host <AE_HOST>
54
60
 
55
61
  Never print, copy, or manually save any token.
56
62
 
63
+ ## Business selection after login
64
+
65
+ First installation without confirmed business state installs all bundled Skills. After successful login, `config refresh`, an account switch, or an active-environment switch, config determines the optional business selection. Analysis and foundation Skills remain available. Only pristine managed copies of explicitly disabled businesses are removed; enabled businesses are restored from the package. Unknown states preserve existing copies. Installation, update, and automatic version synchronization reuse this selection, so an upgrade does not restore disabled Skills.
66
+
67
+ ```bash
68
+ ae-cli config refresh
69
+ ae-cli config show
70
+ ```
71
+
72
+ The global selection follows one active local environment. An explicit `--host` refresh reads that environment's config without changing global Skills, even when its URL matches the active host. External-token and sandbox invocations do not manage local global Skills. Failed config or Skill synchronization does not revoke successful authentication. Partial synchronization reports protected or failed paths; resolve the reported conflict and retry. Existing copies are adopted once only when they exactly match a known package source. No regular backup is needed because the CLI package retains the complete resources.
73
+
74
+ Older Skills installations may have created client links to the shared global directory. The synchronizer migrates an existing same-name link only when its destination is a managed shared Skill whose contents still match both its ownership record and the installed package. A confirmed disabled business removes the verified links before its shared copy; an enabled business replaces them with managed copies. Unknown business states leave links unchanged. Custom targets, modified shared contents, and links to package sources remain protected.
75
+
76
+ Start a new Agent session after synchronization. Descriptions already loaded into a conversation cannot be withdrawn.
77
+
57
78
  ## Host-compatible upgrades and downgrades
58
79
 
59
80
  ```bash
@@ -73,7 +94,7 @@ To use the newer installer while still respecting the current host version, incl
73
94
  npx @thinkingai/ae-cli@latest update --host <AE_HOST>
74
95
  ```
75
96
 
76
- The newer command orchestrates the work; the installed target remains the host-required version. Required package versions and fallback tags must be published and accessible. Global CLI installation follows one target at a time; switching between differently versioned hosts can switch that installation again.
97
+ The newer command orchestrates the work; the installed target remains the host-required version. Required package versions must be published and accessible. Global CLI installation follows one target at a time; switching between differently versioned hosts can switch that installation again.
77
98
 
78
99
  ## Advanced manual troubleshooting
79
100
 
@@ -1,21 +1,27 @@
1
1
  import { createRequire as __createRequire } from 'node:module'; const require = __createRequire(import.meta.url);
2
2
  import {
3
- missingAeHostGuidance,
4
- missingAeHostHint
5
- } from "./chunk-6ZIQV5GW.js";
3
+ invalidateBusinessSkillSynchronization,
4
+ refreshEnvironmentAfterLogin
5
+ } from "./chunk-ZGIYG473.js";
6
6
  import {
7
7
  MultiselectCancelled,
8
8
  promptSingleSelect
9
9
  } from "./chunk-7K24F7T2.js";
10
+ import {
11
+ missingAeHostGuidance,
12
+ missingAeHostHint
13
+ } from "./chunk-6ZIQV5GW.js";
10
14
  import {
11
15
  resolveHost
12
- } from "./chunk-OP44TT4H.js";
16
+ } from "./chunk-IN7KKL6K.js";
13
17
  import {
14
- getLocalCliPackageInfo,
15
18
  printError,
16
- printOutput,
19
+ printOutput
20
+ } from "./chunk-752BSLZC.js";
21
+ import {
22
+ getLocalCliPackageInfo,
17
23
  runHostCompatCheck
18
- } from "./chunk-6VNIR4AP.js";
24
+ } from "./chunk-TULINOLS.js";
19
25
  import {
20
26
  CliTokenValidationUnavailableError,
21
27
  CredentialStoreUnreadableError,
@@ -31,17 +37,19 @@ import {
31
37
  saveCredential,
32
38
  updateCredentialMetadata,
33
39
  validateCliTokenOnServer
34
- } from "./chunk-GHXZK54S.js";
40
+ } from "./chunk-H3K5UGYC.js";
35
41
  import {
36
42
  getFallbackCliToken,
37
43
  loadConfig,
38
- normalizeUrl,
39
44
  saveConfig
40
- } from "./chunk-ZL7SGNIA.js";
45
+ } from "./chunk-JNVVJ273.js";
41
46
  import {
47
+ ExternalCliTokenError,
42
48
  PermissionError,
43
- logger
44
- } from "./chunk-WNGFSIOB.js";
49
+ logger,
50
+ normalizeUrl,
51
+ readExternalCliToken
52
+ } from "./chunk-Z3Q2AEIN.js";
45
53
 
46
54
  // src/core/device-auth.ts
47
55
  import { execFileSync } from "child_process";
@@ -269,7 +277,7 @@ function getExplicitAuthHostOverride(program, opts) {
269
277
  function resolveAuthHost(program, opts) {
270
278
  return resolveHost(getExplicitAuthHostOverride(program, opts));
271
279
  }
272
- async function validateExistingCliToken(host, cliToken) {
280
+ async function validateExistingCliToken(host, cliToken, external = false) {
273
281
  try {
274
282
  return { valid: true, trusted: false, details: await validateCliTokenOnServer(host, cliToken) };
275
283
  } catch (error) {
@@ -286,7 +294,7 @@ async function validateExistingCliToken(host, cliToken) {
286
294
  printError(
287
295
  "auth",
288
296
  error.message,
289
- `Run: ae-cli auth logout --host ${host}, then ae-cli auth login --host ${host}`
297
+ external ? "Replace the external CLI token with a valid token for this host." : `Run: ae-cli auth logout --host ${host}, then ae-cli auth login --host ${host}`
290
298
  );
291
299
  process.exitCode = 1;
292
300
  return { valid: false, trusted: false, details: {} };
@@ -349,6 +357,7 @@ function promptHiddenCliToken() {
349
357
  });
350
358
  }
351
359
  function activateHostAfterLogin(host, explicitHostOverride) {
360
+ invalidateBusinessSkillSynchronization();
352
361
  if (!explicitHostOverride) return;
353
362
  const normalized = normalizeUrl(host);
354
363
  const config = loadConfig();
@@ -426,12 +435,15 @@ async function switchActiveAccount(program, opts) {
426
435
  }
427
436
  }
428
437
  try {
438
+ invalidateBusinessSkillSynchronization();
429
439
  const selected = activateCredential(host, account);
430
440
  clearCliTokenCache(host);
441
+ const environment = await refreshEnvironmentAfterLogin(host);
431
442
  await printOutput({
432
443
  host,
433
444
  active: true,
434
- account: accountOutput(selected.account)
445
+ account: accountOutput(selected.account),
446
+ ...environment ? { environment } : {}
435
447
  }, program.opts().format || "json");
436
448
  } catch (error) {
437
449
  if (error instanceof CredentialStoreUnreadableError) throw error;
@@ -455,6 +467,7 @@ async function persistDeviceTokens(host, tokens, options = {}) {
455
467
  }
456
468
  let saved;
457
469
  try {
470
+ invalidateBusinessSkillSynchronization();
458
471
  saved = saveCredential(host, {
459
472
  cliToken,
460
473
  ...validation.account ? { account: validation.account } : {},
@@ -473,6 +486,7 @@ async function persistManualCliToken(host, cliToken, options = {}) {
473
486
  const validation = await validateCliTokenOnServer(host, cliToken);
474
487
  let saved;
475
488
  try {
489
+ invalidateBusinessSkillSynchronization();
476
490
  saved = saveCredential(host, {
477
491
  cliToken,
478
492
  ...validation.account ? { account: validation.account } : {},
@@ -512,6 +526,12 @@ function resolveLoginTeClaudeBase(host) {
512
526
  }
513
527
  function registerAuth(program) {
514
528
  const auth = program.command("auth").description("Manage authentication or switch the active account interactively").hook("preAction", (_command, actionCommand) => {
529
+ if (["auth", "login", "set-token", "use", "logout"].includes(actionCommand.name()) && readExternalCliToken()) {
530
+ throw new ExternalCliTokenError(
531
+ "Stored-account changes are unavailable while an external CLI token is selected.",
532
+ "EXTERNAL_CLI_TOKEN_ACTIVE"
533
+ );
534
+ }
515
535
  if (["login", "set-token"].includes(actionCommand.name())) {
516
536
  const host = resolveAuthHost(program, actionCommand.opts());
517
537
  if (host) assertCredentialsReadable(host);
@@ -544,8 +564,9 @@ function registerAuth(program) {
544
564
  const tokens2 = await pollDeviceFlow(teClaudeBase, opts.deviceCode, {}, emit);
545
565
  const saved2 = await persistDeviceTokens(host, tokens2, { add: opts.add });
546
566
  activateHostAfterLogin(host, explicitHost);
567
+ const environment2 = await refreshEnvironmentAfterLogin(host);
547
568
  emit("Login successful! CLI token saved securely.");
548
- await printOutput(loginSummary(host, saved2), format);
569
+ await printOutput({ ...loginSummary(host, saved2), ...environment2 ? { environment: environment2 } : {} }, format);
549
570
  return;
550
571
  }
551
572
  if (opts.wait === false) {
@@ -564,8 +585,9 @@ function registerAuth(program) {
564
585
  const tokens = await runDeviceFlow(teClaudeBase, { noBrowser }, emit);
565
586
  const saved = await persistDeviceTokens(host, tokens, { add: opts.add });
566
587
  activateHostAfterLogin(host, explicitHost);
588
+ const environment = await refreshEnvironmentAfterLogin(host);
567
589
  emit("Login successful! CLI token saved securely.");
568
- await printOutput(loginSummary(host, saved), format);
590
+ await printOutput({ ...loginSummary(host, saved), ...environment ? { environment } : {} }, format);
569
591
  } catch (error) {
570
592
  if (error instanceof CredentialStoreUnreadableError) throw error;
571
593
  if (error instanceof DeviceFlowUnsupportedError) {
@@ -608,9 +630,10 @@ function registerAuth(program) {
608
630
  try {
609
631
  const saved = await persistManualCliToken(host, cliToken, { add: opts.add });
610
632
  activateHostAfterLogin(host, explicitHost);
633
+ const environment = await refreshEnvironmentAfterLogin(host);
611
634
  process.stderr.write(`[ae-cli] CLI token verified and saved securely for ${host}
612
635
  `);
613
- await printOutput(manualTokenSummary(host, saved), program.opts().format || "json");
636
+ await printOutput({ ...manualTokenSummary(host, saved), ...environment ? { environment } : {} }, program.opts().format || "json");
614
637
  } catch (error) {
615
638
  if (error instanceof CredentialStoreUnreadableError) throw error;
616
639
  if (error instanceof PermissionError) {
@@ -644,6 +667,22 @@ function registerAuth(program) {
644
667
  }, program.opts().format || "json");
645
668
  return;
646
669
  }
670
+ const external = readExternalCliToken(host);
671
+ if (external) {
672
+ const state = await validateExistingCliToken(host, external.token, true);
673
+ if (!state.valid) return;
674
+ await printOutput({
675
+ authenticated: true,
676
+ host,
677
+ source: external.source,
678
+ cli_token: {
679
+ status: state.trusted ? "trusted" : "valid",
680
+ ...state.details.cliTokenExpiresAt ? { expires_at: state.details.cliTokenExpiresAt } : {}
681
+ },
682
+ ...state.details.account ? { account: accountOutput(state.details.account) } : {}
683
+ }, program.opts().format || "json");
684
+ return;
685
+ }
647
686
  const active = getActiveCredential(host);
648
687
  if (active) {
649
688
  const state = await validateExistingCliToken(host, active.cliToken);
@@ -706,18 +745,21 @@ function registerAuth(program) {
706
745
  process.exit(1);
707
746
  }
708
747
  clearCliTokenCache(host);
748
+ invalidateBusinessSkillSynchronization();
709
749
  if (opts.all) {
710
750
  clearAllCredentials(host);
711
751
  await printOutput({ cleared: true, all: true, host }, program.opts().format || "json");
712
752
  return;
713
753
  }
714
754
  const result = removeActiveCredential(host);
755
+ const environment = result.active ? await refreshEnvironmentAfterLogin(host) : void 0;
715
756
  await printOutput({
716
757
  cleared: !!result.removed,
717
758
  all: false,
718
759
  host,
719
760
  remaining_accounts: listCredentials(host).length,
720
- ...result.active?.account ? { active_account: accountOutput(result.active.account) } : {}
761
+ ...result.active?.account ? { active_account: accountOutput(result.active.account) } : {},
762
+ ...environment ? { environment } : {}
721
763
  }, program.opts().format || "json");
722
764
  });
723
765
  }