@monoes/monograph 1.2.1 → 1.2.2

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": "@monoes/monograph",
3
- "version": "1.2.1",
3
+ "version": "1.2.2",
4
4
  "type": "module",
5
5
  "description": "Native TypeScript code intelligence engine for monomind",
6
6
  "main": "dist/src/index.js",
@@ -245,6 +245,9 @@ function renderSkillMarkdown(
245
245
  lines.push('---');
246
246
  lines.push(`name: ${toKebabName(label)}`);
247
247
  lines.push(`description: "Skill for the ${label} community. ${members.length} symbols."`);
248
+ lines.push(`type: Code Community`);
249
+ lines.push(`tags: [monograph, code-community]`);
250
+ lines.push(`timestamp: ${new Date().toISOString()}`);
248
251
  lines.push('---');
249
252
  lines.push('');
250
253
 
@@ -1,3 +1,4 @@
1
+ import Database from 'better-sqlite3';
1
2
  import type { MonographNode, NodeLabel } from '../types.js';
2
3
  import type { MonographDb } from '../storage/db.js';
3
4
 
@@ -55,13 +56,13 @@ function rowToNode(r: {
55
56
  // so the same query shape reuses the compiled statement across calls.
56
57
 
57
58
  // WeakMap ensures the cache is garbage-collected when the DB object is released.
58
- const stmtCache = new WeakMap<object, Map<string, ReturnType<MonographDb['prepare']>>>();
59
+ const stmtCache = new WeakMap<object, Map<string, Database.Statement>>();
59
60
 
60
61
  function getCachedStmt(
61
62
  db: MonographDb,
62
63
  key: string,
63
64
  buildSql: () => string,
64
- ): ReturnType<MonographDb['prepare']> {
65
+ ): Database.Statement {
65
66
  let dbCache = stmtCache.get(db);
66
67
  if (!dbCache) {
67
68
  dbCache = new Map();
@@ -1,3 +1,4 @@
1
+ import Database from 'better-sqlite3';
1
2
  import type { MonographDb } from '../storage/db.js';
2
3
 
3
4
  export interface PageRankOptions {
@@ -13,8 +14,8 @@ export interface PageRankOptions {
13
14
  // Per-DB statement cache — avoids recompiling SQL on every pageRank() call.
14
15
  // ---------------------------------------------------------------------------
15
16
  interface StmtCache {
16
- selectNodes: ReturnType<MonographDb['prepare']>;
17
- selectEdges: ReturnType<MonographDb['prepare']>;
17
+ selectNodes: Database.Statement;
18
+ selectEdges: Database.Statement;
18
19
  }
19
20
 
20
21
  const _stmtCache = new Map<string, StmtCache>();
@@ -1,3 +1,4 @@
1
+ import Database from 'better-sqlite3';
1
2
  import type { MonographNode, MonographEdge } from '../types.js';
2
3
  import type { MonographDb } from '../storage/db.js';
3
4
 
@@ -66,7 +67,7 @@ export function extractInducedSubgraph(db: MonographDb, nodeIds: string[]): Indu
66
67
  const stmts = getStmtCaches(db);
67
68
 
68
69
  // Chunk helper — caches prepared statements by chunk size to avoid re-prepare per call.
69
- function queryChunked<T>(ids: string[], chunkSize: number, stmtCache: Map<number, ReturnType<MonographDb['prepare']>>, sql: (ph: string) => string): T[] {
70
+ function queryChunked<T>(ids: string[], chunkSize: number, stmtCache: Map<number, Database.Statement>, sql: (ph: string) => string): T[] {
70
71
  const results: T[] = [];
71
72
  for (let i = 0; i < ids.length; i += chunkSize) {
72
73
  const chunk = ids.slice(i, i + chunkSize);
@@ -160,7 +160,11 @@ export async function generateWikiPage(
160
160
  content = (block?.type === 'text') ? block.text : '';
161
161
  }
162
162
 
163
- // 7. Persist to DB
163
+ // 7. Persist to DB — prepend OKF frontmatter if not already present
164
+ if (!content.startsWith('---')) {
165
+ const safeLabel = label.replace(/\\/g, '\\\\').replace(/"/g, '\\"');
166
+ content = `---\ntype: Code Community Wiki\ntitle: "${safeLabel}"\ntags: [monograph, wiki]\ntimestamp: ${new Date().toISOString()}\n---\n\n${content}`;
167
+ }
164
168
  upsertWikiPage(db, communityIdStr, content);
165
169
 
166
170
  return content;