openrune 0.3.7 → 0.3.9
This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
- package/bin/rune.js +28 -7
- package/lib/index.js +10 -3
- package/package.json +1 -1
package/bin/rune.js
CHANGED
|
@@ -747,8 +747,16 @@ function runRune(file, restArgs) {
|
|
|
747
747
|
if (autoMode) {
|
|
748
748
|
console.log(`🔮 [auto] ${rune.name} is working on: ${prompt}\n`)
|
|
749
749
|
|
|
750
|
+
// Temporarily hide .mcp.json to prevent MCP interference
|
|
751
|
+
const mcpPath = path.join(folderPath, '.mcp.json')
|
|
752
|
+
const mcpBackup = path.join(folderPath, '.mcp.json.bak')
|
|
753
|
+
let mcpHidden = false
|
|
754
|
+
if (fs.existsSync(mcpPath)) {
|
|
755
|
+
fs.renameSync(mcpPath, mcpBackup)
|
|
756
|
+
mcpHidden = true
|
|
757
|
+
}
|
|
758
|
+
|
|
750
759
|
const claudeArgs = ['-p', '--print',
|
|
751
|
-
'--bare',
|
|
752
760
|
'--dangerously-skip-permissions',
|
|
753
761
|
'--verbose',
|
|
754
762
|
'--output-format', 'stream-json',
|
|
@@ -758,6 +766,12 @@ function runRune(file, restArgs) {
|
|
|
758
766
|
}
|
|
759
767
|
claudeArgs.push(prompt)
|
|
760
768
|
|
|
769
|
+
const restoreMcp = () => {
|
|
770
|
+
if (mcpHidden && fs.existsSync(mcpBackup)) {
|
|
771
|
+
fs.renameSync(mcpBackup, mcpPath)
|
|
772
|
+
}
|
|
773
|
+
}
|
|
774
|
+
|
|
761
775
|
const child = spawn('claude', claudeArgs, {
|
|
762
776
|
cwd: folderPath,
|
|
763
777
|
stdio: ['ignore', 'pipe', 'pipe'],
|
|
@@ -820,6 +834,7 @@ function runRune(file, restArgs) {
|
|
|
820
834
|
child.stderr.on('data', (d) => { process.stderr.write(d) })
|
|
821
835
|
|
|
822
836
|
child.on('close', (code) => {
|
|
837
|
+
restoreMcp()
|
|
823
838
|
// Save to history
|
|
824
839
|
rune.history = rune.history || []
|
|
825
840
|
rune.history.push({ role: 'user', text: prompt, ts: Date.now() })
|
|
@@ -831,22 +846,28 @@ function runRune(file, restArgs) {
|
|
|
831
846
|
process.exit(code || 0)
|
|
832
847
|
})
|
|
833
848
|
|
|
849
|
+
// Restore .mcp.json if process is killed
|
|
850
|
+
process.on('SIGINT', restoreMcp)
|
|
851
|
+
process.on('SIGTERM', restoreMcp)
|
|
852
|
+
|
|
834
853
|
return
|
|
835
854
|
}
|
|
836
855
|
|
|
837
856
|
// Normal mode: print-only, no tool execution
|
|
838
|
-
|
|
857
|
+
// Run from tmpdir to avoid .mcp.json interference, add project folder via --add-dir
|
|
858
|
+
const claudeArgs = ['-p', '--print', '--add-dir', folderPath]
|
|
839
859
|
if (systemPrompt) {
|
|
840
|
-
claudeArgs.push('--system-prompt', systemPrompt)
|
|
860
|
+
claudeArgs.push('--system-prompt', systemPrompt + `\nWorking folder: ${folderPath}`)
|
|
841
861
|
}
|
|
842
862
|
if (outputFormat === 'json') {
|
|
843
863
|
claudeArgs.push('--output-format', 'json')
|
|
844
864
|
}
|
|
845
865
|
claudeArgs.push(prompt)
|
|
846
866
|
|
|
867
|
+
const os = require('os')
|
|
847
868
|
const child = spawn('claude', claudeArgs, {
|
|
848
|
-
cwd:
|
|
849
|
-
stdio: ['
|
|
869
|
+
cwd: os.tmpdir(),
|
|
870
|
+
stdio: ['ignore', 'pipe', 'pipe'],
|
|
850
871
|
env: { ...process.env },
|
|
851
872
|
})
|
|
852
873
|
|
|
@@ -955,7 +976,7 @@ async function pipeRunes(args) {
|
|
|
955
976
|
const output = await new Promise((resolve, reject) => {
|
|
956
977
|
const child = spawn('claude', claudeArgs, {
|
|
957
978
|
cwd: folderPath,
|
|
958
|
-
stdio: ['
|
|
979
|
+
stdio: ['ignore', 'pipe', 'pipe'],
|
|
959
980
|
env: { ...process.env },
|
|
960
981
|
})
|
|
961
982
|
|
|
@@ -1066,7 +1087,7 @@ function watchRune(file, restArgs) {
|
|
|
1066
1087
|
|
|
1067
1088
|
const child = spawn('claude', claudeArgs, {
|
|
1068
1089
|
cwd: folderPath,
|
|
1069
|
-
stdio: ['
|
|
1090
|
+
stdio: ['ignore', 'pipe', 'pipe'],
|
|
1070
1091
|
env: { ...process.env },
|
|
1071
1092
|
})
|
|
1072
1093
|
|
package/lib/index.js
CHANGED
|
@@ -44,16 +44,23 @@ function load(filePath) {
|
|
|
44
44
|
}
|
|
45
45
|
}
|
|
46
46
|
|
|
47
|
-
|
|
47
|
+
systemParts.push(`Working folder: ${folderPath}`)
|
|
48
|
+
|
|
49
|
+
const claudeArgs = ['-p', '--print']
|
|
48
50
|
if (systemParts.length > 0) {
|
|
49
51
|
claudeArgs.push('--system-prompt', systemParts.join('\n'))
|
|
50
52
|
}
|
|
53
|
+
claudeArgs.push('--add-dir', folderPath)
|
|
51
54
|
claudeArgs.push(prompt)
|
|
52
55
|
|
|
56
|
+
// Run from a temp dir to avoid loading .mcp.json from the project folder
|
|
57
|
+
const os = require('os')
|
|
58
|
+
const tmpDir = os.tmpdir()
|
|
59
|
+
|
|
53
60
|
const result = await new Promise((resolve, reject) => {
|
|
54
61
|
const child = spawn('claude', claudeArgs, {
|
|
55
|
-
cwd:
|
|
56
|
-
stdio: ['
|
|
62
|
+
cwd: tmpDir,
|
|
63
|
+
stdio: ['ignore', 'pipe', 'pipe'],
|
|
57
64
|
env: { ...process.env },
|
|
58
65
|
})
|
|
59
66
|
|
package/package.json
CHANGED