Skip to content

Add TUI CLI Bridge Utility - #1

Draft
google-labs-jules[bot] wants to merge 16 commits into
mainfrom
feat/tui-cli-bridge-9387251213784613305
Draft

Add TUI CLI Bridge Utility#1
google-labs-jules[bot] wants to merge 16 commits into
mainfrom
feat/tui-cli-bridge-9387251213784613305

Conversation

@google-labs-jules

Copy link
Copy Markdown

Implemented a TUI interface for the Memory Thread SDK located at memory_thread/utils/cli_bridge.py. This tool allows for interactive chat, knowledge graph visualization, and project file ingestion, acting as a bridge to the underlying SDK without modifying core dependencies. It includes robust error handling and fallback modes for missing optional dependencies.


PR created automatically by Jules for task 9387251213784613305 started by @badalraj9

This commit introduces a new utility script `memory_thread/utils/cli_bridge.py` that provides a Text User Interface (TUI) for interacting with the Memory Thread SDK.

Features:
- **Interactive Chat:** Chat with agents (coder, architect, reviewer) using different memory scopes.
- **Knowledge Graph Visualization:** Toggleable graph view (F3) showing entity relationships using `rich` tree view.
- **Project Ingestion:** Command `/ingest` to scan and memorize project files.
- **Configuration:** Runtime switching of LLM providers (Groq, OpenRouter, Local).
- **Robustness:** Graceful handling of missing dependencies (`rich`, `prompt_toolkit`) and binary files during ingestion.

Note:
- No core files were modified.
- Users need to install `rich` and `prompt_toolkit` manually to use the full TUI features.
@google-labs-jules

Copy link
Copy Markdown
Author

👋 Jules, reporting for duty! I'm here to lend a hand with this pull request.

When you start a review, I'll add a 👀 emoji to each comment to let you know I've read it. I'll focus on feedback directed at me and will do my best to stay out of conversations between you and other bots or reviewers to keep the noise down.

I'll push a commit with your requested changes shortly after. Please note there might be a delay between these steps, but rest assured I'm on the job!

For more direct control, you can switch me to Reactive Mode. When this mode is on, I will only act on comments where you specifically mention me with @jules. You can find this option in the Pull Request section of your global Jules UI settings. You can always switch back!

New to Jules? Learn more at jules.google/docs.


For security, I will only act on instructions from the user who triggered this task.

google-labs-jules Bot and others added 15 commits January 26, 2026 10:24
This commit introduces a new utility script `memory_thread/utils/cli_bridge.py` that provides a Text User Interface (TUI) for interacting with the Memory Thread SDK.

Features:
- **Interactive Chat:** Chat with agents (coder, architect, reviewer) using different memory scopes.
- **Knowledge Graph Visualization:** Toggleable graph view (F3) showing entity relationships using `rich` tree view.
- **Project Ingestion:** Command `/ingest` to scan and memorize project files.
- **Configuration:** Runtime switching of LLM providers (Groq, OpenRouter, Local).
- **Robustness:** Graceful handling of missing dependencies (`rich`, `prompt_toolkit`) and binary files during ingestion.

Note:
- No core files were modified.
- Users need to install `rich` and `prompt_toolkit` manually to use the full TUI features.
This commit introduces an additive "Firewall Layer" for Memory Thread, implementing Role-Based Access Control (RBAC) and Domain-Specific Authority without modifying the core SDK.

Features:
- **RBAC Logic (`memory_thread/nervous/access_control.py`):** Defines roles (Guest to Executive), domains, and authority scoring matrices.
- **Secure Wrapper (`memory_thread/utils/secure_sdk.py`):** A wrapper around `MemoryClient` that enforces read permissions and calculates write authority before calling the core.
- **TUI Updates (`memory_thread/utils/cli_bridge.py`):**
    - Added `/secure` toggle to enable/disable the firewall layer.
    - Added `/login <role>` to simulate persona switching.
    - Updated bottom toolbar to show security status.
- **Documentation:** Added `docs/enterprise_rbac_design.md` detailing the security model.

Note: No core files were modified. The security layer is purely additive.
This commit introduces an additive "Firewall Layer" for Memory Thread, implementing Role-Based Access Control (RBAC), Domain-Specific Authority, and Provenance without modifying the core SDK.

