mirror of
https://github.com/binaricat/Netcatty.git
synced 2026-11-17 04:50:52 +00:00
* fix(#3289): automated AI fix * fix: address Codex review on PR #3290 * fix: address Codex review on PR #3290 * fix: address Codex review on PR #3290 * fix: address Codex review on PR #3290 * fix: address Codex review on PR #3290 * fix: address Codex review on PR #3290 * fix: address Codex review on PR #3290 * fix: address Codex review on PR #3290 * fix: address Codex review on PR #3290 * fix: address Codex review on PR #3290 * fix: address Codex review on PR #3290 * fix: address Codex review on PR #3290 * fix: address Codex review on PR #3290 * fix: address Codex review on PR #3290 * fix: address Codex review on PR #3290 * fix: address Codex review on PR #3290 * fix: address Codex review on PR #3290 * fix: address Codex review on PR #3290 * fix: address Codex review on PR #3290 * fix: address Codex review on PR #3290 * fix: address Codex review on PR #3290 * fix: address Codex review on PR #3290 * fix(ai): apply note attachment budgets synchronously * fix(ai): reuse normalized note search fields while typing * fix(ai): retain draft state binding in panel host * fix(ai): reject carriage returns in note references * fix(ai): protect continuation before pruning note payloads * refactor(ai): keep note mentions as lightweight references * fix(ai): gate note references on reader availability * fix(ai): retain note references ahead of replay prose * refactor(ai): share one instruction across note references * fix(ai): keep accepted note references within replay space * Bound agent note reads and add resumable literal search * Preserve compact note requests and announce picker selection * Retain mixed attachment context in compact note replay * Keep imported long note identities readable * Keep note picker selection and untitled labels consistent --------- Co-authored-by: netcatty-bot <308658023+netcatty-bot@users.noreply.github.com> Co-authored-by: bincxz <16399091+binaricat@users.noreply.github.com>
64 lines
2.6 KiB
TypeScript
64 lines
2.6 KiB
TypeScript
import test from "node:test";
|
|
import assert from "node:assert/strict";
|
|
|
|
import {
|
|
TERMINAL_SELECTION_ATTACHMENT_MEDIA_TYPE,
|
|
buildPromptWithTerminalSelectionAttachments,
|
|
createTerminalSelectionAttachment,
|
|
decodeTerminalSelectionAttachment,
|
|
} from "./terminalSelectionAttachment.ts";
|
|
import { createVaultNoteAttachment, formatVaultNoteReferences } from "./vaultNoteAttachment.ts";
|
|
|
|
test("createTerminalSelectionAttachment returns null for blank selections", () => {
|
|
assert.equal(createTerminalSelectionAttachment(" \n\t"), null);
|
|
});
|
|
|
|
test("createTerminalSelectionAttachment creates a compact terminal log attachment", () => {
|
|
const attachment = createTerminalSelectionAttachment("line one\nline two");
|
|
|
|
assert.ok(attachment);
|
|
assert.equal(attachment.mediaType, TERMINAL_SELECTION_ATTACHMENT_MEDIA_TYPE);
|
|
assert.match(attachment.filename, /^terminal-selection-\d{4}-\d{2}-\d{2}-\d{2}-\d{2}-\d{2}\.log$/);
|
|
assert.equal(attachment.terminalSelection, true);
|
|
assert.equal(attachment.previewText, "line one");
|
|
assert.equal(attachment.lineCount, 2);
|
|
assert.equal(decodeTerminalSelectionAttachment(attachment), "line one\nline two");
|
|
});
|
|
|
|
test("createTerminalSelectionAttachment preserves utf-8 terminal output", () => {
|
|
const attachment = createTerminalSelectionAttachment("错误: 权限不足\n路径: /tmp/测试");
|
|
|
|
assert.ok(attachment);
|
|
assert.equal(decodeTerminalSelectionAttachment(attachment), "错误: 权限不足\n路径: /tmp/测试");
|
|
});
|
|
|
|
test("buildPromptWithTerminalSelectionAttachments expands terminal selections into prompt text", () => {
|
|
const attachment = createTerminalSelectionAttachment("docker ps -a\npermission denied");
|
|
|
|
assert.ok(attachment);
|
|
assert.equal(
|
|
buildPromptWithTerminalSelectionAttachments("帮我看看", [attachment]),
|
|
`帮我看看\n\n[Terminal selection: ${attachment.filename}]\ndocker ps -a\npermission denied`,
|
|
);
|
|
});
|
|
|
|
test("buildPromptWithTerminalSelectionAttachments supports terminal-only prompts", () => {
|
|
const attachment = createTerminalSelectionAttachment("systemctl status nginx");
|
|
|
|
assert.ok(attachment);
|
|
assert.equal(
|
|
buildPromptWithTerminalSelectionAttachments("", [attachment]),
|
|
`[Terminal selection: ${attachment.filename}]\nsystemctl status nginx`,
|
|
);
|
|
});
|
|
|
|
test("buildPromptWithTerminalSelectionAttachments keeps empty Vault note blocks", () => {
|
|
const attachment = createVaultNoteAttachment({ id: "note-1", title: "Runbook" });
|
|
|
|
assert.ok(attachment);
|
|
assert.equal(
|
|
buildPromptWithTerminalSelectionAttachments("add deployment steps to this note", [attachment]),
|
|
`add deployment steps to this note\n\n${formatVaultNoteReferences([attachment])}`,
|
|
);
|
|
});
|