@lingjingai/lj-awb-cli 0.3.12 → 0.3.13
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 +3 -1
- package/build/build.mjs +47 -0
- package/build/pre.mjs +76 -0
- package/build/prod.mjs +95 -0
- package/install.mjs +9 -3
- package/package.json +2 -1
- package/packages/awb-cli/package.json +2 -2
- package/packages/awb-core/package.json +1 -1
- package/skills/lj-awb/SKILL.md +1 -1
- package/skills/lj-awb/VERSION +1 -1
- package/skills/lj-awb/compat.json +2 -2
package/README.md
CHANGED
|
@@ -60,7 +60,9 @@ lj-awb auth status
|
|
|
60
60
|
~/.codex/skills/lj-awb
|
|
61
61
|
```
|
|
62
62
|
|
|
63
|
-
|
|
63
|
+
如果设置了 `CODEX_HOME`,Codex skill 会安装到 `$CODEX_HOME/skills/lj-awb`。
|
|
64
|
+
|
|
65
|
+
可用 `LINGJING_AWB_SKILL_INSTALL_DIR` 指定单一安装目录;如果传入的是以 `skills` 结尾的根目录,安装器会自动追加 `lj-awb`。也可用 `LINGJING_AWB_SKIP_SKILL_INSTALL=1` 跳过 skill 安装。
|
|
64
66
|
|
|
65
67
|
源码运行:
|
|
66
68
|
|
package/build/build.mjs
ADDED
|
@@ -0,0 +1,47 @@
|
|
|
1
|
+
#!/usr/bin/env node
|
|
2
|
+
import { spawnSync } from 'node:child_process';
|
|
3
|
+
import path from 'node:path';
|
|
4
|
+
import { fileURLToPath } from 'node:url';
|
|
5
|
+
|
|
6
|
+
const repoRoot = path.resolve(path.dirname(fileURLToPath(import.meta.url)), '..');
|
|
7
|
+
const rawArgs = process.argv.slice(2);
|
|
8
|
+
const target = rawArgs[0] && !rawArgs[0].startsWith('-') ? rawArgs[0] : 'pre';
|
|
9
|
+
const passthroughArgs = target === rawArgs[0] ? rawArgs.slice(1) : rawArgs;
|
|
10
|
+
|
|
11
|
+
const scriptByTarget = {
|
|
12
|
+
pre: 'pre.mjs',
|
|
13
|
+
prod: 'prod.mjs',
|
|
14
|
+
};
|
|
15
|
+
|
|
16
|
+
function printUsage() {
|
|
17
|
+
process.stderr.write([
|
|
18
|
+
'Usage:',
|
|
19
|
+
' npm run build -- pre',
|
|
20
|
+
' npm run build -- pre --dry-run',
|
|
21
|
+
' npm run build -- prod',
|
|
22
|
+
' npm run build -- prod --dry-run',
|
|
23
|
+
'',
|
|
24
|
+
].join('\n'));
|
|
25
|
+
}
|
|
26
|
+
|
|
27
|
+
const script = scriptByTarget[target];
|
|
28
|
+
if (!script) {
|
|
29
|
+
printUsage();
|
|
30
|
+
process.exit(2);
|
|
31
|
+
}
|
|
32
|
+
|
|
33
|
+
const result = spawnSync(process.execPath, [
|
|
34
|
+
path.join(repoRoot, 'build', script),
|
|
35
|
+
...passthroughArgs,
|
|
36
|
+
], {
|
|
37
|
+
cwd: repoRoot,
|
|
38
|
+
env: process.env,
|
|
39
|
+
stdio: 'inherit',
|
|
40
|
+
});
|
|
41
|
+
|
|
42
|
+
if (result.error) {
|
|
43
|
+
process.stderr.write(`${result.error.message}\n`);
|
|
44
|
+
process.exit(1);
|
|
45
|
+
}
|
|
46
|
+
|
|
47
|
+
process.exit(result.status || 0);
|
package/build/pre.mjs
ADDED
|
@@ -0,0 +1,76 @@
|
|
|
1
|
+
#!/usr/bin/env node
|
|
2
|
+
import { spawnSync } from 'node:child_process';
|
|
3
|
+
import { mkdtempSync, rmSync } from 'node:fs';
|
|
4
|
+
import { tmpdir } from 'node:os';
|
|
5
|
+
import path from 'node:path';
|
|
6
|
+
import { fileURLToPath } from 'node:url';
|
|
7
|
+
|
|
8
|
+
const repoRoot = path.resolve(path.dirname(fileURLToPath(import.meta.url)), '..');
|
|
9
|
+
const dryRun = process.env.NPM_INSTALL_DRY_RUN === '1' || process.argv.slice(2).includes('--dry-run');
|
|
10
|
+
|
|
11
|
+
function run(command, args, options = {}) {
|
|
12
|
+
process.stderr.write(`$ ${[command, ...args].join(' ')}\n`);
|
|
13
|
+
const result = spawnSync(command, args, {
|
|
14
|
+
cwd: repoRoot,
|
|
15
|
+
env: process.env,
|
|
16
|
+
stdio: 'inherit',
|
|
17
|
+
...options,
|
|
18
|
+
});
|
|
19
|
+
|
|
20
|
+
if (result.error) {
|
|
21
|
+
process.stderr.write(`${result.error.message}\n`);
|
|
22
|
+
process.exit(1);
|
|
23
|
+
}
|
|
24
|
+
if (result.status !== 0) {
|
|
25
|
+
process.exit(result.status || 1);
|
|
26
|
+
}
|
|
27
|
+
}
|
|
28
|
+
|
|
29
|
+
function packToTempDir(packDir) {
|
|
30
|
+
process.stderr.write(`$ npm pack --pack-destination ${packDir} --silent\n`);
|
|
31
|
+
const result = spawnSync('npm', ['pack', '--pack-destination', packDir, '--silent'], {
|
|
32
|
+
cwd: repoRoot,
|
|
33
|
+
env: process.env,
|
|
34
|
+
encoding: 'utf8',
|
|
35
|
+
stdio: ['inherit', 'pipe', 'inherit'],
|
|
36
|
+
});
|
|
37
|
+
|
|
38
|
+
if (result.error) {
|
|
39
|
+
process.stderr.write(`${result.error.message}\n`);
|
|
40
|
+
process.exit(1);
|
|
41
|
+
}
|
|
42
|
+
if (result.status !== 0) {
|
|
43
|
+
process.exit(result.status || 1);
|
|
44
|
+
}
|
|
45
|
+
|
|
46
|
+
const tarball = result.stdout.trim().split(/\r?\n/).filter(Boolean).at(-1);
|
|
47
|
+
if (!tarball) {
|
|
48
|
+
process.stderr.write('npm pack did not return a tarball name.\n');
|
|
49
|
+
process.exit(1);
|
|
50
|
+
}
|
|
51
|
+
return path.join(packDir, tarball);
|
|
52
|
+
}
|
|
53
|
+
|
|
54
|
+
if (process.env.SKIP_CHECK !== '1') {
|
|
55
|
+
run('npm', ['run', 'check']);
|
|
56
|
+
}
|
|
57
|
+
|
|
58
|
+
const packDir = mkdtempSync(path.join(tmpdir(), 'lj-awb-pack-'));
|
|
59
|
+
try {
|
|
60
|
+
const tarballPath = packToTempDir(packDir);
|
|
61
|
+
run('npm', [
|
|
62
|
+
'install',
|
|
63
|
+
'-g',
|
|
64
|
+
tarballPath,
|
|
65
|
+
'--registry=https://registry.npmjs.org/',
|
|
66
|
+
...(dryRun ? ['--dry-run'] : []),
|
|
67
|
+
]);
|
|
68
|
+
if (dryRun) {
|
|
69
|
+
process.stderr.write('Validated local pre build install plan from packed tarball.\n');
|
|
70
|
+
} else {
|
|
71
|
+
run('lj-awb', ['--version']);
|
|
72
|
+
process.stderr.write('Installed local pre build globally from packed tarball.\n');
|
|
73
|
+
}
|
|
74
|
+
} finally {
|
|
75
|
+
rmSync(packDir, { recursive: true, force: true });
|
|
76
|
+
}
|
package/build/prod.mjs
ADDED
|
@@ -0,0 +1,95 @@
|
|
|
1
|
+
#!/usr/bin/env node
|
|
2
|
+
import { readFileSync } from 'node:fs';
|
|
3
|
+
import { spawnSync } from 'node:child_process';
|
|
4
|
+
import path from 'node:path';
|
|
5
|
+
import { fileURLToPath } from 'node:url';
|
|
6
|
+
|
|
7
|
+
const repoRoot = path.resolve(path.dirname(fileURLToPath(import.meta.url)), '..');
|
|
8
|
+
const pkg = JSON.parse(readFileSync(path.join(repoRoot, 'package.json'), 'utf8'));
|
|
9
|
+
const passthroughArgs = process.argv.slice(2);
|
|
10
|
+
const registry = findArgValue(passthroughArgs, '--registry') || process.env.NPM_CONFIG_REGISTRY || 'https://registry.npmjs.org/';
|
|
11
|
+
const dryRun = process.env.NPM_PUBLISH_DRY_RUN === '1' || passthroughArgs.includes('--dry-run');
|
|
12
|
+
|
|
13
|
+
function findArgValue(args, name) {
|
|
14
|
+
for (let index = 0; index < args.length; index += 1) {
|
|
15
|
+
const arg = args[index];
|
|
16
|
+
if (arg === name) return args[index + 1];
|
|
17
|
+
if (arg.startsWith(`${name}=`)) return arg.slice(name.length + 1);
|
|
18
|
+
}
|
|
19
|
+
return undefined;
|
|
20
|
+
}
|
|
21
|
+
|
|
22
|
+
function run(command, args, options = {}) {
|
|
23
|
+
process.stderr.write(`$ ${[command, ...args].join(' ')}\n`);
|
|
24
|
+
const result = spawnSync(command, args, {
|
|
25
|
+
cwd: repoRoot,
|
|
26
|
+
env: process.env,
|
|
27
|
+
stdio: 'inherit',
|
|
28
|
+
...options,
|
|
29
|
+
});
|
|
30
|
+
|
|
31
|
+
if (result.error) {
|
|
32
|
+
process.stderr.write(`${result.error.message}\n`);
|
|
33
|
+
process.exit(1);
|
|
34
|
+
}
|
|
35
|
+
if (result.status !== 0) {
|
|
36
|
+
process.exit(result.status || 1);
|
|
37
|
+
}
|
|
38
|
+
}
|
|
39
|
+
|
|
40
|
+
function capture(command, args) {
|
|
41
|
+
return spawnSync(command, args, {
|
|
42
|
+
cwd: repoRoot,
|
|
43
|
+
env: process.env,
|
|
44
|
+
encoding: 'utf8',
|
|
45
|
+
stdio: ['inherit', 'pipe', 'pipe'],
|
|
46
|
+
});
|
|
47
|
+
}
|
|
48
|
+
|
|
49
|
+
function ensureLoggedIn() {
|
|
50
|
+
const result = capture('npm', ['whoami', `--registry=${registry}`]);
|
|
51
|
+
if (result.status === 0) {
|
|
52
|
+
process.stderr.write(`npm user: ${result.stdout.trim()}\n`);
|
|
53
|
+
return;
|
|
54
|
+
}
|
|
55
|
+
|
|
56
|
+
process.stderr.write([
|
|
57
|
+
`npm is not logged in for ${registry}.`,
|
|
58
|
+
`Run: npm login --registry=${registry}`,
|
|
59
|
+
'',
|
|
60
|
+
].join('\n'));
|
|
61
|
+
process.exit(1);
|
|
62
|
+
}
|
|
63
|
+
|
|
64
|
+
function ensureVersionNotPublished() {
|
|
65
|
+
const spec = `${pkg.name}@${pkg.version}`;
|
|
66
|
+
const result = capture('npm', ['view', spec, 'version', `--registry=${registry}`]);
|
|
67
|
+
if (result.status === 0) {
|
|
68
|
+
process.stderr.write(`${spec} already exists on npm. Bump the version before publishing.\n`);
|
|
69
|
+
process.exit(1);
|
|
70
|
+
}
|
|
71
|
+
if (!/E404|404 Not Found|Not found/i.test(`${result.stderr}\n${result.stdout}`)) {
|
|
72
|
+
process.stderr.write(`Could not verify whether ${spec} exists on npm.\n`);
|
|
73
|
+
process.stderr.write(result.stderr || result.stdout || '');
|
|
74
|
+
process.exit(1);
|
|
75
|
+
}
|
|
76
|
+
}
|
|
77
|
+
|
|
78
|
+
process.stderr.write(`Preparing ${pkg.name}@${pkg.version} for npm ${dryRun ? 'dry-run' : 'publish'}.\n`);
|
|
79
|
+
|
|
80
|
+
if (process.env.SKIP_CHECK !== '1') {
|
|
81
|
+
run('npm', ['run', 'check']);
|
|
82
|
+
}
|
|
83
|
+
|
|
84
|
+
ensureVersionNotPublished();
|
|
85
|
+
if (!dryRun) {
|
|
86
|
+
ensureLoggedIn();
|
|
87
|
+
}
|
|
88
|
+
|
|
89
|
+
run('npm', [
|
|
90
|
+
'publish',
|
|
91
|
+
'--access',
|
|
92
|
+
'public',
|
|
93
|
+
`--registry=${registry}`,
|
|
94
|
+
...passthroughArgs,
|
|
95
|
+
]);
|
package/install.mjs
CHANGED
|
@@ -1,7 +1,7 @@
|
|
|
1
1
|
#!/usr/bin/env node
|
|
2
2
|
import { cpSync, existsSync, mkdirSync, readdirSync, rmSync } from 'node:fs';
|
|
3
3
|
import { homedir } from 'node:os';
|
|
4
|
-
import { dirname, join } from 'node:path';
|
|
4
|
+
import { basename, dirname, join } from 'node:path';
|
|
5
5
|
import { fileURLToPath } from 'node:url';
|
|
6
6
|
|
|
7
7
|
const log = (message) => process.stderr.write(`${message}\n`);
|
|
@@ -23,11 +23,17 @@ function copyDirectory(sourceDir, targetDir) {
|
|
|
23
23
|
const packageDir = dirname(fileURLToPath(import.meta.url));
|
|
24
24
|
const skillSourceDir = join(packageDir, 'skills', 'lj-awb');
|
|
25
25
|
const explicitSkillTargetDir = process.env.LINGJING_AWB_SKILL_INSTALL_DIR || process.env.ANIME_SKILL_INSTALL_DIR;
|
|
26
|
+
const codexHomeDir = process.env.CODEX_HOME || join(homedir(), '.codex');
|
|
27
|
+
|
|
28
|
+
function normalizeSkillTargetDir(targetDir) {
|
|
29
|
+
return basename(targetDir) === 'skills' ? join(targetDir, 'lj-awb') : targetDir;
|
|
30
|
+
}
|
|
31
|
+
|
|
26
32
|
const skillTargetDirs = explicitSkillTargetDir
|
|
27
|
-
? [explicitSkillTargetDir]
|
|
33
|
+
? [normalizeSkillTargetDir(explicitSkillTargetDir)]
|
|
28
34
|
: [
|
|
29
35
|
join(homedir(), '.cc-switch', 'skills', 'lj-awb'),
|
|
30
|
-
join(
|
|
36
|
+
join(codexHomeDir, 'skills', 'lj-awb'),
|
|
31
37
|
];
|
|
32
38
|
|
|
33
39
|
if (process.env.LINGJING_AWB_SKIP_SKILL_INSTALL === '1' || process.env.ANIME_SKIP_SKILL_INSTALL === '1') {
|
package/package.json
CHANGED
|
@@ -1,6 +1,6 @@
|
|
|
1
1
|
{
|
|
2
2
|
"name": "@lingjingai/lj-awb-cli",
|
|
3
|
-
"version": "0.3.
|
|
3
|
+
"version": "0.3.13",
|
|
4
4
|
"description": "Lingjing AWB CLI monorepo with shared core, standalone CLI, and agent skills",
|
|
5
5
|
"license": "MIT",
|
|
6
6
|
"type": "module",
|
|
@@ -24,6 +24,7 @@
|
|
|
24
24
|
"version:sync": "node scripts/sync-versions.mjs"
|
|
25
25
|
},
|
|
26
26
|
"files": [
|
|
27
|
+
"build",
|
|
27
28
|
"install.mjs",
|
|
28
29
|
"packages/awb-core",
|
|
29
30
|
"packages/awb-cli",
|
|
@@ -1,6 +1,6 @@
|
|
|
1
1
|
{
|
|
2
2
|
"name": "@lingjingai/awb-cli-bin",
|
|
3
|
-
"version": "0.3.
|
|
3
|
+
"version": "0.3.13",
|
|
4
4
|
"description": "Standalone CLI for Lingjing AWB",
|
|
5
5
|
"private": true,
|
|
6
6
|
"license": "MIT",
|
|
@@ -13,6 +13,6 @@
|
|
|
13
13
|
"README.md"
|
|
14
14
|
],
|
|
15
15
|
"dependencies": {
|
|
16
|
-
"@lingjingai/awb-core": "0.3.
|
|
16
|
+
"@lingjingai/awb-core": "0.3.13"
|
|
17
17
|
}
|
|
18
18
|
}
|
package/skills/lj-awb/SKILL.md
CHANGED
package/skills/lj-awb/VERSION
CHANGED
|
@@ -1 +1 @@
|
|
|
1
|
-
0.3.
|
|
1
|
+
0.3.13
|