Skip to content

armgit / Orkas

Public Imported from GitHub
0

Orkas is an open-source (MIT), local-first AI team for your desktop: a Commander turns your goal into to-dos and coordinates 16 built-in specialist agents plus Claude Code, Codex, OpenCode, OpenClaw and Hermes, with projects, scheduled automations and connectors. Free app for macOS & Windows; built-in models or your own keys.

Let shell handle run-skill redirection

wyt8cb49dd39940
diff --git a/bin/orkas-pkg.cjs b/bin/orkas-pkg.cjs
index 2a7b8847..005dd9d0 100644
--- a/bin/orkas-pkg.cjs
+++ b/bin/orkas-pkg.cjs
@@ -4,7 +4,7 @@
*
* Invoked by the LLM bash tool (guided by the `package-installer` system
* skill) as:
- * $ORKAS_NODE $ORKAS_PC_DIR/bin/orkas-pkg.cjs <command> [args...]
+ * "$ORKAS_NODE" "$ORKAS_PC_DIR/bin/orkas-pkg.cjs" <command> [args...]
*
* Commands:
* install <git-url-or-local-path> [--name <name>] [--consent-deps]
diff --git a/bin/run-skill.cjs b/bin/run-skill.cjs
index 13039443..262d282f 100755
--- a/bin/run-skill.cjs
+++ b/bin/run-skill.cjs
@@ -3,7 +3,7 @@
* Orkas skill runner.
*
* Invoked by LLM bash tool as:
- * $ORKAS_NODE $ORKAS_PC_DIR/bin/run-skill.cjs <skill-id-or-name> <script-basename> [-- args...]
+ * "$ORKAS_NODE" "$ORKAS_PC_DIR/bin/run-skill.cjs" <skill-id-or-name> <script-basename> [-- args...]
*
* Dispatches by file extension so the LLM uses one invocation form regardless
* of skill language:
diff --git a/src/main/model/core-agent/local-tools.ts b/src/main/model/core-agent/local-tools.ts
index b7ea4ba1..d041eb9a 100644
--- a/src/main/model/core-agent/local-tools.ts
+++ b/src/main/model/core-agent/local-tools.ts
@@ -333,6 +333,37 @@ function splitTrailingHeredoc(command: string): { command: string; stdin: string
};
}
+function hasUnquotedShellControlSyntax(input: string): boolean {
+ let quote: "'" | '"' | null = null;
+ for (let i = 0; i < input.length; i++) {
+ const ch = input[i];
+ if (quote === "'") {
+ if (ch === "'") quote = null;
+ continue;
+ }
+ if (quote === '"') {
+ if (ch === '"') {
+ quote = null;
+ continue;
+ }
+ if (ch === '\\' && i + 1 < input.length) i++;
+ continue;
+ }
+ if (ch === "'" || ch === '"') {
+ quote = ch;
+ continue;
+ }
+ if (ch === '\\' && i + 1 < input.length) {
+ i++;
+ continue;
+ }
+ if (ch === '\n' || ch === '\r' || ch === ';' || ch === '|' || ch === '&' || ch === '<' || ch === '>') {
+ return true;
+ }
+ }
+ return false;
+}
+
function shellWords(input: string): string[] | null {
const words: string[] = [];
let cur = '';
@@ -408,6 +439,7 @@ function parseOrkasCliInvocation(
const rawCommand = String(input.command ?? '');
const heredoc = splitTrailingHeredoc(rawCommand);
const command = heredoc?.command ?? rawCommand;
+ if (hasUnquotedShellControlSyntax(command)) return null;
const words = shellWords(command);
if (!words || words.length < 2) return null;
diff --git a/src/main/system_skills/package-installer/SKILL.md b/src/main/system_skills/package-installer/SKILL.md
index 5fc30617..bd54ef5d 100644
--- a/src/main/system_skills/package-installer/SKILL.md
+++ b/src/main/system_skills/package-installer/SKILL.md
@@ -16,7 +16,7 @@ Run the Orkas CLI command below through the command execution tool; Orkas
handles this runner form directly on Windows:
```text
-$ORKAS_NODE "$ORKAS_PC_DIR/bin/orkas-pkg.cjs" <command> [args]
+"$ORKAS_NODE" "$ORKAS_PC_DIR/bin/orkas-pkg.cjs" <command> [args]
```
Commands: `install <git-url> [--name <name>] [--consent-deps]`,
@@ -58,7 +58,7 @@ a successful CLI install — the user already approved installing it. Skip for
2. Write the skill via stdin (the file lands outside the package tree):
```bash
- $ORKAS_NODE "$ORKAS_PC_DIR/bin/orkas-pkg.cjs" skill-write <name> <<'SKILL'
+ "$ORKAS_NODE" "$ORKAS_PC_DIR/bin/orkas-pkg.cjs" skill-write <name> <<'SKILL'
---
name: <human name>
description: <one line: what it does + when to use it>
diff --git a/src/main/system_skills/skill-creator/SKILL.md b/src/main/system_skills/skill-creator/SKILL.md
index 354afd0f..12a0f72b 100644
--- a/src/main/system_skills/skill-creator/SKILL.md
+++ b/src/main/system_skills/skill-creator/SKILL.md
@@ -253,10 +253,10 @@ Add implementation-specific subsections only when they are needed:
Single entry point template (write this in the body's "How to call" section):
```
-$ORKAS_NODE $ORKAS_PC_DIR/bin/run-skill.cjs <skill-id> <script-basename> [-- args...]
+"$ORKAS_NODE" "$ORKAS_PC_DIR/bin/run-skill.cjs" <skill-id> <script-basename> [-- args...]
```
-**Do NOT prefix the command with `bash`** — the command execution tool runs `command` itself; a `bash` prefix tells the shell to execute the Electron binary as a script and produces "cannot execute binary file". The command starts with `$ORKAS_NODE`. The `<script-basename>` does NOT include the extension — only one file per basename per directory.
+**Do NOT prefix the command with `bash`** — the command execution tool runs `command` itself; a `bash` prefix tells the shell to execute the Electron binary as a script and produces "cannot execute binary file". The command starts with `"$ORKAS_NODE"`; keep both runner path parts quoted because app paths can contain spaces. The `<script-basename>` does NOT include the extension — only one file per basename per directory.
Use this exact Orkas runner shape for cross-platform skill execution. It is handled by Orkas's direct CLI path; generic Unix shell pipelines remain OS/shell-specific and should not be the primary implementation of a new skill.
diff --git a/test/main/model/core-agent/local-tools.test.ts b/test/main/model/core-agent/local-tools.test.ts
index 96b2aaeb..57541c87 100644
--- a/test/main/model/core-agent/local-tools.test.ts
+++ b/test/main/model/core-agent/local-tools.test.ts
@@ -92,7 +92,7 @@ describe('local-tools › bash › disabled skills', () => {
const bash = await buildBashTool();
const r = await run(bash, {
- command: '$ORKAS_NODE $ORKAS_PC_DIR/bin/run-skill.cjs disabled-skill search -- query',
+ command: '"$ORKAS_NODE" "$ORKAS_PC_DIR/bin/run-skill.cjs" disabled-skill search -- query',
});
expect(r.isError).toBe(true);
diff --git a/test/main/model/local-tools.test.ts b/test/main/model/local-tools.test.ts
index a32ade1f..28ca2b02 100644
--- a/test/main/model/local-tools.test.ts
+++ b/test/main/model/local-tools.test.ts
@@ -172,7 +172,7 @@ describe('local-tools › Orkas CLI direct execution', () => {
const bash = lt.createLocalTools({}).find((t) => t.name === 'bash')!;
const res = await bash.execute({
- command: '$ORKAS_NODE "$ORKAS_PC_DIR/bin/run-skill.cjs" calculator eval -- 1+1',
+ command: '"$ORKAS_NODE" "$ORKAS_PC_DIR/bin/run-skill.cjs" calculator eval -- 1+1',
timeoutMs: 5000,
}, makeOrkasCtx(pcDir));
@@ -193,7 +193,7 @@ describe('local-tools › Orkas CLI direct execution', () => {
const body = "---\nname: Demo\n---\n\n# Demo";
const res = await bash.execute({
- command: `$ORKAS_NODE "$ORKAS_PC_DIR/bin/orkas-pkg.cjs" skill-write demo <<'SKILL'\n${body}\nSKILL`,
+ command: `"$ORKAS_NODE" "$ORKAS_PC_DIR/bin/orkas-pkg.cjs" skill-write demo <<'SKILL'\n${body}\nSKILL`,
timeoutMs: 5000,
}, makeOrkasCtx(pcDir));
@@ -203,6 +203,29 @@ describe('local-tools › Orkas CLI direct execution', () => {
expect(parsed.body).toBe(body);
});
+ it('lets the host shell handle redirection for standard Orkas CLI commands', async () => {
+ const { lt, perm } = await loadModules();
+ perm.grantLocalExec();
+ const pcDir = writeFakePcScript(
+ 'run-skill.cjs',
+ "process.stdout.write(JSON.stringify({ argv: process.argv.slice(2) }));",
+ );
+ const bash = lt.createLocalTools({}).find((t) => t.name === 'bash')!;
+ const outPath = path.join(tmpDir, 'run-skill-output.json');
+ const errPath = path.join(tmpDir, 'run-skill-stderr.txt');
+
+ const res = await bash.execute({
+ command: `"$ORKAS_NODE" "$ORKAS_PC_DIR/bin/run-skill.cjs" calculator eval -- 1+1 2> "${errPath}" > "${outPath}"`,
+ timeoutMs: 5000,
+ }, makeOrkasCtx(pcDir));
+
+ expect(res.isError).toBeFalsy();
+ expect(String(res.content)).toBe('');
+ const parsed = JSON.parse(fs.readFileSync(outPath, 'utf8'));
+ expect(parsed.argv).toEqual(['calculator', 'eval', '--', '1+1']);
+ expect(fs.readFileSync(errPath, 'utf8')).toBe('');
+ });
+
it('times out direct Orkas CLI commands whose child keeps stdout open', async () => {
const { lt, perm } = await loadModules();
perm.grantLocalExec();
@@ -218,7 +241,7 @@ describe('local-tools › Orkas CLI direct execution', () => {
const started = Date.now();
const res = await bash.execute({
- command: '$ORKAS_NODE "$ORKAS_PC_DIR/bin/run-skill.cjs" calculator eval -- 1+1',
+ command: '"$ORKAS_NODE" "$ORKAS_PC_DIR/bin/run-skill.cjs" calculator eval -- 1+1',
timeoutMs: 500,
}, makeOrkasCtx(pcDir));