@teevee98/synapse-hub 3.9.0 → 3.10.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.
Files changed (44) hide show
  1. package/.agents/rules/git-push-protocol.md +1 -1
  2. package/.agents/rules/mandatory-playwright-live.md +4 -2
  3. package/.agents/rules/mobile_appium_rules.md +14 -39
  4. package/.agents/rules/security_testing_rules.md +24 -0
  5. package/.agents/rules/stack-auto-router.md +17 -0
  6. package/.agents/rules/systematic-debugging.md +9 -8
  7. package/.agents/skills/db-state-verifier-and-seeder/SKILL.md +9 -4
  8. package/.agents/skills/playwright-webapp-testing/SKILL.md +6 -4
  9. package/.agents/skills/token-and-context-optimizer/SKILL.md +1 -1
  10. package/.cursor/rules/agents.mdc +1 -1
  11. package/AGENTS.md +2 -1
  12. package/README.en.md +2 -2
  13. package/README.md +2 -2
  14. package/agentskills.json +1 -1
  15. package/docs/ARCHITECTURE.en.md +1 -1
  16. package/docs/ARCHITECTURE.md +1 -1
  17. package/docs/CLI_REFERENCE.en.md +7 -11
  18. package/docs/CLI_REFERENCE.md +7 -11
  19. package/docs/QUALITY_GATES.en.md +5 -5
  20. package/docs/QUALITY_GATES.md +5 -5
  21. package/package.json +1 -1
  22. package/plugin.json +1 -1
  23. package/scripts/install.ps1 +1 -1
  24. package/scripts/install_global_plugin.ps1 +19 -2
  25. package/scripts/install_global_plugin.sh +21 -2
  26. package/skills_manifest.json +1 -1
  27. package/synapse.config.json +1 -1
  28. package/tools/TOOL_CATALOG.json +1 -1
  29. package/tools/__init__.py +1 -1
  30. package/tools/browser_helpers.js +2 -2
  31. package/tools/cli.py +3 -3
  32. package/tools/core/memory_bus.py +25 -24
  33. package/tools/core/process_supervisor.py +55 -16
  34. package/tools/core/telemetry.py +32 -3
  35. package/tools/dashboard_generator.py +6 -6
  36. package/tools/db_sandbox.py +53 -10
  37. package/tools/mcp_docx_server.py +1 -1
  38. package/tools/mcp_excel_server.py +1 -1
  39. package/tools/mcp_server.py +1 -1
  40. package/tools/package_release.py +29 -5
  41. package/tools/reversible_sandbox.py +85 -7
  42. package/tools/ui_server.py +1 -1
  43. package/tools/update_sentinel.py +3 -3
  44. package/tools/welcome_page.py +1 -1
@@ -49,6 +49,14 @@ SCRIPT_DIR = os.path.dirname(os.path.abspath(__file__))
49
49
  QA_HUB_ROOT = os.path.abspath(os.path.join(SCRIPT_DIR, ".."))
50
50
 
51
51
 
52
+ def _split_cmd(cmd_str: str) -> List[str]:
53
+ """Splits a command string into argument tokens cross-platform without losing backslashes or quoting."""
54
+ if sys.platform == "win32":
55
+ tokens = shlex.split(cmd_str, posix=False)
56
+ return [t.strip('"') for t in tokens]
57
+ return shlex.split(cmd_str)
58
+
59
+
52
60
  def _resolve_wal_path() -> str:
53
61
  cwd = os.path.abspath(os.getcwd())
54
62
  try:
@@ -78,6 +86,7 @@ class ExecutionSandbox:
78
86
 
79
87
  def __init__(self, auto_rollback_on_exit: bool = True, wal_path: Optional[str] = None):
80
88
  self.undo_stack: List[ReversibleAction] = []
89
+ self.failed_actions: List[ReversibleAction] = []
81
90
  self.auto_rollback_on_exit = auto_rollback_on_exit
82
91
  self.wal_path = wal_path if wal_path is not None else _resolve_wal_path()
83
92
  if self.wal_path:
@@ -97,6 +106,7 @@ class ExecutionSandbox:
97
106
  "target_resource": action.target_resource,
