OpenWriterControle/plugins/claude-code/scripts
Darren Hinde cdce9469c9
fix(plugin): add Windows hook wrapper, fix manifest check, remove bundled context (#243)
* fix(shellcheck): declare and assign separately in router.sh (SC2155)

* feat(plugin): enhance context management and skill invocation

- Update .context-manifest.json to include profile and detailed source information.
- Revise context-scout.md to clarify context root discovery and navigation.
- Modify commands to replace deprecated skills with updated ones (brainstorming → approach, systematic-debugging → debugger).
- Streamline install-context.md for clarity and remove interactive profile selection.
- Improve oac-status.md to provide a more comprehensive status report.
- Add OAC system paths to session-start.sh for better context management.
- Remove obsolete skills and improve documentation for existing commands.

* fix(plugin): fix hook JSON escaping and unconditional session firing

- Fix double-escaped skill catalogue: use $'\n' real newlines instead of
  literal \n strings so escape_for_json encodes them correctly as \n in JSON
- Fix OAC_SYSTEM_PATHS embedded raw into JSON string: build with real newlines
  and pass through escape_for_json before interpolation
- Remove SessionStart matcher so hook fires on every session start
  unconditionally (startup, resume, clear, compact and any future types)
- Remove redundant async:false field; add explicit timeout:30

* fix(plugin): add Windows hook wrapper, fix manifest check, remove bundled context

- Add run-hook.cmd polyglot wrapper for Windows compatibility — routes
  session-start through bash on Windows (Git Bash, MSYS2, Cygwin) and
  falls back silently if no bash found so plugin still loads
- Fix warning manifest check to look in correct locations: project-local
  .claude/.context-manifest.json and global ~/.claude/.context-manifest.json
  instead of the plugin root (which is never writable for marketplace users)
- Update warning message skill name: install-context -> context-setup
- Restore SessionStart matcher (startup|resume|clear|compact) for explicit
  session type filtering
- Remove bundled scripts/context/ tree (250+ files) — context is downloaded
  at runtime via /install-context, not shipped with the plugin
2026-02-23 14:19:29 +00:00
..
types fix: overhaul Claude Code plugin for correctness and spec compliance (#225) 2026-02-19 20:16:17 +00:00
utils fix: overhaul Claude Code plugin for correctness and spec compliance (#225) 2026-02-19 20:16:17 +00:00
.context-manifest.json feat(plugin): enhance context management and skill invocation (#239) 2026-02-23 12:12:29 +00:00
cleanup-tmp.sh fix: overhaul Claude Code plugin for correctness and spec compliance (#225) 2026-02-19 20:16:17 +00:00
install-context.js feat(plugin): enhance context management and skill invocation (#239) 2026-02-23 12:12:29 +00:00
install-context.sh feat(plugin): enhance context management and skill invocation (#239) 2026-02-23 12:12:29 +00:00
install-context.ts feat(plugin): enhance context management and skill invocation (#239) 2026-02-23 12:12:29 +00:00
README.md fix: overhaul Claude Code plugin for correctness and spec compliance (#225) 2026-02-19 20:16:17 +00:00
test-install.ts fix: overhaul Claude Code plugin for correctness and spec compliance (#225) 2026-02-19 20:16:17 +00:00
tsconfig.json fix: overhaul Claude Code plugin for correctness and spec compliance (#225) 2026-02-19 20:16:17 +00:00

Context Installer Scripts

TypeScript implementation of the context installer for the Claude Code plugin.

Overview

This directory contains a TypeScript-based context installer that downloads context files from the OpenAgents Control repository using git sparse-checkout.

Files

Core Implementation

  • install-context.ts - Main installer script with CLI interface
  • test-install.ts - Test script for verifying installation against real GitHub repository

Type Definitions

  • types/registry.ts - Registry schema and types (with Zod validation)
  • types/manifest.ts - Manifest schema and types

Utilities

  • utils/registry-fetcher.ts - Fetch and parse registry.json from GitHub
  • utils/git-sparse.ts - Git sparse-checkout operations

Usage

Install Context

# Install essential profile (default)
bun run plugins/claude-code/scripts/install-context.ts

# Install specific profile
bun run plugins/claude-code/scripts/install-context.ts --profile=standard

# Install specific components
bun run plugins/claude-code/scripts/install-context.ts --component=core-standards --component=openagents-repo

# Dry run (see what would be installed)
bun run plugins/claude-code/scripts/install-context.ts --profile=extended --dry-run

# Force reinstall with verbose output
bun run plugins/claude-code/scripts/install-context.ts --force --verbose

Run Tests

# Run test suite
bun run plugins/claude-code/scripts/test-install.ts

Profiles

  • essential - Minimal components for basic functionality
  • standard - Standard components for typical use
  • extended - Extended components for advanced features
  • specialized - Specialized components for specific domains
  • all - All available context

Features

✅ Fetch registry.json from GitHub
✅ Parse and validate with Zod
✅ Filter context components by profile
✅ Download using git sparse-checkout
✅ Create manifest tracking installation
✅ Handle errors gracefully
✅ Dry run mode
✅ Verbose logging
✅ Force reinstall option

Architecture

Registry Fetching

The registry-fetcher utility:

  1. Fetches registry.json from GitHub raw URL
  2. Validates structure with Zod schema
  3. Filters components by profile or custom IDs
  4. Extracts unique directory paths for sparse checkout

Git Sparse Checkout

The git-sparse utility:

  1. Clones repository with --filter=blob:none --sparse
  2. Configures sparse-checkout for specific paths
  3. Copies files to target directory
  4. Cleans up temporary files

Manifest Creation

The installer creates a .context-manifest.json file tracking:

  • Installation profile
  • Source repository and commit SHA
  • Downloaded components with local paths
  • Installation timestamp

Testing

The test script (test-install.ts) verifies:

  1. Registry Fetch - Fetches from real GitHub repository
  2. Profile Filtering - Filters components by profile
  3. Dry Run - Simulates installation without downloading

To test actual installation, uncomment Test 4 in test-install.ts.

Example Output

Context Installer
========================

ℹ Profile: essential
ℹ Repository: darrenhinde/OpenAgentsControl
ℹ Branch: main
ℹ Dry run: false

ℹ Fetching registry from GitHub...
✓ Registry version: 2.0.0
✓ Context components available: 150

ℹ Filtering by profile: essential
✓ Selected 12 components

ℹ Downloading context files...
✓ Files downloaded successfully

ℹ Copying files to context directory...
✓ Files copied to: /path/to/context

ℹ Creating manifest...
✓ Manifest created: .context-manifest.json

ℹ Verifying installation...
✓ Installation complete!
ℹ Files verified: 12/12

Error Handling

The installer handles:

  • Network failures (GitHub unavailable)
  • Invalid registry structure
  • Git command failures
  • Missing dependencies (git not installed)
  • File system errors

All errors are logged with clear messages and the installer exits with appropriate exit codes.

Dependencies

  • Bun - Runtime and package manager
  • Zod - Schema validation
  • Git - Sparse checkout operations

Development

Type Safety

All types are defined in types/ directory with Zod schemas for runtime validation.

Testing

Run tests before committing changes:

bun run plugins/claude-code/scripts/test-install.ts

Adding New Profiles

To add a new profile, update the Profile type in types/registry.ts and the profile mapping in utils/registry-fetcher.ts.

Migration from JavaScript

This TypeScript implementation replaces the original install-context.js with:

  • Type safety with TypeScript and Zod
  • Better error handling
  • Modular architecture
  • Comprehensive testing
  • Improved documentation

The JavaScript version is kept for backward compatibility but the TypeScript version is recommended for new installations.