wepscli 0.1.0

This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
Files changed (130) hide show
  1. package/README.md +293 -0
  2. package/dist/WEPSCLI-shell/agent-runtime.js +824 -0
  3. package/dist/WEPSCLI-shell/agent-runtime.js.map +1 -0
  4. package/dist/WEPSCLI-shell/approval-overlay.js +275 -0
  5. package/dist/WEPSCLI-shell/approval-overlay.js.map +1 -0
  6. package/dist/WEPSCLI-shell/chat-components.js +760 -0
  7. package/dist/WEPSCLI-shell/chat-components.js.map +1 -0
  8. package/dist/WEPSCLI-shell/components.js +850 -0
  9. package/dist/WEPSCLI-shell/components.js.map +1 -0
  10. package/dist/WEPSCLI-shell/config-overlays.js +205 -0
  11. package/dist/WEPSCLI-shell/config-overlays.js.map +1 -0
  12. package/dist/WEPSCLI-shell/debug-log.js +16 -0
  13. package/dist/WEPSCLI-shell/debug-log.js.map +1 -0
  14. package/dist/WEPSCLI-shell/file-change-preview.js +261 -0
  15. package/dist/WEPSCLI-shell/file-change-preview.js.map +1 -0
  16. package/dist/WEPSCLI-shell/helpers.js +112 -0
  17. package/dist/WEPSCLI-shell/helpers.js.map +1 -0
  18. package/dist/WEPSCLI-shell/index.js +3 -0
  19. package/dist/WEPSCLI-shell/index.js.map +1 -0
  20. package/dist/WEPSCLI-shell/provider-add-flow.js +406 -0
  21. package/dist/WEPSCLI-shell/provider-add-flow.js.map +1 -0
  22. package/dist/WEPSCLI-shell/run-wepscli-shell.js +21 -0
  23. package/dist/WEPSCLI-shell/run-wepscli-shell.js.map +1 -0
  24. package/dist/WEPSCLI-shell/runtime-recovery.js +37 -0
  25. package/dist/WEPSCLI-shell/runtime-recovery.js.map +1 -0
  26. package/dist/WEPSCLI-shell/runtime-status.js +66 -0
  27. package/dist/WEPSCLI-shell/runtime-status.js.map +1 -0
  28. package/dist/WEPSCLI-shell/shell-app.js +1047 -0
  29. package/dist/WEPSCLI-shell/shell-app.js.map +1 -0
  30. package/dist/WEPSCLI-shell/shell-modes.js +77 -0
  31. package/dist/WEPSCLI-shell/shell-modes.js.map +1 -0
  32. package/dist/WEPSCLI-shell/slash-commands.js +135 -0
  33. package/dist/WEPSCLI-shell/slash-commands.js.map +1 -0
  34. package/dist/WEPSCLI-shell/theme.js +19 -0
  35. package/dist/WEPSCLI-shell/theme.js.map +1 -0
  36. package/dist/WEPSCLI-shell/tool-approval.js +85 -0
  37. package/dist/WEPSCLI-shell/tool-approval.js.map +1 -0
  38. package/dist/WEPSCLI-shell/tool-diff.js +76 -0
  39. package/dist/WEPSCLI-shell/tool-diff.js.map +1 -0
  40. package/dist/WEPSCLI-shell/tool-file-changes.js +268 -0
  41. package/dist/WEPSCLI-shell/tool-file-changes.js.map +1 -0
  42. package/dist/WEPSCLI-shell/tool-message-detail.js +138 -0
  43. package/dist/WEPSCLI-shell/tool-message-detail.js.map +1 -0
  44. package/dist/WEPSCLI-shell/tool-messages.js +145 -0
  45. package/dist/WEPSCLI-shell/tool-messages.js.map +1 -0
  46. package/dist/WEPSCLI-shell/transcript-panel.js +372 -0
  47. package/dist/WEPSCLI-shell/transcript-panel.js.map +1 -0
  48. package/dist/WEPSCLI-shell/transcript-state.js +62 -0
  49. package/dist/WEPSCLI-shell/transcript-state.js.map +1 -0
  50. package/dist/WEPSCLI-shell/types.js +1 -0
  51. package/dist/WEPSCLI-shell/types.js.map +1 -0
  52. package/dist/cli.js +11 -0
  53. package/dist/cli.js.map +1 -0
  54. package/dist/config.js +40 -0
  55. package/dist/config.js.map +1 -0
  56. package/dist/index.js +4 -0
  57. package/dist/index.js.map +1 -0
  58. package/dist/main.js +140 -0
  59. package/dist/main.js.map +1 -0
  60. package/dist/onboarding/action-screen.js +90 -0
  61. package/dist/onboarding/action-screen.js.map +1 -0
  62. package/dist/onboarding/framed-screen.js +35 -0
  63. package/dist/onboarding/framed-screen.js.map +1 -0
  64. package/dist/onboarding/onboarding-app.js +312 -0
  65. package/dist/onboarding/onboarding-app.js.map +1 -0
  66. package/dist/onboarding/run-onboarding.js +23 -0
  67. package/dist/onboarding/run-onboarding.js.map +1 -0
  68. package/dist/onboarding/select-screen.js +21 -0
  69. package/dist/onboarding/select-screen.js.map +1 -0
  70. package/dist/onboarding/summary-screen.js +23 -0
  71. package/dist/onboarding/summary-screen.js.map +1 -0
  72. package/dist/onboarding/text-input-screen.js +55 -0
  73. package/dist/onboarding/text-input-screen.js.map +1 -0
  74. package/dist/onboarding/theme.js +26 -0
  75. package/dist/onboarding/theme.js.map +1 -0
  76. package/dist/provider-profiles/api-key-store.js +51 -0
  77. package/dist/provider-profiles/api-key-store.js.map +1 -0
  78. package/dist/provider-profiles/defaults.js +18 -0
  79. package/dist/provider-profiles/defaults.js.map +1 -0
  80. package/dist/provider-profiles/fetch-models.js +53 -0
  81. package/dist/provider-profiles/fetch-models.js.map +1 -0
  82. package/dist/provider-profiles/index.js +6 -0
  83. package/dist/provider-profiles/index.js.map +1 -0
  84. package/dist/provider-profiles/provider-profile-service.js +223 -0
  85. package/dist/provider-profiles/provider-profile-service.js.map +1 -0
  86. package/dist/provider-profiles/providers-config-store.js +17 -0
  87. package/dist/provider-profiles/providers-config-store.js.map +1 -0
  88. package/dist/provider-profiles/types.js +1 -0
  89. package/dist/provider-profiles/types.js.map +1 -0
  90. package/dist/session-history/session-history-service.js +142 -0
  91. package/dist/session-history/session-history-service.js.map +1 -0
  92. package/dist/shell/animator.js +30 -0
  93. package/dist/shell/animator.js.map +1 -0
  94. package/dist/shell/clickables.js +101 -0
  95. package/dist/shell/clickables.js.map +1 -0
  96. package/dist/shell/dashboard-shell.js +292 -0
  97. package/dist/shell/dashboard-shell.js.map +1 -0
  98. package/dist/shell/index.js +5 -0
  99. package/dist/shell/index.js.map +1 -0
  100. package/dist/shell/keymap.js +14 -0
  101. package/dist/shell/keymap.js.map +1 -0
  102. package/dist/shell/mouse.js +39 -0
  103. package/dist/shell/mouse.js.map +1 -0
  104. package/dist/shell/render.js +122 -0
  105. package/dist/shell/render.js.map +1 -0
  106. package/dist/shell/run-shell.js +36 -0
  107. package/dist/shell/run-shell.js.map +1 -0
  108. package/dist/shell/theme.js +56 -0
  109. package/dist/shell/theme.js.map +1 -0
  110. package/dist/storage/locked-json-file.js +88 -0
  111. package/dist/storage/locked-json-file.js.map +1 -0
  112. package/dist/workbench/animator.js +30 -0
  113. package/dist/workbench/animator.js.map +1 -0
  114. package/dist/workbench/index.js +6 -0
  115. package/dist/workbench/index.js.map +1 -0
  116. package/dist/workbench/mouse.js +39 -0
  117. package/dist/workbench/mouse.js.map +1 -0
  118. package/dist/workbench/render.js +82 -0
  119. package/dist/workbench/render.js.map +1 -0
  120. package/dist/workbench/renderer.js +364 -0
  121. package/dist/workbench/renderer.js.map +1 -0
  122. package/dist/workbench/run-workbench.js +36 -0
  123. package/dist/workbench/run-workbench.js.map +1 -0
  124. package/dist/workbench/theme.js +63 -0
  125. package/dist/workbench/theme.js.map +1 -0
  126. package/dist/workbench/types.js +1 -0
  127. package/dist/workbench/types.js.map +1 -0
  128. package/dist/workbench/workbench-shell.js +649 -0
  129. package/dist/workbench/workbench-shell.js.map +1 -0
  130. package/package.json +65 -0
