@kelceyp/caw-server 0.0.70 → 0.0.72

This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
package/dist/cli.js CHANGED
@@ -8727,15 +8727,47 @@ var create5 = ({ httpClient }) => {
8727
8727
  };
8728
8728
  var read_default = Object.freeze({ create: create5 });
8729
8729
 
8730
+ // src/helpers/parseFields.js
8731
+ var parseFields = (fieldsParam, onWarning = () => {}) => {
8732
+ if (fieldsParam === undefined || fieldsParam === null) {
8733
+ return { fields: null, error: null };
8734
+ }
8735
+ if (fieldsParam.startsWith("{")) {
8736
+ try {
8737
+ const fields2 = JSON.parse(fieldsParam);
8738
+ return { fields: fields2, error: null };
8739
+ } catch {
8740
+ return { fields: null, error: "Invalid JSON for --fields" };
8741
+ }
8742
+ }
8743
+ const fields = {};
8744
+ for (const pair of fieldsParam.split(",")) {
8745
+ const eqIndex = pair.indexOf("=");
8746
+ if (eqIndex === -1) {
8747
+ onWarning(`Skipping malformed field pair: "${pair}" (missing =)`);
8748
+ continue;
8749
+ }
8750
+ const fieldName = pair.substring(0, eqIndex).trim();
8751
+ const value = pair.substring(eqIndex + 1);
8752
+ if (fieldName === "") {
8753
+ onWarning(`Skipping field pair with empty name: "${pair}"`);
8754
+ continue;
8755
+ }
8756
+ fields[fieldName] = value;
8757
+ }
8758
+ return { fields, error: null };
8759
+ };
8760
+ var parseFields_default = parseFields;
8761
+
8730
8762
  // src/commands/doc/create.js
8731
8763
  var create6 = ({ httpClient }) => {
8732
- return createCommand("create").summary("Create a document").param((p) => p.name("sid").type("string").flag("sid", "s").required()).param((p) => p.name("path").type("string").flag("path")).param((p) => p.name("store").type("string").flag("store")).param((p) => p.name("root").type("string").flag("root")).param((p) => p.name("parent").type("string").flag("parent")).param((p) => p.name("name").type("string").flag("name")).param((p) => p.name("content").type("string").flag("content").stdin()).preValidate((ctx) => {
8764
+ return createCommand("create").summary("Create a document").param((p) => p.name("sid").type("string").flag("sid", "s").required()).param((p) => p.name("path").type("string").flag("path")).param((p) => p.name("store").type("string").flag("store")).param((p) => p.name("root").type("string").flag("root")).param((p) => p.name("parent").type("string").flag("parent")).param((p) => p.name("name").type("string").flag("name")).param((p) => p.name("content").type("string").flag("content").stdin()).param((p) => p.name("subtype").type("string").flag("subtype")).param((p) => p.name("fields").type("string").flag("fields")).preValidate((ctx) => {
8733
8765
  if (ctx.stdin.available && ctx.argv.flags.content) {
8734
8766
  return "Cannot use --content when piping stdin";
8735
8767
  }
8736
8768
  return true;
8737
8769
  }).run(async (ctx) => {
8738
- const { sid, path, store, root, parent, name, content } = ctx.params;
8770
+ const { sid, path, store, root, parent, name, content, subtype, fields: fieldsParam } = ctx.params;
8739
8771
  const args = {};
8740
8772
  if (path !== undefined)
8741
8773
  args.path = path;
@@ -8749,6 +8781,19 @@ var create6 = ({ httpClient }) => {
8749
8781
  args.name = name;
8750
8782
  if (content !== undefined)
8751
8783
  args.content = content;
8784
+ if (subtype !== undefined)
8785
+ args.subtype = subtype;
8786
+ if (fieldsParam !== undefined) {
8787
+ const { fields, error } = parseFields_default(fieldsParam, (msg) => {
8788
+ console.error(`Warning: ${msg}`);
8789
+ });
8790
+ if (error) {
8791
+ throw new Error(error);
8792
+ }
8793
+ if (fields && Object.keys(fields).length > 0) {
8794
+ args.fields = fields;
8795
+ }
8796
+ }
8752
8797
  const result = await httpClient.post(`/cli/mcp-client/${sid}/dispatch`, {
8753
8798
  cwd: process.cwd(),
8754
8799
  tool: "create_document",