@thinkingai/ae-cli 6.0.52 → 6.0.54

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 (185) hide show
  1. package/README.md +35 -10
  2. package/README.zh.md +32 -10
  3. package/bin/ae-cli.js +6 -1
  4. package/cli-installation-guide.md +91 -0
  5. package/dist/{auth-XZNXFRJS.js → auth-MBWRZTB6.js} +171 -13
  6. package/dist/automation-NWWVLWG2.js +459 -0
  7. package/dist/{capability-RJZ4KRGP.js → capability-7SSN6PNZ.js} +11 -6
  8. package/dist/chunk-4655PUNX.js +43 -0
  9. package/dist/{chunk-4NRCTUZJ.js → chunk-5XJYLEVC.js} +4 -4
  10. package/dist/{chunk-JOCDD4ON.js → chunk-7QXISROD.js} +1 -1
  11. package/dist/{chunk-EQ255HKO.js → chunk-AP7YP2NX.js} +2 -2
  12. package/dist/{chunk-DVMLWQD4.js → chunk-CT7QDJS6.js} +2 -2
  13. package/dist/chunk-D6ACFILC.js +56 -0
  14. package/dist/{chunk-HFGZGYCG.js → chunk-EOYSKMXN.js} +264 -10
  15. package/dist/{chunk-57RRFUEZ.js → chunk-FMNNGNYO.js} +43 -8
  16. package/dist/{chunk-7XGFSUOM.js → chunk-GIK6EDUG.js} +291 -84
  17. package/dist/{chunk-WEPZ5M3Z.js → chunk-HBLK3ZHW.js} +7 -4
  18. package/dist/chunk-HVHR4SCP.js +133 -0
  19. package/dist/{chunk-DX5CDO34.js → chunk-KFNMQTZI.js} +580 -214
  20. package/dist/{chunk-HBGADCKA.js → chunk-PLE722AJ.js} +28 -11
  21. package/dist/chunk-RK6GLDGI.js +27 -0
  22. package/dist/{chunk-V2NUHPXF.js → chunk-S6M42KND.js} +1 -1
  23. package/dist/{chunk-7FTTULED.js → chunk-UQ77JXYH.js} +7 -3
  24. package/dist/{chunk-MAPZ7VB6.js → chunk-WNGFSIOB.js} +20 -1
  25. package/dist/{chunk-L2QUIZTS.js → chunk-ZIQWCZTS.js} +3 -3
  26. package/dist/{community-report-client-CU22W53K.js → community-report-client-PEERQCX2.js} +1 -1
  27. package/dist/{config-XO3LI3SA.js → config-FF6YVJKI.js} +29 -10
  28. package/dist/context-YAE3QXP3.js +136 -0
  29. package/dist/{data-integration-HNGUKFIC.js → data-integration-HESZET7E.js} +6 -6
  30. package/dist/index.js +169 -55
  31. package/dist/{local-data-upload-client-GTRIT64F.js → local-data-upload-client-TWMHFLUA.js} +1 -1
  32. package/dist/memory-62BJOULV.js +580 -0
  33. package/dist/{metadata-JAQW7KGZ.js → metadata-7CUMWIB4.js} +7 -7
  34. package/dist/{model-RNPQXIBI.js → model-SBV2JFJI.js} +9 -5
  35. package/dist/{personal-semantic-preference-QCZ2IZTK.js → personal-semantic-preference-6SRCYPGE.js} +119 -11
  36. package/dist/{project-semantic-64JURXKF.js → project-semantic-YYEM4OSU.js} +7 -7
  37. package/dist/{sync-O45NXEQY.js → sync-SU33KYX7.js} +12 -8
  38. package/dist/{te-agent-K5MSPNHJ.js → te-agent-F5QBZSQA.js} +423 -494
  39. package/dist/{te-analysis-KQKCAI5H.js → te-analysis-U4I2W2WC.js} +1090 -67
  40. package/dist/{te-community-4OYU3BDA.js → te-community-PFLDLPP4.js} +3 -3
  41. package/dist/{te-dataops-NFIPB6FX.js → te-dataops-FOQSRIAZ.js} +644 -276
  42. package/dist/{te-engage-HSVSRW22.js → te-engage-ZX76CNAB.js} +6 -6
  43. package/dist/{te-kb-3TS73NO6.js → te-kb-MHDOST62.js} +666 -244
  44. package/dist/{te-system-STMHLS5J.js → te-system-J2FQF5ER.js} +6 -6
  45. package/dist/{te-team-3I5AOX3N.js → te-team-5UOZPTU3.js} +6 -6
  46. package/dist/things-VPPXXLHB.js +1091 -0
  47. package/dist/{update-RZXLPCRH.js → update-EEUTEI6R.js} +59 -51
  48. package/dist/workspace-O3EEIYQM.js +554 -0
  49. package/package.json +30 -11
  50. package/skills/ae-agent/SKILL.md +95 -140
  51. package/skills/ae-agent/references/add-model.md +1 -1
  52. package/skills/ae-agent/references/create-agent.md +1 -1
  53. package/skills/ae-agent/references/find-archived-conversations.md +12 -5
  54. package/skills/ae-agent/references/get-agent.md +1 -1
  55. package/skills/ae-agent/references/list-agents.md +2 -2
  56. package/skills/ae-agent/references/list-models.md +2 -2
  57. package/skills/ae-agent/references/notification.md +40 -0
  58. package/skills/ae-agent/references/restore-conversation.md +3 -1
  59. package/skills/ae-analysis/SKILL.md +76 -15
  60. package/skills/ae-analysis/references/agent_review_submit_to_page.md +2 -0
  61. package/skills/ae-analysis/references/ai_models/event.md +6 -1
  62. package/skills/ae-analysis/references/ai_models/funnel.md +12 -4
  63. package/skills/ae-analysis/references/ai_models/heat_map.md +23 -0
  64. package/skills/ae-analysis/references/ai_models/interval.md +24 -0
  65. package/skills/ae-analysis/references/ai_models/path.md +20 -0
  66. package/skills/ae-analysis/references/ai_models/prop_analysis.md +2 -0
  67. package/skills/ae-analysis/references/ai_models/rank_list.md +30 -0
  68. package/skills/ae-analysis/references/ai_models/retention.md +45 -1
  69. package/skills/ae-analysis/references/ai_models/revenue.md +20 -2
  70. package/skills/ae-analysis/references/ai_models/tag.md +2 -0
  71. package/skills/ae-analysis/references/ai_models.md +96 -0
  72. package/skills/ae-analysis/references/analysis_data_retrieval.md +4 -0
  73. package/skills/ae-analysis/references/asset_batch_info_export.md +10 -0
  74. package/skills/ae-analysis/references/asset_batch_sql_export.md +13 -1
  75. package/skills/ae-analysis/references/asset_export.md +12 -1
  76. package/skills/ae-analysis/references/asset_list.md +1 -0
  77. package/skills/ae-analysis/references/asset_search.md +11 -5
  78. package/skills/ae-analysis/references/bi_panel_list.md +1 -1
  79. package/skills/ae-analysis/references/catalog_list.md +1 -1
  80. package/skills/ae-analysis/references/collaboration.md +48 -0
  81. package/skills/ae-analysis/references/command_index.md +26 -17
  82. package/skills/ae-analysis/references/dashboard_list.md +4 -4
  83. package/skills/ae-analysis/references/dashboard_move.md +21 -0
  84. package/skills/ae-analysis/references/dashboard_report_add.md +2 -0
  85. package/skills/ae-analysis/references/dashboard_report_data_export.md +2 -0
  86. package/skills/ae-analysis/references/dashboard_report_get.md +19 -0
  87. package/skills/ae-analysis/references/dashboard_report_update.md +27 -0
  88. package/skills/ae-analysis/references/dashboard_update.md +1 -1
  89. package/skills/ae-analysis/references/event_export.md +3 -1
  90. package/skills/ae-analysis/references/event_report_presentation.md +76 -0
  91. package/skills/ae-analysis/references/feedback_submit.md +37 -0
  92. package/skills/ae-analysis/references/governance_recommendation_auto_review.md +71 -0
  93. package/skills/ae-analysis/references/governance_recommendation_export.md +11 -0
  94. package/skills/ae-analysis/references/metadata_resolution.md +18 -3
  95. package/skills/ae-analysis/references/metric_export.md +3 -1
  96. package/skills/ae-analysis/references/metric_list.md +1 -1
  97. package/skills/ae-analysis/references/operation_record_export.md +10 -0
  98. package/skills/ae-analysis/references/personal_semantic_preference_add.md +2 -2
  99. package/skills/ae-analysis/references/personal_semantic_preference_get.md +6 -4
  100. package/skills/ae-analysis/references/personal_semantic_preference_list.md +5 -3
  101. package/skills/ae-analysis/references/personal_semantic_preference_review.md +9 -0
  102. package/skills/ae-analysis/references/personal_semantic_preference_review_list.md +7 -0
  103. package/skills/ae-analysis/references/personal_semantic_preference_submit.md +7 -0
  104. package/skills/ae-analysis/references/project_semantic_knowledge_wiki.md +91 -32
  105. package/skills/ae-analysis/references/project_semantic_knowledge_wiki_plan_schema.md +99 -1
  106. package/skills/ae-analysis/references/property_export.md +3 -1
  107. package/skills/ae-analysis/references/report_create.md +17 -3
  108. package/skills/ae-analysis/references/report_data_export.md +6 -0
  109. package/skills/ae-analysis/references/report_get.md +7 -1
  110. package/skills/ae-analysis/references/report_list.md +5 -5
  111. package/skills/ae-analysis/references/report_update.md +20 -3
  112. package/skills/ae-analysis/references/sql_table_columns.md +4 -4
  113. package/skills/ae-analysis/references/sql_table_list.md +5 -5
  114. package/skills/ae-analysis/references/system_query_monitor_overview.md +2 -0
  115. package/skills/ae-analysis/references/system_query_task_cancel.md +2 -0
  116. package/skills/ae-analysis/references/system_query_task_export.md +6 -2
  117. package/skills/ae-analysis/references/system_query_task_get.md +2 -0
  118. package/skills/ae-analysis/references/system_query_task_list.md +7 -3
  119. package/skills/ae-analysis/references/system_query_task_options.md +2 -2
  120. package/skills/ae-analysis/references/system_query_task_realtime_list.md +15 -0
  121. package/skills/ae-analysis/references/user_cluster_models.md +8 -0
  122. package/skills/ae-analysis/references/user_tag_create.md +7 -1
  123. package/skills/ae-analysis/references/user_tag_get.md +1 -1
  124. package/skills/ae-analysis/references/user_tag_models.md +20 -2
  125. package/skills/ae-analysis/references/user_tag_refresh.md +1 -1
  126. package/skills/ae-analysis/references/user_tag_update.md +2 -2
  127. package/skills/ae-analysis/scripts/project-semantic-knowledge-wiki/build-empty-skeleton.mjs +105 -0
  128. package/skills/ae-analysis/scripts/project-semantic-knowledge-wiki/build-project-semantic-wiki.mjs +669 -29
  129. package/skills/ae-analysis/scripts/project-semantic-knowledge-wiki/company-kb.mjs +21 -8
  130. package/skills/ae-analysis/scripts/project-semantic-knowledge-wiki/default-compile-rules.md +28 -10
  131. package/skills/ae-analysis/scripts/project-semantic-knowledge-wiki/default-compile-schema.md +66 -0
  132. package/skills/ae-analysis/scripts/project-semantic-knowledge-wiki/generate-build-ir.mjs +285 -24
  133. package/skills/ae-analysis/scripts/project-semantic-knowledge-wiki/package-wiki-source-zip.mjs +262 -30
  134. package/skills/ae-analysis/scripts/project-semantic-knowledge-wiki/plan-kb-source-sync.mjs +1 -1
  135. package/skills/ae-analysis/scripts/project-semantic-knowledge-wiki/precompiled-source.mjs +46 -2
  136. package/skills/ae-analysis/scripts/project-semantic-knowledge-wiki/prepare-compile-schema.mjs +64 -0
  137. package/skills/ae-analysis/scripts/project-semantic-knowledge-wiki/refresh-state-parts.mjs +91 -0
  138. package/skills/ae-automation/SKILL.md +16 -0
  139. package/skills/ae-automation/references/cli.md +53 -0
  140. package/skills/ae-automation/references/command_index.md +17 -0
  141. package/skills/ae-capability/SKILL.md +73 -2
  142. package/skills/ae-capability/references/collaboration.md +48 -0
  143. package/skills/ae-community/SKILL.md +5 -1
  144. package/skills/ae-community/references/collaboration.md +48 -0
  145. package/skills/ae-current-context/SKILL.md +3 -2
  146. package/skills/ae-data-integration/SKILL.md +4 -0
  147. package/skills/ae-data-integration/references/collaboration.md +48 -0
  148. package/skills/ae-dataops/SKILL.md +54 -74
  149. package/skills/ae-dataops/references/collaboration.md +48 -0
  150. package/skills/ae-dataops/references/dataops-backfill.md +23 -18
  151. package/skills/ae-dataops/references/dataops-flow-create.md +74 -23
  152. package/skills/ae-dataops/references/dataops-flow-monitor.md +45 -13
  153. package/skills/ae-dataops/references/dataops-integration.md +57 -30
  154. package/skills/ae-dataops/references/dataops-query.md +21 -4
  155. package/skills/ae-dataops/references/dataops-table.md +143 -11
  156. package/skills/ae-engage/SKILL.md +21 -6
  157. package/skills/ae-engage/references/channel-mgmt.md +3 -3
  158. package/skills/ae-engage/references/collaboration.md +48 -0
  159. package/skills/ae-engage/references/scene-config-channel.md +4 -4
  160. package/skills/ae-generate-tracking-plan/SKILL.md +4 -0
  161. package/skills/ae-generate-tracking-plan/references/collaboration.md +48 -0
  162. package/skills/ae-kb/SKILL.md +70 -12
  163. package/skills/ae-kb/references/analysis-workflow.md +73 -36
  164. package/skills/ae-kb/references/collaboration.md +48 -0
  165. package/skills/ae-kb/references/query-workflow.md +67 -33
  166. package/skills/ae-kb/references/schema-import.md +32 -0
  167. package/skills/ae-kb/references/source-mutations.md +6 -4
  168. package/skills/ae-kb/references/text-sources.md +53 -0
  169. package/skills/ae-kb-discovery/SKILL.md +8 -3
  170. package/skills/ae-kb-discovery/references/collaboration.md +48 -0
  171. package/skills/ae-metadata/SKILL.md +20 -12
  172. package/skills/ae-metadata/references/collaboration.md +48 -0
  173. package/skills/ae-team/SKILL.md +23 -17
  174. package/skills/ae-things/SKILL.md +85 -0
  175. package/skills/ae-things/references/cli.md +103 -0
  176. package/skills/ae-things-progress/SKILL.md +43 -0
  177. package/skills/ae-things-review/SKILL.md +42 -0
  178. package/skills/ae-workspace/SKILL.md +43 -0
  179. package/skills/ae-workspace/references/commands.md +51 -0
  180. package/dist/chunk-E2JKXMVO.js +0 -29
  181. package/dist/context-IFJI3LIT.js +0 -46
  182. package/dist/memory-QGPSNCQS.js +0 -892
  183. package/skills/ae-agent/references/create-automation.md +0 -125
  184. package/skills/ae-agent/references/list-automations.md +0 -56
  185. package/skills/ae-agent/references/update-automation.md +0 -107
