owenkaplinsky commited on
Commit
7c1461a
·
1 Parent(s): 4485635

Make ID identification clearer

Browse files
project/chat.py CHANGED
@@ -552,13 +552,13 @@ def create_gradio_interface():
552
  SYSTEM_PROMPT = f"""You are an AI assistant that helps users build **MCP servers** using Blockly blocks.
553
 
554
  You'll receive the workspace state in this format:
555
- `blockId → block_name(inputs(input_name: value))`
556
 
557
- Block ID parsing: Block IDs are everything before ` → ` (space-arrow-space). IDs are always complex/long strings.
558
- Example: `?fHZRh^|us|9bECO![$= → text(inputs(TEXT: "hello"))`, ID is `?fHZRh^|us|9bECO![$=`
559
 
560
  Special cases:
561
- - `create_mcp` and `func_def` use `blockId → block_name(inputs(input_name: type), outputs(output_name: value))`
562
  - Indentation or nesting shows logic hierarchy (like loops or conditionals).
563
 
564
  ---
@@ -583,11 +583,11 @@ def create_gradio_interface():
583
  ---
584
 
585
  ### Deleting Blocks
586
- - Each block starts with its ID, like `blockId → block_name(...)`.
587
  - To delete a block, specify its block ID.
588
  - Any block except the main `create_mcp` block can be deleted.
589
 
590
- `blockId → code`
591
 
592
  Use the exact ID from the workspace.
593
 
@@ -684,7 +684,7 @@ def create_gradio_interface():
684
  ### Variables
685
  Variables appear as:
686
 
687
- `varId → varName`
688
 
689
  ---
690
 
 
552
  SYSTEM_PROMPT = f"""You are an AI assistant that helps users build **MCP servers** using Blockly blocks.
553
 
554
  You'll receive the workspace state in this format:
555
+ `↿ blockId ↾ block_name(inputs(input_name: value))`
556
 
557
+ Block ID parsing: Block IDs are everything between `↿` and `↾`. IDs are always complex/long strings.
558
+ Example: `↿ ?fHZRh^|us|9bECO![$= ↾ text(inputs(TEXT: "hello"))`, ID is `?fHZRh^|us|9bECO![$=`
559
 
560
  Special cases:
561
+ - `create_mcp` and `func_def` use `↿ blockId ↾ block_name(inputs(input_name: type), outputs(output_name: value))`
562
  - Indentation or nesting shows logic hierarchy (like loops or conditionals).
563
 
564
  ---
 
583
  ---
584
 
585
  ### Deleting Blocks
586
+ - Each block starts with its ID, like `↿ blockId ↾ block_name(...)`.
587
  - To delete a block, specify its block ID.
588
  - Any block except the main `create_mcp` block can be deleted.
589
 
590
+ `↿ blockId ↾ code`
591
 
592
  Use the exact ID from the workspace.
593
 
 
684
  ### Variables
685
  Variables appear as:
686
 
687
+ `↿ varId ↾ varName`
688
 
689
  ---
690
 
