loki-mode 5.17.0 → 5.19.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 +62 -10
- package/SKILL.md +2 -2
- package/VERSION +1 -1
- package/api/middleware/error.ts +29 -1
- package/api/middleware/timing.ts +135 -0
- package/api/openapi.yaml +590 -0
- package/api/routes/health.ts +133 -1
- package/api/routes/learning.ts +482 -0
- package/api/routes/learning_test.ts +456 -0
- package/api/routes/memory.ts +526 -16
- package/api/routes/sessions.ts +56 -0
- package/api/server.ts +62 -0
- package/api/server_test.ts +93 -0
- package/api/services/cli-bridge.ts +27 -19
- package/api/services/learning-collector.ts +792 -0
- package/api/services/learning-collector_test.ts +468 -0
- package/api/services/state-notifications.ts +421 -0
- package/api/services/state-watcher.ts +68 -52
- package/api/types/memory.ts +62 -0
- package/autonomy/loki +503 -0
- package/autonomy/run.sh +239 -18
- package/docs/SYNERGY-TASKS.md +138 -0
- package/docs/loki-mode-presentation.pptx +0 -0
- package/memory/__init__.py +61 -1
- package/memory/embeddings.py +1065 -145
- package/memory/namespace.py +552 -0
- package/memory/retrieval.py +517 -7
- package/memory/schemas.py +80 -1
- package/memory/storage.py +505 -5
- package/memory/test_importance.py +352 -0
- package/memory/tests/test_namespace.py +538 -0
- package/memory/token_economics.py +156 -0
- package/memory/unified_access.py +591 -0
- package/package.json +13 -3
- package/references/agent-types.md +2 -2
- package/references/agents.md +1 -1
- package/skills/00-index.md +2 -2
- package/skills/agents.md +2 -2
package/README.md
CHANGED
|
@@ -3,7 +3,7 @@
|
|
|
3
3
|
**The First Truly Autonomous Multi-Agent Startup System**
|
|
4
4
|
|
|
5
5
|
[](https://claude.ai)
|
|
6
|
-
[]()
|
|
7
7
|
[](benchmarks/results/)
|
|
8
8
|
[](benchmarks/results/)
|
|
9
9
|
[](benchmarks/results/)
|
|
@@ -29,7 +29,7 @@
|
|
|
29
29
|
|
|
30
30
|

|
|
31
31
|
|
|
32
|
-
*9 slides: Problem, Solution,
|
|
32
|
+
*9 slides: Problem, Solution, 41 Agents, RARV Cycle, Benchmarks, Multi-Provider, Full Lifecycle*
|
|
33
33
|
|
|
34
34
|
**[Download PPTX](docs/loki-mode-presentation.pptx)** for offline viewing
|
|
35
35
|
|
|
@@ -172,7 +172,7 @@ See [benchmarks/results/](benchmarks/results/) for full methodology and solution
|
|
|
172
172
|
|
|
173
173
|
## What is Loki Mode?
|
|
174
174
|
|
|
175
|
-
Loki Mode is a multi-provider AI skill that orchestrates **
|
|
175
|
+
Loki Mode is a multi-provider AI skill that orchestrates **41 specialized AI agent types** across **7 swarms** to autonomously build, test, deploy, and scale complete startups. Works with **Claude Code**, **OpenAI Codex CLI**, and **Google Gemini CLI**. It dynamically spawns only the agents you need—**5-10 for simple projects, 100+ for complex startups**—working in parallel with continuous self-verification.
|
|
176
176
|
|
|
177
177
|
```
|
|
178
178
|
PRD → Research → Architecture → Development → Testing → Deployment → Marketing → Revenue
|
|
@@ -190,7 +190,7 @@ PRD → Research → Architecture → Development → Testing → Deployment →
|
|
|
190
190
|
|----------------|---------------------|
|
|
191
191
|
| **Single agent** writes code linearly | **100+ agents** work in parallel across engineering, ops, business, data, product, and growth |
|
|
192
192
|
| **Manual deployment** required | **Autonomous deployment** to AWS, GCP, Azure, Vercel, Railway with blue-green and canary strategies |
|
|
193
|
-
| **No testing** or basic unit tests | **
|
|
193
|
+
| **No testing** or basic unit tests | **7 automated quality gates**: input/output guardrails, static analysis, blind review, anti-sycophancy, severity blocking, test coverage |
|
|
194
194
|
| **Code only** - you handle the rest | **Full business operations**: marketing, sales, legal, HR, finance, investor relations |
|
|
195
195
|
| **Stops on errors** | **Self-healing**: circuit breakers, dead letter queues, exponential backoff, automatic recovery |
|
|
196
196
|
| **No visibility** into progress | **Real-time dashboard** with agent monitoring, task queues, and live status updates |
|
|
@@ -216,9 +216,9 @@ PRD → Research → Architecture → Development → Testing → Deployment →
|
|
|
216
216
|
| **CLI (v4.1.0)** | `loki` command for start/stop/pause/status | [CLI Commands](#cli-commands-v410) |
|
|
217
217
|
| **Config Files** | YAML configuration support | [autonomy/config.example.yaml](autonomy/config.example.yaml) |
|
|
218
218
|
| **Dashboard** | Realtime Kanban board, agent monitoring | [Dashboard Guide](docs/dashboard-guide.md) |
|
|
219
|
-
| **
|
|
219
|
+
| **41 Agent Types** | Engineering, Ops, Business, Data, Product, Growth, Orchestration | [Agent Definitions](references/agent-types.md) |
|
|
220
220
|
| **RARV Cycle** | Reason-Act-Reflect-Verify workflow | [Core Workflow](references/core-workflow.md) |
|
|
221
|
-
| **Quality Gates** | 7-gate
|
|
221
|
+
| **Quality Gates** | 7-gate system: guardrails, static analysis, blind review, anti-sycophancy, severity blocking, test coverage | [Quality Control](references/quality-control.md) |
|
|
222
222
|
| **Memory System (v5.15.0)** | Complete 3-tier memory with progressive disclosure | [Memory Architecture](references/memory-system.md) |
|
|
223
223
|
| **Parallel Workflows** | Git worktree-based parallelism | [Parallel Workflows](skills/parallel-workflows.md) |
|
|
224
224
|
| **GitHub Integration** | Issue import, PR creation, status sync | [GitHub Integration](skills/github-integration.md) |
|
|
@@ -477,9 +477,9 @@ Config search order: `.loki/config.yaml` (project) -> `~/.config/loki-mode/confi
|
|
|
477
477
|
|
|
478
478
|
---
|
|
479
479
|
|
|
480
|
-
## Agent Swarms (
|
|
480
|
+
## Agent Swarms (41 Types)
|
|
481
481
|
|
|
482
|
-
Loki Mode has **
|
|
482
|
+
Loki Mode has **41 predefined agent types** organized into **7 specialized swarms**. The orchestrator spawns only what you need—simple projects use 5-10 agents, complex startups spawn 100+.
|
|
483
483
|
|
|
484
484
|
<img width="5309" height="979" alt="Agent Swarms Visualization" src="https://github.com/user-attachments/assets/7d18635d-a606-401f-8d9f-430e6e4ee689" />
|
|
485
485
|
|
|
@@ -504,7 +504,59 @@ Loki Mode has **37 predefined agent types** organized into **6 specialized swarm
|
|
|
504
504
|
### **Review (3 types)**
|
|
505
505
|
`review-code` `review-business` `review-security`
|
|
506
506
|
|
|
507
|
-
|
|
507
|
+
### **Orchestration (4 types)**
|
|
508
|
+
`orch-planner` `orch-sub-planner` `orch-judge` `orch-coordinator`
|
|
509
|
+
|
|
510
|
+
<details>
|
|
511
|
+
<summary><strong>View All 41 Agent Types with Capabilities</strong></summary>
|
|
512
|
+
|
|
513
|
+
| Swarm | Agent | Capabilities |
|
|
514
|
+
|-------|-------|--------------|
|
|
515
|
+
| **Engineering** | `eng-frontend` | React/Vue/Svelte, TypeScript, Tailwind, accessibility, responsive design |
|
|
516
|
+
| | `eng-backend` | Node/Python/Go, REST/GraphQL, auth, business logic, middleware |
|
|
517
|
+
| | `eng-database` | PostgreSQL/MySQL/MongoDB, migrations, query optimization, indexing |
|
|
518
|
+
| | `eng-mobile` | React Native/Flutter/Swift/Kotlin, offline-first, push notifications |
|
|
519
|
+
| | `eng-api` | OpenAPI specs, SDK generation, versioning, webhooks, rate limiting |
|
|
520
|
+
| | `eng-qa` | Unit/integration/E2E tests, coverage, automation, test data |
|
|
521
|
+
| | `eng-perf` | Profiling, benchmarking, optimization, caching, load testing |
|
|
522
|
+
| | `eng-infra` | Docker, K8s manifests, IaC, networking, security hardening |
|
|
523
|
+
| **Operations** | `ops-devops` | CI/CD pipelines, GitHub Actions, GitLab CI, Jenkins |
|
|
524
|
+
| | `ops-sre` | Reliability, SLOs/SLIs, capacity planning, runbooks |
|
|
525
|
+
| | `ops-security` | SAST/DAST, pen testing, vulnerability management |
|
|
526
|
+
| | `ops-monitor` | Observability, Datadog/Grafana, alerting, dashboards |
|
|
527
|
+
| | `ops-incident` | Incident response, RCA, post-mortems, communication |
|
|
528
|
+
| | `ops-release` | Versioning, changelogs, blue-green, canary, rollbacks |
|
|
529
|
+
| | `ops-cost` | Cloud cost optimization, right-sizing, FinOps |
|
|
530
|
+
| | `ops-compliance` | SOC2, GDPR, HIPAA, PCI-DSS, audit preparation |
|
|
531
|
+
| **Business** | `biz-marketing` | Landing pages, SEO, content, email campaigns, social media |
|
|
532
|
+
| | `biz-sales` | CRM setup, outreach, demos, proposals, pipeline |
|
|
533
|
+
| | `biz-finance` | Billing (Stripe), invoicing, metrics, runway, pricing |
|
|
534
|
+
| | `biz-legal` | ToS, privacy policy, contracts, IP protection |
|
|
535
|
+
| | `biz-support` | Help docs, FAQs, ticket system, chatbot, knowledge base |
|
|
536
|
+
| | `biz-hr` | Job posts, recruiting, onboarding, culture docs |
|
|
537
|
+
| | `biz-investor` | Pitch decks, investor updates, data room, cap table |
|
|
538
|
+
| | `biz-partnerships` | BD outreach, integrations, co-marketing, API partnerships |
|
|
539
|
+
| **Data** | `data-ml` | Model training, MLOps, feature engineering, inference |
|
|
540
|
+
| | `data-eng` | ETL pipelines, data warehousing, dbt, Airflow |
|
|
541
|
+
| | `data-analytics` | Product analytics, A/B tests, dashboards, insights |
|
|
542
|
+
| **Product** | `prod-pm` | Backlog grooming, prioritization, roadmap, specs |
|
|
543
|
+
| | `prod-design` | Design system, Figma, UX patterns, prototypes |
|
|
544
|
+
| | `prod-techwriter` | API docs, guides, tutorials, release notes |
|
|
545
|
+
| **Growth** | `growth-hacker` | Growth experiments, viral loops, referral programs |
|
|
546
|
+
| | `growth-community` | Community building, Discord/Slack, ambassador programs |
|
|
547
|
+
| | `growth-success` | Customer success, health scoring, churn prevention |
|
|
548
|
+
| | `growth-lifecycle` | Email lifecycle, in-app messaging, re-engagement |
|
|
549
|
+
| **Review** | `review-code` | Code quality, design patterns, SOLID, maintainability |
|
|
550
|
+
| | `review-business` | Requirements alignment, business logic, edge cases |
|
|
551
|
+
| | `review-security` | Vulnerabilities, auth/authz, OWASP Top 10 |
|
|
552
|
+
| **Orchestration** | `orch-planner` | Task decomposition, dependency analysis, work distribution |
|
|
553
|
+
| | `orch-sub-planner` | Domain-specific planning, recursive task breakdown |
|
|
554
|
+
| | `orch-judge` | Cycle continuation decisions, goal assessment, escalation |
|
|
555
|
+
| | `orch-coordinator` | Cross-stream coordination, merge decisions, conflict resolution |
|
|
556
|
+
|
|
557
|
+
</details>
|
|
558
|
+
|
|
559
|
+
See [references/agent-types.md](references/agent-types.md) for complete agent type definitions.
|
|
508
560
|
|
|
509
561
|
---
|
|
510
562
|
|
|
@@ -543,7 +595,7 @@ references/ # Deep documentation (23KB+ files)
|
|
|
543
595
|
| **2. Architecture** | Tech stack selection with self-reflection |
|
|
544
596
|
| **3. Infrastructure** | Provision cloud, CI/CD, monitoring |
|
|
545
597
|
| **4. Development** | Implement with TDD, parallel code review |
|
|
546
|
-
| **5. QA** |
|
|
598
|
+
| **5. QA** | 7 quality gates, security audit, load testing |
|
|
547
599
|
| **6. Deployment** | Blue-green deploy, auto-rollback on errors |
|
|
548
600
|
| **7. Business** | Marketing, sales, legal, support setup |
|
|
549
601
|
| **8. Growth** | Continuous optimization, A/B testing, feedback loops |
|
package/SKILL.md
CHANGED
|
@@ -3,7 +3,7 @@ name: loki-mode
|
|
|
3
3
|
description: Multi-agent autonomous startup system. Triggers on "Loki Mode". Takes PRD to deployed product with zero human intervention. Requires --dangerously-skip-permissions flag.
|
|
4
4
|
---
|
|
5
5
|
|
|
6
|
-
# Loki Mode v5.
|
|
6
|
+
# Loki Mode v5.19.0
|
|
7
7
|
|
|
8
8
|
**You are an autonomous agent. You make decisions. You do not ask questions. You do not stop.**
|
|
9
9
|
|
|
@@ -253,4 +253,4 @@ Auto-detected or force with `LOKI_COMPLEXITY`:
|
|
|
253
253
|
|
|
254
254
|
---
|
|
255
255
|
|
|
256
|
-
**v5.
|
|
256
|
+
**v5.19.0 | Complete Synergy, Learning System, Swarm Intelligence | ~250 lines core**
|
package/VERSION
CHANGED
|
@@ -1 +1 @@
|
|
|
1
|
-
5.
|
|
1
|
+
5.19.0
|
package/api/middleware/error.ts
CHANGED
|
@@ -2,9 +2,11 @@
|
|
|
2
2
|
* Error Handling Middleware
|
|
3
3
|
*
|
|
4
4
|
* Provides consistent error responses and logging.
|
|
5
|
+
* Emits ErrorPatternSignal for learning from API errors.
|
|
5
6
|
*/
|
|
6
7
|
|
|
7
8
|
import type { ApiError } from "../types/api.ts";
|
|
9
|
+
import { learningCollector } from "../services/learning-collector.ts";
|
|
8
10
|
|
|
9
11
|
// Error codes
|
|
10
12
|
export const ErrorCodes = {
|
|
@@ -105,7 +107,8 @@ export function errorMiddleware(
|
|
|
105
107
|
}
|
|
106
108
|
|
|
107
109
|
/**
|
|
108
|
-
* Handle an error and return appropriate response
|
|
110
|
+
* Handle an error and return appropriate response.
|
|
111
|
+
* Also emits an ErrorPatternSignal for learning.
|
|
109
112
|
*/
|
|
110
113
|
export function handleError(err: unknown, req?: Request): Response {
|
|
111
114
|
// Log error for debugging
|
|
@@ -115,6 +118,31 @@ export function handleError(err: unknown, req?: Request): Response {
|
|
|
115
118
|
|
|
116
119
|
console.error(`Error handling ${requestInfo}:`, err);
|
|
117
120
|
|
|
121
|
+
// Emit error pattern signal for learning
|
|
122
|
+
const errorType = err instanceof LokiApiError
|
|
123
|
+
? err.code
|
|
124
|
+
: err instanceof Error
|
|
125
|
+
? err.name
|
|
126
|
+
: "UnknownError";
|
|
127
|
+
const errorMessage = err instanceof Error
|
|
128
|
+
? err.message
|
|
129
|
+
: "An unexpected error occurred";
|
|
130
|
+
|
|
131
|
+
learningCollector.emitErrorPattern(
|
|
132
|
+
requestInfo,
|
|
133
|
+
errorType,
|
|
134
|
+
errorMessage,
|
|
135
|
+
{
|
|
136
|
+
stackTrace: err instanceof Error ? err.stack : undefined,
|
|
137
|
+
context: {
|
|
138
|
+
method: req?.method,
|
|
139
|
+
path: req ? new URL(req.url).pathname : undefined,
|
|
140
|
+
errorCode: err instanceof LokiApiError ? err.code : undefined,
|
|
141
|
+
statusCode: err instanceof LokiApiError ? err.status : 500,
|
|
142
|
+
},
|
|
143
|
+
}
|
|
144
|
+
);
|
|
145
|
+
|
|
118
146
|
// Handle known API errors
|
|
119
147
|
if (err instanceof LokiApiError) {
|
|
120
148
|
return err.toResponse();
|
|
@@ -0,0 +1,135 @@
|
|
|
1
|
+
/**
|
|
2
|
+
* Timing Middleware
|
|
3
|
+
*
|
|
4
|
+
* Tracks API request timing and emits learning signals for efficiency tracking.
|
|
5
|
+
*/
|
|
6
|
+
|
|
7
|
+
import { learningCollector } from "../services/learning-collector.ts";
|
|
8
|
+
|
|
9
|
+
/**
|
|
10
|
+
* Request timing context
|
|
11
|
+
*/
|
|
12
|
+
export interface TimingContext {
|
|
13
|
+
startTime: number;
|
|
14
|
+
method: string;
|
|
15
|
+
path: string;
|
|
16
|
+
}
|
|
17
|
+
|
|
18
|
+
/**
|
|
19
|
+
* Create timing middleware that wraps handlers to track response times.
|
|
20
|
+
*
|
|
21
|
+
* Emits ToolEfficiencySignal for each request with timing data.
|
|
22
|
+
*/
|
|
23
|
+
export function timingMiddleware(
|
|
24
|
+
handler: (req: Request) => Promise<Response> | Response
|
|
25
|
+
): (req: Request) => Promise<Response> {
|
|
26
|
+
return async (req: Request): Promise<Response> => {
|
|
27
|
+
const startTime = Date.now();
|
|
28
|
+
const url = new URL(req.url);
|
|
29
|
+
const method = req.method;
|
|
30
|
+
const path = url.pathname;
|
|
31
|
+
|
|
32
|
+
try {
|
|
33
|
+
const response = await handler(req);
|
|
34
|
+
const duration = Date.now() - startTime;
|
|
35
|
+
|
|
36
|
+
// Emit success signal for non-error responses
|
|
37
|
+
if (response.status < 400) {
|
|
38
|
+
learningCollector.emitApiRequest(path, method, startTime, true, {
|
|
39
|
+
statusCode: response.status,
|
|
40
|
+
context: {
|
|
41
|
+
durationMs: duration,
|
|
42
|
+
},
|
|
43
|
+
});
|
|
44
|
+
} else {
|
|
45
|
+
// Clone response to read body for error details
|
|
46
|
+
const clonedResponse = response.clone();
|
|
47
|
+
let errorMessage = "Request failed";
|
|
48
|
+
try {
|
|
49
|
+
const body = await clonedResponse.json();
|
|
50
|
+
errorMessage = body.error || body.message || errorMessage;
|
|
51
|
+
} catch {
|
|
52
|
+
// Body might not be JSON
|
|
53
|
+
}
|
|
54
|
+
|
|
55
|
+
learningCollector.emitApiRequest(path, method, startTime, false, {
|
|
56
|
+
statusCode: response.status,
|
|
57
|
+
errorMessage,
|
|
58
|
+
context: {
|
|
59
|
+
durationMs: duration,
|
|
60
|
+
},
|
|
61
|
+
});
|
|
62
|
+
}
|
|
63
|
+
|
|
64
|
+
// Add timing header to response
|
|
65
|
+
const headers = new Headers(response.headers);
|
|
66
|
+
headers.set("X-Response-Time", `${duration}ms`);
|
|
67
|
+
|
|
68
|
+
return new Response(response.body, {
|
|
69
|
+
status: response.status,
|
|
70
|
+
statusText: response.statusText,
|
|
71
|
+
headers,
|
|
72
|
+
});
|
|
73
|
+
} catch (error) {
|
|
74
|
+
// Emit error signal
|
|
75
|
+
const errorMessage =
|
|
76
|
+
error instanceof Error ? error.message : "Unknown error";
|
|
77
|
+
|
|
78
|
+
learningCollector.emitApiRequest(path, method, startTime, false, {
|
|
79
|
+
statusCode: 500,
|
|
80
|
+
errorMessage,
|
|
81
|
+
context: {
|
|
82
|
+
errorType: error instanceof Error ? error.name : "UnknownError",
|
|
83
|
+
},
|
|
84
|
+
});
|
|
85
|
+
|
|
86
|
+
throw error;
|
|
87
|
+
}
|
|
88
|
+
};
|
|
89
|
+
}
|
|
90
|
+
|
|
91
|
+
/**
|
|
92
|
+
* Create a timing context for manual timing in route handlers.
|
|
93
|
+
*
|
|
94
|
+
* Usage:
|
|
95
|
+
* const timing = startTiming(req);
|
|
96
|
+
* // ... do work ...
|
|
97
|
+
* endTiming(timing, true);
|
|
98
|
+
*/
|
|
99
|
+
export function startTiming(req: Request): TimingContext {
|
|
100
|
+
const url = new URL(req.url);
|
|
101
|
+
return {
|
|
102
|
+
startTime: Date.now(),
|
|
103
|
+
method: req.method,
|
|
104
|
+
path: url.pathname,
|
|
105
|
+
};
|
|
106
|
+
}
|
|
107
|
+
|
|
108
|
+
/**
|
|
109
|
+
* End timing and emit a learning signal.
|
|
110
|
+
*/
|
|
111
|
+
export function endTiming(
|
|
112
|
+
context: TimingContext,
|
|
113
|
+
success: boolean,
|
|
114
|
+
options: {
|
|
115
|
+
statusCode?: number;
|
|
116
|
+
errorMessage?: string;
|
|
117
|
+
metadata?: Record<string, unknown>;
|
|
118
|
+
} = {}
|
|
119
|
+
): number {
|
|
120
|
+
const duration = Date.now() - context.startTime;
|
|
121
|
+
|
|
122
|
+
learningCollector.emitApiRequest(
|
|
123
|
+
context.path,
|
|
124
|
+
context.method,
|
|
125
|
+
context.startTime,
|
|
126
|
+
success,
|
|
127
|
+
{
|
|
128
|
+
statusCode: options.statusCode,
|
|
129
|
+
errorMessage: options.errorMessage,
|
|
130
|
+
context: options.metadata,
|
|
131
|
+
}
|
|
132
|
+
);
|
|
133
|
+
|
|
134
|
+
return duration;
|
|
135
|
+
}
|