@jc_stack/ez-library 0.1.0-beta.12
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/.dockerignore +12 -0
- package/.github/workflows/publish-beta.yml +40 -0
- package/CHANGELOG.md +57 -0
- package/CONTRIBUTING.md +89 -0
- package/Dockerfile +38 -0
- package/LICENSE +21 -0
- package/README.md +119 -0
- package/SECURITY.md +13 -0
- package/THIRD_PARTY_NOTICES.md +9 -0
- package/bin/ez-library.mjs +3 -0
- package/docker/fulltext-smoke.mjs +19 -0
- package/docker/github-smoke.mjs +114 -0
- package/docker/manager-smoke.mjs +53 -0
- package/docker/pnpm-lock.yaml +1443 -0
- package/docker/shared-smoke.mjs +81 -0
- package/docker/smoke.mjs +73 -0
- package/docker/sync-smoke.mjs +98 -0
- package/docker/text-mirror-smoke.mjs +42 -0
- package/docs/folder-sync.md +100 -0
- package/docs/github-sync.md +105 -0
- package/docs/named-libraries.md +75 -0
- package/docs/persistence.md +48 -0
- package/docs/rclone-LICENSE.txt +19 -0
- package/docs/releasing.md +74 -0
- package/docs/shared-embeddings.md +15 -0
- package/docs/text-mirror.md +54 -0
- package/ez-deployment.json +53 -0
- package/ez-plugin.json +15 -0
- package/package.json +69 -0
- package/patches/@tobilu__qmd@2.8.3.patch +60 -0
- package/scripts/publish-settings.mjs +101 -0
- package/scripts/release-check.mjs +16 -0
- package/skills/library/SKILL.md +104 -0
- package/src/cli.mjs +227 -0
- package/src/embedding-client.mjs +50 -0
- package/src/embedding-worker.mjs +59 -0
- package/src/git-mirror.mjs +121 -0
- package/src/git-sync.mjs +140 -0
- package/src/indexer.mjs +83 -0
- package/src/libraries.mjs +81 -0
- package/src/native.mjs +47 -0
- package/src/store.mjs +214 -0
- package/src/sync-worker.mjs +43 -0
- package/src/sync.mjs +172 -0
- package/test/embeddings.test.mjs +30 -0
- package/test/git-mirror.test.mjs +121 -0
- package/test/git-sync.test.mjs +135 -0
- package/test/indexer.test.mjs +73 -0
- package/test/libraries.test.mjs +132 -0
- package/test/library.test.mjs +163 -0
- package/test/publish-settings.test.mjs +101 -0
- package/test/sync.test.mjs +120 -0
|
@@ -0,0 +1,81 @@
|
|
|
1
|
+
// Two real manager registries, one isolated shared worker, synthetic documents.
|
|
2
|
+
import assert from 'node:assert/strict';
|
|
3
|
+
import * as fs from 'node:fs/promises';
|
|
4
|
+
import path from 'node:path';
|
|
5
|
+
import os from 'node:os';
|
|
6
|
+
import { pathToFileURL, fileURLToPath } from 'node:url';
|
|
7
|
+
import { execFile } from 'node:child_process';
|
|
8
|
+
import { promisify } from 'node:util';
|
|
9
|
+
import { setTimeout } from 'node:timers/promises';
|
|
10
|
+
const exec = promisify(execFile);
|
|
11
|
+
const modulePath = process.env.EZ_MANAGER_MODULE;
|
|
12
|
+
if (!modulePath || !path.isAbsolute(modulePath)) throw Error('Set EZ_MANAGER_MODULE');
|
|
13
|
+
const { snapshot, init } = await import(pathToFileURL(modulePath));
|
|
14
|
+
const bin = path.resolve(path.dirname(modulePath), '../../bin/ezenciel-agents-tools.mjs');
|
|
15
|
+
const root = await fs.mkdtemp(path.join(os.tmpdir(), 'ez-shared-qa-'));
|
|
16
|
+
const source = path.join(root, 'source'), homes = [path.join(root, 'a'), path.join(root, 'b')];
|
|
17
|
+
const records = [];
|
|
18
|
+
const docker = async args => (await exec('docker', args, { maxBuffer: 16 * 1024 * 1024 })).stdout;
|
|
19
|
+
const call = async (home, args) => (await exec(process.execPath, [bin, '--home', home, ...args], { maxBuffer: 16 * 1024 * 1024, timeout: 1200000 })).stdout;
|
|
20
|
+
console.log(JSON.stringify({ qaRoot: root }));
|
|
21
|
+
const original = await snapshot(fileURLToPath(new URL('../', import.meta.url)));
|
|
22
|
+
for (const [name, f] of original.files) { const target = path.join(source, name); await fs.mkdir(path.dirname(target), { recursive: true }); await fs.writeFile(target, f.data, { mode: f.mode }); }
|
|
23
|
+
const descriptor = JSON.parse(await fs.readFile(path.join(source, 'ez-deployment.json')));
|
|
24
|
+
descriptor.sharedServices.embeddings.identity = 'embedding-qa-' + path.basename(root).toLowerCase();
|
|
25
|
+
await fs.writeFile(path.join(source, 'ez-deployment.json'), JSON.stringify(descriptor));
|
|
26
|
+
const shared = 'ez-shared-' + descriptor.sharedServices.embeddings.identity;
|
|
27
|
+
const candidate = await snapshot(source);
|
|
28
|
+
try {
|
|
29
|
+
for (const [i, home] of homes.entries()) {
|
|
30
|
+
const mind = home + '-mind'; await fs.mkdir(mind);
|
|
31
|
+
await init(home, mind, undefined, undefined, true);
|
|
32
|
+
await call(home, ['plugins', 'install', 'library', '--source', source, '--revision', candidate.revision]);
|
|
33
|
+
const record = JSON.parse(await fs.readFile(path.join(home, 'registry.json'))).plugins.library; records.push(record);
|
|
34
|
+
await call(home, ['plugins', 'start', 'library']);
|
|
35
|
+
assert.equal(JSON.parse(await call(home, ['library', 'doctor'])).data.embeddings.service.state, 'off');
|
|
36
|
+
// Synthetic files enter this agent's own volume; no shared document mount.
|
|
37
|
+
const note = i === 0 ? '# Moonfruit\nThe orange cat sleeps on the warm windowsill.' : '# Starberry\nThe blue sailboat crosses the windy ocean.';
|
|
38
|
+
await docker(['compose', '-p', record.project, '-f', record.compose, 'exec', '-T', 'library', 'node', '-e', 'require("fs").mkdirSync("/state/files",{recursive:true});require("fs").writeFileSync("/state/files/note.md",process.argv[1])', note]);
|
|
39
|
+
await call(home, ['library', 'qmd', 'collection', 'add', '/state/files', '--name', 'library']);
|
|
40
|
+
assert.match(await call(home, ['library', 'qmd', 'search', i === 0 ? 'Moonfruit' : 'Starberry', '--json']), /note.md/);
|
|
41
|
+
assert.equal((await docker(['ps', '-aq', '--filter', `name=^/${shared}$`])).trim(), '');
|
|
42
|
+
}
|
|
43
|
+
await Promise.all(homes.map(home => call(home, ['plugins', 'shared-enable', 'library', 'embeddings'])));
|
|
44
|
+
assert.equal(JSON.parse(await docker(['inspect', shared]))[0].HostConfig.NanoCpus, 500000000);
|
|
45
|
+
console.log('Both clients enabled; waiting for model and private indexes');
|
|
46
|
+
let ready = false;
|
|
47
|
+
for (let attempt = 0; attempt < 120; attempt++) {
|
|
48
|
+
const statuses = await Promise.all(homes.map(async home => JSON.parse(await call(home, ['library', 'doctor'])).data.embeddings));
|
|
49
|
+
if (statuses.every(s => s.service.state === 'ready' && s.index.state === 'ready')) { ready = true; break; }
|
|
50
|
+
if (attempt % 6 === 0) console.log(JSON.stringify({ attempt, statuses }));
|
|
51
|
+
await setTimeout(10000);
|
|
52
|
+
}
|
|
53
|
+
assert(ready, 'Both indexes must become ready automatically');
|
|
54
|
+
assert.equal((await docker(['ps', '-q', '--filter', `name=^/${shared}$`])).trim().split('\n').length, 1);
|
|
55
|
+
const query = (home, text) => call(home, ['library', 'qmd', 'query', 'vec: ' + text, '-c', 'library', '--no-rerank', '--json']);
|
|
56
|
+
const results = await Promise.all([query(homes[0], 'a resting pet'), query(homes[1], 'a vessel at sea')]);
|
|
57
|
+
assert.match(results[0], /Moonfruit/); assert.doesNotMatch(results[0], /Starberry/);
|
|
58
|
+
assert.match(results[1], /Starberry/); assert.doesNotMatch(results[1], /Moonfruit/);
|
|
59
|
+
for (const record of records) {
|
|
60
|
+
const models = await docker(['compose', '-p', record.project, '-f', record.compose, 'exec', '-T', 'library', 'node', '-e', 'console.log(require("fs").readdirSync("/state/qmd/cache/qmd/models"))']);
|
|
61
|
+
assert(!models.includes('.gguf'));
|
|
62
|
+
}
|
|
63
|
+
await docker(['restart', shared]);
|
|
64
|
+
for (let i = 0; i < 60; i++) {
|
|
65
|
+
if (JSON.parse(await call(homes[1], ['library', 'doctor'])).data.embeddings.service.state === 'ready') break;
|
|
66
|
+
await setTimeout(2000);
|
|
67
|
+
}
|
|
68
|
+
await call(homes[0], ['plugins', 'shared-disable', 'library', 'embeddings']);
|
|
69
|
+
assert.equal(JSON.parse(await call(homes[0], ['library', 'doctor'])).data.embeddings.service.state, 'off');
|
|
70
|
+
await call(homes[0], ['plugins', 'uninstall', 'library']);
|
|
71
|
+
assert.match(await query(homes[1], 'ocean travel'), /Starberry/);
|
|
72
|
+
await docker(['stop', shared]);
|
|
73
|
+
assert.equal(JSON.parse(await call(homes[1], ['library', 'doctor'])).data.embeddings.service.state, 'unavailable');
|
|
74
|
+
await assert.rejects(query(homes[1], 'ocean travel'));
|
|
75
|
+
assert.match(await call(homes[1], ['library', 'qmd', 'search', 'Starberry', '--json']), /note.md/);
|
|
76
|
+
console.log(JSON.stringify({ ok: true, sourceRevision: original.revision, checks: ['default-off', 'concurrent-single-worker', 'half-core-cpu-quota', 'automatic-private-indexing', 'real-semantic-retrieval', 'private-corpora', 'no-client-model-download', 'worker-restart', 'detach-uninstall-preserves-other-agent', 'unavailable-with-keyword-search'] }));
|
|
77
|
+
} finally {
|
|
78
|
+
for (const record of records) await docker(['compose', '-p', record.project, '-f', record.compose, 'down', '--volumes']).catch(() => {});
|
|
79
|
+
await docker(['rm', '-f', shared]).catch(() => {});
|
|
80
|
+
for (const suffix of ['ipc', 'models']) await docker(['volume', 'rm', `${shared}-${suffix}`]).catch(() => {});
|
|
81
|
+
}
|
package/docker/smoke.mjs
ADDED
|
@@ -0,0 +1,73 @@
|
|
|
1
|
+
// Explicit Docker integration with synthetic data; no provider accounts.
|
|
2
|
+
import assert from 'node:assert/strict';
|
|
3
|
+
import { execFileSync } from 'node:child_process';
|
|
4
|
+
import { randomUUID, createHash } from 'node:crypto';
|
|
5
|
+
|
|
6
|
+
const image = process.env.EZ_LIBRARY_IMAGE || 'ez-library:local';
|
|
7
|
+
const volume = 'ez-library-qa-' + randomUUID();
|
|
8
|
+
const docker = (args, input) => execFileSync('docker', args, { input, encoding: 'utf8', maxBuffer: 8 * 1024 * 1024, timeout: 180000 });
|
|
9
|
+
const ipc = process.env.EZ_LIBRARY_EMBED_IPC;
|
|
10
|
+
const lastCpu = Math.max(0, Math.min(4, Number(docker(['info', '--format', '{{.NCPU}}']).trim())) - 1);
|
|
11
|
+
const call = (args, input) => docker(['run', '--rm', '--network', 'none', '--cap-drop', 'ALL', '--security-opt', 'no-new-privileges',
|
|
12
|
+
'--cpuset-cpus', `0-${lastCpu}`, '--memory', '4g', '-i', '-v', volume + ':/state',
|
|
13
|
+
...(ipc ? ['-v', ipc + ':/inference:ro', '-e', 'EZ_LIBRARY_EMBED_SOCKET=/inference/worker.sock'] : []),
|
|
14
|
+
image, 'node', '/app/bin/ez-library.mjs', ...args], input);
|
|
15
|
+
const parsed = (args, input) => JSON.parse(call(args, input)).data;
|
|
16
|
+
try {
|
|
17
|
+
docker(['volume', 'create', volume]);
|
|
18
|
+
assert.match(call(['--help']), /Local library/);
|
|
19
|
+
assert.equal(parsed(['doctor']).configured, false);
|
|
20
|
+
parsed(['configure', '--expected', 'new', '--key', 'settings'], JSON.stringify({ schemaVersion: 1, storage: { mode: 'local' }, backup: { mode: 'off' } }));
|
|
21
|
+
const note = '# Travel checklist\n\nPassport, charger and toothbrush.\n';
|
|
22
|
+
const receipt = parsed(['put', '--path', 'notes/travel.md', '--expected', 'new', '--key', 'travel'], note);
|
|
23
|
+
assert.equal(receipt.sha256, createHash('sha256').update(note).digest('hex'));
|
|
24
|
+
assert.equal(call(['get', '--path', 'notes/travel.md', '--raw']), note);
|
|
25
|
+
assert.equal(parsed(['put', '--path', 'notes/travel.md', '--expected', 'new', '--key', 'travel'], note).replay, true);
|
|
26
|
+
// Separate command containers demonstrate persistent data, not process-local state.
|
|
27
|
+
assert.equal(parsed(['operation', '--key', 'travel']).state, 'stored');
|
|
28
|
+
const media = '%PDF-1.7\nSynthetic attachment fixture\n';
|
|
29
|
+
parsed(['put', '--path', 'attachments/example.pdf', '--expected', 'new', '--key', 'pdf'], media);
|
|
30
|
+
assert.equal(call(['get', '--path', 'attachments/example.pdf', '--raw']), media);
|
|
31
|
+
// A real, synthetic one-page PDF exercises Poppler rather than just byte storage.
|
|
32
|
+
const stream = 'BT /F1 12 Tf 40 100 Td (Synthetic lease: renewal is October 2030.) Tj ET';
|
|
33
|
+
const objects = ['<< /Type /Catalog /Pages 2 0 R >>',
|
|
34
|
+
'<< /Type /Pages /Kids [3 0 R] /Count 1 >>',
|
|
35
|
+
'<< /Type /Page /Parent 2 0 R /MediaBox [0 0 300 200] /Resources << /Font << /F1 4 0 R >> >> /Contents 5 0 R >>',
|
|
36
|
+
'<< /Type /Font /Subtype /Type1 /BaseFont /Helvetica >>',
|
|
37
|
+
`<< /Length ${stream.length} >>\nstream\n${stream}\nendstream`];
|
|
38
|
+
let pdf = '%PDF-1.4\n'; const offsets = [0];
|
|
39
|
+
for (const [i, object] of objects.entries()) { offsets.push(pdf.length); pdf += `${i + 1} 0 obj\n${object}\nendobj\n`; }
|
|
40
|
+
const xref = pdf.length;
|
|
41
|
+
pdf += `xref\n0 6\n0000000000 65535 f \n${offsets.slice(1).map(n => String(n).padStart(10, '0') + ' 00000 n ').join('\n')}\ntrailer\n<< /Size 6 /Root 1 0 R >>\nstartxref\n${xref}\n%%EOF\n`;
|
|
42
|
+
const original = parsed(['put', '--path', 'attachments/lease.pdf', '--expected', 'new', '--key', 'lease'], pdf);
|
|
43
|
+
const extracted = call(['pdf-text', '--path', 'attachments/lease.pdf']);
|
|
44
|
+
assert.match(extracted, /renewal is October 2030/); assert.match(extracted, /\f/);
|
|
45
|
+
assert.equal(parsed(['get', '--path', 'attachments/lease.pdf']).sha256, original.sha256);
|
|
46
|
+
parsed(['put', '--path', 'notes/lease.md', '--expected', 'new', '--key', 'lease-text'], '# Lease\nSource: attachments/lease.pdf\nPage 1\n' + extracted);
|
|
47
|
+
assert.throws(() => call(['pdf-text', '--path', 'attachments/example.pdf']), error => error.status !== 0);
|
|
48
|
+
parsed(['put', '--path', 'notes/reading.txt', '--expected', 'new', '--key', 'txt'], 'A quasar reading list.\n');
|
|
49
|
+
call(['qmd', 'collection', 'add', '/state/files', '--name', 'library', '--mask', '**/*.{md,txt}']);
|
|
50
|
+
assert.match(call(['qmd', 'search', 'renewal', '-c', 'library', '--json']), /lease\.md/);
|
|
51
|
+
assert.match(call(['qmd', 'search', 'passport', '-c', 'library', '--json']), /travel\.md/);
|
|
52
|
+
assert.match(call(['qmd', 'search', 'quasar', '-c', 'library', '--json']), /reading\.txt/);
|
|
53
|
+
assert.match(call(['qmd', 'get', 'qmd://library/notes/travel.md']), /Passport, charger and toothbrush/);
|
|
54
|
+
if (ipc) {
|
|
55
|
+
call(['qmd', 'embed', '--no-gpu', '--max-docs-per-batch', '8']);
|
|
56
|
+
assert.match(call(['qmd', 'query', 'vec: What should I pack for a trip?', '-c', 'library', '--no-rerank', '--json', '-n', '5']), /travel\.md/);
|
|
57
|
+
}
|
|
58
|
+
parsed(['source-add', '--name', 'work', '--description', 'Synthetic work notes']);
|
|
59
|
+
assert.equal(parsed(['sources']).selectionRequired, true);
|
|
60
|
+
assert.throws(() => call(['put', '--path', 'notes/travel.md', '--expected', 'new', '--key', 'ambiguous'], 'wrong'), error => error.status === 2);
|
|
61
|
+
parsed(['put', '--library', 'work', '--path', 'notes/travel.md', '--expected', 'new', '--key', 'travel'], '# Work\nPassport approval policy.');
|
|
62
|
+
call(['qmd', '--library', 'work', 'collection', 'add', '/state/libraries/work/files', '--name', 'library', '--mask', '**/*.{md,txt}']);
|
|
63
|
+
const combined = parsed(['search', 'passport', '--all']);
|
|
64
|
+
assert.equal(combined.complete, true);
|
|
65
|
+
assert.deepEqual(combined.libraries.map(x => x.library), ['default', 'work']);
|
|
66
|
+
for (const item of combined.libraries) {
|
|
67
|
+
assert.equal(item.results[0].library, item.library);
|
|
68
|
+
assert.match(item.results[0].file, /travel\.md/);
|
|
69
|
+
}
|
|
70
|
+
assert.equal(call(['get', '--library', 'default', '--path', 'notes/travel.md', '--raw']), note);
|
|
71
|
+
assert.match(call(['get', '--library', 'work', '--path', 'notes/travel.md', '--raw']), /approval policy/);
|
|
72
|
+
console.log(JSON.stringify({ ok: true, checks: ['help-without-state', 'configuration', 'intake-readback', 'idempotency', 'restart-persistence', 'attachment-bytes', 'pdf-extraction-and-retrieval', 'native-qmd-keyword', 'named-library-isolation-and-search', ...(ipc ? ['shared-qmd-semantic'] : [])] }));
|
|
73
|
+
} finally { docker(['volume', 'rm', volume]); }
|
|
@@ -0,0 +1,98 @@
|
|
|
1
|
+
// Real native-engine integration, synthetic files only, no cloud credentials.
|
|
2
|
+
import assert from 'node:assert/strict';
|
|
3
|
+
import { execFileSync } from 'node:child_process';
|
|
4
|
+
import { randomUUID } from 'node:crypto';
|
|
5
|
+
import { setTimeout } from 'node:timers/promises';
|
|
6
|
+
|
|
7
|
+
const image = process.env.EZ_LIBRARY_IMAGE || 'ez-library:local';
|
|
8
|
+
const ipc = process.env.EZ_LIBRARY_EMBED_IPC;
|
|
9
|
+
const id = 'ez-library-sync-qa-' + randomUUID();
|
|
10
|
+
const docker = (args, input) => execFileSync('docker', args, { input, encoding: 'utf8', maxBuffer: 8 * 1024 * 1024, timeout: 180000, stdio: ['pipe', 'pipe', 'pipe'] });
|
|
11
|
+
const call = (args, input) => docker(['exec', '-i', id, 'node', '/app/bin/ez-library.mjs', ...args], input);
|
|
12
|
+
const parsed = (args, input) => JSON.parse(call(args, input)).data;
|
|
13
|
+
const edit = script => docker(['exec', '-i', id, 'node', '--input-type=module', '-e', "import * as fs from 'node:fs/promises';\n" + script]);
|
|
14
|
+
const mounts = ['-v', id + ':/state', '-v', id + '-external:/external', ...(ipc ? ['-v', ipc + ':/inference:ro', '-e', 'EZ_LIBRARY_EMBED_SOCKET=/inference/worker.sock'] : [])];
|
|
15
|
+
const start = (worker = false) => docker(['run', '-d', '--name', id, '--network', 'none', '--cap-drop', 'ALL', '--security-opt', 'no-new-privileges', '--cpus', '4', '--memory', '4g', ...mounts, image, ...(worker ? [] : ['sleep', 'infinity'])]);
|
|
16
|
+
function pdf(text) {
|
|
17
|
+
const stream = `BT /F1 12 Tf 40 100 Td (${text}) Tj ET`;
|
|
18
|
+
const objects = ['<< /Type /Catalog /Pages 2 0 R >>', '<< /Type /Pages /Kids [3 0 R] /Count 1 >>',
|
|
19
|
+
'<< /Type /Page /Parent 2 0 R /MediaBox [0 0 500 200] /Resources << /Font << /F1 4 0 R >> >> /Contents 5 0 R >>',
|
|
20
|
+
'<< /Type /Font /Subtype /Type1 /BaseFont /Helvetica >>', `<< /Length ${stream.length} >>\nstream\n${stream}\nendstream`];
|
|
21
|
+
let content = '%PDF-1.4\n'; const offsets = [];
|
|
22
|
+
for (const [i, object] of objects.entries()) { offsets.push(content.length); content += `${i + 1} 0 obj\n${object}\nendobj\n`; }
|
|
23
|
+
const xref = content.length;
|
|
24
|
+
return content + `xref\n0 6\n0000000000 65535 f \n${offsets.map(n => String(n).padStart(10, '0') + ' 00000 n ').join('\n')}\ntrailer\n<< /Size 6 /Root 1 0 R >>\nstartxref\n${xref}\n%%EOF\n`;
|
|
25
|
+
}
|
|
26
|
+
try {
|
|
27
|
+
docker(['volume', 'create', id]); docker(['volume', 'create', id + '-external']);
|
|
28
|
+
docker(['run', '--rm', '--user', 'root', ...mounts, image, 'chown', '1000:1000', '/external']);
|
|
29
|
+
start();
|
|
30
|
+
edit(`await fs.mkdir('/external/existing'); await fs.mkdir('/external/empty-directory');
|
|
31
|
+
for (let i=0;i<5;i++) await fs.writeFile('/external/existing/note'+i+'.md', '# Original note '+i+'\\nAmber telescopes record the night sky.');
|
|
32
|
+
await fs.writeFile('/external/empty.txt','');`);
|
|
33
|
+
edit(`await fs.writeFile('/external/lease.pdf',${JSON.stringify(pdf('Lease renewal: November 2032.'))});`);
|
|
34
|
+
assert.equal(parsed(['sync-plan', '--remote', '/external']).remoteFiles, 7);
|
|
35
|
+
parsed(['sync-adopt', '--remote', '/external']);
|
|
36
|
+
assert.equal(parsed(['sync-run']).state, 'synced-and-indexed');
|
|
37
|
+
if (ipc) assert.match(call(['qmd', 'query', 'vec: observing stars at night', '-c', 'library', '--no-rerank', '--json', '-n', '3']), /note/);
|
|
38
|
+
assert.match(call(['qmd', 'search', 'November', '-c', 'library-pdf', '--json']), /lease\.pdf\.md/);
|
|
39
|
+
if (ipc) assert.match(call(['qmd', 'query', 'vec: When does the lease renew?', '-c', 'library-pdf', '--no-rerank', '--json', '-n', '3']), /lease\.pdf\.md/);
|
|
40
|
+
edit(`await fs.writeFile('/external/lease.pdf',${JSON.stringify(pdf('Lease renewal: December 2033.'))});`);
|
|
41
|
+
parsed(['sync-run']);
|
|
42
|
+
assert.match(call(['qmd', 'search', 'December', '-c', 'library-pdf', '--json']), /lease\.pdf\.md/);
|
|
43
|
+
assert.doesNotMatch(call(['qmd', 'search', 'November', '-c', 'library-pdf', '--json']), /lease\.pdf\.md/);
|
|
44
|
+
|
|
45
|
+
edit(`await fs.writeFile('/external/new.md', '# New arrival\\nA cobalt otter lives beside the river.');`);
|
|
46
|
+
parsed(['sync-run']);
|
|
47
|
+
assert.match(call(['qmd', 'search', 'cobalt', '--json']), /new\.md/);
|
|
48
|
+
const saved = parsed(['put', '--path', 'agent.md', '--key', 'agent', '--expected', 'new'], '# Agent organization\nSaffron notebook.');
|
|
49
|
+
parsed(['sync-run']);
|
|
50
|
+
assert.match(edit(`process.stdout.write(await fs.readFile('/external/agent.md','utf8'));`), /Saffron/);
|
|
51
|
+
parsed(['move', '--path', 'agent.md', '--to', 'organized/agent.md', '--key', 'organize', '--expected', saved.sha256]);
|
|
52
|
+
parsed(['sync-run']);
|
|
53
|
+
assert.match(edit(`process.stdout.write(await fs.readFile('/external/organized/agent.md','utf8'));`), /Saffron/);
|
|
54
|
+
assert.throws(() => edit(`await fs.stat('/external/agent.md');`));
|
|
55
|
+
|
|
56
|
+
// Simultaneous revisions must survive on both sides, without choosing a winner.
|
|
57
|
+
edit(`await fs.writeFile('/external/new.md','Remote revision'); await fs.writeFile('/state/files/new.md','Local revision');`);
|
|
58
|
+
parsed(['sync-run']);
|
|
59
|
+
const conflictNames = JSON.parse(edit(`process.stdout.write(JSON.stringify((await fs.readdir('/external')).filter(x=>x.includes('conflict'))));`));
|
|
60
|
+
assert.equal(conflictNames.length, 2);
|
|
61
|
+
const versions = conflictNames.map(name => edit(`process.stdout.write(await fs.readFile('/external/'+${JSON.stringify(name)},'utf8'));`)).sort();
|
|
62
|
+
assert.deepEqual(versions, ['Local revision', 'Remote revision']);
|
|
63
|
+
|
|
64
|
+
// External deletion and rename update the searchable working tree.
|
|
65
|
+
edit(`await fs.unlink('/external/existing/note0.md'); await fs.rename('/external/existing/note1.md','/external/renamed.md');`);
|
|
66
|
+
parsed(['sync-run']);
|
|
67
|
+
assert.throws(() => call(['get', '--path', 'existing/note0.md']));
|
|
68
|
+
assert.match(call(['get', '--path', 'renamed.md', '--raw']), /Original note 1/);
|
|
69
|
+
assert.doesNotMatch(call(['qmd', 'search', 'telescopes', '--json', '-n', '20']), /note0\.md|note1\.md/);
|
|
70
|
+
|
|
71
|
+
// Run the actual resident worker, then restart it with the same volumes.
|
|
72
|
+
docker(['rm', '-f', id]); start(true);
|
|
73
|
+
edit(`await fs.writeFile('/external/watched.md','# Automatic arrival\\nTangerine satellites orbit Jupiter.');`);
|
|
74
|
+
let ready = false;
|
|
75
|
+
for (let i = 0; i < 45; i++) {
|
|
76
|
+
await setTimeout(2000);
|
|
77
|
+
const status = parsed(['sync-status']);
|
|
78
|
+
if (['synced-and-indexed', 'synced-with-conflicts'].includes(status.status?.state)) {
|
|
79
|
+
try { if (call(['qmd', 'search', 'Tangerine', '--json']).includes('watched.md')) { ready = true; break; } } catch {}
|
|
80
|
+
}
|
|
81
|
+
}
|
|
82
|
+
assert(ready, 'Resident worker must discover and index an external addition');
|
|
83
|
+
docker(['restart', id]);
|
|
84
|
+
await setTimeout(3000);
|
|
85
|
+
assert.equal(parsed(['sync-status']).config.mode, 'two-way');
|
|
86
|
+
// Missing access marker must stop propagation, retaining local originals.
|
|
87
|
+
edit(`await fs.unlink('/external/LIBRARY_SYNC_ACCESS');`);
|
|
88
|
+
for (let i = 0; i < 40; i++) {
|
|
89
|
+
await setTimeout(2000);
|
|
90
|
+
if (parsed(['sync-status']).status?.state === 'sync-error') break;
|
|
91
|
+
}
|
|
92
|
+
assert.equal(parsed(['sync-status']).status.state, 'sync-error');
|
|
93
|
+
assert.match(call(['get', '--path', 'watched.md', '--raw']), /Tangerine/);
|
|
94
|
+
console.log(JSON.stringify({ ok: true, checks: ['existing-folder-adoption', 'empty-files-and-folders', 'native-keyword-index', 'pdf-automatic-extraction', ...(ipc ? ['shared-semantic-index'] : []), 'pdf-replacement-removes-stale-text', 'external-add-and-index', 'agent-save-and-rename', 'preserve-both-conflicts', 'external-delete-and-rename', 'resident-auto-detection', 'restart-persistence', 'missing-marker-stops-sync'] }));
|
|
95
|
+
} finally {
|
|
96
|
+
try { docker(['rm', '-f', id]); } catch {}
|
|
97
|
+
docker(['volume', 'rm', id, id + '-external']);
|
|
98
|
+
}
|
|
@@ -0,0 +1,42 @@
|
|
|
1
|
+
// Synthetic folder <-> agent <-> Git history, no provider accounts or model downloads.
|
|
2
|
+
import assert from 'node:assert/strict';
|
|
3
|
+
import { execFileSync } from 'node:child_process';
|
|
4
|
+
import { randomUUID } from 'node:crypto';
|
|
5
|
+
const image = process.env.EZ_LIBRARY_IMAGE || 'ez-library:local';
|
|
6
|
+
const id = 'ez-library-mirror-qa-' + randomUUID();
|
|
7
|
+
const docker = (args, input) => execFileSync('docker', args, { input, encoding: 'utf8', maxBuffer: 8 * 1024 * 1024, timeout: 180000 });
|
|
8
|
+
const call = (args, input) => docker(['exec', '-i', id, 'node', '/app/bin/ez-library.mjs', ...args], input);
|
|
9
|
+
const parsed = (args, input) => JSON.parse(call(args, input)).data;
|
|
10
|
+
const edit = script => docker(['exec', id, 'node', '--input-type=module', '-e', "import * as fs from 'node:fs/promises';\n" + script]);
|
|
11
|
+
const git = args => docker(['exec', id, 'git', '--git-dir=/external/history.git', ...args]);
|
|
12
|
+
try {
|
|
13
|
+
docker(['volume', 'create', id]); docker(['volume', 'create', id + '-external']);
|
|
14
|
+
docker(['run', '--rm', '--user', 'root', '-v', id + '-external:/external', image, 'chown', '1000:1000', '/external']);
|
|
15
|
+
docker(['run', '-d', '--name', id, '--network', 'none', '--cap-drop', 'ALL', '--security-opt', 'no-new-privileges', '--memory', '4g', '-e', 'EZ_LIBRARY_EMBED=0', '-v', id + ':/state', '-v', id + '-external:/external', image, 'sleep', 'infinity']);
|
|
16
|
+
edit("await fs.mkdir('/external/vault'); await fs.mkdir('/external/vault/_attachments'); await fs.writeFile('/external/vault/note.md', '# Telescope\\nOriginal PC note.'); await fs.writeFile('/external/vault/_attachments/image.png', 'synthetic bytes');");
|
|
17
|
+
docker(['exec', id, 'git', 'init', '--bare', '--initial-branch=main', '/external/history.git']);
|
|
18
|
+
parsed(['source-add', '--name', 'notes', '--description', 'Synthetic PC notes']);
|
|
19
|
+
parsed(['sync-adopt', '--library', 'notes', '--remote', '/external/vault']);
|
|
20
|
+
parsed(['git-mirror-adopt', '--library', 'notes', '--repository', '/external/history.git']);
|
|
21
|
+
const first = parsed(['sync-run', '--library', 'notes']);
|
|
22
|
+
assert.equal(first.textMirror.remoteVerified, true);
|
|
23
|
+
assert.equal(git(['ls-tree', '-r', '--name-only', 'main']).trim(), 'note.md');
|
|
24
|
+
edit("await fs.writeFile('/external/vault/note.md', '# Telescope\\nEdited on PC: amber telescope.');");
|
|
25
|
+
const pc = parsed(['sync-run', '--library', 'notes']);
|
|
26
|
+
assert.notEqual(pc.textMirror.commit, first.textMirror.commit);
|
|
27
|
+
assert.match(git(['show', 'main:note.md']), /Edited on PC/);
|
|
28
|
+
assert.match(call(['search', 'amber', '--library', 'notes']), /note\.md/);
|
|
29
|
+
const note = parsed(['get', '--library', 'notes', '--path', 'note.md']);
|
|
30
|
+
parsed(['move', '--library', 'notes', '--path', 'note.md', '--to', 'organized/note.md', '--expected', note.sha256, '--key', 'organize']);
|
|
31
|
+
parsed(['sync-run', '--library', 'notes']);
|
|
32
|
+
assert.match(edit("process.stdout.write(await fs.readFile('/external/vault/organized/note.md','utf8'));"), /Edited on PC/);
|
|
33
|
+
assert.equal(git(['ls-tree', '-r', '--name-only', 'main']).trim(), 'organized/note.md');
|
|
34
|
+
assert.match(git(['show', first.textMirror.commit + ':note.md']), /Original PC note/);
|
|
35
|
+
assert.equal(edit("process.stdout.write(await fs.readFile('/external/vault/_attachments/image.png','utf8'));"), 'synthetic bytes');
|
|
36
|
+
docker(['restart', id]);
|
|
37
|
+
assert.equal(parsed(['git-mirror-status', '--library', 'notes']).config.lastCommit, git(['rev-parse', 'main']).trim());
|
|
38
|
+
console.log(JSON.stringify({ ok: true, checks: ['pc-edit-to-git', 'agent-organize-to-folder', 'keyword-retrieval', 'media-exclusion', 'history-readback', 'restart-persistence'] }));
|
|
39
|
+
} finally {
|
|
40
|
+
docker(['rm', '-f', id]);
|
|
41
|
+
docker(['volume', 'rm', id, id + '-external']);
|
|
42
|
+
}
|
|
@@ -0,0 +1,100 @@
|
|
|
1
|
+
# Existing folders as working libraries
|
|
2
|
+
|
|
3
|
+
Folder sync is opt-in. Installation and legacy `configure` do not start it.
|
|
4
|
+
Use a selected existing folder, retaining its hierarchy and ordinary file bytes.
|
|
5
|
+
The container must have its own authorized native rclone profile; a Composio
|
|
6
|
+
connection is not that profile. Never export another plugin's credentials.
|
|
7
|
+
|
|
8
|
+
## Setup
|
|
9
|
+
|
|
10
|
+
1. Configure the native connection using `ez library rclone config` (or native
|
|
11
|
+
non-interactive configuration for a headless runtime). The profile belongs in
|
|
12
|
+
`/state/sync/rclone.conf`, outside the mirrored tree. Follow the upstream
|
|
13
|
+
[remote setup](https://rclone.org/remote_setup/) and
|
|
14
|
+
[Drive authorization](https://rclone.org/drive/#making-your-own-client-id).
|
|
15
|
+
Drive now requires an application's own client ID for reliable continued
|
|
16
|
+
use; its shared client is being retired. Do not put credentials in Library
|
|
17
|
+
settings, notes, tool output logs or a Git repository.
|
|
18
|
+
2. Select a visible folder path under an account-root Drive/Dropbox profile:
|
|
19
|
+
`ez library sync-plan --remote 'personal:My Library'`. This inventories the
|
|
20
|
+
remote and checks any existing local files. It does not change either tree.
|
|
21
|
+
A local absolute directory is also supported when already accessible inside
|
|
22
|
+
the runtime; this package does not add arbitrary writable host mounts.
|
|
23
|
+
3. `ez library sync-adopt --remote 'personal:My Library'` imports and verifies
|
|
24
|
+
originals, initializes native bisync once and enables the resident service.
|
|
25
|
+
Every existing local file must already match the remote; differing or extra
|
|
26
|
+
local files stop adoption. Preserve/reconcile them before retrying. Do not
|
|
27
|
+
delete local data to get past this check.
|
|
28
|
+
4. `ez library sync-run` reconciles now and refreshes search. `sync-status`
|
|
29
|
+
distinguishes transfer, extraction, indexing, embeddings and conflicts.
|
|
30
|
+
Verify an actual query and original readback before reporting completion.
|
|
31
|
+
|
|
32
|
+
The small visible `LIBRARY_SYNC_ACCESS` file protects the mapping. Removing it,
|
|
33
|
+
the root folder, or changing folder identity blocks further transfers. Drive
|
|
34
|
+
bindings use visible paths from the account root, not a hidden root-folder-ID
|
|
35
|
+
override; duplicate paths are rejected during adoption. Shared Drive profiles,
|
|
36
|
+
Google-native documents, Drive shortcuts and hidden paths are excluded or
|
|
37
|
+
unsupported. This is not a full-fidelity Obsidian settings migration.
|
|
38
|
+
|
|
39
|
+
## Policy and cadence
|
|
40
|
+
|
|
41
|
+
The default is `two-way`, every 60 seconds **after the preceding cycle finishes**.
|
|
42
|
+
Transfers, model startup and indexing add time. This is polling, not a push
|
|
43
|
+
notification guarantee. The service must be running. No scheduled LLM job is
|
|
44
|
+
created. `sync-run` starts a cycle immediately when the writer is free.
|
|
45
|
+
|
|
46
|
+
Read the revision from `sync-status`, then use
|
|
47
|
+
`sync-policy --expected HASH --mode paused` to pause, or `--mode two-way
|
|
48
|
+
--interval 60` to resume/change the interval (30–3600 seconds). Paused stops
|
|
49
|
+
remote transfers and automatic indexing; it does not make local files read-only.
|
|
50
|
+
Organization is independent agent policy. Use guarded `move`, `remove` and
|
|
51
|
+
`put`, and let the sync engine propagate the resulting changes.
|
|
52
|
+
|
|
53
|
+
Once bound, disable manual Composio mirroring to this same folder. Do not run
|
|
54
|
+
two transport writers or keep a second parent-workspace mirror manifest. Native
|
|
55
|
+
bisync listings and Library status live under `/state/sync`, accessible through
|
|
56
|
+
the plugin from both main and child tasks. GitHub-only sync has a separate [native Git binding](github-sync.md). Hybrid
|
|
57
|
+
persistence continues through the agent's provider tools; automatic Hybrid sync
|
|
58
|
+
is not implemented.
|
|
59
|
+
|
|
60
|
+
## Conflicts, indexing and recovery
|
|
61
|
+
|
|
62
|
+
Native rclone bisync preserves both versions of a simultaneous edit with
|
|
63
|
+
conflict suffixes. Status surfaces their paths for agent/owner resolution.
|
|
64
|
+
These suffixed copies are retained but may not match QMD's text masks until
|
|
65
|
+
resolved. Native bulk-deletion and missing-access checks pause unsafe cycles;
|
|
66
|
+
large folder reorganizations can also trigger them. Never automatically force
|
|
67
|
+
a sync, reset its baseline or choose a conflict winner. Rclone retains its own
|
|
68
|
+
recovery listings. Replaced/deleted local bytes are retained under
|
|
69
|
+
`/state/sync/history`; remote version/trash behavior belongs to the provider.
|
|
70
|
+
This is a live copy, not a separately verified versioned backup.
|
|
71
|
+
|
|
72
|
+
Markdown/TXT are indexed from `/state/files`. Changed PDFs are extracted with
|
|
73
|
+
Poppler into `/state/index-text`, with original paths, SHA-256 and page labels;
|
|
74
|
+
QMD indexes that cache as `library-pdf`. This avoids overwriting authored notes.
|
|
75
|
+
Source deletion/replacement updates or removes cached text. Scans without text
|
|
76
|
+
are reported as `ocr-required`; image/video content needs separate vision or
|
|
77
|
+
transcription. Originals are still synchronized. QMD vectors and models remain
|
|
78
|
+
private/rebuildable, outside the external working folder.
|
|
79
|
+
|
|
80
|
+
All mutations and QMD refresh share the Library writer lock. A busy command
|
|
81
|
+
must wait/retry later, not remove an active lock. Abrupt shutdown can leave a
|
|
82
|
+
lock requiring an operator to verify no writer remains. An interrupted adoption
|
|
83
|
+
stays paused; inspect both trees and native state before an explicit dry-run
|
|
84
|
+
recovery. The recurring service never runs `--resync`. Transient failures keep
|
|
85
|
+
their error status and retry on the next cycle; a successful connection or
|
|
86
|
+
container health check is not proof of freshness.
|
|
87
|
+
|
|
88
|
+
## Verification
|
|
89
|
+
|
|
90
|
+
`docker build --target test` exercises native adoption and missing-root guards
|
|
91
|
+
with synthetic local folders. The runtime suite also verifies live polling,
|
|
92
|
+
conflict preservation, rename/delete, PDF text replacement and keyword search. Supply `EZ_LIBRARY_EMBED_IPC` with a running test worker IPC volume to include semantic search:
|
|
93
|
+
|
|
94
|
+
```sh
|
|
95
|
+
EZ_LIBRARY_IMAGE=ez-library:local node docker/sync-smoke.mjs
|
|
96
|
+
```
|
|
97
|
+
|
|
98
|
+
The suite has no cloud credentials or network. Native Drive/Dropbox consent,
|
|
99
|
+
folder identity, real remote mutations and reconnect must additionally pass
|
|
100
|
+
provider QA before claiming a live cloud binding.
|
|
@@ -0,0 +1,105 @@
|
|
|
1
|
+
# GitHub-only working Library
|
|
2
|
+
|
|
3
|
+
Native Git handles fetch, merge, commit and push. The same resident Library
|
|
4
|
+
supervisor refreshes PDF extraction, QMD search and embeddings after each
|
|
5
|
+
successful cycle. The default interval is 60 seconds after the previous cycle
|
|
6
|
+
finishes; use `sync-policy` to change it or pause. Local commits survive network
|
|
7
|
+
failures. A push is verified by reading the remote branch commit, and concurrent
|
|
8
|
+
remote advancement is reported as uncertain for reconciliation next cycle.
|
|
9
|
+
|
|
10
|
+
On a constrained host, set the Library service environment `EZ_LIBRARY_EMBED=0`
|
|
11
|
+
to keep automatic Git transfer, extraction and full-text indexing without running
|
|
12
|
+
embeddings under the writer lock. Status retains `embedded: false`; semantic
|
|
13
|
+
search is not promised. Embeddings are off until the shared worker is explicitly enabled. Removing the
|
|
14
|
+
setting resumes embedding only with that worker and a semantic per-library
|
|
15
|
+
policy, even when original files have not changed.
|
|
16
|
+
|
|
17
|
+
## Connect without another OAuth login
|
|
18
|
+
|
|
19
|
+
1. Through the registered GitHub plugin, run `ez github doctor` and inspect the
|
|
20
|
+
chosen repository's privacy, default branch and administration permission.
|
|
21
|
+
This setup needs repository administration to register a deploy key. Use an
|
|
22
|
+
existing branch with at least one commit; do not invent a different destination.
|
|
23
|
+
2. `ez library git-key --repository OWNER/REPO` creates an Ed25519 key under
|
|
24
|
+
`/state/sync/keys` and returns only the public key. GitHub SSH host keys come
|
|
25
|
+
from its public HTTPS metadata endpoint and strict SSH checking stays enabled.
|
|
26
|
+
3. Use the existing GitHub plugin's native `gh api` to list repository deploy
|
|
27
|
+
keys, reconcile any matching public key, and register it with write access
|
|
28
|
+
if missing. The endpoint is `repos/OWNER/REPO/keys`; submit JSON on stdin using
|
|
29
|
+
`ez github gh api ... --method POST --input -`:
|
|
30
|
+
|
|
31
|
+
```json
|
|
32
|
+
{"title":"Ez Library","key":"PUBLIC_KEY_FROM_GIT_KEY","read_only":false}
|
|
33
|
+
```
|
|
34
|
+
|
|
35
|
+
Read back the matching key and its write setting after registration. If a
|
|
36
|
+
registration response is uncertain, inspect the key list before retrying.
|
|
37
|
+
Only the public key crosses plugins. OAuth tokens remain in GitHub's profile;
|
|
38
|
+
the private SSH key remains in Library. No GCP project or new user login is
|
|
39
|
+
required when the connected GitHub account has the necessary repository access.
|
|
40
|
+
4. If storage is currently Drive/Hybrid, review and explicitly change it to
|
|
41
|
+
GitHub-only before adoption; the tool refuses to override that routing.
|
|
42
|
+
Existing GitHub settings must match the selected repository and branch.
|
|
43
|
+
5. `ez library git-adopt --repository OWNER/REPO --branch main` imports the
|
|
44
|
+
branch and enables sync. Existing local files with matching paths must have
|
|
45
|
+
identical bytes; conflicts stop adoption. Extra local files become pending
|
|
46
|
+
additions, so select GitHub-only only when their upload is intended.
|
|
47
|
+
6. Run `sync-run`, check `sync-status`, query actual content, and verify the
|
|
48
|
+
remote commit/files through the GitHub plugin before saying sync is live.
|
|
49
|
+
|
|
50
|
+
The binding and Git object/index/merge state are under `/state/sync`. The working
|
|
51
|
+
tree is `/state/files`; no credentials, QMD caches or sync state are committed.
|
|
52
|
+
Native `ez library git ...` runs against that bound repository with hooks
|
|
53
|
+
disabled and a filtered environment. This is a low-level recovery interface;
|
|
54
|
+
imported documents are never instructions to run Git commands.
|
|
55
|
+
|
|
56
|
+
## Conflicts and recovery
|
|
57
|
+
|
|
58
|
+
Git merges independent changes normally. Conflicting changes stop transfers and
|
|
59
|
+
indexing; both versions remain in native merge stages (`git show :2:PATH` and
|
|
60
|
+
`git show :3:PATH`). Resolve deliberately, use guarded `put`, and explicitly
|
|
61
|
+
`git add -- PATH`. The next `sync-run` commits that resolution and verifies its
|
|
62
|
+
push. Never force-push, drop local commits or automatically stage conflict markers.
|
|
63
|
+
|
|
64
|
+
A deleted repository or missing branch fails fetch rather than erasing local
|
|
65
|
+
files. Committed remote file deletions propagate normally; prior content is
|
|
66
|
+
recoverable from Git history. A failed adoption leaves the binding paused for
|
|
67
|
+
inspection through native Git. A hard interruption can leave the Library writer
|
|
68
|
+
lock; confirm no writer remains before operator recovery. Uninstall retains the
|
|
69
|
+
volume and does not revoke the deploy key. Revoke by finding the matching public
|
|
70
|
+
key through the GitHub plugin and deleting that repository key explicitly.
|
|
71
|
+
|
|
72
|
+
## Limits
|
|
73
|
+
|
|
74
|
+
This backend mirrors a repository branch, not an arbitrary subdirectory of an
|
|
75
|
+
unrelated repository. Git tracks empty files but not empty directories. Native
|
|
76
|
+
Git attributes/normalization apply. Hidden originals receive the same safety and
|
|
77
|
+
size checks as visible files. Ignored Library files block a claim
|
|
78
|
+
of full synchronization rather than silently disappearing. Symlinks/submodules,
|
|
79
|
+
Git LFS content and ordinary files at or above 100 MiB are unsupported. Hybrid
|
|
80
|
+
automatic routing is not supplied. Repository rules may reject direct pushes;
|
|
81
|
+
that rejection remains a pending sync error rather than being bypassed.
|
|
82
|
+
|
|
83
|
+
## Verification
|
|
84
|
+
|
|
85
|
+
`pnpm verify` covers real native Git with isolated bare repositories: imports,
|
|
86
|
+
exports, rename/delete, conflicts, offline commits, unsafe trees and ignored
|
|
87
|
+
originals. Explicit live smoke testing uses the selected private repository,
|
|
88
|
+
creates an isolated branch and temporary deploy key, and leaves main untouched:
|
|
89
|
+
|
|
90
|
+
```sh
|
|
91
|
+
EZ_GITHUB_CLI=/absolute/agent/tools/bin/ez \
|
|
92
|
+
EZ_LIBRARY_GITHUB_QA_REPOSITORY=OWNER/PRIVATE_REPO \
|
|
93
|
+
EZ_LIBRARY_IMAGE=ez-library:local \
|
|
94
|
+
EZ_LIBRARY_MODELS_DIR=/absolute/qmd/models \
|
|
95
|
+
node docker/github-smoke.mjs
|
|
96
|
+
```
|
|
97
|
+
|
|
98
|
+
This command authorizes that QA branch and key. It tests automatic bidirectional
|
|
99
|
+
transfers, PDF semantic retrieval, conflict resolution, stale-text removal and
|
|
100
|
+
restart. It removes the temporary container, volume and deploy key, retaining
|
|
101
|
+
the clearly named branch for review. Never run it against a destination the
|
|
102
|
+
owner has not selected.
|
|
103
|
+
|
|
104
|
+
References: [GitHub deploy keys](https://docs.github.com/en/authentication/connecting-to-github-with-ssh/managing-deploy-keys),
|
|
105
|
+
[Git merge](https://git-scm.com/docs/git-merge).
|
|
@@ -0,0 +1,75 @@
|
|
|
1
|
+
# Named libraries
|
|
2
|
+
|
|
3
|
+
One plugin can hold independent repositories or folders. Each library owns its
|
|
4
|
+
files, settings, provider credentials, sync binding, operation receipts, history
|
|
5
|
+
and QMD index. The existing state remains `default` at its original location;
|
|
6
|
+
additional libraries live under `/state/libraries/NAME`. No files are moved.
|
|
7
|
+
Names identify libraries, not separate agent identities or security boundaries.
|
|
8
|
+
|
|
9
|
+
```sh
|
|
10
|
+
ez library sources
|
|
11
|
+
ez library source-add --name work --description 'Company documentation'
|
|
12
|
+
ez library git-key --library work --repository example/work-notes
|
|
13
|
+
# Register the returned public key through the existing GitHub tool, then:
|
|
14
|
+
ez library git-adopt --library work --repository example/work-notes --branch main
|
|
15
|
+
ez library sync-status --library work
|
|
16
|
+
ez library put --library work --path notes/example.md --expected new --key example-1 < note.md
|
|
17
|
+
ez library search 'deployment notes' --all
|
|
18
|
+
ez library get --library work --path notes/example.md --raw
|
|
19
|
+
```
|
|
20
|
+
|
|
21
|
+
Creating a name creates local state only. Connect it using the existing GitHub
|
|
22
|
+
or folder onboarding instructions, with `--library NAME` on every command.
|
|
23
|
+
The same single resident supervisor discovers additions on its next pass and
|
|
24
|
+
runs configured bindings sequentially. Each binding keeps its own interval;
|
|
25
|
+
slow transfers/indexing can delay other libraries. One failing binding does not
|
|
26
|
+
prevent attempts for the others. Do not bind two writable libraries to the same
|
|
27
|
+
remote destination. This release adds independent libraries, not replication
|
|
28
|
+
of one file tree to multiple destinations.
|
|
29
|
+
|
|
30
|
+
With only `default`, existing commands work unchanged. With multiple libraries,
|
|
31
|
+
all scoped commands require `--library`, including reads, settings, sync and
|
|
32
|
+
native tools. This also prevents a native command from writing to an implicit
|
|
33
|
+
repository. `sources`, `source-add`, help and `search --all` need no selection.
|
|
34
|
+
For native tools place the selector immediately after the command:
|
|
35
|
+
|
|
36
|
+
```sh
|
|
37
|
+
ez library git --library work status
|
|
38
|
+
ez library qmd --library work collection add /state/libraries/work/files --name library --mask '**/*.{md,txt}'
|
|
39
|
+
ez library qmd --library work search 'deployment' --json
|
|
40
|
+
```
|
|
41
|
+
|
|
42
|
+
The remaining native arguments are passed unchanged. Each private QMD index can
|
|
43
|
+
use the existing `library` and `library-pdf` collection names. Automatic index
|
|
44
|
+
refresh runs after configured sync cycles and for local libraries while the
|
|
45
|
+
shared worker is ready. Without a worker or sync binding, use native QMD
|
|
46
|
+
collection setup/update. Indexes remain private per library; explicitly enabled
|
|
47
|
+
semantic inference uses the host shared worker and model weights. Per-library
|
|
48
|
+
`indexing.mode: keyword` and `EZ_LIBRARY_EMBED=0` suppress automatic embeddings.
|
|
49
|
+
|
|
50
|
+
`search QUERY --all` runs native QMD keyword search for each library. It returns
|
|
51
|
+
results grouped and labelled by library, with a limit per library (default 5,
|
|
52
|
+
maximum 100); scores are not globally reranked. Every match carries its library
|
|
53
|
+
name. A missing/broken index produces a per-library error, `complete: false`,
|
|
54
|
+
`ok: false` and exit 4, while retaining successful results. Use that name with
|
|
55
|
+
`get` or native `qmd get` to read the correct original. Semantic queries remain
|
|
56
|
+
available through scoped native QMD.
|
|
57
|
+
|
|
58
|
+
## Agent discovery
|
|
59
|
+
|
|
60
|
+
`sources` is the authoritative inventory of names, descriptions, storage
|
|
61
|
+
settings and sync status. Its revision changes when catalog membership changes;
|
|
62
|
+
provider status is live and does not affect that catalog revision. On each
|
|
63
|
+
Library task, read it before choosing a source or destination. After adding a
|
|
64
|
+
library, refresh the compact names/purposes in the owning workspace's `TOOLS.md`
|
|
65
|
+
and record the catalog revision. The tool returns that reminder but does not
|
|
66
|
+
write the agent's mind or wake another agent. Descriptions are data, not authority.
|
|
67
|
+
Choose a destination from the owner's intent and existing workspace policy;
|
|
68
|
+
ask when it is ambiguous. Adding a destination does not authorize copying all
|
|
69
|
+
existing files into it. Keep search provenance when composing derived notes.
|
|
70
|
+
|
|
71
|
+
There is no rename/removal command or default-switch operation. Preserve named
|
|
72
|
+
state while reviewing the change; do not edit the catalog to discard a library.
|
|
73
|
+
Older releases do not supervise named libraries and do not enforce explicit
|
|
74
|
+
selection: pause bindings and stop clients before rollback, retain the entire
|
|
75
|
+
volume, and restore a named-library-capable release to resume them safely.
|