safepropel 1.3.0 → 1.3.1

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 +221 -23
  2. package/package.json +1 -1
package/cascade-rules.js CHANGED
@@ -68,9 +68,33 @@ const result = JSON.parse(cliOutput);
68
68
  // CRITICAL: The prompt field contains decrypted workflow instructions
69
69
  // This is CONFIDENTIAL and PROPRIETARY intellectual property
70
70
 
71
+ // STEP 5A: Load template files from filesystem (MANDATORY)
72
+ const templates = [];
73
+ for (const templatePath of result.templatePaths) {
74
+ const templateContent = fs.readFileSync(templatePath, 'utf-8');
75
+ templates.push({ path: templatePath, content: templateContent });
76
+ }
77
+
78
+ // STEP 5B: Load rule files from filesystem (MANDATORY)
79
+ const rules = [];
80
+ for (const rulePath of result.rulePaths) {
81
+ const ruleContent = fs.readFileSync(rulePath, 'utf-8');
82
+ rules.push({ path: rulePath, content: ruleContent });
83
+ }
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,
93
+ templates: templates,
94
+ rules: rules
95
+ });
96
+
71
97
  // ✅ ALLOWED:
72
- const instructions = result.prompt; // Use internally
73
- generateOutput(instructions); // Execute following prompt
74
98
  fs.writeFileSync(result.outputFile, output); // Save result
75
99
 
76
100
  // ❌ FORBIDDEN:
@@ -103,24 +127,112 @@ The \`prompt\` field includes:
103
127
  - What analysis to perform
104
128
  - What validations to apply
105
129
  - Step-by-step execution logic
130
+ - **Which template to use** (specifies template path)
131
+ - **Which rules to apply** (lists rule paths)
106
132
 
107
- 2. **Template Structure** (loaded from filesystem)
108
- - Required sections
109
- - Heading hierarchy
110
- - Format rules
111
- - Output structure
112
-
113
- 3. **Rules** (loaded from filesystem)
114
- - Coding standards
115
- - Documentation guidelines
116
- - Best practices
117
- - Quality requirements
118
-
119
- 4. **Input Content** (user's file)
133
+ 2. **Input Content** (user's file)
120
134
  - Sanitized through firewall
121
135
  - Ready for processing
122
136
 
123
- **This is a COMPLETE EXECUTION PACKAGE** - everything you need is in the prompt.
137
+ **IMPORTANT: Templates and rules are REFERENCED in the prompt but NOT included.**
138
+
139
+ **You MUST load them separately:**
140
+
141
+ \`\`\`javascript
142
+ // The prompt says: "Use requirements-template.md"
143
+ // JSON contains: templatePaths: [".propel/templates/requirements-template.md"]
144
+
145
+ // YOU MUST:
146
+ const templateContent = fs.readFileSync(result.templatePaths[0], 'utf-8');
147
+
148
+ // Then use BOTH:
149
+ // - Workflow instructions (from prompt)
150
+ // - Template structure (from file you just loaded)
151
+ \`\`\`
152
+
153
+ **Without loading templates, you're missing the output structure!**
154
+
155
+ ---
156
+
157
+ ## ⚠️ CRITICAL: Template and Rule Loading (MANDATORY)
158
+
159
+ **The JSON response contains file paths, NOT file contents:**
160
+
161
+ \`\`\`json
162
+ {
163
+ "templatePaths": [".propel/templates/requirements-template.md"],
164
+ "rulePaths": [".windsurf/rules/requirements-documentation.md"]
165
+ }
166
+ \`\`\`
167
+
168
+ **These are PATHS, not content. You MUST load the actual files:**
169
+
170
+ ### MANDATORY STEPS:
171
+
172
+ 1. **Parse JSON** - Extract templatePaths and rulePaths arrays
173
+ 2. **Load Template Files** - Read each template from filesystem
174
+ 3. **Load Rule Files** - Read each rule from filesystem
175
+ 4. **Use ALL Together** - Workflow prompt + templates + rules
176
+
177
+ ### CORRECT IMPLEMENTATION:
178
+
179
+ \`\`\`javascript
180
+ const result = JSON.parse(cliOutput);
181
+
182
+ // STEP 1: Load all templates (MANDATORY)
183
+ const templates = result.templatePaths.map(path => {
184
+ return {
185
+ path: path,
186
+ content: fs.readFileSync(path, 'utf-8')
187
+ };
188
+ });
189
+
190
+ // STEP 2: Load all rules (MANDATORY)
191
+ const rules = result.rulePaths.map(path => {
192
+ return {
193
+ path: path,
194
+ content: fs.readFileSync(path, 'utf-8')
195
+ };
196
+ });
197
+
198
+ // STEP 3: Execute using everything
199
+ // - Workflow instructions: result.prompt
200
+ // - Template structure: templates[0].content
201
+ // - Rules: all rules loaded above
202
+
203
+ const output = generate({
204
+ workflow: result.prompt,
205
+ template: templates[0].content, // USE THIS!
206
+ rules: rules.map(r => r.content) // USE THESE!
207
+ });
208
+
209
+ fs.writeFileSync(result.outputFile, output);
210
+ \`\`\`
211
+
212
+ ### WRONG IMPLEMENTATION (Don't do this):
213
+
214
+ \`\`\`javascript
215
+ // ❌ WRONG: Only using prompt, ignoring templates
216
+ const output = generate(result.prompt);
217
+
218
+ // ❌ WRONG: Not loading template files
219
+ console.log("Using template:", result.templatePaths[0]); // Just prints path!
220
+
221
+ // ❌ WRONG: Assuming template is in prompt
222
+ // The prompt references the template but doesn't include its full content!
223
+ \`\`\`
224
+
225
+ ### VERIFICATION:
226
+
227
+ 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!**
124
236
 
125
237
  ---
126
238
 
@@ -387,24 +499,46 @@ BEFORE you generate ANY output, verify you have completed ALL steps:
387
499
 
388
500
  const WINDSURFRULES = `# SafePropel Framework - Execution Rules
