|
1 | 1 | import { copyFileSync, existsSync } from "node:fs"; |
2 | 2 | import { homedir } from "node:os"; |
3 | 3 | import { join } from "node:path"; |
4 | | -import { GeminiConnector } from "@signet/connector-gemini"; |
5 | | -import { HermesAgentConnector } from "@signet/connector-hermes-agent"; |
6 | | -import { OhMyPiConnector } from "@signet/connector-oh-my-pi"; |
7 | 4 | import { OpenClawConnector } from "@signet/connector-openclaw"; |
8 | | -import { PiConnector } from "@signet/connector-pi"; |
9 | | -import type { WorkspaceSourceRepoSyncResult } from "@signet/core"; |
| 5 | +import { |
| 6 | + type WorkspaceSourceRepoSyncResult, |
| 7 | + getOhMyPiConfigPath, |
| 8 | + getPiConfigPath, |
| 9 | + loadConfiguredHarnesses, |
| 10 | + resolveHermesRepoPath, |
| 11 | +} from "@signet/core"; |
10 | 12 | import chalk from "chalk"; |
11 | 13 |
|
12 | 14 | interface SkillSync { |
@@ -149,7 +151,23 @@ async function syncNative(basePath: string, deps: Deps): Promise<number> { |
149 | 151 |
|
150 | 152 | async function syncHarnessHooks(basePath: string, deps: Deps): Promise<number> { |
151 | 153 | let synced = 0; |
152 | | - for (const harness of detectHarnesses()) { |
| 154 | + const harnesses = [...loadConfiguredHarnesses(basePath)]; |
| 155 | + const detected = detectInstalledHarnesses(); |
| 156 | + if (detected.length > 0) { |
| 157 | + console.log(chalk.dim(` Installed harnesses detected: ${detected.join(", ")}`)); |
| 158 | + } |
| 159 | + |
| 160 | + if (harnesses.length === 0) { |
| 161 | + console.log(chalk.dim(" No active harnesses configured; skipping hook re-registration")); |
| 162 | + return 0; |
| 163 | + } |
| 164 | + |
| 165 | + const inactive = detected.filter((harness) => !harnesses.includes(harness)); |
| 166 | + if (inactive.length > 0) { |
| 167 | + console.log(chalk.dim(` Installed but inactive: ${inactive.join(", ")}`)); |
| 168 | + } |
| 169 | + |
| 170 | + for (const harness of harnesses) { |
153 | 171 | try { |
154 | 172 | let runtimePath: "plugin" | "legacy" | undefined; |
155 | 173 | if (harness === "openclaw") { |
@@ -180,34 +198,32 @@ async function syncHarnessHooks(basePath: string, deps: Deps): Promise<number> { |
180 | 198 | return synced; |
181 | 199 | } |
182 | 200 |
|
183 | | -function detectHarnesses(): string[] { |
| 201 | +function detectInstalledHarnesses(): string[] { |
184 | 202 | const found: string[] = []; |
| 203 | + const home = process.env.HOME ?? homedir(); |
185 | 204 |
|
186 | | - if (existsSync(join(homedir(), ".claude", "settings.json"))) { |
| 205 | + if (existsSync(join(home, ".claude", "settings.json"))) { |
187 | 206 | found.push("claude-code"); |
188 | 207 | } |
189 | | - if ( |
190 | | - existsSync(join(homedir(), ".config", "signet", "bin", "codex")) || |
191 | | - existsSync(join(homedir(), ".codex", "config.toml")) |
192 | | - ) { |
| 208 | + if (existsSync(join(home, ".config", "signet", "bin", "codex")) || existsSync(join(home, ".codex", "config.toml"))) { |
193 | 209 | found.push("codex"); |
194 | 210 | } |
195 | | - if (existsSync(join(homedir(), ".config", "opencode"))) { |
| 211 | + if (existsSync(join(home, ".config", "opencode"))) { |
196 | 212 | found.push("opencode"); |
197 | 213 | } |
198 | 214 | if (new OpenClawConnector().isInstalled()) { |
199 | 215 | found.push("openclaw"); |
200 | 216 | } |
201 | | - if (new OhMyPiConnector().isInstalled()) { |
| 217 | + if (existsSync(getOhMyPiConfigPath())) { |
202 | 218 | found.push("oh-my-pi"); |
203 | 219 | } |
204 | | - if (new HermesAgentConnector().isInstalled()) { |
| 220 | + if (resolveHermesRepoPath() !== null || existsSync(join(home, ".hermes"))) { |
205 | 221 | found.push("hermes-agent"); |
206 | 222 | } |
207 | | - if (new GeminiConnector().isInstalled()) { |
| 223 | + if (existsSync(join(home, ".gemini", "settings.json"))) { |
208 | 224 | found.push("gemini"); |
209 | 225 | } |
210 | | - if (new PiConnector().isInstalled()) { |
| 226 | + if (existsSync(getPiConfigPath())) { |
211 | 227 | found.push("pi"); |
212 | 228 | } |
213 | 229 |
|
|
0 commit comments