gentle-pi 3.3.0 → 3.5.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.
Files changed (88) hide show
  1. package/README.md +88 -59
  2. package/assets/orchestrator-delegation.md +1 -1
  3. package/bin/gentle-shell.mjs +198 -0
  4. package/docs/assets/brand/gentle-shell-banner.gif +0 -0
  5. package/docs/assets/diagrams/odd-workflow.svg +74 -0
  6. package/docs/assets/features/agents-view.png +0 -0
  7. package/docs/assets/features/changes-view.png +0 -0
  8. package/docs/assets/features/command-palette.png +0 -0
  9. package/docs/assets/features/profiles-routing.png +0 -0
  10. package/docs/gentle-agents-activity.md +95 -0
  11. package/docs/gentle-shell.md +26 -2
  12. package/docs/readme-reference.md +99 -6
  13. package/extensions/ask-user-choice.ts +70 -22
  14. package/extensions/ask-user-question.ts +338 -0
  15. package/extensions/gentle-agents.ts +41 -1
  16. package/extensions/gentle-ai.ts +59 -18
  17. package/extensions/gentle-shell.ts +99 -10
  18. package/extensions/quiet-tools.ts +28 -5
  19. package/extensions/startup-banner.ts +25 -10
  20. package/lib/agents-rpc-publisher.ts +342 -0
  21. package/lib/agents-runner.ts +7 -2
  22. package/lib/animation-policy.ts +52 -0
  23. package/lib/background-cache-warming.ts +38 -0
  24. package/lib/command-palette-catalog.ts +1 -0
  25. package/lib/gentle-shell-launcher.ts +482 -0
  26. package/lib/inprocess-reviewer.ts +38 -1
  27. package/lib/native-review-cli.ts +36 -10
  28. package/lib/questionnaire/questionnaire-view.ts +603 -0
  29. package/lib/questionnaire/schema.ts +82 -0
  30. package/lib/questionnaire/validate.ts +141 -0
  31. package/lib/review-candidate-view-owner.ts +20 -5
  32. package/lib/review-candidate-view.ts +9 -2
  33. package/lib/review-host-relay.ts +10 -0
  34. package/lib/review-integration-v2.ts +4 -1
  35. package/lib/rpc-host.ts +36 -0
  36. package/lib/shell-bar.ts +13 -0
  37. package/lib/shell-sidebar-layout.ts +10 -4
  38. package/lib/shell-usage-view.ts +5 -2
  39. package/lib/shell-usage.ts +120 -6
  40. package/package.json +5 -1
  41. package/runtime/gentle-shell-launcher.mjs +483 -0
  42. package/runtime/native-review-cli.mjs +35 -9
  43. package/runtime/review-integration-v2.mjs +4 -1
  44. package/scripts/build-runtime-modules.mjs +1 -0
  45. package/scripts/gentle-ai-installer.mjs +10 -10
  46. package/scripts/install-gentle-ai.mjs +14 -7
  47. package/scripts/install-tui-mode-setting.mjs +78 -1
  48. package/scripts/verify-package-files.mjs +6 -3
  49. package/tests/agents-rpc-publisher.test.ts +407 -0
  50. package/tests/agents-runner.test.ts +10 -0
  51. package/tests/animation-policy.test.ts +42 -0
  52. package/tests/ask-user-choice.test.ts +129 -0
  53. package/tests/ask-user-question.test.ts +661 -0
  54. package/tests/background-cache-warming.test.ts +60 -0
  55. package/tests/background-subagents.test.ts +68 -0
  56. package/tests/command-palette.test.ts +9 -0
  57. package/tests/gentle-agents.test.ts +161 -2
  58. package/tests/gentle-ai-binary.test.ts +1 -1
  59. package/tests/gentle-ai-installer.test.ts +47 -47
  60. package/tests/gentle-ai.test.ts +56 -4
  61. package/tests/gentle-shell-bin.test.ts +188 -0
  62. package/tests/gentle-shell-launcher.test.ts +718 -0
  63. package/tests/gentle-shell.test.ts +355 -2
  64. package/tests/inprocess-reviewer.test.ts +92 -0
  65. package/tests/install-tui-mode-guard.test.ts +99 -0
  66. package/tests/install-tui-mode-setting.test.ts +39 -1
  67. package/tests/native-review-capability-contract.test.ts +16 -1
  68. package/tests/native-review-parity.test.ts +19 -0
  69. package/tests/package-manifest.test.ts +6 -17
  70. package/tests/questionnaire-schema.test.ts +274 -0
  71. package/tests/questionnaire-view.test.ts +446 -0
  72. package/tests/rdd-status-line.test.ts +21 -4
  73. package/tests/review-candidate-owner-retry.test.ts +63 -0
  74. package/tests/review-candidate-view.test.ts +15 -0
  75. package/tests/review-controller-native-routing.test.ts +86 -0
  76. package/tests/review-host-relay.test.ts +21 -0
  77. package/tests/review-integration-v2.test.ts +30 -0
  78. package/tests/review-ledger-contract.test.ts +1 -2
  79. package/tests/review-relay-transport-agent.test.ts +107 -2
  80. package/tests/review-risk-assessment.test.ts +104 -0
  81. package/tests/rpc-host.test.ts +77 -0
  82. package/tests/shell-bar.test.ts +8 -0
  83. package/tests/shell-sidebar-layout.test.ts +60 -5
  84. package/tests/shell-usage.test.ts +129 -0
  85. package/tests/skill-collision-prefixes.test.ts +1 -1
  86. package/tests/startup-banner.test.ts +93 -2
  87. package/docs/assets/brand/gentle-pi-banner.png +0 -0
  88. package/skills/release/SKILL.md +0 -137
