cloving 0.1.0 → 0.1.1

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.
@@ -14,13 +14,14 @@ const ollama_1 = require("./adapters/ollama");
14
14
  const command_utils_1 = require("../utils/command_utils");
15
15
  class ClovingGPT {
16
16
  constructor(options = { silent: false }) {
17
- const config = (0, command_utils_1.getConfig)();
17
+ const config = (0, command_utils_1.getConfig)(options);
18
18
  if (!config || !config.primaryModel || !config.models) {
19
- throw new Error('No cloving configuration found. Please run `cloving config`');
19
+ console.log('No cloving configuration found. Please run: cloving config');
20
+ process_1.default.exit(1);
20
21
  }
21
22
  const clovingModel = config.primaryModel;
22
23
  this.apiKey = config.models[config?.primaryModel || ''].trim();
23
- this.silent = options.silent;
24
+ this.silent = options.silent || false;
24
25
  const parts = clovingModel.split(':');
25
26
  const model = parts.slice(1).join(':');
26
27
  switch (parts[0]) {
@@ -11,7 +11,7 @@ const string_utils_1 = require("../utils/string_utils");
11
11
  const command_utils_1 = require("../utils/command_utils");
12
12
  const cloving_gpt_1 = __importDefault(require("../cloving_gpt"));
13
13
  const generateAndCommitMessage = async (options) => {
14
- options.silent = (0, command_utils_1.getConfig)().silent || false;
14
+ options.silent = (0, command_utils_1.getConfig)(options).silent || false;
15
15
  const gpt = new cloving_gpt_1.default(options);
16
16
  try {
17
17
  // Generate the prompt for commit message
@@ -3,7 +3,7 @@ Object.defineProperty(exports, "__esModule", { value: true });
3
3
  exports.config = void 0;
4
4
  const command_utils_1 = require("../utils/command_utils");
5
5
  const config = async () => {
6
- let currentConfig = (0, command_utils_1.getConfig)();
6
+ let currentConfig = (0, command_utils_1.getConfig)({});
7
7
  // Ensure models is initialized properly
8
8
  if (!currentConfig.models) {
9
9
  currentConfig.models = {};
@@ -14,7 +14,7 @@ const string_utils_2 = require("../utils/string_utils");
14
14
  const command_utils_1 = require("../utils/command_utils");
15
15
  // Main function for the describe command
16
16
  const init = async (options) => {
17
- options.silent = (0, command_utils_1.getConfig)().silent || false;
17
+ options.silent = (0, command_utils_1.getConfig)(options).silent || false;
18
18
  const gpt = new cloving_gpt_1.default(options);
19
19
  const specialFileContents = (0, command_utils_1.collectSpecialFileContents)();
20
20
  const specialFileNames = Object.keys(specialFileContents).map(file => ' - ' + file);
@@ -38,7 +38,7 @@ const init = async (options) => {
38
38
  `);
39
39
  }
40
40
  }
41
- const config = (0, command_utils_1.getConfig)();
41
+ const config = (0, command_utils_1.getConfig)(options);
42
42
  if (!config || !config?.primaryModel || !config?.models) {
43
43
  console.error('No cloving configuration found. Please run `cloving config`');
44
44
  return;
@@ -10,7 +10,7 @@ const string_utils_1 = require("../utils/string_utils");
10
10
  const cloving_gpt_1 = __importDefault(require("../cloving_gpt"));
11
11
  const command_utils_1 = require("../utils/command_utils");
12
12
  const review = async (options) => {
13
- options.silent = (0, command_utils_1.getConfig)().silent || false;
13
+ options.silent = (0, command_utils_1.getConfig)(options).silent || false;
14
14
  const gpt = new cloving_gpt_1.default(options);
15
15
  try {
16
16
  // Define the prompt for analysis
@@ -127,11 +127,17 @@ const saveConfig = (config) => {
127
127
  console.log(`Configuration saved to ${exports.CONFIG_PATH}`);
128
128
  };
129
129
  exports.saveConfig = saveConfig;
130
- const getConfig = () => {
130
+ const getConfig = (options) => {
131
131
  try {
132
132
  if (fs_1.default.existsSync(exports.CONFIG_PATH)) {
133
133
  const rawConfig = fs_1.default.readFileSync(exports.CONFIG_PATH, 'utf-8');
134
- return JSON.parse(rawConfig);
134
+ const config = JSON.parse(rawConfig);
135
+ if (options.silent) {
136
+ return { ...config, silent: true };
137
+ }
138
+ else {
139
+ return config;
140
+ }
135
141
  }
136
142
  }
137
143
  catch (err) {
@@ -141,11 +147,11 @@ const getConfig = () => {
141
147
  return {
142
148
  models: { [`${process.env.CLOVING_MODEL}`]: process.env.CLOVING_API_KEY ?? '' },
143
149
  primaryModel: process.env.CLOVING_MODEL,
144
- silent: false
150
+ silent: options.silent || false
145
151
  };
146
152
  }
147
153
  else {
148
- return { models: {}, primaryModel: null, silent: false };
154
+ return { models: {}, primaryModel: null, silent: options.silent || false };
149
155
  }
150
156
  };
151
157
  exports.getConfig = getConfig;
package/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "cloving",
3
- "version": "0.1.0",
3
+ "version": "0.1.1",
4
4
  "main": "dist/index.js",
5
5
  "types": "dist/index.d.ts",
6
6
  "scripts": {