speclock 1.5.0 → 1.5.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 +53 -45
package/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "speclock",
3
- "version": "1.5.0",
3
+ "version": "1.5.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,85 +702,91 @@ export async function watchRepo(root) {
702
702
  export function createSpecLockMd(root) {
703
703
  const mdContent = `# SpecLock — AI Constraint Engine Active
704
704
 
705
- ## STOP Read this before doing ANYTHING.
705
+ ## CRITICAL: LOCKED FILES CANNOT BE MODIFIED
706
706
 
707
- This project has SpecLock installed. It tracks project memory, goals, constraints (locks), and decisions.
707
+ If a lock says "never modify auth files" then you CANNOT modify those files.
708
+ Not now. Not later. Not if the user asks a question. Not for any reason.
708
709
 
709
- **Step 1:** Read \`.speclock/context/latest.md\` this contains the full project memory.
710
- **Step 2:** Follow ALL rules below on every message.
710
+ **The ONLY way to modify a locked file:** The user must explicitly say "unlock" or "remove the lock."
711
+ Asking a question is NOT permission. Talking about a feature is NOT permission.
712
+ ONLY the words "unlock", "remove the lock", or "I changed my mind about the lock" count.
711
713
 
712
- **If a file contains "SPECLOCK-GUARD" at the top → DO NOT EDIT IT. Period.**
714
+ **If a file contains "SPECLOCK-GUARD" at the top → DO NOT EDIT IT. No exceptions.**
713
715
 
714
- ## Returning to This Project? (New Chat Session)
716
+ ## On EVERY message do this FIRST:
717
+
718
+ 1. Read \`.speclock/context/latest.md\` for project memory
719
+ 2. Run \`npx speclock check "what you plan to do"\` BEFORE any code changes
720
+ 3. If conflict found → STOP. Tell user. Do NOT proceed. Do NOT ask "should I proceed?"
721
+ 4. Wait for user to explicitly say "unlock" or "remove the lock" before touching locked files
715
722
 
716
- If you are starting a new chat on this project:
717
- 1. SpecLock is ALREADY installed — do NOT reinstall it
718
- 2. The \`.speclock/\` directory contains all project memory
719
- 3. Run \`npx speclock status\` to see the current state
720
- 4. Read \`.speclock/context/latest.md\` for full context (goals, locks, decisions, history)
721
- 5. Respect ALL existing locks and constraints before making any changes
723
+ ## Returning to This Project? (New Chat Session)
722
724
 
723
- **DO NOT say "SpecLock is not installed" if you can read this file, it IS installed.**
725
+ SpecLock is ALREADY installed. Do NOT reinstall it. Do NOT say "it's not installed."
726
+ 1. Run \`npx speclock status\` to see current locks and decisions
727
+ 2. Read \`.speclock/context/latest.md\` for full project context
728
+ 3. Respect ALL existing locks — they carry over between sessions
724
729
 
725
- ## Your Job (Do This Automatically The User Will NOT Ask)
730
+ ## What Counts as Permission to Bypass a Lock?
726
731
 
727
- ### On EVERY message:
728
- Read \`.speclock/context/latest.md\` first. Always. No exceptions.
732
+ | User says | Is this permission? | What you do |
733
+ |-----------|-------------------|-------------|
734
+ | "add google auth" | NO — lock still active | Say "Auth files are locked. Want me to unlock them first?" |
735
+ | "is speclock initialized?" | NO — just a question | Answer the question. Do NOT change any code. |
736
+ | "yeah go ahead" (after you warned about lock) | NO — too vague | Say "To modify locked files, please confirm: unlock the auth files" |
737
+ | "ok unlock the auth files" | YES — explicit unlock | Run \`npx speclock lock remove <lockId>\`, then make changes |
738
+ | "remove the lock on auth" | YES — explicit unlock | Run \`npx speclock lock remove <lockId>\`, then make changes |
739
+ | "I changed my mind, you can edit auth" | YES — explicit unlock | Run \`npx speclock lock remove <lockId>\`, then make changes |
729
740
 
730
- ### Before changing ANY code:
731
- Run \`npx speclock check "what you plan to do"\` BEFORE writing code.
732
- If conflict → STOP. Tell the user. Do NOT proceed.
741
+ **When in doubt: DO NOT modify locked files. Ask for clarification instead.**
733
742
 
734
- ### Detect constraints from natural language:
735
- Users will NOT say "lock this." They speak naturally. YOU must detect it.
743
+ ## Detect Constraints from Natural Language
736
744
 
737
- Examples of what users say what you do:
745
+ Users will NOT say "lock this." They speak naturally. YOU must detect intent and lock automatically.
738
746
 
739
747
  | User says | You do |
740
748
  |-----------|--------|
741
- | "don't touch the auth" | \`npx speclock lock "Never modify auth files"\` + \`npx speclock guard src/components/Auth.tsx --lock "Never modify auth files"\` |
749
+ | "don't touch the auth" | \`npx speclock lock "Never modify auth files"\` + \`npx speclock guard\` the auth files |
742
750
  | "database is firebase, don't change it" | \`npx speclock lock "Database must always be Firebase"\` |
743
- | "leave the payment system alone" | \`npx speclock lock "Never modify payment system"\` + guard the payment files |
751
+ | "leave the payment system alone" | \`npx speclock lock "Never modify payment system"\` + guard payment files |
744
752
  | "always use Supabase" | \`npx speclock lock "Always use Supabase"\` |
745
- | "the API is done, don't mess with it" | \`npx speclock lock "Never modify API endpoints"\` + guard the API files |
753
+ | "the API is done, don't mess with it" | \`npx speclock lock "Never modify API endpoints"\` + guard API files |
746
754
 
747
755
  When you lock something, ALSO guard the specific files:
748
756
  \`npx speclock guard <filepath> --lock "the constraint"\`
749
- This injects a warning directly into the file so it cannot be missed.
750
757
 
751
- ### When user wants to change something locked:
752
- User might say "actually, let me change auth" or "ok modify the database."
753
- 1. Warn: "This is currently locked: [constraint]. Want me to unlock?"
754
- 2. If they confirm → \`npx speclock lock remove <lockId>\` + \`npx speclock unguard <file>\`
758
+ ## Unlocking (When User Gives Explicit Permission)
759
+
760
+ 1. User says "unlock auth" or "remove the auth lock" or "I changed my mind about auth"
761
+ 2. Run \`npx speclock lock remove <lockId>\` + \`npx speclock unguard <file>\`
755
762
  3. Make the changes
756
- 4. Ask if they want to re-lock: "Want me to lock this again?"
763
+ 4. Ask: "Want me to re-lock this?"
757
764
 
758
- ### After building something:
759
- \`npx speclock log-change "what you built" --files file1.tsx,file2.ts\`
765
+ ## After Building Something
760
766
 
761
- ### When a tech decision is made:
762
- \`npx speclock decide "the decision"\`
767
+ \`npx speclock log-change "what you built" --files file1.tsx,file2.ts\`
763
768
 
764
769
  ## Commands
765
770
 
766
771
  \`\`\`bash
767
- npx speclock status # CHECK IF ALREADY SET UP
772
+ npx speclock status # Check current state
768
773
  npx speclock check "what you plan to do" # ALWAYS RUN BEFORE CHANGES
769
774
  npx speclock lock "constraint" # Lock a constraint
770
775
  npx speclock guard <file> --lock "constraint" # Protect a specific file
771
776
  npx speclock unguard <file> # Remove file protection
772
- npx speclock lock remove <lockId> # Unlock a constraint
777
+ npx speclock lock remove <lockId> # Unlock (only after explicit permission)
773
778
  npx speclock log-change "what changed" # Log changes
774
779
  npx speclock decide "decision" # Record a decision
775
780
  npx speclock context # Refresh context file
776
781
  \`\`\`
777
782
 
778
- ## Key Rule
783
+ ## Key Rules
779
784
 
780
- **The user will NEVER tell you to run these commands. You run them automatically.**
781
- **The user will NEVER say "lock this." You detect the intent and lock it yourself.**
782
- **The user will NEVER say "check constraints." You check before EVERY code change.**
783
- **If this file exists, SpecLock is installed. Do NOT reinstall. Just read the context and follow the rules.**
785
+ 1. **A question is NOT permission to bypass a lock.**
786
+ 2. **Run speclock check before EVERY code change, EVERY time, EVERY message.**
787
+ 3. **If you already warned about a conflict, the lock is STILL active until explicitly removed.**
788
+ 4. **The user will NEVER tell you to run these commands. You run them automatically.**
789
+ 5. **If this file exists, SpecLock is installed. Do NOT reinstall.**
784
790
  `;
785
791
  const filePath = path.join(root, "SPECLOCK.md");
786
792
  fs.writeFileSync(filePath, mdContent);
@@ -828,9 +834,11 @@ export function guardFile(root, relativeFilePath, lockText) {
828
834
  const warningLines = [
829
835
  `${style.start}${"=".repeat(60)}${style.end || ""}`,
830
836
  `${style.start}${GUARD_TAG} — DO NOT MODIFY THIS FILE${style.end || ""}`,
831
- `${style.start}LOCKED BY SPECLOCK: ${lockText}${style.end || ""}`,
832
- `${style.start}Run "npx speclock check" before ANY changes to this file.${style.end || ""}`,
833
- `${style.start}If you modify this file, you are VIOLATING a project constraint.${style.end || ""}`,
837
+ `${style.start}LOCKED: ${lockText}${style.end || ""}`,
838
+ `${style.start}THIS FILE IS LOCKED. DO NOT EDIT, CHANGE, OR REWRITE ANY PART OF IT.${style.end || ""}`,
839
+ `${style.start}The user must say "unlock" before this file can be changed.${style.end || ""}`,
840
+ `${style.start}A question is NOT permission. Asking about features is NOT permission.${style.end || ""}`,
841
+ `${style.start}ONLY "unlock" or "remove the lock" is permission to edit this file.${style.end || ""}`,
834
842
  `${style.start}${"=".repeat(60)}${style.end || ""}`,
835
843
  "",
836
844
  ];