ctxloop 0.3.0 → 0.3.1

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.
Files changed (2) hide show
  1. package/bin/graphsnip.js +15 -23
  2. package/package.json +1 -1
package/bin/graphsnip.js CHANGED
@@ -1,29 +1,21 @@
1
1
  #!/usr/bin/env node
2
- // Thin launcher: graphsnip is a Python package. Try uvx, then pipx, then an installed python module.
3
- // (It deliberately never calls a bare `graphsnip`, which would resolve back to this script.)
4
2
  const { spawnSync } = require("child_process");
5
-
3
+ const version = require("../package.json").version;
4
+ const spec = "ctxloop==" + version;
6
5
  const args = process.argv.slice(2);
7
- const attempts = [
8
- ["uvx", ["--from", "ctxloop", "ctxloop", ...args]],
9
- ["pipx", ["run", "--spec", "ctxloop", "ctxloop", ...args]],
10
- ["python3", ["-m", "graphsnip", ...args]],
11
- ["python", ["-m", "graphsnip", ...args]],
12
- ];
13
-
14
- for (const [cmd, a] of attempts) {
15
- const r = spawnSync(cmd, a, { stdio: "inherit" });
16
- if (r.error && r.error.code === "ENOENT") continue; // tool not installed, try the next
17
- if (cmd.startsWith("python") && r.status === 1 && r.signal == null) {
18
- // `python -m graphsnip` exits 1 both for "module missing" and for real command errors; the former prints to stderr
19
- // already via stdio inherit, so just pass the status through.
20
- }
6
+ for (const [cmd, a] of [
7
+ ["uvx", ["--from", spec, "ctxloop", ...args]],
8
+ ["pipx", ["run", "--spec", spec, "ctxloop", ...args]],
9
+ ]) {
10
+ const r = spawnSync(cmd, a, {stdio:"inherit"});
11
+ if (r.error && r.error.code === "ENOENT") continue;
21
12
  process.exit(r.status === null ? 1 : r.status);
22
13
  }
23
-
24
- console.error(
25
- "graphsnip needs Python 3.10+ with uv or pipx.\n" +
26
- " Install one of: pipx install ctxloop | uv tool install ctxloop\n" +
27
- " Docs: https://github.com/naubadnithinkumar/ctxloop"
28
- );
14
+ for (const cmd of ["python3", "python"]) {
15
+ const check = spawnSync(cmd, ["-c", "import importlib.metadata as m; print(m.version('ctxloop'))"], {encoding:"utf8"});
16
+ if (check.status !== 0 || check.stdout.trim() !== version) continue;
17
+ const r = spawnSync(cmd, ["-m", "ctxloop", ...args], {stdio:"inherit"});
18
+ process.exit(r.status === null ? 1 : r.status);
19
+ }
20
+ console.error("CtxLoop requires uv, pipx, or Python 3.10+ with " + spec + " installed.");
29
21
  process.exit(127);
package/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "ctxloop",
3
- "version": "0.3.0",
3
+ "version": "0.3.1",
4
4
  "description": "CtxLoop context engineering library (formerly GraphSnip).",
5
5
  "bin": {
6
6
  "ctxloop": "bin/graphsnip.js",