create-principles-disciple 1.147.4 → 1.147.5

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/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "create-principles-disciple",
3
- "version": "1.147.4",
3
+ "version": "1.147.5",
4
4
  "description": "Interactive CLI installer for Principles Disciple OpenClaw plugin",
5
5
  "type": "module",
6
6
  "bin": {
@@ -101,5 +101,5 @@
101
101
  "pd": {
102
102
  "bundledPluginVersion": "2.5.0"
103
103
  },
104
- "gitHead": "49a91651ab6c755f9074a653998951f4f88c0f43"
104
+ "gitHead": "29d6fbfd56adcc2d71280438b0bcaf8ee8ef3bd8"
105
105
  }
@@ -105,10 +105,14 @@ const translations = {
105
105
  // Install failure / rollback result strings (catch block). EP-11.
106
106
  rollback_no_changes: 'No changes were made — the existing install was not modified (no backup was created).',
107
107
  rollback_restored: 'Previous install has been restored.',
108
+ // PRI-1102: the rollback target itself can be incomplete — say so instead
109
+ // of reporting a restore that leaves the operator with a broken install.
110
+ rollback_restored_incomplete: 'Rolled back to the state that existed before this run, but that state is NOT usable — incomplete: {paths}.',
108
111
  rollback_failed: 'CRITICAL: Rollback also failed — installation state is uncertain. {restoreError} Resolve manually: check {extDir} and {backupDir}',
109
112
  next_no_changes_lock: 'A file lock blocked the backup (EPERM). Stop the OpenClaw gateway (openclaw gateway stop, or re-run with --stop-gateway) and retry.',
110
113
  next_no_changes_other: 'Fix the error above and re-run the installer. The existing install was not modified.',
111
114
  next_restored: 'Check the error above. Previous install has been restored. Fix the issue and re-run the installer.',
115
+ next_restored_incomplete: 'Check the error above. Rollback returned the pre-run state, but it is incomplete: {paths}. Re-run the installer so the missing components are rebuilt.',
112
116
  next_restore_failed: 'Installation and rollback both failed. Check {extDir} and {backupDir} manually. Error: {errorMsg}',
113
117
  // CP-6: fresh-install failure mid-deployment (no pre-existing install → no backup).
114
118
  rollback_fresh_cleaned: 'The install failed before activation — the partially deployed runtime files were removed. Nothing else was modified.',
@@ -225,10 +229,12 @@ const translations = {
225
229
  // 安装失败 / 回滚结果字符串(catch 块)。EP-11。
226
230
  rollback_no_changes: '未做任何改动 —— 现有安装未被修改(未创建备份)。',
227
231
  rollback_restored: '已恢复到之前的安装。',
232
+ rollback_restored_incomplete: '已回滚到本次运行之前的状态,但该状态本身不可用 —— 不完整:{paths}。',
228
233
  rollback_failed: '严重:回滚也失败了 —— 安装状态不确定。{restoreError} 请手动处理:检查 {extDir} 和 {backupDir}',
229
234
  next_no_changes_lock: '文件锁阻塞了备份 (EPERM)。请停止 OpenClaw gateway(openclaw gateway stop,或用 --stop-gateway 重新运行)后重试。',
230
235
  next_no_changes_other: '请修复上方错误后重新运行安装器。现有安装未被修改。',
231
236
  next_restored: '请检查上方错误。已恢复到之前的安装。修复问题后重新运行安装器。',
237
+ next_restored_incomplete: '请检查上方错误。回滚返回的是本次运行之前的状态,但该状态不完整:{paths}。请重新运行安装器,让它重建缺失的组件。',
232
238
  next_restore_failed: '安装与回滚均失败。请手动检查 {extDir} 和 {backupDir}。错误:{errorMsg}',
233
239
  // CP-6:全新安装部署中途失败(无既有安装 → 无备份)。
234
240
  rollback_fresh_cleaned: '安装未激活即失败 —— 已移除本次部署的部分运行时文件。其余内容未被修改。',
@@ -1553,10 +1553,79 @@ export async function checkBuiltPlugin(pluginDir) {
1553
1553
  }
1554
1554
  }
1555
1555
  }
