@worca/ui 0.1.0-rc.3 → 0.1.0-rc.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.
- package/README.md +46 -0
- package/app/main.bundle.js +212 -206
- package/app/main.bundle.js.map +3 -3
- package/bin/worca-ui.js +52 -11
- package/package.json +1 -1
- package/server/index.js +2 -1
- package/server/preferences.js +1 -1
- package/server/project-routes.js +9 -5
package/bin/worca-ui.js
CHANGED
|
@@ -20,6 +20,11 @@ import {
|
|
|
20
20
|
writeProject,
|
|
21
21
|
} from '../server/project-registry.js';
|
|
22
22
|
|
|
23
|
+
const __dirname = dirname(fileURLToPath(import.meta.url));
|
|
24
|
+
const pkg = JSON.parse(
|
|
25
|
+
readFileSync(join(__dirname, '..', 'package.json'), 'utf8'),
|
|
26
|
+
);
|
|
27
|
+
|
|
23
28
|
function findProjectRoot(startDir) {
|
|
24
29
|
let dir = startDir;
|
|
25
30
|
while (dir !== dirname(dir)) {
|
|
@@ -30,12 +35,7 @@ function findProjectRoot(startDir) {
|
|
|
30
35
|
}
|
|
31
36
|
|
|
32
37
|
const PREFS_DIR = join(homedir(), '.worca');
|
|
33
|
-
const SERVER_SCRIPT = join(
|
|
34
|
-
dirname(fileURLToPath(import.meta.url)),
|
|
35
|
-
'..',
|
|
36
|
-
'server',
|
|
37
|
-
'index.js',
|
|
38
|
-
);
|
|
38
|
+
const SERVER_SCRIPT = join(__dirname, '..', 'server', 'index.js');
|
|
39
39
|
|
|
40
40
|
/** Exported for testing */
|
|
41
41
|
export function parseArgs(argv) {
|
|
@@ -44,7 +44,7 @@ export function parseArgs(argv) {
|
|
|
44
44
|
port: 3400,
|
|
45
45
|
host: '127.0.0.1',
|
|
46
46
|
open: false,
|
|
47
|
-
global:
|
|
47
|
+
global: true,
|
|
48
48
|
// projects sub-command
|
|
49
49
|
subAction: null, // 'list' | 'add' | 'remove'
|
|
50
50
|
projectPath: null,
|
|
@@ -57,7 +57,11 @@ export function parseArgs(argv) {
|
|
|
57
57
|
};
|
|
58
58
|
for (let i = 2; i < argv.length; i++) {
|
|
59
59
|
const arg = argv[i];
|
|
60
|
-
if (
|
|
60
|
+
if (arg === '--version' || arg === '-v') {
|
|
61
|
+
args.command = 'version';
|
|
62
|
+
} else if (arg === '--help' || arg === '-h') {
|
|
63
|
+
args.command = 'help';
|
|
64
|
+
} else if (
|
|
61
65
|
['start', 'stop', 'restart', 'status', 'projects', 'migrate'].includes(
|
|
62
66
|
arg,
|
|
63
67
|
)
|
|
@@ -86,6 +90,11 @@ export function parseArgs(argv) {
|
|
|
86
90
|
args.open = true;
|
|
87
91
|
} else if (arg === '--global') {
|
|
88
92
|
args.global = true;
|
|
93
|
+
} else if (arg === '--project') {
|
|
94
|
+
args.global = false;
|
|
95
|
+
if (argv[i + 1] && !argv[i + 1].startsWith('-')) {
|
|
96
|
+
args.projectPath = argv[++i];
|
|
97
|
+
}
|
|
89
98
|
} else if (arg === '--scan' && argv[i + 1]) {
|
|
90
99
|
args.scanDir = argv[++i];
|
|
91
100
|
} else if (arg === '--dry-run') {
|
|
@@ -488,6 +497,34 @@ function migrateStatus() {
|
|
|
488
497
|
}
|
|
489
498
|
}
|
|
490
499
|
|
|
500
|
+
function printHelp() {
|
|
501
|
+
console.log(`worca-ui v${pkg.version} — Pipeline monitoring UI for worca-cc
|
|
502
|
+
|
|
503
|
+
Usage: worca-ui <command> [options]
|
|
504
|
+
|
|
505
|
+
Commands:
|
|
506
|
+
start Start the server (default)
|
|
507
|
+
stop Stop the running server
|
|
508
|
+
restart Restart the server
|
|
509
|
+
status Show server status
|
|
510
|
+
projects list List registered projects
|
|
511
|
+
projects add <path> [--name] Register a project
|
|
512
|
+
projects remove <name> Unregister a project
|
|
513
|
+
migrate --scan <dir> Scan directory for projects to register
|
|
514
|
+
migrate --add <path> Register a single project
|
|
515
|
+
migrate --status Show registration health
|
|
516
|
+
|
|
517
|
+
Options:
|
|
518
|
+
--port <N> Server port (default: 3400, env: PORT)
|
|
519
|
+
--host <addr> Bind address (default: 127.0.0.1, env: HOST)
|
|
520
|
+
--global Multi-project mode (default)
|
|
521
|
+
--project [path] Single-project mode, optionally scoped to path
|
|
522
|
+
--open Open browser after start
|
|
523
|
+
--dry-run Preview migrate --scan without registering
|
|
524
|
+
-v, --version Show version
|
|
525
|
+
-h, --help Show this help`);
|
|
526
|
+
}
|
|
527
|
+
|
|
491
528
|
const args = parseArgs(process.argv);
|
|
492
529
|
switch (args.command) {
|
|
493
530
|
case 'start':
|
|
@@ -533,8 +570,12 @@ switch (args.command) {
|
|
|
533
570
|
);
|
|
534
571
|
}
|
|
535
572
|
break;
|
|
573
|
+
case 'version':
|
|
574
|
+
console.log(pkg.version);
|
|
575
|
+
break;
|
|
576
|
+
case 'help':
|
|
577
|
+
printHelp();
|
|
578
|
+
break;
|
|
536
579
|
default:
|
|
537
|
-
|
|
538
|
-
'Usage: worca-ui [start|stop|restart|status|projects|migrate] [--port N] [--host H] [--open] [--global]',
|
|
539
|
-
);
|
|
580
|
+
printHelp();
|
|
540
581
|
}
|
package/package.json
CHANGED
package/server/index.js
CHANGED
|
@@ -9,13 +9,14 @@ import { attachWsServer } from './ws.js';
|
|
|
9
9
|
// Parse argv
|
|
10
10
|
let port = parseInt(process.env.PORT, 10) || 3400;
|
|
11
11
|
let host = process.env.HOST || '127.0.0.1';
|
|
12
|
-
let isGlobal =
|
|
12
|
+
let isGlobal = true;
|
|
13
13
|
for (let i = 0; i < process.argv.length; i++) {
|
|
14
14
|
if (process.argv[i] === '--port' && process.argv[i + 1])
|
|
15
15
|
port = parseInt(process.argv[++i], 10);
|
|
16
16
|
if (process.argv[i] === '--host' && process.argv[i + 1])
|
|
17
17
|
host = process.argv[++i];
|
|
18
18
|
if (process.argv[i] === '--global') isGlobal = true;
|
|
19
|
+
if (process.argv[i] === '--project') isGlobal = false;
|
|
19
20
|
}
|
|
20
21
|
|
|
21
22
|
// Resolve project root: walk up from cwd until we find .claude/settings.json
|
package/server/preferences.js
CHANGED
package/server/project-routes.js
CHANGED
|
@@ -16,9 +16,11 @@ import {
|
|
|
16
16
|
unlinkSync,
|
|
17
17
|
writeFileSync,
|
|
18
18
|
} from 'node:fs';
|
|
19
|
+
import { homedir } from 'node:os';
|
|
19
20
|
import { dirname, join } from 'node:path';
|
|
20
21
|
import { Router } from 'express';
|
|
21
22
|
import { dbExists, getIssue, listIssues } from './beads-reader.js';
|
|
23
|
+
import { readPreferences } from './preferences.js';
|
|
22
24
|
import { ProcessManager } from './process-manager.js';
|
|
23
25
|
import {
|
|
24
26
|
readProjects,
|
|
@@ -1102,14 +1104,16 @@ export function createProjectScopedRoutes() {
|
|
|
1102
1104
|
|
|
1103
1105
|
// POST /api/projects/:projectId/worca-setup — install or update worca
|
|
1104
1106
|
router.post('/worca-setup', (req, res) => {
|
|
1105
|
-
const {
|
|
1107
|
+
const { projectRoot } = req.project;
|
|
1106
1108
|
let source = req.body?.source;
|
|
1107
1109
|
|
|
1108
|
-
// Fall back to
|
|
1109
|
-
if (!source
|
|
1110
|
+
// Fall back to source_repo from global preferences
|
|
1111
|
+
if (!source) {
|
|
1110
1112
|
try {
|
|
1111
|
-
const
|
|
1112
|
-
|
|
1113
|
+
const prefs = readPreferences(
|
|
1114
|
+
join(homedir(), '.worca', 'preferences.json'),
|
|
1115
|
+
);
|
|
1116
|
+
source = prefs.source_repo || undefined;
|
|
1113
1117
|
} catch {
|
|
1114
1118
|
/* ignore — worca init will use its own resolution chain */
|
|
1115
1119
|
}
|