devflow-kit 0.3.1 → 0.3.3

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.
@@ -760,9 +760,266 @@ fi
760
760
  echo ""
761
761
  ```
762
762
 
763
- ## Step 13: Final Summary
763
+ ## Step 13: Save Release Notes
764
764
 
765
- Provide release summary:
765
+ Save comprehensive release notes to `.docs/releases/`:
766
+
767
+ ```bash
768
+ # Create releases directory if it doesn't exist
769
+ mkdir -p .docs/releases
770
+
771
+ # Get current date
772
+ RELEASE_DATE=$(date +%Y-%m-%d)
773
+
774
+ # Generate release notes file
775
+ RELEASE_NOTES_FILE=".docs/releases/RELEASE_NOTES_v${NEW_VERSION}.md"
776
+
777
+ # Write comprehensive release notes
778
+ cat > "$RELEASE_NOTES_FILE" <<EOF
779
+ # Release ${NEW_VERSION}
780
+
781
+ **Release Date:** ${RELEASE_DATE}
782
+ **Previous Version:** ${CURRENT_VERSION}
783
+ **Project Type:** ${PROJECT_TYPE}
784
+
785
+ ---
786
+
787
+ ## Release Summary
788
+
789
+ - **Version bump:** ${CURRENT_VERSION} → ${NEW_VERSION}
790
+ - **Commits included:** $(git rev-list --count $COMMIT_RANGE 2>/dev/null || echo "N/A")
791
+ - **Release type:** ${BUMP_TYPE}
792
+ - **Tag:** ${TAG_NAME}
793
+
794
+ ---
795
+
796
+ ## Changes
797
+
798
+ $(cat <<'CHANGES_EOF'
799
+ ${CHANGELOG_ENTRY}
800
+ CHANGES_EOF
801
+ )
802
+
803
+ ---
804
+
805
+ ## Commit History
806
+
807
+ \`\`\`
808
+ $(git log --oneline $COMMIT_RANGE 2>/dev/null || echo "No commits to display")
809
+ \`\`\`
810
+
811
+ ---
812
+
813
+ ## Build & Test Results
814
+
815
+ - **Build:** ${BUILD_RESULT:-N/A}
816
+ - **Tests:** ${TEST_RESULT:-N/A}
817
+
818
+ ---
819
+
820
+ ## Distribution
821
+
822
+ EOF
823
+
824
+ # Add registry links based on project type
825
+ if [ -n "$PUBLISH_CMD" ] && [ "$PUBLISH_CMD" != "echo"* ]; then
826
+ echo "**Published to:**" >> "$RELEASE_NOTES_FILE"
827
+ case "$PROJECT_TYPE" in
828
+ nodejs)
829
+ PACKAGE_NAME=$(command -v jq >/dev/null && jq -r '.name' package.json 2>/dev/null || echo "unknown")
830
+ echo "- npm: https://www.npmjs.com/package/${PACKAGE_NAME}/v/${NEW_VERSION}" >> "$RELEASE_NOTES_FILE"
831
+ ;;
832
+ rust)
833
+ CRATE_NAME=$(grep '^name = ' Cargo.toml | head -1 | sed 's/name = "\(.*\)"/\1/')
834
+ echo "- crates.io: https://crates.io/crates/${CRATE_NAME}/${NEW_VERSION}" >> "$RELEASE_NOTES_FILE"
835
+ ;;
836
+ python)
837
+ PACKAGE_NAME=$(grep '^name = ' pyproject.toml | head -1 | sed 's/name = "\(.*\)"/\1/' || echo "unknown")
838
+ echo "- PyPI: https://pypi.org/project/${PACKAGE_NAME}/${NEW_VERSION}/" >> "$RELEASE_NOTES_FILE"
839
+ ;;
840
+ ruby)
841
+ GEM_NAME=$(ls *.gemspec 2>/dev/null | head -1 | sed 's/\.gemspec$//')
842
+ echo "- RubyGems: https://rubygems.org/gems/${GEM_NAME}/versions/${NEW_VERSION}" >> "$RELEASE_NOTES_FILE"
843
+ ;;
844
+ *) echo "- Package registry (check project documentation)" >> "$RELEASE_NOTES_FILE" ;;
845
+ esac
846
+ echo "" >> "$RELEASE_NOTES_FILE"
847
+ fi
848
+
849
+ # Add Git platform links
850
+ if command -v gh >/dev/null && git remote get-url origin 2>/dev/null | grep -q "github.com"; then
851
+ REPO_URL=$(git remote get-url origin | sed 's/\.git$//')
852
+ cat >> "$RELEASE_NOTES_FILE" <<EOF
853
+
854
+ **Git Repository:**
855
+ - Release: ${REPO_URL}/releases/tag/${TAG_NAME}
856
+ - Commits: ${REPO_URL}/compare/${LAST_TAG}...${TAG_NAME}
857
+ - Changelog: ${REPO_URL}/blob/main/${CHANGELOG_FILE}
858
+
859
+ EOF
860
+ fi
861
+
862
+ # Add verification steps
863
+ cat >> "$RELEASE_NOTES_FILE" <<'EOF'
864
+
865
+ ---
866
+
867
+ ## Verification Steps
868
+
869
+ 1. **Registry Check:** Verify package appears in registry (may take a few minutes)
870
+ 2. **Fresh Install:** Test installation in a clean environment
871
+ 3. **Smoke Tests:** Run basic functionality tests
872
+ 4. **Documentation:** Update any version-specific documentation
873
+
874
+ ---
875
+
876
+ *Release notes generated by DevFlow release agent*
877
+ EOF
878
+
879
+ echo ""
880
+ echo "✅ Release notes saved to: $RELEASE_NOTES_FILE"
881
+ echo ""
882
+ ```
883
+
884
+ ## Step 14: Verify Documentation Alignment
885
+
886
+ Check and update documentation files to ensure consistency:
887
+
888
+ ```bash
889
+ echo "📚 Verifying documentation alignment..."
890
+ echo ""
891
+
892
+ DOC_ISSUES=()
893
+
894
+ # Check if ROADMAP.md exists and needs updating
895
+ if [ -f "ROADMAP.md" ]; then
896
+ echo "Checking ROADMAP.md alignment..."
897
+
898
+ # Check if this release includes features that should be marked as completed
899
+ if echo "$CHANGELOG_ENTRY" | grep -qiE "(feat|feature|add|new)"; then
900
+ echo "⚠️ ROADMAP UPDATE NEEDED:"
901
+ echo " This release includes new features."
902
+ echo " Review ROADMAP.md and mark completed items."
903
+ echo " File: ROADMAP.md"
904
+ echo ""
905
+ DOC_ISSUES+=("ROADMAP.md needs review for completed features")
906
+ fi
907
+
908
+ # Check if roadmap references old version
909
+ if grep -q "$CURRENT_VERSION" ROADMAP.md 2>/dev/null; then
910
+ echo "⚠️ ROADMAP VERSION REFERENCE:"
911
+ echo " ROADMAP.md references old version $CURRENT_VERSION"
912
+ echo " Consider updating version references to $NEW_VERSION"
913
+ echo ""
914
+ DOC_ISSUES+=("ROADMAP.md has old version references")
915
+ fi
916
+ fi
917
+
918
+ # Check for README.md files in subpackages (monorepo support)
919
+ echo "Checking README.md files..."
920
+
921
+ # Find all README.md files (excluding node_modules, .git, etc.)
922
+ READMES=$(find . -name "README.md" -not -path "*/node_modules/*" -not -path "*/.git/*" -not -path "*/dist/*" -not -path "*/build/*" 2>/dev/null)
923
+
924
+ if [ $(echo "$READMES" | wc -l) -gt 1 ]; then
925
+ echo "Found multiple README.md files (monorepo detected)"
926
+
927
+ # Check each README for version references
928
+ for readme in $READMES; do
929
+ if grep -q "$CURRENT_VERSION" "$readme" 2>/dev/null; then
930
+ echo "⚠️ VERSION MISMATCH: $readme"
931
+ echo " Contains old version reference: $CURRENT_VERSION"
932
+ echo " Should be updated to: $NEW_VERSION"
933
+ echo ""
934
+ DOC_ISSUES+=("$readme has old version reference")
935
+ fi
936
+ done
937
+
938
+ # Check for installation instructions consistency
939
+ MAIN_README="./README.md"
940
+ if [ -f "$MAIN_README" ]; then
941
+ MAIN_INSTALL=$(grep -A 3 "Installation\|Install\|Getting Started" "$MAIN_README" 2>/dev/null | head -5)
942
+
943
+ for readme in $READMES; do
944
+ if [ "$readme" != "$MAIN_README" ]; then
945
+ SUB_INSTALL=$(grep -A 3 "Installation\|Install\|Getting Started" "$readme" 2>/dev/null | head -5)
946
+
947
+ # Simple check if installation sections differ significantly
948
+ if [ -n "$MAIN_INSTALL" ] && [ -n "$SUB_INSTALL" ]; then
949
+ if ! echo "$SUB_INSTALL" | grep -qF "$(echo "$MAIN_INSTALL" | head -1)"; then
950
+ echo "⚠️ INSTALLATION INCONSISTENCY:"
951
+ echo " $readme has different installation instructions"
952
+ echo " than main README.md"
953
+ echo ""
954
+ DOC_ISSUES+=("$readme installation instructions differ from main README")
955
+ fi
956
+ fi
957
+ fi
958
+ done
959
+ fi
960
+ fi
961
+
962
+ # Verify CHANGELOG.md is up to date
963
+ if [ -f "$CHANGELOG_FILE" ]; then
964
+ if ! grep -q "## \[${NEW_VERSION}\]" "$CHANGELOG_FILE" 2>/dev/null; then
965
+ echo "❌ CHANGELOG MISSING NEW VERSION:"
966
+ echo " $CHANGELOG_FILE does not contain entry for $NEW_VERSION"
967
+ echo " This should have been added in Step 5"
968
+ echo ""
969
+ DOC_ISSUES+=("CHANGELOG missing $NEW_VERSION entry")
970
+ else
971
+ echo "✓ CHANGELOG contains $NEW_VERSION entry"
972
+ fi
973
+
974
+ # Check if changelog has link reference for new version
975
+ if ! grep -q "\[${NEW_VERSION}\].*http" "$CHANGELOG_FILE" 2>/dev/null; then
976
+ echo "⚠️ CHANGELOG LINK MISSING:"
977
+ echo " $CHANGELOG_FILE missing link reference for $NEW_VERSION"
978
+ echo " Add: [${NEW_VERSION}]: https://github.com/.../releases/tag/v${NEW_VERSION}"
979
+ echo ""
980
+ DOC_ISSUES+=("CHANGELOG missing link reference for $NEW_VERSION")
981
+ fi
982
+ fi
983
+
984
+ # Check for docs/ or documentation/ directories
985
+ for docs_dir in "docs" "documentation" ".docs"; do
986
+ if [ -d "$docs_dir" ]; then
987
+ echo "Checking $docs_dir/ for version references..."
988
+
989
+ # Look for markdown files with old version
990
+ OLD_VERSION_DOCS=$(grep -rl "$CURRENT_VERSION" "$docs_dir" 2>/dev/null | grep -E "\.(md|markdown|txt)$" || true)
991
+
992
+ if [ -n "$OLD_VERSION_DOCS" ]; then
993
+ echo "⚠️ DOCUMENTATION VERSION REFERENCES:"
994
+ echo "$OLD_VERSION_DOCS" | while read -r doc_file; do
995
+ echo " - $doc_file"
996
+ done
997
+ echo ""
998
+ DOC_ISSUES+=("Documentation files in $docs_dir/ have old version references")
999
+ fi
1000
+ fi
1001
+ done
1002
+
1003
+ # Summary of documentation issues
1004
+ echo ""
1005
+ if [ ${#DOC_ISSUES[@]} -eq 0 ]; then
1006
+ echo "✅ All documentation checks passed"
1007
+ else
1008
+ echo "⚠️ DOCUMENTATION ISSUES FOUND (${#DOC_ISSUES[@]}):"
1009
+ for issue in "${DOC_ISSUES[@]}"; do
1010
+ echo " - $issue"
1011
+ done
1012
+ echo ""
1013
+ echo "These issues should be addressed before announcing the release."
1014
+ echo "Run a search-and-replace for version references:"
1015
+ echo " find . -type f -name '*.md' -exec sed -i 's/$CURRENT_VERSION/$NEW_VERSION/g' {} +"
1016
+ echo ""
1017
+ fi
1018
+ ```
1019
+
1020
+ ## Step 15: Final Summary
1021
+
1022
+ Display release summary to console:
766
1023
 
