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.
- package/package.json +1 -1
- 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.
|
|
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",
|
package/src/core/engine.js
CHANGED
|
@@ -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
|
-
##
|
|
705
|
+
## CRITICAL: LOCKED FILES CANNOT BE MODIFIED
|
|
706
706
|
|
|
707
|
-
|
|
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
|
-
**
|
|
710
|
-
|
|
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.
|
|
714
|
+
**If a file contains "SPECLOCK-GUARD" at the top → DO NOT EDIT IT. No exceptions.**
|
|
713
715
|
|
|
714
|
-
##
|
|
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
|
-
|
|
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
|
-
|
|
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
|
-
##
|
|
730
|
+
## What Counts as Permission to Bypass a Lock?
|
|
726
731
|
|
|
727
|
-
|
|
728
|
-
|
|
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
|
-
|
|
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
|
-
|
|
735
|
-
Users will NOT say "lock this." They speak naturally. YOU must detect it.
|
|
743
|
+
## Detect Constraints from Natural Language
|
|
736
744
|
|
|
737
|
-
|
|
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
|
|
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
|
|
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
|
|
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
|
-
|
|
752
|
-
|
|
753
|
-
1.
|
|
754
|
-
2.
|
|
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
|
|
763
|
+
4. Ask: "Want me to re-lock this?"
|
|
757
764
|
|
|
758
|
-
|
|
759
|
-
\`npx speclock log-change "what you built" --files file1.tsx,file2.ts\`
|
|
765
|
+
## After Building Something
|
|
760
766
|
|
|
761
|
-
|
|
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 #
|
|
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
|
|
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
|
|
783
|
+
## Key Rules
|
|
779
784
|
|
|
780
|
-
**
|
|
781
|
-
**
|
|
782
|
-
**
|
|
783
|
-
**
|
|
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
|
|
832
|
-
`${style.start}
|
|
833
|
-
`${style.start}
|
|
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
|
];
|