这是indexloc提供的服务,不要输入任何密码
Skip to content
Closed
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension


Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
1 change: 1 addition & 0 deletions .cursorrules
2 changes: 2 additions & 0 deletions .gitignore
Original file line number Diff line number Diff line change
Expand Up @@ -9,3 +9,5 @@
# Generated files
acp_commands.sh


acp/config/tmp/
135 changes: 0 additions & 135 deletions CLAUDE.md

This file was deleted.

23 changes: 0 additions & 23 deletions CONTRIBUTING.md

This file was deleted.

36 changes: 36 additions & 0 deletions Makefile
Original file line number Diff line number Diff line change
Expand Up @@ -27,8 +27,44 @@ example-%: ## Run any acp-example Makefile target: make example-<target>

build: acp-build ## Build acp components


branchname := $(shell git branch --show-current)
dirname := $(shell basename ${PWD})
setup:
@echo "BRANCH: ${branchname}"
@echo "DIRNAME: ${dirname}"

$(MAKE) -C $(ACP_DIR) mocks deps

worktree-cluster:
# replicated cluster create --distribution kind --instance-type r1.small --disk 50 --version 1.33.1 --wait 5m --name ${dirname}
# replicated cluster kuebconfig ${dirname} --output ./kubeconfig
# kubectl --kubeconfig ./kubeconfig get node
# kubectl --kubeconfig ./kubeconfig create secret generic openai --from-literal=OPENAI_API_KEY=${OPENAI_API_KEY}
# kubectl --kubeconfig ./kubeconfig create secret generic anthropic --from-literal=ANTHROPIC_API_KEY=${ANTHROPIC_API_KEY}
# kubectl --kubeconfig ./kubeconfig create secret generic humanlayer --from-literal=HUMANLAYER_API_KEY=${HUMANLAYER_API_KEY}
# KUBECONFIG=./kubeconfig $(MAKE) -C $(ACP_DIR) generate deploy-local-kind

check:
# $(MAKE) -C $(ACP_DIR) fmt vet lint test generate

test: acp-test ## Run tests for acp components

check-keys-set:
@if [ -z "${HUMANLAYER_API_KEY}" ]; then \
echo "HUMANLAYER_API_KEY is not set"; \
exit 1; \
fi
@if [ -z "${OPENAI_API_KEY}" ]; then \
echo "OPENAI_API_KEY is not set"; \
exit 1; \
fi
@if [ -z "${ANTHROPIC_API_KEY}" ]; then \
echo "ANTHROPIC_API_KEY is not set"; \
exit 1; \
fi
@echo "Keys are set"

##@ Cluster Management

cluster-up: ## Create the Kind cluster
Expand Down
8 changes: 8 additions & 0 deletions acp/.gitignore
Original file line number Diff line number Diff line change
Expand Up @@ -32,3 +32,11 @@ go.work
# macOS system files
.DS_Store
**/.DS_Store

# Generated mock files
**/mocks/
internal/**/mocks/
internal/controller/toolcall/services/mocks/
internal/humanlayer/mocks/
internal/llmclient/mocks/
internal/mcpmanager/mocks/
36 changes: 31 additions & 5 deletions acp/Makefile
Original file line number Diff line number Diff line change
Expand Up @@ -93,12 +93,29 @@ lint-fix: golangci-lint ## Run golangci-lint linter and perform fixes
lint-config: golangci-lint ## Verify golangci-lint linter configuration
$(GOLANGCI_LINT) config verify

.PHONY: ask-dex
ask-dex: ## Ask Dex a question about the project
cd hack/ask-dex && bun ask-dex.js $(filter-out $@,$(MAKECMDGOALS))

.PHONY: mocks
mocks: mockgen ## Generate all mocks using mockgen
@echo "Generating mocks..."
$(MOCKGEN) -source=internal/humanlayer/hlclient.go -destination=internal/humanlayer/mocks/mock_hlclient.go -package=mocks
$(MOCKGEN) -source=internal/llmclient/llm_client.go -destination=internal/llmclient/mocks/mock_llm_client.go -package=mocks
$(MOCKGEN) -source=internal/mcpmanager/mcpmanager.go -destination=internal/mcpmanager/mocks/mock_mcpmanager.go -package=mocks
@echo "Mock generation complete"

.PHONY: clean-mocks
clean-mocks: ## Remove all generated mock files
@echo "Cleaning mocks..."
rm -rf internal/humanlayer/mocks/
rm -rf internal/llmclient/mocks/
rm -rf internal/mcpmanager/mocks/
@echo "Mock cleanup complete"
##@ Build

.PHONY: deps
deps: ## Install dependencies
go mod tidy
go mod download
go mod verify

.PHONY: build
build: manifests generate fmt vet ## Build manager binary.
go build -o bin/manager cmd/main.go
Expand Down Expand Up @@ -192,10 +209,11 @@ deploy: manifests docker-build kustomize ## Deploy controller to the K8s cluster
cd config/manager && $(KUSTOMIZE) edit set image controller=${IMG}
$(KUSTOMIZE) build config/default | $(KUBECTL) apply -f -

namespace ?= default
.PHONY: deploy-local-kind
deploy-local-kind: manifests docker-build docker-load-kind kustomize ## Deploy controller to the K8s cluster specified in ~/.kube/config.
cd config/localdev && $(KUSTOMIZE) edit set image controller=${IMG}
$(KUSTOMIZE) build config/localdev | $(KUBECTL) apply -f -
$(KUSTOMIZE) build config/localdev | $(KUBECTL) apply -f - --namespace=$(namespace)

