Skip to content

Commit 97a0a45

Browse files
Cortex Devfactory-droid[bot]
andcommitted
Initial commit: Cortex CLI v0.1.0
- Complete Rust workspace with 40+ crates - Multi-platform CI/CD for Windows, macOS, Linux - Winget package automation - Optimized release builds (LTO, stripped symbols) Co-authored-by: factory-droid[bot] <138933559+factory-droid[bot]@users.noreply.github.com>
1 parent 19d8553 commit 97a0a45

734 files changed

Lines changed: 328893 additions & 0 deletions

File tree

Some content is hidden

Large Commits have some content hidden by default. Use the searchbox below for content that may be hidden.

.github/workflows/ci.yml

Lines changed: 74 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,74 @@
1+
name: CI
2+
3+
on:
4+
push:
5+
branches: [master, main, develop]
6+
pull_request:
7+
branches: [master, main]
8+
9+
env:
10+
CARGO_TERM_COLOR: always
11+
RUST_BACKTRACE: 1
12+
13+
jobs:
14+
fmt:
15+
name: Format
16+
runs-on: ubuntu-latest
17+
steps:
18+
- uses: actions/checkout@v4
19+
- uses: dtolnay/rust-toolchain@stable
20+
with:
21+
components: rustfmt
22+
- run: cargo fmt --all -- --check
23+
24+
clippy:
25+
name: Clippy
26+
runs-on: ubuntu-latest
27+
steps:
28+
- uses: actions/checkout@v4
29+
- uses: dtolnay/rust-toolchain@stable
30+
with:
31+
components: clippy
32+
- uses: Swatinem/rust-cache@v2
33+
- run: cargo clippy --all-targets --all-features -- -D warnings
34+
35+
test:
36+
name: Test (${{ matrix.os }})
37+
runs-on: ${{ matrix.os }}
38+
strategy:
39+
fail-fast: false
40+
matrix:
41+
os: [ubuntu-latest, windows-latest, macos-latest]
42+
steps:
43+
- uses: actions/checkout@v4
44+
- uses: dtolnay/rust-toolchain@stable
45+
- uses: Swatinem/rust-cache@v2
46+
with:
47+
key: ${{ matrix.os }}
48+
- name: Run tests
49+
run: cargo test --workspace --all-features
50+
51+
build-check:
52+
name: Build Check (${{ matrix.os }})
53+
runs-on: ${{ matrix.os }}
54+
strategy:
55+
fail-fast: false
56+
matrix:
57+
os: [ubuntu-latest, windows-latest, macos-latest]
58+
steps:
59+
- uses: actions/checkout@v4
60+
- uses: dtolnay/rust-toolchain@stable
61+
- uses: Swatinem/rust-cache@v2
62+
with:
63+
key: ${{ matrix.os }}
64+
- name: Check build
65+
run: cargo check --workspace --all-features
66+
67+
audit:
68+
name: Security Audit
69+
runs-on: ubuntu-latest
70+
steps:
71+
- uses: actions/checkout@v4
72+
- uses: rustsec/audit-check@v2
73+
with:
74+
token: ${{ secrets.GITHUB_TOKEN }}

.github/workflows/release.yml

