Commit Graph

149 Commits

Author SHA1 Message Date
ajmallesh
bb89d6f458 refactor: replace console.log/chalk with ActivityLogger across services
- Add ActivityLogger interface wrapping Temporal's Context.current().log
- Thread logger parameter through claude-executor, message-handlers, git-manager, prompt-manager, reporting, and agent validators
- Remove chalk dependency from all service/activity files; CLI files keep console.log for terminal output
- Replace colorFn: ChalkInstance parameter with structured logger.info/warn/error calls
- Use replay-safe `log` import from @temporalio/workflow in workflows.ts
2026-02-16 17:16:27 -08:00
ajmallesh
d3816a29fa refactor: extract services layer, Result type, and ErrorCode classification
- Add DI container (src/services/) with AgentExecutionService, ConfigLoaderService, and ExploitationCheckerService — pure domain logic with no Temporal dependencies
- Introduce Result<T, E> type and ErrorCode enum for code-based error classification in classifyErrorForTemporal, replacing scattered string matching
- Consolidate billing/spending cap detection into utils/billing-detection.ts with shared pattern lists across message-handlers, claude-executor, and error-handling
- Extract LogStream abstraction for append-only logging with backpressure, used by both AgentLogger and WorkflowLogger
- Simplify activities.ts from inline lifecycle logic to thin wrappers delegating to services, with heartbeat and error classification
- Expand config-parser with human-readable AJV errors, security validation, and rule type-specific checks
2026-02-16 16:12:21 -08:00
ajmallesh
ae69478541 refactor: consolidate duplicate types and file I/O utilities
- Remove 4 duplicate file I/O functions from audit/utils.ts, re-export from utils/file-io.ts
- Consolidate AgentEndResult interface into new types/audit.ts
- Use exported AgentDefinition from types/agents.ts in session-manager.ts
- Rename AgentMetrics to AgentAuditMetrics to disambiguate from temporal/shared.ts
2026-02-16 12:08:51 -08:00
ajmallesh
8e4fafba99 refactor: remove ~275 lines of dead code and enable stricter tsconfig
- Delete unused src/cli/ui.ts, remove zod dependency, drop 4 dead functions (logError, handleToolError, getRetryDelay, displayTimingSummary)
- Remove 8 unused types/interfaces and 3 duplicate formatting utils from audit/utils.ts
- Narrow export surface: make 7 message-handler functions private, remove unused audit re-exports, unexport AgentDefinition and path constants
- Remove unused runClaudePrompt params (sessionMetadata, attemptNumber) and update caller
- Enable tsconfig noUnusedLocals, noUnusedParameters, noImplicitReturns, noImplicitOverride, noFallthroughCasesInSwitch
2026-02-16 11:55:59 -08:00
ajmallesh
13731f5ebf refactor: remove ~750 lines of dead code across 12 files
- Delete 4 dead files: pre-recon.ts, tool-checker.ts, input-validator.ts, environment.ts
- Remove runClaudePromptWithRetry() and its now-unused imports from claude-executor.ts
- De-export unused symbols: AGENT_ORDER, getParallelGroups, logError, isRouterMode, showHelp, displayTimingSummary
- De-export unused types: ProcessingState, ProcessingResult, SdkMessage, MessageDispatchResult, MessageDispatchContext
- Remove dead import (path from zx) in session-manager.ts and deprecated comment in config.ts
2026-02-16 11:30:00 -08:00
ezl-keygraph
3a07f8a81f Merge pull request #140 from KeygraphHQ/feat/resume-workspace
feat: add named workspaces with resume support
2026-02-17 00:23:23 +05:30
ezl-keygraph
45e9f305ea refactor: remove ./shannon query CLI command
Query functionality is redundant with the Temporal Web UI
at http://localhost:8233. Removes query.ts, CLI handler,
npm script, and all documentation references.
2026-02-16 10:51:08 -08:00
ajmallesh
539bd873cc fix: improve resume edge cases and shell quoting
- Early exit when all agents already completed instead of running empty workflow
- Descriptive error when deliverables missing from disk despite session.json success
- Quote $WORKSPACE in shannon CLI to prevent word splitting
2026-02-16 10:50:52 -08:00
ezl-keygraph
c8bc29c011 Merge pull request #139 from KeygraphHQ/feat/windows-compat-and-claude-cli
feat: add MSYS path fix, Claude Code CLI, and Windows instructions
2026-02-16 23:14:15 +05:30
ezl-keygraph
759c8d8093 fix: resolve named workspace workflow ID in logs command
Strip _shannon-* suffix from workflow IDs so logs command finds
audit-logs stored under the workspace name.
2026-02-16 20:25:09 +05:30
ezl-keygraph
e85f6e0c73 feat: add MSYS path fix, Claude Code CLI, and Windows instructions
- Prevent MSYS from converting Unix container paths on Windows
- Install @anthropic-ai/claude-code globally in the Docker image
- Add Windows platform instructions to README
2026-02-16 20:11:08 +05:30
ezl-keygraph
2cf237d638 fix: resolve resume workflow ID in logs command
Strip _resume_* suffix to find the original workspace log file when
tailing logs for a resumed workflow.
2026-02-14 02:56:57 +05:30
ezl-keygraph
1b696cac1b fix: store checkpoint as success commit hash and show cumulative metrics
- Swap commitGitSuccess/getGitCommitHash order so checkpoint in
  session.json points to the success commit (which contains deliverables)
  instead of the pre-agent marker commit
