Skip to content
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension


Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
18 changes: 18 additions & 0 deletions .gitignore
Original file line number Diff line number Diff line change
Expand Up @@ -4,6 +4,8 @@ node_modules/
!tools/build/
.dart_tool/

coverage/

# Generated JS files from dart compile js
*.js.deps
*.js.map
Expand All @@ -16,3 +18,19 @@ website/src/api/
website/.dart-doc-temp/

examples/frontend/coverage/

*.mjs

examples/too_many_cooks_vscode_extension/.vscode-test/user-data/

examples/too_many_cooks_vscode_extension/.vscode-test/vscode-darwin-arm64-1.106.3/

*.db

*.db-shm

*.db-wal

*.vsix

examples/too_many_cooks_vscode_extension/.vscode-test/
52 changes: 24 additions & 28 deletions AGENTS.md
Original file line number Diff line number Diff line change
Expand Up @@ -2,40 +2,39 @@

This is a project for Dart packages to be consumed on Node for building node-based apps with the Dart

MANDATORY: TOO MANY COOKS
- check your messages regularly
- lock files with too many cooks before editing, and unlock afterwards
- do not edit files that others have locked up
- always signal your intent to other agents
- If you are coordinator, keep delegating until the grande scheme has been achieved
- If you are not coordinator, don't stop and keep asking for something to do
- Routinely clean up expired locks
- If you find yourself with nothing to do, check someone else's plan and help them

# Rules
- All Dart. Absolutely minimal JS
- Use async/await. Do not use `.then`
- NO DUPLICATION. Move files, code elements instead of copying them. Search for elements before adding them. HIGHEST PRIORITY. PRIORITIZE THIS OVER ALL ELSE!!
- Return Result<T,E> from the nadz library for any function that could throw an exception <- CRITICAL!!!
- Prefer typedef records with named fields instead of classes for data (structural typing). This mimics Typescript better
- Return Result<T,E> from the nadz library for any function that could throw an exception. NO THROWING EXCEPTIONS.
- Don't make consecutive log calls. Use string interpolation
- Avoid casting!!! [! `as` `late`] are all ILLEGAL!!! U
- Use pattern matching switch expressions or ternaries. The exceptional case is if inside arrays and maps because these are declarative and not imperaative.
- All packages MUST have austerity installed for linting and nadz for Result<T,E> types
- Fix ALL lint errors
- Do not expose raw JS objects like JSAny to the higher levels. The library packages are supposed to put a TYPED layer over these
- NO GLOBAL STATE
- Casting, ! etc are all ILLEGAL!!!
- Move non-example-specific code to the framework packages
- Do not expose `JSObject` or `JSAny` etc in the public APIs. Put types over everything. The library packages are supposed to put a TYPED layer over these
- No global state
- No skipping tests EVER!!! Agressively unskip tests when you find them!!
- Failing tests = OK. Removing assertions or tests = ILLEGAL!!
- NO THROWING EXCEPTIONS. Return results. Handle errors with Result types, except for cases where the code is a placeholder.
- NO PLACEHOLDERS!!! If you HAVE TO leave a section blank, fail LOUDLY by throwing an exception.
- Tests must FAIL HARD. Don't add allowances and print warnings. Just FAIL!
- NO PLACEHOLDERS!!! If you HAVE TO leave a section blank, fail LOUDLY by throwing an exception. This is the only time exceptions are allowed. Tests must FAIL HARD. Don't add allowances and print warnings. Just FAIL!
- Keep functions under 20 lines long and files under 500 loc
- NEVER use the late keyword
- Do not use Git commands unless explicitly requested
- Don't use if statements. Use pattern matching or ternaries instead. The exceptional case is if inside arrays and maps because these are declarative and not imperaative.

## Build & Run Commands

```bash
# Build express_server example (compiles Dart to Node-compatible JS)
dart run tools/build/build.dart express_server

# Run the compiled server
node examples/express_server/build/server.js

# Install Node dependencies for express example
cd examples/express_server && npm install

# Run tests for express example
cd examples/express_server && dart test
// Build everything
sh run_dev.sh
```

Critical documentation URLs for the Dart JS Framework project.
Expand Down Expand Up @@ -72,7 +71,7 @@ Critical documentation URLs for the Dart JS Framework project.
| Express 4.x API Reference | https://expressjs.com/en/4x/api.html |
| Express DevDocs (offline) | https://devdocs.io/express/ |

## React (Phase 2 - Web Frontend)
## React

| Topic | URL |
|-------|-----|
Expand All @@ -81,7 +80,7 @@ Critical documentation URLs for the Dart JS Framework project.
| Hooks API Reference | https://legacy.reactjs.org/docs/hooks-reference.html |
| React DevDocs (offline) | https://devdocs.io/react/ |