package/README.md CHANGED
@@ -15,8 +15,9 @@ The CLI is designed around:
15
15
  ## Requirements
16
16
 
17
17
  - Node.js 20 or later.
18
+ - macOS, Linux, or native Windows (PowerShell / Command Prompt); WSL is optional.
18
19
  - Access to the npm registry for CLI installation.
19
- - Access to GitHub when installing Skills initially or when the local Skills fallback cannot be used.
20
+ - Access to GitHub only when the bundled Skills source cannot be used.
20
21
 
21
22
  ## Installation
22
23
 
@@ -25,10 +26,12 @@ For setup through Codex, Claude Code, Cursor, or another terminal-capable AI Age
25
26
  Install the public CLI and Agent Skills:
26
27
 
27
28
  ```bash
28
- npm install -g @thinkingai/ae-cli
29
- npx -y skills add ThinkingAIAgenticEngine/ae-cli -g -y
29
+ npx @thinkingai/ae-cli@latest install
30
+ npx @thinkingai/ae-cli@latest install --format json
30
31
  ```
31
32
 
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).
34
+
32
35
  The Skills teach supported coding Agents, including Claude Code, Codex, Cursor, and similar tools, how to discover and call `ae-cli`.
33
36
 
34
37
  Install optional, approved scenario Skills with an interactive category picker:
