diff --git a/.github/workflows/publish.yml b/.github/workflows/publish.yml new file mode 100644 index 0000000..8378096 --- /dev/null +++ b/.github/workflows/publish.yml @@ -0,0 +1,41 @@ +name: publish + +on: + push: + tags: + - "v*" + +permissions: + contents: read + id-token: write + +jobs: + publish: + runs-on: ubuntu-latest + steps: + - name: Checkout + uses: actions/checkout@v4 + + - name: Setup Node.js + uses: actions/setup-node@v4 + with: + node-version: 22 + registry-url: https://registry.npmjs.org + + - name: Setup Bun + uses: oven-sh/setup-bun@v2 + + - name: Install dependencies + run: bun install --frozen-lockfile + + - name: Typecheck + run: bun run check + + - name: Test + run: bun test + + - name: Build + run: bun run build + + - name: Publish to npm + run: npm publish --provenance --access public diff --git a/.npmignore b/.npmignore new file mode 100644 index 0000000..7854fde --- /dev/null +++ b/.npmignore @@ -0,0 +1,14 @@ +# Defense-in-depth: `files` in package.json is the primary allowlist. +# This file excludes junk from the published tarball even if the +# allowlist is ever loosened. +test/ +docs/reports/ +docs/evidence/ +scripts/accept/ +worktrees/ +.github/ +*.log +bun.lock +coverage/ +.nyc_output/ +*.tsbuildinfo diff --git a/LICENSE b/LICENSE new file mode 100644 index 0000000..5e3e058 --- /dev/null +++ b/LICENSE @@ -0,0 +1,21 @@ +MIT License + +Copyright (c) 2026 Heretek-AI + +Permission is hereby granted, free of charge, to any person obtaining a copy +of this software and associated documentation files (the "Software"), to deal +in the Software without restriction, including without limitation the rights +to use, copy, modify, merge, publish, distribute, sublicense, and/or sell +copies of the Software, and to permit persons to whom the Software is +furnished to do so, subject to the following conditions: + +The above copyright notice and this permission notice shall be included in all +copies or substantial portions of the Software. + +THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR +IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY, +FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE +AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER +LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM, +OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE +SOFTWARE. diff --git a/package.json b/package.json index 6fa7f2a..29c243e 100644 --- a/package.json +++ b/package.json @@ -2,14 +2,57 @@ "name": "@heretek-ai/opencode-harness", "version": "1.0.0", "description": "Lean OpenCode v2 in-process harness plugin: Hashline edits, AST codemods, KV-cache-safe context budgeting, permission guards, and DOM geometry auditing.", - "type": "module", - "main": "./src/index.ts", - "exports": { - ".": "./src/index.ts" + "license": "MIT", + "repository": { + "type": "git", + "url": "git+https://github.com/Heretek-AI/opencode-harness.git" }, + "homepage": "https://github.com/Heretek-AI/opencode-harness", + "bugs": { + "url": "https://github.com/Heretek-AI/opencode-harness/issues" + }, + "author": "Heretek-AI", + "keywords": [ + "opencode", + "opencode-plugin", + "hashline", + "ast-codemod", + "permission-guard", + "circuit-breaker", + "context-budget", + "dom-audit" + ], + "engines": { + "bun": ">=1.0.0", + "node": ">=22.0.0" + }, + "sideEffects": false, + "publishConfig": { + "access": "public", + "provenance": true + }, + "type": "module", + "main": "./dist/index.js", + "types": "./dist/index.d.ts", + "exports": { + ".": { + "types": "./dist/index.d.ts", + "import": "./dist/index.js", + "default": "./dist/index.js" + } + }, + "files": [ + "dist", + "src", + "README.md", + "LICENSE", + "AGENTS.md" + ], "scripts": { "check": "tsc --noEmit", "test": "bun test", + "build": "tsc -p tsconfig.build.json", + "prepublishOnly": "bun run check && bun test && npm run build", "accept": "bash scripts/accept/run.sh" }, "dependencies": { diff --git a/src/editors/ast-codemod.ts b/src/editors/ast-codemod.ts index 25ea711..ad0b95f 100644 --- a/src/editors/ast-codemod.ts +++ b/src/editors/ast-codemod.ts @@ -14,7 +14,7 @@ */ import { createRequire } from "node:module"; -import { resolveSafePath } from "./hashline-tools"; +import { resolveSafePath } from "./hashline-tools.js"; export type AstLanguage = | "typescript" diff --git a/src/guards/permission-guard.ts b/src/guards/permission-guard.ts index eb672e5..d018da1 100644 --- a/src/guards/permission-guard.ts +++ b/src/guards/permission-guard.ts @@ -25,7 +25,7 @@ import { classifyShellCommand, isDestructiveShellCommand, -} from "./shell-parse"; +} from "./shell-parse.js"; export const DEFAULT_LOCKED_CONTRACT_GLOBS: string[] = [ "**/contracts/**", diff --git a/src/index.ts b/src/index.ts index 6235286..9de60c6 100644 --- a/src/index.ts +++ b/src/index.ts @@ -32,50 +32,50 @@ import { astRewriteFile, astSearch, type AstLanguage, -} from "./editors/ast-codemod"; +} from "./editors/ast-codemod.js"; import { hashEditFile, hashReadFile, type HashEditHunk, -} from "./editors/hashline-tools"; +} from "./editors/hashline-tools.js"; import { defaultGuardConfig, evaluateBoardGuard, type GuardPolicyConfig, type GuardRequest, type GuardVerdict, -} from "./guards/permission-guard"; +} from "./guards/permission-guard.js"; import { commandPrefixOf, recordToolAttempt, type CircuitBreakerVerdict, -} from "./guards/circuit-breaker"; +} from "./guards/circuit-breaker.js"; import { buildDynamicContextBlocks, injectContextBudgetIntoMessages, packBlocks, type LessonInput, type SessionEvent, -} from "./context/context-budget"; +} from "./context/context-budget.js"; import { auditLivePageWithPlaywright, evaluateDomGeometryInPage, type DomElementInput, type ViewportInput, -} from "./ui-auditor/dom-auditor"; +} from "./ui-auditor/dom-auditor.js"; -export * from "./editors/hashline-tools"; -export * from "./editors/ast-codemod"; -export * from "./guards/shell-parse"; -export * from "./guards/permission-guard"; -export * from "./guards/circuit-breaker"; -export * from "./context/context-budget"; -export * from "./ui-auditor/dom-auditor"; -export { getRecommendedMcpConfig } from "./ui-auditor/mcp-defaults"; +export * from "./editors/hashline-tools.js"; +export * from "./editors/ast-codemod.js"; +export * from "./guards/shell-parse.js"; +export * from "./guards/permission-guard.js"; +export * from "./guards/circuit-breaker.js"; +export * from "./context/context-budget.js"; +export * from "./ui-auditor/dom-auditor.js"; +export { getRecommendedMcpConfig } from "./ui-auditor/mcp-defaults.js"; export type { McpServerEntry, RecommendedMcpConfig, -} from "./ui-auditor/mcp-defaults"; +} from "./ui-auditor/mcp-defaults.js"; export const HARNESS_NAME = "@heretek-ai/opencode-harness"; export const HARNESS_VERSION = "1.0.0"; diff --git a/tsconfig.build.json b/tsconfig.build.json new file mode 100644 index 0000000..ada614b --- /dev/null +++ b/tsconfig.build.json @@ -0,0 +1,15 @@ +{ + "extends": "./tsconfig.json", + "compilerOptions": { + "outDir": "dist", + "rootDir": "src", + "declaration": true, + "declarationMap": true, + "sourceMap": true, + "noEmit": false, + "module": "ESNext", + "moduleResolution": "bundler" + }, + "include": ["src/**/*"], + "exclude": ["test", "scripts", "docs"] +}