@magpie-community/opencode-factory-auth 0.1.32 → 0.1.33

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 +8 -3
  2. package/index.mjs +29 -11
  3. package/package.json +1 -1
package/README.md CHANGED
@@ -128,9 +128,14 @@ The fixed Claude identity is recognized as a complete first line too when
128
128
  magpie joins it with the following system instructions into one text block.
129
129
 
130
130
  For the built-in `update-config` skill, the adapter changes only the known
131
- self-reference "not Claude" to "not the assistant" inside a complete
132
- generated skill-list reminder. Its configuration instructions, other
133
- skill descriptions, tools and caller text are preserved.
131
+ self-reference "not Claude" to "not the assistant" inside that skill's entry
132
+ in a generated skill list. Claude Code renders the entry two ways: as a
133
+ system message (`- update-config: …`) and, in the `claude-code-guide` agent's
134
+ own system prompt under `# User's Current Configuration`, with the slash that
135
+ invokes it (`- /update-config: …`). Both spellings are adapted, and only the
136
+ sentence Factory refuses changes, so the entry's name and the rest of the list
137
+ stay. Its configuration instructions, other skill descriptions, tools and
138
+ caller text are preserved.
134
139
 
135
140
  Claude 5 can send runtime metadata in string-content `system` messages
136
141
  instead of user-message reminders. The plugin adapts the known environment,
