Skip to content

refactor(integrations): generate the TypeScript transport copies from one source - #2623

Merged
hidb4ai merged 1 commit into
oceanbase:masterfrom
Fengzdadi:refactor/ts-lifecycle-module
Nov 14, 2026
Merged

hidb4ai merged 1 commit into
oceanbase:masterfrom
Fengzdadi:refactor/ts-lifecycle-module

Conversation

@Fengzdadi

Copy link
Copy Markdown
Collaborator

Which issue or RFC does this PR close?

Part of #2250.

Rationale for this change

#2250 moves each language's host lifecycle into one module, with thin host shells around it. The Python module exists (#2318). The TypeScript plugins have no shared source: DSH, OpenClaw, OpenCode, and Pi each keep their own copies of the same helpers, and most of those copies have diverged.

This PR starts the TypeScript module with the one helper whose copies are still byte-identical, src/transport.ts, and uses the same generate-and-check mechanism as the Python helpers. No plugin code moves: each plugin keeps importing its copy from the same path.

A generated copy, rather than a bundler alias to a shared path, is needed because Pi loads its TypeScript sources directly and has no build step. It also keeps the bundles unchanged: tsdown names each inlined module by its path (//#region src/transport.ts) and drops // comments.

What changes are included in this PR?

  • integrations/lifecycle/transport.ts is the source, byte-identical to the current copies. integrations/capabilities.toml lists the directory under directory_exclusions, because it is not a host.
  • scripts/generate_integration_lifecycle.py gets a TYPESCRIPT_COPIES table. It writes src/transport.ts in DSH, OpenClaw, OpenCode, and Pi. Below the license block, each copy gets two // lines that name its source and make integration-lifecycle.
    • make integration-lifecycle-check is already part of make check, and tests/test_integration_lifecycle.py runs it in the unit test jobs.
    • It fails when a copy is missing or has drifted, or when a plugin keeps a hand-made file named transport.ts.
  • tests/test_integration_lifecycle.py also fails when a TypeScript source imports anything other than a node: built-in. The plugins install different dependencies, so a copy cannot rely on any package.
  • tests/test_integration_shared_files.py keeps only shared/prompt-privacy.mjs, because the generator check now covers transport.ts.
  • .github/ci-paths.toml adds [shared.lifecycle_typescript], so a change to the source or the generator selects the dsh, cindy, pi, opencode, openclaw, and zcode suites. tests/test_ci_changes.py covers both paths.
  • AGENTS.md and the make integration-lifecycle help name the TypeScript source next to the Python one.

Not included, and planned as separate PRs:

  • The helpers whose copies have diverged. scope.ts, config.ts, errors.ts/client.ts/invoke.ts, and the prompt-recall query bound behave differently between hosts for the same input. Each needs either a host parameter or a separate behavior PR before it moves. For example, OpenClaw keeps the first 8192 bytes of the recall query instead of following tests/fixtures/recall_query_bound.json.
  • The Kimi Code and ZCode .mjs hooks. They have no build step, so their copies would be type-stripped JavaScript. That comes with the first helper they share with the TypeScript plugins (secrets.ts / prompt-privacy.mjs).

Are there any user-facing changes?

No. Each copy gains only a blank line and two comment lines. The committed DSH and OpenCode bundles and the OpenClaw build output are byte-identical to master, and Pi's source changes only by those comments.

How was this change tested?

  • make js-test (DSH: tests, build, lib/ freshness, e2e), make opencode-test (tests, typecheck, build, lib/ freshness), make pi-test (tests, typecheck), and make openclaw-plugin-test (tests, typecheck, build) all pass.

  • Bundle output:

    • git diff --exit-code on DSH and OpenCode lib/ passes after the rebuild.
    • sha256 of the OpenClaw dist/index.js is the same before and after the change (18a930a8…).
  • make check passes.

  • uv run pytest tests/test_recall_query_bound.py tests/test_automatic_prompt_privacy.py tests/test_transport.py tests/test_integration_lifecycle.py tests/test_integration_shared_files.py tests/test_ci_changes.py tests/test_ci_pipeline.py tests/test_integration_manifest.py passes. These include the Python side of the shared fixtures.

  • The generator check was confirmed to fail for each case it should catch:

    • a stale copy,
    • a hand-made transport.ts in another plugin,
    • a source with an unterminated license header.

    The import test was confirmed to fail for a package import and for a relative import.

  • No host was run. This change does not alter what any host loads beyond comments.

  • Self-review against REVIEW.md, plus an independent review pass, found nothing blocking. Notes:

    • Fixed:
      • An unterminated TypeScript license header now fails with a clear message instead of a StopIteration traceback.
      • A source file type without a known comment syntax is rejected instead of getting a // marker.
    • Left as is:
      • The hand-made-copy guard matches any plugin file named transport.ts; its message names the fix.
      • scripts/sync_dsh_plugin_tree.py overwrites the DSH copy. make check then reports it, as it already does for operations.generated.ts.
      • The import test is a simple pattern match. A false positive fails loudly.
      • The Node-built-ins rule states the constraint it protects.

AI usage statement

Claude Code (Claude Opus 5.5) surveyed the copies and wrote the change, tests, and this description. I reviewed the design and the result.

… one source

DSH, OpenClaw, OpenCode, and Pi each ship a byte-identical src/transport.ts.
Keep one source in integrations/lifecycle/ and let
scripts/generate_integration_lifecycle.py write each plugin's copy at the
path it already imports, marked as generated below the license header.
`make integration-lifecycle-check` and the unit tests now reject a stale or
hand-kept copy, replacing the shared-files identity check for transport.ts.

Each copy gains only a comment, which the bundlers drop, so the committed
DSH and OpenCode bundles and the OpenClaw build output are unchanged.
Copilot AI balanced review requested due to automatic review settings November 13, 2026 06:58

Copilot AI 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.

Copilot was unable to review this pull request because the user who requested the review has insufficient remaining quota. Try requesting a review at a lower effort level.

An organization owner can choose the repository organization as the billing source for reviews requested by members with a paid Copilot license. Learn about Copilot code review billing.

@hidb4ai hidb4ai 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.

The shared transport source preserves the existing implementation and import paths in all four plugins. No new database tables or public interfaces, and no blocking findings.

Verified regeneration and drift rejection, targeted tests, and byte-identical DSH/OpenCode bundle output after rebuilding. CI is still in progress; real host acceptance was not rerun for this runtime change, which only adds generated-file comments.

@hireview001 hireview001 left a comment

Copy link
Copy Markdown
Collaborator

Choose a reason for hiding this comment

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

LGTM

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

Labels

1.5.2 v1.5.2 release tracking

Projects

None yet

Development

Successfully merging this pull request may close these issues.

4 participants