Fix: Ensure all skills are tracked as files, not submodules
This commit is contained in:
497
skills/loki-mode/autonomy/.loki/dashboard/index.html
Normal file
497
skills/loki-mode/autonomy/.loki/dashboard/index.html
Normal file
@@ -0,0 +1,497 @@
|
||||
<!DOCTYPE html>
|
||||
<html lang="en">
|
||||
<head>
|
||||
<meta charset="UTF-8">
|
||||
<meta name="viewport" content="width=device-width, initial-scale=1.0">
|
||||
<title>Loki Mode Dashboard</title>
|
||||
<style>
|
||||
:root {
|
||||
--bg-cream: #FDF6E3;
|
||||
--bg-dark: #1a1a2e;
|
||||
--coral: #FF6B6B;
|
||||
--coral-light: #FF8E8E;
|
||||
--teal: #4ECDC4;
|
||||
--purple: #A78BFA;
|
||||
--yellow: #FCD34D;
|
||||
--green: #10B981;
|
||||
--red: #EF4444;
|
||||
--text-dark: #2D3748;
|
||||
--text-light: #718096;
|
||||
--card-bg: #FFFFFF;
|
||||
--border: #E2E8F0;
|
||||
}
|
||||
|
||||
* {
|
||||
margin: 0;
|
||||
padding: 0;
|
||||
box-sizing: border-box;
|
||||
}
|
||||
|
||||
body {
|
||||
font-family: -apple-system, BlinkMacSystemFont, 'Segoe UI', Roboto, Oxygen, Ubuntu, sans-serif;
|
||||
background: var(--bg-cream);
|
||||
color: var(--text-dark);
|
||||
min-height: 100vh;
|
||||
padding: 24px;
|
||||
}
|
||||
|
||||
.header {
|
||||
display: flex;
|
||||
justify-content: space-between;
|
||||
align-items: center;
|
||||
margin-bottom: 32px;
|
||||
}
|
||||
|
||||
.logo {
|
||||
display: flex;
|
||||
align-items: center;
|
||||
gap: 12px;
|
||||
}
|
||||
|
||||
.logo-icon {
|
||||
width: 48px;
|
||||
height: 48px;
|
||||
background: linear-gradient(135deg, var(--coral), var(--coral-light));
|
||||
border-radius: 12px;
|
||||
display: flex;
|
||||
align-items: center;
|
||||
justify-content: center;
|
||||
font-size: 24px;
|
||||
color: white;
|
||||
font-weight: bold;
|
||||
}
|
||||
|
||||
.logo-text {
|
||||
font-size: 28px;
|
||||
font-weight: 700;
|
||||
color: var(--text-dark);
|
||||
}
|
||||
|
||||
.status-bar {
|
||||
display: flex;
|
||||
gap: 16px;
|
||||
align-items: center;
|
||||
}
|
||||
|
||||
.status-item {
|
||||
display: flex;
|
||||
align-items: center;
|
||||
gap: 8px;
|
||||
padding: 8px 16px;
|
||||
background: var(--card-bg);
|
||||
border-radius: 8px;
|
||||
border: 1px solid var(--border);
|
||||
}
|
||||
|
||||
.status-dot {
|
||||
width: 8px;
|
||||
height: 8px;
|
||||
border-radius: 50%;
|
||||
}
|
||||
|
||||
.status-dot.active { background: var(--green); }
|
||||
.status-dot.warning { background: var(--yellow); }
|
||||
.status-dot.error { background: var(--red); }
|
||||
|
||||
.section {
|
||||
margin-bottom: 32px;
|
||||
}
|
||||
|
||||
.section-title {
|
||||
font-size: 20px;
|
||||
font-weight: 600;
|
||||
margin-bottom: 16px;
|
||||
color: var(--text-dark);
|
||||
}
|
||||
|
||||
.agents-grid {
|
||||
display: grid;
|
||||
grid-template-columns: repeat(auto-fill, minmax(320px, 1fr));
|
||||
gap: 16px;
|
||||
}
|
||||
|
||||
.agent-card {
|
||||
background: var(--card-bg);
|
||||
border-radius: 12px;
|
||||
padding: 20px;
|
||||
border: 1px solid var(--border);
|
||||
box-shadow: 0 2px 8px rgba(0,0,0,0.04);
|
||||
}
|
||||
|
||||
.agent-header {
|
||||
display: flex;
|
||||
justify-content: space-between;
|
||||
align-items: flex-start;
|
||||
margin-bottom: 12px;
|
||||
}
|
||||
|
||||
.agent-id {
|
||||
font-weight: 600;
|
||||
font-size: 14px;
|
||||
color: var(--text-dark);
|
||||
}
|
||||
|
||||
.agent-type {
|
||||
font-size: 12px;
|
||||
color: var(--text-light);
|
||||
margin-top: 4px;
|
||||
}
|
||||
|
||||
.model-badge {
|
||||
padding: 4px 10px;
|
||||
border-radius: 12px;
|
||||
font-size: 11px;
|
||||
font-weight: 600;
|
||||
text-transform: uppercase;
|
||||
}
|
||||
|
||||
.model-badge.sonnet {
|
||||
background: #E0E7FF;
|
||||
color: #4338CA;
|
||||
}
|
||||
|
||||
.model-badge.haiku {
|
||||
background: #D1FAE5;
|
||||
color: #065F46;
|
||||
}
|
||||
|
||||
.model-badge.opus {
|
||||
background: #FDE68A;
|
||||
color: #92400E;
|
||||
}
|
||||
|
||||
.agent-work {
|
||||
font-size: 13px;
|
||||
color: var(--text-dark);
|
||||
line-height: 1.5;
|
||||
margin-bottom: 16px;
|
||||
}
|
||||
|
||||
.agent-stats {
|
||||
display: flex;
|
||||
gap: 16px;
|
||||
font-size: 12px;
|
||||
color: var(--text-light);
|
||||
}
|
||||
|
||||
.stat {
|
||||
display: flex;
|
||||
align-items: center;
|
||||
gap: 4px;
|
||||
}
|
||||
|
||||
.agent-status {
|
||||
display: flex;
|
||||
align-items: center;
|
||||
gap: 6px;
|
||||
font-size: 12px;
|
||||
margin-top: 12px;
|
||||
padding-top: 12px;
|
||||
border-top: 1px solid var(--border);
|
||||
}
|
||||
|
||||
.status-active {
|
||||
color: var(--green);
|
||||
}
|
||||
|
||||
.status-completed {
|
||||
color: var(--purple);
|
||||
}
|
||||
|
||||
/* Task Queue Section */
|
||||
.queue-columns {
|
||||
display: grid;
|
||||
grid-template-columns: repeat(4, 1fr);
|
||||
gap: 16px;
|
||||
}
|
||||
|
||||
.queue-column {
|
||||
background: var(--card-bg);
|
||||
border-radius: 12px;
|
||||
padding: 16px;
|
||||
border: 1px solid var(--border);
|
||||
min-height: 300px;
|
||||
}
|
||||
|
||||
.queue-header {
|
||||
display: flex;
|
||||
justify-content: space-between;
|
||||
align-items: center;
|
||||
margin-bottom: 16px;
|
||||
padding-bottom: 12px;
|
||||
border-bottom: 2px solid var(--border);
|
||||
}
|
||||
|
||||
.queue-title {
|
||||
font-weight: 600;
|
||||
font-size: 14px;
|
||||
}
|
||||
|
||||
.queue-count {
|
||||
background: var(--bg-cream);
|
||||
padding: 4px 10px;
|
||||
border-radius: 12px;
|
||||
font-size: 12px;
|
||||
font-weight: 600;
|
||||
}
|
||||
|
||||
.queue-column.pending .queue-header { border-color: var(--yellow); }
|
||||
.queue-column.in-progress .queue-header { border-color: var(--teal); }
|
||||
.queue-column.completed .queue-header { border-color: var(--green); }
|
||||
.queue-column.failed .queue-header { border-color: var(--red); }
|
||||
|
||||
.task-card {
|
||||
background: var(--bg-cream);
|
||||
border-radius: 8px;
|
||||
padding: 12px;
|
||||
margin-bottom: 8px;
|
||||
font-size: 12px;
|
||||
}
|
||||
|
||||
.task-id {
|
||||
font-weight: 600;
|
||||
color: var(--text-dark);
|
||||
margin-bottom: 4px;
|
||||
}
|
||||
|
||||
.task-type {
|
||||
display: inline-block;
|
||||
padding: 2px 8px;
|
||||
background: var(--card-bg);
|
||||
border-radius: 4px;
|
||||
font-size: 10px;
|
||||
color: var(--text-light);
|
||||
margin-bottom: 8px;
|
||||
}
|
||||
|
||||
.task-desc {
|
||||
color: var(--text-dark);
|
||||
line-height: 1.4;
|
||||
}
|
||||
|
||||
.last-updated {
|
||||
text-align: center;
|
||||
color: var(--text-light);
|
||||
font-size: 12px;
|
||||
margin-top: 24px;
|
||||
}
|
||||
|
||||
@media (max-width: 1024px) {
|
||||
.queue-columns {
|
||||
grid-template-columns: repeat(2, 1fr);
|
||||
}
|
||||
}
|
||||
|
||||
@media (max-width: 640px) {
|
||||
.queue-columns {
|
||||
grid-template-columns: 1fr;
|
||||
}
|
||||
.agents-grid {
|
||||
grid-template-columns: 1fr;
|
||||
}
|
||||
}
|
||||
</style>
|
||||
</head>
|
||||
<body>
|
||||
<div class="header">
|
||||
<div class="logo">
|
||||
<div class="logo-icon">L</div>
|
||||
<span class="logo-text">Loki Mode Dashboard</span>
|
||||
</div>
|
||||
<div class="status-bar">
|
||||
<div class="status-item">
|
||||
<div class="status-dot active"></div>
|
||||
<span>Phase: DEVELOPMENT</span>
|
||||
</div>
|
||||
<div class="status-item">
|
||||
<span>v2.18.0</span>
|
||||
</div>
|
||||
</div>
|
||||
</div>
|
||||
|
||||
<div class="section" id="agents-section">
|
||||
<h2 class="section-title">Active Agents</h2>
|
||||
<div class="agents-grid" id="agents-grid">
|
||||
<!-- Agent cards populated by JS -->
|
||||
</div>
|
||||
</div>
|
||||
|
||||
<div class="section" id="queue-section">
|
||||
<h2 class="section-title">Task Queue</h2>
|
||||
<div class="queue-columns" id="queue-columns">
|
||||
<div class="queue-column pending">
|
||||
<div class="queue-header">
|
||||
<span class="queue-title">Pending</span>
|
||||
<span class="queue-count" id="pending-count">0</span>
|
||||
</div>
|
||||
<div id="pending-tasks"></div>
|
||||
</div>
|
||||
<div class="queue-column in-progress">
|
||||
<div class="queue-header">
|
||||
<span class="queue-title">In Progress</span>
|
||||
<span class="queue-count" id="in-progress-count">0</span>
|
||||
</div>
|
||||
<div id="in-progress-tasks"></div>
|
||||
</div>
|
||||
<div class="queue-column completed">
|
||||
<div class="queue-header">
|
||||
<span class="queue-title">Completed</span>
|
||||
<span class="queue-count" id="completed-count">0</span>
|
||||
</div>
|
||||
<div id="completed-tasks"></div>
|
||||
</div>
|
||||
<div class="queue-column failed">
|
||||
<div class="queue-header">
|
||||
<span class="queue-title">Failed</span>
|
||||
<span class="queue-count" id="failed-count">0</span>
|
||||
</div>
|
||||
<div id="failed-tasks"></div>
|
||||
</div>
|
||||
</div>
|
||||
</div>
|
||||
|
||||
<div class="last-updated" id="last-updated">
|
||||
Last updated: --
|
||||
</div>
|
||||
|
||||
<script>
|
||||
// Demo data for screenshots
|
||||
const demoAgents = [
|
||||
{
|
||||
id: 'eng-001-backend-api',
|
||||
type: 'Engineering Backend',
|
||||
model: 'sonnet',
|
||||
work: 'Implementing POST /api/todos endpoint with validation and SQLite storage',
|
||||
runtime: '12m 34s',
|
||||
tasks: 5,
|
||||
status: 'active'
|
||||
},
|
||||
{
|
||||
id: 'eng-002-frontend-ui',
|
||||
type: 'Engineering Frontend',
|
||||
model: 'sonnet',
|
||||
work: 'Building React components for todo list with Tailwind styling',
|
||||
runtime: '8m 21s',
|
||||
tasks: 3,
|
||||
status: 'active'
|
||||
},
|
||||
{
|
||||
id: 'qa-001-testing',
|
||||
type: 'QA Testing',
|
||||
model: 'haiku',
|
||||
work: 'Writing unit tests for authentication module',
|
||||
runtime: '5m 45s',
|
||||
tasks: 8,
|
||||
status: 'active'
|
||||
},
|
||||
{
|
||||
id: 'review-security-001',
|
||||
type: 'Security Review',
|
||||
model: 'opus',
|
||||
work: 'Analyzing auth flow for OWASP vulnerabilities',
|
||||
runtime: '3m 12s',
|
||||
tasks: 2,
|
||||
status: 'active'
|
||||
},
|
||||
{
|
||||
id: 'ops-devops-001',
|
||||
type: 'Operations DevOps',
|
||||
model: 'sonnet',
|
||||
work: 'Configuring GitHub Actions CI/CD pipeline',
|
||||
runtime: '15m 08s',
|
||||
tasks: 4,
|
||||
status: 'active'
|
||||
},
|
||||
{
|
||||
id: 'biz-marketing-001',
|
||||
type: 'Business Marketing',
|
||||
model: 'haiku',
|
||||
work: 'Creating landing page copy and SEO meta tags',
|
||||
runtime: '6m 33s',
|
||||
tasks: 2,
|
||||
status: 'completed'
|
||||
}
|
||||
];
|
||||
|
||||
const demoTasks = {
|
||||
pending: [
|
||||
{ id: 'task-015', type: 'eng-database', desc: 'Create migration for user preferences table' },
|
||||
{ id: 'task-016', type: 'eng-frontend', desc: 'Implement dark mode toggle component' },
|
||||
{ id: 'task-017', type: 'qa-testing', desc: 'Write E2E tests for checkout flow' }
|
||||
],
|
||||
inProgress: [
|
||||
{ id: 'task-012', type: 'eng-backend', desc: 'Implement JWT refresh token rotation' },
|
||||
{ id: 'task-013', type: 'eng-frontend', desc: 'Add form validation to signup page' }
|
||||
],
|
||||
completed: [
|
||||
{ id: 'task-001', type: 'eng-backend', desc: 'Setup Express server with TypeScript' },
|
||||
{ id: 'task-002', type: 'eng-database', desc: 'Create initial SQLite schema' },
|
||||
{ id: 'task-003', type: 'eng-frontend', desc: 'Initialize React with Vite' },
|
||||
{ id: 'task-004', type: 'ops-devops', desc: 'Configure ESLint and Prettier' },
|
||||
{ id: 'task-005', type: 'eng-backend', desc: 'Implement user registration endpoint' }
|
||||
],
|
||||
failed: []
|
||||
};
|
||||
|
||||
function renderAgents() {
|
||||
const grid = document.getElementById('agents-grid');
|
||||
grid.innerHTML = demoAgents.map(agent => `
|
||||
<div class="agent-card">
|
||||
<div class="agent-header">
|
||||
<div>
|
||||
<div class="agent-id">${agent.id}</div>
|
||||
<div class="agent-type">${agent.type}</div>
|
||||
</div>
|
||||
<span class="model-badge ${agent.model}">${agent.model}</span>
|
||||
</div>
|
||||
<div class="agent-work">${agent.work}</div>
|
||||
<div class="agent-stats">
|
||||
<span class="stat">Runtime: ${agent.runtime}</span>
|
||||
<span class="stat">Tasks: ${agent.tasks}</span>
|
||||
</div>
|
||||
<div class="agent-status ${agent.status === 'active' ? 'status-active' : 'status-completed'}">
|
||||
<div class="status-dot ${agent.status === 'active' ? 'active' : ''}"></div>
|
||||
${agent.status === 'active' ? 'Active' : 'Completed'}
|
||||
</div>
|
||||
</div>
|
||||
`).join('');
|
||||
}
|
||||
|
||||
function renderTasks() {
|
||||
const renderTaskList = (tasks, containerId) => {
|
||||
const container = document.getElementById(containerId);
|
||||
container.innerHTML = tasks.map(task => `
|
||||
<div class="task-card">
|
||||
<div class="task-id">${task.id}</div>
|
||||
<span class="task-type">${task.type}</span>
|
||||
<div class="task-desc">${task.desc}</div>
|
||||
</div>
|
||||
`).join('');
|
||||
};
|
||||
|
||||
renderTaskList(demoTasks.pending, 'pending-tasks');
|
||||
renderTaskList(demoTasks.inProgress, 'in-progress-tasks');
|
||||
renderTaskList(demoTasks.completed.slice(0, 5), 'completed-tasks');
|
||||
renderTaskList(demoTasks.failed, 'failed-tasks');
|
||||
|
||||
document.getElementById('pending-count').textContent = demoTasks.pending.length;
|
||||
document.getElementById('in-progress-count').textContent = demoTasks.inProgress.length;
|
||||
document.getElementById('completed-count').textContent = demoTasks.completed.length;
|
||||
document.getElementById('failed-count').textContent = demoTasks.failed.length;
|
||||
}
|
||||
|
||||
function updateTimestamp() {
|
||||
const now = new Date().toLocaleString();
|
||||
document.getElementById('last-updated').textContent = `Last updated: ${now}`;
|
||||
}
|
||||
|
||||
// Initial render
|
||||
renderAgents();
|
||||
renderTasks();
|
||||
updateTimestamp();
|
||||
|
||||
// Auto-refresh every 3 seconds (in production, would fetch real data)
|
||||
setInterval(updateTimestamp, 3000);
|
||||
</script>
|
||||
</body>
|
||||
</html>
|
||||
402
skills/loki-mode/autonomy/CONSTITUTION.md
Normal file
402
skills/loki-mode/autonomy/CONSTITUTION.md
Normal file
@@ -0,0 +1,402 @@
|
||||
# Loki Mode Agent Constitution
|
||||
|
||||
> **Machine-Enforceable Behavioral Contract for All Agents**
|
||||
> Version 1.0.0 | Immutable Principles | Context-Preserved Lineage
|
||||
|
||||
---
|
||||
|
||||
## Core Principles (Inviolable)
|
||||
|
||||
### 1. Specification-First Development
|
||||
**RULE:** No code shall be written before the specification exists.
|
||||
|
||||
**Enforcement:**
|
||||
```
|
||||
IF task.type == "implementation" AND !exists(spec_file):
|
||||
BLOCK with error: "SPEC_MISSING"
|
||||
REQUIRE: Create OpenAPI spec first
|
||||
```
|
||||
|
||||
**Rationale:** Specs are contracts. Code is implementation. Contract before implementation.
|
||||
|
||||
### 2. Git Checkpoint System
|
||||
**RULE:** Every completed task MUST create a git checkpoint.
|
||||
|
||||
**Enforcement:**
|
||||
```
|
||||
ON task.status == "completed":
|
||||
git add <modified_files>
|
||||
git commit -m "[Loki] Task ${task.id}: ${task.title}"
|
||||
UPDATE CONTINUITY.md with commit SHA
|
||||
```
|
||||
|
||||
**Rationale:** Git history is proof of progress. Every task is a save point.
|
||||
|
||||
### 3. Context Preservation
|
||||
**RULE:** All agents MUST inherit and preserve context from their spawning agent.
|
||||
|
||||
**Enforcement:**
|
||||
```
|
||||
ON agent.spawn():
|
||||
agent.context.parent_id = spawner.agent_id
|
||||
agent.context.lineage = [...spawner.lineage, spawner.agent_id]
|
||||
agent.context.inherited_memory = spawner.memory.export()
|
||||
WRITE .agent/sub-agents/${agent.agent_id}.json
|
||||
```
|
||||
|
||||
**Rationale:** Context drift kills multi-agent systems. Lineage is truth.
|
||||
|
||||
### 4. Iterative Specification Questions
|
||||
**RULE:** During spec generation, agents MUST ask clarifying questions before assuming.
|
||||
|
||||
**Enforcement:**
|
||||
```
|
||||
WHILE generating_spec:
|
||||
IF ambiguity_detected OR assumption_required:
|
||||
questions = generate_clarifying_questions()
|
||||
IF orchestrator_mode:
|
||||
answers = infer_from_prd()
|
||||
ELSE:
|
||||
answers = ask_user(questions)
|
||||
UPDATE spec WITH answers
|
||||
```
|
||||
|
||||
**Rationale:** Assumptions create bugs. Questions create clarity.
|
||||
|
||||
### 5. Machine-Readable Rules
|
||||
**RULE:** All behavioral rules MUST be represented as structured artifacts, not just prose.
|
||||
|
||||
**Enforcement:**
|
||||
```
|
||||
rules/
|
||||
├── pre-commit.schema.json # Validation rules
|
||||
├── quality-gates.yaml # Quality thresholds
|
||||
├── agent-contracts.json # Agent responsibilities
|
||||
└── invariants.ts # Runtime assertions
|
||||
```
|
||||
|
||||
**Rationale:** Humans read markdown. Machines enforce JSON/YAML.
|
||||
|
||||
---
|
||||
|
||||
## Agent Behavioral Contracts
|
||||
|
||||
### Orchestrator Agent
|
||||
**Responsibilities:**
|
||||
- Initialize .loki/ directory structure
|
||||
- Maintain CONTINUITY.md (working memory)
|
||||
- Coordinate task queue (pending → in-progress → completed)
|
||||
- Enforce quality gates
|
||||
- Manage git checkpoints
|
||||
|
||||
**Prohibited Actions:**
|
||||
- Writing implementation code directly
|
||||
- Skipping spec generation
|
||||
- Modifying completed tasks without explicit override
|
||||
|
||||
**Context Obligations:**
|
||||
- MUST read CONTINUITY.md before every action
|
||||
- MUST update orchestrator.json after phase transitions
|
||||
- MUST preserve task lineage in completed.json
|
||||
|
||||
### Engineering Swarm Agents
|
||||
**Responsibilities:**
|
||||
- Implement features per OpenAPI spec
|
||||
- Write contract tests before implementation
|
||||
- Create git commits for completed tasks
|
||||
- Ask clarifying questions when spec is ambiguous
|
||||
|
||||
**Prohibited Actions:**
|
||||
- Implementing without spec
|
||||
- Skipping tests
|
||||
- Ignoring linter/type errors
|
||||
|
||||
**Context Obligations:**
|
||||
- MUST inherit parent agent's context
|
||||
- MUST log all decisions to .agent/sub-agents/${agent_id}.md
|
||||
- MUST reference spec in all implementation commits
|
||||
|
||||
### QA Swarm Agents
|
||||
**Responsibilities:**
|
||||
- Generate test cases from OpenAPI spec
|
||||
- Run contract validation tests
|
||||
- Report discrepancies between code and spec
|
||||
- Create bug reports in dead-letter queue
|
||||
|
||||
**Prohibited Actions:**
|
||||
- Modifying implementation code
|
||||
- Skipping failing tests
|
||||
- Approving incomplete features
|
||||
|
||||
**Context Obligations:**
|
||||
- MUST validate against spec as source of truth
|
||||
- MUST log test results to ledgers/
|
||||
- MUST create git commits for test additions
|
||||
|
||||
### DevOps Swarm Agents
|
||||
**Responsibilities:**
|
||||
- Automate deployment pipelines
|
||||
- Monitor service health
|
||||
- Configure infrastructure as code
|
||||
- Manage environment secrets
|
||||
|
||||
**Prohibited Actions:**
|
||||
- Storing secrets in plaintext
|
||||
- Deploying without health checks
|
||||
- Skipping rollback procedures
|
||||
|
||||
**Context Obligations:**
|
||||
- MUST log all deployments to deployment ledger
|
||||
- MUST preserve deployment context for rollback
|
||||
- MUST track infrastructure state in orchestrator.json
|
||||
|
||||
---
|
||||
|
||||
## Quality Gates (Machine-Enforceable)
|
||||
|
||||
### Pre-Commit Hook (BLOCKING)
|
||||
```yaml
|
||||
quality_gates:
|
||||
linting:
|
||||
enabled: true
|
||||
auto_fix: true
|
||||
block_on_failure: true
|
||||
|
||||
type_checking:
|
||||
enabled: true
|
||||
strict_mode: true
|
||||
block_on_failure: true
|
||||
|
||||
contract_tests:
|
||||
enabled: true
|
||||
min_coverage: 80%
|
||||
block_on_failure: true
|
||||
|
||||
spec_validation:
|
||||
enabled: true
|
||||
validator: spectral
|
||||
block_on_failure: true
|
||||
```
|
||||
|
||||
### Post-Implementation Review (AUTO-FIX)
|
||||
```yaml
|
||||
auto_review:
|
||||
static_analysis:
|
||||
tools: [eslint, prettier, tsc]
|
||||
auto_fix: true
|
||||
|
||||
security_scan:
|
||||
tools: [semgrep, snyk]
|
||||
severity_threshold: medium
|
||||
auto_create_issues: true
|
||||
|
||||
performance_check:
|
||||
lighthouse_score: 90
|
||||
bundle_size_limit: 500kb
|
||||
warn_only: true
|
||||
```
|
||||
|
||||
---
|
||||
|
||||
## Memory Hierarchy (Priority Order)
|
||||
|
||||
### 1. CONTINUITY.md (Volatile - Every Turn)
|
||||
**Purpose:** What am I doing RIGHT NOW?
|
||||
**Update Frequency:** Every turn
|
||||
**Content:** Current task, phase, blockers, next steps
|
||||
|
||||
### 2. CONSTITUTION.md (Immutable - This File)
|
||||
**Purpose:** How MUST I behave?
|
||||
**Update Frequency:** Version bumps only
|
||||
**Content:** Behavioral contracts, quality gates, invariants
|
||||
|
||||
### 3. CLAUDE.md (Semi-Stable - Significant Changes)
|
||||
**Purpose:** What is this project?
|
||||
**Update Frequency:** Architecture changes
|
||||
**Content:** Tech stack, patterns, project context
|
||||
|
||||
### 4. Ledgers (Append-Only - Checkpoint)
|
||||
**Purpose:** What happened?
|
||||
**Update Frequency:** After significant events
|
||||
**Content:** Decisions, deployments, reviews
|
||||
|
||||
### 5. .agent/sub-agents/*.json (Lineage Tracking)
|
||||
**Purpose:** Who did what and why?
|
||||
**Update Frequency:** Agent lifecycle events
|
||||
**Content:** Agent context, decisions, inherited memory
|
||||
|
||||
---
|
||||
|
||||
## Context Lineage Schema
|
||||
|
||||
```json
|
||||
{
|
||||
"agent_id": "eng-001-backend-api",
|
||||
"agent_type": "general-purpose",
|
||||
"model": "haiku",
|
||||
"spawned_at": "2026-01-04T05:30:00Z",
|
||||
"spawned_by": "orchestrator-main",
|
||||
"lineage": ["orchestrator-main", "eng-001-backend-api"],
|
||||
"inherited_context": {
|
||||
"phase": "development",
|
||||
"current_task": "task-005",
|
||||
"spec_reference": ".loki/specs/openapi.yaml#/paths/~1api~1todos",
|
||||
"tech_stack": ["Node.js", "Express", "TypeScript", "SQLite"]
|
||||
},
|
||||
"decisions_made": [
|
||||
{
|
||||
"timestamp": "2026-01-04T05:31:15Z",
|
||||
"question": "Should we use Prisma or raw SQL?",
|
||||
"answer": "Raw SQL with better-sqlite3 for simplicity",
|
||||
"rationale": "PRD requires minimal dependencies, synchronous ops preferred"
|
||||
}
|
||||
],
|
||||
"tasks_completed": ["task-005"],
|
||||
"commits_created": ["abc123f", "def456a"],
|
||||
"status": "completed",
|
||||
"completed_at": "2026-01-04T05:45:00Z"
|
||||
}
|
||||
```
|
||||
|
||||
---
|
||||
|
||||
## Git Checkpoint Protocol
|
||||
|
||||
### Commit Message Format
|
||||
```
|
||||
[Loki] ${agent_type}-${task_id}: ${task_title}
|
||||
|
||||
${detailed_description}
|
||||
|
||||
Agent: ${agent_id}
|
||||
Parent: ${parent_agent_id}
|
||||
Spec: ${spec_reference}
|
||||
Tests: ${test_files}
|
||||
```
|
||||
|
||||
### Example
|
||||
```
|
||||
[Loki] eng-005-backend: Implement POST /api/todos endpoint
|
||||
|
||||
Created todo creation endpoint per OpenAPI spec.
|
||||
- Input validation for title field
|
||||
- SQLite insertion with timestamps
|
||||
- Returns 201 with created todo object
|
||||
- Contract tests passing
|
||||
|
||||
Agent: eng-001-backend-api
|
||||
Parent: orchestrator-main
|
||||
Spec: .loki/specs/openapi.yaml#/paths/~1api~1todos/post
|
||||
Tests: backend/tests/todos.contract.test.ts
|
||||
```
|
||||
|
||||
---
|
||||
|
||||
## Invariants (Runtime Assertions)
|
||||
|
||||
```typescript
|
||||
// .loki/rules/invariants.ts
|
||||
|
||||
export const INVARIANTS = {
|
||||
// Spec must exist before implementation
|
||||
SPEC_BEFORE_CODE: (task: Task) => {
|
||||
if (task.type === 'implementation') {
|
||||
assert(exists(task.spec_reference), 'SPEC_MISSING');
|
||||
}
|
||||
},
|
||||
|
||||
// All tasks must have git commits
|
||||
TASK_HAS_COMMIT: (task: Task) => {
|
||||
if (task.status === 'completed') {
|
||||
assert(task.git_commit_sha, 'COMMIT_MISSING');
|
||||
}
|
||||
},
|
||||
|
||||
// Agent lineage must be preserved
|
||||
AGENT_HAS_LINEAGE: (agent: Agent) => {
|
||||
assert(agent.lineage.length > 0, 'LINEAGE_MISSING');
|
||||
assert(agent.spawned_by, 'PARENT_MISSING');
|
||||
},
|
||||
|
||||
// CONTINUITY.md must always exist
|
||||
CONTINUITY_EXISTS: () => {
|
||||
assert(exists('.loki/CONTINUITY.md'), 'CONTINUITY_MISSING');
|
||||
},
|
||||
|
||||
// Quality gates must pass before merge
|
||||
QUALITY_GATES_PASSED: (task: Task) => {
|
||||
if (task.status === 'completed') {
|
||||
assert(task.quality_checks.all_passed, 'QUALITY_GATE_FAILED');
|
||||
}
|
||||
}
|
||||
};
|
||||
```
|
||||
|
||||
---
|
||||
|
||||
## Visual Specification Aids
|
||||
|
||||
### Mermaid Diagram Generation (Required for Complex Features)
|
||||
|
||||
**RULE:** Architecture decisions and complex workflows MUST include Mermaid diagrams.
|
||||
|
||||
**Example - Authentication Flow:**
|
||||
```mermaid
|
||||
sequenceDiagram
|
||||
participant C as Client
|
||||
participant A as API
|
||||
participant D as Database
|
||||
|
||||
C->>A: POST /api/auth/login
|
||||
A->>A: Validate credentials
|
||||
A->>D: Query user
|
||||
D-->>A: User record
|
||||
A->>A: Generate JWT token
|
||||
A-->>C: 200 OK {token}
|
||||
```
|
||||
|
||||
**Storage Location:** `.loki/diagrams/${feature_name}.mmd`
|
||||
|
||||
**When Required:**
|
||||
- Multi-step workflows (3+ steps)
|
||||
- System architecture changes
|
||||
- Complex state machines
|
||||
- Integration points between services
|
||||
|
||||
---
|
||||
|
||||
## Amendment Process
|
||||
|
||||
This constitution can only be amended through:
|
||||
1. Version bump in header
|
||||
2. Git commit with `[CONSTITUTION]` prefix
|
||||
3. Changelog entry documenting what changed and why
|
||||
4. Re-validation of all existing agents against new rules
|
||||
|
||||
**Example Amendment Commit:**
|
||||
```
|
||||
[CONSTITUTION] v1.1.0: Add visual specification requirement
|
||||
|
||||
Added requirement for Mermaid diagrams on complex features to prevent
|
||||
ambiguity in multi-step workflows. Based on Addy Osmani's insight that
|
||||
visual aids significantly improve AI-to-AI communication.
|
||||
|
||||
Breaking changes: None
|
||||
New rules: Section "Visual Specification Aids"
|
||||
```
|
||||
|
||||
---
|
||||
|
||||
## Enforcement
|
||||
|
||||
All rules in this constitution are **machine-enforceable** and **MUST** be implemented as:
|
||||
1. Pre-commit hooks (Git)
|
||||
2. Runtime assertions (TypeScript invariants)
|
||||
3. Quality gate validators (YAML configs)
|
||||
4. Agent behavior validators (JSON schemas)
|
||||
|
||||
**Human guidance is advisory. Machine enforcement is mandatory.**
|
||||
|
||||
---
|
||||
|
||||
*"In autonomous systems, trust is built on invariants, not intentions."*
|
||||
201
skills/loki-mode/autonomy/README.md
Normal file
201
skills/loki-mode/autonomy/README.md
Normal file
@@ -0,0 +1,201 @@
|
||||
# Loki Mode - Autonomous Runner
|
||||
|
||||
Single script that handles everything: prerequisites, setup, Vibe Kanban monitoring, and autonomous execution with auto-resume.
|
||||
|
||||
## Quick Start
|
||||
|
||||
```bash
|
||||
# Run with a PRD
|
||||
./autonomy/run.sh ./docs/requirements.md
|
||||
|
||||
# Run interactively
|
||||
./autonomy/run.sh
|
||||
```
|
||||
|
||||
That's it! The script will:
|
||||
1. Check all prerequisites (Claude CLI, Python, Git, etc.)
|
||||
2. Verify skill installation
|
||||
3. Initialize the `.loki/` directory
|
||||
4. **Start Vibe Kanban background sync** (monitor tasks in real-time)
|
||||
5. Start Claude Code with **live output** (no more waiting blindly)
|
||||
6. Auto-resume on rate limits or interruptions
|
||||
7. Continue until completion or max retries
|
||||
|
||||
## Live Output
|
||||
|
||||
Claude's output is displayed in real-time - you can see exactly what's happening:
|
||||
|
||||
```
|
||||
━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━
|
||||
CLAUDE CODE OUTPUT (live)
|
||||
━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━
|
||||
|
||||
[Claude's output appears here in real-time...]
|
||||
```
|
||||
|
||||
## Status Monitor (Built-in)
|
||||
|
||||
The runner updates `.loki/STATUS.txt` every 5 seconds with task progress:
|
||||
|
||||
```
|
||||
╔════════════════════════════════════════════════════════════════╗
|
||||
║ LOKI MODE STATUS ║
|
||||
╚════════════════════════════════════════════════════════════════╝
|
||||
|
||||
Updated: Sat Dec 28 15:30:00 PST 2025
|
||||
|
||||
Phase: DEVELOPMENT
|
||||
|
||||
Tasks:
|
||||
├─ Pending: 10
|
||||
├─ In Progress: 1
|
||||
├─ Completed: 5
|
||||
└─ Failed: 0
|
||||
|
||||
Monitor: watch -n 2 cat .loki/STATUS.txt
|
||||
```
|
||||
|
||||
### Monitor in Another Terminal
|
||||
|
||||
```bash
|
||||
# Watch status updates live
|
||||
watch -n 2 cat .loki/STATUS.txt
|
||||
|
||||
# Or view once
|
||||
cat .loki/STATUS.txt
|
||||
```
|
||||
|
||||
## What Gets Checked
|
||||
|
||||
| Prerequisite | Required | Notes |
|
||||
|--------------|----------|-------|
|
||||
| Claude Code CLI | Yes | Install from https://claude.ai/code |
|
||||
| Python 3 | Yes | For state management |
|
||||
| Git | Yes | For version control |
|
||||
| curl | Yes | For web fetches |
|
||||
| Node.js | No | Needed for some builds |
|
||||
| jq | No | Helpful for JSON parsing |
|
||||
|
||||
## Configuration
|
||||
|
||||
Environment variables:
|
||||
|
||||
```bash
|
||||
# Retry settings
|
||||
export LOKI_MAX_RETRIES=50 # Max retry attempts (default: 50)
|
||||
export LOKI_BASE_WAIT=60 # Base wait time in seconds (default: 60)
|
||||
export LOKI_MAX_WAIT=3600 # Max wait time in seconds (default: 3600)
|
||||
|
||||
# Skip prerequisite checks (for CI/CD or repeat runs)
|
||||
export LOKI_SKIP_PREREQS=true
|
||||
|
||||
# Run with custom settings
|
||||
LOKI_MAX_RETRIES=100 LOKI_BASE_WAIT=120 ./autonomy/run.sh ./docs/prd.md
|
||||
```
|
||||
|
||||
## How Auto-Resume Works
|
||||
|
||||
```
|
||||
┌─────────────────────────────────────────────────────────────┐
|
||||
│ ./autonomy/run.sh prd.md │
|
||||
└─────────────────────────────────────────────────────────────┘
|
||||
│
|
||||
▼
|
||||
┌───────────────────────┐
|
||||
│ Check Prerequisites │
|
||||
└───────────────────────┘
|
||||
│
|
||||
▼
|
||||
┌───────────────────────┐
|
||||
│ Initialize .loki/ │
|
||||
└───────────────────────┘
|
||||
│
|
||||
▼
|
||||
┌────────────────────────────────┐
|
||||
│ Run Claude Code with prompt │◄────────────────┐
|
||||
└────────────────────────────────┘ │
|
||||
│ │
|
||||
▼ │
|
||||
┌───────────────────────┐ │
|
||||
│ Claude exits │ │
|
||||
└───────────────────────┘ │
|
||||
│ │
|
||||
┌───────────┴───────────┐ │
|
||||
▼ ▼ │
|
||||
┌───────────────┐ ┌───────────────┐ │
|
||||
│ Completed? │──Yes──│ SUCCESS! │ │
|
||||
└───────────────┘ └───────────────┘ │
|
||||
│ No │
|
||||
▼ │
|
||||
┌───────────────┐ │
|
||||
│ Wait (backoff)│─────────────────────────────────────┘
|
||||
└───────────────┘
|
||||
```
|
||||
|
||||
## State Files
|
||||
|
||||
The autonomy runner creates:
|
||||
|
||||
```
|
||||
.loki/
|
||||
├── autonomy-state.json # Runner state (retry count, status)
|
||||
├── logs/
|
||||
│ └── autonomy-*.log # Execution logs
|
||||
├── state/
|
||||
│ └── orchestrator.json # Loki Mode phase tracking
|
||||
└── COMPLETED # Created when done
|
||||
```
|
||||
|
||||
## Resuming After Interruption
|
||||
|
||||
If you stop the script (Ctrl+C) or it crashes, just run it again:
|
||||
|
||||
```bash
|
||||
# State is saved, will resume from last checkpoint
|
||||
./autonomy/run.sh ./docs/requirements.md
|
||||
```
|
||||
|
||||
The script detects the previous state and continues from where it left off.
|
||||
|
||||
## Differences from Manual Mode
|
||||
|
||||
| Feature | Manual Mode | Autonomy Mode |
|
||||
|---------|-------------|---------------|
|
||||
| Start | `claude --dangerously-skip-permissions` | `./autonomy/run.sh` |
|
||||
| Prereq check | Manual | Automatic |
|
||||
| Rate limit handling | Manual restart | Auto-resume |
|
||||
| State persistence | Manual checkpoint | Automatic |
|
||||
| Logging | Console only | Console + file |
|
||||
| Max runtime | Session-based | Configurable retries |
|
||||
|
||||
## Troubleshooting
|
||||
|
||||
### "Claude Code CLI not found"
|
||||
```bash
|
||||
npm install -g @anthropic-ai/claude-code
|
||||
# or visit https://claude.ai/code
|
||||
```
|
||||
|
||||
### "SKILL.md not found"
|
||||
Make sure you're running from the loki-mode directory or have installed the skill:
|
||||
```bash
|
||||
# Option 1: Run from project directory
|
||||
cd /path/to/loki-mode
|
||||
./autonomy/run.sh
|
||||
|
||||
# Option 2: Install skill globally
|
||||
cp -r . ~/.claude/skills/loki-mode/
|
||||
```
|
||||
|
||||
### "Max retries exceeded"
|
||||
The task is taking too long or repeatedly failing. Check:
|
||||
```bash
|
||||
# View logs
|
||||
cat .loki/logs/autonomy-*.log | tail -100
|
||||
|
||||
# Check orchestrator state
|
||||
cat .loki/state/orchestrator.json
|
||||
|
||||
# Increase retries
|
||||
LOKI_MAX_RETRIES=200 ./autonomy/run.sh ./docs/prd.md
|
||||
```
|
||||
1991
skills/loki-mode/autonomy/run.sh
Executable file
1991
skills/loki-mode/autonomy/run.sh
Executable file
File diff suppressed because it is too large
Load Diff
Reference in New Issue
Block a user