@wolfx/opencode-magic-context 0.28.0 → 0.30.1
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/magic-context-prompt.d.ts +1 -1
- package/dist/agents/magic-context-prompt.d.ts.map +1 -1
- package/dist/config/schema/magic-context.d.ts +11 -0
- package/dist/config/schema/magic-context.d.ts.map +1 -1
- package/dist/features/magic-context/dreamer/retrospective-raw-provider.d.ts +0 -1
- package/dist/features/magic-context/dreamer/retrospective-raw-provider.d.ts.map +1 -1
- package/dist/features/magic-context/dreamer/storage-task-schedule.d.ts +10 -0
- package/dist/features/magic-context/dreamer/storage-task-schedule.d.ts.map +1 -1
- package/dist/features/magic-context/dreamer/task-executor.d.ts +0 -3
- package/dist/features/magic-context/dreamer/task-executor.d.ts.map +1 -1
- package/dist/features/magic-context/dreamer/task-prompts.d.ts +1 -1
- package/dist/features/magic-context/dreamer/task-prompts.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/smart-notes/sandbox-runner.d.ts.map +1 -1
- package/dist/features/magic-context/storage-db.d.ts +2 -21
- package/dist/features/magic-context/storage-db.d.ts.map +1 -1
- package/dist/features/magic-context/storage-schema-helpers.d.ts +30 -0
- package/dist/features/magic-context/storage-schema-helpers.d.ts.map +1 -0
- package/dist/features/magic-context/storage-tags.d.ts.map +1 -1
- package/dist/features/magic-context/types.d.ts +12 -1
- package/dist/features/magic-context/types.d.ts.map +1 -1
- package/dist/hooks/magic-context/apply-operations.d.ts +8 -1
- package/dist/hooks/magic-context/apply-operations.d.ts.map +1 -1
- package/dist/hooks/magic-context/channel2-delivery.d.ts +9 -5
- package/dist/hooks/magic-context/channel2-delivery.d.ts.map +1 -1
- package/dist/hooks/magic-context/edit-marker.d.ts +11 -0
- package/dist/hooks/magic-context/edit-marker.d.ts.map +1 -0
- package/dist/hooks/magic-context/event-handler.d.ts +1 -4
- package/dist/hooks/magic-context/event-handler.d.ts.map +1 -1
- package/dist/hooks/magic-context/hook.d.ts +1 -2
- package/dist/hooks/magic-context/hook.d.ts.map +1 -1
- package/dist/hooks/magic-context/read-session-formatting.d.ts.map +1 -1
- package/dist/hooks/magic-context/supersession-reclaim.d.ts +34 -0
- package/dist/hooks/magic-context/supersession-reclaim.d.ts.map +1 -0
- package/dist/hooks/magic-context/system-prompt-hash.d.ts +5 -0
- package/dist/hooks/magic-context/system-prompt-hash.d.ts.map +1 -1
- package/dist/hooks/magic-context/tag-messages.d.ts +8 -0
- package/dist/hooks/magic-context/tag-messages.d.ts.map +1 -1
- package/dist/hooks/magic-context/tool-drop-target.d.ts +2 -0
- package/dist/hooks/magic-context/tool-drop-target.d.ts.map +1 -1
- package/dist/hooks/magic-context/transform-postprocess-phase.d.ts +8 -0
- package/dist/hooks/magic-context/transform-postprocess-phase.d.ts.map +1 -1
- package/dist/hooks/magic-context/transform.d.ts +4 -0
- package/dist/hooks/magic-context/transform.d.ts.map +1 -1
- package/dist/index.d.ts.map +1 -1
- package/dist/index.js +3227 -4977
- package/dist/plugin/hooks/create-session-hooks.d.ts.map +1 -1
- package/dist/plugin/rpc-handlers.d.ts.map +1 -1
- package/dist/plugin/tool-registry.d.ts.map +1 -1
- package/dist/shared/announcement.d.ts +1 -1
- package/dist/shared/announcement.d.ts.map +1 -1
- package/dist/shared/commit-detection.d.ts +29 -0
- package/dist/shared/commit-detection.d.ts.map +1 -0
- package/dist/shared/exit-abort-registry.d.ts +25 -0
- package/dist/shared/exit-abort-registry.d.ts.map +1 -0
- package/dist/shared/harness-provider-map.d.ts +30 -0
- package/dist/shared/harness-provider-map.d.ts.map +1 -0
- package/dist/shared/tag-transcript.d.ts.map +1 -1
- package/dist/shared/transcript.d.ts +15 -0
- package/dist/shared/transcript.d.ts.map +1 -1
- package/dist/tools/ctx-note/tools.d.ts.map +1 -1
- package/dist/tui/badge-contrast.d.ts +37 -22
- package/dist/tui/badge-contrast.d.ts.map +1 -1
- package/package.json +78 -77
- package/src/shared/announcement.ts +2 -3
- package/src/shared/commit-detection.test.ts +63 -0
- package/src/shared/commit-detection.ts +53 -0
- package/src/shared/exit-abort-registry.test.ts +50 -0
- package/src/shared/exit-abort-registry.ts +46 -0
- package/src/shared/harness-provider-map.test.ts +63 -0
- package/src/shared/harness-provider-map.ts +56 -0
- package/src/shared/tag-transcript.ts +32 -0
- package/src/shared/transcript-opencode.ts +33 -0
- package/src/shared/transcript.ts +17 -0
- package/src/tui/badge-contrast.test.ts +39 -1
- package/src/tui/badge-contrast.ts +63 -25
- package/src/tui/slots/sidebar-content.tsx +2 -2
- package/dist/hooks/is-anthropic-provider.d.ts +0 -2
- package/dist/hooks/is-anthropic-provider.d.ts.map +0 -1
- package/dist/shared/live-server-client.d.ts +0 -50
- package/dist/shared/live-server-client.d.ts.map +0 -1
- package/src/shared/live-server-client.ts +0 -152
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"create-session-hooks.d.ts","sourceRoot":"","sources":["../../../src/plugin/hooks/create-session-hooks.ts"],"names":[],"mappings":"AAAA,OAAO,KAAK,EAAE,wBAAwB,EAAE,MAAM,cAAc,CAAC;AAO7D,OAAO,KAAK,EAAE,gBAAgB,EAAE,MAAM,8CAA8C,CAAC;AACrF,OAAO,KAAK,EAAE,aAAa,EAAE,MAAM,UAAU,CAAC;AAE9C;;;;;;GAMG;AACH,wBAAgB,2BAA2B,CAAC,YAAY,EAAE,wBAAwB;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;EA0BjF;AAED,wBAAgB,kBAAkB,CAAC,IAAI,EAAE;IACrC,GAAG,EAAE,aAAa,CAAC;IACnB,YAAY,EAAE,wBAAwB,CAAC;IACvC,gBAAgB,EAAE,gBAAgB,CAAC;CACtC;;;;;;
|
|
1
|
+
{"version":3,"file":"create-session-hooks.d.ts","sourceRoot":"","sources":["../../../src/plugin/hooks/create-session-hooks.ts"],"names":[],"mappings":"AAAA,OAAO,KAAK,EAAE,wBAAwB,EAAE,MAAM,cAAc,CAAC;AAO7D,OAAO,KAAK,EAAE,gBAAgB,EAAE,MAAM,8CAA8C,CAAC;AACrF,OAAO,KAAK,EAAE,aAAa,EAAE,MAAM,UAAU,CAAC;AAE9C;;;;;;GAMG;AACH,wBAAgB,2BAA2B,CAAC,YAAY,EAAE,wBAAwB;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;EA0BjF;AAED,wBAAgB,kBAAkB,CAAC,IAAI,EAAE;IACrC,GAAG,EAAE,aAAa,CAAC;IACnB,YAAY,EAAE,wBAAwB,CAAC;IACvC,gBAAgB,EAAE,gBAAgB,CAAC;CACtC;;;;;;qBA2B28K,CAAC;;;;;;;;;;;;qBAAjhE,CAAC;mBAAyB,CAAC;iBAAuB,CAAC;iBAAuB,CAAC;0BAAc,CAAC;uBAAiB,CAAC;;;;;;0BAAo9mC,CAAC;;;;;;EAD5/tC"}
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"rpc-handlers.d.ts","sourceRoot":"","sources":["../../src/plugin/rpc-handlers.ts"],"names":[],"mappings":"AAAA;;;GAGG;AACH,OAAO,KAAK,EAAE,kBAAkB,EAAE,MAAM,gCAAgC,CAAC;
|
|
1
|
+
{"version":3,"file":"rpc-handlers.d.ts","sourceRoot":"","sources":["../../src/plugin/rpc-handlers.ts"],"names":[],"mappings":"AAAA;;;GAGG;AACH,OAAO,KAAK,EAAE,kBAAkB,EAAE,MAAM,gCAAgC,CAAC;AAIzE,OAAO,EACH,KAAK,eAAe,IAAI,QAAQ,EAGnC,MAAM,mCAAmC,CAAC;AAc3C,OAAO,KAAK,EAAE,gBAAgB,EAAE,MAAM,2CAA2C,CAAC;AAqBlF,OAAO,KAAK,EAAE,qBAAqB,EAAE,MAAM,sBAAsB,CAAC;AAClE,OAAO,KAAK,EAAe,eAAe,EAAE,YAAY,EAAE,MAAM,qBAAqB,CAAC;AA0FtF,wBAAgB,oBAAoB,CAChC,EAAE,EAAE,QAAQ,EACZ,SAAS,EAAE,MAAM,EACjB,SAAS,EAAE,MAAM,EACjB,gBAAgB,CAAC,EAAE,gBAAgB,EACnC,qBAAqB,CAAC,EAAE,MAAM,EAK9B,MAAM,CAAC,EAAE,MAAM,CAAC,MAAM,EAAE,OAAO,CAAC,GACjC,eAAe,CAuVjB;AAED,wBAAgB,iBAAiB,CAC7B,EAAE,EAAE,QAAQ,EACZ,SAAS,EAAE,MAAM,EACjB,SAAS,EAAE,MAAM,EACjB,QAAQ,CAAC,EAAE,MAAM,EACjB,MAAM,CAAC,EAAE,MAAM,CAAC,MAAM,EAAE,OAAO,CAAC,EAChC,gBAAgB,CAAC,EAAE,gBAAgB,EACnC,qBAAqB,CAAC,EAAE,MAAM,GAC/B,YAAY,CAyKd;AA4BD;;GAEG;AACH,wBAAgB,mBAAmB,CAC/B,SAAS,EAAE,qBAAqB,EAChC,IAAI,EAAE;IACF,SAAS,EAAE,MAAM,CAAC;IAClB,MAAM,EAAE,kBAAkB,CAAC;IAC3B,MAAM,EAAE,OAAO,CAAC;IAChB,gBAAgB,EAAE,gBAAgB,CAAC;CACtC,GACF,IAAI,CAyPN"}
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"tool-registry.d.ts","sourceRoot":"","sources":["../../src/plugin/tool-registry.ts"],"names":[],"mappings":"AAAA,OAAO,KAAK,EAAE,cAAc,EAAE,MAAM,qBAAqB,CAAC;AAC1D,OAAO,KAAK,EAAE,wBAAwB,EAAE,MAAM,WAAW,CAAC;AAiB1D,OAAO,KAAK,EAAE,aAAa,EAAE,MAAM,SAAS,CAAC;AAE7C,wBAAgB,kBAAkB,CAAC,IAAI,EAAE;IACrC,GAAG,EAAE,aAAa,CAAC;IACnB,YAAY,EAAE,wBAAwB,CAAC;CAC1C,GAAG,MAAM,CAAC,MAAM,EAAE,cAAc,CAAC,
|
|
1
|
+
{"version":3,"file":"tool-registry.d.ts","sourceRoot":"","sources":["../../src/plugin/tool-registry.ts"],"names":[],"mappings":"AAAA,OAAO,KAAK,EAAE,cAAc,EAAE,MAAM,qBAAqB,CAAC;AAC1D,OAAO,KAAK,EAAE,wBAAwB,EAAE,MAAM,WAAW,CAAC;AAiB1D,OAAO,KAAK,EAAE,aAAa,EAAE,MAAM,SAAS,CAAC;AAE7C,wBAAgB,kBAAkB,CAAC,IAAI,EAAE;IACrC,GAAG,EAAE,aAAa,CAAC;IACnB,YAAY,EAAE,wBAAwB,CAAC;CAC1C,GAAG,MAAM,CAAC,MAAM,EAAE,cAAc,CAAC,CAyFjC"}
|
|
@@ -18,7 +18,7 @@
|
|
|
18
18
|
* Bump only when there are user-visible changes worth a startup dialog.
|
|
19
19
|
* Does NOT need to match the published package version.
|
|
20
20
|
*/
|
|
21
|
-
export declare const ANNOUNCEMENT_VERSION = "0.
|
|
21
|
+
export declare const ANNOUNCEMENT_VERSION = "0.30.1";
|
|
22
22
|
/**
|
|
23
23
|
* Short, user-facing bullet strings. Keep each line ~80 chars or shorter so the
|
|
24
24
|
* TUI dialog renders cleanly without horizontal scroll on a typical terminal.
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"announcement.d.ts","sourceRoot":"","sources":["../../src/shared/announcement.ts"],"names":[],"mappings":"AAAA;;;;;;;;;;;;;;;GAeG;AAoBH;;;GAGG;AACH,eAAO,MAAM,oBAAoB,WAAW,CAAC;AAE7C;;;GAGG;AACH,eAAO,MAAM,qBAAqB,EAAE,aAAa,CAAC,MAAM,
|
|
1
|
+
{"version":3,"file":"announcement.d.ts","sourceRoot":"","sources":["../../src/shared/announcement.ts"],"names":[],"mappings":"AAAA;;;;;;;;;;;;;;;GAeG;AAoBH;;;GAGG;AACH,eAAO,MAAM,oBAAoB,WAAW,CAAC;AAE7C;;;GAGG;AACH,eAAO,MAAM,qBAAqB,EAAE,aAAa,CAAC,MAAM,CAEvD,CAAC;AAEF;;;;;;GAMG;AACH,eAAO,MAAM,mBAAmB,qDAAqD,CAAC;AAyBtF;;;;GAIG;AACH,wBAAgB,wBAAwB,IAAI,MAAM,CAGjD;AAED;;;;GAIG;AACH,wBAAgB,oBAAoB,CAAC,OAAO,EAAE,MAAM,GAAG,IAAI,CAS1D;AAED;;;;;;;;;;;;;;;;;;;;GAoBG;AACH,wBAAgB,sBAAsB,IAAI,OAAO,CA0BhD"}
|
|
@@ -0,0 +1,29 @@
|
|
|
1
|
+
/**
|
|
2
|
+
* Boolean hash test. Non-global (stateless), so this single instance is safe to
|
|
3
|
+
* reuse with `.test()` across call sites — only `/g` regexes carry `lastIndex`.
|
|
4
|
+
*/
|
|
5
|
+
export declare const COMMIT_HASH_TEST_PATTERN: RegExp;
|
|
6
|
+
/**
|
|
7
|
+
* Commit-ACTION verbs, with common inflections, each fully word-boundary-anchored
|
|
8
|
+
* (so they don't match e.g. "commitment"/"merger"). Non-global → safe to share.
|
|
9
|
+
*
|
|
10
|
+
* Scope decision: this is the commit-action set the OpenCode + Pi note-nudge
|
|
11
|
+
* detectors used and pin in tests ("commit/cherry-pick/merge/rebase"). It does
|
|
12
|
+
* NOT include the bare nouns "hash"/"sha" that the historian's old hint regex
|
|
13
|
+
* carried — a parity test asserts "hash <hex>" alone must NOT count as a commit,
|
|
14
|
+
* and those nouns only ever gated a cosmetic hash-strip in historian summaries
|
|
15
|
+
* (never a trigger), so unifying to the action set is behavior-preserving where
|
|
16
|
+
* it matters.
|
|
17
|
+
*/
|
|
18
|
+
export declare const COMMIT_VERB_PATTERN: RegExp;
|
|
19
|
+
/** True when a text part mentions a commit hash in a commit context. Used by the
|
|
20
|
+
* OpenCode + Pi note-nudge detectors. */
|
|
21
|
+
export declare function textMentionsRecentCommit(text: string): boolean;
|
|
22
|
+
/**
|
|
23
|
+
* Fresh `/g` capturing, backtick-aware hash pattern for the historian's
|
|
24
|
+
* extract-and-strip path (matchAll + replace). Returned as a NEW instance per
|
|
25
|
+
* call: a `/g` regex carries `lastIndex`, so handing out a fresh one is
|
|
26
|
+
* bulletproof against accidental `.exec()` reuse across callers.
|
|
27
|
+
*/
|
|
28
|
+
export declare function createCommitHashExtractPattern(): RegExp;
|
|
29
|
+
//# sourceMappingURL=commit-detection.d.ts.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"commit-detection.d.ts","sourceRoot":"","sources":["../../src/shared/commit-detection.ts"],"names":[],"mappings":"AAiBA;;;GAGG;AACH,eAAO,MAAM,wBAAwB,QAAuC,CAAC;AAE7E;;;;;;;;;;;GAWG;AACH,eAAO,MAAM,mBAAmB,QACsE,CAAC;AAEvG;0CAC0C;AAC1C,wBAAgB,wBAAwB,CAAC,IAAI,EAAE,MAAM,GAAG,OAAO,CAE9D;AAED;;;;;GAKG;AACH,wBAAgB,8BAA8B,IAAI,MAAM,CAEvD"}
|
|
@@ -0,0 +1,25 @@
|
|
|
1
|
+
/**
|
|
2
|
+
* Process-global registry of AbortControllers to abort on process exit, backed
|
|
3
|
+
* by a SINGLE `process.once("exit")` listener no matter how many controllers
|
|
4
|
+
* register.
|
|
5
|
+
*
|
|
6
|
+
* Why this exists: the plugin factory runs once per plugin instance, and
|
|
7
|
+
* OpenCode Desktop loads many instances in one Node process (one per open
|
|
8
|
+
* project). Registering a `process.once("exit")` per instance added one listener
|
|
9
|
+
* each, so past Node's default 10-listener cap it logged a
|
|
10
|
+
* `MaxListenersExceededWarning` ("11 exit listeners added to [process]"). One
|
|
11
|
+
* module-global listener that fans out to every registered controller keeps the
|
|
12
|
+
* count at one.
|
|
13
|
+
*/
|
|
14
|
+
/**
|
|
15
|
+
* Abort `controller` when the process exits. The underlying `process.once("exit")`
|
|
16
|
+
* listener is installed on the first call only; subsequent calls just add to the
|
|
17
|
+
* fan-out set.
|
|
18
|
+
*/
|
|
19
|
+
export declare function registerExitAbort(controller: AbortController): void;
|
|
20
|
+
/**
|
|
21
|
+
* Stop tracking `controller` (e.g. when its plugin instance is disposed) so the
|
|
22
|
+
* set doesn't grow without bound as Desktop opens and closes projects.
|
|
23
|
+
*/
|
|
24
|
+
export declare function unregisterExitAbort(controller: AbortController): void;
|
|
25
|
+
//# sourceMappingURL=exit-abort-registry.d.ts.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"exit-abort-registry.d.ts","sourceRoot":"","sources":["../../src/shared/exit-abort-registry.ts"],"names":[],"mappings":"AAAA;;;;;;;;;;;;GAYG;AAeH;;;;GAIG;AACH,wBAAgB,iBAAiB,CAAC,UAAU,EAAE,eAAe,GAAG,IAAI,CAKnE;AAED;;;GAGG;AACH,wBAAgB,mBAAmB,CAAC,UAAU,EAAE,eAAe,GAAG,IAAI,CAErE"}
|
|
@@ -0,0 +1,30 @@
|
|
|
1
|
+
/**
|
|
2
|
+
* Provider-id translation between the canonical (OpenCode) form stored in the
|
|
3
|
+
* shared magic-context config and Pi's harness-native provider ids.
|
|
4
|
+
*
|
|
5
|
+
* OpenCode and Pi now share ONE config, but a few auth-plugin providers were
|
|
6
|
+
* named differently on each side. The model id AFTER the slash is identical;
|
|
7
|
+
* only the provider prefix differs:
|
|
8
|
+
*
|
|
9
|
+
* canonical (OpenCode) Pi
|
|
10
|
+
* -------------------- -------------------
|
|
11
|
+
* openai/<model> openai-codex/<model>
|
|
12
|
+
* google/<model> google-antigravity/<model>
|
|
13
|
+
* anthropic/<model> anthropic/<model> (same; every other provider too)
|
|
14
|
+
*
|
|
15
|
+
* Canonical = OpenCode: the config always stores the OpenCode form. Pi
|
|
16
|
+
* translates at its edges:
|
|
17
|
+
* - read: canonical -> Pi when spawning a configured model (subagent-runner).
|
|
18
|
+
* - write: Pi -> canonical in the Pi setup wizard, so a config written from
|
|
19
|
+
* the Pi side stays readable by OpenCode.
|
|
20
|
+
*
|
|
21
|
+
* OpenCode needs no translation (canonical IS the OpenCode form).
|
|
22
|
+
*/
|
|
23
|
+
/** Pi-native `provider/model` -> canonical (OpenCode). Identity when unmapped.
|
|
24
|
+
* Used by the Pi setup wizard so configs it writes stay OpenCode-readable. */
|
|
25
|
+
export declare function piModelRefToCanonical(ref: string): string;
|
|
26
|
+
/** Canonical (OpenCode) `provider/model` -> Pi-native, for spawning a model on
|
|
27
|
+
* Pi. Idempotent: normalizes any Pi-form prefix back to canonical first, so it
|
|
28
|
+
* is safe on a config that already holds Pi-form ids (hand-edited or pre-fix). */
|
|
29
|
+
export declare function resolveModelRefForPi(ref: string): string;
|
|
30
|
+
//# sourceMappingURL=harness-provider-map.d.ts.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"harness-provider-map.d.ts","sourceRoot":"","sources":["../../src/shared/harness-provider-map.ts"],"names":[],"mappings":"AAAA;;;;;;;;;;;;;;;;;;;;;GAqBG;AAuBH;+EAC+E;AAC/E,wBAAgB,qBAAqB,CAAC,GAAG,EAAE,MAAM,GAAG,MAAM,CAEzD;AAED;;mFAEmF;AACnF,wBAAgB,oBAAoB,CAAC,GAAG,EAAE,MAAM,GAAG,MAAM,CAExD"}
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"tag-transcript.d.ts","sourceRoot":"","sources":["../../src/shared/tag-transcript.ts"],"names":[],"mappings":"AAAA;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;GA6CG;AAEH,OAAO,KAAK,EAAE,eAAe,EAAE,MAAM,mCAAmC,CAAC;AAQzE,OAAO,EAAwB,KAAK,MAAM,EAAE,MAAM,kCAAkC,CAAC;
|
|
1
|
+
{"version":3,"file":"tag-transcript.d.ts","sourceRoot":"","sources":["../../src/shared/tag-transcript.ts"],"names":[],"mappings":"AAAA;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;GA6CG;AAEH,OAAO,KAAK,EAAE,eAAe,EAAE,MAAM,mCAAmC,CAAC;AAQzE,OAAO,EAAwB,KAAK,MAAM,EAAE,MAAM,kCAAkC,CAAC;AASrF,OAAO,KAAK,EAAE,SAAS,EAAE,MAAM,qCAAqC,CAAC;AACrE,OAAO,KAAK,EAAE,UAAU,EAAkB,MAAM,cAAc,CAAC;AAE/D,MAAM,WAAW,oBAAoB;IACjC;;;;;;;OAOG;IACH,mBAAmB,CAAC,EAAE,OAAO,CAAC;IAC9B;;;;;;;OAOG;IACH,2BAA2B,CAAC,EAAE,WAAW,CAAC,MAAM,EAAE,MAAM,CAAC,CAAC;CAC7D;AAED,MAAM,WAAW,mBAAmB;IAChC,OAAO,EAAE,GAAG,CAAC,MAAM,EAAE,SAAS,CAAC,CAAC;CACnC;AA8DD,wBAAgB,aAAa,CACzB,SAAS,EAAE,MAAM,EACjB,UAAU,EAAE,UAAU,EACtB,MAAM,EAAE,MAAM,EACd,EAAE,EAAE,eAAe,EACnB,OAAO,GAAE,oBAAyB,GACnC,mBAAmB,CAiPrB"}
|
|
@@ -117,6 +117,21 @@ export interface TranscriptPart {
|
|
|
117
117
|
inputByteSize: number;
|
|
118
118
|
inputTokenCount: number;
|
|
119
119
|
};
|
|
120
|
+
/**
|
|
121
|
+
* Non-mutating read of this tool invocation's input object, or null for
|
|
122
|
+
* non-tool parts / parts without an input. Used by smart-drops supersession
|
|
123
|
+
* selection (read `ctx_note`'s action, an edit's `filePath`) without
|
|
124
|
+
* touching the wire. Returns the live object reference; callers must NOT
|
|
125
|
+
* mutate it.
|
|
126
|
+
*/
|
|
127
|
+
getToolInput?(): Record<string, unknown> | null;
|
|
128
|
+
/**
|
|
129
|
+
* Replace this tool invocation's input object with `input`. Used by the
|
|
130
|
+
* smart-drops edit_marker path to write back a filePath-preserving,
|
|
131
|
+
* region-hint-clamped copy of an edit's arguments. Returns true if the part
|
|
132
|
+
* carried a writable tool input. No-op (false) for non-tool parts.
|
|
133
|
+
*/
|
|
134
|
+
setToolInput?(input: Record<string, unknown>): boolean;
|
|
120
135
|
/**
|
|
121
136
|
* Replace this part with a sentinel placeholder. Sentinels look like
|
|
122
137
|
* `[dropped §N§]` or `[truncated §N§]` and survive cache-busting
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"transcript.d.ts","sourceRoot":"","sources":["../../src/shared/transcript.ts"],"names":[],"mappings":"AAAA;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;GA+CG;AAEH,2EAA2E;AAC3E,MAAM,MAAM,kBAAkB,GACxB,MAAM,GACN,UAAU,GACV,UAAU,GACV,aAAa,GACb,OAAO,GACP,MAAM,GACN,YAAY,GACZ,SAAS,CAAC;AAEhB;;;;;;;;;;;;;GAaG;AACH,MAAM,WAAW,cAAc;IAC3B,+DAA+D;IAC/D,QAAQ,CAAC,IAAI,EAAE,kBAAkB,CAAC;IAElC;;;;;;;;OAQG;IACH,QAAQ,CAAC,EAAE,EAAE,MAAM,GAAG,SAAS,CAAC;IAEhC;;;;;;;OAOG;IACH,OAAO,IAAI,MAAM,GAAG,SAAS,CAAC;IAE9B;;;;;;;;OAQG;IACH,OAAO,CAAC,OAAO,EAAE,MAAM,GAAG,OAAO,CAAC;IAElC;;;;OAIG;IACH,aAAa,CAAC,OAAO,EAAE,MAAM,GAAG,OAAO,CAAC;IAExC;;;;;;;;;;;OAWG;IACH,eAAe,IAAI;QACf,QAAQ,EAAE,MAAM,GAAG,SAAS,CAAC;QAC7B,aAAa,EAAE,MAAM,CAAC;QACtB,eAAe,EAAE,MAAM,CAAC;KAC3B,CAAC;IAEF;;;;;;;;;;;;OAYG;IACH,mBAAmB,CAAC,YAAY,EAAE,MAAM,GAAG,OAAO,CAAC;IAEnD;;;;;;;;OAQG;IACH,WAAW,CAAC,IAAI,MAAM,CAAC;CAC1B;AAED;;;;;;GAMG;AACH,MAAM,WAAW,iBAAiB;IAC9B;;;;;;;;;;;;;;;;OAgBG;IACH,QAAQ,CAAC,IAAI,EAAE;QAAE,EAAE,CAAC,EAAE,MAAM,CAAC;QAAC,IAAI,EAAE,MAAM,CAAC;QAAC,SAAS,CAAC,EAAE,MAAM,CAAA;KAAE,CAAC;IAEjE,wEAAwE;IACxE,QAAQ,CAAC,KAAK,EAAE,cAAc,EAAE,CAAC;CACpC;AAED;;;;;;;;;GASG;AACH,MAAM,WAAW,UAAU;IACvB,4CAA4C;IAC5C,QAAQ,CAAC,QAAQ,EAAE,iBAAiB,EAAE,CAAC;IAEvC;;;;;;OAMG;IACH,QAAQ,CAAC,OAAO,EAAE,UAAU,GAAG,IAAI,CAAC;IAEpC;;;;;;;;;;;;;OAaG;IACH,MAAM,IAAI,IAAI,CAAC;CAClB;AAED;;;;;;;;;GASG;AACH,eAAO,MAAM,wBAAwB,EAAE,kBAAiC,CAAC"}
|
|
1
|
+
{"version":3,"file":"transcript.d.ts","sourceRoot":"","sources":["../../src/shared/transcript.ts"],"names":[],"mappings":"AAAA;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;GA+CG;AAEH,2EAA2E;AAC3E,MAAM,MAAM,kBAAkB,GACxB,MAAM,GACN,UAAU,GACV,UAAU,GACV,aAAa,GACb,OAAO,GACP,MAAM,GACN,YAAY,GACZ,SAAS,CAAC;AAEhB;;;;;;;;;;;;;GAaG;AACH,MAAM,WAAW,cAAc;IAC3B,+DAA+D;IAC/D,QAAQ,CAAC,IAAI,EAAE,kBAAkB,CAAC;IAElC;;;;;;;;OAQG;IACH,QAAQ,CAAC,EAAE,EAAE,MAAM,GAAG,SAAS,CAAC;IAEhC;;;;;;;OAOG;IACH,OAAO,IAAI,MAAM,GAAG,SAAS,CAAC;IAE9B;;;;;;;;OAQG;IACH,OAAO,CAAC,OAAO,EAAE,MAAM,GAAG,OAAO,CAAC;IAElC;;;;OAIG;IACH,aAAa,CAAC,OAAO,EAAE,MAAM,GAAG,OAAO,CAAC;IAExC;;;;;;;;;;;OAWG;IACH,eAAe,IAAI;QACf,QAAQ,EAAE,MAAM,GAAG,SAAS,CAAC;QAC7B,aAAa,EAAE,MAAM,CAAC;QACtB,eAAe,EAAE,MAAM,CAAC;KAC3B,CAAC;IAEF;;;;;;OAMG;IACH,YAAY,CAAC,IAAI,MAAM,CAAC,MAAM,EAAE,OAAO,CAAC,GAAG,IAAI,CAAC;IAEhD;;;;;OAKG;IACH,YAAY,CAAC,CAAC,KAAK,EAAE,MAAM,CAAC,MAAM,EAAE,OAAO,CAAC,GAAG,OAAO,CAAC;IAEvD;;;;;;;;;;;;OAYG;IACH,mBAAmB,CAAC,YAAY,EAAE,MAAM,GAAG,OAAO,CAAC;IAEnD;;;;;;;;OAQG;IACH,WAAW,CAAC,IAAI,MAAM,CAAC;CAC1B;AAED;;;;;;GAMG;AACH,MAAM,WAAW,iBAAiB;IAC9B;;;;;;;;;;;;;;;;OAgBG;IACH,QAAQ,CAAC,IAAI,EAAE;QAAE,EAAE,CAAC,EAAE,MAAM,CAAC;QAAC,IAAI,EAAE,MAAM,CAAC;QAAC,SAAS,CAAC,EAAE,MAAM,CAAA;KAAE,CAAC;IAEjE,wEAAwE;IACxE,QAAQ,CAAC,KAAK,EAAE,cAAc,EAAE,CAAC;CACpC;AAED;;;;;;;;;GASG;AACH,MAAM,WAAW,UAAU;IACvB,4CAA4C;IAC5C,QAAQ,CAAC,QAAQ,EAAE,iBAAiB,EAAE,CAAC;IAEvC;;;;;;OAMG;IACH,QAAQ,CAAC,OAAO,EAAE,UAAU,GAAG,IAAI,CAAC;IAEpC;;;;;;;;;;;;;OAaG;IACH,MAAM,IAAI,IAAI,CAAC;CAClB;AAED;;;;;;;;;GASG;AACH,eAAO,MAAM,wBAAwB,EAAE,kBAAiC,CAAC"}
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"tools.d.ts","sourceRoot":"","sources":["../../../src/tools/ctx-note/tools.ts"],"names":[],"mappings":"AAAA,OAAO,EAAE,KAAK,cAAc,EAAQ,MAAM,qBAAqB,CAAC;AAYhE,OAAO,KAAK,EAAE,QAAQ,EAAE,MAAM,qBAAqB,CAAC;AAIpD,MAAM,WAAW,eAAe;IAC5B,EAAE,EAAE,QAAQ,CAAC;IACb,cAAc,CAAC,EAAE,OAAO,CAAC;IACzB;;;;;OAKG;IACH,kBAAkB,CAAC,EAAE,CAAC,SAAS,EAAE,MAAM,KAAK,MAAM,CAAC;CACtD;
|
|
1
|
+
{"version":3,"file":"tools.d.ts","sourceRoot":"","sources":["../../../src/tools/ctx-note/tools.ts"],"names":[],"mappings":"AAAA,OAAO,EAAE,KAAK,cAAc,EAAQ,MAAM,qBAAqB,CAAC;AAYhE,OAAO,KAAK,EAAE,QAAQ,EAAE,MAAM,qBAAqB,CAAC;AAIpD,MAAM,WAAW,eAAe;IAC5B,EAAE,EAAE,QAAQ,CAAC;IACb,cAAc,CAAC,EAAE,OAAO,CAAC;IACzB;;;;;OAKG;IACH,kBAAkB,CAAC,EAAE,CAAC,SAAS,EAAE,MAAM,KAAK,MAAM,CAAC;CACtD;AAuTD,wBAAgB,kBAAkB,CAAC,IAAI,EAAE,eAAe,GAAG,MAAM,CAAC,MAAM,EAAE,cAAc,CAAC,CAIxF"}
|
|
@@ -1,31 +1,46 @@
|
|
|
1
1
|
/**
|
|
2
|
-
* Pick
|
|
3
|
-
* background
|
|
2
|
+
* Pick the text color for the sidebar header badge (a bold label drawn on a
|
|
3
|
+
* `theme.accent` background).
|
|
4
4
|
*
|
|
5
|
-
*
|
|
6
|
-
*
|
|
7
|
-
*
|
|
8
|
-
*
|
|
9
|
-
*
|
|
10
|
-
* always opaque, so deriving the text color from it is transparency-proof.
|
|
5
|
+
* Primary rule (matches AFT's sidebar by construction): paint the theme's own
|
|
6
|
+
* `background` color as the label, the inverse-of-panel look. Because it is a
|
|
7
|
+
* fixed theme token rather than an accent-derived computation, MC's badge and
|
|
8
|
+
* AFT's badge agree on EVERY accent automatically, so the same theme can never
|
|
9
|
+
* make one badge black and the other white (issue #198).
|
|
11
10
|
*
|
|
12
|
-
*
|
|
13
|
-
*
|
|
14
|
-
*
|
|
15
|
-
*
|
|
16
|
-
*
|
|
17
|
-
*
|
|
18
|
-
*
|
|
19
|
-
*
|
|
20
|
-
*
|
|
11
|
+
* Fallback rule (the reason a luminance pick exists at all): `theme.background`
|
|
12
|
+
* can be unusable as a label color in two degenerate cases, where it would
|
|
13
|
+
* render the label invisible on the accent:
|
|
14
|
+
* 1. Transparent background. Themes that respect terminal transparency set
|
|
15
|
+
* `background: "none"`, which resolves to `RGBA(0,0,0,0)`; drawing it as
|
|
16
|
+
* text renders fully transparent and the label disappears (issue #186).
|
|
17
|
+
* 2. Background ~= accent. If the theme's background and accent are nearly the
|
|
18
|
+
* same color, background-on-accent text has no contrast.
|
|
19
|
+
* In either case we fall back to a black/white pick that is guaranteed visible
|
|
20
|
+
* on the always-opaque accent.
|
|
21
21
|
*
|
|
22
|
-
* `RGBA` channels from @opentui/core are normalized 0..1 floats
|
|
23
|
-
* minimal `{ r, g, b }` shape so this stays a pure, trivially
|
|
24
|
-
* independent of the native color class
|
|
22
|
+
* `RGBA` channels from @opentui/core are normalized 0..1 floats (alpha included).
|
|
23
|
+
* We accept the minimal `{ r, g, b, a? }` shape so this stays a pure, trivially
|
|
24
|
+
* testable function independent of the native color class, and we return the
|
|
25
|
+
* passed-in `background` object unchanged on the primary path so it stays the
|
|
26
|
+
* exact same theme token AFT uses.
|
|
25
27
|
*/
|
|
26
|
-
|
|
28
|
+
type Color = {
|
|
27
29
|
r: number;
|
|
28
30
|
g: number;
|
|
29
31
|
b: number;
|
|
30
|
-
|
|
32
|
+
a?: number;
|
|
33
|
+
};
|
|
34
|
+
/**
|
|
35
|
+
* Pure black/white pick by accent luminance. Used as the badge fallback and kept
|
|
36
|
+
* exported for callers that only have the accent.
|
|
37
|
+
*/
|
|
38
|
+
export declare function readableTextColorOn(bg: Color): string;
|
|
39
|
+
/**
|
|
40
|
+
* Badge label color on the accent: the theme background (AFT parity) when it is
|
|
41
|
+
* usable, else a guaranteed-visible black/white fallback. Returns the passed-in
|
|
42
|
+
* `background` reference unchanged on the primary path.
|
|
43
|
+
*/
|
|
44
|
+
export declare function badgeTextColor<T extends Color>(accent: T, background: T): T | string;
|
|
45
|
+
export {};
|
|
31
46
|
//# sourceMappingURL=badge-contrast.d.ts.map
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"badge-contrast.d.ts","sourceRoot":"","sources":["../../src/tui/badge-contrast.ts"],"names":[],"mappings":"AAAA
|
|
1
|
+
{"version":3,"file":"badge-contrast.d.ts","sourceRoot":"","sources":["../../src/tui/badge-contrast.ts"],"names":[],"mappings":"AAAA;;;;;;;;;;;;;;;;;;;;;;;;;;GA0BG;AAEH,KAAK,KAAK,GAAG;IAAE,CAAC,EAAE,MAAM,CAAC;IAAC,CAAC,EAAE,MAAM,CAAC;IAAC,CAAC,EAAE,MAAM,CAAC;IAAC,CAAC,CAAC,EAAE,MAAM,CAAA;CAAE,CAAC;AAoC7D;;;GAGG;AACH,wBAAgB,mBAAmB,CAAC,EAAE,EAAE,KAAK,GAAG,MAAM,CAErD;AAED;;;;GAIG;AACH,wBAAgB,cAAc,CAAC,CAAC,SAAS,KAAK,EAAE,MAAM,EAAE,CAAC,EAAE,UAAU,EAAE,CAAC,GAAG,CAAC,GAAG,MAAM,CAMpF"}
|
package/package.json
CHANGED
|
@@ -1,79 +1,80 @@
|
|
|
1
1
|
{
|
|
2
|
-
|
|
3
|
-
|
|
4
|
-
|
|
5
|
-
|
|
6
|
-
|
|
7
|
-
|
|
8
|
-
|
|
9
|
-
|
|
10
|
-
|
|
11
|
-
|
|
12
|
-
|
|
13
|
-
|
|
14
|
-
|
|
15
|
-
|
|
16
|
-
|
|
17
|
-
|
|
18
|
-
|
|
19
|
-
|
|
20
|
-
|
|
21
|
-
|
|
22
|
-
|
|
23
|
-
|
|
24
|
-
|
|
25
|
-
|
|
26
|
-
|
|
27
|
-
|
|
28
|
-
|
|
29
|
-
|
|
30
|
-
|
|
31
|
-
|
|
32
|
-
|
|
33
|
-
|
|
34
|
-
|
|
35
|
-
|
|
36
|
-
|
|
37
|
-
|
|
38
|
-
|
|
39
|
-
|
|
40
|
-
|
|
41
|
-
|
|
42
|
-
|
|
43
|
-
|
|
44
|
-
|
|
45
|
-
|
|
46
|
-
|
|
47
|
-
|
|
48
|
-
|
|
49
|
-
|
|
50
|
-
|
|
51
|
-
|
|
52
|
-
|
|
53
|
-
|
|
54
|
-
|
|
55
|
-
|
|
56
|
-
|
|
57
|
-
|
|
58
|
-
|
|
59
|
-
|
|
60
|
-
|
|
61
|
-
|
|
62
|
-
|
|
63
|
-
|
|
64
|
-
|
|
65
|
-
|
|
66
|
-
|
|
67
|
-
|
|
68
|
-
|
|
69
|
-
|
|
70
|
-
|
|
71
|
-
|
|
72
|
-
|
|
73
|
-
|
|
74
|
-
|
|
75
|
-
|
|
76
|
-
|
|
77
|
-
|
|
78
|
-
|
|
2
|
+
"name": "@wolfx/opencode-magic-context",
|
|
3
|
+
"version": "0.30.1",
|
|
4
|
+
"type": "module",
|
|
5
|
+
"description": "OpenCode plugin for Magic Context — cross-session memory and context management",
|
|
6
|
+
"main": "dist/index.js",
|
|
7
|
+
"types": "dist/index.d.ts",
|
|
8
|
+
"author": "ualtinok",
|
|
9
|
+
"license": "MIT",
|
|
10
|
+
"keywords": [
|
|
11
|
+
"opencode",
|
|
12
|
+
"plugin",
|
|
13
|
+
"context",
|
|
14
|
+
"memory",
|
|
15
|
+
"ai",
|
|
16
|
+
"llm",
|
|
17
|
+
"prompt-caching",
|
|
18
|
+
"session-history"
|
|
19
|
+
],
|
|
20
|
+
"repository": {
|
|
21
|
+
"type": "git",
|
|
22
|
+
"url": "https://github.com/cortexkit/magic-context",
|
|
23
|
+
"directory": "packages/plugin"
|
|
24
|
+
},
|
|
25
|
+
"files": [
|
|
26
|
+
"dist",
|
|
27
|
+
"src/tui",
|
|
28
|
+
"src/shared",
|
|
29
|
+
"README.md"
|
|
30
|
+
],
|
|
31
|
+
"scripts": {
|
|
32
|
+
"build": "bun build src/index.ts --outdir dist --target node --format esm --external @opencode-ai/plugin --external bun:sqlite --external node:sqlite && tsc --emitDeclarationOnly",
|
|
33
|
+
"typecheck": "tsc --noEmit && tsc -p tsconfig.scripts.json",
|
|
34
|
+
"test": "bun test",
|
|
35
|
+
"lint": "biome check .",
|
|
36
|
+
"lint:fix": "biome check --write .",
|
|
37
|
+
"format": "biome format --write .",
|
|
38
|
+
"format:check": "biome format .",
|
|
39
|
+
"clean": "rm -rf dist",
|
|
40
|
+
"prepublishOnly": "bun run build"
|
|
41
|
+
},
|
|
42
|
+
"dependencies": {
|
|
43
|
+
"@huggingface/transformers": "^4.1.0",
|
|
44
|
+
"@jitl/quickjs-singlefile-cjs-release-asyncify": "0.32.0",
|
|
45
|
+
"@opencode-ai/plugin": "^1.17.11",
|
|
46
|
+
"@opencode-ai/sdk": "^1.17.11",
|
|
47
|
+
"@opentui/core": "^0.4.2",
|
|
48
|
+
"@opentui/solid": "^0.4.2",
|
|
49
|
+
"ai-tokenizer": "^1.0.6",
|
|
50
|
+
"comment-json": "^5.0.0",
|
|
51
|
+
"quickjs-emscripten": "^0.32.0",
|
|
52
|
+
"solid-js": "1.9.12",
|
|
53
|
+
"zod": "^4.1.8"
|
|
54
|
+
},
|
|
55
|
+
"devDependencies": {
|
|
56
|
+
"@biomejs/biome": "^2.5.1",
|
|
57
|
+
"@types/better-sqlite3": "^7.6.13",
|
|
58
|
+
"@types/bun": "^1.3.10",
|
|
59
|
+
"@types/node": "^22.20.0",
|
|
60
|
+
"bun-types": "^1.3.10",
|
|
61
|
+
"typescript": "^5.8.0"
|
|
62
|
+
},
|
|
63
|
+
"exports": {
|
|
64
|
+
".": {
|
|
65
|
+
"types": "./dist/index.d.ts",
|
|
66
|
+
"import": "./dist/index.js"
|
|
67
|
+
},
|
|
68
|
+
"./tui": {
|
|
69
|
+
"types": "./src/tui/index.tsx",
|
|
70
|
+
"import": "./src/tui/index.tsx"
|
|
71
|
+
}
|
|
72
|
+
},
|
|
73
|
+
"oc-plugin": [
|
|
74
|
+
"server",
|
|
75
|
+
"tui"
|
|
76
|
+
],
|
|
77
|
+
"peerDependencies": {
|
|
78
|
+
"@opencode-ai/plugin": ">=1.15.0"
|
|
79
|
+
}
|
|
79
80
|
}
|
|
@@ -37,15 +37,14 @@ import { getMagicContextStorageDir } from "./data-path";
|
|
|
37
37
|
* Bump only when there are user-visible changes worth a startup dialog.
|
|
38
38
|
* Does NOT need to match the published package version.
|
|
39
39
|
*/
|
|
40
|
-
export const ANNOUNCEMENT_VERSION = "0.
|
|
40
|
+
export const ANNOUNCEMENT_VERSION = "0.30.1";
|
|
41
41
|
|
|
42
42
|
/**
|
|
43
43
|
* Short, user-facing bullet strings. Keep each line ~80 chars or shorter so the
|
|
44
44
|
* TUI dialog renders cleanly without horizontal scroll on a typical terminal.
|
|
45
45
|
*/
|
|
46
46
|
export const ANNOUNCEMENT_FEATURES: ReadonlyArray<string> = [
|
|
47
|
-
|
|
48
|
-
"The ctx_reduce reminder now reflects how much tool output is actually reclaimable, instead of escalating to 'urgent' just because you're near compaction. It also no longer suggests dropping the agent's task list or tiny status outputs.",
|
|
47
|
+
"Local embeddings work on OpenCode Desktop again (#195): /ctx-embed no longer fails with 'Unsupported device: cpu' on the Desktop app.",
|
|
49
48
|
];
|
|
50
49
|
|
|
51
50
|
/**
|
|
@@ -0,0 +1,63 @@
|
|
|
1
|
+
/// <reference types="bun-types" />
|
|
2
|
+
|
|
3
|
+
import { describe, expect, it } from "bun:test";
|
|
4
|
+
import {
|
|
5
|
+
COMMIT_HASH_TEST_PATTERN,
|
|
6
|
+
COMMIT_VERB_PATTERN,
|
|
7
|
+
createCommitHashExtractPattern,
|
|
8
|
+
textMentionsRecentCommit,
|
|
9
|
+
} from "./commit-detection";
|
|
10
|
+
|
|
11
|
+
describe("textMentionsRecentCommit", () => {
|
|
12
|
+
it("fires on a hash + commit-action verb in the same text", () => {
|
|
13
|
+
expect(textMentionsRecentCommit("Committed abc1234 with the fix")).toBe(true);
|
|
14
|
+
expect(textMentionsRecentCommit("merged a1b2c3d into main")).toBe(true);
|
|
15
|
+
expect(textMentionsRecentCommit("rebased onto feedb4d cleanly")).toBe(true);
|
|
16
|
+
expect(textMentionsRecentCommit("cherry-picked deadbeef")).toBe(true);
|
|
17
|
+
});
|
|
18
|
+
|
|
19
|
+
it("does NOT fire on a hash alone, or the bare word 'hash'/'sha' + hex", () => {
|
|
20
|
+
expect(textMentionsRecentCommit("the value is abc1234")).toBe(false);
|
|
21
|
+
// 'hash'/'sha' are intentionally NOT commit-action verbs (parity contract).
|
|
22
|
+
expect(textMentionsRecentCommit("hash is abc1234567")).toBe(false);
|
|
23
|
+
expect(textMentionsRecentCommit("sha abc1234")).toBe(false);
|
|
24
|
+
});
|
|
25
|
+
|
|
26
|
+
it("does NOT fire on a verb alone (no hash)", () => {
|
|
27
|
+
expect(textMentionsRecentCommit("I will commit later")).toBe(false);
|
|
28
|
+
});
|
|
29
|
+
|
|
30
|
+
it("respects the 7-12 hex length bound", () => {
|
|
31
|
+
expect(textMentionsRecentCommit("committed abc12")).toBe(false); // too short
|
|
32
|
+
expect(textMentionsRecentCommit("committed abc1234567890abcdef")).toBe(false); // too long
|
|
33
|
+
});
|
|
34
|
+
|
|
35
|
+
it("does not match commit-ish words that are not commit actions", () => {
|
|
36
|
+
expect(COMMIT_VERB_PATTERN.test("commitment to abc1234")).toBe(false);
|
|
37
|
+
expect(COMMIT_VERB_PATTERN.test("a merger of abc1234")).toBe(false);
|
|
38
|
+
});
|
|
39
|
+
});
|
|
40
|
+
|
|
41
|
+
describe("shared regex instances are stateless across calls", () => {
|
|
42
|
+
it("COMMIT_HASH_TEST_PATTERN.test is repeatable (non-global)", () => {
|
|
43
|
+
expect(COMMIT_HASH_TEST_PATTERN.test("abc1234")).toBe(true);
|
|
44
|
+
expect(COMMIT_HASH_TEST_PATTERN.test("abc1234")).toBe(true); // no lastIndex drift
|
|
45
|
+
});
|
|
46
|
+
|
|
47
|
+
it("createCommitHashExtractPattern returns a fresh global regex each call", () => {
|
|
48
|
+
const a = createCommitHashExtractPattern();
|
|
49
|
+
const b = createCommitHashExtractPattern();
|
|
50
|
+
expect(a).not.toBe(b);
|
|
51
|
+
expect(a.global).toBe(true);
|
|
52
|
+
});
|
|
53
|
+
});
|
|
54
|
+
|
|
55
|
+
describe("createCommitHashExtractPattern (historian extraction)", () => {
|
|
56
|
+
it("captures backtick-wrapped and bare hashes, deduped via matchAll", () => {
|
|
57
|
+
const text = "Committed `abc1234` and def5678, also abc1234 again";
|
|
58
|
+
const found = [...text.matchAll(createCommitHashExtractPattern())].map((m) =>
|
|
59
|
+
m[1]?.toLowerCase(),
|
|
60
|
+
);
|
|
61
|
+
expect(found).toEqual(["abc1234", "def5678", "abc1234"]);
|
|
62
|
+
});
|
|
63
|
+
});
|
|
@@ -0,0 +1,53 @@
|
|
|
1
|
+
// Canonical commit-detection patterns — the SINGLE source of truth shared by:
|
|
2
|
+
// - the historian commit-cluster trigger + summary hash extraction
|
|
3
|
+
// (read-session-formatting.ts),
|
|
4
|
+
// - the OpenCode note-nudge `commit_detected` boundary (tag-messages.ts),
|
|
5
|
+
// - the Pi note-nudge detector (detect-recent-commit.ts).
|
|
6
|
+
//
|
|
7
|
+
// These three previously each carried their own hash/verb regexes that had
|
|
8
|
+
// drifted (hash length 6 vs 7; verb sets {hash, sha} vs {merge, rebas}). Keeping
|
|
9
|
+
// them here stops that drift: change the patterns once and every site follows.
|
|
10
|
+
//
|
|
11
|
+
// All three sites look for a short git hash AND a commit-related word in the
|
|
12
|
+
// SAME assistant text part — the pairing is what keeps false positives low.
|
|
13
|
+
|
|
14
|
+
/** A short git hash: 7-12 hex chars (git's default abbreviated hash is 7).
|
|
15
|
+
* 6 was too loose — more random-hex false positives. */
|
|
16
|
+
const HASH_HEX = "[0-9a-f]{7,12}";
|
|
17
|
+
|
|
18
|
+
/**
|
|
19
|
+
* Boolean hash test. Non-global (stateless), so this single instance is safe to
|
|
20
|
+
* reuse with `.test()` across call sites — only `/g` regexes carry `lastIndex`.
|
|
21
|
+
*/
|
|
22
|
+
export const COMMIT_HASH_TEST_PATTERN = new RegExp(`\\b${HASH_HEX}\\b`, "i");
|
|
23
|
+
|
|
24
|
+
/**
|
|
25
|
+
* Commit-ACTION verbs, with common inflections, each fully word-boundary-anchored
|
|
26
|
+
* (so they don't match e.g. "commitment"/"merger"). Non-global → safe to share.
|
|
27
|
+
*
|
|
28
|
+
* Scope decision: this is the commit-action set the OpenCode + Pi note-nudge
|
|
29
|
+
* detectors used and pin in tests ("commit/cherry-pick/merge/rebase"). It does
|
|
30
|
+
* NOT include the bare nouns "hash"/"sha" that the historian's old hint regex
|
|
31
|
+
* carried — a parity test asserts "hash <hex>" alone must NOT count as a commit,
|
|
32
|
+
* and those nouns only ever gated a cosmetic hash-strip in historian summaries
|
|
33
|
+
* (never a trigger), so unifying to the action set is behavior-preserving where
|
|
34
|
+
* it matters.
|
|
35
|
+
*/
|
|
36
|
+
export const COMMIT_VERB_PATTERN =
|
|
37
|
+
/\b(?:commit(?:ted|ting|s)?|cherry-?pick(?:ed|ing|s)?|merge[ds]?|merging|rebas(?:e|ed|es|ing))\b/i;
|
|
38
|
+
|
|
39
|
+
/** True when a text part mentions a commit hash in a commit context. Used by the
|
|
40
|
+
* OpenCode + Pi note-nudge detectors. */
|
|
41
|
+
export function textMentionsRecentCommit(text: string): boolean {
|
|
42
|
+
return COMMIT_HASH_TEST_PATTERN.test(text) && COMMIT_VERB_PATTERN.test(text);
|
|
43
|
+
}
|
|
44
|
+
|
|
45
|
+
/**
|
|
46
|
+
* Fresh `/g` capturing, backtick-aware hash pattern for the historian's
|
|
47
|
+
* extract-and-strip path (matchAll + replace). Returned as a NEW instance per
|
|
48
|
+
* call: a `/g` regex carries `lastIndex`, so handing out a fresh one is
|
|
49
|
+
* bulletproof against accidental `.exec()` reuse across callers.
|
|
50
|
+
*/
|
|
51
|
+
export function createCommitHashExtractPattern(): RegExp {
|
|
52
|
+
return new RegExp(`\`?\\b(${HASH_HEX})\\b\`?`, "gi");
|
|
53
|
+
}
|
|
@@ -0,0 +1,50 @@
|
|
|
1
|
+
import { describe, expect, it } from "bun:test";
|
|
2
|
+
import { registerExitAbort, unregisterExitAbort } from "./exit-abort-registry";
|
|
3
|
+
|
|
4
|
+
// Captured before any registration so we can isolate the ONE listener the
|
|
5
|
+
// registry installs process-wide (it intentionally never removes it, mirroring
|
|
6
|
+
// production, so the suite must not strip it either).
|
|
7
|
+
const baseline = process.listenerCount("exit");
|
|
8
|
+
|
|
9
|
+
/** The registry's single 'exit' listener (the first one added past baseline). */
|
|
10
|
+
function registryListener(): () => void {
|
|
11
|
+
return process.listeners("exit").slice(baseline)[0] as () => void;
|
|
12
|
+
}
|
|
13
|
+
|
|
14
|
+
describe("exit-abort-registry", () => {
|
|
15
|
+
it("adds exactly ONE process exit listener no matter how many controllers register", () => {
|
|
16
|
+
registerExitAbort(new AbortController());
|
|
17
|
+
registerExitAbort(new AbortController());
|
|
18
|
+
registerExitAbort(new AbortController());
|
|
19
|
+
expect(process.listenerCount("exit") - baseline).toBe(1);
|
|
20
|
+
});
|
|
21
|
+
|
|
22
|
+
it("aborts every registered controller when the exit listener fires", () => {
|
|
23
|
+
const a = new AbortController();
|
|
24
|
+
const b = new AbortController();
|
|
25
|
+
registerExitAbort(a);
|
|
26
|
+
registerExitAbort(b);
|
|
27
|
+
|
|
28
|
+
// Invoke the registry's listener directly (emitting 'exit' would end the
|
|
29
|
+
// test process).
|
|
30
|
+
registryListener()();
|
|
31
|
+
|
|
32
|
+
expect(a.signal.aborted).toBe(true);
|
|
33
|
+
expect(b.signal.aborted).toBe(true);
|
|
34
|
+
// Still exactly one listener after firing.
|
|
35
|
+
expect(process.listenerCount("exit") - baseline).toBe(1);
|
|
36
|
+
});
|
|
37
|
+
|
|
38
|
+
it("does not abort a controller that was unregistered before exit", () => {
|
|
39
|
+
const keep = new AbortController();
|
|
40
|
+
const drop = new AbortController();
|
|
41
|
+
registerExitAbort(keep);
|
|
42
|
+
registerExitAbort(drop);
|
|
43
|
+
unregisterExitAbort(drop);
|
|
44
|
+
|
|
45
|
+
registryListener()();
|
|
46
|
+
|
|
47
|
+
expect(keep.signal.aborted).toBe(true);
|
|
48
|
+
expect(drop.signal.aborted).toBe(false);
|
|
49
|
+
});
|
|
50
|
+
});
|