Repository navigation
External agent composer: structured prompts, @ files, and queue #54
New issue
Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.
Already on GitHub? Sign in to your account
Merged
Merged
Changes from all commits
Commits
Show all changes
9 commits
Select commit
Hold shift + click to select a range
e142c0e
Add structured chat blocks and searchEntries FS contract.
soorya-u 419dc2b
Wire worker FS search and structured ACP prompt mapping.
soorya-u 28a62d9
Add prompt queue and remote file search hooks.
soorya-u 257ba34
Add Lexical composer with @ mentions, queue, and chips.
soorya-u f0719ab
Update composer specs for external agent capabilities.
soorya-u 8301cab
Fix searchFiles type narrowing for file vs mixed search.
soorya-u f6dd3ca
Update agent instructions for development conventions.
soorya-u 17dc9b8
Address PR review feedback for composer and agent runtime.
soorya-u d9adbc4
Archive external-agent-composer and sync specs to main.
soorya-u File filter
Filter by extension
Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
There are no files selected for viewing
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
| Original file line number | Diff line number | Diff line change |
|---|---|---|
| @@ -1,7 +1,8 @@ | ||
| # Instructions for {{ var.agent_name }} from {{ env.app_name }} | ||
|
|
||
| ## Project | ||
|
|
||
| Cyrus is a cross-platform app for controlling AI coding agents (Claude Code, Codex, and others) that run across a user's own devices — desktop, mobile, web, laptops, and servers. | ||
|
|
||
| It is single-user and personal: every device a user owns joins that user's one "room." Thread metadata is shared across all devices through a minimal server, while agent execution stays local to the device that owns it. The guiding principle is **shared metadata, owned execution** — letting the user start, observe, and continue the same agent conversation from any of their devices in real time. | ||
| ## Coding Criterias | ||
|
|
||
| - This Project is still in development, so no backward compatibility is required. | ||
| - This project highly values "error as values" than exceptions. So always prefer "`better-result` library to get error as values. |
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
| Original file line number | Diff line number | Diff line change |
|---|---|---|
| @@ -0,0 +1,30 @@ | ||
| import { describe, expect, test } from "bun:test"; | ||
| import { mapPromptBlocksToAcp } from "@/core/agents/prompt"; | ||
|
|
||
| describe("prompt-blocks", () => { | ||
| test("maps text and resource blocks to ACP content", () => { | ||
| const blocks = [ | ||
| { type: "text" as const, text: "review this" }, | ||
| { type: "resource" as const, uri: "src/index.ts", name: "index.ts" }, | ||
| { | ||
| type: "resource" as const, | ||
| uri: "https://example.com/docs", | ||
| name: "docs", | ||
| }, | ||
| ]; | ||
|
|
||
| expect(mapPromptBlocksToAcp(blocks, "/tmp/project")).toEqual([ | ||
| { type: "text", text: "review this" }, | ||
| { | ||
| type: "resource_link", | ||
| uri: "file:///tmp/project/src/index.ts", | ||
| name: "index.ts", | ||
| }, | ||
| { | ||
| type: "resource_link", | ||
| uri: "https://example.com/docs", | ||
| name: "docs", | ||
| }, | ||
| ]); | ||
| }); | ||
| }); |
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
| Original file line number | Diff line number | Diff line change |
|---|---|---|
| @@ -0,0 +1,40 @@ | ||
| import { resolve } from "node:path"; | ||
| import { pathToFileURL } from "node:url"; | ||
| import type { ContentBlock } from "@agentclientprotocol/sdk"; | ||
| import type { PromptInputBlock } from "@cyrus/schemas/rtc/chat"; | ||
|
|
||
| const HTTP_URI_PATTERN = /^https?:\/\//i; | ||
|
|
||
| export function mapPromptBlocksToAcp( | ||
| blocks: PromptInputBlock[], | ||
| threadCwd: string | ||
| ): ContentBlock[] { | ||
| return blocks.map((block) => mapPromptBlockToAcp(block, threadCwd)); | ||
| } | ||
|
|
||
| function mapPromptBlockToAcp( | ||
| block: PromptInputBlock, | ||
| threadCwd: string | ||
| ): ContentBlock { | ||
| if (block.type === "text") { | ||
| return { type: "text", text: block.text }; | ||
| } | ||
|
|
||
| const uri = resolveResourceUri(block.uri, threadCwd); | ||
| const name = block.name ?? uri.split("/").pop() ?? uri; | ||
|
|
||
| return { | ||
| type: "resource_link", | ||
| uri, | ||
| name, | ||
| }; | ||
| } | ||
|
|
||
| function resolveResourceUri(uri: string, threadCwd: string): string { | ||
| if (HTTP_URI_PATTERN.test(uri) || uri.startsWith("file://")) { | ||
| return uri; | ||
| } | ||
|
|
||
| const absolute = resolve(threadCwd, uri); | ||
| return pathToFileURL(absolute).href; | ||
| } | ||
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Oops, something went wrong.
Add this suggestion to a batch that can be applied as a single commit.
This suggestion is invalid because no changes were made to the code.
Suggestions cannot be applied while the pull request is closed.
Suggestions cannot be applied while viewing a subset of changes.
Only one suggestion per line can be applied in a batch.
Add this suggestion to a batch that can be applied as a single commit.
Applying suggestions on deleted lines is not supported.
You must change the existing code in this line in order to create a valid suggestion.
Outdated suggestions cannot be applied.
This suggestion has been applied or marked resolved.
Suggestions cannot be applied from pending reviews.
Suggestions cannot be applied on multi-line comments.
Suggestions cannot be applied while the pull request is queued to merge.
Suggestion cannot be applied right now. Please check back later.
Uh oh!
There was an error while loading. Please reload this page.