wogiflow 2.5.7 → 2.5.9

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": "wogiflow",
3
- "version": "2.5.7",
3
+ "version": "2.5.9",
4
4
  "description": "AI-powered development workflow management system with multi-model support",
5
5
  "main": "lib/index.js",
6
6
  "bin": {
@@ -61,6 +61,92 @@ runHook('Stop', async ({ parsedInput }) => {
61
61
  };
62
62
  }
63
63
 
64
+ // Workspace worker: auto-write results back to manager when stopping
65
+ // This runs in the hook (not the AI), so it's guaranteed to execute.
66
+ // The AI can't be relied on to call workspace_send_message — the stop
67
+ // hook fires before the AI gets a chance, or the AI forgets.
68
+ if (process.env.WOGI_WORKSPACE_ROOT && process.env.WOGI_REPO_NAME) {
69
+ try {
70
+ const fs = require('node:fs');
71
+ const path = require('node:path');
72
+ const crypto = require('node:crypto');
73
+ const workspaceRoot = process.env.WOGI_WORKSPACE_ROOT;
74
+ const repoName = process.env.WOGI_REPO_NAME;
75
+ const messagesDir = path.join(workspaceRoot, '.workspace', 'messages');
76
+ fs.mkdirSync(messagesDir, { recursive: true });
77
+
78
+ // Build summary from available state
79
+ const summary = [];
80
+ const { PATHS, safeJsonParse } = require('../../flow-utils');
81
+
82
+ // Get current/recently completed task info
83
+ const ready = safeJsonParse(path.join(PATHS.state, 'ready.json'), {});
84
+ const recentTask = (ready.recentlyCompleted || [])[0];
85
+ const inProgressTask = (ready.inProgress || [])[0];
86
+ const task = recentTask || inProgressTask;
87
+
88
+ if (task) {
89
+ summary.push(`**Task**: ${task.title || task.id}`);
90
+ if (task.type) summary.push(`**Type**: ${task.type}`);
91
+ }
92
+
93
+ // Get last request-log entry
94
+ try {
95
+ const logPath = path.join(PATHS.root, 'request-log.md');
96
+ if (fs.existsSync(logPath)) {
97
+ const stat = fs.statSync(logPath);
98
+ if (stat.size < 200 * 1024) {
99
+ const logContent = fs.readFileSync(logPath, 'utf-8');
100
+ const parts = logContent.split(/^### R-/m);
101
+ if (parts.length > 1) {
102
+ const lastEntry = parts[parts.length - 1];
103
+ if (lastEntry.length < 2000) {
104
+ summary.push(`**Log entry**:\n### R-${lastEntry.trim()}`);
105
+ }
106
+ }
107
+ }
108
+ }
109
+ } catch (_err) { /* non-critical */ }
110
+
111
+ // Get git status for changed files
112
+ try {
113
+ const { execSync } = require('node:child_process');
114
+ const diff = execSync('git diff --name-only HEAD 2>/dev/null || true', { cwd: PATHS.root, encoding: 'utf-8' }).trim();
115
+ const staged = execSync('git diff --name-only --staged 2>/dev/null || true', { cwd: PATHS.root, encoding: 'utf-8' }).trim();
116
+ const allChanged = [...new Set([...diff.split('\n'), ...staged.split('\n')].filter(Boolean))];
117
+ if (allChanged.length > 0) {
118
+ summary.push(`**Files changed**: ${allChanged.join(', ')}`);
119
+ }
120
+ } catch (_err) { /* non-critical */ }
121
+
122
+ const msgId = 'msg-' + crypto.randomBytes(4).toString('hex');
123
+ const message = {
124
+ id: msgId,
125
+ from: repoName,
126
+ to: 'manager',
127
+ type: 'task-complete',
128
+ priority: 'medium',
129
+ timestamp: new Date().toISOString(),
130
+ subject: task ? `Completed: ${task.title || task.id}` : `Work completed by ${repoName}`,
131
+ body: summary.join('\n') || `${repoName} finished processing.`,
132
+ taskId: task?.id || null,
133
+ actionRequired: false,
134
+ status: 'pending'
135
+ };
136
+
137
+ fs.writeFileSync(path.join(messagesDir, `${msgId}.json`), JSON.stringify(message, null, 2));
138
+
139
+ if (process.env.DEBUG) {
140
+ console.error(`[Stop] Workspace message written: ${msgId}`);
141
+ }
142
+ } catch (err) {
143
+ // Non-critical — best effort
144
+ if (process.env.DEBUG) {
145
+ console.error(`[Stop] Workspace message failed: ${err.message}`);
146
+ }
147
+ }
148
+ }
149
+
64
150
  // Check if loop can exit
65
151
  return await checkLoopExit();
66
152
  }, { failMode: 'warn', failOutput: { continue: false } });