toga-ai 1.0.12 → 1.0.13

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/package.json +1 -1
  2. package/scripts/install.js +45 -2
package/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "toga-ai",
3
- "version": "1.0.12",
3
+ "version": "1.0.13",
4
4
  "description": "TOGA Technology Team Claude Knowledge System — shared AI coding harness with skills, knowledge base CLI, and project installer for Claude Code.",
5
5
  "keywords": [
6
6
  "claude",
@@ -94,6 +94,39 @@ function saveRepoPathCache(repoDir) {
94
94
  } catch (e) { /* non-fatal */ }
95
95
  }
96
96
 
97
+ /**
98
+ * Initialize a local git repo at defaultDir seeded from the npm bundle.
99
+ * Used when remote is inaccessible (private repo, no auth) but the machine
100
+ * has git — gives /capture a pushable local repo using stored git credentials.
101
+ */
102
+ function initLocalRepo(defaultDir) {
103
+ const gitCheck = spawnSync('git', ['--version'], { stdio: 'pipe', shell: false });
104
+ if (gitCheck.status !== 0 || gitCheck.error) return null;
105
+
106
+ try {
107
+ fs.mkdirSync(defaultDir, { recursive: true });
108
+
109
+ // Already a git repo — leave it alone
110
+ const isRepo = spawnSync('git', ['-C', defaultDir, 'rev-parse', '--git-dir'], { stdio: 'pipe' });
111
+ if (isRepo.status === 0) return defaultDir;
112
+
113
+ // Init and wire remote so /capture can push
114
+ if (spawnSync('git', ['init', defaultDir], { stdio: 'pipe' }).status !== 0) return null;
115
+ spawnSync('git', ['-C', defaultDir, 'remote', 'add', 'origin', REPO_URL], { stdio: 'pipe' });
116
+
117
+ // Seed knowledge from bundle so capture has something to commit on top of
118
+ const src = path.join(PACKAGE_ROOT, 'knowledge');
119
+ const dest = path.join(defaultDir, 'knowledge');
120
+ if (fs.existsSync(src)) copyDir(src, dest);
121
+
122
+ const env = { ...process.env, GIT_AUTHOR_NAME: 'toga-ai', GIT_AUTHOR_EMAIL: 'toga-ai@local', GIT_COMMITTER_NAME: 'toga-ai', GIT_COMMITTER_EMAIL: 'toga-ai@local' };
123
+ spawnSync('git', ['-C', defaultDir, 'add', 'knowledge/'], { stdio: 'pipe' });
124
+ spawnSync('git', ['-C', defaultDir, 'commit', '-m', 'chore: seed knowledge from toga-ai bundle'], { stdio: 'pipe', env });
125
+
126
+ return defaultDir;
127
+ } catch (e) { return null; }
128
+ }
129
+
97
130
  /**
98
131
  * Try git clone. Only called when no existing clone found and not --post-install.
99
132
  * Access check is done here before cloning — if it fails, return null (use bundle).
@@ -481,7 +514,12 @@ function main() {
481
514
  let repoDir = findExistingClone();
482
515
 
483
516
  if (!repoDir && !isPostInstall) {
484
- repoDir = tryCloneRepo(path.join(os.homedir(), 'toga-tech'));
517
+ const togaTechDir = path.join(os.homedir(), 'toga-tech');
518
+ // Try full clone first (works if repo is public or user is authenticated)
519
+ repoDir = tryCloneRepo(togaTechDir);
520
+ // Fall back: init a local git repo seeded from bundle (private repo / no auth)
521
+ // This gives /capture a pushable git repo using the machine's stored credentials
522
+ if (!repoDir) repoDir = initLocalRepo(togaTechDir);
485
523
  }
486
524
 
487
525
  if (repoDir) {
@@ -504,7 +542,12 @@ function main() {
504
542
 
505
543
  console.log(' Harness: npm bundle v' + bundleVersion);
506
544
  if (knowledgeDir !== PACKAGE_ROOT) {
507
- console.log(' Knowledge: git repo' + (gitUpdateLine ? ' (' + gitUpdateLine.replace('git update: ', '') + ')' : ' (cached)'));
545
+ const isInitOnly = (() => { try { const r = spawnSync('git', ['-C', knowledgeDir, 'remote', 'get-url', 'origin'], { stdio: 'pipe' }); return r.status === 0 && !gitUpdateLine; } catch { return false; } })();
546
+ if (gitUpdateLine) {
547
+ console.log(' Knowledge: git repo (' + gitUpdateLine.replace('git update: ', '') + ')');
548
+ } else {
549
+ console.log(' Knowledge: git repo at ' + knowledgeDir + ' (ready for /capture push)');
550
+ }
508
551
  }
509
552
  if (gitUpdateLine && knowledgeDir === PACKAGE_ROOT) {
510
553
  console.log(' ↳ ' + gitUpdateLine);