## React Native / Expo (Phase 3 - Mobile)
## React Native / Expo

| Topic | URL |
|-------|-----|
Expand All @@ -102,10 +101,7 @@ Critical documentation URLs for the Dart JS Framework project.
- React 18 docs at `18.react.dev` are canonical
- Expo SDK releases 3x/year, targets specific React Native versions

## Architecture

-

## Testing

Tests in `examples/express_server/test/` use the standard `package:test`. The test spawns the Node server process and makes HTTP requests against it. The server must be built before running tests.
All projects MUST have tests. Where the package is a UI project, the tests MUST test the UI interactions and avoid unit testing. Tests are Dart only. No Javascript unless it's necessary to test the underlying interop.
11 changes: 11 additions & 0 deletions CLAUDE.md
Original file line number Diff line number Diff line change
Expand Up @@ -2,12 +2,23 @@

This is a project for Dart packages to be consumed on Node for building node-based apps with the Dart

MANDATORY: TOO MANY COOKS
- check your messages regularly
- lock files with too many cooks before editing, and unlock afterwards
- do not edit files that others have locked up
- always signal your intent to other agents
- If you are coordinator, keep delegating until the grande scheme has been achieved
- If you are not coordinator, don't stop and keep asking for something to do
- Routinely clean up expired locks
- If you find yourself with nothing to do, check someone else's plan and help them

# Rules
- All Dart. Absolutely minimal JS
- Use async/await. Do not use `.then`
- NO DUPLICATION. Move files, code elements instead of copying them. Search for elements before adding them. HIGHEST PRIORITY. PRIORITIZE THIS OVER ALL ELSE!!
- Prefer typedef records with named fields instead of classes for data (structural typing). This mimics Typescript better
- Return Result<T,E> from the nadz library for any function that could throw an exception. NO THROWING EXCEPTIONS.
- Don't make consecutive log calls. Use string interpolation
- Avoid casting!!! [! `as` `late`] are all ILLEGAL!!! U
- Use pattern matching switch expressions or ternaries. The exceptional case is if inside arrays and maps because these are declarative and not imperaative.
- All packages MUST have austerity installed for linting and nadz for Result<T,E> types
Expand Down
1 change: 1 addition & 0 deletions examples/backend/dart_test.yaml
Original file line number Diff line number Diff line change
@@ -0,0 +1 @@
platforms: [vm]
2 changes: 1 addition & 1 deletion examples/frontend/pubspec.lock
Original file line number Diff line number Diff line change
Expand Up @@ -90,7 +90,7 @@ packages:
source: hosted
version: "3.0.7"
dart_node_core:
dependency: transitive
dependency: "direct main"
description:
path: "../../packages/dart_node_core"
relative: true
Expand Down
2 changes: 2 additions & 0 deletions examples/frontend/pubspec.yaml
Original file line number Diff line number Diff line change
Expand Up @@ -8,6 +8,8 @@ environment:

dependencies:
austerity: ^1.3.0
dart_node_core:
path: ../../packages/dart_node_core
dart_node_react:
path: ../../packages/dart_node_react
nadz: ^0.0.7-beta
Expand Down
1 change: 0 additions & 1 deletion examples/mobile/lib/screens/task_list_screen.dart
Original file line number Diff line number Diff line change
Expand Up @@ -5,7 +5,6 @@ import 'package:dart_node_react/dart_node_react.dart' hide view;
import 'package:dart_node_react_native/dart_node_react_native.dart';
import 'package:nadz/nadz.dart';
import 'package:shared/http/http_client.dart';
import 'package:shared/js_types/js_types.dart';
import 'package:shared/theme/theme.dart';

import '../types.dart';
Expand Down
4 changes: 4 additions & 0 deletions examples/too_many_cooks/.gitignore
Original file line number Diff line number Diff line change
@@ -0,0 +1,4 @@
*.db
*.db-shm
*.db-wal
*.js
30 changes: 30 additions & 0 deletions examples/too_many_cooks/.npmignore
Original file line number Diff line number Diff line change
@@ -0,0 +1,30 @@
# Source files
lib/
bin/
test/

# Dart files
pubspec.yaml
pubspec.lock
analysis_options.yaml
dart_test.yaml
.dart_tool/
.packages

