Local-first memory system: raw material in, finished notes out. Synthesis on write. This release brings a guided install that explains itself and ends with a live demo pass, eleven fixes to the knowledge pipeline found by running it against a real archive of 216 sources, and a documentation pass in the project's own voice.
56 lines
1.6 KiB
JavaScript
56 lines
1.6 KiB
JavaScript
#!/usr/bin/env node
|
|
import { promises as fs } from 'node:fs'
|
|
import { existsSync } from 'node:fs'
|
|
import path from 'node:path'
|
|
import {
|
|
graphStats,
|
|
normalizeGraphObject,
|
|
readGraph,
|
|
writeGraph
|
|
} from './mnemazine-graph-utils.mjs'
|
|
import { resolveVault } from './mnemazine-paths.mjs'
|
|
|
|
const argv = process.argv.slice(2)
|
|
|
|
function arg(name, fallback = '') {
|
|
const hit = argv.find(item => item === `--${name}` || item.startsWith(`--${name}=`))
|
|
if (!hit) return fallback
|
|
return hit.includes('=') ? hit.split('=').slice(1).join('=') : argv[argv.indexOf(hit) + 1] || fallback
|
|
}
|
|
|
|
function hasFlag(name) {
|
|
return argv.includes(`--${name}`)
|
|
}
|
|
|
|
const graphPath = path.resolve(arg('graph') || path.join(resolveVault({ requireExists: false }), 'graphify-out', 'graph.json'))
|
|
const outPath = arg('out', '')
|
|
const apply = hasFlag('apply')
|
|
|
|
async function main() {
|
|
if (!existsSync(graphPath)) throw new Error(`graph not found: ${graphPath}`)
|
|
const beforeGraph = await readGraph(graphPath)
|
|
const before = graphStats(beforeGraph)
|
|
const repaired = normalizeGraphObject(beforeGraph)
|
|
const after = graphStats(repaired.graph)
|
|
const target = apply ? graphPath : path.resolve(outPath || `${graphPath}.repaired`)
|
|
|
|
await fs.mkdir(path.dirname(target), { recursive: true })
|
|
await writeGraph(target, repaired.graph)
|
|
|
|
const summary = {
|
|
ok: true,
|
|
applied: apply,
|
|
graph: graphPath,
|
|
out: target,
|
|
before,
|
|
after,
|
|
repair: repaired.stats
|
|
}
|
|
console.log(JSON.stringify(summary, null, 2))
|
|
}
|
|
|
|
main().catch(error => {
|
|
console.error(error.message || error)
|
|
process.exit(1)
|
|
})
|