@niroai/niro 0.3.1 → 0.3.2
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.
- package/README.md +21 -3
- package/docs/working-on-branches.md +55 -104
- package/package.json +1 -1
package/README.md
CHANGED
|
@@ -12,9 +12,27 @@ One package gives you three things:
|
|
|
12
12
|
|
|
13
13
|
> **Two ways to do everything:** every task below shows the **terminal** command *and* how you'd **ask the agent**. Pick whichever you prefer — they call the same code.
|
|
14
14
|
|
|
15
|
-
|
|
16
|
-
|
|
17
|
-
|
|
15
|
+
## Working on branches
|
|
16
|
+
|
|
17
|
+
Niro indexes your team's code from one branch (usually main). When you work on a feature
|
|
18
|
+
branch, Niro notices and refuses to answer from the old code. Your assistant will offer the fix:
|
|
19
|
+
|
|
20
|
+
```bash
|
|
21
|
+
niro new-temp-project # run once in the repo folder
|
|
22
|
+
```
|
|
23
|
+
|
|
24
|
+
This creates your own private copy of the project that follows your branch and your
|
|
25
|
+
uncommitted edits, live (keep `niro watch` running). Teammates are not affected and cannot
|
|
26
|
+
see your copy. Switching branches needs nothing: Niro answers from your copy on the feature
|
|
27
|
+
branch and from the shared project on main. When your branch is merged:
|
|
28
|
+
|
|
29
|
+
```bash
|
|
30
|
+
niro discard-temp-project
|
|
31
|
+
```
|
|
32
|
+
|
|
33
|
+
If you forget, idle copies are cleaned up automatically after two weeks. Full guide:
|
|
34
|
+
[docs/working-on-branches.md](https://unpkg.com/@niroai/niro/docs/working-on-branches.md)
|
|
35
|
+
(plain-text file, ships inside the package too).
|
|
18
36
|
|
|
19
37
|
---
|
|
20
38
|
|
|
@@ -1,135 +1,86 @@
|
|
|
1
|
-
# Working on branches
|
|
1
|
+
# Working on branches with Niro
|
|
2
2
|
|
|
3
|
-
Niro indexes your team's code
|
|
4
|
-
|
|
5
|
-
|
|
3
|
+
Niro indexes your team's code from one branch, usually main.
|
|
4
|
+
When you work on your own branch, your code is different from what Niro indexed.
|
|
5
|
+
This page explains what happens then. Two minutes to read.
|
|
6
6
|
|
|
7
|
-
|
|
7
|
+
## The short version
|
|
8
8
|
|
|
9
|
-
|
|
10
|
-
Codex, or anything else that speaks MCP) and wherever your git repositories live (GitHub, GitLab,
|
|
11
|
-
Bitbucket, or a self-hosted git server). Niro only needs two things: your repository's git URL and
|
|
12
|
-
the branch you're on.
|
|
9
|
+
There is one command to remember:
|
|
13
10
|
|
|
14
|
-
|
|
11
|
+
niro new-temp-project
|
|
15
12
|
|
|
16
|
-
|
|
13
|
+
Run it in your repo folder when Niro asks for it. That is all.
|
|
17
14
|
|
|
18
|
-
|
|
19
|
-
> **temporary project** — a private copy that follows your branch and your edits live — and from
|
|
20
|
-
> then on, answers come from *your* code, not the team's.
|
|
15
|
+
## What you will see
|
|
21
16
|
|
|
22
|
-
|
|
17
|
+
You create a branch and start changing code.
|
|
18
|
+
Then you ask your AI assistant something about the code.
|
|
23
19
|
|
|
24
|
-
|
|
20
|
+
Niro notices your branch is not the one it indexed. Instead of giving you
|
|
21
|
+
a wrong answer based on the old code, it replies with something like:
|
|
25
22
|
|
|
26
|
-
|
|
27
|
-
|
|
23
|
+
I cannot answer this safely. Your branch has diverged
|
|
24
|
+
from the branch Niro indexed.
|
|
28
25
|
|
|
29
|
-
|
|
30
|
-
|---|---|
|
|
31
|
-
| On the indexed branch (e.g. `main`), no edits | Answers from the shared team index. Business as usual. |
|
|
32
|
-
| Just created a new branch, no changes yet | Still answers from the team index — your code is *identical* to what's indexed, so the answers are provably correct. No friction for a fresh branch. |
|
|
33
|
-
| On a branch with real changes, **with** a temporary project | Answers from **your temporary project** — your branch, your uncommitted edits, live. |
|
|
34
|
-
| On a branch with real changes, **no** temporary project | **Refuses to answer** and tells your assistant what to do about it (see below). |
|
|
26
|
+
Your assistant will offer to fix this by running:
|
|
35
27
|
|
|
36
|
-
|
|
37
|
-
branch *looks* right and is quietly wrong — wrong line numbers, missing methods, dead code that
|
|
38
|
-
you already deleted. Niro treats that as worse than no answer.
|
|
28
|
+
niro new-temp-project
|
|
39
29
|
|
|
40
|
-
|
|
30
|
+
Say yes, or run it yourself in the repo folder. It takes a few seconds.
|
|
41
31
|
|
|
42
|
-
|
|
32
|
+
## What the command does
|
|
43
33
|
|
|
44
|
-
|
|
45
|
-
folder. One command; takes seconds.
|
|
46
|
-
2. **Answer from the team index anyway** — only if *you* explicitly say so. The answer will carry
|
|
47
|
-
a visible label saying it describes the indexed branch, not your code.
|
|
48
|
-
3. **Skip Niro for this question** — the assistant falls back to reading files directly.
|
|
34
|
+
It creates your own private copy of the project inside Niro.
|
|
49
35
|
|
|
50
|
-
|
|
51
|
-
|
|
36
|
+
- The copy follows your branch, including changes you have not committed.
|
|
37
|
+
- Every save updates the copy, as long as "niro watch" is running.
|
|
38
|
+
- Teammates are not affected. They keep using the shared project.
|
|
39
|
+
- Nobody can see your copy. Not even teammates on your account.
|
|
52
40
|
|
|
53
|
-
|
|
41
|
+
From then on, answers come from YOUR code.
|
|
54
42
|
|
|
55
|
-
|
|
43
|
+
## Switching branches
|
|
56
44
|
|
|
57
|
-
|
|
58
|
-
teammates on the same account. Your half-finished code stays yours.
|
|
59
|
-
- **Live.** Your working tree — including uncommitted edits — is uploaded once, and every save
|
|
60
|
-
after that streams in automatically (while `niro watch` is running). Ask a question seconds
|
|
61
|
-
after saving; the answer reflects the save.
|
|
62
|
-
- **Cheap.** Creating one copies the already-computed index. No re-parsing of the whole project,
|
|
63
|
-
no waiting for a full rebuild.
|
|
64
|
-
- **Branch-aware, automatically.** Once your temporary project exists, you never point anything at
|
|
65
|
-
it. Niro routes each question by the branch you're on: feature branch → your copy; switch back
|
|
66
|
-
to `main` → the team index. Switch back and forth all day; it just follows.
|
|
45
|
+
Nothing to do. Niro checks which branch you are on for every question.
|
|
67
46
|
|
|
68
|
-
|
|
47
|
+
- On your feature branch: answers come from your private copy.
|
|
48
|
+
- Back on main: answers come from the shared project.
|
|
69
49
|
|
|
70
|
-
|
|
71
|
-
`niro new-temp-project` in each repo's folder as you branch it. All of them join **one**
|
|
72
|
-
temporary project, so cross-repository answers ("what breaks in service B if I change this in
|
|
73
|
-
service A?") reflect *all* of your local work at once. Each repo can even be on a different
|
|
74
|
-
branch — Niro mirrors whatever your working folders actually look like.
|
|
50
|
+
## When your work is merged
|
|
75
51
|
|
|
76
|
-
|
|
52
|
+
Run this in the repo folder:
|
|
77
53
|
|
|
78
|
-
|
|
54
|
+
niro discard-temp-project
|
|
79
55
|
|
|
80
|
-
|
|
81
|
-
|
|
82
|
-
shared index picks up your merged commits through its normal syncing; nothing else to do.
|
|
56
|
+
It deletes your private copy. Your local files are never touched.
|
|
57
|
+
If you forget, Niro deletes unused copies by itself after two weeks.
|
|
83
58
|
|
|
84
|
-
|
|
59
|
+
## A feature that spans several repos
|
|
85
60
|
|
|
86
|
-
|
|
87
|
-
|
|
88
|
-
|
|
89
|
-
|
|
90
|
-
deleted; your local code is never touched, and a fresh copy is one command away.
|
|
61
|
+
Run "niro new-temp-project" in each repo folder you branch.
|
|
62
|
+
All of them join the same private copy, so questions that cross repos
|
|
63
|
+
(for example: what breaks in service B if I change service A?) see all
|
|
64
|
+
of your changes together.
|
|
91
65
|
|
|
92
|
-
##
|
|
66
|
+
## Common questions
|
|
93
67
|
|
|
94
|
-
|
|
95
|
-
|
|
96
|
-
projects, or when you start your assistant from a parent folder that isn't itself a repository.
|
|
68
|
+
Can teammates see my unfinished code?
|
|
69
|
+
No. Your copy is private to you.
|
|
97
70
|
|
|
98
|
-
|
|
71
|
+
Does this work with my AI assistant and my git host?
|
|
72
|
+
Yes. Any assistant that supports MCP (Claude Code, Cursor, Windsurf,
|
|
73
|
+
Codex, and others) and any git server (GitHub, GitLab, Bitbucket,
|
|
74
|
+
self-hosted).
|
|
99
75
|
|
|
100
|
-
|
|
101
|
-
|
|
102
|
-
|
|
103
|
-
- **You don't need it** for the common case: a repo whose URL maps to exactly one Niro project
|
|
104
|
-
resolves by itself.
|
|
76
|
+
Is creating a copy slow?
|
|
77
|
+
No. Niro copies the existing index instead of re-reading your code.
|
|
78
|
+
It normally takes seconds.
|
|
105
79
|
|
|
106
|
-
|
|
80
|
+
I just created a branch and have not changed anything. Will Niro nag me?
|
|
81
|
+
No. Your code is still identical to what Niro indexed, so Niro answers
|
|
82
|
+
normally. It only steps in once your code actually differs.
|
|
107
83
|
|
|
108
|
-
|
|
109
|
-
|
|
110
|
-
|
|
111
|
-
niro discard-temp-project # after merging: delete the copy; routing falls back by itself
|
|
112
|
-
niro discard-temp-project --project <id> # discard from another machine / lost local state
|
|
113
|
-
```
|
|
114
|
-
|
|
115
|
-
And the tool your assistant uses on its own:
|
|
116
|
-
|
|
117
|
-
- `should_create_temp_project` — a read-only check the assistant calls when it notices you're on a
|
|
118
|
-
new branch: "does this repo, on this branch, need a temporary project?" You'll rarely call it
|
|
119
|
-
yourself, but it's why a good assistant offers to run `niro new-temp-project` right when you
|
|
120
|
-
branch, without you asking.
|
|
121
|
-
|
|
122
|
-
## Requirements and honest limits
|
|
123
|
-
|
|
124
|
-
- **Git is required** for branch detection. Folders that aren't git repositories can still be
|
|
125
|
-
indexed and queried (uploaded as plain folders), but there are no branches to follow — the
|
|
126
|
-
branch logic on this page doesn't apply to them.
|
|
127
|
-
- **Any git host works.** Matching uses the repository URL and branch name only — nothing
|
|
128
|
-
GitHub-specific. HTTPS and SSH remotes both work.
|
|
129
|
-
- **Your backend must support routing.** If the server is older than this feature, the CLI warns
|
|
130
|
-
you loudly at `new-temp-project` time instead of letting answers silently come from the wrong
|
|
131
|
-
place.
|
|
132
|
-
- **Detached HEAD** (bisecting, checking out a tag): there's no branch to follow, so Niro answers
|
|
133
|
-
from the team index with an advisory note rather than refusing.
|
|
134
|
-
- **A brand-new repo** created mid-feature (not yet in any Niro project) can't join a temporary
|
|
135
|
-
project yet — Niro will say so honestly instead of pretending to know it.
|
|
84
|
+
What if I really want an answer from the shared project while on my branch?
|
|
85
|
+
Tell your assistant so. The answer will be clearly labeled as describing
|
|
86
|
+
the indexed branch, not your code.
|