Features:
- **RBAC Logic (`memory_thread/nervous/access_control.py`):** Defines roles (Guest to Executive), domains, and authority scoring matrices.
- **Provenance (`memory_thread/models/provenance.py`):** Defines the Identity & Namespace Envelope.
- **Audit Ledger (`memory_thread/nervous/audit_ledger.py`):** Implements an append-only audit log.
- **Secure Wrapper (`memory_thread/utils/secure_sdk.py`):** A wrapper around `MemoryClient` that enforces read permissions, embeds provenance on write, and calculates authority.
- **TUI Updates (`memory_thread/utils/cli_bridge.py`):**
    - Added `/secure` toggle to enable/disable the firewall layer.
    - Added `/login <role>` to simulate persona switching.
    - Added `/audit` command to view the audit log (Root only).
    - Updated bottom toolbar to show security status.
- **Documentation:** Added `docs/enterprise_rbac_design.md` detailing the security model.

Note: No core files were modified. The security layer is purely additive.
This commit introduces an additive "Firewall Layer" for Memory Thread, implementing Role-Based Access Control (RBAC), Domain-Specific Authority, and Provenance without modifying the core SDK.

Features:
- **RBAC Logic (`memory_thread/nervous/access_control.py`):** Defines roles (Guest to Executive), domains, and authority scoring matrices.
- **Provenance (`memory_thread/models/provenance.py`):** Defines the Identity & Namespace Envelope.
- **Audit Ledger (`memory_thread/nervous/audit_ledger.py`):** Implements an append-only audit log.
- **Secure Wrapper (`memory_thread/utils/secure_sdk.py`):** A wrapper around `MemoryClient` that enforces read permissions, embeds provenance on write, and calculates authority.
- **TUI Updates (`memory_thread/utils/cli_bridge.py`):**
    - Added `/secure` toggle to enable/disable the firewall layer.
    - Added `/login <role>` to simulate persona switching.
    - Added `/audit` command to view the audit log (Root only).
    - Updated bottom toolbar to show security status.
- **Documentation:** Added `docs/enterprise_rbac_design.md` detailing the security model.

Note: No core files were modified. The security layer is purely additive.
This commit introduces an additive "Firewall Layer" for Memory Thread, implementing Role-Based Access Control (RBAC), Domain-Specific Authority, and Provenance without modifying the core SDK.

Features:
- **RBAC Logic (`memory_thread/nervous/access_control.py`):** Defines roles (Guest to Executive), domains, and authority scoring matrices.
- **Provenance (`memory_thread/models/provenance.py`):** Defines the Identity & Namespace Envelope.
- **Audit Ledger (`memory_thread/nervous/audit_ledger.py`):** Implements an append-only audit log.
- **Authority Store (`memory_thread/nervous/authority_store.py`):** Manages dynamic authority grants.
- **Secure Wrapper (`memory_thread/utils/secure_sdk.py`):** A wrapper around `MemoryClient` that enforces read permissions, embeds provenance on write, and calculates authority.
- **TUI Updates (`memory_thread/utils/cli_bridge.py`):**
    - Added `/secure` toggle to enable/disable the firewall layer.
    - Added `/login <role>` to simulate persona switching.
    - Added `/grant` & `/revoke` for dynamic authority management.
    - Added `/audit` command to view the audit log (Root only).
    - Added `/smart` toggle for Model Integration reflection loops.
    - Updated UI to show reasoning sources and security status.

Note: No core files were modified. The security layer is purely additive.
This commit fixes a `ModuleNotFoundError` when running the TUI script directly from different directories by dynamically adding the project root to `sys.path`.

- **Fix:** Added dynamic `sys.path` injection in `memory_thread/utils/cli_bridge.py`.
- **Fix:** Corrected a color code typo in `cli_bridge.py` (`#1e1e1e1e` -> `#1e1e1e`).
- **Improvement:** Added `EOFError` handling for cleaner exit in non-interactive shells.
This commit introduces a comprehensive Enterprise Security Layer for Memory Thread, including Role-Based Access Control (RBAC), Dynamic Authority Grants, Audit Logging, and a "Pentagon-style" TUI with secure login.

Features:
- **RBAC & Firewall (`memory_thread/nervous/access_control.py`):** Implements graded access (E-Class to SSS-Class) and dynamic authority overrides.
- **Identity & Provenance (`memory_thread/models/provenance.py`):** Defines immutable envelopes for event tracking.
- **Secure Wrapper (`memory_thread/utils/secure_sdk.py`):** Wraps the core SDK to enforce security policies and provenance injection.
- **Audit Ledger (`memory_thread/nervous/audit_ledger.py`):** Persistent, append-only log for security events.
- **Authority Store (`memory_thread/nervous/authority_store.py`):** Manages dynamic authority grants.
- **Vault (`memory_thread/nervous/vault.py`):** Secure credential store handling PINs and the Nuclear Key.
- **TUI Updates (`memory_thread/utils/cli_bridge.py`):**
    - **Secure Login Flow:** Requires Access Key/PIN.
    - **Stealth Elevation:** Inputting the "Godfather Key" elevates privilege transparently.
    - **Governance Commands:** `/grant`, `/revoke`, `/audit`.
    - **Smart Loop:** `/smart` toggle for Layer VI reflection.
    - **Visuals:** Security status indicators and styled login prompts.

