Skip to content
Closed
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension


Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
162 changes: 162 additions & 0 deletions nexuscli/README.md
Original file line number Diff line number Diff line change
@@ -0,0 +1,162 @@
# NexusCLI

> **A fast, lightweight, Termux-optimized CLI/TUI for agent interactions.**
> Powered by `curl_cffi` and reverse-engineered DeepSeek API endpoints.

---

## 🚀 Features

- **Blazing Fast**: Uses `curl_cffi` for high-performance API calls.
- **Termux Optimized**: Designed for mobile/Termux environments.
- **Lightweight**: No Playwright or heavy dependencies.
- **Phased Architecture**: Modular design for instant execution.
- **Session Management**: Create, list, and manage chat sessions.
- **Interactive Chat**: Real-time streaming responses.

Copy link
Copy Markdown
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

🎯 Functional Correctness | 🟡 Minor | ⚡ Quick win

🧩 Analysis chain

🏁 Script executed:

#!/bin/bash
set -euo pipefail

echo "== files =="
git ls-files | rg '(^|/)README\.md$|nexuscli/core/api\.py$' || true

echo
echo "== README excerpt =="
if [ -f nexuscli/README.md ]; then
  sed -n '1,40p' nexuscli/README.md | cat -n
fi

echo
echo "== api outline =="
ast-grep outline nexuscli/core/api.py --view compact 2>/dev/null | sed -n '1,120p' || true

echo
echo "== api relevant lines =="
sed -n '230,365p' nexuscli/core/api.py | cat -n

echo
echo "== stream=True occurrences =="
rg -n "stream\s*=|streaming|stream" nexuscli/README.md nexuscli/core/api.py || true

echo
echo "== parser/chunk mentions =="
rg -n "chunk|parse|Stream|Generator|yield|open .*request|response\.(iter|content|text)" nexuscli -g '*.py' -g '*.md' || true

Repository: timerloggedout-spec/termux-monorepo

Length of output: 12502


🏁 Script executed:

#!/bin/bash
set -euo pipefail

python3 - <<'PY'
# Read-only probe: inspect source text for response handling and streaming parser calls.
from pathlib import Path
api = Path("nexuscli/core/api.py")
md = Path("nexuscli/README.md")
print("api exists:", api.exists())
print("README exists:", md.exists())
if api.exists():
    text = api.read_text()
    print("\ncontains resp.content:", "resp.content" in text)
    print("\ncontains stream=True:", "stream=True" in text)
    print("\ncontains parse_stream or similar:", any(s in text for s in ["parse_stream", "stream_response", "iter_lines", "decode_stream"]))
    idx = text.find("resp.content")
    start = max(0, idx - 1200) if idx >= 0 else 0
    end = min(len(text), idx + 1200) if idx >= 0 else 0
    print("\ncontext around resp.content:")
    print(text[start:end])
if md.exists():
    print("\nREADME line with interactive chat:")
    for i, line in enumerate(md.read_text().splitlines(), 1):
        if "Interactive Chat" in line:
            print(f"{i}: {line}")
PY

Repository: timerloggedout-spec/termux-monorepo

Length of output: 2834


Make the interactive chat description match the implementation.

stream_completion() sends stream=True, but resp.content is decoded after the response is fully buffered before SSE parsing and printing. The response is not yielded in real time; update nexuscli/README.md:15 or consume and print each SSE chunk as it arrives.

🤖 Prompt for AI Agents
Verify each finding against current code. Fix only still-valid issues, skip the
rest with a brief reason, keep changes minimal, and validate.

In `@nexuscli/README.md` at line 15, Update the Interactive Chat description in
the README to reflect that responses are buffered before SSE parsing rather than
streamed in real time; do not claim real-time streaming unless the
implementation is changed to process and print SSE chunks as they arrive.

- **Export Capabilities**: Export conversations to Markdown or JSON.

---

## 📦 Installation

### 1. Clone the Repository

```bash
cd ~/termux-monorepo
git checkout vibe/deepcode-cli_phased-fusion_fc54fa
```
Comment on lines +22 to +27

Copy link
Copy Markdown
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

🎯 Functional Correctness | 🟡 Minor | ⚡ Quick win

Make the clone step runnable from a clean checkout.

This section does not clone the repository. It assumes that ~/termux-monorepo already exists. It also checks out a PR-specific branch instead of a stable branch or release tag. Add a git clone command and use a published ref.

🤖 Prompt for AI Agents
Verify each finding against current code. Fix only still-valid issues, skip the
rest with a brief reason, keep changes minimal, and validate.

In `@nexuscli/README.md` around lines 22 - 27, Update the “Clone the Repository”
section in README.md to include a runnable git clone command for a clean
checkout, then change the checkout command to use a published stable branch or
release tag instead of the PR-specific ref.


### 2. Install Dependencies

```bash
pip install curl_cffi rich
```
Comment on lines +29 to +33

Copy link
Copy Markdown
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

🎯 Functional Correctness | 🟠 Major | ⚡ Quick win

Install the local package, not only its dependencies.

pip install curl_cffi rich installs third-party packages only. It does not install the local nexuscli package or register the nexuscli command. The documented commands can fail on a clean checkout. Install from nexuscli/requirements.txt and install the local package using its declared package metadata.

🤖 Prompt for AI Agents
Verify each finding against current code. Fix only still-valid issues, skip the
rest with a brief reason, keep changes minimal, and validate.

In `@nexuscli/README.md` around lines 29 - 33, Update the “Install Dependencies”
section in README.md to install dependencies from nexuscli/requirements.txt and
install the local package through its declared packaging metadata, ensuring the
nexuscli command is registered on a clean checkout instead of installing only
curl_cffi and rich.


