@patronage/software-factory 1.0.0-alpha.45 → 1.0.0-alpha.47

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
@@ -32,7 +32,7 @@ This is the release checklist. It lives here and nowhere else; the repository ru
32
32
 
33
33
  Releases are attended. Nothing in the factory publishes, tags, or releases on its own, and no step below may be automated as a drive-by. Delivery closeout (`boundary:check --final`, then `factory:closeout` on the epic) is a separate act with a separate owner: it closes the epic and releases nothing. Only a release-owning boundary carries a release, and one issue at a time holds that authority for a given version. A docs-only or non-release-owning runtime boundary closes without a bump and waits for the next attended cut. The admission skill's [closeout reference](../skills/patronage-software-factory-admission/references/epic-closeout.md#delivery-closeout-is-not-a-release) states the same split from the closeout side.
34
34
 
35
- The factory family has one version posture (ADR 0026, `docs/adr/0026-factory-family-version-lines-move-in-lockstep.md` in the source repository): `@patronage/factory-ci` moves in lockstep majors with this CLI. From factory-ci's first release in the CLI's current series onward, majors and prerelease series move together while patch and prerelease increments stay independent per package. A consumer pins a factory-ci from the same major/prerelease series as its CLI; there is no compatibility matrix. Until that first lockstep release, factory-ci's published 0.x line is the named pre-adoption state and pairs with any CLI version. `@patronage/alchemy-d1-state` keeps independent SemVer. Lockstep is a rule the maintainer follows when cutting releases, never automation.
35
+ The factory family has one version posture (ADR 0026, `docs/adr/0026-factory-family-version-lines-move-in-lockstep.md` in the source repository): `@patronage/factory-ci` and this CLI always release together at the same version, even when only one of them changed. A consumer pins both at the same version; there is no compatibility matrix. Until factory-ci's first 1.x release, its published 0.x line is the named pre-adoption state and pairs with any CLI version. `@patronage/alchemy-d1-state` keeps independent SemVer. Lockstep is a rule the maintainer follows when cutting releases, never automation.
36
36
 
37
37
  For a release-owning epic boundary, the terminal oracle runs before the version-bump pull request merges. The candidate it reviews is exact: the merged implementation children plus the open release-owning version-bump PR at its head. Repair its findings inside the same engagement and re-earn the affected evidence before the bump merges. Once the bump merges, the publish, tag, and GitHub release below follow immediately; the six-fact convergence assertion in step 6 stays the post-publication machine readback, never the first correctness review of released behavior. A bump merged before the oracle burns the version number and forces a forward release — that is how alpha.11 needed alpha.12 on 2026-08-09. Nothing enforces this ordering (ADR 0024, `docs/adr/0024-prose-explains-it-never-enforces.md` in the source repository); it is release discipline the maintainer follows.
38
38
 
@@ -51,7 +51,7 @@ A stable cut has two phases. Phase 1 is the verified package candidate: steps 1
51
51
  pnpm --filter @patronage/software-factory exec tsx scripts/assert-publish-manifest.ts --release .
