@bluenyang/reins 0.1.4-rc.1 → 0.1.4-rc.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.
@@ -2,6 +2,7 @@ import { existsSync, readFileSync, readdirSync, rmdirSync, rmSync } from 'node:f
2
2
  import { dirname, join } from 'node:path';
3
3
  import { parse, stringify } from 'yaml';
4
4
  import { planMemoryProposals } from '../lib/memory.js';
5
+ import { draftRelease, releaseDraftNotes } from '../lib/release.js';
5
6
  import { applyBlocks, parseBlocks } from '../lib/blocks.js';
6
7
  import { CONFIRMED_MODELS, checkBinding, discoverGates, newModelCache, vendorOf, generation, stacks, vendors, } from '../lib/detect.js';
7
8
  import { apply, listFiles } from '../lib/fsx.js';
@@ -186,6 +187,8 @@ export async function runInstall(o) {
186
187
  .map((x) => x.trim())
187
188
  .filter(Boolean));
188
189
  chosen = proposal.proposals.filter((g) => names.has(g.name));
190
+ if (o.dryRun)
191
+ notes.push(`subdirectory gates offered (names are asked in a real run): ${listing}`);
189
192
  for (const n of names)
190
193
  if (!chosen.some((g) => g.name === n))
191
194
  notes.push(`no such subdirectory gate: ${n}`);
@@ -252,6 +255,8 @@ export async function runInstall(o) {
252
255
  writes.push(...memory.writes);
253
256
  notes.push(...memory.notes);
254
257
  }
258
+ // 4c. a release: draft from dispatchable workflows — proposal only, never written
259
+ notes.push(...releaseDraftNotes(draftRelease(root)));
255
260
  // 5. AGENTS.md managed blocks, CLAUDE.md pointer
256
261
  const agentsPath = join(root, 'AGENTS.md');
257
262
  const agents = existsSync(agentsPath) ? readFileSync(agentsPath, 'utf8') : '# AGENTS.md\n';
@@ -65,7 +65,7 @@ export async function runMigrate(o) {
65
65
  if (gen === 'none')
66
66
  return { ...res, refused: 'no existing harness or workspace here — use `reins install`' };
67
67
  // 1. make sure the target layout exists (install is idempotent)
68
- if (!o.dryRun) {
68
+ {
69
69
  const inst = await runInstall({
70
70
  tier: o.tier,
71
71
  mode: o.mode,
@@ -74,6 +74,7 @@ export async function runMigrate(o) {
74
74
  detectVendors: o.detectVendors,
75
75
  now: o.now,
76
76
  overExisting: true,
77
+ dryRun: o.dryRun, // plans only: gate proposals and memory drafts show up as notes
77
78
  });
78
79
  if (inst.refused)
79
80
  return { ...res, refused: inst.refused };
@@ -1,4 +1,4 @@
1
- import { existsSync, readFileSync } from 'node:fs';
1
+ import { existsSync, readdirSync, readFileSync } from 'node:fs';
2
2
  import { join } from 'node:path';
3
3
  import { parse } from 'yaml';
4
4
  /** Reads `release:` from install.yaml; null when the file or the key is missing or malformed. */
@@ -52,3 +52,73 @@ export function dispatchLines(workflows, stage, version) {
52
52
  return ['gh workflow run', shq(w.file), ...args].join(' ');
53
53
  });
54
54
  }
55
+ /**
56
+ * Proposes `release:` settings (design §4) from `.github/workflows/*.yml|yaml` that have an
57
+ * `on: workflow_dispatch` trigger (string, list or map form). Pure: reads, never writes; files
58
+ * that do not parse are ignored. Returns [] when install.yaml already has a `release:` key.
59
+ */
60
+ const RELEASE_NAME = /release|publish|deploy|ship/i;
61
+ export function draftRelease(root) {
62
+ const pin = join(root, '.agents/harness/install.yaml');
63
+ if (existsSync(pin))
64
+ try {
65
+ const doc = parse(readFileSync(pin, 'utf8'));
66
+ if (doc && typeof doc === 'object' && 'release' in doc)
67
+ return [];
68
+ }
69
+ catch {
70
+ // an unreadable pin has no release key to respect
71
+ }
72
+ const dir = join(root, '.github/workflows');
73
+ if (!existsSync(dir))
74
+ return [];
75
+ const out = [];
76
+ for (const f of readdirSync(dir).sort()) {
77
+ if (!/\.ya?ml$/.test(f))
78
+ continue;
79
+ let doc;
80
+ try {
81
+ doc = parse(readFileSync(join(dir, f), 'utf8'));
82
+ }
83
+ catch {
84
+ continue;
85
+ }
86
+ if (!doc || typeof doc !== 'object')
87
+ continue;
88
+ const d = doc;
89
+ const on = 'on' in d ? d['on'] : d['true']; // YAML 1.1 readers turn `on` into true
90
+ let dispatch;
91
+ if (on === 'workflow_dispatch')
92
+ dispatch = {};
93
+ else if (Array.isArray(on))
94
+ dispatch = on.includes('workflow_dispatch') ? {} : undefined;
95
+ else if (on && typeof on === 'object' && 'workflow_dispatch' in on)
96
+ dispatch = on['workflow_dispatch'] ?? {};
97
+ if (dispatch === undefined)
98
+ continue;
99
+ const declared = dispatch?.inputs;
100
+ const inputs = {};
101
+ if (declared && typeof declared === 'object')
102
+ for (const [name, spec] of Object.entries(declared)) {
103
+ const type = spec?.type;
104
+ inputs[name] =
105
+ name === 'version'
106
+ ? '{version}'
107
+ : name === 'tag'
108
+ ? 'v{version}'
109
+ : type === 'boolean'
110
+ ? 'false'
111
+ : '<fill in>';
112
+ }
113
+ out.push({ file: f, inputs, approval: 'none' });
114
+ }
115
+ // CI and scanners are often dispatchable too: when some workflow looks like a release, propose only those
116
+ const releasing = out.filter((d) => RELEASE_NAME.test(d.file));
117
+ return releasing.length ? releasing : out;
118
+ }
119
+ /** The notes install and migrate print for a draft (and their dry runs). */
120
+ export function releaseDraftNotes(drafts) {
121
+ return drafts.map((d) => `release settings draft (not written; add under release.workflows in install.yaml if right): {file: ${d.file}, inputs: {${Object.entries(d.inputs)
122
+ .map(([k, v]) => `${k}: ${JSON.stringify(v)}`)
123
+ .join(', ')}}, approval: ${d.approval}}`);
124
+ }
package/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "@bluenyang/reins",
3
- "version": "0.1.4-rc.1",
3
+ "version": "0.1.4-rc.2",
4
4
  "description": "Installs, migrates and updates an agent harness (harness → loop → graph) that keeps coding agents inside their permitted roles.",
5
5
  "license": "MIT",
6
6
  "repository": {
@@ -6,7 +6,7 @@ description: Install reins in this repository, or move an existing harness onto
6
6
  # reins-setup
7
7
 
8
8
  You act as the **pm** role (`.agents/harness/roles/pm.md` once installed). The CLI does the work; you collect
9
- the answers only the user can give and report what happened. Run the CLI as `npx @bluenyang/reins@0.1.4-rc.1 …`
9
+ the answers only the user can give and report what happened. Run the CLI as `npx @bluenyang/reins@0.1.4-rc.2 …`
10
10
  (the version is pinned to this skill's release; inside the reins repository itself: `node cli/dist/reins.js …`).
11
11
 
12
12
  Defaults from the plugin settings: language `${user_config.language}`, install mode `${user_config.default_mode}`.