build(skill): add build:skill for a readable, non-bundled skill artifact (Phase 6)

`npm run build:skill` emits dist/obelisk-skill/: the whole scripts/ Core
compiled to readable JS (module structure + comments preserved, ~1:1 with
source, no bundling/minifying per ADR-0004), plus schema.sql, SKILL.md,
references/, and a package.json. It excludes app/, tests/, and release/, which
is what keeps the artifact small.

- tsconfig.skill.json compiles scripts/**/*.{ts,mjs} (allowJs) with
  rewriteRelativeImportExtensions, so the .ts specifiers inside the .mjs shells
  (runtime.mjs -> ./core.js, indexer.mjs -> ./providers/*.js, ./persist.js) are
  rewritten to .js. declaration:false — the skill needs no .d.ts.
- packaging/skill-package.json provides the artifact's package.json; it sets
  "type":"module" because the emitted .ts->.js files are ESM.
- build:skill runs tsc then copies schema.sql/SKILL.md/references/package.json.

Add tests/build-skill.test.mjs: runs the real build:skill, asserts the artifact
structure, that no emitted .js/.mjs still imports a .ts module, and that the
compiled artifact builds an index and answers a search end-to-end under plain
Node (no type-stripping) against a temp HOME.

Verified: suite 123/123, typecheck clean, artifact smoke run green.

Co-Authored-By: Claude Opus 4.8 <noreply@anthropic.com>
This commit is contained in:
tommy0103
2026-07-10 16:36:01 +08:00
co-authored by Claude Opus 4.8
parent c964653362
commit e44ab7a1da
4 changed files with 91 additions and 1 deletions
+2 -1
View File
@@ -9,7 +9,8 @@
"test": "node --experimental-test-module-mocks --test tests/*.test.mjs",
"typecheck": "tsc --noEmit && tsc --noEmit -p app/tsconfig.json",
"lint": "eslint .",
"build:core": "rm -rf dist && tsc -p tsconfig.build.json"
"build:core": "rm -rf dist && tsc -p tsconfig.build.json",
"build:skill": "rm -rf dist/obelisk-skill && tsc -p tsconfig.skill.json && cp scripts/schema.sql dist/obelisk-skill/scripts/ && cp SKILL.md dist/obelisk-skill/ && cp -R references dist/obelisk-skill/references && cp packaging/skill-package.json dist/obelisk-skill/package.json"
},
"devDependencies": {
"@eslint/js": "^10.0.1",