@magpie-community/opencode-factory-auth 0.1.8 → 0.1.9

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.
Files changed (3) hide show
  1. package/README.md +5 -0
  2. package/index.mjs +14 -8
  3. package/package.json +1 -1
package/README.md CHANGED
@@ -90,6 +90,11 @@ Claude 5 can send runtime metadata in string-content `system` messages
90
90
  instead of user-message reminders. The plugin adapts the known environment,
91
91
  model and configuration-skill metadata in that shape too, preserving the
92
92
  message role, environment values and session instructions.
93
+ After `/model` switches, Claude Code can send model-only system updates
94
+ without the initial environment paragraph. Updates beginning with the known
95
+ model paragraph and containing complete generated token metadata are
96
+ adapted too, including accumulated switches when resuming a conversation.
97
+ Token budgets, permission instructions and conversation history are preserved.
93
98
 
94
99
  Use magpie's Claude Code integration to select the Factory provider.
95
100
  magpie manages the provider-specific client settings, including capability
package/index.mjs CHANGED
@@ -591,18 +591,24 @@ const CONFIG_SKILL_COMPAT = CONFIG_SKILL_METADATA.replace("not Claude", "not the
591
591
 
592
592
  // Claude 5 also sends its runtime metadata as a string-content system
593
593
  // message, instead of user-message reminders. Preserve that role and all
594
- // instructions; only the known environment paragraph opens this adapter.
594
+ // instructions. A model switch sends a separate update without the
595
+ // environment paragraph; require its opening model paragraph and complete
596
+ // generated token context before adapting that shape.
595
597
  const SYSTEM_ENV_CONTEXT = /^# Environment\nYou have been invoked in the following environment:[ \t]*\n(?: {1,2}- [^\n]*\n)+(?=\n|$)/
596
598
  const SYSTEM_MODEL_CONTEXT = /(^|\n\n)You are powered by the model (?:named )?[^\n<>]+\.(?=\n\n|$)/g
599
+ const SYSTEM_MODEL_UPDATE = /^You are powered by the model (?:named )?[^\n<>]+\.(?=\n\n|$)/
600
+ const SYSTEM_TOKEN_CONTEXT = /(?:^|\n\n)<total_tokens>\d+ tokens left<\/total_tokens>(?=\n\n|$)/
597
601
  function systemContext(text) {
598
- if (!SYSTEM_ENV_CONTEXT.test(text)) return text
599
- let out = text.replace("# Environment", "# Runtime context")
602
+ const environment = SYSTEM_ENV_CONTEXT.test(text)
603
+ if (!environment && !(SYSTEM_MODEL_UPDATE.test(text) && SYSTEM_TOKEN_CONTEXT.test(text))) return text
604
+ let out = text.replace(SYSTEM_MODEL_CONTEXT, (paragraph) => paragraph
605
+ .replace("You are powered by the model named", "Current model name:")
606
+ .replace("You are powered by the model", "Current model:")
607
+ .replace("The exact model ID is", "Model ID:")
608
+ .replace("Assistant knowledge cutoff is", "Model knowledge cutoff:"))
609
+ if (!environment) return out
610
+ out = out.replace("# Environment", "# Runtime context")
600
611
  .replace("You have been invoked in the following environment:", "The session environment is:")
601
- .replace(SYSTEM_MODEL_CONTEXT, (paragraph) => paragraph
602
- .replace("You are powered by the model named", "Current model name:")
603
- .replace("You are powered by the model", "Current model:")
604
- .replace("The exact model ID is", "Model ID:")
605
- .replace("Assistant knowledge cutoff is", "Model knowledge cutoff:"))
606
612
  const skillHeader = "\n\nThe following skills are available for use with the Skill tool:\n\n"
607
613
  const skills = out.indexOf(skillHeader)
608
614
  if (skills >= 0) {
package/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "@magpie-community/opencode-factory-auth",
3
- "version": "0.1.8",
3
+ "version": "0.1.9",
4
4
  "description": "Sign in to a Factory (Droid) subscription from OpenCode or magpie",
5
5
  "type": "module",
6
6
  "main": "./index.mjs",