Skip to content

refactor(integrations): generate the TypeScript prompt-privacy copies from one source - #2644

Merged
hidb4ai merged 2 commits into
oceanbase:masterfrom
Fengzdadi:refactor/ts-lifecycle-secrets
Nov 17, 2026
Merged

hidb4ai merged 2 commits into
oceanbase:masterfrom
Fengzdadi:refactor/ts-lifecycle-secrets

Conversation

@Fengzdadi

@Fengzdadi Fengzdadi commented Nov 14, 2026 •

Copy link
Copy Markdown
Contributor

Which issue or RFC does this PR close?

Part of #2250. Follows #2623, which made integrations/lifecycle/ the source of the TypeScript helpers that host plugins ship and generated the transport copies from it.

Rationale for this change

DSH, OpenCode, and Pi each kept a hand-maintained copy of the automatic prompt-privacy rule: the credential patterns, scrubSecrets, and containsSecret. The copies currently match, but nothing checks them, so a fix to the rule in one plugin can miss the others. This PR generates them from one source, as #2623 did for the transport.

Before the move the copies were compared:

What changes are included in this PR?

Source and copies

  • New integrations/lifecycle/prompt-privacy.ts holds the patterns, scrubSecrets, and containsSecret, taken unchanged from the Pi copy.
  • scripts/generate_integration_lifecycle.py writes it to src/prompt-privacy.ts in the DSH, OpenCode, and Pi plugins. make check and tests/test_integration_lifecycle.py reject a copy that drifts, and make integration-lifecycle rewrites them.

Why prompt-privacy.ts and not secrets.ts

  • DSH's src/secrets.ts also holds the DSH-only explicit-write check (hasSecretContent and the tables of operations and fields it inspects), which is not part of the shared rule.
  • The generator's check rejects any plugin file that shares a generated copy's name, so a shared secrets.ts would have meant moving that DSH code to another file.
  • The new name matches the rule's name in the integrations guide ("Automatic prompt privacy"), its fixture tests/fixtures/automatic_prompt_privacy.json, the plugins' prompt-privacy.spec.ts tests, and the Kimi Code and ZCode shared/prompt-privacy.mjs.

