@shaifulshabuj-waymarks/cli 0.1.0 → 0.3.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/dist/commands/logs.js +1 -1
- package/dist/commands/start.js +54 -17
- package/dist/commands/status.js +66 -3
- package/dist/commands/stop.js +75 -0
- package/dist/index.js +5 -1
- package/package.json +2 -2
package/dist/commands/logs.js
CHANGED
|
@@ -37,7 +37,7 @@ async function run() {
|
|
|
37
37
|
rows = await res.json();
|
|
38
38
|
}
|
|
39
39
|
catch {
|
|
40
|
-
console.log('Waymark is not running. Start with:
|
|
40
|
+
console.log('Waymark is not running. Start with: npx @shaifulshabuj-waymarks/cli start');
|
|
41
41
|
return;
|
|
42
42
|
}
|
|
43
43
|
if (pendingOnly)
|
package/dist/commands/start.js
CHANGED
|
@@ -57,32 +57,69 @@ function openBrowser(url) {
|
|
|
57
57
|
// ignore — browser open is best-effort
|
|
58
58
|
}
|
|
59
59
|
}
|
|
60
|
+
function isAlive(pid) {
|
|
61
|
+
try {
|
|
62
|
+
process.kill(pid, 0);
|
|
63
|
+
return true;
|
|
64
|
+
}
|
|
65
|
+
catch {
|
|
66
|
+
return false;
|
|
67
|
+
}
|
|
68
|
+
}
|
|
60
69
|
function run() {
|
|
61
70
|
const projectRoot = process.cwd();
|
|
62
71
|
const configPath = path.join(projectRoot, 'waymark.config.json');
|
|
72
|
+
const waymarkDir = path.join(projectRoot, '.waymark');
|
|
73
|
+
const pidFile = path.join(waymarkDir, 'waymark.pid');
|
|
63
74
|
if (!fs.existsSync(configPath)) {
|
|
64
|
-
console.error('waymark.config.json not found. Run
|
|
75
|
+
console.error('waymark.config.json not found. Run: npx @shaifulshabuj-waymarks/cli init');
|
|
65
76
|
process.exit(1);
|
|
66
77
|
}
|
|
78
|
+
// Guard: already running
|
|
79
|
+
if (fs.existsSync(pidFile)) {
|
|
80
|
+
try {
|
|
81
|
+
const saved = JSON.parse(fs.readFileSync(pidFile, 'utf8'));
|
|
82
|
+
if (isAlive(saved.api) || isAlive(saved.mcp)) {
|
|
83
|
+
console.log('Waymark is already running.');
|
|
84
|
+
console.log('Dashboard: http://localhost:3001');
|
|
85
|
+
console.log('Run "npx @shaifulshabuj-waymarks/cli stop" to stop it.');
|
|
86
|
+
process.exit(0);
|
|
87
|
+
}
|
|
88
|
+
}
|
|
89
|
+
catch {
|
|
90
|
+
// stale/corrupt PID file — continue to start
|
|
91
|
+
}
|
|
92
|
+
}
|
|
67
93
|
const nodeBin = process.execPath;
|
|
68
94
|
const mcpBin = resolveServerBin('mcp');
|
|
69
95
|
const apiBin = resolveServerBin('api');
|
|
70
96
|
const env = { ...process.env, WAYMARK_PROJECT_ROOT: projectRoot };
|
|
71
|
-
|
|
72
|
-
|
|
73
|
-
|
|
97
|
+
const apiProc = (0, child_process_1.spawn)(nodeBin, [apiBin], {
|
|
98
|
+
env,
|
|
99
|
+
stdio: 'ignore',
|
|
100
|
+
detached: true
|
|
101
|
+
});
|
|
102
|
+
const mcpProc = (0, child_process_1.spawn)(nodeBin, [mcpBin, '--project-root', projectRoot], {
|
|
103
|
+
env,
|
|
104
|
+
stdio: 'ignore',
|
|
105
|
+
detached: true
|
|
106
|
+
});
|
|
107
|
+
apiProc.unref();
|
|
108
|
+
mcpProc.unref();
|
|
109
|
+
// Write PID file
|
|
110
|
+
if (!fs.existsSync(waymarkDir))
|
|
111
|
+
fs.mkdirSync(waymarkDir, { recursive: true });
|
|
112
|
+
fs.writeFileSync(pidFile, JSON.stringify({
|
|
113
|
+
api: apiProc.pid,
|
|
114
|
+
mcp: mcpProc.pid,
|
|
115
|
+
startedAt: new Date().toISOString()
|
|
116
|
+
}, null, 2) + '\n');
|
|
74
117
|
// Open browser after short delay for server startup
|
|
75
|
-
setTimeout(() =>
|
|
76
|
-
|
|
77
|
-
|
|
78
|
-
|
|
79
|
-
|
|
80
|
-
|
|
81
|
-
|
|
82
|
-
apiProc.kill();
|
|
83
|
-
mcpProc.kill();
|
|
84
|
-
process.exit(0);
|
|
85
|
-
};
|
|
86
|
-
process.on('SIGINT', cleanup);
|
|
87
|
-
process.on('SIGTERM', cleanup);
|
|
118
|
+
setTimeout(() => {
|
|
119
|
+
openBrowser('http://localhost:3001');
|
|
120
|
+
console.log('Waymark started (background)');
|
|
121
|
+
console.log('Dashboard: http://localhost:3001');
|
|
122
|
+
console.log('MCP server: active (stdio)');
|
|
123
|
+
console.log('Run "npx @shaifulshabuj-waymarks/cli stop" to stop.');
|
|
124
|
+
}, 1500);
|
|
88
125
|
}
|
package/dist/commands/status.js
CHANGED
|
@@ -1,8 +1,70 @@
|
|
|
1
1
|
"use strict";
|
|
2
|
+
var __createBinding = (this && this.__createBinding) || (Object.create ? (function(o, m, k, k2) {
|
|
3
|
+
if (k2 === undefined) k2 = k;
|
|
4
|
+
var desc = Object.getOwnPropertyDescriptor(m, k);
|
|
5
|
+
if (!desc || ("get" in desc ? !m.__esModule : desc.writable || desc.configurable)) {
|
|
6
|
+
desc = { enumerable: true, get: function() { return m[k]; } };
|
|
7
|
+
}
|
|
8
|
+
Object.defineProperty(o, k2, desc);
|
|
9
|
+
}) : (function(o, m, k, k2) {
|
|
10
|
+
if (k2 === undefined) k2 = k;
|
|
11
|
+
o[k2] = m[k];
|
|
12
|
+
}));
|
|
13
|
+
var __setModuleDefault = (this && this.__setModuleDefault) || (Object.create ? (function(o, v) {
|
|
14
|
+
Object.defineProperty(o, "default", { enumerable: true, value: v });
|
|
15
|
+
}) : function(o, v) {
|
|
16
|
+
o["default"] = v;
|
|
17
|
+
});
|
|
18
|
+
var __importStar = (this && this.__importStar) || (function () {
|
|
19
|
+
var ownKeys = function(o) {
|
|
20
|
+
ownKeys = Object.getOwnPropertyNames || function (o) {
|
|
21
|
+
var ar = [];
|
|
22
|
+
for (var k in o) if (Object.prototype.hasOwnProperty.call(o, k)) ar[ar.length] = k;
|
|
23
|
+
return ar;
|
|
24
|
+
};
|
|
25
|
+
return ownKeys(o);
|
|
26
|
+
};
|
|
27
|
+
return function (mod) {
|
|
28
|
+
if (mod && mod.__esModule) return mod;
|
|
29
|
+
var result = {};
|
|
30
|
+
if (mod != null) for (var k = ownKeys(mod), i = 0; i < k.length; i++) if (k[i] !== "default") __createBinding(result, mod, k[i]);
|
|
31
|
+
__setModuleDefault(result, mod);
|
|
32
|
+
return result;
|
|
33
|
+
};
|
|
34
|
+
})();
|
|
2
35
|
Object.defineProperty(exports, "__esModule", { value: true });
|
|
3
36
|
exports.run = run;
|
|
37
|
+
const fs = __importStar(require("fs"));
|
|
38
|
+
const path = __importStar(require("path"));
|
|
4
39
|
const BASE = 'http://localhost:3001';
|
|
40
|
+
function isAlive(pid) {
|
|
41
|
+
try {
|
|
42
|
+
process.kill(pid, 0);
|
|
43
|
+
return true;
|
|
44
|
+
}
|
|
45
|
+
catch {
|
|
46
|
+
return false;
|
|
47
|
+
}
|
|
48
|
+
}
|
|
5
49
|
async function run() {
|
|
50
|
+
const pidFile = path.join(process.cwd(), '.waymark', 'waymark.pid');
|
|
51
|
+
if (!fs.existsSync(pidFile)) {
|
|
52
|
+
console.log('Waymark is not running. Start with: npx @shaifulshabuj-waymarks/cli start');
|
|
53
|
+
return;
|
|
54
|
+
}
|
|
55
|
+
let saved;
|
|
56
|
+
try {
|
|
57
|
+
saved = JSON.parse(fs.readFileSync(pidFile, 'utf8'));
|
|
58
|
+
}
|
|
59
|
+
catch {
|
|
60
|
+
console.log('Waymark is not running. Start with: npx @shaifulshabuj-waymarks/cli start');
|
|
61
|
+
return;
|
|
62
|
+
}
|
|
63
|
+
if (!isAlive(saved.api) && !isAlive(saved.mcp)) {
|
|
64
|
+
fs.unlinkSync(pidFile);
|
|
65
|
+
console.log('Waymark is not running (crashed). Start with: npx @shaifulshabuj-waymarks/cli start');
|
|
66
|
+
return;
|
|
67
|
+
}
|
|
6
68
|
try {
|
|
7
69
|
const [countRes, actionsRes] = await Promise.all([
|
|
8
70
|
fetch(`${BASE}/api/actions?count=true`),
|
|
@@ -14,11 +76,12 @@ async function run() {
|
|
|
14
76
|
const actions = await actionsRes.json();
|
|
15
77
|
const total = actions.length;
|
|
16
78
|
console.log('Waymark status');
|
|
17
|
-
console.log(`Dashboard:
|
|
18
|
-
console.log(`
|
|
79
|
+
console.log(`Dashboard: ${BASE} (running)`);
|
|
80
|
+
console.log(`Started: ${saved.startedAt}`);
|
|
81
|
+
console.log(`Pending approvals: ${pending}`);
|
|
19
82
|
console.log(`Total actions logged: ${total}`);
|
|
20
83
|
}
|
|
21
84
|
catch {
|
|
22
|
-
console.log('Waymark is not running. Start with:
|
|
85
|
+
console.log('Waymark is not running. Start with: npx @shaifulshabuj-waymarks/cli start');
|
|
23
86
|
}
|
|
24
87
|
}
|
|
@@ -0,0 +1,75 @@
|
|
|
1
|
+
"use strict";
|
|
2
|
+
var __createBinding = (this && this.__createBinding) || (Object.create ? (function(o, m, k, k2) {
|
|
3
|
+
if (k2 === undefined) k2 = k;
|
|
4
|
+
var desc = Object.getOwnPropertyDescriptor(m, k);
|
|
5
|
+
if (!desc || ("get" in desc ? !m.__esModule : desc.writable || desc.configurable)) {
|
|
6
|
+
desc = { enumerable: true, get: function() { return m[k]; } };
|
|
7
|
+
}
|
|
8
|
+
Object.defineProperty(o, k2, desc);
|
|
9
|
+
}) : (function(o, m, k, k2) {
|
|
10
|
+
if (k2 === undefined) k2 = k;
|
|
11
|
+
o[k2] = m[k];
|
|
12
|
+
}));
|
|
13
|
+
var __setModuleDefault = (this && this.__setModuleDefault) || (Object.create ? (function(o, v) {
|
|
14
|
+
Object.defineProperty(o, "default", { enumerable: true, value: v });
|
|
15
|
+
}) : function(o, v) {
|
|
16
|
+
o["default"] = v;
|
|
17
|
+
});
|
|
18
|
+
var __importStar = (this && this.__importStar) || (function () {
|
|
19
|
+
var ownKeys = function(o) {
|
|
20
|
+
ownKeys = Object.getOwnPropertyNames || function (o) {
|
|
21
|
+
var ar = [];
|
|
22
|
+
for (var k in o) if (Object.prototype.hasOwnProperty.call(o, k)) ar[ar.length] = k;
|
|
23
|
+
return ar;
|
|
24
|
+
};
|
|
25
|
+
return ownKeys(o);
|
|
26
|
+
};
|
|
27
|
+
return function (mod) {
|
|
28
|
+
if (mod && mod.__esModule) return mod;
|
|
29
|
+
var result = {};
|
|
30
|
+
if (mod != null) for (var k = ownKeys(mod), i = 0; i < k.length; i++) if (k[i] !== "default") __createBinding(result, mod, k[i]);
|
|
31
|
+
__setModuleDefault(result, mod);
|
|
32
|
+
return result;
|
|
33
|
+
};
|
|
34
|
+
})();
|
|
35
|
+
Object.defineProperty(exports, "__esModule", { value: true });
|
|
36
|
+
exports.run = run;
|
|
37
|
+
const fs = __importStar(require("fs"));
|
|
38
|
+
const path = __importStar(require("path"));
|
|
39
|
+
function tryKill(pid) {
|
|
40
|
+
try {
|
|
41
|
+
process.kill(pid, 'SIGTERM');
|
|
42
|
+
return true;
|
|
43
|
+
}
|
|
44
|
+
catch {
|
|
45
|
+
return false;
|
|
46
|
+
}
|
|
47
|
+
}
|
|
48
|
+
function run() {
|
|
49
|
+
const pidFile = path.join(process.cwd(), '.waymark', 'waymark.pid');
|
|
50
|
+
if (!fs.existsSync(pidFile)) {
|
|
51
|
+
console.log('Waymark is not running.');
|
|
52
|
+
return;
|
|
53
|
+
}
|
|
54
|
+
let saved;
|
|
55
|
+
try {
|
|
56
|
+
saved = JSON.parse(fs.readFileSync(pidFile, 'utf8'));
|
|
57
|
+
}
|
|
58
|
+
catch {
|
|
59
|
+
fs.unlinkSync(pidFile);
|
|
60
|
+
console.log('Waymark is not running.');
|
|
61
|
+
return;
|
|
62
|
+
}
|
|
63
|
+
const killedApi = tryKill(saved.api);
|
|
64
|
+
const killedMcp = tryKill(saved.mcp);
|
|
65
|
+
try {
|
|
66
|
+
fs.unlinkSync(pidFile);
|
|
67
|
+
}
|
|
68
|
+
catch { /* already gone */ }
|
|
69
|
+
if (killedApi || killedMcp) {
|
|
70
|
+
console.log('Waymark stopped.');
|
|
71
|
+
}
|
|
72
|
+
else {
|
|
73
|
+
console.log('Waymark was not running (stale PID file removed).');
|
|
74
|
+
}
|
|
75
|
+
}
|
package/dist/index.js
CHANGED
|
@@ -7,6 +7,9 @@ switch (command) {
|
|
|
7
7
|
case 'start':
|
|
8
8
|
require('./commands/start').run();
|
|
9
9
|
break;
|
|
10
|
+
case 'stop':
|
|
11
|
+
require('./commands/stop').run();
|
|
12
|
+
break;
|
|
10
13
|
case 'status':
|
|
11
14
|
require('./commands/status').run();
|
|
12
15
|
break;
|
|
@@ -14,11 +17,12 @@ switch (command) {
|
|
|
14
17
|
require('./commands/logs').run();
|
|
15
18
|
break;
|
|
16
19
|
default:
|
|
17
|
-
console.log('Usage:
|
|
20
|
+
console.log('Usage: npx @shaifulshabuj-waymarks/cli <init|start|stop|status|logs>');
|
|
18
21
|
console.log('');
|
|
19
22
|
console.log('Commands:');
|
|
20
23
|
console.log(' init Set up Waymark in the current project');
|
|
21
24
|
console.log(' start Start the Waymark dashboard and MCP server');
|
|
25
|
+
console.log(' stop Stop the running Waymark servers');
|
|
22
26
|
console.log(' status Show current Waymark status and pending count');
|
|
23
27
|
console.log(' logs Show recent action log');
|
|
24
28
|
process.exit(command ? 1 : 0);
|
package/package.json
CHANGED
|
@@ -1,6 +1,6 @@
|
|
|
1
1
|
{
|
|
2
2
|
"name": "@shaifulshabuj-waymarks/cli",
|
|
3
|
-
"version": "0.
|
|
3
|
+
"version": "0.3.0",
|
|
4
4
|
"description": "Control what AI agents can do in your codebase",
|
|
5
5
|
"author": "Waymark <hello@waymarks.dev>",
|
|
6
6
|
"license": "MIT",
|
|
@@ -31,7 +31,7 @@
|
|
|
31
31
|
"build": "tsc"
|
|
32
32
|
},
|
|
33
33
|
"dependencies": {
|
|
34
|
-
"@shaifulshabuj-waymarks/server": "0.
|
|
34
|
+
"@shaifulshabuj-waymarks/server": "0.3.0"
|
|
35
35
|
},
|
|
36
36
|
"devDependencies": {
|
|
37
37
|
"@types/node": "^20.11.5",
|