@@ -7,15 +7,20 @@ import {
7
7
  parseAnthropicHeaders,
8
8
  parseCodexHeaders,
9
9
  parseNanQuota,
10
+ parseProviderUsage,
10
11
  parseUsageHeaders,
11
12
  parseCodexUsage,
13
+ parseUsageSource,
12
14
  providerNote,
13
15
  renderUsageBar,
14
16
  renderUsagePanel,
15
17
  SUPPORTED_USAGE_PROVIDERS,
18
+ UsageSourceRegistry,
19
+ USAGE_SOURCE_SCHEMA,
16
20
  UsageStore,
17
21
  windowLabel,
18
22
  type ProviderUsage,
23
+ type UsageSource,
19
24
  type UsageWindow,
20
25
  } from "../lib/shell-usage.ts";
21
26
 
@@ -243,6 +248,130 @@ test("nan is a supported usage provider with its own pending note", () => {
243
248
  assert.deepEqual(renderUsagePanel([], plainTheme, 100, NOW, { provider: "nan" }), ["✿ nan · no usage yet · r to fetch"]);
244
249
  });
245
250
 
251
+ // A generic hook: any extension can register a usage source for its own
252
+ // provider at runtime, without gentle-shell knowing anything about it.
253
+
254
+ test("parseUsageSource validates the registration payload and ignores anything malformed", () => {
255
+ const fetchFn = async () => undefined;
256
+ const valid = parseUsageSource({ schema: USAGE_SOURCE_SCHEMA, provider: "acme-cloud", fetch: fetchFn });
257
+ assert.equal(valid?.schema, USAGE_SOURCE_SCHEMA);
258
+ assert.equal(valid?.provider, "acme-cloud");
259
+ assert.equal(valid?.fetch, fetchFn);
260
+ assert.equal(valid?.pendingNote, undefined);
261
+
262
+ const withNote = parseUsageSource({ schema: USAGE_SOURCE_SCHEMA, provider: "acme-cloud", pendingNote: "warming up", fetch: fetchFn });
263
+ assert.equal(withNote?.pendingNote, "warming up");
264
+
265
+ assert.equal(parseUsageSource({ schema: "gentle-pi.usage-source/v0", provider: "acme-cloud", fetch: fetchFn }), undefined, "wrong schema");
266
+ assert.equal(parseUsageSource({ schema: USAGE_SOURCE_SCHEMA, provider: "", fetch: fetchFn }), undefined, "empty provider");
267
+ assert.equal(parseUsageSource({ schema: USAGE_SOURCE_SCHEMA, provider: "acme cloud", fetch: fetchFn }), undefined, "unsafe provider id");
268
+ assert.equal(parseUsageSource({ schema: USAGE_SOURCE_SCHEMA, provider: "acme-cloud", fetch: "nope" }), undefined, "fetch not a function");
269
+ assert.equal(parseUsageSource({ schema: USAGE_SOURCE_SCHEMA, provider: "acme-cloud", pendingNote: 7, fetch: fetchFn }), undefined, "pendingNote must be a string when present");
270
+ assert.equal(parseUsageSource(null), undefined);
271
+ assert.equal(parseUsageSource(undefined), undefined);
272
+ assert.equal(parseUsageSource("acme-cloud"), undefined);
273
+ assert.equal(parseUsageSource({}), undefined);
274
+ });
275
+
276
+ test("UsageSourceRegistry replaces a provider's source on re-registration", () => {
277
+ const registry = new UsageSourceRegistry();
278
+ assert.equal(registry.has("acme-cloud"), false);
279
+ assert.equal(registry.get("acme-cloud"), undefined);
280
+ assert.equal(registry.note("acme-cloud"), undefined);
281
+
282
+ const first: UsageSource = { schema: USAGE_SOURCE_SCHEMA, provider: "acme-cloud", fetch: async () => undefined };
283
+ registry.register(first);
284
+ assert.equal(registry.has("acme-cloud"), true);
285
+ assert.equal(registry.get("acme-cloud"), first);
286
+ assert.equal(registry.note("acme-cloud"), "no usage yet · r to fetch", "default note when the source sets none");
287
+
288
+ const second: UsageSource = { schema: USAGE_SOURCE_SCHEMA, provider: "acme-cloud", pendingNote: "still warming up", fetch: async () => undefined };
289
+ registry.register(second);
290
+ assert.equal(registry.get("acme-cloud"), second, "re-registration replaces, never accumulates");
291
+ assert.equal(registry.note("acme-cloud"), "still warming up");
292
+ });
293
+
294
+ test("a registered provider is supported without touching the built-in note map", () => {
295
+ const registry = new UsageSourceRegistry();
296
+ assert.equal(providerNote("acme-cloud"), "no subscription usage for this provider");
297
+ assert.equal(providerNote("acme-cloud", registry), "no subscription usage for this provider", "an empty registry changes nothing");
298
+ registry.register({ schema: USAGE_SOURCE_SCHEMA, provider: "acme-cloud", fetch: async () => undefined });
299
+ assert.equal(providerNote("acme-cloud", registry), "no usage yet · r to fetch");
300
+ assert.equal(providerNote("nan", registry), "no usage yet · r to fetch", "the static built-ins are unaffected");
301
+ assert.deepEqual(renderUsagePanel([], plainTheme, 100, NOW, { provider: "acme-cloud" }, registry), ["✿ acme-cloud · no usage yet · r to fetch"]);
302
+ });
303
+
304
+ // A registered source's resolved value crosses the same trust boundary a
305
+ // parsed HTTP payload does. parseProviderUsage validates it exactly like
306
+ // one, and the object gentle-shell records is always freshly built, never
307
+ // the caller's own reference.
308
+
309
+ const VALID_SOURCE_USAGE = {
310
+ provider: "acme-cloud",
311
+ plan: "Acme · 42 credits",
312
+ fetchedAt: 100,
313
+ limits: [
314
+ {
315
+ name: "acme-cloud",
316
+ limitReached: false,
317
+ windows: [
318
+ { label: "week", usedPercent: 40, windowSeconds: 604_800, resetAt: null },
319
+ { label: "day", usedPercent: 12, windowSeconds: 86_400, resetAt: 200, used: 5, budget: 40 },
320
+ ],
321
+ },
322
+ ],
323
+ };
324
+
325
+ test("parseProviderUsage accepts a matching shape and copies it defensively", () => {
326
+ const source = structuredClone(VALID_SOURCE_USAGE);
327
+ const parsed = parseProviderUsage(source, "acme-cloud");
328
+ assert.deepEqual(parsed, source);
329
+ assert.notEqual(parsed, source, "the recorded object must never be the caller's own reference");
330
+ assert.notEqual(parsed?.limits, source.limits);
331
+ assert.notEqual(parsed?.limits[0], source.limits[0]);
332
+ assert.notEqual(parsed?.limits[0].windows, source.limits[0].windows);
333
+ assert.notEqual(parsed?.limits[0].windows[0], source.limits[0].windows[0]);
334
+
335
+ // Mutating the caller's own object after the fact must never reach the copy.
336
+ source.limits[0].windows[0].usedPercent = 999;
337
+ assert.equal(parsed?.limits[0].windows[0].usedPercent, 40);
338
+ });
339
+
340
+ test("parseProviderUsage rejects a resolution for a different provider", () => {
341
+ assert.equal(parseProviderUsage(structuredClone(VALID_SOURCE_USAGE), "other-provider"), undefined);
342
+ });
343
+
344
+ test("parseProviderUsage rejects a missing or malformed limits array", () => {
345
+ assert.equal(parseProviderUsage({ provider: "acme-cloud", plan: undefined, fetchedAt: 0 }, "acme-cloud"), undefined, "limits missing entirely");
346
+ assert.equal(parseProviderUsage({ provider: "acme-cloud", plan: undefined, fetchedAt: 0, limits: "nope" }, "acme-cloud"), undefined, "limits not an array");
347
+ assert.equal(
348
+ parseProviderUsage({ provider: "acme-cloud", plan: undefined, fetchedAt: 0, limits: [{ name: "x", limitReached: "nope", windows: [] }] }, "acme-cloud"),
349
+ undefined,
350
+ "limitReached must be a boolean",
351
+ );
352
+ });
353
+
354
+ test("parseProviderUsage rejects a non-numeric usedPercent inside a window", () => {
355
+ const usage = structuredClone(VALID_SOURCE_USAGE);
356
+ (usage.limits[0].windows[0] as unknown as { usedPercent: unknown }).usedPercent = "40";
357
+ assert.equal(parseProviderUsage(usage, "acme-cloud"), undefined);
358
+ });
359
+
360
+ test("parseProviderUsage rejects a limit whose windows is not an array", () => {
361
+ const usage = structuredClone(VALID_SOURCE_USAGE);
362
+ (usage.limits[0] as unknown as { windows: unknown }).windows = "nope";
363
+ assert.equal(parseProviderUsage(usage, "acme-cloud"), undefined);
364
+ });
365
+
366
+ test("parseProviderUsage rejects malformed inputs outright", () => {
367
+ assert.equal(parseProviderUsage(undefined, "acme-cloud"), undefined);
368
+ assert.equal(parseProviderUsage(null, "acme-cloud"), undefined);
369
+ assert.equal(parseProviderUsage("acme-cloud", "acme-cloud"), undefined);
370
+ assert.equal(parseProviderUsage({ provider: "acme-cloud", plan: 7, fetchedAt: 0, limits: [] }, "acme-cloud"), undefined, "plan must be a string when present");
371
+ assert.equal(parseProviderUsage({ provider: "acme-cloud", plan: undefined, fetchedAt: Number.POSITIVE_INFINITY, limits: [] }, "acme-cloud"), undefined, "fetchedAt must be finite");
372
+ assert.deepEqual(parseProviderUsage({ provider: "acme-cloud", plan: undefined, fetchedAt: 0, limits: [] }, "acme-cloud"), { provider: "acme-cloud", plan: undefined, fetchedAt: 0, limits: [] });
373
+ });
374
+
246
375
  test("renderUsagePanel lists each NaN model allowance with its reset on the same row", () => {
247
376
  const usage = parseNanQuota(NAN_QUOTA, NOW);
248
377
  const lines = renderUsagePanel([usage], plainTheme, 80, NOW, { provider: "nan" });
@@ -25,7 +25,7 @@ const PREFIXED_NAMES: Record<string, string> = {
25
25
  "work-unit-commits": "gentle-ai-work-unit-commits",
26
26
  };
27
27
 
28
- const UNPREFIXED_DIRS = ["gentle-ai", "release"];
28
+ const UNPREFIXED_DIRS = ["gentle-ai"];
29
29
 
30
30
  for (const [dir, expectedName] of Object.entries(PREFIXED_NAMES)) {
31
31
  test(`skills/${dir}/SKILL.md frontmatter name is prefixed`, () => {
@@ -2,7 +2,9 @@ import assert from "node:assert/strict";
2
2
  import test from "node:test";
3
3
  import { syncBuiltinESMExports } from "node:module";
4
4
  import fs from "node:fs/promises";
5
- import { readFileSync } from "node:fs";
5
+ import { mkdtempSync, readFileSync, rmSync, writeFileSync } from "node:fs";
6
+ import { tmpdir } from "node:os";
7
+ import { join } from "node:path";
6
8
  import startup, { readGitBranch } from "../extensions/startup-banner.ts";
7
9
  import type { ExtensionAPI } from "@earendil-works/pi-coding-agent";
8
10
  import { visibleWidth } from "@earendil-works/pi-tui";
@@ -74,6 +76,15 @@ test("startup branch lookup uses direct git argv and hides its Windows child", a
74
76
  });
75
77
 
76
78
  test("startup banner keeps animating after invalidate and cleans up on dispose", async (t) => {
79
+ const home = mkdtempSync(join(tmpdir(), "gp-banner-quality-"));
80
+ writeFileSync(join(home, "animations.json"), '{"schema":"gentle-pi.animations/v1","policy":"quality"}');
81
+ const previousHome = process.env.GENTLE_PI_CONFIG_HOME;
82
+ process.env.GENTLE_PI_CONFIG_HOME = home;
83
+ t.after(() => {
84
+ if (previousHome === undefined) delete process.env.GENTLE_PI_CONFIG_HOME;
85
+ else process.env.GENTLE_PI_CONFIG_HOME = previousHome;
86
+ rmSync(home, { recursive: true, force: true });
87
+ });
77
88
  t.mock.timers.enable({ apis: ["setTimeout", "setInterval", "Date"] });
78
89
  t.mock.method(fs, "readFile", async () => JSON.stringify({ showRose: true, showTextLogo: true, color: "pink" }));
79
90
  syncBuiltinESMExports();
@@ -115,6 +126,85 @@ test("startup banner keeps animating after invalidate and cleans up on dispose",
115
126
  assert.equal(renders, afterDispose, "session_shutdown cleanup stays idle");
116
127
  });
117
128
 
129
+ test("animation modes retain banner lifetime policy, final artwork and approximate duration", async (t) => {
130
+ const home = mkdtempSync(join(tmpdir(), "gp-banner-animations-"));
131
+ const previousHome = process.env.GENTLE_PI_CONFIG_HOME;
132
+ process.env.GENTLE_PI_CONFIG_HOME = home;
133
+ t.after(() => {
134
+ if (previousHome === undefined) delete process.env.GENTLE_PI_CONFIG_HOME;
135
+ else process.env.GENTLE_PI_CONFIG_HOME = previousHome;
136
+ rmSync(home, { recursive: true, force: true });
137
+ });
138
+ t.mock.method(fs, "readFile", async () => JSON.stringify({ showRose: true, showTextLogo: true, color: "pink" }));
139
+ syncBuiltinESMExports();
140
+ t.after(() => { t.mock.restoreAll(); syncBuiltinESMExports(); });
141
+ const argv = process.argv;
142
+ process.argv = ["node"];
143
+ t.after(() => { process.argv = argv; });
144
+ for (const [key, value] of [["rows", 40], ["columns", 200]] as const) {
145
+ const descriptor = Object.getOwnPropertyDescriptor(process.stdout, key);
146
+ Object.defineProperty(process.stdout, key, { configurable: true, writable: true, value });
147
+ t.after(() => descriptor ? Object.defineProperty(process.stdout, key, descriptor) : Reflect.deleteProperty(process.stdout, key));
148
+ }
149
+ let boot: () => void;
150
+ let pulse: () => void;
151
+ let active = false;
152
+ let delay = 0;
153
+ let clock = 0;
154
+ let paints = 0;
155
+ t.mock.method(Date, "now", () => clock);
156
+ t.mock.method(globalThis, "setTimeout", (callback: () => void, ms: number) => {
157
+ if (ms === 50) boot = callback; // Never run operational stats/home reads.
158
+ return {};
159
+ });
160
+ t.mock.method(globalThis, "setInterval", (callback: () => void, ms: number) => {
161
+ pulse = callback; delay = ms; active = true; return {};
162
+ });
163
+ t.mock.method(globalThis, "clearInterval", () => { active = false; });
164
+ let start: (event: unknown, ctx: unknown) => Promise<void>;
165
+ let shutdown: () => void;
166
+ let header: { render(width: number): string[]; dispose(): void };
167
+ // Stroke warmup is module-global; keep duration driving isolated from cold-start tests.
168
+ const { default: isolatedStartup } = await import(new URL("../extensions/startup-banner.ts?animations", import.meta.url).href) as typeof import("../extensions/startup-banner.ts");
169
+ isolatedStartup({ on: (name: string, fn: typeof start) => {
170
+ if (name === "session_start") start = fn;
171
+ if (name === "session_shutdown") shutdown = fn as unknown as () => void;
172
+ }, registerCommand() {}, getCommands: () => [], getAllTools: () => [] } as unknown as ExtensionAPI);
173
+ const ctx = { hasUI: true, cwd: "/fixture", ui: { setHeader(factory: (tui: unknown, theme: unknown) => typeof header) {
174
+ header = factory({ requestRender() { paints++; } }, { fg: (_role: string, text: string) => text });
175
+ } } };
176
+ const save = (policy: string) => writeFileSync(join(home, "animations.json"), JSON.stringify({ schema: "gentle-pi.animations/v1", policy }));
177
+ try {
178
+ save("potato");
179
+ await start!({}, ctx); boot!();
180
+ assert.equal(active, false, "potato starts no animation interval");
181
+ const staticArt = stripAnsi(header!.render(200).join("\n"));
182
+ assert.match(staticArt, /[▄▀█]/);
183
+ assert.match(staticArt, /[\u2800-\u28ff]/);
184
+ header!.dispose();
185
+ let qualityDuration = 0;
186
+ let qualityPaints = 0;
187
+ for (const policy of ["quality", "performance"]) {
188
+ save(policy);
189
+ await start!({}, ctx); boot!();
190
+ for (let i = 0; i < 15; i++) await new Promise<void>((resolve) => setImmediate(resolve));
191
+ assert.equal(delay, policy === "quality" ? 25 : 250);
192
+ save("potato"); // Already-created animation keeps its policy.
193
+ const began = clock;
194
+ const before = paints;
195
+ while (active && clock - began <= 5500) { clock += delay; pulse!(); }
196
+ assert.equal(active, false, "finishes and clears the interval");
197
+ assert.equal(stripAnsi(header!.render(200).join("\n")), staticArt);
198
+ if (policy === "quality") { qualityDuration = clock - began; qualityPaints = paints - before; }
199
+ else {
200
+ assert.ok(Math.abs(clock - began - qualityDuration) <= 250);
201
+ assert.ok(paints - before <= Math.ceil(qualityPaints / 10));
202
+ }
203
+ header!.dispose();
204
+ }
205
+ } finally { shutdown!(); }
206
+ });
207
+
118
208
  // Drive the real header factory; background git/home reads never run.
119
209
  for (const showRose of [false, true]) for (const showTextLogo of [false, true]) {
120
210
  test(`startup art respects rose=${showRose}, logo=${showTextLogo} and cyan palette`, async (t) => {
@@ -134,7 +224,8 @@ for (const showRose of [false, true]) for (const showTextLogo of [false, true])
134
224
  let shutdown: Function;
135
225
  let header: { render(width: number): string[]; dispose(): void };
136
226
  const writes: string[] = [];
137
- startup({ on: (name: string, fn: Function) => {
227
+ const { default: coldStartup } = await import(new URL(`../extensions/startup-banner.ts?art-${showRose}-${showTextLogo}`, import.meta.url).href) as typeof import("../extensions/startup-banner.ts");
228
+ coldStartup({ on: (name: string, fn: Function) => {
138
229
  if (name === "session_start") start = fn;
139
230
  if (name === "session_shutdown") shutdown = fn;
140
231
  }, registerCommand() {}, getCommands: () => [], getAllTools: () => [] } as unknown as ExtensionAPI);
@@ -1,137 +0,0 @@
1
- ---
2
- name: release
3
- description: "Release gentle-pi through GitHub and npm. Trigger: release, publish, npm publish, GitHub release, version bump."
4
- license: Apache-2.0
5
- metadata:
6
- author: gentleman-programming
7
- version: "1.2"
8
- ---
9
-
10
- ## When to Use
11
-
12
- Use this skill when preparing, publishing, or verifying a `gentle-pi` release.
13
-
14
- ## Hard Rules
15
-
16
- - Do not publish `gentle-pi` to npm from a local machine.
17
- - npm publishing MUST go through the GitHub Actions workflow `.github/workflows/publish.yml` so provenance, environment protection, and registry credentials are controlled by GitHub.
18
- - Dispatch the trusted workflow definition from protected default `main`, never from a release tag. Its only caller input is the exact annotated version tag.
19
- - Use a clean worktree for release commits. Do not package unrelated local files or scratch artifacts.
20
- - Review outcomes are informational. Release delivery follows ordinary repository policy and must not be blocked, authorized, or rewritten by RDD.
21
- - Never infer the release tag target from local `HEAD`; use the freshly fetched `origin/main` commit and the repository's normal release safeguards.
22
- - Never skip package verification. The publish workflow runs verification again, but local validation should still pass before tagging.
23
-
24
- ## Release Procedure
25
-
26
- 1. **Inspect state**
27
-
28
- ```bash
29
- git status --short
30
- git fetch origin main --tags
31
- git log --oneline --decorate --max-count=5 origin/main
32
- ```
33
-
34
- 2. **Prepare the release commit**
35
-
36
- - Apply only intended changes.
37
- - Bump `package.json` to the next semver version.
38
- - Keep lockfile changes out unless dependency resolution actually changed.
39
-
40
- 3. **Verify locally**
41
-
42
- ```bash
43
- pnpm test
44
- node scripts/verify-package-files.mjs
45
- npm pack --dry-run
46
- ```
47
-
48
- `npm pack --dry-run` verifies package contents and lifecycle scripts without entering a publish path.
49
-
50
- 4. **Commit and push**
51
-
52
- ```bash
53
- git add <intended-files>
54
- git commit -m "<type(scope): release-ready change>"
55
- git push origin HEAD:main
56
- git fetch origin main --tags
57
- ```
58
-
59
- 5. **Create and verify the exact version tag**
60
-
61
- ```bash
62
- version="$(node -p "require('./package.json').version")"
63
- tag="v${version}"
64
- release_sha="$(git rev-parse 'origin/main^{commit}')"
65
-
66
- test "$(git rev-parse 'HEAD^{commit}')" = "${release_sha}"
67
- test -z "$(git ls-remote --tags origin "refs/tags/${tag}")"
68
-
69
- git tag -a "${tag}" "${release_sha}" -m "gentle-pi ${tag}"
70
- test "$(git rev-parse "${tag}^{commit}")" = "${release_sha}"
71
-
72
- git fetch origin main
73
- test "$(git rev-parse 'origin/main^{commit}')" = "${release_sha}"
74
- git push origin "refs/tags/${tag}"
75
-
76
- git fetch --no-tags origin "refs/tags/${tag}"
77
- test "$(git rev-parse 'FETCH_HEAD^{commit}')" = "${release_sha}"
78
-
79
- gh release create "${tag}" \
80
- --repo Gentleman-Programming/gentle-pi \
81
- --verify-tag \
82
- --title "gentle-pi ${tag}" \
83
- --notes "<release notes>"
84
- ```
85
-
86
- Do not retag or overwrite an existing version. The tag target comes from the freshly fetched immutable `origin/main` commit, not an ambient local branch.
87
-
88
- 6. **Publish npm through GitHub Actions**
89
-
90
- ```bash
91
- version="$(node -p "require('./package.json').version")"
92
- tag="v${version}"
93
- gh workflow run publish.yml \
94
- --repo Gentleman-Programming/gentle-pi \
95
- --ref main \
96
- -f tag="${tag}"
97
- ```
98
-
99
- The workflow definition always comes from protected default `main`. It accepts only one exact `vSemVer` tag, fetches the remote annotated tag and current remote `main`, and requires the peeled tag commit, dispatch/main workflow commit, checkout, and `package.json` version to match. It re-queries remote tag and `main` immediately before npm publication, derives the dist-tag internally, and uses trusted OIDC with provenance.
100
-
101
- Watch the run and fail the release if it fails:
102
-
103
- ```bash
104
- gh run list --repo Gentleman-Programming/gentle-pi --workflow publish.yml --limit 3
105
- gh run watch <run-id> --repo Gentleman-Programming/gentle-pi --exit-status
106
- ```
107
-
108
- 7. **Verify npm**
109
-
110
- ```bash
111
- npm view gentle-pi@<version> version --registry=https://registry.npmjs.org/
112
- npm dist-tag ls gentle-pi --registry=https://registry.npmjs.org/
113
- ```
114
-
115
- ## Failure Handling
116
-
117
- - A publication failure is handled through ordinary repository policy. It does not reopen or alter a review lineage.
118
- - Never attempt or retry `npm publish` locally. Re-dispatch from trusted `main` only when the same tag still targets the current remote `main` and the failure was publication-only.
119
- - If remote `main` advances, do not move or recreate the existing tag. Prepare a new release commit/version and create a new annotated version tag.
120
- - If the workflow fails, inspect logs with:
121
-
122
- ```bash
123
- gh run view <run-id> --repo Gentleman-Programming/gentle-pi --log
124
- ```
125
-
126
- - If npm verification is briefly stale after a successful workflow, check the exact version first (`npm view gentle-pi@<version> version`) before assuming publish failed.
127
-
128
- ## Output Contract
129
-
130
- Report:
131
-
132
- - Commit SHA pushed to `main`.
133
- - Exact version tag and its peeled commit SHA.
134
- - GitHub release URL.
135
- - Publish workflow run URL and conclusion.
136
- - npm exact version and the workflow-derived dist-tag (`latest`, `beta`, or `next`).
137
- - Any remaining follow-up or warnings.