aicoding-rules 0.1.0 → 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.
- package/bin/cli.js +13 -3
- package/package.json +1 -1
- package/src/config.js +11 -0
- package/src/download.js +45 -0
- package/src/interactive.js +72 -1
package/bin/cli.js
CHANGED
|
@@ -2,8 +2,8 @@
|
|
|
2
2
|
|
|
3
3
|
import { Command } from "commander";
|
|
4
4
|
import { loadConfig, getRuleKeys } from "../src/config.js";
|
|
5
|
-
import { downloadAndExtract, downloadMultiple } from "../src/download.js";
|
|
6
|
-
import { selectRules } from "../src/interactive.js";
|
|
5
|
+
import { downloadAndExtract, downloadMultiple, downloadMultipleSkills } from "../src/download.js";
|
|
6
|
+
import { selectRules, selectSkills } from "../src/interactive.js";
|
|
7
7
|
|
|
8
8
|
const config = loadConfig();
|
|
9
9
|
const targetDir = process.cwd();
|
|
@@ -12,7 +12,7 @@ const program = new Command();
|
|
|
12
12
|
|
|
13
13
|
program
|
|
14
14
|
.name("aicoding-rules")
|
|
15
|
-
.description("Download and install AI coding rules for Cursor, Claude, Antigravity, and Copilot")
|
|
15
|
+
.description("Download and install AI coding rules and skills for Cursor, Claude, Antigravity, and Copilot")
|
|
16
16
|
.version("1.0.0");
|
|
17
17
|
|
|
18
18
|
program
|
|
@@ -51,6 +51,16 @@ program
|
|
|
51
51
|
await downloadMultiple(config, allKeys, targetDir);
|
|
52
52
|
});
|
|
53
53
|
|
|
54
|
+
program
|
|
55
|
+
.command("skills")
|
|
56
|
+
.description("Install AI coding skills (interactive selection)")
|
|
57
|
+
.action(async () => {
|
|
58
|
+
const { selectedSkills, targetDir: skillsDir } = await selectSkills(config);
|
|
59
|
+
if (selectedSkills.length > 0) {
|
|
60
|
+
await downloadMultipleSkills(config, selectedSkills, skillsDir);
|
|
61
|
+
}
|
|
62
|
+
});
|
|
63
|
+
|
|
54
64
|
program
|
|
55
65
|
.action(async () => {
|
|
56
66
|
const selectedKeys = await selectRules(config);
|
package/package.json
CHANGED
package/src/config.js
CHANGED
|
@@ -12,6 +12,9 @@ const DEFAULT_CONFIG = {
|
|
|
12
12
|
claude: { fileOid: "68872b563e3eb464f2214263", name: "Claude rules" },
|
|
13
13
|
antigravity: { fileOid: "69202dcfacf31067955cfc1c", name: "Antigravity rules" },
|
|
14
14
|
copilot: { fileOid: "67eab73e899a1711f6cc106f", name: "Copilot prompts" }
|
|
15
|
+
},
|
|
16
|
+
skills: {
|
|
17
|
+
uu_skills: { fileOid: "69786bfc45c7ce292846341e", name: "UU Skills" }
|
|
15
18
|
}
|
|
16
19
|
};
|
|
17
20
|
|
|
@@ -50,3 +53,11 @@ export function getRuleKeys(config) {
|
|
|
50
53
|
export function getRule(config, key) {
|
|
51
54
|
return config.rules[key];
|
|
52
55
|
}
|
|
56
|
+
|
|
57
|
+
export function getSkillKeys(config) {
|
|
58
|
+
return Object.keys(config.skills || {});
|
|
59
|
+
}
|
|
60
|
+
|
|
61
|
+
export function getSkill(config, key) {
|
|
62
|
+
return config.skills?.[key];
|
|
63
|
+
}
|
package/src/download.js
CHANGED
|
@@ -1,4 +1,5 @@
|
|
|
1
1
|
import AdmZip from "adm-zip";
|
|
2
|
+
import { mkdirSync } from "fs";
|
|
2
3
|
import { getAuthenticatedClient } from "./auth.js";
|
|
3
4
|
|
|
4
5
|
function extractZipBuffer(buffer, outputPath) {
|
|
@@ -6,6 +7,10 @@ function extractZipBuffer(buffer, outputPath) {
|
|
|
6
7
|
zip.extractAllTo(outputPath, true);
|
|
7
8
|
}
|
|
8
9
|
|
|
10
|
+
function ensureDir(dirPath) {
|
|
11
|
+
mkdirSync(dirPath, { recursive: true });
|
|
12
|
+
}
|
|
13
|
+
|
|
9
14
|
export async function downloadAndExtract(config, ruleKey, targetDir) {
|
|
10
15
|
const rule = config.rules[ruleKey];
|
|
11
16
|
if (!rule) {
|
|
@@ -38,3 +43,43 @@ export async function downloadMultiple(config, ruleKeys, targetDir) {
|
|
|
38
43
|
await downloadAndExtract(config, key, targetDir);
|
|
39
44
|
}
|
|
40
45
|
}
|
|
46
|
+
|
|
47
|
+
export async function downloadSkill(config, skillKey, targetDir) {
|
|
48
|
+
const skill = config.skills?.[skillKey];
|
|
49
|
+
if (!skill) {
|
|
50
|
+
throw new Error(`Unknown skill: ${skillKey}`);
|
|
51
|
+
}
|
|
52
|
+
|
|
53
|
+
if (!skill.fileOid) {
|
|
54
|
+
throw new Error(`Skill ${skillKey} has no fileOid configured. Please update your config.`);
|
|
55
|
+
}
|
|
56
|
+
|
|
57
|
+
const appClient = await getAuthenticatedClient();
|
|
58
|
+
|
|
59
|
+
const url = `${config.baseUrl}/document/ebc/file/getDataByOid?oid=${config.documentOid}&uuEbcData.fileOid=${skill.fileOid}`;
|
|
60
|
+
|
|
61
|
+
console.log(`Downloading ${skill.name}...`);
|
|
62
|
+
|
|
63
|
+
const response = await appClient.exchange(
|
|
64
|
+
url,
|
|
65
|
+
"get",
|
|
66
|
+
{},
|
|
67
|
+
{},
|
|
68
|
+
0,
|
|
69
|
+
{ responseType: "buffer" }
|
|
70
|
+
);
|
|
71
|
+
|
|
72
|
+
ensureDir(targetDir);
|
|
73
|
+
|
|
74
|
+
const attachmentBuffer = response.body;
|
|
75
|
+
extractZipBuffer(attachmentBuffer, targetDir);
|
|
76
|
+
|
|
77
|
+
console.log(`${skill.name} installed to ${targetDir}`);
|
|
78
|
+
}
|
|
79
|
+
|
|
80
|
+
export async function downloadMultipleSkills(config, skillKeys, targetDir) {
|
|
81
|
+
ensureDir(targetDir);
|
|
82
|
+
for (const key of skillKeys) {
|
|
83
|
+
await downloadSkill(config, key, targetDir);
|
|
84
|
+
}
|
|
85
|
+
}
|
package/src/interactive.js
CHANGED
|
@@ -1,5 +1,7 @@
|
|
|
1
1
|
import inquirer from "inquirer";
|
|
2
|
-
import {
|
|
2
|
+
import { homedir } from "os";
|
|
3
|
+
import { join } from "path";
|
|
4
|
+
import { getRuleKeys, getRule, getSkillKeys, getSkill } from "./config.js";
|
|
3
5
|
|
|
4
6
|
export async function selectRules(config) {
|
|
5
7
|
const ruleKeys = getRuleKeys(config);
|
|
@@ -26,3 +28,72 @@ export async function selectRules(config) {
|
|
|
26
28
|
|
|
27
29
|
return selectedRules;
|
|
28
30
|
}
|
|
31
|
+
|
|
32
|
+
export async function selectSkills(config) {
|
|
33
|
+
const skillKeys = getSkillKeys(config);
|
|
34
|
+
|
|
35
|
+
if (skillKeys.length === 0) {
|
|
36
|
+
console.log("No skills available in configuration.");
|
|
37
|
+
return { selectedSkills: [], targetDir: null };
|
|
38
|
+
}
|
|
39
|
+
|
|
40
|
+
const choices = skillKeys.map(key => ({
|
|
41
|
+
name: getSkill(config, key).name,
|
|
42
|
+
value: key
|
|
43
|
+
}));
|
|
44
|
+
|
|
45
|
+
const { selectedSkills } = await inquirer.prompt([
|
|
46
|
+
{
|
|
47
|
+
type: "checkbox",
|
|
48
|
+
name: "selectedSkills",
|
|
49
|
+
message: "Select skills to install:",
|
|
50
|
+
choices,
|
|
51
|
+
validate: (answer) => {
|
|
52
|
+
if (answer.length === 0) {
|
|
53
|
+
return "You must select at least one skill.";
|
|
54
|
+
}
|
|
55
|
+
return true;
|
|
56
|
+
}
|
|
57
|
+
}
|
|
58
|
+
]);
|
|
59
|
+
|
|
60
|
+
const targetDir = await selectSkillsLocation();
|
|
61
|
+
|
|
62
|
+
return { selectedSkills, targetDir };
|
|
63
|
+
}
|
|
64
|
+
|
|
65
|
+
export async function selectSkillsLocation() {
|
|
66
|
+
const { location } = await inquirer.prompt([
|
|
67
|
+
{
|
|
68
|
+
type: "list",
|
|
69
|
+
name: "location",
|
|
70
|
+
message: "Where do you want to extract the skills?",
|
|
71
|
+
choices: [
|
|
72
|
+
{ name: "~/.claude/skills (Claude global skills)", value: "claude-global" },
|
|
73
|
+
{ name: "~/.cursor/skills (Cursor global skills)", value: "cursor-global" },
|
|
74
|
+
{ name: "Current directory - .claude/skills", value: "claude-local" },
|
|
75
|
+
{ name: "Current directory - .cursor/skills", value: "cursor-local" }
|
|
76
|
+
]
|
|
77
|
+
}
|
|
78
|
+
]);
|
|
79
|
+
|
|
80
|
+
return resolveSkillsPath(location);
|
|
81
|
+
}
|
|
82
|
+
|
|
83
|
+
function resolveSkillsPath(location) {
|
|
84
|
+
const cwd = process.cwd();
|
|
85
|
+
const home = homedir();
|
|
86
|
+
|
|
87
|
+
switch (location) {
|
|
88
|
+
case "claude-global":
|
|
89
|
+
return join(home, ".claude", "skills");
|
|
90
|
+
case "cursor-global":
|
|
91
|
+
return join(home, ".cursor", "skills");
|
|
92
|
+
case "claude-local":
|
|
93
|
+
return join(cwd, ".claude", "skills");
|
|
94
|
+
case "cursor-local":
|
|
95
|
+
return join(cwd, ".cursor", "skills");
|
|
96
|
+
default:
|
|
97
|
+
return cwd;
|
|
98
|
+
}
|
|
99
|
+
}
|