cokit-cli 1.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/FAQ.md +102 -0
- package/LICENSE +32 -0
- package/QUICK-START.md +37 -0
- package/README.md +110 -0
- package/bin/cokit.js +4 -0
- package/docs/cokit-comprehensive-mapping-guide.md +937 -0
- package/docs/cokit-slides.md +205 -0
- package/docs/cokit-team-presentation.md +319 -0
- package/docs/migration-guide.md +120 -0
- package/docs/project-roadmap.md +257 -0
- package/package.json +35 -0
- package/plans/260106-1102-cokit-implementation/phases/phase-01-cli-tool.md +151 -0
- package/plans/260106-1102-cokit-implementation/phases/phase-02-repo-level-templates.md +198 -0
- package/plans/260106-1102-cokit-implementation/phases/phase-03-user-level-skills.md +219 -0
- package/plans/260106-1102-cokit-implementation/phases/phase-04-prompt-files.md +328 -0
- package/plans/260106-1102-cokit-implementation/phases/phase-05-documentation.md +166 -0
- package/plans/260106-1102-cokit-implementation/plan.md +130 -0
- package/plans/260106-1102-cokit-implementation/research/researcher-01-copilot-skills-spec.md +182 -0
- package/plans/260106-1102-cokit-implementation/research/researcher-02-copilot-instructions-prompts.md +201 -0
- package/plans/reports/code-reviewer-260106-1718-phase2-repo-templates.md +184 -0
- package/plans/reports/code-reviewer-260106-1728-phase3-review.md +486 -0
- package/plans/reports/code-reviewer-260106-1742-phase4-prompts.md +235 -0
- package/plans/reports/code-reviewer-260106-1753-phase5-docs.md +275 -0
- package/plans/reports/docs-manager-260106-1217-phase1-completion.md +45 -0
- package/plans/reports/docs-manager-260106-1734-phase3-skills.md +108 -0
- package/plans/reports/docs-manager-260106-1746-phase4-prompt-files.md +75 -0
- package/plans/reports/project-manager-260106-1734-SUMMARY.md +354 -0
- package/plans/reports/project-manager-260106-1734-phase3-completion.md +257 -0
- package/plans/reports/project-manager-260106-1734-phase3-to-phase4-transition.md +274 -0
- package/plans/reports/project-manager-260106-1734-phase4-kickoff.md +343 -0
- package/plans/reports/project-manager-260106-1734-project-status.md +355 -0
- package/plans/reports/project-manager-260106-1746-phase4-completion.md +249 -0
- package/plans/reports/project-manager-260106-1746-phase4-deliverables.md +350 -0
- package/plans/reports/project-manager-260106-1804-project-complete.md +297 -0
- package/plans/reports/tester-260106-1717-phase2-templates.md +216 -0
- package/plans/reports/tester-260106-1726-phase3-user-skills.md +256 -0
- package/plans/reports/tester-260106-1741-phase4-prompts.md +202 -0
- package/plans/reports/tester-260106-1751-phase5-docs.md +301 -0
- package/skills/code-review/SKILL.md +86 -0
- package/skills/code-review/references/code-review-reception.md +76 -0
- package/skills/code-review/references/verification-before-completion.md +86 -0
- package/skills/debugging/SKILL.md +70 -0
- package/skills/debugging/references/root-cause-tracing.md +65 -0
- package/skills/debugging/references/systematic-debugging.md +74 -0
- package/skills/debugging/references/verification.md +74 -0
- package/skills/docs-seeker/SKILL.md +91 -0
- package/skills/docs-seeker/references/search-patterns.md +93 -0
- package/skills/docs-seeker/references/source-evaluation.md +77 -0
- package/skills/planning/SKILL.md +82 -0
- package/skills/planning/references/plan-organization.md +88 -0
- package/skills/planning/references/research-phase.md +56 -0
- package/skills/planning/references/solution-design.md +65 -0
- package/skills/sequential-thinking/SKILL.md +80 -0
- package/skills/sequential-thinking/references/advanced-techniques.md +88 -0
- package/skills/sequential-thinking/references/core-patterns.md +87 -0
- package/src/commands/add.js +93 -0
- package/src/commands/doctor.js +117 -0
- package/src/commands/init.js +152 -0
- package/src/commands/list.js +91 -0
- package/src/commands/update.js +22 -0
- package/src/index.js +23 -0
- package/src/utils/colors.js +14 -0
- package/src/utils/copy.js +122 -0
- package/src/utils/paths.js +35 -0
- package/templates/repo/.github/.cokit-version +4 -0
- package/templates/repo/.github/AGENTS.md +55 -0
- package/templates/repo/.github/copilot-instructions.md +45 -0
- package/templates/repo/.github/instructions/backend.instructions.md +35 -0
- package/templates/repo/.github/instructions/development.instructions.md +25 -0
- package/templates/repo/.github/instructions/frontend.instructions.md +31 -0
- package/templates/repo/.github/instructions/testing.instructions.md +31 -0
- package/templates/repo/.github/prompts/code.prompt.md +28 -0
- package/templates/repo/.github/prompts/docs.prompt.md +23 -0
- package/templates/repo/.github/prompts/fix.prompt.md +24 -0
- package/templates/repo/.github/prompts/plan.prompt.md +24 -0
- package/templates/repo/.github/prompts/review.prompt.md +24 -0
- package/templates/repo/.github/prompts/test.prompt.md +23 -0
- package/templates/repo/.github/skills/code-review/SKILL.md +46 -0
- package/templates/repo/.github/skills/debugging/SKILL.md +34 -0
- package/templates/repo/.vscode/settings.json +6 -0
- package/templates/repo/prompts/code.prompt.md +40 -0
- package/templates/repo/prompts/docs.prompt.md +29 -0
- package/templates/repo/prompts/fix.prompt.md +35 -0
- package/templates/repo/prompts/plan.prompt.md +41 -0
- package/templates/repo/prompts/review.prompt.md +38 -0
- package/templates/repo/prompts/test.prompt.md +29 -0
|
@@ -0,0 +1,80 @@
|
|
|
1
|
+
---
|
|
2
|
+
name: sequential-thinking
|
|
3
|
+
description: Apply structured, reflective problem-solving for complex tasks requiring multi-step analysis, revision capability, and hypothesis verification.
|
|
4
|
+
---
|
|
5
|
+
|
|
6
|
+
# Sequential Thinking
|
|
7
|
+
|
|
8
|
+
Structured problem-solving via manageable, reflective thought sequences with dynamic adjustment.
|
|
9
|
+
|
|
10
|
+
## When to Apply
|
|
11
|
+
|
|
12
|
+
- Complex problem decomposition
|
|
13
|
+
- Adaptive planning with revision capability
|
|
14
|
+
- Analysis needing course correction
|
|
15
|
+
- Problems with unclear/emerging scope
|
|
16
|
+
- Multi-step solutions requiring context maintenance
|
|
17
|
+
- Hypothesis-driven investigation/debugging
|
|
18
|
+
|
|
19
|
+
## Core Process
|
|
20
|
+
|
|
21
|
+
### 1. Start with Loose Estimate
|
|
22
|
+
```
|
|
23
|
+
Thought 1/5: [Initial analysis]
|
|
24
|
+
```
|
|
25
|
+
Adjust dynamically as understanding evolves.
|
|
26
|
+
|
|
27
|
+
### 2. Structure Each Thought
|
|
28
|
+
- Build on previous context explicitly
|
|
29
|
+
- Address one aspect per thought
|
|
30
|
+
- State assumptions, uncertainties, realizations
|
|
31
|
+
- Signal what next thought should address
|
|
32
|
+
|
|
33
|
+
### 3. Apply Dynamic Adjustment
|
|
34
|
+
- **Expand**: More complexity discovered → increase total
|
|
35
|
+
- **Contract**: Simpler than expected → decrease total
|
|
36
|
+
- **Revise**: New insight invalidates previous → mark revision
|
|
37
|
+
- **Branch**: Multiple approaches → explore alternatives
|
|
38
|
+
|
|
39
|
+
### 4. Use Revision When Needed
|
|
40
|
+
```
|
|
41
|
+
Thought 5/8 [REVISION of Thought 2]: [Corrected understanding]
|
|
42
|
+
- Original: [What was stated]
|
|
43
|
+
- Why revised: [New insight]
|
|
44
|
+
- Impact: [What changes]
|
|
45
|
+
```
|
|
46
|
+
|
|
47
|
+
### 5. Branch for Alternatives
|
|
48
|
+
```
|
|
49
|
+
Thought 4/7 [BRANCH A from Thought 2]: [Approach A]
|
|
50
|
+
Thought 4/7 [BRANCH B from Thought 2]: [Approach B]
|
|
51
|
+
```
|
|
52
|
+
Compare explicitly, converge with decision rationale.
|
|
53
|
+
|
|
54
|
+
### 6. Generate & Verify Hypotheses
|
|
55
|
+
```
|
|
56
|
+
Thought 6/9 [HYPOTHESIS]: [Proposed solution]
|
|
57
|
+
Thought 7/9 [VERIFICATION]: [Test results]
|
|
58
|
+
```
|
|
59
|
+
Iterate until hypothesis verified.
|
|
60
|
+
|
|
61
|
+
### 7. Complete Only When Ready
|
|
62
|
+
Mark final: `Thought N/N [FINAL]`
|
|
63
|
+
|
|
64
|
+
Complete when:
|
|
65
|
+
- Solution verified
|
|
66
|
+
- All critical aspects addressed
|
|
67
|
+
- Confidence achieved
|
|
68
|
+
- No outstanding uncertainties
|
|
69
|
+
|
|
70
|
+
## Application Modes
|
|
71
|
+
|
|
72
|
+
**Explicit**: Use visible thought markers when complexity warrants visible reasoning or user requests breakdown.
|
|
73
|
+
|
|
74
|
+
**Implicit**: Apply methodology internally for routine problem-solving where thinking aids accuracy without cluttering response.
|
|
75
|
+
|
|
76
|
+
## References
|
|
77
|
+
|
|
78
|
+
Load when deeper understanding needed:
|
|
79
|
+
- `references/core-patterns.md` - Revision & branching patterns
|
|
80
|
+
- `references/advanced-techniques.md` - Spiral refinement, hypothesis testing, convergence
|
|
@@ -0,0 +1,88 @@
|
|
|
1
|
+
# Advanced Sequential Thinking Techniques
|
|
2
|
+
|
|
3
|
+
Complex problem-solving patterns.
|
|
4
|
+
|
|
5
|
+
## Spiral Refinement
|
|
6
|
+
|
|
7
|
+
Return to concepts with progressively deeper understanding.
|
|
8
|
+
|
|
9
|
+
```
|
|
10
|
+
Thought 1/7: Initial design (surface)
|
|
11
|
+
Thought 2/7: Discover constraint A
|
|
12
|
+
Thought 3/7: Refine for A
|
|
13
|
+
Thought 4/7: Discover constraint B
|
|
14
|
+
Thought 5/7: Refine for both A and B
|
|
15
|
+
Thought 6/7: Integration reveals edge case
|
|
16
|
+
Thought 7/7: Final design addressing all constraints
|
|
17
|
+
```
|
|
18
|
+
|
|
19
|
+
**Use for**: Complex systems where constraints emerge iteratively.
|
|
20
|
+
**Key**: Each return is refinement, not restart.
|
|
21
|
+
|
|
22
|
+
## Hypothesis-Driven Investigation
|
|
23
|
+
|
|
24
|
+
Systematic hypothesis generation and testing.
|
|
25
|
+
|
|
26
|
+
```
|
|
27
|
+
Thought 1/6: Observe symptoms
|
|
28
|
+
Thought 2/6 [HYPOTHESIS]: Explanation X
|
|
29
|
+
Thought 3/6 [VERIFICATION]: Test X—partial match
|
|
30
|
+
Thought 4/6 [REFINED HYPOTHESIS]: Adjusted Y
|
|
31
|
+
Thought 5/6 [VERIFICATION]: Test Y—confirmed
|
|
32
|
+
Thought 6/6 [FINAL]: Solution based on verified Y
|
|
33
|
+
```
|
|
34
|
+
|
|
35
|
+
**Use for**: Debugging, root cause analysis, diagnostics.
|
|
36
|
+
**Pattern**: Generate → Test → Refine → Re-test loop.
|
|
37
|
+
|
|
38
|
+
## Multi-Branch Convergence
|
|
39
|
+
|
|
40
|
+
Explore alternatives, then synthesize best approach.
|
|
41
|
+
|
|
42
|
+
```
|
|
43
|
+
Thought 2/8: Multiple viable approaches
|
|
44
|
+
Thought 3/8 [BRANCH A]: Approach A benefits
|
|
45
|
+
Thought 4/8 [BRANCH A]: Approach A drawbacks
|
|
46
|
+
Thought 5/8 [BRANCH B]: Approach B benefits
|
|
47
|
+
Thought 6/8 [BRANCH B]: Approach B drawbacks
|
|
48
|
+
Thought 7/8 [CONVERGENCE]: Hybrid combining A's X with B's Y
|
|
49
|
+
Thought 8/8 [FINAL]: Hybrid superior to either alone
|
|
50
|
+
```
|
|
51
|
+
|
|
52
|
+
**Use for**: Complex decisions where neither option clearly best.
|
|
53
|
+
**Key**: Convergence often yields better solution than either branch.
|
|
54
|
+
|
|
55
|
+
## Progressive Context Deepening
|
|
56
|
+
|
|
57
|
+
Build understanding in layers from abstract to concrete.
|
|
58
|
+
|
|
59
|
+
```
|
|
60
|
+
Thought 1/9: High-level problem
|
|
61
|
+
Thought 2/9: Identify major components
|
|
62
|
+
Thought 3/9: Zoom into component A (detailed)
|
|
63
|
+
Thought 4/9: Zoom into component B (detailed)
|
|
64
|
+
Thought 5/9: Identify A-B interactions
|
|
65
|
+
Thought 6/9: Discover emergent constraint
|
|
66
|
+
Thought 7/9 [REVISION of 3-4]: Adjust for interaction
|
|
67
|
+
Thought 8/9: Verify complete system
|
|
68
|
+
Thought 9/9 [FINAL]: Integrated solution
|
|
69
|
+
```
|
|
70
|
+
|
|
71
|
+
**Use for**: System design, architecture, integration problems.
|
|
72
|
+
**Pattern**: Abstract → Components → Details → Interactions → Integration.
|
|
73
|
+
|
|
74
|
+
## Uncertainty Management
|
|
75
|
+
|
|
76
|
+
For high-uncertainty problems:
|
|
77
|
+
- Acknowledge uncertainty explicitly in thought markers
|
|
78
|
+
- Use confidence levels (high/medium/low)
|
|
79
|
+
- Branch when confidence diverges significantly
|
|
80
|
+
- Verify high-impact assumptions early
|
|
81
|
+
|
|
82
|
+
## Meta-Thinking Calibration
|
|
83
|
+
|
|
84
|
+
Periodically assess:
|
|
85
|
+
- Are thoughts advancing toward solution?
|
|
86
|
+
- Is scope expanding appropriately?
|
|
87
|
+
- Should approach be revised?
|
|
88
|
+
- Is current depth sufficient?
|
|
@@ -0,0 +1,87 @@
|
|
|
1
|
+
# Core Sequential Thinking Patterns
|
|
2
|
+
|
|
3
|
+
Essential revision and branching patterns.
|
|
4
|
+
|
|
5
|
+
## Revision Patterns
|
|
6
|
+
|
|
7
|
+
### Assumption Challenge
|
|
8
|
+
Early assumption proves invalid with new data.
|
|
9
|
+
```
|
|
10
|
+
Thought 1/5: Assume X is bottleneck
|
|
11
|
+
Thought 4/5 [REVISION of Thought 1]: X adequate; Y is actual bottleneck
|
|
12
|
+
```
|
|
13
|
+
|
|
14
|
+
### Scope Expansion
|
|
15
|
+
Problem larger than initially understood.
|
|
16
|
+
```
|
|
17
|
+
Thought 1/4: Fix bug
|
|
18
|
+
Thought 4/5 [REVISION of scope]: Architectural redesign needed, not patch
|
|
19
|
+
```
|
|
20
|
+
|
|
21
|
+
### Approach Shift
|
|
22
|
+
Initial strategy inadequate for requirements.
|
|
23
|
+
```
|
|
24
|
+
Thought 2/6: Optimize query
|
|
25
|
+
Thought 5/6 [REVISION of Thought 2]: Optimization + cache layer required
|
|
26
|
+
```
|
|
27
|
+
|
|
28
|
+
### Understanding Deepening
|
|
29
|
+
Later insight fundamentally changes interpretation.
|
|
30
|
+
```
|
|
31
|
+
Thought 1/5: Feature broken
|
|
32
|
+
Thought 4/5 [REVISION of Thought 1]: Not bug—UX confusion issue
|
|
33
|
+
```
|
|
34
|
+
|
|
35
|
+
## Branching Patterns
|
|
36
|
+
|
|
37
|
+
### Trade-off Evaluation
|
|
38
|
+
Compare approaches with different trade-offs.
|
|
39
|
+
```
|
|
40
|
+
Thought 3/7: Choose between X and Y
|
|
41
|
+
Thought 4/7 [BRANCH A]: X—simpler, less scalable
|
|
42
|
+
Thought 4/7 [BRANCH B]: Y—complex, scales better
|
|
43
|
+
Thought 5/7: Choose Y for long-term needs
|
|
44
|
+
```
|
|
45
|
+
|
|
46
|
+
### Risk Mitigation
|
|
47
|
+
Prepare backup for high-risk primary approach.
|
|
48
|
+
```
|
|
49
|
+
Thought 2/6: Primary: API integration
|
|
50
|
+
Thought 3/6 [BRANCH A]: API details
|
|
51
|
+
Thought 3/6 [BRANCH B]: Fallback: webhook
|
|
52
|
+
Thought 4/6: Implement A with B contingency
|
|
53
|
+
```
|
|
54
|
+
|
|
55
|
+
### Parallel Exploration
|
|
56
|
+
Investigate independent concerns separately.
|
|
57
|
+
```
|
|
58
|
+
Thought 3/8: Two unknowns—DB schema & API design
|
|
59
|
+
Thought 4/8 [BRANCH DB]: DB options
|
|
60
|
+
Thought 4/8 [BRANCH API]: API patterns
|
|
61
|
+
Thought 5/8: Integrate findings
|
|
62
|
+
```
|
|
63
|
+
|
|
64
|
+
### Hypothesis Testing
|
|
65
|
+
Test multiple explanations systematically.
|
|
66
|
+
```
|
|
67
|
+
Thought 2/6: Could be A, B, or C
|
|
68
|
+
Thought 3/6 [BRANCH A]: Test A—not cause
|
|
69
|
+
Thought 3/6 [BRANCH B]: Test B—confirmed
|
|
70
|
+
Thought 4/6: Root cause via Branch B
|
|
71
|
+
```
|
|
72
|
+
|
|
73
|
+
## Adjustment Guidelines
|
|
74
|
+
|
|
75
|
+
**Expand when**: Complexity discovered, multiple aspects identified, verification needed, alternatives require exploration.
|
|
76
|
+
|
|
77
|
+
**Contract when**: Key insight solves earlier, problem simpler, steps merge naturally.
|
|
78
|
+
|
|
79
|
+
## Anti-Patterns
|
|
80
|
+
|
|
81
|
+
**Premature Completion**: Rushing without verification → Add verification thoughts.
|
|
82
|
+
|
|
83
|
+
**Revision Cascade**: Repeated revisions without understanding why → Identify root cause.
|
|
84
|
+
|
|
85
|
+
**Branching Explosion**: Too many branches → Limit to 2-3, converge before more.
|
|
86
|
+
|
|
87
|
+
**Context Loss**: Ignoring earlier insights → Reference previous thoughts explicitly.
|
|
@@ -0,0 +1,93 @@
|
|
|
1
|
+
// add command - Add specific skills
|
|
2
|
+
import { Command } from 'commander';
|
|
3
|
+
import { copyDir, pathExists, listDirs } from '../utils/copy.js';
|
|
4
|
+
import { getSkillsSourceDir, getUserSkillsDir } from '../utils/paths.js';
|
|
5
|
+
import { success, error, info, done, hint, bold, cyan } from '../utils/colors.js';
|
|
6
|
+
import { join } from 'path';
|
|
7
|
+
import { existsSync, mkdirSync } from 'fs';
|
|
8
|
+
|
|
9
|
+
// Validate skill name to prevent path traversal
|
|
10
|
+
function validateSkillName(skill) {
|
|
11
|
+
if (!skill || !/^[a-zA-Z0-9_-]+$/.test(skill)) {
|
|
12
|
+
return false;
|
|
13
|
+
}
|
|
14
|
+
return true;
|
|
15
|
+
}
|
|
16
|
+
|
|
17
|
+
export const addCommand = new Command('add')
|
|
18
|
+
.description('Add a specific skill')
|
|
19
|
+
.argument('[skill]', 'Skill name to add')
|
|
20
|
+
.option('-l, --list', 'List available skills')
|
|
21
|
+
.option('-g, --global', 'Add to ~/.copilot/skills/ (default)')
|
|
22
|
+
.option('--local', 'Add to .github/skills/ in current project')
|
|
23
|
+
.option('--overwrite', 'Overwrite existing files')
|
|
24
|
+
.action(async (skill, options) => {
|
|
25
|
+
const skillsSrc = getSkillsSourceDir();
|
|
26
|
+
|
|
27
|
+
// List available skills
|
|
28
|
+
if (options.list || !skill) {
|
|
29
|
+
console.log();
|
|
30
|
+
console.log(bold(cyan('Available Skills:')));
|
|
31
|
+
console.log();
|
|
32
|
+
|
|
33
|
+
const skills = listDirs(skillsSrc);
|
|
34
|
+
if (skills.length === 0) {
|
|
35
|
+
info('No skills available.');
|
|
36
|
+
} else {
|
|
37
|
+
skills.forEach(s => {
|
|
38
|
+
console.log(` • ${s}`);
|
|
39
|
+
});
|
|
40
|
+
console.log();
|
|
41
|
+
hint('Run: npx cokit add <skill-name>');
|
|
42
|
+
}
|
|
43
|
+
return;
|
|
44
|
+
}
|
|
45
|
+
|
|
46
|
+
// Validate skill name (prevent path traversal)
|
|
47
|
+
if (!validateSkillName(skill)) {
|
|
48
|
+
error('Invalid skill name. Use only letters, numbers, hyphens, and underscores.');
|
|
49
|
+
return;
|
|
50
|
+
}
|
|
51
|
+
|
|
52
|
+
// Validate skill exists
|
|
53
|
+
const skillSrc = join(skillsSrc, skill);
|
|
54
|
+
if (!pathExists(skillSrc)) {
|
|
55
|
+
error(`Skill "${skill}" not found.`);
|
|
56
|
+
hint('Run: npx cokit add --list');
|
|
57
|
+
return;
|
|
58
|
+
}
|
|
59
|
+
|
|
60
|
+
// Determine destination
|
|
61
|
+
let skillDest;
|
|
62
|
+
if (options.local) {
|
|
63
|
+
skillDest = join(process.cwd(), '.github', 'skills', skill);
|
|
64
|
+
} else {
|
|
65
|
+
skillDest = join(getUserSkillsDir(), skill);
|
|
66
|
+
}
|
|
67
|
+
|
|
68
|
+
// Ensure parent directory exists
|
|
69
|
+
const parentDir = join(skillDest, '..');
|
|
70
|
+
if (!existsSync(parentDir)) {
|
|
71
|
+
mkdirSync(parentDir, { recursive: true });
|
|
72
|
+
}
|
|
73
|
+
|
|
74
|
+
try {
|
|
75
|
+
console.log();
|
|
76
|
+
info(`Adding skill: ${skill}`);
|
|
77
|
+
|
|
78
|
+
await copyDir(skillSrc, skillDest, {
|
|
79
|
+
overwrite: options.overwrite,
|
|
80
|
+
prompt: true
|
|
81
|
+
});
|
|
82
|
+
|
|
83
|
+
console.log();
|
|
84
|
+
done(`Skill "${skill}" added!`);
|
|
85
|
+
if (options.local) {
|
|
86
|
+
hint('Skill added to .github/skills/');
|
|
87
|
+
} else {
|
|
88
|
+
hint('Skill added to ~/.copilot/skills/');
|
|
89
|
+
}
|
|
90
|
+
} catch (err) {
|
|
91
|
+
error(`Failed to add skill: ${err.message}`);
|
|
92
|
+
}
|
|
93
|
+
});
|
|
@@ -0,0 +1,117 @@
|
|
|
1
|
+
// doctor command - Diagnose setup issues
|
|
2
|
+
import { Command } from 'commander';
|
|
3
|
+
import { pathExists, listDirs, countFiles } from '../utils/copy.js';
|
|
4
|
+
import { getUserSkillsDir, getRepoGithubDir, getRepoVscodeDir } from '../utils/paths.js';
|
|
5
|
+
import { success, error, warn, info, hint, bold, cyan } from '../utils/colors.js';
|
|
6
|
+
import { join } from 'path';
|
|
7
|
+
import { readdirSync, existsSync, readFileSync } from 'fs';
|
|
8
|
+
import { execSync } from 'child_process';
|
|
9
|
+
|
|
10
|
+
export const doctorCommand = new Command('doctor')
|
|
11
|
+
.description('Diagnose CoKit setup issues')
|
|
12
|
+
.action(async () => {
|
|
13
|
+
console.log();
|
|
14
|
+
console.log(bold(cyan('Checking CoKit setup...')));
|
|
15
|
+
console.log();
|
|
16
|
+
|
|
17
|
+
let hasIssues = false;
|
|
18
|
+
|
|
19
|
+
// Check project-level files
|
|
20
|
+
console.log(bold('Project Files:'));
|
|
21
|
+
const githubDir = getRepoGithubDir();
|
|
22
|
+
|
|
23
|
+
// Check copilot-instructions.md
|
|
24
|
+
const instructionsFile = join(githubDir, 'copilot-instructions.md');
|
|
25
|
+
if (pathExists(instructionsFile)) {
|
|
26
|
+
success('.github/copilot-instructions.md exists');
|
|
27
|
+
} else {
|
|
28
|
+
error('.github/copilot-instructions.md not found');
|
|
29
|
+
hint('Run: npx cokit init');
|
|
30
|
+
hasIssues = true;
|
|
31
|
+
}
|
|
32
|
+
|
|
33
|
+
// Check prompts directory
|
|
34
|
+
const promptsDir = join(githubDir, 'prompts');
|
|
35
|
+
if (pathExists(promptsDir)) {
|
|
36
|
+
const promptFiles = readdirSync(promptsDir).filter(f => f.endsWith('.prompt.md'));
|
|
37
|
+
if (promptFiles.length >= 6) {
|
|
38
|
+
success(`.github/prompts/ has ${promptFiles.length} prompts`);
|
|
39
|
+
} else {
|
|
40
|
+
warn(`.github/prompts/ has ${promptFiles.length} prompts (expected 6)`);
|
|
41
|
+
hasIssues = true;
|
|
42
|
+
}
|
|
43
|
+
} else {
|
|
44
|
+
error('.github/prompts/ not found');
|
|
45
|
+
hint('Run: npx cokit init');
|
|
46
|
+
hasIssues = true;
|
|
47
|
+
}
|
|
48
|
+
|
|
49
|
+
console.log();
|
|
50
|
+
|
|
51
|
+
// Check global skills
|
|
52
|
+
console.log(bold('Personal Skills:'));
|
|
53
|
+
const globalSkillsDir = getUserSkillsDir();
|
|
54
|
+
|
|
55
|
+
if (pathExists(globalSkillsDir)) {
|
|
56
|
+
const skills = listDirs(globalSkillsDir);
|
|
57
|
+
if (skills.length >= 5) {
|
|
58
|
+
success(`~/.copilot/skills/ has ${skills.length} skills`);
|
|
59
|
+
} else if (skills.length > 0) {
|
|
60
|
+
warn(`~/.copilot/skills/ has ${skills.length} skills (expected 5)`);
|
|
61
|
+
} else {
|
|
62
|
+
error('~/.copilot/skills/ is empty');
|
|
63
|
+
hint('Run: npx cokit init --global');
|
|
64
|
+
hasIssues = true;
|
|
65
|
+
}
|
|
66
|
+
} else {
|
|
67
|
+
error('~/.copilot/skills/ not found');
|
|
68
|
+
hint('Run: npx cokit init --global');
|
|
69
|
+
hasIssues = true;
|
|
70
|
+
}
|
|
71
|
+
|
|
72
|
+
console.log();
|
|
73
|
+
|
|
74
|
+
// Check VS Code
|
|
75
|
+
console.log(bold('Environment:'));
|
|
76
|
+
|
|
77
|
+
// Check if VS Code is installed
|
|
78
|
+
try {
|
|
79
|
+
execSync('code --version', { stdio: 'pipe' });
|
|
80
|
+
success('VS Code detected');
|
|
81
|
+
} catch {
|
|
82
|
+
warn('VS Code not detected in PATH');
|
|
83
|
+
hint('Install VS Code or add to PATH');
|
|
84
|
+
}
|
|
85
|
+
|
|
86
|
+
// Check .vscode/settings.json
|
|
87
|
+
const vscodeSettings = join(getRepoVscodeDir(), 'settings.json');
|
|
88
|
+
if (pathExists(vscodeSettings)) {
|
|
89
|
+
success('.vscode/settings.json exists');
|
|
90
|
+
|
|
91
|
+
// Check for Copilot settings
|
|
92
|
+
try {
|
|
93
|
+
const settings = JSON.parse(readFileSync(vscodeSettings, 'utf-8'));
|
|
94
|
+
if (settings['github.copilot.chat.useAgentSkills'] === true) {
|
|
95
|
+
success('Agent Skills enabled in settings');
|
|
96
|
+
} else {
|
|
97
|
+
warn('Agent Skills not enabled in settings');
|
|
98
|
+
hint('Add: "github.copilot.chat.useAgentSkills": true');
|
|
99
|
+
hasIssues = true;
|
|
100
|
+
}
|
|
101
|
+
} catch {
|
|
102
|
+
// Can't parse settings, skip
|
|
103
|
+
}
|
|
104
|
+
} else {
|
|
105
|
+
info('.vscode/settings.json not found (optional)');
|
|
106
|
+
}
|
|
107
|
+
|
|
108
|
+
console.log();
|
|
109
|
+
|
|
110
|
+
// Summary
|
|
111
|
+
if (hasIssues) {
|
|
112
|
+
console.log(bold('Found issues. Run suggested commands to fix.'));
|
|
113
|
+
} else {
|
|
114
|
+
console.log(bold(cyan('✓ Everything looks good!')));
|
|
115
|
+
}
|
|
116
|
+
console.log();
|
|
117
|
+
});
|
|
@@ -0,0 +1,152 @@
|
|
|
1
|
+
// init command - Setup CoKit in project or globally
|
|
2
|
+
import { Command } from 'commander';
|
|
3
|
+
import prompts from 'prompts';
|
|
4
|
+
import { copyDir, pathExists } from '../utils/copy.js';
|
|
5
|
+
import { getTemplatesDir, getSkillsSourceDir, getUserSkillsDir, getRepoGithubDir, getRepoVscodeDir } from '../utils/paths.js';
|
|
6
|
+
import { success, error, done, info, hint, bold, cyan } from '../utils/colors.js';
|
|
7
|
+
import { join } from 'path';
|
|
8
|
+
import { mkdirSync, existsSync } from 'fs';
|
|
9
|
+
|
|
10
|
+
export const initCommand = new Command('init')
|
|
11
|
+
.description('Set up CoKit in your project or globally')
|
|
12
|
+
.option('-g, --global', 'Install personal skills to ~/.copilot/')
|
|
13
|
+
.option('-a, --all', 'Install both project templates and personal skills')
|
|
14
|
+
.option('-y, --yes', 'Skip confirmation prompts')
|
|
15
|
+
.option('--overwrite', 'Overwrite existing files without prompting')
|
|
16
|
+
.action(async (options) => {
|
|
17
|
+
console.log();
|
|
18
|
+
console.log(bold(cyan('🚀 CoKit Setup')));
|
|
19
|
+
console.log();
|
|
20
|
+
|
|
21
|
+
try {
|
|
22
|
+
// Determine what to install
|
|
23
|
+
let installProject = false;
|
|
24
|
+
let installGlobal = false;
|
|
25
|
+
|
|
26
|
+
if (options.all) {
|
|
27
|
+
installProject = true;
|
|
28
|
+
installGlobal = true;
|
|
29
|
+
} else if (options.global) {
|
|
30
|
+
installGlobal = true;
|
|
31
|
+
} else if (!options.global && !options.all) {
|
|
32
|
+
// Interactive mode - ask user
|
|
33
|
+
const response = await prompts({
|
|
34
|
+
type: 'select',
|
|
35
|
+
name: 'mode',
|
|
36
|
+
message: 'What do you want to set up?',
|
|
37
|
+
choices: [
|
|
38
|
+
{ title: 'Project templates (.github/)', value: 'project', description: 'For this project only - share via git' },
|
|
39
|
+
{ title: 'Personal skills (~/.copilot/)', value: 'global', description: 'Works in all projects' },
|
|
40
|
+
{ title: 'Both', value: 'both', description: 'Recommended for first-time setup' }
|
|
41
|
+
],
|
|
42
|
+
initial: 0
|
|
43
|
+
});
|
|
44
|
+
|
|
45
|
+
if (!response.mode) {
|
|
46
|
+
console.log('Setup cancelled.');
|
|
47
|
+
return;
|
|
48
|
+
}
|
|
49
|
+
|
|
50
|
+
installProject = response.mode === 'project' || response.mode === 'both';
|
|
51
|
+
installGlobal = response.mode === 'global' || response.mode === 'both';
|
|
52
|
+
}
|
|
53
|
+
|
|
54
|
+
// Confirm before proceeding
|
|
55
|
+
if (!options.yes) {
|
|
56
|
+
const targets = [];
|
|
57
|
+
if (installProject) targets.push('.github/');
|
|
58
|
+
if (installGlobal) targets.push('~/.copilot/skills/');
|
|
59
|
+
|
|
60
|
+
const confirm = await prompts({
|
|
61
|
+
type: 'confirm',
|
|
62
|
+
name: 'proceed',
|
|
63
|
+
message: `This will create files in ${targets.join(' and ')}. Continue?`,
|
|
64
|
+
initial: true
|
|
65
|
+
});
|
|
66
|
+
|
|
67
|
+
if (!confirm.proceed) {
|
|
68
|
+
console.log('Setup cancelled.');
|
|
69
|
+
return;
|
|
70
|
+
}
|
|
71
|
+
}
|
|
72
|
+
|
|
73
|
+
console.log();
|
|
74
|
+
|
|
75
|
+
// Install project templates
|
|
76
|
+
if (installProject) {
|
|
77
|
+
info('Setting up project templates...');
|
|
78
|
+
await installProjectTemplates(options);
|
|
79
|
+
console.log();
|
|
80
|
+
}
|
|
81
|
+
|
|
82
|
+
// Install global skills
|
|
83
|
+
if (installGlobal) {
|
|
84
|
+
info('Setting up personal skills...');
|
|
85
|
+
await installGlobalSkills(options);
|
|
86
|
+
console.log();
|
|
87
|
+
}
|
|
88
|
+
|
|
89
|
+
// Success message
|
|
90
|
+
done('Done! Open VS Code and start using Copilot.');
|
|
91
|
+
hint('Try typing /fix in Copilot Chat.');
|
|
92
|
+
console.log();
|
|
93
|
+
|
|
94
|
+
} catch (err) {
|
|
95
|
+
error(`Setup failed: ${err.message}`);
|
|
96
|
+
process.exit(1);
|
|
97
|
+
}
|
|
98
|
+
});
|
|
99
|
+
|
|
100
|
+
async function installProjectTemplates(options) {
|
|
101
|
+
const templatesDir = getTemplatesDir();
|
|
102
|
+
const cwd = process.cwd();
|
|
103
|
+
|
|
104
|
+
// Check if templates exist
|
|
105
|
+
if (!pathExists(templatesDir)) {
|
|
106
|
+
error('Templates not found. Package may be corrupted.');
|
|
107
|
+
return;
|
|
108
|
+
}
|
|
109
|
+
|
|
110
|
+
// Copy .github directory
|
|
111
|
+
const githubSrc = join(templatesDir, '.github');
|
|
112
|
+
const githubDest = getRepoGithubDir(cwd);
|
|
113
|
+
|
|
114
|
+
if (pathExists(githubSrc)) {
|
|
115
|
+
await copyDir(githubSrc, githubDest, {
|
|
116
|
+
overwrite: options.overwrite,
|
|
117
|
+
prompt: !options.yes
|
|
118
|
+
});
|
|
119
|
+
}
|
|
120
|
+
|
|
121
|
+
// Copy .vscode directory
|
|
122
|
+
const vscodeSrc = join(templatesDir, '.vscode');
|
|
123
|
+
const vscodeDest = getRepoVscodeDir(cwd);
|
|
124
|
+
|
|
125
|
+
if (pathExists(vscodeSrc)) {
|
|
126
|
+
await copyDir(vscodeSrc, vscodeDest, {
|
|
127
|
+
overwrite: options.overwrite,
|
|
128
|
+
prompt: !options.yes
|
|
129
|
+
});
|
|
130
|
+
}
|
|
131
|
+
}
|
|
132
|
+
|
|
133
|
+
async function installGlobalSkills(options) {
|
|
134
|
+
const skillsSrc = getSkillsSourceDir();
|
|
135
|
+
const skillsDest = getUserSkillsDir();
|
|
136
|
+
|
|
137
|
+
// Check if skills source exists
|
|
138
|
+
if (!pathExists(skillsSrc)) {
|
|
139
|
+
error('Skills not found. Package may be corrupted.');
|
|
140
|
+
return;
|
|
141
|
+
}
|
|
142
|
+
|
|
143
|
+
// Ensure ~/.copilot/skills/ directory exists
|
|
144
|
+
if (!existsSync(skillsDest)) {
|
|
145
|
+
mkdirSync(skillsDest, { recursive: true });
|
|
146
|
+
}
|
|
147
|
+
|
|
148
|
+
await copyDir(skillsSrc, skillsDest, {
|
|
149
|
+
overwrite: options.overwrite,
|
|
150
|
+
prompt: !options.yes
|
|
151
|
+
});
|
|
152
|
+
}
|