microralph 0.2.0

A tiny CLI for creating and executing PRDs with coding agents
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
82
83
84
85
86
87
88
89
90
91
92
93
94
95
96
97
98
99
100
101
102
103
104
105
106
107
108
109
110
111
112
113
114
115
116
117
118
119
120
121
122
123
124
125
126
127
128
129
130
131
132
133
134
135
136
137
138
139
140
141
142
143
144
145
146
147
148
149
150
151
152
153
154
155
156
157
158
159
160
161
162
163
164
165
166
167
168
169
170
171
172
173
174
175
176
177
178
179
180
181
182
183
184
185
186
187
188
189
190
191
192
193
194
195
196
197
198
199
200
201
202
203
204
205
206
207
208
209
210
211
212
213
214
215
216
217
218
219
220
221
222
223
224
225
226
227
228
229
230
231
232
233
234
235
236
237
238
239
240
241
242
243
244
245
246
247
248
249
250
251
252
253
254
255
256
257
258
259
260
261
262
263
264
265
266
267
268
269
270
271
272
273
274
275
276
277
278
279
280
281
282
283
284
285
286
287
288
289
290
291
292
293
294
295
296
297
298
299
300
301
302
303
304
305
306
307
308
309
310
311
312
313
314
315
316
317
318
319
320
321
322
323
324
325
326
327
328
329
330
331
332
333
334
335
336
337
338
339
340
341
342
343
344
345
346
347
348
349
350
351
352
353
354
355
356
357
358
359
360
361
362
363
364
365
366
367
368
369
370
371
372
373
374
375
376
377
378
379
380
381
382
383
384
385
386
387
388
389
390
391
392
393
394
395
396
397
398
399
400
401
402
403
404
405
406
407
408
409
410
411
412
413
414
415
416
417
418
419
420
421
422
423
424
425
426
427
428
429
430
431
432
433
434
435
436
437
438
439
440
441
442
443
444
445
446
447
448
449
450
451
452
453
454
455
456
457
458
459
460
461
462
463
464
465
466
467
468
469
470
471
472
473
474
475
476
477
478
479
480
481
482
483
484
485
486
487
# microralph — cargo-make configuration
# Reference: https://github.com/twitchax/kord/blob/main/Makefile.toml

# =============================================================================
# Tool Installation
# =============================================================================

[tasks.install-cargo-binstall]
# In CI, this is installed by the cargo-bins/cargo-binstall@main action.
# Locally, users should install manually: https://github.com/cargo-bins/cargo-binstall
script = "echo 'Checking cargo-binstall availability...'"

[tasks.install-nextest]
dependencies = ["install-cargo-binstall"]
command = "cargo"
args = ["binstall", "cargo-nextest", "--no-confirm"]

[tasks.install-llvm-cov]
dependencies = ["install-cargo-binstall"]
command = "cargo"
args = ["binstall", "cargo-llvm-cov", "--no-confirm"]

[tasks.install-cargo-release]
dependencies = ["install-cargo-binstall"]
command = "cargo"
args = ["binstall", "cargo-release", "--no-confirm"]

[tasks.install-git-cliff]
dependencies = ["install-cargo-binstall"]
command = "cargo"
args = ["binstall", "git-cliff", "--no-confirm"]

[tasks.install-wkg]
dependencies = ["install-cargo-binstall"]
command = "cargo"
args = ["binstall", "wkg", "--no-confirm"]

[tasks.tools]
dependencies = ["install-nextest", "install-llvm-cov"]

# =============================================================================
# Formatting
# =============================================================================

[tasks.fmt]
cwd = "."
workspace = false
command = "cargo"
args = ["fmt"]

[tasks.fmt-check]
cwd = "."
workspace = false
command = "cargo"
args = ["fmt", "--check"]

# =============================================================================
# Linting
# =============================================================================

[tasks.clippy]
cwd = "."
workspace = false
command = "cargo"
args = ["clippy", "--all-targets", "--all-features", "--", "-D", "warnings"]

# =============================================================================
# Build
# =============================================================================

[tasks.build]
cwd = "."
workspace = false
command = "cargo"
args = ["build"]

[tasks.build-release]
cwd = "."
workspace = false
command = "cargo"
args = ["build", "--release"]

# =============================================================================
# Testing
# =============================================================================

[tasks.test]
cwd = "."
workspace = false
dependencies = ["install-nextest"]
command = "cargo"
args = ["nextest", "run"]

[tasks.test-cargo]
# Fallback for environments without nextest.
cwd = "."
workspace = false
command = "cargo"
args = ["test"]

# =============================================================================
# UAT (User Acceptance Tests)
# =============================================================================

[tasks.uat]
# The one true gate for this repo.
# Usage: cargo make uat [filter]
# Examples:
#   cargo make uat              - Run full CI pipeline
#   cargo make uat prd_new      - Run CI then tests matching "prd_new"
workspace = false
script_runner = "@shell"
script = '''
cargo make ci
if [ -n "${1:-}" ]; then
    cargo nextest run "$1"
fi
'''

# =============================================================================
# microralph Integration Tests
# =============================================================================

