metaharness 0.1.4 → 0.1.6

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.
Files changed (160) hide show
  1. package/dist/diag.d.ts +1 -1
  2. package/dist/diag.d.ts.map +1 -1
  3. package/dist/diag.js +13 -9
  4. package/dist/diag.js.map +1 -1
  5. package/dist/eject.js +1 -1
  6. package/dist/eject.js.map +1 -1
  7. package/dist/external-template.js +1 -1
  8. package/dist/external-template.js.map +1 -1
  9. package/dist/index.d.ts +1 -1
  10. package/dist/index.d.ts.map +1 -1
  11. package/dist/index.js +14 -6
  12. package/dist/index.js.map +1 -1
  13. package/dist/manifest.d.ts +1 -1
  14. package/dist/mcp-cmd.js +2 -2
  15. package/dist/mcp-cmd.js.map +1 -1
  16. package/dist/subcommands.d.ts +1 -1
  17. package/dist/subcommands.js +3 -3
  18. package/dist/subcommands.js.map +1 -1
  19. package/dist/validate.js +1 -1
  20. package/dist/validate.js.map +1 -1
  21. package/dist/witness-client.js +1 -1
  22. package/dist/witness-client.js.map +1 -1
  23. package/package.json +3 -3
  24. package/templates/minimal/CLAUDE.md.tmpl +1 -1
  25. package/templates/minimal/__tests__/smoke.test.ts.tmpl +37 -0
  26. package/templates/minimal/bin/cli.js.tmpl +100 -0
  27. package/templates/minimal/manifest.json +4 -1
  28. package/templates/minimal/package.json.tmpl +7 -6
  29. package/templates/minimal/src/init.ts.tmpl +2 -2
  30. package/templates/minimal/tsconfig.json.tmpl +19 -0
  31. package/templates/vertical_advertising/CLAUDE.md.tmpl +1 -1
  32. package/templates/vertical_advertising/__tests__/smoke.test.ts.tmpl +37 -0
  33. package/templates/vertical_advertising/bin/cli.js.tmpl +100 -0
  34. package/templates/vertical_advertising/manifest.json +15 -0
  35. package/templates/vertical_advertising/package.json.tmpl +6 -6
  36. package/templates/vertical_advertising/src/init.ts.tmpl +2 -2
  37. package/templates/vertical_advertising/tsconfig.json.tmpl +19 -0
  38. package/templates/vertical_agentics/CLAUDE.md.tmpl +1 -1
  39. package/templates/vertical_agentics/__tests__/smoke.test.ts.tmpl +37 -0
  40. package/templates/vertical_agentics/bin/cli.js.tmpl +100 -0
  41. package/templates/vertical_agentics/manifest.json +15 -0
  42. package/templates/vertical_agentics/package.json.tmpl +6 -6
  43. package/templates/vertical_agentics/src/init.ts.tmpl +2 -2
  44. package/templates/vertical_agentics/tsconfig.json.tmpl +19 -0
  45. package/templates/vertical_ai/CLAUDE.md.tmpl +1 -1
  46. package/templates/vertical_ai/__tests__/smoke.test.ts.tmpl +37 -0
  47. package/templates/vertical_ai/bin/cli.js.tmpl +100 -0
  48. package/templates/vertical_ai/manifest.json +15 -0
  49. package/templates/vertical_ai/package.json.tmpl +6 -6
  50. package/templates/vertical_ai/src/init.ts.tmpl +2 -2
  51. package/templates/vertical_ai/tsconfig.json.tmpl +19 -0
  52. package/templates/vertical_business/CLAUDE.md.tmpl +1 -1
  53. package/templates/vertical_business/__tests__/smoke.test.ts.tmpl +37 -0
  54. package/templates/vertical_business/bin/cli.js.tmpl +100 -0
  55. package/templates/vertical_business/manifest.json +15 -0
  56. package/templates/vertical_business/package.json.tmpl +6 -6
  57. package/templates/vertical_business/src/init.ts.tmpl +2 -2
  58. package/templates/vertical_business/tsconfig.json.tmpl +19 -0
  59. package/templates/vertical_coding/CLAUDE.md.tmpl +1 -1
  60. package/templates/vertical_coding/__tests__/smoke.test.ts.tmpl +37 -0
  61. package/templates/vertical_coding/bin/cli.js.tmpl +100 -0
  62. package/templates/vertical_coding/manifest.json +15 -0
  63. package/templates/vertical_coding/package.json.tmpl +6 -6
  64. package/templates/vertical_coding/src/init.ts.tmpl +2 -2
  65. package/templates/vertical_coding/tsconfig.json.tmpl +19 -0
  66. package/templates/vertical_crm/CLAUDE.md.tmpl +1 -1
  67. package/templates/vertical_crm/__tests__/smoke.test.ts.tmpl +37 -0
  68. package/templates/vertical_crm/bin/cli.js.tmpl +100 -0
  69. package/templates/vertical_crm/manifest.json +15 -0
  70. package/templates/vertical_crm/package.json.tmpl +6 -6
  71. package/templates/vertical_crm/src/init.ts.tmpl +2 -2
  72. package/templates/vertical_crm/tsconfig.json.tmpl +19 -0
  73. package/templates/vertical_devops/CLAUDE.md.tmpl +1 -1
  74. package/templates/vertical_devops/__tests__/smoke.test.ts.tmpl +37 -0
  75. package/templates/vertical_devops/bin/cli.js.tmpl +100 -0
  76. package/templates/vertical_devops/manifest.json +15 -0
  77. package/templates/vertical_devops/package.json.tmpl +6 -6
  78. package/templates/vertical_devops/src/init.ts.tmpl +2 -2
  79. package/templates/vertical_devops/tsconfig.json.tmpl +19 -0
  80. package/templates/vertical_education/CLAUDE.md.tmpl +1 -1
  81. package/templates/vertical_education/__tests__/smoke.test.ts.tmpl +37 -0
  82. package/templates/vertical_education/bin/cli.js.tmpl +100 -0
  83. package/templates/vertical_education/manifest.json +15 -0
  84. package/templates/vertical_education/package.json.tmpl +6 -6
  85. package/templates/vertical_education/src/init.ts.tmpl +2 -2
  86. package/templates/vertical_education/tsconfig.json.tmpl +19 -0
  87. package/templates/vertical_exotic/CLAUDE.md.tmpl +1 -1
  88. package/templates/vertical_exotic/__tests__/smoke.test.ts.tmpl +37 -0
  89. package/templates/vertical_exotic/bin/cli.js.tmpl +100 -0
  90. package/templates/vertical_exotic/manifest.json +15 -0
  91. package/templates/vertical_exotic/package.json.tmpl +6 -6
  92. package/templates/vertical_exotic/src/init.ts.tmpl +2 -2
  93. package/templates/vertical_exotic/tsconfig.json.tmpl +19 -0
  94. package/templates/vertical_gaming/CLAUDE.md.tmpl +1 -1
  95. package/templates/vertical_gaming/__tests__/smoke.test.ts.tmpl +37 -0
  96. package/templates/vertical_gaming/bin/cli.js.tmpl +100 -0
  97. package/templates/vertical_gaming/manifest.json +15 -0
  98. package/templates/vertical_gaming/package.json.tmpl +6 -6
  99. package/templates/vertical_gaming/src/init.ts.tmpl +2 -2
  100. package/templates/vertical_gaming/tsconfig.json.tmpl +19 -0
  101. package/templates/vertical_health/CLAUDE.md.tmpl +1 -1
  102. package/templates/vertical_health/__tests__/smoke.test.ts.tmpl +37 -0
  103. package/templates/vertical_health/bin/cli.js.tmpl +100 -0
  104. package/templates/vertical_health/manifest.json +15 -0
  105. package/templates/vertical_health/package.json.tmpl +6 -6
  106. package/templates/vertical_health/src/init.ts.tmpl +2 -2
  107. package/templates/vertical_health/tsconfig.json.tmpl +19 -0
  108. package/templates/vertical_legal/__tests__/smoke.test.ts.tmpl +37 -0
  109. package/templates/vertical_legal/bin/cli.js.tmpl +100 -0
  110. package/templates/vertical_legal/manifest.json +15 -0
  111. package/templates/vertical_legal/package.json.tmpl +4 -4
  112. package/templates/vertical_legal/src/init.ts.tmpl +2 -2
  113. package/templates/vertical_legal/tsconfig.json.tmpl +19 -0
  114. package/templates/vertical_marketing/CLAUDE.md.tmpl +1 -1
  115. package/templates/vertical_marketing/__tests__/smoke.test.ts.tmpl +37 -0
  116. package/templates/vertical_marketing/bin/cli.js.tmpl +100 -0
  117. package/templates/vertical_marketing/manifest.json +15 -0
  118. package/templates/vertical_marketing/package.json.tmpl +6 -6
  119. package/templates/vertical_marketing/src/init.ts.tmpl +2 -2
  120. package/templates/vertical_marketing/tsconfig.json.tmpl +19 -0
  121. package/templates/vertical_repo-maintainer/CLAUDE.md.tmpl +1 -1
  122. package/templates/vertical_repo-maintainer/__tests__/smoke.test.ts.tmpl +37 -0
  123. package/templates/vertical_repo-maintainer/bin/cli.js.tmpl +100 -0
  124. package/templates/vertical_repo-maintainer/manifest.json +15 -0
  125. package/templates/vertical_repo-maintainer/package.json.tmpl +6 -6
  126. package/templates/vertical_repo-maintainer/src/init.ts.tmpl +2 -2
  127. package/templates/vertical_repo-maintainer/tsconfig.json.tmpl +19 -0
  128. package/templates/vertical_research/__tests__/smoke.test.ts.tmpl +37 -0
  129. package/templates/vertical_research/bin/cli.js.tmpl +100 -0
  130. package/templates/vertical_research/manifest.json +15 -0
  131. package/templates/vertical_research/package.json.tmpl +4 -4
  132. package/templates/vertical_research/src/init.ts.tmpl +2 -2
  133. package/templates/vertical_research/tsconfig.json.tmpl +19 -0
  134. package/templates/vertical_ruview/CLAUDE.md.tmpl +1 -1
  135. package/templates/vertical_ruview/__tests__/smoke.test.ts.tmpl +37 -0
  136. package/templates/vertical_ruview/bin/cli.js.tmpl +100 -0
  137. package/templates/vertical_ruview/manifest.json +15 -0
  138. package/templates/vertical_ruview/package.json.tmpl +6 -6
  139. package/templates/vertical_ruview/src/init.ts.tmpl +2 -2
  140. package/templates/vertical_ruview/tsconfig.json.tmpl +19 -0
  141. package/templates/vertical_sales/CLAUDE.md.tmpl +1 -1
  142. package/templates/vertical_sales/__tests__/smoke.test.ts.tmpl +37 -0
  143. package/templates/vertical_sales/bin/cli.js.tmpl +100 -0
  144. package/templates/vertical_sales/manifest.json +15 -0
  145. package/templates/vertical_sales/package.json.tmpl +6 -6
  146. package/templates/vertical_sales/src/init.ts.tmpl +2 -2
  147. package/templates/vertical_sales/tsconfig.json.tmpl +19 -0
  148. package/templates/vertical_support/CLAUDE.md.tmpl +1 -1
  149. package/templates/vertical_support/__tests__/smoke.test.ts.tmpl +37 -0
  150. package/templates/vertical_support/bin/cli.js.tmpl +100 -0
  151. package/templates/vertical_support/manifest.json +15 -0
  152. package/templates/vertical_support/package.json.tmpl +6 -6
  153. package/templates/vertical_support/src/init.ts.tmpl +2 -2
  154. package/templates/vertical_support/tsconfig.json.tmpl +19 -0
  155. package/templates/vertical_trading/__tests__/smoke.test.ts.tmpl +37 -0
  156. package/templates/vertical_trading/bin/cli.js.tmpl +100 -0
  157. package/templates/vertical_trading/manifest.json +15 -0
  158. package/templates/vertical_trading/package.json.tmpl +4 -4
  159. package/templates/vertical_trading/src/init.ts.tmpl +2 -2
  160. package/templates/vertical_trading/tsconfig.json.tmpl +19 -0
