@plur-ai/core 0.9.0 → 0.9.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/dist/index.d.ts +9 -0
- package/dist/index.js +50 -1
- package/package.json +1 -1
package/dist/index.d.ts
CHANGED
|
@@ -2050,6 +2050,15 @@ declare class Plur {
|
|
|
2050
2050
|
shared?: boolean;
|
|
2051
2051
|
readonly?: boolean;
|
|
2052
2052
|
}): void;
|
|
2053
|
+
/**
|
|
2054
|
+
* Auto-discover .plur/engrams.yaml in CWD and parent dirs (up to git root).
|
|
2055
|
+
* If found and not already registered, auto-register as a project store.
|
|
2056
|
+
* Returns list of newly discovered stores (empty if none found or all already known).
|
|
2057
|
+
*/
|
|
2058
|
+
autoDiscoverStores(cwd?: string): Array<{
|
|
2059
|
+
path: string;
|
|
2060
|
+
scope: string;
|
|
2061
|
+
}>;
|
|
2053
2062
|
/** List all configured stores. */
|
|
2054
2063
|
listStores(): Array<{
|
|
2055
2064
|
path: string;
|
package/dist/index.js
CHANGED
|
@@ -33,7 +33,9 @@ import {
|
|
|
33
33
|
sync,
|
|
34
34
|
withLock
|
|
35
35
|
} from "./chunk-PRK3B7WR.js";
|
|
36
|
-
import
|
|
36
|
+
import {
|
|
37
|
+
__require
|
|
38
|
+
} from "./chunk-2ZDO52B4.js";
|
|
37
39
|
|
|
38
40
|
// src/index.ts
|
|
39
41
|
import * as fs4 from "fs";
|
|
@@ -3861,6 +3863,53 @@ Generate an improved version of the procedure that prevents this failure. Return
|
|
|
3861
3863
|
fs4.writeFileSync(this.paths.config, yaml6.dump(configData, { lineWidth: 120, noRefs: true }));
|
|
3862
3864
|
this.config = loadConfig(this.paths.config);
|
|
3863
3865
|
}
|
|
3866
|
+
/**
|
|
3867
|
+
* Auto-discover .plur/engrams.yaml in CWD and parent dirs (up to git root).
|
|
3868
|
+
* If found and not already registered, auto-register as a project store.
|
|
3869
|
+
* Returns list of newly discovered stores (empty if none found or all already known).
|
|
3870
|
+
*/
|
|
3871
|
+
autoDiscoverStores(cwd) {
|
|
3872
|
+
const startDir = cwd || process.cwd();
|
|
3873
|
+
const discovered = [];
|
|
3874
|
+
const os = __require("os");
|
|
3875
|
+
const tmpDir = os.tmpdir();
|
|
3876
|
+
if (this.paths.root.startsWith(tmpDir) || this.paths.root.startsWith("/tmp/")) {
|
|
3877
|
+
return discovered;
|
|
3878
|
+
}
|
|
3879
|
+
const knownPaths = new Set((this.config.stores ?? []).map((s) => s.path));
|
|
3880
|
+
const primaryDir = __require("path").dirname(this.paths.engrams);
|
|
3881
|
+
let dir = startDir;
|
|
3882
|
+
const { join: join5, dirname: dirname2, basename: basename2 } = __require("path");
|
|
3883
|
+
const visited = /* @__PURE__ */ new Set();
|
|
3884
|
+
while (dir && !visited.has(dir)) {
|
|
3885
|
+
visited.add(dir);
|
|
3886
|
+
const candidate = join5(dir, ".plur", "engrams.yaml");
|
|
3887
|
+
if (join5(dir, ".plur") === primaryDir) {
|
|
3888
|
+
dir = dirname2(dir);
|
|
3889
|
+
continue;
|
|
3890
|
+
}
|
|
3891
|
+
if (fs4.existsSync(candidate) && !knownPaths.has(candidate)) {
|
|
3892
|
+
let scope = `project:${basename2(dir)}`;
|
|
3893
|
+
try {
|
|
3894
|
+
const plurYaml = join5(dir, ".plur.yaml");
|
|
3895
|
+
if (fs4.existsSync(plurYaml)) {
|
|
3896
|
+
const raw = yaml6.load(fs4.readFileSync(plurYaml, "utf8"));
|
|
3897
|
+
if (raw?.scope) scope = raw.scope;
|
|
3898
|
+
}
|
|
3899
|
+
} catch {
|
|
3900
|
+
}
|
|
3901
|
+
this.addStore(candidate, scope, { shared: true, readonly: false });
|
|
3902
|
+
discovered.push({ path: candidate, scope });
|
|
3903
|
+
knownPaths.add(candidate);
|
|
3904
|
+
logger.info(`Auto-discovered project store: ${candidate} (${scope})`);
|
|
3905
|
+
}
|
|
3906
|
+
if (fs4.existsSync(join5(dir, ".git"))) break;
|
|
3907
|
+
const parent = dirname2(dir);
|
|
3908
|
+
if (parent === dir) break;
|
|
3909
|
+
dir = parent;
|
|
3910
|
+
}
|
|
3911
|
+
return discovered;
|
|
3912
|
+
}
|
|
3864
3913
|
/** List all configured stores. */
|
|
3865
3914
|
listStores() {
|
|
3866
3915
|
const stores = this.config.stores ?? [];
|