package/README.md ADDED
@@ -0,0 +1,293 @@
1
+ # WEPSCLI
2
+
3
+ `WEPSCLI` is a TUI‑first coding agent CLI built on top of the shared runtime in this monorepo.
4
+
5
+ It focuses on:
6
+
7
+ - Provider/profile‑driven configuration on the local machine
8
+ - A guided first‑run onboarding flow
9
+ - A modern terminal UI chat shell, built with OpenTUI + pi‑tui
10
+ - Persisted session history and provider metadata
11
+
12
+ > Status: experimental / work‑in‑progress. Shell UX, keybindings, and configuration formats may change.
13
+
14
+ ---
15
+
16
+ ## Requirements
17
+
18
+ - **Node.js**: >= 20.0.0
19
+ - **OS**: macOS, Linux, or Windows with a TTY‑capable terminal
20
+ - **Bun (optional but recommended)**: if available, WEPSCLI will automatically relaunch the interactive shell under Bun for better OpenTUI compatibility.
21
+
22
+ ---
23
+
24
+ ## Installation & Getting Started
25
+
26
+ ### From npm (global CLI)
27
+
28
+ ```bash
29
+ npm install -g wepscli
30
+ wepscli --help
31
+ ```
32
+
33
+ Or via `npx`:
34
+
35
+ ```bash
36
+ npx wepscli
37
+ ```
38
+
39
+ ### From source in this monorepo
40
+
41
+ From the repo root, install dependencies if you have not already:
42
+
43
+ ```bash
44
+ npm install
45
+ ```
46
+
47
+ Then build and run `wepscli`:
48
+
49
+ ```bash
50
+ cd D:/WEPsCodingCLI/agents-core/packages/wepscli
51
+ npm run build
52
+ npm run shell # or: node dist/cli.js
53
+ ```
54
+
55
+ To run the shell explicitly under Bun (if installed):
56
+
57
+ ```bash
58
+ npm run shell:bun
59
+ ```
60
+
61
+ ---
62
+
63
+ ## CLI Usage
64
+
65
+ The entry binary is called `wepscli`:
66
+
67
+ ```bash
68
+ wepscli # normal startup
69
+ wepscli --help # usage help
70
+ wepscli --version # show CLI version
71
+ ```
72
+
73
+ On startup WEPSCLI performs the following steps:
74
+
75
+ 1. Ensure the **agent config directory** exists (see [Configuration directory](#configuration-directory)).
76
+ 2. Load **provider profiles** from `providers.json`.
77
+ 3. If no provider profiles are configured, and the terminal is interactive, start the **first‑run onboarding wizard**.
78
+ 4. If the terminal is interactive and at least one profile exists:
79
+ - Prefer to **relaunch under Bun** (via `bun --conditions=browser --preload @opentui/solid/preload`) when available.
80
+ - Otherwise, start the OpenTUI‑based **WEPSCLI shell** under Node.
81
+ - If the WEPSCLI shell fails to start, optionally fall back to the temporary **workbench shell** (see below).
82
+ 5. If the terminal is **not** interactive, print a small bootstrap summary and exit.
83
+
84
+ ---
85
+
86
+ ## Configuration directory
87
+
88
+ WEPSCLI keeps all user configuration, credentials, and runtime metadata under a single agent directory.
89
+
90
+ ### Location
91
+
92
+ By default:
93
+
94
+ ```text
95
+ ~/.wepscli/agent
96
+ ```
97
+
98
+ You can override this path via the `WEPSCLI_AGENT_DIR` environment variable. `~` and `~/...` are expanded to your home directory. Examples:
99
+
100
+ ```bash
101
+ # Use a custom config root
102
+ export WEPSCLI_AGENT_DIR="~/my-wepscli/agent"
103
+
104
+ # Windows PowerShell
105
+ $env:WEPSCLI_AGENT_DIR = "C:\\wepscli-agent"
106
+ ```
107
+
108
+ ### Files inside the agent directory
109
+
110
+ WEPSCLI currently uses the following files:
111
+
112
+ - `settings.json` – reserved for future global app settings.
113
+ - `providers.json` – provider profile configuration (see below).
114
+ - `auth.json` – API keys per provider profile, stored as **plain text**.
115
+ - `sessions.json` – persisted shell session history and metadata.
116
+ - `startup-error.log` – appended when the shell or fallback workbench fail to start.
117
+ - `shell-debug.log` – debug log emitted by the OpenTUI shell.
118
+
119
+ All JSON files are accessed through a small `LockedJsonFile` helper which uses `proper-lockfile` to provide safe concurrent access across processes.
120
+
121
+ > Security note: `auth.json` is intentionally stored in plain text, matching the current design. Only use WEPSCLI on machines you trust, and protect your home directory appropriately.
122
+
123
+ ---
124
+
125
+ ## First‑run onboarding
126
+
127
+ If no provider profiles exist in `providers.json`, running `wepscli` in an interactive terminal launches a guided onboarding wizard implemented with `@mariozechner/pi-tui`.
128
+
129
+ The wizard will:
130
+
131
+ 1. **Welcome** – explain that WEPSCLI needs at least one provider profile.
132
+ 2. **Choose provider family** – select a high‑level API family:
133
+ - `openai` – for OpenAI‑style / OpenAI‑compatible endpoints.
134
+ - `anthropic` – for Anthropic‑style / compatible endpoints.
135
+ 3. **Provider label** – enter a friendly name used inside the shell (e.g. "My OpenAI Proxy").
136
+ 4. **Base URL** – enter the absolute endpoint URL. WEPSCLI uses this value **exactly as entered** (no automatic `/v1` normalization).
137
+ 5. **API key** – paste the API key. It will be stored in `auth.json` under your agent dir.
138
+ 6. **Connection test** – WEPSCLI performs a small model‑list request as a connectivity probe and reports success or error.
139
+ 7. **Fetch models** – attempts to fetch a list of models for this profile:
140
+ - On success, shows a picker of discovered models.
141
+ - On failure, lets you enter a model id manually.
142
+ 8. **Review & save** – show a summary of the profile and selected model, then write:
143
+ - Profile + model metadata into `providers.json`.
144
+ - API key into `auth.json`.
145
+ - Active profile + model selection into the providers config.
146
+
147
+ If onboarding is aborted, WEPSCLI exits without creating a profile.
148
+
149
+ When the terminal is not interactive (e.g. CI), WEPSCLI will not start the wizard. Instead, it prints a bootstrap summary of paths and current profile state and exits.
150
+
151
+ ---
152
+
153
+ ## Provider profiles
154
+
155
+ Provider profiles are managed via the `ProviderProfileService` and stored in `providers.json`. Each profile contains:
156
+
157
+ - An internal `id` and user‑visible `label`.
158
+ - A `family` (e.g. `openai` / `anthropic`).
159
+ - An `apiDialect` (currently derived from the family).
160
+ - A `baseUrl` for requests.
161
+ - A list of discovered `models`.
162
+ - Validation metadata (`lastValidatedAt`, `lastValidationStatus`, `lastValidationMessage`).
163
+
164
+ API keys are stored separately in `auth.json` and looked up by profile id.
165
+
166
+ The WEPSCLI shell:
167
+
168
+ - Tracks an **active profile + model** selection.
169
+ - Updates the selection when you switch sessions or providers.
170
+ - Persists profile changes and model discoveries through `ProviderProfileService` APIs.
171
+
172
+ You can add additional providers later directly from the shell via the **provider add** flow (see [Slash commands](#slash-commands)).
173
+
174
+ ---
175
+
176
+ ## Session history
177
+
178
+ The shell keeps a small, capped session history in `sessions.json` via `SessionHistoryService`:
179
+
180
+ - Each session has an `id`, `title`, `summary`, `state` (`active` | `ready` | `recent`), timestamps, and optional provider/model metadata.
181
+ - New sessions are created when you start a new chat or when the shell needs a transient session while initializing.
182
+ - The active session is marked, and the previous active session is downgraded to `recent`.
183
+ - History is capped (currently at 50 sessions) to keep the file bounded.
184
+
185
+ On first use in a new agent directory, an initial seed of example sessions is written so the shell has something to render.
186
+
187
+ ---
188
+
189
+ ## WEPSCLI shell (OpenTUI)
190
+
191
+ After onboarding, running `wepscli` in an interactive terminal starts the OpenTUI‑based chat shell (`WEPSCLIShellApp`).
192
+
193
+ High‑level behavior:
194
+
195
+ - **Chat transcript panel** on top: shows messages in the current session.
196
+ - **Composer** at the bottom: one‑line input for prompts and slash commands.
197
+ - **Status line**: shows agent dir path and active provider/model status.
198
+ - **Session‑aware runtime**: prompts are executed through a `WepsAgentRuntime` that integrates with the underlying pi coding agent.
199
+
200
+ ### Basic key behavior
201
+
202
+ - `Ctrl+C` – exit the shell immediately.
203
+ - `Esc` in the composer when it is empty – exit the shell.
204
+ - `Tab` – move focus between main area and composer.
205
+ - `Esc` while overlays or detail views are open – close them and return to the composer.
206
+
207
+ ### Slash commands
208
+
209
+ The composer supports a small slash‑command palette. Type `/` to see suggestions, then continue typing to filter.
210
+
211
+ Built‑in commands:
212
+
213
+ - `/new` – start a new shell session.
214
+ - `/providers` – open the provider picker overlay.
215
+ - `/provider add` – open the guided provider setup flow inside the shell.
216
+ - `/models` – open the model picker for the active provider.
217
+ - `/sessions` – choose from recent sessions.
218
+ - `/review` – queue a "review current change" prompt template into the composer.
219
+ - `/debug` – queue a "debug current issue" prompt template.
220
+ - `/provider-check` – queue a provider configuration inspection task.
221
+
222
+ Unknown commands are echoed into the timeline as informational system messages.
223
+
224
+ ### Provider & model selection inside the shell
225
+
226
+ From the shell you can:
227
+
228
+ - Switch **active provider** and model via overlays (e.g. `/providers`, `/models`).
229
+ - Run the **provider add** flow (`/provider add`) to add additional endpoints.
230
+ - Associate a session with a specific profile + model; switching sessions restores the associated selection.
231
+
232
+ All changes are persisted via `ProviderProfileService` and `SessionHistoryService` so subsequent runs of WEPSCLI pick up where you left off.
233
+
234
+ ---
235
+
236
+ ## Fallback workbench shell
237
+
238
+ If the OpenTUI‑based WEPSCLI shell fails to start, the CLI will:
239
+
240
+ 1. Write details about the failure to `startup-error.log` in the agent directory.
241
+ 2. Optionally print a warning and then attempt to start the older **workbench** shell implementation.
242
+
243
+ You can disable the fallback behavior by setting:
244
+
245
+ ```bash
246
+ export WEPSCLI_DISABLE_FALLBACK=1
247
+ ```
248
+
249
+ In that case, a shell startup failure will propagate as a normal process error.
250
+
251
+ ---
252
+
253
+ ## Networking and proxies
254
+
255
+ WEPSCLI configures `undici` as its HTTP client and installs `EnvHttpProxyAgent` as the global dispatcher. This means standard environment variables like `HTTP_PROXY`, `HTTPS_PROXY`, and `NO_PROXY` are respected for outbound HTTP(S) requests to your providers.
256
+
257
+ ---
258
+
259
+ ## Development notes
260
+
261
+ This package is intended to be developed inside the mono‑repo and relies on local `@mariozechner/pi-*` packages.
262
+
263
+ Useful scripts:
264
+
265
+ ```bash
266
+ # Clean build output
267
+ npm run clean
268
+
269
+ # Build once (ensures runtime deps and compiles TypeScript)
270
+ npm run build
271
+
272
+ # Incremental build in watch mode
273
+ npm run dev
274
+
275
+ # Launch the CLI shell from dist
276
+ npm run shell
277
+
278
+ # Shell using Bun + OpenTUI preload
279
+ npm run shell:bun
280
+
281
+ # Minimal smoke tests for OpenTUI rendering (require Bun)
282
+ npm run smoke:hello
283
+ npm run smoke:panel
284
+ npm run smoke:shell-min
285
+ ```
286
+
287
+ The published npm package exposes:
288
+
289
+ - `bin/wepscli` -> `dist/cli.js`
290
+ - `main` entrypoint -> `dist/index.js`
291
+ - Type declarations -> `dist/index.d.ts`
292
+
293
+ Changes to runtime behavior should be reflected here in the README to keep user‑facing documentation in sync with the implementation.