create-byan-agent 2.16.1 → 2.17.0

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 (30) hide show
  1. package/CHANGELOG.md +78 -0
  2. package/README.md +24 -0
  3. package/install/lib/claude-native-setup.js +37 -0
  4. package/install/package.json +1 -1
  5. package/install/packages/platform-config/lib/validate.js +0 -14
  6. package/install/src/webui/api.js +6 -0
  7. package/install/src/webui/server.js +8 -1
  8. package/install/templates/.claude/CLAUDE.md +18 -0
  9. package/install/templates/.claude/hooks/lib/strict-config.json +46 -0
  10. package/install/templates/.claude/hooks/lib/strict-runtime.js +82 -0
  11. package/install/templates/.claude/hooks/strict-context-inject.js +86 -0
  12. package/install/templates/.claude/hooks/strict-scope-guard.js +101 -0
  13. package/install/templates/.claude/hooks/strict-stop-guard.js +100 -0
  14. package/install/templates/.claude/rules/strict-mode.md +166 -0
  15. package/install/templates/.claude/settings.json +12 -0
  16. package/install/templates/.claude/skills/byan-strict/SKILL.md +54 -0
  17. package/install/templates/.githooks/pre-commit +15 -0
  18. package/install/templates/_byan/_config/strict-mode.yaml +258 -0
  19. package/install/templates/_byan/mcp/byan-mcp-server/bin/byan-sync-rules.js +24 -0
  20. package/install/templates/_byan/mcp/byan-mcp-server/bin/strict-precommit-gate.js +21 -0
  21. package/install/templates/_byan/mcp/byan-mcp-server/lib/fd-state.js +2 -1
  22. package/install/templates/_byan/mcp/byan-mcp-server/lib/precommit-gate.js +120 -0
  23. package/install/templates/_byan/mcp/byan-mcp-server/lib/strict-activation.js +76 -0
  24. package/install/templates/_byan/mcp/byan-mcp-server/lib/strict-mode.js +391 -0
  25. package/install/templates/_byan/mcp/byan-mcp-server/lib/strict-sync.js +140 -0
  26. package/install/templates/_byan/mcp/byan-mcp-server/lib/sync-rules.js +261 -0
  27. package/install/templates/_byan/mcp/byan-mcp-server/server.js +207 -1
  28. package/package.json +6 -2
  29. package/src/byan-v2/data/strict-mantras.json +188 -0
  30. package/src/byan-v2/generation/mantra-validator.js +39 -4