98
107
  "undo_command": action.undo_command,
99
108
  "metadata": action.metadata,
109
+ "status": "PENDING",
100
110
  "timestamp": time.time()
101
111
  }
102
112
  line = json.dumps(entry, ensure_ascii=False) + "\n"
@@ -115,7 +125,7 @@ class ExecutionSandbox:
115
125
  sys.stderr.write(f"Warning: Failed to write undo WAL journal: {e}\n")
116
126
 
117
127
  def _clear_wal(self):
118
- """Clears or resets WAL journal when stack has been completely unwound."""
128
+ """Clears or resets WAL journal when stack has been completely unwound without errors."""
119
129
  if not self.wal_path or not os.path.exists(self.wal_path):
120
130
  return
121
131
  try:
@@ -130,6 +140,51 @@ class ExecutionSandbox:
130
140
  except Exception as clear_err:
131
141
  sys.stderr.write(f"Notice: Failed to clear WAL: {clear_err}\n")
132
142
 
143
+ def _update_wal_journal(
144
+ self,
145
+ pending_actions: List[ReversibleAction],
146
+ failed_entries: Optional[List[Dict[str, Any]]] = None
147
+ ):
148
+ """
149
+ Synchronously updates WAL journal with pending and failed actions (Incremental 2PC).
150
+ Clears the journal only when 100% of actions are resolved without failure.
151
+ """
152
+ if not self.wal_path:
153
+ return
154
+ failed_list = failed_entries or []
155
+ if not pending_actions and not failed_list:
156
+ self._clear_wal()
157
+ return
158
+
159
+ lines = []
160
+ for entry in failed_list:
161
+ lines.append(json.dumps(entry, ensure_ascii=False) + "\n")
162
+ for action in pending_actions:
163
+ entry = {
164
+ "action_type": action.action_type,
165
+ "target_resource": action.target_resource,
166
+ "undo_command": action.undo_command,
167
+ "metadata": action.metadata,
168
+ "status": "PENDING",
169
+ "timestamp": time.time()
170
+ }
171
+ lines.append(json.dumps(entry, ensure_ascii=False) + "\n")
172
+
173
+ content = "".join(lines)
174
+ try:
175
+ try:
176
+ from tools.core.file_lock import file_lock
177
+ with file_lock(self.wal_path + ".lock", timeout=5.0):
178
+ with open(self.wal_path, "w", encoding="utf-8") as f:
179
+ f.write(content)
180
+ f.flush()
181
+ except ImportError:
182
+ with open(self.wal_path, "w", encoding="utf-8") as f:
183
+ f.write(content)
184
+ f.flush()
185
+ except Exception as e:
186
+ sys.stderr.write(f"Warning: Failed to update WAL journal: {e}\n")
187
+
133
188
  def record_mutation(
134
189
  self,
135
190
  action_type: str,
@@ -156,7 +211,7 @@ class ExecutionSandbox:
156
211
  ) -> bool:
157
212
  """Executes a forward shell command and immediately records its reversible undo counterpart."""
158
213
  try:
159
- args = shlex.split(forward_cmd) if isinstance(forward_cmd, str) else forward_cmd
214
+ args = _split_cmd(forward_cmd) if isinstance(forward_cmd, str) else forward_cmd
160
215
  res = subprocess.run(args, text=True, capture_output=True, timeout=60.0)
161
216
  if res.returncode == 0:
162
217
  self.record_mutation(action_type, target_resource, undo_cmd, {"forward_cmd": forward_cmd})
@@ -166,10 +221,12 @@ class ExecutionSandbox:
166
221
  return False
167
222
 
168
223
  def rollback_all(self, silent: bool = False) -> List[Dict[str, Any]]:
169
- """Unwinds the undo stack in strictly reverse (LIFO) order and cleans WAL."""
224
+ """Unwinds the undo stack in strictly reverse (LIFO) order and preserves failed entries in WAL."""
170
225
  results = []
226
+ failed_entries: List[Dict[str, Any]] = []
227
+
171
228
  while self.undo_stack:
172
- action = self.undo_stack.pop()
229
+ action = self.undo_stack[-1]
173
230
  success = True