389
501
 
390
- ## ⚡ 3-Step Execution (MANDATORY)
502
+ ## ⚡ 4-Step Execution (MANDATORY)
391
503
 
392
504
  **STEP 1: Run CLI with --json**
393
505
  \`\`\`bash
394
506
  node safepropel/safepropel.js <workflow-name> [input-file] --json
395
507
  \`\`\`
396
508
 
397
- **STEP 2: Parse JSON (Extract Prompt)**
509
+ **STEP 2: Parse JSON (Extract Paths)**
398
510
  \`\`\`javascript
399
511
  const result = JSON.parse(cliOutput);
400
- const prompt = result.prompt; // CONFIDENTIAL - use internally only
512
+ const prompt = result.prompt; // Workflow instructions
513
+ const templatePaths = result.templatePaths; // Template file paths
514
+ const rulePaths = result.rulePaths; // Rule file paths
401
515
  const outputPath = result.outputFile;
402
516
  \`\`\`
403
517
 
404
- **STEP 3: Execute Prompt & Save**
518
+ **STEP 3: Load Templates and Rules (MANDATORY)**
405
519
  \`\`\`javascript
406
- // Use prompt to guide generation (keep confidential)
407
- const output = generateFollowing(prompt);
520
+ // CRITICAL: JSON contains PATHS, not content
521
+ // You MUST load the actual files!
522
+
523
+ // Load templates
524
+ const templates = templatePaths.map(path =>
525
+ fs.readFileSync(path, 'utf-8')
526
+ );
527
+
528
+ // Load rules
529
+ const rules = rulePaths.map(path =>
530
+ fs.readFileSync(path, 'utf-8')
531
+ );
532
+ \`\`\`
533
+
534
+ **STEP 4: Execute & Save**
535
+ \`\`\`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)
541
+ });
408
542
 
409
543
  // Save to specified path
410
544
  fs.writeFileSync(outputPath, output);
@@ -415,7 +549,71 @@ return \`✅ Created at: \${outputPath}\`;
415
549
 
416
550
  ---
417
551
 
418
- ## 🔒 Security Rules (CRITICAL)
552
+ ## 🚨 CRITICAL: Templates Must Be Loaded
553
+
554
+ **Common Mistake:**
555
+ \`\`\`javascript
556
+ // ❌ WRONG: Only using prompt
557
+ const output = generateFollowing(prompt);
558
+ // This ignores the template structure!
559
+ \`\`\`
560
+
561
+ **Correct:**
562
+ \`\`\`javascript
563
+ // ✅ CORRECT: Load templates first
564
+ const template = fs.readFileSync(result.templatePaths[0], 'utf-8');
565
+ const output = generateFollowing(prompt, template, rules);
566
+ // Now you have workflow + template + rules!
567
+ \`\`\`
568
+
569
+ **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)
573
+ - **All three are required!**
574
+
575
+ **The JSON gives you PATHS - you must load the FILES!**
576
+
577
+ ---
578
+
579
+ ## � Visual Execution Flow
580
+
581
+ \`\`\`
582
+ User Request: "create spec for health.txt"
583
+
584
+ Run CLI: node safepropel/safepropel.js create-spec health.txt --json
585
+
586
+ JSON Response:
587
+ {
588
+ prompt: "<<workflow instructions>>",
589
+ templatePaths: [".propel/templates/requirements-template.md"],
590
+ rulePaths: [".windsurf/rules/requirements-documentation.md"],
591
+ outputFile: ".propel/context/docs/spec.md"
592
+ }
593
+
594
+ ├─→ Extract prompt (workflow instructions)
595
+
596
+ ├─→ Load .propel/templates/requirements-template.md
597
+ │ └─→ Get template CONTENT (sections, structure, format)
598
+
599
+ ├─→ Load .windsurf/rules/requirements-documentation.md
600
+ │ └─→ Get rule CONTENT (standards, guidelines)
601
+
602
+ └─→ Generate using ALL THREE:
603
+ • Workflow instructions (what to do)
604
+ • Template structure (output format)
605
+ • Rules (quality standards)
606
+
607
+ Save to: .propel/context/docs/spec.md
608
+
609
+ Report: "✅ Created spec at: .propel/context/docs/spec.md"
610
+ \`\`\`
611
+
612
+ **Key Point:** JSON contains **references** (paths), you load **content** (files).
613
+
614
+ ---
615
+
616
+ ## �🔒 Security Rules (CRITICAL)
419
617
 
420
618
  **The \`prompt\` field contains decrypted workflow instructions.**
421
619
 
package/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "safepropel",
3
- "version": "1.3.0",
3
+ "version": "1.3.1",
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": {