gorig-cli 1.0.21 → 1.0.24

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
@@ -72,6 +72,33 @@ npx gorig-cli@latest doc user
72
72
  After generating the documentation, you can access it through:
73
73
  http://127.0.0.1:8080/redoc.html
74
74
 
75
+ ### Install Gorig Skill
76
+
77
+ Use the `skill` command to install the bundled `gorig-backend` skill for Codex or Claude:
78
+
79
+ ```sh
80
+ # Install both Codex and Claude user-level skills
81
+ gorig-cli skill install all
82
+
83
+ # Install only the Codex skill
84
+ gorig-cli skill install codex
85
+
86
+ # Install Claude user-level skill
87
+ gorig-cli skill install claude user
88
+
89
+ # Install Claude project-level skill into the current repository
90
+ gorig-cli skill install claude project
91
+ ```
92
+
93
+ Or use npx:
94
+
95
+ ```sh
96
+ npx gorig-cli@latest skill install all
97
+ npx gorig-cli@latest skill install codex
98
+ npx gorig-cli@latest skill install claude user
99
+ npx gorig-cli@latest skill install claude project
100
+ ```
101
+
75
102
  ### Run the Project
76
103
 
77
104
  After entering the project directory, you can run the project using the following commands:
@@ -86,4 +113,3 @@ Or run it after building:
86
113
  ```sh
87
114
  go build -o my-new-project _cmd/main.go && ./my-new-project
88
115
  ```
89
-
package/bin/cli.js CHANGED
@@ -8,7 +8,7 @@ const args = process.argv.slice(2);
8
8
 
9
9
  // Validate if a command is provided
10
10
  if (args.length < 1) {
11
- console.error(chalk.red('Please provide a valid command, e.g.: create or init'));
11
+ console.error(chalk.red('Please provide a valid command, e.g.: create, init, doc, or skill'));
12
12
  process.exit(1);
13
13
  }
14
14
 
@@ -48,8 +48,17 @@ switch (command) {
48
48
  });
49
49
  break;
50
50
 
51
+ case 'skill':
52
+ import(path.join(__dirname, '../commands/skill.js')).then(module => {
53
+ const skillModule = module.default;
54
+ skillModule(args.slice(1));
55
+ }).catch(error => {
56
+ console.error(chalk.red('Failed to load skill command module:', error.message));
57
+ });
58
+ break;
59
+
51
60
  default:
52
61
  console.error(chalk.red(`Unknown command: ${command}`));
53
- console.error(chalk.yellow('Available commands: create, init'));
62
+ console.error(chalk.yellow('Available commands: create, init, doc, skill'));
54
63
  process.exit(1);
55
64
  }
