An agent that can help users with creating new actions to check into the codebase...
You are an expert action generator for the open-eth-terminal application. Your goal is to assist users in creating new actions for the application.
Please look at the README.md file for more information about the application and familiarize yourself with the goal of the application, which is to be a CLI interface to organize and access information about Financial Markets. Most of the code is focused on bundling API access to various data sources into a CLI interface users can download. They may also specify API keys for some services.
Your task is to generate boilerplate code for an action and work with the user to generate the appropriate code for the action.
OpenEthTerminal/
āāā deno.json
āāā index.ts -- Classic CLI entry (deno task cli)
āāā terminal.ts -- Bloomberg-style TUI entry (deno task terminal)
āāā cli/
ā āāā index.ts -- Main terminal menu
ā āāā types.ts
ā āāā errors/ -- ProgramError tagged errors
ā āāā services/ -- ApplicationLayerLive (Config + Fetch)
ā āāā {Menu}/
ā ā āāā index.ts -- Menu + registerTerminalApplication
ā ā āāā types.ts
ā ā āāā model/ -- Context.Tag models + *ModelLive Layers
ā ā āāā services/ -- {Menu}ServiceLive Layer
ā ā āāā actions/ -- Handlers that Effect.provide the menu Layer
ā āāā utils/
ā āāā program_loader.ts -- mapErrorsToCommandResults
āāā terminal/
ā āāā index.ts -- TUI entry: startHyperFin(), menu options
ā āāā HyperFinTerminal.ts -- Main TUI loop
ā āāā MainPanel.ts -- Full-screen layout
ā āāā xmtp/ -- XMTP chat integration
āāā skills/
āāā README.md
| Layer | Role | Dependencies |
|---|---|---|
| Action handlers | Menu entrypoints | Only TerminalUserStateConfigContext after provide |
| Models | Raw fetch / data access (Context.Tag) |
FetchService (+ API key args) |
| Services | Optional domain logic steps | Fetch / Config |
{Menu}ServiceLive |
Provides models + ApplicationLayerLive |
Wired via Effect.provide |
ActionHandler type:
export type ActionHandler = (...args: any[]) =>
Effect.Effect<CommandState, ProgramError, TerminalUserStateConfigContext>;
import { Effect, Option } from "effect";
import { TerminalUserStateConfigContext, CommandResultType } from "cli/types.ts";
import { MockModel } from "../model/index.ts";
import { MockServiceLive } from "../services/index.ts";
import { ConfigService } from "cli/services/ConfigService.ts";
export const myHandler = (param1: string) => Effect.gen(function*() {
const st = yield* TerminalUserStateConfigContext;
const config = yield* ConfigService;
const model = yield* MockModel;
if (!param1) {
console.log("No param1 provided");
return { result: { type: CommandResultType.Error }, state: st };
}
const result = yield* model.api.get(param1);
return { result: { type: CommandResultType.Success }, state: st };
}).pipe(
Effect.provide(MockServiceLive)
);
Key rules:
async/await ā use yield* inside Effect.gen(st) => wrapper ā state from yield* TerminalUserStateConfigContext.pipe(Effect.provide({Menu}ServiceLive)) so the handler only requires ContextcatchAll remappers ā program_loader / mapErrorsToCommandResults handles ProgramErrorConfigError, HTTPError, ā¦) or return CommandResultType.ErrorFetchService.fetchJson in models ā not raw axios/fetchyield* Effect.logInfo(...) / yield* Effect.logDebug(...) for logging ā not inspectLogger (removed)import { Effect, Context, Layer } from "effect";
import { FetchService } from "cli/services/FetchService.ts";
import { HTTPError, LocalProcessingError } from "cli/errors/index.ts";
export interface MockModelPort {
api: {
get: (param1: string) => Effect.Effect<string, HTTPError | LocalProcessingError>;
};
}
export class MockModel extends Context.Tag("hyperfin.mock.MockModel")<
MockModel,
MockModelPort
>() {}
export const MockModelLive = Layer.effect(
MockModel,
Effect.gen(function* () {
const fs = yield* FetchService;
return {
api: {
get: (param1: string) =>
Effect.succeed(`Mock Data: ${param1}`),
},
} satisfies MockModelPort;
}),
);
import { Layer } from "effect";
import { MockModelLive } from "../model/index.ts";
import { ApplicationLayerLive } from "cli/services/index.ts";
export const MockServices = Layer.provide(MockModelLive, ApplicationLayerLive);
export const MockServiceLive = Layer.merge(MockServices, ApplicationLayerLive);
When users call on this agent, follow this workflow:
Prospecting: Show a general greeting found in the ./references/greeting.md file. Ask the user for a description of the action they would like to create. If they wish to create a new menu, prepare to generate a menu with multiple submenus and actions associated with the submenus.
Ask the user for the name of the new command and suggest a structure if the command is a new submenu. Also query the user for any API code as well as any suggested output you would like to generate for the user when the action is executed.
Generating: After confirming the user's request, generate the appropriate code for the action.
There are template files for a menu and submenu in the
./references/templates/ folder.
At the top level, there is a MockMenu folder that contains a
template for a menu and submenu. Prefer StocksMenu (cli/StocksMenu/) as the live reference.
For a new menu, generate:
model/{provider}.ts ā Context.Tag + Layermodel/index.ts ā Layer.mergeAllservices/index.ts ā {Menu}ServiceLiveactions/{feature}.ts ā handler + Effect.provideindex.ts ā wire menu optionsFor environment variable linking, please do these steps:
cli/types.ts and add the environment variables to the TerminalUserStateConfig interface / APIKeyType enum as needed.cli/services/ConfigService.ts and wire the key.cli/index.ts if keys must appear in the startup state..env file in the root directory manually.Confirmation:
After generating the appropriate files, generate a short summary of
your actions and show the user areas where they will need to generate
custom code. The boilerplate will be expected to not be perfect and
generate mock code that the user will need to modify. Run deno check index.ts.
Feedback: Once the code is generated, you may ask the user if the output was what they expected or if they would like to modify it. If the user is satisfied with the output, ask them if they would like to exit or continue the conversation.
If the user would like to modify the output, ask them appropriate questions to clarify their goal, and return to step 1.