archicore 0.1.9 → 0.2.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.
@@ -603,23 +603,33 @@ async function handleDeadCodeCommand() {
603
603
  if (!response.ok)
604
604
  throw new Error('Analysis failed');
605
605
  const data = await response.json();
606
- const result = data.deadCode;
606
+ // Handle various response formats
607
+ const result = data.deadCode || data.result || data || {};
607
608
  spinner.succeed('Analysis complete');
608
609
  printSection('Dead Code');
609
- console.log(` Unused exports: ${result.unusedExports?.length || 0}`);
610
- console.log(` Unused variables: ${result.unusedVariables?.length || 0}`);
611
- console.log(` Unreachable code: ${result.unreachableCode?.length || 0}`);
612
- if (result.unusedExports?.length > 0) {
610
+ const unusedExports = result.unusedExports || [];
611
+ const unusedVariables = result.unusedVariables || [];
612
+ const unreachableCode = result.unreachableCode || [];
613
+ console.log(` Unused exports: ${unusedExports.length}`);
614
+ console.log(` Unused variables: ${unusedVariables.length}`);
615
+ console.log(` Unreachable code: ${unreachableCode.length}`);
616
+ if (unusedExports.length === 0 && unusedVariables.length === 0 && unreachableCode.length === 0) {
617
+ printSuccess('No dead code found!');
618
+ return;
619
+ }
620
+ if (unusedExports.length > 0) {
613
621
  console.log();
614
622
  console.log(colors.muted(' Top unused exports:'));
615
- for (const item of result.unusedExports.slice(0, 5)) {
616
- console.log(` ${colors.warning(icons.warning)} ${item.name} ${colors.dim(`(${item.filePath})`)}`);
623
+ for (const item of unusedExports.slice(0, 5)) {
624
+ const name = item.name || item.symbol || 'unknown';
625
+ const file = item.filePath || item.file || '';
626
+ console.log(` ${colors.warning(icons.warning)} ${name} ${colors.dim(`(${file})`)}`);
617
627
  }
618
628
  }
619
629
  }
620
630
  catch (error) {
621
631
  spinner.fail('Analysis failed');
622
- throw error;
632
+ printFormattedError(error, { operation: 'Dead code analysis' });
623
633
  }
624
634
  }
625
635
  async function handleSecurityCommand() {
@@ -634,7 +644,9 @@ async function handleSecurityCommand() {
634
644
  if (!response.ok)
635
645
  throw new Error('Analysis failed');
636
646
  const data = await response.json();
637
- const vulns = data.security?.vulnerabilities || [];
647
+ // Handle various response formats
648
+ const security = data.security || data.result || data || {};
649
+ const vulns = security.vulnerabilities || security.issues || [];
638
650
  spinner.succeed('Analysis complete');
639
651
  printSection('Security');
640
652
  if (vulns.length === 0) {
@@ -655,13 +667,15 @@ async function handleSecurityCommand() {
655
667
  console.log();
656
668
  console.log(colors.muted(' Critical/High issues:'));
657
669
  for (const v of vulns.filter((v) => v.severity === 'critical' || v.severity === 'high').slice(0, 5)) {
658
- console.log(` ${colors.error(icons.error)} ${v.type}: ${v.description}`);
670
+ const type = v.type || v.category || 'Issue';
671
+ const desc = v.description || v.message || 'No description';
672
+ console.log(` ${colors.error(icons.error)} ${type}: ${desc}`);
659
673
  }
660
674
  }
661
675
  }
662
676
  catch (error) {
663
677
  spinner.fail('Analysis failed');
664
- throw error;
678
+ printFormattedError(error, { operation: 'Security analysis' });
665
679
  }
666
680
  }
667
681
  async function handleMetricsCommand() {
@@ -676,19 +690,38 @@ async function handleMetricsCommand() {
676
690
  if (!response.ok)
677
691
  throw new Error('Analysis failed');
678
692
  const data = await response.json();
679
- const metrics = data.metrics;
693
+ // Handle various response formats
694
+ const metrics = data.metrics || data.result || data || {};
695
+ const summary = metrics.summary || metrics || {};
680
696
  spinner.succeed('Metrics calculated');
681
697
  printSection('Code Metrics');
682
- if (metrics.summary) {
683
- console.log(` Files: ${metrics.summary.totalFiles || 0}`);
684
- console.log(` Lines: ${metrics.summary.totalLines || 0}`);
685
- console.log(` Avg Complexity: ${(metrics.summary.avgComplexity || 0).toFixed(2)}`);
686
- console.log(` Avg Maintainability: ${(metrics.summary.avgMaintainability || 0).toFixed(1)}`);
698
+ // Display available metrics
699
+ const totalFiles = summary.totalFiles || summary.files || metrics.totalFiles || 0;
700
+ const totalLines = summary.totalLines || summary.lines || metrics.totalLines || 0;
701
+ const avgComplexity = summary.avgComplexity || summary.complexity || metrics.avgComplexity || 0;
702
+ const avgMaintainability = summary.avgMaintainability || summary.maintainability || metrics.avgMaintainability || 0;
703
+ console.log(` Files: ${totalFiles}`);
704
+ console.log(` Lines: ${totalLines}`);
705
+ if (avgComplexity > 0) {
706
+ console.log(` Avg Complexity: ${Number(avgComplexity).toFixed(2)}`);
707
+ }
708
+ if (avgMaintainability > 0) {
709
+ console.log(` Avg Maintainability: ${Number(avgMaintainability).toFixed(1)}`);
710
+ }
711
+ // Show additional metrics if available
712
+ if (metrics.functions || summary.functions) {
713
+ console.log(` Functions: ${metrics.functions || summary.functions}`);
714
+ }
715
+ if (metrics.classes || summary.classes) {
716
+ console.log(` Classes: ${metrics.classes || summary.classes}`);
717
+ }
718
+ if (totalFiles === 0 && totalLines === 0) {
719
+ printWarning('No metrics data available. Make sure project is indexed.');
687
720
  }
688
721
  }
689
722
  catch (error) {
690
723
  spinner.fail('Analysis failed');
691
- throw error;
724
+ printFormattedError(error, { operation: 'Metrics calculation' });
692
725
  }
693
726
  }
694
727
  async function handleExportCommand(args) {
@@ -781,28 +814,37 @@ async function handleDuplicationCommand() {
781
814
  if (!response.ok)
782
815
  throw new Error('Analysis failed');
783
816
  const data = await response.json();
784
- const result = data.duplication;
817
+ // Handle various response formats
818
+ const result = data.duplication || data.result || data || {};
819
+ const clones = result.clones || [];
820
+ const duplicationRate = result.duplicationRate || result.rate || 0;
821
+ const duplicatedLines = result.duplicatedLines || result.lines || 0;
785
822
  spinner.succeed('Analysis complete');
786
823
  printSection('Code Duplication');
787
- console.log(` Code clones: ${result.clones?.length || 0}`);
788
- console.log(` Duplication rate: ${(result.duplicationRate || 0).toFixed(1)}%`);
789
- console.log(` Duplicated lines: ${result.duplicatedLines || 0}`);
790
- if (result.clones?.length > 0) {
791
- console.log();
792
- console.log(colors.muted(' Top duplicates:'));
793
- for (const clone of result.clones.slice(0, 5)) {
794
- console.log(` ${colors.warning(icons.warning)} ${clone.files?.length || 2} files, ${clone.lines || 0} lines`);
795
- if (clone.files) {
796
- for (const f of clone.files.slice(0, 2)) {
797
- console.log(` ${colors.dim(f)}`);
798
- }
824
+ console.log(` Code clones: ${clones.length}`);
825
+ console.log(` Duplication rate: ${Number(duplicationRate).toFixed(1)}%`);
826
+ console.log(` Duplicated lines: ${duplicatedLines}`);
827
+ if (clones.length === 0) {
828
+ printSuccess('No code duplication found!');
829
+ return;
830
+ }
831
+ console.log();
832
+ console.log(colors.muted(' Top duplicates:'));
833
+ for (const clone of clones.slice(0, 5)) {
834
+ const files = clone.files || clone.locations || [];
835
+ const lines = clone.lines || clone.lineCount || 0;
836
+ console.log(` ${colors.warning(icons.warning)} ${files.length || 2} files, ${lines} lines`);
837
+ if (files.length > 0) {
838
+ for (const f of files.slice(0, 2)) {
839
+ const filePath = typeof f === 'string' ? f : f.file || f.path || '';
840
+ console.log(` ${colors.dim(filePath)}`);
799
841
  }
800
842
  }
801
843
  }
802
844
  }
803
845
  catch (error) {
804
846
  spinner.fail('Analysis failed');
805
- throw error;
847
+ printFormattedError(error, { operation: 'Duplication analysis' });
806
848
  }
807
849
  }
808
850
  async function handleRefactoringCommand() {
@@ -818,7 +860,9 @@ async function handleRefactoringCommand() {
818
860
  if (!response.ok)
819
861
  throw new Error('Analysis failed');
820
862
  const data = await response.json();
821
- const suggestions = data.refactoring?.suggestions || [];
863
+ // Handle various response formats
864
+ const refactoring = data.refactoring || data.result || data || {};
865
+ const suggestions = refactoring.suggestions || refactoring.items || [];
822
866
  spinner.succeed('Analysis complete');
823
867
  printSection('Refactoring Suggestions');
824
868
  if (suggestions.length === 0) {
@@ -837,17 +881,20 @@ async function handleRefactoringCommand() {
837
881
  console.log();
838
882
  console.log(colors.muted(' Top suggestions:'));
839
883
  for (const s of suggestions.slice(0, 5)) {
840
- const priorityColor = s.priority === 'critical' ? colors.critical :
841
- s.priority === 'high' ? colors.high : colors.muted;
842
- console.log(` ${priorityColor(`[${s.priority}]`)} ${s.type}: ${s.description}`);
843
- if (s.file) {
844
- console.log(` ${colors.dim(s.file)}`);
884
+ const priority = s.priority || 'medium';
885
+ const type = s.type || s.category || 'Suggestion';
886
+ const desc = s.description || s.message || '';
887
+ const priorityColor = priority === 'critical' ? colors.critical :
888
+ priority === 'high' ? colors.high : colors.muted;
889
+ console.log(` ${priorityColor(`[${priority}]`)} ${type}: ${desc}`);
890
+ if (s.file || s.filePath) {
891
+ console.log(` ${colors.dim(s.file || s.filePath)}`);
845
892
  }
846
893
  }
847
894
  }
848
895
  catch (error) {
849
896
  spinner.fail('Analysis failed');
850
- throw error;
897
+ printFormattedError(error, { operation: 'Refactoring analysis' });
851
898
  }
852
899
  }
853
900
  async function handleRulesCommand() {
@@ -863,7 +910,9 @@ async function handleRulesCommand() {
863
910
  if (!response.ok)
864
911
  throw new Error('Analysis failed');
865
912
  const data = await response.json();
866
- const violations = data.rules?.violations || [];
913
+ // Handle various response formats
914
+ const rules = data.rules || data.result || data || {};
915
+ const violations = rules.violations || rules.issues || [];
867
916
  spinner.succeed('Analysis complete');
868
917
  printSection('Architectural Rules');
869
918
  if (violations.length === 0) {
@@ -873,17 +922,20 @@ async function handleRulesCommand() {
873
922
  console.log(` Violations: ${violations.length}`);
874
923
  console.log();
875
924
  for (const v of violations.slice(0, 10)) {
876
- const severityColor = v.severity === 'error' ? colors.error :
877
- v.severity === 'warning' ? colors.warning : colors.muted;
878
- console.log(` ${severityColor(icons.error)} ${v.rule}: ${v.message}`);
879
- if (v.file) {
880
- console.log(` ${colors.dim(v.file)}`);
925
+ const severity = v.severity || 'warning';
926
+ const rule = v.rule || v.name || 'Unknown rule';
927
+ const message = v.message || v.description || '';
928
+ const severityColor = severity === 'error' ? colors.error :
929
+ severity === 'warning' ? colors.warning : colors.muted;
930
+ console.log(` ${severityColor(icons.error)} ${rule}: ${message}`);
931
+ if (v.file || v.filePath) {
932
+ console.log(` ${colors.dim(v.file || v.filePath)}`);
881
933
  }
882
934
  }
883
935
  }
884
936
  catch (error) {
885
937
  spinner.fail('Analysis failed');
886
- throw error;
938
+ printFormattedError(error, { operation: 'Rules check' });
887
939
  }
888
940
  }
889
941
  async function handleDocsCommand(args) {
package/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "archicore",
3
- "version": "0.1.9",
3
+ "version": "0.2.0",
4
4
  "description": "AI Software Architect - code analysis, impact prediction, semantic search",
5
5
  "main": "dist/index.js",
6
6
  "type": "module",