### 3. Set Up API Token

```bash
export NEXUSCLI_TOKEN="your_deepseek_token_here"
# Or save in config
echo '{"token": "your_deepseek_token_here"}' > ~/.nexuscli/config.json

Copy link
Copy Markdown
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

🎯 Functional Correctness | 🟡 Minor | ⚡ Quick win

Create ~/.nexuscli before writing the config.

Shell redirection runs before the CLI can create directories. On first use, this command fails if ~/.nexuscli does not exist. Add mkdir -p ~/.nexuscli or document a supported configuration command.

🤖 Prompt for AI Agents
Verify each finding against current code. Fix only still-valid issues, skip the
rest with a brief reason, keep changes minimal, and validate.

In `@nexuscli/README.md` at line 40, Update the configuration setup instructions
around the config.json shell command to create ~/.nexuscli before writing the
file, using mkdir -p or an existing supported configuration command so
first-time setup succeeds.

```

---

## 🎯 Usage

### Basic Commands

| Command | Description |
|---------|-------------|
| `nexuscli sessions` | List all sessions |
| `nexuscli new-session` | Create a new session |
| `nexuscli chat --last` | Start interactive chat |
| `nexuscli send --prompt "Hello" --last` | Send a single message |
| `nexuscli export --last --format markdown` | Export session history |

### Examples

```bash
# List all sessions
nexuscli sessions

# Create a new expert session
nexuscli new-session --model expert --save

# Start interactive chat with last session
nexuscli chat --last --thinking

# Send a single message
nexuscli send --prompt "Explain Python decorators" --last

# Export session to Markdown
nexuscli export --last --format markdown --output conversation.md
```

---

## 🏗️ Project Structure

```
nexuscli/
├── __init__.py
├── core/
│ ├── __init__.py
│ └── api.py # Core API wrapper (reverse-engineered)
├── cli/
│ ├── __init__.py
│ └── main.py # CLI entry point
├── nexuscli.py # Launcher script
├── pow_solver.js # POW solver for API challenges
└── README.md
```

---

## 🔧 Configuration

### Config File

Located at `~/.nexuscli/config.json`:

```json
{
"token": "your_deepseek_token",
"last_session": "your_last_session_id"
}
```

### Environment Variables

- `NEXUSCLI_TOKEN` or `DEEPSEEK_TOKEN`: API token
- `NEXUSCLI_BASE_URL`: Custom API base URL (default: `https://chat.deepseek.com`)

---

## 🤖 API Endpoints

The following endpoints are reverse-engineered and used:

| Endpoint | Description |
|----------|-------------|
| `/api/v0/chat_session/create` | Create a new chat session |
| `/api/v0/chat_session/fetch_page` | Fetch all sessions |
| `/api/v0/chat/history_messages` | Get session history |
| `/api/v0/chat/create_pow_challenge` | Get POW challenge |
| `/api/v0/chat/completion` | Send message (streaming) |
| `/api/v0/file/upload_file` | Upload a file |
| `/api/v0/share/create` | Create a share |
| `/api/v0/share/fork` | Fork a conversation |

---

## 📜 License

MIT License. See [LICENSE](../../LICENSE) for details.

Copy link
Copy Markdown
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

📐 Maintainability & Code Quality | 🟡 Minor | ⚡ Quick win

Fix the relative LICENSE link.

From nexuscli/README.md, ../../LICENSE resolves above the repository root. Use ../LICENSE when LICENSE is stored at the repository root.

🤖 Prompt for AI Agents
Verify each finding against current code. Fix only still-valid issues, skip the
rest with a brief reason, keep changes minimal, and validate.

In `@nexuscli/README.md` at line 135, Update the MIT License link in the README to
reference the repository-root LICENSE file with ../LICENSE instead of
../../LICENSE.


---

## 🙌 Contributing

1. Fork the repository
2. Create a feature branch (`git checkout -b feature/amazing-feature`)
3. Commit your changes (`git commit -m 'Add amazing feature'`)
4. Push to the branch (`git push origin feature/amazing-feature`)
5. Open a Pull Request

---

## 🔗 Related Projects

- [termux-monorepo](https://github.com/timerloggedout-spec/termux-monorepo)
- [deepcli](https://github.com/timerloggedout-spec/termux-monorepo/tree/master/deepcli)
- [multi-ai-cli](https://github.com/timerloggedout-spec/termux-monorepo/tree/master/multi-ai-cli)
- [termux-multi-agent](https://github.com/timerloggedout-spec/termux-monorepo/tree/master/termux-multi-agent)

---

## 🎨 Branding

**NexusCLI** is part of the **Termux Monorepo** ecosystem.

> **"All for One; and, One for All!"** 🚀
9 changes: 9 additions & 0 deletions nexuscli/__init__.py
Original file line number Diff line number Diff line change
@@ -0,0 +1,9 @@
#!/usr/bin/env python3
"""
NexusCLI
A fast, lightweight, Termux-optimized CLI/TUI for agent interactions.
Uses curl_cffi for high-performance API calls.
"""

__version__ = "0.1.0"
__author__ = "Termux Monorepo Team"
8 changes: 8 additions & 0 deletions nexuscli/cli/__init__.py
Original file line number Diff line number Diff line change
@@ -0,0 +1,8 @@
#!/usr/bin/env python3
"""
CLI module for DeepCode-CLI Phased Nexus.
"""

from .main import main

__all__ = ["main"]
Loading
Loading