(args []string)
| 170 | if _, err := os.Stat(dest); err == nil && !*force { |
| 171 | fmt.Fprintf(os.Stderr, "error: %s already exists; use --force to overwrite\n", dest) |
| 172 | return 1 |
| 173 | } else if err != nil && !os.IsNotExist(err) { |
| 174 | fmt.Fprintf(os.Stderr, "error: stat %s: %v\n", dest, err) |
| 175 | return 1 |
| 176 | } |
| 177 | if err := h.InstallSkill(skillFiles()); err != nil { |
| 178 | fmt.Fprintf(os.Stderr, "error: %v\n", err) |
| 179 | return 1 |
| 180 | } |
| 181 | if err := writeSkillVersion(Version); err != nil { |
| 182 | fmt.Fprintf(os.Stderr, "warning: could not record skill version: %v\n", err) |
| 183 | } |
| 184 | fmt.Printf("installed flow skill to %s\n", dest) |
| 185 | |
| 186 | if *skipHook { |
| 187 | fmt.Println("--skip-hook: leaving harness settings alone") |
| 188 | return 0 |
| 189 | } |
| 190 | if added, err := h.InstallSessionStartHook(hookCommand); err != nil { |
| 191 | fmt.Fprintf(os.Stderr, "warning: could not install SessionStart hook: %v\n", err) |
| 192 | // Non-fatal: the skill is still usable without the hook; the |
| 193 | // user can wire it manually. Return 0 so `flow init` doesn't |
| 194 | // fail on a settings quirk. |
| 195 | return 0 |
| 196 | } else if added { |
| 197 | fmt.Printf("installed SessionStart hook (fires on startup + resume)\n") |
| 198 | } else { |
| 199 | fmt.Println("SessionStart hook already installed — leaving as is") |
| 200 | } |
| 201 | if added, err := h.InstallUserPromptSubmitHook(userPromptSubmitHookCommand); err != nil { |
| 202 | fmt.Fprintf(os.Stderr, "warning: could not install UserPromptSubmit hook: %v\n", err) |
| 203 | return 0 |
| 204 | } else if added { |
| 205 | fmt.Println("installed UserPromptSubmit hook (nudges drift/close-out on bound-session prompts)") |
| 206 | } else { |
| 207 | fmt.Println("UserPromptSubmit hook already installed — leaving as is") |
| 208 | } |
| 209 | if removed, err := h.UninstallPostToolUseHook(postToolUseHookCommand); err == nil && removed { |
| 210 | fmt.Println("removed retired PostToolUse hook (bus delivery now rides `flow inbox pop --wait`)") |
| 211 | } |
| 212 | if added, err := h.InstallStopHook(stopHookCommand); err != nil { |
| 213 | fmt.Fprintf(os.Stderr, "warning: could not install Stop hook: %v\n", err) |
| 214 | return 0 |
| 215 | } else if added { |
no test coverage detected