@@ -57,6 +60,10 @@ ae-cli update
57
60
  ae-cli update --dry-run
58
61
  ```
59
62
 
63
+ 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
+
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.
66
+
60
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.
61
68
 
62
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.
@@ -126,7 +133,7 @@ The table covers every current root command individually. Use `ae-cli --help` fo
126
133
  | Engage | `engage-workbench` | Engage workbench and to-do management |
127
134
  | Engage | `engage-query` | Engage queries, asynchronous exports, and artifact management |
128
135
  | DataOps | `dataops_repo` | Data-warehouse and data-source management |
129
- | DataOps | `dataops_datatable` | Data-table lifecycle management |
136
+ | DataOps | `dataops_datatable` | Table/view lifecycle management, including recycling, recycle-bin discovery, and permanent deletion |
130
137
  | DataOps | `dataops_flow` | Development flows, scheduling, and backfill-job management |
131
138
  | DataOps | `dataops_ide` | IDE queries and result downloads |
132
139
  | DataOps | `dataops_integration` | Data-integration task management |
@@ -134,15 +141,19 @@ The table covers every current root command individually. Use `ae-cli --help` fo
134
141
  | Agent platform | `kb` | Knowledge-base lifecycle, LLM Q&A, and deterministic index/grep/read retrieval |
135
142
  | Agent platform | `agent` | Agents, approvals, automations, models, MCP servers, Skills, attachments, credentials, and sandbox tools |
136
143
  | Agent platform | `context` | Read the current product-page context authorized for the active Agent Run |
137
- | Agent platform | `memory` | User memory, Top-K context writing, and actual-usage accounting |
144
+ | Agent platform | `memory` | AgentSpace memory, drafts, shared review, extraction jobs, revisions, and state transitions |
138
145
  | Agent platform | `team` | Agent Team and TeamRun execution, chat, results, and artifacts |
139
146
  | Agent platform | `system` | Root/admin management of members, sandboxes, tools, models, usage, quotas, and channels |
140
147
  | General tools | `capability` | Capability discovery, schema inspection, validation, dry-run, and generic execution |
141
148
  | General tools | `auth` | Host-scoped login, status, and multi-account management |
142
149
  | General tools | `config` | Add, switch, rename, and remove Host environments |
143
- | General tools | `sync` | Push or pull local Skills and MCPs to/from the Agent application |
144
- | General tools | `model` | Inspect and switch the current workspace model inside an Agent sandbox |
150
+ | General tools | `sync` | Push or pull local Skills and MCPs to/from the Agent application; blocked in AgentSpace context |
151
+ | General tools | `model` | Inspect and switch the current workspace model inside an Agent sandbox; blocked in AgentSpace context |
145
152
  | General tools | `update` | Synchronize CLI and Skills to the version required by the current Host |
153
+ | General tools | `install` | Install and verify CLI and matching global Skills |
154
+ | Agent platform | `workspace` | AgentSpace context, profiles, capabilities, members, activities, and lifecycle |
155
+ | Agent platform | `things` | Workspace issues, collaborators, timeline, archive, and restore |
156
+ | Agent platform | `automation` | Automation configuration, execution, history, and results |
146
157
  <!-- root-command-surface:end -->
147
158
 
148
159
  ## Capability Gateway
@@ -164,6 +175,10 @@ Use `validate` while fixing complex nested input. Use `dry-run` when you need th
164
175
 
165
176
  Gateway-backed features follow the [Capability command admission rules](docs/capability-command-admission.md). Common workflows may have curated commands; long-tail capabilities remain dynamically discoverable.
166
177
 
178
+ Event-report presentation is separate from its query definition: `analysis report create|update --presentation '{"chart_type":"bar","table_layout":"event"}'` sets the source chart/result-table layout, and `report get` returns its effective presentation. On same-model updates, omit presentation to preserve the saved chart and result-table layout. For a table card on an analysis board, use `analysis dashboard-report get|update` with exact project/dashboard/report IDs; `update --chart-type table --table-layout event --date-outside false` changes only that card, preserving the source definition and other boards. This presentation contract currently supports event reports only. See [report update](skills/ae-analysis/references/report_update.md) and [card update](skills/ae-analysis/references/dashboard_report_update.md).
179
+
180
+ Event combination charts use source `presentation.chart_type=combo` and `series` items `{metric_index:1,type:"bar",axis:"primary"}` (`type=bar|line`, `axis=primary|secondary`). Indexes are current 1-based `definition.metrics` positions; updates use the current report version, subset patches, or explicit `series: []`/`chart_type=line` resets. Board trends inherit source series, so source edits affect its other trend cards; `dashboard-report update --chart-type combo` selects existing combo, not a card-local override. Cumulative line is not combo. See [combination-chart scope and safety](skills/ae-analysis/references/event_report_presentation.md).
181
+
167
182
  `analysis user-tag create|update` supports periodic refresh in one command: pass `--auto-refresh-schedule '{"frequency":"daily","time":"02:30"}'` (also weekly/monthly), or `--auto-refresh-cron`. Use `--enable-auto-refresh false` to disable it. Scheduling-only updates do not recompute; omitted settings preserve the existing plan. See the [tag create](skills/ae-analysis/references/user_tag_create.md) and [tag update](skills/ae-analysis/references/user_tag_update.md) references.
168
183
 
169
184
  ## Authentication and Environments
@@ -176,6 +191,10 @@ For scripts and agents, use the non-interactive subcommands:
176
191
  ```bash
