Skip to content

Commit b38df45

Browse files
committed
Add robust run-repo shortcuts with nested project support
1 parent dfea755 commit b38df45

6 files changed

Lines changed: 348 additions & 35 deletions

File tree

‎docs/commands/sync.md‎

Lines changed: 23 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -6,6 +6,17 @@ Sync git repo: pull from tracking remote, merge upstream changes, optionally pus
66

77
Single command to bring a repository up to date. Pulls from the tracking branch, syncs upstream if configured (fork workflow), and optionally pushes. Works with both plain git and jj (jujutsu) colocated repos.
88

9+
## Context Card
10+
11+
Use this block when passing `f sync` behavior to another agent:
12+
13+
- Default behavior: pull/sync only; push is off unless `--push`.
14+
- Defaults: `--stash=true`, `--fix=true`.
15+
- Modes: uses jj flow in healthy colocated workspaces, falls back to plain git when needed.
16+
- Push target: configured `[git].remote` first, then standard fallback behavior.
17+
- Clipboard output: synced commit list is copied only when remote commit ranges are detected (typically jj fetch path).
18+
- Conflict note: jj can finish with unresolved conflicts and prints `jj resolve` guidance.
19+
920
## Quick Start
1021

1122
```bash
@@ -77,8 +88,10 @@ Restores auto-stashed changes if any were stashed in step 1.
7788

7889
### Step 6: Synced commit list + clipboard
7990

80-
On successful sync, Flow prints only the deduplicated list of newly synced commits (hash + subject)
81-
and copies that same list to your clipboard.
91+
When remote commit ranges are discovered (typically during jj fetch), Flow prints a deduplicated
92+
list of newly synced commits (hash + subject) and copies that same list to your clipboard.
93+
94+
If no synced commit ranges were detected, this section is skipped.
8295

8396
Set `FLOW_NO_CLIPBOARD=1` to disable clipboard copy.
8497

@@ -178,6 +191,14 @@ jj git import
178191
rm -rf .jj && jj git init --colocate
179192
```
180193

194+
### "Sync complete (jj) but conflicts remain"
195+
196+
This means sync/rebase completed but conflict revisions still exist in jj.
197+
198+
```bash
199+
jj resolve
200+
```
201+
181202
## See Also
182203

183204
- [upstream](upstream.md) - Manage upstream fork workflow

‎docs/index.mdx‎

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -40,6 +40,7 @@ High-signal docs for the Codex/Claude workflow:
4040
- [`rl-for-myflow-harbor.md`](rl-for-myflow-harbor.md): practical RL roadmap for turning myflow -> Harbor exports into a gated training/improvement loop.
4141
- [`rl-myflow-harbor-task-specs.md`](rl-myflow-harbor-task-specs.md): executable task contracts for validate/reward/canary/hardcase stages.
4242
- [`private-fork-flow.md`](private-fork-flow.md): generic AI runbook for private-fork setup and safe push routing via Flow `[git].remote`.
43+
- [`run-repos.md`](run-repos.md): shortcuts and resolution rules for running tasks in `~/code/run` and `~/code/run/i` from anywhere.
4344
- [`dependency-vendoring.md`](dependency-vendoring.md): inhouse dependency workflow, offender ranking, and fast upstream sync loop for vendored crates.
4445
- [`vendor-code-intelligence.md`](vendor-code-intelligence.md): opensrc-style local code indexing/search for vendored crates + first-party code via Typesense.
4546
- [`vendor-nix-inspiration.md`](vendor-nix-inspiration.md): how Flow vendoring borrows Nix ideas (pinning, reproducibility, provenance, rollback) while staying Cargo-first.

‎docs/run-repos.md‎

