Files
Netcatty/components/ai/toolArtifacts/toolArtifactNames.test.ts
T
fc55e9ac17 feat(vault): let Skills + CLI operate notes with the same approval as MCP (#3512)
* feat(vault): let Skills + CLI operate notes with the same approval as MCP

Expose vault note list, read, write, and markdown import on the tool CLI so agents can save generated documents only after the user approves.

Co-authored-by: Cursor <cursoragent@cursor.com>

* fix(vault): keep explicit empty note fields in the CLI

A supplied empty string was treated as an omitted flag, so note clears and empty markdown imports never reached the note service.

Co-authored-by: Cursor <cursoragent@cursor.com>

* fix(vault): allow an explicit empty note body on CLI create

notes create --content "" was rejected as a missing flag, so it did not match vault_notes_create.

Co-authored-by: Cursor <cursoragent@cursor.com>

* fix(vault): stop echoing imported note bodies and recognize leading CLI flags

A batch import resent every document over IPC, and a leading --json hid the notes command from artifact inference.

Co-authored-by: Cursor <cursoragent@cursor.com>

* fix(vault): make note CLI import safe and fail writes cleanly

---------

Co-authored-by: Cursor <cursoragent@cursor.com>
Co-authored-by: bincxz <16399091+binaricat@users.noreply.github.com>
2026-09-29 12:22:35 +08:00

84 lines
2.5 KiB
TypeScript

import test from 'node:test';
import assert from 'node:assert/strict';
import {
inferArtifactToolNameFromCliArgs,
normalizeArtifactToolName,
} from './toolArtifactNames.ts';
test('normalizeArtifactToolName unwraps MCP server prefixes', () => {
assert.equal(
normalizeArtifactToolName('mcp__netcatty__vault_notes_create'),
'vault_notes_create',
);
assert.equal(
normalizeArtifactToolName('mcp__netcatty-remote-hosts__terminal_read_context'),
'terminal_read_context',
);
});
test('normalizeArtifactToolName unwraps OpenCode server prefixes', () => {
assert.equal(
normalizeArtifactToolName('netcatty-remote-hosts_vault_notes_get'),
'vault_notes_get',
);
assert.equal(
normalizeArtifactToolName('netcatty-remote-hosts_vault_hosts_list'),
'vault_hosts_list',
);
assert.equal(
normalizeArtifactToolName('netcatty-remote-hosts_terminal_read_context'),
'terminal_read_context',
);
});
test('normalizeArtifactToolName unwraps Copilot server prefixes', () => {
assert.equal(
normalizeArtifactToolName('netcatty-remote-hosts-vault_notes_list'),
'vault_notes_list',
);
assert.equal(
normalizeArtifactToolName('netcatty-remote-hosts-terminal_read_context'),
'terminal_read_context',
);
});
test('inferArtifactToolNameFromCliArgs maps Netcatty CLI artifact commands', () => {
assert.equal(
inferArtifactToolNameFromCliArgs({
command: `/bin/zsh -lc '"/Applications/Netcatty.app/netcatty-tool-cli" vault host get --host-id host_1 --json'`,
}),
'host_get',
);
assert.equal(
inferArtifactToolNameFromCliArgs({
command: `/bin/zsh -lc '"/Applications/Netcatty.app/netcatty-tool-cli" notes import --file-name runbook.md --content-stdin --json'`,
}),
'vault_notes_import',
);
assert.equal(
inferArtifactToolNameFromCliArgs({
command: `/bin/zsh -lc '"/Applications/Netcatty.app/netcatty-tool-cli" --json notes list'`,
}),
'vault_notes_list',
);
assert.equal(
inferArtifactToolNameFromCliArgs({
command: 'netcatty-tool-cli notes list --json',
}),
'vault_notes_list',
);
assert.equal(
inferArtifactToolNameFromCliArgs({
command: 'netcatty-tool-cli notes --group "ops team" import --content-stdin --json',
}),
'vault_notes_import',
);
assert.equal(
inferArtifactToolNameFromCliArgs({
command: '& "C:\\Program Files\\Netcatty\\netcatty-tool-cli.cmd" notes import --attachment-index 0 --json',
}),
'vault_notes_import',
);
});