Skip to content

feat: add Jungian Intelligence Layer service v3.2.0#7

Open
ckaraca wants to merge 1 commit intomainfrom
feature/jungian-intelligence-layer
Open

feat: add Jungian Intelligence Layer service v3.2.0#7
ckaraca wants to merge 1 commit intomainfrom
feature/jungian-intelligence-layer

Conversation

@ckaraca
Copy link
Copy Markdown
Contributor

@ckaraca ckaraca commented Mar 2, 2026

Summary

  • Adds JungianService class exposed as client.jungian.*
  • Methods: searchWithContext(), getIndividuationScore(), getIndividuationHistory(), getSynchronicityPatterns(), getDreamHistory()

Test plan

  • Run npm run build to verify compilation
  • Verify all 5 methods call correct API endpoints
  • Test type exports are accessible from package entry point

Summary by Sourcery

Add a new Jungian intelligence service to the client SDK for accessing archetype-aware memory and individuation insights.

New Features:

  • Introduce JungianService with methods for archetype-aware search, individuation scoring and history, synchronicity patterns, and dream history retrieval.
  • Expose Jungian intelligence types and JungianService through the main package entry point and PluggedInClient API.

Add JungianService with 5 methods: searchWithContext,
getIndividuationScore, getIndividuationHistory,
getSynchronicityPatterns, getDreamHistory. Includes
new types for archetypes, individuation, synchronicity,
and dream consolidation.
@sourcery-ai
Copy link
Copy Markdown

sourcery-ai bot commented Mar 2, 2026

Reviewer's Guide

Adds a new JungianService to the SDK, wires it into the main client and package exports, and defines the associated Jungian Intelligence TypeScript types for individuation, archetypal search, synchronicity patterns, and dream history responses.

Sequence diagram for client.jungian.getDreamHistory call

sequenceDiagram
  actor Developer
  participant PluggedInClient
  participant JungianService
  participant AxiosInstance
  participant PluggedInAPI

  Developer->>PluggedInClient: new PluggedInClient(config)
  PluggedInClient->>PluggedInClient: createAxiosInstance()
  PluggedInClient->>JungianService: new JungianService(axios, config)
  PluggedInClient->>JungianService: jungian.getDreamHistory()
  JungianService->>AxiosInstance: get(/api/memory/dream/history)
  AxiosInstance->>PluggedInAPI: HTTP GET /api/memory/dream/history
  PluggedInAPI-->>AxiosInstance: 200 OK DreamConsolidation[]
  AxiosInstance-->>JungianService: data: DreamConsolidation[]
  JungianService-->>PluggedInClient: Promise(DreamConsolidation[])
  PluggedInClient-->>Developer: DreamConsolidation[]
Loading

Class diagram for JungianService and Jungian Intelligence types

classDiagram
  class PluggedInClient {
    - AxiosInstance axios
    - Required_ClientConfig_ config
    + PluggedInClient(config: ClientConfig)
    + jungian: JungianService
  }

  class JungianService {
    - AxiosInstance axios
    - Required_ClientConfig_ config
    + JungianService(axios: AxiosInstance, config: Required_ClientConfig_)
    + searchWithContext(query: string, toolName: string, outcome: string, includeArchetypes: boolean): Promise~ArchetypeSearchResponse~
    + getIndividuationScore(): Promise~IndividuationResponse~
    + getIndividuationHistory(days: number): Promise~IndividuationResponse[]~
    + getSynchronicityPatterns(): Promise~SynchronicityPattern[]~
    + getDreamHistory(): Promise~DreamConsolidation[]~
  }

  class IndividuationResponse {
    + total: number
    + level: string
    + weeklyTrend: string
    + tip: string
    + components_memoryDepth: number
    + components_learningVelocity: number
    + components_collectiveContribution: number
    + components_selfAwareness: number
  }

  class ArchetypedPattern {
    + uuid: string
    + archetype: string
    + archetypeLabel: string
    + archetypeWeight: number
    + patternType: string
    + description: string
    + pattern: string
    + confidence: number
    + similarity: number
  }

  class ArchetypeSearchResponse {
    + patterns: ArchetypedPattern[]
  }

  class SynchronicityPattern {
    + uuid: string
    + patternType: string
    + description: string
    + confidence: number
    + uniqueProfiles: number
  }

  class DreamConsolidation {
    + uuid: string
    + sourceCount: number
    + tokenSavings: number
    + clusterSimilarity: number
    + createdAt: string
  }

  PluggedInClient --> JungianService
  JungianService --> IndividuationResponse
  JungianService --> ArchetypeSearchResponse
  JungianService --> SynchronicityPattern
  JungianService --> DreamConsolidation
  ArchetypeSearchResponse --> ArchetypedPattern
