apero-kit-cli 1.7.1 → 2.1.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.
@@ -1,129 +0,0 @@
1
- import fs from 'fs-extra';
2
- import { join } from 'path';
3
- import chalk from 'chalk';
4
- import { isAkProject, resolveSource, TARGETS } from '../utils/paths.js';
5
- import { loadState } from '../utils/state.js';
6
-
7
- export async function doctorCommand(options = {}) {
8
- const projectDir = process.cwd();
9
-
10
- console.log(chalk.cyan.bold('\nApero Kit Doctor\n'));
11
- console.log(chalk.gray('Checking project health...\n'));
12
-
13
- let issues = 0;
14
- let warnings = 0;
15
-
16
- // Check 1: Is this an ak project?
17
- const isProject = isAkProject(projectDir);
18
- if (isProject) {
19
- console.log(chalk.green('✓ ak project detected'));
20
- } else {
21
- console.log(chalk.red('✗ Not an ak project'));
22
- issues++;
23
- }
24
-
25
- // Check 2: State file
26
- const state = await loadState(projectDir);
27
- if (state) {
28
- console.log(chalk.green('✓ State file (.ak/state.json) exists'));
29
- } else if (isProject) {
30
- console.log(chalk.yellow('⚠ No state file - project may have been created manually'));
31
- warnings++;
32
- }
33
-
34
- // Check 3: Target directory
35
- let targetDir = null;
36
- for (const [name, folder] of Object.entries(TARGETS)) {
37
- const dir = join(projectDir, folder);
38
- if (fs.existsSync(dir)) {
39
- targetDir = { name, folder, dir };
40
- break;
41
- }
42
- }
43
-
44
- if (targetDir) {
45
- console.log(chalk.green(`✓ Target directory exists (${targetDir.folder})`));
46
- } else {
47
- console.log(chalk.red('✗ No target directory (.claude/, .opencode/, .agent/)'));
48
- issues++;
49
- }
50
-
51
- // Check 4: AGENTS.md
52
- const agentsMd = join(projectDir, 'AGENTS.md');
53
- if (fs.existsSync(agentsMd)) {
54
- console.log(chalk.green('✓ AGENTS.md exists'));
55
- } else {
56
- console.log(chalk.yellow('⚠ AGENTS.md not found (optional but recommended)'));
57
- warnings++;
58
- }
59
-
60
- // Check 5: Source availability
61
- if (state && state.source) {
62
- if (fs.existsSync(state.source)) {
63
- console.log(chalk.green(`✓ Source directory accessible`));
64
- } else {
65
- console.log(chalk.red(`✗ Source directory not found: ${state.source}`));
66
- issues++;
67
- }
68
- }
69
-
70
- // Check 6: Key subdirectories
71
- if (targetDir) {
72
- const checkDirs = ['agents', 'commands', 'skills'];
73
- for (const dir of checkDirs) {
74
- const fullPath = join(targetDir.dir, dir);
75
- if (fs.existsSync(fullPath)) {
76
- const items = fs.readdirSync(fullPath).length;
77
- console.log(chalk.green(`✓ ${dir}/ exists (${items} items)`));
78
- } else {
79
- console.log(chalk.yellow(`⚠ ${dir}/ not found`));
80
- warnings++;
81
- }
82
- }
83
- }
84
-
85
- // Check 7: Auto-detect source in parent directories
86
- console.log('');
87
- console.log(chalk.gray('Source detection:'));
88
- const source = resolveSource();
89
- if (source.error) {
90
- console.log(chalk.yellow(` ⚠ ${source.error}`));
91
- warnings++;
92
- } else {
93
- console.log(chalk.green(` ✓ Found source: ${source.path}`));
94
- console.log(chalk.gray(` Type: ${source.type || 'unknown'}`));
95
- }
96
-
97
- // Summary
98
- console.log('');
99
- console.log(chalk.cyan('─'.repeat(40)));
100
-
101
- if (issues === 0 && warnings === 0) {
102
- console.log(chalk.green.bold('\n✓ All checks passed!\n'));
103
- } else if (issues === 0) {
104
- console.log(chalk.yellow(`\n⚠ ${warnings} warning(s), no critical issues\n`));
105
- } else {
106
- console.log(chalk.red(`\n✗ ${issues} issue(s), ${warnings} warning(s)\n`));
107
- }
108
-
109
- // Suggestions
110
- if (issues > 0 || warnings > 0) {
111
- console.log(chalk.cyan('Suggestions:'));
112
-
113
- if (!isProject) {
114
- console.log(chalk.white(' • Run "ak init ." to initialize this directory'));
115
- }
116
-
117
- if (!state && isProject) {
118
- console.log(chalk.white(' • State file is missing. Re-run "ak init" or create manually'));
119
- }
120
-
121
- if (state && state.source && !fs.existsSync(state.source)) {
122
- console.log(chalk.white(' • Update source path: ak update --source <new-path>'));
123
- }
124
-
125
- console.log('');
126
- }
127
-
128
- return { issues, warnings };
129
- }