getappmap / appmap-js

Client libraries for AppMap
45 stars 12 forks source link

Don't prompt extension users to install the extension #1806

Closed dustinbyrne closed 1 month ago

dustinbyrne commented 1 month ago

This PR updates the code editor prompt to inform the LLM that they're talking to a code editor user and not to provide additional instructions as to how to install the extension.

I've added an additional commit that will allow us to easily tweak the temperature via environment variable.

how do i use appmap in this editor

  To use AppMap in VS Code for your Ruby project, follow these steps to ensure that AppMap is properly configured and you're able to record and visualize your code execution:

  1. **Verify `appmap` gem Installation**:

     Ensure the `appmap` gem is added at the beginning of your Gemfile in the `:development, :test` group:

     ```ruby
     group :development, :test do
       gem 'appmap'
     end
 Run `bundle install` to install the gem if it's not already installed.
  1. Configuration with appmap.yml:

    Your appmap.yml is correctly configured as follows:

     name: sample_app_6th_ed
     language: ruby
     appmap_dir: tmp/appmap
     packages:
       - path: app
       - path: lib
     compare:
       filter:
         hide_external: true
         dependency_folders: [ vendor ]
         hide_name: 
           - /^external-route:.*\bhttp:\/\/127\.0\.0\.1:\d+\/session\/[a-f0-9]{32,}\//
           - /^query:[\s\S]*\bSAVEPOINT\b/
           - /^query:[\s\S]*\bPRAGMA\b/,
           - /^query:[\s\S]*\bsqlite_master\b/
     update:
       test_folders: [ test ]
       test_commands:
         test:
           - env DISABLE_SPRING=true rails test {testFiles}
  2. Enable AppMap in your Test Framework:

    Depending on the test framework you're using (RSpec, Minitest, Cucumber), ensure AppMap is properly required.

    RSpec:

    Add require 'appmap/rspec' to your spec_helper.rb before loading the environment:

     require 'appmap/rspec'
     require File.expand_path("../../config/environment", __FILE__)

    Run specs normally:

     bundle exec rspec

    Minitest:

    Add require 'appmap/minitest' to your test_helper.rb before loading the environment:

     require 'appmap/minitest'
     require_relative '../config/environment'

    Run tests normally:

     rails test

    Cucumber:

    Add require 'appmap/cucumber' in support/env.rb and configure the Around hook in support/hooks.rb:

     require 'appmap/cucumber'
     if AppMap::Cucumber.enabled?
       Around('not @appmap-disable') do |scenario, block|
         appmap = AppMap.record do
           block.call
         end
    
         AppMap::Cucumber.write_scenario(scenario, appmap)
       end
     end

    Run features normally:

     bundle exec cucumber
  3. Run AppMap Task:

    The provided Rake task lib/tasks/appmap.rake can update AppMaps. Run the architecture task to update AppMaps based on your tests:

     bundle exec rake appmap:architecture
  4. Open and View AppMaps in VS Code:

    • Open the VS Code Command Palette (Ctrl+Shift+P or Cmd+Shift+P on macOS).
    • Search for and select AppMap: Show Views.
    • Use the AppMap panel to explore the recorded AppMaps.
  5. Label Important Methods:

    Optionally, you can add labels to your methods to improve the analysis and visualization:

     class ApiKey
       # @labels provider.authentication security
       def authenticate(key)
         # logic
       end
     end

    By following these steps, you should be able to record and visualize your application’s runtime behavior using AppMap within your VS Code environment. If you encounter any issues or need further assistance, feel free to ask!

kgilpin commented 1 month ago

These Ruby instructions are still a lot more complicated than necessary.

appmap.yml is not needed - it’s auto created

imports into the tests code are not needed either

nor is a rake task

dustinbyrne commented 1 month ago

All of this information came from context.

evlawler commented 1 month ago

So the rake task came from our doc or from the model's training. We need to control our help chat and turn down the model.

kgilpin commented 1 month ago

So the rake task came from our doc or from the model's training. We need to control our help chat and turn down the model.

If we prompt it to only explain one step at a time, I think it will calm down. The user can only do one thing at a time anyway.

dustinbyrne commented 1 month ago

The rake task came from the repository, not our documentation or training. It matched this file due to the keyword appmap: https://gist.github.com/dustinbyrne/9a8881e209cba91d3441b2a7ddef7f70

dustinbyrne commented 1 month ago

Here's a response from a less integrated project. Same prompt, zero temperature.


Given that you have AppMap already installed and activated in your Visual Studio Code editor, here's how you can make the most of it:

  1. Viewing AppMap Diagrams:

    • Open AppMap Data: In your file explorer, navigate to the tmp/appmap directory (as specified in your appmap.yml). Here, you will find the .appmap.json files that represent recorded AppMaps.
    • Open Sequence Diagrams: Click on any .appmap.json file. VS Code will display an option to view the sequence diagram. Select the Sequence Diagram tab to view the interactive diagram.
  2. Navigating Code with AppMap:

    • Highlight Code: AppMap diagrams highlight the most critical code pathways and relationships. You can click on any part of the diagram to jump directly to the corresponding code within VS Code.
    • Analyze HTTP Routing: Based on your project stats, you have several HTTP routes defined. These routes can be visualized to understand how they interact with your backend logic and database.
  3. Generating New AppMaps:

    • Considering you have a Spring-based Java project (spring-petclinic), you should run your tests or your application to generate new AppMap data. Given that you have Spring routes, information will be recorded with each interaction.
  4. Interactive Analysis:

    • Dependency Maps: Use the dependency map to understand how various parts of your application depend on each other.
    • Trace Views & Flame Graphs: These views can help you analyze performance bottlenecks and execution flow, making it easier to optimize your application.

Quick Steps to View a Sequence Diagram:

  1. Navigate to the tmp/appmap directory in your project.
  2. Open any of the .appmap.json files.
  3. Click on the Sequence Diagram tab in the VS Code editor.

Open sequence diagram

Additional Tips:

By fully utilizing these features, you'll gain deeper insights into your application's behavior and architecture, and be able to make informed decisions for maintenance and improvements.

appland-release commented 1 month ago

:tada: This PR is included in version @appland/navie-v1.10.0 :tada:

The release is available on:

Your semantic-release bot :package::rocket: