clementine-agent 1.0.79 → 1.0.80

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/dist/cli/index.js +63 -14
  2. package/package.json +1 -1
package/dist/cli/index.js CHANGED
@@ -1074,10 +1074,16 @@ function cmdTools() {
1074
1074
  }
1075
1075
  // ── Program ──────────────────────────────────────────────────────────
1076
1076
  const program = new Command();
1077
+ let pkgVersion = '0.0.0';
1078
+ try {
1079
+ const pkgRaw = readFileSync(path.join(PACKAGE_ROOT, 'package.json'), 'utf-8');
1080
+ pkgVersion = String(JSON.parse(pkgRaw).version ?? '0.0.0');
1081
+ }
1082
+ catch { /* fall back to placeholder */ }
1077
1083
  program
1078
1084
  .name('clementine')
1079
1085
  .description('Clementine Personal AI Assistant')
1080
- .version('1.0.0');
1086
+ .version(pkgVersion);
1081
1087
  program
1082
1088
  .command('launch')
1083
1089
  .description('Start the assistant (daemon by default)')
@@ -1609,11 +1615,46 @@ async function cmdUpdate(options) {
1609
1615
  console.log();
1610
1616
  console.log(` ${DIM}Updating ${getAssistantName()}...${RESET}`);
1611
1617
  console.log();
1612
- // 1. Check we're in a git repo
1613
- if (!existsSync(path.join(PACKAGE_ROOT, '.git'))) {
1614
- console.error(` ${RED}FAIL${RESET} Package root is not a git repository: ${PACKAGE_ROOT}`);
1615
- console.error(' Update requires a git-cloned installation.');
1616
- process.exit(1);
1618
+ // 1. Detect install flavor. Two valid paths:
1619
+ // - git-clone install (PACKAGE_ROOT has .git) → pull + rebuild path below
1620
+ // - npm-global install (no .git) delegate to `npm install -g clementine-agent@latest`
1621
+ const isGitInstall = existsSync(path.join(PACKAGE_ROOT, '.git'));
1622
+ if (!isGitInstall) {
1623
+ if (options.dryRun) {
1624
+ console.log(` ${DIM}[dry-run]${RESET} Would run: npm install -g clementine-agent@latest`);
1625
+ if (options.restart)
1626
+ console.log(` ${DIM}[dry-run]${RESET} Would restart the daemon`);
1627
+ return;
1628
+ }
1629
+ console.log(` ${DIM}npm-global install detected at ${PACKAGE_ROOT}${RESET}`);
1630
+ console.log(` ${DIM}Running: npm install -g clementine-agent@latest${RESET}`);
1631
+ console.log();
1632
+ try {
1633
+ execSync('npm install -g clementine-agent@latest', { stdio: 'inherit' });
1634
+ console.log();
1635
+ console.log(` ${GREEN}OK${RESET} Updated via npm`);
1636
+ }
1637
+ catch (err) {
1638
+ console.error(` ${RED}FAIL${RESET} npm update failed: ${String(err).slice(0, 200)}`);
1639
+ console.error(` ${YELLOW}Hint${RESET} If you see EACCES, see README "Troubleshooting" for npm prefix setup.`);
1640
+ process.exit(1);
1641
+ }
1642
+ if (options.restart) {
1643
+ try {
1644
+ console.log(` ${DIM}Restarting daemon...${RESET}`);
1645
+ execSync('clementine restart', { stdio: 'inherit' });
1646
+ console.log(` ${GREEN}OK${RESET} Daemon restarted`);
1647
+ }
1648
+ catch (err) {
1649
+ console.error(` ${YELLOW}WARN${RESET} Restart failed: ${String(err).slice(0, 200)}. Run \`clementine restart\` manually.`);
1650
+ }
1651
+ }
1652
+ else {
1653
+ console.log();
1654
+ console.log(` ${DIM}Restart your daemon to pick up the new code:${RESET}`);
1655
+ console.log(` clementine restart`);
1656
+ }
1657
+ return;
1617
1658
  }
1618
1659
  let step = 0;
1619
1660
  const S = () => `[${++step}]`;
@@ -1643,11 +1684,16 @@ async function cmdUpdate(options) {
1643
1684
  try {
1644
1685
  const status = execSync('git status --porcelain', { cwd: PACKAGE_ROOT, encoding: 'utf-8' }).trim();
1645
1686
  if (status) {
1646
- console.log(` ${S()} Stashing local changes...`);
1647
- const stashOut = execSync('git stash', { cwd: PACKAGE_ROOT, encoding: 'utf-8', stdio: ['pipe', 'pipe', 'pipe'] }).trim();
1648
- didStash = !stashOut.includes('No local changes');
1649
- if (didStash) {
1650
- console.log(` ${GREEN}OK${RESET} Stashed local changes`);
1687
+ if (options.dryRun) {
1688
+ console.log(` ${S()} Would stash local changes`);
1689
+ }
1690
+ else {
1691
+ console.log(` ${S()} Stashing local changes...`);
1692
+ const stashOut = execSync('git stash', { cwd: PACKAGE_ROOT, encoding: 'utf-8', stdio: ['pipe', 'pipe', 'pipe'] }).trim();
1693
+ didStash = !stashOut.includes('No local changes');
1694
+ if (didStash) {
1695
+ console.log(` ${GREEN}OK${RESET} Stashed local changes`);
1696
+ }
1651
1697
  }
1652
1698
  }
1653
1699
  }
@@ -1688,15 +1734,18 @@ async function cmdUpdate(options) {
1688
1734
  const pid = readPid();
1689
1735
  const wasRunning = pid && isProcessAlive(pid);
1690
1736
  if (wasRunning) {
1691
- console.log(` ${S()} Stopping daemon (PID ${pid})...`);
1692
- if (!options.dryRun) {
1737
+ if (options.dryRun) {
1738
+ console.log(` ${S()} Would stop daemon (PID ${pid})`);
1739
+ }
1740
+ else {
1741
+ console.log(` ${S()} Stopping daemon (PID ${pid})...`);
1693
1742
  stopDaemon(pid);
1694
1743
  try {
1695
1744
  unlinkSync(getPidFilePath());
1696
1745
  }
1697
1746
  catch { /* ignore */ }
1747
+ console.log(` ${GREEN}OK${RESET} Daemon stopped`);
1698
1748
  }
1699
- console.log(` ${GREEN}OK${RESET} Daemon stopped`);
1700
1749
  }
1701
1750
  // Helper: if update fails after stopping daemon, relaunch before exiting
1702
1751
  function failAndRestart(backupDir) {
package/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "clementine-agent",
3
- "version": "1.0.79",
3
+ "version": "1.0.80",
4
4
  "description": "Clementine — Personal AI Assistant (TypeScript)",
5
5
  "type": "module",
6
6
  "main": "dist/index.js",