@malmhq/intermesh-cli 0.1.0
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/LICENSE +198 -0
- package/README.md +77 -0
- package/dist/generation/.opencode/AGENTS.md +38 -0
- package/dist/generation/.opencode/agents/generation-builder.md +9 -0
- package/dist/generation/.opencode/agents/generation-fidelity.md +9 -0
- package/dist/generation/.opencode/agents/generation-source.md +13 -0
- package/dist/generation/.opencode/prompts/analyze-capabilities.md +61 -0
- package/dist/generation/.opencode/prompts/analyze-source.md +41 -0
- package/dist/generation/.opencode/prompts/generate.md +9 -0
- package/dist/generation/.opencode/prompts/repair-capability-proposal.md +5 -0
- package/dist/generation/.opencode/skills/generation-building/SKILL.md +32 -0
- package/dist/generation/.opencode/skills/generation-package-review/SKILL.md +36 -0
- package/dist/generation/.opencode/skills/generation-source-analysis/SKILL.md +36 -0
- package/dist/generation/AGENTS.md +38 -0
- package/dist/generation/agent-skill-installer/index.ts +4 -0
- package/dist/generation/agent-skill-installer/install.ts +503 -0
- package/dist/generation/agent-skill-installer/lock.ts +128 -0
- package/dist/generation/agent-skill-installer/manifest.ts +271 -0
- package/dist/generation/agent-skill-installer/targets.ts +169 -0
- package/dist/generation/runtime-entrypoint.js +39980 -0
- package/dist/generation/scripts/check-package.mjs +45 -0
- package/dist/generation/scripts/installed-help.mjs +98 -0
- package/dist/generation/scripts/lead-input.mjs +584 -0
- package/dist/generation/scripts/prepare-opencode.mjs +33 -0
- package/dist/generation/scripts/prepared-work.mjs +197 -0
- package/dist/generation/scripts/repair-loop.mjs +519 -0
- package/dist/generation/scripts/run-reviewers.mjs +306 -0
- package/dist/generation/scripts/runtime-capture.mjs +119 -0
- package/dist/generation/scripts/stage-timings.mjs +53 -0
- package/dist/generation/scripts/validate-source-brief.mjs +220 -0
- package/dist/generation/scripts/verify-package.mjs +365 -0
- package/dist/generation/templates/npm-cli/CONTRIBUTING.md +20 -0
- package/dist/generation/templates/npm-cli/GENERATION-PATTERNS.md +143 -0
- package/dist/generation/templates/npm-cli/README.md +67 -0
- package/dist/generation/templates/npm-cli/capabilities.json +1 -0
- package/dist/generation/templates/npm-cli/mock/routes.ts +3 -0
- package/dist/generation/templates/npm-cli/mock/server.ts +15 -0
- package/dist/generation/templates/npm-cli/mock/types.ts +7 -0
- package/dist/generation/templates/npm-cli/package.json +36 -0
- package/dist/generation/templates/npm-cli/pnpm-lock.yaml +495 -0
- package/dist/generation/templates/npm-cli/pnpm-workspace.yaml +2 -0
- package/dist/generation/templates/npm-cli/skills/customer-cli-management/SKILL.md +22 -0
- package/dist/generation/templates/npm-cli/skills/customer-workflow/SKILL.md +22 -0
- package/dist/generation/templates/npm-cli/src/auth/commands.ts +77 -0
- package/dist/generation/templates/npm-cli/src/auth/credentials.ts +66 -0
- package/dist/generation/templates/npm-cli/src/auth/prompt.ts +27 -0
- package/dist/generation/templates/npm-cli/src/cli.ts +53 -0
- package/dist/generation/templates/npm-cli/src/commands.ts +6 -0
- package/dist/generation/templates/npm-cli/src/customer.ts +16 -0
- package/dist/generation/templates/npm-cli/src/index.ts +11 -0
- package/dist/generation/templates/npm-cli/src/lifecycle/commands.ts +344 -0
- package/dist/generation/templates/npm-cli/src/lifecycle/config.ts +32 -0
- package/dist/generation/templates/npm-cli/src/shared/dry-run.ts +32 -0
- package/dist/generation/templates/npm-cli/src/shared/errors.ts +162 -0
- package/dist/generation/templates/npm-cli/src/shared/files.ts +45 -0
- package/dist/generation/templates/npm-cli/src/shared/http.ts +125 -0
- package/dist/generation/templates/npm-cli/src/shared/output.ts +33 -0
- package/dist/generation/templates/npm-cli/test/auth.test.ts +113 -0
- package/dist/generation/templates/npm-cli/test/fixture-cli.ts +51 -0
- package/dist/generation/templates/npm-cli/test/foundation.test.ts +316 -0
- package/dist/generation/templates/npm-cli/test/helpers.ts +34 -0
- package/dist/generation/templates/npm-cli/test/mock-lifecycle.test.ts +86 -0
- package/dist/generation/templates/npm-cli/test/run-with-mock.ts +142 -0
- package/dist/generation/templates/npm-cli/tsconfig.build.json +5 -0
- package/dist/generation/templates/npm-cli/tsconfig.json +11 -0
- package/dist/generation/templates/opencode-bootstrap/package-lock.json +402 -0
- package/dist/generation/templates/opencode-bootstrap/package.json +7 -0
- package/dist/index.js +51965 -0
- package/dist/runtime/candidate-inspection/inspect.Dockerfile +4 -0
- package/dist/runtime/candidate-inspection/install.Dockerfile +5 -0
- package/dist/runtime/candidate-inspection/registry-proxy.mjs +37 -0
- package/dist/runtime/harbor/bootstrap/package-lock.json +402 -0
- package/dist/runtime/harbor/bootstrap/package.json +7 -0
- package/dist/runtime/harbor/evaluation.Dockerfile +31 -0
- package/dist/runtime/harbor/harbor_launcher.py +62 -0
- package/dist/runtime/harbor/intermesh_opencode.py +44 -0
- package/dist/runtime/harbor/model-forwarder.mjs +52 -0
- package/dist/runtime/live-task.md +13 -0
- package/package.json +44 -0
- package/skills/inter-cli-management/SKILL.md +38 -0
- package/skills/inter-cli-management/evals/evals.json +40 -0
- package/skills/inter-context/SKILL.md +72 -0
- package/skills/inter-context/evals/cases.json +82 -0
- package/skills/inter-eval-authoring/SKILL.md +70 -0
- package/skills/inter-eval-authoring/evals/evals.json +69 -0
- package/skills/inter-eval-authoring/evals/trigger-queries.json +34 -0
- package/skills/inter-eval-authoring/references/authoring-guide.md +70 -0
- package/skills/inter-eval-authoring/references/eval-plan.example.json +92 -0
- package/skills/inter-eval-authoring/references/eval-plan.schema.json +304 -0
- package/skills/inter-evaluation/SKILL.md +51 -0
- package/skills/inter-evaluation/evals/evals.json +49 -0
- package/skills/inter-evaluation/evals/trigger-queries.json +30 -0
- package/skills/inter-generation/SKILL.md +42 -0
- package/skills/inter-generation/evals/evals.json +81 -0
- package/skills/inter-generation/evals/trigger-queries.json +58 -0
|
@@ -0,0 +1,45 @@
|
|
|
1
|
+
import { spawnSync } from 'node:child_process';
|
|
2
|
+
import { writeFileSync } from 'node:fs';
|
|
3
|
+
|
|
4
|
+
const [packagePath, opencode] = process.argv.slice(2);
|
|
5
|
+
const checks = [];
|
|
6
|
+
for (const args of [
|
|
7
|
+
['install', '--frozen-lockfile', '--ignore-scripts'],
|
|
8
|
+
['check'],
|
|
9
|
+
['test'],
|
|
10
|
+
['build'],
|
|
11
|
+
]) {
|
|
12
|
+
const result = spawnSync('pnpm', args, { cwd: packagePath, stdio: 'inherit', timeout: 120_000 });
|
|
13
|
+
checks.push({ command: `pnpm ${args.join(' ')}`, exit_code: result.status });
|
|
14
|
+
writeFileSync(
|
|
15
|
+
'.generation/starter-checks.json',
|
|
16
|
+
JSON.stringify({ passed: result.status === 0, checks }, null, 2),
|
|
17
|
+
);
|
|
18
|
+
if (result.status !== 0) process.exit(1);
|
|
19
|
+
}
|
|
20
|
+
function version(command) {
|
|
21
|
+
const result = spawnSync(command, ['--version'], { encoding: 'utf8', timeout: 30_000 });
|
|
22
|
+
if (result.status !== 0) {
|
|
23
|
+
const reason =
|
|
24
|
+
result.error?.message ??
|
|
25
|
+
result.signal ??
|
|
26
|
+
result.stderr.trim() ??
|
|
27
|
+
`exit ${String(result.status)}`;
|
|
28
|
+
throw new Error(`Environment check failed: ${command} (${reason})`);
|
|
29
|
+
}
|
|
30
|
+
return result.stdout.trim();
|
|
31
|
+
}
|
|
32
|
+
writeFileSync(
|
|
33
|
+
'.generation/environment.json',
|
|
34
|
+
JSON.stringify(
|
|
35
|
+
{
|
|
36
|
+
node: process.version,
|
|
37
|
+
pnpm: version('pnpm'),
|
|
38
|
+
opencode: version(opencode),
|
|
39
|
+
shell: process.env.SHELL,
|
|
40
|
+
},
|
|
41
|
+
null,
|
|
42
|
+
2,
|
|
43
|
+
),
|
|
44
|
+
{ flag: 'wx' },
|
|
45
|
+
);
|
|
@@ -0,0 +1,98 @@
|
|
|
1
|
+
import { execFile } from 'node:child_process';
|
|
2
|
+
import { createHash } from 'node:crypto';
|
|
3
|
+
import { mkdtemp, readFile, readdir, rm, writeFile } from 'node:fs/promises';
|
|
4
|
+
import { tmpdir } from 'node:os';
|
|
5
|
+
import { join, resolve } from 'node:path';
|
|
6
|
+
import { promisify } from 'node:util';
|
|
7
|
+
|
|
8
|
+
const execute = promisify(execFile);
|
|
9
|
+
|
|
10
|
+
async function editableHash(directory, prefix = '') {
|
|
11
|
+
const hash = createHash('sha256');
|
|
12
|
+
for (const entry of (await readdir(directory, { withFileTypes: true })).sort((a, b) =>
|
|
13
|
+
a.name.localeCompare(b.name),
|
|
14
|
+
)) {
|
|
15
|
+
if (['dist', 'node_modules'].includes(entry.name)) continue;
|
|
16
|
+
const relative = prefix ? `${prefix}/${entry.name}` : entry.name;
|
|
17
|
+
const path = join(directory, entry.name);
|
|
18
|
+
if (entry.isDirectory()) hash.update(await editableHash(path, relative));
|
|
19
|
+
else if (entry.isFile())
|
|
20
|
+
hash
|
|
21
|
+
.update(relative)
|
|
22
|
+
.update('\0')
|
|
23
|
+
.update(await readFile(path));
|
|
24
|
+
}
|
|
25
|
+
return hash.digest();
|
|
26
|
+
}
|
|
27
|
+
|
|
28
|
+
export async function createInstalledHelp(packageDirectory, receiptPath) {
|
|
29
|
+
const packagePath = resolve(packageDirectory);
|
|
30
|
+
const sourceHash = (await editableHash(packagePath)).toString('hex');
|
|
31
|
+
const pkg = JSON.parse(await readFile(join(packagePath, 'package.json'), 'utf8'));
|
|
32
|
+
const binary = Object.keys(pkg.bin ?? {})[0];
|
|
33
|
+
if (!binary) throw new TypeError('Package has no binary');
|
|
34
|
+
const manifest = JSON.parse(await readFile(join(packagePath, 'capabilities.json'), 'utf8'));
|
|
35
|
+
const commands = manifest.commands.map((item) => item.command);
|
|
36
|
+
const scratch = await mkdtemp(join(tmpdir(), 'intermesh-preliminary-help-'));
|
|
37
|
+
const environment = Object.fromEntries(
|
|
38
|
+
Object.entries(process.env).filter(
|
|
39
|
+
([name]) => !['OPENROUTER_API_KEY', 'DEEPSEEK_API_KEY'].includes(name),
|
|
40
|
+
),
|
|
41
|
+
);
|
|
42
|
+
try {
|
|
43
|
+
await execute('pnpm', ['build'], { cwd: packagePath, env: environment, timeout: 120_000 });
|
|
44
|
+
const tarball = join(scratch, 'candidate.tgz');
|
|
45
|
+
await execute('pnpm', ['pack', '--out', tarball, '--json'], {
|
|
46
|
+
cwd: packagePath,
|
|
47
|
+
env: environment,
|
|
48
|
+
timeout: 120_000,
|
|
49
|
+
});
|
|
50
|
+
await writeFile(join(scratch, 'package.json'), '{"private":true}');
|
|
51
|
+
await execute('pnpm', ['add', '--ignore-scripts', tarball], {
|
|
52
|
+
cwd: scratch,
|
|
53
|
+
env: environment,
|
|
54
|
+
timeout: 120_000,
|
|
55
|
+
});
|
|
56
|
+
const executable = join(scratch, 'node_modules/.bin', binary);
|
|
57
|
+
const help = {};
|
|
58
|
+
for (const command of ['', ...commands]) {
|
|
59
|
+
const args = command ? [...command.split(/\s+/u), '--help'] : ['--help'];
|
|
60
|
+
const result = await execute(executable, args, {
|
|
61
|
+
cwd: scratch,
|
|
62
|
+
env: environment,
|
|
63
|
+
timeout: 30_000,
|
|
64
|
+
});
|
|
65
|
+
help[command || '$root'] = result.stdout;
|
|
66
|
+
}
|
|
67
|
+
const currentHash = (await editableHash(packagePath)).toString('hex');
|
|
68
|
+
if (currentHash !== sourceHash)
|
|
69
|
+
throw new TypeError('Editable package changed during installed-help capture');
|
|
70
|
+
const receipt = {
|
|
71
|
+
schema_version: '1.0.0',
|
|
72
|
+
editable_source_sha256: sourceHash,
|
|
73
|
+
binary,
|
|
74
|
+
commands,
|
|
75
|
+
help,
|
|
76
|
+
preliminary_only: true,
|
|
77
|
+
};
|
|
78
|
+
await writeFile(receiptPath, `${JSON.stringify(receipt, null, 2)}\n`, { flag: 'wx' });
|
|
79
|
+
return receipt;
|
|
80
|
+
} finally {
|
|
81
|
+
await rm(scratch, { recursive: true, force: true });
|
|
82
|
+
}
|
|
83
|
+
}
|
|
84
|
+
|
|
85
|
+
export async function verifyInstalledHelp(packageDirectory, receiptPath) {
|
|
86
|
+
const receipt = JSON.parse(await readFile(receiptPath, 'utf8'));
|
|
87
|
+
const currentHash = (await editableHash(resolve(packageDirectory))).toString('hex');
|
|
88
|
+
if (receipt.preliminary_only !== true || receipt.editable_source_sha256 !== currentHash)
|
|
89
|
+
throw new TypeError('Installed-help receipt does not match current editable source');
|
|
90
|
+
return receipt;
|
|
91
|
+
}
|
|
92
|
+
|
|
93
|
+
if (process.argv[1] === new URL(import.meta.url).pathname) {
|
|
94
|
+
const [command, packageDirectory, receiptPath] = process.argv.slice(2);
|
|
95
|
+
if (command === 'create') await createInstalledHelp(packageDirectory, receiptPath);
|
|
96
|
+
else if (command === 'verify') await verifyInstalledHelp(packageDirectory, receiptPath);
|
|
97
|
+
else throw new TypeError('Expected create or verify');
|
|
98
|
+
}
|