@memnexus-ai/mx-agent-cli 0.1.298 → 0.1.299
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/dist/commands/bootstrap.d.ts.map +1 -1
- package/dist/commands/bootstrap.js +5 -0
- package/dist/commands/bootstrap.js.map +1 -1
- package/dist/commands/create.d.ts.map +1 -1
- package/dist/commands/create.js +5 -0
- package/dist/commands/create.js.map +1 -1
- package/dist/commands/init.d.ts.map +1 -1
- package/dist/commands/init.js +7 -0
- package/dist/commands/init.js.map +1 -1
- package/dist/commands/new.d.ts.map +1 -1
- package/dist/commands/new.js +12 -1
- package/dist/commands/new.js.map +1 -1
- package/dist/lib/coordination-token.d.ts +6 -0
- package/dist/lib/coordination-token.d.ts.map +1 -1
- package/dist/lib/coordination-token.js +11 -0
- package/dist/lib/coordination-token.js.map +1 -1
- package/dist/lib/creation-login.d.ts +42 -0
- package/dist/lib/creation-login.d.ts.map +1 -0
- package/dist/lib/creation-login.js +62 -0
- package/dist/lib/creation-login.js.map +1 -0
- package/dist/lib/gh-remote.d.ts +26 -5
- package/dist/lib/gh-remote.d.ts.map +1 -1
- package/dist/lib/gh-remote.js +54 -16
- package/dist/lib/gh-remote.js.map +1 -1
- package/package.json +1 -1
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"gh-remote.d.ts","sourceRoot":"","sources":["../../src/lib/gh-remote.ts"],"names":[],"mappings":"AAAA
|
|
1
|
+
{"version":3,"file":"gh-remote.d.ts","sourceRoot":"","sources":["../../src/lib/gh-remote.ts"],"names":[],"mappings":"AAAA;;;;;;;;;;;;;GAaG;AAEH,OAAO,EAAa,KAAK,gBAAgB,EAAE,MAAM,eAAe,CAAC;AAEjE,MAAM,MAAM,gBAAgB,GAAG,QAAQ,GAAG,SAAS,CAAC;AAEpD;;;;;;;;;;;GAWG;AACH,wBAAgB,gBAAgB,CAC9B,GAAG,EAAE,MAAM,EACX,MAAM,SAAW,EACjB,KAA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,EACjC,KAAK,GAAE,WAAuB,GAC7B,OAAO,CAAC,YAAY,CAAC,CA0DvB"}
|
package/dist/lib/gh-remote.js
CHANGED
|
@@ -1,10 +1,12 @@
|
|
|
1
1
|
/**
|
|
2
2
|
* GitHub remote auto-setup helper for `mx-agent new`.
|
|
3
3
|
*
|
|
4
|
-
* Opt-in via --with-remote.
|
|
5
|
-
*
|
|
6
|
-
*
|
|
7
|
-
*
|
|
4
|
+
* Opt-in via --with-remote. `requireCreationLogin` (lib/creation-login.ts, #818)
|
|
5
|
+
* refuses before the first write when gh is missing or logged out. This helper
|
|
6
|
+
* runs at the end of the command and still fails open: any failure here (a login
|
|
7
|
+
* lost since that check, repo already exists, network error) downgrades to a
|
|
8
|
+
* warning and returns { created: false, reason } so the caller can still print
|
|
9
|
+
* the manual remote-setup hint.
|
|
8
10
|
*
|
|
9
11
|
* Security: all arguments are passed as argv to spawnSync (never through
|
|
10
12
|
* a shell). projectName is validated upstream by validateProjectName().
|
|
@@ -75,24 +77,60 @@ export function validateOwnerRepoShape(value) {
|
|
|
75
77
|
return OWNER_REPO_SHAPE_REASONS.dotSegment;
|
|
76
78
|
return null;
|
|
77
79
|
}
|
|
80
|
+
/**
|
|
81
|
+
* The limit on each `gh` probe. The probes now run before the first write, so a
|
|
82
|
+
* hanging `gh` would otherwise hold the command at its start with no output.
|
|
83
|
+
*/
|
|
84
|
+
export const GH_PROBE_TIMEOUT_MS = 30_000;
|
|
85
|
+
function spawnErrorCode(result) {
|
|
86
|
+
return result.error?.code;
|
|
87
|
+
}
|
|
88
|
+
/**
|
|
89
|
+
* Whether `gh` runs and `gh auth status` exits 0. Returns the problem, or null
|
|
90
|
+
* when there is none. One function so the pre-write check and
|
|
91
|
+
* `maybeCreateRemote` cannot disagree about what "logged in" means (#818).
|
|
92
|
+
*
|
|
93
|
+
* 'gh-missing' means the spawn itself reported ENOENT and nothing else does: a
|
|
94
|
+
* `gh` that ran and exited non-zero was found. 'gh-unauthenticated' means only
|
|
95
|
+
* that `gh auth status` did not exit 0. That command ran live, so it does not
|
|
96
|
+
* establish that the login is the cause.
|
|
97
|
+
*/
|
|
98
|
+
export function probeGhLogin(spawn = spawnSync, timeoutMs = GH_PROBE_TIMEOUT_MS) {
|
|
99
|
+
// SIGKILL, because a `gh` that ignores the default SIGTERM would hold
|
|
100
|
+
// spawnSync past the limit.
|
|
101
|
+
const options = {
|
|
102
|
+
encoding: 'utf-8', stdio: 'pipe', timeout: timeoutMs, killSignal: 'SIGKILL',
|
|
103
|
+
};
|
|
104
|
+
// 1. gh present? Probe directly (shell-free) so a missing binary surfaces as
|
|
105
|
+
// ENOENT. Avoids `command -v gh` under `shell: true`, which triggers Node
|
|
106
|
+
// DEP0190 (passing args with shell option true).
|
|
107
|
+
const which = spawn('gh', ['--version'], options);
|
|
108
|
+
if (spawnErrorCode(which) === 'ENOENT')
|
|
109
|
+
return 'gh-missing';
|
|
110
|
+
if (spawnErrorCode(which) === 'ETIMEDOUT')
|
|
111
|
+
return 'gh-timed-out';
|
|
112
|
+
if (which.status !== 0)
|
|
113
|
+
return 'gh-version-failed';
|
|
114
|
+
// 2. gh authenticated?
|
|
115
|
+
const auth = spawn('gh', ['auth', 'status'], options);
|
|
116
|
+
if (spawnErrorCode(auth) === 'ETIMEDOUT')
|
|
117
|
+
return 'gh-timed-out';
|
|
118
|
+
if (auth.status !== 0)
|
|
119
|
+
return 'gh-unauthenticated';
|
|
120
|
+
return null;
|
|
121
|
+
}
|
|
78
122
|
export async function maybeCreateRemote(outputDir, projectName, options, spawn = spawnSync) {
|
|
79
123
|
if (!options.withRemote) {
|
|
80
124
|
return { created: false, reason: 'not-requested' };
|
|
81
125
|
}
|
|
82
126
|
const visibility = options.remoteVisibility === 'public' ? 'public' : 'private';
|
|
83
|
-
// 1. gh present
|
|
84
|
-
//
|
|
85
|
-
|
|
86
|
-
|
|
87
|
-
|
|
88
|
-
return { created: false, reason: 'gh-missing' };
|
|
89
|
-
}
|
|
90
|
-
// 2. gh authenticated?
|
|
91
|
-
const auth = spawn('gh', ['auth', 'status'], { encoding: 'utf-8', stdio: 'pipe' });
|
|
92
|
-
if (auth.status !== 0) {
|
|
93
|
-
return { created: false, reason: 'gh-unauthenticated' };
|
|
127
|
+
// 1. gh present and logged in? Asked again here, one cheap command, because a
|
|
128
|
+
// login can be lost between the pre-write check and this push.
|
|
129
|
+
const problem = probeGhLogin(spawn);
|
|
130
|
+
if (problem !== null) {
|
|
131
|
+
return { created: false, reason: problem };
|
|
94
132
|
}
|
|
95
|
-
//
|
|
133
|
+
// 2. Create repo and push. stdio inherit so users see progress.
|
|
96
134
|
const create = spawn('gh', ['repo', 'create', projectName, `--${visibility}`, `--source=${outputDir}`, '--remote=origin', '--push'], { encoding: 'utf-8', stdio: 'inherit' });
|
|
97
135
|
if (create.status !== 0) {
|
|
98
136
|
const stderr = typeof create.stderr === 'string'
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"gh-remote.js","sourceRoot":"","sources":["../../src/lib/gh-remote.ts"],"names":[],"mappings":"AAAA
|
|
1
|
+
{"version":3,"file":"gh-remote.js","sourceRoot":"","sources":["../../src/lib/gh-remote.ts"],"names":[],"mappings":"AAAA;;;;;;;;;;;;;GAaG;AAEH,OAAO,EAAE,SAAS,EAAyB,MAAM,eAAe,CAAC;AAIjE;;;;;;;;;;;GAWG;AACH,MAAM,UAAU,gBAAgB,CAC9B,GAAW,EACX,MAAM,GAAG,QAAQ,EACjB,QAAqB,SAAS;IAE9B,IAAI,CAAsD,CAAC;IAC3D,IAAI,CAAC;QACH,CAAC,GAAG,KAAK,CAAC,KAAK,EAAE,CAAC,IAAI,EAAE,GAAG,EAAE,QAAQ,EAAE,SAAS,EAAE,MAAM,CAAC,EAAE;YACzD,QAAQ,EAAE,OAAO;YACjB,KAAK,EAAE,MAAM;SACd,CAAC,CAAC;IACL,CAAC;IAAC,MAAM,CAAC;QACP,OAAO,IAAI,CAAC;IACd,CAAC;IACD,IAAI,CAAC,CAAC,MAAM,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