tower-studio 0.1.6 → 0.1.8

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/tower.mjs +22 -23
  2. package/package.json +2 -2
package/bin/tower.mjs CHANGED
@@ -16,8 +16,10 @@
16
16
 
17
17
  import { existsSync, readFileSync, mkdirSync } from "fs";
18
18
  import { join, dirname, resolve } from "path";
19
- import { execSync, spawn } from "child_process";
19
+ import { execSync } from "child_process";
20
+ import { createServer } from "http";
20
21
  import { fileURLToPath } from "url";
22
+ import { parseArgs } from "node:util";
21
23
  import { homedir } from "os";
22
24
 
23
25
  const __filename = fileURLToPath(import.meta.url);
@@ -30,9 +32,10 @@ const DB_DIR = join(TOWER_DIR, "database");
30
32
  const DB_PATH = join(DB_DIR, "tower.db");
31
33
  const DB_URL = `file:${DB_PATH}`;
32
34
 
33
- // ─── Parse CLI args ───
34
- import { parseArgs } from "node:util";
35
+ // Set DATABASE_URL before anything else
36
+ process.env.DATABASE_URL = DB_URL;
35
37
 
38
+ // ─── Parse CLI args ───
36
39
  const { values: flags, positionals } = parseArgs({
37
40
  args: process.argv.slice(2),
38
41
  options: {
@@ -45,8 +48,7 @@ const { values: flags, positionals } = parseArgs({
45
48
  });
46
49
 
47
50
  const command = positionals[0] ?? "start";
48
-
49
- const PORT = flags.port ?? process.env.PORT ?? "3000";
51
+ const PORT = parseInt(flags.port ?? process.env.PORT ?? "3000", 10);
50
52
  const HOST = flags.host ?? "0.0.0.0";
51
53
 
52
54
  // ─── Help ───
@@ -83,17 +85,12 @@ function logError(msg) {
83
85
  console.error(`\x1b[31m[tower]\x1b[0m ${msg}`);
84
86
  }
85
87
 
86
- function childEnv() {
87
- return { ...process.env, DATABASE_URL: DB_URL };
88
- }
89
-
90
- function run(cmd, opts = {}) {
88
+ function run(cmd) {
91
89
  try {
92
90
  execSync(cmd, {
93
91
  cwd: PROJECT_ROOT,
94
92
  stdio: "inherit",
95
- env: childEnv(),
96
- ...opts,
93
+ env: { ...process.env, DATABASE_URL: DB_URL },
97
94
  });
98
95
  } catch {
99
96
  logError(`Command failed: ${cmd}`);
@@ -118,9 +115,6 @@ async function initDatabase() {
118
115
  ensureDirs();
119
116
  log(`Data directory: ${TOWER_DIR}`);
120
117
 
121
- log("Generating Prisma client...");
122
- run("npx prisma generate");
123
-
124
118
  log("Syncing database schema...");
125
119
  run("npx prisma db push --skip-generate");
126
120
 
@@ -144,16 +138,21 @@ async function cmdStart() {
144
138
  await initDatabase();
145
139
  }
146
140
 
147
- log(`Starting Tower on http://${HOST === "0.0.0.0" ? "localhost" : HOST}:${PORT}`);
148
- const child = spawn("npx", ["next", "start", "-p", PORT, "-H", HOST], {
149
- cwd: PROJECT_ROOT,
150
- stdio: "inherit",
151
- env: childEnv(),
141
+ // Use Next.js programmatic API (same approach as nextra, tldraw)
142
+ const next = (await import("next")).default;
143
+ const app = next({
144
+ dev: false,
145
+ dir: PROJECT_ROOT,
146
+ quiet: false,
152
147
  });
153
148
 
154
- child.on("exit", (code) => process.exit(code ?? 0));
155
- process.on("SIGINT", () => child.kill("SIGINT"));
156
- process.on("SIGTERM", () => child.kill("SIGTERM"));
149
+ const handle = app.getRequestHandler();
150
+ await app.prepare();
151
+
152
+ const server = createServer(handle);
153
+ server.listen(PORT, HOST, () => {
154
+ log(`Tower running on http://${HOST === "0.0.0.0" ? "localhost" : HOST}:${PORT}`);
155
+ });
157
156
  }
158
157
 
159
158
  // ─── Dispatch ───
package/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "tower-studio",
3
- "version": "0.1.6",
3
+ "version": "0.1.8",
4
4
  "description": "AI Task Orchestration Platform — Kanban + Terminal + Code Editor + MCP",
5
5
  "bin": {
6
6
  "tower": "bin/tower.mjs"
@@ -40,7 +40,7 @@
40
40
  "test:e2e": "NO_PROXY=localhost,127.0.0.1 no_proxy=localhost,127.0.0.1 playwright test",
41
41
  "changelog": "conventional-changelog -p angular -i CHANGELOG.md -s",
42
42
  "mcp": "tsx src/mcp/index.ts",
43
- "postinstall": "npx prisma generate && node scripts/copy-monaco.js && node scripts/link-prisma.js"
43
+ "postinstall": "node scripts/copy-monaco.js && node scripts/link-prisma.js"
44
44
  },
45
45
  "pnpm": {
46
46
  "onlyBuiltDependencies": [