Skip to content

build: Flatten scoped shipped plugin paths - #790

Open
skoeva wants to merge 2 commits into
Azure:mainfrom
skoeva:shipped
Open

build: Flatten scoped shipped plugin paths#790
skoeva wants to merge 2 commits into
Azure:mainfrom
skoeva:shipped

Conversation

@skoeva

@skoeva skoeva commented Jul 24, 2026

Copy link
Copy Markdown
Collaborator

Scoped plugin names created nested directories under .plugins, but Headlamp only discovers direct children. This flattens scoped plugin paths while preserving the canonical package identity.

Fixes: #787

Changes

  • Package AI Assistant at .plugins/ai-assistant
  • Preserve @headlamp-k8s/ai-assistant in package.json
  • Add regression coverage and run it in CI

Testing

  • npm run test:build
  • npm run plugin:setup
  • Built the macOS app and confirmed AI Assistant appears as Shipped under Settings -> Plugins

Screenshot

image

@skoeva
skoeva requested a review from Copilot July 24, 2026 18:39
@skoeva skoeva self-assigned this Jul 24, 2026
@skoeva skoeva added the github_actions Pull requests that update GitHub Actions code label Jul 24, 2026

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.

Pull request overview

Flattens the on-disk directory layout for shipped plugins under headlamp/.plugins so that scoped package names (e.g. @headlamp-k8s/ai-assistant) are packaged as direct children (e.g. .plugins/ai-assistant), matching Headlamp’s plugin discovery behavior and fixing the missing AI Assistant shipped plugin regression.

Changes:

  • Adds a copyShippedPlugin() helper to package built plugin artifacts into a flattened shipped-plugin directory (and remove the legacy scoped path).
  • Adds build-script regression tests for the plugin packaging behavior and wires them into CI.
  • Adds a root test:build script to run build script tests via tsx.

Reviewed changes

Copilot reviewed 5 out of 5 changed files in this pull request and generated 2 comments.

Show a summary per file
File Description
package.json Adds test:build script to run build-script unit tests.
build/setup-plugins.ts Switches plugin copying logic to the new helper to flatten shipped plugin paths.
build/plugin-packaging.ts Introduces copyShippedPlugin() to flatten scoped plugin output paths and clean up legacy directories.
build/plugin-packaging.test.ts Adds regression tests ensuring scoped plugins are flattened and unscoped plugins keep their directory name.
.github/workflows/ci.yml Adds a CI job to run the new build-script tests.

💡 Add Copilot custom instructions for smarter, more guided reviews. Learn how to get started.

Comment thread build/plugin-packaging.ts
Comment thread package.json Outdated
Copilot AI review requested due to automatic review settings July 24, 2026 18:43

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.

Pull request overview

Copilot reviewed 5 out of 5 changed files in this pull request and generated 1 comment.

Comments suppressed due to low confidence (2)

build/plugin-packaging.ts:23

  • copyShippedPlugin recreates the target directory but never removes existing contents. If a previous build left files that are no longer emitted by dist/, those stale artifacts will remain in the shipped plugin directory and can cause runtime issues or confusing debugging.
  fs.mkdirSync(targetDir, { recursive: true });

package.json:16

  • test:build relies on a shell glob (build/*.test.ts). On Windows (where npm scripts run via cmd.exe by default), this glob typically won’t expand, causing the script to fail to find any test files.
    "test:build": "tsx --test build/*.test.ts",

Comment thread build/plugin-packaging.ts Outdated
Copilot AI review requested due to automatic review settings July 24, 2026 18:47

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.

Pull request overview

Copilot reviewed 5 out of 5 changed files in this pull request and generated 1 comment.

Comments suppressed due to low confidence (1)

build/plugin-packaging.ts:3

  • New build/ TypeScript files in this repo typically include the standard copyright/license header and use single quotes for imports/strings (see build/setup-plugins.ts, build/setup-external-tools.ts). Adding the header here and switching the imports to single quotes will keep build tooling consistent.
import * as fs from "fs";
import * as path from "path";

Comment thread build/plugin-packaging.test.ts Outdated
Copilot AI review requested due to automatic review settings July 24, 2026 18:51
@skoeva
skoeva marked this pull request as ready for review July 24, 2026 18:52

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.

Pull request overview

Copilot reviewed 5 out of 5 changed files in this pull request and generated 1 comment.

Comment thread build/plugin-packaging.ts Outdated
skoeva added 2 commits July 24, 2026 15:11
Signed-off-by: Evangelos Skopelitis <eskopelitis@microsoft.com>
Signed-off-by: Evangelos Skopelitis <eskopelitis@microsoft.com>
Copilot AI review requested due to automatic review settings July 24, 2026 19:11

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.

Pull request overview

Copilot reviewed 5 out of 5 changed files in this pull request and generated no new comments.

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

left a small suggestion, not a blocker though

return { pluginDir, pluginsDir };
}

test('copies a scoped plugin to a direct shipped-plugin directory', () => {

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.

I think instead of separate test file for copyShippedPlugin function it would be better to validate that all the expected plugins got bundled properly in an extra validation step inside setup-plugins.ts, similar to how it's done with external tools in verify-bundled-tools.ts, what do you think?

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

Labels

github_actions Pull requests that update GitHub Actions code

Projects

None yet

Development

Successfully merging this pull request may close these issues.

[BUG] AI Assistant plugin missing in 0.9.0

3 participants