@cortexkit/magic-context 0.27.3 → 0.29.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/dist/index.js +57 -1
- package/package.json +1 -1
package/dist/index.js
CHANGED
|
@@ -13647,6 +13647,12 @@ var init_read_session_db = __esm(async () => {
|
|
|
13647
13647
|
await init_sqlite();
|
|
13648
13648
|
});
|
|
13649
13649
|
|
|
13650
|
+
// ../plugin/src/shared/commit-detection.ts
|
|
13651
|
+
var HASH_HEX = "[0-9a-f]{7,12}", COMMIT_HASH_TEST_PATTERN;
|
|
13652
|
+
var init_commit_detection = __esm(() => {
|
|
13653
|
+
COMMIT_HASH_TEST_PATTERN = new RegExp(`\\b${HASH_HEX}\\b`, "i");
|
|
13654
|
+
});
|
|
13655
|
+
|
|
13650
13656
|
// ../../node_modules/.bun/ai-tokenizer@1.0.6/node_modules/ai-tokenizer/dist/index.js
|
|
13651
13657
|
function _typeof(o) {
|
|
13652
13658
|
"@babel/helpers - typeof";
|
|
@@ -146097,6 +146103,7 @@ var init_claude = __esm(() => {
|
|
|
146097
146103
|
// ../plugin/src/hooks/magic-context/read-session-formatting.ts
|
|
146098
146104
|
var tokenizer;
|
|
146099
146105
|
var init_read_session_formatting = __esm(() => {
|
|
146106
|
+
init_commit_detection();
|
|
146100
146107
|
init_dist5();
|
|
146101
146108
|
init_claude();
|
|
146102
146109
|
tokenizer = new src_default(exports_claude);
|
|
@@ -146132,6 +146139,13 @@ function isRecord2(value) {
|
|
|
146132
146139
|
return typeof value === "object" && value !== null && !Array.isArray(value);
|
|
146133
146140
|
}
|
|
146134
146141
|
|
|
146142
|
+
// ../plugin/src/hooks/magic-context/edit-marker.ts
|
|
146143
|
+
var PATH_KEYS, DIFF_KEYS;
|
|
146144
|
+
var init_edit_marker = __esm(() => {
|
|
146145
|
+
PATH_KEYS = new Set(["filePath", "file_path", "path"]);
|
|
146146
|
+
DIFF_KEYS = new Set(["oldString", "newString", "content", "old_string", "new_string"]);
|
|
146147
|
+
});
|
|
146148
|
+
|
|
146135
146149
|
// ../plugin/src/hooks/magic-context/tool-drop-target.ts
|
|
146136
146150
|
function hasMeaningfulPart(part) {
|
|
146137
146151
|
if (!isRecord2(part))
|
|
@@ -146177,6 +146191,7 @@ class ToolMutationBatch {
|
|
|
146177
146191
|
}
|
|
146178
146192
|
var IGNORE_PART_TYPES;
|
|
146179
146193
|
var init_tool_drop_target = __esm(() => {
|
|
146194
|
+
init_edit_marker();
|
|
146180
146195
|
init_tag_content_primitives();
|
|
146181
146196
|
IGNORE_PART_TYPES = new Set([
|
|
146182
146197
|
"thinking",
|
|
@@ -149339,7 +149354,7 @@ var init_storage_primers = __esm(() => {
|
|
|
149339
149354
|
// ../plugin/src/features/magic-context/storage-source.ts
|
|
149340
149355
|
var init_storage_source = () => {};
|
|
149341
149356
|
// ../plugin/src/features/magic-context/storage-tags.ts
|
|
149342
|
-
var insertTagStatements, updateTagStatusStatements, updateTagDropModeStatements, updateTagMessageIdStatements, getTagNumbersByMessageIdStatements, deleteTagsByMessageIdStatements, getMaxTagNumberBySessionStatements, getTagNumberByMessageIdStatements, updateTagByteSizeStatements, updateTagInputByteSizeStatements, updateTagTokenCountStatements, updateTagInputTokenCountStatements, getOwnerScopedToolTagNumbersStatements, getMinMessageTagNumberForRawIdStatements, getActiveTagsBySessionStatements, getMaxDroppedTagNumberStatements, getToolTagNumberByOwnerStatements, getNullOwnerToolTagStatements, adoptNullOwnerToolTagStatements, deleteToolTagsByOwnerStatements;
|
|
149357
|
+
var insertTagStatements, updateTagStatusStatements, updateTagDropModeStatements, updateTagMessageIdStatements, getTagNumbersByMessageIdStatements, deleteTagsByMessageIdStatements, getMaxTagNumberBySessionStatements, getTagNumberByMessageIdStatements, updateTagByteSizeStatements, updateTagInputByteSizeStatements, RECLAIM_HINT_EXCLUDED_TOOLS, RECLAIM_HINT_EXCLUDED_LIST, updateTagTokenCountStatements, updateTagInputTokenCountStatements, getOwnerScopedToolTagNumbersStatements, getMinMessageTagNumberForRawIdStatements, getActiveTagsBySessionStatements, getMaxDroppedTagNumberStatements, getToolTagNumberByOwnerStatements, getNullOwnerToolTagStatements, adoptNullOwnerToolTagStatements, deleteToolTagsByOwnerStatements;
|
|
149343
149358
|
var init_storage_tags = __esm(() => {
|
|
149344
149359
|
insertTagStatements = new WeakMap;
|
|
149345
149360
|
updateTagStatusStatements = new WeakMap;
|
|
@@ -149351,6 +149366,8 @@ var init_storage_tags = __esm(() => {
|
|
|
149351
149366
|
getTagNumberByMessageIdStatements = new WeakMap;
|
|
149352
149367
|
updateTagByteSizeStatements = new WeakMap;
|
|
149353
149368
|
updateTagInputByteSizeStatements = new WeakMap;
|
|
149369
|
+
RECLAIM_HINT_EXCLUDED_TOOLS = ["todowrite"];
|
|
149370
|
+
RECLAIM_HINT_EXCLUDED_LIST = RECLAIM_HINT_EXCLUDED_TOOLS.map((name2) => `'${name2.replace(/'/g, "''")}'`).join(", ");
|
|
149354
149371
|
updateTagTokenCountStatements = new WeakMap;
|
|
149355
149372
|
updateTagInputTokenCountStatements = new WeakMap;
|
|
149356
149373
|
getOwnerScopedToolTagNumbersStatements = new WeakMap;
|
|
@@ -149970,6 +149987,10 @@ function stripUnsafeProjectConfigFields(projectRaw) {
|
|
|
149970
149987
|
delete projectRaw.auto_update;
|
|
149971
149988
|
warnings.push("Ignoring auto_update from project config (security: this setting only honors user-level config).");
|
|
149972
149989
|
}
|
|
149990
|
+
if ("language" in projectRaw) {
|
|
149991
|
+
delete projectRaw.language;
|
|
149992
|
+
warnings.push("Ignoring language from project config (security: output language is a user-level setting).");
|
|
149993
|
+
}
|
|
149973
149994
|
if ("sqlite" in projectRaw) {
|
|
149974
149995
|
delete projectRaw.sqlite;
|
|
149975
149996
|
warnings.push("Ignoring sqlite.* from project config (security: SQLite cache/mmap PRAGMAs apply to the " + "process-global shared database handle; only user-level config may set them).");
|
|
@@ -164702,6 +164723,38 @@ var init_zod = __esm(() => {
|
|
|
164702
164723
|
init_external();
|
|
164703
164724
|
});
|
|
164704
164725
|
|
|
164726
|
+
// ../plugin/src/agents/language-directive.ts
|
|
164727
|
+
function resolveLanguageName(language) {
|
|
164728
|
+
const code = typeof language === "string" ? language.trim().toLowerCase() : "";
|
|
164729
|
+
if (!/^[a-z]{2}$/.test(code))
|
|
164730
|
+
return "";
|
|
164731
|
+
let english;
|
|
164732
|
+
try {
|
|
164733
|
+
english = ENGLISH_LANGUAGE_NAMES.of(code) ?? undefined;
|
|
164734
|
+
} catch {
|
|
164735
|
+
return "";
|
|
164736
|
+
}
|
|
164737
|
+
if (!english)
|
|
164738
|
+
return "";
|
|
164739
|
+
let endonym;
|
|
164740
|
+
try {
|
|
164741
|
+
endonym = new Intl.DisplayNames([code], { type: "language", fallback: "none" }).of(code) ?? undefined;
|
|
164742
|
+
} catch {
|
|
164743
|
+
endonym = undefined;
|
|
164744
|
+
}
|
|
164745
|
+
return endonym && endonym !== english ? `${english} (${endonym})` : english;
|
|
164746
|
+
}
|
|
164747
|
+
function isValidLanguageCode(language) {
|
|
164748
|
+
return resolveLanguageName(language) !== "";
|
|
164749
|
+
}
|
|
164750
|
+
var ENGLISH_LANGUAGE_NAMES;
|
|
164751
|
+
var init_language_directive = __esm(() => {
|
|
164752
|
+
ENGLISH_LANGUAGE_NAMES = new Intl.DisplayNames(["en"], {
|
|
164753
|
+
type: "language",
|
|
164754
|
+
fallback: "none"
|
|
164755
|
+
});
|
|
164756
|
+
});
|
|
164757
|
+
|
|
164705
164758
|
// ../plugin/src/features/magic-context/defaults.ts
|
|
164706
164759
|
var DEFAULT_PROTECTED_TAGS = 20;
|
|
164707
164760
|
|
|
@@ -164747,6 +164800,7 @@ function defaultTaskConfig(task) {
|
|
|
164747
164800
|
var DEFAULT_EXECUTE_THRESHOLD_PERCENTAGE = 65, EXECUTE_THRESHOLD_CAP_MESSAGE = "execute_threshold is capped at 80% for cache safety: a single large agent step can overflow the context window before Magic Context can compact between turns, forcing OpenCode's native compaction (hard to recover from). 80% also leaves headroom below the 85%/95% emergency bands. Use a value between 20 and 80.", DEFAULT_HISTORIAN_TIMEOUT_MS = 300000, DEFAULT_HISTORY_BUDGET_PERCENTAGE = 0.15, DEFAULT_LOCAL_EMBEDDING_MODEL = "Xenova/all-MiniLM-L6-v2", DreamingTaskSchema, PiThinkingLevelSchema, CronScheduleSchema, DreamTaskBaseConfigSchema, PromotionThresholdSchema, PrimerPromotionThresholdSchema, DreamTaskConfigSchema, ReviewUserMemoriesTaskConfigSchema, PromotePrimersTaskConfigSchema, DEFAULT_TASK_SCHEDULES2, DreamTasksSchema, DreamerConfigSchema, SidekickConfigSchema, HistorianConfigSchema, BaseEmbeddingConfigSchema, EmbeddingConfigSchema, MagicContextConfigSchema;
|
|
164748
164801
|
var init_magic_context = __esm(() => {
|
|
164749
164802
|
init_zod();
|
|
164803
|
+
init_language_directive();
|
|
164750
164804
|
init_cron();
|
|
164751
164805
|
init_task_registry();
|
|
164752
164806
|
init_agent_overrides();
|
|
@@ -164868,6 +164922,7 @@ var init_magic_context = __esm(() => {
|
|
|
164868
164922
|
MagicContextConfigSchema = exports_external.object({
|
|
164869
164923
|
enabled: exports_external.boolean().default(true).describe("Enable magic context (default: true)"),
|
|
164870
164924
|
auto_update: exports_external.boolean().optional().describe("Enable automatic npm self-update checks for the OpenCode plugin. Security: USER-only in config loader, so hostile project configs cannot suppress updates."),
|
|
164925
|
+
language: exports_external.string().trim().toLowerCase().refine((s) => isValidLanguageCode(s), 'language must be a 2-letter ISO 639-1 code (e.g. "tr", "es", "de")').optional().describe("Output language for Magic Context's generated content and guidance, as a " + '2-letter ISO 639-1 code (e.g. "tr", "es", "de", "ja", "pt"). When set, the ' + "historian, dreamer, sidekick, and the agent-guidance block instruct the model to " + "write its PROSE in this language while keeping all structural tokens (XML tags, " + "the five memory category names, code identifiers, file paths) in English. " + "USER-LEVEL ONLY (ignored in project config for security). Unset = today's " + "behavior (model mirrors the conversation; English scaffolding). Changing it " + "triggers one cache re-materialization; existing compartments/memories keep their " + "original language until naturally rewritten."),
|
|
164871
164926
|
ctx_reduce_enabled: exports_external.boolean().default(true).describe("When false, ctx_reduce tool is hidden, all nudges disabled, and prompt guidance about ctx_reduce stripped. Heuristic cleanup, compartments, memory, and other features still work. (default: true)"),
|
|
164872
164927
|
historian: HistorianConfigSchema.describe("Historian agent configuration (model, fallback_models, variant, temperature, maxTokens, permission, two_pass, etc.)"),
|
|
164873
164928
|
dreamer: DreamerConfigSchema.optional().describe("Dreamer agent + scheduling configuration (model, fallback_models, disable, schedule, tasks, etc.)"),
|
|
@@ -164905,6 +164960,7 @@ var init_magic_context = __esm(() => {
|
|
|
164905
164960
|
}).describe("Embedding provider configuration"),
|
|
164906
164961
|
temporal_awareness: exports_external.boolean().default(true).describe('Inject wall-clock gap markers (<!-- +Xm -->) between user messages where > 5 min elapsed since the previous message, and add start/end date attributes on compartments. Gives the agent a sense of session pacing and "how long ago" across multi-day sessions. Graduated from experimental.temporal_awareness; default: true (set false to opt out).'),
|
|
164907
164962
|
keep_subagents: exports_external.boolean().default(false).describe("Debug: keep the child sessions Magic Context spawns for its own subagents (historian, dreamer, sidekick, memory-migration) instead of deleting them on success. Useful for short-term inspection/data collection — their full transcript (prompt, tool calls, token usage, output) stays in the host session store. Kept sessions accumulate until manually cleared; leave false for normal use. Requires a restart to take effect."),
|
|
164963
|
+
smart_drops: exports_external.boolean().default(false).describe("Content-aware reclaim of provably-superseded tool output, layered on the existing execute-pass auto-drop. When on: superseded todowrite (keep newest 1), spent ctx_reduce (keep newest 5), and zero-value meta (bash_status, bash_kill, ctx_note read/dismiss) outputs are dropped; older edits to a file are compressed to a filePath-preserving marker while the newest edit per file stays full. Only acts on passes already busting the cache, so it never originates a cache bust. Honors the protected-tag reserve. Experimental: opt-in, default off until cache stability is proven; when off the wire is byte-identical to the positional-only reclaim. Requires a restart."),
|
|
164908
164964
|
caveman_text_compression: exports_external.object({
|
|
164909
164965
|
enabled: exports_external.boolean().default(false).describe("Apply deterministic caveman-style text compression to old conversation text. Only active when ctx_reduce_enabled=false. Compresses user/assistant text in oldest-first tiers: ultra (oldest 20%), full, lite, untouched (newest 40%)."),
|
|
164910
164966
|
min_chars: exports_external.number().min(100).max(1e4).default(500).describe("Text parts shorter than this (characters) stay untouched. Min 100, max 10000. Default: 500.")
|