style: apply prettier formatting from pre-commit hook
Some checks failed
Bump version / bump-version (push) Has been cancelled
Update token count / update-tokens (push) Has been cancelled

Co-Authored-By: Claude Opus 4.6 (1M context) <noreply@anthropic.com>
This commit is contained in:
woozu-shin
2026-03-28 14:46:11 +09:00
parent 576d5ce366
commit 6b273740dd
3 changed files with 47 additions and 40 deletions

View File

@@ -6,40 +6,46 @@ import { spawnSync } from 'child_process';
import { describe, expect, it } from 'vitest'; import { describe, expect, it } from 'vitest';
describe('claw skill script', () => { describe('claw skill script', () => {
it('exits zero after successful structured output even if the runtime is terminated', { timeout: 20000 }, () => { it(
const tempDir = fs.mkdtempSync(path.join(os.tmpdir(), 'claw-skill-test-')); 'exits zero after successful structured output even if the runtime is terminated',
const binDir = path.join(tempDir, 'bin'); { timeout: 20000 },
fs.mkdirSync(binDir, { recursive: true }); () => {
const tempDir = fs.mkdtempSync(
path.join(os.tmpdir(), 'claw-skill-test-'),
);
const binDir = path.join(tempDir, 'bin');
fs.mkdirSync(binDir, { recursive: true });
const runtimePath = path.join(binDir, 'container'); const runtimePath = path.join(binDir, 'container');
fs.writeFileSync( fs.writeFileSync(
runtimePath, runtimePath,
`#!/bin/sh `#!/bin/sh
cat >/dev/null cat >/dev/null
printf '%s\n' '---NANOCLAW_OUTPUT_START---' '{"status":"success","result":"4","newSessionId":"sess-1"}' '---NANOCLAW_OUTPUT_END---' printf '%s\n' '---NANOCLAW_OUTPUT_START---' '{"status":"success","result":"4","newSessionId":"sess-1"}' '---NANOCLAW_OUTPUT_END---'
sleep 30 sleep 30
`, `,
); );
fs.chmodSync(runtimePath, 0o755); fs.chmodSync(runtimePath, 0o755);
const result = spawnSync( const result = spawnSync(
'python3', 'python3',
['.claude/skills/claw/scripts/claw', '-j', 'tg:123', 'What is 2+2?'], ['.claude/skills/claw/scripts/claw', '-j', 'tg:123', 'What is 2+2?'],
{ {
cwd: process.cwd(), cwd: process.cwd(),
encoding: 'utf8', encoding: 'utf8',
env: { env: {
...process.env, ...process.env,
NANOCLAW_DIR: tempDir, NANOCLAW_DIR: tempDir,
PATH: `${binDir}:${process.env.PATH || ''}`, PATH: `${binDir}:${process.env.PATH || ''}`,
},
timeout: 15000,
}, },
timeout: 15000, );
},
);
expect(result.status).toBe(0); expect(result.status).toBe(0);
expect(result.signal).toBeNull(); expect(result.signal).toBeNull();
expect(result.stdout).toContain('4'); expect(result.stdout).toContain('4');
expect(result.stderr).toContain('[session: sess-1]'); expect(result.stderr).toContain('[session: sess-1]');
}); },
);
}); });

View File

@@ -51,8 +51,12 @@ describe('stopContainer', () => {
}); });
it('rejects names with shell metacharacters', () => { it('rejects names with shell metacharacters', () => {
expect(() => stopContainer('foo; rm -rf /')).toThrow('Invalid container name'); expect(() => stopContainer('foo; rm -rf /')).toThrow(
expect(() => stopContainer('foo$(whoami)')).toThrow('Invalid container name'); 'Invalid container name',
);
expect(() => stopContainer('foo$(whoami)')).toThrow(
'Invalid container name',
);
expect(() => stopContainer('foo`id`')).toThrow('Invalid container name'); expect(() => stopContainer('foo`id`')).toThrow('Invalid container name');
expect(mockExecSync).not.toHaveBeenCalled(); expect(mockExecSync).not.toHaveBeenCalled();
}); });
@@ -67,13 +71,10 @@ describe('ensureContainerRuntimeRunning', () => {
ensureContainerRuntimeRunning(); ensureContainerRuntimeRunning();
expect(mockExecSync).toHaveBeenCalledTimes(1); expect(mockExecSync).toHaveBeenCalledTimes(1);
expect(mockExecSync).toHaveBeenCalledWith( expect(mockExecSync).toHaveBeenCalledWith(`${CONTAINER_RUNTIME_BIN} info`, {
`${CONTAINER_RUNTIME_BIN} info`, stdio: 'pipe',
{ stdio: 'pipe' }, });
); expect(logger.debug).toHaveBeenCalledWith('Docker runtime already running');
expect(logger.debug).toHaveBeenCalledWith(
'Docker runtime already running',
);
}); });
it('throws when docker info fails', () => { it('throws when docker info fails', () => {

View File

@@ -442,9 +442,9 @@ export async function processTaskIpc(
); );
break; break;
} }
// Defense in depth: agent cannot set isMain via IPC. // Defense in depth: agent cannot set isMain via IPC.
// Preserve isMain from the existing registration so IPC config // Preserve isMain from the existing registration so IPC config
// updates (e.g. adding additionalMounts) don't strip the flag. // updates (e.g. adding additionalMounts) don't strip the flag.
const existingGroup = registeredGroups[data.jid]; const existingGroup = registeredGroups[data.jid];
deps.registerGroup(data.jid, { deps.registerGroup(data.jid, {
name: data.name, name: data.name,