sessionmem 1.0.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.
Files changed (71) hide show
  1. package/LICENSE +21 -0
  2. package/README.md +344 -0
  3. package/dist/adapters/capabilities/fallbackTools.js +36 -0
  4. package/dist/adapters/contract/hostAdapterContract.js +1 -0
  5. package/dist/adapters/factory.js +40 -0
  6. package/dist/adapters/generic.js +128 -0
  7. package/dist/adapters/global/antigravity.js +22 -0
  8. package/dist/adapters/global/claudeCode.js +22 -0
  9. package/dist/adapters/global/codex.js +22 -0
  10. package/dist/adapters/global/qcoder.js +22 -0
  11. package/dist/adapters/ide/cline.js +20 -0
  12. package/dist/adapters/ide/cursor.js +28 -0
  13. package/dist/adapters/ide/installer.js +57 -0
  14. package/dist/adapters/ide/windsurf.js +28 -0
  15. package/dist/adapters/tools/ping.js +15 -0
  16. package/dist/cli/commands/config.js +79 -0
  17. package/dist/cli/commands/export.js +28 -0
  18. package/dist/cli/commands/forget.js +28 -0
  19. package/dist/cli/commands/import.js +112 -0
  20. package/dist/cli/commands/install.js +57 -0
  21. package/dist/cli/commands/list.js +13 -0
  22. package/dist/cli/commands/ping.js +12 -0
  23. package/dist/cli/commands/redactScan.js +40 -0
  24. package/dist/cli/commands/retention.js +54 -0
  25. package/dist/cli/commands/run.js +26 -0
  26. package/dist/cli/commands/search.js +29 -0
  27. package/dist/cli/commands/show.js +15 -0
  28. package/dist/cli/commands/stats.js +46 -0
  29. package/dist/cli/commands/sync.js +118 -0
  30. package/dist/cli/commands/team.js +96 -0
  31. package/dist/cli/commands/uninstall.js +30 -0
  32. package/dist/cli/context.js +69 -0
  33. package/dist/cli/index.js +147 -0
  34. package/dist/cli/output.js +37 -0
  35. package/dist/core/api/contracts.js +263 -0
  36. package/dist/core/api/errors.js +29 -0
  37. package/dist/core/api/localOnlyPolicy.js +29 -0
  38. package/dist/core/api/memoryCoreService.js +595 -0
  39. package/dist/core/api/sessionLifecycleService.js +289 -0
  40. package/dist/core/config/policyConfig.js +131 -0
  41. package/dist/core/embed/deterministicEmbed.js +31 -0
  42. package/dist/core/embed/embeddingVersion.js +1 -0
  43. package/dist/core/embed/reembedPolicy.js +9 -0
  44. package/dist/core/embed/textNormalize.js +12 -0
  45. package/dist/core/injection/formatStartupInjection.js +97 -0
  46. package/dist/core/injection/tokenBudget.js +38 -0
  47. package/dist/core/retrieve/decay.js +15 -0
  48. package/dist/core/retrieve/importance.js +6 -0
  49. package/dist/core/retrieve/recencyBands.js +18 -0
  50. package/dist/core/retrieve/retrieveMemories.js +83 -0
  51. package/dist/core/retrieve/score.js +25 -0
  52. package/dist/core/schema/migrations/001_initial.sql +25 -0
  53. package/dist/core/schema/migrations/002_indexes.sql +18 -0
  54. package/dist/core/schema/migrations/003_summarization_failures.sql +14 -0
  55. package/dist/core/schema/migrations/004_memory_feedback.sql +12 -0
  56. package/dist/core/schema/migrations/005_team_provenance.sql +9 -0
  57. package/dist/core/schema/runMigrations.js +38 -0
  58. package/dist/core/session.js +4 -0
  59. package/dist/core/storage/db.js +8 -0
  60. package/dist/core/storage/memoryFeedbackRepo.js +16 -0
  61. package/dist/core/storage/memoryRepo.js +179 -0
  62. package/dist/core/storage/memorySearchRepo.js +30 -0
  63. package/dist/core/storage/sessionEventsRepo.js +20 -0
  64. package/dist/core/storage/summarizationFailuresRepo.js +39 -0
  65. package/dist/core/storage/types.js +1 -0
  66. package/dist/core/summarize/cloudSummarizer.js +19 -0
  67. package/dist/core/summarize/localSummarizer.js +31 -0
  68. package/dist/core/summarize/redaction.js +48 -0
  69. package/dist/core/summarize/strategySelector.js +7 -0
  70. package/dist/core/summarize/summaryShape.js +49 -0
  71. package/package.json +48 -0
