feat(ocm-cli): add session move with local history export and TUI plugin (#304)

* loop: ocm-session-move completed after 7 iterations

* feat(ocm-cli): add session move with local history export and TUI plugin

* docs(ocm-cli): update plugin config to tui-only entry and clarify session history source

* fix(ocm-cli): replace raw postinstall output with TUI toast notification
This commit is contained in:
Chris Scott authored and GitHub committed 2026-07-08 17:23:53 -04:00
1 parent 54323267f5
commit 61efcf9ad1
19 files changed
+906 -157

No files matched your search

+15 -25
View File
@@ -6,37 +6,27 @@ const dist = join(root, 'dist')
rmSync(dist, { recursive: true, force: true })
console.log('Bundling ocm CLI...')
const cliResult = await Bun.build({
entrypoints: [join(root, 'bin', 'ocm.ts')],
outdir: dist,
target: 'node',
format: 'esm',
naming: { entry: 'ocm.js' },
})
async function bundleEntry(label: string, entrypoint: string, outputName: string): Promise<void> {
console.log(`Bundling ${label}...`)
const result = await Bun.build({
entrypoints: [join(root, entrypoint)],
outdir: dist,
target: 'node',
format: 'esm',
external: ['bun:sqlite'],
naming: { entry: outputName },
})
if (!cliResult.success) {
for (const log of cliResult.logs) {
if (result.success) return
for (const log of result.logs) {
console.error(log)
}
process.exit(1)
}
console.log('Bundling opencode plugin entry...')
const pluginResult = await Bun.build({
entrypoints: [join(root, 'src', 'plugin.ts')],
outdir: dist,
target: 'node',
format: 'esm',
naming: { entry: 'plugin.js' },
})
if (!pluginResult.success) {
for (const log of pluginResult.logs) {
console.error(log)
}
process.exit(1)
}
await bundleEntry('ocm CLI', join('bin', 'ocm.ts'), 'ocm.js')
await bundleEntry('TUI plugin entry', join('src', 'tui-plugin.ts'), 'tui.js')
const ocmJsPath = join(dist, 'ocm.js')
const ocmJsContent = readFileSync(ocmJsPath, 'utf-8')
+15 -14
View File
@@ -1,5 +1,5 @@
#!/usr/bin/env node
import { existsSync, mkdirSync, symlinkSync, unlinkSync, lstatSync, readlinkSync, chmodSync } from 'node:fs'
import { existsSync, mkdirSync, symlinkSync, unlinkSync, lstatSync, readlinkSync, chmodSync, writeFileSync } from 'node:fs'
import { homedir } from 'node:os'
import { join, resolve, dirname } from 'node:path'
import { fileURLToPath } from 'node:url'
@@ -26,16 +26,24 @@ if (process.env.npm_config_global === 'true' || process.env.npm_config_global ==
}
const binDir = join(homedir(), '.local', 'bin')
const link = join(binDir, 'ocm')
const noticeDir = join(homedir(), '.config', 'opencode-manager')
const noticeFile = join(noticeDir, 'install-notice.json')
function writeInstallNotice(pathMissing) {
try {
mkdirSync(noticeDir, { recursive: true })
writeFileSync(noticeFile, JSON.stringify({ link, binDir, pathMissing }, null, 2), { mode: 0o600 })
} catch {
}
}
try {
mkdirSync(binDir, { recursive: true })
} catch (err) {
process.stderr.write(`ocm-cli: cannot create ${binDir}: ${err.message}\n`)
} catch {
process.exit(0)
}
const link = join(binDir, 'ocm')
try {
const stat = lstatSync(link)
if (stat.isSymbolicLink()) {
@@ -44,7 +52,6 @@ try {
}
unlinkSync(link)
} else {
process.stderr.write(`ocm-cli: ${link} exists and is not a symlink; leaving alone\n`)
process.exit(0)
}
} catch {
@@ -53,15 +60,9 @@ try {
try {
symlinkSync(target, link)
} catch (err) {
process.stderr.write(`ocm-cli: failed to symlink ${link}: ${err.message}\n`)
} catch {
process.exit(0)
}
process.stdout.write(`ocm installed at ${link}\n`)
const path = process.env.PATH ?? ''
if (!path.split(':').includes(binDir)) {
process.stdout.write(`note: ${binDir} is not on your PATH. Add to your shell rc:\n`)
process.stdout.write(` export PATH="${binDir}:$PATH"\n`)
}
writeInstallNotice(!path.split(':').includes(binDir))