@mdless/cli 1.1.0 → 1.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/README.md CHANGED
@@ -4,21 +4,7 @@
4
4
 
5
5
  **Mind less, ship more.**
6
6
 
7
- You know that feeling when you craft the perfect Claude Code skill, and then you need it in another project? Or when your teammate asks "how did you make Claude do that?"
8
-
9
- Yeah, we're tired of that too.
10
-
11
- ## 🤔 Why "mdless"?
12
-
13
- Two reasons:
14
-
15
- 1. Write less markdown. Skills are maintained by the community, so you don't have to craft every SKILL.md from scratch.
16
-
17
- 2. Mind less - stop overthinking - and just ship that shit out.
18
-
19
- Mdless lets you share your superpowers across projects and teams. Skills live in your repo, not on your machine—so your whole team gets to be a superhero.
20
-
21
- No more "it works on my Claude." No more copy-pasting skills between repos. No more explaining to Eddy how to set up his `.claude` folder for the fifth time.
7
+ Run custom Claude Code agent loops from markdown prompts in your repo.
22
8
 
23
9
  ## 📦 Installation
24
10
 
@@ -36,28 +22,29 @@ npm install -g @mdless/cli
36
22
 
37
23
  ## 📋 Key Features
38
24
 
39
- #### Share skills across projects
25
+ #### Set up agent prompts
40
26
 
41
27
  ```bash
42
- mdless skills
28
+ mdless init
43
29
  ```
44
30
 
45
- | Skill | What it does |
46
- | ---------------------------------------------- | ------------------------------------------------- |
47
- | [**commit**](skills/commit/SKILL.md) | Writes commit messages so you don't have to think |
48
- | [**pr**](skills/pr/SKILL.md) | Creates PRs with actual descriptions |
49
- | [**pr-comments**](skills/pr-comments/SKILL.md) | Responds to PR comments (politely) |
50
- | [**ci-errors**](skills/ci-errors/SKILL.md) | Reads CI logs and fixes the errors |
31
+ Copies default prompts into `.mdless/agents/`. Edit them to match your project.
51
32
 
52
- That's it. Pick the skills you want, hit enter, go back to shipping.
33
+ #### Run agents in tmux
53
34
 
54
- The CLI will:
35
+ ```bash
36
+ mdless work
37
+ ```
38
+
39
+ Launches every prompt in `.mdless/agents/` as a looping agent in a tmux session.
55
40
 
