hablas 2.0.5

This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
package/CHANGELOG.md ADDED
@@ -0,0 +1,108 @@
1
+ # Changelog
2
+
3
+ All notable changes to **Hablas CLI** will be documented in this file.
4
+
5
+ The format is based on [Keep a Changelog](https://keepachangelog.com/en/1.1.0/),
6
+ and this project adheres to [Semantic Versioning](https://semver.org/spec/v2.0.0.html).
7
+
8
+ ---
9
+
10
+ ## [1.0.0] — 2026-05-31 · **First Public Release**
11
+
12
+ The first formal, polished, production-ready release of Hablas CLI. Months of
13
+ internal iteration consolidated into a focused, type-strict, dead-code-free
14
+ multi-agent system that runs locally or against any OpenAI-compatible API.
15
+
16
+ ### ✨ Highlights
17
+ - **Live Team Theatre** — watch the multi-agent team (Hablas → Emma → Bob →
18
+ Alex → David) collaborate in real time, in character, with bounded
19
+ in-character dialogue between agents.
20
+ - **Single-leader UX** — you only talk to Hablas. He delegates, reviews,
21
+ synthesizes, and replies in his own INTJ voice.
22
+ - **Strict separation of concerns** — `AgentChannel` (event bus),
23
+ `TheatreRenderer` (UI), `TeamConductor` (orchestration logic),
24
+ `InterAgentChat` (dialogue generation) are fully decoupled.
25
+
26
+ ### Added
27
+ - **Live Team Theatre subsystem** (5 new modules, ~1,000 LOC):
28
+ - `agents/agent-channel.ts` — typed event bus, single source of truth.
29
+ - `agents/inter-agent-chat.ts` — bounded in-character dialogue generator
30
+ with token budget, cache, and deterministic fallback.
31
+ - `agents/team-conductor.ts` — drives delegate → handoff → execute →
32
+ peer-review → synthesize on the AgentChannel.
33
+ - `repl/theatre.ts` — executive-silver TUI subscriber.
34
+ - `agents/__tests__/agent-channel.test.ts` — 11 unit tests.
35
+ - **T-shirt sizing** (XS/S/M/L/XL) for complexity-aware routing.
36
+ - **Plan approval flow** with `approve / edit / skip` for L and XL tasks.
37
+ - **`/team`, `/agents`, `/agents models`, `/delegate`** slash commands.
38
+ - **Multi-provider support** — Ollama, NVIDIA NIM, OpenAI-compatible APIs.
39
+ - **Tool Parser V2** — model-aware learning across 6+ tool-call formats.
40
+ - **ReAct engine** with `<thinking>` block parsing and step budget warnings.
41
+ - **Error Recovery engine** — classifies tool failures and injects
42
+ recovery strategies into the next prompt.
43
+ - **Smart abort** — only critical tool failures stop the chain.
44
+ - **Ctrl+C** — single press cancels the current op, double press exits cleanly.
45
+ - **Checkpoint & Undo Stack** — `/checkpoint save|list|restore`, `/undo [all|list|N]`.
46
+ - **Project memory** — categorized, importance-weighted, decay-based, agent-lanes.
47
+ - **Auto-inject** — files mentioned in user input are auto-loaded into the session.
48
+ - **Setup wizard** on first run.
49
+ - **Team mode** (`--team`) — Supabase + Git-based file locks and presence.
50
+ - **`hablas commit | pr | changelog | security | stats | info`** sub-commands.
51
+
52
+ ### Changed
53
+ - **`package.json` version** bumped from internal `2.0.0` to public `1.0.0`.
54
+ - **README** updated for the v1.0.0 release.
55
+ - **`tsconfig.json`** hardened: enabled `noUnusedLocals`,
56
+ `noUnusedParameters`, `noImplicitOverride`,
57
+ `noFallthroughCasesInSwitch`.
58
+
59
+ ### Removed (cleanup)
60
+ - **37 dead-code files** (~6,000 LOC) — abandoned v1/v2/v3 variants,
61
+ unfinished subsystems, type shims for unused dependencies. Concretely:
62
+ - `agents/{research-agent, self-evaluator, smart-retry, sub-agents}.ts`
63
+ - `context/{codebase-index, context-manager-v3, simple-vector-store,
64
+ sqlite-memory, summarizer}.ts` and `context/v3/*`
65
+ - `kernel/{hooks, permissions, runtime}.ts`
66
+ - `llm/{models, thinking-engine}.ts`
67
+ - `mcp/{client, server}.ts`
68
+ - `planner/{classifier, executor, smart-planner-v2}.ts`
69
+ - `tools/{compact, glob, multi-edit, project-intelligence, registry-v3,
70
+ todo-manager, web-search, v2/web, v2/background}.ts`
71
+ - `repl/todo-renderer.ts`
72
+ - `templates/template-manager.ts`
73
+ - `types/{web-deps, xenova-transformers}.d.ts`
74
+ - **~95 unused imports** across live files, removed via static analysis.
75
+ - **Legacy `setOutputCallback` printer** in `loop.ts` — superseded by the
76
+ Theatre pipeline.
77
+ - **Hardcoded `2.0.0` strings** — now bind dynamically to `package.json`.
78
+
79
+ ### Fixed
80
+ - `api/server.ts` health endpoint returns the real version from `package.json`.
81
+ - `team-conductor.ts` no longer holds an unused `config` field.
82
+ - `loop.ts` `BACKUP_DIR` and unused `fsPromises` removed.
83
+ - All `tsc --noUnusedLocals --noUnusedParameters` warnings cleared.
84
+
85
+ ### Hard Guarantees
86
+ - ✅ `npm run build` (strict TS) passes with **zero** errors.
87
+ - ✅ `npm test` passes (11/11 channel tests).
88
+ - ✅ `npm install` succeeds with the declared dependencies (no phantom imports).
89
+ - ✅ Hablas is the sole speaker to the user — no agent surprises.
90
+ - ✅ Token budget capped per turn; silent fallback when LLM is offline.
91
+ - ✅ Web app, Supabase schema, and `@Consul` collaboration code untouched.
92
+
93
+ ### Engineering Stats
94
+ | Metric | Before | After |
95
+ |---|---|---|
96
+ | TypeScript files | 111 | **74** |
97
+ | Total LOC | 27,143 | **~21,000** |
98
+ | Dead-code files | 37 | **0** |
99
+ | Unused imports/declarations | 103 | **0** |
100
+ | `--noUnusedLocals` clean | ❌ | ✅ |
101
+ | `--noUnusedParameters` clean | ❌ | ✅ |
102
+ | `@ts-ignore` count | 0 | **0** |
103
+ | Unit tests | 0 | **11** |
104
+
105
+ ---
106
+
107
+ > The full audit that drove this release is preserved in
108
+ > [`AUDIT_v1.0.0.md`](./AUDIT_v1.0.0.md).
package/CREDITS.md ADDED
@@ -0,0 +1,33 @@
1
+ # Credits
2
+
3
+ ## Developer
4
+
5
+ **Abdulmoin Hablas** — Full-Stack Developer
6
+
7
+ ### Connect
8
+
9
+ | Platform | Link |
10
+ |----------|------|
11
+ | Portfolio | [portfolio-monopoly63s-projects.vercel.app](https://portfolio-monopoly63s-projects.vercel.app/) |
12
+ | GitHub | [github.com/Monopoly63](https://github.com/Monopoly63?tab=repositories) |
13
+ | Telegram | [@Hablas_Trade](https://t.me/Hablas_Trade) |
14
+ | WhatsApp | [+1 323 212 8875](https://wa.me/13232128875) |
15
+ | Instagram | [@li0vy_](https://www.instagram.com/li0vy_) |
16
+
17
+ ### Other Projects
18
+
19
+ | Project | Link |
20
+ |---------|------|
21
+ | AI Search Engine | [ai-search-engine-ashy.vercel.app](https://ai-search-engine-ashy.vercel.app/) |
22
+ | Trade Tracker | [trade-tracker-monopoly63s-projects.vercel.app](https://trade-tracker-monopoly63s-projects.vercel.app/) |
23
+ | Tree Algorithms Lab | [tree-algorithms-lab.vercel.app](https://tree-algorithms-lab.vercel.app/) |
24
+
25
+ ---
26
+
27
+ ## Built With
28
+
29
+ - TypeScript · Node.js 20+ · Ollama · Commander.js · Pino
30
+
31
+ ## License
32
+
33
+ MIT
package/LICENSE ADDED
@@ -0,0 +1,21 @@
1
+ MIT License
2
+
3
+ Copyright (c) 2024-2026 Abdulmoin Hablas
4
+
5
+ Permission is hereby granted, free of charge, to any person obtaining a copy
6
+ of this software and associated documentation files (the "Software"), to deal
7
+ in the Software without restriction, including without limitation the rights
8
+ to use, copy, modify, merge, publish, distribute, sublicense, and/or sell
9
+ copies of the Software, and to permit persons to whom the Software is
10
+ furnished to do so, subject to the following conditions:
11
+
12
+ The above copyright notice and this permission notice shall be included in all
13
+ copies or substantial portions of the Software.
14
+
15
+ THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR
16
+ IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY,
17
+ FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE
18
+ AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER
19
+ LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM,
20
+ OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE
21
+ SOFTWARE.
package/README.md ADDED
@@ -0,0 +1,317 @@
1
+ <div align="center">
2
+
3
+ # ◆ Hablas CLI
4
+
5
+ **Premium multi-agent AI coding agent for your terminal**
6
+
7
+ Local-first · Cloud-compatible · Watch the team work in front of you
8
+
9
+ *by [Abdulmoin Hablas](https://portfolio-monopoly63s-projects.vercel.app/)*
10
+
11
+ [![License: MIT](https://img.shields.io/badge/License-MIT-blue.svg)](LICENSE)
12
+ [![Version](https://img.shields.io/badge/version-1.0.0-gold.svg)](CHANGELOG.md)
13
+ [![Node.js](https://img.shields.io/badge/Node.js-20%2B-green.svg)](https://nodejs.org)
14
+ [![TypeScript](https://img.shields.io/badge/TypeScript-5.5-blue.svg)](https://www.typescriptlang.org)
15
+
16
+ </div>
17
+
18
+ ---
19
+
20
+ ## ✦ Overview
21
+
22
+ **Hablas** is a multi-agent AI development system that runs in your terminal.
23
+ Unlike single-model assistants, Hablas leads a **team of specialists** —
24
+ Emma (Product), Bob (Architect), Alex (Engineer), David (Analyst) — and
25
+ **you watch them collaborate live**, in character, while Hablas (the Team
26
+ Leader) remains your single point of contact.
27
+
28
+ It runs **locally via Ollama**, or against **any OpenAI-compatible API**
29
+ (NVIDIA NIM, OpenAI, Groq, Together, OpenRouter, and more).
30
+
31
+ ### ✨ What makes v1.0.0 different
32
+
33
+ - **Live Team Theatre** — see the team handoff tasks, think, run tools,
34
+ and review each other's work in real time, with an executive-silver TUI.
35
+ - **Hablas-only conversation** — you talk to one leader; the rest is theatre.
36
+ - **Persona-faithful** — each agent stays in their distinctive voice
37
+ (Hablas is INTJ-direct, Bob is methodical, Alex is pragmatic, …).
38
+ - **Token-bounded dialogue** — the inter-agent chat is capped and
39
+ gracefully falls back to deterministic lines when offline.
40
+
41
+ ### Key Features
42
+
43
+ - **Multi-Agent System** — 5 specialized agents with their own mindsets
44
+ and (optionally) their own models per role.
45
+ - **T-shirt Sizing** — XS/S/M/L/XL routing so a "hi" doesn't trigger a plan.
46
+ - **Plan Approval** — for L/XL tasks, you approve / edit / skip before exec.
47
+ - **Dual Provider** — Ollama (local), NVIDIA NIM, or any
48
+ OpenAI-compatible API. Switch live with `/provider`.
49
+ - **Dynamic Model Discovery** — `/models` lists everything your API exposes.
50
+ - **Agentic Loop** — multi-step tool execution with auto-retry,
51
+ smart abort, and recovery hints.
52
+ - **15+ Built-in Tools** — file ops, shell, codebase search, web search,
53
+ web scraping, PDF reading, code execution, bug detection, and more.
54
+ - **Smart Context** — project-aware prompts, memory with categories and
55
+ importance decay, shared notebook, auto-injection of mentioned files.
56
+ - **Premium TUI** — executive-silver theme, spinners, progress, plan
57
+ boxes, session summaries.
58
+ - **Three-tier safety** — `safe / confirm / dangerous` per tool.
59
+ - **Ctrl+C UX** — single = cancel current op, double = exit cleanly.
60
+ - **Auto Mode** — `--auto` skips tool confirmations for scripting
61
+ (plan approval still required).
62
+ - **Checkpoints & Undo** — `/checkpoint save|restore`, `/undo`.
63
+ - **Team Mode** — optional Supabase + Git-based locks and presence sync.
64
+
65
+ ---
66
+
67
+ ## ✦ Installation
68
+
69
+ ```bash
70
+ git clone https://github.com/Monopoly63/mobile-bot.git
71
+ cd mobile-bot/flowagent
72
+ npm install
73
+ npm run build
74
+ npm link # exposes the `hablas` command globally
75
+ ```
76
+
77
+ ### Requirements
78
+
79
+ - **Node.js 20+**
80
+ - One of:
81
+ - **Ollama** running locally (`ollama serve`)
82
+ - An **OpenAI-compatible API** key
83
+ - **NVIDIA NIM** API key
84
+
85
+ First run launches a setup wizard. You can re-run it anytime with `hablas --setup`.
86
+
87
+ ---
88
+
89
+ ## ✦ Quick Start
90
+
91
+ ```bash
92
+ # Interactive REPL
93
+ hablas
94
+
95
+ # One-shot command
96
+ hablas run "refactor src/auth.ts to use bcrypt"
97
+
98
+ # Generate a commit message from staged changes
99
+ hablas commit
100
+
101
+ # Project info
102
+ hablas info
103
+
104
+ # Diagnostics
105
+ hablas doctor
106
+ ```
107
+
108
+ ---
109
+
110
+ ## ✦ Commands Reference
111
+
112
+ ### Core Slash Commands
113
+
114
+ | Command | Description |
115
+ |---|---|
116
+ | `/help` | List all commands |
117
+ | `/about` · `/version` | Identity & version info |
118
+ | `/team` · `/agents` | Team roster · multi-agent system status |
119
+ | `/agents on\|off\|status\|models` | Toggle and inspect agents |
120
+ | `/delegate <agent> <task>` | Manually assign a task to one agent |
121
+ | `/mindset <name>` · `/mindsets` | Switch / list agent mindsets |
122
+ | `/clear` · `/history [n]` | Reset context · show recent turns |
123
+ | `/status` · `/quit` | Show status · exit |
124
+
125
+ ### Model & Provider
126
+
127
+ | Command | Description |
128
+ |---|---|
129
+ | `/model [name]` | Show or switch the active model |
130
+ | `/models [page\|query]` | Browse available models (paged + search) |
131
+ | `/provider [ollama\|nvidia\|custom\|test]` | Switch / test the provider |
132
+ | `/addmodel` · `/listmodels` · `/usemodel <name>` · `/removemodel <name>` | Manage saved provider profiles |
133
+
134
+ ### Project Tools
135
+
136
+ | Command | Description |
137
+ |---|---|
138
+ | `/security` | Run the project security scan |
139
+ | `/git status` | Show Git status |
140
+ | `/workspace` | Show framework/language/CI detection |
141
+ | `/stats` · `/cost` | Usage analytics |
142
+ | `/test [--fix]` | Detect & run tests, optionally let the agent fix them |
143
+ | `/checkpoint save\|list\|restore\|delete` | Snapshot & restore project state |
144
+ | `/undo [N\|all\|list]` | Revert recent agent changes |
145
+ | `/compare <a> <b>` · `/compare HEAD~1` | Side-by-side diff |
146
+
147
+ ### Memory & Context
148
+
149
+ | Command | Description |
150
+ |---|---|
151
+ | `/memory [set\|del\|search\|clear]` | Persistent project memory |
152
+ | `/learn "<preference>"` | Teach the agent a preference (importance: 9) |
153
+ | `/context [set\|get\|del\|decisions\|clear]` | Cross-agent shared notebook |
154
+ | `/plan status\|finish\|next\|reset` | Inspect the active plan |
155
+
156
+ ### Plugins & Diagnostics
157
+
158
+ | Command | Description |
159
+ |---|---|
160
+ | `/plugins [enable\|disable]` | Manage plugins (~/.hablas/plugins/) |
161
+ | `/alias [set\|del]` | Custom command aliases |
162
+ | `/doctor` | System diagnostics |
163
+ | `/session save\|list` | Save/load conversation state |
164
+
165
+ ---
166
+
167
+ ## ✦ CLI Flags & Sub-commands
168
+
169
+ | Flag / Sub-command | Description |
170
+ |---|---|
171
+ | `-m, --model <name>` | Set the active model |
172
+ | `-p, --project <path>` | Set the working directory |
173
+ | `--provider <ollama\|custom\|nvidia>` | Choose LLM provider |
174
+ | `--api-url <url>` · `--api-key <key>` | Configure custom/NVIDIA provider |
175
+ | `--auto` | Skip tool confirmations (plan approval still required) |
176
+ | `--timeout <ms>` | Per-request timeout (default 120000) |
177
+ | `--theme <dark\|light\|galaxy\|ocean\|forest>` | UI theme |
178
+ | `--team --user <name> --team-key <pwd>` | Enable Team Mode |
179
+ | `--setup` | Run the first-time wizard |
180
+ | `hablas run "<prompt>"` | Non-interactive single shot |
181
+ | `hablas commit` · `pr` · `changelog` | Git intelligence sub-commands |
182
+ | `hablas info` · `doctor` · `security` · `stats` | Project insights |
183
+ | `hablas api --port 8080` | Start the REST API server |
184
+
185
+ ---
186
+
187
+ ## ✦ Built-in Tools
188
+
189
+ | Tool | Purpose | Safety |
190
+ |---|---|---|
191
+ | `read_file`, `list_dir`, `get_file_info` | Read filesystem | safe |
192
+ | `write_file`, `edit_file`, `patch_file`, `append_to_file`, `search_and_replace` | Mutate files | confirm |
193
+ | `delete_file`, `move_file`, `create_dir` | Manage paths | dangerous / confirm |
194
+ | `run_command` | Shell execution (with timeout + blocklist) | dangerous |
195
+ | `search_codebase` | Ripgrep-style search | safe |
196
+ | `detect_bugs` | Static analysis | safe |
197
+ | `web_search` | DuckDuckGo search | safe |
198
+ | `scrape_url`, `extract_links` | HTML scraping | safe |
199
+ | `read_pdf`, `pdf_metadata` | PDF reading | safe |
200
+ | `execute_code` | Sandboxed code execution | confirm |
201
+
202
+ ---
203
+
204
+ ## ✦ Configuration
205
+
206
+ Config lives at **`~/.hablas/config.json`**. Sub-files:
207
+
208
+ | File | Purpose |
209
+ |---|---|
210
+ | `~/.hablas/config.json` | Main config (model, provider, theme, flags) |
211
+ | `~/.hablas/agent-models.json` | Per-agent model overrides |
212
+ | `~/.hablas/models.json` | Saved provider profiles (`/addmodel`) |
213
+ | `~/.hablas/aliases.json` | Custom slash-command aliases |
214
+ | `~/.hablas/memory/<hash>.json` | Per-project memory store |
215
+ | `~/.hablas/plugins/` | Installed plugins |
216
+ | `~/.hablas/logs/` | Structured pino logs |
217
+
218
+ ---
219
+
220
+ ## ✦ The Multi-Agent Team
221
+
222
+ | Agent | Title | Role | Voice |
223
+ |---|---|---|---|
224
+ | **★ Hablas** | Team Leader | Coordination, planning, synthesis, the only one you talk to | INTJ, authoritative, terse |
225
+ | **◆ Emma** | Product Manager | Requirements, PRDs, user stories | Calm, structured |
226
+ | **◆ Bob** | Architect | System design, schemas, contracts, peer-reviews Alex | Methodical, principled |
227
+ | **◆ Alex** | Engineer | Implementation, debugging, tests | Pragmatic, action-biased |
228
+ | **◆ David** | Data Analyst | Research, documentation, comparisons | Factual, evidence-driven |
229
+
230
+ Routing is automatic and complexity-aware (T-shirt sizing):
231
+
232
+ | Size | Trigger | Behavior |
233
+ |---|---|---|
234
+ | **XS** | Greetings, casual chat | Hablas replies directly, no tools |
235
+ | **S** | Single clear question | Single agent, no plan |
236
+ | **M** | Single focused task | Live theatre, one specialist + Hablas synthesis |
237
+ | **L** | Multi-step, multi-concern | Plan → approval → live theatre with peer review |
238
+ | **XL** | Full system / feature | XL plan (Emma writes PRD first) → approval → full theatre |
239
+
240
+ ---
241
+
242
+ ## ✦ Examples
243
+
244
+ ```bash
245
+ # Read, then edit
246
+ > read src/auth.ts and add JWT validation
247
+
248
+ # Multi-step (triggers L flow)
249
+ > design and implement a /users endpoint with tests
250
+
251
+ # Specific agent
252
+ > /delegate bob design the cache layer for the search API
253
+
254
+ # Git workflow
255
+ > hablas commit
256
+ > hablas pr --base main
257
+ > hablas changelog --version 1.1.0
258
+
259
+ # Memory
260
+ > /learn always use tabs and 2-space indent for YAML
261
+ > /memory search auth
262
+ ```
263
+
264
+ ---
265
+
266
+ ## ✦ Architecture
267
+
268
+ ```
269
+ src/
270
+ ├── repl/ REPL loop, slash commands, TUI, live theatre
271
+ ├── agents/ Orchestrator, conductor, runner, channel, dialogue
272
+ ├── planner/ T-shirt sizing, plan lifecycle, task queue
273
+ ├── llm/ Unified provider (Ollama/Custom/NVIDIA), tool parser v2
274
+ ├── mindset/ Per-agent system prompts
275
+ ├── tools/ Tool registry + 15 built-in tools
276
+ ├── context/ Session, memory, shared notebook, auto-inject
277
+ ├── config/ Defaults + JSON loader
278
+ ├── collaboration/ Optional Team Mode (Supabase + Git locks)
279
+ ├── plugins/ Plugin loader + diagnostics
280
+ ├── security/ /security scanner
281
+ ├── analytics/ Usage stats
282
+ ├── git/ /commit /pr /changelog intelligence
283
+ ├── workspace/ Framework / language / CI detection
284
+ └── utils/ logger, diff, tokens
285
+ ```
286
+
287
+ 74 TypeScript files, ~21,000 LOC, `strict` mode, zero `@ts-ignore`,
288
+ zero unused locals/parameters.
289
+
290
+ ---
291
+
292
+ ## ✦ Development
293
+
294
+ ```bash
295
+ npm install # install deps
296
+ npm run build # tsc → dist/
297
+ npm run lint # tsc --noEmit
298
+ npm test # run the channel unit tests
299
+ npm run dev -- run "your prompt" # dev mode without build
300
+ ```
301
+
302
+ ---
303
+
304
+ ## ✦ Author
305
+
306
+ **Abdulmoin Hablas** — [Portfolio](https://portfolio-monopoly63s-projects.vercel.app/)
307
+
308
+ ### Other Projects
309
+
310
+ - **mobile-bot** — the web companion + landing pages
311
+ - **Hablas Web Chat** — ChatGPT-style chat on the web
312
+
313
+ ---
314
+
315
+ ## ✦ License
316
+
317
+ [MIT](LICENSE) © 2024-2026 Abdulmoin Hablas
@@ -0,0 +1,47 @@
1
+ #!/usr/bin/env node
2
+
3
+ const fs = require('fs');
4
+ const path = require('path');
5
+ const { spawnSync } = require('child_process');
6
+
7
+ const pkg = require('../package.json');
8
+ const VERSION = pkg.version;
9
+
10
+ const PLATFORM_MAP = {
11
+ win32: { x64: 'hablas-win-x64.exe' },
12
+ linux: { x64: 'hablas-linux-x64' },
13
+ darwin: { x64: 'hablas-macos-x64' }
14
+ };
15
+
16
+ function getBinaryName() {
17
+ const osConfig = PLATFORM_MAP[process.platform];
18
+ if (!osConfig) return null;
19
+ return osConfig[process.arch] || null;
20
+ }
21
+
22
+ function run() {
23
+ const binaryName = getBinaryName();
24
+ const binaryPath = binaryName ? path.resolve(__dirname, binaryName) : null;
25
+
26
+ // If Standalone Binary exists, execute it
27
+ if (binaryPath && fs.existsSync(binaryPath)) {
28
+ const args = process.argv.slice(2);
29
+ const result = spawnSync(binaryPath, args, { stdio: 'inherit' });
30
+
31
+ // Exit with the same status code
32
+ process.exit(result.status ?? 0);
33
+ } else {
34
+ // Graceful fallback to running the bundled JavaScript version
35
+ const fallbackPath = path.resolve(__dirname, '..', 'dist', 'index.js');
36
+ if (fs.existsSync(fallbackPath)) {
37
+ // Execute the bundled JavaScript directly using node
38
+ require(fallbackPath);
39
+ } else {
40
+ console.error(`❌ Error: Hablas CLI entry point not found!`);
41
+ console.error(`Please reinstall the package using: npm install -g hablas`);
42
+ process.exit(1);
43
+ }
44
+ }
45
+ }
46
+
47
+ run();