@scemoon/cdh 1.0.5 → 1.0.6

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/cdh/cli.py CHANGED
@@ -14,6 +14,7 @@ from cdh.scaffold import (
14
14
  from onecode.cli import cli as onecode_cli
15
15
  from onecode.cli import setup_logging
16
16
  from onecode.config import ensure_dirs, load_config, save_config
17
+ from onecode import __version__ as _VERSION
17
18
 
18
19
 
19
20
  _CDH_DIR = Path.home() / ".cdh"
@@ -26,6 +27,7 @@ Usage:
26
27
  cdh onecode <sub> onecode CLI surface (config / codebase / skill / mcp / help)
27
28
  cdh project Project management
28
29
  cdh session list|load Session management
30
+ cdh uninstall Remove ~/.cdh/ global state
29
31
  cdh version Show version information
30
32
 
31
33
  \b
@@ -43,7 +45,7 @@ Paths:
43
45
  short_help="Cloud Dev Harness - AI agent framework with TUI.",
44
46
  epilog=_COMMON_HELP,
45
47
  )
46
- @click.version_option(version="1.0.0", prog_name="cdh")
48
+ @click.version_option(version=_VERSION, prog_name="cdh")
47
49
  @click.pass_context
48
50
  def cli(ctx):
49
51
  """
@@ -737,6 +739,53 @@ def help_cmd(command):
737
739
 
738
740
  # --- version command ---
739
741
 
742
+ @cli.command(short_help="Remove ~/.cdh/ global state")
743
+ def uninstall():
744
+ """Remove CDH global state (~/.cdh/) and Python environment.
745
+
746
+ \b
747
+ After running this, uninstall the package itself:
748
+ pip uninstall cloud-dev-harness (if installed via pip)
749
+ pnpm remove -g @scemoon/cdh (if installed via pnpm)
750
+ npm uninstall -g @scemoon/cdh (if installed via npm)
751
+
752
+ \b
753
+ Also check your shell config (~/.zshrc, ~/.bashrc, etc.) for
754
+ PATH entries pointing to ~/.cdh/python/bin and remove them.
755
+ """
756
+ import shutil
757
+
758
+ cdh_dir = Path.home() / ".cdh"
759
+
760
+ removed_anything = False
761
+
762
+ python_dir = cdh_dir / "python"
763
+ if python_dir.exists():
764
+ click.echo(f"Removing Python environment at {python_dir}...")
765
+ shutil.rmtree(python_dir, ignore_errors=True)
766
+ removed_anything = True
767
+
768
+ if cdh_dir.exists():
769
+ click.echo(f"Removing global state at {cdh_dir}...")
770
+ shutil.rmtree(cdh_dir, ignore_errors=True)
771
+ removed_anything = True
772
+
773
+ if not removed_anything:
774
+ click.echo("Nothing to remove (~/.cdh/ not found).")
775
+ else:
776
+ click.echo("")
777
+ click.echo("Cleanup complete. To finish uninstall:")
778
+ click.echo("")
779
+ click.echo(" 1. Remove the package:")
780
+ click.echo(" pip uninstall cloud-dev-harness")
781
+ click.echo(" # or: pnpm remove -g @scemoon/cdh")
782
+ click.echo(" # or: npm uninstall -g @scemoon/cdh")
783
+ click.echo("")
784
+ click.echo(" 2. Check your shell config (~/.zshrc, ~/.bashrc, etc.) for:")
785
+ click.echo(' export PATH="$HOME/.cdh/python/bin:$PATH"')
786
+ click.echo(" Remove this line if present.")
787
+
788
+
740
789
  @cli.command(short_help="Show version info")
741
790
  def version():
742
791
  """Show CDH version and build information."""
@@ -1 +1 @@
1
- __version__ = "1.0.5"
1
+ __version__ = "1.0.6"
package/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "@scemoon/cdh",
3
- "version": "1.0.5",
3
+ "version": "1.0.6",
4
4
  "description": "Cloud Dev Harness - cloud-native development Agent framework",
5
5
  "keywords": ["ai", "agent", "cloud", "development", "cli", "tui"],
6
6
  "license": "MIT",
package/run.js CHANGED
@@ -1,6 +1,8 @@
1
1
  #!/usr/bin/env node
2
- const { spawn, execSync } = require('child_process');
2
+ const { spawn, spawnSync, execSync } = require('child_process');
3
3
  const path = require('path');
4
+ const fs = require('fs');
5
+ const os = require('os');
4
6
  const pkg = require('./package.json');
5
7
 
6
8
  function exec(cmd, opts = {}) {
@@ -11,6 +13,12 @@ function exec(cmd, opts = {}) {
11
13
  }
12
14
  }
13
15
 
16
+ function execVerbose(cmd, label) {
17
+ if (label) console.log(`cdh: ${label}`);
18
+ const r = spawnSync(cmd, { shell: true, stdio: 'inherit' });
19
+ return { ok: r.status === 0 };
20
+ }
21
+
14
22
  function checkPython() {
15
23
  const script = 'import sys; v=sys.version_info; print(f"{v.major}.{v.minor}")';
16
24
  const r = exec(`python3 -c "${script}"`);
@@ -32,11 +40,49 @@ function checkCdhInstalled(pythonCmd) {
32
40
  return exec(`${pythonCmd} -m pip show cloud-dev-harness 2>/dev/null`).ok;
33
41
  }
34
42
 
43
+ function uninstallCmd() {
44
+ const cdhDir = path.join(os.homedir(), '.cdh');
45
+ const pythonDir = path.join(cdhDir, 'python');
46
+
47
+ console.log('cdh: Uninstalling Cloud Dev Harness...');
48
+ console.log('');
49
+
50
+ if (fs.existsSync(pythonDir)) {
51
+ console.log(`cdh: Removing Python environment at ${pythonDir}...`);
52
+ fs.rmSync(pythonDir, { recursive: true, force: true });
53
+ }
54
+
55
+ if (fs.existsSync(cdhDir)) {
56
+ console.log(`cdh: Removing global state at ${cdhDir}...`);
57
+ fs.rmSync(cdhDir, { recursive: true, force: true });
58
+ }
59
+
60
+ console.log('');
61
+ console.log('cdh: Cleanup complete. To finish uninstall:');
62
+ console.log('');
63
+ console.log(' 1. Remove the npm package:');
64
+ console.log(' pnpm remove -g @scemoon/cdh');
65
+ console.log(' # or: npm uninstall -g @scemoon/cdh');
66
+ console.log('');
67
+ console.log(' 2. Check your shell config (~/.zshrc, ~/.bashrc, etc.) for:');
68
+ console.log(' export PATH="$HOME/.cdh/python/bin:$PATH"');
69
+ console.log(' Remove this line if present.');
70
+ console.log('');
71
+
72
+ process.exit(0);
73
+ }
74
+
35
75
  function run(pythonModule) {
36
76
  const PKG_DIR = __dirname;
37
- const PYTHON_ENV_DIR = path.join(require('os').homedir(), '.cdh', 'python');
77
+ const PYTHON_ENV_DIR = path.join(os.homedir(), '.cdh', 'python');
38
78
 
39
79
  const args = process.argv.slice(2);
80
+
81
+ if (args[0] === 'uninstall') {
82
+ uninstallCmd();
83
+ return;
84
+ }
85
+
40
86
  if (args.includes('--version') || args.includes('-v')) {
41
87
  console.log(pkg.version);
42
88
  process.exit(0);
@@ -49,13 +95,19 @@ function run(pythonModule) {
49
95
  console.error(`cdh: Python ${py.version || 'not found'}, version 3.14+ is required.`);
50
96
 
51
97
  if (checkUv()) {
52
- console.log('cdh: Creating Python environment with uv...');
53
- exec(`uv venv "${PYTHON_ENV_DIR}"`);
98
+ if (fs.existsSync(PYTHON_ENV_DIR)) {
99
+ console.log('cdh: Python environment exists, reusing...');
100
+ } else {
101
+ const rv = execVerbose(`uv venv "${PYTHON_ENV_DIR}"`, 'Creating Python environment with uv...');
102
+ if (!rv.ok) {
103
+ console.error('cdh: Failed to create Python environment.');
104
+ process.exit(1);
105
+ }
106
+ }
54
107
  const venvPython = path.join(PYTHON_ENV_DIR, 'bin', 'python');
55
- console.log('cdh: Installing cloud-dev-harness...');
56
- const r = exec(`uv pip install "${PKG_DIR}" --python "${venvPython}"`);
57
- if (!r.ok) {
58
- console.error('cdh: Install failed:', r.out);
108
+ const ri = execVerbose(`uv pip install "${PKG_DIR}" --python "${venvPython}"`, 'Installing cloud-dev-harness...');
109
+ if (!ri.ok) {
110
+ console.error('cdh: Install failed.');
59
111
  process.exit(1);
60
112
  }
61
113
  if (isPostinstall) {
@@ -72,12 +124,14 @@ function run(pythonModule) {
72
124
  }
73
125
 
74
126
  if (!checkCdhInstalled(py.pythonCmd)) {
75
- console.log('cdh: Installing cloud-dev-harness...');
76
- const r = checkUv()
77
- ? exec(`uv pip install "${PKG_DIR}" --python "${py.pythonCmd}"`)
78
- : exec(`${py.pythonCmd} -m pip install "${PKG_DIR}"`);
79
- if (!r.ok) {
80
- console.error('cdh: Install failed:', r.out);
127
+ let ri;
128
+ if (checkUv()) {
129
+ ri = execVerbose(`uv pip install "${PKG_DIR}" --python "${py.pythonCmd}"`, 'Installing cloud-dev-harness...');
130
+ } else {
131
+ ri = execVerbose(`${py.pythonCmd} -m pip install "${PKG_DIR}"`, 'Installing cloud-dev-harness...');
132
+ }
133
+ if (!ri.ok) {
134
+ console.error('cdh: Install failed.');
81
135
  process.exit(1);
82
136
  }
83
137
  }