@jaguilar87/gaia 5.0.0-rc1
This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
- package/.claude-plugin/marketplace.json +33 -0
- package/.claude-plugin/plugin.json +26 -0
- package/ARCHITECTURE.md +335 -0
- package/CHANGELOG.md +1212 -0
- package/CODE_OF_CONDUCT.md +11 -0
- package/CONTRIBUTING.md +146 -0
- package/INSTALL.md +436 -0
- package/LICENSE +21 -0
- package/README.md +222 -0
- package/SECURITY.md +47 -0
- package/agents/README.md +78 -0
- package/agents/cloud-troubleshooter.md +73 -0
- package/agents/developer.md +65 -0
- package/agents/gaia-operator.md +64 -0
- package/agents/gaia-orchestrator.md +237 -0
- package/agents/gaia-planner.md +53 -0
- package/agents/gaia-system.md +70 -0
- package/agents/gitops-operator.md +61 -0
- package/agents/terraform-architect.md +63 -0
- package/bin/README.md +106 -0
- package/bin/cli/__init__.py +1 -0
- package/bin/cli/approvals.py +740 -0
- package/bin/cli/cleanup.py +562 -0
- package/bin/cli/context.py +283 -0
- package/bin/cli/doctor.py +628 -0
- package/bin/cli/history.py +305 -0
- package/bin/cli/memory.py +464 -0
- package/bin/cli/metrics.py +1068 -0
- package/bin/cli/plans.py +515 -0
- package/bin/cli/status.py +302 -0
- package/bin/cli/update.py +382 -0
- package/bin/gaia +112 -0
- package/bin/gaia-cleanup.js +531 -0
- package/bin/gaia-doctor.js +635 -0
- package/bin/gaia-evidence +126 -0
- package/bin/gaia-history.js +251 -0
- package/bin/gaia-metrics.js +1278 -0
- package/bin/gaia-review.js +269 -0
- package/bin/gaia-scan +44 -0
- package/bin/gaia-scan.py +589 -0
- package/bin/gaia-skills-diagnose.js +929 -0
- package/bin/gaia-status.js +278 -0
- package/bin/gaia-uninstall.js +111 -0
- package/bin/gaia-update.js +816 -0
- package/bin/pre-publish-validate.js +610 -0
- package/bin/python-detect.js +60 -0
- package/commands/README.md +64 -0
- package/commands/gaia.md +37 -0
- package/commands/scan-project.md +67 -0
- package/config/README.md +71 -0
- package/config/cloud/aws.json +134 -0
- package/config/cloud/gcp.json +139 -0
- package/config/context-contracts.json +158 -0
- package/config/crons-schema.md +81 -0
- package/config/git_standards.json +72 -0
- package/config/surface-routing.json +421 -0
- package/config/universal-rules.json +102 -0
- package/dist/gaia-ops/.claude-plugin/plugin.json +24 -0
- package/dist/gaia-ops/README.md +80 -0
- package/dist/gaia-ops/agents/cloud-troubleshooter.md +73 -0
- package/dist/gaia-ops/agents/developer.md +65 -0
- package/dist/gaia-ops/agents/gaia-operator.md +64 -0
- package/dist/gaia-ops/agents/gaia-orchestrator.md +237 -0
- package/dist/gaia-ops/agents/gaia-planner.md +53 -0
- package/dist/gaia-ops/agents/gaia-system.md +70 -0
- package/dist/gaia-ops/agents/gitops-operator.md +61 -0
- package/dist/gaia-ops/agents/terraform-architect.md +63 -0
- package/dist/gaia-ops/commands/gaia.md +37 -0
- package/dist/gaia-ops/config/README.md +71 -0
- package/dist/gaia-ops/config/cloud/aws.json +134 -0
- package/dist/gaia-ops/config/cloud/gcp.json +139 -0
- package/dist/gaia-ops/config/context-contracts.json +158 -0
- package/dist/gaia-ops/config/crons-schema.md +81 -0
- package/dist/gaia-ops/config/git_standards.json +72 -0
- package/dist/gaia-ops/config/surface-routing.json +421 -0
- package/dist/gaia-ops/config/universal-rules.json +102 -0
- package/dist/gaia-ops/hooks/adapters/__init__.py +52 -0
- package/dist/gaia-ops/hooks/adapters/base.py +219 -0
- package/dist/gaia-ops/hooks/adapters/channel.py +17 -0
- package/dist/gaia-ops/hooks/adapters/claude_code.py +1890 -0
- package/dist/gaia-ops/hooks/adapters/types.py +194 -0
- package/dist/gaia-ops/hooks/adapters/utils.py +25 -0
- package/dist/gaia-ops/hooks/hooks.json +163 -0
- package/dist/gaia-ops/hooks/modules/__init__.py +15 -0
- package/dist/gaia-ops/hooks/modules/agents/__init__.py +29 -0
- package/dist/gaia-ops/hooks/modules/agents/contract_validator.py +647 -0
- package/dist/gaia-ops/hooks/modules/agents/response_contract.py +496 -0
- package/dist/gaia-ops/hooks/modules/agents/skill_injection_verifier.py +120 -0
- package/dist/gaia-ops/hooks/modules/agents/state_tracker.py +267 -0
- package/dist/gaia-ops/hooks/modules/agents/task_info_builder.py +74 -0
- package/dist/gaia-ops/hooks/modules/agents/transcript_analyzer.py +458 -0
- package/dist/gaia-ops/hooks/modules/agents/transcript_reader.py +152 -0
- package/dist/gaia-ops/hooks/modules/audit/__init__.py +28 -0
- package/dist/gaia-ops/hooks/modules/audit/event_detector.py +168 -0
- package/dist/gaia-ops/hooks/modules/audit/logger.py +131 -0
- package/dist/gaia-ops/hooks/modules/audit/metrics.py +134 -0
- package/dist/gaia-ops/hooks/modules/audit/workflow_auditor.py +611 -0
- package/dist/gaia-ops/hooks/modules/audit/workflow_recorder.py +296 -0
- package/dist/gaia-ops/hooks/modules/context/__init__.py +11 -0
- package/dist/gaia-ops/hooks/modules/context/agentic_loop_detector.py +165 -0
- package/dist/gaia-ops/hooks/modules/context/anchor_tracker.py +317 -0
- package/dist/gaia-ops/hooks/modules/context/compact_context_builder.py +218 -0
- package/dist/gaia-ops/hooks/modules/context/context_freshness.py +145 -0
- package/dist/gaia-ops/hooks/modules/context/context_injector.py +558 -0
- package/dist/gaia-ops/hooks/modules/context/context_writer.py +530 -0
- package/dist/gaia-ops/hooks/modules/context/contracts_loader.py +161 -0
- package/dist/gaia-ops/hooks/modules/core/__init__.py +40 -0
- package/dist/gaia-ops/hooks/modules/core/hook_entry.py +78 -0
- package/dist/gaia-ops/hooks/modules/core/paths.py +160 -0
- package/dist/gaia-ops/hooks/modules/core/plugin_mode.py +149 -0
- package/dist/gaia-ops/hooks/modules/core/plugin_setup.py +577 -0
- package/dist/gaia-ops/hooks/modules/core/state.py +179 -0
- package/dist/gaia-ops/hooks/modules/core/stdin.py +24 -0
- package/dist/gaia-ops/hooks/modules/events/__init__.py +1 -0
- package/dist/gaia-ops/hooks/modules/events/event_writer.py +210 -0
- package/dist/gaia-ops/hooks/modules/memory/__init__.py +8 -0
- package/dist/gaia-ops/hooks/modules/memory/episode_writer.py +216 -0
- package/dist/gaia-ops/hooks/modules/orchestrator/__init__.py +1 -0
- package/dist/gaia-ops/hooks/modules/orchestrator/delegate_mode.py +122 -0
- package/dist/gaia-ops/hooks/modules/scanning/__init__.py +8 -0
- package/dist/gaia-ops/hooks/modules/scanning/scan_trigger.py +84 -0
- package/dist/gaia-ops/hooks/modules/security/__init__.py +120 -0
- package/dist/gaia-ops/hooks/modules/security/approval_cleanup.py +87 -0
- package/dist/gaia-ops/hooks/modules/security/approval_constants.py +23 -0
- package/dist/gaia-ops/hooks/modules/security/approval_grants.py +1638 -0
- package/dist/gaia-ops/hooks/modules/security/approval_messages.py +71 -0
- package/dist/gaia-ops/hooks/modules/security/approval_scopes.py +222 -0
- package/dist/gaia-ops/hooks/modules/security/blocked_commands.py +595 -0
- package/dist/gaia-ops/hooks/modules/security/blocked_message_formatter.py +87 -0
- package/dist/gaia-ops/hooks/modules/security/command_semantics.py +181 -0
- package/dist/gaia-ops/hooks/modules/security/composition_rules.py +547 -0
- package/dist/gaia-ops/hooks/modules/security/flag_classifiers.py +873 -0
- package/dist/gaia-ops/hooks/modules/security/gitops_validator.py +179 -0
- package/dist/gaia-ops/hooks/modules/security/mutative_verbs.py +1131 -0
- package/dist/gaia-ops/hooks/modules/security/network_hosts.py +481 -0
- package/dist/gaia-ops/hooks/modules/security/prompt_validator.py +40 -0
- package/dist/gaia-ops/hooks/modules/security/shell_unwrapper.py +165 -0
- package/dist/gaia-ops/hooks/modules/security/tiers.py +196 -0
- package/dist/gaia-ops/hooks/modules/session/__init__.py +10 -0
- package/dist/gaia-ops/hooks/modules/session/pending_scanner.py +174 -0
- package/dist/gaia-ops/hooks/modules/session/session_context_writer.py +100 -0
- package/dist/gaia-ops/hooks/modules/session/session_event_injector.py +160 -0
- package/dist/gaia-ops/hooks/modules/session/session_manager.py +31 -0
- package/dist/gaia-ops/hooks/modules/session/session_registry.py +232 -0
- package/dist/gaia-ops/hooks/modules/tools/__init__.py +29 -0
- package/dist/gaia-ops/hooks/modules/tools/bash_validator.py +1008 -0
- package/dist/gaia-ops/hooks/modules/tools/cloud_pipe_validator.py +231 -0
- package/dist/gaia-ops/hooks/modules/tools/hook_response.py +55 -0
- package/dist/gaia-ops/hooks/modules/tools/shell_parser.py +227 -0
- package/dist/gaia-ops/hooks/modules/tools/stage_decomposer.py +315 -0
- package/dist/gaia-ops/hooks/modules/tools/task_validator.py +294 -0
- package/dist/gaia-ops/hooks/modules/validation/__init__.py +23 -0
- package/dist/gaia-ops/hooks/modules/validation/commit_validator.py +380 -0
- package/dist/gaia-ops/hooks/post_compact.py +43 -0
- package/dist/gaia-ops/hooks/post_tool_use.py +54 -0
- package/dist/gaia-ops/hooks/pre_compact.py +60 -0
- package/dist/gaia-ops/hooks/pre_tool_use.py +413 -0
- package/dist/gaia-ops/hooks/session_start.py +81 -0
- package/dist/gaia-ops/hooks/stop_hook.py +82 -0
- package/dist/gaia-ops/hooks/subagent_start.py +71 -0
- package/dist/gaia-ops/hooks/subagent_stop.py +295 -0
- package/dist/gaia-ops/hooks/task_completed.py +70 -0
- package/dist/gaia-ops/hooks/user_prompt_submit.py +246 -0
- package/dist/gaia-ops/settings.json +72 -0
- package/dist/gaia-ops/skills/README.md +154 -0
- package/dist/gaia-ops/skills/agent-protocol/SKILL.md +93 -0
- package/dist/gaia-ops/skills/agent-protocol/examples.md +223 -0
- package/dist/gaia-ops/skills/agent-response/SKILL.md +69 -0
- package/dist/gaia-ops/skills/agentic-loop/SKILL.md +80 -0
- package/dist/gaia-ops/skills/agentic-loop/reference.md +378 -0
- package/dist/gaia-ops/skills/blog-writing/SKILL.md +98 -0
- package/dist/gaia-ops/skills/blog-writing/reference.md +130 -0
- package/dist/gaia-ops/skills/brief-spec/SKILL.md +182 -0
- package/dist/gaia-ops/skills/command-execution/SKILL.md +64 -0
- package/dist/gaia-ops/skills/command-execution/reference.md +83 -0
- package/dist/gaia-ops/skills/context-updater/SKILL.md +87 -0
- package/dist/gaia-ops/skills/context-updater/examples.md +71 -0
- package/dist/gaia-ops/skills/developer-patterns/SKILL.md +50 -0
- package/dist/gaia-ops/skills/developer-patterns/reference.md +112 -0
- package/dist/gaia-ops/skills/execution/SKILL.md +99 -0
- package/dist/gaia-ops/skills/fast-queries/SKILL.md +43 -0
- package/dist/gaia-ops/skills/gaia-compact/SKILL.md +74 -0
- package/dist/gaia-ops/skills/gaia-patterns/SKILL.md +108 -0
- package/dist/gaia-ops/skills/gaia-patterns/reference.md +395 -0
- package/dist/gaia-ops/skills/gaia-planner/SKILL.md +37 -0
- package/dist/gaia-ops/skills/gaia-planner/reference.md +107 -0
- package/dist/gaia-ops/skills/gaia-release/SKILL.md +82 -0
- package/dist/gaia-ops/skills/gaia-release/reference.md +102 -0
- package/dist/gaia-ops/skills/gaia-self-check/SKILL.md +114 -0
- package/dist/gaia-ops/skills/gaia-self-check/reference.md +453 -0
- package/dist/gaia-ops/skills/gaia-verify/SKILL.md +77 -0
- package/dist/gaia-ops/skills/gaia-verify/reference.md +80 -0
- package/dist/gaia-ops/skills/git-conventions/SKILL.md +47 -0
- package/dist/gaia-ops/skills/gitops-patterns/SKILL.md +60 -0
- package/dist/gaia-ops/skills/gitops-patterns/reference.md +183 -0
- package/dist/gaia-ops/skills/gmail-policy/SKILL.md +200 -0
- package/dist/gaia-ops/skills/gmail-policy/reference.md +150 -0
- package/dist/gaia-ops/skills/gmail-triage/SKILL.md +100 -0
- package/dist/gaia-ops/skills/gws-setup/SKILL.md +99 -0
- package/dist/gaia-ops/skills/gws-setup/reference.md +73 -0
- package/dist/gaia-ops/skills/investigation/SKILL.md +100 -0
- package/dist/gaia-ops/skills/memory-curation/SKILL.md +83 -0
- package/dist/gaia-ops/skills/memory-search/SKILL.md +88 -0
- package/dist/gaia-ops/skills/orchestrator-approval/SKILL.md +160 -0
- package/dist/gaia-ops/skills/orchestrator-approval/reference.md +174 -0
- package/dist/gaia-ops/skills/pending-approvals/SKILL.md +72 -0
- package/dist/gaia-ops/skills/pending-approvals/reference.md +214 -0
- package/dist/gaia-ops/skills/readme-writing/SKILL.md +71 -0
- package/dist/gaia-ops/skills/readme-writing/reference.md +188 -0
- package/dist/gaia-ops/skills/reference.md +135 -0
- package/dist/gaia-ops/skills/request-approval/SKILL.md +140 -0
- package/dist/gaia-ops/skills/request-approval/examples.md +140 -0
- package/dist/gaia-ops/skills/request-approval/reference.md +57 -0
- package/dist/gaia-ops/skills/schedule-task/SKILL.md +64 -0
- package/dist/gaia-ops/skills/schedule-task/reference.md +233 -0
- package/dist/gaia-ops/skills/security-tiers/SKILL.md +141 -0
- package/dist/gaia-ops/skills/security-tiers/destructive-commands-reference.md +623 -0
- package/dist/gaia-ops/skills/security-tiers/reference.md +39 -0
- package/dist/gaia-ops/skills/skill-creation/SKILL.md +92 -0
- package/dist/gaia-ops/skills/skill-creation/reference.md +29 -0
- package/dist/gaia-ops/skills/terraform-patterns/SKILL.md +89 -0
- package/dist/gaia-ops/skills/terraform-patterns/reference.md +93 -0
- package/dist/gaia-ops/tools/__init__.py +9 -0
- package/dist/gaia-ops/tools/agentic-loop/decide-status.py +210 -0
- package/dist/gaia-ops/tools/agentic-loop/parse-metric.py +106 -0
- package/dist/gaia-ops/tools/agentic-loop/record-iteration.py +221 -0
- package/dist/gaia-ops/tools/context/README.md +132 -0
- package/dist/gaia-ops/tools/context/__init__.py +42 -0
- package/dist/gaia-ops/tools/context/_paths.py +20 -0
- package/dist/gaia-ops/tools/context/context_provider.py +721 -0
- package/dist/gaia-ops/tools/context/context_section_reader.py +342 -0
- package/dist/gaia-ops/tools/context/deep_merge.py +159 -0
- package/dist/gaia-ops/tools/context/pending_updates.py +760 -0
- package/dist/gaia-ops/tools/context/surface_router.py +278 -0
- package/dist/gaia-ops/tools/fast-queries/README.md +65 -0
- package/dist/gaia-ops/tools/fast-queries/__init__.py +30 -0
- package/dist/gaia-ops/tools/fast-queries/appservices/quicktriage_devops_developer.sh +75 -0
- package/dist/gaia-ops/tools/fast-queries/cloud/aws/quicktriage_aws_troubleshooter.sh +32 -0
- package/dist/gaia-ops/tools/fast-queries/cloud/gcp/quicktriage_gcp_troubleshooter.sh +88 -0
- package/dist/gaia-ops/tools/fast-queries/gitops/quicktriage_gitops_operator.sh +48 -0
- package/dist/gaia-ops/tools/fast-queries/run_triage.sh +59 -0
- package/dist/gaia-ops/tools/fast-queries/terraform/quicktriage_terraform_architect.sh +80 -0
- package/dist/gaia-ops/tools/gaia_simulator/__init__.py +33 -0
- package/dist/gaia-ops/tools/gaia_simulator/cli.py +354 -0
- package/dist/gaia-ops/tools/gaia_simulator/extractor.py +457 -0
- package/dist/gaia-ops/tools/gaia_simulator/reporter.py +258 -0
- package/dist/gaia-ops/tools/gaia_simulator/routing_simulator.py +334 -0
- package/dist/gaia-ops/tools/gaia_simulator/runner.py +539 -0
- package/dist/gaia-ops/tools/gaia_simulator/skills_mapper.py +264 -0
- package/dist/gaia-ops/tools/memory/README.md +0 -0
- package/dist/gaia-ops/tools/memory/__init__.py +20 -0
- package/dist/gaia-ops/tools/memory/backfill_fts5.py +107 -0
- package/dist/gaia-ops/tools/memory/conflict_detector.py +295 -0
- package/dist/gaia-ops/tools/memory/episodic.py +1210 -0
- package/dist/gaia-ops/tools/memory/git_invalidator.py +262 -0
- package/dist/gaia-ops/tools/memory/paths.py +102 -0
- package/dist/gaia-ops/tools/memory/scoring.py +193 -0
- package/dist/gaia-ops/tools/memory/search_store.py +360 -0
- package/dist/gaia-ops/tools/persist_transcript_analysis.py +85 -0
- package/dist/gaia-ops/tools/review/__init__.py +1 -0
- package/dist/gaia-ops/tools/review/review_engine.py +157 -0
- package/dist/gaia-ops/tools/scan/__init__.py +35 -0
- package/dist/gaia-ops/tools/scan/config.py +247 -0
- package/dist/gaia-ops/tools/scan/merge.py +212 -0
- package/dist/gaia-ops/tools/scan/orchestrator.py +549 -0
- package/dist/gaia-ops/tools/scan/registry.py +127 -0
- package/dist/gaia-ops/tools/scan/scanners/__init__.py +18 -0
- package/dist/gaia-ops/tools/scan/scanners/base.py +137 -0
- package/dist/gaia-ops/tools/scan/scanners/environment.py +349 -0
- package/dist/gaia-ops/tools/scan/scanners/git.py +570 -0
- package/dist/gaia-ops/tools/scan/scanners/infrastructure.py +875 -0
- package/dist/gaia-ops/tools/scan/scanners/orchestration.py +600 -0
- package/dist/gaia-ops/tools/scan/scanners/stack.py +1085 -0
- package/dist/gaia-ops/tools/scan/scanners/tools.py +260 -0
- package/dist/gaia-ops/tools/scan/setup.py +686 -0
- package/dist/gaia-ops/tools/scan/tests/__init__.py +1 -0
- package/dist/gaia-ops/tools/scan/tests/conftest.py +796 -0
- package/dist/gaia-ops/tools/scan/tests/test_environment.py +323 -0
- package/dist/gaia-ops/tools/scan/tests/test_git.py +419 -0
- package/dist/gaia-ops/tools/scan/tests/test_infrastructure.py +382 -0
- package/dist/gaia-ops/tools/scan/tests/test_integration.py +920 -0
- package/dist/gaia-ops/tools/scan/tests/test_merge.py +269 -0
- package/dist/gaia-ops/tools/scan/tests/test_orchestration.py +304 -0
- package/dist/gaia-ops/tools/scan/tests/test_stack.py +604 -0
- package/dist/gaia-ops/tools/scan/tests/test_tools.py +349 -0
- package/dist/gaia-ops/tools/scan/ui.py +624 -0
- package/dist/gaia-ops/tools/scan/verify.py +270 -0
- package/dist/gaia-ops/tools/scan/walk.py +118 -0
- package/dist/gaia-ops/tools/scan/workspace.py +85 -0
- package/dist/gaia-ops/tools/validation/README.md +244 -0
- package/dist/gaia-ops/tools/validation/__init__.py +17 -0
- package/dist/gaia-ops/tools/validation/approval_gate.py +321 -0
- package/dist/gaia-ops/tools/validation/validate_skills.py +189 -0
- package/dist/gaia-security/.claude-plugin/plugin.json +24 -0
- package/dist/gaia-security/README.md +90 -0
- package/dist/gaia-security/config/universal-rules.json +102 -0
- package/dist/gaia-security/hooks/adapters/__init__.py +52 -0
- package/dist/gaia-security/hooks/adapters/base.py +219 -0
- package/dist/gaia-security/hooks/adapters/channel.py +17 -0
- package/dist/gaia-security/hooks/adapters/claude_code.py +1890 -0
- package/dist/gaia-security/hooks/adapters/types.py +194 -0
- package/dist/gaia-security/hooks/adapters/utils.py +25 -0
- package/dist/gaia-security/hooks/hooks.json +84 -0
- package/dist/gaia-security/hooks/modules/__init__.py +15 -0
- package/dist/gaia-security/hooks/modules/agents/__init__.py +29 -0
- package/dist/gaia-security/hooks/modules/agents/contract_validator.py +647 -0
- package/dist/gaia-security/hooks/modules/agents/response_contract.py +496 -0
- package/dist/gaia-security/hooks/modules/agents/skill_injection_verifier.py +120 -0
- package/dist/gaia-security/hooks/modules/agents/state_tracker.py +267 -0
- package/dist/gaia-security/hooks/modules/agents/task_info_builder.py +74 -0
- package/dist/gaia-security/hooks/modules/agents/transcript_analyzer.py +458 -0
- package/dist/gaia-security/hooks/modules/agents/transcript_reader.py +152 -0
- package/dist/gaia-security/hooks/modules/audit/__init__.py +28 -0
- package/dist/gaia-security/hooks/modules/audit/event_detector.py +168 -0
- package/dist/gaia-security/hooks/modules/audit/logger.py +131 -0
- package/dist/gaia-security/hooks/modules/audit/metrics.py +134 -0
- package/dist/gaia-security/hooks/modules/audit/workflow_auditor.py +611 -0
- package/dist/gaia-security/hooks/modules/audit/workflow_recorder.py +296 -0
- package/dist/gaia-security/hooks/modules/context/__init__.py +11 -0
- package/dist/gaia-security/hooks/modules/context/agentic_loop_detector.py +165 -0
- package/dist/gaia-security/hooks/modules/context/anchor_tracker.py +317 -0
- package/dist/gaia-security/hooks/modules/context/compact_context_builder.py +218 -0
- package/dist/gaia-security/hooks/modules/context/context_freshness.py +145 -0
- package/dist/gaia-security/hooks/modules/context/context_injector.py +558 -0
- package/dist/gaia-security/hooks/modules/context/context_writer.py +530 -0
- package/dist/gaia-security/hooks/modules/context/contracts_loader.py +161 -0
- package/dist/gaia-security/hooks/modules/core/__init__.py +40 -0
- package/dist/gaia-security/hooks/modules/core/hook_entry.py +78 -0
- package/dist/gaia-security/hooks/modules/core/paths.py +160 -0
- package/dist/gaia-security/hooks/modules/core/plugin_mode.py +149 -0
- package/dist/gaia-security/hooks/modules/core/plugin_setup.py +577 -0
- package/dist/gaia-security/hooks/modules/core/state.py +179 -0
- package/dist/gaia-security/hooks/modules/core/stdin.py +24 -0
- package/dist/gaia-security/hooks/modules/events/__init__.py +1 -0
- package/dist/gaia-security/hooks/modules/events/event_writer.py +210 -0
- package/dist/gaia-security/hooks/modules/memory/__init__.py +8 -0
- package/dist/gaia-security/hooks/modules/memory/episode_writer.py +216 -0
- package/dist/gaia-security/hooks/modules/orchestrator/__init__.py +1 -0
- package/dist/gaia-security/hooks/modules/orchestrator/delegate_mode.py +122 -0
- package/dist/gaia-security/hooks/modules/scanning/__init__.py +8 -0
- package/dist/gaia-security/hooks/modules/scanning/scan_trigger.py +84 -0
- package/dist/gaia-security/hooks/modules/security/__init__.py +120 -0
- package/dist/gaia-security/hooks/modules/security/approval_cleanup.py +87 -0
- package/dist/gaia-security/hooks/modules/security/approval_constants.py +23 -0
- package/dist/gaia-security/hooks/modules/security/approval_grants.py +1638 -0
- package/dist/gaia-security/hooks/modules/security/approval_messages.py +71 -0
- package/dist/gaia-security/hooks/modules/security/approval_scopes.py +222 -0
- package/dist/gaia-security/hooks/modules/security/blocked_commands.py +595 -0
- package/dist/gaia-security/hooks/modules/security/blocked_message_formatter.py +87 -0
- package/dist/gaia-security/hooks/modules/security/command_semantics.py +181 -0
- package/dist/gaia-security/hooks/modules/security/composition_rules.py +547 -0
- package/dist/gaia-security/hooks/modules/security/flag_classifiers.py +873 -0
- package/dist/gaia-security/hooks/modules/security/gitops_validator.py +179 -0
- package/dist/gaia-security/hooks/modules/security/mutative_verbs.py +1131 -0
- package/dist/gaia-security/hooks/modules/security/network_hosts.py +481 -0
- package/dist/gaia-security/hooks/modules/security/prompt_validator.py +40 -0
- package/dist/gaia-security/hooks/modules/security/shell_unwrapper.py +165 -0
- package/dist/gaia-security/hooks/modules/security/tiers.py +196 -0
- package/dist/gaia-security/hooks/modules/session/__init__.py +10 -0
- package/dist/gaia-security/hooks/modules/session/pending_scanner.py +174 -0
- package/dist/gaia-security/hooks/modules/session/session_context_writer.py +100 -0
- package/dist/gaia-security/hooks/modules/session/session_event_injector.py +160 -0
- package/dist/gaia-security/hooks/modules/session/session_manager.py +31 -0
- package/dist/gaia-security/hooks/modules/session/session_registry.py +232 -0
- package/dist/gaia-security/hooks/modules/tools/__init__.py +29 -0
- package/dist/gaia-security/hooks/modules/tools/bash_validator.py +1008 -0
- package/dist/gaia-security/hooks/modules/tools/cloud_pipe_validator.py +231 -0
- package/dist/gaia-security/hooks/modules/tools/hook_response.py +55 -0
- package/dist/gaia-security/hooks/modules/tools/shell_parser.py +227 -0
- package/dist/gaia-security/hooks/modules/tools/stage_decomposer.py +315 -0
- package/dist/gaia-security/hooks/modules/tools/task_validator.py +294 -0
- package/dist/gaia-security/hooks/modules/validation/__init__.py +23 -0
- package/dist/gaia-security/hooks/modules/validation/commit_validator.py +380 -0
- package/dist/gaia-security/hooks/post_tool_use.py +54 -0
- package/dist/gaia-security/hooks/pre_tool_use.py +413 -0
- package/dist/gaia-security/hooks/session_start.py +81 -0
- package/dist/gaia-security/hooks/stop_hook.py +82 -0
- package/dist/gaia-security/hooks/user_prompt_submit.py +246 -0
- package/dist/gaia-security/settings.json +58 -0
- package/git-hooks/commit-msg +41 -0
- package/hooks/README.md +100 -0
- package/hooks/adapters/__init__.py +52 -0
- package/hooks/adapters/base.py +219 -0
- package/hooks/adapters/channel.py +17 -0
- package/hooks/adapters/claude_code.py +1890 -0
- package/hooks/adapters/types.py +194 -0
- package/hooks/adapters/utils.py +25 -0
- package/hooks/elicitation_result.py +179 -0
- package/hooks/hooks.json +84 -0
- package/hooks/modules/README.md +189 -0
- package/hooks/modules/__init__.py +15 -0
- package/hooks/modules/agents/__init__.py +29 -0
- package/hooks/modules/agents/contract_validator.py +647 -0
- package/hooks/modules/agents/response_contract.py +496 -0
- package/hooks/modules/agents/skill_injection_verifier.py +120 -0
- package/hooks/modules/agents/state_tracker.py +267 -0
- package/hooks/modules/agents/task_info_builder.py +74 -0
- package/hooks/modules/agents/transcript_analyzer.py +458 -0
- package/hooks/modules/agents/transcript_reader.py +152 -0
- package/hooks/modules/audit/__init__.py +28 -0
- package/hooks/modules/audit/event_detector.py +168 -0
- package/hooks/modules/audit/logger.py +131 -0
- package/hooks/modules/audit/metrics.py +134 -0
- package/hooks/modules/audit/workflow_auditor.py +611 -0
- package/hooks/modules/audit/workflow_recorder.py +296 -0
- package/hooks/modules/context/__init__.py +11 -0
- package/hooks/modules/context/agentic_loop_detector.py +165 -0
- package/hooks/modules/context/anchor_tracker.py +317 -0
- package/hooks/modules/context/compact_context_builder.py +218 -0
- package/hooks/modules/context/context_freshness.py +145 -0
- package/hooks/modules/context/context_injector.py +558 -0
- package/hooks/modules/context/context_writer.py +530 -0
- package/hooks/modules/context/contracts_loader.py +161 -0
- package/hooks/modules/core/__init__.py +40 -0
- package/hooks/modules/core/hook_entry.py +78 -0
- package/hooks/modules/core/paths.py +160 -0
- package/hooks/modules/core/plugin_mode.py +149 -0
- package/hooks/modules/core/plugin_setup.py +577 -0
- package/hooks/modules/core/state.py +179 -0
- package/hooks/modules/core/stdin.py +24 -0
- package/hooks/modules/events/__init__.py +1 -0
- package/hooks/modules/events/event_writer.py +210 -0
- package/hooks/modules/evidence/__init__.py +34 -0
- package/hooks/modules/evidence/assertions.py +137 -0
- package/hooks/modules/evidence/index_writer.py +57 -0
- package/hooks/modules/evidence/loader.py +126 -0
- package/hooks/modules/evidence/runner.py +241 -0
- package/hooks/modules/memory/__init__.py +8 -0
- package/hooks/modules/memory/episode_writer.py +216 -0
- package/hooks/modules/orchestrator/__init__.py +1 -0
- package/hooks/modules/orchestrator/delegate_mode.py +122 -0
- package/hooks/modules/scanning/__init__.py +8 -0
- package/hooks/modules/scanning/scan_trigger.py +84 -0
- package/hooks/modules/security/__init__.py +120 -0
- package/hooks/modules/security/approval_cleanup.py +87 -0
- package/hooks/modules/security/approval_constants.py +23 -0
- package/hooks/modules/security/approval_grants.py +1638 -0
- package/hooks/modules/security/approval_messages.py +71 -0
- package/hooks/modules/security/approval_scopes.py +222 -0
- package/hooks/modules/security/blocked_commands.py +595 -0
- package/hooks/modules/security/blocked_message_formatter.py +87 -0
- package/hooks/modules/security/command_semantics.py +181 -0
- package/hooks/modules/security/composition_rules.py +547 -0
- package/hooks/modules/security/flag_classifiers.py +873 -0
- package/hooks/modules/security/gitops_validator.py +179 -0
- package/hooks/modules/security/mutative_verbs.py +1131 -0
- package/hooks/modules/security/network_hosts.py +481 -0
- package/hooks/modules/security/prompt_validator.py +40 -0
- package/hooks/modules/security/shell_unwrapper.py +165 -0
- package/hooks/modules/security/tiers.py +196 -0
- package/hooks/modules/session/__init__.py +10 -0
- package/hooks/modules/session/pending_scanner.py +174 -0
- package/hooks/modules/session/session_context_writer.py +100 -0
- package/hooks/modules/session/session_event_injector.py +160 -0
- package/hooks/modules/session/session_manager.py +31 -0
- package/hooks/modules/session/session_registry.py +232 -0
- package/hooks/modules/tools/__init__.py +29 -0
- package/hooks/modules/tools/bash_validator.py +1008 -0
- package/hooks/modules/tools/cloud_pipe_validator.py +231 -0
- package/hooks/modules/tools/hook_response.py +55 -0
- package/hooks/modules/tools/shell_parser.py +227 -0
- package/hooks/modules/tools/stage_decomposer.py +315 -0
- package/hooks/modules/tools/task_validator.py +294 -0
- package/hooks/modules/validation/__init__.py +23 -0
- package/hooks/modules/validation/commit_validator.py +380 -0
- package/hooks/post_compact.py +43 -0
- package/hooks/post_tool_use.py +54 -0
- package/hooks/pre_compact.py +60 -0
- package/hooks/pre_tool_use.py +413 -0
- package/hooks/session_start.py +81 -0
- package/hooks/stop_hook.py +82 -0
- package/hooks/subagent_start.py +71 -0
- package/hooks/subagent_stop.py +295 -0
- package/hooks/task_completed.py +70 -0
- package/hooks/user_prompt_submit.py +246 -0
- package/index.js +83 -0
- package/package.json +99 -0
- package/pyproject.toml +32 -0
- package/skills/README.md +154 -0
- package/skills/agent-protocol/SKILL.md +93 -0
- package/skills/agent-protocol/examples.md +223 -0
- package/skills/agent-response/SKILL.md +69 -0
- package/skills/agentic-loop/SKILL.md +80 -0
- package/skills/agentic-loop/reference.md +378 -0
- package/skills/blog-writing/SKILL.md +98 -0
- package/skills/blog-writing/reference.md +130 -0
- package/skills/brief-spec/SKILL.md +182 -0
- package/skills/command-execution/SKILL.md +64 -0
- package/skills/command-execution/reference.md +83 -0
- package/skills/context-updater/SKILL.md +87 -0
- package/skills/context-updater/examples.md +71 -0
- package/skills/developer-patterns/SKILL.md +50 -0
- package/skills/developer-patterns/reference.md +112 -0
- package/skills/execution/SKILL.md +99 -0
- package/skills/fast-queries/SKILL.md +43 -0
- package/skills/gaia-compact/SKILL.md +74 -0
- package/skills/gaia-patterns/SKILL.md +108 -0
- package/skills/gaia-patterns/reference.md +395 -0
- package/skills/gaia-planner/SKILL.md +37 -0
- package/skills/gaia-planner/reference.md +107 -0
- package/skills/gaia-release/SKILL.md +82 -0
- package/skills/gaia-release/reference.md +102 -0
- package/skills/gaia-self-check/SKILL.md +114 -0
- package/skills/gaia-self-check/reference.md +453 -0
- package/skills/gaia-verify/SKILL.md +77 -0
- package/skills/gaia-verify/reference.md +80 -0
- package/skills/git-conventions/SKILL.md +47 -0
- package/skills/gitops-patterns/SKILL.md +60 -0
- package/skills/gitops-patterns/reference.md +183 -0
- package/skills/gmail-policy/SKILL.md +200 -0
- package/skills/gmail-policy/reference.md +150 -0
- package/skills/gmail-triage/SKILL.md +100 -0
- package/skills/gws-setup/SKILL.md +99 -0
- package/skills/gws-setup/reference.md +73 -0
- package/skills/investigation/SKILL.md +100 -0
- package/skills/memory-curation/SKILL.md +83 -0
- package/skills/memory-search/SKILL.md +88 -0
- package/skills/orchestrator-approval/SKILL.md +160 -0
- package/skills/orchestrator-approval/reference.md +174 -0
- package/skills/pending-approvals/SKILL.md +72 -0
- package/skills/pending-approvals/reference.md +214 -0
- package/skills/readme-writing/SKILL.md +71 -0
- package/skills/readme-writing/reference.md +188 -0
- package/skills/reference.md +135 -0
- package/skills/request-approval/SKILL.md +140 -0
- package/skills/request-approval/examples.md +140 -0
- package/skills/request-approval/reference.md +57 -0
- package/skills/schedule-task/SKILL.md +64 -0
- package/skills/schedule-task/reference.md +233 -0
- package/skills/security-tiers/SKILL.md +141 -0
- package/skills/security-tiers/destructive-commands-reference.md +623 -0
- package/skills/security-tiers/reference.md +39 -0
- package/skills/skill-creation/SKILL.md +92 -0
- package/skills/skill-creation/reference.md +29 -0
- package/skills/terraform-patterns/SKILL.md +89 -0
- package/skills/terraform-patterns/reference.md +93 -0
- package/templates/README.md +69 -0
- package/templates/managed-settings.template.json +43 -0
- package/tools/__init__.py +9 -0
- package/tools/agentic-loop/decide-status.py +210 -0
- package/tools/agentic-loop/parse-metric.py +106 -0
- package/tools/agentic-loop/record-iteration.py +221 -0
- package/tools/context/README.md +132 -0
- package/tools/context/__init__.py +42 -0
- package/tools/context/_paths.py +20 -0
- package/tools/context/context_provider.py +721 -0
- package/tools/context/context_section_reader.py +342 -0
- package/tools/context/deep_merge.py +159 -0
- package/tools/context/pending_updates.py +760 -0
- package/tools/context/surface_router.py +278 -0
- package/tools/fast-queries/README.md +65 -0
- package/tools/fast-queries/__init__.py +30 -0
- package/tools/fast-queries/appservices/quicktriage_devops_developer.sh +75 -0
- package/tools/fast-queries/cloud/aws/quicktriage_aws_troubleshooter.sh +32 -0
- package/tools/fast-queries/cloud/gcp/quicktriage_gcp_troubleshooter.sh +88 -0
- package/tools/fast-queries/gitops/quicktriage_gitops_operator.sh +48 -0
- package/tools/fast-queries/run_triage.sh +59 -0
- package/tools/fast-queries/terraform/quicktriage_terraform_architect.sh +80 -0
- package/tools/gaia_simulator/__init__.py +33 -0
- package/tools/gaia_simulator/cli.py +354 -0
- package/tools/gaia_simulator/extractor.py +457 -0
- package/tools/gaia_simulator/reporter.py +258 -0
- package/tools/gaia_simulator/routing_simulator.py +334 -0
- package/tools/gaia_simulator/runner.py +539 -0
- package/tools/gaia_simulator/skills_mapper.py +264 -0
- package/tools/memory/README.md +0 -0
- package/tools/memory/__init__.py +20 -0
- package/tools/memory/backfill_fts5.py +107 -0
- package/tools/memory/conflict_detector.py +295 -0
- package/tools/memory/episodic.py +1210 -0
- package/tools/memory/git_invalidator.py +262 -0
- package/tools/memory/paths.py +102 -0
- package/tools/memory/scoring.py +193 -0
- package/tools/memory/search_store.py +360 -0
- package/tools/persist_transcript_analysis.py +85 -0
- package/tools/review/__init__.py +1 -0
- package/tools/review/review_engine.py +157 -0
- package/tools/scan/__init__.py +35 -0
- package/tools/scan/config.py +247 -0
- package/tools/scan/merge.py +212 -0
- package/tools/scan/orchestrator.py +549 -0
- package/tools/scan/registry.py +127 -0
- package/tools/scan/scanners/__init__.py +18 -0
- package/tools/scan/scanners/base.py +137 -0
- package/tools/scan/scanners/environment.py +349 -0
- package/tools/scan/scanners/git.py +570 -0
- package/tools/scan/scanners/infrastructure.py +875 -0
- package/tools/scan/scanners/orchestration.py +600 -0
- package/tools/scan/scanners/stack.py +1085 -0
- package/tools/scan/scanners/tools.py +260 -0
- package/tools/scan/setup.py +686 -0
- package/tools/scan/tests/__init__.py +1 -0
- package/tools/scan/tests/conftest.py +796 -0
- package/tools/scan/tests/test_environment.py +323 -0
- package/tools/scan/tests/test_git.py +419 -0
- package/tools/scan/tests/test_infrastructure.py +382 -0
- package/tools/scan/tests/test_integration.py +920 -0
- package/tools/scan/tests/test_merge.py +269 -0
- package/tools/scan/tests/test_orchestration.py +304 -0
- package/tools/scan/tests/test_stack.py +604 -0
- package/tools/scan/tests/test_tools.py +349 -0
- package/tools/scan/ui.py +624 -0
- package/tools/scan/verify.py +270 -0
- package/tools/scan/walk.py +118 -0
- package/tools/scan/workspace.py +85 -0
- package/tools/validation/README.md +244 -0
- package/tools/validation/__init__.py +17 -0
- package/tools/validation/approval_gate.py +321 -0
- package/tools/validation/validate_skills.py +189 -0
package/bin/cli/plans.py
ADDED
|
@@ -0,0 +1,515 @@
|
|
|
1
|
+
"""
|
|
2
|
+
gaia plans -- List and display project briefs/plans.
|
|
3
|
+
|
|
4
|
+
Subcommands:
|
|
5
|
+
gaia plans list [--json] List all briefs with status info
|
|
6
|
+
gaia plans show <name> [--json] Show brief.md + plan.md for a named brief
|
|
7
|
+
(accepts name with or without prefix)
|
|
8
|
+
gaia plans rename <name> [--all] Sync directory prefix to frontmatter status
|
|
9
|
+
(accepts name with or without prefix)
|
|
10
|
+
"""
|
|
11
|
+
|
|
12
|
+
import json
|
|
13
|
+
import sys
|
|
14
|
+
from pathlib import Path
|
|
15
|
+
|
|
16
|
+
|
|
17
|
+
# ---------------------------------------------------------------------------
|
|
18
|
+
# Root detection
|
|
19
|
+
# ---------------------------------------------------------------------------
|
|
20
|
+
|
|
21
|
+
def _find_project_root(start: Path) -> Path | None:
|
|
22
|
+
"""Locate the project root that owns .claude/project-context/briefs/.
|
|
23
|
+
|
|
24
|
+
Resolution order:
|
|
25
|
+
1. CLAUDE_PLUGIN_DATA env var (set by Claude Code at runtime) -- its
|
|
26
|
+
parent is the project root.
|
|
27
|
+
2. Walk up from ``start`` looking for .claude/project-context/briefs/
|
|
28
|
+
that actually exists (contains user brief data, not plugin config).
|
|
29
|
+
3. Walk up from ``start`` looking for .claude/project-context/ (has
|
|
30
|
+
project-context data even if briefs/ is absent).
|
|
31
|
+
4. Walk up from ``start`` for any .claude/ directory (original fallback).
|
|
32
|
+
|
|
33
|
+
Strategies 2-3 ensure the CLI skips a plugin's own .claude/ config dir
|
|
34
|
+
(e.g., gaia-ops-dev/.claude/) and continues up to the user's project root
|
|
35
|
+
(e.g., ~/ws/me/.claude/) when the CLI is invoked from inside the plugin
|
|
36
|
+
subdirectory.
|
|
37
|
+
"""
|
|
38
|
+
import os
|
|
39
|
+
plugin_data = os.environ.get("CLAUDE_PLUGIN_DATA")
|
|
40
|
+
if plugin_data:
|
|
41
|
+
candidate = Path(plugin_data)
|
|
42
|
+
# CLAUDE_PLUGIN_DATA points to .claude/ itself; its parent is the root.
|
|
43
|
+
if candidate.is_dir():
|
|
44
|
+
return candidate.parent
|
|
45
|
+
# If the path doesn't exist yet, still trust the env var.
|
|
46
|
+
return candidate.parent
|
|
47
|
+
|
|
48
|
+
current = start.resolve()
|
|
49
|
+
candidates = [current, *current.parents]
|
|
50
|
+
|
|
51
|
+
# Pass 1: prefer a root that has the actual briefs data directory.
|
|
52
|
+
for parent in candidates:
|
|
53
|
+
if (parent / ".claude" / "project-context" / "briefs").is_dir():
|
|
54
|
+
return parent
|
|
55
|
+
|
|
56
|
+
# Pass 2: accept any root that has project-context/ (data dir present).
|
|
57
|
+
for parent in candidates:
|
|
58
|
+
if (parent / ".claude" / "project-context").is_dir():
|
|
59
|
+
return parent
|
|
60
|
+
|
|
61
|
+
# Pass 3: original fallback -- any .claude/ directory.
|
|
62
|
+
for parent in candidates:
|
|
63
|
+
if (parent / ".claude").is_dir():
|
|
64
|
+
return parent
|
|
65
|
+
|
|
66
|
+
return None
|
|
67
|
+
|
|
68
|
+
|
|
69
|
+
def _get_briefs_dir(project_root: Path) -> Path:
|
|
70
|
+
return project_root / ".claude" / "project-context" / "briefs"
|
|
71
|
+
|
|
72
|
+
|
|
73
|
+
# ---------------------------------------------------------------------------
|
|
74
|
+
# Frontmatter parsing
|
|
75
|
+
# ---------------------------------------------------------------------------
|
|
76
|
+
|
|
77
|
+
def _parse_frontmatter(text: str) -> dict:
|
|
78
|
+
"""Extract key: value pairs from YAML frontmatter (no external deps).
|
|
79
|
+
|
|
80
|
+
Returns an empty dict if no frontmatter found.
|
|
81
|
+
"""
|
|
82
|
+
if not text.startswith("---"):
|
|
83
|
+
return {}
|
|
84
|
+
try:
|
|
85
|
+
end = text.index("---", 3)
|
|
86
|
+
except ValueError:
|
|
87
|
+
return {}
|
|
88
|
+
fm_text = text[3:end]
|
|
89
|
+
result = {}
|
|
90
|
+
for line in fm_text.splitlines():
|
|
91
|
+
stripped = line.strip()
|
|
92
|
+
if not stripped or stripped.startswith("#"):
|
|
93
|
+
continue
|
|
94
|
+
if ":" in stripped:
|
|
95
|
+
key, _, value = stripped.partition(":")
|
|
96
|
+
key = key.strip()
|
|
97
|
+
value = value.strip()
|
|
98
|
+
if value:
|
|
99
|
+
result[key] = value
|
|
100
|
+
return result
|
|
101
|
+
|
|
102
|
+
|
|
103
|
+
# ---------------------------------------------------------------------------
|
|
104
|
+
# Prefix helpers
|
|
105
|
+
# ---------------------------------------------------------------------------
|
|
106
|
+
|
|
107
|
+
_KNOWN_PREFIXES = ("open_", "in-progress_", "closed_")
|
|
108
|
+
|
|
109
|
+
_STATUS_TO_PREFIX: dict[str, str] = {
|
|
110
|
+
"draft": "open_",
|
|
111
|
+
"ready": "open_",
|
|
112
|
+
"in-progress": "in-progress_",
|
|
113
|
+
"complete": "closed_",
|
|
114
|
+
"verified": "closed_",
|
|
115
|
+
"done": "closed_",
|
|
116
|
+
}
|
|
117
|
+
|
|
118
|
+
|
|
119
|
+
def _strip_prefix(name: str) -> str:
|
|
120
|
+
"""Return the bare feature name without any known prefix."""
|
|
121
|
+
for prefix in _KNOWN_PREFIXES:
|
|
122
|
+
if name.startswith(prefix):
|
|
123
|
+
return name[len(prefix):]
|
|
124
|
+
return name
|
|
125
|
+
|
|
126
|
+
|
|
127
|
+
def _resolve_brief_dir(briefs_dir: Path, name: str) -> Path | None:
|
|
128
|
+
"""Find the brief directory for ``name`` regardless of prefix.
|
|
129
|
+
|
|
130
|
+
If ``name`` already contains a valid prefix, look for that exact path first.
|
|
131
|
+
Otherwise (or if not found), search by stripping all known prefixes from
|
|
132
|
+
existing directories and matching the bare suffix.
|
|
133
|
+
|
|
134
|
+
Returns the Path if a unique match is found, None if not found.
|
|
135
|
+
Raises ValueError if multiple directories match the same bare name.
|
|
136
|
+
"""
|
|
137
|
+
if not briefs_dir.is_dir():
|
|
138
|
+
return None
|
|
139
|
+
|
|
140
|
+
# Exact match first (name may already have the right prefix).
|
|
141
|
+
exact = briefs_dir / name
|
|
142
|
+
if exact.is_dir():
|
|
143
|
+
return exact
|
|
144
|
+
|
|
145
|
+
# Fuzzy match: strip prefix from ``name``, then compare bare suffixes.
|
|
146
|
+
bare = _strip_prefix(name)
|
|
147
|
+
matches = [
|
|
148
|
+
entry for entry in briefs_dir.iterdir()
|
|
149
|
+
if entry.is_dir() and _strip_prefix(entry.name) == bare
|
|
150
|
+
]
|
|
151
|
+
if len(matches) == 1:
|
|
152
|
+
return matches[0]
|
|
153
|
+
if len(matches) > 1:
|
|
154
|
+
raise ValueError(
|
|
155
|
+
f"Ambiguous brief name '{name}': multiple matches {[m.name for m in matches]}"
|
|
156
|
+
)
|
|
157
|
+
return None
|
|
158
|
+
|
|
159
|
+
|
|
160
|
+
# ---------------------------------------------------------------------------
|
|
161
|
+
# Core helpers
|
|
162
|
+
# ---------------------------------------------------------------------------
|
|
163
|
+
|
|
164
|
+
def _collect_briefs(briefs_dir: Path) -> list[dict]:
|
|
165
|
+
"""Walk briefs_dir and return a list of brief info dicts."""
|
|
166
|
+
results = []
|
|
167
|
+
if not briefs_dir.is_dir():
|
|
168
|
+
return results
|
|
169
|
+
|
|
170
|
+
for entry in sorted(briefs_dir.iterdir()):
|
|
171
|
+
if not entry.is_dir():
|
|
172
|
+
continue
|
|
173
|
+
brief_file = entry / "brief.md"
|
|
174
|
+
plan_file = entry / "plan.md"
|
|
175
|
+
if not brief_file.exists():
|
|
176
|
+
continue
|
|
177
|
+
|
|
178
|
+
brief_text = brief_file.read_text(encoding="utf-8")
|
|
179
|
+
brief_fm = _parse_frontmatter(brief_text)
|
|
180
|
+
|
|
181
|
+
plan_fm: dict = {}
|
|
182
|
+
if plan_file.exists():
|
|
183
|
+
plan_text = plan_file.read_text(encoding="utf-8")
|
|
184
|
+
plan_fm = _parse_frontmatter(plan_text)
|
|
185
|
+
|
|
186
|
+
results.append(
|
|
187
|
+
{
|
|
188
|
+
"name": entry.name,
|
|
189
|
+
"brief_status": brief_fm.get("status", "(none)"),
|
|
190
|
+
"plan_file_status": plan_fm.get("status", "(absent)") if plan_file.exists() else "(absent)",
|
|
191
|
+
"has_plan": plan_file.exists(),
|
|
192
|
+
}
|
|
193
|
+
)
|
|
194
|
+
return results
|
|
195
|
+
|
|
196
|
+
|
|
197
|
+
# ---------------------------------------------------------------------------
|
|
198
|
+
# Subcommand handlers
|
|
199
|
+
# ---------------------------------------------------------------------------
|
|
200
|
+
|
|
201
|
+
def _cmd_list(args) -> int:
|
|
202
|
+
"""Handle `gaia plans list`."""
|
|
203
|
+
project_root = _find_project_root(Path.cwd())
|
|
204
|
+
if project_root is None:
|
|
205
|
+
msg = "gaia plans: could not find project root (.claude/ directory)"
|
|
206
|
+
if getattr(args, "json", False):
|
|
207
|
+
print(json.dumps({"error": msg}))
|
|
208
|
+
else:
|
|
209
|
+
print(f"Error: {msg}", file=sys.stderr)
|
|
210
|
+
return 1
|
|
211
|
+
|
|
212
|
+
briefs_dir = _get_briefs_dir(project_root)
|
|
213
|
+
briefs = _collect_briefs(briefs_dir)
|
|
214
|
+
|
|
215
|
+
if getattr(args, "json", False):
|
|
216
|
+
print(json.dumps({"briefs": briefs}, indent=2))
|
|
217
|
+
return 0
|
|
218
|
+
|
|
219
|
+
if not briefs:
|
|
220
|
+
print("No briefs found.")
|
|
221
|
+
return 0
|
|
222
|
+
|
|
223
|
+
# Human-readable table
|
|
224
|
+
col_name = max(len("BRIEF"), max(len(b["name"]) for b in briefs))
|
|
225
|
+
col_brief = max(len("BRIEF STATUS"), max(len(b["brief_status"]) for b in briefs))
|
|
226
|
+
col_plan = max(len("PLAN STATUS"), max(len(b["plan_file_status"]) for b in briefs))
|
|
227
|
+
|
|
228
|
+
header = (
|
|
229
|
+
f"{'BRIEF':<{col_name}} {'BRIEF STATUS':<{col_brief}} {'PLAN STATUS':<{col_plan}}"
|
|
230
|
+
)
|
|
231
|
+
sep = "-" * len(header)
|
|
232
|
+
print(header)
|
|
233
|
+
print(sep)
|
|
234
|
+
for b in briefs:
|
|
235
|
+
print(
|
|
236
|
+
f"{b['name']:<{col_name}} {b['brief_status']:<{col_brief}} {b['plan_file_status']:<{col_plan}}"
|
|
237
|
+
)
|
|
238
|
+
return 0
|
|
239
|
+
|
|
240
|
+
|
|
241
|
+
def _cmd_show(args) -> int:
|
|
242
|
+
"""Handle `gaia plans show <name>` (prefix-tolerant)."""
|
|
243
|
+
project_root = _find_project_root(Path.cwd())
|
|
244
|
+
if project_root is None:
|
|
245
|
+
msg = "gaia plans: could not find project root (.claude/ directory)"
|
|
246
|
+
if getattr(args, "json", False):
|
|
247
|
+
print(json.dumps({"error": msg}))
|
|
248
|
+
else:
|
|
249
|
+
print(f"Error: {msg}", file=sys.stderr)
|
|
250
|
+
return 1
|
|
251
|
+
|
|
252
|
+
brief_name: str = args.name
|
|
253
|
+
briefs_dir = _get_briefs_dir(project_root)
|
|
254
|
+
|
|
255
|
+
try:
|
|
256
|
+
brief_dir = _resolve_brief_dir(briefs_dir, brief_name)
|
|
257
|
+
except ValueError as exc:
|
|
258
|
+
msg = str(exc)
|
|
259
|
+
if getattr(args, "json", False):
|
|
260
|
+
print(json.dumps({"error": msg}))
|
|
261
|
+
else:
|
|
262
|
+
print(f"Error: {msg}", file=sys.stderr)
|
|
263
|
+
return 1
|
|
264
|
+
|
|
265
|
+
if brief_dir is None:
|
|
266
|
+
msg = f"Brief '{brief_name}' not found in {briefs_dir}"
|
|
267
|
+
if getattr(args, "json", False):
|
|
268
|
+
print(json.dumps({"error": msg}))
|
|
269
|
+
else:
|
|
270
|
+
print(f"Error: {msg}", file=sys.stderr)
|
|
271
|
+
return 1
|
|
272
|
+
|
|
273
|
+
# Use the resolved directory name for display.
|
|
274
|
+
brief_name = brief_dir.name
|
|
275
|
+
|
|
276
|
+
brief_file = brief_dir / "brief.md"
|
|
277
|
+
plan_file = brief_dir / "plan.md"
|
|
278
|
+
|
|
279
|
+
if not brief_file.exists():
|
|
280
|
+
msg = f"brief.md not found for '{brief_name}'"
|
|
281
|
+
if getattr(args, "json", False):
|
|
282
|
+
print(json.dumps({"error": msg}))
|
|
283
|
+
else:
|
|
284
|
+
print(f"Error: {msg}", file=sys.stderr)
|
|
285
|
+
return 1
|
|
286
|
+
|
|
287
|
+
brief_content = brief_file.read_text(encoding="utf-8")
|
|
288
|
+
plan_content = plan_file.read_text(encoding="utf-8") if plan_file.exists() else None
|
|
289
|
+
|
|
290
|
+
if getattr(args, "json", False):
|
|
291
|
+
payload: dict = {"name": brief_name, "brief": brief_content}
|
|
292
|
+
if plan_content is not None:
|
|
293
|
+
payload["plan"] = plan_content
|
|
294
|
+
print(json.dumps(payload, indent=2))
|
|
295
|
+
return 0
|
|
296
|
+
|
|
297
|
+
# Human-readable output
|
|
298
|
+
print(f"=== {brief_name}/brief.md ===")
|
|
299
|
+
print(brief_content)
|
|
300
|
+
if plan_content is not None:
|
|
301
|
+
print(f"=== {brief_name}/plan.md ===")
|
|
302
|
+
print(plan_content)
|
|
303
|
+
else:
|
|
304
|
+
print(f"(no plan.md for '{brief_name}')")
|
|
305
|
+
return 0
|
|
306
|
+
|
|
307
|
+
|
|
308
|
+
def _rename_one(briefs_dir: Path, name: str) -> dict:
|
|
309
|
+
"""Rename a single brief directory to match its frontmatter status.
|
|
310
|
+
|
|
311
|
+
Returns a result dict with keys: old_name, new_name, status, action.
|
|
312
|
+
action is "renamed" or "already-correct".
|
|
313
|
+
Raises ValueError on ambiguous match or missing brief.
|
|
314
|
+
"""
|
|
315
|
+
brief_dir = _resolve_brief_dir(briefs_dir, name)
|
|
316
|
+
if brief_dir is None:
|
|
317
|
+
raise ValueError(f"Brief '{name}' not found in {briefs_dir}")
|
|
318
|
+
|
|
319
|
+
brief_file = brief_dir / "brief.md"
|
|
320
|
+
if not brief_file.exists():
|
|
321
|
+
raise ValueError(f"brief.md not found in '{brief_dir.name}'")
|
|
322
|
+
|
|
323
|
+
brief_fm = _parse_frontmatter(brief_file.read_text(encoding="utf-8"))
|
|
324
|
+
status = brief_fm.get("status", "")
|
|
325
|
+
|
|
326
|
+
expected_prefix = _STATUS_TO_PREFIX.get(status)
|
|
327
|
+
if expected_prefix is None:
|
|
328
|
+
raise ValueError(
|
|
329
|
+
f"Unknown status '{status}' in '{brief_dir.name}'. "
|
|
330
|
+
f"Known values: {sorted(_STATUS_TO_PREFIX)}"
|
|
331
|
+
)
|
|
332
|
+
|
|
333
|
+
bare = _strip_prefix(brief_dir.name)
|
|
334
|
+
expected_name = expected_prefix + bare
|
|
335
|
+
|
|
336
|
+
if brief_dir.name == expected_name:
|
|
337
|
+
return {
|
|
338
|
+
"old_name": brief_dir.name,
|
|
339
|
+
"new_name": brief_dir.name,
|
|
340
|
+
"status": status,
|
|
341
|
+
"action": "already-correct",
|
|
342
|
+
}
|
|
343
|
+
|
|
344
|
+
new_dir = briefs_dir / expected_name
|
|
345
|
+
brief_dir.rename(new_dir)
|
|
346
|
+
return {
|
|
347
|
+
"old_name": brief_dir.name,
|
|
348
|
+
"new_name": expected_name,
|
|
349
|
+
"status": status,
|
|
350
|
+
"action": "renamed",
|
|
351
|
+
}
|
|
352
|
+
|
|
353
|
+
|
|
354
|
+
def _cmd_rename(args) -> int:
|
|
355
|
+
"""Handle `gaia plans rename <name>` and `gaia plans rename --all`."""
|
|
356
|
+
project_root = _find_project_root(Path.cwd())
|
|
357
|
+
if project_root is None:
|
|
358
|
+
msg = "gaia plans: could not find project root (.claude/ directory)"
|
|
359
|
+
if getattr(args, "json", False):
|
|
360
|
+
print(json.dumps({"error": msg}))
|
|
361
|
+
else:
|
|
362
|
+
print(f"Error: {msg}", file=sys.stderr)
|
|
363
|
+
return 1
|
|
364
|
+
|
|
365
|
+
briefs_dir = _get_briefs_dir(project_root)
|
|
366
|
+
|
|
367
|
+
rename_all = getattr(args, "all", False)
|
|
368
|
+
|
|
369
|
+
if rename_all:
|
|
370
|
+
if not briefs_dir.is_dir():
|
|
371
|
+
result: dict = {"results": [], "error": None}
|
|
372
|
+
if getattr(args, "json", False):
|
|
373
|
+
print(json.dumps(result, indent=2))
|
|
374
|
+
else:
|
|
375
|
+
print("No briefs directory found.")
|
|
376
|
+
return 0
|
|
377
|
+
|
|
378
|
+
results = []
|
|
379
|
+
errors = []
|
|
380
|
+
for entry in sorted(briefs_dir.iterdir()):
|
|
381
|
+
if not entry.is_dir():
|
|
382
|
+
continue
|
|
383
|
+
if not (entry / "brief.md").exists():
|
|
384
|
+
continue
|
|
385
|
+
try:
|
|
386
|
+
res = _rename_one(briefs_dir, entry.name)
|
|
387
|
+
results.append(res)
|
|
388
|
+
except ValueError as exc:
|
|
389
|
+
errors.append({"name": entry.name, "error": str(exc)})
|
|
390
|
+
|
|
391
|
+
if getattr(args, "json", False):
|
|
392
|
+
print(json.dumps({"results": results, "errors": errors}, indent=2))
|
|
393
|
+
else:
|
|
394
|
+
for res in results:
|
|
395
|
+
action_label = "renamed" if res["action"] == "renamed" else "ok"
|
|
396
|
+
print(f"[{action_label}] {res['old_name']} -> {res['new_name']} (status: {res['status']})")
|
|
397
|
+
for err in errors:
|
|
398
|
+
print(f"[error] {err['name']}: {err['error']}", file=sys.stderr)
|
|
399
|
+
return 0
|
|
400
|
+
|
|
401
|
+
# Single brief rename.
|
|
402
|
+
brief_name: str = getattr(args, "name", None)
|
|
403
|
+
if not brief_name:
|
|
404
|
+
print("Error: provide a brief name or use --all", file=sys.stderr)
|
|
405
|
+
return 1
|
|
406
|
+
|
|
407
|
+
try:
|
|
408
|
+
result_single = _rename_one(briefs_dir, brief_name)
|
|
409
|
+
except ValueError as exc:
|
|
410
|
+
msg = str(exc)
|
|
411
|
+
if getattr(args, "json", False):
|
|
412
|
+
print(json.dumps({"error": msg}))
|
|
413
|
+
else:
|
|
414
|
+
print(f"Error: {msg}", file=sys.stderr)
|
|
415
|
+
return 1
|
|
416
|
+
|
|
417
|
+
if getattr(args, "json", False):
|
|
418
|
+
print(json.dumps(result_single, indent=2))
|
|
419
|
+
else:
|
|
420
|
+
if result_single["action"] == "renamed":
|
|
421
|
+
print(
|
|
422
|
+
f"Renamed: {result_single['old_name']} -> {result_single['new_name']} "
|
|
423
|
+
f"(status: {result_single['status']})"
|
|
424
|
+
)
|
|
425
|
+
else:
|
|
426
|
+
print(
|
|
427
|
+
f"Already correct: {result_single['new_name']} "
|
|
428
|
+
f"(status: {result_single['status']})"
|
|
429
|
+
)
|
|
430
|
+
return 0
|
|
431
|
+
|
|
432
|
+
|
|
433
|
+
# ---------------------------------------------------------------------------
|
|
434
|
+
# Plugin registration
|
|
435
|
+
# ---------------------------------------------------------------------------
|
|
436
|
+
|
|
437
|
+
def register(subparsers) -> None:
|
|
438
|
+
"""Register the `plans` subcommand with the root parser."""
|
|
439
|
+
plans_parser = subparsers.add_parser(
|
|
440
|
+
"plans",
|
|
441
|
+
help="List and display project briefs/plans",
|
|
442
|
+
)
|
|
443
|
+
plans_subparsers = plans_parser.add_subparsers(dest="plans_cmd", metavar="<action>")
|
|
444
|
+
|
|
445
|
+
# gaia plans list
|
|
446
|
+
list_parser = plans_subparsers.add_parser("list", help="List all briefs")
|
|
447
|
+
list_parser.add_argument(
|
|
448
|
+
"--json",
|
|
449
|
+
action="store_true",
|
|
450
|
+
default=False,
|
|
451
|
+
help="Output as JSON",
|
|
452
|
+
)
|
|
453
|
+
|
|
454
|
+
# gaia plans show <name>
|
|
455
|
+
show_parser = plans_subparsers.add_parser(
|
|
456
|
+
"show", help="Show brief content (prefix-tolerant)"
|
|
457
|
+
)
|
|
458
|
+
show_parser.add_argument(
|
|
459
|
+
"name", help="Brief name with or without prefix (e.g. evidence-runner or open_evidence-runner)"
|
|
460
|
+
)
|
|
461
|
+
show_parser.add_argument(
|
|
462
|
+
"--json",
|
|
463
|
+
action="store_true",
|
|
464
|
+
default=False,
|
|
465
|
+
help="Output as JSON",
|
|
466
|
+
)
|
|
467
|
+
|
|
468
|
+
# gaia plans rename <name> [--all]
|
|
469
|
+
rename_parser = plans_subparsers.add_parser(
|
|
470
|
+
"rename", help="Sync directory prefix to frontmatter status"
|
|
471
|
+
)
|
|
472
|
+
rename_parser.add_argument(
|
|
473
|
+
"name",
|
|
474
|
+
nargs="?",
|
|
475
|
+
default=None,
|
|
476
|
+
help="Brief name with or without prefix. Omit when using --all.",
|
|
477
|
+
)
|
|
478
|
+
rename_parser.add_argument(
|
|
479
|
+
"--all",
|
|
480
|
+
action="store_true",
|
|
481
|
+
default=False,
|
|
482
|
+
help="Sync all briefs in the briefs directory",
|
|
483
|
+
)
|
|
484
|
+
rename_parser.add_argument(
|
|
485
|
+
"--json",
|
|
486
|
+
action="store_true",
|
|
487
|
+
default=False,
|
|
488
|
+
help="Output as JSON",
|
|
489
|
+
)
|
|
490
|
+
|
|
491
|
+
|
|
492
|
+
def cmd_plans(args) -> int:
|
|
493
|
+
"""Dispatch handler for `gaia plans`."""
|
|
494
|
+
plans_cmd = getattr(args, "plans_cmd", None)
|
|
495
|
+
if plans_cmd == "list":
|
|
496
|
+
return _cmd_list(args)
|
|
497
|
+
if plans_cmd == "show":
|
|
498
|
+
return _cmd_show(args)
|
|
499
|
+
if plans_cmd == "rename":
|
|
500
|
+
return _cmd_rename(args)
|
|
501
|
+
|
|
502
|
+
# No sub-action: print help for the plans subcommand
|
|
503
|
+
import argparse
|
|
504
|
+
|
|
505
|
+
# Re-parse with just `plans --help` to show the sub-help
|
|
506
|
+
tmp_parser = argparse.ArgumentParser(prog="gaia plans")
|
|
507
|
+
tmp_sub = tmp_parser.add_subparsers(dest="plans_cmd", metavar="<action>")
|
|
508
|
+
tmp_sub.add_parser("list", help="List all briefs")
|
|
509
|
+
show_p = tmp_sub.add_parser("show", help="Show brief content")
|
|
510
|
+
show_p.add_argument("name")
|
|
511
|
+
rename_p = tmp_sub.add_parser("rename", help="Sync directory prefix to frontmatter status")
|
|
512
|
+
rename_p.add_argument("name", nargs="?")
|
|
513
|
+
rename_p.add_argument("--all", action="store_true")
|
|
514
|
+
tmp_parser.print_help()
|
|
515
|
+
return 0
|