Compare commits

...

6 Commits

Author SHA1 Message Date
di-sukharev
a4716b35a4 1.1.28 2023-03-29 11:26:59 +08:00
di-sukharev
c1e9062ce0 1.1.27 2023-03-29 11:26:51 +08:00
di-sukharev
c7efa6f935 refactor: remove @dqbd/tiktoken dependency
chore(tsconfig.json): change target to ESNext
The @dqbd/tiktoken dependency was removed from the package.json file. This dependency was not being used in the project and was therefore removed to reduce the size of the project. The target in the tsconfig.json file was changed from ES2020 to ESNext to allow for the use of the latest ECMAScript features.
2023-03-29 11:26:19 +08:00
di-sukharev
1b70de1d20 fix(githook.ts): capitalize OpenCommit in console output
chore(githook.ts): remove unused import
refactor(tokenCount.ts): simplify token count calculation
The console output now correctly capitalizes OpenCommit for consistency with the project name. The unused import of fileURLToPath is removed. The tokenCount function is refactored to simplify the calculation of the token count. The Tiktoken library is no longer used, and the token count is now calculated based on the length of the content divided by an average token length of 2.7 characters.
2023-03-29 11:26:05 +08:00
di-sukharev
853662acc4 refactor(tokenCount.ts): format code with consistent indentation and quotes
The code has been reformatted to use consistent indentation and quotes. This improves the readability and maintainability of the code. No functionality has been changed.
2023-03-29 11:25:48 +08:00
di-sukharev
0e1ad33179 1.1.26 2023-03-29 10:45:35 +08:00
5 changed files with 17 additions and 17 deletions

4
package-lock.json generated
View File

@@ -1,12 +1,12 @@
{
"name": "opencommit",
"version": "1.1.25",
"version": "1.1.28",
"lockfileVersion": 3,
"requires": true,
"packages": {
"": {
"name": "opencommit",
"version": "1.1.25",
"version": "1.1.28",
"license": "MIT",
"dependencies": {
"@clack/prompts": "^0.6.1",

View File

@@ -1,6 +1,6 @@
{
"name": "opencommit",
"version": "1.1.25",
"version": "1.1.28",
"description": "GPT CLI to auto-generate impressive commits in 1 second. Killing lame commits with AI 🤯🔫",
"keywords": [
"git",
@@ -60,7 +60,6 @@
},
"dependencies": {
"@clack/prompts": "^0.6.1",
"@dqbd/tiktoken": "^1.0.2",
"axios": "^1.3.4",
"chalk": "^5.2.0",
"cleye": "^1.3.2",

5
src/commands/githook.ts Normal file → Executable file
View File

@@ -6,6 +6,7 @@ import { existsSync } from 'fs';
import chalk from 'chalk';
import { intro, outro } from '@clack/prompts';
import { COMMANDS } from '../CommandsEnum.js';
import { fileURLToPath } from 'url';
const HOOK_NAME = 'prepare-commit-msg';
const SYMLINK_URL = `.git/hooks/${HOOK_NAME}`;
@@ -28,7 +29,7 @@ export const hookCommand = command(
const { setUnset: mode } = argv._;
if (mode === 'set') {
intro(`setting opencommit as '${HOOK_NAME}' hook`);
intro(`setting OpenCommit as '${HOOK_NAME}' hook`);
if (isHookExists) {
let realPath;
@@ -40,7 +41,7 @@ export const hookCommand = command(
}
if (realPath === HOOK_URL)
return outro(`opencommit is already set as '${HOOK_NAME}'`);
return outro(`OpenCommit is already set as '${HOOK_NAME}'`);
throw new Error(
`Different ${HOOK_NAME} is already set. Remove it before setting opencommit as '${HOOK_NAME}' hook.`

View File

@@ -1,14 +1,14 @@
import { Tiktoken } from "@dqbd/tiktoken/lite"
import cl100k_base from "@dqbd/tiktoken/encoders/cl100k_base.json" assert{type: "json"}
// import { Tiktoken } from '@dqbd/tiktoken/lite';
// import cl100k_base from '@dqbd/tiktoken/encoders/cl100k_base.json' assert { type: 'json' };
export function tokenCount(content: string): number {
const encoding = new Tiktoken(
cl100k_base.bpe_ranks,
cl100k_base.special_tokens,
cl100k_base.pat_str
);
const tokens = encoding.encode(content);
encoding.free();
// const encoding = new Tiktoken(
// cl100k_base.bpe_ranks,
// cl100k_base.special_tokens,
// cl100k_base.pat_str
// );
// const tokens = encoding.encode(content);
// encoding.free();
return tokens.length;
return content.length / 2.7;
}

View File

@@ -1,6 +1,6 @@
{
"compilerOptions": {
"target": "ES2020",
"target": "ESNext",
"lib": ["ES5", "ES6"],
"module": "ESNext",