mnotes-cli 1.9.0 → 1.9.1

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/dist/client.d.ts CHANGED
@@ -72,6 +72,26 @@ export declare function createClient(baseUrl: string, apiKey: string): {
72
72
  isDefault: boolean;
73
73
  }>;
74
74
  }>;
75
+ recallKnowledge(opts: {
76
+ query: string;
77
+ workspaceId?: string;
78
+ tags?: string[];
79
+ limit?: number;
80
+ }): Promise<{
81
+ data: {
82
+ results: Array<{
83
+ id: string;
84
+ title: string;
85
+ key: string | null;
86
+ excerpt: string;
87
+ importance: number | null;
88
+ tags: string[];
89
+ semanticScore: number;
90
+ freshnessScore: number;
91
+ finalScore: number;
92
+ }>;
93
+ };
94
+ }>;
75
95
  queryGraph(opts?: {
76
96
  workspaceId?: string;
77
97
  query?: string;
package/dist/client.js CHANGED
@@ -51,6 +51,14 @@ function createClient(baseUrl, apiKey) {
51
51
  async listWorkspaces() {
52
52
  return request("GET", "/api/v1/workspaces");
53
53
  },
54
+ async recallKnowledge(opts) {
55
+ return request("POST", "/api/v1/knowledge/recall", {
56
+ query: opts.query,
57
+ workspaceId: opts.workspaceId,
58
+ tags: opts.tags,
59
+ limit: opts.limit,
60
+ });
61
+ },
54
62
  async queryGraph(opts) {
55
63
  const params = new URLSearchParams();
56
64
  if (opts?.workspaceId)
@@ -7,30 +7,55 @@ const output_1 = require("../output");
7
7
  function registerRecallKnowledgeCommand(program) {
8
8
  program
9
9
  .command("recall_knowledge")
10
- .description("Query the knowledge graph (read-only)")
11
- .option("--query <text>", "Filter nodes by label (case-insensitive)")
12
- .option("--type <type>", "Filter by node type: note, tag, concept")
13
- .option("--neighbors <nodeId>", "Show neighbors of a specific node")
14
- .option("--depth <n>", "Neighbor traversal depth (1-3, default 1)", "1")
15
- .option("--limit <n>", "Max nodes to return (default 50)", "50")
10
+ .description("Query knowledge entries via semantic search (read-only)")
11
+ .option("--query <text>", "Search query (required for semantic recall)")
12
+ .option("--tags <tags>", "Filter by tags (comma-separated)")
13
+ .option("--limit <n>", "Max results (default 10)", "10")
14
+ .option("--graph", "Query the knowledge graph (GraphNode/GraphEdge) instead of semantic recall")
15
+ .option("--type <type>", "Node type filter (graph mode only): note, tag, concept")
16
+ .option("--neighbors <nodeId>", "Show neighbors of a node (graph mode only)")
17
+ .option("--depth <n>", "Neighbor traversal depth 1-3 (graph mode only)", "1")
16
18
  .option("--workspace-id <id>", "Workspace ID")
17
19
  .action(async (opts) => {
18
20
  const globalOpts = program.opts();
19
21
  const config = (0, config_1.resolveConfig)(globalOpts);
20
22
  const client = (0, client_1.createClient)(config.baseUrl, config.apiKey);
21
- const result = await client.queryGraph({
22
- workspaceId: opts.workspaceId || config.workspaceId,
23
+ const workspaceId = opts.workspaceId || config.workspaceId;
24
+ // Graph mode
25
+ if (opts.graph) {
26
+ const result = await client.queryGraph({
27
+ workspaceId,
28
+ query: opts.query,
29
+ nodeType: opts.type,
30
+ neighbors: opts.neighbors,
31
+ depth: opts.depth ? parseInt(opts.depth, 10) : undefined,
32
+ limit: opts.limit ? parseInt(opts.limit, 10) : undefined,
33
+ });
34
+ if (globalOpts.json) {
35
+ (0, output_1.printJson)(result.data);
36
+ }
37
+ else {
38
+ (0, output_1.printGraph)(result.data.nodes, result.data.edges);
39
+ }
40
+ return;
41
+ }
42
+ // Semantic recall mode (default)
43
+ if (!opts.query) {
44
+ process.stderr.write("Error: --query is required for semantic recall. Use --graph for graph queries without a query.\n");
45
+ process.exit(1);
46
+ }
47
+ const tags = opts.tags ? opts.tags.split(",").map((t) => t.trim()) : undefined;
48
+ const result = await client.recallKnowledge({
23
49
  query: opts.query,
24
- nodeType: opts.type,
25
- neighbors: opts.neighbors,
26
- depth: opts.depth ? parseInt(opts.depth, 10) : undefined,
50
+ workspaceId,
51
+ tags,
27
52
  limit: opts.limit ? parseInt(opts.limit, 10) : undefined,
28
53
  });
29
54
  if (globalOpts.json) {
30
- (0, output_1.printJson)(result.data);
55
+ (0, output_1.printJson)(result.data.results);
31
56
  }
32
57
  else {
33
- (0, output_1.printGraph)(result.data.nodes, result.data.edges);
58
+ (0, output_1.printKnowledgeResults)(result.data.results);
34
59
  }
35
60
  });
36
61
  }
package/dist/output.d.ts CHANGED
@@ -14,6 +14,17 @@ export declare function printSearchResults(results: Array<{
14
14
  title: string;
15
15
  snippet?: string;
16
16
  }>): void;
17
+ export declare function printKnowledgeResults(results: Array<{
18
+ id: string;
19
+ title: string;
20
+ key: string | null;
21
+ excerpt: string;
22
+ importance: number | null;
23
+ tags: string[];
24
+ semanticScore: number;
25
+ freshnessScore: number;
26
+ finalScore: number;
27
+ }>): void;
17
28
  export declare function printGraph(nodes: Array<{
18
29
  id: string;
19
30
  noteId: string | null;
package/dist/output.js CHANGED
@@ -4,6 +4,7 @@ exports.printJson = printJson;
4
4
  exports.printNoteList = printNoteList;
5
5
  exports.printNote = printNote;
6
6
  exports.printSearchResults = printSearchResults;
7
+ exports.printKnowledgeResults = printKnowledgeResults;
7
8
  exports.printGraph = printGraph;
8
9
  exports.printSuccess = printSuccess;
9
10
  function printJson(data) {
@@ -43,6 +44,28 @@ function printSearchResults(results) {
43
44
  }
44
45
  }
45
46
  }
47
+ function printKnowledgeResults(results) {
48
+ if (results.length === 0) {
49
+ process.stderr.write("No knowledge entries found.\n");
50
+ return;
51
+ }
52
+ for (let i = 0; i < results.length; i++) {
53
+ const r = results[i];
54
+ const score = (r.finalScore * 100).toFixed(0);
55
+ const key = r.key ? ` [${r.key}]` : "";
56
+ const tags = r.tags.length > 0 ? ` (${r.tags.join(", ")})` : "";
57
+ const importance = r.importance !== null ? ` imp:${r.importance}` : "";
58
+ console.log(`${i + 1}. ${r.title}${key} ${score}%${importance}${tags}`);
59
+ if (r.excerpt) {
60
+ const lines = r.excerpt.split("\n").slice(0, 3).join("\n ");
61
+ console.log(` ${lines}`);
62
+ }
63
+ if (i < results.length - 1)
64
+ console.log("");
65
+ }
66
+ console.log("");
67
+ console.log(`${results.length} result(s)`);
68
+ }
46
69
  function printGraph(nodes, edges) {
47
70
  if (nodes.length === 0) {
48
71
  process.stderr.write("Knowledge graph is empty.\n");
package/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "mnotes-cli",
3
- "version": "1.9.0",
3
+ "version": "1.9.1",
4
4
  "description": "CLI for m-notes AI knowledge base — manage notes, search, and CRUD from the terminal",
5
5
  "bin": {
6
6
  "mnotes": "./dist/index.js"