@@ -0,0 +1,92 @@
1
+ import fs from 'fs-extra';
2
+ import os from 'os';
3
+ import path from 'path';
4
+ import chalk from 'chalk';
5
+ import { fileURLToPath } from 'url';
6
+
7
+ const __filename = fileURLToPath(import.meta.url);
8
+ const __dirname = path.dirname(__filename);
9
+
10
+ const SKILL_NAME = 'gorig-backend';
11
+ const VALID_TARGETS = new Set(['codex', 'claude', 'all']);
12
+ const VALID_SCOPES = new Set(['user', 'project']);
13
+
14
+ const printUsage = () => {
15
+ console.log(chalk.yellow('Usage: gorig-cli skill install <codex|claude|all> [user|project]'));
16
+ };
17
+
18
+ const installSkill = async (target, scope) => {
19
+ const templateRoot = path.join(__dirname, '../templates/skills');
20
+ const installs = [];
21
+
22
+ if (target === 'codex' || target === 'all') {
23
+ const codexHome = process.env.CODEX_HOME || path.join(os.homedir(), '.codex');
24
+ installs.push({
25
+ label: 'Codex',
26
+ source: path.join(templateRoot, 'codex', SKILL_NAME),
27
+ destination: path.join(codexHome, 'skills', SKILL_NAME),
28
+ });
29
+ }
30
+
31
+ if (target === 'claude' || target === 'all') {
32
+ const claudeBase = scope === 'project'
33
+ ? path.join(process.cwd(), '.claude')
34
+ : path.join(os.homedir(), '.claude');
35
+
36
+ installs.push({
37
+ label: `Claude (${scope})`,
38
+ source: path.join(templateRoot, 'claude', SKILL_NAME),
39
+ destination: path.join(claudeBase, 'skills', SKILL_NAME),
40
+ });
41
+ }
42
+
43
+ for (const install of installs) {
44
+ const exists = await fs.pathExists(install.source);
45
+ if (!exists) {
46
+ throw new Error(`Skill template not found: ${install.source}`);
47
+ }
48
+
49
+ await fs.ensureDir(path.dirname(install.destination));
50
+ await fs.copy(install.source, install.destination, { overwrite: true });
51
+ console.log(chalk.green(`Installed ${install.label} skill to ${install.destination}`));
52
+ }
53
+ };
54
+
55
+ const skillModule = async (args) => {
56
+ const action = args[0];
57
+
58
+ if (!action) {
59
+ printUsage();
60
+ process.exit(1);
61
+ }
62
+
63
+ if (action !== 'install') {
64
+ console.error(chalk.red(`Unknown skill action: ${action}`));
65
+ printUsage();
66
+ process.exit(1);
67
+ }
68
+
69
+ const target = args[1] || 'all';
70
+ const scope = args[2] || 'user';
71
+
72
+ if (!VALID_TARGETS.has(target)) {
73
+ console.error(chalk.red(`Unknown skill target: ${target}`));
74
+ printUsage();
75
+ process.exit(1);
76
+ }
77
+
78
+ if (!VALID_SCOPES.has(scope)) {
79
+ console.error(chalk.red(`Unknown skill scope: ${scope}`));
80
+ printUsage();
81
+ process.exit(1);
82
+ }
83
+
84
+ try {
85
+ await installSkill(target, scope);
86
+ } catch (error) {
87
+ console.error(chalk.red('Failed to install skill:'), chalk.redBright(error.message));
88
+ process.exit(1);
89
+ }
90
+ };
91
+
92
+ export default skillModule;
@@ -0,0 +1,65 @@
1
+ #!/bin/bash
2
+
3
+ # 确保脚本有执行权限
4
+ # chmod +x npm_publish.sh
5
+
6
+ # 设置官方源地址和原仓库源地址
7
+ NPM_OFFICIAL_REGISTRY="https://registry.npmjs.org/"
8
+ CUSTOM_REGISTRY=$(npm config get registry)
9
+
10
+ # 检查原始仓库源是否为官方源
11
+ if [ "$CUSTOM_REGISTRY" = "$NPM_OFFICIAL_REGISTRY" ]; then
12
+ echo "当前已经是官方源,不需要切换。"
13
+ else
14
+ echo "当前仓库源为: $CUSTOM_REGISTRY"
15
+ echo "正在切换为官方源: $NPM_OFFICIAL_REGISTRY"
16
+ npm config set registry $NPM_OFFICIAL_REGISTRY
17
+ fi
18
+
19
+ # 验证是否成功切换到官方源
20
+ CURRENT_REGISTRY=$(npm config get registry)
21
+ if [ "$CURRENT_REGISTRY" = "$NPM_OFFICIAL_REGISTRY" ]; then
22
+ echo "仓库源已成功切换为官方源。"
23
+ else
24
+ echo "切换仓库源失败,请检查。"
25
+ exit 1
26
+ fi
27
+
28
+ # 登录 npm 账户
29
+ echo "开始登录 npm,请根据提示输入用户名、密码和邮箱地址。"
30
+ npm login
31
+ if [ $? -ne 0 ]; then
32
+ echo "npm 登录失败,请检查用户名、密码和邮箱是否正确。"
33
+ exit 1
34
+ fi
35
+
36
+ # 执行 yarn publish 或 npm publish
37
+ echo "请选择使用 yarn 还是 npm 发布包(输入 y 表示使用 yarn,输入 n 表示使用 npm):"
38
+ read -p "[y/n]: " CHOICE
39
+
40
+ if [ "$CHOICE" = "y" ]; then
41
+ yarn publish
42
+ elif [ "$CHOICE" = "n" ]; then
43
+ npm publish
44
+ else
45
+ echo "无效输入,请重新运行脚本并选择 y 或 n。"
46
+ exit 1
47
+ fi
48
+
49
+ if [ $? -ne 0 ]; then
50
+ echo "发布失败,请检查日志。"
51
+ exit 1
52
+ else
53
+ echo "发布成功!"
54
+ fi
55
+
56
+ # 恢复原始仓库源
57
+ if [ "$CUSTOM_REGISTRY" != "$NPM_OFFICIAL_REGISTRY" ]; then
58
+ echo "正在恢复原始仓库源: $CUSTOM_REGISTRY"
59
+ npm config set registry $CUSTOM_REGISTRY
60
+ echo "仓库源已恢复为: $(npm config get registry)"
61
+ else
62
+ echo "仓库源保持为官方源,无需恢复。"
63
+ fi
64
+
65
+ echo "脚本执行完成。"
package/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "gorig-cli",
3
- "version": "1.0.21",
3
+ "version": "1.0.24",
4
4
  "type": "module",
5
5
  "description": "gorig build tool",
6
6
  "main": "bin/cli.js",