create-merlin-brain 3.8.2 → 3.10.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 (138) hide show
  1. package/bin/install.cjs +126 -21
  2. package/dist/server/api/client.d.ts.map +1 -1
  3. package/dist/server/api/client.js +11 -7
  4. package/dist/server/api/client.js.map +1 -1
  5. package/dist/server/cost/classifier.d.ts +22 -0
  6. package/dist/server/cost/classifier.d.ts.map +1 -0
  7. package/dist/server/cost/classifier.js +137 -0
  8. package/dist/server/cost/classifier.js.map +1 -0
  9. package/dist/server/cost/tracker.d.ts +34 -0
  10. package/dist/server/cost/tracker.d.ts.map +1 -0
  11. package/dist/server/cost/tracker.js +81 -0
  12. package/dist/server/cost/tracker.js.map +1 -0
  13. package/dist/server/lang/detector.d.ts +17 -0
  14. package/dist/server/lang/detector.d.ts.map +1 -0
  15. package/dist/server/lang/detector.js +144 -0
  16. package/dist/server/lang/detector.js.map +1 -0
  17. package/dist/server/lang/rules.d.ts +21 -0
  18. package/dist/server/lang/rules.d.ts.map +1 -0
  19. package/dist/server/lang/rules.js +70 -0
  20. package/dist/server/lang/rules.js.map +1 -0
  21. package/dist/server/server.d.ts.map +1 -1
  22. package/dist/server/server.js +74 -26
  23. package/dist/server/server.js.map +1 -1
  24. package/dist/server/tools/adaptive.d.ts.map +1 -1
  25. package/dist/server/tools/adaptive.js +2 -1
  26. package/dist/server/tools/adaptive.js.map +1 -1
  27. package/dist/server/tools/agents-index.d.ts.map +1 -1
  28. package/dist/server/tools/agents-index.js +6 -3
  29. package/dist/server/tools/agents-index.js.map +1 -1
  30. package/dist/server/tools/agents.d.ts.map +1 -1
  31. package/dist/server/tools/agents.js +10 -5
  32. package/dist/server/tools/agents.js.map +1 -1
  33. package/dist/server/tools/auto-teach.d.ts.map +1 -1
  34. package/dist/server/tools/auto-teach.js +2 -1
  35. package/dist/server/tools/auto-teach.js.map +1 -1
  36. package/dist/server/tools/behaviors.d.ts.map +1 -1
  37. package/dist/server/tools/behaviors.js +8 -4
  38. package/dist/server/tools/behaviors.js.map +1 -1
  39. package/dist/server/tools/config-sync.d.ts.map +1 -1
  40. package/dist/server/tools/config-sync.js +8 -4
  41. package/dist/server/tools/config-sync.js.map +1 -1
  42. package/dist/server/tools/context.d.ts.map +1 -1
  43. package/dist/server/tools/context.js +66 -7
  44. package/dist/server/tools/context.js.map +1 -1
  45. package/dist/server/tools/cost.d.ts +7 -0
  46. package/dist/server/tools/cost.d.ts.map +1 -0
  47. package/dist/server/tools/cost.js +53 -0
  48. package/dist/server/tools/cost.js.map +1 -0
  49. package/dist/server/tools/discoveries.d.ts.map +1 -1
  50. package/dist/server/tools/discoveries.js +8 -11
  51. package/dist/server/tools/discoveries.js.map +1 -1
  52. package/dist/server/tools/lite.d.ts.map +1 -1
  53. package/dist/server/tools/lite.js +8 -4
  54. package/dist/server/tools/lite.js.map +1 -1
  55. package/dist/server/tools/project.d.ts.map +1 -1
  56. package/dist/server/tools/project.js +14 -7
  57. package/dist/server/tools/project.js.map +1 -1
  58. package/dist/server/tools/route.d.ts.map +1 -1
  59. package/dist/server/tools/route.js +145 -31
  60. package/dist/server/tools/route.js.map +1 -1
  61. package/dist/server/tools/sights-index.d.ts.map +1 -1
  62. package/dist/server/tools/sights-index.js +4 -2
  63. package/dist/server/tools/sights-index.js.map +1 -1
  64. package/dist/server/tools/smart-route.d.ts +12 -0
  65. package/dist/server/tools/smart-route.d.ts.map +1 -0
  66. package/dist/server/tools/smart-route.js +156 -0
  67. package/dist/server/tools/smart-route.js.map +1 -0
  68. package/dist/server/tools/verification.d.ts.map +1 -1
  69. package/dist/server/tools/verification.js +2 -1
  70. package/dist/server/tools/verification.js.map +1 -1
  71. package/files/agents/code-organization-supervisor.md +1 -0
  72. package/files/agents/context-guardian.md +1 -0
  73. package/files/agents/docs-keeper.md +1 -0
  74. package/files/agents/dry-refactor.md +1 -0
  75. package/files/agents/elite-code-refactorer.md +1 -0
  76. package/files/agents/hardening-guard.md +1 -0
  77. package/files/agents/implementation-dev.md +1 -0
  78. package/files/agents/merlin-api-designer.md +1 -0
  79. package/files/agents/merlin-codebase-mapper.md +4 -0
  80. package/files/agents/merlin-debugger.md +1 -0
  81. package/files/agents/merlin-executor.md +1 -0
  82. package/files/agents/merlin-frontend.md +1 -0
  83. package/files/agents/merlin-integration-checker.md +1 -0
  84. package/files/agents/merlin-migrator.md +1 -0
  85. package/files/agents/merlin-milestone-auditor.md +1 -0
  86. package/files/agents/merlin-performance.md +1 -0
  87. package/files/agents/merlin-planner.md +1 -0
  88. package/files/agents/merlin-researcher.md +4 -0
  89. package/files/agents/merlin-reviewer.md +1 -0
  90. package/files/agents/merlin-security.md +1 -0
  91. package/files/agents/merlin-verifier.md +1 -0
  92. package/files/agents/merlin-work-verifier.md +1 -0
  93. package/files/agents/merlin.md +19 -3
  94. package/files/agents/ops-railway.md +1 -0
  95. package/files/agents/orchestrator-retrofit.md +1 -0
  96. package/files/agents/product-spec.md +1 -0
  97. package/files/agents/remotion.md +1 -0
  98. package/files/agents/system-architect.md +1 -0
  99. package/files/agents/tests-qa.md +1 -0
  100. package/files/commands/merlin/help.md +11 -0
  101. package/files/commands/merlin/loop-recipes.md +73 -0
  102. package/files/hooks/agent-sync.sh +3 -0
  103. package/files/hooks/check-file-size.sh +12 -0
  104. package/files/hooks/config-change.sh +43 -0
  105. package/files/hooks/instructions-loaded.sh +34 -0
  106. package/files/hooks/session-start.sh +52 -2
  107. package/files/hooks/worktree-create.sh +44 -0
  108. package/files/hooks/worktree-remove.sh +36 -0
  109. package/files/loop/lib/agents.sh +3 -0
  110. package/files/loop/lib/blend-handoff.sh +3 -0
  111. package/files/loop/lib/blend-learn.sh +3 -0
  112. package/files/loop/lib/blend-parallel.sh +3 -0
  113. package/files/loop/lib/blend-verify.sh +3 -0
  114. package/files/loop/lib/blend.sh +3 -0
  115. package/files/loop/lib/boot.sh +3 -0
  116. package/files/loop/lib/context.sh +3 -0
  117. package/files/loop/lib/discuss.sh +3 -0
  118. package/files/loop/lib/modes.sh +3 -0
  119. package/files/loop/lib/progress.sh +3 -0
  120. package/files/loop/lib/safety.sh +3 -0
  121. package/files/loop/lib/session-end.sh +3 -0
  122. package/files/loop/lib/sights.sh +3 -0
  123. package/files/loop/lib/state.sh +3 -0
  124. package/files/loop/lib/teams.sh +3 -0
  125. package/files/loop/lib/timeout.sh +3 -0
  126. package/files/loop/lib/tui.sh +3 -0
  127. package/files/loop/lib/workflow-gen.sh +3 -0
  128. package/files/loop/lib/workflow-run.sh +3 -0
  129. package/files/loop/lib/workflow.sh +3 -0
  130. package/files/loop/merlin-loop.sh +3 -0
  131. package/files/loop/merlin-session.sh +3 -0
  132. package/package.json +2 -1
  133. package/rules/go.md +38 -0
  134. package/rules/java.md +36 -0
  135. package/rules/python.md +38 -0
  136. package/rules/rust.md +34 -0
  137. package/rules/swift.md +35 -0
  138. package/rules/typescript.md +38 -0
