@nex-ai/nex 0.1.7
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 +228 -0
- package/dist/cli.d.ts +5 -0
- package/dist/cli.js +18 -0
- package/dist/cli.js.map +1 -0
- package/dist/commands/attribute.d.ts +4 -0
- package/dist/commands/attribute.js +75 -0
- package/dist/commands/attribute.js.map +1 -0
- package/dist/commands/config-cmd.d.ts +4 -0
- package/dist/commands/config-cmd.js +53 -0
- package/dist/commands/config-cmd.js.map +1 -0
- package/dist/commands/context.d.ts +4 -0
- package/dist/commands/context.js +135 -0
- package/dist/commands/context.js.map +1 -0
- package/dist/commands/insight.d.ts +4 -0
- package/dist/commands/insight.js +39 -0
- package/dist/commands/insight.js.map +1 -0
- package/dist/commands/integrate.d.ts +4 -0
- package/dist/commands/integrate.js +136 -0
- package/dist/commands/integrate.js.map +1 -0
- package/dist/commands/list-job.d.ts +4 -0
- package/dist/commands/list-job.js +41 -0
- package/dist/commands/list-job.js.map +1 -0
- package/dist/commands/list.d.ts +4 -0
- package/dist/commands/list.js +148 -0
- package/dist/commands/list.js.map +1 -0
- package/dist/commands/note.d.ts +4 -0
- package/dist/commands/note.js +77 -0
- package/dist/commands/note.js.map +1 -0
- package/dist/commands/object.d.ts +4 -0
- package/dist/commands/object.js +78 -0
- package/dist/commands/object.js.map +1 -0
- package/dist/commands/record.d.ts +4 -0
- package/dist/commands/record.js +126 -0
- package/dist/commands/record.js.map +1 -0
- package/dist/commands/register.d.ts +4 -0
- package/dist/commands/register.js +23 -0
- package/dist/commands/register.js.map +1 -0
- package/dist/commands/relationship.d.ts +4 -0
- package/dist/commands/relationship.js +80 -0
- package/dist/commands/relationship.js.map +1 -0
- package/dist/commands/scan.d.ts +4 -0
- package/dist/commands/scan.js +58 -0
- package/dist/commands/scan.js.map +1 -0
- package/dist/commands/search.d.ts +4 -0
- package/dist/commands/search.js +22 -0
- package/dist/commands/search.js.map +1 -0
- package/dist/commands/session.d.ts +4 -0
- package/dist/commands/session.js +31 -0
- package/dist/commands/session.js.map +1 -0
- package/dist/commands/setup.d.ts +10 -0
- package/dist/commands/setup.js +254 -0
- package/dist/commands/setup.js.map +1 -0
- package/dist/commands/task.d.ts +4 -0
- package/dist/commands/task.js +114 -0
- package/dist/commands/task.js.map +1 -0
- package/dist/index.d.ts +25 -0
- package/dist/index.js +68 -0
- package/dist/index.js.map +1 -0
- package/dist/lib/capture-filter.d.ts +9 -0
- package/dist/lib/capture-filter.js +14 -0
- package/dist/lib/capture-filter.js.map +1 -0
- package/dist/lib/client.d.ts +19 -0
- package/dist/lib/client.js +115 -0
- package/dist/lib/client.js.map +1 -0
- package/dist/lib/config.d.ts +34 -0
- package/dist/lib/config.js +59 -0
- package/dist/lib/config.js.map +1 -0
- package/dist/lib/context-format.d.ts +7 -0
- package/dist/lib/context-format.js +21 -0
- package/dist/lib/context-format.js.map +1 -0
- package/dist/lib/errors.d.ts +18 -0
- package/dist/lib/errors.js +30 -0
- package/dist/lib/errors.js.map +1 -0
- package/dist/lib/file-scanner.d.ts +38 -0
- package/dist/lib/file-scanner.js +178 -0
- package/dist/lib/file-scanner.js.map +1 -0
- package/dist/lib/installers.d.ts +19 -0
- package/dist/lib/installers.js +205 -0
- package/dist/lib/installers.js.map +1 -0
- package/dist/lib/output.d.ts +7 -0
- package/dist/lib/output.js +50 -0
- package/dist/lib/output.js.map +1 -0
- package/dist/lib/platform-detect.d.ts +16 -0
- package/dist/lib/platform-detect.js +188 -0
- package/dist/lib/platform-detect.js.map +1 -0
- package/dist/lib/project-config.d.ts +53 -0
- package/dist/lib/project-config.js +151 -0
- package/dist/lib/project-config.js.map +1 -0
- package/dist/lib/prompt.d.ts +4 -0
- package/dist/lib/prompt.js +21 -0
- package/dist/lib/prompt.js.map +1 -0
- package/dist/lib/rate-limiter.d.ts +13 -0
- package/dist/lib/rate-limiter.js +49 -0
- package/dist/lib/rate-limiter.js.map +1 -0
- package/dist/lib/recall-filter.d.ts +6 -0
- package/dist/lib/recall-filter.js +58 -0
- package/dist/lib/recall-filter.js.map +1 -0
- package/dist/lib/session-store.d.ts +15 -0
- package/dist/lib/session-store.js +62 -0
- package/dist/lib/session-store.js.map +1 -0
- package/package.json +32 -0
package/README.md
ADDED
|
@@ -0,0 +1,228 @@
|
|
|
1
|
+
# @nex-ai/nex
|
|
2
|
+
|
|
3
|
+
Nex CLI provides organizational context & memory to AI agents across 10+ platforms.
|
|
4
|
+
|
|
5
|
+
## Install
|
|
6
|
+
|
|
7
|
+
```bash
|
|
8
|
+
# Install globally
|
|
9
|
+
npm install -g @nex-ai/nex
|
|
10
|
+
|
|
11
|
+
# Or run directly (no install)
|
|
12
|
+
npx @nex-ai/nex ask "who is Maria?"
|
|
13
|
+
```
|
|
14
|
+
|
|
15
|
+
## Quick Start
|
|
16
|
+
|
|
17
|
+
```bash
|
|
18
|
+
# 1. Register for an API key
|
|
19
|
+
nex register --email you@company.com
|
|
20
|
+
|
|
21
|
+
# 2. Set up your platforms (auto-detects installed tools)
|
|
22
|
+
nex setup
|
|
23
|
+
|
|
24
|
+
# 3. Query your knowledge
|
|
25
|
+
nex ask "what's the latest on the Acme deal?"
|
|
26
|
+
```
|
|
27
|
+
|
|
28
|
+
## Supported Platforms
|
|
29
|
+
|
|
30
|
+
`nex setup` auto-detects and configures these platforms:
|
|
31
|
+
|
|
32
|
+
| Platform | Detection | Integration |
|
|
33
|
+
|----------|-----------|-------------|
|
|
34
|
+
| **Claude Code** | `~/.claude/` | Hooks (auto-recall, auto-capture, session start) + slash commands + MCP |
|
|
35
|
+
| **Claude Desktop** | App config exists | MCP server |
|
|
36
|
+
| **Cursor** | `~/.cursor/` | MCP server |
|
|
37
|
+
| **VS Code (Copilot)** | `which code` or `.vscode/` | MCP server (workspace-level) |
|
|
38
|
+
| **Windsurf** | `~/.codeium/windsurf/` | MCP server |
|
|
39
|
+
| **Cline** | VS Code extension installed | MCP server (globalStorage config) |
|
|
40
|
+
| **Continue.dev** | `.continue/` or `~/.continue/` | MCP server |
|
|
41
|
+
| **Zed** | `~/.config/zed/` | MCP server (context_servers) |
|
|
42
|
+
| **Kilo Code** | `.kilocode/` in project | MCP server |
|
|
43
|
+
| **OpenCode** | `~/.config/opencode/` | MCP server |
|
|
44
|
+
|
|
45
|
+
All MCP-based platforms use the same server entry:
|
|
46
|
+
|
|
47
|
+
```json
|
|
48
|
+
{
|
|
49
|
+
"nex": {
|
|
50
|
+
"command": "npx",
|
|
51
|
+
"args": ["-y", "@nex-crm/mcp-server"],
|
|
52
|
+
"env": { "NEX_API_KEY": "sk-..." }
|
|
53
|
+
}
|
|
54
|
+
}
|
|
55
|
+
```
|
|
56
|
+
|
|
57
|
+
## Setup Command
|
|
58
|
+
|
|
59
|
+
```bash
|
|
60
|
+
nex setup # Auto-detect platforms, install Claude Code plugin, create .nex.toml
|
|
61
|
+
nex setup --with-mcp # Also write MCP config to all detected platforms
|
|
62
|
+
nex setup --platform cursor # Install for a specific platform only
|
|
63
|
+
nex setup --no-plugin # Only create config files, skip hooks/commands
|
|
64
|
+
nex setup status # Show all platforms, install status, and connections
|
|
65
|
+
```
|
|
66
|
+
|
|
67
|
+
**Default behavior** (no flags):
|
|
68
|
+
- Claude Code: installs hooks + slash commands (no MCP — avoids filling context windows)
|
|
69
|
+
- Other platforms: detected but MCP not written until `--with-mcp` is passed
|
|
70
|
+
- Creates `.nex.toml` project config with commented defaults
|
|
71
|
+
- Syncs API key to `~/.nex-mcp.json` (shared config)
|
|
72
|
+
|
|
73
|
+
> **Tip:** AI agents don't automatically know about Nex. Explicitly tell your agent to "use Nex for context and memory" in your prompts or CLAUDE.md instructions.
|
|
74
|
+
|
|
75
|
+
## Project Config: `.nex.toml`
|
|
76
|
+
|
|
77
|
+
Per-project settings file created by `nex setup`. All fields are optional.
|
|
78
|
+
|
|
79
|
+
```toml
|
|
80
|
+
[auth]
|
|
81
|
+
# api_key = "sk-..." # Prefer NEX_API_KEY env var or ~/.nex/config.json
|
|
82
|
+
|
|
83
|
+
[hooks]
|
|
84
|
+
# enabled = true # Master kill switch for all hooks
|
|
85
|
+
|
|
86
|
+
[hooks.recall]
|
|
87
|
+
# enabled = true # Auto-recall context on each prompt
|
|
88
|
+
# debounce_ms = 30000
|
|
89
|
+
|
|
90
|
+
[hooks.capture]
|
|
91
|
+
# enabled = true # Auto-capture on conversation stop
|
|
92
|
+
# min_length = 20
|
|
93
|
+
# max_length = 50000
|
|
94
|
+
|
|
95
|
+
[hooks.session_start]
|
|
96
|
+
# enabled = true # Load context on session start
|
|
97
|
+
|
|
98
|
+
[scan]
|
|
99
|
+
# enabled = true
|
|
100
|
+
# extensions = [".md", ".txt", ".csv", ".json", ".yaml", ".yml"]
|
|
101
|
+
# ignore_dirs = ["node_modules", ".git", "dist", "build", "__pycache__"]
|
|
102
|
+
# max_files = 5
|
|
103
|
+
# max_file_size = 100000
|
|
104
|
+
# depth = 2
|
|
105
|
+
|
|
106
|
+
[mcp]
|
|
107
|
+
# enabled = false # Set to true by `nex setup --with-mcp`
|
|
108
|
+
|
|
109
|
+
[output]
|
|
110
|
+
# format = "text" # "text" | "json"
|
|
111
|
+
# timeout = 120000
|
|
112
|
+
```
|
|
113
|
+
|
|
114
|
+
**Resolution order:** CLI flags > `.nex.toml` > env vars > `~/.nex/config.json` > defaults
|
|
115
|
+
|
|
116
|
+
## Commands
|
|
117
|
+
|
|
118
|
+
### Knowledge Graph
|
|
119
|
+
|
|
120
|
+
```bash
|
|
121
|
+
nex ask <query> # Query with natural language
|
|
122
|
+
nex remember <content> # Ingest text (meeting notes, emails, docs)
|
|
123
|
+
nex recall <query> # Query → XML-wrapped for agent injection
|
|
124
|
+
nex capture [content] # Rate-limited ingestion for agent hooks
|
|
125
|
+
nex artifact <id> # Check processing status
|
|
126
|
+
nex search <query> # Search CRM records by name
|
|
127
|
+
nex insight list [--last 24h] # Recent insights
|
|
128
|
+
```
|
|
129
|
+
|
|
130
|
+
### Integrations
|
|
131
|
+
|
|
132
|
+
```bash
|
|
133
|
+
nex integrate list # Show all integrations with connection status
|
|
134
|
+
nex integrate connect email google # Connect Gmail via OAuth
|
|
135
|
+
nex integrate connect messaging slack # Connect Slack
|
|
136
|
+
nex integrate disconnect <id> # Disconnect by connection ID
|
|
137
|
+
```
|
|
138
|
+
|
|
139
|
+
Supported providers: Gmail, Google Calendar, Outlook, Outlook Calendar, Slack, Attio, HubSpot, Salesforce.
|
|
140
|
+
|
|
141
|
+
### CRM Records
|
|
142
|
+
|
|
143
|
+
```bash
|
|
144
|
+
nex object list # List object types (person, company, deal)
|
|
145
|
+
nex record list person --limit 10
|
|
146
|
+
nex record create person --data '{"name":"Jane Doe"}'
|
|
147
|
+
nex record upsert person --match email --data '{"name":"Jane","email":"jane@co.com"}'
|
|
148
|
+
nex record update <id> --data '{"phone":"+1234"}'
|
|
149
|
+
nex record delete <id>
|
|
150
|
+
nex record timeline <id>
|
|
151
|
+
```
|
|
152
|
+
|
|
153
|
+
### Tasks & Notes
|
|
154
|
+
|
|
155
|
+
```bash
|
|
156
|
+
nex task create --title "Follow up" --priority high --due 2026-04-01
|
|
157
|
+
nex task list --assignee me --search "follow up"
|
|
158
|
+
nex task update <id> --completed
|
|
159
|
+
nex note create --title "Call notes" --content "..." --entity <record-id>
|
|
160
|
+
```
|
|
161
|
+
|
|
162
|
+
### Relationships & Lists
|
|
163
|
+
|
|
164
|
+
```bash
|
|
165
|
+
nex rel list-defs
|
|
166
|
+
nex rel create <record-id> --def <def-id> --entity1 <id1> --entity2 <id2>
|
|
167
|
+
nex list list person
|
|
168
|
+
nex list add-member <list-id> --parent <record-id>
|
|
169
|
+
nex list-job create "enterprise contacts in EMEA"
|
|
170
|
+
```
|
|
171
|
+
|
|
172
|
+
### File Scanning
|
|
173
|
+
|
|
174
|
+
On session start, Nex automatically scans project files and ingests changed content.
|
|
175
|
+
|
|
176
|
+
**Default text-based extensions:** `.md`, `.txt`, `.csv`, `.json`, `.yaml`, `.yml`
|
|
177
|
+
|
|
178
|
+
**Document formats** (handled separately): `.docx`, `.doc`, `.odt`, `.xlsx`, `.xls`, `.pptx`, `.ppt`, `.pdf`
|
|
179
|
+
|
|
180
|
+
Configure via `.nex.toml` `[scan]` section or environment variables (`NEX_SCAN_ENABLED`, `NEX_SCAN_EXTENSIONS`, etc.).
|
|
181
|
+
|
|
182
|
+
### Config & Sessions
|
|
183
|
+
|
|
184
|
+
```bash
|
|
185
|
+
nex config show # Resolved config (key masked)
|
|
186
|
+
nex config set default_format text
|
|
187
|
+
nex config path # ~/.nex/config.json
|
|
188
|
+
nex session list # Stored session mappings
|
|
189
|
+
nex session clear
|
|
190
|
+
```
|
|
191
|
+
|
|
192
|
+
## Global Flags
|
|
193
|
+
|
|
194
|
+
```
|
|
195
|
+
--api-key <key> Override API key (env: NEX_API_KEY)
|
|
196
|
+
--format <fmt> json | text (default for integrate list) | quiet
|
|
197
|
+
--timeout <ms> Request timeout (default: 120000)
|
|
198
|
+
--session <id> Session ID for multi-turn context
|
|
199
|
+
--debug Debug output on stderr
|
|
200
|
+
```
|
|
201
|
+
|
|
202
|
+
## Stdin Support
|
|
203
|
+
|
|
204
|
+
`ask`, `remember`, and `capture` read from stdin when no argument is provided:
|
|
205
|
+
|
|
206
|
+
```bash
|
|
207
|
+
cat meeting-notes.txt | nex remember
|
|
208
|
+
echo "what happened today?" | nex ask
|
|
209
|
+
git diff | nex capture
|
|
210
|
+
```
|
|
211
|
+
|
|
212
|
+
## Exit Codes
|
|
213
|
+
|
|
214
|
+
| Code | Meaning |
|
|
215
|
+
|------|---------|
|
|
216
|
+
| 0 | Success |
|
|
217
|
+
| 1 | General error (server error, rate limit, invalid input) |
|
|
218
|
+
| 2 | Auth error (no API key, invalid key, 401/403) |
|
|
219
|
+
|
|
220
|
+
## Development
|
|
221
|
+
|
|
222
|
+
```bash
|
|
223
|
+
npm install
|
|
224
|
+
npm run build # TypeScript → dist/
|
|
225
|
+
npm run dev # Run with tsx (no build)
|
|
226
|
+
npm test # Unit tests
|
|
227
|
+
NEX_DEV_URL=http://localhost:30000 nex ask "test" # Local API
|
|
228
|
+
```
|
package/dist/cli.d.ts
ADDED
package/dist/cli.js
ADDED
|
@@ -0,0 +1,18 @@
|
|
|
1
|
+
/**
|
|
2
|
+
* Commander program definition with global flags.
|
|
3
|
+
*/
|
|
4
|
+
import { Command } from "commander";
|
|
5
|
+
import { createRequire } from "node:module";
|
|
6
|
+
const require = createRequire(import.meta.url);
|
|
7
|
+
const { version } = require("../package.json");
|
|
8
|
+
export const program = new Command();
|
|
9
|
+
program
|
|
10
|
+
.name("nex")
|
|
11
|
+
.description("Nex CLI — command-line interface for the Nex Developer API")
|
|
12
|
+
.version(version)
|
|
13
|
+
.option("--api-key <key>", "Override API key (env: NEX_API_KEY)")
|
|
14
|
+
.option("--format <fmt>", "Output format: json, text, quiet")
|
|
15
|
+
.option("--timeout <ms>", "Request timeout in milliseconds")
|
|
16
|
+
.option("--session <id>", "Session ID for multi-turn context")
|
|
17
|
+
.option("--debug", "Debug output on stderr");
|
|
18
|
+
//# sourceMappingURL=cli.js.map
|
package/dist/cli.js.map
ADDED
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"cli.js","sourceRoot":"","sources":["../src/cli.ts"],"names":[],"mappings":"AAAA;;GAEG;AAEH,OAAO,EAAE,OAAO,EAAE,MAAM,WAAW,CAAC;AACpC,OAAO,EAAE,aAAa,EAAE,MAAM,aAAa,CAAC;AAE5C,MAAM,OAAO,GAAG,aAAa,CAAC,MAAM,CAAC,IAAI,CAAC,GAAG,CAAC,CAAC;AAC/C,MAAM,EAAE,OAAO,EAAE,GAAG,OAAO,CAAC,iBAAiB,CAAwB,CAAC;AAEtE,MAAM,CAAC,MAAM,OAAO,GAAG,IAAI,OAAO,EAAE,CAAC;AAErC,OAAO;KACJ,IAAI,CAAC,KAAK,CAAC;KACX,WAAW,CAAC,4DAA4D,CAAC;KACzE,OAAO,CAAC,OAAO,CAAC;KAChB,MAAM,CAAC,iBAAiB,EAAE,qCAAqC,CAAC;KAChE,MAAM,CAAC,gBAAgB,EAAE,kCAAkC,CAAC;KAC5D,MAAM,CAAC,gBAAgB,EAAE,iCAAiC,CAAC;KAC3D,MAAM,CAAC,gBAAgB,EAAE,mCAAmC,CAAC;KAC7D,MAAM,CAAC,SAAS,EAAE,wBAAwB,CAAC,CAAC"}
|
|
@@ -0,0 +1,75 @@
|
|
|
1
|
+
/**
|
|
2
|
+
* nex attribute — CRUD operations for object attributes.
|
|
3
|
+
*/
|
|
4
|
+
import { program } from "../cli.js";
|
|
5
|
+
import { NexClient } from "../lib/client.js";
|
|
6
|
+
import { resolveApiKey, resolveFormat, resolveTimeout } from "../lib/config.js";
|
|
7
|
+
import { printOutput } from "../lib/output.js";
|
|
8
|
+
function getClient() {
|
|
9
|
+
const opts = program.opts();
|
|
10
|
+
const client = new NexClient(resolveApiKey(opts.apiKey), resolveTimeout(opts.timeout));
|
|
11
|
+
return { client, format: resolveFormat(opts.format) };
|
|
12
|
+
}
|
|
13
|
+
const attr = program.command("attribute").description("Manage object attributes");
|
|
14
|
+
attr
|
|
15
|
+
.command("create")
|
|
16
|
+
.description("Create an attribute on an object")
|
|
17
|
+
.argument("<object-slug>", "Object slug")
|
|
18
|
+
.requiredOption("--name <name>", "Attribute name")
|
|
19
|
+
.requiredOption("--slug <slug>", "Attribute slug")
|
|
20
|
+
.requiredOption("--type <type>", "Attribute type")
|
|
21
|
+
.option("--description <description>", "Attribute description")
|
|
22
|
+
.option("--options <json>", "Options as JSON string")
|
|
23
|
+
.action(async (objectSlug, opts) => {
|
|
24
|
+
const { client, format } = getClient();
|
|
25
|
+
const body = { name: opts.name, slug: opts.slug, type: opts.type };
|
|
26
|
+
if (opts.description !== undefined)
|
|
27
|
+
body.description = opts.description;
|
|
28
|
+
if (opts.options) {
|
|
29
|
+
try {
|
|
30
|
+
body.options = JSON.parse(opts.options);
|
|
31
|
+
}
|
|
32
|
+
catch {
|
|
33
|
+
throw new Error(`Invalid JSON for --options: ${opts.options}`);
|
|
34
|
+
}
|
|
35
|
+
}
|
|
36
|
+
const result = await client.post(`/v1/objects/${encodeURIComponent(objectSlug)}/attributes`, body);
|
|
37
|
+
printOutput(result, format);
|
|
38
|
+
});
|
|
39
|
+
attr
|
|
40
|
+
.command("update")
|
|
41
|
+
.description("Update an attribute")
|
|
42
|
+
.argument("<object-slug>", "Object slug")
|
|
43
|
+
.argument("<attr-id>", "Attribute ID")
|
|
44
|
+
.option("--name <name>", "New name")
|
|
45
|
+
.option("--description <description>", "New description")
|
|
46
|
+
.option("--options <json>", "Options as JSON string")
|
|
47
|
+
.action(async (objectSlug, attrId, opts) => {
|
|
48
|
+
const { client, format } = getClient();
|
|
49
|
+
const body = {};
|
|
50
|
+
if (opts.name !== undefined)
|
|
51
|
+
body.name = opts.name;
|
|
52
|
+
if (opts.description !== undefined)
|
|
53
|
+
body.description = opts.description;
|
|
54
|
+
if (opts.options) {
|
|
55
|
+
try {
|
|
56
|
+
body.options = JSON.parse(opts.options);
|
|
57
|
+
}
|
|
58
|
+
catch {
|
|
59
|
+
throw new Error(`Invalid JSON for --options: ${opts.options}`);
|
|
60
|
+
}
|
|
61
|
+
}
|
|
62
|
+
const result = await client.patch(`/v1/objects/${encodeURIComponent(objectSlug)}/attributes/${encodeURIComponent(attrId)}`, body);
|
|
63
|
+
printOutput(result, format);
|
|
64
|
+
});
|
|
65
|
+
attr
|
|
66
|
+
.command("delete")
|
|
67
|
+
.description("Delete an attribute")
|
|
68
|
+
.argument("<object-slug>", "Object slug")
|
|
69
|
+
.argument("<attr-id>", "Attribute ID")
|
|
70
|
+
.action(async (objectSlug, attrId) => {
|
|
71
|
+
const { client, format } = getClient();
|
|
72
|
+
const result = await client.delete(`/v1/objects/${encodeURIComponent(objectSlug)}/attributes/${encodeURIComponent(attrId)}`);
|
|
73
|
+
printOutput(result, format);
|
|
74
|
+
});
|
|
75
|
+
//# sourceMappingURL=attribute.js.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"attrib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IG_PATH, resolveApiKey, BASE_URL, } from "../lib/config.js";
|
|
6
|
+
import { printOutput } from "../lib/output.js";
|
|
7
|
+
import { resolveFormat } from "../lib/config.js";
|
|
8
|
+
function maskApiKey(key) {
|
|
9
|
+
if (key.length <= 4)
|
|
10
|
+
return key;
|
|
11
|
+
return "****" + key.slice(-4);
|
|
12
|
+
}
|
|
13
|
+
const configCmd = program
|
|
14
|
+
.command("config")
|
|
15
|
+
.description("Manage CLI configuration");
|
|
16
|
+
configCmd
|
|
17
|
+
.command("show")
|
|
18
|
+
.description("Show resolved configuration")
|
|
19
|
+
.action(() => {
|
|
20
|
+
const globalOpts = program.opts();
|
|
21
|
+
const format = resolveFormat(globalOpts.format);
|
|
22
|
+
const config = loadConfig();
|
|
23
|
+
const apiKey = resolveApiKey(globalOpts.apiKey);
|
|
24
|
+
const display = {
|
|
25
|
+
...config,
|
|
26
|
+
api_key: apiKey ? maskApiKey(apiKey) : undefined,
|
|
27
|
+
base_url: BASE_URL,
|
|
28
|
+
config_path: CONFIG_PATH,
|
|
29
|
+
};
|
|
30
|
+
printOutput(display, format);
|
|
31
|
+
});
|
|
32
|
+
configCmd
|
|
33
|
+
.command("set")
|
|
34
|
+
.description("Set a configuration value")
|
|
35
|
+
.argument("<key>", "Config key to set")
|
|
36
|
+
.argument("<value>", "Value to set")
|
|
37
|
+
.action((key, value) => {
|
|
38
|
+
const config = loadConfig();
|
|
39
|
+
config[key] = value;
|
|
40
|
+
saveConfig(config);
|
|
41
|
+
const globalOpts = program.opts();
|
|
42
|
+
const format = resolveFormat(globalOpts.format);
|
|
43
|
+
printOutput({ [key]: value }, format);
|
|
44
|
+
});
|
|
45
|
+
configCmd
|
|
46
|
+
.command("path")
|
|
47
|
+
.description("Print the config file path")
|
|
48
|
+
.action(() => {
|
|
49
|
+
const globalOpts = program.opts();
|
|
50
|
+
const format = resolveFormat(globalOpts.format);
|
|
51
|
+
printOutput({ path: CONFIG_PATH }, format);
|
|
52
|
+
});
|
|
53
|
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E,MAAM,CAAC,CAAC;AAC/B,CAAC,CAAC,CAAC;AAEL,SAAS;KACN,OAAO,CAAC,KAAK,CAAC;KACd,WAAW,CAAC,2BAA2B,CAAC;KACxC,QAAQ,CAAC,OAAO,EAAE,mBAAmB,CAAC;KACtC,QAAQ,CAAC,SAAS,EAAE,cAAc,CAAC;KACnC,MAAM,CAAC,CAAC,GAAW,EAAE,KAAa,EAAE,EAAE;IACrC,MAAM,MAAM,GAAG,UAAU,EAAE,CAAC;IAC3B,MAAkC,CAAC,GAAG,CAAC,GAAG,KAAK,CAAC;IACjD,UAAU,CAAC,MAAM,CAAC,CAAC;IAEnB,MAAM,UAAU,GAAG,OAAO,CAAC,IAAI,EAAE,CAAC;IAClC,MAAM,MAAM,GAAG,aAAa,CAAC,UAAU,CAAC,MAAM,CAAW,CAAC;IAC1D,WAAW,CAAC,EAAE,CAAC,GAAG,CAAC,EAAE,KAAK,EAAE,EAAE,MAAM,CAAC,CAAC;AACxC,CAAC,CAAC,CAAC;AAEL,SAAS;KACN,OAAO,CAAC,MAAM,CAAC;KACf,WAAW,CAAC,4BAA4B,CAAC;KACzC,MAAM,CAAC,GAAG,EAAE;IACX,MAAM,UAAU,GAAG,OAAO,CAAC,IAAI,EAAE,CAAC;IAClC,MAAM,MAAM,GAAG,aAAa,CAAC,UAAU,CAAC,MAAM,CAAW,CAAC;IAC1D,WAAW,CAAC,EAAE,IAAI,EAAE,WAAW,EAAE,EAAE,MAAM,CAAC,CAAC;AAC7C,CAAC,CAAC,CAAC"}
|
|
@@ -0,0 +1,135 @@
|
|
|
1
|
+
/**
|
|
2
|
+
* Context commands: ask, remember, artifact, recall, capture.
|
|
3
|
+
*/
|
|
4
|
+
import { program } from "../cli.js";
|
|
5
|
+
import { NexClient } from "../lib/client.js";
|
|
6
|
+
import { resolveApiKey, resolveFormat, resolveTimeout } from "../lib/config.js";
|
|
7
|
+
import { printOutput } from "../lib/output.js";
|
|
8
|
+
import { shouldRecall, recordRecall } from "../lib/recall-filter.js";
|
|
9
|
+
import { formatNexContext } from "../lib/context-format.js";
|
|
10
|
+
import { captureFilter } from "../lib/capture-filter.js";
|
|
11
|
+
import { RateLimiter } from "../lib/rate-limiter.js";
|
|
12
|
+
import { SessionStore } from "../lib/session-store.js";
|
|
13
|
+
function getClient() {
|
|
14
|
+
const opts = program.opts();
|
|
15
|
+
const client = new NexClient(resolveApiKey(opts.apiKey), resolveTimeout(opts.timeout));
|
|
16
|
+
return { client, format: resolveFormat(opts.format) };
|
|
17
|
+
}
|
|
18
|
+
async function readStdin() {
|
|
19
|
+
if (process.stdin.isTTY)
|
|
20
|
+
return undefined;
|
|
21
|
+
const chunks = [];
|
|
22
|
+
for await (const chunk of process.stdin) {
|
|
23
|
+
chunks.push(chunk);
|
|
24
|
+
}
|
|
25
|
+
const text = Buffer.concat(chunks).toString("utf-8").trim();
|
|
26
|
+
return text || undefined;
|
|
27
|
+
}
|
|
28
|
+
program
|
|
29
|
+
.command("ask")
|
|
30
|
+
.description("Ask a question against your Nex context")
|
|
31
|
+
.argument("[query]", "The question to ask")
|
|
32
|
+
.action(async (query) => {
|
|
33
|
+
const input = query ?? (await readStdin());
|
|
34
|
+
if (!input) {
|
|
35
|
+
throw new Error("No query provided. Pass as argument or pipe via stdin.");
|
|
36
|
+
}
|
|
37
|
+
const { client, format } = getClient();
|
|
38
|
+
const body = { query: input };
|
|
39
|
+
const sessionId = program.opts().session;
|
|
40
|
+
if (sessionId) {
|
|
41
|
+
body.session_id = sessionId;
|
|
42
|
+
}
|
|
43
|
+
const result = await client.post("/v1/context/ask", body);
|
|
44
|
+
printOutput(result, format);
|
|
45
|
+
});
|
|
46
|
+
program
|
|
47
|
+
.command("remember")
|
|
48
|
+
.description("Store content in your Nex context")
|
|
49
|
+
.argument("[content]", "The content to remember")
|
|
50
|
+
.option("--context <context>", "Additional context")
|
|
51
|
+
.action(async (content, opts) => {
|
|
52
|
+
const input = content ?? (await readStdin());
|
|
53
|
+
if (!input) {
|
|
54
|
+
throw new Error("No content provided. Pass as argument or pipe via stdin.");
|
|
55
|
+
}
|
|
56
|
+
const { client, format } = getClient();
|
|
57
|
+
const body = { content: input };
|
|
58
|
+
if (opts.context) {
|
|
59
|
+
body.context = opts.context;
|
|
60
|
+
}
|
|
61
|
+
const result = await client.post("/v1/context/text", body);
|
|
62
|
+
printOutput(result, format);
|
|
63
|
+
});
|
|
64
|
+
program
|
|
65
|
+
.command("artifact")
|
|
66
|
+
.description("Retrieve a context artifact by ID")
|
|
67
|
+
.argument("<id>", "Artifact ID")
|
|
68
|
+
.action(async (id) => {
|
|
69
|
+
const { client, format } = getClient();
|
|
70
|
+
const result = await client.get(`/v1/context/artifacts/${encodeURIComponent(id)}`);
|
|
71
|
+
printOutput(result, format);
|
|
72
|
+
});
|
|
73
|
+
program
|
|
74
|
+
.command("recall")
|
|
75
|
+
.description("Recall context for injection into LLM prompts")
|
|
76
|
+
.argument("[query]", "The query to recall context for")
|
|
77
|
+
.option("--first-prompt", "Treat as first prompt in session")
|
|
78
|
+
.action(async (query, opts) => {
|
|
79
|
+
const input = query ?? (await readStdin());
|
|
80
|
+
if (!input) {
|
|
81
|
+
throw new Error("No query provided. Pass as argument or pipe via stdin.");
|
|
82
|
+
}
|
|
83
|
+
const isFirst = opts?.firstPrompt ?? false;
|
|
84
|
+
const decision = shouldRecall(input, isFirst);
|
|
85
|
+
if (!decision.shouldRecall) {
|
|
86
|
+
process.exit(0);
|
|
87
|
+
}
|
|
88
|
+
const { client } = getClient();
|
|
89
|
+
const body = { query: input };
|
|
90
|
+
const sessionId = program.opts().session;
|
|
91
|
+
if (sessionId) {
|
|
92
|
+
body.session_id = sessionId;
|
|
93
|
+
}
|
|
94
|
+
const result = await client.post("/v1/context/ask", body);
|
|
95
|
+
recordRecall();
|
|
96
|
+
const formatted = formatNexContext({
|
|
97
|
+
answer: result.answer ?? "",
|
|
98
|
+
entityCount: result.entityCount ?? 0,
|
|
99
|
+
sessionId: result.sessionId,
|
|
100
|
+
});
|
|
101
|
+
process.stdout.write(formatted + "\n");
|
|
102
|
+
});
|
|
103
|
+
program
|
|
104
|
+
.command("capture")
|
|
105
|
+
.description("Capture content into Nex context with filtering and rate limiting")
|
|
106
|
+
.argument("[content]", "The content to capture")
|
|
107
|
+
.action(async (content) => {
|
|
108
|
+
const input = content ?? (await readStdin());
|
|
109
|
+
if (!input) {
|
|
110
|
+
throw new Error("No content provided. Pass as argument or pipe via stdin.");
|
|
111
|
+
}
|
|
112
|
+
const filtered = captureFilter(input);
|
|
113
|
+
if (filtered.skipped) {
|
|
114
|
+
process.stderr.write(`capture skipped: ${filtered.reason}\n`);
|
|
115
|
+
process.exit(0);
|
|
116
|
+
}
|
|
117
|
+
const limiter = new RateLimiter();
|
|
118
|
+
if (!limiter.canProceed()) {
|
|
119
|
+
process.stderr.write("capture skipped: rate limited\n");
|
|
120
|
+
process.exit(0);
|
|
121
|
+
}
|
|
122
|
+
const { client, format } = getClient();
|
|
123
|
+
const body = { content: filtered.text };
|
|
124
|
+
const sessionId = program.opts().session;
|
|
125
|
+
if (sessionId) {
|
|
126
|
+
const store = new SessionStore();
|
|
127
|
+
const existing = store.get(sessionId);
|
|
128
|
+
if (existing) {
|
|
129
|
+
body.session_id = existing;
|
|
130
|
+
}
|
|
131
|
+
}
|
|
132
|
+
const result = await client.post("/v1/context/text", body, 60_000);
|
|
133
|
+
printOutput(result, format);
|
|
134
|
+
});
|
|
135
|
+
//# sourceMappingURL=context.js.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"context.js","sourceRoot":"","sources":["../../src/commands/context.ts"],"names":[],"mappings":"AAAA;;GAEG;AAEH,OAAO,EAAE,OAAO,EAAE,MAAM,WAAW,CAAC;AACpC,OAAO,EAAE,SAAS,EAAE,MAAM,kBAAkB,CAAC;AAC7C,OAAO,EAAE,aAAa,EAAE,aAAa,EAAE,cAAc,EAAE,MAAM,kBAAkB,CAAC;AAChF,OAAO,EAAE,WAAW,EAAE,MAAM,kBAAkB,CA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AAW,EAAE,CAAC;IAClC,IAAI,CAAC,OAAO,CAAC,UAAU,EAAE,EAAE,CAAC;QAC1B,OAAO,CAAC,MAAM,CAAC,KAAK,CAAC,iCAAiC,CAAC,CAAC;QACxD,OAAO,CAAC,IAAI,CAAC,CAAC,CAAC,CAAC;IAClB,CAAC;IAED,MAAM,EAAE,MAAM,EAAE,MAAM,EAAE,GAAG,SAAS,EAAE,CAAC;IACvC,MAAM,IAAI,GAA2B,EAAE,OAAO,EAAE,QAAQ,CAAC,IAAI,EAAE,CAAC;IAEhE,MAAM,SAAS,GAAG,OAAO,CAAC,IAAI,EAAE,CAAC,OAAO,CAAC;IACzC,IAAI,SAAS,EAAE,CAAC;QACd,MAAM,KAAK,GAAG,IAAI,YAAY,EAAE,CAAC;QACjC,MAAM,QAAQ,GAAG,KAAK,CAAC,GAAG,CAAC,SAAS,CAAC,CAAC;QACtC,IAAI,QAAQ,EAAE,CAAC;YACb,IAAI,CAAC,UAAU,GAAG,QAAQ,CAAC;QAC7B,CAAC;IACH,CAAC;IAED,MAAM,MAAM,GAAG,MAAM,MAAM,CAAC,IAAI,CAAC,kBAAkB,EAAE,IAAI,EAAE,MAAM,CAAC,CAAC;IACnE,WAAW,CAAC,MAAM,EAAE,MAAM,CAAC,CAAC;AAC9B,CAAC,CAAC,CAAC"}
|
|
@@ -0,0 +1,39 @@
|
|
|
1
|
+
/**
|
|
2
|
+
* nex insight — list insights from your Nex workspace.
|
|
3
|
+
*/
|
|
4
|
+
import { program } from "../cli.js";
|
|
5
|
+
import { NexClient } from "../lib/client.js";
|
|
6
|
+
import { resolveApiKey, resolveFormat, resolveTimeout } from "../lib/config.js";
|
|
7
|
+
import { printOutput } from "../lib/output.js";
|
|
8
|
+
function getClient() {
|
|
9
|
+
const opts = program.opts();
|
|
10
|
+
const client = new NexClient(resolveApiKey(opts.apiKey), resolveTimeout(opts.timeout));
|
|
11
|
+
return { client, format: resolveFormat(opts.format) };
|
|
12
|
+
}
|
|
13
|
+
const insightCmd = program
|
|
14
|
+
.command("insight")
|
|
15
|
+
.description("Manage insights");
|
|
16
|
+
insightCmd
|
|
17
|
+
.command("list")
|
|
18
|
+
.description("List insights")
|
|
19
|
+
.option("--last <duration>", "Time duration (e.g. 7d, 24h)")
|
|
20
|
+
.option("--from <date>", "Start date (ISO 8601)")
|
|
21
|
+
.option("--to <date>", "End date (ISO 8601)")
|
|
22
|
+
.option("--limit <n>", "Maximum number of results")
|
|
23
|
+
.action(async (opts) => {
|
|
24
|
+
const { client, format } = getClient();
|
|
25
|
+
const params = new URLSearchParams();
|
|
26
|
+
if (opts.last)
|
|
27
|
+
params.set("last", opts.last);
|
|
28
|
+
if (opts.from)
|
|
29
|
+
params.set("from", opts.from);
|
|
30
|
+
if (opts.to)
|
|
31
|
+
params.set("to", opts.to);
|
|
32
|
+
if (opts.limit)
|
|
33
|
+
params.set("limit", opts.limit);
|
|
34
|
+
const qs = params.toString();
|
|
35
|
+
const path = `/v1/insights${qs ? `?${qs}` : ""}`;
|
|
36
|
+
const result = await client.get(path);
|
|
37
|
+
printOutput(result, format);
|
|
38
|
+
});
|
|
39
|
+
//# sourceMappingURL=insight.js.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"insight.js","sourceRoot":"","sources":["../../src/commands/insight.ts"],"names":[],"mappings":"AAAA;;GAEG;AAEH,OAAO,EAAE,OAAO,EAAE,MAAM,WAAW,CAAC;AACpC,OAAO,EAAE,SAAS,EAAE,MAAM,kBAAkB,CAAC;AAC7C,OAAO,EAAE,aAAa,EAAE,aAAa,EAAE,cAAc,EAAE,MAAM,kBAAkB,CAAC;AAChF,OAAO,EAAE,WAAW,EAAE,MAAM,kBAAkB,CAAC;AAG/C,SAAS,SAAS;IAChB,MAAM,IAAI,GAAG,OAAO,CAAC,IAAI,EAAE,CAAC;IAC5B,MAAM,MAAM,GAAG,IAAI,SAAS,CAAC,aAAa,CAAC,IAAI,CAAC,MAAM,CAAC,EAAE,cAAc,CAAC,IAAI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