Skip to content

feat(sdk)!: extract seed execution into a CLI plugin package#1807

Draft
dqn wants to merge 10 commits into
v2from
feat/sdk-plugin-seed
Draft

feat(sdk)!: extract seed execution into a CLI plugin package#1807
dqn wants to merge 10 commits into
v2from
feat/sdk-plugin-seed

Conversation

@dqn

@dqn dqn commented Jul 17, 2026

Copy link
Copy Markdown
Contributor

Summary

The seed runner that seedPlugin used to generate as exec.mjs moves into a new CLI plugin package, @tailor-platform/sdk-plugin-seed, resolved through the CLI's plugin dispatch as tailor seed.

Usage

npm install -D @tailor-platform/sdk-plugin-seed

# was: node <distPath>/exec.mjs [options] [types...]
tailor seed apply
tailor seed apply --truncate --yes
tailor seed apply -n my-db
tailor seed apply User Order

# was: node <distPath>/exec.mjs validate [path]
tailor seed validate

Without the plugin installed, the CLI points at the fix:

✖ "tailor seed" is provided by the @tailor-platform/sdk-plugin-seed CLI plugin, which is not installed.
ℹ Install it with: npm install -D @tailor-platform/sdk-plugin-seed

Affected public surfaces

  • @tailor-platform/sdk: seedPlugin no longer generates exec.mjs (breaking; see Notes). Seed data and schema generation (data/*.jsonl, data/*.schema.ts) is unchanged.
  • New package @tailor-platform/sdk-plugin-seed ships the tailor-seed executable (@tailor-platform/sdk is a peer dependency). apply keeps the old runner's options (-m/--machine-user, -n/--namespace, --skip-idp, --truncate, --yes, type-name arguments) and both commands emit --json summaries.
  • New @tailor-platform/sdk/cli exports for the plugin: loadSeedContext (+ SeedContext types), SeedData (now JSON-typed), and ScriptInvoker (executeScript accepts a plain-object invoker).

Behavioral changes

  • Namespaces, seeding order, and the IdP _User context are computed from tailor.config.ts at run time instead of being baked in at generate time, so seedPlugin option edits (e.g. machineUserName) take effect without regenerating.
  • A relative seedPlugin distPath resolves against the working directory — the same base tailor generate writes it to; run both commands from the same directory.
  • Duplicate type names across namespaces are rejected at seed time, matching generation and deploy.
  • A truncate declined at the confirmation prompt (or run non-interactively without --yes) exits 1.

Verification

  • Local smoke through the real dispatch in example/: tailor plugin list resolves seed, tailor seed validate (and -v) passes against the example config, tailor seed apply --help renders the full option set.
  • Seeding against a deployed workspace (apply/truncate/IdP _User) has not been exercised in this PR; the platform-side path is a direct port of the generated runner onto the same bundleSeedScript/chunkSeedData/executeScript primitives.

Notes

  • Breaking: projects using the generated runner must install the plugin, replace node <distPath>/exec.mjs invocations with tailor seed apply / tailor seed validate, and delete the stale generated exec.mjs. A codemod-less migration entry (with source-string detection for exec.mjs) and doc updates are included.
  • Cross-repo follow-up: tailor-platform/actions/seed-validate (pinned by the tailor setup workflow templates) still runs node .tailor-sdk/exec.mjs validate and is already incompatible with v2's .tailor output directory; it needs a tailor seed validate release and a pin bump in the templates regardless of this PR.
  • pkg.pr.new previews include the new package, but --compact requires an npm-published package; if the preview publish fails for it, re-add after the first next release (same sequencing as the erd plugin).
  • Global flags placed before the plugin command (tailor --json seed apply) are consumed by the host and not forwarded — place them after the command (same documented caveat as the erd plugin).

dqn added 8 commits July 17, 2026 17:06
seedPlugin no longer generates the exec.mjs seed runner; it keeps
generating the JSONL data and lines-db schema files. The new
@tailor-platform/sdk-plugin-seed package ships a tailor-seed executable
that the CLI dispatches to as `tailor seed apply` / `tailor seed
validate`, with the same options the generated script had. Instead of
baking namespaces, dependency order, and IdP scripts into a generated
file, the plugin loads them from tailor.config.ts at run time through
the new loadSeedContext export in @tailor-platform/sdk/cli.

- @tailor-platform/sdk/cli: add loadSeedContext (+ SeedContext types),
  type SeedData as JSON objects, and accept plain-object executeScript
  invokers via ScriptInvoker
- host CLI: register the seed plugin in KNOWN_PLUGIN_PACKAGES for the
  install hint
- example / create-sdk generators template: replace exec.mjs usage with
  tailor seed scripts and a devDependency on the plugin;
  prepare-templates.js now also rewrites the plugin version
- docs: CLI plugins section, configuration.md, and a codemod-less
  v2/seed-exec-to-cli-plugin migration entry
- CI: publish the plugin on pkg.pr.new and cover it in changeset-check
- treat a script result without success: true as a failure, matching the
  generated runner's semantics
- name the file and line when a JSONL seed line fails to parse
- decline truncate confirmation instead of hanging when stdin is not a TTY
- validate the seedPlugin distPath option in loadSeedContext
- fold the duplicated IdP seed/truncate execution into one helper and move
  dataDir into the shared execution context
- drop the discarded processSeedTypeInfo call from the generate hook
- dedupe version resolution in create-sdk's prepare-templates.js and log
  every rewritten package
… emit --json output

- resolve auth namespaces in loadSeedContext before reading userProfile;
  without it the IdP _User context was always null at run time
- resolve a relative distPath against the working directory, the same
  base tailor generate writes it to
- honor --json: apply emits an aggregated { success, processed } summary
  and validate emits { valid, path }
- reject duplicate cross-namespace type names in loadSeedContext, matching
  generation and deploy
- report a cancelled truncate as a failure (exit 1) and emit the --json
  cancel summary
- accept -v for --verbose, matching the generated seed runner's validate
- also flag exec.mjs references inside source strings in the migration
  registry entry
@changeset-bot

changeset-bot Bot commented Jul 17, 2026

Copy link
Copy Markdown

🦋 Changeset detected

Latest commit: 81b6b0c

The changes in this PR will be included in the next version bump.

This PR includes changesets to release 4 packages
Name Type
@tailor-platform/sdk-plugin-seed Major
@tailor-platform/sdk Major
@tailor-platform/sdk-plugin-tailordb-erd Major
@tailor-platform/create-sdk Major

Not sure what this means? Click here to learn what changesets are.

Click here if you're a maintainer who wants to add another changeset to this PR

@pkg-pr-new

pkg-pr-new Bot commented Jul 17, 2026

Copy link
Copy Markdown

Open in StackBlitz

pnpm add https://pkg.pr.new/tailor-platform/sdk/@tailor-platform/create-sdk@81b6b0c
pnpm add https://pkg.pr.new/tailor-platform/sdk/@tailor-platform/sdk@81b6b0c
pnpm add https://pkg.pr.new/tailor-platform/sdk/@tailor-platform/sdk-plugin-seed@81b6b0c
pnpm add https://pkg.pr.new/tailor-platform/sdk/@tailor-platform/sdk-plugin-tailordb-erd@81b6b0c

commit: 81b6b0c

@github-actions

github-actions Bot commented Jul 17, 2026

Copy link
Copy Markdown

🗺️ ERD preview

Self-contained ERD viewer HTML built for this run. Each viewer can switch between the current schema and a diff against base branch v2.

@github-actions

This comment has been minimized.

politty's runMain resets process.exitCode on a successful run, so the
cancelled path must throw instead of setting the exit code directly.
@github-actions

This comment has been minimized.

The example seed scripts run `tailor seed` in the deploy e2e workflow;
without a built dist/index.js pnpm never links the tailor-seed bin and
plugin dispatch reports the plugin as not installed.
@github-actions

Copy link
Copy Markdown

Code Metrics Report (packages/sdk)

main (4675aa4) #1807 (ecdf2cf) +/-
Coverage 74.5% 76.7% +2.1%
Code to Test Ratio 1:0.4 1:0.4 +0.0
Details
  |                    | main (4675aa4) | #1807 (ecdf2cf) |  +/-  |
  |--------------------|----------------|-----------------|-------|
+ | Coverage           |          74.5% |           76.7% | +2.1% |
  |   Files            |            457 |             446 |   -11 |
  |   Lines            |          16953 |           16578 |  -375 |
+ |   Covered          |          12636 |           12716 |   +80 |
+ | Code to Test Ratio |          1:0.4 |           1:0.4 |  +0.0 |
  |   Code             |         113445 |          115303 | +1858 |
+ |   Test             |          52708 |           54636 | +1928 |

Code coverage of files in pull request scope (77.8% → 84.6%)

Details
Files Coverage +/- Status
packages/sdk-codemod/src/registry.ts 0.0% -60.0% modified
packages/sdk/example/tailordb/user.ts 0.0% -100.0% affected
packages/sdk/llm-challenge/src/types.ts 0.0% -100.0% affected
packages/sdk/packages/sdk-plugin-tailordb-erd/src/diff-command.ts 0.0% -71.0% affected
packages/sdk/packages/sdk-plugin-tailordb-erd/src/diff.ts 0.0% -89.5% affected
packages/sdk/packages/sdk-plugin-tailordb-erd/src/export.ts 0.0% -4.4% affected
packages/sdk/packages/sdk-plugin-tailordb-erd/src/local-schema.ts 0.0% -25.0% affected
packages/sdk/packages/sdk-plugin-tailordb-erd/src/serve.ts 0.0% -18.8% affected
packages/sdk/packages/sdk-plugin-tailordb-erd/src/viewer.ts 0.0% -82.8% affected
packages/sdk/src/cli/commands/auth/index.ts 100.0% +100.0% affected
packages/sdk/src/cli/commands/auth/token.ts 33.3% +33.3% affected
packages/sdk/src/cli/commands/deploy/test_fixtures/prepare.ts 90.9% -2.5% affected
packages/sdk/src/cli/commands/deploy/test_fixtures/tailor.config.generators-compat.ts 0.0% -100.0% affected
packages/sdk/src/cli/commands/deploy/test_fixtures/tailor.config.plugins-compat.ts 0.0% -100.0% affected
packages/sdk/src/cli/commands/deploy/auth-invoker.ts 0.0% -100.0% affected
packages/sdk/src/cli/commands/deploy/deploy.ts 89.9% +84.6% affected
packages/sdk/src/cli/commands/deploy/executor.ts 83.8% +2.0% affected
packages/sdk/src/cli/commands/deploy/invoker.ts 100.0% +100.0% affected
packages/sdk/src/cli/commands/deploy/tailordb/index.ts 87.8% -0.3% affected
packages/sdk/src/cli/commands/function/logs.ts 39.7% -4.6% affected
packages/sdk/src/cli/commands/function/test-run.ts 56.8% -3.4% affected
packages/sdk/src/cli/commands/generate/service.ts 70.4% +2.5% modified
packages/sdk/src/cli/commands/login.ts 82.9% -0.9% affected
packages/sdk/src/cli/commands/plugin/index.ts 50.0% +50.0% affected
packages/sdk/src/cli/commands/plugin/list.ts 6.6% +6.6% affected
packages/sdk/src/cli/commands/profile/create.ts 77.2% +72.7% affected
packages/sdk/src/cli/commands/profile/update.ts 92.3% +0.2% affected
packages/sdk/src/cli/commands/skills/install.ts 0.0% -57.2% affected
packages/sdk/src/cli/commands/tailordb/migrate/db-types-generator.ts 95.8% -1.4% affected
packages/sdk/src/cli/commands/tailordb/migrate/diff-calculator.ts 72.9% -0.8% affected
packages/sdk/src/cli/commands/tailordb/migrate/snapshot-manifest.ts 61.7% -0.3% affected
packages/sdk/src/cli/commands/tailordb/migrate/snapshot.ts 80.2% -1.1% affected
packages/sdk/src/cli/commands/user/switch.ts 88.2% +0.7% affected
packages/sdk/src/cli/commands/workflow/start.ts 83.6% +12.5% affected
packages/sdk/src/cli/commands/workspace/create.ts 89.0% +0.2% affected
packages/sdk/src/cli/crashreport/report.ts 88.0% +2.2% affected
packages/sdk/src/cli/index.ts 50.0% -50.0% affected
packages/sdk/src/cli/query/type-field-order.ts 85.7% +85.7% affected
packages/sdk/src/cli/services/application.ts 84.1% +3.1% affected
packages/sdk/src/cli/services/auth/bundler.ts 92.3% -3.6% affected
packages/sdk/src/cli/services/executor/bundler.ts 84.4% -1.7% affected
packages/sdk/src/cli/services/executor/loader.ts 84.6% +1.2% affected
packages/sdk/src/cli/services/file-loader.ts 88.8% -7.9% affected
packages/sdk/src/cli/services/http-adapter/bundler.ts 91.6% -1.1% affected
packages/sdk/src/cli/services/resolver/bundler.ts 94.5% +0.3% affected
packages/sdk/src/cli/services/stale-cleanup.ts 0.0% -91.0% affected
packages/sdk/src/cli/services/tailordb/hooks-validate-bundler.ts 85.7% -1.0% affected
packages/sdk/src/cli/services/tailordb/service.ts 83.3% -0.6% affected
packages/sdk/src/cli/services/workflow/bundler.ts 94.6% -1.0% affected
packages/sdk/src/cli/services/workflow/service.ts 83.7% +3.7% affected
packages/sdk/src/cli/services/workflow/start-transformer.ts 87.5% +87.5% affected
packages/sdk/src/cli/services/workflow/trigger-transformer.ts 0.0% -88.9% affected
packages/sdk/src/cli/shared/auth-input.ts 100.0% +100.0% added
packages/sdk/src/cli/shared/auth-namespace.ts 100.0% +100.0% affected
packages/sdk/src/cli/shared/builtin-commands.ts 100.0% +100.0% affected
packages/sdk/src/cli/shared/config-loader.ts 77.4% -6.9% affected
packages/sdk/src/cli/shared/context.ts 94.5% +15.1% affected
packages/sdk/src/cli/shared/plugin.ts 85.8% +85.8% modified
packages/sdk/src/cli/shared/register-ts-hook.ts 100.0% +100.0% affected
packages/sdk/src/cli/shared/register-tsconfig-paths-hook.ts 0.0% -100.0% affected
packages/sdk/src/cli/shared/register-typescript-runtime.ts 0.0% -100.0% affected
packages/sdk/src/cli/shared/resolve-tsconfig.ts 0.0% -100.0% affected
packages/sdk/src/cli/shared/script-executor.ts 100.0% 0.0% modified
packages/sdk/src/cli/shared/seed-chunker.ts 94.9% 0.0% modified
packages/sdk/src/cli/shared/seed-context.ts 100.0% +100.0% added
packages/sdk/src/cli/shared/skills-installer.ts 0.0% -93.4% affected
packages/sdk/src/cli/shared/start-context.ts 82.6% +82.6% affected
packages/sdk/src/cli/shared/trigger-context.ts 0.0% -82.7% affected
packages/sdk/src/cli/ts-hook.mjs 92.3% +92.3% affected
packages/sdk/src/cli/tsconfig-paths-hook.mjs 0.0% -96.0% affected
packages/sdk/src/configure/services/auth/index.ts 100.0% +25.0% affected
packages/sdk/src/configure/services/staticwebsite/index.ts 100.0% +100.0% affected
packages/sdk/src/configure/services/tailordb/schema.ts 96.6% +7.6% affected
packages/sdk/src/configure/services/workflow/job.ts 90.0% +4.2% affected
packages/sdk/src/configure/services/workflow/registry.ts 100.0% +9.0% affected
packages/sdk/src/configure/services/workflow/test-env-key.ts 100.0% +6.6% affected
packages/sdk/src/configure/services/workflow/workflow.ts 66.6% -13.4% affected
packages/sdk/src/parser/service/auth/schema.ts 92.3% +4.5% affected
packages/sdk/src/parser/service/executor/schema.ts 92.3% +1.3% affected
packages/sdk/src/parser/service/tailordb/builder-helpers.ts 100.0% +100.0% affected
packages/sdk/src/parser/service/tailordb/field.ts 83.8% -16.2% affected
packages/sdk/src/parser/service/tailordb/relation.ts 92.0% -0.6% affected
packages/sdk/src/parser/service/tailordb/type-script.ts 100.0% +100.0% affected
packages/sdk/src/plugin/builtin/kysely-type/type-processor.ts 91.9% +0.1% affected
packages/sdk/src/plugin/builtin/seed/idp-user-processor.ts 100.0% +11.1% affected
packages/sdk/src/plugin/builtin/seed/index.ts 3.3% +1.7% modified
packages/sdk/src/plugin/builtin/seed/seed-type-processor.ts 100.0% +100.0% modified
packages/sdk/src/plugin/builtin/seed/template-literal.ts 0.0% -100.0% removed
packages/sdk/src/utils/test/index.ts 95.0% -5.0% affected
packages/sdk/src/vitest/mocks/file.ts 92.5% +7.4% affected
packages/sdk/src/vitest/mocks/workflow.ts 91.2% -0.3% affected
packages/sdk/src/vitest/workflow-local.ts 77.1% +77.1% affected
packages/sdk/src/vitest/workflow-runtime.ts 70.0% +12.8% affected

SDK Configure Bundle Size

main (4675aa4) #1807 (ecdf2cf) +/-
configure-index-size 32.17KB 31.26KB -0.91KB
dependency-chunks-size 29.88KB 24.97KB -4.91KB
total-bundle-size 62.05KB 56.22KB -5.83KB

Runtime Performance

main (4675aa4) #1807 (ecdf2cf) +/-
Generate Median 3,134ms 2,659ms -475ms
Generate Max 3,297ms 2,675ms -622ms
Apply Build Median 3,150ms 2,715ms -435ms
Apply Build Max 3,169ms 2,726ms -443ms

Type Performance (instantiations)

main (4675aa4) #1807 (ecdf2cf) +/-
tailordb-basic 43,881 39,060 -4,821
tailordb-optional 4,451 4,535 84
tailordb-relation 6,220 3,854 -2,366
tailordb-validate 753 666 -87
tailordb-hooks 5,279 5,499 220
tailordb-object 12,547 16,345 3,798
tailordb-enum 1,486 1,538 52
resolver-basic 9,252 12,107 2,855
resolver-nested 26,119 35,406 9,287
resolver-array 18,059 24,043 5,984
executor-schedule 4,310 4,481 171
executor-webhook 949 1,120 171
executor-record 6,762 4,532 -2,230
executor-resolver 4,090 5,777 1,687
executor-operation-function 937 1,108 171
executor-operation-gql 945 1,116 171
executor-operation-webhook 956 1,127 171
executor-operation-workflow 1,798 1,921 123

Reported by octocov

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.

1 participant