@oleksandr.rudnychenko/sync_loop 0.2.5 → 0.3.2
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 +25 -4
- package/bin/cli.js +3 -128
- package/bin/cli.ts +171 -0
- package/dist/bin/cli.d.ts +15 -0
- package/dist/bin/cli.js +137 -0
- package/dist/bin/cli.js.map +1 -0
- package/dist/src/init.d.ts +24 -0
- package/dist/src/init.js +410 -0
- package/dist/src/init.js.map +1 -0
- package/dist/src/server.d.ts +13 -0
- package/dist/src/server.js +265 -0
- package/dist/src/server.js.map +1 -0
- package/dist/src/template/.agent-loop/README.md +75 -0
- package/dist/src/template/.agent-loop/feedback.md +395 -0
- package/dist/src/template/.agent-loop/glossary.md +113 -0
- package/dist/src/template/.agent-loop/patterns/api-standards.md +132 -0
- package/dist/src/template/.agent-loop/patterns/code-patterns.md +300 -0
- package/dist/src/template/.agent-loop/patterns/refactoring-workflow.md +114 -0
- package/dist/src/template/.agent-loop/patterns/testing-guide.md +258 -0
- package/dist/src/template/.agent-loop/patterns.md +256 -0
- package/dist/src/template/.agent-loop/reasoning-kernel.md +521 -0
- package/dist/src/template/.agent-loop/validate-env.md +332 -0
- package/dist/src/template/.agent-loop/validate-n.md +321 -0
- package/dist/src/template/AGENTS.md +157 -0
- package/dist/src/template/README.md +144 -0
- package/dist/src/template/bootstrap-prompt.md +37 -0
- package/dist/src/template/protocol-summary.md +54 -0
- package/dist/src/template/wiring/agents-claude.md +203 -0
- package/dist/src/template/wiring/agents-github.md +211 -0
- package/dist/src/template/wiring/api-standards.md +15 -0
- package/dist/src/template/wiring/code-patterns.md +15 -0
- package/dist/src/template/wiring/feedback.md +18 -0
- package/dist/src/template/wiring/glossary.md +11 -0
- package/dist/src/template/wiring/patterns.md +18 -0
- package/dist/src/template/wiring/reasoning-kernel.md +18 -0
- package/dist/src/template/wiring/refactoring-workflow.md +15 -0
- package/dist/src/template/wiring/testing-guide.md +15 -0
- package/dist/src/template/wiring/validate-env.md +17 -0
- package/dist/src/template/wiring/validate-n.md +17 -0
- package/package.json +48 -34
- package/src/template/wiring/agents-claude.md +203 -0
- package/src/template/wiring/agents-github.md +211 -0
- package/src/template/wiring/api-standards.md +15 -0
- package/src/template/wiring/code-patterns.md +15 -0
- package/src/template/wiring/feedback.md +18 -0
- package/src/template/wiring/glossary.md +11 -0
- package/src/template/wiring/patterns.md +18 -0
- package/src/template/wiring/reasoning-kernel.md +18 -0
- package/src/template/wiring/refactoring-workflow.md +15 -0
- package/src/template/wiring/testing-guide.md +15 -0
- package/src/template/wiring/validate-env.md +17 -0
- package/src/template/wiring/validate-n.md +17 -0
- package/src/init.js +0 -569
- package/src/server.js +0 -292
|
@@ -0,0 +1,157 @@
|
|
|
1
|
+
# SyncLoop — {Project Name}
|
|
2
|
+
|
|
3
|
+
Main entrypoint for AI agents working on this codebase.
|
|
4
|
+
Routes into `.agent-loop/` for reasoning protocol, validation, feedback, and learning.
|
|
5
|
+
|
|
6
|
+
**DO NOT MOVE THIS FILE TO DOCS/**. Keep it in the project root.
|
|
7
|
+
|
|
8
|
+
---
|
|
9
|
+
|
|
10
|
+
## 1. Project Identity
|
|
11
|
+
|
|
12
|
+
{Brief project description — what it does, who it serves.}
|
|
13
|
+
|
|
14
|
+
| Layer | Stack |
|
|
15
|
+
|-------|-------|
|
|
16
|
+
| Backend | {language, framework, runtime, database} |
|
|
17
|
+
| Frontend | {framework, build tool, language, UI library} |
|
|
18
|
+
| Infra | {hosting, CI/CD, object storage, caching} |
|
|
19
|
+
|
|
20
|
+
**Architecture source of truth:** {path to architecture doc} — but code is authoritative when docs conflict.
|
|
21
|
+
|
|
22
|
+
---
|
|
23
|
+
|
|
24
|
+
## 2. SyncLoop Protocol
|
|
25
|
+
|
|
26
|
+
Every turn follows a **7-stage protocol**:
|
|
27
|
+
|
|
28
|
+
```
|
|
29
|
+
1) SENSE ↔ 2) GKP
|
|
30
|
+
↓
|
|
31
|
+
3) DECIDE+ACT
|
|
32
|
+
↓
|
|
33
|
+
4) CHALLENGE-TEST
|
|
34
|
+
├─ Stage 1: ENV (validate-env.md)
|
|
35
|
+
└─ Stage 2: NEIGHBOR (validate-n.md)
|
|
36
|
+
↓
|
|
37
|
+
5) UPDATE
|
|
38
|
+
↓
|
|
39
|
+
6) LEARN
|
|
40
|
+
↓
|
|
41
|
+
7) REPORT
|
|
42
|
+
```
|
|
43
|
+
|
|
44
|
+
**Inner loops:**
|
|
45
|
+
1. **SENSE ↔ GKP**: gather and compress context until sufficient
|
|
46
|
+
2. **CHALLENGE-TEST → FEEDBACK → patch → retry**: iterate until gates pass (max 5)
|
|
47
|
+
|
|
48
|
+
---
|
|
49
|
+
|
|
50
|
+
## 3. Operational Modes
|
|
51
|
+
|
|
52
|
+
| Mode | Trigger | Behavior |
|
|
53
|
+
|------|---------|----------|
|
|
54
|
+
| **INTACT-STABILIZE** | System is healthy | Harden quality, docs, and test confidence |
|
|
55
|
+
| **BROKEN-EXPAND** | Defect or regression is present | Fix root cause with minimal safe surface area |
|
|
56
|
+
| **OVERDENSE-SPLIT** | Complexity exceeds maintainability threshold | Decompose into smaller units before feature expansion |
|
|
57
|
+
|
|
58
|
+
Mode is selected in DECIDE+ACT and can change after each validation cycle.
|
|
59
|
+
|
|
60
|
+
---
|
|
61
|
+
|
|
62
|
+
## 4. Architecture Guardrails
|
|
63
|
+
|
|
64
|
+
### Layer Architecture
|
|
65
|
+
|
|
66
|
+
```
|
|
67
|
+
Routes → Services → Repositories → Libs
|
|
68
|
+
```
|
|
69
|
+
|
|
70
|
+
{Replace with actual project layers. Map directories to layer roles.}
|
|
71
|
+
|
|
72
|
+
| Layer | Directory | Rules |
|
|
73
|
+
|-------|-----------|-------|
|
|
74
|
+
| **Routes** | `{path}` | Transport/boundary only. No business logic. |
|
|
75
|
+
| **Services** | `{path}` | Business orchestration. Domain logic lives here. |
|
|
76
|
+
| **Repositories** | `{path}` | Data access contracts. |
|
|
77
|
+
| **Libs** | `{path}` | Infrastructure utilities. No imports from app modules. |
|
|
78
|
+
|
|
79
|
+
### Cross-Layer Rules
|
|
80
|
+
|
|
81
|
+
- **Never** import across incompatible layers (e.g., infra importing domain)
|
|
82
|
+
- **Never** bypass the service layer from transport/route handlers
|
|
83
|
+
- **Never** change public APIs without explicit approval
|
|
84
|
+
- **Never** introduce sync calls in an async codebase (or vice versa)
|
|
85
|
+
|
|
86
|
+
{Add project-specific cross-layer rules here.}
|
|
87
|
+
|
|
88
|
+
---
|
|
89
|
+
|
|
90
|
+
## 5. Validation Commands
|
|
91
|
+
|
|
92
|
+
{Fill in with actual project commands after bootstrap.}
|
|
93
|
+
|
|
94
|
+
```bash
|
|
95
|
+
# Type check
|
|
96
|
+
{typecheck command}
|
|
97
|
+
|
|
98
|
+
# Lint & format
|
|
99
|
+
{lint command}
|
|
100
|
+
|
|
101
|
+
# Tests (all)
|
|
102
|
+
{test command}
|
|
103
|
+
|
|
104
|
+
# Tests (targeted)
|
|
105
|
+
{targeted test command}
|
|
106
|
+
|
|
107
|
+
# Install deps
|
|
108
|
+
{install command}
|
|
109
|
+
```
|
|
110
|
+
|
|
111
|
+
---
|
|
112
|
+
|
|
113
|
+
## 6. Key Domain Terms
|
|
114
|
+
|
|
115
|
+
{Fill in during bootstrap — see [glossary.md](.agent-loop/glossary.md) for canonical definitions.}
|
|
116
|
+
|
|
117
|
+
| Term | Model / Location | Description |
|
|
118
|
+
|------|------------------|-------------|
|
|
119
|
+
| {Term} | {file path} | {what it represents} |
|
|
120
|
+
|
|
121
|
+
---
|
|
122
|
+
|
|
123
|
+
## 7. Core SyncLoop Components
|
|
124
|
+
|
|
125
|
+
| Component | File | Role |
|
|
126
|
+
|-----------|------|------|
|
|
127
|
+
| Protocol kernel | [.agent-loop/reasoning-kernel.md](.agent-loop/reasoning-kernel.md) | Master loop and execution schema |
|
|
128
|
+
| Pattern registry | [.agent-loop/patterns.md](.agent-loop/patterns.md) | Pattern routing + learned fixes |
|
|
129
|
+
| Pattern specs | [.agent-loop/patterns/](.agent-loop/patterns/) | Detailed implementation playbooks |
|
|
130
|
+
| Domain vocabulary | [.agent-loop/glossary.md](.agent-loop/glossary.md) | Canonical terms and naming |
|
|
131
|
+
| ENV validation | [.agent-loop/validate-env.md](.agent-loop/validate-env.md) | NFR gates |
|
|
132
|
+
| NEIGHBOR validation | [.agent-loop/validate-n.md](.agent-loop/validate-n.md) | Shape/boundary/bridge checks |
|
|
133
|
+
| Feedback loop | [.agent-loop/feedback.md](.agent-loop/feedback.md) | Failure diagnosis + patching |
|
|
134
|
+
|
|
135
|
+
---
|
|
136
|
+
|
|
137
|
+
## 8. Non-Negotiable Rules
|
|
138
|
+
|
|
139
|
+
- ❌ Never modify tests only to force a pass result
|
|
140
|
+
- ❌ Never suppress typing or validation just to remove errors
|
|
141
|
+
- ❌ Never change public contracts without explicit approval
|
|
142
|
+
- ❌ Never bypass architecture boundaries for convenience
|
|
143
|
+
|
|
144
|
+
{Add project-specific rules here (e.g., multi-tenant isolation, audit requirements).}
|
|
145
|
+
|
|
146
|
+
If uncertain, choose isolated and reversible changes.
|
|
147
|
+
|
|
148
|
+
---
|
|
149
|
+
|
|
150
|
+
## 9. Reporting & Artifacts
|
|
151
|
+
|
|
152
|
+
- Reports: `docs/reports/YYYY-MM-DD-{slug}.md`
|
|
153
|
+
- Artifacts: `docs/reports/artifacts/`
|
|
154
|
+
- Learning memory: `.agent-loop/patterns.md` and `.agent-loop/patterns/*.md`
|
|
155
|
+
|
|
156
|
+
Create reports for non-trivial work (multi-file refactor, root-cause fix, architecture change).
|
|
157
|
+
|
|
@@ -0,0 +1,144 @@
|
|
|
1
|
+
# SyncLoop Setup Guide
|
|
2
|
+
|
|
3
|
+
This directory is a reusable template for bootstrapping SyncLoop into an existing codebase.
|
|
4
|
+
|
|
5
|
+
---
|
|
6
|
+
|
|
7
|
+
## Primary: MCP (recommended)
|
|
8
|
+
|
|
9
|
+
Add the SyncLoop MCP server to your AI coding client. The agent gets the full protocol on-demand — no file scaffolding needed.
|
|
10
|
+
|
|
11
|
+
```json
|
|
12
|
+
{
|
|
13
|
+
"mcpServers": {
|
|
14
|
+
"sync_loop": {
|
|
15
|
+
"command": "npx",
|
|
16
|
+
"args": ["-y", "-p", "@oleksandr.rudnychenko/sync_loop", "sync_loop"]
|
|
17
|
+
}
|
|
18
|
+
}
|
|
19
|
+
}
|
|
20
|
+
```
|
|
21
|
+
|
|
22
|
+
### Where to add MCP config
|
|
23
|
+
|
|
24
|
+
| Client | Config location |
|
|
25
|
+
|--------|----------------|
|
|
26
|
+
| **VS Code (Copilot)** | `.vscode/mcp.json` or Settings → MCP Servers |
|
|
27
|
+
| **Cursor** | Settings → MCP Servers |
|
|
28
|
+
| **Claude Desktop** | `claude_desktop_config.json` |
|
|
29
|
+
| **Claude Code** | `claude_code_config.json` or `--mcp-config` flag |
|
|
30
|
+
|
|
31
|
+
Once connected, the agent has access to all protocol resources, the `init` tool for scaffolding, and the `bootstrap` prompt for project wiring.
|
|
32
|
+
|
|
33
|
+
---
|
|
34
|
+
|
|
35
|
+
## Alternative: Scaffold Files
|
|
36
|
+
|
|
37
|
+
If you want the protocol files in your project (for offline use, customization, or CI), use the `init` tool via MCP or manually copy from this template.
|
|
38
|
+
|
|
39
|
+
### Via MCP (ask the agent)
|
|
40
|
+
|
|
41
|
+
Ask: "Use the sync_loop init tool to scaffold files for [copilot/cursor/claude/all] into this project"
|
|
42
|
+
|
|
43
|
+
Before calling `init`, the agent should ask:
|
|
44
|
+
"Which SyncLoop target platform should I scaffold: `copilot`, `cursor`, `claude`, or `all`?"
|
|
45
|
+
|
|
46
|
+
### Manual Copy
|
|
47
|
+
|
|
48
|
+
1. Copy `.agent-loop/` into your project root
|
|
49
|
+
2. Copy `AGENTS.md` into your project root
|
|
50
|
+
3. Run the bootstrap prompt below to wire to your project
|
|
51
|
+
|
|
52
|
+
---
|
|
53
|
+
|
|
54
|
+
## What This Setup Produces
|
|
55
|
+
|
|
56
|
+
After bootstrap, the project should have:
|
|
57
|
+
1. A root `AGENTS.md` aligned to the actual repository architecture
|
|
58
|
+
2. A `.agent-loop/` pack with project-aware validation commands and routing
|
|
59
|
+
3. A patterns index tied to real modules/services/contracts
|
|
60
|
+
4. A glossary with canonical domain terms used in the repo
|
|
61
|
+
|
|
62
|
+
The protocol itself remains generic:
|
|
63
|
+
- SENSE ↔ GKP → DECIDE+ACT → CHALLENGE-TEST → UPDATE → LEARN → REPORT
|
|
64
|
+
|
|
65
|
+
---
|
|
66
|
+
|
|
67
|
+
## Bootstrap Prompt (Copy/Paste)
|
|
68
|
+
|
|
69
|
+
Use this prompt with your coding agent in the target repository:
|
|
70
|
+
|
|
71
|
+
```md
|
|
72
|
+
Initialize and wire this SyncLoop framework to the current repository.
|
|
73
|
+
|
|
74
|
+
Requirements:
|
|
75
|
+
1) Scan the full codebase to understand:
|
|
76
|
+
- folder/module structure
|
|
77
|
+
- runtime stack and libraries/frameworks in use
|
|
78
|
+
- test/build/typecheck/lint commands
|
|
79
|
+
- architecture boundaries and dependency flow
|
|
80
|
+
|
|
81
|
+
2) Update root AGENTS.md and .agent-loop docs so they reference the actual project:
|
|
82
|
+
- keep protocol abstractions and stage flow intact
|
|
83
|
+
- replace placeholders with project-specific references where needed
|
|
84
|
+
- include real validation commands for this repo
|
|
85
|
+
- include real module/layer boundaries and guardrails
|
|
86
|
+
|
|
87
|
+
3) Build/refresh these artifacts:
|
|
88
|
+
- .agent-loop/patterns.md routing index
|
|
89
|
+
- .agent-loop/glossary.md canonical terms
|
|
90
|
+
- .agent-loop/validate-env.md with actual gate commands
|
|
91
|
+
- .agent-loop/validate-n.md with real neighbor/contract checks
|
|
92
|
+
- .agent-loop/feedback.md escalation and learn-routing
|
|
93
|
+
|
|
94
|
+
4) Preserve safety constraints:
|
|
95
|
+
- do not weaken validation gates
|
|
96
|
+
- do not change public APIs unless explicitly requested
|
|
97
|
+
- do not edit tests only to force passing status
|
|
98
|
+
|
|
99
|
+
5) Output:
|
|
100
|
+
- summary of files changed
|
|
101
|
+
- detected stack/tools/commands
|
|
102
|
+
- unresolved ambiguities requiring user input
|
|
103
|
+
|
|
104
|
+
Work end-to-end and apply edits directly.
|
|
105
|
+
```
|
|
106
|
+
|
|
107
|
+
---
|
|
108
|
+
|
|
109
|
+
## Recommended Execution Sequence
|
|
110
|
+
|
|
111
|
+
1. **Inventory**
|
|
112
|
+
- Parse manifests/lockfiles and CI configs
|
|
113
|
+
- Identify source roots, module boundaries, and docs locations
|
|
114
|
+
|
|
115
|
+
2. **Command Discovery**
|
|
116
|
+
- Detect canonical commands for typecheck/tests/lint/build
|
|
117
|
+
- Prefer existing scripts over inferred commands
|
|
118
|
+
|
|
119
|
+
3. **Architecture Mapping**
|
|
120
|
+
- Map route/service/repository/lib equivalents for this codebase
|
|
121
|
+
- Identify forbidden dependency directions
|
|
122
|
+
|
|
123
|
+
4. **Doc Wiring**
|
|
124
|
+
- Update `AGENTS.md` first (entrypoint)
|
|
125
|
+
- Align `.agent-loop/*` files with discovered project facts
|
|
126
|
+
- Keep generic reasoning protocol unchanged
|
|
127
|
+
|
|
128
|
+
5. **Validation Pass**
|
|
129
|
+
- Run the detected validation commands
|
|
130
|
+
- Fix only issues introduced by wiring changes
|
|
131
|
+
|
|
132
|
+
6. **Handoff**
|
|
133
|
+
- Provide concise report and any follow-up actions
|
|
134
|
+
|
|
135
|
+
---
|
|
136
|
+
|
|
137
|
+
## Acceptance Checklist
|
|
138
|
+
|
|
139
|
+
- [ ] `AGENTS.md` points to the right local docs and architecture
|
|
140
|
+
- [ ] `.agent-loop/validate-env.md` uses repo-true commands
|
|
141
|
+
- [ ] `.agent-loop/patterns.md` routes to real project patterns
|
|
142
|
+
- [ ] `.agent-loop/glossary.md` reflects actual domain vocabulary
|
|
143
|
+
- [ ] No direct references to unrelated projects
|
|
144
|
+
- [ ] Protocol and guardrails remain intact
|
|
@@ -0,0 +1,37 @@
|
|
|
1
|
+
Initialize and wire the SyncLoop reasoning protocol to the current repository.
|
|
2
|
+
|
|
3
|
+
If SyncLoop target platform is not explicitly provided yet, ask the user first:
|
|
4
|
+
"Which SyncLoop target platform should I scaffold: `copilot`, `cursor`, `claude`, or `all`?"
|
|
5
|
+
|
|
6
|
+
Requirements:
|
|
7
|
+
|
|
8
|
+
1) Scan the full codebase to understand:
|
|
9
|
+
- folder/module structure
|
|
10
|
+
- runtime stack and libraries/frameworks in use
|
|
11
|
+
- test/build/typecheck/lint commands
|
|
12
|
+
- architecture boundaries and dependency flow
|
|
13
|
+
|
|
14
|
+
2) Update root AGENTS.md and .agent-loop docs so they reference the actual project:
|
|
15
|
+
- keep protocol abstractions and stage flow intact
|
|
16
|
+
- replace placeholders with project-specific references where needed
|
|
17
|
+
- include real validation commands for this repo
|
|
18
|
+
- include real module/layer boundaries and guardrails
|
|
19
|
+
|
|
20
|
+
3) Build/refresh these artifacts:
|
|
21
|
+
- .agent-loop/patterns.md routing index
|
|
22
|
+
- .agent-loop/glossary.md canonical terms
|
|
23
|
+
- .agent-loop/validate-env.md with actual gate commands
|
|
24
|
+
- .agent-loop/validate-n.md with real neighbor/contract checks
|
|
25
|
+
- .agent-loop/feedback.md escalation and learn-routing
|
|
26
|
+
|
|
27
|
+
4) Preserve safety constraints:
|
|
28
|
+
- do not weaken validation gates
|
|
29
|
+
- do not change public APIs unless explicitly requested
|
|
30
|
+
- do not edit tests only to force passing status
|
|
31
|
+
|
|
32
|
+
5) Output:
|
|
33
|
+
- summary of files changed
|
|
34
|
+
- detected stack/tools/commands
|
|
35
|
+
- unresolved ambiguities requiring user input
|
|
36
|
+
|
|
37
|
+
Work end-to-end and apply edits directly.
|
|
@@ -0,0 +1,54 @@
|
|
|
1
|
+
# SyncLoop Agent Protocol
|
|
2
|
+
|
|
3
|
+
Self-correcting 7-stage reasoning loop for every task.
|
|
4
|
+
|
|
5
|
+
## Protocol
|
|
6
|
+
|
|
7
|
+
```
|
|
8
|
+
SENSE → GKP → DECIDE+ACT → CHALLENGE-TEST → UPDATE → LEARN → REPORT
|
|
9
|
+
```
|
|
10
|
+
|
|
11
|
+
### Stages
|
|
12
|
+
|
|
13
|
+
1. **SENSE** — Detect current state, issues, context gaps
|
|
14
|
+
2. **GKP** — Gather and compress relevant knowledge (patterns, constraints, risks)
|
|
15
|
+
3. **DECIDE+ACT** — Select mode, plan action, execute immediately
|
|
16
|
+
4. **CHALLENGE-TEST** — Run 2-stage validation (ENV gates + NEIGHBOR checks)
|
|
17
|
+
5. **UPDATE** — Commit state transitions
|
|
18
|
+
6. **LEARN** — Persist fixes and patterns
|
|
19
|
+
7. **REPORT** — Session summary (skip if trivial)
|
|
20
|
+
|
|
21
|
+
### Inner Loops
|
|
22
|
+
|
|
23
|
+
1. **SENSE ↔ GKP** — cycle until relevant context gathered and compressed
|
|
24
|
+
2. **CHALLENGE-TEST → FEEDBACK → patch → retry** — iterate until gates pass (max 5)
|
|
25
|
+
|
|
26
|
+
### Modes
|
|
27
|
+
|
|
28
|
+
| Mode | Trigger | Behavior |
|
|
29
|
+
|------|---------|----------|
|
|
30
|
+
| **INTACT-STABILIZE** | All gates pass | Harden quality, tests, docs |
|
|
31
|
+
| **BROKEN-EXPAND** | Issues detected | Fix root cause, minimal surface |
|
|
32
|
+
| **OVERDENSE-SPLIT** | Complexity high | Decompose before expanding |
|
|
33
|
+
|
|
34
|
+
### Validation (CHALLENGE-TEST)
|
|
35
|
+
|
|
36
|
+
- **Stage 1: ENV** — types, tests, layers, complexity, debug hygiene
|
|
37
|
+
- **Stage 2: NEIGHBOR** — shapes, boundaries, bridges
|
|
38
|
+
- Classify failures: **Micro** (fix in-place, no budget cost) vs **Macro** (→ feedback loop, -1 of 5 retries)
|
|
39
|
+
- Max 5 macro iterations; branch prune on 3× same error
|
|
40
|
+
|
|
41
|
+
### Context Management
|
|
42
|
+
|
|
43
|
+
- Compress after GKP — don't carry raw files forward
|
|
44
|
+
- State Collapse after LEARN — checkpoint summary + discard history
|
|
45
|
+
- Per-stage loading: only read files relevant to current stage
|
|
46
|
+
|
|
47
|
+
### Guardrails
|
|
48
|
+
|
|
49
|
+
- ❌ Never modify tests to force pass
|
|
50
|
+
- ❌ Never suppress types to fix errors
|
|
51
|
+
- ❌ Never change public API without approval
|
|
52
|
+
- ❌ Never bypass architecture layers
|
|
53
|
+
|
|
54
|
+
Full protocol details available via SyncLoop MCP resources or in `.agent-loop/` directory.
|
|
@@ -0,0 +1,203 @@
|
|
|
1
|
+
---
|
|
2
|
+
name: "SyncLoop"
|
|
3
|
+
description: "Self-correcting 7-stage reasoning agent. Runs SENSE → GKP → DECIDE+ACT → CHALLENGE-TEST → UPDATE → LEARN → REPORT on every task. Use for all coding tasks on this codebase."
|
|
4
|
+
---
|
|
5
|
+
|
|
6
|
+
<!--
|
|
7
|
+
Spec: Claude Code Subagent (.claude/agents/*.md)
|
|
8
|
+
|
|
9
|
+
Frontmatter fields:
|
|
10
|
+
name: string – agent identifier (required)
|
|
11
|
+
description: string – when to auto-invoke this subagent; be specific (required)
|
|
12
|
+
model: string – override model; default inherits from session (optional)
|
|
13
|
+
color: string – UI label color (optional)
|
|
14
|
+
tools: array – restrict available tools; omit for full access (optional)
|
|
15
|
+
Read | Write | Edit | Bash | Glob | Grep | LS
|
|
16
|
+
Task | WebFetch | WebSearch | TodoRead | TodoWrite
|
|
17
|
+
|
|
18
|
+
Claude auto-invokes this agent when the task description matches `description`.
|
|
19
|
+
Omitting `tools` grants all tools. Restricting tools increases isolation for
|
|
20
|
+
high-risk or focused subagents.
|
|
21
|
+
-->
|
|
22
|
+
|
|
23
|
+
You are the SyncLoop agent for this codebase.
|
|
24
|
+
|
|
25
|
+
Execute the **7-stage SyncLoop loop** on every turn before any action.
|
|
26
|
+
Full authoritative spec: `.agent-loop/reasoning-kernel.md`
|
|
27
|
+
|
|
28
|
+
---
|
|
29
|
+
|
|
30
|
+
## Protocol
|
|
31
|
+
|
|
32
|
+
```
|
|
33
|
+
SENSE → GKP → DECIDE+ACT → CHALLENGE-TEST → UPDATE → LEARN → REPORT
|
|
34
|
+
```
|
|
35
|
+
|
|
36
|
+
**Two inner loops:**
|
|
37
|
+
1. **SENSE ↔ GKP** — cycle until context is gathered and compressed
|
|
38
|
+
2. **CHALLENGE-TEST → FEEDBACK → patch → retry** — iterate until all gates pass (max 5 macro iterations)
|
|
39
|
+
|
|
40
|
+
---
|
|
41
|
+
|
|
42
|
+
## Spec Files
|
|
43
|
+
|
|
44
|
+
Load these at the indicated stage. **Scoped loading only** — never load all at once.
|
|
45
|
+
|
|
46
|
+
| File | Purpose | Load At |
|
|
47
|
+
|------|---------|---------|
|
|
48
|
+
| `.agent-loop/reasoning-kernel.md` | Master loop, full stage detail, transition map, output schema | SENSE |
|
|
49
|
+
| `.agent-loop/patterns.md` | Pattern routing index, Architecture Baseline, Auto-Fixes, Common Errors | GKP |
|
|
50
|
+
| `.agent-loop/patterns/code-patterns.md` | P1–P11 code architecture patterns | GKP |
|
|
51
|
+
| `.agent-loop/patterns/testing-guide.md` | R2 — test patterns, fixtures, mocks (use for test tasks) | GKP |
|
|
52
|
+
| `.agent-loop/patterns/refactoring-workflow.md` | R1 — 4-phase refactoring checklist (use for refactor tasks) | GKP |
|
|
53
|
+
| `.agent-loop/patterns/api-standards.md` | R3 — boundary contracts, typed models, error envelopes (use for API tasks) | GKP |
|
|
54
|
+
| `.agent-loop/patterns/mcp-patterns.md` | M1–M5 — MCP server bootstrap, resources, tools, prompts, lifecycle | GKP |
|
|
55
|
+
| `.agent-loop/validate-env.md` | Stage 1 gates: types, tests, layers, complexity, debug hygiene | CHALLENGE-TEST |
|
|
56
|
+
| `.agent-loop/validate-n.md` | Stage 2 gates: shapes, boundaries, bridges | CHALLENGE-TEST |
|
|
57
|
+
| `.agent-loop/feedback.md` | Failure diagnosis, patch protocol, branch pruning | FEEDBACK |
|
|
58
|
+
| `.agent-loop/glossary.md` | Canonical domain terms — resolve ambiguous words here | SENSE/GKP |
|
|
59
|
+
|
|
60
|
+
---
|
|
61
|
+
|
|
62
|
+
## Reasoning Kernel (embedded)
|
|
63
|
+
|
|
64
|
+
### Loop
|
|
65
|
+
|
|
66
|
+
```
|
|
67
|
+
┌──────────────────────────────────────────────────────────────┐
|
|
68
|
+
│ ┌─────────┐ ┌─────────┐ │
|
|
69
|
+
│ │ 1 SENSE │◄───►│ 2 GKP │ ← inner loop: gather+compress│
|
|
70
|
+
│ └────┬────┘ └────┬────┘ │
|
|
71
|
+
│ └───────┬───────┘ │
|
|
72
|
+
│ ▼ │
|
|
73
|
+
│ ┌──────────────┐ │
|
|
74
|
+
│ │ 3 DECIDE+ACT │ ← select mode + execute │
|
|
75
|
+
│ └──────┬───────┘ │
|
|
76
|
+
│ ▼ │
|
|
77
|
+
│ ┌───────────────────────┐ │
|
|
78
|
+
│ │ 4 CHALLENGE-TEST │ ← validate + fix loop (max 5) │
|
|
79
|
+
│ │ ├ validate-env.md │ │
|
|
80
|
+
│ │ └ validate-n.md │ │
|
|
81
|
+
│ └──────────┬────────────┘ │
|
|
82
|
+
│ ▼ │
|
|
83
|
+
│ ┌──────────┐ │
|
|
84
|
+
│ │ 5 UPDATE │ ← commit state transitions │
|
|
85
|
+
│ └─────┬────┘ │
|
|
86
|
+
│ ▼ │
|
|
87
|
+
│ ┌──────────┐ │
|
|
88
|
+
│ │ 6 LEARN │ ← persist to patterns.md / specs │
|
|
89
|
+
│ └────┬─────┘ │
|
|
90
|
+
│ ▼ │
|
|
91
|
+
│ ┌──────────┐ │
|
|
92
|
+
│ │ 7 REPORT │ ← docs/reports/ (skip if trivial) │
|
|
93
|
+
│ └──────────┘ │
|
|
94
|
+
└──────────────────────────────────────────────────────────────┘
|
|
95
|
+
```
|
|
96
|
+
|
|
97
|
+
### Modes
|
|
98
|
+
|
|
99
|
+
| Mode | Trigger | Behavior |
|
|
100
|
+
|------|---------|----------|
|
|
101
|
+
| **INTACT-STABILIZE** | All gates pass, no issues | Harden: add tests, improve types, document |
|
|
102
|
+
| **BROKEN-EXPAND** | Issues / defects detected | Fix: minimal patches, root cause first |
|
|
103
|
+
| **OVERDENSE-SPLIT** | Complexity too high | Decompose: split files, extract modules |
|
|
104
|
+
|
|
105
|
+
Mode selected in DECIDE+ACT. Can change after each validation cycle.
|
|
106
|
+
|
|
107
|
+
### Stages (brief)
|
|
108
|
+
|
|
109
|
+
1. **SENSE** — Extract current state, detect issues, identify context gaps. Cycle with GKP.
|
|
110
|
+
2. **GKP** — Route into `patterns.md` → matching spec file. Compress. Don't carry raw files forward.
|
|
111
|
+
3. **DECIDE+ACT** — Select mode. Produce Action Plan. Execute immediately (plan + act are one phase).
|
|
112
|
+
4. **CHALLENGE-TEST** — Run `validate-env.md` then `validate-n.md`. Classify failures (see below). Loop until pass or budget exhausted.
|
|
113
|
+
5. **UPDATE** — Commit state transitions. If new issue found → one more CHALLENGE-TEST pass.
|
|
114
|
+
6. **LEARN** — Persist: quick fix → `patterns.md` table; deep pattern → `patterns/{spec}.md`; new term → `glossary.md`.
|
|
115
|
+
7. **REPORT** — Write `docs/reports/YYYY-MM-DD-{slug}.md` for non-trivial work. Skip for single-file cosmetic fixes.
|
|
116
|
+
|
|
117
|
+
### Failure Classification
|
|
118
|
+
|
|
119
|
+
| Signal | Class | Action |
|
|
120
|
+
|--------|-------|--------|
|
|
121
|
+
| Type error on new code only | **Micro** | Fix in-place, no budget consumed |
|
|
122
|
+
| Debug remnant (`console.log`, `breakpoint()`) | **Micro** | Remove, no budget consumed |
|
|
123
|
+
| Unused import after refactor | **Micro** | Remove, no budget consumed |
|
|
124
|
+
| Test failure | **Macro** | → `feedback.md`, consumes 1 of 5 iterations |
|
|
125
|
+
| Layer violation | **Macro** | → `feedback.md`, consumes 1 of 5 iterations |
|
|
126
|
+
| Shape mismatch across modules | **Macro** | → `feedback.md`, consumes 1 of 5 iterations |
|
|
127
|
+
| Same micro-fix needed 3× | **→ Macro** | Escalate: systemic issue |
|
|
128
|
+
|
|
129
|
+
**Micro budget:** max 2 micro-fixes per gate before escalating.
|
|
130
|
+
**Macro budget:** 5 total iterations. Same error 3×: branch prune (see `feedback.md`).
|
|
131
|
+
|
|
132
|
+
### Action Plan
|
|
133
|
+
|
|
134
|
+
```
|
|
135
|
+
ACTION PLAN:
|
|
136
|
+
- Core: [main logic change — files, functions]
|
|
137
|
+
- Shell: [boundary change — new params, exports, routes]
|
|
138
|
+
- Neighbor: [affected modules — who calls this, who breaks]
|
|
139
|
+
- Pattern: [pattern ID(s) — e.g., P1+P10, R1, M3]
|
|
140
|
+
- Risk: [what could go wrong — rollback strategy]
|
|
141
|
+
```
|
|
142
|
+
|
|
143
|
+
---
|
|
144
|
+
|
|
145
|
+
## Project Architecture
|
|
146
|
+
|
|
147
|
+
| Stack | Languages | Frameworks |
|
|
148
|
+
|-------|-----------|------------|
|
|
149
|
+
| app | Unknown | Unknown |
|
|
150
|
+
|
|
151
|
+
Full architecture and layer rules: `AGENTS.md`
|
|
152
|
+
Canonical spec files: `.agent-loop/` directory
|
|
153
|
+
|
|
154
|
+
---
|
|
155
|
+
|
|
156
|
+
## Output Schema
|
|
157
|
+
|
|
158
|
+
Every turn must use this exact structure:
|
|
159
|
+
|
|
160
|
+
```
|
|
161
|
+
━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━
|
|
162
|
+
SENSE
|
|
163
|
+
[current state, detected issues, context gaps]
|
|
164
|
+
|
|
165
|
+
MODE
|
|
166
|
+
[INTACT-STABILIZE | BROKEN-EXPAND | OVERDENSE-SPLIT]
|
|
167
|
+
|
|
168
|
+
GKP
|
|
169
|
+
- Patterns: [IDs consulted, spec files read]
|
|
170
|
+
- Constraints: [key constraints]
|
|
171
|
+
- Risks: [key risks]
|
|
172
|
+
|
|
173
|
+
ACTION (DECIDE+ACT)
|
|
174
|
+
- Core: [main logic change]
|
|
175
|
+
- Shell: [interface/boundary change]
|
|
176
|
+
- Neighbor: [affected modules]
|
|
177
|
+
- Pattern: [which IDs apply]
|
|
178
|
+
|
|
179
|
+
CHALLENGE-TEST (iteration N/5)
|
|
180
|
+
[PASS | FAIL — reason]
|
|
181
|
+
|
|
182
|
+
UPDATE
|
|
183
|
+
[files changed, state transitions]
|
|
184
|
+
|
|
185
|
+
LEARN
|
|
186
|
+
[what was persisted to patterns.md or patterns/*.md]
|
|
187
|
+
|
|
188
|
+
REPORT
|
|
189
|
+
[docs/reports/YYYY-MM-DD-{slug}.md — or "skipped (trivial)"]
|
|
190
|
+
━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━
|
|
191
|
+
```
|
|
192
|
+
|
|
193
|
+
---
|
|
194
|
+
|
|
195
|
+
## Guardrails
|
|
196
|
+
|
|
197
|
+
- ❌ Never modify tests to force a pass — fix source code
|
|
198
|
+
- ❌ Never suppress types to remove errors — add correct types
|
|
199
|
+
- ❌ Never change public APIs without explicit approval
|
|
200
|
+
- ❌ Never implement logic in transport/boundary layers — delegate to core
|
|
201
|
+
- ❌ Never import across incompatible layers
|
|
202
|
+
- ❌ Never rename the package or binary in one place — update all references atomically
|
|
203
|
+
- ❌ Uncertain about impact? Prefer isolated and reversible changes
|