Documentation
¶
Overview ¶
Copyright © 2025 Sun Asterisk Inc.
Permission is hereby granted, free of charge, to any person obtaining a copy of this software and associated documentation files (the "Software"), to deal in the Software without restriction, including without limitation the rights to use, copy, modify, merge, publish, distribute, sublicense, and/or sell copies of the Software, and to permit persons to whom the Software is furnished to do so, subject to the following conditions:
The above copyright notice and this permission notice shall be included in all copies or substantial portions of the Software.
THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY, FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM, OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE SOFTWARE.
Index ¶
- Constants
- Variables
- func CleanupPartial(targetDir string) error
- func Download(url, checksum string, progress ProgressCallback) (string, error)
- func Extract(zipPath, targetDir string) error
- func ExtractWithMerge(zipPath, targetDir string) error
- func MergeGitignoreFiles(existingPath, templatePath string) error
- func MergeJSONFiles(existingPath, templatePath string) error
- func UpdateAIToolConfig(aiTool, projectDir, githubToken, mcpServerEndpoint string) error
- type Cache
- func (c *Cache) Clear() error
- func (c *Cache) Get(aiTool string, ttl time.Duration) (*CacheEntry, error)
- func (c *Cache) GetCachedFile(aiTool string) (io.ReadCloser, error)
- func (c *Cache) List() []CacheEntry
- func (c *Cache) Prune(ttl time.Duration) error
- func (c *Cache) Put(aiTool, version, originalURL string, data []byte) error
- func (c *Cache) Remove(aiTool string) error
- func (c *Cache) Size() int64
- func (c *Cache) VerifyIntegrity() (bool, []string)
- type CacheEntry
- type CacheIndex
- type ClaudeMCPConfig
- type ClaudeMCPServer
- type ConfigUpdater
- type MergeType
- type ProgressCallback
Constants ¶
const DefaultCacheTTL = 24 * time.Hour
DefaultCacheTTL is the default time-to-live for cached templates
Variables ¶
var MergeableFiles = map[string]MergeType{ ".vscode/settings.json": MergeTypeJSON, ".mcp.json": MergeTypeJSON, ".gitignore": MergeTypeGitignore, }
MergeableFiles defines which files should be merged instead of overwritten
Functions ¶
func CleanupPartial ¶
CleanupPartial removes partially extracted files on error
func Download ¶
func Download(url, checksum string, progress ProgressCallback) (string, error)
Download downloads a template from the given URL
func ExtractWithMerge ¶ added in v0.2.3
ExtractWithMerge extracts a ZIP file to the target directory, merging config files instead of overwriting
func MergeGitignoreFiles ¶ added in v0.2.3
MergeGitignoreFiles appends unique lines from template .gitignore to existing .gitignore
func MergeJSONFiles ¶ added in v0.2.3
MergeJSONFiles performs a deep merge of template JSON into existing JSON file Template values are merged into existing values using deep merge strategy
func UpdateAIToolConfig ¶
UpdateAIToolConfig updates the AI tool config with GitHub token This is the main entry point that delegates to the specific updater
Types ¶
type Cache ¶
type Cache struct {
// contains filtered or unexported fields
}
Cache manages template caching for offline mode
func (*Cache) GetCachedFile ¶
func (c *Cache) GetCachedFile(aiTool string) (io.ReadCloser, error)
GetCachedFile returns an io.ReadCloser for a cached template
func (*Cache) VerifyIntegrity ¶
VerifyIntegrity checks that all cached files match their recorded checksums
type CacheEntry ¶
type CacheEntry struct {
AITool string `json:"ai_tool"`
Version string `json:"version"`
Checksum string `json:"checksum"`
CachedAt time.Time `json:"cached_at"`
FilePath string `json:"file_path"`
OriginalURL string `json:"original_url"`
Size int64 `json:"size"`
}
CacheEntry represents a cached template
type CacheIndex ¶
type CacheIndex struct {
Version string `json:"version"`
Entries map[string]CacheEntry `json:"entries"` // Key is AI tool name
UpdatedAt time.Time `json:"updated_at"`
}
CacheIndex represents the cache index file
type ClaudeMCPConfig ¶
type ClaudeMCPConfig struct {
Servers map[string]ClaudeMCPServer `json:"mcpServers"`
}
ClaudeMCPConfig represents the structure of Claude's .mcp.json file
type ClaudeMCPServer ¶
type ClaudeMCPServer struct {
Type string `json:"type"`
URL string `json:"url"`
Headers map[string]string `json:"headers"`
}
ClaudeMCPServer represents a Claude MCP server configuration
type ConfigUpdater ¶
type ConfigUpdater interface {
ConfigureMCPServer(projectDir, githubToken, mcpServerEndpoint string) error
}
ConfigUpdater defines the interface for updating AI tool specific configs
func GetConfigUpdater ¶
func GetConfigUpdater(aiTool string) ConfigUpdater
GetConfigUpdater returns the appropriate config updater for the given AI tool
type MergeType ¶ added in v0.2.3
type MergeType int
MergeType defines how to merge a specific file type
func ShouldMerge ¶ added in v0.2.3
ShouldMerge checks if a file should be merged based on its relative path
type ProgressCallback ¶
type ProgressCallback func(downloaded, total int64)
ProgressCallback is a function called to report download progress