@devobsessed/code-captain 0.0.3 → 0.0.5

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/bin/install.js +41 -5
  2. package/package.json +1 -1
package/bin/install.js CHANGED
@@ -15,11 +15,16 @@ const __dirname = dirname(__filename);
15
15
 
16
16
  class CodeCaptainInstaller {
17
17
  constructor() {
18
+ // Determine if we're running from npm package or development
19
+ const packageRoot = path.resolve(__dirname, '..');
20
+ const isNpmPackage = fs.existsSync(path.join(packageRoot, 'package.json'));
21
+
18
22
  this.config = {
19
23
  repoUrl: 'https://github.com/devobsessed/code-captain',
20
24
  baseUrl: 'https://raw.githubusercontent.com/devobsessed/code-captain/main',
21
25
  version: 'main',
22
- localSource: process.env.CC_LOCAL_SOURCE || null,
26
+ // Default to local source when running from npm package
27
+ localSource: process.env.CC_LOCAL_SOURCE || (isNpmPackage ? packageRoot : null),
23
28
  versionFile: '.code-captain/.version',
24
29
  manifestFile: '.code-captain/.manifest.json'
25
30
  };
@@ -128,7 +133,23 @@ class CodeCaptainInstaller {
128
133
  return [...new Set(installations)]; // Remove duplicates
129
134
  }
130
135
 
131
- // Calculate SHA256 hash of a local file
136
+ // Get the current package version
137
+ async getPackageVersion() {
138
+ try {
139
+ if (this.config.localSource) {
140
+ const packageJsonPath = path.join(this.config.localSource, 'package.json');
141
+ if (await fs.pathExists(packageJsonPath)) {
142
+ const packageJson = await fs.readJson(packageJsonPath);
143
+ return packageJson.version || 'unknown';
144
+ }
145
+ }
146
+ return 'unknown';
147
+ } catch (error) {
148
+ return 'unknown';
149
+ }
150
+ }
151
+
152
+ // Calculate SHA256 hash of a file
132
153
  async calculateFileHash(filePath) {
133
154
  try {
134
155
  const crypto = await import('crypto');
@@ -201,8 +222,15 @@ class CodeCaptainInstaller {
201
222
 
202
223
  if (!localManifest) {
203
224
  spinner.succeed('No previous manifest found - treating as fresh installation');
225
+
226
+ // Get proper version information for first install
227
+ const currentVersion = this.config.localSource ? await this.getPackageVersion() : 'unknown';
228
+ const availableVersion = remoteManifest.version;
229
+
204
230
  return {
205
231
  isFirstInstall: true,
232
+ localVersion: currentVersion,
233
+ remoteVersion: availableVersion,
206
234
  changes: [],
207
235
  newFiles: [],
208
236
  recommendations: ['Full installation recommended (no change tracking available)']
@@ -276,10 +304,14 @@ class CodeCaptainInstaller {
276
304
 
277
305
  spinner.succeed(`Found ${changes.length} updated files, ${newFiles.length} new files`);
278
306
 
307
+ // Get proper version information
308
+ const currentVersion = this.config.localSource ? await this.getPackageVersion() : 'unknown';
309
+ const availableVersion = remoteManifest.version;
310
+
279
311
  return {
280
312
  isFirstInstall: false,
281
- localVersion: localManifest.version,
282
- remoteVersion: remoteManifest.version,
313
+ localVersion: currentVersion,
314
+ remoteVersion: availableVersion,
283
315
  changes,
284
316
  newFiles,
285
317
  recommendations
@@ -1040,7 +1072,11 @@ class CodeCaptainInstaller {
1040
1072
  }
1041
1073
 
1042
1074
  // Run installer if called directly
1043
- if (import.meta.url === `file://${process.argv[1]}`) {
1075
+ const isMainModule = import.meta.url === `file://${process.argv[1]}` ||
1076
+ (process.argv[1] && process.argv[1].includes('code-captain')) ||
1077
+ process.argv[1] === undefined;
1078
+
1079
+ if (isMainModule) {
1044
1080
  const installer = new CodeCaptainInstaller();
1045
1081
  installer.run();
1046
1082
  }
package/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "@devobsessed/code-captain",
3
- "version": "0.0.3",
3
+ "version": "0.0.5",
4
4
  "description": "Unified AI Development Agent System with intelligent change detection",
5
5
  "type": "module",
6
6
  "bin": {