56
- 1. Create `.claude/skills/` if it doesn't exist (you're welcome, Eddy)
57
- 2. Show you a list of available skills
58
- 3. Install the ones you pick (remove the ones you don't)
41
+ #### Run a single agent
42
+
43
+ ```bash
44
+ mdless agent <name>
45
+ ```
59
46
 
60
- Commit the skills to your repo. Now everyone on your team has them. Revolutionary, we know.
47
+ Runs one agent on repeat using `.mdless/agents/<name>.md`.
61
48
 
62
49
  ## 📄 License
63
50
 
package/package.json CHANGED
@@ -1,7 +1,7 @@
1
1
  {
2
2
  "name": "@mdless/cli",
3
- "version": "1.1.0",
4
- "description": "Mind less, ship more. Share Claude Code skills across projects and teams.",
3
+ "version": "1.2.0",
4
+ "description": "Mind less, ship more. Agent loops for Claude Code projects.",
5
5
  "type": "module",
6
6
  "bin": {
7
7
  "mdless": "bin.mjs"
@@ -9,7 +9,6 @@
9
9
  "files": [
10
10
  "bin.mjs",
11
11
  "src/",
12
- "skills/",
13
12
  "assets/"
14
13
  ],
15
14
  "keywords": [
@@ -1,4 +1,4 @@
1
- # Watcher Agent
1
+ # Curator Agent
2
2
 
3
3
  You scan this project for problems and file GitHub issues so other agents can pick them up.
4
4
 
@@ -10,13 +10,7 @@ You never edit code or create PRs. Only issues.
10
10
 
11
11
  Scan these in order. If any command fails (tool not installed, no auth), log it once and move on — don't retry in the same iteration.
12
12
 
13
- ### 1. Sentry — unresolved issues
14
-
15
- ```sh
16
- sentry-cli issues list --status unresolved
17
- ```
18
-
19
- ### 2. TODO / FIXME comments
13
+ ### 1. TODO / FIXME comments
20
14
 
21
15
  ```sh
22
16
  git grep -nE "TODO|FIXME" -- ':!*.md' ':!.mdless'
@@ -24,7 +18,7 @@ git grep -nE "TODO|FIXME" -- ':!*.md' ':!.mdless'
24
18
 
25
19
  Only flag things that look actionable. Skip example/doc style comments.
26
20
 
27
- ### 3. Dependency vulnerabilities
21
+ ### 2. Dependency vulnerabilities
28
22
 
29
23
  Pick the audit command matching the project's lockfile:
30
24
 
@@ -52,7 +46,6 @@ Each source has a unique id format embedded in the issue body:
52
46
 
53
47
  | Source | Source-ID line |
54
48
  | ------ | --------------------------------------- |
55
- | Sentry | `Sentry-ID: <id>` |
56
49
  | TODO | `Source-Ref: <file>:<line>` |
57
50
  | CVE | `CVE: <cve-id>` or `Advisory: <ghsa-id>` |
58
51
 
@@ -67,12 +60,11 @@ gh issue create --label mdless/work --title "..." --body "..."
67
60
  Title: concise and action-oriented.
68
61
  Good: `Fix null deref in PaymentProcessor.charge`
69
62
  Good: `Upgrade lodash to patch CVE-2024-XXXXX`
70
- Bad: `Sentry issue ABC-456`
71
63
 
72
64
  Body: start with metadata, then a separator, then details.
73
65
 
74
66
  ```
75
- Source: sentry | todo | cve
67
+ Source: todo | cve
76
68
  <Source-ID line>
77
69
  ---
78
70
  <problem description, affected files/area, repro details>
@@ -80,8 +72,8 @@ Source: sentry | todo | cve
80
72
 
81
73
  ### Step 3 — Log one line
82
74
 
83
- - `created #123 sentry ABC-456`
84
- - `skip todo src/foo.ts:42 (already #98)`
75
+ - `created #123 todo src/foo.ts:42`
76
+ - `skip todo src/bar.ts:10 (already #98)`
85
77
 
86
78
  ---
87
79
 
@@ -1,4 +1,4 @@
1
- # Executor Agent
1
+ # Developer Agent
2
2
 
3
3
  You implement fixes for work tracked in GitHub. You have two phases per invocation: Phase 1: Follow-up and Phase 2: New work.
4
4
 
@@ -1,6 +1,6 @@
1
1
  # Reviewer Agent
2
2
 
3
- You review pull requests created by the executor. You either approve them (via a label) or leave actionable inline comments.
3
+ You review pull requests created by the developer agent. You either approve them (via a label) or leave actionable inline comments.
4
4
 
5
5
  Do one PR per invocation, then exit. The wrapper sleeps and re-invokes you.
6
6
 
@@ -2,12 +2,7 @@ import { spawn } from "node:child_process";
2
2
  import { existsSync, mkdirSync, readFileSync, createWriteStream } from "node:fs";
3
3
  import { join } from "node:path";
4
4
 
5
- const DEFAULT_SLEEP_SECONDS: Record<string, number> = {
6
- watcher: 300,
7
- executor: 60,
8
- reviewer: 120,
9
- };
10
- const FALLBACK_SLEEP_SECONDS = 60;
5
+ const SLEEP_SECONDS = 60;
11
6
 
12
7
  function timestamp(): string {
13
8
  const d = new Date();
@@ -52,20 +47,12 @@ const TOOL_COLORS: Record<string, string> = {
52
47
  Task: MAGENTA_PURPLE,
53
48
  };
54
49
 
55
- const AGENT_COLORS: Record<string, string> = {
56
- watcher: LAVENDER,
57
- executor: VIOLET,
58
- reviewer: MAGENTA_PURPLE,
59
- };
50
+ const AGENT_COLOR = VIOLET;
60
51
 
61
52
  function toolColor(name: string): string {
62
53
  return TOOL_COLORS[name] ?? VIOLET;
63
54
  }
64
55
 
65
- function agentColor(name: string): string {
66
- return AGENT_COLORS[name] ?? VIOLET;
67
- }
68
-
69
56
  function truncate(s: string, n: number): string {
70
57
  const clean = s.replace(/\s+/g, " ").trim();
71
58
  return clean.length > n ? clean.slice(0, n - 1) + "…" : clean;
@@ -240,16 +227,13 @@ function sleep(seconds: number): Promise<void> {
240
227
 
241
228
  export async function agentCommand(name: string): Promise<void> {
242
229
  const prompt = loadPrompt(name);
243
- const sleepSeconds =
244
- Number(process.env.MDLESS_SLEEP) ||
245
- DEFAULT_SLEEP_SECONDS[name] ||
246
- FALLBACK_SLEEP_SECONDS;
230
+ const sleepSeconds = Number(process.env.MDLESS_SLEEP) || SLEEP_SECONDS;
247
231
 
248
232
  const logDir = join(process.cwd(), ".mdless", "logs");
249
233
  mkdirSync(logDir, { recursive: true });
250
234
  const logStream = createWriteStream(join(logDir, `${name}.log`), { flags: "a" });
251
235
 
252
- const titleColor = agentColor(name);
236
+ const titleColor = AGENT_COLOR;
253
237
  const banner =
254
238
  `\n${titleColor}${BOLD} ✦ mdless · ${name}${RESET}\n` +
255
239
  `${DIM} ${"─".repeat(40)}${RESET}\n` +
@@ -8,6 +8,9 @@ import {
8
8
  } from "node:fs";
9
9
  import { basename, join } from "node:path";
10
10
  import { platform } from "node:os";
11
+ import { confirm } from "@inquirer/prompts";
12
+ import { initCommand } from "./init.js";
13
+ import { withExitHandler } from "../utils.js";
11
14
 
12
15
  const SESSION_PREFIX = "mdless";
13
16
  const LABELS: Array<{ name: string; color: string; description: string }> = [
@@ -19,7 +22,7 @@ const LABELS: Array<{ name: string; color: string; description: string }> = [
19
22
  {
20
23
  name: "mdless/approved",
21
24
  color: "5319E7",
22
- description: "Approved by the mdless reviewer agent",
25
+ description: "Approved via mdless",
23
26
  },
24
27
  ];
25
28
 
@@ -61,7 +64,6 @@ function autoInstall(cmd: string): boolean {
61
64
  function checkPrereqs(): boolean {
62
65
  const autoInstallable = ["tmux"];
63
66
  const required = ["gh", "claude"];
64
- const optional = ["sentry-cli"];
65
67
  let ok = true;
66
68
 
67
69
  for (const cmd of autoInstallable) {
@@ -74,11 +76,6 @@ function checkPrereqs(): boolean {
74
76
  ok = false;
75
77
  }
76
78
  }
77
- for (const cmd of optional) {
78
- if (!which(cmd)) {
79
- console.log(`! Optional command not found: ${cmd} (watcher will skip this source)`);
80
- }
81
- }
82
79
 
83
80
  if (!ok) return false;
84
81
 
@@ -202,12 +199,24 @@ export async function startCommand(): Promise<void> {
202
199
  process.exit(1);
203
200
  }
204
201
 
205
- const agents = discoverAgents();
202
+ let agents = discoverAgents();
206
203
  if (agents.length === 0) {
207
- console.error(
208
- "✗ no agent prompts found in .mdless/agents/\n run `mdless init` to create the default prompts.",
204
+ console.log("! no agent prompts found in .mdless/agents/");
205
+ const shouldInit = await withExitHandler(
206
+ confirm({
207
+ message: "Run `mdless init` to copy the default prompts?",
208
+ default: true,
209
+ }),
209
210
  );
210
- process.exit(1);
211
+ if (!shouldInit) {
212
+ process.exit(1);
213
+ }
214
+ await initCommand();
215
+ agents = discoverAgents();
216
+ if (agents.length === 0) {
217
+ console.error("✗ init ran but no prompts were found. Aborting.");
218
+ process.exit(1);
219
+ }
211
220
  }
212
221
 
213
222
  if (!checkPrereqs()) {
package/src/index.ts CHANGED
@@ -4,8 +4,6 @@ import { select } from "@inquirer/prompts";
4
4
  import packageJson from "../package.json" with { type: "json" };
5
5
  import { agentCommand } from "./commands/agent.js";
6
6
  import { initCommand } from "./commands/init.js";
7
- import { scanCommand } from "./commands/scan.js";
8
- import { skillsCommand } from "./commands/skills.js";
9
7
  import { startCommand } from "./commands/start.js";
10
8
  import { withExitHandler } from "./utils.js";
11
9
 
@@ -19,16 +17,6 @@ const banner = `
19
17
  `;
20
18
 
21
19
  const commands = [
22
- {
23
- name: "skills",
24
- description: "Share Claude Code skills across projects and teams",
25
- action: skillsCommand,
26
- },
27
- {
28
- name: "scan",
29
- description: "Find Claude workspaces on your computer",
30
- action: scanCommand,
31
- },
32
20
  {
33
21
  name: "init",
34
22
  description: "Copy the default agent prompts into .mdless/agents/",
@@ -82,7 +70,7 @@ for (const cmd of commands) {
82
70
 
83
71
  program
84
72
  .command("agent <name>")
85
- .description("Run a single agent loop (watcher | executor | reviewer)")
73
+ .description("Run a single agent on repeat — reads the prompt from .mdless/agents/<name>.md")
86
74
  .action(agentCommand);
87
75
 
88
76
  // If no arguments provided, show interactive mode
package/src/utils.ts CHANGED
@@ -1,39 +1,11 @@
1
- import { readdirSync, statSync } from "node:fs";
2
- import { homedir } from "node:os";
3
- import { join } from "node:path";
4
-
5
1
  export function exit(): never {
6
2
  console.log("\nAborted.");
7
3
  process.exit(0);
8
4
  }
9
5
 
10
- export function getDirectories(path: string): string[] {
11
- return readdirSync(path).filter((name) =>
12
- statSync(join(path, name)).isDirectory()
13
- );
14
- }
15
-
16
6
  export function withExitHandler<T>(promise: Promise<T>): Promise<T> {
17
7
  return promise.catch((e: Error) => {
18
8
  if (e.name === "ExitPromptError") exit();
19
9
  throw e;
20
10
  });
21
11
  }
22
-
23
- export function truncatePath(path: string, maxLength = 50): string {
24
- const home = homedir();
25
- let display = path.startsWith(home) ? path.replace(home, "~") : path;
26
- if (display.length > maxLength) {
27
- display = "..." + display.slice(-maxLength + 3);
28
- }
29
- return display;
30
- }
31
-
32
- export function clearLine(): void {
33
- process.stdout.write("\r\x1b[K");
34
- }
35
-
36
- export function formatDuration(ms: number): string {
37
- if (ms < 1000) return `${ms}ms`;
38
- return `${(ms / 1000).toFixed(1)}s`;
39
- }
@@ -1,29 +0,0 @@
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.
@@ -1,27 +0,0 @@
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.
@@ -1,22 +0,0 @@
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.
@@ -1,26 +0,0 @@
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").
@@ -1,39 +0,0 @@
1
- ---
2
- name: sentry
3
- description: Investigate Sentry issues and errors using the sentry-cli
4
- allowed-tools: Bash(sentry-cli:*), Read, Grep, Glob, Edit
5
- argument-hint: [optional: issue ID]
6
- ---
7
-
8
- # Sentry
9
-
10
- Investigate Sentry issues and errors using `sentry-cli`.
11
-
12
- ## Instructions
13
-
14
- 1. Based on $ARGUMENTS, run `sentry-cli issues list` directly:
15
- - **No arguments**: `sentry-cli issues list -s unresolved --max-rows 10`
16
- - **Issue ID provided**: `sentry-cli issues list -i <ID>`
17
-
18
- 2. If the command fails due to missing authentication or configuration, help the user create a `.sentryclirc` in the project root:
19
-
20
- ```ini
21
- [auth]
22
- token=<ask user for their token>
23
-
24
- [defaults]
25
- org=<ask user for org slug>
26
- project=<ask user for project slug>
27
- ```
28
-
29
- Make sure `.sentryclirc` is listed in `.gitignore` since it contains the auth token. Then retry the command.
30
-
31
- 3. Analyze the issues found. For each relevant issue, identify the likely root cause by reading the referenced source files.
32
-
33
- 4. If the user wants a fix, apply it directly. Otherwise, summarize findings and suggest next steps.
34
-
35
- ## Tips
36
-
37
- - Use `sentry-cli issues list --query "is:unresolved level:error"` for unresolved errors only
38
- - Use `--max-rows` and `--pages` to limit output
39
- - Always prefer `sentry-cli` over the Sentry MCP or API
@@ -1,90 +0,0 @@
1
- import { readdirSync, statSync, existsSync } from "node:fs";
2
- import { homedir } from "node:os";
3
- import { join, basename } from "node:path";
4
- import { loadConfig, saveConfig } from "../config.js";
5
- import { clearLine, formatDuration, truncatePath } from "../utils.js";
6
-
7
- const EXCLUSIONS = new Set([
8
- "node_modules",
9
- "dist",
10
- "build",
11
- "Library",
12
- "Applications",
13
- "__pycache__",
14
- "venv",
15
- "worktrees",
16
- "workspaces",
17
- "tmp",
18
- ]);
19
-
20
- function* walkDirectories(dir: string): Generator<string> {
21
- let entries: string[];
22
- try {
23
- entries = readdirSync(dir);
24
- } catch {
25
- return;
26
- }
27
-
28
- for (const entry of entries) {
29
- if (entry.startsWith(".") || EXCLUSIONS.has(entry)) continue;
30
-
31
- const fullPath = join(dir, entry);
32
- let stat;
33
- try {
34
- stat = statSync(fullPath);
35
- } catch {
36
- continue;
37
- }
38
-
39
- if (stat.isDirectory()) {
40
- yield fullPath;
41
- yield* walkDirectories(fullPath);
42
- }
43
- }
44
- }
45
-
46
- function isClaudeWorkspace(dir: string): boolean {
47
- return existsSync(join(dir, ".claude")) && existsSync(join(dir, ".git"));
48
- }
49
-
50
- export async function scanCommand(): Promise<void> {
51
- const startTime = Date.now();
52
- const home = homedir();
53
-
54
- console.log(`Scanning from ${home}...`);
55
-
56
- const found: string[] = [];
57
- let scanned = 0;
58
-
59
- for (const dir of walkDirectories(home)) {
60
- scanned++;
61
- if (isClaudeWorkspace(dir)) {
62
- found.push(dir);
63
- }
64
- if (scanned % 100 === 0) {
65
- clearLine();
66
- process.stdout.write(
67
- ` ${scanned.toLocaleString()} checked, ${found.length} found | ${truncatePath(dir)}`,
68
- );
69
- }
70
- }
71
-
72
- clearLine();
73
-
74
- const config = loadConfig();
75
- config.workingDirectories = found.map((path) => ({
76
- path,
77
- name: basename(path),
78
- sync: true,
79
- }));
80
- saveConfig(config);
81
-
82
- const duration = formatDuration(Date.now() - startTime);
83
- console.log(`\n✓ Found ${found.length} workspaces in ${duration}`);
84
-
85
- for (const dir of found) {
86
- console.log(` • ${basename(dir)}`);
87
- }
88
-
89
- console.log(`\nSaved to ~/.mdless/config.json`);
90
- }
@@ -1,73 +0,0 @@
1
- import { checkbox, confirm } from "@inquirer/prompts";
2
- import { cpSync, existsSync, mkdirSync, rmSync } from "node:fs";
3
- import { join } from "node:path";
4
- import { exit, getDirectories, withExitHandler } from "../utils.js";
5
-
6
- export async function skillsCommand(): Promise<void> {
7
- const cwd = process.cwd();
8
- const claudeDir = join(cwd, ".claude");
9
-
10
- if (!existsSync(claudeDir)) {
11
- const shouldCreate = await withExitHandler(
12
- confirm({ message: "No .claude folder found. Create one?" })
13
- );
14
-
15
- if (!shouldCreate) {
16
- exit();
17
- }
18
-
19
- mkdirSync(claudeDir);
20
- console.log("✓ Created .claude folder.");
21
- }
22
-
23
- const skillsDir = join(import.meta.dirname!, "..", "..", "skills");
24
- const skills = getDirectories(skillsDir);
25
- const destSkillsDir = join(claudeDir, "skills");
26
-
27
- function isInstalled(skill: string): boolean {
28
- return existsSync(join(destSkillsDir, skill));
29
- }
30
-
31
- const selected = await withExitHandler(
32
- checkbox({
33
- message: "Select skills to install:",
34
- choices: skills.map((skill) => ({
35
- name: skill,
36
- value: skill,
37
- checked: isInstalled(skill),
38
- })),
39
- })
40
- );
41
-
42
- const installed: string[] = [];
43
- const removed: string[] = [];
44
-
45
- for (const skill of skills) {
46
- const src = join(skillsDir, skill);
47
- const dest = join(destSkillsDir, skill);
48
- const wasInstalled = isInstalled(skill);
49
- const shouldBeInstalled = selected.includes(skill);
50
-
51
- if (shouldBeInstalled && !wasInstalled) {
52
- cpSync(src, dest, { recursive: true });
53
- installed.push(skill);
54
- } else if (!shouldBeInstalled && wasInstalled) {
55
- rmSync(dest, { recursive: true });
56
- removed.push(skill);
57
- }
58
- }
59
-
60
- if (installed.length > 0 || removed.length > 0) {
61
- console.log("✓ Changes applied.");
62
- }
63
-
64
- const finalSkills = existsSync(destSkillsDir)
65
- ? getDirectories(destSkillsDir)
66
- : [];
67
-
68
- if (finalSkills.length > 0) {
69
- console.log(`\nProject skills: ${finalSkills.join(", ")}`);
70
- } else {
71
- console.log("\nNo skills in this project.");
72
- }
73
- }
package/src/config.ts DELETED
@@ -1,42 +0,0 @@
1
- import { existsSync, mkdirSync, readFileSync, writeFileSync } from "node:fs";
2
- import { homedir } from "node:os";
3
- import { join } from "node:path";
4
-
5
- export const MDLESS_DIR = join(homedir(), ".mdless");
6
- export const CONFIG_PATH = join(MDLESS_DIR, "config.json");
7
-
8
- export interface WorkingDirectory {
9
- path: string;
10
- name: string;
11
- sync: boolean;
12
- }
13
-
14
- export interface MdlessConfig {
15
- version: 1;
16
- workingDirectories: WorkingDirectory[];
17
- }
18
-
19
- export function ensureConfigDir(): void {
20
- if (!existsSync(MDLESS_DIR)) {
21
- mkdirSync(MDLESS_DIR, { recursive: true });
22
- }
23
- }
24
-
25
- export function loadConfig(): MdlessConfig {
26
- ensureConfigDir();
27
-
28
- if (!existsSync(CONFIG_PATH)) {
29
- return {
30
- version: 1,
31
- workingDirectories: [],
32
- };
33
- }
34
-
35
- const content = readFileSync(CONFIG_PATH, "utf-8");
36
- return JSON.parse(content) as MdlessConfig;
37
- }
38
-
39
- export function saveConfig(config: MdlessConfig): void {
40
- ensureConfigDir();
41
- writeFileSync(CONFIG_PATH, JSON.stringify(config, null, 2) + "\n");
42
- }