@haolin-ai/skillman 1.0.4 → 1.0.6

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/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "@haolin-ai/skillman",
3
- "version": "1.0.4",
3
+ "version": "1.0.6",
4
4
  "description": "A CLI tool to install AI agent skills across multiple platforms",
5
5
  "type": "module",
6
6
  "bin": {
@@ -11,7 +11,7 @@
11
11
  "src"
12
12
  ],
13
13
  "scripts": {
14
- "test": "echo \"Error: no test specified\" && exit 1"
14
+ "test": "node --test test/**/*.test.js"
15
15
  },
16
16
  "keywords": [
17
17
  "cli",
package/src/downloader.js CHANGED
@@ -41,8 +41,8 @@ export function parseUrl(url) {
41
41
  };
42
42
  }
43
43
 
44
- // Regular git URLs
45
- if (url.startsWith('https://') || url.startsWith('git@') || url.startsWith('http://')) {
44
+ // Regular git URLs (https, http, git@, ssh://)
45
+ if (url.startsWith('https://') || url.startsWith('git@') || url.startsWith('http://') || url.startsWith('ssh://')) {
46
46
  // Remove .git suffix if present for consistency
47
47
  const cleanUrl = url.replace(/\.git$/, '');
48
48
  return { type: 'git', url: cleanUrl + '.git', subPath: null };
package/src/history.js CHANGED
@@ -17,22 +17,33 @@ function getConfigDir() {
17
17
  return path.join(os.homedir(), '.config', 'skillman');
18
18
  }
19
19
 
20
- const HISTORY_FILE = path.join(getConfigDir(), 'history.json');
20
+ // Allow overriding history file location for testing
21
+ function getHistoryFile() {
22
+ return process.env.SKILLMAN_HISTORY_FILE
23
+ ? process.env.SKILLMAN_HISTORY_FILE
24
+ : path.join(getConfigDir(), 'history.json');
25
+ }
21
26
  const MAX_HISTORY_SIZE = 10;
22
27
 
23
28
  async function ensureDir() {
24
- const dir = path.dirname(HISTORY_FILE);
29
+ const historyFile = getHistoryFile();
30
+ const dir = path.dirname(historyFile);
25
31
  try {
26
- await fs.access(dir);
27
- } catch {
28
32
  await fs.mkdir(dir, { recursive: true });
33
+ } catch (err) {
34
+ // If mkdir fails, try to provide more context
35
+ if (err.code === 'ENOENT') {
36
+ throw new Error(`Cannot create directory ${dir}: parent path does not exist`);
37
+ }
38
+ throw err;
29
39
  }
30
40
  }
31
41
 
32
42
  export async function loadHistory(agentName) {
33
43
  try {
34
44
  await ensureDir();
35
- const data = await fs.readFile(HISTORY_FILE, 'utf8');
45
+ const historyFile = getHistoryFile();
46
+ const data = await fs.readFile(historyFile, 'utf8');
36
47
  const history = JSON.parse(data);
37
48
  return {
38
49
  workspaces: history[agentName]?.workspaces || [],
@@ -46,9 +57,10 @@ export async function loadHistory(agentName) {
46
57
 
47
58
  export async function saveHistory(agentName, workspaces) {
48
59
  await ensureDir();
60
+ const historyFile = getHistoryFile();
49
61
  let data = {};
50
62
  try {
51
- const existing = await fs.readFile(HISTORY_FILE, 'utf8');
63
+ const existing = await fs.readFile(historyFile, 'utf8');
52
64
  data = JSON.parse(existing);
53
65
  } catch {
54
66
  // File doesn't exist or is invalid
@@ -59,14 +71,15 @@ export async function saveHistory(agentName, workspaces) {
59
71
  updatedAt: new Date().toISOString()
60
72
  };
61
73
 
62
- await fs.writeFile(HISTORY_FILE, JSON.stringify(data, null, 2));
74
+ await fs.writeFile(historyFile, JSON.stringify(data, null, 2));
63
75
  }
64
76
 
65
77
  export async function saveLastUsed(agentName, scope) {
66
78
  await ensureDir();
79
+ const historyFile = getHistoryFile();
67
80
  let data = {};
68
81
  try {
69
- const existing = await fs.readFile(HISTORY_FILE, 'utf8');
82
+ const existing = await fs.readFile(historyFile, 'utf8');
70
83
  data = JSON.parse(existing);
71
84
  } catch {
72
85
  // File doesn't exist or is invalid
@@ -76,7 +89,7 @@ export async function saveLastUsed(agentName, scope) {
76
89
  if (scope) data.lastScope = scope;
77
90
  data.updatedAt = new Date().toISOString();
78
91
 
79
- await fs.writeFile(HISTORY_FILE, JSON.stringify(data, null, 2));
92
+ await fs.writeFile(historyFile, JSON.stringify(data, null, 2));
80
93
  }
81
94
 
82
95
  export async function addWorkspace(agentName, workspacePath) {