/** * Squad upgrade command — overwrites squad-owned files, runs migrations * Zero-dep implementation using Node.js stdlib only * @module cli/core/upgrade */ import { type SquadStateMcpSpec } from './mcp-spec.js'; export { resolveSquadStateMcpSpec } from './mcp-spec.js'; /** * Returns true if the version looks like a local dev build or unpublished * pre-release that cannot be resolved from the public npm registry. * Guards against writing unresolvable version strings into MCP config * (see #1204). */ export declare function isLocalOrUnpublishedVersion(version: string): boolean; export interface UpgradeOptions { migrateDirectory?: boolean; self?: boolean; force?: boolean; /** When --self, install the insider (prerelease) tag instead of latest. */ insider?: boolean; /** Preview what upgrade would change without writing. */ dryRun?: boolean; } export interface UpdateInfo { fromVersion: string; toVersion: string; filesUpdated: string[]; migrationsRun: string[]; } /** * Ensure .gitattributes has required merge=union rules (idempotent) */ export declare function ensureGitattributes(dest: string): string[]; /** * Ensure .gitignore has required entries (idempotent). * Skips entries already covered by a parent path (e.g. `.squad/` covers `.squad/log/`). */ export declare function ensureGitignore(dest: string): string[]; /** * Create missing infrastructure directories */ export declare function ensureDirectories(dest: string): string[]; /** * Scaffold default casting files (registry.json, policy.json, history.json) * if they don't already exist. Sources content from shipped templates when * available, falling back to inline JSON defaults. */ export declare function ensureCastingDefaults(dest: string, templatesDir?: string): string[]; /** * Re-run the ESM import patcher against the project's own node_modules (#1190). * * npm runs postinstall with cwd inside the installed package dir, so a global * `npm install -g` only ever patches the global copy — the consumer repo's * node_modules stays unpatched and `squad doctor` keeps failing its * vscode-jsonrpc / copilot-sdk checks there. Loading the patch script and * pointing it at `/node_modules` closes that gap on every upgrade. * * Returns true when at least one file was patched. */ export declare function ensureEsmImportsPatched(dest: string): Promise; /** Human-readable single-line description of an McpSpec for success() messages. */ export declare function describeMcpSpec(spec: SquadStateMcpSpec): string; export declare function ensureMemoryGovernanceUpgradeDefaults(dest: string): string[]; /** * Migrate the legacy case-sensitive `.squad/agents/Rai/` directory — produced * by prior releases that scaffolded the built-in with a capitalized directory * name — to the canonical lowercase `.squad/agents/rai/`, preserving any * existing charter/history content. * * Detection uses `storage.listSync` (on-disk entry names) rather than * `storage.existsSync('.squad/agents/rai')`, because `existsSync` can report * a false positive for `rai` on case-insensitive filesystems (macOS, Windows) * even when only the legacy `Rai` entry physically exists — that false * positive would make the migration silently no-op on those platforms and * leave the case-sensitive `.squad/agents/Rai/` behind on Linux checkouts of * the same repo. * * Idempotent and duplicate-safe: * - Only `Rai/` exists → rename it in place to `rai/` (single `renameSync`, * same convention as `migrateDirectory`'s `.ai-team/` → `.squad/` rename). * - Both `Rai/` and `rai/` exist (possible on a case-sensitive filesystem * after a partial upgrade) → canonical `rai/` wins; the legacy `Rai/` is * removed without overwriting `rai/`, so no in-place customization at the * canonical location is ever clobbered. * - Neither exists, or only `rai/` exists → no-op. * * @param dest Root directory containing .squad/ * @returns Paths (relative to dest) affected by the migration */ export declare function migrateLegacyRaiAgent(dest: string): { migrated: string[]; tombstoned: string[]; }; /** * Scaffold always-on built-in agent charters (Rai, Fact Checker) that ship * as templates but may be missing from older squads. Idempotent — only writes * when the agent directory is absent. Never overwrites existing charters or * history. Sources charter content from the shipped `templates/{name}-charter.md` * files when available, falling back to a minimal placeholder otherwise. * * Scribe and Ralph are intentionally NOT scaffolded here — they should already * exist in any squad that ran a prior init, and their charters are inlined in * cast.ts (no shipped template file). Adding them here would risk overwriting * customized versions on legacy squads. * * Callers should run `migrateLegacyRaiAgent(dest)` before this function so a * pre-existing legacy `.squad/agents/Rai/` is renamed to `rai/` first — this * function's idempotency check (`storage.existsSync(agentDir)`) would * otherwise miss it on case-sensitive filesystems and scaffold a duplicate. * * @param dest Root directory containing .squad/ * @param templatesDir Directory containing shipped charter templates * @returns Paths (relative to dest) of created agent files */ export declare function ensureBuiltinAgents(dest: string, templatesDir: string): string[]; /** * Install user-owned template files that are missing on disk. * * Iterates TEMPLATE_MANIFEST entries with `overwriteOnUpgrade: false` and * copies each source template to its destination only if the destination * does not yet exist. Existing user-customized files are never touched. * * Called during both `squad init` (post-SDK scaffolding) and `squad upgrade` * (via runEnsureChecks) so that newly-added user-owned templates are installed * for existing squads on upgrade without overwriting any prior customization. */ export declare function ensureUserOwnedTemplates(dest: string, templatesDir: string): string[]; /** * Run the upgrade command */ export declare function runUpgrade(dest: string, options?: UpgradeOptions): Promise; export interface SelfUpgradeOptions { insider?: boolean; force?: boolean; } /** * Self-upgrade the Squad CLI package via the detected package manager. * * Detects whether the CLI was installed via npm, pnpm, or yarn and runs the * appropriate global install command. On EACCES errors, suggests `sudo` with * the detected installer name. */ export declare function selfUpgradeCli(options?: SelfUpgradeOptions): Promise; //# sourceMappingURL=upgrade.d.ts.map