speclock 1.4.0 → 1.4.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/package.json +1 -1
  2. package/src/core/engine.js +46 -32
package/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "speclock",
3
- "version": "1.4.0",
3
+ "version": "1.4.1",
4
4
  "description": "AI constraint engine — MCP server + CLI with active enforcement. Memory + guardrails for AI coding tools. Works with Bolt.new, Claude Code, Cursor, Lovable.",
5
5
  "type": "module",
6
6
  "main": "src/mcp/server.js",
@@ -702,54 +702,68 @@ export async function watchRepo(root) {
702
702
  export function createSpecLockMd(root) {
703
703
  const mdContent = `# SpecLock — AI Constraint Engine Active
704
704
 
705
- ## MANDATORY: Read this BEFORE doing anything.
705
+ ## STOP Read this before doing ANYTHING.
706
706
 
707
- This project uses **SpecLock** for AI constraint enforcement.
707
+ **If a file contains "SPECLOCK-GUARD" at the top → DO NOT EDIT IT. Period.**
708
708
 
709
- **STOP. Before writing or modifying ANY code, you MUST:**
710
- 1. Read \`.speclock/context/latest.md\` for project memory
711
- 2. Run \`npx speclock check "what you plan to change"\`
712
- 3. If conflict found → STOP and warn the user
709
+ ## Your Job (Do This Automatically The User Will NOT Ask)
713
710
 
714
- **If a file starts with "SPECLOCK-GUARD — DO NOT MODIFY" → DO NOT EDIT IT.**
711
+ ### On EVERY message:
712
+ Read \`.speclock/context/latest.md\` first. Always. No exceptions.
715
713
 
716
- ## Rules (MANDATORY every message, no exceptions)
714
+ ### Before changing ANY code:
715
+ Run \`npx speclock check "what you plan to do"\` BEFORE writing code.
716
+ If conflict → STOP. Tell the user. Do NOT proceed.
717
717
 
718
- 1. **FIRST ACTION OF EVERY MESSAGE**: Read \`.speclock/context/latest.md\`. This contains all project constraints (locks), decisions, and goals. Show: "Memory loaded — X locks, Y decisions." If the file doesn't exist, run \`npx speclock context\`.
718
+ ### Detect constraints from natural language:
719
+ Users will NOT say "lock this." They speak naturally. YOU must detect it.
719
720
 
720
- 2. **BEFORE MODIFYING ANY CODE EVERY TIME**: Run \`npx speclock check "description of what you plan to change"\`. If a conflict is found (HIGH confidence), STOP IMMEDIATELY. Tell the user which constraint would be violated. Do NOT proceed unless the user explicitly overrides. THIS IS THE MOST IMPORTANT RULE.
721
+ Examples of what users say what you do:
721
722
 
722
- 3. **WHEN USER SAYS "lock this", "never touch", "don't change", "always", "critical"**: Run \`npx speclock lock "the exact constraint"\`. Then run \`npx speclock guard <file> --lock "constraint"\` on the specific files to inject a lock warning directly into the file. Confirm: "Locked: [constraint]"
723
+ | User says | You do |
724
+ |-----------|--------|
725
+ | "don't touch the auth" | \`npx speclock lock "Never modify auth files"\` + \`npx speclock guard src/components/Auth.tsx --lock "Never modify auth files"\` |
726
+ | "database is firebase, don't change it" | \`npx speclock lock "Database must always be Firebase"\` |
727
+ | "leave the payment system alone" | \`npx speclock lock "Never modify payment system"\` + guard the payment files |
728
+ | "always use Supabase" | \`npx speclock lock "Always use Supabase"\` |
729
+ | "the API is done, don't mess with it" | \`npx speclock lock "Never modify API endpoints"\` + guard the API files |
723
730
 
724
- 4. **AFTER COMPLETING A FEATURE OR CHANGE**: Run \`npx speclock log-change "what was built" --files file1.tsx,file2.ts\`.
731
+ When you lock something, ALSO guard the specific files:
732
+ \`npx speclock guard <filepath> --lock "the constraint"\`
733
+ This injects a warning directly into the file so it cannot be missed.
725
734
 
726
- 5. **WHEN AN ARCHITECTURAL DECISION IS MADE**: Run \`npx speclock decide "the decision"\`
735
+ ### When user wants to change something locked:
736
+ User might say "actually, let me change auth" or "ok modify the database."
737
+ 1. Warn: "This is currently locked: [constraint]. Want me to unlock?"
738
+ 2. If they confirm → \`npx speclock lock remove <lockId>\` + \`npx speclock unguard <file>\`
739
+ 3. Make the changes
740
+ 4. Ask if they want to re-lock: "Want me to lock this again?"
727
741
 
728
- 6. **WHEN USER WANTS TO CHANGE SOMETHING LOCKED**: Warn first. If confirmed, run \`npx speclock lock remove <lockId>\` and \`npx speclock unguard <file>\` to remove the file guard.
742
+ ### After building something:
743
+ \`npx speclock log-change "what you built" --files file1.tsx,file2.ts\`
729
744
 
730
- ## Quick Reference
745
+ ### When a tech decision is made:
746
+ \`npx speclock decide "the decision"\`
747
+
748
+ ## Commands
731
749
 
732
750
  \`\`\`bash
733
- npx speclock check "what you plan to do" # CHECK BEFORE CHANGES
734
- npx speclock lock "constraint text" # Add a constraint
735
- npx speclock guard src/Auth.tsx --lock "text" # Inject lock into file
736
- npx speclock unguard src/Auth.tsx # Remove file lock
737
- npx speclock lock remove <lockId> # Remove a constraint
738
- npx speclock log-change "what changed" # Log a change
739
- npx speclock decide "decision text" # Record a decision
740
- npx speclock context # Regenerate context file
741
- npx speclock status # See brain summary
751
+ npx speclock check "what you plan to do" # ALWAYS RUN BEFORE CHANGES
752
+ npx speclock lock "constraint" # Lock a constraint
753
+ npx speclock guard <file> --lock "constraint" # Protect a specific file
754
+ npx speclock unguard <file> # Remove file protection
755
+ npx speclock lock remove <lockId> # Unlock a constraint
756
+ npx speclock log-change "what changed" # Log changes
757
+ npx speclock decide "decision" # Record a decision
758
+ npx speclock context # Refresh context file
759
+ npx speclock status # See project summary
742
760
  \`\`\`
743
761
 
744
- ## How It Works
745
-
746
- SpecLock maintains a \`.speclock/\` directory with structured project memory:
747
- - \`brain.json\` — goals, locks, decisions, session history
748
- - \`events.log\` — immutable audit trail
749
- - \`context/latest.md\` — human-readable context (read this!)
762
+ ## Key Rule
750
763
 
751
- **Guarded files** have a lock warning header injected directly into the source code.
752
- When you see "SPECLOCK-GUARD" at the top of a file, that file is LOCKED.
764
+ **The user will NEVER tell you to run these commands. You run them automatically.**
765
+ **The user will NEVER say "lock this." You detect the intent and lock it yourself.**
766
+ **The user will NEVER say "check constraints." You check before EVERY code change.**
753
767
  `;
754
768
  const filePath = path.join(root, "SPECLOCK.md");
755
769
  fs.writeFileSync(filePath, mdContent);