@claudetools/tools 0.3.7 → 0.3.9
This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
|
@@ -21,18 +21,18 @@ export declare function apiRequest<T>(endpoint: string, method?: 'GET' | 'POST',
|
|
|
21
21
|
export declare function addMemory(projectId: string, sessionId: string, messages: {
|
|
22
22
|
role: string;
|
|
23
23
|
content: string;
|
|
24
|
-
}[], extractFacts?: boolean): Promise<{
|
|
24
|
+
}[], extractFacts?: boolean, userId?: string): Promise<{
|
|
25
25
|
success: boolean;
|
|
26
26
|
episode_ids: string[];
|
|
27
27
|
}>;
|
|
28
|
-
export declare function searchMemory(projectId: string, query: string, limit?: number): Promise<MemoryContext>;
|
|
29
|
-
export declare function storeFact(projectId: string, entity1: string, relationship: string, entity2: string, context: string): Promise<{
|
|
28
|
+
export declare function searchMemory(projectId: string, query: string, limit?: number, userId?: string): Promise<MemoryContext>;
|
|
29
|
+
export declare function storeFact(projectId: string, entity1: string, relationship: string, entity2: string, context: string, userId?: string): Promise<{
|
|
30
30
|
success: boolean;
|
|
31
31
|
fact_id: string;
|
|
32
32
|
}>;
|
|
33
|
-
export declare function getContext(projectId: string, query?: string): Promise<MemoryContext>;
|
|
34
|
-
export declare function getSummary(projectId: string): Promise<string>;
|
|
35
|
-
export declare function getEntities(projectId: string): Promise<{
|
|
33
|
+
export declare function getContext(projectId: string, query?: string, userId?: string): Promise<MemoryContext>;
|
|
34
|
+
export declare function getSummary(projectId: string, userId?: string): Promise<string>;
|
|
35
|
+
export declare function getEntities(projectId: string, userId?: string): Promise<{
|
|
36
36
|
name: string;
|
|
37
37
|
labels: string[];
|
|
38
38
|
entity_id: string;
|
|
@@ -19,42 +19,41 @@ export async function apiRequest(endpoint, method = 'GET', body) {
|
|
|
19
19
|
}
|
|
20
20
|
return response.json();
|
|
21
21
|
}
|
|
22
|
-
export async function addMemory(projectId, sessionId, messages, extractFacts = true) {
|
|
23
|
-
return apiRequest(`/api/v1/memory/${projectId}/add`, 'POST', {
|
|
22
|
+
export async function addMemory(projectId, sessionId, messages, extractFacts = true, userId = DEFAULT_USER_ID) {
|
|
23
|
+
return apiRequest(`/api/v1/memory/${userId}/${projectId}/add`, 'POST', {
|
|
24
24
|
session_id: sessionId,
|
|
25
25
|
messages,
|
|
26
26
|
extract_facts: extractFacts,
|
|
27
27
|
});
|
|
28
28
|
}
|
|
29
|
-
export async function searchMemory(projectId, query, limit = 10) {
|
|
30
|
-
return apiRequest(`/api/v1/memory/${projectId}/search`, 'POST', {
|
|
29
|
+
export async function searchMemory(projectId, query, limit = 10, userId = DEFAULT_USER_ID) {
|
|
30
|
+
return apiRequest(`/api/v1/memory/${userId}/${projectId}/search`, 'POST', {
|
|
31
31
|
query,
|
|
32
32
|
limit,
|
|
33
33
|
});
|
|
34
34
|
}
|
|
35
|
-
export async function storeFact(projectId, entity1, relationship, entity2, context) {
|
|
36
|
-
return apiRequest(`/api/v1/memory/${projectId}/fact`, 'POST', {
|
|
35
|
+
export async function storeFact(projectId, entity1, relationship, entity2, context, userId = DEFAULT_USER_ID) {
|
|
36
|
+
return apiRequest(`/api/v1/memory/${userId}/${projectId}/fact`, 'POST', {
|
|
37
37
|
entity1,
|
|
38
38
|
relationship,
|
|
39
39
|
entity2,
|
|
40
40
|
context,
|
|
41
41
|
});
|
|
42
42
|
}
|
|
43
|
-
export async function getContext(projectId, query) {
|
|
43
|
+
export async function getContext(projectId, query, userId = DEFAULT_USER_ID) {
|
|
44
44
|
const params = query ? `?query=${encodeURIComponent(query)}` : '';
|
|
45
|
-
return apiRequest(`/api/v1/memory/${projectId}/context${params}`);
|
|
45
|
+
return apiRequest(`/api/v1/memory/${userId}/${projectId}/context${params}`);
|
|
46
46
|
}
|
|
47
|
-
export async function getSummary(projectId) {
|
|
48
|
-
const response = await fetch(`${API_BASE_URL}/api/v1/memory/${projectId}/summary`);
|
|
47
|
+
export async function getSummary(projectId, userId = DEFAULT_USER_ID) {
|
|
48
|
+
const response = await fetch(`${API_BASE_URL}/api/v1/memory/${userId}/${projectId}/summary`);
|
|
49
49
|
return response.text();
|
|
50
50
|
}
|
|
51
|
-
export async function getEntities(projectId) {
|
|
52
|
-
return apiRequest(`/api/v1/memory/${projectId}/entities`);
|
|
51
|
+
export async function getEntities(projectId, userId = DEFAULT_USER_ID) {
|
|
52
|
+
return apiRequest(`/api/v1/memory/${userId}/${projectId}/entities`);
|
|
53
53
|
}
|
|
54
|
-
export async function injectContext(projectId, query, userId) {
|
|
55
|
-
const response = await apiRequest(`/api/v1/memory/${projectId}/inject`, 'POST', {
|
|
54
|
+
export async function injectContext(projectId, query, userId = DEFAULT_USER_ID) {
|
|
55
|
+
const response = await apiRequest(`/api/v1/memory/${userId}/${projectId}/inject`, 'POST', {
|
|
56
56
|
query,
|
|
57
|
-
userId: userId || DEFAULT_USER_ID,
|
|
58
57
|
});
|
|
59
58
|
return response.data;
|
|
60
59
|
}
|
|
@@ -21,7 +21,7 @@ export const DEFAULT_CONFIG = {
|
|
|
21
21
|
defaultProjectId: undefined,
|
|
22
22
|
defaultUserId: 'default',
|
|
23
23
|
// Context Injection
|
|
24
|
-
autoInjectContext:
|
|
24
|
+
autoInjectContext: true, // Enabled by default - this is the core value prop
|
|
25
25
|
contextRelevanceThreshold: 0.5,
|
|
26
26
|
maxContextFacts: 10,
|
|
27
27
|
// Logging & Verbosity
|
package/dist/setup.js
CHANGED
|
@@ -589,7 +589,16 @@ CWD=$(pwd)
|
|
|
589
589
|
PROJECT_ID=""
|
|
590
590
|
PROJECT_NAME=""
|
|
591
591
|
|
|
592
|
-
|
|
592
|
+
# Priority 1: Check .claude/CLAUDE.md for project ID (from claudetools init)
|
|
593
|
+
CLAUDE_MD="$CWD/.claude/CLAUDE.md"
|
|
594
|
+
if [ -f "$CLAUDE_MD" ]; then
|
|
595
|
+
# Extract project ID from format: **Project ID:** \\\`local_xxx\\\` or \\\`proj_xxx\\\`
|
|
596
|
+
# Use sed to extract text between backticks after "Project ID"
|
|
597
|
+
PROJECT_ID=$(grep "Project ID" "$CLAUDE_MD" 2>/dev/null | sed -n "s/.*\\\`\\([a-z0-9_]*\\)\\\`.*/\\1/p" | head -1)
|
|
598
|
+
fi
|
|
599
|
+
|
|
600
|
+
# Priority 2: Fall back to projects.json cache
|
|
601
|
+
if [ -z "$PROJECT_ID" ] && [ -f "$PROJECTS_FILE" ]; then
|
|
593
602
|
# Find project by path prefix match (use variable binding for jq startswith)
|
|
594
603
|
# Use -c for compact output so head -1 gets complete JSON object
|
|
595
604
|
PROJECT_DATA=$(jq -c --arg cwd "$CWD" '
|
|
@@ -684,12 +693,19 @@ API_KEY=$(jq -r '.apiKey // empty' "$CONFIG_FILE")
|
|
|
684
693
|
|
|
685
694
|
if [ -z "$API_KEY" ]; then exit 0; fi
|
|
686
695
|
|
|
687
|
-
# Get current project
|
|
696
|
+
# Get current project - check CLAUDE.md first, then projects.json
|
|
688
697
|
PROJECT_FILE="$HOME/.claudetools/projects.json"
|
|
689
698
|
CWD=$(pwd)
|
|
690
699
|
PROJECT_ID=""
|
|
691
700
|
|
|
692
|
-
|
|
701
|
+
# Priority 1: Check .claude/CLAUDE.md for project ID (from claudetools init)
|
|
702
|
+
CLAUDE_MD="$CWD/.claude/CLAUDE.md"
|
|
703
|
+
if [ -f "$CLAUDE_MD" ]; then
|
|
704
|
+
PROJECT_ID=$(grep "Project ID" "$CLAUDE_MD" 2>/dev/null | sed -n "s/.*\\\`\\([a-z0-9_]*\\)\\\`.*/\\1/p" | head -1)
|
|
705
|
+
fi
|
|
706
|
+
|
|
707
|
+
# Priority 2: Fall back to projects.json cache
|
|
708
|
+
if [ -z "$PROJECT_ID" ] && [ -f "$PROJECT_FILE" ]; then
|
|
693
709
|
# Try to find project by path prefix (use variable binding for jq startswith)
|
|
694
710
|
PROJECT_ID=$(jq -r --arg cwd "$CWD" '
|
|
695
711
|
.bindings[]? | select(.local_path) |
|