@cassiomc1/forgeloop 0.1.0

This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
Files changed (63) hide show
  1. package/.cursor/rules/project-loop.mdc +18 -0
  2. package/.forgeloop/.gitignore +2 -0
  3. package/.github/copilot-instructions.md +16 -0
  4. package/AGENTS.md +16 -0
  5. package/AGENT_COMPATIBILITY.md +147 -0
  6. package/CLAUDE.md +14 -0
  7. package/CONTRACT_COVERAGE.md +27 -0
  8. package/DELEGATION_PROTOCOL.md +91 -0
  9. package/ENG/accessibility-eng.md +155 -0
  10. package/ENG/clean-code-eng.md +223 -0
  11. package/ENG/design-code-eng.md +511 -0
  12. package/ENG/games-code-design-web-eng.md +751 -0
  13. package/ENG/perf-code-eng.md +441 -0
  14. package/ENG/premium-sites-studio-eng.md +320 -0
  15. package/ENG/sec-code-eng.md +706 -0
  16. package/ENG/test-code-eng.md +257 -0
  17. package/EXECUTION_STATE.md +107 -0
  18. package/GUIDE_ROUTER.md +274 -0
  19. package/LICENSE +21 -0
  20. package/LICENSE-DOCS.md +13 -0
  21. package/LOOP_ENGINEERING.md +551 -0
  22. package/LOOP_SYSTEM_DESIGN.md +394 -0
  23. package/ORCHESTRATOR_INTEGRATION.md +106 -0
  24. package/PROJECT_PROFILE.md +124 -0
  25. package/QUALITY_SCORECARD.md +54 -0
  26. package/README.md +492 -0
  27. package/TERMINOLOGY.md +21 -0
  28. package/THIRD_PARTY_NOTICES.md +129 -0
  29. package/THREAT_MODEL.md +35 -0
  30. package/package.json +51 -0
  31. package/schemas/delegated-result.schema.json +33 -0
  32. package/schemas/evidence.schema.json +15 -0
  33. package/schemas/execution-receipt.schema.json +46 -0
  34. package/schemas/routing-input.schema.json +17 -0
  35. package/schemas/routing-result.schema.json +17 -0
  36. package/schemas/task-brief.schema.json +24 -0
  37. package/schemas/work-state.schema.json +46 -0
  38. package/src/cli.js +341 -0
  39. package/src/commands/clear-state.js +11 -0
  40. package/src/commands/doctor.js +165 -0
  41. package/src/commands/init.js +42 -0
  42. package/src/commands/inspect.js +17 -0
  43. package/src/commands/route.js +32 -0
  44. package/src/commands/status.js +29 -0
  45. package/src/commands/update.js +109 -0
  46. package/src/commands/validate-protocol.js +133 -0
  47. package/src/commands/validate-receipt.js +19 -0
  48. package/src/commands/validate-state.js +30 -0
  49. package/src/core/agent-support.js +89 -0
  50. package/src/core/conformance.js +133 -0
  51. package/src/core/delegation.js +283 -0
  52. package/src/core/evidence.js +56 -0
  53. package/src/core/filesystem.js +122 -0
  54. package/src/core/inspect.js +115 -0
  55. package/src/core/json-safety.js +54 -0
  56. package/src/core/manifest.js +75 -0
  57. package/src/core/protocol.js +81 -0
  58. package/src/core/receipt.js +129 -0
  59. package/src/core/repository.js +19 -0
  60. package/src/core/router.js +296 -0
  61. package/src/core/schema-validation.js +179 -0
  62. package/src/core/templates.js +56 -0
  63. package/src/core/work-state.js +471 -0