@@ -0,0 +1,38 @@
1
+ # Python Coding Rules
2
+
3
+ ## Type Hints
4
+ - Type hints on all function signatures — parameters and return types
5
+ - Use `from __future__ import annotations` for forward references
6
+ - Prefer concrete types (`list[str]`) over generic aliases (`List[str]`) for Python 3.9+
7
+ - `Optional[X]` → `X | None` (Python 3.10+ union syntax preferred)
8
+
9
+ ## Data Structures
10
+ - Dataclasses (`@dataclass`) for plain data containers — avoid raw dicts for structured data
11
+ - Pydantic for validated data (API payloads, configs) — use `model_validator` not `__init__`
12
+ - No mutable default arguments: `def foo(items=None): items = items or []` pattern
13
+ - Prefer `TypedDict` over plain `dict` when shape is known and Pydantic is overkill
14
+
15
+ ## Strings & Output
16
+ - f-strings for all string interpolation — never `%` formatting or `.format()` for new code
17
+ - Multi-line strings: use triple-quoted f-strings, not concatenation
18
+ - `str.join()` for building strings from lists — avoid `+=` in loops
19
+
20
+ ## File & Resource Handling
21
+ - `pathlib.Path` for all filesystem paths — never `os.path.join` in new code
22
+ - Context managers (`with`) for files, network connections, locks — never manual `.close()`
23
+ - `tempfile` module for temporary files — never hardcode `/tmp/`
24
+
25
+ ## Functions & Classes
26
+ - Single responsibility per function; >20 lines is a signal to refactor
27
+ - Class methods that don't use `self` should be `@staticmethod` or module-level functions
28
+ - `__slots__` on data classes where performance matters
29
+ - Abstract base classes (`ABC`) to define interfaces; avoid duck-typing where contracts matter
30
+
31
+ ## Error Handling
32
+ - Specific exceptions over `except Exception` — catch the narrowest type possible
33
+ - Custom exception classes for domain errors (inherit from `Exception` with a clear name)
34
+ - `logging` module, not `print()` — use structured log fields
35
+
36
+ ## Async
37
+ - `asyncio.gather()` for concurrent coroutines — avoid sequential `await` in a loop
38
+ - Mark I/O-bound functions `async def`; CPU-bound code stays sync (use `ProcessPoolExecutor`)
package/rules/rust.md ADDED
@@ -0,0 +1,34 @@
1
+ # Rust Coding Rules
2
+
3
+ ## Ownership & Borrowing
4
+ - Ownership over reference counting — prefer passing values or borrows over `Rc`/`Arc`
5
+ - `Arc<Mutex<T>>` for shared mutable state across threads; document why sharing is needed
6
+ - Avoid cloning in hot paths — profile before adding `.clone()` calls
7
+ - Return owned values from functions that create data; accept borrows in functions that read
8
+
9
+ ## Error Handling
10
+ - `Result<T, E>` for all fallible operations — never panic in library code
11
+ - Custom error types with `thiserror` for libraries; `anyhow` for application binaries
12
+ - `?` operator for propagation — avoid `unwrap()` in production code; prefer `expect("reason")`
13
+ - Map errors at boundaries: `map_err(|e| MyError::Database(e))`
14
+
15
+ ## Types & Traits
16
+ - Derive traits liberally: `#[derive(Debug, Clone, PartialEq, Eq, Hash, Serialize, Deserialize)]`
17
+ - `impl` blocks immediately after their `struct`/`enum` definition in the same file
18
+ - Prefer `&str` over `String` in function parameters (accepts both literals and owned strings)
19
+ - `Into<T>` / `From<T>` for ergonomic conversions; implement `Display` for user-facing types
20
+
21
+ ## Structs & Enums
22
+ - Exhaustive `match` on enums — no `_ =>` catch-all unless truly irrelevant variants exist
23
+ - Newtype pattern (`struct UserId(u64)`) to prevent mixing domain IDs
24
+ - Builder pattern for structs with many optional fields (derive with `typed-builder`)
25
+
26
+ ## Async
27
+ - `tokio` for async runtime; `async-trait` for async in trait methods
28
+ - `tokio::join!` / `tokio::try_join!` for concurrent futures
29
+ - Avoid blocking calls inside async context — use `tokio::task::spawn_blocking`
30
+
31
+ ## Safety
32
+ - No `unsafe` without a `// SAFETY:` comment explaining the invariant
33
+ - Keep `unsafe` blocks as small as possible; encapsulate behind a safe API
34
+ - Prefer `Vec` and slices over raw pointer arithmetic
package/rules/swift.md ADDED
@@ -0,0 +1,35 @@
1
+ # Swift Coding Rules
2
+
3
+ ## Concurrency (Swift 6)
4
+ - `async`/`await` for all asynchronous operations — no completion handler callbacks in new code
5
+ - Actors for shared mutable state: `actor MyService { ... }`
6
+ - `@MainActor` on UI-bound types and functions
7
+ - `Sendable` conformance required for types crossing actor boundaries — use `@unchecked Sendable` sparingly with a justification comment
8
+ - `async let` for independent concurrent work; `withTaskGroup` for dynamic concurrency
9
+
10
+ ## Types & Values
11
+ - Value types (`struct`, `enum`) by default — use `class` only when reference semantics are required (identity, inheritance, Obj-C interop)
12
+ - Protocol-oriented design: define capabilities as protocols, extend with default implementations
13
+ - `enum` with associated values for discriminated unions instead of subclassing
14
+ - Avoid `@objc` and `NSObject` subclasses unless required for interoperability
15
+
16
+ ## Optionals & Safety
17
+ - `guard` for early returns when preconditions fail — keeps happy path unindented
18
+ - Never force-unwrap (`!`) except in tests or `@IBOutlet` — use `guard let` or `if let`
19
+ - `??` for default values on optionals; avoid chained optionals deeper than 2 levels
20
+ - Mark parameters optional (`T?`) only when absence carries meaning; prefer overloads otherwise
21
+
22
+ ## Memory Management
23
+ - `weak` references to break retain cycles (delegates, closures capturing self)
24
+ - `unowned` only when the object is guaranteed to outlive the reference — prefer `weak` when uncertain
25
+ - Use `[weak self]` captures in closures stored beyond the current scope
26
+
27
+ ## Protocols & Extensions
28
+ - Small, focused protocols (Interface Segregation) — prefer many narrow protocols over one wide one
29
+ - Extensions to add protocol conformances, keeping the type definition clean
30
+ - `Codable` for serialisable types; `CodingKeys` enum to map non-Swift naming
31
+
32
+ ## Style
33
+ - `let` by default; `var` only when mutation is needed
34
+ - 4-space indentation, Allman-style braces
35
+ - Prefer named parameters at call sites for clarity
@@ -0,0 +1,38 @@
1
+ # TypeScript Coding Rules
2
+
3
+ ## Type Safety
4
+ - Enable strict mode — no `any` without an explicit justification comment
5
+ - Prefer `unknown` over `any` for values of uncertain type; narrow with type guards
6
+ - Use `satisfies` operator for type-safe literal assignments
7
+ - Avoid type assertions (`as Foo`) unless interfacing with untyped third-party code
8
+
9
+ ## Variables & Functions
10
+ - `const` by default, `let` only when reassignment is necessary — never `var`
11
+ - `async`/`await` over raw Promise chains; avoid `.then()` chains longer than 2 steps
12
+ - Explicit return types on exported functions; internal functions may infer
13
+ - Exhaustive switch/case: add a `default` that asserts `never` to catch future enum additions
14
+
15
+ ## Interfaces & Types
16
+ - `interface` for object shapes (extendable, declaration-merged)
17
+ - `type` for unions, intersections, primitives, and mapped types
18
+ - No empty interfaces (`interface Foo {}`); use `Record<never, never>` or a comment
19
+
20
+ ## Error Handling
21
+ - Typed errors: extend `Error` with named subclasses for domain errors
22
+ - No bare `catch (e) {}` — always log or rethrow with context
23
+ - Use `Result<T, E>` patterns for expected failure paths (avoid throw-for-control-flow)
24
+ - Wrap third-party calls in try/catch at the boundary, not deep in business logic
25
+
26
+ ## Imports & Modules
27
+ - Use named exports; avoid default exports (harder to rename/trace)
28
+ - Group imports: external packages → internal modules → relative paths (blank line between)
29
+ - Barrel files (`index.ts`) only at module boundaries, not within a feature folder
30
+
31
+ ## Async & Concurrency
32
+ - `Promise.all` for independent async operations (don't serialize what can parallelize)
33
+ - Avoid `async` functions that never `await` anything
34
+ - Always handle rejected promises — no floating promise anti-pattern
35
+
36
+ ## Null Safety
37
+ - Prefer optional chaining (`?.`) and nullish coalescing (`??`) over manual null checks
38
+ - Avoid optional properties (`foo?: string`) on data types; use `| null` for explicitness