177
192
  ae-cli auth login --host https://host-a.example.com
178
193
  ae-cli auth status --host https://host-a.example.com
194
+ # Import a CLI token copied from External Access Management (hidden prompt)
195
+ ae-cli auth set-token --host https://host-a.example.com
196
+ # 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
179
198
  # For the uncommon case where one Host needs multiple accounts
180
199
  ae-cli auth login --host https://host-a.example.com --add
181
200
  ae-cli auth list --host https://host-a.example.com
@@ -195,6 +214,8 @@ ae-cli config remove pre-production --yes
195
214
 
196
215
  A regular `auth login` keeps the simple one-Host/one-account behavior and replaces credentials for that Host; use `--add` only when other accounts must be retained. `auth status` reports CLI-token state only. A new backend can also provide account identity and expiration; when an older backend does not support `/validate`, the CLI preserves the historical behavior of trusting the stored CLI token and omits `account` instead of returning null fields.
197
216
 
217
+ `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
+
198
219
  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.
199
220
 
200
221
  Login uses a cross-platform device-code flow. Use `--no-browser` when the environment cannot open a browser.
@@ -268,7 +289,7 @@ ae-cli agent +list-agents
268
289
  ae-cli agent +list-models
269
290
  ae-cli agent +list-mcps
270
291
  ae-cli agent +list-skills
271
- ae-cli agent +list-automations
292
+ ae-cli automation list
272
293
  ae-cli agent +list-attachments
273
294
  ae-cli agent approval-type list
274
295
  ae-cli agent approval-request list --status pending
@@ -311,14 +332,17 @@ The npm package includes the same `skills/` directory used by the public reposit
311
332
  | `ae-community` | Community analysis and reporting |
312
333
  | `ae-data-integration` | Local CSV/JSON/Excel inspection, mapping, conversion, upload, and reusable handoff |
313
334
  | `ae-kb`, `ae-kb-discovery` | Knowledge-base lifecycle, Q&A, deterministic retrieval, and read-only knowledge-base discovery |
314
- | `ae-agent`, `ae-system`, `ae-team` | Agent resources and user memory, administration, and TeamRun workflows |
335
+ | `ae-workspace` | AgentSpace context, profiles, capabilities, members, activities, and lifecycle |
336
+ | `ae-things`, `ae-things-progress`, `ae-things-review` | Workspace issues, progress digests, and review summaries |
337
+ | `ae-automation` | Automation configuration, execution, history, and results |
338
+ | `ae-agent`, `ae-system`, `ae-team` | Agent resources, AgentSpace memory, administration, and TeamRun workflows |
315
339
  | `ae-generate-tracking-plan`, `ae-generate-tracking-code` | Tracking-plan and tracking-code generation |
316
340
  | `ae-data-integration-helper` | SDK and LogBus2 integration guidance |
317
341
 
318
342
  Reinstall all public Skills with:
319
343
 
320
344
  ```bash
321
- npx -y skills add ThinkingAIAgenticEngine/ae-cli -g -y
345
+ ae-cli install
322
346
  ```
323
347
 
324
348
  ## Development
@@ -361,6 +385,7 @@ npm run verify:readme
361
385
  npm run verify:auth-credentials
362
386
  npm run verify:update-check
363
387
  npm run verify:version-sync
388
+ npm run verify:install
364
389
  ```
365
390
 
366
391
  ## Changelog
package/README.zh.md CHANGED
@@ -15,8 +15,9 @@ CLI 的核心设计包括:
15
15
  ## 环境要求
16
16
 
17
17
  - Node.js 20 或更高版本。
18
+ - 支持 macOS、Linux 和原生 Windows(PowerShell / CMD),无需安装 WSL。
18
19
  - 安装 CLI 时能够访问 npm 仓库。
19
- - 首次安装 Skills,或本地 Skills 来源不可用时,能够访问 GitHub。
20
+ - 内置 Skills 来源不可用时,能够访问 GitHub。
20
21
 
21
22
  ## 安装
22
23
 
@@ -24,15 +25,17 @@ CLI 的核心设计包括:
24
25
 
25
26
  可直接复制给 Agent,并把 `<AE_HOST>` 替换为你的 AE 地址:
26
27
 
27
- > 请阅读 https://raw.githubusercontent.com/ThinkingAIAgenticEngine/ae-cli/main/cli-installation-guide.md 并按说明帮我安装或升级 AE CLI。我的 AE 地址是 `<AE_HOST>`。只安装 AE CLI 和配套 Skills,不要修改当前项目;遇到登录授权或需要管理员权限时请暂停并提示我。
28
+ > 请按[安装指南](./cli-installation-guide.md)中的“AI installation prompt”帮助我安装 AE CLI;全局安装 Skills,并根据最终 CLI/Skills 验证结果判断成功。
28
29
 
29
30
  安装公开版 CLI 和 Agent Skills:
30
31
 
31
32
  ```bash
32
- npm install -g @thinkingai/ae-cli
33
- npx -y skills add ThinkingAIAgenticEngine/ae-cli -g -y
33
+ npx @thinkingai/ae-cli@latest install
34
+ npx @thinkingai/ae-cli@latest install --format json
34
35
  ```
35
36
 
37
+ 安装器检查 Node.js 20+、安装并验证 CLI,再将同版本 Skills 全局安装到 `~/.agents/skills`,公共文件只写入一次,再自动向需要独立目录的客户端分发副本,无需选择 Agent;之后安装的 Codex、Cursor 也可共享这些 Skills。支持 `--dry-run`、`--format json` 和可选的 `--host <AE_HOST>`。验证成功后不显示无关的项目级客户端告警;文件缺失和 YAML 错误仍判为失败。未登录不算安装失败。详见[安装指南](./cli-installation-guide.md)。
38
+
36
39
  Skills 会帮助 Claude Code、Codex、Cursor 等编码 Agent 理解、发现并调用 `ae-cli`。
37
40
 
38
41
  按业务分类交互安装可选的已准出场景 Skill:
