import assert from "node:assert/strict";
import test from "node:test";

import { createAgentChatRequestBody, findRemovedWorkspaceFileInput } from "./client.ts";

test("direct helper agent chat body never sends legacy workspaceFiles", () => {
  const body = createAgentChatRequestBody({
    message: "validate gitbundle direct helper payload",
    providerProfile: "deepseek",
    sessionId: "ses_test",
    conversationId: "cnv_test",
    projectId: "prj_test",
    traceId: "trc_test"
  });

  assert.equal(body.shortConnection, true);
  assert.equal(Object.hasOwn(body, "workspaceFiles"), false);
  assert.equal(Object.hasOwn(body, "resourceWorkspaceFiles"), false);
});

test("direct helper rejects removed spec injection inputs", () => {
  assert.equal(findRemovedWorkspaceFileInput({ "spec-path": ".hwlab/hwpod-spec.yaml" }, {}), "--spec-path");
  assert.equal(findRemovedWorkspaceFileInput({ specPath: ".hwlab/hwpod-spec.yaml" }, {}), "--specPath");
  assert.equal(findRemovedWorkspaceFileInput({}, { HWPOD_SPEC_CONTENT: "kind: Hwpod" }), "HWPOD_SPEC_CONTENT");
  assert.equal(findRemovedWorkspaceFileInput({}, { HWPOD_SPEC: "kind: Hwpod" }), "HWPOD_SPEC");
  assert.equal(findRemovedWorkspaceFileInput({}, {}), null);
});
