wangchuan 5.1.0 → 5.2.1
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/README.md +8 -6
- package/README.zh-CN.md +8 -6
- package/dist/bin/wangchuan.js +10 -4
- package/dist/bin/wangchuan.js.map +1 -1
- package/dist/src/agents/index.d.ts.map +1 -1
- package/dist/src/agents/index.js +9 -0
- package/dist/src/agents/index.js.map +1 -1
- package/dist/src/commands/doctor.d.ts.map +1 -1
- package/dist/src/commands/doctor.js +27 -17
- package/dist/src/commands/doctor.js.map +1 -1
- package/dist/src/commands/init.d.ts.map +1 -1
- package/dist/src/commands/init.js +49 -4
- package/dist/src/commands/init.js.map +1 -1
- package/dist/src/commands/key.d.ts.map +1 -1
- package/dist/src/commands/key.js +1 -17
- package/dist/src/commands/key.js.map +1 -1
- package/dist/src/commands/memory.js +44 -2
- package/dist/src/commands/memory.js.map +1 -1
- package/dist/src/commands/pull.js.map +1 -1
- package/dist/src/commands/push.js.map +1 -1
- package/dist/src/commands/snapshot.d.ts.map +1 -1
- package/dist/src/commands/snapshot.js +1 -19
- package/dist/src/commands/snapshot.js.map +1 -1
- package/dist/src/commands/sync.d.ts.map +1 -1
- package/dist/src/commands/sync.js +1 -15
- package/dist/src/commands/sync.js.map +1 -1
- package/dist/src/commands/watch.js.map +1 -1
- package/dist/src/core/crypto.d.ts +4 -0
- package/dist/src/core/crypto.d.ts.map +1 -1
- package/dist/src/core/crypto.js +15 -2
- package/dist/src/core/crypto.js.map +1 -1
- package/dist/src/core/merge.d.ts +1 -1
- package/dist/src/core/merge.d.ts.map +1 -1
- package/dist/src/core/merge.js +2 -18
- package/dist/src/core/merge.js.map +1 -1
- package/dist/src/core/migrate.d.ts.map +1 -1
- package/dist/src/core/migrate.js +5 -20
- package/dist/src/core/migrate.js.map +1 -1
- package/dist/src/core/sync-lock.d.ts.map +1 -1
- package/dist/src/core/sync-lock.js +20 -1
- package/dist/src/core/sync-lock.js.map +1 -1
- package/dist/src/core/sync.d.ts +4 -4
- package/dist/src/core/sync.d.ts.map +1 -1
- package/dist/src/core/sync.js +74 -19
- package/dist/src/core/sync.js.map +1 -1
- package/dist/src/i18n.d.ts.map +1 -1
- package/dist/src/i18n.js +17 -1
- package/dist/src/i18n.js.map +1 -1
- package/dist/src/types.d.ts +13 -3
- package/dist/src/types.d.ts.map +1 -1
- package/dist/src/types.js.map +1 -1
- package/dist/src/utils/fs.d.ts +18 -0
- package/dist/src/utils/fs.d.ts.map +1 -0
- package/dist/src/utils/fs.js +56 -0
- package/dist/src/utils/fs.js.map +1 -0
- package/dist/src/utils/lcs.d.ts +8 -0
- package/dist/src/utils/lcs.d.ts.map +1 -0
- package/dist/src/utils/lcs.js +20 -0
- package/dist/src/utils/lcs.js.map +1 -0
- package/dist/src/utils/linediff.d.ts +1 -1
- package/dist/src/utils/linediff.d.ts.map +1 -1
- package/dist/src/utils/linediff.js +2 -15
- package/dist/src/utils/linediff.js.map +1 -1
- package/dist/test/merge.test.d.ts +5 -0
- package/dist/test/merge.test.d.ts.map +1 -0
- package/dist/test/merge.test.js +226 -0
- package/dist/test/merge.test.js.map +1 -0
- package/package.json +2 -2
- package/skill/SKILL.md +12 -2
|
@@ -0,0 +1,226 @@
|
|
|
1
|
+
/**
|
|
2
|
+
* merge.test.ts — Three-way merge module unit tests
|
|
3
|
+
*/
|
|
4
|
+
import { describe, it } from 'node:test';
|
|
5
|
+
import assert from 'node:assert/strict';
|
|
6
|
+
import { threeWayMerge } from '../src/core/merge.js';
|
|
7
|
+
// ---------------------------------------------------------------------------
|
|
8
|
+
// 1. Fast paths
|
|
9
|
+
// ---------------------------------------------------------------------------
|
|
10
|
+
describe('threeWayMerge fast paths', () => {
|
|
11
|
+
it('local === remote → returns local as-is, no conflicts', () => {
|
|
12
|
+
const base = 'a\nb\nc';
|
|
13
|
+
const local = 'a\nX\nc';
|
|
14
|
+
const remote = 'a\nX\nc';
|
|
15
|
+
const result = threeWayMerge(base, local, remote);
|
|
16
|
+
assert.equal(result.merged, local);
|
|
17
|
+
assert.equal(result.hasConflicts, false);
|
|
18
|
+
});
|
|
19
|
+
it('local === base → returns remote (only remote changed)', () => {
|
|
20
|
+
const base = 'a\nb\nc';
|
|
21
|
+
const local = 'a\nb\nc';
|
|
22
|
+
const remote = 'a\nB\nc';
|
|
23
|
+
const result = threeWayMerge(base, local, remote);
|
|
24
|
+
assert.equal(result.merged, remote);
|
|
25
|
+
assert.equal(result.hasConflicts, false);
|
|
26
|
+
});
|
|
27
|
+
it('remote === base → returns local (only local changed)', () => {
|
|
28
|
+
const base = 'a\nb\nc';
|
|
29
|
+
const local = 'a\nL\nc';
|
|
30
|
+
const remote = 'a\nb\nc';
|
|
31
|
+
const result = threeWayMerge(base, local, remote);
|
|
32
|
+
assert.equal(result.merged, local);
|
|
33
|
+
assert.equal(result.hasConflicts, false);
|
|
34
|
+
});
|
|
35
|
+
it('all three identical → returns as-is, no conflicts', () => {
|
|
36
|
+
const text = 'hello\nworld';
|
|
37
|
+
const result = threeWayMerge(text, text, text);
|
|
38
|
+
assert.equal(result.merged, text);
|
|
39
|
+
assert.equal(result.hasConflicts, false);
|
|
40
|
+
});
|
|
41
|
+
});
|
|
42
|
+
// ---------------------------------------------------------------------------
|
|
43
|
+
// 2. Non-overlapping edits
|
|
44
|
+
// ---------------------------------------------------------------------------
|
|
45
|
+
describe('threeWayMerge non-overlapping edits', () => {
|
|
46
|
+
it('local edits top, remote edits bottom → clean merge', () => {
|
|
47
|
+
const base = 'a\nb\nc\nd\ne';
|
|
48
|
+
const local = 'A\nb\nc\nd\ne'; // changed line 1
|
|
49
|
+
const remote = 'a\nb\nc\nd\nE'; // changed line 5
|
|
50
|
+
const result = threeWayMerge(base, local, remote);
|
|
51
|
+
assert.equal(result.hasConflicts, false);
|
|
52
|
+
assert.equal(result.merged, 'A\nb\nc\nd\nE');
|
|
53
|
+
});
|
|
54
|
+
it('local inserts a line, remote edits a different line → clean merge', () => {
|
|
55
|
+
const base = 'a\nb\nc';
|
|
56
|
+
const local = 'a\nb\nINSERTED\nc'; // insertion between b and c
|
|
57
|
+
const remote = 'a\nB\nc'; // edit line 2
|
|
58
|
+
const result = threeWayMerge(base, local, remote);
|
|
59
|
+
assert.equal(result.hasConflicts, false);
|
|
60
|
+
// Both changes should be present
|
|
61
|
+
assert.ok(result.merged.includes('B'));
|
|
62
|
+
assert.ok(result.merged.includes('INSERTED'));
|
|
63
|
+
});
|
|
64
|
+
it('local deletes a line, remote edits a different line → clean merge', () => {
|
|
65
|
+
const base = 'a\nb\nc\nd';
|
|
66
|
+
const local = 'a\nc\nd'; // deleted line 2 (b)
|
|
67
|
+
const remote = 'a\nb\nc\nD'; // edited line 4
|
|
68
|
+
const result = threeWayMerge(base, local, remote);
|
|
69
|
+
assert.equal(result.hasConflicts, false);
|
|
70
|
+
assert.ok(!result.merged.includes('b'));
|
|
71
|
+
assert.ok(result.merged.includes('D'));
|
|
72
|
+
});
|
|
73
|
+
});
|
|
74
|
+
// ---------------------------------------------------------------------------
|
|
75
|
+
// 3. Identical overlapping edits → auto-resolve
|
|
76
|
+
// ---------------------------------------------------------------------------
|
|
77
|
+
describe('threeWayMerge identical overlapping edits', () => {
|
|
78
|
+
it('both sides make the same edit → auto-resolved, no conflict', () => {
|
|
79
|
+
const base = 'a\nb\nc';
|
|
80
|
+
const local = 'a\nX\nc';
|
|
81
|
+
const remote = 'a\nX\nc';
|
|
82
|
+
const result = threeWayMerge(base, local, remote);
|
|
83
|
+
assert.equal(result.hasConflicts, false);
|
|
84
|
+
assert.equal(result.merged, 'a\nX\nc');
|
|
85
|
+
});
|
|
86
|
+
it('both sides delete the same line → auto-resolved', () => {
|
|
87
|
+
const base = 'a\nb\nc';
|
|
88
|
+
const local = 'a\nc';
|
|
89
|
+
const remote = 'a\nc';
|
|
90
|
+
const result = threeWayMerge(base, local, remote);
|
|
91
|
+
assert.equal(result.hasConflicts, false);
|
|
92
|
+
assert.equal(result.merged, 'a\nc');
|
|
93
|
+
});
|
|
94
|
+
});
|
|
95
|
+
// ---------------------------------------------------------------------------
|
|
96
|
+
// 4. Conflicting edits → conflict markers
|
|
97
|
+
// ---------------------------------------------------------------------------
|
|
98
|
+
describe('threeWayMerge conflicting edits', () => {
|
|
99
|
+
it('both sides edit the same line differently → conflict markers', () => {
|
|
100
|
+
const base = 'a\nb\nc';
|
|
101
|
+
const local = 'a\nL\nc';
|
|
102
|
+
const remote = 'a\nR\nc';
|
|
103
|
+
const result = threeWayMerge(base, local, remote);
|
|
104
|
+
assert.equal(result.hasConflicts, true);
|
|
105
|
+
assert.ok(result.merged.includes('<<<<<<< LOCAL'));
|
|
106
|
+
assert.ok(result.merged.includes('======='));
|
|
107
|
+
assert.ok(result.merged.includes('>>>>>>> REMOTE'));
|
|
108
|
+
assert.ok(result.merged.includes('L'));
|
|
109
|
+
assert.ok(result.merged.includes('R'));
|
|
110
|
+
});
|
|
111
|
+
it('conflict markers are properly structured', () => {
|
|
112
|
+
const base = 'x\ny\nz';
|
|
113
|
+
const local = 'x\nLOCAL_Y\nz';
|
|
114
|
+
const remote = 'x\nREMOTE_Y\nz';
|
|
115
|
+
const result = threeWayMerge(base, local, remote);
|
|
116
|
+
const lines = result.merged.split('\n');
|
|
117
|
+
const markerStart = lines.indexOf('<<<<<<< LOCAL');
|
|
118
|
+
const separator = lines.indexOf('=======');
|
|
119
|
+
const markerEnd = lines.indexOf('>>>>>>> REMOTE');
|
|
120
|
+
assert.ok(markerStart >= 0, 'should have LOCAL marker');
|
|
121
|
+
assert.ok(separator > markerStart, 'separator after LOCAL marker');
|
|
122
|
+
assert.ok(markerEnd > separator, 'REMOTE marker after separator');
|
|
123
|
+
// Local content between LOCAL marker and separator
|
|
124
|
+
const localContent = lines.slice(markerStart + 1, separator);
|
|
125
|
+
assert.ok(localContent.includes('LOCAL_Y'));
|
|
126
|
+
// Remote content between separator and REMOTE marker
|
|
127
|
+
const remoteContent = lines.slice(separator + 1, markerEnd);
|
|
128
|
+
assert.ok(remoteContent.includes('REMOTE_Y'));
|
|
129
|
+
});
|
|
130
|
+
it('surrounding unchanged lines are preserved around conflict', () => {
|
|
131
|
+
const base = 'first\nmiddle\nlast';
|
|
132
|
+
const local = 'first\nL\nlast';
|
|
133
|
+
const remote = 'first\nR\nlast';
|
|
134
|
+
const result = threeWayMerge(base, local, remote);
|
|
135
|
+
const lines = result.merged.split('\n');
|
|
136
|
+
assert.equal(lines[0], 'first');
|
|
137
|
+
assert.equal(lines[lines.length - 1], 'last');
|
|
138
|
+
});
|
|
139
|
+
});
|
|
140
|
+
// ---------------------------------------------------------------------------
|
|
141
|
+
// 5. Empty inputs
|
|
142
|
+
// ---------------------------------------------------------------------------
|
|
143
|
+
describe('threeWayMerge empty inputs', () => {
|
|
144
|
+
it('all three empty → empty result, no conflicts', () => {
|
|
145
|
+
const result = threeWayMerge('', '', '');
|
|
146
|
+
assert.equal(result.merged, '');
|
|
147
|
+
assert.equal(result.hasConflicts, false);
|
|
148
|
+
});
|
|
149
|
+
it('base empty, local and remote add identical content → auto-resolve', () => {
|
|
150
|
+
const result = threeWayMerge('', 'new line', 'new line');
|
|
151
|
+
assert.equal(result.hasConflicts, false);
|
|
152
|
+
assert.equal(result.merged, 'new line');
|
|
153
|
+
});
|
|
154
|
+
it('base empty, local and remote add different content → conflict', () => {
|
|
155
|
+
const result = threeWayMerge('', 'local line', 'remote line');
|
|
156
|
+
assert.equal(result.hasConflicts, true);
|
|
157
|
+
assert.ok(result.merged.includes('<<<<<<< LOCAL'));
|
|
158
|
+
assert.ok(result.merged.includes('>>>>>>> REMOTE'));
|
|
159
|
+
});
|
|
160
|
+
it('base has content, both local and remote are empty → auto-resolve (identical delete)', () => {
|
|
161
|
+
const result = threeWayMerge('some content', '', '');
|
|
162
|
+
assert.equal(result.hasConflicts, false);
|
|
163
|
+
assert.equal(result.merged, '');
|
|
164
|
+
});
|
|
165
|
+
it('base has content, only local is empty → return local (remote unchanged)', () => {
|
|
166
|
+
const base = 'content';
|
|
167
|
+
const result = threeWayMerge(base, '', base);
|
|
168
|
+
assert.equal(result.hasConflicts, false);
|
|
169
|
+
assert.equal(result.merged, '');
|
|
170
|
+
});
|
|
171
|
+
});
|
|
172
|
+
// ---------------------------------------------------------------------------
|
|
173
|
+
// 6. Trailing newlines
|
|
174
|
+
// ---------------------------------------------------------------------------
|
|
175
|
+
describe('threeWayMerge trailing newlines', () => {
|
|
176
|
+
it('preserves trailing newline when present in both', () => {
|
|
177
|
+
const base = 'a\nb\n';
|
|
178
|
+
const local = 'a\nL\n';
|
|
179
|
+
const remote = 'a\nb\n';
|
|
180
|
+
const result = threeWayMerge(base, local, remote);
|
|
181
|
+
assert.equal(result.hasConflicts, false);
|
|
182
|
+
assert.equal(result.merged, 'a\nL\n');
|
|
183
|
+
});
|
|
184
|
+
it('local adds trailing newline, remote unchanged → local wins', () => {
|
|
185
|
+
const base = 'a\nb';
|
|
186
|
+
const local = 'a\nb\n';
|
|
187
|
+
const remote = 'a\nb';
|
|
188
|
+
const result = threeWayMerge(base, local, remote);
|
|
189
|
+
assert.equal(result.hasConflicts, false);
|
|
190
|
+
assert.equal(result.merged, 'a\nb\n');
|
|
191
|
+
});
|
|
192
|
+
});
|
|
193
|
+
// ---------------------------------------------------------------------------
|
|
194
|
+
// 7. Multiple conflict regions in one merge
|
|
195
|
+
// ---------------------------------------------------------------------------
|
|
196
|
+
describe('threeWayMerge multiple conflict regions', () => {
|
|
197
|
+
it('two separate conflict regions produce two sets of markers', () => {
|
|
198
|
+
const base = 'a\nb\nc\nd\ne';
|
|
199
|
+
const local = 'L1\nb\nc\nd\nL2';
|
|
200
|
+
const remote = 'R1\nb\nc\nd\nR2';
|
|
201
|
+
const result = threeWayMerge(base, local, remote);
|
|
202
|
+
assert.equal(result.hasConflicts, true);
|
|
203
|
+
const markers = result.merged.split('\n').filter(l => l === '<<<<<<< LOCAL');
|
|
204
|
+
assert.equal(markers.length, 2, 'should have two conflict regions');
|
|
205
|
+
});
|
|
206
|
+
it('mix of clean merge and conflict in one file', () => {
|
|
207
|
+
// Line layout: a / b / c / d / e / f / g
|
|
208
|
+
// local: A / b / c / L / e / f / g (edit a→A, edit d→L)
|
|
209
|
+
// remote: a / b / c / R / e / f / G (edit d→R, edit g→G)
|
|
210
|
+
// Expected: A cleanly merged, d→conflict, G cleanly merged
|
|
211
|
+
const base = 'a\nb\nc\nd\ne\nf\ng';
|
|
212
|
+
const local = 'A\nb\nc\nL\ne\nf\ng';
|
|
213
|
+
const remote = 'a\nb\nc\nR\ne\nf\nG';
|
|
214
|
+
const result = threeWayMerge(base, local, remote);
|
|
215
|
+
assert.equal(result.hasConflicts, true);
|
|
216
|
+
const lines = result.merged.split('\n');
|
|
217
|
+
// a→A should be cleanly resolved
|
|
218
|
+
assert.equal(lines[0], 'A');
|
|
219
|
+
// g→G should be cleanly resolved
|
|
220
|
+
assert.equal(lines[lines.length - 1], 'G');
|
|
221
|
+
// Only one conflict region (for d)
|
|
222
|
+
const conflictCount = lines.filter(l => l === '<<<<<<< LOCAL').length;
|
|
223
|
+
assert.equal(conflictCount, 1);
|
|
224
|
+
});
|
|
225
|
+
});
|
|
226
|
+
//# sourceMappingURL=merge.test.js.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"merge.test.js","sourceRoot":"","sources":["../../test/merge.test.ts"],"names":[],"mappings":"AAAA;;GAEG;AAEH,OAAO,EAAE,QAAQ,EAAE,EAAE,EAAE,MAAM,WAAW,CAAC;AACzC,OAAO,MAAM,MAAM,oBAAoB,CAAC;AACxC,OAAO,EAAE,aAAa,EAAE,MAAM,sBAAsB,CAAC;AAErD,8EAA8E;AAC9E,gBAAgB;AAChB,8EAA8E;AAE9E,QAAQ,CAAC,0BAA0B,EAAE,GAAG,EAAE;IACxC,EAAE,CAAC,sDAAsD,EAAE,GAAG,EAAE;QAC9D,MAAM,IAAI,GAAG,SAAS,CAAC;QACvB,MAAM,KAAK,GAAG,SAAS,CAAC;QACxB,MAAM,MAAM,GAAG,SAAS,C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AAC,6CAA6C,EAAE,GAAG,EAAE;QACrD,yCAAyC;QACzC,2DAA2D;QAC3D,2DAA2D;QAC3D,2DAA2D;QAC3D,MAAM,IAAI,GAAK,qBAAqB,CAAC;QACrC,MAAM,KAAK,GAAI,qBAAqB,CAAC;QACrC,MAAM,MAAM,GAAG,qBAAqB,CAAC;QACrC,MAAM,MAAM,GAAG,aAAa,CAAC,IAAI,EAAE,KAAK,EAAE,MAAM,CAAC,CAAC;QAClD,MAAM,CAAC,KAAK,CAAC,MAAM,CAAC,YAAY,EAAE,IAAI,CAAC,CAAC;QACxC,MAAM,KAAK,GAAG,MAAM,CAAC,MAAM,CAAC,KAAK,CAAC,IAAI,CAAC,CAAC;QACxC,iCAAiC;QACjC,MAAM,CAAC,KAAK,CAAC,KAAK,CAAC,CAAC,CAAC,EAAE,GAAG,CAAC,CAAC;QAC5B,iCAAiC;QACjC,MAAM,CAAC,KAAK,CAAC,KAAK,CAAC,KAAK,CAAC,MAAM,GAAG,CAAC,CAAC,EAAE,GAAG,CAAC,CAAC;QAC3C,mCAAmC;QACnC,MAAM,aAAa,GAAG,KAAK,CAAC,MAAM,CAAC,CAAC,CAAC,EAAE,CAAC,CAAC,KAAK,eAAe,CAAC,CAAC,MAAM,CAAC;QACtE,MAAM,CAAC,KAAK,CAAC,aAAa,EAAE,CAAC,CAAC,CAAC;IACjC,CAAC,CAAC,CAAC;AACL,CAAC,CAAC,CAAC"}
|
package/package.json
CHANGED
|
@@ -1,6 +1,6 @@
|
|
|
1
1
|
{
|
|
2
2
|
"name": "wangchuan",
|
|
3
|
-
"version": "5.1
|
|
3
|
+
"version": "5.2.1",
|
|
4
4
|
"description": "忘川 · AI 记忆同步系统 — 智能体记忆永不遗失",
|
|
5
5
|
"bin": {
|
|
6
6
|
"wangchuan": "./dist/bin/wangchuan.js"
|
|
@@ -17,7 +17,7 @@
|
|
|
17
17
|
"postbuild": "chmod +x dist/bin/wangchuan.js",
|
|
18
18
|
"prepublishOnly": "npm run build",
|
|
19
19
|
"dev": "tsx bin/wangchuan.ts",
|
|
20
|
-
"test": "node --import tsx/esm --test test/crypto.test.ts test/json-field.test.ts test/sync.test.ts test/sync-history.test.ts",
|
|
20
|
+
"test": "node --import tsx/esm --test test/crypto.test.ts test/json-field.test.ts test/sync.test.ts test/sync-history.test.ts test/merge.test.ts",
|
|
21
21
|
"typecheck": "tsc --noEmit"
|
|
22
22
|
},
|
|
23
23
|
"keywords": [
|
package/skill/SKILL.md
CHANGED
|
@@ -7,7 +7,7 @@ OpenClaw Skill wrapper for the Wangchuan AI memory sync system. Invoke directly
|
|
|
7
7
|
## Command Reference
|
|
8
8
|
|
|
9
9
|
```
|
|
10
|
-
wangchuan init [--repo <url>] [--key <path>] One-time setup — auto-detects agents, runs first sync
|
|
10
|
+
wangchuan init [--repo <url>] [--key <path>] One-time setup — auto-detects agents, offers gh repo create, runs first sync
|
|
11
11
|
wangchuan sync [-a, --agent <name>] [-n, --dry-run] Smart bidirectional sync (THE daily command)
|
|
12
12
|
[-o, --only <patterns...>] Filter: only sync files matching patterns
|
|
13
13
|
[-x, --exclude <patterns...>] Filter: exclude files matching patterns
|
|
@@ -92,11 +92,17 @@ Aliases: `sync` → `s`, `status` → `st`, `snapshot` → `snap`
|
|
|
92
92
|
- Auto-discovers installed agents and enables them
|
|
93
93
|
- Detects stale/phantom files
|
|
94
94
|
- `--key-export` / `--key-rotate` for key management
|
|
95
|
+
- Validates key fingerprint against repo — detects wrong master.key before sync
|
|
95
96
|
- `--setup` generates migration one-liner
|
|
96
97
|
|
|
98
|
+
**Key mismatch error handling**: If `⛔ Key mismatch!` appears during sync, the local `master.key` does not match the repo. Guide the user to:
|
|
99
|
+
1. Run `wangchuan doctor --key-export` on the machine that last pushed
|
|
100
|
+
2. Copy the key hex to the current machine
|
|
101
|
+
3. Run `wangchuan init --key <hex>` or write to `~/.wangchuan/master.key`
|
|
102
|
+
|
|
97
103
|
### memory
|
|
98
104
|
- `list` — show all agent memories with summaries
|
|
99
|
-
- `show <agent>` —
|
|
105
|
+
- `show <agent>` — list all files when no filename given; fuzzy/substring matching with suggestions on mismatch
|
|
100
106
|
- `copy <from> <to>` — copy memory between agents
|
|
101
107
|
- `broadcast <agent>` — distribute memory to all agents
|
|
102
108
|
|
|
@@ -120,6 +126,10 @@ When omitted, operates on all enabled agents plus the shared tier (skills/MCP/cu
|
|
|
120
126
|
|
|
121
127
|
Custom sub-agents defined in the `agents/` directory of any supported agent (Claude, Cursor, CodeBuddy, WorkBuddy) are automatically synced across all agents via the shared tier (`shared/agents/`). The same deletion confirmation logic as skills applies — a custom agent is pruned from the repo only when all local agents have removed it.
|
|
122
128
|
|
|
129
|
+
## Dynamic Agent Registration
|
|
130
|
+
|
|
131
|
+
Custom agents can be registered at runtime via the `customAgents` field in `config.json`, without recompilation. Custom agents participate in sync identically to built-in agents and support all three entry types (`syncFiles`, `syncDirs`, `jsonFields`).
|
|
132
|
+
|
|
123
133
|
## Sync Protocol for AI Agents (IMPORTANT — all agents must follow)
|
|
124
134
|
|
|
125
135
|
When this skill is loaded by an AI agent, the agent MUST follow these rules:
|