@@ -61,6 +64,10 @@ ae-cli update
61
64
  ae-cli update --dry-run
62
65
  ```
63
66
 
67
+ 更新与 `install` 复用全局 Skills 安装和校验。旧包无需包含安装器或生成的清单,直接以目标包内置 Skills 为准。CLI 安装后 Skills 失败会返回部分成功信息,修复后可重复执行。
68
+
69
+ 自动同步在登录后的普通命令中触发,集群版本检查最长缓存 24 小时;`ae-cli update --host <AE_HOST>` 可立即查询。降级后,后续更新由旧版 CLI 自身执行,也受旧版实现限制。需要用新安装逻辑匹配旧集群时,可运行 `npx @thinkingai/ae-cli@latest update --host <AE_HOST>`,目标仍是集群要求的版本。
70
+
64
71
  `ae-cli update` 安装当前 Host 要求的精确版本,不依赖 npm `latest`。更新时优先从已安装的 npm 包同步 Skills,本地来源失败后才回退到对应的 GitHub tag。
65
72
 
66
73
  从 `6.0.37` 和 `6.1.9` 维护线开始,普通业务命令可以自动升级或降级到环境要求的版本。同步成功后,旧进程会返回 `AE_CLI_VERSION_SYNCED`;重新执行原命令,即可使用新的 CLI 和 Skills。安装失败会给出提示,但不会用安装输出污染业务命令的 JSON 结果。
@@ -130,7 +137,7 @@ ae-cli capability list --domain analysis --jq '.data.capabilities[] | .id'
130
137
  | 运营 | `engage-workbench` | 运营工作台和待办管理 |
131
138
  | 运营 | `engage-query` | 运营查询、异步导出和产物管理 |
132
139
  | DataOps | `dataops_repo` | 数仓和数据源管理 |
133
- | DataOps | `dataops_datatable` | 数据表生命周期管理 |
140
+ | DataOps | `dataops_datatable` | 表/视图生命周期管理,包括回收、查询回收站与彻底删除 |
134
141
  | DataOps | `dataops_flow` | 开发流程、调度和补数作业管理 |
135
142
  | DataOps | `dataops_ide` | IDE 查询及结果下载 |
136
143
  | DataOps | `dataops_integration` | 数据集成任务管理 |
@@ -138,15 +145,19 @@ ae-cli capability list --domain analysis --jq '.data.capabilities[] | .id'
138
145
  | Agent 平台 | `kb` | 知识库生命周期、LLM 问答及确定性的 index/grep/read 检索 |
139
146
  | Agent 平台 | `agent` | Agent、审批、自动化、模型、MCP、Skills、附件、凭证和沙盒工具 |
140
147
  | Agent 平台 | `context` | 读取当前 Agent Run 已授权的产品页面上下文 |
141
- | Agent 平台 | `memory` | 用户记忆、Top-K 上下文写入和实际采用计数 |
148
+ | Agent 平台 | `memory` | AgentSpace 记忆、草稿、共享审核、提取任务、版本与状态治理 |
142
149
  | Agent 平台 | `team` | Agent Team 和 TeamRun 的执行、对话、结果及产物 |
143
150
  | Agent 平台 | `system` | root/admin 的成员、沙盒、工具、模型、用量、配额和渠道管理 |
144
151
  | 通用工具 | `capability` | 能力发现、Schema 查看、参数校验、dry-run 和通用执行 |
145
152
  | 通用工具 | `auth` | 按 Host 登录、查看状态及管理同一 Host 的多个账号 |
146
153
  | 通用工具 | `config` | 添加、切换、重命名和删除 Host 环境 |
147
- | 通用工具 | `sync` | 在本地工作区与 Agent 应用之间推送或拉取 Skills 和 MCP |
148
- | 通用工具 | `model` | 在 Agent 沙盒中查看并切换当前工作区模型 |
154
+ | 通用工具 | `sync` | 在本地工作区与 Agent 应用之间推送或拉取 Skills 和 MCP;在 AgentSpace 上下文中禁用 |
155
+ | 通用工具 | `model` | 在 Agent 沙盒中查看并切换当前工作区模型;在 AgentSpace 上下文中禁用 |
149
156
  | 通用工具 | `update` | 将 CLI 和 Skills 同步到当前 Host 要求的版本 |
157
+ | 通用工具 | `install` | 一键安装、验证 CLI 和同版本全局 Skills |
158
+ | Agent 平台 | `workspace` | AgentSpace 上下文、资料、能力、成员、动态与生命周期 |
159
+ | Agent 平台 | `things` | 工作空间事项、协作成员、时间线、归档与恢复 |
160
+ | Agent 平台 | `automation` | 自动化配置、执行、历史和结果 |
150
161
  <!-- root-command-surface:end -->
151
162
 
152
163
  ## Capability Gateway
@@ -168,6 +179,10 @@ ae-cli capability run analysis.report.list --input input.json
168
179
 
169
180
  Gateway 命令遵循 [Capability 命令收录规则](docs/capability-command-admission.md)。常见工作流可以提供精选命令,长尾能力则保持动态发现。
170
181
 
182
+ 事件报表的展示配置与查询定义分开:`analysis report create|update --presentation '{"chart_type":"bar","table_layout":"event"}'` 设置原报表图形及结果表布局,`report get` 返回实际生效的展示配置。同模型更新时省略 presentation 可保留原有图形和结果表布局。看板表格卡片使用 `analysis dashboard-report get|update`,明确项目、看板和报表 ID;`update --chart-type table --table-layout event --date-outside false` 只改变该卡片,保留原报表定义及其他看板。本次展示配置契约仅支持事件报表。详见[报表更新](skills/ae-analysis/references/report_update.md)和[卡片更新](skills/ae-analysis/references/dashboard_report_update.md)。
183
+
184
+ 事件组合图使用原报表 `presentation.chart_type=combo` 和 `series` 项 `{metric_index:1,type:"bar",axis:"primary"}`(`type=bar|line`,`axis=primary|secondary`)。索引是当前 `definition.metrics` 从 1 开始的位置;更新使用当前报表版本,支持部分指标补丁及显式 `series: []` / `chart_type=line` 重置。看板趋势图继承原报表系列,修改源系列会影响该报表的其他趋势卡片;`dashboard-report update --chart-type combo` 选择已有组合图,不提供卡片独立覆盖。累计折线不等于组合图。详见[组合图作用域与安全规则](skills/ae-analysis/references/event_report_presentation.md)。
185
+
171
186
  `analysis user-tag create|update` 支持一次配置自动更新:传入 `--auto-refresh-schedule '{"frequency":"daily","time":"02:30"}'`(也支持每周、每月),或使用 `--auto-refresh-cron`。用 `--enable-auto-refresh false` 关闭自动更新。仅修改调度计划不触发即时重算;省略调度参数则保留原计划。详见[创建标签](skills/ae-analysis/references/user_tag_create.md)和[更新标签](skills/ae-analysis/references/user_tag_update.md)。
172
187
 
173
188
  ## 认证与多环境
@@ -180,6 +195,10 @@ Gateway 命令遵循 [Capability 命令收录规则](docs/capability-command-adm
180
195
  ```bash
