Skip to content

perf: cache winget list to avoid per-app subprocess calls#5

Merged
ycookiey merged 11 commits intomainfrom
copilot/add-bootstrap-to-app
Mar 16, 2026
Merged

perf: cache winget list to avoid per-app subprocess calls#5
ycookiey merged 11 commits intomainfrom
copilot/add-bootstrap-to-app

Conversation

Copy link
Copy Markdown
Contributor

Copilot AI commented Mar 16, 2026

install/winget.ps1 was calling winget list --id <id> -e inside the loop for every app in wingetfile.json, making setup time linear in app count due to repeated subprocess overhead.

  • Cache installed apps: Call winget list --output json once before the loop, parse JSON, and build a hashtable of installed package IDs for O(1) lookup
  • In-memory lookup: Replace per-iteration winget list --id with $installedAppIds.ContainsKey() against the cached hashtable, ensuring exact ID matching without regex false positives
  • README: Clarify install/wingetfile.json path
# Before: O(n) winget invocations
foreach ($app in $json.apps) {
    $check = winget list --id $app.Id -e 2>$null
    if ($LASTEXITCODE -eq 0 -and $check -match [regex]::Escape($app.Id)) { continue }
}

# After: 1 winget invocation + O(n) hashtable lookups
$installedAppIds = @{}
$installedAppsOutput = winget list --output json 2>$null
if ($LASTEXITCODE -eq 0 -and $installedAppsOutput) {
    $installedAppsJson = $installedAppsOutput | Out-String
    $installedApps = $installedAppsJson | ConvertFrom-Json
    foreach ($pkg in $installedApps) { $installedAppIds[$pkg.Id] = $true }
}

foreach ($app in $json.apps) {
    if ($installedAppIds.ContainsKey($app.Id)) { continue }
}

🔒 GitHub Advanced Security automatically protects Copilot coding agent pull requests. You can protect all pull requests by enabling Advanced Security for your repositories. Learn more about Advanced Security.

…tstrap

Co-authored-by: ycookiey <70356861+ycookiey@users.noreply.github.com>
Copilot AI changed the title [WIP] Add Bootstrap integration to the application bootstrap に Claude Code / Google 日本語入力のインストールを追加 Mar 16, 2026
Copilot AI requested a review from ycookiey March 16, 2026 01:11
Copilot AI changed the title bootstrap に Claude Code / Google 日本語入力のインストールを追加 Discuss bootstrap strategy for Claude Code and Google IME Mar 16, 2026
…-sync

- Add install/wingetfile.json for declarative winget app list
- Add install/winget.ps1 to install from wingetfile.json
- Add winget export auto-sync to pwsh/sync.ps1
- Remove install/claude-code.ps1 (out of scope)
- Remove install/google-ime.ps1 (consolidated into wingetfile.json)
- Update setup.ps1 to call winget.ps1 instead of individual scripts
- Update README.md to reflect wingetfile.json

Co-authored-by: ycookiey <70356861+ycookiey@users.noreply.github.com>
Copilot AI changed the title Discuss bootstrap strategy for Claude Code and Google IME feat: declarative winget management with wingetfile.json and auto-sync Mar 16, 2026
Co-authored-by: ycookiey <70356861+ycookiey@users.noreply.github.com>
Copilot AI changed the title feat: declarative winget management with wingetfile.json and auto-sync feat: winget 宣言的管理 (wingetfile.json + 自動同期) Mar 16, 2026
@ycookiey ycookiey marked this pull request as ready for review March 16, 2026 01:28
Copilot AI review requested due to automatic review settings March 16, 2026 01:28
Copy link
Copy Markdown
Contributor

Copilot AI left a comment

Choose a reason for hiding this comment

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

Pull request overview

Scoop と同様に、Winget アプリを install/wingetfile.json で宣言的に管理し、setup.ps1 の導入処理と pwsh/sync.ps1 の自動同期フローに組み込む PR。

Changes:

  • install/wingetfile.json を追加し、Winget アプリの宣言的リストを導入
  • install/winget.ps1 を追加し、未導入アプリのみを winget install で導入
  • pwsh/sync.ps1winget export ベースの wingetfile 自動同期を追加(winget ソースのみ)

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
setup.ps1 セットアップ中に install/winget.ps1 を実行して winget アプリ導入を統合
pwsh/sync.ps1 winget export から install/wingetfile.json を自動生成・更新する同期処理を追加
install/wingetfile.json Winget 管理対象アプリの宣言ファイルを新規追加
install/winget.ps1 wingetfile.json を読み、未インストール分のみ導入するインストーラを新規追加
README.md Winget アプリが wingetfile から自動導入される旨を追記

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

