[PR #6] [MERGED] Refactor: modularize extension into src/ with per-provider modules #7

Closed
opened 2026-10-15 13:27:57 +00:00 by bsakaguchi · 0 comments
Owner

📋 Pull Request Information

Original PR: https://github.com/SillyTavern/Extension-Weather/pull/6
Author: @Copilot
Created: 2/25/2026
Status: ✅ Merged
Merged: 2/25/2026
Merged by: @Cohee1207

Base: main ← Head: copilot/refactor-extension-code-structure


📝 Commits (2)

  • c2f9dab Initial plan
  • 7e0fba3 Refactor: split monolithic index.js into modular src/ structure

📊 Changes

10 files changed (+1452 additions, -1343 deletions)

View changed files

📝 index.js (+6 -1343)
➕ src/commands.js (+306 -0)
➕ src/functions.js (+132 -0)
➕ src/providers/accuweather.js (+417 -0)
➕ src/providers/index.js (+46 -0)
➕ src/providers/open-meteo.js (+155 -0)
➕ src/providers/openweathermap.js (+160 -0)
➕ src/providers/wttr-in.js (+97 -0)
➕ src/settings.js (+123 -0)
➕ src/utils.js (+10 -0)

📄 Description

Split the monolithic 1347-line index.js into separate modules under src/, with index.js retained as a thin entry point.

Structure

index.js                    # Entry point — loads settings, registers commands/tools
src/
├── settings.js             # WEATHER_PROVIDERS, defaultSettings, UI init
├── commands.js             # Slash commands (/weather, /forecast, /weather-provider, etc.)
├── functions.js            # Function tool registration (GetCurrentWeather, GetWeatherForecast)
├── utils.js                # Shared helpers (degreesToDirection)
└── providers/
    ├── index.js            # Provider routing via map-based dispatch
    ├── accuweather.js
    ├── openweathermap.js
    ├── open-meteo.js
    └── wttr-in.js

Standard provider interface

Each provider exports two functions with a uniform signature:

export async function getWeather(location, args);   // → formatted string
export async function getForecast(location, units);  // → formatted string

API key validation and provider-specific caching are encapsulated within each module. The routing layer (src/providers/index.js) resolves the active provider from settings and delegates via a simple map lookup with AccuWeather as the default fallback.

Notes

  • No behavioral changes — all logic preserved line-for-line
  • Settings key remains extension_settings.accuweather (existing user data compat)

💡 You can make Copilot smarter by setting up custom instructions, customizing its development environment and configuring Model Context Protocol (MCP) servers. Learn more Copilot coding agent tips in the docs.


🔄 This issue represents a GitHub Pull Request. It cannot be merged through Gitea due to API limitations.

## 📋 Pull Request Information **Original PR:** https://github.com/SillyTavern/Extension-Weather/pull/6 **Author:** [@Copilot](https://github.com/apps/copilot-swe-agent) **Created:** 2/25/2026 **Status:** ✅ Merged **Merged:** 2/25/2026 **Merged by:** [@Cohee1207](https://github.com/Cohee1207) **Base:** `main` ← **Head:** `copilot/refactor-extension-code-structure` --- ### 📝 Commits (2) - [`c2f9dab`](https://github.com/SillyTavern/Extension-Weather/commit/c2f9dabe77af4cf29c1235f721d5975123bab168) Initial plan - [`7e0fba3`](https://github.com/SillyTavern/Extension-Weather/commit/7e0fba3a29ac27d31744f1cf8476aa978d74f9b6) Refactor: split monolithic index.js into modular src/ structure ### 📊 Changes **10 files changed** (+1452 additions, -1343 deletions) <details> <summary>View changed files</summary> 📝 `index.js` (+6 -1343) ➕ `src/commands.js` (+306 -0) ➕ `src/functions.js` (+132 -0) ➕ `src/providers/accuweather.js` (+417 -0) ➕ `src/providers/index.js` (+46 -0) ➕ `src/providers/open-meteo.js` (+155 -0) ➕ `src/providers/openweathermap.js` (+160 -0) ➕ `src/providers/wttr-in.js` (+97 -0) ➕ `src/settings.js` (+123 -0) ➕ `src/utils.js` (+10 -0) </details> ### 📄 Description Split the monolithic 1347-line `index.js` into separate modules under `src/`, with `index.js` retained as a thin entry point. ### Structure ``` index.js # Entry point — loads settings, registers commands/tools src/ ├── settings.js # WEATHER_PROVIDERS, defaultSettings, UI init ├── commands.js # Slash commands (/weather, /forecast, /weather-provider, etc.) ├── functions.js # Function tool registration (GetCurrentWeather, GetWeatherForecast) ├── utils.js # Shared helpers (degreesToDirection) └── providers/ ├── index.js # Provider routing via map-based dispatch ├── accuweather.js ├── openweathermap.js ├── open-meteo.js └── wttr-in.js ``` ### Standard provider interface Each provider exports two functions with a uniform signature: ```js export async function getWeather(location, args); // → formatted string export async function getForecast(location, units); // → formatted string ``` API key validation and provider-specific caching are encapsulated within each module. The routing layer (`src/providers/index.js`) resolves the active provider from settings and delegates via a simple map lookup with AccuWeather as the default fallback. ### Notes - No behavioral changes — all logic preserved line-for-line - Settings key remains `extension_settings.accuweather` (existing user data compat) <!-- START COPILOT CODING AGENT TIPS --> --- 💡 You can make Copilot smarter by setting up custom instructions, customizing its development environment and configuring Model Context Protocol (MCP) servers. Learn more [Copilot coding agent tips](https://gh.io/copilot-coding-agent-tips) in the docs. --- <sub>🔄 This issue represents a GitHub Pull Request. It cannot be merged through Gitea due to API limitations.</sub>
bsakaguchi 2026-10-15 13:27:57 +00:00
Sign in to join this conversation.
No labels
pull-request
No milestone
No project
No assignees
1 participant
Notifications
Due date
The due date is invalid or out of range. Please use the format "yyyy-mm-dd".

No due date set.

Dependencies

No dependencies set.

Reference
SillyTavern/Extension-Weather#7
No description provided.