Plugins

  • Pi and OpenCode: src/secrets.ts is removed. Capture, recall, invoke, and the tests import the rule from src/prompt-privacy.ts.
  • DSH: the rule moves out of src/secrets.ts, which keeps the explicit-write check and imports containsSecret for it from src/prompt-privacy.ts (fix(dsh): apply the shared prompt-privacy rule to explicit writes #2643 made that check use the shared rule); the check itself does not change. Capture, recall, and the prompt-privacy tests import the rule from src/prompt-privacy.ts, as do the DSH pet plugin and the Cindy worker, which build from DSH sources.
  • Rebuilt bundles: the DSH lib/index.js, the DSH pet lib/index.js, the Cindy node/worker.cjs, and the OpenCode lib/index.js and lib/tui.js. Only the module comments and the OpenCode doc comments and variable name change.

Not included

Are there any user-facing changes?

No. The rule, its exports, and every plugin's behavior are unchanged.

How was this change tested?

  • make js-test: DSH unit and e2e tests, DSH pet adapter tests, and freshness of the DSH and DSH pet bundles.

  • make cindy-test: Cindy hook tests, worker freshness, and packaging.

  • make opencode-test: tests, type check, and bundle freshness.

  • make pi-test: tests and type check.

  • make check, including scripts/generate_integration_lifecycle.py --check, and git diff --check.

  • uv run pytest tests/test_integration_lifecycle.py tests/test_integration_shared_files.py tests/test_ci_changes.py tests/test_automatic_prompt_privacy.py tests/test_integration_manifest.py tests/test_dsh*.py.

  • No real host was run; the change does not alter behavior.

  • Self-review against REVIEW.md, plus an independent review pass. Neither found anything to change.

    Confirmed:

    • the patterns in the three removed copies and the new source are byte-identical, and the functions behave the same;
    • nothing imports a removed export or path; the remaining src/secrets.ts importers in DSH use only hasSecretContent;
    • the generator's check reports a drifted copy and an unlisted prompt-privacy.ts in another plugin;
    • in each rebuilt bundle, the rule's module region now names src/prompt-privacy.ts, and in the DSH bundle it comes before the capture and recall code that uses it.

    Left as notes:

AI usage statement

Claude Code (Claude Opus 5.5) wrote the change and this description, and ran the checks above.

… from one source

DSH, OpenCode, and Pi each kept their own copy of the automatic
prompt-privacy rule (SECRET_PATTERNS, scrubSecrets, containsSecret). The
copies matched in patterns and behavior; OpenCode's lacked the doc
comments and named one variable differently.

integrations/lifecycle/prompt-privacy.ts is now the source, and
scripts/generate_integration_lifecycle.py writes it to src/prompt-privacy.ts
in each of the three plugins, so `make check` rejects a copy that drifts.
The file is named after the rule, like the Kimi Code and ZCode
shared/prompt-privacy.mjs: DSH's src/secrets.ts keeps its own explicit-write
check, which is not part of the shared rule, and a shared secrets.ts copy
would have displaced it.

Pi and OpenCode drop src/secrets.ts and import the rule from
src/prompt-privacy.ts. DSH's src/secrets.ts keeps only the explicit-write
check; capture, recall, the DSH pet, and the Cindy worker import the rule
from prompt-privacy.ts. Behavior does not change.

The DSH, DSH pet, Cindy, and OpenCode bundles are rebuilt.

@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

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

Reviewed b91159a. No correctness issues found. Generating the existing prompt-privacy rules from one source prevents copy drift while preserving behavior and the shipped package interfaces; no database tables or APIs are added.

Validated old/new behavior equivalence, generator rejection of missing/stale/unlisted copies, plugin tests and type checks, rebuilt bundle freshness, live-Server DSH call-through, and Pi CLI package loading. The DSH startup timeout passed when rerun alone with locked dependencies. Full model conversations were not exercised.

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

  • Resolve merge conflicts with the target branch.

@AlexStocks AlexStocks added the 1.6.0 v1.6.0 release tracking label Nov 17, 2026

@PsiACE PsiACE left a comment

Copy link
Copy Markdown
Member

Choose a reason for hiding this comment

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

LGTM, thanks!

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

Re-reviewed bf3ef53 against fd16583. No blocking findings. The merge resolution preserves the DSH explicit-write privacy fix, including configured-credential checks, and retains both flush-progress and prompt-privacy generation. No database tables or interfaces are added relative to master.

Behavior comparisons, generator failure-mode probes, affected plugin tests, type checks, and bundle freshness checks passed. Live-Server DSH tests also passed after rerunning the cases affected by startup/shutdown timeouts. Full host/model conversations were not exercised.

@hidb4ai
hidb4ai merged commit 0169457 into oceanbase:master Nov 17, 2026
44 checks passed
hidb4ai pushed a commit that referenced this pull request Nov 18, 2026
…source (#2704)

#2636 gave the OpenClaw plugin the automatic prompt-privacy rule as a
hand-written src/secrets.ts, and #2644 made
integrations/lifecycle/prompt-privacy.ts the source of the DSH, OpenCode,
and Pi copies. OpenClaw's copy was the only one the generator did not
write or check.

scripts/generate_integration_lifecycle.py now also writes
src/prompt-privacy.ts into the OpenClaw plugin, so `make check` rejects
it if it drifts. src/secrets.ts is removed, and src/lifecycle.ts and its
privacy test import the rule from ./prompt-privacy.js. The generated copy
differs from the removed file only in comments, so behavior does not
change.
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

1.6.0 v1.6.0 release tracking

Projects

None yet

Development

Successfully merging this pull request may close these issues.

5 participants