181
196
  ae-cli auth login --host https://host-a.example.com
182
197
  ae-cli auth status --host https://host-a.example.com
198
+ # 导入从“外部访问管理”复制的 CLI Token(隐藏输入)
199
+ ae-cli auth set-token --host https://host-a.example.com
200
+ # 本地脚本或测试使用非交互输入
201
+ printf '%s' "$AE_CLI_TOKEN" | ae-cli auth set-token --host https://host-a.example.com --token-stdin
183
202
  # 少量需要同一 Host 多账号的场景
184
203
  ae-cli auth login --host https://host-a.example.com --add
185
204
  ae-cli auth list --host https://host-a.example.com
@@ -199,6 +218,8 @@ ae-cli config remove pre-production --yes
199
218
 
200
219
  普通 `auth login` 保持一个 Host 一个账号的简单语义,并替换该 Host 已保存的账号;仅在需要时使用 `--add` 保留其他账号。`auth status` 只展示 CLI Token 状态;新版后端可同时返回账号和到期时间,旧版后端不支持 `/validate` 时仍按历史行为信任本地 CLI Token,且不会输出含 null 字段的 `account`。
201
220
 
221
+ `auth set-token` 用于在本地导入从“外部访问管理”复制的 `cli_` Token。默认使用不回显的隐藏输入,`--token-stdin` 支持本地测试等非交互场景。CLI 会先向目标 Host 校验 Token,再替换本地凭证,并写入现有的按 Host 加密凭据库;命令输出不会包含 Token。需要保留同一 Host 的其他账号时增加 `--add`。
222
+
202
223
  新版 CLI 只持久化 CLI Token,不保存 access token 或 refresh token。多账号保存在加密的 V1 凭据文件中,同时维护旧文件格式的当前账号投影,保证 CLI 自动降级后仍可登录;再次升级时会合并旧 CLI 对投影的登录、切换或退出变更。
203
224
 
204
225
  登录使用跨平台设备码流程。当前环境无法打开浏览器时,可使用 `--no-browser`。
@@ -272,7 +293,7 @@ ae-cli agent +list-agents
272
293
  ae-cli agent +list-models
273
294
  ae-cli agent +list-mcps
274
295
  ae-cli agent +list-skills
275
- ae-cli agent +list-automations
296
+ ae-cli automation list
276
297
  ae-cli agent +list-attachments
277
298
  ae-cli agent approval-type list
278
299
  ae-cli agent approval-request list --status pending
@@ -322,7 +343,7 @@ npm 包内包含与公开仓库一致的 `skills/` 目录:
322
343
  重新安装全部公开 Skills:
323
344
 
324
345
  ```bash
325
- npx -y skills add ThinkingAIAgenticEngine/ae-cli -g -y
346
+ ae-cli install
326
347
  ```
327
348
 
328
349
  ## 开发
@@ -365,6 +386,7 @@ npm run verify:readme
365
386
  npm run verify:auth-credentials
366
387
  npm run verify:update-check
367
388
  npm run verify:version-sync
389
+ npm run verify:install
368
390
  ```
369
391
 
370
392
  ## 更新日志
package/bin/ae-cli.js CHANGED
@@ -1,2 +1,7 @@
1
1
  #!/usr/bin/env node
2
- import '../dist/index.js';
2
+ if (Number(process.versions.node.split('.')[0]) < 20) {
3
+ console.error('AE CLI requires Node.js 20 or later. Select a supported Node.js runtime and rerun.');
4
+ process.exitCode = 1;
5
+ } else {
6
+ await import('../dist/index.js');
7
+ }
@@ -0,0 +1,91 @@
1
+ # AE CLI Installation Guide
2
+
3
+ Use the same one-command installer from a terminal or an AI Agent:
4
+
5
+ ```bash
6
+ npx @thinkingai/ae-cli@latest install
7
+ ```
8
+
9
+ No Agent selection is required. Optional usage:
10
+
11
+ ```bash
12
+ npx @thinkingai/ae-cli@latest install --format json
13
+ npx @thinkingai/ae-cli@latest install --host <AE_HOST>
14
+ npx @thinkingai/ae-cli@latest install --dry-run
15
+ ```
16
+
17
+ ## Requirements and global Skills
18
+
19
+ Node.js 20 or later, npm, and npx must be available. The installer does not change the default Node version, use sudo, or modify project dependencies. macOS, Linux, and native Windows are supported. On Windows, use PowerShell or Command Prompt; WSL is optional. Global Skills are installed under the current user's home directory on each platform.
20
+
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
+
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.
24
+
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
+
27
+ ## Verification and output
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.
30
+
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
+
33
+ - Complete verification: `ok: true`.
34
+ - Partial installation: `ok: false`, preserving the CLI result and listing failed Skills and reasons.
35
+ - Unrelated PromptScript/Eve project-only diagnostics and their failure summary are handled internally and not displayed as user warnings after verification succeeds.
36
+ - YAML errors, missing or stale files, supported-client installation errors, CLI version mismatch, and unsuccessful processes remain failures.
37
+
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
+
40
+ ## Host and login
41
+
42
+ `--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.
43
+
44
+ ```bash
45
+ ae-cli auth login --host <AE_HOST> --no-wait
46
+ ```
47
+
48
+ Show the returned `verification_url` to the user. After browser authorization:
49
+
50
+ ```bash
51
+ ae-cli auth login --host <AE_HOST> --device-code <DEVICE_CODE>
52
+ ae-cli auth status --host <AE_HOST>
53
+ ```
54
+
55
+ Never print, copy, or manually save any token.
56
+
57
+ ## Host-compatible upgrades and downgrades
58
+
59
+ ```bash
60
+ ae-cli update --host <AE_HOST>
61
+ ae-cli update --target 6.0.40 --dry-run
62
+ ```
63
+
64
+ The target is the exact `aeCliVersion` returned by the host, not npm latest or the cluster's general product version. CLI and Skills follow that target together. Existing automatic synchronization eligibility, locking, retry limits, and pending-Skills recovery are retained. Automatic changes apply only to the public distribution, after login and during normal commands; help, version, auth, config, install, update, CI, and configured sandbox/skip modes do not initiate automatic synchronization.
65
+
66
+ Host checks are cached for up to 24 hours. A cluster upgrade is discovered on a later eligible command after refresh, not by a background updater. Explicit `ae-cli update --host <AE_HOST>` queries immediately. A successful automatic switch asks the caller to rerun the original command.
67
+
68
+ For example, a CLI with this installer can switch from 6.0.50 to an older 6.0.40 package using that package's bundled Skills. After the switch, the installed 6.0.40 CLI runs future updates with its own historical code; new validation and diagnostic handling do not survive the downgrade. The published 6.0.40 already has automatic upgrade/downgrade support, but invokes an unpinned Skills tool and does not perform this installer's complete verification. Successful version selection does not guarantee historical Skills tooling will work in every Node/network environment.
69
+
70
+ To use the newer installer while still respecting the current host version, including to repair an older updater's failed Skills step:
71
+
72
+ ```bash
73
+ npx @thinkingai/ae-cli@latest update --host <AE_HOST>
74
+ ```
75
+
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.
77
+
78
+ ## Advanced manual troubleshooting
79
+
80
+ Prefer the unified installer. For a specific client or source diagnosis, advanced users can still invoke the external Skills tool directly:
81
+
82
+ ```bash
83
+ npx -y skills@1.5.12 add <INSTALLED_CLI_SKILLS_PATH> -g -y --agent codex
84
+ npx -y skills@1.5.12 list -g --json
85
+ ```
86
+
87
+ Raw manual-tool output is not the AE installer's final result. Do not infer completeness from the list alone, delete unrelated Skills, or overwrite a source link to resolve a conflict.
88
+
89
+ ## AI installation prompt
90
+
91
+ > Install AE CLI and its matching Skills globally. Check Node.js 20+, npm, and npx without changing my default Node version. Run `npx @thinkingai/ae-cli@latest install --format json`, adding `--host <AE_HOST>` only if I supplied a host. No Agent selection is needed. Judge success by the installer's final `ok`, CLI verification, and global Skills verification. The installer handles unrelated project-only client diagnostics internally. If installation fails, report the named Skills and reasons; do not hide YAML errors, missing files, or actual installation failures. Do not modify project files, delete unrelated Skills, use sudo, overwrite an npm source link, or print/copy/save tokens. After successful installation, guide me through device-code login if needed and wait for browser authorization. Then use `ae-cli update --host <AE_HOST>` to match the environment. If an older CLI cannot finish its update, use `npx @thinkingai/ae-cli@latest update --host <AE_HOST>` to retain exact host-version selection. Report the installed version, global Skills directory, verified Skill count, and authentication status.
@@ -1,27 +1,27 @@
1
1
  import { createRequire as __createRequire } from 'node:module'; const require = __createRequire(import.meta.url);
