@pigcloud/skills 1.0.7 → 1.0.9

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/bin/cli.js CHANGED
@@ -3,9 +3,8 @@
3
3
  const fs = require('fs/promises');
4
4
  const fsSync = require('fs');
5
5
  const path = require('path');
6
- const os = require('os');
7
- const { detectRulesBundle } = require('./rules-loader');
8
- const { ensureNpmRuntime } = require('./runtime-bootstrap');
6
+ const os = require('os');
7
+ const { detectRulesBundle } = require('./rules-loader');
9
8
 
10
9
  const PACKAGE_ROOT = path.join(__dirname, '..');
11
10
  const SKILLS_DIR = path.join(PACKAGE_ROOT, 'skills');
@@ -463,13 +462,13 @@ function printHelp() {
463
462
  console.log(' pig-skills update [--tool codex]');
464
463
  }
465
464
 
466
- async function ensureRuntimeForInstall() {
467
- const result = await ensureNpmRuntime({ quiet: false });
468
- if (result.installed) {
469
- console.log(chalk.green('Installed Node.js/npm runtime for this session.'));
470
- }
471
- return result;
472
- }
465
+ async function ensureRuntimeForInstall() {
466
+ if (!commandAvailable('npm')) {
467
+ throw new Error('npm is not available. Install Node.js LTS first, then rerun the command.');
468
+ }
469
+
470
+ return { installed: false, skipped: false, npmPath: 'npm' };
471
+ }
473
472
 
