pier-setup 0.2.6 → 0.2.7
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/install.mjs +21 -0
- package/package.json +1 -1
package/install.mjs
CHANGED
|
@@ -192,6 +192,25 @@ function piAgentDir() {
|
|
|
192
192
|
return process.env.PI_CODING_AGENT_DIR || join(homedir(), '.pi', 'agent');
|
|
193
193
|
}
|
|
194
194
|
|
|
195
|
+
/* ── 旧版 git 模式注册迁移 ──────────────────────────────────────── */
|
|
196
|
+
// 早期 `pi install git:github.com/July24/pier` 的遗留注册与 npm:pi-pier 并存时,
|
|
197
|
+
// 两份扩展会注册同名工具(todo_write / ask_user_question…),pi 启动即报 conflict。
|
|
198
|
+
const LEGACY_GIT_SPEC = 'git:github.com/July24/pier';
|
|
199
|
+
|
|
200
|
+
function registeredPiPackages() {
|
|
201
|
+
try {
|
|
202
|
+
return JSON.parse(readFileSync(join(piAgentDir(), 'settings.json'), 'utf8'))?.packages ?? [];
|
|
203
|
+
} catch { return []; }
|
|
204
|
+
}
|
|
205
|
+
|
|
206
|
+
/** install/update 前清理旧 git 模式注册;--pi-spec 显式指定该 git 源时视为目标源,不动。 */
|
|
207
|
+
function removeLegacyGitRegistration() {
|
|
208
|
+
if (piSource() === LEGACY_GIT_SPEC) return;
|
|
209
|
+
if (!registeredPiPackages().includes(LEGACY_GIT_SPEC)) return;
|
|
210
|
+
if (tryRun('pi', ['remove', LEGACY_GIT_SPEC])) log(`✓ removed legacy git-mode registration (${LEGACY_GIT_SPEC}); using ${piSource()}`);
|
|
211
|
+
else { console.error('✗ failed to remove legacy git-mode registration'); log(` manual: pi remove ${LEGACY_GIT_SPEC}`); process.exitCode = 1; }
|
|
212
|
+
}
|
|
213
|
+
|
|
195
214
|
function npmNameFromSpec(spec) {
|
|
196
215
|
if (!spec.startsWith('npm:')) return null;
|
|
197
216
|
const rest = spec.slice(4);
|
|
@@ -365,6 +384,7 @@ function version() {
|
|
|
365
384
|
|
|
366
385
|
function update() {
|
|
367
386
|
checkEnv();
|
|
387
|
+
removeLegacyGitRegistration();
|
|
368
388
|
const me = readPkgVersion(ROOT);
|
|
369
389
|
const latestSetup = npmLatest('pier-setup');
|
|
370
390
|
if (latestSetup && me && cmpSemver(me, latestSetup) < 0) {
|
|
@@ -390,6 +410,7 @@ function install() {
|
|
|
390
410
|
const hmrDev = flags.has('--hmr-dev');
|
|
391
411
|
const force = flags.has('--force');
|
|
392
412
|
checkEnv();
|
|
413
|
+
removeLegacyGitRegistration();
|
|
393
414
|
|
|
394
415
|
if (dev) {
|
|
395
416
|
if (tryRun('pi', ['install', piSource()])) log('✓ pi extension installed (packages/pier-ext, local)');
|