@elasto/nyx-cli 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.
- package/README.md +136 -0
- package/bin/nyx.js +3 -0
- package/dist/agent/index.d.ts +29 -0
- package/dist/agent/index.d.ts.map +1 -0
- package/dist/agent/index.js +362 -0
- package/dist/agent/index.js.map +1 -0
- package/dist/agent/prompt.d.ts +16 -0
- package/dist/agent/prompt.d.ts.map +1 -0
- package/dist/agent/prompt.js +487 -0
- package/dist/agent/prompt.js.map +1 -0
- package/dist/agent/templates/index.d.ts +2 -0
- package/dist/agent/templates/index.d.ts.map +1 -0
- package/dist/agent/templates/index.js +44 -0
- package/dist/agent/templates/index.js.map +1 -0
- package/dist/auth/index.d.ts +23 -0
- package/dist/auth/index.d.ts.map +1 -0
- package/dist/auth/index.js +161 -0
- package/dist/auth/index.js.map +1 -0
- package/dist/commands/login.d.ts +3 -0
- package/dist/commands/login.d.ts.map +1 -0
- package/dist/commands/login.js +32 -0
- package/dist/commands/login.js.map +1 -0
- package/dist/commands/logout.d.ts +3 -0
- package/dist/commands/logout.d.ts.map +1 -0
- package/dist/commands/logout.js +13 -0
- package/dist/commands/logout.js.map +1 -0
- package/dist/commands/logs.d.ts +3 -0
- package/dist/commands/logs.d.ts.map +1 -0
- package/dist/commands/logs.js +29 -0
- package/dist/commands/logs.js.map +1 -0
- package/dist/commands/root.d.ts +3 -0
- package/dist/commands/root.d.ts.map +1 -0
- package/dist/commands/root.js +27 -0
- package/dist/commands/root.js.map +1 -0
- package/dist/commands/run.d.ts +3 -0
- package/dist/commands/run.d.ts.map +1 -0
- package/dist/commands/run.js +74 -0
- package/dist/commands/run.js.map +1 -0
- package/dist/commands/session.d.ts +3 -0
- package/dist/commands/session.d.ts.map +1 -0
- package/dist/commands/session.js +61 -0
- package/dist/commands/session.js.map +1 -0
- package/dist/config/index.d.ts +22 -0
- package/dist/config/index.d.ts.map +1 -0
- package/dist/config/index.js +110 -0
- package/dist/config/index.js.map +1 -0
- package/dist/db/index.d.ts +5 -0
- package/dist/db/index.d.ts.map +1 -0
- package/dist/db/index.js +72 -0
- package/dist/db/index.js.map +1 -0
- package/dist/events/index.d.ts +3 -0
- package/dist/events/index.d.ts.map +1 -0
- package/dist/events/index.js +45 -0
- package/dist/events/index.js.map +1 -0
- package/dist/filetracker/index.d.ts +8 -0
- package/dist/filetracker/index.d.ts.map +1 -0
- package/dist/filetracker/index.js +21 -0
- package/dist/filetracker/index.js.map +1 -0
- package/dist/hooks/index.d.ts +13 -0
- package/dist/hooks/index.d.ts.map +1 -0
- package/dist/hooks/index.js +42 -0
- package/dist/hooks/index.js.map +1 -0
- package/dist/index.d.ts +2 -0
- package/dist/index.d.ts.map +1 -0
- package/dist/index.js +140 -0
- package/dist/index.js.map +1 -0
- package/dist/logging/index.d.ts +16 -0
- package/dist/logging/index.d.ts.map +1 -0
- package/dist/logging/index.js +76 -0
- package/dist/logging/index.js.map +1 -0
- package/dist/lsp/index.d.ts +10 -0
- package/dist/lsp/index.d.ts.map +1 -0
- package/dist/lsp/index.js +130 -0
- package/dist/lsp/index.js.map +1 -0
- package/dist/mcp/index.d.ts +11 -0
- package/dist/mcp/index.d.ts.map +1 -0
- package/dist/mcp/index.js +102 -0
- package/dist/mcp/index.js.map +1 -0
- package/dist/permissions/index.d.ts +13 -0
- package/dist/permissions/index.d.ts.map +1 -0
- package/dist/permissions/index.js +96 -0
- package/dist/permissions/index.js.map +1 -0
- package/dist/session/index.d.ts +25 -0
- package/dist/session/index.d.ts.map +1 -0
- package/dist/session/index.js +100 -0
- package/dist/session/index.js.map +1 -0
- package/dist/shell/index.d.ts +8 -0
- package/dist/shell/index.d.ts.map +1 -0
- package/dist/shell/index.js +29 -0
- package/dist/shell/index.js.map +1 -0
- package/dist/skills/index.d.ts +9 -0
- package/dist/skills/index.d.ts.map +1 -0
- package/dist/skills/index.js +53 -0
- package/dist/skills/index.js.map +1 -0
- package/dist/tools/bash.d.ts +35 -0
- package/dist/tools/bash.d.ts.map +1 -0
- package/dist/tools/bash.js +44 -0
- package/dist/tools/bash.js.map +1 -0
- package/dist/tools/diagnostics.d.ts +19 -0
- package/dist/tools/diagnostics.d.ts.map +1 -0
- package/dist/tools/diagnostics.js +45 -0
- package/dist/tools/diagnostics.js.map +1 -0
- package/dist/tools/edit.d.ts +31 -0
- package/dist/tools/edit.d.ts.map +1 -0
- package/dist/tools/edit.js +72 -0
- package/dist/tools/edit.js.map +1 -0
- package/dist/tools/glob.d.ts +23 -0
- package/dist/tools/glob.d.ts.map +1 -0
- package/dist/tools/glob.js +40 -0
- package/dist/tools/glob.js.map +1 -0
- package/dist/tools/grep.d.ts +31 -0
- package/dist/tools/grep.d.ts.map +1 -0
- package/dist/tools/grep.js +72 -0
- package/dist/tools/grep.js.map +1 -0
- package/dist/tools/index.d.ts +9 -0
- package/dist/tools/index.d.ts.map +1 -0
- package/dist/tools/index.js +78 -0
- package/dist/tools/index.js.map +1 -0
- package/dist/tools/job_output.d.ts +49 -0
- package/dist/tools/job_output.d.ts.map +1 -0
- package/dist/tools/job_output.js +57 -0
- package/dist/tools/job_output.js.map +1 -0
- package/dist/tools/ls.d.ts +19 -0
- package/dist/tools/ls.d.ts.map +1 -0
- package/dist/tools/ls.js +55 -0
- package/dist/tools/ls.js.map +1 -0
- package/dist/tools/todos.d.ts +41 -0
- package/dist/tools/todos.d.ts.map +1 -0
- package/dist/tools/todos.js +54 -0
- package/dist/tools/todos.js.map +1 -0
- package/dist/tools/view.d.ts +27 -0
- package/dist/tools/view.d.ts.map +1 -0
- package/dist/tools/view.js +59 -0
- package/dist/tools/view.js.map +1 -0
- package/dist/tools/web_fetch.d.ts +24 -0
- package/dist/tools/web_fetch.d.ts.map +1 -0
- package/dist/tools/web_fetch.js +43 -0
- package/dist/tools/web_fetch.js.map +1 -0
- package/dist/tools/web_search.d.ts +23 -0
- package/dist/tools/web_search.d.ts.map +1 -0
- package/dist/tools/web_search.js +41 -0
- package/dist/tools/web_search.js.map +1 -0
- package/dist/tools/write.d.ts +23 -0
- package/dist/tools/write.d.ts.map +1 -0
- package/dist/tools/write.js +39 -0
- package/dist/tools/write.js.map +1 -0
- package/dist/types/index.d.ts +136 -0
- package/dist/types/index.d.ts.map +1 -0
- package/dist/types/index.js +3 -0
- package/dist/types/index.js.map +1 -0
- package/dist/ui/index.d.ts +3 -0
- package/dist/ui/index.d.ts.map +1 -0
- package/dist/ui/index.js +318 -0
- package/dist/ui/index.js.map +1 -0
- package/dist/util/diff.d.ts +17 -0
- package/dist/util/diff.d.ts.map +1 -0
- package/dist/util/diff.js +74 -0
- package/dist/util/diff.js.map +1 -0
- package/dist/util/index.d.ts +6 -0
- package/dist/util/index.d.ts.map +1 -0
- package/dist/util/index.js +33 -0
- package/dist/util/index.js.map +1 -0
- package/dist/workspace/index.d.ts +6 -0
- package/dist/workspace/index.d.ts.map +1 -0
- package/dist/workspace/index.js +133 -0
- package/dist/workspace/index.js.map +1 -0
- package/package.json +47 -0
package/README.md
ADDED
|
@@ -0,0 +1,136 @@
|
|
|
1
|
+
# Nyx
|
|
2
|
+
|
|
3
|
+
**Your AI pair programmer — right in the terminal.**
|
|
4
|
+
|
|
5
|
+
Nyx is an AI-powered coding assistant that lives in your CLI. It reads your codebase, understands your project, and helps you write, edit, debug, and refactor code — all without leaving your terminal.
|
|
6
|
+
|
|
7
|
+
Think of it as an engineering teammate that never sleeps, installed via npm.
|
|
8
|
+
|
|
9
|
+
## Why Nyx?
|
|
10
|
+
|
|
11
|
+
Instead of copying errors into ChatGPT or switching context to a web browser, Nyx works **where you already are**:
|
|
12
|
+
|
|
13
|
+
```
|
|
14
|
+
cd your-project
|
|
15
|
+
nyx
|
|
16
|
+
❯ add input validation to the login endpoint
|
|
17
|
+
```
|
|
18
|
+
|
|
19
|
+
Nyx reads the relevant files, plans the change, and executes it — writing code, running tests, fixing errors — all autonomously.
|
|
20
|
+
|
|
21
|
+
## How It Works
|
|
22
|
+
|
|
23
|
+
```
|
|
24
|
+
You type a prompt → Nyx analyzes your codebase
|
|
25
|
+
→ Plans the change
|
|
26
|
+
→ Edits files, runs commands
|
|
27
|
+
→ Summarizes what was done
|
|
28
|
+
```
|
|
29
|
+
|
|
30
|
+
Nyx has access to tools — `view`, `write`, `edit`, `grep`, `bash`, and more — and uses them to get work done. It's like having a senior engineer iterating on your feedback loop in real time.
|
|
31
|
+
|
|
32
|
+
## Installation
|
|
33
|
+
|
|
34
|
+
```bash
|
|
35
|
+
npm install -g @elasto/nyx-cli
|
|
36
|
+
```
|
|
37
|
+
|
|
38
|
+
Requires **Node.js 20+**.
|
|
39
|
+
|
|
40
|
+
## Quick Start
|
|
41
|
+
|
|
42
|
+
```bash
|
|
43
|
+
# Create an account via browser
|
|
44
|
+
nyx login --signup
|
|
45
|
+
|
|
46
|
+
# Log in
|
|
47
|
+
nyx login
|
|
48
|
+
|
|
49
|
+
# Start an interactive session
|
|
50
|
+
cd your-project
|
|
51
|
+
nyx
|
|
52
|
+
|
|
53
|
+
# Or run a one-off prompt
|
|
54
|
+
nyx run "explain the architecture of this project"
|
|
55
|
+
```
|
|
56
|
+
|
|
57
|
+
## What Nyx Can Do
|
|
58
|
+
|
|
59
|
+
| Task | Example |
|
|
60
|
+
|---|---|
|
|
61
|
+
| **Understand your codebase** | `nyx run "what does this project do?"` |
|
|
62
|
+
| **Write new code** | `nyx run "add a healthcheck endpoint"` |
|
|
63
|
+
| **Debug errors** | Paste an error log and ask Nyx to find the root cause |
|
|
64
|
+
| **Fix issues** | `nyx run "fix the TypeScript errors in src/"` |
|
|
65
|
+
| **Refactor** | `nyx run "extract the database logic into a separate module"` |
|
|
66
|
+
| **Install deps + run tests** | Nyx runs `npm install` and `npm test` automatically |
|
|
67
|
+
| **Continue after interruptions** | `nyx -C` picks up where you left off |
|
|
68
|
+
|
|
69
|
+
## Commands
|
|
70
|
+
|
|
71
|
+
| Command | Description |
|
|
72
|
+
|---|---|
|
|
73
|
+
| `nyx` | Start interactive TUI session |
|
|
74
|
+
| `nyx run <prompt>` | Run a prompt non-interactively |
|
|
75
|
+
| `nyx login` | Log in via browser |
|
|
76
|
+
| `nyx logout` | Log out |
|
|
77
|
+
| `nyx -C` | Continue the most recent session |
|
|
78
|
+
| `nyx -S <id>` | Continue a specific session |
|
|
79
|
+
|
|
80
|
+
### Interactive (inside `nyx`)
|
|
81
|
+
|
|
82
|
+
| Command | Description |
|
|
83
|
+
|---|---|
|
|
84
|
+
| `/login` | Log in |
|
|
85
|
+
| `/logout` | Log out |
|
|
86
|
+
| `/continue` | Resume last session |
|
|
87
|
+
| `/plan` | View current task plan |
|
|
88
|
+
| `/usage` | Check token usage |
|
|
89
|
+
| `/subscribe` | View plans and upgrade |
|
|
90
|
+
| `/exit` | Quit |
|
|
91
|
+
|
|
92
|
+
## Features
|
|
93
|
+
|
|
94
|
+
- **Streaming AI responses** — see the AI think in real time
|
|
95
|
+
- **Autonomous tool use** — Nyx runs shell commands, edits files, installs packages
|
|
96
|
+
- **Session persistence** — conversation history saved locally, resume anytime
|
|
97
|
+
- **Smart summaries** — structured recap after every task
|
|
98
|
+
- **Plan tracking** — automatically creates todo lists for complex multi-step tasks
|
|
99
|
+
- **Permission system** — approve or deny each action (or use `--yolo`)
|
|
100
|
+
- **Color-coded actions** — green (view), cyan (write), yellow (edit), red (delete), magenta (bash)
|
|
101
|
+
|
|
102
|
+
## Plans
|
|
103
|
+
|
|
104
|
+
| Tier | Tokens / month | Price |
|
|
105
|
+
|---|---|---|
|
|
106
|
+
| Free | 10,000 | $0 |
|
|
107
|
+
| Starter | 200,000 | $7.99 |
|
|
108
|
+
| Pro | 1,000,000 | $14.99 |
|
|
109
|
+
| Enterprise | 10,000,000 | $99.99 |
|
|
110
|
+
|
|
111
|
+
## Dashboard
|
|
112
|
+
|
|
113
|
+
Manage your account, view usage, and upgrade at [nyx.elasto.ng](https://nyx.elasto.ng).
|
|
114
|
+
|
|
115
|
+
## Configuration
|
|
116
|
+
|
|
117
|
+
No configuration needed. Nyx works out of the box pointing to `nyx.elasto.ng`.
|
|
118
|
+
|
|
119
|
+
To use a self-hosted backend, create a `nyx.json`:
|
|
120
|
+
|
|
121
|
+
```json
|
|
122
|
+
{
|
|
123
|
+
"web_url": "https://your-instance.com",
|
|
124
|
+
"api_url": "https://api.your-instance.com"
|
|
125
|
+
}
|
|
126
|
+
```
|
|
127
|
+
|
|
128
|
+
## Requirements
|
|
129
|
+
|
|
130
|
+
- Node.js 20+
|
|
131
|
+
- A Nyx account ([sign up](https://nyx.elasto.ng))
|
|
132
|
+
- Internet connection
|
|
133
|
+
|
|
134
|
+
## License
|
|
135
|
+
|
|
136
|
+
MIT
|
package/bin/nyx.js
ADDED
|
@@ -0,0 +1,29 @@
|
|
|
1
|
+
import { Config } from '../config/index.js';
|
|
2
|
+
import type { ChatMessage, AgentEvent } from '../types/index.js';
|
|
3
|
+
export interface AgentCall {
|
|
4
|
+
prompt: string;
|
|
5
|
+
history?: ChatMessage[];
|
|
6
|
+
projectPath: string;
|
|
7
|
+
openFiles?: {
|
|
8
|
+
path: string;
|
|
9
|
+
content?: string;
|
|
10
|
+
}[];
|
|
11
|
+
sessionId?: string;
|
|
12
|
+
onEvent?: (event: AgentEvent) => void;
|
|
13
|
+
}
|
|
14
|
+
export declare class Agent {
|
|
15
|
+
private auth;
|
|
16
|
+
private config;
|
|
17
|
+
private permissions;
|
|
18
|
+
private fileTracker;
|
|
19
|
+
private sessions;
|
|
20
|
+
private abortController;
|
|
21
|
+
constructor(config: Config, yolo?: boolean);
|
|
22
|
+
execute(call: AgentCall): Promise<void>;
|
|
23
|
+
private detectPlan;
|
|
24
|
+
private streamNyx;
|
|
25
|
+
private parseToolCalls;
|
|
26
|
+
private extractToolCalls;
|
|
27
|
+
cancel(): void;
|
|
28
|
+
}
|
|
29
|
+
//# sourceMappingURL=index.d.ts.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"index.d.ts","sourceRoot":"","sources":["../../src/agent/index.ts"],"names":[],"mappings":"AACA,OAAO,EAAE,MAAM,EAAE,MAAM,oBAAoB,CAAA;AAS3C,OAAO,KAAK,EAAE,WAAW,EAAY,UAAU,EAAE,MAAM,mBAAmB,CAAA;AAE1E,MAAM,WAAW,SAAS;IACxB,MAAM,EAAE,MAAM,CAAA;IACd,OAAO,CAAC,EAAE,WAAW,EAAE,CAAA;IACvB,WAAW,EAAE,MAAM,CAAA;IACnB,SAAS,CAAC,EAAE;QAAE,IAAI,EAAE,MAAM,CAAC;QAAC,OAAO,CAAC,EAAE,MAAM,CAAA;KAAE,EAAE,CAAA;IAChD,SAAS,CAAC,EAAE,MAAM,CAAA;IAClB,OAAO,CAAC,EAAE,CAAC,KAAK,EAAE,UAAU,KAAK,IAAI,CAAA;CACtC;AAED,qBAAa,KAAK;IAChB,OAAO,CAAC,IAAI,CAAM;IAClB,OAAO,CAAC,MAAM,CAAQ;IACtB,OAAO,CAAC,WAAW,CAAmB;IACtC,OAAO,CAAC,WAAW,CAAa;IAChC,OAAO,CAAC,QAAQ,CAAgB;IAChC,OAAO,CAAC,eAAe,CAA+B;gBAE1C,MAAM,EAAE,MAAM,EAAE,IAAI,GAAE,OAAe;IAQ3C,OAAO,CAAC,IAAI,EAAE,SAAS,GAAG,OAAO,CAAC,IAAI,CAAC;IA8I7C,OAAO,CAAC,UAAU;YAsBJ,SAAS;IA4IvB,OAAO,CAAC,cAAc;IA2BtB,OAAO,CAAC,gBAAgB;IAiBxB,MAAM;CAGP"}
|
|
@@ -0,0 +1,362 @@
|
|
|
1
|
+
"use strict";
|
|
2
|
+
Object.defineProperty(exports, "__esModule", { value: true });
|
|
3
|
+
exports.Agent = void 0;
|
|
4
|
+
const index_js_1 = require("../auth/index.js");
|
|
5
|
+
const index_js_2 = require("../logging/index.js");
|
|
6
|
+
const index_js_3 = require("../tools/index.js");
|
|
7
|
+
const index_js_4 = require("../permissions/index.js");
|
|
8
|
+
const index_js_5 = require("../workspace/index.js");
|
|
9
|
+
const index_js_6 = require("../filetracker/index.js");
|
|
10
|
+
const index_js_7 = require("../session/index.js");
|
|
11
|
+
const prompt_js_1 = require("./prompt.js");
|
|
12
|
+
const todos_js_1 = require("../tools/todos.js");
|
|
13
|
+
class Agent {
|
|
14
|
+
auth;
|
|
15
|
+
config;
|
|
16
|
+
permissions;
|
|
17
|
+
fileTracker;
|
|
18
|
+
sessions;
|
|
19
|
+
abortController = null;
|
|
20
|
+
constructor(config, yolo = false) {
|
|
21
|
+
this.auth = new index_js_1.Auth();
|
|
22
|
+
this.config = config;
|
|
23
|
+
this.permissions = new index_js_4.PermissionManager(config.raw, yolo);
|
|
24
|
+
this.fileTracker = new index_js_6.FileTracker();
|
|
25
|
+
this.sessions = new index_js_7.SessionService();
|
|
26
|
+
}
|
|
27
|
+
async execute(call) {
|
|
28
|
+
const emit = call.onEvent || (() => { });
|
|
29
|
+
const maxIterations = 15;
|
|
30
|
+
let iterations = 0;
|
|
31
|
+
const toolHistory = [];
|
|
32
|
+
const summary = [];
|
|
33
|
+
this.abortController = new AbortController();
|
|
34
|
+
let workspaceContext = '';
|
|
35
|
+
try {
|
|
36
|
+
const index = (0, index_js_5.indexWorkspace)(call.projectPath);
|
|
37
|
+
workspaceContext = (0, index_js_5.buildContextSummary)(index);
|
|
38
|
+
index_js_2.logger.info(`Indexed ${index.totalFiles} files`);
|
|
39
|
+
}
|
|
40
|
+
catch (err) {
|
|
41
|
+
index_js_2.logger.warn('Indexing failed', err);
|
|
42
|
+
}
|
|
43
|
+
// Build Nyx-like system prompt with dynamic env data
|
|
44
|
+
const promptData = (0, prompt_js_1.buildPromptData)(call.projectPath, this.config.raw);
|
|
45
|
+
const skillsXML = promptData.availableSkills.length > 0
|
|
46
|
+
? promptData.availableSkills.map((s) => ` <skill name="${s.name}" type="builtin" location="${s.path}/SKILL.md" description="${s.description}"/>`).join('\n')
|
|
47
|
+
: '';
|
|
48
|
+
const systemPrompt = (0, prompt_js_1.buildSystemPrompt)(promptData, skillsXML);
|
|
49
|
+
let sessionId = call.sessionId;
|
|
50
|
+
if (!sessionId) {
|
|
51
|
+
const session = this.sessions.create();
|
|
52
|
+
sessionId = session.id;
|
|
53
|
+
}
|
|
54
|
+
// Load previous conversation history from session
|
|
55
|
+
const previousMessages = this.sessions.getMessages(sessionId);
|
|
56
|
+
const messages = [
|
|
57
|
+
{ role: 'system', content: systemPrompt },
|
|
58
|
+
...previousMessages.slice(-20),
|
|
59
|
+
...(call.history || []).slice(-8),
|
|
60
|
+
{ role: 'user', content: call.prompt },
|
|
61
|
+
];
|
|
62
|
+
this.sessions.addMessage(sessionId, messages[messages.length - 1]);
|
|
63
|
+
// Agent loop
|
|
64
|
+
while (iterations < maxIterations) {
|
|
65
|
+
iterations++;
|
|
66
|
+
index_js_2.logger.info(`Agent iteration ${iterations}`);
|
|
67
|
+
if (this.abortController.signal.aborted) {
|
|
68
|
+
emit({ type: 'content', data: { text: '\n\n(Operation cancelled)' } });
|
|
69
|
+
return;
|
|
70
|
+
}
|
|
71
|
+
// Loop detection
|
|
72
|
+
if (toolHistory.length >= 4) {
|
|
73
|
+
const last4 = toolHistory.slice(-4);
|
|
74
|
+
if (last4.every((t) => t === last4[0])) {
|
|
75
|
+
index_js_2.logger.warn('Detected repeated same action, breaking loop');
|
|
76
|
+
emit({ type: 'content', data: { text: '\n\n(I notice this action is repeating. Moving on.)\n\n' } });
|
|
77
|
+
break;
|
|
78
|
+
}
|
|
79
|
+
}
|
|
80
|
+
emit({ type: 'plan', data: { text: 'Thinking...' } });
|
|
81
|
+
// Stream response from Nyx backend (only user/assistant/system messages)
|
|
82
|
+
const apiMessages = messages.filter((m) => m.role !== 'tool');
|
|
83
|
+
const responseContent = await this.streamNyx(apiMessages, emit);
|
|
84
|
+
if (responseContent === null)
|
|
85
|
+
break;
|
|
86
|
+
// Check for native API tool_calls + text-parsed tool calls
|
|
87
|
+
const nativeToolCalls = (this._nativeToolCalls || []).map((tc) => ({
|
|
88
|
+
...tc,
|
|
89
|
+
tool: tc.tool.includes('.') ? tc.tool.split('.').pop() : tc.tool,
|
|
90
|
+
}));
|
|
91
|
+
const textToolCalls = this.parseToolCalls(responseContent).map((tc) => ({
|
|
92
|
+
...tc,
|
|
93
|
+
tool: tc.tool.includes('.') ? tc.tool.split('.').pop() : tc.tool,
|
|
94
|
+
}));
|
|
95
|
+
const toolCalls = nativeToolCalls.length > 0 ? nativeToolCalls : textToolCalls;
|
|
96
|
+
// Auto-detect text plans on first iteration and create todos
|
|
97
|
+
if (iterations === 1 && responseContent && toolCalls.length > 0) {
|
|
98
|
+
const planItems = this.detectPlan(responseContent);
|
|
99
|
+
for (const item of planItems) {
|
|
100
|
+
await todos_js_1.todosTool.execute({ action: 'add', content: item }, call.projectPath);
|
|
101
|
+
}
|
|
102
|
+
if (planItems.length > 0) {
|
|
103
|
+
emit({ type: 'content', data: { text: `\n (plan: ${planItems.length} steps tracked)\n` } });
|
|
104
|
+
}
|
|
105
|
+
}
|
|
106
|
+
if (toolCalls.length === 0) {
|
|
107
|
+
this.sessions.addMessage(sessionId, { role: 'assistant', content: responseContent });
|
|
108
|
+
break;
|
|
109
|
+
}
|
|
110
|
+
this.sessions.addMessage(sessionId, { role: 'assistant', content: responseContent });
|
|
111
|
+
// Execute each tool
|
|
112
|
+
for (const tool of toolCalls) {
|
|
113
|
+
const toolKey = `${tool.tool}:${JSON.stringify(tool.args)}`;
|
|
114
|
+
toolHistory.push(toolKey);
|
|
115
|
+
const allowed = await this.permissions.requestPermission(tool.tool, tool.args);
|
|
116
|
+
if (!allowed) {
|
|
117
|
+
emit({ type: 'tool_result', data: { id: tool.id, success: false, output: '', error: 'Permission denied', tool: tool.tool, args: tool.args } });
|
|
118
|
+
messages.push({ role: 'user', content: `Tool ${tool.tool} was denied by user.` });
|
|
119
|
+
this.sessions.addMessage(sessionId, messages[messages.length - 1]);
|
|
120
|
+
continue;
|
|
121
|
+
}
|
|
122
|
+
index_js_2.logger.info(`Tool: ${tool.tool}`, tool.args);
|
|
123
|
+
emit({ type: 'tool_call', data: { id: tool.id, tool: tool.tool, args: tool.args } });
|
|
124
|
+
const result = await (0, index_js_3.executeTool)(tool, call.projectPath);
|
|
125
|
+
const trackedPath = tool.args.file_path || tool.args.command || tool.args.path || '';
|
|
126
|
+
this.fileTracker.track(trackedPath);
|
|
127
|
+
summary.push({ tool: tool.tool, file: tool.args.file_path || tool.args.path, success: result.success });
|
|
128
|
+
emit({ type: 'tool_result', data: { id: tool.id, success: result.success, output: result.output, error: result.error, tool: tool.tool, args: tool.args } });
|
|
129
|
+
if (!result.success) {
|
|
130
|
+
messages.push({ role: 'user', content: `Tool ${tool.tool} failed: ${result.error}. Let me try a different approach.` });
|
|
131
|
+
}
|
|
132
|
+
else {
|
|
133
|
+
const resultContent = result.tool === 'bash'
|
|
134
|
+
? `Command completed:\n\`\`\`\n${result.output.substring(0, 1500)}\n\`\`\``
|
|
135
|
+
: `Tool ${result.tool} result:\n${result.output.substring(0, 2000)}`;
|
|
136
|
+
messages.push({ role: 'user', content: resultContent });
|
|
137
|
+
}
|
|
138
|
+
this.sessions.addMessage(sessionId, messages[messages.length - 1]);
|
|
139
|
+
}
|
|
140
|
+
}
|
|
141
|
+
if (iterations >= maxIterations) {
|
|
142
|
+
emit({ type: 'content', data: { text: '\n\n(Maximum iterations reached)' } });
|
|
143
|
+
}
|
|
144
|
+
emit({ type: 'done', data: { sessionId, summary } });
|
|
145
|
+
}
|
|
146
|
+
detectPlan(text) {
|
|
147
|
+
// Detect numbered list plans like "1. Do this\n2. Do that"
|
|
148
|
+
const items = [];
|
|
149
|
+
const lines = text.split('\n');
|
|
150
|
+
let inPlan = false;
|
|
151
|
+
for (const line of lines) {
|
|
152
|
+
const trimmed = line.trim();
|
|
153
|
+
const match = trimmed.match(/^\d+[\.\)]\s+(.+)/);
|
|
154
|
+
if (match) {
|
|
155
|
+
inPlan = true;
|
|
156
|
+
items.push(match[1].trim());
|
|
157
|
+
}
|
|
158
|
+
else if (inPlan && trimmed.startsWith('- ')) {
|
|
159
|
+
items.push(trimmed.slice(2).trim());
|
|
160
|
+
}
|
|
161
|
+
else if (inPlan && trimmed === '') {
|
|
162
|
+
// continue collecting
|
|
163
|
+
}
|
|
164
|
+
else if (inPlan && items.length > 0) {
|
|
165
|
+
break; // stop at the first non-plan line after plan started
|
|
166
|
+
}
|
|
167
|
+
}
|
|
168
|
+
return items;
|
|
169
|
+
}
|
|
170
|
+
async streamNyx(messages, emit) {
|
|
171
|
+
const headers = this.auth.getHeaders();
|
|
172
|
+
if (!headers.Authorization) {
|
|
173
|
+
emit({ type: 'error', data: { message: 'Not logged in. Run `nyx login` first.' } });
|
|
174
|
+
return null;
|
|
175
|
+
}
|
|
176
|
+
// Build native tool definitions to send to the API
|
|
177
|
+
const toolDefs = (0, index_js_3.getToolDefinitions)(this.config.getDisabledTools());
|
|
178
|
+
const apiTools = toolDefs.map((t) => ({
|
|
179
|
+
type: 'function',
|
|
180
|
+
function: {
|
|
181
|
+
name: t.name,
|
|
182
|
+
description: t.description,
|
|
183
|
+
parameters: t.parameters,
|
|
184
|
+
},
|
|
185
|
+
}));
|
|
186
|
+
const body = {
|
|
187
|
+
messages: messages.map((m) => ({ role: m.role, content: m.content })),
|
|
188
|
+
stream: true,
|
|
189
|
+
provider: process.env.NYX_PROVIDER || '',
|
|
190
|
+
model: process.env.NYX_MODEL || '',
|
|
191
|
+
maxTokens: 8192,
|
|
192
|
+
tools: apiTools,
|
|
193
|
+
};
|
|
194
|
+
// Retry loop with exponential backoff
|
|
195
|
+
const maxRetries = 2;
|
|
196
|
+
let lastError = '';
|
|
197
|
+
for (let attempt = 0; attempt <= maxRetries; attempt++) {
|
|
198
|
+
if (attempt > 0) {
|
|
199
|
+
const delay = Math.min(1000 * Math.pow(2, attempt - 1), 8000);
|
|
200
|
+
emit({ type: 'content', data: { text: `\n(retry ${attempt}/${maxRetries} in ${delay / 1000}s...)\n` } });
|
|
201
|
+
await new Promise((r) => setTimeout(r, delay));
|
|
202
|
+
}
|
|
203
|
+
const controller = new AbortController();
|
|
204
|
+
const timeout = setTimeout(() => controller.abort(), 90000);
|
|
205
|
+
let res;
|
|
206
|
+
try {
|
|
207
|
+
res = await fetch(`${this.auth.getApiUrl()}/api/ai/chat`, {
|
|
208
|
+
method: 'POST',
|
|
209
|
+
headers: { ...headers, Accept: 'text/event-stream' },
|
|
210
|
+
body: JSON.stringify(body),
|
|
211
|
+
signal: this.abortController?.signal,
|
|
212
|
+
});
|
|
213
|
+
}
|
|
214
|
+
catch (err) {
|
|
215
|
+
lastError = err.message;
|
|
216
|
+
clearTimeout(timeout);
|
|
217
|
+
continue;
|
|
218
|
+
}
|
|
219
|
+
clearTimeout(timeout);
|
|
220
|
+
if (!res.ok) {
|
|
221
|
+
const errText = await res.text().catch(() => 'Unknown error');
|
|
222
|
+
if (res.status >= 400 && res.status < 500) {
|
|
223
|
+
emit({ type: 'error', data: { message: `API error ${res.status}: ${errText}` } });
|
|
224
|
+
return null;
|
|
225
|
+
}
|
|
226
|
+
lastError = `API error ${res.status}: ${errText}`;
|
|
227
|
+
continue;
|
|
228
|
+
}
|
|
229
|
+
const reader = res.body?.getReader();
|
|
230
|
+
if (!reader) {
|
|
231
|
+
lastError = 'No response body';
|
|
232
|
+
continue;
|
|
233
|
+
}
|
|
234
|
+
const decoder = new TextDecoder();
|
|
235
|
+
let fullContent = '';
|
|
236
|
+
let buffer = '';
|
|
237
|
+
const nativeToolCalls = new Map();
|
|
238
|
+
let lastEmittedPos = 0;
|
|
239
|
+
const emitInterval = setInterval(() => {
|
|
240
|
+
const clean = fullContent.replace(/```(?:json)?[\s\S]*?(?:```|$)/g, '').replace(/\u0060{3,}/g, '');
|
|
241
|
+
const newPart = clean.slice(lastEmittedPos);
|
|
242
|
+
if (newPart.trim()) {
|
|
243
|
+
emit({ type: 'content', data: { text: newPart } });
|
|
244
|
+
lastEmittedPos = clean.length;
|
|
245
|
+
}
|
|
246
|
+
}, 150);
|
|
247
|
+
try {
|
|
248
|
+
while (true) {
|
|
249
|
+
const { done, value } = await reader.read();
|
|
250
|
+
if (done)
|
|
251
|
+
break;
|
|
252
|
+
buffer += decoder.decode(value, { stream: true });
|
|
253
|
+
const lines = buffer.split('\n');
|
|
254
|
+
buffer = lines.pop() || '';
|
|
255
|
+
for (const line of lines) {
|
|
256
|
+
const trimmed = line.trim();
|
|
257
|
+
if (!trimmed || trimmed === 'data: [DONE]')
|
|
258
|
+
continue;
|
|
259
|
+
if (!trimmed.startsWith('data: '))
|
|
260
|
+
continue;
|
|
261
|
+
try {
|
|
262
|
+
const json = JSON.parse(trimmed.slice(6));
|
|
263
|
+
const delta = json.choices?.[0]?.delta;
|
|
264
|
+
const chunk = delta?.content || delta?.text || '';
|
|
265
|
+
if (chunk)
|
|
266
|
+
fullContent += chunk;
|
|
267
|
+
if (delta?.tool_calls) {
|
|
268
|
+
for (const tc of delta.tool_calls) {
|
|
269
|
+
const idx = tc.index ?? 0;
|
|
270
|
+
let tName = tc.function?.name || '';
|
|
271
|
+
if (tName.includes('.'))
|
|
272
|
+
tName = tName.split('.').pop() || tName;
|
|
273
|
+
if (!nativeToolCalls.has(idx))
|
|
274
|
+
nativeToolCalls.set(idx, { id: tc.id || '', name: tName, args: '' });
|
|
275
|
+
const existing = nativeToolCalls.get(idx);
|
|
276
|
+
if (tc.id)
|
|
277
|
+
existing.id = tc.id;
|
|
278
|
+
if (tc.function?.name)
|
|
279
|
+
existing.name = tName;
|
|
280
|
+
if (tc.function?.arguments)
|
|
281
|
+
existing.args += tc.function.arguments;
|
|
282
|
+
}
|
|
283
|
+
}
|
|
284
|
+
}
|
|
285
|
+
catch { }
|
|
286
|
+
}
|
|
287
|
+
}
|
|
288
|
+
}
|
|
289
|
+
catch (err) {
|
|
290
|
+
lastError = err.message;
|
|
291
|
+
clearInterval(emitInterval);
|
|
292
|
+
continue;
|
|
293
|
+
}
|
|
294
|
+
finally {
|
|
295
|
+
clearInterval(emitInterval);
|
|
296
|
+
}
|
|
297
|
+
const final = fullContent.replace(/```(?:json)?[\s\S]*?(?:```|$)/g, '').replace(/\u0060{3,}/g, '');
|
|
298
|
+
const trail = final.slice(lastEmittedPos);
|
|
299
|
+
if (trail.trim())
|
|
300
|
+
emit({ type: 'content', data: { text: trail } });
|
|
301
|
+
const nativeParsed = [];
|
|
302
|
+
for (const [, tc] of nativeToolCalls) {
|
|
303
|
+
if (tc.name && tc.args) {
|
|
304
|
+
try {
|
|
305
|
+
nativeParsed.push({ id: tc.id || `tc-${Date.now()}`, tool: tc.name, args: JSON.parse(tc.args) });
|
|
306
|
+
}
|
|
307
|
+
catch { }
|
|
308
|
+
}
|
|
309
|
+
}
|
|
310
|
+
;
|
|
311
|
+
this._nativeToolCalls = nativeParsed;
|
|
312
|
+
return fullContent;
|
|
313
|
+
}
|
|
314
|
+
emit({ type: 'error', data: { message: lastError || 'Request failed after retries' } });
|
|
315
|
+
return null;
|
|
316
|
+
}
|
|
317
|
+
parseToolCalls(text) {
|
|
318
|
+
const toolCalls = [];
|
|
319
|
+
const seen = new Set();
|
|
320
|
+
const jsonBlockRegex = /```(?:json)?\s*(\[[\s\S]*?\]|\{[\s\S]*?\})\s*```/g;
|
|
321
|
+
let match;
|
|
322
|
+
while ((match = jsonBlockRegex.exec(text)) !== null) {
|
|
323
|
+
this.extractToolCalls(match[1], toolCalls, seen);
|
|
324
|
+
}
|
|
325
|
+
const inlineRegex = /\{(?:[^{}]|(?:\{[^{}]*\}))*\}/g;
|
|
326
|
+
while ((match = inlineRegex.exec(text)) !== null) {
|
|
327
|
+
if (match[0].includes('"tool"')) {
|
|
328
|
+
this.extractToolCalls(match[0], toolCalls, seen);
|
|
329
|
+
}
|
|
330
|
+
}
|
|
331
|
+
const arrayRegex = /\[(?:[^\[\]]|(?:\[[^\[\]]*\]))*\]/g;
|
|
332
|
+
while ((match = arrayRegex.exec(text)) !== null) {
|
|
333
|
+
if (match[0].includes('"tool"')) {
|
|
334
|
+
this.extractToolCalls(match[0], toolCalls, seen);
|
|
335
|
+
}
|
|
336
|
+
}
|
|
337
|
+
return toolCalls;
|
|
338
|
+
}
|
|
339
|
+
extractToolCalls(jsonStr, result, seen) {
|
|
340
|
+
try {
|
|
341
|
+
const parsed = JSON.parse(jsonStr);
|
|
342
|
+
if (Array.isArray(parsed)) {
|
|
343
|
+
for (const item of parsed) {
|
|
344
|
+
if (item.tool && !seen.has(item.tool + JSON.stringify(item.args || {}))) {
|
|
345
|
+
seen.add(item.tool + JSON.stringify(item.args || {}));
|
|
346
|
+
result.push({ id: `tc-${Date.now()}-${result.length}`, tool: item.tool, args: item.args || {} });
|
|
347
|
+
}
|
|
348
|
+
}
|
|
349
|
+
}
|
|
350
|
+
else if (parsed.tool && !seen.has(parsed.tool + JSON.stringify(parsed.args || {}))) {
|
|
351
|
+
seen.add(parsed.tool + JSON.stringify(parsed.args || {}));
|
|
352
|
+
result.push({ id: `tc-${Date.now()}-${result.length}`, tool: parsed.tool, args: parsed.args || {} });
|
|
353
|
+
}
|
|
354
|
+
}
|
|
355
|
+
catch { }
|
|
356
|
+
}
|
|
357
|
+
cancel() {
|
|
358
|
+
this.abortController?.abort();
|
|
359
|
+
}
|
|
360
|
+
}
|
|
361
|
+
exports.Agent = Agent;
|
|
362
|
+
//# sourceMappingURL=index.js.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"index.js","sourceRoot":"","sources":["../../src/agent/index.ts"],"names":[],"mappings":";;;AAAA,+CAAuC;AAEvC,kDAA4C;AAC5C,gDAAmE;AACnE,sDAA2D;AAC3D,oDAA2E;AAC3E,sDAAqD;AACrD,kDAAoD;AACpD,2CAAgE;AAChE,gDAA6C;AAY7C,MAAa,KAAK;IACR,IAAI,CAAM;IACV,MAAM,CAAQ;IACd,WAAW,CAAmB;IAC9B,WAAW,CAAa;IACxB,QAAQ,CAAgB;IACxB,eAAe,GAA2B,IAAI,CAAA;IAEtD,YAAY,MAAc,EAAE,OAAgB,KAAK;QAC/C,IAAI,CAAC,IAAI,GAAG,IAAI,eAAI,EAAE,CAAA;QACtB,IAAI,CAAC,MAAM,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,EAAE,EAAE,IAAI,EAAE,MAAM,CAAC,IAAI,EAAE,IAAI,EAAE,MAAM,CAAC,IAAI,IAAI,EAAE,EAAE,CAAC,CAAA;YACtG,CAAC;QACH,CAAC;QAAC,MAAM,CAAC,CAAA,CAAC;IACZ,CAAC;IAED,MAAM;QACJ,IAAI,CAAC,eAAe,EAAE,KAAK,EAAE,CAAA;IAC/B,CAAC;CACF;AA/WD,sBA+WC"}
|
|
@@ -0,0 +1,16 @@
|
|
|
1
|
+
import type { Skill } from '../skills/index.js';
|
|
2
|
+
import type { NyxConfig } from '../types/index.js';
|
|
3
|
+
export interface PromptData {
|
|
4
|
+
workingDir: string;
|
|
5
|
+
isGitRepo: boolean;
|
|
6
|
+
platform: string;
|
|
7
|
+
date: string;
|
|
8
|
+
gitBranch: string;
|
|
9
|
+
gitStatus: string;
|
|
10
|
+
recentCommits: string;
|
|
11
|
+
contextFiles: string;
|
|
12
|
+
availableSkills: Skill[];
|
|
13
|
+
}
|
|
14
|
+
export declare function buildPromptData(projectPath: string, config: NyxConfig): PromptData;
|
|
15
|
+
export declare function buildSystemPrompt(data: PromptData, skillsXML: string): string;
|
|
16
|
+
//# sourceMappingURL=prompt.d.ts.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"prompt.d.ts","sourceRoot":"","sources":["../../src/agent/prompt.ts"],"names":[],"mappings":"AAKA,OAAO,KAAK,EAAE,KAAK,EAAE,MAAM,oBAAoB,CAAA;AAC/C,OAAO,KAAK,EAAE,SAAS,EAAE,MAAM,mBAAmB,CAAA;AAElD,MAAM,WAAW,UAAU;IACzB,UAAU,EAAE,MAAM,CAAA;IAClB,SAAS,EAAE,OAAO,CAAA;IAClB,QAAQ,EAAE,MAAM,CAAA;IAChB,IAAI,EAAE,MAAM,CAAA;IACZ,SAAS,EAAE,MAAM,CAAA;IACjB,SAAS,EAAE,MAAM,CAAA;IACjB,aAAa,EAAE,MAAM,CAAA;IACrB,YAAY,EAAE,MAAM,CAAA;IACpB,eAAe,EAAE,KAAK,EAAE,CAAA;CACzB;AAED,wBAAgB,eAAe,CAAC,WAAW,EAAE,MAAM,EAAE,MAAM,EAAE,SAAS,GAAG,UAAU,CAsClF;AAED,wBAAgB,iBAAiB,CAAC,IAAI,EAAE,UAAU,EAAE,SAAS,EAAE,MAAM,GAAG,MAAM,CAgb7E"}
|