| 1125 | return None |
| 1126 | |
| 1127 | def get_platform_info(self): |
| 1128 | platform_text = "" |
| 1129 | try: |
| 1130 | platform_text = f"- Platform: {platform.platform()}\n" |
| 1131 | except KeyError: |
| 1132 | # Skip platform info if it can't be retrieved |
| 1133 | platform_text = "- Platform information unavailable\n" |
| 1134 | |
| 1135 | shell_var = "COMSPEC" if os.name == "nt" else "SHELL" |
| 1136 | shell_val = os.getenv(shell_var) |
| 1137 | platform_text += f"- Shell: {shell_var}={shell_val}\n" |
| 1138 | |
| 1139 | user_lang = self.get_user_language() |
| 1140 | if user_lang: |
| 1141 | platform_text += f"- Language: {user_lang}\n" |
| 1142 | |
| 1143 | dt = datetime.now().astimezone().strftime("%Y-%m-%d") |
| 1144 | platform_text += f"- Current date: {dt}\n" |
| 1145 | |
| 1146 | if self.repo: |
| 1147 | platform_text += "- The user is operating inside a git repository\n" |
| 1148 | |
| 1149 | if self.lint_cmds: |
| 1150 | if self.auto_lint: |
| 1151 | platform_text += ( |
| 1152 | "- The user's pre-commit runs these lint commands, don't suggest running" |
| 1153 | " them:\n" |
| 1154 | ) |
| 1155 | else: |
| 1156 | platform_text += "- The user prefers these lint commands:\n" |
| 1157 | for lang, cmd in self.lint_cmds.items(): |
| 1158 | if lang is None: |
| 1159 | platform_text += f" - {cmd}\n" |
| 1160 | else: |
| 1161 | platform_text += f" - {lang}: {cmd}\n" |
| 1162 | |
| 1163 | if self.test_cmd: |
| 1164 | if self.auto_test: |
| 1165 | platform_text += ( |
| 1166 | "- The user's pre-commit runs this test command, don't suggest running them: " |
| 1167 | ) |
| 1168 | else: |
| 1169 | platform_text += "- The user prefers this test command: " |
| 1170 | platform_text += self.test_cmd + "\n" |
| 1171 | |
| 1172 | return platform_text |
| 1173 | |
| 1174 | def fmt_system_prompt(self, prompt): |
| 1175 | final_reminders = [] |