@otwld/workflow-cli 0.1.33 → 0.1.34
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/package.json +1 -1
- package/src/index.d.ts +0 -1
- package/src/index.js +0 -1
- package/src/index.js.map +1 -1
- package/src/main.js +1 -4
- package/src/main.js.map +1 -1
- package/src/audit-github.d.ts +0 -46
- package/src/audit-github.js +0 -111
- package/src/audit-github.js.map +0 -1
- package/src/audit-policy.d.ts +0 -16
- package/src/audit-policy.js +0 -46
- package/src/audit-policy.js.map +0 -1
- package/src/audit-prompt.d.ts +0 -2
- package/src/audit-prompt.js +0 -61
- package/src/audit-prompt.js.map +0 -1
- package/src/audit.d.ts +0 -21
- package/src/audit.js +0 -146
- package/src/audit.js.map +0 -1
- package/src/automation.d.ts +0 -7
- package/src/automation.js +0 -37
- package/src/automation.js.map +0 -1
- package/src/codex-pool.d.ts +0 -5
- package/src/codex-pool.js +0 -48
- package/src/codex-pool.js.map +0 -1
- package/src/codex.d.ts +0 -14
- package/src/codex.js +0 -187
- package/src/codex.js.map +0 -1
- package/src/executable.d.ts +0 -7
- package/src/executable.js +0 -24
- package/src/executable.js.map +0 -1
package/package.json
CHANGED
package/src/index.d.ts
CHANGED
package/src/index.js
CHANGED
package/src/index.js.map
CHANGED
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"index.js","sourceRoot":"","sources":["../../../../apps/workflow-cli/src/index.ts"],"names":[],"mappings":"AAAA,OAAO,EAAE,YAAY,EAAE,iBAAiB,EAAE,MAAM,UAAU,CAAC;AAC3D,OAAO,EAAE,WAAW,EAAE,MAAM,eAAe,CAAC
|
|
1
|
+
{"version":3,"file":"index.js","sourceRoot":"","sources":["../../../../apps/workflow-cli/src/index.ts"],"names":[],"mappings":"AAAA,OAAO,EAAE,YAAY,EAAE,iBAAiB,EAAE,MAAM,UAAU,CAAC;AAC3D,OAAO,EAAE,WAAW,EAAE,MAAM,eAAe,CAAC"}
|
package/src/main.js
CHANGED
|
@@ -4,7 +4,6 @@ import { readFile } from 'node:fs/promises';
|
|
|
4
4
|
import { createRequire } from 'node:module';
|
|
5
5
|
import { promisify } from 'node:util';
|
|
6
6
|
import { releaseChangelog, releasePublish, releaseVersion } from 'nx/release';
|
|
7
|
-
import { runAutomation } from './automation.js';
|
|
8
7
|
import { parseCommand } from './cli.js';
|
|
9
8
|
import { isStableProjectTag } from './git-tags.js';
|
|
10
9
|
import { isRequestedNxProject } from './project-shape.js';
|
|
@@ -160,9 +159,7 @@ async function affectedProjectsQuery(baseSha, sourceSha, target) {
|
|
|
160
159
|
return result;
|
|
161
160
|
}
|
|
162
161
|
try {
|
|
163
|
-
|
|
164
|
-
await runWorkflow(parseCommand(process.argv.slice(2), process.env), dependencies);
|
|
165
|
-
}
|
|
162
|
+
await runWorkflow(parseCommand(process.argv.slice(2), process.env), dependencies);
|
|
166
163
|
}
|
|
167
164
|
catch (error) {
|
|
168
165
|
const message = error instanceof Error ? error.message : String(error);
|
package/src/main.js.map
CHANGED
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"main.js","sourceRoot":"","sources":["../../../../apps/workflow-cli/src/main.ts"],"names":[],"mappings":";AACA,OAAO,EAAE,QAAQ,EAAE,KAAK,EAAE,MAAM,oBAAoB,CAAC;AACrD,OAAO,EAAE,QAAQ,EAAE,MAAM,kBAAkB,CAAC;AAC5C,OAAO,EAAE,aAAa,EAAE,MAAM,aAAa,CAAC;AAC5C,OAAO,EAAE,SAAS,EAAE,MAAM,WAAW,CAAC;AACtC,OAAO,EAAE,gBAAgB,EAAE,cAAc,EAAE,cAAc,EAAE,MAAM,YAAY,CAAC;AAC9E,OAAO,EAAE,
|
|
1
|
+
{"version":3,"file":"main.js","sourceRoot":"","sources":["../../../../apps/workflow-cli/src/main.ts"],"names":[],"mappings":";AACA,OAAO,EAAE,QAAQ,EAAE,KAAK,EAAE,MAAM,oBAAoB,CAAC;AACrD,OAAO,EAAE,QAAQ,EAA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;IACvE,OAAO,CAAC,MAAM,CAAC,KAAK,CAAC,iBAAiB,OAAO,IAAI,CAAC,CAAC;IACnD,OAAO,CAAC,QAAQ,GAAG,CAAC,CAAC;AACvB,CAAC"}
|
package/src/audit-github.d.ts
DELETED
|
@@ -1,46 +0,0 @@
|
|
|
1
|
-
/** Marker shared by the mission and its diagnostic fallback. */
|
|
2
|
-
export declare const auditMarker = "<!-- otwld:pnpm-audit -->";
|
|
3
|
-
/** Human-controlled opt-out, honored before the mission and fallback. */
|
|
4
|
-
export declare const auditPauseLabel = "automation-paused";
|
|
5
|
-
/** Minimal PR metadata needed to route a mission or its fallback. */
|
|
6
|
-
export interface AuditPull {
|
|
7
|
-
/** GitHub PR number. */
|
|
8
|
-
number: number;
|
|
9
|
-
/** Markdown description, including the automation marker. */
|
|
10
|
-
body: string;
|
|
11
|
-
/** Current source branch, preserved across retries. */
|
|
12
|
-
headRefName: string;
|
|
13
|
-
/** Whether the source belongs to another repository. */
|
|
14
|
-
isCrossRepository: boolean;
|
|
15
|
-
/** Labels used for explicit human suspension. */
|
|
16
|
-
labels: Array<{
|
|
17
|
-
name: string;
|
|
18
|
-
}>;
|
|
19
|
-
}
|
|
20
|
-
/**
|
|
21
|
-
* Execute the runner's existing GitHub CLI with the workflow credentials.
|
|
22
|
-
* @param args - Structured gh arguments, never a shell command.
|
|
23
|
-
* @param env - Workflow environment including its dedicated PAT.
|
|
24
|
-
* @param body - Optional JSON API request body sent over stdin.
|
|
25
|
-
* @returns The command output.
|
|
26
|
-
*/
|
|
27
|
-
export declare function github(args: string[], env: NodeJS.ProcessEnv, body?: unknown): string;
|
|
28
|
-
/**
|
|
29
|
-
* Locate the single open audit PR, including PRs created before this migration.
|
|
30
|
-
* @param env - Consumer repository and credentials.
|
|
31
|
-
* @returns Existing same-repository audit PR, when present.
|
|
32
|
-
*/
|
|
33
|
-
export declare function auditPull(env: NodeJS.ProcessEnv): AuditPull | undefined;
|
|
34
|
-
/**
|
|
35
|
-
* Report only when the agent has not already communicated in this execution.
|
|
36
|
-
* @param env - Consumer repository, credentials and workflow run identity.
|
|
37
|
-
* @param diagnosis - Preserved mission response or execution failure details.
|
|
38
|
-
*/
|
|
39
|
-
export declare function ensureAuditDiagnostic(env: NodeJS.ProcessEnv, diagnosis: string): void;
|
|
40
|
-
/**
|
|
41
|
-
* Link the exact attempt so the mission and fallback can avoid duplicate reports.
|
|
42
|
-
* @param env - GitHub Actions run identity.
|
|
43
|
-
* @returns Run URL, including the attempt when available.
|
|
44
|
-
* @throws If GitHub Actions did not supply its run ID.
|
|
45
|
-
*/
|
|
46
|
-
export declare function auditRunUrl(env: NodeJS.ProcessEnv): string;
|
package/src/audit-github.js
DELETED
|
@@ -1,111 +0,0 @@
|
|
|
1
|
-
import { execFileSync } from 'node:child_process';
|
|
2
|
-
import { executable } from './executable.js';
|
|
3
|
-
/** Marker shared by the mission and its diagnostic fallback. */
|
|
4
|
-
export const auditMarker = '<!-- otwld:pnpm-audit -->';
|
|
5
|
-
/** Human-controlled opt-out, honored before the mission and fallback. */
|
|
6
|
-
export const auditPauseLabel = 'automation-paused';
|
|
7
|
-
/**
|
|
8
|
-
* Execute the runner's existing GitHub CLI with the workflow credentials.
|
|
9
|
-
* @param args - Structured gh arguments, never a shell command.
|
|
10
|
-
* @param env - Workflow environment including its dedicated PAT.
|
|
11
|
-
* @param body - Optional JSON API request body sent over stdin.
|
|
12
|
-
* @returns The command output.
|
|
13
|
-
*/
|
|
14
|
-
export function github(args, env, body) {
|
|
15
|
-
return execFileSync(executable('gh'), args, {
|
|
16
|
-
env: { ...process.env, ...env, GH_REPO: repository(env) },
|
|
17
|
-
input: body === undefined ? undefined : JSON.stringify(body),
|
|
18
|
-
encoding: 'utf8',
|
|
19
|
-
maxBuffer: 8 * 1024 * 1024,
|
|
20
|
-
});
|
|
21
|
-
}
|
|
22
|
-
/**
|
|
23
|
-
* Locate the single open audit PR, including PRs created before this migration.
|
|
24
|
-
* @param env - Consumer repository and credentials.
|
|
25
|
-
* @returns Existing same-repository audit PR, when present.
|
|
26
|
-
*/
|
|
27
|
-
export function auditPull(env) {
|
|
28
|
-
const pulls = JSON.parse(github([
|
|
29
|
-
'pr',
|
|
30
|
-
'list',
|
|
31
|
-
'--state',
|
|
32
|
-
'open',
|
|
33
|
-
'--limit',
|
|
34
|
-
'100',
|
|
35
|
-
'--json',
|
|
36
|
-
'number,body,headRefName,isCrossRepository,labels',
|
|
37
|
-
], env));
|
|
38
|
-
return pulls.find((pull) => !pull.isCrossRepository &&
|
|
39
|
-
(pull.body.includes(auditMarker) ||
|
|
40
|
-
pull.headRefName === 'automation/pnpm-audit' ||
|
|
41
|
-
pull.headRefName.startsWith('automation/pnpm-audit-')));
|
|
42
|
-
}
|
|
43
|
-
/**
|
|
44
|
-
* Report only when the agent has not already communicated in this execution.
|
|
45
|
-
* @param env - Consumer repository, credentials and workflow run identity.
|
|
46
|
-
* @param diagnosis - Preserved mission response or execution failure details.
|
|
47
|
-
*/
|
|
48
|
-
export function ensureAuditDiagnostic(env, diagnosis) {
|
|
49
|
-
const pull = auditPull(env);
|
|
50
|
-
if (pull?.labels.some((label) => label.name === auditPauseLabel)) {
|
|
51
|
-
return;
|
|
52
|
-
}
|
|
53
|
-
const issues = pull
|
|
54
|
-
? []
|
|
55
|
-
: JSON.parse(github([
|
|
56
|
-
'issue',
|
|
57
|
-
'list',
|
|
58
|
-
'--state',
|
|
59
|
-
'open',
|
|
60
|
-
'--limit',
|
|
61
|
-
'100',
|
|
62
|
-
'--json',
|
|
63
|
-
'number,body',
|
|
64
|
-
], env));
|
|
65
|
-
const target = pull || issues.find((issue) => issue.body.includes(auditMarker));
|
|
66
|
-
const run = auditRunUrl(env);
|
|
67
|
-
const path = `repos/${repository(env)}/issues`;
|
|
68
|
-
if (target) {
|
|
69
|
-
const comments = github([
|
|
70
|
-
'api',
|
|
71
|
-
'--paginate',
|
|
72
|
-
`${path}/${target.number}/comments`,
|
|
73
|
-
'--jq',
|
|
74
|
-
'.[].body',
|
|
75
|
-
], env);
|
|
76
|
-
if (target.body.includes(run) || comments.includes(run)) {
|
|
77
|
-
return;
|
|
78
|
-
}
|
|
79
|
-
}
|
|
80
|
-
const body = `${auditMarker}\n\nAudit execution: ${run}\n\n${diagnosis}`;
|
|
81
|
-
github([
|
|
82
|
-
'api',
|
|
83
|
-
target ? `${path}/${target.number}/comments` : path,
|
|
84
|
-
'--method',
|
|
85
|
-
'POST',
|
|
86
|
-
'--input',
|
|
87
|
-
'-',
|
|
88
|
-
], env, target
|
|
89
|
-
? { body }
|
|
90
|
-
: { title: 'Dependency audit: developer diagnosis', body });
|
|
91
|
-
}
|
|
92
|
-
/**
|
|
93
|
-
* Link the exact attempt so the mission and fallback can avoid duplicate reports.
|
|
94
|
-
* @param env - GitHub Actions run identity.
|
|
95
|
-
* @returns Run URL, including the attempt when available.
|
|
96
|
-
* @throws If GitHub Actions did not supply its run ID.
|
|
97
|
-
*/
|
|
98
|
-
export function auditRunUrl(env) {
|
|
99
|
-
if (!env.GITHUB_RUN_ID) {
|
|
100
|
-
throw new Error('Missing GITHUB_RUN_ID');
|
|
101
|
-
}
|
|
102
|
-
return `${env.GITHUB_SERVER_URL || 'https://github.com'}/${repository(env)}/actions/runs/${env.GITHUB_RUN_ID}/attempts/${env.GITHUB_RUN_ATTEMPT || '1'}`;
|
|
103
|
-
}
|
|
104
|
-
function repository(env) {
|
|
105
|
-
const value = env.GITHUB_REPOSITORY;
|
|
106
|
-
if (!value || !/^[\w.-]+\/[\w.-]+$/.test(value)) {
|
|
107
|
-
throw new Error('Missing or invalid GITHUB_REPOSITORY');
|
|
108
|
-
}
|
|
109
|
-
return value;
|
|
110
|
-
}
|
|
111
|
-
//# sourceMappingURL=audit-github.js.map
|
package/src/audit-github.js.map
DELETED
|
@@ -1 +0,0 @@
|
|
|
1
|
-
{"version":3,"file":"audit-github.js","sourceRoot":"","sources":["../../../../apps/workflow-cli/src/audit-github.ts"],"names":[],"mappings":"AAAA,OAAO,EAAE,YAAY,EA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AM,CAAC,MAAM,WAAW,CAAC,CAAC,CAAC,IAAI;QACnD,UAAU;QACV,MAAM;QACN,SAAS;QACT,GAAG;KACJ,EACD,GAAG,EACH,MAAM;QACJ,CAAC,CAAC,EAAE,IAAI,EAAE;QACV,CAAC,CAAC,EAAE,KAAK,EAAE,uCAAuC,EAAE,IAAI,EAAE,CAC7D,CAAC;AACJ,CAAC;AAED;;;;;GAKG;AACH,MAAM,UAAU,WAAW,CAAC,GAAsB;IAChD,IAAI,CAAC,GAAG,CAAC,aAAa,EAAE,CAAC;QACvB,MAAM,IAAI,KAAK,CAAC,uBAAuB,CAAC,CAAC;IAC3C,CAAC;IACD,OAAO,GAAG,GAAG,CAAC,iBAAiB,IAAI,oBAAoB,IAAI,UAAU,CAAC,GAAG,CAAC,iBAAiB,GAAG,CAAC,aAAa,aAAa,GAAG,CAAC,kBAAkB,IAAI,GAAG,EAAE,CAAC;AAC3J,CAAC;AAED,SAAS,UAAU,CAAC,GAAsB;IACxC,MAAM,KAAK,GAAG,GAAG,CAAC,iBAAiB,CAAC;IACpC,IAAI,CAAC,KAAK,IAAI,CAAC,oBAAoB,CAAC,IAAI,CAAC,KAAK,CAAC,EAAE,CAAC;QAChD,MAAM,IAAI,KAAK,CAAC,sCAAsC,CAAC,CAAC;IAC1D,CAAC;IACD,OAAO,KAAK,CAAC;AACf,CAAC"}
|
package/src/audit-policy.d.ts
DELETED
|
@@ -1,16 +0,0 @@
|
|
|
1
|
-
type Json = Record<string, unknown>;
|
|
2
|
-
/**
|
|
3
|
-
* Validate an object-shaped external value.
|
|
4
|
-
* @param value - External value to validate.
|
|
5
|
-
* @returns The validated operation result.
|
|
6
|
-
* @throws If the input or external operation fails validation.
|
|
7
|
-
*/
|
|
8
|
-
export declare function record(value: unknown): Json;
|
|
9
|
-
/**
|
|
10
|
-
* Classify an audit result without confusing registry failures with vulnerabilities.
|
|
11
|
-
* @param code - Audit subprocess exit code.
|
|
12
|
-
* @param value - External value to validate.
|
|
13
|
-
* @returns The validated operation result.
|
|
14
|
-
*/
|
|
15
|
-
export declare function classifyAudit(code: number | null, value: unknown): 'clean' | 'vulnerable' | 'technical-error';
|
|
16
|
-
export {};
|
package/src/audit-policy.js
DELETED
|
@@ -1,46 +0,0 @@
|
|
|
1
|
-
/**
|
|
2
|
-
* Validate an object-shaped external value.
|
|
3
|
-
* @param value - External value to validate.
|
|
4
|
-
* @returns The validated operation result.
|
|
5
|
-
* @throws If the input or external operation fails validation.
|
|
6
|
-
*/
|
|
7
|
-
export function record(value) {
|
|
8
|
-
if (!value || typeof value !== 'object' || Array.isArray(value)) {
|
|
9
|
-
throw new Error('Expected an object');
|
|
10
|
-
}
|
|
11
|
-
return value;
|
|
12
|
-
}
|
|
13
|
-
/**
|
|
14
|
-
* Classify an audit result without confusing registry failures with vulnerabilities.
|
|
15
|
-
* @param code - Audit subprocess exit code.
|
|
16
|
-
* @param value - External value to validate.
|
|
17
|
-
* @returns The validated operation result.
|
|
18
|
-
*/
|
|
19
|
-
export function classifyAudit(code, value) {
|
|
20
|
-
try {
|
|
21
|
-
const report = record(value);
|
|
22
|
-
if (report['error']) {
|
|
23
|
-
return 'technical-error';
|
|
24
|
-
}
|
|
25
|
-
const advisories = record(report['advisories']);
|
|
26
|
-
const counts = record(record(report['metadata'])['vulnerabilities']);
|
|
27
|
-
const values = ['info', 'low', 'moderate', 'high', 'critical'].map((key) => counts[key]);
|
|
28
|
-
if (!values.every((value) => typeof value === 'number' && Number.isInteger(value) && value >= 0)) {
|
|
29
|
-
return 'technical-error';
|
|
30
|
-
}
|
|
31
|
-
const count = values.reduce((total, value) => total + Number(value), 0);
|
|
32
|
-
// pnpm 11 filters ignored GHSAs from advisories but retains their metadata counts.
|
|
33
|
-
const actionable = Object.keys(advisories).length;
|
|
34
|
-
if (code === 0 && actionable === 0) {
|
|
35
|
-
return 'clean';
|
|
36
|
-
}
|
|
37
|
-
if (code !== null && code > 0 && count > 0 && actionable > 0) {
|
|
38
|
-
return 'vulnerable';
|
|
39
|
-
}
|
|
40
|
-
return 'technical-error';
|
|
41
|
-
}
|
|
42
|
-
catch {
|
|
43
|
-
return 'technical-error';
|
|
44
|
-
}
|
|
45
|
-
}
|
|
46
|
-
//# sourceMappingURL=audit-policy.js.map
|
package/src/audit-policy.js.map
DELETED
|
@@ -1 +0,0 @@
|
|
|
1
|
-
{"version":3,"file":"audit-policy.js","sourceRoot":"","sources":["../../../../apps/workflow-cli/src/audit-policy.ts"],"names":[],"mappings":"AACA;;;;;GAKG;AACH,MAAM,UAAU,MAAM,CAAC,KAAc;IACnC,IAAI,CAAC,KAAK,IAAI,OAAO,KAAK,KAAK,QAAQ,IAAI,KAAK,CAAC,OAAO,CAAC,KAAK,CAAC,EAAE,CAAC;QAChE,MAAM,IAAI,KAAK,CAAC,oBAAoB,CAAC,CAAC;IACxC,CAAC;IACD,OAAO,KAAa,CAAC;AACvB,CAAC;AACD;;;;;GAKG;AACH,MAAM,UAAU,aAAa,CAC3B,IAAmB,EACnB,KAAc;IAEd,IAAI,CAAC;QACH,MAAM,MAAM,GAAG,MAAM,CAAC,KAAK,CAAC,CAAC;QAC7B,IAAI,MAAM,CAAC,OAAO,CAAC,EAAE,CAAC;YACpB,OAAO,iBAAiB,CAAC;QAC3B,CAAC;QACD,MAAM,UAAU,GAAG,MAAM,CAAC,MAAM,CAAC,YAAY,CAAC,CAAC,CAAC;QAChD,MAAM,MAAM,GAAG,MAAM,CAAC,MAAM,CAAC,MAAM,CAAC,UAAU,CAAC,CAAC,CAAC,iBAAiB,CAAC,CAAC,CAAC;QACrE,MAAM,MAAM,GAAG,CAAC,MAAM,EAAE,KAAK,EAAE,UAAU,EAAE,MAAM,EAAE,UAAU,CAAC,CAAC,GAAG,CAChE,CAAC,GAAG,EAAE,EAAE,CAAC,MAAM,CAAC,GAAG,CAAC,CACrB,CAAC;QACF,IACE,CAAC,MAAM,CAAC,KAAK,CACX,CAAC,KAAK,EAAE,EAAE,CACR,OAAO,KAAK,KAAK,QAAQ,IAAI,MAAM,CAAC,SAAS,CAAC,KAAK,CAAC,IAAI,KAAK,IAAI,CAAC,CACrE,EACD,CAAC;YACD,OAAO,iBAAiB,CAAC;QAC3B,CAAC;QACD,MAAM,KAAK,GAAG,MAAM,CAAC,MAAM,CACzB,CAAC,KAAK,EAAE,KAAK,EAAE,EAAE,CAAC,KAAK,GAAG,MAAM,CAAC,KAAK,CAAC,EACvC,CAAC,CACF,CAAC;QACF,mFAAmF;QACnF,MAAM,UAAU,GAAG,MAAM,CAAC,IAAI,CAAC,UAAU,CAAC,CAAC,MAAM,CAAC;QAClD,IAAI,IAAI,KAAK,CAAC,IAAI,UAAU,KAAK,CAAC,EAAE,CAAC;YACnC,OAAO,OAAO,CAAC;QACjB,CAAC;QACD,IAAI,IAAI,KAAK,IAAI,IAAI,IAAI,GAAG,CAAC,IAAI,KAAK,GAAG,CAAC,IAAI,UAAU,GAAG,CAAC,EAAE,CAAC;YAC7D,OAAO,YAAY,CAAC;QACtB,CAAC;QACD,OAAO,iBAAiB,CAAC;IAC3B,CAAC;IAAC,MAAM,CAAC;QACP,OAAO,iBAAiB,CAAC;IAC3B,CAAC;AACH,CAAC"}
|
package/src/audit-prompt.d.ts
DELETED
|
@@ -1,2 +0,0 @@
|
|
|
1
|
-
/** Dependency remediation, collaboration and publication are owned by the agent. */
|
|
2
|
-
export declare const auditPrompt = "You own this repository's dependency-audit PR and developer communication.\nRead AGENTS.md and relevant domain contexts first. Use pnpm only.\nUse gh and Git normally; GitHub access is configured. Never print credentials.\nRead the supplied audit report. A technical audit error is not evidence of a\nvulnerability: investigate it and report a diagnosis rather than invent a fix.\nFind the existing open audit PR (including older automation/pnpm-audit-* branches)\nand read its description, comments, checks and latest commits. Honor the pause\nlabel. Otherwise check out its current branch and preserve human contributions.\nIf there is no existing PR, create automation/pnpm-audit from the current default\nbranch. Configure Git identity from the authenticated GitHub account when needed\nand use gh auth setup-git to authenticate pushes. Never force-push, rewrite history,\nreset away human work, reopen closed PRs, merge or close a PR automatically.\nInstall repository dependencies before working. Progress from the smallest\nsufficient patch/update through minor upgrades, majors or package replacement.\nNew packages and source/configuration/test migrations are allowed when necessary.\nKeep changes focused. Never raise audit thresholds, disable CI, remove tests or\nweaken assertions. Preserve repository contracts.\nOn EVERY attempt, review ALL existing audit exceptions, including manual entries,\nlegacy settings and exceptions on the existing PR. Inspect the effective pnpm\nconfiguration after checking out that PR; the supplied snapshot is only a starting\npoint. Never silently activate legacy settings ignored by this pnpm version.\nVerify each ignored advisory against current registry releases and its upstream\nsecurity advisory. Check the installed dependency paths with exceptions temporarily\nremoved in an isolated copy/configuration so a green filtered audit is not proof\nof a fix. Report each exception as removed, retained with evidence, or unverified.\nWhen a corrected version is published, attempt the update/migration and remove the\nexception in the SAME change once the fix is verified. Remove obsolete exceptions\nwhen an unfiltered check proves the affected dependency is no longer present.\nIf migration or verification is incomplete, retain an existing exception with an\nexplicit diagnosis. Do not silently skip exceptions when the budget expires.\nA NEW exception is allowed ONLY after confirming that NO published version fixes\nthat advisory. Verify both the registry releases and the upstream advisory; cite\nversions and sources. A breaking major, failed checks, exhausted budget, missing\nnetwork access or uncertainty does NOT justify a new exception. Prefer actual\nfixes first; do not add a permanent fork solely to make the audit green.\nAdd only the exact GHSA to pnpm's supported ignore list, following the repository's\nexisting configuration. Keep a short reason and source link beside the entry.\nDo not ignore an entire package, severity level, registry failure or all unfixable\nadvisories. Reuse that configuration as the sole durable exception inventory;\ndo not introduce a second tracking file. Put the detailed evidence and current\nreview in the PR/comment or existing diagnostic issue. Do not create commits just\nto refresh review dates when the exception and evidence are otherwise unchanged.\nLook for related Renovate PRs and link useful ones; their existence does not block\nyour work. Use judgment rather than a title-matching rule.\nRun focused checks useful for your changes, including pnpm audit. The ordinary PR\nCI owns complete validation; do not duplicate the full CI or wait for it to finish.\nCommit and push useful changes even if the correction is incomplete or checks fail.\nCreate a regular non-draft PR, or update the existing one. Its body must retain the\nsupplied audit marker and explain the changes, broader migrations and limitations.\nOn every attempt, publish context and check results as a PR comment including the\nexact execution URL, even if you made no new commit. Read previous feedback before\nretrying. If the audit is green on the PR, still review all exceptions before reporting no further work.\nIf there is no useful change and no PR, create or update one open diagnostic issue\nidentified by the audit marker. Include the execution URL and actionable findings.\nIf a useful unpublished change remains near the deadline, prioritize committing,\npushing and opening/updating its PR over further investigation. A timeout does not\nmake the patch invalid. Finish with a response summarizing changes, checks,\nremaining findings and the PR or issue URL. Never merge automatically.\n";
|
package/src/audit-prompt.js
DELETED
|
@@ -1,61 +0,0 @@
|
|
|
1
|
-
/** Dependency remediation, collaboration and publication are owned by the agent. */
|
|
2
|
-
export const auditPrompt = `You own this repository's dependency-audit PR and developer communication.
|
|
3
|
-
Read AGENTS.md and relevant domain contexts first. Use pnpm only.
|
|
4
|
-
Use gh and Git normally; GitHub access is configured. Never print credentials.
|
|
5
|
-
Read the supplied audit report. A technical audit error is not evidence of a
|
|
6
|
-
vulnerability: investigate it and report a diagnosis rather than invent a fix.
|
|
7
|
-
Find the existing open audit PR (including older automation/pnpm-audit-* branches)
|
|
8
|
-
and read its description, comments, checks and latest commits. Honor the pause
|
|
9
|
-
label. Otherwise check out its current branch and preserve human contributions.
|
|
10
|
-
If there is no existing PR, create automation/pnpm-audit from the current default
|
|
11
|
-
branch. Configure Git identity from the authenticated GitHub account when needed
|
|
12
|
-
and use gh auth setup-git to authenticate pushes. Never force-push, rewrite history,
|
|
13
|
-
reset away human work, reopen closed PRs, merge or close a PR automatically.
|
|
14
|
-
Install repository dependencies before working. Progress from the smallest
|
|
15
|
-
sufficient patch/update through minor upgrades, majors or package replacement.
|
|
16
|
-
New packages and source/configuration/test migrations are allowed when necessary.
|
|
17
|
-
Keep changes focused. Never raise audit thresholds, disable CI, remove tests or
|
|
18
|
-
weaken assertions. Preserve repository contracts.
|
|
19
|
-
On EVERY attempt, review ALL existing audit exceptions, including manual entries,
|
|
20
|
-
legacy settings and exceptions on the existing PR. Inspect the effective pnpm
|
|
21
|
-
configuration after checking out that PR; the supplied snapshot is only a starting
|
|
22
|
-
point. Never silently activate legacy settings ignored by this pnpm version.
|
|
23
|
-
Verify each ignored advisory against current registry releases and its upstream
|
|
24
|
-
security advisory. Check the installed dependency paths with exceptions temporarily
|
|
25
|
-
removed in an isolated copy/configuration so a green filtered audit is not proof
|
|
26
|
-
of a fix. Report each exception as removed, retained with evidence, or unverified.
|
|
27
|
-
When a corrected version is published, attempt the update/migration and remove the
|
|
28
|
-
exception in the SAME change once the fix is verified. Remove obsolete exceptions
|
|
29
|
-
when an unfiltered check proves the affected dependency is no longer present.
|
|
30
|
-
If migration or verification is incomplete, retain an existing exception with an
|
|
31
|
-
explicit diagnosis. Do not silently skip exceptions when the budget expires.
|
|
32
|
-
A NEW exception is allowed ONLY after confirming that NO published version fixes
|
|
33
|
-
that advisory. Verify both the registry releases and the upstream advisory; cite
|
|
34
|
-
versions and sources. A breaking major, failed checks, exhausted budget, missing
|
|
35
|
-
network access or uncertainty does NOT justify a new exception. Prefer actual
|
|
36
|
-
fixes first; do not add a permanent fork solely to make the audit green.
|
|
37
|
-
Add only the exact GHSA to pnpm's supported ignore list, following the repository's
|
|
38
|
-
existing configuration. Keep a short reason and source link beside the entry.
|
|
39
|
-
Do not ignore an entire package, severity level, registry failure or all unfixable
|
|
40
|
-
advisories. Reuse that configuration as the sole durable exception inventory;
|
|
41
|
-
do not introduce a second tracking file. Put the detailed evidence and current
|
|
42
|
-
review in the PR/comment or existing diagnostic issue. Do not create commits just
|
|
43
|
-
to refresh review dates when the exception and evidence are otherwise unchanged.
|
|
44
|
-
Look for related Renovate PRs and link useful ones; their existence does not block
|
|
45
|
-
your work. Use judgment rather than a title-matching rule.
|
|
46
|
-
Run focused checks useful for your changes, including pnpm audit. The ordinary PR
|
|
47
|
-
CI owns complete validation; do not duplicate the full CI or wait for it to finish.
|
|
48
|
-
Commit and push useful changes even if the correction is incomplete or checks fail.
|
|
49
|
-
Create a regular non-draft PR, or update the existing one. Its body must retain the
|
|
50
|
-
supplied audit marker and explain the changes, broader migrations and limitations.
|
|
51
|
-
On every attempt, publish context and check results as a PR comment including the
|
|
52
|
-
exact execution URL, even if you made no new commit. Read previous feedback before
|
|
53
|
-
retrying. If the audit is green on the PR, still review all exceptions before reporting no further work.
|
|
54
|
-
If there is no useful change and no PR, create or update one open diagnostic issue
|
|
55
|
-
identified by the audit marker. Include the execution URL and actionable findings.
|
|
56
|
-
If a useful unpublished change remains near the deadline, prioritize committing,
|
|
57
|
-
pushing and opening/updating its PR over further investigation. A timeout does not
|
|
58
|
-
make the patch invalid. Finish with a response summarizing changes, checks,
|
|
59
|
-
remaining findings and the PR or issue URL. Never merge automatically.
|
|
60
|
-
`;
|
|
61
|
-
//# sourceMappingURL=audit-prompt.js.map
|
package/src/audit-prompt.js.map
DELETED
|
@@ -1 +0,0 @@
|
|
|
1
|
-
{"version":3,"file":"audit-prompt.js","sourceRoot":"","sources":["../../../../apps/workflow-cli/src/audit-prompt.ts"],"names":[],"mappings":"AAAA,oFAAoF;AACpF,MAAM,CAAC,MAAM,WAAW,GAAG;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;CA0D1B,CAAC"}
|
package/src/audit.d.ts
DELETED
|
@@ -1,21 +0,0 @@
|
|
|
1
|
-
/**
|
|
2
|
-
* Execute the same unfiltered dependency audit as ordinary CI.
|
|
3
|
-
* @returns The report and whether pnpm found actionable vulnerabilities.
|
|
4
|
-
* @throws If the registry or audit command fails technically.
|
|
5
|
-
*/
|
|
6
|
-
export declare function audit(): {
|
|
7
|
-
status: 'clean' | 'vulnerable';
|
|
8
|
-
report: unknown;
|
|
9
|
-
};
|
|
10
|
-
/**
|
|
11
|
-
* Snapshot only audit exceptions, without collecting registry credentials.
|
|
12
|
-
* @param cwd - Consumer workspace whose effective pnpm settings are inspected.
|
|
13
|
-
* @returns Effective exception settings and legacy manifest entries for agent review.
|
|
14
|
-
*/
|
|
15
|
-
export declare function auditExceptions(cwd?: string): Record<string, unknown>;
|
|
16
|
-
/**
|
|
17
|
-
* Prepare one prompt-driven mission, or ensure its developer-facing diagnosis.
|
|
18
|
-
* @param phase - Prepare or report.
|
|
19
|
-
* @param env - Workflow environment and optional mission overrides.
|
|
20
|
-
*/
|
|
21
|
-
export declare function runAuditCommand(phase: string, env: NodeJS.ProcessEnv): Promise<void>;
|
package/src/audit.js
DELETED
|
@@ -1,146 +0,0 @@
|
|
|
1
|
-
import { execFileSync, spawnSync } from 'node:child_process';
|
|
2
|
-
import { appendFileSync, existsSync, mkdirSync, readFileSync, writeFileSync, } from 'node:fs';
|
|
3
|
-
import { join, resolve } from 'node:path';
|
|
4
|
-
import { executable } from './executable.js';
|
|
5
|
-
import { classifyAudit, record } from './audit-policy.js';
|
|
6
|
-
import { auditPrompt } from './audit-prompt.js';
|
|
7
|
-
import { auditMarker, auditPauseLabel, auditPull, auditRunUrl, ensureAuditDiagnostic, } from './audit-github.js';
|
|
8
|
-
/**
|
|
9
|
-
* Execute the same unfiltered dependency audit as ordinary CI.
|
|
10
|
-
* @returns The report and whether pnpm found actionable vulnerabilities.
|
|
11
|
-
* @throws If the registry or audit command fails technically.
|
|
12
|
-
*/
|
|
13
|
-
export function audit() {
|
|
14
|
-
const result = spawnSync(executable('pnpm'), ['audit', '--json'], {
|
|
15
|
-
encoding: 'utf8',
|
|
16
|
-
maxBuffer: 32 * 1024 * 1024,
|
|
17
|
-
});
|
|
18
|
-
let report;
|
|
19
|
-
try {
|
|
20
|
-
report = JSON.parse(result.stdout);
|
|
21
|
-
}
|
|
22
|
-
catch {
|
|
23
|
-
throw new Error('Audit returned no valid JSON; registry/network failure');
|
|
24
|
-
}
|
|
25
|
-
const status = classifyAudit(result.status, report);
|
|
26
|
-
if (status === 'technical-error') {
|
|
27
|
-
throw new Error('Audit failed technically');
|
|
28
|
-
}
|
|
29
|
-
return { status, report };
|
|
30
|
-
}
|
|
31
|
-
/**
|
|
32
|
-
* Snapshot only audit exceptions, without collecting registry credentials.
|
|
33
|
-
* @param cwd - Consumer workspace whose effective pnpm settings are inspected.
|
|
34
|
-
* @returns Effective exception settings and legacy manifest entries for agent review.
|
|
35
|
-
*/
|
|
36
|
-
export function auditExceptions(cwd = process.cwd()) {
|
|
37
|
-
const exceptions = {};
|
|
38
|
-
for (const key of ['auditConfig', 'audit']) {
|
|
39
|
-
const text = execFileSync(executable('pnpm'), ['config', 'get', key, '--json'], {
|
|
40
|
-
cwd,
|
|
41
|
-
encoding: 'utf8',
|
|
42
|
-
maxBuffer: 1024 * 1024,
|
|
43
|
-
stdio: ['ignore', 'pipe', 'pipe'],
|
|
44
|
-
}).trim();
|
|
45
|
-
const config = text && text !== 'undefined' ? JSON.parse(text) : {};
|
|
46
|
-
collectExceptions(exceptions, `Effective pnpm ${key}`, config);
|
|
47
|
-
}
|
|
48
|
-
const path = join(cwd, 'package.json');
|
|
49
|
-
if (existsSync(path)) {
|
|
50
|
-
const manifest = record(JSON.parse(readFileSync(path, 'utf8')));
|
|
51
|
-
const legacy = record(manifest['pnpm'] || {})['auditConfig'];
|
|
52
|
-
collectExceptions(exceptions, 'package.json pnpm.auditConfig (legacy; may be inactive)', legacy);
|
|
53
|
-
}
|
|
54
|
-
return exceptions;
|
|
55
|
-
}
|
|
56
|
-
function collectExceptions(exceptions, source, config) {
|
|
57
|
-
const entries = Object.entries(record(config || {})).filter(([key, value]) => key.startsWith('ignore') &&
|
|
58
|
-
(Array.isArray(value) ? value.length > 0 : Boolean(value)));
|
|
59
|
-
if (entries.length) {
|
|
60
|
-
exceptions[source] = Object.fromEntries(entries);
|
|
61
|
-
}
|
|
62
|
-
}
|
|
63
|
-
/**
|
|
64
|
-
* Prepare one prompt-driven mission, or ensure its developer-facing diagnosis.
|
|
65
|
-
* @param phase - Prepare or report.
|
|
66
|
-
* @param env - Workflow environment and optional mission overrides.
|
|
67
|
-
*/
|
|
68
|
-
export async function runAuditCommand(phase, env) {
|
|
69
|
-
if (!['prepare', 'report'].includes(phase)) {
|
|
70
|
-
throw new Error(`Unsupported audit phase: ${phase}`);
|
|
71
|
-
}
|
|
72
|
-
if (!env.AUDIT_DIRECTORY) {
|
|
73
|
-
throw new Error('Missing AUDIT_DIRECTORY');
|
|
74
|
-
}
|
|
75
|
-
const directory = resolve(env.AUDIT_DIRECTORY);
|
|
76
|
-
mkdirSync(directory, { recursive: true });
|
|
77
|
-
if (phase === 'report') {
|
|
78
|
-
reportMission(directory, env);
|
|
79
|
-
return;
|
|
80
|
-
}
|
|
81
|
-
const pull = auditPull(env);
|
|
82
|
-
if (pull?.labels.some((label) => label.name === auditPauseLabel)) {
|
|
83
|
-
output(env, 'status', 'paused');
|
|
84
|
-
return;
|
|
85
|
-
}
|
|
86
|
-
let status;
|
|
87
|
-
let exceptions = {};
|
|
88
|
-
try {
|
|
89
|
-
exceptions = auditExceptions();
|
|
90
|
-
const result = audit();
|
|
91
|
-
status = result.status;
|
|
92
|
-
writeFileSync(join(directory, 'audit.json'), JSON.stringify(result.report, null, 2));
|
|
93
|
-
}
|
|
94
|
-
catch (error) {
|
|
95
|
-
status = 'technical-error';
|
|
96
|
-
writeFileSync(join(directory, 'audit.json'), JSON.stringify({ error: String(error) }));
|
|
97
|
-
}
|
|
98
|
-
const review = status === 'clean' && (Object.keys(exceptions).length > 0 || Boolean(pull));
|
|
99
|
-
output(env, 'status', review ? 'review' : status);
|
|
100
|
-
const context = `\n\nExecution context (applies also to a custom prompt):
|
|
101
|
-
Repository: ${env.GITHUB_REPOSITORY}
|
|
102
|
-
Default branch: ${env.DEFAULT_BRANCH}
|
|
103
|
-
Mission budget: ${env.CODEX_TIMEOUT_MINUTES || 20} minutes
|
|
104
|
-
Initial audit: ${status}
|
|
105
|
-
Audit report: ${join(directory, 'audit.json')}
|
|
106
|
-
Audit exceptions to investigate (read-only snapshot, not a second registry):
|
|
107
|
-
${JSON.stringify(exceptions, null, 2)}
|
|
108
|
-
Execution URL: ${auditRunUrl(env)}
|
|
109
|
-
Audit marker for PR/diagnostic bodies: ${auditMarker}
|
|
110
|
-
Pause label: ${auditPauseLabel}
|
|
111
|
-
Existing audit PR: ${pull ? '#' + pull.number + ' (' + pull.headRefName + ')' : 'none found'}
|
|
112
|
-
`;
|
|
113
|
-
writeFileSync(join(directory, 'prompt.md'), (env.AUDIT_PROMPT || auditPrompt) + context);
|
|
114
|
-
}
|
|
115
|
-
function output(env, key, value) {
|
|
116
|
-
if (env.GITHUB_OUTPUT) {
|
|
117
|
-
appendFileSync(env.GITHUB_OUTPUT, `${key}=${value}\n`);
|
|
118
|
-
}
|
|
119
|
-
}
|
|
120
|
-
function reportMission(directory, env) {
|
|
121
|
-
const response = env.CODEX_RESPONSE_FILE;
|
|
122
|
-
const text = response && existsSync(response)
|
|
123
|
-
? readFileSync(response, 'utf8').trim()
|
|
124
|
-
: '';
|
|
125
|
-
const diagnosis = text ||
|
|
126
|
-
`Codex status: ${env.CODEX_STATUS || 'execution-error'}. Inspect this run's logs and artifacts. No final response was produced.`;
|
|
127
|
-
writeFileSync(join(directory, 'diagnosis.md'), diagnosis);
|
|
128
|
-
if (env.GITHUB_STEP_SUMMARY) {
|
|
129
|
-
appendFileSync(env.GITHUB_STEP_SUMMARY, `${diagnosis}\n`);
|
|
130
|
-
}
|
|
131
|
-
// Preserve unpublished edits after a timeout without adding another publisher.
|
|
132
|
-
try {
|
|
133
|
-
execFileSync(executable('git'), ['add', '--intent-to-add', '.'], {
|
|
134
|
-
stdio: 'pipe',
|
|
135
|
-
});
|
|
136
|
-
const patch = execFileSync(executable('git'), ['diff', '--binary', 'HEAD'], { encoding: 'utf8', maxBuffer: 32 * 1024 * 1024 });
|
|
137
|
-
if (patch) {
|
|
138
|
-
writeFileSync(join(directory, 'unpublished.patch'), patch);
|
|
139
|
-
}
|
|
140
|
-
}
|
|
141
|
-
catch {
|
|
142
|
-
// A failed checkout/setup still needs its GitHub diagnosis.
|
|
143
|
-
}
|
|
144
|
-
ensureAuditDiagnostic(env, diagnosis.slice(0, 12000));
|
|
145
|
-
}
|
|
146
|
-
//# sourceMappingURL=audit.js.map
|
package/src/audit.js.map
DELETED
|
@@ -1 +0,0 @@
|
|
|
1
|
-
{"version":3,"file":"audit.js","sourceRoot":"","sources":["../../../../apps/workflow-cli/src/audit.ts"],"names":[],"mappings":"AAAA,OAAO,EAAE,YAAY,EAAE,SAAS,EAAE,MAAM,oBAAoB,CAAC;AAC7D,OAAO,EACL,cAAc,EACd,UAAU,EACV,SAAS,EACT,YAAY,EACZ,aAAa,GACd,MAAM,SAAS,CAAC;AACjB,OAAO,EAAE,IAAI,EAAE,OAAO,EAAE,MAAM,WAAW,CAAC;AAC1C,OAAO,EAAE,UAAU,EAAE,MAAM,iBAAiB,CAAC;AAC7C,OAAO,EAAE,aAAa,EAAE,MAAM,EAAE,MAAM,mBAAmB,CAAC;AAC1D,OAAO,EAAE,WAAW,EAAE,MAAM,mBAAmB,CAAC;AAChD,OAAO,EACL,WAAW,EACX,eAAe,EACf,SAAS,EACT,WAAW,EACX,qBAAqB,GACtB,MAAM,mBAAmB,CAAC;AAE3B;;;;GAIG;AACH,MAAM,UAAU,KAAK;IACnB,MAAM,MAAM,GAAG,SAAS,CAAC,UAAU,CAAC,MAAM,CAAC,EAAE,CAAC,OAAO,EAAE,QAAQ,CAAC,EAAE;QAChE,QAAQ,EAAE,MAAM;QAChB,SAAS,EAAE,EAAE,GAAG,IAAI,GAAG,IAAI;KAC5B,CAAC,CAAC;IACH,IAAI,MAAe,CAAC;IACpB,IAAI,CAAC;QACH,MAAM,GAAG,IAAI,CAAC,KAAK,CAAC,MAAM,CAAC,MAAM,CAAC,CAAC;IACrC,CAAC;IAAC,MAAM,CAAC;QACP,MAAM,IAAI,KAAK,CAAC,wDAAwD,CAAC,CAAC;IAC5E,CAAC;IACD,MAAM,MAAM,GAAG,aAAa,CAAC,MAAM,CAAC,MAAM,EAAE,MAAM,CAAC,CAAC;IACpD,IAAI,MAAM,KAAK,iBAAiB,EAAE,CAAC;QACjC,MAAM,IAAI,KAAK,CAAC,0BAA0B,CAAC,CAAC;IAC9C,CAAC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K,EAAE,iBAAiB,EAAE,GAAG,CAAC,EAAE;YAC/D,KAAK,EAAE,MAAM;SACd,CAAC,CAAC;QACH,MAAM,KAAK,GAAG,YAAY,CACxB,UAAU,CAAC,KAAK,CAAC,EACjB,CAAC,MAAM,EAAE,UAAU,EAAE,MAAM,CAAC,EAC5B,EAAE,QAAQ,EAAE,MAAM,EAAE,SAAS,EAAE,EAAE,GAAG,IAAI,GAAG,IAAI,EAAE,CAClD,CAAC;QACF,IAAI,KAAK,EAAE,CAAC;YACV,aAAa,CAAC,IAAI,CAAC,SAAS,EAAE,mBAAmB,CAAC,EAAE,KAAK,CAAC,CAAC;QAC7D,CAAC;IACH,CAAC;IAAC,MAAM,CAAC;QACP,4DAA4D;IAC9D,CAAC;IACD,qBAAqB,CAAC,GAAG,EAAE,SAAS,CAAC,KAAK,CAAC,CAAC,EAAE,KAAK,CAAC,CAAC,CAAC;AACxD,CAAC"}
|
package/src/automation.d.ts
DELETED
|
@@ -1,7 +0,0 @@
|
|
|
1
|
-
/**
|
|
2
|
-
* Execute automation operations which do not require Nx release selection.
|
|
3
|
-
* @param argv - CLI operation and positional arguments.
|
|
4
|
-
* @param env - Workflow environment inputs.
|
|
5
|
-
* @returns Whether the automation operation was recognized.
|
|
6
|
-
*/
|
|
7
|
-
export declare function runAutomation(argv: string[], env: NodeJS.ProcessEnv): Promise<boolean>;
|
package/src/automation.js
DELETED
|
@@ -1,37 +0,0 @@
|
|
|
1
|
-
import { executeCodex } from './codex.js';
|
|
2
|
-
import { runAuditCommand } from './audit.js';
|
|
3
|
-
/**
|
|
4
|
-
* Execute automation operations which do not require Nx release selection.
|
|
5
|
-
* @param argv - CLI operation and positional arguments.
|
|
6
|
-
* @param env - Workflow environment inputs.
|
|
7
|
-
* @returns Whether the automation operation was recognized.
|
|
8
|
-
*/
|
|
9
|
-
export async function runAutomation(argv, env) {
|
|
10
|
-
if (argv[0] === 'codex-pool') {
|
|
11
|
-
if (argv.length !== 2 || argv[1] !== 'validate') {
|
|
12
|
-
throw new Error('Expected codex-pool validate');
|
|
13
|
-
}
|
|
14
|
-
const { validateCodexPool } = await import('./codex-pool.js');
|
|
15
|
-
validateCodexPool();
|
|
16
|
-
return true;
|
|
17
|
-
}
|
|
18
|
-
if (argv[0] === 'codex') {
|
|
19
|
-
if (argv.length !== 1) {
|
|
20
|
-
throw new Error('codex uses CODEX_* environment inputs and accepts no positional flags');
|
|
21
|
-
}
|
|
22
|
-
await executeCodex(env);
|
|
23
|
-
return true;
|
|
24
|
-
}
|
|
25
|
-
if (argv[0] === 'audit') {
|
|
26
|
-
await auditOperation(argv, env);
|
|
27
|
-
return true;
|
|
28
|
-
}
|
|
29
|
-
return false;
|
|
30
|
-
}
|
|
31
|
-
async function auditOperation(argv, env) {
|
|
32
|
-
if (argv.length !== 2) {
|
|
33
|
-
throw new Error('Expected audit prepare or report');
|
|
34
|
-
}
|
|
35
|
-
await runAuditCommand(argv[1], env);
|
|
36
|
-
}
|
|
37
|
-
//# sourceMappingURL=automation.js.map
|
package/src/automation.js.map
DELETED
|
@@ -1 +0,0 @@
|
|
|
1
|
-
{"version":3,"file":"automation.js","sourceRoot":"","sources":["../../../../apps/workflow-cli/src/automation.ts"],"names":[],"mappings":"AAAA,OAAO,EAAE,YAAY,EAAE,MAAM,YAAY,CAAC;AAC1C,OAAO,EAAE,eAAe,EAAE,MAAM,YAAY,CAAC;AAE7C;;;;;GAKG;AACH,MAAM,CAAC,KAAK,UAAU,aAAa,CACjC,IAAc,EACd,GAAsB;IAEtB,IAAI,IAAI,CAAC,CAAC,CAAC,KAAK,YAAY,EAAE,CAAC;QAC7B,IAAI,IAAI,CAAC,MAAM,KAAK,CAAC,IAAI,IAAI,CAAC,CAAC,CAAC,KAAK,UAAU,EAAE,CAAC;YAChD,MAAM,IAAI,KAAK,CAAC,8BAA8B,CAAC,CAAC;QAClD,CAAC;QACD,MAAM,EAAE,iBAAiB,EAAE,GAAG,MAAM,MAAM,CAAC,iBAAiB,CAAC,CAAC;QAC9D,iBAAiB,EAAE,CAAC;QACpB,OAAO,IAAI,CAAC;IACd,CAAC;IACD,IAAI,IAAI,CAAC,CAAC,CAAC,KAAK,OAAO,EAAE,CAAC;QACxB,IAAI,IAAI,CAAC,MAAM,KAAK,CAAC,EAAE,CAAC;YACtB,MAAM,IAAI,KAAK,CACb,uEAAuE,CACxE,CAAC;QACJ,CAAC;QACD,MAAM,YAAY,CAAC,GAAG,CAAC,CAAC;QACxB,OAAO,IAAI,CAAC;IACd,CAAC;IACD,IAAI,IAAI,CAAC,CAAC,CAAC,KAAK,OAAO,EAAE,CAAC;QACxB,MAAM,cAAc,CAAC,IAAI,EAAE,GAAG,CAAC,CAAC;QAChC,OAAO,IAAI,CAAC;IACd,CAAC;IACD,OAAO,KAAK,CAAC;AACf,CAAC;AAED,KAAK,UAAU,cAAc,CAC3B,IAAc,EACd,GAAsB;IAEtB,IAAI,IAAI,CAAC,MAAM,KAAK,CAAC,EAAE,CAAC;QACtB,MAAM,IAAI,KAAK,CAAC,kCAAkC,CAAC,CAAC;IACtD,CAAC;IACD,MAAM,eAAe,CAAC,IAAI,CAAC,CAAC,CAAC,EAAE,GAAG,CAAC,CAAC;AACtC,CAAC"}
|
package/src/codex-pool.d.ts
DELETED
package/src/codex-pool.js
DELETED
|
@@ -1,48 +0,0 @@
|
|
|
1
|
-
import { executable } from './executable.js';
|
|
2
|
-
import { execFileSync } from 'node:child_process';
|
|
3
|
-
import { readFileSync } from 'node:fs';
|
|
4
|
-
import { join } from 'node:path';
|
|
5
|
-
import { parse } from 'yaml';
|
|
6
|
-
import { record } from './audit-policy.js';
|
|
7
|
-
/**
|
|
8
|
-
* Validate the ARC configuration and render its Kubernetes resources.
|
|
9
|
-
* @throws If the pool configuration or rendered manifests are invalid.
|
|
10
|
-
*/
|
|
11
|
-
export function validateCodexPool() {
|
|
12
|
-
const root = 'gitops/infrastructure/operators/gha-codex-runner-scale-set';
|
|
13
|
-
const path = join(root, 'values.yaml');
|
|
14
|
-
const values = record(parse(readFileSync(path, 'utf8')));
|
|
15
|
-
if (values['minRunners'] !== 0 ||
|
|
16
|
-
values['maxRunners'] !== 1 ||
|
|
17
|
-
values['runnerGroup'] !== 'codex') {
|
|
18
|
-
throw new Error('Codex pool must be restricted and serialized');
|
|
19
|
-
}
|
|
20
|
-
const application = record(parse(readFileSync(join(root, 'application.yaml'), 'utf8')));
|
|
21
|
-
const spec = record(application['spec']);
|
|
22
|
-
const sources = spec['sources'];
|
|
23
|
-
if (!Array.isArray(sources)) {
|
|
24
|
-
throw new Error('Missing Helm application sources');
|
|
25
|
-
}
|
|
26
|
-
const source = sources.map(record).find((entry) => entry['chart']);
|
|
27
|
-
if (!source) {
|
|
28
|
-
throw new Error('Missing Helm chart source');
|
|
29
|
-
}
|
|
30
|
-
const destination = record(spec['destination']);
|
|
31
|
-
const rendered = execFileSync(executable('helm'), [
|
|
32
|
-
'template',
|
|
33
|
-
String(record(application['metadata'])['name']),
|
|
34
|
-
`oci://${source['repoURL']}/${source['chart']}`,
|
|
35
|
-
'--version',
|
|
36
|
-
String(source['targetRevision']),
|
|
37
|
-
'--namespace',
|
|
38
|
-
String(destination['namespace']),
|
|
39
|
-
'--values',
|
|
40
|
-
path,
|
|
41
|
-
], { encoding: 'utf8', maxBuffer: 8 * 1024 * 1024 });
|
|
42
|
-
execFileSync(executable('kubeconform'), ['-strict', '-ignore-missing-schemas'], {
|
|
43
|
-
input: rendered,
|
|
44
|
-
stdio: ['pipe', 'inherit', 'inherit'],
|
|
45
|
-
});
|
|
46
|
-
execFileSync(executable('kubeconform'), ['-strict', join(root, 'resources/auth-pvc.yaml')], { stdio: 'inherit' });
|
|
47
|
-
}
|
|
48
|
-
//# sourceMappingURL=codex-pool.js.map
|
package/src/codex-pool.js.map
DELETED
|
@@ -1 +0,0 @@
|
|
|
1
|
-
{"version":3,"file":"codex-pool.js","sourceRoot":"","sources":["../../../../apps/workflow-cli/src/codex-pool.ts"],"names":[],"mappings":"AAAA,OAAO,EAAE,UAAU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AK,CAAC,OAAO,CAAC,CAAC,CAAC;IACnE,IAAI,CAAC,MAAM,EAAE,CAAC;QACZ,MAAM,IAAI,KAAK,CAAC,2BAA2B,CAAC,CAAC;IAC/C,CAAC;IACD,MAAM,WAAW,GAAG,MAAM,CAAC,IAAI,CAAC,aAAa,CAAC,CAAC,CAAC;IAChD,MAAM,QAAQ,GAAG,YAAY,CAC3B,UAAU,CAAC,MAAM,CAAC,EAClB;QACE,UAAU;QACV,MAAM,CAAC,MAAM,CAAC,WAAW,CAAC,UAAU,CAAC,CAAC,CAAC,MAAM,CAAC,CAAC;QAC/C,SAAS,MAAM,CAAC,SAAS,CAAC,IAAI,MAAM,CAAC,OAAO,CAAC,EAAE;QAC/C,WAAW;QACX,MAAM,CAAC,MAAM,CAAC,gBAAgB,CAAC,CAAC;QAChC,aAAa;QACb,MAAM,CAAC,WAAW,CAAC,WAAW,CAAC,CAAC;QAChC,UAAU;QACV,IAAI;KACL,EACD,EAAE,QAAQ,EAAE,MAAM,EAAE,SAAS,EAAE,CAAC,GAAG,IAAI,GAAG,IAAI,EAAE,CACjD,CAAC;IACF,YAAY,CACV,UAAU,CAAC,aAAa,CAAC,EACzB,CAAC,SAAS,EAAE,yBAAyB,CAAC,EACtC;QACE,KAAK,EAAE,QAAQ;QACf,KAAK,EAAE,CAAC,MAAM,EAAE,SAAS,EAAE,SAAS,CAAC;KACtC,CACF,CAAC;IACF,YAAY,CACV,UAAU,CAAC,aAAa,CAAC,EACzB,CAAC,SAAS,EAAE,IAAI,CAAC,IAAI,EAAE,yBAAyB,CAAC,CAAC,EAClD,EAAE,KAAK,EAAE,SAAS,EAAE,CACrB,CAAC;AACJ,CAAC"}
|
package/src/codex.d.ts
DELETED
|
@@ -1,14 +0,0 @@
|
|
|
1
|
-
/**
|
|
2
|
-
* Execute a bounded mission using persisted ChatGPT account authentication.
|
|
3
|
-
* @param env - Workflow environment and operation-specific inputs.
|
|
4
|
-
* @returns The asynchronous operation result.
|
|
5
|
-
* @throws If the input or external operation fails validation.
|
|
6
|
-
*/
|
|
7
|
-
export declare function executeCodex(env: NodeJS.ProcessEnv): Promise<void>;
|
|
8
|
-
/**
|
|
9
|
-
* Resolve and validate the mission time limit in minutes.
|
|
10
|
-
* @throws If the timeout is outside the supported execution window.
|
|
11
|
-
* @param value - External value to validate.
|
|
12
|
-
* @returns The validated operation result.
|
|
13
|
-
*/
|
|
14
|
-
export declare function codexTimeout(value: string | undefined): number;
|
package/src/codex.js
DELETED
|
@@ -1,187 +0,0 @@
|
|
|
1
|
-
import { executable } from './executable.js';
|
|
2
|
-
import { spawn } from 'node:child_process';
|
|
3
|
-
import { mkdtempSync, readFileSync, writeFileSync, appendFileSync, existsSync, rmSync, copyFileSync, } from 'node:fs';
|
|
4
|
-
import { tmpdir } from 'node:os';
|
|
5
|
-
import { join, resolve } from 'node:path';
|
|
6
|
-
/**
|
|
7
|
-
* Execute a bounded mission using persisted ChatGPT account authentication.
|
|
8
|
-
* @param env - Workflow environment and operation-specific inputs.
|
|
9
|
-
* @returns The asynchronous operation result.
|
|
10
|
-
* @throws If the input or external operation fails validation.
|
|
11
|
-
*/
|
|
12
|
-
export async function executeCodex(env) {
|
|
13
|
-
const cwd = resolve(env.CODEX_WORKING_DIRECTORY || '.');
|
|
14
|
-
const minutes = codexTimeout(env.CODEX_TIMEOUT_MINUTES);
|
|
15
|
-
if (Boolean(env.CODEX_PROMPT) === Boolean(env.CODEX_PROMPT_FILE)) {
|
|
16
|
-
throw new Error('Supply exactly one of prompt and prompt-file');
|
|
17
|
-
}
|
|
18
|
-
const prompt = env.CODEX_PROMPT ||
|
|
19
|
-
readFileSync(resolve(cwd, env.CODEX_PROMPT_FILE || ''), 'utf8');
|
|
20
|
-
const authDir = authenticationDirectory(env, () => finish('auth-error', 1));
|
|
21
|
-
const home = mkdtempSync(join(env.RUNNER_TEMP || tmpdir(), 'codex-mission-'));
|
|
22
|
-
copyFileSync(join(authDir, 'auth.json'), join(home, 'auth.json'));
|
|
23
|
-
const response = join(env.RUNNER_TEMP || tmpdir(), `codex-response-${Date.now()}.md`);
|
|
24
|
-
const { args, childEnv } = codexInvocation(env, cwd, home, response);
|
|
25
|
-
let expired = false;
|
|
26
|
-
const child = spawn(executable('codex'), args, {
|
|
27
|
-
cwd,
|
|
28
|
-
env: childEnv,
|
|
29
|
-
stdio: ['pipe', 'ignore', 'inherit'],
|
|
30
|
-
detached: true,
|
|
31
|
-
});
|
|
32
|
-
child.stdin.on('error', () => {
|
|
33
|
-
/* Codex may exit before consuming the entire prompt. */
|
|
34
|
-
});
|
|
35
|
-
child.stdin.end(prompt);
|
|
36
|
-
let killTimer;
|
|
37
|
-
function stop() {
|
|
38
|
-
const pid = child.pid;
|
|
39
|
-
if (!pid) {
|
|
40
|
-
return;
|
|
41
|
-
}
|
|
42
|
-
try {
|
|
43
|
-
process.kill(-pid, 'SIGTERM');
|
|
44
|
-
}
|
|
45
|
-
catch {
|
|
46
|
-
/* The process group may already have exited. */
|
|
47
|
-
}
|
|
48
|
-
killTimer = setTimeout(() => {
|
|
49
|
-
try {
|
|
50
|
-
process.kill(-pid, 'SIGKILL');
|
|
51
|
-
}
|
|
52
|
-
catch {
|
|
53
|
-
/* The process group may already have exited. */
|
|
54
|
-
}
|
|
55
|
-
}, 5000);
|
|
56
|
-
killTimer.unref();
|
|
57
|
-
}
|
|
58
|
-
const signals = ['SIGINT', 'SIGTERM'];
|
|
59
|
-
const onSignal = () => {
|
|
60
|
-
expired = true;
|
|
61
|
-
stop();
|
|
62
|
-
};
|
|
63
|
-
for (const signal of signals) {
|
|
64
|
-
process.on(signal, onSignal);
|
|
65
|
-
}
|
|
66
|
-
const timer = setTimeout(() => {
|
|
67
|
-
expired = true;
|
|
68
|
-
stop();
|
|
69
|
-
}, minutes * 60000);
|
|
70
|
-
const code = await new Promise((resolveExit) => {
|
|
71
|
-
child.on('error', () => resolveExit(1));
|
|
72
|
-
child.on('close', (exitCode) => resolveExit(exitCode ?? 1));
|
|
73
|
-
});
|
|
74
|
-
clearTimeout(timer);
|
|
75
|
-
// A finished parent can leave background tools in its process group.
|
|
76
|
-
if (child.pid) {
|
|
77
|
-
try {
|
|
78
|
-
process.kill(-child.pid, 'SIGKILL');
|
|
79
|
-
}
|
|
80
|
-
catch {
|
|
81
|
-
/* Already exited. */
|
|
82
|
-
}
|
|
83
|
-
}
|
|
84
|
-
if (killTimer) {
|
|
85
|
-
clearTimeout(killTimer);
|
|
86
|
-
}
|
|
87
|
-
for (const signal of signals) {
|
|
88
|
-
process.off(signal, onSignal);
|
|
89
|
-
}
|
|
90
|
-
await persistAuth(home, authDir);
|
|
91
|
-
if (env.GITHUB_OUTPUT) {
|
|
92
|
-
appendFileSync(env.GITHUB_OUTPUT, `response-file=${response}\n`);
|
|
93
|
-
}
|
|
94
|
-
finish(executionStatus(expired, code), expired ? 124 : code);
|
|
95
|
-
function finish(status, code) {
|
|
96
|
-
if (env.GITHUB_OUTPUT) {
|
|
97
|
-
appendFileSync(env.GITHUB_OUTPUT, `status=${status}\n`);
|
|
98
|
-
}
|
|
99
|
-
if (env.GITHUB_STEP_SUMMARY) {
|
|
100
|
-
appendFileSync(env.GITHUB_STEP_SUMMARY, `Codex mission: **${status}**\n`);
|
|
101
|
-
}
|
|
102
|
-
process.exit(code);
|
|
103
|
-
}
|
|
104
|
-
}
|
|
105
|
-
/**
|
|
106
|
-
* Resolve and validate the mission time limit in minutes.
|
|
107
|
-
* @throws If the timeout is outside the supported execution window.
|
|
108
|
-
* @param value - External value to validate.
|
|
109
|
-
* @returns The validated operation result.
|
|
110
|
-
*/
|
|
111
|
-
export function codexTimeout(value) {
|
|
112
|
-
const minutes = Number(value || 20);
|
|
113
|
-
if (!Number.isFinite(minutes) || minutes <= 0 || minutes > 120) {
|
|
114
|
-
throw new Error('timeout-minutes must be > 0 and <= 120');
|
|
115
|
-
}
|
|
116
|
-
return minutes;
|
|
117
|
-
}
|
|
118
|
-
function codexInvocation(env, cwd, home, response) {
|
|
119
|
-
const args = [
|
|
120
|
-
'exec',
|
|
121
|
-
'--ephemeral',
|
|
122
|
-
'--ignore-user-config',
|
|
123
|
-
'-c',
|
|
124
|
-
'forced_login_method="chatgpt"',
|
|
125
|
-
'-c',
|
|
126
|
-
'cli_auth_credentials_store="file"',
|
|
127
|
-
'-c',
|
|
128
|
-
'approval_policy="never"',
|
|
129
|
-
'-c',
|
|
130
|
-
`model_reasoning_effort=${JSON.stringify(env.CODEX_EFFORT || 'medium')}`,
|
|
131
|
-
'--sandbox',
|
|
132
|
-
'danger-full-access',
|
|
133
|
-
'--output-last-message',
|
|
134
|
-
response,
|
|
135
|
-
];
|
|
136
|
-
if (env.CODEX_MODEL) {
|
|
137
|
-
args.push('--model', env.CODEX_MODEL);
|
|
138
|
-
}
|
|
139
|
-
if (env.CODEX_OUTPUT_SCHEMA) {
|
|
140
|
-
args.push('--output-schema', resolve(cwd, env.CODEX_OUTPUT_SCHEMA));
|
|
141
|
-
}
|
|
142
|
-
args.push('-');
|
|
143
|
-
const childEnv = { ...env, CODEX_HOME: home };
|
|
144
|
-
for (const key of [
|
|
145
|
-
'OPENAI_API_KEY',
|
|
146
|
-
'CODEX_API_KEY',
|
|
147
|
-
'CODEX_ACCESS_TOKEN',
|
|
148
|
-
'ACTIONS_RUNTIME_TOKEN',
|
|
149
|
-
]) {
|
|
150
|
-
delete childEnv[key];
|
|
151
|
-
}
|
|
152
|
-
return { args, childEnv };
|
|
153
|
-
}
|
|
154
|
-
async function persistAuth(home, authDir) {
|
|
155
|
-
// Atomic replacement preserves refresh-token rotation even after failed missions.
|
|
156
|
-
try {
|
|
157
|
-
if (existsSync(join(home, 'auth.json'))) {
|
|
158
|
-
const { renameSync } = await import('node:fs');
|
|
159
|
-
writeFileSync(join(authDir, 'auth.json.next'), readFileSync(join(home, 'auth.json')), { mode: 0o600 });
|
|
160
|
-
renameSync(join(authDir, 'auth.json.next'), join(authDir, 'auth.json'));
|
|
161
|
-
}
|
|
162
|
-
}
|
|
163
|
-
finally {
|
|
164
|
-
rmSync(home, { recursive: true, force: true });
|
|
165
|
-
}
|
|
166
|
-
}
|
|
167
|
-
function executionStatus(expired, code) {
|
|
168
|
-
if (expired) {
|
|
169
|
-
return 'timeout';
|
|
170
|
-
}
|
|
171
|
-
return code === 0 ? 'success' : 'execution-error';
|
|
172
|
-
}
|
|
173
|
-
function authenticationDirectory(env, fail) {
|
|
174
|
-
const authDir = env.CODEX_AUTH_DIR;
|
|
175
|
-
if (!authDir || !existsSync(join(authDir, 'auth.json'))) {
|
|
176
|
-
fail();
|
|
177
|
-
}
|
|
178
|
-
if (!authDir) {
|
|
179
|
-
throw new Error('Missing authentication directory');
|
|
180
|
-
}
|
|
181
|
-
const auth = JSON.parse(readFileSync(join(authDir, 'auth.json'), 'utf8'));
|
|
182
|
-
if (auth.OPENAI_API_KEY || !auth.tokens?.refresh_token) {
|
|
183
|
-
fail();
|
|
184
|
-
}
|
|
185
|
-
return authDir;
|
|
186
|
-
}
|
|
187
|
-
//# sourceMappingURL=codex.js.map
|
package/src/codex.js.map
DELETED
|
@@ -1 +0,0 @@
|
|
|
1
|
-
{"version":3,"file":"codex.js","sourceRoot":"","sources":["../../../../apps/workflow-cli/src/codex.ts"],"names":[],"mappings":"AAAA,OAAO,EAAE,UAAU,EAAE,MAAM,iBAAiB,CAAC;AAC7C,OAAO,EAAE,KAAK,EAAE,MAAM,oBAAoB,CAAC;AAC3C,OAAO,EACL,WAAW,EACX,YAAY,EACZ,aAAa,EACb,cAAc,EACd,UAAU,EACV,MAAM,EACN,YAAY,GACb,MAAM,SAAS,CAAC;AACjB,OAAO,EAAE,MAAM,EAAE,MAAM,SAAS,CAAC;AACjC,OAAO,EAAE,IAAI,EAAE,OAAO,EAAE,MAAM,WAAW,CAAC;AAE1C;;;;;GAKG;AACH,MAAM,CAAC,KAAK,UAAU,YAAY,CAAC,GAAsB;IACvD,MAAM,GAAG,GAAG,OAAO,CAAC,GAAG,CAAC,uBAAuB,IAAI,GAAG,CAAC,CAAC;IACxD,MAAM,O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CAAC,OAAO,EAAE,WAAW,CAAC,CAAC,EAAE,CAAC;QACxD,IAAI,EAAE,CAAC;IACT,CAAC;IACD,IAAI,CAAC,OAAO,EAAE,CAAC;QACb,MAAM,IAAI,KAAK,CAAC,kCAAkC,CAAC,CAAC;IACtD,CAAC;IACD,MAAM,IAAI,GAAG,IAAI,CAAC,KAAK,CAAC,YAAY,CAAC,IAAI,CAAC,OAAO,EAAE,WAAW,CAAC,EAAE,MAAM,CAAC,CAAC,CAAC;IAC1E,IAAI,IAAI,CAAC,cAAc,IAAI,CAAC,IAAI,CAAC,MAAM,EAAE,aAAa,EAAE,CAAC;QACvD,IAAI,EAAE,CAAC;IACT,CAAC;IAED,OAAO,OAAO,CAAC;AACjB,CAAC"}
|
package/src/executable.d.ts
DELETED
|
@@ -1,7 +0,0 @@
|
|
|
1
|
-
/**
|
|
2
|
-
* Resolve a tool supplied by the trusted runner toolchain to an absolute path.
|
|
3
|
-
* @param name - Executable name from workflow-cli source, never task input.
|
|
4
|
-
* @returns The canonical executable path.
|
|
5
|
-
* @throws If the runner does not provide an executable file for this tool.
|
|
6
|
-
*/
|
|
7
|
-
export declare function executable(name: string): string;
|
package/src/executable.js
DELETED
|
@@ -1,24 +0,0 @@
|
|
|
1
|
-
import { execFileSync } from 'node:child_process';
|
|
2
|
-
import { realpathSync, statSync } from 'node:fs';
|
|
3
|
-
import { isAbsolute } from 'node:path';
|
|
4
|
-
/**
|
|
5
|
-
* Resolve a tool supplied by the trusted runner toolchain to an absolute path.
|
|
6
|
-
* @param name - Executable name from workflow-cli source, never task input.
|
|
7
|
-
* @returns The canonical executable path.
|
|
8
|
-
* @throws If the runner does not provide an executable file for this tool.
|
|
9
|
-
*/
|
|
10
|
-
export function executable(name) {
|
|
11
|
-
const path = execFileSync('/usr/bin/which', [name], {
|
|
12
|
-
encoding: 'utf8',
|
|
13
|
-
}).trim();
|
|
14
|
-
if (!isAbsolute(path)) {
|
|
15
|
-
throw new Error(`Missing executable: ${name}`);
|
|
16
|
-
}
|
|
17
|
-
const canonical = realpathSync(path);
|
|
18
|
-
const info = statSync(canonical);
|
|
19
|
-
if (!info.isFile() || (info.mode & 0o111) === 0) {
|
|
20
|
-
throw new Error(`Invalid executable: ${name}`);
|
|
21
|
-
}
|
|
22
|
-
return canonical;
|
|
23
|
-
}
|
|
24
|
-
//# sourceMappingURL=executable.js.map
|
package/src/executable.js.map
DELETED
|
@@ -1 +0,0 @@
|
|
|
1
|
-
{"version":3,"file":"executable.js","sourceRoot":"","sources":["../../../../apps/workflow-cli/src/executable.ts"],"names":[],"mappings":"AAAA,OAAO,EAAE,YAAY,EAAE,MAAM,oBAAoB,CAAC;AAClD,OAAO,EAAE,YAAY,EAAE,QAAQ,EAAE,MAAM,SAAS,CAAC;AACjD,OAAO,EAAE,UAAU,EAAE,MAAM,WAAW,CAAC;AAEvC;;;;;GAKG;AACH,MAAM,UAAU,UAAU,CAAC,IAAY;IACrC,MAAM,IAAI,GAAG,YAAY,CAAC,gBAAgB,EAAE,CAAC,IAAI,CAAC,EAAE;QAClD,QAAQ,EAAE,MAAM;KACjB,CAAC,CAAC,IAAI,EAAE,CAAC;IACV,IAAI,CAAC,UAAU,CAAC,IAAI,CAAC,EAAE,CAAC;QACtB,MAAM,IAAI,KAAK,CAAC,uBAAuB,IAAI,EAAE,CAAC,CAAC;IACjD,CAAC;IACD,MAAM,SAAS,GAAG,YAAY,CAAC,IAAI,CAAC,CAAC;IACrC,MAAM,IAAI,GAAG,QAAQ,CAAC,SAAS,CAAC,CAAC;IACjC,IAAI,CAAC,IAAI,CAAC,MAAM,EAAE,IAAI,CAAC,IAAI,CAAC,IAAI,GAAG,KAAK,CAAC,KAAK,CAAC,EAAE,CAAC;QAChD,MAAM,IAAI,KAAK,CAAC,uBAAuB,IAAI,EAAE,CAAC,CAAC;IACjD,CAAC;IACD,OAAO,SAAS,CAAC;AACnB,CAAC"}
|