Lines changed: 83 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,83 @@
1+
# Run Repos Shortcuts (`f r`, `f ri`, `f rp`, `f rip`)
2+
3+
This workflow lets you run Flow tasks in `~/code/run` and `~/code/run/i` from anywhere,
4+
without manual `cd`.
5+
6+
## Standard Layout
7+
8+
```text
9+
~/code/run/ # public run repo (has flow.toml)
10+
~/code/run/i/ # internal run repo (has flow.toml)
11+
~/code/run/i/linsa/ # nested internal project example
12+
```
13+
14+
`f health` now ensures `~/code/run` and `~/code/run/i` directories exist.
15+
16+
## Primary Commands
17+
18+
| Command | Meaning |
19+
|---|---|
20+
| `f r <task> [args...]` | Run task in `~/code/run` |
21+
| `f ri <task> [args...]` | Run task in `~/code/run/i` |
22+
| `f rp <project> <task> [args...]` | Run task in project under run tree |
23+
| `f rip <project> <task> [args...]` | Run task in `~/code/run/i/<project>` |
24+
25+
## Resolution Rules
26+
27+
`f rp <project> ...` resolves in this order:
28+
29+
1. `~/code/run/<project>`
30+
2. `~/code/run/i/<project>` (fallback)
31+
32+
If both exist, Flow fails with an ambiguity error and asks for explicit path:
33+
34+
- `f rp <project> ...` for public path
35+
- `f rp i/<project> ...` or `f rip <project> ...` for internal path
36+
37+
## Nested Project Support
38+
39+
Nested `flow.toml` projects are supported. Example:
40+
41+
```bash
42+
f rip linsa bootstrap
43+
f rp linsa opencode-codex-login
44+
```
45+
46+
Both target `~/code/run/i/linsa` (unless `~/code/run/linsa` also exists).
47+
48+
## Why This Is Robust
49+
50+
- Uses explicit `f run --config <dir>/flow.toml <task>` internally.
51+
- Avoids task-lookup ambiguity when nested `flow.toml` files exist.
52+
- Blocks unsafe paths (`/absolute`, `..` traversal) for run repo/project selectors.
53+
54+
## Discovery and Maintenance
55+
56+
```bash
57+
f run-list # list all flow.toml repos/projects under ~/code/run (recursive)
58+
f run-sync # sync all git repos under ~/code/run (recursive)
59+
f run-sync i # sync only ~/code/run/i
60+
```
61+
62+
## Script Interface
63+
64+
Task shortcuts are powered by:
65+
66+
```bash
67+
scripts/run-repos.sh
68+
```
69+
70+
Direct script commands:
71+
72+
```bash
73+
bash ./scripts/run-repos.sh r <task> [args...]
74+
bash ./scripts/run-repos.sh ri <task> [args...]
75+
bash ./scripts/run-repos.sh rp <project> <task> [args...]
76+
bash ./scripts/run-repos.sh rip <project> <task> [args...]
77+
```
78+
79+
`RUN_ROOT` can be overridden for testing:
80+
81+
```bash
82+
RUN_ROOT=/tmp/my-run-layout f rp linsa whoami
83+
```

‎flow.toml‎

Lines changed: 24 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -398,6 +398,30 @@ name = "run-exec"
398398
command = "bash ./scripts/run-repos.sh exec $@"
399399
description = "Ensure run repo exists (clone/sync) and run a task. Usage: f run-exec <name> <repo-ssh-url> [--branch <branch>] <task> [args...]"
400400

401+
[[tasks]]
402+
name = "run-ri"
403+
command = "bash ./scripts/run-repos.sh ri $@"
404+
description = "Run a task in the internal run repo (~/code/run/i). Usage: f ri <task> [args...]"
405+
shortcuts = ["ri"]
406+
407+
[[tasks]]
408+
name = "run-r"
409+
command = "bash ./scripts/run-repos.sh r $@"
410+
description = "Run a task in the public run repo (~/code/run). Usage: f r <task> [args...]"
411+
shortcuts = ["r"]
412+
413+
[[tasks]]
414+
name = "run-rp"
415+
command = "bash ./scripts/run-repos.sh rp $@"
416+
description = "Run a task in a run project. Usage: f rp <project> <task> [args...] (resolves ~/code/run/<project> or ~/code/run/i/<project>)"
417+
shortcuts = ["rp"]
418+
419+
[[tasks]]
420+
name = "run-rip"
421+
command = "bash ./scripts/run-repos.sh rip $@"
422+
description = "Run a task in an internal run project. Usage: f rip <project> <task> [args...] (maps to ~/code/run/i/<project>)"
423+
shortcuts = ["rip"]
424+
401425
[storage]
402426
provider = "myflow.sh"
403427
env_var = "FLOW_SECRETS_TOKEN" # optional; defaults to this value

0 commit comments

Comments
 (0)