@duypham93/openkit 0.2.6 → 0.2.7
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
CHANGED
|
@@ -21,6 +21,10 @@ function writeFile(filePath, content, mode) {
|
|
|
21
21
|
}
|
|
22
22
|
}
|
|
23
23
|
|
|
24
|
+
function writeJson(filePath, value) {
|
|
25
|
+
writeFile(filePath, `${JSON.stringify(value, null, 2)}\n`);
|
|
26
|
+
}
|
|
27
|
+
|
|
24
28
|
function relativeTarget(fromPath, toPath) {
|
|
25
29
|
return path.relative(path.dirname(fromPath), toPath) || '.';
|
|
26
30
|
}
|
|
@@ -128,12 +132,26 @@ process.exit(typeof result.status === 'number' ? result.status : 1);
|
|
|
128
132
|
type: 'file',
|
|
129
133
|
});
|
|
130
134
|
|
|
135
|
+
const opencodeRoot = path.join(paths.projectRoot, '.opencode');
|
|
136
|
+
const opencodePackagePath = path.join(opencodeRoot, 'package.json');
|
|
137
|
+
if (!fs.existsSync(opencodePackagePath)) {
|
|
138
|
+
writeJson(opencodePackagePath, { type: 'module' });
|
|
139
|
+
createdPaths.push(opencodePackagePath);
|
|
140
|
+
}
|
|
141
|
+
|
|
131
142
|
if (!fs.existsSync(path.join(paths.projectRoot, '.opencode', 'workflow-state.js'))) {
|
|
132
143
|
const rootWorkflowCli = `#!/usr/bin/env node
|
|
133
144
|
import { spawnSync } from 'node:child_process';
|
|
134
145
|
|
|
135
|
-
const
|
|
136
|
-
const
|
|
146
|
+
const rawArgs = process.argv.slice(2);
|
|
147
|
+
const command = rawArgs[0];
|
|
148
|
+
const aliasMap = new Map([
|
|
149
|
+
['get', 'show'],
|
|
150
|
+
['--help', 'help'],
|
|
151
|
+
['-h', 'help'],
|
|
152
|
+
]);
|
|
153
|
+
const normalizedArgs = rawArgs.length === 0 ? ['help'] : [aliasMap.get(command) ?? command, ...rawArgs.slice(1)];
|
|
154
|
+
const result = spawnSync(process.execPath, [${JSON.stringify(paths.workspaceShimWorkflowCliPath)}, ...normalizedArgs], {
|
|
137
155
|
stdio: 'inherit',
|
|
138
156
|
env: process.env,
|
|
139
157
|
});
|
|
@@ -367,6 +367,30 @@ test('openkit run cleans root compatibility shims when created files are removed
|
|
|
367
367
|
assert.equal(fs.existsSync(path.join(projectRoot, '.opencode', 'openkit', 'AGENTS.md')), true);
|
|
368
368
|
});
|
|
369
369
|
|
|
370
|
+
test('openkit run creates a module-aware root workflow wrapper with alias support', () => {
|
|
371
|
+
const tempHome = makeTempDir();
|
|
372
|
+
const projectRoot = makeTempDir();
|
|
373
|
+
const fakeBinDir = path.join(tempHome, 'bin');
|
|
374
|
+
|
|
375
|
+
writeExecutable(path.join(fakeBinDir, 'opencode'), '#!/bin/sh\nexit 0\n');
|
|
376
|
+
|
|
377
|
+
const result = runCli(['run'], {
|
|
378
|
+
cwd: projectRoot,
|
|
379
|
+
env: {
|
|
380
|
+
...process.env,
|
|
381
|
+
OPENCODE_HOME: tempHome,
|
|
382
|
+
PATH: `${fakeBinDir}${path.delimiter}${process.env.PATH}`,
|
|
383
|
+
},
|
|
384
|
+
});
|
|
385
|
+
|
|
386
|
+
assert.equal(result.status, 0);
|
|
387
|
+
assert.deepEqual(readJson(path.join(projectRoot, '.opencode', 'package.json')), { type: 'module' });
|
|
388
|
+
|
|
389
|
+
const wrapper = fs.readFileSync(path.join(projectRoot, '.opencode', 'workflow-state.js'), 'utf8');
|
|
390
|
+
assert.match(wrapper, /\['get', 'show'\]/);
|
|
391
|
+
assert.match(wrapper, /\['--help', 'help'\]/);
|
|
392
|
+
});
|
|
393
|
+
|
|
370
394
|
test('openkit run reports missing opencode after first-time setup completes', () => {
|
|
371
395
|
const tempHome = makeTempDir();
|
|
372
396
|
const projectRoot = makeTempDir();
|