v0.12.0 — AI cleanup prompt handoff (Improvements + Unused + CLI)#105
Merged
Conversation
Closes the gap between "Lineage tells you what's dead" and "Lineage
helps you delete it" without breaking the read-only / zero-dep promise.
Lineage never mutates the model itself — it generates a markdown prompt
the user pastes into Claude Code (with the pbi-desktop plugin) or any
AI agent that can drive TOM / Tabular Editor CLI.
What ships in this commit:
- src/ai-prompts.ts: pure buildCleanupPrompt(data, category), three
categories (unused-measures, dead-chain-measures, measures-all),
EXTERNALMEASURE proxies + auto-date tables filtered out. Self-
contained so it inlines into the dashboard's classic-script bundle
(no improvements.ts runtime dep). Plus countCleanupTargets() helper
for the UI to label the button accurately.
- src/improvements.ts: unused-measures + dead-chain findings now embed
a collapsible <details> block carrying the matching prompt body —
survives the ADO Wiki / GitHub MD render path so wiki readers get
the prompt without opening the dashboard.
- Dashboard Unused tab: top toolbar with one smart "Generate AI
cleanup prompt" button (auto-picks category from what's flagged)
plus modal preview with Copy / Download .md / Esc-key /
backdrop-click close.
- html-generator.ts: strengthened inline-script export-stripper to
handle `export function|const|let|var|class` and named
`export { ... }` blocks. Previously only stripped trailing empty
`export {};`, which silently killed the whole inline script when
ai-prompts.js joined the manifest.
Per design decision flipped during implementation: DAX bodies are NOT
embedded in the prompt — the AI agent already has live-model access
via pbi-desktop and can read DAX itself before deleting. Just lists
measures as bullets.
Tests: 293/293 pass (14 new for the prompt builder, 4 new for the MD
embed). No new runtime dependencies.
Co-Authored-By: Claude Opus 4.7 (1M context) <noreply@anthropic.com>
Adds the CLI subcommand `powerbi-lineage prompt --category … --report …` that exposes the same buildCleanupPrompt logic as the dashboard button for batch / CI flows. Plus version bump, changelog entry, WHATS-NEW + readme test counts. Builds on prior commit cf2e2e0 which shipped Stops 1-4 of the v0.12.0 handoff feature (pure builder, MD embed, modal, Unused-tab toolbar). - src/app.ts: new `prompt` subcommand dispatched before server startup. Flags: --category (required), --report (required), --output (optional, defaults to stdout), --help. Unknown flags fail loudly so a typo doesn't silently produce the wrong prompt. - tests/cli-prompt.test.ts: 6 spawn-based smoke tests — arg validation, --help, stdout emission against H&S fixture, --output to file. - CHANGELOG.md + changelog/0.12.0.md + WHATS-NEW.md + readme badges + package.json bump to 0.12.0. Tests: 299/299 (was 293 + 6 new for the CLI). Co-Authored-By: Claude Opus 4.7 (1M context) <noreply@anthropic.com>
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment
Add this suggestion to a batch that can be applied as a single commit.This suggestion is invalid because no changes were made to the code.Suggestions cannot be applied while the pull request is closed.Suggestions cannot be applied while viewing a subset of changes.Only one suggestion per line can be applied in a batch.Add this suggestion to a batch that can be applied as a single commit.Applying suggestions on deleted lines is not supported.You must change the existing code in this line in order to create a valid suggestion.Outdated suggestions cannot be applied.This suggestion has been applied or marked resolved.Suggestions cannot be applied from pending reviews.Suggestions cannot be applied on multi-line comments.Suggestions cannot be applied while the pull request is queued to merge.Suggestion cannot be applied right now. Please check back later.
Summary
Closes the gap between "Lineage tells you what's dead" and "Lineage helps you delete it" — without breaking the read-only / zero-dep promise. Lineage never mutates the model itself; instead it generates a markdown prompt the user pastes into Claude Code (with Kurt Buhler's
pbi-desktopplugin) or any AI agent that can drive TOM / Tabular Editor CLI.Three surfaces:
improvements.mddoc's "unused measures" and "dead-chain" findings each embed a<details>block carrying the same prompt — survives ADO Wiki + GitHub render, so wiki readers get it too.powerbi-lineage prompt --category <c> --report <path> [--output <file>]for batch / CI flows.The prompt itself carries Stage 1 / Stage 2 ordering, an EXTERNALMEASURE guard, a
_-prefix helper-measure flag, a git-commit pre-flight (PBI Desktop's Ctrl+Z does NOT undo TOM changes), and a soft pin topbi-desktopas the recommended tool. No DAX bodies embedded — the AI is already connected to the live model and can read DAX itself before deleting.Zero new runtime deps. Tests: 299/299 (was 276) — 14 new for the builder, 4 new for the MD embed, 6 new for the CLI smoke.
Why this design
A read-only doc generator is what users picked us for. Vendoring
pbi-desktop(GPL-3.0) would license-contaminate the repo; shelling out to TOM via PowerShell would require a 200 MB NuGet install and break the browser-mode + cross-platform promises; TMDL-on-disk pruning would reimplement what TOM already validates atomically, with a huge test surface for edge cases.Generating an AI prompt keeps every existing constraint intact and adds the verb users actually wanted. The user re-points Lineage at the project after running the prompt; the audit shrinks; that's the verification — no diff view needed.
Full decision table and rejected alternatives in
claudedocs/intake-specs/design-ai-cleanup-handoff.md(gitignored — internal-only).Commits in this PR
cf2e2e0— Stops 1–4: pure prompt builder + MD embed + modal + Unused-tab toolbar + inline-script export-stripper hardening.951ca69— Stops 5–6: CLI subcommand + version bump + CHANGELOG + WHATS-NEW + readme badge.Test plan
Automated (already green):
npm test— 299/299 passnpm run build— cleanManual (defer to merge / pre-tag):
.pbipin the dashboard. Confirm the Unused-tab toolbar appears when there are flagged measures and doesn't when there aren't.<details>block expands cleanly; prompt is select-all-able. Paste into a test ADO Wiki page + a GitHub gist — both render correctly.node dist/app.js prompt --category measures-all --report <real-pbip>prints a valid prompt;--output cleanup.mdwrites the same bytes to a file.pbi-desktopplugin installed against a sacrificial.pbip. Delete one disposable test measure via the AI. Reopen the project in Lineage. Confirm the audit shrinks by exactly that measure.Notes for review
src/html-generator.tsis the load-bearing infrastructure fix —ai-prompts.tshasexport functiondeclarations (it's a dual-use module for both server and inline-script), and the old stripper only handled trailing emptyexport {};. Caught mid-implementation when the dashboard rendered blank; covered now by every inline script in the bundle parsing vianew Function()at smoke-test time.findDeadChainMeasuresis duplicated insrc/ai-prompts.tsto keep that module self-contained (so it can concat into the dashboard's classic-script bundle without draggingimprovements.tsalong). Both copies are exercised by tests on each side.🤖 Generated with Claude Code