@feelingmindful/thinking-graph 1.8.0 → 1.9.0
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/storage/sqlite.js +3 -0
- package/dist/tools/learn.js +36 -1
- package/dist/tools/recall.d.ts +2 -2
- package/dist/tools/think.js +7 -2
- package/package.json +1 -1
package/dist/storage/sqlite.js
CHANGED
|
@@ -30,6 +30,9 @@ export class SQLiteAdapter {
|
|
|
30
30
|
this.db = new SQL.Database();
|
|
31
31
|
}
|
|
32
32
|
this.db.run('PRAGMA foreign_keys = ON');
|
|
33
|
+
// sql.js uses db.export() which serializes the full DB — WAL mode is not
|
|
34
|
+
// supported and causes data loss. Force DELETE journal mode.
|
|
35
|
+
this.db.run('PRAGMA journal_mode = DELETE');
|
|
33
36
|
// Run migration (multi-statement)
|
|
34
37
|
const sql = readFileSync(MIGRATION_PATH, 'utf-8');
|
|
35
38
|
this.db.exec(sql);
|
package/dist/tools/learn.js
CHANGED
|
@@ -1,5 +1,5 @@
|
|
|
1
1
|
import { z } from 'zod';
|
|
2
|
-
import { NODE_TYPES, EDGE_TYPES } from '../engine/types.js';
|
|
2
|
+
import { NODE_TYPES, EDGE_TYPES, GLOBAL_NODE_TYPES } from '../engine/types.js';
|
|
3
3
|
export const learnSchema = z.object({
|
|
4
4
|
content: z.string().describe('What was learned'),
|
|
5
5
|
type: z.enum(NODE_TYPES).describe('Node type'),
|
|
@@ -77,6 +77,40 @@ export async function learnHandler(graph, input) {
|
|
|
77
77
|
relatedCount++;
|
|
78
78
|
}
|
|
79
79
|
}
|
|
80
|
+
// Suggest writing to the knowledge-graph vault for durable, cross-project knowledge
|
|
81
|
+
const suggestions = [];
|
|
82
|
+
if (GLOBAL_NODE_TYPES.includes(input.type)) {
|
|
83
|
+
suggestions.push({
|
|
84
|
+
tool: 'kg_create_node',
|
|
85
|
+
when: 'Persist this to the knowledge vault for semantic search, community detection, and cross-project discovery',
|
|
86
|
+
example: {
|
|
87
|
+
title: input.content.slice(0, 60).replace(/[^a-zA-Z0-9 ]/g, ''),
|
|
88
|
+
directory: input.type === 'insight' ? 'Insights' : input.type === 'pattern' ? 'Patterns' : 'Principles',
|
|
89
|
+
content: input.content,
|
|
90
|
+
frontmatter: {
|
|
91
|
+
type: input.type,
|
|
92
|
+
tags: [input.type],
|
|
93
|
+
...(input.projectId && { project: input.projectId }),
|
|
94
|
+
},
|
|
95
|
+
},
|
|
96
|
+
});
|
|
97
|
+
}
|
|
98
|
+
if (input.type === 'code_fact' && input.filePath) {
|
|
99
|
+
suggestions.push({
|
|
100
|
+
tool: 'kg_create_node',
|
|
101
|
+
when: 'Persist this code fact to the knowledge vault for future recall across projects',
|
|
102
|
+
example: {
|
|
103
|
+
title: input.content.slice(0, 60).replace(/[^a-zA-Z0-9 ]/g, ''),
|
|
104
|
+
directory: 'Code Facts',
|
|
105
|
+
content: input.content,
|
|
106
|
+
frontmatter: {
|
|
107
|
+
type: 'code_fact',
|
|
108
|
+
filePath: input.filePath,
|
|
109
|
+
tags: ['code-fact'],
|
|
110
|
+
},
|
|
111
|
+
},
|
|
112
|
+
});
|
|
113
|
+
}
|
|
80
114
|
return {
|
|
81
115
|
content: [{
|
|
82
116
|
type: 'text',
|
|
@@ -85,6 +119,7 @@ export async function learnHandler(graph, input) {
|
|
|
85
119
|
type: node.type,
|
|
86
120
|
relatedCount,
|
|
87
121
|
duplicateOf: null,
|
|
122
|
+
...(suggestions.length > 0 && { suggestions }),
|
|
88
123
|
}),
|
|
89
124
|
}],
|
|
90
125
|
};
|
package/dist/tools/recall.d.ts
CHANGED
|
@@ -21,12 +21,12 @@ export declare const recallSchema: z.ZodObject<{
|
|
|
21
21
|
metadata?: Record<string, unknown> | undefined;
|
|
22
22
|
query?: string | undefined;
|
|
23
23
|
crossProject?: boolean | undefined;
|
|
24
|
+
limit?: number | undefined;
|
|
24
25
|
relatedTo?: string | undefined;
|
|
25
26
|
edgeType?: "depends_on" | "contradicts" | "supports" | "refines" | "supersedes" | "similar_to" | "located_in" | "violates" | "addresses" | "detected_by" | "invoked_by" | ("depends_on" | "contradicts" | "supports" | "refines" | "supersedes" | "similar_to" | "located_in" | "violates" | "addresses" | "detected_by" | "invoked_by")[] | undefined;
|
|
26
27
|
direction?: "outgoing" | "incoming" | "both" | undefined;
|
|
27
28
|
depth?: number | undefined;
|
|
28
29
|
since?: string | undefined;
|
|
29
|
-
limit?: number | undefined;
|
|
30
30
|
offset?: number | undefined;
|
|
31
31
|
}, {
|
|
32
32
|
type?: "thought" | "decision" | "insight" | "code_fact" | "assumption" | "detection" | "tech_debt" | "principle" | "pattern" | "skill_result" | "research" | ("thought" | "decision" | "insight" | "code_fact" | "assumption" | "detection" | "tech_debt" | "principle" | "pattern" | "skill_result" | "research")[] | undefined;
|
|
@@ -35,12 +35,12 @@ export declare const recallSchema: z.ZodObject<{
|
|
|
35
35
|
metadata?: Record<string, unknown> | undefined;
|
|
36
36
|
query?: string | undefined;
|
|
37
37
|
crossProject?: unknown;
|
|
38
|
+
limit?: number | undefined;
|
|
38
39
|
relatedTo?: string | undefined;
|
|
39
40
|
edgeType?: "depends_on" | "contradicts" | "supports" | "refines" | "supersedes" | "similar_to" | "located_in" | "violates" | "addresses" | "detected_by" | "invoked_by" | ("depends_on" | "contradicts" | "supports" | "refines" | "supersedes" | "similar_to" | "located_in" | "violates" | "addresses" | "detected_by" | "invoked_by")[] | undefined;
|
|
40
41
|
direction?: "outgoing" | "incoming" | "both" | undefined;
|
|
41
42
|
depth?: number | undefined;
|
|
42
43
|
since?: string | undefined;
|
|
43
|
-
limit?: number | undefined;
|
|
44
44
|
offset?: number | undefined;
|
|
45
45
|
}>;
|
|
46
46
|
export type RecallInput = z.infer<typeof recallSchema>;
|
package/dist/tools/think.js
CHANGED
|
@@ -3,13 +3,18 @@ import { NODE_TYPES, EDGE_TYPES, GLOBAL_NODE_TYPES } from '../engine/types.js';
|
|
|
3
3
|
const coerceBool = z.preprocess((v) => (v === 'true' ? true : v === 'false' ? false : v), z.boolean());
|
|
4
4
|
function buildSuggestions(type, thoughtNumber, relatedCount, stats, matchedSkills) {
|
|
5
5
|
const suggestions = [];
|
|
6
|
-
// First thought in session — suggest recall
|
|
6
|
+
// First thought in session — suggest recall + knowledge vault search
|
|
7
7
|
if (thoughtNumber === 1 && stats.totalNodes > 1) {
|
|
8
8
|
suggestions.push({
|
|
9
9
|
tool: 'recall',
|
|
10
|
-
when: 'Check what the graph already knows before reasoning from scratch',
|
|
10
|
+
when: 'Check what the thinking graph already knows before reasoning from scratch',
|
|
11
11
|
example: { query: '<topic>', crossProject: true },
|
|
12
12
|
});
|
|
13
|
+
suggestions.push({
|
|
14
|
+
tool: 'kg_search',
|
|
15
|
+
when: 'Search the knowledge vault for semantically related insights, patterns, and facts from past work',
|
|
16
|
+
example: { query: '<topic>', type: 'semantic', limit: 5 },
|
|
17
|
+
});
|
|
13
18
|
}
|
|
14
19
|
// Decision nodes with no relationships — suggest relate
|
|
15
20
|
if (type === 'decision' && relatedCount === 0) {
|
package/package.json
CHANGED