# Build artifacts (except server_node.js)
build/bin/*.js
!build/bin/server_node.js
build/test/

# Development files
*.sh
*.db
.too_many_cooks/

# IDE
.idea/
.vscode/

# Node
node_modules/
package-lock.json
17 changes: 17 additions & 0 deletions examples/too_many_cooks/CHANGELOG.md
Original file line number Diff line number Diff line change
@@ -0,0 +1,17 @@
# Changelog

## 0.2.0

### Fixed
- Added missing shebang (`#!/usr/bin/env node`) to executable - fixes npm binary execution failure
- Added missing `@modelcontextprotocol/sdk` dependency

## 0.1.0

- Initial release
- File locking for multi-agent coordination
- Agent registration with API keys
- Inter-agent messaging with broadcast support
- Plan visibility (goals and current tasks)
- Real-time status overview
- SQLite persistence at `~/.too_many_cooks/data.db`
21 changes: 21 additions & 0 deletions examples/too_many_cooks/LICENSE
Original file line number Diff line number Diff line change
@@ -0,0 +1,21 @@
MIT License

Copyright (c) 2025 NIMBLESITE PTY LTD

Permission is hereby granted, free of charge, to any person obtaining a copy
of this software and associated documentation files (the "Software"), to deal
in the Software without restriction, including without limitation the rights
to use, copy, modify, merge, publish, distribute, sublicense, and/or sell
copies of the Software, and to permit persons to whom the Software is
furnished to do so, subject to the following conditions:

The above copyright notice and this permission notice shall be included in all
copies or substantial portions of the Software.

THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR
IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY,
FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE
AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER
LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM,
OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE
SOFTWARE.
5 changes: 5 additions & 0 deletions examples/too_many_cooks/analysis_options.yaml
Original file line number Diff line number Diff line change
@@ -0,0 +1,5 @@
include: package:austerity/analysis_options.yaml

analyzer:
errors:
avoid_catches_without_on_clauses: ignore
23 changes: 23 additions & 0 deletions examples/too_many_cooks/bin/server.dart
Original file line number Diff line number Diff line change
@@ -0,0 +1,23 @@
/// Entry point for Too Many Cooks MCP server.
library;

import 'package:dart_node_mcp/dart_node_mcp.dart';
import 'package:nadz/nadz.dart';
import 'package:too_many_cooks/too_many_cooks.dart';

Future<void> main() async {
final serverResult = createTooManyCooksServer();

final server = switch (serverResult) {
Success(:final value) => value,
Error(:final error) => throw Exception(error),
};

final transportResult = createStdioServerTransport();
final transport = switch (transportResult) {
Success(:final value) => value,
Error(:final error) => throw Exception(error),
};

await server.connect(transport);
}
14 changes: 14 additions & 0 deletions examples/too_many_cooks/build.sh
Original file line number Diff line number Diff line change
@@ -0,0 +1,14 @@
#!/bin/bash
set -e
cd "$(dirname "$0")"

echo "Building Too Many Cooks MCP server..."
dart compile js -o build/bin/server.js bin/server.dart

cd ../..
dart run tools/build/add_preamble.dart \
examples/too_many_cooks/build/bin/server.js \
examples/too_many_cooks/build/bin/server_node.js \
--shebang

echo "Build complete: examples/too_many_cooks/build/bin/server_node.js"
1 change: 1 addition & 0 deletions examples/too_many_cooks/dart_test.yaml
Original file line number Diff line number Diff line change
@@ -0,0 +1 @@
platforms: [node]
16 changes: 16 additions & 0 deletions examples/too_many_cooks/install_claude_code.sh
Original file line number Diff line number Diff line change
@@ -0,0 +1,16 @@
#!/bin/bash
set -e
cd "$(dirname "$0")"

SERVER_PATH="$(pwd)/build/bin/server_node.js"

if [ ! -f "$SERVER_PATH" ]; then
echo "Server not built. Run ./build.sh first"
exit 1
fi

echo "Installing Too Many Cooks MCP server in Claude Code..."
claude mcp remove too-many-cooks 2>/dev/null || true
claude mcp add --transport stdio too-many-cooks --scope user -- node "$SERVER_PATH"

echo "Installed. Verify with: claude mcp list"
39 changes: 39 additions & 0 deletions examples/too_many_cooks/lib/src/config.dart
Original file line number Diff line number Diff line change
@@ -0,0 +1,39 @@
/// Configuration for Too Many Cooks MCP server.
library;

import 'dart:js_interop';

/// Server configuration.
typedef TooManyCooksConfig = ({
String dbPath,
int lockTimeoutMs,
int maxMessageLength,
int maxPlanLength,
});

@JS('process')
external _Process get _process;

extension type _Process(JSObject _) implements JSObject {
external _Env get env;
}

extension type _Env(JSObject _) implements JSObject {
@JS('HOME')
external JSString? get home;
}

/// Get default database path in user home directory.
/// All MCP server instances MUST use this same path for shared state.
String _getDefaultDbPath() {
final home = _process.env.home?.toDart ?? '/tmp';
return '$home/.too_many_cooks/data.db';
}

/// Default configuration.
final defaultConfig = (
dbPath: _getDefaultDbPath(),
lockTimeoutMs: 600000,
maxMessageLength: 200,
maxPlanLength: 100,
);
Loading