Loading

File-Level Changes

Change Details Files
Introduce Jungian Intelligence domain types for individuation, archetype search, synchronicity patterns, and dream consolidation responses.
  • Add IndividuationResponse interface capturing overall individuation metrics and component scores.
  • Add ArchetypedPattern and ArchetypeSearchResponse interfaces to model archetype-enriched search results.
  • Add SynchronicityPattern interface for cross-profile synchronicity patterns.
  • Add DreamConsolidation interface for dream consolidation history items.
src/types/index.ts
Export Jungian service and related types from the package entry point so consumers can access them directly.
  • Export JungianService from the main index so it becomes part of the public API surface.
  • Export new Jungian Intelligence response types from the types barrel in the main index.
src/index.ts
Wire JungianService into the API client and implement Jungian Intelligence endpoints.
  • Instantiate and expose a jungian property on PluggedInClient that provides access to JungianService methods.
  • Implement JungianService class with methods for archetype-aware memory search, individuation score and history retrieval, synchronicity pattern retrieval, and dream history retrieval.
  • Map each JungianService method to its corresponding REST endpoint using the shared Axios instance and client config.
src/client.ts
src/services/jungian.ts

Tips and commands

Interacting with Sourcery

  • Trigger a new review: Comment @sourcery-ai review on the pull request.
  • Continue discussions: Reply directly to Sourcery's review comments.
  • Generate a GitHub issue from a review comment: Ask Sourcery to create an
    issue from a review comment by replying to it. You can also reply to a
    review comment with @sourcery-ai issue to create an issue from it.
  • Generate a pull request title: Write @sourcery-ai anywhere in the pull
    request title to generate a title at any time. You can also comment
    @sourcery-ai title on the pull request to (re-)generate the title at any time.
  • Generate a pull request summary: Write @sourcery-ai summary anywhere in
    the pull request body to generate a PR summary at any time exactly where you
    want it. You can also comment @sourcery-ai summary on the pull request to
    (re-)generate the summary at any time.
  • Generate reviewer's guide: Comment @sourcery-ai guide on the pull
    request to (re-)generate the reviewer's guide at any time.
  • Resolve all Sourcery comments: Comment @sourcery-ai resolve on the
    pull request to resolve all Sourcery comments. Useful if you've already
    addressed all the comments and don't want to see them anymore.
  • Dismiss all Sourcery reviews: Comment @sourcery-ai dismiss on the pull
    request to dismiss all existing Sourcery reviews. Especially useful if you
    want to start fresh with a new review - don't forget to comment
    @sourcery-ai review to trigger a new review!

Customizing Your Experience

Access your dashboard to:

  • Enable or disable review features such as the Sourcery-generated pull request
    summary, the reviewer's guide, and others.
  • Change the review language.
  • Add, remove or edit custom review instructions.
  • Adjust other review settings.

Getting Help

@gemini-code-assist
Copy link
Copy Markdown

Summary of Changes

Hello, I'm Gemini Code Assist1! I'm currently reviewing this pull request and will post my feedback shortly. In the meantime, here's a summary to help you and other reviewers quickly get up to speed!

This pull request introduces the Jungian Intelligence Layer service, significantly expanding the client's capabilities. It provides a new set of advanced psychological and analytical tools, allowing users to interact with features such as archetype-contextualized memory search, individuation score tracking, synchronicity pattern analysis, and dream history retrieval, all accessible through a dedicated client.jungian interface.

Highlights

  • New Service Addition: The JungianService class has been added to provide functionalities related to Jungian Intelligence.
  • Client Integration: The new JungianService is exposed through the main client as client.jungian.*, making its methods easily accessible.
  • New Methods: Five new methods are introduced: searchWithContext(), getIndividuationScore(), getIndividuationHistory(), getSynchronicityPatterns(), and getDreamHistory().
  • Type Definitions: New TypeScript interfaces have been defined to support the data structures returned by the Jungian Intelligence API endpoints.