Note: No core logic or schemas were modified. The security layer is purely additive via wrappers.
Prevents secret vault files and local audit logs from being tracked by git.

- Added `.mt/` directory.
- Added `vault.json`, `audit_ledger.jsonl`, `authority_grants.jsonl`.
…ging

Optimizes the TUI to be responsive, robust, and user-friendly.

- **Async/Threading:** Wrapped heavy `recall` and `chat` calls in `ThreadPoolExecutor` within an `asyncio` event loop. The UI spinner now remains responsive during LLM/DB operations.
- **Strict Validation:** `login_flow` now validates roles against the Enterprise Grade system, preventing invalid logins.
- **Dynamic Autocomplete:** `/login`, `/grant`, and `/revoke` now autocomplete with valid roles dynamically.
- **System Overview:** Added a dashboard panel on startup showing Identity, Security Status, and Smart Loop state.
- **Debug Logging:** Enabled `INFO` level logging to `tui_debug.log` for easier troubleshooting.
- **Fix:** Resolved import path issues for cross-platform execution.
This commit introduces a comprehensive Enterprise Security Layer for Memory Thread, including Role-Based Access Control (RBAC), Dynamic Authority Grants, Audit Logging, and a "Pentagon-style" TUI with secure login.

Features:
- **RBAC & Firewall (`memory_thread/nervous/access_control.py`):** Implements graded access (E-Class to SSS-Class) and dynamic authority overrides.
- **Identity & Provenance (`memory_thread/models/provenance.py`):** Defines immutable envelopes for event tracking.
- **Secure Wrapper (`memory_thread/utils/secure_sdk.py`):** Wraps the core SDK to enforce security policies and provenance injection.
- **Audit Ledger (`memory_thread/nervous/audit_ledger.py`):** Persistent, append-only log for security events.
- **Authority Store (`memory_thread/nervous/authority_store.py`):** Manages dynamic authority grants.
- **Vault (`memory_thread/nervous/vault.py`):** Secure credential store handling PINs and the Nuclear Key.
- **TUI Updates (`memory_thread/utils/cli_bridge.py`):**
    - **Secure Login Flow:** Requires Access Key/PIN.
    - **Stealth Elevation:** Inputting the "Godfather Key" elevates privilege transparently.
    - **Governance Commands:** `/grant`, `/revoke`, `/audit`.
    - **Smart Loop:** `/smart` toggle for Layer VI reflection.
    - **Visuals:** Security status indicators and styled login prompts.
    - **Async Optimization:** Uses `asyncio` and `ThreadPoolExecutor` for responsive UI.

Note: No core logic or schemas were modified. The security layer is purely additive via wrappers.
- Refactored `login_flow` to be asynchronous.
- Replaced synchronous `session.prompt()` with `await session.prompt_async()`.
- Updated `main_loop` to await the login flow.
- Replaced `time.sleep` with `asyncio.sleep` to avoid blocking the event loop.

This fixes the `RuntimeError: asyncio.run() cannot be called from a running event loop` when using the `/login` command in the TUI.
… command

- Defined 'Cognitive Galaxy Schema' in `docs/COGNITIVE_GALAXY.md`.
- Implemented `GalaxyQueryEngine` in `memory_thread/utils/galaxy.py` to support OLAP-style operations (slice, dice, drill) on memory.
- Updated `memory_thread/utils/cli_bridge.py` to include the `/galaxy` command.
- Integrated `GalaxyQueryEngine` with `SecureMemoryClient` to respect RBAC and Provenance.
- Implemented `ingest_fact` and `record_belief` in `SecureMemoryClient`.
- Enforced strict runtime checks: facts cannot be embeddings, beliefs must have provenance.
- Deprecated generic `remember()` with warnings and routing logic.
- Documented the architectural law in `docs/PRIME_RULE.md`.
- Updated TUI `cli_bridge.py` to use the new strict ingestion API.
- Implemented `/code` command for dedicated multi-line code ingestion.
- Added Workspace Navigation: `/ls` (canonical facts), `/focus` (set context), `/open` (view fact).
- Added Visualization: `/facts` and `/beliefs` commands to inspect the Galaxy Schema.
- Consolidated `GalaxyQueryEngine` logic into `cli_bridge.py` and removed `galaxy.py`.
- Updated TUI to auto-inject focused fact content into chat context.
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.

1 participant