package/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "metaharness",
3
- "version": "0.1.4",
3
+ "version": "0.1.6",
4
4
  "description": "MetaHarness — mint a custom AI agent harness from any repo. Browser Studio + `npx metaharness` CLI. Runs on Claude Code, Codex, pi.dev, Hermes, OpenClaw, RVM.",
5
5
  "homepage": "https://github.com/ruvnet/agent-harness-generator",
6
6
  "repository": {
@@ -99,10 +99,10 @@
99
99
  "prompts": "^2.4.2"
100
100
  },
101
101
  "peerDependencies": {
102
- "@ruflo/kernel": "0.1.0"
102
+ "@metaharness/kernel": "0.1.0"
103
103
  },
104
104
  "peerDependenciesMeta": {
105
- "@ruflo/kernel": {
105
+ "@metaharness/kernel": {
106
106
  "optional": true
107
107
  }
108
108
  },
@@ -20,4 +20,4 @@ After `{{name}} init`, the following are available:
20
20
 
21
21
  ## Architecture
22
22
 
23
- This harness uses [@ruflo/kernel](https://www.npmjs.com/package/@ruflo/kernel) for its primitives. The kernel is a Rust-compiled WASM module with a NAPI-RS native fallback — same code runs identically on every platform.
23
+ This harness uses [@metaharness/kernel](https://www.npmjs.com/package/@metaharness/kernel) for its primitives. The kernel is a Rust-compiled WASM module with a NAPI-RS native fallback — same code runs identically on every platform.
@@ -0,0 +1,37 @@
1
+ // SPDX-License-Identifier: MIT
2
+ // Generated by metaharness — a real smoke test for {{name}}.
3
+ //
4
+ // This is NOT a placeholder: it boots the actual kernel + host adapter the
5
+ // harness depends on, so `npm test` fails loudly if @metaharness/kernel or
6
+ // @metaharness/host-{{host}} is missing, broken, or version-skewed. It is the
7
+ // fastest signal that `npm install` produced a runnable harness.
8
+
9
+ import { describe, it, expect } from 'vitest';
10
+ import { loadKernel } from '@metaharness/kernel';
11
+ import adapter from '@metaharness/host-{{host}}';
12
+ import { run } from '../bin/cli.js';
13
+
14
+ describe('{{name}} — install smoke test', () => {
15
+ it('loads the kernel and reports a version + a known backend', async () => {
16
+ const kernel = await loadKernel();
17
+ const info = kernel.kernelInfo();
18
+ expect(typeof info.version).toBe('string');
19
+ expect(info.version.length).toBeGreaterThan(0);
20
+ expect(['native', 'wasm', 'js']).toContain(kernel.backend);
21
+ });
22
+
23
+ it('resolves the host adapter with a name', () => {
24
+ expect(typeof adapter.name).toBe('string');
25
+ expect(adapter.name.length).toBeGreaterThan(0);
26
+ });
27
+
28
+ it('the CLI doctor command succeeds (exit 0)', async () => {
29
+ const code = await run(['doctor']);
30
+ expect(code).toBe(0);
31
+ });
32
+
33
+ it('an unknown CLI command exits non-zero', async () => {
34
+ const code = await run(['definitely-not-a-command']);
35
+ expect(code).not.toBe(0);
36
+ });
37
+ });
@@ -0,0 +1,100 @@
1
+ #!/usr/bin/env node
2
+ // SPDX-License-Identifier: MIT
3
+ // Generated by metaharness — the `{{name}}` CLI entry point.
4
+ //
5
+ // This is plain ESM JavaScript on purpose: it runs as-is via `npx {{name}}`
6
+ // with NO build step. `npm run build` (tsc) is only needed if you extend the
7
+ // TypeScript in src/. The published package ships this file directly (see the
8
+ // "bin" + "files" fields in package.json), so `npx {{name}}` works the moment
9
+ // `npm install` has resolved @metaharness/kernel + @metaharness/host-{{host}}.
10
+
11
+ import { loadKernel } from '@metaharness/kernel';
12
+ import adapter from '@metaharness/host-{{host}}';
13
+
14
+ const HARNESS_NAME = '{{name}}';
15
+
16
+ /** `{{name}} init` — boot the kernel + host adapter and report status. */
17
+ async function init() {
18
+ const kernel = await loadKernel();
19
+ const info = kernel.kernelInfo();
20
+ console.log(`${HARNESS_NAME} — kernel ${info.version} (${kernel.backend})`);
21
+ console.log(`Host adapter: ${adapter.name}`);
22
+ console.log(`Run \`${HARNESS_NAME} doctor\` to verify the install.`);
23
+ return 0;
24
+ }
25
+
26
+ /** `{{name}} doctor` — verify the install end-to-end (kernel + host resolve). */
27
+ async function doctor() {
28
+ const kernel = await loadKernel();
29
+ const info = kernel.kernelInfo();
30
+ const checks = [
31
+ ['kernel loads', !!kernel],
32
+ ['kernel reports a version', typeof info.version === 'string' && info.version.length > 0],
33
+ ['kernel backend is native|wasm|js', ['native', 'wasm', 'js'].includes(kernel.backend)],
34
+ ['host adapter has a name', typeof adapter?.name === 'string' && adapter.name.length > 0],
35
+ ];
36
+ let ok = true;
37
+ for (const [label, pass] of checks) {
38
+ console.log(`${pass ? 'PASS' : 'FAIL'} ${label}`);
39
+ if (!pass) ok = false;
40
+ }
41
+ console.log(
42
+ ok
43
+ ? `\n${HARNESS_NAME}: all checks passed (kernel ${info.version}, ${kernel.backend} backend, host ${adapter.name})`
44
+ : `\n${HARNESS_NAME}: doctor found problems`,
45
+ );
46
+ return ok ? 0 : 1;
47
+ }
48
+
49
+ /**
50
+ * Dispatch one CLI invocation. Exported (not just run on import) so a test can
51
+ * drive it without spawning a subprocess. Returns the intended exit code.
52
+ */
53
+ export async function run(argv) {
54
+ const cmd = argv[0] ?? 'init';
55
+ switch (cmd) {
56
+ case 'init':
57
+ return init();
58
+ case 'doctor':
59
+ return doctor();
60
+ case '--version':
61
+ case '-v': {
62
+ const kernel = await loadKernel();
63
+ console.log(kernel.version());
64
+ return 0;
65
+ }
66
+ case '--help':
67
+ case '-h':
68
+ console.log(`Usage: ${HARNESS_NAME} <command>\n\n init boot the kernel + host adapter (default)\n doctor verify the install end-to-end\n --version print the kernel version`);
69
+ return 0;
70
+ default:
71
+ console.error(`Unknown command: ${cmd}. Try \`${HARNESS_NAME} --help\`.`);
72
+ return 2;
73
+ }
74
+ }
75
+
76
+ // CLI guard: execute only when invoked directly (not when imported by a test).
77
+ // npm's bin shims pass a NON-normalized argv[1] (e.g. ".../.bin/../<pkg>/bin/cli.js"
78
+ // on Windows) and may differ in case, so realpath BOTH sides before comparing —
79
+ // a naive string === misses the npx/shim path and the CLI silently no-ops.
80
+ import { fileURLToPath } from 'node:url';
81
+ import { realpathSync } from 'node:fs';
82
+ import { argv } from 'node:process';
83
+ const invokedDirectly = (() => {
84
+ if (!argv[1]) return false;
85
+ try {
86
+ const a = realpathSync(argv[1]);
87
+ const b = realpathSync(fileURLToPath(import.meta.url));
88
+ return process.platform === 'win32' ? a.toLowerCase() === b.toLowerCase() : a === b;
89
+ } catch {
90
+ return false;
91
+ }
92
+ })();
93
+ if (invokedDirectly) {
94
+ run(argv.slice(2))
95
+ .then((code) => process.exit(code))
96
+ .catch((err) => {
97
+ console.error(err);
98
+ process.exit(1);
99
+ });
100
+ }
@@ -3,11 +3,14 @@
3
3
  "description": "Minimal harness with kernel + one host adapter + an init entry point",
4
4
  "files": [
5
5
  { "src": "package.json.tmpl", "dst": "package.json", "render": true },
6
+ { "src": "tsconfig.json.tmpl", "dst": "tsconfig.json", "render": true },
6
7
  { "src": "CLAUDE.md.tmpl", "dst": "CLAUDE.md", "render": true },
7
8
  { "src": "README.md.tmpl", "dst": "README.md", "render": true },
8
9
  { "src": ".claude/settings.json.tmpl", "dst": ".claude/settings.json", "render": true },
9
10
  { "src": ".claude-plugin/plugin.json.tmpl", "dst": ".claude-plugin/plugin.json", "render": true },
10
- { "src": "src/init.ts.tmpl", "dst": "src/init.ts", "render": true }
11
+ { "src": "bin/cli.js.tmpl", "dst": "bin/cli.js", "render": true },
12
+ { "src": "src/init.ts.tmpl", "dst": "src/init.ts", "render": true },
13
+ { "src": "__tests__/smoke.test.ts.tmpl", "dst": "__tests__/smoke.test.ts", "render": true }
11
14
  ],
12
15
  "vars": [
13
16
  { "name": "name", "prompt": "Harness name (kebab-case)", "validate": "^[a-z0-9-]+$" },
@@ -4,17 +4,18 @@
4
4
  "description": "{{description}}",
5
5
  "type": "module",
6
6
  "bin": {
7
- "{{name}}": "./bin/{{name}}.js"
7
+ "{{name}}": "./bin/cli.js"
8
8
  },
9
- "files": ["bin/**", "dist/**", "templates/**", ".claude/**", "CLAUDE.md", "README.md", "LICENSE"],
9
+ "files": ["bin/**", "dist/**", "src/**", "tsconfig.json", ".claude/**", "CLAUDE.md", "README.md", "LICENSE"],
10
10
  "scripts": {
11
11
  "build": "tsc",
12
- "test": "vitest run --passWithNoTests",
13
- "init": "node ./dist/init.js"
12
+ "test": "vitest run",
13
+ "init": "node ./bin/cli.js init",
14
+ "doctor": "node ./bin/cli.js doctor"
14
15
  },
15
16
  "dependencies": {
16
- "@ruflo/kernel": "^0.1.0",
17
- "@ruflo/host-{{host}}": "^0.1.0"
17
+ "@metaharness/kernel": "^0.1.0",
18
+ "@metaharness/host-{{host}}": "^0.1.0"
18
19
  },
19
20
  "devDependencies": {
20
21
  "@types/node": "^20.0.0",
@@ -1,8 +1,8 @@
1
1
  // SPDX-License-Identifier: MIT
2
2
  // Generated by create-agent-harness — your harness's `{{name}} init` entry.
3
3
 
4
- import { loadKernel } from '@ruflo/kernel';
5
- import adapter from '@ruflo/host-{{host}}';
4
+ import { loadKernel } from '@metaharness/kernel';
5
+ import adapter from '@metaharness/host-{{host}}';
6
6
 
7
7
  const HARNESS_NAME = '{{name}}';
8
8
 
@@ -0,0 +1,19 @@
1
+ {
2
+ "compilerOptions": {
3
+ "target": "ES2022",
4
+ "module": "NodeNext",
5
+ "moduleResolution": "NodeNext",
6
+ "lib": ["ES2022"],
7
+ "outDir": "./dist",
8
+ "rootDir": "./src",
9
+ "declaration": true,
10
+ "declarationMap": true,
11
+ "sourceMap": true,
12
+ "strict": true,
13
+ "esModuleInterop": true,
14
+ "skipLibCheck": true,
15
+ "forceConsistentCasingInFileNames": true
16
+ },
17
+ "include": ["src/**/*.ts"],
18
+ "exclude": ["node_modules", "dist", "__tests__"]
19
+ }
@@ -27,4 +27,4 @@
27
27
 
28
28
  ## Architecture
29
29
 
30
- This harness uses [@ruflo/kernel](https://www.npmjs.com/package/@ruflo/kernel) — a Rust-compiled WASM module with a NAPI-RS native fallback — so the same code runs identically on every platform.
30
+ This harness uses [@metaharness/kernel](https://www.npmjs.com/package/@metaharness/kernel) — a Rust-compiled WASM module with a NAPI-RS native fallback — so the same code runs identically on every platform.
@@ -0,0 +1,37 @@
1
+ // SPDX-License-Identifier: MIT
2
+ // Generated by metaharness — a real smoke test for {{name}}.
3
+ //
4
+ // This is NOT a placeholder: it boots the actual kernel + host adapter the
5
+ // harness depends on, so `npm test` fails loudly if @metaharness/kernel or
6
+ // @metaharness/host-{{host}} is missing, broken, or version-skewed. It is the
7
+ // fastest signal that `npm install` produced a runnable harness.
8
+
9
+ import { describe, it, expect } from 'vitest';
10
+ import { loadKernel } from '@metaharness/kernel';
11
+ import adapter from '@metaharness/host-{{host}}';
12
+ import { run } from '../bin/cli.js';
13
+
14
+ describe('{{name}} — install smoke test', () => {
15
+ it('loads the kernel and reports a version + a known backend', async () => {
16
+ const kernel = await loadKernel();
17
+ const info = kernel.kernelInfo();
18
+ expect(typeof info.version).toBe('string');
19
+ expect(info.version.length).toBeGreaterThan(0);
20
+ expect(['native', 'wasm', 'js']).toContain(kernel.backend);
21
+ });
22
+
23
+ it('resolves the host adapter with a name', () => {
24
+ expect(typeof adapter.name).toBe('string');
25
+ expect(adapter.name.length).toBeGreaterThan(0);
26
+ });
27
+
28
+ it('the CLI doctor command succeeds (exit 0)', async () => {
29
+ const code = await run(['doctor']);
30
+ expect(code).toBe(0);
31
+ });
32
+
33
+ it('an unknown CLI command exits non-zero', async () => {
34
+ const code = await run(['definitely-not-a-command']);
35
+ expect(code).not.toBe(0);
36
+ });
37
+ });
@@ -0,0 +1,100 @@
1
+ #!/usr/bin/env node
2
+ // SPDX-License-Identifier: MIT
3
+ // Generated by metaharness — the `{{name}}` CLI entry point.
4
+ //
5
+ // This is plain ESM JavaScript on purpose: it runs as-is via `npx {{name}}`
6
+ // with NO build step. `npm run build` (tsc) is only needed if you extend the
7
+ // TypeScript in src/. The published package ships this file directly (see the
8
+ // "bin" + "files" fields in package.json), so `npx {{name}}` works the moment
9
+ // `npm install` has resolved @metaharness/kernel + @metaharness/host-{{host}}.
10
+
11
+ import { loadKernel } from '@metaharness/kernel';
12
+ import adapter from '@metaharness/host-{{host}}';
13
+
14
+ const HARNESS_NAME = '{{name}}';
15
+
16
+ /** `{{name}} init` — boot the kernel + host adapter and report status. */
17
+ async function init() {
18
+ const kernel = await loadKernel();
19
+ const info = kernel.kernelInfo();
20
+ console.log(`${HARNESS_NAME} — kernel ${info.version} (${kernel.backend})`);
21
+ console.log(`Host adapter: ${adapter.name}`);
22
+ console.log(`Run \`${HARNESS_NAME} doctor\` to verify the install.`);
23
+ return 0;
24
+ }
25
+
26
+ /** `{{name}} doctor` — verify the install end-to-end (kernel + host resolve). */
27
+ async function doctor() {
28
+ const kernel = await loadKernel();
29
+ const info = kernel.kernelInfo();
30
+ const checks = [
31
+ ['kernel loads', !!kernel],
32
+ ['kernel reports a version', typeof info.version === 'string' && info.version.length > 0],
33
+ ['kernel backend is native|wasm|js', ['native', 'wasm', 'js'].includes(kernel.backend)],
34
+ ['host adapter has a name', typeof adapter?.name === 'string' && adapter.name.length > 0],
35
+ ];
36
+ let ok = true;
37
+ for (const [label, pass] of checks) {
38
+ console.log(`${pass ? 'PASS' : 'FAIL'} ${label}`);
39
+ if (!pass) ok = false;
40
+ }
41
+ console.log(
42
+ ok
43
+ ? `\n${HARNESS_NAME}: all checks passed (kernel ${info.version}, ${kernel.backend} backend, host ${adapter.name})`
44
+ : `\n${HARNESS_NAME}: doctor found problems`,
45
+ );
46
+ return ok ? 0 : 1;
47
+ }
48
+
49
+ /**
50
+ * Dispatch one CLI invocation. Exported (not just run on import) so a test can
51
+ * drive it without spawning a subprocess. Returns the intended exit code.
52
+ */
53
+ export async function run(argv) {
54
+ const cmd = argv[0] ?? 'init';
55
+ switch (cmd) {
56
+ case 'init':
57
+ return init();
58
+ case 'doctor':
59
+ return doctor();
60
+ case '--version':
61
+ case '-v': {
62
+ const kernel = await loadKernel();
63
+ console.log(kernel.version());
64
+ return 0;
65
+ }
66
+ case '--help':
67
+ case '-h':
68
+ console.log(`Usage: ${HARNESS_NAME} <command>\n\n init boot the kernel + host adapter (default)\n doctor verify the install end-to-end\n --version print the kernel version`);
69
+ return 0;
70
+ default:
71
+ console.error(`Unknown command: ${cmd}. Try \`${HARNESS_NAME} --help\`.`);
72
+ return 2;
73
+ }
74
+ }
75
+
76
+ // CLI guard: execute only when invoked directly (not when imported by a test).
77
+ // npm's bin shims pass a NON-normalized argv[1] (e.g. ".../.bin/../<pkg>/bin/cli.js"
78
+ // on Windows) and may differ in case, so realpath BOTH sides before comparing —
79
+ // a naive string === misses the npx/shim path and the CLI silently no-ops.
80
+ import { fileURLToPath } from 'node:url';
81
+ import { realpathSync } from 'node:fs';
82
+ import { argv } from 'node:process';
83
+ const invokedDirectly = (() => {
84
+ if (!argv[1]) return false;
85
+ try {
86
+ const a = realpathSync(argv[1]);
87
+ const b = realpathSync(fileURLToPath(import.meta.url));
88
+ return process.platform === 'win32' ? a.toLowerCase() === b.toLowerCase() : a === b;
89
+ } catch {
90
+ return false;
91
+ }
92
+ })();
93
+ if (invokedDirectly) {
94
+ run(argv.slice(2))
95
+ .then((code) => process.exit(code))
96
+ .catch((err) => {
97
+ console.error(err);
98
+ process.exit(1);
99
+ });
100
+ }
@@ -58,6 +58,21 @@
58
58
  "src": ".claude/commands/doctor.md.tmpl",
59
59
  "dst": ".claude/commands/doctor.md",
60
60
  "render": true
61
+ },
62
+ {
63
+ "src": "tsconfig.json.tmpl",
64
+ "dst": "tsconfig.json",
65
+ "render": true
66
+ },
67
+ {
68
+ "src": "bin/cli.js.tmpl",
69
+ "dst": "bin/cli.js",
70
+ "render": true
71
+ },
72
+ {
73
+ "src": "__tests__/smoke.test.ts.tmpl",
74
+ "dst": "__tests__/smoke.test.ts",
75
+ "render": true
61
76
  }
62
77
  ],
63
78
  "vars": [
@@ -4,17 +4,17 @@
4
4
  "description": "{{description}}",
5
5
  "type": "module",
6
6
  "bin": {
7
- "{{name}}": "./bin/{{name}}.js"
7
+ "{{name}}": "./bin/cli.js"
8
8
  },
9
- "files": ["bin/**", "dist/**", ".claude/**", "CLAUDE.md", "README.md", "LICENSE"],
9
+ "files": ["bin/**", "dist/**", "src/**", "tsconfig.json", ".claude/**", "CLAUDE.md", "README.md", "LICENSE"],
10
10
  "scripts": {
11
11
  "build": "tsc",
12
- "test": "vitest run --passWithNoTests",
13
- "init": "node ./dist/init.js"
12
+ "test": "vitest run",
13
+ "init": "node ./bin/cli.js init", "doctor": "node ./bin/cli.js doctor"
14
14
  },
15
15
  "dependencies": {
16
- "@ruflo/kernel": "^0.1.0",
17
- "@ruflo/host-{{host}}": "^0.1.0"
16
+ "@metaharness/kernel": "^0.1.0",
17
+ "@metaharness/host-{{host}}": "^0.1.0"
18
18
  },
19
19
  "devDependencies": {
20
20
  "@types/node": "^20.0.0",
@@ -1,8 +1,8 @@
1
1
  // SPDX-License-Identifier: MIT
2
2
  // Generated by create-agent-harness — your harness's `{{name}} init` entry.
3
3
 
4
- import { loadKernel } from '@ruflo/kernel';
5
- import adapter from '@ruflo/host-{{host}}';
4
+ import { loadKernel } from '@metaharness/kernel';
5
+ import adapter from '@metaharness/host-{{host}}';
6
6
 
7
7
  const HARNESS_NAME = '{{name}}';
8
8
 
@@ -0,0 +1,19 @@
1
+ {
2
+ "compilerOptions": {
3
+ "target": "ES2022",
4
+ "module": "NodeNext",
5
+ "moduleResolution": "NodeNext",
6
+ "lib": ["ES2022"],
7
+ "outDir": "./dist",
8
+ "rootDir": "./src",
9
+ "declaration": true,
10
+ "declarationMap": true,
11
+ "sourceMap": true,
12
+ "strict": true,
13
+ "esModuleInterop": true,
14
+ "skipLibCheck": true,
15
+ "forceConsistentCasingInFileNames": true
16
+ },
17
+ "include": ["src/**/*.ts"],
18
+ "exclude": ["node_modules", "dist", "__tests__"]
19
+ }
@@ -29,4 +29,4 @@
29
29
 
30
30
  ## Architecture
31
31
 
32
- This harness uses [@ruflo/kernel](https://www.npmjs.com/package/@ruflo/kernel) — a Rust-compiled WASM module with a NAPI-RS native fallback — so the same code runs identically on every platform.
32
+ This harness uses [@metaharness/kernel](https://www.npmjs.com/package/@metaharness/kernel) — a Rust-compiled WASM module with a NAPI-RS native fallback — so the same code runs identically on every platform.
@@ -0,0 +1,37 @@
1
+ // SPDX-License-Identifier: MIT
2
+ // Generated by metaharness — a real smoke test for {{name}}.
3
+ //
4
+ // This is NOT a placeholder: it boots the actual kernel + host adapter the
5
+ // harness depends on, so `npm test` fails loudly if @metaharness/kernel or
6
+ // @metaharness/host-{{host}} is missing, broken, or version-skewed. It is the
7
+ // fastest signal that `npm install` produced a runnable harness.
8
+
9
+ import { describe, it, expect } from 'vitest';
10
+ import { loadKernel } from '@metaharness/kernel';
11
+ import adapter from '@metaharness/host-{{host}}';
12
+ import { run } from '../bin/cli.js';
13
+
14
+ describe('{{name}} — install smoke test', () => {
15
+ it('loads the kernel and reports a version + a known backend', async () => {
16
+ const kernel = await loadKernel();
17
+ const info = kernel.kernelInfo();
18
+ expect(typeof info.version).toBe('string');
19
+ expect(info.version.length).toBeGreaterThan(0);
20
+ expect(['native', 'wasm', 'js']).toContain(kernel.backend);
21
+ });
22
+
23
+ it('resolves the host adapter with a name', () => {
24
+ expect(typeof adapter.name).toBe('string');
25
+ expect(adapter.name.length).toBeGreaterThan(0);
26
+ });
27
+
28
+ it('the CLI doctor command succeeds (exit 0)', async () => {
29
+ const code = await run(['doctor']);
30
+ expect(code).toBe(0);
31
+ });
32
+
33
+ it('an unknown CLI command exits non-zero', async () => {
34
+ const code = await run(['definitely-not-a-command']);
35
+ expect(code).not.toBe(0);
36
+ });
37
+ });
@@ -0,0 +1,100 @@
1
+ #!/usr/bin/env node
2
+ // SPDX-License-Identifier: MIT
3
+ // Generated by metaharness — the `{{name}}` CLI entry point.
4
+ //
5
+ // This is plain ESM JavaScript on purpose: it runs as-is via `npx {{name}}`
6
+ // with NO build step. `npm run build` (tsc) is only needed if you extend the
7
+ // TypeScript in src/. The published package ships this file directly (see the
8
+ // "bin" + "files" fields in package.json), so `npx {{name}}` works the moment
9
+ // `npm install` has resolved @metaharness/kernel + @metaharness/host-{{host}}.
10
+
11
+ import { loadKernel } from '@metaharness/kernel';
12
+ import adapter from '@metaharness/host-{{host}}';
13
+
14
+ const HARNESS_NAME = '{{name}}';
15
+
16
+ /** `{{name}} init` — boot the kernel + host adapter and report status. */
17
+ async function init() {
18
+ const kernel = await loadKernel();
19
+ const info = kernel.kernelInfo();
20
+ console.log(`${HARNESS_NAME} — kernel ${info.version} (${kernel.backend})`);
21
+ console.log(`Host adapter: ${adapter.name}`);
22
+ console.log(`Run \`${HARNESS_NAME} doctor\` to verify the install.`);
23
+ return 0;
24
+ }
25
+
26
+ /** `{{name}} doctor` — verify the install end-to-end (kernel + host resolve). */
27
+ async function doctor() {
28
+ const kernel = await loadKernel();
29
+ const info = kernel.kernelInfo();
30
+ const checks = [
31
+ ['kernel loads', !!kernel],
32
+ ['kernel reports a version', typeof info.version === 'string' && info.version.length > 0],
33
+ ['kernel backend is native|wasm|js', ['native', 'wasm', 'js'].includes(kernel.backend)],
34
+ ['host adapter has a name', typeof adapter?.name === 'string' && adapter.name.length > 0],
35
+ ];
36
+ let ok = true;
37
+ for (const [label, pass] of checks) {
38
+ console.log(`${pass ? 'PASS' : 'FAIL'} ${label}`);
39
+ if (!pass) ok = false;
40
+ }
41
+ console.log(
42
+ ok
43
+ ? `\n${HARNESS_NAME}: all checks passed (kernel ${info.version}, ${kernel.backend} backend, host ${adapter.name})`
44
+ : `\n${HARNESS_NAME}: doctor found problems`,
45
+ );
46
+ return ok ? 0 : 1;
47
+ }
48
+
49
+ /**
50
+ * Dispatch one CLI invocation. Exported (not just run on import) so a test can
51
+ * drive it without spawning a subprocess. Returns the intended exit code.
52
+ */
53
+ export async function run(argv) {
54
+ const cmd = argv[0] ?? 'init';
55
+ switch (cmd) {
56
+ case 'init':
57
+ return init();
58
+ case 'doctor':
59
+ return doctor();
60
+ case '--version':
61
+ case '-v': {
62
+ const kernel = await loadKernel();
63
+ console.log(kernel.version());
64
+ return 0;
65
+ }
66
+ case '--help':
67
+ case '-h':
68
+ console.log(`Usage: ${HARNESS_NAME} <command>\n\n init boot the kernel + host adapter (default)\n doctor verify the install end-to-end\n --version print the kernel version`);
69
+ return 0;
70
+ default:
71
+ console.error(`Unknown command: ${cmd}. Try \`${HARNESS_NAME} --help\`.`);
72
+ return 2;
73
+ }
74
+ }
75
+
76
+ // CLI guard: execute only when invoked directly (not when imported by a test).
77
+ // npm's bin shims pass a NON-normalized argv[1] (e.g. ".../.bin/../<pkg>/bin/cli.js"
78
+ // on Windows) and may differ in case, so realpath BOTH sides before comparing —
79
+ // a naive string === misses the npx/shim path and the CLI silently no-ops.
80
+ import { fileURLToPath } from 'node:url';
81
+ import { realpathSync } from 'node:fs';
82
+ import { argv } from 'node:process';
83
+ const invokedDirectly = (() => {
84
+ if (!argv[1]) return false;
85
+ try {
86
+ const a = realpathSync(argv[1]);
87
+ const b = realpathSync(fileURLToPath(import.meta.url));
88
+ return process.platform === 'win32' ? a.toLowerCase() === b.toLowerCase() : a === b;
89
+ } catch {
90
+ return false;
91
+ }
92
+ })();
93
+ if (invokedDirectly) {
94
+ run(argv.slice(2))
95
+ .then((code) => process.exit(code))
96
+ .catch((err) => {
97
+ console.error(err);
98
+ process.exit(1);
99
+ });
100
+ }
@@ -68,6 +68,21 @@
68
68
  "src": ".claude/commands/doctor.md.tmpl",
69
69
  "dst": ".claude/commands/doctor.md",
70
70
  "render": true
71
+ },
72
+ {
73
+ "src": "tsconfig.json.tmpl",
74
+ "dst": "tsconfig.json",
75
+ "render": true
76
+ },
77
+ {
78
+ "src": "bin/cli.js.tmpl",
79
+ "dst": "bin/cli.js",
80
+ "render": true
81
+ },
82
+ {
83
+ "src": "__tests__/smoke.test.ts.tmpl",
84
+ "dst": "__tests__/smoke.test.ts",
85
+ "render": true
71
86
  }
72
87
  ],
73
88
  "vars": [
@@ -4,17 +4,17 @@
4
4
  "description": "{{description}}",
5
5
  "type": "module",
6
6
  "bin": {
7
- "{{name}}": "./bin/{{name}}.js"
7
+ "{{name}}": "./bin/cli.js"
8
8
  },
9
- "files": ["bin/**", "dist/**", ".claude/**", "CLAUDE.md", "README.md", "LICENSE"],
9
+ "files": ["bin/**", "dist/**", "src/**", "tsconfig.json", ".claude/**", "CLAUDE.md", "README.md", "LICENSE"],
10
10
  "scripts": {
11
11
  "build": "tsc",
12
- "test": "vitest run --passWithNoTests",
13
- "init": "node ./dist/init.js"
12
+ "test": "vitest run",
13
+ "init": "node ./bin/cli.js init", "doctor": "node ./bin/cli.js doctor"
14
14
  },
15
15
  "dependencies": {
16
- "@ruflo/kernel": "^0.1.0",
17
- "@ruflo/host-{{host}}": "^0.1.0"
16
+ "@metaharness/kernel": "^0.1.0",
17
+ "@metaharness/host-{{host}}": "^0.1.0"
18
18
  },
19
19
  "devDependencies": {
20
20
  "@types/node": "^20.0.0",