[tasks.mr-test]
# Integration tests for MR itself (stub for now).
cwd = "."
workspace = false
dependencies = ["test"]

[tasks.mr-uat]
# MR end-to-end acceptance tests (stub for now).
cwd = "."
workspace = false
dependencies = ["test"]

# =============================================================================
# Constitution UATs (PRD-0012)
# =============================================================================

[tasks.constitution_bootstrap]
# UAT-001: Bootstrap creates initial constitution file
workspace = false
dependencies = ["install-nextest"]
command = "cargo"
args = ["nextest", "run", "test_bootstrap_creates_constitution"]

[tasks.constitution_template]
# UAT-002: Constitution contains numbered example rules
workspace = false
dependencies = ["install-nextest"]
command = "cargo"
args = ["nextest", "run", "test_constitution_template_content"]

[tasks.constitution_prd_new]
# UAT-003: prd new reads and respects constitution
workspace = false
dependencies = ["install-nextest"]
command = "cargo"
args = ["nextest", "run", "test_constitution_prd_new"]

[tasks.constitution_prd_finalize]
# UAT-004: prd finalize reads and respects constitution
workspace = false
dependencies = ["install-nextest"]
command = "cargo"
args = ["nextest", "run", "test_constitution_prd_finalize"]

[tasks.constitution_edit]
# UAT-005: constitution edit command updates via LLM
workspace = false
dependencies = ["install-nextest"]
command = "cargo"
args = ["nextest", "run", "test_constitution_edit"]

[tasks.constitution_violation_logging]
# UAT-006: Runner logs violations in PRD history
workspace = false
dependencies = ["install-nextest"]
command = "cargo"
args = ["nextest", "run", "test_constitution_violation_logging"]

# =============================================================================
# CI Pipeline
# =============================================================================

[tasks.ci]
# The full CI pipeline: fmt, clippy, test.
workspace = false
dependencies = ["fmt-check", "clippy", "test"]

[tasks.check-all]
workspace = false
dependencies = ["fmt", "test"]

# =============================================================================
# Code Coverage
# =============================================================================

[tasks.codecov]
cwd = "."
workspace = false
clear = true
dependencies = ["tools"]
command = "cargo"
args = ["llvm-cov", "nextest", "--lcov", "--output-path", "coverage.lcov"]

[tasks.codecov-html]
cwd = "."
workspace = false
clear = true
dependencies = ["tools"]
command = "cargo"
args = ["llvm-cov", "nextest", "--html"]

# =============================================================================
# Platform Builds (for CI artifact generation)
# =============================================================================

[tasks.build-linux]
cwd = "."
workspace = false
command = "cargo"
args = ["build", "--target", "x86_64-unknown-linux-gnu", "--release"]

[tasks.build-windows]
cwd = "."
workspace = false
command = "cargo"
args = ["build", "--target", "x86_64-pc-windows-gnu", "--release"]

[tasks.build-macos]
cwd = "."
workspace = false
command = "cargo"
args = ["build", "--target", "aarch64-apple-darwin", "--release"]

[tasks.build-wasm]
cwd = "."
workspace = false
command = "cargo"
args = ["build", "--target", "wasm32-wasip2", "--release"]

[tasks.build-oci]
# Alias for build-wasm (OCI publishing uses the same WASM binary)
cwd = "."
workspace = false
dependencies = ["build-wasm"]

[tasks.publish-oci]
# Publish WASM binary to GitHub Container Registry
# Prerequisites:
#   - Install wkg: cargo binstall wkg
#   - Authenticate: docker login ghcr.io -u USERNAME
#   - Build: cargo make build-oci
dependencies = ["build-oci", "install-wkg"]
cwd = "."
workspace = false
command = "wkg"
args = [
    "oci",
    "push",
    "ghcr.io/twitchax/microralph:latest",
    "--file",
    "target/wasm32-wasip2/release/mr.wasm",
]

# =============================================================================
# Publishing
# =============================================================================

[tasks.release-bump]
cwd = "."
workspace = false
dependencies = ["install-cargo-release"]
command = "cargo"
args = ["release", "--workspace", "--no-publish", "--execute"]

[tasks.release-builds]
cwd = "."
workspace = false
run_task = { name = [
    "changelog",
    "build-linux",
    "build-macos",
    "build-windows",
    "build-wasm",
], fork = false }

[tasks.release]
cwd = "."
workspace = false
dependencies = ["ci", "release-builds"]
script_runner = "@shell"
script = '''
echo ""
echo "✅ Release build complete!"
echo ""
echo "Next steps:"
echo "  1. Review CHANGELOG.md"
echo "  2. Bump version: cargo make release-bump"
echo "  3. Commit changes: git add . && git commit -m \"chore: prepare release\""
echo "  4. Push to trigger CI: git push"
echo "  5. Download artifacts: gh run list --branch main --workflow build.yml --limit 1 --json databaseId --jq '.[0].databaseId' | xargs -I {} gh run download {} --dir release-artifacts"
echo "  6. Publish: cargo make publish-all <version-tag>"
'''

