@cortexkit/opencode-magic-context 0.8.8 → 0.8.9

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.
@@ -1 +1 @@
1
- {"version":3,"file":"embedding-local.d.ts","sourceRoot":"","sources":["../../../../src/features/magic-context/memory/embedding-local.ts"],"names":[],"mappings":"AAEA,OAAO,KAAK,EAAE,iBAAiB,EAAE,MAAM,sBAAsB,CAAC;AAyH9D,qBAAa,sBAAuB,YAAW,iBAAiB;IAC5D,QAAQ,CAAC,OAAO,EAAE,MAAM,CAAC;IAEzB,OAAO,CAAC,QAAQ,CAAC,KAAK,CAAS;IAC/B,OAAO,CAAC,QAAQ,CAAkC;IAClD,OAAO,CAAC,WAAW,CAA8B;gBAErC,KAAK,SAAgC;IAK3C,UAAU,IAAI,OAAO,CAAC,OAAO,CAAC;IA+E9B,KAAK,CAAC,IAAI,EAAE,MAAM,GAAG,OAAO,CAAC,YAAY,GAAG,IAAI,CAAC;IAyBjD,UAAU,CAAC,KAAK,EAAE,MAAM,EAAE,GAAG,OAAO,CAAC,CAAC,YAAY,GAAG,IAAI,CAAC,EAAE,CAAC;IA6B7D,OAAO,IAAI,OAAO,CAAC,IAAI,CAAC;IAqB9B,QAAQ,IAAI,OAAO;CAGtB"}
1
+ {"version":3,"file":"embedding-local.d.ts","sourceRoot":"","sources":["../../../../src/features/magic-context/memory/embedding-local.ts"],"names":[],"mappings":"AAKA,OAAO,KAAK,EAAE,iBAAiB,EAAE,MAAM,sBAAsB,CAAC;AAyH9D,qBAAa,sBAAuB,YAAW,iBAAiB;IAC5D,QAAQ,CAAC,OAAO,EAAE,MAAM,CAAC;IAEzB,OAAO,CAAC,QAAQ,CAAC,KAAK,CAAS;IAC/B,OAAO,CAAC,QAAQ,CAAkC;IAClD,OAAO,CAAC,WAAW,CAA8B;gBAErC,KAAK,SAAgC;IAK3C,UAAU,IAAI,OAAO,CAAC,OAAO,CAAC;IAqG9B,KAAK,CAAC,IAAI,EAAE,MAAM,GAAG,OAAO,CAAC,YAAY,GAAG,IAAI,CAAC;IAyBjD,UAAU,CAAC,KAAK,EAAE,MAAM,EAAE,GAAG,OAAO,CAAC,CAAC,YAAY,GAAG,IAAI,CAAC,EAAE,CAAC;IA6B7D,OAAO,IAAI,OAAO,CAAC,IAAI,CAAC;IAqB9B,QAAQ,IAAI,OAAO;CAGtB"}
package/dist/index.js CHANGED
@@ -16166,6 +16166,8 @@ function cosineSimilarity(a, b) {
16166
16166
  }
16167
16167
 
16168
16168
  // src/features/magic-context/memory/embedding-local.ts
