Skip to content

setup / meta / scaffold can't find meta/ in the published package (getMetaDir off-by-one) #193

Description

@SutuSebastian

We hit this wiring up @tanstack/intent for @stainless-code/persist. In the published 0.3.4 (latest), the maintainer commands that read meta/ all fail:

$ intent setup
No templates directory found. Is @tanstack/intent installed?

$ intent meta
Meta-skills directory not found.

scaffold and setup-github-actions hit the same thing — they all go through getMetaDir().

Root cause

packages/intent/src/commands/support.ts:

export function getMetaDir(): string {
  const thisDir = dirname(fileURLToPath(import.meta.url))
  return join(thisDir, '..', '..', 'meta')
}

The ../../meta depth is correct in source — the module lives at src/commands/support.ts, so two .. lands on the package root where meta/ lives. But the build bundles the module flat into dist/ (tsdown src/cli.ts …dist/support-*.mjs at the dist root). From dist/, two .. overshoots past the package root into @tanstack/, so it looks for @tanstack/meta (doesn't exist) instead of @tanstack/intent/meta (one .. up, where it actually is).

Runtime proof from a consumer install:

getMetaDir()  -> …/node_modules/@tanstack/meta        # doesn't exist
templates at  -> …/node_modules/@tanstack/intent/meta/templates/workflows  # exists

So it's a build-layout mismatch, not a naming thing — the code does look for <metaDir>/templates/workflows, it just computes metaDir one level too high once src/commands/ is flattened to dist/.

Blast radius

Only the getMetaDir-backed maintainer commands: setup, setup-github-actions, meta, scaffold. Consumer commands (list, load, validate, stale, install, exclude, hooks) don't use it and work fine. Still present on main (same two lines).

Fix

Walk up to the first meta/ instead of hardcoding the depth — works for both src/commands/ and flat dist/, and for symlinked installs (pnpm). PR incoming.

Metadata

Metadata

Assignees

No one assigned

    Labels

    No labels
    No labels

    Type

    No type

    Projects

    No projects

    Milestone

    No milestone

    Relationships

    None yet

    Development

    No branches or pull requests

    Issue actions