[tasks.publish-all]
cwd = "."
workspace = false
script_runner = "@shell"
script = '''#!/bin/bash
set -e

TAG=${1:-}
if [ -z "$TAG" ]; then
    echo "❌ Error: Version tag required"
    echo "Usage: cargo make publish-all <tag>"
    echo "Example: cargo make publish-all v0.1.0"
    exit 1
fi

echo "🚀 Starting full release pipeline for $TAG..."
echo ""

# Step 1: Publish to crates.io
echo "📦 Step 1/2: Publishing to crates.io..."
cargo make publish-crates

# Step 2: Create GitHub release with artifacts
echo ""
echo "📦 Step 2/2: Creating GitHub release..."
cargo make github-release "$TAG" "${@:2}"

echo ""
echo "✅ Full release pipeline complete!"
echo "   Published to crates.io: https://crates.io/crates/microralph"
echo "   GitHub release: https://github.com/twitchax/microralph/releases/tag/$TAG"
'''

[tasks.changelog]
cwd = "."
workspace = false
dependencies = ["install-git-cliff"]
command = "git-cliff"
args = ["--output", "CHANGELOG.md"]

[tasks.publish-crates]
cwd = "."
workspace = false
dependencies = ["ci"]
script_runner = "@shell"
script = '''
echo "Running pre-publish checks..."
cargo package --no-verify --list

echo ""
echo "Publishing microralph to crates.io..."
cargo publish --no-verify ${@}

if [ "${1:-}" != "--dry-run" ]; then
    echo ""
    echo "✅ Published successfully!"
fi
'''

[tasks.github-release]
cwd = "."
workspace = false
script_runner = "@shell"
script = '''#!/bin/bash
set -e

TAG=${1:-}
if [ -z "$TAG" ]; then
    echo "❌ Error: Version tag required"
    echo "Usage: cargo make github-release <tag> [--draft]"
    echo "Example: cargo make github-release v0.1.0"
    exit 1
fi

echo "📦 Creating GitHub release for $TAG..."

# Prepare release notes
TEMP_DIR=$(mktemp -d)
trap "rm -rf $TEMP_DIR" EXIT
NOTES_FILE="$TEMP_DIR/release_notes.md"

if [ -f "CHANGELOG.md" ]; then
    echo "Using changelog for release notes..."
    cp CHANGELOG.md "$NOTES_FILE"
else
    echo "## Release $TAG" > "$NOTES_FILE"
    echo "" >> "$NOTES_FILE"
    echo "See the full changelog at https://github.com/twitchax/microralph/blob/main/CHANGELOG.md" >> "$NOTES_FILE"
fi

# Check for artifacts directory
ARTIFACTS=""
if [ -d "release-artifacts" ]; then
    echo "📎 Found release-artifacts directory"
    for file in release-artifacts/*; do
        if [ -f "$file" ]; then
            echo "  → $(basename "$file")"
            ARTIFACTS="$ARTIFACTS \"$file\""
        fi
    done
fi

# Build gh release create command
GH_CMD="gh release create \"$TAG\" --title \"$TAG\" --notes-file \"$NOTES_FILE\""

# Add draft flag if requested
shift
if echo "$@" | grep -q "\-\-draft"; then
    GH_CMD="$GH_CMD --draft"
    echo "📝 Creating as draft release"
fi

# Add artifacts
if [ -n "$ARTIFACTS" ]; then
    GH_CMD="$GH_CMD $ARTIFACTS"
fi

# Execute the release creation
echo ""
echo "🚀 Creating GitHub release..."
eval $GH_CMD

echo ""
echo "✅ GitHub release created successfully!"
echo "   View at: https://github.com/twitchax/microralph/releases/tag/$TAG"
echo ""
echo "💡 To download artifacts from CI, run:"
echo "   gh run list --branch main --workflow build.yml --limit 1 --json databaseId --jq '.[0].databaseId' | xargs -I {} gh run download {} --dir release-artifacts"
'''

# =============================================================================
# Development Helpers
# =============================================================================

[tasks.run]
cwd = "."
workspace = false
command = "cargo"
args = ["run", "--", "${@}"]

[tasks.watch]
cwd = "."
workspace = false
script = '''
cargo watch -x "run -- status"
'''

[tasks.devcontainer]
# Start and exec into the dev container
cwd = "."
workspace = false
script_runner = "@shell"
script = '''
# Ensure @devcontainers/cli is installed
if ! command -v devcontainer &> /dev/null; then
    echo "📦 Installing @devcontainers/cli..."
    npm install -g @devcontainers/cli
fi

# Generate config if it doesn't exist
if [ ! -f ".devcontainer/devcontainer.json" ]; then
    echo "⚠️  No devcontainer config found. Run 'cargo run -- devcontainer generate' first."
    exit 1
fi

echo "🚀 Starting dev container..."
devcontainer up --workspace-folder . --remove-existing-container

echo "🔗 Connecting to dev container..."
devcontainer exec --workspace-folder . bash
'''

# =============================================================================
# Clean
# =============================================================================

[tasks.clean]
cwd = "."
workspace = false
command = "cargo"
args = ["clean"]