1556
+ /**
1557
+ * PRI-1102: a target that exists as a DANGLING link (an interrupted install
1558
+ * left a reparse point whose target is gone) is not a directory the installer
1559
+ * can copy into. `existsSync` follows the link and reports "missing", so the
1560
+ * backup step never moves it, and `ensureDir` then treats it as present —
1561
+ * the follow-up mkdir fails with ENOENT and aborts the whole install.
1562
+ *
1563
+ * Absent targets are created. A dangling link is removed (the link itself only,
1564
+ * never a target), and the caller recreates the real directory. Everything
1565
+ * else — a real directory, or a link that still resolves — is left untouched,
1566
+ * so an existing install is never destroyed by this step.
1567
+ */
1568
+ export async function preparePluginInstallTarget(targetDir) {
1569
+ let stats;
1570
+ try {
1571
+ stats = lstatSync(targetDir, { throwIfNoEntry: false });
1572
+ }
1573
+ catch (error) {
1574
+ throw new Error(`Cannot inspect plugin install target ${targetDir}: ${error instanceof Error ? error.message : String(error)}`, { cause: error });
1575
+ }
1576
+ if (stats !== undefined && stats.isSymbolicLink()) {
1577
+ let resolves = true;
1578
+ try {
1579
+ realpathSync(targetDir);
1580
+ }
1581
+ catch {
1582
+ resolves = false;
1583
+ }
1584
+ if (!resolves) {
1585
+ // fs-extra's remove unlinks the reparse point instead of traversing it.
1586
+ await fse.remove(targetDir);
1587
+ logger.warn(`Removed dangling link at ${targetDir} (target missing) — rebuilding the plugin install directory.`);
1588
+ }
1589
+ }
1590
+ await fse.ensureDir(targetDir);
1591
+ }
1592
+ /**
1593
+ * PRI-1102: a rollback is only as good as the state it returns to. The
1594
+ * pre-run state can itself be incomplete (a component directory the previous
1595
+ * run never finished, a link whose target is gone), so "restored" must not be
1596
+ * reported as a healthy install without checking what the restored paths
1597
+ * actually resolve to.
1598
+ */
1599
+ export function describeRestoredStateGaps() {
1600
+ const gaps = [];
1601
+ for (const dir of [getPluginExtDir(), getPdRuntimeDir()]) {
1602
+ let stats;
1603
+ try {
1604
+ stats = lstatSync(dir, { throwIfNoEntry: false });
1605
+ }
1606
+ catch (error) {
1607
+ gaps.push(`${dir} (unreadable: ${error instanceof Error ? error.message : String(error)})`);
1608
+ continue;
1609
+ }
1610
+ if (stats === undefined) {
1611
+ gaps.push(`${dir} (missing)`);
1612
+ continue;
1613
+ }
1614
+ if (stats.isSymbolicLink()) {
1615
+ try {
1616
+ realpathSync(dir);
1617
+ }
1618
+ catch {
1619
+ gaps.push(`${dir} (dangling link)`);
1620
+ }
1621
+ }
1622
+ }
1623
+ return gaps;
1624
+ }
1556
1625
  export async function installPluginToStaging(pluginDir, language) {
1557
1626
  const builtPluginDir = path.join(pluginDir, 'plugin');
1558
1627
  for (const targetDir of pluginInstallDirs()) {
1559
- await fse.ensureDir(targetDir);
1628
+ await preparePluginInstallTarget(targetDir);
1560
1629
  // PRI-1037 payload fix: npm-era payloads carried a ~16k-file node_modules
1561
1630
  // (the whole pi-ai/openai/anthropic tree, dragged in through the plugin's
1562
1631
  // historical file:./core dependency) plus a `core` junction, in BOTH plugin
@@ -4355,6 +4424,10 @@ transaction) {
4355
4424
  // pre-date this run, so it is NOT wholesale-removed. Report its retention
4356
4425
  // honestly instead of claiming "nothing else was modified".
4357
4426
  const workspaceTouched = !hasBackup && mutationStarted && journal?.lastState !== 'planned';
4427
+ // PRI-1102: `restored` describes the rollback operation, not the health of
4428
+ // the state it returned to. Name the gaps so "restored" is never read as
4429
+ // "usable install".
4430
+ const restoredGaps = hasBackup && restoreResult.restored ? describeRestoredStateGaps() : [];
4358
4431
  const rollbackSuffix = !hasBackup
4359
4432
  ? freshCleanup
4360
4433
  ? freshCleanup.failed.length === 0
@@ -4362,7 +4435,9 @@ transaction) {
4362
4435
  : t('rollback_fresh_clean_failed').replace('{dirs}', freshCleanup.failed.map((f) => f.dir).join(', '))
4363
4436
  : t('rollback_no_changes')
4364
4437
  : restoreResult.restored
4365
- ? t('rollback_restored')
4438
+ ? restoredGaps.length === 0
4439
+ ? t('rollback_restored')
4440
+ : t('rollback_restored_incomplete').replace('{paths}', restoredGaps.join(', '))
4366
4441
  : t('rollback_failed')
4367
4442
  .replace('{restoreError}', restoreResult.error ?? '')
4368
4443
  .replace('{extDir}', extDir)
@@ -4379,7 +4454,9 @@ transaction) {
4379
4454
  ? t('next_no_changes_lock')
4380
4455
  : t('next_no_changes_other'))
4381
4456
  : restoreResult.restored
4382
- ? t('next_restored')
4457
+ ? restoredGaps.length === 0
4458
+ ? t('next_restored')
4459
+ : t('next_restored_incomplete').replace('{paths}', restoredGaps.join(', '))
4383
4460
  : t('next_restore_failed')
4384
4461
  .replace('{extDir}', extDir)
4385
4462
  .replace('{backupDir}', backupDir ?? runtimeBackupDir ?? '')
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "create-principles-disciple",
3
- "version": "1.147.4",
3
+ "version": "1.147.5",
4
4
  "description": "Interactive CLI installer for Principles Disciple OpenClaw plugin",
5
5
  "type": "module",
6
6
  "bin": {