@awareness-sdk/local 0.1.5 → 0.1.7

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.
package/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "@awareness-sdk/local",
3
- "version": "0.1.5",
3
+ "version": "0.1.7",
4
4
  "description": "Local-first AI agent memory system. No account needed.",
5
5
  "license": "Apache-2.0",
6
6
  "type": "module",
package/src/daemon.mjs CHANGED
@@ -42,6 +42,26 @@ function nowISO() {
42
42
  return new Date().toISOString();
43
43
  }
44
44
 
45
+ /** Categories surfaced as top-level user_preferences (mirrors cloud PREFERENCE_FIRST_CATEGORIES). */
46
+ const PREFERENCE_FIRST_CATEGORIES = new Set([
47
+ 'personal_preference', 'activity_preference', 'important_detail', 'career_info',
48
+ ]);
49
+ const MAX_USER_PREFERENCES = 15;
50
+
51
+ /** Split knowledge cards into {user_preferences, knowledge_cards}. */
52
+ function splitPreferences(cards) {
53
+ const prefs = [];
54
+ const other = [];
55
+ for (const c of cards) {
56
+ if (PREFERENCE_FIRST_CATEGORIES.has(c.category) && prefs.length < MAX_USER_PREFERENCES) {
57
+ prefs.push(c);
58
+ } else {
59
+ other.push(c);
60
+ }
61
+ }
62
+ return { user_preferences: prefs, knowledge_cards: other };
63
+ }
64
+
45
65
  /**
46
66
  * Send a JSON response.
47
67
  * @param {http.ServerResponse} res
@@ -668,13 +688,15 @@ export class AwarenessLocalDaemon {
668
688
  needs_attention: staleTasks > 0 || highRisks > 0,
669
689
  };
670
690
 
691
+ const { user_preferences, knowledge_cards: otherCards } = splitPreferences(recentCards);
671
692
  return {
672
693
  content: [{
673
694
  type: 'text',
674
695
  text: JSON.stringify({
675
696
  session_id: session.id,
676
697
  mode: 'local',
677
- knowledge_cards: recentCards,
698
+ user_preferences,
699
+ knowledge_cards: otherCards,
678
700
  open_tasks: openTasks,
679
701
  recent_sessions: recentSessions,
680
702
  stats,
@@ -1548,12 +1570,13 @@ ${item.description || item.title || ''}
1548
1570
 
1549
1571
  switch (type) {
1550
1572
  case 'context': {
1551
- // Full context dump
1573
+ // Full context dump with preference separation
1552
1574
  const stats = this.indexer.getStats();
1553
1575
  const knowledge = this.indexer.getRecentKnowledge(limit);
1554
1576
  const tasks = this.indexer.getOpenTasks(0);
1555
1577
  const sessions = this.indexer.getRecentSessions(7);
1556
- return { stats, knowledge_cards: knowledge, open_tasks: tasks, recent_sessions: sessions, mode: 'local' };
1578
+ const { user_preferences, knowledge_cards: otherCards } = splitPreferences(knowledge);
1579
+ return { stats, user_preferences, knowledge_cards: otherCards, open_tasks: tasks, recent_sessions: sessions, mode: 'local' };
1557
1580
  }
1558
1581
 
1559
1582
  case 'tasks': {
@@ -19,6 +19,26 @@ import { z } from 'zod';
19
19
  // Helpers
20
20
  // ---------------------------------------------------------------------------
21
21
 
22
+ /** Categories surfaced as top-level user_preferences (mirrors cloud). */
23
+ const PREFERENCE_FIRST_CATEGORIES = new Set([
24
+ 'personal_preference', 'activity_preference', 'important_detail', 'career_info',
25
+ ]);
26
+ const MAX_USER_PREFERENCES = 15;
27
+
28
+ /** Split knowledge cards into {user_preferences, knowledge_cards}. */
29
+ function splitPreferences(cards) {
30
+ const prefs = [];
31
+ const other = [];
32
+ for (const c of cards) {
33
+ if (PREFERENCE_FIRST_CATEGORIES.has(c.category) && prefs.length < MAX_USER_PREFERENCES) {
34
+ prefs.push(c);
35
+ } else {
36
+ other.push(c);
37
+ }
38
+ }
39
+ return { user_preferences: prefs, knowledge_cards: other };
40
+ }
41
+
22
42
  /**
23
43
  * Wrap a result object in the MCP-standard content envelope.
24
44
  * @param {object} result
@@ -118,10 +138,12 @@ export class LocalMcpServer {
118
138
  // Load workflow rules from awareness-spec.json
119
139
  const spec = this.engine.loadSpec();
120
140
 
141
+ const { user_preferences, knowledge_cards: otherCards } = splitPreferences(recentCards);
121
142
  return mcpResult({
122
143
  session_id: session.id,
123
144
  mode: 'local',
124
- knowledge_cards: recentCards,
145
+ user_preferences,
146
+ knowledge_cards: otherCards,
125
147
  open_tasks: openTasks,
126
148
  recent_sessions: recentSessions,
127
149
  stats,