174
231
  err_msg = ""
175
232
  cmd = action.undo_command.strip()
@@ -191,13 +248,15 @@ class ExecutionSandbox:
191
248
  except Exception as e:
192
249
  success = False
193
250
  err_msg = str(e)
251
+ elif cmd in ("NOOP", ":"):
252
+ success = True
194
253
  elif cmd:
195
254
  try:
196
- args = shlex.split(cmd) if isinstance(cmd, str) else cmd
255
+ args = _split_cmd(cmd) if isinstance(cmd, str) else cmd
197
256
  res = subprocess.run(args, text=True, capture_output=True, timeout=60.0)
198
257
  success = (res.returncode == 0)
199
258
  if not success:
200
- err_msg = res.stderr.strip()
259
+ err_msg = res.stderr.strip() or f"Command exited with code {res.returncode}"
201
260
  except Exception as e:
202
261
  success = False
203
262
  err_msg = str(e)
@@ -210,11 +269,30 @@ class ExecutionSandbox:
210
269
  "error": err_msg
211
270
  }
212
271
  results.append(result_entry)
272
+
273
+ self.undo_stack.pop()
274
+
275
+ if success:
276
+ self._update_wal_journal(self.undo_stack, failed_entries=failed_entries)
277
+ else:
278
+ self.failed_actions.append(action)
279
+ failed_entry = {
280
+ "action_type": action.action_type,
281
+ "target_resource": action.target_resource,
282
+ "undo_command": action.undo_command,
283
+ "metadata": action.metadata,
284
+ "status": "FAILED",
285
+ "error": err_msg,
286
+ "timestamp": time.time()
287
+ }
288
+ failed_entries.append(failed_entry)
289
+ self._update_wal_journal(self.undo_stack, failed_entries=failed_entries)
290
+
213
291
  if not silent:
214
292
  status_icon = "✅" if success else "⚠️"
215
293
  print(f" {status_icon} [ROLLBACK] {action.action_type} on '{action.target_resource}': {action.undo_command}")
216
294
 
217
- if not self.undo_stack:
295
+ if not self.undo_stack and not self.failed_actions and not failed_entries:
218
296
  self._clear_wal()
219
297
 
220
298
  return results
@@ -236,7 +236,7 @@ class SynapseUiHandler(BaseHTTPRequestHandler):
236
236
  if path == "/api/status":
237
237
  active_target = JOB_MANAGER.target_dir or REPO_ROOT
238
238
  self.send_json(200, {
239
- "version": "3.9.0",
239
+ "version": "3.10.0",
240
240
  "status": "ONLINE",
241
241
  "os": sys.platform,
242
242
  "workspace": active_target,
@@ -65,7 +65,7 @@ def get_local_version():
65
65
  try:
66
66
  with open(pkg_file, "r", encoding="utf-8") as f:
67
67
  data = json.load(f)
68
- return data.get("version", "3.9.0")
68
+ return data.get("version", "3.10.0")
69
69
  except (OSError, json.JSONDecodeError):
70
70
  data = {}
71
71
 
@@ -74,11 +74,11 @@ def get_local_version():
74
74
  try:
75
75
  with open(manifest_file, "r", encoding="utf-8") as f:
76
76
  data = json.load(f)
77
- return data.get("version", "3.9.0")
77
+ return data.get("version", "3.10.0")
78
78
  except (OSError, json.JSONDecodeError):
79
79
  data = {}
80
80
 
81
- return "3.9.0"
81
+ return "3.10.0"
82
82
 
83
83
 
84
84
  def fetch_remote_version():
@@ -47,7 +47,7 @@ def get_hub_metadata() -> Dict[str, Any]:
47
47
  """Retrieves version and catalog count from skills_manifest.json."""
48
48
  manifest_path = os.path.join(HUB_ROOT, "skills_manifest.json")
49
49
  meta = {
50
- "version": "3.9.0",
50
+ "version": "3.10.0",
51
51
  "totalSkills": 42,
52
52
  "author": "Thế Vị (@TeeVee98)",
53
53
  "repo": "https://github.com/TeeVee98/Synapse-Hub"