fix: address latest Grok review findings

This commit is contained in:
MistyStar committed 2026-10-20 10:35:37 +08:00
1 parent 4140e0c35c
commit 460f55351f
3 files changed
+27 -6

No files matched your search

+9 -1
View File
@@ -19,13 +19,21 @@ function canonicalArgs(argv = process.argv.slice(2)) {
for (let index = 0; index < argv.length; index += 1) {
const argument = argv[index];
if (argument === '--target') {
const value = argv[index + 1];
if (!value || value.startsWith('-')) {
throw new Error('Missing value for --target');
}
index += 1;
continue;
}
args.push(argument);
if (SELECTION_FLAGS.has(argument)) hasSelection = true;
if (VALUE_FLAGS.has(argument)) {
if (index + 1 < argv.length) args.push(argv[index + 1]);
const value = argv[index + 1];
if (!value || value.startsWith('-')) {
throw new Error(`Missing value for ${argument}`);
}
args.push(value);
index += 1;
} else if (!argument.startsWith('-')) {
hasSelection = true;
+3 -1
View File
@@ -247,11 +247,13 @@ function runTests() {
const destination = path.join(parent, 'snapshot');
const calls = [];
try {
const archive = Buffer.from('archive');
copyGitArchive('/source', 'bbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbb', destination, (...args) => {
calls.push(args);
return Buffer.alloc(0);
return archive;
});
assert.deepStrictEqual(calls[1][1], ['-x', '-f', '-', '-C', destination]);
assert.deepStrictEqual(calls[1][2].input, archive);
} finally {
fs.rmSync(parent, { recursive: true, force: true });
}
+15 -4
View File
@@ -165,6 +165,11 @@ function runTests() {
);
})) passed++; else failed++;
if (test('Grok alias rejects option-prefixed values for value flags', () => {
assert.throws(() => canonicalArgs(['--target', '--dry-run']), /Missing value for --target/);
assert.throws(() => canonicalArgs(['--consent-mcp', '--dry-run']), /Missing value for --consent-mcp/);
})) passed++; else failed++;
if (test('plans Grok through the canonical request with a local pinned fixture', () => {
const homeDir = createTempDir('install-apply-grok-home-');
const fixtureRoot = createTempDir('install-apply-grok-source-');
@@ -174,11 +179,17 @@ function runTests() {
const sourceSha = execFileSync('git', ['rev-parse', 'HEAD'], { cwd: sourceRoot, encoding: 'utf8' }).trim();
const marketplacePath = path.join(sourceRoot, '.grok-plugin', 'marketplace.json');
const marketplace = readJson(marketplacePath);
marketplace.plugins[0] = {
...marketplace.plugins[0],
source: { source: 'url', url: sourceRoot, sha: sourceSha },
const updatedMarketplace = {
...marketplace,
plugins: [
{
...marketplace.plugins[0],
source: { source: 'url', url: sourceRoot, sha: sourceSha },
},
...marketplace.plugins.slice(1),
],
};
fs.writeFileSync(marketplacePath, `${JSON.stringify(marketplace, null, 2)}\n`);
fs.writeFileSync(marketplacePath, `${JSON.stringify(updatedMarketplace, null, 2)}\n`);
const result = run(
['--target', 'grok', '--profile', 'minimal', '--dry-run', '--json'],