Sign In

graphstore-cli

Package Overview
Dependencies
Maintainers
1
Versions
6
Alerts
File Explorer

Advanced tools

Socket logo

Install Socket

Detect and block malicious and high-risk dependencies

Install

graphstore-cli - npm Package Compare versions

Comparing version
0.1.2
to
0.1.3
+19
-1
dist/index.js

@@ -9,2 +9,3 @@ #!/usr/bin/env node

import { createInterface } from "readline/promises";
import { stdin } from "process";
var file = join(homedir(), ".config", "graphstore", "config.json");

@@ -24,2 +25,8 @@ async function config() {

}
async function readStdin() {
let value = "";
stdin.setEncoding("utf8");
for await (const chunk of stdin) value += chunk;
return value;
}
async function request(path, options = {}, json = true) {

@@ -131,3 +138,14 @@ const c = await config(), headers = new Headers(options.headers);

data.command("index-delete <id>").action(async (id) => print(await request(`/v1/indexes/${id}`, { method: "DELETE" }), { json: p.opts().json }));
data.command("query <file>").action(async (file2) => print(await request("/v1/query", { method: "POST", body: JSON.parse(await readFile(file2, "utf8")) }), { json: p.opts().json }));
data.command("query [file]").option("--stdin", "read query JSON from standard input").option("--json-query <json>", "inline query JSON").action(async (file2, o) => {
const sources = [Boolean(file2), Boolean(o.stdin), Boolean(o.jsonQuery)].filter(Boolean).length;
if (sources !== 1) throw Error("Provide exactly one of a file, --stdin, or --json-query");
const raw = o.stdin ? await readStdin() : o.jsonQuery || await readFile(file2, "utf8");
let query;
try {
query = JSON.parse(raw);
} catch {
throw Error("Query must be valid JSON");
}
print(await request("/v1/query", { method: "POST", body: query }), { json: p.opts().json });
});
data.command("neighbors <id>").option("--rel <rel>").option("--direction <direction>", "out, in, or both", "out").option("--depth <n>", "maximum depth", "1").action(async (id, o) => print(await request(`/v1/nodes/${id}/neighbors?` + new URLSearchParams({ rel: o.rel || "*", direction: o.direction, depth: String(Math.min(Number(o.depth), 5)) })), { json: p.opts().json }));

@@ -134,0 +152,0 @@ data.command("shortest <from> <to>").option("--rel <rel>").option("--max-depth <n>", "maximum depth", "6").action(async (from, to, o) => print(await request("/v1/paths/shortest", { method: "POST", body: { from, to, rel: o.rel, max_depth: Number(o.maxDepth) } }), { json: p.opts().json }));

+1
-1
{
"name": "graphstore-cli",
"version": "0.1.2",
"version": "0.1.3",
"description": "CLI for the Graphstore agent-first graph database",

@@ -5,0 +5,0 @@ "type": "module",

@@ -13,1 +13,14 @@ # graphstore-cli

For CI or agents, set `GRAPHSTORE_URL` and `GRAPHSTORE_API_KEY`, or pass `--url` and `--key`.
LLMs and pipelines should send structured queries on stdin:
```bash
printf '%s' '{"type":"task","where":[{"path":"$.status","op":"eq","value":"open"}]}' | gs data query --stdin
```
Saved files and small inline queries also work:
```bash
gs data query query.json
gs data query --json-query '{"type":"task","limit":10}'
```