@alterset/alterspec-client 0.28.0 → 0.29.0

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 CHANGED
@@ -110,8 +110,9 @@ npx @alterset/alterspec-client init --product --dispatcher https://<dispatcher>
110
110
 
111
111
  It writes `.alterspec-client.json` with `dispatcher` and `key` only (`--key` as above; no export, no tracks), the
112
112
  `dispatcher` entry in `.mcp.json` and its approval, and nothing of the developer's: no hook, no skill, no prompt. It
113
- prints the key to send to the admin, who registers the owner as a **product person**: a person of their own, with no
114
- track. One key, one role: an owner who also develops uses another key in the code repository.
113
+ prints the key to send to the admin, who registers the owner as a **product person** (the product flag). One key,
114
+ both roles: an owner who also develops has their tracks and the product flag on one person, and the client asks the
115
+ dispatcher for the role its folder means (`product` here, `developer` in a code repository; dispatcher decision 33).
115
116
 
116
117
  In the next Claude Code session in the spec project the dispatcher's product tools appear, and only those:
117
118
  `whoami`, `questions`, `answer`, `reconcile`, `feedback` (the teams' feedback lines, read) and `bug_reports` (the
package/dist/cli.js CHANGED
@@ -241,6 +241,35 @@ function writeConfig(root, config) {
241
241
  writeFileSync(join(root, CONFIG_FILE), JSON.stringify(config, null, 2) + "\n");
242
242
  }
243
243
 
244
+ // src/role.ts
245
+ var ROLE_HEADER = "x-alterspec-role";
246
+ var roleOfConfig = (config) => isProduct(config) ? "product" : "developer";
247
+ var PRODUCT_TOOLS = [
248
+ "whoami",
249
+ "questions",
250
+ "answer",
251
+ "reconcile",
252
+ "feedback",
253
+ "bug_reports"
254
+ ];
255
+ var PRODUCT_ONLY = /* @__PURE__ */ new Set(["answer", "reconcile", "bug_reports"]);
256
+ function roleOf(whoami) {
257
+ if (whoami.role === "product" || whoami.role === "developer") return whoami.role;
258
+ return whoami.product === true ? "product" : "developer";
259
+ }
260
+ function allows(role, tool) {
261
+ return role === "product" ? PRODUCT_TOOLS.includes(tool) : !PRODUCT_ONLY.has(tool);
262
+ }
263
+ function refusal(role, tool) {
264
+ return role === "product" ? {
265
+ code: "NOT_DEVELOPER",
266
+ message: `Your key is registered as a product person; \`${tool}\` is the developers'. A product session sees the build's questions, feedback and bugs, never its tasks.`
267
+ } : {
268
+ code: "NOT_PRODUCT",
269
+ message: `Your key is registered as a developer; \`${tool}\` is the product side's. Answers and reconciling are the spec project's, through a key registered as a product person.`
270
+ };
271
+ }
272
+
244
273
  // src/ssh.ts
245
274
  import { execFileSync as execFileSync2 } from "child_process";
246
275
  import { createHash } from "crypto";
@@ -359,11 +388,14 @@ var Session = class {
359
388
  this.fetchFn = opts.fetch ?? fetch;
360
389
  this.now = opts.now ?? Date.now;
361
390
  this.signer = opts.signer ?? sign;
391
+ this.role = opts.role;
362
392
  }
363
393
  token;
364
394
  fetchFn;
365
395
  now;
366
396
  signer;
397
+ /** The role asked for on every request, when the configuration means one (decision 33). */
398
+ role;
367
399
  /** How many times this session signed in, for tests and logs. */
368
400
  signIns = 0;
369
401
  async call(path, init) {
@@ -406,6 +438,7 @@ var Session = class {
406
438
  for (let attempt = 0; ; attempt++) {
407
439
  const headers = new Headers(init.headers);
408
440
  headers.set("authorization", `Bearer ${await this.bearer()}`);
441
+ if (this.role) headers.set(ROLE_HEADER, this.role);
409
442
  const res = await this.call(path, { ...init, headers });
410
443
  if (res.status !== 401 || attempt > 0) {
411
444
  if (res.status === 401 || res.status === 403) throw await errorOf(res, this.key);
@@ -422,7 +455,7 @@ function keyOf(loaded) {
422
455
  const configured = key && !/^(ssh-ed25519|sk-ssh-ed25519@openssh\.com) /.test(key) ? configPath(loaded.root, key) : key;
423
456
  return resolveKey({ configured });
424
457
  }
425
- var sessionOf = (loaded) => new Session(loaded.config.dispatcher, keyOf(loaded));
458
+ var sessionOf = (loaded) => new Session(loaded.config.dispatcher, keyOf(loaded), { role: roleOfConfig(loaded.config) });
426
459
 
427
460
  // src/bugs.ts
428
461
  import { z as z8 } from "zod";
@@ -1253,35 +1286,6 @@ import { z as z7 } from "zod";
1253
1286
 
1254
1287
  // src/mcp.ts
1255
1288
  import { createInterface } from "readline";
1256
-
1257
- // src/role.ts
1258
- var PRODUCT_TOOLS = [
1259
- "whoami",
1260
- "questions",
1261
- "answer",
1262
- "reconcile",
1263
- "feedback",
1264
- "bug_reports"
1265
- ];
1266
- var PRODUCT_ONLY = /* @__PURE__ */ new Set(["answer", "reconcile", "bug_reports"]);
1267
- function roleOf(whoami) {
1268
- if (whoami.role === "product" || whoami.role === "developer") return whoami.role;
1269
- return whoami.product === true ? "product" : "developer";
1270
- }
1271
- function allows(role, tool) {
1272
- return role === "product" ? PRODUCT_TOOLS.includes(tool) : !PRODUCT_ONLY.has(tool);
1273
- }
1274
- function refusal(role, tool) {
1275
- return role === "product" ? {
1276
- code: "NOT_DEVELOPER",
1277
- message: `Your key is registered as a product person; \`${tool}\` is the developers'. A product session sees the build's questions, feedback and bugs, never its tasks.`
1278
- } : {
1279
- code: "NOT_PRODUCT",
1280
- message: `Your key is registered as a developer; \`${tool}\` is the product side's. Answers and reconciling are the spec project's, through a key registered as a product person.`
1281
- };
1282
- }
1283
-
1284
- // src/mcp.ts
1285
1289
  var isRequest = (m) => m.method !== void 0 && m.id !== void 0;
1286
1290
  async function callTool(session, name, args = {}) {
1287
1291
  const res = await session.fetch("/mcp", {