anix-type 0.1.0__tar.gz

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.
@@ -0,0 +1,21 @@
1
+ MIT License
2
+
3
+ Copyright (c) 2026 an1zy
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.
@@ -0,0 +1,207 @@
1
+ Metadata-Version: 2.4
2
+ Name: anix-type
3
+ Version: 0.1.0
4
+ Summary: Context-aware autocompletion and natural language command forge for your terminal.
5
+ Author: an1zy
6
+ License: MIT
7
+ Project-URL: Homepage, https://github.com/an1zy/anix-type
8
+ Project-URL: Issues, https://github.com/an1zy/anix-type/issues
9
+ Keywords: terminal,powershell,autocomplete,cli,ai,ollama,groq,llm,productivity
10
+ Classifier: Development Status :: 4 - Beta
11
+ Classifier: Environment :: Console
12
+ Classifier: License :: OSI Approved :: MIT License
13
+ Classifier: Programming Language :: Python :: 3
14
+ Classifier: Programming Language :: Python :: 3.10
15
+ Classifier: Programming Language :: Python :: 3.11
16
+ Classifier: Programming Language :: Python :: 3.12
17
+ Classifier: Programming Language :: Python :: 3.13
18
+ Classifier: Programming Language :: Python :: 3.14
19
+ Classifier: Topic :: System :: Shells
20
+ Classifier: Topic :: Software Development
21
+ Requires-Python: >=3.10
22
+ Description-Content-Type: text/markdown
23
+ License-File: LICENSE
24
+ Provides-Extra: dev
25
+ Requires-Dist: pytest>=8; extra == "dev"
26
+ Dynamic: license-file
27
+
28
+ # ANIX Type
29
+
30
+ [![tests](https://github.com/an1zy/anix-type/actions/workflows/tests.yml/badge.svg)](https://github.com/an1zy/anix-type/actions/workflows/tests.yml)
31
+ ![python](https://img.shields.io/badge/python-3.10%2B-blue)
32
+ ![license](https://img.shields.io/badge/license-MIT-green)
33
+ ![dependencies](https://img.shields.io/badge/dependencies-0-brightgreen)
34
+ ![status](https://img.shields.io/badge/status-active-success)
35
+
36
+ 🇬🇧 English · 🇷🇺 [Русский](README.ru.md)
37
+
38
+ > Context-aware shell autocompletion and natural language command forge. Zero runtime dependencies. Sub-millisecond latency. Works 100% offline.
39
+
40
+ ```powershell
41
+ # 1. Instant heuristic autocompletion (<0.05ms):
42
+ PS C:\projects\anixcode> git p·ush origin main [Tab]
43
+ PS C:\projects\anixcode> pyt·est -q [Tab]
44
+ PS C:\projects\anixcode> pnpm d·ev [Tab]
45
+
46
+ # 2. Natural language command forge:
47
+ PS C:\projects\anixcode> ?? undo last commit keep files [Enter]
48
+ → git reset --soft HEAD~1
49
+
50
+ PS C:\projects\anixcode> ?? kill port 3000 [Enter]
51
+ → Stop-Process -Id (Get-NetTCPConnection -LocalPort 3000).OwningProcess -Force
52
+
53
+ # 3. Unlimited local AI via Ollama (qwen2.5-coder:1.5b):
54
+ PS C:\projects\anixcode> ?? top 5 memory heavy processes [Enter]
55
+ → Get-Process | Sort-Object -Property WorkingSet -Descending | Select-Object -First 5
56
+ ```
57
+
58
+ ---
59
+
60
+ ## Why ANIX Type?
61
+
62
+ - **⚡ Zero Runtime Dependencies:** Built strictly on the Python 3 standard library (`http.server`, `urllib`, `json`). Installs in seconds, zero package conflicts.
63
+ - **⚡ Sub-Millisecond Context Engine:** Directly reads `.git/HEAD` (<0.05 ms), parses `package.json` scripts, detects Python/Docker environments on the fly.
64
+ - **🔒 100% Offline & Private:** Built-in heuristic engine handles 95% of everyday developer commands locally without touching the network.
65
+ - **🧠 Unlimited AI Forge:** Connects to local [Ollama](https://ollama.com) (`qwen2.5-coder:1.5b`) for complete offline privacy, or any OpenAI-compatible provider (DeepSeek, Groq, OpenAI).
66
+ - **🌍 Bilingual (EN + RU):** Natural language command forge understands both English and Russian prompts out of the box.
67
+ - **💻 Native PowerShell Integration:** Hooks cleanly into `PSReadLine` for instant `Tab`, `RightArrow`, and `Enter` replacement without prompt flickering.
68
+
69
+ ---
70
+
71
+ ## Install
72
+
73
+ Requires Python 3.10+.
74
+
75
+ ```bash
76
+ pip install anix-type
77
+ ```
78
+
79
+ ### 1. Hook into PowerShell
80
+
81
+ Run the install command once to add the integration hook to your PowerShell `$PROFILE`:
82
+
83
+ ```powershell
84
+ anix-type install
85
+ ```
86
+
87
+ Reload your current terminal session:
88
+
89
+ ```powershell
90
+ . $PROFILE
91
+ ```
92
+
93
+ *(You will see `⚡ ANIX Type ready` in your console)*.
94
+
95
+ ---
96
+
97
+ ## Usage
98
+
99
+ ### Instant Autocompletion
100
+
101
+ Just type and press **Tab** or **RightArrow (→)**:
102
+
103
+ | What you type | What ANIX Type predicts | Context |
104
+ |---|---|---|
105
+ | `git p` + Tab | `git push origin <current-branch>` | Reads your actual `.git/HEAD` |
106
+ | `git s` + Tab | `git status` | Git repository |
107
+ | `pyt` + Tab | `pytest -q` | Python repository |
108
+ | `py` + Tab | `python` | Python environment |
109
+ | `pnpm d` + Tab | `pnpm dev` | Reads scripts from `package.json` |
110
+ | `pip i` + Tab | `pip install ` | Python |
111
+
112
+ ### Command Forge (`?? <what you want to do>`)
113
+
114
+ Type `??` followed by plain English or Russian, then press **Enter**:
115
+
116
+ ```powershell
117
+ # Git operations
118
+ ?? undo last commit keep files → git reset --soft HEAD~1
119
+ ?? stash changes → git stash
120
+ ?? pop stash → git stash pop
121
+ ?? new branch feat-login → git checkout -b feat-login
122
+ ?? discard changes → git restore .
123
+
124
+ # System & ports
125
+ ?? kill port 8080 → Stop-Process -Id (Get-NetTCPConnection -LocalPort 8080).OwningProcess -Force
126
+ ?? top memory processes → Get-Process | Sort-Object -Property WorkingSet -Descending | Select-Object -First 5
127
+ ?? folder size → calculates folder size in MB
128
+ ?? find file settings.py → Get-ChildItem -Recurse -Filter "*settings.py*"
129
+
130
+ # Python & Docker
131
+ ?? create venv → python -m venv .venv
132
+ ?? activate venv → .\.venv\Scripts\Activate.ps1
133
+ ?? purge pip cache → pip cache purge
134
+ ?? stop all docker containers → docker stop $(docker ps -q)
135
+ ```
136
+
137
+ ---
138
+
139
+ ## AI Providers (Optional)
140
+
141
+ ANIX Type works completely offline using built-in heuristics. For complex, non-template queries, you can optionally connect an AI model:
142
+
143
+ ### 1. Local Ollama (Recommended — 100% Free & Offline)
144
+
145
+ ```bash
146
+ # Install Ollama and pull lightweight coder model
147
+ winget install Ollama.Ollama
148
+ ollama run qwen2.5-coder:1.5b
149
+
150
+ # Switch ANIX Type to Ollama
151
+ anix-type config --ollama --model qwen2.5-coder:1.5b
152
+ ```
153
+
154
+ ### 2. DeepSeek / OpenAI / Custom Proxy
155
+
156
+ ```bash
157
+ anix-type config --openai-key sk-... --base-url https://api.deepseek.com/v1 --model deepseek-chat
158
+ ```
159
+
160
+ ### 3. Groq (Ultra-fast cloud)
161
+
162
+ ```bash
163
+ anix-type config --groq-key gsk_...
164
+ ```
165
+
166
+ ---
167
+
168
+ ## CLI Reference
169
+
170
+ ```bash
171
+ anix-type status # Check daemon health, port, and AI provider
172
+ anix-type start # Start daemon in background (auto-starts on terminal open)
173
+ anix-type stop # Stop background daemon
174
+ anix-type daemon # Run daemon in foreground with --verbose logging
175
+ anix-type config # Configure AI model and API keys
176
+ anix-type install # Install integration hook into PowerShell profile
177
+ ```
178
+
179
+ ---
180
+
181
+ ## Architecture
182
+
183
+ ```
184
+ ┌──────────────────────────────────────────────┐
185
+ │ Terminal (PSReadLine) │
186
+ └───────────────┬──────────────────────────────┘
187
+ │ HTTP / JSON (<2ms)
188
+ ▼
189
+ ┌──────────────────────────────────────────────┐
190
+ │ ANIX Type Daemon (127.0.0.1:8766) │
191
+ ├──────────────────────────────┬───────────────┤
192
+ │ Context Engine (<0.05ms) │ History Index │
193
+ └───────────────┬──────────────┴───────────────┘
194
+ │
195
+ ┌───────────────┴───────────────┐
196
+ ▼ ▼
197
+ [Offline Heuristics Engine] [AI Forge Layer]
198
+ • Direct .git/HEAD reader • Local Ollama (qwen2.5-coder)
199
+ • package.json script parser • DeepSeek / OpenAI / Groq
200
+ • Bilingual intent patterns • 100% offline fallback
201
+ ```
202
+
203
+ ---
204
+
205
+ ## License
206
+
207
+ MIT © [an1zy](https://github.com/an1zy)
@@ -0,0 +1,180 @@
1
+ # ANIX Type
2
+
3
+ [![tests](https://github.com/an1zy/anix-type/actions/workflows/tests.yml/badge.svg)](https://github.com/an1zy/anix-type/actions/workflows/tests.yml)
4
+ ![python](https://img.shields.io/badge/python-3.10%2B-blue)
5
+ ![license](https://img.shields.io/badge/license-MIT-green)
6
+ ![dependencies](https://img.shields.io/badge/dependencies-0-brightgreen)
7
+ ![status](https://img.shields.io/badge/status-active-success)
8
+
9
+ 🇬🇧 English · 🇷🇺 [Русский](README.ru.md)
10
+
11
+ > Context-aware shell autocompletion and natural language command forge. Zero runtime dependencies. Sub-millisecond latency. Works 100% offline.
12
+
13
+ ```powershell
14
+ # 1. Instant heuristic autocompletion (<0.05ms):
15
+ PS C:\projects\anixcode> git p·ush origin main [Tab]
16
+ PS C:\projects\anixcode> pyt·est -q [Tab]
17
+ PS C:\projects\anixcode> pnpm d·ev [Tab]
18
+
19
+ # 2. Natural language command forge:
20
+ PS C:\projects\anixcode> ?? undo last commit keep files [Enter]
21
+ → git reset --soft HEAD~1
22
+
23
+ PS C:\projects\anixcode> ?? kill port 3000 [Enter]
24
+ → Stop-Process -Id (Get-NetTCPConnection -LocalPort 3000).OwningProcess -Force
25
+
26
+ # 3. Unlimited local AI via Ollama (qwen2.5-coder:1.5b):
27
+ PS C:\projects\anixcode> ?? top 5 memory heavy processes [Enter]
28
+ → Get-Process | Sort-Object -Property WorkingSet -Descending | Select-Object -First 5
29
+ ```
30
+
31
+ ---
32
+
33
+ ## Why ANIX Type?
34
+
35
+ - **⚡ Zero Runtime Dependencies:** Built strictly on the Python 3 standard library (`http.server`, `urllib`, `json`). Installs in seconds, zero package conflicts.
36
+ - **⚡ Sub-Millisecond Context Engine:** Directly reads `.git/HEAD` (<0.05 ms), parses `package.json` scripts, detects Python/Docker environments on the fly.
37
+ - **🔒 100% Offline & Private:** Built-in heuristic engine handles 95% of everyday developer commands locally without touching the network.
38
+ - **🧠 Unlimited AI Forge:** Connects to local [Ollama](https://ollama.com) (`qwen2.5-coder:1.5b`) for complete offline privacy, or any OpenAI-compatible provider (DeepSeek, Groq, OpenAI).
39
+ - **🌍 Bilingual (EN + RU):** Natural language command forge understands both English and Russian prompts out of the box.
40
+ - **💻 Native PowerShell Integration:** Hooks cleanly into `PSReadLine` for instant `Tab`, `RightArrow`, and `Enter` replacement without prompt flickering.
41
+
42
+ ---
43
+
44
+ ## Install
45
+
46
+ Requires Python 3.10+.
47
+
48
+ ```bash
49
+ pip install anix-type
50
+ ```
51
+
52
+ ### 1. Hook into PowerShell
53
+
54
+ Run the install command once to add the integration hook to your PowerShell `$PROFILE`:
55
+
56
+ ```powershell
57
+ anix-type install
58
+ ```
59
+
60
+ Reload your current terminal session:
61
+
62
+ ```powershell
63
+ . $PROFILE
64
+ ```
65
+
66
+ *(You will see `⚡ ANIX Type ready` in your console)*.
67
+
68
+ ---
69
+
70
+ ## Usage
71
+
72
+ ### Instant Autocompletion
73
+
74
+ Just type and press **Tab** or **RightArrow (→)**:
75
+
76
+ | What you type | What ANIX Type predicts | Context |
77
+ |---|---|---|
78
+ | `git p` + Tab | `git push origin <current-branch>` | Reads your actual `.git/HEAD` |
79
+ | `git s` + Tab | `git status` | Git repository |
80
+ | `pyt` + Tab | `pytest -q` | Python repository |
81
+ | `py` + Tab | `python` | Python environment |
82
+ | `pnpm d` + Tab | `pnpm dev` | Reads scripts from `package.json` |
83
+ | `pip i` + Tab | `pip install ` | Python |
84
+
85
+ ### Command Forge (`?? <what you want to do>`)
86
+
87
+ Type `??` followed by plain English or Russian, then press **Enter**:
88
+
89
+ ```powershell
90
+ # Git operations
91
+ ?? undo last commit keep files → git reset --soft HEAD~1
92
+ ?? stash changes → git stash
93
+ ?? pop stash → git stash pop
94
+ ?? new branch feat-login → git checkout -b feat-login
95
+ ?? discard changes → git restore .
96
+
97
+ # System & ports
98
+ ?? kill port 8080 → Stop-Process -Id (Get-NetTCPConnection -LocalPort 8080).OwningProcess -Force
99
+ ?? top memory processes → Get-Process | Sort-Object -Property WorkingSet -Descending | Select-Object -First 5
100
+ ?? folder size → calculates folder size in MB
101
+ ?? find file settings.py → Get-ChildItem -Recurse -Filter "*settings.py*"
102
+
103
+ # Python & Docker
104
+ ?? create venv → python -m venv .venv
105
+ ?? activate venv → .\.venv\Scripts\Activate.ps1
106
+ ?? purge pip cache → pip cache purge
107
+ ?? stop all docker containers → docker stop $(docker ps -q)
108
+ ```
109
+
110
+ ---
111
+
112
+ ## AI Providers (Optional)
113
+
114
+ ANIX Type works completely offline using built-in heuristics. For complex, non-template queries, you can optionally connect an AI model:
115
+
116
+ ### 1. Local Ollama (Recommended — 100% Free & Offline)
117
+
118
+ ```bash
119
+ # Install Ollama and pull lightweight coder model
120
+ winget install Ollama.Ollama
121
+ ollama run qwen2.5-coder:1.5b
122
+
123
+ # Switch ANIX Type to Ollama
124
+ anix-type config --ollama --model qwen2.5-coder:1.5b
125
+ ```
126
+
127
+ ### 2. DeepSeek / OpenAI / Custom Proxy
128
+
129
+ ```bash
130
+ anix-type config --openai-key sk-... --base-url https://api.deepseek.com/v1 --model deepseek-chat
131
+ ```
132
+
133
+ ### 3. Groq (Ultra-fast cloud)
134
+
135
+ ```bash
136
+ anix-type config --groq-key gsk_...
137
+ ```
138
+
139
+ ---
140
+
141
+ ## CLI Reference
142
+
143
+ ```bash
144
+ anix-type status # Check daemon health, port, and AI provider
145
+ anix-type start # Start daemon in background (auto-starts on terminal open)
146
+ anix-type stop # Stop background daemon
147
+ anix-type daemon # Run daemon in foreground with --verbose logging
148
+ anix-type config # Configure AI model and API keys
149
+ anix-type install # Install integration hook into PowerShell profile
150
+ ```
151
+
152
+ ---
153
+
154
+ ## Architecture
155
+
156
+ ```
157
+ ┌──────────────────────────────────────────────┐
158
+ │ Terminal (PSReadLine) │
159
+ └───────────────┬──────────────────────────────┘
160
+ │ HTTP / JSON (<2ms)
161
+ ▼
162
+ ┌──────────────────────────────────────────────┐
163
+ │ ANIX Type Daemon (127.0.0.1:8766) │
164
+ ├──────────────────────────────┬───────────────┤
165
+ │ Context Engine (<0.05ms) │ History Index │
166
+ └───────────────┬──────────────┴───────────────┘
167
+ │
168
+ ┌───────────────┴───────────────┐
169
+ ▼ ▼
170
+ [Offline Heuristics Engine] [AI Forge Layer]
171
+ • Direct .git/HEAD reader • Local Ollama (qwen2.5-coder)
172
+ • package.json script parser • DeepSeek / OpenAI / Groq
173
+ • Bilingual intent patterns • 100% offline fallback
174
+ ```
175
+
176
+ ---
177
+
178
+ ## License
179
+
180
+ MIT © [an1zy](https://github.com/an1zy)
@@ -0,0 +1,3 @@
1
+ """ANIX Type — context-aware AI autocompletion & command forge for your terminal."""
2
+
3
+ __version__ = "0.1.0"
@@ -0,0 +1,4 @@
1
+ from anix_type.cli import main
2
+
3
+ if __name__ == "__main__":
4
+ main()
@@ -0,0 +1,232 @@
1
+ """Command-line interface for anix-type."""
2
+ from __future__ import annotations
3
+
4
+ import argparse
5
+ import os
6
+ import subprocess
7
+ import sys
8
+ import urllib.request
9
+ from pathlib import Path
10
+
11
+ from . import __version__
12
+ from .server import run_server
13
+ from .settings import Settings, get_config_dir
14
+
15
+
16
+ def _check_running(port: int = 8766) -> bool:
17
+ try:
18
+ with urllib.request.urlopen(f"http://127.0.0.1:{port}/health", timeout=0.5) as resp:
19
+ return resp.status == 200
20
+ except Exception:
21
+ return False
22
+
23
+
24
+ def cmd_status(args: argparse.Namespace) -> None:
25
+ settings = Settings.load()
26
+ running = _check_running(settings.port)
27
+ print(f"⚡ ANIX Type v{__version__}")
28
+ print(f" Daemon status: {'🟢 Running' if running else '🔴 Stopped'}")
29
+ print(f" Port: {settings.port}")
30
+ print(f" AI Provider: {settings.ai_provider}")
31
+ print(f" AI Model: {settings.model}")
32
+ if settings.ai_provider == "groq":
33
+ masked = (settings.groq_api_key[:6] + "…" + settings.groq_api_key[-4:]) if len(settings.groq_api_key) > 10 else "(not set)"
34
+ print(f" Groq Key: {masked}")
35
+
36
+
37
+ def cmd_daemon(args: argparse.Namespace) -> None:
38
+ run_server(port=args.port, verbose=args.verbose)
39
+
40
+
41
+ def cmd_start(args: argparse.Namespace) -> None:
42
+ settings = Settings.load()
43
+ if _check_running(settings.port):
44
+ print(f"⚡ ANIX Type is already running on port {settings.port}!")
45
+ return
46
+
47
+ exe = sys.executable
48
+ if sys.platform == "win32":
49
+ pw = Path(sys.executable).parent / "pythonw.exe"
50
+ if pw.is_file():
51
+ exe = str(pw)
52
+
53
+ cmd = [exe, "-m", "anix_type", "daemon", "--port", str(settings.port)]
54
+ creationflags = 0
55
+ if sys.platform == "win32":
56
+ creationflags = subprocess.CREATE_NO_WINDOW | subprocess.DETACHED_PROCESS | subprocess.CREATE_NEW_PROCESS_GROUP # type: ignore[attr-defined]
57
+
58
+ subprocess.Popen(
59
+ cmd,
60
+ stdin=subprocess.DEVNULL,
61
+ stdout=subprocess.DEVNULL,
62
+ stderr=subprocess.DEVNULL,
63
+ creationflags=creationflags,
64
+ close_fds=True,
65
+ )
66
+ print(f"⚡ ANIX Type started in background on http://127.0.0.1:{settings.port}")
67
+
68
+
69
+ def cmd_stop(args: argparse.Namespace) -> None:
70
+ settings = Settings.load()
71
+ if not _check_running(settings.port):
72
+ print("ANIX Type is not running.")
73
+ return
74
+
75
+ if sys.platform == "win32":
76
+ try:
77
+ out = subprocess.check_output(f"netstat -ano | findstr :{settings.port}", shell=True, text=True)
78
+ for line in out.splitlines():
79
+ if "LISTENING" in line:
80
+ pid = line.strip().split()[-1]
81
+ subprocess.run(f"taskkill /PID {pid} /F", shell=True, check=False)
82
+ print("⚡ ANIX Type daemon stopped.")
83
+ return
84
+ except Exception:
85
+ pass
86
+ print("Could not automatically stop daemon. Please close the process.")
87
+
88
+
89
+ def cmd_install(args: argparse.Namespace) -> None:
90
+ """Install integration hook into PowerShell profile or bash/zsh."""
91
+ if sys.platform == "win32":
92
+ _install_powershell()
93
+ else:
94
+ print("For Linux/macOS, add `eval $(anix-type init zsh)` to your ~/.zshrc or ~/.bashrc.")
95
+
96
+
97
+ def _get_powershell_profile_path() -> Path:
98
+ candidates = [
99
+ Path.home() / "Documents" / "WindowsPowerShell" / "Microsoft.PowerShell_profile.ps1",
100
+ Path.home() / "OneDrive" / "Documents" / "WindowsPowerShell" / "Microsoft.PowerShell_profile.ps1",
101
+ ]
102
+ for c in candidates:
103
+ if c.is_file():
104
+ return c
105
+
106
+ try:
107
+ raw = subprocess.check_output(
108
+ ["powershell", "-NoProfile", "-Command", "[Console]::OutputEncoding = [System.Text.Encoding]::UTF8; Write-Output $PROFILE"],
109
+ )
110
+ path_str = raw.decode("utf-8", errors="replace").strip()
111
+ if path_str:
112
+ return Path(path_str)
113
+ except Exception:
114
+ pass
115
+
116
+ return candidates[0]
117
+
118
+
119
+ def _install_powershell() -> None:
120
+ ps_file = Path(__file__).resolve().parent / "integrations" / "anix-type.ps1"
121
+ if not ps_file.is_file():
122
+ print(f"Error: integration script not found at {ps_file}")
123
+ return
124
+
125
+ profile_path = _get_powershell_profile_path()
126
+ profile_path.parent.mkdir(parents=True, exist_ok=True)
127
+
128
+ hook_line = f'. "{ps_file}"'
129
+ existing = ""
130
+ if profile_path.is_file():
131
+ existing = profile_path.read_text(encoding="utf-8", errors="ignore")
132
+
133
+ if hook_line in existing:
134
+ print("✓ ANIX Type is already hooked into your PowerShell $PROFILE:")
135
+ print(f" {profile_path}")
136
+ else:
137
+ with open(profile_path, "a", encoding="utf-8") as f:
138
+ if existing and not existing.endswith("\n"):
139
+ f.write("\n")
140
+ f.write(f"\n# ANIX Type shell autocompletion\n{hook_line}\n")
141
+ print("🎉 Successfully hooked ANIX Type into PowerShell $PROFILE:")
142
+ print(f" {profile_path}")
143
+ print("\nTo activate immediately, restart PowerShell or run:")
144
+ print(f' . "$PROFILE"')
145
+
146
+
147
+ def cmd_config(args: argparse.Namespace) -> None:
148
+ settings = Settings.load()
149
+ changed = False
150
+
151
+ if args.groq_key:
152
+ settings.groq_api_key = args.groq_key.strip()
153
+ settings.ai_provider = "groq"
154
+ changed = True
155
+ print("✓ Groq API key saved and activated!")
156
+
157
+ if args.openai_key:
158
+ settings.openai_api_key = args.openai_key.strip()
159
+ settings.ai_provider = "openai"
160
+ changed = True
161
+ print("✓ OpenAI/DeepSeek/Custom API key saved and activated!")
162
+
163
+ if args.base_url:
164
+ settings.openai_base_url = args.base_url.strip()
165
+ changed = True
166
+ print(f"✓ Base URL set to: {settings.openai_base_url}")
167
+
168
+ if args.model:
169
+ settings.model = args.model.strip()
170
+ changed = True
171
+ print(f"✓ Model set to: {settings.model}")
172
+
173
+ if args.ollama:
174
+ settings.ai_provider = "ollama"
175
+ changed = True
176
+ print("✓ Switched AI provider to local Ollama!")
177
+
178
+ if changed:
179
+ settings.save()
180
+ print("Restarting daemon to apply new configuration...")
181
+ cmd_stop(args)
182
+ cmd_start(args)
183
+ else:
184
+ print("Usage:")
185
+ print(" anix-type config --groq-key gsk_...")
186
+ print(" anix-type config --openai-key sk-... [--base-url https://api.deepseek.com/v1] [--model deepseek-chat]")
187
+ print(" anix-type config --ollama [--model qwen2.5-coder:1.5b]")
188
+
189
+
190
+ def main() -> None:
191
+ parser = argparse.ArgumentParser(prog="anix-type", description="Context-aware AI autocompletion for terminal.")
192
+ subparsers = parser.add_subparsers(dest="command")
193
+
194
+ p_daemon = subparsers.add_parser("daemon", help="Run the daemon in foreground")
195
+ p_daemon.add_argument("--port", type=int, default=8766, help="Port to listen on (default: 8766)")
196
+ p_daemon.add_argument("--verbose", action="store_true", help="Enable debug logging")
197
+
198
+ subparsers.add_parser("start", help="Start the daemon in background")
199
+ subparsers.add_parser("stop", help="Stop the running background daemon")
200
+ subparsers.add_parser("status", help="Show daemon and AI configuration status")
201
+ subparsers.add_parser("install", help="Hook ANIX Type into PowerShell $PROFILE")
202
+
203
+ p_conf = subparsers.add_parser("config", help="Configure AI providers and keys")
204
+ p_conf.add_argument("--groq-key", help="Free Groq API key from console.groq.com")
205
+ p_conf.add_argument("--openai-key", help="OpenAI, DeepSeek, OpenRouter or proxy API key")
206
+ p_conf.add_argument("--base-url", help="Custom OpenAI-compatible base URL (e.g. https://api.deepseek.com/v1)")
207
+ p_conf.add_argument("--ollama", action="store_true", help="Use local Ollama")
208
+ p_conf.add_argument("--model", help="Model name (e.g. deepseek-chat, gpt-4o-mini, llama-3.1-8b-instant)")
209
+
210
+ args = parser.parse_args()
211
+ if not args.command:
212
+ cmd_status(args)
213
+ return
214
+
215
+ commands = {
216
+ "status": cmd_status,
217
+ "daemon": cmd_daemon,
218
+ "start": cmd_start,
219
+ "stop": cmd_stop,
220
+ "install": cmd_install,
221
+ "config": cmd_config,
222
+ }
223
+
224
+ fn = commands.get(args.command)
225
+ if fn:
226
+ fn(args)
227
+ else:
228
+ parser.print_help()
229
+
230
+
231
+ if __name__ == "__main__":
232
+ main()