2 Commits

Author SHA1 Message Date
955f13d72a build(plugin): isolate dist/, add install.mjs, untrack .js artifacts
Closes the long-standing 'jiti picks stale .js over updated .ts' trap
that silently shipped wrong code at least 5 times during sim e2e. Root
cause was three things compounding:

  1. tsconfig.plugin.json had outDir=plugin (same as rootDir), so tsc
     emitted compiled .js next to .ts sources. jiti's extension resolver
     prefers .js, so the moment a .ts changed without a matching rebuild,
     the .js won and the new code never ran.

  2. The .js artifacts were tracked in git, so even on clean clones the
     stale files came back.

  3. There was no install script. Every deploy was an ad-hoc tar + rsync
     that copied both .ts and .js to the same target dir, recreating the
     race on the install side.

This commit fixes all three together:

  - tsconfig.plugin.json: outDir=dist/dialectic, module/moduleResolution
    flipped from ESNext/bundler to NodeNext/NodeNext (so emitted .js
    works under plain Node ESM at runtime, the only thing jiti and the
    openclaw gateway actually use).
  - .gitignore: /dist/ + plugin/**/*.{js,mjs,cjs,js.map,d.ts}, then
    git rm --cached the 4 existing tracked .js files.
  - scripts/install.mjs (new, ESM): mirrors Fabric.OpenclawPlugin's
    install.mjs pattern — detect, checkDeps, build (clean dist/ first),
    install (copy dist/dialectic/ + openclaw.plugin.json + package.json
    to ~/.openclaw/plugins/dialectic/), configure (plugins.allow,
    plugins.load.paths, plugins.entries.<id>.enabled). Supports
    --install / --build-only / --uninstall / --skip-check / --verbose /
    --openclaw-profile-path / --backend-url.

Verified on sim dind-t2: install.mjs --install produces a plugin
directory with ONLY .js files (no .ts left behind), gateway loads it,
8 tools register cleanly, dialectic_list_topics + fabric-guild-list
work end-to-end.

Plugin is now fully ESM-clean: type=module + NodeNext + .js import
extensions + no bundler-only knobs. Matches the project-wide invariant
[[project-fabric-esm]] (every Fabric subproject is ESM).
2026-05-23 22:44:01 +01:00
db85d7dc69 feat: initial Dialectic.OpenclawPlugin — agent tools for Dialectic v2
Phase 3 of DIALECTIC-V2. Six tools wired to the Go backend running on
server.t3:

- dialectic_list_topics      GET  /api/topics
- dialectic_topic_detail     GET  /api/topics/{id}
- dialectic_propose_topic    POST /api/topics
- dialectic_signup           POST /api/topics/{id}/signups (HF pre-check)
- dialectic_post_argument    POST /api/topics/{id}/arguments
- dialectic_view_verdict     GET  /api/topics/{id}/verdict

All tools return MCP {content:[{type:text,text}]} shape. Errors caught
and surfaced as text payload so agents see actionable failure messages.

Per-agent API key resolved via secret-mgr key dialectic-agent-apikey
(cached in memory; AGENT_VERIFY env required). HF on_call coverage
check degrades gracefully to skipped if HarborForge.OpenclawPlugin
does not yet expose hasOnCallCovering() — backend stores pre_validated
flag as audit signal.

openclaw.plugin.json declares both contracts.tools (the 6 names) AND
activation.onStartup:true per loader gotchas memory; missing either
silently drops the plugin.

Plain export default {id, name, register} entry shape matching
prism-facet. No openclaw SDK imports (jiti runtime resolution of
openclaw was flaky in HF-style entries; structurally simpler avoids
the lookup entirely).

Defaults backendUrl to https://dialectic-api.hangman-lab.top; override
via openclaw.json plugins.entries.dialectic.config.backendUrl for sim.

Phase 3 deferred items (in README): agent key provisioning workflow,
HF window-coverage accessor, SSE subscription tool, token-cost
reporting.
2026-05-23 13:04:12 +01:00