767
1024
  ```bash
768
1025
  echo "========================================="
@@ -773,15 +1030,22 @@ echo "📊 RELEASE SUMMARY:"
773
1030
  echo "- Old version: $CURRENT_VERSION"
774
1031
  echo "- New version: $NEW_VERSION"
775
1032
  echo "- Project type: $PROJECT_TYPE"
776
- echo "- Commits included: $(git rev-list --count $COMMIT_RANGE)"
1033
+ echo "- Commits included: $(git rev-list --count $COMMIT_RANGE 2>/dev/null || echo "N/A")"
777
1034
  echo "- Tag: $TAG_NAME"
1035
+ echo "- Release notes: .docs/releases/RELEASE_NOTES_v${NEW_VERSION}.md"
778
1036
  echo ""
779
1037
 
780
1038
  if [ -n "$PUBLISH_CMD" ] && [ "$PUBLISH_CMD" != "echo"* ]; then
781
1039
  echo "📦 PUBLISHED TO:"
782
1040
  case "$PROJECT_TYPE" in
783
- nodejs) echo "- npm: https://www.npmjs.com/package/<package-name>" ;;
784
- rust) echo "- crates.io: https://crates.io/crates/<crate-name>" ;;
1041
+ nodejs)
1042
+ PACKAGE_NAME=$(command -v jq >/dev/null && jq -r '.name' package.json 2>/dev/null || echo "package")
1043
+ echo "- npm: https://www.npmjs.com/package/${PACKAGE_NAME}"
1044
+ ;;
1045
+ rust)
1046
+ CRATE_NAME=$(grep '^name = ' Cargo.toml | head -1 | sed 's/name = "\(.*\)"/\1/')
1047
+ echo "- crates.io: https://crates.io/crates/${CRATE_NAME}"
1048
+ ;;
785
1049
  python) echo "- PyPI: https://pypi.org/project/<package-name>" ;;
786
1050
  ruby) echo "- RubyGems: https://rubygems.org/gems/<gem-name>" ;;
787
1051
  php) echo "- Packagist: https://packagist.org/packages/<vendor>/<package>" ;;
@@ -790,20 +1054,27 @@ if [ -n "$PUBLISH_CMD" ] && [ "$PUBLISH_CMD" != "echo"* ]; then
790
1054
  echo ""
791
1055
  fi
792
1056
 
793
- if command -v gh >/dev/null && git remote get-url origin | grep -q "github.com"; then
1057
+ if command -v gh >/dev/null && git remote get-url origin 2>/dev/null | grep -q "github.com"; then
794
1058
  REPO_URL=$(git remote get-url origin | sed 's/\.git$//')
795
1059
  echo "🔗 LINKS:"
796
1060
  echo "- Release: $REPO_URL/releases/tag/$TAG_NAME"
797
1061
  echo "- Commits: $REPO_URL/compare/$LAST_TAG...$TAG_NAME"
798
1062
  echo "- Changelog: $REPO_URL/blob/main/$CHANGELOG_FILE"
1063
+ echo "- Release Notes: $REPO_URL/blob/main/.docs/releases/RELEASE_NOTES_v${NEW_VERSION}.md"
799
1064
  fi
800
1065
 
801
1066
  echo ""
802
1067
  echo "✅ NEXT STEPS:"
803
1068
  echo "1. Verify package appears in registry (may take a few minutes)"
804
1069
  echo "2. Test installation in a fresh environment"
805
- echo "3. Announce release to users/team"
806
- echo "4. Update documentation if needed"
1070
+ if [ ${#DOC_ISSUES[@]} -gt 0 ]; then
1071
+ echo "3. ⚠️ Address documentation issues (${#DOC_ISSUES[@]} found)"
1072
+ echo "4. Announce release to users/team"
1073
+ echo "5. Review release notes: .docs/releases/RELEASE_NOTES_v${NEW_VERSION}.md"
1074
+ else
1075
+ echo "3. Announce release to users/team"
1076
+ echo "4. Review release notes: .docs/releases/RELEASE_NOTES_v${NEW_VERSION}.md"
1077
+ fi
807
1078
  echo ""
808
1079
  ```
