any-skills 0.1.2 → 0.1.4

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
@@ -1,32 +1,65 @@
1
1
  # any-skills
2
2
 
3
- When installed as a dependency, this package creates a shared skills directory (default: `.skills`) so Claude, Codex, and similar tools can reuse the same skills.
3
+ Create a shared skills directory and link tool-specific folders so Claude, Codex,
4
+ Gemini, and others can reuse the same skills.
4
5
 
5
- - `.claude/skills`
6
- - `.codex/skills`
6
+ ## What it does
7
7
 
8
- ## How it works
8
+ - Creates a shared `skills` directory in the working directory (or uses the
9
+ configured target).
10
+ - Creates tool links such as `.claude/skills` or `.codex/skills`.
11
+ - Auto-detects `claude`, `codex`, and `gemini` commands on your PATH by default.
9
12
 
10
- The `postinstall` script runs at install time. It uses the user's install working directory as the root (prefers `INIT_CWD`, then `npm_config_local_prefix`, and falls back to `process.cwd()`). If the shared skills directory does not exist, it is created, then the tool-specific symlinks are generated (unless overridden by configuration). By default it auto-detects the `claude`, `codex`, and `gemini` commands on your PATH.
13
+ ## Install
11
14
 
12
- When installed globally, the postinstall step is skipped. Instead, run the CLI in the project you want to link.
15
+ ```sh
16
+ npm install any-skills --save-dev
17
+ ```
18
+
19
+ Or install globally:
20
+
21
+ ```sh
22
+ npm install -g any-skills
23
+ ```
24
+
25
+ ## Usage
26
+
27
+ Create links in the current directory:
28
+
29
+ ```sh
30
+ npx any-skills
31
+ ```
32
+
33
+ Create links in your home directory (for example `~/.claude/skills`):
34
+
35
+ ```sh
36
+ npx any-skills -g
37
+ ```
38
+
39
+ Limit to specific tools:
40
+
41
+ ```sh
42
+ npx any-skills claude
43
+ npx any-skills deepseek
44
+ ```
45
+
46
+ If a tool is not in the configured map, it links to `.<name>/skills` by default.
13
47
 
14
48
  ## Configuration
15
49
 
16
- You can customize which links are created by adding `.skillsrc` (JSON) in your project root.
50
+ Create `.skillsrc` (JSON) in the working directory.
17
51
 
18
52
  Supported fields:
19
53
 
20
- - `target`: optional string. Overrides where skills are stored (default: `.skills`).
54
+ - `target`: optional string. Overrides where skills are stored (default: `skills`).
21
55
  - `links`: array of link definitions. Strings map to `target` by default.
22
- - `tools`: optional object mapping command names to link paths, used for auto-detection.
23
- - `linkRoot`: optional string. Controls where links are created (`cwd`, `home`, `~`, or a path).
56
+ - `tools`: optional object mapping command names to link paths.
24
57
 
25
58
  Example:
26
59
 
27
60
  ```json
28
61
  {
29
- "target": ".skills",
62
+ "target": "skills",
30
63
  "links": [".codex/skills", ".claude/skills"]
31
64
  }
32
65
  ```
@@ -43,46 +76,11 @@ Example (auto-detect commands):
43
76
  }
