@cortexkit/opencode-magic-context 0.49.48 → 0.49.49
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/{announcement-g789dmt6.js → announcement-9pr71hd5.js} +3 -2
- package/dist/auto-search-worker.js +5 -5
- package/dist/chunk-embedding-write-worker.js +14 -15
- package/dist/{compaction-marker-candidates-dkfp1q9j.js → compaction-marker-candidates-8hazqfvj.js} +2 -3
- package/dist/compaction-marker-candidates-worker.js +1 -1
- package/dist/{compartment-chunk-embedding-snj51nmg.js → compartment-chunk-embedding-gfd093f8.js} +7 -8
- package/dist/{conflict-warning-hook-w1aw6w5t.js → conflict-warning-hook-56qpq7ws.js} +7 -8
- package/dist/{context-8r125qv3.js → context-bwf57gnh.js} +41 -43
- package/dist/{derive-budgets-nkw09vq7.js → derive-budgets-z53424qx.js} +2 -3
- package/dist/{embedding-backfill-kpy5shsa.js → embedding-backfill-d9x9q2e2.js} +12 -13
- package/dist/embedding-worker-process.js +2 -3
- package/dist/embedding-worker.js +5 -6
- package/dist/features/magic-context/dreamer/docs-proposals.d.ts.map +1 -1
- package/dist/{history-owner-0z620wgz.js → history-owner-n50e0e8y.js} +2 -3
- package/dist/hooks/magic-context/compartment-runner-incremental.d.ts.map +1 -1
- package/dist/hooks/magic-context/compartment-trigger.d.ts.map +1 -1
- package/dist/hooks/magic-context/protected-tail-boundary.d.ts +5 -3
- package/dist/hooks/magic-context/protected-tail-boundary.d.ts.map +1 -1
- package/dist/hooks/magic-context/transform-compartment-phase.d.ts.map +1 -1
- package/dist/hooks/magic-context/transform.d.ts.map +1 -1
- package/dist/{index-txs8tce6.js → index-0k283v27.js} +2 -4
- package/dist/{index-s79g172v.js → index-0mdh2cke.js} +10 -10
- package/dist/{index-ak11t3gm.js → index-0tz2fzpq.js} +1 -1
- package/dist/{index-2qbtqg1w.js → index-25tm250q.js} +1 -1
- package/dist/{index-h9m41624.js → index-2ny9xwdn.js} +2 -2
- package/dist/{index-xa9mmq6c.js → index-36wseasx.js} +1 -1
- package/dist/{index-sd2s4t4p.js → index-3n9ee4jh.js} +2 -2
- package/dist/{index-vk6srk5r.js → index-5850zme4.js} +3 -3
- package/dist/{index-qsyx931k.js → index-5bksfv58.js} +13 -15
- package/dist/{index-cgzpbz78.js → index-7n2n3v92.js} +5 -5
- package/dist/{index-jrfre9ah.js → index-82dfe8en.js} +146 -5
- package/dist/{index-gn6gfz4y.js → index-90z05d0p.js} +1 -1
- package/dist/{index-9wnbnx8f.js → index-a6aqpfp6.js} +1 -1
- package/dist/{index-q6pjqm49.js → index-agfh931z.js} +11 -13
- package/dist/{index-d4qw2h43.js → index-arxg51bj.js} +4 -4
- package/dist/{index-4wpfbzks.js → index-bkg4hdyh.js} +3 -3
- package/dist/{index-gp3kcpc4.js → index-cd3vp8xa.js} +1 -1
- package/dist/{index-cgsmttyj.js → index-cs7pmwt6.js} +4 -4
- package/dist/{index-brj6was5.js → index-em92bp7f.js} +2 -2
- package/dist/{index-2p37txes.js → index-ga5q492k.js} +1 -1
- package/dist/{index-8cfnaagj.js → index-gapnh6tk.js} +2 -4
- package/dist/{index-fw42ms3m.js → index-gz001bx7.js} +1 -1
- package/dist/{index-t6s0tsp7.js → index-h3p558ec.js} +3 -3
- package/dist/{index-qcz1fy7h.js → index-hexdee98.js} +4 -4
- package/dist/{index-smtbdmc3.js → index-hsv31e69.js} +2 -2
- package/dist/{index-dj2p8653.js → index-hsyczpn7.js} +2 -2
- package/dist/{index-q41sm60t.js → index-j7verehm.js} +71 -54
- package/dist/{index-fgft4qjn.js → index-jedbxq6n.js} +4 -4
- package/dist/{index-xh3jyejb.js → index-k47v0tmk.js} +16 -18
- package/dist/{index-1hwn96x1.js → index-kn1bx21r.js} +3 -3
- package/dist/{index-nj360hcs.js → index-pb8ysnq2.js} +4 -4
- package/dist/{index-rvmhyk89.js → index-qb75tv9j.js} +8 -8
- package/dist/{index-jz5bk7xd.js → index-qperbvjn.js} +2 -2
- package/dist/{index-25ka1jza.js → index-r9agn061.js} +4 -4
- package/dist/{index-hacf2tyx.js → index-reyws9fy.js} +1 -1
- package/dist/{index-fxbk7gk3.js → index-tad3can2.js} +1 -1
- package/dist/{index-hkh8x221.js → index-tj5gz396.js} +3 -5
- package/dist/{index-zetm0ayn.js → index-va9x7y48.js} +35 -31
- package/dist/{index-8ka0ne8t.js → index-vbmh68fb.js} +6 -6
- package/dist/{index-ta87fpfs.js → index-vyv4tame.js} +12 -14
- package/dist/{index-trkxkgmd.js → index-wdmfnmv1.js} +5 -5
- package/dist/index.js +53 -55
- package/dist/{logger-qwnbcfj9.js → logger-sw7z6sjz.js} +1 -2
- package/dist/{message-fts-rowid-map-msffhkve.js → message-fts-rowid-map-kx1bsdyg.js} +4 -5
- package/dist/{message-index-bounded-0q7sy04w.js → message-index-bounded-2shxmht9.js} +11 -12
- package/dist/{message-time-backfill-39bm498k.js → message-time-backfill-hp2jgn49.js} +2 -3
- package/dist/migration-worker.js +12 -13
- package/dist/{project-embedding-registry-r6xfsrbe.js → project-embedding-registry-nzgkq61z.js} +11 -12
- package/dist/raw-ordinal-warmup-worker.js +8 -8
- package/dist/{read-session-chunk-7fmg9p5m.js → read-session-chunk-c15y8yg6.js} +9 -10
- package/dist/{read-session-raw-x7a9b3jm.js → read-session-raw-04ger9zt.js} +2 -3
- package/dist/{recomp-orchestrator-jqa5z4ar.js → recomp-orchestrator-gfxqqpph.js} +30 -31
- package/dist/{render-mnqc74ar.js → render-5tx8r0me.js} +20 -21
- package/dist/{safe-notification-target-wztd7bgk.js → safe-notification-target-mx5khyxf.js} +2 -3
- package/dist/{search-archive-df09r8qn.js → search-archive-6tgh88xp.js} +11 -12
- package/dist/{search-kt764afk.js → search-k2n5bvsk.js} +23 -24
- package/dist/{send-session-notification-j93pn2hn.js → send-session-notification-gamjee2f.js} +5 -6
- package/dist/shared/data-path.d.ts +7 -13
- package/dist/shared/data-path.d.ts.map +1 -1
- package/dist/{storage-tags-96vyd6ra.js → storage-tags-kdb4qsyq.js} +4 -5
- package/dist/{transform-postprocess-phase-a7ety10n.js → transform-postprocess-phase-36dw4kxb.js} +31 -32
- package/dist/v2/auto-search-worker.js +5 -5
- package/dist/v2/chunk-embedding-write-worker.js +14 -14
- package/dist/v2/{compaction-marker-candidates-y737qb1v.js → compaction-marker-candidates-re14353a.js} +2 -2
- package/dist/v2/compaction-marker-candidates-worker.js +1 -1
- package/dist/v2/{compartment-chunk-embedding-nj5nrnbj.js → compartment-chunk-embedding-0pxsrzrt.js} +7 -7
- package/dist/v2/{context-9x7mnb7x.js → context-td3jyze3.js} +68 -49
- package/dist/v2/{derive-budgets-b5cgrtp8.js → derive-budgets-w0815q82.js} +3 -3
- package/dist/v2/{embedding-backfill-360efh1t.js → embedding-backfill-5dqdm3ff.js} +12 -12
- package/dist/v2/embedding-worker-process.js +1 -1
- package/dist/v2/embedding-worker.js +4 -4
- package/dist/v2/{history-owner-fpka43cn.js → history-owner-ep91wgqj.js} +2 -2
- package/dist/v2/{logger-4cj6d03m.js → logger-xnscpj6w.js} +1 -1
- package/dist/v2/{message-fts-rowid-map-qe7cpksd.js → message-fts-rowid-map-57jh6xpb.js} +4 -4
- package/dist/v2/{message-index-bounded-hctgp22r.js → message-index-bounded-j1jskn8a.js} +11 -11
- package/dist/v2/{message-time-backfill-0c4h7sg6.js → message-time-backfill-baxebka0.js} +2 -2
- package/dist/v2/migration-worker.js +11 -11
- package/dist/v2/{project-embedding-registry-ek0cy0d5.js → project-embedding-registry-swm4mw1t.js} +11 -11
- package/dist/v2/raw-ordinal-warmup-worker.js +8 -8
- package/dist/v2/{read-session-chunk-zknadvjr.js → read-session-chunk-carzw3m8.js} +9 -9
- package/dist/v2/{read-session-raw-yss2ev98.js → read-session-raw-3e482h3c.js} +2 -2
- package/dist/v2/{recomp-orchestrator-m5w0eqke.js → recomp-orchestrator-e7vrs932.js} +31 -31
- package/dist/v2/{render-89asy54r.js → render-e9mh9y1d.js} +20 -20
- package/dist/v2/{safe-notification-target-gphhast7.js → safe-notification-target-9r79xnbt.js} +2 -2
- package/dist/v2/{search-archive-axz2gbdb.js → search-archive-j3kb9ggd.js} +11 -11
- package/dist/v2/{search-kdtja5rx.js → search-sr23g316.js} +22 -22
- package/dist/v2/{send-session-notification-na3q825m.js → send-session-notification-95p89k7q.js} +5 -5
- package/dist/v2/{server-pej5rnye.js → server-0qxb8r8q.js} +2 -2
- package/dist/v2/{server-sg2qjkrb.js → server-1ppcpsdw.js} +2 -2
- package/dist/v2/{server-nn4hbymt.js → server-2qxt6qv0.js} +8 -8
- package/dist/v2/{server-7vb38e51.js → server-3jc6qmdz.js} +1 -1
- package/dist/v2/{server-69m30b21.js → server-3yk44ddz.js} +1 -1
- package/dist/v2/{server-z3tyd1mx.js → server-4y2pcckw.js} +3 -3
- package/dist/v2/{server-3schkz95.js → server-58h6rrnx.js} +4 -4
- package/dist/v2/{server-af1rmkyn.js → server-5kgesxck.js} +2 -2
- package/dist/v2/{server-mfn1yf9d.js → server-7vrtk78d.js} +1 -1
- package/dist/v2/{server-f0j864ma.js → server-91gb0vh8.js} +1 -1
- package/dist/v2/{server-131h608x.js → server-966dq3pd.js} +2 -2
- package/dist/v2/{server-jb6tjyeb.js → server-bb6kf05j.js} +23 -20
- package/dist/v2/{server-e3m10ds0.js → server-c5kq8d5n.js} +4 -4
- package/dist/v2/{server-gwxys0d0.js → server-c8z2grq0.js} +1 -1
- package/dist/v2/{server-4x7n5qz7.js → server-e14c3hd6.js} +10 -10
- package/dist/v2/{server-jra7awr5.js → server-e20kfytm.js} +11 -11
- package/dist/v2/{server-2gjqhmn9.js → server-fw49gc57.js} +8 -8
- package/dist/v2/{server-y8n33d9j.js → server-g61hgy1y.js} +4 -4
- package/dist/v2/{server-2j87594q.js → server-kgq2e2hh.js} +2 -2
- package/dist/v2/{server-ddw42d76.js → server-mxsy9h1d.js} +2 -2
- package/dist/v2/{server-qmmkhz2z.js → server-np27dgyt.js} +1 -1
- package/dist/v2/{server-dcws5831.js → server-qp5sj6n5.js} +2 -2
- package/dist/v2/{server-sr8tf5dt.js → server-r7y35vm9.js} +4 -4
- package/dist/v2/{server-7be0ersd.js → server-rcchadw0.js} +3 -3
- package/dist/v2/{server-b3r080cm.js → server-rz5jnhnv.js} +1 -1
- package/dist/v2/{server-zt1m5rwj.js → server-sa1fdt41.js} +1 -1
- package/dist/v2/{server-jqn7q7tm.js → server-t5cgb15n.js} +5 -5
- package/dist/v2/{server-ypf1ap0v.js → server-t8n27rbt.js} +1 -1
- package/dist/v2/{server-sefxj8k1.js → server-tmf0ayqp.js} +1 -1
- package/dist/v2/{server-wa4qhryh.js → server-ttrrh27h.js} +2 -2
- package/dist/v2/{server-bez34e60.js → server-vqq3g1t7.js} +4 -4
- package/dist/v2/{server-tpt7bwq8.js → server-ww7xbxxf.js} +1 -1
- package/dist/v2/{server-zahgxer8.js → server-y7q8cds3.js} +3 -3
- package/dist/v2/{server-27kccwe7.js → server-yxe0gh3v.js} +11 -11
- package/dist/v2/{server-yyqmvbvv.js → server-z7n3n1ra.js} +34 -28
- package/dist/v2/server.js +5 -5
- package/dist/v2/{storage-tags-xq8hjqkf.js → storage-tags-rzv7y0n3.js} +4 -4
- package/dist/v2/{v2-archive-reader-ky1wqcws.js → v2-archive-reader-jnzjavzr.js} +1 -1
- package/dist/v2/{wrapup-orchestrator-6wt67saz.js → wrapup-orchestrator-jw4nre49.js} +31 -31
- package/dist/{v2-archive-reader-665x2x4d.js → v2-archive-reader-b76tfeje.js} +1 -1
- package/dist/wrapup-orchestrator-fhfazjkq.js +55 -0
- package/package.json +1 -1
- package/src/shared/data-path.test.ts +104 -56
- package/src/shared/data-path.ts +30 -30
- package/dist/index-g2q4htwp.js +0 -146
- package/dist/wrapup-orchestrator-7kmb3jf9.js +0 -56
|
@@ -7,7 +7,7 @@ import {
|
|
|
7
7
|
getProjectMagicContextHistorianDir,
|
|
8
8
|
log2,
|
|
9
9
|
sessionLog2
|
|
10
|
-
} from "./server-
|
|
10
|
+
} from "./server-bb6kf05j.js";
|
|
11
11
|
import {
|
|
12
12
|
sanitizeDiagnosticText
|
|
13
13
|
} from "./server-z4p0ry94.js";
|
|
@@ -20,13 +20,13 @@ import {
|
|
|
20
20
|
cortexKitProjectConfigBasePath,
|
|
21
21
|
resolveLegacyConfigSourcesForHarness,
|
|
22
22
|
loadPluginConfigDetailed
|
|
23
|
-
} from "./server-
|
|
23
|
+
} from "./server-ttrrh27h.js";
|
|
24
24
|
import {
|
|
25
25
|
catalogOutputReserve,
|
|
26
26
|
getSdkContextLimit,
|
|
27
27
|
modelSupportsVision,
|
|
28
28
|
getSdkOutputLimit
|
|
29
|
-
} from "./server-
|
|
29
|
+
} from "./server-sa1fdt41.js";
|
|
30
30
|
import {
|
|
31
31
|
withContentLanguageDirective,
|
|
32
32
|
buildPrimaryLanguageDirective,
|
|
@@ -48,7 +48,7 @@ import {
|
|
|
48
48
|
RawOrdinalsNotReady2,
|
|
49
49
|
dropRawSessionOrdinalCheckpoints2,
|
|
50
50
|
runSessionWarmupWorker
|
|
51
|
-
} from "./server-
|
|
51
|
+
} from "./server-rz5jnhnv.js";
|
|
52
52
|
import {
|
|
53
53
|
providerMass,
|
|
54
54
|
calibrationForModelKey,
|
|
@@ -64,12 +64,12 @@ import {
|
|
|
64
64
|
foldShrunkPartTags2,
|
|
65
65
|
getTagNumberByMessageId2,
|
|
66
66
|
getActiveTagsBySession2
|
|
67
|
-
} from "./server-
|
|
67
|
+
} from "./server-rcchadw0.js";
|
|
68
68
|
import {
|
|
69
69
|
hasMeaningfulUserText2,
|
|
70
70
|
estimateTokens,
|
|
71
71
|
estimateFixedPromptTokens
|
|
72
|
-
} from "./server-
|
|
72
|
+
} from "./server-3jc6qmdz.js";
|
|
73
73
|
import {
|
|
74
74
|
resolveOpenCodeDbPath,
|
|
75
75
|
assertOpenCodeStoreGeneration,
|
|
@@ -80,7 +80,7 @@ import {
|
|
|
80
80
|
openCodeDbExists,
|
|
81
81
|
withReadOnlySessionDb,
|
|
82
82
|
getMessageTimesFromOpenCodeDb
|
|
83
|
-
} from "./server-
|
|
83
|
+
} from "./server-7vrtk78d.js";
|
|
84
84
|
import {
|
|
85
85
|
removeUnsupportedCommitHashes,
|
|
86
86
|
completedToolArcCrossesBoundary,
|
|
@@ -152,17 +152,17 @@ import {
|
|
|
152
152
|
getRawSessionTagKeysThrough2,
|
|
153
153
|
getLegacyProtectedTailStartOrdinal2,
|
|
154
154
|
readSessionChunk2
|
|
155
|
-
} from "./server-
|
|
155
|
+
} from "./server-2qxt6qv0.js";
|
|
156
156
|
import {
|
|
157
157
|
BoundedSessionMap
|
|
158
|
-
} from "./server-
|
|
158
|
+
} from "./server-kgq2e2hh.js";
|
|
159
159
|
import {
|
|
160
160
|
clearCompressionDepth,
|
|
161
161
|
clearCompressionDepthRange,
|
|
162
162
|
toMessageIndexSource,
|
|
163
163
|
clearIndexedMessagesInTransaction,
|
|
164
164
|
indexSourcesAfterOrdinal
|
|
165
|
-
} from "./server-
|
|
165
|
+
} from "./server-c5kq8d5n.js";
|
|
166
166
|
import {
|
|
167
167
|
COMPARTMENT_LEASE_RENEWAL_MS,
|
|
168
168
|
getCompartmentLeaseBlocker,
|
|
@@ -206,7 +206,7 @@ import {
|
|
|
206
206
|
getProjectState,
|
|
207
207
|
recordSubagentInvocation,
|
|
208
208
|
getLatestHistorianInvocationId
|
|
209
|
-
} from "./server-
|
|
209
|
+
} from "./server-yxe0gh3v.js";
|
|
210
210
|
import {
|
|
211
211
|
invalidateAutoEmbedSession
|
|
212
212
|
} from "./server-2amn2s73.js";
|
|
@@ -219,7 +219,7 @@ import {
|
|
|
219
219
|
replaceCompartmentChunkEmbeddings2,
|
|
220
220
|
deleteChunkEmbedBackoffForSession2,
|
|
221
221
|
chunkWindowSourceKey2
|
|
222
|
-
} from "./server-
|
|
222
|
+
} from "./server-g61hgy1y.js";
|
|
223
223
|
import {
|
|
224
224
|
isMarkerCandidateBasisCurrent2,
|
|
225
225
|
invalidateMarkerCandidateBasis2,
|
|
@@ -230,18 +230,18 @@ import {
|
|
|
230
230
|
certifiedMarkerReferenceFloor2,
|
|
231
231
|
readMarkerReferenceRows2,
|
|
232
232
|
readKnownMarkerReferenceRows2
|
|
233
|
-
} from "./server-
|
|
233
|
+
} from "./server-c8z2grq0.js";
|
|
234
234
|
import {
|
|
235
235
|
shouldSkipHomeProjectMemory,
|
|
236
236
|
resolveProjectIdentity
|
|
237
|
-
} from "./server-
|
|
237
|
+
} from "./server-3yk44ddz.js";
|
|
238
238
|
import {
|
|
239
239
|
contentSha2562,
|
|
240
240
|
enqueueShadowEmbeddingItems2,
|
|
241
241
|
getProjectChunkEmbeddingModelId2,
|
|
242
242
|
getProjectEmbeddingMaxInputTokens2,
|
|
243
243
|
embedItemsForProject2
|
|
244
|
-
} from "./server-
|
|
244
|
+
} from "./server-fw49gc57.js";
|
|
245
245
|
import {
|
|
246
246
|
V2_MEMORY_CATEGORIES,
|
|
247
247
|
CATEGORY_PRIORITY,
|
|
@@ -260,13 +260,13 @@ import {
|
|
|
260
260
|
userFacingFailureCode,
|
|
261
261
|
promoteSessionFactsDurable,
|
|
262
262
|
embedPromotedFacts
|
|
263
|
-
} from "./server-
|
|
263
|
+
} from "./server-0qxb8r8q.js";
|
|
264
264
|
import {
|
|
265
265
|
getSchemaFenceRejection,
|
|
266
266
|
LATEST_SUPPORTED_VERSION,
|
|
267
267
|
getPersistedSchemaVersion,
|
|
268
268
|
openDatabase
|
|
269
|
-
} from "./server-
|
|
269
|
+
} from "./server-e14c3hd6.js";
|
|
270
270
|
import {
|
|
271
271
|
parseCompartmentOutput,
|
|
272
272
|
resolveWorkspaceShareCategories,
|
|
@@ -275,7 +275,7 @@ import {
|
|
|
275
275
|
resolveStoredPathWorkspaceIdentity,
|
|
276
276
|
sourceNameForMemory,
|
|
277
277
|
computeWorkspaceEpochFingerprint
|
|
278
|
-
} from "./server-
|
|
278
|
+
} from "./server-58h6rrnx.js";
|
|
279
279
|
import {
|
|
280
280
|
FAIL_CLOSED_DOCTOR_COMMAND
|
|
281
281
|
} from "./server-468mya5v.js";
|
|
@@ -283,7 +283,7 @@ import {
|
|
|
283
283
|
getSessionNotes,
|
|
284
284
|
getReadySmartNotes,
|
|
285
285
|
insertPrimerCandidates
|
|
286
|
-
} from "./server-
|
|
286
|
+
} from "./server-t8n27rbt.js";
|
|
287
287
|
import {
|
|
288
288
|
pushNotification2
|
|
289
289
|
} from "./server-x8a7jmkh.js";
|
|
@@ -291,10 +291,10 @@ import {
|
|
|
291
291
|
deriveTriggerBudget2,
|
|
292
292
|
resolveHistorianProducerLimits2,
|
|
293
293
|
producerSourceLocalBudget2
|
|
294
|
-
} from "./server-
|
|
294
|
+
} from "./server-5kgesxck.js";
|
|
295
295
|
import {
|
|
296
296
|
sendStatusNotification2
|
|
297
|
-
} from "./server-
|
|
297
|
+
} from "./server-vqq3g1t7.js";
|
|
298
298
|
import {
|
|
299
299
|
retreatPastHostUnservedRows,
|
|
300
300
|
snapTerminalCompartmentToServedRow,
|
|
@@ -314,7 +314,7 @@ import {
|
|
|
314
314
|
import {
|
|
315
315
|
logSlowWriteTransaction,
|
|
316
316
|
WriteTransactionSteps
|
|
317
|
-
} from "./server-
|
|
317
|
+
} from "./server-np27dgyt.js";
|
|
318
318
|
|
|
319
319
|
// src/config/live-snapshot.ts
|
|
320
320
|
import { createHash } from "node:crypto";
|
|
@@ -13418,10 +13418,6 @@ var FORCE80_MAX_CAP = 500000;
|
|
|
13418
13418
|
var FORCE95_MAX_CAP = 750000;
|
|
13419
13419
|
var NORMAL_HYSTERESIS_TOKENS = 256;
|
|
13420
13420
|
var RECOVERY_NO_HEAD_LIMIT = 2;
|
|
13421
|
-
var MIN_FORCE_ELIGIBLE_TOKENS_CAP = 1000;
|
|
13422
|
-
function deriveMinForceEligibleTokens(scaledN) {
|
|
13423
|
-
return Math.min(MIN_FORCE_ELIGIBLE_TOKENS_CAP, Math.max(1, Math.floor(scaledN / 8)));
|
|
13424
|
-
}
|
|
13425
13421
|
function clampPercentage(value) {
|
|
13426
13422
|
if (!Number.isFinite(value))
|
|
13427
13423
|
return 0;
|
|
@@ -13666,6 +13662,7 @@ function resolveProtectedTailBoundary(ctx) {
|
|
|
13666
13662
|
priorBoundaryOrdinal: ctx.priorBoundaryOrdinal,
|
|
13667
13663
|
migrationFloorActive: ctx.migrationFloorActive,
|
|
13668
13664
|
emergencyTailScale: ctx.emergencyTailScale,
|
|
13665
|
+
recovery: ctx.recovery,
|
|
13669
13666
|
providerShapeVersion: ctx.providerShapeVersion,
|
|
13670
13667
|
cacheNamespace: ctx.cacheNamespace,
|
|
13671
13668
|
createdAt,
|
|
@@ -13710,6 +13707,7 @@ function resolveProtectedTailBoundary(ctx) {
|
|
|
13710
13707
|
priorBoundaryOrdinal: ctx.priorBoundaryOrdinal,
|
|
13711
13708
|
migrationFloorActive: false,
|
|
13712
13709
|
emergencyTailScale: ctx.emergencyTailScale,
|
|
13710
|
+
recovery: ctx.recovery,
|
|
13713
13711
|
providerShapeVersion: ctx.providerShapeVersion,
|
|
13714
13712
|
cacheNamespace: ctx.cacheNamespace,
|
|
13715
13713
|
createdAt,
|
|
@@ -13825,6 +13823,7 @@ function resolveProtectedTailBoundary(ctx) {
|
|
|
13825
13823
|
priorBoundaryOrdinal: ctx.priorBoundaryOrdinal,
|
|
13826
13824
|
migrationFloorActive: ctx.migrationFloorActive,
|
|
13827
13825
|
emergencyTailScale: ctx.emergencyTailScale,
|
|
13826
|
+
recovery: ctx.recovery,
|
|
13828
13827
|
liftLivePromptFloor: ctx.liftLivePromptFloor === true ? true : undefined,
|
|
13829
13828
|
providerShapeVersion: ctx.providerShapeVersion,
|
|
13830
13829
|
cacheNamespace: ctx.cacheNamespace,
|
|
@@ -13903,6 +13902,7 @@ function resolveBoundaryContext(args) {
|
|
|
13903
13902
|
protectedTailPolicyVersion: meta.protectedTailPolicyVersion,
|
|
13904
13903
|
migrationFloorActive,
|
|
13905
13904
|
emergencyTailScale: args.emergencyTailScale,
|
|
13905
|
+
recovery: args.recovery,
|
|
13906
13906
|
liftLivePromptFloor: args.liftLivePromptFloor,
|
|
13907
13907
|
providerShapeVersion: args.providerShapeVersion ?? "opencode-v1",
|
|
13908
13908
|
cacheNamespace: args.cacheNamespace ?? `opencode:${args.sessionId}`,
|
|
@@ -14083,9 +14083,11 @@ function hasRunnableCompartmentWindow(snapshot) {
|
|
|
14083
14083
|
return false;
|
|
14084
14084
|
if (snapshot.eligibleEndOrdinal <= snapshot.offset)
|
|
14085
14085
|
return false;
|
|
14086
|
+
if (snapshot.recovery || snapshot.usagePercentage >= 95 || snapshot.mode === "manual-wrapup" || snapshot.mode === "manual-full-recomp")
|
|
14087
|
+
return true;
|
|
14086
14088
|
const forceMaterializationPercentage = escalationBands(snapshot.executeThresholdPercentage).forceMaterializationPercentage;
|
|
14087
14089
|
if (snapshot.usagePercentage >= forceMaterializationPercentage || snapshot.emergencyTailScale) {
|
|
14088
|
-
return snapshot.
|
|
14090
|
+
return snapshot.summaryRemovedEligibleTokens >= snapshot.contextLimit * 0.02;
|
|
14089
14091
|
}
|
|
14090
14092
|
return snapshot.eligibleEndOrdinal > snapshot.offset;
|
|
14091
14093
|
}
|
|
@@ -14547,7 +14549,7 @@ async function runCompartmentAgent(deps) {
|
|
|
14547
14549
|
return;
|
|
14548
14550
|
}
|
|
14549
14551
|
if (!validation.ok && validation.reason === "stale_snapshot") {
|
|
14550
|
-
const
|
|
14552
|
+
const refreshedBoundary = deps.refreshBoundarySnapshot ? deps.refreshBoundarySnapshot(boundarySnapshot, validation) : resolveOpenCodeProtectedTailBoundary({
|
|
14551
14553
|
db,
|
|
14552
14554
|
sessionId,
|
|
14553
14555
|
mode: "incremental-runner",
|
|
@@ -14561,6 +14563,10 @@ async function runCompartmentAgent(deps) {
|
|
|
14561
14563
|
emergencyTailScale: boundarySnapshot.emergencyTailScale,
|
|
14562
14564
|
liftLivePromptFloor: boundarySnapshot.liftLivePromptFloor === true
|
|
14563
14565
|
});
|
|
14566
|
+
const refreshed = refreshedBoundary ? {
|
|
14567
|
+
...refreshedBoundary,
|
|
14568
|
+
recovery: boundarySnapshot.recovery || deps.forceDrainQuota
|
|
14569
|
+
} : null;
|
|
14564
14570
|
if (refreshed && hasRunnableCompartmentWindow(refreshed)) {
|
|
14565
14571
|
sessionLog2(sessionId, `historian: refreshed stale protected-tail snapshot at run time (was: ${validation.detail ?? "stale"}) — eligible head ${refreshed.offset}-${refreshed.eligibleEndOrdinal - 1}`);
|
|
14566
14572
|
boundarySnapshot = refreshed;
|
package/dist/v2/server.js
CHANGED
|
@@ -1,6 +1,6 @@
|
|
|
1
1
|
import {
|
|
2
2
|
loadPluginConfigDetailed
|
|
3
|
-
} from "./server-
|
|
3
|
+
} from "./server-ttrrh27h.js";
|
|
4
4
|
import {
|
|
5
5
|
setHarness2
|
|
6
6
|
} from "./server-pavzsdc6.js";
|
|
@@ -11,9 +11,9 @@ import {
|
|
|
11
11
|
registerStalePluginBuildHost,
|
|
12
12
|
log2,
|
|
13
13
|
flushLogger2
|
|
14
|
-
} from "./server-
|
|
14
|
+
} from "./server-bb6kf05j.js";
|
|
15
15
|
import"./server-z4p0ry94.js";
|
|
16
|
-
import"./server-
|
|
16
|
+
import"./server-sa1fdt41.js";
|
|
17
17
|
import {
|
|
18
18
|
string,
|
|
19
19
|
unknown,
|
|
@@ -7875,7 +7875,7 @@ var require_src2 = __commonJS(function(exports, module) {
|
|
|
7875
7875
|
// package.json
|
|
7876
7876
|
var package_default = {
|
|
7877
7877
|
name: "@cortexkit/opencode-magic-context",
|
|
7878
|
-
version: "0.49.
|
|
7878
|
+
version: "0.49.49",
|
|
7879
7879
|
type: "module",
|
|
7880
7880
|
description: "OpenCode plugin for Magic Context — cross-session memory and context management",
|
|
7881
7881
|
main: "dist/index.js",
|
|
@@ -8196,7 +8196,7 @@ async function setup(context) {
|
|
|
8196
8196
|
if (claimStorageBackupWarningCheck() && isMagicContextStorageOutsideEngram(storageDir)) {
|
|
8197
8197
|
log2(`[magic-context] Magic Context storage is at ${storageDir}, outside the folder Engram backs up (~/.local/share/cortexkit/magic-context). It is not included in CortexKit backups.`);
|
|
8198
8198
|
}
|
|
8199
|
-
const { registerContext } = await import("./context-
|
|
8199
|
+
const { registerContext } = await import("./context-td3jyze3.js");
|
|
8200
8200
|
setHarness2("opencode2");
|
|
8201
8201
|
bindStaleBuildNotice({}, import.meta.url, "opencode2");
|
|
8202
8202
|
const duties = await registerContext(context);
|
|
@@ -64,12 +64,12 @@ import {
|
|
|
64
64
|
adoptNullOwnerToolTag2,
|
|
65
65
|
getCandidateToolOwners2,
|
|
66
66
|
pickNearestPriorOwner2
|
|
67
|
-
} from "./server-
|
|
67
|
+
} from "./server-rcchadw0.js";
|
|
68
68
|
import"./server-1zx87sdm.js";
|
|
69
|
-
import"./server-
|
|
70
|
-
import"./server-
|
|
69
|
+
import"./server-ww7xbxxf.js";
|
|
70
|
+
import"./server-3jc6qmdz.js";
|
|
71
71
|
import"./server-gzy5w8ya.js";
|
|
72
|
-
import"./server-
|
|
72
|
+
import"./server-bb6kf05j.js";
|
|
73
73
|
import"./server-pavzsdc6.js";
|
|
74
74
|
import"./server-z4p0ry94.js";
|
|
75
75
|
export {
|
|
@@ -1,9 +1,9 @@
|
|
|
1
1
|
import"./server-pavzsdc6.js";
|
|
2
2
|
import {
|
|
3
3
|
sessionLog2
|
|
4
|
-
} from "./server-
|
|
4
|
+
} from "./server-bb6kf05j.js";
|
|
5
5
|
import"./server-z4p0ry94.js";
|
|
6
|
-
import"./server-
|
|
6
|
+
import"./server-tmf0ayqp.js";
|
|
7
7
|
import {
|
|
8
8
|
COMPARTMENT_LEASE_RENEWAL_MS,
|
|
9
9
|
acquireCompartmentLease,
|
|
@@ -11,20 +11,20 @@ import {
|
|
|
11
11
|
releaseCompartmentLeaseBestEffort,
|
|
12
12
|
getCompartments,
|
|
13
13
|
getLastCompartmentEndMessage
|
|
14
|
-
} from "./server-
|
|
14
|
+
} from "./server-yxe0gh3v.js";
|
|
15
15
|
import"./server-2amn2s73.js";
|
|
16
|
-
import"./server-
|
|
17
|
-
import"./server-
|
|
16
|
+
import"./server-3jc6qmdz.js";
|
|
17
|
+
import"./server-mxsy9h1d.js";
|
|
18
18
|
import {
|
|
19
19
|
inRootAsyncContext2
|
|
20
20
|
} from "./server-gzy5w8ya.js";
|
|
21
21
|
import"./server-v0p37hm2.js";
|
|
22
22
|
import"./server-96ztjvkn.js";
|
|
23
23
|
import"./server-1d042x6w.js";
|
|
24
|
-
import"./server-
|
|
25
|
-
import"./server-
|
|
26
|
-
import"./server-
|
|
27
|
-
import"./server-
|
|
24
|
+
import"./server-rz5jnhnv.js";
|
|
25
|
+
import"./server-966dq3pd.js";
|
|
26
|
+
import"./server-g61hgy1y.js";
|
|
27
|
+
import"./server-c5kq8d5n.js";
|
|
28
28
|
import {
|
|
29
29
|
getWrapupInProgressState,
|
|
30
30
|
acquireWrapupInProgress,
|
|
@@ -33,26 +33,26 @@ import {
|
|
|
33
33
|
getHistorianFailureState,
|
|
34
34
|
clearEmergencyRecovery,
|
|
35
35
|
prepareRawSessionOrdinals2
|
|
36
|
-
} from "./server-
|
|
37
|
-
import"./server-
|
|
38
|
-
import"./server-
|
|
36
|
+
} from "./server-2qxt6qv0.js";
|
|
37
|
+
import"./server-ww7xbxxf.js";
|
|
38
|
+
import"./server-e14c3hd6.js";
|
|
39
39
|
import"./server-1zx87sdm.js";
|
|
40
|
-
import"./server-
|
|
40
|
+
import"./server-rcchadw0.js";
|
|
41
41
|
import"./server-p9s40wfa.js";
|
|
42
42
|
import"./server-2ra6pwf3.js";
|
|
43
|
-
import"./server-
|
|
44
|
-
import"./server-
|
|
43
|
+
import"./server-7vrtk78d.js";
|
|
44
|
+
import"./server-kgq2e2hh.js";
|
|
45
45
|
import"./server-fr0wbhdn.js";
|
|
46
|
-
import"./server-
|
|
47
|
-
import"./server-
|
|
46
|
+
import"./server-58h6rrnx.js";
|
|
47
|
+
import"./server-3yk44ddz.js";
|
|
48
48
|
import"./server-rthnpmbp.js";
|
|
49
49
|
import"./server-fb3zxn06.js";
|
|
50
50
|
import"./server-468mya5v.js";
|
|
51
|
-
import"./server-
|
|
51
|
+
import"./server-t8n27rbt.js";
|
|
52
52
|
import {
|
|
53
53
|
pushNotification2
|
|
54
54
|
} from "./server-x8a7jmkh.js";
|
|
55
|
-
import"./server-
|
|
55
|
+
import"./server-c8z2grq0.js";
|
|
56
56
|
import {
|
|
57
57
|
describeBoundaryDiagnostics,
|
|
58
58
|
resolveWrapupProtectedTailBoundary,
|
|
@@ -63,23 +63,23 @@ import {
|
|
|
63
63
|
registerActiveCompartmentRun,
|
|
64
64
|
setRecompStarting2,
|
|
65
65
|
setRecompTerminal2
|
|
66
|
-
} from "./server-
|
|
66
|
+
} from "./server-z7n3n1ra.js";
|
|
67
67
|
import"./server-qt1qqasc.js";
|
|
68
|
-
import"./server-
|
|
69
|
-
import"./server-
|
|
68
|
+
import"./server-fw49gc57.js";
|
|
69
|
+
import"./server-qp5sj6n5.js";
|
|
70
70
|
import"./server-4dhv7mqz.js";
|
|
71
|
-
import"./server-
|
|
72
|
-
import"./server-
|
|
71
|
+
import"./server-1ppcpsdw.js";
|
|
72
|
+
import"./server-r7y35vm9.js";
|
|
73
73
|
import"./server-jjvbk92s.js";
|
|
74
|
-
import"./server-
|
|
75
|
-
import"./server-
|
|
76
|
-
import"./server-
|
|
77
|
-
import"./server-
|
|
78
|
-
import"./server-
|
|
74
|
+
import"./server-0qxb8r8q.js";
|
|
75
|
+
import"./server-ttrrh27h.js";
|
|
76
|
+
import"./server-sa1fdt41.js";
|
|
77
|
+
import"./server-5kgesxck.js";
|
|
78
|
+
import"./server-91gb0vh8.js";
|
|
79
79
|
import {
|
|
80
80
|
sendStatusNotification2
|
|
81
|
-
} from "./server-
|
|
82
|
-
import"./server-
|
|
81
|
+
} from "./server-vqq3g1t7.js";
|
|
82
|
+
import"./server-np27dgyt.js";
|
|
83
83
|
|
|
84
84
|
// src/hooks/magic-context/wrapup-orchestrator.ts
|
|
85
85
|
import * as crypto from "node:crypto";
|
|
@@ -0,0 +1,55 @@
|
|
|
1
|
+
import {
|
|
2
|
+
runManagedWrapup2
|
|
3
|
+
} from "./index-vbmh68fb.js";
|
|
4
|
+
import"./index-wdmfnmv1.js";
|
|
5
|
+
import"./index-va9x7y48.js";
|
|
6
|
+
import"./index-90z05d0p.js";
|
|
7
|
+
import"./index-sd3egckz.js";
|
|
8
|
+
import"./index-3n9ee4jh.js";
|
|
9
|
+
import"./index-arxg51bj.js";
|
|
10
|
+
import"./index-jjvbk92s.js";
|
|
11
|
+
import"./index-0mdh2cke.js";
|
|
12
|
+
import"./index-4dhv7mqz.js";
|
|
13
|
+
import"./index-vyv4tame.js";
|
|
14
|
+
import"./index-25tm250q.js";
|
|
15
|
+
import"./index-jedbxq6n.js";
|
|
16
|
+
import"./index-2amn2s73.js";
|
|
17
|
+
import"./index-6athgjba.js";
|
|
18
|
+
import"./index-gapnh6tk.js";
|
|
19
|
+
import"./index-r9agn061.js";
|
|
20
|
+
import"./index-qt1qqasc.js";
|
|
21
|
+
import"./index-qb75tv9j.js";
|
|
22
|
+
import"./index-bkg4hdyh.js";
|
|
23
|
+
import"./index-1zx87sdm.js";
|
|
24
|
+
import"./index-em92bp7f.js";
|
|
25
|
+
import"./index-x8a7jmkh.js";
|
|
26
|
+
import"./index-gz001bx7.js";
|
|
27
|
+
import"./index-tj5gz396.js";
|
|
28
|
+
import"./index-4dpvnp8k.js";
|
|
29
|
+
import"./index-qperbvjn.js";
|
|
30
|
+
import"./index-hexdee98.js";
|
|
31
|
+
import"./index-hsyczpn7.js";
|
|
32
|
+
import"./index-agfh931z.js";
|
|
33
|
+
import"./index-fb3zxn06.js";
|
|
34
|
+
import"./index-pb8ysnq2.js";
|
|
35
|
+
import"./index-fr0wbhdn.js";
|
|
36
|
+
import"./index-0k283v27.js";
|
|
37
|
+
import"./index-2ny9xwdn.js";
|
|
38
|
+
import"./index-wh9fxds5.js";
|
|
39
|
+
import"./index-ga5q492k.js";
|
|
40
|
+
import"./index-hsv31e69.js";
|
|
41
|
+
import"./index-a6aqpfp6.js";
|
|
42
|
+
import"./index-36wseasx.js";
|
|
43
|
+
import"./index-96ztjvkn.js";
|
|
44
|
+
import"./index-v0p37hm2.js";
|
|
45
|
+
import"./index-58e3y90n.js";
|
|
46
|
+
import"./index-tad3can2.js";
|
|
47
|
+
import"./index-0tz2fzpq.js";
|
|
48
|
+
import"./index-gzy5w8ya.js";
|
|
49
|
+
import"./index-82dfe8en.js";
|
|
50
|
+
import"./index-pavzsdc6.js";
|
|
51
|
+
import"./index-z4p0ry94.js";
|
|
52
|
+
import"./index-1d042x6w.js";
|
|
53
|
+
export {
|
|
54
|
+
runManagedWrapup2 as runManagedWrapup
|
|
55
|
+
};
|
package/package.json
CHANGED
|
@@ -1,5 +1,13 @@
|
|
|
1
|
-
import { afterEach, beforeEach, describe, expect, test } from "bun:test";
|
|
2
|
-
import {
|
|
1
|
+
import { afterEach, beforeEach, describe, expect, spyOn, test } from "bun:test";
|
|
2
|
+
import {
|
|
3
|
+
existsSync,
|
|
4
|
+
mkdirSync,
|
|
5
|
+
readFileSync,
|
|
6
|
+
rmSync,
|
|
7
|
+
statSync,
|
|
8
|
+
symlinkSync,
|
|
9
|
+
writeFileSync,
|
|
10
|
+
} from "node:fs";
|
|
3
11
|
import * as os from "node:os";
|
|
4
12
|
import * as path from "node:path";
|
|
5
13
|
import {
|
|
@@ -16,6 +24,7 @@ import {
|
|
|
16
24
|
getProjectMagicContextHistorianDir,
|
|
17
25
|
isMagicContextStorageOutsideEngram,
|
|
18
26
|
} from "./data-path";
|
|
27
|
+
import * as logger from "./logger";
|
|
19
28
|
import { createTestTempDirFromPath } from "./test-temp-dir";
|
|
20
29
|
|
|
21
30
|
const savedEnv = {
|
|
@@ -320,63 +329,102 @@ describe("data-path", () => {
|
|
|
320
329
|
});
|
|
321
330
|
|
|
322
331
|
describe("ensureCortexKitArtifactGitignore", () => {
|
|
323
|
-
|
|
324
|
-
|
|
325
|
-
|
|
326
|
-
ensureCortexKitArtifactGitignore(dir);
|
|
327
|
-
const gi = readFileSync(path.join(dir, ".cortexkit", ".gitignore"), "utf8");
|
|
328
|
-
expect(gi).toContain("# >>> cortexkit:magic-context");
|
|
329
|
-
expect(gi).toContain("magic-context/");
|
|
330
|
-
expect(gi).toContain("# <<< cortexkit:magic-context");
|
|
331
|
-
} finally {
|
|
332
|
-
rmSync(dir, { recursive: true, force: true });
|
|
333
|
-
}
|
|
334
|
-
});
|
|
335
|
-
|
|
336
|
-
test("is idempotent — a second call does not duplicate the block", () => {
|
|
337
|
-
const dir = createTestTempDirFromPath(path.join(os.tmpdir(), "mc-gi-"));
|
|
338
|
-
try {
|
|
339
|
-
ensureCortexKitArtifactGitignore(dir);
|
|
340
|
-
ensureCortexKitArtifactGitignore(dir);
|
|
341
|
-
const gi = readFileSync(path.join(dir, ".cortexkit", ".gitignore"), "utf8");
|
|
342
|
-
const occurrences = gi.split("# >>> cortexkit:magic-context").length - 1;
|
|
343
|
-
expect(occurrences).toBe(1);
|
|
344
|
-
} finally {
|
|
345
|
-
rmSync(dir, { recursive: true, force: true });
|
|
346
|
-
}
|
|
347
|
-
});
|
|
348
|
-
|
|
349
|
-
test("preserves a sibling module's existing entries (appends, never clobbers)", () => {
|
|
350
|
-
const dir = createTestTempDirFromPath(path.join(os.tmpdir(), "mc-gi-"));
|
|
351
|
-
try {
|
|
352
|
-
const ckDir = path.join(dir, ".cortexkit");
|
|
353
|
-
mkdirSync(ckDir, { recursive: true });
|
|
354
|
-
// Simulate a sibling (e.g. AFT) already owning a fenced block.
|
|
355
|
-
writeFileSync(
|
|
356
|
-
path.join(ckDir, ".gitignore"),
|
|
357
|
-
"# >>> cortexkit:aft\naft/scratch/\n# <<< cortexkit:aft\n",
|
|
358
|
-
);
|
|
359
|
-
ensureCortexKitArtifactGitignore(dir);
|
|
360
|
-
const gi = readFileSync(path.join(ckDir, ".gitignore"), "utf8");
|
|
361
|
-
expect(gi).toContain("# >>> cortexkit:aft");
|
|
362
|
-
expect(gi).toContain("aft/scratch/");
|
|
363
|
-
expect(gi).toContain("# >>> cortexkit:magic-context");
|
|
364
|
-
expect(gi).toContain("magic-context/");
|
|
365
|
-
} finally {
|
|
366
|
-
rmSync(dir, { recursive: true, force: true });
|
|
367
|
-
}
|
|
368
|
-
});
|
|
369
|
-
|
|
370
|
-
test("does not ignore the project config — only the artifact dir", () => {
|
|
332
|
+
const dirs: string[] = [];
|
|
333
|
+
const legacy = "# >>> cortexkit:magic-context\nmagic-context/\n# <<< cortexkit:magic-context\n";
|
|
334
|
+
function fixture() {
|
|
371
335
|
const dir = createTestTempDirFromPath(path.join(os.tmpdir(), "mc-gi-"));
|
|
336
|
+
dirs.push(dir);
|
|
337
|
+
mkdirSync(path.join(dir, ".cortexkit"), { recursive: true });
|
|
338
|
+
return {
|
|
339
|
+
dir,
|
|
340
|
+
shared: path.join(dir, ".cortexkit/.gitignore"),
|
|
341
|
+
nested: path.join(dir, ".cortexkit/magic-context/.gitignore"),
|
|
342
|
+
};
|
|
343
|
+
}
|
|
344
|
+
afterEach(() => {
|
|
345
|
+
for (const dir of dirs.splice(0)) rmSync(dir, { recursive: true, force: true });
|
|
346
|
+
});
|
|
347
|
+
|
|
348
|
+
test("creates only the self-ignoring nested file and does not rewrite matching bytes", () => {
|
|
349
|
+
const { dir, nested, shared } = fixture();
|
|
350
|
+
ensureCortexKitArtifactGitignore(dir);
|
|
351
|
+
expect(readFileSync(nested, "utf8")).toBe("*\n");
|
|
352
|
+
const before = statSync(nested).mtimeMs;
|
|
353
|
+
ensureCortexKitArtifactGitignore(dir);
|
|
354
|
+
expect(statSync(nested).mtimeMs).toBe(before);
|
|
355
|
+
expect(existsSync(shared)).toBe(false);
|
|
356
|
+
});
|
|
357
|
+
|
|
358
|
+
test.each([
|
|
359
|
+
"",
|
|
360
|
+
"*",
|
|
361
|
+
"*\r\n",
|
|
362
|
+
"artifacts/\n",
|
|
363
|
+
])("repairs differing nested bytes %j", (existing) => {
|
|
364
|
+
const { dir, nested } = fixture();
|
|
365
|
+
mkdirSync(path.dirname(nested), { recursive: true });
|
|
366
|
+
writeFileSync(nested, existing);
|
|
367
|
+
ensureCortexKitArtifactGitignore(dir);
|
|
368
|
+
expect(readFileSync(nested, "utf8")).toBe("*\n");
|
|
369
|
+
});
|
|
370
|
+
|
|
371
|
+
test.each([
|
|
372
|
+
legacy,
|
|
373
|
+
` \r\n\t\n${legacy}\n `,
|
|
374
|
+
legacy.replaceAll("\n", "\r\n"),
|
|
375
|
+
legacy.trimEnd(),
|
|
376
|
+
])("deletes the old shared file when only our block and whitespace remain %j", (existing) => {
|
|
377
|
+
const { dir, nested, shared } = fixture();
|
|
378
|
+
writeFileSync(shared, existing);
|
|
379
|
+
ensureCortexKitArtifactGitignore(dir);
|
|
380
|
+
expect(readFileSync(nested, "utf8")).toBe("*\n");
|
|
381
|
+
expect(existsSync(shared)).toBe(false);
|
|
382
|
+
});
|
|
383
|
+
|
|
384
|
+
test("removes our complete blocks while preserving every other byte", () => {
|
|
385
|
+
const { dir, shared } = fixture();
|
|
386
|
+
const prefix = "# café\r\n# >>> cortexkit:aft\r\naft/scratch/\r\n# <<< cortexkit:aft\r\n\n";
|
|
387
|
+
const suffix = "# >>> cortexkit:other\nother/\n# <<< cortexkit:other\nlast-without-newline";
|
|
388
|
+
writeFileSync(shared, prefix + legacy.replaceAll("\n", "\r\n") + legacy + suffix);
|
|
389
|
+
ensureCortexKitArtifactGitignore(dir);
|
|
390
|
+
ensureCortexKitArtifactGitignore(dir);
|
|
391
|
+
expect(readFileSync(shared)).toEqual(Buffer.from(prefix + suffix));
|
|
392
|
+
});
|
|
393
|
+
|
|
394
|
+
test("shared cleanup preserves non-UTF8 bytes outside our block", () => {
|
|
395
|
+
const { dir, shared } = fixture();
|
|
396
|
+
const prefix = Buffer.from([0xff, 0x80, 0x0a]);
|
|
397
|
+
const suffix = Buffer.from("# >>> cortexkit:aft\naft/\n# <<< cortexkit:aft\n");
|
|
398
|
+
writeFileSync(shared, Buffer.concat([prefix, Buffer.from(legacy), suffix]));
|
|
399
|
+
ensureCortexKitArtifactGitignore(dir);
|
|
400
|
+
expect(readFileSync(shared)).toEqual(Buffer.concat([prefix, suffix]));
|
|
401
|
+
});
|
|
402
|
+
|
|
403
|
+
test.each([
|
|
404
|
+
"# >>> cortexkit:aft\naft/scratch/\n# <<< cortexkit:aft\n",
|
|
405
|
+
"# >>> cortexkit:magic-context\nmagic-context/\n# >>> cortexkit:aft\naft/\n# <<< cortexkit:aft\n# <<< cortexkit:magic-context\n",
|
|
406
|
+
"prefix # >>> cortexkit:magic-context\nmagic-context/\n# <<< cortexkit:magic-context\n",
|
|
407
|
+
])("leaves unowned or incomplete shared blocks unchanged %j", (existing) => {
|
|
408
|
+
const { dir, shared } = fixture();
|
|
409
|
+
writeFileSync(shared, existing);
|
|
410
|
+
ensureCortexKitArtifactGitignore(dir);
|
|
411
|
+
expect(readFileSync(shared)).toEqual(Buffer.from(existing));
|
|
412
|
+
});
|
|
413
|
+
|
|
414
|
+
test("logs a nested write failure without throwing or retiring the shared rule", () => {
|
|
415
|
+
const { dir, nested, shared } = fixture();
|
|
416
|
+
mkdirSync(nested, { recursive: true });
|
|
417
|
+
writeFileSync(shared, legacy);
|
|
418
|
+
const logged = spyOn(logger, "log").mockImplementation(() => {});
|
|
372
419
|
try {
|
|
373
|
-
ensureCortexKitArtifactGitignore(dir);
|
|
374
|
-
|
|
375
|
-
|
|
376
|
-
|
|
377
|
-
|
|
420
|
+
expect(() => ensureCortexKitArtifactGitignore(dir)).not.toThrow();
|
|
421
|
+
expect(readFileSync(shared, "utf8")).toBe(legacy);
|
|
422
|
+
expect(logged).toHaveBeenCalledWith("Failed to ensure project artifact gitignore", {
|
|
423
|
+
directory: dir,
|
|
424
|
+
error: expect.any(String),
|
|
425
|
+
});
|
|
378
426
|
} finally {
|
|
379
|
-
|
|
427
|
+
logged.mockRestore();
|
|
380
428
|
}
|
|
381
429
|
});
|
|
382
430
|
});
|