bitcompass 0.2.8 → 0.2.9
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/dist/commands/rules.d.ts +3 -1
- package/dist/commands/rules.js +15 -3
- package/dist/commands/solutions.d.ts +3 -1
- package/dist/commands/solutions.js +15 -3
- package/dist/index.js +10 -2
- package/package.json +1 -1
package/dist/commands/rules.d.ts
CHANGED
|
@@ -1,4 +1,6 @@
|
|
|
1
1
|
export declare const runRulesSearch: (query?: string) => Promise<void>;
|
|
2
2
|
export declare const runRulesList: () => Promise<void>;
|
|
3
|
-
export declare const runRulesPull: (id?: string
|
|
3
|
+
export declare const runRulesPull: (id?: string, options?: {
|
|
4
|
+
global?: boolean;
|
|
5
|
+
}) => Promise<void>;
|
|
4
6
|
export declare const runRulesPush: (file?: string) => Promise<void>;
|
package/dist/commands/rules.js
CHANGED
|
@@ -3,6 +3,7 @@ import ora from 'ora';
|
|
|
3
3
|
import chalk from 'chalk';
|
|
4
4
|
import { mkdirSync, writeFileSync } from 'fs';
|
|
5
5
|
import { join } from 'path';
|
|
6
|
+
import { homedir } from 'os';
|
|
6
7
|
import { loadCredentials } from '../auth/config.js';
|
|
7
8
|
import { getProjectConfig } from '../auth/project-config.js';
|
|
8
9
|
import { searchRules, fetchRules, getRuleById, insertRule } from '../api/client.js';
|
|
@@ -46,7 +47,7 @@ export const runRulesList = async () => {
|
|
|
46
47
|
if (list.length === 0)
|
|
47
48
|
console.log(chalk.yellow('No rules yet.'));
|
|
48
49
|
};
|
|
49
|
-
export const runRulesPull = async (id) => {
|
|
50
|
+
export const runRulesPull = async (id, options) => {
|
|
50
51
|
if (!loadCredentials()) {
|
|
51
52
|
console.error(chalk.red('Not logged in. Run bitcompass login.'));
|
|
52
53
|
process.exit(1);
|
|
@@ -70,13 +71,24 @@ export const runRulesPull = async (id) => {
|
|
|
70
71
|
console.error(chalk.red('Rule not found.'));
|
|
71
72
|
process.exit(1);
|
|
72
73
|
}
|
|
73
|
-
|
|
74
|
-
|
|
74
|
+
let outDir;
|
|
75
|
+
if (options?.global) {
|
|
76
|
+
// Use global location: ~/.cursor/rules/
|
|
77
|
+
outDir = join(homedir(), '.cursor', 'rules');
|
|
78
|
+
}
|
|
79
|
+
else {
|
|
80
|
+
// Use project config (default behavior)
|
|
81
|
+
const { outputPath } = getProjectConfig({ warnIfMissing: true });
|
|
82
|
+
outDir = join(process.cwd(), outputPath);
|
|
83
|
+
}
|
|
75
84
|
mkdirSync(outDir, { recursive: true });
|
|
76
85
|
const filename = join(outDir, ruleFilename(rule.title, rule.id));
|
|
77
86
|
const content = `# ${rule.title}\n\n${rule.description}\n\n${rule.body}\n`;
|
|
78
87
|
writeFileSync(filename, content);
|
|
79
88
|
console.log(chalk.green('Wrote'), filename);
|
|
89
|
+
if (options?.global) {
|
|
90
|
+
console.log(chalk.dim('Installed globally for all projects'));
|
|
91
|
+
}
|
|
80
92
|
};
|
|
81
93
|
export const runRulesPush = async (file) => {
|
|
82
94
|
if (!loadCredentials()) {
|
|
@@ -1,3 +1,5 @@
|
|
|
1
1
|
export declare const runSolutionsSearch: (query?: string) => Promise<void>;
|
|
2
|
-
export declare const runSolutionsPull: (id?: string
|
|
2
|
+
export declare const runSolutionsPull: (id?: string, options?: {
|
|
3
|
+
global?: boolean;
|
|
4
|
+
}) => Promise<void>;
|
|
3
5
|
export declare const runSolutionsPush: (file?: string) => Promise<void>;
|
|
@@ -3,6 +3,7 @@ import ora from 'ora';
|
|
|
3
3
|
import chalk from 'chalk';
|
|
4
4
|
import { mkdirSync, writeFileSync } from 'fs';
|
|
5
5
|
import { join } from 'path';
|
|
6
|
+
import { homedir } from 'os';
|
|
6
7
|
import { loadCredentials } from '../auth/config.js';
|
|
7
8
|
import { getProjectConfig } from '../auth/project-config.js';
|
|
8
9
|
import { searchRules, fetchRules, getRuleById, insertRule } from '../api/client.js';
|
|
@@ -34,7 +35,7 @@ export const runSolutionsSearch = async (query) => {
|
|
|
34
35
|
console.log(rule.body);
|
|
35
36
|
}
|
|
36
37
|
};
|
|
37
|
-
export const runSolutionsPull = async (id) => {
|
|
38
|
+
export const runSolutionsPull = async (id, options) => {
|
|
38
39
|
if (!loadCredentials()) {
|
|
39
40
|
console.error(chalk.red('Not logged in. Run bitcompass login.'));
|
|
40
41
|
process.exit(1);
|
|
@@ -58,13 +59,24 @@ export const runSolutionsPull = async (id) => {
|
|
|
58
59
|
console.error(chalk.red('Solution not found.'));
|
|
59
60
|
process.exit(1);
|
|
60
61
|
}
|
|
61
|
-
|
|
62
|
-
|
|
62
|
+
let outDir;
|
|
63
|
+
if (options?.global) {
|
|
64
|
+
// Use global location: ~/.cursor/rules/
|
|
65
|
+
outDir = join(homedir(), '.cursor', 'rules');
|
|
66
|
+
}
|
|
67
|
+
else {
|
|
68
|
+
// Use project config (default behavior)
|
|
69
|
+
const { outputPath } = getProjectConfig({ warnIfMissing: true });
|
|
70
|
+
outDir = join(process.cwd(), outputPath);
|
|
71
|
+
}
|
|
63
72
|
mkdirSync(outDir, { recursive: true });
|
|
64
73
|
const filename = join(outDir, solutionFilename(rule.title, rule.id));
|
|
65
74
|
const content = `# ${rule.title}\n\n${rule.description}\n\n## Solution\n\n${rule.body}\n`;
|
|
66
75
|
writeFileSync(filename, content);
|
|
67
76
|
console.log(chalk.green('Wrote'), filename);
|
|
77
|
+
if (options?.global) {
|
|
78
|
+
console.log(chalk.dim('Installed globally for all projects'));
|
|
79
|
+
}
|
|
68
80
|
};
|
|
69
81
|
export const runSolutionsPush = async (file) => {
|
|
70
82
|
if (!loadCredentials()) {
|
package/dist/index.js
CHANGED
|
@@ -45,12 +45,20 @@ configCmd.command('get <key>').description('Get a config value').action((key) =>
|
|
|
45
45
|
const rules = program.command('rules').description('Manage rules');
|
|
46
46
|
rules.command('search [query]').description('Search rules').action((query) => runRulesSearch(query).catch(handleErr));
|
|
47
47
|
rules.command('list').description('List rules').action(() => runRulesList().catch(handleErr));
|
|
48
|
-
rules
|
|
48
|
+
rules
|
|
49
|
+
.command('pull [id]')
|
|
50
|
+
.description('Pull a rule by ID or choose from list')
|
|
51
|
+
.option('-g, --global', 'Install globally to ~/.cursor/rules/ for all projects')
|
|
52
|
+
.action((id, options) => runRulesPull(id, options).catch(handleErr));
|
|
49
53
|
rules.command('push [file]').description('Push a rule (file or interactive)').action((file) => runRulesPush(file).catch(handleErr));
|
|
50
54
|
// solutions
|
|
51
55
|
const solutions = program.command('solutions').description('Manage solutions');
|
|
52
56
|
solutions.command('search [query]').description('Search solutions').action((query) => runSolutionsSearch(query).catch(handleErr));
|
|
53
|
-
solutions
|
|
57
|
+
solutions
|
|
58
|
+
.command('pull [id]')
|
|
59
|
+
.description('Pull a solution by ID or choose from list')
|
|
60
|
+
.option('-g, --global', 'Install globally to ~/.cursor/rules/ for all projects')
|
|
61
|
+
.action((id, options) => runSolutionsPull(id, options).catch(handleErr));
|
|
54
62
|
solutions.command('push [file]').description('Push a solution (file or interactive)').action((file) => runSolutionsPush(file).catch(handleErr));
|
|
55
63
|
// mcp
|
|
56
64
|
const mcp = program.command('mcp').description('MCP server');
|