@@ -0,0 +1,188 @@
1
+ {
2
+ "metadata": {
3
+ "source": "byan-sync-rules",
4
+ "generated_from": "_byan/_config/strict-mode.yaml",
5
+ "count": 12
6
+ },
7
+ "mantras": [
8
+ {
9
+ "id": "STRICT-1",
10
+ "title": "Scope Lock First",
11
+ "description": "Reformulate the request and lock the scope before any build. The locked scope is the contract for the rest of the task.",
12
+ "validation": {
13
+ "type": "keyword",
14
+ "keywords": [
15
+ "lock the scope",
16
+ "byan_strict_lock_scope",
17
+ "scope lock"
18
+ ],
19
+ "required": true
20
+ },
21
+ "priority": "critical"
22
+ },
23
+ {
24
+ "id": "STRICT-2",
25
+ "title": "No Downgrade",
26
+ "description": "Deliver the scope that was asked. Do not substitute an MVP, a stub, or a \"simplified version\" unless the user approves it and it is recorded in the audit trail.",
27
+ "validation": {
28
+ "type": "keyword",
29
+ "keywords": [
30
+ "no downgrade",
31
+ "downgrade",
32
+ "mvp"
33
+ ],
34
+ "required": true
35
+ },
36
+ "priority": "critical"
37
+ },
38
+ {
39
+ "id": "STRICT-3",
40
+ "title": "No Silent Cut",
41
+ "description": "If a part of the scope cannot be done, surface it as a gap in the self_verify findings. Do not drop it quietly.",
42
+ "validation": {
43
+ "type": "keyword",
44
+ "keywords": [
45
+ "silent cut",
46
+ "surface it as a gap",
47
+ "do not cut silently"
48
+ ],
49
+ "required": true
50
+ },
51
+ "priority": "high"
52
+ },
53
+ {
54
+ "id": "STRICT-4",
55
+ "title": "Self-Verify Three Times",
56
+ "description": "Run at least three self-verification passes against the locked acceptance criteria before calling complete.",
57
+ "validation": {
58
+ "type": "keyword",
59
+ "keywords": [
60
+ "self-verify",
61
+ "byan_strict_self_verify",
62
+ "three times"
63
+ ],
64
+ "required": true
65
+ },
66
+ "priority": "critical"
67
+ },
68
+ {
69
+ "id": "STRICT-5",
70
+ "title": "Re-Read The Original",
71
+ "description": "Each self-verify pass re-reads the original request, not your own summary of it.",
72
+ "validation": {
73
+ "type": "keyword",
74
+ "keywords": [
75
+ "re-read",
76
+ "original request"
77
+ ],
78
+ "required": true
79
+ },
80
+ "priority": "high"
81
+ },
82
+ {
83
+ "id": "STRICT-6",
84
+ "title": "Evidence Over Assertion",
85
+ "description": "A \"done\" claim needs an artifact (test output, file diff, command result), not a statement.",
86
+ "validation": {
87
+ "type": "keyword",
88
+ "keywords": [
89
+ "evidence",
90
+ "artifact",
91
+ "test output"
92
+ ],
93
+ "required": true
94
+ },
95
+ "priority": "high"
96
+ },
97
+ {
98
+ "id": "STRICT-7",
99
+ "title": "Hard Claim Floor",
100
+ "description": "Claims in security, performance, or compliance need LEVEL-1 sourcing (95%) or they are BLOCKED.",
101
+ "validation": {
102
+ "type": "keyword",
103
+ "keywords": [
104
+ "level-1",
105
+ "95%",
106
+ "blocked"
107
+ ],
108
+ "required": true
109
+ },
110
+ "priority": "critical"
111
+ },
112
+ {
113
+ "id": "STRICT-8",
114
+ "title": "Gap Is Not Failure",
115
+ "description": "Reporting a gap is the correct behavior. Hiding a gap is the violation.",
116
+ "validation": {
117
+ "type": "keyword",
118
+ "keywords": [
119
+ "gap is",
120
+ "hiding a gap",
121
+ "the violation"
122
+ ],
123
+ "required": true
124
+ },
125
+ "priority": "high"
126
+ },
127
+ {
128
+ "id": "STRICT-9",
129
+ "title": "Audit Trail",
130
+ "description": "Every scope lock, verify pass, and completion is appended to the audit log. The commit gate reads this trail.",
131
+ "validation": {
132
+ "type": "keyword",
133
+ "keywords": [
134
+ "audit trail",
135
+ "audit log",
136
+ "audit token"
137
+ ],
138
+ "required": true
139
+ },
140
+ "priority": "high"
141
+ },
142
+ {
143
+ "id": "STRICT-10",
144
+ "title": "No Premature Complete",
145
+ "description": "complete is rejected below three passes or when the last pass found a gap.",
146
+ "validation": {
147
+ "type": "keyword",
148
+ "keywords": [
149
+ "byan_strict_complete",
150
+ "rejected below",
151
+ "earn"
152
+ ],
153
+ "required": true
154
+ },
155
+ "priority": "critical"
156
+ },
157
+ {
158
+ "id": "STRICT-11",
159
+ "title": "Honest Status",
160
+ "description": "Report failing tests with their output. Report skipped steps as skipped. Do not round a partial result up to \"done\".",
161
+ "validation": {
162
+ "type": "keyword",
163
+ "keywords": [
164
+ "honest status",
165
+ "failing tests",
166
+ "skipped"
167
+ ],
168
+ "required": true
169
+ },
170
+ "priority": "high"
171
+ },
172
+ {
173
+ "id": "STRICT-12",
174
+ "title": "Full Over Fast",
175
+ "description": "When the user states \"complete, no cost compromise\", speed is out of scope. Do not re-question the budget under the guise of an estimate.",
176
+ "validation": {
177
+ "type": "keyword",
178
+ "keywords": [
179
+ "full over fast",
180
+ "no cost compromise",
181
+ "out of scope"
182
+ ],
183
+ "required": true
184
+ },
185
+ "priority": "high"
186
+ }
187
+ ]
188
+ }
@@ -5,25 +5,60 @@ class MantraValidator {
5
5
  constructor(mantrasData = null) {
6
6
  if (mantrasData) {
7
7
  this.mantrasData = mantrasData;
8
+ this._explicitMantras = true;
8
9
  } else {
9
10
  const mantrasPath = path.join(__dirname, '../data/mantras.json');
10
11
  this.mantrasData = JSON.parse(fs.readFileSync(mantrasPath, 'utf8'));
12
+ this._explicitMantras = false;
11
13
  }
12
-
13
- this.mantras = this.mantrasData.mantras;
14
+
15
+ this.personaMantras = this.mantrasData.mantras;
16
+ this.strictMantras = this._loadStrictMantras();
17
+ this.mantras = this.personaMantras;
14
18
  this.results = null;
15
19
  this.agentContent = null;
16
20
  }
17
21
 
22
+ // Strict-mode artifacts (the byan-strict skill, AGENTS.md block, copilot
23
+ // block) are validated against the strict mantra set, not the 64 persona
24
+ // mantras. The set is generated by byan-sync-rules from strict-mode.yaml.
25
+ _loadStrictMantras() {
26
+ try {
27
+ const p = path.join(__dirname, '../data/strict-mantras.json');
28
+ if (fs.existsSync(p)) {
29
+ return JSON.parse(fs.readFileSync(p, 'utf8')).mantras;
30
+ }
31
+ } catch {
32
+ // fall through — no strict set available
33
+ }
34
+ return null;
35
+ }
36
+
37
+ _isStrictArtifact(content) {
38
+ if (typeof content !== 'string') return false;
39
+ if (/name:\s*byan-strict/.test(content)) return true;
40
+ if (/#\s*BYAN Strict Mode/.test(content)) return true;
41
+ const strictIds = content.match(/STRICT-\d+/g) || [];
42
+ return strictIds.length >= 3;
43
+ }
44
+
18
45
  validate(agentDefinition) {
19
46
  if (agentDefinition === null || agentDefinition === undefined) {
20
47
  throw new Error('Agent definition is required');
21
48
  }
22
49
 
23
- this.agentContent = typeof agentDefinition === 'string'
24
- ? agentDefinition
50
+ this.agentContent = typeof agentDefinition === 'string'
51
+ ? agentDefinition
25
52
  : JSON.stringify(agentDefinition);
26
53
 
54
+ // Pick the ruleset : strict artifacts get the strict mantras, unless the
55
+ // caller supplied an explicit mantra set in the constructor.
56
+ if (!this._explicitMantras && this.strictMantras && this._isStrictArtifact(this.agentContent)) {
57
+ this.mantras = this.strictMantras;
58
+ } else {
59
+ this.mantras = this.personaMantras;
60
+ }
61
+
27
62
  this.results = {
28
63
  totalMantras: this.mantras.length,
29
64
  compliant: [],