Skip to content

Conversation

mrubens
Copy link
Collaborator

@mrubens mrubens commented Nov 21, 2024

Asked Cline to write a standalone version of itself. 🤯


Important

Introduces a standalone CLI for Cline, an AI coding assistant, with task execution capabilities using OpenRouter API and various tools.

  • CLI Implementation:
    • Adds cline CLI tool in mod.ts for executing tasks with AI models.
    • Supports options for model selection, API key input, and debug mode.
  • API Integration:
    • Implements OpenRouterHandler in openrouter.ts for API communication.
    • buildApiHandler function in mod.ts to initialize API handlers.
  • Core Functionality:
    • StandaloneAgent in StandaloneAgent.ts manages task execution and tool usage.
    • SYSTEM_PROMPT in prompts.ts defines the agent's behavior and available tools.
  • Tools:
    • Implements file and command operations in tools/mod.ts (e.g., executeCommand, readFile).
  • Documentation:
    • Adds README.md with installation, configuration, and usage instructions.
  • Package Configuration:
    • deno.jsonc includes dependencies and scripts for building and running the CLI.

This description was created by Ellipsis for 1c471bd. It will automatically update as commits are pushed.

@mrubens mrubens requested a review from stea9499 November 21, 2024 04:54
Copy link

@ellipsis-dev ellipsis-dev bot left a comment

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

❌ Changes requested. Reviewed everything up to e341b63 in 1 minute and 6 seconds

More details
  • Looked at 936 lines of code in 9 files
  • Skipped 2 files when reviewing.
  • Skipped posting 4 drafted comments based on config settings.
1. cli/src/api/providers/openrouter.ts:30
  • Draft comment:
    fetch is used but not imported. Ensure fetch is available in the environment or import it explicitly.
  • Reason this comment was not posted:
    Comment did not seem useful.
2. cli/src/tools/index.ts:76
  • Draft comment:
    fs.readdir does not support a recursive option. Consider implementing a recursive directory traversal manually. This comment also applies to the searchFiles function.
  • Reason this comment was not posted:
    Marked as duplicate.
3. cli/src/api/providers/openrouter.ts:17
4. cli/src/tools/index.ts:13

Workflow ID: wflow_kTRmKqnXKvE5Gu5l


Want Ellipsis to fix these issues? Tag @ellipsis-dev in a comment. You can customize Ellipsis with 👍 / 👎 feedback, review rules, user-specific overrides, quiet mode, and more.

