@cspeach/cli 0.6.1 → 0.6.2

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.
@@ -9,6 +9,7 @@
9
9
  import Anthropic from '@anthropic-ai/sdk';
10
10
  import { getDeviceFingerprint } from '../auth/device.js';
11
11
  import { createManagedSkillSource } from '../skills/source-managed.js';
12
+ import { CLI_VERSION } from '../lib/version.js';
12
13
  export function createManagedProvider(cfg, getBearer) {
13
14
  const skillSource = createManagedSkillSource(cfg, getBearer);
14
15
  return {
@@ -18,7 +19,7 @@ export function createManagedProvider(cfg, getBearer) {
18
19
  async createStream(params, options = {}) {
19
20
  const bearer = await getBearer();
20
21
  const device = await getDeviceFingerprint();
21
- const cliVersion = process.env['npm_package_version'] ?? '0.5.0';
22
+ const cliVersion = CLI_VERSION;
22
23
  const sdk = new Anthropic({
23
24
  apiKey: 'proxy-bearer-auth', // ignored by our proxy; SDK requires non-empty
24
25
  baseURL: cfg.proxy_url.replace(/\/$/, '') + '/',
package/dist/cli.js CHANGED
@@ -1,4 +1,5 @@
1
1
  import chalk from 'chalk';
2
+ import { CLI_VERSION } from './lib/version.js';
2
3
  import { runAddSapWizard } from './sap/onboarding.js';
3
4
  import { runGcOnStartup } from './session/gc.js';
4
5
  import { checkForUpgrade } from './upgrade-check.js';
@@ -12,7 +13,7 @@ export async function main(argv) {
12
13
  return 0;
13
14
  }
14
15
  if (args[0] === '--version') {
15
- console.log(process.env.npm_package_version ?? '0.5.0');
16
+ console.log(CLI_VERSION);
16
17
  return 0;
17
18
  }
18
19
  if (args[0] === '--upgrade') {
@@ -0,0 +1,16 @@
1
+ /**
2
+ * CLI_VERSION — read once from the package.json at module load.
3
+ *
4
+ * Why not process.env.npm_package_version: that env var is only set when
5
+ * npm itself invokes a script (e.g. `npm run start`). When a user runs the
6
+ * installed `cspeach` binary directly, the env var is undefined and we'd
7
+ * fall back to a hardcoded literal — which silently rots on every release.
8
+ */
9
+ import { readFileSync } from 'node:fs';
10
+ import { fileURLToPath } from 'node:url';
11
+ import { dirname, resolve } from 'node:path';
12
+ const here = dirname(fileURLToPath(import.meta.url));
13
+ // dist/lib/version.js → dist/lib/.. → dist → ../../package.json
14
+ const pkgPath = resolve(here, '../../package.json');
15
+ const pkg = JSON.parse(readFileSync(pkgPath, 'utf8'));
16
+ export const CLI_VERSION = pkg.version;
@@ -1,4 +1,5 @@
1
1
  import chalk from 'chalk';
2
+ import { CLI_VERSION } from '../lib/version.js';
2
3
  /** CSPeach brand colour — used for the brand-name text in the startup line,
3
4
  * the tool-dispatch bullet (⏺), and the result continuation glyph (⎿).
4
5
  * Single source of truth so a future rebrand is one find-replace.
@@ -26,7 +27,7 @@ export const PEACH = '#FFCBA4';
26
27
  * which is why the literal exists at all.
27
28
  */
28
29
  export function printStartupBanner() {
29
- const version = process.env.npm_package_version ?? '0.5.0';
30
+ const version = CLI_VERSION;
30
31
  console.log('');
31
32
  console.log(`🍑 ${chalk.hex(PEACH).bold('CSPeach')} ${chalk.white.bold('v' + version)}`);
32
33
  console.log(` ${chalk.gray('ABAP + AI + safety gates')} ${chalk.dim('·')} ${chalk.gray('by Cremencing Solutions')}`);
@@ -1,5 +1,6 @@
1
1
  import chalk from 'chalk';
2
2
  import { loadConfig } from './config/loader.js';
3
+ import { CLI_VERSION } from './lib/version.js';
3
4
  function compareVersions(a, b) {
4
5
  const pa = a.split('.').map(Number);
5
6
  const pb = b.split('.').map(Number);
@@ -16,7 +17,7 @@ export async function checkForUpgrade() {
16
17
  try {
17
18
  const r = await fetch(`${cfg.proxy_url}/v1/skills/abap-radar`, { method: 'HEAD', signal: AbortSignal.timeout(3000) });
18
19
  const minCli = r.headers.get('x-skill-min-cli-version');
19
- const current = process.env.npm_package_version ?? '0.5.0';
20
+ const current = CLI_VERSION;
20
21
  if (minCli && compareVersions(current, minCli) < 0) {
21
22
  console.log(chalk.yellow.bold(`\n⚠ Your cspeach (${current}) is older than the minimum required (${minCli}).`));
22
23
  console.log(chalk.yellow(` Run: cspeach --upgrade\n`));
package/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "@cspeach/cli",
3
- "version": "0.6.1",
3
+ "version": "0.6.2",
4
4
  "description": "CSPeach — AI-assisted ABAP development CLI. Direct SAP access, 33 skills, safety gates.",
5
5
  "keywords": [
6
6
  "abap",