diff --git a/opencode/command/ci-audit.md b/opencode/command/ci-audit.md
index b68e9fa..4663e08 100644
--- a/opencode/command/ci-audit.md
+++ b/opencode/command/ci-audit.md
@@ -8,7 +8,7 @@ tools:
---
-@/home/jchery/.config/opencode/ci/workflows/audit.md
+@__OPENCODE_DIR__/ci/workflows/audit.md
diff --git a/opencode/command/ci-clarify.md b/opencode/command/ci-clarify.md
index 5417ca7..197b0ee 100644
--- a/opencode/command/ci-clarify.md
+++ b/opencode/command/ci-clarify.md
@@ -13,7 +13,7 @@ tools:
---
-@/home/jchery/.config/opencode/ci/workflows/clarify.md
+@__OPENCODE_DIR__/ci/workflows/clarify.md
diff --git a/opencode/command/ci-debug.md b/opencode/command/ci-debug.md
index e189801..2d2f067 100644
--- a/opencode/command/ci-debug.md
+++ b/opencode/command/ci-debug.md
@@ -13,7 +13,7 @@ tools:
---
-@/home/jchery/.config/opencode/ci/workflows/debug.md
+@__OPENCODE_DIR__/ci/workflows/debug.md
diff --git a/opencode/command/ci-init.md b/opencode/command/ci-init.md
index a1f09db..a3a5750 100644
--- a/opencode/command/ci-init.md
+++ b/opencode/command/ci-init.md
@@ -13,7 +13,7 @@ tools:
---
-@/home/jchery/.config/opencode/ci/workflows/init.md
+@__OPENCODE_DIR__/ci/workflows/init.md
diff --git a/opencode/command/ci-quick.md b/opencode/command/ci-quick.md
index c867065..7ec5a39 100644
--- a/opencode/command/ci-quick.md
+++ b/opencode/command/ci-quick.md
@@ -13,7 +13,7 @@ tools:
---
-@/home/jchery/.config/opencode/ci/workflows/quick.md
+@__OPENCODE_DIR__/ci/workflows/quick.md
diff --git a/opencode/command/ci-review.md b/opencode/command/ci-review.md
index 9ac08e3..6c1b80c 100644
--- a/opencode/command/ci-review.md
+++ b/opencode/command/ci-review.md
@@ -12,7 +12,7 @@ tools:
---
-@/home/jchery/.config/opencode/ci/workflows/review.md
+@__OPENCODE_DIR__/ci/workflows/review.md
diff --git a/opencode/command/ci-rollback.md b/opencode/command/ci-rollback.md
index 2e14fbd..595a8b4 100644
--- a/opencode/command/ci-rollback.md
+++ b/opencode/command/ci-rollback.md
@@ -13,7 +13,7 @@ tools:
---
-@/home/jchery/.config/opencode/ci/workflows/rollback.md
+@__OPENCODE_DIR__/ci/workflows/rollback.md
diff --git a/opencode/command/ci-run.md b/opencode/command/ci-run.md
index 4f5421e..3bf4130 100644
--- a/opencode/command/ci-run.md
+++ b/opencode/command/ci-run.md
@@ -13,7 +13,7 @@ tools:
---
-@/home/jchery/.config/opencode/ci/workflows/run.md
+@__OPENCODE_DIR__/ci/workflows/run.md
diff --git a/opencode/command/ci-ship.md b/opencode/command/ci-ship.md
index 77b16d1..3ce9df3 100644
--- a/opencode/command/ci-ship.md
+++ b/opencode/command/ci-ship.md
@@ -12,7 +12,7 @@ tools:
---
-@/home/jchery/.config/opencode/ci/workflows/ship.md
+@__OPENCODE_DIR__/ci/workflows/ship.md
diff --git a/opencode/command/ci-status.md b/opencode/command/ci-status.md
index b4ad88d..25b9983 100644
--- a/opencode/command/ci-status.md
+++ b/opencode/command/ci-status.md
@@ -8,7 +8,7 @@ tools:
---
-@/home/jchery/.config/opencode/ci/workflows/status.md
+@__OPENCODE_DIR__/ci/workflows/status.md
diff --git a/opencode/command/ci-verify.md b/opencode/command/ci-verify.md
index 3b3a793..7215935 100644
--- a/opencode/command/ci-verify.md
+++ b/opencode/command/ci-verify.md
@@ -12,7 +12,7 @@ tools:
---
-@/home/jchery/.config/opencode/ci/workflows/verify.md
+@__OPENCODE_DIR__/ci/workflows/verify.md
diff --git a/scripts/install.sh b/scripts/install.sh
index 7b605e6..5fec96a 100644
--- a/scripts/install.sh
+++ b/scripts/install.sh
@@ -70,7 +70,7 @@ copy_file() {
return
fi
- cp "$src" "$dest"
+ sed "s|__OPENCODE_DIR__|${OPENCODE_DIR}|g" "$src" > "$dest"
COPIED=$((COPIED + 1))
}
@@ -109,14 +109,16 @@ CI_JSON="${CI_DIR}/opencode.json"
if [ -f "$CI_JSON" ]; then
if [ ! -f "$OPENCODE_JSON" ]; then
- cp "$CI_JSON" "$OPENCODE_JSON"
+ sed "s|__OPENCODE_DIR__|${OPENCODE_DIR}|g" "$CI_JSON" > "$OPENCODE_JSON"
echo " Created opencode.json"
else
if command -v node &>/dev/null; then
+ local_ci_json="$(sed "s|__OPENCODE_DIR__|${OPENCODE_DIR}|g" "$CI_JSON")"
+ echo "$local_ci_json" > /tmp/ci-json-merge.json
node -e "
const fs = require('fs');
const existing = JSON.parse(fs.readFileSync('${OPENCODE_JSON}', 'utf8'));
- const ci = JSON.parse(fs.readFileSync('${CI_JSON}', 'utf8'));
+ const ci = JSON.parse(fs.readFileSync('/tmp/ci-json-merge.json', 'utf8'));
const merged = { ...existing };
merged.permission = merged.permission || {};
merged.permission.read = merged.permission.read || {};
@@ -130,6 +132,7 @@ if [ -f "$CI_JSON" ]; then
fs.writeFileSync('${OPENCODE_JSON}', JSON.stringify(merged, null, 2));
console.log(' Merged permissions (preserved existing entries)');
"
+ rm -f /tmp/ci-json-merge.json
else
echo " Warning: node not found. Manually merge opencode.json permissions."
echo " Add to opencode.json:"
diff --git a/scripts/postinstall.js b/scripts/postinstall.js
index 516188d..c296677 100644
--- a/scripts/postinstall.js
+++ b/scripts/postinstall.js
@@ -20,7 +20,7 @@ function isGlobalInstall() {
return false;
}
-function copyFile(src, dest, force) {
+function copyFile(src, dest, force, templateVars) {
if (!fs.existsSync(src)) return { copied: 0, skipped: 0 };
const dir = path.dirname(dest);
@@ -28,17 +28,27 @@ function copyFile(src, dest, force) {
if (fs.existsSync(dest) && !force) {
try {
- const srcContent = fs.readFileSync(src, "utf8");
+ const srcContent = applyTemplate(fs.readFileSync(src, "utf8"), templateVars);
const destContent = fs.readFileSync(dest, "utf8");
if (srcContent === destContent) return { copied: 0, skipped: 1 };
} catch {}
return { copied: 0, skipped: 1 };
}
- fs.copyFileSync(src, dest);
+ const content = applyTemplate(fs.readFileSync(src, "utf8"), templateVars);
+ fs.writeFileSync(dest, content, "utf8");
return { copied: 1, skipped: 0 };
}
+function applyTemplate(content, vars) {
+ if (!vars) return content;
+ let result = content;
+ for (const [key, value] of Object.entries(vars)) {
+ result = result.replaceAll(key, value);
+ }
+ return result;
+}
+
function install() {
const pkgDir = getPackageDir();
if (!pkgDir) {
@@ -58,6 +68,10 @@ function install() {
return;
}
+ const templateVars = {
+ __OPENCODE_DIR__: OPENCODE_DIR,
+ };
+
let copied = 0;
let skipped = 0;
@@ -68,7 +82,7 @@ function install() {
return f.startsWith(pattern);
});
for (const entry of entries) {
- const result = copyFile(path.join(srcDir, entry), path.join(destDir, entry), false);
+ const result = copyFile(path.join(srcDir, entry), path.join(destDir, entry), false, templateVars);
copied += result.copied;
skipped += result.skipped;
}
@@ -88,7 +102,7 @@ function install() {
const versionFile = path.join(opencodeDir, "ci", "VERSION");
if (fs.existsSync(versionFile)) {
- const result = copyFile(versionFile, path.join(OPENCODE_DIR, "ci", "VERSION"), false);
+ const result = copyFile(versionFile, path.join(OPENCODE_DIR, "ci", "VERSION"), false, templateVars);
copied += result.copied;
skipped += result.skipped;
}
@@ -98,11 +112,12 @@ function install() {
if (fs.existsSync(ciJsonPath)) {
if (!fs.existsSync(targetJsonPath)) {
- fs.copyFileSync(ciJsonPath, targetJsonPath);
+ const content = applyTemplate(fs.readFileSync(ciJsonPath, "utf8"), templateVars);
+ fs.writeFileSync(targetJsonPath, content, "utf8");
} else {
try {
const existing = JSON.parse(fs.readFileSync(targetJsonPath, "utf8"));
- const ciJson = JSON.parse(fs.readFileSync(ciJsonPath, "utf8"));
+ const ciJson = JSON.parse(applyTemplate(fs.readFileSync(ciJsonPath, "utf8"), templateVars));
existing.permission = existing.permission || {};
existing.permission.read = existing.permission.read || {};
existing.permission.external_directory = existing.permission.external_directory || {};