@phren/cli 0.1.12 → 0.1.13
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/dist/cli/namespaces.js +20 -0
- package/dist/profile-store.js +14 -1
- package/dist/shared/index.js +22 -3
- package/dist/shared/retrieval.js +10 -9
- package/package.json +1 -1
package/dist/cli/namespaces.js
CHANGED
|
@@ -1719,6 +1719,26 @@ export async function handleStoreNamespace(args) {
|
|
|
1719
1719
|
stdio: "pipe",
|
|
1720
1720
|
timeout: 30_000,
|
|
1721
1721
|
});
|
|
1722
|
+
// Re-apply sparse-checkout after pull on primary store to avoid materializing all files
|
|
1723
|
+
if (store.role === "primary") {
|
|
1724
|
+
try {
|
|
1725
|
+
const sparseList = execFileSync("git", ["sparse-checkout", "list"], {
|
|
1726
|
+
cwd: store.path,
|
|
1727
|
+
stdio: "pipe",
|
|
1728
|
+
timeout: 10_000,
|
|
1729
|
+
}).toString().trim();
|
|
1730
|
+
if (sparseList) {
|
|
1731
|
+
execFileSync("git", ["sparse-checkout", "reapply"], {
|
|
1732
|
+
cwd: store.path,
|
|
1733
|
+
stdio: "pipe",
|
|
1734
|
+
timeout: 10_000,
|
|
1735
|
+
});
|
|
1736
|
+
}
|
|
1737
|
+
}
|
|
1738
|
+
catch {
|
|
1739
|
+
// sparse-checkout not configured — nothing to reapply
|
|
1740
|
+
}
|
|
1741
|
+
}
|
|
1722
1742
|
console.log(` ${store.name}: ok`);
|
|
1723
1743
|
}
|
|
1724
1744
|
catch (err) {
|
package/dist/profile-store.js
CHANGED
|
@@ -310,8 +310,19 @@ export function listProjectCards(phrenPath, profile) {
|
|
|
310
310
|
const dirs = getProjectDirs(phrenPath, profile).sort((a, b) => path.basename(a).localeCompare(path.basename(b)));
|
|
311
311
|
const cards = dirs.map(buildProjectCard);
|
|
312
312
|
const seen = new Set(dirs.map((d) => path.basename(d)));
|
|
313
|
-
// Include projects from team stores
|
|
313
|
+
// Include projects from team stores, filtered by active profile
|
|
314
314
|
try {
|
|
315
|
+
// Resolve the profile's project allow-list (if any)
|
|
316
|
+
let profileProjectNames;
|
|
317
|
+
if (profile) {
|
|
318
|
+
const profiles = listProfiles(phrenPath);
|
|
319
|
+
if (profiles.ok) {
|
|
320
|
+
const active = profiles.data.find((p) => p.name === profile);
|
|
321
|
+
if (active && active.projects.length > 0) {
|
|
322
|
+
profileProjectNames = new Set(active.projects);
|
|
323
|
+
}
|
|
324
|
+
}
|
|
325
|
+
}
|
|
315
326
|
for (const store of getNonPrimaryStores(phrenPath)) {
|
|
316
327
|
if (!fs.existsSync(store.path))
|
|
317
328
|
continue;
|
|
@@ -319,6 +330,8 @@ export function listProjectCards(phrenPath, profile) {
|
|
|
319
330
|
const name = path.basename(dir);
|
|
320
331
|
if (seen.has(name) || name === "global")
|
|
321
332
|
continue;
|
|
333
|
+
if (profileProjectNames && !profileProjectNames.has(name))
|
|
334
|
+
continue;
|
|
322
335
|
seen.add(name);
|
|
323
336
|
cards.push(buildProjectCard(dir));
|
|
324
337
|
}
|
package/dist/shared/index.js
CHANGED
|
@@ -30,12 +30,30 @@ async function refreshStoreProjectDirs(phrenPath, profile) {
|
|
|
30
30
|
try {
|
|
31
31
|
const { getNonPrimaryStores, getStoreProjectDirs } = await import("../store-registry.js");
|
|
32
32
|
const otherStores = getNonPrimaryStores(phrenPath);
|
|
33
|
-
|
|
33
|
+
let dirs = [];
|
|
34
34
|
for (const store of otherStores) {
|
|
35
35
|
if (!fs.existsSync(store.path))
|
|
36
36
|
continue;
|
|
37
37
|
dirs.push(...getStoreProjectDirs(store));
|
|
38
38
|
}
|
|
39
|
+
// Filter by active profile's project list, matching getProjectDirs behavior
|
|
40
|
+
if (profile) {
|
|
41
|
+
const profilePath = path.join(phrenPath, "profiles", `${profile}.yaml`);
|
|
42
|
+
if (fs.existsSync(profilePath)) {
|
|
43
|
+
try {
|
|
44
|
+
const yaml = await import("js-yaml");
|
|
45
|
+
const data = yaml.load(fs.readFileSync(profilePath, "utf-8"), { schema: yaml.CORE_SCHEMA });
|
|
46
|
+
const projects = data?.projects;
|
|
47
|
+
if (Array.isArray(projects)) {
|
|
48
|
+
const allowed = new Set(projects.map(String));
|
|
49
|
+
dirs = dirs.filter(dir => allowed.has(path.basename(dir)));
|
|
50
|
+
}
|
|
51
|
+
}
|
|
52
|
+
catch {
|
|
53
|
+
// Profile parse error — include all dirs as fallback
|
|
54
|
+
}
|
|
55
|
+
}
|
|
56
|
+
}
|
|
39
57
|
_cachedStoreProjectDirs = dirs;
|
|
40
58
|
_cachedStorePhrenPath = phrenPath;
|
|
41
59
|
}
|
|
@@ -445,8 +463,9 @@ function globAllFiles(phrenPath, profile) {
|
|
|
445
463
|
const allAbsolutePaths = [];
|
|
446
464
|
for (const dir of projectDirs) {
|
|
447
465
|
const projectName = path.basename(dir);
|
|
448
|
-
const
|
|
449
|
-
const
|
|
466
|
+
const storePath = path.dirname(dir);
|
|
467
|
+
const config = readProjectConfig(storePath, projectName);
|
|
468
|
+
const ownership = getProjectOwnershipMode(storePath, projectName, config);
|
|
450
469
|
const mdFilesSet = new Set();
|
|
451
470
|
for (const pattern of indexPolicy.includeGlobs) {
|
|
452
471
|
const dot = indexPolicy.includeHidden || pattern.startsWith(".") || pattern.includes("/.");
|
package/dist/shared/retrieval.js
CHANGED
|
@@ -495,20 +495,21 @@ export async function searchKnowledgeRows(db, options) {
|
|
|
495
495
|
* Returns an array of results tagged with their source store. Read-only — no mutations.
|
|
496
496
|
*/
|
|
497
497
|
export async function searchFederatedStores(localPhrenPath, options) {
|
|
498
|
-
|
|
498
|
+
// Registered non-primary stores are already included in the main FTS index
|
|
499
|
+
// by buildIndex (via refreshStoreProjectDirs). Only search unregistered
|
|
500
|
+
// federation paths from PHREN_FEDERATION_PATHS to avoid double indexing.
|
|
501
|
+
let registeredStorePaths;
|
|
499
502
|
try {
|
|
500
503
|
const { getNonPrimaryStores } = await import("../store-registry.js");
|
|
501
|
-
|
|
502
|
-
path: s.path, name: s.name, id: s.id,
|
|
503
|
-
}));
|
|
504
|
+
registeredStorePaths = new Set(getNonPrimaryStores(localPhrenPath).map((s) => s.path));
|
|
504
505
|
}
|
|
505
506
|
catch {
|
|
506
|
-
|
|
507
|
-
const raw = process.env.PHREN_FEDERATION_PATHS ?? "";
|
|
508
|
-
nonPrimaryStores = raw.split(":").map((p) => p.trim())
|
|
509
|
-
.filter((p) => p.length > 0 && p !== localPhrenPath && fs.existsSync(p))
|
|
510
|
-
.map((p) => ({ path: p, name: path.basename(p), id: "" }));
|
|
507
|
+
registeredStorePaths = new Set();
|
|
511
508
|
}
|
|
509
|
+
const raw = process.env.PHREN_FEDERATION_PATHS ?? "";
|
|
510
|
+
const nonPrimaryStores = raw.split(":").map((p) => p.trim())
|
|
511
|
+
.filter((p) => p.length > 0 && p !== localPhrenPath && !registeredStorePaths.has(p) && fs.existsSync(p))
|
|
512
|
+
.map((p) => ({ path: p, name: path.basename(p), id: "" }));
|
|
512
513
|
if (nonPrimaryStores.length === 0)
|
|
513
514
|
return [];
|
|
514
515
|
const allRows = [];
|