loki-mode 5.42.2 → 5.46.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.
- package/README.md +4 -3
- package/SKILL.md +2 -2
- package/VERSION +1 -1
- package/autonomy/app-runner.sh +684 -0
- package/autonomy/checklist-verify.py +368 -0
- package/autonomy/completion-council.sh +49 -0
- package/autonomy/loki +83 -0
- package/autonomy/playwright-verify.sh +350 -0
- package/autonomy/prd-analyzer.py +457 -0
- package/autonomy/prd-checklist.sh +223 -0
- package/autonomy/run.sh +164 -4
- package/completions/loki.bash +6 -1
- package/dashboard/__init__.py +1 -1
- package/dashboard/server.py +134 -1
- package/dashboard/static/index.html +804 -265
- package/docs/INSTALLATION.md +1 -1
- package/docs/audit-logging.md +600 -0
- package/docs/authentication.md +374 -0
- package/docs/authorization.md +455 -0
- package/docs/git-workflow.md +446 -0
- package/docs/metrics.md +527 -0
- package/docs/network-security.md +275 -0
- package/docs/openclaw-integration.md +572 -0
- package/docs/siem-integration.md +579 -0
- package/learning/__init__.py +1 -1
- package/mcp/__init__.py +1 -1
- package/memory/__init__.py +2 -0
- package/package.json +2 -1
|
@@ -0,0 +1,446 @@
|
|
|
1
|
+
# Git Workflow
|
|
2
|
+
|
|
3
|
+
Branch protection and Git best practices for Loki Mode (v5.37.0).
|
|
4
|
+
|
|
5
|
+
## Overview
|
|
6
|
+
|
|
7
|
+
Loki Mode includes branch protection features that prevent direct commits to main/master branches and enforce a clean PR-based workflow. This ensures code review, quality gates, and audit trails for all changes made by autonomous agents.
|
|
8
|
+
|
|
9
|
+
## Branch Protection (v5.37.0)
|
|
10
|
+
|
|
11
|
+
### Enable Branch Protection
|
|
12
|
+
|
|
13
|
+
```bash
|
|
14
|
+
export LOKI_BRANCH_PROTECTION=true
|
|
15
|
+
loki start ./prd.md
|
|
16
|
+
```
|
|
17
|
+
|
|
18
|
+
When enabled, Loki Mode automatically:
|
|
19
|
+
|
|
20
|
+
1. Creates a feature branch: `loki/session-<timestamp>-<pid>`
|
|
21
|
+
2. Performs all agent work on the feature branch
|
|
22
|
+
3. Creates a PR at session end (if GitHub CLI is available)
|
|
23
|
+
4. Requires manual review and merge to main
|
|
24
|
+
|
|
25
|
+
### Feature Branch Naming
|
|
26
|
+
|
|
27
|
+
Branches are automatically named using this pattern:
|
|
28
|
+
|
|
29
|
+
```
|
|
30
|
+
loki/session-<timestamp>-<pid>
|
|
31
|
+
```
|
|
32
|
+
|
|
33
|
+
Examples:
|
|
34
|
+
- `loki/session-20260215-143022-12345`
|
|
35
|
+
- `loki/session-20260215-150430-67890`
|
|
36
|
+
|
|
37
|
+
### Workflow
|
|
38
|
+
|
|
39
|
+
```
|
|
40
|
+
Session Start
|
|
41
|
+
↓
|
|
42
|
+
Create feature branch (loki/session-*)
|
|
43
|
+
↓
|
|
44
|
+
Agent makes changes on feature branch
|
|
45
|
+
↓
|
|
46
|
+
Commit changes to feature branch
|
|
47
|
+
↓
|
|
48
|
+
Session Complete
|
|
49
|
+
↓
|
|
50
|
+
Create PR: feature branch → main
|
|
51
|
+
↓
|
|
52
|
+
Manual Review & Approval
|
|
53
|
+
↓
|
|
54
|
+
Merge to main (squash commit)
|
|
55
|
+
↓
|
|
56
|
+
Delete feature branch
|
|
57
|
+
```
|
|
58
|
+
|
|
59
|
+
## Configuration
|
|
60
|
+
|
|
61
|
+
### Environment Variables
|
|
62
|
+
|
|
63
|
+
| Variable | Default | Description |
|
|
64
|
+
|----------|---------|-------------|
|
|
65
|
+
| `LOKI_BRANCH_PROTECTION` | `false` | Enable automatic feature branch workflow |
|
|
66
|
+
| `LOKI_BASE_BRANCH` | `main` | Target branch for PRs (or `master` if detected) |
|
|
67
|
+
| `LOKI_BRANCH_PREFIX` | `loki/session-` | Prefix for auto-created branches |
|
|
68
|
+
| `LOKI_AUTO_PR` | `true` | Automatically create PR at session end |
|
|
69
|
+
| `LOKI_PR_TEMPLATE` | - | Path to PR description template |
|
|
70
|
+
|
|
71
|
+
### Configuration File
|
|
72
|
+
|
|
73
|
+
```yaml
|
|
74
|
+
# .loki/config.yaml
|
|
75
|
+
git:
|
|
76
|
+
branch_protection:
|
|
77
|
+
enabled: true
|
|
78
|
+
base_branch: main
|
|
79
|
+
branch_prefix: loki/session-
|
|
80
|
+
auto_pr: true
|
|
81
|
+
squash_merge: true
|
|
82
|
+
delete_after_merge: true
|
|
83
|
+
```
|
|
84
|
+
|
|
85
|
+
## Manual Git Workflow
|
|
86
|
+
|
|
87
|
+
If branch protection is disabled, follow these best practices:
|
|
88
|
+
|
|
89
|
+
### 1. Create Feature Branch
|
|
90
|
+
|
|
91
|
+
```bash
|
|
92
|
+
git checkout -b feature/my-feature
|
|
93
|
+
```
|
|
94
|
+
|
|
95
|
+
### 2. Run Loki Mode
|
|
96
|
+
|
|
97
|
+
```bash
|
|
98
|
+
loki start ./prd.md
|
|
99
|
+
```
|
|
100
|
+
|
|
101
|
+
### 3. Review Changes
|
|
102
|
+
|
|
103
|
+
```bash
|
|
104
|
+
git log --oneline
|
|
105
|
+
git diff main
|
|
106
|
+
```
|
|
107
|
+
|
|
108
|
+
### 4. Create Pull Request
|
|
109
|
+
|
|
110
|
+
```bash
|
|
111
|
+
# Using GitHub CLI
|
|
112
|
+
gh pr create --title "Add my feature" --body "Description"
|
|
113
|
+
|
|
114
|
+
# Or push and create PR manually
|
|
115
|
+
git push origin feature/my-feature
|
|
116
|
+
# Then create PR on GitHub.com
|
|
117
|
+
```
|
|
118
|
+
|
|
119
|
+
### 5. Review and Merge
|
|
120
|
+
|
|
121
|
+
- Request code review from team
|
|
122
|
+
- Address feedback
|
|
123
|
+
- Merge when approved
|
|
124
|
+
|
|
125
|
+
## Pull Request Creation
|
|
126
|
+
|
|
127
|
+
### Automatic PR Creation
|
|
128
|
+
|
|
129
|
+
When `LOKI_AUTO_PR=true` and GitHub CLI is installed:
|
|
130
|
+
|
|
131
|
+
```bash
|
|
132
|
+
# Loki Mode automatically runs at session end
|
|
133
|
+
gh pr create \
|
|
134
|
+
--title "Loki Mode session $(date +%Y-%m-%d)" \
|
|
135
|
+
--body "$(cat .loki/session-summary.md)" \
|
|
136
|
+
--base main \
|
|
137
|
+
--head loki/session-20260215-143022-12345
|
|
138
|
+
```
|
|
139
|
+
|
|
140
|
+
### PR Description Template
|
|
141
|
+
|
|
142
|
+
Create a template for consistent PR descriptions:
|
|
143
|
+
|
|
144
|
+
```markdown
|
|
145
|
+
# .loki/pr-template.md
|
|
146
|
+
|
|
147
|
+
## Changes
|
|
148
|
+
|
|
149
|
+
<!-- Auto-generated summary of changes -->
|
|
150
|
+
|
|
151
|
+
## Tasks Completed
|
|
152
|
+
|
|
153
|
+
<!-- List of completed tasks from task queue -->
|
|
154
|
+
|
|
155
|
+
## Quality Gates
|
|
156
|
+
|
|
157
|
+
- [ ] All tests passing
|
|
158
|
+
- [ ] Code review completed
|
|
159
|
+
- [ ] No security vulnerabilities
|
|
160
|
+
- [ ] Documentation updated
|
|
161
|
+
|
|
162
|
+
## Cost
|
|
163
|
+
|
|
164
|
+
Estimated cost: $X.XX USD
|
|
165
|
+
|
|
166
|
+
## Session Info
|
|
167
|
+
|
|
168
|
+
- Start: YYYY-MM-DD HH:MM:SS
|
|
169
|
+
- End: YYYY-MM-DD HH:MM:SS
|
|
170
|
+
- Duration: X hours
|
|
171
|
+
- Iterations: X
|
|
172
|
+
- Provider: claude/codex/gemini
|
|
173
|
+
```
|
|
174
|
+
|
|
175
|
+
Set template path:
|
|
176
|
+
|
|
177
|
+
```bash
|
|
178
|
+
export LOKI_PR_TEMPLATE=.loki/pr-template.md
|
|
179
|
+
```
|
|
180
|
+
|
|
181
|
+
## Agent Action Audit
|
|
182
|
+
|
|
183
|
+
All Git operations performed by agents are logged to `.loki/logs/agent-audit.jsonl`:
|
|
184
|
+
|
|
185
|
+
```json
|
|
186
|
+
{
|
|
187
|
+
"timestamp": "2026-02-15T14:30:00Z",
|
|
188
|
+
"action": "git_commit",
|
|
189
|
+
"agent": "development",
|
|
190
|
+
"branch": "loki/session-20260215-143022-12345",
|
|
191
|
+
"details": {
|
|
192
|
+
"message": "Add authentication module",
|
|
193
|
+
"files_changed": 3,
|
|
194
|
+
"insertions": 150,
|
|
195
|
+
"deletions": 20
|
|
196
|
+
}
|
|
197
|
+
}
|
|
198
|
+
```
|
|
199
|
+
|
|
200
|
+
View audit log:
|
|
201
|
+
|
|
202
|
+
```bash
|
|
203
|
+
loki audit log
|
|
204
|
+
loki audit log --action git_commit
|
|
205
|
+
```
|
|
206
|
+
|
|
207
|
+
## Git Hooks
|
|
208
|
+
|
|
209
|
+
Loki Mode respects Git hooks:
|
|
210
|
+
|
|
211
|
+
### Pre-commit Hook
|
|
212
|
+
|
|
213
|
+
Validate changes before commit:
|
|
214
|
+
|
|
215
|
+
```bash
|
|
216
|
+
#!/bin/bash
|
|
217
|
+
# .git/hooks/pre-commit
|
|
218
|
+
|
|
219
|
+
# Run linter
|
|
220
|
+
npm run lint
|
|
221
|
+
|
|
222
|
+
# Run tests
|
|
223
|
+
npm test
|
|
224
|
+
|
|
225
|
+
# Check for secrets
|
|
226
|
+
git diff --cached | grep -E "(API_KEY|SECRET|PASSWORD)" && exit 1
|
|
227
|
+
|
|
228
|
+
exit 0
|
|
229
|
+
```
|
|
230
|
+
|
|
231
|
+
### Pre-push Hook
|
|
232
|
+
|
|
233
|
+
Prevent direct pushes to main:
|
|
234
|
+
|
|
235
|
+
```bash
|
|
236
|
+
#!/bin/bash
|
|
237
|
+
# .git/hooks/pre-push
|
|
238
|
+
|
|
239
|
+
BRANCH=$(git rev-parse --abbrev-ref HEAD)
|
|
240
|
+
if [ "$BRANCH" = "main" ] || [ "$BRANCH" = "master" ]; then
|
|
241
|
+
echo "ERROR: Direct push to $BRANCH is not allowed"
|
|
242
|
+
echo "Please create a feature branch and submit a PR"
|
|
243
|
+
exit 1
|
|
244
|
+
fi
|
|
245
|
+
```
|
|
246
|
+
|
|
247
|
+
## Best Practices
|
|
248
|
+
|
|
249
|
+
### For Loki Mode Sessions
|
|
250
|
+
|
|
251
|
+
1. **Always enable branch protection in production**:
|
|
252
|
+
```bash
|
|
253
|
+
export LOKI_BRANCH_PROTECTION=true
|
|
254
|
+
```
|
|
255
|
+
|
|
256
|
+
2. **Review changes before merging**:
|
|
257
|
+
```bash
|
|
258
|
+
# Check PR diff
|
|
259
|
+
gh pr diff 123
|
|
260
|
+
|
|
261
|
+
# View commits
|
|
262
|
+
gh pr view 123 --web
|
|
263
|
+
```
|
|
264
|
+
|
|
265
|
+
3. **Use squash merge** to keep history clean:
|
|
266
|
+
```bash
|
|
267
|
+
gh pr merge 123 --squash
|
|
268
|
+
```
|
|
269
|
+
|
|
270
|
+
4. **Delete feature branches after merge**:
|
|
271
|
+
```bash
|
|
272
|
+
gh pr merge 123 --delete-branch
|
|
273
|
+
```
|
|
274
|
+
|
|
275
|
+
### For Development Teams
|
|
276
|
+
|
|
277
|
+
1. **Require PR reviews** (configure in GitHub repo settings)
|
|
278
|
+
2. **Enable status checks** (CI/CD must pass)
|
|
279
|
+
3. **Use CODEOWNERS** for automatic reviewers
|
|
280
|
+
4. **Enable branch protection rules** in GitHub
|
|
281
|
+
5. **Require signed commits** for audit trail
|
|
282
|
+
|
|
283
|
+
### For Audit Compliance
|
|
284
|
+
|
|
285
|
+
1. Enable audit logging to track all Git operations
|
|
286
|
+
2. Configure branch protection in repo settings
|
|
287
|
+
3. Require approval from CODEOWNERS
|
|
288
|
+
4. Enable commit signing (GPG)
|
|
289
|
+
5. Retain Git history (no force pushes)
|
|
290
|
+
|
|
291
|
+
## Integration with GitHub Actions
|
|
292
|
+
|
|
293
|
+
### Automatic PR Creation Workflow
|
|
294
|
+
|
|
295
|
+
```yaml
|
|
296
|
+
# .github/workflows/loki-pr.yml
|
|
297
|
+
name: Loki PR Creation
|
|
298
|
+
on:
|
|
299
|
+
push:
|
|
300
|
+
branches:
|
|
301
|
+
- 'loki/session-*'
|
|
302
|
+
|
|
303
|
+
jobs:
|
|
304
|
+
create-pr:
|
|
305
|
+
runs-on: ubuntu-latest
|
|
306
|
+
steps:
|
|
307
|
+
- uses: actions/checkout@v4
|
|
308
|
+
|
|
309
|
+
- name: Create Pull Request
|
|
310
|
+
run: |
|
|
311
|
+
gh pr create \
|
|
312
|
+
--title "Loki Mode session $(date +%Y-%m-%d)" \
|
|
313
|
+
--body-file .loki/session-summary.md \
|
|
314
|
+
--base main
|
|
315
|
+
env:
|
|
316
|
+
GITHUB_TOKEN: ${{ secrets.GITHUB_TOKEN }}
|
|
317
|
+
```
|
|
318
|
+
|
|
319
|
+
### Automatic Code Review
|
|
320
|
+
|
|
321
|
+
```yaml
|
|
322
|
+
# .github/workflows/loki-review.yml
|
|
323
|
+
name: Loki Code Review
|
|
324
|
+
on:
|
|
325
|
+
pull_request:
|
|
326
|
+
types: [opened, synchronize]
|
|
327
|
+
|
|
328
|
+
jobs:
|
|
329
|
+
review:
|
|
330
|
+
runs-on: ubuntu-latest
|
|
331
|
+
steps:
|
|
332
|
+
- uses: actions/checkout@v4
|
|
333
|
+
|
|
334
|
+
- uses: asklokesh/loki-mode@v5
|
|
335
|
+
with:
|
|
336
|
+
mode: review
|
|
337
|
+
github_token: ${{ secrets.GITHUB_TOKEN }}
|
|
338
|
+
env:
|
|
339
|
+
ANTHROPIC_API_KEY: ${{ secrets.ANTHROPIC_API_KEY }}
|
|
340
|
+
```
|
|
341
|
+
|
|
342
|
+
## Troubleshooting
|
|
343
|
+
|
|
344
|
+
### Branch Already Exists
|
|
345
|
+
|
|
346
|
+
```bash
|
|
347
|
+
# List existing Loki branches
|
|
348
|
+
git branch -a | grep loki/session
|
|
349
|
+
|
|
350
|
+
# Delete old session branch
|
|
351
|
+
git branch -D loki/session-20260214-120000-11111
|
|
352
|
+
|
|
353
|
+
# Or delete remote branch
|
|
354
|
+
git push origin --delete loki/session-20260214-120000-11111
|
|
355
|
+
```
|
|
356
|
+
|
|
357
|
+
### PR Creation Fails
|
|
358
|
+
|
|
359
|
+
```bash
|
|
360
|
+
# Check GitHub CLI is installed
|
|
361
|
+
gh --version
|
|
362
|
+
|
|
363
|
+
# Authenticate GitHub CLI
|
|
364
|
+
gh auth login
|
|
365
|
+
|
|
366
|
+
# Check repository permissions
|
|
367
|
+
gh repo view
|
|
368
|
+
|
|
369
|
+
# Manually create PR
|
|
370
|
+
gh pr create --title "My PR" --body "Description"
|
|
371
|
+
```
|
|
372
|
+
|
|
373
|
+
### Merge Conflicts
|
|
374
|
+
|
|
375
|
+
```bash
|
|
376
|
+
# Update feature branch with latest main
|
|
377
|
+
git checkout loki/session-20260215-143022-12345
|
|
378
|
+
git fetch origin
|
|
379
|
+
git merge origin/main
|
|
380
|
+
|
|
381
|
+
# Resolve conflicts
|
|
382
|
+
git status
|
|
383
|
+
# Edit conflicted files
|
|
384
|
+
git add .
|
|
385
|
+
git commit -m "Resolve merge conflicts"
|
|
386
|
+
|
|
387
|
+
# Push updated branch
|
|
388
|
+
git push origin loki/session-20260215-143022-12345
|
|
389
|
+
```
|
|
390
|
+
|
|
391
|
+
### Detached HEAD State
|
|
392
|
+
|
|
393
|
+
```bash
|
|
394
|
+
# Check current state
|
|
395
|
+
git status
|
|
396
|
+
|
|
397
|
+
# Return to feature branch
|
|
398
|
+
git checkout loki/session-20260215-143022-12345
|
|
399
|
+
|
|
400
|
+
# Or create new branch from current commit
|
|
401
|
+
git checkout -b loki/session-new
|
|
402
|
+
```
|
|
403
|
+
|
|
404
|
+
## Security
|
|
405
|
+
|
|
406
|
+
### Prevent Secrets in Commits
|
|
407
|
+
|
|
408
|
+
Use Git hooks or pre-commit framework:
|
|
409
|
+
|
|
410
|
+
```bash
|
|
411
|
+
# Install pre-commit
|
|
412
|
+
pip install pre-commit
|
|
413
|
+
|
|
414
|
+
# .pre-commit-config.yaml
|
|
415
|
+
repos:
|
|
416
|
+
- repo: https://github.com/pre-commit/pre-commit-hooks
|
|
417
|
+
hooks:
|
|
418
|
+
- id: detect-private-key
|
|
419
|
+
- id: detect-aws-credentials
|
|
420
|
+
- repo: https://github.com/Yelp/detect-secrets
|
|
421
|
+
hooks:
|
|
422
|
+
- id: detect-secrets
|
|
423
|
+
```
|
|
424
|
+
|
|
425
|
+
### Signed Commits
|
|
426
|
+
|
|
427
|
+
Require GPG-signed commits:
|
|
428
|
+
|
|
429
|
+
```bash
|
|
430
|
+
# Generate GPG key
|
|
431
|
+
gpg --gen-key
|
|
432
|
+
|
|
433
|
+
# Configure Git to sign commits
|
|
434
|
+
git config --global user.signingkey YOUR_KEY_ID
|
|
435
|
+
git config --global commit.gpgsign true
|
|
436
|
+
|
|
437
|
+
# Verify signature
|
|
438
|
+
git log --show-signature
|
|
439
|
+
```
|
|
440
|
+
|
|
441
|
+
## See Also
|
|
442
|
+
|
|
443
|
+
- [Audit Logging](audit-logging.md) - Track Git operations
|
|
444
|
+
- [GitHub Integration](../skills/github-integration.md) - Issue import and PR creation
|
|
445
|
+
- [Enterprise Features](../wiki/Enterprise-Features.md) - Branch protection setup
|
|
446
|
+
- [Contributing](../CONTRIBUTING.md) - Contribution guidelines
|