sync: update from private repo (6fcb0d0)

This commit is contained in:
oss-sync
2026-06-04 03:03:12 +00:00
parent 21be01b699
commit 57685d995c
36 changed files with 2467 additions and 391 deletions
+49 -2
View File
@@ -396,9 +396,9 @@ movements:
expect(() => loadPiece('multi', 'pieces', tempDir)).not.toThrow();
});
it('all 13 bundled pieces load without validation errors', () => {
it('all 12 bundled pieces load without validation errors', () => {
const piecesDir = join(process.cwd(), 'pieces');
const names = ['brainstorming', 'chat', 'data-process', 'game-tweet-generator', 'general',
const names = ['brainstorming', 'chat', 'data-process', 'general',
'office-process', 'piece-builder', 'research', 'slide', 'sns-research',
'ssh-console', 'ssh-ops', 'x-ai-digest'];
for (const name of names) {
@@ -1111,3 +1111,50 @@ describe('allowed_ssh_connections validation (Phase 4)', () => {
expect(() => validatePieceDef(piece)).toThrow(/Piece "ssh-test" has invalid allowed_ssh_connections/);
});
});
// --- Task 1: loadPiece multi-dir support ---
describe('loadPiece multi-dir (string | string[])', () => {
it('resolves from a list of custom dirs (per-user wins over builtin name miss)', () => {
const dirA = mkdtempSync(join(tmpdir(), 'pa-')); // empty
const dirB = mkdtempSync(join(tmpdir(), 'pb-'));
writeFileSync(
join(dirB, 'mycustom.yaml'),
`name: mycustom\ndescription: d\nmax_movements: 1\ninitial_movement: go\nmovements:\n - name: go\n edit: false\n persona: w\n instruction: x\n allowed_tools: []\n rules: []\n default_next: COMPLETE\n`,
);
// array form: searches dirA then dirB then builtin
const p = loadPiece('mycustom', 'pieces', [dirA, dirB]);
expect(p.name).toBe('mycustom');
// builtin still resolvable when not in any custom dir
expect(() => loadPiece('chat', 'pieces', [dirA, dirB])).not.toThrow();
rmSync(dirA, { recursive: true });
rmSync(dirB, { recursive: true });
});
it('first dir wins when same name appears in two custom dirs', () => {
const dirA = mkdtempSync(join(tmpdir(), 'pa-'));
const dirB = mkdtempSync(join(tmpdir(), 'pb-'));
writeFileSync(
join(dirA, 'dup.yaml'),
`name: dup\ndescription: from-a\nmax_movements: 1\ninitial_movement: go\nmovements:\n - name: go\n edit: false\n persona: w\n instruction: x\n allowed_tools: []\n rules: []\n default_next: COMPLETE\n`,
);
writeFileSync(
join(dirB, 'dup.yaml'),
`name: dup\ndescription: from-b\nmax_movements: 1\ninitial_movement: go\nmovements:\n - name: go\n edit: false\n persona: w\n instruction: x\n allowed_tools: []\n rules: []\n default_next: COMPLETE\n`,
);
const p = loadPiece('dup', 'pieces', [dirA, dirB]);
expect(p.description).toBe('from-a');
rmSync(dirA, { recursive: true });
rmSync(dirB, { recursive: true });
});
it('string form still works (backward compat)', () => {
const dir = mkdtempSync(join(tmpdir(), 'pc-'));
writeFileSync(
join(dir, 'strcompat.yaml'),
`name: strcompat\ndescription: str\nmax_movements: 1\ninitial_movement: go\nmovements:\n - name: go\n edit: false\n persona: w\n instruction: x\n allowed_tools: []\n rules: []\n default_next: COMPLETE\n`,
);
const p = loadPiece('strcompat', 'pieces', dir);
expect(p.name).toBe('strcompat');
rmSync(dir, { recursive: true });
});
});