.PHONY: deploy-samples
deploy-samples: kustomize ## Deploy samples to the K8s cluster specified in ~/.kube/config.
Expand Down Expand Up @@ -232,6 +250,7 @@ KUSTOMIZE ?= $(LOCALBIN)/kustomize
CONTROLLER_GEN ?= $(LOCALBIN)/controller-gen
ENVTEST ?= $(LOCALBIN)/setup-envtest
GOLANGCI_LINT = $(LOCALBIN)/golangci-lint
MOCKGEN = $(LOCALBIN)/mockgen

## Tool Versions
KUSTOMIZE_VERSION ?= v5.5.0
Expand All @@ -241,6 +260,7 @@ ENVTEST_VERSION ?= $(shell go list -m -f "{{ .Version }}" sigs.k8s.io/controller
#ENVTEST_K8S_VERSION is the version of Kubernetes to use for setting up ENVTEST binaries (i.e. 1.31)
ENVTEST_K8S_VERSION ?= $(shell go list -m -f "{{ .Version }}" k8s.io/api | awk -F'[v.]' '{printf "1.%d", $$3}')
GOLANGCI_LINT_VERSION ?= v1.63.4
MOCKGEN_VERSION ?= v0.5.0

.PHONY: kustomize
kustomize: $(KUSTOMIZE) ## Download kustomize locally if necessary.
Expand Down Expand Up @@ -270,6 +290,11 @@ golangci-lint: $(GOLANGCI_LINT) ## Download golangci-lint locally if necessary.
$(GOLANGCI_LINT): $(LOCALBIN)
$(call go-install-tool,$(GOLANGCI_LINT),github.com/golangci/golangci-lint/cmd/golangci-lint,$(GOLANGCI_LINT_VERSION))

.PHONY: mockgen
mockgen: $(MOCKGEN) ## Download mockgen locally if necessary.
$(MOCKGEN): $(LOCALBIN)
$(call go-install-tool,$(MOCKGEN),go.uber.org/mock/mockgen,$(MOCKGEN_VERSION))

# go-install-tool will 'go install' any package with custom target and name of binary, if it doesn't exist
# $1 - target path with name of binary
# $2 - package url which can be installed
Expand All @@ -282,6 +307,7 @@ echo "Downloading $${package}" ;\
rm -f $(1) || true ;\
GOBIN=$(LOCALBIN) go install $${package} ;\
mv $(1) $(1)-$(3) ;\
chmod 755 $(1)-$(3) ;\
} ;\
ln -sf $(1)-$(3) $(1)
endef
13 changes: 13 additions & 0 deletions acp/README.md
Original file line number Diff line number Diff line change
Expand Up @@ -132,8 +132,21 @@ Run `make help` for more information on all potential `make` targets. Common tar
- `make manifests` - Generate WebhookConfiguration, ClusterRole, and CustomResourceDefinition objects
- `make generate` - Generate code (DeepCopy methods)
- `make test` - Run tests
- `make mocks` - Generate mock implementations for testing (not committed to git)
- `make docker-build` - Build the Docker image

#### Mock Generation

The project uses generated mocks for testing interfaces. Mock files are automatically generated via `make mocks` and are **not committed to version control**. They are recreated locally as needed for testing.

```sh
# Generate all mock files
make mocks

# Clean and regenerate mocks
make clean-mocks && make mocks
```

### Resources

- [Kubebuilder Book](https://book.kubebuilder.io/introduction.html) - Official Kubebuilder documentation
Expand Down
11 changes: 6 additions & 5 deletions acp/cmd/main.go
Original file line number Diff line number Diff line change
Expand Up @@ -240,11 +240,12 @@ func main() {
// Create a shared MCPManager that all controllers will use
mcpManagerInstance := mcpmanager.NewMCPServerManagerWithClient(mgr.GetClient())

if err = (&agent.AgentReconciler{
Client: mgr.GetClient(),
Scheme: mgr.GetScheme(),
MCPManager: mcpManagerInstance,
}).SetupWithManager(mgr); err != nil {
agentReconciler, err := agent.NewAgentReconcilerForManager(mgr)
if err != nil {
setupLog.Error(err, "unable to create agent reconciler")
os.Exit(1)
}
if err = agentReconciler.SetupWithManager(mgr); err != nil {
setupLog.Error(err, "unable to create controller", "controller", "Agent")
os.Exit(1)
}
Expand Down
2 changes: 1 addition & 1 deletion acp/config/localdev/kustomization.yaml
Original file line number Diff line number Diff line change
Expand Up @@ -26,4 +26,4 @@ patches:
images:
- name: controller
newName: controller
newTag: "202505211432"
newTag: "202506131406"
4 changes: 2 additions & 2 deletions acp/config/manager/kustomization.yaml
Original file line number Diff line number Diff line change
Expand Up @@ -5,5 +5,5 @@ apiVersion: kustomize.config.k8s.io/v1beta1
kind: Kustomization
images:
- name: controller
newName: ghcr.io/humanlayer/agentcontrolplane
newTag: v0.6.1
newName: example.com/acp
newTag: v0.0.1
Loading
Loading