package/index.mjs CHANGED
@@ -953,11 +953,29 @@ const CLAUDE_IDENTITIES = new Set([
953
953
  const ENV_REMINDER = /^<system-reminder>\n# Environment\nYou have been invoked in the following environment:[ \t]*\n(?: {1,2}- [^\n]*\n)+<\/system-reminder>$/
954
954
  const MODEL_REMINDER = /^<system-reminder>\nYou are powered by the model (?:named )?[^\n<>]+\.\n<\/system-reminder>$/
955
955
  const SKILL_REMINDER = /^<system-reminder>\nThe following skills are available for use with the Skill tool:\n\n(?:(?!<\/?system-reminder>)[\s\S])*\n<\/system-reminder>$/
956
- // Factory also refuses this fixed self-reference in Claude Code 2.1.287's
957
- // built-in update-config description. Keep its instructions and the rest
958
- // of the skill list intact; only the known line in a complete listing changes.
959
- const CONFIG_SKILL_METADATA = '- update-config: Use this skill to configure the Claude Code harness via settings.json. Automated behaviors ("from now on when X", "each time X", "whenever X", "before/after X") require hooks configured in settings.json - the harness executes these, not Claude, so memory/preferences cannot fulfill them.'
960
- const CONFIG_SKILL_COMPAT = CONFIG_SKILL_METADATA.replace("not Claude", "not the assistant")
956
+ // Factory also refuses this fixed self-reference in Claude Code's built-in
957
+ // update-config description. Keep its instructions and the rest of the skill
958
+ // list intact; only that entry changes.
959
+ //
960
+ // Claude Code renders the entry two ways: as a system message ("- update-
961
+ // config: …") and, in the claude-code-guide agent's own system prompt under
962
+ // "# User's Current Configuration", with the slash that invokes it
963
+ // ("- /update-config: …"). Match the entry by its name in either spelling and
964
+ // change only the refused sentence in it, so a rewording of the rest of the
965
+ // description cannot defeat the match. The sentence is the built-in
966
+ // description's own text, so no other entry carries it by accident.
967
+ const CONFIG_SKILL_ENTRY = /^- \/?update-config: /
968
+ const CONFIG_SKILL_REFUSED = "the harness executes these, not Claude, so memory/preferences cannot fulfill them."
969
+ const CONFIG_SKILL_SAFE = CONFIG_SKILL_REFUSED.replace("not Claude", "not the assistant")
970
+
971
+ // configSkillText repairs that entry wherever the text carries a skill list.
972
+ function configSkillText(text) {
973
+ if (!text.includes(CONFIG_SKILL_REFUSED)) return text
974
+ return text
975
+ .split("\n")
976
+ .map((line) => (CONFIG_SKILL_ENTRY.test(line) ? line.replace(CONFIG_SKILL_REFUSED, CONFIG_SKILL_SAFE) : line))
977
+ .join("\n")
978
+ }
961
979
 
962
980
  // Claude Code also sends the skill list alone as a system message: the
963
981
  // entries only, no header, no <system-reminder> wrapper and no token tail,
@@ -965,7 +983,7 @@ const CONFIG_SKILL_COMPAT = CONFIG_SKILL_METADATA.replace("not Claude", "not the
965
983
  // list (it opens with an entry) changes, and in it only the known line.
966
984
  function bareSkills(text) {
967
985
  if (!text.startsWith("- ")) return text
968
- return ("\n" + text).replace("\n" + CONFIG_SKILL_METADATA, "\n" + CONFIG_SKILL_COMPAT).slice(1)
986
+ return configSkillText(text)
969
987
  }
970
988
 
971
989
  // Claude 5 also sends its runtime metadata as a string-content system
@@ -1018,7 +1036,7 @@ function announcedSkills(text) {
1018
1036
  const list = parts[i + 1]
1019
1037
  // Skill descriptions can contain continuation lines.
1020
1038
  if (!list.startsWith("- ")) continue
1021
- parts[i + 1] = ("\n" + list).replace("\n" + CONFIG_SKILL_METADATA, "\n" + CONFIG_SKILL_COMPAT).slice(1)
1039
+ parts[i + 1] = configSkillText(list)
1022
1040
  }
1023
1041
  return parts.join("\n\n")
1024
1042
  }
@@ -1069,7 +1087,7 @@ function announcedContext(text, start = 1) {
1069
1087
  } else if (SYSTEM_MODEL_UPDATE.test(part)) {
1070
1088
  parts[i] = systemModelLine(part)
1071
1089
  } else if (parts[i - 1] === "The following skills are available for use with the Skill tool:") {
1072
- parts[i] = ("\n" + part).replace("\n" + CONFIG_SKILL_METADATA, "\n" + CONFIG_SKILL_COMPAT).slice(1)
1090
+ parts[i] = configSkillText(part)
1073
1091
  }
1074
1092
  }
1075
1093
  return parts.join("\n\n")
@@ -1123,7 +1141,7 @@ function generatedContext(text) {
1123
1141
  const skills = out.indexOf(skillHeader)
1124
1142
  if (skills >= 0) {
1125
1143
  const start = skills + skillHeader.length - 1
1126
- out = out.slice(0, start) + out.slice(start).replace("\n" + CONFIG_SKILL_METADATA, "\n" + CONFIG_SKILL_COMPAT)
1144
+ out = out.slice(0, start) + configSkillText(out.slice(start))
1127
1145
  }
1128
1146
  return out
1129
1147
  }
@@ -1302,7 +1320,7 @@ function claudeIdentity(text) {
1302
1320
 
1303
1321
  // promptText adapts a system prompt's text.
1304
1322
  function promptText(text) {
1305
- return clientOpening(systemModelLine(claudeIdentity(text)))
1323
+ return configSkillText(clientOpening(systemModelLine(claudeIdentity(text))))
1306
1324
  }
1307
1325
 
1308
1326
  // systemMessageText adapts a system message's text after the prompt.
@@ -1327,7 +1345,7 @@ function userBlockText(text) {
1327
1345
  .replace("The exact model ID is", "Model ID:")
1328
1346
  .replace("Assistant knowledge cutoff is", "Model knowledge cutoff:")
1329
1347
  }
1330
- if (SKILL_REMINDER.test(text)) return text.replace("\n" + CONFIG_SKILL_METADATA, "\n" + CONFIG_SKILL_COMPAT)
1348
+ if (SKILL_REMINDER.test(text)) return configSkillText(text)
1331
1349
  return text
1332
1350
  }
1333
1351
 
package/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "@magpie-community/opencode-factory-auth",
3
- "version": "0.1.32",
3
+ "version": "0.1.33",
4
4
  "description": "Sign in to a Factory (Droid) subscription from OpenCode or magpie",
5
5
  "type": "module",
6
6
  "main": "./index.mjs",