@feedramp/cli 0.5.0 → 0.5.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.
- package/README.md +4 -0
- package/dist/feedramp.js +217 -179
- package/package.json +2 -2
package/README.md
CHANGED
|
@@ -142,6 +142,10 @@ On Linux and macOS the service reads the key from the 0600 credentials file
|
|
|
142
142
|
keychain prompt or open a locked keyring. Windows keeps it in the Credential
|
|
143
143
|
Manager.
|
|
144
144
|
|
|
145
|
+
Without a global install (`npm install -g @feedramp/cli`), put
|
|
146
|
+
`npx -y @feedramp/cli@latest` where these say `feedramp`; the CLI's own
|
|
147
|
+
messages already do when it was started that way.
|
|
148
|
+
|
|
145
149
|
```sh
|
|
146
150
|
feedramp worker doctor # what's missing, in plain words, with the fix
|
|
147
151
|
feedramp worker status
|
package/dist/feedramp.js
CHANGED
|
@@ -36978,9 +36978,9 @@ function writeError(ctx, command, message, opts = {}) {
|
|
|
36978
36978
|
}
|
|
36979
36979
|
|
|
36980
36980
|
// src/version.ts
|
|
36981
|
-
var VERSION = "0.5.
|
|
36982
|
-
var COMMIT = "
|
|
36983
|
-
var BUILD_DATE = "2026-11-
|
|
36981
|
+
var VERSION = "0.5.2";
|
|
36982
|
+
var COMMIT = "c32d3ca";
|
|
36983
|
+
var BUILD_DATE = "2026-11-28";
|
|
36984
36984
|
|
|
36985
36985
|
// src/commands/foundational.ts
|
|
36986
36986
|
var import_toml2 = __toESM(require_toml(), 1);
|
|
@@ -37696,6 +37696,9 @@ var SETTABLE_KEYS = /* @__PURE__ */ new Set([
|
|
|
37696
37696
|
"api_key",
|
|
37697
37697
|
"trusted_api_urls"
|
|
37698
37698
|
]);
|
|
37699
|
+
function configValueForDisplay(key, value) {
|
|
37700
|
+
return key === "api_key" && value !== void 0 ? "<redacted>" : value;
|
|
37701
|
+
}
|
|
37699
37702
|
function getGlobalFlagsForConfig(cmd) {
|
|
37700
37703
|
const f = getGlobalFlags(cmd);
|
|
37701
37704
|
return {
|
|
@@ -37711,7 +37714,8 @@ function registerFoundational(program3) {
|
|
|
37711
37714
|
const flags = getGlobalFlagsForConfig(cmd);
|
|
37712
37715
|
const rc = resolveConfig(flags);
|
|
37713
37716
|
for (const t of rc.trace) {
|
|
37714
|
-
const
|
|
37717
|
+
const value = configValueForDisplay(t.key, t.value);
|
|
37718
|
+
const v = value === void 0 ? "<unset>" : JSON.stringify(value);
|
|
37715
37719
|
process.stdout.write(`${t.key} = ${v} [${t.layer}: ${t.source}]
|
|
37716
37720
|
`);
|
|
37717
37721
|
}
|
|
@@ -37723,7 +37727,7 @@ function registerFoundational(program3) {
|
|
|
37723
37727
|
const flags = getGlobalFlagsForConfig(cmd);
|
|
37724
37728
|
const rc = resolveConfig(flags);
|
|
37725
37729
|
const trace = explainKey(rc, key);
|
|
37726
|
-
const value = trace?.value;
|
|
37730
|
+
const value = configValueForDisplay(key, trace?.value);
|
|
37727
37731
|
if (opts.explain && trace) {
|
|
37728
37732
|
process.stdout.write(`${key}=${JSON.stringify(value)} [${trace.layer}: ${trace.source}]
|
|
37729
37733
|
`);
|
|
@@ -37764,7 +37768,7 @@ function registerFoundational(program3) {
|
|
|
37764
37768
|
const tmp = `${path2}.${process.pid}.${Date.now()}.tmp`;
|
|
37765
37769
|
writeFileSync3(tmp, import_toml2.default.stringify(cur));
|
|
37766
37770
|
renameSync3(tmp, path2);
|
|
37767
|
-
process.stdout.write(`set ${key}=${JSON.stringify(parsed)} in ${path2}
|
|
37771
|
+
process.stdout.write(`set ${key}=${JSON.stringify(configValueForDisplay(key, parsed))} in ${path2}
|
|
37768
37772
|
`);
|
|
37769
37773
|
});
|
|
37770
37774
|
const auth = program3.command("auth").description("Manage API key credentials");
|
|
@@ -38861,11 +38865,32 @@ function registerComments(program3) {
|
|
|
38861
38865
|
import { spawn as spawn4 } from "node:child_process";
|
|
38862
38866
|
import { hostname as hostname3, userInfo as userInfo2 } from "node:os";
|
|
38863
38867
|
|
|
38868
|
+
// src/invocation.ts
|
|
38869
|
+
import { fileURLToPath } from "node:url";
|
|
38870
|
+
var NPX_COMMAND = "npx -y @feedramp/cli@latest";
|
|
38871
|
+
function cliCommand(file, env = process.env) {
|
|
38872
|
+
const f = file.replace(/\\/g, "/");
|
|
38873
|
+
if (env.npm_command === "exec" || f.includes("/_npx/") || f.includes("/.feedramp/cli/")) return NPX_COMMAND;
|
|
38874
|
+
return "feedramp";
|
|
38875
|
+
}
|
|
38876
|
+
var cached;
|
|
38877
|
+
function cli() {
|
|
38878
|
+
if (cached === void 0) {
|
|
38879
|
+
let file = process.argv[1] ?? "";
|
|
38880
|
+
try {
|
|
38881
|
+
file = fileURLToPath(import.meta.url);
|
|
38882
|
+
} catch {
|
|
38883
|
+
}
|
|
38884
|
+
cached = cliCommand(file);
|
|
38885
|
+
}
|
|
38886
|
+
return cached;
|
|
38887
|
+
}
|
|
38888
|
+
|
|
38864
38889
|
// src/commands/workerSetup.ts
|
|
38865
38890
|
import { existsSync as existsSync11, rmSync as rmSync3 } from "node:fs";
|
|
38866
38891
|
import { homedir as homedir4, userInfo } from "node:os";
|
|
38867
38892
|
import { basename } from "node:path";
|
|
38868
|
-
import { fileURLToPath } from "node:url";
|
|
38893
|
+
import { fileURLToPath as fileURLToPath2 } from "node:url";
|
|
38869
38894
|
|
|
38870
38895
|
// src/worker/loop.ts
|
|
38871
38896
|
import { hostname as hostname2, platform as platform2 } from "node:os";
|
|
@@ -38873,128 +38898,16 @@ import { join as join6 } from "node:path";
|
|
|
38873
38898
|
|
|
38874
38899
|
// src/worker/git.ts
|
|
38875
38900
|
import { spawn } from "node:child_process";
|
|
38876
|
-
import { existsSync as
|
|
38877
|
-
import { dirname as
|
|
38878
|
-
var GitError = class extends Error {
|
|
38879
|
-
constructor(message, result) {
|
|
38880
|
-
super(message);
|
|
38881
|
-
this.result = result;
|
|
38882
|
-
}
|
|
38883
|
-
result;
|
|
38884
|
-
};
|
|
38885
|
-
function authEnv(auth) {
|
|
38886
|
-
const env = { GIT_TERMINAL_PROMPT: "0", GCM_INTERACTIVE: "never" };
|
|
38887
|
-
if (!auth || !/^https:\/\//i.test(auth.url)) return env;
|
|
38888
|
-
const origin = new URL(auth.url).origin + "/";
|
|
38889
|
-
const basic = Buffer.from(`x-access-token:${auth.token}`).toString("base64");
|
|
38890
|
-
Object.assign(env, {
|
|
38891
|
-
GIT_CONFIG_COUNT: "2",
|
|
38892
|
-
GIT_CONFIG_KEY_0: `http.${origin}.extraheader`,
|
|
38893
|
-
GIT_CONFIG_VALUE_0: `AUTHORIZATION: basic ${basic}`,
|
|
38894
|
-
// Make sure no credential helper stores or prompts for anything.
|
|
38895
|
-
GIT_CONFIG_KEY_1: "credential.helper",
|
|
38896
|
-
GIT_CONFIG_VALUE_1: ""
|
|
38897
|
-
});
|
|
38898
|
-
return env;
|
|
38899
|
-
}
|
|
38900
|
-
function git(cwd, args, opts = {}) {
|
|
38901
|
-
return new Promise((resolve4, reject) => {
|
|
38902
|
-
const child = spawn("git", args, {
|
|
38903
|
-
cwd,
|
|
38904
|
-
env: { ...process.env, ...authEnv(opts.auth) },
|
|
38905
|
-
windowsHide: true,
|
|
38906
|
-
stdio: ["ignore", "pipe", "pipe"]
|
|
38907
|
-
});
|
|
38908
|
-
let stdout = "", stderr = "";
|
|
38909
|
-
child.stdout.on("data", (d) => {
|
|
38910
|
-
stdout += d;
|
|
38911
|
-
});
|
|
38912
|
-
child.stderr.on("data", (d) => {
|
|
38913
|
-
stderr += d;
|
|
38914
|
-
});
|
|
38915
|
-
child.on("error", reject);
|
|
38916
|
-
child.on("close", (code) => {
|
|
38917
|
-
const result = { code: code ?? 1, stdout: stdout.trim(), stderr: redact2(stderr.trim(), opts.auth) };
|
|
38918
|
-
if (result.code !== 0 && !opts.allowFail) reject(new GitError(`git ${args[0]} failed: ${result.stderr || result.stdout}`, result));
|
|
38919
|
-
else resolve4(result);
|
|
38920
|
-
});
|
|
38921
|
-
});
|
|
38922
|
-
}
|
|
38923
|
-
function redact2(text, auth) {
|
|
38924
|
-
return auth?.token ? text.split(auth.token).join("***") : text;
|
|
38925
|
-
}
|
|
38926
|
-
async function prepareWorkspace(o) {
|
|
38927
|
-
if (!existsSync5(join4(o.dir, ".git"))) {
|
|
38928
|
-
mkdirSync4(dirname4(o.dir), { recursive: true });
|
|
38929
|
-
await git(dirname4(o.dir), ["clone", "--no-tags", o.cloneUrl, o.dir], { auth: o.auth });
|
|
38930
|
-
} else {
|
|
38931
|
-
await git(o.dir, ["remote", "set-url", "origin", o.cloneUrl]);
|
|
38932
|
-
await git(o.dir, ["fetch", "--prune", "origin"], { auth: o.auth });
|
|
38933
|
-
}
|
|
38934
|
-
const local = [
|
|
38935
|
-
["user.name", o.author.name],
|
|
38936
|
-
["user.email", o.author.email],
|
|
38937
|
-
["core.autocrlf", "false"],
|
|
38938
|
-
["core.longpaths", "true"],
|
|
38939
|
-
["push.autoSetupRemote", "false"]
|
|
38940
|
-
];
|
|
38941
|
-
for (const [k, v] of local) await git(o.dir, ["config", "--local", k, v]);
|
|
38942
|
-
writeExclude(o.dir, o.exclude);
|
|
38943
|
-
const base = await defaultBranch(o.dir, o.auth);
|
|
38944
|
-
const remoteHas = (await git(o.dir, ["ls-remote", "--heads", "origin", o.branch], { auth: o.auth })).stdout.length > 0;
|
|
38945
|
-
const start = remoteHas ? `origin/${o.branch}` : `origin/${base}`;
|
|
38946
|
-
if (remoteHas) await git(o.dir, ["fetch", "origin", `+refs/heads/${o.branch}:refs/remotes/origin/${o.branch}`], { auth: o.auth });
|
|
38947
|
-
await git(o.dir, ["checkout", "--force", "-B", o.branch, start]);
|
|
38948
|
-
await git(o.dir, ["reset", "--hard", start]);
|
|
38949
|
-
await git(o.dir, ["clean", "-fd"]);
|
|
38950
|
-
return { base, resumed: remoteHas };
|
|
38951
|
-
}
|
|
38952
|
-
async function defaultBranch(dir, auth) {
|
|
38953
|
-
const head = await git(dir, ["symbolic-ref", "--short", "refs/remotes/origin/HEAD"], { allowFail: true });
|
|
38954
|
-
if (head.code === 0 && head.stdout.startsWith("origin/")) return head.stdout.slice("origin/".length);
|
|
38955
|
-
const remote = await git(dir, ["ls-remote", "--symref", "origin", "HEAD"], { auth, allowFail: true });
|
|
38956
|
-
const m = remote.stdout.match(/^ref: refs\/heads\/(\S+)\s+HEAD/m);
|
|
38957
|
-
return m?.[1] ?? "main";
|
|
38958
|
-
}
|
|
38959
|
-
function writeExclude(dir, paths) {
|
|
38960
|
-
const file = join4(dir, ".git", "info", "exclude");
|
|
38961
|
-
mkdirSync4(dirname4(file), { recursive: true });
|
|
38962
|
-
const current = existsSync5(file) ? readFileSync6(file, "utf8") : "";
|
|
38963
|
-
const missing = paths.filter((p) => !current.split(/\r?\n/).includes(p));
|
|
38964
|
-
if (missing.length) writeFileSync4(file, `${current}${current && !current.endsWith("\n") ? "\n" : ""}${missing.join("\n")}
|
|
38965
|
-
`);
|
|
38966
|
-
}
|
|
38967
|
-
async function headSha(dir) {
|
|
38968
|
-
return (await git(dir, ["rev-parse", "HEAD"])).stdout;
|
|
38969
|
-
}
|
|
38970
|
-
async function commitAndPush(dir, branch, message, auth, always = []) {
|
|
38971
|
-
await git(dir, ["add", "-A"]);
|
|
38972
|
-
for (const p of always) if (existsSync5(join4(dir, p))) await git(dir, ["add", "-f", "--", p]);
|
|
38973
|
-
const staged = await git(dir, ["diff", "--cached", "--quiet"], { allowFail: true });
|
|
38974
|
-
if (staged.code === 1) await git(dir, ["commit", "--no-verify", "-m", message]);
|
|
38975
|
-
await git(dir, ["push", "origin", `HEAD:refs/heads/${branch}`], { auth });
|
|
38976
|
-
return headSha(dir);
|
|
38977
|
-
}
|
|
38978
|
-
function removeWorkspace(dir) {
|
|
38979
|
-
try {
|
|
38980
|
-
rmSync(dir, { recursive: true, force: true, maxRetries: 3 });
|
|
38981
|
-
return true;
|
|
38982
|
-
} catch {
|
|
38983
|
-
return false;
|
|
38984
|
-
}
|
|
38985
|
-
}
|
|
38986
|
-
async function discardLocal(dir) {
|
|
38987
|
-
if (!existsSync5(join4(dir, ".git"))) return;
|
|
38988
|
-
await git(dir, ["reset", "--hard", "HEAD"], { allowFail: true });
|
|
38989
|
-
await git(dir, ["clean", "-fd"], { allowFail: true });
|
|
38990
|
-
}
|
|
38901
|
+
import { existsSync as existsSync6, mkdirSync as mkdirSync5, readFileSync as readFileSync7, rmSync, writeFileSync as writeFileSync5 } from "node:fs";
|
|
38902
|
+
import { dirname as dirname5, join as join5 } from "node:path";
|
|
38991
38903
|
|
|
38992
38904
|
// src/worker/progress.ts
|
|
38993
|
-
import { existsSync as
|
|
38994
|
-
import { dirname as
|
|
38905
|
+
import { existsSync as existsSync5, mkdirSync as mkdirSync4, readFileSync as readFileSync6, writeFileSync as writeFileSync4 } from "node:fs";
|
|
38906
|
+
import { dirname as dirname4, join as join4 } from "node:path";
|
|
38995
38907
|
var PROGRESS_PATH = ".feedramp/progress.md";
|
|
38996
38908
|
var CONTEXT_DIR = ".feedramp/context";
|
|
38997
38909
|
var MOCKUP_DIR = ".feedramp/mockups";
|
|
38910
|
+
var PRIVATE_WORKER_DIRS = [CONTEXT_DIR, MOCKUP_DIR];
|
|
38998
38911
|
function criteriaList(claim) {
|
|
38999
38912
|
if (!claim.criteria?.length) return "_None recorded._";
|
|
39000
38913
|
return claim.criteria.map((c) => {
|
|
@@ -39010,22 +38923,22 @@ function handoffBlock(h) {
|
|
|
39010
38923
|
return lines2.join("\n");
|
|
39011
38924
|
}
|
|
39012
38925
|
function writeProgress(dir, claim, worker, now) {
|
|
39013
|
-
const file =
|
|
39014
|
-
|
|
38926
|
+
const file = join4(dir, PROGRESS_PATH);
|
|
38927
|
+
mkdirSync4(dirname4(file), { recursive: true });
|
|
39015
38928
|
const session = [
|
|
39016
38929
|
`## Claim by ${worker} at ${now.toISOString()}`,
|
|
39017
38930
|
handoffBlock(claim.handoff),
|
|
39018
38931
|
"",
|
|
39019
38932
|
"- [ ] (the agent keeps this list of done / next up to date)"
|
|
39020
38933
|
].filter(Boolean).join("\n");
|
|
39021
|
-
if (
|
|
39022
|
-
|
|
38934
|
+
if (existsSync5(file)) {
|
|
38935
|
+
writeFileSync4(file, `${readFileSync6(file, "utf8").trimEnd()}
|
|
39023
38936
|
|
|
39024
38937
|
${session}
|
|
39025
38938
|
`);
|
|
39026
38939
|
return;
|
|
39027
38940
|
}
|
|
39028
|
-
|
|
38941
|
+
writeFileSync4(file, [
|
|
39029
38942
|
`# ${claim.featureRef}: ${claim.specification.title}`,
|
|
39030
38943
|
"",
|
|
39031
38944
|
"> Maintained by Feedramp workers. Read this first and keep it up to date:",
|
|
@@ -39046,9 +38959,9 @@ ${session}
|
|
|
39046
38959
|
].join("\n"));
|
|
39047
38960
|
}
|
|
39048
38961
|
function appendProgress(dir, line) {
|
|
39049
|
-
const file =
|
|
39050
|
-
if (!
|
|
39051
|
-
|
|
38962
|
+
const file = join4(dir, PROGRESS_PATH);
|
|
38963
|
+
if (!existsSync5(file)) return;
|
|
38964
|
+
writeFileSync4(file, `${readFileSync6(file, "utf8").trimEnd()}
|
|
39052
38965
|
- ${line}
|
|
39053
38966
|
`);
|
|
39054
38967
|
}
|
|
@@ -39058,11 +38971,11 @@ function safeName(s) {
|
|
|
39058
38971
|
async function writeContext(dir, context) {
|
|
39059
38972
|
const written = [];
|
|
39060
38973
|
if (!context) return written;
|
|
39061
|
-
const ctxDir =
|
|
39062
|
-
|
|
38974
|
+
const ctxDir = join4(dir, CONTEXT_DIR);
|
|
38975
|
+
mkdirSync4(ctxDir, { recursive: true });
|
|
39063
38976
|
for (const d of context.documents ?? []) {
|
|
39064
38977
|
const p = `${CONTEXT_DIR}/${safeName(d.displayId)}-${safeName(d.title)}.md`;
|
|
39065
|
-
|
|
38978
|
+
writeFileSync4(join4(dir, p), `# ${d.displayId}: ${d.title}
|
|
39066
38979
|
|
|
39067
38980
|
${d.body ?? ""}
|
|
39068
38981
|
`);
|
|
@@ -39070,7 +38983,7 @@ ${d.body ?? ""}
|
|
|
39070
38983
|
}
|
|
39071
38984
|
for (const a of context.adrs ?? []) {
|
|
39072
38985
|
const p = `${CONTEXT_DIR}/${safeName(a.displayId)}-${safeName(a.title)}.md`;
|
|
39073
|
-
|
|
38986
|
+
writeFileSync4(join4(dir, p), `# ${a.displayId}: ${a.title} (${a.status ?? ""})
|
|
39074
38987
|
|
|
39075
38988
|
## Context
|
|
39076
38989
|
${a.context ?? ""}
|
|
@@ -39085,21 +38998,21 @@ ${a.consequences ?? ""}
|
|
|
39085
38998
|
}
|
|
39086
38999
|
if (context.memories?.length) {
|
|
39087
39000
|
const p = `${CONTEXT_DIR}/eval-shapes.md`;
|
|
39088
|
-
|
|
39001
|
+
writeFileSync4(join4(dir, p), context.memories.map((m) => `## ${m.title}
|
|
39089
39002
|
|
|
39090
39003
|
${m.content}
|
|
39091
39004
|
`).join("\n"));
|
|
39092
39005
|
written.push(p);
|
|
39093
39006
|
}
|
|
39094
39007
|
if (context.mockups?.length) {
|
|
39095
|
-
|
|
39008
|
+
mkdirSync4(join4(dir, MOCKUP_DIR), { recursive: true });
|
|
39096
39009
|
for (const m of context.mockups) {
|
|
39097
39010
|
try {
|
|
39098
39011
|
const res = await fetch(m.url, { signal: AbortSignal.timeout(3e4) });
|
|
39099
39012
|
if (!res.ok) continue;
|
|
39100
39013
|
const ext = m.mimeType.split("/")[1]?.replace("jpeg", "jpg").replace(/[^a-z0-9]/g, "") || "png";
|
|
39101
39014
|
const p = `${MOCKUP_DIR}/${m.id}-${safeName(m.name)}.${ext}`;
|
|
39102
|
-
|
|
39015
|
+
writeFileSync4(join4(dir, p), Buffer.from(await res.arrayBuffer()));
|
|
39103
39016
|
written.push(p);
|
|
39104
39017
|
} catch {
|
|
39105
39018
|
}
|
|
@@ -39124,6 +39037,129 @@ function buildPrompt(claim, o) {
|
|
|
39124
39037
|
].filter((l) => l !== null).join("\n");
|
|
39125
39038
|
}
|
|
39126
39039
|
|
|
39040
|
+
// src/worker/git.ts
|
|
39041
|
+
var GitError = class extends Error {
|
|
39042
|
+
constructor(message, result) {
|
|
39043
|
+
super(message);
|
|
39044
|
+
this.result = result;
|
|
39045
|
+
}
|
|
39046
|
+
result;
|
|
39047
|
+
};
|
|
39048
|
+
function authEnv(auth) {
|
|
39049
|
+
const env = { GIT_TERMINAL_PROMPT: "0", GCM_INTERACTIVE: "never" };
|
|
39050
|
+
if (!auth || !/^https:\/\//i.test(auth.url)) return env;
|
|
39051
|
+
const origin = new URL(auth.url).origin + "/";
|
|
39052
|
+
const basic = Buffer.from(`x-access-token:${auth.token}`).toString("base64");
|
|
39053
|
+
Object.assign(env, {
|
|
39054
|
+
GIT_CONFIG_COUNT: "2",
|
|
39055
|
+
GIT_CONFIG_KEY_0: `http.${origin}.extraheader`,
|
|
39056
|
+
GIT_CONFIG_VALUE_0: `AUTHORIZATION: basic ${basic}`,
|
|
39057
|
+
// Make sure no credential helper stores or prompts for anything.
|
|
39058
|
+
GIT_CONFIG_KEY_1: "credential.helper",
|
|
39059
|
+
GIT_CONFIG_VALUE_1: ""
|
|
39060
|
+
});
|
|
39061
|
+
return env;
|
|
39062
|
+
}
|
|
39063
|
+
function git(cwd, args, opts = {}) {
|
|
39064
|
+
return new Promise((resolve4, reject) => {
|
|
39065
|
+
const child = spawn("git", args, {
|
|
39066
|
+
cwd,
|
|
39067
|
+
env: { ...process.env, ...authEnv(opts.auth) },
|
|
39068
|
+
windowsHide: true,
|
|
39069
|
+
stdio: ["ignore", "pipe", "pipe"]
|
|
39070
|
+
});
|
|
39071
|
+
let stdout = "", stderr = "";
|
|
39072
|
+
child.stdout.on("data", (d) => {
|
|
39073
|
+
stdout += d;
|
|
39074
|
+
});
|
|
39075
|
+
child.stderr.on("data", (d) => {
|
|
39076
|
+
stderr += d;
|
|
39077
|
+
});
|
|
39078
|
+
child.on("error", reject);
|
|
39079
|
+
child.on("close", (code) => {
|
|
39080
|
+
const result = { code: code ?? 1, stdout: stdout.trim(), stderr: redact2(stderr.trim(), opts.auth) };
|
|
39081
|
+
if (result.code !== 0 && !opts.allowFail) reject(new GitError(`git ${args[0]} failed: ${result.stderr || result.stdout}`, result));
|
|
39082
|
+
else resolve4(result);
|
|
39083
|
+
});
|
|
39084
|
+
});
|
|
39085
|
+
}
|
|
39086
|
+
function redact2(text, auth) {
|
|
39087
|
+
return auth?.token ? text.split(auth.token).join("***") : text;
|
|
39088
|
+
}
|
|
39089
|
+
async function prepareWorkspace(o) {
|
|
39090
|
+
if (!existsSync6(join5(o.dir, ".git"))) {
|
|
39091
|
+
mkdirSync5(dirname5(o.dir), { recursive: true });
|
|
39092
|
+
await git(dirname5(o.dir), ["clone", "--no-tags", o.cloneUrl, o.dir], { auth: o.auth });
|
|
39093
|
+
} else {
|
|
39094
|
+
await git(o.dir, ["remote", "set-url", "origin", o.cloneUrl]);
|
|
39095
|
+
await git(o.dir, ["fetch", "--prune", "origin"], { auth: o.auth });
|
|
39096
|
+
}
|
|
39097
|
+
const local = [
|
|
39098
|
+
["user.name", o.author.name],
|
|
39099
|
+
["user.email", o.author.email],
|
|
39100
|
+
["core.autocrlf", "false"],
|
|
39101
|
+
["core.longpaths", "true"],
|
|
39102
|
+
["push.autoSetupRemote", "false"]
|
|
39103
|
+
];
|
|
39104
|
+
for (const [k, v] of local) await git(o.dir, ["config", "--local", k, v]);
|
|
39105
|
+
writeExclude(o.dir, o.exclude);
|
|
39106
|
+
const base = await defaultBranch(o.dir, o.auth);
|
|
39107
|
+
const remoteHas = (await git(o.dir, ["ls-remote", "--heads", "origin", o.branch], { auth: o.auth })).stdout.length > 0;
|
|
39108
|
+
const start = remoteHas ? `origin/${o.branch}` : `origin/${base}`;
|
|
39109
|
+
if (remoteHas) await git(o.dir, ["fetch", "origin", `+refs/heads/${o.branch}:refs/remotes/origin/${o.branch}`], { auth: o.auth });
|
|
39110
|
+
await git(o.dir, ["checkout", "--force", "-B", o.branch, start]);
|
|
39111
|
+
await git(o.dir, ["reset", "--hard", start]);
|
|
39112
|
+
await git(o.dir, ["clean", "-fd"]);
|
|
39113
|
+
return { base, resumed: remoteHas };
|
|
39114
|
+
}
|
|
39115
|
+
async function defaultBranch(dir, auth) {
|
|
39116
|
+
const head = await git(dir, ["symbolic-ref", "--short", "refs/remotes/origin/HEAD"], { allowFail: true });
|
|
39117
|
+
if (head.code === 0 && head.stdout.startsWith("origin/")) return head.stdout.slice("origin/".length);
|
|
39118
|
+
const remote = await git(dir, ["ls-remote", "--symref", "origin", "HEAD"], { auth, allowFail: true });
|
|
39119
|
+
const m = remote.stdout.match(/^ref: refs\/heads\/(\S+)\s+HEAD/m);
|
|
39120
|
+
return m?.[1] ?? "main";
|
|
39121
|
+
}
|
|
39122
|
+
function writeExclude(dir, paths) {
|
|
39123
|
+
const file = join5(dir, ".git", "info", "exclude");
|
|
39124
|
+
mkdirSync5(dirname5(file), { recursive: true });
|
|
39125
|
+
const current = existsSync6(file) ? readFileSync7(file, "utf8") : "";
|
|
39126
|
+
const missing = paths.filter((p) => !current.split(/\r?\n/).includes(p));
|
|
39127
|
+
if (missing.length) writeFileSync5(file, `${current}${current && !current.endsWith("\n") ? "\n" : ""}${missing.join("\n")}
|
|
39128
|
+
`);
|
|
39129
|
+
}
|
|
39130
|
+
async function headSha(dir) {
|
|
39131
|
+
return (await git(dir, ["rev-parse", "HEAD"])).stdout;
|
|
39132
|
+
}
|
|
39133
|
+
async function commitAndPush(dir, branch, message, startSha, auth, always = []) {
|
|
39134
|
+
const privatePaths = PRIVATE_WORKER_DIRS.map((path2) => `:(top,literal,icase)${path2}`);
|
|
39135
|
+
await git(dir, ["add", "-A"]);
|
|
39136
|
+
for (const p of always) if (existsSync6(join5(dir, p))) await git(dir, ["add", "-f", "--", p]);
|
|
39137
|
+
await git(dir, ["reset", "-q", "--", ...privatePaths]);
|
|
39138
|
+
const privateStaged = await git(dir, ["diff", "--cached", "--no-renames", "--name-only", "--", ...privatePaths]);
|
|
39139
|
+
if (privateStaged.stdout) throw new Error("Worker context or mockup files are still staged. Refusing to commit or push.");
|
|
39140
|
+
const staged = await git(dir, ["diff", "--cached", "--quiet"], { allowFail: true });
|
|
39141
|
+
if (staged.code === 1) await git(dir, ["commit", "--no-verify", "-m", message]);
|
|
39142
|
+
if (staged.code > 1) throw new GitError("Could not inspect staged worker changes", staged);
|
|
39143
|
+
const sha = await headSha(dir);
|
|
39144
|
+
const privateCommits = await git(dir, ["log", "--full-history", "-m", "-1", "--format=%H", `${startSha}..${sha}`, "--", ...privatePaths]);
|
|
39145
|
+
if (privateCommits.stdout) throw new Error("Worker context or mockup files changed in local commits. Refusing to push.");
|
|
39146
|
+
await git(dir, ["push", "origin", `${sha}:refs/heads/${branch}`], { auth });
|
|
39147
|
+
return sha;
|
|
39148
|
+
}
|
|
39149
|
+
function removeWorkspace(dir) {
|
|
39150
|
+
try {
|
|
39151
|
+
rmSync(dir, { recursive: true, force: true, maxRetries: 3 });
|
|
39152
|
+
return true;
|
|
39153
|
+
} catch {
|
|
39154
|
+
return false;
|
|
39155
|
+
}
|
|
39156
|
+
}
|
|
39157
|
+
async function discardLocal(dir) {
|
|
39158
|
+
if (!existsSync6(join5(dir, ".git"))) return;
|
|
39159
|
+
await git(dir, ["reset", "--hard", "HEAD"], { allowFail: true });
|
|
39160
|
+
await git(dir, ["clean", "-fd"], { allowFail: true });
|
|
39161
|
+
}
|
|
39162
|
+
|
|
39127
39163
|
// src/worker/resilience.ts
|
|
39128
39164
|
function isTransient(e) {
|
|
39129
39165
|
if (!(e instanceof CliError)) return true;
|
|
@@ -39431,6 +39467,7 @@ async function runOnce(deps, signal) {
|
|
|
39431
39467
|
const tokens = [];
|
|
39432
39468
|
let token = null;
|
|
39433
39469
|
let branch = "";
|
|
39470
|
+
let initialSha;
|
|
39434
39471
|
let usageDone = {};
|
|
39435
39472
|
let usageRun = {};
|
|
39436
39473
|
let lastNote;
|
|
@@ -39443,7 +39480,7 @@ async function runOnce(deps, signal) {
|
|
|
39443
39480
|
return { token: token.token, url: token.cloneUrl };
|
|
39444
39481
|
}
|
|
39445
39482
|
async function push(message) {
|
|
39446
|
-
return commitAndPush(dir, branch, message, await auth(), [PROGRESS_PATH]);
|
|
39483
|
+
return commitAndPush(dir, branch, message, initialSha, await auth(), [PROGRESS_PATH]);
|
|
39447
39484
|
}
|
|
39448
39485
|
function checkpoint(sha) {
|
|
39449
39486
|
return { branch, headSha: sha, progressPath: PROGRESS_PATH, pushedAt: now().toISOString() };
|
|
@@ -39565,8 +39602,9 @@ async function runOnce(deps, signal) {
|
|
|
39565
39602
|
branch,
|
|
39566
39603
|
auth: first,
|
|
39567
39604
|
author: { name: settings.git.authorName, email: settings.git.authorEmail },
|
|
39568
|
-
exclude:
|
|
39605
|
+
exclude: PRIVATE_WORKER_DIRS.map((path2) => `${path2}/`)
|
|
39569
39606
|
});
|
|
39607
|
+
initialSha = await headSha(dir);
|
|
39570
39608
|
const context = await steady("context", () => api.context(ref)).catch((e) => {
|
|
39571
39609
|
log(`context unavailable: ${e.message}`);
|
|
39572
39610
|
return null;
|
|
@@ -39974,7 +40012,7 @@ function loadWorkerConfig(name) {
|
|
|
39974
40012
|
checkName(name);
|
|
39975
40013
|
migrateLegacy(name);
|
|
39976
40014
|
const p = configPath(name);
|
|
39977
|
-
if (!existsSync8(p)) throw new CliError(`no worker named "${name}". Set it up with
|
|
40015
|
+
if (!existsSync8(p)) throw new CliError(`no worker named "${name}". Set it up with \`${cli()} worker setup --enroll <code>\` (the code comes from the Workers page).`, { exitCode: ExitCode.NOT_FOUND });
|
|
39978
40016
|
const c = JSON.parse(readFileSync9(p, "utf8"));
|
|
39979
40017
|
return { ...c, workRoot: expandHome(c.workRoot), models: c.models ?? [] };
|
|
39980
40018
|
}
|
|
@@ -40040,7 +40078,7 @@ function acquireLock(name, pid = process.pid) {
|
|
|
40040
40078
|
if (e.code !== "EEXIST") throw e;
|
|
40041
40079
|
const holder = Number(readFileSync9(p, "utf8").trim());
|
|
40042
40080
|
if (holder && holder !== pid && pidAlive(holder)) {
|
|
40043
|
-
throw new CliError(`worker "${name}" is already running on this machine (process ${holder}). Stop it first with
|
|
40081
|
+
throw new CliError(`worker "${name}" is already running on this machine (process ${holder}). Stop it first with \`${cli()} worker stop --name ${name}\`.`, { exitCode: ExitCode.GENERAL });
|
|
40044
40082
|
}
|
|
40045
40083
|
try {
|
|
40046
40084
|
unlinkSync3(p);
|
|
@@ -40100,7 +40138,7 @@ var GIT_FIX = "Install git 2.31 or newer (https://git-scm.com/downloads) for the
|
|
|
40100
40138
|
function agentProblem(a, name) {
|
|
40101
40139
|
if (!a.supported) return { what: `This Feedramp CLI can't run ${a.label} yet`, fix: "Pick Claude Code for this worker on the Workers page, or update the CLI when it supports this agent." };
|
|
40102
40140
|
if (!a.installed) return { what: `${a.label} isn't installed (or isn't on this user's PATH)`, fix: a.label === "Claude Code" ? "Install Claude Code (https://claude.com/claude-code) as this user, then open a new terminal so it's on PATH." : `Install ${a.label} as this user.` };
|
|
40103
|
-
if (a.signedIn === false) return { what: `${a.label} isn't signed in`, fix: a.ownLogin ?
|
|
40141
|
+
if (a.signedIn === false) return { what: `${a.label} isn't signed in`, fix: a.ownLogin ? `${cli()} worker agent-login --name ${name}` : a.label === "Claude Code" ? "Run `claude` and sign in with /login, then /exit." : `Sign ${a.label} in as this user.` };
|
|
40104
40142
|
return null;
|
|
40105
40143
|
}
|
|
40106
40144
|
function doctorChecks(f) {
|
|
@@ -40108,7 +40146,7 @@ function doctorChecks(f) {
|
|
|
40108
40146
|
const add = (id, state, what, fix) => out.push({ id, state, what, ...fix ? { fix } : {} });
|
|
40109
40147
|
add("node", "ok", `Node.js ${f.node.version}`);
|
|
40110
40148
|
if (f.node.servicePath && f.node.servicePathOk === false) {
|
|
40111
|
-
add("service-node", "fail", `The service runs Node from ${f.node.servicePath}, which isn't there any more`,
|
|
40149
|
+
add("service-node", "fail", `The service runs Node from ${f.node.servicePath}, which isn't there any more`, `${cli()} worker setup --name ${f.name} (sets the service up again with this Node)`);
|
|
40112
40150
|
}
|
|
40113
40151
|
const gv = f.git ? parseGitVersion(f.git) : null;
|
|
40114
40152
|
if (!f.git) add("git", "fail", "git isn't installed (or isn't on this user's PATH)", GIT_FIX);
|
|
@@ -40116,7 +40154,7 @@ function doctorChecks(f) {
|
|
|
40116
40154
|
else add("git", "ok", f.git);
|
|
40117
40155
|
const ap = agentProblem(f.agent, f.name);
|
|
40118
40156
|
add("agent", ap ? "fail" : "ok", ap ? ap.what : `${f.agent.label}${f.agent.version ? ` ${f.agent.version}` : ""} installed and signed in`, ap?.fix);
|
|
40119
|
-
if (!f.key) add("key", "fail", "No key stored for this worker", `Get a new setup code on the Workers page (Replace key), then:
|
|
40157
|
+
if (!f.key) add("key", "fail", "No key stored for this worker", `Get a new setup code on the Workers page (Replace key), then: ${cli()} worker setup --enroll <code> --name ${f.name}`);
|
|
40120
40158
|
else add("key", "ok", "Key stored");
|
|
40121
40159
|
if (f.key) {
|
|
40122
40160
|
if (f.feedramp.ok) {
|
|
@@ -40128,7 +40166,7 @@ function doctorChecks(f) {
|
|
|
40128
40166
|
);
|
|
40129
40167
|
} else {
|
|
40130
40168
|
const c = f.feedramp.code ?? "";
|
|
40131
|
-
const fix = c === "REVOKED_API_KEY" || c === "INVALID_API_KEY" || c === "EXPIRED_API_KEY" ? `This worker's key no longer works. Get a new setup code on the Workers page (Replace key), then:
|
|
40169
|
+
const fix = c === "REVOKED_API_KEY" || c === "INVALID_API_KEY" || c === "EXPIRED_API_KEY" ? `This worker's key no longer works. Get a new setup code on the Workers page (Replace key), then: ${cli()} worker setup --enroll <code> --name ${f.name}` : c ? "See the message above; `--verbose` shows the full answer from Feedramp." : `Check this machine can reach ${f.apiUrl} (proxy, firewall, DNS).`;
|
|
40132
40170
|
add("feedramp", "fail", `Can't use Feedramp at ${f.apiUrl}: ${f.feedramp.message}`, fix);
|
|
40133
40171
|
}
|
|
40134
40172
|
}
|
|
@@ -40136,15 +40174,15 @@ function doctorChecks(f) {
|
|
|
40136
40174
|
add(
|
|
40137
40175
|
"service",
|
|
40138
40176
|
"warn",
|
|
40139
|
-
|
|
40140
|
-
|
|
40177
|
+
`Not set up to run in the background: it only runs while \`${cli()} worker start\` is open`,
|
|
40178
|
+
`${cli()} worker setup --name ${f.name}`
|
|
40141
40179
|
);
|
|
40142
40180
|
} else {
|
|
40143
|
-
if (!f.service.cliOk) add("service-cli", "fail", `The service's copy of the CLI is missing (${f.service.cli})`,
|
|
40181
|
+
if (!f.service.cliOk) add("service-cli", "fail", `The service's copy of the CLI is missing (${f.service.cli})`, `${cli()} worker setup --name ${f.name}`);
|
|
40144
40182
|
const s = f.service.state;
|
|
40145
|
-
if (!s.installed) add("service", "fail", "The background service was removed",
|
|
40183
|
+
if (!s.installed) add("service", "fail", "The background service was removed", `${cli()} worker setup --name ${f.name}`);
|
|
40146
40184
|
else if (f.process.running || s.running) add("service", "ok", `Runs in the background (starts ${f.service.startsWhen})`);
|
|
40147
|
-
else add("service", "fail", `The background service isn't running (${s.detail})`, `Look at the log (${f.service.logs}), fix what it says, then:
|
|
40185
|
+
else add("service", "fail", `The background service isn't running (${s.detail})`, `Look at the log (${f.service.logs}), fix what it says, then: ${cli()} worker setup --name ${f.name}`);
|
|
40148
40186
|
}
|
|
40149
40187
|
if (f.process.running) {
|
|
40150
40188
|
const st = f.process.state ?? "running";
|
|
@@ -40400,7 +40438,7 @@ function serviceInput(config, svc, os) {
|
|
|
40400
40438
|
};
|
|
40401
40439
|
}
|
|
40402
40440
|
function runningCliFile() {
|
|
40403
|
-
const file =
|
|
40441
|
+
const file = fileURLToPath2(import.meta.url);
|
|
40404
40442
|
if (basename(file) !== "feedramp.js") throw new UsageError("worker setup copies the built CLI: run it from the npm package or `node cli/dist/feedramp.js`, not from source");
|
|
40405
40443
|
return file;
|
|
40406
40444
|
}
|
|
@@ -40412,13 +40450,13 @@ async function stopWorker(name, maxMs, say) {
|
|
|
40412
40450
|
const s = isRunning(name);
|
|
40413
40451
|
if (!s) return;
|
|
40414
40452
|
if (s.featureRef && maxMs === 0) {
|
|
40415
|
-
throw new CliError(`worker "${name}" is working on ${s.featureRef}. Stop it first with
|
|
40453
|
+
throw new CliError(`worker "${name}" is working on ${s.featureRef}. Stop it first with \`${cli()} worker stop --name ${name}\` (it hands the feature back cleanly), then run this again.`, { exitCode: ExitCode.CONFLICT });
|
|
40416
40454
|
}
|
|
40417
40455
|
say(s.featureRef ? `Asking ${name} to stop: it pushes its work on ${s.featureRef} and hands it back first\u2026` : `Stopping ${name}\u2026`);
|
|
40418
40456
|
requestStop(name);
|
|
40419
40457
|
const deadline = Date.now() + Math.max(maxMs, 3e4);
|
|
40420
40458
|
while (pidAlive(s.pid) && Date.now() < deadline) await sleep2(1e3);
|
|
40421
|
-
if (pidAlive(s.pid)) throw new CliError(`worker "${name}" hasn't stopped yet (process ${s.pid}). Check
|
|
40459
|
+
if (pidAlive(s.pid)) throw new CliError(`worker "${name}" hasn't stopped yet (process ${s.pid}). Check \`${cli()} worker status --name ${name}\` and try again.`, { exitCode: ExitCode.GENERAL });
|
|
40422
40460
|
clearStop(name);
|
|
40423
40461
|
}
|
|
40424
40462
|
async function agentFacts(c) {
|
|
@@ -40458,7 +40496,7 @@ async function setupWorker(opts, flags) {
|
|
|
40458
40496
|
const gv = git2 ? parseGitVersion(git2) : null;
|
|
40459
40497
|
if (!git2 || gv && !gitNewEnough(gv)) throw new CliError(`${git2 ? `${git2} is too old (needs 2.31 or newer)` : "git isn't installed (or isn't on PATH)"}. ${GIT_FIX}${unused}`);
|
|
40460
40498
|
if (opts.service && os === "linux" && !systemdUserAvailable()) {
|
|
40461
|
-
throw new CliError(`This machine has no systemd user session, so the worker can't run in the background as you. Run this again with --no-service and keep
|
|
40499
|
+
throw new CliError(`This machine has no systemd user session, so the worker can't run in the background as you. Run this again with --no-service and keep \`${cli()} worker start\` running yourself (for example under your own process manager).${unused}`);
|
|
40462
40500
|
}
|
|
40463
40501
|
const probe = {
|
|
40464
40502
|
name: existing?.name ?? opts.name ?? "new-worker",
|
|
@@ -40536,8 +40574,8 @@ async function setupWorker(opts, flags) {
|
|
|
40536
40574
|
notes: []
|
|
40537
40575
|
};
|
|
40538
40576
|
const unprompted = unpromptedWarning(config);
|
|
40539
|
-
if (unprompted) result.notes.push(`${agentLabel(config.agent)} runs without permission prompts as ${currentUser(os)}, so it can read and change anything this user can. Use a machine (or a user) kept for the worker, or
|
|
40540
|
-
if (config.ownAgentLogin) result.notes.push(`Sign the agent in for this worker:
|
|
40577
|
+
if (unprompted) result.notes.push(`${agentLabel(config.agent)} runs without permission prompts as ${currentUser(os)}, so it can read and change anything this user can. Use a machine (or a user) kept for the worker, or \`${cli()} worker install\` for a separate OS user.`);
|
|
40578
|
+
if (config.ownAgentLogin) result.notes.push(`Sign the agent in for this worker: ${cli()} worker agent-login --name ${config.name}`);
|
|
40541
40579
|
if (copy && config.service) {
|
|
40542
40580
|
const plan = userServicePlan(serviceInput(config, config.service, os));
|
|
40543
40581
|
say("Starting it in the background\u2026");
|
|
@@ -40554,7 +40592,7 @@ async function setupWorker(opts, flags) {
|
|
|
40554
40592
|
result.service = { id: plan.id, startsWhen: plan.startsWhen, logs: plan.logs, running };
|
|
40555
40593
|
report(result, flags, config.name);
|
|
40556
40594
|
if (!running) {
|
|
40557
|
-
throw new CliError(`The service was set up but the worker didn't start within 30 seconds. Look at its log (${plan.logs}) or run
|
|
40595
|
+
throw new CliError(`The service was set up but the worker didn't start within 30 seconds. Look at its log (${plan.logs}) or run \`${cli()} worker doctor --name ${config.name}\`.`);
|
|
40558
40596
|
}
|
|
40559
40597
|
return;
|
|
40560
40598
|
}
|
|
@@ -40578,10 +40616,10 @@ function report(r, flags, name) {
|
|
|
40578
40616
|
` It starts again ${r.service.startsWhen}, and after a crash.`,
|
|
40579
40617
|
` Folder: ${r.folder}`,
|
|
40580
40618
|
` Log: ${r.service.logs}`,
|
|
40581
|
-
` Check:
|
|
40582
|
-
` Stop:
|
|
40583
|
-
` Remove:
|
|
40584
|
-
] : [`\u2713 Worker ${name} is set up. Start it with:
|
|
40619
|
+
` Check: ${cli()} worker doctor --name ${name}`,
|
|
40620
|
+
` Stop: ${cli()} worker stop --name ${name} (finishes cleanly; starts again ${r.service.startsWhen})`,
|
|
40621
|
+
` Remove: ${cli()} worker uninstall --name ${name}`
|
|
40622
|
+
] : [`\u2713 Worker ${name} is set up. Start it with: ${cli()} worker start --name ${name}`, ` Folder: ${r.folder}`];
|
|
40585
40623
|
if (r.service?.running) lines2.push("", "It shows as connected on the Workers page within a minute.");
|
|
40586
40624
|
for (const n of r.notes) lines2.push("", `note: ${n}`);
|
|
40587
40625
|
process.stdout.write(`${lines2.join("\n")}
|
|
@@ -40690,7 +40728,7 @@ async function uninstallWorker(name, forget, flags) {
|
|
|
40690
40728
|
}
|
|
40691
40729
|
process.stdout.write([
|
|
40692
40730
|
removed ? `\u2713 Removed ${name}'s background service.` : `\u2713 ${name} had no background service.`,
|
|
40693
|
-
forget ? ` Deleted its folder and key from this machine. Revoke or delete it on the Workers page too, unless you'll set it up again.` : ` Its settings and key are still here:
|
|
40731
|
+
forget ? ` Deleted its folder and key from this machine. Revoke or delete it on the Workers page too, unless you'll set it up again.` : ` Its settings and key are still here: \`${cli()} worker setup --name ${name}\` runs it in the background again.`
|
|
40694
40732
|
].join("\n") + "\n");
|
|
40695
40733
|
}
|
|
40696
40734
|
|
|
@@ -41349,7 +41387,7 @@ function agentEnv(config, agentId, base = process.env) {
|
|
|
41349
41387
|
function unpromptedWarning(config, user = safeUser()) {
|
|
41350
41388
|
if (config.agent !== "claude-code" || (config.permissionMode ?? "bypassPermissions") !== "bypassPermissions") return null;
|
|
41351
41389
|
if (user.toLowerCase() === `feedramp-${config.name}`) return null;
|
|
41352
|
-
return `warning: Claude Code runs without permission prompts as "${user}", so it can read and change anything this user can. Run the worker as its own user (
|
|
41390
|
+
return `warning: Claude Code runs without permission prompts as "${user}", so it can read and change anything this user can. Run the worker as its own user (${cli()} worker install --name ${config.name}) or on a machine kept for it.`;
|
|
41353
41391
|
}
|
|
41354
41392
|
function safeUser() {
|
|
41355
41393
|
try {
|
|
@@ -41455,30 +41493,30 @@ function registerWorker(program3) {
|
|
|
41455
41493
|
agent: config.agent,
|
|
41456
41494
|
models: config.models,
|
|
41457
41495
|
next: [
|
|
41458
|
-
...config.ownAgentLogin ? [
|
|
41459
|
-
|
|
41460
|
-
|
|
41496
|
+
...config.ownAgentLogin ? [`${cli()} worker agent-login --name ${config.name}`] : [],
|
|
41497
|
+
`${cli()} worker setup --name ${config.name} (runs it in the background)`,
|
|
41498
|
+
`${cli()} worker start --name ${config.name} (or run it here, in the foreground)`
|
|
41461
41499
|
]
|
|
41462
41500
|
});
|
|
41463
41501
|
}), `feedramp --api-url https://test.feedramp.ai worker init --name win-box-claude --enroll 7K3M-Q9TD`);
|
|
41464
|
-
withFooter(worker.command("setup").description("Set up a worker and run it in the background as you, no admin needed: checks git and the agent first, uses the one-time code, keeps its own copy of the CLI and starts the service. Without --enroll, sets the background service up again for a worker already on this machine (e.g. after updating the CLI).").option("--enroll <code>", "One-time setup code from Feedramp's Workers page").option("--name <name>", "Worker name (with --enroll, defaults to its name on the Workers page)").option("--own-agent-login", "Give the agent its own sign-in in this worker's folder, e.g. to run two Claude accounts on one machine").option("--work-root <dir>", "Where feature checkouts go (default: the worker's own folder)").option("--permission-mode <mode>", `Claude Code permission mode: ${PERMISSION_MODES.join(", ")} (default bypassPermissions: no prompts, so the agent can reach whatever you can)`).option("--pass-env <names>", "Comma-separated environment variables the agent may see beyond the basics, e.g. DATABASE_URL or AWS_*").option("--no-service",
|
|
41502
|
+
withFooter(worker.command("setup").description("Set up a worker and run it in the background as you, no admin needed: checks git and the agent first, uses the one-time code, keeps its own copy of the CLI and starts the service. Without --enroll, sets the background service up again for a worker already on this machine (e.g. after updating the CLI).").option("--enroll <code>", "One-time setup code from Feedramp's Workers page").option("--name <name>", "Worker name (with --enroll, defaults to its name on the Workers page)").option("--own-agent-login", "Give the agent its own sign-in in this worker's folder, e.g. to run two Claude accounts on one machine").option("--work-root <dir>", "Where feature checkouts go (default: the worker's own folder)").option("--permission-mode <mode>", `Claude Code permission mode: ${PERMISSION_MODES.join(", ")} (default bypassPermissions: no prompts, so the agent can reach whatever you can)`).option("--pass-env <names>", "Comma-separated environment variables the agent may see beyond the basics, e.g. DATABASE_URL or AWS_*").option("--no-service", `Don't run it in the background; start it yourself with \`${cli()} worker start\``).action(async (opts, cmd) => {
|
|
41465
41503
|
const flags = getGlobalFlags(cmd);
|
|
41466
41504
|
await setupWorker(opts, flags);
|
|
41467
41505
|
}), `npx -y @feedramp/cli@latest worker setup --enroll 7K3M-Q9TD --api-url https://feedramp.ai`);
|
|
41468
41506
|
withFooter(worker.command("doctor").description("Check what a worker needs on this machine (git, the agent and its sign-in, its key, Feedramp, the background service) and say how to fix what's missing").option("--name <name>", "Only this worker (default: every worker on this machine)").action(async (opts, cmd) => {
|
|
41469
41507
|
const flags = getGlobalFlags(cmd);
|
|
41470
41508
|
await doctorCommand(opts.name, flags);
|
|
41471
|
-
}),
|
|
41509
|
+
}), `${cli()} worker doctor --name win-box-claude`);
|
|
41472
41510
|
withFooter(worker.command("uninstall").description("Stop a worker cleanly (it hands its feature back) and remove its background service. --forget also deletes its folder and key from this machine.").requiredOption("--name <name>", "Worker name").option("--forget", "Also delete the worker's folder (checkouts, logs) and its key from this machine").action(async (opts, cmd) => {
|
|
41473
41511
|
const flags = getGlobalFlags(cmd);
|
|
41474
41512
|
await uninstallWorker(checkName(opts.name), !!opts.forget, flags);
|
|
41475
|
-
}),
|
|
41476
|
-
withFooter(worker.command("start").description(
|
|
41513
|
+
}), `${cli()} worker uninstall --name win-box-claude`);
|
|
41514
|
+
withFooter(worker.command("start").description(`Run the worker loop in the foreground (Ctrl-C or \`${cli()} worker stop\` stops it cleanly)`).requiredOption("--name <name>", "Worker name").option("--once", "Work on at most one feature, then exit").action(async (opts, cmd) => {
|
|
41477
41515
|
const flags = getGlobalFlags(cmd);
|
|
41478
41516
|
const config = loadWorkerConfig(opts.name);
|
|
41479
41517
|
const auth = await loadApiKey({ flag: flags.apiKey, profile: keyProfile(config.name) });
|
|
41480
41518
|
if (!auth.apiKey && readStatus(config.name)?.state === "revoked") {
|
|
41481
|
-
process.stderr.write(`feedramp: worker "${config.name}" was revoked in Feedramp and its key was removed. Set it up again with
|
|
41519
|
+
process.stderr.write(`feedramp: worker "${config.name}" was revoked in Feedramp and its key was removed. Set it up again with \`${cli()} worker setup --enroll <code>\` to bring it back.
|
|
41482
41520
|
`);
|
|
41483
41521
|
return;
|
|
41484
41522
|
}
|
|
@@ -41567,7 +41605,7 @@ function registerWorker(program3) {
|
|
|
41567
41605
|
process.off("SIGINT", shutdown);
|
|
41568
41606
|
process.off("SIGTERM", shutdown);
|
|
41569
41607
|
}
|
|
41570
|
-
}),
|
|
41608
|
+
}), `${cli()} worker start --name win-box-claude`);
|
|
41571
41609
|
withFooter(worker.command("agent-login").description("Sign the agent in for a worker that has its own agent login (set up with --own-agent-login)").requiredOption("--name <name>", "Worker name").action(async (opts) => {
|
|
41572
41610
|
const config = loadWorkerConfig(opts.name);
|
|
41573
41611
|
if (!config.ownAgentLogin) throw new UsageError(`worker "${config.name}" uses this machine user's own ${agentLabel(config.agent)} sign-in. Set it up again with --own-agent-login to give it its own.`);
|
|
@@ -41581,7 +41619,7 @@ function registerWorker(program3) {
|
|
|
41581
41619
|
child.on("error", () => done(127));
|
|
41582
41620
|
});
|
|
41583
41621
|
if (code === 127) throw new CliError("Claude Code (claude) isn't installed or isn't on PATH", { exitCode: ExitCode.GENERAL });
|
|
41584
|
-
}),
|
|
41622
|
+
}), `${cli()} worker agent-login --name box-2-claude-b`);
|
|
41585
41623
|
withFooter(worker.command("install").description("Run the worker as a service under its own OS user (prints the plan; --apply runs it as root/administrator)").requiredOption("--name <name>", "Worker name (set up with worker init first)").option("--apply", "Carry out the plan (needs root, or an elevated prompt on Windows)").option("--os <os>", "Show the plan for another OS: linux, macos or windows").action(async (opts, cmd) => {
|
|
41586
41624
|
const flags = getGlobalFlags(cmd);
|
|
41587
41625
|
const config = loadWorkerConfig(opts.name);
|
|
@@ -41605,8 +41643,8 @@ Nothing changed. Run again with --apply (as root/administrator) to do this.
|
|
|
41605
41643
|
Installed ${config.name} as ${plan.user}. Next:
|
|
41606
41644
|
${plan.after.map((a) => `- ${a}`).join("\n")}
|
|
41607
41645
|
`);
|
|
41608
|
-
}),
|
|
41609
|
-
$ sudo
|
|
41646
|
+
}), `${cli()} worker install --name box-2-claude # review the plan
|
|
41647
|
+
$ sudo ${cli()} worker install --name box-2-claude --apply`);
|
|
41610
41648
|
withFooter(worker.command("status").description("What each worker on this machine is doing").option("--name <name>", "Only this worker").action(async (opts, cmd) => {
|
|
41611
41649
|
const flags = getGlobalFlags(cmd);
|
|
41612
41650
|
const names = opts.name ? [checkName(opts.name)] : listWorkerNames();
|
|
@@ -41631,7 +41669,7 @@ ${plan.after.map((a) => `- ${a}`).join("\n")}
|
|
|
41631
41669
|
};
|
|
41632
41670
|
});
|
|
41633
41671
|
emit(makeContext({ json: flags.json, jsonl: flags.jsonl, pretty: flags.pretty, quiet: flags.quiet, fields: flags.fields }), opts.name ? rows[0] : rows);
|
|
41634
|
-
}),
|
|
41672
|
+
}), `${cli()} worker status`);
|
|
41635
41673
|
withFooter(worker.command("stop").description("Ask a running worker to stop cleanly: it commits and pushes its work, then releases the feature with a hand-off").requiredOption("--name <name>", "Worker name").action(async (opts, cmd) => {
|
|
41636
41674
|
const flags = getGlobalFlags(cmd);
|
|
41637
41675
|
loadWorkerConfig(opts.name);
|
|
@@ -41639,7 +41677,7 @@ ${plan.after.map((a) => `- ${a}`).join("\n")}
|
|
|
41639
41677
|
const s = readStatus(opts.name);
|
|
41640
41678
|
const running = !!s && s.state !== "stopped" && pidAlive(s.pid);
|
|
41641
41679
|
emit(makeContext({ json: flags.json, pretty: flags.pretty, quiet: flags.quiet }), { name: opts.name, stopRequested: true, running });
|
|
41642
|
-
}),
|
|
41680
|
+
}), `${cli()} worker stop --name box-2-claude`);
|
|
41643
41681
|
}
|
|
41644
41682
|
|
|
41645
41683
|
// src/index.ts
|
package/package.json
CHANGED
|
@@ -1,12 +1,12 @@
|
|
|
1
1
|
{
|
|
2
2
|
"name": "@feedramp/cli",
|
|
3
|
-
"version": "0.5.
|
|
3
|
+
"version": "0.5.2",
|
|
4
4
|
"description": "Feedramp command-line interface — drive your roadmap from the terminal.",
|
|
5
5
|
"license": "MIT",
|
|
6
6
|
"homepage": "https://feedramp.ai",
|
|
7
7
|
"type": "module",
|
|
8
8
|
"bin": {
|
|
9
|
-
"feedramp": "
|
|
9
|
+
"feedramp": "dist/feedramp.js"
|
|
10
10
|
},
|
|
11
11
|
"files": [
|
|
12
12
|
"dist",
|