Skip to content

Add PowerShell and Bash modules for command history tracking with P2P sync#66

Merged
kayodebristol merged 5 commits intomainfrom
copilot/refine-pluresdb-cli-integration
Jan 30, 2026
Merged

Add PowerShell and Bash modules for command history tracking with P2P sync#66
kayodebristol merged 5 commits intomainfrom
copilot/refine-pluresdb-cli-integration

Conversation

Copy link
Contributor

Copilot AI commented Jan 30, 2026

Implements shell integration modules for cross-device command history tracking, deduplication, and analysis with NixOS/WSL support.

Modules

PowerShell (modules/powershell/)

  • 11 functions: init, query, frequency analysis, session/host stats, config
  • Profile integration via PSReadLine hooks
  • WSL hostname detection

Bash (modules/bash/)

  • 15 functions: equivalent to PowerShell + NixOS/WSL-specific features
  • Integration via DEBUG trap and PROMPT_COMMAND
  • macOS/BSD timestamp fallback for cross-platform compatibility

Database Schema

CREATE TABLE command_history (
    command TEXT, hostname TEXT, shell_type TEXT,
    timestamp INTEGER, duration_ms INTEGER, exit_code INTEGER,
    session_id TEXT, device_id TEXT,  -- P2P sync fields
    UNIQUE(hostname, shell_type, command, timestamp)
);

-- Views: command_history_unique, command_frequency, failed_commands, 
--        session_history, host_summary

Indexed by hostname, shell type, timestamp, and session for efficient cross-device queries.

Usage

# PowerShell
Import-Module PluresDB
Enable-PluresDBHistoryIntegration
Get-PluresDBHistory -CommandLike "git*" -SuccessOnly -Last 20
Get-PluresDBCommandFrequency -Top 10
# Bash
source /path/to/pluresdb/modules/bash/pluresdb.sh
pluresdb_enable_integration
pluresdb_history --command-like "git" --failed-only
pluresdb_nixos_rebuilds  # NixOS-specific

Security

  • SQL injection prevention via input escaping (doubled single quotes)
  • Input validation with [ValidateRange] on numeric parameters
  • Regex special character escaping in ignore patterns
  • Documentation on sensitive data handling (passwords in command args)

Platform Support

  • Windows: PowerShell 5.1+, Core 6.0+
  • Linux: All major distros, NixOS-specific features
  • macOS: BSD-compatible date handling
  • WSL: Cross-platform command tracking

Documentation

  • docs/COMMAND_LINE_INTEGRATION.md (16KB): Complete reference
  • docs/CLI_INTEGRATION_SUMMARY.md: Implementation overview
  • Example scripts for both shells
Original prompt

This section details on the original issue you should resolve

<issue_title>Refine and document pluresdb command line integration</issue_title>
<issue_description>Add pluresdb powershell and bash module implementing advanced features, data entry and retrieval, data cleanup, manipulation, database setup and configuration, and database troubleshooting and analysis utilities.

Add easy cmd history integration, whereby powershell history and transcripts are automatically routed to pluresdb and retrieved from pluresdb once configured. Implement history dedup view that shows unique cmds, cmd grouping and sorting, and support simplified queries which can return cmds of type or like, which ended in error or were successful, to include command to return output and just the cmd or both.

Include nixos integration for advanced nixos troubleshooting.

Index all system integrations by hostname and shell type so synced database could allow accessing cmds, history, transcripts, etc, from different machines, or different shells.

Also support wsl. </issue_description>

Comments on the Issue (you are @copilot in this section)


✨ Let Copilot coding agent set things up for you — coding agent works faster and does higher quality work when set up for your repo.

Copilot AI and others added 4 commits January 30, 2026 07:07
- Created PowerShell module (PluresDB.psm1) with comprehensive command history functions
- Created Bash module (pluresdb.sh) with equivalent functionality
- Added database schema for command history tracking
- Implemented deduplication views and statistics
- Added NixOS-specific command tracking
- Added WSL integration support
- Indexed by hostname and shell type for cross-device sync
- Created comprehensive documentation
- Added example scripts for both shells

Co-authored-by: kayodebristol <3579196+kayodebristol@users.noreply.github.com>
- Added Pester tests for PowerShell module
- Added bash tests with comprehensive function validation
- Updated README with shell integration documentation
- All bash module tests passing

Co-authored-by: kayodebristol <3579196+kayodebristol@users.noreply.github.com>
Security fixes:
- Fix SQL injection in PowerShell and Bash query functions via proper escaping
- Fix regex injection in Bash ignore patterns
- Handle null LASTEXITCODE in PowerShell
- Add security documentation about sensitive commands

Cross-platform improvements:
- Add fallback for timestamp generation on macOS/BSD
- Fix PROMPT_COMMAND concatenation in Bash
- Clean up backup files after sed operations

Documentation:
- Add comprehensive security considerations section
- Document recommendations for handling sensitive data
- Add file permission examples

Co-authored-by: kayodebristol <3579196+kayodebristol@users.noreply.github.com>
- Added CLI_INTEGRATION_SUMMARY.md with complete feature overview
- Documents all 11 files and 1,357 lines of code
- Lists all functions, security measures, and use cases
- Includes testing status and future enhancement ideas

Co-authored-by: kayodebristol <3579196+kayodebristol@users.noreply.github.com>
Copilot AI changed the title [WIP] Add pluresdb command line integration and documentation Add PowerShell and Bash modules for command history tracking with P2P sync Jan 30, 2026
Copilot AI requested a review from kayodebristol January 30, 2026 07:17
@kayodebristol kayodebristol marked this pull request as ready for review January 30, 2026 07:20
@kayodebristol kayodebristol merged commit 5d269b1 into main Jan 30, 2026
3 checks passed
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.

Refine and document pluresdb command line integration

2 participants