cp-toolkit 3.0.1 ā 3.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.
package/bin/cp-toolkit.js
CHANGED
|
@@ -46,6 +46,7 @@ program
|
|
|
46
46
|
.description('Initialize cp-kit in a directory (creates .github/ structure)')
|
|
47
47
|
.option('-y, --yes', 'Skip prompts and use defaults')
|
|
48
48
|
.option('-f, --force', 'Overwrite existing configuration')
|
|
49
|
+
.option('-g, --global', 'Install instructions globally to VS Code User Prompts directory')
|
|
49
50
|
.action(initCommand);
|
|
50
51
|
|
|
51
52
|
// cp-kit add <type> <name>
|
package/package.json
CHANGED
package/src/commands/init.js
CHANGED
|
@@ -11,6 +11,7 @@
|
|
|
11
11
|
|
|
12
12
|
import fs from 'fs-extra';
|
|
13
13
|
import path from 'path';
|
|
14
|
+
import os from 'os';
|
|
14
15
|
import chalk from 'chalk';
|
|
15
16
|
import ora from 'ora';
|
|
16
17
|
import prompts from 'prompts';
|
|
@@ -20,10 +21,89 @@ import { fileURLToPath } from 'url';
|
|
|
20
21
|
const __filename = fileURLToPath(import.meta.url);
|
|
21
22
|
const __dirname = path.dirname(__filename);
|
|
22
23
|
|
|
24
|
+
function getGlobalPromptsDir() {
|
|
25
|
+
const platform = os.platform();
|
|
26
|
+
const homeDir = os.homedir();
|
|
27
|
+
|
|
28
|
+
if (platform === 'win32') {
|
|
29
|
+
return path.join(process.env.APPDATA, 'Code', 'User', 'prompts');
|
|
30
|
+
} else if (platform === 'darwin') {
|
|
31
|
+
return path.join(homeDir, 'Library', 'Application Support', 'Code', 'User', 'prompts');
|
|
32
|
+
} else {
|
|
33
|
+
// Linux and others
|
|
34
|
+
return path.join(homeDir, '.config', 'Code', 'User', 'prompts');
|
|
35
|
+
}
|
|
36
|
+
}
|
|
37
|
+
|
|
38
|
+
async function initGlobal(options, templatesDir) {
|
|
39
|
+
const targetDir = getGlobalPromptsDir();
|
|
40
|
+
console.log(chalk.bold.cyan('\nš cp-toolkit - Installing Global Instructions\n'));
|
|
41
|
+
console.log(chalk.dim(`Target directory: ${targetDir}`));
|
|
42
|
+
|
|
43
|
+
if (!options.yes) {
|
|
44
|
+
const { confirm } = await prompts({
|
|
45
|
+
type: 'confirm',
|
|
46
|
+
name: 'confirm',
|
|
47
|
+
message: `Install instructions globally to VS Code User Data?`,
|
|
48
|
+
initial: true
|
|
49
|
+
});
|
|
50
|
+
if (!confirm) return;
|
|
51
|
+
}
|
|
52
|
+
|
|
53
|
+
const spinner = ora('Installing global instructions...').start();
|
|
54
|
+
|
|
55
|
+
try {
|
|
56
|
+
// Check if Code/User exists (VS Code installed?)
|
|
57
|
+
if (!fs.existsSync(path.dirname(targetDir))) {
|
|
58
|
+
spinner.warn(chalk.yellow('VS Code User directory not found. Is VS Code installed?'));
|
|
59
|
+
const { create } = await prompts({
|
|
60
|
+
type: 'confirm',
|
|
61
|
+
name: 'create',
|
|
62
|
+
message: 'Create directory anyway?',
|
|
63
|
+
initial: true
|
|
64
|
+
});
|
|
65
|
+
if (!create) return;
|
|
66
|
+
}
|
|
67
|
+
|
|
68
|
+
await fs.ensureDir(targetDir);
|
|
69
|
+
|
|
70
|
+
// Copy instructions
|
|
71
|
+
// We flatten them: templates/instructions/*.md -> targetDir/*.md
|
|
72
|
+
const instructionsSourceDir = path.join(templatesDir, 'instructions');
|
|
73
|
+
const files = await fs.readdir(instructionsSourceDir);
|
|
74
|
+
|
|
75
|
+
let count = 0;
|
|
76
|
+
for (const file of files) {
|
|
77
|
+
if (file.endsWith('.md')) {
|
|
78
|
+
await fs.copy(
|
|
79
|
+
path.join(instructionsSourceDir, file),
|
|
80
|
+
path.join(targetDir, file),
|
|
81
|
+
{ overwrite: options.force }
|
|
82
|
+
);
|
|
83
|
+
count++;
|
|
84
|
+
}
|
|
85
|
+
}
|
|
86
|
+
|
|
87
|
+
spinner.succeed(chalk.green(`⨠Installed ${count} global instruction files!`));
|
|
88
|
+
console.log(chalk.bold('\nš Next Steps:'));
|
|
89
|
+
console.log(` 1. Instructions are now available in ${chalk.cyan('ALL')} your projects.`);
|
|
90
|
+
console.log(` 2. Use ${chalk.yellow('Settings Sync')} in VS Code to sync them across machines.`);
|
|
91
|
+
|
|
92
|
+
} catch (error) {
|
|
93
|
+
spinner.fail(chalk.red('ā Failed to install global instructions'));
|
|
94
|
+
console.error(error);
|
|
95
|
+
}
|
|
96
|
+
}
|
|
97
|
+
|
|
23
98
|
export async function initCommand(directory, options) {
|
|
99
|
+
const templatesDir = path.join(__dirname, '../../templates');
|
|
100
|
+
|
|
101
|
+
if (options.global) {
|
|
102
|
+
return initGlobal(options, templatesDir);
|
|
103
|
+
}
|
|
104
|
+
|
|
24
105
|
const targetDir = directory ? path.resolve(directory) : process.cwd();
|
|
25
106
|
const dirName = path.basename(targetDir);
|
|
26
|
-
const templatesDir = path.join(__dirname, '../../templates');
|
|
27
107
|
|
|
28
108
|
console.log(chalk.bold.cyan('\nš cp-toolkit - GitHub Copilot Agent Toolkit\n'));
|
|
29
109
|
|
|
@@ -1,42 +1,49 @@
|
|
|
1
1
|
---
|
|
2
2
|
name: testing-development
|
|
3
3
|
description: Guidelines for test structure, frameworks, and code coverage best practices.
|
|
4
|
-
version:
|
|
4
|
+
version: 2.0
|
|
5
5
|
applyTo: "**/*.test.*,**/*.spec.*,**/tests/**,**/__tests__/**"
|
|
6
6
|
---
|
|
7
7
|
|
|
8
8
|
# Testing Development Guidelines
|
|
9
9
|
|
|
10
|
-
|
|
11
|
-
|
|
12
|
-
|
|
13
|
-
|
|
14
|
-
-
|
|
15
|
-
-
|
|
16
|
-
|
|
17
|
-
|
|
18
|
-
|
|
19
|
-
-
|
|
20
|
-
|
|
21
|
-
|
|
22
|
-
|
|
23
|
-
|
|
24
|
-
|
|
25
|
-
|
|
26
|
-
|
|
27
|
-
|
|
28
|
-
|
|
29
|
-
|
|
30
|
-
|
|
31
|
-
|
|
32
|
-
|
|
33
|
-
|
|
34
|
-
|
|
35
|
-
|
|
36
|
-
|
|
37
|
-
|
|
38
|
-
-
|
|
39
|
-
-
|
|
40
|
-
-
|
|
41
|
-
|
|
42
|
-
|
|
10
|
+
You are an expert in Software Quality Assurance and Test Automation.
|
|
11
|
+
When writing or analyzing tests in this repository, you MUST follow these directives:
|
|
12
|
+
|
|
13
|
+
## 1. Test Structure & Strategy
|
|
14
|
+
- **Unit Tests**: Isolate individual functions/methods. Mock ALL external dependencies (DB, API, File System).
|
|
15
|
+
- **Integration Tests**: Verify interaction between modules (e.g., API + DB). Use containerized services if possible.
|
|
16
|
+
- **E2E Tests**: Simulate user journeys. Use Playwright/Cypress standards.
|
|
17
|
+
|
|
18
|
+
## 2. The AAA Pattern (Strict Enforcement)
|
|
19
|
+
Every test case MUST follow the **Arrange-Act-Assert** pattern structure explicitly.
|
|
20
|
+
|
|
21
|
+
```javascript
|
|
22
|
+
// ā
CORRECT
|
|
23
|
+
it('should calculate total validation', () => {
|
|
24
|
+
// Arrange
|
|
25
|
+
const input = 10;
|
|
26
|
+
const expected = 20;
|
|
27
|
+
|
|
28
|
+
// Act
|
|
29
|
+
const result = calculate(input);
|
|
30
|
+
|
|
31
|
+
// Assert
|
|
32
|
+
expect(result).toBe(expected);
|
|
33
|
+
});
|
|
34
|
+
```
|
|
35
|
+
|
|
36
|
+
## 3. Naming Conventions
|
|
37
|
+
- **Files**: `*.test.ts` (Unit), `*.spec.ts` (E2E/Integration).
|
|
38
|
+
- **Descriptions**: Use "should [expected behavior] when [condition]".
|
|
39
|
+
- ā `test('login', ...)`
|
|
40
|
+
- ā
`test('should return 401 when token is expired', ...)`
|
|
41
|
+
|
|
42
|
+
## 4. Mocking & Isolation
|
|
43
|
+
- **No side effects**: Tests must be atomic and order-independent.
|
|
44
|
+
- **State reset**: Use `beforeEach`/`afterEach` to clean up state.
|
|
45
|
+
- **External calls**: NEVER rely on real 3rd party APIs in unit tests.
|
|
46
|
+
|
|
47
|
+
## 5. Agent Behavior
|
|
48
|
+
- If the user asks to "fix a bug", **ALWAYS** ask to write a reproduction test case first.
|
|
49
|
+
- If code coverage is low, proactively suggest adding missing test cases for edge conditions.
|