@cortexkit/opencode-magic-context 0.49.100 → 0.49.103
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/agents/dreamer.d.ts +3 -2
- package/dist/agents/dreamer.d.ts.map +1 -1
- package/dist/agents/permissions.d.ts +2 -0
- package/dist/agents/permissions.d.ts.map +1 -1
- package/dist/agents/smart-notes-dreamer-gate.fixture.d.ts +3 -1
- package/dist/agents/smart-notes-dreamer-gate.fixture.d.ts.map +1 -1
- package/dist/auto-search-worker.js +5 -5
- package/dist/chunk-embedding-write-worker.js +1 -1
- package/dist/{context-k2tdh146.js → context-jk7bgc3s.js} +227 -43
- package/dist/{embedding-backfill-79br4kk6.js → embedding-backfill-anty7zdf.js} +3 -3
- package/dist/{embedding-cache-zn4r1c31.js → embedding-cache-dveynq4m.js} +1 -1
- package/dist/features/magic-context/dreamer/curate-memory-safety.d.ts +1 -0
- package/dist/features/magic-context/dreamer/curate-memory-safety.d.ts.map +1 -1
- package/dist/features/magic-context/dreamer/task-executor.d.ts.map +1 -1
- package/dist/features/magic-context/dreamer/task-prompts.d.ts +7 -1
- package/dist/features/magic-context/dreamer/task-prompts.d.ts.map +1 -1
- package/dist/features/magic-context/memory/storage-memory-embeddings.d.ts +2 -1
- package/dist/features/magic-context/memory/storage-memory-embeddings.d.ts.map +1 -1
- package/dist/features/magic-context/overflow-detection.d.ts.map +1 -1
- package/dist/features/magic-context/project-embedding-registry.d.ts +5 -2
- package/dist/features/magic-context/project-embedding-registry.d.ts.map +1 -1
- package/dist/hooks/magic-context/compartment-runner-historian.d.ts.map +1 -1
- package/dist/hooks/magic-context/compartment-runner-incremental.d.ts.map +1 -1
- package/dist/hooks/magic-context/host-served-rows.d.ts +7 -0
- package/dist/hooks/magic-context/host-served-rows.d.ts.map +1 -1
- package/dist/hooks/magic-context/transform.d.ts.map +1 -1
- package/dist/{index-zyb7tndy.js → index-3nxhxeeg.js} +5 -5
- package/dist/{index-esym6cw4.js → index-42fg6tzz.js} +3 -3
- package/dist/{index-z1hc2g06.js → index-4536jdzj.js} +2 -2
- package/dist/{index-mfx7hzyc.js → index-4dywj733.js} +1 -1
- package/dist/{index-63kp05sy.js → index-4v50y0jr.js} +1 -1
- package/dist/{index-zg5r2syy.js → index-6gd9akdt.js} +1 -1
- package/dist/{index-0tqhr9zs.js → index-6t6v8prs.js} +5 -5
- package/dist/{index-0eyxarpb.js → index-7jvc0rhh.js} +100 -28
- package/dist/{index-kjhgxkdx.js → index-9jqaha1g.js} +1 -1
- package/dist/{index-634cww4x.js → index-9mxkvdtp.js} +9 -9
- package/dist/{index-3cgh0ght.js → index-f455a0g3.js} +1 -1
- package/dist/{index-6hjbeeth.js → index-jg5whyrd.js} +4 -4
- package/dist/{index-qjcye18f.js → index-jjxpmypb.js} +3 -3
- package/dist/{index-e6s2jpr8.js → index-jyj9jg9f.js} +2 -2
- package/dist/{index-ajmy0v5j.js → index-ke0mkz7g.js} +13 -0
- package/dist/{index-txthzqrm.js → index-mes48s7a.js} +152 -75
- package/dist/{index-jjy4shhy.js → index-p8nc9axh.js} +1 -1
- package/dist/{index-9emdjcb5.js → index-pw1f07vg.js} +1 -1
- package/dist/{v2/server-qjwpqvnf.js → index-qbydvfev.js} +4 -3
- package/dist/{index-rjxg7a7m.js → index-qzfz2tvk.js} +5 -1
- package/dist/{index-n3tebmah.js → index-t2h3484a.js} +8 -8
- package/dist/{index-mhdavdd4.js → index-vhx6yph7.js} +11 -8
- package/dist/{index-rakm1eay.js → index-zh683xh2.js} +2 -2
- package/dist/index.d.ts.map +1 -1
- package/dist/index.js +43 -42
- package/dist/{message-index-bounded-289186ah.js → message-index-bounded-8s8sx40x.js} +3 -3
- package/dist/migration-worker.js +1 -1
- package/dist/plugin/dream-timer.d.ts.map +1 -1
- package/dist/plugin/subagent-tool-policy.d.ts.map +1 -1
- package/dist/plugin/tool-registry.d.ts.map +1 -1
- package/dist/{project-embedding-registry-xy8dcdys.js → project-embedding-registry-4cv7n37m.js} +2 -2
- package/dist/raw-ordinal-warmup-worker.js +4 -4
- package/dist/{read-session-chunk-frnwxnjg.js → read-session-chunk-wwg20mte.js} +2 -2
- package/dist/{recomp-orchestrator-e7n124g0.js → recomp-orchestrator-vg4cxyp7.js} +13 -13
- package/dist/{render-argap54x.js → render-f32trg2t.js} +7 -7
- package/dist/{search-archive-ads5mh9s.js → search-archive-yh6xtvrx.js} +5 -5
- package/dist/{search-fxtb4844.js → search-ygtyb91s.js} +11 -11
- package/dist/{storage-memory-hhrvfw0x.js → storage-memory-p91f7b5h.js} +2 -2
- package/dist/{storage-tags-2d2ba8e9.js → storage-tags-5nke1bdt.js} +1 -1
- package/dist/{store-reader-01e8t5j0.js → store-reader-c5fwa9qx.js} +1 -1
- package/dist/{store-235fjtsn.js → store-wpx314rk.js} +2 -2
- package/dist/tools/ctx-memory/constants.d.ts +2 -0
- package/dist/tools/ctx-memory/constants.d.ts.map +1 -1
- package/dist/tools/ctx-memory/tools.d.ts +1 -0
- package/dist/tools/ctx-memory/tools.d.ts.map +1 -1
- package/dist/tools/ctx-reduce/constants.d.ts.map +1 -1
- package/dist/{transform-postprocess-phase-2y0st4gk.js → transform-postprocess-phase-958fmjs5.js} +14 -14
- package/dist/v2/auto-search-worker.js +5 -5
- package/dist/v2/chunk-embedding-write-worker.js +1 -1
- package/dist/v2/{context-v56v40cx.js → context-3g3jvxg8.js} +347 -88
- package/dist/v2/{embedding-backfill-nhgp8znm.js → embedding-backfill-ra9gbbs4.js} +3 -3
- package/dist/v2/{embedding-cache-zn4r1c31.js → embedding-cache-dveynq4m.js} +1 -1
- package/dist/v2/fold/instruction-supersession.d.ts +18 -1
- package/dist/v2/fold/instruction-supersession.d.ts.map +1 -1
- package/dist/v2/hooks/context.d.ts +2 -1
- package/dist/v2/hooks/context.d.ts.map +1 -1
- package/dist/v2/hooks/hidden-child.d.ts.map +1 -1
- package/dist/v2/hooks/revert-message-state.d.ts +6 -0
- package/dist/v2/hooks/revert-message-state.d.ts.map +1 -1
- package/dist/v2/hooks/tools.d.ts.map +1 -1
- package/dist/v2/{message-index-bounded-p69v4wpy.js → message-index-bounded-j1sxtefe.js} +3 -3
- package/dist/v2/migration-worker.js +1 -1
- package/dist/v2/{project-embedding-registry-qz9x79kn.js → project-embedding-registry-gdaqb7h0.js} +2 -2
- package/dist/v2/raw-ordinal-warmup-worker.js +4 -4
- package/dist/v2/{read-session-chunk-qzw3vedr.js → read-session-chunk-p6z3kmdj.js} +2 -2
- package/dist/v2/{recomp-orchestrator-5gkzamy2.js → recomp-orchestrator-29m3cc5b.js} +12 -12
- package/dist/v2/{render-atxj9eaf.js → render-jpj43axy.js} +7 -7
- package/dist/v2/{search-archive-vgwnvdx2.js → search-archive-wbhxp0p1.js} +5 -5
- package/dist/v2/{search-51qr14ed.js → search-ybyc7vmx.js} +10 -10
- package/dist/v2/{server-bhr92yb4.js → server-1qxdyz4p.js} +2 -2
- package/dist/v2/{server-8vby30m5.js → server-8f92sd2r.js} +2 -2
- package/dist/v2/{server-08jh9wew.js → server-8m5wk6aq.js} +5 -5
- package/dist/v2/{server-606mnrv4.js → server-9ms9b75c.js} +5 -1
- package/dist/v2/{server-s3m2y97h.js → server-b01a7dhj.js} +1 -1
- package/dist/v2/{server-rwdp3hw6.js → server-df5scn4q.js} +71 -11
- package/dist/v2/{server-7wpw3wc6.js → server-fagcnt6j.js} +11 -8
- package/dist/v2/{server-b25nvm9c.js → server-ga6y57vh.js} +1 -1
- package/dist/v2/{server-2ek9exbe.js → server-kx5egpt7.js} +3 -3
- package/dist/v2/{server-e14d7ebh.js → server-mc5t7k8v.js} +1 -1
- package/dist/v2/{server-9emdjcb5.js → server-pw1f07vg.js} +1 -1
- package/dist/{index-qjwpqvnf.js → v2/server-qbydvfev.js} +4 -3
- package/dist/v2/{server-c1vcbszm.js → server-qdpd8h27.js} +1 -1
- package/dist/v2/{server-ysg14rv1.js → server-qg8jyfxa.js} +13 -0
- package/dist/v2/{server-d2a639dg.js → server-r851hxn5.js} +8 -8
- package/dist/v2/{server-p2wxmjc3.js → server-t45hgcsg.js} +2 -2
- package/dist/v2/{server-awth2wsg.js → server-x22jtpna.js} +1 -1
- package/dist/v2/{server-wdmcqhv6.js → server-xpy46ddq.js} +3 -3
- package/dist/v2/server.js +2 -2
- package/dist/v2/{storage-memory-hhrvfw0x.js → storage-memory-p91f7b5h.js} +2 -2
- package/dist/v2/{storage-tags-4t9fb4ch.js → storage-tags-s7nvvyg8.js} +1 -1
- package/dist/v2/{store-0kjfynwp.js → store-mba47sxn.js} +2 -2
- package/dist/v2/{store-reader-w0srb18d.js → store-reader-w7w8vfsy.js} +1 -1
- package/dist/v2/store-reader.d.ts +7 -0
- package/dist/v2/store-reader.d.ts.map +1 -1
- package/dist/v2/{v2-archive-reader-1wc5wb1a.js → v2-archive-reader-5njmg3a3.js} +1 -1
- package/dist/v2/{wrapup-orchestrator-ksdn2emb.js → wrapup-orchestrator-ahkq8a61.js} +12 -12
- package/dist/{v2-archive-reader-4pk46nc1.js → v2-archive-reader-y38khjax.js} +1 -1
- package/dist/{wrapup-orchestrator-sc2fsfct.js → wrapup-orchestrator-gjqaac65.js} +14 -14
- package/package.json +1 -1
- package/src/agents/dreamer.ts +3 -2
- package/src/agents/hidden-agent-registrations.ts +2 -2
- package/src/agents/permissions.test.ts +89 -3
- package/src/agents/permissions.ts +32 -0
- package/src/agents/smart-notes-dreamer-gate.fixture.ts +27 -4
- package/src/agents/smart-notes-dreamer-gate.test.ts +5 -1
|
@@ -99,6 +99,19 @@ import {
|
|
|
99
99
|
releaseGitSweepLease
|
|
100
100
|
} from "./index-fd3hkyk1.js";
|
|
101
101
|
import {
|
|
102
|
+
CTX_MEMORY_TOOL_NAME,
|
|
103
|
+
CTX_MEMORY_LIST_TOOL_NAME,
|
|
104
|
+
CTX_MEMORY_CURATE_TOOL_NAME,
|
|
105
|
+
CTX_MEMORY_LIST_DESCRIPTION,
|
|
106
|
+
CTX_MEMORY_DESCRIPTION,
|
|
107
|
+
DEFAULT_SEARCH_LIMIT,
|
|
108
|
+
DREAMER_AGENT,
|
|
109
|
+
DREAMER_RETROSPECTIVE_AGENT,
|
|
110
|
+
DREAMER_PRIMER_INVESTIGATOR_AGENT,
|
|
111
|
+
DREAMER_MEMORY_MAPPER_AGENT,
|
|
112
|
+
DREAMER_CLASSIFIER_AGENT,
|
|
113
|
+
DREAMER_DOCS_AGENT,
|
|
114
|
+
DREAMER_REVIEWER_AGENT,
|
|
102
115
|
getMagicContextBuiltinCommands,
|
|
103
116
|
formatConfigParseStatusLine,
|
|
104
117
|
isCommitRetentionPaused,
|
|
@@ -112,13 +125,6 @@ import {
|
|
|
112
125
|
producerInputTokenLimit,
|
|
113
126
|
historianProducerReserve,
|
|
114
127
|
producerPromptFailureReason,
|
|
115
|
-
DREAMER_AGENT,
|
|
116
|
-
DREAMER_RETROSPECTIVE_AGENT,
|
|
117
|
-
DREAMER_PRIMER_INVESTIGATOR_AGENT,
|
|
118
|
-
DREAMER_MEMORY_MAPPER_AGENT,
|
|
119
|
-
DREAMER_CLASSIFIER_AGENT,
|
|
120
|
-
DREAMER_DOCS_AGENT,
|
|
121
|
-
DREAMER_REVIEWER_AGENT,
|
|
122
128
|
createChildSessionWithFence,
|
|
123
129
|
HiddenCompletionRefusal,
|
|
124
130
|
DreamerProviderOutputFailureError,
|
|
@@ -213,7 +219,7 @@ import {
|
|
|
213
219
|
snapRangeToCompartments,
|
|
214
220
|
getActiveCompartmentRun,
|
|
215
221
|
startCompartmentAgent
|
|
216
|
-
} from "./index-
|
|
222
|
+
} from "./index-7jvc0rhh.js";
|
|
217
223
|
import {
|
|
218
224
|
formatWindowDerivationLine,
|
|
219
225
|
getSdkWindowGeometry,
|
|
@@ -371,7 +377,7 @@ import {
|
|
|
371
377
|
getTagsByNumbers2,
|
|
372
378
|
getDroppedTagsByNumbers2,
|
|
373
379
|
getMaxDroppedTagNumber2
|
|
374
|
-
} from "./index-
|
|
380
|
+
} from "./index-qzfz2tvk.js";
|
|
375
381
|
import {
|
|
376
382
|
BoundedSessionMap,
|
|
377
383
|
observeTemporalDecisions,
|
|
@@ -445,7 +451,7 @@ import {
|
|
|
445
451
|
readRawSessionMessageById2,
|
|
446
452
|
readSessionChunk2,
|
|
447
453
|
readRawSessionSeedTail2
|
|
448
|
-
} from "./index-
|
|
454
|
+
} from "./index-9jqaha1g.js";
|
|
449
455
|
import {
|
|
450
456
|
buildDreamTaskRuntimeConfigs2,
|
|
451
457
|
userMemoryCollectionEnabled2
|
|
@@ -469,7 +475,7 @@ import {
|
|
|
469
475
|
runSqliteOptimize,
|
|
470
476
|
openDatabase,
|
|
471
477
|
openCurrentDatabase
|
|
472
|
-
} from "./index-
|
|
478
|
+
} from "./index-f455a0g3.js";
|
|
473
479
|
import {
|
|
474
480
|
unescapeXml,
|
|
475
481
|
resolveWorkspaceShareCategories,
|
|
@@ -588,10 +594,10 @@ import {
|
|
|
588
594
|
GLOBAL_USER_PROFILE_PROJECT_PATH,
|
|
589
595
|
getProjectState,
|
|
590
596
|
bumpProjectUserProfileVersion
|
|
591
|
-
} from "./index-
|
|
597
|
+
} from "./index-4536jdzj.js";
|
|
592
598
|
import {
|
|
593
599
|
getLastIndexedOrdinal
|
|
594
|
-
} from "./index-
|
|
600
|
+
} from "./index-p8nc9axh.js";
|
|
595
601
|
import {
|
|
596
602
|
SESSION_NOTE_CONDITION_ERROR,
|
|
597
603
|
getNoteByIdInScope,
|
|
@@ -645,18 +651,17 @@ import {
|
|
|
645
651
|
embedTextForProject2,
|
|
646
652
|
embedBatchForProject2,
|
|
647
653
|
countUnembeddedMemoriesForProject2,
|
|
648
|
-
embedUnembeddedMemoriesForProject2,
|
|
649
654
|
embedUnembeddedMemoriesForProjectOutcome2,
|
|
650
655
|
drainCommitBacklogForProject2,
|
|
651
656
|
embedSessionCompartmentChunks2,
|
|
652
657
|
getEmbeddingCoverageStatus2,
|
|
653
658
|
getAutoEmbeddingSessionCoverage2
|
|
654
|
-
} from "./index-
|
|
659
|
+
} from "./index-vhx6yph7.js";
|
|
655
660
|
import {
|
|
656
661
|
saveEmbeddingIfHashMatches,
|
|
657
662
|
invalidateProject2,
|
|
658
663
|
invalidateMemory2
|
|
659
|
-
} from "./index-
|
|
664
|
+
} from "./index-qbydvfev.js";
|
|
660
665
|
import {
|
|
661
666
|
renderUserFacingFailure,
|
|
662
667
|
userFacingFailureCode,
|
|
@@ -677,7 +682,7 @@ import {
|
|
|
677
682
|
readGitFileChangeTimesSince,
|
|
678
683
|
verificationFileExists,
|
|
679
684
|
normalizeVerificationFiles
|
|
680
|
-
} from "./index-
|
|
685
|
+
} from "./index-42fg6tzz.js";
|
|
681
686
|
import {
|
|
682
687
|
computeCueContentHash,
|
|
683
688
|
hasMuralCueColumns,
|
|
@@ -704,7 +709,7 @@ import {
|
|
|
704
709
|
archiveMemory2,
|
|
705
710
|
getMemoryCount2,
|
|
706
711
|
getMemoryCountsByStatus2
|
|
707
|
-
} from "./index-
|
|
712
|
+
} from "./index-pw1f07vg.js";
|
|
708
713
|
import {
|
|
709
714
|
renderSingleStoreMigrationRequiredRefusal,
|
|
710
715
|
SingleStoreMigrationRequiredError,
|
|
@@ -725,13 +730,13 @@ import {
|
|
|
725
730
|
resolveMemoriesByIdsForSearch2,
|
|
726
731
|
unifiedSearch2,
|
|
727
732
|
formatSearchResults2
|
|
728
|
-
} from "./index-
|
|
733
|
+
} from "./index-9mxkvdtp.js";
|
|
729
734
|
import {
|
|
730
735
|
scheduleReconciliation,
|
|
731
736
|
scheduleIncrementalIndex,
|
|
732
737
|
getMessageIndexQueueHeapStats,
|
|
733
738
|
clearSessionTracking
|
|
734
|
-
} from "./index-
|
|
739
|
+
} from "./index-4v50y0jr.js";
|
|
735
740
|
import {
|
|
736
741
|
resolveModelCacheTtl,
|
|
737
742
|
resolveContextWindowGeometry,
|
|
@@ -830,7 +835,7 @@ import {
|
|
|
830
835
|
abortSessionFailClosed2,
|
|
831
836
|
evaluateEmergencyFailClosed2,
|
|
832
837
|
runPostTransformPhase2
|
|
833
|
-
} from "./index-
|
|
838
|
+
} from "./index-t2h3484a.js";
|
|
834
839
|
import {
|
|
835
840
|
flushIgnoredMessages2,
|
|
836
841
|
clearIgnoredMessages2,
|
|
@@ -840,7 +845,7 @@ import {
|
|
|
840
845
|
import {
|
|
841
846
|
setRecompStarting2,
|
|
842
847
|
setRecompTerminal2
|
|
843
|
-
} from "./index-
|
|
848
|
+
} from "./index-jg5whyrd.js";
|
|
844
849
|
import {
|
|
845
850
|
ANNOUNCEMENT_VERSION2,
|
|
846
851
|
ANNOUNCEMENT_FEATURES2,
|
|
@@ -855,14 +860,14 @@ import {
|
|
|
855
860
|
renderMessageByOrdinal2,
|
|
856
861
|
renderVerboseRangeForTool2,
|
|
857
862
|
renderItemByTag2
|
|
858
|
-
} from "./index-
|
|
863
|
+
} from "./index-zh683xh2.js";
|
|
859
864
|
import {
|
|
860
865
|
readV2ArchiveOffThread2
|
|
861
|
-
} from "./index-
|
|
866
|
+
} from "./index-3nxhxeeg.js";
|
|
862
867
|
import {
|
|
863
868
|
unresolvedLiveTailRefusal2,
|
|
864
869
|
renderSearchArchiveOffThread2
|
|
865
|
-
} from "./index-
|
|
870
|
+
} from "./index-jjxpmypb.js";
|
|
866
871
|
import {
|
|
867
872
|
takeCoveredInstructionRows,
|
|
868
873
|
cloneKeepingCoveredInstructionMarks
|
|
@@ -969,14 +974,16 @@ Project memory uses exactly 5 categories. Every memory belongs to one:
|
|
|
969
974
|
- **NAMING** — naming conventions and canonical names. Not inventories.
|
|
970
975
|
|
|
971
976
|
**Legacy categories during transition:** older memories may still carry pre-v2 category names. When you touch one, map it to its 5-category home with \`action="update"\` (or \`merge\`): WORKFLOW_RULES→PROJECT_RULES, ARCHITECTURE_DECISIONS→ARCHITECTURE, CONFIG_DEFAULTS→CONFIG_VALUES, ENVIRONMENT→CONFIG_VALUES (paths) or CONSTRAINTS, KNOWN_ISSUES→CONSTRAINTS only if it's an external-system limit. USER_DIRECTIVES / USER_PREFERENCES are NOT project categories. Do not compare project memories with the global user profile or use it to justify an archive.`;
|
|
972
|
-
|
|
977
|
+
function buildCurateSystemPrompt(memoryTool) {
|
|
978
|
+
const example = (args) => memoryTool === CTX_MEMORY_TOOL_NAME ? args : `${memoryTool}(${args})`;
|
|
979
|
+
return `You are a memory-pool curator for the magic-context system. You run during a scheduled dream window to keep a project's cross-session memory store lean and well-formed.
|
|
973
980
|
|
|
974
981
|
## Memory operations
|
|
975
982
|
- The scoped category snapshot arrives in the first message. Do not list or get it again; track mutation deltas.
|
|
976
|
-
-
|
|
977
|
-
-
|
|
978
|
-
-
|
|
979
|
-
-
|
|
983
|
+
- \`${example('action="merge", ids=[N,M,...], content="...", category="..."')}\` — consolidate duplicates into one canonical memory
|
|
984
|
+
- \`${example('action="update", ids=[N], content="...", superseded_by=M')}\` — rewrite content; name where removed detail survives when cutting more than half
|
|
985
|
+
- \`${example('action="write", category="...", content="..."')}\` — create a memory (SPLITS ONLY — never mint new facts)
|
|
986
|
+
- \`${example('action="archive", ids=[N], superseded_by=M, reason="..."')}\` — consolidate a redundant memory into the named active same-category survivor
|
|
980
987
|
|
|
981
988
|
## Rules
|
|
982
989
|
1. **Assume the pool is accurate.** A separate verify task checks memories against code. You handle QUALITY only — duplicates, wording, low-value entries — never correctness, and you do NOT read the codebase.
|
|
@@ -987,6 +994,8 @@ var CURATE_SYSTEM_PROMPT = `You are a memory-pool curator for the magic-context
|
|
|
987
994
|
6. **Never mint new facts** — that is the historian's job. \`write\` is for splitting a compound memory only.
|
|
988
995
|
|
|
989
996
|
${PROJECT_MEMORY_TAXONOMY}`;
|
|
997
|
+
}
|
|
998
|
+
var CURATE_SYSTEM_PROMPT = buildCurateSystemPrompt(CTX_MEMORY_CURATE_TOOL_NAME);
|
|
990
999
|
var MAINTAIN_DOCS_SYSTEM_PROMPT = `You are a read-only documentation investigator for the magic-context system. Use read, grep, glob and navigation tools to verify source. Never edit any file or run commands. Return only a proposed change to the project's ARCHITECTURE.md and STRUCTURE.md, not a change log. The protected regions between <!-- mc:protected START ... --> and <!-- mc:protected END --> must remain byte-identical. If the docs are accurate, return [].`;
|
|
991
1000
|
var REVIEW_USER_MEMORIES_SYSTEM_PROMPT = `You are a user-profile reviewer for the magic-context system. You run during a scheduled dream window to decide which recurring behavioral observations about the human user are real, persistent patterns worth keeping in their global user profile.
|
|
992
1001
|
|
|
@@ -1021,7 +1030,7 @@ The memories below are assumed ACCURATE (a separate verify task keeps them true)
|
|
|
1021
1030
|
Work ALL THREE phases below in order (A → B → C) over this category. Do NOT stop after consolidating — a run that only merges and never improves or archives is incomplete.
|
|
1022
1031
|
|
|
1023
1032
|
### Phase A — Consolidate duplicates
|
|
1024
|
-
Group by category, then merge near-identical / superset-subset / same-fact-different-angle clusters into one canonical memory with
|
|
1033
|
+
Group by category, then merge near-identical / superset-subset / same-fact-different-angle clusters into one canonical memory with \`${args.memoryTool ?? CTX_MEMORY_CURATE_TOOL_NAME}(action="merge", ids=[...], content="...", category="...")\`. Preserve every unique detail; terse present tense; paths/keys verbatim. Every id in a merge MUST share the same category — the system rejects cross-category merges. If two similar memories sit in different categories they are NOT duplicates; do not archive either as a consolidation. One fact per memory.
|
|
1025
1034
|
|
|
1026
1035
|
### Phase B — Improve wording
|
|
1027
1036
|
Rewrite narrative/historical → operational present tense ("X uses Y because Z", not "we switched to Y"); drop session-local context and commit hashes (unless the hash is the point); add specifics where vague. A rewrite that removes more than half the content must name the active same-category memory preserving that detail with \`superseded_by\`. \`write\` is for SPLITS ONLY (update the original down to its first fact, write the second) — a healthy run is net-neutral or net-shrinking, never net-adds facts.
|
|
@@ -1150,7 +1159,8 @@ function buildDreamTaskPrompt(task, args) {
|
|
|
1150
1159
|
projectPath: args.projectPath,
|
|
1151
1160
|
category: args.curate?.category ?? "PROJECT_RULES",
|
|
1152
1161
|
memories: args.curate?.memories ?? [],
|
|
1153
|
-
crossChunkCandidates: args.curate?.crossChunkCandidates
|
|
1162
|
+
crossChunkCandidates: args.curate?.crossChunkCandidates,
|
|
1163
|
+
memoryTool: args.curate?.memoryTool
|
|
1154
1164
|
});
|
|
1155
1165
|
case "maintain-docs":
|
|
1156
1166
|
return buildMaintainDocsPrompt(args.projectPath, args.docsChangeSet ?? "", args.existingDocs ?? { architecture: false, structure: false }, args.docsBudget, args.docsCurrentTokens, args.docsContents);
|
|
@@ -4128,7 +4138,8 @@ var refusalReasons = new Set(CURATE_SAFETY_REFUSAL_REASONS);
|
|
|
4128
4138
|
function parseCurateSafetyRefusal(action, output) {
|
|
4129
4139
|
if (action !== "archive" && action !== "update")
|
|
4130
4140
|
return null;
|
|
4131
|
-
const refusal = /^Skipped (archive|update) for memory \[ID: -?\d+(?:, -?\d+)*\]: curate safety refusal \(([a-z,-]+)\); refused=[1-9]\d*\.$/.exec(output
|
|
4141
|
+
const refusal = /^Skipped (archive|update) for memory \[ID: -?\d+(?:, -?\d+)*\]: curate safety refusal \(([a-z,-]+)\); refused=[1-9]\d*\.$/.exec(output.split(`
|
|
4142
|
+
`, 1)[0] ?? "");
|
|
4132
4143
|
if (refusal?.[1] !== action || !refusal[2])
|
|
4133
4144
|
return null;
|
|
4134
4145
|
const reasons = [...new Set(refusal[2].split(","))];
|
|
@@ -4179,14 +4190,20 @@ function assessCurateMutationSafety(args) {
|
|
|
4179
4190
|
return null;
|
|
4180
4191
|
}
|
|
4181
4192
|
function recordCurateSafetyRefusal(sessionId, refusal) {
|
|
4182
|
-
const
|
|
4183
|
-
|
|
4193
|
+
const counts = refusalCountsBySession.get(sessionId) ?? { total: 0, byMemory: new Map };
|
|
4194
|
+
const forMemory = (counts.byMemory.get(refusal.memoryId) ?? 0) + 1;
|
|
4195
|
+
counts.byMemory.set(refusal.memoryId, forMemory);
|
|
4196
|
+
const count = ++counts.total;
|
|
4197
|
+
refusalCountsBySession.set(sessionId, counts);
|
|
4184
4198
|
const lengths = refusal.originalChars === undefined ? "" : ` original_chars=${refusal.originalChars} replacement_chars=${refusal.replacementChars ?? 0}`;
|
|
4185
4199
|
log2(`[dreamer] curate safety refusal: session_id=${sessionId} memory_id=${refusal.memoryId} verdict=${refusal.verdict} reason=${refusal.reason}${lengths} refused=${count}`);
|
|
4186
4200
|
return count;
|
|
4187
4201
|
}
|
|
4202
|
+
function curateSafetyRefusalsForMemory(sessionId, memoryId) {
|
|
4203
|
+
return refusalCountsBySession.get(sessionId)?.byMemory.get(memoryId) ?? 0;
|
|
4204
|
+
}
|
|
4188
4205
|
function takeCurateSafetyRefusalCount(sessionId) {
|
|
4189
|
-
const count = refusalCountsBySession.get(sessionId) ?? 0;
|
|
4206
|
+
const count = refusalCountsBySession.get(sessionId)?.total ?? 0;
|
|
4190
4207
|
refusalCountsBySession.delete(sessionId);
|
|
4191
4208
|
return count;
|
|
4192
4209
|
}
|
|
@@ -10198,7 +10215,7 @@ function inspectCurateMemoryOperations(messages) {
|
|
|
10198
10215
|
if (!isRecord(part) || part.type !== "tool")
|
|
10199
10216
|
continue;
|
|
10200
10217
|
const toolName = part.tool ?? part.name;
|
|
10201
|
-
if (toolName !==
|
|
10218
|
+
if (toolName !== CTX_MEMORY_TOOL_NAME && toolName !== CTX_MEMORY_CURATE_TOOL_NAME)
|
|
10202
10219
|
continue;
|
|
10203
10220
|
const state = isRecord(part.state) ? part.state : null;
|
|
10204
10221
|
const input = isRecord(state?.input) ? state.input : null;
|
|
@@ -11370,6 +11387,9 @@ async function runAgenticTask(config, ctx, helpers) {
|
|
|
11370
11387
|
const curateChunks = curateMemories ? chunkCurateMemories(curateMemories, Math.max(4000, Math.floor(resolveRetrospectiveUsableInputTokens(config, deps) * 2))) : [];
|
|
11371
11388
|
const batches = task === "curate" ? curateChunks : [{ memories: [], crossChunkCandidates: [] }];
|
|
11372
11389
|
const curateOperations = emptyCurateMemoryOperations();
|
|
11390
|
+
const harness = getHarness2();
|
|
11391
|
+
const curateMemoryTool = harness === "pi" || harness === "omp" ? CTX_MEMORY_TOOL_NAME : CTX_MEMORY_CURATE_TOOL_NAME;
|
|
11392
|
+
const taskSystemPrompt = task === "maintain-docs" ? MAINTAIN_DOCS_SYSTEM_PROMPT : buildCurateSystemPrompt(curateMemoryTool);
|
|
11373
11393
|
let curateRefused = 0;
|
|
11374
11394
|
let run = {
|
|
11375
11395
|
output: [],
|
|
@@ -11390,7 +11410,8 @@ async function runAgenticTask(config, ctx, helpers) {
|
|
|
11390
11410
|
curate: curateMemories && curateCategory ? {
|
|
11391
11411
|
category: curateCategory,
|
|
11392
11412
|
memories: batch.memories,
|
|
11393
|
-
crossChunkCandidates: batch.crossChunkCandidates
|
|
11413
|
+
crossChunkCandidates: batch.crossChunkCandidates,
|
|
11414
|
+
memoryTool: curateMemoryTool
|
|
11394
11415
|
} : undefined
|
|
11395
11416
|
});
|
|
11396
11417
|
if (deps.hiddenCompletionExecutor) {
|
|
@@ -11399,7 +11420,7 @@ async function runAgenticTask(config, ctx, helpers) {
|
|
|
11399
11420
|
parentSessionId: parent ?? undefined,
|
|
11400
11421
|
sessionDirectory: docsDir,
|
|
11401
11422
|
agent: task === "maintain-docs" ? DREAMER_DOCS_AGENT : DREAMER_AGENT,
|
|
11402
|
-
system:
|
|
11423
|
+
system: taskSystemPrompt,
|
|
11403
11424
|
prompt: taskPrompt,
|
|
11404
11425
|
title: `magic-context-dream-${task}`,
|
|
11405
11426
|
callContext: `dreamer:${task}`,
|
|
@@ -11446,7 +11467,7 @@ async function runAgenticTask(config, ctx, helpers) {
|
|
|
11446
11467
|
query: { directory: docsDir },
|
|
11447
11468
|
body: {
|
|
11448
11469
|
agent: task === "maintain-docs" ? DREAMER_DOCS_AGENT : DREAMER_AGENT,
|
|
11449
|
-
system: task === "maintain-docs" ?
|
|
11470
|
+
system: task === "maintain-docs" ? taskSystemPrompt : withContentLanguageDirective(taskSystemPrompt, config.language ?? deps.language),
|
|
11450
11471
|
...modelBodyField(config.model),
|
|
11451
11472
|
parts: [{ type: "text", text: taskPrompt, synthetic: true }]
|
|
11452
11473
|
}
|
|
@@ -12030,6 +12051,7 @@ function logEmptyIdentityRefusalOnce(directory) {
|
|
|
12030
12051
|
log2(`[dreamer] not registering ${directory}: it has no project identity, so no project-scoped work runs for it`);
|
|
12031
12052
|
}
|
|
12032
12053
|
var registeredProjects = new Map;
|
|
12054
|
+
var lastMemoryEmbeddingSkip = new WeakMap;
|
|
12033
12055
|
function stopDreamScheduleTimerIfIdle() {
|
|
12034
12056
|
if (registeredProjects.size !== 0)
|
|
12035
12057
|
return;
|
|
@@ -12069,6 +12091,8 @@ async function startDreamScheduleTimer(args) {
|
|
|
12069
12091
|
}
|
|
12070
12092
|
}
|
|
12071
12093
|
registeredProjects.set(args.directory, args);
|
|
12094
|
+
if (previousRegistration !== args)
|
|
12095
|
+
lastMemoryEmbeddingSkip.delete(args);
|
|
12072
12096
|
if (isNewRegistration) {
|
|
12073
12097
|
log2(`[dreamer] registered project ${args.projectIdentity} (dreaming=${dreamingEnabled} embeddings=${embeddingSweepEnabled} commits=${commitIndexingEnabled}; total=${registeredProjects.size})`);
|
|
12074
12098
|
}
|
|
@@ -12220,17 +12244,51 @@ async function runProjectMaintenance(reg, origin, db) {
|
|
|
12220
12244
|
const sampled = reg.sampleDreamRun?.();
|
|
12221
12245
|
const current = sampled ? { ...reg, ...sampled } : reg;
|
|
12222
12246
|
const projectMaintenanceEnabled = Boolean(current.dreamerConfig && current.dreamerConfig.disable !== true) || reg.memoryEnabled === true || current.gitCommitIndexing?.enabled === true || reg.historianChildSweep !== undefined;
|
|
12223
|
-
if (!projectMaintenanceEnabled)
|
|
12247
|
+
if (!projectMaintenanceEnabled) {
|
|
12248
|
+
logMemoryEmbeddingOutcome(reg, { kind: "disabled" });
|
|
12224
12249
|
return;
|
|
12250
|
+
}
|
|
12225
12251
|
await reg.ensureRegistered(reg.directory, db);
|
|
12226
12252
|
const memorySnapshot = getProjectEmbeddingSnapshot2(reg.projectIdentity);
|
|
12227
|
-
|
|
12228
|
-
|
|
12229
|
-
|
|
12230
|
-
|
|
12253
|
+
const outcome = memorySnapshot?.enabled ? await embedUnembeddedMemoriesForProjectOutcome2(db, reg.projectIdentity) : { kind: "disabled" };
|
|
12254
|
+
logMemoryEmbeddingOutcome(reg, outcome);
|
|
12255
|
+
await sweepProject(current, origin, db, current.gitCommitIndexing?.enabled === true);
|
|
12256
|
+
}
|
|
12257
|
+
function logMemoryEmbeddingOutcome(reg, outcome) {
|
|
12258
|
+
let reason;
|
|
12259
|
+
let missingCount;
|
|
12260
|
+
switch (outcome.kind) {
|
|
12261
|
+
case "done":
|
|
12262
|
+
reason = "nothing missing";
|
|
12263
|
+
break;
|
|
12264
|
+
case "disabled":
|
|
12265
|
+
reason = "embedding disabled";
|
|
12266
|
+
break;
|
|
12267
|
+
case "unavailable":
|
|
12268
|
+
reason = outcome.reason === "busy" ? "a session is busy" : "provider unavailable";
|
|
12269
|
+
missingCount = outcome.missingCount;
|
|
12270
|
+
break;
|
|
12271
|
+
case "embedded": {
|
|
12272
|
+
const { count } = outcome;
|
|
12273
|
+
if (count > 0) {
|
|
12274
|
+
lastMemoryEmbeddingSkip.delete(reg);
|
|
12275
|
+
log2(`[magic-context] proactively embedded ${count} ${count === 1 ? "memory" : "memories"} for project ${reg.projectIdentity}`);
|
|
12276
|
+
return;
|
|
12277
|
+
}
|
|
12278
|
+
reason = "no vectors saved";
|
|
12279
|
+
missingCount = outcome.missingCount;
|
|
12280
|
+
break;
|
|
12231
12281
|
}
|
|
12282
|
+
case "failed":
|
|
12283
|
+
lastMemoryEmbeddingSkip.delete(reg);
|
|
12284
|
+
return;
|
|
12232
12285
|
}
|
|
12233
|
-
|
|
12286
|
+
const missing = missingCount === undefined ? "" : ` (${missingCount} missing at check)`;
|
|
12287
|
+
const line = `[magic-context] proactive memory embedding skipped for project ${reg.projectIdentity}: ${reason}${missing}`;
|
|
12288
|
+
if (line === lastMemoryEmbeddingSkip.get(reg))
|
|
12289
|
+
return;
|
|
12290
|
+
log2(line);
|
|
12291
|
+
lastMemoryEmbeddingSkip.set(reg, line);
|
|
12234
12292
|
}
|
|
12235
12293
|
async function sweepProject(reg, origin, db, gitCommitEnabled) {
|
|
12236
12294
|
if (!directoryStillExists(reg.directory)) {
|
|
@@ -16466,7 +16524,7 @@ function registerRpcHandlers(rpcServer, args) {
|
|
|
16466
16524
|
const db = readDatabase();
|
|
16467
16525
|
if (!db)
|
|
16468
16526
|
return { ok: false, error: "db unavailable" };
|
|
16469
|
-
const { runManagedRecomp } = await importPluginModule(() => import("./recomp-orchestrator-
|
|
16527
|
+
const { runManagedRecomp } = await importPluginModule(() => import("./recomp-orchestrator-vg4cxyp7.js"));
|
|
16470
16528
|
const { sendIgnoredMessage } = await importPluginModule(() => import("./send-session-notification-tfhs4dbc.js"));
|
|
16471
16529
|
log2(`[rpc] recomp requested for session ${sessionId}`);
|
|
16472
16530
|
if (!args.client && !args.hiddenCompletionExecutor) {
|
|
@@ -16551,7 +16609,7 @@ function registerRpcHandlers(rpcServer, args) {
|
|
|
16551
16609
|
const db = readDatabase();
|
|
16552
16610
|
if (!db)
|
|
16553
16611
|
return { ok: false, error: "db unavailable" };
|
|
16554
|
-
const { runManagedWrapup } = await importPluginModule(() => import("./wrapup-orchestrator-
|
|
16612
|
+
const { runManagedWrapup } = await importPluginModule(() => import("./wrapup-orchestrator-gjqaac65.js"));
|
|
16555
16613
|
const model = await args.readSelectedSessionModel?.(sessionId) ?? liveSessionState.liveModelBySession.get(sessionId);
|
|
16556
16614
|
const window = resolveOpenCodeWrapupWindow(db, sessionId, model);
|
|
16557
16615
|
if (!window)
|
|
@@ -26949,6 +27007,7 @@ ${notice}`, notificationParams));
|
|
|
26949
27007
|
}
|
|
26950
27008
|
}
|
|
26951
27009
|
reclaim?.markRetired();
|
|
27010
|
+
reclaim?.settle?.();
|
|
26952
27011
|
const signedThinkingServed = isPrefixBoundThinkingModel(modelForBudget?.providerID, modelForBudget?.modelID) && servesThinkingBlock2(messages, modelForBudget?.providerID, modelForBudget?.modelID);
|
|
26953
27012
|
finishSystemDateRefresh(deps.historyRefreshSessions, dateRequest, postTransformResult.bustedThisPass && !activeThinkingPrefixHold && !signedThinkingServed || postTransformResult.thinkingReleasedForFit === true, signedThinkingServed);
|
|
26954
27013
|
if (activeThinkingPrefixHold && !postTransformResult.thinkingReleasedForFit && sessionMeta.cachedM0Bytes != null && sessionMeta.cachedM1Bytes != null) {
|
|
@@ -28312,7 +28371,7 @@ function truncateError(name, code, message, maxLen = 240) {
|
|
|
28312
28371
|
}
|
|
28313
28372
|
|
|
28314
28373
|
// src/plugin/subagent-tool-policy.ts
|
|
28315
|
-
var PRIMARY_ONLY_TOOLS = new Set(["ctx_memory", "ctx_note"]);
|
|
28374
|
+
var PRIMARY_ONLY_TOOLS = new Set(["ctx_memory", "ctx_note", CTX_MEMORY_CURATE_TOOL_NAME]);
|
|
28316
28375
|
function primaryOnlyToolIds(existing = []) {
|
|
28317
28376
|
return [...new Set([...existing, ...PRIMARY_ONLY_TOOLS])];
|
|
28318
28377
|
}
|
|
@@ -28605,23 +28664,6 @@ function createCtxExpandTools(deps) {
|
|
|
28605
28664
|
ctx_expand: createCtxExpandTool(deps)
|
|
28606
28665
|
};
|
|
28607
28666
|
}
|
|
28608
|
-
// src/tools/ctx-memory/constants.ts
|
|
28609
|
-
var CTX_MEMORY_TOOL_NAME = "ctx_memory";
|
|
28610
|
-
var CTX_MEMORY_LIST_TOOL_NAME = "ctx_memory_list";
|
|
28611
|
-
var CTX_MEMORY_LIST_DESCRIPTION = "Browse active memories, optionally filter by category.";
|
|
28612
|
-
var CTX_MEMORY_DESCRIPTION = `Durable facts about this project, shared with every agent working on it and kept for the months this work lasts.
|
|
28613
|
-
|
|
28614
|
-
Your active memories are already in <project-memory> as \`#id: fact\` lines. Write one when you learn something that must not have to be found again — a project rule, an architectural fact, a hard-won constraint, a config value, a naming convention — and especially when it cost you turns to find. One standalone fact per memory, phrased to make sense on its own. A pending intention with its evidence ("do X later, here is what we know") is ctx_note, not memory.
|
|
28615
|
-
|
|
28616
|
-
Actions:
|
|
28617
|
-
- write: new memory (content + category).
|
|
28618
|
-
- update: rewrite one memory whose fact changed (ids: [one], content; category: the current one to keep, a new one to recategorize).
|
|
28619
|
-
- archive: retire wrong or obsolete memories (ids: [one or more], optional reason).
|
|
28620
|
-
- merge: collapse duplicates into one (ids: [two or more distinct ids of memories in the same category], content).
|
|
28621
|
-
- get: fetch by id (ids: 1–20), readable in every status.
|
|
28622
|
-
The call form that works on every host sends action, content, category and ids every time: argument-dropping providers only emit required fields. For get and archive pass content="" and any valid category; for write pass ids=[].
|
|
28623
|
-
Examples: category="CONFIG_VALUES", content="OpenCode source is at ~/Work/OSS/opencode" · category="CONSTRAINTS", content="Dashboard Tauri build needs RGBA PNGs, not grayscale"`;
|
|
28624
|
-
var DEFAULT_SEARCH_LIMIT = 10;
|
|
28625
28667
|
// src/tools/ctx-memory/tools.ts
|
|
28626
28668
|
import { tool as tool2 } from "@opencode-ai/plugin";
|
|
28627
28669
|
|
|
@@ -28838,13 +28880,28 @@ function preflightCurateMutation(args) {
|
|
|
28838
28880
|
if (refusals.length === 0)
|
|
28839
28881
|
return { skip: null, successor };
|
|
28840
28882
|
let refused = 0;
|
|
28883
|
+
let steer = false;
|
|
28884
|
+
const leaveAlone = [];
|
|
28841
28885
|
for (const refusal of refusals) {
|
|
28842
28886
|
refused = recordCurateSafetyRefusal(args.sessionId, refusal);
|
|
28887
|
+
if (curateSafetyRefusalsForMemory(args.sessionId, refusal.memoryId) >= 3) {
|
|
28888
|
+
leaveAlone.push(refusal.memoryId);
|
|
28889
|
+
} else if (args.toolName === CTX_MEMORY_TOOL_NAME && params.superseded_by === undefined && (refusal.reason === "missing-active-same-category-successor" || refusal.reason === "content-loss")) {
|
|
28890
|
+
steer = true;
|
|
28891
|
+
}
|
|
28843
28892
|
}
|
|
28844
28893
|
const memoryIds = refusals.map((refusal) => refusal.memoryId).join(", ");
|
|
28845
28894
|
const reasons = [...new Set(refusals.map((refusal) => refusal.reason))].join(",");
|
|
28895
|
+
const guidance = [
|
|
28896
|
+
...steer ? [`Use ${CTX_MEMORY_CURATE_TOOL_NAME} to name the survivor with superseded_by.`] : [],
|
|
28897
|
+
...leaveAlone.map((id) => `Memory [ID: ${id}] is left as it is for this run. Do not try it again.`)
|
|
28898
|
+
];
|
|
28846
28899
|
return {
|
|
28847
|
-
skip:
|
|
28900
|
+
skip: [
|
|
28901
|
+
`Skipped ${params.action} for memory [ID: ${memoryIds}]: curate safety refusal (${reasons}); refused=${refused}.`,
|
|
28902
|
+
...guidance
|
|
28903
|
+
].join(`
|
|
28904
|
+
`),
|
|
28848
28905
|
successor
|
|
28849
28906
|
};
|
|
28850
28907
|
}
|
|
@@ -28888,12 +28945,16 @@ var ctxMemoryListArgsShape = {
|
|
|
28888
28945
|
category: tool2.schema.enum([...V2_MEMORY_CATEGORIES]).optional().describe("Filter listed memories to this category (optional)."),
|
|
28889
28946
|
limit: tool2.schema.number().optional().describe("Max results for list (default 10).")
|
|
28890
28947
|
};
|
|
28948
|
+
var ctxMemoryCurateArgsShape = {
|
|
28949
|
+
...ctxMemoryArgsShape,
|
|
28950
|
+
superseded_by: tool2.schema.number().optional().describe("ID of the active memory in the same project and category that keeps the information.")
|
|
28951
|
+
};
|
|
28891
28952
|
var ctxMemoryArgsSchema = tool2.schema.object({
|
|
28892
28953
|
...ctxMemoryArgsShape,
|
|
28893
|
-
superseded_by:
|
|
28954
|
+
superseded_by: ctxMemoryCurateArgsShape.superseded_by,
|
|
28894
28955
|
limit: tool2.schema.number().optional()
|
|
28895
28956
|
}).passthrough();
|
|
28896
|
-
function createCtxMemoryTool(deps) {
|
|
28957
|
+
function createCtxMemoryTool(deps, toolName = CTX_MEMORY_TOOL_NAME) {
|
|
28897
28958
|
const allowedActions = getAllowedActions(deps);
|
|
28898
28959
|
return tool2({
|
|
28899
28960
|
description: CTX_MEMORY_DESCRIPTION,
|
|
@@ -28942,7 +29003,8 @@ function createCtxMemoryTool(deps) {
|
|
|
28942
29003
|
const curatePreflight = toolContext.agent === DREAMER_AGENT ? preflightCurateMutation({
|
|
28943
29004
|
db: deps.db,
|
|
28944
29005
|
params: args,
|
|
28945
|
-
sessionId: toolContext.sessionID
|
|
29006
|
+
sessionId: toolContext.sessionID,
|
|
29007
|
+
toolName
|
|
28946
29008
|
}) : { skip: null, successor: null };
|
|
28947
29009
|
if (curatePreflight.skip)
|
|
28948
29010
|
return curatePreflight.skip;
|
|
@@ -29270,6 +29332,22 @@ function createCtxMemoryListTools(deps) {
|
|
|
29270
29332
|
[CTX_MEMORY_LIST_TOOL_NAME]: createCtxMemoryListTool(deps)
|
|
29271
29333
|
};
|
|
29272
29334
|
}
|
|
29335
|
+
function createDreamerMemoryTools(deps) {
|
|
29336
|
+
const memoryTool = createCtxMemoryTool(deps, CTX_MEMORY_CURATE_TOOL_NAME);
|
|
29337
|
+
return {
|
|
29338
|
+
...createCtxMemoryListTools(deps),
|
|
29339
|
+
[CTX_MEMORY_CURATE_TOOL_NAME]: tool2({
|
|
29340
|
+
description: "Maintain the project memory pool during Curate.",
|
|
29341
|
+
args: ctxMemoryCurateArgsShape,
|
|
29342
|
+
async execute(args, toolContext) {
|
|
29343
|
+
if (toolContext.agent !== DREAMER_AGENT) {
|
|
29344
|
+
return `Error: ${CTX_MEMORY_CURATE_TOOL_NAME} is only available to the dreamer agent.`;
|
|
29345
|
+
}
|
|
29346
|
+
return memoryTool.execute(args, toolContext);
|
|
29347
|
+
}
|
|
29348
|
+
})
|
|
29349
|
+
};
|
|
29350
|
+
}
|
|
29273
29351
|
// src/tools/ctx-note/constants.ts
|
|
29274
29352
|
var CTX_NOTE_DESCRIPTION = `Session notes are pending intentions: work you intend to return to, with its findings attached.
|
|
29275
29353
|
|
|
@@ -30066,14 +30144,13 @@ Keep: user messages (never stamp one for its directive), your own conversation t
|
|
|
30066
30144
|
|
|
30067
30145
|
Look at each tag before stamping it; never blanket-stamp a range like "1-50". Many small targeted stamps beat one sweep. \`drop\` accepts "3-5", "1,2,9", "1-5,8,12-15".`;
|
|
30068
30146
|
function formatCtxReduceReply(stampedCount, selfStampCount = 0) {
|
|
30069
|
-
const parts = [];
|
|
30070
30147
|
if (stampedCount > 0) {
|
|
30071
|
-
|
|
30148
|
+
return `${stampedCount} tag${stampedCount === 1 ? "" : "s"} stamped.`;
|
|
30072
30149
|
}
|
|
30073
30150
|
if (selfStampCount > 0) {
|
|
30074
|
-
|
|
30151
|
+
return "Nothing stamped: ctx_reduce calls are cleaned up automatically.";
|
|
30075
30152
|
}
|
|
30076
|
-
return
|
|
30153
|
+
return "";
|
|
30077
30154
|
}
|
|
30078
30155
|
// src/tools/ctx-reduce/tools.ts
|
|
30079
30156
|
import { createHash as createHash17 } from "node:crypto";
|
|
@@ -30998,4 +31075,4 @@ function applyHiddenSubagentTemperature(input, output, log) {
|
|
|
30998
31075
|
output.temperature = temperature;
|
|
30999
31076
|
}
|
|
31000
31077
|
|
|
31001
|
-
export { logConfigDependencyNotesOnce, openOpenCodeDb, DREAMER_SYSTEM_PROMPT, runSessionProjectBackfill, SMART_NOTE_COMPILER_SYSTEM_PROMPT, createLiveSessionState, RETROSPECTIVE_MAX_USER_MESSAGE_CHARS, RETROSPECTIVE_MESSAGE_TRUNCATION_MARKER, OpenCodeRetrospectiveRawProvider, createDreamTaskExecutor, runManualDream, runDueTasksForProject, startDreamScheduleTimer, createDreamTimerModuleClient, ensureProjectRegisteredFromOpenCodeDirectory, describeStorageUnavailability, resolveSessionCacheTtl, runEmbedHistoryDrain, pauseEmbedHistoryDrain, formatEmbedStatusText, getSessionProperties, getSessionCreatedInfo, getMessageUpdatedAssistantInfo, getMessageUpdatedInfo, getSessionErrorInfo, getMessageRemovedInfo, summarizeManualDream, createMagicContextCommandHandler, getLiveNotificationParams, createChatMessageHook, createEventHook, createCommandExecuteBeforeHook, createToolExecuteAfterHook, recordHiddenVariantWarning, buildStatusDetail, isDebugRpcEnabled, registerRpcHandlers, recordHostSqliteRuntime, maybeAutoEmbedSessionBackfill, clearTransformDecisionSession, scheduleOpenCodeTransformDecisionWrite, stageOpenCodeV2TransformDecision, bindOpenCodeV2TransformDecision, maybeDeliverChannel2, PROVIDER_OVERFLOW_NOTICE, noteServedRecoveryForOverflowHint, holdOverflowResendHint, ProviderRefusalCounts, snapshotRefusalHistory, pushRefusalFields, withProviderRefusalPass, createM0RenderOptions, lkgReplayLimit, measureLkgReplay, moduleRawBlockMappings, STORAGE_BUSY_MESSAGE, StorageBusyRefusalError, bindSystemDateRequestIdentity, bindSystemDateOutput, registerSystemDateRefresh, rustWrapupHistorianFields, isClearlyOverWindow, UnmanagedOverWindowError, UnresolvedHistoryBoundaryError, clearMessageTokensCache, rendersCompartmentHistory, createTransform, createSubcModuleClient, createModuleToolBackends, createRustRefusalRecovery, createSystemPromptHashHandler, tryMessagesTransformLkgReplay, createMessagesTransformHandler, primaryOnlyToolIds, subagentToolRefusal, guardSubagentTools, hideSubagentTools, removePrimaryOnlyTools, storedSubagentMode, createCtxExpandTools,
|
|
31078
|
+
export { logConfigDependencyNotesOnce, openOpenCodeDb, DREAMER_SYSTEM_PROMPT, runSessionProjectBackfill, SMART_NOTE_COMPILER_SYSTEM_PROMPT, createLiveSessionState, RETROSPECTIVE_MAX_USER_MESSAGE_CHARS, RETROSPECTIVE_MESSAGE_TRUNCATION_MARKER, OpenCodeRetrospectiveRawProvider, createDreamTaskExecutor, runManualDream, runDueTasksForProject, startDreamScheduleTimer, createDreamTimerModuleClient, ensureProjectRegisteredFromOpenCodeDirectory, describeStorageUnavailability, resolveSessionCacheTtl, runEmbedHistoryDrain, pauseEmbedHistoryDrain, formatEmbedStatusText, getSessionProperties, getSessionCreatedInfo, getMessageUpdatedAssistantInfo, getMessageUpdatedInfo, getSessionErrorInfo, getMessageRemovedInfo, summarizeManualDream, createMagicContextCommandHandler, getLiveNotificationParams, createChatMessageHook, createEventHook, createCommandExecuteBeforeHook, createToolExecuteAfterHook, recordHiddenVariantWarning, buildStatusDetail, isDebugRpcEnabled, registerRpcHandlers, recordHostSqliteRuntime, maybeAutoEmbedSessionBackfill, clearTransformDecisionSession, scheduleOpenCodeTransformDecisionWrite, stageOpenCodeV2TransformDecision, bindOpenCodeV2TransformDecision, maybeDeliverChannel2, PROVIDER_OVERFLOW_NOTICE, noteServedRecoveryForOverflowHint, holdOverflowResendHint, ProviderRefusalCounts, snapshotRefusalHistory, pushRefusalFields, withProviderRefusalPass, createM0RenderOptions, lkgReplayLimit, measureLkgReplay, moduleRawBlockMappings, STORAGE_BUSY_MESSAGE, StorageBusyRefusalError, bindSystemDateRequestIdentity, bindSystemDateOutput, registerSystemDateRefresh, rustWrapupHistorianFields, isClearlyOverWindow, UnmanagedOverWindowError, UnresolvedHistoryBoundaryError, clearMessageTokensCache, rendersCompartmentHistory, createTransform, createSubcModuleClient, createModuleToolBackends, createRustRefusalRecovery, createSystemPromptHashHandler, tryMessagesTransformLkgReplay, createMessagesTransformHandler, primaryOnlyToolIds, subagentToolRefusal, guardSubagentTools, hideSubagentTools, removePrimaryOnlyTools, storedSubagentMode, createCtxExpandTools, CTX_MEMORY_ACTIONS, createCtxMemoryTools, createDreamerMemoryTools, CTX_NOTE_DESCRIPTION, withoutSmartNoteText, createCtxNoteTools, createCtxReduceTools, createCtxSearchTools, parameterDescriptionsFor, applyJsonSchemaParameterDescriptions, MagicContextRpcServer, subagentTemperature, applyHiddenSubagentTemperature };
|
|
@@ -53,6 +53,8 @@ function loadAllEmbeddings(db, projectPath, modelId) {
|
|
|
53
53
|
}
|
|
54
54
|
return embeddings;
|
|
55
55
|
}
|
|
56
|
+
var EMBEDDABLE_MEMORIES_FOR_PROJECT = `FROM memories m
|
|
57
|
+
WHERE m.project_path = ? AND m.status IN ('active', 'permanent')`;
|
|
56
58
|
function getMemoryEmbedCoverage(db, projectPath, modelId) {
|
|
57
59
|
const row = db.prepare(`SELECT
|
|
58
60
|
COUNT(*) AS total,
|
|
@@ -60,8 +62,7 @@ function getMemoryEmbedCoverage(db, projectPath, modelId) {
|
|
|
60
62
|
SELECT 1 FROM memory_embeddings e
|
|
61
63
|
WHERE e.memory_id = m.id AND e.model_id = ?
|
|
62
64
|
) THEN 1 ELSE 0 END) AS embedded
|
|
63
|
-
|
|
64
|
-
WHERE m.project_path = ? AND m.status = 'active'`).get(modelId, projectPath);
|
|
65
|
+
${EMBEDDABLE_MEMORIES_FOR_PROJECT}`).get(modelId, projectPath);
|
|
65
66
|
return {
|
|
66
67
|
total: typeof row?.total === "number" ? row.total : 0,
|
|
67
68
|
embedded: typeof row?.embedded === "number" ? row.embedded : 0
|
|
@@ -175,4 +176,4 @@ function setEmbeddingCacheTtlForTests2(ttlMs) {
|
|
|
175
176
|
embeddingCacheTtlMs = Math.max(0, Math.floor(ttlMs));
|
|
176
177
|
}
|
|
177
178
|
|
|
178
|
-
export { saveEmbeddingIfHashMatches, getMemoryEmbedCoverage, keepWorkerMemoryEmbeddings2, maintainKeptWorkerMemoryEmbeddings2, getProjectEmbeddings2, peekProjectEmbeddings2, invalidateProject2, invalidateMemory2, resetEmbeddingCacheForTests2, setEmbeddingCacheTtlForTests2 };
|
|
179
|
+
export { saveEmbeddingIfHashMatches, EMBEDDABLE_MEMORIES_FOR_PROJECT, getMemoryEmbedCoverage, keepWorkerMemoryEmbeddings2, maintainKeptWorkerMemoryEmbeddings2, getProjectEmbeddings2, peekProjectEmbeddings2, invalidateProject2, invalidateMemory2, resetEmbeddingCacheForTests2, setEmbeddingCacheTtlForTests2 };
|
|
@@ -5390,9 +5390,13 @@ function isFable51ThinkingBindingModel(providerID, modelID) {
|
|
|
5390
5390
|
return false;
|
|
5391
5391
|
return /(?:^|[-_.])fable[-_.]?5[-_.]1(?:$|[-_.])/i.test(modelID);
|
|
5392
5392
|
}
|
|
5393
|
+
var PATH_LIKE_ERROR_RUN = /^(?:(?![a-z][a-z\d+.-]*:\/\/)[a-z\d_.-]+[=:])?(?:[.~]?\\?\/|\.\.\/|\\\\|[a-z]:[\\/]|[a-z][a-z\d+.-]*:\/\/.)/i;
|
|
5394
|
+
function has413OverflowWord(message) {
|
|
5395
|
+
return message.split(/[\s"'`,;()[\]{}<>]+/).some((run) => !PATH_LIKE_ERROR_RUN.test(run) && /(entity|payload|context|prompt)/i.test(run));
|
|
5396
|
+
}
|
|
5393
5397
|
function detectOverflow(error) {
|
|
5394
5398
|
const message = extractErrorMessage(error);
|
|
5395
|
-
const hasStatus413 = /\b413\b/.test(message) &&
|
|
5399
|
+
const hasStatus413 = /\b413\b/.test(message) && has413OverflowWord(message);
|
|
5396
5400
|
const matched = OVERFLOW_PATTERNS.find((pattern) => pattern.test(message));
|
|
5397
5401
|
if (!matched && !hasStatus413 && !hasColdRequestCode(error)) {
|
|
5398
5402
|
return unitlessLiteLLMOverflow(error, message) ?? { isOverflow: false };
|