Changelog
  • src/client.ts
    • Imported JungianService.
    • Added a public readonly jungian: JungianService; property to the PluggedInClient class.
    • Instantiated JungianService within the PluggedInClient constructor.
  • src/index.ts
    • Exported JungianService.
    • Exported new Jungian Intelligence related types including IndividuationResponse, ArchetypedPattern, ArchetypeSearchResponse, SynchronicityPattern, and DreamConsolidation.
  • src/services/jungian.ts
    • Added a new file defining the JungianService class.
    • Implemented searchWithContext method for archetype context injection.
    • Implemented getIndividuationScore method to retrieve the current individuation score.
    • Implemented getIndividuationHistory method to fetch historical individuation scores.
    • Implemented getSynchronicityPatterns method to get synchronicity patterns.
    • Implemented getDreamHistory method to retrieve dream consolidation history.
  • src/types/index.ts
    • Added IndividuationResponse interface.
    • Added ArchetypedPattern interface.
    • Added ArchetypeSearchResponse interface.
    • Added SynchronicityPattern interface.
    • Added DreamConsolidation interface.
Activity
  • No activity has occurred on this pull request yet.
Using Gemini Code Assist

The full guide for Gemini Code Assist can be found on our documentation page, here are some quick tips.

Invoking Gemini

You can request assistance from Gemini at any point by creating a comment using either /gemini <command> or @gemini-code-assist <command>. Below is a summary of the supported commands on the current page.

Feature Command Description
Code Review /gemini review Performs a code review for the current pull request in its current state.
Pull Request Summary /gemini summary Provides a summary of the current pull request in its current state.
Comment @gemini-code-assist Responds in comments when explicitly tagged, both in pull request comments and review comments.
Help /gemini help Displays a list of available commands.

Customization

To customize Gemini Code Assist for GitHub experience, repository maintainers can create a configuration file and/or provide a custom code review style guide (such as PEP-8 for Python) by creating and adding files to a .gemini/ folder in the base of the repository. Detailed instructions can be found here.

Limitations & Feedback

Gemini Code Assist may make mistakes. Please leave feedback on any instances where its feedback is incorrect or counter productive. You can react with 👍 and 👎 on @gemini-code-assist comments. If you're interested in giving your feedback about your experience with Gemini Code Assist for Github and other Google products, sign up here.

You can also get AI-powered code generation, chat, as well as code reviews directly in the IDE at no cost with the Gemini Code Assist IDE Extension.

Footnotes

  1. Review the Privacy Notices, Generative AI Prohibited Use Policy, Terms of Service, and learn how to configure Gemini Code Assist in GitHub here. Gemini can make mistakes, so double check it and use code with caution.

Copy link
Copy Markdown

@sourcery-ai sourcery-ai bot left a comment

Choose a reason for hiding this comment

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

Hey - I've found 2 issues, and left some high level feedback:

  • The includeArchetypes parameter in searchWithContext is accepted in the method signature but never sent to the API; either wire it into the request body/query or remove it from the public interface to avoid confusion.
  • The config: Required<ClientConfig> constructor parameter in JungianService is currently unused; consider either removing it or leveraging it (e.g., for base URL or headers) to avoid dead code.
  • In getIndividuationHistory, the days argument is always included in params even when undefined; consider building the params object conditionally so you don’t send days: undefined to the API.
Prompt for AI Agents
Please address the comments from this code review:

## Overall Comments
- The `includeArchetypes` parameter in `searchWithContext` is accepted in the method signature but never sent to the API; either wire it into the request body/query or remove it from the public interface to avoid confusion.
- The `config: Required<ClientConfig>` constructor parameter in `JungianService` is currently unused; consider either removing it or leveraging it (e.g., for base URL or headers) to avoid dead code.
- In `getIndividuationHistory`, the `days` argument is always included in `params` even when `undefined`; consider building the `params` object conditionally so you don’t send `days: undefined` to the API.

## Individual Comments

