@magpie-community/opencode-factory-auth 0.1.21 → 0.1.22
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/README.md +7 -0
- package/index.mjs +28 -2
- package/package.json +1 -1
package/README.md
CHANGED
|
@@ -143,6 +143,13 @@ When runtime notifications precede the skill update, the adapter recognizes
|
|
|
143
143
|
the complete skill-header and bullet-list paragraphs inside a token-terminated
|
|
144
144
|
bundle. It preserves MCP connection errors, other notifications, mode updates
|
|
145
145
|
and custom skill descriptions while adapting the known built-in description.
|
|
146
|
+
After `/compact`, Claude Code also sends the files it restores and the
|
|
147
|
+
runtime context as one turn that opens with an unwrapped restored-file note
|
|
148
|
+
or Read call, with no token marker first. When that turn also carries the
|
|
149
|
+
generated environment paragraph or a token marker before any hook output,
|
|
150
|
+
each fixed paragraph (file notes, Read calls and results, environment, model
|
|
151
|
+
line) is adapted as in a token-prefixed bundle; everything else stays
|
|
152
|
+
byte-for-byte. Quoted, incomplete and hook-owned forms are left alone.
|
|
146
153
|
|
|
147
154
|
Factory can also refuse fixed client phrases quoted in tool results, such as
|
|
148
155
|
the identity/environment definitions printed when inspecting this plugin's
|
package/index.mjs
CHANGED
|
@@ -685,6 +685,8 @@ const SYSTEM_SKILL_CONTEXT = /^The following skills are available for use with t
|
|
|
685
685
|
function systemContext(text) {
|
|
686
686
|
text = changedFileContext(text)
|
|
687
687
|
text = announcedSkills(text)
|
|
688
|
+
const restored = restoredContext(text)
|
|
689
|
+
if (restored !== null) return restored
|
|
688
690
|
if (SYSTEM_TOKEN_OPENING.test(text) || SYSTEM_SKILL_CONTEXT.test(text)) return announcedContext(text)
|
|
689
691
|
if (HOOK_OUTPUT.test(text) || text.startsWith(DEFERRED_TOOLS_OPENING)) {
|
|
690
692
|
const at = text.indexOf(HOOK_CONTEXT)
|
|
@@ -714,11 +716,11 @@ function announcedSkills(text) {
|
|
|
714
716
|
// Claude Code also announces several reminders as one system turn, with
|
|
715
717
|
// token context and no system-reminder wrappers. Only known metadata
|
|
716
718
|
// paragraphs change; numbered file contents and the hook's own output stay.
|
|
717
|
-
function announcedContext(text) {
|
|
719
|
+
function announcedContext(text, start = 1) {
|
|
718
720
|
const parts = changedFileContext(text).split(/\n\n(?!\.\.\. \[)/)
|
|
719
721
|
const open = "<system-reminder>\n", close = "\n</system-reminder>"
|
|
720
722
|
let quoteChangedFiles = true
|
|
721
|
-
for (let i =
|
|
723
|
+
for (let i = start; i < parts.length; i++) {
|
|
722
724
|
const part = parts[i]
|
|
723
725
|
const hook = part.replace(/^<system-reminder>\n/, "")
|
|
724
726
|
if (HOOK_OUTPUT.test(hook)) break
|
|
@@ -747,6 +749,28 @@ function announcedContext(text) {
|
|
|
747
749
|
return parts.join("\n\n")
|
|
748
750
|
}
|
|
749
751
|
|
|
752
|
+
// After /compact, Claude Code (2.1.280) sends the files it restores and the
|
|
753
|
+
// session's runtime context as one turn without reminder wrappers or an
|
|
754
|
+
// opening token marker: restored-file notes, Read calls and their results,
|
|
755
|
+
// the environment, the model line, token and date. Each fixed fragment is
|
|
756
|
+
// refused on its own (plugins#68). Require the generated restored-file
|
|
757
|
+
// opening and the generated environment paragraph or a token marker before
|
|
758
|
+
// the first hook; then each paragraph is adapted as in a token-prefixed
|
|
759
|
+
// bundle, the rest kept byte-for-byte. An adapted block no longer opens
|
|
760
|
+
// with the generated note, so a second pass leaves it as it is.
|
|
761
|
+
function restoredContext(text) {
|
|
762
|
+
const parts = text.split(/\n\n(?!\.\.\. \[)/)
|
|
763
|
+
const result = parts[0].indexOf("\n" + READ_RESULT_HEADER)
|
|
764
|
+
const opening = "<system-reminder>\n" + (result < 0 ? parts[0] : parts[0].slice(0, result)) + "\n</system-reminder>"
|
|
765
|
+
if (!COMPACT_FILE.test(opening) && !COMPACT_READ.test(opening)) return null
|
|
766
|
+
if (compactContext(opening) === opening) return null
|
|
767
|
+
for (const part of parts.slice(1)) {
|
|
768
|
+
if (HOOK_NOTIFICATION.test(part.replace(/^<system-reminder>\n/, ""))) return null
|
|
769
|
+
if (SYSTEM_ENV_CONTEXT.test(part + "\n") || /^<total_tokens>\d+ tokens left<\/total_tokens>$/.test(part)) return announcedContext(text, 0)
|
|
770
|
+
}
|
|
771
|
+
return null
|
|
772
|
+
}
|
|
773
|
+
|
|
750
774
|
function generatedContext(text) {
|
|
751
775
|
const environment = SYSTEM_ENV_CONTEXT.test(text)
|
|
752
776
|
if (!environment && !((SYSTEM_MODEL_UPDATE.test(text) || SYSTEM_ENV_UPDATE.test(text)) && SYSTEM_TOKEN_CONTEXT.test(text))) return text
|
|
@@ -801,6 +825,8 @@ function compactContext(text, quoteChangedFiles = true) {
|
|
|
801
825
|
// A translating gateway can fold an announced system turn into user text.
|
|
802
826
|
if (SYSTEM_TOKEN_OPENING.test(text) || SYSTEM_SKILL_CONTEXT.test(text)) return announcedContext(text)
|
|
803
827
|
if (HOOK_OUTPUT.test(text) || text.startsWith(DEFERRED_TOOLS_OPENING)) return systemContext(text)
|
|
828
|
+
const restored = restoredContext(text)
|
|
829
|
+
if (restored !== null) return restored
|
|
804
830
|
const result = readResultText(text)
|
|
805
831
|
if (result !== null) return result
|
|
806
832
|
const changedFile = quoteChangedFiles && text.startsWith("<system-reminder>\n") ? changedFileText(text) : null
|