Skip to content
Draft
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension


Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
12 changes: 12 additions & 0 deletions CHANGELOG.md
Original file line number Diff line number Diff line change
Expand Up @@ -5,6 +5,18 @@ Format follows [Keep a Changelog](https://keepachangelog.com/en/1.1.0/).

## [Unreleased]

## [0.2.7] - unreleased

Release date will be set at publish time.

### Fixed
- Align update-manifest URLs with uploaded asset filenames for KeepMind and Corp on macOS and Windows (#16).
- Guard both editions with real electron-builder macro expansion for macOS DMG/ZIP and Windows NSIS names, plus post-build exact filename, size and SHA-512 manifest validation.

### Release preparation notes
- Includes `2869b3e` (#16, "fix: align Windows installer names with update manifests"); both builder configs define explicit `artifactName` for macOS, NSIS and Linux.
- Both desktop editions use the root package version 0.2.7. The Corp server version (`corp/lib.mjs`, 0.8.0) and the standalone MCP package (`tools/package.json`, 0.1.1) are versioned separately and stay unchanged.

### Added
- Project continuity in the desktop app, native chat and bundled MCP: versioned objectives, decisions, alternatives, attempts, artifacts, expected/observed outcomes and questions.
- Evidence digests, changed/unavailable source checks, dependent artifact impacts, human review history and usefulness feedback.
Expand Down
4 changes: 2 additions & 2 deletions package-lock.json

Some generated files are not rendered by default. Learn more about how customized files appear on GitHub.

3 changes: 2 additions & 1 deletion package.json
Original file line number Diff line number Diff line change
@@ -1,6 +1,6 @@
{
"name": "keepmind",
"version": "0.2.6",
"version": "0.2.7",
"description": "KeepMind — open-source installable second brain. Connects your apps, remembers everything, learns while you sleep.",
"license": "MIT",
"main": "./out/main/index.js",
Expand All @@ -15,6 +15,7 @@
"typecheck": "tsc --noEmit -p tsconfig.node.json && tsc --noEmit -p tsconfig.web.json",
"dist": "electron-vite build && electron-builder",
"test": "vitest run",
"check:update-manifests": "node scripts/check-update-manifests.mjs",
"check:release-gates": "node scripts/check-release-gates.mjs",
"corp": "node corp/server.mjs",
"corp:build-brain": "vite build --config vite.corp.config.mts",
Expand Down
47 changes: 47 additions & 0 deletions scripts/check-update-manifests.mjs
Original file line number Diff line number Diff line change
@@ -0,0 +1,47 @@
import { createReadStream } from 'node:fs'
import { readdir, readFile, stat } from 'node:fs/promises'
import { createHash } from 'node:crypto'
import { resolve, join } from 'node:path'
import { pathToFileURL } from 'node:url'
import yaml from 'js-yaml'

export async function checkUpdateManifests(distDir) {
const names = await readdir(distDir)
const manifests = names.filter(name => /^latest.*\.yml$/.test(name))
if (!manifests.length) throw new Error(`No latest*.yml manifests in ${distDir}`)
for (const manifest of manifests) {
const data = yaml.load(await readFile(join(distDir, manifest), 'utf8'))
const fail = message => { throw new Error(`${manifest}: ${message}`) }
if (!data || !Array.isArray(data.files) || !data.files.length) fail('missing files entries')
const verify = async (name, size, sha512) => {
if (typeof name !== 'string' || !/^[A-Za-z0-9._-]+$/.test(name) || name === '.' || name === '..') fail(`unsafe asset name: ${JSON.stringify(name)}`)
if (!names.includes(name)) fail(`exact asset filename missing: ${name}`)
const info = await stat(join(distDir, name))
if (!info.isFile()) fail(`asset is not a file: ${name}`)
if (!Number.isSafeInteger(size) || size < 0 || info.size !== size) fail(`size mismatch for ${name}: manifest ${size}, actual ${info.size}`)
const hash = createHash('sha512')
for await (const chunk of createReadStream(join(distDir, name))) hash.update(chunk)
if (typeof sha512 !== 'string' || hash.digest('base64') !== sha512) fail(`sha512 mismatch for ${name}`)
}
for (const file of data.files) {
if (!file || typeof file !== 'object') fail('invalid files entry')
await verify(file.url, file.size, file.sha512)
}
if (data.path !== undefined) {
const entry = data.files.find(file => file.url === data.path)
if (!entry) fail(`path has no matching files entry: ${data.path}`)
await verify(data.path, data.size ?? entry.size, data.sha512)
}
}
return manifests.length
}

if (process.argv[1] && import.meta.url === pathToFileURL(resolve(process.argv[1])).href) {
try {
if (!process.argv[2]) throw new Error('Usage: node scripts/check-update-manifests.mjs <distDir>')
console.log(`Validated ${await checkUpdateManifests(process.argv[2])} update manifest(s)`)
} catch (error) {
console.error(`Update manifest check failed: ${error.message}`)
process.exitCode = 1
}
}
4 changes: 2 additions & 2 deletions scripts/packaged-mac-smoke.mjs
Original file line number Diff line number Diff line change
Expand Up @@ -16,11 +16,11 @@ async function identity(page){return edition==='personal'?page.evaluate(()=>wind
try{
let page=await launch();await page.screenshot({path:join(out,'01-open.png')});if(edition==='personal'){assert(page.url().startsWith('file:'),'Wrong personal entrypoint');await page.evaluate(()=>window.sb.authRegister('fixture@example.invalid','synthetic-password','Test'))}else{assert(page.url().startsWith('http://127.0.0.1:'),'Wrong Corp entrypoint');const setup=await page.evaluate(async()=>{const r=await fetch('/api/setup',{method:'POST',headers:{'Content-Type':'application/json'},body:JSON.stringify({orgName:'Synthetic Org',name:'Test',email:'fixture@example.invalid',password:'synthetic-password',confirm:'synthetic-password'})});return{status:r.status,body:await r.json()}});assert(setup.status===201,'Corp setup failed '+JSON.stringify(setup));await main.eval("process.mainModule.require('electron').session.defaultSession.cookies.flushStore()")}
let account=await identity(page);assert(account.user?.email==='fixture@example.invalid','Account setup failed');const userId=account.user.id;log('Packaged opening and synthetic account creation');await stop();rmSync(target,{recursive:true});install();page=await launch();account=await identity(page);assert(account.user?.id===userId,'Reinstall lost session/account');assert(readFileSync(sentinel,'utf8')==='preserve synthetic data','Reinstall lost data');log('Removal/reinstall preserves account, session and data');await page.screenshot({path:join(out,'02-reinstalled.png')});
const fixture=join(root,'fixture');mkdirSync(fixture);const newApp=join(fixture,name+'.app');cpSync(target,newApp,{recursive:true});writeFileSync(join(newApp,'Contents/Resources/update-proof'),'new-build');const archive=join(root,'update.zip');execFileSync('ditto',['-c','-k','--sequesterRsrc','--keepParent',newApp,archive]);const content=readFileSync(archive),digest='sha256:'+createHash('sha256').update(content).digest('hex'),assetName=edition==='corp'?`KeepMind-Corp-0.2.6-${process.arch}-mac.zip`:`KeepMind-SB-0.2.6-${process.arch}-mac.zip`,repo=edition==='corp'?'keepmind-corp':'keepmind';
const fixture=join(root,'fixture');mkdirSync(fixture);const newApp=join(fixture,name+'.app');cpSync(target,newApp,{recursive:true});writeFileSync(join(newApp,'Contents/Resources/update-proof'),'new-build');const archive=join(root,'update.zip');execFileSync('ditto',['-c','-k','--sequesterRsrc','--keepParent',newApp,archive]);const content=readFileSync(archive),digest='sha256:'+createHash('sha256').update(content).digest('hex'),assetName=edition==='corp'?`KeepMind-Corp-0.2.7-${process.arch}-mac.zip`:`KeepMind-SB-0.2.7-${process.arch}-mac.zip`,repo=edition==='corp'?'keepmind-corp':'keepmind';
server=createServer((req,res)=>{if(req.url==='/meta'){res.setHeader('Content-Type','application/json');res.end(JSON.stringify({updated_at:'fixture-new-build',assets:[{name:assetName,digest,size:content.length,browser_download_url:`https://github.com/criptogus/${repo}/releases/download/continuous/${assetName}`}]}))}else if(req.url==='/archive'){res.setHeader('Content-Length',String(content.length));createReadStream(archive).pipe(res)}else{res.writeHead(404);res.end()}});await new Promise(r=>server.listen(0,'127.0.0.1',r));const origin=`http://127.0.0.1:${server.address().port}`;
writeFileSync(join(profile,'continuous-state.json'),JSON.stringify({seen:'old-build'}));
await main.eval(`globalThis.auditElectron=process.mainModule.require('electron');globalThis.auditFetch=auditOriginalFetch;auditElectron.net.fetch=(url,opts)=>auditFetch(${JSON.stringify(origin)}+(String(url).includes('api.github.com')?'/meta':'/archive'),opts);globalThis.auditFs=process.mainModule.require('fs');globalThis.auditDir=auditElectron.app.getAppPath()+'/out/main/chunks';globalThis.auditModule=auditFs.readdirSync(auditDir).find(f=>auditFs.readFileSync(auditDir+'/'+f,'utf8').includes('exports.checkForUpdates'));globalThis.auditUpdater=process.mainModule.require(auditDir+'/'+auditModule);auditUpdater.initUpdater({edition:${JSON.stringify(edition)}});`);
let downloaded=await main.eval('auditUpdater.checkForUpdates()');for(let i=0;downloaded.busy&&i<600;i++){await sleep(200);downloaded=await main.eval('auditUpdater.checkForUpdates()')}assert(downloaded.continuous==='0.2.6','Download failed '+JSON.stringify(downloaded));log('Real updater downloads and verifies controlled archive');const oldPort=readFileSync(join(profile,'DevToolsActivePort'),'utf8');assert(await main.eval('auditUpdater.installUpdate()'),'Installer refused');main.ws.close();main=undefined;await browser.close().catch(()=>{});browser=undefined;
let downloaded=await main.eval('auditUpdater.checkForUpdates()');for(let i=0;downloaded.busy&&i<600;i++){await sleep(200);downloaded=await main.eval('auditUpdater.checkForUpdates()')}assert(downloaded.continuous==='0.2.7','Download failed '+JSON.stringify(downloaded));log('Real updater downloads and verifies controlled archive');const oldPort=readFileSync(join(profile,'DevToolsActivePort'),'utf8');assert(await main.eval('auditUpdater.installUpdate()'),'Installer refused');main.ws.close();main=undefined;await browser.close().catch(()=>{});browser=undefined;
for(let i=0;i<300;i++){if(existsSync(join(target,'Contents/Resources/update-proof'))&&readNewDebugPort(join(profile,'DevToolsActivePort'),oldPort)!==null)break;await sleep(200)}
assert(existsSync(join(target,'Contents/Resources/update-proof')),'Updated bundle was not installed');const port=readNewDebugPort(join(profile,'DevToolsActivePort'),oldPort);assert(port,'Relaunched debugging endpoint is not ready');browser=await chromium.connectOverCDP('http://127.0.0.1:'+port);page=browser.contexts()[0].pages()[0] ?? await browser.contexts()[0].waitForEvent('page',{timeout:45000});await page.waitForFunction(()=>document.body?.innerText.trim().length>0);account=await identity(page);assert(account.user?.id===userId,'Update lost session/account');assert(readFileSync(sentinel,'utf8')==='preserve synthetic data','Update lost profile data');assert(existsSync(target+'.previous'),'Missing recovery bundle');assert(!existsSync(join(profile,'update/pending.json')),'Update receipt not committed');log('Automatic swap/relaunch preserves account, session and data');await page.screenshot({path:join(out,'03-updated.png')});
// Stop only our relaunched disposable application via its own isolated process path.
Expand Down
4 changes: 2 additions & 2 deletions scripts/packaged-platform-smoke.mjs
Original file line number Diff line number Diff line change
Expand Up @@ -13,7 +13,7 @@ async function stop(){if(main){void main.eval("process.mainModule.require('elect
const identity=p=>edition==='personal'?p.evaluate(()=>window.sb.authState()):p.evaluate(async()=>await(await fetch('/api/session')).json());
try{install();let page=await launch();await page.screenshot({path:join(out,'01-open.png')});if(edition==='personal')await page.evaluate(()=>window.sb.authRegister('fixture@example.invalid','synthetic-password','Test'));else{const status=await page.evaluate(async()=>{const r=await fetch('/api/setup',{method:'POST',headers:{'Content-Type':'application/json'},body:JSON.stringify({orgName:'Fixture',name:'Test',email:'fixture@example.invalid',password:'synthetic-password',confirm:'synthetic-password'})});return r.status});assert(status===201,'Corp setup failed');await main.eval("process.mainModule.require('electron').session.defaultSession.cookies.flushStore()")};const account=await identity(page),id=account.user?.id;assert(id,'Missing account');writeFileSync(join(profile,'sentinel'),'preserve');log('Native installation, opening and synthetic account creation');await stop();
if(win){const uninstaller=join(target,`Uninstall ${name}.exe`);assert(existsSync(uninstaller),'Missing native uninstaller');execFileSync(uninstaller,['/S'],{env,timeout:180000});await sleep(3000)}else rmSync(target);install();page=await launch();assert((await identity(page)).user?.id===id,'Reinstall lost account/session');log('Uninstall/reinstall preserves account and session');
const artifact=readFileSync(resolve(source)),digest='sha256:'+createHash('sha256').update(artifact).digest('hex'),prefix=edition==='corp'?'KeepMind-Corp':'KeepMind-SB',assetName=win?`${prefix}-Setup-0.2.6.exe`:`${prefix}-0.2.6.AppImage`,repo=edition==='corp'?'keepmind-corp':'keepmind';server=createServer((req,res)=>{if(req.url==='/meta'){res.setHeader('Content-Type','application/json');res.end(JSON.stringify({updated_at:'fixture-new',assets:[{name:assetName,digest,size:artifact.length,browser_download_url:`https://github.com/criptogus/${repo}/releases/download/continuous/${assetName}`}]}))}else{res.setHeader('Content-Length',String(artifact.length));createReadStream(resolve(source)).pipe(res)}});await new Promise(r=>server.listen(0,'127.0.0.1',r));const origin=`http://127.0.0.1:${server.address().port}`;writeFileSync(join(profile,'continuous-state.json'),JSON.stringify({seen:'old'}));
await main.eval(`globalThis.auditElectron=process.mainModule.require('electron');globalThis.auditFetch=auditOriginalFetch;auditElectron.net.fetch=(url,opts)=>auditFetch(${JSON.stringify(origin)}+(String(url).includes('api.github.com')?'/meta':'/archive'),opts);globalThis.auditFs=process.mainModule.require('fs');globalThis.auditDir=auditElectron.app.getAppPath()+'/out/main/chunks';globalThis.auditModule=auditFs.readdirSync(auditDir).find(f=>auditFs.readFileSync(auditDir+'/'+f,'utf8').includes('exports.checkForUpdates'));globalThis.auditUpdater=process.mainModule.require(auditDir+'/'+auditModule);auditUpdater.initUpdater({edition:${JSON.stringify(edition)}});`);let downloaded=await main.eval('auditUpdater.checkForUpdates()');for(let i=0;downloaded.busy&&i<600;i++){await sleep(200);downloaded=await main.eval('auditUpdater.checkForUpdates()')}assert(downloaded.continuous==='0.2.6','Update download failed '+JSON.stringify(downloaded));log('Real updater downloads and verifies installer');const oldPort=readFileSync(join(profile,'DevToolsActivePort'),'utf8');assert(await main.eval('auditUpdater.installUpdate()'),'Installer refused');main.ws.close();main=undefined;await browser.close().catch(()=>{});browser=undefined;
const artifact=readFileSync(resolve(source)),digest='sha256:'+createHash('sha256').update(artifact).digest('hex'),prefix=edition==='corp'?'KeepMind-Corp':'KeepMind-SB',assetName=win?`${prefix}-Setup-0.2.7.exe`:`${prefix}-0.2.7.AppImage`,repo=edition==='corp'?'keepmind-corp':'keepmind';server=createServer((req,res)=>{if(req.url==='/meta'){res.setHeader('Content-Type','application/json');res.end(JSON.stringify({updated_at:'fixture-new',assets:[{name:assetName,digest,size:artifact.length,browser_download_url:`https://github.com/criptogus/${repo}/releases/download/continuous/${assetName}`}]}))}else{res.setHeader('Content-Length',String(artifact.length));createReadStream(resolve(source)).pipe(res)}});await new Promise(r=>server.listen(0,'127.0.0.1',r));const origin=`http://127.0.0.1:${server.address().port}`;writeFileSync(join(profile,'continuous-state.json'),JSON.stringify({seen:'old'}));
await main.eval(`globalThis.auditElectron=process.mainModule.require('electron');globalThis.auditFetch=auditOriginalFetch;auditElectron.net.fetch=(url,opts)=>auditFetch(${JSON.stringify(origin)}+(String(url).includes('api.github.com')?'/meta':'/archive'),opts);globalThis.auditFs=process.mainModule.require('fs');globalThis.auditDir=auditElectron.app.getAppPath()+'/out/main/chunks';globalThis.auditModule=auditFs.readdirSync(auditDir).find(f=>auditFs.readFileSync(auditDir+'/'+f,'utf8').includes('exports.checkForUpdates'));globalThis.auditUpdater=process.mainModule.require(auditDir+'/'+auditModule);auditUpdater.initUpdater({edition:${JSON.stringify(edition)}});`);let downloaded=await main.eval('auditUpdater.checkForUpdates()');for(let i=0;downloaded.busy&&i<600;i++){await sleep(200);downloaded=await main.eval('auditUpdater.checkForUpdates()')}assert(downloaded.continuous==='0.2.7','Update download failed '+JSON.stringify(downloaded));log('Real updater downloads and verifies installer');const oldPort=readFileSync(join(profile,'DevToolsActivePort'),'utf8');assert(await main.eval('auditUpdater.installUpdate()'),'Installer refused');main.ws.close();main=undefined;await browser.close().catch(()=>{});browser=undefined;
for(let i=0;i<900;i++){if(!existsSync(join(profile,'update/pending.json'))&&readNewDebugPort(join(profile,'DevToolsActivePort'),oldPort)!==null)break;await sleep(200)}assert(!existsSync(join(profile,'update/pending.json')),'Update helper did not complete');const port=readNewDebugPort(join(profile,'DevToolsActivePort'),oldPort);assert(port,'Relaunched debugging endpoint is not ready');browser=await chromium.connectOverCDP('http://127.0.0.1:'+port);const context=browser.contexts()[0];page=context.pages()[0]??await context.waitForEvent('page',{timeout:45000});await page.waitForFunction(()=>document.body?.innerText.trim().length>0);assert((await identity(page)).user?.id===id,'Update lost account/session');assert(readFileSync(join(profile,'sentinel'),'utf8')==='preserve','Update lost profile data');log('Native automatic update and relaunch preserve data and session');await page.screenshot({path:join(out,'03-updated.png')});writeFileSync(join(out,'report.json'),JSON.stringify({edition,platform:process.platform,root,checks,passed:checks.length,failed:0,scope:'Packaged source build; controlled update feed'},null,2));
}catch(error){for(const file of ['install.ps1','install.log','helper.log','swap.sh']){const path=join(profile,'update',file);if(existsSync(path))cpSync(path,join(out,file))}if(win){try{writeFileSync(join(out,'processes.json'),execFileSync('powershell.exe',['-NoProfile','-Command',"Get-CimInstance Win32_Process | Where-Object {$_.Name -match 'KeepMind|powershell'} | Select-Object Name,ProcessId,ParentProcessId,CommandLine | ConvertTo-Json"],{encoding:'utf8'}))}catch{}}writeFileSync(join(out,'report.json'),JSON.stringify({edition,platform:process.platform,root,checks,failed:1,error:String(error)},null,2));throw error}finally{await stop();server?.close();if(win){try{execFileSync('powershell.exe',['-NoProfile','-Command',`Get-Process | Where-Object {$_.Path -eq '${exe.replaceAll("'","''")}'} | Stop-Process -Force`])}catch{}}}
Loading
Loading