@mdless/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/LICENSE +21 -0
- package/main.ts +118 -0
- package/package.json +26 -0
- package/skills/ci-errors/SKILL.md +29 -0
- package/skills/commit/SKILL.md +27 -0
- package/skills/pr/SKILL.md +22 -0
- package/skills/pr-comments/SKILL.md +26 -0
package/LICENSE
ADDED
|
@@ -0,0 +1,21 @@
|
|
|
1
|
+
MIT License
|
|
2
|
+
|
|
3
|
+
Copyright (c) 2025 mdless
|
|
4
|
+
|
|
5
|
+
Permission is hereby granted, free of charge, to any person obtaining a copy
|
|
6
|
+
of this software and associated documentation files (the "Software"), to deal
|
|
7
|
+
in the Software without restriction, including without limitation the rights
|
|
8
|
+
to use, copy, modify, merge, publish, distribute, sublicense, and/or sell
|
|
9
|
+
copies of the Software, and to permit persons to whom the Software is
|
|
10
|
+
furnished to do so, subject to the following conditions:
|
|
11
|
+
|
|
12
|
+
The above copyright notice and this permission notice shall be included in all
|
|
13
|
+
copies or substantial portions of the Software.
|
|
14
|
+
|
|
15
|
+
THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR
|
|
16
|
+
IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY,
|
|
17
|
+
FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE
|
|
18
|
+
AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER
|
|
19
|
+
LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM,
|
|
20
|
+
OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE
|
|
21
|
+
SOFTWARE.
|
package/main.ts
ADDED
|
@@ -0,0 +1,118 @@
|
|
|
1
|
+
#!/usr/bin/env tsx
|
|
2
|
+
import { checkbox, confirm } from "@inquirer/prompts";
|
|
3
|
+
import {
|
|
4
|
+
cpSync,
|
|
5
|
+
existsSync,
|
|
6
|
+
mkdirSync,
|
|
7
|
+
readdirSync,
|
|
8
|
+
rmSync,
|
|
9
|
+
statSync,
|
|
10
|
+
} from "node:fs";
|
|
11
|
+
import { join } from "node:path";
|
|
12
|
+
|
|
13
|
+
function exit(): never {
|
|
14
|
+
console.log("\nAborted.");
|
|
15
|
+
process.exit(0);
|
|
16
|
+
}
|
|
17
|
+
|
|
18
|
+
function showHelp(): void {
|
|
19
|
+
console.log(`Usage: mdless <command>
|
|
20
|
+
|
|
21
|
+
Commands:
|
|
22
|
+
skills Install or remove Claude Code skills`);
|
|
23
|
+
}
|
|
24
|
+
|
|
25
|
+
async function skillsCommand(): Promise<void> {
|
|
26
|
+
const cwd = process.cwd();
|
|
27
|
+
const claudeDir = join(cwd, ".claude");
|
|
28
|
+
|
|
29
|
+
if (!existsSync(claudeDir)) {
|
|
30
|
+
const shouldCreate = await confirm({
|
|
31
|
+
message: "No .claude folder found. Create one?",
|
|
32
|
+
}).catch((e: Error) => {
|
|
33
|
+
if (e.name === "ExitPromptError") exit();
|
|
34
|
+
throw e;
|
|
35
|
+
});
|
|
36
|
+
|
|
37
|
+
if (!shouldCreate) {
|
|
38
|
+
exit();
|
|
39
|
+
}
|
|
40
|
+
|
|
41
|
+
mkdirSync(claudeDir);
|
|
42
|
+
console.log("✓ Created .claude folder.");
|
|
43
|
+
}
|
|
44
|
+
|
|
45
|
+
const skillsDir = join(import.meta.dirname!, "skills");
|
|
46
|
+
const skills = readdirSync(skillsDir).filter((name) =>
|
|
47
|
+
statSync(join(skillsDir, name)).isDirectory(),
|
|
48
|
+
);
|
|
49
|
+
|
|
50
|
+
const destSkillsDir = join(claudeDir, "skills");
|
|
51
|
+
|
|
52
|
+
function isInstalled(skill: string): boolean {
|
|
53
|
+
return existsSync(join(destSkillsDir, skill));
|
|
54
|
+
}
|
|
55
|
+
|
|
56
|
+
const selected = await checkbox({
|
|
57
|
+
message: "Select skills to install:",
|
|
58
|
+
choices: skills.map((skill) => ({
|
|
59
|
+
name: skill,
|
|
60
|
+
value: skill,
|
|
61
|
+
checked: isInstalled(skill),
|
|
62
|
+
})),
|
|
63
|
+
}).catch((e: Error) => {
|
|
64
|
+
if (e.name === "ExitPromptError") exit();
|
|
65
|
+
throw e;
|
|
66
|
+
});
|
|
67
|
+
|
|
68
|
+
const installed: string[] = [];
|
|
69
|
+
const removed: string[] = [];
|
|
70
|
+
|
|
71
|
+
for (const skill of skills) {
|
|
72
|
+
const src = join(skillsDir, skill);
|
|
73
|
+
const dest = join(destSkillsDir, skill);
|
|
74
|
+
const wasInstalled = isInstalled(skill);
|
|
75
|
+
const shouldBeInstalled = selected.includes(skill);
|
|
76
|
+
|
|
77
|
+
if (shouldBeInstalled && !wasInstalled) {
|
|
78
|
+
cpSync(src, dest, { recursive: true });
|
|
79
|
+
installed.push(skill);
|
|
80
|
+
} else if (!shouldBeInstalled && wasInstalled) {
|
|
81
|
+
rmSync(dest, { recursive: true });
|
|
82
|
+
removed.push(skill);
|
|
83
|
+
}
|
|
84
|
+
}
|
|
85
|
+
|
|
86
|
+
if (installed.length > 0 || removed.length > 0) {
|
|
87
|
+
console.log("✓ Changes applied.");
|
|
88
|
+
}
|
|
89
|
+
|
|
90
|
+
const finalSkills = existsSync(destSkillsDir)
|
|
91
|
+
? readdirSync(destSkillsDir).filter((name) =>
|
|
92
|
+
statSync(join(destSkillsDir, name)).isDirectory(),
|
|
93
|
+
)
|
|
94
|
+
: [];
|
|
95
|
+
|
|
96
|
+
if (finalSkills.length > 0) {
|
|
97
|
+
console.log(`\nInstalled skills: ${finalSkills.join(", ")}`);
|
|
98
|
+
} else {
|
|
99
|
+
console.log("\nNo skills installed.");
|
|
100
|
+
}
|
|
101
|
+
}
|
|
102
|
+
|
|
103
|
+
const [command] = process.argv.slice(2);
|
|
104
|
+
|
|
105
|
+
switch (command) {
|
|
106
|
+
case "skills":
|
|
107
|
+
await skillsCommand();
|
|
108
|
+
break;
|
|
109
|
+
case undefined:
|
|
110
|
+
case "-h":
|
|
111
|
+
case "--help":
|
|
112
|
+
showHelp();
|
|
113
|
+
break;
|
|
114
|
+
default:
|
|
115
|
+
console.error(`Unknown command: ${command}`);
|
|
116
|
+
showHelp();
|
|
117
|
+
process.exit(1);
|
|
118
|
+
}
|
package/package.json
ADDED
|
@@ -0,0 +1,26 @@
|
|
|
1
|
+
{
|
|
2
|
+
"name": "@mdless/cli",
|
|
3
|
+
"version": "1.0.0",
|
|
4
|
+
"description": "Interactive skill selector CLI",
|
|
5
|
+
"type": "module",
|
|
6
|
+
"bin": {
|
|
7
|
+
"mdless": "./main.ts"
|
|
8
|
+
},
|
|
9
|
+
"files": [
|
|
10
|
+
"main.ts",
|
|
11
|
+
"skills/"
|
|
12
|
+
],
|
|
13
|
+
"keywords": [
|
|
14
|
+
"cli",
|
|
15
|
+
"interactive",
|
|
16
|
+
"prompt"
|
|
17
|
+
],
|
|
18
|
+
"license": "MIT",
|
|
19
|
+
"dependencies": {
|
|
20
|
+
"@inquirer/prompts": "^8.2.0",
|
|
21
|
+
"tsx": "^4.7.0"
|
|
22
|
+
},
|
|
23
|
+
"devDependencies": {
|
|
24
|
+
"@types/bun": "^1.3.8"
|
|
25
|
+
}
|
|
26
|
+
}
|
|
@@ -0,0 +1,29 @@
|
|
|
1
|
+
---
|
|
2
|
+
name: ci-errors
|
|
3
|
+
description: Fetch failing CI logs for the current PR, analyze errors, and fix them
|
|
4
|
+
allowed-tools: Bash(gh:*), Bash(git:*), Read, Grep, Glob, Edit
|
|
5
|
+
argument-hint: [optional: specific check name to focus on]
|
|
6
|
+
---
|
|
7
|
+
|
|
8
|
+
# CI Errors
|
|
9
|
+
|
|
10
|
+
Fetch failing CI logs for the current PR, analyze the errors, and fix them.
|
|
11
|
+
|
|
12
|
+
## Instructions
|
|
13
|
+
|
|
14
|
+
1. Run `gh pr view --json number,title,headRefName` to confirm there is an open PR. If not, stop.
|
|
15
|
+
|
|
16
|
+
2. Get failing checks:
|
|
17
|
+
```bash
|
|
18
|
+
gh pr checks --json name,bucket,link,state --jq '[.[] | select(.bucket == "fail")]'
|
|
19
|
+
```
|
|
20
|
+
If no checks are failing, tell the user and stop. Filter by $ARGUMENTS if provided.
|
|
21
|
+
|
|
22
|
+
3. Extract `run_id` and `job_id` from each failing check link (format: `.../actions/runs/<run_id>/job/<job_id>`).
|
|
23
|
+
Fetch logs with `gh run view <run_id> --log-failed`. Fall back to annotations if unavailable.
|
|
24
|
+
|
|
25
|
+
4. Categorize each failure (test, lint/type, build, or other) and identify the root cause.
|
|
26
|
+
|
|
27
|
+
5. Fix each error: read the source, apply the fix, explain what changed.
|
|
28
|
+
|
|
29
|
+
6. Summarize what was fixed and suggest the user re-run CI.
|
|
@@ -0,0 +1,27 @@
|
|
|
1
|
+
---
|
|
2
|
+
name: commit
|
|
3
|
+
description: Stage and commit changes with a conventional commit message
|
|
4
|
+
allowed-tools: Bash(git:*)
|
|
5
|
+
argument-hint: [optional: what to commit]
|
|
6
|
+
---
|
|
7
|
+
|
|
8
|
+
# Commit
|
|
9
|
+
|
|
10
|
+
Stage and commit changes using conventional commit messages.
|
|
11
|
+
|
|
12
|
+
## Instructions
|
|
13
|
+
|
|
14
|
+
1. Check `git status --short` to see what changes exist
|
|
15
|
+
2. Stage relevant files for commit
|
|
16
|
+
3. Verify nothing is staged that shouldn't be
|
|
17
|
+
4. Create a commit using conventional format: `<type>: <description>`
|
|
18
|
+
|
|
19
|
+
Only push the commit if specifically instructed to do so.
|
|
20
|
+
|
|
21
|
+
## Conventional Commit Types
|
|
22
|
+
|
|
23
|
+
`feat` | `fix` | `docs` | `style` | `refactor` | `perf` | `test` | `chore` | `ci`
|
|
24
|
+
|
|
25
|
+
Description: short summary (50 chars or less), lowercase, no period.
|
|
26
|
+
|
|
27
|
+
Use $ARGUMENTS as guidance for what to commit. If not provided, commit all unstaged changes.
|
|
@@ -0,0 +1,22 @@
|
|
|
1
|
+
---
|
|
2
|
+
name: pr
|
|
3
|
+
description: Commit changes, push, and create/update a pull request
|
|
4
|
+
allowed-tools: Bash(git:*), Bash(gh:*), Read, Edit
|
|
5
|
+
argument-hint: [optional: branch/commit message guidance]
|
|
6
|
+
---
|
|
7
|
+
|
|
8
|
+
# Create PR
|
|
9
|
+
|
|
10
|
+
Commit changes, push, and create/update a pull request.
|
|
11
|
+
|
|
12
|
+
## Instructions
|
|
13
|
+
|
|
14
|
+
1. Check `git status` and current branch
|
|
15
|
+
2. If on main/master, create a feature branch. Otherwise stay on current branch.
|
|
16
|
+
3. Stage and commit changes using conventional commit format
|
|
17
|
+
4. Push to origin (use `-u` if branch is new)
|
|
18
|
+
5. Check if PR exists with `gh pr view`
|
|
19
|
+
6. If no PR, create one with `gh pr create` (include a summary of the changes)
|
|
20
|
+
7. Open in browser with `gh pr view --web`
|
|
21
|
+
|
|
22
|
+
Use $ARGUMENTS as guidance for branch name and commit message.
|
|
@@ -0,0 +1,26 @@
|
|
|
1
|
+
---
|
|
2
|
+
name: pr-comments
|
|
3
|
+
description: Review and respond to PR comments
|
|
4
|
+
allowed-tools: Bash(gh:*), Bash(git:*), Read, Edit
|
|
5
|
+
argument-hint: [optional: e.g. "reply to antoine saying we should add tests"]
|
|
6
|
+
---
|
|
7
|
+
|
|
8
|
+
# PR Comments
|
|
9
|
+
|
|
10
|
+
Review and respond to comments on a pull request.
|
|
11
|
+
|
|
12
|
+
## Instructions
|
|
13
|
+
|
|
14
|
+
1. Get the PR number: `gh pr view --json number -q .number`
|
|
15
|
+
|
|
16
|
+
2. Fetch review comments using `gh api` for the current PR
|
|
17
|
+
|
|
18
|
+
3. For each comment, show: file, line, author, body. Then suggest either:
|
|
19
|
+
- A code fix (if requesting a change)
|
|
20
|
+
- A reply (if it's a question/discussion)
|
|
21
|
+
|
|
22
|
+
4. Ask the user what to do: apply fix, reply, skip, or custom action
|
|
23
|
+
|
|
24
|
+
5. Execute: for fixes, edit/commit/push. For replies, post via `gh api`.
|
|
25
|
+
|
|
26
|
+
Use $ARGUMENTS to guide actions (e.g., "fix all issues" or "reply to antoine").
|