@@ -0,0 +1,274 @@
1
+ # Guide Router
2
+
3
+ > Select technical context for [Loop Engineering](./LOOP_ENGINEERING.md). This file decides **which** guides to consult; each guide defines **how** to work in its domain.
4
+
5
+ ## Selection contract
6
+
7
+ 1. Read the request, the nearest repository instructions, and [PROJECT_PROFILE.md](./PROJECT_PROFILE.md).
8
+ 2. Confirm the actual stack from manifests and configuration.
9
+ 3. Identify the surfaces that will change.
10
+ 4. Activate the primary guide and every complementary guide required by the risks.
11
+ 5. Locate relevant headings and keywords before loading a long guide.
12
+ 6. Load only the sections needed for the current task.
13
+ 7. Reassess the route if the scope changes during execution.
14
+
15
+ Activate a guide from a combination of intent, files, and risk. A word in documentation, a lockfile, or an example does not by itself prove a stack or activate a guide.
16
+
17
+ Useful questions:
18
+
19
+ - What behavior or artifact will change?
20
+ - Is there a human interface, sensitive data, critical path, or external system?
21
+ - Which files will change?
22
+ - Which checks will demonstrate the result?
23
+ - Did the user explicitly request a standard or domain?
24
+
25
+ ## Canonical catalog
26
+
27
+ | ID | Guide | Responsibility |
28
+ | --- | --- | --- |
29
+ | `premium` | [Premium websites](./ENG/premium-sites-studio-eng.md) | End-to-end delivery of high-quality websites and web experiences |
30
+ | `clean` | [Clean code](./ENG/clean-code-eng.md) | Structure, readability, observability, and maintenance |
31
+ | `test` | [Testing](./ENG/test-code-eng.md) | Risk-driven verification strategy and tooling |
32
+ | `security` | [Security](./ENG/sec-code-eng.md) | Web, API, mobile, desktop, data, and supply-chain security |
33
+ | `design` | [Design](./ENG/design-code-eng.md) | Visual direction, UX, motion, and perceived performance |
34
+ | `performance` | [Performance](./ENG/perf-code-eng.md) | Measurement, diagnosis, budgets, and optimization |
35
+ | `accessibility` | [Accessibility](./ENG/accessibility-eng.md) | WCAG, keyboard access, focus, semantics, and assistive technology |
36
+ | `games` | [Web games](./ENG/games-code-design-web-eng.md) | Architecture and operation of 2D, 3D, and procedural web games |
37
+
38
+ ## Domain rules
39
+
40
+ ### `clean` — code and structure
41
+
42
+ **Activate when:** creating or modifying code, fixing a bug, refactoring, changing architecture, reviewing quality, or producing development instructions.
43
+
44
+ **Do not activate merely because:** documentation contains code snippets but no software behavior changes.
45
+
46
+ **Usually combine with:** `test`; add `security`, `performance`, `design`, or `accessibility` according to the affected surface.
47
+
48
+ Locate relevant sections first:
49
+
50
+ ```bash
51
+ rg -n '^## (Style|Comments|Tests|Dependencies|Structure|Logging|Debugging)|responsibility|typing|errors' ENG/clean-code-eng.md
52
+ ```
53
+
54
+ **Expected evidence:** a small readable diff, coherent interfaces, error handling, tests, and official checks.
55
+
56
+ ### `test` — verification strategy
57
+
58
+ **Activate when:** behavior changes, a bug is fixed, an integration or release changes, executable configuration changes, or QA is requested.
59
+
60
+ **Do not activate merely because:** prose names a testing framework without executing or changing software.
61
+
62
+ **Usually combine with:** every guide that produces behavior; use the domain to choose test levels.
63
+
64
+ ```bash
65
+ rg -n '^## |risk|regression|unit|integration|E2E|accessibility|load|CI' ENG/test-code-eng.md
66
+ ```
67
+
68
+ **Expected evidence:** a RED reproduction when applicable, a GREEN targeted check, and proportional regression coverage.
69
+
70
+ ### `security` — trust and external surfaces
71
+
72
+ **Activate when:** authentication, authorization, untrusted input, APIs, databases, uploads, secrets, dependencies, CI/CD, mobile or desktop platforms, cryptography, personal data, payments, or publication are involved.
73
+
74
+ **Do not activate merely because:** a reference mentions OWASP or security without changing a trust surface.
75
+
76
+ **Usually combine with:** `clean` and `test`; add `performance` when controls affect latency or availability.
77
+
78
+ ```bash
79
+ rg -n '^## |authentication|authorization|upload|SSRF|CSP|OAuth|JWT|secrets|supply chain|mobile|desktop' ENG/sec-code-eng.md
80
+ ```
81
+
82
+ **Expected evidence:** explicit trust boundaries, server-side validation, least privilege, no secrets in Git, and negative tests.
83
+
84
+ ### `performance` — measurable cost
85
+
86
+ **Activate when:** the request involves latency, scale, a critical path, rendering, bundles, databases, networking, memory, battery, load, Web Vitals, FPS, or a budget.
87
+
88
+ **Do not activate merely because:** every task could theoretically be faster. Avoid speculative optimization without a risk or metric.
89
+
90
+ **Usually combine with:** the main domain guide and `test`.
91
+
92
+ ```bash
93
+ rg -n '^## |baseline|budget|p75|p95|Web Vitals|profil|database|mobile|desktop|load' ENG/perf-code-eng.md
94
+ ```
95
+
96
+ **Expected evidence:** a baseline, a hypothesis, comparable before-and-after measurement, and no functional regression.
97
+
98
+ ### `design` — interface and experience
99
+
100
+ **Activate when:** creating, redesigning, or reviewing UI, layout, components, visual identity, motion, responsive behavior, mobile or desktop apps, or premium experiences.
101
+
102
+ **Do not activate merely because:** an interface-free API uses the word "design" in architecture documentation.
103
+
104
+ **Usually combine with:** `accessibility`, `test`, and `performance`; use `security` for forms, authentication, and external content.
105
+
106
+ ```bash
107
+ rg -n '^## |palette|typography|layout|mobile|motion|components|checklist' ENG/design-code-eng.md
108
+ ```
109
+
110
+ **Expected evidence:** complete states, coherent hierarchy, responsive behavior, visual validation, and fallbacks for optional enhancements.
111
+
112
+ ### `accessibility` — inclusive completion
113
+
114
+ **Activate when:** work affects an interface, audiovisual content, navigation, forms, interactive components, games, mobile or desktop apps, or task completion.
115
+
116
+ **Do not activate merely because:** an internal service transports normalized data and changes neither user-facing content nor a consumed contract.
117
+
118
+ **Usually combine with:** `design` and `test`; add the interface domain guide.
119
+
120
+ ```bash
121
+ rg -n '^## |WCAG|keyboard|focus|contrast|ARIA|screen reader|motion|Definition of Done' ENG/accessibility-eng.md
122
+ ```
123
+
124
+ **Expected evidence:** semantics, keyboard operation, focus, contrast, zoom and reflow, reduced motion, and compatible manual or automated tests.
125
+
126
+ ### `premium` — complete website production
127
+
128
+ **Activate when:** creating or comprehensively reviewing a landing page, institutional site, portfolio, campaign, or web experience that requires studio-quality delivery.
129
+
130
+ **Do not activate when:** the task is an isolated component, an API, or technical maintenance without a complete website process.
131
+
132
+ **Usually combine with:** `design`, `accessibility`, `clean`, `test`, `security`, and `performance`.
133
+
134
+ ```bash
135
+ rg -n '^## [0-9]+\.|brief|content|direction|design system|implementation|quality|launch' ENG/premium-sites-studio-eng.md
136
+ ```
137
+
138
+ **Expected evidence:** approved strategy, content, direction, production, quality, launch, and operation gates.
139
+
140
+ ### `games` — web game architecture and operation
141
+
142
+ **Activate when:** designing, implementing, testing, or operating a 2D or 3D web game, procedural generation, game loops, assets, input, multiplayer, or game distribution.
143
+
144
+ **Do not activate when:** "game" means lightweight gamification in an ordinary interface; use the UI and code guides instead.
145
+
146
+ **Usually combine with:** `clean`, `test`, `security`, `performance`, and `accessibility`; add `design` for UI and visual direction.
147
+
148
+ ```bash
149
+ rg -n '^## |game loop|procedural|input|assets|audio|multiplayer|WASM|PWA|CI/CD' ENG/games-code-design-web-eng.md
150
+ ```
151
+
152
+ **Expected evidence:** verifiable simulation, determinism when promised, capability fallbacks, budgets, accessibility, and release gates.
153
+
154
+ ## Work-type matrix
155
+
156
+ | Work | Primary guide | Common complements | Exclude when |
157
+ | --- | --- | --- | --- |
158
+ | Documentation change | Relevant domain | `test` only for executable examples or commands | No software behavior exists |
159
+ | Code or bug without UI | `clean` | `test`; risk may add `security` or `performance` | The surface is unchanged |
160
+ | Backend, API, or data | `clean` | `test`, `security`; `performance` for a critical path | That layer does not exist |
161
+ | Web, mobile, or desktop UI | `design` | `accessibility`, `clean`, `test`; risk defines the rest | Users cannot observe the change |
162
+ | Complete website | `premium` | `design`, `accessibility`, `clean`, `test`, `security`, `performance` | The deliverable is not a complete site |
163
+ | Web game | `games` | `clean`, `test`, `security`, `performance`, `accessibility`; `design` with UI | The product is not a game |
164
+ | HTML video or motion | `design` | `accessibility`, `performance`, `test`, `security` | There is no audiovisual composition |
165
+ | Infrastructure or CI/CD | `security` | `test`; `performance` when availability or cost changes | The change is non-executable prose |
166
+
167
+ HyperFrames is optional and may be used only when requested or already available and appropriate. A reference to it does not authorize installation.
168
+
169
+ ## Deterministic route contract
170
+
171
+ The active agent may classify natural language, but it must pass declared
172
+ signals to the deterministic evaluator in `src/core/router.js`. The evaluator
173
+ does not parse natural language, call a model, or infer a stack from a word in
174
+ the repository.
175
+
176
+ The first routing contract is versioned as `schemaVersion: 1`. It accepts:
177
+
178
+ - `workType`: `documentation`, `code`, `bug`, `refactor`, `backend`, `api`,
179
+ `api-auth`, `complete-website`, `mobile-ui`, `web-game`, `html-video`,
180
+ `infrastructure`, `security-review`, `performance`, `accessibility`,
181
+ `test-only`, `dependency-update`, or `release`;
182
+ - `surfaces`: `ui`, `forms`, `api`, `auth`, `data`, `database`, `mobile`,
183
+ `desktop`, `game`, `video`, `ci`, `config`, or `critical-path`;
184
+ - `risks`: `untrusted-input`, `personal-data`, `secrets`, `external-service`,
185
+ `publication`, `critical-path`, `performance`, or `accessibility`;
186
+ - `platforms`: `web`, `mobile`, `desktop`, `server`, `ci`, or
187
+ `cross-platform`;
188
+ - optional boolean `behaviorChange` and `executableChange` signals.
189
+
190
+ Rule precedence is deterministic: the work type establishes the primary
191
+ closure; affected surfaces add mandatory complements; risks add security,
192
+ performance, or accessibility; executable/behavior changes add clean and
193
+ test; required rules win over optional exclusions; and the evaluator preserves
194
+ canonical insertion order. Unknown or duplicate signals fail with a routing
195
+ error.
196
+
197
+ Every selected guide has stable reason codes such as
198
+ `WORK_COMPLETE_WEBSITE`, `SURFACE_UI`, `RISK_UNTRUSTED_INPUT`, and
199
+ `CHANGE_EXECUTABLE_CONFIG`. Exclusions use stable codes such as
200
+ `NO_TRUST_BOUNDARY` and `NO_MEASURABLE_PERFORMANCE_RISK`. Documentation-only
201
+ input records `DOCUMENTATION_DOMAIN_GUIDE_REQUIRED` instead of activating
202
+ technical guides automatically.
203
+
204
+ Platform signals are contextual, not automatic guide activators:
205
+
206
+ | Platform | Semantic effect | Stable reason |
207
+ | --- | --- | --- |
208
+ | `mobile` | With an existing UI surface, reinforces design/accessibility and adds performance constraints. | `PLATFORM_MOBILE` |
209
+ | `desktop` | With an existing UI surface, reinforces design/accessibility. | `PLATFORM_DESKTOP` |
210
+ | `server` | With `auth`, reinforces the trust boundary and adds testing. | `PLATFORM_SERVER` |
211
+ | `ci` | With `executableChange: true`, adds security to the existing change checks. | `PLATFORM_CI` |
212
+ | `web` | Informational-only; surface and risk signals remain authoritative. | — |
213
+ | `cross-platform` | Informational-only; it never selects a guide by itself. | — |
214
+
215
+ Equivalent normalized signal arrays produce identical JSON. A valid route has
216
+ no duplicate guides, a reason for every selected guide, an exclusion reason
217
+ for every excluded guide, no selected/excluded overlap, and a primary that is
218
+ either null or selected. The local `validate-protocol` command checks
219
+ cross-artifact relationships without executing task data.
220
+
221
+ Negative routing guarantees:
222
+
223
+ - a documentation mention of OAuth does not activate `security`;
224
+ - a backend refactor does not activate `design` or `accessibility`;
225
+ - static UI copy does not activate `security` without a trust-boundary signal;
226
+ - a package file alone does not prove that Node is an affected task surface;
227
+ - an explicit executable-change signal adds `clean` and `test` even when the
228
+ semantic work type is documentation.
229
+
230
+ ## Verifiable scenarios
231
+
232
+ Route comments are stable contracts for the validator. They contain IDs, not loading instructions.
233
+
234
+ ### Premium landing page
235
+
236
+ <!-- route:landing-page-premium=premium,design,accessibility,clean,test,security,performance -->
237
+
238
+ Verify the brief, content, responsive UI, states, WCAG coverage, build, tests, Web Vitals, forms, analytics, launch, and operation.
239
+
240
+ ### Authenticated API
241
+
242
+ <!-- route:api-auth=clean,test,security,performance -->
243
+
244
+ Verify HTTP contracts, input validation, authentication and authorization, negative tests, persistence, rate limiting, observability, and critical-path latency.
245
+
246
+ ### Bug without UI
247
+
248
+ <!-- route:bug-without-ui=clean,test -->
249
+
250
+ Start with reproduction and a regression test. Activate `security` or `performance` only if the cause or fix reaches those surfaces.
251
+
252
+ ### Mobile app with UI
253
+
254
+ <!-- route:app-mobile-ui=clean,test,design,accessibility,security,performance -->
255
+
256
+ Verify the actual native or cross-platform target, states, gestures, keyboard and focus behavior, accessibility, storage, networking, battery, memory, and tests on a compatible target.
257
+
258
+ ### Multiplayer web game
259
+
260
+ <!-- route:game-web-multiplayer=games,clean,test,security,performance,accessibility,design -->
261
+
262
+ Verify the game loop, authoritative server, reconciliation, input, assets, fallbacks, budgets, accessibility, security, and release process.
263
+
264
+ ### Documentation
265
+
266
+ <!-- route:documentation=domain -->
267
+
268
+ `domain` means the single domain guide implicated by the change. Verify Markdown, links, paths, commands, and examples.
269
+
270
+ ## Route changes
271
+
272
+ If investigation reveals a new surface, update the guide set before editing that area. Record only the concise reason; do not create a versioned task log.
273
+
274
+ If an applicable guide is missing or inaccessible, use conservative defaults, do not invent its content, and disclose the limitation in the delivery.
package/LICENSE ADDED
@@ -0,0 +1,21 @@
1
+ MIT License
2
+
3
+ Copyright (c) 2026 Cassio
4
+
5
+ Permission is hereby granted, free of charge, to any person obtaining a copy
6
+ of this software and associated documentation files (the "Software"), to deal
7
+ in the Software without restriction, including without limitation the rights
8
+ to use, copy, modify, merge, publish, distribute, sublicense, and/or sell
9
+ copies of the Software, and to permit persons to whom the Software is
10
+ furnished to do so, subject to the following conditions:
11
+
12
+ The above copyright notice and this permission notice shall be included in all
13
+ copies or substantial portions of the Software.
14
+
15
+ THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR
16
+ IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY,
17
+ FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE
18
+ AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER
19
+ LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM,
20
+ OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE
21
+ SOFTWARE.
@@ -0,0 +1,13 @@
1
+ # Documentation license
2
+
3
+ Original documentation in this repository is offered under the Creative
4
+ Commons Attribution 4.0 International license (CC BY 4.0):
5
+
6
+ <https://creativecommons.org/licenses/by/4.0/>
7
+
8
+ That license permits sharing, adaptation, and commercial use when appropriate
9
+ credit, a link to the license, and an indication of changes are provided.
10
+
11
+ This notice applies only to documentation for which the repository owner has
12
+ the necessary rights. Adapted or externally sourced material remains subject
13
+ to the terms and attribution recorded in `THIRD_PARTY_NOTICES.md`.