- Simplify restoreGitCheckpoint: git reset --hard now naturally preserves
  completed agent deliverables, removing the in-memory backup/restore
- Show cumulative cost/duration in workflow.log from session.json
- Fill in per-agent metrics for skipped agents in workflow.log breakdown
- Display cumulative cost in client output for resume runs
2026-02-14 02:52:11 +05:30
ezl-keygraph
7f9c5cc496 fix: copy deliverables to audit-logs once at workflow end instead of per-agent
Moves the copyDeliverablesToAudit call from runAgentActivity (called after
every agent) to logWorkflowComplete (called once at workflow end). This
prevents intermediate agent runs from copying incomplete or rogue deliverables
into the audit trail.
2026-02-14 01:21:02 +05:30
ezl-keygraph
dbcb4587ee fix: update session.json status on workflow completion
logWorkflowComplete wrote to workflow.log but never called
updateSessionStatus, leaving all workspaces stuck as "in-progress"
in session.json. Also derive audit path for model injection instead
of requiring explicit outputPath.
2026-02-13 22:41:07 +05:30
ezl-keygraph
f017a41436 fix: set originalWorkflowId in logPhaseTransition and remove path import from agents.ts
logPhaseTransition was the first activity to create session.json but
didn't pass workflowId, so originalWorkflowId was never set. This
caused terminateExistingWorkflows to look up the workspace name instead
of the actual workflow ID during resume.

Also remove path import from types/agents.ts to fix Temporal workflow
bundle determinism error.
2026-02-13 22:09:07 +05:30
ezl-keygraph
ee5d7b80a0 feat: add named workspaces and workspace listing
Support WORKSPACE=<name> flag for friendly workspace names that
auto-resume if they exist or create a new named workspace otherwise.
Add ./shannon workspaces command to list all workspaces with status,
duration, and cost.
2026-02-13 20:53:18 +05:30
ezl-keygraph
f932fad2ed feat: add workflow resume from workspace via --workspace flag
When a workflow is interrupted (VM crash, Ctrl+C, Docker restart), it can
now be resumed by passing the workspace name. The system reads session.json
to determine which agents completed, validates deliverables exist on disk,
restores the git checkpoint, and skips already-completed agents.

- Add --workspace CLI flag and auto-terminate conflicting workflows
- Add loadResumeState, restoreGitCheckpoint, recordResumeAttempt activities
- Add skip logic for all 5 pipeline phases including parallel execution
- Separate sessionId (persistent directory) from workflowId (execution ID)
- Track resume attempts in session.json for audit trail
- Derive AgentName type from ALL_AGENTS array to eliminate duplication
- Add getDeliverablePath mapping for deliverable validation
2026-02-13 20:26:16 +05:30
Arjun Malleswaran
ce2628f6f0 Merge pull request #127 from KeygraphHQ/fix/large-deliverable-handling-v2
fix: improve large deliverable handling and audit trail
2026-02-12 08:54:19 -08:00
ezl-keygraph
c169b0d0a6 fix: restore CLAUDE_CODE_MAX_OUTPUT_TOKENS env var support
Re-add the env var that was removed during SDK upgrade. Needed for
controlling output token limits in SDK subprocesses.
2026-02-12 08:51:39 -08:00
ajmallesh
80bc8e3a44 feat: copy deliverables to audit-logs for self-contained audit trail 2026-02-12 08:51:39 -08:00
ajmallesh
30b5522647 fix: add chunked writing instructions to all agent prompts
- Replace single-call "Write to deliverables/" pattern with multi-step
  Write + Edit chunked writing across all 12 agent prompts
- Standardize section name to "CHUNKED WRITING (MANDATORY)" for
  vuln, exploit, pre-recon, and recon agents
- Prevents agents from hitting 32K output token limit when generating
  large analysis reports and exploitation evidence
