-
Notifications
You must be signed in to change notification settings - Fork 0
knowledge extractor #79
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
base: add-history-support
Are you sure you want to change the base?
Changes from all commits
76c2658
820b914
4349c1f
8165ac5
6fe2e18
95b423b
21cf2c7
d9877a1
06a0e37
79cd057
ffa66ef
6eaabad
258c917
aa398ce
15139de
c48e897
482ad47
File filter
Filter by extension
Conversations
Jump to
Diff view
Diff view
There are no files selected for viewing
| Original file line number | Diff line number | Diff line change |
|---|---|---|
| @@ -0,0 +1,26 @@ | ||
| # What bashrc need to be for OSC 333 | ||
|
|
||
| ``` | ||
|
|
||
| # --- OSC 333 marks for the multiplexer --- | ||
| _osc333_preexec() { | ||
| [[ -n "$_osc333_in_cmd" ]] && return | ||
| printf '\e]333;C\a' | ||
| _osc333_in_cmd=1 | ||
| } | ||
|
|
||
| _osc333_postexec() { | ||
| local ec=$? | ||
| printf '\e]333;D;%d\a' "$ec" | ||
| unset _osc333_in_cmd | ||
| } | ||
|
|
||
| trap '_osc333_preexec' DEBUG # «pre‑exec» | ||
| PROMPT_COMMAND='_osc333_postexec' # «post‑exec» | ||
|
|
||
| PS1='\[\e]333;A\a\]\u@\h:\w\$ \[\e]333;B\a\]' | ||
| PS2='\[\e]333;A\a\]> \[\e]333;B\a\]' | ||
| PS3='\[\e]333;A\a\]#? \[\e]333;B\a\]' | ||
| ``` | ||
|
|
||
| description of a standart - https://gitlab.freedesktop.org/Per_Bothner/specifications/-/blob/master/proposals/semantic-prompts.md |
| Original file line number | Diff line number | Diff line change |
|---|---|---|
| @@ -0,0 +1,12 @@ | ||
| ## How `bash` window is working in `terminal_multiplexer.cpp` | ||
|
|
||
| - Method `init` initialize two PTY's for agent and bash windows | ||
| - Methods from `refresh_cursor` to `resize` (lines 30-37 in `terminal_multiplexer.hpp`) are technical | ||
| - Method `run_terminal` creates an epoll instance and fill it with `STDIN`, screens PTY's and fd for window resize. After this it goes to infinite cycle for waiting this fd's. | ||
|
|
||
| ### Then `STDIN` was called | ||
|
|
||
| - Symbols handles by `handle_input()` method for special symbols like `CTRL + B` and if it is just a letter, it writes this to fd of bash screen | ||
| - Then method `handle_screen_output(Screen &screen, const int fd)` starts working, because it handles everything that needs to print on a screen(including bash screen) | ||
| - Method `handle_screen_output(Screen &screen, const int fd)` also can be called from epolling cycle by bash command output | ||
| - This method reads all symbols from given `fd` and sends it to `screen's` method `handle_char(const TerminalChar &tch)` to show it on a screen |
| Original file line number | Diff line number | Diff line change |
|---|---|---|
| @@ -0,0 +1,42 @@ | ||
| #ifndef MARKDOWN_MANAGER_HPP | ||
| #define MARKDOWN_MANAGER_HPP | ||
|
|
||
| #include <unordered_map> | ||
| #include <string> | ||
| #include <fstream> | ||
| #include <iomanip> | ||
| #include <sstream> | ||
| #include <cstdlib> | ||
| #include <sys/stat.h> | ||
| #include "../nlohmann/json.hpp" | ||
| #include "bookmark_manager.hpp" | ||
| #include "agency_manager.hpp" | ||
|
|
||
| using json = nlohmann::json; | ||
|
|
||
| class MarkdownManager { | ||
|
|
||
| public: | ||
| explicit MarkdownManager(); | ||
| virtual ~MarkdownManager(); | ||
|
|
||
| virtual bool create_markdowns_file(const std::string &filename); | ||
| virtual void parse_markdown_json(const json &markdown); | ||
|
|
||
| virtual void load_markdowns(const std::string &filename); | ||
| virtual void save_markdowns(const std::string &filename); | ||
|
|
||
| virtual bool is_markdown(const std::string &bookmark) const; | ||
| virtual std::pair<std::string, std::string> get_markdown(const std::string &bookmark) const; | ||
|
|
||
| virtual void markdown(const std::pair<std::string, std::string>& protocol); // create markdown from bookmark with "default" group | ||
| virtual void list_markdowns() const; // list markdowns "markdown -l" | ||
| virtual void remove_markdown(const std::string &bookmark); // remove markdown "markdown -r" | ||
| virtual void add_to_group(const std::string &group, const std::string &bookmark); // change markdown's group | ||
| virtual std::vector<std::string> get_by_group(const std::string &group); // give LLM context of this group | ||
| virtual bool save_as_file(const std::string& bookmark); // save markdown as <bookmark>.md | ||
|
|
||
| std::unordered_map<std::string, std::pair<std::string, std::string>> markdowns; // <bookmark> [<group, protocol>] | ||
| }; | ||
|
|
||
| #endif //MARKDOWN_MANAGER_HPP |
| Original file line number | Diff line number | Diff line change |
|---|---|---|
| @@ -0,0 +1,63 @@ | ||
| #ifndef SESSION_TRACKER_HPP | ||
| #define SESSION_TRACKER_HPP | ||
|
|
||
| #include <string> | ||
| #include <vector> | ||
| #include <sqlite3.h> | ||
|
|
||
| class SessionTracker { | ||
| public: | ||
| enum class EventType { | ||
| ShellCommand, | ||
| SystemCommand, | ||
| Unknown | ||
| }; | ||
|
|
||
| struct ShellCmd { | ||
| int interaction_id; | ||
| std::string command; | ||
| std::string output; | ||
| std::string execution_start; | ||
| std::string execution_end; | ||
| int exit_code; | ||
| }; | ||
|
|
||
| struct Interaction { | ||
| int interaction_id; | ||
| std::string timestamp; | ||
| std::string question; | ||
| std::string answer; | ||
| std::vector<ShellCmd> shell; | ||
| }; | ||
|
|
||
| static SessionTracker& get(); | ||
|
|
||
| void startSession(); | ||
| void endSession(); | ||
|
|
||
| void logAgentInteraction(const std::string& question, const std::string& response); | ||
|
|
||
| void addNewCommand(EventType command_type); | ||
| void appendCommandText(const std::string& text); | ||
| void setCommandOutput(const std::string& output); | ||
| void setExitCode(int exit_code); | ||
|
|
||
| const std::vector<Interaction>& get_history() const; | ||
|
|
||
| private: | ||
| SessionTracker(); | ||
| ~SessionTracker(); | ||
|
|
||
| SessionTracker(const SessionTracker&) = delete; | ||
| SessionTracker& operator=(const SessionTracker&) = delete; | ||
|
|
||
| void openLogFile(); | ||
|
|
||
| sqlite3 *db; | ||
|
Contributor
There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. It is better to use some prefix for members |
||
| int sessionDbId; | ||
| int lastCommandId; | ||
|
|
||
| mutable std::vector<Interaction> history; | ||
| }; | ||
|
|
||
| #endif // SESSION_TRACKER_HPP | ||
| Original file line number | Diff line number | Diff line change |
|---|---|---|
|
|
@@ -35,13 +35,20 @@ class TerminalMultiplexer { | |
| void send_dims(); | ||
| void resize(); | ||
| void run_terminal(); | ||
| int handle_screen_output(Screen &screen, int fd) const; | ||
| int handle_screen_output(Screen &screen, int fd); | ||
|
Author
There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. I've done it because i want to call non-const method to collect command output and change variable last_command_finished |
||
| int handle_input(); | ||
|
|
||
| static void handle_pty_input(int fd, char ch); | ||
| void zoom_in(); | ||
| void zoom_out(); | ||
| void toggle_manual_scroll(); | ||
|
|
||
| /* ────────── OSC 133 state (bash‑экран) ────────── */ | ||
| bool bash_capturing = false; | ||
| bool bash_waiting_for_prompt = true; | ||
| std::string bash_output; | ||
| int last_command_line = -10; | ||
| int first_command_line = -10; | ||
| }; | ||
|
|
||
| #endif | ||
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Comments?