tycono 0.1.85 → 0.1.87

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/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "tycono",
3
- "version": "0.1.85",
3
+ "version": "0.1.87",
4
4
  "description": "Build an AI company. Watch them work.",
5
5
  "type": "module",
6
6
  "bin": {
@@ -51,9 +51,9 @@ saveRouter.get('/history', (req: Request, res: Response, next: NextFunction) =>
51
51
  });
52
52
 
53
53
  // POST /api/save/init — initialize git repo
54
- saveRouter.post('/init', (_req: Request, res: Response, next: NextFunction) => {
54
+ saveRouter.post('/init', (req: Request, res: Response, next: NextFunction) => {
55
55
  try {
56
- const result = gitInit(COMPANY_ROOT);
56
+ const result = gitInit(COMPANY_ROOT, getRepo(req));
57
57
  if (!result.ok) {
58
58
  res.status(500).json({ error: result.message });
59
59
  return;
@@ -52,29 +52,28 @@ function configPath(companyRoot: string): string {
52
52
  */
53
53
  export function resolveCodeRoot(companyRoot: string): string {
54
54
  const config = readConfig(companyRoot);
55
- if (config.codeRoot) return config.codeRoot;
56
-
57
- // Auto-generate: ../{folder-name}-code/
58
- const dirName = path.basename(companyRoot);
59
- const autoCodeRoot = path.join(path.dirname(companyRoot), `${dirName}-code`);
60
-
61
- if (!fs.existsSync(autoCodeRoot)) {
62
- fs.mkdirSync(autoCodeRoot, { recursive: true });
63
- }
64
-
65
- // Auto-init git if not already a repo
66
- const gitDir = path.join(autoCodeRoot, '.git');
67
- if (!fs.existsSync(gitDir)) {
55
+ const codeRoot = config.codeRoot ?? (() => {
56
+ // Auto-generate: ../{folder-name}-code/
57
+ const dirName = path.basename(companyRoot);
58
+ const auto = path.join(path.dirname(companyRoot), `${dirName}-code`);
59
+ if (!fs.existsSync(auto)) {
60
+ fs.mkdirSync(auto, { recursive: true });
61
+ }
62
+ // Persist so it's stable across restarts
63
+ writeConfig(companyRoot, { ...config, codeRoot: auto });
64
+ return auto;
65
+ })();
66
+
67
+ // Auto-init git if not already a repo (even if codeRoot was already configured)
68
+ const gitDir = path.join(codeRoot, '.git');
69
+ if (fs.existsSync(codeRoot) && !fs.existsSync(gitDir)) {
68
70
  try {
69
- execSync('git init', { cwd: autoCodeRoot, stdio: 'pipe' });
70
- execSync('git commit --allow-empty -m "Initial commit by Tycono"', { cwd: autoCodeRoot, stdio: 'pipe' });
71
+ execSync('git init', { cwd: codeRoot, stdio: 'pipe' });
72
+ execSync('git commit --allow-empty -m "Initial commit by Tycono"', { cwd: codeRoot, stdio: 'pipe' });
71
73
  } catch { /* ignore — git may not be installed */ }
72
74
  }
73
75
 
74
- // Persist so it's stable across restarts
75
- writeConfig(companyRoot, { ...config, codeRoot: autoCodeRoot });
76
-
77
- return autoCodeRoot;
76
+ return codeRoot;
78
77
  }
79
78
 
80
79
  /** Read config from .tycono/config.json. Returns defaults if missing. */