52
52
  ```
53
53
 
54
- It reads what you just did and derives the channel from the manifest version. A stable release must converge exactly among manifest, npm `latest`, non-prerelease GitHub release, tag, and stable docs. A prerelease must exist on npm, own npm `next`, leave npm `latest` at the stable docs version, and have its prerelease GitHub release and tag. The sixth fact is the factory-ci pairing above: the assertion passes while every observed published `@patronage/factory-ci` version is pre-adoption 0.x and names that state, fails once a lockstep factory-ci release exists whose newest published version is outside the CLI's major/prerelease series, and fails when the registry read yields no readable factory-ci versions or contains an entry that does not parse — missing or unreadable data is an unsatisfied fact, not pre-adoption. It publishes nothing. Step 6 is the only step a machine performs, and it performs it after you.
54
+ It reads what you just did and derives the channel from the manifest version. A stable release must converge exactly among manifest, npm `latest`, non-prerelease GitHub release, tag, and stable docs. A prerelease must exist on npm, own npm `next`, leave npm `latest` at the stable docs version, and have its prerelease GitHub release and tag. The sixth fact is the factory-ci pairing above: the assertion passes while every observed published `@patronage/factory-ci` version is pre-adoption 0.x and names that state, fails once a lockstep factory-ci release exists but factory-ci has not published the CLI's exact version, and fails when the registry read yields no readable factory-ci versions or contains an entry that does not parse — missing or unreadable data is an unsatisfied fact, not pre-adoption. It publishes nothing. Step 6 is the only step a machine performs, and it performs it after you.
55
55
 
56
56
  ## Use it in a project
57
57
 
@@ -77,3 +77,28 @@ npx skills add https://github.com/patronage/software-factory -g --all
77
77
  They provide procedure and link back to the documentation site; they are not a second command reference.
78
78
 
79
79
  `assembleReviewPrompt` puts a repository-root `CODING_STANDARDS.md` into the correctness prompt when the file exists and is not blank. It reads the file at the candidate head, not from the working tree, and emits one `coding-standards` section that names the head SHA. A repository without the file gets an unchanged prompt. `pr:review --assemble` writes that factory-owned prompt under `.factory-memory/pr-review-prompt.json`. `pr:review --findings` copies the recorded sections onto the proof when the artifact's patch-id matches.
80
+
81
+ ## Cloud credential adapters
82
+
83
+ The `@patronage/software-factory/cloud` subpath provides `cloudCredentialEnvironment(env, references)` and `readCloudSecret(ref, env)`. Repository adapters supply an explicit map from child environment variable names to reviewed `op://vault/item/field` references. The module supplies no vault, item, runtime, command or deployment defaults. It uses only `op-fast item get`, keeps values in memory, suppresses resolver output in errors, and strips 1Password authority, reference variables and unrelated Factory HQ/D1/npm credentials from the returned child environment. The caller's environment is unchanged. This is credential delivery, not a general environment sandbox.
84
+
85
+ ```js
86
+ import { spawnSync } from "node:child_process";
87
+
88
+ import { cloudCredentialEnvironment } from "@patronage/software-factory/cloud";
89
+
90
+ // Repository-owned policy selects its runtime and approved item references.
91
+ const env = cloudCredentialEnvironment(process.env, {
92
+ CF_ACCESS_CLIENT_ID: process.env.FACTORY_HQ_CLIENT_ID_REF,
93
+ CF_ACCESS_CLIENT_SECRET: process.env.FACTORY_HQ_CLIENT_SECRET_REF,
94
+ });
95
+ const result = spawnSync("psf", ["doctor", "--preflight"], {
96
+ env,
97
+ stdio: "inherit",
98
+ });
99
+ process.exitCode = result.status ?? 1;
100
+ ```
101
+
102
+ Install tools without credentials during the environment build, after the repository's own dependency installation. Resolve the shipped installer with `import.meta.resolve("@patronage/software-factory/cloud/install-tools.sh")`, convert that file URL with `fileURLToPath`, and run it through Bash with an absolute bin directory argument. It installs checksum-pinned Linux binaries; macOS, unsupported architectures and archive mismatches fail closed. Put that bin directory on the runtime PATH using the repository's existing setup path. Never resolve secrets during the build or write resolved values to shell profiles or hook export files. The module needs Node 24 and a runtime `OP_SERVICE_ACCOUNT_TOKEN`; it does not install tools or select a runtime.
103
+
104
+ These exports ship from `1.0.0-alpha.47`; `1.0.0-alpha.46` and earlier do not have them. Consumer adoption must pin alpha.47 or later and validate its packed artifact before changing live startup paths. See the source repository's `docs/agents/cloud-setup.md` for Factory-only rollout policy and acceptance.
package/dist/cli.js CHANGED
@@ -1,6 +1,6 @@
1
1
  #!/usr/bin/env node
