@code-sentinel-cli/code-sentinel-cli 3.0.2 → 3.0.3

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/LICENSE ADDED
@@ -0,0 +1,7 @@
1
+ UNLICENSED
2
+
3
+ Copyright (c) Viettel.
4
+
5
+ All rights reserved. Publishing this package to npm does not grant
6
+ permission to copy, modify, redistribute, sublicense, or use the software
7
+ except as separately authorized by the copyright holder.
package/README.md CHANGED
@@ -1,6 +1,6 @@
1
1
  # @code-sentinel-cli/code-sentinel-cli
2
2
 
3
- Hybrid (rule-based + AI) code review CLI tool for Angular 19 (FE) and Spring Boot (BE) — built for Viettel internal use.
3
+ AI-assisted code review CLI for Angular, Spring Boot, and Flutter projects.
4
4
 
5
5
  ## Install
6
6
 
@@ -9,6 +9,65 @@ npm install -g @code-sentinel-cli/code-sentinel-cli
9
9
  cs --help
10
10
  ```
11
11
 
12
- This package requires Node.js 22 or newer. Secrets such as AI provider
13
- keys and dashboard tokens are read from local config or environment
14
- variables at runtime; they are not bundled into this npm package.
12
+ Requires Node.js 22 or newer.
13
+
14
+ ## Quick Start
15
+
16
+ ```bash
17
+ cs quickstart
18
+ cs init
19
+ cs review . --ai-off
20
+ ```
21
+
22
+ Enable AI review by configuring a provider key in your shell or local
23
+ Code Sentinel config, then run:
24
+
25
+ ```bash
26
+ cs review .
27
+ ```
28
+
29
+ ## Common Commands
30
+
31
+ - `cs --help` - list commands.
32
+ - `cs version --json` - print machine-readable build metadata.
33
+ - `cs doctor` - check local prerequisites.
34
+ - `cs init` - create a local `.code-sentinel/codereviewrc.yaml`.
35
+ - `cs review .` - run a review for the current workspace.
36
+ - `cs rule list` - inspect bundled rules.
37
+
38
+ ## Configuration
39
+
40
+ Secrets such as AI provider keys and dashboard tokens are read from local
41
+ config or environment variables at runtime; they are not bundled into this
42
+ npm package. Useful environment variables include:
43
+
44
+ - `LLM_API_KEY`, `GEMINI_API_KEY`, `GROQ_API_KEY`, `OPENCODE_GO_API_KEY`,
45
+ `FREEMODEL_API_KEY` - AI provider credentials.
46
+ - `CODE_SENTINEL_DASHBOARD_URL` and `CODE_SENTINEL_DASHBOARD_TOKEN` -
47
+ dashboard integration.
48
+ - `CODE_SENTINEL_NO_UPDATE_CHECK=1` - disable npm update checks.
49
+ - `NO_COLOR=1` - disable ANSI color output.
50
+
51
+ ## Updates
52
+
53
+ The CLI may check npm for a newer package version at most once every 24
54
+ hours when running in an interactive terminal. It skips CI/non-TTY sessions,
55
+ does not block review execution on network errors, and can be disabled with
56
+ `CODE_SENTINEL_NO_UPDATE_CHECK=1` or `NO_UPDATE_NOTIFIER=1`.
57
+
58
+ ```bash
59
+ npm install -g @code-sentinel-cli/code-sentinel-cli@latest
60
+ ```
61
+
62
+ ## Troubleshooting
63
+
64
+ - Use Node.js 22 or newer: `node --version`.
65
+ - Run `cs doctor` for local setup checks.
66
+ - Run with `--no-color` if your terminal does not support ANSI colors.
67
+ - Use `cs review . --ai-off` for an offline static-rule-only smoke test.
68
+
69
+ ## Module Format
70
+
71
+ This package is ESM-only. The supported public import surface is the package
72
+ root export; deep imports from `dist/` are not part of the compatibility
73
+ contract.
package/dist/bin.js CHANGED
@@ -8,7 +8,7 @@ import { dirname, resolve, join, isAbsolute, basename, relative, extname, sep, p
8
8
  import { Command } from 'commander';
9
9
  import { execFile as execFile$1, execSync, spawn } from 'child_process';
10
10
  import { promisify } from 'util';
11
- import { mkdir, writeFile, readFile, rename, access, mkdtemp, stat, readdir, rm, unlink, chmod, lstat, realpath as realpath$1, open } from 'fs/promises';
11
+ import { readFile, mkdir, writeFile, rename, access, mkdtemp, stat, readdir, rm, unlink, chmod, lstat, realpath as realpath$1, open } from 'fs/promises';
12
12
  import { password, confirm, input, select } from '@inquirer/prompts';
13
13
  import { fileURLToPath, pathToFileURL } from 'url';
14
14
  import * as nativeFs from 'fs';
@@ -2380,11 +2380,11 @@ var definedBuildValue = (value, fallback) => typeof value === "string" && value.
2380
2380
  var getCliBuildMetadata = (version2) => ({
2381
2381
  version: version2,
2382
2382
  gitSha: definedBuildValue(
2383
- "c1a2df007e5c" ,
2383
+ "db0ad7eaf9c6" ,
2384
2384
  "unknown"
2385
2385
  ),
2386
2386
  buildTimestamp: definedBuildValue(
2387
- "2026-08-07T02:37:37.057Z" ,
2387
+ "2026-08-07T03:32:56.496Z" ,
2388
2388
  "unknown"
2389
2389
  ),
2390
2390
  configSchemaRange: definedBuildValue(
@@ -16128,7 +16128,7 @@ function sql(strings, ...params) {
16128
16128
  return new SQL([new StringChunk(str)]);
16129
16129
  }
16130
16130
  sql2.raw = raw;
16131
- function join9(chunks, separator) {
16131
+ function join10(chunks, separator) {
16132
16132
  const result = [];
16133
16133
  for (const [i, chunk] of chunks.entries()) {
16134
16134
  if (i > 0 && separator !== void 0) {
@@ -16138,7 +16138,7 @@ function sql(strings, ...params) {
16138
16138
  }
16139
16139
  return new SQL(result);
16140
16140
  }
16141
- sql2.join = join9;
16141
+ sql2.join = join10;
16142
16142
  function identifier(value) {
16143
16143
  return new Name(value);
16144
16144
  }
@@ -18393,7 +18393,7 @@ var SQLiteSelectQueryBuilderBase = class extends TypedQueryBuilder {
18393
18393
  return (table, on) => {
18394
18394
  const baseTableName = this.tableName;
18395
18395
  const tableName = getTableLikeName(table);
18396
- if (typeof tableName === "string" && this.config.joins?.some((join9) => join9.alias === tableName)) {
18396
+ if (typeof tableName === "string" && this.config.joins?.some((join10) => join10.alias === tableName)) {
18397
18397
  throw new Error(`Alias "${tableName}" is already used in this query`);
18398
18398
  }
18399
18399
  if (!this.isPartialSelect) {
@@ -19196,7 +19196,7 @@ var SQLiteUpdateBase = class extends QueryPromise {
19196
19196
  createJoin(joinType) {
19197
19197
  return (table, on) => {
19198
19198
  const tableName = getTableLikeName(table);
19199
- if (typeof tableName === "string" && this.config.joins.some((join9) => join9.alias === tableName)) {
19199
+ if (typeof tableName === "string" && this.config.joins.some((join10) => join10.alias === tableName)) {
19200
19200
  throw new Error(`Alias "${tableName}" is already used in this query`);
19201
19201
  }
19202
19202
  if (typeof on === "function") {
@@ -32277,6 +32277,97 @@ var loadDotenv = (options = {}) => {
32277
32277
  }
32278
32278
  return { loaded };
32279
32279
  };
32280
+ var CHECK_INTERVAL_MS = 24 * 60 * 60 * 1e3;
32281
+ var FETCH_TIMEOUT_MS = 1200;
32282
+ var truthy = (value) => value === "1" || value === "true" || value === "yes" || value === "on";
32283
+ var disabledByEnv = (env) => truthy(env.CODE_SENTINEL_NO_UPDATE_CHECK) || truthy(env.NO_UPDATE_NOTIFIER) || truthy(env.CI) || env.npm_config_update_notifier === "false";
32284
+ var cacheDirectory = (env) => {
32285
+ const base = env.XDG_CACHE_HOME?.trim() || (homedir() ? join(homedir(), ".cache") : tmpdir());
32286
+ return join(base, "code-sentinel");
32287
+ };
32288
+ var parseCache2 = (text2) => {
32289
+ try {
32290
+ const parsed = JSON.parse(text2);
32291
+ return typeof parsed.checkedAt === "number" ? { checkedAt: parsed.checkedAt, latest: parsed.latest } : null;
32292
+ } catch {
32293
+ return null;
32294
+ }
32295
+ };
32296
+ var numericCore = (version2) => {
32297
+ const match = version2.match(/^(\d+)\.(\d+)\.(\d+)/);
32298
+ if (!match) return null;
32299
+ return [Number(match[1]), Number(match[2]), Number(match[3])];
32300
+ };
32301
+ var isNewerVersion = (latest, current) => {
32302
+ const latestCore = numericCore(latest);
32303
+ const currentCore = numericCore(current);
32304
+ if (!latestCore || !currentCore) return false;
32305
+ for (let index2 = 0; index2 < latestCore.length; index2++) {
32306
+ const latestPart = latestCore[index2] ?? 0;
32307
+ const currentPart = currentCore[index2] ?? 0;
32308
+ if (latestPart > currentPart) return true;
32309
+ if (latestPart < currentPart) return false;
32310
+ }
32311
+ return false;
32312
+ };
32313
+ var registryLatestUrl = (packageName) => `https://registry.npmjs.org/${packageName.replace("/", "%2F")}/latest`;
32314
+ var fetchLatestVersion = async (packageName) => {
32315
+ const controller = new AbortController();
32316
+ const timeout = setTimeout(() => controller.abort(), FETCH_TIMEOUT_MS);
32317
+ timeout.unref?.();
32318
+ try {
32319
+ const response = await fetch(registryLatestUrl(packageName), { signal: controller.signal });
32320
+ if (!response.ok) return null;
32321
+ const body = await response.json();
32322
+ return typeof body.version === "string" ? body.version : null;
32323
+ } catch {
32324
+ return null;
32325
+ } finally {
32326
+ clearTimeout(timeout);
32327
+ }
32328
+ };
32329
+ var printUpdateMessage = (packageName, current, latest) => {
32330
+ process.stderr.write(
32331
+ [
32332
+ "",
32333
+ yellow(`Update available: ${packageName} ${current} -> ${latest}`),
32334
+ gray(`Run: npm install -g ${packageName}@latest`),
32335
+ gray("Disable this check with CODE_SENTINEL_NO_UPDATE_CHECK=1."),
32336
+ ""
32337
+ ].join("\n")
32338
+ );
32339
+ };
32340
+ var maybeNotifyUpdate = async (options) => {
32341
+ const env = options.env ?? process.env;
32342
+ const now = options.now ?? Date.now();
32343
+ if (options.privatePackage) return;
32344
+ if (!options.packageName || options.packageName === "@code-sentinel/cli") return;
32345
+ if (!process.stderr.isTTY) return;
32346
+ if (disabledByEnv(env)) return;
32347
+ const directory = cacheDirectory(env);
32348
+ const cachePath = join(directory, "update-check.json");
32349
+ let cache3 = null;
32350
+ try {
32351
+ cache3 = parseCache2(await readFile(cachePath, "utf8"));
32352
+ } catch {
32353
+ cache3 = null;
32354
+ }
32355
+ if (cache3?.latest && isNewerVersion(cache3.latest, options.currentVersion)) {
32356
+ printUpdateMessage(options.packageName, options.currentVersion, cache3.latest);
32357
+ }
32358
+ if (cache3 && now - cache3.checkedAt < CHECK_INTERVAL_MS) return;
32359
+ const latest = await fetchLatestVersion(options.packageName);
32360
+ const nextCache = { checkedAt: now, ...latest ? { latest } : {} };
32361
+ try {
32362
+ await mkdir(directory, { recursive: true });
32363
+ await writeFile(cachePath, `${JSON.stringify(nextCache, null, 2)}
32364
+ `, "utf8");
32365
+ } catch {
32366
+ }
32367
+ if (latest && latest !== cache3?.latest && isNewerVersion(latest, options.currentVersion)) {
32368
+ printUpdateMessage(options.packageName, options.currentVersion, latest);
32369
+ }
32370
+ };
32280
32371
  var DEFAULT_HOST = "0.0.0.0";