project/src/generators/chat.js CHANGED
@@ -70,8 +70,8 @@ forBlock['create_mcp'] = function (block, generator) {
70
  let body = generator.statementToCode(block, 'BODY');
71
 
72
  // Construct the create_mcp call with inputs and outputs
73
- // Include block ID for deletion tracking with arrow separator
74
- let code = `${block.id} → create_mcp(inputs(${inputParams.join(', ')}), outputs(${outputParams.join(', ')}))`
75
 
76
  // Add the function body
77
  if (body) {
@@ -120,8 +120,8 @@ forBlock['func_def'] = function (block, generator) {
120
  let body = generator.statementToCode(block, 'BODY');
121
 
122
  // Construct the func_def call with inputs and outputs
123
- // Include block ID for deletion tracking with arrow separator
124
- let code = `${block.id} → ${name}(inputs(${inputParams.join(', ')}), outputs(${outputParams.join(', ')}))`
125
 
126
  // Add the function body
127
  if (body) {
@@ -257,7 +257,7 @@ chatGenerator.blockToCode = function (block, opt_thisOnly) {
257
  }
258
 
259
  // Generate the controls_if call with conditions
260
- let code = `${block.id} → ${blockType}(inputs(${inputs.join(', ')}))`;
261
 
262
  // Now get all the statement blocks with proper formatting
263
  // DO0, DO1, etc. are indented under the if
@@ -326,8 +326,8 @@ chatGenerator.blockToCode = function (block, opt_thisOnly) {
326
  }
327
  }
328
 
329
- // Generate the standard format: name(inputs(...)) with block ID and arrow separator
330
- const code = `${block.id} → ${blockType}(inputs(${inputs.join(', ')}))`;
331
 
332
  // Handle statement inputs (for blocks that have a body)
333
  let statements = '';
@@ -359,7 +359,7 @@ chatGenerator.blockToCode = function (block, opt_thisOnly) {
359
  return [valueCode, this.ORDER_ATOMIC];
360
  } else {
361
  // When standalone (not connected), include the ID
362
- const standaloneCode = `${block.id} → ${blockType}(inputs(${inputs.join(', ')}))`;
363
  // For standalone value blocks, we need to return them as statement-like
364
  // but still maintain the value block return format for Blockly
365
  return [standaloneCode, this.ORDER_ATOMIC];
 
70
  let body = generator.statementToCode(block, 'BODY');
71
 
72
  // Construct the create_mcp call with inputs and outputs
73
+ // Include block ID for deletion tracking with bounded separator
74
+ let code = `↿ ${block.id} ↾ create_mcp(inputs(${inputParams.join(', ')}), outputs(${outputParams.join(', ')}))`
75
 
76
  // Add the function body
77
  if (body) {
 
120
  let body = generator.statementToCode(block, 'BODY');
121
 
122
  // Construct the func_def call with inputs and outputs
123
+ // Include block ID for deletion tracking with bounded separator
124
+ let code = `↿ ${block.id} ↾ ${name}(inputs(${inputParams.join(', ')}), outputs(${outputParams.join(', ')}))`
125
 
126
  // Add the function body
127
  if (body) {
 
257
  }
258
 
259
  // Generate the controls_if call with conditions
260
+ let code = `↿ ${block.id} ↾ ${blockType}(inputs(${inputs.join(', ')}))`;
261
 
262
  // Now get all the statement blocks with proper formatting
263
  // DO0, DO1, etc. are indented under the if
 
326
  }
327
  }
328
 
329
+ // Generate the standard format: name(inputs(...)) with block ID and bounded separator
330
+ const code = `↿ ${block.id} ↾ ${blockType}(inputs(${inputs.join(', ')}))`;
331
 
332
  // Handle statement inputs (for blocks that have a body)
333
  let statements = '';
 
359
  return [valueCode, this.ORDER_ATOMIC];
360
  } else {
361
  // When standalone (not connected), include the ID
362
+ const standaloneCode = `↿ ${block.id} ↾ ${blockType}(inputs(${inputs.join(', ')}))`;
363
  // For standalone value blocks, we need to return them as statement-like
364
  // but still maintain the value block return format for Blockly
365
  return [standaloneCode, this.ORDER_ATOMIC];
project/src/index.js CHANGED
@@ -1239,7 +1239,7 @@ const updateCode = () => {
1239
 
1240
  // Variable map (unchanged)
1241
  const vars = ws.getVariableMap().getAllVariables();
1242
- globalVarString = vars.map(v => `${v.id} → ${v.name}`).join("\n");
1243
 
1244
  const codeEl = document.querySelector('#generatedCode code');
1245
 
 
1239
 
1240
  // Variable map (unchanged)
1241
  const vars = ws.getVariableMap().getAllVariables();
1242
+ globalVarString = vars.map(v => `↿ ${v.id} ↾ ${v.name}`).join("\n");
1243
 
1244
  const codeEl = document.querySelector('#generatedCode code');
1245