Lines changed: 147 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,147 @@
1+
name: Release
2+
3+
on:
4+
push:
5+
tags:
6+
- 'v*'
7+
workflow_dispatch:
8+
inputs:
9+
tag:
10+
description: 'Release tag (e.g., v0.1.0)'
11+
required: true
12+
13+
env:
14+
CARGO_TERM_COLOR: always
15+
RUST_BACKTRACE: 1
16+
BINARY_NAME: Cortex
17+
18+
permissions:
19+
contents: write
20+
21+
jobs:
22+
build:
23+
name: Build ${{ matrix.target }}
24+
runs-on: ${{ matrix.os }}
25+
strategy:
26+
fail-fast: false
27+
matrix:
28+
include:
29+
# Windows
30+
- os: windows-latest
31+
target: x86_64-pc-windows-msvc
32+
artifact: cortex-windows-x64
33+
ext: .exe
34+
- os: windows-latest
35+
target: aarch64-pc-windows-msvc
36+
artifact: cortex-windows-arm64
37+
ext: .exe
38+
# macOS
39+
- os: macos-latest
40+
target: x86_64-apple-darwin
41+
artifact: cortex-macos-x64
42+
ext: ""
43+
- os: macos-latest
44+
target: aarch64-apple-darwin
45+
artifact: cortex-macos-arm64
46+
ext: ""
47+
# Linux
48+
- os: ubuntu-latest
49+
target: x86_64-unknown-linux-gnu
50+
artifact: cortex-linux-x64
51+
ext: ""
52+
- os: ubuntu-latest
53+
target: aarch64-unknown-linux-gnu
54+
artifact: cortex-linux-arm64
55+
ext: ""
56+
cross: true
57+
58+
steps:
59+
- uses: actions/checkout@v4
60+
61+
- name: Install Rust
62+
uses: dtolnay/rust-toolchain@stable
63+
with:
64+
targets: ${{ matrix.target }}
65+
66+
- name: Install cross-compilation tools (Linux ARM64)
67+
if: matrix.cross == true
68+
run: |
69+
sudo apt-get update
70+
sudo apt-get install -y gcc-aarch64-linux-gnu g++-aarch64-linux-gnu
71+
echo "CARGO_TARGET_AARCH64_UNKNOWN_LINUX_GNU_LINKER=aarch64-linux-gnu-gcc" >> $GITHUB_ENV
72+
73+
- name: Cache cargo
74+
uses: Swatinem/rust-cache@v2
75+
with:
76+
key: ${{ matrix.target }}
77+
78+
- name: Build release binary
79+
run: cargo build --release --target ${{ matrix.target }} -p cortex-cli
80+
81+
- name: Prepare artifact (Unix)
82+
if: runner.os != 'Windows'
83+
run: |
84+
mkdir -p dist
85+
cp target/${{ matrix.target }}/release/${{ env.BINARY_NAME }}${{ matrix.ext }} dist/
86+
cd dist
87+
tar -czvf ../${{ matrix.artifact }}.tar.gz *
88+
89+
- name: Prepare artifact (Windows)
90+
if: runner.os == 'Windows'
91+
shell: pwsh
92+
run: |
93+
New-Item -ItemType Directory -Force -Path dist
94+
Copy-Item "target/${{ matrix.target }}/release/${{ env.BINARY_NAME }}${{ matrix.ext }}" dist/
95+
Compress-Archive -Path dist/* -DestinationPath "${{ matrix.artifact }}.zip"
96+
97+
- name: Upload artifact
98+
uses: actions/upload-artifact@v4
99+
with:
100+
name: ${{ matrix.artifact }}
101+
path: |
102+
${{ matrix.artifact }}.tar.gz
103+
${{ matrix.artifact }}.zip
104+
if-no-files-found: ignore
105+
106+
release:
107+
name: Create Release
108+
needs: build
109+
runs-on: ubuntu-latest
110+
steps:
111+
- uses: actions/checkout@v4
112+
113+
- name: Download all artifacts
114+
uses: actions/download-artifact@v4
115+
with:
116+
path: artifacts
117+
118+
- name: Get version
119+
id: version
120+
run: |
121+
if [ "${{ github.event_name }}" = "workflow_dispatch" ]; then
122+
echo "version=${{ github.event.inputs.tag }}" >> $GITHUB_OUTPUT
123+
else
124+
echo "version=${GITHUB_REF#refs/tags/}" >> $GITHUB_OUTPUT
125+
fi
126+
127+
- name: Generate checksums
128+
run: |
129+
cd artifacts
130+
find . -type f \( -name "*.tar.gz" -o -name "*.zip" \) -exec mv {} . \;
131+
sha256sum *.tar.gz *.zip > checksums-sha256.txt || true
132+
cat checksums-sha256.txt
133+
134+
- name: Create GitHub Release
135+
uses: softprops/action-gh-release@v2
136+
with:
137+
tag_name: ${{ steps.version.outputs.version }}
138+
name: Cortex CLI ${{ steps.version.outputs.version }}
139+
draft: false
140+
prerelease: ${{ contains(steps.version.outputs.version, '-') }}
141+
generate_release_notes: true
142+
files: |
143+
artifacts/*.tar.gz
144+
artifacts/*.zip
145+
artifacts/checksums-sha256.txt
146+
env:
147+
GITHUB_TOKEN: ${{ secrets.GITHUB_TOKEN }}

.github/workflows/winget.yml

Lines changed: 174 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,174 @@
1+
name: Winget Release
2+
3+
on:
4+
release:
5+
types: [published]
6+
workflow_dispatch:
7+
inputs:
8+
tag:
9+
description: 'Release tag (e.g., v0.1.0)'
10+
required: true
11+
12+
env:
13+
PACKAGE_ID: CortexLM.Cortex
14+
15+
jobs:
16+
winget:
17+
name: Publish to Winget
18+
runs-on: windows-latest
19+
steps:
20+
- uses: actions/checkout@v4
21+
22+
- name: Get version
23+
id: version
24+
shell: pwsh
25+
run: |
26+
if ("${{ github.event_name }}" -eq "workflow_dispatch") {
27+
$version = "${{ github.event.inputs.tag }}" -replace '^v', ''
28+
} else {
29+
$version = "${{ github.event.release.tag_name }}" -replace '^v', ''
30+
}
31+
echo "version=$version" >> $env:GITHUB_OUTPUT
32+
echo "Version: $version"
33+
34+
- name: Get release URLs and hashes
35+
id: release
36+
shell: pwsh
37+
run: |
38+
$tag = "v${{ steps.version.outputs.version }}"
39+
$baseUrl = "https://github.com/${{ github.repository }}/releases/download/$tag"
40+
41+
# Download and hash x64
42+
$x64Url = "$baseUrl/cortex-windows-x64.zip"
43+
Invoke-WebRequest -Uri $x64Url -OutFile "cortex-x64.zip" -ErrorAction Stop
44+
$x64Hash = (Get-FileHash -Path "cortex-x64.zip" -Algorithm SHA256).Hash
45+
46+
# Download and hash arm64
47+
$arm64Url = "$baseUrl/cortex-windows-arm64.zip"
48+
try {
49+
Invoke-WebRequest -Uri $arm64Url -OutFile "cortex-arm64.zip" -ErrorAction Stop
50+
$arm64Hash = (Get-FileHash -Path "cortex-arm64.zip" -Algorithm SHA256).Hash
51+
} catch {
52+
$arm64Hash = ""
53+
$arm64Url = ""
54+
}
55+
56+
echo "x64_url=$x64Url" >> $env:GITHUB_OUTPUT
57+
echo "x64_hash=$x64Hash" >> $env:GITHUB_OUTPUT
58+
echo "arm64_url=$arm64Url" >> $env:GITHUB_OUTPUT
59+
echo "arm64_hash=$arm64Hash" >> $env:GITHUB_OUTPUT
60+
61+
- name: Create winget manifest directory
62+
shell: pwsh
63+
run: |
64+
$version = "${{ steps.version.outputs.version }}"
65+
$manifestDir = "manifests/c/CortexLM/Cortex/$version"
66+
New-Item -ItemType Directory -Force -Path $manifestDir
67+
echo "MANIFEST_DIR=$manifestDir" >> $env:GITHUB_ENV
68+
69+
- name: Generate version manifest
70+
shell: pwsh
71+
run: |
72+
$content = @"
73+
PackageIdentifier: ${{ env.PACKAGE_ID }}
74+
PackageVersion: ${{ steps.version.outputs.version }}
75+
DefaultLocale: en-US
76+
ManifestType: version
77+
ManifestVersion: 1.6.0
78+
"@
79+
$content | Out-File -FilePath "${{ env.MANIFEST_DIR }}/${{ env.PACKAGE_ID }}.yaml" -Encoding utf8
80+
81+
- name: Generate installer manifest
82+
shell: pwsh
83+
run: |
84+
$installers = @"
85+
PackageIdentifier: ${{ env.PACKAGE_ID }}
86+
PackageVersion: ${{ steps.version.outputs.version }}
87+
Platform:
88+
- Windows.Desktop
89+
MinimumOSVersion: 10.0.17763.0
90+
InstallerType: zip
91+
NestedInstallerType: portable
92+
NestedInstallerFiles:
93+
- RelativeFilePath: Cortex.exe
94+
PortableCommandAlias: cortex
95+
Installers:
96+
- Architecture: x64
97+
InstallerUrl: ${{ steps.release.outputs.x64_url }}
98+
InstallerSha256: ${{ steps.release.outputs.x64_hash }}
99+
"@
100+
101+
if ("${{ steps.release.outputs.arm64_hash }}" -ne "") {
102+
$installers += @"
103+
104+
- Architecture: arm64
105+
InstallerUrl: ${{ steps.release.outputs.arm64_url }}
106+
InstallerSha256: ${{ steps.release.outputs.arm64_hash }}
107+
"@
108+
}
109+
110+
$installers += @"
111+
112+
ManifestType: installer
113+
ManifestVersion: 1.6.0
114+
"@
115+
116+
$installers | Out-File -FilePath "${{ env.MANIFEST_DIR }}/${{ env.PACKAGE_ID }}.installer.yaml" -Encoding utf8
117+
118+
- name: Generate locale manifest
119+
shell: pwsh
120+
run: |
121+
$content = @"
122+
PackageIdentifier: ${{ env.PACKAGE_ID }}
123+
PackageVersion: ${{ steps.version.outputs.version }}
124+
PackageLocale: en-US
125+
Publisher: CortexLM
126+
PublisherUrl: https://github.com/CortexLM
127+
PublisherSupportUrl: https://github.com/CortexLM/cortex-cli/issues
128+
PackageName: Cortex CLI
129+
PackageUrl: https://github.com/CortexLM/cortex-cli
130+
License: Apache-2.0
131+
LicenseUrl: https://github.com/CortexLM/cortex-cli/blob/master/LICENSE
132+
ShortDescription: Cortex CLI - A modern AI coding agent
133+
Description: Cortex is a powerful command-line AI coding assistant that helps developers write, debug, and maintain code more efficiently.
134+
Tags:
135+
- ai
136+
- cli
137+
- coding
138+
- developer-tools
139+
- rust
140+
ManifestType: defaultLocale
141+
ManifestVersion: 1.6.0
142+
"@
143+
$content | Out-File -FilePath "${{ env.MANIFEST_DIR }}/${{ env.PACKAGE_ID }}.locale.en-US.yaml" -Encoding utf8
144+
145+
- name: Install wingetcreate
146+
shell: pwsh
147+
run: |
148+
iwr https://aka.ms/wingetcreate/latest -OutFile wingetcreate.exe
149+
150+
- name: Validate manifests
151+
shell: pwsh
152+
run: |
153+
.\wingetcreate.exe validate ${{ env.MANIFEST_DIR }}
154+
155+
- name: Submit to winget-pkgs (manual step)
156+
shell: pwsh
157+
run: |
158+
Write-Host "==============================================="
159+
Write-Host "Winget manifests generated successfully!"
160+
Write-Host "==============================================="
161+
Write-Host ""
162+
Write-Host "To submit to winget-pkgs repository:"
163+
Write-Host "1. Fork https://github.com/microsoft/winget-pkgs"
164+
Write-Host "2. Copy the manifests from: ${{ env.MANIFEST_DIR }}"
165+
Write-Host "3. Create a PR to microsoft/winget-pkgs"
166+
Write-Host ""
167+
Write-Host "Or use wingetcreate with a GitHub token:"
168+
Write-Host ".\wingetcreate.exe submit ${{ env.MANIFEST_DIR }} --token <PAT>"
169+
170+
- name: Upload manifests as artifact
171+
uses: actions/upload-artifact@v4
172+
with:
173+
name: winget-manifests
174+
path: manifests/

0 commit comments

Comments
 (0)