loki-mode 4.2.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 (54) hide show
  1. package/LICENSE +21 -0
  2. package/README.md +691 -0
  3. package/SKILL.md +191 -0
  4. package/VERSION +1 -0
  5. package/autonomy/.loki/dashboard/index.html +2634 -0
  6. package/autonomy/CONSTITUTION.md +508 -0
  7. package/autonomy/README.md +201 -0
  8. package/autonomy/config.example.yaml +152 -0
  9. package/autonomy/loki +526 -0
  10. package/autonomy/run.sh +3636 -0
  11. package/bin/loki-mode.js +26 -0
  12. package/bin/postinstall.js +60 -0
  13. package/docs/ACKNOWLEDGEMENTS.md +234 -0
  14. package/docs/COMPARISON.md +325 -0
  15. package/docs/COMPETITIVE-ANALYSIS.md +333 -0
  16. package/docs/INSTALLATION.md +547 -0
  17. package/docs/auto-claude-comparison.md +276 -0
  18. package/docs/cursor-comparison.md +225 -0
  19. package/docs/dashboard-guide.md +355 -0
  20. package/docs/screenshots/README.md +149 -0
  21. package/docs/screenshots/dashboard-agents.png +0 -0
  22. package/docs/screenshots/dashboard-tasks.png +0 -0
  23. package/docs/thick2thin.md +173 -0
  24. package/package.json +48 -0
  25. package/references/advanced-patterns.md +453 -0
  26. package/references/agent-types.md +243 -0
  27. package/references/agents.md +1043 -0
  28. package/references/business-ops.md +550 -0
  29. package/references/competitive-analysis.md +216 -0
  30. package/references/confidence-routing.md +371 -0
  31. package/references/core-workflow.md +275 -0
  32. package/references/cursor-learnings.md +207 -0
  33. package/references/deployment.md +604 -0
  34. package/references/lab-research-patterns.md +534 -0
  35. package/references/mcp-integration.md +186 -0
  36. package/references/memory-system.md +467 -0
  37. package/references/openai-patterns.md +647 -0
  38. package/references/production-patterns.md +568 -0
  39. package/references/prompt-repetition.md +192 -0
  40. package/references/quality-control.md +437 -0
  41. package/references/sdlc-phases.md +410 -0
  42. package/references/task-queue.md +361 -0
  43. package/references/tool-orchestration.md +691 -0
  44. package/skills/00-index.md +120 -0
  45. package/skills/agents.md +249 -0
  46. package/skills/artifacts.md +174 -0
  47. package/skills/github-integration.md +218 -0
  48. package/skills/model-selection.md +125 -0
  49. package/skills/parallel-workflows.md +526 -0
  50. package/skills/patterns-advanced.md +188 -0
  51. package/skills/production.md +292 -0
  52. package/skills/quality-gates.md +180 -0
  53. package/skills/testing.md +149 -0
  54. package/skills/troubleshooting.md +109 -0
