Skip to content

Commit eb1ad39

Browse files
committed
initial commit
0 parents  commit eb1ad39

File tree

15 files changed

+1748
-0
lines changed

15 files changed

+1748
-0
lines changed

.github/workflows/build-app.yml

Lines changed: 60 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,60 @@
1+
name: Build app
2+
3+
on:
4+
push:
5+
branches:
6+
- master
7+
8+
permissions:
9+
contents: read
10+
11+
jobs:
12+
build:
13+
name: Build app ${{ matrix.os }} (${{ matrix.arch }})
14+
runs-on: ${{ matrix.runner }}
15+
strategy:
16+
fail-fast: false
17+
matrix:
18+
include:
19+
- runner: ubuntu-24.04
20+
os: linux
21+
arch: amd64
22+
- runner: ubuntu-24.04-arm
23+
os: linux
24+
arch: arm64
25+
- runner: macos-13
26+
os: darwin
27+
arch: amd64
28+
- runner: macos-15
29+
os: darwin
30+
arch: arm64
31+
steps:
32+
- name: Checkout
33+
uses: actions/checkout@v5
34+
35+
- name: Set up Go
36+
uses: actions/setup-go@v5
37+
with:
38+
go-version-file: go.mod
39+
check-latest: true
40+
cache: true
41+
42+
- name: Show environment
43+
run: |
44+
go version
45+
go env GOOS GOARCH
46+
47+
- name: Build
48+
run: |
49+
mkdir -p dist
50+
GOFLAGS="-trimpath" go build -ldflags="-s -w" -o dist/gradient-engineer.${{ matrix.os }}.${{ matrix.arch }} ./app
51+
52+
- name: Upload binary artifact
53+
uses: actions/upload-artifact@v4
54+
with:
55+
name: gradient-engineer.${{ matrix.os }}.${{ matrix.arch }}
56+
path: dist/gradient-engineer.${{ matrix.os }}.${{ matrix.arch }}
57+
if-no-files-found: error
58+
compression-level: 0
59+
60+
Lines changed: 67 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,67 @@
1+
name: Build toolbox
2+
3+
on:
4+
push:
5+
branches:
6+
- master
7+
8+
permissions:
9+
contents: read
10+
11+
jobs:
12+
build:
13+
name: Build toolbox ${{ matrix.os }} (${{ matrix.arch }})
14+
runs-on: ${{ matrix.runner }}
15+
strategy:
16+
fail-fast: false
17+
matrix:
18+
include:
19+
- runner: ubuntu-24.04
20+
os: linux
21+
arch: amd64
22+
- runner: ubuntu-24.04-arm
23+
os: linux
24+
arch: arm64
25+
# - runner: macos-13
26+
# os: darwin
27+
# arch: amd64
28+
# - runner: macos-15
29+
# os: darwin
30+
# arch: arm64
31+
steps:
32+
- name: Checkout
33+
uses: actions/checkout@v5
34+
35+
- name: Setup Go
36+
uses: actions/setup-go@v5
37+
with:
38+
go-version-file: go.mod
39+
check-latest: true
40+
cache: true
41+
42+
- name: Install Nix
43+
uses: cachix/install-nix-action@v31
44+
45+
- name: Build toolbox builder
46+
shell: bash
47+
run: |
48+
set -euo pipefail
49+
cd toolbox
50+
go build -o toolbox-builder
51+
52+
- name: Build toolbox archive
53+
shell: bash
54+
run: |
55+
set -euo pipefail
56+
cd toolbox
57+
./toolbox-builder --playbook ../playbook/60-second-linux.yaml --out .
58+
59+
- name: Upload artifact
60+
uses: actions/upload-artifact@v4
61+
with:
62+
name: toolbox.${{ matrix.os }}.${{ matrix.arch }}
63+
path: toolbox/*.tar.xz
64+
if-no-files-found: error
65+
retention-days: 7
66+
67+

LICENSE

Lines changed: 21 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,21 @@
1+
MIT License
2+
3+
Copyright (c) 2025 Quesma, Inc.
4+
5+
Permission is hereby granted, free of charge, to any person obtaining a copy
6+
of this software and associated documentation files (the "Software"), to deal
7+
in the Software without restriction, including without limitation the rights
8+
to use, copy, modify, merge, publish, distribute, sublicense, and/or sell
9+
copies of the Software, and to permit persons to whom the Software is
10+
furnished to do so, subject to the following conditions:
11+
12+
The above copyright notice and this permission notice shall be included in all
13+
copies or substantial portions of the Software.
14+
15+
THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR
16+
IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY,
17+
FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE
18+
AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER
19+
LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM,
20+
OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE
21+
SOFTWARE.

README.md

Lines changed: 47 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,47 @@
1+
# Gradient Engineer — 60‑Second Linux Analysis (Nix + LLM)
2+
3+
Run the classic [“60‑second Linux Performance Analysis”](https://netflixtechblog.com/linux-performance-analysis-in-60-000-milliseconds-accc10403c55) checklist in one command. A portable Nix toolbox is downloaded on the fly, diagnostics run in parallel with a simple TUI, and an optional AI summary is shown at the end.
4+
5+
- One command to run it all
6+
- Fast and portable
7+
- No Docker, no system‑wide installs
8+
- Optional AI summary
9+
10+
> [!NOTE]
11+
> This project is an early experiment.
12+
13+
## Quick start
14+
15+
```bash
16+
# Any provider works; set one of these env vars to enable AI summary
17+
export ANTHROPIC_API_KEY="<your Anthropic API key>" # Anthropic
18+
export OPENAI_API_KEY="<your OpenAI API key>" # OpenAI
19+
export OPENROUTER_API_KEY="<your OpenRouter API key>" # OpenRouter
20+
21+
curl -fsSL https://gradient.engineer/60-second-linux.sh | sh
22+
```
23+
24+
Notes:
25+
26+
- If no key is set, diagnostics still run; only the AI summary is skipped.
27+
- TUI controls: Tab toggles details; q / Esc / Ctrl+C quits.
28+
29+
## Build from source
30+
31+
```bash
32+
cd app
33+
go build -o gradient-engineer-go
34+
./gradient-engineer-go
35+
```
36+
37+
## Advanced
38+
39+
- You can override the API base URL via `OPENAI_BASE_URL` (for OpenAI/OpenRouter) if needed.
40+
41+
## License
42+
43+
This project is licensed under the MIT License. See the `LICENSE` file for details.
44+
45+
## Third-party software and licenses
46+
47+
This app downloads a prebuilt Linux toolbox containing third-party binaries (e.g., `coreutils`, `util-linux`, `procps`, `sysstat`, and `proot`). Some of these are licensed under GPL terms. See `THIRD_PARTY_NOTICES.md` for details and links to upstream sources. Go module dependencies each retain their own licenses; consult `go.mod` and the notices file for an overview.

THIRD_PARTY_NOTICES.md

Lines changed: 34 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,34 @@
1+
Third-Party Notices
2+
3+
This project bundles or invokes third-party software. License obligations for these components are summarized here. This file is provided for convenience and does not replace the original license texts.
4+
5+
Toolbox binaries (downloaded at runtime)
6+
7+
- Nixpkgs packages included in the toolbox archive (via `toolbox/toolbox.tar.xz` downloaded by the app):
8+
- coreutils (GPL-3.0-or-later)
9+
- util-linux (GPL-2.0-only and LGPL-2.1-or-later; mixed licensing by subcomponent)
10+
- procps (GPL-2.0-or-later)
11+
- sysstat (GPL-2.0-only)
12+
- proot.static from Alpine APK (GPL-2.0-only)
13+
14+
Notes
15+
16+
- These binaries are redistributed as part of a prebuilt toolbox archive hosted by Quesma. Where required by GPL, the corresponding source is available from the original upstream projects (e.g., Nixpkgs, Alpine Linux, and project repositories). For convenience, you can obtain matching sources via Nixpkgs and Alpine repositories for the specific versions referenced by the toolbox. If you need assistance locating the exact sources, contact Quesma.
17+
- The runtime downloads and executes these tools in a sandboxed environment to perform diagnostics; the Go application itself is licensed under MIT.
18+
19+
Go dependencies
20+
21+
This application depends on Go libraries via `go.mod`. Each dependency retains its own license; common licenses include MIT, Apache-2.0, BSD, and similar permissive terms. Notable direct dependencies include:
22+
23+
- charmbracelet libraries (`bubbletea`, `bubbles`, `lipgloss`, `glamour`)
24+
- `github.com/ulikunitz/xz` (BSD-3-Clause)
25+
- `gopkg.in/yaml.v3` (MIT)
26+
- `github.com/openai/openai-go` and `github.com/anthropics/anthropic-sdk-go` (see respective repos for licenses)
27+
28+
For a complete, authoritative list of Go dependencies and their licenses, consult `go.mod`, `go.sum`, and the respective upstream repositories.
29+
30+
Requests for source
31+
32+
If you require assistance obtaining source code corresponding to any GPL components used in or distributed with the toolbox, please contact Quesma at [email protected].
33+
34+

app/main.go

Lines changed: 45 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,45 @@
1+
package main
2+
3+
import (
4+
"log"
5+
6+
tea "github.com/charmbracelet/bubbletea"
7+
"github.com/spf13/cobra"
8+
)
9+
10+
var (
11+
toolboxRepo string
12+
)
13+
14+
func main() {
15+
var rootCmd = &cobra.Command{
16+
Use: "gradient-engineer [flags] PLAYBOOK_NAME",
17+
Short: "Run diagnostic playbooks using gradient engineer toolbox",
18+
Long: `Gradient Engineer runs diagnostic playbooks by downloading and executing
19+
toolbox commands. The toolbox is automatically downloaded from the specified
20+
repository based on your platform (OS and architecture).`,
21+
Args: cobra.ExactArgs(1),
22+
Run: func(cmd *cobra.Command, args []string) {
23+
playbookName := args[0]
24+
25+
// Create a new toolbox instance
26+
tb := NewToolbox(toolboxRepo, playbookName)
27+
defer tb.Cleanup()
28+
29+
// Create and run the Bubble Tea program which will handle toolbox download and diagnostics
30+
p := tea.NewProgram(NewModel(tb), tea.WithMouseCellMotion())
31+
if _, err := p.Run(); err != nil {
32+
log.Fatalf("Error running Bubble Tea program: %v", err)
33+
}
34+
},
35+
}
36+
37+
// Define flags
38+
rootCmd.Flags().StringVar(&toolboxRepo, "toolbox-repo", "https://gradient.engineer/toolbox/",
39+
"Toolbox repository URL or path (e.g., file:///home/user/mytoolboxes/)")
40+
41+
// Execute the command
42+
if err := rootCmd.Execute(); err != nil {
43+
log.Fatal(err)
44+
}
45+
}

0 commit comments

Comments
 (0)