@shepai/cli 1.3.0 → 1.4.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.
@@ -0,0 +1,15 @@
1
+ /**
2
+ * Settings Command Group
3
+ *
4
+ * Provides subcommands for managing Shep global settings.
5
+ *
6
+ * Usage:
7
+ * shep settings show # Display current settings
8
+ * shep settings init # Initialize settings to defaults
9
+ */
10
+ import { Command } from 'commander';
11
+ /**
12
+ * Create the settings command group
13
+ */
14
+ export declare function createSettingsCommand(): Command;
15
+ //# sourceMappingURL=index.d.ts.map
@@ -0,0 +1 @@
1
+ {"version":3,"file":"index.d.ts","sourceRoot":"","sources":["../../../../../../src/presentation/cli/commands/settings/index.ts"],"names":[],"mappings":"AAAA;;;;;;;;GAQG;AAEH,OAAO,EAAE,OAAO,EAAE,MAAM,WAAW,CAAC;AAIpC;;GAEG;AACH,wBAAgB,qBAAqB,IAAI,OAAO,CAK/C"}
@@ -0,0 +1,21 @@
1
+ /**
2
+ * Settings Command Group
3
+ *
4
+ * Provides subcommands for managing Shep global settings.
5
+ *
6
+ * Usage:
7
+ * shep settings show # Display current settings
8
+ * shep settings init # Initialize settings to defaults
9
+ */
10
+ import { Command } from 'commander';
11
+ import { createShowCommand } from './show.command.js';
12
+ import { createInitCommand } from './init.command.js';
13
+ /**
14
+ * Create the settings command group
15
+ */
16
+ export function createSettingsCommand() {
17
+ return new Command('settings')
18
+ .description('Manage Shep global settings')
19
+ .addCommand(createShowCommand())
20
+ .addCommand(createInitCommand());
21
+ }
@@ -0,0 +1,15 @@
1
+ /**
2
+ * Init Settings Command
3
+ *
4
+ * Re-initializes Shep settings to defaults with confirmation prompt.
5
+ *
6
+ * Usage:
7
+ * shep settings init # Prompt for confirmation
8
+ * shep settings init --force # Skip confirmation
9
+ */
10
+ import { Command } from 'commander';
11
+ /**
12
+ * Create the init settings command
13
+ */
14
+ export declare function createInitCommand(): Command;
15
+ //# sourceMappingURL=init.command.d.ts.map
@@ -0,0 +1 @@
1
+ {"version":3,"file":"init.command.d.ts","sourceRoot":"","sources":["../../../../../../src/presentation/cli/commands/settings/init.command.ts"],"names":[],"mappings":"AAAA;;;;;;;;GAQG;AAEH,OAAO,EAAE,OAAO,EAAE,MAAM,WAAW,CAAC;AAoCpC;;GAEG;AACH,wBAAgB,iBAAiB,IAAI,OAAO,CAoC3C"}
@@ -0,0 +1,71 @@
1
+ /**
2
+ * Init Settings Command
3
+ *
4
+ * Re-initializes Shep settings to defaults with confirmation prompt.
5
+ *
6
+ * Usage:
7
+ * shep settings init # Prompt for confirmation
8
+ * shep settings init --force # Skip confirmation
9
+ */
10
+ import { Command } from 'commander';
11
+ import { createInterface } from 'node:readline';
12
+ import { createDefaultSettings } from '../../../../domain/factories/settings-defaults.factory.js';
13
+ import { resetSettings, initializeSettings, } from '../../../../infrastructure/services/settings.service.js';
14
+ import { messages } from '../../ui/index.js';
15
+ /**
16
+ * Prompt user for yes/no confirmation.
17
+ * Returns false on EOF (no stdin) to prevent silent modifications.
18
+ */
19
+ function confirm(message) {
20
+ return new Promise((resolve) => {
21
+ const rl = createInterface({
22
+ input: process.stdin,
23
+ output: process.stdout,
24
+ });
25
+ let answered = false;
26
+ rl.question(message, (answer) => {
27
+ answered = true;
28
+ rl.close();
29
+ resolve(answer.toLowerCase() === 'y');
30
+ });
31
+ rl.on('close', () => {
32
+ if (!answered) {
33
+ resolve(false);
34
+ }
35
+ });
36
+ });
37
+ }
38
+ /**
39
+ * Create the init settings command
40
+ */
41
+ export function createInitCommand() {
42
+ return new Command('init')
43
+ .description('Initialize settings to defaults')
44
+ .option('-f, --force', 'Skip confirmation prompt')
45
+ .addHelpText('after', `
46
+ Examples:
47
+ $ shep settings init Prompt for confirmation before reset
48
+ $ shep settings init --force Reset settings without prompting
49
+ $ shep settings init -f Same as --force (short flag)`)
50
+ .action(async (options) => {
51
+ try {
52
+ if (!options.force) {
53
+ messages.warning('This will reset all settings to defaults. Consider backing up ~/.shep/data first.');
54
+ const confirmed = await confirm('Are you sure? (y/N): ');
55
+ if (!confirmed) {
56
+ messages.info('Operation cancelled.');
57
+ return;
58
+ }
59
+ }
60
+ const newSettings = createDefaultSettings();
61
+ resetSettings();
62
+ initializeSettings(newSettings);
63
+ messages.success('Settings initialized to defaults.');
64
+ }
65
+ catch (error) {
66
+ const err = error instanceof Error ? error : new Error(String(error));
67
+ messages.error('Failed to initialize settings', err);
68
+ process.exitCode = 1;
69
+ }
70
+ });
71
+ }
@@ -0,0 +1,16 @@
1
+ /**
2
+ * Show Settings Command
3
+ *
4
+ * Displays current Shep settings with multiple output format support.
5
+ *
6
+ * Usage:
7
+ * shep settings show # Display as table (default)
8
+ * shep settings show --output json # Display as JSON
9
+ * shep settings show -o yaml # Display as YAML
10
+ */
11
+ import { Command } from 'commander';
12
+ /**
13
+ * Create the show settings command
14
+ */
15
+ export declare function createShowCommand(): Command;
16
+ //# sourceMappingURL=show.command.d.ts.map
@@ -0,0 +1 @@
1
+ {"version":3,"file":"show.command.d.ts","sourceRoot":"","sources":["../../../../../../src/presentation/cli/commands/settings/show.command.ts"],"names":[],"mappings":"AAAA;;;;;;;;;GASG;AAEH,OAAO,EAAE,OAAO,EAAU,MAAM,WAAW,CAAC;AAO5C;;GAEG;AACH,wBAAgB,iBAAiB,IAAI,OAAO,CA6C3C"}
@@ -0,0 +1,66 @@
1
+ /**
2
+ * Show Settings Command
3
+ *
4
+ * Displays current Shep settings with multiple output format support.
5
+ *
6
+ * Usage:
7
+ * shep settings show # Display as table (default)
8
+ * shep settings show --output json # Display as JSON
9
+ * shep settings show -o yaml # Display as YAML
10
+ */
11
+ import { Command, Option } from 'commander';
12
+ import { OutputFormatter } from '../../ui/output.js';
13
+ import { getShepDbPath } from '../../../../infrastructure/services/filesystem/shep-directory.service.js';
14
+ import { getSettings } from '../../../../infrastructure/services/settings.service.js';
15
+ import { statSync } from 'node:fs';
16
+ import { messages, fmt } from '../../ui/index.js';
17
+ /**
18
+ * Create the show settings command
19
+ */
20
+ export function createShowCommand() {
21
+ return new Command('show')
22
+ .description('Display current settings')
23
+ .addOption(new Option('-o, --output <format>', 'Output format: table|json|yaml')
24
+ .choices(['table', 'json', 'yaml'])
25
+ .default('table'))
26
+ .addHelpText('after', `
27
+ Examples:
28
+ $ shep settings show Display settings as table
29
+ $ shep settings show --output json Display settings as JSON
30
+ $ shep settings show -o yaml Display settings as YAML`)
31
+ .action((options) => {
32
+ try {
33
+ const settings = getSettings();
34
+ const output = OutputFormatter.format(settings, options.output);
35
+ console.log(output);
36
+ // Show database metadata for table format
37
+ if (options.output === 'table') {
38
+ const dbPath = getShepDbPath();
39
+ let sizeStr = 'unknown';
40
+ try {
41
+ const stats = statSync(dbPath);
42
+ sizeStr = formatFileSize(stats.size);
43
+ }
44
+ catch {
45
+ // File may not be accessible
46
+ }
47
+ messages.newline();
48
+ console.log(fmt.heading('Database'));
49
+ console.log(` ${fmt.label('Path:')} ${dbPath}`);
50
+ console.log(` ${fmt.label('Size:')} ${sizeStr}`);
51
+ }
52
+ }
53
+ catch (error) {
54
+ const err = error instanceof Error ? error : new Error(String(error));
55
+ messages.error('Failed to load settings', err);
56
+ process.exitCode = 1;
57
+ }
58
+ });
59
+ }
60
+ function formatFileSize(bytes) {
61
+ if (bytes < 1024)
62
+ return `${bytes} B`;
63
+ if (bytes < 1024 * 1024)
64
+ return `${(bytes / 1024).toFixed(1)} KB`;
65
+ return `${(bytes / (1024 * 1024)).toFixed(1)} MB`;
66
+ }
@@ -21,6 +21,7 @@ import 'reflect-metadata';
21
21
  import { Command } from 'commander';
