cadr-cli 1.10.0 ā 2.0.0
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.
- package/dist/commands/status.d.ts +11 -0
- package/dist/commands/status.d.ts.map +1 -0
- package/dist/commands/status.js +69 -0
- package/dist/commands/status.js.map +1 -0
- package/dist/commands/status.test.d.ts +2 -0
- package/dist/commands/status.test.d.ts.map +1 -0
- package/dist/commands/status.test.js +83 -0
- package/dist/commands/status.test.js.map +1 -0
- package/dist/index.d.ts.map +1 -1
- package/dist/index.js +5 -0
- package/dist/index.js.map +1 -1
- package/package.json +1 -1
- package/src/commands/status.test.ts +64 -0
- package/src/commands/status.ts +71 -0
- package/src/index.ts +6 -0
|
@@ -0,0 +1,11 @@
|
|
|
1
|
+
/**
|
|
2
|
+
* Status Command
|
|
3
|
+
*
|
|
4
|
+
* Provides information about the current cADR configuration and environment.
|
|
5
|
+
*/
|
|
6
|
+
/**
|
|
7
|
+
* Execute the status command
|
|
8
|
+
* Displays configuration and environment status
|
|
9
|
+
*/
|
|
10
|
+
export declare function statusCommand(): Promise<void>;
|
|
11
|
+
//# sourceMappingURL=status.d.ts.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"status.d.ts","sourceRoot":"","sources":["../../src/commands/status.ts"],"names":[],"mappings":"AAAA;;;;GAIG;AAMH;;;GAGG;AACH,wBAAsB,aAAa,IAAI,OAAO,CAAC,IAAI,CAAC,CAwDnD"}
|
|
@@ -0,0 +1,69 @@
|
|
|
1
|
+
"use strict";
|
|
2
|
+
/**
|
|
3
|
+
* Status Command
|
|
4
|
+
*
|
|
5
|
+
* Provides information about the current cADR configuration and environment.
|
|
6
|
+
*/
|
|
7
|
+
Object.defineProperty(exports, "__esModule", { value: true });
|
|
8
|
+
exports.statusCommand = statusCommand;
|
|
9
|
+
const config_1 = require("../config");
|
|
10
|
+
const logger_1 = require("../logger");
|
|
11
|
+
const fs_1 = require("fs");
|
|
12
|
+
/**
|
|
13
|
+
* Execute the status command
|
|
14
|
+
* Displays configuration and environment status
|
|
15
|
+
*/
|
|
16
|
+
async function statusCommand() {
|
|
17
|
+
try {
|
|
18
|
+
const configPath = (0, config_1.getDefaultConfigPath)();
|
|
19
|
+
const configExists = (0, fs_1.existsSync)(configPath);
|
|
20
|
+
// eslint-disable-next-line no-console
|
|
21
|
+
console.log('\nš cADR Status');
|
|
22
|
+
// eslint-disable-next-line no-console
|
|
23
|
+
console.log('='.repeat(30));
|
|
24
|
+
// Config Status
|
|
25
|
+
// eslint-disable-next-line no-console
|
|
26
|
+
console.log(`\nš Configuration:`);
|
|
27
|
+
if (configExists) {
|
|
28
|
+
// eslint-disable-next-line no-console
|
|
29
|
+
console.log(` Path: ${configPath}`);
|
|
30
|
+
const config = await (0, config_1.loadConfig)(configPath);
|
|
31
|
+
if (config) {
|
|
32
|
+
// eslint-disable-next-line no-console
|
|
33
|
+
console.log(` Provider: ${config.provider}`);
|
|
34
|
+
// eslint-disable-next-line no-console
|
|
35
|
+
console.log(` Model: ${config.analysis_model}`);
|
|
36
|
+
// API Key Check
|
|
37
|
+
const apiKeySet = !!process.env[config.api_key_env];
|
|
38
|
+
// eslint-disable-next-line no-console
|
|
39
|
+
console.log(` API Key (${config.api_key_env}): ${apiKeySet ? 'ā
Set' : 'ā Not Set'}`);
|
|
40
|
+
}
|
|
41
|
+
else {
|
|
42
|
+
// eslint-disable-next-line no-console
|
|
43
|
+
console.log(' ā Error loading configuration details.');
|
|
44
|
+
}
|
|
45
|
+
}
|
|
46
|
+
else {
|
|
47
|
+
// eslint-disable-next-line no-console
|
|
48
|
+
console.log(` Path: ${configPath} (ā Not Found)`);
|
|
49
|
+
// eslint-disable-next-line no-console
|
|
50
|
+
console.log(' Run `cadr init` to create one.');
|
|
51
|
+
}
|
|
52
|
+
// Git Status (Basic check)
|
|
53
|
+
// eslint-disable-next-line no-console
|
|
54
|
+
console.log(`\nš ļø Environment:`);
|
|
55
|
+
// eslint-disable-next-line no-console
|
|
56
|
+
console.log(` OS: ${process.platform}`);
|
|
57
|
+
// eslint-disable-next-line no-console
|
|
58
|
+
console.log(` Node: ${process.version}`);
|
|
59
|
+
// eslint-disable-next-line no-console
|
|
60
|
+
console.log('\nDone.\n');
|
|
61
|
+
logger_1.loggerInstance.info('Status command completed');
|
|
62
|
+
}
|
|
63
|
+
catch (error) {
|
|
64
|
+
logger_1.loggerInstance.error('Status command failed', { error });
|
|
65
|
+
// eslint-disable-next-line no-console
|
|
66
|
+
console.error('\nā Failed to retrieve status. Check logs for details.\n');
|
|
67
|
+
}
|
|
68
|
+
}
|
|
69
|
+
//# sourceMappingURL=status.js.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"status.js","sourceRoot":"","sources":["../../src/commands/status.ts"],"names":[],"mappings":";AAAA;;;;GAIG;;AAUH,sCAwDC;AAhED,sCAA6D;AAC7D,sCAAqD;AACrD,2BAAgC;AAEhC;;;GAGG;AACI,KAAK,UAAU,aAAa;IACjC,IAAI,CAAC;QACH,MAAM,UAAU,GAAG,IAAA,6BAAoB,GAAE,CAAC;QAC1C,MAAM,YAAY,GAAG,IAAA,eAAU,EAAC,UAAU,CAAC,CAAC;QAE5C,sCAAsC;QACtC,OAAO,CAAC,GAAG,CAAC,kBAAkB,CAAC,CAAC;QAChC,sCAAsC;QACtC,OAAO,CAAC,GAAG,CAAC,GAAG,CAAC,MAAM,CAAC,EAAE,CAAC,CAAC,CAAC;QAE5B,gBAAgB;QAChB,sCAAsC;QACtC,OAAO,CAAC,GAAG,CAAC,qBAAqB,CAAC,CAAC;QACnC,IAAI,YAAY,EAAE,CAAC;YACjB,sCAAsC;YACtC,OAAO,CAAC,GAAG,CAAC,YAAY,UAAU,EAAE,CAAC,CAAC;YAEtC,MAAM,MAAM,GAAG,MAAM,IAAA,mBAAU,EAAC,UAAU,CAAC,CAAC;YAC5C,IAAI,MAAM,EAAE,CAAC;gBACX,sCAAsC;gBACtC,OAAO,CAAC,G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,CAAC;IAC5E,CAAC;AACH,CAAC"}
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"status.test.d.ts","sourceRoot":"","sources":["../../src/commands/status.test.ts"],"names":[],"mappings":""}
|
|
@@ -0,0 +1,83 @@
|
|
|
1
|
+
"use strict";
|
|
2
|
+
var __createBinding = (this && this.__createBinding) || (Object.create ? (function(o, m, k, k2) {
|
|
3
|
+
if (k2 === undefined) k2 = k;
|
|
4
|
+
var desc = Object.getOwnPropertyDescriptor(m, k);
|
|
5
|
+
if (!desc || ("get" in desc ? !m.__esModule : desc.writable || desc.configurable)) {
|
|
6
|
+
desc = { enumerable: true, get: function() { return m[k]; } };
|
|
7
|
+
}
|
|
8
|
+
Object.defineProperty(o, k2, desc);
|
|
9
|
+
}) : (function(o, m, k, k2) {
|
|
10
|
+
if (k2 === undefined) k2 = k;
|
|
11
|
+
o[k2] = m[k];
|
|
12
|
+
}));
|
|
13
|
+
var __setModuleDefault = (this && this.__setModuleDefault) || (Object.create ? (function(o, v) {
|
|
14
|
+
Object.defineProperty(o, "default", { enumerable: true, value: v });
|
|
15
|
+
}) : function(o, v) {
|
|
16
|
+
o["default"] = v;
|
|
17
|
+
});
|
|
18
|
+
var __importStar = (this && this.__importStar) || (function () {
|
|
19
|
+
var ownKeys = function(o) {
|
|
20
|
+
ownKeys = Object.getOwnPropertyNames || function (o) {
|
|
21
|
+
var ar = [];
|
|
22
|
+
for (var k in o) if (Object.prototype.hasOwnProperty.call(o, k)) ar[ar.length] = k;
|
|
23
|
+
return ar;
|
|
24
|
+
};
|
|
25
|
+
return ownKeys(o);
|
|
26
|
+
};
|
|
27
|
+
return function (mod) {
|
|
28
|
+
if (mod && mod.__esModule) return mod;
|
|
29
|
+
var result = {};
|
|
30
|
+
if (mod != null) for (var k = ownKeys(mod), i = 0; i < k.length; i++) if (k[i] !== "default") __createBinding(result, mod, k[i]);
|
|
31
|
+
__setModuleDefault(result, mod);
|
|
32
|
+
return result;
|
|
33
|
+
};
|
|
34
|
+
})();
|
|
35
|
+
Object.defineProperty(exports, "__esModule", { value: true });
|
|
36
|
+
const status_1 = require("./status");
|
|
37
|
+
const config = __importStar(require("../config"));
|
|
38
|
+
const fs = __importStar(require("fs"));
|
|
39
|
+
// Mock dependencies
|
|
40
|
+
jest.mock('../config');
|
|
41
|
+
jest.mock('fs');
|
|
42
|
+
jest.mock('../logger');
|
|
43
|
+
describe('Status Command', () => {
|
|
44
|
+
beforeEach(() => {
|
|
45
|
+
jest.clearAllMocks();
|
|
46
|
+
});
|
|
47
|
+
describe('statusCommand', () => {
|
|
48
|
+
test('displays status when config exists', async () => {
|
|
49
|
+
fs.existsSync.mockReturnValue(true);
|
|
50
|
+
config.getDefaultConfigPath.mockReturnValue('cadr.yaml');
|
|
51
|
+
config.loadConfig.mockResolvedValue({
|
|
52
|
+
provider: 'openai',
|
|
53
|
+
analysis_model: 'gpt-4',
|
|
54
|
+
api_key_env: 'OPENAI_API_KEY'
|
|
55
|
+
});
|
|
56
|
+
const consoleSpy = jest.spyOn(console, 'log').mockImplementation();
|
|
57
|
+
await (0, status_1.statusCommand)();
|
|
58
|
+
expect(consoleSpy).toHaveBeenCalledWith(expect.stringContaining('cADR Status'));
|
|
59
|
+
expect(consoleSpy).toHaveBeenCalledWith(expect.stringContaining('Provider: openai'));
|
|
60
|
+
expect(consoleSpy).toHaveBeenCalledWith(expect.stringContaining('Model: gpt-4'));
|
|
61
|
+
consoleSpy.mockRestore();
|
|
62
|
+
});
|
|
63
|
+
test('displays warning when config does not exist', async () => {
|
|
64
|
+
fs.existsSync.mockReturnValue(false);
|
|
65
|
+
config.getDefaultConfigPath.mockReturnValue('cadr.yaml');
|
|
66
|
+
const consoleSpy = jest.spyOn(console, 'log').mockImplementation();
|
|
67
|
+
await (0, status_1.statusCommand)();
|
|
68
|
+
expect(consoleSpy).toHaveBeenCalledWith(expect.stringContaining('Not Found'));
|
|
69
|
+
expect(consoleSpy).toHaveBeenCalledWith(expect.stringContaining('Run `cadr init`'));
|
|
70
|
+
consoleSpy.mockRestore();
|
|
71
|
+
});
|
|
72
|
+
test('handles errors gracefully', async () => {
|
|
73
|
+
config.getDefaultConfigPath.mockImplementation(() => {
|
|
74
|
+
throw new Error('FileSystem error');
|
|
75
|
+
});
|
|
76
|
+
const errorSpy = jest.spyOn(console, 'error').mockImplementation();
|
|
77
|
+
await (0, status_1.statusCommand)();
|
|
78
|
+
expect(errorSpy).toHaveBeenCalledWith(expect.stringContaining('Failed to retrieve status'));
|
|
79
|
+
errorSpy.mockRestore();
|
|
80
|
+
});
|
|
81
|
+
});
|
|
82
|
+
});
|
|
83
|
+
//# sourceMappingURL=status.test.js.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"status.test.js","sourceRoot":"","sources":["../../src/commands/status.test.ts"],"names":[],"mappings":";;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;AAAA,qCAAyC;AACzC,kDAAoC;AACpC,uCAAyB;AAEzB,oBAAoB;AACpB,IAAI,CAAC,IAAI,CAAC,WAAW,CAAC,CAAC;AACvB,IAAI,CAAC,IAAI,CAAC,IAAI,CAAC,CAAC;AAChB,IAAI,CAAC,IAAI,CAAC,WAAW,CAAC,CAAC;AAEvB,QAAQ,CAAC,gBAAgB,EAAE,GAAG,EAAE;IAC9B,UAAU,CAAC,GAAG,EAAE;QACd,IAAI,CAAC,aAAa,EAAE,CAAC;IACvB,CAAC,CAAC,CAAC;IAEH,QAAQ,CAAC,eAAe,EAAE,GAAG,EAAE;QAC7B,IAAI,CAAC,oCAAoC,EAAE,KAAK,IAAI,EAAE;YACnD,EAAE,CAAC,UAAwB,CAAC,eAAe,CAAC,IAAI,CAAC,CAAC;YAClD,MAAM,CAAC,oBAAkC,CAAC,eAAe,CAAC,WAAW,CAAC,CAAC;YACvE,MAAM,CAAC,UAAwB,CAAC,iBAAiB,CAAC;gBACjD,QAAQ,EAAE,QAAQ;gBAClB,cAAc,EAAE,OAAO;gBACvB,WAAW,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;gBACjE,MAAM,IAAI,KAAK,CAAC,kBAAkB,CAAC,CAAC;YACtC,CAAC,CAAC,CAAC;YAEH,MAAM,QAAQ,GAAG,IAAI,CAAC,KAAK,CAAC,OAAO,EAAE,OAAO,CAAC,CAAC,kBAAkB,EAAE,CAAC;YAEnE,MAAM,IAAA,sBAAa,GAAE,CAAC;YAEtB,MAAM,CAAC,QAAQ,CAAC,CAAC,oBAAoB,CAAC,MAAM,CAAC,gBAAgB,CAAC,2BAA2B,CAAC,CAAC,CAAC;YAE5F,QAAQ,CAAC,WAAW,EAAE,CAAC;QACzB,CAAC,CAAC,CAAC;IACL,CAAC,CAAC,CAAC;AACL,CAAC,CAAC,CAAC"}
|
package/dist/index.d.ts.map
CHANGED
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"index.d.ts","sourceRoot":"","sources":["../src/index.ts"],"names":[],"mappings":"
|
|
1
|
+
{"version":3,"file":"index.d.ts","sourceRoot":"","sources":["../src/index.ts"],"names":[],"mappings":"AAQA,wBAAgB,QAAQ,IAAI,IAAI,CA8C/B;AAED,wBAAgB,WAAW,IAAI,IAAI,CAElC"}
|
package/dist/index.js
CHANGED
|
@@ -5,6 +5,7 @@ exports.showHelp = showHelp;
|
|
|
5
5
|
exports.showVersion = showVersion;
|
|
6
6
|
const init_1 = require("./commands/init");
|
|
7
7
|
const analyze_1 = require("./commands/analyze");
|
|
8
|
+
const status_1 = require("./commands/status");
|
|
8
9
|
// Version constants
|
|
9
10
|
const CORE_VERSION = '0.0.1';
|
|
10
11
|
const CLI_VERSION = '0.0.1';
|
|
@@ -19,6 +20,7 @@ USAGE
|
|
|
19
20
|
COMMANDS
|
|
20
21
|
init Create a cadr.yaml configuration file
|
|
21
22
|
analyze Analyze code changes and generate ADRs (default)
|
|
23
|
+
status Show current configuration and environment status
|
|
22
24
|
help Show this help message
|
|
23
25
|
|
|
24
26
|
ANALYZE OPTIONS
|
|
@@ -81,6 +83,9 @@ if (require.main === module) {
|
|
|
81
83
|
case 'analyze':
|
|
82
84
|
await (0, analyze_1.analyzeCommand)(args);
|
|
83
85
|
break;
|
|
86
|
+
case 'status':
|
|
87
|
+
await (0, status_1.statusCommand)();
|
|
88
|
+
break;
|
|
84
89
|
default:
|
|
85
90
|
// Unknown command - show error and help
|
|
86
91
|
process.stdout.write(`\nā Unknown command: ${command}\n`);
|
package/dist/index.js.map
CHANGED
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"index.js","sourceRoot":"","sources":["../src/index.ts"],"names":[],"mappings":";;
|
|
1
|
+
{"version":3,"file":"index.js","sourceRoot":"","sources":["../src/index.ts"],"names":[],"mappings":";;AAQA,4BA8CC;AAED,kCAEC;AA1DD,0CAA8C;AAC9C,gDAAoD;AACpD,8CAAkD;AAElD,oBAAoB;AACpB,MAAM,YAAY,GAAG,OAAO,CAAC;AAC7B,MAAM,WAAW,GAAG,OAAO,CAAC;AAE5B,SAAgB,QAAQ;IACtB,MAAM,IAAI,GAAG;;WAEJ,WAAW;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;CAyCrB,CAAC;IACA,OAAO,CAAC,MAAM,CAAC,KAAK,CAAC,IAAI,CAAC,CAAC;AAC7B,CAAC;AAED,SAAgB,WAAW;IACzB,OAAO,CAAC,MAAM,CAAC,KAAK,CAAC,gBAAgB,WAAW,WAAW,YAAY,KAAK,CAAC,CAAC;AAChF,CAAC;AAGD,8DAA8D;AAC9D,IAAI,OAAO,CAAC,IAAI,KAAK,MAAM,EAAE,CAAC;IAC5B,MAAM,IAAI,GAAG,OAAO,CAAC,IAAI,CAAC,KAAK,CAAC,CAAC,CAAC,CAAC;IACnC,MAAM,OAAO,GAAG,IAAI,CAAC,CAAC,CAAC,CAAC;IAExB,kBAAkB;IAClB,CAAC,KAAK,IAAI,EAAE;QACV,aAAa;QACb,IAAI,CAAC,OAAO,IAAI,OAAO,KAAK,MAAM,IAAI,IAAI,CAAC,QAAQ,CAAC,QAAQ,CAAC,IAAI,IAAI,CAAC,QAAQ,CAAC,IAAI,CAAC,EAAE,CAAC;YACrF,QAAQ,EAAE,CAAC;YACX,OAAO;QACT,CAAC;QAED,eAAe;QACf,IAAI,IAAI,CAAC,QAAQ,CAAC,WAAW,CAAC,EAAE,CAAC;YAC/B,WAAW,EAAE,CAAC;YACd,OAAO;QACT,CAAC;QAED,WAAW;QACX,QAAQ,OAAO,EAAE,CAAC;YAChB,KAAK,MAAM;gBACT,MAAM,IAAA,kBAAW,GAAE,CAAC;gBACpB,MAAM;YAER,KAAK,SAAS;gBACZ,MAAM,IAAA,wBAAc,EAAC,IAAI,CAAC,CAAC;gBAC3B,MAAM;YAER,KAAK,QAAQ;gBACX,MAAM,IAAA,sBAAa,GAAE,CAAC;gBACtB,MAAM;YAER;gBACE,wCAAwC;gBACxC,OAAO,CAAC,MAAM,CAAC,KAAK,CAAC,wBAAwB,OAAO,IAAI,CAAC,CAAC;gBAC1D,QAAQ,EAAE,CAAC;gBACX,OAAO,CAAC,IAAI,CAAC,CAAC,CAAC,CAAC;QACpB,CAAC;IACH,CAAC,CAAC,EAAE,CAAC,KAAK,CAAC,CAAC,KAAK,EAAE,EAAE;QACnB,sCAAsC;QACtC,OAAO,CAAC,KAAK,CAAC,QAAQ,EAAE,KAAK,CAAC,OAAO,IAAI,KAAK,CAAC,CAAC;QAChD,OAAO,CAAC,IAAI,CAAC,CAAC,CAAC,CAAC;IAClB,CAAC,CAAC,CAAC;AACL,CAAC"}
|
package/package.json
CHANGED
|
@@ -0,0 +1,64 @@
|
|
|
1
|
+
import { statusCommand } from './status';
|
|
2
|
+
import * as config from '../config';
|
|
3
|
+
import * as fs from 'fs';
|
|
4
|
+
|
|
5
|
+
// Mock dependencies
|
|
6
|
+
jest.mock('../config');
|
|
7
|
+
jest.mock('fs');
|
|
8
|
+
jest.mock('../logger');
|
|
9
|
+
|
|
10
|
+
describe('Status Command', () => {
|
|
11
|
+
beforeEach(() => {
|
|
12
|
+
jest.clearAllMocks();
|
|
13
|
+
});
|
|
14
|
+
|
|
15
|
+
describe('statusCommand', () => {
|
|
16
|
+
test('displays status when config exists', async () => {
|
|
17
|
+
(fs.existsSync as jest.Mock).mockReturnValue(true);
|
|
18
|
+
(config.getDefaultConfigPath as jest.Mock).mockReturnValue('cadr.yaml');
|
|
19
|
+
(config.loadConfig as jest.Mock).mockResolvedValue({
|
|
20
|
+
provider: 'openai',
|
|
21
|
+
analysis_model: 'gpt-4',
|
|
22
|
+
api_key_env: 'OPENAI_API_KEY'
|
|
23
|
+
});
|
|
24
|
+
|
|
25
|
+
const consoleSpy = jest.spyOn(console, 'log').mockImplementation();
|
|
26
|
+
|
|
27
|
+
await statusCommand();
|
|
28
|
+
|
|
29
|
+
expect(consoleSpy).toHaveBeenCalledWith(expect.stringContaining('cADR Status'));
|
|
30
|
+
expect(consoleSpy).toHaveBeenCalledWith(expect.stringContaining('Provider: openai'));
|
|
31
|
+
expect(consoleSpy).toHaveBeenCalledWith(expect.stringContaining('Model: gpt-4'));
|
|
32
|
+
|
|
33
|
+
consoleSpy.mockRestore();
|
|
34
|
+
});
|
|
35
|
+
|
|
36
|
+
test('displays warning when config does not exist', async () => {
|
|
37
|
+
(fs.existsSync as jest.Mock).mockReturnValue(false);
|
|
38
|
+
(config.getDefaultConfigPath as jest.Mock).mockReturnValue('cadr.yaml');
|
|
39
|
+
|
|
40
|
+
const consoleSpy = jest.spyOn(console, 'log').mockImplementation();
|
|
41
|
+
|
|
42
|
+
await statusCommand();
|
|
43
|
+
|
|
44
|
+
expect(consoleSpy).toHaveBeenCalledWith(expect.stringContaining('Not Found'));
|
|
45
|
+
expect(consoleSpy).toHaveBeenCalledWith(expect.stringContaining('Run `cadr init`'));
|
|
46
|
+
|
|
47
|
+
consoleSpy.mockRestore();
|
|
48
|
+
});
|
|
49
|
+
|
|
50
|
+
test('handles errors gracefully', async () => {
|
|
51
|
+
(config.getDefaultConfigPath as jest.Mock).mockImplementation(() => {
|
|
52
|
+
throw new Error('FileSystem error');
|
|
53
|
+
});
|
|
54
|
+
|
|
55
|
+
const errorSpy = jest.spyOn(console, 'error').mockImplementation();
|
|
56
|
+
|
|
57
|
+
await statusCommand();
|
|
58
|
+
|
|
59
|
+
expect(errorSpy).toHaveBeenCalledWith(expect.stringContaining('Failed to retrieve status'));
|
|
60
|
+
|
|
61
|
+
errorSpy.mockRestore();
|
|
62
|
+
});
|
|
63
|
+
});
|
|
64
|
+
});
|
|
@@ -0,0 +1,71 @@
|
|
|
1
|
+
/**
|
|
2
|
+
* Status Command
|
|
3
|
+
*
|
|
4
|
+
* Provides information about the current cADR configuration and environment.
|
|
5
|
+
*/
|
|
6
|
+
|
|
7
|
+
import { loadConfig, getDefaultConfigPath } from '../config';
|
|
8
|
+
import { loggerInstance as logger } from '../logger';
|
|
9
|
+
import { existsSync } from 'fs';
|
|
10
|
+
|
|
11
|
+
/**
|
|
12
|
+
* Execute the status command
|
|
13
|
+
* Displays configuration and environment status
|
|
14
|
+
*/
|
|
15
|
+
export async function statusCommand(): Promise<void> {
|
|
16
|
+
try {
|
|
17
|
+
const configPath = getDefaultConfigPath();
|
|
18
|
+
const configExists = existsSync(configPath);
|
|
19
|
+
|
|
20
|
+
// eslint-disable-next-line no-console
|
|
21
|
+
console.log('\nš cADR Status');
|
|
22
|
+
// eslint-disable-next-line no-console
|
|
23
|
+
console.log('='.repeat(30));
|
|
24
|
+
|
|
25
|
+
// Config Status
|
|
26
|
+
// eslint-disable-next-line no-console
|
|
27
|
+
console.log(`\nš Configuration:`);
|
|
28
|
+
if (configExists) {
|
|
29
|
+
// eslint-disable-next-line no-console
|
|
30
|
+
console.log(` Path: ${configPath}`);
|
|
31
|
+
|
|
32
|
+
const config = await loadConfig(configPath);
|
|
33
|
+
if (config) {
|
|
34
|
+
// eslint-disable-next-line no-console
|
|
35
|
+
console.log(` Provider: ${config.provider}`);
|
|
36
|
+
// eslint-disable-next-line no-console
|
|
37
|
+
console.log(` Model: ${config.analysis_model}`);
|
|
38
|
+
|
|
39
|
+
// API Key Check
|
|
40
|
+
const apiKeySet = !!process.env[config.api_key_env];
|
|
41
|
+
// eslint-disable-next-line no-console
|
|
42
|
+
console.log(` API Key (${config.api_key_env}): ${apiKeySet ? 'ā
Set' : 'ā Not Set'}`);
|
|
43
|
+
} else {
|
|
44
|
+
// eslint-disable-next-line no-console
|
|
45
|
+
console.log(' ā Error loading configuration details.');
|
|
46
|
+
}
|
|
47
|
+
} else {
|
|
48
|
+
// eslint-disable-next-line no-console
|
|
49
|
+
console.log(` Path: ${configPath} (ā Not Found)`);
|
|
50
|
+
// eslint-disable-next-line no-console
|
|
51
|
+
console.log(' Run `cadr init` to create one.');
|
|
52
|
+
}
|
|
53
|
+
|
|
54
|
+
// Git Status (Basic check)
|
|
55
|
+
// eslint-disable-next-line no-console
|
|
56
|
+
console.log(`\nš ļø Environment:`);
|
|
57
|
+
// eslint-disable-next-line no-console
|
|
58
|
+
console.log(` OS: ${process.platform}`);
|
|
59
|
+
// eslint-disable-next-line no-console
|
|
60
|
+
console.log(` Node: ${process.version}`);
|
|
61
|
+
|
|
62
|
+
// eslint-disable-next-line no-console
|
|
63
|
+
console.log('\nDone.\n');
|
|
64
|
+
|
|
65
|
+
logger.info('Status command completed');
|
|
66
|
+
} catch (error) {
|
|
67
|
+
logger.error('Status command failed', { error });
|
|
68
|
+
// eslint-disable-next-line no-console
|
|
69
|
+
console.error('\nā Failed to retrieve status. Check logs for details.\n');
|
|
70
|
+
}
|
|
71
|
+
}
|
package/src/index.ts
CHANGED
|
@@ -1,5 +1,6 @@
|
|
|
1
1
|
import { initCommand } from './commands/init';
|
|
2
2
|
import { analyzeCommand } from './commands/analyze';
|
|
3
|
+
import { statusCommand } from './commands/status';
|
|
3
4
|
|
|
4
5
|
// Version constants
|
|
5
6
|
const CORE_VERSION = '0.0.1';
|
|
@@ -16,6 +17,7 @@ USAGE
|
|
|
16
17
|
COMMANDS
|
|
17
18
|
init Create a cadr.yaml configuration file
|
|
18
19
|
analyze Analyze code changes and generate ADRs (default)
|
|
20
|
+
status Show current configuration and environment status
|
|
19
21
|
help Show this help message
|
|
20
22
|
|
|
21
23
|
ANALYZE OPTIONS
|
|
@@ -85,6 +87,10 @@ if (require.main === module) {
|
|
|
85
87
|
case 'analyze':
|
|
86
88
|
await analyzeCommand(args);
|
|
87
89
|
break;
|
|
90
|
+
|
|
91
|
+
case 'status':
|
|
92
|
+
await statusCommand();
|
|
93
|
+
break;
|
|
88
94
|
|
|
89
95
|
default:
|
|
90
96
|
// Unknown command - show error and help
|