@cortexkit/opencode-magic-context 0.33.0 → 0.34.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/config/agent-disable.d.ts +22 -0
- package/dist/config/agent-disable.d.ts.map +1 -1
- package/dist/config/index.d.ts.map +1 -1
- package/dist/config/project-security.d.ts +7 -0
- package/dist/config/project-security.d.ts.map +1 -1
- package/dist/config/schema/magic-context.d.ts +144 -24
- package/dist/config/schema/magic-context.d.ts.map +1 -1
- package/dist/config/transform-mode.d.ts +2 -0
- package/dist/config/transform-mode.d.ts.map +1 -1
- package/dist/{conflict-warning-hook-bwa99a04.js → conflict-warning-hook-fvpfvt0w.js} +1 -1
- package/dist/{derive-budgets-e9j09sjr.js → derive-budgets-9crp0cvd.js} +1 -1
- package/dist/features/builtin-commands/commands.d.ts +1 -1
- package/dist/features/builtin-commands/commands.d.ts.map +1 -1
- package/dist/features/magic-context/compaction-marker.d.ts +106 -0
- package/dist/features/magic-context/compaction-marker.d.ts.map +1 -1
- package/dist/features/magic-context/compartment-chunk-embedding.d.ts +0 -2
- package/dist/features/magic-context/compartment-chunk-embedding.d.ts.map +1 -1
- package/dist/features/magic-context/dreamer/classify.d.ts.map +1 -1
- package/dist/features/magic-context/dreamer/evaluate-smart-notes.d.ts.map +1 -1
- package/dist/features/magic-context/dreamer/map-memories.d.ts.map +1 -1
- package/dist/features/magic-context/dreamer/refresh-primers.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-registry.d.ts +0 -1
- package/dist/features/magic-context/dreamer/task-registry.d.ts.map +1 -1
- package/dist/features/magic-context/dreamer/verify.d.ts.map +1 -1
- package/dist/features/magic-context/fail-closed-block.d.ts +10 -0
- package/dist/features/magic-context/fail-closed-block.d.ts.map +1 -1
- package/dist/features/magic-context/git-commits/index.d.ts +2 -2
- package/dist/features/magic-context/git-commits/index.d.ts.map +1 -1
- package/dist/features/magic-context/git-commits/storage-git-commit-embeddings.d.ts +0 -2
- package/dist/features/magic-context/git-commits/storage-git-commit-embeddings.d.ts.map +1 -1
- package/dist/features/magic-context/git-commits/storage-git-commits.d.ts +0 -13
- package/dist/features/magic-context/git-commits/storage-git-commits.d.ts.map +1 -1
- package/dist/features/magic-context/memory/embedding-identity.d.ts.map +1 -1
- package/dist/features/magic-context/memory/embedding-local.d.ts +7 -1
- package/dist/features/magic-context/memory/embedding-local.d.ts.map +1 -1
- package/dist/features/magic-context/memory/embedding.d.ts +1 -2
- package/dist/features/magic-context/memory/embedding.d.ts.map +1 -1
- package/dist/features/magic-context/memory/memory-migration.d.ts +0 -6
- package/dist/features/magic-context/memory/memory-migration.d.ts.map +1 -1
- package/dist/features/magic-context/memory/project-identity.d.ts +2 -6
- package/dist/features/magic-context/memory/project-identity.d.ts.map +1 -1
- package/dist/features/magic-context/memory/storage-memory-embeddings.d.ts +0 -1
- package/dist/features/magic-context/memory/storage-memory-embeddings.d.ts.map +1 -1
- package/dist/features/magic-context/memory/storage-memory.d.ts +1 -6
- package/dist/features/magic-context/memory/storage-memory.d.ts.map +1 -1
- package/dist/features/magic-context/memory/verification-paths.d.ts +0 -1
- package/dist/features/magic-context/memory/verification-paths.d.ts.map +1 -1
- package/dist/features/magic-context/migrations.d.ts.map +1 -1
- package/dist/features/magic-context/mural/compress-cues.d.ts.map +1 -1
- package/dist/features/magic-context/mural/render-mural.d.ts.map +1 -1
- package/dist/features/magic-context/mural/storage-mural.d.ts +0 -1
- package/dist/features/magic-context/mural/storage-mural.d.ts.map +1 -1
- package/dist/features/magic-context/overflow-detection.d.ts +8 -1
- package/dist/features/magic-context/overflow-detection.d.ts.map +1 -1
- package/dist/features/magic-context/project-embedding-registry.d.ts +16 -2
- package/dist/features/magic-context/project-embedding-registry.d.ts.map +1 -1
- package/dist/features/magic-context/scheduler.d.ts.map +1 -1
- package/dist/features/magic-context/schema-fence-probe.d.ts +28 -0
- package/dist/features/magic-context/schema-fence-probe.d.ts.map +1 -0
- package/dist/features/magic-context/sidekick/agent.d.ts.map +1 -1
- package/dist/features/magic-context/smart-notes/capabilities.d.ts +0 -2
- package/dist/features/magic-context/smart-notes/capabilities.d.ts.map +1 -1
- package/dist/features/magic-context/smart-notes/compiler.d.ts +0 -1
- package/dist/features/magic-context/smart-notes/compiler.d.ts.map +1 -1
- package/dist/features/magic-context/smart-notes/types.d.ts +0 -16
- package/dist/features/magic-context/smart-notes/types.d.ts.map +1 -1
- package/dist/features/magic-context/storage-db.d.ts +35 -1
- package/dist/features/magic-context/storage-db.d.ts.map +1 -1
- package/dist/features/magic-context/storage-meta-persisted.d.ts +38 -5
- package/dist/features/magic-context/storage-meta-persisted.d.ts.map +1 -1
- package/dist/features/magic-context/storage-meta.d.ts +1 -1
- package/dist/features/magic-context/storage-meta.d.ts.map +1 -1
- package/dist/features/magic-context/storage.d.ts +1 -1
- package/dist/features/magic-context/storage.d.ts.map +1 -1
- package/dist/features/magic-context/user-memory/review-user-memories.d.ts.map +1 -1
- package/dist/features/magic-context/user-memory/storage-user-memory.d.ts +0 -2
- package/dist/features/magic-context/user-memory/storage-user-memory.d.ts.map +1 -1
- package/dist/hooks/auto-update-checker/types.d.ts +0 -3
- package/dist/hooks/auto-update-checker/types.d.ts.map +1 -1
- package/dist/hooks/magic-context/boundary-execution.d.ts +1 -1
- package/dist/hooks/magic-context/boundary-execution.d.ts.map +1 -1
- package/dist/hooks/magic-context/cache-busting-signals.d.ts +1 -1
- package/dist/hooks/magic-context/cache-busting-signals.d.ts.map +1 -1
- package/dist/hooks/magic-context/channel2-delivery.d.ts.map +1 -1
- package/dist/hooks/magic-context/child-session-spawn.d.ts +26 -0
- package/dist/hooks/magic-context/child-session-spawn.d.ts.map +1 -0
- package/dist/hooks/magic-context/command-handler.d.ts +2 -0
- package/dist/hooks/magic-context/command-handler.d.ts.map +1 -1
- package/dist/hooks/magic-context/compaction-marker-manager.d.ts +49 -0
- package/dist/hooks/magic-context/compaction-marker-manager.d.ts.map +1 -1
- package/dist/hooks/magic-context/compaction-off-transition.d.ts +96 -0
- package/dist/hooks/magic-context/compaction-off-transition.d.ts.map +1 -0
- package/dist/hooks/magic-context/compartment-parser.d.ts +12 -0
- package/dist/hooks/magic-context/compartment-parser.d.ts.map +1 -1
- package/dist/hooks/magic-context/compartment-runner-historian.d.ts +2 -0
- 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/compartment-runner-mapping.d.ts +0 -12
- package/dist/hooks/magic-context/compartment-runner-mapping.d.ts.map +1 -1
- package/dist/hooks/magic-context/compartment-runner-partial-recomp.d.ts.map +1 -1
- package/dist/hooks/magic-context/compartment-runner-recomp.d.ts.map +1 -1
- package/dist/hooks/magic-context/compartment-trigger.d.ts +12 -5
- package/dist/hooks/magic-context/compartment-trigger.d.ts.map +1 -1
- package/dist/hooks/magic-context/ctx-reduce-availability.d.ts +47 -1
- package/dist/hooks/magic-context/ctx-reduce-availability.d.ts.map +1 -1
- package/dist/hooks/magic-context/emergency-drop.d.ts +2 -2
- package/dist/hooks/magic-context/event-handler.d.ts +7 -0
- package/dist/hooks/magic-context/event-handler.d.ts.map +1 -1
- package/dist/hooks/magic-context/event-resolvers.d.ts +13 -21
- package/dist/hooks/magic-context/event-resolvers.d.ts.map +1 -1
- package/dist/hooks/magic-context/final-wire-token-estimate.d.ts +2 -0
- package/dist/hooks/magic-context/final-wire-token-estimate.d.ts.map +1 -1
- package/dist/hooks/magic-context/heuristic-cleanup.d.ts +1 -1
- package/dist/hooks/magic-context/historian-prompt.generated.d.ts +1 -1
- package/dist/hooks/magic-context/historian-prompt.generated.d.ts.map +1 -1
- package/dist/hooks/magic-context/hook-handlers.d.ts +1 -0
- package/dist/hooks/magic-context/hook-handlers.d.ts.map +1 -1
- package/dist/hooks/magic-context/hook.d.ts +11 -1
- package/dist/hooks/magic-context/hook.d.ts.map +1 -1
- package/dist/hooks/magic-context/inject-compartments.d.ts +18 -0
- package/dist/hooks/magic-context/inject-compartments.d.ts.map +1 -1
- package/dist/hooks/magic-context/protected-tail-boundary.d.ts.map +1 -1
- package/dist/hooks/magic-context/read-session-db.d.ts.map +1 -1
- package/dist/hooks/magic-context/read-session-true-raw-tokens.d.ts.map +1 -1
- package/dist/hooks/magic-context/rust-mode-transform.d.ts +3 -0
- package/dist/hooks/magic-context/rust-mode-transform.d.ts.map +1 -1
- package/dist/hooks/magic-context/send-session-notification.d.ts +20 -1
- package/dist/hooks/magic-context/send-session-notification.d.ts.map +1 -1
- package/dist/hooks/magic-context/sentinel.d.ts +39 -0
- package/dist/hooks/magic-context/sentinel.d.ts.map +1 -1
- package/dist/hooks/magic-context/tag-messages.d.ts.map +1 -1
- package/dist/hooks/magic-context/tool-drop-target.d.ts +19 -0
- package/dist/hooks/magic-context/tool-drop-target.d.ts.map +1 -1
- package/dist/hooks/magic-context/transform-compartment-phase.d.ts +3 -0
- package/dist/hooks/magic-context/transform-compartment-phase.d.ts.map +1 -1
- package/dist/hooks/magic-context/transform-postprocess-phase.d.ts +30 -0
- package/dist/hooks/magic-context/transform-postprocess-phase.d.ts.map +1 -1
- package/dist/hooks/magic-context/transform.d.ts +27 -0
- package/dist/hooks/magic-context/transform.d.ts.map +1 -1
- package/dist/{index-kxz4tn6m.js → index-56yjaeb2.js} +56 -4
- package/dist/{index-bmkea2dq.js → index-b563sga5.js} +40 -287
- package/dist/{index-y1c9tcm3.js → index-cn960ffd.js} +101 -20
- package/dist/{index-k5y60ymm.js → index-dtas91s5.js} +27 -6
- package/dist/index-fcyvznch.js +279 -0
- package/dist/{index-63dq2g4d.js → index-ry8rh8cv.js} +138 -24
- package/dist/{index-h86twgsp.js → index-s0mdn690.js} +2113 -1067
- package/dist/index.d.ts.map +1 -1
- package/dist/index.js +1356 -627
- package/dist/plugin/embedding-bootstrap.d.ts.map +1 -1
- package/dist/plugin/hooks/create-session-hooks.d.ts +19 -8
- package/dist/plugin/hooks/create-session-hooks.d.ts.map +1 -1
- package/dist/plugin/messages-transform.d.ts +10 -0
- package/dist/plugin/messages-transform.d.ts.map +1 -1
- package/dist/plugin/rpc-handlers.d.ts +3 -7
- package/dist/plugin/rpc-handlers.d.ts.map +1 -1
- package/dist/plugin/tool-registry.d.ts +8 -0
- package/dist/plugin/tool-registry.d.ts.map +1 -1
- package/dist/{recomp-orchestrator-yh7pepvx.js → recomp-orchestrator-8e82vmvb.js} +6 -5
- package/dist/send-session-notification-6njqewzk.js +20 -0
- package/dist/shared/conflict-detector.d.ts +38 -1
- package/dist/shared/conflict-detector.d.ts.map +1 -1
- package/dist/shared/conflict-fixer.d.ts +18 -1
- package/dist/shared/conflict-fixer.d.ts.map +1 -1
- package/dist/shared/context-limit-provenance.d.ts +3 -0
- package/dist/shared/context-limit-provenance.d.ts.map +1 -0
- package/dist/shared/escalation-bands.d.ts +9 -0
- package/dist/shared/escalation-bands.d.ts.map +1 -0
- package/dist/shared/format-threshold.d.ts +1 -1
- package/dist/shared/models-dev-cache.d.ts +29 -3
- package/dist/shared/models-dev-cache.d.ts.map +1 -1
- package/dist/shared/rpc-server.d.ts.map +1 -1
- package/dist/shared/rpc-types.d.ts +46 -1
- package/dist/shared/rpc-types.d.ts.map +1 -1
- package/dist/shared/sqlite.d.ts +9 -4
- package/dist/shared/sqlite.d.ts.map +1 -1
- package/dist/shared/storage-permissions.d.ts +5 -0
- package/dist/shared/storage-permissions.d.ts.map +1 -0
- package/dist/{storage-meta-session-1phy0b1z.js → storage-meta-session-xt41zbw4.js} +2 -1
- package/dist/{task-config-dn9k9szr.js → task-config-5nx3qfz8.js} +1 -2
- package/dist/tui/compaction-off.d.ts +13 -0
- package/dist/tui/compaction-off.d.ts.map +1 -0
- package/dist/tui/data/context-db.d.ts.map +1 -1
- package/dist/tui-compiled/compaction-off.d.ts +13 -0
- package/dist/tui-compiled/compaction-off.d.ts.map +1 -0
- package/dist/tui-compiled/data/context-db.d.ts.map +1 -1
- package/package.json +8 -3
- package/src/agents/dreamer.ts +68 -0
- package/src/agents/hidden-agent-registrations.ts +331 -0
- package/src/agents/historian.ts +3 -0
- package/src/agents/language-directive.test.ts +138 -0
- package/src/agents/language-directive.ts +121 -0
- package/src/agents/magic-context-prompt.language.test.ts +35 -0
- package/src/agents/magic-context-prompt.test.ts +292 -0
- package/src/agents/magic-context-prompt.ts +182 -0
- package/src/agents/permissions.test.ts +252 -0
- package/src/agents/permissions.ts +186 -0
- package/src/agents/sidekick.ts +1 -0
- package/src/agents/smart-note-compiler.ts +1 -0
- package/src/config/agent-disable.ts +106 -0
- package/src/config/compaction-accessor-guard.test.ts +82 -0
- package/src/config/compaction-backcompat.test.ts +52 -0
- package/src/config/index.test.ts +904 -0
- package/src/config/index.ts +601 -0
- package/src/config/migrate-config-location.test.ts +332 -0
- package/src/config/migrate-config-location.ts +635 -0
- package/src/config/migrate-dreamer-v2.test.ts +287 -0
- package/src/config/migrate-dreamer-v2.ts +336 -0
- package/src/config/migrate-experimental.ts +159 -0
- package/src/config/project-security.test.ts +366 -0
- package/src/config/project-security.ts +588 -0
- package/src/config/prune-config-leaf.test.ts +78 -0
- package/src/config/prune-config-leaf.ts +68 -0
- package/src/config/removed-config-keys.test.ts +116 -0
- package/src/config/schema/agent-overrides.ts +45 -0
- package/src/config/schema/magic-context.test.ts +358 -0
- package/src/config/schema/magic-context.ts +1002 -0
- package/src/config/transform-mode.test.ts +62 -0
- package/src/config/transform-mode.ts +34 -0
- package/src/config/variable.test.ts +323 -0
- package/src/config/variable.ts +192 -0
- package/src/features/magic-context/defaults.ts +1 -0
- package/src/features/magic-context/dreamer/cron.ts +243 -0
- package/src/features/magic-context/dreamer/task-registry.ts +104 -0
- package/src/shared/conflict-detector.test.ts +251 -1
- package/src/shared/conflict-detector.ts +84 -5
- package/src/shared/conflict-fixer.test.ts +309 -0
- package/src/shared/conflict-fixer.ts +82 -5
- package/src/shared/context-limit-provenance.ts +6 -0
- package/src/shared/escalation-bands.test.ts +23 -0
- package/src/shared/escalation-bands.ts +18 -0
- package/src/shared/format-threshold.ts +1 -1
- package/src/shared/models-dev-cache.test.ts +171 -0
- package/src/shared/models-dev-cache.ts +195 -38
- package/src/shared/rpc-server.ts +27 -18
- package/src/shared/rpc-types.ts +46 -1
- package/src/shared/sqlite.ts +13 -33
- package/src/shared/storage-permissions.ts +20 -0
- package/src/tui/compaction-off.test.ts +56 -0
- package/src/tui/compaction-off.ts +29 -0
- package/src/tui/data/context-db.ts +6 -0
- package/src/tui/index.tsx +113 -65
- package/src/tui/slots/sidebar-content.tsx +139 -83
- package/src/tui-compiled/compaction-off.ts +29 -0
- package/src/tui-compiled/data/context-db.ts +6 -0
- package/src/tui-compiled/index.tsx +558 -455
- package/src/tui-compiled/slots/sidebar-content.tsx +237 -161
- package/dist/config/schema.d.ts +0 -3
- package/dist/config/schema.d.ts.map +0 -1
- package/dist/features/magic-context/plugin-messages.d.ts +0 -75
- package/dist/features/magic-context/plugin-messages.d.ts.map +0 -1
- package/dist/hooks/magic-context/compartment-runner-state-xml.d.ts +0 -21
- package/dist/hooks/magic-context/compartment-runner-state-xml.d.ts.map +0 -1
- package/dist/index-anhrfygk.js +0 -57
- package/dist/send-session-notification-tghq9gnh.js +0 -11
- package/dist/shared/opencode-compaction-detector.d.ts +0 -2
- package/dist/shared/opencode-compaction-detector.d.ts.map +0 -1
- package/dist/shared/transcript-opencode.d.ts +0 -71
- package/dist/shared/transcript-opencode.d.ts.map +0 -1
- package/dist/tools/index.d.ts +0 -6
- package/dist/tools/index.d.ts.map +0 -1
- package/src/shared/opencode-compaction-detector.test.ts +0 -239
- package/src/shared/opencode-compaction-detector.ts +0 -81
- package/src/shared/transcript-opencode.ts +0 -302
- /package/dist/{index-v7fmc1s2.js → index-ygcng9t8.js} +0 -0
package/dist/index-anhrfygk.js
DELETED
|
@@ -1,57 +0,0 @@
|
|
|
1
|
-
// src/features/magic-context/dreamer/task-registry.ts
|
|
2
|
-
var CANONICAL_DREAM_TASKS = [
|
|
3
|
-
"map-memories",
|
|
4
|
-
"verify",
|
|
5
|
-
"verify-broad",
|
|
6
|
-
"curate",
|
|
7
|
-
"compress-cues",
|
|
8
|
-
"classify-memories",
|
|
9
|
-
"retrospective",
|
|
10
|
-
"maintain-docs",
|
|
11
|
-
"evaluate-smart-notes",
|
|
12
|
-
"review-user-memories",
|
|
13
|
-
"promote-primers",
|
|
14
|
-
"refresh-primers"
|
|
15
|
-
];
|
|
16
|
-
var AGENTIC_DREAM_TASKS = ["curate", "maintain-docs"];
|
|
17
|
-
var MEMORY_DOMAIN_TASKS = [
|
|
18
|
-
"map-memories",
|
|
19
|
-
"verify",
|
|
20
|
-
"verify-broad",
|
|
21
|
-
"curate",
|
|
22
|
-
"compress-cues",
|
|
23
|
-
"classify-memories",
|
|
24
|
-
"retrospective",
|
|
25
|
-
"promote-primers",
|
|
26
|
-
"refresh-primers"
|
|
27
|
-
];
|
|
28
|
-
var MEMORY_DOMAIN_SET = new Set(MEMORY_DOMAIN_TASKS);
|
|
29
|
-
function leaseKindFor(task) {
|
|
30
|
-
if (MEMORY_DOMAIN_SET.has(task))
|
|
31
|
-
return "memory";
|
|
32
|
-
switch (task) {
|
|
33
|
-
case "review-user-memories":
|
|
34
|
-
return "user-memories";
|
|
35
|
-
case "promote-primers":
|
|
36
|
-
case "refresh-primers":
|
|
37
|
-
return "memory";
|
|
38
|
-
case "maintain-docs":
|
|
39
|
-
return "maintain-docs";
|
|
40
|
-
case "evaluate-smart-notes":
|
|
41
|
-
return "evaluate-smart-notes";
|
|
42
|
-
default:
|
|
43
|
-
return "memory";
|
|
44
|
-
}
|
|
45
|
-
}
|
|
46
|
-
function leaseKeyFor(task, projectIdentity) {
|
|
47
|
-
const kind = leaseKindFor(task);
|
|
48
|
-
return kind === "user-memories" ? "user-memories" : `${kind}:${projectIdentity}`;
|
|
49
|
-
}
|
|
50
|
-
function isCanonicalDreamTask(value) {
|
|
51
|
-
return CANONICAL_DREAM_TASKS.includes(value);
|
|
52
|
-
}
|
|
53
|
-
function compareTaskOrder(a, b) {
|
|
54
|
-
return CANONICAL_DREAM_TASKS.indexOf(a) - CANONICAL_DREAM_TASKS.indexOf(b);
|
|
55
|
-
}
|
|
56
|
-
|
|
57
|
-
export { CANONICAL_DREAM_TASKS, AGENTIC_DREAM_TASKS, leaseKindFor, leaseKeyFor, isCanonicalDreamTask, compareTaskOrder };
|
|
@@ -1 +0,0 @@
|
|
|
1
|
-
{"version":3,"file":"opencode-compaction-detector.d.ts","sourceRoot":"","sources":["../../src/shared/opencode-compaction-detector.ts"],"names":[],"mappings":"AAqBA,wBAAgB,+BAA+B,CAAC,SAAS,EAAE,MAAM,GAAG,OAAO,CAsB1E"}
|
|
@@ -1,71 +0,0 @@
|
|
|
1
|
-
/**
|
|
2
|
-
* OpenCode adapter for the harness-agnostic transcript interface.
|
|
3
|
-
*
|
|
4
|
-
* This is a thin proxy over OpenCode's `MessageLike[]` (i.e. `{ info,
|
|
5
|
-
* parts: unknown[] }[]`) — it does NOT copy data. Mutations through
|
|
6
|
-
* `setText`/`setToolOutput`/`replaceWithSentinel` write directly into
|
|
7
|
-
* the source `parts[]` arrays, exactly as the existing OpenCode-only
|
|
8
|
-
* transform code does today. `commit()` is a no-op because OpenCode's
|
|
9
|
-
* AI SDK reads `parts[]` back from the same array we mutated.
|
|
10
|
-
*
|
|
11
|
-
* This module is the boundary that lets the rest of the transform code
|
|
12
|
-
* (which moves to use the Transcript interface in 4b.2) work both for
|
|
13
|
-
* OpenCode and Pi without branching on harness type. By the end of 4b
|
|
14
|
-
* the only OpenCode-aware code in the plugin is this file plus
|
|
15
|
-
* `messages-transform.ts`.
|
|
16
|
-
*
|
|
17
|
-
* ## Mutation contract recap
|
|
18
|
-
*
|
|
19
|
-
* Magic Context's transform mutates message parts in three ways:
|
|
20
|
-
*
|
|
21
|
-
* 1. **Tag prefix injection** — prepends `§N§ ` to text parts and
|
|
22
|
-
* tool result outputs. Repeated tagging is idempotent because
|
|
23
|
-
* `prependTag` strips any existing prefix first.
|
|
24
|
-
*
|
|
25
|
-
* 2. **Sentinel replacement** — when a queued drop fires, the part is
|
|
26
|
-
* replaced with a `[dropped §N§]` or `[truncated §N§]` placeholder.
|
|
27
|
-
* The original tag number is preserved so the agent's mental
|
|
28
|
-
* model of "what was here" survives.
|
|
29
|
-
*
|
|
30
|
-
* 3. **Structural noise stripping** — `step-start`/`step-finish`
|
|
31
|
-
* wrappers and similar structural metadata are replaced with empty
|
|
32
|
-
* sentinel parts so they don't consume tag numbers or get tagged
|
|
33
|
-
* themselves.
|
|
34
|
-
*
|
|
35
|
-
* The OpenCode adapter implements (1) and (2) by editing `part.text` /
|
|
36
|
-
* `part.state.output` in place. For (3), structural parts surface as
|
|
37
|
-
* `kind: "structural"` so callers can filter them out. Adapter does NOT
|
|
38
|
-
* itself perform stripping — that's the transform pipeline's job, called
|
|
39
|
-
* after the adapter wraps the messages.
|
|
40
|
-
*
|
|
41
|
-
* Step 4b.1 ships the adapter alone. The existing OpenCode transform
|
|
42
|
-
* code keeps using `MessageLike[]` directly until 4b.2 migrates the
|
|
43
|
-
* tagging+drops layer to use Transcript instances.
|
|
44
|
-
*/
|
|
45
|
-
import type { Transcript } from "./transcript";
|
|
46
|
-
/**
|
|
47
|
-
* The OpenCode `MessageLike` shape. Re-declared here to avoid a circular
|
|
48
|
-
* import with `tag-messages.ts` (which lives in the magic-context hooks
|
|
49
|
-
* tree and depends on storage). Keeping a local minimal type also makes
|
|
50
|
-
* the adapter trivially unit-testable without booting OpenCode SDK
|
|
51
|
-
* types.
|
|
52
|
-
*
|
|
53
|
-
* MUST stay structurally compatible with `tag-messages.ts MessageLike` —
|
|
54
|
-
* if that file's MessageLike adds a required field, this one needs to
|
|
55
|
-
* add it too. The build will fail loudly if the shapes diverge.
|
|
56
|
-
*/
|
|
57
|
-
export interface OpenCodeMessageLike {
|
|
58
|
-
info: {
|
|
59
|
-
id?: string;
|
|
60
|
-
role?: string;
|
|
61
|
-
sessionID?: string;
|
|
62
|
-
};
|
|
63
|
-
parts: unknown[];
|
|
64
|
-
}
|
|
65
|
-
/**
|
|
66
|
-
* Wrap an existing `MessageLike[]` as a Transcript. Zero copies — every
|
|
67
|
-
* `TranscriptPart` returned proxies the matching entry in the source
|
|
68
|
-
* `parts` array, and mutations are reflected immediately.
|
|
69
|
-
*/
|
|
70
|
-
export declare function createOpenCodeTranscript(messages: OpenCodeMessageLike[]): Transcript;
|
|
71
|
-
//# sourceMappingURL=transcript-opencode.d.ts.map
|
|
@@ -1 +0,0 @@
|
|
|
1
|
-
{"version":3,"file":"transcript-opencode.d.ts","sourceRoot":"","sources":["../../src/shared/transcript-opencode.ts"],"names":[],"mappings":"AAAA;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;GA2CG;AAIH,OAAO,KAAK,EACR,UAAU,EAIb,MAAM,cAAc,CAAC;AAEtB;;;;;;;;;;GAUG;AACH,MAAM,WAAW,mBAAmB;IAChC,IAAI,EAAE;QAAE,EAAE,CAAC,EAAE,MAAM,CAAC;QAAC,IAAI,CAAC,EAAE,MAAM,CAAC;QAAC,SAAS,CAAC,EAAE,MAAM,CAAA;KAAE,CAAC;IACzD,KAAK,EAAE,OAAO,EAAE,CAAC;CACpB;AAED;;;;GAIG;AACH,wBAAgB,wBAAwB,CAAC,QAAQ,EAAE,mBAAmB,EAAE,GAAG,UAAU,CA2BpF"}
|
package/dist/tools/index.d.ts
DELETED
|
@@ -1 +0,0 @@
|
|
|
1
|
-
{"version":3,"file":"index.d.ts","sourceRoot":"","sources":["../../src/tools/index.ts"],"names":[],"mappings":"AAAA,cAAc,cAAc,CAAC;AAC7B,cAAc,cAAc,CAAC;AAC7B,cAAc,YAAY,CAAC;AAC3B,cAAc,cAAc,CAAC;AAC7B,cAAc,cAAc,CAAC"}
|
|
@@ -1,239 +0,0 @@
|
|
|
1
|
-
import { afterEach, beforeEach, describe, expect, it, spyOn } from "bun:test";
|
|
2
|
-
import { mkdirSync, rmSync, writeFileSync } from "node:fs";
|
|
3
|
-
import { join } from "node:path";
|
|
4
|
-
import { isOpenCodeAutoCompactionEnabled } from "./opencode-compaction-detector";
|
|
5
|
-
import * as configDir from "./opencode-config-dir";
|
|
6
|
-
|
|
7
|
-
describe("opencode-compaction-detector", () => {
|
|
8
|
-
let tmpDir: string;
|
|
9
|
-
let previousDisableAutocompact: string | undefined;
|
|
10
|
-
let restoreConfigPaths: () => void;
|
|
11
|
-
|
|
12
|
-
beforeEach(() => {
|
|
13
|
-
tmpDir = join("/tmp", `compaction-detector-test-${Date.now()}`);
|
|
14
|
-
mkdirSync(join(tmpDir, ".opencode"), { recursive: true });
|
|
15
|
-
previousDisableAutocompact = process.env.OPENCODE_DISABLE_AUTOCOMPACT;
|
|
16
|
-
delete process.env.OPENCODE_DISABLE_AUTOCOMPACT;
|
|
17
|
-
const configPathsSpy = spyOn(configDir, "getOpenCodeConfigPaths").mockReturnValue({
|
|
18
|
-
configJson: join(tmpDir, "user-config", "opencode.json"),
|
|
19
|
-
configJsonc: join(tmpDir, "user-config", "opencode.jsonc"),
|
|
20
|
-
} as ReturnType<typeof configDir.getOpenCodeConfigPaths>);
|
|
21
|
-
restoreConfigPaths = () => configPathsSpy.mockRestore();
|
|
22
|
-
});
|
|
23
|
-
|
|
24
|
-
afterEach(() => {
|
|
25
|
-
restoreConfigPaths();
|
|
26
|
-
try {
|
|
27
|
-
rmSync(tmpDir, { recursive: true, force: true, maxRetries: 10, retryDelay: 100 });
|
|
28
|
-
} catch {
|
|
29
|
-
/* Ignore EBUSY on Windows */
|
|
30
|
-
}
|
|
31
|
-
if (previousDisableAutocompact === undefined) {
|
|
32
|
-
delete process.env.OPENCODE_DISABLE_AUTOCOMPACT;
|
|
33
|
-
} else {
|
|
34
|
-
process.env.OPENCODE_DISABLE_AUTOCOMPACT = previousDisableAutocompact;
|
|
35
|
-
}
|
|
36
|
-
});
|
|
37
|
-
|
|
38
|
-
describe("#given no config exists", () => {
|
|
39
|
-
it("#then returns true (default: compaction enabled)", () => {
|
|
40
|
-
const emptyDir = join("/tmp", `compaction-empty-${Date.now()}`);
|
|
41
|
-
mkdirSync(emptyDir, { recursive: true });
|
|
42
|
-
|
|
43
|
-
const result = isOpenCodeAutoCompactionEnabled(emptyDir);
|
|
44
|
-
|
|
45
|
-
expect(result).toBe(true);
|
|
46
|
-
try {
|
|
47
|
-
rmSync(emptyDir, { recursive: true, force: true, maxRetries: 10, retryDelay: 100 });
|
|
48
|
-
} catch {
|
|
49
|
-
/* Ignore EBUSY on Windows */
|
|
50
|
-
}
|
|
51
|
-
});
|
|
52
|
-
});
|
|
53
|
-
|
|
54
|
-
describe("#given OPENCODE_DISABLE_AUTOCOMPACT env flag is set", () => {
|
|
55
|
-
it("#then returns false", () => {
|
|
56
|
-
process.env.OPENCODE_DISABLE_AUTOCOMPACT = "1";
|
|
57
|
-
|
|
58
|
-
const result = isOpenCodeAutoCompactionEnabled(tmpDir);
|
|
59
|
-
|
|
60
|
-
expect(result).toBe(false);
|
|
61
|
-
});
|
|
62
|
-
});
|
|
63
|
-
|
|
64
|
-
describe("#given project config has compaction.auto = false", () => {
|
|
65
|
-
it("#when opencode.json #then returns false", () => {
|
|
66
|
-
writeFileSync(
|
|
67
|
-
join(tmpDir, ".opencode", "opencode.json"),
|
|
68
|
-
JSON.stringify({ compaction: { auto: false } }),
|
|
69
|
-
);
|
|
70
|
-
|
|
71
|
-
const result = isOpenCodeAutoCompactionEnabled(tmpDir);
|
|
72
|
-
|
|
73
|
-
expect(result).toBe(false);
|
|
74
|
-
});
|
|
75
|
-
|
|
76
|
-
it("#when opencode.jsonc #then returns false", () => {
|
|
77
|
-
writeFileSync(
|
|
78
|
-
join(tmpDir, ".opencode", "opencode.jsonc"),
|
|
79
|
-
`{
|
|
80
|
-
// compaction disabled
|
|
81
|
-
"compaction": { "auto": false }
|
|
82
|
-
}`,
|
|
83
|
-
);
|
|
84
|
-
|
|
85
|
-
const result = isOpenCodeAutoCompactionEnabled(tmpDir);
|
|
86
|
-
|
|
87
|
-
expect(result).toBe(false);
|
|
88
|
-
});
|
|
89
|
-
});
|
|
90
|
-
|
|
91
|
-
describe("#given project config has compaction.auto = true", () => {
|
|
92
|
-
it("#then returns true", () => {
|
|
93
|
-
writeFileSync(
|
|
94
|
-
join(tmpDir, ".opencode", "opencode.json"),
|
|
95
|
-
JSON.stringify({ compaction: { auto: true } }),
|
|
96
|
-
);
|
|
97
|
-
|
|
98
|
-
const result = isOpenCodeAutoCompactionEnabled(tmpDir);
|
|
99
|
-
|
|
100
|
-
expect(result).toBe(true);
|
|
101
|
-
});
|
|
102
|
-
});
|
|
103
|
-
|
|
104
|
-
describe("#given project config has compaction.prune = true", () => {
|
|
105
|
-
it("#then returns true (conflict enabled)", () => {
|
|
106
|
-
writeFileSync(
|
|
107
|
-
join(tmpDir, ".opencode", "opencode.json"),
|
|
108
|
-
JSON.stringify({ compaction: { auto: false, prune: true } }),
|
|
109
|
-
);
|
|
110
|
-
|
|
111
|
-
const result = isOpenCodeAutoCompactionEnabled(tmpDir);
|
|
112
|
-
|
|
113
|
-
expect(result).toBe(true);
|
|
114
|
-
});
|
|
115
|
-
});
|
|
116
|
-
|
|
117
|
-
describe("#given project config has auto/prune both false", () => {
|
|
118
|
-
it("#then returns false", () => {
|
|
119
|
-
writeFileSync(
|
|
120
|
-
join(tmpDir, ".opencode", "opencode.json"),
|
|
121
|
-
JSON.stringify({ compaction: { auto: false, prune: false } }),
|
|
122
|
-
);
|
|
123
|
-
|
|
124
|
-
const result = isOpenCodeAutoCompactionEnabled(tmpDir);
|
|
125
|
-
|
|
126
|
-
expect(result).toBe(false);
|
|
127
|
-
});
|
|
128
|
-
});
|
|
129
|
-
|
|
130
|
-
describe("#given project config has only compaction.prune = false", () => {
|
|
131
|
-
it("#then returns false", () => {
|
|
132
|
-
writeFileSync(
|
|
133
|
-
join(tmpDir, ".opencode", "opencode.json"),
|
|
134
|
-
JSON.stringify({ compaction: { prune: false } }),
|
|
135
|
-
);
|
|
136
|
-
|
|
137
|
-
const result = isOpenCodeAutoCompactionEnabled(tmpDir);
|
|
138
|
-
|
|
139
|
-
expect(result).toBe(false);
|
|
140
|
-
});
|
|
141
|
-
});
|
|
142
|
-
|
|
143
|
-
describe("#given jsonc and json both exist", () => {
|
|
144
|
-
it("#then jsonc takes precedence", () => {
|
|
145
|
-
writeFileSync(
|
|
146
|
-
join(tmpDir, ".opencode", "opencode.json"),
|
|
147
|
-
JSON.stringify({ compaction: { auto: true } }),
|
|
148
|
-
);
|
|
149
|
-
writeFileSync(
|
|
150
|
-
join(tmpDir, ".opencode", "opencode.jsonc"),
|
|
151
|
-
`{ "compaction": { "auto": false } }`,
|
|
152
|
-
);
|
|
153
|
-
|
|
154
|
-
const result = isOpenCodeAutoCompactionEnabled(tmpDir);
|
|
155
|
-
|
|
156
|
-
expect(result).toBe(false);
|
|
157
|
-
});
|
|
158
|
-
});
|
|
159
|
-
|
|
160
|
-
describe("#given config exists but no compaction field", () => {
|
|
161
|
-
it("#then returns true (default)", () => {
|
|
162
|
-
writeFileSync(
|
|
163
|
-
join(tmpDir, ".opencode", "opencode.json"),
|
|
164
|
-
JSON.stringify({ model: "claude-opus-4-6" }),
|
|
165
|
-
);
|
|
166
|
-
|
|
167
|
-
const result = isOpenCodeAutoCompactionEnabled(tmpDir);
|
|
168
|
-
|
|
169
|
-
expect(result).toBe(true);
|
|
170
|
-
});
|
|
171
|
-
});
|
|
172
|
-
|
|
173
|
-
describe("#given env flag overrides config", () => {
|
|
174
|
-
it("#then env flag wins even when config has auto: true", () => {
|
|
175
|
-
process.env.OPENCODE_DISABLE_AUTOCOMPACT = "true";
|
|
176
|
-
writeFileSync(
|
|
177
|
-
join(tmpDir, ".opencode", "opencode.json"),
|
|
178
|
-
JSON.stringify({ compaction: { auto: true } }),
|
|
179
|
-
);
|
|
180
|
-
|
|
181
|
-
const result = isOpenCodeAutoCompactionEnabled(tmpDir);
|
|
182
|
-
|
|
183
|
-
expect(result).toBe(false);
|
|
184
|
-
});
|
|
185
|
-
});
|
|
186
|
-
|
|
187
|
-
describe("#given root-level project config", () => {
|
|
188
|
-
it("#when root opencode.json has compaction.auto = false #then returns false", () => {
|
|
189
|
-
writeFileSync(
|
|
190
|
-
join(tmpDir, "opencode.json"),
|
|
191
|
-
JSON.stringify({ compaction: { auto: false } }),
|
|
192
|
-
);
|
|
193
|
-
|
|
194
|
-
const result = isOpenCodeAutoCompactionEnabled(tmpDir);
|
|
195
|
-
|
|
196
|
-
expect(result).toBe(false);
|
|
197
|
-
});
|
|
198
|
-
|
|
199
|
-
it("#when root opencode.jsonc has compaction.auto = false #then returns false", () => {
|
|
200
|
-
writeFileSync(join(tmpDir, "opencode.jsonc"), `{ "compaction": { "auto": false } }`);
|
|
201
|
-
|
|
202
|
-
const result = isOpenCodeAutoCompactionEnabled(tmpDir);
|
|
203
|
-
|
|
204
|
-
expect(result).toBe(false);
|
|
205
|
-
});
|
|
206
|
-
});
|
|
207
|
-
|
|
208
|
-
describe("#given .opencode/ overrides root-level config", () => {
|
|
209
|
-
it("#when root says false but .opencode says true #then .opencode wins", () => {
|
|
210
|
-
writeFileSync(
|
|
211
|
-
join(tmpDir, "opencode.json"),
|
|
212
|
-
JSON.stringify({ compaction: { auto: false } }),
|
|
213
|
-
);
|
|
214
|
-
writeFileSync(
|
|
215
|
-
join(tmpDir, ".opencode", "opencode.json"),
|
|
216
|
-
JSON.stringify({ compaction: { auto: true } }),
|
|
217
|
-
);
|
|
218
|
-
|
|
219
|
-
const result = isOpenCodeAutoCompactionEnabled(tmpDir);
|
|
220
|
-
|
|
221
|
-
expect(result).toBe(true);
|
|
222
|
-
});
|
|
223
|
-
|
|
224
|
-
it("#when root says true but .opencode says false #then .opencode wins", () => {
|
|
225
|
-
writeFileSync(
|
|
226
|
-
join(tmpDir, "opencode.json"),
|
|
227
|
-
JSON.stringify({ compaction: { auto: true } }),
|
|
228
|
-
);
|
|
229
|
-
writeFileSync(
|
|
230
|
-
join(tmpDir, ".opencode", "opencode.json"),
|
|
231
|
-
JSON.stringify({ compaction: { auto: false } }),
|
|
232
|
-
);
|
|
233
|
-
|
|
234
|
-
const result = isOpenCodeAutoCompactionEnabled(tmpDir);
|
|
235
|
-
|
|
236
|
-
expect(result).toBe(false);
|
|
237
|
-
});
|
|
238
|
-
});
|
|
239
|
-
});
|
|
@@ -1,81 +0,0 @@
|
|
|
1
|
-
import { join } from "node:path";
|
|
2
|
-
import { readJsoncFile } from "./jsonc-parser";
|
|
3
|
-
import { log } from "./logger";
|
|
4
|
-
import { getOpenCodeConfigPaths } from "./opencode-config-dir";
|
|
5
|
-
|
|
6
|
-
interface OpenCodeConfig {
|
|
7
|
-
compaction?: {
|
|
8
|
-
auto?: boolean;
|
|
9
|
-
prune?: boolean;
|
|
10
|
-
};
|
|
11
|
-
}
|
|
12
|
-
|
|
13
|
-
function hasCompactionConflict(
|
|
14
|
-
compaction: OpenCodeConfig["compaction"] | undefined,
|
|
15
|
-
): boolean | undefined {
|
|
16
|
-
if (!compaction) return undefined;
|
|
17
|
-
const hasExplicitSetting = compaction.auto !== undefined || compaction.prune !== undefined;
|
|
18
|
-
if (!hasExplicitSetting) return undefined;
|
|
19
|
-
return compaction.auto === true || compaction.prune === true;
|
|
20
|
-
}
|
|
21
|
-
|
|
22
|
-
export function isOpenCodeAutoCompactionEnabled(directory: string): boolean {
|
|
23
|
-
if (process.env.OPENCODE_DISABLE_AUTOCOMPACT) {
|
|
24
|
-
log(
|
|
25
|
-
"[compaction-detector] OPENCODE_DISABLE_AUTOCOMPACT env flag set — auto compaction disabled",
|
|
26
|
-
);
|
|
27
|
-
return false;
|
|
28
|
-
}
|
|
29
|
-
|
|
30
|
-
const projectCompaction = readProjectCompactionConfig(directory);
|
|
31
|
-
if (projectCompaction !== undefined) {
|
|
32
|
-
log("[compaction-detector] project config compaction conflict =", projectCompaction);
|
|
33
|
-
return projectCompaction;
|
|
34
|
-
}
|
|
35
|
-
|
|
36
|
-
const userCompaction = readUserCompactionConfig(directory);
|
|
37
|
-
if (userCompaction !== undefined) {
|
|
38
|
-
log("[compaction-detector] user config compaction conflict =", userCompaction);
|
|
39
|
-
return userCompaction;
|
|
40
|
-
}
|
|
41
|
-
|
|
42
|
-
log("[compaction-detector] no compaction config found — default is enabled");
|
|
43
|
-
return true;
|
|
44
|
-
}
|
|
45
|
-
|
|
46
|
-
function readProjectCompactionConfig(directory: string): boolean | undefined {
|
|
47
|
-
// .opencode/ dir config has higher precedence than root-level config in OpenCode's loading order.
|
|
48
|
-
// Check highest precedence first — if .opencode/ sets compaction.auto, that wins.
|
|
49
|
-
const dotOpenCodeJsonc = join(directory, ".opencode", "opencode.jsonc");
|
|
50
|
-
const dotOpenCodeJson = join(directory, ".opencode", "opencode.json");
|
|
51
|
-
const dotOpenCodeConfig =
|
|
52
|
-
readJsoncFile<OpenCodeConfig>(dotOpenCodeJsonc) ??
|
|
53
|
-
readJsoncFile<OpenCodeConfig>(dotOpenCodeJson);
|
|
54
|
-
|
|
55
|
-
const dotOpenCodeCompactionConflict = hasCompactionConflict(dotOpenCodeConfig?.compaction);
|
|
56
|
-
if (dotOpenCodeCompactionConflict !== undefined) {
|
|
57
|
-
return dotOpenCodeCompactionConflict;
|
|
58
|
-
}
|
|
59
|
-
|
|
60
|
-
// Root-level project config (lower precedence than .opencode/)
|
|
61
|
-
const rootJsonc = join(directory, "opencode.jsonc");
|
|
62
|
-
const rootJson = join(directory, "opencode.json");
|
|
63
|
-
const rootConfig =
|
|
64
|
-
readJsoncFile<OpenCodeConfig>(rootJsonc) ?? readJsoncFile<OpenCodeConfig>(rootJson);
|
|
65
|
-
|
|
66
|
-
return hasCompactionConflict(rootConfig?.compaction);
|
|
67
|
-
}
|
|
68
|
-
|
|
69
|
-
function readUserCompactionConfig(_directory: string): boolean | undefined {
|
|
70
|
-
try {
|
|
71
|
-
const paths = getOpenCodeConfigPaths({ binary: "opencode" });
|
|
72
|
-
const config =
|
|
73
|
-
readJsoncFile<OpenCodeConfig>(paths.configJsonc) ??
|
|
74
|
-
readJsoncFile<OpenCodeConfig>(paths.configJson);
|
|
75
|
-
|
|
76
|
-
return hasCompactionConflict(config?.compaction);
|
|
77
|
-
} catch {
|
|
78
|
-
// Intentional: config read is best-effort; missing/unreadable config is not an error
|
|
79
|
-
return undefined;
|
|
80
|
-
}
|
|
81
|
-
}
|