@ryanfw/prompt-orchestration-pipeline 0.3.0 → 0.4.0

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": "@ryanfw/prompt-orchestration-pipeline",
3
- "version": "0.3.0",
3
+ "version": "0.4.0",
4
4
  "description": "A Prompt-orchestration pipeline (POP) is a framework for building, running, and experimenting with complex chains of LLM tasks.",
5
5
  "type": "module",
6
6
  "main": "src/ui/server.js",
@@ -26,6 +26,7 @@
26
26
  "ui": "NODE_ENV=development nodemon src/ui/server.js",
27
27
  "ui:dev": "vite",
28
28
  "ui:build": "vite build",
29
+ "prepack": "npm run ui:build",
29
30
  "ui:prod": "node src/ui/server.js",
30
31
  "demo:ui": "NODE_ENV=production PO_ROOT=demo node src/ui/server.js",
31
32
  "demo:orchestrator": "PO_ROOT=demo NODE_ENV=production node -e \"import('./src/core/orchestrator.js').then(m => m.startOrchestrator({ dataDir: process.env.PO_ROOT || 'demo' })).catch(err => { console.error(err); process.exit(1) })\"",
package/src/cli/index.js CHANGED
@@ -4,9 +4,14 @@ import { submitJobWithValidation } from "../api/index.js";
4
4
  import { PipelineOrchestrator } from "../api/index.js";
5
5
  import fs from "node:fs/promises";
6
6
  import path from "node:path";
7
+ import { fileURLToPath } from "node:url";
7
8
  import { spawn } from "node:child_process";
8
9
  import { updatePipelineJson } from "./update-pipeline-json.js";
9
10
 
11
+ // Derive package root for resolving internal paths regardless of host CWD
12
+ const currentFile = fileURLToPath(import.meta.url);
13
+ const PKG_ROOT = path.dirname(path.dirname(path.dirname(currentFile)));
14
+
10
15
  // Canonical stage names that must match src/core/task-runner.js
11
16
  const STAGE_NAMES = [
12
17
  "ingestion",
@@ -140,46 +145,29 @@ program
140
145
  });
141
146
 
142
147
  try {
143
- // Step d: Build UI once if dist/ doesn't exist
144
- const distPath = path.join(process.cwd(), "dist");
148
+ // Step d: Check for prebuilt UI assets
149
+ const distPath = path.join(PKG_ROOT, "src/ui/dist");
145
150
  try {
146
151
  await fs.access(distPath);
147
152
  console.log("UI build found, skipping build step");
148
153
  } catch {
149
- console.log("Building UI...");
150
- await new Promise((resolve, reject) => {
151
- const vitePath = path.resolve(
152
- process.cwd(),
153
- "node_modules/vite/bin/vite.js"
154
- );
155
- const buildChild = spawn("node", [vitePath, "build"], {
156
- stdio: "inherit",
157
- env: { ...process.env, NODE_ENV: "development" },
158
- });
159
-
160
- buildChild.on("exit", (code) => {
161
- if (code === 0) {
162
- console.log("UI build completed");
163
- resolve();
164
- } else {
165
- reject(new Error(`UI build failed with code ${code}`));
166
- }
167
- });
168
-
169
- buildChild.on("error", reject);
170
- });
154
+ console.error(
155
+ "UI assets missing. This indicates a source checkout. Run 'npm run ui:build' locally or install dev deps."
156
+ );
157
+ process.exit(1);
171
158
  }
172
159
 
173
160
  // Step e: Spawn UI server
174
161
  console.log("Starting UI server...");
175
- const uiServerPath = path.resolve(process.cwd(), "src/ui/server.js");
162
+ const uiServerPath = path.join(PKG_ROOT, "src/ui/server.js");
176
163
  uiChild = spawn("node", [uiServerPath], {
177
164
  stdio: "pipe",
178
165
  env: {
179
166
  ...process.env,
180
167
  NODE_ENV: "production",
181
168
  PO_ROOT: absoluteRoot,
182
- PO_UI_PORT: port,
169
+ PORT: port,
170
+ PO_UI_PORT: undefined, // Ensure PORT takes precedence
183
171
  },
184
172
  });
185
173
 
@@ -194,8 +182,8 @@ program
194
182
 
195
183
  // Step f: Spawn orchestrator
196
184
  console.log("Starting orchestrator...");
197
- const orchestratorPath = path.resolve(
198
- process.cwd(),
185
+ const orchestratorPath = path.join(
186
+ PKG_ROOT,
199
187
  "src/cli/run-orchestrator.js"
200
188
  );
201
189
  orchestratorChild = spawn("node", [orchestratorPath], {