@@ -0,0 +1,120 @@
1
+ # Skill Modules Index
2
+
3
+ **Load 1-3 modules based on your current task. Do not load all modules.**
4
+
5
+ > **Full documentation:** For comprehensive details, see `references/` directory:
6
+ > - `references/agents.md` - Complete 37 agent type specifications
7
+ > - `references/openai-patterns.md` - OpenAI Agents SDK patterns
8
+ > - `references/lab-research-patterns.md` - DeepMind + Anthropic research
9
+ > - `references/production-patterns.md` - HN 2025 production insights
10
+ > - `references/memory-system.md` - Episodic/semantic/procedural memory
11
+ > - `references/tool-orchestration.md` - NVIDIA ToolOrchestra efficiency metrics
12
+ > - `references/quality-control.md` - Code review and guardrails
13
+
14
+ ## Module Selection Rules
15
+
16
+ | If your task involves... | Load these modules |
17
+ |--------------------------|-------------------|
18
+ | Writing code, implementing features | `model-selection.md` |
19
+ | Running tests, E2E, Playwright | `testing.md` |
20
+ | Code review, quality checks | `quality-gates.md` |
21
+ | Deployment, CI/CD, infrastructure | `production.md` |
22
+ | Debugging, errors, failures | `troubleshooting.md` |
23
+ | Spawning subagents, Task tool | `model-selection.md`, `agents.md` |
24
+ | Architecture, design decisions | `patterns-advanced.md` |
25
+ | Generating artifacts, reports | `artifacts.md` |
26
+ | Parallel features, git worktrees | `parallel-workflows.md` |
27
+ | Scale patterns (50+ agents) | `parallel-workflows.md` + `references/cursor-learnings.md` |
28
+ | GitHub issues, PRs, syncing | `github-integration.md` |
29
+
30
+ ## Module Descriptions
31
+
32
+ ### model-selection.md
33
+ **When:** Spawning subagents, choosing models, parallelization
34
+ - Task tool parameters and examples
35
+ - Opus/Sonnet/Haiku usage patterns
36
+ - Extended thinking mode prefixes
37
+ - Prompt repetition for Haiku
38
+ - Background agents and resumption
39
+
40
+ ### quality-gates.md
41
+ **When:** Code review, pre-commit checks, quality assurance
42
+ - 7-gate quality system
43
+ - Blind review + anti-sycophancy
44
+ - Velocity-quality feedback loop (arXiv research)
45
+ - Mandatory quality checks per task
46
+ - Guardrails (input/output validation)
47
+
48
+ ### patterns-advanced.md
49
+ **When:** Architecture decisions, complex problem-solving
50
+ - OptiMind problem classification + expert hints
51
+ - Ensemble solution generation
52
+ - Formal state machines (k8s-valkey-operator)
53
+ - Constitutional AI self-critique
54
+ - Debate-based verification (DeepMind)
55
+
56
+ ### testing.md
57
+ **When:** Writing tests, E2E automation, verification
58
+ - Playwright MCP for browser testing
59
+ - Property-based testing (Kiro pattern)
60
+ - Unit/integration/E2E strategies
61
+ - Visual design input workflow
62
+
63
+ ### production.md
64
+ **When:** Deployment, CI/CD, production concerns
65
+ - HN 2025 production patterns
66
+ - Narrow scope, confidence-based routing
67
+ - Git worktree isolation (Cursor pattern)
68
+ - Atomic checkpoint/rollback
69
+ - CI/CD automation (Zencoder patterns)
70
+ - Context engineering and proactive compaction
71
+
72
+ ### troubleshooting.md
73
+ **When:** Errors, failures, debugging
74
+ - Common issues and solutions
75
+ - Red flags (never do these)
76
+ - Multi-tiered fallback system
77
+ - Rate limit handling
78
+ - Circuit breakers
79
+
80
+ ### agents.md
81
+ **When:** Understanding agent types, structured prompting
82
+ - 37 agent type overview
83
+ - Structured prompting format (GOAL/CONSTRAINTS/CONTEXT/OUTPUT)
84
+ - Agent handoffs and callbacks
85
+ - Routing mode optimization
86
+
87
+ ### artifacts.md
88
+ **When:** Generating reports, documentation, screenshots
89
+ - Artifact generation (Antigravity pattern)
90
+ - Code transformation (Amazon Q pattern)
91
+ - Phase completion reports
92
+ - Screenshot gallery generation
93
+
94
+ ### parallel-workflows.md
95
+ **When:** Running multiple features in parallel, worktree orchestration
96
+ - Git worktree-based isolation
97
+ - Parallel Claude sessions (feature, testing, docs streams)
98
+ - Inter-stream communication via signals
99
+ - Auto-merge completed features
100
+ - Orchestrator state management
101
+
102
+ ### github-integration.md (v4.1.0)
103
+ **When:** Working with GitHub issues, creating PRs, syncing status
104
+ - Import open issues as pending tasks
105
+ - Create PRs on feature completion
106
+ - Sync task status back to GitHub issues
107
+ - Filter by labels, milestone, assignee
108
+ - Requires `gh` CLI authenticated
109
+
110
+ ## How to Load
111
+
112
+ ```python
113
+ # Example: Before implementing a feature with tests
114
+ # 1. Read this index
115
+ # 2. Decide: need model-selection.md + testing.md
116
+ # 3. Read those files
117
+ # 4. Execute with loaded context
118
+ ```
119
+
120
+ **Remember:** Loading fewer modules = more context for actual work.
@@ -0,0 +1,249 @@
1
+ # Agent Dispatch & Structured Prompting
2
+
3
+ > **Full agent type definitions:** See `references/agents.md` for complete 37 agent role specifications across 7 swarms (Engineering, Operations, Business, Data, Product, Growth, Review).
4
+
5
+ ---
6
+
7
+ ## How Agents Actually Work
8
+
9
+ **Claude Code's Task tool has these subagent_types:**
10
+ - `general-purpose` - Most work (implementation, review, testing)
11
+ - `Explore` - Codebase exploration and search
12
+ - `Plan` - Architecture and planning
13
+ - `Bash` - Command execution
14
+ - `platform-orchestrator` - Deployment and service management
15
+
16
+ **The 37 agent types are ROLES defined through prompts.** Create specialized behavior:
17
+
18
+ ```python
19
+ # Security reviewer = general-purpose + security-focused prompt
20
+ Task(
21
+ subagent_type="general-purpose",
22
+ model="opus",
23
+ description="Security review: auth module",
24
+ prompt="""You are a security reviewer. Focus on:
25
+ - Authentication vulnerabilities
26
+ - Input validation gaps
27
+ - OWASP Top 10 issues
28
+ Review: src/auth/*.ts"""
29
+ )
30
+
31
+ # Frontend agent = general-purpose + frontend-focused prompt
32
+ Task(
33
+ subagent_type="general-purpose",
34
+ model="opus",
35
+ description="Implement login form",
36
+ prompt="""You are a frontend developer. Implement:
37
+ - React login form component
38
+ - Form validation
39
+ - Error state handling"""
40
+ )
41
+ ```
42
+
43
+ ---
44
+
45
+ ## Structured Prompting Template
46
+
47
+ **Every Task dispatch MUST include these sections:**
48
+
49
+ ```
50
+ ## GOAL
51
+ [What success looks like - measurable outcome]
52
+
53
+ ## CONSTRAINTS
54
+ [Hard limits - what you cannot do]
55
+
56
+ ## CONTEXT
57
+ [Files to read, previous attempts, related decisions]
58
+
59
+ ## OUTPUT
60
+ [Exact deliverables expected]
61
+ ```
62
+
63
+ **Example:**
64
+ ```python
65
+ Task(
66
+ subagent_type="general-purpose",
67
+ model="opus",
68
+ description="Implement user registration API",
69
+ prompt="""
70
+ ## GOAL
71
+ Create POST /api/users endpoint that registers new users.
72
+ Success: Endpoint works, tests pass, matches OpenAPI spec.
73
+
74
+ ## CONSTRAINTS
75
+ - Use bcrypt for password hashing (already in dependencies)
76
+ - No new dependencies without approval
77
+ - Response time < 200ms
78
+
79
+ ## CONTEXT
80
+ - Existing auth pattern: src/auth/login.ts
81
+ - OpenAPI spec: .loki/specs/openapi.yaml
82
+ - User model: src/models/user.ts
83
+
84
+ ## OUTPUT
85
+ - [ ] Endpoint implementation in src/routes/users.ts
86
+ - [ ] Unit tests in tests/users.test.ts
87
+ - [ ] Integration test in tests/integration/users.test.ts
88
+ """
89
+ )
90
+ ```
91
+
92
+ ---
93
+
94
+ ## Parallel Review Pattern
95
+
96
+ **Code review uses 3 parallel reviewers with different focus areas:**
97
+
98
+ ```python
99
+ # Launch all 3 in ONE message (parallel execution)
100
+ Task(
101
+ subagent_type="general-purpose",
102
+ model="opus",
103
+ description="Review: correctness",
104
+ prompt="Review for bugs, logic errors, edge cases. Files: {files}"
105
+ )
106
+ Task(
107
+ subagent_type="general-purpose",
108
+ model="opus",
109
+ description="Review: security",
110
+ prompt="Review for vulnerabilities, injection, auth issues. Files: {files}"
111
+ )
112
+ Task(
113
+ subagent_type="general-purpose",
114
+ model="opus",
115
+ description="Review: performance",
116
+ prompt="Review for N+1 queries, memory leaks, slow operations. Files: {files}"
117
+ )
118
+ ```
119
+
120
+ **Rules:**
121
+ - ALWAYS use opus for reviews
122
+ - ALWAYS launch all 3 in single message
123
+ - WAIT for all 3 before aggregating
124
+ - IF unanimous approval: run Devil's Advocate reviewer
125
+
126
+ ---
127
+
128
+ ## Confidence-Based Routing
129
+
130
+ | Confidence | Dispatch Strategy |
131
+ |------------|-------------------|
132
+ | >= 0.95 | Direct haiku execution, no review |
133
+ | 0.70-0.95 | Direct execution + async review |
134
+ | 0.40-0.70 | Supervisor orchestration, mandatory review |
135
+ | < 0.40 | Flag for human decision |
136
+
137
+ **Confidence factors:**
138
+ - Requirement clarity (30%)
139
+ - Similar past successes (20%)
140
+ - Technical complexity match (25%)
141
+ - Resource availability (15%)
142
+ - Time pressure (10%)
143
+
144
+ ---
145
+
146
+ ## Agent Handoffs
147
+
148
+ When one agent completes and hands off to another:
149
+
150
+ ```python
151
+ # Agent A completes, hands off to Agent B
152
+ handoff_data = {
153
+ "completed_work": "Implemented user registration endpoint",
154
+ "files_modified": ["src/routes/users.ts", "tests/users.test.ts"],
155
+ "decisions_made": ["Used bcrypt, not argon2", "Email validation via regex"],
156
+ "open_questions": ["Rate limiting not implemented yet"],
157
+ "mistakes_learned": ["First attempt had SQL injection - fixed"]
158
+ }
159
+
160
+ Task(
161
+ subagent_type="general-purpose",
162
+ model="sonnet",
163
+ description="Integration testing for user registration",
164
+ prompt=f"Previous agent completed: {handoff_data}. Now write integration tests..."
165
+ )
166
+ ```
167
+
168
+ ---
169
+
170
+ ## Project AGENTS.md
171
+
172
+ **IF target project has AGENTS.md, read it first.** (OpenAI/AAIF standard)
173
+
174
+ Priority order for context:
175
+ 1. `AGENTS.md` in current directory
176
+ 2. `CLAUDE.md` project instructions
177
+ 3. `.loki/CONTINUITY.md` session state
178
+
179
+ ---
180
+
181
+ ## A2A-Inspired Communication (Google Protocol)
182
+
183
+ **Agent Cards for capability discovery:**
184
+
185
+ ```json
186
+ {
187
+ "agent_id": "eng-backend-001",
188
+ "capabilities": ["api-endpoint", "auth", "database"],
189
+ "status": "available",
190
+ "current_task": null,
191
+ "inbox": ".loki/messages/inbox/eng-backend-001/",
192
+ "outbox": ".loki/messages/outbox/eng-backend-001/"
193
+ }
194
+ ```
195
+
196
+ **Handoff message format:**
197
+
198
+ ```json
199
+ {
200
+ "from": "eng-backend-001",
201
+ "to": "eng-qa-001",
202
+ "task_id": "task-123",
203
+ "type": "handoff",
204
+ "payload": {
205
+ "completed_work": "POST /api/users implemented",
206
+ "files_modified": ["src/routes/users.ts"],
207
+ "decisions": ["bcrypt for passwords"],
208
+ "artifacts": [".loki/artifacts/users-api-spec.json"]
209
+ }
210
+ }
211
+ ```
212
+
213
+ **Location:** `.loki/messages/` directory structure
214
+
215
+ ---
216
+
217
+ ## Agentic Patterns Reference (awesome-agentic-patterns)
218
+
219
+ **Patterns used in Loki Mode:**
220
+
221
+ | Pattern | Implementation |
222
+ |---------|---------------|
223
+ | Sub-Agent Spawning | Task tool with focused prompts |
224
+ | Plan-Then-Execute | Architect -> Engineer workflow |
225
+ | Dual LLM | Opus for planning, Haiku for execution |
226
+ | CI Feedback Loop | Test results injected into retry prompts |
227
+ | Self-Critique | Constitutional AI revision cycle |
228
+ | Semantic Context Filtering | Only relevant files in context |
229
+ | Episodic Memory | `.loki/memory/episodic/` traces |
230
+
231
+ **Key insight (moridinamael.github.io):** Simple orchestration beats complex frameworks. "Ralph Wiggum Mode" - basic continuation prompts work better than elaborate coordination systems.
232
+
233
+ ---
234
+
235
+ ## The 37 Agent Roles
236
+
237
+ See `references/agents.md` for complete specifications. Summary:
238
+
239
+ | Swarm | Agent Types | Count |
240
+ |-------|-------------|-------|
241
+ | Engineering | frontend, backend, database, mobile, api, qa, perf, infra | 8 |
242
+ | Operations | devops, sre, security, monitor, incident, release, cost, compliance | 8 |
243
+ | Business | marketing, sales, finance, legal, support, hr, investor, partnerships | 8 |
244
+ | Data | ml, eng, analytics | 3 |
245
+ | Product | pm, design, techwriter | 3 |
246
+ | Growth | hacker, community, success, lifecycle | 4 |
247
+ | Review | code, business, security | 3 |
248
+
249
+ **Spawn only what you need.** Simple project: 5-10 agents. Complex startup: 100+.
@@ -0,0 +1,174 @@
1
+ # Artifact Generation & Code Transformation
2
+
3
+ ## Artifact Generation (Antigravity Pattern)
4
+
5
+ **Auto-generate verifiable deliverables for audit trail without human intervention.**
6
+
7
+ ```yaml
8
+ artifact_generation:
9
+ purpose: "Prove autonomous work without line-by-line code review"
10
+ location: ".loki/artifacts/{date}/{phase}/"
11
+
12
+ triggers:
13
+ on_phase_complete:
14
+ - verification_report: "Summary of tests passed, coverage, static analysis"
15
+ - architecture_diff: "Mermaid diagram showing changes from previous state"
16
+ - decision_log: "Key decisions made with rationale (from CONTINUITY.md)"
17
+
18
+ on_feature_complete:
19
+ - screenshot: "Key UI states captured via Playwright"
20
+ - api_diff: "OpenAPI spec changes highlighted"
21
+ - test_summary: "Unit, integration, E2E results"
22
+
23
+ on_deployment:
24
+ - release_notes: "Auto-generated from commit history"
25
+ - rollback_plan: "Steps to revert if issues detected"
26
+ - monitoring_baseline: "Expected metrics post-deploy"
27
+ ```
28
+
29
+ ---
30
+
31
+ ## Artifact Types
32
+
33
+ ### Verification Report
34
+ ```yaml
35
+ format: "markdown"
36
+ contents:
37
+ - Phase name and duration
38
+ - Tasks completed (from queue)
39
+ - Quality gate results (7 gates)
40
+ - Coverage metrics
41
+ - Known issues / TODOs
42
+ ```
43
+
44
+ ### Architecture Diff
45
+ ```yaml
46
+ format: "mermaid diagram"
47
+ contents:
48
+ - Components added/modified/removed
49
+ - Dependency changes
50
+ - Data flow changes
51
+ ```
52
+
53
+ ### Screenshot Gallery
54
+ ```yaml
55
+ format: "png + markdown index"
56
+ capture:
57
+ - Critical user flows
58
+ - Error states
59
+ - Before/after comparisons
60
+ ```
61
+
62
+ **Why artifacts matter for autonomous operation:**
63
+ - Creates audit trail without human during execution
64
+ - Enables async human review if needed later
65
+ - Proves work quality through outcomes, not code inspection
66
+ - Aligns with "outcome verification" over "line-by-line auditing"
67
+
68
+ ---
69
+
70
+ ## Code Transformation Agent (Amazon Q Pattern)
71
+
72
+ **Dedicated workflows for legacy modernization - narrow scope, deterministic verification.**
73
+
74
+ ```yaml
75
+ transformation_agent:
76
+ purpose: "Autonomous code migration without human intervention"
77
+ trigger: "/transform or PRD mentions migration/upgrade/modernization"
78
+
79
+ workflows:
80
+ language_upgrade:
81
+ steps:
82
+ 1. Analyze current version and dependencies
83
+ 2. Identify deprecated APIs and breaking changes
84
+ 3. Generate migration plan with risk assessment
85
+ 4. Apply transformations incrementally
86
+ 5. Run compatibility tests after each change
87
+ 6. Validate performance benchmarks
88
+ examples:
89
+ - "Java 8 to Java 21"
90
+ - "Python 2 to Python 3"
91
+ - "Node 16 to Node 22"
92
+
93
+ database_migration:
94
+ steps:
95
+ 1. Schema diff analysis (source vs target)
96
+ 2. SQL dialect conversion rules
97
+ 3. Data type mapping
98
+ 4. Generate migration scripts
99
+ 5. Run verification queries
100
+ 6. Validate data integrity
101
+ examples:
102
+ - "Oracle to PostgreSQL"
103
+ - "MySQL to PostgreSQL"
104
+ - "MongoDB to PostgreSQL"
105
+
106
+ framework_modernization:
107
+ steps:
108
+ 1. Dependency audit and compatibility matrix
109
+ 2. Breaking change detection
110
+ 3. Code pattern updates (deprecated -> modern)
111
+ 4. Test suite adaptation
112
+ 5. Performance regression testing
113
+ examples:
114
+ - "Angular to React"
115
+ - ".NET Framework to .NET Core"
116
+ - "Express to Fastify"
117
+
118
+ success_criteria:
119
+ - All existing tests pass
120
+ - No regression in performance (< 5% degradation)
121
+ - Static analysis clean
122
+ - API compatibility maintained (or documented breaks)
123
+ ```
124
+
125
+ **Why this fits autonomous operation:**
126
+ - Narrow scope with clear boundaries
127
+ - Deterministic success criteria (tests pass, benchmarks met)
128
+ - No subjective judgment required
129
+ - High value, repetitive tasks
130
+
131
+ ---
132
+
133
+ ## Code-Only Agent Pattern (rijnard.com)
134
+
135
+ **Enforce execution through code, creating verifiable "code witnesses".**
136
+
137
+ ```yaml
138
+ code_only_principle:
139
+ benefit: "Produces executable, verifiable behavior traces"
140
+
141
+ patterns:
142
+ - Return small outputs (<1KB) inline
143
+ - Write large results to JSON files with path references
144
+ - Use dynamic languages (Python, TypeScript) for native runtime injection
145
+
146
+ enforcement:
147
+ - Tool PreHooks to catch banned operations
148
+ - Initial prompting toward code-generation patterns
149
+ ```
150
+
151
+ **Key Insight:** LLM outputs should be executable code, not prose descriptions. This creates an auditable trace of what actually happened.
152
+
153
+ ---
154
+
155
+ ## Release Notes Generation
156
+
157
+ **Auto-generate from commit history:**
158
+
159
+ ```bash
160
+ # Generate release notes from git commits
161
+ git log --oneline v2.0.0..HEAD | \
162
+ grep -E "^[a-f0-9]+ (feat|fix|perf|refactor):" | \
163
+ sed 's/^[a-f0-9]* /- /'
164
+ ```
165
+
166
+ ```yaml
167
+ release_notes_template:
168
+ sections:
169
+ - "## New Features" (feat: commits)
170
+ - "## Bug Fixes" (fix: commits)
171
+ - "## Performance" (perf: commits)
172
+ - "## Breaking Changes" (BREAKING: in commit body)
173
+ - "## Migration Guide" (if breaking changes)
174
+ ```