16169
+ import { mkdirSync } from "fs";
16170
+ import { join as join9 } from "path";
16169
16171
  async function withQuietConsole(fn) {
16170
16172
  const origWarn = console.warn;
16171
16173
  const origError = console.error;
@@ -16250,6 +16252,13 @@ class LocalEmbeddingProvider {
16250
16252
  if (LogLevel && "ERROR" in LogLevel) {
16251
16253
  env.logLevel = LogLevel.ERROR;
16252
16254
  }
16255
+ const modelCacheDir = join9(getOpenCodeStorageDir(), "plugin", "magic-context", "models");
16256
+ try {
16257
+ mkdirSync(modelCacheDir, { recursive: true });
16258
+ env.cacheDir = modelCacheDir;
16259
+ } catch {
16260
+ log("[magic-context] could not create model cache dir, using library default");
16261
+ }
16253
16262
  const createPipeline = transformersModule.pipeline;
16254
16263
  const MAX_ATTEMPTS = 3;
16255
16264
  let lastError;
@@ -16351,6 +16360,7 @@ class LocalEmbeddingProvider {
16351
16360
  }
16352
16361
  var init_embedding_local = __esm(() => {
16353
16362
  init_magic_context();
16363
+ init_data_path();
16354
16364
  init_logger();
16355
16365
  });
16356
16366
 
@@ -17401,11 +17411,11 @@ var init_migrations = __esm(() => {
17401
17411
 
17402
17412
  // src/features/magic-context/storage-db.ts
17403
17413
  import { Database as Database3 } from "bun:sqlite";
17404
- import { mkdirSync } from "fs";
17405
- import { join as join9 } from "path";
17414
+ import { mkdirSync as mkdirSync2 } from "fs";
17415
+ import { join as join10 } from "path";
17406
17416
  function resolveDatabasePath() {
17407
- const dbDir = join9(getOpenCodeStorageDir(), "plugin", "magic-context");
17408
- return { dbDir, dbPath: join9(dbDir, "context.db") };
17417
+ const dbDir = join10(getOpenCodeStorageDir(), "plugin", "magic-context");
17418
+ return { dbDir, dbPath: join10(dbDir, "context.db") };
17409
17419
  }
17410
17420
  function initializeDatabase(db) {
17411
17421
  db.run("PRAGMA journal_mode=WAL");
@@ -17720,7 +17730,7 @@ function openDatabase() {
17720
17730
  }
17721
17731
  return existing;
17722
17732
  }
17723
- mkdirSync(dbDir, { recursive: true });
17733
+ mkdirSync2(dbDir, { recursive: true });
17724
17734
  const db = new Database3(dbPath);
17725
17735
  initializeDatabase(db);
17726
17736
  runMigrations(db);
@@ -18559,7 +18569,7 @@ var init_send_session_notification = __esm(() => {
18559
18569
 
18560
18570
  // src/features/magic-context/compaction-marker.ts
18561
18571
  import { Database as Database4 } from "bun:sqlite";
18562
- import { join as join11 } from "path";
18572
+ import { join as join12 } from "path";
18563
18573
  function randomBase62(length) {
18564
18574
  const chars = [];
18565
18575
  for (let i = 0;i < length; i++) {
@@ -18579,7 +18589,7 @@ function generatePartId(timestampMs, counter = 0n) {
18579
18589
  return generateId("prt", timestampMs, counter);
18580
18590
  }
18581
18591
  function getOpenCodeDbPath3() {
18582
- return join11(getDataDir(), "opencode", "opencode.db");
18592
+ return join12(getDataDir(), "opencode", "opencode.db");
18583
18593
  }
18584
18594
  function getWritableOpenCodeDb() {
18585
18595
  const dbPath = getOpenCodeDbPath3();
@@ -19472,9 +19482,9 @@ var init_compartment_runner_validation = __esm(() => {
19472
19482
  });
19473
19483
 
19474
19484
  // src/hooks/magic-context/compartment-runner-historian.ts
19475
- import { mkdirSync as mkdirSync2, unlinkSync, writeFileSync } from "fs";
19485
+ import { mkdirSync as mkdirSync3, unlinkSync, writeFileSync } from "fs";
19476
19486
  import { tmpdir as tmpdir2 } from "os";
19477
- import { join as join12 } from "path";
19487
+ import { join as join13 } from "path";
19478
19488
  async function runValidatedHistorianPass(args) {
19479
19489
  const firstRun = await runHistorianPrompt({
19480
19490
  ...args,
@@ -19677,10 +19687,10 @@ function cleanupHistorianDump(sessionId, dumpPath) {
19677
19687
  }
19678
19688
  function dumpHistorianResponse(sessionId, label, text) {
19679
19689
  try {
19680
- mkdirSync2(HISTORIAN_RESPONSE_DUMP_DIR, { recursive: true });
19690
+ mkdirSync3(HISTORIAN_RESPONSE_DUMP_DIR, { recursive: true });
19681
19691
  const safeSessionId = sanitizeDumpName(sessionId);
19682
19692
  const safeLabel = sanitizeDumpName(label);
19683
- const dumpPath = join12(HISTORIAN_RESPONSE_DUMP_DIR, `${safeSessionId}-${safeLabel}-${Date.now()}.xml`);
19693
+ const dumpPath = join13(HISTORIAN_RESPONSE_DUMP_DIR, `${safeSessionId}-${safeLabel}-${Date.now()}.xml`);
19684
19694
  writeFileSync(dumpPath, text, "utf8");
19685
19695
  sessionLog(sessionId, "compartment agent: historian response dumped", {
19686
19696
  label,
@@ -19704,7 +19714,7 @@ var init_compartment_runner_historian = __esm(() => {
19704
19714
  init_shared();
19705
19715
  init_assistant_message_extractor();
19706
19716
  init_compartment_runner_validation();
19707
- HISTORIAN_RESPONSE_DUMP_DIR = join12(tmpdir2(), "magic-context-historian");
19717
+ HISTORIAN_RESPONSE_DUMP_DIR = join13(tmpdir2(), "magic-context-historian");
19708
19718
  });
19709
19719
 
19710
19720
  // src/hooks/magic-context/compartment-runner-state-xml.ts
@@ -28037,10 +28047,10 @@ var require_stringify = __commonJS((exports, module) => {
28037
28047
  replacer = null;
28038
28048
  indent = EMPTY;
28039
28049
  };
28040
- var join15 = (one, two, gap) => one ? two ? one + two.trim() + LF + gap : one.trimRight() + repeat_line_breaks(Math.max(1, count_trailing_line_breaks(one, gap)), gap) : two ? two.trimRight() + repeat_line_breaks(Math.max(1, count_trailing_line_breaks(two, gap)), gap) : EMPTY;
28050
+ var join16 = (one, two, gap) => one ? two ? one + two.trim() + LF + gap : one.trimRight() + repeat_line_breaks(Math.max(1, count_trailing_line_breaks(one, gap)), gap) : two ? two.trimRight() + repeat_line_breaks(Math.max(1, count_trailing_line_breaks(two, gap)), gap) : EMPTY;
28041
28051
  var join_content = (inside, value, gap) => {
28042
28052
  const comment = process_comments(value, PREFIX_BEFORE, gap + indent, true);
28043
- return join15(comment, inside, gap);
28053
+ return join16(comment, inside, gap);
28044
28054
  };
28045
28055
  var stringify_string = (holder, key, value) => {
28046
28056
  const raw = get_raw_string_literal(holder, key);
@@ -28062,13 +28072,13 @@ var require_stringify = __commonJS((exports, module) => {
28062
28072
  if (i !== 0) {
28063
28073
  inside += COMMA;
28064
28074
  }
28065
- const before = join15(after_comma, process_comments(value, BEFORE(i), deeper_gap), deeper_gap);
28075
+ const before = join16(after_comma, process_comments(value, BEFORE(i), deeper_gap), deeper_gap);
28066
28076
  inside += before || LF + deeper_gap;
28067
28077
  inside += stringify(i, value, deeper_gap) || STR_NULL;
28068
28078
  inside += process_comments(value, AFTER_VALUE(i), deeper_gap);
28069
28079
  after_comma = process_comments(value, AFTER(i), deeper_gap);
28070
28080
  }
28071
- inside += join15(after_comma, process_comments(value, PREFIX_AFTER, deeper_gap), deeper_gap);
28081
+ inside += join16(after_comma, process_comments(value, PREFIX_AFTER, deeper_gap), deeper_gap);
28072
28082
  return BRACKET_OPEN + join_content(inside, value, gap) + BRACKET_CLOSE;
28073
28083
  };
28074
28084
  var object_stringify = (value, gap) => {
@@ -28089,13 +28099,13 @@ var require_stringify = __commonJS((exports, module) => {
28089
28099
  inside += COMMA;
28090
28100
  }
28091
28101
  first = false;
28092
- const before = join15(after_comma, process_comments(value, BEFORE(key), deeper_gap), deeper_gap);
28102
+ const before = join16(after_comma, process_comments(value, BEFORE(key), deeper_gap), deeper_gap);
28093
28103
  inside += before || LF + deeper_gap;
28094
28104
  inside += quote(key) + process_comments(value, AFTER_PROP(key), deeper_gap) + COLON + process_comments(value, AFTER_COLON(key), deeper_gap) + SPACE + sv + process_comments(value, AFTER_VALUE(key), deeper_gap);
28095
28105
  after_comma = process_comments(value, AFTER(key), deeper_gap);
28096
28106
  };
28097
28107
  keys.forEach(iteratee);
28098
- inside += join15(after_comma, process_comments(value, PREFIX_AFTER, deeper_gap), deeper_gap);
28108
+ inside += join16(after_comma, process_comments(value, PREFIX_AFTER, deeper_gap), deeper_gap);
28099
28109
  return CURLY_BRACKET_OPEN + join_content(inside, value, gap) + CURLY_BRACKET_CLOSE;
28100
28110
  };
28101
28111
  function stringify(key, holder, gap) {
@@ -28192,12 +28202,12 @@ var exports_tui_config = {};
28192
28202
  __export(exports_tui_config, {
28193
28203
  ensureTuiPluginEntry: () => ensureTuiPluginEntry
28194
28204
  });
28195
- import { existsSync as existsSync7, mkdirSync as mkdirSync4, readFileSync as readFileSync6, writeFileSync as writeFileSync3 } from "fs";
28196
- import { dirname as dirname2, join as join15 } from "path";
28205
+ import { existsSync as existsSync7, mkdirSync as mkdirSync5, readFileSync as readFileSync6, writeFileSync as writeFileSync3 } from "fs";
28206
+ import { dirname as dirname2, join as join16 } from "path";
28197
28207
  function resolveTuiConfigPath() {
28198
28208
  const configDir = getOpenCodeConfigPaths({ binary: "opencode" }).configDir;
28199
- const jsoncPath = join15(configDir, "tui.jsonc");
28200
- const jsonPath = join15(configDir, "tui.json");
28209
+ const jsoncPath = join16(configDir, "tui.jsonc");
28210
+ const jsonPath = join16(configDir, "tui.json");
28201
28211
  if (existsSync7(jsoncPath))
28202
28212
  return jsoncPath;
28203
28213
  if (existsSync7(jsonPath))
@@ -28218,7 +28228,7 @@ function ensureTuiPluginEntry() {
28218
28228
  }
28219
28229
  plugins.push(PLUGIN_ENTRY);
28220
28230
  config2.plugin = plugins;
28221
- mkdirSync4(dirname2(configPath), { recursive: true });
28231
+ mkdirSync5(dirname2(configPath), { recursive: true });
28222
28232
  writeFileSync3(configPath, `${import_comment_json.stringify(config2, null, 2)}
28223
28233
  `);
28224
28234
  log(`[magic-context] added TUI plugin entry to ${configPath}`);
@@ -30194,7 +30204,7 @@ function createCompactionHandler() {
30194
30204
  init_logger();
30195
30205
  import { existsSync as existsSync5, readFileSync as readFileSync4 } from "fs";
30196
30206
  import { homedir as homedir5, platform as platform2 } from "os";
30197
- import { join as join10 } from "path";
30207
+ import { join as join11 } from "path";
30198
30208
  var cachedLimits = null;
30199
30209
  var lastLoadAttempt = 0;
30200
30210
  var RELOAD_INTERVAL_MS = 5 * 60 * 1000;
@@ -30205,11 +30215,11 @@ function getModelsJsonPath() {
30205
30215
  if (xdgCache) {
30206
30216
  cacheBase = xdgCache;
30207
30217
  } else if (os3 === "win32") {
30208
- cacheBase = process.env.LOCALAPPDATA ?? join10(homedir5(), "AppData", "Local");
30218
+ cacheBase = process.env.LOCALAPPDATA ?? join11(homedir5(), "AppData", "Local");
30209
30219
  } else {
30210
- cacheBase = join10(homedir5(), ".cache");
30220
+ cacheBase = join11(homedir5(), ".cache");
30211
30221
  }
30212
- return join10(cacheBase, "opencode", "models.json");
30222
+ return join11(cacheBase, "opencode", "models.json");
30213
30223
  }
30214
30224
  function loadModelsDevLimits() {
30215
30225
  const limits = new Map;
@@ -33801,7 +33811,7 @@ init_send_session_notification();
33801
33811
 
33802
33812
  // src/hooks/magic-context/system-prompt-hash.ts
33803
33813
  import { existsSync as existsSync6, readFileSync as readFileSync5, realpathSync } from "fs";
33804
- import { join as join13, resolve as resolve2, sep } from "path";
33814
+ import { join as join14, resolve as resolve2, sep } from "path";
33805
33815
 
33806
33816
  // src/agents/magic-context-prompt.ts
33807
33817
  function getToolHistoryGuidance(dropToolStructure) {
@@ -34021,7 +34031,7 @@ var DOC_FILES = ["ARCHITECTURE.md", "STRUCTURE.md"];
34021
34031
  function readProjectDocs(directory) {
34022
34032
  const sections = [];
34023
34033
  for (const filename of DOC_FILES) {
34024
- const filePath = join13(directory, filename);
34034
+ const filePath = join14(directory, filename);
34025
34035
  try {
34026
34036
  if (existsSync6(filePath)) {
34027
34037
  const content = readFileSync5(filePath, "utf-8").trim();
@@ -36035,19 +36045,19 @@ init_model_requirements();
36035
36045
 
36036
36046
  // src/shared/rpc-server.ts
36037
36047
  init_logger();
36038
- import { mkdirSync as mkdirSync3, renameSync, unlinkSync as unlinkSync2, writeFileSync as writeFileSync2 } from "fs";
36048
+ import { mkdirSync as mkdirSync4, renameSync, unlinkSync as unlinkSync2, writeFileSync as writeFileSync2 } from "fs";
36039
36049
  import { createServer } from "http";
36040
36050
  import { dirname } from "path";
36041
36051
 
36042
36052
  // src/shared/rpc-utils.ts
36043
36053
  import { createHash } from "crypto";
36044
- import { join as join14 } from "path";
36054
+ import { join as join15 } from "path";
36045
36055
  function projectHash(directory) {
36046
36056
  const normalized = directory.replace(/\/+$/, "");
36047
36057
  return createHash("sha256").update(normalized).digest("hex").slice(0, 16);
36048
36058
  }
36049
36059
  function rpcPortFilePath(storageDir, directory) {
36050
- return join14(storageDir, "rpc", projectHash(directory), "port");
36060
+ return join15(storageDir, "rpc", projectHash(directory), "port");
36051
36061
  }
36052
36062
 
36053
36063
  // src/shared/rpc-server.ts
@@ -36079,7 +36089,7 @@ class MagicContextRpcServer {
36079
36089
  this.server = server;
36080
36090
  try {
36081
36091
  const dir = dirname(this.portFilePath);
36082
- mkdirSync3(dir, { recursive: true });
36092
+ mkdirSync4(dir, { recursive: true });
36083
36093
  const tmpPath = `${this.portFilePath}.tmp`;
36084
36094
  writeFileSync2(tmpPath, String(this.port), "utf-8");
36085
36095
  renameSync(tmpPath, this.portFilePath);
package/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "@cortexkit/opencode-magic-context",
3
- "version": "0.8.8",
3
+ "version": "0.8.9",
4
4
  "type": "module",
5
5
  "description": "OpenCode plugin for Magic Context — cross-session memory and context management",
6
6
  "main": "dist/index.js",