Skip to content

fix(cli): replace stale data/scripts pointer files on install (#237)#386

Merged
mrgoonie merged 1 commit into
nextlevelbuilder:mainfrom
ia-abatista:fix/cli-installer-stale-pointer-dirs
Jun 25, 2026
Merged

fix(cli): replace stale data/scripts pointer files on install (#237)#386
mrgoonie merged 1 commit into
nextlevelbuilder:mainfrom
ia-abatista:fix/cli-installer-stale-pointer-dirs

Conversation

@ia-abatista

Copy link
Copy Markdown
Contributor

What & why

On Windows, uipro init (especially --ai all) can leave a platform — e.g. codex — with broken data/scripts pointer files instead of real directories (#237).

Root cause: if <skill>/data or <skill>/scripts already exists as a plain file (left by an older CLI, or by a git checkout that materialized the repo's symlinked data/scripts as text "pointer" files), copyDataAndScripts calls mkdir(target, { recursive: true }) on that path, which throws EEXIST. Under --ai all, generateAllPlatformFiles swallows the per-platform error (template.ts:238), so that platform is left with the stale pointer files and no real directories — exactly the reported symptom. A clean install is unaffected, which is why a fresh temp-dir install "works".

Fix

Add ensureCleanDir(): before mkdir, lstat the target and remove it only if it isn't already a directory. Existing real directories are preserved, so re-installs are unaffected. Applied before both the data and scripts copies (the same path runs for all 18 platforms, so no platform regresses).

async function ensureCleanDir(path: string): Promise<void> {
  try {
    const stat = await lstat(path);
    if (!stat.isDirectory()) await rm(path, { recursive: true, force: true });
  } catch { /* nothing there yet */ }
}

Verification

  • npm --prefix cli run typecheck passes.
  • Repro harness: without the fix, mkdir on a pointer file throws EEXIST; with it, data becomes a real directory with the copied contents, and a pre-existing real directory is preserved on re-install.

Scope

Closes #237

On Windows, an older install (or a git checkout that materialized the
repo's symlinked data/scripts as plain "pointer" files) leaves a regular
file at <skill>/data or <skill>/scripts. copyDataAndScripts then calls
mkdir on that path, which throws EEXIST; under `uipro init --ai all` the
per-platform error is swallowed, leaving e.g. codex with the stale
pointer files and no real directories.

Add ensureCleanDir(): before mkdir, lstat the target and remove it if it
is not already a directory. Existing real directories are preserved
(re-install is unaffected). Verified with a repro harness.

Closes nextlevelbuilder#237
@ia-abatista

Copy link
Copy Markdown
Contributor Author

@mrgoonie another quick fix, while you're still around!

@mrgoonie mrgoonie left a comment

Copy link
Copy Markdown
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Summary: PR #386 is a narrow installer migration for issue #237. It changes only cli/src/utils/template.ts, adding ensureCleanDir() so stale plain-file data/scripts pointer paths are removed before creating real directories during platform install.

Risk level: Low. Single-file, 20-line change in the CLI install path.

Mandatory gates:

  • Duplicate / prior implementation: clear. GitHub search found only this PR for the exact stale pointer-file install cleanup; related PR #302 is a broader direct Codex package and does not address this migration path.
  • Project standards: docs/source-of-truth pattern found; change stays in existing CLI template utility and does not touch generated assets.
  • Strategic necessity: clear value. It directly addresses Windows/legacy-upgrade broken installs from #237 without broad packaging churn.

Findings: none blocking.

Verification notes:

  • Inspected linked issue #237, PR body, full diff, changed file context, related search results, and current CLI install code.
  • Local npm --prefix cli run typecheck could not run because this checkout lacks installed dev dependency binary tsc; no node_modules present. This is an environment limitation, not a PR finding. The PR is small enough to review statically.
  • GitHub reports no checks for branch fix/cli-installer-stale-pointer-dirs.

Verdict: Approve. If GitHub accepts merge with no required checks, merge after approval because mergeStateStatus=CLEAN and the change is narrow.

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

None yet

Projects

None yet

Development

Successfully merging this pull request may close these issues.

Codex install creates broken data and scripts pointer files on Windows

2 participants