809
1080
 
@@ -858,5 +1129,9 @@ Before declaring release complete:
858
1129
  - [ ] Tag created and pushed
859
1130
  - [ ] Package published (if applicable)
860
1131
  - [ ] Platform release created (if applicable)
1132
+ - [ ] Release notes saved to `.docs/releases/RELEASE_NOTES_v<version>.md`
1133
+ - [ ] Documentation alignment verified (ROADMAP, READMEs, docs/)
1134
+ - [ ] Version references updated across all documentation
1135
+ - [ ] No installation instruction inconsistencies in subpackages
861
1136
 
862
1137
  This ensures every release is professional, consistent, and safe across any programming language or ecosystem.
@@ -70,24 +70,46 @@ else
70
70
  INCLUDE_DB_AUDIT=false
71
71
  fi
72
72
  echo ""
73
+
74
+ # Set up audit directory structure
75
+ TIMESTAMP=$(date +%Y-%m-%d_%H%M)
76
+ AUDIT_BASE_DIR=".docs/audits/${CURRENT_BRANCH}"
77
+ mkdir -p "$AUDIT_BASE_DIR"
78
+
79
+ echo "📁 Audit reports will be saved to: $AUDIT_BASE_DIR"
80
+ echo ""
73
81
  ```
74
82
 
75
83
  ### Step 3: Launch Specialized Sub-Agents in Parallel
76
84
 
77
- Launch these sub-agents in parallel based on change detection:
85
+ Launch these sub-agents in parallel based on change detection.
86
+
87
+ **IMPORTANT**: Pass the following variables to each sub-agent:
88
+ - `CURRENT_BRANCH`: The branch being reviewed
89
+ - `AUDIT_BASE_DIR`: Base directory for audit reports (`.docs/audits/${CURRENT_BRANCH}`)
90
+ - `TIMESTAMP`: Current timestamp for report filenames
91
+
92
+ Each sub-agent should save its report to:
93
+ ```
94
+ ${AUDIT_BASE_DIR}/<audit-type>-report.${TIMESTAMP}.md
95
+ ```
96
+
97
+ **Example paths**:
98
+ - `.docs/audits/feature-auth/security-report.2025-10-18_1430.md`
99
+ - `.docs/audits/feature-auth/performance-report.2025-10-18_1430.md`
78
100
 
79
101
  **Core Audits (Always Run)**:
80
- 1. audit-security sub-agent
81
- 2. audit-performance sub-agent
82
- 3. audit-architecture sub-agent
83
- 4. audit-tests sub-agent
84
- 5. audit-complexity sub-agent
85
- 6. audit-dependencies sub-agent
86
- 7. audit-documentation sub-agent
102
+ 1. audit-security sub-agent → `${AUDIT_BASE_DIR}/security-report.${TIMESTAMP}.md`
103
+ 2. audit-performance sub-agent → `${AUDIT_BASE_DIR}/performance-report.${TIMESTAMP}.md`
104
+ 3. audit-architecture sub-agent → `${AUDIT_BASE_DIR}/architecture-report.${TIMESTAMP}.md`
105
+ 4. audit-tests sub-agent → `${AUDIT_BASE_DIR}/tests-report.${TIMESTAMP}.md`
106
+ 5. audit-complexity sub-agent → `${AUDIT_BASE_DIR}/complexity-report.${TIMESTAMP}.md`
107
+ 6. audit-dependencies sub-agent → `${AUDIT_BASE_DIR}/dependencies-report.${TIMESTAMP}.md`
108
+ 7. audit-documentation sub-agent → `${AUDIT_BASE_DIR}/documentation-report.${TIMESTAMP}.md`
87
109
 
88
110
  **Conditional Audits** (automatically detect and skip if not applicable):
89
- 8. audit-typescript sub-agent (only if .ts/.tsx files changed or tsconfig.json exists)
90
- 9. audit-database sub-agent (only if database changes detected)
111
+ 8. audit-typescript sub-agent `${AUDIT_BASE_DIR}/typescript-report.${TIMESTAMP}.md`
112
+ 9. audit-database sub-agent `${AUDIT_BASE_DIR}/database-report.${TIMESTAMP}.md`
91
113
 
92
114
  ### Step 4: Synthesize Comprehensive Review
93
115
 
@@ -100,7 +122,13 @@ After all sub-agents complete their analysis:
100
122
 
101
123
  ### Step 5: Save Comprehensive Review Document
102
124
 
103
- Create a detailed review document at `.docs/reviews/branch-{BRANCH_NAME}-{YYYY-MM-DD_HHMM}.md`:
125
+ Create a detailed review document at `${AUDIT_BASE_DIR}/comprehensive-review.${TIMESTAMP}.md`:
126
+
127
+ ```bash
128
+ REVIEW_FILE="${AUDIT_BASE_DIR}/comprehensive-review.${TIMESTAMP}.md"
129
+ ```
130
+
131
+ **File structure**:
104
132
 
105
133
  ```markdown
