moflo 4.8.19 → 4.8.20
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/.claude/guidance/shipped/moflo.md +45 -0
- package/.claude/helpers/statusline.cjs +1 -1
- package/.claude/workflow-state.json +9 -0
- package/package.json +2 -2
- package/src/@claude-flow/cli/dist/src/init/statusline-generator.js +1 -1
- package/src/@claude-flow/cli/dist/src/services/agentic-flow-bridge.js +5 -3
- package/src/@claude-flow/cli/package.json +1 -1
- package/src/@claude-flow/memory/dist/agent-memory-scope.d.ts +131 -0
- package/src/@claude-flow/memory/dist/agent-memory-scope.js +223 -0
- package/src/@claude-flow/memory/dist/agent-memory-scope.test.d.ts +8 -0
- package/src/@claude-flow/memory/dist/agent-memory-scope.test.js +466 -0
- package/src/@claude-flow/memory/dist/agentdb-adapter.d.ts +165 -0
- package/src/@claude-flow/memory/dist/agentdb-adapter.js +806 -0
- package/src/@claude-flow/memory/dist/agentdb-backend.d.ts +212 -0
- package/src/@claude-flow/memory/dist/agentdb-backend.js +842 -0
- package/src/@claude-flow/memory/dist/agentdb-backend.test.d.ts +7 -0
- package/src/@claude-flow/memory/dist/agentdb-backend.test.js +258 -0
- package/src/@claude-flow/memory/dist/application/commands/delete-memory.command.d.ts +65 -0
- package/src/@claude-flow/memory/dist/application/commands/delete-memory.command.js +129 -0
- package/src/@claude-flow/memory/dist/application/commands/store-memory.command.d.ts +48 -0
- package/src/@claude-flow/memory/dist/application/commands/store-memory.command.js +72 -0
- package/src/@claude-flow/memory/dist/application/index.d.ts +12 -0
- package/src/@claude-flow/memory/dist/application/index.js +15 -0
- package/src/@claude-flow/memory/dist/application/queries/search-memory.query.d.ts +72 -0
- package/src/@claude-flow/memory/dist/application/queries/search-memory.query.js +143 -0
- package/src/@claude-flow/memory/dist/application/services/memory-application-service.d.ts +121 -0
- package/src/@claude-flow/memory/dist/application/services/memory-application-service.js +190 -0
- package/src/@claude-flow/memory/dist/auto-memory-bridge.d.ts +226 -0
- package/src/@claude-flow/memory/dist/auto-memory-bridge.js +709 -0
- package/src/@claude-flow/memory/dist/auto-memory-bridge.test.d.ts +8 -0
- package/src/@claude-flow/memory/dist/auto-memory-bridge.test.js +757 -0
- package/src/@claude-flow/memory/dist/benchmark.test.d.ts +2 -0
- package/src/@claude-flow/memory/dist/benchmark.test.js +277 -0
- package/src/@claude-flow/memory/dist/cache-manager.d.ts +134 -0
- package/src/@claude-flow/memory/dist/cache-manager.js +407 -0
- package/src/@claude-flow/memory/dist/controller-registry.d.ts +216 -0
- package/src/@claude-flow/memory/dist/controller-registry.js +893 -0
- package/src/@claude-flow/memory/dist/controller-registry.test.d.ts +14 -0
- package/src/@claude-flow/memory/dist/controller-registry.test.js +593 -0
- package/src/@claude-flow/memory/dist/database-provider.d.ts +87 -0
- package/src/@claude-flow/memory/dist/database-provider.js +372 -0
- package/src/@claude-flow/memory/dist/database-provider.test.d.ts +7 -0
- package/src/@claude-flow/memory/dist/database-provider.test.js +287 -0
- package/src/@claude-flow/memory/dist/domain/entities/memory-entry.d.ts +143 -0
- package/src/@claude-flow/memory/dist/domain/entities/memory-entry.js +226 -0
- package/src/@claude-flow/memory/dist/domain/index.d.ts +11 -0
- package/src/@claude-flow/memory/dist/domain/index.js +12 -0
- package/src/@claude-flow/memory/dist/domain/repositories/memory-repository.interface.d.ts +102 -0
- package/src/@claude-flow/memory/dist/domain/repositories/memory-repository.interface.js +11 -0
- package/src/@claude-flow/memory/dist/domain/services/memory-domain-service.d.ts +105 -0
- package/src/@claude-flow/memory/dist/domain/services/memory-domain-service.js +297 -0
- package/src/@claude-flow/memory/dist/hnsw-index.d.ts +111 -0
- package/src/@claude-flow/memory/dist/hnsw-index.js +781 -0
- package/src/@claude-flow/memory/dist/hnsw-lite.d.ts +23 -0
- package/src/@claude-flow/memory/dist/hnsw-lite.js +168 -0
- package/src/@claude-flow/memory/dist/index.d.ts +204 -0
- package/src/@claude-flow/memory/dist/index.js +358 -0
- package/src/@claude-flow/memory/dist/infrastructure/index.d.ts +17 -0
- package/src/@claude-flow/memory/dist/infrastructure/index.js +16 -0
- package/src/@claude-flow/memory/dist/infrastructure/repositories/hybrid-memory-repository.d.ts +66 -0
- package/src/@claude-flow/memory/dist/infrastructure/repositories/hybrid-memory-repository.js +409 -0
- package/src/@claude-flow/memory/dist/learning-bridge.d.ts +137 -0
- package/src/@claude-flow/memory/dist/learning-bridge.js +335 -0
- package/src/@claude-flow/memory/dist/learning-bridge.test.d.ts +8 -0
- package/src/@claude-flow/memory/dist/learning-bridge.test.js +578 -0
- package/src/@claude-flow/memory/dist/memory-graph.d.ts +100 -0
- package/src/@claude-flow/memory/dist/memory-graph.js +333 -0
- package/src/@claude-flow/memory/dist/memory-graph.test.d.ts +8 -0
- package/src/@claude-flow/memory/dist/memory-graph.test.js +609 -0
- package/src/@claude-flow/memory/dist/migration.d.ts +68 -0
- package/src/@claude-flow/memory/dist/migration.js +513 -0
- package/src/@claude-flow/memory/dist/persistent-sona.d.ts +144 -0
- package/src/@claude-flow/memory/dist/persistent-sona.js +332 -0
- package/src/@claude-flow/memory/dist/query-builder.d.ts +211 -0
- package/src/@claude-flow/memory/dist/query-builder.js +438 -0
- package/src/@claude-flow/memory/dist/rvf-backend.d.ts +51 -0
- package/src/@claude-flow/memory/dist/rvf-backend.js +481 -0
- package/src/@claude-flow/memory/dist/rvf-learning-store.d.ts +139 -0
- package/src/@claude-flow/memory/dist/rvf-learning-store.js +295 -0
- package/src/@claude-flow/memory/dist/rvf-migration.d.ts +45 -0
- package/src/@claude-flow/memory/dist/rvf-migration.js +234 -0
- package/src/@claude-flow/memory/dist/sqljs-backend.d.ts +127 -0
- package/src/@claude-flow/memory/dist/sqljs-backend.js +600 -0
- package/src/@claude-flow/memory/dist/types.d.ts +484 -0
- package/src/@claude-flow/memory/dist/types.js +58 -0
- package/src/@claude-flow/shared/dist/core/config/defaults.d.ts +41 -0
- package/src/@claude-flow/shared/dist/core/config/defaults.js +186 -0
- package/src/@claude-flow/shared/dist/core/config/index.d.ts +8 -0
- package/src/@claude-flow/shared/dist/core/config/index.js +12 -0
- package/src/@claude-flow/shared/dist/core/config/loader.d.ts +45 -0
- package/src/@claude-flow/shared/dist/core/config/loader.js +222 -0
- package/src/@claude-flow/shared/dist/core/config/schema.d.ts +1134 -0
- package/src/@claude-flow/shared/dist/core/config/schema.js +158 -0
- package/src/@claude-flow/shared/dist/core/config/validator.d.ts +92 -0
- package/src/@claude-flow/shared/dist/core/config/validator.js +147 -0
- package/src/@claude-flow/shared/dist/core/event-bus.d.ts +31 -0
- package/src/@claude-flow/shared/dist/core/event-bus.js +197 -0
- package/src/@claude-flow/shared/dist/core/index.d.ts +15 -0
- package/src/@claude-flow/shared/dist/core/index.js +19 -0
- package/src/@claude-flow/shared/dist/core/interfaces/agent.interface.d.ts +200 -0
- package/src/@claude-flow/shared/dist/core/interfaces/agent.interface.js +6 -0
- package/src/@claude-flow/shared/dist/core/interfaces/coordinator.interface.d.ts +310 -0
- package/src/@claude-flow/shared/dist/core/interfaces/coordinator.interface.js +7 -0
- package/src/@claude-flow/shared/dist/core/interfaces/event.interface.d.ts +224 -0
- package/src/@claude-flow/shared/dist/core/interfaces/event.interface.js +46 -0
- package/src/@claude-flow/shared/dist/core/interfaces/index.d.ts +10 -0
- package/src/@claude-flow/shared/dist/core/interfaces/index.js +15 -0
- package/src/@claude-flow/shared/dist/core/interfaces/memory.interface.d.ts +298 -0
- package/src/@claude-flow/shared/dist/core/interfaces/memory.interface.js +7 -0
- package/src/@claude-flow/shared/dist/core/interfaces/task.interface.d.ts +185 -0
- package/src/@claude-flow/shared/dist/core/interfaces/task.interface.js +6 -0
- package/src/@claude-flow/shared/dist/core/orchestrator/event-coordinator.d.ts +35 -0
- package/src/@claude-flow/shared/dist/core/orchestrator/event-coordinator.js +101 -0
- package/src/@claude-flow/shared/dist/core/orchestrator/health-monitor.d.ts +60 -0
- package/src/@claude-flow/shared/dist/core/orchestrator/health-monitor.js +166 -0
- package/src/@claude-flow/shared/dist/core/orchestrator/index.d.ts +46 -0
- package/src/@claude-flow/shared/dist/core/orchestrator/index.js +64 -0
- package/src/@claude-flow/shared/dist/core/orchestrator/lifecycle-manager.d.ts +56 -0
- package/src/@claude-flow/shared/dist/core/orchestrator/lifecycle-manager.js +195 -0
- package/src/@claude-flow/shared/dist/core/orchestrator/session-manager.d.ts +83 -0
- package/src/@claude-flow/shared/dist/core/orchestrator/session-manager.js +193 -0
- package/src/@claude-flow/shared/dist/core/orchestrator/task-manager.d.ts +49 -0
- package/src/@claude-flow/shared/dist/core/orchestrator/task-manager.js +253 -0
- package/src/@claude-flow/shared/dist/events/domain-events.d.ts +282 -0
- package/src/@claude-flow/shared/dist/events/domain-events.js +165 -0
- package/src/@claude-flow/shared/dist/events/event-store.d.ts +126 -0
- package/src/@claude-flow/shared/dist/events/event-store.js +432 -0
- package/src/@claude-flow/shared/dist/events/event-store.test.d.ts +8 -0
- package/src/@claude-flow/shared/dist/events/event-store.test.js +297 -0
- package/src/@claude-flow/shared/dist/events/example-usage.d.ts +10 -0
- package/src/@claude-flow/shared/dist/events/example-usage.js +193 -0
- package/src/@claude-flow/shared/dist/events/index.d.ts +21 -0
- package/src/@claude-flow/shared/dist/events/index.js +22 -0
- package/src/@claude-flow/shared/dist/events/projections.d.ts +177 -0
- package/src/@claude-flow/shared/dist/events/projections.js +421 -0
- package/src/@claude-flow/shared/dist/events/rvf-event-log.d.ts +82 -0
- package/src/@claude-flow/shared/dist/events/rvf-event-log.js +340 -0
- package/src/@claude-flow/shared/dist/events/state-reconstructor.d.ts +101 -0
- package/src/@claude-flow/shared/dist/events/state-reconstructor.js +263 -0
- package/src/@claude-flow/shared/dist/events.d.ts +80 -0
- package/src/@claude-flow/shared/dist/events.js +249 -0
- package/src/@claude-flow/shared/dist/hooks/example-usage.d.ts +42 -0
- package/src/@claude-flow/shared/dist/hooks/example-usage.js +351 -0
- package/src/@claude-flow/shared/dist/hooks/executor.d.ts +100 -0
- package/src/@claude-flow/shared/dist/hooks/executor.js +267 -0
- package/src/@claude-flow/shared/dist/hooks/hooks.test.d.ts +9 -0
- package/src/@claude-flow/shared/dist/hooks/hooks.test.js +322 -0
- package/src/@claude-flow/shared/dist/hooks/index.d.ts +52 -0
- package/src/@claude-flow/shared/dist/hooks/index.js +51 -0
- package/src/@claude-flow/shared/dist/hooks/registry.d.ts +133 -0
- package/src/@claude-flow/shared/dist/hooks/registry.js +277 -0
- package/src/@claude-flow/shared/dist/hooks/safety/bash-safety.d.ts +105 -0
- package/src/@claude-flow/shared/dist/hooks/safety/bash-safety.js +481 -0
- package/src/@claude-flow/shared/dist/hooks/safety/file-organization.d.ts +144 -0
- package/src/@claude-flow/shared/dist/hooks/safety/file-organization.js +328 -0
- package/src/@claude-flow/shared/dist/hooks/safety/git-commit.d.ts +158 -0
- package/src/@claude-flow/shared/dist/hooks/safety/git-commit.js +450 -0
- package/src/@claude-flow/shared/dist/hooks/safety/index.d.ts +17 -0
- package/src/@claude-flow/shared/dist/hooks/safety/index.js +17 -0
- package/src/@claude-flow/shared/dist/hooks/session-hooks.d.ts +234 -0
- package/src/@claude-flow/shared/dist/hooks/session-hooks.js +334 -0
- package/src/@claude-flow/shared/dist/hooks/task-hooks.d.ts +163 -0
- package/src/@claude-flow/shared/dist/hooks/task-hooks.js +326 -0
- package/src/@claude-flow/shared/dist/hooks/types.d.ts +267 -0
- package/src/@claude-flow/shared/dist/hooks/types.js +62 -0
- package/src/@claude-flow/shared/dist/hooks/verify-exports.test.d.ts +9 -0
- package/src/@claude-flow/shared/dist/hooks/verify-exports.test.js +93 -0
- package/src/@claude-flow/shared/dist/index.d.ts +20 -0
- package/src/@claude-flow/shared/dist/index.js +50 -0
- package/src/@claude-flow/shared/dist/mcp/connection-pool.d.ts +98 -0
- package/src/@claude-flow/shared/dist/mcp/connection-pool.js +364 -0
- package/src/@claude-flow/shared/dist/mcp/index.d.ts +69 -0
- package/src/@claude-flow/shared/dist/mcp/index.js +84 -0
- package/src/@claude-flow/shared/dist/mcp/server.d.ts +166 -0
- package/src/@claude-flow/shared/dist/mcp/server.js +593 -0
- package/src/@claude-flow/shared/dist/mcp/session-manager.d.ts +136 -0
- package/src/@claude-flow/shared/dist/mcp/session-manager.js +335 -0
- package/src/@claude-flow/shared/dist/mcp/tool-registry.d.ts +178 -0
- package/src/@claude-flow/shared/dist/mcp/tool-registry.js +439 -0
- package/src/@claude-flow/shared/dist/mcp/transport/http.d.ts +104 -0
- package/src/@claude-flow/shared/dist/mcp/transport/http.js +476 -0
- package/src/@claude-flow/shared/dist/mcp/transport/index.d.ts +102 -0
- package/src/@claude-flow/shared/dist/mcp/transport/index.js +238 -0
- package/src/@claude-flow/shared/dist/mcp/transport/stdio.d.ts +104 -0
- package/src/@claude-flow/shared/dist/mcp/transport/stdio.js +263 -0
- package/src/@claude-flow/shared/dist/mcp/transport/websocket.d.ts +133 -0
- package/src/@claude-flow/shared/dist/mcp/transport/websocket.js +396 -0
- package/src/@claude-flow/shared/dist/mcp/types.d.ts +438 -0
- package/src/@claude-flow/shared/dist/mcp/types.js +54 -0
- package/src/@claude-flow/shared/dist/plugin-interface.d.ts +544 -0
- package/src/@claude-flow/shared/dist/plugin-interface.js +23 -0
- package/src/@claude-flow/shared/dist/plugin-loader.d.ts +139 -0
- package/src/@claude-flow/shared/dist/plugin-loader.js +434 -0
- package/src/@claude-flow/shared/dist/plugin-registry.d.ts +183 -0
- package/src/@claude-flow/shared/dist/plugin-registry.js +457 -0
- package/src/@claude-flow/shared/dist/plugins/index.d.ts +10 -0
- package/src/@claude-flow/shared/dist/plugins/index.js +10 -0
- package/src/@claude-flow/shared/dist/plugins/official/hive-mind-plugin.d.ts +106 -0
- package/src/@claude-flow/shared/dist/plugins/official/hive-mind-plugin.js +241 -0
- package/src/@claude-flow/shared/dist/plugins/official/index.d.ts +10 -0
- package/src/@claude-flow/shared/dist/plugins/official/index.js +10 -0
- package/src/@claude-flow/shared/dist/plugins/official/maestro-plugin.d.ts +121 -0
- package/src/@claude-flow/shared/dist/plugins/official/maestro-plugin.js +355 -0
- package/src/@claude-flow/shared/dist/plugins/types.d.ts +93 -0
- package/src/@claude-flow/shared/dist/plugins/types.js +9 -0
- package/src/@claude-flow/shared/dist/resilience/bulkhead.d.ts +105 -0
- package/src/@claude-flow/shared/dist/resilience/bulkhead.js +206 -0
- package/src/@claude-flow/shared/dist/resilience/circuit-breaker.d.ts +132 -0
- package/src/@claude-flow/shared/dist/resilience/circuit-breaker.js +233 -0
- package/src/@claude-flow/shared/dist/resilience/index.d.ts +19 -0
- package/src/@claude-flow/shared/dist/resilience/index.js +19 -0
- package/src/@claude-flow/shared/dist/resilience/rate-limiter.d.ts +168 -0
- package/src/@claude-flow/shared/dist/resilience/rate-limiter.js +314 -0
- package/src/@claude-flow/shared/dist/resilience/retry.d.ts +91 -0
- package/src/@claude-flow/shared/dist/resilience/retry.js +159 -0
- package/src/@claude-flow/shared/dist/security/index.d.ts +10 -0
- package/src/@claude-flow/shared/dist/security/index.js +12 -0
- package/src/@claude-flow/shared/dist/security/input-validation.d.ts +73 -0
- package/src/@claude-flow/shared/dist/security/input-validation.js +201 -0
- package/src/@claude-flow/shared/dist/security/secure-random.d.ts +92 -0
- package/src/@claude-flow/shared/dist/security/secure-random.js +142 -0
- package/src/@claude-flow/shared/dist/services/index.d.ts +7 -0
- package/src/@claude-flow/shared/dist/services/index.js +7 -0
- package/src/@claude-flow/shared/dist/services/v3-progress.service.d.ts +124 -0
- package/src/@claude-flow/shared/dist/services/v3-progress.service.js +402 -0
- package/src/@claude-flow/shared/dist/types/agent.types.d.ts +137 -0
- package/src/@claude-flow/shared/dist/types/agent.types.js +6 -0
- package/src/@claude-flow/shared/dist/types/index.d.ts +11 -0
- package/src/@claude-flow/shared/dist/types/index.js +17 -0
- package/src/@claude-flow/shared/dist/types/mcp.types.d.ts +266 -0
- package/src/@claude-flow/shared/dist/types/mcp.types.js +7 -0
- package/src/@claude-flow/shared/dist/types/memory.types.d.ts +236 -0
- package/src/@claude-flow/shared/dist/types/memory.types.js +7 -0
- package/src/@claude-flow/shared/dist/types/swarm.types.d.ts +186 -0
- package/src/@claude-flow/shared/dist/types/swarm.types.js +65 -0
- package/src/@claude-flow/shared/dist/types/task.types.d.ts +178 -0
- package/src/@claude-flow/shared/dist/types/task.types.js +32 -0
- package/src/@claude-flow/shared/dist/types.d.ts +197 -0
- package/src/@claude-flow/shared/dist/types.js +21 -0
- package/src/@claude-flow/shared/dist/utils/secure-logger.d.ts +69 -0
- package/src/@claude-flow/shared/dist/utils/secure-logger.js +208 -0
|
@@ -31,6 +31,51 @@ npx flo doctor --fix # Verify everything is working
|
|
|
31
31
|
|
|
32
32
|
---
|
|
33
33
|
|
|
34
|
+
## Building from Source
|
|
35
|
+
|
|
36
|
+
Moflo is a TypeScript monorepo using **project references** (`tsc -b`). The root `tsconfig.json` is a solution-style config that delegates to `src/tsconfig.json`, which references all 17 `@claude-flow/*` sub-packages.
|
|
37
|
+
|
|
38
|
+
### Build Commands
|
|
39
|
+
|
|
40
|
+
```bash
|
|
41
|
+
npm run build # Runs tsc -b (project references build)
|
|
42
|
+
npm run build:ts # Build @claude-flow/cli only (legacy shortcut)
|
|
43
|
+
npm run build:guidance # Build @claude-flow/guidance only (legacy shortcut)
|
|
44
|
+
```
|
|
45
|
+
|
|
46
|
+
### Architecture
|
|
47
|
+
|
|
48
|
+
```
|
|
49
|
+
tsconfig.json → Solution root (references src/)
|
|
50
|
+
src/tsconfig.json → References all @claude-flow/* packages
|
|
51
|
+
src/tsconfig.base.json → Shared compilerOptions (ES2022, bundler, composite)
|
|
52
|
+
src/@claude-flow/shared/ → Base types (no deps)
|
|
53
|
+
src/@claude-flow/cli/ → CLI + MCP server (depends on shared, swarm)
|
|
54
|
+
src/@claude-flow/hooks/ → Hook system (depends on shared, neural, memory)
|
|
55
|
+
src/@claude-flow/memory/ → Memory backends (no deps)
|
|
56
|
+
src/@claude-flow/guidance/ → Guidance indexing (depends on hooks)
|
|
57
|
+
src/@claude-flow/testing/ → Regression tests (depends on shared, memory, swarm)
|
|
58
|
+
... (17 packages total)
|
|
59
|
+
```
|
|
60
|
+
|
|
61
|
+
### Important Rules
|
|
62
|
+
|
|
63
|
+
1. **Always build from root** — `npm run build` (which runs `tsc -b`) builds all packages in dependency order. Do NOT build individual packages in isolation unless you know what you're doing.
|
|
64
|
+
2. **Never bypass the build** — The `dist/` directories contain compiled JS that ships with `npm publish`. If you edit `.ts` source, you MUST rebuild before publishing.
|
|
65
|
+
3. **Do not work around build errors** — If `tsc -b` fails, fix the type errors. Do not manually compile individual packages to skip errors, as this leads to drift between source and compiled output.
|
|
66
|
+
4. **Sub-packages need `composite: true`** — Every sub-package tsconfig must have `"composite": true` in compilerOptions for project references to work.
|
|
67
|
+
5. **Cross-package imports need `paths`** — If package A imports from `@claude-flow/B`, package A's tsconfig needs both a `"references"` entry and a `"paths"` mapping pointing to B's source.
|
|
68
|
+
|
|
69
|
+
### Publishing
|
|
70
|
+
|
|
71
|
+
```bash
|
|
72
|
+
npm version patch # Bump version (auto-syncs cli sub-package version)
|
|
73
|
+
npm run build # MUST succeed with zero errors
|
|
74
|
+
npm publish --otp=XXX # Requires 2FA OTP
|
|
75
|
+
```
|
|
76
|
+
|
|
77
|
+
---
|
|
78
|
+
|
|
34
79
|
## Session Start Automation
|
|
35
80
|
|
|
36
81
|
When a Claude Code session starts, moflo automatically runs three background indexers:
|
package/package.json
CHANGED
|
@@ -1,6 +1,6 @@
|
|
|
1
1
|
{
|
|
2
2
|
"name": "moflo",
|
|
3
|
-
"version": "4.8.
|
|
3
|
+
"version": "4.8.20",
|
|
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",
|
|
@@ -47,7 +47,7 @@
|
|
|
47
47
|
],
|
|
48
48
|
"scripts": {
|
|
49
49
|
"dev": "tsx watch src/index.ts",
|
|
50
|
-
"build": "tsc",
|
|
50
|
+
"build": "tsc -b",
|
|
51
51
|
"build:ts": "cd src/@claude-flow/cli && npm run build || true",
|
|
52
52
|
"build:guidance": "cd src/@claude-flow/guidance && npx tsc -p tsconfig.json || true",
|
|
53
53
|
"prepublishOnly": "npm run build:ts && npm run build:guidance",
|
|
@@ -7,9 +7,11 @@
|
|
|
7
7
|
*
|
|
8
8
|
* @module agentic-flow-bridge
|
|
9
9
|
*/
|
|
10
|
-
// Suppress agentic-flow
|
|
11
|
-
// agentdb v1.
|
|
12
|
-
//
|
|
10
|
+
// Suppress the agentic-flow agentdb-runtime-patch warning.
|
|
11
|
+
// The patch targets agentdb v1.3.9 (dist/controllers/index.js) but
|
|
12
|
+
// agentdb v3+ moved to dist/src/controllers/ and already ships with
|
|
13
|
+
// correct .js extensions. The patch is unnecessary and prints a
|
|
14
|
+
// confusing "[AgentDB Patch] Controller index not found" warning.
|
|
13
15
|
if (typeof process !== 'undefined' && !process.env.SKIP_AGENTDB_PATCH) {
|
|
14
16
|
process.env.SKIP_AGENTDB_PATCH = '1';
|
|
15
17
|
}
|
|
@@ -1,6 +1,6 @@
|
|
|
1
1
|
{
|
|
2
2
|
"name": "@moflo/cli",
|
|
3
|
-
"version": "4.8.
|
|
3
|
+
"version": "4.8.20",
|
|
4
4
|
"type": "module",
|
|
5
5
|
"description": "MoFlo CLI — AI agent orchestration with specialized agents, swarm coordination, MCP server, self-learning hooks, and vector memory for Claude Code",
|
|
6
6
|
"main": "dist/src/index.js",
|
|
@@ -0,0 +1,131 @@
|
|
|
1
|
+
/**
|
|
2
|
+
* Agent-Scoped Memory - Support for Claude Code's 3-scope agent memory directories
|
|
3
|
+
*
|
|
4
|
+
* Claude Code organizes agent memory into three scopes:
|
|
5
|
+
* - **project**: Shared across all collaborators (checked into git)
|
|
6
|
+
* - **local**: Machine-specific, not shared (gitignored)
|
|
7
|
+
* - **user**: Global per-user, spans all projects
|
|
8
|
+
*
|
|
9
|
+
* Each scope stores agent-specific memory in a named subdirectory,
|
|
10
|
+
* enabling isolated yet transferable knowledge between agents.
|
|
11
|
+
*
|
|
12
|
+
* @module @claude-flow/memory/agent-memory-scope
|
|
13
|
+
*/
|
|
14
|
+
import type { IMemoryBackend } from './types.js';
|
|
15
|
+
import { AutoMemoryBridge } from './auto-memory-bridge.js';
|
|
16
|
+
import type { AutoMemoryBridgeConfig, InsightCategory } from './auto-memory-bridge.js';
|
|
17
|
+
/** Claude Code's 3-scope agent memory system */
|
|
18
|
+
export type AgentMemoryScope = 'project' | 'local' | 'user';
|
|
19
|
+
/** Configuration for agent-scoped memory bridge */
|
|
20
|
+
export interface AgentScopedConfig extends AutoMemoryBridgeConfig {
|
|
21
|
+
/** Agent name (used in directory path) */
|
|
22
|
+
agentName: string;
|
|
23
|
+
/** Memory scope */
|
|
24
|
+
scope: AgentMemoryScope;
|
|
25
|
+
}
|
|
26
|
+
/** Options for knowledge transfer between agents */
|
|
27
|
+
export interface TransferOptions {
|
|
28
|
+
/** Source namespace to transfer from */
|
|
29
|
+
sourceNamespace: string;
|
|
30
|
+
/** Minimum confidence to include (default: 0.8) */
|
|
31
|
+
minConfidence?: number;
|
|
32
|
+
/** Maximum entries to transfer (default: 20) */
|
|
33
|
+
maxEntries?: number;
|
|
34
|
+
/** Filter by categories */
|
|
35
|
+
categories?: InsightCategory[];
|
|
36
|
+
}
|
|
37
|
+
/** Result of a knowledge transfer */
|
|
38
|
+
export interface TransferResult {
|
|
39
|
+
/** Number of entries transferred */
|
|
40
|
+
transferred: number;
|
|
41
|
+
/** Number of entries skipped (below threshold or duplicate) */
|
|
42
|
+
skipped: number;
|
|
43
|
+
}
|
|
44
|
+
/**
|
|
45
|
+
* Resolve the agent memory directory for a given agent name, scope, and working directory.
|
|
46
|
+
*
|
|
47
|
+
* Path resolution matches Claude Code binary behavior:
|
|
48
|
+
* ```
|
|
49
|
+
* project: <gitRoot>/.claude/agent-memory/<agentName>/
|
|
50
|
+
* local: <gitRoot>/.claude/agent-memory-local/<agentName>/
|
|
51
|
+
* user: ~/.claude/agent-memory/<agentName>/
|
|
52
|
+
* ```
|
|
53
|
+
*
|
|
54
|
+
* Agent names are sanitized to prevent path traversal attacks.
|
|
55
|
+
*
|
|
56
|
+
* @param agentName - The agent identifier
|
|
57
|
+
* @param scope - Memory scope: project, local, or user
|
|
58
|
+
* @param workingDir - Working directory for git root detection (defaults to cwd)
|
|
59
|
+
* @returns Absolute path to the agent's memory directory
|
|
60
|
+
*/
|
|
61
|
+
export declare function resolveAgentMemoryDir(agentName: string, scope: AgentMemoryScope, workingDir?: string): string;
|
|
62
|
+
/**
|
|
63
|
+
* Create an AutoMemoryBridge configured for a specific agent scope.
|
|
64
|
+
*
|
|
65
|
+
* This is the primary factory for creating scoped bridges. It resolves
|
|
66
|
+
* the correct memory directory based on agent name and scope, then
|
|
67
|
+
* delegates to AutoMemoryBridge for the actual sync logic.
|
|
68
|
+
*
|
|
69
|
+
* @param backend - The AgentDB memory backend
|
|
70
|
+
* @param config - Agent-scoped configuration
|
|
71
|
+
* @returns A configured AutoMemoryBridge instance
|
|
72
|
+
*
|
|
73
|
+
* @example
|
|
74
|
+
* ```typescript
|
|
75
|
+
* const bridge = createAgentBridge(backend, {
|
|
76
|
+
* agentName: 'coder',
|
|
77
|
+
* scope: 'project',
|
|
78
|
+
* syncMode: 'on-write',
|
|
79
|
+
* });
|
|
80
|
+
* await bridge.recordInsight({ ... });
|
|
81
|
+
* ```
|
|
82
|
+
*/
|
|
83
|
+
export declare function createAgentBridge(backend: IMemoryBackend, config: AgentScopedConfig): AutoMemoryBridge;
|
|
84
|
+
/**
|
|
85
|
+
* Transfer knowledge from a source backend namespace into a target bridge.
|
|
86
|
+
*
|
|
87
|
+
* Queries high-confidence entries from the source and records them as
|
|
88
|
+
* insights in the target bridge. Useful for cross-agent knowledge sharing
|
|
89
|
+
* or promoting learnings from one scope to another.
|
|
90
|
+
*
|
|
91
|
+
* @param sourceBackend - Backend to query entries from
|
|
92
|
+
* @param targetBridge - Bridge to record insights into
|
|
93
|
+
* @param options - Transfer options (namespace, filters, limits)
|
|
94
|
+
* @returns Transfer result with counts of transferred and skipped entries
|
|
95
|
+
*
|
|
96
|
+
* @example
|
|
97
|
+
* ```typescript
|
|
98
|
+
* const result = await transferKnowledge(sourceBackend, targetBridge, {
|
|
99
|
+
* sourceNamespace: 'learnings',
|
|
100
|
+
* minConfidence: 0.9,
|
|
101
|
+
* maxEntries: 10,
|
|
102
|
+
* categories: ['architecture', 'security'],
|
|
103
|
+
* });
|
|
104
|
+
* console.log(`Transferred ${result.transferred}, skipped ${result.skipped}`);
|
|
105
|
+
* ```
|
|
106
|
+
*/
|
|
107
|
+
export declare function transferKnowledge(sourceBackend: IMemoryBackend, targetBridge: AutoMemoryBridge, options: TransferOptions): Promise<TransferResult>;
|
|
108
|
+
/**
|
|
109
|
+
* List all agent scopes and their agents for the current project.
|
|
110
|
+
*
|
|
111
|
+
* Scans the three scope directories (project, local, user) and returns
|
|
112
|
+
* the agent names found in each. Useful for discovery and diagnostics.
|
|
113
|
+
*
|
|
114
|
+
* @param workingDir - Working directory for git root detection (defaults to cwd)
|
|
115
|
+
* @returns Array of scope/agents pairs
|
|
116
|
+
*
|
|
117
|
+
* @example
|
|
118
|
+
* ```typescript
|
|
119
|
+
* const scopes = listAgentScopes('/workspaces/my-project');
|
|
120
|
+
* // [
|
|
121
|
+
* // { scope: 'project', agents: ['coder', 'tester'] },
|
|
122
|
+
* // { scope: 'local', agents: ['researcher'] },
|
|
123
|
+
* // { scope: 'user', agents: ['planner'] },
|
|
124
|
+
* // ]
|
|
125
|
+
* ```
|
|
126
|
+
*/
|
|
127
|
+
export declare function listAgentScopes(workingDir?: string): Array<{
|
|
128
|
+
scope: AgentMemoryScope;
|
|
129
|
+
agents: string[];
|
|
130
|
+
}>;
|
|
131
|
+
//# sourceMappingURL=agent-memory-scope.d.ts.map
|
|
@@ -0,0 +1,223 @@
|
|
|
1
|
+
/**
|
|
2
|
+
* Agent-Scoped Memory - Support for Claude Code's 3-scope agent memory directories
|
|
3
|
+
*
|
|
4
|
+
* Claude Code organizes agent memory into three scopes:
|
|
5
|
+
* - **project**: Shared across all collaborators (checked into git)
|
|
6
|
+
* - **local**: Machine-specific, not shared (gitignored)
|
|
7
|
+
* - **user**: Global per-user, spans all projects
|
|
8
|
+
*
|
|
9
|
+
* Each scope stores agent-specific memory in a named subdirectory,
|
|
10
|
+
* enabling isolated yet transferable knowledge between agents.
|
|
11
|
+
*
|
|
12
|
+
* @module @claude-flow/memory/agent-memory-scope
|
|
13
|
+
*/
|
|
14
|
+
import * as path from 'node:path';
|
|
15
|
+
import { existsSync, readdirSync, statSync } from 'node:fs';
|
|
16
|
+
import { AutoMemoryBridge } from './auto-memory-bridge.js';
|
|
17
|
+
// ===== Internal Helpers =====
|
|
18
|
+
/**
|
|
19
|
+
* Find the git root directory by walking up from a starting directory.
|
|
20
|
+
* Synchronous variant for path resolution (no async needed for stat checks).
|
|
21
|
+
*/
|
|
22
|
+
function findGitRootSync(dir) {
|
|
23
|
+
let current = path.resolve(dir);
|
|
24
|
+
const root = path.parse(current).root;
|
|
25
|
+
while (current !== root) {
|
|
26
|
+
if (existsSync(path.join(current, '.git'))) {
|
|
27
|
+
return current;
|
|
28
|
+
}
|
|
29
|
+
current = path.dirname(current);
|
|
30
|
+
}
|
|
31
|
+
return null;
|
|
32
|
+
}
|
|
33
|
+
/**
|
|
34
|
+
* List agent subdirectories inside a given directory.
|
|
35
|
+
* Returns an empty array if the directory does not exist or is unreadable.
|
|
36
|
+
*/
|
|
37
|
+
function listAgentsInDir(dir) {
|
|
38
|
+
if (!existsSync(dir))
|
|
39
|
+
return [];
|
|
40
|
+
try {
|
|
41
|
+
return readdirSync(dir).filter((name) => {
|
|
42
|
+
try {
|
|
43
|
+
return statSync(path.join(dir, name)).isDirectory();
|
|
44
|
+
}
|
|
45
|
+
catch {
|
|
46
|
+
return false;
|
|
47
|
+
}
|
|
48
|
+
});
|
|
49
|
+
}
|
|
50
|
+
catch {
|
|
51
|
+
return [];
|
|
52
|
+
}
|
|
53
|
+
}
|
|
54
|
+
// ===== Public Functions =====
|
|
55
|
+
/**
|
|
56
|
+
* Resolve the agent memory directory for a given agent name, scope, and working directory.
|
|
57
|
+
*
|
|
58
|
+
* Path resolution matches Claude Code binary behavior:
|
|
59
|
+
* ```
|
|
60
|
+
* project: <gitRoot>/.claude/agent-memory/<agentName>/
|
|
61
|
+
* local: <gitRoot>/.claude/agent-memory-local/<agentName>/
|
|
62
|
+
* user: ~/.claude/agent-memory/<agentName>/
|
|
63
|
+
* ```
|
|
64
|
+
*
|
|
65
|
+
* Agent names are sanitized to prevent path traversal attacks.
|
|
66
|
+
*
|
|
67
|
+
* @param agentName - The agent identifier
|
|
68
|
+
* @param scope - Memory scope: project, local, or user
|
|
69
|
+
* @param workingDir - Working directory for git root detection (defaults to cwd)
|
|
70
|
+
* @returns Absolute path to the agent's memory directory
|
|
71
|
+
*/
|
|
72
|
+
export function resolveAgentMemoryDir(agentName, scope, workingDir) {
|
|
73
|
+
// Sanitize agent name to prevent path traversal
|
|
74
|
+
const safeName = agentName.replace(/[^a-zA-Z0-9_-]/g, '_');
|
|
75
|
+
if (scope === 'user') {
|
|
76
|
+
const home = process.env.HOME
|
|
77
|
+
|| process.env.USERPROFILE
|
|
78
|
+
|| (process.env.HOMEDRIVE && process.env.HOMEPATH ? process.env.HOMEDRIVE + process.env.HOMEPATH : '');
|
|
79
|
+
if (!home) {
|
|
80
|
+
throw new Error('Cannot determine home directory: HOME, USERPROFILE, and HOMEDRIVE+HOMEPATH are all undefined');
|
|
81
|
+
}
|
|
82
|
+
return path.join(home, '.claude', 'agent-memory', safeName);
|
|
83
|
+
}
|
|
84
|
+
// For project and local scopes, find git root
|
|
85
|
+
const effectiveDir = workingDir || process.cwd();
|
|
86
|
+
const gitRoot = findGitRootSync(effectiveDir);
|
|
87
|
+
const baseDir = gitRoot || effectiveDir;
|
|
88
|
+
if (scope === 'local') {
|
|
89
|
+
return path.join(baseDir, '.claude', 'agent-memory-local', safeName);
|
|
90
|
+
}
|
|
91
|
+
// scope === 'project'
|
|
92
|
+
return path.join(baseDir, '.claude', 'agent-memory', safeName);
|
|
93
|
+
}
|
|
94
|
+
/**
|
|
95
|
+
* Create an AutoMemoryBridge configured for a specific agent scope.
|
|
96
|
+
*
|
|
97
|
+
* This is the primary factory for creating scoped bridges. It resolves
|
|
98
|
+
* the correct memory directory based on agent name and scope, then
|
|
99
|
+
* delegates to AutoMemoryBridge for the actual sync logic.
|
|
100
|
+
*
|
|
101
|
+
* @param backend - The AgentDB memory backend
|
|
102
|
+
* @param config - Agent-scoped configuration
|
|
103
|
+
* @returns A configured AutoMemoryBridge instance
|
|
104
|
+
*
|
|
105
|
+
* @example
|
|
106
|
+
* ```typescript
|
|
107
|
+
* const bridge = createAgentBridge(backend, {
|
|
108
|
+
* agentName: 'coder',
|
|
109
|
+
* scope: 'project',
|
|
110
|
+
* syncMode: 'on-write',
|
|
111
|
+
* });
|
|
112
|
+
* await bridge.recordInsight({ ... });
|
|
113
|
+
* ```
|
|
114
|
+
*/
|
|
115
|
+
export function createAgentBridge(backend, config) {
|
|
116
|
+
const memoryDir = resolveAgentMemoryDir(config.agentName, config.scope, config.workingDir);
|
|
117
|
+
return new AutoMemoryBridge(backend, {
|
|
118
|
+
...config,
|
|
119
|
+
memoryDir,
|
|
120
|
+
});
|
|
121
|
+
}
|
|
122
|
+
/**
|
|
123
|
+
* Transfer knowledge from a source backend namespace into a target bridge.
|
|
124
|
+
*
|
|
125
|
+
* Queries high-confidence entries from the source and records them as
|
|
126
|
+
* insights in the target bridge. Useful for cross-agent knowledge sharing
|
|
127
|
+
* or promoting learnings from one scope to another.
|
|
128
|
+
*
|
|
129
|
+
* @param sourceBackend - Backend to query entries from
|
|
130
|
+
* @param targetBridge - Bridge to record insights into
|
|
131
|
+
* @param options - Transfer options (namespace, filters, limits)
|
|
132
|
+
* @returns Transfer result with counts of transferred and skipped entries
|
|
133
|
+
*
|
|
134
|
+
* @example
|
|
135
|
+
* ```typescript
|
|
136
|
+
* const result = await transferKnowledge(sourceBackend, targetBridge, {
|
|
137
|
+
* sourceNamespace: 'learnings',
|
|
138
|
+
* minConfidence: 0.9,
|
|
139
|
+
* maxEntries: 10,
|
|
140
|
+
* categories: ['architecture', 'security'],
|
|
141
|
+
* });
|
|
142
|
+
* console.log(`Transferred ${result.transferred}, skipped ${result.skipped}`);
|
|
143
|
+
* ```
|
|
144
|
+
*/
|
|
145
|
+
export async function transferKnowledge(sourceBackend, targetBridge, options) {
|
|
146
|
+
const { sourceNamespace, minConfidence = 0.8, maxEntries = 20, categories, } = options;
|
|
147
|
+
let transferred = 0;
|
|
148
|
+
let skipped = 0;
|
|
149
|
+
// Query high-confidence entries from source (fetch extra to allow for filtering)
|
|
150
|
+
const entries = await sourceBackend.query({
|
|
151
|
+
type: 'hybrid',
|
|
152
|
+
namespace: sourceNamespace,
|
|
153
|
+
tags: ['insight'],
|
|
154
|
+
limit: maxEntries * 2,
|
|
155
|
+
});
|
|
156
|
+
for (const entry of entries) {
|
|
157
|
+
if (transferred >= maxEntries)
|
|
158
|
+
break;
|
|
159
|
+
const confidence = entry.metadata?.confidence || 0;
|
|
160
|
+
if (confidence < minConfidence) {
|
|
161
|
+
skipped++;
|
|
162
|
+
continue;
|
|
163
|
+
}
|
|
164
|
+
// Filter by category if specified
|
|
165
|
+
const entryCategory = entry.metadata?.category;
|
|
166
|
+
if (categories &&
|
|
167
|
+
categories.length > 0 &&
|
|
168
|
+
entryCategory &&
|
|
169
|
+
!categories.includes(entryCategory)) {
|
|
170
|
+
skipped++;
|
|
171
|
+
continue;
|
|
172
|
+
}
|
|
173
|
+
// Record as insight in target bridge
|
|
174
|
+
const insight = {
|
|
175
|
+
category: entryCategory || 'project-patterns',
|
|
176
|
+
summary: entry.metadata?.summary || entry.content.split('\n')[0],
|
|
177
|
+
detail: entry.content,
|
|
178
|
+
source: `transfer:${sourceNamespace}`,
|
|
179
|
+
confidence,
|
|
180
|
+
agentDbId: entry.id,
|
|
181
|
+
};
|
|
182
|
+
await targetBridge.recordInsight(insight);
|
|
183
|
+
transferred++;
|
|
184
|
+
}
|
|
185
|
+
return { transferred, skipped };
|
|
186
|
+
}
|
|
187
|
+
/**
|
|
188
|
+
* List all agent scopes and their agents for the current project.
|
|
189
|
+
*
|
|
190
|
+
* Scans the three scope directories (project, local, user) and returns
|
|
191
|
+
* the agent names found in each. Useful for discovery and diagnostics.
|
|
192
|
+
*
|
|
193
|
+
* @param workingDir - Working directory for git root detection (defaults to cwd)
|
|
194
|
+
* @returns Array of scope/agents pairs
|
|
195
|
+
*
|
|
196
|
+
* @example
|
|
197
|
+
* ```typescript
|
|
198
|
+
* const scopes = listAgentScopes('/workspaces/my-project');
|
|
199
|
+
* // [
|
|
200
|
+
* // { scope: 'project', agents: ['coder', 'tester'] },
|
|
201
|
+
* // { scope: 'local', agents: ['researcher'] },
|
|
202
|
+
* // { scope: 'user', agents: ['planner'] },
|
|
203
|
+
* // ]
|
|
204
|
+
* ```
|
|
205
|
+
*/
|
|
206
|
+
export function listAgentScopes(workingDir) {
|
|
207
|
+
const effectiveDir = workingDir || process.cwd();
|
|
208
|
+
const gitRoot = findGitRootSync(effectiveDir);
|
|
209
|
+
const baseDir = gitRoot || effectiveDir;
|
|
210
|
+
const home = process.env.HOME
|
|
211
|
+
|| process.env.USERPROFILE
|
|
212
|
+
|| (process.env.HOMEDRIVE && process.env.HOMEPATH ? process.env.HOMEDRIVE + process.env.HOMEPATH : '')
|
|
213
|
+
|| '';
|
|
214
|
+
const projectDir = path.join(baseDir, '.claude', 'agent-memory');
|
|
215
|
+
const localDir = path.join(baseDir, '.claude', 'agent-memory-local');
|
|
216
|
+
const userDir = path.join(home, '.claude', 'agent-memory');
|
|
217
|
+
return [
|
|
218
|
+
{ scope: 'project', agents: listAgentsInDir(projectDir) },
|
|
219
|
+
{ scope: 'local', agents: listAgentsInDir(localDir) },
|
|
220
|
+
{ scope: 'user', agents: listAgentsInDir(userDir) },
|
|
221
|
+
];
|
|
222
|
+
}
|
|
223
|
+
//# sourceMappingURL=agent-memory-scope.js.map
|