@@ -0,0 +1,49 @@
1
+ function extractEventText(event) {
2
+ try {
3
+ const parsed = JSON.parse(event.payload_json);
4
+ if (typeof parsed.text === "string" && parsed.text.trim().length > 0) {
5
+ return parsed.text.trim();
6
+ }
7
+ }
8
+ catch {
9
+ // fall through to raw payload
10
+ }
11
+ return event.payload_json.trim();
12
+ }
13
+ function sectionLines(events, fallback) {
14
+ const lines = events.map(extractEventText).filter((line) => line.length > 0);
15
+ if (lines.length === 0) {
16
+ return [fallback];
17
+ }
18
+ return lines.slice(0, 3);
19
+ }
20
+ export function buildStructuredSummary(events, options) {
21
+ const sharedLines = sectionLines(events, "No relevant events captured.");
22
+ const summarySection = [
23
+ "goals",
24
+ ...sharedLines.map((line) => `- ${line}`),
25
+ "",
26
+ "actions",
27
+ ...sharedLines.map((line) => `- ${line}`),
28
+ "",
29
+ "decisions",
30
+ ...sharedLines.map((line) => `- ${line}`),
31
+ "",
32
+ "blockers",
33
+ ...sharedLines.map((line) => `- ${line}`),
34
+ "",
35
+ "outcomes",
36
+ ...sharedLines.map((line) => `- ${line}`),
37
+ ].join("\n");
38
+ const facts = events
39
+ .map((event) => `- [${event.event_type}] ${extractEventText(event)}`)
40
+ .slice(0, 5);
41
+ const factSection = ["facts", ...facts].join("\n");
42
+ if (options.factMode === "summary-only") {
43
+ return summarySection;
44
+ }
45
+ if (options.factMode === "facts-only") {
46
+ return factSection;
47
+ }
48
+ return `${summarySection}\n\n${factSection}`;
49
+ }
package/package.json ADDED
@@ -0,0 +1,48 @@
1
+ {
2
+ "name": "sessionmem",
3
+ "version": "1.0.0",
4
+ "private": false,
5
+ "type": "module",
6
+ "description": "Local-first MCP memory layer for coding agents across Claude Code, Codex, Cursor, Cline, Windsurf, and other MCP-compatible hosts.",
7
+ "license": "MIT",
8
+ "author": "kavishdua",
9
+ "repository": {
10
+ "type": "git",
11
+ "url": "git+https://github.com/kavishdua/sessionmem.git"
12
+ },
13
+ "mcpName": "io.github.kavishdua/sessionmem",
14
+ "files": [
15
+ "dist"
16
+ ],
17
+ "publishConfig": {
18
+ "access": "public"
19
+ },
20
+ "bin": {
21
+ "sessionmem": "./dist/cli/index.js"
22
+ },
23
+ "scripts": {
24
+ "build": "tsc && node scripts/copy-migrations.mjs",
25
+ "prepack": "npm run build",
26
+ "test": "vitest run --reporter=dot",
27
+ "test:schema": "vitest run tests/integration/storage/schema.spec.ts --reporter=dot",
28
+ "lint": "eslint .",
29
+ "typecheck": "tsc --noEmit",
30
+ "benchmark": "node scripts/benchmark.mjs"
31
+ },
32
+ "dependencies": {
33
+ "@modelcontextprotocol/sdk": "^1.29.0",
34
+ "better-sqlite3": "^12.4.1",
35
+ "commander": "^15.0.0",
36
+ "js-tiktoken": "^1.0.21",
37
+ "zod": "^4.4.3"
38
+ },
39
+ "devDependencies": {
40
+ "@eslint/js": "^10.0.1",
41
+ "@types/better-sqlite3": "^7.6.13",
42
+ "eslint": "^10.4.1",
43
+ "globals": "^17.6.0",
44
+ "typescript": "^6.0.3",
45
+ "typescript-eslint": "^8.61.0",
46
+ "vitest": "^4.1.8"
47
+ }
48
+ }