claude-code-swarm 0.3.4 → 0.3.6
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-plugin/marketplace.json +1 -1
- package/.claude-plugin/plugin.json +22 -1
- package/.claude-plugin/run-agent-inbox-mcp.sh +95 -0
- package/.claude-plugin/run-minimem-mcp.sh +98 -0
- package/.claude-plugin/run-opentasks-mcp.sh +65 -0
- package/.gitattributes +3 -0
- package/.opentasks/config.json +9 -0
- package/.opentasks/graph.jsonl +0 -0
- package/CLAUDE.md +196 -36
- package/e2e/helpers/cleanup.mjs +17 -3
- package/e2e/helpers/map-mock-server.mjs +201 -25
- package/e2e/helpers/opentasks-daemon.mjs +149 -0
- package/e2e/helpers/sidecar.mjs +222 -0
- package/e2e/helpers/workspace.mjs +2 -1
- package/e2e/tier5-sidecar-inbox.test.mjs +900 -0
- package/e2e/tier6-inbox-mcp.test.mjs +173 -0
- package/e2e/tier6-live-agent.test.mjs +759 -0
- package/e2e/tier6-live-inbox-flow.test.mjs +938 -0
- package/e2e/tier7-hooks.test.mjs +992 -0
- package/e2e/tier7-minimem.test.mjs +461 -0
- package/e2e/tier7-opentasks.test.mjs +513 -0
- package/e2e/tier7-skilltree.test.mjs +506 -0
- package/e2e/vitest.config.e2e.mjs +1 -1
- package/hooks/hooks.json +15 -8
- package/package.json +17 -1
- package/references/agent-inbox/CLAUDE.md +151 -0
- package/references/agent-inbox/README.md +238 -0
- package/references/agent-inbox/docs/CLAUDE-CODE-SWARM-PROPOSAL.md +137 -0
- package/references/agent-inbox/docs/DESIGN.md +1156 -0
- package/references/agent-inbox/hooks/inbox-hook.mjs +119 -0
- package/references/agent-inbox/hooks/register-hook.mjs +69 -0
- package/references/agent-inbox/package-lock.json +3347 -0
- package/references/agent-inbox/package.json +58 -0
- package/references/agent-inbox/rules/agent-inbox.md +78 -0
- package/references/agent-inbox/src/federation/address.ts +61 -0
- package/references/agent-inbox/src/federation/connection-manager.ts +573 -0
- package/references/agent-inbox/src/federation/delivery-queue.ts +222 -0
- package/references/agent-inbox/src/federation/index.ts +6 -0
- package/references/agent-inbox/src/federation/routing-engine.ts +188 -0
- package/references/agent-inbox/src/federation/trust.ts +71 -0
- package/references/agent-inbox/src/index.ts +404 -0
- package/references/agent-inbox/src/ipc/ipc-server.ts +265 -0
- package/references/agent-inbox/src/jsonrpc/mail-server.ts +382 -0
- package/references/agent-inbox/src/map/map-client.ts +414 -0
- package/references/agent-inbox/src/mcp/mcp-proxy.ts +326 -0
- package/references/agent-inbox/src/mcp/mcp-server.ts +272 -0
- package/references/agent-inbox/src/mesh/delivery-bridge.ts +110 -0
- package/references/agent-inbox/src/mesh/mesh-connector.ts +41 -0
- package/references/agent-inbox/src/mesh/mesh-transport.ts +157 -0
- package/references/agent-inbox/src/mesh/type-mapper.ts +239 -0
- package/references/agent-inbox/src/push/notifier.ts +233 -0
- package/references/agent-inbox/src/registry/warm-registry.ts +255 -0
- package/references/agent-inbox/src/router/message-router.ts +175 -0
- package/references/agent-inbox/src/storage/interface.ts +48 -0
- package/references/agent-inbox/src/storage/memory.ts +145 -0
- package/references/agent-inbox/src/storage/sqlite.ts +671 -0
- package/references/agent-inbox/src/traceability/traceability.ts +183 -0
- package/references/agent-inbox/src/types.ts +329 -0
- package/references/agent-inbox/test/federation/address.test.ts +101 -0
- package/references/agent-inbox/test/federation/connection-manager.test.ts +546 -0
- package/references/agent-inbox/test/federation/delivery-queue.test.ts +159 -0
- package/references/agent-inbox/test/federation/integration.test.ts +857 -0
- package/references/agent-inbox/test/federation/routing-engine.test.ts +117 -0
- package/references/agent-inbox/test/federation/sdk-integration.test.ts +744 -0
- package/references/agent-inbox/test/federation/trust.test.ts +89 -0
- package/references/agent-inbox/test/ipc-jsonrpc.test.ts +113 -0
- package/references/agent-inbox/test/ipc-new-commands.test.ts +200 -0
- package/references/agent-inbox/test/ipc-server.test.ts +197 -0
- package/references/agent-inbox/test/mail-server.test.ts +285 -0
- package/references/agent-inbox/test/map-client.test.ts +408 -0
- package/references/agent-inbox/test/mcp-proxy.test.ts +191 -0
- package/references/agent-inbox/test/mesh/delivery-bridge.test.ts +178 -0
- package/references/agent-inbox/test/mesh/e2e-mesh.test.ts +527 -0
- package/references/agent-inbox/test/mesh/e2e-real-meshpeer.test.ts +629 -0
- package/references/agent-inbox/test/mesh/federation-mesh.test.ts +269 -0
- package/references/agent-inbox/test/mesh/mesh-connector.test.ts +66 -0
- package/references/agent-inbox/test/mesh/mesh-transport.test.ts +191 -0
- package/references/agent-inbox/test/mesh/meshpeer-integration.test.ts +442 -0
- package/references/agent-inbox/test/mesh/mock-mesh.ts +125 -0
- package/references/agent-inbox/test/mesh/mock-meshpeer.ts +266 -0
- package/references/agent-inbox/test/mesh/type-mapper.test.ts +226 -0
- package/references/agent-inbox/test/message-router.test.ts +184 -0
- package/references/agent-inbox/test/push-notifier.test.ts +139 -0
- package/references/agent-inbox/test/registry/warm-registry.test.ts +171 -0
- package/references/agent-inbox/test/sqlite-prefix.test.ts +192 -0
- package/references/agent-inbox/test/sqlite-storage.test.ts +243 -0
- package/references/agent-inbox/test/storage.test.ts +196 -0
- package/references/agent-inbox/test/traceability.test.ts +123 -0
- package/references/agent-inbox/test/wake.test.ts +330 -0
- package/references/agent-inbox/tsconfig.json +20 -0
- package/references/agent-inbox/tsup.config.ts +10 -0
- package/references/agent-inbox/vitest.config.ts +8 -0
- package/references/minimem/.claude/settings.json +7 -0
- package/references/minimem/.sudocode/issues.jsonl +18 -0
- package/references/minimem/.sudocode/specs.jsonl +1 -0
- package/references/minimem/CLAUDE.md +329 -0
- package/references/minimem/README.md +565 -0
- package/references/minimem/claude-plugin/.claude-plugin/plugin.json +10 -0
- package/references/minimem/claude-plugin/.mcp.json +7 -0
- package/references/minimem/claude-plugin/README.md +158 -0
- package/references/minimem/claude-plugin/commands/recall.md +47 -0
- package/references/minimem/claude-plugin/commands/remember.md +41 -0
- package/references/minimem/claude-plugin/hooks/__tests__/hooks.test.ts +272 -0
- package/references/minimem/claude-plugin/hooks/hooks.json +27 -0
- package/references/minimem/claude-plugin/hooks/session-end.sh +86 -0
- package/references/minimem/claude-plugin/hooks/session-start.sh +85 -0
- package/references/minimem/claude-plugin/skills/memory/SKILL.md +108 -0
- package/references/minimem/media/banner.png +0 -0
- package/references/minimem/package-lock.json +5373 -0
- package/references/minimem/package.json +76 -0
- package/references/minimem/scripts/postbuild.js +49 -0
- package/references/minimem/src/__tests__/edge-cases.test.ts +371 -0
- package/references/minimem/src/__tests__/errors.test.ts +265 -0
- package/references/minimem/src/__tests__/helpers.ts +199 -0
- package/references/minimem/src/__tests__/internal.test.ts +407 -0
- package/references/minimem/src/__tests__/knowledge-frontmatter.test.ts +148 -0
- package/references/minimem/src/__tests__/knowledge.test.ts +148 -0
- package/references/minimem/src/__tests__/minimem.integration.test.ts +1127 -0
- package/references/minimem/src/__tests__/session.test.ts +190 -0
- package/references/minimem/src/cli/__tests__/commands.test.ts +760 -0
- package/references/minimem/src/cli/__tests__/contained-layout.test.ts +286 -0
- package/references/minimem/src/cli/commands/__tests__/conflicts.test.ts +141 -0
- package/references/minimem/src/cli/commands/append.ts +76 -0
- package/references/minimem/src/cli/commands/config.ts +262 -0
- package/references/minimem/src/cli/commands/conflicts.ts +415 -0
- package/references/minimem/src/cli/commands/daemon.ts +169 -0
- package/references/minimem/src/cli/commands/index.ts +12 -0
- package/references/minimem/src/cli/commands/init.ts +166 -0
- package/references/minimem/src/cli/commands/mcp.ts +221 -0
- package/references/minimem/src/cli/commands/push-pull.ts +213 -0
- package/references/minimem/src/cli/commands/search.ts +223 -0
- package/references/minimem/src/cli/commands/status.ts +84 -0
- package/references/minimem/src/cli/commands/store.ts +189 -0
- package/references/minimem/src/cli/commands/sync-init.ts +290 -0
- package/references/minimem/src/cli/commands/sync.ts +70 -0
- package/references/minimem/src/cli/commands/upsert.ts +197 -0
- package/references/minimem/src/cli/config.ts +611 -0
- package/references/minimem/src/cli/index.ts +299 -0
- package/references/minimem/src/cli/shared.ts +189 -0
- package/references/minimem/src/cli/sync/__tests__/central.test.ts +152 -0
- package/references/minimem/src/cli/sync/__tests__/conflicts.test.ts +209 -0
- package/references/minimem/src/cli/sync/__tests__/daemon.test.ts +118 -0
- package/references/minimem/src/cli/sync/__tests__/detection.test.ts +207 -0
- package/references/minimem/src/cli/sync/__tests__/integration.test.ts +476 -0
- package/references/minimem/src/cli/sync/__tests__/registry.test.ts +363 -0
- package/references/minimem/src/cli/sync/__tests__/state.test.ts +255 -0
- package/references/minimem/src/cli/sync/__tests__/validation.test.ts +193 -0
- package/references/minimem/src/cli/sync/__tests__/watcher.test.ts +178 -0
- package/references/minimem/src/cli/sync/central.ts +292 -0
- package/references/minimem/src/cli/sync/conflicts.ts +205 -0
- package/references/minimem/src/cli/sync/daemon.ts +407 -0
- package/references/minimem/src/cli/sync/detection.ts +138 -0
- package/references/minimem/src/cli/sync/index.ts +107 -0
- package/references/minimem/src/cli/sync/operations.ts +373 -0
- package/references/minimem/src/cli/sync/registry.ts +279 -0
- package/references/minimem/src/cli/sync/state.ts +358 -0
- package/references/minimem/src/cli/sync/validation.ts +206 -0
- package/references/minimem/src/cli/sync/watcher.ts +237 -0
- package/references/minimem/src/cli/version.ts +34 -0
- package/references/minimem/src/core/index.ts +9 -0
- package/references/minimem/src/core/indexer.ts +628 -0
- package/references/minimem/src/core/searcher.ts +221 -0
- package/references/minimem/src/db/schema.ts +183 -0
- package/references/minimem/src/db/sqlite-vec.ts +24 -0
- package/references/minimem/src/embeddings/__tests__/embeddings.test.ts +431 -0
- package/references/minimem/src/embeddings/batch-gemini.ts +392 -0
- package/references/minimem/src/embeddings/batch-openai.ts +409 -0
- package/references/minimem/src/embeddings/embeddings.ts +434 -0
- package/references/minimem/src/index.ts +132 -0
- package/references/minimem/src/internal.ts +299 -0
- package/references/minimem/src/minimem.ts +1291 -0
- package/references/minimem/src/search/__tests__/hybrid.test.ts +247 -0
- package/references/minimem/src/search/graph.ts +234 -0
- package/references/minimem/src/search/hybrid.ts +151 -0
- package/references/minimem/src/search/search.ts +256 -0
- package/references/minimem/src/server/__tests__/mcp.test.ts +347 -0
- package/references/minimem/src/server/__tests__/tools.test.ts +364 -0
- package/references/minimem/src/server/mcp.ts +326 -0
- package/references/minimem/src/server/tools.ts +720 -0
- package/references/minimem/src/session.ts +460 -0
- package/references/minimem/src/store/__tests__/manifest.test.ts +177 -0
- package/references/minimem/src/store/__tests__/materialize.test.ts +52 -0
- package/references/minimem/src/store/__tests__/store-graph.test.ts +228 -0
- package/references/minimem/src/store/index.ts +27 -0
- package/references/minimem/src/store/manifest.ts +203 -0
- package/references/minimem/src/store/materialize.ts +185 -0
- package/references/minimem/src/store/store-graph.ts +252 -0
- package/references/minimem/tsconfig.json +19 -0
- package/references/minimem/tsup.config.ts +26 -0
- package/references/minimem/vitest.config.ts +29 -0
- package/references/multi-agent-protocol/.sudocode/issues.jsonl +120 -0
- package/references/multi-agent-protocol/.sudocode/specs.jsonl +15 -0
- package/references/multi-agent-protocol/LICENSE +21 -0
- package/references/multi-agent-protocol/README.md +113 -0
- package/references/multi-agent-protocol/docs/00-design-specification.md +496 -0
- package/references/multi-agent-protocol/docs/01-open-questions.md +1050 -0
- package/references/multi-agent-protocol/docs/02-wire-protocol.md +296 -0
- package/references/multi-agent-protocol/docs/03-streaming-semantics.md +252 -0
- package/references/multi-agent-protocol/docs/04-error-handling.md +231 -0
- package/references/multi-agent-protocol/docs/05-connection-model.md +244 -0
- package/references/multi-agent-protocol/docs/06-visibility-permissions.md +243 -0
- package/references/multi-agent-protocol/docs/07-federation.md +335 -0
- package/references/multi-agent-protocol/docs/08-macro-agent-migration.md +253 -0
- package/references/multi-agent-protocol/docs/09-authentication.md +748 -0
- package/references/multi-agent-protocol/docs/10-environment-awareness.md +242 -0
- package/references/multi-agent-protocol/docs/10-mail-protocol.md +553 -0
- package/references/multi-agent-protocol/docs/11-anp-inspired-improvements.md +1079 -0
- package/references/multi-agent-protocol/docs/11-trajectory-protocol.md +292 -0
- package/references/multi-agent-protocol/docs/12-anp-implementation-plan.md +641 -0
- package/references/multi-agent-protocol/docs/agent-iam-integration.md +877 -0
- package/references/multi-agent-protocol/docs/agentic-mesh-integration-draft.md +459 -0
- package/references/multi-agent-protocol/docs/git-transport-draft.md +251 -0
- package/references/multi-agent-protocol/docs-site/Gemfile +22 -0
- package/references/multi-agent-protocol/docs-site/README.md +82 -0
- package/references/multi-agent-protocol/docs-site/_config.yml +91 -0
- package/references/multi-agent-protocol/docs-site/_includes/head_custom.html +20 -0
- package/references/multi-agent-protocol/docs-site/_sass/color_schemes/map.scss +42 -0
- package/references/multi-agent-protocol/docs-site/_sass/custom/custom.scss +34 -0
- package/references/multi-agent-protocol/docs-site/examples/full-integration.md +510 -0
- package/references/multi-agent-protocol/docs-site/examples/index.md +138 -0
- package/references/multi-agent-protocol/docs-site/examples/simple-chat.md +282 -0
- package/references/multi-agent-protocol/docs-site/examples/task-queue.md +399 -0
- package/references/multi-agent-protocol/docs-site/getting-started/index.md +98 -0
- package/references/multi-agent-protocol/docs-site/getting-started/installation.md +219 -0
- package/references/multi-agent-protocol/docs-site/getting-started/overview.md +172 -0
- package/references/multi-agent-protocol/docs-site/getting-started/quickstart.md +237 -0
- package/references/multi-agent-protocol/docs-site/index.md +136 -0
- package/references/multi-agent-protocol/docs-site/protocol/authentication.md +391 -0
- package/references/multi-agent-protocol/docs-site/protocol/connection-model.md +376 -0
- package/references/multi-agent-protocol/docs-site/protocol/design.md +284 -0
- package/references/multi-agent-protocol/docs-site/protocol/error-handling.md +312 -0
- package/references/multi-agent-protocol/docs-site/protocol/federation.md +449 -0
- package/references/multi-agent-protocol/docs-site/protocol/index.md +129 -0
- package/references/multi-agent-protocol/docs-site/protocol/permissions.md +398 -0
- package/references/multi-agent-protocol/docs-site/protocol/streaming.md +353 -0
- package/references/multi-agent-protocol/docs-site/protocol/wire-protocol.md +369 -0
- package/references/multi-agent-protocol/docs-site/sdk/api/agent.md +357 -0
- package/references/multi-agent-protocol/docs-site/sdk/api/client.md +380 -0
- package/references/multi-agent-protocol/docs-site/sdk/api/index.md +62 -0
- package/references/multi-agent-protocol/docs-site/sdk/api/server.md +453 -0
- package/references/multi-agent-protocol/docs-site/sdk/api/types.md +468 -0
- package/references/multi-agent-protocol/docs-site/sdk/guides/agent.md +375 -0
- package/references/multi-agent-protocol/docs-site/sdk/guides/authentication.md +405 -0
- package/references/multi-agent-protocol/docs-site/sdk/guides/client.md +352 -0
- package/references/multi-agent-protocol/docs-site/sdk/guides/index.md +89 -0
- package/references/multi-agent-protocol/docs-site/sdk/guides/server.md +360 -0
- package/references/multi-agent-protocol/docs-site/sdk/guides/testing.md +446 -0
- package/references/multi-agent-protocol/docs-site/sdk/guides/transports.md +363 -0
- package/references/multi-agent-protocol/docs-site/sdk/index.md +206 -0
- package/references/multi-agent-protocol/package-lock.json +4230 -0
- package/references/multi-agent-protocol/package.json +56 -0
- package/references/multi-agent-protocol/schema/meta.json +584 -0
- package/references/multi-agent-protocol/schema/schema.json +3067 -0
- package/references/openhive/.claude/settings.json +6 -0
- package/references/openhive/.dockerignore +54 -0
- package/references/openhive/.github/workflows/docker.yml +52 -0
- package/references/openhive/.sudocode/issues.jsonl +24 -0
- package/references/openhive/.sudocode/specs.jsonl +4 -0
- package/references/openhive/CLAUDE.md +88 -0
- package/references/openhive/Dockerfile +105 -0
- package/references/openhive/README.md +745 -0
- package/references/openhive/bin/openhive.js +6 -0
- package/references/openhive/cloudbuild.yaml +80 -0
- package/references/openhive/deploy/cloud-run.sh +106 -0
- package/references/openhive/deploy/openhive.env.example +80 -0
- package/references/openhive/deploy/openhive.service +91 -0
- package/references/openhive/docker-compose.yml +67 -0
- package/references/openhive/docker-entrypoint.sh +117 -0
- package/references/openhive/docs/API_MIGRATION.md +176 -0
- package/references/openhive/docs/DEPLOYMENT.md +847 -0
- package/references/openhive/docs/DESIGN_v1.md +489 -0
- package/references/openhive/docs/DESIGN_v2.md +564 -0
- package/references/openhive/docs/HEADSCALE_HOSTING_SPEC.md +513 -0
- package/references/openhive/docs/HIVE_SYNC_DESIGN.md +2362 -0
- package/references/openhive/docs/HIVE_SYNC_IMPLEMENTATION_PLAN.md +1169 -0
- package/references/openhive/docs/HOSTING.md +601 -0
- package/references/openhive/docs/IMPLEMENTATION_PLAN.md +428 -0
- package/references/openhive/docs/LOCAL_SETUP.md +506 -0
- package/references/openhive/docs/MACRO_AGENT_ATLAS_EXTENSION.md +351 -0
- package/references/openhive/docs/MEMORY_BANK_SYNC_SPEC.md +909 -0
- package/references/openhive/docs/PLAN_v1.md +471 -0
- package/references/openhive/docs/PLAN_v2.md +623 -0
- package/references/openhive/docs/WEBSOCKET.md +267 -0
- package/references/openhive/docs/openswarm-bootstrap-token-spec.md +240 -0
- package/references/openhive/ecosystem.config.cjs +76 -0
- package/references/openhive/fly.toml +63 -0
- package/references/openhive/package-lock.json +17640 -0
- package/references/openhive/package.json +128 -0
- package/references/openhive/packages/openhive-types/package-lock.json +1473 -0
- package/references/openhive/packages/openhive-types/package.json +42 -0
- package/references/openhive/packages/openhive-types/src/index.ts +36 -0
- package/references/openhive/packages/openhive-types/src/map-coordination.ts +92 -0
- package/references/openhive/packages/openhive-types/src/map-session-sync.ts +50 -0
- package/references/openhive/packages/openhive-types/src/map-sync.ts +68 -0
- package/references/openhive/packages/openhive-types/tsconfig.json +15 -0
- package/references/openhive/packages/openhive-types/tsconfig.tsbuildinfo +1 -0
- package/references/openhive/packages/openhive-types/tsup.config.ts +12 -0
- package/references/openhive/railway.json +13 -0
- package/references/openhive/railway.toml +24 -0
- package/references/openhive/render.yaml +51 -0
- package/references/openhive/src/__tests__/auth.test.ts +148 -0
- package/references/openhive/src/__tests__/bridge/credentials.test.ts +65 -0
- package/references/openhive/src/__tests__/bridge/dal.test.ts +279 -0
- package/references/openhive/src/__tests__/bridge/inbound.test.ts +349 -0
- package/references/openhive/src/__tests__/bridge/manager.test.ts +419 -0
- package/references/openhive/src/__tests__/bridge/mentions.test.ts +83 -0
- package/references/openhive/src/__tests__/bridge/outbound.test.ts +209 -0
- package/references/openhive/src/__tests__/bridge/slack-adapter.test.ts +276 -0
- package/references/openhive/src/__tests__/cli.test.ts +342 -0
- package/references/openhive/src/__tests__/config.test.ts +205 -0
- package/references/openhive/src/__tests__/coordination/coordination.test.ts +1072 -0
- package/references/openhive/src/__tests__/coordination/cross-instance.test.ts +540 -0
- package/references/openhive/src/__tests__/coordination/e2e.test.ts +780 -0
- package/references/openhive/src/__tests__/data-dir.test.ts +332 -0
- package/references/openhive/src/__tests__/db.test.ts +258 -0
- package/references/openhive/src/__tests__/discovery.test.ts +288 -0
- package/references/openhive/src/__tests__/events/dal.test.ts +371 -0
- package/references/openhive/src/__tests__/events/dispatch.test.ts +202 -0
- package/references/openhive/src/__tests__/events/e2e.test.ts +528 -0
- package/references/openhive/src/__tests__/events/normalizers.test.ts +263 -0
- package/references/openhive/src/__tests__/events/router.test.ts +314 -0
- package/references/openhive/src/__tests__/events/routes.test.ts +407 -0
- package/references/openhive/src/__tests__/follows.test.ts +328 -0
- package/references/openhive/src/__tests__/helpers/test-dirs.ts +44 -0
- package/references/openhive/src/__tests__/ingest-keys.test.ts +925 -0
- package/references/openhive/src/__tests__/map/sync-client-content.test.ts +288 -0
- package/references/openhive/src/__tests__/map/sync-client.test.ts +500 -0
- package/references/openhive/src/__tests__/map/sync-listener.test.ts +504 -0
- package/references/openhive/src/__tests__/middleware/hostname-guard.test.ts +73 -0
- package/references/openhive/src/__tests__/migrations.test.ts +260 -0
- package/references/openhive/src/__tests__/opentasks/client.test.ts +497 -0
- package/references/openhive/src/__tests__/opentasks/discovery.test.ts +283 -0
- package/references/openhive/src/__tests__/opentasks/e2e.test.ts +767 -0
- package/references/openhive/src/__tests__/routes/agents.test.ts +417 -0
- package/references/openhive/src/__tests__/routes/opentasks-content.test.ts +493 -0
- package/references/openhive/src/__tests__/routes/resource-content.test.ts +1741 -0
- package/references/openhive/src/__tests__/sessions/adapters.test.ts +524 -0
- package/references/openhive/src/__tests__/sessions/routes.test.ts +1053 -0
- package/references/openhive/src/__tests__/sessions/storage.test.ts +545 -0
- package/references/openhive/src/__tests__/sessions/trajectory-checkpoints.test.ts +349 -0
- package/references/openhive/src/__tests__/sessions/trajectory-routes.test.ts +290 -0
- package/references/openhive/src/__tests__/swarm/config.test.ts +125 -0
- package/references/openhive/src/__tests__/swarm/credentials.test.ts +254 -0
- package/references/openhive/src/__tests__/swarm/dal.test.ts +290 -0
- package/references/openhive/src/__tests__/swarm/e2e.test.ts +827 -0
- package/references/openhive/src/__tests__/swarm/fixtures/exit-immediately.js +3 -0
- package/references/openhive/src/__tests__/swarm/fixtures/map-server.js +147 -0
- package/references/openhive/src/__tests__/swarm/fixtures/sleep-server.js +52 -0
- package/references/openhive/src/__tests__/swarm/local-provider.test.ts +279 -0
- package/references/openhive/src/__tests__/swarm/manager.test.ts +305 -0
- package/references/openhive/src/__tests__/swarm/routes.test.ts +396 -0
- package/references/openhive/src/__tests__/swarm/workspace.test.ts +257 -0
- package/references/openhive/src/__tests__/swarmhub/client.test.ts +324 -0
- package/references/openhive/src/__tests__/swarmhub/config.test.ts +213 -0
- package/references/openhive/src/__tests__/swarmhub/connector.test.ts +581 -0
- package/references/openhive/src/__tests__/swarmhub/routes.test.ts +639 -0
- package/references/openhive/src/__tests__/swarmhub/slack-client.test.ts +164 -0
- package/references/openhive/src/__tests__/swarmhub/slack-connector.test.ts +164 -0
- package/references/openhive/src/__tests__/swarmhub/slack-routes.test.ts +373 -0
- package/references/openhive/src/__tests__/swarmhub/webhook-handler.test.ts +295 -0
- package/references/openhive/src/__tests__/sync/resource-sync.test.ts +1418 -0
- package/references/openhive/src/__tests__/sync/sync.test.ts +800 -0
- package/references/openhive/src/api/index.ts +65 -0
- package/references/openhive/src/api/middleware/auth.ts +227 -0
- package/references/openhive/src/api/middleware/hostname-guard.ts +38 -0
- package/references/openhive/src/api/routes/admin.ts +366 -0
- package/references/openhive/src/api/routes/agents.ts +223 -0
- package/references/openhive/src/api/routes/auth.ts +164 -0
- package/references/openhive/src/api/routes/bridges.ts +384 -0
- package/references/openhive/src/api/routes/comments.ts +294 -0
- package/references/openhive/src/api/routes/coordination.ts +312 -0
- package/references/openhive/src/api/routes/events.ts +158 -0
- package/references/openhive/src/api/routes/federation.ts +367 -0
- package/references/openhive/src/api/routes/feed.ts +212 -0
- package/references/openhive/src/api/routes/hives.ts +264 -0
- package/references/openhive/src/api/routes/map.ts +674 -0
- package/references/openhive/src/api/routes/memory-banks.ts +971 -0
- package/references/openhive/src/api/routes/posts.ts +342 -0
- package/references/openhive/src/api/routes/resource-content.ts +727 -0
- package/references/openhive/src/api/routes/resources.ts +1013 -0
- package/references/openhive/src/api/routes/search.ts +45 -0
- package/references/openhive/src/api/routes/sessions.ts +1187 -0
- package/references/openhive/src/api/routes/swarm-hosting.ts +313 -0
- package/references/openhive/src/api/routes/sync-protocol.ts +168 -0
- package/references/openhive/src/api/routes/sync.ts +279 -0
- package/references/openhive/src/api/routes/uploads.ts +174 -0
- package/references/openhive/src/api/routes/webhooks.ts +603 -0
- package/references/openhive/src/api/schemas/agents.ts +26 -0
- package/references/openhive/src/api/schemas/comments.ts +22 -0
- package/references/openhive/src/api/schemas/hives.ts +33 -0
- package/references/openhive/src/api/schemas/posts.ts +37 -0
- package/references/openhive/src/api/schemas/sync.ts +56 -0
- package/references/openhive/src/auth/index.ts +2 -0
- package/references/openhive/src/auth/jwks.ts +58 -0
- package/references/openhive/src/bridge/adapters/slack.ts +306 -0
- package/references/openhive/src/bridge/credentials.ts +72 -0
- package/references/openhive/src/bridge/inbound.ts +288 -0
- package/references/openhive/src/bridge/index.ts +42 -0
- package/references/openhive/src/bridge/manager.ts +425 -0
- package/references/openhive/src/bridge/mentions.ts +42 -0
- package/references/openhive/src/bridge/outbound.ts +103 -0
- package/references/openhive/src/bridge/schema.ts +82 -0
- package/references/openhive/src/bridge/types.ts +238 -0
- package/references/openhive/src/cli/network.ts +480 -0
- package/references/openhive/src/cli.ts +620 -0
- package/references/openhive/src/config.ts +611 -0
- package/references/openhive/src/coordination/index.ts +43 -0
- package/references/openhive/src/coordination/listener.ts +92 -0
- package/references/openhive/src/coordination/schema.ts +79 -0
- package/references/openhive/src/coordination/service.ts +233 -0
- package/references/openhive/src/coordination/types.ts +177 -0
- package/references/openhive/src/data-dir.ts +105 -0
- package/references/openhive/src/db/adapters/index.ts +21 -0
- package/references/openhive/src/db/adapters/postgres.ts +310 -0
- package/references/openhive/src/db/adapters/sqlite.ts +56 -0
- package/references/openhive/src/db/adapters/types.ts +65 -0
- package/references/openhive/src/db/dal/agents.ts +430 -0
- package/references/openhive/src/db/dal/bridge.ts +336 -0
- package/references/openhive/src/db/dal/comments.ts +213 -0
- package/references/openhive/src/db/dal/coordination.ts +361 -0
- package/references/openhive/src/db/dal/events.ts +381 -0
- package/references/openhive/src/db/dal/follows.ts +96 -0
- package/references/openhive/src/db/dal/hives.ts +198 -0
- package/references/openhive/src/db/dal/ingest-keys.ts +176 -0
- package/references/openhive/src/db/dal/instances.ts +196 -0
- package/references/openhive/src/db/dal/invites.ts +123 -0
- package/references/openhive/src/db/dal/map.ts +750 -0
- package/references/openhive/src/db/dal/posts.ts +274 -0
- package/references/openhive/src/db/dal/remote-agents.ts +56 -0
- package/references/openhive/src/db/dal/search.ts +238 -0
- package/references/openhive/src/db/dal/sync-events.ts +160 -0
- package/references/openhive/src/db/dal/sync-groups.ts +100 -0
- package/references/openhive/src/db/dal/sync-peer-configs.ts +216 -0
- package/references/openhive/src/db/dal/sync-peers.ts +145 -0
- package/references/openhive/src/db/dal/syncable-resources.ts +888 -0
- package/references/openhive/src/db/dal/trajectory-checkpoints.ts +291 -0
- package/references/openhive/src/db/dal/uploads.ts +124 -0
- package/references/openhive/src/db/dal/votes.ts +124 -0
- package/references/openhive/src/db/index.ts +293 -0
- package/references/openhive/src/db/providers/index.ts +75 -0
- package/references/openhive/src/db/providers/postgres.ts +529 -0
- package/references/openhive/src/db/providers/sqlite.ts +1383 -0
- package/references/openhive/src/db/providers/turso.ts +1360 -0
- package/references/openhive/src/db/providers/types.ts +516 -0
- package/references/openhive/src/db/schema.ts +641 -0
- package/references/openhive/src/discovery/index.ts +403 -0
- package/references/openhive/src/events/dispatch.ts +106 -0
- package/references/openhive/src/events/index.ts +17 -0
- package/references/openhive/src/events/normalizers/github.ts +133 -0
- package/references/openhive/src/events/normalizers/index.ts +62 -0
- package/references/openhive/src/events/normalizers/slack.ts +50 -0
- package/references/openhive/src/events/router.ts +156 -0
- package/references/openhive/src/events/schema.ts +66 -0
- package/references/openhive/src/events/types.ts +130 -0
- package/references/openhive/src/federation/index.ts +1 -0
- package/references/openhive/src/federation/service.ts +776 -0
- package/references/openhive/src/headscale/client.ts +256 -0
- package/references/openhive/src/headscale/config.ts +212 -0
- package/references/openhive/src/headscale/index.ts +23 -0
- package/references/openhive/src/headscale/manager.ts +249 -0
- package/references/openhive/src/headscale/sync.ts +272 -0
- package/references/openhive/src/headscale/types.ts +231 -0
- package/references/openhive/src/index.ts +225 -0
- package/references/openhive/src/map/client-entry.ts +26 -0
- package/references/openhive/src/map/index.ts +76 -0
- package/references/openhive/src/map/schema.ts +119 -0
- package/references/openhive/src/map/service.ts +323 -0
- package/references/openhive/src/map/sync-client.ts +696 -0
- package/references/openhive/src/map/sync-listener.ts +409 -0
- package/references/openhive/src/map/types.ts +290 -0
- package/references/openhive/src/network/factory.ts +118 -0
- package/references/openhive/src/network/headscale-provider.ts +437 -0
- package/references/openhive/src/network/index.ts +43 -0
- package/references/openhive/src/network/tailscale-client.ts +289 -0
- package/references/openhive/src/network/tailscale-provider.ts +287 -0
- package/references/openhive/src/network/types.ts +178 -0
- package/references/openhive/src/opentasks-client/client.ts +374 -0
- package/references/openhive/src/opentasks-client/index.ts +7 -0
- package/references/openhive/src/realtime/index.ts +282 -0
- package/references/openhive/src/server.ts +1069 -0
- package/references/openhive/src/services/email.ts +177 -0
- package/references/openhive/src/services/sitemap.ts +135 -0
- package/references/openhive/src/sessions/adapters/claude.ts +466 -0
- package/references/openhive/src/sessions/adapters/codex.ts +265 -0
- package/references/openhive/src/sessions/adapters/index.ts +263 -0
- package/references/openhive/src/sessions/adapters/raw.ts +144 -0
- package/references/openhive/src/sessions/adapters/types.ts +83 -0
- package/references/openhive/src/sessions/index.ts +50 -0
- package/references/openhive/src/sessions/storage/adapters/gcs.ts +277 -0
- package/references/openhive/src/sessions/storage/adapters/local.ts +240 -0
- package/references/openhive/src/sessions/storage/adapters/s3.ts +321 -0
- package/references/openhive/src/sessions/storage/index.ts +231 -0
- package/references/openhive/src/sessions/storage/types.ts +189 -0
- package/references/openhive/src/sessions/types.ts +415 -0
- package/references/openhive/src/shared/types/index.ts +45 -0
- package/references/openhive/src/shared/types/map-coordination.ts +92 -0
- package/references/openhive/src/shared/types/map-session-sync.ts +170 -0
- package/references/openhive/src/shared/types/map-sync.ts +68 -0
- package/references/openhive/src/skill.ts +203 -0
- package/references/openhive/src/storage/adapters/local.ts +169 -0
- package/references/openhive/src/storage/adapters/s3.ts +195 -0
- package/references/openhive/src/storage/index.ts +64 -0
- package/references/openhive/src/storage/types.ts +69 -0
- package/references/openhive/src/swarm/credentials.ts +98 -0
- package/references/openhive/src/swarm/dal.ts +206 -0
- package/references/openhive/src/swarm/index.ts +28 -0
- package/references/openhive/src/swarm/manager.ts +917 -0
- package/references/openhive/src/swarm/providers/local.ts +338 -0
- package/references/openhive/src/swarm/providers/sandboxed-local.ts +478 -0
- package/references/openhive/src/swarm/providers/workspace.ts +52 -0
- package/references/openhive/src/swarm/schema.ts +43 -0
- package/references/openhive/src/swarm/types.ts +333 -0
- package/references/openhive/src/swarmhub/client.ts +279 -0
- package/references/openhive/src/swarmhub/connector.ts +463 -0
- package/references/openhive/src/swarmhub/index.ts +43 -0
- package/references/openhive/src/swarmhub/routes.ts +296 -0
- package/references/openhive/src/swarmhub/types.ts +213 -0
- package/references/openhive/src/swarmhub/webhook-handler.ts +126 -0
- package/references/openhive/src/sync/compaction.ts +193 -0
- package/references/openhive/src/sync/coordination-hooks.ts +154 -0
- package/references/openhive/src/sync/crypto.ts +79 -0
- package/references/openhive/src/sync/gossip.ts +136 -0
- package/references/openhive/src/sync/hooks.ts +202 -0
- package/references/openhive/src/sync/materializer-repo.ts +256 -0
- package/references/openhive/src/sync/materializer.ts +682 -0
- package/references/openhive/src/sync/middleware.ts +140 -0
- package/references/openhive/src/sync/peer-resolver.ts +157 -0
- package/references/openhive/src/sync/resource-hooks.ts +161 -0
- package/references/openhive/src/sync/schema.ts +158 -0
- package/references/openhive/src/sync/service.ts +990 -0
- package/references/openhive/src/sync/types.ts +369 -0
- package/references/openhive/src/terminal/index.ts +4 -0
- package/references/openhive/src/terminal/pty-manager.ts +337 -0
- package/references/openhive/src/terminal/resolve-tui.ts +44 -0
- package/references/openhive/src/terminal/terminal-ws.ts +251 -0
- package/references/openhive/src/types.ts +442 -0
- package/references/openhive/src/utils/git-remote.ts +329 -0
- package/references/openhive/src/web/App.tsx +77 -0
- package/references/openhive/src/web/__tests__/components/dashboard/RecentActivity.test.tsx +77 -0
- package/references/openhive/src/web/__tests__/components/dashboard/StatsOverview.test.tsx +62 -0
- package/references/openhive/src/web/__tests__/components/dashboard/SwarmStatusSummary.test.tsx +122 -0
- package/references/openhive/src/web/__tests__/components/dashboard/SyncResourcesStatus.test.tsx +104 -0
- package/references/openhive/src/web/__tests__/components/layout/Sidebar.test.tsx +110 -0
- package/references/openhive/src/web/__tests__/components/swarm/StatusBadges.test.tsx +65 -0
- package/references/openhive/src/web/__tests__/components/terminal/query-responses.test.ts +143 -0
- package/references/openhive/src/web/__tests__/components/terminal/terminal-mouse.test.ts +509 -0
- package/references/openhive/src/web/__tests__/hooks/useEventsApi.test.ts +378 -0
- package/references/openhive/src/web/__tests__/pages/Dashboard.test.tsx +57 -0
- package/references/openhive/src/web/__tests__/pages/Events.test.tsx +886 -0
- package/references/openhive/src/web/__tests__/pages/Explore.test.tsx +63 -0
- package/references/openhive/src/web/__tests__/routing.test.tsx +79 -0
- package/references/openhive/src/web/__tests__/setup.ts +37 -0
- package/references/openhive/src/web/__tests__/stores/dashboard.test.ts +49 -0
- package/references/openhive/src/web/components/common/AgentBadge.tsx +58 -0
- package/references/openhive/src/web/components/common/Avatar.tsx +78 -0
- package/references/openhive/src/web/components/common/ErrorBoundary.tsx +76 -0
- package/references/openhive/src/web/components/common/Highlight.tsx +79 -0
- package/references/openhive/src/web/components/common/ImageUpload.tsx +209 -0
- package/references/openhive/src/web/components/common/LoadingSpinner.tsx +37 -0
- package/references/openhive/src/web/components/common/Logo.tsx +21 -0
- package/references/openhive/src/web/components/common/Markdown.tsx +53 -0
- package/references/openhive/src/web/components/common/ProtectedRoute.tsx +18 -0
- package/references/openhive/src/web/components/common/ThemeToggle.tsx +38 -0
- package/references/openhive/src/web/components/common/TimeAgo.tsx +17 -0
- package/references/openhive/src/web/components/common/Toast.tsx +70 -0
- package/references/openhive/src/web/components/common/VoteButtons.tsx +100 -0
- package/references/openhive/src/web/components/dashboard/RecentActivity.tsx +100 -0
- package/references/openhive/src/web/components/dashboard/StatsOverview.tsx +40 -0
- package/references/openhive/src/web/components/dashboard/SwarmStatusSummary.tsx +89 -0
- package/references/openhive/src/web/components/dashboard/SyncResourcesStatus.tsx +81 -0
- package/references/openhive/src/web/components/feed/FeedControls.tsx +38 -0
- package/references/openhive/src/web/components/feed/NewPostsIndicator.tsx +75 -0
- package/references/openhive/src/web/components/feed/PostCard.tsx +129 -0
- package/references/openhive/src/web/components/feed/PostList.tsx +83 -0
- package/references/openhive/src/web/components/layout/Footer.tsx +5 -0
- package/references/openhive/src/web/components/layout/Layout.tsx +29 -0
- package/references/openhive/src/web/components/layout/Sidebar.tsx +348 -0
- package/references/openhive/src/web/components/post/CommentForm.tsx +59 -0
- package/references/openhive/src/web/components/post/CommentTree.tsx +145 -0
- package/references/openhive/src/web/components/resources/MemoryBrowser.tsx +208 -0
- package/references/openhive/src/web/components/resources/OpenTasksSummary.tsx +138 -0
- package/references/openhive/src/web/components/resources/SkillBrowser.tsx +284 -0
- package/references/openhive/src/web/components/swarm/StatusBadges.tsx +56 -0
- package/references/openhive/src/web/components/terminal/TerminalPanel.tsx +485 -0
- package/references/openhive/src/web/components/terminal/index.ts +2 -0
- package/references/openhive/src/web/components/terminal/query-responses.ts +70 -0
- package/references/openhive/src/web/components/terminal/terminal-mouse.ts +222 -0
- package/references/openhive/src/web/hooks/useApi.ts +740 -0
- package/references/openhive/src/web/hooks/useDocumentTitle.ts +49 -0
- package/references/openhive/src/web/hooks/useInfiniteScroll.ts +58 -0
- package/references/openhive/src/web/hooks/useRealtimeUpdates.ts +154 -0
- package/references/openhive/src/web/hooks/useWebSocket.ts +225 -0
- package/references/openhive/src/web/index.html +73 -0
- package/references/openhive/src/web/lib/api.ts +518 -0
- package/references/openhive/src/web/main.tsx +32 -0
- package/references/openhive/src/web/pages/About.tsx +131 -0
- package/references/openhive/src/web/pages/Agent.tsx +130 -0
- package/references/openhive/src/web/pages/Agents.tsx +69 -0
- package/references/openhive/src/web/pages/AuthCallback.tsx +75 -0
- package/references/openhive/src/web/pages/Dashboard.tsx +41 -0
- package/references/openhive/src/web/pages/Events.tsx +1025 -0
- package/references/openhive/src/web/pages/Explore.tsx +43 -0
- package/references/openhive/src/web/pages/Hive.tsx +134 -0
- package/references/openhive/src/web/pages/Hives.tsx +64 -0
- package/references/openhive/src/web/pages/Home.tsx +43 -0
- package/references/openhive/src/web/pages/Login.tsx +122 -0
- package/references/openhive/src/web/pages/Post.tsx +216 -0
- package/references/openhive/src/web/pages/ResourceDetail.tsx +426 -0
- package/references/openhive/src/web/pages/Resources.tsx +276 -0
- package/references/openhive/src/web/pages/Search.tsx +234 -0
- package/references/openhive/src/web/pages/SessionDetail.tsx +703 -0
- package/references/openhive/src/web/pages/Sessions.tsx +129 -0
- package/references/openhive/src/web/pages/Settings.tsx +826 -0
- package/references/openhive/src/web/pages/SwarmCraft.tsx +16 -0
- package/references/openhive/src/web/pages/Swarms.tsx +981 -0
- package/references/openhive/src/web/pages/Terminal.tsx +69 -0
- package/references/openhive/src/web/postcss.config.js +5 -0
- package/references/openhive/src/web/public/favicon.svg +11 -0
- package/references/openhive/src/web/public/manifest.json +21 -0
- package/references/openhive/src/web/stores/auth.ts +207 -0
- package/references/openhive/src/web/stores/dashboard.ts +23 -0
- package/references/openhive/src/web/stores/realtime.ts +90 -0
- package/references/openhive/src/web/stores/theme.ts +70 -0
- package/references/openhive/src/web/stores/toast.ts +63 -0
- package/references/openhive/src/web/styles/globals.css +503 -0
- package/references/openhive/src/web/sw.ts +228 -0
- package/references/openhive/src/web/utils/serviceWorker.ts +86 -0
- package/references/openhive/src/web/vite.config.ts +81 -0
- package/references/openhive/tsconfig.json +32 -0
- package/references/openhive/tsup.config.ts +17 -0
- package/references/openhive/vitest.config.ts +30 -0
- package/references/openhive/vitest.web.config.ts +20 -0
- package/references/opentasks/.claude/settings.json +6 -0
- package/references/opentasks/.claude-plugin/plugin.json +20 -0
- package/references/opentasks/.lintstagedrc.json +4 -0
- package/references/opentasks/.prettierignore +4 -0
- package/references/opentasks/.prettierrc.json +11 -0
- package/references/opentasks/.sudocode/issues.jsonl +89 -0
- package/references/opentasks/.sudocode/specs.jsonl +24 -0
- package/references/opentasks/README.md +401 -0
- package/references/opentasks/docs/ARCHITECTURE.md +841 -0
- package/references/opentasks/docs/DESIGN.md +689 -0
- package/references/opentasks/docs/INTERFACE.md +670 -0
- package/references/opentasks/docs/PERSISTENCE.md +1638 -0
- package/references/opentasks/docs/PROVIDERS.md +1412 -0
- package/references/opentasks/docs/SCHEMA.md +815 -0
- package/references/opentasks/docs/TESTING.md +1081 -0
- package/references/opentasks/eslint.config.js +58 -0
- package/references/opentasks/package-lock.json +4348 -0
- package/references/opentasks/package.json +81 -0
- package/references/opentasks/skills/opentasks/SKILL.md +139 -0
- package/references/opentasks/skills/opentasks/dependency-management.md +119 -0
- package/references/opentasks/skills/opentasks/feedback-and-review.md +100 -0
- package/references/opentasks/skills/opentasks/linking-external-data.md +103 -0
- package/references/opentasks/skills/opentasks/spec-to-implementation.md +98 -0
- package/references/opentasks/src/__tests__/cli-tools.test.ts +800 -0
- package/references/opentasks/src/__tests__/cli.test.ts +97 -0
- package/references/opentasks/src/__tests__/p1-p3-gaps.test.ts +635 -0
- package/references/opentasks/src/cli.ts +929 -0
- package/references/opentasks/src/client/__tests__/client-crud.test.ts +546 -0
- package/references/opentasks/src/client/__tests__/client.test.ts +658 -0
- package/references/opentasks/src/client/__tests__/socket-discovery.test.ts +122 -0
- package/references/opentasks/src/client/client.ts +560 -0
- package/references/opentasks/src/client/index.ts +32 -0
- package/references/opentasks/src/config/__tests__/defaults.test.ts +66 -0
- package/references/opentasks/src/config/__tests__/env.test.ts +155 -0
- package/references/opentasks/src/config/__tests__/index.test.ts +148 -0
- package/references/opentasks/src/config/__tests__/loader.test.ts +173 -0
- package/references/opentasks/src/config/__tests__/merge.test.ts +121 -0
- package/references/opentasks/src/config/__tests__/schema.test.ts +446 -0
- package/references/opentasks/src/config/defaults.ts +18 -0
- package/references/opentasks/src/config/env.ts +170 -0
- package/references/opentasks/src/config/errors.ts +33 -0
- package/references/opentasks/src/config/index.ts +63 -0
- package/references/opentasks/src/config/loader.ts +90 -0
- package/references/opentasks/src/config/merge.ts +64 -0
- package/references/opentasks/src/config/schema.ts +767 -0
- package/references/opentasks/src/core/__tests__/conditional-redirects.test.ts +116 -0
- package/references/opentasks/src/core/__tests__/connections.test.ts +194 -0
- package/references/opentasks/src/core/__tests__/hash.test.ts +161 -0
- package/references/opentasks/src/core/__tests__/id.test.ts +175 -0
- package/references/opentasks/src/core/__tests__/init.test.ts +115 -0
- package/references/opentasks/src/core/__tests__/location.test.ts +94 -0
- package/references/opentasks/src/core/__tests__/merge-driver.test.ts +300 -0
- package/references/opentasks/src/core/__tests__/redirects.test.ts +169 -0
- package/references/opentasks/src/core/__tests__/resolve-location-target.test.ts +468 -0
- package/references/opentasks/src/core/__tests__/uri.test.ts +228 -0
- package/references/opentasks/src/core/__tests__/worktree.test.ts +160 -0
- package/references/opentasks/src/core/conditional-redirects.ts +100 -0
- package/references/opentasks/src/core/connections.ts +217 -0
- package/references/opentasks/src/core/discover.ts +195 -0
- package/references/opentasks/src/core/hash.ts +74 -0
- package/references/opentasks/src/core/id.ts +174 -0
- package/references/opentasks/src/core/index.ts +108 -0
- package/references/opentasks/src/core/init.ts +66 -0
- package/references/opentasks/src/core/location.ts +139 -0
- package/references/opentasks/src/core/merge-driver.ts +280 -0
- package/references/opentasks/src/core/redirects.ts +182 -0
- package/references/opentasks/src/core/uri.ts +270 -0
- package/references/opentasks/src/core/worktree.ts +504 -0
- package/references/opentasks/src/daemon/__tests__/e2e-live-agent.test.ts +344 -0
- package/references/opentasks/src/daemon/__tests__/e2e-session-pipeline.test.ts +447 -0
- package/references/opentasks/src/daemon/__tests__/e2e-watch.test.ts +279 -0
- package/references/opentasks/src/daemon/__tests__/entire-linker.test.ts +1074 -0
- package/references/opentasks/src/daemon/__tests__/entire-watcher.test.ts +659 -0
- package/references/opentasks/src/daemon/__tests__/flush.test.ts +306 -0
- package/references/opentasks/src/daemon/__tests__/integration.test.ts +338 -0
- package/references/opentasks/src/daemon/__tests__/ipc.test.ts +406 -0
- package/references/opentasks/src/daemon/__tests__/lifecycle.test.ts +378 -0
- package/references/opentasks/src/daemon/__tests__/lock.test.ts +240 -0
- package/references/opentasks/src/daemon/__tests__/methods/graph.test.ts +372 -0
- package/references/opentasks/src/daemon/__tests__/methods/provider.test.ts +238 -0
- package/references/opentasks/src/daemon/__tests__/methods/tools.test.ts +690 -0
- package/references/opentasks/src/daemon/__tests__/multi-location.test.ts +945 -0
- package/references/opentasks/src/daemon/__tests__/registry.test.ts +268 -0
- package/references/opentasks/src/daemon/__tests__/watcher.test.ts +329 -0
- package/references/opentasks/src/daemon/entire-linker.ts +615 -0
- package/references/opentasks/src/daemon/entire-watcher.ts +415 -0
- package/references/opentasks/src/daemon/factory.ts +133 -0
- package/references/opentasks/src/daemon/flush.ts +168 -0
- package/references/opentasks/src/daemon/index.ts +120 -0
- package/references/opentasks/src/daemon/ipc.ts +491 -0
- package/references/opentasks/src/daemon/lifecycle.ts +1106 -0
- package/references/opentasks/src/daemon/location-state.ts +481 -0
- package/references/opentasks/src/daemon/lock.ts +168 -0
- package/references/opentasks/src/daemon/methods/__tests__/graph.test.ts +359 -0
- package/references/opentasks/src/daemon/methods/__tests__/provider.test.ts +227 -0
- package/references/opentasks/src/daemon/methods/__tests__/tools.test.ts +360 -0
- package/references/opentasks/src/daemon/methods/__tests__/watch.test.ts +656 -0
- package/references/opentasks/src/daemon/methods/archive.ts +193 -0
- package/references/opentasks/src/daemon/methods/graph.ts +274 -0
- package/references/opentasks/src/daemon/methods/lifecycle.ts +112 -0
- package/references/opentasks/src/daemon/methods/location.ts +118 -0
- package/references/opentasks/src/daemon/methods/provider.ts +159 -0
- package/references/opentasks/src/daemon/methods/tools.ts +221 -0
- package/references/opentasks/src/daemon/methods/watch.ts +206 -0
- package/references/opentasks/src/daemon/registry.ts +244 -0
- package/references/opentasks/src/daemon/types.ts +163 -0
- package/references/opentasks/src/daemon/watcher.ts +248 -0
- package/references/opentasks/src/entire/__tests__/agent-registry.test.ts +127 -0
- package/references/opentasks/src/entire/__tests__/claude-generator.test.ts +49 -0
- package/references/opentasks/src/entire/__tests__/commit-msg.test.ts +89 -0
- package/references/opentasks/src/entire/__tests__/cursor-agent.test.ts +224 -0
- package/references/opentasks/src/entire/__tests__/flush-sentinel.test.ts +93 -0
- package/references/opentasks/src/entire/__tests__/gemini-agent.test.ts +375 -0
- package/references/opentasks/src/entire/__tests__/git-hooks.test.ts +85 -0
- package/references/opentasks/src/entire/__tests__/hook-managers.test.ts +128 -0
- package/references/opentasks/src/entire/__tests__/opencode-agent.test.ts +329 -0
- package/references/opentasks/src/entire/__tests__/redaction.test.ts +143 -0
- package/references/opentasks/src/entire/__tests__/session-store.test.ts +83 -0
- package/references/opentasks/src/entire/__tests__/summarize.test.ts +346 -0
- package/references/opentasks/src/entire/__tests__/transcript-timestamp.test.ts +127 -0
- package/references/opentasks/src/entire/__tests__/types.test.ts +112 -0
- package/references/opentasks/src/entire/__tests__/utils.test.ts +296 -0
- package/references/opentasks/src/entire/__tests__/validation.test.ts +103 -0
- package/references/opentasks/src/entire/__tests__/worktree.test.ts +66 -0
- package/references/opentasks/src/entire/agent/registry.ts +143 -0
- package/references/opentasks/src/entire/agent/session-types.ts +117 -0
- package/references/opentasks/src/entire/agent/types.ts +217 -0
- package/references/opentasks/src/entire/commands/clean.ts +134 -0
- package/references/opentasks/src/entire/commands/disable.ts +85 -0
- package/references/opentasks/src/entire/commands/doctor.ts +152 -0
- package/references/opentasks/src/entire/commands/enable.ts +149 -0
- package/references/opentasks/src/entire/commands/explain.ts +271 -0
- package/references/opentasks/src/entire/commands/reset.ts +105 -0
- package/references/opentasks/src/entire/commands/resume.ts +194 -0
- package/references/opentasks/src/entire/commands/rewind.ts +204 -0
- package/references/opentasks/src/entire/commands/status.ts +150 -0
- package/references/opentasks/src/entire/config.ts +153 -0
- package/references/opentasks/src/entire/git-operations.ts +485 -0
- package/references/opentasks/src/entire/hooks/git-hooks.ts +171 -0
- package/references/opentasks/src/entire/hooks/lifecycle.ts +224 -0
- package/references/opentasks/src/entire/index.ts +644 -0
- package/references/opentasks/src/entire/security/redaction.ts +263 -0
- package/references/opentasks/src/entire/session/state-machine.ts +463 -0
- package/references/opentasks/src/entire/store/checkpoint-store.ts +489 -0
- package/references/opentasks/src/entire/store/native-store.ts +178 -0
- package/references/opentasks/src/entire/store/provider-types.ts +99 -0
- package/references/opentasks/src/entire/store/session-store.ts +233 -0
- package/references/opentasks/src/entire/strategy/attribution.ts +300 -0
- package/references/opentasks/src/entire/strategy/common.ts +222 -0
- package/references/opentasks/src/entire/strategy/content-overlap.ts +242 -0
- package/references/opentasks/src/entire/strategy/manual-commit.ts +1008 -0
- package/references/opentasks/src/entire/strategy/types.ts +285 -0
- package/references/opentasks/src/entire/summarize/claude-generator.ts +119 -0
- package/references/opentasks/src/entire/summarize/summarize.ts +432 -0
- package/references/opentasks/src/entire/types.ts +408 -0
- package/references/opentasks/src/entire/utils/chunk-files.ts +49 -0
- package/references/opentasks/src/entire/utils/commit-message.ts +65 -0
- package/references/opentasks/src/entire/utils/detect-agent.ts +36 -0
- package/references/opentasks/src/entire/utils/hook-managers.ts +118 -0
- package/references/opentasks/src/entire/utils/ide-tags.ts +32 -0
- package/references/opentasks/src/entire/utils/paths.ts +59 -0
- package/references/opentasks/src/entire/utils/preview-rewind.ts +86 -0
- package/references/opentasks/src/entire/utils/rewind-conflict.ts +121 -0
- package/references/opentasks/src/entire/utils/shadow-branch.ts +113 -0
- package/references/opentasks/src/entire/utils/string-utils.ts +46 -0
- package/references/opentasks/src/entire/utils/todo-extract.ts +193 -0
- package/references/opentasks/src/entire/utils/trailers.ts +190 -0
- package/references/opentasks/src/entire/utils/transcript-parse.ts +177 -0
- package/references/opentasks/src/entire/utils/transcript-timestamp.ts +61 -0
- package/references/opentasks/src/entire/utils/tree-ops.ts +227 -0
- package/references/opentasks/src/entire/utils/tty.ts +72 -0
- package/references/opentasks/src/entire/utils/validation.ts +67 -0
- package/references/opentasks/src/entire/utils/worktree.ts +58 -0
- package/references/opentasks/src/graph/EdgeTypeRegistry.ts +330 -0
- package/references/opentasks/src/graph/FederatedGraph.ts +796 -0
- package/references/opentasks/src/graph/GraphologyAdapter.ts +374 -0
- package/references/opentasks/src/graph/HydratingFederatedGraph.ts +533 -0
- package/references/opentasks/src/graph/__tests__/EdgeTypeRegistry.test.ts +263 -0
- package/references/opentasks/src/graph/__tests__/FederatedGraph.test.ts +821 -0
- package/references/opentasks/src/graph/__tests__/GraphologyAdapter.test.ts +408 -0
- package/references/opentasks/src/graph/__tests__/HydratingFederatedGraph.test.ts +735 -0
- package/references/opentasks/src/graph/__tests__/debounce.test.ts +276 -0
- package/references/opentasks/src/graph/__tests__/e2e-store-roundtrip.test.ts +349 -0
- package/references/opentasks/src/graph/__tests__/edge-cases.test.ts +595 -0
- package/references/opentasks/src/graph/__tests__/expansion.test.ts +304 -0
- package/references/opentasks/src/graph/__tests__/git-graph-syncer.test.ts +572 -0
- package/references/opentasks/src/graph/__tests__/provider-store.test.ts +1091 -0
- package/references/opentasks/src/graph/__tests__/query.test.ts +991 -0
- package/references/opentasks/src/graph/__tests__/store.test.ts +998 -0
- package/references/opentasks/src/graph/__tests__/sync.test.ts +178 -0
- package/references/opentasks/src/graph/__tests__/validation.test.ts +657 -0
- package/references/opentasks/src/graph/coordination.ts +454 -0
- package/references/opentasks/src/graph/debounce.ts +154 -0
- package/references/opentasks/src/graph/expansion.ts +364 -0
- package/references/opentasks/src/graph/git-graph-syncer.ts +321 -0
- package/references/opentasks/src/graph/history.ts +438 -0
- package/references/opentasks/src/graph/index.ts +145 -0
- package/references/opentasks/src/graph/provider-store.ts +1077 -0
- package/references/opentasks/src/graph/query.ts +651 -0
- package/references/opentasks/src/graph/store.ts +861 -0
- package/references/opentasks/src/graph/sync.ts +116 -0
- package/references/opentasks/src/graph/types.ts +420 -0
- package/references/opentasks/src/graph/validation.ts +520 -0
- package/references/opentasks/src/index.ts +270 -0
- package/references/opentasks/src/materialization/CLAUDE.md +88 -0
- package/references/opentasks/src/materialization/README.md +187 -0
- package/references/opentasks/src/materialization/__tests__/archive-methods.test.ts +194 -0
- package/references/opentasks/src/materialization/__tests__/archiver.test.ts +528 -0
- package/references/opentasks/src/materialization/__tests__/config.test.ts +123 -0
- package/references/opentasks/src/materialization/__tests__/git-remote-store.test.ts +533 -0
- package/references/opentasks/src/materialization/__tests__/graph-id.test.ts +82 -0
- package/references/opentasks/src/materialization/__tests__/http-remote-store.test.ts +263 -0
- package/references/opentasks/src/materialization/__tests__/materialize-before-archive.test.ts +246 -0
- package/references/opentasks/src/materialization/__tests__/remote-store-factory.test.ts +152 -0
- package/references/opentasks/src/materialization/__tests__/snapshot.test.ts +209 -0
- package/references/opentasks/src/materialization/archiver.ts +318 -0
- package/references/opentasks/src/materialization/git-archive-store.ts +568 -0
- package/references/opentasks/src/materialization/git-remote-store.ts +551 -0
- package/references/opentasks/src/materialization/graph-id.ts +173 -0
- package/references/opentasks/src/materialization/http-remote-store.ts +190 -0
- package/references/opentasks/src/materialization/index.ts +62 -0
- package/references/opentasks/src/materialization/remote-store-factory.ts +55 -0
- package/references/opentasks/src/materialization/snapshot.ts +230 -0
- package/references/opentasks/src/materialization/types.ts +410 -0
- package/references/opentasks/src/providers/__tests__/beads.test.ts +752 -0
- package/references/opentasks/src/providers/__tests__/claude-tasks.test.ts +485 -0
- package/references/opentasks/src/providers/__tests__/entire-e2e.test.ts +692 -0
- package/references/opentasks/src/providers/__tests__/entire-sessionlog-e2e.test.ts +1113 -0
- package/references/opentasks/src/providers/__tests__/entire.test.ts +1016 -0
- package/references/opentasks/src/providers/__tests__/from-config.test.ts +183 -0
- package/references/opentasks/src/providers/__tests__/global.test.ts +515 -0
- package/references/opentasks/src/providers/__tests__/materialization.test.ts +567 -0
- package/references/opentasks/src/providers/__tests__/native.test.ts +693 -0
- package/references/opentasks/src/providers/__tests__/registry.test.ts +232 -0
- package/references/opentasks/src/providers/beads.ts +1155 -0
- package/references/opentasks/src/providers/claude-tasks.ts +402 -0
- package/references/opentasks/src/providers/entire.ts +608 -0
- package/references/opentasks/src/providers/from-config.ts +210 -0
- package/references/opentasks/src/providers/global.ts +460 -0
- package/references/opentasks/src/providers/index.ts +147 -0
- package/references/opentasks/src/providers/location.ts +237 -0
- package/references/opentasks/src/providers/materialization.ts +346 -0
- package/references/opentasks/src/providers/native.ts +725 -0
- package/references/opentasks/src/providers/registry.ts +114 -0
- package/references/opentasks/src/providers/sudocode.ts +1292 -0
- package/references/opentasks/src/providers/sync.ts +485 -0
- package/references/opentasks/src/providers/traits/RelationshipQueryable.ts +169 -0
- package/references/opentasks/src/providers/traits/TaskManageable.ts +211 -0
- package/references/opentasks/src/providers/traits/Watchable.ts +260 -0
- package/references/opentasks/src/providers/traits/__tests__/RelationshipQueryable.test.ts +217 -0
- package/references/opentasks/src/providers/traits/__tests__/TaskManageable.test.ts +241 -0
- package/references/opentasks/src/providers/traits/index.ts +42 -0
- package/references/opentasks/src/providers/types.ts +439 -0
- package/references/opentasks/src/schema/__tests__/validation.test.ts +283 -0
- package/references/opentasks/src/schema/base.ts +88 -0
- package/references/opentasks/src/schema/edges.ts +78 -0
- package/references/opentasks/src/schema/index.ts +37 -0
- package/references/opentasks/src/schema/nodes.ts +119 -0
- package/references/opentasks/src/schema/storage.ts +130 -0
- package/references/opentasks/src/schema/validation.ts +209 -0
- package/references/opentasks/src/storage/__tests__/atomic-write.test.ts +227 -0
- package/references/opentasks/src/storage/__tests__/file-lock.test.ts +120 -0
- package/references/opentasks/src/storage/__tests__/jsonl.test.ts +267 -0
- package/references/opentasks/src/storage/__tests__/locked-writer.test.ts +134 -0
- package/references/opentasks/src/storage/__tests__/sqlite.test.ts +572 -0
- package/references/opentasks/src/storage/atomic-write.ts +86 -0
- package/references/opentasks/src/storage/file-lock.ts +215 -0
- package/references/opentasks/src/storage/index.ts +24 -0
- package/references/opentasks/src/storage/interface.ts +289 -0
- package/references/opentasks/src/storage/jsonl.ts +264 -0
- package/references/opentasks/src/storage/locked-writer.ts +140 -0
- package/references/opentasks/src/storage/sqlite-schema.ts +177 -0
- package/references/opentasks/src/storage/sqlite.ts +791 -0
- package/references/opentasks/src/tools/__tests__/annotate.test.ts +381 -0
- package/references/opentasks/src/tools/__tests__/link.test.ts +299 -0
- package/references/opentasks/src/tools/__tests__/query.test.ts +350 -0
- package/references/opentasks/src/tools/__tests__/task.test.ts +218 -0
- package/references/opentasks/src/tools/annotate.ts +277 -0
- package/references/opentasks/src/tools/index.ts +57 -0
- package/references/opentasks/src/tools/link.ts +163 -0
- package/references/opentasks/src/tools/query.ts +468 -0
- package/references/opentasks/src/tools/task.ts +213 -0
- package/references/opentasks/src/tools/types.ts +451 -0
- package/references/opentasks/src/tracking/__tests__/claude-tool-categorizer.test.ts +223 -0
- package/references/opentasks/src/tracking/__tests__/transcript-extractor.test.ts +262 -0
- package/references/opentasks/src/tracking/claude-tool-categorizer.ts +155 -0
- package/references/opentasks/src/tracking/index.ts +32 -0
- package/references/opentasks/src/tracking/skill-tracker.ts +322 -0
- package/references/opentasks/src/tracking/transcript-extractor.ts +225 -0
- package/references/opentasks/tests/e2e/helpers/assertions.ts +211 -0
- package/references/opentasks/tests/e2e/helpers/beads-helpers.ts +487 -0
- package/references/opentasks/tests/e2e/helpers/fixtures.ts +236 -0
- package/references/opentasks/tests/e2e/helpers/index.ts +122 -0
- package/references/opentasks/tests/e2e/helpers/sudocode-helpers.ts +341 -0
- package/references/opentasks/tests/e2e/helpers/system-setup.ts +504 -0
- package/references/opentasks/tests/e2e/helpers/test-agent.ts +504 -0
- package/references/opentasks/tests/e2e/infrastructure.e2e.test.ts +521 -0
- package/references/opentasks/tests/e2e/skill-tracking.e2e.test.ts +625 -0
- package/references/opentasks/tests/e2e/workflows/feedback-loop.e2e.test.ts +279 -0
- package/references/opentasks/tests/e2e/workflows/multi-agent.e2e.test.ts +304 -0
- package/references/opentasks/tests/e2e/workflows/provider-sync/background-sync.e2e.test.ts +292 -0
- package/references/opentasks/tests/e2e/workflows/provider-sync/beads-provider-compat.e2e.test.ts +249 -0
- package/references/opentasks/tests/e2e/workflows/provider-sync/cross-provider-edges.e2e.test.ts +407 -0
- package/references/opentasks/tests/e2e/workflows/provider-sync/federated-ready.e2e.test.ts +504 -0
- package/references/opentasks/tests/e2e/workflows/provider-sync/hydration.e2e.test.ts +340 -0
- package/references/opentasks/tests/e2e/workflows/provider-sync/materialization.e2e.test.ts +370 -0
- package/references/opentasks/tests/e2e/workflows/provider-sync/sudocode-provider-compat.e2e.test.ts +683 -0
- package/references/opentasks/tests/e2e/workflows/provider-sync/watchable-beads.e2e.test.ts +573 -0
- package/references/opentasks/tests/e2e/workflows/spec-driven.e2e.test.ts +244 -0
- package/references/opentasks/tests/e2e/worktree-location.e2e.test.ts +699 -0
- package/references/opentasks/tests/integration/daemon/helpers.ts +147 -0
- package/references/opentasks/tests/integration/daemon/ipc.integration.test.ts +343 -0
- package/references/opentasks/tests/integration/daemon/lifecycle.integration.test.ts +407 -0
- package/references/opentasks/tests/integration/graph/federated-graph.integration.test.ts +660 -0
- package/references/opentasks/tests/integration/helpers/flags.ts +28 -0
- package/references/opentasks/tests/integration/helpers/index.ts +47 -0
- package/references/opentasks/tests/integration/helpers/process.ts +133 -0
- package/references/opentasks/tests/integration/helpers/temp.ts +105 -0
- package/references/opentasks/tests/integration/helpers/wait.ts +133 -0
- package/references/opentasks/tests/integration/helpers.test.ts +120 -0
- package/references/opentasks/tests/integration/providers/beads-task-manageable.integration.test.ts +450 -0
- package/references/opentasks/tests/integration/providers/beads.integration.test.ts +388 -0
- package/references/opentasks/tests/integration/providers/native-task-manageable.integration.test.ts +667 -0
- package/references/opentasks/tests/integration/providers/sudocode-task-manageable.integration.test.ts +406 -0
- package/references/opentasks/tests/integration/providers/sudocode.integration.test.ts +342 -0
- package/references/opentasks/tests/integration/storage/jsonl-durability.integration.test.ts +390 -0
- package/references/opentasks/tests/integration/storage/sqlite-durability.integration.test.ts +527 -0
- package/references/opentasks/tests/integration/worktree/redirect-location-resolution.integration.test.ts +578 -0
- package/references/opentasks/tests/integration/worktree/worktree-flow.integration.test.ts +656 -0
- package/references/opentasks/tsconfig.json +18 -0
- package/references/opentasks/vitest.config.ts +27 -0
- package/references/opentasks/vitest.e2e.config.ts +35 -0
- package/references/opentasks/vitest.integration.config.ts +19 -0
- package/references/openteams/.claude/settings.json +6 -0
- package/references/openteams/CLAUDE.md +98 -0
- package/references/openteams/README.md +508 -0
- package/references/openteams/SKILL.md +198 -0
- package/references/openteams/design.md +250 -0
- package/references/openteams/docs/visual-editor-design.md +1225 -0
- package/references/openteams/editor/index.html +15 -0
- package/references/openteams/editor/package.json +39 -0
- package/references/openteams/editor/src/App.tsx +48 -0
- package/references/openteams/editor/src/components/canvas/Canvas.tsx +131 -0
- package/references/openteams/editor/src/components/canvas/QuickAddMenu.tsx +134 -0
- package/references/openteams/editor/src/components/edges/PeerRouteEdge.tsx +82 -0
- package/references/openteams/editor/src/components/edges/SignalFlowEdge.tsx +77 -0
- package/references/openteams/editor/src/components/edges/SpawnEdge.tsx +54 -0
- package/references/openteams/editor/src/components/inspector/ChannelInspector.tsx +158 -0
- package/references/openteams/editor/src/components/inspector/EdgeInspector.tsx +168 -0
- package/references/openteams/editor/src/components/inspector/Inspector.tsx +46 -0
- package/references/openteams/editor/src/components/inspector/RoleInspector.tsx +508 -0
- package/references/openteams/editor/src/components/inspector/TeamInspector.tsx +126 -0
- package/references/openteams/editor/src/components/nodes/ChannelNode.tsx +103 -0
- package/references/openteams/editor/src/components/nodes/RoleNode.tsx +157 -0
- package/references/openteams/editor/src/components/nodes/node-styles.ts +101 -0
- package/references/openteams/editor/src/components/sidebar/Sidebar.tsx +227 -0
- package/references/openteams/editor/src/components/toolbar/ExportModal.tsx +110 -0
- package/references/openteams/editor/src/components/toolbar/ImportModal.tsx +139 -0
- package/references/openteams/editor/src/components/toolbar/Toolbar.tsx +190 -0
- package/references/openteams/editor/src/hooks/use-autosave.ts +126 -0
- package/references/openteams/editor/src/hooks/use-keyboard.ts +106 -0
- package/references/openteams/editor/src/hooks/use-validation.ts +45 -0
- package/references/openteams/editor/src/index.css +245 -0
- package/references/openteams/editor/src/lib/auto-layout.ts +51 -0
- package/references/openteams/editor/src/lib/bundled-templates.ts +42 -0
- package/references/openteams/editor/src/lib/compiler.ts +75 -0
- package/references/openteams/editor/src/lib/load-template.ts +103 -0
- package/references/openteams/editor/src/lib/rebuild-edges.ts +104 -0
- package/references/openteams/editor/src/lib/serializer.ts +408 -0
- package/references/openteams/editor/src/lib/signal-catalog.ts +50 -0
- package/references/openteams/editor/src/lib/validator.ts +172 -0
- package/references/openteams/editor/src/main.tsx +10 -0
- package/references/openteams/editor/src/stores/canvas-store.ts +80 -0
- package/references/openteams/editor/src/stores/config-store.ts +243 -0
- package/references/openteams/editor/src/stores/history-store.ts +143 -0
- package/references/openteams/editor/src/stores/theme-store.ts +66 -0
- package/references/openteams/editor/src/stores/ui-store.ts +46 -0
- package/references/openteams/editor/src/stores/validation-store.ts +27 -0
- package/references/openteams/editor/src/types/editor.ts +74 -0
- package/references/openteams/editor/src/vite-env.d.ts +1 -0
- package/references/openteams/editor/tests/compiler.test.ts +151 -0
- package/references/openteams/editor/tests/e2e-add-remove.test.ts +386 -0
- package/references/openteams/editor/tests/e2e-components.test.tsx +424 -0
- package/references/openteams/editor/tests/e2e-export-roundtrip.test.ts +299 -0
- package/references/openteams/editor/tests/e2e-template-load.test.ts +204 -0
- package/references/openteams/editor/tests/e2e-ui-store.test.ts +126 -0
- package/references/openteams/editor/tests/e2e-undo-redo.test.ts +203 -0
- package/references/openteams/editor/tests/e2e-validation.test.ts +307 -0
- package/references/openteams/editor/tests/serializer.test.ts +142 -0
- package/references/openteams/editor/tests/setup.ts +52 -0
- package/references/openteams/editor/tests/validator.test.ts +92 -0
- package/references/openteams/editor/tsconfig.json +21 -0
- package/references/openteams/editor/tsconfig.tsbuildinfo +1 -0
- package/references/openteams/editor/vite.config.ts +28 -0
- package/references/openteams/examples/bmad-method/prompts/analyst/ROLE.md +16 -0
- package/references/openteams/examples/bmad-method/prompts/analyst/SOUL.md +5 -0
- package/references/openteams/examples/bmad-method/prompts/architect/ROLE.md +24 -0
- package/references/openteams/examples/bmad-method/prompts/architect/SOUL.md +5 -0
- package/references/openteams/examples/bmad-method/prompts/developer/ROLE.md +25 -0
- package/references/openteams/examples/bmad-method/prompts/developer/SOUL.md +5 -0
- package/references/openteams/examples/bmad-method/prompts/master/ROLE.md +21 -0
- package/references/openteams/examples/bmad-method/prompts/master/SOUL.md +5 -0
- package/references/openteams/examples/bmad-method/prompts/pm/ROLE.md +20 -0
- package/references/openteams/examples/bmad-method/prompts/pm/SOUL.md +5 -0
- package/references/openteams/examples/bmad-method/prompts/qa/ROLE.md +17 -0
- package/references/openteams/examples/bmad-method/prompts/qa/SOUL.md +5 -0
- package/references/openteams/examples/bmad-method/prompts/quick-flow-dev/ROLE.md +23 -0
- package/references/openteams/examples/bmad-method/prompts/quick-flow-dev/SOUL.md +5 -0
- package/references/openteams/examples/bmad-method/prompts/scrum-master/ROLE.md +27 -0
- package/references/openteams/examples/bmad-method/prompts/scrum-master/SOUL.md +5 -0
- package/references/openteams/examples/bmad-method/prompts/tech-writer/ROLE.md +21 -0
- package/references/openteams/examples/bmad-method/prompts/tech-writer/SOUL.md +5 -0
- package/references/openteams/examples/bmad-method/prompts/ux-designer/ROLE.md +16 -0
- package/references/openteams/examples/bmad-method/prompts/ux-designer/SOUL.md +5 -0
- package/references/openteams/examples/bmad-method/roles/analyst.yaml +9 -0
- package/references/openteams/examples/bmad-method/roles/architect.yaml +9 -0
- package/references/openteams/examples/bmad-method/roles/developer.yaml +8 -0
- package/references/openteams/examples/bmad-method/roles/master.yaml +8 -0
- package/references/openteams/examples/bmad-method/roles/pm.yaml +9 -0
- package/references/openteams/examples/bmad-method/roles/qa.yaml +8 -0
- package/references/openteams/examples/bmad-method/roles/quick-flow-dev.yaml +8 -0
- package/references/openteams/examples/bmad-method/roles/scrum-master.yaml +9 -0
- package/references/openteams/examples/bmad-method/roles/tech-writer.yaml +8 -0
- package/references/openteams/examples/bmad-method/roles/ux-designer.yaml +8 -0
- package/references/openteams/examples/bmad-method/team.yaml +161 -0
- package/references/openteams/examples/bug-fix-pipeline/roles/fixer.yaml +9 -0
- package/references/openteams/examples/bug-fix-pipeline/roles/investigator.yaml +8 -0
- package/references/openteams/examples/bug-fix-pipeline/roles/pr-creator.yaml +6 -0
- package/references/openteams/examples/bug-fix-pipeline/roles/triager.yaml +7 -0
- package/references/openteams/examples/bug-fix-pipeline/roles/verifier.yaml +8 -0
- package/references/openteams/examples/bug-fix-pipeline/team.yaml +88 -0
- package/references/openteams/examples/codebase-migration/roles/assessor.yaml +7 -0
- package/references/openteams/examples/codebase-migration/roles/migrator.yaml +9 -0
- package/references/openteams/examples/codebase-migration/roles/planner.yaml +5 -0
- package/references/openteams/examples/codebase-migration/roles/test-extractor.yaml +9 -0
- package/references/openteams/examples/codebase-migration/roles/validator.yaml +7 -0
- package/references/openteams/examples/codebase-migration/team.yaml +81 -0
- package/references/openteams/examples/docs-sync/roles/adr-writer.yaml +7 -0
- package/references/openteams/examples/docs-sync/roles/api-doc-writer.yaml +7 -0
- package/references/openteams/examples/docs-sync/roles/change-detector.yaml +7 -0
- package/references/openteams/examples/docs-sync/roles/doc-reviewer.yaml +7 -0
- package/references/openteams/examples/docs-sync/roles/guide-writer.yaml +7 -0
- package/references/openteams/examples/docs-sync/team.yaml +84 -0
- package/references/openteams/examples/gsd/prompts/codebase-mapper/ROLE.md +17 -0
- package/references/openteams/examples/gsd/prompts/codebase-mapper/SOUL.md +5 -0
- package/references/openteams/examples/gsd/prompts/debugger/ROLE.md +25 -0
- package/references/openteams/examples/gsd/prompts/debugger/SOUL.md +5 -0
- package/references/openteams/examples/gsd/prompts/executor/ROLE.md +34 -0
- package/references/openteams/examples/gsd/prompts/executor/SOUL.md +5 -0
- package/references/openteams/examples/gsd/prompts/integration-checker/ROLE.md +18 -0
- package/references/openteams/examples/gsd/prompts/integration-checker/SOUL.md +3 -0
- package/references/openteams/examples/gsd/prompts/orchestrator/ROLE.md +42 -0
- package/references/openteams/examples/gsd/prompts/orchestrator/SOUL.md +5 -0
- package/references/openteams/examples/gsd/prompts/phase-researcher/ROLE.md +15 -0
- package/references/openteams/examples/gsd/prompts/phase-researcher/SOUL.md +3 -0
- package/references/openteams/examples/gsd/prompts/plan-checker/ROLE.md +17 -0
- package/references/openteams/examples/gsd/prompts/plan-checker/SOUL.md +3 -0
- package/references/openteams/examples/gsd/prompts/planner/ROLE.md +28 -0
- package/references/openteams/examples/gsd/prompts/planner/SOUL.md +5 -0
- package/references/openteams/examples/gsd/prompts/project-researcher/ROLE.md +16 -0
- package/references/openteams/examples/gsd/prompts/project-researcher/SOUL.md +3 -0
- package/references/openteams/examples/gsd/prompts/research-synthesizer/ROLE.md +13 -0
- package/references/openteams/examples/gsd/prompts/research-synthesizer/SOUL.md +3 -0
- package/references/openteams/examples/gsd/prompts/roadmapper/ROLE.md +14 -0
- package/references/openteams/examples/gsd/prompts/roadmapper/SOUL.md +3 -0
- package/references/openteams/examples/gsd/prompts/verifier/ROLE.md +19 -0
- package/references/openteams/examples/gsd/prompts/verifier/SOUL.md +5 -0
- package/references/openteams/examples/gsd/roles/codebase-mapper.yaml +8 -0
- package/references/openteams/examples/gsd/roles/debugger.yaml +8 -0
- package/references/openteams/examples/gsd/roles/executor.yaml +8 -0
- package/references/openteams/examples/gsd/roles/integration-checker.yaml +8 -0
- package/references/openteams/examples/gsd/roles/orchestrator.yaml +9 -0
- package/references/openteams/examples/gsd/roles/phase-researcher.yaml +7 -0
- package/references/openteams/examples/gsd/roles/plan-checker.yaml +8 -0
- package/references/openteams/examples/gsd/roles/planner.yaml +8 -0
- package/references/openteams/examples/gsd/roles/project-researcher.yaml +8 -0
- package/references/openteams/examples/gsd/roles/research-synthesizer.yaml +7 -0
- package/references/openteams/examples/gsd/roles/roadmapper.yaml +7 -0
- package/references/openteams/examples/gsd/roles/verifier.yaml +8 -0
- package/references/openteams/examples/gsd/team.yaml +154 -0
- package/references/openteams/examples/incident-response/roles/communicator.yaml +5 -0
- package/references/openteams/examples/incident-response/roles/fix-proposer.yaml +7 -0
- package/references/openteams/examples/incident-response/roles/incident-triager.yaml +8 -0
- package/references/openteams/examples/incident-response/roles/investigator.yaml +8 -0
- package/references/openteams/examples/incident-response/team.yaml +68 -0
- package/references/openteams/examples/pr-review-checks/roles/code-reviewer.yaml +7 -0
- package/references/openteams/examples/pr-review-checks/roles/security-scanner.yaml +6 -0
- package/references/openteams/examples/pr-review-checks/roles/summarizer.yaml +6 -0
- package/references/openteams/examples/pr-review-checks/roles/test-checker.yaml +8 -0
- package/references/openteams/examples/pr-review-checks/team.yaml +64 -0
- package/references/openteams/examples/security-audit/roles/code-analyzer.yaml +6 -0
- package/references/openteams/examples/security-audit/roles/dep-scanner.yaml +7 -0
- package/references/openteams/examples/security-audit/roles/fixer.yaml +9 -0
- package/references/openteams/examples/security-audit/roles/pr-creator.yaml +6 -0
- package/references/openteams/examples/security-audit/roles/prioritizer.yaml +6 -0
- package/references/openteams/examples/security-audit/roles/secrets-scanner.yaml +6 -0
- package/references/openteams/examples/security-audit/roles/verifier.yaml +8 -0
- package/references/openteams/examples/security-audit/team.yaml +102 -0
- package/references/openteams/media/banner.png +0 -0
- package/references/openteams/media/editor.png +0 -0
- package/references/openteams/package-lock.json +4804 -0
- package/references/openteams/package.json +58 -0
- package/references/openteams/schema/role.schema.json +147 -0
- package/references/openteams/schema/team.schema.json +311 -0
- package/references/openteams/src/cli/editor.ts +170 -0
- package/references/openteams/src/cli/generate.test.ts +191 -0
- package/references/openteams/src/cli/generate.ts +242 -0
- package/references/openteams/src/cli/prompt-utils.ts +42 -0
- package/references/openteams/src/cli/template.test.ts +365 -0
- package/references/openteams/src/cli/template.ts +205 -0
- package/references/openteams/src/cli.ts +22 -0
- package/references/openteams/src/generators/agent-prompt-generator.test.ts +426 -0
- package/references/openteams/src/generators/agent-prompt-generator.ts +556 -0
- package/references/openteams/src/generators/package-generator.test.ts +129 -0
- package/references/openteams/src/generators/package-generator.ts +110 -0
- package/references/openteams/src/generators/skill-generator.test.ts +274 -0
- package/references/openteams/src/generators/skill-generator.ts +394 -0
- package/references/openteams/src/index.ts +84 -0
- package/references/openteams/src/template/builtins.test.ts +74 -0
- package/references/openteams/src/template/builtins.ts +108 -0
- package/references/openteams/src/template/install-service.test.ts +452 -0
- package/references/openteams/src/template/install-service.ts +332 -0
- package/references/openteams/src/template/loader.test.ts +1696 -0
- package/references/openteams/src/template/loader.ts +804 -0
- package/references/openteams/src/template/resolver.test.ts +304 -0
- package/references/openteams/src/template/resolver.ts +251 -0
- package/references/openteams/src/template/types.ts +229 -0
- package/references/openteams/tsconfig.cjs.json +7 -0
- package/references/openteams/tsconfig.esm.json +8 -0
- package/references/openteams/tsconfig.json +16 -0
- package/references/openteams/vitest.config.ts +9 -0
- package/references/sessionlog/.husky/pre-commit +1 -0
- package/references/sessionlog/.lintstagedrc.json +4 -0
- package/references/sessionlog/.prettierignore +4 -0
- package/references/sessionlog/.prettierrc.json +11 -0
- package/references/sessionlog/LICENSE +21 -0
- package/references/sessionlog/README.md +453 -0
- package/references/sessionlog/eslint.config.js +58 -0
- package/references/sessionlog/package-lock.json +3672 -0
- package/references/sessionlog/package.json +65 -0
- package/references/sessionlog/src/__tests__/agent-hooks.test.ts +570 -0
- package/references/sessionlog/src/__tests__/agent-registry.test.ts +127 -0
- package/references/sessionlog/src/__tests__/claude-code-hooks.test.ts +225 -0
- package/references/sessionlog/src/__tests__/claude-generator.test.ts +46 -0
- package/references/sessionlog/src/__tests__/commit-msg.test.ts +86 -0
- package/references/sessionlog/src/__tests__/cursor-agent.test.ts +224 -0
- package/references/sessionlog/src/__tests__/e2e-live.test.ts +890 -0
- package/references/sessionlog/src/__tests__/event-log.test.ts +183 -0
- package/references/sessionlog/src/__tests__/flush-sentinel.test.ts +105 -0
- package/references/sessionlog/src/__tests__/gemini-agent.test.ts +375 -0
- package/references/sessionlog/src/__tests__/git-hooks.test.ts +78 -0
- package/references/sessionlog/src/__tests__/hook-managers.test.ts +121 -0
- package/references/sessionlog/src/__tests__/lifecycle-tasks.test.ts +759 -0
- package/references/sessionlog/src/__tests__/opencode-agent.test.ts +338 -0
- package/references/sessionlog/src/__tests__/redaction.test.ts +136 -0
- package/references/sessionlog/src/__tests__/session-repo.test.ts +353 -0
- package/references/sessionlog/src/__tests__/session-store.test.ts +166 -0
- package/references/sessionlog/src/__tests__/setup-ccweb.test.ts +466 -0
- package/references/sessionlog/src/__tests__/skill-live.test.ts +461 -0
- package/references/sessionlog/src/__tests__/summarize.test.ts +348 -0
- package/references/sessionlog/src/__tests__/task-plan-e2e.test.ts +610 -0
- package/references/sessionlog/src/__tests__/task-plan-live.test.ts +632 -0
- package/references/sessionlog/src/__tests__/transcript-timestamp.test.ts +121 -0
- package/references/sessionlog/src/__tests__/types.test.ts +166 -0
- package/references/sessionlog/src/__tests__/utils.test.ts +333 -0
- package/references/sessionlog/src/__tests__/validation.test.ts +103 -0
- package/references/sessionlog/src/__tests__/worktree.test.ts +57 -0
- package/references/sessionlog/src/agent/registry.ts +143 -0
- package/references/sessionlog/src/agent/session-types.ts +113 -0
- package/references/sessionlog/src/agent/types.ts +220 -0
- package/references/sessionlog/src/cli.ts +597 -0
- package/references/sessionlog/src/commands/clean.ts +133 -0
- package/references/sessionlog/src/commands/disable.ts +84 -0
- package/references/sessionlog/src/commands/doctor.ts +145 -0
- package/references/sessionlog/src/commands/enable.ts +202 -0
- package/references/sessionlog/src/commands/explain.ts +261 -0
- package/references/sessionlog/src/commands/reset.ts +105 -0
- package/references/sessionlog/src/commands/resume.ts +180 -0
- package/references/sessionlog/src/commands/rewind.ts +195 -0
- package/references/sessionlog/src/commands/setup-ccweb.ts +275 -0
- package/references/sessionlog/src/commands/status.ts +172 -0
- package/references/sessionlog/src/config.ts +165 -0
- package/references/sessionlog/src/events/event-log.ts +126 -0
- package/references/sessionlog/src/git-operations.ts +558 -0
- package/references/sessionlog/src/hooks/git-hooks.ts +165 -0
- package/references/sessionlog/src/hooks/lifecycle.ts +391 -0
- package/references/sessionlog/src/index.ts +650 -0
- package/references/sessionlog/src/security/redaction.ts +283 -0
- package/references/sessionlog/src/session/state-machine.ts +452 -0
- package/references/sessionlog/src/store/checkpoint-store.ts +509 -0
- package/references/sessionlog/src/store/native-store.ts +173 -0
- package/references/sessionlog/src/store/provider-types.ts +99 -0
- package/references/sessionlog/src/store/session-store.ts +266 -0
- package/references/sessionlog/src/strategy/attribution.ts +296 -0
- package/references/sessionlog/src/strategy/common.ts +207 -0
- package/references/sessionlog/src/strategy/content-overlap.ts +228 -0
- package/references/sessionlog/src/strategy/manual-commit.ts +988 -0
- package/references/sessionlog/src/strategy/types.ts +279 -0
- package/references/sessionlog/src/summarize/claude-generator.ts +115 -0
- package/references/sessionlog/src/summarize/summarize.ts +432 -0
- package/references/sessionlog/src/types.ts +508 -0
- package/references/sessionlog/src/utils/chunk-files.ts +49 -0
- package/references/sessionlog/src/utils/commit-message.ts +65 -0
- package/references/sessionlog/src/utils/detect-agent.ts +36 -0
- package/references/sessionlog/src/utils/hook-managers.ts +125 -0
- package/references/sessionlog/src/utils/ide-tags.ts +32 -0
- package/references/sessionlog/src/utils/paths.ts +79 -0
- package/references/sessionlog/src/utils/preview-rewind.ts +80 -0
- package/references/sessionlog/src/utils/rewind-conflict.ts +121 -0
- package/references/sessionlog/src/utils/shadow-branch.ts +109 -0
- package/references/sessionlog/src/utils/string-utils.ts +46 -0
- package/references/sessionlog/src/utils/todo-extract.ts +188 -0
- package/references/sessionlog/src/utils/trailers.ts +187 -0
- package/references/sessionlog/src/utils/transcript-parse.ts +177 -0
- package/references/sessionlog/src/utils/transcript-timestamp.ts +59 -0
- package/references/sessionlog/src/utils/tree-ops.ts +219 -0
- package/references/sessionlog/src/utils/tty.ts +72 -0
- package/references/sessionlog/src/utils/validation.ts +65 -0
- package/references/sessionlog/src/utils/worktree.ts +58 -0
- package/references/sessionlog/src/wire-types.ts +59 -0
- package/references/sessionlog/templates/setup-env.sh +153 -0
- package/references/sessionlog/tsconfig.json +18 -0
- package/references/sessionlog/vitest.config.ts +12 -0
- package/references/skill-tree/.claude/settings.json +6 -0
- package/references/skill-tree/.sudocode/issues.jsonl +19 -0
- package/references/skill-tree/.sudocode/specs.jsonl +3 -0
- package/references/skill-tree/CLAUDE.md +132 -0
- package/references/skill-tree/README.md +396 -0
- package/references/skill-tree/docs/GAPS_v1.md +221 -0
- package/references/skill-tree/docs/INTEGRATION_PLAN.md +467 -0
- package/references/skill-tree/docs/TODOS.md +91 -0
- package/references/skill-tree/docs/anthropic_skill_guide.md +1364 -0
- package/references/skill-tree/docs/design/federated-skill-trees.md +524 -0
- package/references/skill-tree/docs/design/multi-agent-sync.md +759 -0
- package/references/skill-tree/docs/scraper/BRAINSTORM.md +583 -0
- package/references/skill-tree/docs/scraper/POC_PLAN.md +420 -0
- package/references/skill-tree/docs/scraper/README.md +170 -0
- package/references/skill-tree/examples/basic-usage.ts +157 -0
- package/references/skill-tree/package-lock.json +1852 -0
- package/references/skill-tree/package.json +66 -0
- package/references/skill-tree/plan.md +78 -0
- package/references/skill-tree/scraper/README.md +123 -0
- package/references/skill-tree/scraper/docs/DESIGN.md +683 -0
- package/references/skill-tree/scraper/docs/PLAN.md +336 -0
- package/references/skill-tree/scraper/drizzle.config.ts +10 -0
- package/references/skill-tree/scraper/package-lock.json +6329 -0
- package/references/skill-tree/scraper/package.json +68 -0
- package/references/skill-tree/scraper/test/fixtures/invalid-skill/missing-description.md +7 -0
- package/references/skill-tree/scraper/test/fixtures/invalid-skill/missing-name.md +7 -0
- package/references/skill-tree/scraper/test/fixtures/minimal-skill/SKILL.md +27 -0
- package/references/skill-tree/scraper/test/fixtures/skill-json/SKILL.json +21 -0
- package/references/skill-tree/scraper/test/fixtures/skill-with-meta/SKILL.md +54 -0
- package/references/skill-tree/scraper/test/fixtures/skill-with-meta/_meta.json +24 -0
- package/references/skill-tree/scraper/test/fixtures/valid-skill/SKILL.md +93 -0
- package/references/skill-tree/scraper/test/fixtures/valid-skill/_meta.json +22 -0
- package/references/skill-tree/scraper/tsup.config.ts +14 -0
- package/references/skill-tree/scraper/vitest.config.ts +17 -0
- package/references/skill-tree/scripts/convert-to-vitest.ts +166 -0
- package/references/skill-tree/skills/skill-writer/SKILL.md +339 -0
- package/references/skill-tree/skills/skill-writer/references/examples.md +326 -0
- package/references/skill-tree/skills/skill-writer/references/patterns.md +210 -0
- package/references/skill-tree/skills/skill-writer/references/quality-checklist.md +123 -0
- package/references/skill-tree/test/run-all.ts +106 -0
- package/references/skill-tree/test/utils.ts +128 -0
- package/references/skill-tree/vitest.config.ts +16 -0
- package/references/swarmkit/LICENSE +21 -0
- package/references/swarmkit/README.md +130 -0
- package/references/swarmkit/docs/design.md +453 -0
- package/references/swarmkit/docs/package-setup-reference.md +519 -0
- package/references/swarmkit/package-lock.json +1938 -0
- package/references/swarmkit/package.json +43 -0
- package/references/swarmkit/src/cli.ts +41 -0
- package/references/swarmkit/src/commands/add.ts +126 -0
- package/references/swarmkit/src/commands/doctor.ts +117 -0
- package/references/swarmkit/src/commands/hive.ts +279 -0
- package/references/swarmkit/src/commands/init/phases/configure.ts +74 -0
- package/references/swarmkit/src/commands/init/phases/global-setup.ts +104 -0
- package/references/swarmkit/src/commands/init/phases/packages.ts +44 -0
- package/references/swarmkit/src/commands/init/phases/project.ts +81 -0
- package/references/swarmkit/src/commands/init/phases/use-case.ts +47 -0
- package/references/swarmkit/src/commands/init/state.test.ts +23 -0
- package/references/swarmkit/src/commands/init/state.ts +22 -0
- package/references/swarmkit/src/commands/init/wizard.ts +160 -0
- package/references/swarmkit/src/commands/init.ts +17 -0
- package/references/swarmkit/src/commands/login.ts +106 -0
- package/references/swarmkit/src/commands/logout.ts +22 -0
- package/references/swarmkit/src/commands/remove.ts +72 -0
- package/references/swarmkit/src/commands/status.ts +101 -0
- package/references/swarmkit/src/commands/update.ts +62 -0
- package/references/swarmkit/src/commands/whoami.ts +41 -0
- package/references/swarmkit/src/config/global.test.ts +258 -0
- package/references/swarmkit/src/config/global.ts +141 -0
- package/references/swarmkit/src/config/keys.test.ts +109 -0
- package/references/swarmkit/src/config/keys.ts +49 -0
- package/references/swarmkit/src/doctor/checks.test.ts +366 -0
- package/references/swarmkit/src/doctor/checks.ts +292 -0
- package/references/swarmkit/src/doctor/types.ts +33 -0
- package/references/swarmkit/src/hub/auth-flow.test.ts +127 -0
- package/references/swarmkit/src/hub/auth-flow.ts +144 -0
- package/references/swarmkit/src/hub/client.test.ts +224 -0
- package/references/swarmkit/src/hub/client.ts +185 -0
- package/references/swarmkit/src/hub/credentials.test.ts +132 -0
- package/references/swarmkit/src/hub/credentials.ts +51 -0
- package/references/swarmkit/src/index.ts +116 -0
- package/references/swarmkit/src/packages/installer.test.ts +365 -0
- package/references/swarmkit/src/packages/installer.ts +206 -0
- package/references/swarmkit/src/packages/plugin.test.ts +141 -0
- package/references/swarmkit/src/packages/plugin.ts +46 -0
- package/references/swarmkit/src/packages/registry.test.ts +235 -0
- package/references/swarmkit/src/packages/registry.ts +209 -0
- package/references/swarmkit/src/packages/setup.test.ts +1395 -0
- package/references/swarmkit/src/packages/setup.ts +671 -0
- package/references/swarmkit/src/utils/ui.test.ts +115 -0
- package/references/swarmkit/src/utils/ui.ts +62 -0
- package/references/swarmkit/tsconfig.json +17 -0
- package/references/swarmkit/vitest.config.ts +9 -0
- package/scripts/bootstrap.mjs +33 -1
- package/scripts/generate-agents.mjs +5 -1
- package/scripts/map-hook.mjs +100 -63
- package/scripts/map-sidecar.mjs +198 -25
- package/scripts/team-loader.mjs +26 -48
- package/skills/swarm/SKILL.md +85 -27
- package/src/__tests__/agent-generator.test.mjs +15 -23
- package/src/__tests__/bootstrap.test.mjs +124 -1
- package/src/__tests__/config.test.mjs +72 -27
- package/src/__tests__/context-output.test.mjs +13 -14
- package/src/__tests__/e2e-inbox-integration.test.mjs +732 -0
- package/src/__tests__/e2e-live-inbox.test.mjs +597 -0
- package/src/__tests__/e2e-live-map.test.mjs +536 -0
- package/src/__tests__/e2e-mesh-sidecar.test.mjs +570 -0
- package/src/__tests__/e2e-native-task-hooks.test.mjs +376 -0
- package/src/__tests__/e2e-sidecar-bridge.test.mjs +477 -0
- package/src/__tests__/helpers.mjs +13 -0
- package/src/__tests__/inbox-integration.test.mjs +298 -0
- package/src/__tests__/inbox.test.mjs +22 -89
- package/src/__tests__/index.test.mjs +33 -9
- package/src/__tests__/integration.test.mjs +514 -0
- package/src/__tests__/map-events.test.mjs +514 -150
- package/src/__tests__/mesh-connection.test.mjs +308 -0
- package/src/__tests__/opentasks-client.test.mjs +517 -0
- package/src/__tests__/paths.test.mjs +185 -54
- package/src/__tests__/sidecar-client.test.mjs +35 -0
- package/src/__tests__/sidecar-server.test.mjs +124 -0
- package/src/__tests__/skilltree-client.test.mjs +126 -0
- package/src/agent-generator.mjs +129 -67
- package/src/bootstrap.mjs +174 -13
- package/src/config.mjs +35 -1
- package/src/context-output.mjs +254 -30
- package/src/inbox.mjs +9 -54
- package/src/index.mjs +38 -7
- package/src/map-connection.mjs +1 -0
- package/src/map-events.mjs +350 -80
- package/src/mesh-connection.mjs +148 -0
- package/src/opentasks-client.mjs +269 -0
- package/src/paths.mjs +178 -28
- package/src/sessionlog.mjs +14 -9
- package/src/sidecar-client.mjs +79 -25
- package/src/sidecar-server.mjs +205 -16
- package/src/skilltree-client.mjs +218 -0
- package/src/template.mjs +68 -4
- package/vitest.config.mjs +1 -0
|
@@ -0,0 +1,1741 @@
|
|
|
1
|
+
/**
|
|
2
|
+
* Comprehensive tests for resource content routes.
|
|
3
|
+
*
|
|
4
|
+
* Creates fixtures using the ACTUAL minimem and skill-tree packages:
|
|
5
|
+
* - Memory files generated via minimem's serializeFrontmatter() + addFrontmatter()
|
|
6
|
+
* - Skill files generated via skill-tree's FilesystemStorageAdapter.saveSkill()
|
|
7
|
+
* - Cross-validates route responses against the packages' own parsers
|
|
8
|
+
*/
|
|
9
|
+
|
|
10
|
+
import { describe, it, expect, beforeAll, afterAll } from 'vitest';
|
|
11
|
+
import Fastify, { FastifyInstance } from 'fastify';
|
|
12
|
+
import * as fs from 'fs';
|
|
13
|
+
import * as path from 'path';
|
|
14
|
+
import { initDatabase, closeDatabase } from '../../db/index.js';
|
|
15
|
+
import * as agentsDAL from '../../db/dal/agents.js';
|
|
16
|
+
import * as resourcesDAL from '../../db/dal/syncable-resources.js';
|
|
17
|
+
import { resourceContentRoutes } from '../../api/routes/resource-content.js';
|
|
18
|
+
import { ConfigSchema, type Config } from '../../config.js';
|
|
19
|
+
import { testRoot, testDbPath, cleanTestRoot, mkTestDir } from '../helpers/test-dirs.js';
|
|
20
|
+
|
|
21
|
+
// ---------------------------------------------------------------------------
|
|
22
|
+
// Imports from the ACTUAL packages (installed as file: deps)
|
|
23
|
+
// ---------------------------------------------------------------------------
|
|
24
|
+
import {
|
|
25
|
+
serializeFrontmatter,
|
|
26
|
+
parseFrontmatter as minimemParseFrontmatter,
|
|
27
|
+
} from 'minimem/session';
|
|
28
|
+
import type { MemoryFrontmatter, KnowledgeLink } from 'minimem/session';
|
|
29
|
+
|
|
30
|
+
import { FilesystemStorageAdapter } from 'skill-tree';
|
|
31
|
+
import type { Skill } from 'skill-tree';
|
|
32
|
+
|
|
33
|
+
// ============================================================================
|
|
34
|
+
// Fixture builders that use the actual packages
|
|
35
|
+
// ============================================================================
|
|
36
|
+
|
|
37
|
+
/** Build a minimem knowledge note file using the package's serializer */
|
|
38
|
+
function buildMemoryFile(frontmatter: MemoryFrontmatter, body: string): string {
|
|
39
|
+
return serializeFrontmatter(frontmatter) + body;
|
|
40
|
+
}
|
|
41
|
+
|
|
42
|
+
/** Build a minimal Skill object compatible with skill-tree's types */
|
|
43
|
+
function buildSkill(overrides: Partial<Skill> & { id: string; name: string }): Skill {
|
|
44
|
+
const now = new Date();
|
|
45
|
+
return {
|
|
46
|
+
version: '1.0.0',
|
|
47
|
+
description: '',
|
|
48
|
+
problem: '',
|
|
49
|
+
triggerConditions: [],
|
|
50
|
+
solution: '',
|
|
51
|
+
verification: '',
|
|
52
|
+
examples: [],
|
|
53
|
+
author: 'test',
|
|
54
|
+
tags: [],
|
|
55
|
+
createdAt: now,
|
|
56
|
+
updatedAt: now,
|
|
57
|
+
status: 'active',
|
|
58
|
+
metrics: { usageCount: 0, successRate: 0, feedbackScores: [] },
|
|
59
|
+
...overrides,
|
|
60
|
+
};
|
|
61
|
+
}
|
|
62
|
+
|
|
63
|
+
// ============================================================================
|
|
64
|
+
// Fixture data (typed through the packages' own types)
|
|
65
|
+
// ============================================================================
|
|
66
|
+
|
|
67
|
+
const OBSERVATION_FM: MemoryFrontmatter = {
|
|
68
|
+
id: 'k-prisma-migration',
|
|
69
|
+
type: 'observation',
|
|
70
|
+
domain: ['database', 'devops'],
|
|
71
|
+
entities: ['prisma', 'postgres'],
|
|
72
|
+
confidence: 0.85,
|
|
73
|
+
source: {
|
|
74
|
+
origin: 'extracted',
|
|
75
|
+
trajectories: ['t-001', 't-002'],
|
|
76
|
+
agentId: 'agent-v1',
|
|
77
|
+
},
|
|
78
|
+
links: [
|
|
79
|
+
{ target: 'k-postgres-tips', relation: 'related-to', layer: 'semantic' },
|
|
80
|
+
{ target: 'k-schema-design', relation: 'depends-on', layer: 'causal' },
|
|
81
|
+
],
|
|
82
|
+
created: '2025-01-15T10:00:00Z',
|
|
83
|
+
updated: '2025-01-15T12:00:00Z',
|
|
84
|
+
supersedes: 'k-old-migration',
|
|
85
|
+
tags: ['migration', 'patterns'],
|
|
86
|
+
};
|
|
87
|
+
|
|
88
|
+
const ENTITY_FM: MemoryFrontmatter = {
|
|
89
|
+
id: 'k-postgres-tips',
|
|
90
|
+
type: 'entity',
|
|
91
|
+
domain: ['database'],
|
|
92
|
+
entities: ['postgres'],
|
|
93
|
+
confidence: 0.92,
|
|
94
|
+
source: { origin: 'agent-authored', agentId: 'agent-v2' },
|
|
95
|
+
created: '2025-01-16T08:00:00Z',
|
|
96
|
+
tags: ['database', 'tips'],
|
|
97
|
+
};
|
|
98
|
+
|
|
99
|
+
const DAILY_LOG_FM: MemoryFrontmatter = {
|
|
100
|
+
created: '2025-01-15',
|
|
101
|
+
tags: ['daily', 'log'],
|
|
102
|
+
};
|
|
103
|
+
|
|
104
|
+
const TS_SKILL: Skill = buildSkill({
|
|
105
|
+
id: 'typescript-strict',
|
|
106
|
+
name: 'TypeScript Strict Mode Fixes',
|
|
107
|
+
version: '1.2.0',
|
|
108
|
+
status: 'active',
|
|
109
|
+
description: 'Fix common TypeScript strict mode errors in Node.js projects',
|
|
110
|
+
tags: ['typescript', 'node', 'strict-mode', 'error-fix'],
|
|
111
|
+
author: 'agent-v1',
|
|
112
|
+
problem: 'TypeScript strict mode enables several compiler checks that catch common errors.',
|
|
113
|
+
triggerConditions: [
|
|
114
|
+
{ type: 'pattern', value: '"strict": true', description: 'tsconfig has strict mode' },
|
|
115
|
+
],
|
|
116
|
+
solution: 'Start with strictNullChecks first. Use optional chaining and nullish coalescing.',
|
|
117
|
+
verification: 'Run `npx tsc --noEmit` — zero errors.',
|
|
118
|
+
examples: [
|
|
119
|
+
{
|
|
120
|
+
scenario: 'Optional chaining migration',
|
|
121
|
+
before: 'const name = response.data.user.name;',
|
|
122
|
+
after: "const name = response.data?.user?.name ?? 'Unknown';",
|
|
123
|
+
},
|
|
124
|
+
],
|
|
125
|
+
notes: 'This skill is especially useful during major TypeScript version upgrades.',
|
|
126
|
+
});
|
|
127
|
+
|
|
128
|
+
const API_SKILL: Skill = buildSkill({
|
|
129
|
+
id: 'api-design',
|
|
130
|
+
name: 'REST API Design Patterns',
|
|
131
|
+
version: '0.1.0',
|
|
132
|
+
status: 'draft',
|
|
133
|
+
description: 'Best practices for designing RESTful APIs',
|
|
134
|
+
tags: ['api', 'rest', 'design'],
|
|
135
|
+
author: 'agent-v2',
|
|
136
|
+
problem: 'Inconsistent API design leads to confusion and integration issues.',
|
|
137
|
+
solution: 'Use nouns for resource URLs, not verbs. Version your API.',
|
|
138
|
+
verification: 'All endpoints follow naming conventions.',
|
|
139
|
+
});
|
|
140
|
+
|
|
141
|
+
const GIT_SKILL: Skill = buildSkill({
|
|
142
|
+
id: 'git-workflow',
|
|
143
|
+
name: 'Git Rebase Workflow',
|
|
144
|
+
version: '0.3.0',
|
|
145
|
+
status: 'experimental',
|
|
146
|
+
description: 'Rebase-based git workflow for clean history',
|
|
147
|
+
tags: ['git', 'workflow', 'rebase'],
|
|
148
|
+
problem: 'Merge commits clutter the git history.',
|
|
149
|
+
triggerConditions: [
|
|
150
|
+
{ type: 'context', value: 'feature-branch', description: 'Working on feature branches' },
|
|
151
|
+
],
|
|
152
|
+
solution: 'Rebase feature branch onto main before merging.',
|
|
153
|
+
verification: 'git log --oneline shows linear history on main.',
|
|
154
|
+
});
|
|
155
|
+
|
|
156
|
+
const DEPRECATED_SKILL: Skill = buildSkill({
|
|
157
|
+
id: 'jquery-dom',
|
|
158
|
+
name: 'jQuery DOM Manipulation',
|
|
159
|
+
version: '2.0.0',
|
|
160
|
+
status: 'deprecated',
|
|
161
|
+
description: 'DOM manipulation patterns using jQuery',
|
|
162
|
+
tags: ['jquery', 'frontend', 'legacy'],
|
|
163
|
+
author: 'agent-v0',
|
|
164
|
+
problem: 'Direct DOM manipulation without a framework is verbose.',
|
|
165
|
+
solution: 'Use jQuery selectors and chaining for DOM operations.',
|
|
166
|
+
notes: 'This skill is kept for reference when maintaining legacy codebases.',
|
|
167
|
+
});
|
|
168
|
+
|
|
169
|
+
// ============================================================================
|
|
170
|
+
// Test setup
|
|
171
|
+
// ============================================================================
|
|
172
|
+
|
|
173
|
+
const TEST_ROOT = testRoot('resource-content');
|
|
174
|
+
const TEST_DB_PATH = testDbPath(TEST_ROOT, 'resource-content-test.db');
|
|
175
|
+
|
|
176
|
+
function createTestConfig(): Config {
|
|
177
|
+
return ConfigSchema.parse({
|
|
178
|
+
database: TEST_DB_PATH,
|
|
179
|
+
instance: { name: 'Test OpenHive', description: 'Test instance' },
|
|
180
|
+
admin: { createOnStartup: false },
|
|
181
|
+
auth: { mode: 'local' },
|
|
182
|
+
rateLimit: { enabled: false },
|
|
183
|
+
});
|
|
184
|
+
}
|
|
185
|
+
|
|
186
|
+
async function createTestApp(config: Config): Promise<FastifyInstance> {
|
|
187
|
+
const app = Fastify({ logger: false });
|
|
188
|
+
app.decorateRequest('agent', null);
|
|
189
|
+
await app.register(
|
|
190
|
+
async (api) => {
|
|
191
|
+
await api.register(resourceContentRoutes, { config });
|
|
192
|
+
},
|
|
193
|
+
{ prefix: '/api/v1' },
|
|
194
|
+
);
|
|
195
|
+
return app;
|
|
196
|
+
}
|
|
197
|
+
|
|
198
|
+
/**
|
|
199
|
+
* Create a memory bank directory using minimem's serializer.
|
|
200
|
+
*/
|
|
201
|
+
function createMemoryBankFixture(baseDir: string): void {
|
|
202
|
+
fs.mkdirSync(baseDir, { recursive: true });
|
|
203
|
+
|
|
204
|
+
const memoryDir = path.join(baseDir, 'memory');
|
|
205
|
+
fs.mkdirSync(memoryDir, { recursive: true });
|
|
206
|
+
|
|
207
|
+
// MEMORY.md — plain file (no frontmatter)
|
|
208
|
+
fs.writeFileSync(path.join(baseDir, 'MEMORY.md'), '# Project Notes\n\n## Architecture\n\nChose SQLite for simplicity.\n');
|
|
209
|
+
|
|
210
|
+
// Knowledge note (observation) — generated by minimem's serializeFrontmatter
|
|
211
|
+
fs.writeFileSync(
|
|
212
|
+
path.join(memoryDir, 'prisma-migration.md'),
|
|
213
|
+
buildMemoryFile(OBSERVATION_FM, '# Prisma Migration Patterns\n\nAlways use `prisma migrate deploy`.\n'),
|
|
214
|
+
);
|
|
215
|
+
|
|
216
|
+
// Knowledge note (entity) — generated by minimem's serializeFrontmatter
|
|
217
|
+
fs.writeFileSync(
|
|
218
|
+
path.join(memoryDir, 'postgres-tips.md'),
|
|
219
|
+
buildMemoryFile(ENTITY_FM, '# PostgreSQL Tips\n\nUse PgBouncer for connection pooling.\n'),
|
|
220
|
+
);
|
|
221
|
+
|
|
222
|
+
// Daily log — generated by minimem's serializeFrontmatter
|
|
223
|
+
fs.writeFileSync(
|
|
224
|
+
path.join(memoryDir, '2025-01-15.md'),
|
|
225
|
+
buildMemoryFile(DAILY_LOG_FM, '# 2025-01-15\n\n## Completed\n\n- Fixed auth middleware bug\n'),
|
|
226
|
+
);
|
|
227
|
+
}
|
|
228
|
+
|
|
229
|
+
/**
|
|
230
|
+
* Create a skill tree directory using skill-tree's FilesystemStorageAdapter.
|
|
231
|
+
*/
|
|
232
|
+
async function createSkillTreeFixture(baseDir: string): Promise<void> {
|
|
233
|
+
const adapter = new FilesystemStorageAdapter({ basePath: baseDir });
|
|
234
|
+
await adapter.initialize();
|
|
235
|
+
await adapter.saveSkill(TS_SKILL);
|
|
236
|
+
await adapter.saveSkill(API_SKILL);
|
|
237
|
+
await adapter.saveSkill(GIT_SKILL);
|
|
238
|
+
await adapter.saveSkill(DEPRECATED_SKILL);
|
|
239
|
+
}
|
|
240
|
+
|
|
241
|
+
// ============================================================================
|
|
242
|
+
// Tests
|
|
243
|
+
// ============================================================================
|
|
244
|
+
|
|
245
|
+
describe('Resource Content Routes', () => {
|
|
246
|
+
let app: FastifyInstance;
|
|
247
|
+
let config: Config;
|
|
248
|
+
let testAgent: { id: string; apiKey: string };
|
|
249
|
+
let otherAgent: { id: string; apiKey: string };
|
|
250
|
+
|
|
251
|
+
let memoryResource: { id: string };
|
|
252
|
+
let skillResource: { id: string };
|
|
253
|
+
let remoteResource: { id: string };
|
|
254
|
+
|
|
255
|
+
let memoryDir: string;
|
|
256
|
+
let skillDir: string;
|
|
257
|
+
|
|
258
|
+
// References to the skill-tree adapter for cross-validation
|
|
259
|
+
let skillAdapter: FilesystemStorageAdapter;
|
|
260
|
+
|
|
261
|
+
beforeAll(async () => {
|
|
262
|
+
initDatabase(TEST_DB_PATH);
|
|
263
|
+
config = createTestConfig();
|
|
264
|
+
app = await createTestApp(config);
|
|
265
|
+
|
|
266
|
+
// Create test agents
|
|
267
|
+
const { agent: a1, apiKey: k1 } = await agentsDAL.createAgent({
|
|
268
|
+
name: 'content-test-agent',
|
|
269
|
+
description: 'Test agent for content routes',
|
|
270
|
+
});
|
|
271
|
+
testAgent = { id: a1.id, apiKey: k1 };
|
|
272
|
+
|
|
273
|
+
const { agent: a2, apiKey: k2 } = await agentsDAL.createAgent({
|
|
274
|
+
name: 'other-content-agent',
|
|
275
|
+
description: 'Another agent',
|
|
276
|
+
});
|
|
277
|
+
otherAgent = { id: a2.id, apiKey: k2 };
|
|
278
|
+
|
|
279
|
+
// Create memory bank fixture using minimem's serializer
|
|
280
|
+
memoryDir = mkTestDir(TEST_ROOT, 'memory-bank');
|
|
281
|
+
createMemoryBankFixture(memoryDir);
|
|
282
|
+
|
|
283
|
+
// Create skill tree fixture using skill-tree's adapter
|
|
284
|
+
skillDir = mkTestDir(TEST_ROOT, 'skill-tree');
|
|
285
|
+
await createSkillTreeFixture(skillDir);
|
|
286
|
+
|
|
287
|
+
// Keep adapter around for cross-validation reads
|
|
288
|
+
skillAdapter = new FilesystemStorageAdapter({ basePath: skillDir });
|
|
289
|
+
await skillAdapter.initialize();
|
|
290
|
+
|
|
291
|
+
// Create syncable resources
|
|
292
|
+
memoryResource = resourcesDAL.createResource({
|
|
293
|
+
resource_type: 'memory_bank',
|
|
294
|
+
name: 'Test Memory Bank',
|
|
295
|
+
description: 'Memory bank for testing',
|
|
296
|
+
git_remote_url: memoryDir,
|
|
297
|
+
visibility: 'private',
|
|
298
|
+
owner_agent_id: testAgent.id,
|
|
299
|
+
});
|
|
300
|
+
|
|
301
|
+
skillResource = resourcesDAL.createResource({
|
|
302
|
+
resource_type: 'skill',
|
|
303
|
+
name: 'Test Skill Tree',
|
|
304
|
+
description: 'Skill tree for testing',
|
|
305
|
+
git_remote_url: skillDir,
|
|
306
|
+
visibility: 'private',
|
|
307
|
+
owner_agent_id: testAgent.id,
|
|
308
|
+
});
|
|
309
|
+
|
|
310
|
+
remoteResource = resourcesDAL.createResource({
|
|
311
|
+
resource_type: 'memory_bank',
|
|
312
|
+
name: 'Remote Memory',
|
|
313
|
+
git_remote_url: 'https://github.com/example/memories.git',
|
|
314
|
+
visibility: 'public',
|
|
315
|
+
owner_agent_id: testAgent.id,
|
|
316
|
+
});
|
|
317
|
+
});
|
|
318
|
+
|
|
319
|
+
afterAll(async () => {
|
|
320
|
+
await app.close();
|
|
321
|
+
closeDatabase();
|
|
322
|
+
cleanTestRoot(TEST_ROOT);
|
|
323
|
+
});
|
|
324
|
+
|
|
325
|
+
// ========================================================================
|
|
326
|
+
// Memory Bank — List Files
|
|
327
|
+
// ========================================================================
|
|
328
|
+
|
|
329
|
+
describe('GET /resources/:id/content/files', () => {
|
|
330
|
+
it('should list all memory files written by minimem serializer', async () => {
|
|
331
|
+
const response = await app.inject({
|
|
332
|
+
method: 'GET',
|
|
333
|
+
url: `/api/v1/resources/${memoryResource.id}/content/files`,
|
|
334
|
+
headers: { Authorization: `Bearer ${testAgent.apiKey}` },
|
|
335
|
+
});
|
|
336
|
+
|
|
337
|
+
expect(response.statusCode).toBe(200);
|
|
338
|
+
const body = JSON.parse(response.body);
|
|
339
|
+
expect(body.files).toBeInstanceOf(Array);
|
|
340
|
+
|
|
341
|
+
// On case-insensitive FS (macOS), memory.md also resolves to MEMORY.md
|
|
342
|
+
expect(body.files.length).toBeGreaterThanOrEqual(4);
|
|
343
|
+
|
|
344
|
+
const paths = body.files.map((f: { path: string }) => f.path);
|
|
345
|
+
expect(paths).toContain('MEMORY.md');
|
|
346
|
+
expect(paths).toContain('memory/prisma-migration.md');
|
|
347
|
+
expect(paths).toContain('memory/postgres-tips.md');
|
|
348
|
+
expect(paths).toContain('memory/2025-01-15.md');
|
|
349
|
+
|
|
350
|
+
for (const file of body.files) {
|
|
351
|
+
expect(file.size).toBeGreaterThan(0);
|
|
352
|
+
expect(new Date(file.modified).getTime()).not.toBeNaN();
|
|
353
|
+
}
|
|
354
|
+
});
|
|
355
|
+
|
|
356
|
+
it('should require authentication', async () => {
|
|
357
|
+
const res = await app.inject({
|
|
358
|
+
method: 'GET',
|
|
359
|
+
url: `/api/v1/resources/${memoryResource.id}/content/files`,
|
|
360
|
+
});
|
|
361
|
+
expect(res.statusCode).toBe(401);
|
|
362
|
+
});
|
|
363
|
+
|
|
364
|
+
it('should return 403 for unauthorized agent', async () => {
|
|
365
|
+
const res = await app.inject({
|
|
366
|
+
method: 'GET',
|
|
367
|
+
url: `/api/v1/resources/${memoryResource.id}/content/files`,
|
|
368
|
+
headers: { Authorization: `Bearer ${otherAgent.apiKey}` },
|
|
369
|
+
});
|
|
370
|
+
expect(res.statusCode).toBe(403);
|
|
371
|
+
});
|
|
372
|
+
|
|
373
|
+
it('should return 404 for non-existent resource', async () => {
|
|
374
|
+
const res = await app.inject({
|
|
375
|
+
method: 'GET',
|
|
376
|
+
url: '/api/v1/resources/res_nonexistent/content/files',
|
|
377
|
+
headers: { Authorization: `Bearer ${testAgent.apiKey}` },
|
|
378
|
+
});
|
|
379
|
+
expect(res.statusCode).toBe(404);
|
|
380
|
+
});
|
|
381
|
+
|
|
382
|
+
it('should return 400 for remote resources', async () => {
|
|
383
|
+
const res = await app.inject({
|
|
384
|
+
method: 'GET',
|
|
385
|
+
url: `/api/v1/resources/${remoteResource.id}/content/files`,
|
|
386
|
+
headers: { Authorization: `Bearer ${testAgent.apiKey}` },
|
|
387
|
+
});
|
|
388
|
+
expect(res.statusCode).toBe(400);
|
|
389
|
+
expect(JSON.parse(res.body).message).toContain('local filesystem');
|
|
390
|
+
});
|
|
391
|
+
|
|
392
|
+
it('should return 400 for non-memory_bank type', async () => {
|
|
393
|
+
const res = await app.inject({
|
|
394
|
+
method: 'GET',
|
|
395
|
+
url: `/api/v1/resources/${skillResource.id}/content/files`,
|
|
396
|
+
headers: { Authorization: `Bearer ${testAgent.apiKey}` },
|
|
397
|
+
});
|
|
398
|
+
expect(res.statusCode).toBe(400);
|
|
399
|
+
});
|
|
400
|
+
});
|
|
401
|
+
|
|
402
|
+
// ========================================================================
|
|
403
|
+
// Memory Bank — Read File + Cross-validate with minimem
|
|
404
|
+
// ========================================================================
|
|
405
|
+
|
|
406
|
+
describe('GET /resources/:id/content/file', () => {
|
|
407
|
+
it('should read plain MEMORY.md (no frontmatter)', async () => {
|
|
408
|
+
const res = await app.inject({
|
|
409
|
+
method: 'GET',
|
|
410
|
+
url: `/api/v1/resources/${memoryResource.id}/content/file`,
|
|
411
|
+
query: { path: 'MEMORY.md' },
|
|
412
|
+
headers: { Authorization: `Bearer ${testAgent.apiKey}` },
|
|
413
|
+
});
|
|
414
|
+
|
|
415
|
+
expect(res.statusCode).toBe(200);
|
|
416
|
+
const body = JSON.parse(res.body);
|
|
417
|
+
expect(body.path).toBe('MEMORY.md');
|
|
418
|
+
expect(body.frontmatter).toBeNull();
|
|
419
|
+
expect(body.body).toContain('# Project Notes');
|
|
420
|
+
});
|
|
421
|
+
|
|
422
|
+
it('should match minimem parseFrontmatter for observation note', async () => {
|
|
423
|
+
const res = await app.inject({
|
|
424
|
+
method: 'GET',
|
|
425
|
+
url: `/api/v1/resources/${memoryResource.id}/content/file`,
|
|
426
|
+
query: { path: 'memory/prisma-migration.md' },
|
|
427
|
+
headers: { Authorization: `Bearer ${testAgent.apiKey}` },
|
|
428
|
+
});
|
|
429
|
+
|
|
430
|
+
expect(res.statusCode).toBe(200);
|
|
431
|
+
const routeResult = JSON.parse(res.body);
|
|
432
|
+
|
|
433
|
+
// Cross-validate: parse the same file with minimem's own parser
|
|
434
|
+
const rawContent = fs.readFileSync(
|
|
435
|
+
path.join(memoryDir, 'memory', 'prisma-migration.md'),
|
|
436
|
+
'utf-8',
|
|
437
|
+
);
|
|
438
|
+
const minimemResult = minimemParseFrontmatter(rawContent);
|
|
439
|
+
|
|
440
|
+
// Route should have frontmatter
|
|
441
|
+
expect(routeResult.frontmatter).not.toBeNull();
|
|
442
|
+
|
|
443
|
+
// The key knowledge fields should match minimem's parse
|
|
444
|
+
const routeFm = routeResult.frontmatter;
|
|
445
|
+
const mmFm = minimemResult.frontmatter!;
|
|
446
|
+
|
|
447
|
+
expect(routeFm.id).toBe(mmFm.id);
|
|
448
|
+
expect(routeFm.type).toBe(mmFm.type);
|
|
449
|
+
expect(routeFm.domain).toEqual(mmFm.domain);
|
|
450
|
+
expect(routeFm.entities).toEqual(mmFm.entities);
|
|
451
|
+
expect(routeFm.confidence).toBe(mmFm.confidence);
|
|
452
|
+
expect(routeFm.source.origin).toBe(mmFm.source!.origin);
|
|
453
|
+
expect(routeFm.source.trajectories).toEqual(mmFm.source!.trajectories);
|
|
454
|
+
expect(routeFm.source.agentId).toBe(mmFm.source!.agentId);
|
|
455
|
+
expect(routeFm.tags).toEqual(mmFm.tags);
|
|
456
|
+
expect(routeFm.supersedes).toBe(mmFm.supersedes);
|
|
457
|
+
|
|
458
|
+
// Links structure should match
|
|
459
|
+
expect(routeFm.links).toBeInstanceOf(Array);
|
|
460
|
+
expect(routeFm.links.length).toBe(mmFm.links!.length);
|
|
461
|
+
for (let i = 0; i < routeFm.links.length; i++) {
|
|
462
|
+
expect(routeFm.links[i].target).toBe(mmFm.links![i].target);
|
|
463
|
+
expect(routeFm.links[i].relation).toBe(mmFm.links![i].relation);
|
|
464
|
+
expect(routeFm.links[i].layer).toBe(mmFm.links![i].layer);
|
|
465
|
+
}
|
|
466
|
+
|
|
467
|
+
// Bodies should match
|
|
468
|
+
expect(routeResult.body.trim()).toBe(minimemResult.body.trim());
|
|
469
|
+
});
|
|
470
|
+
|
|
471
|
+
it('should match minimem parseFrontmatter for entity note', async () => {
|
|
472
|
+
const res = await app.inject({
|
|
473
|
+
method: 'GET',
|
|
474
|
+
url: `/api/v1/resources/${memoryResource.id}/content/file`,
|
|
475
|
+
query: { path: 'memory/postgres-tips.md' },
|
|
476
|
+
headers: { Authorization: `Bearer ${testAgent.apiKey}` },
|
|
477
|
+
});
|
|
478
|
+
|
|
479
|
+
const routeResult = JSON.parse(res.body);
|
|
480
|
+
const rawContent = fs.readFileSync(
|
|
481
|
+
path.join(memoryDir, 'memory', 'postgres-tips.md'),
|
|
482
|
+
'utf-8',
|
|
483
|
+
);
|
|
484
|
+
const minimemResult = minimemParseFrontmatter(rawContent);
|
|
485
|
+
|
|
486
|
+
expect(routeResult.frontmatter).not.toBeNull();
|
|
487
|
+
expect(routeResult.frontmatter.id).toBe(minimemResult.frontmatter!.id);
|
|
488
|
+
expect(routeResult.frontmatter.type).toBe(minimemResult.frontmatter!.type);
|
|
489
|
+
expect(routeResult.frontmatter.confidence).toBe(minimemResult.frontmatter!.confidence);
|
|
490
|
+
});
|
|
491
|
+
|
|
492
|
+
it('should match minimem parseFrontmatter for daily log', async () => {
|
|
493
|
+
const res = await app.inject({
|
|
494
|
+
method: 'GET',
|
|
495
|
+
url: `/api/v1/resources/${memoryResource.id}/content/file`,
|
|
496
|
+
query: { path: 'memory/2025-01-15.md' },
|
|
497
|
+
headers: { Authorization: `Bearer ${testAgent.apiKey}` },
|
|
498
|
+
});
|
|
499
|
+
|
|
500
|
+
const routeResult = JSON.parse(res.body);
|
|
501
|
+
const rawContent = fs.readFileSync(
|
|
502
|
+
path.join(memoryDir, 'memory', '2025-01-15.md'),
|
|
503
|
+
'utf-8',
|
|
504
|
+
);
|
|
505
|
+
const minimemResult = minimemParseFrontmatter(rawContent);
|
|
506
|
+
|
|
507
|
+
expect(routeResult.frontmatter).not.toBeNull();
|
|
508
|
+
expect(routeResult.frontmatter.tags).toEqual(minimemResult.frontmatter!.tags);
|
|
509
|
+
expect(routeResult.body.trim()).toBe(minimemResult.body.trim());
|
|
510
|
+
});
|
|
511
|
+
|
|
512
|
+
it('should require path query parameter', async () => {
|
|
513
|
+
const res = await app.inject({
|
|
514
|
+
method: 'GET',
|
|
515
|
+
url: `/api/v1/resources/${memoryResource.id}/content/file`,
|
|
516
|
+
headers: { Authorization: `Bearer ${testAgent.apiKey}` },
|
|
517
|
+
});
|
|
518
|
+
expect(res.statusCode).toBe(400);
|
|
519
|
+
});
|
|
520
|
+
|
|
521
|
+
it('should reject path traversal attempts', async () => {
|
|
522
|
+
for (const attempt of ['../etc/passwd', '../../secret.md', '/etc/passwd.md']) {
|
|
523
|
+
const res = await app.inject({
|
|
524
|
+
method: 'GET',
|
|
525
|
+
url: `/api/v1/resources/${memoryResource.id}/content/file`,
|
|
526
|
+
query: { path: attempt },
|
|
527
|
+
headers: { Authorization: `Bearer ${testAgent.apiKey}` },
|
|
528
|
+
});
|
|
529
|
+
expect(res.statusCode).toBe(400);
|
|
530
|
+
}
|
|
531
|
+
});
|
|
532
|
+
|
|
533
|
+
it('should reject non-.md file extensions', async () => {
|
|
534
|
+
const res = await app.inject({
|
|
535
|
+
method: 'GET',
|
|
536
|
+
url: `/api/v1/resources/${memoryResource.id}/content/file`,
|
|
537
|
+
query: { path: 'config.json' },
|
|
538
|
+
headers: { Authorization: `Bearer ${testAgent.apiKey}` },
|
|
539
|
+
});
|
|
540
|
+
expect(res.statusCode).toBe(400);
|
|
541
|
+
});
|
|
542
|
+
|
|
543
|
+
it('should return 404 for non-existent file', async () => {
|
|
544
|
+
const res = await app.inject({
|
|
545
|
+
method: 'GET',
|
|
546
|
+
url: `/api/v1/resources/${memoryResource.id}/content/file`,
|
|
547
|
+
query: { path: 'memory/nonexistent.md' },
|
|
548
|
+
headers: { Authorization: `Bearer ${testAgent.apiKey}` },
|
|
549
|
+
});
|
|
550
|
+
expect(res.statusCode).toBe(404);
|
|
551
|
+
});
|
|
552
|
+
});
|
|
553
|
+
|
|
554
|
+
// ========================================================================
|
|
555
|
+
// Memory Bank — Search
|
|
556
|
+
// ========================================================================
|
|
557
|
+
|
|
558
|
+
describe('GET /resources/:id/content/search', () => {
|
|
559
|
+
it('should find matches across files written by minimem serializer', async () => {
|
|
560
|
+
const res = await app.inject({
|
|
561
|
+
method: 'GET',
|
|
562
|
+
url: `/api/v1/resources/${memoryResource.id}/content/search`,
|
|
563
|
+
query: { q: 'postgres' },
|
|
564
|
+
headers: { Authorization: `Bearer ${testAgent.apiKey}` },
|
|
565
|
+
});
|
|
566
|
+
|
|
567
|
+
expect(res.statusCode).toBe(200);
|
|
568
|
+
const body = JSON.parse(res.body);
|
|
569
|
+
expect(body.results.length).toBeGreaterThan(0);
|
|
570
|
+
|
|
571
|
+
const matchPaths = body.results.map((r: { path: string }) => r.path);
|
|
572
|
+
expect(matchPaths).toContain('memory/postgres-tips.md');
|
|
573
|
+
});
|
|
574
|
+
|
|
575
|
+
it('should return line numbers and context snippets', async () => {
|
|
576
|
+
const res = await app.inject({
|
|
577
|
+
method: 'GET',
|
|
578
|
+
url: `/api/v1/resources/${memoryResource.id}/content/search`,
|
|
579
|
+
query: { q: 'Prisma' },
|
|
580
|
+
headers: { Authorization: `Bearer ${testAgent.apiKey}` },
|
|
581
|
+
});
|
|
582
|
+
|
|
583
|
+
const body = JSON.parse(res.body);
|
|
584
|
+
for (const result of body.results) {
|
|
585
|
+
expect(result.line).toBeGreaterThan(0);
|
|
586
|
+
expect(result.snippet.length).toBeGreaterThan(0);
|
|
587
|
+
}
|
|
588
|
+
});
|
|
589
|
+
|
|
590
|
+
it('should be case-insensitive', async () => {
|
|
591
|
+
const res = await app.inject({
|
|
592
|
+
method: 'GET',
|
|
593
|
+
url: `/api/v1/resources/${memoryResource.id}/content/search`,
|
|
594
|
+
query: { q: 'ARCHITECTURE' },
|
|
595
|
+
headers: { Authorization: `Bearer ${testAgent.apiKey}` },
|
|
596
|
+
});
|
|
597
|
+
|
|
598
|
+
const body = JSON.parse(res.body);
|
|
599
|
+
expect(body.results.length).toBeGreaterThan(0);
|
|
600
|
+
expect(body.results.some((r: { path: string }) => r.path === 'MEMORY.md')).toBe(true);
|
|
601
|
+
});
|
|
602
|
+
|
|
603
|
+
it('should respect limit parameter', async () => {
|
|
604
|
+
const res = await app.inject({
|
|
605
|
+
method: 'GET',
|
|
606
|
+
url: `/api/v1/resources/${memoryResource.id}/content/search`,
|
|
607
|
+
query: { q: 'the', limit: '2' },
|
|
608
|
+
headers: { Authorization: `Bearer ${testAgent.apiKey}` },
|
|
609
|
+
});
|
|
610
|
+
|
|
611
|
+
const body = JSON.parse(res.body);
|
|
612
|
+
expect(body.results.length).toBeLessThanOrEqual(2);
|
|
613
|
+
expect(body.total).toBeGreaterThanOrEqual(body.results.length);
|
|
614
|
+
});
|
|
615
|
+
|
|
616
|
+
it('should return empty for no matches', async () => {
|
|
617
|
+
const res = await app.inject({
|
|
618
|
+
method: 'GET',
|
|
619
|
+
url: `/api/v1/resources/${memoryResource.id}/content/search`,
|
|
620
|
+
query: { q: 'zzz_nonexistent_zzz' },
|
|
621
|
+
headers: { Authorization: `Bearer ${testAgent.apiKey}` },
|
|
622
|
+
});
|
|
623
|
+
|
|
624
|
+
const body = JSON.parse(res.body);
|
|
625
|
+
expect(body.results).toEqual([]);
|
|
626
|
+
expect(body.total).toBe(0);
|
|
627
|
+
});
|
|
628
|
+
|
|
629
|
+
it('should require q parameter', async () => {
|
|
630
|
+
const res = await app.inject({
|
|
631
|
+
method: 'GET',
|
|
632
|
+
url: `/api/v1/resources/${memoryResource.id}/content/search`,
|
|
633
|
+
headers: { Authorization: `Bearer ${testAgent.apiKey}` },
|
|
634
|
+
});
|
|
635
|
+
expect(res.statusCode).toBe(400);
|
|
636
|
+
});
|
|
637
|
+
|
|
638
|
+
it('should reject empty query', async () => {
|
|
639
|
+
const res = await app.inject({
|
|
640
|
+
method: 'GET',
|
|
641
|
+
url: `/api/v1/resources/${memoryResource.id}/content/search`,
|
|
642
|
+
query: { q: ' ' },
|
|
643
|
+
headers: { Authorization: `Bearer ${testAgent.apiKey}` },
|
|
644
|
+
});
|
|
645
|
+
expect(res.statusCode).toBe(400);
|
|
646
|
+
});
|
|
647
|
+
});
|
|
648
|
+
|
|
649
|
+
// ========================================================================
|
|
650
|
+
// Skill Content — List Skills + Cross-validate with skill-tree
|
|
651
|
+
// ========================================================================
|
|
652
|
+
|
|
653
|
+
describe('GET /resources/:id/content/skills', () => {
|
|
654
|
+
it('should list skills written by skill-tree adapter', async () => {
|
|
655
|
+
const res = await app.inject({
|
|
656
|
+
method: 'GET',
|
|
657
|
+
url: `/api/v1/resources/${skillResource.id}/content/skills`,
|
|
658
|
+
headers: { Authorization: `Bearer ${testAgent.apiKey}` },
|
|
659
|
+
});
|
|
660
|
+
|
|
661
|
+
expect(res.statusCode).toBe(200);
|
|
662
|
+
const body = JSON.parse(res.body);
|
|
663
|
+
expect(body.skills).toBeInstanceOf(Array);
|
|
664
|
+
expect(body.skills.length).toBe(4);
|
|
665
|
+
|
|
666
|
+
const ids = body.skills.map((s: { id: string }) => s.id).sort();
|
|
667
|
+
expect(ids).toEqual(['api-design', 'git-workflow', 'jquery-dom', 'typescript-strict']);
|
|
668
|
+
});
|
|
669
|
+
|
|
670
|
+
it('should match skill-tree adapter listSkills results', async () => {
|
|
671
|
+
// Read via our route
|
|
672
|
+
const res = await app.inject({
|
|
673
|
+
method: 'GET',
|
|
674
|
+
url: `/api/v1/resources/${skillResource.id}/content/skills`,
|
|
675
|
+
headers: { Authorization: `Bearer ${testAgent.apiKey}` },
|
|
676
|
+
});
|
|
677
|
+
const routeSkills = JSON.parse(res.body).skills as Array<{
|
|
678
|
+
id: string; name: string; version: string; status: string;
|
|
679
|
+
description: string; tags: string[]; author: string;
|
|
680
|
+
}>;
|
|
681
|
+
|
|
682
|
+
// Read via skill-tree's own adapter
|
|
683
|
+
const adapterSkills = await skillAdapter.listSkills();
|
|
684
|
+
|
|
685
|
+
// Same count
|
|
686
|
+
expect(routeSkills.length).toBe(adapterSkills.length);
|
|
687
|
+
|
|
688
|
+
// For each skill, the key fields should match
|
|
689
|
+
for (const adapterSkill of adapterSkills) {
|
|
690
|
+
const routeSkill = routeSkills.find(s => s.id === adapterSkill.id);
|
|
691
|
+
expect(routeSkill).toBeDefined();
|
|
692
|
+
expect(routeSkill!.name).toBe(adapterSkill.name);
|
|
693
|
+
expect(routeSkill!.version).toBe(adapterSkill.version);
|
|
694
|
+
expect(routeSkill!.status).toBe(adapterSkill.status);
|
|
695
|
+
expect(routeSkill!.author).toBe(adapterSkill.author);
|
|
696
|
+
}
|
|
697
|
+
});
|
|
698
|
+
|
|
699
|
+
it('should handle all skill statuses', async () => {
|
|
700
|
+
const res = await app.inject({
|
|
701
|
+
method: 'GET',
|
|
702
|
+
url: `/api/v1/resources/${skillResource.id}/content/skills`,
|
|
703
|
+
headers: { Authorization: `Bearer ${testAgent.apiKey}` },
|
|
704
|
+
});
|
|
705
|
+
|
|
706
|
+
const body = JSON.parse(res.body);
|
|
707
|
+
const statuses = new Map(body.skills.map((s: { id: string; status: string }) => [s.id, s.status]));
|
|
708
|
+
expect(statuses.get('typescript-strict')).toBe('active');
|
|
709
|
+
expect(statuses.get('api-design')).toBe('draft');
|
|
710
|
+
expect(statuses.get('git-workflow')).toBe('experimental');
|
|
711
|
+
expect(statuses.get('jquery-dom')).toBe('deprecated');
|
|
712
|
+
});
|
|
713
|
+
|
|
714
|
+
it('should return 400 for non-skill resource type', async () => {
|
|
715
|
+
const res = await app.inject({
|
|
716
|
+
method: 'GET',
|
|
717
|
+
url: `/api/v1/resources/${memoryResource.id}/content/skills`,
|
|
718
|
+
headers: { Authorization: `Bearer ${testAgent.apiKey}` },
|
|
719
|
+
});
|
|
720
|
+
expect(res.statusCode).toBe(400);
|
|
721
|
+
});
|
|
722
|
+
|
|
723
|
+
it('should return empty for directory with no skills', async () => {
|
|
724
|
+
const emptyDir = mkTestDir(TEST_ROOT, 'empty-skill');
|
|
725
|
+
const r = resourcesDAL.createResource({
|
|
726
|
+
resource_type: 'skill',
|
|
727
|
+
name: 'Empty',
|
|
728
|
+
git_remote_url: emptyDir,
|
|
729
|
+
visibility: 'private',
|
|
730
|
+
owner_agent_id: testAgent.id,
|
|
731
|
+
});
|
|
732
|
+
|
|
733
|
+
const res = await app.inject({
|
|
734
|
+
method: 'GET',
|
|
735
|
+
url: `/api/v1/resources/${r.id}/content/skills`,
|
|
736
|
+
headers: { Authorization: `Bearer ${testAgent.apiKey}` },
|
|
737
|
+
});
|
|
738
|
+
|
|
739
|
+
expect(res.statusCode).toBe(200);
|
|
740
|
+
expect(JSON.parse(res.body).skills).toEqual([]);
|
|
741
|
+
});
|
|
742
|
+
});
|
|
743
|
+
|
|
744
|
+
// ========================================================================
|
|
745
|
+
// Skill Content — Detail + Cross-validate with skill-tree
|
|
746
|
+
// ========================================================================
|
|
747
|
+
|
|
748
|
+
describe('GET /resources/:id/content/skills/:skillId', () => {
|
|
749
|
+
it('should return full detail and match skill-tree getSkill', async () => {
|
|
750
|
+
const res = await app.inject({
|
|
751
|
+
method: 'GET',
|
|
752
|
+
url: `/api/v1/resources/${skillResource.id}/content/skills/typescript-strict`,
|
|
753
|
+
headers: { Authorization: `Bearer ${testAgent.apiKey}` },
|
|
754
|
+
});
|
|
755
|
+
|
|
756
|
+
expect(res.statusCode).toBe(200);
|
|
757
|
+
const routeDetail = JSON.parse(res.body);
|
|
758
|
+
|
|
759
|
+
// Cross-validate with skill-tree's own parser
|
|
760
|
+
const adapterSkill = await skillAdapter.getSkill('typescript-strict');
|
|
761
|
+
expect(adapterSkill).not.toBeNull();
|
|
762
|
+
|
|
763
|
+
// Frontmatter fields
|
|
764
|
+
expect(routeDetail.id).toBe(adapterSkill!.id);
|
|
765
|
+
expect(routeDetail.name).toBe(adapterSkill!.name);
|
|
766
|
+
expect(routeDetail.version).toBe(adapterSkill!.version);
|
|
767
|
+
expect(routeDetail.status).toBe(adapterSkill!.status);
|
|
768
|
+
expect(routeDetail.author).toBe(adapterSkill!.author);
|
|
769
|
+
|
|
770
|
+
// Section content should be present
|
|
771
|
+
expect(routeDetail.problem).not.toBeNull();
|
|
772
|
+
expect(routeDetail.problem).toContain('strict mode');
|
|
773
|
+
|
|
774
|
+
expect(routeDetail.solution).not.toBeNull();
|
|
775
|
+
expect(routeDetail.solution).toContain('strictNullChecks');
|
|
776
|
+
|
|
777
|
+
expect(routeDetail.verification).not.toBeNull();
|
|
778
|
+
expect(routeDetail.verification).toContain('npx tsc --noEmit');
|
|
779
|
+
|
|
780
|
+
expect(routeDetail.notes).not.toBeNull();
|
|
781
|
+
expect(routeDetail.notes).toContain('TypeScript version upgrades');
|
|
782
|
+
|
|
783
|
+
// Raw content should be present
|
|
784
|
+
expect(routeDetail.raw).toContain('---');
|
|
785
|
+
});
|
|
786
|
+
|
|
787
|
+
it('should return sections that match skill-tree parsed content', async () => {
|
|
788
|
+
for (const skillId of ['typescript-strict', 'api-design', 'git-workflow', 'jquery-dom']) {
|
|
789
|
+
const res = await app.inject({
|
|
790
|
+
method: 'GET',
|
|
791
|
+
url: `/api/v1/resources/${skillResource.id}/content/skills/${skillId}`,
|
|
792
|
+
headers: { Authorization: `Bearer ${testAgent.apiKey}` },
|
|
793
|
+
});
|
|
794
|
+
|
|
795
|
+
const routeDetail = JSON.parse(res.body);
|
|
796
|
+
const adapterSkill = await skillAdapter.getSkill(skillId);
|
|
797
|
+
expect(adapterSkill).not.toBeNull();
|
|
798
|
+
|
|
799
|
+
// Problem and solution are required in our test skills
|
|
800
|
+
if (adapterSkill!.problem) {
|
|
801
|
+
expect(routeDetail.problem).not.toBeNull();
|
|
802
|
+
// Both should contain the same core content
|
|
803
|
+
// (exact whitespace may differ between parsers)
|
|
804
|
+
expect(routeDetail.problem).toContain(adapterSkill!.problem.slice(0, 20));
|
|
805
|
+
}
|
|
806
|
+
|
|
807
|
+
if (adapterSkill!.solution) {
|
|
808
|
+
expect(routeDetail.solution).not.toBeNull();
|
|
809
|
+
expect(routeDetail.solution).toContain(adapterSkill!.solution.slice(0, 20));
|
|
810
|
+
}
|
|
811
|
+
|
|
812
|
+
// Notes match when present
|
|
813
|
+
if (adapterSkill!.notes) {
|
|
814
|
+
expect(routeDetail.notes).not.toBeNull();
|
|
815
|
+
expect(routeDetail.notes).toContain(adapterSkill!.notes.slice(0, 20));
|
|
816
|
+
} else {
|
|
817
|
+
expect(routeDetail.notes).toBeNull();
|
|
818
|
+
}
|
|
819
|
+
}
|
|
820
|
+
});
|
|
821
|
+
|
|
822
|
+
it('should handle skill with minimal sections', async () => {
|
|
823
|
+
const res = await app.inject({
|
|
824
|
+
method: 'GET',
|
|
825
|
+
url: `/api/v1/resources/${skillResource.id}/content/skills/api-design`,
|
|
826
|
+
headers: { Authorization: `Bearer ${testAgent.apiKey}` },
|
|
827
|
+
});
|
|
828
|
+
|
|
829
|
+
const body = JSON.parse(res.body);
|
|
830
|
+
expect(body.name).toBe('REST API Design Patterns');
|
|
831
|
+
expect(body.status).toBe('draft');
|
|
832
|
+
expect(body.problem).not.toBeNull();
|
|
833
|
+
expect(body.solution).not.toBeNull();
|
|
834
|
+
// No trigger conditions, examples, or notes sections in this skill
|
|
835
|
+
// With skill-tree adapter, empty sections return [] not null
|
|
836
|
+
expect(body.triggerConditions).toEqual([]);
|
|
837
|
+
expect(body.examples).toEqual([]);
|
|
838
|
+
});
|
|
839
|
+
|
|
840
|
+
it('should return 404 for non-existent skill', async () => {
|
|
841
|
+
const res = await app.inject({
|
|
842
|
+
method: 'GET',
|
|
843
|
+
url: `/api/v1/resources/${skillResource.id}/content/skills/nonexistent`,
|
|
844
|
+
headers: { Authorization: `Bearer ${testAgent.apiKey}` },
|
|
845
|
+
});
|
|
846
|
+
expect(res.statusCode).toBe(404);
|
|
847
|
+
});
|
|
848
|
+
|
|
849
|
+
it('should reject path traversal in skill ID', async () => {
|
|
850
|
+
for (const attempt of ['../etc', 'foo/bar', 'foo\\bar']) {
|
|
851
|
+
const res = await app.inject({
|
|
852
|
+
method: 'GET',
|
|
853
|
+
url: `/api/v1/resources/${skillResource.id}/content/skills/${encodeURIComponent(attempt)}`,
|
|
854
|
+
headers: { Authorization: `Bearer ${testAgent.apiKey}` },
|
|
855
|
+
});
|
|
856
|
+
expect(res.statusCode).toBe(400);
|
|
857
|
+
}
|
|
858
|
+
});
|
|
859
|
+
|
|
860
|
+
it('should return 400 for non-skill resource type', async () => {
|
|
861
|
+
const res = await app.inject({
|
|
862
|
+
method: 'GET',
|
|
863
|
+
url: `/api/v1/resources/${memoryResource.id}/content/skills/any`,
|
|
864
|
+
headers: { Authorization: `Bearer ${testAgent.apiKey}` },
|
|
865
|
+
});
|
|
866
|
+
expect(res.statusCode).toBe(400);
|
|
867
|
+
});
|
|
868
|
+
});
|
|
869
|
+
|
|
870
|
+
// ========================================================================
|
|
871
|
+
// Edge Cases
|
|
872
|
+
// ========================================================================
|
|
873
|
+
|
|
874
|
+
describe('Edge Cases', () => {
|
|
875
|
+
it('should handle empty memory directory', async () => {
|
|
876
|
+
const dir = mkTestDir(TEST_ROOT, 'empty-mem');
|
|
877
|
+
const r = resourcesDAL.createResource({
|
|
878
|
+
resource_type: 'memory_bank',
|
|
879
|
+
name: 'Empty',
|
|
880
|
+
git_remote_url: dir,
|
|
881
|
+
visibility: 'private',
|
|
882
|
+
owner_agent_id: testAgent.id,
|
|
883
|
+
});
|
|
884
|
+
|
|
885
|
+
const res = await app.inject({
|
|
886
|
+
method: 'GET',
|
|
887
|
+
url: `/api/v1/resources/${r.id}/content/files`,
|
|
888
|
+
headers: { Authorization: `Bearer ${testAgent.apiKey}` },
|
|
889
|
+
});
|
|
890
|
+
|
|
891
|
+
expect(res.statusCode).toBe(200);
|
|
892
|
+
expect(JSON.parse(res.body).files).toEqual([]);
|
|
893
|
+
});
|
|
894
|
+
|
|
895
|
+
it('should handle malformed frontmatter gracefully', async () => {
|
|
896
|
+
const dir = mkTestDir(TEST_ROOT, 'malformed');
|
|
897
|
+
// Content with no closing --- delimiter — minimem's parser treats this as no frontmatter
|
|
898
|
+
fs.writeFileSync(path.join(dir, 'MEMORY.md'), '---\ninvalid yaml here\n# Content\n');
|
|
899
|
+
|
|
900
|
+
const r = resourcesDAL.createResource({
|
|
901
|
+
resource_type: 'memory_bank',
|
|
902
|
+
name: 'Malformed',
|
|
903
|
+
git_remote_url: dir,
|
|
904
|
+
visibility: 'private',
|
|
905
|
+
owner_agent_id: testAgent.id,
|
|
906
|
+
});
|
|
907
|
+
|
|
908
|
+
const res = await app.inject({
|
|
909
|
+
method: 'GET',
|
|
910
|
+
url: `/api/v1/resources/${r.id}/content/file`,
|
|
911
|
+
query: { path: 'MEMORY.md' },
|
|
912
|
+
headers: { Authorization: `Bearer ${testAgent.apiKey}` },
|
|
913
|
+
});
|
|
914
|
+
|
|
915
|
+
expect(res.statusCode).toBe(200);
|
|
916
|
+
expect(JSON.parse(res.body).frontmatter).toBeNull();
|
|
917
|
+
});
|
|
918
|
+
|
|
919
|
+
it('should handle frontmatter-only file (empty body)', async () => {
|
|
920
|
+
const dir = mkTestDir(TEST_ROOT, 'fm-only');
|
|
921
|
+
// Use minimem serializer — body will be empty
|
|
922
|
+
const content = serializeFrontmatter({ tags: ['test'] });
|
|
923
|
+
fs.writeFileSync(path.join(dir, 'MEMORY.md'), content);
|
|
924
|
+
|
|
925
|
+
const r = resourcesDAL.createResource({
|
|
926
|
+
resource_type: 'memory_bank',
|
|
927
|
+
name: 'FM Only',
|
|
928
|
+
git_remote_url: dir,
|
|
929
|
+
visibility: 'private',
|
|
930
|
+
owner_agent_id: testAgent.id,
|
|
931
|
+
});
|
|
932
|
+
|
|
933
|
+
const res = await app.inject({
|
|
934
|
+
method: 'GET',
|
|
935
|
+
url: `/api/v1/resources/${r.id}/content/file`,
|
|
936
|
+
query: { path: 'MEMORY.md' },
|
|
937
|
+
headers: { Authorization: `Bearer ${testAgent.apiKey}` },
|
|
938
|
+
});
|
|
939
|
+
|
|
940
|
+
expect(res.statusCode).toBe(200);
|
|
941
|
+
const body = JSON.parse(res.body);
|
|
942
|
+
expect(body.frontmatter).not.toBeNull();
|
|
943
|
+
expect(body.frontmatter.tags).toEqual(['test']);
|
|
944
|
+
expect(body.body).toBe('');
|
|
945
|
+
});
|
|
946
|
+
|
|
947
|
+
it('should handle skill directory without SKILL.md', async () => {
|
|
948
|
+
const dir = mkTestDir(TEST_ROOT, 'no-skillmd');
|
|
949
|
+
const skillsDir = path.join(dir, '.skilltree', 'skills', 'broken');
|
|
950
|
+
fs.mkdirSync(skillsDir, { recursive: true });
|
|
951
|
+
fs.writeFileSync(path.join(skillsDir, 'README.md'), '# Not a skill');
|
|
952
|
+
|
|
953
|
+
const r = resourcesDAL.createResource({
|
|
954
|
+
resource_type: 'skill',
|
|
955
|
+
name: 'No SKILL.md',
|
|
956
|
+
git_remote_url: dir,
|
|
957
|
+
visibility: 'private',
|
|
958
|
+
owner_agent_id: testAgent.id,
|
|
959
|
+
});
|
|
960
|
+
|
|
961
|
+
const res = await app.inject({
|
|
962
|
+
method: 'GET',
|
|
963
|
+
url: `/api/v1/resources/${r.id}/content/skills`,
|
|
964
|
+
headers: { Authorization: `Bearer ${testAgent.apiKey}` },
|
|
965
|
+
});
|
|
966
|
+
|
|
967
|
+
expect(res.statusCode).toBe(200);
|
|
968
|
+
expect(JSON.parse(res.body).skills).toEqual([]);
|
|
969
|
+
});
|
|
970
|
+
|
|
971
|
+
it('should handle skill with no frontmatter', async () => {
|
|
972
|
+
const dir = mkTestDir(TEST_ROOT, 'no-fm-skill');
|
|
973
|
+
// Use canonical .skilltree/skills/ location (matches skill-tree discovery)
|
|
974
|
+
const sd = path.join(dir, '.skilltree', 'skills', 'raw');
|
|
975
|
+
fs.mkdirSync(sd, { recursive: true });
|
|
976
|
+
fs.writeFileSync(path.join(sd, 'SKILL.md'), '## Problem\n\nSome problem.\n\n## Solution\n\nSome solution.\n');
|
|
977
|
+
|
|
978
|
+
const r = resourcesDAL.createResource({
|
|
979
|
+
resource_type: 'skill',
|
|
980
|
+
name: 'No FM',
|
|
981
|
+
git_remote_url: dir,
|
|
982
|
+
visibility: 'private',
|
|
983
|
+
owner_agent_id: testAgent.id,
|
|
984
|
+
});
|
|
985
|
+
|
|
986
|
+
const listRes = await app.inject({
|
|
987
|
+
method: 'GET',
|
|
988
|
+
url: `/api/v1/resources/${r.id}/content/skills`,
|
|
989
|
+
headers: { Authorization: `Bearer ${testAgent.apiKey}` },
|
|
990
|
+
});
|
|
991
|
+
const skills = JSON.parse(listRes.body).skills;
|
|
992
|
+
expect(skills.length).toBe(1);
|
|
993
|
+
// skill-tree adapter falls back to skill ID when name is missing
|
|
994
|
+
expect(skills[0].name).toBe('raw');
|
|
995
|
+
expect(skills[0].tags).toEqual([]);
|
|
996
|
+
|
|
997
|
+
const detailRes = await app.inject({
|
|
998
|
+
method: 'GET',
|
|
999
|
+
url: `/api/v1/resources/${r.id}/content/skills/raw`,
|
|
1000
|
+
headers: { Authorization: `Bearer ${testAgent.apiKey}` },
|
|
1001
|
+
});
|
|
1002
|
+
const detail = JSON.parse(detailRes.body);
|
|
1003
|
+
expect(detail.problem).toContain('Some problem');
|
|
1004
|
+
expect(detail.solution).toContain('Some solution');
|
|
1005
|
+
});
|
|
1006
|
+
|
|
1007
|
+
it('should handle deleted filesystem path', async () => {
|
|
1008
|
+
const dir = mkTestDir(TEST_ROOT, 'deleted');
|
|
1009
|
+
fs.writeFileSync(path.join(dir, 'MEMORY.md'), '# Temp');
|
|
1010
|
+
|
|
1011
|
+
const r = resourcesDAL.createResource({
|
|
1012
|
+
resource_type: 'memory_bank',
|
|
1013
|
+
name: 'Deleted',
|
|
1014
|
+
git_remote_url: dir,
|
|
1015
|
+
visibility: 'private',
|
|
1016
|
+
owner_agent_id: testAgent.id,
|
|
1017
|
+
});
|
|
1018
|
+
|
|
1019
|
+
fs.rmSync(dir, { recursive: true, force: true });
|
|
1020
|
+
|
|
1021
|
+
const res = await app.inject({
|
|
1022
|
+
method: 'GET',
|
|
1023
|
+
url: `/api/v1/resources/${r.id}/content/files`,
|
|
1024
|
+
headers: { Authorization: `Bearer ${testAgent.apiKey}` },
|
|
1025
|
+
});
|
|
1026
|
+
expect(res.statusCode).toBe(404);
|
|
1027
|
+
});
|
|
1028
|
+
|
|
1029
|
+
it('should handle deeply nested memory files', async () => {
|
|
1030
|
+
const dir = mkTestDir(TEST_ROOT, 'nested');
|
|
1031
|
+
const deep = path.join(dir, 'memory', 'deep', 'nested');
|
|
1032
|
+
fs.mkdirSync(deep, { recursive: true });
|
|
1033
|
+
fs.writeFileSync(path.join(deep, 'note.md'), '# Deep Note\n\nVery deep.');
|
|
1034
|
+
|
|
1035
|
+
const r = resourcesDAL.createResource({
|
|
1036
|
+
resource_type: 'memory_bank',
|
|
1037
|
+
name: 'Nested',
|
|
1038
|
+
git_remote_url: dir,
|
|
1039
|
+
visibility: 'private',
|
|
1040
|
+
owner_agent_id: testAgent.id,
|
|
1041
|
+
});
|
|
1042
|
+
|
|
1043
|
+
const listRes = await app.inject({
|
|
1044
|
+
method: 'GET',
|
|
1045
|
+
url: `/api/v1/resources/${r.id}/content/files`,
|
|
1046
|
+
headers: { Authorization: `Bearer ${testAgent.apiKey}` },
|
|
1047
|
+
});
|
|
1048
|
+
const paths = JSON.parse(listRes.body).files.map((f: { path: string }) => f.path);
|
|
1049
|
+
expect(paths).toContain('memory/deep/nested/note.md');
|
|
1050
|
+
|
|
1051
|
+
const fileRes = await app.inject({
|
|
1052
|
+
method: 'GET',
|
|
1053
|
+
url: `/api/v1/resources/${r.id}/content/file`,
|
|
1054
|
+
query: { path: 'memory/deep/nested/note.md' },
|
|
1055
|
+
headers: { Authorization: `Bearer ${testAgent.apiKey}` },
|
|
1056
|
+
});
|
|
1057
|
+
expect(fileRes.statusCode).toBe(200);
|
|
1058
|
+
expect(JSON.parse(fileRes.body).body).toContain('Very deep');
|
|
1059
|
+
});
|
|
1060
|
+
});
|
|
1061
|
+
|
|
1062
|
+
// ========================================================================
|
|
1063
|
+
// Round-trip Fidelity — Data created by packages, read by routes
|
|
1064
|
+
// ========================================================================
|
|
1065
|
+
|
|
1066
|
+
describe('Round-trip Fidelity', () => {
|
|
1067
|
+
it('minimem: serializeFrontmatter → route parse → matches original fields', async () => {
|
|
1068
|
+
// We wrote the observation note using minimem's serializer (in beforeAll).
|
|
1069
|
+
// Read it via the route and verify each field matches the original MemoryFrontmatter.
|
|
1070
|
+
const res = await app.inject({
|
|
1071
|
+
method: 'GET',
|
|
1072
|
+
url: `/api/v1/resources/${memoryResource.id}/content/file`,
|
|
1073
|
+
query: { path: 'memory/prisma-migration.md' },
|
|
1074
|
+
headers: { Authorization: `Bearer ${testAgent.apiKey}` },
|
|
1075
|
+
});
|
|
1076
|
+
|
|
1077
|
+
const fm = JSON.parse(res.body).frontmatter;
|
|
1078
|
+
|
|
1079
|
+
expect(fm.id).toBe(OBSERVATION_FM.id);
|
|
1080
|
+
expect(fm.type).toBe(OBSERVATION_FM.type);
|
|
1081
|
+
expect(fm.domain).toEqual(OBSERVATION_FM.domain);
|
|
1082
|
+
expect(fm.entities).toEqual(OBSERVATION_FM.entities);
|
|
1083
|
+
expect(fm.confidence).toBe(OBSERVATION_FM.confidence);
|
|
1084
|
+
expect(fm.source.origin).toBe(OBSERVATION_FM.source!.origin);
|
|
1085
|
+
expect(fm.source.trajectories).toEqual(OBSERVATION_FM.source!.trajectories);
|
|
1086
|
+
expect(fm.source.agentId).toBe(OBSERVATION_FM.source!.agentId);
|
|
1087
|
+
expect(fm.tags).toEqual(OBSERVATION_FM.tags);
|
|
1088
|
+
expect(fm.supersedes).toBe(OBSERVATION_FM.supersedes);
|
|
1089
|
+
|
|
1090
|
+
// Links round-trip
|
|
1091
|
+
expect(fm.links.length).toBe(OBSERVATION_FM.links!.length);
|
|
1092
|
+
for (let i = 0; i < fm.links.length; i++) {
|
|
1093
|
+
expect(fm.links[i].target).toBe(OBSERVATION_FM.links![i].target);
|
|
1094
|
+
expect(fm.links[i].relation).toBe(OBSERVATION_FM.links![i].relation);
|
|
1095
|
+
expect(fm.links[i].layer).toBe(OBSERVATION_FM.links![i].layer);
|
|
1096
|
+
}
|
|
1097
|
+
});
|
|
1098
|
+
|
|
1099
|
+
it('skill-tree: saveSkill → route parse → matches original Skill object', async () => {
|
|
1100
|
+
// We wrote TS_SKILL using skill-tree's adapter (in beforeAll).
|
|
1101
|
+
// Read it via the route and verify key fields match the original Skill object.
|
|
1102
|
+
const res = await app.inject({
|
|
1103
|
+
method: 'GET',
|
|
1104
|
+
url: `/api/v1/resources/${skillResource.id}/content/skills/typescript-strict`,
|
|
1105
|
+
headers: { Authorization: `Bearer ${testAgent.apiKey}` },
|
|
1106
|
+
});
|
|
1107
|
+
|
|
1108
|
+
const detail = JSON.parse(res.body);
|
|
1109
|
+
|
|
1110
|
+
expect(detail.name).toBe(TS_SKILL.name);
|
|
1111
|
+
expect(detail.version).toBe(TS_SKILL.version);
|
|
1112
|
+
expect(detail.status).toBe(TS_SKILL.status);
|
|
1113
|
+
expect(detail.author).toBe(TS_SKILL.author);
|
|
1114
|
+
|
|
1115
|
+
// Route now uses skill-tree's adapter for parsing — fields match the Skill object
|
|
1116
|
+
expect(detail.problem).toContain(TS_SKILL.problem.slice(0, 30));
|
|
1117
|
+
expect(detail.solution).toContain(TS_SKILL.solution.slice(0, 30));
|
|
1118
|
+
expect(detail.verification).toContain(TS_SKILL.verification.slice(0, 30));
|
|
1119
|
+
expect(detail.notes).toContain(TS_SKILL.notes!.slice(0, 30));
|
|
1120
|
+
});
|
|
1121
|
+
|
|
1122
|
+
it('skill-tree: route list matches adapter list for all skills', async () => {
|
|
1123
|
+
const res = await app.inject({
|
|
1124
|
+
method: 'GET',
|
|
1125
|
+
url: `/api/v1/resources/${skillResource.id}/content/skills`,
|
|
1126
|
+
headers: { Authorization: `Bearer ${testAgent.apiKey}` },
|
|
1127
|
+
});
|
|
1128
|
+
const routeSkills = JSON.parse(res.body).skills;
|
|
1129
|
+
const adapterSkills = await skillAdapter.listSkills();
|
|
1130
|
+
|
|
1131
|
+
// Same IDs
|
|
1132
|
+
const routeIds = routeSkills.map((s: { id: string }) => s.id).sort();
|
|
1133
|
+
const adapterIds = adapterSkills.map(s => s.id).sort();
|
|
1134
|
+
expect(routeIds).toEqual(adapterIds);
|
|
1135
|
+
|
|
1136
|
+
// Each skill's core fields match
|
|
1137
|
+
for (const original of [TS_SKILL, API_SKILL, GIT_SKILL, DEPRECATED_SKILL]) {
|
|
1138
|
+
const fromRoute = routeSkills.find((s: { id: string }) => s.id === original.id);
|
|
1139
|
+
expect(fromRoute).toBeDefined();
|
|
1140
|
+
expect(fromRoute.name).toBe(original.name);
|
|
1141
|
+
expect(fromRoute.version).toBe(original.version);
|
|
1142
|
+
expect(fromRoute.status).toBe(original.status);
|
|
1143
|
+
}
|
|
1144
|
+
});
|
|
1145
|
+
});
|
|
1146
|
+
|
|
1147
|
+
// ========================================================================
|
|
1148
|
+
// Cognitive-Core Knowledge Structure
|
|
1149
|
+
// ========================================================================
|
|
1150
|
+
|
|
1151
|
+
describe('Cognitive-Core Knowledge Directory Structure', () => {
|
|
1152
|
+
let knowledgeResource: { id: string };
|
|
1153
|
+
let knowledgeDir: string;
|
|
1154
|
+
|
|
1155
|
+
// Fixture frontmatter for cognitive-core notes
|
|
1156
|
+
const OBS_1_FM: MemoryFrontmatter = {
|
|
1157
|
+
id: 'k-ts-strict-001',
|
|
1158
|
+
type: 'observation',
|
|
1159
|
+
domain: ['typescript', 'tooling'],
|
|
1160
|
+
entities: ['tsc', 'tsconfig'],
|
|
1161
|
+
confidence: 0.65,
|
|
1162
|
+
source: {
|
|
1163
|
+
origin: 'extracted',
|
|
1164
|
+
trajectories: ['traj-100'],
|
|
1165
|
+
agentId: 'atlas-v1',
|
|
1166
|
+
},
|
|
1167
|
+
links: [
|
|
1168
|
+
{ target: 'k-ts-strict-002', relation: 'related-to', layer: 'semantic' },
|
|
1169
|
+
{ target: 'typescript', relation: 'depends-on', layer: 'entity' },
|
|
1170
|
+
],
|
|
1171
|
+
created: '2025-06-01T10:00:00Z',
|
|
1172
|
+
updated: '2025-06-01T10:00:00Z',
|
|
1173
|
+
tags: ['error-pattern'],
|
|
1174
|
+
};
|
|
1175
|
+
|
|
1176
|
+
const OBS_2_FM: MemoryFrontmatter = {
|
|
1177
|
+
id: 'k-ts-strict-002',
|
|
1178
|
+
type: 'observation',
|
|
1179
|
+
domain: ['typescript'],
|
|
1180
|
+
entities: ['tsc'],
|
|
1181
|
+
confidence: 0.45,
|
|
1182
|
+
source: { origin: 'extracted', trajectories: ['traj-101'] },
|
|
1183
|
+
links: [
|
|
1184
|
+
{ target: 'k-ts-strict-001', relation: 'related-to', layer: 'semantic' },
|
|
1185
|
+
],
|
|
1186
|
+
created: '2025-06-02T10:00:00Z',
|
|
1187
|
+
tags: ['config'],
|
|
1188
|
+
};
|
|
1189
|
+
|
|
1190
|
+
const ENTITY_TS_FM: MemoryFrontmatter = {
|
|
1191
|
+
id: 'typescript',
|
|
1192
|
+
type: 'entity',
|
|
1193
|
+
domain: ['typescript', 'tooling'],
|
|
1194
|
+
entities: ['typescript'],
|
|
1195
|
+
confidence: 0.92,
|
|
1196
|
+
source: { origin: 'agent-authored', agentId: 'atlas-v1' },
|
|
1197
|
+
links: [],
|
|
1198
|
+
created: '2025-06-01T08:00:00Z',
|
|
1199
|
+
tags: ['language'],
|
|
1200
|
+
};
|
|
1201
|
+
|
|
1202
|
+
const DOMAIN_FM: MemoryFrontmatter = {
|
|
1203
|
+
id: 'domain-typescript',
|
|
1204
|
+
type: 'domain-summary',
|
|
1205
|
+
domain: ['typescript'],
|
|
1206
|
+
confidence: 1.0,
|
|
1207
|
+
source: { origin: 'agent-authored', agentId: 'atlas-v1' },
|
|
1208
|
+
created: '2025-06-01T12:00:00Z',
|
|
1209
|
+
tags: ['summary'],
|
|
1210
|
+
};
|
|
1211
|
+
|
|
1212
|
+
const STALE_OBS_FM: MemoryFrontmatter = {
|
|
1213
|
+
id: 'k-stale-001',
|
|
1214
|
+
type: 'observation',
|
|
1215
|
+
domain: ['database'],
|
|
1216
|
+
entities: ['mysql'],
|
|
1217
|
+
confidence: 0.15,
|
|
1218
|
+
source: { origin: 'extracted' },
|
|
1219
|
+
created: '2024-01-01T00:00:00Z',
|
|
1220
|
+
tags: ['stale'],
|
|
1221
|
+
};
|
|
1222
|
+
|
|
1223
|
+
beforeAll(async () => {
|
|
1224
|
+
// Create the cognitive-core directory structure:
|
|
1225
|
+
// memory/knowledge/observations/
|
|
1226
|
+
// memory/knowledge/entities/
|
|
1227
|
+
// memory/knowledge/domains/
|
|
1228
|
+
knowledgeDir = mkTestDir(TEST_ROOT, 'cognitive-core-bank');
|
|
1229
|
+
|
|
1230
|
+
const obsDir = path.join(knowledgeDir, 'memory', 'knowledge', 'observations');
|
|
1231
|
+
const entDir = path.join(knowledgeDir, 'memory', 'knowledge', 'entities');
|
|
1232
|
+
const domDir = path.join(knowledgeDir, 'memory', 'knowledge', 'domains');
|
|
1233
|
+
fs.mkdirSync(obsDir, { recursive: true });
|
|
1234
|
+
fs.mkdirSync(entDir, { recursive: true });
|
|
1235
|
+
fs.mkdirSync(domDir, { recursive: true });
|
|
1236
|
+
|
|
1237
|
+
// Write knowledge notes using minimem serializer
|
|
1238
|
+
fs.writeFileSync(
|
|
1239
|
+
path.join(obsDir, 'k-ts-strict-001.md'),
|
|
1240
|
+
buildMemoryFile(OBS_1_FM, '# Strict Mode Null Check Issue\n\nWhen strict mode is enabled, tsc requires explicit null checks.\n'),
|
|
1241
|
+
);
|
|
1242
|
+
|
|
1243
|
+
fs.writeFileSync(
|
|
1244
|
+
path.join(obsDir, 'k-ts-strict-002.md'),
|
|
1245
|
+
buildMemoryFile(OBS_2_FM, '# TSConfig Strict Flags\n\nEnable strictNullChecks and noImplicitAny separately.\n'),
|
|
1246
|
+
);
|
|
1247
|
+
|
|
1248
|
+
fs.writeFileSync(
|
|
1249
|
+
path.join(obsDir, 'k-stale-001.md'),
|
|
1250
|
+
buildMemoryFile(STALE_OBS_FM, '# MySQL Timeout Config\n\nOld observation about MySQL wait_timeout.\n'),
|
|
1251
|
+
);
|
|
1252
|
+
|
|
1253
|
+
fs.writeFileSync(
|
|
1254
|
+
path.join(entDir, 'typescript.md'),
|
|
1255
|
+
buildMemoryFile(ENTITY_TS_FM, '# TypeScript\n\nA strongly-typed superset of JavaScript.\n\n## Known Patterns\n\n- Use strict mode.\n'),
|
|
1256
|
+
);
|
|
1257
|
+
|
|
1258
|
+
fs.writeFileSync(
|
|
1259
|
+
path.join(domDir, 'typescript.md'),
|
|
1260
|
+
buildMemoryFile(DOMAIN_FM, '# TypeScript Domain Summary\n\n3 observations, 1 entity.\n'),
|
|
1261
|
+
);
|
|
1262
|
+
|
|
1263
|
+
// Also put a regular MEMORY.md at root
|
|
1264
|
+
fs.writeFileSync(path.join(knowledgeDir, 'MEMORY.md'), '# Project Memory\n\nNon-knowledge note.\n');
|
|
1265
|
+
|
|
1266
|
+
knowledgeResource = resourcesDAL.createResource({
|
|
1267
|
+
resource_type: 'memory_bank',
|
|
1268
|
+
name: 'Cognitive Core Bank',
|
|
1269
|
+
description: 'Memory bank with cognitive-core knowledge structure',
|
|
1270
|
+
git_remote_url: knowledgeDir,
|
|
1271
|
+
visibility: 'private',
|
|
1272
|
+
owner_agent_id: testAgent.id,
|
|
1273
|
+
});
|
|
1274
|
+
});
|
|
1275
|
+
|
|
1276
|
+
it('should discover all files in cognitive-core directory structure', async () => {
|
|
1277
|
+
const res = await app.inject({
|
|
1278
|
+
method: 'GET',
|
|
1279
|
+
url: `/api/v1/resources/${knowledgeResource.id}/content/files`,
|
|
1280
|
+
headers: { Authorization: `Bearer ${testAgent.apiKey}` },
|
|
1281
|
+
});
|
|
1282
|
+
|
|
1283
|
+
expect(res.statusCode).toBe(200);
|
|
1284
|
+
const paths = JSON.parse(res.body).files.map((f: { path: string }) => f.path);
|
|
1285
|
+
|
|
1286
|
+
expect(paths).toContain('MEMORY.md');
|
|
1287
|
+
expect(paths).toContain('memory/knowledge/observations/k-ts-strict-001.md');
|
|
1288
|
+
expect(paths).toContain('memory/knowledge/observations/k-ts-strict-002.md');
|
|
1289
|
+
expect(paths).toContain('memory/knowledge/observations/k-stale-001.md');
|
|
1290
|
+
expect(paths).toContain('memory/knowledge/entities/typescript.md');
|
|
1291
|
+
expect(paths).toContain('memory/knowledge/domains/typescript.md');
|
|
1292
|
+
});
|
|
1293
|
+
|
|
1294
|
+
it('should read deeply nested observation with full knowledge frontmatter', async () => {
|
|
1295
|
+
const res = await app.inject({
|
|
1296
|
+
method: 'GET',
|
|
1297
|
+
url: `/api/v1/resources/${knowledgeResource.id}/content/file`,
|
|
1298
|
+
query: { path: 'memory/knowledge/observations/k-ts-strict-001.md' },
|
|
1299
|
+
headers: { Authorization: `Bearer ${testAgent.apiKey}` },
|
|
1300
|
+
});
|
|
1301
|
+
|
|
1302
|
+
expect(res.statusCode).toBe(200);
|
|
1303
|
+
const body = JSON.parse(res.body);
|
|
1304
|
+
|
|
1305
|
+
// Full knowledge frontmatter preserved
|
|
1306
|
+
expect(body.frontmatter.id).toBe('k-ts-strict-001');
|
|
1307
|
+
expect(body.frontmatter.type).toBe('observation');
|
|
1308
|
+
expect(body.frontmatter.domain).toEqual(['typescript', 'tooling']);
|
|
1309
|
+
expect(body.frontmatter.entities).toEqual(['tsc', 'tsconfig']);
|
|
1310
|
+
expect(body.frontmatter.confidence).toBe(0.65);
|
|
1311
|
+
expect(body.frontmatter.source.origin).toBe('extracted');
|
|
1312
|
+
expect(body.frontmatter.source.trajectories).toEqual(['traj-100']);
|
|
1313
|
+
expect(body.frontmatter.source.agentId).toBe('atlas-v1');
|
|
1314
|
+
expect(body.frontmatter.links).toHaveLength(2);
|
|
1315
|
+
expect(body.frontmatter.links[0].target).toBe('k-ts-strict-002');
|
|
1316
|
+
expect(body.frontmatter.links[0].relation).toBe('related-to');
|
|
1317
|
+
expect(body.frontmatter.links[0].layer).toBe('semantic');
|
|
1318
|
+
expect(body.body).toContain('tsc requires explicit null checks');
|
|
1319
|
+
});
|
|
1320
|
+
|
|
1321
|
+
it('should read entity note from entities/ subdirectory', async () => {
|
|
1322
|
+
const res = await app.inject({
|
|
1323
|
+
method: 'GET',
|
|
1324
|
+
url: `/api/v1/resources/${knowledgeResource.id}/content/file`,
|
|
1325
|
+
query: { path: 'memory/knowledge/entities/typescript.md' },
|
|
1326
|
+
headers: { Authorization: `Bearer ${testAgent.apiKey}` },
|
|
1327
|
+
});
|
|
1328
|
+
|
|
1329
|
+
const body = JSON.parse(res.body);
|
|
1330
|
+
expect(body.frontmatter.id).toBe('typescript');
|
|
1331
|
+
expect(body.frontmatter.type).toBe('entity');
|
|
1332
|
+
expect(body.frontmatter.confidence).toBe(0.92);
|
|
1333
|
+
expect(body.body).toContain('strongly-typed superset');
|
|
1334
|
+
});
|
|
1335
|
+
|
|
1336
|
+
it('should read domain-summary from domains/ subdirectory', async () => {
|
|
1337
|
+
const res = await app.inject({
|
|
1338
|
+
method: 'GET',
|
|
1339
|
+
url: `/api/v1/resources/${knowledgeResource.id}/content/file`,
|
|
1340
|
+
query: { path: 'memory/knowledge/domains/typescript.md' },
|
|
1341
|
+
headers: { Authorization: `Bearer ${testAgent.apiKey}` },
|
|
1342
|
+
});
|
|
1343
|
+
|
|
1344
|
+
const body = JSON.parse(res.body);
|
|
1345
|
+
expect(body.frontmatter.id).toBe('domain-typescript');
|
|
1346
|
+
expect(body.frontmatter.type).toBe('domain-summary');
|
|
1347
|
+
expect(body.frontmatter.confidence).toBe(1.0);
|
|
1348
|
+
});
|
|
1349
|
+
|
|
1350
|
+
it('should search across knowledge notes in nested directories', async () => {
|
|
1351
|
+
const res = await app.inject({
|
|
1352
|
+
method: 'GET',
|
|
1353
|
+
url: `/api/v1/resources/${knowledgeResource.id}/content/search`,
|
|
1354
|
+
query: { q: 'strict' },
|
|
1355
|
+
headers: { Authorization: `Bearer ${testAgent.apiKey}` },
|
|
1356
|
+
});
|
|
1357
|
+
|
|
1358
|
+
const body = JSON.parse(res.body);
|
|
1359
|
+
const matchPaths = body.results.map((r: { path: string }) => r.path);
|
|
1360
|
+
expect(matchPaths).toContain('memory/knowledge/observations/k-ts-strict-001.md');
|
|
1361
|
+
});
|
|
1362
|
+
});
|
|
1363
|
+
|
|
1364
|
+
// ========================================================================
|
|
1365
|
+
// Knowledge Search Endpoint
|
|
1366
|
+
// ========================================================================
|
|
1367
|
+
|
|
1368
|
+
describe('GET /resources/:id/content/knowledge', () => {
|
|
1369
|
+
let knowledgeResource: { id: string };
|
|
1370
|
+
let knowledgeDir: string;
|
|
1371
|
+
|
|
1372
|
+
beforeAll(async () => {
|
|
1373
|
+
// Reuse a knowledge bank structure
|
|
1374
|
+
knowledgeDir = mkTestDir(TEST_ROOT, 'knowledge-search-bank');
|
|
1375
|
+
const obsDir = path.join(knowledgeDir, 'memory', 'knowledge', 'observations');
|
|
1376
|
+
const entDir = path.join(knowledgeDir, 'memory', 'knowledge', 'entities');
|
|
1377
|
+
fs.mkdirSync(obsDir, { recursive: true });
|
|
1378
|
+
fs.mkdirSync(entDir, { recursive: true });
|
|
1379
|
+
|
|
1380
|
+
// Observations
|
|
1381
|
+
fs.writeFileSync(
|
|
1382
|
+
path.join(obsDir, 'obs-db-001.md'),
|
|
1383
|
+
buildMemoryFile({
|
|
1384
|
+
id: 'k-db-001', type: 'observation',
|
|
1385
|
+
domain: ['database'], entities: ['prisma', 'postgres'],
|
|
1386
|
+
confidence: 0.8, source: { origin: 'extracted' },
|
|
1387
|
+
links: [{ target: 'k-db-002', relation: 'related-to' }],
|
|
1388
|
+
}, '# Prisma Migration Tip\n\nUse prisma migrate deploy in production.\n'),
|
|
1389
|
+
);
|
|
1390
|
+
|
|
1391
|
+
fs.writeFileSync(
|
|
1392
|
+
path.join(obsDir, 'obs-db-002.md'),
|
|
1393
|
+
buildMemoryFile({
|
|
1394
|
+
id: 'k-db-002', type: 'observation',
|
|
1395
|
+
domain: ['database'], entities: ['postgres'],
|
|
1396
|
+
confidence: 0.6, source: { origin: 'extracted' },
|
|
1397
|
+
links: [{ target: 'k-db-001', relation: 'related-to' }],
|
|
1398
|
+
}, '# Postgres Connection Pooling\n\nUse PgBouncer for connection pooling.\n'),
|
|
1399
|
+
);
|
|
1400
|
+
|
|
1401
|
+
fs.writeFileSync(
|
|
1402
|
+
path.join(obsDir, 'obs-ts-001.md'),
|
|
1403
|
+
buildMemoryFile({
|
|
1404
|
+
id: 'k-ts-001', type: 'observation',
|
|
1405
|
+
domain: ['typescript'], entities: ['tsc'],
|
|
1406
|
+
confidence: 0.9, source: { origin: 'extracted' },
|
|
1407
|
+
}, '# TS Strict Mode\n\nEnable strict mode in tsconfig.\n'),
|
|
1408
|
+
);
|
|
1409
|
+
|
|
1410
|
+
// Entity
|
|
1411
|
+
fs.writeFileSync(
|
|
1412
|
+
path.join(entDir, 'postgres.md'),
|
|
1413
|
+
buildMemoryFile({
|
|
1414
|
+
id: 'postgres-entity', type: 'entity',
|
|
1415
|
+
domain: ['database'], entities: ['postgres'],
|
|
1416
|
+
confidence: 0.95, source: { origin: 'agent-authored' },
|
|
1417
|
+
}, '# PostgreSQL\n\nA powerful relational database.\n'),
|
|
1418
|
+
);
|
|
1419
|
+
|
|
1420
|
+
// Non-knowledge file
|
|
1421
|
+
fs.writeFileSync(path.join(knowledgeDir, 'MEMORY.md'), '# Notes\n\nPlain memory note.\n');
|
|
1422
|
+
|
|
1423
|
+
knowledgeResource = resourcesDAL.createResource({
|
|
1424
|
+
resource_type: 'memory_bank',
|
|
1425
|
+
name: 'Knowledge Search Bank',
|
|
1426
|
+
git_remote_url: knowledgeDir,
|
|
1427
|
+
visibility: 'private',
|
|
1428
|
+
owner_agent_id: testAgent.id,
|
|
1429
|
+
});
|
|
1430
|
+
});
|
|
1431
|
+
|
|
1432
|
+
it('should return all knowledge notes without filters', async () => {
|
|
1433
|
+
const res = await app.inject({
|
|
1434
|
+
method: 'GET',
|
|
1435
|
+
url: `/api/v1/resources/${knowledgeResource.id}/content/knowledge`,
|
|
1436
|
+
headers: { Authorization: `Bearer ${testAgent.apiKey}` },
|
|
1437
|
+
});
|
|
1438
|
+
|
|
1439
|
+
expect(res.statusCode).toBe(200);
|
|
1440
|
+
const body = JSON.parse(res.body);
|
|
1441
|
+
// Should include all files (knowledge notes + MEMORY.md)
|
|
1442
|
+
expect(body.total).toBeGreaterThanOrEqual(5);
|
|
1443
|
+
});
|
|
1444
|
+
|
|
1445
|
+
it('should filter by knowledge type', async () => {
|
|
1446
|
+
const res = await app.inject({
|
|
1447
|
+
method: 'GET',
|
|
1448
|
+
url: `/api/v1/resources/${knowledgeResource.id}/content/knowledge`,
|
|
1449
|
+
query: { type: 'observation' },
|
|
1450
|
+
headers: { Authorization: `Bearer ${testAgent.apiKey}` },
|
|
1451
|
+
});
|
|
1452
|
+
|
|
1453
|
+
const body = JSON.parse(res.body);
|
|
1454
|
+
expect(body.total).toBe(3);
|
|
1455
|
+
for (const result of body.results) {
|
|
1456
|
+
expect(result.knowledge_type).toBe('observation');
|
|
1457
|
+
}
|
|
1458
|
+
});
|
|
1459
|
+
|
|
1460
|
+
it('should filter by entity type', async () => {
|
|
1461
|
+
const res = await app.inject({
|
|
1462
|
+
method: 'GET',
|
|
1463
|
+
url: `/api/v1/resources/${knowledgeResource.id}/content/knowledge`,
|
|
1464
|
+
query: { type: 'entity' },
|
|
1465
|
+
headers: { Authorization: `Bearer ${testAgent.apiKey}` },
|
|
1466
|
+
});
|
|
1467
|
+
|
|
1468
|
+
const body = JSON.parse(res.body);
|
|
1469
|
+
expect(body.total).toBe(1);
|
|
1470
|
+
expect(body.results[0].knowledge_type).toBe('entity');
|
|
1471
|
+
});
|
|
1472
|
+
|
|
1473
|
+
it('should filter by domain', async () => {
|
|
1474
|
+
const res = await app.inject({
|
|
1475
|
+
method: 'GET',
|
|
1476
|
+
url: `/api/v1/resources/${knowledgeResource.id}/content/knowledge`,
|
|
1477
|
+
query: { domain: 'typescript' },
|
|
1478
|
+
headers: { Authorization: `Bearer ${testAgent.apiKey}` },
|
|
1479
|
+
});
|
|
1480
|
+
|
|
1481
|
+
const body = JSON.parse(res.body);
|
|
1482
|
+
expect(body.total).toBe(1);
|
|
1483
|
+
expect(body.results[0].frontmatter.id).toBe('k-ts-001');
|
|
1484
|
+
});
|
|
1485
|
+
|
|
1486
|
+
it('should filter by entity', async () => {
|
|
1487
|
+
const res = await app.inject({
|
|
1488
|
+
method: 'GET',
|
|
1489
|
+
url: `/api/v1/resources/${knowledgeResource.id}/content/knowledge`,
|
|
1490
|
+
query: { entity: 'prisma' },
|
|
1491
|
+
headers: { Authorization: `Bearer ${testAgent.apiKey}` },
|
|
1492
|
+
});
|
|
1493
|
+
|
|
1494
|
+
const body = JSON.parse(res.body);
|
|
1495
|
+
expect(body.total).toBe(1);
|
|
1496
|
+
expect(body.results[0].frontmatter.id).toBe('k-db-001');
|
|
1497
|
+
});
|
|
1498
|
+
|
|
1499
|
+
it('should filter by minimum confidence', async () => {
|
|
1500
|
+
const res = await app.inject({
|
|
1501
|
+
method: 'GET',
|
|
1502
|
+
url: `/api/v1/resources/${knowledgeResource.id}/content/knowledge`,
|
|
1503
|
+
query: { min_confidence: '0.85' },
|
|
1504
|
+
headers: { Authorization: `Bearer ${testAgent.apiKey}` },
|
|
1505
|
+
});
|
|
1506
|
+
|
|
1507
|
+
const body = JSON.parse(res.body);
|
|
1508
|
+
// Should include obs-ts-001 (0.9) and postgres entity (0.95)
|
|
1509
|
+
expect(body.total).toBe(2);
|
|
1510
|
+
for (const result of body.results) {
|
|
1511
|
+
expect(result.frontmatter.confidence).toBeGreaterThanOrEqual(0.85);
|
|
1512
|
+
}
|
|
1513
|
+
});
|
|
1514
|
+
|
|
1515
|
+
it('should combine knowledge filters with text query', async () => {
|
|
1516
|
+
const res = await app.inject({
|
|
1517
|
+
method: 'GET',
|
|
1518
|
+
url: `/api/v1/resources/${knowledgeResource.id}/content/knowledge`,
|
|
1519
|
+
query: { domain: 'database', q: 'pooling' },
|
|
1520
|
+
headers: { Authorization: `Bearer ${testAgent.apiKey}` },
|
|
1521
|
+
});
|
|
1522
|
+
|
|
1523
|
+
const body = JSON.parse(res.body);
|
|
1524
|
+
expect(body.total).toBe(1);
|
|
1525
|
+
expect(body.results[0].frontmatter.id).toBe('k-db-002');
|
|
1526
|
+
});
|
|
1527
|
+
|
|
1528
|
+
it('should sort results by confidence descending', async () => {
|
|
1529
|
+
const res = await app.inject({
|
|
1530
|
+
method: 'GET',
|
|
1531
|
+
url: `/api/v1/resources/${knowledgeResource.id}/content/knowledge`,
|
|
1532
|
+
query: { domain: 'database' },
|
|
1533
|
+
headers: { Authorization: `Bearer ${testAgent.apiKey}` },
|
|
1534
|
+
});
|
|
1535
|
+
|
|
1536
|
+
const body = JSON.parse(res.body);
|
|
1537
|
+
expect(body.total).toBeGreaterThanOrEqual(2);
|
|
1538
|
+
// Check descending order
|
|
1539
|
+
for (let i = 1; i < body.results.length; i++) {
|
|
1540
|
+
const prevConf = body.results[i - 1].frontmatter?.confidence ?? -1;
|
|
1541
|
+
const currConf = body.results[i].frontmatter?.confidence ?? -1;
|
|
1542
|
+
expect(prevConf).toBeGreaterThanOrEqual(currConf);
|
|
1543
|
+
}
|
|
1544
|
+
});
|
|
1545
|
+
|
|
1546
|
+
it('should include frontmatter and snippet in results', async () => {
|
|
1547
|
+
const res = await app.inject({
|
|
1548
|
+
method: 'GET',
|
|
1549
|
+
url: `/api/v1/resources/${knowledgeResource.id}/content/knowledge`,
|
|
1550
|
+
query: { type: 'entity' },
|
|
1551
|
+
headers: { Authorization: `Bearer ${testAgent.apiKey}` },
|
|
1552
|
+
});
|
|
1553
|
+
|
|
1554
|
+
const body = JSON.parse(res.body);
|
|
1555
|
+
expect(body.results[0].frontmatter).not.toBeNull();
|
|
1556
|
+
expect(body.results[0].frontmatter.id).toBeDefined();
|
|
1557
|
+
expect(body.results[0].snippet.length).toBeGreaterThan(0);
|
|
1558
|
+
expect(body.results[0].path).toBeDefined();
|
|
1559
|
+
});
|
|
1560
|
+
|
|
1561
|
+
it('should return 400 for non-memory_bank resource', async () => {
|
|
1562
|
+
const res = await app.inject({
|
|
1563
|
+
method: 'GET',
|
|
1564
|
+
url: `/api/v1/resources/${skillResource.id}/content/knowledge`,
|
|
1565
|
+
headers: { Authorization: `Bearer ${testAgent.apiKey}` },
|
|
1566
|
+
});
|
|
1567
|
+
expect(res.statusCode).toBe(400);
|
|
1568
|
+
});
|
|
1569
|
+
});
|
|
1570
|
+
|
|
1571
|
+
// ========================================================================
|
|
1572
|
+
// Knowledge Graph Endpoint
|
|
1573
|
+
// ========================================================================
|
|
1574
|
+
|
|
1575
|
+
describe('GET /resources/:id/content/knowledge/graph', () => {
|
|
1576
|
+
let knowledgeResource: { id: string };
|
|
1577
|
+
let knowledgeDir: string;
|
|
1578
|
+
|
|
1579
|
+
beforeAll(async () => {
|
|
1580
|
+
knowledgeDir = mkTestDir(TEST_ROOT, 'knowledge-graph-bank');
|
|
1581
|
+
const obsDir = path.join(knowledgeDir, 'memory', 'knowledge', 'observations');
|
|
1582
|
+
const entDir = path.join(knowledgeDir, 'memory', 'knowledge', 'entities');
|
|
1583
|
+
fs.mkdirSync(obsDir, { recursive: true });
|
|
1584
|
+
fs.mkdirSync(entDir, { recursive: true });
|
|
1585
|
+
|
|
1586
|
+
// A -> B (related-to), A -> C (depends-on), B -> C (supports)
|
|
1587
|
+
fs.writeFileSync(
|
|
1588
|
+
path.join(obsDir, 'node-a.md'),
|
|
1589
|
+
buildMemoryFile({
|
|
1590
|
+
id: 'node-a', type: 'observation',
|
|
1591
|
+
domain: ['test'], confidence: 0.8,
|
|
1592
|
+
links: [
|
|
1593
|
+
{ target: 'node-b', relation: 'related-to', layer: 'semantic' },
|
|
1594
|
+
{ target: 'node-c', relation: 'depends-on', layer: 'causal' },
|
|
1595
|
+
],
|
|
1596
|
+
}, '# Node A\n\nRoot observation.\n'),
|
|
1597
|
+
);
|
|
1598
|
+
|
|
1599
|
+
fs.writeFileSync(
|
|
1600
|
+
path.join(obsDir, 'node-b.md'),
|
|
1601
|
+
buildMemoryFile({
|
|
1602
|
+
id: 'node-b', type: 'observation',
|
|
1603
|
+
domain: ['test'], confidence: 0.6,
|
|
1604
|
+
links: [
|
|
1605
|
+
{ target: 'node-c', relation: 'supports', layer: 'semantic' },
|
|
1606
|
+
],
|
|
1607
|
+
}, '# Node B\n\nRelated to A.\n'),
|
|
1608
|
+
);
|
|
1609
|
+
|
|
1610
|
+
fs.writeFileSync(
|
|
1611
|
+
path.join(entDir, 'node-c.md'),
|
|
1612
|
+
buildMemoryFile({
|
|
1613
|
+
id: 'node-c', type: 'entity',
|
|
1614
|
+
domain: ['test'], confidence: 0.9,
|
|
1615
|
+
links: [],
|
|
1616
|
+
}, '# Node C\n\nTarget entity.\n'),
|
|
1617
|
+
);
|
|
1618
|
+
|
|
1619
|
+
knowledgeResource = resourcesDAL.createResource({
|
|
1620
|
+
resource_type: 'memory_bank',
|
|
1621
|
+
name: 'Knowledge Graph Bank',
|
|
1622
|
+
git_remote_url: knowledgeDir,
|
|
1623
|
+
visibility: 'private',
|
|
1624
|
+
owner_agent_id: testAgent.id,
|
|
1625
|
+
});
|
|
1626
|
+
});
|
|
1627
|
+
|
|
1628
|
+
it('should traverse outgoing links from a node', async () => {
|
|
1629
|
+
const res = await app.inject({
|
|
1630
|
+
method: 'GET',
|
|
1631
|
+
url: `/api/v1/resources/${knowledgeResource.id}/content/knowledge/graph`,
|
|
1632
|
+
query: { note_id: 'node-a', direction: 'outgoing' },
|
|
1633
|
+
headers: { Authorization: `Bearer ${testAgent.apiKey}` },
|
|
1634
|
+
});
|
|
1635
|
+
|
|
1636
|
+
expect(res.statusCode).toBe(200);
|
|
1637
|
+
const body = JSON.parse(res.body);
|
|
1638
|
+
|
|
1639
|
+
expect(body.root).toBe('node-a');
|
|
1640
|
+
expect(body.edges.length).toBe(2);
|
|
1641
|
+
expect(body.edges.some((e: { to: string }) => e.to === 'node-b')).toBe(true);
|
|
1642
|
+
expect(body.edges.some((e: { to: string }) => e.to === 'node-c')).toBe(true);
|
|
1643
|
+
|
|
1644
|
+
// Nodes include root + targets
|
|
1645
|
+
const nodeIds = body.nodes.map((n: { id: string }) => n.id);
|
|
1646
|
+
expect(nodeIds).toContain('node-a');
|
|
1647
|
+
expect(nodeIds).toContain('node-b');
|
|
1648
|
+
expect(nodeIds).toContain('node-c');
|
|
1649
|
+
});
|
|
1650
|
+
|
|
1651
|
+
it('should traverse incoming links to a node', async () => {
|
|
1652
|
+
const res = await app.inject({
|
|
1653
|
+
method: 'GET',
|
|
1654
|
+
url: `/api/v1/resources/${knowledgeResource.id}/content/knowledge/graph`,
|
|
1655
|
+
query: { note_id: 'node-c', direction: 'incoming' },
|
|
1656
|
+
headers: { Authorization: `Bearer ${testAgent.apiKey}` },
|
|
1657
|
+
});
|
|
1658
|
+
|
|
1659
|
+
const body = JSON.parse(res.body);
|
|
1660
|
+
// node-c has incoming from node-a (depends-on) and node-b (supports)
|
|
1661
|
+
expect(body.edges.length).toBe(2);
|
|
1662
|
+
expect(body.edges.every((e: { to: string }) => e.to === 'node-c')).toBe(true);
|
|
1663
|
+
});
|
|
1664
|
+
|
|
1665
|
+
it('should filter edges by relation type', async () => {
|
|
1666
|
+
const res = await app.inject({
|
|
1667
|
+
method: 'GET',
|
|
1668
|
+
url: `/api/v1/resources/${knowledgeResource.id}/content/knowledge/graph`,
|
|
1669
|
+
query: { note_id: 'node-a', relation: 'depends-on' },
|
|
1670
|
+
headers: { Authorization: `Bearer ${testAgent.apiKey}` },
|
|
1671
|
+
});
|
|
1672
|
+
|
|
1673
|
+
const body = JSON.parse(res.body);
|
|
1674
|
+
expect(body.edges.length).toBe(1);
|
|
1675
|
+
expect(body.edges[0].to).toBe('node-c');
|
|
1676
|
+
expect(body.edges[0].relation).toBe('depends-on');
|
|
1677
|
+
});
|
|
1678
|
+
|
|
1679
|
+
it('should traverse multiple hops with depth parameter', async () => {
|
|
1680
|
+
const res = await app.inject({
|
|
1681
|
+
method: 'GET',
|
|
1682
|
+
url: `/api/v1/resources/${knowledgeResource.id}/content/knowledge/graph`,
|
|
1683
|
+
query: { note_id: 'node-a', depth: '2', direction: 'outgoing' },
|
|
1684
|
+
headers: { Authorization: `Bearer ${testAgent.apiKey}` },
|
|
1685
|
+
});
|
|
1686
|
+
|
|
1687
|
+
const body = JSON.parse(res.body);
|
|
1688
|
+
// Depth 1: A->B, A->C. Depth 2: B->C (already visited but edge still emitted)
|
|
1689
|
+
expect(body.edges.length).toBe(3);
|
|
1690
|
+
});
|
|
1691
|
+
|
|
1692
|
+
it('should include node metadata', async () => {
|
|
1693
|
+
const res = await app.inject({
|
|
1694
|
+
method: 'GET',
|
|
1695
|
+
url: `/api/v1/resources/${knowledgeResource.id}/content/knowledge/graph`,
|
|
1696
|
+
query: { note_id: 'node-a' },
|
|
1697
|
+
headers: { Authorization: `Bearer ${testAgent.apiKey}` },
|
|
1698
|
+
});
|
|
1699
|
+
|
|
1700
|
+
const body = JSON.parse(res.body);
|
|
1701
|
+
const nodeA = body.nodes.find((n: { id: string }) => n.id === 'node-a');
|
|
1702
|
+
expect(nodeA).toBeDefined();
|
|
1703
|
+
expect(nodeA.path).toContain('observations/node-a.md');
|
|
1704
|
+
expect(nodeA.type).toBe('observation');
|
|
1705
|
+
expect(nodeA.confidence).toBe(0.8);
|
|
1706
|
+
});
|
|
1707
|
+
|
|
1708
|
+
it('should require note_id parameter', async () => {
|
|
1709
|
+
const res = await app.inject({
|
|
1710
|
+
method: 'GET',
|
|
1711
|
+
url: `/api/v1/resources/${knowledgeResource.id}/content/knowledge/graph`,
|
|
1712
|
+
headers: { Authorization: `Bearer ${testAgent.apiKey}` },
|
|
1713
|
+
});
|
|
1714
|
+
expect(res.statusCode).toBe(400);
|
|
1715
|
+
});
|
|
1716
|
+
|
|
1717
|
+
it('should handle unknown note_id gracefully', async () => {
|
|
1718
|
+
const res = await app.inject({
|
|
1719
|
+
method: 'GET',
|
|
1720
|
+
url: `/api/v1/resources/${knowledgeResource.id}/content/knowledge/graph`,
|
|
1721
|
+
query: { note_id: 'nonexistent-node' },
|
|
1722
|
+
headers: { Authorization: `Bearer ${testAgent.apiKey}` },
|
|
1723
|
+
});
|
|
1724
|
+
|
|
1725
|
+
expect(res.statusCode).toBe(200);
|
|
1726
|
+
const body = JSON.parse(res.body);
|
|
1727
|
+
expect(body.edges).toEqual([]);
|
|
1728
|
+
expect(body.nodes.length).toBe(1); // Just the root (no file found)
|
|
1729
|
+
});
|
|
1730
|
+
|
|
1731
|
+
it('should return 400 for non-memory_bank resource', async () => {
|
|
1732
|
+
const res = await app.inject({
|
|
1733
|
+
method: 'GET',
|
|
1734
|
+
url: `/api/v1/resources/${skillResource.id}/content/knowledge/graph`,
|
|
1735
|
+
query: { note_id: 'any' },
|
|
1736
|
+
headers: { Authorization: `Bearer ${testAgent.apiKey}` },
|
|
1737
|
+
});
|
|
1738
|
+
expect(res.statusCode).toBe(400);
|
|
1739
|
+
});
|
|
1740
|
+
});
|
|
1741
|
+
});
|