skills-script 1.0.0 → 1.1.1
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 +10 -2
- package/package.json +1 -1
- package/src/cli.js +6 -3
- package/src/commands/sync.js +11 -11
- package/src/lib/path-utils.js +13 -15
package/README.md
CHANGED
|
@@ -24,9 +24,15 @@ Built-in options:
|
|
|
24
24
|
- `codex`
|
|
25
25
|
- `gemini`
|
|
26
26
|
|
|
27
|
+
Built-in targets are under command invocation directory:
|
|
28
|
+
|
|
29
|
+
- `claude` => `<cwd>/.claude/skills`
|
|
30
|
+
- `codex` => `<cwd>/.codex/skills`
|
|
31
|
+
- `gemini` => `<cwd>/.gemini/skills`
|
|
32
|
+
|
|
27
33
|
Custom token rules:
|
|
28
34
|
|
|
29
|
-
- `.aaa` =>
|
|
35
|
+
- `.aaa` => `<cwd>/.aaa/skills`
|
|
30
36
|
- absolute/relative path => used directly as target directory
|
|
31
37
|
|
|
32
38
|
## Source Skills Directory
|
|
@@ -34,9 +40,11 @@ Custom token rules:
|
|
|
34
40
|
The source is fixed to:
|
|
35
41
|
|
|
36
42
|
```bash
|
|
37
|
-
<
|
|
43
|
+
<command invocation directory>/.agents/skills
|
|
38
44
|
```
|
|
39
45
|
|
|
46
|
+
When running through npm/npx, the tool prefers `INIT_CWD` to avoid temp-cache working directory issues.
|
|
47
|
+
|
|
40
48
|
## Non-Interactive Mode
|
|
41
49
|
|
|
42
50
|
```bash
|
package/package.json
CHANGED
package/src/cli.js
CHANGED
|
@@ -1,6 +1,7 @@
|
|
|
1
1
|
import { createRequire } from 'node:module';
|
|
2
2
|
import { runSyncCommand } from './commands/sync.js';
|
|
3
3
|
import { runInteractive } from './commands/interactive.js';
|
|
4
|
+
import { resolveInvocationCwd } from './lib/path-utils.js';
|
|
4
5
|
|
|
5
6
|
const require = createRequire(import.meta.url);
|
|
6
7
|
const { version } = require('../package.json');
|
|
@@ -18,9 +19,11 @@ function printUsage() {
|
|
|
18
19
|
console.log('example : skill-script sync claude,codex,.aaa');
|
|
19
20
|
}
|
|
20
21
|
|
|
21
|
-
export async function runCli(argv, { cwd
|
|
22
|
+
export async function runCli(argv, { cwd } = {}) {
|
|
23
|
+
const baseCwd = cwd || resolveInvocationCwd();
|
|
24
|
+
|
|
22
25
|
if (!argv.length) {
|
|
23
|
-
return runInteractive(
|
|
26
|
+
return runInteractive(baseCwd);
|
|
24
27
|
}
|
|
25
28
|
|
|
26
29
|
const first = argv[0].toLowerCase();
|
|
@@ -36,7 +39,7 @@ export async function runCli(argv, { cwd = process.cwd() } = {}) {
|
|
|
36
39
|
}
|
|
37
40
|
|
|
38
41
|
if (first === 'sync') {
|
|
39
|
-
return runSyncCommand(argv.slice(1), { cwd });
|
|
42
|
+
return runSyncCommand(argv.slice(1), { cwd: baseCwd });
|
|
40
43
|
}
|
|
41
44
|
|
|
42
45
|
console.error(`[ERROR] Unknown command: ${argv[0]}`);
|
package/src/commands/sync.js
CHANGED
|
@@ -1,12 +1,8 @@
|
|
|
1
1
|
import fs from 'node:fs/promises';
|
|
2
2
|
import path from 'node:path';
|
|
3
|
-
import {
|
|
3
|
+
import { resolveCustomTarget, sameOrSubPath } from '../lib/path-utils.js';
|
|
4
4
|
|
|
5
|
-
|
|
6
|
-
codex: '~/.codex/skills',
|
|
7
|
-
claude: '~/.claude/skills',
|
|
8
|
-
gemini: '~/.gemini/skills'
|
|
9
|
-
};
|
|
5
|
+
const PLATFORM_NAMES = ['claude', 'codex', 'gemini'];
|
|
10
6
|
|
|
11
7
|
function splitTokens(input) {
|
|
12
8
|
return input
|
|
@@ -29,11 +25,15 @@ function dedupePaths(paths) {
|
|
|
29
25
|
return result;
|
|
30
26
|
}
|
|
31
27
|
|
|
28
|
+
function resolveNamedPlatformTarget(name, cwd) {
|
|
29
|
+
return path.join(cwd, `.${name}`, 'skills');
|
|
30
|
+
}
|
|
31
|
+
|
|
32
32
|
export function resolveTargetDirs({ platformTokens, cwd }) {
|
|
33
33
|
const targets = [];
|
|
34
34
|
|
|
35
35
|
const addNamed = (name) => {
|
|
36
|
-
targets.push(
|
|
36
|
+
targets.push(resolveNamedPlatformTarget(name, cwd));
|
|
37
37
|
};
|
|
38
38
|
|
|
39
39
|
for (const tokenRaw of platformTokens) {
|
|
@@ -46,13 +46,13 @@ export function resolveTargetDirs({ platformTokens, cwd }) {
|
|
|
46
46
|
|
|
47
47
|
const lower = token.toLowerCase();
|
|
48
48
|
if (lower === 'all') {
|
|
49
|
-
|
|
50
|
-
|
|
51
|
-
|
|
49
|
+
for (const name of PLATFORM_NAMES) {
|
|
50
|
+
addNamed(name);
|
|
51
|
+
}
|
|
52
52
|
continue;
|
|
53
53
|
}
|
|
54
54
|
|
|
55
|
-
if (
|
|
55
|
+
if (PLATFORM_NAMES.includes(lower)) {
|
|
56
56
|
addNamed(lower);
|
|
57
57
|
continue;
|
|
58
58
|
}
|
package/src/lib/path-utils.js
CHANGED
|
@@ -1,12 +1,4 @@
|
|
|
1
1
|
import path from 'node:path';
|
|
2
|
-
import os from 'node:os';
|
|
3
|
-
|
|
4
|
-
export function expandHome(inputPath) {
|
|
5
|
-
if (!inputPath) return inputPath;
|
|
6
|
-
if (inputPath === '~') return os.homedir();
|
|
7
|
-
if (inputPath.startsWith('~/')) return path.join(os.homedir(), inputPath.slice(2));
|
|
8
|
-
return inputPath;
|
|
9
|
-
}
|
|
10
2
|
|
|
11
3
|
export function sameOrSubPath(childPath, parentPath) {
|
|
12
4
|
const child = path.resolve(childPath);
|
|
@@ -20,16 +12,22 @@ export function resolveCustomTarget(token, cwd) {
|
|
|
20
12
|
const raw = token.trim();
|
|
21
13
|
if (!raw) return null;
|
|
22
14
|
|
|
23
|
-
// .aaa ->
|
|
15
|
+
// .aaa -> <cwd>/.aaa/skills
|
|
24
16
|
if (raw.startsWith('.') && !raw.startsWith('./') && !raw.startsWith('../')) {
|
|
25
|
-
return path.join(
|
|
17
|
+
return path.join(cwd, raw, 'skills');
|
|
26
18
|
}
|
|
27
19
|
|
|
28
|
-
|
|
29
|
-
|
|
30
|
-
if (path.isAbsolute(expanded)) {
|
|
31
|
-
return expanded;
|
|
20
|
+
if (path.isAbsolute(raw)) {
|
|
21
|
+
return raw;
|
|
32
22
|
}
|
|
33
23
|
|
|
34
|
-
return path.resolve(cwd,
|
|
24
|
+
return path.resolve(cwd, raw);
|
|
25
|
+
}
|
|
26
|
+
|
|
27
|
+
export function resolveInvocationCwd() {
|
|
28
|
+
const initCwd = process.env.INIT_CWD;
|
|
29
|
+
if (initCwd && path.isAbsolute(initCwd)) {
|
|
30
|
+
return initCwd;
|
|
31
|
+
}
|
|
32
|
+
return process.cwd();
|
|
35
33
|
}
|