Share your feedback on the upcoming Cody CLI Beta

Hi all! We’re working on launching a cody cli tool as Beta. This is a new iteration of the previous cody-agent experimental-cli tool that was launched in April here.

To get started with the new cody tool:

npm install -g @sourcegraph/cody # Note: no longer `cody-agent`

# Authenticate with Sourcegraph by opening a browser window
cody auth login --web

# Ask Cody a question (with no context):
cody chat -m 'what color is the sky?'

# Ask Cody a question (with Sourcegraph Enterprise repository context):
cody chat --context-repo github.com/sourcegraph/{sourcegraph,cody} --show-context -m 'how is authentication handled in sourcegraph/cody?'

Please share your feedback in this thread :slight_smile:

I posted this a bit too early since I haven’t published the @sourcegraph/cody npm package yet. I wanted to share a link to this post in our docs. Right now, you need to install @sourcegraph/cody-agent and run cody-agent instead of just cody. Otherwise, it’s the same cody auth and cody chat experience.

@olafurpg
It appears that context is broken with the latest update. Please see the snippet below

>> cody-agent chat --context-repo xyz.url/repo --show-context -m 'explain what is happening in main.py?'
⠋ Loading access token(node:77774) [DEP0040] DeprecationWarning: The `punycode` module is deprecated. Please use a userland alternative instead.
(Use `node --trace-deprecation ...` to show where the warning was created)
> Context items:



Unfortunately, without the `main.py` file, I cannot provide an explanation of what is happening in it. Could you please provide the contents of the `main.py` file, or at least a brief description of what it is supposed to do? With that information, I can better analyze and explain what is happening in the code.

As shown in the snippet, referencing to a repo for context does not work and no context is shown.

I have already logged in

>> cody-agent auth login --web
⠋ Logging in...(node:84368) [DEP0040] DeprecationWarning: The `punycode` module is deprecated. Please use a userland alternative instead.
(Use `node --trace-deprecation ...` to show where the warning was created)
✔ You are already logged in as <USER>
  1. Am I using the cli correctly?

  2. Also, Is there an ETA for publishing the npm package?

Thank you for reporting! I am able to reproduce the issue with --context-repo. It was working not too long ago so it must be something small that broke.

I tried to release the @sourcegraph/cody npm package on Friday but the CI job failed because this package doesn’t exist yet. It was unfortunate timing since I’m OOO this week so I won’t be able to fix the release (and --context-repo) until next week.

I’ll post back again once I have a new update :slight_smile: Sorry for the inconvenience!

1 Like

@olafurpg I see version 5.5.9 was released. And I got the package from npm and looks like context is not working with the new version either.

Screenshot 2024-07-17 at 10.40.38 AM

/Users/vinpatel >> cody chat --context-repo xyz.url/repo --show-context -m 'write unit tests for functions in main.py'
⠋ Loading access token(node:34181) [DEP0040] DeprecationWarning: The `punycode` module is deprecated. Please use a userland alternative instead.
(Use `node --trace-deprecation ...` to show where the warning was created)
> Context items:



Sure, I can help you write unit tests for the functions in `main.py`. However, I don't have access to the actual codebase context since you didn't provide it. Could you please share the `main.py` file or the relevant code snippets you want me to write unit tests for?

This feedback might be premature, because the npm is released but I understand sourcegraph release is yet to happen (scheduled for today)?

I’m able to login but when I run cody chat it says I’m not :thinking:

whoami works

Thank you for sharing! I’m eager to help you resolve this :slight_smile: Please note that I will be OOO next week so forgive me if I will be slow to respond to followup questions (summer months :sweat_smile: )

Just to confirm, does the same question work in VS Code?

Also, are you using exactly the same repo name as appears on your sourcegraph instance? For example, --context-repo sourcegraph/cody does not work, you have to explicitly spell out the full repo name as it appears on your Sourcegraph Enterprise instance, which is --context-repo github.com/sourcegraph/cody. I just opened an issue to allow substring matches and fail fast with a helpful error message if no repo matches the --context-repo options.

Please keep the feedback coming :pray:

Thank you for sharing! Any chance you have SRC_ACCESS_TOKEN set in your environment? There’s an issue in cody auth whoami where it doesn’t read the environment variable like cody chat does. I have a TODO to ensure both commands run the exact same authentication logic.

@VinAI I’ve merged a change that now reports an error message if --context-repo has no matching repository. This change has now been released as part of 5.5.10 CLI: fail fast if `--context-repo` does not have a matching name by olafurpg · Pull Request #4919 · sourcegraph/cody · GitHub

1 Like

That was it, problem solved :slight_smile: ty Olaf

Thank you @olafurpg failfast works in 5.5.10 now! and it seems that Cody CLI is context aware now.

However, --show-context is not showing current context (though it seems to be getting the context, just not displaying with --show-context command)

/Users/vinpatel/Desktop >> cody chat --context-repo xyz.url/repo --show-context -m 'explain what is hapenning in main.py'
⠋ Loading access token(node:57457) [DEP0040] DeprecationWarning: The `punycode` module is deprecated. Please use a userland alternative instead.
(Use `node --trace-deprecation ...` to show where the warning was created)
> Context items:



As shown here, context is showing empty.

Great. That bumps up the priority of the issue to make cody auth whoami consistent with cody chat. I’ve hit on this myself. It only impacts existing users for src-cli though, and cody chat is consistent with src-cli. The scope of the issue is only to make cody auth whoami consistent with src-cli, which makes me think it’s not an urgent issue to fix.

Thank you for reporting! I’m able to reproduce. I have a pending fix here CLI: fix bug in `--show-context` by olafurpg · Pull Request #4933 · sourcegraph/cody · GitHub

@olafurpg Do you have an estimate when CLI: fix bug in `--show-context` by olafurpg · Pull Request #4933 · sourcegraph/cody · GitHub will be merged?

I’m sorry for the slow response, I was on vacation last week. I just merged the PR and cut a new 5.5.11 release with the fix for --show-context. Thank you for your patience :pray:

❯ cody chat --context-file agent/README.md -m 'what is the agent' --show-context
> Context items:

> 1. /Users/olafurpg/dev/sourcegraph/cody/agent/README.md

Changelog cody/agent/CHANGELOG.md at main · sourcegraph/cody · GitHub

1 Like