Fix no signer error on git push to nostr remote

both from the terminal or chat interface
This commit is contained in:
DanConwayDev committed 2025-10-30 07:24:05 +00:00
1 parent 0b2003d9f8
commit 930ae56f40
5 files changed
+22 -5

No files matched your search

+1 -1
View File
@@ -154,7 +154,7 @@ export const ChatPane = forwardRef<ChatPaneRef, ChatPaneProps>(({
nostr_read_protocol: new NostrReadProtocolTool(),
nostr_read_nips_index: new NostrReadNipsIndexTool(),
nostr_generate_kind: new NostrGenerateKindTool(),
shell: new ShellTool(fs, cwd, git, projectsPath),
shell: new ShellTool(fs, cwd, git, projectsPath, user?.signer),
read_console_messages: new ReadConsoleMessagesTool(),
};
+4 -2
View File
@@ -7,6 +7,7 @@ import { ShellTool } from '@/lib/tools/ShellTool';
import { useFS } from '@/hooks/useFS';
import { useFSPaths } from '@/hooks/useFSPaths';
import { useGit } from '@/hooks/useGit';
import { useCurrentUser } from '@/hooks/useCurrentUser';
import { ansiToHtml, containsAnsiCodes } from '@/lib/ansiToHtml';
interface TerminalProps {
@@ -35,10 +36,11 @@ export function Terminal({ projectId, className }: TerminalProps) {
const { fs } = useFS();
const { projectsPath } = useFSPaths();
const { git } = useGit();
const { user } = useCurrentUser();
// Initialize ShellTool
useEffect(() => {
shellToolRef.current = new ShellTool(fs, `${projectsPath}/${projectId}`, git, projectsPath);
shellToolRef.current = new ShellTool(fs, `${projectsPath}/${projectId}`, git, projectsPath, user?.signer);
// Add welcome message
setLines([{
@@ -47,7 +49,7 @@ export function Terminal({ projectId, className }: TerminalProps) {
content: `Welcome to Shakespeare Terminal\nType 'help' to see available commands.`,
timestamp: new Date()
}]);
}, [projectId, fs, git, projectsPath]);
}, [projectId, fs, git, projectsPath, user?.signer]);
// Auto-scroll to bottom when new lines are added or execution state changes
useEffect(() => {
+6
View File
@@ -1,6 +1,7 @@
import type { Git } from "../git";
import type { JSRuntimeFS } from "../JSRuntime";
import type { ShellCommand, ShellCommandResult } from "./ShellCommand";
import type { NostrSigner } from "@nostrify/nostrify";
import { createSuccessResult, createErrorResult } from "./ShellCommand";
// Import subcommands
@@ -34,12 +35,14 @@ export interface GitSubcommandOptions {
git: Git;
fs: JSRuntimeFS;
pwd: string;
signer?: NostrSigner;
}
export interface GitCommandOptions {
git: Git;
fs: JSRuntimeFS;
cwd: string;
signer?: NostrSigner;
}
/**
@@ -54,12 +57,14 @@ export class GitCommand implements ShellCommand {
private git: Git;
private fs: JSRuntimeFS;
private cwd: string;
private signer?: NostrSigner;
private subcommands: Map<string, GitSubcommand>;
constructor(options: GitCommandOptions) {
this.git = options.git;
this.fs = options.fs;
this.cwd = options.cwd;
this.signer = options.signer;
this.subcommands = new Map();
// Register all subcommands
@@ -67,6 +72,7 @@ export class GitCommand implements ShellCommand {
git: this.git,
fs: this.fs,
pwd: this.cwd,
signer: this.signer,
};
this.registerSubcommand(new GitInitCommand(subcommandOptions));
+6
View File
@@ -1,5 +1,6 @@
import type { JSRuntimeFS } from "../../JSRuntime";
import type { ShellCommandResult } from "../ShellCommand";
import type { NostrSigner } from "@nostrify/nostrify";
import { createSuccessResult, createErrorResult } from "../ShellCommand";
import type { GitSubcommand, GitSubcommandOptions } from "../git";
import type { Git } from "../../git";
@@ -14,11 +15,13 @@ export class GitPushCommand implements GitSubcommand {
private git: Git;
private fs: JSRuntimeFS;
private pwd: string;
private signer?: NostrSigner;
constructor(options: GitSubcommandOptions) {
this.git = options.git;
this.fs = options.fs;
this.pwd = options.pwd;
this.signer = options.signer;
}
async execute(args: string[]): Promise<ShellCommandResult> {
@@ -73,6 +76,7 @@ export class GitPushCommand implements GitSubcommand {
ref: targetBranch,
remoteRef: targetBranch,
onAuth: (url) => findCredentialsForRepo(url, settings.credentials),
signer: this.signer,
});
return createSuccessResult(`To ${remoteUrl}\n ${targetBranch} -> ${targetBranch}\n`);
@@ -85,6 +89,8 @@ export class GitPushCommand implements GitSubcommand {
return createErrorResult(`error: failed to push some refs to '${remoteUrl}'\nhint: Updates were rejected because the remote contains work that you do not have locally.`);
} else if (error.message.includes('network')) {
return createErrorResult('fatal: unable to access remote repository. Please check your network connection.');
} else if (error.message.includes('Nostr signer is required')) {
return createErrorResult('fatal: Nostr signer is required for pushing to Nostr repositories. Please log in with a Nostr account.');
}
}
+5 -2
View File
@@ -4,6 +4,7 @@ import type { JSRuntimeFS } from "../JSRuntime";
import type { ShellCommand } from "../commands/ShellCommand";
import { Git } from "../git";
import { stripAnsiCodes } from "../ansiToHtml";
import type { NostrSigner } from "@nostrify/nostrify";
import {
CatCommand,
CdCommand,
@@ -51,6 +52,7 @@ export class ShellTool implements Tool<ShellToolParams> {
private git: Git;
private commands: Map<string, ShellCommand>;
private projectsPath: string;
private signer?: NostrSigner;
readonly description = "Execute shell commands like cat, ls, cd, pwd, rm, cp, mv, echo, head, tail, grep, find, wc, touch, mkdir, sort, uniq, cut, tr, sed, diff, which, whoami, date, env, clear, git, curl, unzip, hexdump. Supports compound commands with &&, ||, ;, and | operators, and output redirection with > and >> operators";
@@ -60,11 +62,12 @@ export class ShellTool implements Tool<ShellToolParams> {
),
});
constructor(fs: JSRuntimeFS, cwd: string, git: Git, projectsPath: string = '/projects') {
constructor(fs: JSRuntimeFS, cwd: string, git: Git, projectsPath: string = '/projects', signer?: NostrSigner) {
this.fs = fs;
this.cwd = cwd;
this.git = git;
this.projectsPath = projectsPath;
this.signer = signer;
this.commands = new Map();
// Register available commands
@@ -79,7 +82,7 @@ export class ShellTool implements Tool<ShellToolParams> {
this.registerCommand(new EchoCommand());
this.registerCommand(new EnvCommand());
this.registerCommand(new FindCommand(fs));
this.registerCommand(new GitCommand({ git: this.git, fs, cwd: this.cwd }));
this.registerCommand(new GitCommand({ git: this.git, fs, cwd: this.cwd, signer: this.signer }));
this.registerCommand(new GrepCommand(fs));
this.registerCommand(new HeadCommand(fs));
this.registerCommand(new HexdumpCommand(fs));