singularity-forge/scripts/uninstall-pi-global.js
ace-pm 35dc87ef53 chore: sync workspace state after rebrand
- Rebrand commits already in history (gsd → forge)
- Sync pre-existing doc, docker, and CI config updates
- All rebrand artifacts verified in place:
  * Native crates: forge-engine, forge-ast, forge-grep
  * Log prefixes: [forge] across 22+ files
  * Binary: ~/bin/sf-run
  * Workspace scopes: @sf-run/*, @singularity-forge/*
  * Nix flake: Rust toolchain ready

System ready for: nix develop && bun run build:native

Co-Authored-By: Claude Opus 4.6 (1M context) <noreply@anthropic.com>
2026-04-15 14:54:20 +02:00

66 lines
2.1 KiB
JavaScript

#!/usr/bin/env node
import { existsSync, readFileSync, readdirSync, rmSync, rmdirSync } from 'node:fs'
import os from 'node:os'
import { dirname, join, resolve } from 'node:path'
import { fileURLToPath } from 'node:url'
const __dirname = dirname(fileURLToPath(import.meta.url))
const resourcesDir = resolve(__dirname, '..', 'src', 'resources')
const piRoot = join(os.homedir(), '.pi')
const piAgentDir = join(piRoot, 'agent')
const removed = []
const skipped = []
function safeRemove(path, label) {
if (!existsSync(path)) return
rmSync(path, { recursive: true, force: true })
removed.push(label)
}
function removeResourceEntries(containerName) {
const srcDir = join(resourcesDir, containerName)
const destDir = join(piAgentDir, containerName)
if (!existsSync(srcDir) || !existsSync(destDir)) return
for (const entry of readdirSync(srcDir)) {
safeRemove(join(destDir, entry), `${containerName}/${entry}`)
}
try {
if (readdirSync(destDir).length === 0) {
rmdirSync(destDir)
removed.push(`${containerName}/`)
}
} catch {
// ignore non-empty or missing dirs
}
}
function removeIfContentMatches(targetPath, sourcePath, label) {
if (!existsSync(targetPath) || !existsSync(sourcePath)) return
try {
const target = readFileSync(targetPath, 'utf8')
const source = readFileSync(sourcePath, 'utf8')
if (target === source) {
rmSync(targetPath, { force: true })
removed.push(label)
} else {
skipped.push(`${label} (modified, left in place)`)
}
} catch {
skipped.push(`${label} (could not verify, left in place)`)
}
}
removeResourceEntries('extensions')
removeResourceEntries('skills')
removeResourceEntries('agents')
removeIfContentMatches(join(piAgentDir, 'AGENTS.md'), join(resourcesDir, 'AGENTS.md'), 'agent/AGENTS.md')
removeIfContentMatches(join(piRoot, 'SF-WORKFLOW.md'), join(resourcesDir, 'SF-WORKFLOW.md'), 'SF-WORKFLOW.md')
process.stdout.write(
`Removed SF resources from ${piRoot}\n` +
`Removed: ${removed.length ? removed.join(', ') : '(nothing)'}\n` +
(skipped.length ? `Skipped: ${skipped.join(', ')}\n` : '')
)