Co-authored-by: Copilot Autofix powered by AI <175728472+Copilot@users.noreply.github.com>
Co-authored-by: ycookiey <70356861+ycookiey@users.noreply.github.com>
Copilot AI changed the title feat: winget 宣言的管理 (wingetfile.json + 自動同期) perf: cache winget list to avoid per-app subprocess calls Mar 16, 2026
@ycookiey ycookiey requested a review from Copilot March 16, 2026 01:46
Copy link
Copy Markdown
Contributor

Copilot AI left a comment

Choose a reason for hiding this comment

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

Pull request overview

Adds Winget-based app installation to the dotfiles bootstrap flow and improves performance by avoiding repeated WinGet subprocess calls during install checks, while also introducing a Wingetfile sync mechanism.

Changes:

  • Invoke a new install/winget.ps1 from setup.ps1 to install apps listed in install/wingetfile.json.
  • Add Winget export-based synchronization to regenerate install/wingetfile.json from installed Winget-source packages.
  • Update README to document Wingetfile-driven installs.

Reviewed changes

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

Show a summary per file
File Description
setup.ps1 Calls the new Winget installer script during setup and logs the step.
pwsh/sync.ps1 Adds winget export-based generation of install/wingetfile.json.
install/wingetfile.json Introduces declarative Winget app list (initial entry).
install/winget.ps1 Implements Winget install loop with a cached installed-apps check.
README.md Documents that Winget apps are installed from install/wingetfile.json.

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

ycookiey and others added 3 commits March 16, 2026 10:51
Co-authored-by: Copilot Autofix powered by AI <175728472+Copilot@users.noreply.github.com>
Co-authored-by: Copilot Autofix powered by AI <175728472+Copilot@users.noreply.github.com>
Co-authored-by: Copilot Autofix powered by AI <175728472+Copilot@users.noreply.github.com>
Copy link
Copy Markdown
Contributor

Copilot AI left a comment

Choose a reason for hiding this comment

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

Pull request overview

This PR improves the dotfiles bootstrap/setup pipeline by adding Winget-based app installation (driven by install/wingetfile.json) and by avoiding per-app winget list subprocess calls via a cached installed-apps lookup.

Changes:

  • Add install/winget.ps1 and install/wingetfile.json to install Winget apps during setup.ps1.
  • Extend pwsh/sync.ps1 to auto-generate/sync install/wingetfile.json from winget export (winget source only).
  • Update README to document Winget app installation via wingetfile.json.

Reviewed changes

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

Show a summary per file
File Description
setup.ps1 Runs the new Winget install step as part of setup.
pwsh/sync.ps1 Adds best-effort sync of install/wingetfile.json using winget export.
install/wingetfile.json Introduces the Winget app manifest (initial app list).
install/winget.ps1 Installs Winget apps and caches installed apps to reduce subprocess overhead.
README.md Documents that Winget apps are installed from install/wingetfile.json.

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

Comment on lines +12 to +16
# Cache list of installed apps once to avoid repeated winget invocations in the loop
$installedAppIds = @{}
$installedAppsOutput = winget list --output json 2>$null
if ($LASTEXITCODE -eq 0) {
try {
Copy link
Copy Markdown
Owner

Choose a reason for hiding this comment

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

@copilot apply changes based on this feedback

Copy link
Copy Markdown
Contributor Author

Choose a reason for hiding this comment

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

Updated the PR description to accurately reflect the implementation: winget list --output json → JSON parse → hashtable lookup ($installedAppIds.ContainsKey()), not regex matching.

ycookiey and others added 2 commits March 16, 2026 11:30
Co-authored-by: Copilot Autofix powered by AI <175728472+Copilot@users.noreply.github.com>
Co-authored-by: Copilot Autofix powered by AI <175728472+Copilot@users.noreply.github.com>
@ycookiey ycookiey merged commit f34e303 into main Mar 16, 2026
1 check passed
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.

3 participants