quilltap 4.15.0-dev.150 → 4.15.0-dev.159
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
CHANGED
|
@@ -271,7 +271,7 @@ quilltap docs mvdir <mount> <fromPath> <toPath> # Rename/move a fo
|
|
|
271
271
|
|
|
272
272
|
`ls` flags: `--recursive` / `-R` lists every file below the path, grouped by folder; `--sort name|time|size|links` (default `name`) with `--reverse` / `-r` to flip it; `--links` lists the other mount/path entries under each file that has more than one hard link. `tree` takes `--depth N` (default 20), `--max-nodes N` (default 1000) and `--long`, which is accepted but reserved — it does not yet add columns.
|
|
273
273
|
|
|
274
|
-
Mount arguments accept the mount name (case-insensitive) or a UUID; ambiguous names print candidates and exit non-zero. `--json` is supported by every verb; `reindex`, `embed`, `link`, `rmdir`, and `mvdir` refuse to run without a reachable server. `grep --semantic` goes through `POST /api/v1/mount-points?action=semantic-search`, because the embedding provider lives in the server; it defaults to `--top 20`, `--threshold 0.5`, `--port 3000`.
|
|
274
|
+
Mount arguments accept the mount name (case-insensitive) or a UUID; ambiguous names print candidates and exit non-zero. A renamed store still answers to a name it used to carry (the `formerNames` column), with a note on stderr saying which store was found, until another store takes that name; the UUID is the reference that never changes. `--json` is supported by every verb; `reindex`, `embed`, `link`, `rmdir`, and `mvdir` refuse to run without a reachable server. `grep --semantic` goes through `POST /api/v1/mount-points?action=semantic-search`, because the embedding provider lives in the server; it defaults to `--top 20`, `--threshold 0.5`, `--port 3000`.
|
|
275
275
|
|
|
276
276
|
### Addressing documents with `qtap://` URIs
|
|
277
277
|
|
|
@@ -284,7 +284,7 @@ quilltap docs grep --mount qtap://notes/ "TODO"
|
|
|
284
284
|
quilltap docs find --uri Manifesto
|
|
285
285
|
```
|
|
286
286
|
|
|
287
|
-
The URI authority is matched name-first, UUID
|
|
287
|
+
The URI authority is matched name-first, then UUID, then a former name — the same rule as a bare `<mount>` (`qtap://<store name>/…` or `qtap://<uuid>/…`). Two-target verbs (`move` / `copy` / `link` / `mvdir`) take either two `qtap://` URIs or the four legacy positionals; `find` and `grep` take one via `--mount`.
|
|
288
288
|
|
|
289
289
|
**CLI limitation:** the CLI addresses document stores only. `qtap://self/…` needs a character context, and there is none at a shell prompt, so it is rejected with guidance; `qtap://project/…` and `qtap://general/…` are likewise not CLI-addressable — pass a store name or UUID instead.
|
|
290
290
|
|
|
@@ -0,0 +1,60 @@
|
|
|
1
|
+
/**
|
|
2
|
+
* The CLI looks a document store up by name in SQL, so it mirrors the last
|
|
3
|
+
* step of the server's `matchStoreRef` itself: a store still answers to a name
|
|
4
|
+
* it used to carry (`doc_mount_points.formerNames`), so a script written
|
|
5
|
+
* before a rename keeps working. Never a guess: two claimants match neither,
|
|
6
|
+
* and a database from before the column existed has no former names.
|
|
7
|
+
*
|
|
8
|
+
* @jest-environment node
|
|
9
|
+
*/
|
|
10
|
+
|
|
11
|
+
'use strict';
|
|
12
|
+
|
|
13
|
+
const path = require('path');
|
|
14
|
+
|
|
15
|
+
// The real driver: `better-sqlite3` is auto-mocked for unit tests.
|
|
16
|
+
const Database = require(path.join(process.cwd(), 'node_modules', 'better-sqlite3'));
|
|
17
|
+
const { findMountByFormerName } = require('../db-helpers');
|
|
18
|
+
|
|
19
|
+
let db;
|
|
20
|
+
|
|
21
|
+
beforeEach(() => {
|
|
22
|
+
db = new Database(':memory:');
|
|
23
|
+
db.exec(`CREATE TABLE doc_mount_points (id TEXT PRIMARY KEY, name TEXT NOT NULL, formerNames TEXT NOT NULL DEFAULT '[]')`);
|
|
24
|
+
});
|
|
25
|
+
afterEach(() => db.close());
|
|
26
|
+
|
|
27
|
+
const insert = (id, name, formerNames) =>
|
|
28
|
+
db.prepare('INSERT INTO doc_mount_points (id, name, formerNames) VALUES (?, ?, ?)').run(id, name, formerNames);
|
|
29
|
+
|
|
30
|
+
it('finds the store that used to carry the name, ignoring case and surrounding space', () => {
|
|
31
|
+
insert('a', 'Novel', JSON.stringify(['Novel Drafts']));
|
|
32
|
+
insert('b', 'Lore', '[]');
|
|
33
|
+
expect(findMountByFormerName(db, ' novel drafts ')).toMatchObject({ id: 'a', name: 'Novel' });
|
|
34
|
+
});
|
|
35
|
+
|
|
36
|
+
it('finds nothing for a name no store used to carry', () => {
|
|
37
|
+
insert('a', 'Novel', JSON.stringify(['Novel Drafts']));
|
|
38
|
+
expect(findMountByFormerName(db, 'Lore')).toBeNull();
|
|
39
|
+
expect(findMountByFormerName(db, '')).toBeNull();
|
|
40
|
+
});
|
|
41
|
+
|
|
42
|
+
it('matches neither store when two claim one former name', () => {
|
|
43
|
+
insert('a', 'One', JSON.stringify(['Shared']));
|
|
44
|
+
insert('b', 'Two', JSON.stringify(['shared']));
|
|
45
|
+
expect(findMountByFormerName(db, 'Shared')).toBeNull();
|
|
46
|
+
});
|
|
47
|
+
|
|
48
|
+
it('reads a malformed column as no former names', () => {
|
|
49
|
+
insert('a', 'Novel', 'not json');
|
|
50
|
+
insert('b', 'Lore', JSON.stringify({ not: 'an array' }));
|
|
51
|
+
expect(findMountByFormerName(db, 'Novel Drafts')).toBeNull();
|
|
52
|
+
});
|
|
53
|
+
|
|
54
|
+
it('finds nothing in a database from before stores kept their former names', () => {
|
|
55
|
+
const old = new Database(':memory:');
|
|
56
|
+
old.exec('CREATE TABLE doc_mount_points (id TEXT PRIMARY KEY, name TEXT NOT NULL)');
|
|
57
|
+
old.prepare('INSERT INTO doc_mount_points (id, name) VALUES (?, ?)').run('a', 'Novel');
|
|
58
|
+
expect(findMountByFormerName(old, 'Novel Drafts')).toBeNull();
|
|
59
|
+
old.close();
|
|
60
|
+
});
|
package/lib/db-helpers.js
CHANGED
|
@@ -370,7 +370,35 @@ function resolveProject(db, query) {
|
|
|
370
370
|
return fuzzy[0];
|
|
371
371
|
}
|
|
372
372
|
|
|
373
|
+
/**
|
|
374
|
+
* The one document store that used to carry `spec` as its name, or null. A
|
|
375
|
+
* store keeps its former names (`doc_mount_points.formerNames`, JSON) so an
|
|
376
|
+
* address written before a rename still reaches it; this mirrors the last step
|
|
377
|
+
* of the server's `matchStoreRef`. Callers try the current name and the UUID
|
|
378
|
+
* first, since the holder of a name always wins it. Two stores claiming one
|
|
379
|
+
* former name match neither. A database from before the column existed has no
|
|
380
|
+
* former names.
|
|
381
|
+
*/
|
|
382
|
+
function findMountByFormerName(db, spec) {
|
|
383
|
+
const hasColumn = db
|
|
384
|
+
.prepare("SELECT 1 FROM pragma_table_info('doc_mount_points') WHERE name = 'formerNames'")
|
|
385
|
+
.get();
|
|
386
|
+
if (!hasColumn) return null;
|
|
387
|
+
const needle = String(spec).trim().toLowerCase();
|
|
388
|
+
if (!needle) return null;
|
|
389
|
+
const holders = db.prepare('SELECT * FROM doc_mount_points').all().filter((row) => {
|
|
390
|
+
try {
|
|
391
|
+
const former = JSON.parse(row.formerNames || '[]');
|
|
392
|
+
return Array.isArray(former) && former.some((name) => String(name).trim().toLowerCase() === needle);
|
|
393
|
+
} catch {
|
|
394
|
+
return false;
|
|
395
|
+
}
|
|
396
|
+
});
|
|
397
|
+
return holders.length === 1 ? holders[0] : null;
|
|
398
|
+
}
|
|
399
|
+
|
|
373
400
|
module.exports = {
|
|
401
|
+
findMountByFormerName,
|
|
374
402
|
resolveDataDir,
|
|
375
403
|
resolveDataDirAndPassphrase,
|
|
376
404
|
printDefaultInstanceHint,
|
package/lib/docs-commands.js
CHANGED
|
@@ -8,6 +8,7 @@ const {
|
|
|
8
8
|
printDefaultInstanceHint,
|
|
9
9
|
loadDbKey,
|
|
10
10
|
openMountIndexDb,
|
|
11
|
+
findMountByFormerName,
|
|
11
12
|
} = require('./db-helpers');
|
|
12
13
|
const { isQtapUri, parseQtapUri, formatDocStoreUri } = require('./qtap-uri');
|
|
13
14
|
|
|
@@ -93,7 +94,8 @@ Write subcommands (server required for database-backed mounts):
|
|
|
93
94
|
mvdir <mount> <fromPath> <toPath> Rename/move a folder (server-required)
|
|
94
95
|
|
|
95
96
|
<mount> may be a mount name or UUID. Names are case-insensitive; ambiguous
|
|
96
|
-
names print candidates and exit non-zero.
|
|
97
|
+
names print candidates and exit non-zero. A renamed store still answers to a
|
|
98
|
+
name it used to carry, until another store takes that name.
|
|
97
99
|
|
|
98
100
|
Addressing with qtap:// URIs: anywhere a <mount> <relativePath> pair is taken,
|
|
99
101
|
you may instead pass a single qtap:// URI in its place — e.g.
|
|
@@ -399,6 +401,12 @@ function requireMount(db, spec) {
|
|
|
399
401
|
ORDER BY name COLLATE NOCASE`
|
|
400
402
|
).all(spec);
|
|
401
403
|
if (rows.length === 0) {
|
|
404
|
+
// No store holds the name now; one may have carried it before a rename.
|
|
405
|
+
const renamed = findMountByFormerName(db, spec);
|
|
406
|
+
if (renamed) {
|
|
407
|
+
console.error(`Note: "${spec}" is a former name of "${renamed.name}".`);
|
|
408
|
+
return renamed;
|
|
409
|
+
}
|
|
402
410
|
console.error(`No mount point found with name "${spec}"`);
|
|
403
411
|
process.exit(1);
|
|
404
412
|
}
|
package/lib/sync-command.js
CHANGED
|
@@ -34,6 +34,7 @@ const {
|
|
|
34
34
|
loadDbKey,
|
|
35
35
|
openMountIndexDb,
|
|
36
36
|
UUID_RE,
|
|
37
|
+
findMountByFormerName,
|
|
37
38
|
} = require('./db-helpers');
|
|
38
39
|
const { isQtapUri, parseQtapUri } = require('./qtap-uri');
|
|
39
40
|
const { formatActionLines, formatSummary, exitCodeFor } = require('./sync-report');
|
|
@@ -178,6 +179,12 @@ function requireMount(db, spec) {
|
|
|
178
179
|
`SELECT * FROM doc_mount_points WHERE LOWER(name) = LOWER(?) ORDER BY name COLLATE NOCASE`
|
|
179
180
|
).all(spec);
|
|
180
181
|
if (rows.length === 0) {
|
|
182
|
+
// No store holds the name now; one may have carried it before a rename.
|
|
183
|
+
const renamed = findMountByFormerName(db, spec);
|
|
184
|
+
if (renamed) {
|
|
185
|
+
console.error(`Note: "${spec}" is a former name of "${renamed.name}".`);
|
|
186
|
+
return renamed;
|
|
187
|
+
}
|
|
181
188
|
console.error(`No document store found with name "${spec}"`);
|
|
182
189
|
process.exit(1);
|
|
183
190
|
}
|