@plur-ai/core 0.9.0 → 0.9.2

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 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 "./chunk-2ZDO52B4.js";
36
+ import {
37
+ __require
38
+ } from "./chunk-2ZDO52B4.js";
37
39
 
38
40
  // src/index.ts
39
41
  import * as fs4 from "fs";
@@ -2964,6 +2966,10 @@ var Plur = class {
2964
2966
  constructor(options) {
2965
2967
  this.paths = detectPlurStorage(options?.path);
2966
2968
  this.config = loadConfig(this.paths.config);
2969
+ this.autoDiscoverStores();
2970
+ if (this.config.stores?.length !== loadConfig(this.paths.config).stores?.length) {
2971
+ this.config = loadConfig(this.paths.config);
2972
+ }
2967
2973
  if (this.config.index) {
2968
2974
  this.indexedStorage = new IndexedStorage(this.paths.engrams, this.paths.db, this.config.stores);
2969
2975
  }
@@ -3861,6 +3867,53 @@ Generate an improved version of the procedure that prevents this failure. Return
3861
3867
  fs4.writeFileSync(this.paths.config, yaml6.dump(configData, { lineWidth: 120, noRefs: true }));
3862
3868
  this.config = loadConfig(this.paths.config);
3863
3869
  }
3870
+ /**
3871
+ * Auto-discover .plur/engrams.yaml in CWD and parent dirs (up to git root).
3872
+ * If found and not already registered, auto-register as a project store.
3873
+ * Returns list of newly discovered stores (empty if none found or all already known).
3874
+ */
3875
+ autoDiscoverStores(cwd) {
3876
+ const startDir = cwd || process.cwd();
3877
+ const discovered = [];
3878
+ const os = __require("os");
3879
+ const tmpDir = os.tmpdir();
3880
+ if (this.paths.root.startsWith(tmpDir) || this.paths.root.startsWith("/tmp/")) {
3881
+ return discovered;
3882
+ }
3883
+ const knownPaths = new Set((this.config.stores ?? []).map((s) => s.path));
3884
+ const primaryDir = __require("path").dirname(this.paths.engrams);
3885
+ let dir = startDir;
3886
+ const { join: join5, dirname: dirname2, basename: basename2 } = __require("path");
3887
+ const visited = /* @__PURE__ */ new Set();
3888
+ while (dir && !visited.has(dir)) {
3889
+ visited.add(dir);
3890
+ const candidate = join5(dir, ".plur", "engrams.yaml");
3891
+ if (join5(dir, ".plur") === primaryDir) {
3892
+ dir = dirname2(dir);
3893
+ continue;
3894
+ }
3895
+ if (fs4.existsSync(candidate) && !knownPaths.has(candidate)) {
3896
+ let scope = `project:${basename2(dir)}`;
3897
+ try {
3898
+ const plurYaml = join5(dir, ".plur.yaml");
3899
+ if (fs4.existsSync(plurYaml)) {
3900
+ const raw = yaml6.load(fs4.readFileSync(plurYaml, "utf8"));
3901
+ if (raw?.scope) scope = raw.scope;
3902
+ }
3903
+ } catch {
3904
+ }
3905
+ this.addStore(candidate, scope, { shared: true, readonly: false });
3906
+ discovered.push({ path: candidate, scope });
3907
+ knownPaths.add(candidate);
3908
+ logger.info(`Auto-discovered project store: ${candidate} (${scope})`);
3909
+ }
3910
+ if (fs4.existsSync(join5(dir, ".git"))) break;
3911
+ const parent = dirname2(dir);
3912
+ if (parent === dir) break;
3913
+ dir = parent;
3914
+ }
3915
+ return discovered;
3916
+ }
3864
3917
  /** List all configured stores. */
3865
3918
  listStores() {
3866
3919
  const stores = this.config.stores ?? [];
package/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "@plur-ai/core",
3
- "version": "0.9.0",
3
+ "version": "0.9.2",
4
4
  "type": "module",
5
5
  "main": "dist/index.js",
6
6
  "types": "dist/index.d.ts",