22
22
  import { VersionService } from '../../infrastructure/services/version.service.js';
23
23
  import { createVersionCommand } from './commands/version.command.js';
24
+ import { createSettingsCommand } from './commands/settings/index.js';
24
25
  import { messages } from './ui/index.js';
25
26
  // DI container and settings
26
27
  import { initializeContainer, container } from '../../infrastructure/di/container.js';
@@ -64,8 +65,9 @@ async function bootstrap() {
64
65
  });
65
66
  // Register commands
66
67
  program.addCommand(createVersionCommand());
67
- // Parse arguments
68
- program.parse();
68
+ program.addCommand(createSettingsCommand());
69
+ // Parse arguments (parseAsync needed for async command actions like init)
70
+ await program.parseAsync();
69
71
  }
70
72
  catch (_error) {
71
73
  // Final catch - already logged specific error above
@@ -15,4 +15,6 @@ export { colors, type Colors } from './colors.js';
15
15
  export { symbols, type Symbols } from './symbols.js';
16
16
  export { fmt, type Formatters } from './formatters.js';
17
17
  export { messages, type Messages } from './messages.js';
18
+ export { TableFormatter } from './tables.js';
19
+ export { OutputFormatter, type OutputFormat } from './output.js';
18
20
  //# sourceMappingURL=index.d.ts.map
@@ -1 +1 @@
1
- {"version":3,"file":"index.d.ts","sourceRoot":"","sources":["../../../../../src/presentation/cli/ui/index.ts"],"names":[],"mappings":"AAAA;;;;;;;;;;;;GAYG;AAEH,OAAO,EAAE,MAAM,EAAE,KAAK,MAAM,EAAE,MAAM,aAAa,CAAC;AAClD,OAAO,EAAE,OAAO,EAAE,KAAK,OAAO,EAAE,MAAM,cAAc,CAAC;AACrD,OAAO,EAAE,GAAG,EAAE,KAAK,UAAU,EAAE,MAAM,iBAAiB,CAAC;AACvD,OAAO,EAAE,QAAQ,EAAE,KAAK,QAAQ,EAAE,MAAM,eAAe,CAAC"}
1
+ {"version":3,"file":"index.d.ts","sourceRoot":"","sources":["../../../../../src/presentation/cli/ui/index.ts"],"names":[],"mappings":"AAAA;;;;;;;;;;;;GAYG;AAEH,OAAO,EAAE,MAAM,EAAE,KAAK,MAAM,EAAE,MAAM,aAAa,CAAC;AAClD,OAAO,EAAE,OAAO,EAAE,KAAK,OAAO,EAAE,MAAM,cAAc,CAAC;AACrD,OAAO,EAAE,GAAG,EAAE,KAAK,UAAU,EAAE,MAAM,iBAAiB,CAAC;AACvD,OAAO,EAAE,QAAQ,EAAE,KAAK,QAAQ,EAAE,MAAM,eAAe,CAAC;AACxD,OAAO,EAAE,cAAc,EAAE,MAAM,aAAa,CAAC;AAC7C,OAAO,EAAE,eAAe,EAAE,KAAK,YAAY,EAAE,MAAM,aAAa,CAAC"}
@@ -15,3 +15,5 @@ export { colors } from './colors.js';
15
15
  export { symbols } from './symbols.js';
16
16
  export { fmt } from './formatters.js';
17
17
  export { messages } from './messages.js';
18
+ export { TableFormatter } from './tables.js';
19
+ export { OutputFormatter } from './output.js';
@@ -0,0 +1,33 @@
1
+ /**
2
+ * Output Format Utilities
3
+ *
4
+ * Provides utilities for formatting output in multiple formats:
5
+ * - Table (default, using cli-table3)
6
+ * - JSON (structured data)
7
+ * - YAML (human-readable structured data)
8
+ *
9
+ * @module output
10
+ */
11
+ export type OutputFormat = 'table' | 'json' | 'yaml';
12
+ /**
13
+ * Output formatter for multiple formats
14
+ */
15
+ export declare class OutputFormatter {
16
+ /**
17
+ * Formats data according to the specified output format
18
+ */
19
+ static format(data: unknown, format: OutputFormat): string;
20
+ /**
21
+ * Formats data as a table
22
+ */
23
+ static formatAsTable(data: unknown): string;
24
+ /**
25
+ * Formats data as JSON
26
+ */
27
+ static formatAsJSON(data: unknown): string;
28
+ /**
29
+ * Formats data as YAML
30
+ */
31
+ static formatAsYAML(data: unknown): string;
32
+ }
33
+ //# sourceMappingURL=output.d.ts.map
@@ -0,0 +1 @@
1
+ {"version":3,"file":"output.d.ts","sourceRoot":"","sources":["../../../../../src/presentation/cli/ui/output.ts"],"names":[],"mappings":"AAAA;;;;;;;;;GASG;AAKH,MAAM,MAAM,YAAY,GAAG,OAAO,GAAG,MAAM,GAAG,MAAM,CAAC;AAErD;;GAEG;AACH,qBAAa,eAAe;IAC1B;;OAEG;IACH,MAAM,CAAC,MAAM,CAAC,IAAI,EAAE,OAAO,EAAE,MAAM,EAAE,YAAY,GAAG,MAAM;IAW1D;;OAEG;IACH,MAAM,CAAC,aAAa,CAAC,IAAI,EAAE,OAAO,GAAG,MAAM;IAK3C;;OAEG;IACH,MAAM,CAAC,YAAY,CAAC,IAAI,EAAE,OAAO,GAAG,MAAM;IAI1C;;OAEG;IACH,MAAM,CAAC,YAAY,CAAC,IAAI,EAAE,OAAO,GAAG,MAAM;CAG3C"}
@@ -0,0 +1,49 @@
1
+ /**
2
+ * Output Format Utilities
3
+ *
4
+ * Provides utilities for formatting output in multiple formats:
5
+ * - Table (default, using cli-table3)
6
+ * - JSON (structured data)
7
+ * - YAML (human-readable structured data)
8
+ *
9
+ * @module output
10
+ */
11
+ import yaml from 'js-yaml';
12
+ import { TableFormatter } from './tables.js';
13
+ /**
14
+ * Output formatter for multiple formats
15
+ */
16
+ export class OutputFormatter {
17
+ /**
18
+ * Formats data according to the specified output format
19
+ */
20
+ static format(data, format) {
21
+ switch (format) {
22
+ case 'table':
23
+ return OutputFormatter.formatAsTable(data);
24
+ case 'json':
25
+ return OutputFormatter.formatAsJSON(data);
26
+ case 'yaml':
27
+ return OutputFormatter.formatAsYAML(data);
28
+ }
29
+ }
30
+ /**
31
+ * Formats data as a table
32
+ */
33
+ static formatAsTable(data) {
34
+ const table = TableFormatter.createSettingsTable(data);
35
+ return table.toString();
36
+ }
37
+ /**
38
+ * Formats data as JSON
39
+ */
40
+ static formatAsJSON(data) {
41
+ return JSON.stringify(data, null, 2);
42
+ }
43
+ /**
44
+ * Formats data as YAML
45
+ */
46
+ static formatAsYAML(data) {
47
+ return yaml.dump(data, { indent: 2, lineWidth: -1 });
48
+ }
49
+ }
@@ -0,0 +1,19 @@
1
+ /**
2
+ * Table Formatting Utilities
3
+ *
4
+ * Provides utilities for rendering structured data as formatted tables
5
+ * in the terminal using cli-table3.
6
+ *
7
+ * @module tables
8
+ */
9
+ import Table from 'cli-table3';
10
+ /**
11
+ * Table formatter for CLI output
12
+ */
13
+ export declare class TableFormatter {
14
+ /**
15
+ * Creates a formatted table for settings data
16
+ */
17
+ static createSettingsTable(settings: unknown): InstanceType<typeof Table>;
18
+ }
19
+ //# sourceMappingURL=tables.d.ts.map
@@ -0,0 +1 @@
1
+ {"version":3,"file":"tables.d.ts","sourceRoot":"","sources":["../../../../../src/presentation/cli/ui/tables.ts"],"names":[],"mappings":"AAAA;;;;;;;GAOG;AAEH,OAAO,KAAK,MAAM,YAAY,CAAC;AAG/B;;GAEG;AACH,qBAAa,cAAc;IACzB;;OAEG;IACH,MAAM,CAAC,mBAAmB,CAAC,QAAQ,EAAE,OAAO,GAAG,YAAY,CAAC,OAAO,KAAK,CAAC;CAwC1E"}
@@ -0,0 +1,32 @@
1
+ /**
2
+ * Table Formatting Utilities
3
+ *
4
+ * Provides utilities for rendering structured data as formatted tables
5
+ * in the terminal using cli-table3.
6
+ *
7
+ * @module tables
8
+ */
9
+ import Table from 'cli-table3';
10
+ /**
11
+ * Table formatter for CLI output
12
+ */
13
+ export class TableFormatter {
14
+ /**
15
+ * Creates a formatted table for settings data
16
+ */
17
+ static createSettingsTable(settings) {
18
+ const s = settings;
19
+ const table = new Table({
20
+ style: { head: [], border: [] },
21
+ });
22
+ // Models section
23
+ table.push([{ colSpan: 2, content: 'Models', hAlign: 'center' }], ['Analyze', s.models.analyze], ['Requirements', s.models.requirements], ['Plan', s.models.plan], ['Implement', s.models.implement]);
24
+ // User section
25
+ table.push([{ colSpan: 2, content: 'User', hAlign: 'center' }], ['Name', s.user.name ?? '(not set)'], ['Email', s.user.email ?? '(not set)'], ['GitHub', s.user.githubUsername ?? '(not set)']);
26
+ // Environment section
27
+ table.push([{ colSpan: 2, content: 'Environment', hAlign: 'center' }], ['Editor', s.environment.defaultEditor], ['Shell', s.environment.shellPreference]);
28
+ // System section
29
+ table.push([{ colSpan: 2, content: 'System', hAlign: 'center' }], ['Auto-Update', String(s.system.autoUpdate)], ['Log Level', s.system.logLevel]);
30
+ return table;
31
+ }
32
+ }