@memorax/memorax-code 0.1.0
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/LICENSE +21 -0
- package/README.md +53 -0
- package/bin/memorax-cli.mjs +28 -0
- package/bin/memorax-code-backend.mjs +4 -0
- package/bin/memorax-code-claude.mjs +4 -0
- package/bin/memorax-code-codex.mjs +4 -0
- package/bin/memorax-code-npm-preinstall.mjs +55 -0
- package/bin/memorax-code-plugin-postinstall.mjs +1236 -0
- package/bin/memorax-code.mjs +204 -0
- package/docs/configuration.md +232 -0
- package/docs/troubleshooting.md +179 -0
- package/lib/client-hook-runtime.mjs +32 -0
- package/lib/memorax-code-adapter-common/src/backend-connection.d.mts +111 -0
- package/lib/memorax-code-adapter-common/src/backend-connection.mjs +304 -0
- package/lib/memorax-code-adapter-common/src/clients/claude-command.mjs +38 -0
- package/lib/memorax-code-adapter-common/src/clients/codex-command.mjs +41 -0
- package/lib/memorax-code-adapter-common/src/clients/codex-plugin-artifact.d.mts +3 -0
- package/lib/memorax-code-adapter-common/src/clients/codex-plugin-artifact.mjs +38 -0
- package/lib/memorax-code-adapter-common/src/config-utils.d.mts +27 -0
- package/lib/memorax-code-adapter-common/src/config-utils.mjs +391 -0
- package/lib/memorax-code-adapter-common/src/hooks/capture-cwd-hook.mjs +137 -0
- package/lib/memorax-code-adapter-common/src/hooks/client-hook-launcher.mjs +324 -0
- package/lib/memorax-code-adapter-common/src/hooks/ensure-backend-runner.mjs +142 -0
- package/lib/memorax-code-adapter-common/src/hooks/hook-runtime-generation.d.mts +38 -0
- package/lib/memorax-code-adapter-common/src/hooks/hook-runtime-generation.mjs +501 -0
- package/lib/memorax-code-adapter-common/src/hooks/memory-skill-reminder-hook.mjs +277 -0
- package/lib/memorax-code-adapter-common/src/memorax-code-config-file.d.mts +28 -0
- package/lib/memorax-code-adapter-common/src/memorax-code-config-file.mjs +296 -0
- package/lib/memorax-code-adapter-common/src/memorax-defaults.d.mts +10 -0
- package/lib/memorax-code-adapter-common/src/memorax-defaults.mjs +12 -0
- package/lib/memorax-code-adapter-common/src/repo-memory/repo-memory-job-context.mjs +28 -0
- package/lib/memorax-code-adapter-common/src/repo-memory/repo-memory-job-marker.mjs +252 -0
- package/lib/memorax-code-adapter-common/src/repo-memory/repo-memory-job-supervisor.mjs +559 -0
- package/lib/memorax-code-adapter-common/src/repo-memory/repo-memory-job-worker.mjs +411 -0
- package/lib/memorax-code-adapter-common/src/repo-memory/repo-memory-update-policy-evaluator.mjs +185 -0
- package/lib/memorax-code-adapter-common/src/repo-memory/repo-memory-update-policy.mjs +165 -0
- package/lib/memorax-code-adapter-common/src/repo-memory/repo-procedure-memory-context.mjs +181 -0
- package/lib/memorax-code-adapter-common/src/repo-memory/repo-user-profile-context.mjs +251 -0
- package/lib/memorax-code-adapter-common/src/runtime-record.d.mts +55 -0
- package/lib/memorax-code-adapter-common/src/runtime-record.mjs +152 -0
- package/lib/memorax-code-adapter-common/src/windows-cli-invocation.mjs +100 -0
- package/lib/memorax-code-backend/dist/active-client-selection.js +35 -0
- package/lib/memorax-code-backend/dist/adapter-lifecycle-participant.js +1 -0
- package/lib/memorax-code-backend/dist/automatic-memory-retrieval.js +113 -0
- package/lib/memorax-code-backend/dist/automatic-memory-writeback.js +297 -0
- package/lib/memorax-code-backend/dist/backend-env.js +13 -0
- package/lib/memorax-code-backend/dist/backend-lifecycle-lock.js +42 -0
- package/lib/memorax-code-backend/dist/backend-process.js +147 -0
- package/lib/memorax-code-backend/dist/backend-service-cleanup.js +18 -0
- package/lib/memorax-code-backend/dist/backend-service-record.js +206 -0
- package/lib/memorax-code-backend/dist/backend-service-result.js +37 -0
- package/lib/memorax-code-backend/dist/backend-service-token.js +11 -0
- package/lib/memorax-code-backend/dist/backend-shutdown-request.js +133 -0
- package/lib/memorax-code-backend/dist/backend-state.js +58 -0
- package/lib/memorax-code-backend/dist/backend-status.js +53 -0
- package/lib/memorax-code-backend/dist/backend-token-record.js +79 -0
- package/lib/memorax-code-backend/dist/claude-adapter-lifecycle.js +134 -0
- package/lib/memorax-code-backend/dist/claude-local-transcript.js +648 -0
- package/lib/memorax-code-backend/dist/claude-memory-hook-runtime.js +472 -0
- package/lib/memorax-code-backend/dist/claude-transcript-turn.js +876 -0
- package/lib/memorax-code-backend/dist/client-plugin-removal.js +67 -0
- package/lib/memorax-code-backend/dist/client-selection.js +36 -0
- package/lib/memorax-code-backend/dist/codex-adapter-lifecycle.js +131 -0
- package/lib/memorax-code-backend/dist/codex-effective-prompt.js +54 -0
- package/lib/memorax-code-backend/dist/codex-memory-hook-runtime.js +541 -0
- package/lib/memorax-code-backend/dist/codex-plugin-hooks.js +421 -0
- package/lib/memorax-code-backend/dist/codex-plugin-install.js +523 -0
- package/lib/memorax-code-backend/dist/codex-rollout-turn.js +402 -0
- package/lib/memorax-code-backend/dist/codex-session-turn-index.js +88 -0
- package/lib/memorax-code-backend/dist/codex-workspace-links.js +55 -0
- package/lib/memorax-code-backend/dist/debug-log.js +21 -0
- package/lib/memorax-code-backend/dist/entrypoint.js +14 -0
- package/lib/memorax-code-backend/dist/incremental-jsonl-projection.js +271 -0
- package/lib/memorax-code-backend/dist/install-watchdog.js +71 -0
- package/lib/memorax-code-backend/dist/jsonl-append.js +75 -0
- package/lib/memorax-code-backend/dist/memorax-adapter.js +451 -0
- package/lib/memorax-code-backend/dist/memorax-cli.js +14 -0
- package/lib/memorax-code-backend/dist/memorax-code-config.js +279 -0
- package/lib/memorax-code-backend/dist/memorax-code-lifecycle.js +523 -0
- package/lib/memorax-code-backend/dist/memorax-code.js +3 -0
- package/lib/memorax-code-backend/dist/memorax-config.js +283 -0
- package/lib/memorax-code-backend/dist/memorax-http.js +142 -0
- package/lib/memorax-code-backend/dist/memory-cli.js +345 -0
- package/lib/memorax-code-backend/dist/memory-hook-command.js +200 -0
- package/lib/memorax-code-backend/dist/memory-observability.js +1 -0
- package/lib/memorax-code-backend/dist/memory-project.js +89 -0
- package/lib/memorax-code-backend/dist/memory-reminder-trace-recorder.js +58 -0
- package/lib/memorax-code-backend/dist/memory-service.js +66 -0
- package/lib/memorax-code-backend/dist/memory-turn-coordinator.js +139 -0
- package/lib/memorax-code-backend/dist/memory-viewer-activity.js +113 -0
- package/lib/memorax-code-backend/dist/memory-viewer-data-projection-cache.js +69 -0
- package/lib/memorax-code-backend/dist/memory-viewer-event-identity.js +3 -0
- package/lib/memorax-code-backend/dist/memory-viewer-history-projection.js +79 -0
- package/lib/memorax-code-backend/dist/memory-viewer-logo.js +1 -0
- package/lib/memorax-code-backend/dist/memory-viewer-observability.js +8 -0
- package/lib/memorax-code-backend/dist/memory-viewer-redaction.js +52 -0
- package/lib/memorax-code-backend/dist/memory-viewer-session-title.js +93 -0
- package/lib/memorax-code-backend/dist/memory-viewer-store.js +964 -0
- package/lib/memorax-code-backend/dist/memory-viewer-turn-reference.js +12 -0
- package/lib/memorax-code-backend/dist/memory-viewer-user-html.js +115 -0
- package/lib/memorax-code-backend/dist/memory-viewer-user-projection.js +168 -0
- package/lib/memorax-code-backend/dist/memory-viewer-writeback-status.js +97 -0
- package/lib/memorax-code-backend/dist/memory-writeback-buffer.js +217 -0
- package/lib/memorax-code-backend/dist/memory-writeback-chunk.js +120 -0
- package/lib/memorax-code-backend/dist/memory-writeback-reconciler.js +244 -0
- package/lib/memorax-code-backend/dist/memory-writeback-task-projection.js +377 -0
- package/lib/memorax-code-backend/dist/proxy-env.js +54 -0
- package/lib/memorax-code-backend/dist/repo-memory-readiness.js +188 -0
- package/lib/memorax-code-backend/dist/repository-memory-context.js +134 -0
- package/lib/memorax-code-backend/dist/repository-memory-scope.js +490 -0
- package/lib/memorax-code-backend/dist/server-cli.js +787 -0
- package/lib/memorax-code-backend/dist/server-health.js +16 -0
- package/lib/memorax-code-backend/dist/server-http.js +110 -0
- package/lib/memorax-code-backend/dist/server-json.js +4 -0
- package/lib/memorax-code-backend/dist/server-memory-hook.js +32 -0
- package/lib/memorax-code-backend/dist/server-memory-viewer.js +135 -0
- package/lib/memorax-code-backend/dist/server-observability.js +102 -0
- package/lib/memorax-code-backend/dist/server.js +220 -0
- package/lib/memorax-code-backend/dist/service-entrypoint.js +10 -0
- package/lib/memorax-code-backend/dist/service.js +567 -0
- package/lib/memorax-code-backend/dist/trace-config.js +112 -0
- package/lib/memorax-code-backend/dist/trace-context.js +111 -0
- package/lib/memorax-code-backend/dist/trace-store.js +571 -0
- package/lib/memorax-code-backend/dist/utils.js +3 -0
- package/lib/memorax-code-backend/dist/windows-cli-invocation.js +148 -0
- package/lib/memorax-code-backend/package.json +26 -0
- package/lib/memorax-code-claude-adapter/.claude-plugin/plugin.json +15 -0
- package/lib/memorax-code-claude-adapter/hooks/hook-launcher.mjs +27 -0
- package/lib/memorax-code-claude-adapter/hooks/hooks.json +66 -0
- package/lib/memorax-code-claude-adapter/hooks/repo-memory-job.mjs +37 -0
- package/lib/memorax-code-claude-adapter/hooks/runtime-hook.mjs +4 -0
- package/lib/memorax-code-claude-adapter/hooks/runtime-shell.json +5 -0
- package/lib/memorax-code-claude-adapter/package.json +13 -0
- package/lib/memorax-code-claude-adapter/runtime-hooks/capture-cwd.mjs +17 -0
- package/lib/memorax-code-claude-adapter/runtime-hooks/ensure-backend.mjs +59 -0
- package/lib/memorax-code-claude-adapter/runtime-hooks/memory-cli-session.mjs +33 -0
- package/lib/memorax-code-claude-adapter/runtime-hooks/memory-skill-reminder.mjs +73 -0
- package/lib/memorax-code-claude-adapter/runtime-hooks/memory-turn.mjs +91 -0
- package/lib/memorax-code-claude-adapter/scripts/build-marketplace.mjs +99 -0
- package/lib/memorax-code-claude-adapter/skills/memorax-code/SKILL.md +83 -0
- package/lib/memorax-code-claude-adapter/skills/memorax-code/agents/claude.yaml +10 -0
- package/lib/memorax-code-claude-adapter/skills/memorax-code/agents/openai.yaml +7 -0
- package/lib/memorax-code-claude-adapter/skills/memorax-code/defaults.json +9 -0
- package/lib/memorax-code-claude-adapter/skills/memorax-code/references/memorax-add.md +82 -0
- package/lib/memorax-code-claude-adapter/skills/memorax-code/references/memorax-search.md +61 -0
- package/lib/memorax-code-claude-adapter/skills/memorax-code/references/personal-read.md +46 -0
- package/lib/memorax-code-claude-adapter/skills/memorax-code/references/personal-write.md +100 -0
- package/lib/memorax-code-claude-adapter/skills/memorax-code/references/repo-build.md +270 -0
- package/lib/memorax-code-claude-adapter/skills/memorax-code/references/repo-read.md +96 -0
- package/lib/memorax-code-claude-adapter/skills/memorax-code/references/repo-templates.md +270 -0
- package/lib/memorax-code-claude-adapter/skills/memorax-code/references/repo-update.md +116 -0
- package/lib/memorax-code-claude-adapter/skills/memorax-code/scripts/collect_all.py +496 -0
- package/lib/memorax-code-claude-adapter/skills/memorax-code/scripts/detect_updates.py +856 -0
- package/lib/memorax-code-claude-adapter/skills/memorax-code/scripts/git_commit_facets.py +222 -0
- package/lib/memorax-code-claude-adapter/skills/memorax-code/scripts/github_resource_facets.py +504 -0
- package/lib/memorax-code-claude-adapter/skills/memorax-code/scripts/gitlab_resource_facets.py +509 -0
- package/lib/memorax-code-claude-adapter/skills/memorax-code/scripts/prepare_repo_memory.py +411 -0
- package/lib/memorax-code-claude-adapter/skills/memorax-code/scripts/user_profile_memory.py +528 -0
- package/lib/memorax-code-claude-adapter/skills/memorax-code/scripts/validate_memory.py +226 -0
- package/lib/memorax-code-claude-adapter/src/adapter-paths.mjs +46 -0
- package/lib/memorax-code-claude-adapter/src/cli.mjs +363 -0
- package/lib/memorax-code-claude-adapter/src/config-utils.mjs +1 -0
- package/lib/memorax-code-claude-adapter/src/config.mjs +544 -0
- package/lib/memorax-code-claude-adapter/src/plugin-artifact-contract.mjs +148 -0
- package/lib/memorax-code-claude-adapter/src/plugin-install.mjs +566 -0
- package/lib/memorax-code-claude-marketplace/.claude-plugin/marketplace.json +15 -0
- package/lib/memorax-code-claude-marketplace/plugins/memorax-code-claude-adapter/.claude-plugin/plugin.json +15 -0
- package/lib/memorax-code-claude-marketplace/plugins/memorax-code-claude-adapter/hooks/hook-launcher.mjs +27 -0
- package/lib/memorax-code-claude-marketplace/plugins/memorax-code-claude-adapter/hooks/hooks.json +66 -0
- package/lib/memorax-code-claude-marketplace/plugins/memorax-code-claude-adapter/hooks/repo-memory-job.mjs +37 -0
- package/lib/memorax-code-claude-marketplace/plugins/memorax-code-claude-adapter/hooks/runtime-hook.mjs +4 -0
- package/lib/memorax-code-claude-marketplace/plugins/memorax-code-claude-adapter/hooks/runtime-shell.json +5 -0
- package/lib/memorax-code-claude-marketplace/plugins/memorax-code-claude-adapter/memorax-code-adapter-common/src/backend-connection.d.mts +111 -0
- package/lib/memorax-code-claude-marketplace/plugins/memorax-code-claude-adapter/memorax-code-adapter-common/src/backend-connection.mjs +304 -0
- package/lib/memorax-code-claude-marketplace/plugins/memorax-code-claude-adapter/memorax-code-adapter-common/src/clients/claude-command.mjs +38 -0
- package/lib/memorax-code-claude-marketplace/plugins/memorax-code-claude-adapter/memorax-code-adapter-common/src/clients/codex-command.mjs +41 -0
- package/lib/memorax-code-claude-marketplace/plugins/memorax-code-claude-adapter/memorax-code-adapter-common/src/clients/codex-plugin-artifact.d.mts +3 -0
- package/lib/memorax-code-claude-marketplace/plugins/memorax-code-claude-adapter/memorax-code-adapter-common/src/clients/codex-plugin-artifact.mjs +38 -0
- package/lib/memorax-code-claude-marketplace/plugins/memorax-code-claude-adapter/memorax-code-adapter-common/src/config-utils.d.mts +27 -0
- package/lib/memorax-code-claude-marketplace/plugins/memorax-code-claude-adapter/memorax-code-adapter-common/src/config-utils.mjs +391 -0
- package/lib/memorax-code-claude-marketplace/plugins/memorax-code-claude-adapter/memorax-code-adapter-common/src/hooks/capture-cwd-hook.mjs +137 -0
- package/lib/memorax-code-claude-marketplace/plugins/memorax-code-claude-adapter/memorax-code-adapter-common/src/hooks/client-hook-launcher.mjs +324 -0
- package/lib/memorax-code-claude-marketplace/plugins/memorax-code-claude-adapter/memorax-code-adapter-common/src/hooks/ensure-backend-runner.mjs +142 -0
- package/lib/memorax-code-claude-marketplace/plugins/memorax-code-claude-adapter/memorax-code-adapter-common/src/hooks/hook-runtime-generation.d.mts +38 -0
- package/lib/memorax-code-claude-marketplace/plugins/memorax-code-claude-adapter/memorax-code-adapter-common/src/hooks/hook-runtime-generation.mjs +501 -0
- package/lib/memorax-code-claude-marketplace/plugins/memorax-code-claude-adapter/memorax-code-adapter-common/src/hooks/memory-skill-reminder-hook.mjs +277 -0
- package/lib/memorax-code-claude-marketplace/plugins/memorax-code-claude-adapter/memorax-code-adapter-common/src/memorax-code-config-file.d.mts +28 -0
- package/lib/memorax-code-claude-marketplace/plugins/memorax-code-claude-adapter/memorax-code-adapter-common/src/memorax-code-config-file.mjs +296 -0
- package/lib/memorax-code-claude-marketplace/plugins/memorax-code-claude-adapter/memorax-code-adapter-common/src/memorax-defaults.d.mts +10 -0
- package/lib/memorax-code-claude-marketplace/plugins/memorax-code-claude-adapter/memorax-code-adapter-common/src/memorax-defaults.mjs +12 -0
- package/lib/memorax-code-claude-marketplace/plugins/memorax-code-claude-adapter/memorax-code-adapter-common/src/repo-memory/repo-memory-job-context.mjs +28 -0
- package/lib/memorax-code-claude-marketplace/plugins/memorax-code-claude-adapter/memorax-code-adapter-common/src/repo-memory/repo-memory-job-marker.mjs +252 -0
- package/lib/memorax-code-claude-marketplace/plugins/memorax-code-claude-adapter/memorax-code-adapter-common/src/repo-memory/repo-memory-job-supervisor.mjs +559 -0
- package/lib/memorax-code-claude-marketplace/plugins/memorax-code-claude-adapter/memorax-code-adapter-common/src/repo-memory/repo-memory-job-worker.mjs +411 -0
- package/lib/memorax-code-claude-marketplace/plugins/memorax-code-claude-adapter/memorax-code-adapter-common/src/repo-memory/repo-memory-update-policy-evaluator.mjs +185 -0
- package/lib/memorax-code-claude-marketplace/plugins/memorax-code-claude-adapter/memorax-code-adapter-common/src/repo-memory/repo-memory-update-policy.mjs +165 -0
- package/lib/memorax-code-claude-marketplace/plugins/memorax-code-claude-adapter/memorax-code-adapter-common/src/repo-memory/repo-procedure-memory-context.mjs +181 -0
- package/lib/memorax-code-claude-marketplace/plugins/memorax-code-claude-adapter/memorax-code-adapter-common/src/repo-memory/repo-user-profile-context.mjs +251 -0
- package/lib/memorax-code-claude-marketplace/plugins/memorax-code-claude-adapter/memorax-code-adapter-common/src/runtime-record.d.mts +55 -0
- package/lib/memorax-code-claude-marketplace/plugins/memorax-code-claude-adapter/memorax-code-adapter-common/src/runtime-record.mjs +152 -0
- package/lib/memorax-code-claude-marketplace/plugins/memorax-code-claude-adapter/memorax-code-adapter-common/src/windows-cli-invocation.mjs +100 -0
- package/lib/memorax-code-claude-marketplace/plugins/memorax-code-claude-adapter/package.json +13 -0
- package/lib/memorax-code-claude-marketplace/plugins/memorax-code-claude-adapter/runtime-hooks/capture-cwd.mjs +17 -0
- package/lib/memorax-code-claude-marketplace/plugins/memorax-code-claude-adapter/runtime-hooks/ensure-backend.mjs +59 -0
- package/lib/memorax-code-claude-marketplace/plugins/memorax-code-claude-adapter/runtime-hooks/memory-cli-session.mjs +33 -0
- package/lib/memorax-code-claude-marketplace/plugins/memorax-code-claude-adapter/runtime-hooks/memory-skill-reminder.mjs +73 -0
- package/lib/memorax-code-claude-marketplace/plugins/memorax-code-claude-adapter/runtime-hooks/memory-turn.mjs +91 -0
- package/lib/memorax-code-claude-marketplace/plugins/memorax-code-claude-adapter/scripts/build-marketplace.mjs +99 -0
- package/lib/memorax-code-claude-marketplace/plugins/memorax-code-claude-adapter/skills/memorax-code/SKILL.md +83 -0
- package/lib/memorax-code-claude-marketplace/plugins/memorax-code-claude-adapter/skills/memorax-code/agents/claude.yaml +10 -0
- package/lib/memorax-code-claude-marketplace/plugins/memorax-code-claude-adapter/skills/memorax-code/agents/openai.yaml +7 -0
- package/lib/memorax-code-claude-marketplace/plugins/memorax-code-claude-adapter/skills/memorax-code/defaults.json +9 -0
- package/lib/memorax-code-claude-marketplace/plugins/memorax-code-claude-adapter/skills/memorax-code/references/memorax-add.md +82 -0
- package/lib/memorax-code-claude-marketplace/plugins/memorax-code-claude-adapter/skills/memorax-code/references/memorax-search.md +61 -0
- package/lib/memorax-code-claude-marketplace/plugins/memorax-code-claude-adapter/skills/memorax-code/references/personal-read.md +46 -0
- package/lib/memorax-code-claude-marketplace/plugins/memorax-code-claude-adapter/skills/memorax-code/references/personal-write.md +100 -0
- package/lib/memorax-code-claude-marketplace/plugins/memorax-code-claude-adapter/skills/memorax-code/references/repo-build.md +270 -0
- package/lib/memorax-code-claude-marketplace/plugins/memorax-code-claude-adapter/skills/memorax-code/references/repo-read.md +96 -0
- package/lib/memorax-code-claude-marketplace/plugins/memorax-code-claude-adapter/skills/memorax-code/references/repo-templates.md +270 -0
- package/lib/memorax-code-claude-marketplace/plugins/memorax-code-claude-adapter/skills/memorax-code/references/repo-update.md +116 -0
- package/lib/memorax-code-claude-marketplace/plugins/memorax-code-claude-adapter/skills/memorax-code/scripts/collect_all.py +496 -0
- package/lib/memorax-code-claude-marketplace/plugins/memorax-code-claude-adapter/skills/memorax-code/scripts/detect_updates.py +856 -0
- package/lib/memorax-code-claude-marketplace/plugins/memorax-code-claude-adapter/skills/memorax-code/scripts/git_commit_facets.py +222 -0
- package/lib/memorax-code-claude-marketplace/plugins/memorax-code-claude-adapter/skills/memorax-code/scripts/github_resource_facets.py +504 -0
- package/lib/memorax-code-claude-marketplace/plugins/memorax-code-claude-adapter/skills/memorax-code/scripts/gitlab_resource_facets.py +509 -0
- package/lib/memorax-code-claude-marketplace/plugins/memorax-code-claude-adapter/skills/memorax-code/scripts/prepare_repo_memory.py +411 -0
- package/lib/memorax-code-claude-marketplace/plugins/memorax-code-claude-adapter/skills/memorax-code/scripts/user_profile_memory.py +528 -0
- package/lib/memorax-code-claude-marketplace/plugins/memorax-code-claude-adapter/skills/memorax-code/scripts/validate_memory.py +226 -0
- package/lib/memorax-code-claude-marketplace/plugins/memorax-code-claude-adapter/src/adapter-paths.mjs +46 -0
- package/lib/memorax-code-claude-marketplace/plugins/memorax-code-claude-adapter/src/cli.mjs +363 -0
- package/lib/memorax-code-claude-marketplace/plugins/memorax-code-claude-adapter/src/config-utils.mjs +1 -0
- package/lib/memorax-code-claude-marketplace/plugins/memorax-code-claude-adapter/src/config.mjs +544 -0
- package/lib/memorax-code-claude-marketplace/plugins/memorax-code-claude-adapter/src/plugin-artifact-contract.mjs +148 -0
- package/lib/memorax-code-claude-marketplace/plugins/memorax-code-claude-adapter/src/plugin-install.mjs +566 -0
- package/lib/memorax-code-codex-adapter/.codex-plugin/plugin.json +33 -0
- package/lib/memorax-code-codex-adapter/assets/composer-icon.png +0 -0
- package/lib/memorax-code-codex-adapter/assets/logo.png +0 -0
- package/lib/memorax-code-codex-adapter/hooks/hook-launcher.mjs +26 -0
- package/lib/memorax-code-codex-adapter/hooks/hooks.json +61 -0
- package/lib/memorax-code-codex-adapter/hooks/repo-memory-job.mjs +38 -0
- package/lib/memorax-code-codex-adapter/hooks/repo-memory-update-policy.mjs +10 -0
- package/lib/memorax-code-codex-adapter/hooks/runtime-hook.mjs +4 -0
- package/lib/memorax-code-codex-adapter/hooks/runtime-shell.json +5 -0
- package/lib/memorax-code-codex-adapter/package.json +13 -0
- package/lib/memorax-code-codex-adapter/runtime-hooks/capture-cwd.mjs +18 -0
- package/lib/memorax-code-codex-adapter/runtime-hooks/ensure-backend.mjs +82 -0
- package/lib/memorax-code-codex-adapter/runtime-hooks/memory-skill-reminder.mjs +125 -0
- package/lib/memorax-code-codex-adapter/runtime-hooks/memory-writeback.mjs +52 -0
- package/lib/memorax-code-codex-adapter/skills/memorax-code/SKILL.md +83 -0
- package/lib/memorax-code-codex-adapter/skills/memorax-code/agents/claude.yaml +10 -0
- package/lib/memorax-code-codex-adapter/skills/memorax-code/agents/openai.yaml +7 -0
- package/lib/memorax-code-codex-adapter/skills/memorax-code/defaults.json +9 -0
- package/lib/memorax-code-codex-adapter/skills/memorax-code/references/memorax-add.md +82 -0
- package/lib/memorax-code-codex-adapter/skills/memorax-code/references/memorax-search.md +61 -0
- package/lib/memorax-code-codex-adapter/skills/memorax-code/references/personal-read.md +46 -0
- package/lib/memorax-code-codex-adapter/skills/memorax-code/references/personal-write.md +100 -0
- package/lib/memorax-code-codex-adapter/skills/memorax-code/references/repo-build.md +270 -0
- package/lib/memorax-code-codex-adapter/skills/memorax-code/references/repo-read.md +96 -0
- package/lib/memorax-code-codex-adapter/skills/memorax-code/references/repo-templates.md +270 -0
- package/lib/memorax-code-codex-adapter/skills/memorax-code/references/repo-update.md +116 -0
- package/lib/memorax-code-codex-adapter/skills/memorax-code/scripts/collect_all.py +496 -0
- package/lib/memorax-code-codex-adapter/skills/memorax-code/scripts/detect_updates.py +856 -0
- package/lib/memorax-code-codex-adapter/skills/memorax-code/scripts/git_commit_facets.py +222 -0
- package/lib/memorax-code-codex-adapter/skills/memorax-code/scripts/github_resource_facets.py +504 -0
- package/lib/memorax-code-codex-adapter/skills/memorax-code/scripts/gitlab_resource_facets.py +509 -0
- package/lib/memorax-code-codex-adapter/skills/memorax-code/scripts/prepare_repo_memory.py +411 -0
- package/lib/memorax-code-codex-adapter/skills/memorax-code/scripts/user_profile_memory.py +528 -0
- package/lib/memorax-code-codex-adapter/skills/memorax-code/scripts/validate_memory.py +226 -0
- package/lib/memorax-code-codex-adapter/src/adapter-paths.mjs +29 -0
- package/lib/memorax-code-codex-adapter/src/cli.mjs +368 -0
- package/lib/memorax-code-codex-adapter/src/config-utils.mjs +1 -0
- package/lib/memorax-code-codex-adapter/src/config.mjs +226 -0
- package/lib/memorax-code-codex-adapter/src/session-registry.mjs +331 -0
- package/lib/memorax-code-codex-adapter/src/workspace-kind.mjs +68 -0
- package/lib/node-version.mjs +11 -0
- package/lib/npm-invocation.mjs +31 -0
- package/lib/resolve-claude-command.mjs +47 -0
- package/lib/resolve-codex-command.mjs +94 -0
- package/lib/run-entrypoint.mjs +83 -0
- package/lib/vscode-extension-command.mjs +119 -0
- package/lib/windows-cli-invocation.mjs +100 -0
- package/package.json +45 -0
|
@@ -0,0 +1,226 @@
|
|
|
1
|
+
import { existsSync } from "node:fs";
|
|
2
|
+
import { join } from "node:path";
|
|
3
|
+
import { activeCodexPluginSkillsRoot } from "../../memorax-code-adapter-common/src/clients/codex-plugin-artifact.mjs";
|
|
4
|
+
import {
|
|
5
|
+
DEFAULT_BACKEND_URL,
|
|
6
|
+
adapterStatePath,
|
|
7
|
+
defaultCodexHome,
|
|
8
|
+
defaultMemoraxCodeHome,
|
|
9
|
+
normalizeBackendUrl,
|
|
10
|
+
} from "./adapter-paths.mjs";
|
|
11
|
+
export {
|
|
12
|
+
DEFAULT_BACKEND_URL,
|
|
13
|
+
DEFAULT_TOKEN_ENV,
|
|
14
|
+
adapterSessionRegistryPath,
|
|
15
|
+
adapterStatePath,
|
|
16
|
+
adapterWorkspaceStatePath,
|
|
17
|
+
defaultCodexHome,
|
|
18
|
+
defaultMemoraxCodeHome,
|
|
19
|
+
normalizeBackendUrl,
|
|
20
|
+
} from "./adapter-paths.mjs";
|
|
21
|
+
import { seedExistingCodexSessionsAsNative } from "./session-registry.mjs";
|
|
22
|
+
export {
|
|
23
|
+
inspectCodexHistory,
|
|
24
|
+
readCodexSessionRegistry,
|
|
25
|
+
readCodexWorkspaceStatus,
|
|
26
|
+
readMergedCodexSessions,
|
|
27
|
+
updateCodexSessionRegistry,
|
|
28
|
+
} from "./session-registry.mjs";
|
|
29
|
+
import { atomicWriteJson, readAdapterState, stringOption } from "./config-utils.mjs";
|
|
30
|
+
export { readAdapterState } from "./config-utils.mjs";
|
|
31
|
+
|
|
32
|
+
const CODEX_ADAPTER_STATE_VERSION = 1;
|
|
33
|
+
const CODEX_INTEGRATION = "hooks";
|
|
34
|
+
const CODEX_MEMORY_SKILL = "memorax-code";
|
|
35
|
+
|
|
36
|
+
export function enableCodexAdapter(options = {}) {
|
|
37
|
+
const codexHome = options.codexHome ?? defaultCodexHome();
|
|
38
|
+
const memoraxCodeHome = options.memoraxCodeHome ?? defaultMemoraxCodeHome();
|
|
39
|
+
const statePath = options.statePath ?? adapterStatePath(memoraxCodeHome, "codex");
|
|
40
|
+
const previousState = readAdapterState(statePath);
|
|
41
|
+
if (previousState?.unreadable) {
|
|
42
|
+
return { ok: false, action: "enable", reason: "state_unreadable", statePath };
|
|
43
|
+
}
|
|
44
|
+
if (previousState && previousState.version !== CODEX_ADAPTER_STATE_VERSION) {
|
|
45
|
+
return {
|
|
46
|
+
ok: false,
|
|
47
|
+
action: "enable",
|
|
48
|
+
reason: "state_version_unsupported",
|
|
49
|
+
statePath,
|
|
50
|
+
expectedVersion: CODEX_ADAPTER_STATE_VERSION,
|
|
51
|
+
actualVersion: previousState.version,
|
|
52
|
+
};
|
|
53
|
+
}
|
|
54
|
+
|
|
55
|
+
const nativeBaseline = seedExistingCodexSessionsAsNative({ ...options, codexHome, memoraxCodeHome, dryRun: true });
|
|
56
|
+
const codexPluginSkillsRoot = stringOption(options.codexPluginSkillsRoot);
|
|
57
|
+
const codexSkills = codexPluginSkillsSummary(codexHome, codexPluginSkillsRoot);
|
|
58
|
+
if (codexSkills.ok === false) {
|
|
59
|
+
return { ok: false, action: "enable", reason: "skill_delivery_failed", statePath, codexSkills };
|
|
60
|
+
}
|
|
61
|
+
const state = {
|
|
62
|
+
version: CODEX_ADAPTER_STATE_VERSION,
|
|
63
|
+
runtime: "codex",
|
|
64
|
+
integration: CODEX_INTEGRATION,
|
|
65
|
+
enabled: true,
|
|
66
|
+
enabledAt: previousState?.enabled === true && stringOption(previousState.enabledAt)
|
|
67
|
+
? previousState.enabledAt
|
|
68
|
+
: new Date().toISOString(),
|
|
69
|
+
codexHome,
|
|
70
|
+
backendUrl: normalizeBackendUrl(
|
|
71
|
+
options.backendUrl
|
|
72
|
+
?? previousState?.backendUrl
|
|
73
|
+
?? DEFAULT_BACKEND_URL,
|
|
74
|
+
),
|
|
75
|
+
codexSkillDelivery: "plugin",
|
|
76
|
+
...(codexPluginSkillsRoot
|
|
77
|
+
? { codexPluginSkillsRoot }
|
|
78
|
+
: {}),
|
|
79
|
+
};
|
|
80
|
+
atomicWriteJson(statePath, state);
|
|
81
|
+
const seededNativeSessions = nativeBaseline.ok
|
|
82
|
+
? seedExistingCodexSessionsAsNative({ ...options, codexHome, memoraxCodeHome })
|
|
83
|
+
: { ...nativeBaseline, skipped: true };
|
|
84
|
+
return {
|
|
85
|
+
ok: true,
|
|
86
|
+
action: "enable",
|
|
87
|
+
codexHome,
|
|
88
|
+
memoraxCodeHome,
|
|
89
|
+
statePath,
|
|
90
|
+
state,
|
|
91
|
+
installed: true,
|
|
92
|
+
enabled: true,
|
|
93
|
+
integration: CODEX_INTEGRATION,
|
|
94
|
+
changed: previousState?.enabled !== true || previousState?.integration !== CODEX_INTEGRATION || codexSkills.counts?.changed > 0,
|
|
95
|
+
seededNativeSessions,
|
|
96
|
+
codexSkills,
|
|
97
|
+
};
|
|
98
|
+
}
|
|
99
|
+
|
|
100
|
+
export function disableCodexAdapter(options = {}) {
|
|
101
|
+
const codexHome = options.codexHome ?? defaultCodexHome();
|
|
102
|
+
const memoraxCodeHome = options.memoraxCodeHome ?? defaultMemoraxCodeHome();
|
|
103
|
+
const statePath = options.statePath ?? adapterStatePath(memoraxCodeHome, "codex");
|
|
104
|
+
const previousState = readAdapterState(statePath);
|
|
105
|
+
if (previousState?.unreadable) {
|
|
106
|
+
return { ok: false, action: "disable", reason: "state_unreadable", statePath };
|
|
107
|
+
}
|
|
108
|
+
if (previousState && previousState.version !== CODEX_ADAPTER_STATE_VERSION) {
|
|
109
|
+
return {
|
|
110
|
+
ok: false,
|
|
111
|
+
action: "disable",
|
|
112
|
+
reason: "state_version_unsupported",
|
|
113
|
+
statePath,
|
|
114
|
+
expectedVersion: CODEX_ADAPTER_STATE_VERSION,
|
|
115
|
+
actualVersion: previousState.version,
|
|
116
|
+
};
|
|
117
|
+
}
|
|
118
|
+
const codexSkills = codexPluginSkillsSummary(
|
|
119
|
+
codexHome,
|
|
120
|
+
stringOption(options.codexPluginSkillsRoot) ?? stringOption(previousState?.codexPluginSkillsRoot),
|
|
121
|
+
);
|
|
122
|
+
const state = {
|
|
123
|
+
version: CODEX_ADAPTER_STATE_VERSION,
|
|
124
|
+
runtime: "codex",
|
|
125
|
+
integration: CODEX_INTEGRATION,
|
|
126
|
+
enabled: false,
|
|
127
|
+
disabledAt: new Date().toISOString(),
|
|
128
|
+
codexHome,
|
|
129
|
+
backendUrl: normalizeBackendUrl(
|
|
130
|
+
options.backendUrl
|
|
131
|
+
?? previousState?.backendUrl
|
|
132
|
+
?? DEFAULT_BACKEND_URL,
|
|
133
|
+
),
|
|
134
|
+
};
|
|
135
|
+
atomicWriteJson(statePath, state);
|
|
136
|
+
return {
|
|
137
|
+
ok: true,
|
|
138
|
+
action: "disable",
|
|
139
|
+
codexHome,
|
|
140
|
+
memoraxCodeHome,
|
|
141
|
+
statePath,
|
|
142
|
+
state,
|
|
143
|
+
installed: false,
|
|
144
|
+
enabled: false,
|
|
145
|
+
integration: CODEX_INTEGRATION,
|
|
146
|
+
changed: previousState?.enabled === true,
|
|
147
|
+
codexSkills,
|
|
148
|
+
};
|
|
149
|
+
}
|
|
150
|
+
|
|
151
|
+
export function readCodexAdapterStatus(options = {}) {
|
|
152
|
+
const codexHome = options.codexHome ?? defaultCodexHome();
|
|
153
|
+
const memoraxCodeHome = options.memoraxCodeHome ?? defaultMemoraxCodeHome();
|
|
154
|
+
const statePath = options.statePath ?? adapterStatePath(memoraxCodeHome, "codex");
|
|
155
|
+
const state = readAdapterState(statePath);
|
|
156
|
+
const enabled = state?.unreadable !== true
|
|
157
|
+
&& state?.version === CODEX_ADAPTER_STATE_VERSION
|
|
158
|
+
&& state?.enabled === true
|
|
159
|
+
&& state?.integration === CODEX_INTEGRATION;
|
|
160
|
+
const configuredBackendUrl = stringOption(state?.backendUrl)
|
|
161
|
+
? normalizeBackendUrl(state.backendUrl)
|
|
162
|
+
: undefined;
|
|
163
|
+
const expectedBackendUrl = stringOption(options.backendUrl)
|
|
164
|
+
? normalizeBackendUrl(options.backendUrl)
|
|
165
|
+
: undefined;
|
|
166
|
+
return {
|
|
167
|
+
ok: true,
|
|
168
|
+
action: "status",
|
|
169
|
+
codexHome,
|
|
170
|
+
memoraxCodeHome,
|
|
171
|
+
statePath,
|
|
172
|
+
state,
|
|
173
|
+
installed: enabled,
|
|
174
|
+
enabled,
|
|
175
|
+
integration: CODEX_INTEGRATION,
|
|
176
|
+
memoryIntegration: CODEX_INTEGRATION,
|
|
177
|
+
configuredBackendUrl,
|
|
178
|
+
expectedBackendUrl,
|
|
179
|
+
backendUrlMatches: !expectedBackendUrl
|
|
180
|
+
|| configuredBackendUrl === expectedBackendUrl
|
|
181
|
+
|| (!configuredBackendUrl && !enabled),
|
|
182
|
+
codexSkills: codexPluginSkillsSummary(
|
|
183
|
+
codexHome,
|
|
184
|
+
stringOption(options.codexPluginSkillsRoot) ?? stringOption(state?.codexPluginSkillsRoot),
|
|
185
|
+
),
|
|
186
|
+
};
|
|
187
|
+
}
|
|
188
|
+
|
|
189
|
+
function codexPluginSkillsSummary(codexHome, explicitRootPath) {
|
|
190
|
+
const cacheRoot = codexPluginCacheRoot(codexHome);
|
|
191
|
+
const rootPath = explicitRootPath ?? activeCodexPluginSkillsRoot(codexHome) ?? cacheRoot;
|
|
192
|
+
const sourcePath = join(rootPath, CODEX_MEMORY_SKILL);
|
|
193
|
+
const ready = existsSync(join(sourcePath, "SKILL.md"));
|
|
194
|
+
const skills = [{
|
|
195
|
+
name: CODEX_MEMORY_SKILL,
|
|
196
|
+
sourcePath,
|
|
197
|
+
targetPath: "",
|
|
198
|
+
sourceKind: "plugin",
|
|
199
|
+
sourceExists: ready,
|
|
200
|
+
targetExists: false,
|
|
201
|
+
targetIsSymlink: false,
|
|
202
|
+
ok: ready,
|
|
203
|
+
status: ready ? "plugin-managed" : "missing",
|
|
204
|
+
}];
|
|
205
|
+
return {
|
|
206
|
+
ok: ready,
|
|
207
|
+
status: ready ? "plugin-managed" : "missing",
|
|
208
|
+
delivery: "plugin",
|
|
209
|
+
rootPath,
|
|
210
|
+
skills,
|
|
211
|
+
counts: {
|
|
212
|
+
total: 1,
|
|
213
|
+
linked: 0,
|
|
214
|
+
missing: ready ? 0 : 1,
|
|
215
|
+
conflict: 0,
|
|
216
|
+
sourceMissing: ready ? 0 : 1,
|
|
217
|
+
failed: 0,
|
|
218
|
+
changed: 0,
|
|
219
|
+
removed: 0,
|
|
220
|
+
},
|
|
221
|
+
};
|
|
222
|
+
}
|
|
223
|
+
|
|
224
|
+
function codexPluginCacheRoot(codexHome) {
|
|
225
|
+
return join(codexHome, "plugins", "cache", "memorax-code", "memorax-code-codex-adapter");
|
|
226
|
+
}
|
|
@@ -0,0 +1,331 @@
|
|
|
1
|
+
import { existsSync, lstatSync, readdirSync, statSync } from "node:fs";
|
|
2
|
+
import { basename, join, relative } from "node:path";
|
|
3
|
+
import {
|
|
4
|
+
adapterSessionRegistryPath,
|
|
5
|
+
adapterWorkspaceStatePath,
|
|
6
|
+
defaultCodexHome,
|
|
7
|
+
defaultMemoraxCodeHome,
|
|
8
|
+
} from "./adapter-paths.mjs";
|
|
9
|
+
import {
|
|
10
|
+
atomicWriteJson,
|
|
11
|
+
readAdapterState,
|
|
12
|
+
sha256,
|
|
13
|
+
stringOption,
|
|
14
|
+
withJsonFileLock,
|
|
15
|
+
} from "./config-utils.mjs";
|
|
16
|
+
|
|
17
|
+
export function readCodexWorkspaceStatus(options = {}) {
|
|
18
|
+
const memoraxCodeHome = options.memoraxCodeHome ?? defaultMemoraxCodeHome();
|
|
19
|
+
const path = adapterWorkspaceStatePath(memoraxCodeHome, "codex");
|
|
20
|
+
const state = readAdapterState(path);
|
|
21
|
+
const latest = state?.latest && typeof state.latest === "object" ? state.latest : undefined;
|
|
22
|
+
return {
|
|
23
|
+
ok: true,
|
|
24
|
+
path,
|
|
25
|
+
captured: Boolean(latest?.cwd),
|
|
26
|
+
latest,
|
|
27
|
+
sessionCount: state?.sessions && typeof state.sessions === "object" ? Object.keys(state.sessions).length : 0,
|
|
28
|
+
state,
|
|
29
|
+
};
|
|
30
|
+
}
|
|
31
|
+
|
|
32
|
+
export function inspectCodexHistory(options = {}) {
|
|
33
|
+
const codexHome = options.codexHome ?? defaultCodexHome();
|
|
34
|
+
const memoraxCodeHome = options.memoraxCodeHome ?? defaultMemoraxCodeHome();
|
|
35
|
+
const sessionsRoot = join(codexHome, "sessions");
|
|
36
|
+
const nativeSessions = collectSessionFiles(sessionsRoot, codexHome, options);
|
|
37
|
+
const historyPath = join(codexHome, "history.jsonl");
|
|
38
|
+
return {
|
|
39
|
+
ok: true,
|
|
40
|
+
action: "inspect-history",
|
|
41
|
+
codexHome,
|
|
42
|
+
memoraxCodeHome,
|
|
43
|
+
readOnly: true,
|
|
44
|
+
native: {
|
|
45
|
+
sessionsRoot,
|
|
46
|
+
sessionsRootExists: existsSync(sessionsRoot),
|
|
47
|
+
historyPath,
|
|
48
|
+
historyExists: existsSync(historyPath),
|
|
49
|
+
sessionCount: nativeSessions.length,
|
|
50
|
+
sessions: nativeSessions,
|
|
51
|
+
},
|
|
52
|
+
memoraxCode: {
|
|
53
|
+
registryPath: adapterSessionRegistryPath(memoraxCodeHome, "codex"),
|
|
54
|
+
workspaceStatePath: adapterWorkspaceStatePath(memoraxCodeHome, "codex"),
|
|
55
|
+
registryExists: existsSync(adapterSessionRegistryPath(memoraxCodeHome, "codex")),
|
|
56
|
+
workspaceStateExists: existsSync(adapterWorkspaceStatePath(memoraxCodeHome, "codex")),
|
|
57
|
+
},
|
|
58
|
+
};
|
|
59
|
+
}
|
|
60
|
+
|
|
61
|
+
export function readCodexSessionRegistry(options = {}) {
|
|
62
|
+
const memoraxCodeHome = options.memoraxCodeHome ?? defaultMemoraxCodeHome();
|
|
63
|
+
const path = options.registryPath ?? adapterSessionRegistryPath(memoraxCodeHome, "codex");
|
|
64
|
+
const state = readAdapterState(path);
|
|
65
|
+
const rawSessions = state?.sessions && typeof state.sessions === "object" && !Array.isArray(state.sessions)
|
|
66
|
+
? state.sessions
|
|
67
|
+
: {};
|
|
68
|
+
const sessions = {};
|
|
69
|
+
for (const [key, value] of Object.entries(rawSessions)) {
|
|
70
|
+
if (!value || typeof value !== "object") continue;
|
|
71
|
+
const session = normalizeRegistrySession(key, value);
|
|
72
|
+
if (session) sessions[key] = session;
|
|
73
|
+
}
|
|
74
|
+
return {
|
|
75
|
+
ok: true,
|
|
76
|
+
action: "session-registry",
|
|
77
|
+
path,
|
|
78
|
+
exists: existsSync(path),
|
|
79
|
+
unreadable: Boolean(state?.unreadable),
|
|
80
|
+
state: {
|
|
81
|
+
version: 1,
|
|
82
|
+
runtime: "codex",
|
|
83
|
+
updatedAt: typeof state?.updatedAt === "string" ? state.updatedAt : undefined,
|
|
84
|
+
sessions,
|
|
85
|
+
},
|
|
86
|
+
};
|
|
87
|
+
}
|
|
88
|
+
|
|
89
|
+
export function updateCodexSessionRegistry(options = {}) {
|
|
90
|
+
const memoraxCodeHome = options.memoraxCodeHome ?? defaultMemoraxCodeHome();
|
|
91
|
+
const path = options.registryPath ?? adapterSessionRegistryPath(memoraxCodeHome, "codex");
|
|
92
|
+
const sessionId = stringOption(options.sessionId);
|
|
93
|
+
if (!sessionId) return { ok: false, action: "mark-session", reason: "missing_session_id", message: "--session-id is required", path };
|
|
94
|
+
return withJsonFileLock(path, () => {
|
|
95
|
+
const registry = readCodexSessionRegistry({ ...options, memoraxCodeHome, registryPath: path });
|
|
96
|
+
if (registry.unreadable) {
|
|
97
|
+
return { ok: false, action: "mark-session", reason: "unreadable_registry", message: "session registry is unreadable; inspect it before overwriting", path };
|
|
98
|
+
}
|
|
99
|
+
const existing = registry.state.sessions[sessionId];
|
|
100
|
+
const now = new Date().toISOString();
|
|
101
|
+
const session = {
|
|
102
|
+
...(existing ?? {}),
|
|
103
|
+
key: sessionId,
|
|
104
|
+
title: stringOption(options.title) ?? existing?.title,
|
|
105
|
+
codexSessionId: stringOption(options.codexSessionId) ?? existing?.codexSessionId ?? sessionId,
|
|
106
|
+
transcriptPath: stringOption(options.transcriptPath) ?? existing?.transcriptPath,
|
|
107
|
+
workspace: stringOption(options.workspace) ?? existing?.workspace,
|
|
108
|
+
};
|
|
109
|
+
const state = {
|
|
110
|
+
version: 1,
|
|
111
|
+
runtime: "codex",
|
|
112
|
+
updatedAt: now,
|
|
113
|
+
sessions: {
|
|
114
|
+
...registry.state.sessions,
|
|
115
|
+
[sessionId]: session,
|
|
116
|
+
},
|
|
117
|
+
};
|
|
118
|
+
atomicWriteJson(path, state);
|
|
119
|
+
return { ok: true, action: "mark-session", path, session, changed: JSON.stringify(existing) !== JSON.stringify(session) };
|
|
120
|
+
});
|
|
121
|
+
}
|
|
122
|
+
|
|
123
|
+
export function seedExistingCodexSessionsAsNative(options = {}) {
|
|
124
|
+
const codexHome = options.codexHome ?? defaultCodexHome();
|
|
125
|
+
const memoraxCodeHome = options.memoraxCodeHome ?? defaultMemoraxCodeHome();
|
|
126
|
+
const path = options.registryPath ?? adapterSessionRegistryPath(memoraxCodeHome, "codex");
|
|
127
|
+
const initialRegistry = readCodexSessionRegistry({ ...options, memoraxCodeHome, registryPath: path });
|
|
128
|
+
if (initialRegistry.unreadable) return unreadableCodexRegistry(path);
|
|
129
|
+
const history = inspectCodexHistory({ ...options, codexHome, memoraxCodeHome });
|
|
130
|
+
if (options.dryRun) return seedCodexSessions(path, codexHome, initialRegistry, history, false);
|
|
131
|
+
return withJsonFileLock(path, () => {
|
|
132
|
+
const registry = readCodexSessionRegistry({ ...options, memoraxCodeHome, registryPath: path });
|
|
133
|
+
if (registry.unreadable) return unreadableCodexRegistry(path);
|
|
134
|
+
return seedCodexSessions(path, codexHome, registry, history, true);
|
|
135
|
+
});
|
|
136
|
+
}
|
|
137
|
+
|
|
138
|
+
function seedCodexSessions(path, codexHome, registry, history, write) {
|
|
139
|
+
const existingSessions = registry.state.sessions;
|
|
140
|
+
const sessions = { ...existingSessions };
|
|
141
|
+
const now = new Date().toISOString();
|
|
142
|
+
let seeded = 0;
|
|
143
|
+
for (const item of history.native.sessions) {
|
|
144
|
+
if (findExistingRegistrySessionKey(sessions, item)) continue;
|
|
145
|
+
const transcriptPath = join(codexHome, item.relativePath);
|
|
146
|
+
sessions[item.id] = {
|
|
147
|
+
key: item.id,
|
|
148
|
+
codexSessionId: item.id,
|
|
149
|
+
transcriptPath,
|
|
150
|
+
};
|
|
151
|
+
seeded += 1;
|
|
152
|
+
}
|
|
153
|
+
if (write && seeded > 0) {
|
|
154
|
+
atomicWriteJson(path, {
|
|
155
|
+
version: 1,
|
|
156
|
+
runtime: "codex",
|
|
157
|
+
updatedAt: now,
|
|
158
|
+
sessions,
|
|
159
|
+
});
|
|
160
|
+
}
|
|
161
|
+
return { ok: true, action: "seed-native-sessions", path, inspected: history.native.sessionCount, seeded };
|
|
162
|
+
}
|
|
163
|
+
|
|
164
|
+
function unreadableCodexRegistry(path) {
|
|
165
|
+
return {
|
|
166
|
+
ok: false,
|
|
167
|
+
action: "seed-native-sessions",
|
|
168
|
+
reason: "unreadable_registry",
|
|
169
|
+
message: "session registry is unreadable; inspect it before seeding native Codex sessions",
|
|
170
|
+
path,
|
|
171
|
+
};
|
|
172
|
+
}
|
|
173
|
+
|
|
174
|
+
export function readMergedCodexSessions(options = {}) {
|
|
175
|
+
const history = inspectCodexHistory(options);
|
|
176
|
+
const registry = readCodexSessionRegistry(options);
|
|
177
|
+
const workspaceStatus = readCodexWorkspaceStatus(options);
|
|
178
|
+
if (registry.unreadable) {
|
|
179
|
+
return {
|
|
180
|
+
ok: false,
|
|
181
|
+
action: "sessions",
|
|
182
|
+
reason: "unreadable_registry",
|
|
183
|
+
message: "session registry is unreadable; sessions are not merged to avoid hiding or rewriting adapter state",
|
|
184
|
+
codexHome: history.codexHome,
|
|
185
|
+
memoraxCodeHome: history.memoraxCodeHome,
|
|
186
|
+
registryPath: registry.path,
|
|
187
|
+
nativeSessionCount: history.native.sessionCount,
|
|
188
|
+
sessionCount: 0,
|
|
189
|
+
sessions: [],
|
|
190
|
+
};
|
|
191
|
+
}
|
|
192
|
+
const workspaceByKey = workspaceRecordMap(workspaceStatus.state);
|
|
193
|
+
const registeredByCodexId = new Map();
|
|
194
|
+
for (const session of Object.values(registry.state.sessions)) {
|
|
195
|
+
if (session.codexSessionId) registeredByCodexId.set(session.codexSessionId, session);
|
|
196
|
+
}
|
|
197
|
+
const native = history.native.sessions.map((item) => {
|
|
198
|
+
const registered = registeredByCodexId.get(item.id);
|
|
199
|
+
const workspace = findWorkspaceRecord(workspaceByKey, registered?.key, item.id, registered?.transcriptPath, item.relativePath);
|
|
200
|
+
return {
|
|
201
|
+
key: registered?.key ?? item.id,
|
|
202
|
+
title: registered?.title,
|
|
203
|
+
codexSessionId: item.id,
|
|
204
|
+
relativePath: item.relativePath,
|
|
205
|
+
pathHash: item.pathHash,
|
|
206
|
+
sizeBytes: item.sizeBytes,
|
|
207
|
+
modifiedAt: item.modifiedAt,
|
|
208
|
+
workspace: registered?.workspace ?? workspace?.cwd,
|
|
209
|
+
transcriptPath: registered?.transcriptPath ?? workspace?.transcriptPath,
|
|
210
|
+
observedAt: workspace?.capturedAt,
|
|
211
|
+
};
|
|
212
|
+
});
|
|
213
|
+
const sessions = native.sort((a, b) => String(b.modifiedAt ?? "").localeCompare(String(a.modifiedAt ?? "")));
|
|
214
|
+
return {
|
|
215
|
+
ok: true,
|
|
216
|
+
action: "sessions",
|
|
217
|
+
codexHome: history.codexHome,
|
|
218
|
+
memoraxCodeHome: history.memoraxCodeHome,
|
|
219
|
+
registryPath: registry.path,
|
|
220
|
+
sessionCount: sessions.length,
|
|
221
|
+
sessions,
|
|
222
|
+
};
|
|
223
|
+
}
|
|
224
|
+
|
|
225
|
+
function collectSessionFiles(root, codexHome, options = {}) {
|
|
226
|
+
const requestedMaxFiles = Number(options.maxFiles);
|
|
227
|
+
const requestedMaxDepth = Number(options.maxDepth);
|
|
228
|
+
const maxFiles = Number.isFinite(requestedMaxFiles) ? Math.max(0, Math.floor(requestedMaxFiles)) : 500;
|
|
229
|
+
const maxDepth = Number.isFinite(requestedMaxDepth) ? Math.max(0, Math.floor(requestedMaxDepth)) : 8;
|
|
230
|
+
const files = [];
|
|
231
|
+
walkSessionFiles(root, 0, maxDepth, files, maxFiles);
|
|
232
|
+
return files.map((path) => sessionFileSummary(path, codexHome)).filter(Boolean);
|
|
233
|
+
}
|
|
234
|
+
|
|
235
|
+
function walkSessionFiles(path, depth, maxDepth, files, maxFiles) {
|
|
236
|
+
if (files.length >= maxFiles || depth > maxDepth || !existsSync(path)) return;
|
|
237
|
+
let stat;
|
|
238
|
+
try {
|
|
239
|
+
stat = lstatSync(path);
|
|
240
|
+
} catch {
|
|
241
|
+
return;
|
|
242
|
+
}
|
|
243
|
+
if (stat.isSymbolicLink()) return;
|
|
244
|
+
if (stat.isFile()) {
|
|
245
|
+
if (/\.(jsonl|json)$/i.test(path)) files.push(path);
|
|
246
|
+
return;
|
|
247
|
+
}
|
|
248
|
+
if (!stat.isDirectory()) return;
|
|
249
|
+
let entries = [];
|
|
250
|
+
try {
|
|
251
|
+
entries = readdirSync(path, { withFileTypes: true });
|
|
252
|
+
} catch {
|
|
253
|
+
return;
|
|
254
|
+
}
|
|
255
|
+
entries
|
|
256
|
+
.sort((a, b) => a.name.localeCompare(b.name))
|
|
257
|
+
.forEach((entry) => walkSessionFiles(join(path, entry.name), depth + 1, maxDepth, files, maxFiles));
|
|
258
|
+
}
|
|
259
|
+
|
|
260
|
+
function sessionFileSummary(path, codexHome) {
|
|
261
|
+
try {
|
|
262
|
+
const stat = statSync(path);
|
|
263
|
+
const relativePath = relative(codexHome, path);
|
|
264
|
+
const id = basename(path).replace(/\.(jsonl|json)$/i, "");
|
|
265
|
+
return {
|
|
266
|
+
id,
|
|
267
|
+
kind: "codex-session-file",
|
|
268
|
+
relativePath,
|
|
269
|
+
pathHash: sha256(relativePath).slice(0, 16),
|
|
270
|
+
sizeBytes: stat.size,
|
|
271
|
+
modifiedAt: stat.mtime.toISOString(),
|
|
272
|
+
};
|
|
273
|
+
} catch {
|
|
274
|
+
return undefined;
|
|
275
|
+
}
|
|
276
|
+
}
|
|
277
|
+
|
|
278
|
+
function normalizeRegistrySession(key, value) {
|
|
279
|
+
return {
|
|
280
|
+
key,
|
|
281
|
+
title: stringOption(value.title),
|
|
282
|
+
codexSessionId: stringOption(value.codexSessionId),
|
|
283
|
+
transcriptPath: stringOption(value.transcriptPath),
|
|
284
|
+
workspace: stringOption(value.workspace),
|
|
285
|
+
};
|
|
286
|
+
}
|
|
287
|
+
|
|
288
|
+
function workspaceRecordMap(state) {
|
|
289
|
+
const raw = state?.sessions && typeof state.sessions === "object" && !Array.isArray(state.sessions)
|
|
290
|
+
? state.sessions
|
|
291
|
+
: {};
|
|
292
|
+
const records = new Map();
|
|
293
|
+
for (const [key, value] of Object.entries(raw)) {
|
|
294
|
+
if (!value || typeof value !== "object" || Array.isArray(value)) continue;
|
|
295
|
+
records.set(key, value);
|
|
296
|
+
}
|
|
297
|
+
return records;
|
|
298
|
+
}
|
|
299
|
+
|
|
300
|
+
function findWorkspaceRecord(records, ...keys) {
|
|
301
|
+
for (const key of workspaceLookupKeys(keys)) {
|
|
302
|
+
const record = records.get(key);
|
|
303
|
+
if (record) return record;
|
|
304
|
+
}
|
|
305
|
+
return undefined;
|
|
306
|
+
}
|
|
307
|
+
|
|
308
|
+
function workspaceLookupKeys(keys) {
|
|
309
|
+
const result = new Set();
|
|
310
|
+
for (const key of keys) {
|
|
311
|
+
const value = stringOption(key);
|
|
312
|
+
if (!value) continue;
|
|
313
|
+
result.add(value);
|
|
314
|
+
const base = basename(value).replace(/\.[^.]+$/, "");
|
|
315
|
+
result.add(base);
|
|
316
|
+
if (value.startsWith("codex_")) result.add(value.slice("codex_".length));
|
|
317
|
+
else result.add(`codex_${value}`);
|
|
318
|
+
if (base.startsWith("codex_")) result.add(base.slice("codex_".length));
|
|
319
|
+
else result.add(`codex_${base}`);
|
|
320
|
+
}
|
|
321
|
+
return result;
|
|
322
|
+
}
|
|
323
|
+
|
|
324
|
+
function findExistingRegistrySessionKey(sessions, item) {
|
|
325
|
+
for (const [key, session] of Object.entries(sessions ?? {})) {
|
|
326
|
+
if (key === item.id) return key;
|
|
327
|
+
if (session?.codexSessionId === item.id) return key;
|
|
328
|
+
if (session?.transcriptPath && item.relativePath && String(session.transcriptPath).endsWith(item.relativePath)) return key;
|
|
329
|
+
}
|
|
330
|
+
return undefined;
|
|
331
|
+
}
|
|
@@ -0,0 +1,68 @@
|
|
|
1
|
+
import { realpathSync } from "node:fs";
|
|
2
|
+
import { homedir } from "node:os";
|
|
3
|
+
import { posix, win32 } from "node:path";
|
|
4
|
+
|
|
5
|
+
const ISO_DATE_PATTERN = /^(\d{4})-(\d{2})-(\d{2})$/;
|
|
6
|
+
const nativePath = process.platform === "win32" ? win32 : posix;
|
|
7
|
+
|
|
8
|
+
export function resolveCodexWorkspaceKind(input, options = {}) {
|
|
9
|
+
const explicitKind = stringValue(input?.workspace_kind) ?? stringValue(input?.workspaceKind);
|
|
10
|
+
if (explicitKind) return explicitKind;
|
|
11
|
+
return isCodexManagedTaskWorkspace(stringValue(input?.cwd), options) ? "projectless" : undefined;
|
|
12
|
+
}
|
|
13
|
+
|
|
14
|
+
export function isCodexManagedTaskWorkspace(value, options = {}) {
|
|
15
|
+
const path = options.path ?? nativePath;
|
|
16
|
+
if (!value || !path.isAbsolute(value)) return false;
|
|
17
|
+
const canonicalize = options.canonicalize ?? canonicalPath;
|
|
18
|
+
const workspace = canonicalize(value);
|
|
19
|
+
if (!workspace) return false;
|
|
20
|
+
const roots = options.managedRoots ?? defaultManagedRoots(options.env);
|
|
21
|
+
return roots.some((root) => managedRelativePath(canonicalize(root), workspace, path));
|
|
22
|
+
}
|
|
23
|
+
|
|
24
|
+
function managedRelativePath(root, workspace, pathApi) {
|
|
25
|
+
if (!root || !workspace) return false;
|
|
26
|
+
const path = pathApi.relative(root, workspace);
|
|
27
|
+
if (!path || path.startsWith(`..${pathApi.sep}`) || path === ".." || pathApi.isAbsolute(path)) return false;
|
|
28
|
+
const parts = path.split(pathApi.sep);
|
|
29
|
+
return parts.length === 2 && validIsoDate(parts[0]) && Boolean(parts[1]);
|
|
30
|
+
}
|
|
31
|
+
|
|
32
|
+
function defaultManagedRoots(env = process.env) {
|
|
33
|
+
const home = stringValue(process.platform === "win32" ? env.USERPROFILE : env.HOME)
|
|
34
|
+
?? stringValue(env.HOME)
|
|
35
|
+
?? homedir();
|
|
36
|
+
const roots = [nativePath.join(home, "Documents", "Codex")];
|
|
37
|
+
if (process.platform === "win32") {
|
|
38
|
+
for (const key of ["OneDrive", "OneDriveCommercial", "OneDriveConsumer"]) {
|
|
39
|
+
const oneDrive = stringValue(env[key]);
|
|
40
|
+
if (oneDrive) roots.push(nativePath.join(oneDrive, "Documents", "Codex"));
|
|
41
|
+
}
|
|
42
|
+
}
|
|
43
|
+
return [...new Set(roots)];
|
|
44
|
+
}
|
|
45
|
+
|
|
46
|
+
function canonicalPath(value) {
|
|
47
|
+
try {
|
|
48
|
+
return realpathSync(value);
|
|
49
|
+
} catch {
|
|
50
|
+
return undefined;
|
|
51
|
+
}
|
|
52
|
+
}
|
|
53
|
+
|
|
54
|
+
function validIsoDate(value) {
|
|
55
|
+
const match = ISO_DATE_PATTERN.exec(value);
|
|
56
|
+
if (!match) return false;
|
|
57
|
+
const year = Number(match[1]);
|
|
58
|
+
const month = Number(match[2]);
|
|
59
|
+
const day = Number(match[3]);
|
|
60
|
+
const date = new Date(Date.UTC(year, month - 1, day));
|
|
61
|
+
return date.getUTCFullYear() === year
|
|
62
|
+
&& date.getUTCMonth() === month - 1
|
|
63
|
+
&& date.getUTCDate() === day;
|
|
64
|
+
}
|
|
65
|
+
|
|
66
|
+
function stringValue(value) {
|
|
67
|
+
return typeof value === "string" && value.trim() ? value.trim() : undefined;
|
|
68
|
+
}
|
|
@@ -0,0 +1,11 @@
|
|
|
1
|
+
export const MINIMUM_NODE_MAJOR = 24;
|
|
2
|
+
|
|
3
|
+
export function unsupportedNodeVersionMessage(version = process.versions.node) {
|
|
4
|
+
const value = String(version ?? "").trim();
|
|
5
|
+
const match = /^v?(\d+)(?:\.|$)/.exec(value);
|
|
6
|
+
const major = match ? Number.parseInt(match[1], 10) : undefined;
|
|
7
|
+
if (major !== undefined && major >= MINIMUM_NODE_MAJOR) return undefined;
|
|
8
|
+
const current = value || "unknown";
|
|
9
|
+
return `MemoraX Code requires Node.js ${MINIMUM_NODE_MAJOR} or newer; `
|
|
10
|
+
+ `the current runtime is Node.js ${current}. Upgrade Node.js and try again.`;
|
|
11
|
+
}
|
|
@@ -0,0 +1,31 @@
|
|
|
1
|
+
import { existsSync } from "node:fs";
|
|
2
|
+
import path from "node:path";
|
|
3
|
+
|
|
4
|
+
export function resolveNpmInvocation(npmArgs, options = {}) {
|
|
5
|
+
const env = options.env ?? process.env;
|
|
6
|
+
const platform = options.platform ?? process.platform;
|
|
7
|
+
const nodePath = options.nodePath ?? process.execPath;
|
|
8
|
+
const fileExists = options.existsSync ?? existsSync;
|
|
9
|
+
if (platform !== "win32") return { command: "npm", args: npmArgs };
|
|
10
|
+
const pathApi = path.win32;
|
|
11
|
+
const candidates = [
|
|
12
|
+
env.MEMORAX_CODE_NPM_EXEC_PATH,
|
|
13
|
+
env.npm_execpath,
|
|
14
|
+
env.NPM_CLI_JS,
|
|
15
|
+
pathApi.join(pathApi.dirname(nodePath), "node_modules", "npm", "bin", "npm-cli.js"),
|
|
16
|
+
pathApi.join(
|
|
17
|
+
pathApi.dirname(pathApi.dirname(nodePath)),
|
|
18
|
+
"lib",
|
|
19
|
+
"node_modules",
|
|
20
|
+
"npm",
|
|
21
|
+
"bin",
|
|
22
|
+
"npm-cli.js",
|
|
23
|
+
),
|
|
24
|
+
].filter((candidate) => typeof candidate === "string" && /\.(?:cjs|js|mjs)$/i.test(candidate));
|
|
25
|
+
const npmCli = candidates.find((candidate) => fileExists(candidate));
|
|
26
|
+
if (npmCli) return { command: nodePath, args: [npmCli, ...npmArgs] };
|
|
27
|
+
throw new Error(
|
|
28
|
+
"npm CLI JavaScript entrypoint was not found; set MEMORAX_CODE_NPM_EXEC_PATH, "
|
|
29
|
+
+ "npm_execpath, or NPM_CLI_JS before running memorax-code update",
|
|
30
|
+
);
|
|
31
|
+
}
|