2026-02-12 08:51:38 -08:00
Arjun Malleswaran
2f4fa89e7b fix: add file_path parameter to save_deliverable for large reports (#123)
* fix: add file_path parameter to save_deliverable for large reports

Large deliverable reports can exceed output token limits when passed as
inline content. This change allows agents to write reports to disk first
and pass a file_path instead.

Changes:
- Add file_path parameter to save_deliverable MCP tool with path
  traversal protection
- Pass CLAUDE_CODE_MAX_OUTPUT_TOKENS env var to SDK subprocesses
- Fix false positive error detection by extracting only text content
  (not tool_use JSON) when checking for API errors
- Update all prompts to instruct agents to use file_path for large
  reports and stop immediately after completion

* docs: simplify and condense CLAUDE.md

Reduce verbosity while preserving all essential information for AI
assistance. Makes the documentation more scannable and focused.

* feat: add issue number detection to pr command

The /pr command now automatically detects issue numbers from:
1. Explicit arguments (e.g., /pr 123 or /pr 123,456)
2. Branch name patterns (e.g., fix/123-bug, issue-456-feature)

Adds "Closes #X" lines to PR body to auto-close issues on merge.

* chore: remove CLAUDE_CODE_MAX_OUTPUT_TOKENS env var handling

No longer needed with the new Claude Agent SDK version.

* fix: restore max_output_tokens error handling
2026-02-11 13:40:49 -08:00
ezl-keygraph
2e1fe3454a chore: migrate issue templates to GitHub issue forms (#119)
Replace markdown-based issue templates with YAML issue forms for
structured input with dropdowns, checkboxes, and required fields.
2026-02-11 19:02:36 +05:30
ezl-keygraph
a5daa07178 fix: auto-detect Podman to avoid host-gateway incompatibility (#117)
Podman doesn't support the `host-gateway` special value in extra_hosts,
which causes container startup failures on macOS with Podman Desktop.

Changes:
- Add docker-compose.docker.yml with extra_hosts override for Docker
- Update shannon script to detect Podman via `command -v podman`
- Skip extra_hosts override when Podman is detected

This ensures:
- Docker users (Linux): Get host.docker.internal working automatically
- Podman users (macOS): Base config works without modification

Co-authored-by: ajmallesh <ajmallesh@gmail.com>
2026-02-11 01:51:48 +05:30
ezl-keygraph
efb5368b3c fix: prevent deliverables from being lost during agent retry rollbacks (#112)
Deliverables saved by agents were never committed to git because
git identity was not configured in the Docker container. This left
them as untracked files, which git clean -fd destroyed whenever
another agent's retry triggered a workspace rollback. Moves git
config after ENV HOME=/tmp so the config is written to /tmp/.gitconfig
where git actually looks at runtime.
2026-02-11 00:26:48 +05:30
ezl-keygraph
3c13a9a7e6 feat: upgrade claude-agent-sdk to 0.2.38 and adapt to new SDK types (#113)
* feat: upgrade claude-agent-sdk to 0.2.38 and adapt to new SDK types

- Bump @anthropic-ai/claude-agent-sdk from 0.1.x to 0.2.38 (both root and mcp-server)
- Bump zod from 3.x to 4.x (SDK peer dependency)
- Add allowDangerouslySkipPermissions to query options (required for bypassPermissions)
- Suppress new SDK message types (tool_progress, tool_use_summary, auth_status)
- Use structured error field on assistant messages instead of text-sniffing
- Add stop_reason to result message handling for diagnostics
- Add SDKAssistantMessageError type matching SDK's string literal union

* chore: remove CLAUDE_CODE_MAX_OUTPUT_TOKENS from all config and docs
2026-02-11 00:19:59 +05:30
ezl-keygraph
24bcd29d97 fix: ensure deliverables directory is writable by container user (#116)
Pre-create the deliverables directory with proper permissions on the
host before starting containers, and surface permission errors instead
of silently swallowing them in save_deliverable.
2026-02-11 00:03:02 +05:30
ezl-keygraph
77c5b26a94 feat: add issue templates (#110) 2026-02-10 03:00:21 +05:30
Arjun Malleswaran
9809c769e3 fix: extend heartbeat timeout to prevent stalls during sub-agent execution (#108)
* fix: extend heartbeat timeout to prevent stalls during sub-agent execution

* feat: add /pr command for creating pull requests with conventional commits
2026-02-09 10:58:03 -08:00
ezl-keygraph
2e9ee2a11e fix: mount repos and configs directories into worker container (#107)
* feat: use static repos/ folder mount instead of dynamic TARGET_REPO

Replace dynamic per-run TARGET_REPO bind mount with a static ./repos:/repos
mount. Users place target repositories under ./repos/ and reference them by
folder name. This fixes stale mounts when switching targets and enables
running multiple scans concurrently against different repos.

* feat: mount configs directory into worker container

* docs: add instructions for repos and configs directory setup
2026-02-10 00:05:41 +05:30
Arjun Malleswaran
4aee8db3d0 fix: add cache-busting param to screenshot URL (#82) 2026-02-07 10:08:25 -08:00
Arjun Malleswaran
9ed5327561 Feat/shannon by keygraph branding (#81)
* feat: update splash screen screenshot with new branding

* docs: add Trendshift badge to README
2026-02-07 10:02:48 -08:00
Arjun Malleswaran
3a63624ff7 Merge pull request #59 from KeygraphHQ/keygraphVarun-patch-1
Update README.md
2026-01-27 16:20:45 -08:00
keygraphVarun
7cb0a0ae5e Update README.md 2026-01-27 16:18:02 -08:00
Arjun Malleswaran
1c5a61e05f Merge pull request #58 from KeygraphHQ/keygraphVarun-patch-1
Update README.md
2026-01-22 15:44:36 -08:00
keygraphVarun
8f42eb64fa Update README.md 2026-01-22 15:26:16 -08:00
Arjun Malleswaran
d05eaf2ff7 Merge pull request #56 from KeygraphHQ/feat/model-router
feat: add multi-model router support for OpenAI and OpenRouter
2026-01-21 17:42:52 -08:00
ajmallesh
a15408e23f docs: remove Gemini 3 Pro from supported router models 2026-01-20 16:42:16 -08:00
Arjun Malleswaran
534b24901e Merge branch 'main' into feat/model-router 2026-01-20 10:26:27 -08:00
Arjun Malleswaran
cdb7d165ca Merge pull request #57 from KeygraphHQ/fix/audit-logs-permission-issue
fix: create audit-logs directory before container startup
2026-01-20 10:24:07 -08:00
ajmallesh
65aa5625f6 fix: set write permissions on audit-logs and output directories for container user
The container runs as non-root user 'pentest' (UID 1001), but bind-mounted
directories are owned by the host user. Added chmod 777 after mkdir to ensure
the container can write to these directories.
2026-01-20 10:13:07 -08:00
ajmallesh
25fde5240a docs: remove DeepSeek references from router mode documentation 2026-01-20 09:59:40 -08:00
ajmallesh
f85c1bd193 refactor: simplify router to OpenAI and OpenRouter providers only
- Remove Gemini direct and DeepSeek provider configurations
- Keep OpenAI (gpt-5.2, gpt-5-mini) and OpenRouter (Gemini 3 models)
- Update documentation and environment examples
- Remove cost column from README providers table
2026-01-20 09:49:16 -08:00
ajmallesh
63741d780e revert: remove '402' billing pattern causing false positives
Reverts 5428422 - the pattern matched tool call IDs containing "402"
2026-01-16 17:29:54 -08:00
ajmallesh
9606ffcf70 fix: add universal billing error detection for router mode
- Add HTTP 402 and 'insufficient credits' patterns to error classification
- Detect provider billing errors in both exception and message content paths
2026-01-16 11:18:27 -08:00
ajmallesh
cd04c7a6d2 feat: add model tracking and reporting across pipeline
- Track actual model name from router through audit logs, session.json, and query output
- Add router-utils.ts to resolve model names from ROUTER_DEFAULT env var
- Inject model info into final report's Executive Summary section
- Update documentation with supported providers, pricing, and config examples
- Update router-config.json with latest model versions (GPT-5.2, Gemini 2.5, etc.)
2026-01-15 18:30:19 -08:00
ajmallesh
d01980ce4b feat: add OpenRouter provider support for claude-code-router 2026-01-15 15:21:34 -08:00
ajmallesh
d925c4942b feat: add DeepSeek provider support for claude-code-router
- Add DeepSeek provider config with Together.ai and official API support
- Configure deepseek and enhancetool transformers for reliable tool calling
- Add DEEPSEEK_API_KEY and DEEPSEEK_API_BASE env vars to docker-compose
- Update shannon CLI to recognize DeepSeek as valid router provider
2026-01-15 15:16:05 -08:00
ajmallesh
914860a6bd feat: add claude-code-router support for multi-model testing
- Add ROUTER=true flag to route requests through claude-code-router
- Add router service to docker-compose with profile-based activation
- Support OpenAI (gpt-4o) and Google Gemini (gemini-2.5-pro) as alternatives
- Add router-config.json with provider configuration template
- Update .env.example with provider API key options
- Document router mode limitations (cost tracking shows $0)
2026-01-15 14:14:37 -08:00