@dotlabshq/clave 0.2.1 → 0.2.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 +1 -1
- package/package.json +1 -1
- package/src/init.mjs +25 -18
package/README.md
CHANGED
|
@@ -10,7 +10,7 @@ It runs in your terminal, in the repository, the first time you set it up on thi
|
|
|
10
10
|
|
|
11
11
|
1. **Signs you in** through the browser (no token to copy). The sign-in lasts for this run only and is not saved.
|
|
12
12
|
2. **Picks the org** and **the project**: it matches this repository's git remote. A missing project or unit is created when you are owner or admin; otherwise it tells you what an owner should run.
|
|
13
|
-
3. **Picks the unit** (team) your agents work for.
|
|
13
|
+
3. **Picks the unit** (team) your agents work for; owners and admins can also create one from the list (`+ New unit…`).
|
|
14
14
|
4. **Registers your agents** (default `coder`). An agent belongs to you: its id is `name@your-handle` (e.g. `coder@ayse`), so the same name can exist for other people. One token per agent.
|
|
15
15
|
5. **Writes the MCP config by variable name**: `claude mcp add --scope local` with `Authorization: Bearer ${CLAVE_TOKEN_<AGENT>}` (stored on this machine, not in the repository); without the `claude` CLI it writes `.mcp.json`. The tokens themselves go to a git-ignored `.env.clave` (0600). Load it before starting your client: `set -a; . ./.env.clave; set +a`, or export those variables in your shell profile.
|
|
16
16
|
6. **Adds a clave block** to `AGENTS.md` or `CLAUDE.md` (it asks first), so every agent session starts with `session_start`.
|
package/package.json
CHANGED
package/src/init.mjs
CHANGED
|
@@ -57,6 +57,25 @@ async function session(opts, { manage = false } = {}) {
|
|
|
57
57
|
return { u, ask, log, org, call, manager: MANAGERS.has(org.role) };
|
|
58
58
|
}
|
|
59
59
|
|
|
60
|
+
/**
|
|
61
|
+
* Birim seçimi: var olanlardan biri ya da (sahip/yönetici) listenin sonundaki "+ New unit…" ile yeni birim.
|
|
62
|
+
* Hiç birim yoksa sahip/yönetici açar, üye sahibe yollanır. Dönüş: birim anahtarı.
|
|
63
|
+
*/
|
|
64
|
+
async function pickUnit({ setup, call, ask, log, org, manager, question }) {
|
|
65
|
+
const units = setup.units.filter((x) => !x.archived);
|
|
66
|
+
const NEW = { key: "", name: "+ New unit…", label: "+ New unit…" };
|
|
67
|
+
const options = [...units.map((x) => ({ label: x.name, ...x })), ...(manager ? [NEW] : [])];
|
|
68
|
+
let pick = null;
|
|
69
|
+
if (options.length) pick = await ask.choose(question, options);
|
|
70
|
+
if (pick && pick.key) { log(`Unit: ${pick.name}`); return pick.key; }
|
|
71
|
+
if (!manager) throw new Error(`${org.name} has no unit for this. Ask an owner or admin to run: clave add unit <name>`);
|
|
72
|
+
const name = await ask.ask(units.length ? "New unit name" : "No units yet. Name the team that owns the work", units.length ? "" : "Core team");
|
|
73
|
+
if (!name) throw new Error("A unit name is required.");
|
|
74
|
+
const { key } = await call("POST", "/setup/units", { name });
|
|
75
|
+
log(`Unit created: ${name} (${key})`);
|
|
76
|
+
return key;
|
|
77
|
+
}
|
|
78
|
+
|
|
60
79
|
/** Kişinin kendi agent'ları: kayıt (varsa kendi kaydı kullanılır) ve her birine bir token. Secret yalnız dönüşte. */
|
|
61
80
|
async function registerAgents(call, names, unit, log) {
|
|
62
81
|
const bad = names.find((n) => !NAME.test(n));
|
|
@@ -114,19 +133,8 @@ export async function init(opts) {
|
|
|
114
133
|
log(`Project created: ${name} (${key})`);
|
|
115
134
|
} else log(`Project: ${project.name} (${project.key})`);
|
|
116
135
|
|
|
117
|
-
// Birim: var olanlardan
|
|
118
|
-
const
|
|
119
|
-
let unit;
|
|
120
|
-
if (units.length) {
|
|
121
|
-
const pickU = await ask.choose("Unit your agents work for", units.map((x) => ({ label: x.name, ...x })));
|
|
122
|
-
unit = pickU.key;
|
|
123
|
-
log(`Unit: ${pickU.name}`);
|
|
124
|
-
} else {
|
|
125
|
-
if (!manager) throw new Error(`${org.name} has no unit yet. Ask an owner or admin to run: clave add unit <name>`);
|
|
126
|
-
const name = await ask.ask("No units yet. Name the team that owns the work", "Core team");
|
|
127
|
-
unit = (await call("POST", "/setup/units", { name })).key;
|
|
128
|
-
log(`Unit created: ${name}`);
|
|
129
|
-
}
|
|
136
|
+
// Birim: var olanlardan seç ya da (sahip/yönetici) yeni aç.
|
|
137
|
+
const unit = await pickUnit({ setup, call, ask, log, org, manager, question: "Unit your agents work for" });
|
|
130
138
|
if (!setup.lines.some((l) => !l.archived) || !setup.goals.some((g) => !g.archived)) {
|
|
131
139
|
log(`Tip: the plan has no business line or goal yet. Finish it at ${u.site}/app/welcome`);
|
|
132
140
|
}
|
|
@@ -158,7 +166,7 @@ export async function add(kind, name, opts) {
|
|
|
158
166
|
const { cwd = process.cwd(), claude: useClaude = "auto", run = spawnSync } = opts;
|
|
159
167
|
if (!["unit", "project", "agent"].includes(kind)) throw new Error(`clave add: what to add is unit, project or agent (got "${kind ?? ""}")`);
|
|
160
168
|
if (!name) throw new Error(`clave add ${kind}: give it a name`);
|
|
161
|
-
const { u, ask, log, org, call } = await session(opts, { manage: kind !== "agent" });
|
|
169
|
+
const { u, ask, log, org, call, manager } = await session(opts, { manage: kind !== "agent" });
|
|
162
170
|
try {
|
|
163
171
|
if (kind === "unit") {
|
|
164
172
|
const { key } = await call("POST", "/setup/units", { name });
|
|
@@ -176,11 +184,10 @@ export async function add(kind, name, opts) {
|
|
|
176
184
|
// agent: birim kuruludan ya da --unit; kurulum yoksa da çalışır (yalnız MCP ayarı yazılır).
|
|
177
185
|
const done = existingSetup(cwd);
|
|
178
186
|
const setup = await call("GET", "/setup");
|
|
179
|
-
const units = setup.units.filter((x) => !x.archived);
|
|
180
187
|
let unit = opts.unit;
|
|
181
|
-
if (unit && !units.some((x) => x.key === unit)) throw new Error(`No unit "${unit}" in ${org.name}.`);
|
|
182
|
-
if (!unit
|
|
183
|
-
const issued = await registerAgents(call, [name.toLowerCase()], unit
|
|
188
|
+
if (unit && !setup.units.some((x) => x.key === unit && !x.archived)) throw new Error(`No unit "${unit}" in ${org.name}.`);
|
|
189
|
+
if (!unit) unit = await pickUnit({ setup, call, ask, log, org, manager, question: "Unit the agent works for" });
|
|
190
|
+
const issued = await registerAgents(call, [name.toLowerCase()], unit, log);
|
|
184
191
|
const { servers, claudeOk } = configure({ issued, u, cwd, useClaude, run, log });
|
|
185
192
|
const project = opts.project ?? done?.project ?? "";
|
|
186
193
|
if (project) {
|