scribe-cli 0.5.1

Advanced code analysis and repository exploration library with AI-powered insights
Documentation
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
82
83
84
85
86
87
88
89
90
91
92
93
94
95
96
97
98
99
100
101
102
103
104
105
106
107
108
109
110
111
112
113
114
115
116
117
118
119
120
121
122
123
124
125
126
127
128
129
130
131
132
133
134
135
136
137
138
139
140
141
142
143
144
145
146
147
148
149
150
151
152
153
154
155
156
157
158
159
160
161
162
163
164
165
166
167
168
169
170
171
172
173
174
175
176
177
178
179
180
181
182
183
184
185
186
187
188
189
190
191
192
193
194
195
196
197
198
199
200
201
202
203
204
205
206
207
208
209
210
211
212
213
214
215
216
217
218
219
220
221
222
223
224
225
226
227
228
229
230
231
232
233
234
235
236
237
238
239
240
241
242
243
244
245
246
247
248
249
250
251
252
253
254
255
256
257
258
259
260
261
262
263
264
265
266
267
268
269
270
271
272
273
274
275
276
277
278
279
280
281
282
283
284
285
286
287
288
289
290
291
292
293
294
295
296
297
298
299
300
301
302
303
304
305
306
307
308
309
310
311
312
313
314
315
316
317
318
319
320
321
322
323
324
325
326
327
328
329
330
331
332
333
334
335
336
337
338
339
340
341
342
343
344
345
346
347
348
349
350
351
352
353
354
355
356
357
358
359
360
361
362
363
364
365
366
367
368
369
370
371
372
373
374
375
376
377
378
379
380
381
382
383
384
385
386
387
388
389
390
391
392
393
394
395
396
397
398
399
400
401
402
403
404
405
406
407
408
409
410
411
412
413
414
415
416
417
418
419
420
name: Scribe CI/CD Pipeline

on:
  push:
    branches: [main, master, develop]
  pull_request:
    branches: [main, master]
  schedule:
    # Run nightly builds to catch drift
    - cron: '0 2 * * *'

env:
  CARGO_TERM_COLOR: always
  RUST_BACKTRACE: 1