106
134
  # Branch Review - {BRANCH_NAME}
@@ -333,11 +361,22 @@ Give the developer a clear, actionable summary:
333
361
  - {Easy fix 1} ({estimated time})
334
362
  - {Easy fix 2} ({estimated time})
335
363
 
336
- 📄 Full review: .docs/reviews/branch-{branch}-{timestamp}.md
364
+ 📄 Full review: ${AUDIT_BASE_DIR}/comprehensive-review.${TIMESTAMP}.md
365
+
366
+ 📁 Individual audit reports:
367
+ ${AUDIT_BASE_DIR}/security-report.${TIMESTAMP}.md
368
+ ${AUDIT_BASE_DIR}/performance-report.${TIMESTAMP}.md
369
+ ${AUDIT_BASE_DIR}/architecture-report.${TIMESTAMP}.md
370
+ ${AUDIT_BASE_DIR}/tests-report.${TIMESTAMP}.md
371
+ ${AUDIT_BASE_DIR}/complexity-report.${TIMESTAMP}.md
372
+ ${AUDIT_BASE_DIR}/dependencies-report.${TIMESTAMP}.md
373
+ ${AUDIT_BASE_DIR}/documentation-report.${TIMESTAMP}.md
374
+ (+ typescript-report.${TIMESTAMP}.md if applicable)
375
+ (+ database-report.${TIMESTAMP}.md if applicable)
337
376
 