@@ -0,0 +1,122 @@
import { exec } from 'child_process';
Copy link

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Using exec can lead to command injection vulnerabilities. Consider using execFile or properly sanitize inputs.

): Promise<ToolResponse> {
try {
const fullPath = path.join(workingDir, searchPath);
const files = await fs.readdir(fullPath, { recursive: true });
Copy link

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

fs.readdir does not support a recursive option. Consider implementing a recursive directory traversal manually.

Suggested change
const files = await fs.readdir(fullPath, { recursive: true });
const files = await fs.readdir(fullPath);

cli/src/index.ts Outdated
@@ -0,0 +1,94 @@
#!/usr/bin/env node
Copy link

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Ensure that unit tests and integration tests are included for the new functionality, with at least 80% test coverage, as per our Development Standards: https://www.notion.so/Development-Standards-59febcf8ead647fd9c2ec3f60c22f3df?pvs=4#11869ad2d58180f7b224d6db54dab6b5

// Only execute one tool at a time
break;

} catch (error: any) {
Copy link

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Implement centralized error handling and structured logging for consistent error responses and easier debugging, as per our Development Standards: https://www.notion.so/Development-Standards-59febcf8ead647fd9c2ec3f60c22f3df?pvs=4#11869ad2d58180bc982fd2d560354e47

Copy link

@ellipsis-dev ellipsis-dev bot left a comment

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

❌ Changes requested. Incremental review on 485c7e5 in 1 minute and 10 seconds

More details
  • Looked at 1058 lines of code in 13 files
  • Skipped 1 files when reviewing.
  • Skipped posting 8 drafted comments based on config settings.
1. cli/src/tools/index.ts:76
  • Draft comment:
    fs.readdir does not support a recursive option. Consider using a library like recursive-readdir or implement a custom recursive function to list files.
  • Reason this comment was not posted:
    Marked as duplicate.
2. cli/src/tools/index.ts:11
3. cli/src/tools/index.ts:21
4. cli/src/tools/index.ts:31
5. cli/src/tools/index.ts:58
6. cli/src/tools/index.ts:76
7. cli/src/tools/index.ts:87
8. cli/src/tools/index.ts:112

Workflow ID: wflow_YXuc2j2PsP77lv5O


Want Ellipsis to fix these issues? Tag @ellipsis-dev in a comment. You can customize Ellipsis with 👍 / 👎 feedback, review rules, user-specific overrides, quiet mode, and more.

): Promise<ToolResponse> {
try {
const fullPath = path.join(workingDir, searchPath);
const files = await fs.readdir(fullPath, { recursive: true });
Copy link

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

fs.readdir does not support a recursive option. Consider using a library like recursive-readdir or implement a custom recursive function to list files.


const execAsync = promisify(exec);

export async function executeCommand(command: string): Promise<ToolResponse> {
Copy link

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Be cautious with exec as it can lead to command injection vulnerabilities. Consider using execFile or validating/sanitizing input to mitigate risks.

Copy link

@ellipsis-dev ellipsis-dev bot left a comment

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

❌ Changes requested. Incremental review on 4afd2f7 in 1 minute and 23 seconds

More details
  • Looked at 1059 lines of code in 13 files
  • Skipped 1 files when reviewing.
  • Skipped posting 9 drafted comments based on config settings.
1. cli/src/tools/index.ts:76
  • Draft comment:
    fs.readdir does not support a recursive option. Consider using a library like recursive-readdir or implement a custom recursive function to list files.
  • Reason this comment was not posted:
    Marked as duplicate.
2. cli/src/tools/index.ts:13
3. cli/src/index.ts:21
4. cli/src/api/index.ts:7
5. cli/src/tools/index.ts:9
6. cli/src/core/StandaloneAgent.ts:25
7. cli/src/api/providers/openrouter.ts:122
8. cli/package.json:32
9. cli/src/index.ts:20

Workflow ID: wflow_ZFmyTqyzZOOKamMA


Want Ellipsis to fix these issues? Tag @ellipsis-dev in a comment. You can customize Ellipsis with 👍 / 👎 feedback, review rules, user-specific overrides, quiet mode, and more.

): Promise<ToolResponse> {
try {
const fullPath = path.join(workingDir, searchPath);
const files = await fs.readdir(fullPath, { recursive: true });
Copy link

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

fs.readdir does not support a recursive option. Consider using a library like recursive-readdir or implement a custom recursive function to list files.

const content = await fs.readFile(fullPath, 'utf8');

// Basic regex patterns for common code definitions
const patterns = {
Copy link

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Using regex to parse JavaScript code can be unreliable. Consider using a JavaScript parser like acorn or esprima for more accurate code analysis.

Copy link

@ellipsis-dev ellipsis-dev bot left a comment

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

❌ Changes requested. Incremental review on 459851e in 1 minute and 33 seconds

More details
  • Looked at 1105 lines of code in 13 files
  • Skipped 1 files when reviewing.
  • Skipped posting 9 drafted comments based on config settings.
1. cli/src/tools/index.ts:76
  • Draft comment:
    fs.readdir does not support a recursive option. Consider using a library like recursive-readdir or implement a custom recursive function to list files.
  • Reason this comment was not posted:
    Marked as duplicate.
2. cli/src/tools/index.ts:11
  • Draft comment:
    Using async/await makes asynchronous code more readable and easier to maintain than chaining .then() calls. Please refactor this to use async/await. This is from our Development Standards: Development Standards.
  • Reason this comment was not posted:
    Comment looked like it was already resolved.
3. cli/src/tools/index.ts:21
  • Draft comment:
    Using async/await makes asynchronous code more readable and easier to maintain than chaining .then() calls. Please refactor this to use async/await. This is from our Development Standards: Development Standards.
  • Reason this comment was not posted:
    Marked as duplicate.
4. cli/src/tools/index.ts:31
  • Draft comment:
    Using async/await makes asynchronous code more readable and easier to maintain than chaining .then() calls. Please refactor this to use async/await. This is from our Development Standards: Development Standards.
  • Reason this comment was not posted:
    Marked as duplicate.
5. cli/src/tools/index.ts:58
  • Draft comment:
    Using async/await makes asynchronous code more readable and easier to maintain than chaining .then() calls. Please refactor this to use async/await. This is from our Development Standards: Development Standards.
  • Reason this comment was not posted:
    Marked as duplicate.
6. cli/src/tools/index.ts:76
  • Draft comment:
    Using async/await makes asynchronous code more readable and easier to maintain than chaining .then() calls. Please refactor this to use async/await. This is from our Development Standards: Development Standards.
  • Reason this comment was not posted:
    Marked as duplicate.
7. cli/src/tools/index.ts:87
  • Draft comment:
    Using async/await makes asynchronous code more readable and easier to maintain than chaining .then() calls. Please refactor this to use async/await. This is from our Development Standards: Development Standards.
  • Reason this comment was not posted:
    Marked as duplicate.
8. cli/src/tools/index.ts:108
  • Draft comment:
    Using async/await makes asynchronous code more readable and easier to maintain than chaining .then() calls. Please refactor this to use async/await. This is from our Development Standards: Development Standards.
  • Reason this comment was not posted:
    Marked as duplicate.
9. cli/src/tools/index.ts:112
  • Draft comment:
    Using async/await makes asynchronous code more readable and easier to maintain than chaining .then() calls. Please refactor this to use async/await. This is from our Development Standards: Development Standards.
  • Reason this comment was not posted:
    Marked as duplicate.

Workflow ID: wflow_VoL8yntiwE5UBszV


Want Ellipsis to fix these issues? Tag @ellipsis-dev in a comment. You can customize Ellipsis with 👍 / 👎 feedback, review rules, user-specific overrides, quiet mode, and more.

): Promise<ToolResponse> {
try {
const fullPath = path.join(workingDir, searchPath);
const files = await fs.readdir(fullPath, { recursive: true });
Copy link

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

fs.readdir does not support a recursive option. Consider using a library like recursive-readdir or implement a custom recursive function to list files.

Suggested change
const files = await fs.readdir(fullPath, { recursive: true });
const files = await fs.readdir(fullPath);

import { promisify } from 'util';
import type { ToolResponse } from '../types.js';

const execAsync = promisify(exec);
Copy link

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Be cautious with execAsync as it can lead to command injection vulnerabilities. Consider validating or sanitizing the input command to mitigate this risk.

@mrubens mrubens force-pushed the cli branch 2 times, most recently from e341b63 to e23ec68 Compare November 21, 2024 06:20
Copy link

@ellipsis-dev ellipsis-dev bot left a comment

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

❌ Changes requested. Incremental review on e23ec68 in 1 minute and 1 seconds

More details
  • Looked at 960 lines of code in 9 files
  • Skipped 2 files when reviewing.
  • Skipped posting 2 drafted comments based on config settings.
1. cli/src/tools/index.ts:76
  • Draft comment:
    The fs.readdir method does not support a recursive option. Consider using a library like recursive-readdir or implementing a custom recursive function to list files.
  • Reason this comment was not posted:
    Marked as duplicate.
2. cli/src/tools/index.ts:11

Workflow ID: wflow_3MYseFYfJmc8h1cy


Want Ellipsis to fix these issues? Tag @ellipsis-dev in a comment. You can customize Ellipsis with 👍 / 👎 feedback, review rules, user-specific overrides, quiet mode, and more.

): Promise<ToolResponse> {
try {
const fullPath = path.join(workingDir, searchPath);
const files = await fs.readdir(fullPath, { recursive: true });
Copy link

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

The fs.readdir method does not support a recursive option. Consider using a library like recursive-readdir or implementing a custom recursive function to list files.

Suggested change
const files = await fs.readdir(fullPath, { recursive: true });
const files = await fs.readdir(fullPath);

cli/src/index.ts Outdated
@@ -0,0 +1,94 @@
#!/usr/bin/env node
Copy link

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Ensure that unit tests (and integration tests, where appropriate) are included for the new functionality. The minimum acceptable test coverage is 80%. Tests should be deterministic and isolated, and data-testid attributes should be included on all UI elements under test. This is from our Development Standards: https://www.notion.so/Development-Standards-59febcf8ead647fd9c2ec3f60c22f3df?pvs=4#11869ad2d58180f7b224d6db54dab6b5

totalCost: this.calculateCost(inputTokens, outputTokens)
};

} catch (error: any) {
Copy link

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Avoid using 'any' type. Consider using 'unknown' instead, as it forces type-checking before usage. This is from our Development Standards: https://www.notion.so/Development-Standards-59febcf8ead647fd9c2ec3f60c22f3df?pvs=4#11869ad2d5818051ae9cefd92c3aac2b

Suggested change
} catch (error: any) {
} catch (error: unknown) {

@mrubens mrubens marked this pull request as draft November 21, 2024 06:29
@mrubens mrubens force-pushed the cli branch 3 times, most recently from ac86ccd to f6e6fca Compare November 21, 2024 18:31
@stea9499 stea9499 marked this pull request as ready for review November 22, 2024 19:40
Copy link

@ellipsis-dev ellipsis-dev bot left a comment

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

👍 Looks good to me! Reviewed everything up to 1c471bd in 1 minute and 53 seconds

More details
  • Looked at 1186 lines of code in 12 files
  • Skipped 0 files when reviewing.
  • Skipped posting 8 drafted comments based on config settings.
1. cli/api/providers/openrouter.ts:30
  • Draft comment:
    Consider making the API endpoint URL configurable instead of hardcoding it. This will allow for easier testing and flexibility in different environments.
  • Reason this comment was not posted:
    Confidence changes required: 50%
    The code in cli/api/providers/openrouter.ts uses a hardcoded URL for the API endpoint. This could be improved by making it configurable, allowing for easier testing and flexibility in different environments.
2. cli/tools/mod.ts:97
  • Draft comment:
    Using sh for command execution may not be compatible with non-Unix systems. Consider using a cross-platform approach to handle command execution.
  • Reason this comment was not posted:
    Confidence changes required: 50%
    The code in cli/tools/mod.ts uses a shell command sh to execute commands. This might not be compatible with non-Unix systems like Windows, where sh might not be available. It would be better to handle this in a cross-platform manner.
3. cli/mod.ts:73
  • Draft comment:
    Consider providing more informative error messages or guidance on how to grant the necessary permissions when they are denied.
  • Reason this comment was not posted:
    Confidence changes required: 50%
    The code in cli/mod.ts checks for permissions but does not handle the case where permissions are denied. It would be better to provide a more informative error message or guidance on how to grant the necessary permissions.
4. cli/core/StandaloneAgent.ts:128
  • Draft comment:
    Consider removing the break statement to allow processing of all tools in the message instead of stopping after the first one.
  • Reason this comment was not posted:
    Confidence changes required: 50%
    The code in cli/core/StandaloneAgent.ts breaks out of the loop after executing a tool, which might not be the intended behavior if multiple tools are specified in the message. It should continue processing all tools in the message.
5. cli/api/providers/openrouter.ts:17
6. cli/README.md:1
7. cli/deno.jsonc:1
8. cli/tools/mod.ts:1

Workflow ID: wflow_6nBIkOCxckGF2oSb


You can customize Ellipsis with 👍 / 👎 feedback, review rules, user-specific overrides, quiet mode, and more.

args: readonly string[];
}

// Define allowed commands and their descriptions

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

This is a nice data structure for these commands. At some point we can combine with the Cline.ALLOWED_AUTO_EXECUTE_COMMANDS allowlist.

@stea9499 stea9499 merged commit 17f307e into main Nov 22, 2024
@cte cte deleted the cli branch February 1, 2025 06:16
hannesrudolph pushed a commit that referenced this pull request May 24, 2025
* refactor(marketplace): add installed tabs

* fix: missing settings button

* refactor(marketplace): better card UI

* refactor(marketplace): better error message for sources

* tests(marketplace): item card and source config

* refactor(marketplace): colocate local states

* refactor(marketplace): simplify tabs

* test: marketplace view

---------

Co-authored-by: elianiva <[email protected]>
hannesrudolph pushed a commit that referenced this pull request May 24, 2025
* refactor(marketplace): add installed tabs

* fix: missing settings button

* refactor(marketplace): better card UI

* refactor(marketplace): better error message for sources

* tests(marketplace): item card and source config

* refactor(marketplace): colocate local states

* refactor(marketplace): simplify tabs

* test: marketplace view

---------

Co-authored-by: elianiva <[email protected]>
mrubens pushed a commit that referenced this pull request Jun 11, 2025
* refactor(marketplace): add installed tabs

* fix: missing settings button

* refactor(marketplace): better card UI

* refactor(marketplace): better error message for sources

* tests(marketplace): item card and source config

* refactor(marketplace): colocate local states

* refactor(marketplace): simplify tabs

* test: marketplace view

---------

Co-authored-by: elianiva <[email protected]>
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

Successfully merging this pull request may close these issues.

2 participants