5.3 KiB
5.3 KiB
Repository Guidelines
Project Overview
wow-pi is a Bun + TypeScript pi extension package that ports selected wow-omp features to original pi. It provides two runtime modules: Markdown context injection and environment variable injection.
Architecture & Data Flow
- Root
package.jsondeclares a private workspace and pi extension entry atpackages/wow-pi/src/index.ts. packages/wow-pi/src/index.tsimportswow-contextsandwow-injectfor side-effect module registration, then calls each registered module with pi'sExtensionAPI.packages/wow-coreowns shared infrastructure: config loading, module registry, logger, UI rendering, path utilities, and${protocol:value}reference resolution.packages/wow-contextsregisters/wow:contexts:list,/wow:contexts:reload,/wow:init, then injects configured Markdown files intobefore_agent_startsystem prompts.packages/wow-injectloads.envfiles andinject.envvalues during setup andsession_start, writing resolved values intoprocess.env.
Key Directories
packages/wow-pi/: pi extension entry package and bundleddist/output.packages/wow-core/: shared config, registry, logger, UI, utilities, and ref resolver.packages/wow-contexts/: context scanning/building, command handlers, and init prompt.packages/wow-inject/:.envparser and environment injection module.scripts/: build and install/uninstall orchestration scripts.docs/contexts/: subsystem reference cards loaded by wow contexts.
Development Commands
bun install: install workspace dependencies.bun run check: run TypeScript type checking withtsc --noEmit.bun run build: debug bundle forpackages/wow-piusing Bun with--target node.bun run build:release: minified release bundle.bun run script:install: debug build and copypackages/wow-pi/distto~/.pi/agent/extensions/wow-pi.bun run script:install:release: release build and install withWOW_RELEASE=1.bun run script:uninstall: remove installed~/.pi/agent/extensions/wow-pi.pi -e /path/to/wow-pi: load this extension once from source for manual testing.
Code Conventions & Common Patterns
- Use TypeScript ESM with strict type checking and Bun runtime types.
- Keep feature modules self-registering: import side effects call
registerModule({ name, register }). - Keep shared behavior in
wow-core; feature packages should depend onwow-core, not each other. - Use
getWowSettingSync(key, cwd)for module config and callresetWowConfigCache()when config should be re-read. - Use
registerWowCommand(pi, name, options)so commands are namespaced as/wow:<name>. - Use
showInfo,showWarn, orshowfor command UI notifications. - Avoid relying on source changes after install; installed pi code comes from copied
packages/wow-pi/dist.
Important Files
package.json: workspace scripts, pi manifest, peer dependencies.packages/wow-pi/src/index.ts: extension bootstrap and module registration loop.packages/wow-core/src/config.ts: JSON/YAML config loading and merge rules.packages/wow-core/src/registry.ts: module registration contract.packages/wow-contexts/src/index.ts:before_agent_startcontext injection.packages/wow-contexts/src/commands.ts:/wow:*command handlers.packages/wow-contexts/src/init-prompt.ts:/wow:initprompt template.packages/wow-inject/src/env.ts: environment injection flow.scripts/build.ts: debug/release build orchestrator.scripts/install.ts: hard-copy install/uninstall logic.wow.example.yaml: example global/project wow configuration.
Runtime/Tooling Preferences
- Use Bun for package management, scripts, and bundling.
- Build bundles with
--target node; pi loads extensions through Node/Jiti, and--target buncan emitimport.meta.require, which fails under pi. - Externalize pi host packages in the bundle:
@earendil-works/pi-coding-agent,@earendil-works/pi-ai,@earendil-works/pi-tui, andtypebox. - Config files are
~/.pi/agent/wow.{json,yaml,yml}and<project>/.pi/wow.{json,yaml,yml}; project config extends global config. - Logs write to
~/.pi/agent/wow/logs/wow.YYYY-MM-DD.logwith best-effort rotation. pi-subagentsmay be installed in the user environment;/wow:initexplicitly asks for read-only scout/context-builder fanout when available.
Testing & QA
- There are no unit tests or test framework dependencies currently.
bun run checkis the primary validation command and only runs TypeScript.- Build validation should include
bun run buildandbun run build:releasewhen touching bundling or dependencies. - Install validation should include
bun run script:installand a pi smoke command such asPI_CODING_AGENT_DIR="$HOME/.pi/agent" pi --help. - For extension behavior, manually verify
/wow:contexts:list,/wow:contexts:reload, and/wow:initin pi.
Module Contexts (docs/contexts/)
docs/contexts/wow-pi.md: extension entry and module orchestration.docs/contexts/wow-core.md: shared config, registry, logger, UI, and utilities.docs/contexts/wow-contexts.md: Markdown context scanning, injection, and commands.docs/contexts/wow-inject.md:.envloading and ref-based environment injection.docs/contexts/build-and-install.md: bundle, install, release, and validation flow.