474
473
  async function run() {
475
474
  const { options, positionals } = parseArgs(process.argv.slice(2));
@@ -0,0 +1,35 @@
1
+ {
2
+ "name": "codex-commands",
3
+ "version": "1.1.0",
4
+ "description": "Codex command pack for Pig Skills. Exposes direct command-style entrypoints such as /prd and /analyze so the skill pack can be invoked without memorizing raw skill names.",
5
+ "author": {
6
+ "name": "pig-cloud-framework",
7
+ "url": "https://gitee.com/rebys/pig-skills"
8
+ },
9
+ "homepage": "https://gitee.com/rebys/pig-skills",
10
+ "repository": "https://gitee.com/rebys/pig-skills.git",
11
+ "license": "MIT",
12
+ "keywords": [
13
+ "codex",
14
+ "commands",
15
+ "skills",
16
+ "prd",
17
+ "analysis"
18
+ ],
19
+ "interface": {
20
+ "displayName": "Pig Skills Codex Commands",
21
+ "shortDescription": "Command-style entrypoints for the Pig Skills pack",
22
+ "longDescription": "Provides Codex command files like /prd, /analyze, /design, /build, and /kb that route into the Pig Skills pack with stable, low-token prompts and clear execution gates.",
23
+ "developerName": "pig-cloud-framework",
24
+ "category": "Productivity",
25
+ "capabilities": [
26
+ "Interactive",
27
+ "Read"
28
+ ],
29
+ "websiteURL": "https://gitee.com/rebys/pig-skills",
30
+ "defaultPrompt": [
31
+ "Use /prd, /analyze, /design, /build, /review, or /kb to route work into the correct Pig Skill"
32
+ ],
33
+ "brandColor": "#2563EB"
34
+ }
35
+ }
@@ -0,0 +1,23 @@
1
+ # Pig Skills Codex Commands
2
+
3
+ 鏈彃浠舵彁渚?Pig Skills skill pack 鐨勫懡浠ゅ紡鍏ュ彛銆?
4
+ 鍏堝畨瑁?skill pack锛屽啀閲嶅惎 Codex锛屽懡浠ゆ墠浼氱敓鏁堛€?
5
+
6
+ ## Commands
7
+
8
+ - `/spec-refinement` -> `spec-refinement`
9
+ - `/design` -> `technical-design`
10
+ - `/build` -> `feature-build`
11
+ - `/review` -> `code-review`
12
+ - `/security` -> `security-audit`
13
+ - `/perf` -> `performance-audit`
14
+ - `/test` -> `test-design`
15
+ - `/doc` -> `api-contract-docs`
16
+ - `/distill` -> `domain-modeling`
17
+ - `/workflow` -> `workflow-router`
18
+ - `/kb` -> `knowledge-capture`
19
+ - `/init` -> `project-bootstrap`
20
+ - `/infra` -> `environment-deploy`
21
+
22
+ 杩欎簺鍛戒护椤典繚鎸佺煭灏忥紝鏄负浜嗚 Codex 鏇村揩瀹氫綅鍒版纭殑 skill銆?
23
+
@@ -0,0 +1,22 @@
1
+ # /analyze
2
+
3
+ 鎶婂凡缁忕‘璁ょ殑闇€姹傛敹鏁涙垚鐮斿彂鍙墽琛岀殑瑙勬牸銆?
4
+
5
+ ## Route
6
+
7
+ - 瀵瑰簲 skill锛歚spec-refinement`
8
+ - 閫傜敤锛氶渶姹傛媶瑙c€佽竟鐣屾⒊鐞嗐€佷緷璧栫‘璁ゃ€侀獙鏀舵爣鍑嗚ˉ鍏?
9
+ - 涓嶉€傜敤锛氳繕娌℃敹鍙g殑浜у搧璁ㄨ
10
+
11
+ ## Workflow
12
+
13
+ 1. 鍏堢‘璁よ緭鍏ュ凡缁忔敹鏁涘埌鍙墽琛岃鏍笺€?
14
+ 2. 鎶婄洰鏍囥€佽竟鐣屻€佷緷璧栥€佺害鏉熷拰楠屾敹鏉′欢鏁寸悊鎴愬彲鎵ц瑙勬牸銆?
15
+ 3. 杈撳嚭鐮斿彂鍒嗘瀽缁撴灉锛屾槑纭悗缁疄鐜版墍闇€杈撳叆銆?
16
+ 4. 蹇呰鏃朵氦缁?`technical-design` 鎴?`knowledge-capture`銆?
17
+
18
+ ## Guardrails
19
+
20
+ - 涓嶇洿鎺ュ啓瀹炵幇浠g爜銆?
21
+ - 涓嶆妸鏈‘璁ゅ亣璁惧綋缁撹銆?
22
+
@@ -0,0 +1,22 @@
1
+ # /build
2
+
3
+ 鎸夋柟妗堣鑼冨疄鐜板凡缁忔敹鍙g殑闇€姹傘€?
4
+
5
+ ## Route
6
+
7
+ - 瀵瑰簲 skill锛歚feature-build`
8
+ - 閫傜敤锛氬紑鍙戝疄鐜般€佸閲忔敼閫犮€佹帴鍙h仈鍔ㄣ€佽惤鍦颁唬鐮?
9
+ - 涓嶉€傜敤锛氶渶姹傝繕娌℃敹鍙o紝鎴栬€呰璁¤繕娌$ǔ瀹?
10
+
11
+ ## Workflow
12
+
13
+ 1. 鍏堢‘璁よ緭鍏ユ潵鑷?`spec-refinement` 鎴?`technical-design`銆?
14
+ 2. 鎸夊垎灞傘€佷簨鍔″拰杩斿洖鍊艰鑼冨疄鐜般€?
15
+ 3. 淇濇寔鏀瑰姩鏈€灏忥紝浼樺厛鍙獙璇併€?
16
+ 4. 浜ょ粰 `test-design` 鍜?`code-review` 鏀跺彛銆?
17
+
18
+ ## Guardrails
19
+
20
+ - 涓嶇粫杩囨灦鏋勭害鏉熴€?
21
+ - 涓嶆妸涓存椂淇ˉ褰撲綔鏈€缁堝疄鐜般€?
22
+
@@ -0,0 +1,22 @@
1
+ # /design
2
+
3
+ 鎶婂凡缁忔敹鍙g殑闇€姹傝ˉ鎴愬彲瀹炵幇鐨勬妧鏈柟妗堛€?
4
+
5
+ ## Route
6
+
7
+ - 瀵瑰簲 skill锛歚technical-design`
8
+ - 閫傜敤锛氭灦鏋勯€夊瀷銆佹ā鍧楁媶鍒嗐€佹帴鍙h璁°€佹暟鎹祦璁捐銆佸疄鐜板墠琛ュ厖璁捐
9
+ - 涓嶉€傜敤锛氬皻鏈敹鍙g殑闇€姹傝璁?
10
+
11
+ ## Workflow
12
+
13
+ 1. 璇诲彇 `spec-refinement` 鐨勭粨璁恒€?
14
+ 2. 鎷嗗垎妯″潡銆佹帴鍙c€佹暟鎹粨鏋勩€佷簨鍔¤竟鐣屽拰寮傚父璺緞銆?
15
+ 3. 杈撳嚭鏂规鑽夊浘銆佸叧閿喅绛栧拰钀藉湴椤哄簭銆?
16
+ 4. 缁?`feature-build` 鍑嗗瀹炵幇杈撳叆銆?
17
+
18
+ ## Guardrails
19
+
20
+ - 涓嶉噸鏂板彂鏁i渶姹傝寖鍥淬€?
21
+ - 涓嶈烦杩囨灦鏋勭害鏉熺洿鎺ュ啓瀹炵幇銆?
22
+
@@ -0,0 +1,21 @@
1
+ # /distill
2
+
3
+ 把业务事实提炼成可复用的领域知识。
4
+
5
+ ## Route
6
+
7
+ - 对应 skill:`domain-modeling`
8
+ - 适用:领域边界、实体关系、核心概念、规则沉淀
9
+ - 不适用:纯接口变更说明
10
+
11
+ ## Workflow
12
+
13
+ 1. 识别业务对象、边界和核心规则。
14
+ 2. 抽取实体、关系、状态和约束。
15
+ 3. 输出可复用的领域索引和冲突点。
16
+ 4. 不把命名本身当作领域模型。
17
+
18
+ ## Guardrails
19
+
20
+ - 不忽略规则冲突。
21
+ - 不把实现细节冒充领域知识。
@@ -0,0 +1,22 @@
1
+ # /doc
2
+
3
+ 鎶婃帴鍙e拰鍙樻洿鏁寸悊鎴愬彲瀵规帴鐨勬枃妗c€?
4
+
5
+ ## Route
6
+
7
+ - 瀵瑰簲 skill锛歚api-contract-docs`
8
+ - 閫傜敤锛氭帴鍙h鏄庛€佸彉鏇磋鏄庛€佽仈璋冭鏄庛€佸悓姝ユ枃妗?
9
+ - 涓嶉€傜敤锛氱函浠g爜瀹℃煡
10
+
11
+ ## Workflow
12
+
13
+ 1. 鍏堢‘璁ゆ帴鍙h竟鐣屽拰杈撳叆杈撳嚭銆?
14
+ 2. 鎻愮偧璇锋眰銆佸搷搴斻€侀敊璇爜鍜岃皟鐢ㄩ『搴忋€?
15
+ 3. 杈撳嚭鍙仈璋冪殑鏂囨。鑽夋銆?
16
+ 4. 鍙樻洿鍚庡悓姝ュ埌鐭ヨ瘑娌夋穩銆?
17
+
18
+ ## Guardrails
19
+
20
+ - 涓嶉仐婕忛敊璇繑鍥炲拰绾︽潫銆?
21
+ - 涓嶆妸绌烘硾璇存槑褰撴垚鏂囨。浜や粯銆?
22
+
@@ -0,0 +1,21 @@
1
+ # /infra
2
+
3
+ 准备或管理开发依赖的基础设施。
4
+
5
+ ## Route
6
+
7
+ - 对应 skill:`environment-deploy`
8
+ - 适用:Docker Compose、依赖服务启动、开发联调环境准备
9
+ - 不适用:业务需求分析
10
+
11
+ ## Workflow
12
+
13
+ 1. 识别需要启动的基础设施组件。
14
+ 2. 只拉起最小可用组合。
15
+ 3. 输出启动状态和常见失败点。
16
+ 4. 不把生产部署和本地开发混在一起。
17
+
18
+ ## Guardrails
19
+
20
+ - 不默认启动多余服务。
21
+ - 不混淆生产环境和本地环境。
@@ -0,0 +1,20 @@
1
+ # /init
2
+
3
+ 初始化项目或模块脚手架。
4
+
5
+ ## Route
6
+
7
+ - 对应 skill:`project-bootstrap`
8
+ - 适用:新建项目、模块初始化、标准目录生成
9
+ - 不适用:业务分析
10
+
11
+ ## Workflow
12
+
13
+ 1. 确认初始化对象是项目还是模块。
14
+ 2. 生成标准目录、基础配置和依赖边界。
15
+ 3. 输出后续应该进入的 skill。
16
+ 4. 不触碰具体业务逻辑。
17
+
18
+ ## Guardrails
19
+
20
+ - 不跳过基础配置检查。
@@ -0,0 +1,20 @@
1
+ # /kb
2
+
3
+ 把项目事实整理成可检索、可复用、可过期治理的知识中心。
4
+
5
+ ## Route
6
+
7
+ - 对应 skill:`knowledge-capture`
8
+ - 适用:项目概览、模块索引、领域知识、方案沉淀、交接归档
9
+
10
+ ## Workflow
11
+
12
+ 1. 收集事实、来源、适用场景和限制条件。
13
+ 2. 分类沉淀到项目、模块、领域、方案或协作索引。
14
+ 3. 标明哪些内容可复用,哪些内容应过期清理。
15
+ 4. 让归档结果反哺后续分析和实现。
16
+
17
+ ## Guardrails
18
+
19
+ - 不堆文档。
20
+ - 不把未经验证的信息当知识沉淀。
@@ -0,0 +1,21 @@
1
+ # /perf
2
+
3
+ 妫€鏌ユ€ц兘鐑偣銆佺摱棰堝拰鍥炲綊椋庨櫓銆?
4
+
5
+ ## Route
6
+
7
+ - 瀵瑰簲 skill锛歚performance-audit`
8
+ - 閫傜敤锛歂+1銆佺紦瀛樸€佺储寮曘€佹壒閲忔搷浣溿€佺儹鐐硅矾寰?
9
+ - 涓嶉€傜敤锛氱函瀹夊叏瀹℃煡鎴栫函闇€姹傝璁?
10
+
11
+ ## Workflow
12
+
13
+ 1. 鎵惧嚭楂橀璺緞鍜屽ぇ鏁版嵁閲忚矾寰勩€?
14
+ 2. 妫€鏌ユ暟鎹簱璁块棶銆佺紦瀛樺懡涓€佸惊鐜皟鐢ㄥ拰鎵瑰鐞嗐€?
15
+ 3. 杈撳嚭鍙獙璇佺殑鎬ц兘椋庨櫓鍜屼紭鍖栭『搴忋€?
16
+ 4. 蹇呰鏃朵氦缁?`code-review` 鎴?`feature-build`銆?
17
+
18
+ ## Guardrails
19
+
20
+ - 涓嶇敤娉涙硾寤鸿鏇夸唬瀹氫綅缁撹銆?
21
+
@@ -0,0 +1,22 @@
1
+ # /prd
2
+
3
+ 鎶婁骇鍝佹剰鍥炬敹鍙f垚缁欑爺鍙戝垎鏋愪娇鐢ㄧ殑闇€姹傝緭鍏ャ€?
4
+
5
+ ## Route
6
+
7
+ - 瀵瑰簲 skill锛歚spec-refinement`
8
+ - 閫傜敤锛氫骇鍝佺洰鏍囥€佷笟鍔¤儗鏅€佽寖鍥磋鍓€佷紭鍏堢骇銆侀獙鏀跺彛寰勩€侀渶姹傚垵绋?
9
+ - 涓嶉€傜敤锛氬凡缁忚繘鍏ュ疄鐜扮粏鑺傜殑鐮斿彂鍒嗘瀽
10
+
11
+ ## Workflow
12
+
13
+ 1. 鍏堢‘璁よ繖鏄骇鍝佷晶闇€姹傦紝涓嶇洿鎺ヨ繘鍏ヨ璁℃垨缂栫爜銆?
14
+ 2. 鏀堕泦鐩爣銆佽寖鍥淬€佺害鏉熴€佷紭鍏堢骇鍜岄獙鏀舵爣鍑嗐€?
15
+ 3. 杈撳嚭缁撴瀯鍖栫殑 PRD-ready brief銆?
16
+ 4. 浜ょ粰 `technical-design`銆?
17
+
18
+ ## Guardrails
19
+
20
+ - 涓嶆浛浠g爺鍙戦渶姹傚垎鏋愩€?
21
+ - 涓嶈烦杩囬渶姹傛敹鍙g洿鎺ュ啓鏈€缁堢粨璁恒€?
22
+
@@ -0,0 +1,22 @@
1
+ # /review
2
+
3
+ 瀹℃煡浠g爜鍙樻洿銆佽川閲忛闄╁拰璺ㄦā鍧楀奖鍝嶃€?
4
+
5
+ ## Route
6
+
7
+ - 瀵瑰簲 skill锛歚code-review`
8
+ - 閫傜敤锛歅R 瀹℃煡銆乨iff 瀹℃牳銆佷笂绾垮墠妫€鏌ャ€佹鏋惰鑼冩牳瀵?
9
+ - 涓嶉€傜敤锛氱函闇€姹傝璁?
10
+
11
+ ## Workflow
12
+
13
+ 1. 鍏堢‘璁ゅ彉鏇磋寖鍥达紝涓嶅彧鐪嬪崟鏂囦欢銆?
14
+ 2. 鏍稿鏋舵瀯銆佽竟鐣屻€佸洖褰掗闄╁拰绾︽潫銆?
15
+ 3. 杈撳嚭闂绾у埆銆侀闄╁拰淇寤鸿銆?
16
+ 4. 蹇呰鏃惰ˉ `security-audit` 鎴?`performance-audit`銆?
17
+
18
+ ## Guardrails
19
+
20
+ - 鍙鏌ュ凡缁忓彂鐢熺殑鍙樻洿銆?
21
+ - 涓嶈烦杩囪瘉鎹洿鎺ヤ笅缁撹銆?
22
+
@@ -0,0 +1,22 @@
1
+ # /security
2
+
3
+ 瀹℃煡瀹夊叏椋庨櫓銆佹潈闄愯竟鐣屽拰鏁忔劅鏁版嵁鏆撮湶銆?
4
+
5
+ ## Route
6
+
7
+ - 瀵瑰簲 skill锛歚security-audit`
8
+ - 閫傜敤锛氬畨鍏ㄥ鏌ャ€佹潈闄愭鏌ャ€佹暟鎹毚闇叉鏌ャ€佸悎瑙勯闄╂鏌?
9
+ - 涓嶉€傜敤锛氭櫘閫氶渶姹傝璁?
10
+
11
+ ## Workflow
12
+
13
+ 1. 鍏堢‘璁よ緭鍏ユ槸宸茬粡鍙戠敓鐨勫彉鏇存垨鍙鏌ョ殑鏂规銆?
14
+ 2. 鎷嗗垎鎺ュ彛銆佹潈闄愩€佹暟鎹祦鍚戝拰鏁忔劅淇℃伅椋庨櫓銆?
15
+ 3. 杈撳嚭瀹夊叏鍙戠幇銆佷紭鍏堢骇鍜屼慨澶嶅缓璁€?
16
+ 4. 蹇呰鏃朵氦缁?`knowledge-capture` 鎴?`feature-build`銆?
17
+
18
+ ## Guardrails
19
+
20
+ - 涓嶇洿鎺ヤ慨鏀圭敓浜т唬鐮併€?
21
+ - 涓嶆妸涓€鑸川閲忛棶棰樿鍒ゆ垚瀹夊叏缁撹銆?
22
+
@@ -0,0 +1,21 @@
1
+ # /test
2
+
3
+ 把验收标准转成可执行的测试设计。
4
+
5
+ ## Route
6
+
7
+ - 对应 skill:`test-design`
8
+ - 适用:测试策略、用例设计、回归矩阵、验证路径
9
+ - 不适用:需求还不明确,或者只是想“快速跑一下”
10
+
11
+ ## Workflow
12
+
13
+ 1. 先确认验收标准或实现结果。
14
+ 2. 转成测试策略、用例、回归和边界场景。
15
+ 3. 输出可执行的验证方案。
16
+ 4. 必要时交给 `code-review` 或 `feature-build`。
17
+
18
+ ## Guardrails
19
+
20
+ - 不跳过前置条件。
21
+ - 不把“跑过一次”当作完整验证。
@@ -0,0 +1,20 @@
1
+ # /workflow
2
+
3
+ 按阶段路由到正确的 skill,并控制阶段切换。
4
+
5
+ ## Route
6
+
7
+ - 适用:多阶段任务、跨 skill 协作、门禁控制、阶段切换
8
+ - 不适用:单一步骤的小任务
9
+
10
+ ## Workflow
11
+
12
+ 1. 判断当前处于哪个生命周期阶段。
13
+ 2. 选择当前 skill 或下一步 skill。
14
+ 3. 如果门禁失败,暂停下游并说明原因。
15
+ 4. 记录下一步应该走哪个 skill。
16
+
17
+ ## Guardrails
18
+
19
+ - 不替用户决定跳过阶段。
20
+ - 不让下游覆盖上游未确认结果。
package/install.cmd CHANGED
@@ -1,5 +1,5 @@
1
- @echo off
2
- setlocal
3
- set "SCRIPT_DIR=%~dp0"
4
- powershell -NoProfile -ExecutionPolicy Bypass -File "%SCRIPT_DIR%install.ps1" %*
5
- exit /b %ERRORLEVEL%
1
+ @echo off
2
+ setlocal
3
+ set "SCRIPT_DIR=%~dp0"
4
+ powershell -NoProfile -ExecutionPolicy Bypass -File "%SCRIPT_DIR%install.ps1" %*
5
+ exit /b %ERRORLEVEL%
package/install.ps1 CHANGED
@@ -1,74 +1,30 @@
1
- param(
2
- [switch]$SkipRuntimeBootstrap,
3
- [switch]$SkipPostInstallSync
4
- )
5
-
6
- $ErrorActionPreference = 'Stop'
7
-
8
- function Write-Info([string]$Message) {
9
- Write-Host $Message
10
- }
11
-
12
- function Write-Warn([string]$Message) {
13
- Write-Warning $Message
14
- }
15
-
16
- function Test-Command([string]$Name) {
17
- return [bool](Get-Command $Name -ErrorAction SilentlyContinue)
18
- }
19
-
20
- function Ensure-NodeRuntime {
21
- if (Test-Command npm) {
22
- return
23
- }
24
-
25
- if ($SkipRuntimeBootstrap -or $env:PIG_SKILLS_SKIP_RUNTIME_BOOTSTRAP -match '^(1|true|yes)$') {
26
- throw 'npm is not available and runtime bootstrap is disabled. Install Node.js LTS first, then rerun.'
27
- }
28
-
29
- if (-not (Test-Command winget)) {
30
- throw 'npm is not available and winget is missing. Install Node.js LTS manually, then rerun.'
31
- }
32
-
33
- Write-Info 'npm is missing. Installing Node.js LTS via winget...'
34
- & winget install --id OpenJS.NodeJS.LTS -e --source winget --accept-package-agreements --accept-source-agreements --silent --disable-interactivity | Out-Null
35
- if ($LASTEXITCODE -ne 0) {
36
- throw "winget install failed with exit code $LASTEXITCODE"
37
- }
38
-
39
- $programFilesX86 = [Environment]::GetEnvironmentVariable('ProgramFiles(x86)')
40
- $nodeDirCandidates = @(
41
- Join-Path $env:ProgramFiles 'nodejs',
42
- if ($programFilesX86) { Join-Path $programFilesX86 'nodejs' },
43
- Join-Path $env:LocalAppData 'Programs\nodejs',
44
- Join-Path $env:LocalAppData 'Microsoft\WinGet\Links'
45
- ) | Where-Object { $_ -and (Test-Path $_) }
46
-
47
- foreach ($candidate in $nodeDirCandidates) {
48
- if (-not (($env:PATH -split ';') -contains $candidate)) {
49
- $env:PATH = "$candidate;$env:PATH"
50
- }
51
- }
52
-
53
- if (-not (Test-Command npm)) {
54
- throw 'Node.js was installed, but npm is still not visible in this shell. Restart the shell and rerun.'
55
- }
56
- }
57
-
58
- function Install-Package {
59
- $repoRoot = (Resolve-Path -LiteralPath $PSScriptRoot).Path
60
- $npmArgs = @('install', '-g', $repoRoot)
61
- if ($SkipPostInstallSync) {
62
- $env:PIG_SKILLS_SKIP_AUTO_SYNC = '1'
63
- }
64
-
65
- Write-Info "Installing Pig Skills from $repoRoot ..."
66
- & npm @npmArgs
67
- if ($LASTEXITCODE -ne 0) {
68
- throw "npm install failed with exit code $LASTEXITCODE"
69
- }
70
- }
71
-
72
- Ensure-NodeRuntime
73
- Install-Package
74
- Write-Info 'Pig Skills installation complete.'
1
+ param(
2
+ [switch]$SkipPostInstallSync
3
+ )
4
+
5
+ $ErrorActionPreference = 'Stop'
6
+
7
+ function Write-Info([string]$Message) {
8
+ Write-Host $Message
9
+ }
10
+
11
+ function Test-Command([string]$Name) {
12
+ return [bool](Get-Command $Name -ErrorAction SilentlyContinue)
13
+ }
14
+
15
+ if (-not (Test-Command npm)) {
16
+ throw 'npm is not available. Install Node.js LTS first, then rerun.'
17
+ }
18
+
19
+ $repoRoot = (Resolve-Path -LiteralPath $PSScriptRoot).Path
20
+ if ($SkipPostInstallSync -or $env:PIG_SKILLS_SKIP_AUTO_SYNC -match '^(1|true|yes)$') {
21
+ $env:PIG_SKILLS_SKIP_AUTO_SYNC = '1'
22
+ }
23
+
24
+ Write-Info "Installing Pig Skills from $repoRoot ..."
25
+ & npm install -g $repoRoot
26
+ if ($LASTEXITCODE -ne 0) {
27
+ throw "npm install failed with exit code $LASTEXITCODE"
28
+ }
29
+
30
+ Write-Info 'Pig Skills installation complete.'
package/install.sh CHANGED
@@ -1,168 +1,36 @@
1
- #!/usr/bin/env bash
2
- set -euo pipefail
3
-
4
- SCRIPT_DIR="$(cd "$(dirname "${BASH_SOURCE[0]}")" && pwd)"
5
- REPO_ROOT="$SCRIPT_DIR"
6
- SKIP_RUNTIME_BOOTSTRAP="${PIG_SKILLS_SKIP_RUNTIME_BOOTSTRAP:-0}"
7
- SKIP_POSTINSTALL_SYNC="${PIG_SKILLS_SKIP_AUTO_SYNC:-0}"
8
-
9
- for arg in "$@"; do
10
- case "$arg" in
11
- --skip-runtime-bootstrap)
12
- SKIP_RUNTIME_BOOTSTRAP=1
13
- ;;
14
- --skip-postinstall-sync)
15
- SKIP_POSTINSTALL_SYNC=1
16
- ;;
17
- esac
18
- done
19
-
20
- log() {
21
- printf '%s\n' "$1"
22
- }
23
-
24
- warn() {
25
- printf '%s\n' "$1" >&2
26
- }
27
-
28
- has_command() {
29
- command -v "$1" >/dev/null 2>&1
30
- }
31
-
32
- is_true() {
33
- case "${1:-}" in
34
- 1|true|TRUE|yes|YES) return 0 ;;
35
- *) return 1 ;;
36
- esac
37
- }
38
-
39
- run_privileged() {
40
- if [ "$(id -u)" -eq 0 ]; then
41
- "$@"
42
- return
43
- fi
44
-
45
- if has_command sudo; then
46
- sudo "$@"
47
- return
48
- fi
49
-
50
- die "Command requires elevated privileges: $*"
51
- }
52
-
53
- die() {
54
- warn "$1"
55
- exit 1
56
- }
57
-
58
- bootstrap_with_nvm() {
59
- if ! has_command curl; then
60
- die "curl is required to bootstrap Node.js via nvm."
61
- fi
62
- if ! has_command git; then
63
- die "git is required to bootstrap Node.js via nvm."
64
- fi
65
-
66
- export NVM_DIR="${NVM_DIR:-$HOME/.nvm}"
67
- if [ ! -s "$NVM_DIR/nvm.sh" ]; then
68
- log "npm is missing. Installing nvm and Node.js LTS..."
69
- mkdir -p "$NVM_DIR"
70
- tmp_install_script="$(mktemp "${TMPDIR:-/tmp}/pig-skills-nvm.XXXXXX")"
71
- curl -fsSL https://raw.githubusercontent.com/nvm-sh/nvm/v0.40.3/install.sh -o "$tmp_install_script"
72
- bash "$tmp_install_script"
73
- rm -f "$tmp_install_script"
74
- fi
75
-
76
- # shellcheck disable=SC1090
77
- [ -s "$NVM_DIR/nvm.sh" ] && . "$NVM_DIR/nvm.sh"
78
- # shellcheck disable=SC1091
79
- [ -s "$NVM_DIR/bash_completion" ] && . "$NVM_DIR/bash_completion"
80
- nvm install --lts
81
- nvm use --lts
82
- }
83
-
84
- bootstrap_on_macos() {
85
- if has_command brew; then
86
- log "npm is missing. Installing Node.js via Homebrew..."
87
- brew install node
88
- return
89
- fi
90
-
91
- bootstrap_with_nvm
92
- }
93
-
94
- bootstrap_on_linux() {
95
- if has_command apt-get; then
96
- log "npm is missing. Installing Node.js via apt..."
97
- run_privileged apt-get update
98
- run_privileged apt-get install -y nodejs npm
99
- return
100
- fi
101
-
102
- if has_command dnf; then
103
- log "npm is missing. Installing Node.js via dnf..."
104
- run_privileged dnf install -y nodejs npm
105
- return
106
- fi
107
-
108
- if has_command yum; then
109
- log "npm is missing. Installing Node.js via yum..."
110
- run_privileged yum install -y nodejs npm
111
- return
112
- fi
113
-
114
- if has_command pacman; then
115
- log "npm is missing. Installing Node.js via pacman..."
116
- run_privileged pacman -Sy --noconfirm nodejs npm
117
- return
118
- fi
119
-
120
- if has_command zypper; then
121
- log "npm is missing. Installing Node.js via zypper..."
122
- run_privileged zypper --non-interactive install nodejs npm
123
- return
124
- fi
125
-
126
- if has_command apk; then
127
- log "npm is missing. Installing Node.js via apk..."
128
- run_privileged apk add nodejs npm
129
- return
130
- fi
131
-
132
- bootstrap_with_nvm
133
- }
134
-
135
- ensure_node_runtime() {
136
- if has_command npm; then
137
- return
138
- fi
139
-
140
- if is_true "$SKIP_RUNTIME_BOOTSTRAP"; then
141
- die "npm is not available and runtime bootstrap is disabled. Install Node.js LTS first, then rerun."
142
- fi
143
-
144
- case "$(uname -s)" in
145
- Darwin) bootstrap_on_macos ;;
146
- Linux) bootstrap_on_linux ;;
147
- *)
148
- die "Unsupported platform for automatic bootstrap. Install Node.js LTS manually, then rerun."
149
- ;;
150
- esac
151
-
152
- if ! has_command npm; then
153
- die "Node.js was installed, but npm is still not visible in this shell. Restart the shell and rerun."
154
- fi
155
- }
156
-
157
- install_package() {
158
- log "Installing Pig Skills from $REPO_ROOT ..."
159
- if is_true "$SKIP_POSTINSTALL_SYNC"; then
160
- PIG_SKILLS_SKIP_AUTO_SYNC=1 npm install -g "$REPO_ROOT"
161
- else
162
- npm install -g "$REPO_ROOT"
163
- fi
164
- }
165
-
166
- ensure_node_runtime
167
- install_package
168
- log "Pig Skills installation complete."
1
+ #!/usr/bin/env bash
2
+ set -euo pipefail
3
+
4
+ SCRIPT_DIR="$(cd "$(dirname "${BASH_SOURCE[0]}")" && pwd)"
5
+ REPO_ROOT="$SCRIPT_DIR"
6
+ SKIP_POSTINSTALL_SYNC="${PIG_SKILLS_SKIP_AUTO_SYNC:-0}"
7
+
8
+ for arg in "$@"; do
9
+ case "$arg" in
10
+ --skip-postinstall-sync)
11
+ SKIP_POSTINSTALL_SYNC=1
12
+ ;;
13
+ esac
14
+ done
15
+
16
+ log() {
17
+ printf '%s\n' "$1"
18
+ }
19
+
20
+ die() {
21
+ printf '%s\n' "$1" >&2
22
+ exit 1
23
+ }
24
+
25
+ if ! command -v npm >/dev/null 2>&1; then
26
+ die 'npm is not available. Install Node.js LTS first, then rerun.'
27
+ fi
28
+
29
+ log "Installing Pig Skills from $REPO_ROOT ..."
30
+ if [ "$SKIP_POSTINSTALL_SYNC" = "1" ] || [ "${SKIP_POSTINSTALL_SYNC,,}" = "true" ] || [ "${SKIP_POSTINSTALL_SYNC,,}" = "yes" ]; then
31
+ PIG_SKILLS_SKIP_AUTO_SYNC=1 npm install -g "$REPO_ROOT"
32
+ else
33
+ npm install -g "$REPO_ROOT"
34
+ fi
35
+
36
+ log 'Pig Skills installation complete.'
package/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "@pigcloud/skills",
3
- "version": "1.0.7",
3
+ "version": "1.0.9",
4
4
  "description": "面向 Codex、Trae 和 Claude Code 的 AI 技能包,提供共享技能、规则约束、工作流路由和 Pig Cloud 专属覆盖层。",
