mirror of
https://github.com/sdwolf4103/opencode-working-memory.git
synced 2026-06-02 06:19:36 +02:00
fix: package memory-diag compiled runtime
This commit is contained in:
@@ -5,6 +5,16 @@ All notable changes to this project will be documented in this file.
|
|||||||
The format is based on [Keep a Changelog](https://keepachangelog.com/en/1.0.0/),
|
The format is based on [Keep a Changelog](https://keepachangelog.com/en/1.0.0/),
|
||||||
and this project adheres to [Semantic Versioning](https://semver.org/spec/v2.0.0.html).
|
and this project adheres to [Semantic Versioning](https://semver.org/spec/v2.0.0.html).
|
||||||
|
|
||||||
|
## [1.6.2] - 2026-05-11
|
||||||
|
|
||||||
|
### Fixed
|
||||||
|
|
||||||
|
- Fixed the published `memory-diag` npm bin by compiling the diagnostics CLI before packing and launching the compiled JavaScript runtime instead of type-stripping TypeScript under `node_modules`.
|
||||||
|
|
||||||
|
### Added
|
||||||
|
|
||||||
|
- Added a pack/npx smoke test that runs `memory-diag --help` from a packed tarball outside the repository.
|
||||||
|
|
||||||
## [1.6.1] - 2026-05-08
|
## [1.6.1] - 2026-05-08
|
||||||
|
|
||||||
### Added
|
### Added
|
||||||
|
|||||||
@@ -1,5 +1,40 @@
|
|||||||
# Release Notes
|
# Release Notes
|
||||||
|
|
||||||
|
## 1.6.2 (2026-05-11)
|
||||||
|
|
||||||
|
### Published `memory-diag` Bin Fix
|
||||||
|
|
||||||
|
This patch release fixes the published npm package path for `memory-diag`. In v1.6.1 the source-tree CLI tests passed, but the installed package could fail under `npx --package opencode-working-memory memory-diag` because Node refuses TypeScript type stripping for files inside `node_modules`.
|
||||||
|
|
||||||
|
v1.6.2 compiles the diagnostics CLI during packing and makes the npm bin launch the compiled JavaScript runtime.
|
||||||
|
|
||||||
|
### What Changed
|
||||||
|
|
||||||
|
- **Compiled diagnostics runtime**: `prepack` now builds `dist/scripts/memory-diag.js` before the package is packed or published.
|
||||||
|
- **Safer npm bin wrapper**: `memory-diag` no longer runs published `.ts` files through `--experimental-strip-types`; it launches the compiled JS artifact and reports a clear reinstall/build message if the artifact is missing.
|
||||||
|
- **Packaged-bin smoke test**: release verification now includes a pack/npx smoke test from a temp consumer project outside the repository.
|
||||||
|
|
||||||
|
### Upgrade Notes
|
||||||
|
|
||||||
|
- No config changes are required.
|
||||||
|
- Existing OpenCode server and TUI plugin entry points are unchanged.
|
||||||
|
- If you hit the v1.6.1 bin failure, upgrade and rerun:
|
||||||
|
|
||||||
|
```bash
|
||||||
|
npx --package opencode-working-memory@1.6.2 memory-diag --help
|
||||||
|
```
|
||||||
|
|
||||||
|
### Validation
|
||||||
|
|
||||||
|
- `npm run build` — `BUILD_PASS`
|
||||||
|
- `node ./scripts/memory-diag-bin.cjs --help`
|
||||||
|
- `npm run test:pack:memory-diag` — packed tarball smoke test passed
|
||||||
|
- `npm run typecheck` — `TYPECHECK_PASS`
|
||||||
|
- `npm test` — 421 tests passing, `TEST_PASS`
|
||||||
|
- `npm pack --dry-run` — includes compiled `dist/` diagnostics artifacts
|
||||||
|
|
||||||
|
---
|
||||||
|
|
||||||
## 1.6.1 (2026-05-08)
|
## 1.6.1 (2026-05-08)
|
||||||
|
|
||||||
### Native TUI Memory Menu
|
### Native TUI Memory Menu
|
||||||
|
|||||||
+8
-3
@@ -1,6 +1,6 @@
|
|||||||
{
|
{
|
||||||
"name": "opencode-working-memory",
|
"name": "opencode-working-memory",
|
||||||
"version": "1.6.1",
|
"version": "1.6.2",
|
||||||
"description": "Three-layer memory architecture for OpenCode with workspace memory and hot session state",
|
"description": "Three-layer memory architecture for OpenCode with workspace memory and hot session state",
|
||||||
"type": "module",
|
"type": "module",
|
||||||
"main": "index.ts",
|
"main": "index.ts",
|
||||||
@@ -18,12 +18,17 @@
|
|||||||
"scripts/memory-diag.ts",
|
"scripts/memory-diag.ts",
|
||||||
"scripts/memory-diag/",
|
"scripts/memory-diag/",
|
||||||
"scripts/memory-diag-bin.cjs",
|
"scripts/memory-diag-bin.cjs",
|
||||||
|
"dist/",
|
||||||
"README.md",
|
"README.md",
|
||||||
"LICENSE"
|
"LICENSE"
|
||||||
],
|
],
|
||||||
"scripts": {
|
"scripts": {
|
||||||
"build": "node -e \"console.log('No build step required: OpenCode loads index.ts directly')\"",
|
"clean:dist": "node -e \"require('node:fs').rmSync('dist',{recursive:true,force:true})\"",
|
||||||
"diag": "node --experimental-strip-types scripts/memory-diag.ts",
|
"build:memory-diag": "npm run clean:dist && tsc -p tsconfig.memory-diag.json",
|
||||||
|
"build": "npm run build:memory-diag && node -e \"console.log('BUILD_PASS')\"",
|
||||||
|
"prepack": "npm run build",
|
||||||
|
"diag": "npm run --silent build:memory-diag && node ./scripts/memory-diag-bin.cjs",
|
||||||
|
"test:pack:memory-diag": "node --test --experimental-strip-types tests/smoke/memory-diag-packaging.test.ts",
|
||||||
"typecheck": "tsc --noEmit && node -e \"console.log('TYPECHECK_PASS')\"",
|
"typecheck": "tsc --noEmit && node -e \"console.log('TYPECHECK_PASS')\"",
|
||||||
"test": "node --import ./tests/setup-xdg-data-home.ts --test --experimental-strip-types tests/*.test.ts && node -e \"console.log('TEST_PASS')\"",
|
"test": "node --import ./tests/setup-xdg-data-home.ts --test --experimental-strip-types tests/*.test.ts && node -e \"console.log('TEST_PASS')\"",
|
||||||
"check:compat": "npm install --no-save @opencode-ai/plugin@latest && npm run typecheck && npm test"
|
"check:compat": "npm install --no-save @opencode-ai/plugin@latest && npm run typecheck && npm test"
|
||||||
|
|||||||
@@ -1,5 +1,6 @@
|
|||||||
#!/usr/bin/env node
|
#!/usr/bin/env node
|
||||||
const { execFileSync } = require("child_process");
|
const { execFileSync } = require("child_process");
|
||||||
|
const { existsSync } = require("fs");
|
||||||
const path = require("path");
|
const path = require("path");
|
||||||
|
|
||||||
function isSupportedNodeVersion(version) {
|
function isSupportedNodeVersion(version) {
|
||||||
@@ -9,13 +10,19 @@ function isSupportedNodeVersion(version) {
|
|||||||
}
|
}
|
||||||
|
|
||||||
if (!isSupportedNodeVersion(process.versions.node)) {
|
if (!isSupportedNodeVersion(process.versions.node)) {
|
||||||
process.stderr.write(`memory-diag requires Node >=22.6.0 because it runs TypeScript with --experimental-strip-types. Current Node: v${process.versions.node}.\n`);
|
process.stderr.write(`memory-diag requires Node >=22.6.0 per opencode-working-memory package engines. Current Node: v${process.versions.node}.\n`);
|
||||||
process.exit(1);
|
process.exit(1);
|
||||||
}
|
}
|
||||||
|
|
||||||
const binDir = __dirname;
|
const binDir = __dirname;
|
||||||
const tsScript = path.join(binDir, "memory-diag.ts");
|
const compiledScript = path.join(binDir, "..", "dist", "scripts", "memory-diag.js");
|
||||||
const args = ["--experimental-strip-types", tsScript, ...process.argv.slice(2)];
|
|
||||||
|
if (!existsSync(compiledScript)) {
|
||||||
|
process.stderr.write("memory-diag package is missing dist/scripts/memory-diag.js. Reinstall opencode-working-memory or run npm run build before using the local package.\n");
|
||||||
|
process.exit(1);
|
||||||
|
}
|
||||||
|
|
||||||
|
const args = [compiledScript, ...process.argv.slice(2)];
|
||||||
try {
|
try {
|
||||||
execFileSync(process.execPath, args, { stdio: "inherit" });
|
execFileSync(process.execPath, args, { stdio: "inherit" });
|
||||||
process.exit(0);
|
process.exit(0);
|
||||||
|
|||||||
@@ -0,0 +1,51 @@
|
|||||||
|
import test from "node:test";
|
||||||
|
import assert from "node:assert/strict";
|
||||||
|
import { execFile } from "node:child_process";
|
||||||
|
import { mkdir, mkdtemp, rm } from "node:fs/promises";
|
||||||
|
import { tmpdir } from "node:os";
|
||||||
|
import { dirname, join } from "node:path";
|
||||||
|
import { fileURLToPath } from "node:url";
|
||||||
|
import { promisify } from "node:util";
|
||||||
|
|
||||||
|
const execFileAsync = promisify(execFile);
|
||||||
|
const repoRoot = join(dirname(fileURLToPath(import.meta.url)), "../..");
|
||||||
|
const maxBuffer = 10 * 1024 * 1024;
|
||||||
|
|
||||||
|
function executable(name: "npm" | "npx"): string {
|
||||||
|
return process.platform === "win32" ? `${name}.cmd` : name;
|
||||||
|
}
|
||||||
|
|
||||||
|
test("packed memory-diag bin runs from a temp consumer project", async () => {
|
||||||
|
const tempRoot = await mkdtemp(join(tmpdir(), "opencode-memory-diag-packaging-"));
|
||||||
|
const packDir = join(tempRoot, "pack");
|
||||||
|
const consumerDir = join(tempRoot, "consumer");
|
||||||
|
|
||||||
|
try {
|
||||||
|
await mkdir(packDir, { recursive: true });
|
||||||
|
await mkdir(consumerDir, { recursive: true });
|
||||||
|
|
||||||
|
const packResult = await execFileAsync(executable("npm"), [
|
||||||
|
"pack",
|
||||||
|
repoRoot,
|
||||||
|
"--pack-destination",
|
||||||
|
packDir,
|
||||||
|
"--silent",
|
||||||
|
], { cwd: tempRoot, maxBuffer });
|
||||||
|
const tarballName = packResult.stdout.trim().split(/\r?\n/).filter(Boolean).at(-1);
|
||||||
|
assert.ok(tarballName, `npm pack did not report a tarball name. stdout:\n${packResult.stdout}\nstderr:\n${packResult.stderr}`);
|
||||||
|
|
||||||
|
const tarballPath = join(packDir, tarballName);
|
||||||
|
const runResult = await execFileAsync(executable("npx"), [
|
||||||
|
"--yes",
|
||||||
|
"--package",
|
||||||
|
tarballPath,
|
||||||
|
"memory-diag",
|
||||||
|
"--help",
|
||||||
|
], { cwd: consumerDir, maxBuffer });
|
||||||
|
|
||||||
|
assert.match(runResult.stdout, /Usage:/);
|
||||||
|
assert.match(runResult.stdout, /memory-diag \[status\]/);
|
||||||
|
} finally {
|
||||||
|
await rm(tempRoot, { recursive: true, force: true });
|
||||||
|
}
|
||||||
|
});
|
||||||
@@ -0,0 +1,27 @@
|
|||||||
|
{
|
||||||
|
"extends": "./tsconfig.json",
|
||||||
|
"compilerOptions": {
|
||||||
|
"allowImportingTsExtensions": true,
|
||||||
|
"noEmit": false,
|
||||||
|
"outDir": "dist",
|
||||||
|
"rootDir": ".",
|
||||||
|
"declaration": false,
|
||||||
|
"sourceMap": false,
|
||||||
|
"rewriteRelativeImportExtensions": true,
|
||||||
|
"tsBuildInfoFile": "dist/.tsbuildinfo"
|
||||||
|
},
|
||||||
|
"include": ["scripts/memory-diag.ts", "scripts/memory-diag/**/*.ts", "src/**/*.ts"],
|
||||||
|
"exclude": [
|
||||||
|
"node_modules",
|
||||||
|
"dist",
|
||||||
|
"tests",
|
||||||
|
"src/plugin.ts",
|
||||||
|
"src/tui-plugin.ts",
|
||||||
|
"src/opencode.ts",
|
||||||
|
"src/session-state.ts",
|
||||||
|
"src/extractors.ts",
|
||||||
|
"src/pending-journal.ts",
|
||||||
|
"src/promotion-accounting.ts",
|
||||||
|
"src/memory-visibility.ts"
|
||||||
|
]
|
||||||
|
}
|
||||||
Reference in New Issue
Block a user