mirror of
https://github.com/qwibitai/nanoclaw.git
synced 2026-06-12 18:11:51 +08:00
5fff2d2728
The `ncl` transport-error message and ~20 skill docs hardcoded v1's `com.nanoclaw` / `nanoclaw` for launchd labels and systemd units. Under v2 the names are slug-suffixed per checkout (`com.nanoclaw.<slug>`, `nanoclaw-<slug>.service`), so those commands no longer match a real service on the host. - `src/cli/client.ts` — extract `formatTransportError` into `src/cli/transport-errors.ts` so it can read `install-slug` and call `getLaunchdLabel()` / `getSystemdUnit()`. - `src/cli/transport-errors.test.ts` — regression test for #2484: the error string must not contain the bare v1 names. - `.claude/skills/**/*.md` — replace hardcoded restart snippets with the canonical `source setup/lib/install-slug.sh` + `$(systemd_unit)` / `$(launchd_label)` pattern (or the inline subshell form where the snippet is a one-liner). Closes #2484 Closes #2485
32 lines
1.4 KiB
TypeScript
32 lines
1.4 KiB
TypeScript
import { describe, it, expect } from 'vitest';
|
|
|
|
import { getLaunchdLabel, getSystemdUnit } from '../install-slug.js';
|
|
import { formatTransportError } from './transport-errors.js';
|
|
|
|
describe('formatTransportError', () => {
|
|
it('renders per-install service names on ENOENT, not the bare v1 names', () => {
|
|
const out = formatTransportError(new Error('connect ENOENT /tmp/nanoclaw.sock'));
|
|
|
|
// Regression for #2484: pre-fix, this string was a hardcoded
|
|
// `com.nanoclaw` / `nanoclaw`, which doesn't match the actual
|
|
// v2 per-install slug-suffixed unit and label.
|
|
expect(out).toContain(`gui/$(id -u)/${getLaunchdLabel()}`);
|
|
expect(out).toContain(`systemctl --user restart ${getSystemdUnit()}`);
|
|
expect(out).not.toMatch(/gui\/\$\(id -u\)\/com\.nanoclaw\b(?!-v2)/);
|
|
expect(out).not.toMatch(/systemctl --user restart nanoclaw\b(?!-v2)/);
|
|
});
|
|
|
|
it('renders the same on ECONNREFUSED', () => {
|
|
const out = formatTransportError(new Error('connect ECONNREFUSED'));
|
|
expect(out).toContain(getLaunchdLabel());
|
|
expect(out).toContain(getSystemdUnit());
|
|
});
|
|
|
|
it('falls back to a generic transport error for other failures', () => {
|
|
const out = formatTransportError(new Error('some unrelated failure'));
|
|
expect(out).toBe('ncl: transport error: some unrelated failure\n');
|
|
expect(out).not.toContain('launchctl');
|
|
expect(out).not.toContain('systemctl');
|
|
});
|
|
});
|