prizmkit 1.1.188 → 1.1.189
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/create-prizmkit.js +1 -1
- package/bundled/VERSION.json +3 -3
- package/bundled/skills/_metadata.json +1 -1
- package/package.json +1 -1
- package/src/scaffold.js +250 -96
- package/src/upgrade.js +33 -1
package/bin/create-prizmkit.js
CHANGED
|
@@ -46,7 +46,7 @@ program
|
|
|
46
46
|
.option('--ai-cli <command>', 'AI CLI executable command (e.g. cbc, claude, codex, pi, agent)')
|
|
47
47
|
.option('--headless-prompt-arg <arg>', 'Prompt injection argv token for a custom AI CLI (e.g. -p or -i)')
|
|
48
48
|
.option('--headless-extra-args <args>', 'Additional headless argv tokens for a custom AI CLI')
|
|
49
|
-
.option('--external-skills <names>', 'Comma-separated external skill names to install (e.g. find-skills,
|
|
49
|
+
.option('--external-skills <names>', 'Comma-separated external skill names to install (e.g. find-skills,frontend-design)')
|
|
50
50
|
.option('--non-interactive', 'Skip interactive prompts (requires --platform)')
|
|
51
51
|
.option('--dry-run', 'Show what would be created without making changes')
|
|
52
52
|
.action(async (directory = '.', options) => {
|
package/bundled/VERSION.json
CHANGED
package/package.json
CHANGED
package/src/scaffold.js
CHANGED
|
@@ -1418,6 +1418,137 @@ export async function installGitignore(projectRoot, options = {}, dryRun) {
|
|
|
1418
1418
|
// ============================================================
|
|
1419
1419
|
|
|
1420
1420
|
const PLAYWRIGHT_SKILL_NAME = 'playwright-cli';
|
|
1421
|
+
const PLAYWRIGHT_CLI_PACKAGE = '@playwright/cli';
|
|
1422
|
+
|
|
1423
|
+
function parseVersion(value) {
|
|
1424
|
+
const match = String(value || '').match(/(\d+)\.(\d+)\.(\d+)(?:-([0-9A-Za-z.-]+))?/);
|
|
1425
|
+
if (!match) return null;
|
|
1426
|
+
return {
|
|
1427
|
+
core: [Number(match[1]), Number(match[2]), Number(match[3])],
|
|
1428
|
+
prerelease: match[4] || '',
|
|
1429
|
+
};
|
|
1430
|
+
}
|
|
1431
|
+
|
|
1432
|
+
/**
|
|
1433
|
+
* Compare two semantic versions. Returns -1, 0, or 1, or null when unparsable.
|
|
1434
|
+
*/
|
|
1435
|
+
function compareVersions(left, right) {
|
|
1436
|
+
const a = parseVersion(left);
|
|
1437
|
+
const b = parseVersion(right);
|
|
1438
|
+
if (!a || !b) return null;
|
|
1439
|
+
for (let i = 0; i < a.core.length; i += 1) {
|
|
1440
|
+
if (a.core[i] !== b.core[i]) return a.core[i] < b.core[i] ? -1 : 1;
|
|
1441
|
+
}
|
|
1442
|
+
if (a.prerelease === b.prerelease) return 0;
|
|
1443
|
+
if (!a.prerelease) return 1;
|
|
1444
|
+
if (!b.prerelease) return -1;
|
|
1445
|
+
return a.prerelease < b.prerelease ? -1 : 1;
|
|
1446
|
+
}
|
|
1447
|
+
|
|
1448
|
+
function readInstalledPlaywrightCliVersion() {
|
|
1449
|
+
try {
|
|
1450
|
+
return String(execSync('playwright-cli --version', { stdio: 'pipe', timeout: 20000 })).trim() || null;
|
|
1451
|
+
} catch {
|
|
1452
|
+
return null;
|
|
1453
|
+
}
|
|
1454
|
+
}
|
|
1455
|
+
|
|
1456
|
+
function readLatestNpmVersion(packageName) {
|
|
1457
|
+
try {
|
|
1458
|
+
const output = String(execSync(`npm view ${packageName} version`, { stdio: 'pipe', timeout: 30000 })).trim();
|
|
1459
|
+
return output.split('\n').pop().trim() || null;
|
|
1460
|
+
} catch {
|
|
1461
|
+
return null;
|
|
1462
|
+
}
|
|
1463
|
+
}
|
|
1464
|
+
|
|
1465
|
+
function readGlobalNpmPackageVersion(packageName) {
|
|
1466
|
+
try {
|
|
1467
|
+
const output = String(execSync(`npm ls -g ${packageName} --depth=0 --json`, { stdio: 'pipe', timeout: 30000 }));
|
|
1468
|
+
const parsed = JSON.parse(output);
|
|
1469
|
+
return parsed?.dependencies?.[packageName]?.version || null;
|
|
1470
|
+
} catch {
|
|
1471
|
+
return null;
|
|
1472
|
+
}
|
|
1473
|
+
}
|
|
1474
|
+
|
|
1475
|
+
function installGlobalNpmPackage(packageName, version) {
|
|
1476
|
+
const target = version || 'latest';
|
|
1477
|
+
try {
|
|
1478
|
+
console.log(chalk.blue(` ⏳ Installing ${packageName}@${target} globally...`));
|
|
1479
|
+
execSync(`npm install -g ${packageName}@${target}`, { stdio: 'pipe', timeout: 120000 });
|
|
1480
|
+
console.log(chalk.green(` ✓ ${packageName}@${target} installed globally`));
|
|
1481
|
+
return true;
|
|
1482
|
+
} catch (e) {
|
|
1483
|
+
console.log(chalk.yellow(` ⚠ ${packageName} install failed: ${e.message}`));
|
|
1484
|
+
console.log(chalk.yellow(` ⚠ Run manually: npm install -g ${packageName}@${target}`));
|
|
1485
|
+
return false;
|
|
1486
|
+
}
|
|
1487
|
+
}
|
|
1488
|
+
|
|
1489
|
+
/**
|
|
1490
|
+
* Sync a globally installed npm CLI with the published latest version.
|
|
1491
|
+
* A registry failure never blocks installation: the existing global CLI keeps
|
|
1492
|
+
* working and the remaining external assets are still refreshed.
|
|
1493
|
+
*/
|
|
1494
|
+
function syncGlobalNpmPackage(packageName, label, installedVersion) {
|
|
1495
|
+
if (!installedVersion) return installGlobalNpmPackage(packageName);
|
|
1496
|
+
|
|
1497
|
+
const latest = readLatestNpmVersion(packageName);
|
|
1498
|
+
const comparison = latest ? compareVersions(installedVersion, latest) : null;
|
|
1499
|
+
if (comparison === null) {
|
|
1500
|
+
console.log(chalk.green(` ✓ ${label} ${installedVersion} (already installed)`));
|
|
1501
|
+
return true;
|
|
1502
|
+
}
|
|
1503
|
+
if (comparison === 0) {
|
|
1504
|
+
console.log(chalk.green(` ✓ ${label} ${installedVersion} (latest)`));
|
|
1505
|
+
return true;
|
|
1506
|
+
}
|
|
1507
|
+
if (comparison > 0) {
|
|
1508
|
+
console.log(chalk.green(` ✓ ${label} ${installedVersion} (newer than published ${latest})`));
|
|
1509
|
+
return true;
|
|
1510
|
+
}
|
|
1511
|
+
console.log(chalk.blue(` ⏳ Updating ${label} ${installedVersion} → ${latest}...`));
|
|
1512
|
+
if (installGlobalNpmPackage(packageName, latest)) return true;
|
|
1513
|
+
console.log(chalk.yellow(` ⚠ Continuing with ${label} ${installedVersion}`));
|
|
1514
|
+
return true;
|
|
1515
|
+
}
|
|
1516
|
+
|
|
1517
|
+
function ensurePlaywrightCli() {
|
|
1518
|
+
return syncGlobalNpmPackage(
|
|
1519
|
+
PLAYWRIGHT_CLI_PACKAGE,
|
|
1520
|
+
'playwright-cli',
|
|
1521
|
+
readInstalledPlaywrightCliVersion(),
|
|
1522
|
+
);
|
|
1523
|
+
}
|
|
1524
|
+
|
|
1525
|
+
function playwrightBrowserCacheDir() {
|
|
1526
|
+
return process.env.PLAYWRIGHT_BROWSERS_PATH
|
|
1527
|
+
|| path.join(process.env.HOME || process.env.USERPROFILE || '.',
|
|
1528
|
+
process.platform === 'darwin' ? 'Library/Caches/ms-playwright'
|
|
1529
|
+
: process.platform === 'win32' ? 'AppData/Local/ms-playwright'
|
|
1530
|
+
: '.cache/ms-playwright');
|
|
1531
|
+
}
|
|
1532
|
+
|
|
1533
|
+
/**
|
|
1534
|
+
* Detect installed Chromium builds. Recent Playwright releases install the
|
|
1535
|
+
* headless shell as a separate `chromium_headless_shell-<build>` directory.
|
|
1536
|
+
*/
|
|
1537
|
+
function playwrightChromiumState(cacheDir) {
|
|
1538
|
+
const state = { chromium: false, headlessShell: false };
|
|
1539
|
+
if (!fs.pathExistsSync(cacheDir)) return state;
|
|
1540
|
+
let entries = [];
|
|
1541
|
+
try {
|
|
1542
|
+
entries = fs.readdirSync(cacheDir);
|
|
1543
|
+
} catch {
|
|
1544
|
+
return state;
|
|
1545
|
+
}
|
|
1546
|
+
for (const entry of entries) {
|
|
1547
|
+
if (/^chromium-\d/.test(entry)) state.chromium = true;
|
|
1548
|
+
else if (/^chromium_headless_shell-\d/.test(entry)) state.headlessShell = true;
|
|
1549
|
+
}
|
|
1550
|
+
return state;
|
|
1551
|
+
}
|
|
1421
1552
|
|
|
1422
1553
|
function extrasContextObject(value) {
|
|
1423
1554
|
return Boolean(value) && typeof value === 'object' && !Array.isArray(value);
|
|
@@ -1488,27 +1619,12 @@ async function distributePlaywrightSkill(projectRoot, extrasContext, dryRun) {
|
|
|
1488
1619
|
export async function installPlaywrightCli(projectRoot, dryRun, extrasContext = {}) {
|
|
1489
1620
|
const context = extrasContextObject(extrasContext) ? extrasContext : {};
|
|
1490
1621
|
if (dryRun) {
|
|
1491
|
-
console.log(chalk.gray(' [dry-run] @playwright/cli (global install + workspace
|
|
1622
|
+
console.log(chalk.gray(' [dry-run] @playwright/cli (global install/update + workspace skills)'));
|
|
1492
1623
|
await distributePlaywrightSkill(projectRoot, context, true);
|
|
1493
1624
|
return;
|
|
1494
1625
|
}
|
|
1495
1626
|
|
|
1496
|
-
|
|
1497
|
-
try {
|
|
1498
|
-
execSync('playwright-cli --version', { stdio: 'pipe' });
|
|
1499
|
-
console.log(chalk.green(' ✓ playwright-cli (already installed)'));
|
|
1500
|
-
} catch {
|
|
1501
|
-
// Not installed, install it
|
|
1502
|
-
try {
|
|
1503
|
-
console.log(chalk.blue(' ⏳ Installing @playwright/cli globally...'));
|
|
1504
|
-
execSync('npm install -g @playwright/cli@latest', { stdio: 'pipe', timeout: 120000 });
|
|
1505
|
-
console.log(chalk.green(' ✓ @playwright/cli installed globally'));
|
|
1506
|
-
} catch (e) {
|
|
1507
|
-
console.log(chalk.yellow(` ⚠ @playwright/cli install failed: ${e.message}`));
|
|
1508
|
-
console.log(chalk.yellow(' ⚠ Run manually: npm install -g @playwright/cli@latest'));
|
|
1509
|
-
return;
|
|
1510
|
-
}
|
|
1511
|
-
}
|
|
1627
|
+
if (!ensurePlaywrightCli()) return;
|
|
1512
1628
|
|
|
1513
1629
|
// Install AI agent skills (official SKILL.md + references, auto-detects system browser)
|
|
1514
1630
|
try {
|
|
@@ -1527,15 +1643,12 @@ export async function installPlaywrightCli(projectRoot, dryRun, extrasContext =
|
|
|
1527
1643
|
|
|
1528
1644
|
// Install Playwright browser binary (needed for E2E testing via prizmkit-test)
|
|
1529
1645
|
try {
|
|
1530
|
-
const
|
|
1531
|
-
|
|
1532
|
-
process.platform === 'darwin' ? 'Library/Caches/ms-playwright'
|
|
1533
|
-
: process.platform === 'win32' ? 'AppData/Local/ms-playwright'
|
|
1534
|
-
: '.cache/ms-playwright');
|
|
1535
|
-
const hasChromium = fs.pathExistsSync(cacheDir)
|
|
1536
|
-
&& fs.readdirSync(cacheDir).some(d => d.startsWith('chromium-'));
|
|
1537
|
-
if (hasChromium) {
|
|
1646
|
+
const browsers = playwrightChromiumState(playwrightBrowserCacheDir());
|
|
1647
|
+
if (browsers.chromium) {
|
|
1538
1648
|
console.log(chalk.green(' ✓ Playwright Chromium (already installed)'));
|
|
1649
|
+
} else if (browsers.headlessShell) {
|
|
1650
|
+
console.log(chalk.green(' ✓ Playwright Chromium headless shell (already installed)'));
|
|
1651
|
+
console.log(chalk.gray(' • Headed runs still need a full build: npx playwright install chromium --no-shell'));
|
|
1539
1652
|
} else {
|
|
1540
1653
|
console.log(chalk.blue(' ⏳ Installing Playwright Chromium (needed for E2E testing)...'));
|
|
1541
1654
|
execSync('npx --yes playwright install chromium', { stdio: 'pipe', timeout: 180000 });
|
|
@@ -1551,6 +1664,8 @@ export async function installPlaywrightCli(projectRoot, dryRun, extrasContext =
|
|
|
1551
1664
|
// OpenCLI 安装
|
|
1552
1665
|
// ============================================================
|
|
1553
1666
|
|
|
1667
|
+
const OPENCLI_PACKAGE = '@jackwener/opencli';
|
|
1668
|
+
|
|
1554
1669
|
/**
|
|
1555
1670
|
* Side-effect-free OpenCLI presence check. Running OpenCLI itself is unsafe here:
|
|
1556
1671
|
* browser-oriented commands such as `opencli doctor` create a live browser session.
|
|
@@ -1564,6 +1679,98 @@ function isOpenCliAvailable() {
|
|
|
1564
1679
|
}
|
|
1565
1680
|
}
|
|
1566
1681
|
|
|
1682
|
+
function openCliExtensionDir() {
|
|
1683
|
+
return path.join(process.env.HOME || process.env.USERPROFILE || '.', '.opencli', 'extension');
|
|
1684
|
+
}
|
|
1685
|
+
|
|
1686
|
+
function readOpenCliExtensionVersion(extDir) {
|
|
1687
|
+
try {
|
|
1688
|
+
return fs.readJSONSync(path.join(extDir, 'manifest.json'))?.version || null;
|
|
1689
|
+
} catch {
|
|
1690
|
+
return null;
|
|
1691
|
+
}
|
|
1692
|
+
}
|
|
1693
|
+
|
|
1694
|
+
/**
|
|
1695
|
+
* Resolve the latest published Chrome extension asset. The release tag names the
|
|
1696
|
+
* CLI version, so the extension version comes from the asset file name.
|
|
1697
|
+
*/
|
|
1698
|
+
function fetchLatestOpenCliExtension() {
|
|
1699
|
+
try {
|
|
1700
|
+
const release = JSON.parse(String(execSync(
|
|
1701
|
+
'curl -sL https://api.github.com/repos/jackwener/OpenCLI/releases/latest',
|
|
1702
|
+
{ stdio: 'pipe', timeout: 30000 },
|
|
1703
|
+
)));
|
|
1704
|
+
const asset = release.assets?.find(a => a.name?.startsWith('opencli-extension-') && a.name?.endsWith('.zip'));
|
|
1705
|
+
if (!asset) return null;
|
|
1706
|
+
return {
|
|
1707
|
+
name: asset.name,
|
|
1708
|
+
url: asset.browser_download_url,
|
|
1709
|
+
version: asset.name.match(/opencli-extension-v?(\d+\.\d+\.\d+)/)?.[1] || null,
|
|
1710
|
+
};
|
|
1711
|
+
} catch {
|
|
1712
|
+
return null;
|
|
1713
|
+
}
|
|
1714
|
+
}
|
|
1715
|
+
|
|
1716
|
+
async function downloadOpenCliExtension(asset, extDir) {
|
|
1717
|
+
console.log(chalk.blue(` ⏳ Downloading ${asset.name}...`));
|
|
1718
|
+
const tmpZip = path.join(extDir, '..', '.opencli-ext-tmp.zip');
|
|
1719
|
+
await fs.ensureDir(path.dirname(tmpZip));
|
|
1720
|
+
execSync(`curl -sL "${asset.url}" -o "${tmpZip}"`, { stdio: 'pipe', timeout: 60000 });
|
|
1721
|
+
|
|
1722
|
+
// Extract (use unzip on macOS/Linux, tar on Windows fallback)
|
|
1723
|
+
console.log(chalk.blue(` ⏳ Extracting to ${extDir}...`));
|
|
1724
|
+
await fs.ensureDir(extDir);
|
|
1725
|
+
execSync(`unzip -o "${tmpZip}" -d "${extDir}"`, { stdio: 'pipe', timeout: 30000 });
|
|
1726
|
+
await fs.remove(tmpZip);
|
|
1727
|
+
|
|
1728
|
+
console.log(chalk.green(` ✓ Extension extracted to ${extDir}`));
|
|
1729
|
+
printOpenCliLoadSteps(extDir);
|
|
1730
|
+
}
|
|
1731
|
+
|
|
1732
|
+
/**
|
|
1733
|
+
* Keep the Chrome extension at the latest published version. Extension files are
|
|
1734
|
+
* only staged on disk; the user still reloads them in chrome://extensions.
|
|
1735
|
+
*/
|
|
1736
|
+
async function syncOpenCliExtension() {
|
|
1737
|
+
const extDir = openCliExtensionDir();
|
|
1738
|
+
const installedVersion = readOpenCliExtensionVersion(extDir);
|
|
1739
|
+
if (!installedVersion) console.log(chalk.blue(' ⏳ Fetching latest extension release info...'));
|
|
1740
|
+
const latest = fetchLatestOpenCliExtension();
|
|
1741
|
+
|
|
1742
|
+
if (!latest) {
|
|
1743
|
+
if (installedVersion) {
|
|
1744
|
+
console.log(chalk.green(` ✓ OpenCLI extension ${installedVersion} (already downloaded)`));
|
|
1745
|
+
console.log(chalk.gray(' • Extension version check skipped: latest release unavailable'));
|
|
1746
|
+
} else {
|
|
1747
|
+
console.log(chalk.yellow(' ⚠ Could not read the latest extension release'));
|
|
1748
|
+
printOpenCliManualSteps();
|
|
1749
|
+
}
|
|
1750
|
+
return;
|
|
1751
|
+
}
|
|
1752
|
+
|
|
1753
|
+
if (installedVersion) {
|
|
1754
|
+
const comparison = latest.version ? compareVersions(installedVersion, latest.version) : null;
|
|
1755
|
+
if (comparison === null) {
|
|
1756
|
+
console.log(chalk.green(` ✓ OpenCLI extension ${installedVersion} (already downloaded)`));
|
|
1757
|
+
return;
|
|
1758
|
+
}
|
|
1759
|
+
if (comparison >= 0) {
|
|
1760
|
+
console.log(chalk.green(` ✓ OpenCLI extension ${installedVersion} (latest)`));
|
|
1761
|
+
return;
|
|
1762
|
+
}
|
|
1763
|
+
console.log(chalk.blue(` ⏳ Updating OpenCLI extension ${installedVersion} → ${latest.version}...`));
|
|
1764
|
+
}
|
|
1765
|
+
|
|
1766
|
+
try {
|
|
1767
|
+
await downloadOpenCliExtension(latest, extDir);
|
|
1768
|
+
} catch (e) {
|
|
1769
|
+
console.log(chalk.yellow(` ⚠ Extension download failed: ${e.message}`));
|
|
1770
|
+
printOpenCliManualSteps();
|
|
1771
|
+
}
|
|
1772
|
+
}
|
|
1773
|
+
|
|
1567
1774
|
/**
|
|
1568
1775
|
* 安装 opencli(全局 npm 包)
|
|
1569
1776
|
* 用于浏览器交互验证,复用 Chrome 已登录会话(OAuth/SSO/第三方集成)
|
|
@@ -1571,38 +1778,33 @@ function isOpenCliAvailable() {
|
|
|
1571
1778
|
export async function installOpenCli(projectRoot, dryRun, autoDownload = true) {
|
|
1572
1779
|
const shouldAutoDownload = resolveOpenCliAutoDownload(autoDownload);
|
|
1573
1780
|
if (dryRun) {
|
|
1574
|
-
console.log(chalk.gray(
|
|
1781
|
+
console.log(chalk.gray(` [dry-run] ${OPENCLI_PACKAGE}@latest (global install/update)`));
|
|
1782
|
+
console.log(chalk.gray(' [dry-run] OpenCLI extension (version check + update when outdated)'));
|
|
1575
1783
|
return;
|
|
1576
1784
|
}
|
|
1577
1785
|
|
|
1578
1786
|
// Detect the executable without running it. This keeps repeated PrizmKit
|
|
1579
1787
|
// installs/upgrades idempotent and avoids starting an OpenCLI browser session.
|
|
1580
1788
|
if (isOpenCliAvailable()) {
|
|
1581
|
-
|
|
1582
|
-
|
|
1583
|
-
|
|
1584
|
-
|
|
1585
|
-
|
|
1586
|
-
console.log(chalk.green(' ✓ @jackwener/opencli installed globally'));
|
|
1587
|
-
} catch (e) {
|
|
1588
|
-
console.log(chalk.yellow(` ⚠ @jackwener/opencli install failed: ${e.message}`));
|
|
1589
|
-
console.log(chalk.yellow(' ⚠ Run manually: npm install -g @jackwener/opencli@latest'));
|
|
1590
|
-
return;
|
|
1789
|
+
const installedVersion = readGlobalNpmPackageVersion(OPENCLI_PACKAGE);
|
|
1790
|
+
if (installedVersion) {
|
|
1791
|
+
syncGlobalNpmPackage(OPENCLI_PACKAGE, 'opencli', installedVersion);
|
|
1792
|
+
} else {
|
|
1793
|
+
console.log(chalk.green(' ✓ opencli (already installed)'));
|
|
1591
1794
|
}
|
|
1795
|
+
} else if (!installGlobalNpmPackage(OPENCLI_PACKAGE)) {
|
|
1796
|
+
return;
|
|
1592
1797
|
}
|
|
1593
1798
|
|
|
1594
|
-
|
|
1595
|
-
|
|
1596
|
-
|
|
1597
|
-
|
|
1598
|
-
|
|
1599
|
-
|
|
1600
|
-
|
|
1601
|
-
)
|
|
1602
|
-
|
|
1603
|
-
console.log(chalk.green(' ✓ OpenCLI extension files (already downloaded)'));
|
|
1604
|
-
} else if (shouldAutoDownload) {
|
|
1605
|
-
await downloadOpenCliExtension();
|
|
1799
|
+
if (shouldAutoDownload) {
|
|
1800
|
+
await syncOpenCliExtension();
|
|
1801
|
+
return;
|
|
1802
|
+
}
|
|
1803
|
+
|
|
1804
|
+
// Auto-download disabled: report what is already on disk and never touch the network.
|
|
1805
|
+
const installedExtension = readOpenCliExtensionVersion(openCliExtensionDir());
|
|
1806
|
+
if (installedExtension) {
|
|
1807
|
+
console.log(chalk.green(` ✓ OpenCLI extension ${installedExtension} (already downloaded)`));
|
|
1606
1808
|
} else {
|
|
1607
1809
|
printOpenCliManualSteps();
|
|
1608
1810
|
}
|
|
@@ -1612,54 +1814,6 @@ export async function installOpenCli(projectRoot, dryRun, autoDownload = true) {
|
|
|
1612
1814
|
// OpenCLI Extension 下载/指引
|
|
1613
1815
|
// ============================================================
|
|
1614
1816
|
|
|
1615
|
-
/**
|
|
1616
|
-
* 从 GitHub releases 下载并解压 opencli Chrome 扩展。
|
|
1617
|
-
* 省去用户手动下载解压步骤,但仍需在 Chrome 中手动加载。
|
|
1618
|
-
*/
|
|
1619
|
-
async function downloadOpenCliExtension() {
|
|
1620
|
-
const extDir = path.join(process.env.HOME || process.env.USERPROFILE || '.', '.opencli', 'extension');
|
|
1621
|
-
|
|
1622
|
-
// Check if already downloaded
|
|
1623
|
-
const manifestPath = path.join(extDir, 'manifest.json');
|
|
1624
|
-
if (fs.pathExistsSync(manifestPath)) {
|
|
1625
|
-
console.log(chalk.green(` ✓ Extension already downloaded at ${extDir}`));
|
|
1626
|
-
printOpenCliLoadSteps(extDir);
|
|
1627
|
-
return;
|
|
1628
|
-
}
|
|
1629
|
-
|
|
1630
|
-
try {
|
|
1631
|
-
console.log(chalk.blue(' ⏳ Fetching latest extension release info...'));
|
|
1632
|
-
const releaseJson = execSync(
|
|
1633
|
-
'curl -sL https://api.github.com/repos/jackwener/OpenCLI/releases/latest',
|
|
1634
|
-
{ stdio: 'pipe', timeout: 30000 }
|
|
1635
|
-
).toString();
|
|
1636
|
-
const release = JSON.parse(releaseJson);
|
|
1637
|
-
const extAsset = release.assets?.find(a => a.name?.startsWith('opencli-extension-') && a.name?.endsWith('.zip'));
|
|
1638
|
-
|
|
1639
|
-
if (!extAsset) {
|
|
1640
|
-
console.log(chalk.yellow(' ⚠ Could not find extension asset in latest release'));
|
|
1641
|
-
printOpenCliManualSteps();
|
|
1642
|
-
return;
|
|
1643
|
-
}
|
|
1644
|
-
|
|
1645
|
-
console.log(chalk.blue(` ⏳ Downloading ${extAsset.name}...`));
|
|
1646
|
-
const tmpZip = path.join(extDir, '..', '.opencli-ext-tmp.zip');
|
|
1647
|
-
await fs.ensureDir(path.dirname(tmpZip));
|
|
1648
|
-
execSync(`curl -sL "${extAsset.browser_download_url}" -o "${tmpZip}"`, { stdio: 'pipe', timeout: 60000 });
|
|
1649
|
-
|
|
1650
|
-
// Extract (use unzip on macOS/Linux, tar on Windows fallback)
|
|
1651
|
-
console.log(chalk.blue(` ⏳ Extracting to ${extDir}...`));
|
|
1652
|
-
await fs.ensureDir(extDir);
|
|
1653
|
-
execSync(`unzip -o "${tmpZip}" -d "${extDir}"`, { stdio: 'pipe', timeout: 30000 });
|
|
1654
|
-
await fs.remove(tmpZip);
|
|
1655
|
-
|
|
1656
|
-
console.log(chalk.green(` ✓ Extension extracted to ${extDir}`));
|
|
1657
|
-
printOpenCliLoadSteps(extDir);
|
|
1658
|
-
} catch (e) {
|
|
1659
|
-
console.log(chalk.yellow(` ⚠ Extension download failed: ${e.message}`));
|
|
1660
|
-
printOpenCliManualSteps();
|
|
1661
|
-
}
|
|
1662
|
-
}
|
|
1663
1817
|
|
|
1664
1818
|
/**
|
|
1665
1819
|
* 显示手动安装步骤(兜底路径)。
|
package/src/upgrade.js
CHANGED
|
@@ -15,6 +15,7 @@ import { confirm } from '@inquirer/prompts';
|
|
|
15
15
|
|
|
16
16
|
import { readManifestForLifecycle, writeManifest, buildManifest, diffManifest } from './manifest.js';
|
|
17
17
|
import {
|
|
18
|
+
loadMetadata,
|
|
18
19
|
loadRulesMetadata,
|
|
19
20
|
} from './metadata.js';
|
|
20
21
|
import {
|
|
@@ -32,12 +33,27 @@ import {
|
|
|
32
33
|
removeRetiredAgentTeamArtifacts,
|
|
33
34
|
EXTRAS_REGISTRY,
|
|
34
35
|
} from './scaffold.js';
|
|
35
|
-
import { canonicalizePlatformSelection, expandPlatforms, isKnownPlatform, PLATFORM_IDS, platformLabel, resolvePayloadPlatforms, uniquePlatforms, unknownPlatformMessage } from './platforms.js';
|
|
36
|
+
import { canonicalizePlatformSelection, expandPlatforms, isKnownPlatform, nativeSkillRoot, PLATFORM_IDS, platformLabel, resolvePayloadPlatforms, uniquePlatforms, unknownPlatformMessage } from './platforms.js';
|
|
36
37
|
import { normalizeRuntime, runtimeLabel } from './runtimes.js';
|
|
37
38
|
|
|
38
39
|
const __dirname = dirname(fileURLToPath(import.meta.url));
|
|
39
40
|
const pkg = JSON.parse(readFileSync(join(__dirname, '..', 'package.json'), 'utf-8'));
|
|
40
41
|
|
|
42
|
+
/**
|
|
43
|
+
* Discover external Skill trees this installation already owns. Presence in a
|
|
44
|
+
* payload skill root is the only signal available: third-party Skill repos
|
|
45
|
+
* publish no version metadata, so the refresh always fetches upstream HEAD.
|
|
46
|
+
*/
|
|
47
|
+
async function resolveInstalledExternalSkills(projectRoot, payloadPlatforms) {
|
|
48
|
+
const metadata = await loadMetadata();
|
|
49
|
+
const known = metadata.external_skills?.known || [];
|
|
50
|
+
if (known.length === 0) return [];
|
|
51
|
+
const roots = payloadPlatforms.map(p => nativeSkillRoot(p, projectRoot));
|
|
52
|
+
return known.filter(skillDef => roots.some(
|
|
53
|
+
root => fs.pathExistsSync(path.join(root, skillDef.name, 'SKILL.md')),
|
|
54
|
+
));
|
|
55
|
+
}
|
|
56
|
+
|
|
41
57
|
/**
|
|
42
58
|
* Remove skill files for a specific platform.
|
|
43
59
|
*/
|
|
@@ -510,6 +526,22 @@ export async function runUpgrade(directory, options = {}) {
|
|
|
510
526
|
}
|
|
511
527
|
}
|
|
512
528
|
|
|
529
|
+
// External Skills have no version metadata: refresh the installed trees from upstream
|
|
530
|
+
const externalSkillDefs = await resolveInstalledExternalSkills(projectRoot, payloadPlatforms);
|
|
531
|
+
if (externalSkillDefs.length > 0) {
|
|
532
|
+
const { installExternalSkill } = await import('./external-skills.js');
|
|
533
|
+
console.log(chalk.blue(' External Skills:'));
|
|
534
|
+
for (const skillDef of externalSkillDefs) {
|
|
535
|
+
try {
|
|
536
|
+
await installExternalSkill(skillDef, platform, projectRoot, dryRun, aiCli);
|
|
537
|
+
console.log(chalk.green(` ✓ ${skillDef.name} (refreshed)`));
|
|
538
|
+
} catch (e) {
|
|
539
|
+
console.log(chalk.yellow(` ⚠ ${skillDef.name} refresh skipped: ${e.message}`));
|
|
540
|
+
}
|
|
541
|
+
}
|
|
542
|
+
console.log('');
|
|
543
|
+
}
|
|
544
|
+
|
|
513
545
|
// Git hook
|
|
514
546
|
console.log(chalk.blue(' Git Hook:'));
|
|
515
547
|
await installGitHook(projectRoot, dryRun, runtime);
|