-
Minimum necessary changes only
- Change only what's explicitly required. No refactoring adjacent code, no adding comments/docs, no "improvements" beyond scope.
- Read existing code before modifying it. Follow existing patterns in the file.
-
Review marker requirement (MANDATORY) After modifying ANY source file, append this marker as the LAST line:
- Go files (.go):
// AGENT_MODIFIED: Human review required before merge - Markdown (.md):
<!-- AGENT_MODIFIED: Human review required before merge --> - YAML (.yaml, .yml):
# AGENT_MODIFIED: Human review required before merge - Shell (.sh):
# AGENT_MODIFIED: Human review required before merge - Dockerfile:
# AGENT_MODIFIED: Human review required before merge
DO NOT add markers to:
- Binary files
- Generated files (*.pb.go, go.sum, package-lock.json)
- Vendored dependencies (/vendor/)
- Files you only read but didn't modify
Humans will remove these markers as they review each file. PRs with remaining markers will be rejected by CI.
- Go files (.go):
-
License header requirement (MANDATORY for Go files) Every
.gofile must start with the Apache 2.0 license header. CI enforces this viaaddlicenseand will block the PR if missing.// Copyright 2024 The KitOps Authors. // // Licensed under the Apache License, Version 2.0 (the "License"); // you may not use this file except in compliance with the License. // You may obtain a copy of the License at // // http://www.apache.org/licenses/LICENSE-2.0 // // Unless required by applicable law or agreed to in writing, software // distributed under the License is distributed on an "AS IS" BASIS, // WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. // See the License for the specific language governing permissions and // limitations under the License. // // SPDX-License-Identifier: Apache-2.0
When creating new
.gofiles, add this header before thepackagedeclaration. To fix missing headers in bulk:go install github.com/google/addlicense@latest addlicense -s -l apache -c "The KitOps Authors." $(find . -name '*.go')
-
Do not update
cli-reference.mdfile The filedocs/src/docs/cli/cli-reference.mdcontains the CLI reference documentation for the current release of the Kit CLI, and should only be updated on full releases of the CLI -- not in Pull Requests or regular commits. The script atdocs/src/docs/cli/generate.shautomatically regenerates this file and is run as part of the release workflow. It should not be used when making changes this repository.
Before reviewing code, search the entire PR for AGENT_MODIFIED. If any markers are found, reject immediately — all modified files must be human-reviewed and markers removed before merge.
- Evidence over speculation: Every issue must cite specific code locations and concrete failure conditions. No hypothetical "this could be a problem" without a demonstrable trigger.
- Disprove yourself first: Before reporting an issue, search for mitigations — check callers, defensive code in parent functions, and similar patterns elsewhere in the codebase.
- Compare intent vs. outcome: Read the PR description. Flag mismatches between stated goals and actual changes.
- Severity requires confidence: Only mark critical if you have high confidence AND it breaks core functionality or security. Uncertain issues are suggestions, not blockers.
- Path traversal in tar layers: Verify
filesystem.VerifySubpath()is used. Check that archive entries can't escape the context/unpack directory via../or absolute paths. - CWD assumptions: Code in pack/unpack/import runs after
os.Chdir— verify paths are correct relative to the shifted working directory. - OCI spec compliance: Layers, manifests, and media types must conform to the OCI and ModelKit specification.
- Registry credential handling: Auth tokens and credentials in
pkg/lib/network/must not leak into logs or error messages. - Symlink safety: File operations in
pkg/lib/filesystem/must not follow symlinks outside the context directory.
Categorize findings as Critical (must fix — breaks functionality or security), Important (should fix), or Suggestion (author's discretion). End with one of: APPROVE, REQUEST CHANGES, or COMMENT.
KitOps is a CNCF open standards project for packaging, versioning, and securely sharing AI/ML projects. Built on the OCI standard, it serves as the reference implementation of the CNCF's ModelPack specification for vendor-neutral AI/ML interchange format.
# Build the CLI
go build -o kit .
# Run tests
go test ./...
# Run specific package tests
go test ./pkg/cmd/pack -v
# Install locally
go install .cd docs
pnpm install
pnpm docs:dev # Development server
pnpm docs:build # Production build
pnpm docs:preview # Preview built docs- Entry point:
main.go→cmd/root.gousing Cobra framework - Commands: Individual CLI commands in
pkg/cmd/{command}/(pack, unpack, push, pull, tag, list, inspect, etc.) - Libraries: Core functionality in
pkg/lib/:kitfile/: Kitfile manifest parsing, validation, and generationrepo/local/&repo/remote/: Repository management for local storage and OCI registriesfilesystem/: File operations, caching, and ignore patternsnetwork/: Authentication and network operations
- ModelKit: Immutable OCI-compatible bundles containing code, models, datasets, and metadata
- Kitfile: YAML manifest format defining ModelKit contents (spec in
pkg/artifact/kitfile.md) - Repository Management: Uses OCI layout for local storage, compatible with container registries
- Documentation: VitePress-based site in
docs/with comprehensive guides and API reference
All commands follow consistent structure:
- Command definition:
pkg/cmd/{command}/cmd.go - Main logic:
pkg/cmd/{command}/{command}.go - Options/configuration in separate files when complex
Pack, unpack, and import all change the process working directory via os.Chdir to simulate tar -C semantics. This ensures relative paths inside OCI tar layers are correct (relative to the context directory, not wherever the user ran kit from).
Where it happens:
pkg/cmd/pack/cmd.go— changes tocontextDir, not restored (CLI exits after)pkg/lib/filesystem/unpack/core.go— changes toUnpackDir, restored via deferpkg/cmd/kitimport/util.go— changes tocontextDir, restored via defer (required on Windows to allow temp dir cleanup)
Rules when modifying pack/unpack/import code:
- Any code running after
os.Chdirin pack operates in the context directory, not the original cwd - If calling pack logic from a library context (not a CLI command that exits), you must save and restore cwd
- New commands that reuse packing internals must account for the cwd shift
filesystem.VerifySubpath()validates that paths stay within bounds after the cwd change — do not bypass it
- Unit tests:
*_test.gofiles alongside source - Integration tests:
testing/directory with comprehensive test data intesting/testdata/ - Test categories include manifest comparison, kitfile generation, pack/unpack workflows
- All CLI output routed through
pkg/output/for consistent formatting and logging - Configuration handled via
pkg/lib/constants/with environment variable support - Caching managed in
pkg/lib/filesystem/cache/