32281
32372
  var DEFAULT_PORT = 8787;
32282
32373
  var DEFAULT_PATH = "/webhooks/gitlab";
@@ -33731,6 +33822,11 @@ var main = async (argv) => {
33731
33822
  const program = buildProgram();
33732
33823
  try {
33733
33824
  await program.parseAsync(argv);
33825
+ await maybeNotifyUpdate({
33826
+ packageName: pkg.name ?? "code-sentinel",
33827
+ currentVersion: VERSION,
33828
+ privatePackage: pkg.private === true
33829
+ });
33734
33830
  const code2 = process.exitCode ?? EXIT.SUCCESS;
33735
33831
  return typeof code2 === "number" ? code2 : Number.parseInt(String(code2), 10) || EXIT.SUCCESS;
33736
33832
  } catch (e) {
package/dist/index.js CHANGED
@@ -2380,11 +2380,11 @@ var definedBuildValue = (value, fallback) => typeof value === "string" && value.
2380
2380
  var getCliBuildMetadata = (version2) => ({
2381
2381
  version: version2,
2382
2382
  gitSha: definedBuildValue(
2383
- "c1a2df007e5c" ,
2383
+ "db0ad7eaf9c6" ,
2384
2384
  "unknown"
2385
2385
  ),
2386
2386
  buildTimestamp: definedBuildValue(
2387
- "2026-08-07T02:37:37.057Z" ,
2387
+ "2026-08-07T03:32:56.496Z" ,
2388
2388
  "unknown"
2389
2389
  ),
2390
2390
  configSchemaRange: definedBuildValue(
@@ -16158,7 +16158,7 @@ function sql(strings, ...params) {
16158
16158
  return new SQL([new StringChunk(str)]);
16159
16159
  }
16160
16160
  sql2.raw = raw;
16161
- function join9(chunks, separator) {
16161
+ function join10(chunks, separator) {
16162
16162
  const result = [];
16163
16163
  for (const [i, chunk] of chunks.entries()) {
16164
16164
  if (i > 0 && separator !== void 0) {
@@ -16168,7 +16168,7 @@ function sql(strings, ...params) {
16168
16168
  }
16169
16169
  return new SQL(result);
16170
16170
  }
16171
- sql2.join = join9;
16171
+ sql2.join = join10;
16172
16172
  function identifier(value) {
16173
16173
  return new Name(value);
16174
16174
  }
@@ -18423,7 +18423,7 @@ var SQLiteSelectQueryBuilderBase = class extends TypedQueryBuilder {
18423
18423
  return (table, on) => {
18424
18424
  const baseTableName = this.tableName;
18425
18425
  const tableName = getTableLikeName(table);
18426
- if (typeof tableName === "string" && this.config.joins?.some((join9) => join9.alias === tableName)) {
18426
+ if (typeof tableName === "string" && this.config.joins?.some((join10) => join10.alias === tableName)) {
18427
18427
  throw new Error(`Alias "${tableName}" is already used in this query`);
18428
18428
  }
18429
18429
  if (!this.isPartialSelect) {
@@ -19226,7 +19226,7 @@ var SQLiteUpdateBase = class extends QueryPromise {
19226
19226
  createJoin(joinType) {
19227
19227
  return (table, on) => {
19228
19228
  const tableName = getTableLikeName(table);
19229
- if (typeof tableName === "string" && this.config.joins.some((join9) => join9.alias === tableName)) {
19229
+ if (typeof tableName === "string" && this.config.joins.some((join10) => join10.alias === tableName)) {
19230
19230
  throw new Error(`Alias "${tableName}" is already used in this query`);
19231
19231
  }
19232
19232
  if (typeof on === "function") {
@@ -32307,6 +32307,97 @@ var loadDotenv = (options = {}) => {
32307
32307
  }
32308
32308
  return { loaded };
32309
32309
  };
32310
+ var CHECK_INTERVAL_MS = 24 * 60 * 60 * 1e3;
32311
+ var FETCH_TIMEOUT_MS = 1200;
32312
+ var truthy = (value) => value === "1" || value === "true" || value === "yes" || value === "on";
32313
+ var disabledByEnv = (env) => truthy(env.CODE_SENTINEL_NO_UPDATE_CHECK) || truthy(env.NO_UPDATE_NOTIFIER) || truthy(env.CI) || env.npm_config_update_notifier === "false";
32314
+ var cacheDirectory = (env) => {
32315
+ const base = env.XDG_CACHE_HOME?.trim() || (homedir() ? join(homedir(), ".cache") : tmpdir());
32316
+ return join(base, "code-sentinel");
32317
+ };
32318
+ var parseCache2 = (text2) => {
32319
+ try {
32320
+ const parsed = JSON.parse(text2);
32321
+ return typeof parsed.checkedAt === "number" ? { checkedAt: parsed.checkedAt, latest: parsed.latest } : null;
32322
+ } catch {
32323
+ return null;
32324
+ }
32325
+ };
32326
+ var numericCore = (version2) => {
32327
+ const match = version2.match(/^(\d+)\.(\d+)\.(\d+)/);
32328
+ if (!match) return null;
32329
+ return [Number(match[1]), Number(match[2]), Number(match[3])];
32330
+ };
32331
+ var isNewerVersion = (latest, current) => {
32332
+ const latestCore = numericCore(latest);
32333
+ const currentCore = numericCore(current);
32334
+ if (!latestCore || !currentCore) return false;
32335
+ for (let index2 = 0; index2 < latestCore.length; index2++) {
32336
+ const latestPart = latestCore[index2] ?? 0;
32337
+ const currentPart = currentCore[index2] ?? 0;
32338
+ if (latestPart > currentPart) return true;
32339
+ if (latestPart < currentPart) return false;
32340
+ }
32341
+ return false;
32342
+ };
32343
+ var registryLatestUrl = (packageName) => `https://registry.npmjs.org/${packageName.replace("/", "%2F")}/latest`;
32344
+ var fetchLatestVersion = async (packageName) => {
32345
+ const controller = new AbortController();
32346
+ const timeout = setTimeout(() => controller.abort(), FETCH_TIMEOUT_MS);
32347
+ timeout.unref?.();
32348
+ try {
32349
+ const response = await fetch(registryLatestUrl(packageName), { signal: controller.signal });
32350
+ if (!response.ok) return null;
32351
+ const body = await response.json();
32352
+ return typeof body.version === "string" ? body.version : null;
32353
+ } catch {
32354
+ return null;
32355
+ } finally {
32356
+ clearTimeout(timeout);
32357
+ }
32358
+ };
32359
+ var printUpdateMessage = (packageName, current, latest) => {
32360
+ process.stderr.write(
32361
+ [
32362
+ "",
32363
+ yellow(`Update available: ${packageName} ${current} -> ${latest}`),
32364
+ gray(`Run: npm install -g ${packageName}@latest`),
32365
+ gray("Disable this check with CODE_SENTINEL_NO_UPDATE_CHECK=1."),
32366
+ ""
32367
+ ].join("\n")
32368
+ );
32369
+ };
32370
+ var maybeNotifyUpdate = async (options) => {
32371
+ const env = options.env ?? process.env;
32372
+ const now = options.now ?? Date.now();
32373
+ if (options.privatePackage) return;
32374
+ if (!options.packageName || options.packageName === "@code-sentinel/cli") return;
32375
+ if (!process.stderr.isTTY) return;
32376
+ if (disabledByEnv(env)) return;
32377
+ const directory = cacheDirectory(env);
32378
+ const cachePath = join(directory, "update-check.json");
32379
+ let cache3 = null;
32380
+ try {
32381
+ cache3 = parseCache2(await readFile(cachePath, "utf8"));
32382
+ } catch {
32383
+ cache3 = null;
32384
+ }
32385
+ if (cache3?.latest && isNewerVersion(cache3.latest, options.currentVersion)) {
32386
+ printUpdateMessage(options.packageName, options.currentVersion, cache3.latest);
32387
+ }
32388
+ if (cache3 && now - cache3.checkedAt < CHECK_INTERVAL_MS) return;
32389
+ const latest = await fetchLatestVersion(options.packageName);
32390
+ const nextCache = { checkedAt: now, ...latest ? { latest } : {} };
32391
+ try {
32392
+ await mkdir(directory, { recursive: true });
32393
+ await writeFile(cachePath, `${JSON.stringify(nextCache, null, 2)}
32394
+ `, "utf8");
32395
+ } catch {
32396
+ }
32397
+ if (latest && latest !== cache3?.latest && isNewerVersion(latest, options.currentVersion)) {
32398
+ printUpdateMessage(options.packageName, options.currentVersion, latest);
32399
+ }
32400
+ };
32310
32401
  var DEFAULT_HOST = "0.0.0.0";
32311
32402
  var DEFAULT_PORT = 8787;
32312
32403
  var DEFAULT_PATH = "/webhooks/gitlab";
@@ -33761,6 +33852,11 @@ var main = async (argv) => {
33761
33852
  const program = buildProgram();
33762
33853
  try {
33763
33854
  await program.parseAsync(argv);
33855
+ await maybeNotifyUpdate({
33856
+ packageName: pkg.name ?? "code-sentinel",
33857
+ currentVersion: VERSION,
33858
+ privatePackage: pkg.private === true
33859
+ });
33764
33860
  const code = process.exitCode ?? EXIT.SUCCESS;
33765
33861
  return typeof code === "number" ? code : Number.parseInt(String(code), 10) || EXIT.SUCCESS;
33766
33862
  } catch (e) {
package/package.json CHANGED
@@ -1,9 +1,9 @@
1
1
  {
2
2
  "name": "@code-sentinel-cli/code-sentinel-cli",
3
- "version": "3.0.2",
3
+ "version": "3.0.3",
4
4
  "private": false,
5
5
  "type": "module",
6
- "description": "Hybrid (rule-based + AI) code review CLI tool for Angular 19 (FE) and Spring Boot (BE) — built for Viettel internal use.",
6
+ "description": "AI-assisted code review CLI for Angular, Spring Boot, and Flutter projects.",
7
7
  "license": "UNLICENSED",
8
8
  "author": "Viettel",
9
9
  "keywords": [
@@ -14,11 +14,12 @@
14
14
  "ai-review",
15
15
  "viettel"
16
16
  ],
17
+ "homepage": "https://www.npmjs.com/package/@code-sentinel-cli/code-sentinel-cli",
17
18
  "main": "./dist/index.js",
18
19
  "types": "./dist/index.d.ts",
19
20
  "bin": {
20
- "code-sentinel": "./dist/bin.js",
21
- "cs": "./dist/bin.js"
21
+ "code-sentinel": "dist/bin.js",
22
+ "cs": "dist/bin.js"
22
23
  },
23
24
  "exports": {
24
25
  ".": {