dotdog 0.8.3 → 0.8.4

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.
Files changed (2) hide show
  1. package/dist/cli.js +69 -9
  2. package/package.json +1 -1
package/dist/cli.js CHANGED
@@ -2856,6 +2856,26 @@ function parseBlocks(lines, start, end, errors2) {
2856
2856
  i = yamlEnd + 1;
2857
2857
  continue;
2858
2858
  }
2859
+ if (Array.isArray(yaml.relationships)) {
2860
+ for (const item of yaml.relationships) {
2861
+ blocks.push({
2862
+ kind: "relationship",
2863
+ source: item.from || item.source || "",
2864
+ target: item.to || item.target || "",
2865
+ verb: item.verb || "connects",
2866
+ description: item.description || "",
2867
+ cardinality: item.cardinality || "N:M",
2868
+ required: item.required === true,
2869
+ cascade: item.cascade || "none",
2870
+ invariants: [],
2871
+ yaml: item,
2872
+ lineStart: i + 1,
2873
+ lineEnd: yamlEnd
2874
+ });
2875
+ }
2876
+ i = yamlEnd + 1;
2877
+ continue;
2878
+ }
2859
2879
  if (yaml.event) {
2860
2880
  blocks.push({
2861
2881
  kind: "event",
@@ -2898,7 +2918,7 @@ function parseBlocks(lines, start, end, errors2) {
2898
2918
  i = yamlEnd + 1;
2899
2919
  continue;
2900
2920
  }
2901
- const key = yaml.prediction ? "prediction" : yaml.entity ? "entity" : yaml.event ? "event" : yaml.relationship || yaml.verb ? "relationship" : null;
2921
+ const key = yaml.prediction ? "prediction" : yaml.entity ? "entity" : yaml.event ? "event" : yaml.relationship || yaml.verb ? "relationship" : Array.isArray(yaml.relationships) ? "relationship_list" : null;
2902
2922
  if (key) {
2903
2923
  if (key === "prediction") {
2904
2924
  blocks.push({ kind: "prediction", statement: yaml.prediction || "", description: yaml.description || "", trigger: yaml.trigger || "", timeframe: yaml.timeframe || "", confidence: yaml.confidence || 0, measurement: yaml.measurement || "", status: yaml.status || "pending", yaml, lineStart: i + 1, lineEnd: yamlEnd });
@@ -2908,6 +2928,10 @@ function parseBlocks(lines, start, end, errors2) {
2908
2928
  blocks.push({ kind: "event", name: yaml.event || "", trigger: yaml.trigger || "", payload: {}, preconditions: [], postconditions: [], sideEffects: [], probability: null, yaml, lineStart: i + 1, lineEnd: yamlEnd });
2909
2929
  } else if (key === "relationship") {
2910
2930
  blocks.push({ kind: "relationship", source: yaml.source || "", target: yaml.target || "", verb: yaml.verb || "connects", description: yaml.description || "", cardinality: yaml.cardinality || "N:M", required: false, cascade: "none", invariants: [], yaml, lineStart: i + 1, lineEnd: yamlEnd });
2931
+ } else if (key === "relationship_list") {
2932
+ for (const item of yaml.relationships) {
2933
+ blocks.push({ kind: "relationship", source: item.from || item.source || "", target: item.to || item.target || "", verb: item.verb || "connects", description: item.description || "", cardinality: item.cardinality || "N:M", required: item.required === true, cascade: item.cascade || "none", invariants: [], yaml: item, lineStart: i + 1, lineEnd: yamlEnd });
2934
+ }
2911
2935
  }
2912
2936
  i = yamlEnd + 1;
2913
2937
  continue;
@@ -3023,13 +3047,19 @@ function buildEntityNode(name, description, yaml, lineStart, lineEnd) {
3023
3047
  const rawProps = yaml.properties;
3024
3048
  if (rawProps) {
3025
3049
  for (const [key, val] of Object.entries(rawProps)) {
3026
- if (typeof val === "object" && val !== null) {
3050
+ let resolved = val;
3051
+ if (typeof val === "string" && val.startsWith("{") && val.endsWith("}")) {
3052
+ const inline = parseInlineObject(val);
3053
+ if (inline)
3054
+ resolved = inline;
3055
+ }
3056
+ if (typeof resolved === "object" && resolved !== null) {
3027
3057
  properties[key] = {
3028
- type: val.type || "string",
3029
- required: val.required !== false,
3030
- default: val.default,
3031
- constraints: val.constraints,
3032
- example: val.example
3058
+ type: resolved.type || "string",
3059
+ required: resolved.required !== false,
3060
+ default: resolved.default,
3061
+ constraints: resolved.constraints,
3062
+ example: resolved.example
3033
3063
  };
3034
3064
  }
3035
3065
  }
@@ -3136,7 +3166,12 @@ function parseSimpleYAML(lines) {
3136
3166
  const topMatch = line.match(/^(\w[\w_]*):\s*(.+)?$/);
3137
3167
  if (topMatch && !line.startsWith(" ") && !line.startsWith("\t")) {
3138
3168
  if (inNested && currentKey) {
3139
- result[currentKey] = currentObj;
3169
+ if (Array.isArray(currentObj.__list) && currentObj.__list.length > 0) {
3170
+ result[currentKey] = currentObj.__list;
3171
+ delete currentObj.__list;
3172
+ } else {
3173
+ result[currentKey] = currentObj;
3174
+ }
3140
3175
  inNested = false;
3141
3176
  currentObj = {};
3142
3177
  }
@@ -3179,6 +3214,26 @@ function parseSimpleYAML(lines) {
3179
3214
  }
3180
3215
  continue;
3181
3216
  }
3217
+ const listMatch = line.match(/^\s{2}-(?:\s+)?(.+)?$/);
3218
+ if (listMatch && inNested && currentKey) {
3219
+ const item = (listMatch[1] || "").trim();
3220
+ if (!Array.isArray(currentObj.__list)) {
3221
+ currentObj.__list = [];
3222
+ }
3223
+ if (item.startsWith("{") && item.endsWith("}")) {
3224
+ const inline = parseInlineObject(item);
3225
+ currentObj.__list.push(inline || item);
3226
+ } else if (item === "true") {
3227
+ currentObj.__list.push(true);
3228
+ } else if (item === "false") {
3229
+ currentObj.__list.push(false);
3230
+ } else if (/^-?\d+(\.\d+)?$/.test(item)) {
3231
+ currentObj.__list.push(parseFloat(item));
3232
+ } else {
3233
+ currentObj.__list.push(item);
3234
+ }
3235
+ continue;
3236
+ }
3182
3237
  if (nestedMatch && !inNested) {
3183
3238
  const key = nestedMatch[1];
3184
3239
  const value = (nestedMatch[2] || "").trim();
@@ -3204,7 +3259,12 @@ function parseSimpleYAML(lines) {
3204
3259
  }
3205
3260
  }
3206
3261
  if (inNested && currentKey) {
3207
- result[currentKey] = currentObj;
3262
+ if (Array.isArray(currentObj.__list) && currentObj.__list.length > 0) {
3263
+ result[currentKey] = currentObj.__list;
3264
+ delete currentObj.__list;
3265
+ } else {
3266
+ result[currentKey] = currentObj;
3267
+ }
3208
3268
  }
3209
3269
  return result;
3210
3270
  }
package/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "dotdog",
3
- "version": "0.8.3",
3
+ "version": "0.8.4",
4
4
  "description": "CLI tool for structured software specifications. Validate .dog files, compile .dag graphs, query via MCP.",
5
5
  "type": "module",
6
6
  "main": "dist/cli.js",