first commit
This commit is contained in:
@@ -0,0 +1,5 @@
|
|||||||
|
out
|
||||||
|
dist
|
||||||
|
node_modules
|
||||||
|
.vscode-test/
|
||||||
|
*.vsix
|
||||||
@@ -0,0 +1,5 @@
|
|||||||
|
import { defineConfig } from '@vscode/test-cli';
|
||||||
|
|
||||||
|
export default defineConfig({
|
||||||
|
files: 'out/test/**/*.test.js',
|
||||||
|
});
|
||||||
Vendored
+8
@@ -0,0 +1,8 @@
|
|||||||
|
{
|
||||||
|
// See http://go.microsoft.com/fwlink/?LinkId=827846
|
||||||
|
// for the documentation about the extensions.json format
|
||||||
|
"recommendations": [
|
||||||
|
"dbaeumer.vscode-eslint",
|
||||||
|
"ms-vscode.extension-test-runner"
|
||||||
|
]
|
||||||
|
}
|
||||||
Vendored
+21
@@ -0,0 +1,21 @@
|
|||||||
|
// A launch configuration that compiles the extension and then opens it inside a new window
|
||||||
|
// Use IntelliSense to learn about possible attributes.
|
||||||
|
// Hover to view descriptions of existing attributes.
|
||||||
|
// For more information, visit: https://go.microsoft.com/fwlink/?linkid=830387
|
||||||
|
{
|
||||||
|
"version": "0.2.0",
|
||||||
|
"configurations": [
|
||||||
|
{
|
||||||
|
"name": "Run Extension",
|
||||||
|
"type": "extensionHost",
|
||||||
|
"request": "launch",
|
||||||
|
"args": [
|
||||||
|
"--extensionDevelopmentPath=${workspaceFolder}"
|
||||||
|
],
|
||||||
|
"outFiles": [
|
||||||
|
"${workspaceFolder}/out/**/*.js"
|
||||||
|
],
|
||||||
|
"preLaunchTask": "${defaultBuildTask}"
|
||||||
|
}
|
||||||
|
]
|
||||||
|
}
|
||||||
Vendored
+11
@@ -0,0 +1,11 @@
|
|||||||
|
// Place your settings in this file to overwrite default and user settings.
|
||||||
|
{
|
||||||
|
"files.exclude": {
|
||||||
|
"out": false // set this to true to hide the "out" folder with the compiled JS files
|
||||||
|
},
|
||||||
|
"search.exclude": {
|
||||||
|
"out": true // set this to false to include "out" folder in search results
|
||||||
|
},
|
||||||
|
// Turn off tsc task auto detection since we have the necessary tasks as npm scripts
|
||||||
|
"js/ts.tsc.autoDetect": "off"
|
||||||
|
}
|
||||||
Vendored
+20
@@ -0,0 +1,20 @@
|
|||||||
|
// See https://go.microsoft.com/fwlink/?LinkId=733558
|
||||||
|
// for the documentation about the tasks.json format
|
||||||
|
{
|
||||||
|
"version": "2.0.0",
|
||||||
|
"tasks": [
|
||||||
|
{
|
||||||
|
"type": "npm",
|
||||||
|
"script": "watch",
|
||||||
|
"problemMatcher": "$tsc-watch",
|
||||||
|
"isBackground": true,
|
||||||
|
"presentation": {
|
||||||
|
"reveal": "never"
|
||||||
|
},
|
||||||
|
"group": {
|
||||||
|
"kind": "build",
|
||||||
|
"isDefault": true
|
||||||
|
}
|
||||||
|
}
|
||||||
|
]
|
||||||
|
}
|
||||||
@@ -0,0 +1,11 @@
|
|||||||
|
.vscode/**
|
||||||
|
.vscode-test/**
|
||||||
|
src/**
|
||||||
|
.gitignore
|
||||||
|
.yarnrc
|
||||||
|
vsc-extension-quickstart.md
|
||||||
|
**/tsconfig.json
|
||||||
|
**/eslint.config.mjs
|
||||||
|
**/*.map
|
||||||
|
**/*.ts
|
||||||
|
**/.vscode-test.*
|
||||||
@@ -0,0 +1,9 @@
|
|||||||
|
# Change Log
|
||||||
|
|
||||||
|
All notable changes to the "deepseek-balance" extension will be documented in this file.
|
||||||
|
|
||||||
|
Check [Keep a Changelog](http://keepachangelog.com/) for recommendations on how to structure this file.
|
||||||
|
|
||||||
|
## [Unreleased]
|
||||||
|
|
||||||
|
- Initial release
|
||||||
@@ -0,0 +1,26 @@
|
|||||||
|
# DeepSeek Balance
|
||||||
|
|
||||||
|
A lightweight VS Code extension that displays your current DeepSeek API balance directly in the status bar, along with real-time peak and off-peak status indicators.
|
||||||
|
|
||||||
|
## Features
|
||||||
|
|
||||||
|
- **Live API Balance:** View your current DeepSeek account balance at a glance.
|
||||||
|
- **Peak / Off-Peak Indicator:** Real-time rate detection based on DeepSeek server schedules:
|
||||||
|
- **OFF-PEAK:** Green status text during discount hours.
|
||||||
|
- **PEAK:** Red status badge during standard pricing windows.
|
||||||
|
- **Quick Dashboard Access:** Click the status bar item to open the DeepSeek Platform in your default browser and refresh your balance.
|
||||||
|
- **Auto Refresh:** Periodically updates every 5 minutes automatically.
|
||||||
|
|
||||||
|
## Requirements & Configuration
|
||||||
|
|
||||||
|
To start fetching your balance, add your DeepSeek API key to your VS Code settings:
|
||||||
|
|
||||||
|
1. Open VS Code Settings (`Ctrl+,` or `Cmd+,`).
|
||||||
|
2. Search for `DeepSeek Balance`.
|
||||||
|
3. Enter your API key under `DeepSeek Balance: Api Key`.
|
||||||
|
|
||||||
|
Alternatively, add it directly to your `settings.json`:
|
||||||
|
|
||||||
|
```json
|
||||||
|
"deepseekBalance.apiKey": "sk-your-actual-api-key-here"
|
||||||
|
```
|
||||||
@@ -0,0 +1,27 @@
|
|||||||
|
import typescriptEslint from "typescript-eslint";
|
||||||
|
|
||||||
|
export default [{
|
||||||
|
files: ["**/*.ts"],
|
||||||
|
}, {
|
||||||
|
plugins: {
|
||||||
|
"@typescript-eslint": typescriptEslint.plugin,
|
||||||
|
},
|
||||||
|
|
||||||
|
languageOptions: {
|
||||||
|
parser: typescriptEslint.parser,
|
||||||
|
ecmaVersion: 2022,
|
||||||
|
sourceType: "module",
|
||||||
|
},
|
||||||
|
|
||||||
|
rules: {
|
||||||
|
"@typescript-eslint/naming-convention": ["warn", {
|
||||||
|
selector: "import",
|
||||||
|
format: ["camelCase", "PascalCase"],
|
||||||
|
}],
|
||||||
|
|
||||||
|
curly: "warn",
|
||||||
|
eqeqeq: "warn",
|
||||||
|
"no-throw-literal": "warn",
|
||||||
|
semi: "warn",
|
||||||
|
},
|
||||||
|
}];
|
||||||
Generated
+3191
File diff suppressed because it is too large
Load Diff
@@ -0,0 +1,57 @@
|
|||||||
|
{
|
||||||
|
"name": "deepseek-balance",
|
||||||
|
"displayName": "DeepSeek Balance",
|
||||||
|
"publisher": "ryankegel",
|
||||||
|
"description": "See your current balance and also whether you are currently on peak or non-peak hours",
|
||||||
|
"version": "0.0.2",
|
||||||
|
"engines": {
|
||||||
|
"vscode": "^1.130.0"
|
||||||
|
},
|
||||||
|
"categories": [
|
||||||
|
"Other"
|
||||||
|
],
|
||||||
|
"activationEvents": [
|
||||||
|
"onStartupFinished"
|
||||||
|
],
|
||||||
|
"main": "./out/extension.js",
|
||||||
|
"contributes": {
|
||||||
|
"commands": [
|
||||||
|
{
|
||||||
|
"command": "deepseek-balance.helloWorld",
|
||||||
|
"title": "Hello World"
|
||||||
|
}
|
||||||
|
],
|
||||||
|
"configuration": {
|
||||||
|
"title": "DeepSeek Balance",
|
||||||
|
"properties": {
|
||||||
|
"deepseekBalance.apiKey": {
|
||||||
|
"type": "string",
|
||||||
|
"default": "",
|
||||||
|
"description": "Your DeepSeek API Key"
|
||||||
|
}
|
||||||
|
}
|
||||||
|
}
|
||||||
|
},
|
||||||
|
"scripts": {
|
||||||
|
"vscode:prepublish": "npm run compile",
|
||||||
|
"compile": "tsc -p ./",
|
||||||
|
"watch": "tsc -watch -p ./",
|
||||||
|
"pretest": "npm run compile && npm run lint",
|
||||||
|
"lint": "eslint src",
|
||||||
|
"test": "vscode-test"
|
||||||
|
},
|
||||||
|
"devDependencies": {
|
||||||
|
"@types/vscode": "^1.130.0",
|
||||||
|
"@types/mocha": "^10.0.10",
|
||||||
|
"@types/node": "24.x",
|
||||||
|
"typescript-eslint": "^8.61.1",
|
||||||
|
"eslint": "^10.5.0",
|
||||||
|
"typescript": "^6.0.3",
|
||||||
|
"@vscode/test-cli": "^0.0.15",
|
||||||
|
"@vscode/test-electron": "^3.0.0"
|
||||||
|
},
|
||||||
|
"overrides": {
|
||||||
|
"diff": "^8.0.4",
|
||||||
|
"serialize-javascript": "^7.0.6"
|
||||||
|
}
|
||||||
|
}
|
||||||
@@ -0,0 +1,88 @@
|
|||||||
|
import * as vscode from 'vscode';
|
||||||
|
|
||||||
|
let statusBarItem: vscode.StatusBarItem;
|
||||||
|
|
||||||
|
export function activate(context: vscode.ExtensionContext) {
|
||||||
|
statusBarItem = vscode.window.createStatusBarItem(vscode.StatusBarAlignment.Right, 100);
|
||||||
|
statusBarItem.command = 'deepseekBalance.openDashboard';
|
||||||
|
context.subscriptions.push(statusBarItem);
|
||||||
|
|
||||||
|
// Command to open the DeepSeek platform in the browser and trigger a balance refresh
|
||||||
|
const openDashboardCommand = vscode.commands.registerCommand('deepseekBalance.openDashboard', () => {
|
||||||
|
vscode.env.openExternal(vscode.Uri.parse('https://platform.deepseek.com'));
|
||||||
|
fetchBalance();
|
||||||
|
});
|
||||||
|
context.subscriptions.push(openDashboardCommand);
|
||||||
|
|
||||||
|
// Command palette fallback to manually refresh without opening browser
|
||||||
|
const refreshCommand = vscode.commands.registerCommand('deepseekBalance.refresh', fetchBalance);
|
||||||
|
context.subscriptions.push(refreshCommand);
|
||||||
|
|
||||||
|
fetchBalance();
|
||||||
|
|
||||||
|
// Refresh every 5 minutes
|
||||||
|
const interval = setInterval(fetchBalance, 5 * 60 * 1000);
|
||||||
|
context.subscriptions.push({ dispose: () => clearInterval(interval) });
|
||||||
|
}
|
||||||
|
|
||||||
|
/**
|
||||||
|
* Checks if current UTC time falls within DeepSeek peak windows:
|
||||||
|
* Monday - Friday: 01:00–04:00 UTC and 06:00–10:00 UTC
|
||||||
|
*/
|
||||||
|
function isPeakHour(now = new Date()): boolean {
|
||||||
|
const day = now.getUTCDay(); // 0 = Sun, 6 = Sat
|
||||||
|
if (day === 0 || day === 6) return false;
|
||||||
|
|
||||||
|
const hour = now.getUTCHours();
|
||||||
|
return (hour >= 1 && hour < 4) || (hour >= 6 && hour < 10);
|
||||||
|
}
|
||||||
|
|
||||||
|
async function fetchBalance() {
|
||||||
|
const config = vscode.workspace.getConfiguration('deepseekBalance');
|
||||||
|
const apiKey = config.get<string>('apiKey');
|
||||||
|
const isPeak = isPeakHour();
|
||||||
|
|
||||||
|
if (!apiKey) {
|
||||||
|
statusBarItem.text = `$(wallet) DeepSeek: Set API Key`;
|
||||||
|
statusBarItem.tooltip = 'Click to open DeepSeek Platform';
|
||||||
|
statusBarItem.backgroundColor = undefined;
|
||||||
|
statusBarItem.color = undefined;
|
||||||
|
statusBarItem.show();
|
||||||
|
return;
|
||||||
|
}
|
||||||
|
|
||||||
|
try {
|
||||||
|
statusBarItem.text = `$(sync~spin) DeepSeek: Loading...`;
|
||||||
|
|
||||||
|
const response = await fetch('https://api.deepseek.com/user/balance', {
|
||||||
|
headers: { 'Authorization': `Bearer ${apiKey}` }
|
||||||
|
});
|
||||||
|
|
||||||
|
if (!response.ok) throw new Error(`HTTP ${response.status}`);
|
||||||
|
|
||||||
|
const data: any = await response.json();
|
||||||
|
const balanceInfo = data.balance_infos?.[0];
|
||||||
|
const balance = balanceInfo ? `${balanceInfo.total_balance} ${balanceInfo.currency}` : 'N/A';
|
||||||
|
|
||||||
|
if (isPeak) {
|
||||||
|
statusBarItem.text = `$(wallet) DeepSeek: ${balance} | PEAK`;
|
||||||
|
statusBarItem.backgroundColor = new vscode.ThemeColor('statusBarItem.errorBackground');
|
||||||
|
statusBarItem.color = undefined;
|
||||||
|
} else {
|
||||||
|
// Uses standard theme text color with a clear icon
|
||||||
|
statusBarItem.text = `$(wallet) DeepSeek: ${balance} | $(zap) OFF-PEAK`;
|
||||||
|
statusBarItem.backgroundColor = undefined;
|
||||||
|
statusBarItem.color = new vscode.ThemeColor('testing.iconPassed');
|
||||||
|
}
|
||||||
|
|
||||||
|
statusBarItem.show();
|
||||||
|
} catch (error) {
|
||||||
|
statusBarItem.text = `$(error) DeepSeek: Error`;
|
||||||
|
statusBarItem.tooltip = `Failed to fetch balance: ${error}\nClick to open DeepSeek Platform`;
|
||||||
|
statusBarItem.backgroundColor = new vscode.ThemeColor('statusBarItem.errorBackground');
|
||||||
|
statusBarItem.color = undefined;
|
||||||
|
statusBarItem.show();
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
|
export function deactivate() {}
|
||||||
@@ -0,0 +1,15 @@
|
|||||||
|
import * as assert from 'assert';
|
||||||
|
|
||||||
|
// You can import and use all API from the 'vscode' module
|
||||||
|
// as well as import your extension to test it
|
||||||
|
import * as vscode from 'vscode';
|
||||||
|
// import * as myExtension from '../../extension';
|
||||||
|
|
||||||
|
suite('Extension Test Suite', () => {
|
||||||
|
vscode.window.showInformationMessage('Start all tests.');
|
||||||
|
|
||||||
|
test('Sample test', () => {
|
||||||
|
assert.strictEqual(-1, [1, 2, 3].indexOf(5));
|
||||||
|
assert.strictEqual(-1, [1, 2, 3].indexOf(0));
|
||||||
|
});
|
||||||
|
});
|
||||||
@@ -0,0 +1,21 @@
|
|||||||
|
{
|
||||||
|
"compilerOptions": {
|
||||||
|
"module": "Node16",
|
||||||
|
"target": "ES2022",
|
||||||
|
"outDir": "out",
|
||||||
|
"lib": [
|
||||||
|
"ES2022"
|
||||||
|
],
|
||||||
|
"types": [
|
||||||
|
"node",
|
||||||
|
"mocha",
|
||||||
|
],
|
||||||
|
"sourceMap": true,
|
||||||
|
"rootDir": "src",
|
||||||
|
"strict": true, /* enable all strict type-checking options */
|
||||||
|
/* Additional Checks */
|
||||||
|
// "noImplicitReturns": true, /* Report error when not all code paths in function return a value. */
|
||||||
|
// "noFallthroughCasesInSwitch": true, /* Report errors for fallthrough cases in switch statement. */
|
||||||
|
// "noUnusedParameters": true, /* Report errors on unused parameters. */
|
||||||
|
}
|
||||||
|
}
|
||||||
@@ -0,0 +1,44 @@
|
|||||||
|
# Welcome to your VS Code Extension
|
||||||
|
|
||||||
|
## What's in the folder
|
||||||
|
|
||||||
|
* This folder contains all of the files necessary for your extension.
|
||||||
|
* `package.json` - this is the manifest file in which you declare your extension and command.
|
||||||
|
* The sample plugin registers a command and defines its title and command name. With this information VS Code can show the command in the command palette. It doesn’t yet need to load the plugin.
|
||||||
|
* `src/extension.ts` - this is the main file where you will provide the implementation of your command.
|
||||||
|
* The file exports one function, `activate`, which is called the very first time your extension is activated (in this case by executing the command). Inside the `activate` function we call `registerCommand`.
|
||||||
|
* We pass the function containing the implementation of the command as the second parameter to `registerCommand`.
|
||||||
|
|
||||||
|
## Get up and running straight away
|
||||||
|
|
||||||
|
* Press `F5` to open a new window with your extension loaded.
|
||||||
|
* Run your command from the command palette by pressing (`Ctrl+Shift+P` or `Cmd+Shift+P` on Mac) and typing `Hello World`.
|
||||||
|
* Set breakpoints in your code inside `src/extension.ts` to debug your extension.
|
||||||
|
* Find output from your extension in the debug console.
|
||||||
|
|
||||||
|
## Make changes
|
||||||
|
|
||||||
|
* You can relaunch the extension from the debug toolbar after changing code in `src/extension.ts`.
|
||||||
|
* You can also reload (`Ctrl+R` or `Cmd+R` on Mac) the VS Code window with your extension to load your changes.
|
||||||
|
|
||||||
|
## Explore the API
|
||||||
|
|
||||||
|
* You can open the full set of our API when you open the file `node_modules/@types/vscode/index.d.ts`.
|
||||||
|
|
||||||
|
## Run tests
|
||||||
|
|
||||||
|
* Install the [Extension Test Runner](https://marketplace.visualstudio.com/items?itemName=ms-vscode.extension-test-runner)
|
||||||
|
* Run the "watch" task via the **Tasks: Run Task** command. Make sure this is running, or tests might not be discovered.
|
||||||
|
* Open the Testing view from the activity bar and click the Run Test" button, or use the hotkey `Ctrl/Cmd + ; A`
|
||||||
|
* See the output of the test result in the Test Results view.
|
||||||
|
* Make changes to `src/test/extension.test.ts` or create new test files inside the `test` folder.
|
||||||
|
* The provided test runner will only consider files matching the name pattern `**.test.ts`.
|
||||||
|
* You can create folders inside the `test` folder to structure your tests any way you want.
|
||||||
|
|
||||||
|
## Go further
|
||||||
|
|
||||||
|
* [Follow UX guidelines](https://code.visualstudio.com/api/ux-guidelines/overview) to create extensions that seamlessly integrate with VS Code's native interface and patterns.
|
||||||
|
* Reduce the extension size and improve the startup time by [bundling your extension](https://code.visualstudio.com/api/working-with-extensions/bundling-extension).
|
||||||
|
* [Publish your extension](https://code.visualstudio.com/api/working-with-extensions/publishing-extension) on the VS Code extension marketplace.
|
||||||
|
* Automate builds by setting up [Continuous Integration](https://code.visualstudio.com/api/working-with-extensions/continuous-integration).
|
||||||
|
* Integrate to the [report issue](https://code.visualstudio.com/api/get-started/wrapping-up#issue-reporting) flow to get issue and feature requests reported by users.
|
||||||
Reference in New Issue
Block a user