@nitsan-ai/ragsuite-test 0.1.6 → 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 CHANGED
@@ -1,51 +1,42 @@
1
1
  # RAGSuite test CLI (`ragsuite-test`)
2
2
 
3
- npm-style deploy: **init once**, then **start / update / stop** via host **npm scripts** — **no Docker**.
3
+ End-user deploy: install the CLI **globally**, init once, then start/update/stop.
4
4
 
5
5
  ```bash
6
- npm install -g @nitsan-ai/ragsuite-test
7
-
8
- # First time only
9
- ragsuite-test init
10
- # clones → ~/ragsuite-test
11
-
12
- # Needs Postgres :5436 + Redis :6382 (auto-started via data-only compose if Docker is available)
13
- ragsuite-test start
14
- # API http://localhost:9090 · Web http://localhost:9191
6
+ # Always use -g (puts ragsuite-test on your PATH)
7
+ npm install -g @nitsan-ai/ragsuite-test@latest
15
8
 
9
+ ragsuite-test init # once → ~/ragsuite-test
10
+ ragsuite-test start # API :9090 · Web :9191
16
11
  ragsuite-test stop
17
- # stops host app + leftover Docker app containers; keeps DB volumes
18
12
  ```
19
13
 
20
- Same under the hood as:
14
+ ### Upgrade later (CLI + app, keeps data)
21
15
 
22
16
  ```bash
23
- cd ~/ragsuite-test
24
- npm start # scripts/native-start.sh
25
- npm run stop # scripts/native-stop.sh
17
+ ragsuite-test update
18
+ ragsuite-test start
26
19
  ```
27
20
 
28
- Active install is remembered in `~/.ragsuite-test/config.json`.
21
+ `update` runs `npm install -g @nitsan-ai/ragsuite-test@latest` then `git pull` in the install dir. It never runs `docker compose down -v`.
29
22
 
30
- **Data safety:** `start` may run `docker compose up -d postgres redis` only (existing volumes). It never runs `down -v`. App code always runs natively.
23
+ > If you run `npm i @nitsan-ai/ragsuite-test` **without** `-g`, the `ragsuite-test` command will be missing. Fix: `npm install -g @nitsan-ai/ragsuite-test@latest`.
31
24
 
32
- ---
33
-
34
- ## Upgrade (keeps data & `.env`)
25
+ Same as:
35
26
 
36
27
  ```bash
37
- npm install -g @nitsan-ai/ragsuite-test@latest
38
- ragsuite-test update # git pull only
39
- ragsuite-test start
28
+ cd ~/ragsuite-test
29
+ npm start # scripts/native-start.sh
30
+ npm run stop # scripts/native-stop.sh
40
31
  ```
41
32
 
42
- **Never** run `docker compose down -v` or `init --force` unless you mean to wipe data.
33
+ Active install: `~/.ragsuite-test/config.json`.
43
34
 
44
- If you already installed and run `init` again **Already installed** (exit OK).
35
+ **Data safety:** `start` may run `docker compose up -d postgres redis` only (existing volumes). App processes run on the host.
45
36
 
46
37
  ---
47
38
 
48
- ## Prerequisites (host)
39
+ ## Prerequisites
49
40
 
50
41
  | Tool | Notes |
51
42
  |------|--------|
