@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
|
@@ -0,0 +1,254 @@
|
|
|
1
|
+
/**
|
|
2
|
+
* `nex setup` command — detect platforms, install plugin/MCP, create .nex.toml.
|
|
3
|
+
*
|
|
4
|
+
* nex setup Interactive: detect → install plugin + config
|
|
5
|
+
* nex setup --platform <name> Direct install for specific platform
|
|
6
|
+
* nex setup --with-mcp Also install MCP server
|
|
7
|
+
* nex setup --no-plugin Skip hooks/commands, only config files
|
|
8
|
+
* nex setup status Show install status + integration connections
|
|
9
|
+
*/
|
|
10
|
+
import { existsSync } from "node:fs";
|
|
11
|
+
import { join } from "node:path";
|
|
12
|
+
import { program } from "../cli.js";
|
|
13
|
+
import { resolveApiKey, resolveFormat, resolveTimeout } from "../lib/config.js";
|
|
14
|
+
import { NexClient } from "../lib/client.js";
|
|
15
|
+
import { printOutput, printError } from "../lib/output.js";
|
|
16
|
+
import { detectPlatforms, getPlatformById, VALID_PLATFORM_IDS } from "../lib/platform-detect.js";
|
|
17
|
+
import { installMcpServer, installClaudeCodePlugin, syncApiKeyToMcpConfig } from "../lib/installers.js";
|
|
18
|
+
import { writeDefaultProjectConfig } from "../lib/project-config.js";
|
|
19
|
+
function getClient() {
|
|
20
|
+
const opts = program.opts();
|
|
21
|
+
const client = new NexClient(resolveApiKey(opts.apiKey), resolveTimeout(opts.timeout));
|
|
22
|
+
return { client, format: resolveFormat(opts.format) };
|
|
23
|
+
}
|
|
24
|
+
// --- Status subcommand ---
|
|
25
|
+
async function showStatus(format) {
|
|
26
|
+
const opts = program.opts();
|
|
27
|
+
const apiKey = resolveApiKey(opts.apiKey);
|
|
28
|
+
const platforms = detectPlatforms();
|
|
29
|
+
if (format === "json") {
|
|
30
|
+
const data = {
|
|
31
|
+
auth: apiKey ? { configured: true, key_preview: maskKey(apiKey) } : { configured: false },
|
|
32
|
+
platforms: platforms.map((p) => ({
|
|
33
|
+
id: p.id,
|
|
34
|
+
name: p.displayName,
|
|
35
|
+
detected: p.detected,
|
|
36
|
+
nex_installed: p.nexInstalled,
|
|
37
|
+
plugin_support: p.pluginSupport,
|
|
38
|
+
})),
|
|
39
|
+
project_config: projectConfigExists(),
|
|
40
|
+
};
|
|
41
|
+
// Fetch integrations if authenticated
|
|
42
|
+
if (apiKey) {
|
|
43
|
+
try {
|
|
44
|
+
const client = new NexClient(apiKey, resolveTimeout(opts.timeout));
|
|
45
|
+
data.integrations = await client.get("/v1/integrations/");
|
|
46
|
+
}
|
|
47
|
+
catch {
|
|
48
|
+
data.integrations = null;
|
|
49
|
+
}
|
|
50
|
+
}
|
|
51
|
+
printOutput(data, "json");
|
|
52
|
+
return;
|
|
53
|
+
}
|
|
54
|
+
// Text format
|
|
55
|
+
const lines = [];
|
|
56
|
+
lines.push("Nex Setup Status");
|
|
57
|
+
lines.push("================");
|
|
58
|
+
lines.push("");
|
|
59
|
+
// Auth
|
|
60
|
+
if (apiKey) {
|
|
61
|
+
lines.push(`Auth: Configured (${maskKey(apiKey)})`);
|
|
62
|
+
}
|
|
63
|
+
else {
|
|
64
|
+
lines.push("Auth: Not configured — run `nex register` first");
|
|
65
|
+
}
|
|
66
|
+
lines.push("");
|
|
67
|
+
// Platforms
|
|
68
|
+
lines.push("Platforms:");
|
|
69
|
+
for (const p of platforms) {
|
|
70
|
+
if (!p.detected) {
|
|
71
|
+
lines.push(` ${padRight(p.displayName, 20)} Not found`);
|
|
72
|
+
continue;
|
|
73
|
+
}
|
|
74
|
+
const parts = [` ${padRight(p.displayName, 20)} Detected`];
|
|
75
|
+
if (p.pluginSupport) {
|
|
76
|
+
parts.push(` Plugin: ${p.nexInstalled ? "installed" : "not installed"}`);
|
|
77
|
+
}
|
|
78
|
+
// MCP status
|
|
79
|
+
if (p.id !== "claude-code") {
|
|
80
|
+
parts.push(` MCP: ${p.nexInstalled ? "installed" : "not installed"}`);
|
|
81
|
+
}
|
|
82
|
+
lines.push(parts.join(""));
|
|
83
|
+
}
|
|
84
|
+
lines.push("");
|
|
85
|
+
// Project config
|
|
86
|
+
lines.push(`Project Config: ${projectConfigExists() ? ".nex.toml found" : ".nex.toml not found"}`);
|
|
87
|
+
lines.push("");
|
|
88
|
+
// Integrations
|
|
89
|
+
if (apiKey) {
|
|
90
|
+
try {
|
|
91
|
+
const client = new NexClient(apiKey, resolveTimeout(opts.timeout));
|
|
92
|
+
const integrations = await client.get("/v1/integrations/");
|
|
93
|
+
if (Array.isArray(integrations) && integrations.length > 0) {
|
|
94
|
+
lines.push("Connections:");
|
|
95
|
+
for (const integration of integrations) {
|
|
96
|
+
const type = String(integration.type ?? "");
|
|
97
|
+
const provider = String(integration.provider ?? "");
|
|
98
|
+
const label = `${type} / ${provider}`;
|
|
99
|
+
const connections = integration.connections;
|
|
100
|
+
if (connections && connections.length > 0) {
|
|
101
|
+
for (const conn of connections) {
|
|
102
|
+
const displayName = conn.display_name ?? conn.email ?? "";
|
|
103
|
+
lines.push(` ${padRight(label, 25)} \u25CF connected ${displayName} (ID: ${conn.id})`);
|
|
104
|
+
}
|
|
105
|
+
}
|
|
106
|
+
else {
|
|
107
|
+
lines.push(` ${padRight(label, 25)} \u25CB not connected \u2192 nex integrate connect ${type} ${provider}`);
|
|
108
|
+
}
|
|
109
|
+
}
|
|
110
|
+
}
|
|
111
|
+
}
|
|
112
|
+
catch {
|
|
113
|
+
lines.push("Connections: Could not fetch (check auth)");
|
|
114
|
+
}
|
|
115
|
+
}
|
|
116
|
+
process.stdout.write(lines.join("\n") + "\n");
|
|
117
|
+
}
|
|
118
|
+
// --- Main setup flow ---
|
|
119
|
+
async function runSetup(opts) {
|
|
120
|
+
const globalOpts = program.opts();
|
|
121
|
+
const apiKey = resolveApiKey(globalOpts.apiKey);
|
|
122
|
+
// 1. Check auth
|
|
123
|
+
if (!apiKey) {
|
|
124
|
+
printError("No API key found. Run `nex register` first to create an account.");
|
|
125
|
+
process.exit(2);
|
|
126
|
+
}
|
|
127
|
+
// 2. Sync API key to shared config
|
|
128
|
+
syncApiKeyToMcpConfig(apiKey);
|
|
129
|
+
// 3. Detect or select platforms
|
|
130
|
+
let targetPlatforms;
|
|
131
|
+
if (opts.platform) {
|
|
132
|
+
const p = getPlatformById(opts.platform);
|
|
133
|
+
if (!p) {
|
|
134
|
+
printError(`Unknown platform "${opts.platform}". Valid: ${VALID_PLATFORM_IDS.join(", ")}`);
|
|
135
|
+
process.exit(1);
|
|
136
|
+
}
|
|
137
|
+
targetPlatforms = [p];
|
|
138
|
+
}
|
|
139
|
+
else {
|
|
140
|
+
targetPlatforms = detectPlatforms().filter((p) => p.detected);
|
|
141
|
+
if (targetPlatforms.length === 0) {
|
|
142
|
+
process.stderr.write("No supported platforms detected.\n");
|
|
143
|
+
process.stderr.write(`Supported: ${VALID_PLATFORM_IDS.join(", ")}\n`);
|
|
144
|
+
process.stderr.write("Use --platform <name> to install manually.\n");
|
|
145
|
+
}
|
|
146
|
+
}
|
|
147
|
+
const results = [];
|
|
148
|
+
// 4. Install for each platform
|
|
149
|
+
for (const platform of targetPlatforms) {
|
|
150
|
+
// Claude Code — install plugin (hooks + commands) unless --no-plugin
|
|
151
|
+
if (platform.id === "claude-code" && !opts.noPlugin) {
|
|
152
|
+
const result = installClaudeCodePlugin();
|
|
153
|
+
if (result.installed) {
|
|
154
|
+
if (result.hooksAdded.length > 0) {
|
|
155
|
+
results.push(`Claude Code: hooks installed (${result.hooksAdded.join(", ")})`);
|
|
156
|
+
}
|
|
157
|
+
else {
|
|
158
|
+
results.push("Claude Code: hooks already configured");
|
|
159
|
+
}
|
|
160
|
+
if (result.commandsLinked.length > 0) {
|
|
161
|
+
results.push(`Claude Code: commands linked (${result.commandsLinked.join(", ")})`);
|
|
162
|
+
}
|
|
163
|
+
}
|
|
164
|
+
else {
|
|
165
|
+
results.push("Claude Code: plugin directory not found — install @nex-crm/claude-code-nex-plugin");
|
|
166
|
+
}
|
|
167
|
+
}
|
|
168
|
+
// MCP server — only with --with-mcp
|
|
169
|
+
if (opts.withMcp && platform.id !== "claude-code") {
|
|
170
|
+
const result = installMcpServer(platform, apiKey);
|
|
171
|
+
if (result.installed) {
|
|
172
|
+
results.push(`${platform.displayName}: MCP server configured at ${result.configPath}`);
|
|
173
|
+
}
|
|
174
|
+
}
|
|
175
|
+
else if (platform.id !== "claude-code" && !opts.withMcp) {
|
|
176
|
+
results.push(`${platform.displayName}: detected — use --with-mcp to install MCP server`);
|
|
177
|
+
}
|
|
178
|
+
// Claude Code MCP — also with --with-mcp
|
|
179
|
+
if (opts.withMcp && platform.id === "claude-code") {
|
|
180
|
+
const result = installMcpServer(platform, apiKey);
|
|
181
|
+
if (result.installed) {
|
|
182
|
+
results.push(`Claude Code: MCP server configured`);
|
|
183
|
+
}
|
|
184
|
+
}
|
|
185
|
+
}
|
|
186
|
+
// 5. Create .nex.toml
|
|
187
|
+
const created = writeDefaultProjectConfig();
|
|
188
|
+
if (created) {
|
|
189
|
+
results.push("Created .nex.toml with default settings");
|
|
190
|
+
}
|
|
191
|
+
else {
|
|
192
|
+
results.push(".nex.toml already exists");
|
|
193
|
+
}
|
|
194
|
+
// 6. Output results
|
|
195
|
+
if (opts.format === "json") {
|
|
196
|
+
printOutput({
|
|
197
|
+
platforms: targetPlatforms.map((p) => ({
|
|
198
|
+
id: p.id,
|
|
199
|
+
name: p.displayName,
|
|
200
|
+
detected: p.detected,
|
|
201
|
+
})),
|
|
202
|
+
results,
|
|
203
|
+
}, "json");
|
|
204
|
+
}
|
|
205
|
+
else {
|
|
206
|
+
process.stderr.write("\n");
|
|
207
|
+
for (const r of results) {
|
|
208
|
+
process.stderr.write(` \u2713 ${r}\n`);
|
|
209
|
+
}
|
|
210
|
+
process.stderr.write("\n");
|
|
211
|
+
}
|
|
212
|
+
// 7. Show status
|
|
213
|
+
if (opts.format !== "json") {
|
|
214
|
+
await showStatus(opts.format);
|
|
215
|
+
}
|
|
216
|
+
}
|
|
217
|
+
// --- Helpers ---
|
|
218
|
+
function maskKey(key) {
|
|
219
|
+
if (key.length <= 8)
|
|
220
|
+
return "****";
|
|
221
|
+
return key.slice(0, 4) + "****" + key.slice(-4);
|
|
222
|
+
}
|
|
223
|
+
function padRight(str, len) {
|
|
224
|
+
return str.length >= len ? str : str + " ".repeat(len - str.length);
|
|
225
|
+
}
|
|
226
|
+
function projectConfigExists() {
|
|
227
|
+
return existsSync(join(process.cwd(), ".nex.toml"));
|
|
228
|
+
}
|
|
229
|
+
// --- Command registration ---
|
|
230
|
+
const setup = program
|
|
231
|
+
.command("setup")
|
|
232
|
+
.description("Set up Nex integration for your development environment")
|
|
233
|
+
.option("--platform <name>", `Target platform: ${VALID_PLATFORM_IDS.join(", ")}`)
|
|
234
|
+
.option("--with-mcp", "Also install MCP server for detected platforms", false)
|
|
235
|
+
.option("--no-plugin", "Skip plugin (hooks/commands), only update config files")
|
|
236
|
+
.action(async (cmdOpts) => {
|
|
237
|
+
const globalOpts = program.opts();
|
|
238
|
+
const format = resolveFormat(globalOpts.format);
|
|
239
|
+
await runSetup({
|
|
240
|
+
platform: cmdOpts.platform,
|
|
241
|
+
withMcp: cmdOpts.withMcp,
|
|
242
|
+
noPlugin: cmdOpts.noPlugin ?? false,
|
|
243
|
+
format,
|
|
244
|
+
});
|
|
245
|
+
});
|
|
246
|
+
setup
|
|
247
|
+
.command("status")
|
|
248
|
+
.description("Show Nex installation status across all platforms")
|
|
249
|
+
.action(async () => {
|
|
250
|
+
const globalOpts = program.opts();
|
|
251
|
+
const format = resolveFormat(globalOpts.format);
|
|
252
|
+
await showStatus(format);
|
|
253
|
+
});
|
|
254
|
+
//# sourceMappingURL=setup.js.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"setup.js","sourceRoot":"","sources":["../../src/commands/setup.ts"],"names":[],"mappings":"AAAA;;;;;;;;GAQG;AAEH,OAAO,EAAE,UAAU,EAAE,MAAM,SA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AAa,CAAC,UAAU,CAAC,MAAM,CAAW,CAAC;IAC1D,MAAM,QAAQ,CAAC;QACb,QAAQ,EAAE,OAAO,CAAC,QAAQ;QAC1B,OAAO,EAAE,OAAO,CAAC,OAAO;QACxB,QAAQ,EAAE,OAAO,CAAC,QAAQ,IAAI,KAAK;QACnC,MAAM;KACP,CAAC,CAAC;AACL,CAAC,CAAC,CAAC;AAEL,KAAK;KACF,OAAO,CAAC,QAAQ,CAAC;KACjB,WAAW,CAAC,mDAAmD,CAAC;KAChE,MAAM,CAAC,KAAK,IAAI,EAAE;IACjB,MAAM,UAAU,GAAG,OAAO,CAAC,IAAI,EAAE,CAAC;IAClC,MAAM,MAAM,GAAG,aAAa,CAAC,UAAU,CAAC,MAAM,CAAW,CAAC;IAC1D,MAAM,UAAU,CAAC,MAAM,CAAC,CAAC;AAC3B,CAAC,CAAC,CAAC"}
|
|
@@ -0,0 +1,114 @@
|
|
|
1
|
+
/**
|
|
2
|
+
* nex task — CRUD operations for tasks.
|
|
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 task = program.command("task").description("Manage tasks");
|
|
14
|
+
task
|
|
15
|
+
.command("list")
|
|
16
|
+
.description("List tasks")
|
|
17
|
+
.option("--entity <id>", "Filter by entity ID")
|
|
18
|
+
.option("--assignee <id>", "Filter by assignee ID")
|
|
19
|
+
.option("--search <query>", "Search query")
|
|
20
|
+
.option("--completed", "Show completed tasks")
|
|
21
|
+
.option("--limit <n>", "Max tasks to return")
|
|
22
|
+
.action(async (opts) => {
|
|
23
|
+
const { client, format } = getClient();
|
|
24
|
+
const params = new URLSearchParams();
|
|
25
|
+
if (opts.entity)
|
|
26
|
+
params.set("entity_id", opts.entity);
|
|
27
|
+
if (opts.assignee)
|
|
28
|
+
params.set("assignee_id", opts.assignee);
|
|
29
|
+
if (opts.search)
|
|
30
|
+
params.set("search", opts.search);
|
|
31
|
+
if (opts.completed)
|
|
32
|
+
params.set("is_completed", "true");
|
|
33
|
+
if (opts.limit)
|
|
34
|
+
params.set("limit", opts.limit);
|
|
35
|
+
const qs = params.toString();
|
|
36
|
+
const result = await client.get(`/v1/tasks${qs ? `?${qs}` : ""}`);
|
|
37
|
+
printOutput(result, format);
|
|
38
|
+
});
|
|
39
|
+
task
|
|
40
|
+
.command("get")
|
|
41
|
+
.description("Get a task by ID")
|
|
42
|
+
.argument("<id>", "Task ID")
|
|
43
|
+
.action(async (id) => {
|
|
44
|
+
const { client, format } = getClient();
|
|
45
|
+
const result = await client.get(`/v1/tasks/${encodeURIComponent(id)}`);
|
|
46
|
+
printOutput(result, format);
|
|
47
|
+
});
|
|
48
|
+
task
|
|
49
|
+
.command("create")
|
|
50
|
+
.description("Create a task")
|
|
51
|
+
.requiredOption("--title <title>", "Task title")
|
|
52
|
+
.option("--description <description>", "Task description")
|
|
53
|
+
.option("--priority <priority>", "Priority: low, medium, high, urgent")
|
|
54
|
+
.option("--due <date>", "Due date")
|
|
55
|
+
.option("--entities <ids>", "Comma-separated entity IDs")
|
|
56
|
+
.option("--assignees <ids>", "Comma-separated assignee IDs")
|
|
57
|
+
.action(async (opts) => {
|
|
58
|
+
const { client, format } = getClient();
|
|
59
|
+
const body = { title: opts.title };
|
|
60
|
+
if (opts.description)
|
|
61
|
+
body.description = opts.description;
|
|
62
|
+
if (opts.priority)
|
|
63
|
+
body.priority = opts.priority;
|
|
64
|
+
if (opts.due)
|
|
65
|
+
body.due_date = opts.due;
|
|
66
|
+
if (opts.entities)
|
|
67
|
+
body.entity_ids = opts.entities.split(",");
|
|
68
|
+
if (opts.assignees)
|
|
69
|
+
body.assignee_ids = opts.assignees.split(",");
|
|
70
|
+
const result = await client.post("/v1/tasks", body);
|
|
71
|
+
printOutput(result, format);
|
|
72
|
+
});
|
|
73
|
+
task
|
|
74
|
+
.command("update")
|
|
75
|
+
.description("Update a task")
|
|
76
|
+
.argument("<id>", "Task ID")
|
|
77
|
+
.option("--title <title>", "New title")
|
|
78
|
+
.option("--description <description>", "New description")
|
|
79
|
+
.option("--completed", "Mark as completed")
|
|
80
|
+
.option("--no-completed", "Mark as not completed")
|
|
81
|
+
.option("--priority <priority>", "Priority: low, medium, high, urgent")
|
|
82
|
+
.option("--due <date>", "Due date")
|
|
83
|
+
.option("--entities <ids>", "Comma-separated entity IDs")
|
|
84
|
+
.option("--assignees <ids>", "Comma-separated assignee IDs")
|
|
85
|
+
.action(async (id, opts) => {
|
|
86
|
+
const { client, format } = getClient();
|
|
87
|
+
const body = {};
|
|
88
|
+
if (opts.title !== undefined)
|
|
89
|
+
body.title = opts.title;
|
|
90
|
+
if (opts.description !== undefined)
|
|
91
|
+
body.description = opts.description;
|
|
92
|
+
if (opts.completed !== undefined)
|
|
93
|
+
body.is_completed = opts.completed;
|
|
94
|
+
if (opts.priority !== undefined)
|
|
95
|
+
body.priority = opts.priority;
|
|
96
|
+
if (opts.due !== undefined)
|
|
97
|
+
body.due_date = opts.due;
|
|
98
|
+
if (opts.entities)
|
|
99
|
+
body.entity_ids = opts.entities.split(",");
|
|
100
|
+
if (opts.assignees)
|
|
101
|
+
body.assignee_ids = opts.assignees.split(",");
|
|
102
|
+
const result = await client.patch(`/v1/tasks/${encodeURIComponent(id)}`, body);
|
|
103
|
+
printOutput(result, format);
|
|
104
|
+
});
|
|
105
|
+
task
|
|
106
|
+
.command("delete")
|
|
107
|
+
.description("Delete a task")
|
|
108
|
+
.argument("<id>", "Task ID")
|
|
109
|
+
.action(async (id) => {
|
|
110
|
+
const { client, format } = getClient();
|
|
111
|
+
const result = await client.delete(`/v1/tasks/${encodeURIComponent(id)}`);
|
|
112
|
+
printOutput(result, format);
|
|
113
|
+
});
|
|
114
|
+
//# sourceMappingURL=task.js.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"task.js","sourceRoot":"","sources":["../../src/commands/task.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,CAAC,OAAO,CAAC,CAAC,CAAC;IACvF,OAAO,EAAE,MAAM,EAAE,MAAM,EAAE,aAAa,CAAC,IAAI,CAAC,MAAM,CAAW,EAAE,CAAC;AAClE,CAAC;AAED,MAAM,IAAI,GAAG,OAAO,CAAC,OAAO,CAAC,MAAM,CAAC,CAAC,WAAW,CAAC,cAAc,CAAC,CAAC;AAEjE,IAAI;KACD,OAAO,CAAC,MAAM,CAAC;KACf,WAAW,CAAC,YAAY,CAAC;KACzB,MAAM,CAAC,eAAe,EAAE,qBAAqB,CAAC;KAC9C,MAAM,CAAC,iBAAiB,EAAE,uBAAuB,CAAC;KAClD,MAAM,CAAC,kBAAkB,EAAE,cAAc,CAAC;KAC1C,MAAM,CAAC,aAAa,EAAE,sBAAsB,CAAC;KAC7C,MAAM,CAAC,aAAa,EAAE,qBAAqB,CAAC;KAC5C,MAAM,CAAC,KAAK,EAAE,IAAkG,EAAE,EAAE;IACnH,MAAM,EAAE,MAAM,EAAE,MAAM,EAAE,GAAG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AAC;IAC9D,IAAI,IAAI,CAAC,SAAS;QAAE,IAAI,CAAC,YAAY,GAAG,IAAI,CAAC,SAAS,CAAC,KAAK,CAAC,GAAG,CAAC,CAAC;IAClE,MAAM,MAAM,GAAG,MAAM,MAAM,CAAC,KAAK,CAAC,aAAa,kBAAkB,CAAC,EAAE,CAAC,EAAE,EAAE,IAAI,CAAC,CAAC;IAC/E,WAAW,CAAC,MAAM,EAAE,MAAM,CAAC,CAAC;AAC9B,CAAC,CAAC,CAAC;AAEL,IAAI;KACD,OAAO,CAAC,QAAQ,CAAC;KACjB,WAAW,CAAC,eAAe,CAAC;KAC5B,QAAQ,CAAC,MAAM,EAAE,SAAS,CAAC;KAC3B,MAAM,CAAC,KAAK,EAAE,EAAU,EAAE,EAAE;IAC3B,MAAM,EAAE,MAAM,EAAE,MAAM,EAAE,GAAG,SAAS,EAAE,CAAC;IACvC,MAAM,MAAM,GAAG,MAAM,MAAM,CAAC,MAAM,CAAC,aAAa,kBAAkB,CAAC,EAAE,CAAC,EAAE,CAAC,CAAC;IAC1E,WAAW,CAAC,MAAM,EAAE,MAAM,CAAC,CAAC;AAC9B,CAAC,CAAC,CAAC"}
|
package/dist/index.d.ts
ADDED
|
@@ -0,0 +1,25 @@
|
|
|
1
|
+
#!/usr/bin/env node
|
|
2
|
+
/**
|
|
3
|
+
* Entry point: stdin detection, error handling, exit codes.
|
|
4
|
+
*/
|
|
5
|
+
import "./commands/register.js";
|
|
6
|
+
import "./commands/context.js";
|
|
7
|
+
import "./commands/config-cmd.js";
|
|
8
|
+
import "./commands/search.js";
|
|
9
|
+
import "./commands/insight.js";
|
|
10
|
+
import "./commands/object.js";
|
|
11
|
+
import "./commands/attribute.js";
|
|
12
|
+
import "./commands/record.js";
|
|
13
|
+
import "./commands/relationship.js";
|
|
14
|
+
import "./commands/list.js";
|
|
15
|
+
import "./commands/list-job.js";
|
|
16
|
+
import "./commands/task.js";
|
|
17
|
+
import "./commands/note.js";
|
|
18
|
+
import "./commands/session.js";
|
|
19
|
+
import "./commands/scan.js";
|
|
20
|
+
import "./commands/integrate.js";
|
|
21
|
+
import "./commands/setup.js";
|
|
22
|
+
/**
|
|
23
|
+
* Read all data from stdin (non-TTY only).
|
|
24
|
+
*/
|
|
25
|
+
export declare function readStdin(): Promise<string | undefined>;
|
package/dist/index.js
ADDED
|
@@ -0,0 +1,68 @@
|
|
|
1
|
+
#!/usr/bin/env node
|
|
2
|
+
/**
|
|
3
|
+
* Entry point: stdin detection, error handling, exit codes.
|
|
4
|
+
*/
|
|
5
|
+
import { program } from "./cli.js";
|
|
6
|
+
import { AuthError, RateLimitError, ServerError } from "./lib/errors.js";
|
|
7
|
+
import { printError } from "./lib/output.js";
|
|
8
|
+
// Import command registrations
|
|
9
|
+
import "./commands/register.js";
|
|
10
|
+
import "./commands/context.js";
|
|
11
|
+
import "./commands/config-cmd.js";
|
|
12
|
+
import "./commands/search.js";
|
|
13
|
+
import "./commands/insight.js";
|
|
14
|
+
import "./commands/object.js";
|
|
15
|
+
import "./commands/attribute.js";
|
|
16
|
+
import "./commands/record.js";
|
|
17
|
+
import "./commands/relationship.js";
|
|
18
|
+
import "./commands/list.js";
|
|
19
|
+
import "./commands/list-job.js";
|
|
20
|
+
import "./commands/task.js";
|
|
21
|
+
import "./commands/note.js";
|
|
22
|
+
import "./commands/session.js";
|
|
23
|
+
import "./commands/scan.js";
|
|
24
|
+
import "./commands/integrate.js";
|
|
25
|
+
import "./commands/setup.js";
|
|
26
|
+
/**
|
|
27
|
+
* Read all data from stdin (non-TTY only).
|
|
28
|
+
*/
|
|
29
|
+
export async function readStdin() {
|
|
30
|
+
if (process.stdin.isTTY)
|
|
31
|
+
return undefined;
|
|
32
|
+
const chunks = [];
|
|
33
|
+
for await (const chunk of process.stdin) {
|
|
34
|
+
chunks.push(chunk);
|
|
35
|
+
}
|
|
36
|
+
const text = Buffer.concat(chunks).toString("utf-8").trim();
|
|
37
|
+
return text || undefined;
|
|
38
|
+
}
|
|
39
|
+
async function main() {
|
|
40
|
+
try {
|
|
41
|
+
await program.parseAsync(process.argv);
|
|
42
|
+
}
|
|
43
|
+
catch (err) {
|
|
44
|
+
if (err instanceof AuthError) {
|
|
45
|
+
printError(err.message);
|
|
46
|
+
process.exit(2);
|
|
47
|
+
}
|
|
48
|
+
if (err instanceof RateLimitError) {
|
|
49
|
+
printError(err.message);
|
|
50
|
+
process.exit(1);
|
|
51
|
+
}
|
|
52
|
+
if (err instanceof ServerError) {
|
|
53
|
+
printError(err.message);
|
|
54
|
+
process.exit(1);
|
|
55
|
+
}
|
|
56
|
+
if (err instanceof Error) {
|
|
57
|
+
printError(err.message);
|
|
58
|
+
if (program.opts().debug) {
|
|
59
|
+
console.error(err.stack);
|
|
60
|
+
}
|
|
61
|
+
process.exit(1);
|
|
62
|
+
}
|
|
63
|
+
printError(String(err));
|
|
64
|
+
process.exit(1);
|
|
65
|
+
}
|
|
66
|
+
}
|
|
67
|
+
main();
|
|
68
|
+
//# sourceMappingURL=index.js.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"index.js","sourceRoot":"","sources":["../src/index.ts"],"names":[],"mappings":";AAEA;;GAEG;AAEH,OAAO,EAAE,OAAO,EAAE,MAAM,UAAU,CAAC;AACnC,OAAO,EAAE,SAAS,EAAE,cAAc,EAAE,WAAW,EAAE,MAAM,iBAAiB,CAAC;AACzE,OAAO,EAAE,UAAU,EAAE,MAAM,iBAAiB,CAAC;AAE7C,+BAA+B;AAC/B,OAAO,wBAAwB,CAAC;AAChC,OAAO,uBAAuB,CAAC;AAC/B,OAAO,0BAA0B,CAAC;AAClC,OAAO,sBAAsB,CAAC;AAC9B,OAAO,uBAAuB,CAAC;AAC/B,OAAO,sBAAsB,CAAC;AAC9B,OAAO,yBAAyB,CAAC;AACjC,OAAO,sBAAsB,CAAC;AAC9B,OAAO,4BAA4B,CAAC;AACpC,OAAO,oBAAoB,CAAC;AAC5B,OAAO,wBAAwB,CAAC;AAChC,OAAO,oBAAoB,C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C;YACzB,UAAU,CAAC,GAAG,CAAC,OAAO,CAAC,CAAC;YACxB,IAAI,OAAO,CAAC,IAAI,EAAE,CAAC,KAAK,EAAE,CAAC;gBACzB,OAAO,CAAC,KAAK,CAAC,GAAG,CAAC,KAAK,CAAC,CAAC;YAC3B,CAAC;YACD,OAAO,CAAC,IAAI,CAAC,CAAC,CAAC,CAAC;QAClB,CAAC;QACD,UAAU,CAAC,MAAM,CAAC,GAAG,CAAC,CAAC,CAAC;QACxB,OAAO,CAAC,IAAI,CAAC,CAAC,CAAC,CAAC;IAClB,CAAC;AACH,CAAC;AAED,IAAI,EAAE,CAAC"}
|
|
@@ -0,0 +1,14 @@
|
|
|
1
|
+
import { stripNexContext } from "./context-format.js";
|
|
2
|
+
const MIN_LENGTH = 20;
|
|
3
|
+
const MAX_LENGTH = 50_000;
|
|
4
|
+
export function captureFilter(text) {
|
|
5
|
+
if (!text || text.trim().length === 0)
|
|
6
|
+
return { skipped: true, reason: "empty text" };
|
|
7
|
+
const cleaned = stripNexContext(text);
|
|
8
|
+
if (cleaned.length < MIN_LENGTH)
|
|
9
|
+
return { skipped: true, reason: `too short (${cleaned.length} chars)` };
|
|
10
|
+
if (cleaned.length > MAX_LENGTH)
|
|
11
|
+
return { skipped: true, reason: `too long (${cleaned.length} chars)` };
|
|
12
|
+
return { skipped: false, text: cleaned };
|
|
13
|
+
}
|
|
14
|
+
//# sourceMappingURL=capture-filter.js.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"capture-filter.js","sourceRoot":"","sources":["../../src/lib/capture-filter.ts"],"names":[],"mappings":"AAAA,OAAO,EAAE,eAAe,EAAE,MAAM,qBAAqB,CAAC;AAEtD,MAAM,UAAU,GAAG,EAAE,CAAC;AACtB,MAAM,UAAU,GAAG,MAAM,CAAC;AAY1B,MAAM,UAAU,aAAa,CAAC,IAAY;IACxC,IAAI,CAAC,IAAI,IAAI,IAAI,CAAC,IAAI,EAAE,CAAC,MAAM,KAAK,CAAC;QACnC,OAAO,EAAE,OAAO,EAAE,IAAI,EAAE,MAAM,EAAE,YAAY,EAAE,CAAC;IACjD,MAAM,OAAO,GAAG,eAAe,CAAC,IAAI,CAAC,CAAC;IACtC,IAAI,OAAO,CAAC,MAAM,GAAG,UAAU;QAC7B,OAAO,EAAE,OAAO,EAAE,IAAI,EAAE,MAAM,EAAE,cAAc,OAAO,CAAC,MAAM,SAAS,EAAE,CAAC;IAC1E,IAAI,OAAO,CAAC,MAAM,GAAG,UAAU;QAC7B,OAAO,EAAE,OAAO,EAAE,IAAI,EAAE,MAAM,EAAE,aAAa,OAAO,CAAC,MAAM,SAAS,EAAE,CAAC;IACzE,OAAO,EAAE,OAAO,EAAE,KAAK,EAAE,IAAI,EAAE,OAAO,EAAE,CAAC;AAC3C,CAAC"}
|
|
@@ -0,0 +1,19 @@
|
|
|
1
|
+
/**
|
|
2
|
+
* HTTP client for the Nex Developer API.
|
|
3
|
+
* Hardcoded base URL with all HTTP methods.
|
|
4
|
+
*/
|
|
5
|
+
export declare class NexClient {
|
|
6
|
+
private apiKey;
|
|
7
|
+
private timeoutMs;
|
|
8
|
+
constructor(apiKey?: string, timeoutMs?: number);
|
|
9
|
+
get isAuthenticated(): boolean;
|
|
10
|
+
setApiKey(key: string): void;
|
|
11
|
+
private requireAuth;
|
|
12
|
+
private request;
|
|
13
|
+
register(email: string, name?: string, companyName?: string): Promise<Record<string, unknown>>;
|
|
14
|
+
get<T = unknown>(path: string, timeoutMs?: number): Promise<T>;
|
|
15
|
+
post<T = unknown>(path: string, body?: unknown, timeoutMs?: number): Promise<T>;
|
|
16
|
+
put<T = unknown>(path: string, body?: unknown, timeoutMs?: number): Promise<T>;
|
|
17
|
+
patch<T = unknown>(path: string, body?: unknown, timeoutMs?: number): Promise<T>;
|
|
18
|
+
delete<T = unknown>(path: string, timeoutMs?: number): Promise<T>;
|
|
19
|
+
}
|
|
@@ -0,0 +1,115 @@
|
|
|
1
|
+
/**
|
|
2
|
+
* HTTP client for the Nex Developer API.
|
|
3
|
+
* Hardcoded base URL with all HTTP methods.
|
|
4
|
+
*/
|
|
5
|
+
import { AuthError, RateLimitError, ServerError } from "./errors.js";
|
|
6
|
+
import { API_BASE, REGISTER_URL } from "./config.js";
|
|
7
|
+
export class NexClient {
|
|
8
|
+
apiKey;
|
|
9
|
+
timeoutMs;
|
|
10
|
+
constructor(apiKey, timeoutMs = 120_000) {
|
|
11
|
+
this.apiKey = apiKey;
|
|
12
|
+
this.timeoutMs = timeoutMs;
|
|
13
|
+
}
|
|
14
|
+
get isAuthenticated() {
|
|
15
|
+
return this.apiKey !== undefined && this.apiKey.length > 0;
|
|
16
|
+
}
|
|
17
|
+
setApiKey(key) {
|
|
18
|
+
this.apiKey = key;
|
|
19
|
+
}
|
|
20
|
+
requireAuth() {
|
|
21
|
+
if (!this.isAuthenticated) {
|
|
22
|
+
throw new AuthError();
|
|
23
|
+
}
|
|
24
|
+
}
|
|
25
|
+
async request(method, path, body, timeoutMs) {
|
|
26
|
+
this.requireAuth();
|
|
27
|
+
const url = `${API_BASE}${path}`;
|
|
28
|
+
const controller = new AbortController();
|
|
29
|
+
const timer = setTimeout(() => controller.abort(), timeoutMs ?? this.timeoutMs);
|
|
30
|
+
try {
|
|
31
|
+
const headers = {
|
|
32
|
+
Authorization: `Bearer ${this.apiKey}`,
|
|
33
|
+
};
|
|
34
|
+
if (body !== undefined) {
|
|
35
|
+
headers["Content-Type"] = "application/json";
|
|
36
|
+
}
|
|
37
|
+
const res = await fetch(url, {
|
|
38
|
+
method,
|
|
39
|
+
headers,
|
|
40
|
+
body: body !== undefined ? JSON.stringify(body) : undefined,
|
|
41
|
+
signal: controller.signal,
|
|
42
|
+
});
|
|
43
|
+
if (res.status === 401 || res.status === 403) {
|
|
44
|
+
throw new AuthError("Invalid or expired API key.");
|
|
45
|
+
}
|
|
46
|
+
if (res.status === 429) {
|
|
47
|
+
const retryAfter = res.headers.get("retry-after");
|
|
48
|
+
const ms = retryAfter ? parseInt(retryAfter, 10) * 1000 : 60_000;
|
|
49
|
+
throw new RateLimitError(ms);
|
|
50
|
+
}
|
|
51
|
+
if (!res.ok) {
|
|
52
|
+
let errorBody;
|
|
53
|
+
try {
|
|
54
|
+
errorBody = await res.text();
|
|
55
|
+
}
|
|
56
|
+
catch {
|
|
57
|
+
// ignore
|
|
58
|
+
}
|
|
59
|
+
throw new ServerError(res.status, errorBody);
|
|
60
|
+
}
|
|
61
|
+
const text = await res.text();
|
|
62
|
+
if (!text || !text.trim())
|
|
63
|
+
return {};
|
|
64
|
+
return JSON.parse(text);
|
|
65
|
+
}
|
|
66
|
+
finally {
|
|
67
|
+
clearTimeout(timer);
|
|
68
|
+
}
|
|
69
|
+
}
|
|
70
|
+
async register(email, name, companyName) {
|
|
71
|
+
const body = { email, source: "cli" };
|
|
72
|
+
if (name !== undefined)
|
|
73
|
+
body.name = name;
|
|
74
|
+
if (companyName !== undefined)
|
|
75
|
+
body.company_name = companyName;
|
|
76
|
+
const res = await fetch(REGISTER_URL, {
|
|
77
|
+
method: "POST",
|
|
78
|
+
headers: { "Content-Type": "application/json" },
|
|
79
|
+
body: JSON.stringify(body),
|
|
80
|
+
signal: AbortSignal.timeout(this.timeoutMs),
|
|
81
|
+
});
|
|
82
|
+
if (!res.ok) {
|
|
83
|
+
let errorBody;
|
|
84
|
+
try {
|
|
85
|
+
errorBody = await res.text();
|
|
86
|
+
}
|
|
87
|
+
catch {
|
|
88
|
+
// ignore
|
|
89
|
+
}
|
|
90
|
+
throw new ServerError(res.status, errorBody);
|
|
91
|
+
}
|
|
92
|
+
const data = (await res.json());
|
|
93
|
+
const apiKey = data.api_key;
|
|
94
|
+
if (typeof apiKey === "string" && apiKey.length > 0) {
|
|
95
|
+
this.apiKey = apiKey;
|
|
96
|
+
}
|
|
97
|
+
return data;
|
|
98
|
+
}
|
|
99
|
+
async get(path, timeoutMs) {
|
|
100
|
+
return this.request("GET", path, undefined, timeoutMs);
|
|
101
|
+
}
|
|
102
|
+
async post(path, body, timeoutMs) {
|
|
103
|
+
return this.request("POST", path, body, timeoutMs);
|
|
104
|
+
}
|
|
105
|
+
async put(path, body, timeoutMs) {
|
|
106
|
+
return this.request("PUT", path, body, timeoutMs);
|
|
107
|
+
}
|
|
108
|
+
async patch(path, body, timeoutMs) {
|
|
109
|
+
return this.request("PATCH", path, body, timeoutMs);
|
|
110
|
+
}
|
|
111
|
+
async delete(path, timeoutMs) {
|
|
112
|
+
return this.request("DELETE", path, undefined, timeoutMs);
|
|
113
|
+
}
|
|
114
|
+
}
|
|
115
|
+
//# sourceMappingURL=client.js.map
|