2
- import {
3
- MultiselectCancelled,
4
- promptSingleSelect
5
- } from "./chunk-7K24F7T2.js";
6
2
  import {
7
3
  missingAeHostGuidance,
8
4
  missingAeHostHint
9
5
  } from "./chunk-6ZIQV5GW.js";
10
6
  import {
11
- getLocalCliPackageInfo
12
- } from "./chunk-E2JKXMVO.js";
7
+ MultiselectCancelled,
8
+ promptSingleSelect
9
+ } from "./chunk-7K24F7T2.js";
13
10
  import {
14
11
  resolveHost
15
- } from "./chunk-JOCDD4ON.js";
12
+ } from "./chunk-7QXISROD.js";
16
13
  import {
14
+ getLocalCliPackageInfo,
17
15
  printError,
18
16
  printOutput,
19
17
  runHostCompatCheck
20
- } from "./chunk-DX5CDO34.js";
18
+ } from "./chunk-KFNMQTZI.js";
21
19
  import {
22
20
  CliTokenValidationUnavailableError,
21
+ CredentialStoreUnreadableError,
23
22
  SecureStoreAuthError,
24
23
  activateCredential,
24
+ assertCredentialsReadable,
25
25
  clearAllCredentials,
26
26
  clearCliTokenCache,
27
27
  getActiveCredential,
@@ -31,17 +31,17 @@ import {
31
31
  saveCredential,
32
32
  updateCredentialMetadata,
33
33
  validateCliTokenOnServer
34
- } from "./chunk-7XGFSUOM.js";
34
+ } from "./chunk-GIK6EDUG.js";
35
35
  import {
36
36
  getFallbackCliToken,
37
37
  loadConfig,
38
38
  normalizeUrl,
39
39
  saveConfig
40
- } from "./chunk-7FTTULED.js";
40
+ } from "./chunk-UQ77JXYH.js";
41
41
  import {
42
42
  PermissionError,
43
43
  logger
44
- } from "./chunk-MAPZ7VB6.js";
44
+ } from "./chunk-WNGFSIOB.js";
45
45
 
46
46
  // src/core/device-auth.ts
47
47
  import { execFileSync } from "child_process";
@@ -277,12 +277,77 @@ async function validateExistingCliToken(host, cliToken) {
277
277
  logger.warn(`auth status: ${error.message}; trusting the stored CLI token for compatibility`);
278
278
  return { valid: true, trusted: true, details: {} };
279
279
  }
280
+ if (error instanceof PermissionError) {
281
+ printError("permission", error.message, error.hint, error.code);
282
+ process.exitCode = 1;
283
+ return { valid: false, trusted: false, details: {} };
284
+ }
280
285
  if (!(error instanceof SecureStoreAuthError)) throw error;
281
- printError("auth", error.message);
286
+ printError(
287
+ "auth",
288
+ error.message,
289
+ `Run: ae-cli auth logout --host ${host}, then ae-cli auth login --host ${host}`
290
+ );
282
291
  process.exitCode = 1;
283
292
  return { valid: false, trusted: false, details: {} };
284
293
  }
285
294
  }
295
+ async function readCliTokenFromStdin() {
296
+ let value = "";
297
+ process.stdin.setEncoding("utf8");
298
+ for await (const chunk of process.stdin) value += chunk;
299
+ return value.trim();
300
+ }
301
+ function promptHiddenCliToken() {
302
+ const stdin = process.stdin;
303
+ const stderr = process.stderr;
304
+ if (!stdin.isTTY || !stderr.isTTY) {
305
+ return Promise.reject(new Error(
306
+ "Interactive CLI token input requires a TTY. Pipe the token and add --token-stdin."
307
+ ));
308
+ }
309
+ return new Promise((resolve, reject) => {
310
+ let value = "";
311
+ let settled = false;
312
+ stdin.setRawMode(true);
313
+ stdin.resume();
314
+ stdin.setEncoding("utf8");
315
+ stderr.write("CLI token: ");
316
+ function cleanup() {
317
+ if (settled) return;
318
+ settled = true;
319
+ stdin.setRawMode(false);
320
+ stdin.pause();
321
+ stdin.removeListener("data", onData);
322
+ stderr.write("\n");
323
+ }
324
+ function onData(chunk) {
325
+ for (const key of chunk) {
326
+ if (key === "\r" || key === "\n") {
327
+ cleanup();
328
+ resolve(value.trim());
329
+ return;
330
+ }
331
+ if (key === "" || key === "\x1B") {
332
+ cleanup();
333
+ reject(new Error("CLI token input cancelled."));
334
+ return;
335
+ }
336
+ if (key === "") {
337
+ cleanup();
338
+ resolve(value.trim());
339
+ return;
340
+ }
341
+ if (key === "\x7F" || key === "\b") {
342
+ value = value.slice(0, -1);
343
+ continue;
344
+ }
345
+ if (key >= " ") value += key;
346
+ }
347
+ }
348
+ stdin.on("data", onData);
349
+ });
350
+ }
286
351
  function activateHostAfterLogin(host, explicitHostOverride) {
287
352
  if (!explicitHostOverride) return;
288
353
  const normalized = normalizeUrl(host);
@@ -369,11 +434,13 @@ async function switchActiveAccount(program, opts) {
369
434
  account: accountOutput(selected.account)
370
435
  }, program.opts().format || "json");
