fivocell 8.12.6 → 8.12.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.
@@ -3162,6 +3162,69 @@ async function handleMCPToolCall(name, args) {
3162
3162
  return { error: `Tool ${name} failed: ${msg}` };
3163
3163
  }
3164
3164
  }
3165
+ // ─── Watch REST API (for CLI commands) ────────────────────────────
3166
+ app.post('/watch/start', (req, res) => {
3167
+ try {
3168
+ const { startWatcher } = require('../watcher/live-watcher');
3169
+ const { project, dir } = req.body || {};
3170
+ if (!project) {
3171
+ res.status(400).json({ error: 'project required' });
3172
+ return;
3173
+ }
3174
+ const result = startWatcher(project, dir || process.cwd());
3175
+ res.json({ success: true, project, dir: dir || process.cwd(), result });
3176
+ }
3177
+ catch (e) {
3178
+ res.status(500).json({ error: 'Watch start failed: ' + String(e) });
3179
+ }
3180
+ });
3181
+ app.post('/watch/stop', (req, res) => {
3182
+ try {
3183
+ const { stopWatcher } = require('../watcher/live-watcher');
3184
+ const { project } = req.body || {};
3185
+ if (!project) {
3186
+ res.status(400).json({ error: 'project required' });
3187
+ return;
3188
+ }
3189
+ const result = stopWatcher(project);
3190
+ res.json({ success: true, project, result });
3191
+ }
3192
+ catch (e) {
3193
+ res.status(500).json({ error: 'Watch stop failed: ' + String(e) });
3194
+ }
3195
+ });
3196
+ app.get('/watch/status', (req, res) => {
3197
+ try {
3198
+ const { getWatcherStatus, getActiveWatchers } = require('../watcher/live-watcher');
3199
+ const project = String(req.query.project || '');
3200
+ if (project) {
3201
+ const status = getWatcherStatus(project);
3202
+ if (!status) {
3203
+ res.json({ project, active: false, message: 'No watcher found' });
3204
+ return;
3205
+ }
3206
+ res.json({ project, active: true, dirPath: status.dirPath, eventCount: status.eventCount, lastEventAt: status.lastEventAt });
3207
+ }
3208
+ else {
3209
+ res.json({ active: getActiveWatchers() });
3210
+ }
3211
+ }
3212
+ catch (e) {
3213
+ res.status(500).json({ error: 'Watch status failed: ' + String(e) });
3214
+ }
3215
+ });
3216
+ app.get('/watch/events', (req, res) => {
3217
+ try {
3218
+ const { getLiveEvents } = require('../watcher/live-watcher');
3219
+ const project = String(req.query.project || '');
3220
+ const limit = parseInt(String(req.query.limit || '20'), 10);
3221
+ const events = getLiveEvents(project, limit);
3222
+ res.json({ project, events, count: events.length });
3223
+ }
3224
+ catch (e) {
3225
+ res.status(500).json({ error: 'Watch events failed: ' + String(e) });
3226
+ }
3227
+ });
3165
3228
  app.post('/mcp', async (req, res) => {
3166
3229
  // Wrap entire handler in try/catch so uncaught errors don't 500 silently
3167
3230
  try {
@@ -3376,7 +3439,7 @@ const server = app.listen(Number(PORT), HOST, () => {
3376
3439
  setTimeout(() => {
3377
3440
  try {
3378
3441
  const { startWatcher } = require('../watcher/live-watcher');
3379
- startWatcher(startProject, startDir);
3442
+ startWatcher(startProject, startDir, { preserveState: true });
3380
3443
  console.log(`[cell] Auto-started watcher for "${startProject}"`);
3381
3444
  }
3382
3445
  catch (e) {