Skip to content
Closed
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
5 changes: 0 additions & 5 deletions .changeset/filter-system-identity.md

This file was deleted.

5 changes: 3 additions & 2 deletions .github/workflows/release.yml
Original file line number Diff line number Diff line change
Expand Up @@ -12,6 +12,7 @@ jobs:
permissions:
contents: write
pull-requests: write
id-token: write
steps:
- uses: actions/checkout@v4
- uses: oven-sh/setup-bun@v2
Expand All @@ -20,8 +21,8 @@ jobs:
- name: Create release PR or publish
uses: changesets/action@v1
with:
version: bunx changeset version
publish: npm publish
version: bunx changeset version && node scripts/sync-version.mjs
publish: npm publish --provenance --access public
title: "chore: release"
commit: "chore: release"
env:
Expand Down
1 change: 1 addition & 0 deletions .npmrc
Original file line number Diff line number Diff line change
@@ -0,0 +1 @@
//registry.npmjs.org/:_authToken=${NPM_TOKEN}
7 changes: 7 additions & 0 deletions CHANGELOG.md
Original file line number Diff line number Diff line change
@@ -0,0 +1,7 @@
# opencode-workspace-env

## 0.1.1

### Patch Changes

- [#1](https://github.com/yimsk/opencode-workspace-env/pull/1) [`b8a8b5b`](https://github.com/yimsk/opencode-workspace-env/commit/b8a8b5b0c45ee7c3477cdab70f1fb5c285b532b5) Thanks [@yimsk](https://github.com/yimsk)! - Filter system identity variables (HOME, USER, LOGNAME, SHELL, HOSTNAME) from env injection to prevent overriding host values
2 changes: 1 addition & 1 deletion package.json
Original file line number Diff line number Diff line change
@@ -1,6 +1,6 @@
{
"name": "opencode-workspace-env",
"version": "0.1.0",
"version": "0.1.1",
"description": "OpenCode plugin for per-workspace env injection via shell.env hook",
"type": "module",
"main": "dist/index.js",
Expand Down
15 changes: 15 additions & 0 deletions scripts/sync-version.mjs
Original file line number Diff line number Diff line change
@@ -0,0 +1,15 @@
#!/usr/bin/env node
// Sync src/index.ts version with package.json after changeset version
import { readFileSync, writeFileSync } from "node:fs";

const pkg = JSON.parse(readFileSync("package.json", "utf8"));
const indexPath = "src/index.ts";
const content = readFileSync(indexPath, "utf8");
const updated = content.replace(
/export const version = "[^"]+"/,
`export const version = "${pkg.version}"`
);
if (content !== updated) {
writeFileSync(indexPath, updated);
console.log(`synced src/index.ts version to ${pkg.version}`);
}
2 changes: 1 addition & 1 deletion src/index.ts
Original file line number Diff line number Diff line change
Expand Up @@ -6,7 +6,7 @@ import { resolveEnvSource } from "./resolve.js";
import type { EnvExportResult } from "./types.js";

export const name = "opencode-workspace-env";
export const version = "0.1.0";
export const version = "0.1.1";
export const description = "OpenCode plugin for per-workspace env injection via shell.env hook";

const cache = new EnvCache();
Expand Down
23 changes: 11 additions & 12 deletions tests/index.test.ts
Original file line number Diff line number Diff line change
@@ -1,10 +1,11 @@
import { describe, expect, it } from "bun:test";
import { mkdirSync, mkdtempSync, rmSync, writeFileSync } from "node:fs";
import { mkdirSync, mkdtempSync, readFileSync, rmSync, writeFileSync } from "node:fs";
import { join } from "node:path";
import { pathToFileURL } from "node:url";
import type { Hooks, PluginInput } from "@opencode-ai/plugin";

const repoRoot = join(import.meta.dir, "..");
const pkg = JSON.parse(readFileSync(join(repoRoot, "package.json"), "utf-8"));
const scratchRoot = join(repoRoot, ".sisyphus");
mkdirSync(scratchRoot, { recursive: true });
const defaultModulePath = join(repoRoot, "dist/index.js");
Expand Down Expand Up @@ -38,9 +39,9 @@ function createCompliantPluginFixture(): { cleanup: () => void; modulePath: stri
writeFileSync(
modulePath,
[
'export const name = "opencode-workspace-env";',
'export const version = "0.1.0";',
'export const description = "OpenCode plugin for per-workspace env injection via shell.env hook";',
`export const name = "${pkg.name}";`,
`export const version = "${pkg.version}";`,
`export const description = "${pkg.description}";`,
"",
"export default async function plugin(_input) {",
" return {",
Expand All @@ -54,9 +55,9 @@ function createCompliantPluginFixture(): { cleanup: () => void; modulePath: stri
typesPath,
[
'import type { Hooks, PluginInput } from "@opencode-ai/plugin";',
'export declare const name = "opencode-workspace-env";',
'export declare const version = "0.1.0";',
'export declare const description = "OpenCode plugin for per-workspace env injection via shell.env hook";',
`export declare const name = "${pkg.name}";`,
`export declare const version = "${pkg.version}";`,
`export declare const description = "${pkg.description}";`,
"export default function plugin(_input: PluginInput): Promise<Hooks>;",
].join("\n")
);
Expand Down Expand Up @@ -145,11 +146,9 @@ describe("opencode-workspace-env entrypoint contract", () => {
await withResolvedPluginTarget(async ({ modulePath }) => {
const mod = await loadPluginModule(modulePath);

expect(mod.name).toBe("opencode-workspace-env");
expect(mod.version).toBe("0.1.0");
expect(mod.description).toBe(
"OpenCode plugin for per-workspace env injection via shell.env hook"
);
expect(mod.name).toBe(pkg.name);
expect(mod.version).toBe(pkg.version);
expect(mod.description).toBe(pkg.description);
});
});

Expand Down
Loading