Skip to content
Open
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
2 changes: 2 additions & 0 deletions client.go
Original file line number Diff line number Diff line change
Expand Up @@ -30,6 +30,7 @@ type Client struct {
RAG *RAGService
Uploads *UploadsService
Agents *AgentsService
Jungian *JungianService
}

// NewClient creates a new Plugged.in API client
Expand Down Expand Up @@ -62,6 +63,7 @@ func NewClientWithOptions(apiKey, baseURL string, httpClient *http.Client) *Clie
c.RAG = &RAGService{client: c}
c.Uploads = &UploadsService{client: c}
c.Agents = &AgentsService{client: c}
c.Jungian = &JungianService{client: c}

return c
}
Expand Down
58 changes: 58 additions & 0 deletions jungian.go
Original file line number Diff line number Diff line change
@@ -0,0 +1,58 @@
package pluggedinkit

import (
"context"
"fmt"
"net/url"
)

// JungianService handles Jungian Intelligence Layer operations
type JungianService struct {
client *Client
}

// SearchWithContext performs an archetype-enhanced memory search
func (s *JungianService) SearchWithContext(ctx context.Context, query string, toolName string, outcome string) (*ArchetypeSearchResponse, error) {
body := map[string]interface{}{
"query": query,
"tool_name": toolName,
"outcome": outcome,
}
Comment on lines +16 to +20
Copy link
Copy Markdown

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

medium

For improved type safety and readability, consider using a struct for the request body instead of map[string]interface{}. This makes the request structure explicit and less error-prone. You could use an anonymous struct here:

body := struct {
    Query    string `json:"query"`
    ToolName string `json:"tool_name"`
    Outcome  string `json:"outcome"`
}{
    Query:    query,
    ToolName: toolName,
    Outcome:  outcome,
}

var result ArchetypeSearchResponse
err := s.client.post(ctx, "/api/memory/archetype/inject", body, &result)
return &result, err
}

// GetIndividuationScore returns the current individuation score
func (s *JungianService) GetIndividuationScore(ctx context.Context) (*IndividuationResponse, error) {
var result IndividuationResponse
err := s.client.get(ctx, "/api/memory/individuation", &result)
return &result, err
}

// GetIndividuationHistory returns daily score snapshots for the specified number of days
func (s *JungianService) GetIndividuationHistory(ctx context.Context, days int) ([]IndividuationResponse, error) {
params := url.Values{}
params.Set("history", "true")
params.Set("days", fmt.Sprintf("%d", days))
Copy link
Copy Markdown

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

medium

For converting an integer to a string, strconv.Itoa is generally more idiomatic and can be more performant than fmt.Sprintf. You will need to add "strconv" to your imports.

Suggested change
params.Set("days", fmt.Sprintf("%d", days))
params.Set("days", strconv.Itoa(days))


path := fmt.Sprintf("/api/memory/individuation?%s", params.Encode())

var result []IndividuationResponse
err := s.client.get(ctx, path, &result)
return result, err
}

// GetSynchronicityPatterns returns detected synchronicity patterns
func (s *JungianService) GetSynchronicityPatterns(ctx context.Context) ([]SynchronicityPattern, error) {
var result []SynchronicityPattern
err := s.client.get(ctx, "/api/memory/sync/patterns", &result)
return result, err
}

// GetDreamHistory returns dream consolidation records
func (s *JungianService) GetDreamHistory(ctx context.Context) ([]DreamConsolidation, error) {
var result []DreamConsolidation
err := s.client.get(ctx, "/api/memory/dream/history", &result)
return result, err
}
55 changes: 55 additions & 0 deletions types.go
Original file line number Diff line number Diff line change
Expand Up @@ -331,3 +331,58 @@ type ClipboardDeleteResponse struct {
Deleted bool `json:"deleted,omitempty"`
Error string `json:"error,omitempty"`
}

// --- Jungian Intelligence ---

// IndividuationComponents represents the breakdown of an individuation score
type IndividuationComponents struct {
MemoryDepth int `json:"memoryDepth"`
LearningVelocity int `json:"learningVelocity"`
CollectiveContribution int `json:"collectiveContribution"`
SelfAwareness int `json:"selfAwareness"`
}

// IndividuationResponse represents the individuation score and metadata
type IndividuationResponse struct {
Total int `json:"total"`
Level string `json:"level"`
WeeklyTrend string `json:"weeklyTrend"`
Tip string `json:"tip"`
Components IndividuationComponents `json:"components"`
}

// ArchetypedPattern represents a memory pattern with archetype metadata
type ArchetypedPattern struct {
UUID string `json:"uuid"`
Archetype string `json:"archetype"`
ArchetypeLabel string `json:"archetypeLabel"`
ArchetypeWeight float64 `json:"archetypeWeight"`
PatternType string `json:"patternType"`
Description string `json:"description"`
Pattern string `json:"pattern"`
Confidence float64 `json:"confidence"`
Similarity float64 `json:"similarity"`
}

// ArchetypeSearchResponse represents the response from an archetype-enhanced search
type ArchetypeSearchResponse struct {
Patterns []ArchetypedPattern `json:"patterns"`
}

// SynchronicityPattern represents a detected synchronicity pattern
type SynchronicityPattern struct {
UUID string `json:"uuid"`
PatternType string `json:"patternType"`
Description string `json:"description"`
Confidence float64 `json:"confidence"`
UniqueProfiles int `json:"uniqueProfiles"`
}

// DreamConsolidation represents a dream consolidation record
type DreamConsolidation struct {
UUID string `json:"uuid"`
SourceCount int `json:"sourceCount"`
TokenSavings int `json:"tokenSavings"`
ClusterSimilarity float64 `json:"clusterSimilarity"`
CreatedAt string `json:"createdAt"`
Copy link
Copy Markdown

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

medium

The CreatedAt field is of type string, while other structs in this file (like Document, SearchResult, ClipboardEntry) use time.Time for timestamp fields. To maintain consistency and leverage Go's type system for time-related operations, it's recommended to use time.Time here as well. The encoding/json package can automatically parse RFC3339 formatted date strings into time.Time fields.

Suggested change
CreatedAt string `json:"createdAt"`
CreatedAt time.Time `json:"createdAt"`

}