5
5
  "author": "Pig Skills Maintainers",
6
6
  "license": "MIT",
@@ -34,7 +34,7 @@
34
34
  "install.cmd",
35
35
  "install.ps1",
36
36
  "install.sh",
37
- "pig-cloud-skills-commands/",
37
+ "codex-commands/",
38
38
  "rules/",
39
39
  "skills/",
40
40
  "scripts/",
@@ -1,121 +0,0 @@
1
- #!/usr/bin/env node
2
-
3
- const fs = require('fs');
4
- const path = require('path');
5
- const { spawnSync } = require('child_process');
6
-
7
- const NPM_CANDIDATES = process.platform === 'win32'
8
- ? [
9
- path.join(process.env.ProgramFiles || 'C:\\Program Files', 'nodejs', 'npm.cmd'),
10
- path.join(process.env['ProgramFiles(x86)'] || 'C:\\Program Files (x86)', 'nodejs', 'npm.cmd'),
11
- path.join(process.env.LocalAppData || '', 'Programs', 'nodejs', 'npm.cmd'),
12
- path.join(process.env.LocalAppData || '', 'Microsoft', 'WinGet', 'Links', 'npm.cmd')
13
- ]
14
- : [];
15
-
16
- function commandAvailable(command) {
17
- const result = spawnSync(command, ['--version'], { stdio: 'ignore' });
18
- return !result.error && result.status === 0;
19
- }
20
-
21
- function findInstalledNpm() {
22
- for (const candidate of NPM_CANDIDATES) {
23
- if (candidate && fs.existsSync(candidate)) {
24
- return candidate;
25
- }
26
- }
27
- return null;
28
- }
29
-
30
- function refreshPathFromNpm(npmPath) {
31
- if (!npmPath) return;
32
- const npmDir = path.dirname(npmPath);
33
- const currentPath = String(process.env.PATH || '');
34
- const parts = currentPath.split(path.delimiter).filter(Boolean);
35
- if (!parts.some((part) => part.toLowerCase() === npmDir.toLowerCase())) {
36
- process.env.PATH = [npmDir, ...parts].join(path.delimiter);
37
- }
38
- }
39
-
40
- function installNodeJsWithWinget() {
41
- const args = [
42
- 'install',
43
- '--id',
44
- 'OpenJS.NodeJS.LTS',
45
- '-e',
46
- '--source',
47
- 'winget',
48
- '--accept-package-agreements',
49
- '--accept-source-agreements',
50
- '--silent',
51
- '--disable-interactivity'
52
- ];
53
-
54
- const result = spawnSync('winget', args, {
55
- encoding: 'utf8',
56
- stdio: ['ignore', 'pipe', 'pipe']
57
- });
58
-
59
- if (result.error) {
60
- throw new Error(`Failed to launch winget: ${result.error.message}`);
61
- }
62
-
63
- if (result.status !== 0) {
64
- const message = [result.stdout, result.stderr]
65
- .filter(Boolean)
66
- .map((text) => String(text).trim())
67
- .filter(Boolean)
68
- .join('\n');
69
- throw new Error(message || `winget exited with code ${result.status}`);
70
- }
71
- }
72
-
73
- async function ensureNpmRuntime(options = {}) {
74
- const skip = ['1', 'true', 'yes'].includes(String(process.env.PIG_SKILLS_SKIP_RUNTIME_BOOTSTRAP || '').toLowerCase());
75
- if (skip) {
76
- return { installed: false, skipped: true, npmPath: commandAvailable('npm') ? 'npm' : null };
77
- }
78
-
79
- if (commandAvailable('npm')) {
80
- return { installed: false, skipped: false, npmPath: 'npm' };
81
- }
82
-
83
- if (process.platform !== 'win32') {
84
- throw new Error(
85
- 'npm is not available in PATH. Install Node.js 20+ first, then rerun the skill installer.'
86
- );
87
- }
88
-
89
- if (!commandAvailable('winget')) {
90
- throw new Error(
91
- 'npm is not available and winget is not installed. Install Node.js LTS manually, then rerun the skill installer.'
92
- );
93
- }
94
-
95
- if (!options.quiet) {
96
- process.stdout.write('npm is missing. Installing Node.js LTS through winget...\n');
97
- }
98
-
99
- installNodeJsWithWinget();
100
-
101
- const npmPath = findInstalledNpm();
102
- refreshPathFromNpm(npmPath);
103
-
104
- if (!npmPath && !commandAvailable('npm')) {
105
- throw new Error(
106
- 'Node.js was installed, but npm is still not visible in this shell. Restart the shell and rerun the skill installer.'
107
- );
108
- }
109
-
110
- return {
111
- installed: true,
112
- skipped: false,
113
- npmPath: npmPath || 'npm'
114
- };
115
- }
116
-
117
- module.exports = {
118
- ensureNpmRuntime,
119
- commandAvailable,
120
- findInstalledNpm
121
- };