moflo 4.8.84 → 4.8.85

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/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "moflo",
3
- "version": "4.8.84",
3
+ "version": "4.8.85",
4
4
  "description": "MoFlo — AI agent orchestration for Claude Code. Forked from ruflo/claude-flow with patches applied to source, plus feature-level orchestration.",
5
5
  "main": "dist/index.js",
6
6
  "type": "module",
@@ -117,7 +117,7 @@
117
117
  "@types/node": "^24.12.2",
118
118
  "@xenova/transformers": "^2.17.0",
119
119
  "eslint": "^8.0.0",
120
- "moflo": "^4.8.83",
120
+ "moflo": "^4.8.84",
121
121
  "tsx": "^4.21.0",
122
122
  "typescript": "^5.9.3",
123
123
  "vitest": "^4.0.0"
@@ -87,7 +87,11 @@ export async function getRegistry(dbPath) {
87
87
  if (!registryPromise) {
88
88
  registryPromise = (async () => {
89
89
  try {
90
- const { ControllerRegistry } = await importMofloMemory(import.meta.url);
90
+ const memoryModule = await importMofloMemory();
91
+ if (!memoryModule) {
92
+ throw new Error('@moflo/memory not available (src/modules/memory/dist/index.js not found)');
93
+ }
94
+ const { ControllerRegistry } = memoryModule;
91
95
  const registry = new ControllerRegistry();
92
96
  // Suppress noisy init logs
93
97
  const origLog = console.log;
@@ -381,8 +381,8 @@ export async function getHNSWIndex(options) {
381
381
  // Use HnswLite pure TS implementation (no native dependencies). The
382
382
  // shared resolver handles the consumer case where @moflo/memory is not
383
383
  // a declared dep and must be loaded via a relative URL fallback.
384
- const memoryModule = await importMofloMemory(import.meta.url);
385
- if (!('HnswLite' in memoryModule) || memoryModule.HnswLite === undefined) {
384
+ const memoryModule = await importMofloMemory();
385
+ if (!memoryModule || !('HnswLite' in memoryModule) || memoryModule.HnswLite === undefined) {
386
386
  // Shape-check (issue #482): warn loudly and bail — the outer catch
387
387
  // would otherwise swallow a cryptic "undefined is not a constructor".
388
388
  console.warn('[getHNSWIndex] @moflo/memory missing expected export: HnswLite');
@@ -13,6 +13,8 @@
13
13
  */
14
14
  import { createRequire } from 'module';
15
15
  import { fileURLToPath, pathToFileURL } from 'url';
16
+ import { existsSync } from 'fs';
17
+ import { dirname, join } from 'path';
16
18
  // createRequire anchored to this file — resolves from moflo's own node_modules
17
19
  const mofloRequire = createRequire(fileURLToPath(import.meta.url));
18
20
  /**
@@ -79,24 +81,63 @@ export function mofloResolve(specifier) {
79
81
  }
80
82
  }
81
83
  /**
82
- * Import `@moflo/memory` from within a moflo source module. The root `moflo`
83
- * package ships @moflo/memory as a source folder rather than a declared
84
- * dependency, so `mofloImport('@moflo/memory')` fails in consumer installs
85
- * (node_modules/@moflo/memory/ doesn't exist). Fall back to a URL resolved
86
- * relative to the caller's file — the same src/modules/memory/dist/index.js
87
- * layout holds in both dev and consumer.
84
+ * Locate `src/modules/memory/dist/index.js` by walking up from this file's
85
+ * directory until the path resolves. Layout-invariant across:
86
+ * - dev source (cli/src/services/)
87
+ * - built output (cli/dist/src/services/)
88
+ * - installed package (node_modules/moflo/src/modules/cli/dist/src/services/)
89
+ * - Windows and POSIX (path.join/dirname are platform-aware)
88
90
  *
89
- * Callers live at src/modules/cli/src/memory/<file>.ts, so from that dir
90
- * the memory dist is 3 levels up (cli/src/memory → cli/src → cli → modules)
91
- * plus `memory/dist/index.js`.
91
+ * Returns a file:// URL for ESM `import()`, or null if memory isn't built.
92
+ */
93
+ let cachedMemoryUrl;
94
+ function locateMofloMemoryDist() {
95
+ if (cachedMemoryUrl !== undefined)
96
+ return cachedMemoryUrl;
97
+ let dir = dirname(fileURLToPath(import.meta.url));
98
+ const rel = join('src', 'modules', 'memory', 'dist', 'index.js');
99
+ // 12 levels is far more than any real moflo install depth
100
+ for (let i = 0; i < 12; i++) {
101
+ const candidate = join(dir, rel);
102
+ if (existsSync(candidate)) {
103
+ cachedMemoryUrl = pathToFileURL(candidate).href;
104
+ return cachedMemoryUrl;
105
+ }
106
+ const parent = dirname(dir);
107
+ if (parent === dir)
108
+ break; // filesystem root
109
+ dir = parent;
110
+ }
111
+ cachedMemoryUrl = null;
112
+ return null;
113
+ }
114
+ /**
115
+ * Import `@moflo/memory` from within a moflo source module.
116
+ *
117
+ * The root `moflo` package ships @moflo/memory as a source folder rather than
118
+ * a declared dependency, so `mofloImport('@moflo/memory')` fails in consumer
119
+ * installs (node_modules/@moflo/memory/ doesn't exist). Fall back to a
120
+ * layout-invariant walk-up that finds `src/modules/memory/dist/index.js`
121
+ * regardless of whether the caller is running source, built, or installed.
92
122
  *
93
- * @param callerUrl `import.meta.url` of the file that needs @moflo/memory
123
+ * Returns null when memory isn't available callers must handle that.
94
124
  */
95
- export async function importMofloMemory(callerUrl) {
125
+ export async function importMofloMemory() {
96
126
  const viaRequire = await mofloImport('@moflo/memory');
97
127
  if (viaRequire)
98
128
  return viaRequire;
99
- const memoryUrl = new URL('../../../memory/dist/index.js', callerUrl);
100
- return import(memoryUrl.href);
129
+ const url = locateMofloMemoryDist();
130
+ if (!url)
131
+ return null;
132
+ try {
133
+ return await import(url);
134
+ }
135
+ catch {
136
+ return null;
137
+ }
138
+ }
139
+ // Test-only: reset the cache between unit tests that mutate the filesystem.
140
+ export function _resetMofloMemoryCacheForTest() {
141
+ cachedMemoryUrl = undefined;
101
142
  }
102
143
  //# sourceMappingURL=moflo-require.js.map
@@ -2,5 +2,5 @@
2
2
  * Auto-generated by build. Do not edit manually.
3
3
  * Source of truth: root package.json → scripts/sync-version.mjs
4
4
  */
5
- export const VERSION = '4.8.84';
5
+ export const VERSION = '4.8.85';
6
6
  //# sourceMappingURL=version.js.map
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "@moflo/cli",
3
- "version": "4.8.84",
3
+ "version": "4.8.85",
4
4
  "type": "module",
5
5
  "main": "dist/src/index.js",
6
6
  "types": "dist/src/index.d.ts",