cortexhawk 3.1.0

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.
Files changed (136) hide show
  1. package/.cortexhawk-team.yml +65 -0
  2. package/CHANGELOG.md +268 -0
  3. package/CLAUDE.md +96 -0
  4. package/LICENSE +21 -0
  5. package/PACKS.md +14 -0
  6. package/README.md +418 -0
  7. package/REGISTRY.md +23 -0
  8. package/agents/architect.md +46 -0
  9. package/agents/brainstormer.md +57 -0
  10. package/agents/code-simplifier.md +56 -0
  11. package/agents/codebase-mapper.md +63 -0
  12. package/agents/copywriter.md +48 -0
  13. package/agents/debugger.md +44 -0
  14. package/agents/designer.md +53 -0
  15. package/agents/devops.md +49 -0
  16. package/agents/docs-manager.md +50 -0
  17. package/agents/fullstack-developer.md +55 -0
  18. package/agents/git-manager.md +63 -0
  19. package/agents/implementer.md +30 -0
  20. package/agents/journal-writer.md +53 -0
  21. package/agents/planner.md +52 -0
  22. package/agents/project-manager.md +50 -0
  23. package/agents/researcher.md +46 -0
  24. package/agents/reviewer.md +63 -0
  25. package/agents/security-auditor.md +92 -0
  26. package/agents/teacher.md +71 -0
  27. package/agents/tester.md +41 -0
  28. package/commands/api-gen.md +17 -0
  29. package/commands/backlog.md +26 -0
  30. package/commands/bootstrap.md +32 -0
  31. package/commands/brainstorm.md +18 -0
  32. package/commands/build.md +16 -0
  33. package/commands/chain.md +46 -0
  34. package/commands/changelog.md +16 -0
  35. package/commands/check.md +40 -0
  36. package/commands/ci.md +32 -0
  37. package/commands/context.md +35 -0
  38. package/commands/debug.md +16 -0
  39. package/commands/deploy.md +16 -0
  40. package/commands/doc.md +15 -0
  41. package/commands/export.md +17 -0
  42. package/commands/journal.md +18 -0
  43. package/commands/learn.md +16 -0
  44. package/commands/map.md +16 -0
  45. package/commands/migrate.md +17 -0
  46. package/commands/monitor.md +16 -0
  47. package/commands/optimize.md +17 -0
  48. package/commands/plan.md +17 -0
  49. package/commands/pulse.md +46 -0
  50. package/commands/refactor.md +16 -0
  51. package/commands/research.md +18 -0
  52. package/commands/review.md +16 -0
  53. package/commands/scan.md +19 -0
  54. package/commands/ship.md +17 -0
  55. package/commands/simplify.md +16 -0
  56. package/commands/task.md +32 -0
  57. package/commands/tdd.md +17 -0
  58. package/commands/test.md +16 -0
  59. package/commands/upgrade.md +27 -0
  60. package/cortexhawk +450 -0
  61. package/hooks/agent-analytics.sh +67 -0
  62. package/hooks/branch-guard.sh +56 -0
  63. package/hooks/codex-dispatcher.sh +84 -0
  64. package/hooks/commit-guard.sh +71 -0
  65. package/hooks/compose.yml +47 -0
  66. package/hooks/dependency-check.sh +56 -0
  67. package/hooks/file-guard.sh +69 -0
  68. package/hooks/hooks.json +46 -0
  69. package/hooks/self-review.sh +71 -0
  70. package/hooks/session-start.sh +132 -0
  71. package/hooks/session-telemetry.sh +60 -0
  72. package/hooks/test-reminder.sh +75 -0
  73. package/install.sh +3805 -0
  74. package/mcp/README.md +37 -0
  75. package/mcp/context7.json +8 -0
  76. package/mcp/puppeteer.json +8 -0
  77. package/mcp/sequential-thinking.json +8 -0
  78. package/modes/default.md +5 -0
  79. package/modes/fast.md +5 -0
  80. package/modes/learn.md +9 -0
  81. package/modes/orchestration.md +5 -0
  82. package/modes/pair.md +10 -0
  83. package/modes/research.md +5 -0
  84. package/modes/review.md +5 -0
  85. package/package.json +32 -0
  86. package/profiles/api.json +27 -0
  87. package/profiles/data.json +23 -0
  88. package/profiles/fullstack.json +27 -0
  89. package/scripts/autodetect-profile.sh +68 -0
  90. package/scripts/benchmark.sh +106 -0
  91. package/scripts/chain-post-save.sh +23 -0
  92. package/scripts/generate-plans-index.sh +50 -0
  93. package/scripts/git-workflow-init.sh +115 -0
  94. package/scripts/install-codex.sh +128 -0
  95. package/scripts/interactive-init.sh +264 -0
  96. package/scripts/post-install-audit.sh +130 -0
  97. package/scripts/validate.sh +214 -0
  98. package/settings.json +90 -0
  99. package/setup.sh +67 -0
  100. package/skills/databases/schema-designer/SKILL.md +54 -0
  101. package/skills/databases/sql-optimizer/SKILL.md +37 -0
  102. package/skills/devops/ci-cd/SKILL.md +59 -0
  103. package/skills/devops/deployment/SKILL.md +49 -0
  104. package/skills/devops/docker/SKILL.md +57 -0
  105. package/skills/frameworks/api-design/SKILL.md +103 -0
  106. package/skills/frameworks/fastapi/SKILL.md +68 -0
  107. package/skills/frameworks/nextjs/SKILL.md +74 -0
  108. package/skills/frameworks/python/SKILL.md +89 -0
  109. package/skills/frameworks/react/SKILL.md +83 -0
  110. package/skills/frameworks/sveltekit/SKILL.md +69 -0
  111. package/skills/frameworks/tailwindcss/SKILL.md +75 -0
  112. package/skills/frameworks/typescript/SKILL.md +94 -0
  113. package/skills/meta/mcp-builder/SKILL.md +54 -0
  114. package/skills/meta/skill-creator/SKILL.md +43 -0
  115. package/skills/optimization/performance/SKILL.md +70 -0
  116. package/skills/quality/complexity-analyzer/SKILL.md +52 -0
  117. package/skills/quality/error-handling/SKILL.md +123 -0
  118. package/skills/quality/log-analyzer/SKILL.md +31 -0
  119. package/skills/quality/pattern-detector/SKILL.md +50 -0
  120. package/skills/security/auth-analyzer/SKILL.md +96 -0
  121. package/skills/security/compliance-checker/SKILL.md +92 -0
  122. package/skills/security/container-security/SKILL.md +128 -0
  123. package/skills/security/dependency-auditor/SKILL.md +100 -0
  124. package/skills/security/encryption/SKILL.md +94 -0
  125. package/skills/security/incident-response/SKILL.md +127 -0
  126. package/skills/security/secrets/SKILL.md +93 -0
  127. package/skills/security/security-headers/SKILL.md +83 -0
  128. package/skills/security/security-logging/SKILL.md +107 -0
  129. package/skills/security/vulnerability-scanner/SKILL.md +114 -0
  130. package/skills/testing/e2e-testing/SKILL.md +119 -0
  131. package/skills/testing/tdd/SKILL.md +40 -0
  132. package/skills/testing/test-generator/SKILL.md +39 -0
  133. package/skills/workflow/commit/SKILL.md +61 -0
  134. package/skills/workflow/confidence-check/SKILL.md +90 -0
  135. package/skills/workflow/pr-review-comments/SKILL.md +81 -0
  136. package/skills/workflow/pr-review-comments/scripts/fetch_comments.py +237 -0
