clawmatrix 0.1.21 → 0.1.22

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": "clawmatrix",
3
- "version": "0.1.21",
3
+ "version": "0.1.22",
4
4
  "description": "Decentralized mesh cluster plugin for OpenClaw — inter-gateway communication, model proxy, task handoff, and tool proxy.",
5
5
  "type": "module",
6
6
  "license": "MIT",
@@ -31,6 +31,18 @@ export interface KnowledgeSyncOptions {
31
31
 
32
32
  const TAG = "knowledge";
33
33
 
34
+ async function streamToString(stream: ReadableStream | null): Promise<string> {
35
+ if (!stream) return "";
36
+ const reader = stream.getReader();
37
+ const chunks: Uint8Array[] = [];
38
+ for (;;) {
39
+ const { done, value } = await reader.read();
40
+ if (done) break;
41
+ chunks.push(value);
42
+ }
43
+ return Buffer.concat(chunks).toString("utf-8");
44
+ }
45
+
34
46
  export class KnowledgeSync {
35
47
  private doc: Automerge.Doc<KnowledgeDoc>;
36
48
  private syncStates = new Map<string, Automerge.SyncState>();
@@ -356,6 +368,34 @@ export class KnowledgeSync {
356
368
  } else {
357
369
  debug(TAG, "git repo already initialized");
358
370
  }
371
+
372
+ // Ensure local git user config exists (so commits don't fail on unconfigured machines)
373
+ const nameCheck = spawnProcess(["git", "config", "user.name"], {
374
+ cwd: this.opts.workspacePath,
375
+ stdout: "pipe",
376
+ stderr: "pipe",
377
+ });
378
+ if ((await nameCheck.exited) !== 0) {
379
+ const setName = spawnProcess(["git", "config", "user.name", "clawmatrix"], {
380
+ cwd: this.opts.workspacePath,
381
+ stdout: "pipe",
382
+ stderr: "pipe",
383
+ });
384
+ await setName.exited;
385
+ }
386
+ const emailCheck = spawnProcess(["git", "config", "user.email"], {
387
+ cwd: this.opts.workspacePath,
388
+ stdout: "pipe",
389
+ stderr: "pipe",
390
+ });
391
+ if ((await emailCheck.exited) !== 0) {
392
+ const setEmail = spawnProcess(["git", "config", "user.email", "clawmatrix@local"], {
393
+ cwd: this.opts.workspacePath,
394
+ stdout: "pipe",
395
+ stderr: "pipe",
396
+ });
397
+ await setEmail.exited;
398
+ }
359
399
  } catch {
360
400
  debug(TAG, "git not available, skipping git integration");
361
401
  }
@@ -389,8 +429,13 @@ export class KnowledgeSync {
389
429
  stderr: "pipe",
390
430
  },
391
431
  );
392
- await commit.exited;
393
- debug(TAG, `git commit: ${message}`);
432
+ const commitCode = await commit.exited;
433
+ if (commitCode !== 0) {
434
+ const stderr = await streamToString(commit.stderr);
435
+ debug(TAG, `git commit failed (exit ${commitCode}): ${stderr}`);
436
+ } else {
437
+ debug(TAG, `git commit: ${message}`);
438
+ }
394
439
  } catch (err) {
395
440
  debug(TAG, `git commit failed: ${err}`);
396
441
  }