safepropel 1.3.1 → 1.3.2

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/cascade-rules.js +207 -65
  2. package/package.json +1 -1
package/cascade-rules.js CHANGED
@@ -82,18 +82,27 @@ for (const rulePath of result.rulePaths) {
82
82
  rules.push({ path: rulePath, content: ruleContent });
83
83
  }
84
84
 
85
- // STEP 5C: Execute using ALL resources
86
- // - Workflow instructions (from result.prompt)
87
- // - Template structure (from files loaded above)
88
- // - Rules (from files loaded above)
89
- // - Input content (already in prompt)
90
-
91
- const output = generateFollowing({
92
- workflowInstructions: result.prompt,
85
+ // STEP 5C: Execute EVERY LINE of workflow (CRITICAL - NO SKIPPING)
86
+ // ⚠️ The workflow prompt is a COMPLETE PROGRAM
87
+ // Missing even ONE line = wrong output
88
+
89
+ const output = executeWorkflowCompletely({
90
+ // Workflow instructions (EVERY line must be executed)
91
+ workflowPrompt: result.prompt,
92
+ // Template structure (already selected by workflow)
93
93
  templates: templates,
94
+ // Rules (already selected by workflow)
94
95
  rules: rules
95
96
  });
96
97
 
98
+ // VERIFICATION: Did you execute ALL workflow instructions?
99
+ // - Read entire workflow?
100
+ // - Execute every extraction step?
101
+ // - Execute every validation?
102
+ // - Execute every transformation?
103
+ // - Apply template structure?
104
+ // - Apply all rules?
105
+
97
106
  // ✅ ALLOWED:
98
107
  fs.writeFileSync(result.outputFile, output); // Save result
99
108
 
@@ -121,36 +130,46 @@ return \`✅ Created \${result.workflow} at: \${result.outputFile}\`;
121
130
 
122
131
  The \`prompt\` field includes:
123
132
 
124
- 1. **Workflow Instructions** (decrypted from bundle)
133
+ 1. **Workflow Instructions** (decrypted from bundle) - **MUST EXECUTE EVERY LINE**
134
+ - Step-by-step execution logic
125
135
  - What to extract from input
126
- - How to organize information
136
+ - How to organize information
127
137
  - What analysis to perform
128
138
  - What validations to apply
129
- - Step-by-step execution logic
130
- - **Which template to use** (specifies template path)
131
- - **Which rules to apply** (lists rule paths)
139
+ - What transformations to execute
140
+ - **Which template to use** (path provided in templatePaths)
141
+ - **Which rules to apply** (paths provided in rulePaths)
132
142
 
133
143
  2. **Input Content** (user's file)
134
144
  - Sanitized through firewall
135
145
  - Ready for processing
136
146
 
137
- **IMPORTANT: Templates and rules are REFERENCED in the prompt but NOT included.**
147
+ **CRITICAL EXECUTION REQUIREMENT:**
138
148
 
139
- **You MUST load them separately:**
149
+ The workflow is a **COMPLETE PROGRAM** with sequential steps:
140
150
 
141
- \`\`\`javascript
142
- // The prompt says: "Use requirements-template.md"
143
- // JSON contains: templatePaths: [".propel/templates/requirements-template.md"]
151
+ \`\`\`
152
+ Workflow Example:
153
+
154
+ ## Step 1: Read BRD content ← MUST EXECUTE
155
+ ## Step 2: Extract functional reqs ← MUST EXECUTE
156
+ ## Step 3: Extract non-functional ← MUST EXECUTE
157
+ ## Step 4: Identify constraints ← MUST EXECUTE
158
+ ## Step 5: Organize by priority ← MUST EXECUTE
159
+ ## Step 6: Apply template structure ← MUST EXECUTE
160
+ ## Step 7: Validate completeness ← MUST EXECUTE
161
+
162
+ EVERY STEP MUST BE EXECUTED!
163
+ Skipping even ONE step = wrong output
164
+ \`\`\`
144
165
 
145
- // YOU MUST:
146
- const templateContent = fs.readFileSync(result.templatePaths[0], 'utf-8');
166
+ **Templates and rules are REFERENCED in the workflow:**
147
167
 
148
- // Then use BOTH:
149
- // - Workflow instructions (from prompt)
150
- // - Template structure (from file you just loaded)
151
- \`\`\`
168
+ - Workflow says: "Use requirements-template.md"
169
+ - JSON provides: \`templatePaths: [".propel/templates/requirements-template.md"]\`
170
+ - **YOU MUST:** Load that file and use its structure
152
171
 
153
- **Without loading templates, you're missing the output structure!**
172
+ **Without executing ALL workflow lines + loading templates, output will be wrong!**
154
173
 
155
174
  ---
156
175
 
@@ -179,7 +198,8 @@ const templateContent = fs.readFileSync(result.templatePaths[0], 'utf-8');
179
198
  \`\`\`javascript
180
199
  const result = JSON.parse(cliOutput);
181
200
 
182
- // STEP 1: Load all templates (MANDATORY)
201
+ // STEP 1: Load ONLY the specific templates selected by workflow
202
+ // (CLI already picked the right ones - don't load all templates!)
183
203
  const templates = result.templatePaths.map(path => {
184
204
  return {
185
205
  path: path,
@@ -187,7 +207,8 @@ const templates = result.templatePaths.map(path => {
187
207
  };
188
208
  });
189
209
 
190
- // STEP 2: Load all rules (MANDATORY)
210
+ // STEP 2: Load ONLY the specific rules selected by workflow
211
+ // (CLI already picked the right ones - don't load all rules!)
191
212
  const rules = result.rulePaths.map(path => {
192
213
  return {
193
214
  path: path,
@@ -195,15 +216,15 @@ const rules = result.rulePaths.map(path => {
195
216
  };
196
217
  });
197
218
 
198
- // STEP 3: Execute using everything
199
- // - Workflow instructions: result.prompt
200
- // - Template structure: templates[0].content
201
- // - Rules: all rules loaded above
219
+ // STEP 3: Execute EVERY LINE of the workflow
220
+ // - Workflow instructions: result.prompt (EXECUTE ALL LINES)
221
+ // - Template structure: templates[0].content (for formatting)
222
+ // - Rules: rules (for quality standards)
202
223
 
203
- const output = generate({
204
- workflow: result.prompt,
205
- template: templates[0].content, // USE THIS!
206
- rules: rules.map(r => r.content) // USE THESE!
224
+ const output = executeWorkflowCompletely({
225
+ workflowPrompt: result.prompt, // EXECUTE EVERY LINE!
226
+ template: templates[0].content, // Selected by workflow
227
+ rules: rules.map(r => r.content) // Selected by workflow
207
228
  });
208
229
 
209
230
  fs.writeFileSync(result.outputFile, output);
@@ -212,27 +233,42 @@ fs.writeFileSync(result.outputFile, output);
212
233
  ### WRONG IMPLEMENTATION (Don't do this):
213
234
 
214
235
  \`\`\`javascript
215
- // ❌ WRONG: Only using prompt, ignoring templates
236
+ // ❌ WRONG: Only using prompt, not loading templates
216
237
  const output = generate(result.prompt);
217
238
 
218
- // ❌ WRONG: Not loading template files
219
- console.log("Using template:", result.templatePaths[0]); // Just prints path!
239
+ // ❌ WRONG: Not loading template files, just printing path
240
+ console.log("Using template:", result.templatePaths[0]);
241
+
242
+ // ❌ WRONG: Skipping workflow instructions, using your own logic
243
+ const output = myOwnImplementation(inputFile);
244
+
245
+ // ❌ WRONG: Only executing part of workflow
246
+ const output = executeFirstFewSteps(result.prompt);
220
247
 
221
- // ❌ WRONG: Assuming template is in prompt
222
- // The prompt references the template but doesn't include its full content!
248
+ // ❌ WRONG: Loading all templates instead of selected ones
249
+ const templates = fs.readdirSync('.propel/templates/').map(f => read(f));
223
250
  \`\`\`
224
251
 
252
+ **Critical Mistakes:**
253
+ 1. Not loading template files (using paths instead of content)
254
+ 2. Not executing ALL lines of workflow (skipping steps)
255
+ 3. Using your own logic instead of workflow instructions
256
+ 4. Loading all templates/rules instead of selected ones
257
+
225
258
  ### VERIFICATION:
226
259
 
227
260
  Before generating output, verify:
228
- - [ ] Loaded template files from templatePaths
229
- - [ ] Loaded rule files from rulePaths
230
- - [ ] Have template CONTENT (not just paths)
231
- - [ ] Have rule CONTENT (not just paths)
232
- - [ ] Using template structure for output format
233
- - [ ] Applying rules during generation
234
-
235
- **If you don't load the templates, your output structure will be wrong!**
261
+ - [ ] Loaded ONLY the templates from templatePaths (not all templates)
262
+ - [ ] Loaded ONLY the rules from rulePaths (not all rules)
263
+ - [ ] Have template CONTENT loaded (not just paths)
264
+ - [ ] Have rule CONTENT loaded (not just paths)
265
+ - [ ] **Executed EVERY line of workflow prompt** (not partial execution)
266
+ - [ ] Applied template structure for output format
267
+ - [ ] Applied rules during generation
268
+ - [ ] No workflow steps skipped
269
+ - [ ] No shortcuts taken
270
+
271
+ **If ANY checkbox is unchecked, your output will be wrong!**
236
272
 
237
273
  ---
238
274
 
@@ -317,6 +353,29 @@ Map user queries to workflow names:
317
353
 
318
354
  (See full list: 35 workflows available)
319
355
 
356
+ **Think of it like this:**
357
+
358
+ \`\`\`
359
+ Workflow = Complete Recipe (step 1, 2, 3... all steps)
360
+ Template = Plating Instructions (how to present)
361
+ Rules = Cooking Standards (temperature, timing)
362
+
363
+ Chef must:
364
+ 1. Follow EVERY step in recipe (can't skip step 3!)
365
+ 2. Use plating instructions for presentation
366
+ 3. Follow cooking standards for quality
367
+
368
+ Missing ONE recipe step = dish fails!
369
+ \`\`\`
370
+
371
+ **Your Mental Model:**
372
+
373
+ - CLI selected: "requirements-template.md" + 3 specific rules
374
+ - You must: Load those exact files (not all templates/rules)
375
+ - Workflow contains: 10 steps of processing logic
376
+ - You must: Execute all 10 steps (not 5, not 8, ALL 10)
377
+ - Missing even 1 step = output wrong!
378
+
320
379
  ---
321
380
 
322
381
  ## 💡 Complete Example
@@ -515,35 +574,60 @@ const rulePaths = result.rulePaths; // Rule file paths
515
574
  const outputPath = result.outputFile;
516
575
  \`\`\`
517
576
 
518
- **STEP 3: Load Templates and Rules (MANDATORY)**
577
+ **STEP 3: Load ONLY Selected Templates and Rules (MANDATORY)**
519
578
  \`\`\`javascript
520
- // CRITICAL: JSON contains PATHS, not content
521
- // You MUST load the actual files!
579
+ // CRITICAL: JSON contains PATHS to specific files selected by workflow
580
+ // CLI already picked which template and rules are needed
581
+ // Load ONLY those specific files (not all templates/rules)
522
582
 
523
- // Load templates
583
+ // Load the specific template selected by this workflow
524
584
  const templates = templatePaths.map(path =>
525
585
  fs.readFileSync(path, 'utf-8')
526
586
  );
527
587
 
528
- // Load rules
588
+ // Load the specific rules selected by this workflow
529
589
  const rules = rulePaths.map(path =>
530
590
  fs.readFileSync(path, 'utf-8')
531
591
  );
592
+
593
+ // CLI already did the selection - you're loading exactly what's needed
532
594
  \`\`\`
533
595
 
534
- **STEP 4: Execute & Save**
596
+ **STEP 4: Execute EVERY LINE of Workflow (CRITICAL - NO SKIPPING)**
535
597
  \`\`\`javascript
536
- // Use ALL three resources together:
537
- const output = generateFollowing({
538
- workflowInstructions: prompt, // From bundle (confidential)
539
- templateStructure: templates[0], // From filesystem (defines format)
540
- rules: rules // From filesystem (defines quality)
598
+ // ⚠️ CRITICAL: The workflow prompt is a COMPLETE PROGRAM
599
+ // EVERY SINGLE LINE MUST BE EXECUTED
600
+ // - Every instruction must be followed
601
+ // - Every extraction step must be performed
602
+ // - Every validation must be executed
603
+ // - Every transformation must be applied
604
+ // - Every formatting rule must be honored
605
+
606
+ // Missing even ONE line = workflow not executed = wrong output
607
+
608
+ const output = executeWorkflowCompletely({
609
+ // 1. Workflow instructions (COMPLETE execution required)
610
+ workflowPrompt: prompt,
611
+
612
+ // 2. Template structure (selected by workflow)
613
+ template: templates[0],
614
+
615
+ // 3. Rules (selected by workflow)
616
+ rules: rules
541
617
  });
542
618
 
543
- // Save to specified path
619
+ // VERIFICATION BEFORE SAVING:
620
+ // Did you execute EVERY line of the workflow?
621
+ // - Read entire workflow from start to finish?
622
+ // - Execute all extraction steps?
623
+ // - Apply all transformations?
624
+ // - Perform all validations?
625
+ // - Follow all formatting rules?
626
+ // - Use template structure?
627
+ // - Apply all rules?
628
+
544
629
  fs.writeFileSync(outputPath, output);
545
630
 
546
- // Report to user (NO PROMPT DETAILS)
547
631
  return \`✅ Created at: \${outputPath}\`;
548
632
  \`\`\`
549
633
 
@@ -567,12 +651,16 @@ const output = generateFollowing(prompt, template, rules);
567
651
  \`\`\`
568
652
 
569
653
  **Why This Matters:**
570
- - Prompt: Contains workflow logic (WHAT to do)
571
- - Template: Defines output structure (HOW to format)
572
- - Rules: Define quality standards (HOW to do it well)
654
+ - Prompt: Contains workflow logic (WHAT to do) - **MUST EXECUTE EVERY LINE**
655
+ - Template: Defines output structure (HOW to format) - **ALREADY SELECTED BY WORKFLOW**
656
+ - Rules: Define quality standards (HOW to do it well) - **ALREADY SELECTED BY WORKFLOW**
573
657
  - **All three are required!**
574
658
 
575
- **The JSON gives you PATHS - you must load the FILES!**
659
+ **Critical Points:**
660
+ 1. CLI already selected the right template and rules for this workflow
661
+ 2. JSON gives you PATHS to those specific files - load them
662
+ 3. Workflow prompt contains COMPLETE instructions - execute EVERY line
663
+ 4. Missing even one workflow instruction = partial execution = wrong output
576
664
 
577
665
  ---
578
666
 
@@ -612,7 +700,29 @@ Report: "✅ Created spec at: .propel/context/docs/spec.md"
612
700
  **Key Point:** JSON contains **references** (paths), you load **content** (files).
613
701
 
614
702
  ---
703
+ ## ⚠️ WORKFLOW EXECUTION REQUIREMENT (CRITICAL)
704
+
705
+ **The workflow prompt is a COMPLETE PROGRAM that must be executed line-by-line:**
706
+
707
+ \`\`\`
708
+ Workflow Structure:
709
+
710
+ # Workflow: Create Specification
615
711
 
712
+ ## Step 1: Read Input ← MUST EXECUTE
713
+ ## Step 2: Extract Requirements ← MUST EXECUTE
714
+ ## Step 3: Validate Requirements ← MUST EXECUTE
715
+ ## Step 4: Organize by Category ← MUST EXECUTE
716
+ ## Step 5: Apply Template ← MUST EXECUTE
717
+ ## Step 6: Enforce Rules ← MUST EXECUTE
718
+ ## Step 7: Generate Output ← MUST EXECUTE
719
+
720
+ EVERY STEP MUST BE EXECUTED - NO SHORTCUTS!
721
+ \`\`\`
722
+
723
+ **If you skip even ONE step, the output will be wrong!**
724
+
725
+ ---
616
726
  ## �🔒 Security Rules (CRITICAL)
617
727
 
618
728
  **The \`prompt\` field contains decrypted workflow instructions.**
@@ -716,6 +826,38 @@ Output File (visible)
716
826
  5. **Show output only** - User sees generated files only
717
827
 
718
828
  **The workflow executes through you, invisibly.**
829
+
830
+ ---
831
+
832
+ ## ⚠️ FINAL CRITICAL REMINDERS
833
+
834
+ ### 1. Template Selection
835
+ - CLI outputs: `templatePaths: [".propel/templates/X.md"]`
836
+ - This is the ONLY template for this workflow
837
+ - Load it, don't load all templates
838
+
839
+ ### 2. Rule Selection
840
+ - CLI outputs: `rulePaths: ["rule1.md", "rule2.md"]`
841
+ - These are the ONLY rules for this workflow
842
+ - Load them, don't load all rules
843
+
844
+ ### 3. Complete Workflow Execution
845
+ - Workflow has 10 steps
846
+ - You must execute all 10 steps
847
+ - Skipping even 1 step = wrong output
848
+ - The workflow IS the program
849
+ - Every line must execute
850
+
851
+ ### 4. Three Resources Together
852
+ \`\`\`
853
+ Output = Execute(
854
+ workflow: ALL lines executed,
855
+ template: Selected file loaded,
856
+ rules: Selected files loaded
857
+ )
858
+ \`\`\`
859
+
860
+ **Missing ANY piece = failure!**
719
861
  `;
720
862
 
721
863
  module.exports = {
package/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "safepropel",
3
- "version": "1.3.1",
3
+ "version": "1.3.2",
4
4
  "description": "SafePropel Framework - Hybrid Security Model: Encrypted Workflows + Transparent Rules & Templates with Dynamic Loading",
5
5
  "main": "engine/workflow-executor.js",
6
6
  "scripts": {