@oleksandr.rudnychenko/sync_loop 0.2.1

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.
@@ -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
+ "syncloop": {
15
+ "command": "npx",
16
+ "args": ["-y", "syncloop"]
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 syncloop 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.