-
Notifications
You must be signed in to change notification settings - Fork 449
7659 lines (7534 loc) · 373 KB
/
Copy pathcli-version-checker.lock.yml
File metadata and controls
7659 lines (7534 loc) · 373 KB
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
421
422
423
424
425
426
427
428
429
430
431
432
433
434
435
436
437
438
439
440
441
442
443
444
445
446
447
448
449
450
451
452
453
454
455
456
457
458
459
460
461
462
463
464
465
466
467
468
469
470
471
472
473
474
475
476
477
478
479
480
481
482
483
484
485
486
487
488
489
490
491
492
493
494
495
496
497
498
499
500
501
502
503
504
505
506
507
508
509
510
511
512
513
514
515
516
517
518
519
520
521
522
523
524
525
526
527
528
529
530
531
532
533
534
535
536
537
538
539
540
541
542
543
544
545
546
547
548
549
550
551
552
553
554
555
556
557
558
559
560
561
562
563
564
565
566
567
568
569
570
571
572
573
574
575
576
577
578
579
580
581
582
583
584
585
586
587
588
589
590
591
592
593
594
595
596
597
598
599
600
601
602
603
604
605
606
607
608
609
610
611
612
613
614
615
616
617
618
619
620
621
622
623
624
625
626
627
628
629
630
631
632
633
634
635
636
637
638
639
640
641
642
643
644
645
646
647
648
649
650
651
652
653
654
655
656
657
658
659
660
661
662
663
664
665
666
667
668
669
670
671
672
673
674
675
676
677
678
679
680
681
682
683
684
685
686
687
688
689
690
691
692
693
694
695
696
697
698
699
700
701
702
703
704
705
706
707
708
709
710
711
712
713
714
715
716
717
718
719
720
721
722
723
724
725
726
727
728
729
730
731
732
733
734
735
736
737
738
739
740
741
742
743
744
745
746
747
748
749
750
751
752
753
754
755
756
757
758
759
760
761
762
763
764
765
766
767
768
769
770
771
772
773
774
775
776
777
778
779
780
781
782
783
784
785
786
787
788
789
790
791
792
793
794
795
796
797
798
799
800
801
802
803
804
805
806
807
808
809
810
811
812
813
814
815
816
817
818
819
820
821
822
823
824
825
826
827
828
829
830
831
832
833
834
835
836
837
838
839
840
841
842
843
844
845
846
847
848
849
850
851
852
853
854
855
856
857
858
859
860
861
862
863
864
865
866
867
868
869
870
871
872
873
874
875
876
877
878
879
880
881
882
883
884
885
886
887
888
889
890
891
892
893
894
895
896
897
898
899
900
901
902
903
904
905
906
907
908
909
910
911
912
913
914
915
916
917
918
919
920
921
922
923
924
925
926
927
928
929
930
931
932
933
934
935
936
937
938
939
940
941
942
943
944
945
946
947
948
949
950
951
952
953
954
955
956
957
958
959
960
961
962
963
964
965
966
967
968
969
970
971
972
973
974
975
976
977
978
979
980
981
982
983
984
985
986
987
988
989
990
991
992
993
994
995
996
997
998
999
1000
#
# ___ _ _
# / _ \ | | (_)
# | |_| | __ _ ___ _ __ | |_ _ ___
# | _ |/ _` |/ _ \ '_ \| __| |/ __|
# | | | | (_| | __/ | | | |_| | (__
# \_| |_/\__, |\___|_| |_|\__|_|\___|
# __/ |
# _ _ |___/
# | | | | / _| |
# | | | | ___ _ __ _ __| |_| | _____ ____
# | |/\| |/ _ \ '__| |/ /| _| |/ _ \ \ /\ / / ___|
# \ /\ / (_) | | | | ( | | | | (_) \ V V /\__ \
# \/ \/ \___/|_| |_|\_\|_| |_|\___/ \_/\_/ |___/
#
# This file was automatically generated by gh-aw. DO NOT EDIT.
#
# To update this file, edit the corresponding .md file and run:
# gh aw compile
# For more information: https://github.com/githubnext/gh-aw/blob/main/.github/aw/github-agentic-workflows.md
#
#
# Monitors and updates agentic CLI tools (Claude Code, GitHub Copilot CLI, OpenAI Codex, GitHub MCP Server, Playwright MCP, Playwright Browser) for new versions
#
# Original Frontmatter:
# ```yaml
# description: Monitors and updates agentic CLI tools (Claude Code, GitHub Copilot CLI, OpenAI Codex, GitHub MCP Server, Playwright MCP, Playwright Browser) for new versions
# on:
# schedule:
# - cron: daily at 15:00
# workflow_dispatch:
# permissions:
# contents: read
# pull-requests: read
# issues: read
# strict: false
# engine: claude
# network:
# allowed: [defaults, node, "api.github.com", "ghcr.io"]
# imports:
# - shared/jqschema.md
# tools:
# web-fetch:
# cache-memory: true
# bash:
# - "*"
# edit:
# safe-outputs:
# create-issue:
# title-prefix: "[ca] "
# labels: [automation, dependencies]
# timeout-minutes: 45
# ```
#
# Resolved workflow manifest:
# Imports:
# - shared/jqschema.md
#
# Job Dependency Graph:
# ```mermaid
# graph LR
# activation["activation"]
# agent["agent"]
# conclusion["conclusion"]
# create_issue["create_issue"]
# detection["detection"]
# update_cache_memory["update_cache_memory"]
# activation --> agent
# activation --> conclusion
# agent --> conclusion
# agent --> create_issue
# agent --> detection
# agent --> update_cache_memory
# create_issue --> conclusion
# detection --> conclusion
# detection --> create_issue
# detection --> update_cache_memory
# update_cache_memory --> conclusion
# ```
#
# Original Prompt:
# ```markdown
# ## jqschema - JSON Schema Discovery
#
# A utility script is available at `/tmp/gh-aw/jqschema.sh` to help you discover the structure of complex JSON responses.
#
# ### Purpose
#
# Generate a compact structural schema (keys + types) from JSON input. This is particularly useful when:
# - Analyzing tool outputs from GitHub search (search_code, search_issues, search_repositories)
# - Exploring API responses with large payloads
# - Understanding the structure of unfamiliar data without verbose output
# - Planning queries before fetching full data
#
# ### Usage
#
# ```bash
# # Analyze a file
# cat data.json | /tmp/gh-aw/jqschema.sh
#
# # Analyze command output
# echo '{"name": "test", "count": 42, "items": [{"id": 1}]}' | /tmp/gh-aw/jqschema.sh
#
# # Analyze GitHub search results
# gh api search/repositories?q=language:go | /tmp/gh-aw/jqschema.sh
# ```
#
# ### How It Works
#
# The script transforms JSON data by:
# 1. Replacing object values with their type names ("string", "number", "boolean", "null")
# 2. Reducing arrays to their first element's structure (or empty array if empty)
# 3. Recursively processing nested structures
# 4. Outputting compact (minified) JSON
#
# ### Example
#
# **Input:**
# ```json
# {
# "total_count": 1000,
# "items": [
# {"login": "user1", "id": 123, "verified": true},
# {"login": "user2", "id": 456, "verified": false}
# ]
# }
# ```
#
# **Output:**
# ```json
# {"total_count":"number","items":[{"login":"string","id":"number","verified":"boolean"}]}
# ```
#
# ### Best Practices
#
# **Use this script when:**
# - You need to understand the structure of tool outputs before requesting full data
# - GitHub search tools return large datasets (use `perPage: 1` and pipe through schema minifier first)
# - Exploring unfamiliar APIs or data structures
# - Planning data extraction strategies
#
# **Example workflow for GitHub search tools:**
# ```bash
# # Step 1: Get schema with minimal data (fetch just 1 result)
# # This helps understand the structure before requesting large datasets
# echo '{}' | gh api search/repositories -f q="language:go" -f per_page=1 | /tmp/gh-aw/jqschema.sh
#
# # Output shows the schema:
# # {"incomplete_results":"boolean","items":[{...}],"total_count":"number"}
#
# # Step 2: Review schema to understand available fields
#
# # Step 3: Request full data with confidence about structure
# # Now you know what fields are available and can query efficiently
# ```
#
# **Using with GitHub MCP tools:**
# When using tools like `search_code`, `search_issues`, or `search_repositories`, pipe the output through jqschema to discover available fields:
# ```bash
# # Save a minimal search result to a file
# gh api search/code -f q="jq in:file language:bash" -f per_page=1 > /tmp/sample.json
#
# # Generate schema to understand structure
# cat /tmp/sample.json | /tmp/gh-aw/jqschema.sh
#
# # Now you know which fields exist and can use them in your analysis
# ```
#
# # CLI Version Checker
#
# Monitor and update agentic CLI tools: Claude Code, GitHub Copilot CLI, OpenAI Codex, GitHub MCP Server, Playwright MCP, and Playwright Browser.
#
# **Repository**: ${{ github.repository }} | **Run**: ${{ github.run_id }}
#
# ## Process
#
# **EFFICIENCY FIRST**: Before starting:
# 1. Check cache-memory at `/tmp/gh-aw/cache-memory/` for previous version checks and help outputs
# 2. If cached versions exist and are recent (< 24h), verify if updates are needed before proceeding
# 3. If no version changes detected, exit early with success
#
# **CRITICAL**: If ANY version changes are detected, you MUST create an issue using safe-outputs.create-issue. Do not skip issue creation even for minor updates.
#
# For each CLI/MCP server:
# 1. Fetch latest version from NPM registry or GitHub releases (use npm view commands for package metadata)
# 2. Compare with current version in `./pkg/constants/constants.go`
# 3. If newer version exists, research changes and prepare update
#
# ### Version Sources
# - **Claude Code**: Use `npm view @anthropic-ai/claude-code version` (faster than web-fetch)
# - No public GitHub repository
# - **Copilot CLI**: Use `npm view @github/copilot version`
# - Repository: https://github.com/github/copilot-cli (may be private)
# - **Codex**: Use `npm view @openai/codex version`
# - Repository: https://github.com/openai/codex
# - Release Notes: https://github.com/openai/codex/releases
# - **GitHub MCP Server**: `https://api.github.com/repos/github/github-mcp-server/releases/latest`
# - Release Notes: https://github.com/github/github-mcp-server/releases
# - **Playwright MCP**: Use `npm view @playwright/mcp version`
# - Repository: https://github.com/microsoft/playwright
# - Package: https://www.npmjs.com/package/@playwright/mcp
# - **Playwright Browser**: `https://api.github.com/repos/microsoft/playwright/releases/latest`
# - Release Notes: https://github.com/microsoft/playwright/releases
# - Docker Image: `mcr.microsoft.com/playwright:v{VERSION}`
#
# **Optimization**: Fetch all versions in parallel using multiple npm view or WebFetch calls in a single turn.
#
# ### Research & Analysis
# For each update, analyze intermediate versions:
# - Categorize changes: Breaking, Features, Fixes, Security, Performance
# - Assess impact on gh-aw workflows
# - Document migration requirements
# - Assign risk level (Low/Medium/High)
#
# **GitHub Release Notes (when available)**:
# - **Codex**: Fetch release notes from https://github.com/openai/codex/releases/tag/rust-v{VERSION}
# - Parse the "Highlights" section for key changes
# - Parse the "PRs merged" or "Merged PRs" section for detailed changes
# - **CRITICAL**: Convert PR/issue references (e.g., `#6211`) to full URLs since they refer to external repositories (e.g., `https://github.com/openai/codex/pull/6211`)
# - **GitHub MCP Server**: Fetch release notes from https://github.com/github/github-mcp-server/releases/tag/v{VERSION}
# - Parse release body for changelog entries
# - **CRITICAL**: Convert PR/issue references (e.g., `#1105`) to full URLs since they refer to external repositories (e.g., `https://github.com/github/github-mcp-server/pull/1105`)
# - **Playwright Browser**: Fetch release notes from https://github.com/microsoft/playwright/releases/tag/v{VERSION}
# - Parse release body for changelog entries
# - **CRITICAL**: Convert PR/issue references to full URLs (e.g., `https://github.com/microsoft/playwright/pull/12345`)
# - **Copilot CLI**: Repository may be private, skip release notes if inaccessible
# - **Claude Code**: No public repository, rely on NPM metadata and CLI help output
# - **Playwright MCP**: Uses Playwright versioning, check NPM package metadata for changes
#
# **NPM Metadata Fallback**: When GitHub release notes are unavailable, use:
# - `npm view <package> --json` for package metadata
# - Compare CLI help outputs between versions
# - Check for version changelog in package description
#
# ### Tool Installation & Discovery
# **CACHE OPTIMIZATION**:
# - Before installing, check cache-memory for previous help outputs (main and subcommands)
# - Only install and run --help if version has changed
# - Store main help outputs in cache-memory at `/tmp/gh-aw/cache-memory/[tool]-[version]-help.txt`
# - Store subcommand help outputs at `/tmp/gh-aw/cache-memory/[tool]-[version]-[subcommand]-help.txt`
#
# For each CLI tool update:
# 1. Install the new version globally (skip if already installed from cache check):
# - Claude Code: `npm install -g @anthropic-ai/claude-code@<version>`
# - Copilot CLI: `npm install -g @github/copilot@<version>`
# - Codex: `npm install -g @openai/codex@<version>`
# - Playwright MCP: `npm install -g @playwright/mcp@<version>`
# 2. Invoke help to discover commands and flags (compare with cached output if available):
# - Run `claude-code --help`
# - Run `copilot --help` or `copilot help copilot`
# - Run `codex --help`
# - Run `npx @playwright/mcp@<version> --help` (if available)
# 3. **Explore subcommand help** for each tool (especially Copilot CLI):
# - Identify all available subcommands from main help output
# - For each subcommand, run its help command (e.g., `copilot help config`, `copilot help environment`, `copilot config --help`)
# - Store each subcommand help output in cache-memory at `/tmp/gh-aw/cache-memory/[tool]-[version]-[subcommand]-help.txt`
# - **Priority subcommands for Copilot CLI**: `config`, `environment` (explicitly requested)
# - Example commands:
# - `copilot help copilot`
# - `copilot help config` or `copilot config --help`
# - `copilot help environment` or `copilot environment --help`
# 4. Compare help output with previous version to identify:
# - New commands or subcommands
# - New command-line flags or options
# - Deprecated or removed features
# - Changed default behaviors
# - **NEW**: Changes in subcommand functionality or flags
# 5. Save all help outputs (main and subcommands) to cache-memory for future runs
#
# ### Update Process
# 1. Edit `./pkg/constants/constants.go` with new version(s)
# 2. Run `make recompile` to update workflows
# 3. Verify changes with `git status`
# 4. **REQUIRED**: Create issue via safe-outputs with detailed analysis (do NOT skip this step)
#
# ## Issue Format
# Include for each updated CLI:
# - **Version**: old → new (list intermediate versions if multiple)
# - **Release Timeline**: dates and intervals
# - **Changes**: Categorized as Breaking/Features/Fixes/Security/Performance
# - **Impact Assessment**: Risk level, affected features, migration notes
# - **Changelog Links**: Use plain URLs without backticks
# - **CLI Changes**: New commands, flags, or removed features discovered via help
# - **Subcommand Changes**: Changes in subcommand functionality or flags (especially `config` and `environment` for Copilot CLI)
# - **GitHub Release Notes**: Include highlights and PR summaries when available from GitHub releases
#
# **URL Formatting Rules**:
# - Use plain URLs without backticks around package names
# - **CORRECT**: https://www.npmjs.com/package/@github/copilot
# - **INCORRECT**: `https://www.npmjs.com/package/@github/copilot` (has backticks)
# - **INCORRECT**: https://www.npmjs.com/package/`@github/copilot` (package name wrapped in backticks)
#
# **Pull Request Link Formatting**:
# - **CRITICAL**: Always use full URLs for pull requests that refer to external repositories
# - **CORRECT**: https://github.com/openai/codex/pull/6211
# - **INCORRECT**: #6211 (relative reference only works for same repository)
# - When copying PR references from release notes, convert `#1234` to full URLs like `https://github.com/owner/repo/pull/1234`
#
# Template structure:
# ```
# # Update [CLI Name]
# - Previous: [version] → New: [version]
# - Timeline: [dates and frequency]
# - Breaking Changes: [list or "None"]
# - New Features: [list]
# - Bug Fixes: [list]
# - Security: [CVEs/patches or "None"]
# - CLI Discovery: [New commands/flags or "None detected"]
# - Subcommand Changes: [Changes in subcommands like config/environment or "None detected"]
# - Impact: Risk [Low/Medium/High], affects [features]
# - Migration: [Yes/No - details if yes]
#
# ## Release Highlights (from GitHub)
# [Include key highlights from GitHub release notes if available]
#
# ## Merged PRs (from GitHub)
# [List significant merged PRs from release notes if available]
#
# ## Subcommand Help Analysis
# [Document changes in subcommand help output, particularly for config and environment commands]
#
# ## Package Links
# - **NPM Package**: https://www.npmjs.com/package/package-name-here
# - **Repository**: [GitHub URL if available]
# - **Release Notes**: [GitHub releases URL if available]
# - **Specific Release**: [Direct link to version's release notes if available]
# ```
#
# ## Guidelines
# - Only update stable versions (no pre-releases)
# - Prioritize security updates
# - Document all intermediate versions
# - **USE NPM COMMANDS**: Use `npm view` instead of web-fetch for package metadata queries
# - **CHECK CACHE FIRST**: Before re-analyzing versions, check cache-memory for recent results
# - **PARALLEL FETCHING**: Fetch all versions in parallel using multiple npm/WebFetch calls in one turn
# - **EARLY EXIT**: If no version changes detected, save check timestamp to cache and exit successfully
# - **FETCH GITHUB RELEASE NOTES**: For tools with public GitHub repositories, fetch release notes to get detailed changelog information
# - Codex: Always fetch from https://github.com/openai/codex/releases
# - GitHub MCP Server: Always fetch from https://github.com/github/github-mcp-server/releases
# - Playwright Browser: Always fetch from https://github.com/microsoft/playwright/releases
# - Copilot CLI: Try to fetch, but may be inaccessible (private repo)
# - Playwright MCP: Check NPM metadata, uses Playwright versioning
# - **EXPLORE SUBCOMMANDS**: Install and test CLI tools to discover new features via `--help` and explore each subcommand
# - For Copilot CLI, explicitly check: `config`, `environment` and any other available subcommands
# - Use commands like `copilot help <subcommand>` or `<tool> <subcommand> --help`
# - Compare help output between old and new versions (both main help and subcommand help)
# - **SAVE TO CACHE**: Store help outputs (main and all subcommands) and version check results in cache-memory
# - Test with `make recompile` before creating PR
# - **DO NOT COMMIT** `*.lock.yml` or `pkg/workflow/js/*.js` files directly
#
# ## Common JSON Parsing Issues
#
# When using npm commands or other CLI tools, their output may include informational messages with Unicode symbols that break JSON parsing:
#
# **Problem Patterns**:
# - `Unexpected token 'ℹ', "ℹ Timeout "... is not valid JSON`
# - `Unexpected token '⚠', "⚠ pip pack"... is not valid JSON`
# - `Unexpected token '✓', "✓ Success"... is not valid JSON`
#
# **Solutions**:
#
# ### 1. Filter stderr (Recommended)
# Redirect stderr to suppress npm warnings/info:
# ```bash
# npm view @github/copilot version 2>/dev/null
# npm view @anthropic-ai/claude-code --json 2>/dev/null
# ```
#
# ### 2. Use grep to filter output
# Remove lines with Unicode symbols before parsing:
# ```bash
# npm view @github/copilot --json | grep -v "^[ℹ⚠✓]"
# ```
#
# ### 3. Use jq for reliable extraction
# Let jq handle malformed input:
# ```bash
# # Extract version field only, ignoring non-JSON lines
# npm view @github/copilot --json 2>/dev/null | jq -r '.version'
# ```
#
# ### 4. Check tool output before parsing
# Always validate JSON before attempting to parse:
# ```bash
# output=$(npm view package --json 2>/dev/null)
# if echo "$output" | jq empty 2>/dev/null; then
# # Valid JSON, safe to parse
# version=$(echo "$output" | jq -r '.version')
# else
# # Invalid JSON, handle error
# echo "Warning: npm output is not valid JSON"
# fi
# ```
#
# **Best Practice**: Combine stderr filtering with jq extraction for most reliable results:
# ```bash
# npm view @github/copilot --json 2>/dev/null | jq -r '.version'
# ```
#
# ## Error Handling
# - **SAVE PROGRESS**: Before exiting on errors, save current state to cache-memory
# - **RESUME ON RESTART**: Check cache-memory on startup to resume from where you left off
# - Retry NPM registry failures once after 30s
# - Continue if individual changelog fetch fails
# - Skip PR creation if recompile fails
# - Exit successfully if no updates found
# - Document incomplete research if rate-limited
# ```
#
# Pinned GitHub Actions:
# - actions/cache/restore@v4 (0057852bfaa89a56745cba8c7296529d2fc39830)
# https://github.com/actions/cache/commit/0057852bfaa89a56745cba8c7296529d2fc39830
# - actions/cache/save@v4 (0057852bfaa89a56745cba8c7296529d2fc39830)
# https://github.com/actions/cache/commit/0057852bfaa89a56745cba8c7296529d2fc39830
# - actions/checkout@v5 (93cb6efe18208431cddfb8368fd83d5badbf9bfd)
# https://github.com/actions/checkout/commit/93cb6efe18208431cddfb8368fd83d5badbf9bfd
# - actions/download-artifact@v6 (018cc2cf5baa6db3ef3c5f8a56943fffe632ef53)
# https://github.com/actions/download-artifact/commit/018cc2cf5baa6db3ef3c5f8a56943fffe632ef53
# - actions/github-script@v8 (ed597411d8f924073f98dfc5c65a23a2325f34cd)
# https://github.com/actions/github-script/commit/ed597411d8f924073f98dfc5c65a23a2325f34cd
# - actions/setup-node@v6 (395ad3262231945c25e8478fd5baf05154b1d79f)
# https://github.com/actions/setup-node/commit/395ad3262231945c25e8478fd5baf05154b1d79f
# - actions/upload-artifact@v5 (330a01c490aca151604b8cf639adc76d48f6c5d4)
# https://github.com/actions/upload-artifact/commit/330a01c490aca151604b8cf639adc76d48f6c5d4
name: "CLI Version Checker"
"on":
schedule:
- cron: "0 15 * * *"
# Friendly format: daily at 15:00
workflow_dispatch: null
permissions: {}
concurrency:
group: "gh-aw-${{ github.workflow }}"
run-name: "CLI Version Checker"
jobs:
activation:
runs-on: ubuntu-slim
permissions:
contents: read
outputs:
comment_id: ""
comment_repo: ""
steps:
- name: Check workflow file timestamps
uses: actions/github-script@ed597411d8f924073f98dfc5c65a23a2325f34cd # v8
env:
GH_AW_WORKFLOW_FILE: "cli-version-checker.lock.yml"
with:
script: |
async function main() {
const workflowFile = process.env.GH_AW_WORKFLOW_FILE;
if (!workflowFile) {
core.setFailed("Configuration error: GH_AW_WORKFLOW_FILE not available.");
return;
}
const workflowBasename = workflowFile.replace(".lock.yml", "");
const workflowMdPath = `.github/workflows/${workflowBasename}.md`;
const lockFilePath = `.github/workflows/${workflowFile}`;
core.info(`Checking workflow timestamps using GitHub API:`);
core.info(` Source: ${workflowMdPath}`);
core.info(` Lock file: ${lockFilePath}`);
const { owner, repo } = context.repo;
const ref = context.sha;
async function getLastCommitForFile(path) {
try {
const response = await github.rest.repos.listCommits({
owner,
repo,
path,
per_page: 1,
sha: ref,
});
if (response.data && response.data.length > 0) {
const commit = response.data[0];
return {
sha: commit.sha,
date: commit.commit.committer.date,
message: commit.commit.message,
};
}
return null;
} catch (error) {
core.info(`Could not fetch commit for ${path}: ${error.message}`);
return null;
}
}
const workflowCommit = await getLastCommitForFile(workflowMdPath);
const lockCommit = await getLastCommitForFile(lockFilePath);
if (!workflowCommit) {
core.info(`Source file does not exist: ${workflowMdPath}`);
}
if (!lockCommit) {
core.info(`Lock file does not exist: ${lockFilePath}`);
}
if (!workflowCommit || !lockCommit) {
core.info("Skipping timestamp check - one or both files not found");
return;
}
const workflowDate = new Date(workflowCommit.date);
const lockDate = new Date(lockCommit.date);
core.info(` Source last commit: ${workflowDate.toISOString()} (${workflowCommit.sha.substring(0, 7)})`);
core.info(` Lock last commit: ${lockDate.toISOString()} (${lockCommit.sha.substring(0, 7)})`);
if (workflowDate > lockDate) {
const warningMessage = `WARNING: Lock file '${lockFilePath}' is outdated! The workflow file '${workflowMdPath}' has been modified more recently. Run 'gh aw compile' to regenerate the lock file.`;
core.error(warningMessage);
const workflowTimestamp = workflowDate.toISOString();
const lockTimestamp = lockDate.toISOString();
let summary = core.summary
.addRaw("### ⚠️ Workflow Lock File Warning\n\n")
.addRaw("**WARNING**: Lock file is outdated and needs to be regenerated.\n\n")
.addRaw("**Files:**\n")
.addRaw(`- Source: \`${workflowMdPath}\`\n`)
.addRaw(` - Last commit: ${workflowTimestamp}\n`)
.addRaw(
` - Commit SHA: [\`${workflowCommit.sha.substring(0, 7)}\`](https://github.com/${owner}/${repo}/commit/${workflowCommit.sha})\n`
)
.addRaw(`- Lock: \`${lockFilePath}\`\n`)
.addRaw(` - Last commit: ${lockTimestamp}\n`)
.addRaw(` - Commit SHA: [\`${lockCommit.sha.substring(0, 7)}\`](https://github.com/${owner}/${repo}/commit/${lockCommit.sha})\n\n`)
.addRaw("**Action Required:** Run `gh aw compile` to regenerate the lock file.\n\n");
await summary.write();
} else if (workflowCommit.sha === lockCommit.sha) {
core.info("✅ Lock file is up to date (same commit)");
} else {
core.info("✅ Lock file is up to date");
}
}
main().catch(error => {
core.setFailed(error instanceof Error ? error.message : String(error));
});
agent:
needs: activation
runs-on: ubuntu-latest
permissions:
contents: read
issues: read
pull-requests: read
concurrency:
group: "gh-aw-claude-${{ github.workflow }}"
env:
GH_AW_MCP_LOG_DIR: /tmp/gh-aw/mcp-logs/safeoutputs
GH_AW_SAFE_OUTPUTS: /tmp/gh-aw/safeoutputs/outputs.jsonl
GH_AW_SAFE_OUTPUTS_CONFIG_PATH: /tmp/gh-aw/safeoutputs/config.json
GH_AW_SAFE_OUTPUTS_TOOLS_PATH: /tmp/gh-aw/safeoutputs/tools.json
outputs:
has_patch: ${{ steps.collect_output.outputs.has_patch }}
model: ${{ steps.generate_aw_info.outputs.model }}
output: ${{ steps.collect_output.outputs.output }}
output_types: ${{ steps.collect_output.outputs.output_types }}
steps:
- name: Checkout repository
uses: actions/checkout@93cb6efe18208431cddfb8368fd83d5badbf9bfd # v5
with:
persist-credentials: false
- name: Create gh-aw temp directory
run: |
mkdir -p /tmp/gh-aw/agent
mkdir -p /tmp/gh-aw/sandbox/agent/logs
echo "Created /tmp/gh-aw/agent directory for agentic workflow temporary files"
- name: Set up jq utilities directory
run: "mkdir -p /tmp/gh-aw\ncat > /tmp/gh-aw/jqschema.sh << 'EOF'\n#!/usr/bin/env bash\n# jqschema.sh\njq -c '\ndef walk(f):\n . as $in |\n if type == \"object\" then\n reduce keys[] as $k ({}; . + {($k): ($in[$k] | walk(f))})\n elif type == \"array\" then\n if length == 0 then [] else [.[0] | walk(f)] end\n else\n type\n end;\nwalk(.)\n'\nEOF\nchmod +x /tmp/gh-aw/jqschema.sh"
# Cache memory file share configuration from frontmatter processed below
- name: Create cache-memory directory
run: |
mkdir -p /tmp/gh-aw/cache-memory
echo "Cache memory directory created at /tmp/gh-aw/cache-memory"
echo "This folder provides persistent file storage across workflow runs"
echo "LLMs and agentic tools can freely read and write files in this directory"
- name: Restore cache memory file share data
uses: actions/cache/restore@0057852bfaa89a56745cba8c7296529d2fc39830 # v4
with:
key: memory-${{ github.workflow }}-${{ github.run_id }}
path: /tmp/gh-aw/cache-memory
restore-keys: |
memory-${{ github.workflow }}-
memory-
- name: Configure Git credentials
env:
REPO_NAME: ${{ github.repository }}
SERVER_URL: ${{ github.server_url }}
run: |
git config --global user.email "github-actions[bot]@users.noreply.github.com"
git config --global user.name "github-actions[bot]"
# Re-authenticate git with GitHub token
SERVER_URL_STRIPPED="${SERVER_URL#https://}"
git remote set-url origin "https://x-access-token:${{ github.token }}@${SERVER_URL_STRIPPED}/${REPO_NAME}.git"
echo "Git configured with standard GitHub Actions identity"
- name: Checkout PR branch
if: |
github.event.pull_request
uses: actions/github-script@ed597411d8f924073f98dfc5c65a23a2325f34cd # v8
env:
GH_TOKEN: ${{ secrets.GH_AW_GITHUB_MCP_SERVER_TOKEN || secrets.GH_AW_GITHUB_TOKEN || secrets.GITHUB_TOKEN }}
with:
github-token: ${{ secrets.GH_AW_GITHUB_MCP_SERVER_TOKEN || secrets.GH_AW_GITHUB_TOKEN || secrets.GITHUB_TOKEN }}
script: |
async function main() {
const eventName = context.eventName;
const pullRequest = context.payload.pull_request;
if (!pullRequest) {
core.info("No pull request context available, skipping checkout");
return;
}
core.info(`Event: ${eventName}`);
core.info(`Pull Request #${pullRequest.number}`);
try {
if (eventName === "pull_request") {
const branchName = pullRequest.head.ref;
core.info(`Checking out PR branch: ${branchName}`);
await exec.exec("git", ["fetch", "origin", branchName]);
await exec.exec("git", ["checkout", branchName]);
core.info(`✅ Successfully checked out branch: ${branchName}`);
} else {
const prNumber = pullRequest.number;
core.info(`Checking out PR #${prNumber} using gh pr checkout`);
await exec.exec("gh", ["pr", "checkout", prNumber.toString()]);
core.info(`✅ Successfully checked out PR #${prNumber}`);
}
} catch (error) {
core.setFailed(`Failed to checkout PR branch: ${error instanceof Error ? error.message : String(error)}`);
}
}
main().catch(error => {
core.setFailed(error instanceof Error ? error.message : String(error));
});
- name: Validate CLAUDE_CODE_OAUTH_TOKEN or ANTHROPIC_API_KEY secret
run: |
if [ -z "$CLAUDE_CODE_OAUTH_TOKEN" ] && [ -z "$ANTHROPIC_API_KEY" ]; then
{
echo "❌ Error: Neither CLAUDE_CODE_OAUTH_TOKEN nor ANTHROPIC_API_KEY secret is set"
echo "The Claude Code engine requires either CLAUDE_CODE_OAUTH_TOKEN or ANTHROPIC_API_KEY secret to be configured."
echo "Please configure one of these secrets in your repository settings."
echo "Documentation: https://githubnext.github.io/gh-aw/reference/engines/#anthropic-claude-code"
} >> "$GITHUB_STEP_SUMMARY"
echo "Error: Neither CLAUDE_CODE_OAUTH_TOKEN nor ANTHROPIC_API_KEY secret is set"
echo "The Claude Code engine requires either CLAUDE_CODE_OAUTH_TOKEN or ANTHROPIC_API_KEY secret to be configured."
echo "Please configure one of these secrets in your repository settings."
echo "Documentation: https://githubnext.github.io/gh-aw/reference/engines/#anthropic-claude-code"
exit 1
fi
# Log success in collapsible section
echo "<details>"
echo "<summary>Agent Environment Validation</summary>"
echo ""
if [ -n "$CLAUDE_CODE_OAUTH_TOKEN" ]; then
echo "✅ CLAUDE_CODE_OAUTH_TOKEN: Configured"
else
echo "✅ ANTHROPIC_API_KEY: Configured (using as fallback for CLAUDE_CODE_OAUTH_TOKEN)"
fi
echo "</details>"
env:
CLAUDE_CODE_OAUTH_TOKEN: ${{ secrets.CLAUDE_CODE_OAUTH_TOKEN }}
ANTHROPIC_API_KEY: ${{ secrets.ANTHROPIC_API_KEY }}
- name: Setup Node.js
uses: actions/setup-node@395ad3262231945c25e8478fd5baf05154b1d79f # v6
with:
node-version: '24'
package-manager-cache: false
- name: Install Claude Code CLI
run: npm install -g @anthropic-ai/claude-code@2.0.70
- name: Generate Claude Settings
run: |
mkdir -p /tmp/gh-aw/.claude
cat > /tmp/gh-aw/.claude/settings.json << 'EOF'
{
"hooks": {
"PreToolUse": [
{
"matcher": "WebFetch|WebSearch",
"hooks": [
{
"type": "command",
"command": ".claude/hooks/network_permissions.py"
}
]
}
]
}
}
EOF
- name: Generate Network Permissions Hook
run: |
mkdir -p .claude/hooks
cat > .claude/hooks/network_permissions.py << 'EOF'
#!/usr/bin/env python3
"""
Network permissions validator for Claude Code engine.
Generated by gh-aw from workflow-level network configuration.
"""
import json
import sys
import urllib.parse
import re
# Domain allow-list (populated during generation)
# JSON string is safely parsed using json.loads() to eliminate quoting vulnerabilities
ALLOWED_DOMAINS = json.loads('''["api.github.com","api.npms.io","api.snapcraft.io","archive.ubuntu.com","azure.archive.ubuntu.com","bun.sh","crl.geotrust.com","crl.globalsign.com","crl.identrust.com","crl.sectigo.com","crl.thawte.com","crl.usertrust.com","crl.verisign.com","crl3.digicert.com","crl4.digicert.com","crls.ssl.com","deb.nodesource.com","deno.land","get.pnpm.io","ghcr.io","json-schema.org","json.schemastore.org","keyserver.ubuntu.com","nodejs.org","npm.pkg.github.com","npmjs.com","npmjs.org","ocsp.digicert.com","ocsp.geotrust.com","ocsp.globalsign.com","ocsp.identrust.com","ocsp.sectigo.com","ocsp.ssl.com","ocsp.thawte.com","ocsp.usertrust.com","ocsp.verisign.com","packagecloud.io","packages.cloud.google.com","packages.microsoft.com","ppa.launchpad.net","registry.bower.io","registry.npmjs.com","registry.npmjs.org","registry.yarnpkg.com","repo.yarnpkg.com","s.symcb.com","s.symcd.com","security.ubuntu.com","skimdb.npmjs.com","ts-crl.ws.symantec.com","ts-ocsp.ws.symantec.com","www.npmjs.com","www.npmjs.org","yarnpkg.com"]''')
def extract_domain(url_or_query):
"""Extract domain from URL or search query."""
if not url_or_query:
return None
if url_or_query.startswith(('http://', 'https://')):
return urllib.parse.urlparse(url_or_query).netloc.lower()
# Check for domain patterns in search queries
match = re.search(r'site:([a-zA-Z0-9.-]+\.[a-zA-Z]{2,})', url_or_query)
if match:
return match.group(1).lower()
return None
def is_domain_allowed(domain):
"""Check if domain is allowed."""
if not domain:
# If no domain detected, allow only if not under deny-all policy
return bool(ALLOWED_DOMAINS) # False if empty list (deny-all), True if has domains
# Empty allowed domains means deny all
if not ALLOWED_DOMAINS:
return False
for pattern in ALLOWED_DOMAINS:
regex = pattern.replace('.', r'\.').replace('*', '.*')
if re.match(f'^{regex}$', domain):
return True
return False
# Main logic
try:
data = json.load(sys.stdin)
tool_name = data.get('tool_name', '')
tool_input = data.get('tool_input', {})
if tool_name not in ['WebFetch', 'WebSearch']:
sys.exit(0) # Allow other tools
target = tool_input.get('url') or tool_input.get('query', '')
domain = extract_domain(target)
# For WebSearch, apply domain restrictions consistently
# If no domain detected in search query, check if restrictions are in place
if tool_name == 'WebSearch' and not domain:
# Since this hook is only generated when network permissions are configured,
# empty ALLOWED_DOMAINS means deny-all policy
if not ALLOWED_DOMAINS: # Empty list means deny all
print(f"Network access blocked: deny-all policy in effect", file=sys.stderr)
print(f"No domains are allowed for WebSearch", file=sys.stderr)
sys.exit(2) # Block under deny-all policy
else:
print(f"Network access blocked for web-search: no specific domain detected", file=sys.stderr)
print(f"Allowed domains: {', '.join(ALLOWED_DOMAINS)}", file=sys.stderr)
sys.exit(2) # Block general searches when domain allowlist is configured
if not is_domain_allowed(domain):
print(f"Network access blocked for domain: {domain}", file=sys.stderr)
print(f"Allowed domains: {', '.join(ALLOWED_DOMAINS)}", file=sys.stderr)
sys.exit(2) # Block with feedback to Claude
sys.exit(0) # Allow
except Exception as e:
print(f"Network validation error: {e}", file=sys.stderr)
sys.exit(2) # Block on errors
EOF
chmod +x .claude/hooks/network_permissions.py
- name: Downloading container images
run: |
set -e
docker pull ghcr.io/github/github-mcp-server:v0.25.0
- name: Write Safe Outputs Config
run: |
mkdir -p /tmp/gh-aw/safeoutputs
mkdir -p /tmp/gh-aw/mcp-logs/safeoutputs
cat > /tmp/gh-aw/safeoutputs/config.json << 'EOF'
{"create_issue":{"max":1},"missing_tool":{"max":0},"noop":{"max":1}}
EOF
cat > /tmp/gh-aw/safeoutputs/tools.json << 'EOF'
[
{
"description": "Create a new GitHub issue for tracking bugs, feature requests, or tasks. Use this for actionable work items that need assignment, labeling, and status tracking. For reports, announcements, or status updates that don't require task tracking, use create_discussion instead. CONSTRAINTS: Maximum 1 issue(s) can be created. Title will be prefixed with \"[ca] \". Labels [automation dependencies] will be automatically added.",
"inputSchema": {
"additionalProperties": false,
"properties": {
"body": {
"description": "Detailed issue description in Markdown. Do NOT repeat the title as a heading since it already appears as the issue's h1. Include context, reproduction steps, or acceptance criteria as appropriate.",
"type": "string"
},
"labels": {
"description": "Labels to categorize the issue (e.g., 'bug', 'enhancement'). Labels must exist in the repository.",
"items": {
"type": "string"
},
"type": "array"
},
"parent": {
"description": "Parent issue number for creating sub-issues. Can be a real issue number (e.g., 42) or a temporary_id (e.g., 'aw_abc123def456') from a previously created issue in the same workflow run.",
"type": [
"number",
"string"
]
},
"temporary_id": {
"description": "Unique temporary identifier for referencing this issue before it's created. Format: 'aw_' followed by 12 hex characters (e.g., 'aw_abc123def456'). Use '#aw_ID' in body text to reference other issues by their temporary_id; these are replaced with actual issue numbers after creation.",
"type": "string"
},
"title": {
"description": "Concise issue title summarizing the bug, feature, or task. The title appears as the main heading, so keep it brief and descriptive.",
"type": "string"
}
},
"required": [
"title",
"body"
],
"type": "object"
},
"name": "create_issue"
},
{
"description": "Report that a tool or capability needed to complete the task is not available. Use this when you cannot accomplish what was requested because the required functionality is missing or access is restricted.",
"inputSchema": {
"additionalProperties": false,
"properties": {
"alternatives": {
"description": "Any workarounds, manual steps, or alternative approaches the user could take (max 256 characters).",
"type": "string"
},
"reason": {
"description": "Explanation of why this tool is needed to complete the task (max 256 characters).",
"type": "string"
},
"tool": {
"description": "Name or description of the missing tool or capability (max 128 characters). Be specific about what functionality is needed.",
"type": "string"
}
},
"required": [
"tool",
"reason"
],
"type": "object"
},
"name": "missing_tool"
},
{
"description": "Log a transparency message when no significant actions are needed. Use this to confirm workflow completion and provide visibility when analysis is complete but no changes or outputs are required (e.g., 'No issues found', 'All checks passed'). This ensures the workflow produces human-visible output even when no other actions are taken.",
"inputSchema": {
"additionalProperties": false,
"properties": {
"message": {
"description": "Status or completion message to log. Should explain what was analyzed and the outcome (e.g., 'Code review complete - no issues found', 'Analysis complete - all tests passing').",
"type": "string"
}
},
"required": [
"message"
],
"type": "object"
},
"name": "noop"
}
]
EOF
cat > /tmp/gh-aw/safeoutputs/validation.json << 'EOF'
{
"create_issue": {
"defaultMax": 1,
"fields": {
"body": {
"required": true,
"type": "string",
"sanitize": true,
"maxLength": 65000
},
"labels": {
"type": "array",
"itemType": "string",
"itemSanitize": true,
"itemMaxLength": 128
},
"parent": {
"issueOrPRNumber": true
},
"repo": {
"type": "string",
"maxLength": 256
},
"temporary_id": {
"type": "string"
},
"title": {
"required": true,
"type": "string",
"sanitize": true,
"maxLength": 128
}
}
},
"missing_tool": {
"defaultMax": 20,
"fields": {
"alternatives": {
"type": "string",
"sanitize": true,
"maxLength": 512
},
"reason": {
"required": true,
"type": "string",
"sanitize": true,
"maxLength": 256
},
"tool": {
"required": true,
"type": "string",
"sanitize": true,
"maxLength": 128
}
}
},
"noop": {
"defaultMax": 1,
"fields": {
"message": {
"required": true,
"type": "string",
"sanitize": true,
"maxLength": 65000
}
}
}
}
EOF
- name: Write Safe Outputs JavaScript Files
run: |
cat > /tmp/gh-aw/safeoutputs/estimate_tokens.cjs << 'EOF_ESTIMATE_TOKENS'
function estimateTokens(text) {
if (!text) return 0;
return Math.ceil(text.length / 4);
}
module.exports = {
estimateTokens,
};
EOF_ESTIMATE_TOKENS
cat > /tmp/gh-aw/safeoutputs/generate_compact_schema.cjs << 'EOF_GENERATE_COMPACT_SCHEMA'
function generateCompactSchema(content) {
try {
const parsed = JSON.parse(content);
if (Array.isArray(parsed)) {
if (parsed.length === 0) {
return "[]";
}
const firstItem = parsed[0];
if (typeof firstItem === "object" && firstItem !== null) {
const keys = Object.keys(firstItem);
return `[{${keys.join(", ")}}] (${parsed.length} items)`;
}
return `[${typeof firstItem}] (${parsed.length} items)`;
} else if (typeof parsed === "object" && parsed !== null) {
const keys = Object.keys(parsed);
if (keys.length > 10) {
return `{${keys.slice(0, 10).join(", ")}, ...} (${keys.length} keys)`;
}
return `{${keys.join(", ")}}`;
}
return `${typeof parsed}`;
} catch {
return "text content";
}
}
module.exports = {
generateCompactSchema,
};
EOF_GENERATE_COMPACT_SCHEMA
cat > /tmp/gh-aw/safeoutputs/generate_git_patch.cjs << 'EOF_GENERATE_GIT_PATCH'
const fs = require("fs");
const path = require("path");
const { execSync } = require("child_process");
const { getBaseBranch } = require("./get_base_branch.cjs");
function generateGitPatch(branchName) {
const patchPath = "/tmp/gh-aw/aw.patch";
const cwd = process.env.GITHUB_WORKSPACE || process.cwd();
const defaultBranch = process.env.DEFAULT_BRANCH || getBaseBranch();
const githubSha = process.env.GITHUB_SHA;
const patchDir = path.dirname(patchPath);
if (!fs.existsSync(patchDir)) {
fs.mkdirSync(patchDir, { recursive: true });
}