jobs:
  # ================================
  # RUST CORE TESTING
  # ================================
  rust-core:
    name: Rust Core - Build & Test
    runs-on: ubuntu-latest
    timeout-minutes: 30

    steps:
      - name: Checkout code
        uses: actions/checkout@v4

      - name: Install Rust toolchain
        uses: dtolnay/rust-toolchain@stable
        with:
          components: rustfmt, clippy

      - name: Cache Rust dependencies
        uses: Swatinem/rust-cache@v2

      - name: Check Rust formatting
        run: cargo fmt --all -- --check

      - name: Run Clippy lints
        run: cargo clippy --lib --bins --tests --all-features -- -D warnings

      - name: Build all workspace crates
        run: cargo build --workspace --all-features

      - name: Run Rust unit tests
        run: cargo test --workspace --all-features

      - name: Run Rust integration tests
        run: |
          cargo test --workspace --all-features --test '*'

      - name: Build scribe binaries
        run: |
          cargo build -p scribe-analyzer --bin scribe --release
          cargo build -p scribe-webservice --bin scribe-web --release

      - name: Test CLI functionality
        run: |
          ./target/release/scribe --version
          ./target/release/scribe --help
          ./target/release/scribe-web --version
          ./target/release/scribe-web --help

      - name: Upload Rust artifacts
        uses: actions/upload-artifact@v4
        with:
          name: rust-artifacts
          path: |
            target/release/scribe
            target/release/scribe-web
          retention-days: 7

  # ================================
  # E2E TEST INFRASTRUCTURE
  # ================================
  e2e-tests:
    name: E2E Tests - Library & CLI
    runs-on: ubuntu-latest
    needs: rust-core
    timeout-minutes: 45

    steps:
      - name: Checkout code
        uses: actions/checkout@v4

      - name: Install Rust toolchain
        uses: dtolnay/rust-toolchain@stable

      - name: Install Bun
        uses: oven-sh/setup-bun@v1
        with:
          bun-version: latest

      - name: Cache Rust dependencies
        uses: Swatinem/rust-cache@v2
        with:
          workspaces: .

      - name: Download Rust artifacts
        uses: actions/download-artifact@v4
        with:
          name: rust-artifacts
          path: target/release/

      - name: Make binaries executable
        run: |
          chmod +x target/release/scribe
          chmod +x target/release/scribe-web

      - name: Setup e2e test environment
        run: |
          cd tests
          make check-deps
          make deps

      - name: Run library unit tests
        run: |
          cd tests
          make test-lib

      - name: Build Scribe for e2e tests
        run: |
          cd tests
          make build

      - name: Run CLI parameter tests
        run: |
          cd tests
          make test-cli

      - name: Upload e2e test results
        if: always()
        uses: actions/upload-artifact@v4
        with:
          name: e2e-test-results
          path: |
            tests/artifacts/
            tests/logs/
          retention-days: 7

  # ================================
  # WEB UI E2E TESTS (with Playwright)
  # ================================
  webui-e2e:
    name: Web UI E2E Tests
    runs-on: ubuntu-latest
    needs: rust-core
    timeout-minutes: 60

    steps:
      - name: Checkout code
        uses: actions/checkout@v4

      - name: Install Rust toolchain
        uses: dtolnay/rust-toolchain@stable

      - name: Install Bun
        uses: oven-sh/setup-bun@v1
        with:
          bun-version: latest

      - name: Cache Rust dependencies
        uses: Swatinem/rust-cache@v2
        with:
          workspaces: .

      - name: Download Rust artifacts
        uses: actions/download-artifact@v4
        with:
          name: rust-artifacts
          path: target/release/

      - name: Make binaries executable
        run: |
          chmod +x target/release/scribe
          chmod +x target/release/scribe-web

      - name: Setup test environment
        run: |
          cd tests
          make check-deps
          make deps

      - name: Install Playwright browsers
        run: |
          cd tests
          bun run playwright:install

      - name: Build Scribe for web UI tests
        run: |
          cd tests
          make build

      - name: Run Web UI tests
        run: |
          cd tests
          make test-webui
        env:
          CI: true

      - name: Upload Playwright report
        if: always()
        uses: actions/upload-artifact@v4
        with:
          name: playwright-report
          path: |
            tests/playwright-report/
            tests/test-results/
          retention-days: 7


  # ================================
  # INTEGRATION & SMOKE TESTS
  # ================================
  integration:
    name: Integration & Smoke Tests
    runs-on: ubuntu-latest
    needs: [rust-core, e2e-tests]
    timeout-minutes: 30

    steps:
      - name: Checkout code
        uses: actions/checkout@v4

      - name: Install Rust toolchain
        uses: dtolnay/rust-toolchain@stable

      - name: Install Bun
        uses: oven-sh/setup-bun@v1

      - name: Cache Rust dependencies
        uses: Swatinem/rust-cache@v2
        with:
          workspaces: .

      - name: Download Rust artifacts
        uses: actions/download-artifact@v4
        with:
          name: rust-artifacts
          path: target/release/

      - name: Make binaries executable
        run: |
          chmod +x target/release/scribe
          chmod +x target/release/scribe-web

      - name: Smoke test - Scribe on itself
        run: |
          # Test Scribe analyzing its own codebase
          ./target/release/scribe-web . --token-budget 10000 --no-browser --port 9999 &
          SERVER_PID=$!
          
          # Wait for server to start
          sleep 10
          
          # Check if server is responding
          curl -f http://localhost:9999/ || echo "Server not responding"
          
          # Clean shutdown
          kill $SERVER_PID || true
          wait $SERVER_PID 2>/dev/null || true

      - name: Test different CLI configurations
        run: |
          # Test various CLI parameter combinations
          ./target/release/scribe-web . --token-budget 5000 --max-file-size 100000 --no-exclude-tests --no-browser --port 9998 &
          SERVER_PID=$!
          sleep 5
          kill $SERVER_PID || true
          wait $SERVER_PID 2>/dev/null || true

      - name: Performance baseline test
        run: |
          # Quick performance test
          time ./target/release/scribe-web . --token-budget 1000 --no-browser --port 9997 &
          SERVER_PID=$!
          sleep 3
          kill $SERVER_PID || true
          wait $SERVER_PID 2>/dev/null || true

  # ================================
  # SECURITY & QUALITY CHECKS
  # ================================
  security:
    name: Security & Quality
    runs-on: ubuntu-latest
    timeout-minutes: 20

    steps:
      - name: Checkout code
        uses: actions/checkout@v4

      - name: Install Rust toolchain
        uses: dtolnay/rust-toolchain@stable

      - name: Cache Rust dependencies
        uses: Swatinem/rust-cache@v2
        with:
          workspaces: .

      - name: Run cargo audit
        run: |
          cargo install cargo-audit
          cargo audit

      - name: Run cargo deny
        run: |
          cargo install cargo-deny
          cargo deny check

      - name: Check for common security issues
        run: |
          # Check for hardcoded secrets (basic check)
          if grep -r "password\|secret\|key\|token" --include="*.rs" . | grep -v "// " | grep -v "test"; then
            echo "Warning: Potential hardcoded secrets found"
          fi

      - name: Validate dependencies
        run: |
          cargo tree --duplicates

  # ================================
  # RELEASE & DOCUMENTATION
  # ================================
  release-check:
    name: Release Readiness
    runs-on: ubuntu-latest
    needs: [rust-core, e2e-tests, webui-e2e, integration, security]
    if: github.ref == 'refs/heads/main' || github.ref == 'refs/heads/master'
    timeout-minutes: 15

    steps:
      - name: Checkout code
        uses: actions/checkout@v4

      - name: Install Rust toolchain
        uses: dtolnay/rust-toolchain@stable

      - name: Check release build
        run: |
          cargo build --release --workspace

      - name: Validate documentation
        run: |
          cargo doc --workspace --all-features --no-deps

      - name: Check version consistency
        run: |
          # Ensure all workspace crates have the same version
          EXPECTED_VERSION=$(grep '^version' Cargo.toml | head -1 | cut -d'"' -f2)
          echo "Expected version: $EXPECTED_VERSION"
          
          for crate in scribe-*; do
            if [ -f "$crate/Cargo.toml" ]; then
              CRATE_VERSION=$(grep '^version.workspace = true' "$crate/Cargo.toml" || grep '^version = ' "$crate/Cargo.toml" | cut -d'"' -f2)
              if [ -n "$CRATE_VERSION" ] && [ "$CRATE_VERSION" != "true" ] && [ "$CRATE_VERSION" != "$EXPECTED_VERSION" ]; then
                echo "Version mismatch in $crate: $CRATE_VERSION"
                exit 1
              fi
            fi
          done

      - name: Generate release summary
        run: |
          echo "# Scribe Release Summary" > release-summary.md
          echo "" >> release-summary.md
          echo "**Version:** $(grep '^version' Cargo.toml | head -1 | cut -d'"' -f2)" >> release-summary.md
          echo "**Commit:** ${{ github.sha }}" >> release-summary.md
          echo "**Date:** $(date -Iseconds)" >> release-summary.md
          echo "" >> release-summary.md
          echo "## Test Results" >> release-summary.md
          echo "- ✅ Rust core tests passed" >> release-summary.md
          echo "- ✅ E2E tests passed" >> release-summary.md
          echo "- ✅ Web UI tests passed" >> release-summary.md
          echo "- ✅ Integration tests passed" >> release-summary.md
          echo "- ✅ Security checks passed" >> release-summary.md

      - name: Upload release artifacts
        uses: actions/upload-artifact@v4
        with:
          name: release-summary
          path: release-summary.md
          retention-days: 30

  # ================================
  # FINAL STATUS SUMMARY
  # ================================
  status:
    name: CI Status Summary
    runs-on: ubuntu-latest
    needs: [rust-core, e2e-tests, webui-e2e, integration, security]
    if: always()

    steps:
      - name: Check overall status
        run: |
          echo "==================================="
          echo "Scribe CI/CD Pipeline Summary"
          echo "==================================="
          echo "Rust Core: ${{ needs.rust-core.result }}"
          echo "E2E Tests: ${{ needs.e2e-tests.result }}"
          echo "Web UI Tests: ${{ needs.webui-e2e.result }}"
          echo "Integration: ${{ needs.integration.result }}"
          echo "Security: ${{ needs.security.result }}"
          echo "==================================="
          
          # Determine overall status
          if [[ "${{ needs.rust-core.result }}" == "success" && 
                "${{ needs.e2e-tests.result }}" == "success" && 
                "${{ needs.integration.result }}" == "success" && 
                "${{ needs.security.result }}" == "success" ]]; then
            echo "🎉 Overall Status: SUCCESS"
            echo "All critical tests passed!"
            exit 0
          else
            echo "❌ Overall Status: FAILURE"
            echo "Some tests failed - review the logs above"
            exit 1
          fi