| name | Dayarc Upgrade |
| description | Check for and apply updates to the Dayarc agent package from GitHub. |
When to Use
User asks to update, upgrade, or check for new versions of the agent — including upgrading to a specific branch or commit, or returning to stable main.
Detecting Install Method
First, determine how Dayarc was installed:
# Check plugin install
$pluginHit = Get-ChildItem -Path (Join-Path $HOME ".copilot\installed-plugins") -Filter "plugin.json" -Recurse -ErrorAction SilentlyContinue | Where-Object {
(Get-Content $_.FullName -Raw | ConvertFrom-Json).name -eq "dayarc"
} | Select-Object -First 1
# Check git clone
$cloneDir = Join-Path $HOME ".dayarc-agent"
$isClone = Test-Path (Join-Path $cloneDir ".git")
- Plugin install →
$pluginHit exists → use copilot plugin update dayarc
- Git clone →
$isClone is true → use git-based upgrade (below)
- Neither found → tell user to reinstall
Plugin Upgrade
If installed as a plugin, do not run the upgrade yourself. Plugin upgrades are managed by the Copilot CLI's built-in slash command, which only the user can invoke from chat. Instruct the user:
To upgrade the Dayarc plugin, run /plugin update dayarc in this chat. Once it finishes, ask me again and I'll re-register the scheduler if needed.
If the user reports the slash command has completed, run the After Update scheduler re-registration steps (skip the file-copy step — the plugin system handles that).
Preview branches are not supported for plugin installs. If the user asks for a preview branch, tell them to use the git clone install method instead.
Git Clone Upgrade
Detecting Preview Mode
Check whether ~/.dayarc-agent/.preview exists. If it does, warn the user:
⚠️ Preview build active — you are running a pre-release commit (<contents of .preview>). This build may be unstable. Say "upgrade to stable" to return to main.
Check for Updates
cd ~/.dayarc-agent
git fetch origin main
Compare HEAD vs origin/main:
- If identical → "Already up to date."
- If behind → show new commits:
git log HEAD..origin/main --oneline
Apply Update (stable, default)
git pull --ff-only origin main
If fast-forward fails (local modifications), tell the user:
Local changes detected. Run irm https://raw.githubusercontent.com/YuiZhou/dayarc-agent/main/setup.ps1 | iex to reinstall cleanly.
After a successful stable update, if ~/.dayarc-agent/.preview exists, delete it.
Preview Upgrade (branch or commit)
Triggered when the user says something like:
- "upgrade to branch feat/triage-bot"
- "upgrade to commit abc1234"
- "preview branch feat/new-feature"
Steps:
-
Warn the user upfront:
⚠️ Preview builds may be unstable and are not suitable for production use. Proceed?
Wait for explicit confirmation ("yes" / "ok" / "proceed"). If the user does not confirm, abort.
-
Guard local changes — stash any uncommitted changes first:
cd ~/.dayarc-agent
git stash --include-untracked
Note the stash result. If the working tree is clean, note that too (nothing to stash).
-
Fetch the ref:
git fetch origin <branch-or-sha>
If the ref looks like a branch name (not a 40-char or abbreviated hex SHA), fetch it as:
git fetch origin refs/heads/<branch>:refs/remotes/origin/<branch>
-
Resolve to a commit SHA:
git rev-parse FETCH_HEAD
-
Detach HEAD to that commit:
git checkout --detach FETCH_HEAD
-
Write the .preview marker with the ref description and resolved SHA:
feat/triage-bot @ abc1234f
Full path: ~/.dayarc-agent/.preview
-
Run After Update steps (copy files, re-register scheduler if applicable).
-
Report:
✅ Now running preview: feat/triage-bot @ abc1234f. Say "upgrade to stable" to return to main.
If git fetch or git checkout fails (e.g., invalid ref), tell the user the ref could not be found and abort without modifying any files.
Return to Stable
Triggered when the user says "upgrade to stable", "rollback", or "go back to main".
cd ~/.dayarc-agent
git fetch origin main
git checkout main
git pull --ff-only origin main
Remove-Item -Path ".preview" -ErrorAction SilentlyContinue
Then run After Update steps as normal. Report:
✅ Restored to stable main. Preview mode cleared.
After Update
-
Read CHANGELOG.md and summarize what changed since the previous HEAD.
-
Git clone only: Copy updated files to ~/.copilot/ (agent profile + skills). Skip for plugin installs — the plugin system handles this.
-
Re-apply user connector MCP entries: Read ~/Documents/dayarc/config.json → connectors. For each connector entry that has an mcp field, apply the following logic:
Read current mcp.json into $mcpConfig
For each $connector in config.json → connectors where $connector.mcp exists:
$name = $connector.name
If $mcpConfig.mcpServers does NOT have key $name:
Build new entry:
command = $connector.mcp.command
args = $connector.mcp.args
env = { for each var in $connector.mcp.env_vars: $var → "REPLACE_ME" }
Add $mcpConfig.mcpServers[$name] = new entry
Mark $name as restored
Write updated mcp.json back
If any connectors were restored, tell the user:
✅ Restored MCP config for connector(s): {restored names}. Your actual credentials were not stored here — check mcp.json and replace any REPLACE_ME values if needed.
If env_vars is empty or absent for a connector, add the entry with no env block.
Skip this step entirely if no connector in config.json has an mcp field.
-
Re-register scheduler if this machine owns one: Read ~/Documents/dayarc/config.json. The scheduler field is an array of { machine, am_time, pm_time } entries. Find the entry where machine matches $env:COMPUTERNAME. If found, find the scheduler.ps1 path (same discovery logic as the scheduler script itself) and re-register:
# Find scheduler.ps1 (plugin or clone)
$pluginHit = Get-ChildItem -Path (Join-Path $HOME ".copilot\installed-plugins") -Filter "scheduler.ps1" -Recurse -ErrorAction SilentlyContinue | Where-Object { (Split-Path $_.DirectoryName -Leaf) -ne "skills" } | Select-Object -First 1
if ($pluginHit) { $script = $pluginHit.FullName }
else { $script = Join-Path $HOME ".dayarc-agent\scheduler.ps1" }
Unregister-ScheduledTask -TaskName "Dayarc-AM" -Confirm:$false -ErrorAction SilentlyContinue
Unregister-ScheduledTask -TaskName "Dayarc-PM" -Confirm:$false -ErrorAction SilentlyContinue
$settings = New-ScheduledTaskSettingsSet -AllowStartIfOnBatteries -DontStopIfGoingOnBatteries -StartWhenAvailable
Register-ScheduledTask -TaskName "Dayarc-AM" -Action (New-ScheduledTaskAction -Execute "powershell.exe" -Argument "-NoProfile -File `"$script`" -trigger am") -Trigger (New-ScheduledTaskTrigger -Weekly -DaysOfWeek Monday,Tuesday,Wednesday,Thursday,Friday -At $amTime) -Settings $settings -Description "Dayarc morning brief"
Register-ScheduledTask -TaskName "Dayarc-PM" -Action (New-ScheduledTaskAction -Execute "powershell.exe" -Argument "-NoProfile -File `"$script`" -trigger pm") -Trigger (New-ScheduledTaskTrigger -Weekly -DaysOfWeek Monday,Tuesday,Wednesday,Thursday,Friday -At $pmTime) -Settings $settings -Description "Dayarc evening brief"
Read am_time and pm_time from the matching entry (default: 08:00 / 20:00).
If no entry matches this machine, skip this step.
Note: The scheduler.ps1 script auto-detects the correct agent name at runtime (dayarc:dayarc for plugin, dayarc for user-level). Re-registering the scheduler after a migration from user-level to plugin (or vice versa) is sufficient — no manual agent name changes needed.
-
Report the new version (latest tag or commit short hash).
Migration: User-Level → Plugin
When upgrading from a user-level install (~/.dayarc-agent/ + ~/.copilot/skills/dayarc-*) to a plugin install:
- The agent name changes from
dayarc to dayarc:dayarc.
- The
scheduler.ps1 script handles this automatically — it detects the install method at startup and uses the correct agent name.
- After plugin install, clean up the old user-level files to avoid confusion:
Remove-Item -Path (Join-Path $HOME ".copilot\agents\dayarc.agent.md") -ErrorAction SilentlyContinue
Get-ChildItem -Path (Join-Path $HOME ".copilot\skills") -Filter "dayarc-*" -Directory | Remove-Item -Recurse -Force
If the old ~/.dayarc-agent/ clone is no longer needed:
Remove-Item -Path (Join-Path $HOME ".dayarc-agent") -Recurse -Force
- Re-register the scheduler tasks (Step 3 above) so the Task Scheduler points to the plugin's
scheduler.ps1.
Version
- Git clone:
git describe --tags --always in ~/.dayarc-agent/.
- Plugin:
copilot plugin list or read plugin.json version field.