### Comment 1
<location path="src/services/jungian.ts" line_range="19-23" />
<code_context>
+  /**
+   * Search memory with archetype context injection
+   */
+  async searchWithContext(params: {
+    query: string;
+    toolName?: string;
+    outcome?: string;
+    includeArchetypes?: boolean;
+  }): Promise<ArchetypeSearchResponse> {
+    const { data } = await this.axios.post('/api/memory/archetype/inject', {
</code_context>
<issue_to_address>
**issue (bug_risk):** `includeArchetypes` parameter is unused in the request

This flag is accepted in `searchWithContext` but never included in the request to `/api/memory/archetype/inject`. If the backend supports controlling archetype inclusion, this is a functional gap; if not, the parameter should be removed to avoid a misleading API surface.
</issue_to_address>

### Comment 2
<location path="src/services/jungian.ts" line_range="11-13" />
<code_context>
+} from '../types';
+
+export class JungianService {
+  constructor(
+    private axios: AxiosInstance,
+    private config: Required<ClientConfig>
+  ) {}
+
</code_context>
<issue_to_address>
**suggestion:** `config` is stored but never used in `JungianService`

`config` is stored but never read. If it isn’t needed (e.g., for base URL or headers), remove it from the constructor and class to avoid dead state and lint warnings. If it will be needed later, consider wiring it into at least one code path now (e.g., via a helper) so it isn’t effectively unused.

Suggested implementation:

```typescript
export class JungianService {
  constructor(private axios: AxiosInstance) {}

```

Anywhere `JungianService` is instantiated, update the constructor calls to pass only the `AxiosInstance` and remove the `config` argument, e.g. change `new JungianService(axios, config)` to `new JungianService(axios)`. If any fields or methods in this file referenced `this.config`, those references should also be removed or refactored accordingly.
</issue_to_address>

Sourcery is free for open source - if you like our reviews please consider sharing them ✨
Help me be more useful! Please click 👍 or 👎 on each comment and I'll use the feedback to improve your reviews.

Comment on lines +19 to +23
async searchWithContext(params: {
query: string;
toolName?: string;
outcome?: string;
includeArchetypes?: boolean;
Copy link
Copy Markdown

Choose a reason for hiding this comment

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

issue (bug_risk): includeArchetypes parameter is unused in the request

This flag is accepted in searchWithContext but never included in the request to /api/memory/archetype/inject. If the backend supports controlling archetype inclusion, this is a functional gap; if not, the parameter should be removed to avoid a misleading API surface.

Comment on lines +11 to +13
constructor(
private axios: AxiosInstance,
private config: Required<ClientConfig>
Copy link
Copy Markdown

Choose a reason for hiding this comment

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

suggestion: config is stored but never used in JungianService

config is stored but never read. If it isn’t needed (e.g., for base URL or headers), remove it from the constructor and class to avoid dead state and lint warnings. If it will be needed later, consider wiring it into at least one code path now (e.g., via a helper) so it isn’t effectively unused.

Suggested implementation:

export class JungianService {
  constructor(private axios: AxiosInstance) {}

Anywhere JungianService is instantiated, update the constructor calls to pass only the AxiosInstance and remove the config argument, e.g. change new JungianService(axios, config) to new JungianService(axios). If any fields or methods in this file referenced this.config, those references should also be removed or refactored accordingly.

@claude
Copy link
Copy Markdown

claude bot commented Mar 2, 2026

PR Review: feat: add Jungian Intelligence Layer service v3.2.0

Overall the structure is clean and consistent with the existing service pattern. A few issues need attention before merging.


Bugs

includeArchetypes is silently ignored (src/services/jungian.ts, line 23 / 25–29)

The includeArchetypes parameter is declared in the method signature but never included in the POST body:

async searchWithContext(params: {
  query: string;
  toolName?: string;
  outcome?: string;
  includeArchetypes?: boolean;  // declared...
}): Promise<ArchetypeSearchResponse> {
  const { data } = await this.axios.post('/api/memory/archetype/inject', {
    query: params.query,
    tool_name: params.toolName,
    outcome: params.outcome,
    // ...but never sent!
  });

Either remove it from the interface or forward it: include_archetypes: params.includeArchetypes.


Type Safety

Missing generic type parameters on axios calls (src/services/jungian.ts)

Every other service in this codebase passes a type argument to axios, e.g. from agents.ts:

const response = await this.axios.get<Agent[]>('/api/agents');
return response.data;

JungianService skips the generic, so data is any and the declared return type is unenforced:

// current — data is `any`
const { data } = await this.axios.post('/api/memory/archetype/inject', ...);
return data;

// should be
const { data } = await this.axios.post<ArchetypeSearchResponse>('/api/memory/archetype/inject', ...);
return data;

Apply this to all five methods for consistency and compile-time safety.


Missing Tests

There is no test file for JungianService. The only existing test is tests/clipboard.test.ts, and the PR checklist itself calls out verifying the endpoints. Please add tests/jungian.test.ts following the same mocked-axios pattern used in clipboard.test.ts. At minimum, cover:

  • Each of the 5 methods calls the correct endpoint/method
  • getIndividuationHistory forwards the days param correctly
  • searchWithContext sends tool_name and outcome (and include_archetypes once the bug above is fixed)

Minor

ArchetypedPattern naming (src/types/index.ts, line ~420)

Every other type in the codebase uses noun form: Agent, SynchronicityPattern, DreamConsolidation. "Archetyped" (past participle) is unusual and inconsistent. Consider ArchetypePattern to match the rest.

Unused config (src/services/jungian.ts, line 13)

config is stored but never referenced. This is consistent with some other services, so not a blocker — but if it's not needed here, removing it keeps the constructor signature minimal.


Summary

Severity Issue
Bug includeArchetypes param declared but not forwarded to the API
Code quality Axios calls missing generic type parameters
Test coverage No tests added for JungianService
Minor ArchetypedPattern naming inconsistency

The integration wiring (client.ts, index.ts) is correct and clean. Fix the three main issues above and this should be good to merge.

Copy link
Copy Markdown

@gemini-code-assist gemini-code-assist bot left a comment

Choose a reason for hiding this comment

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

Code Review

This pull request introduces a new JungianService to the SDK, exposing several new methods for interacting with a Jungian intelligence layer. The changes include adding the new service, defining its associated types, and integrating it into the main client. My review found a bug where a parameter in searchWithContext was not being used, and an inconsistency in date type handling in getDreamHistory compared to the rest of the SDK. I've provided suggestions to fix these issues.

Comment on lines +26 to +28
query: params.query,
tool_name: params.toolName,
outcome: params.outcome,
Copy link
Copy Markdown

Choose a reason for hiding this comment

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

high

The includeArchetypes parameter is defined in the method signature but is not being passed to the API. This means the feature to include archetypes in the search context is not functional. The API likely expects this parameter as include_archetypes.

      query: params.query,
      tool_name: params.toolName,
      outcome: params.outcome,
      include_archetypes: params.includeArchetypes

Comment on lines +63 to +64
const { data } = await this.axios.get('/api/memory/dream/history');
return data;
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

To align with the recommended change in the DreamConsolidation interface (changing createdAt to a Date type), this method should transform the string date received from the API into a Date object.

    const { data } = await this.axios.get('/api/memory/dream/history');
    return (data as any[]).map((d) => ({ ...d, createdAt: new Date(d.createdAt) }));

sourceCount: number;
tokenSavings: number;
clusterSimilarity: number;
createdAt: string;
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 consistency across the SDK, timestamp fields should use the Date type instead of string. Other interfaces like Document and ClipboardEntry already follow this pattern. This provides a more consistent and developer-friendly API.

Suggested change
createdAt: string;
createdAt: Date;

Comment on lines +23 to +29
includeArchetypes?: boolean;
}): Promise<ArchetypeSearchResponse> {
const { data } = await this.axios.post('/api/memory/archetype/inject', {
query: params.query,
tool_name: params.toolName,
outcome: params.outcome,
});
Copy link
Copy Markdown

Choose a reason for hiding this comment

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

Bug: The includeArchetypes parameter in the searchWithContext method is defined but is never used in the API request, so it has no effect.
Severity: MEDIUM

Suggested Fix

Update the searchWithContext method to include the includeArchetypes parameter in the data payload of the axios.post call. This will ensure the backend API receives the parameter and can modify its response accordingly, aligning its behavior with the function's signature.

Prompt for AI Agent
Review the code at the location below. A potential bug has been identified by an AI
agent.
Verify if this is a real issue. If it is, propose a fix; if not, explain why it's not
valid.

Location: src/services/jungian.ts#L23-L29

Potential issue: The `searchWithContext` method in `JungianService` defines an optional
boolean parameter `includeArchetypes`. However, this parameter is never actually used in
the body of the `axios.post` request sent to the API. Only the `query`, `tool_name`, and
`outcome` fields are passed. This is inconsistent with other services in the codebase
where optional parameters are explicitly included in API calls. Consequently, callers
who set `includeArchetypes` to `true` or `false` will find the parameter is silently
ignored, and the API's behavior will not change as expected.

Did we get this right? 👍 / 👎 to inform future reviews.

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

None yet

Projects

None yet

Development

Successfully merging this pull request may close these issues.

1 participant