Initialize narratio Go module and CLI scaffold

This commit is contained in:
2026-05-02 10:37:38 -05:00
parent 48c51e1c77
commit 902e6bc994
42 changed files with 1486 additions and 1 deletions

View File

@@ -0,0 +1,24 @@
package artifacts
import (
"crypto/sha256"
"encoding/hex"
"io"
"os"
)
// SHA256File returns the SHA-256 hex digest of a file.
func SHA256File(path string) (string, error) {
f, err := os.Open(path)
if err != nil {
return "", err
}
defer f.Close()
h := sha256.New()
if _, err := io.Copy(h, f); err != nil {
return "", err
}
return hex.EncodeToString(h.Sum(nil)), nil
}

View File

@@ -0,0 +1,2 @@
// Package artifacts defines artifact references and storage contracts.
package artifacts

View File

@@ -0,0 +1,31 @@
package artifacts
import (
"context"
"fmt"
)
// LocalStore is a placeholder local filesystem artifact store.
type LocalStore struct {
RootDir string
}
// WriteLocal returns a not-yet-implemented error in the scaffold.
func (s *LocalStore) WriteLocal(_ context.Context, _ Ref, _ []byte) error {
return fmt.Errorf("artifacts local write: not yet implemented")
}
// ReadLocal returns a not-yet-implemented error in the scaffold.
func (s *LocalStore) ReadLocal(_ context.Context, _ Ref) ([]byte, error) {
return nil, fmt.Errorf("artifacts local read: not yet implemented")
}
// ExistsLocal returns a not-yet-implemented error in the scaffold.
func (s *LocalStore) ExistsLocal(_ context.Context, _ Ref) (bool, error) {
return false, fmt.Errorf("artifacts local exists: not yet implemented")
}
// Upload returns a not-yet-implemented error in the scaffold.
func (s *LocalStore) Upload(_ context.Context, _ Ref) (string, error) {
return "", fmt.Errorf("artifacts local upload: not yet implemented")
}

View File

@@ -0,0 +1,8 @@
package artifacts
import "path/filepath"
// SessionWorkDir returns the work directory for one session.
func SessionWorkDir(rootDir, sessionID string) string {
return filepath.Join(rootDir, "work", sessionID)
}

32
internal/artifacts/s3.go Normal file
View File

@@ -0,0 +1,32 @@
package artifacts
import (
"context"
"fmt"
)
// S3Store is a placeholder S3-compatible artifact store.
type S3Store struct {
Bucket string
Prefix string
}
// WriteLocal returns a not-yet-implemented error in the scaffold.
func (s *S3Store) WriteLocal(_ context.Context, _ Ref, _ []byte) error {
return fmt.Errorf("artifacts s3 write local: not yet implemented")
}
// ReadLocal returns a not-yet-implemented error in the scaffold.
func (s *S3Store) ReadLocal(_ context.Context, _ Ref) ([]byte, error) {
return nil, fmt.Errorf("artifacts s3 read local: not yet implemented")
}
// ExistsLocal returns a not-yet-implemented error in the scaffold.
func (s *S3Store) ExistsLocal(_ context.Context, _ Ref) (bool, error) {
return false, fmt.Errorf("artifacts s3 exists local: not yet implemented")
}
// Upload returns a not-yet-implemented error in the scaffold.
func (s *S3Store) Upload(_ context.Context, _ Ref) (string, error) {
return "", fmt.Errorf("artifacts s3 upload: not yet implemented")
}

View File

@@ -0,0 +1,19 @@
package artifacts
import "context"
// Ref identifies a pipeline artifact and optional remote location.
type Ref struct {
Kind string
LocalPath string
RemoteKey string
Checksum string
}
// Store is a placeholder artifact storage abstraction.
type Store interface {
WriteLocal(ctx context.Context, ref Ref, data []byte) error
ReadLocal(ctx context.Context, ref Ref) ([]byte, error)
ExistsLocal(ctx context.Context, ref Ref) (bool, error)
Upload(ctx context.Context, ref Ref) (string, error)
}