@@ -53,10 +44,8 @@ If you already installed and run `init` again → **Already installed** (exit OK
53
44
  | Python 3 + venv | backend |
54
45
  | Yarn | Expo frontend |
55
46
  | Git | `init` clone |
56
- | Postgres + Redis | Host brew **or** data-only compose (`postgres`/`redis` services) on :5436 / :6382 |
57
- | Docker (optional) | Only to auto-start/reuse existing postgres/redis volumes |
58
-
59
- Docker is **not** required to run the API/UI (those are native).
47
+ | Postgres + Redis | Host brew **or** data-only compose on :5436 / :6382 |
48
+ | Docker (optional) | Auto-start/reuse existing postgres/redis volumes |
60
49
 
61
50
  ---
62
51
 
@@ -64,17 +53,17 @@ Docker is **not** required to run the API/UI (those are native).
64
53
 
65
54
  | Command | Purpose |
66
55
  |---------|---------|
67
- | `init` | First-time git install (no port checks) |
68
- | `start` | `scripts/native-start.sh` (+ data services if needed) |
56
+ | `init` | First-time git install |
57
+ | `start` | Native app (+ data services if needed) |
69
58
  | `stop` | Native PIDs + leftover app containers (DB kept) |
70
- | `update` | `git pull` in place |
59
+ | `update` | Upgrade CLI (`npm -g`) + app (`git pull`) |
71
60
  | `doctor` | Native prereq checks |
72
61
  | `logs` | Tail `.ragsuite/native/*.log` |
73
62
  | `version` | CLI version |
74
63
 
75
64
  ## Ports
76
65
 
77
- API **9090** · Web **9191** · Postgres **5436** · Redis **6382** · Chroma **8004** (started by native-start if needed)
66
+ API **9090** · Web **9191** · Postgres **5436** · Redis **6382** · Chroma **8004**
78
67
 
79
68
  ## Publish (maintainers)
80
69
 
package/package.json CHANGED
@@ -1,11 +1,11 @@
1
1
  {
2
2
  "name": "@nitsan-ai/ragsuite-test",
3
- "version": "0.1.6",
3
+ "version": "0.1.7",
4
4
  "private": false,
5
- "description": "RAGSuite testing CLI — init once, then start/update/stop via native npm scripts.",
5
+ "description": "RAGSuite testing CLI — npm -g install, then init/start/update/stop (keeps data).",
6
6
  "main": "src/index.js",
7
7
  "bin": {
8
- "ragsuite-test": "./bin/ragsuite-test.js"
8
+ "ragsuite-test": "bin/ragsuite-test.js"
9
9
  },
10
10
  "files": [
11
11
  "bin/",
@@ -5,25 +5,25 @@ const path = require('path');
5
5
  const { resolveRepoRoot, assertNativeDeploy, looksLikeGitCheckout } = require('../utils/paths');
6
6
  const { readConfig } = require('../utils/config');
7
7
  const { setActiveInstall } = require('../utils/global-config');
8
+ const { upgradeGlobalCli } = require('../utils/cli-self-update');
8
9
  const { captureCommand } = require('../utils/spawn');
9
10
  const { info, warn, error } = require('../utils/log');
10
11
 
11
12
  const name = 'update';
12
- const summary = 'git pull in place — keeps .env and data (no Docker)';
13
+ const summary = 'Upgrade CLI (npm -g) + app (git pull) — keeps .env and data';
13
14
 
14
15
  function help() {
15
16
  return `Usage: ragsuite-test update
16
17
 
17
- Upgrades the active git install without wiping data:
18
- git pull --ff-only in the install dir
19
- Keeps .env and any host Postgres/Redis/Chroma data
18
+ Upgrades everything safely:
19
+ 1. npm install -g @nitsan-ai/ragsuite-test@latest (CLI on PATH)
20
+ 2. git pull in the active install dir (app source)
20
21
 
21
- Never runs docker compose (no volume risk).
22
+ Keeps .env and database volumes. Never runs docker compose down -v.
22
23
 
23
- Typical flow after a new release:
24
+ If you previously ran \`npm i @nitsan-ai/ragsuite-test\` without -g,
25
+ the command disappears from PATH. Fix with:
24
26
  npm install -g @nitsan-ai/ragsuite-test@latest
25
- ragsuite-test update
26
- ragsuite-test start
27
27
 
28
28
  Options:
29
29
  --repo-root <path> Override active install
@@ -31,30 +31,12 @@ Options:
31
31
  `;
32
32
  }
33
33
 
34
- function run(ctx) {
35
- let repoRoot;
36
- try {
37
- repoRoot = resolveRepoRoot({
38
- cwd: ctx.cwd,
39
- repoRootFlag: ctx.globals.repoRoot,
40
- env: ctx.env,
41
- });
42
- assertNativeDeploy(repoRoot);
43
- } catch (err) {
44
- error(err.message);
45
- return 1;
46
- }
47
-
48
- setActiveInstall(repoRoot);
49
- const cfg = readConfig(repoRoot);
50
- const source = (cfg && cfg.source) || 'git';
51
-
52
- info(`Updating install: ${repoRoot}`);
53
- info(` source=${source} mode=native`);
34
+ function updateAppSource(repoRoot, env, dryRun) {
35
+ info(`Updating app install: ${repoRoot}`);
54
36
  info(' (.env and database data are kept)');
55
37
  info('');
56
38
 
57
- if (ctx.globals.dryRun) {
39
+ if (dryRun) {
58
40
  info('[dry-run] would update via git pull --ff-only');
59
41
  return 0;
60
42
  }
@@ -67,24 +49,63 @@ function run(ctx) {
67
49
  info('Fetching and pulling latest from git (non-destructive)…');
68
50
  const pull = captureCommand('git', ['pull', '--ff-only'], {
69
51
  cwd: repoRoot,
70
- env: ctx.env,
52
+ env,
71
53
  });
72
54
  if (pull.status !== 0) {
73
- warn(`git pull --ff-only failed (exit ${pull.status}). Trying fetch + status…`);
55
+ warn(`git pull --ff-only failed (exit ${pull.status}).`);
74
56
  if (pull.stderr) warn(String(pull.stderr).trimEnd());
75
- captureCommand('git', ['fetch', '--all', '--prune'], { cwd: repoRoot, env: ctx.env });
76
- const st = captureCommand('git', ['status', '-sb'], { cwd: repoRoot, env: ctx.env });
57
+ captureCommand('git', ['fetch', '--all', '--prune'], { cwd: repoRoot, env });
58
+ const st = captureCommand('git', ['status', '-sb'], { cwd: repoRoot, env });
77
59
  if (st.stdout) info(String(st.stdout).trimEnd());
78
60
  error('Could not fast-forward. Fix local commits or stash, then: cd install && git pull');
79
61
  return 1;
80
62
  }
81
63
  if (pull.stdout) info(String(pull.stdout).trimEnd());
82
64
  info('git pull OK.');
65
+ return 0;
66
+ }
67
+
68
+ function run(ctx) {
69
+ info('=== Upgrade ===');
70
+ info('');
71
+
72
+ const cliResult = upgradeGlobalCli({
73
+ dryRun: ctx.globals.dryRun,
74
+ env: ctx.env,
75
+ });
76
+ if (cliResult.status !== 0) {
77
+ return cliResult.status;
78
+ }
79
+
80
+ info('');
81
+
82
+ let repoRoot = null;
83
+ try {
84
+ repoRoot = resolveRepoRoot({
85
+ cwd: ctx.cwd,
86
+ repoRootFlag: ctx.globals.repoRoot,
87
+ env: ctx.env,
88
+ });
89
+ assertNativeDeploy(repoRoot);
90
+ } catch (err) {
91
+ warn('No app install found yet — CLI was updated only.');
92
+ info('First time? ragsuite-test init && ragsuite-test start');
93
+ return 0;
94
+ }
95
+
96
+ setActiveInstall(repoRoot);
97
+ const cfg = readConfig(repoRoot);
98
+ const source = (cfg && cfg.source) || 'git';
99
+ info(`App source=${source} mode=native`);
100
+ info('');
101
+
102
+ const appCode = updateAppSource(repoRoot, ctx.env, ctx.globals.dryRun);
103
+ if (appCode !== 0) return appCode;
104
+
83
105
  info('');
84
- info('Restart to apply:');
106
+ info('Done. Apply with:');
85
107
  info(' ragsuite-test stop');
86
108
  info(' ragsuite-test start');
87
- info(' # or: cd install && npm run stop && npm start');
88
109
  return 0;
89
110
  }
90
111
 
@@ -2,6 +2,7 @@
2
2
 
3
3
  const path = require('path');
4
4
  const { info } = require('../utils/log');
5
+ const { PACKAGE_NAME } = require('../utils/cli-self-update');
5
6
 
6
7
  const name = 'version';
7
8
  const summary = 'Print CLI package version';
@@ -9,7 +10,11 @@ const summary = 'Print CLI package version';
9
10
  function help() {
10
11
  return `Usage: ragsuite-test version
11
12
 
12
- Print @nitsan-ai/ragsuite-test version from package.json.
13
+ Print ${PACKAGE_NAME} version from package.json.
14
+
15
+ Upgrade:
16
+ npm install -g ${PACKAGE_NAME}@latest
17
+ # or: ragsuite-test update
13
18
  `;
14
19
  }
15
20
 
@@ -17,6 +22,7 @@ function run() {
17
22
  const pkgPath = path.join(__dirname, '..', '..', 'package.json');
18
23
  const pkg = require(pkgPath);
19
24
  info(`${pkg.name}@${pkg.version}`);
25
+ info(`Upgrade: npm install -g ${PACKAGE_NAME}@latest`);
20
26
  return 0;
21
27
  }
22
28
 
package/src/index.js CHANGED
@@ -18,9 +18,16 @@ function globalHelp() {
18
18
  const lines = [
19
19
  'RAGSuite test CLI (experimental)',
20
20
  '',
21
+ 'Install / upgrade (global — required for the ragsuite-test command):',
22
+ ' npm install -g @nitsan-ai/ragsuite-test@latest',
23
+ '',
21
24
  'Usage: ragsuite-test <command> [options]',
22
25
  '',
23
- 'Deploy path: git clone + native npm scripts (no Docker).',
26
+ 'Typical flow:',
27
+ ' ragsuite-test init',
28
+ ' ragsuite-test start',
29
+ ' ragsuite-test update # upgrades CLI + app (keeps data)',
30
+ ' ragsuite-test stop',
24
31
  '',
25
32
  'Commands:',
26
33
  ];
@@ -0,0 +1,72 @@
1
+ 'use strict';
2
+
3
+ const path = require('path');
4
+ const { captureCommand } = require('./spawn');
5
+ const { info, warn, error } = require('./log');
6
+
7
+ const PACKAGE_NAME = '@nitsan-ai/ragsuite-test';
8
+
9
+ function localCliVersion() {
10
+ try {
11
+ const pkg = require(path.join(__dirname, '..', '..', 'package.json'));
12
+ return String(pkg.version || '');
13
+ } catch {
14
+ return '';
15
+ }
16
+ }
17
+
18
+ /**
19
+ * Upgrade the global CLI binary (npm install -g).
20
+ * Safe for end users; does not touch app data or Docker volumes.
21
+ * @returns {{ status: number, versionBefore: string, versionAfter: string|null }}
22
+ */
23
+ function upgradeGlobalCli({ dryRun = false, env = process.env } = {}) {
24
+ const versionBefore = localCliVersion();
25
+ info(`Updating CLI package: npm install -g ${PACKAGE_NAME}@latest`);
26
+ info(' (must use -g so the ragsuite-test command stays on your PATH)');
27
+
28
+ if (dryRun) {
29
+ info(`[dry-run] would run: npm install -g ${PACKAGE_NAME}@latest`);
30
+ return { status: 0, versionBefore, versionAfter: versionBefore };
31
+ }
32
+
33
+ const result = captureCommand(
34
+ 'npm',
35
+ ['install', '-g', `${PACKAGE_NAME}@latest`],
36
+ { env },
37
+ );
38
+ if (result.status !== 0) {
39
+ error(`CLI update failed (exit ${result.status}).`);
40
+ if (result.stderr) error(String(result.stderr).trimEnd());
41
+ if (result.stdout) warn(String(result.stdout).trimEnd());
42
+ error(`Fix: npm install -g ${PACKAGE_NAME}@latest`);
43
+ return { status: result.status || 1, versionBefore, versionAfter: null };
44
+ }
45
+ if (result.stdout) info(String(result.stdout).trimEnd());
46
+
47
+ // Re-read from the newly installed global package when possible
48
+ let versionAfter = null;
49
+ const which = captureCommand('npm', ['root', '-g'], { env });
50
+ if (which.status === 0 && which.stdout) {
51
+ const root = String(which.stdout).trim();
52
+ try {
53
+ const pkg = require(path.join(root, PACKAGE_NAME, 'package.json'));
54
+ versionAfter = String(pkg.version || '');
55
+ } catch {
56
+ versionAfter = null;
57
+ }
58
+ }
59
+
60
+ if (versionAfter) {
61
+ info(`CLI is now ${PACKAGE_NAME}@${versionAfter}`);
62
+ } else {
63
+ info(`CLI update finished. Check: ragsuite-test version`);
64
+ }
65
+ return { status: 0, versionBefore, versionAfter };
66
+ }
67
+
68
+ module.exports = {
69
+ PACKAGE_NAME,
70
+ localCliVersion,
71
+ upgradeGlobalCli,
72
+ };