@codespar/cli 0.2.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 +116 -0
- package/dist/api.js +62 -0
- package/dist/api.js.map +1 -0
- package/dist/commands/connect.js +71 -0
- package/dist/commands/connect.js.map +1 -0
- package/dist/commands/execute.js +62 -0
- package/dist/commands/execute.js.map +1 -0
- package/dist/commands/init.js +130 -0
- package/dist/commands/init.js.map +1 -0
- package/dist/commands/login.js +55 -0
- package/dist/commands/login.js.map +1 -0
- package/dist/commands/logs.js +74 -0
- package/dist/commands/logs.js.map +1 -0
- package/dist/commands/servers.js +48 -0
- package/dist/commands/servers.js.map +1 -0
- package/dist/commands/sessions.js +62 -0
- package/dist/commands/sessions.js.map +1 -0
- package/dist/commands/tools.js +43 -0
- package/dist/commands/tools.js.map +1 -0
- package/dist/config.js +57 -0
- package/dist/config.js.map +1 -0
- package/dist/index.js +210 -0
- package/dist/index.js.map +1 -0
- package/dist/output.js +54 -0
- package/dist/output.js.map +1 -0
- package/package.json +55 -0
- package/templates/ecommerce-checkout/.env.example +2 -0
- package/templates/ecommerce-checkout/README.md +22 -0
- package/templates/ecommerce-checkout/package.json +24 -0
- package/templates/ecommerce-checkout/src/index.ts +73 -0
- package/templates/ecommerce-checkout/tsconfig.json +15 -0
- package/templates/multi-tenant/.env.example +2 -0
- package/templates/multi-tenant/README.md +31 -0
- package/templates/multi-tenant/app/api/commerce/[tenantId]/route.ts +55 -0
- package/templates/multi-tenant/lib/commerce.ts +24 -0
- package/templates/multi-tenant/package.json +26 -0
- package/templates/multi-tenant/tsconfig.json +21 -0
- package/templates/pix-agent/.env.example +2 -0
- package/templates/pix-agent/README.md +22 -0
- package/templates/pix-agent/package.json +24 -0
- package/templates/pix-agent/src/index.ts +66 -0
- package/templates/pix-agent/tsconfig.json +15 -0
- package/templates/streaming-chat/.env.example +2 -0
- package/templates/streaming-chat/README.md +23 -0
- package/templates/streaming-chat/app/api/chat/route.ts +29 -0
- package/templates/streaming-chat/app/layout.tsx +12 -0
- package/templates/streaming-chat/app/page.tsx +66 -0
- package/templates/streaming-chat/package.json +29 -0
- package/templates/streaming-chat/tsconfig.json +21 -0
|
@@ -0,0 +1,48 @@
|
|
|
1
|
+
import { CliError } from "../config.js";
|
|
2
|
+
import { json, kv, table } from "../output.js";
|
|
3
|
+
export async function listServersCommand(client, opts) {
|
|
4
|
+
const data = await client.get("/v1/servers", {
|
|
5
|
+
category: opts.category,
|
|
6
|
+
region: opts.region,
|
|
7
|
+
});
|
|
8
|
+
if (opts.json) {
|
|
9
|
+
json(data.data);
|
|
10
|
+
return;
|
|
11
|
+
}
|
|
12
|
+
table(["ID", "NAME", "CATEGORY", "REGION", "TOOLS", "STATUS"], data.data.map((s) => [
|
|
13
|
+
s.id,
|
|
14
|
+
s.name,
|
|
15
|
+
s.category ?? "-",
|
|
16
|
+
s.region ?? "-",
|
|
17
|
+
String(s.tool_count ?? "-"),
|
|
18
|
+
s.status ?? "-",
|
|
19
|
+
]));
|
|
20
|
+
}
|
|
21
|
+
export async function showServerCommand(client, id, opts) {
|
|
22
|
+
if (!id)
|
|
23
|
+
throw new CliError("Server id is required. Example: `codespar servers show stripe`");
|
|
24
|
+
const server = await client.get(`/v1/servers/${encodeURIComponent(id)}`);
|
|
25
|
+
if (opts.json) {
|
|
26
|
+
json(server);
|
|
27
|
+
return;
|
|
28
|
+
}
|
|
29
|
+
kv([
|
|
30
|
+
["ID", server.id],
|
|
31
|
+
["Name", server.name],
|
|
32
|
+
["Category", server.category ?? "-"],
|
|
33
|
+
["Region", server.region ?? "-"],
|
|
34
|
+
["Status", server.status ?? "-"],
|
|
35
|
+
["Auth", server.auth_type ?? "-"],
|
|
36
|
+
["Tools", String(server.tool_count ?? server.tools?.length ?? "-")],
|
|
37
|
+
]);
|
|
38
|
+
if (server.description) {
|
|
39
|
+
process.stdout.write(`\n${server.description}\n`);
|
|
40
|
+
}
|
|
41
|
+
if (server.tools && server.tools.length > 0) {
|
|
42
|
+
process.stdout.write("\nTools:\n");
|
|
43
|
+
for (const t of server.tools) {
|
|
44
|
+
process.stdout.write(` • ${t.name}${t.description ? ` — ${t.description}` : ""}\n`);
|
|
45
|
+
}
|
|
46
|
+
}
|
|
47
|
+
}
|
|
48
|
+
//# sourceMappingURL=servers.js.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"servers.js","sourceRoot":"","sources":["../../src/commands/servers.ts"],"names":[],"mappings":"AACA,OAAO,EAAE,QAAQ,EAAE,MAAM,cAAc,CAAC;AACxC,OAAO,EAAE,IAAI,EAAE,EAAE,EAAE,KAAK,EAAE,MAAM,cAAc,CAAC;AAyB/C,MAAM,CAAC,KAAK,UAAU,kBAAkB,CAAC,MAAiB,EAAE,IAAiB;IAC3E,MAAM,IAAI,GAAG,MAAM,MAAM,CAAC,GAAG,CAA4B,aAAa,EAAE;QACtE,QAAQ,EAAE,IAAI,CAAC,QAAQ;QACvB,MAAM,EAAE,IAAI,CAAC,MAAM;KACpB,CAAC,CAAC;IAEH,IAAI,IAAI,CAAC,IAAI,EAAE,CAAC;QACd,IAAI,CAAC,IAAI,CAAC,IAAI,CAAC,CAAC;QAChB,OAAO;IACT,CAAC;IAED,KAAK,CACH,CAAC,IAAI,EAAE,MAAM,EAAE,UAAU,EAAE,QAAQ,EAAE,OAAO,EAAE,QAAQ,CAAC,EACvD,IAAI,CAAC,IAAI,CAAC,GAAG,CAAC,CAAC,CAAC,EAAE,EAAE,CAAC;QACnB,CAAC,CAAC,EAAE;QACJ,CAAC,CAAC,IAAI;QACN,CAAC,CAAC,QAAQ,IAAI,GAAG;QACjB,CAAC,CAAC,MAAM,IAAI,GAAG;QACf,MAAM,CAAC,CAAC,CAAC,UAAU,IAAI,GAAG,CAAC;QAC3B,CAAC,CAAC,MAAM,IAAI,GAAG;KAChB,CAAC,CACH,CAAC;AACJ,CAAC;AAMD,MAAM,CAAC,KAAK,UAAU,iBAAiB,CACrC,MAAiB,EAC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,CAAC,CAAC,CAAC,MAAM,CAAC,CAAC,WAAW,EAAE,CAAC,CAAC,CAAC,EAAE,IAAI,CAAC,CAAC;QACvF,CAAC;IACH,CAAC;AACH,CAAC"}
|
|
@@ -0,0 +1,62 @@
|
|
|
1
|
+
import { CliError } from "../config.js";
|
|
2
|
+
import { json, kv, success, table } from "../output.js";
|
|
3
|
+
export async function listSessionsCommand(client, opts) {
|
|
4
|
+
const data = await client.get("/v1/sessions", {
|
|
5
|
+
status: opts.status,
|
|
6
|
+
limit: opts.limit,
|
|
7
|
+
});
|
|
8
|
+
if (opts.json) {
|
|
9
|
+
json(data.data);
|
|
10
|
+
return;
|
|
11
|
+
}
|
|
12
|
+
table(["ID", "USER", "STATUS", "SERVERS", "TOOL CALLS", "CREATED"], data.data.map((s) => [
|
|
13
|
+
s.id,
|
|
14
|
+
s.user_id ?? "-",
|
|
15
|
+
s.status ?? "-",
|
|
16
|
+
(s.servers ?? []).join(", "),
|
|
17
|
+
String(s.tool_call_count ?? 0),
|
|
18
|
+
s.created_at ? new Date(s.created_at).toISOString().slice(0, 19).replace("T", " ") : "-",
|
|
19
|
+
]));
|
|
20
|
+
}
|
|
21
|
+
export async function showSessionCommand(client, id, opts) {
|
|
22
|
+
if (!id)
|
|
23
|
+
throw new CliError("Session id is required.");
|
|
24
|
+
const session = await client.get(`/v1/sessions/${encodeURIComponent(id)}`);
|
|
25
|
+
if (opts.json) {
|
|
26
|
+
if (opts.logs) {
|
|
27
|
+
const logs = await client.get(`/v1/sessions/${encodeURIComponent(id)}/logs`);
|
|
28
|
+
json({ session, logs: logs.data });
|
|
29
|
+
}
|
|
30
|
+
else {
|
|
31
|
+
json(session);
|
|
32
|
+
}
|
|
33
|
+
return;
|
|
34
|
+
}
|
|
35
|
+
kv([
|
|
36
|
+
["ID", session.id],
|
|
37
|
+
["User", session.user_id ?? "-"],
|
|
38
|
+
["Status", session.status ?? "-"],
|
|
39
|
+
["Servers", (session.servers ?? []).join(", ")],
|
|
40
|
+
["Tool calls", String(session.tool_call_count ?? 0)],
|
|
41
|
+
["Created", session.created_at ?? "-"],
|
|
42
|
+
["Closed", session.closed_at ?? "-"],
|
|
43
|
+
]);
|
|
44
|
+
if (opts.logs) {
|
|
45
|
+
const logs = await client.get(`/v1/sessions/${encodeURIComponent(id)}/logs`);
|
|
46
|
+
process.stdout.write("\nLogs:\n");
|
|
47
|
+
table(["TOOL", "SERVER", "STATUS", "MS", "AT"], logs.data.map((l) => [
|
|
48
|
+
l.tool,
|
|
49
|
+
l.server,
|
|
50
|
+
l.status,
|
|
51
|
+
String(l.duration_ms ?? "-"),
|
|
52
|
+
l.called_at ? new Date(l.called_at).toISOString().slice(11, 19) : "-",
|
|
53
|
+
]));
|
|
54
|
+
}
|
|
55
|
+
}
|
|
56
|
+
export async function closeSessionCommand(client, id) {
|
|
57
|
+
if (!id)
|
|
58
|
+
throw new CliError("Session id is required.");
|
|
59
|
+
await client.post(`/v1/sessions/${encodeURIComponent(id)}/close`);
|
|
60
|
+
success(`Session ${id} closed.`);
|
|
61
|
+
}
|
|
62
|
+
//# sourceMappingURL=sessions.js.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"sessions.js","sourceRoot":"","sources":["../../src/commands/sessions.ts"],"names":[],"mappings":"AACA,OAAO,EAAE,QAAQ,EAAE,MAAM,cAAc,CAAC;AACxC,OAAO,EAAE,IAAI,EAAE,EAAE,EAAE,OAAO,EAAE,KAAK,EAAE,MAAM,cAAc,CAAC;AAkBxD,MAAM,CAAC,KAAK,UAAU,mBAAmB,CAAC,MAAiB,EAAE,IAAiB;IAC5E,MAAM,IAAI,GAAG,MAAM,MAAM,CAAC,GAAG,CAA6B,cAAc,EAAE;QACxE,MAAM,EAAE,IAAI,CAAC,MAAM;QACnB,KAAK,EAAE,IAAI,CAAC,KAAK;KAClB,CAAC,CAAC;IAEH,IAAI,IAAI,CAAC,IAAI,EAAE,CAAC;QACd,IAAI,CAAC,IAAI,CAAC,IAAI,CAAC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,GAAG;SACtE,CAAC,CACH,CAAC;IACJ,CAAC;AACH,CAAC;AAED,MAAM,CAAC,KAAK,UAAU,mBAAmB,CAAC,MAAiB,EAAE,EAAU;IACrE,IAAI,CAAC,EAAE;QAAE,MAAM,IAAI,QAAQ,CAAC,yBAAyB,CAAC,CAAC;IACvD,MAAM,MAAM,CAAC,IAAI,CAAC,gBAAgB,kBAAkB,CAAC,EAAE,CAAC,QAAQ,CAAC,CAAC;IAClE,OAAO,CAAC,WAAW,EAAE,UAAU,CAAC,CAAC;AACnC,CAAC"}
|
|
@@ -0,0 +1,43 @@
|
|
|
1
|
+
import { CliError } from "../config.js";
|
|
2
|
+
import { json, kv, table } from "../output.js";
|
|
3
|
+
export async function listToolsCommand(client, opts) {
|
|
4
|
+
const data = await client.get("/v1/tools", {
|
|
5
|
+
server: opts.server,
|
|
6
|
+
});
|
|
7
|
+
if (opts.json) {
|
|
8
|
+
json(data.data);
|
|
9
|
+
return;
|
|
10
|
+
}
|
|
11
|
+
table(["NAME", "SERVER", "DESCRIPTION"], data.data.map((t) => [
|
|
12
|
+
t.name,
|
|
13
|
+
t.server,
|
|
14
|
+
truncate(t.description ?? "", 60),
|
|
15
|
+
]));
|
|
16
|
+
}
|
|
17
|
+
export async function showToolCommand(client, name, opts) {
|
|
18
|
+
if (!name)
|
|
19
|
+
throw new CliError("Tool name is required. Example: `codespar tools show codespar_pay`");
|
|
20
|
+
const tool = await client.get(`/v1/tools/${encodeURIComponent(name)}`);
|
|
21
|
+
if (opts.json) {
|
|
22
|
+
json(tool);
|
|
23
|
+
return;
|
|
24
|
+
}
|
|
25
|
+
kv([
|
|
26
|
+
["Name", tool.name],
|
|
27
|
+
["Server", tool.server],
|
|
28
|
+
]);
|
|
29
|
+
if (tool.description)
|
|
30
|
+
process.stdout.write(`\n${tool.description}\n`);
|
|
31
|
+
if (tool.input_schema) {
|
|
32
|
+
process.stdout.write("\nInput schema:\n");
|
|
33
|
+
process.stdout.write(JSON.stringify(tool.input_schema, null, 2) + "\n");
|
|
34
|
+
}
|
|
35
|
+
if (tool.output_schema) {
|
|
36
|
+
process.stdout.write("\nOutput schema:\n");
|
|
37
|
+
process.stdout.write(JSON.stringify(tool.output_schema, null, 2) + "\n");
|
|
38
|
+
}
|
|
39
|
+
}
|
|
40
|
+
function truncate(s, n) {
|
|
41
|
+
return s.length <= n ? s : s.slice(0, n - 1) + "…";
|
|
42
|
+
}
|
|
43
|
+
//# sourceMappingURL=tools.js.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"tools.js","sourceRoot":"","sources":["../../src/commands/tools.ts"],"names":[],"mappings":"AACA,OAAO,EAAE,QAAQ,EAAE,MAAM,cAAc,CAAC;AACxC,OAAO,EAAE,IAAI,EAAE,EAAE,EAAE,KAAK,EAAE,MAAM,cAAc,CAAC;AAkB/C,MAAM,CAAC,KAAK,UAAU,gBAAgB,CAAC,MAAiB,EAAE,IAAiB;IACzE,MAAM,IAAI,GAAG,MAAM,MAAM,CAAC,GAAG,CAA0B,WAAW,EAAE;QAClE,MAAM,EAAE,IAAI,CAAC,MAAM;KACpB,CAAC,CAAC;IAEH,IAAI,IAAI,CAAC,IAAI,EAAE,CAAC;QACd,IAAI,CAAC,IAAI,CAAC,IAAI,CAAC,CAAC;QAChB,OAAO;IACT,CAAC;IAED,KAAK,CACH,CAAC,MAAM,EAAE,QAAQ,EAAE,aAAa,CAAC,EACjC,IAAI,CAAC,IAAI,CAAC,GAAG,CAAC,CAAC,CAAC,EAAE,EAAE,CAAC;QACnB,CAAC,CAAC,IAAI;QACN,CAAC,CAAC,MAAM;QACR,QAAQ,CAAC,CAAC,CAAC,WAAW,IAAI,EAAE,EAAE,EAAE,CAAC;KAClC,CAAC,CACH,CAAC;AACJ,CAAC;AAMD,MAAM,CAAC,KAAK,UAAU,eAAe,CACnC,MAAiB,EACjB,IAAY,EACZ,IAAiB;IAEjB,IAAI,CAAC,IAAI;QAAE,MAAM,IAAI,QAAQ,CAAC,oEAAoE,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-0,0 +1,57 @@
|
|
|
1
|
+
import { readFile, writeFile, mkdir, chmod } from "node:fs/promises";
|
|
2
|
+
import { homedir } from "node:os";
|
|
3
|
+
import { dirname, join } from "node:path";
|
|
4
|
+
const CONFIG_DIR = join(homedir(), ".codespar");
|
|
5
|
+
const CONFIG_FILE = join(CONFIG_DIR, "config.json");
|
|
6
|
+
export async function loadConfig() {
|
|
7
|
+
const fromEnv = {
|
|
8
|
+
apiKey: process.env.CODESPAR_API_KEY,
|
|
9
|
+
project: process.env.CODESPAR_PROJECT,
|
|
10
|
+
baseUrl: process.env.CODESPAR_BASE_URL,
|
|
11
|
+
};
|
|
12
|
+
let fromFile = {};
|
|
13
|
+
try {
|
|
14
|
+
const raw = await readFile(CONFIG_FILE, "utf-8");
|
|
15
|
+
fromFile = JSON.parse(raw);
|
|
16
|
+
}
|
|
17
|
+
catch {
|
|
18
|
+
// No config file yet — that's fine, login will create it.
|
|
19
|
+
}
|
|
20
|
+
// Env wins over file; command-line flags override both at the call site.
|
|
21
|
+
return {
|
|
22
|
+
apiKey: fromEnv.apiKey ?? fromFile.apiKey,
|
|
23
|
+
project: fromEnv.project ?? fromFile.project,
|
|
24
|
+
baseUrl: fromEnv.baseUrl ?? fromFile.baseUrl ?? "https://api.codespar.dev",
|
|
25
|
+
};
|
|
26
|
+
}
|
|
27
|
+
export async function saveConfig(patch) {
|
|
28
|
+
await mkdir(dirname(CONFIG_FILE), { recursive: true });
|
|
29
|
+
let existing = {};
|
|
30
|
+
try {
|
|
31
|
+
existing = JSON.parse(await readFile(CONFIG_FILE, "utf-8"));
|
|
32
|
+
}
|
|
33
|
+
catch {
|
|
34
|
+
// fresh file
|
|
35
|
+
}
|
|
36
|
+
const next = { ...existing, ...patch };
|
|
37
|
+
await writeFile(CONFIG_FILE, JSON.stringify(next, null, 2) + "\n", "utf-8");
|
|
38
|
+
// File contains an API key — restrict to owner only.
|
|
39
|
+
await chmod(CONFIG_FILE, 0o600);
|
|
40
|
+
}
|
|
41
|
+
export function requireApiKey(config) {
|
|
42
|
+
if (!config.apiKey) {
|
|
43
|
+
throw new CliError("Not logged in. Run `codespar login` or set CODESPAR_API_KEY.");
|
|
44
|
+
}
|
|
45
|
+
return config.apiKey;
|
|
46
|
+
}
|
|
47
|
+
/**
|
|
48
|
+
* Error that should be printed to stderr and exit 1 without a stack trace.
|
|
49
|
+
* Anything else bubbling up is treated as a bug and prints the stack.
|
|
50
|
+
*/
|
|
51
|
+
export class CliError extends Error {
|
|
52
|
+
constructor(message) {
|
|
53
|
+
super(message);
|
|
54
|
+
this.name = "CliError";
|
|
55
|
+
}
|
|
56
|
+
}
|
|
57
|
+
//# sourceMappingURL=config.js.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"config.js","sourceRoot":"","sources":["../src/config.ts"],"names":[],"mappings":"AAAA,OAAO,EAAE,QAAQ,EAAE,SAAS,EAAE,KAAK,EAAE,KAAK,EAAE,MAAM,kBAAkB,CAAC;AACrE,OAAO,EAAE,OAAO,EAAE,MAAM,SAAS,CAAC;AAClC,OAAO,EAAE,OAAO,EAAE,IAAI,EAAE,MAAM,WAAW,CAAC;AAiB1C,MAAM,UAAU,GAAG,IAAI,CAAC,OAAO,EAAE,EAAE,WAAW,CAAC,CAAC;AAChD,MAAM,WAAW,GAAG,IAAI,CAAC,UAAU,EAAE,aAAa,CAAC,CAAC;AAEpD,MAAM,CAAC,KAAK,UAAU,UAAU;IAC9B,MAAM,OAAO,GAAc;QACzB,MAAM,EAAE,OAAO,CAAC,GAAG,CAAC,gBAAgB;QACpC,OAAO,EAAE,OAAO,CAAC,GAAG,CAAC,gBAAgB;QACrC,OAAO,EAAE,OAAO,CAAC,GAAG,CAAC,iBAAiB;KACvC,CAAC;IAEF,IAAI,QAAQ,GAAc,EAAE,CAAC;IAC7B,IAAI,CAAC;QACH,MAAM,GAAG,GAAG,MAAM,QAAQ,CAAC,WAAW,EAAE,OAAO,CAAC,CAAC;QACjD,QAAQ,GAAG,IAAI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jC,YAAY,OAAe;QACzB,KAAK,CAAC,OAAO,CAAC,CAAC;QACf,IAAI,CAAC,IAAI,GAAG,UAAU,CAAC;IACzB,CAAC;CACF"}
|
package/dist/index.js
ADDED
|
@@ -0,0 +1,210 @@
|
|
|
1
|
+
#!/usr/bin/env node
|
|
2
|
+
import { Command } from "commander";
|
|
3
|
+
import { ApiClient } from "./api.js";
|
|
4
|
+
import { CliError, loadConfig, requireApiKey } from "./config.js";
|
|
5
|
+
import { loginCommand, whoamiCommand } from "./commands/login.js";
|
|
6
|
+
import { listServersCommand, showServerCommand } from "./commands/servers.js";
|
|
7
|
+
import { listToolsCommand, showToolCommand } from "./commands/tools.js";
|
|
8
|
+
import { executeCommand } from "./commands/execute.js";
|
|
9
|
+
import { closeSessionCommand, listSessionsCommand, showSessionCommand, } from "./commands/sessions.js";
|
|
10
|
+
import { listConnectionsCommand, revokeConnectCommand, startConnectCommand, } from "./commands/connect.js";
|
|
11
|
+
import { tailLogsCommand } from "./commands/logs.js";
|
|
12
|
+
import { initCommand } from "./commands/init.js";
|
|
13
|
+
import { c } from "./output.js";
|
|
14
|
+
const VERSION = "0.2.0";
|
|
15
|
+
const program = new Command();
|
|
16
|
+
program
|
|
17
|
+
.name("codespar")
|
|
18
|
+
.description("CodeSpar CLI — authenticate, inspect servers, execute tools, manage sessions.")
|
|
19
|
+
.version(VERSION, "-v, --version")
|
|
20
|
+
.option("--api-key <key>", "CodeSpar API key (overrides config + env)")
|
|
21
|
+
.option("--base-url <url>", "API base URL (overrides config + env)")
|
|
22
|
+
.option("--json", "Output machine-readable JSON instead of tables");
|
|
23
|
+
/** Build an authenticated ApiClient from config + CLI-level flags. */
|
|
24
|
+
async function authedClient() {
|
|
25
|
+
const config = await loadConfig();
|
|
26
|
+
const root = program.opts();
|
|
27
|
+
const apiKey = root.apiKey ?? requireApiKey(config);
|
|
28
|
+
const baseUrl = root.baseUrl ?? config.baseUrl ?? "https://api.codespar.dev";
|
|
29
|
+
return new ApiClient({ apiKey, baseUrl });
|
|
30
|
+
}
|
|
31
|
+
function rootJsonFlag() {
|
|
32
|
+
return Boolean(program.opts().json);
|
|
33
|
+
}
|
|
34
|
+
// ============ auth ============
|
|
35
|
+
program
|
|
36
|
+
.command("login")
|
|
37
|
+
.description("Authenticate and save your API key to ~/.codespar/config.json")
|
|
38
|
+
.option("--api-key <key>", "API key (prompts if omitted)")
|
|
39
|
+
.action(async (opts) => {
|
|
40
|
+
const root = program.opts();
|
|
41
|
+
await loginCommand({ apiKey: opts.apiKey, baseUrl: root.baseUrl });
|
|
42
|
+
});
|
|
43
|
+
program
|
|
44
|
+
.command("whoami")
|
|
45
|
+
.description("Show the authenticated user, org, project, and key scopes")
|
|
46
|
+
.action(async () => {
|
|
47
|
+
const client = await authedClient();
|
|
48
|
+
await whoamiCommand(client, rootJsonFlag());
|
|
49
|
+
});
|
|
50
|
+
program
|
|
51
|
+
.command("logout")
|
|
52
|
+
.description("Clear the stored API key")
|
|
53
|
+
.action(async () => {
|
|
54
|
+
const { saveConfig } = await import("./config.js");
|
|
55
|
+
await saveConfig({ apiKey: undefined });
|
|
56
|
+
const { success } = await import("./output.js");
|
|
57
|
+
success("Logged out.");
|
|
58
|
+
});
|
|
59
|
+
// ============ servers ============
|
|
60
|
+
const servers = program.command("servers").description("Browse the server catalog");
|
|
61
|
+
servers
|
|
62
|
+
.command("list")
|
|
63
|
+
.description("List servers")
|
|
64
|
+
.option("-c, --category <name>", "Filter by category")
|
|
65
|
+
.option("-r, --region <code>", "Filter by region (e.g. BR, MX)")
|
|
66
|
+
.action(async (opts) => {
|
|
67
|
+
const client = await authedClient();
|
|
68
|
+
await listServersCommand(client, { ...opts, json: rootJsonFlag() });
|
|
69
|
+
});
|
|
70
|
+
servers
|
|
71
|
+
.command("show <id>")
|
|
72
|
+
.description("Show details of a server")
|
|
73
|
+
.action(async (id) => {
|
|
74
|
+
const client = await authedClient();
|
|
75
|
+
await showServerCommand(client, id, { json: rootJsonFlag() });
|
|
76
|
+
});
|
|
77
|
+
// ============ tools ============
|
|
78
|
+
const tools = program.command("tools").description("Inspect tools exposed by servers");
|
|
79
|
+
tools
|
|
80
|
+
.command("list")
|
|
81
|
+
.description("List tools")
|
|
82
|
+
.option("-s, --server <id>", "Filter by server")
|
|
83
|
+
.action(async (opts) => {
|
|
84
|
+
const client = await authedClient();
|
|
85
|
+
await listToolsCommand(client, { ...opts, json: rootJsonFlag() });
|
|
86
|
+
});
|
|
87
|
+
tools
|
|
88
|
+
.command("show <name>")
|
|
89
|
+
.description("Show a tool's full schema")
|
|
90
|
+
.action(async (name) => {
|
|
91
|
+
const client = await authedClient();
|
|
92
|
+
await showToolCommand(client, name, { json: rootJsonFlag() });
|
|
93
|
+
});
|
|
94
|
+
// ============ execute ============
|
|
95
|
+
program
|
|
96
|
+
.command("execute <tool>")
|
|
97
|
+
.description("Run a single tool call (creates a throwaway session)")
|
|
98
|
+
.requiredOption("-s, --server <id>", "Server to open the session against")
|
|
99
|
+
.option("-i, --input <json>", "Input as JSON string")
|
|
100
|
+
.option("-f, --input-file <path>", "Input as JSON file path")
|
|
101
|
+
.option("-u, --user <id>", "User id for the session (default: cli-user)")
|
|
102
|
+
.action(async (tool, opts) => {
|
|
103
|
+
const config = await loadConfig();
|
|
104
|
+
const root = program.opts();
|
|
105
|
+
const apiKey = root.apiKey ?? requireApiKey(config);
|
|
106
|
+
const baseUrl = root.baseUrl ?? config.baseUrl ?? "https://api.codespar.dev";
|
|
107
|
+
await executeCommand(tool, {
|
|
108
|
+
...opts,
|
|
109
|
+
apiKey,
|
|
110
|
+
baseUrl,
|
|
111
|
+
json: rootJsonFlag(),
|
|
112
|
+
});
|
|
113
|
+
});
|
|
114
|
+
// ============ sessions ============
|
|
115
|
+
const sessions = program.command("sessions").description("Inspect and manage sessions");
|
|
116
|
+
sessions
|
|
117
|
+
.command("list")
|
|
118
|
+
.description("List recent sessions")
|
|
119
|
+
.option("--status <s>", "Filter by status: active, closed, error")
|
|
120
|
+
.option("--limit <n>", "Max results (default 50)")
|
|
121
|
+
.action(async (opts) => {
|
|
122
|
+
const client = await authedClient();
|
|
123
|
+
await listSessionsCommand(client, { ...opts, json: rootJsonFlag() });
|
|
124
|
+
});
|
|
125
|
+
sessions
|
|
126
|
+
.command("show <id>")
|
|
127
|
+
.description("Show a session's details")
|
|
128
|
+
.option("--logs", "Also include tool-call logs")
|
|
129
|
+
.action(async (id, opts) => {
|
|
130
|
+
const client = await authedClient();
|
|
131
|
+
await showSessionCommand(client, id, { ...opts, json: rootJsonFlag() });
|
|
132
|
+
});
|
|
133
|
+
sessions
|
|
134
|
+
.command("close <id>")
|
|
135
|
+
.description("Close an active session")
|
|
136
|
+
.action(async (id) => {
|
|
137
|
+
const client = await authedClient();
|
|
138
|
+
await closeSessionCommand(client, id);
|
|
139
|
+
});
|
|
140
|
+
// ============ connect ============
|
|
141
|
+
const connect = program.command("connect").description("Manage Connect Links for end-user provider OAuth");
|
|
142
|
+
connect
|
|
143
|
+
.command("list")
|
|
144
|
+
.description("List active connections")
|
|
145
|
+
.option("-u, --user <id>", "Filter by user")
|
|
146
|
+
.option("--status <s>", "Filter by status: connected, pending, revoked, expired")
|
|
147
|
+
.action(async (opts) => {
|
|
148
|
+
const client = await authedClient();
|
|
149
|
+
await listConnectionsCommand(client, { ...opts, json: rootJsonFlag() });
|
|
150
|
+
});
|
|
151
|
+
connect
|
|
152
|
+
.command("start <server>")
|
|
153
|
+
.description("Start a Connect Link flow for a server")
|
|
154
|
+
.option("-u, --user <id>", "User id (default: cli-user)")
|
|
155
|
+
.option("--open", "Open the link in the system browser")
|
|
156
|
+
.action(async (server, opts) => {
|
|
157
|
+
const client = await authedClient();
|
|
158
|
+
await startConnectCommand(client, server, { ...opts, json: rootJsonFlag() });
|
|
159
|
+
});
|
|
160
|
+
connect
|
|
161
|
+
.command("revoke <server>")
|
|
162
|
+
.description("Revoke an existing connection")
|
|
163
|
+
.option("-u, --user <id>", "User id (default: cli-user)")
|
|
164
|
+
.action(async (server, opts) => {
|
|
165
|
+
const client = await authedClient();
|
|
166
|
+
await revokeConnectCommand(client, server, opts);
|
|
167
|
+
});
|
|
168
|
+
// ============ logs ============
|
|
169
|
+
const logs = program.command("logs").description("Inspect tool-call execution logs");
|
|
170
|
+
logs
|
|
171
|
+
.command("tail")
|
|
172
|
+
.description("Stream logs in real time (SSE)")
|
|
173
|
+
.option("-s, --server <id>", "Filter by server")
|
|
174
|
+
.option("--status <s>", "Filter by status: success, error, running")
|
|
175
|
+
.option("-t, --tool <name>", "Filter by tool name")
|
|
176
|
+
.option("--limit <n>", "Request up to N backfilled entries before tailing")
|
|
177
|
+
.action(async (opts) => {
|
|
178
|
+
const config = await loadConfig();
|
|
179
|
+
const root = program.opts();
|
|
180
|
+
const apiKey = root.apiKey ?? requireApiKey(config);
|
|
181
|
+
const baseUrl = root.baseUrl ?? config.baseUrl ?? "https://api.codespar.dev";
|
|
182
|
+
await tailLogsCommand({ apiKey, baseUrl }, { ...opts, json: rootJsonFlag() });
|
|
183
|
+
});
|
|
184
|
+
// ============ init ============
|
|
185
|
+
program
|
|
186
|
+
.command("init <name>")
|
|
187
|
+
.description("Scaffold a new commerce agent from a template")
|
|
188
|
+
.option("-t, --template <slug>", "Template slug (pix-agent, ecommerce-checkout, streaming-chat, multi-tenant)")
|
|
189
|
+
.option("-y, --yes", "Use default template without prompting")
|
|
190
|
+
.action(async (name, opts) => {
|
|
191
|
+
await initCommand(name, opts);
|
|
192
|
+
});
|
|
193
|
+
// ============ global error handling ============
|
|
194
|
+
async function main() {
|
|
195
|
+
try {
|
|
196
|
+
await program.parseAsync(process.argv);
|
|
197
|
+
}
|
|
198
|
+
catch (err) {
|
|
199
|
+
if (err instanceof CliError) {
|
|
200
|
+
process.stderr.write(`${c.red("✗")} ${err.message}\n`);
|
|
201
|
+
process.exit(1);
|
|
202
|
+
}
|
|
203
|
+
// Unexpected error — show stack so we can debug.
|
|
204
|
+
process.stderr.write(`${c.red("✗ internal error:")}\n`);
|
|
205
|
+
process.stderr.write(String(err.stack ?? err) + "\n");
|
|
206
|
+
process.exit(2);
|
|
207
|
+
}
|
|
208
|
+
}
|
|
209
|
+
main();
|
|
210
|
+
//# sourceMappingURL=index.js.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"index.js","sourceRoot":"","sources":["../src/index.ts"],"names":[],"mappings":";AACA,OAAO,EAAE,OAAO,EAAE,MAAM,WAAW,CAAC;AACpC,OAAO,EAAE,SAAS,EAAE,MAAM,UAAU,CAAC;AACrC,OAAO,EAAE,QAAQ,EAAE,UAAU,EAAE,aAAa,EAAE,MAAM,aAAa,CAAC;AAClE,OAAO,EAAE,YAAY,EAAE,aAAa,EAAE,MAAM,qBAAqB,CAAC;AAClE,OAAO,EAAE,kBAAkB,EAAE,iBAAiB,EAAE,MAAM,uBAAuB,CAAC;AAC9E,OAAO,EAAE,gBAAgB,EAAE,eAAe,EAAE,MAAM,qBAAqB,CAAC;AACxE,OAAO,EAAE,cAAc,EAAE,MAAM,uBAAuB,CAAC;AACvD,OAAO,EACL,mBAAmB,EACnB,mBAAmB,EACnB,kBAAkB,GACnB,MAAM,wBAAwB,CAAC;AAChC,OAAO,EACL,sBAAsB,EACtB,oBAAoB,EACpB,mBAAmB,GACpB,MAAM,uBAAuB,CAAC;AAC/B,OAAO,EAAE,eAAe,EAAE,MAAM,oBAAoB,CAAC;AACrD,OAAO,EAAE,WAAW,EAAE,MAAM,oBAAoB,CAAC;AACjD,OAAO,EAAE,CAAC,EAAE,MAAM,aAAa,CAAC;AAEhC,MAAM,OAAO,GAAG,OAAO,CAAC;AAExB,MAAM,OAAO,GAAG,IAAI,OAAO,EAAE,CAAC;AAC9B,OAAO;KACJ,IAAI,CAAC,UAAU,CAAC;KAChB,WAAW,CAAC,+EAA+E,CAAC;KAC5F,OAAO,CAAC,OAAO,EAAE,eAAe,CAAC;KACjC,MAAM,CAAC,iBAAiB,EAAE,2CAA2C,CAAC;KACtE,MAAM,CAAC,kBAAkB,EAAE,uCA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IAAI,CAAC,CAAC;AAChC,CAAC,CAAC,CAAC;AAEL,kDAAkD;AAClD,KAAK,UAAU,IAAI;IACjB,IAAI,CAAC;QACH,MAAM,OAAO,CAAC,UAAU,CAAC,OAAO,CAAC,IAAI,CAAC,CAAC;IACzC,CAAC;IAAC,OAAO,GAAG,EAAE,CAAC;QACb,IAAI,GAAG,YAAY,QAAQ,EAAE,CAAC;YAC5B,OAAO,CAAC,MAAM,CAAC,KAAK,CAAC,GAAG,CAAC,CAAC,GAAG,CAAC,GAAG,CAAC,IAAI,GAAG,CAAC,OAAO,IAAI,CAAC,CAAC;YACvD,OAAO,CAAC,IAAI,CAAC,CAAC,CAAC,CAAC;QAClB,CAAC;QACD,iDAAiD;QACjD,OAAO,CAAC,MAAM,CAAC,KAAK,CAAC,GAAG,CAAC,CAAC,GAAG,CAAC,mBAAmB,CAAC,IAAI,CAAC,CAAC;QACxD,OAAO,CAAC,MAAM,CAAC,KAAK,CAAC,MAAM,CAAE,GAAa,CAAC,KAAK,IAAI,GAAG,CAAC,GAAG,IAAI,CAAC,CAAC;QACjE,OAAO,CAAC,IAAI,CAAC,CAAC,CAAC,CAAC;IAClB,CAAC;AACH,CAAC;AAED,IAAI,EAAE,CAAC"}
|
package/dist/output.js
ADDED
|
@@ -0,0 +1,54 @@
|
|
|
1
|
+
/**
|
|
2
|
+
* Output helpers. Zero deps — ANSI color codes directly, disabled when
|
|
3
|
+
* `NO_COLOR` is set, `FORCE_COLOR=0`, or stdout is not a TTY. This keeps
|
|
4
|
+
* piped output (`| jq`, `| grep`) plain text without us having to strip.
|
|
5
|
+
*/
|
|
6
|
+
const USE_COLOR = process.env.NO_COLOR === undefined &&
|
|
7
|
+
process.env.FORCE_COLOR !== "0" &&
|
|
8
|
+
(process.env.FORCE_COLOR !== undefined || process.stdout.isTTY);
|
|
9
|
+
function wrap(open, close) {
|
|
10
|
+
return (s) => (USE_COLOR ? `\x1b[${open}m${s}\x1b[${close}m` : s);
|
|
11
|
+
}
|
|
12
|
+
export const c = {
|
|
13
|
+
dim: wrap("2", "22"),
|
|
14
|
+
bold: wrap("1", "22"),
|
|
15
|
+
green: wrap("32", "39"),
|
|
16
|
+
red: wrap("31", "39"),
|
|
17
|
+
yellow: wrap("33", "39"),
|
|
18
|
+
blue: wrap("34", "39"),
|
|
19
|
+
gray: wrap("90", "39"),
|
|
20
|
+
};
|
|
21
|
+
/** Print a compact key/value block. Used for `whoami` and `servers show`. */
|
|
22
|
+
export function kv(pairs) {
|
|
23
|
+
const width = Math.max(...pairs.map(([k]) => k.length));
|
|
24
|
+
for (const [k, v] of pairs) {
|
|
25
|
+
process.stdout.write(`${c.gray(k.padEnd(width))} ${v}\n`);
|
|
26
|
+
}
|
|
27
|
+
}
|
|
28
|
+
/** Print a table with aligned columns. `headers` are shown in bold gray. */
|
|
29
|
+
export function table(headers, rows) {
|
|
30
|
+
if (rows.length === 0) {
|
|
31
|
+
process.stderr.write(c.dim("(no results)\n"));
|
|
32
|
+
return;
|
|
33
|
+
}
|
|
34
|
+
const widths = headers.map((h, i) => Math.max(h.length, ...rows.map((r) => (r[i] ?? "").length)));
|
|
35
|
+
const fmt = (cells) => cells.map((cell, i) => cell.padEnd(widths[i])).join(" ");
|
|
36
|
+
process.stdout.write(c.bold(c.gray(fmt(headers))) + "\n");
|
|
37
|
+
for (const row of rows)
|
|
38
|
+
process.stdout.write(fmt(row) + "\n");
|
|
39
|
+
}
|
|
40
|
+
/** Print valid JSON to stdout — for `--json` flag / scripting. */
|
|
41
|
+
export function json(value) {
|
|
42
|
+
process.stdout.write(JSON.stringify(value, null, 2) + "\n");
|
|
43
|
+
}
|
|
44
|
+
/** Info message to stderr (keeps stdout clean for scripting). */
|
|
45
|
+
export function info(msg) {
|
|
46
|
+
process.stderr.write(`${c.blue("ℹ")} ${msg}\n`);
|
|
47
|
+
}
|
|
48
|
+
export function success(msg) {
|
|
49
|
+
process.stderr.write(`${c.green("✓")} ${msg}\n`);
|
|
50
|
+
}
|
|
51
|
+
export function warn(msg) {
|
|
52
|
+
process.stderr.write(`${c.yellow("⚠")} ${msg}\n`);
|
|
53
|
+
}
|
|
54
|
+
//# sourceMappingURL=output.js.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"output.js","sourceRoot":"","sources":["../src/output.ts"],"names":[],"mappings":"AAAA;;;;GAIG;AACH,MAAM,SAAS,GACb,OAAO,CAAC,GAAG,CAAC,QAAQ,KAAK,SAAS;IAClC,OAAO,CAAC,GAAG,CAAC,WAAW,KAAK,GAAG;IAC/B,CAAC,OAAO,CAAC,GAAG,CAAC,WAAW,KAAK,SAAS,IAAI,OAAO,CAAC,MAAM,CAAC,KAAK,CAAC,CAAC;AAElE,SAAS,IAAI,CAAC,IAAY,EAAE,KAAa;IACvC,OAAO,CAAC,CAAS,EAAE,EAAE,CAAC,CAAC,SAAS,CAAC,CAAC,CAAC,QAAQ,IAAI,IAAI,CAAC,QAAQ,KAAK,GAAG,CAAC,CAAC,CAAC,CAAC,CAAC,CAAC;AAC5E,CAAC;AAED,MAAM,CAAC,MAAM,CAAC,GAAG;IACf,GAAG,EAAE,IAAI,CAAC,GAAG,EAAE,IAAI,CAAC;IACpB,IAAI,EAAE,IAAI,CAAC,GAAG,EAAE,IAAI,CAAC;IACrB,KAAK,EAAE,IAAI,CAAC,IAAI,EAAE,IAAI,CAAC;IACvB,GAAG,EAAE,IAAI,CAAC,IAAI,EAAE,IAAI,CAAC;IACrB,MAAM,EAAE,IAAI,CAAC,IAAI,EAAE,IAAI,CAAC;IACxB,IAAI,EAAE,IAAI,CAAC,IAAI,EAAE,IAAI,CAAC;IACtB,IAAI,EAAE,IAAI,CAAC,IAAI,EAAE,IAAI,CAAC;CACvB,CAAC;AAEF,6EAA6E;AAC7E,MAAM,UAAU,EAAE,CAAC,KAA8B;IAC/C,MAAM,KAAK,GAAG,IAAI,CAAC,GAAG,CAAC,GAAG,KAAK,CAAC,GAAG,CAAC,CAAC,CAAC,CAAC,CAAC,EAAE,EAAE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,CAAC,KAAK,CAAC,GAAG,CAAC,GAAG,CAAC,GAAG,IAAI,CAAC,CAAC;AAChE,CAAC;AAED,kEAAkE;AAClE,MAAM,UAAU,IAAI,CAAC,KAAc;IACjC,OAAO,CAAC,MAAM,CAAC,KAAK,CAAC,IAAI,CAAC,SAAS,CAAC,KAAK,EAAE,IAAI,EAAE,CAAC,CAAC,GAAG,IAAI,CAAC,CAAC;AAC9D,CAAC;AAED,iEAAiE;AACjE,MAAM,UAAU,IAAI,CAAC,GAAW;IAC9B,OAAO,CAAC,MAAM,CAAC,KAAK,CAAC,GAAG,CAAC,CAAC,IAAI,CAAC,GAAG,CAAC,IAAI,GAAG,IAAI,CAAC,CAAC;AAClD,CAAC;AACD,MAAM,UAAU,OAAO,CAAC,GAAW;IACjC,OAAO,CAAC,MAAM,CAAC,KAAK,CAAC,GAAG,CAAC,CAAC,KAAK,CAAC,GAAG,CAAC,IAAI,GAAG,IAAI,CAAC,CAAC;AACnD,CAAC;AACD,MAAM,UAAU,IAAI,CAAC,GAAW;IAC9B,OAAO,CAAC,MAAM,CAAC,KAAK,CAAC,GAAG,CAAC,CAAC,MAAM,CAAC,GAAG,CAAC,IAAI,GAAG,IAAI,CAAC,CAAC;AACpD,CAAC"}
|
package/package.json
ADDED
|
@@ -0,0 +1,55 @@
|
|
|
1
|
+
{
|
|
2
|
+
"name": "@codespar/cli",
|
|
3
|
+
"version": "0.2.0",
|
|
4
|
+
"description": "CodeSpar CLI — authenticate, browse servers, execute tools, manage sessions, stream logs, and scaffold projects from your terminal.",
|
|
5
|
+
"type": "module",
|
|
6
|
+
"bin": {
|
|
7
|
+
"codespar": "./dist/index.js"
|
|
8
|
+
},
|
|
9
|
+
"files": [
|
|
10
|
+
"dist",
|
|
11
|
+
"templates",
|
|
12
|
+
"README.md",
|
|
13
|
+
"LICENSE"
|
|
14
|
+
],
|
|
15
|
+
"scripts": {
|
|
16
|
+
"build": "tsc",
|
|
17
|
+
"dev": "tsc --watch",
|
|
18
|
+
"typecheck": "tsc --noEmit",
|
|
19
|
+
"clean": "rm -rf dist",
|
|
20
|
+
"prepublishOnly": "npm run build"
|
|
21
|
+
},
|
|
22
|
+
"keywords": [
|
|
23
|
+
"cli",
|
|
24
|
+
"codespar",
|
|
25
|
+
"ai-agent",
|
|
26
|
+
"commerce",
|
|
27
|
+
"mcp",
|
|
28
|
+
"pix",
|
|
29
|
+
"latam"
|
|
30
|
+
],
|
|
31
|
+
"license": "MIT",
|
|
32
|
+
"repository": {
|
|
33
|
+
"type": "git",
|
|
34
|
+
"url": "https://github.com/codespar/codespar-core",
|
|
35
|
+
"directory": "packages/cli"
|
|
36
|
+
},
|
|
37
|
+
"homepage": "https://codespar.dev/docs/cli",
|
|
38
|
+
"bugs": {
|
|
39
|
+
"url": "https://github.com/codespar/codespar-core/issues"
|
|
40
|
+
},
|
|
41
|
+
"publishConfig": {
|
|
42
|
+
"access": "public"
|
|
43
|
+
},
|
|
44
|
+
"engines": {
|
|
45
|
+
"node": ">=20"
|
|
46
|
+
},
|
|
47
|
+
"dependencies": {
|
|
48
|
+
"@codespar/sdk": "^0.2.0",
|
|
49
|
+
"commander": "^13.0.0"
|
|
50
|
+
},
|
|
51
|
+
"devDependencies": {
|
|
52
|
+
"@types/node": "^25.6.0",
|
|
53
|
+
"typescript": "^5.8.0"
|
|
54
|
+
}
|
|
55
|
+
}
|
|
@@ -0,0 +1,22 @@
|
|
|
1
|
+
# {{name}}
|
|
2
|
+
|
|
3
|
+
End-to-end e-commerce checkout agent scaffolded by `codespar init`.
|
|
4
|
+
|
|
5
|
+
## Setup
|
|
6
|
+
|
|
7
|
+
```bash
|
|
8
|
+
cp .env.example .env
|
|
9
|
+
# Fill in CODESPAR_API_KEY and ANTHROPIC_API_KEY
|
|
10
|
+
|
|
11
|
+
npm install
|
|
12
|
+
npm run dev
|
|
13
|
+
```
|
|
14
|
+
|
|
15
|
+
## What it does
|
|
16
|
+
|
|
17
|
+
Handles the full Complete Loop: product discovery → checkout → invoice (NF-e) → shipping → WhatsApp notification. Uses Claude as the reasoning engine.
|
|
18
|
+
|
|
19
|
+
## Learn more
|
|
20
|
+
|
|
21
|
+
- [E-Commerce Checkout cookbook](https://codespar.dev/docs/cookbooks/ecommerce-checkout)
|
|
22
|
+
- [Claude provider reference](https://codespar.dev/docs/providers/claude)
|
|
@@ -0,0 +1,24 @@
|
|
|
1
|
+
{
|
|
2
|
+
"name": "{{name}}",
|
|
3
|
+
"version": "0.1.0",
|
|
4
|
+
"private": true,
|
|
5
|
+
"type": "module",
|
|
6
|
+
"scripts": {
|
|
7
|
+
"dev": "tsx src/index.ts",
|
|
8
|
+
"build": "tsc",
|
|
9
|
+
"start": "node dist/index.js"
|
|
10
|
+
},
|
|
11
|
+
"dependencies": {
|
|
12
|
+
"@codespar/sdk": "^0.2.0",
|
|
13
|
+
"@codespar/claude": "^0.2.0",
|
|
14
|
+
"@anthropic-ai/sdk": "^0.40.0"
|
|
15
|
+
},
|
|
16
|
+
"devDependencies": {
|
|
17
|
+
"@types/node": "^22.0.0",
|
|
18
|
+
"tsx": "^4.0.0",
|
|
19
|
+
"typescript": "^5.0.0"
|
|
20
|
+
},
|
|
21
|
+
"engines": {
|
|
22
|
+
"node": ">=20"
|
|
23
|
+
}
|
|
24
|
+
}
|