44
77
  ```
45
78
 
46
- Example (link into home directory):
47
-
48
- ```json
49
- {
50
- "linkRoot": "home"
51
- }
52
- ```
53
-
54
79
  ## Cross-platform behavior
55
80
 
56
81
  - macOS / Linux uses `dir` symlinks
57
82
  - Windows uses `junction` for better compatibility
58
83
 
59
- ## Usage
60
-
61
- ```sh
62
- npm install any-skills --save-dev
63
- ```
64
-
65
- ## Global usage
66
-
67
- ```sh
68
- npm install -g any-skills
69
- ```
70
-
71
- Then, in the project directory where you want links created:
72
-
73
- ```sh
74
- npx any-skills
75
- ```
76
-
77
- If the project does not list `any-skills` as a dependency, the CLI defaults to linking into your home directory (for example `~/.claude/skills`). Use `linkRoot` in `.skillsrc` to override.
78
-
79
- You can also pass tool names to only create those links:
80
-
81
- ```sh
82
- npx any-skills claude
83
- npx any-skills deepseek
84
- ```
85
-
86
84
  ## Git ignore
87
85
 
88
86
  Add the tool-specific shared skill directories to your `.gitignore`:
package/package.json CHANGED
@@ -1,11 +1,8 @@
1
1
  {
2
2
  "name": "any-skills",
3
- "version": "0.1.2",
4
- "description": "Share skills between Claude, Codex, and similar tools via a shared .skills directory.",
3
+ "version": "0.1.4",
4
+ "description": "Share skills between Claude, Codex, and similar tools via a shared skills directory.",
5
5
  "type": "commonjs",
6
- "scripts": {
7
- "postinstall": "node scripts/postinstall.js"
8
- },
9
6
  "bin": {
10
7
  "any-skills": "scripts/cli.js"
11
8
  }
package/scripts/cli.js CHANGED
@@ -1,57 +1,29 @@
1
1
  #!/usr/bin/env node
2
2
  'use strict';
3
3
 
4
- const fs = require('fs');
5
4
  const os = require('os');
6
- const path = require('path');
7
5
  const { linkSkills } = require('./link-skills');
8
6
 
9
- function readPackageJson(filePath) {
10
- try {
11
- return JSON.parse(fs.readFileSync(filePath, 'utf8'));
12
- } catch (err) {
13
- return null;
14
- }
15
- }
16
-
17
- function hasAnySkillsDependency(pkg) {
18
- const dependencyFields = [
19
- 'dependencies',
20
- 'devDependencies',
21
- 'optionalDependencies',
22
- 'peerDependencies',
23
- ];
24
- for (const field of dependencyFields) {
25
- if (pkg && pkg[field] && pkg[field]['any-skills']) {
26
- return true;
27
- }
28
- }
29
- return false;
30
- }
31
-
32
- function hasLocalInstall(startDir) {
33
- let current = path.resolve(startDir);
34
- while (true) {
35
- const pkgPath = path.join(current, 'package.json');
36
- if (fs.existsSync(pkgPath)) {
37
- const pkg = readPackageJson(pkgPath);
38
- if (hasAnySkillsDependency(pkg)) {
39
- return true;
40
- }
7
+ function parseArgs(argv) {
8
+ const flags = new Set();
9
+ const tools = [];
10
+ for (const arg of argv) {
11
+ if (arg === '--global' || arg === '-g') {
12
+ flags.add('global');
13
+ continue;
41
14
  }
42
-
43
- const parent = path.dirname(current);
44
- if (parent === current) {
45
- return false;
15
+ if (arg.startsWith('-')) {
16
+ continue;
46
17
  }
47
- current = parent;
18
+ tools.push(arg);
48
19
  }
20
+ return { flags, tools };
49
21
  }
50
22
 
51
23
  const rootDir = process.cwd();
52
- const linkRoot = hasLocalInstall(rootDir) ? rootDir : os.homedir();
53
- const args = process.argv.slice(2).filter(Boolean);
54
- const explicitTools = args.length ? args : null;
24
+ const { flags, tools } = parseArgs(process.argv.slice(2));
25
+ const linkRoot = flags.has('global') ? os.homedir() : rootDir;
26
+ const explicitTools = tools.length ? tools : null;
55
27
  const exitCode = linkSkills(rootDir, { linkRoot, explicitTools });
56
28
  if (exitCode) {
57
29
  process.exit(exitCode);
@@ -1,10 +1,9 @@
1
1
  'use strict';
2
2
 
3
3
  const fs = require('fs');
4
- const os = require('os');
5
4
  const path = require('path');
6
5
 
7
- const targetName = '.skills';
6
+ const targetName = 'skills';
8
7
  const configFileName = '.skillsrc';
9
8
  const defaultToolTargets = {
10
9
  claude: '.claude/skills',
@@ -119,29 +118,6 @@ function resolveRootPath(value, baseDir) {
119
118
  return path.isAbsolute(value) ? value : path.join(baseDir, value);
120
119
  }
121
120
 
122
- function resolveLinkRoot(config, rootDir, defaultLinkRoot) {
123
- if (
124
- config &&
125
- typeof config.linkRoot === 'string' &&
126
- config.linkRoot.trim() !== ''
127
- ) {
128
- const raw = config.linkRoot.trim();
129
- if (raw === 'home') {
130
- return os.homedir();
131
- }
132
- if (raw === 'cwd') {
133
- return rootDir;
134
- }
135
- if (raw === '~' || raw.startsWith('~/')) {
136
- const suffix = raw.length > 2 ? raw.slice(2) : '';
137
- return path.join(os.homedir(), suffix);
138
- }
139
- return resolveRootPath(raw, rootDir);
140
- }
141
-
142
- return defaultLinkRoot || rootDir;
143
- }
144
-
145
121
  function resolveTarget(config, rootDir) {
146
122
  if (
147
123
  config &&
@@ -292,7 +268,7 @@ function buildLinkMappings({
292
268
  linkRoot,
293
269
  explicitTools,
294
270
  }) {
295
- const resolvedLinkRoot = resolveLinkRoot(config, rootDir, linkRoot);
271
+ const resolvedLinkRoot = linkRoot || rootDir;
296
272
  const explicitTargets = Array.isArray(explicitTools)
297
273
  ? resolveExplicitTargets(config, explicitTools)
298
274
  : null;
@@ -1,33 +0,0 @@
1
- 'use strict';
2
-
3
- const path = require('path');
4
- const { linkSkills } = require('./link-skills');
5
-
6
- function getInstallRoot() {
7
- const initCwd = process.env.INIT_CWD;
8
- if (initCwd) {
9
- return path.resolve(initCwd);
10
- }
11
-
12
- const npmPrefix = process.env.npm_config_local_prefix;
13
- if (npmPrefix) {
14
- return path.resolve(npmPrefix);
15
- }
16
-
17
- return process.cwd();
18
- }
19
-
20
- const isGlobalInstall =
21
- process.env.npm_config_global === 'true' ||
22
- process.env.npm_config_global === '1';
23
-
24
- if (isGlobalInstall) {
25
- console.log('[any-skills] Global install detected; skipping postinstall.');
26
- process.exit(0);
27
- }
28
-
29
- const rootDir = getInstallRoot();
30
- const exitCode = linkSkills(rootDir);
31
- if (exitCode) {
32
- process.exit(exitCode);
33
- }