package/mcp/README.md ADDED
@@ -0,0 +1,37 @@
1
+ # MCP Server Configs
2
+
3
+ Pre-configured MCP servers for Claude Code. Copy the ones you need into your project's `.mcp.json`.
4
+
5
+ ## Usage
6
+
7
+ ```bash
8
+ # Copy a single config
9
+ cp mcp/context7.json .mcp.json
10
+
11
+ # Or merge into existing .mcp.json manually
12
+ ```
13
+
14
+ ## Available Servers
15
+
16
+ | Server | Purpose | Requires |
17
+ |---|---|---|
18
+ | `context7.json` | Library docs lookup via Context7 | npx |
19
+ | `sequential-thinking.json` | Step-by-step reasoning for complex problems | npx |
20
+ | `puppeteer.json` | Browser automation and testing | npx |
21
+
22
+ ## Adding to your project
23
+
24
+ Create or edit `.mcp.json` at your project root:
25
+
26
+ ```json
27
+ {
28
+ "mcpServers": {
29
+ "server-name": {
30
+ "command": "npx",
31
+ "args": ["-y", "package-name"]
32
+ }
33
+ }
34
+ }
35
+ ```
36
+
37
+ Then restart Claude Code to activate.
@@ -0,0 +1,8 @@
1
+ {
2
+ "mcpServers": {
3
+ "context7": {
4
+ "command": "npx",
5
+ "args": ["-y", "@upstash/context7-mcp@latest"]
6
+ }
7
+ }
8
+ }
@@ -0,0 +1,8 @@
1
+ {
2
+ "mcpServers": {
3
+ "puppeteer": {
4
+ "command": "npx",
5
+ "args": ["-y", "@anthropic-ai/mcp-server-puppeteer"]
6
+ }
7
+ }
8
+ }
@@ -0,0 +1,8 @@
1
+ {
2
+ "mcpServers": {
3
+ "sequential-thinking": {
4
+ "command": "npx",
5
+ "args": ["-y", "@modelcontextprotocol/server-sequential-thinking"]
6
+ }
7
+ }
8
+ }
@@ -0,0 +1,5 @@
1
+ ---
2
+ name: default
3
+ description: Balanced mode — thorough but efficient.
4
+ ---
5
+ Respond with clear, actionable output. Balance between detail and brevity. Ask for clarification only when truly ambiguous. Show your work when it adds value.
package/modes/fast.md ADDED
@@ -0,0 +1,5 @@
1
+ ---
2
+ name: fast
3
+ description: Minimal tokens, direct answers, no fluff.
4
+ ---
5
+ Be extremely concise. Code over explanation. No preamble, no summary, no caveats unless critical. One-line answers when possible. Skip alternatives unless asked.
package/modes/learn.md ADDED
@@ -0,0 +1,9 @@
1
+ ---
2
+ name: learn
3
+ description: Teaching mode — three levels from hands-off guidance to structured lectures.
4
+ ---
5
+
6
+ Never write code for the user. Default to **guided** if no level is specified.
7
+ - **guided**: Step-by-step instructions (what file, what line, what concept) but zero code. The user writes everything.
8
+ - **mentor**: Socratic method — ask questions, give hints, review attempts. Never give direct answers.
9
+ - **professor**: Teach theory first. Architecture, trade-offs, patterns, then a learning roadmap.
@@ -0,0 +1,5 @@
1
+ ---
2
+ name: orchestration
3
+ description: Multi-agent coordination mode for complex tasks.
4
+ ---
5
+ Break the task into subtasks. Assign each to the appropriate agent. Coordinate outputs between agents. Maintain context across handoffs. Report progress at each stage. Chain: plan → build → test → review → ship.
package/modes/pair.md ADDED
@@ -0,0 +1,10 @@
1
+ ---
2
+ name: pair
3
+ description: Pair-programming mode — alternate between implementer and reviewer on each change.
4
+ ---
5
+
6
+ After each code change, immediately switch to reviewer and run a review pass (Correctness + Security).
7
+ - If the review finds critical issues, fix them as implementer, then re-review. Max 2 review cycles per change.
8
+ - If the review passes, move to the next change.
9
+ - Always announce the current role: `[implementer]` or `[reviewer]`.
10
+ - Prioritize shipping working code over perfection — stop refining after 2 cycles.
@@ -0,0 +1,5 @@
1
+ ---
2
+ name: research
3
+ description: Deep analysis, brainstorming, exploration of alternatives.
4
+ ---
5
+ Explore thoroughly. Consider multiple angles. Present trade-offs explicitly. Use comparison tables. Include evidence and references. Think out loud. Don't rush to a conclusion — examine the space first.
@@ -0,0 +1,5 @@
1
+ ---
2
+ name: review
3
+ description: Critical, thorough examination with high standards.
4
+ ---
5
+ Be rigorous. Check every edge case. Question assumptions. Flag anything that could fail in production. Score confidence for each finding. Include both problems and positive observations.
package/package.json ADDED
@@ -0,0 +1,32 @@
1
+ {
2
+ "name": "cortexhawk",
3
+ "version": "3.1.0",
4
+ "description": "Open-source development toolkit for Claude Code — optimized agents, skills, commands, hooks, and modes",
5
+ "bin": {
6
+ "cortexhawk": "./cortexhawk"
7
+ },
8
+ "repository": {
9
+ "type": "git",
10
+ "url": "git+https://github.com/Spechawk94/CortexHawk.git"
11
+ },
12
+ "homepage": "https://github.com/Spechawk94/CortexHawk#readme",
13
+ "bugs": {
14
+ "url": "https://github.com/Spechawk94/CortexHawk/issues"
15
+ },
16
+ "keywords": [
17
+ "claude",
18
+ "claude-code",
19
+ "ai",
20
+ "agents",
21
+ "cli",
22
+ "productivity",
23
+ "developer-tools",
24
+ "kimi",
25
+ "codex"
26
+ ],
27
+ "author": "Spechawk94",
28
+ "license": "MIT",
29
+ "engines": {
30
+ "node": ">=16"
31
+ }
32
+ }
@@ -0,0 +1,27 @@
1
+ {
2
+ "name": "api",
3
+ "description": "Backend API development",
4
+ "skills": [
5
+ "frameworks/fastapi",
6
+ "frameworks/python",
7
+ "frameworks/typescript",
8
+ "frameworks/api-design",
9
+ "testing/tdd",
10
+ "testing/test-generator",
11
+ "databases/schema-designer",
12
+ "databases/sql-optimizer",
13
+ "devops/docker",
14
+ "devops/ci-cd",
15
+ "devops/deployment",
16
+ "optimization/performance",
17
+ "quality/error-handling",
18
+ "quality/log-analyzer",
19
+ "security/auth-analyzer",
20
+ "security/vulnerability-scanner",
21
+ "security/dependency-auditor",
22
+ "security/compliance-checker",
23
+ "workflow/commit",
24
+ "workflow/confidence-check",
25
+ "workflow/pr-review-comments"
26
+ ]
27
+ }
@@ -0,0 +1,23 @@
1
+ {
2
+ "name": "data",
3
+ "description": "Data engineering and data science",
4
+ "skills": [
5
+ "frameworks/python",
6
+ "testing/tdd",
7
+ "testing/test-generator",
8
+ "databases/schema-designer",
9
+ "databases/sql-optimizer",
10
+ "devops/docker",
11
+ "devops/ci-cd",
12
+ "devops/deployment",
13
+ "optimization/performance",
14
+ "quality/error-handling",
15
+ "quality/log-analyzer",
16
+ "quality/pattern-detector",
17
+ "security/dependency-auditor",
18
+ "security/secrets",
19
+ "workflow/commit",
20
+ "workflow/confidence-check",
21
+ "workflow/pr-review-comments"
22
+ ]
23
+ }
@@ -0,0 +1,27 @@
1
+ {
2
+ "name": "fullstack",
3
+ "description": "Full-stack web development",
4
+ "skills": [
5
+ "frameworks/react",
6
+ "frameworks/nextjs",
7
+ "frameworks/tailwindcss",
8
+ "frameworks/typescript",
9
+ "frameworks/api-design",
10
+ "testing/tdd",
11
+ "testing/e2e-testing",
12
+ "testing/test-generator",
13
+ "databases/schema-designer",
14
+ "databases/sql-optimizer",
15
+ "devops/docker",
16
+ "devops/ci-cd",
17
+ "devops/deployment",
18
+ "optimization/performance",
19
+ "quality/error-handling",
20
+ "quality/complexity-analyzer",
21
+ "security/auth-analyzer",
22
+ "security/security-headers",
23
+ "workflow/commit",
24
+ "workflow/confidence-check",
25
+ "workflow/pr-review-comments"
26
+ ]
27
+ }
@@ -0,0 +1,68 @@
1
+ #!/bin/bash
2
+ # autodetect-profile.sh — Metadata-driven skill detection (Phase 2)
3
+ # Usage: source this script. Sets PROFILE_FILE and SKILL_COUNT.
4
+
5
+ CORTEXHAWK_DIR="$(cd "$(dirname "${BASH_SOURCE[0]:-$0}")/.." && pwd)"
6
+ SKILLS=""
7
+
8
+ add_skill() {
9
+ case ",$SKILLS," in *",$1,"*) ;; *) SKILLS="${SKILLS:+$SKILLS,}$1" ;; esac
10
+ }
11
+
12
+ check_marker() {
13
+ local marker="$1"
14
+ case "$marker" in
15
+ base) return 0 ;;
16
+ dir:*) [ -d "${marker#dir:}" ] && return 0 ;;
17
+ *:*) local file="${marker%%:*}" pattern="${marker#*:}"
18
+ [ -f "$file" ] && grep -qi "$pattern" "$file" 2>/dev/null && return 0 ;;
19
+ *) [ -f "$marker" ] && return 0 ;;
20
+ esac
21
+ return 1
22
+ }
23
+
24
+ for skill_file in "$CORTEXHAWK_DIR"/skills/*/*/SKILL.md; do
25
+ [ -f "$skill_file" ] || continue
26
+ detect_line=""
27
+ in_front=false
28
+ while IFS= read -r line; do
29
+ if [ "$line" = "---" ]; then
30
+ if [ "$in_front" = true ]; then break; fi
31
+ in_front=true; continue
32
+ fi
33
+ case "$line" in detect:*) detect_line="${line#detect: }" ;; esac
34
+ done < "$skill_file"
35
+ [ -z "$detect_line" ] && continue
36
+
37
+ skill_path="${skill_file#$CORTEXHAWK_DIR/skills/}"
38
+ skill_path="${skill_path%/SKILL.md}"
39
+
40
+ for marker in $detect_line; do
41
+ if check_marker "$marker"; then
42
+ add_skill "$skill_path"
43
+ break
44
+ fi
45
+ done
46
+ done
47
+
48
+ # --- Generate JSON ---
49
+ PROFILE_FILE="/tmp/cortexhawk-autodetect-$$.json"
50
+ SKILL_JSON=$(echo "$SKILLS" | tr ',' '\n' | sed 's/.*/ "&"/' | paste -sd ',' - | sed 's/,/,\n/g')
51
+ cat > "$PROFILE_FILE" << EOF
52
+ {
53
+ "name": "autodetect",
54
+ "description": "Auto-detected from project stack",
55
+ "skills": [
56
+ $SKILL_JSON
57
+ ]
58
+ }
59
+ EOF
60
+ SKILL_COUNT=$(echo "$SKILLS" | tr ',' '\n' | wc -l | tr -d ' ')
61
+
62
+ # --- Stack snapshot ---
63
+ if [ -d "docs/.context" ]; then
64
+ { echo "# Stack Detection"; echo "_Auto-generated. Do not edit._"
65
+ echo ""; echo "Last scan: $(date +%Y-%m-%d)"; echo "Skills detected: $SKILL_COUNT"; echo ""
66
+ echo "$SKILLS" | tr ',' '\n' | while read -r s; do echo "- $s"; done
67
+ } > "docs/.context/_stack.md"
68
+ fi
@@ -0,0 +1,106 @@
1
+ #!/bin/bash
2
+ # benchmark.sh — Validate benchmark fixtures and expectations for CortexHawk agents
3
+ # Run: bash scripts/benchmark.sh
4
+
5
+ set -euo pipefail
6
+
7
+ REPO_DIR="$(cd "$(dirname "$0")/.." && pwd)"
8
+ FIXTURES_DIR="$REPO_DIR/tests/fixtures"
9
+ EXPECTATIONS_DIR="$REPO_DIR/tests/expectations"
10
+ PASS=0
11
+ FAIL=0
12
+
13
+ red() { echo -e "\033[31m$1\033[0m"; }
14
+ green() { echo -e "\033[32m$1\033[0m"; }
15
+
16
+ pass() { green " PASS: $1"; PASS=$((PASS + 1)); }
17
+ fail() { red " FAIL: $1"; FAIL=$((FAIL + 1)); }
18
+
19
+ echo "================================"
20
+ echo "CortexHawk Benchmark Validator"
21
+ echo "================================"
22
+ echo ""
23
+
24
+ # --- Validate fixtures ---
25
+ FIXTURES="node-express-app python-fastapi-app react-nextjs-app"
26
+
27
+ echo "Checking fixtures..."
28
+ for fixture in $FIXTURES; do
29
+ fixture_path="$FIXTURES_DIR/$fixture"
30
+
31
+ # Check directory exists
32
+ if [ ! -d "$fixture_path" ]; then
33
+ fail "$fixture — directory missing"
34
+ continue
35
+ fi
36
+
37
+ # Count files
38
+ file_count=$(find "$fixture_path" -type f | wc -l | tr -d ' ')
39
+ if [ "$file_count" -lt 3 ]; then
40
+ fail "$fixture — only $file_count files (minimum 3)"
41
+ else
42
+ pass "$fixture — $file_count files found"
43
+ fi
44
+
45
+ # Check README exists
46
+ if [ -f "$fixture_path/README.md" ]; then
47
+ pass "$fixture — README.md present"
48
+ else
49
+ fail "$fixture — README.md missing"
50
+ fi
51
+
52
+ # Count BUG/VULN tags
53
+ bug_count=$(grep -r "BUG:" "$fixture_path" --include='*.js' --include='*.py' --include='*.txt' 2>/dev/null | wc -l | tr -d ' ')
54
+ vuln_count=$(grep -r "VULN:" "$fixture_path" --include='*.js' --include='*.py' --include='*.txt' 2>/dev/null | wc -l | tr -d ' ')
55
+ total_tags=$((bug_count + vuln_count))
56
+
57
+ if [ "$total_tags" -ge 4 ]; then
58
+ pass "$fixture — $bug_count BUG + $vuln_count VULN tags ($total_tags total)"
59
+ else
60
+ fail "$fixture — only $total_tags BUG/VULN tags (minimum 4)"
61
+ fi
62
+ done
63
+ echo ""
64
+
65
+ # --- Validate expectations ---
66
+ AGENTS="planner implementer reviewer debugger security-auditor architect brainstormer codebase-mapper code-simplifier copywriter designer devops docs-manager fullstack-developer git-manager journal-writer project-manager researcher teacher tester"
67
+
68
+ echo "Checking expectations..."
69
+ for agent in $AGENTS; do
70
+ exp_file="$EXPECTATIONS_DIR/$agent.json"
71
+
72
+ # Check file exists
73
+ if [ ! -f "$exp_file" ]; then
74
+ fail "$agent.json — file missing"
75
+ continue
76
+ fi
77
+
78
+ # Validate JSON syntax
79
+ if python3 -m json.tool "$exp_file" > /dev/null 2>&1; then
80
+ pass "$agent.json — valid JSON"
81
+ else
82
+ fail "$agent.json — invalid JSON syntax"
83
+ continue
84
+ fi
85
+
86
+ # Check required fields via JSON parsing
87
+ for field in required_sections required_keywords forbidden_patterns; do
88
+ if python3 -c "import json,sys; data=json.load(open(sys.argv[1])); sys.exit(0 if sys.argv[2] in data else 1)" "$exp_file" "$field" 2>/dev/null; then
89
+ pass "$agent.json — has '$field'"
90
+ else
91
+ fail "$agent.json — missing '$field'"
92
+ fi
93
+ done
94
+ done
95
+ echo ""
96
+
97
+ # --- Summary ---
98
+ TOTAL=$((PASS + FAIL))
99
+ echo "================================"
100
+ if [ "$FAIL" -gt 0 ]; then
101
+ red "RESULT: $PASS/$TOTAL passed, $FAIL failed"
102
+ exit 1
103
+ else
104
+ green "RESULT: $PASS/$TOTAL passed — all checks clean"
105
+ exit 0
106
+ fi
@@ -0,0 +1,23 @@
1
+ #!/bin/bash
2
+ # Post-save hook for chain outputs: creates plan symlink + regenerates INDEX.md
3
+ set -e
4
+
5
+ CHAIN_DIR="${1:?Usage: chain-post-save.sh <chain-dir> [project-root]}"
6
+ PROJECT_ROOT="${2:-.}"
7
+ PLANS_DIR="$PROJECT_ROOT/docs/plans"
8
+
9
+ # Extract chain name from dir path
10
+ chain_name=$(basename "$CHAIN_DIR")
11
+
12
+ # Create symlink for planner output
13
+ if [ -f "$CHAIN_DIR/1-planner.md" ]; then
14
+ mkdir -p "$PLANS_DIR"
15
+ ln -sf "../chains/$chain_name/1-planner.md" "$PLANS_DIR/${chain_name}-plan.md"
16
+ echo "Symlink: docs/plans/${chain_name}-plan.md -> ../chains/$chain_name/1-planner.md"
17
+ fi
18
+
19
+ # Regenerate plans INDEX.md
20
+ SCRIPT_DIR="$(cd "$(dirname "$0")" && pwd)"
21
+ if [ -f "$SCRIPT_DIR/generate-plans-index.sh" ]; then
22
+ bash "$SCRIPT_DIR/generate-plans-index.sh" "$PROJECT_ROOT"
23
+ fi
@@ -0,0 +1,50 @@
1
+ #!/bin/bash
2
+ # Generate docs/plans/INDEX.md from standalone plans + chain plans
3
+ set -e
4
+
5
+ PROJECT_ROOT="${1:-.}"
6
+ PLANS_DIR="$PROJECT_ROOT/docs/plans"
7
+ CHAINS_DIR="$PROJECT_ROOT/docs/chains"
8
+ INDEX="$PLANS_DIR/INDEX.md"
9
+
10
+ mkdir -p "$PLANS_DIR"
11
+
12
+ # Collect rows into temp var, then sort
13
+ rows=""
14
+
15
+ # Standalone plans (skip symlinks — those are listed via chains)
16
+ for file in "$PLANS_DIR"/*.md; do
17
+ [ -f "$file" ] || continue
18
+ [ -L "$file" ] && continue
19
+ name=$(basename "$file" .md)
20
+ [ "$name" = "INDEX" ] && continue
21
+ date=$(echo "$name" | grep -oE '^[0-9]{4}-[0-9]{2}-[0-9]{2}' || echo "—")
22
+ title=$(head -1 "$file" | sed 's/^#* *//')
23
+ rows="$rows| $date | [$title]($name.md) | standalone |
24
+ "
25
+ done
26
+
27
+ # Chain plans
28
+ for file in "$CHAINS_DIR"/*/1-planner.md; do
29
+ [ -f "$file" ] || continue
30
+ chain_dir=$(basename "$(dirname "$file")")
31
+ date=$(echo "$chain_dir" | grep -oE '^[0-9]{4}-[0-9]{2}-[0-9]{2}' || echo "—")
32
+ title=$(head -1 "$file" | sed 's/^#* *//')
33
+ relpath="../chains/$chain_dir/1-planner.md"
34
+ rows="$rows| $date | [$title]($relpath) | chain |
35
+ "
36
+ done
37
+
38
+ # Write INDEX.md: header + sorted rows (newest first)
39
+ {
40
+ echo "# Plans Index"
41
+ echo ""
42
+ echo "Auto-generated — do not edit manually."
43
+ echo ""
44
+ echo "| Date | Plan | Source |"
45
+ echo "|---|---|---|"
46
+ echo -n "$rows" | sort -r
47
+ } > "$INDEX"
48
+
49
+ count=$(echo -n "$rows" | grep -c '^|' || true)
50
+ echo "INDEX.md generated: $count plan(s)"
@@ -0,0 +1,115 @@
1
+ #!/bin/bash
2
+ # git-workflow-init.sh — Git workflow preferences wizard (step 5 of --init)
3
+ # Sourced by install.sh after CLAUDE.md setup. Args: $1=PROJECT_ROOT $2=TARGET
4
+ # If GIT_BRANCHING is already set (from interactive-init.sh), skip questions and just write.
5
+
6
+ GW_PROJECT_ROOT="$1"
7
+ GW_TARGET="$2"
8
+
9
+ cyan() { printf "\033[36m%s\033[0m\n" "$1"; } 2>/dev/null
10
+ green() { printf "\033[32m%s\033[0m\n" "$1"; } 2>/dev/null
11
+ bold() { printf "\033[1m%s\033[0m\n" "$1"; } 2>/dev/null
12
+
13
+ # If variables already set by interactive-init.sh, skip questions
14
+ if [ -z "$GIT_BRANCHING" ]; then
15
+ echo ""
16
+ bold "5. Git Workflow"
17
+ echo ""
18
+
19
+ # --- Branching strategy ---
20
+ echo " Branching strategy:"
21
+ echo " 1) Direct main — commit + push direct to main (solo/small team)"
22
+ echo " 2) Dev branch — work on a fixed branch, PR to main when ready"
23
+ echo " 3) Feature branch — one branch per feature, merge via PR"
24
+ echo " 4) GitFlow — develop/release/hotfix (formal release cycles)"
25
+ read -r -p " Choice [1-4] (default: 1): " branch_choice
26
+ case "$branch_choice" in
27
+ 2) GIT_BRANCHING="dev-branch" ;;
28
+ 3) GIT_BRANCHING="feature-branches" ;;
29
+ 4) GIT_BRANCHING="gitflow" ;;
30
+ *) GIT_BRANCHING="direct-main" ;;
31
+ esac
32
+
33
+ GIT_WORK_BRANCH=""
34
+ if [ "$GIT_BRANCHING" = "dev-branch" ]; then
35
+ read -r -p " Working branch name (default: dev): " work_branch
36
+ GIT_WORK_BRANCH="${work_branch:-dev}"
37
+ green " -> $GIT_BRANCHING (branch: $GIT_WORK_BRANCH)"
38
+ else
39
+ green " -> $GIT_BRANCHING"
40
+ fi
41
+ echo ""
42
+
43
+ # --- Commit convention ---
44
+ echo " Commit convention:"
45
+ echo " 1) Conventional — feat(scope): description (default)"
46
+ echo " 2) Freeform — no enforced format"
47
+ read -r -p " Choice [1-2] (default: 1): " commit_choice
48
+ case "$commit_choice" in
49
+ 2) GIT_COMMIT_CONVENTION="freeform" ;;
50
+ *) GIT_COMMIT_CONVENTION="conventional" ;;
51
+ esac
52
+ green " -> $GIT_COMMIT_CONVENTION"
53
+ echo ""
54
+
55
+ # --- PR preference ---
56
+ echo " Pull requests:"
57
+ echo " 1) Never — /ship does commit + push, no PR"
58
+ echo " 2) On demand — /ship asks before creating a PR (default)"
59
+ echo " 3) Always — /ship always creates a PR"
60
+ read -r -p " Choice [1-3] (default: 2): " pr_choice
61
+ case "$pr_choice" in
62
+ 1) GIT_PR_PREFERENCE="never" ;;
63
+ 3) GIT_PR_PREFERENCE="always" ;;
64
+ *) GIT_PR_PREFERENCE="on-demand" ;;
65
+ esac
66
+ green " -> $GIT_PR_PREFERENCE"
67
+ echo ""
68
+
69
+ # --- Auto-push ---
70
+ echo " Auto-push after commit:"
71
+ echo " 1) Never — commit only, manual push"
72
+ echo " 2) After commit — push automatically after each commit (default)"
73
+ echo " 3) Ask — ask each time"
74
+ read -r -p " Choice [1-3] (default: 2): " push_choice
75
+ case "$push_choice" in
76
+ 1) GIT_AUTO_PUSH="never" ;;
77
+ 3) GIT_AUTO_PUSH="ask" ;;
78
+ *) GIT_AUTO_PUSH="after-commit" ;;
79
+ esac
80
+ green " -> $GIT_AUTO_PUSH"
81
+ echo ""
82
+ fi
83
+
84
+ # Use variables from interactive-init.sh or from questions above
85
+ BRANCHING="${GIT_BRANCHING}"
86
+ COMMIT_CONVENTION="${GIT_COMMIT_CONVENTION}"
87
+ PR_PREFERENCE="${GIT_PR_PREFERENCE}"
88
+ AUTO_PUSH="${GIT_AUTO_PUSH}"
89
+
90
+ # --- Write git-workflow.conf ---
91
+ {
92
+ echo "# CortexHawk git workflow preferences"
93
+ echo "# Generated by install.sh --init"
94
+ echo "BRANCHING=$BRANCHING"
95
+ echo "COMMIT_CONVENTION=$COMMIT_CONVENTION"
96
+ echo "PR_PREFERENCE=$PR_PREFERENCE"
97
+ echo "AUTO_PUSH=$AUTO_PUSH"
98
+ [ -n "$GIT_WORK_BRANCH" ] && echo "WORK_BRANCH=$GIT_WORK_BRANCH"
99
+ } > "$GW_TARGET/git-workflow.conf"
100
+ green " Saved git-workflow.conf"
101
+
102
+ # --- Append ## Git Workflow to CLAUDE.md ---
103
+ GW_CLAUDE_MD="$GW_PROJECT_ROOT/CLAUDE.md"
104
+ if [ -f "$GW_CLAUDE_MD" ] && ! grep -q "^## Git Workflow" "$GW_CLAUDE_MD"; then
105
+ {
106
+ echo ""
107
+ echo "## Git Workflow"
108
+ echo ""
109
+ echo "- **Branching**: $BRANCHING$([ -n "$GIT_WORK_BRANCH" ] && echo " (working branch: $GIT_WORK_BRANCH)")"
110
+ echo "- **Commits**: $COMMIT_CONVENTION"
111
+ echo "- **PR preference**: $PR_PREFERENCE"
112
+ echo "- **Auto-push**: $AUTO_PUSH"
113
+ } >> "$GW_CLAUDE_MD"
114
+ green " Appended Git Workflow section to CLAUDE.md"
115
+ fi