projectops 4.104.6 → 4.104.8
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/bin/projectops.js +4 -4
- package/package.json +1 -1
- package/src/cli/args.js +43 -43
- package/src/cli/errors.js +8 -8
- package/src/cli/help.js +4 -4
- package/src/commands/doctor.js +39 -39
- package/src/commands/full.js +29 -29
- package/src/commands/interactive.js +86 -86
- package/src/commands/issues.js +5 -5
- package/src/commands/skills.js +13 -13
- package/src/commands/version.js +8 -8
- package/src/commands/workflows.js +23 -22
- package/src/context.js +24 -24
- package/src/core/agent-guide.js +5 -5
- package/src/core/assets.js +11 -11
- package/src/core/baseline.js +24 -24
- package/src/core/branch-sub.js +23 -23
- package/src/core/breaking-check.js +21 -21
- package/src/core/breaking.js +6 -6
- package/src/core/ci-minutes-sub.js +13 -13
- package/src/core/constants.js +17 -17
- package/src/core/copy/coderabbit.js +10 -10
- package/src/core/copy/gitignore.js +9 -9
- package/src/core/copy/readme.js +7 -7
- package/src/core/copy/simple.js +35 -35
- package/src/core/copy/util.js +9 -9
- package/src/core/copy/workflows.js +99 -99
- package/src/core/detect-fs.js +21 -21
- package/src/core/detect.js +12 -12
- package/src/core/development-branch.js +11 -11
- package/src/core/exclusions.js +12 -12
- package/src/core/fsutil.js +9 -9
- package/src/core/git-branch.js +11 -11
- package/src/core/ide/adapter.js +23 -23
- package/src/core/ide/adapters/claude.js +12 -12
- package/src/core/ide/adapters/codex.js +4 -4
- package/src/core/ide/adapters/copilot.js +12 -12
- package/src/core/ide/adapters/cursor.js +7 -7
- package/src/core/ide/adapters/gemini.js +5 -5
- package/src/core/ide/adapters/pi-common.js +12 -12
- package/src/core/ide/adapters/pi-harness.js +7 -7
- package/src/core/ide/adapters/pi.js +3 -3
- package/src/core/ide/home-skills.js +6 -6
- package/src/core/ide/legacy.js +8 -8
- package/src/core/ide/registry.js +6 -6
- package/src/core/ide/runner.js +15 -15
- package/src/core/ide/skills-copy.js +34 -34
- package/src/core/ide/stable-entry.js +11 -11
- package/src/core/ide/util.js +4 -4
- package/src/core/incoming.js +13 -13
- package/src/core/label-style.js +12 -12
- package/src/core/migration-guide.js +19 -19
- package/src/core/migrations/index.js +16 -16
- package/src/core/migrations/registry.js +39 -39
- package/src/core/migrations/rules/legacy-dirs.js +6 -6
- package/src/core/migrations/rules/obsolete-workflows.js +4 -4
- package/src/core/migrations/rules/root-files.js +3 -3
- package/src/core/migrations/rules/settings-extractors.js +8 -8
- package/src/core/options-ask.js +104 -104
- package/src/core/options-schema.js +23 -23
- package/src/core/orphan-workflows.js +14 -14
- package/src/core/paths-resolve.js +54 -54
- package/src/core/paths.js +2 -2
- package/src/core/placeholder-triggers.js +10 -10
- package/src/core/repo-language.js +10 -10
- package/src/core/resolve-options.js +30 -30
- package/src/core/run-trace.js +54 -54
- package/src/core/store-locales-hint.js +13 -13
- package/src/core/verify.js +27 -27
- package/src/core/version-yml.js +117 -116
- package/src/core/wizard-env.js +42 -42
- package/src/core/wizard-labels.js +31 -31
- package/src/core/workflow-groups.js +14 -14
- package/src/i18n/core.en.js +1 -1
- package/src/i18n/doctor.en.js +1 -1
- package/src/i18n/ide.en.js +1 -1
- package/src/i18n/migrate.en.js +1 -1
- package/src/i18n/options.en.js +1 -1
- package/src/index.js +60 -60
- package/src/ui/ansi.js +5 -5
- package/src/ui/env-plan.js +44 -44
- package/src/ui/prompts.js +21 -21
- package/src/ui/readline-engine.js +38 -38
- package/src/ui/skills-prompts.js +4 -4
package/README.md
CHANGED
|
@@ -163,7 +163,7 @@ Supported types: `spring`, `flutter`, `react` (incl. Next.js), `node`, `python`,
|
|
|
163
163
|
Everything is on the **[docs site](https://cassiiopeia.github.io/projectops/)**, in English and [Korean](https://cassiiopeia.github.io/projectops/ko/): [Getting started](https://cassiiopeia.github.io/projectops/getting-started) · [CLI](https://cassiiopeia.github.io/projectops/cli) · [Agent Skills](https://cassiiopeia.github.io/projectops/skills) · [Versioning](https://cassiiopeia.github.io/projectops/version-control) · [Changelog](https://cassiiopeia.github.io/projectops/changelog-automation) · [SSH + Docker deploy](https://cassiiopeia.github.io/projectops/ssh-docker-deployment-guide) · [Flutter CI/CD](https://cassiiopeia.github.io/projectops/flutter-cicd-overview) · [Troubleshooting](https://cassiiopeia.github.io/projectops/troubleshooting)
|
|
164
164
|
|
|
165
165
|
<!-- AUTO-VERSION-SECTION: DO NOT EDIT MANUALLY -->
|
|
166
|
-
## Latest version : v4.104.
|
|
166
|
+
## Latest version : v4.104.8 (2026-11-14)
|
|
167
167
|
|
|
168
168
|
[View full version history](CHANGELOG.md)
|
|
169
169
|
|
package/bin/projectops.js
CHANGED
|
@@ -1,12 +1,12 @@
|
|
|
1
1
|
#!/usr/bin/env node
|
|
2
|
-
// projectops CLI
|
|
2
|
+
// projectops CLI entry — passes argv to run() in src/index.js.
|
|
3
3
|
import { fileURLToPath } from "node:url";
|
|
4
4
|
import { dirname, join } from "node:path";
|
|
5
5
|
import { pathToFileURL } from "node:url";
|
|
6
6
|
|
|
7
7
|
const [nodeMajor, nodeMinor] = process.versions.node.split(".").map(Number);
|
|
8
8
|
if (nodeMajor < 20 || (nodeMajor === 20 && nodeMinor < 12)) {
|
|
9
|
-
console.error(`Node.js 20.12
|
|
9
|
+
console.error(`Node.js 20.12 or later is required (current: ${process.versions.node})`);
|
|
10
10
|
process.exit(1);
|
|
11
11
|
}
|
|
12
12
|
|
|
@@ -15,6 +15,6 @@ const indexPath = join(here, "..", "src", "index.js");
|
|
|
15
15
|
const { run } = await import(pathToFileURL(indexPath).href);
|
|
16
16
|
|
|
17
17
|
const code = await run(process.argv.slice(2), { cwd: process.cwd() });
|
|
18
|
-
// stdout
|
|
19
|
-
//
|
|
18
|
+
// When stdout is a pipe, writes are async, so exiting right away cuts large output (--mode options --json) near 8KB.
|
|
19
|
+
// The callback of an empty write fires after all earlier writes are flushed, so exit there.
|
|
20
20
|
process.stdout.write("", () => process.exit(code));
|
package/package.json
CHANGED
package/src/cli/args.js
CHANGED
|
@@ -1,4 +1,4 @@
|
|
|
1
|
-
// CLI
|
|
1
|
+
// CLI argument parsing.
|
|
2
2
|
import { existsSync, statSync, realpathSync } from "node:fs";
|
|
3
3
|
import { join, relative, isAbsolute } from "node:path";
|
|
4
4
|
import { VALID_TYPES } from "../context.js";
|
|
@@ -7,44 +7,44 @@ import { REPO_LANGUAGES } from "../core/repo-language.js";
|
|
|
7
7
|
|
|
8
8
|
import { DEPLOY_TARGETS, PUBLISH_TARGETS, INTENT_VALUES, LABEL_STYLES } from "../core/constants.js";
|
|
9
9
|
|
|
10
|
-
//
|
|
10
|
+
// core/constants.js owns the value lists. Re-exported here so existing import paths keep working.
|
|
11
11
|
export { DEPLOY_TARGETS, PUBLISH_TARGETS, INTENT_VALUES };
|
|
12
12
|
export const LABEL_STYLE_VALUES = LABEL_STYLES;
|
|
13
|
-
//
|
|
13
|
+
// repo-language.js holds the single list of supported languages (#787). A separate copy here would drift.
|
|
14
14
|
export const LANGUAGE_VALUES = REPO_LANGUAGES;
|
|
15
15
|
const SEMVER_RE = /^\d+\.\d+\.\d+$/;
|
|
16
|
-
//
|
|
16
|
+
// Unicode letters and digits allowed (#719) — spaces and shell metacharacters are not in the class, so still rejected.
|
|
17
17
|
const BRANCH_RE = /^[\p{L}\p{N}][\p{L}\p{N}._/-]*$/u;
|
|
18
|
-
//
|
|
18
|
+
// Allowed run modes (#665) — keeps a typo from ending silently as "0 copies, success".
|
|
19
19
|
export const MODE_VALUES = ["full", "version", "workflows", "issues", "skills", "doctor", "options", "interactive"];
|
|
20
20
|
|
|
21
|
-
// argv(process.argv.slice(2)) →
|
|
21
|
+
// argv (process.argv.slice(2)) → parse result. Throws on error (caller exits 1).
|
|
22
22
|
export function parseArgs(argv) {
|
|
23
23
|
const result = {
|
|
24
24
|
mode: "interactive",
|
|
25
|
-
version: "", //
|
|
25
|
+
version: "", // Initial version of the target project (--project-version)
|
|
26
26
|
types: [],
|
|
27
27
|
primaryType: "",
|
|
28
|
-
deployTarget: null, //
|
|
29
|
-
publishTargets: null, //
|
|
30
|
-
deployBranch: "", //
|
|
31
|
-
deployTriggerBranch: "", //
|
|
32
|
-
language: null, //
|
|
33
|
-
labelStyle: null, //
|
|
34
|
-
intent: null, //
|
|
28
|
+
deployTarget: null, // Deploy axis (#439): docker-ssh|vercel|none, null = unset
|
|
29
|
+
publishTargets: null, // Publish axis (#439): target array, null = unset
|
|
30
|
+
deployBranch: "", // Release PR head branch (#456): --deploy-branch, empty = not given
|
|
31
|
+
deployTriggerBranch: "", // Branch that triggers deploy workflows (#1114): --deploy-trigger-branch, empty = default branch
|
|
32
|
+
language: null, // Repo text language (#769): --language en|ko (differs from the screen language --lang)
|
|
33
|
+
labelStyle: null, // Status label style (#776): --label-style en|ko
|
|
34
|
+
intent: null, // Project nature (#485): --intent app|library|both|none|manual, null = unset (inferred)
|
|
35
35
|
includeSecretBackup: null,
|
|
36
|
-
aiPrSummary: null, // #566 —
|
|
37
|
-
codeReviewCoderabbit: null, // --coderabbit: CodeRabbit
|
|
38
|
-
projectsSync: null, // #716 —
|
|
39
|
-
ciMinutesSaver: null, // #1114 — CI
|
|
40
|
-
json: false, // --json:
|
|
41
|
-
removeLegacy: false, // #809 —
|
|
42
|
-
createDevelopmentBranch: false, // #715 —
|
|
43
|
-
pathsCsv: "", // "flutter=app,react=client"
|
|
36
|
+
aiPrSummary: null, // #566 — whether to include the AI change summary workflow
|
|
37
|
+
codeReviewCoderabbit: null, // --coderabbit: whether to install the CodeRabbit code review config (.coderabbit.yaml) (null = not given → saved value, else off)
|
|
38
|
+
projectsSync: null, // #716 — whether to include the Projects board sync workflow (null = not given)
|
|
39
|
+
ciMinutesSaver: null, // #1114 — CI minutes saver substitution (null = not given → saved value, else off)
|
|
40
|
+
json: false, // --json: machine-readable output (--mode options)
|
|
41
|
+
removeLegacy: false, // #809 — also move old-generation deploy workflows (confirm tier) aside as .bak
|
|
42
|
+
createDevelopmentBranch: false, // #715 — create and push the development branch non-interactively (writes to the remote, so only when explicit)
|
|
43
|
+
pathsCsv: "", // Raw "flutter=app,react=client" (normalized in the resolve step)
|
|
44
44
|
force: false,
|
|
45
45
|
lang: null, // --lang en|ko (null = decided by src/i18n resolveLang)
|
|
46
46
|
help: false,
|
|
47
|
-
showVersion: false, // -v/--version → projectops
|
|
47
|
+
showVersion: false, // -v/--version → print the projectops package version (npm convention)
|
|
48
48
|
};
|
|
49
49
|
const args = [...argv];
|
|
50
50
|
while (args.length > 0) {
|
|
@@ -60,12 +60,12 @@ export function parseArgs(argv) {
|
|
|
60
60
|
break;
|
|
61
61
|
}
|
|
62
62
|
case "-v": case "--version":
|
|
63
|
-
// npm
|
|
63
|
+
// npm convention: -v/--version prints the package version. (The initial version is set with --project-version)
|
|
64
64
|
result.showVersion = true; break;
|
|
65
65
|
case "--project-version":
|
|
66
66
|
{
|
|
67
|
-
// version.yml
|
|
68
|
-
// 'v1.0.0'
|
|
67
|
+
// version.yml and shell scripts read this value as is, so only x.y.z is accepted (#676)
|
|
68
|
+
// 'v1.0.0' is a common user notation, so it is accepted with the prefix stripped rather than rejected
|
|
69
69
|
const v = (args.shift() ?? "").trim().replace(/^[vV](?=\d)/, "");
|
|
70
70
|
if (!SEMVER_RE.test(v)) {
|
|
71
71
|
throw new CliError(t("args.projectVersion", { v }));
|
|
@@ -124,9 +124,9 @@ export function parseArgs(argv) {
|
|
|
124
124
|
break;
|
|
125
125
|
}
|
|
126
126
|
case "--deploy-branch": {
|
|
127
|
-
//
|
|
127
|
+
// Release PR head branch (#456). Separate from default_branch.
|
|
128
128
|
const v = (args.shift() ?? "").trim();
|
|
129
|
-
//
|
|
129
|
+
// Inserted as is into workflow yaml and shell, so only safe branch names are allowed (#676)
|
|
130
130
|
if (v && (!BRANCH_RE.test(v) || v.includes("..") || v.endsWith("/") || v.endsWith(".lock"))) {
|
|
131
131
|
throw new CliError(t("args.deployBranch", { v }));
|
|
132
132
|
}
|
|
@@ -134,7 +134,7 @@ export function parseArgs(argv) {
|
|
|
134
134
|
break;
|
|
135
135
|
}
|
|
136
136
|
case "--deploy-trigger-branch": {
|
|
137
|
-
//
|
|
137
|
+
// Branch whose push runs the deploy (#1114). Used only when split from the default branch. Goes into workflow yaml as is, so same check as --deploy-branch.
|
|
138
138
|
const v = (args.shift() ?? "").trim();
|
|
139
139
|
if (v && (!BRANCH_RE.test(v) || v.includes("..") || v.endsWith("/") || v.endsWith(".lock"))) {
|
|
140
140
|
throw new CliError(t("args.deployBranch", { v }));
|
|
@@ -143,7 +143,7 @@ export function parseArgs(argv) {
|
|
|
143
143
|
break;
|
|
144
144
|
}
|
|
145
145
|
case "--intent": {
|
|
146
|
-
//
|
|
146
|
+
// Project nature (#485). If not given, inferred from --deploy/--publish.
|
|
147
147
|
const v = (args.shift() ?? "").trim();
|
|
148
148
|
if (!INTENT_VALUES.includes(v)) {
|
|
149
149
|
throw new CliError(t("args.intent", { values: INTENT_VALUES.join(" | "), v }));
|
|
@@ -152,8 +152,8 @@ export function parseArgs(argv) {
|
|
|
152
152
|
break;
|
|
153
153
|
}
|
|
154
154
|
case "--language": {
|
|
155
|
-
//
|
|
156
|
-
//
|
|
155
|
+
// Repo text language (#769). If not given, saved version.yml value → (new en / existing ko).
|
|
156
|
+
// Differs from the screen language (--lang): this is the language of templates written into the user repo.
|
|
157
157
|
const v = (args.shift() ?? "").trim();
|
|
158
158
|
if (!LANGUAGE_VALUES.includes(v)) {
|
|
159
159
|
throw new CliError(`--language must be one of ${LANGUAGE_VALUES.join(" | ")}: '${v}'`);
|
|
@@ -162,7 +162,7 @@ export function parseArgs(argv) {
|
|
|
162
162
|
break;
|
|
163
163
|
}
|
|
164
164
|
case "--label-style": {
|
|
165
|
-
//
|
|
165
|
+
// Status label style (#776). If not given, saved version.yml value → (new en / existing ko).
|
|
166
166
|
const v = (args.shift() ?? "").trim();
|
|
167
167
|
if (!LABEL_STYLE_VALUES.includes(v)) {
|
|
168
168
|
throw new CliError(`--label-style must be one of ${LABEL_STYLE_VALUES.join(" | ")}: '${v}'`);
|
|
@@ -170,7 +170,7 @@ export function parseArgs(argv) {
|
|
|
170
170
|
result.labelStyle = v;
|
|
171
171
|
break;
|
|
172
172
|
}
|
|
173
|
-
// ── deprecated alias (1 minor
|
|
173
|
+
// ── deprecated alias (kept for 1 minor — #439) ──
|
|
174
174
|
case "--nexus":
|
|
175
175
|
process.stderr.write(t("args.nexusDeprecated") + "\n");
|
|
176
176
|
result.publishTargets = [...new Set([...(result.publishTargets ?? []), "nexus"])];
|
|
@@ -181,7 +181,7 @@ export function parseArgs(argv) {
|
|
|
181
181
|
break;
|
|
182
182
|
case "--secret-backup": result.includeSecretBackup = true; break;
|
|
183
183
|
case "--no-secret-backup": result.includeSecretBackup = false; break;
|
|
184
|
-
// #566 —
|
|
184
|
+
// #566 — must be switchable non-interactively too. Otherwise automation has no choice.
|
|
185
185
|
case "--coderabbit": result.codeReviewCoderabbit = true; break;
|
|
186
186
|
case "--no-coderabbit": result.codeReviewCoderabbit = false; break;
|
|
187
187
|
case "--ai-summary": result.aiPrSummary = true; break;
|
|
@@ -211,19 +211,19 @@ export function parseArgs(argv) {
|
|
|
211
211
|
|
|
212
212
|
export class CliError extends Error {}
|
|
213
213
|
|
|
214
|
-
//
|
|
214
|
+
// Path normalization: trim spaces, \→/, strip trailing / and leading ./, empty→"."
|
|
215
215
|
export function normalizePath(p) {
|
|
216
216
|
let s = String(p).trim();
|
|
217
217
|
s = s.replace(/\\/g, "/");
|
|
218
|
-
s = s.replace(/\/+$/, ""); //
|
|
219
|
-
s = s.replace(/^\.\//, ""); //
|
|
218
|
+
s = s.replace(/\/+$/, ""); // Trailing /
|
|
219
|
+
s = s.replace(/^\.\//, ""); // Leading ./
|
|
220
220
|
return s === "" ? "." : s;
|
|
221
221
|
}
|
|
222
222
|
|
|
223
|
-
// --paths
|
|
224
|
-
// ·
|
|
225
|
-
// ·
|
|
226
|
-
// ·
|
|
223
|
+
// --paths map validation (#674) — a path outside the repo is the most dangerous, since version_manager actually edits that file.
|
|
224
|
+
// · reject absolute paths and `..` segments (only paths relative to the repo root)
|
|
225
|
+
// · reject type keys not chosen with --type
|
|
226
|
+
// · reject folders that do not exist (realpath also blocks symlinks pointing outside)
|
|
227
227
|
export function validatePathsMap(map, { root, types }) {
|
|
228
228
|
for (const [type, p] of map) {
|
|
229
229
|
if (!types.includes(type)) {
|
|
@@ -243,7 +243,7 @@ export function validatePathsMap(map, { root, types }) {
|
|
|
243
243
|
}
|
|
244
244
|
}
|
|
245
245
|
|
|
246
|
-
// "flutter=app,react=client" → Map<type, normalizedPath>.
|
|
246
|
+
// "flutter=app,react=client" → Map<type, normalizedPath>. Validates types (invalid → throw).
|
|
247
247
|
export function parsePathsCsv(csv) {
|
|
248
248
|
const map = new Map();
|
|
249
249
|
if (!csv) return map;
|
package/src/cli/errors.js
CHANGED
|
@@ -1,20 +1,20 @@
|
|
|
1
1
|
import { t } from "../i18n/index.js";
|
|
2
2
|
|
|
3
|
-
//
|
|
4
|
-
//
|
|
3
|
+
// Turns unexpected exceptions into a readable one-line error + action hint (#672).
|
|
4
|
+
// A stack trace is not something users can fix, so it is shown only when the DEBUG env var is set.
|
|
5
5
|
|
|
6
|
-
// err → { message, hint }.
|
|
6
|
+
// err → { message, hint }. Classified by the err.code / message format Node throws.
|
|
7
7
|
export function describeError(err) {
|
|
8
8
|
const msg = String(err?.message || err);
|
|
9
9
|
const code = err?.code;
|
|
10
10
|
|
|
11
|
-
//
|
|
11
|
+
// git is not on PATH — spawn-family calls throw ENOENT
|
|
12
12
|
if (code === "ENOENT" && /\bgit\b/.test(`${err?.path ?? ""} ${err?.syscall ?? ""} ${msg}`)) {
|
|
13
13
|
return { message: t("errors.git.message"), hint: t("errors.git.hint") };
|
|
14
14
|
}
|
|
15
|
-
//
|
|
15
|
+
// Template download failed — execFileSync throws "Command failed: git clone ..."
|
|
16
16
|
if (/Command failed: git clone/.test(msg)) {
|
|
17
|
-
// Windows
|
|
17
|
+
// Windows path length limit — blaming the network would send people to the wrong place
|
|
18
18
|
if (/Filename too long|cannot stat/i.test(msg)) {
|
|
19
19
|
return { message: t("errors.clone.pathTooLong.message"), hint: t("errors.clone.pathTooLong.hint") };
|
|
20
20
|
}
|
|
@@ -23,7 +23,7 @@ export function describeError(err) {
|
|
|
23
23
|
hint: t("errors.clone.hint"),
|
|
24
24
|
};
|
|
25
25
|
}
|
|
26
|
-
//
|
|
26
|
+
// Permission / read-only filesystem
|
|
27
27
|
if (code === "EACCES" || code === "EPERM" || code === "EROFS") {
|
|
28
28
|
const where = err?.path ? ` (${err.path})` : "";
|
|
29
29
|
return {
|
|
@@ -37,7 +37,7 @@ export function describeError(err) {
|
|
|
37
37
|
return { message: t("errors.unexpected.message", { msg }), hint: t("errors.unexpected.hint") };
|
|
38
38
|
}
|
|
39
39
|
|
|
40
|
-
//
|
|
40
|
+
// Print the error to stderr. The caller just returns a non-zero exit code.
|
|
41
41
|
export function reportFatal(err, { env = process.env, write = (s) => process.stderr.write(s) } = {}) {
|
|
42
42
|
const { message, hint } = describeError(err);
|
|
43
43
|
write(`❌ ${message}\n`);
|
package/src/cli/help.js
CHANGED
|
@@ -1,9 +1,9 @@
|
|
|
1
1
|
// --help text in each supported language. English is the default (see src/i18n).
|
|
2
2
|
//
|
|
3
|
-
//
|
|
4
|
-
//
|
|
5
|
-
//
|
|
6
|
-
//
|
|
3
|
+
// AI agents read this screen more than people do. So it states not only "what it does" but also
|
|
4
|
+
// when questions appear · what happens if omitted · what changes in the repo.
|
|
5
|
+
// Value lists and per-flag details live in src/core/options-schema.js (source of truth); `--mode options --json` prints them as is.
|
|
6
|
+
// Every flag in args.js must appear in both the English and Korean help texts — add new flags to both.
|
|
7
7
|
import { getLang } from "../i18n/index.js";
|
|
8
8
|
|
|
9
9
|
const HELP_EN = `projectops — installs and updates GitHub automation (versioning, release notes, CI/CD, issue templates, agent skills)
|
package/src/commands/doctor.js
CHANGED
|
@@ -1,16 +1,16 @@
|
|
|
1
|
-
// doctor
|
|
1
|
+
// doctor command (#558) — diagnoses integration state and repo settings. Read-only, touches no files.
|
|
2
2
|
//
|
|
3
|
-
//
|
|
4
|
-
// ①
|
|
5
|
-
//
|
|
6
|
-
// ②
|
|
7
|
-
//
|
|
8
|
-
// ③
|
|
9
|
-
// ④
|
|
10
|
-
//
|
|
3
|
+
// Output design:
|
|
4
|
+
// ① Item names carry their purpose ("what the setting is for"). Seeing only `actions: write`
|
|
5
|
+
// does not tell what it handles in your own release flow.
|
|
6
|
+
// ② The tool does not rule "you must fix this". It states only the facts found; whether that is a
|
|
7
|
+
// problem for you is the user's call — there is no reason to register secrets for workflows you do not use.
|
|
8
|
+
// ③ Only problem items expand as `symptom → impact → action`; healthy items collapse to one line.
|
|
9
|
+
// ④ Strings actually shown on GitHub settings screens ("Read and write permissions", etc.)
|
|
10
|
+
// are not translated. Translated, the explanation reads fine but the item cannot be found on screen.
|
|
11
11
|
//
|
|
12
|
-
//
|
|
13
|
-
//
|
|
12
|
+
// Remote checks run only with GITHUB_TOKEN. Missing it is not a failure — local checks alone
|
|
13
|
+
// catch most common accidents (substitution failures, missing secrets).
|
|
14
14
|
import { join } from "node:path";
|
|
15
15
|
import { execFileSync } from "node:child_process";
|
|
16
16
|
import { existsSync, readFileSync, readdirSync } from "node:fs";
|
|
@@ -23,18 +23,18 @@ import { detectMigrations } from "../core/migrations/index.js";
|
|
|
23
23
|
import { scanPlaceholderTriggers } from "../core/placeholder-triggers.js";
|
|
24
24
|
import { t } from "../i18n/index.js";
|
|
25
25
|
|
|
26
|
-
//
|
|
26
|
+
// Kept as a function so it is evaluated at language switch time (withLang, etc.)
|
|
27
27
|
const permPurpose = () => t("doctor.perm.purpose");
|
|
28
28
|
|
|
29
29
|
const GITHUB_CHECK_TIMEOUT_MILLISECONDS = 5000;
|
|
30
30
|
|
|
31
|
-
// GitHub REST
|
|
31
|
+
// GitHub REST call. Failure returns {ok:false} instead of throwing, so the diagnosis does not stop.
|
|
32
32
|
async function gh(path, token) {
|
|
33
33
|
try {
|
|
34
34
|
const res = await fetch(`https://api.github.com${path}`, {
|
|
35
35
|
headers: { Authorization: `token ${token}`, Accept: "application/vnd.github+json",
|
|
36
36
|
"User-Agent": "projectops-doctor" },
|
|
37
|
-
signal: AbortSignal.timeout(GITHUB_CHECK_TIMEOUT_MILLISECONDS), //
|
|
37
|
+
signal: AbortSignal.timeout(GITHUB_CHECK_TIMEOUT_MILLISECONDS), // Keeps the diagnosis from hanging on a blocked network
|
|
38
38
|
});
|
|
39
39
|
if (!res.ok) return { ok: false, status: res.status };
|
|
40
40
|
return { ok: true, data: await res.json() };
|
|
@@ -43,7 +43,7 @@ async function gh(path, token) {
|
|
|
43
43
|
}
|
|
44
44
|
}
|
|
45
45
|
|
|
46
|
-
//
|
|
46
|
+
// Extract owner/repo from the git remote. null if missing.
|
|
47
47
|
function detectSlug(cwd) {
|
|
48
48
|
try {
|
|
49
49
|
const url = execFileSync("git", ["remote", "get-url", "origin"],
|
|
@@ -55,7 +55,7 @@ function detectSlug(cwd) {
|
|
|
55
55
|
}
|
|
56
56
|
}
|
|
57
57
|
|
|
58
|
-
// ──
|
|
58
|
+
// ── Local checks ─────────────────────────────────────────────────────────
|
|
59
59
|
export function localChecks(cwd = ".") {
|
|
60
60
|
const rows = [];
|
|
61
61
|
const add = (r) => rows.push(r);
|
|
@@ -68,11 +68,11 @@ export function localChecks(cwd = ".") {
|
|
|
68
68
|
value: t("doctor.integ.noVersionYml"),
|
|
69
69
|
detail: [t("doctor.integ.notIntegrated"),
|
|
70
70
|
t("doctor.integ.howTo")] });
|
|
71
|
-
return rows; //
|
|
71
|
+
return rows; // Before integration the remaining checks are meaningless
|
|
72
72
|
}
|
|
73
73
|
|
|
74
74
|
add({ name: t("doctor.integ.name"), purpose: t("doctor.integ.purpose"), status: "OK",
|
|
75
|
-
//
|
|
75
|
+
// Without a recorded template version, show readable text instead of "vunknown" — old installs lack this value in version.yml
|
|
76
76
|
value: existing.templateVersion
|
|
77
77
|
? t("doctor.integ.versions", { tpl: existing.templateVersion, proj: existing.version })
|
|
78
78
|
: t("doctor.integ.versionsNoTemplate", { proj: existing.version }) });
|
|
@@ -86,7 +86,7 @@ export function localChecks(cwd = ".") {
|
|
|
86
86
|
detail: files.length ? null : [t("doctor.wf.none"),
|
|
87
87
|
t("doctor.wf.noneHint")] });
|
|
88
88
|
|
|
89
|
-
//
|
|
89
|
+
// Substitution and secret checks use the same module as post-install verification (#549) — two copies would split the criteria.
|
|
90
90
|
const v = verifyInstall(cwd);
|
|
91
91
|
add({
|
|
92
92
|
name: t("doctor.unres.name"), purpose: t("doctor.unres.purpose"),
|
|
@@ -100,7 +100,7 @@ export function localChecks(cwd = ".") {
|
|
|
100
100
|
],
|
|
101
101
|
});
|
|
102
102
|
|
|
103
|
-
//
|
|
103
|
+
// Automatic trigger + sample values (#662) — your-project-style values slip past the unreplaced token check and keep producing failed runs
|
|
104
104
|
const autoPlaceholders = scanPlaceholderTriggers(wfDir);
|
|
105
105
|
add({
|
|
106
106
|
name: t("doctor.ph.name"), purpose: t("doctor.ph.purpose"),
|
|
@@ -126,9 +126,9 @@ export function localChecks(cwd = ".") {
|
|
|
126
126
|
] : null,
|
|
127
127
|
});
|
|
128
128
|
|
|
129
|
-
// AI
|
|
130
|
-
//
|
|
131
|
-
//
|
|
129
|
+
// AI summary keys (#569) — there was no way to check "I registered it, does it work?".
|
|
130
|
+
// Repo secrets cannot be read locally, so this tells which names to use
|
|
131
|
+
// and that not registering is fine. Whether they are actually registered is checked remotely.
|
|
132
132
|
const AI_KEY_NAMES = ["GEMINI_API_KEY", "OPENAI_API_KEY", "ANTHROPIC_API_KEY", "GROQ_API_KEY", "MISTRAL_API_KEY"];
|
|
133
133
|
const hasSummaryWf = files.some((f) => /AI-PR-SUMMARY|RELEASE-CHANGELOG/.test(f));
|
|
134
134
|
if (hasSummaryWf) {
|
|
@@ -147,14 +147,14 @@ export function localChecks(cwd = ".") {
|
|
|
147
147
|
});
|
|
148
148
|
}
|
|
149
149
|
|
|
150
|
-
//
|
|
151
|
-
//
|
|
152
|
-
// permissions
|
|
153
|
-
//
|
|
150
|
+
// Check permissions declarations in workflow files (#558).
|
|
151
|
+
// Repo settings (Settings > Actions) are "the maximum that can be requested", while a workflow's
|
|
152
|
+
// permissions block is "what is actually requested". They are different layers, so even with healthy repo settings
|
|
153
|
+
// a missing declaration gets a 403 from the API — exactly the #555 accident.
|
|
154
154
|
const needsActionsWrite = [];
|
|
155
155
|
for (const f of files) {
|
|
156
156
|
const body = readFileSync(join(wfDir, f), "utf8");
|
|
157
|
-
//
|
|
157
|
+
// Only files that wake other workflows — a mention in a comment line (describing the woken side) is not a call
|
|
158
158
|
const code = body.split("\n").filter((line) => !/^\s*#/.test(line)).join("\n");
|
|
159
159
|
if (!code.includes("dispatch_downstream.py")) continue;
|
|
160
160
|
const perm = body.match(/^permissions:\r?\n((?:\s+.*\r?\n)+)/m);
|
|
@@ -175,8 +175,8 @@ export function localChecks(cwd = ".") {
|
|
|
175
175
|
});
|
|
176
176
|
}
|
|
177
177
|
|
|
178
|
-
//
|
|
179
|
-
//
|
|
178
|
+
// Retired old-generation workflows (#809) — updates only detect and leave them, so they run alongside the new ones.
|
|
179
|
+
// Logging alone would make doctor report "no problems", so they are caught here.
|
|
180
180
|
const legacy = detectMigrations(cwd).confirm;
|
|
181
181
|
add({
|
|
182
182
|
name: t("doctor.legacy.name"), purpose: t("doctor.legacy.purpose"),
|
|
@@ -204,9 +204,9 @@ export function localChecks(cwd = ".") {
|
|
|
204
204
|
return rows;
|
|
205
205
|
}
|
|
206
206
|
|
|
207
|
-
// ──
|
|
208
|
-
//
|
|
209
|
-
//
|
|
207
|
+
// ── Remote checks ─────────────────────────────────────────────────────────
|
|
208
|
+
// Workflows that never declare a permissions block — only then do the repo default permissions (Settings) apply as is.
|
|
209
|
+
// With a declaration, it runs with the declared scope even if the repo default is read (measured on release automerge with an org read default, #723).
|
|
210
210
|
export function workflowsWithoutPermissions(cwd = ".") {
|
|
211
211
|
const wfDir = join(cwd, PATHS.workflowsDir);
|
|
212
212
|
if (!existsSync(wfDir)) return [];
|
|
@@ -228,7 +228,7 @@ export async function remoteChecks(slug, token, requiredSecrets = [], undeclared
|
|
|
228
228
|
add({ name: "Workflow permissions", purpose: permPurpose(), status: "OK",
|
|
229
229
|
value: "Read and write permissions" });
|
|
230
230
|
} else if (undeclared.length === 0) {
|
|
231
|
-
//
|
|
231
|
+
// Every workflow declares permissions itself → the repo default (read) does not affect actual behavior
|
|
232
232
|
add({ name: "Workflow permissions", purpose: permPurpose(), status: "INFO",
|
|
233
233
|
value: t("doctor.rm.roOk"),
|
|
234
234
|
detail: [t("doctor.rm.roOkDetail")] });
|
|
@@ -269,7 +269,7 @@ export async function remoteChecks(slug, token, requiredSecrets = [], undeclared
|
|
|
269
269
|
} else {
|
|
270
270
|
const have = new Set((sec.data?.secrets || []).map((s) => s.name));
|
|
271
271
|
|
|
272
|
-
// AI
|
|
272
|
+
// Whether AI summary keys are actually registered (#569) — if so, also shows which service.
|
|
273
273
|
const AI_KEYS = { GEMINI_API_KEY: "Gemini", OPENAI_API_KEY: "OpenAI", ANTHROPIC_API_KEY: "Anthropic",
|
|
274
274
|
GROQ_API_KEY: "Groq", MISTRAL_API_KEY: "Mistral", MODEL_API_KEY: t("doctor.air.legacy") };
|
|
275
275
|
const foundAi = Object.entries(AI_KEYS).filter(([n]) => have.has(n));
|
|
@@ -282,7 +282,7 @@ export async function remoteChecks(slug, token, requiredSecrets = [], undeclared
|
|
|
282
282
|
t("doctor.air.l2"),
|
|
283
283
|
],
|
|
284
284
|
});
|
|
285
|
-
// AI
|
|
285
|
+
// AI keys are optional items covered separately above — mixing them into the unregistered 'needed for deploy' list makes them read as required (#723)
|
|
286
286
|
const missing = requiredSecrets.filter((n) => !have.has(n) && !(n in AI_KEYS));
|
|
287
287
|
add({
|
|
288
288
|
name: t("doctor.sr.name"), purpose: t("doctor.sr.purpose"),
|
|
@@ -300,14 +300,14 @@ export async function remoteChecks(slug, token, requiredSecrets = [], undeclared
|
|
|
300
300
|
return rows;
|
|
301
301
|
}
|
|
302
302
|
|
|
303
|
-
// ──
|
|
303
|
+
// ── Render ──────────────────────────────────────────────────────────────
|
|
304
304
|
const ICON = { OK: "✅", WARN: "⚠️", FAIL: "❌", INFO: "ℹ️" };
|
|
305
305
|
|
|
306
306
|
export function renderRows(rows, write = (s) => process.stderr.write(s + "\n")) {
|
|
307
307
|
const head = (r) => `${r.name}${r.purpose ? ` - ${r.purpose}` : ""}`;
|
|
308
308
|
for (const r of rows) {
|
|
309
309
|
write(`${ICON[r.status] || "·"} ${head(r)}: ${r.value}`);
|
|
310
|
-
//
|
|
310
|
+
// Healthy items collapse to one line. Expand only when the user needs to do something.
|
|
311
311
|
if (r.detail && r.status !== "OK") {
|
|
312
312
|
for (const line of r.detail) write(` ${line}`);
|
|
313
313
|
write("");
|
|
@@ -321,7 +321,7 @@ export function renderRows(rows, write = (s) => process.stderr.write(s + "\n"))
|
|
|
321
321
|
return warn;
|
|
322
322
|
}
|
|
323
323
|
|
|
324
|
-
//
|
|
324
|
+
// Entry point. Returns the number of items to look at (not used as the exit code — a diagnosis is not a failure)
|
|
325
325
|
export async function runDoctor({ cwd = ".", token = process.env.GITHUB_TOKEN || "" } = {}) {
|
|
326
326
|
const write = (s) => process.stderr.write(s + "\n");
|
|
327
327
|
write("");
|