2
2
  import { PrPublishFollowUpError, run } from "./index.js";
3
- //#region src/cli.ts
3
+ // src/cli.ts
4
4
  try {
5
5
  await run(process.argv, import.meta.filename);
6
6
  } catch (error) {
@@ -8,5 +8,4 @@ try {
8
8
  else console.error("\nError:", error instanceof Error ? error.message : String(error));
9
9
  process.exit(1);
10
10
  }
11
- //#endregion
12
11
  export {};
@@ -0,0 +1,21 @@
1
+ /** Explicit, reviewed repository policy: child environment key to op:// reference. */
2
+ export type CloudCredentialReferences = Readonly<Record<string, string>>;
3
+ export type CloudEnvironment = Record<string, string | undefined>;
4
+ export type CloudSecretReader = (
5
+ reference: string,
6
+ env: CloudEnvironment
7
+ ) => string;
8
+ export declare class CloudSecretError extends Error {
9
+ readonly name = "CloudSecretError";
10
+ }
11
+ /** op-fast item get; no kernel keyring, stock-op fallback, or output diagnostics. */
12
+ export function readCloudSecret(
13
+ reference: string,
14
+ env: CloudEnvironment
15
+ ): string;
16
+ /** Resolves selected credentials in memory, strips vault and unrelated provider authority. */
17
+ export function cloudCredentialEnvironment(
18
+ env: CloudEnvironment,
19
+ credentials: CloudCredentialReferences,
20
+ read?: CloudSecretReader
21
+ ): CloudEnvironment;
@@ -0,0 +1,136 @@
1
+ // Shared cloud credential mechanics. Callers own references and runtime policy.
2
+ import { spawnSync } from "node:child_process";
3
+
4
+ export class CloudSecretError extends Error {
5
+ name = "CloudSecretError";
6
+ }
7
+
8
+ // Capture both streams: resolver errors can quote secret material. Never attach
9
+ // an underlying error/cause or include captured output in a diagnostic.
10
+ export function readCloudSecret(reference, env) {
11
+ if (!env.OP_SERVICE_ACCOUNT_TOKEN) {
12
+ throw new CloudSecretError(
13
+ "Cloud credentials require OP_SERVICE_ACCOUNT_TOKEN."
14
+ );
15
+ }
16
+ const match =
17
+ /^op:\/\/(?<vault>[^/\r\n]+)\/(?<item>[^/\r\n]+)\/(?<field>[^/\r\n]+)$/u.exec(
18
+ reference
19
+ );
20
+ if (!match?.groups) {
21
+ throw new CloudSecretError("Invalid cloud credential reference.");
22
+ }
23
+ const { vault, item, field } = match.groups;
24
+ const resolverEnv = {
25
+ ...Object.fromEntries(
26
+ Object.entries(env).filter(
27
+ ([key]) =>
28
+ !key.startsWith("OP_SESSION") &&
29
+ !["OP_ACCOUNT", "OP_CONNECT_HOST", "OP_CONNECT_TOKEN"].includes(key)
30
+ )
31
+ ),
32
+ OP_BIOMETRIC_UNLOCK_ENABLED: "false",
33
+ };
34
+ let result;
35
+ try {
36
+ result = spawnSync(
37
+ "op-fast",
38
+ ["item", "get", item, "--vault", vault, "--format=json"],
39
+ {
40
+ encoding: "utf-8",
41
+ env: resolverEnv,
42
+ maxBuffer: 256 * 1024,
43
+ stdio: ["ignore", "pipe", "pipe"],
44
+ timeout: 10_000,
45
+ }
46
+ );
47
+ } catch {
48
+ throw new CloudSecretError(
49
+ "Cloud credential resolution failed; check op-fast, vault access and network access."
50
+ );
51
+ }
52
+ let value;
53
+ try {
54
+ const { fields } = JSON.parse(result.stdout);
55
+ const matches = fields.filter(
56
+ (candidate) => candidate.id === field || candidate.label === field
57
+ );
58
+ if (matches.length === 1) {
59
+ [{ value }] = matches;
60
+ }
61
+ } catch {
62
+ // Malformed provider output must not be included in a diagnostic.
63
+ }
64
+ if (
65
+ result.error ||
66
+ result.status !== 0 ||
67
+ typeof value !== "string" ||
68
+ !value ||
69
+ value.startsWith("op://") ||
70
+ /[\r\n\0]/u.test(value)
71
+ ) {
72
+ throw new CloudSecretError(
73
+ "Cloud credential resolution failed; check op-fast, vault access and network access."
74
+ );
75
+ }
76
+ return value;
77
+ }
78
+
79
+ // Resolve only explicitly selected references and hand a consuming child no
80
+ // vault authority or unrelated Factory provider credentials. No defaults here:
81
+ // vault/item choices and the command/purpose decision belong to the repository.
82
+ export function cloudCredentialEnvironment(
83
+ env,
84
+ credentials,
85
+ read = readCloudSecret
86
+ ) {
87
+ if (!env.OP_SERVICE_ACCOUNT_TOKEN) {
88
+ throw new CloudSecretError(
89
+ "Cloud credentials require OP_SERVICE_ACCOUNT_TOKEN."
90
+ );
91
+ }
92
+ if (env.OP_CONNECT_HOST || env.OP_CONNECT_TOKEN) {
93
+ throw new CloudSecretError(
94
+ "Remove 1Password Connect settings before using the cloud service account."
95
+ );
96
+ }
97
+ const entries = Object.entries(credentials);
98
+ if (
99
+ !entries.length ||
100
+ entries.some(
101
+ ([key, ref]) =>
102
+ !key ||
103
+ key.startsWith("OP_") ||
104
+ /^FACTORY_.*_REF$/u.test(key) ||
105
+ !/^op:\/\/[^/\r\n]+\/[^/\r\n]+\/[^/\r\n]+$/u.test(ref)
106
+ )
107
+ ) {
108
+ throw new CloudSecretError(
109
+ "Cloud credentials require explicit environment keys and op:// references."
110
+ );
111
+ }
112
+ const unrelatedCredentials = new Set([
113
+ // Legacy repository tools also read the HTTP header names from env.
114
+ "CF-Access-Client-Id",
115
+ "CF-Access-Client-Secret",
116
+ "CF_ACCESS_CLIENT_ID",
117
+ "CF_ACCESS_CLIENT_SECRET",
118
+ "CLOUDFLARE_API_TOKEN",
119
+ "CLOUDFLARE_READ_ONLY_API_TOKEN",
120
+ "NPM_TOKEN",
121
+ "NODE_AUTH_TOKEN",
122
+ "npm_config_//registry.npmjs.org/:_authToken",
123
+ ]);
124
+ const child = Object.fromEntries(
125
+ Object.entries(env).filter(
126
+ ([key]) =>
127
+ !key.startsWith("OP_") &&
128
+ !/^FACTORY_.*_REF$/u.test(key) &&
129
+ !unrelatedCredentials.has(key)
130
+ )
131
+ );
132
+ for (const [key, ref] of entries) {
133
+ child[key] = read(ref, env);
134
+ }
135
+ return child;
136
+ }
@@ -0,0 +1,59 @@
1
+ #!/usr/bin/env bash
2
+ set -euo pipefail
3
+
4
+ # Credential-free Linux tool bootstrap shared by Cursor Build and Claude
5
+ # SessionStart. Never read OP_SERVICE_ACCOUNT_TOKEN or persist resolved values.
6
+ # Archive SHA-256 pins: official 1Password 2.41.1 archives and upstream op-fast
7
+ # v0.1.1 release assets (github.com/cometkim/op-fast/releases/tag/v0.1.1).
8
+ cloud_tools_arch() {
9
+ case "$1" in
10
+ x86_64 | amd64)
11
+ printf '%s\n' amd64 x86_64 \
12
+ e52476700cba9202ac7469bdfb2648ecdbf3438ac85822010f77230139e74966 \
13
+ a480a09ef344b7503a26f3b173891350a4d3bc465f6dcdd7b0f51735554c65f8 ;;
14
+ aarch64 | arm64)
15
+ printf '%s\n' arm64 aarch64 \
16
+ 89abd60c17d5c614066c20e6abed816449eb018c5e0679ed63d57071c7bee85e \
17
+ 59622b22f76fe1ff54fec06dc214b192b6878cf6dd596a972f11e9a7d1461ca5 ;;
18
+ *) return 1 ;;
19
+ esac
20
+ }
21
+
22
+ if [ "${FACTORY_CLOUD_TOOLS_DEFINE_ONLY:-}" = "1" ]; then
23
+ return 0 2>/dev/null || exit 0
24
+ fi
25
+
26
+ [ "$(uname -s)" = Linux ] || { echo 'cloud-tools: Linux is required.' >&2; exit 1; }
27
+ tool_bin="${1:?Usage: install-cloud-secrets.sh <absolute-bin-directory>}"
28
+ [[ "$tool_bin" = /* ]] || { echo 'cloud-tools: absolute bin directory required.' >&2; exit 1; }
29
+ mkdir -p "$tool_bin"
30
+
31
+ if [ "$("$tool_bin/op" --version 2>/dev/null || true)" = '2.41.1' ] &&
32
+ [ "$("$tool_bin/op-fast" --version 2>/dev/null || true)" = 'op-fast 0.1.1' ]; then
33
+ exit 0
34
+ fi
35
+
36
+ for required in curl unzip tar sha256sum; do
37
+ command -v "$required" >/dev/null || { echo "cloud-tools: missing $required." >&2; exit 1; }
38
+ done
39
+ pins="$(cloud_tools_arch "$(uname -m)")" || { echo 'cloud-tools: unsupported architecture.' >&2; exit 1; }
40
+ op_arch="$(printf '%s\n' "$pins" | sed -n '1p')"
41
+ fast_arch="$(printf '%s\n' "$pins" | sed -n '2p')"
42
+ op_sha="$(printf '%s\n' "$pins" | sed -n '3p')"
43
+ fast_sha="$(printf '%s\n' "$pins" | sed -n '4p')"
44
+ staging="$(mktemp -d "$tool_bin/.install.XXXXXX")"
45
+ trap 'rm -rf "$staging"' EXIT
46
+ curl --proto '=https' --tlsv1.2 -fsSL --max-time 120 \
47
+ "https://cache.agilebits.com/dist/1P/op2/pkg/v2.41.1/op_linux_${op_arch}_v2.41.1.zip" -o "$staging/op.zip"
48
+ printf '%s %s\n' "$op_sha" "$staging/op.zip" | sha256sum --check --status
49
+ unzip -q "$staging/op.zip" op -d "$staging"
50
+ fast_asset="op-fast-${fast_arch}-unknown-linux-gnu"
51
+ curl --proto '=https' --tlsv1.2 -fsSL --max-time 120 \
52
+ "https://github.com/cometkim/op-fast/releases/download/v0.1.1/$fast_asset.tar.xz" -o "$staging/op-fast.tar.xz"
53
+ printf '%s %s\n' "$fast_sha" "$staging/op-fast.tar.xz" | sha256sum --check --status
54
+ tar -xJf "$staging/op-fast.tar.xz" -C "$staging"
55
+ fast_binary="$staging/$fast_asset/op-fast"
56
+ [ -f "$fast_binary" ] || { echo 'cloud-tools: unexpected op-fast archive.' >&2; exit 1; }
57
+ install -m 755 "$staging/op" "$tool_bin/op"
58
+ install -m 755 "$fast_binary" "$tool_bin/op-fast"
59
+ echo 'cloud-tools: installed checksum-pinned 1Password backend and op-fast.'