338
377
  🔄 NEXT STEPS:
339
378
  1. Address blocking issues above
340
- 2. Run `/pre-commit` after fixes to verify
379
+ 2. Run `/code-review` after fixes to verify
341
380
  3. Create PR using this review as reference
342
381
  4. Share review with team for human review focus
343
382
  ```
@@ -10,106 +10,74 @@ INPUT=$(cat)
10
10
  if command -v jq &> /dev/null; then
11
11
  MODEL=$(echo "$INPUT" | jq -r '.model.display_name // .model.id // "claude"' 2>/dev/null)
12
12
  CWD=$(echo "$INPUT" | jq -r '.cwd // "~"' 2>/dev/null)
13
- TOTAL_COST=$(echo "$INPUT" | jq -r '.cost.total_cost_usd // 0' 2>/dev/null)
14
- LINES_ADDED=$(echo "$INPUT" | jq -r '.cost.total_lines_added // 0' 2>/dev/null)
15
- LINES_REMOVED=$(echo "$INPUT" | jq -r '.cost.total_lines_removed // 0' 2>/dev/null)
16
- TOTAL_DURATION_MS=$(echo "$INPUT" | jq -r '.cost.total_duration_ms // 0' 2>/dev/null)
17
- API_DURATION_MS=$(echo "$INPUT" | jq -r '.cost.total_api_duration_ms // 0' 2>/dev/null)
18
13
  EXCEEDS_200K=$(echo "$INPUT" | jq -r '.exceeds_200k_tokens // false' 2>/dev/null)
19
- VERSION=$(echo "$INPUT" | jq -r '.version // ""' 2>/dev/null)
20
- OUTPUT_STYLE=$(echo "$INPUT" | jq -r '.output_style.name // ""' 2>/dev/null)
21
14
  else
22
15
  MODEL="claude"
23
16
  CWD=$(pwd)
24
- TOTAL_COST="0.00"
25
- LINES_ADDED="0"
26
- LINES_REMOVED="0"
27
- TOTAL_DURATION_MS="0"
28
- API_DURATION_MS="0"
29
17
  EXCEEDS_200K="false"
30
- VERSION=""
31
- OUTPUT_STYLE=""
32
18
  fi
33
19
 
34
20
  # Get current directory name
35
21
  DIR_NAME=$(basename "$CWD")
36
22
 
37
- # Get git branch and last commit if in a git repo
23
+ # Get git branch if in a git repo
38
24
  GIT_BRANCH=$(cd "$CWD" 2>/dev/null && git branch --show-current 2>/dev/null || echo "")
39
25
  if [ -z "$GIT_BRANCH" ]; then
40
26
  GIT_INFO=""
41
27
  else
42
- # Get last commit message (first line, truncated to 50 chars)
43
- LAST_COMMIT_MSG=$(cd "$CWD" 2>/dev/null && git log -1 --pretty=format:"%s" 2>/dev/null | cut -c1-50 || echo "")
44
-
45
28
  # Check if there are uncommitted changes
46
29
  if [ -n "$(cd "$CWD" 2>/dev/null && git status --porcelain 2>/dev/null)" ]; then
47
- GIT_INFO=" / \033[1;33m$GIT_BRANCH*\033[0m"
30
+ GIT_INFO=" \033[1;33m$GIT_BRANCH*\033[0m"
48
31
  else
49
- GIT_INFO=" / \033[1;32m$GIT_BRANCH\033[0m"
50
- fi
51
-
52
- # Add commit message if available
53
- if [ -n "$LAST_COMMIT_MSG" ]; then
54
- GIT_INFO="$GIT_INFO \033[1;90m($LAST_COMMIT_MSG)\033[0m"
32
+ GIT_INFO=" \033[1;32m$GIT_BRANCH\033[0m"
55
33
  fi
56
34
  fi
57
35
 
58
- # Format cost with 2 decimal places
59
- COST_FORMATTED=$(printf "%.2f" "$TOTAL_COST" 2>/dev/null || echo "0.00")
60
-
61
- # Format session duration from milliseconds to human readable
62
- format_duration() {
63
- local ms=$1
64
- local seconds=$((ms / 1000))
65
- local minutes=$((seconds / 60))
66
- local hours=$((minutes / 60))
67
- local remaining_minutes=$((minutes % 60))
36
+ # Get system CPU and memory usage
37
+ get_cpu_usage() {
38
+ # Try multiple methods for cross-platform compatibility
39
+ if command -v top &> /dev/null; then
40
+ # Linux/macOS with top
41
+ top -bn1 2>/dev/null | grep -i "cpu" | head -1 | awk '{print $2}' | sed 's/%us,//' | sed 's/id,//' || echo "0"
42
+ elif command -v ps &> /dev/null; then
43
+ # Fallback: average CPU of all processes
44
+ ps -A -o %cpu | awk '{s+=$1} END {printf "%.0f", s}'
45
+ else
46
+ echo "0"
47
+ fi
48
+ }
68
49
 
69
- if [ "$hours" -gt 0 ]; then
70
- echo "${hours}h${remaining_minutes}m"
71
- elif [ "$minutes" -gt 0 ]; then
72
- echo "${minutes}m"
50
+ get_memory_usage() {
51
+ # Try multiple methods for cross-platform compatibility
52
+ if command -v free &> /dev/null; then
53
+ # Linux with free
54
+ free | grep Mem | awk '{printf "%.0f", ($3/$2)*100}'
55
+ elif command -v vm_stat &> /dev/null; then
56
+ # macOS with vm_stat
57
+ vm_stat | awk '/Pages active/ {active=$3} /Pages wired/ {wired=$4} /Pages free/ {free=$3} END {printf "%.0f", ((active+wired)/(active+wired+free))*100}' | sed 's/\.//'
73
58
  else
74
- echo "${seconds}s"
59
+ echo "0"
75
60
  fi
76
61
  }
77
62
 
78
- SESSION_DURATION=$(format_duration "$TOTAL_DURATION_MS")
79
- API_DURATION=$(format_duration "$API_DURATION_MS")
63
+ CPU_USAGE=$(get_cpu_usage)
64
+ MEMORY_USAGE=$(get_memory_usage)
80
65
 
81
- # Calculate API efficiency percentage
82
- if [ "$TOTAL_DURATION_MS" -gt 0 ]; then
83
- API_EFFICIENCY=$(echo "$API_DURATION_MS $TOTAL_DURATION_MS" | awk '{printf "%.0f", ($1/$2)*100}')
84
- else
85
- API_EFFICIENCY="0"
86
- fi
87
-
88
- # Build status line with colors - show components conditionally
66
+ # Build status line with colors
89
67
  STATUS_LINE="\033[1;34m$DIR_NAME\033[0m$GIT_INFO"
90
68
 
91
- # Add session duration if meaningful
92
- # if [ "$TOTAL_DURATION_MS" -gt 60000 ]; then # > 1 minute
93
- # STATUS_LINE="$STATUS_LINE \033[1;33m$SESSION_DURATION\033[0m"
94
- # fi
69
+ # Add model name
70
+ STATUS_LINE="$STATUS_LINE \033[1;36m$MODEL\033[0m"
95
71
 
96
- # Add API efficiency if session is long enough and efficiency is notable
97
- if [ "$TOTAL_DURATION_MS" -gt 300000 ] && [ "$API_EFFICIENCY" -gt 10 ]; then # > 5 min and >10% API time
98
- STATUS_LINE="$STATUS_LINE \033[1;91mapi:${API_EFFICIENCY}%\033[0m"
99
- fi
72
+ # Add CPU usage
73
+ STATUS_LINE="$STATUS_LINE \033[1;35mcpu:${CPU_USAGE}%\033[0m"
100
74
 
101
- # Add large context warning
102
- if [ "$EXCEEDS_200K" = "true" ]; then
103
- STATUS_LINE="$STATUS_LINE \033[1;93m⚠️large\033[0m"
104
- fi
75
+ # Add memory usage
76
+ STATUS_LINE="$STATUS_LINE \033[1;33mmem:${MEMORY_USAGE}%\033[0m"
105
77
 
106
- # Add cost if non-zero and meaningful (> $0.01)
107
- COST_CENTS=$(echo "$TOTAL_COST" | awk '{printf "%.0f", $1*100}')
108
- if [ "$COST_CENTS" -gt 1 ]; then
109
- STATUS_LINE="$STATUS_LINE \033[1;32m\$$COST_FORMATTED\033[0m"
78
+ # Add large context warning if needed
79
+ if [ "$EXCEEDS_200K" = "true" ]; then
80
+ STATUS_LINE="$STATUS_LINE \033[1;91m⚠️large\033[0m"
110
81
  fi
111
82
 
112
- # Add model at the end
113
- # STATUS_LINE="$STATUS_LINE \033[1;36m$MODEL\033[0m"
114
-
115
83
  echo -e "$STATUS_LINE"