371
436
  } catch (error) {
437
+ if (error instanceof CredentialStoreUnreadableError) throw error;
372
438
  printError("auth", error.message);
373
439
  process.exitCode = 1;
374
440
  }
375
441
  }
376
442
  async function persistDeviceTokens(host, tokens, options = {}) {
443
+ assertCredentialsReadable(host);
377
444
  const cliToken = await mintCliToken(host, tokens.access_token);
378
445
  let validation = {};
379
446
  try {
@@ -401,6 +468,24 @@ async function persistDeviceTokens(host, tokens, options = {}) {
401
468
  await runHostCompatCheck(getLocalCliPackageInfo(), host);
402
469
  return saved;
403
470
  }
471
+ async function persistManualCliToken(host, cliToken, options = {}) {
472
+ assertCredentialsReadable(host);
473
+ const validation = await validateCliTokenOnServer(host, cliToken);
474
+ let saved;
475
+ try {
476
+ saved = saveCredential(host, {
477
+ cliToken,
478
+ ...validation.account ? { account: validation.account } : {},
479
+ ...validation.cliTokenExpiresAt ? { cliTokenExpiresAt: validation.cliTokenExpiresAt } : {}
480
+ }, options);
481
+ } catch (error) {
482
+ clearCliTokenCache(host);
483
+ throw error;
484
+ }
485
+ clearCliTokenCache(host);
486
+ await runHostCompatCheck(getLocalCliPackageInfo(), host);
487
+ return saved;
488
+ }
404
489
  function loginSummary(host, credential) {
405
490
  return {
406
491
  authenticated: true,
@@ -408,13 +493,30 @@ function loginSummary(host, credential) {
408
493
  ...credential.account ? { account: accountOutput(credential.account) } : {}
409
494
  };
410
495
  }
496
+ function manualTokenSummary(host, credential) {
497
+ return {
498
+ authenticated: true,
499
+ host,
500
+ source: "manual-cli-token",
501
+ ...credential.account ? { account: accountOutput(credential.account) } : {},
502
+ cli_token: {
503
+ status: "valid",
504
+ ...credential.cliTokenExpiresAt ? { expires_at: credential.cliTokenExpiresAt } : {}
505
+ }
506
+ };
507
+ }
411
508
  function resolveLoginTeClaudeBase(host) {
412
509
  const base = host.replace(/\/+$/, "");
413
510
  const basePath = process.env.TE_CLAUDE_BASE_PATH || "/agent";
414
511
  return base.endsWith(basePath) ? base : base + basePath;
415
512
  }
416
513
  function registerAuth(program) {
417
- const auth = program.command("auth").description("Manage authentication or switch the active account interactively").action(async () => {
514
+ const auth = program.command("auth").description("Manage authentication or switch the active account interactively").hook("preAction", (_command, actionCommand) => {
515
+ if (["login", "set-token"].includes(actionCommand.name())) {
516
+ const host = resolveAuthHost(program, actionCommand.opts());
517
+ if (host) assertCredentialsReadable(host);
518
+ }
519
+ }).action(async () => {
418
520
  await switchActiveAccount(program, {});
419
521
  });
420
522
  auth.command("login").description("Log in to AE; by default replaces this host credentials, --add keeps existing accounts").option("--host <url>", HOST_OPTION_DESC).option("--add", "Add another account for the host and keep existing accounts").option("--no-browser", "Do not auto-open the browser; only print the authorization URL").option("--no-wait", "Print device authorization data and exit; resume with --device-code").option("--device-code <code>", "Resume a split-flow login with the given device code").action(async (opts) => {
@@ -465,6 +567,7 @@ function registerAuth(program) {
465
567
  emit("Login successful! CLI token saved securely.");
466
568
  await printOutput(loginSummary(host, saved), format);
467
569
  } catch (error) {
570
+ if (error instanceof CredentialStoreUnreadableError) throw error;
468
571
  if (error instanceof DeviceFlowUnsupportedError) {
469
572
  printError("auth", error.message, "Upgrade the AE server to a version that supports device login.");
470
573
  process.exit(1);
@@ -477,6 +580,59 @@ function registerAuth(program) {
477
580
  process.exit(1);
478
581
  }
479
582
  });
583
+ auth.command("set-token").description("Validate and securely store a CLI token copied from External Access Management").option("--host <url>", HOST_OPTION_DESC).option("--token-stdin", "Read the CLI token from stdin instead of prompting").option("--add", "Add another account for the host and keep existing accounts").action(async (opts) => {
584
+ const explicitHost = getExplicitAuthHostOverride(program, opts);
585
+ const host = resolveAuthHost(program, opts);
586
+ if (!host) {
587
+ printError("config", "No AE host configured.", missingAeHostHint());
588
+ process.exitCode = 1;
589
+ return;
590
+ }
591
+ let cliToken;
592
+ try {
593
+ cliToken = opts.tokenStdin ? await readCliTokenFromStdin() : await promptHiddenCliToken();
594
+ } catch (error) {
595
+ printError("validation", error.message);
596
+ process.exitCode = 1;
597
+ return;
598
+ }
599
+ if (!/^cli_\S+$/.test(cliToken)) {
600
+ printError(
601
+ "validation",
602
+ "Invalid CLI token format.",
603
+ "Copy a current CLI token from External Access Management; the value must start with cli_."
604
+ );
605
+ process.exitCode = 1;
606
+ return;
607
+ }
608
+ try {
609
+ const saved = await persistManualCliToken(host, cliToken, { add: opts.add });
610
+ activateHostAfterLogin(host, explicitHost);
611
+ process.stderr.write(`[ae-cli] CLI token verified and saved securely for ${host}
612
+ `);
613
+ await printOutput(manualTokenSummary(host, saved), program.opts().format || "json");
614
+ } catch (error) {
615
+ if (error instanceof CredentialStoreUnreadableError) throw error;
616
+ if (error instanceof PermissionError) {
617
+ printError("permission", error.message, error.hint, error.code);
618
+ } else if (error instanceof SecureStoreAuthError) {
619
+ printError(
620
+ "auth",
621
+ error.message,
622
+ "Copy a current CLI token from External Access Management and try again."
623
+ );
624
+ } else if (error instanceof CliTokenValidationUnavailableError) {
625
+ printError(
626
+ "api",
627
+ error.message,
628
+ "Verify the AE host and deployment, then retry. The token was not saved."
629
+ );
630
+ } else {
631
+ printError("api", error.message);
632
+ }
633
+ process.exitCode = 1;
634
+ }
635
+ });
480
636
  auth.command("status").description("Show the active CLI-token authentication status for a host").option("--host <url>", HOST_OPTION_DESC).action(async (opts) => {
481
637
  const host = resolveAuthHost(program, opts);
482
638
  if (!host) {
@@ -569,6 +725,8 @@ export {
569
725
  activateHostAfterLogin,
570
726
  buildAccountSelectionItems,
571
727
  persistDeviceTokens,
728
+ persistManualCliToken,
729
+ promptHiddenCliToken,
572
730
  registerAuth,
573
731
  resolveLoginTeClaudeBase
574
732
  };