Compare commits
1 Commits
dev
...
fix/subage
| Author | SHA1 | Date | |
|---|---|---|---|
|
|
21ddd55162 |
BIN
.github/assets/building-in-public.png
vendored
BIN
.github/assets/building-in-public.png
vendored
Binary file not shown.
|
Before Width: | Height: | Size: 278 KiB |
21
.github/workflows/ci.yml
vendored
21
.github/workflows/ci.yml
vendored
@@ -60,33 +60,16 @@ jobs:
|
||||
bun test src/features/opencode-skill-loader/loader.test.ts
|
||||
bun test src/hooks/anthropic-context-window-limit-recovery/recovery-hook.test.ts
|
||||
bun test src/hooks/anthropic-context-window-limit-recovery/executor.test.ts
|
||||
# src/shared mock-heavy files (mock.module pollutes connected-providers-cache and legacy-plugin-warning)
|
||||
bun test src/shared/model-capabilities.test.ts
|
||||
bun test src/shared/log-legacy-plugin-startup-warning.test.ts
|
||||
bun test src/shared/model-error-classifier.test.ts
|
||||
bun test src/shared/opencode-message-dir.test.ts
|
||||
# session-recovery mock isolation (recover-tool-result-missing mocks ./storage)
|
||||
bun test src/hooks/session-recovery/recover-tool-result-missing.test.ts
|
||||
# legacy-plugin-toast mock isolation (hook.test.ts mocks ./auto-migrate)
|
||||
bun test src/hooks/legacy-plugin-toast/hook.test.ts
|
||||
|
||||
- name: Run remaining tests
|
||||
run: |
|
||||
# Enumerate subdirectories/files explicitly to EXCLUDE mock-heavy files
|
||||
# that were already run in isolation above.
|
||||
# Excluded from src/shared: model-capabilities, log-legacy-plugin-startup-warning, model-error-classifier, opencode-message-dir
|
||||
# Excluded from src/cli: doctor/formatter.test.ts, doctor/format-default.test.ts
|
||||
# Excluded from src/tools: call-omo-agent/sync-executor.test.ts, call-omo-agent/session-creator.test.ts, session-manager (all)
|
||||
# Excluded from src/hooks/anthropic-context-window-limit-recovery: recovery-hook.test.ts, executor.test.ts
|
||||
# Build src/shared file list excluding mock-heavy files already run in isolation
|
||||
SHARED_FILES=$(find src/shared -name '*.test.ts' \
|
||||
! -name 'model-capabilities.test.ts' \
|
||||
! -name 'log-legacy-plugin-startup-warning.test.ts' \
|
||||
! -name 'model-error-classifier.test.ts' \
|
||||
! -name 'opencode-message-dir.test.ts' \
|
||||
| sort | tr '\n' ' ')
|
||||
bun test bin script src/config src/mcp src/index.test.ts \
|
||||
src/agents $SHARED_FILES \
|
||||
src/agents src/shared \
|
||||
src/cli/run src/cli/config-manager src/cli/mcp-oauth \
|
||||
src/cli/index.test.ts src/cli/install.test.ts src/cli/model-fallback.test.ts \
|
||||
src/cli/config-manager.test.ts \
|
||||
@@ -99,8 +82,6 @@ jobs:
|
||||
src/tools/call-omo-agent/background-executor.test.ts \
|
||||
src/tools/call-omo-agent/subagent-session-creator.test.ts \
|
||||
src/hooks/anthropic-context-window-limit-recovery/empty-content-recovery-sdk.test.ts src/hooks/anthropic-context-window-limit-recovery/parser.test.ts src/hooks/anthropic-context-window-limit-recovery/pruning-deduplication.test.ts src/hooks/anthropic-context-window-limit-recovery/recovery-deduplication.test.ts src/hooks/anthropic-context-window-limit-recovery/storage.test.ts \
|
||||
src/hooks/session-recovery/detect-error-type.test.ts src/hooks/session-recovery/index.test.ts src/hooks/session-recovery/recover-empty-content-message-sdk.test.ts src/hooks/session-recovery/resume.test.ts src/hooks/session-recovery/storage \
|
||||
src/hooks/legacy-plugin-toast/auto-migrate.test.ts \
|
||||
src/hooks/claude-code-compatibility \
|
||||
src/hooks/context-injection \
|
||||
src/hooks/provider-toast \
|
||||
|
||||
173
.github/workflows/publish-platform.yml
vendored
173
.github/workflows/publish-platform.yml
vendored
@@ -56,82 +56,32 @@ jobs:
|
||||
env:
|
||||
BUN_INSTALL_ALLOW_SCRIPTS: "@ast-grep/napi"
|
||||
|
||||
- name: Validate release inputs
|
||||
id: validate
|
||||
env:
|
||||
INPUT_VERSION: ${{ inputs.version }}
|
||||
INPUT_DIST_TAG: ${{ inputs.dist_tag }}
|
||||
run: |
|
||||
VERSION="$INPUT_VERSION"
|
||||
DIST_TAG="$INPUT_DIST_TAG"
|
||||
|
||||
if ! [[ "$VERSION" =~ ^[0-9]+\.[0-9]+\.[0-9]+(-[0-9A-Za-z]+(\.[0-9A-Za-z]+)*)?$ ]]; then
|
||||
echo "::error::Invalid version: $VERSION"
|
||||
exit 1
|
||||
fi
|
||||
|
||||
if [ -n "$DIST_TAG" ] && ! [[ "$DIST_TAG" =~ ^[a-z][a-z0-9-]*$ ]]; then
|
||||
echo "::error::Invalid dist_tag: $DIST_TAG"
|
||||
exit 1
|
||||
fi
|
||||
|
||||
echo "version=$VERSION" >> $GITHUB_OUTPUT
|
||||
echo "dist_tag=$DIST_TAG" >> $GITHUB_OUTPUT
|
||||
|
||||
- name: Check if already published
|
||||
id: check
|
||||
env:
|
||||
VERSION: ${{ steps.validate.outputs.version }}
|
||||
run: |
|
||||
PKG_NAME="oh-my-opencode-${{ matrix.platform }}"
|
||||
VERSION="${{ inputs.version }}"
|
||||
STATUS=$(curl -s -o /dev/null -w "%{http_code}" "https://registry.npmjs.org/${PKG_NAME}/${VERSION}")
|
||||
# Convert platform name for output (replace - with _)
|
||||
PLATFORM_KEY="${{ matrix.platform }}"
|
||||
PLATFORM_KEY="${PLATFORM_KEY//-/_}"
|
||||
|
||||
# Check oh-my-opencode
|
||||
OC_STATUS=$(curl -s -o /dev/null -w "%{http_code}" "https://registry.npmjs.org/oh-my-opencode-${{ matrix.platform }}/${VERSION}")
|
||||
# Check oh-my-openagent
|
||||
OA_STATUS=$(curl -s -o /dev/null -w "%{http_code}" "https://registry.npmjs.org/oh-my-openagent-${{ matrix.platform }}/${VERSION}")
|
||||
|
||||
echo "oh-my-opencode-${{ matrix.platform }}@${VERSION}: ${OC_STATUS}"
|
||||
echo "oh-my-openagent-${{ matrix.platform }}@${VERSION}: ${OA_STATUS}"
|
||||
|
||||
if [ "$OC_STATUS" = "200" ]; then
|
||||
echo "skip_opencode=true" >> $GITHUB_OUTPUT
|
||||
echo "✓ oh-my-opencode-${{ matrix.platform }}@${VERSION} already published"
|
||||
else
|
||||
echo "skip_opencode=false" >> $GITHUB_OUTPUT
|
||||
echo "→ oh-my-opencode-${{ matrix.platform }}@${VERSION} needs publishing"
|
||||
fi
|
||||
|
||||
if [ "$OA_STATUS" = "200" ]; then
|
||||
echo "skip_openagent=true" >> $GITHUB_OUTPUT
|
||||
echo "✓ oh-my-openagent-${{ matrix.platform }}@${VERSION} already published"
|
||||
else
|
||||
echo "skip_openagent=false" >> $GITHUB_OUTPUT
|
||||
echo "→ oh-my-openagent-${{ matrix.platform }}@${VERSION} needs publishing"
|
||||
fi
|
||||
|
||||
# Skip build only if BOTH are already published
|
||||
if [ "$OC_STATUS" = "200" ] && [ "$OA_STATUS" = "200" ]; then
|
||||
if [ "$STATUS" = "200" ]; then
|
||||
echo "skip=true" >> $GITHUB_OUTPUT
|
||||
echo "skip_${PLATFORM_KEY}=true" >> $GITHUB_OUTPUT
|
||||
echo "✓ ${PKG_NAME}@${VERSION} already published"
|
||||
else
|
||||
echo "skip=false" >> $GITHUB_OUTPUT
|
||||
echo "skip_${PLATFORM_KEY}=false" >> $GITHUB_OUTPUT
|
||||
echo "→ ${PKG_NAME}@${VERSION} needs publishing"
|
||||
fi
|
||||
|
||||
- name: Update version in package.json
|
||||
if: steps.check.outputs.skip != 'true'
|
||||
env:
|
||||
VERSION: ${{ steps.validate.outputs.version }}
|
||||
run: |
|
||||
VERSION="${{ inputs.version }}"
|
||||
cd packages/${{ matrix.platform }}
|
||||
jq --arg v "$VERSION" '.version = $v' package.json > tmp.json && mv tmp.json package.json
|
||||
|
||||
- name: Set root package version
|
||||
if: steps.check.outputs.skip != 'true'
|
||||
env:
|
||||
VERSION: ${{ steps.validate.outputs.version }}
|
||||
run: |
|
||||
jq --arg v "$VERSION" '.version = $v' package.json > tmp.json && mv tmp.json package.json
|
||||
|
||||
- name: Pre-download baseline compile target
|
||||
if: steps.check.outputs.skip != 'true' && endsWith(matrix.platform, '-baseline')
|
||||
shell: bash
|
||||
@@ -242,6 +192,12 @@ jobs:
|
||||
retention-days: 1
|
||||
if-no-files-found: error
|
||||
|
||||
# =============================================================================
|
||||
# Job 2: Publish all platforms using OIDC/Provenance
|
||||
# - Runs on ubuntu-latest for ALL platforms (just downloading artifacts)
|
||||
# - Uses npm Trusted Publishing (OIDC) - no NODE_AUTH_TOKEN needed
|
||||
# - Fresh OIDC token at publish time avoids timeout issues
|
||||
# =============================================================================
|
||||
publish:
|
||||
needs: build
|
||||
if: always() && !cancelled()
|
||||
@@ -252,60 +208,23 @@ jobs:
|
||||
matrix:
|
||||
platform: [darwin-arm64, darwin-x64, darwin-x64-baseline, linux-x64, linux-x64-baseline, linux-arm64, linux-x64-musl, linux-x64-musl-baseline, linux-arm64-musl, windows-x64, windows-x64-baseline]
|
||||
steps:
|
||||
- name: Validate release inputs
|
||||
id: validate
|
||||
env:
|
||||
INPUT_VERSION: ${{ inputs.version }}
|
||||
INPUT_DIST_TAG: ${{ inputs.dist_tag }}
|
||||
run: |
|
||||
VERSION="$INPUT_VERSION"
|
||||
DIST_TAG="$INPUT_DIST_TAG"
|
||||
|
||||
if ! [[ "$VERSION" =~ ^[0-9]+\.[0-9]+\.[0-9]+(-[0-9A-Za-z]+(\.[0-9A-Za-z]+)*)?$ ]]; then
|
||||
echo "::error::Invalid version: $VERSION"
|
||||
exit 1
|
||||
fi
|
||||
|
||||
if [ -n "$DIST_TAG" ] && ! [[ "$DIST_TAG" =~ ^[a-z][a-z0-9-]*$ ]]; then
|
||||
echo "::error::Invalid dist_tag: $DIST_TAG"
|
||||
exit 1
|
||||
fi
|
||||
|
||||
echo "version=$VERSION" >> $GITHUB_OUTPUT
|
||||
echo "dist_tag=$DIST_TAG" >> $GITHUB_OUTPUT
|
||||
|
||||
- name: Check if already published
|
||||
id: check
|
||||
env:
|
||||
VERSION: ${{ steps.validate.outputs.version }}
|
||||
run: |
|
||||
OC_STATUS=$(curl -s -o /dev/null -w "%{http_code}" "https://registry.npmjs.org/oh-my-opencode-${{ matrix.platform }}/${VERSION}")
|
||||
OA_STATUS=$(curl -s -o /dev/null -w "%{http_code}" "https://registry.npmjs.org/oh-my-openagent-${{ matrix.platform }}/${VERSION}")
|
||||
|
||||
if [ "$OC_STATUS" = "200" ]; then
|
||||
echo "skip_opencode=true" >> $GITHUB_OUTPUT
|
||||
echo "✓ oh-my-opencode-${{ matrix.platform }}@${VERSION} already published"
|
||||
PKG_NAME="oh-my-opencode-${{ matrix.platform }}"
|
||||
VERSION="${{ inputs.version }}"
|
||||
STATUS=$(curl -s -o /dev/null -w "%{http_code}" "https://registry.npmjs.org/${PKG_NAME}/${VERSION}")
|
||||
if [ "$STATUS" = "200" ]; then
|
||||
echo "skip=true" >> $GITHUB_OUTPUT
|
||||
echo "✓ ${PKG_NAME}@${VERSION} already published, skipping"
|
||||
else
|
||||
echo "skip_opencode=false" >> $GITHUB_OUTPUT
|
||||
fi
|
||||
|
||||
if [ "$OA_STATUS" = "200" ]; then
|
||||
echo "skip_openagent=true" >> $GITHUB_OUTPUT
|
||||
echo "✓ oh-my-openagent-${{ matrix.platform }}@${VERSION} already published"
|
||||
else
|
||||
echo "skip_openagent=false" >> $GITHUB_OUTPUT
|
||||
fi
|
||||
|
||||
# Need artifact if either package needs publishing
|
||||
if [ "$OC_STATUS" = "200" ] && [ "$OA_STATUS" = "200" ]; then
|
||||
echo "skip_all=true" >> $GITHUB_OUTPUT
|
||||
else
|
||||
echo "skip_all=false" >> $GITHUB_OUTPUT
|
||||
echo "skip=false" >> $GITHUB_OUTPUT
|
||||
echo "→ ${PKG_NAME}@${VERSION} will be published"
|
||||
fi
|
||||
|
||||
- name: Download artifact
|
||||
id: download
|
||||
if: steps.check.outputs.skip_all != 'true'
|
||||
if: steps.check.outputs.skip != 'true'
|
||||
continue-on-error: true
|
||||
uses: actions/download-artifact@v4
|
||||
with:
|
||||
@@ -313,7 +232,7 @@ jobs:
|
||||
path: .
|
||||
|
||||
- name: Extract artifact
|
||||
if: steps.check.outputs.skip_all != 'true' && steps.download.outcome == 'success'
|
||||
if: steps.check.outputs.skip != 'true' && steps.download.outcome == 'success'
|
||||
run: |
|
||||
PLATFORM="${{ matrix.platform }}"
|
||||
mkdir -p packages/${PLATFORM}
|
||||
@@ -329,45 +248,23 @@ jobs:
|
||||
ls -la packages/${PLATFORM}/bin/
|
||||
|
||||
- uses: actions/setup-node@v4
|
||||
if: steps.check.outputs.skip_all != 'true' && steps.download.outcome == 'success'
|
||||
if: steps.check.outputs.skip != 'true' && steps.download.outcome == 'success'
|
||||
with:
|
||||
node-version: "24"
|
||||
registry-url: "https://registry.npmjs.org"
|
||||
|
||||
- name: Publish oh-my-opencode-${{ matrix.platform }}
|
||||
if: steps.check.outputs.skip_opencode != 'true' && steps.download.outcome == 'success'
|
||||
env:
|
||||
DIST_TAG: ${{ steps.validate.outputs.dist_tag }}
|
||||
NODE_AUTH_TOKEN: ${{ secrets.NODE_AUTH_TOKEN }}
|
||||
NPM_CONFIG_PROVENANCE: true
|
||||
- name: Publish ${{ matrix.platform }}
|
||||
if: steps.check.outputs.skip != 'true' && steps.download.outcome == 'success'
|
||||
run: |
|
||||
cd packages/${{ matrix.platform }}
|
||||
|
||||
if [ -n "$DIST_TAG" ]; then
|
||||
npm publish --access public --provenance --tag "$DIST_TAG"
|
||||
else
|
||||
npm publish --access public --provenance
|
||||
|
||||
TAG_ARG=""
|
||||
if [ -n "${{ inputs.dist_tag }}" ]; then
|
||||
TAG_ARG="--tag ${{ inputs.dist_tag }}"
|
||||
fi
|
||||
timeout-minutes: 15
|
||||
|
||||
- name: Publish oh-my-openagent-${{ matrix.platform }}
|
||||
if: steps.check.outputs.skip_openagent != 'true' && steps.download.outcome == 'success'
|
||||
|
||||
npm publish --access public --provenance $TAG_ARG
|
||||
env:
|
||||
DIST_TAG: ${{ steps.validate.outputs.dist_tag }}
|
||||
NODE_AUTH_TOKEN: ${{ secrets.NODE_AUTH_TOKEN }}
|
||||
NPM_CONFIG_PROVENANCE: true
|
||||
run: |
|
||||
cd packages/${{ matrix.platform }}
|
||||
|
||||
# Rename package for oh-my-openagent
|
||||
jq --arg name "oh-my-openagent-${{ matrix.platform }}" \
|
||||
--arg desc "Platform-specific binary for oh-my-openagent (${{ matrix.platform }})" \
|
||||
'.name = $name | .description = $desc | .bin = {"oh-my-openagent": (.bin | to_entries | .[0].value)}' \
|
||||
package.json > tmp.json && mv tmp.json package.json
|
||||
|
||||
if [ -n "$DIST_TAG" ]; then
|
||||
npm publish --access public --provenance --tag "$DIST_TAG"
|
||||
else
|
||||
npm publish --access public --provenance
|
||||
fi
|
||||
timeout-minutes: 15
|
||||
|
||||
203
.github/workflows/publish.yml
vendored
203
.github/workflows/publish.yml
vendored
@@ -57,51 +57,32 @@ jobs:
|
||||
bun test src/cli/doctor/format-default.test.ts
|
||||
bun test src/tools/call-omo-agent/sync-executor.test.ts
|
||||
bun test src/tools/call-omo-agent/session-creator.test.ts
|
||||
bun test src/tools/session-manager
|
||||
bun test src/features/opencode-skill-loader/loader.test.ts
|
||||
bun test src/hooks/anthropic-context-window-limit-recovery/recovery-hook.test.ts
|
||||
bun test src/hooks/anthropic-context-window-limit-recovery/executor.test.ts
|
||||
# src/shared mock-heavy files (mock.module pollutes connected-providers-cache and legacy-plugin-warning)
|
||||
bun test src/shared/model-capabilities.test.ts
|
||||
bun test src/shared/log-legacy-plugin-startup-warning.test.ts
|
||||
bun test src/shared/model-error-classifier.test.ts
|
||||
bun test src/shared/opencode-message-dir.test.ts
|
||||
# session-recovery mock isolation (recover-tool-result-missing mocks ./storage)
|
||||
bun test src/hooks/session-recovery/recover-tool-result-missing.test.ts
|
||||
# legacy-plugin-toast mock isolation (hook.test.ts mocks ./auto-migrate)
|
||||
bun test src/hooks/legacy-plugin-toast/hook.test.ts
|
||||
|
||||
- name: Run remaining tests
|
||||
run: |
|
||||
# Enumerate subdirectories/files explicitly to EXCLUDE mock-heavy files
|
||||
# that were already run in isolation above.
|
||||
# Excluded from src/shared: model-capabilities, log-legacy-plugin-startup-warning, model-error-classifier, opencode-message-dir
|
||||
# Excluded from src/cli: doctor/formatter.test.ts, doctor/format-default.test.ts
|
||||
# Excluded from src/tools: call-omo-agent/sync-executor.test.ts, call-omo-agent/session-creator.test.ts, session-manager (all)
|
||||
# Excluded from src/tools: call-omo-agent/sync-executor.test.ts, call-omo-agent/session-creator.test.ts
|
||||
# Excluded from src/hooks/anthropic-context-window-limit-recovery: recovery-hook.test.ts, executor.test.ts
|
||||
# Build src/shared file list excluding mock-heavy files already run in isolation
|
||||
SHARED_FILES=$(find src/shared -name '*.test.ts' \
|
||||
! -name 'model-capabilities.test.ts' \
|
||||
! -name 'log-legacy-plugin-startup-warning.test.ts' \
|
||||
! -name 'model-error-classifier.test.ts' \
|
||||
! -name 'opencode-message-dir.test.ts' \
|
||||
| sort | tr '\n' ' ')
|
||||
# Excluded from src/tools: call-omo-agent/sync-executor.test.ts, call-omo-agent/session-creator.test.ts
|
||||
bun test bin script src/config src/mcp src/index.test.ts \
|
||||
src/agents $SHARED_FILES \
|
||||
src/agents src/shared \
|
||||
src/cli/run src/cli/config-manager src/cli/mcp-oauth \
|
||||
src/cli/index.test.ts src/cli/install.test.ts src/cli/model-fallback.test.ts \
|
||||
src/cli/config-manager.test.ts \
|
||||
src/cli/doctor/runner.test.ts src/cli/doctor/checks \
|
||||
src/tools/ast-grep src/tools/background-task src/tools/delegate-task \
|
||||
src/tools/glob src/tools/grep src/tools/interactive-bash \
|
||||
src/tools/look-at src/tools/lsp \
|
||||
src/tools/look-at src/tools/lsp src/tools/session-manager \
|
||||
src/tools/skill src/tools/skill-mcp src/tools/slashcommand src/tools/task \
|
||||
src/tools/call-omo-agent/background-agent-executor.test.ts \
|
||||
src/tools/call-omo-agent/background-executor.test.ts \
|
||||
src/tools/call-omo-agent/subagent-session-creator.test.ts \
|
||||
src/hooks/anthropic-context-window-limit-recovery/empty-content-recovery-sdk.test.ts src/hooks/anthropic-context-window-limit-recovery/parser.test.ts src/hooks/anthropic-context-window-limit-recovery/pruning-deduplication.test.ts src/hooks/anthropic-context-window-limit-recovery/recovery-deduplication.test.ts src/hooks/anthropic-context-window-limit-recovery/storage.test.ts \
|
||||
src/hooks/session-recovery/detect-error-type.test.ts src/hooks/session-recovery/index.test.ts src/hooks/session-recovery/recover-empty-content-message-sdk.test.ts src/hooks/session-recovery/resume.test.ts src/hooks/session-recovery/storage \
|
||||
src/hooks/legacy-plugin-toast/auto-migrate.test.ts \
|
||||
src/hooks/claude-code-compatibility \
|
||||
src/hooks/context-injection \
|
||||
src/hooks/provider-toast \
|
||||
@@ -140,7 +121,7 @@ jobs:
|
||||
publish-main:
|
||||
runs-on: ubuntu-latest
|
||||
needs: [test, typecheck]
|
||||
if: github.repository == 'code-yeongyu/oh-my-openagent'
|
||||
if: github.repository == 'code-yeongyu/oh-my-opencode'
|
||||
outputs:
|
||||
version: ${{ steps.version.outputs.version }}
|
||||
dist_tag: ${{ steps.version.outputs.dist_tag }}
|
||||
@@ -167,47 +148,33 @@ jobs:
|
||||
|
||||
- name: Calculate version
|
||||
id: version
|
||||
env:
|
||||
RAW_VERSION: ${{ inputs.version }}
|
||||
BUMP: ${{ inputs.bump }}
|
||||
run: |
|
||||
VERSION="$RAW_VERSION"
|
||||
VERSION="${{ inputs.version }}"
|
||||
if [ -z "$VERSION" ]; then
|
||||
PREV=$(curl -s https://registry.npmjs.org/oh-my-opencode/latest | jq -r '.version // "0.0.0"')
|
||||
BASE="${PREV%%-*}"
|
||||
IFS='.' read -r MAJOR MINOR PATCH <<< "$BASE"
|
||||
case "$BUMP" in
|
||||
case "${{ inputs.bump }}" in
|
||||
major) VERSION="$((MAJOR+1)).0.0" ;;
|
||||
minor) VERSION="${MAJOR}.$((MINOR+1)).0" ;;
|
||||
*) VERSION="${MAJOR}.${MINOR}.$((PATCH+1))" ;;
|
||||
esac
|
||||
fi
|
||||
|
||||
if ! [[ "$VERSION" =~ ^[0-9]+\.[0-9]+\.[0-9]+(-[0-9A-Za-z]+(\.[0-9A-Za-z]+)*)?$ ]]; then
|
||||
echo "::error::Invalid version: $VERSION"
|
||||
exit 1
|
||||
fi
|
||||
|
||||
echo "version=$VERSION" >> $GITHUB_OUTPUT
|
||||
|
||||
|
||||
if [[ "$VERSION" == *"-"* ]]; then
|
||||
DIST_TAG=$(printf '%s' "$VERSION" | cut -d'-' -f2 | cut -d'.' -f1)
|
||||
if ! [[ "$DIST_TAG" =~ ^[a-z][a-z0-9-]*$ ]]; then
|
||||
echo "::error::Invalid dist_tag: $DIST_TAG"
|
||||
exit 1
|
||||
fi
|
||||
DIST_TAG=$(echo "$VERSION" | cut -d'-' -f2 | cut -d'.' -f1)
|
||||
echo "dist_tag=${DIST_TAG:-next}" >> $GITHUB_OUTPUT
|
||||
else
|
||||
echo "dist_tag=" >> $GITHUB_OUTPUT
|
||||
fi
|
||||
|
||||
|
||||
echo "Version: $VERSION"
|
||||
|
||||
- name: Check if already published
|
||||
id: check
|
||||
env:
|
||||
VERSION: ${{ steps.version.outputs.version }}
|
||||
run: |
|
||||
VERSION="${{ steps.version.outputs.version }}"
|
||||
STATUS=$(curl -s -o /dev/null -w "%{http_code}" "https://registry.npmjs.org/oh-my-opencode/${VERSION}")
|
||||
if [ "$STATUS" = "200" ]; then
|
||||
echo "skip=true" >> $GITHUB_OUTPUT
|
||||
@@ -218,16 +185,15 @@ jobs:
|
||||
|
||||
- name: Update version
|
||||
if: steps.check.outputs.skip != 'true'
|
||||
env:
|
||||
VERSION: ${{ steps.version.outputs.version }}
|
||||
run: |
|
||||
VERSION="${{ steps.version.outputs.version }}"
|
||||
jq --arg v "$VERSION" '.version = $v' package.json > tmp.json && mv tmp.json package.json
|
||||
|
||||
|
||||
for platform in darwin-arm64 darwin-x64 darwin-x64-baseline linux-x64 linux-x64-baseline linux-arm64 linux-x64-musl linux-x64-musl-baseline linux-arm64-musl windows-x64 windows-x64-baseline; do
|
||||
jq --arg v "$VERSION" '.version = $v' "packages/${platform}/package.json" > tmp.json
|
||||
mv tmp.json "packages/${platform}/package.json"
|
||||
done
|
||||
|
||||
|
||||
jq --arg v "$VERSION" '.optionalDependencies = (.optionalDependencies | to_entries | map(.value = $v) | from_entries)' package.json > tmp.json && mv tmp.json package.json
|
||||
|
||||
- name: Build main package
|
||||
@@ -238,75 +204,48 @@ jobs:
|
||||
bunx tsc --emitDeclarationOnly
|
||||
bun run build:schema
|
||||
|
||||
- name: Publish oh-my-opencode
|
||||
- name: Publish main package
|
||||
if: steps.check.outputs.skip != 'true'
|
||||
run: |
|
||||
TAG_ARG=""
|
||||
if [ -n "${{ steps.version.outputs.dist_tag }}" ]; then
|
||||
TAG_ARG="--tag ${{ steps.version.outputs.dist_tag }}"
|
||||
fi
|
||||
npm publish --access public --provenance $TAG_ARG
|
||||
env:
|
||||
DIST_TAG: ${{ steps.version.outputs.dist_tag }}
|
||||
NODE_AUTH_TOKEN: ${{ secrets.NODE_AUTH_TOKEN }}
|
||||
NPM_CONFIG_PROVENANCE: true
|
||||
run: |
|
||||
if [ -n "$DIST_TAG" ]; then
|
||||
npm publish --access public --provenance --tag "$DIST_TAG"
|
||||
else
|
||||
npm publish --access public --provenance
|
||||
fi
|
||||
|
||||
- name: Check if oh-my-openagent already published
|
||||
id: check-openagent
|
||||
- name: Git commit and tag
|
||||
if: steps.check.outputs.skip != 'true'
|
||||
run: |
|
||||
git config user.email "github-actions[bot]@users.noreply.github.com"
|
||||
git config user.name "github-actions[bot]"
|
||||
git add package.json assets/oh-my-opencode.schema.json packages/*/package.json || true
|
||||
git diff --cached --quiet || git commit -m "release: v${{ steps.version.outputs.version }}"
|
||||
git tag -f "v${{ steps.version.outputs.version }}"
|
||||
git push origin --tags --force
|
||||
git push origin HEAD || echo "Branch push failed (non-critical)"
|
||||
env:
|
||||
VERSION: ${{ steps.version.outputs.version }}
|
||||
run: |
|
||||
STATUS=$(curl -s -o /dev/null -w "%{http_code}" "https://registry.npmjs.org/oh-my-openagent/${VERSION}")
|
||||
if [ "$STATUS" = "200" ]; then
|
||||
echo "skip=true" >> $GITHUB_OUTPUT
|
||||
echo "✓ oh-my-openagent@${VERSION} already published"
|
||||
else
|
||||
echo "skip=false" >> $GITHUB_OUTPUT
|
||||
fi
|
||||
GITHUB_TOKEN: ${{ secrets.GITHUB_TOKEN }}
|
||||
|
||||
- name: Publish oh-my-openagent
|
||||
if: steps.check-openagent.outputs.skip != 'true'
|
||||
env:
|
||||
VERSION: ${{ steps.version.outputs.version }}
|
||||
DIST_TAG: ${{ steps.version.outputs.dist_tag }}
|
||||
NODE_AUTH_TOKEN: ${{ secrets.NODE_AUTH_TOKEN }}
|
||||
NPM_CONFIG_PROVENANCE: true
|
||||
run: |
|
||||
# Update package name, version, and optionalDependencies for oh-my-openagent
|
||||
jq --arg v "$VERSION" '
|
||||
.name = "oh-my-openagent" |
|
||||
.version = $v |
|
||||
.optionalDependencies = (
|
||||
.optionalDependencies | to_entries |
|
||||
map(.key = (.key | sub("^oh-my-opencode-"; "oh-my-openagent-")) | .value = $v) |
|
||||
from_entries
|
||||
)
|
||||
' package.json > tmp.json && mv tmp.json package.json
|
||||
|
||||
if [ -n "$DIST_TAG" ]; then
|
||||
npm publish --access public --provenance --tag "$DIST_TAG"
|
||||
else
|
||||
npm publish --access public --provenance
|
||||
fi
|
||||
|
||||
- name: Restore package.json
|
||||
if: always() && steps.check-openagent.outputs.skip != 'true'
|
||||
run: |
|
||||
git checkout -- package.json
|
||||
|
||||
publish-platform:
|
||||
trigger-platform:
|
||||
runs-on: ubuntu-latest
|
||||
needs: publish-main
|
||||
if: inputs.skip_platform != true
|
||||
uses: ./.github/workflows/publish-platform.yml
|
||||
with:
|
||||
version: ${{ needs.publish-main.outputs.version }}
|
||||
dist_tag: ${{ needs.publish-main.outputs.dist_tag }}
|
||||
secrets: inherit
|
||||
steps:
|
||||
- name: Trigger platform publish workflow
|
||||
run: |
|
||||
gh workflow run publish-platform.yml \
|
||||
--repo ${{ github.repository }} \
|
||||
--ref ${{ github.ref }} \
|
||||
-f version=${{ needs.publish-main.outputs.version }} \
|
||||
-f dist_tag=${{ needs.publish-main.outputs.dist_tag }}
|
||||
env:
|
||||
GH_TOKEN: ${{ secrets.GITHUB_TOKEN }}
|
||||
|
||||
release:
|
||||
runs-on: ubuntu-latest
|
||||
needs: [publish-main, publish-platform]
|
||||
if: always() && needs.publish-main.result == 'success' && (inputs.skip_platform == true || needs.publish-platform.result == 'success')
|
||||
needs: publish-main
|
||||
steps:
|
||||
- uses: actions/checkout@v4
|
||||
with:
|
||||
@@ -330,53 +269,13 @@ jobs:
|
||||
env:
|
||||
GH_TOKEN: ${{ secrets.GITHUB_TOKEN }}
|
||||
|
||||
- name: Apply release version to source tree
|
||||
env:
|
||||
VERSION: ${{ needs.publish-main.outputs.version }}
|
||||
run: |
|
||||
jq --arg v "$VERSION" '.version = $v' package.json > tmp.json && mv tmp.json package.json
|
||||
|
||||
for platform in darwin-arm64 darwin-x64 darwin-x64-baseline linux-x64 linux-x64-baseline linux-arm64 linux-x64-musl linux-x64-musl-baseline linux-arm64-musl windows-x64 windows-x64-baseline; do
|
||||
jq --arg v "$VERSION" '.version = $v' "packages/${platform}/package.json" > tmp.json
|
||||
mv tmp.json "packages/${platform}/package.json"
|
||||
done
|
||||
|
||||
jq --arg v "$VERSION" '.optionalDependencies = (.optionalDependencies | to_entries | map(.value = $v) | from_entries)' package.json > tmp.json && mv tmp.json package.json
|
||||
|
||||
- name: Commit version bump
|
||||
env:
|
||||
VERSION: ${{ needs.publish-main.outputs.version }}
|
||||
run: |
|
||||
git config user.email "github-actions[bot]@users.noreply.github.com"
|
||||
git config user.name "github-actions[bot]"
|
||||
git add package.json packages/*/package.json
|
||||
git diff --cached --quiet || git commit -m "release: v${VERSION}"
|
||||
|
||||
- name: Create release tag
|
||||
env:
|
||||
VERSION: ${{ needs.publish-main.outputs.version }}
|
||||
run: |
|
||||
if git rev-parse "v${VERSION}" >/dev/null 2>&1; then
|
||||
echo "::error::Tag v${VERSION} already exists"
|
||||
exit 1
|
||||
fi
|
||||
git tag "v${VERSION}"
|
||||
|
||||
- name: Push release state
|
||||
env:
|
||||
VERSION: ${{ needs.publish-main.outputs.version }}
|
||||
GITHUB_TOKEN: ${{ secrets.GITHUB_TOKEN }}
|
||||
run: |
|
||||
git push origin HEAD
|
||||
git push origin "v${VERSION}"
|
||||
|
||||
- name: Create GitHub release
|
||||
env:
|
||||
VERSION: ${{ needs.publish-main.outputs.version }}
|
||||
GH_TOKEN: ${{ secrets.GITHUB_TOKEN }}
|
||||
run: |
|
||||
VERSION="${{ needs.publish-main.outputs.version }}"
|
||||
gh release view "v${VERSION}" >/dev/null 2>&1 || \
|
||||
gh release create "v${VERSION}" --title "v${VERSION}" --notes-file /tmp/changelog.md
|
||||
env:
|
||||
GH_TOKEN: ${{ secrets.GITHUB_TOKEN }}
|
||||
|
||||
- name: Delete draft release
|
||||
run: gh release delete next --yes 2>/dev/null || true
|
||||
@@ -385,13 +284,13 @@ jobs:
|
||||
|
||||
- name: Merge to master
|
||||
continue-on-error: true
|
||||
env:
|
||||
VERSION: ${{ needs.publish-main.outputs.version }}
|
||||
GITHUB_TOKEN: ${{ secrets.GITHUB_TOKEN }}
|
||||
run: |
|
||||
git config user.name "github-actions[bot]"
|
||||
git config user.email "github-actions[bot]@users.noreply.github.com"
|
||||
VERSION="${{ needs.publish-main.outputs.version }}"
|
||||
git stash --include-untracked || true
|
||||
git checkout master
|
||||
git reset --hard "v${VERSION}"
|
||||
git push -f origin master || echo "::warning::Failed to push to master"
|
||||
env:
|
||||
GITHUB_TOKEN: ${{ secrets.GITHUB_TOKEN }}
|
||||
|
||||
46
.github/workflows/refresh-model-capabilities.yml
vendored
46
.github/workflows/refresh-model-capabilities.yml
vendored
@@ -1,46 +0,0 @@
|
||||
name: Refresh Model Capabilities
|
||||
|
||||
on:
|
||||
schedule:
|
||||
- cron: "17 4 * * 1"
|
||||
workflow_dispatch:
|
||||
|
||||
permissions:
|
||||
contents: write
|
||||
pull-requests: write
|
||||
|
||||
jobs:
|
||||
refresh:
|
||||
runs-on: ubuntu-latest
|
||||
if: github.repository == 'code-yeongyu/oh-my-openagent'
|
||||
steps:
|
||||
- uses: actions/checkout@v4
|
||||
|
||||
- uses: oven-sh/setup-bun@v2
|
||||
with:
|
||||
bun-version: latest
|
||||
|
||||
- name: Install dependencies
|
||||
run: bun install
|
||||
env:
|
||||
BUN_INSTALL_ALLOW_SCRIPTS: "@ast-grep/napi"
|
||||
|
||||
- name: Refresh bundled model capabilities snapshot
|
||||
run: bun run build:model-capabilities
|
||||
|
||||
- name: Validate capability guardrails
|
||||
run: bun run test:model-capabilities
|
||||
|
||||
- name: Create refresh pull request
|
||||
uses: peter-evans/create-pull-request@v7
|
||||
with:
|
||||
commit-message: "chore: refresh model capabilities snapshot"
|
||||
title: "chore: refresh model capabilities snapshot"
|
||||
body: |
|
||||
Automated refresh of `src/generated/model-capabilities.generated.json` from `https://models.dev/api.json`.
|
||||
|
||||
This keeps the bundled capability snapshot aligned with upstream model metadata without relying on manual refreshes.
|
||||
branch: automation/refresh-model-capabilities
|
||||
delete-branch: true
|
||||
labels: |
|
||||
maintenance
|
||||
2
.gitignore
vendored
2
.gitignore
vendored
@@ -9,7 +9,6 @@ dist/
|
||||
# Platform binaries (built, not committed)
|
||||
packages/*/bin/oh-my-opencode
|
||||
packages/*/bin/oh-my-opencode.exe
|
||||
packages/*/bin/*.map
|
||||
|
||||
# IDE
|
||||
.idea/
|
||||
@@ -36,4 +35,3 @@ test-injection/
|
||||
notepad.md
|
||||
oauth-success.html
|
||||
*.bun-build
|
||||
.omx/
|
||||
|
||||
61
.issue-comment-2064.md
Normal file
61
.issue-comment-2064.md
Normal file
@@ -0,0 +1,61 @@
|
||||
[sisyphus-bot]
|
||||
|
||||
## Confirmed Bug
|
||||
|
||||
We have identified the root cause of this issue. The bug is in the config writing logic during installation.
|
||||
|
||||
### Root Cause
|
||||
|
||||
**File:** `src/cli/config-manager/write-omo-config.ts` (line 46)
|
||||
|
||||
```typescript
|
||||
const merged = deepMergeRecord(existing, newConfig)
|
||||
```
|
||||
|
||||
When a user runs `oh-my-opencode install` (even just to update settings), the installer:
|
||||
1. Reads the existing config (with user's custom model settings)
|
||||
2. Generates a **new** config based on detected provider availability
|
||||
3. Calls `deepMergeRecord(existing, newConfig)`
|
||||
4. Writes the result back
|
||||
|
||||
**The problem:** `deepMergeRecord` overwrites values in `existing` with values from `newConfig`. This means your custom `"model": "openai/gpt-5.2-codex"` gets overwritten by the generated default model (e.g., `anthropic/claude-opus-4-6` if Claude is available).
|
||||
|
||||
### Why This Happens
|
||||
|
||||
Looking at `deepMergeRecord` (line 24-25):
|
||||
```typescript
|
||||
} else if (sourceValue !== undefined) {
|
||||
result[key] = sourceValue as TTarget[keyof TTarget]
|
||||
}
|
||||
```
|
||||
|
||||
Any defined value in the source (generated config) overwrites the target (user's config).
|
||||
|
||||
### Fix Approach
|
||||
|
||||
The merge direction should be reversed to respect user overrides:
|
||||
```typescript
|
||||
const merged = deepMergeRecord(newConfig, existing)
|
||||
```
|
||||
|
||||
This ensures:
|
||||
- User's explicit settings take precedence
|
||||
- Only new/undefined keys get populated from generated defaults
|
||||
- Custom model choices are preserved
|
||||
|
||||
### SEVERITY: HIGH
|
||||
|
||||
- **Impact:** User configuration is overwritten without consent
|
||||
- **Affected Files:**
|
||||
- `src/cli/config-manager/write-omo-config.ts`
|
||||
- `src/cli/config-manager/deep-merge-record.ts`
|
||||
- **Trigger:** Running `oh-my-opencode install` (even for unrelated updates)
|
||||
|
||||
### Workaround (Until Fix)
|
||||
|
||||
Backup your config before running install:
|
||||
```bash
|
||||
cp ~/.config/opencode/oh-my-opencode.jsonc ~/.config/opencode/oh-my-opencode.jsonc.backup
|
||||
```
|
||||
|
||||
We're working on a fix that will preserve your explicit model configurations.
|
||||
0
.openchrome/hints/hints-2026-03-09.jsonl
Normal file
0
.openchrome/hints/hints-2026-03-09.jsonl
Normal file
0
.openchrome/timeline/timeline-2026-03-09.jsonl
Normal file
0
.openchrome/timeline/timeline-2026-03-09.jsonl
Normal file
@@ -1,229 +1,105 @@
|
||||
---
|
||||
name: github-triage
|
||||
description: "Read-only GitHub triage for issues AND PRs. 1 item = 1 background task (category: quick). Analyzes all open items and writes evidence-backed reports to /tmp/{datetime}/. Every claim requires a GitHub permalink as proof. NEVER takes any action on GitHub - no comments, no merges, no closes, no labels. Reports only. Triggers: 'triage', 'triage issues', 'triage PRs', 'github triage'."
|
||||
description: "Unified GitHub triage for issues AND PRs. 1 item = 1 background task (category: free). Issues: answer questions from codebase, analyze bugs. PRs: review bugfixes, merge safe ones. All parallel, all background. Triggers: 'triage', 'triage issues', 'triage PRs', 'github triage'."
|
||||
---
|
||||
|
||||
# GitHub Triage - Read-Only Analyzer
|
||||
# GitHub Triage — Unified Issue & PR Processor
|
||||
|
||||
<role>
|
||||
Read-only GitHub triage orchestrator. Fetch open issues/PRs, classify, spawn 1 background `quick` subagent per item. Each subagent analyzes and writes a report file. ZERO GitHub mutations.
|
||||
You are a GitHub triage orchestrator. You fetch all open issues and PRs, classify each one, then spawn exactly 1 background subagent per item using `category="free"`. Each subagent analyzes its item, takes action (comment/close/merge/report), and records results via TaskCreate.
|
||||
</role>
|
||||
|
||||
## Architecture
|
||||
---
|
||||
|
||||
**1 ISSUE/PR = 1 `task_create` = 1 `quick` SUBAGENT (background). NO EXCEPTIONS.**
|
||||
## ARCHITECTURE
|
||||
|
||||
```
|
||||
1 issue or PR = 1 TaskCreate = 1 task(category="free", run_in_background=true)
|
||||
```
|
||||
|
||||
| Rule | Value |
|
||||
|------|-------|
|
||||
| Category | `quick` |
|
||||
| Execution | `run_in_background=true` |
|
||||
| Parallelism | ALL items simultaneously |
|
||||
| Tracking | `task_create` per item |
|
||||
| Output | `/tmp/{YYYYMMDD-HHmmss}/issue-{N}.md` or `pr-{N}.md` |
|
||||
| Category for ALL subagents | `free` |
|
||||
| Execution mode | `run_in_background=true` |
|
||||
| Parallelism | ALL items launched simultaneously |
|
||||
| Result tracking | Each subagent calls `TaskCreate` with its findings |
|
||||
| Result collection | `background_output()` polling loop |
|
||||
|
||||
---
|
||||
|
||||
## Zero-Action Policy (ABSOLUTE)
|
||||
## PHASE 1: FETCH ALL OPEN ITEMS
|
||||
|
||||
<zero_action>
|
||||
Subagents MUST NEVER run ANY command that writes or mutates GitHub state.
|
||||
|
||||
**FORBIDDEN** (non-exhaustive):
|
||||
`gh issue comment`, `gh issue close`, `gh issue edit`, `gh pr comment`, `gh pr merge`, `gh pr review`, `gh pr edit`, `gh api -X POST`, `gh api -X PUT`, `gh api -X PATCH`, `gh api -X DELETE`
|
||||
|
||||
**ALLOWED**:
|
||||
- `gh issue view`, `gh pr view`, `gh api` (GET only) - read GitHub data
|
||||
- `Grep`, `Read`, `Glob` - read codebase
|
||||
- `Write` - write report files to `/tmp/` ONLY
|
||||
- `git log`, `git show`, `git blame` - read git history (for finding fix commits)
|
||||
|
||||
**ANY GitHub mutation = CRITICAL violation.**
|
||||
</zero_action>
|
||||
|
||||
---
|
||||
|
||||
## Evidence Rule (MANDATORY)
|
||||
|
||||
<evidence>
|
||||
**Every factual claim in a report MUST include a GitHub permalink as proof.**
|
||||
|
||||
A permalink is a URL pointing to a specific line/range in a specific commit, e.g.:
|
||||
`https://github.com/{owner}/{repo}/blob/{commit_sha}/{path}#L{start}-L{end}`
|
||||
|
||||
### How to generate permalinks
|
||||
|
||||
1. Find the relevant file and line(s) via Grep/Read.
|
||||
2. Get the current commit SHA: `git rev-parse HEAD`
|
||||
3. Construct: `https://github.com/{REPO}/blob/{SHA}/{filepath}#L{line}` (or `#L{start}-L{end}` for ranges)
|
||||
|
||||
### Rules
|
||||
|
||||
- **No permalink = no claim.** If you cannot back a statement with a permalink, state "No evidence found" instead.
|
||||
- Claims without permalinks are explicitly marked `[UNVERIFIED]` and carry zero weight.
|
||||
- Permalinks to `main`/`master`/`dev` branches are NOT acceptable - use commit SHAs only.
|
||||
- For bug analysis: permalink to the problematic code. For fix verification: permalink to the fixing commit diff.
|
||||
</evidence>
|
||||
|
||||
---
|
||||
|
||||
## Phase 0: Setup
|
||||
<fetch>
|
||||
Run these commands to collect data. Use the bundled script if available, otherwise fall back to gh CLI.
|
||||
|
||||
```bash
|
||||
REPO=$(gh repo view --json nameWithOwner -q .nameWithOwner)
|
||||
REPORT_DIR="/tmp/$(date +%Y%m%d-%H%M%S)"
|
||||
mkdir -p "$REPORT_DIR"
|
||||
COMMIT_SHA=$(git rev-parse HEAD)
|
||||
|
||||
# Issues: all open
|
||||
gh issue list --repo $REPO --state open --limit 500 \
|
||||
--json number,title,state,createdAt,updatedAt,labels,author,body,comments
|
||||
|
||||
# PRs: all open
|
||||
gh pr list --repo $REPO --state open --limit 500 \
|
||||
--json number,title,state,createdAt,updatedAt,labels,author,body,headRefName,baseRefName,isDraft,mergeable,reviewDecision,statusCheckRollup
|
||||
```
|
||||
|
||||
Pass `REPO`, `REPORT_DIR`, and `COMMIT_SHA` to every subagent.
|
||||
If either returns exactly 500 results, paginate using `--search "created:<LAST_CREATED_AT"` until exhausted.
|
||||
</fetch>
|
||||
|
||||
---
|
||||
|
||||
---
|
||||
## PHASE 2: CLASSIFY EACH ITEM
|
||||
|
||||
## Phase 1: Fetch All Open Items (CORRECTED)
|
||||
For each item, determine its type based on title, labels, and body content:
|
||||
|
||||
**IMPORTANT:** `body` and `comments` fields may contain control characters that break jq parsing. Fetch basic metadata first, then fetch full details per-item in subagents.
|
||||
<classification>
|
||||
|
||||
```bash
|
||||
# Step 1: Fetch basic metadata (without body/comments to avoid JSON parsing issues)
|
||||
ISSUES_LIST=$(gh issue list --repo $REPO --state open --limit 500 \
|
||||
--json number,title,labels,author,createdAt)
|
||||
ISSUE_COUNT=$(echo "$ISSUES_LIST" | jq length)
|
||||
### Issues
|
||||
|
||||
# Paginate if needed
|
||||
if [ "$ISSUE_COUNT" -eq 500 ]; then
|
||||
LAST_DATE=$(echo "$ISSUES_LIST" | jq -r '.[-1].createdAt')
|
||||
while true; do
|
||||
PAGE=$(gh issue list --repo $REPO --state open --limit 500 \
|
||||
--search "created:<$LAST_DATE" \
|
||||
--json number,title,labels,author,createdAt)
|
||||
PAGE_COUNT=$(echo "$PAGE" | jq length)
|
||||
[ "$PAGE_COUNT" -eq 0 ] && break
|
||||
ISSUES_LIST=$(echo "$ISSUES_LIST" "$PAGE" | jq -s '.[0] + .[1] | unique_by(.number)')
|
||||
ISSUE_COUNT=$(echo "$ISSUES_LIST" | jq length)
|
||||
[ "$PAGE_COUNT" -lt 500 ] && break
|
||||
LAST_DATE=$(echo "$PAGE" | jq -r '.[-1].createdAt')
|
||||
done
|
||||
fi
|
||||
| Type | Detection | Action Path |
|
||||
|------|-----------|-------------|
|
||||
| `ISSUE_QUESTION` | Title contains `[Question]`, `[Discussion]`, `?`, or body is asking "how to" / "why does" / "is it possible" | SUBAGENT_ISSUE_QUESTION |
|
||||
| `ISSUE_BUG` | Title contains `[Bug]`, `Bug:`, body describes unexpected behavior, error messages, stack traces | SUBAGENT_ISSUE_BUG |
|
||||
| `ISSUE_FEATURE` | Title contains `[Feature]`, `[RFE]`, `[Enhancement]`, `Feature Request`, `Proposal` | SUBAGENT_ISSUE_FEATURE |
|
||||
| `ISSUE_OTHER` | Anything else | SUBAGENT_ISSUE_OTHER |
|
||||
|
||||
# Same for PRs
|
||||
PRS_LIST=$(gh pr list --repo $REPO --state open --limit 500 \
|
||||
--json number,title,labels,author,headRefName,baseRefName,isDraft,createdAt)
|
||||
PR_COUNT=$(echo "$PRS_LIST" | jq length)
|
||||
### PRs
|
||||
|
||||
if [ "$PR_COUNT" -eq 500 ]; then
|
||||
LAST_DATE=$(echo "$PRS_LIST" | jq -r '.[-1].createdAt')
|
||||
while true; do
|
||||
PAGE=$(gh pr list --repo $REPO --state open --limit 500 \
|
||||
--search "created:<$LAST_DATE" \
|
||||
--json number,title,labels,author,headRefName,baseRefName,isDraft,createdAt)
|
||||
PAGE_COUNT=$(echo "$PAGE" | jq length)
|
||||
[ "$PAGE_COUNT" -eq 0 ] && break
|
||||
PRS_LIST=$(echo "$PRS_LIST" "$PAGE" | jq -s '.[0] + .[1] | unique_by(.number)')
|
||||
PR_COUNT=$(echo "$PRS_LIST" | jq length)
|
||||
[ "$PAGE_COUNT" -lt 500 ] && break
|
||||
LAST_DATE=$(echo "$PAGE" | jq -r '.[-1].createdAt')
|
||||
done
|
||||
fi
|
||||
|
||||
echo "Total issues: $ISSUE_COUNT, Total PRs: $PR_COUNT"
|
||||
```
|
||||
|
||||
**LARGE REPOSITORY HANDLING:**
|
||||
If total items exceeds 50, you MUST process ALL items. Use the pagination code above to fetch every single open issue and PR.
|
||||
**DO NOT** sample or limit to 50 items - process the entire backlog.
|
||||
|
||||
Example: If there are 500 open issues, spawn 500 subagents. If there are 1000 open PRs, spawn 1000 subagents.
|
||||
|
||||
**Note:** Background task system will queue excess tasks automatically.
|
||||
| Type | Detection | Action Path |
|
||||
|------|-----------|-------------|
|
||||
| `PR_BUGFIX` | Title starts with `fix`, `fix:`, `fix(`, branch contains `fix/`, `bugfix/`, or labels include `bug` | SUBAGENT_PR_BUGFIX |
|
||||
| `PR_OTHER` | Everything else (feat, refactor, docs, chore, etc.) | SUBAGENT_PR_OTHER |
|
||||
|
||||
</classification>
|
||||
|
||||
---
|
||||
|
||||
## Phase 2: Classify
|
||||
## PHASE 3: SPAWN 1 BACKGROUND TASK PER ITEM
|
||||
|
||||
| Type | Detection |
|
||||
|------|-----------|
|
||||
| `ISSUE_QUESTION` | `[Question]`, `[Discussion]`, `?`, "how to" / "why does" / "is it possible" |
|
||||
| `ISSUE_BUG` | `[Bug]`, `Bug:`, error messages, stack traces, unexpected behavior |
|
||||
| `ISSUE_FEATURE` | `[Feature]`, `[RFE]`, `[Enhancement]`, `Feature Request`, `Proposal` |
|
||||
| `ISSUE_OTHER` | Anything else |
|
||||
| `PR_BUGFIX` | Title starts with `fix`, branch contains `fix/`/`bugfix/`, label `bug` |
|
||||
| `PR_OTHER` | Everything else |
|
||||
|
||||
---
|
||||
|
||||
## Phase 3: Spawn Subagents (Individual Tool Calls)
|
||||
|
||||
**CRITICAL: Create tasks ONE BY ONE using individual `task_create` tool calls. NEVER batch or script.**
|
||||
|
||||
For each item, execute these steps sequentially:
|
||||
|
||||
### Step 3.1: Create Task Record
|
||||
```typescript
|
||||
task_create(
|
||||
subject="Triage: #{number} {title}",
|
||||
description="GitHub {issue|PR} triage analysis - {type}",
|
||||
metadata={"type": "{ISSUE_QUESTION|ISSUE_BUG|ISSUE_FEATURE|ISSUE_OTHER|PR_BUGFIX|PR_OTHER}", "number": {number}}
|
||||
)
|
||||
```
|
||||
|
||||
### Step 3.2: Spawn Analysis Subagent (Background)
|
||||
```typescript
|
||||
task(
|
||||
category="quick",
|
||||
run_in_background=true,
|
||||
load_skills=[],
|
||||
prompt=SUBAGENT_PROMPT
|
||||
)
|
||||
```
|
||||
|
||||
**ABSOLUTE RULES for Subagents:**
|
||||
- **ONLY ANALYZE** - Never take action on GitHub (no comments, merges, closes)
|
||||
- **READ-ONLY** - Use tools only for reading code/GitHub data
|
||||
- **WRITE REPORT ONLY** - Output goes to `{REPORT_DIR}/{issue|pr}-{number}.md` via Write tool
|
||||
- **EVIDENCE REQUIRED** - Every claim must have GitHub permalink as proof
|
||||
For EVERY item, create a TaskCreate entry first, then spawn a background task.
|
||||
|
||||
```
|
||||
For each item:
|
||||
1. task_create(subject="Triage: #{number} {title}")
|
||||
2. task(category="quick", run_in_background=true, load_skills=[], prompt=SUBAGENT_PROMPT)
|
||||
1. TaskCreate(subject="Triage: #{number} {title}")
|
||||
2. task(category="free", run_in_background=true, load_skills=[], prompt=SUBAGENT_PROMPT)
|
||||
3. Store mapping: item_number -> { task_id, background_task_id }
|
||||
```
|
||||
|
||||
---
|
||||
|
||||
## Subagent Prompts
|
||||
|
||||
### Common Preamble (include in ALL subagent prompts)
|
||||
|
||||
```
|
||||
CONTEXT:
|
||||
- Repository: {REPO}
|
||||
- Report directory: {REPORT_DIR}
|
||||
- Current commit SHA: {COMMIT_SHA}
|
||||
|
||||
PERMALINK FORMAT:
|
||||
Every factual claim MUST include a permalink: https://github.com/{REPO}/blob/{COMMIT_SHA}/{filepath}#L{start}-L{end}
|
||||
No permalink = no claim. Mark unverifiable claims as [UNVERIFIED].
|
||||
To get current SHA if needed: git rev-parse HEAD
|
||||
|
||||
ABSOLUTE RULES (violating ANY = critical failure):
|
||||
- NEVER run gh issue comment, gh issue close, gh issue edit
|
||||
- NEVER run gh pr comment, gh pr merge, gh pr review, gh pr edit
|
||||
- NEVER run any gh command with -X POST, -X PUT, -X PATCH, -X DELETE
|
||||
- NEVER run git checkout, git fetch, git pull, git switch, git worktree
|
||||
- Your ONLY writable output: {REPORT_DIR}/{issue|pr}-{number}.md via the Write tool
|
||||
```
|
||||
## SUBAGENT PROMPT TEMPLATES
|
||||
|
||||
Each subagent gets an explicit, step-by-step prompt. Free models are limited — leave NOTHING implicit.
|
||||
|
||||
---
|
||||
|
||||
### ISSUE_QUESTION
|
||||
### SUBAGENT_ISSUE_QUESTION
|
||||
|
||||
<issue_question_prompt>
|
||||
|
||||
```
|
||||
You are analyzing issue #{number} for {REPO}.
|
||||
You are a GitHub issue responder for the repository {REPO}.
|
||||
|
||||
ITEM:
|
||||
- Issue #{number}: {title}
|
||||
@@ -231,43 +107,52 @@ ITEM:
|
||||
- Body: {body}
|
||||
- Comments: {comments_summary}
|
||||
|
||||
TASK:
|
||||
1. Understand the question.
|
||||
2. Search the codebase (Grep, Read) for the answer.
|
||||
3. For every finding, construct a permalink: https://github.com/{REPO}/blob/{COMMIT_SHA}/{path}#L{N}
|
||||
4. Write report to {REPORT_DIR}/issue-{number}.md
|
||||
YOUR JOB:
|
||||
1. Read the issue carefully. Understand what the user is asking.
|
||||
2. Search the codebase to find the answer. Use Grep and Read tools.
|
||||
- Search for relevant file names, function names, config keys mentioned in the issue.
|
||||
- Read the files you find to understand how the feature works.
|
||||
3. Decide: Can you answer this clearly and accurately from the codebase?
|
||||
|
||||
REPORT FORMAT (write this as the file content):
|
||||
IF YES (you found a clear, accurate answer):
|
||||
Step A: Write a helpful comment. The comment MUST:
|
||||
- Start with exactly: [sisyphus-bot]
|
||||
- Be warm, friendly, and thorough
|
||||
- Include specific file paths and code references
|
||||
- Include code snippets or config examples if helpful
|
||||
- End with "Feel free to reopen if this doesn't resolve your question!"
|
||||
Step B: Post the comment:
|
||||
gh issue comment {number} --repo {REPO} --body "YOUR_COMMENT"
|
||||
Step C: Close the issue:
|
||||
gh issue close {number} --repo {REPO}
|
||||
Step D: Report back with this EXACT format:
|
||||
ACTION: ANSWERED_AND_CLOSED
|
||||
COMMENT_POSTED: yes
|
||||
SUMMARY: [1-2 sentence summary of your answer]
|
||||
|
||||
# Issue #{number}: {title}
|
||||
**Type:** Question | **Author:** {author} | **Created:** {createdAt}
|
||||
IF NO (not enough info in codebase, or answer is uncertain):
|
||||
Report back with:
|
||||
ACTION: NEEDS_MANUAL_ATTENTION
|
||||
REASON: [why you couldn't answer — be specific]
|
||||
PARTIAL_FINDINGS: [what you DID find, if anything]
|
||||
|
||||
## Question
|
||||
[1-2 sentence summary]
|
||||
|
||||
## Findings
|
||||
[Each finding with permalink proof. Example:]
|
||||
- The config is parsed in [`src/config/loader.ts#L42-L58`](https://github.com/{REPO}/blob/{SHA}/src/config/loader.ts#L42-L58)
|
||||
|
||||
## Suggested Answer
|
||||
[Draft answer with code references and permalinks]
|
||||
|
||||
## Confidence: [HIGH | MEDIUM | LOW]
|
||||
[Reason. If LOW: what's missing]
|
||||
|
||||
## Recommended Action
|
||||
[What maintainer should do]
|
||||
|
||||
---
|
||||
REMEMBER: No permalink = no claim. Every code reference needs a permalink.
|
||||
RULES:
|
||||
- NEVER guess. Only answer if the codebase clearly supports your answer.
|
||||
- NEVER make up file paths or function names.
|
||||
- The [sisyphus-bot] prefix is MANDATORY on every comment you post.
|
||||
- Be genuinely helpful — imagine you're a senior maintainer who cares about the community.
|
||||
```
|
||||
|
||||
</issue_question_prompt>
|
||||
|
||||
---
|
||||
|
||||
### ISSUE_BUG
|
||||
### SUBAGENT_ISSUE_BUG
|
||||
|
||||
<issue_bug_prompt>
|
||||
|
||||
```
|
||||
You are analyzing bug report #{number} for {REPO}.
|
||||
You are a GitHub bug analyzer for the repository {REPO}.
|
||||
|
||||
ITEM:
|
||||
- Issue #{number}: {title}
|
||||
@@ -275,75 +160,74 @@ ITEM:
|
||||
- Body: {body}
|
||||
- Comments: {comments_summary}
|
||||
|
||||
TASK:
|
||||
1. Understand: expected behavior, actual behavior, reproduction steps.
|
||||
2. Search the codebase for relevant code. Trace the logic.
|
||||
3. Determine verdict: CONFIRMED_BUG, NOT_A_BUG, ALREADY_FIXED, or UNCLEAR.
|
||||
4. For ALREADY_FIXED: find the fixing commit using git log/git blame. Include the commit SHA and what changed.
|
||||
5. For every finding, construct a permalink.
|
||||
6. Write report to {REPORT_DIR}/issue-{number}.md
|
||||
YOUR JOB:
|
||||
1. Read the issue carefully. Understand the reported bug:
|
||||
- What behavior does the user expect?
|
||||
- What behavior do they actually see?
|
||||
- What steps reproduce it?
|
||||
2. Search the codebase for the relevant code. Use Grep and Read tools.
|
||||
- Find the files/functions mentioned or related to the bug.
|
||||
- Read them carefully and trace the logic.
|
||||
3. Determine one of three outcomes:
|
||||
|
||||
FINDING "ALREADY_FIXED" COMMITS:
|
||||
- Use `git log --all --oneline -- {file}` to find recent changes to relevant files
|
||||
- Use `git log --all --grep="fix" --grep="{keyword}" --all-match --oneline` to search commit messages
|
||||
- Use `git blame {file}` to find who last changed the relevant lines
|
||||
- Use `git show {commit_sha}` to verify the fix
|
||||
- Construct commit permalink: https://github.com/{REPO}/commit/{fix_commit_sha}
|
||||
OUTCOME A — CONFIRMED BUG (you found the problematic code):
|
||||
Step 1: Post a comment on the issue. The comment MUST:
|
||||
- Start with exactly: [sisyphus-bot]
|
||||
- Apologize sincerely for the inconvenience ("We're sorry you ran into this issue.")
|
||||
- Briefly acknowledge what the bug is
|
||||
- Say "We've identified the root cause and will work on a fix."
|
||||
- Do NOT reveal internal implementation details unnecessarily
|
||||
Step 2: Post the comment:
|
||||
gh issue comment {number} --repo {REPO} --body "YOUR_COMMENT"
|
||||
Step 3: Report back with:
|
||||
ACTION: CONFIRMED_BUG
|
||||
ROOT_CAUSE: [which file, which function, what goes wrong]
|
||||
FIX_APPROACH: [how to fix it — be specific: "In {file}, line ~{N}, change X to Y because Z"]
|
||||
SEVERITY: [LOW|MEDIUM|HIGH|CRITICAL]
|
||||
AFFECTED_FILES: [list of files that need changes]
|
||||
|
||||
REPORT FORMAT (write this as the file content):
|
||||
OUTCOME B — NOT A BUG (user misunderstanding, provably correct behavior):
|
||||
ONLY choose this if you can RIGOROUSLY PROVE the behavior is correct.
|
||||
Step 1: Post a comment. The comment MUST:
|
||||
- Start with exactly: [sisyphus-bot]
|
||||
- Be kind and empathetic — never condescending
|
||||
- Explain clearly WHY the current behavior is correct
|
||||
- Include specific code references or documentation links
|
||||
- Offer a workaround or alternative if possible
|
||||
- End with "Please let us know if you have further questions!"
|
||||
Step 2: Post the comment:
|
||||
gh issue comment {number} --repo {REPO} --body "YOUR_COMMENT"
|
||||
Step 3: DO NOT close the issue. Let the user or maintainer decide.
|
||||
Step 4: Report back with:
|
||||
ACTION: NOT_A_BUG
|
||||
EXPLANATION: [why this is correct behavior]
|
||||
PROOF: [specific code reference proving it]
|
||||
|
||||
# Issue #{number}: {title}
|
||||
**Type:** Bug Report | **Author:** {author} | **Created:** {createdAt}
|
||||
OUTCOME C — UNCLEAR (can't determine from codebase alone):
|
||||
Report back with:
|
||||
ACTION: NEEDS_INVESTIGATION
|
||||
FINDINGS: [what you found so far]
|
||||
BLOCKERS: [what's preventing you from determining the cause]
|
||||
SUGGESTED_NEXT_STEPS: [what a human should look at]
|
||||
|
||||
## Bug Summary
|
||||
**Expected:** [what user expects]
|
||||
**Actual:** [what actually happens]
|
||||
**Reproduction:** [steps if provided]
|
||||
|
||||
## Verdict: [CONFIRMED_BUG | NOT_A_BUG | ALREADY_FIXED | UNCLEAR]
|
||||
|
||||
## Analysis
|
||||
|
||||
### Evidence
|
||||
[Each piece of evidence with permalink. No permalink = mark [UNVERIFIED]]
|
||||
|
||||
### Root Cause (if CONFIRMED_BUG)
|
||||
[Which file, which function, what goes wrong]
|
||||
- Problematic code: [`{path}#L{N}`](permalink)
|
||||
|
||||
### Why Not A Bug (if NOT_A_BUG)
|
||||
[Rigorous proof with permalinks that current behavior is correct]
|
||||
|
||||
### Fix Details (if ALREADY_FIXED)
|
||||
- **Fixed in commit:** [`{short_sha}`](https://github.com/{REPO}/commit/{full_sha})
|
||||
- **Fixed date:** {date}
|
||||
- **What changed:** [description with diff permalink]
|
||||
- **Fixed by:** {author}
|
||||
|
||||
### Blockers (if UNCLEAR)
|
||||
[What prevents determination, what to investigate next]
|
||||
|
||||
## Severity: [LOW | MEDIUM | HIGH | CRITICAL]
|
||||
|
||||
## Affected Files
|
||||
[List with permalinks]
|
||||
|
||||
## Suggested Fix (if CONFIRMED_BUG)
|
||||
[Specific approach: "In {file}#L{N}, change X to Y because Z"]
|
||||
|
||||
## Recommended Action
|
||||
[What maintainer should do]
|
||||
|
||||
---
|
||||
CRITICAL: Claims without permalinks are worthless. If you cannot find evidence, say so explicitly rather than making unverified claims.
|
||||
RULES:
|
||||
- NEVER guess at root causes. Only report CONFIRMED_BUG if you found the exact problematic code.
|
||||
- NEVER close bug issues yourself. Only comment.
|
||||
- For OUTCOME B (not a bug): you MUST have rigorous proof. If there's ANY doubt, choose OUTCOME C instead.
|
||||
- The [sisyphus-bot] prefix is MANDATORY on every comment.
|
||||
- When apologizing, be genuine. The user took time to report this.
|
||||
```
|
||||
|
||||
</issue_bug_prompt>
|
||||
|
||||
---
|
||||
|
||||
### ISSUE_FEATURE
|
||||
### SUBAGENT_ISSUE_FEATURE
|
||||
|
||||
<issue_feature_prompt>
|
||||
|
||||
```
|
||||
You are analyzing feature request #{number} for {REPO}.
|
||||
You are a GitHub feature request analyzer for the repository {REPO}.
|
||||
|
||||
ITEM:
|
||||
- Issue #{number}: {title}
|
||||
@@ -351,41 +235,38 @@ ITEM:
|
||||
- Body: {body}
|
||||
- Comments: {comments_summary}
|
||||
|
||||
TASK:
|
||||
1. Understand the request.
|
||||
2. Search codebase for existing (partial/full) implementations.
|
||||
3. Assess feasibility.
|
||||
4. Write report to {REPORT_DIR}/issue-{number}.md
|
||||
YOUR JOB:
|
||||
1. Read the feature request.
|
||||
2. Search the codebase to check if this feature already exists (partially or fully).
|
||||
3. Assess feasibility and alignment with the project.
|
||||
|
||||
REPORT FORMAT (write this as the file content):
|
||||
Report back with:
|
||||
ACTION: FEATURE_ASSESSED
|
||||
ALREADY_EXISTS: [YES_FULLY | YES_PARTIALLY | NO]
|
||||
IF_EXISTS: [where in the codebase, how to use it]
|
||||
FEASIBILITY: [EASY | MODERATE | HARD | ARCHITECTURAL_CHANGE]
|
||||
RELEVANT_FILES: [files that would need changes]
|
||||
NOTES: [any observations about implementation approach]
|
||||
|
||||
# Issue #{number}: {title}
|
||||
**Type:** Feature Request | **Author:** {author} | **Created:** {createdAt}
|
||||
If the feature already fully exists:
|
||||
Post a comment (prefix: [sisyphus-bot]) explaining how to use the existing feature with examples.
|
||||
gh issue comment {number} --repo {REPO} --body "YOUR_COMMENT"
|
||||
|
||||
## Request Summary
|
||||
[What the user wants]
|
||||
|
||||
## Existing Implementation: [YES_FULLY | YES_PARTIALLY | NO]
|
||||
[If exists: where, with permalinks to the implementation]
|
||||
|
||||
## Feasibility: [EASY | MODERATE | HARD | ARCHITECTURAL_CHANGE]
|
||||
|
||||
## Relevant Files
|
||||
[With permalinks]
|
||||
|
||||
## Implementation Notes
|
||||
[Approach, pitfalls, dependencies]
|
||||
|
||||
## Recommended Action
|
||||
[What maintainer should do]
|
||||
RULES:
|
||||
- Do NOT close feature requests.
|
||||
- The [sisyphus-bot] prefix is MANDATORY on any comment.
|
||||
```
|
||||
|
||||
</issue_feature_prompt>
|
||||
|
||||
---
|
||||
|
||||
### ISSUE_OTHER
|
||||
### SUBAGENT_ISSUE_OTHER
|
||||
|
||||
<issue_other_prompt>
|
||||
|
||||
```
|
||||
You are analyzing issue #{number} for {REPO}.
|
||||
You are a GitHub issue analyzer for the repository {REPO}.
|
||||
|
||||
ITEM:
|
||||
- Issue #{number}: {title}
|
||||
@@ -393,195 +274,209 @@ ITEM:
|
||||
- Body: {body}
|
||||
- Comments: {comments_summary}
|
||||
|
||||
TASK: Assess and write report to {REPORT_DIR}/issue-{number}.md
|
||||
YOUR JOB:
|
||||
Quickly assess this issue and report:
|
||||
ACTION: ASSESSED
|
||||
TYPE_GUESS: [QUESTION | BUG | FEATURE | DISCUSSION | META | STALE]
|
||||
SUMMARY: [1-2 sentence summary]
|
||||
NEEDS_ATTENTION: [YES | NO]
|
||||
SUGGESTED_LABEL: [if any]
|
||||
|
||||
REPORT FORMAT (write this as the file content):
|
||||
|
||||
# Issue #{number}: {title}
|
||||
**Type:** [QUESTION | BUG | FEATURE | DISCUSSION | META | STALE]
|
||||
**Author:** {author} | **Created:** {createdAt}
|
||||
|
||||
## Summary
|
||||
[1-2 sentences]
|
||||
|
||||
## Needs Attention: [YES | NO]
|
||||
## Suggested Label: [if any]
|
||||
## Recommended Action: [what maintainer should do]
|
||||
Do NOT post comments. Do NOT close. Just analyze and report.
|
||||
```
|
||||
|
||||
</issue_other_prompt>
|
||||
|
||||
---
|
||||
|
||||
### PR_BUGFIX
|
||||
### SUBAGENT_PR_BUGFIX
|
||||
|
||||
<pr_bugfix_prompt>
|
||||
|
||||
```
|
||||
You are reviewing PR #{number} for {REPO}.
|
||||
You are a GitHub PR reviewer for the repository {REPO}.
|
||||
|
||||
ITEM:
|
||||
- PR #{number}: {title}
|
||||
- Author: {author}
|
||||
- Base: {baseRefName} <- Head: {headRefName}
|
||||
- Draft: {isDraft} | Mergeable: {mergeable}
|
||||
- Review: {reviewDecision} | CI: {statusCheckRollup_summary}
|
||||
- Base: {baseRefName}
|
||||
- Head: {headRefName}
|
||||
- Draft: {isDraft}
|
||||
- Mergeable: {mergeable}
|
||||
- Review Decision: {reviewDecision}
|
||||
- CI Status: {statusCheckRollup_summary}
|
||||
- Body: {body}
|
||||
|
||||
TASK:
|
||||
1. Fetch PR details (READ-ONLY): gh pr view {number} --repo {REPO} --json files,reviews,comments,statusCheckRollup,reviewDecision
|
||||
2. Read diff: gh api repos/{REPO}/pulls/{number}/files
|
||||
3. Search codebase to verify fix correctness.
|
||||
4. Write report to {REPORT_DIR}/pr-{number}.md
|
||||
YOUR JOB:
|
||||
1. Fetch PR details (DO NOT checkout the branch — read-only analysis):
|
||||
gh pr view {number} --repo {REPO} --json files,reviews,comments,statusCheckRollup,reviewDecision
|
||||
2. Read the changed files list. For each changed file, use `gh api repos/{REPO}/pulls/{number}/files` to see the diff.
|
||||
3. Search the codebase to understand what the PR is fixing and whether the fix is correct.
|
||||
4. Evaluate merge safety:
|
||||
|
||||
REPORT FORMAT (write this as the file content):
|
||||
MERGE CONDITIONS (ALL must be true for auto-merge):
|
||||
a. CI status checks: ALL passing (no failures, no pending)
|
||||
b. Review decision: APPROVED
|
||||
c. The fix is clearly correct — addresses an obvious, unambiguous bug
|
||||
d. No risky side effects (no architectural changes, no breaking changes)
|
||||
e. Not a draft PR
|
||||
f. Mergeable state is clean (no conflicts)
|
||||
|
||||
# PR #{number}: {title}
|
||||
**Type:** Bugfix | **Author:** {author}
|
||||
**Base:** {baseRefName} <- {headRefName} | **Draft:** {isDraft}
|
||||
IF ALL MERGE CONDITIONS MET:
|
||||
Step 1: Merge the PR:
|
||||
gh pr merge {number} --repo {REPO} --squash --auto
|
||||
Step 2: Report back with:
|
||||
ACTION: MERGED
|
||||
FIX_SUMMARY: [what bug was fixed and how]
|
||||
FILES_CHANGED: [list of files]
|
||||
RISK: NONE
|
||||
|
||||
## Fix Summary
|
||||
[What bug, how fixed - with permalinks to changed code]
|
||||
IF ANY CONDITION NOT MET:
|
||||
Report back with:
|
||||
ACTION: NEEDS_HUMAN_DECISION
|
||||
FIX_SUMMARY: [what the PR does]
|
||||
WHAT_IT_FIXES: [the bug or issue it addresses]
|
||||
CI_STATUS: [PASS | FAIL | PENDING — list any failures]
|
||||
REVIEW_STATUS: [APPROVED | CHANGES_REQUESTED | PENDING | NONE]
|
||||
MISSING: [what's preventing auto-merge — be specific]
|
||||
RISK_ASSESSMENT: [what could go wrong]
|
||||
AMBIGUOUS_PARTS: [anything that needs human judgment]
|
||||
RECOMMENDED_ACTION: [what the maintainer should do]
|
||||
|
||||
## Code Review
|
||||
|
||||
### Correctness
|
||||
[Is fix correct? Root cause addressed? Evidence with permalinks]
|
||||
|
||||
### Side Effects
|
||||
[Risky changes, breaking changes - with permalinks if any]
|
||||
|
||||
### Code Quality
|
||||
[Style, patterns, test coverage]
|
||||
|
||||
## Merge Readiness
|
||||
|
||||
| Check | Status |
|
||||
|-------|--------|
|
||||
| CI | [PASS / FAIL / PENDING] |
|
||||
| Review | [APPROVED / CHANGES_REQUESTED / PENDING / NONE] |
|
||||
| Mergeable | [YES / NO / CONFLICTED] |
|
||||
| Draft | [YES / NO] |
|
||||
| Correctness | [VERIFIED / CONCERNS / UNCLEAR] |
|
||||
| Risk | [NONE / LOW / MEDIUM / HIGH] |
|
||||
|
||||
## Files Changed
|
||||
[List with brief descriptions]
|
||||
|
||||
## Recommended Action: [MERGE | REQUEST_CHANGES | NEEDS_REVIEW | WAIT]
|
||||
[Reasoning with evidence]
|
||||
|
||||
---
|
||||
NEVER merge. NEVER comment. NEVER review. Write to file ONLY.
|
||||
ABSOLUTE RULES:
|
||||
- NEVER run `git checkout`, `git fetch`, `git pull`, or `git switch`. READ-ONLY via gh CLI and API.
|
||||
- NEVER checkout the PR branch. NEVER. Use `gh api` and `gh pr view` only.
|
||||
- Only merge if you are 100% certain ALL conditions are met. When in doubt, report instead.
|
||||
- The [sisyphus-bot] prefix is MANDATORY on any comment you post.
|
||||
```
|
||||
|
||||
</pr_bugfix_prompt>
|
||||
|
||||
---
|
||||
|
||||
### PR_OTHER
|
||||
### SUBAGENT_PR_OTHER
|
||||
|
||||
<pr_other_prompt>
|
||||
|
||||
```
|
||||
You are reviewing PR #{number} for {REPO}.
|
||||
You are a GitHub PR reviewer for the repository {REPO}.
|
||||
|
||||
ITEM:
|
||||
- PR #{number}: {title}
|
||||
- Author: {author}
|
||||
- Base: {baseRefName} <- Head: {headRefName}
|
||||
- Draft: {isDraft} | Mergeable: {mergeable}
|
||||
- Review: {reviewDecision} | CI: {statusCheckRollup_summary}
|
||||
- Base: {baseRefName}
|
||||
- Head: {headRefName}
|
||||
- Draft: {isDraft}
|
||||
- Mergeable: {mergeable}
|
||||
- Review Decision: {reviewDecision}
|
||||
- CI Status: {statusCheckRollup_summary}
|
||||
- Body: {body}
|
||||
|
||||
TASK:
|
||||
1. Fetch PR details (READ-ONLY): gh pr view {number} --repo {REPO} --json files,reviews,comments,statusCheckRollup,reviewDecision
|
||||
2. Read diff: gh api repos/{REPO}/pulls/{number}/files
|
||||
3. Write report to {REPORT_DIR}/pr-{number}.md
|
||||
YOUR JOB:
|
||||
1. Fetch PR details (READ-ONLY — no checkout):
|
||||
gh pr view {number} --repo {REPO} --json files,reviews,comments,statusCheckRollup,reviewDecision
|
||||
2. Read the changed files via `gh api repos/{REPO}/pulls/{number}/files`.
|
||||
3. Assess the PR and report:
|
||||
|
||||
REPORT FORMAT (write this as the file content):
|
||||
ACTION: PR_ASSESSED
|
||||
TYPE: [FEATURE | REFACTOR | DOCS | CHORE | TEST | OTHER]
|
||||
SUMMARY: [what this PR does in 2-3 sentences]
|
||||
CI_STATUS: [PASS | FAIL | PENDING]
|
||||
REVIEW_STATUS: [APPROVED | CHANGES_REQUESTED | PENDING | NONE]
|
||||
FILES_CHANGED: [count and key files]
|
||||
RISK_LEVEL: [LOW | MEDIUM | HIGH]
|
||||
ALIGNMENT: [does this fit the project direction? YES | NO | UNCLEAR]
|
||||
BLOCKERS: [anything preventing merge]
|
||||
RECOMMENDED_ACTION: [MERGE | REQUEST_CHANGES | NEEDS_REVIEW | CLOSE | WAIT]
|
||||
NOTES: [any observations for the maintainer]
|
||||
|
||||
# PR #{number}: {title}
|
||||
**Type:** [FEATURE | REFACTOR | DOCS | CHORE | TEST | OTHER]
|
||||
**Author:** {author}
|
||||
**Base:** {baseRefName} <- {headRefName} | **Draft:** {isDraft}
|
||||
|
||||
## Summary
|
||||
[2-3 sentences with permalinks to key changes]
|
||||
|
||||
## Status
|
||||
|
||||
| Check | Status |
|
||||
|-------|--------|
|
||||
| CI | [PASS / FAIL / PENDING] |
|
||||
| Review | [APPROVED / CHANGES_REQUESTED / PENDING / NONE] |
|
||||
| Mergeable | [YES / NO / CONFLICTED] |
|
||||
| Risk | [LOW / MEDIUM / HIGH] |
|
||||
| Alignment | [YES / NO / UNCLEAR] |
|
||||
|
||||
## Files Changed
|
||||
[Count and key files]
|
||||
|
||||
## Blockers
|
||||
[If any]
|
||||
|
||||
## Recommended Action: [MERGE | REQUEST_CHANGES | NEEDS_REVIEW | CLOSE | WAIT]
|
||||
[Reasoning]
|
||||
|
||||
---
|
||||
NEVER merge. NEVER comment. NEVER review. Write to file ONLY.
|
||||
ABSOLUTE RULES:
|
||||
- NEVER run `git checkout`, `git fetch`, `git pull`, or `git switch`. READ-ONLY.
|
||||
- NEVER checkout the PR branch. Use `gh api` and `gh pr view` only.
|
||||
- Do NOT merge non-bugfix PRs automatically. Report only.
|
||||
```
|
||||
|
||||
---
|
||||
|
||||
## Phase 4: Collect & Update
|
||||
|
||||
Poll `background_output()` per task. As each completes:
|
||||
1. Parse report.
|
||||
2. `task_update(id=task_id, status="completed", description=REPORT_SUMMARY)`
|
||||
3. Stream to user immediately.
|
||||
</pr_other_prompt>
|
||||
|
||||
---
|
||||
|
||||
## Phase 5: Final Summary
|
||||
## PHASE 4: COLLECT RESULTS & UPDATE TASKS
|
||||
|
||||
Write to `{REPORT_DIR}/SUMMARY.md` AND display to user:
|
||||
<collection>
|
||||
Poll `background_output()` for each spawned task. As each completes:
|
||||
|
||||
1. Parse the subagent's report.
|
||||
2. Update the corresponding TaskCreate entry:
|
||||
- `TaskUpdate(id=task_id, status="completed", description=FULL_REPORT_TEXT)`
|
||||
3. Stream the result to the user immediately — do not wait for all to finish.
|
||||
|
||||
Track counters:
|
||||
- issues_answered (commented + closed)
|
||||
- bugs_confirmed
|
||||
- bugs_not_a_bug
|
||||
- prs_merged
|
||||
- prs_needs_decision
|
||||
- features_assessed
|
||||
</collection>
|
||||
|
||||
---
|
||||
|
||||
## PHASE 5: FINAL SUMMARY
|
||||
|
||||
After all background tasks complete, produce a summary:
|
||||
|
||||
```markdown
|
||||
# GitHub Triage Report - {REPO}
|
||||
# GitHub Triage Report — {REPO}
|
||||
|
||||
**Date:** {date} | **Commit:** {COMMIT_SHA}
|
||||
**Date:** {date}
|
||||
**Items Processed:** {total}
|
||||
**Report Directory:** {REPORT_DIR}
|
||||
|
||||
## Issues ({issue_count})
|
||||
| Category | Count |
|
||||
|----------|-------|
|
||||
| Bug Confirmed | {n} |
|
||||
| Bug Already Fixed | {n} |
|
||||
| Not A Bug | {n} |
|
||||
| Needs Investigation | {n} |
|
||||
| Question Analyzed | {n} |
|
||||
| Feature Assessed | {n} |
|
||||
| Other | {n} |
|
||||
| Action | Count |
|
||||
|--------|-------|
|
||||
| Answered & Closed | {issues_answered} |
|
||||
| Bug Confirmed | {bugs_confirmed} |
|
||||
| Not A Bug (explained) | {bugs_not_a_bug} |
|
||||
| Feature Assessed | {features_assessed} |
|
||||
| Needs Manual Attention | {needs_manual} |
|
||||
|
||||
## PRs ({pr_count})
|
||||
| Category | Count |
|
||||
|----------|-------|
|
||||
| Bugfix Reviewed | {n} |
|
||||
| Other PR Reviewed | {n} |
|
||||
| Action | Count |
|
||||
|--------|-------|
|
||||
| Auto-Merged (safe bugfix) | {prs_merged} |
|
||||
| Needs Human Decision | {prs_needs_decision} |
|
||||
| Assessed (non-bugfix) | {prs_assessed} |
|
||||
|
||||
## Items Requiring Attention
|
||||
[Each item: number, title, verdict, 1-line summary, link to report file]
|
||||
|
||||
## Report Files
|
||||
[All generated files with paths]
|
||||
## Items Requiring Your Attention
|
||||
[List each item that needs human decision with its report summary]
|
||||
```
|
||||
|
||||
---
|
||||
|
||||
## Anti-Patterns
|
||||
## ANTI-PATTERNS
|
||||
|
||||
| Violation | Severity |
|
||||
|-----------|----------|
|
||||
| ANY GitHub mutation (comment/close/merge/review/label/edit) | **CRITICAL** |
|
||||
| Claim without permalink | **CRITICAL** |
|
||||
| Using category other than `quick` | CRITICAL |
|
||||
| Using any category other than `free` | CRITICAL |
|
||||
| Batching multiple items into one task | CRITICAL |
|
||||
| `run_in_background=false` | CRITICAL |
|
||||
| `git checkout` on PR branch | CRITICAL |
|
||||
| Guessing without codebase evidence | HIGH |
|
||||
| Not writing report to `{REPORT_DIR}` | HIGH |
|
||||
| Using branch name instead of commit SHA in permalink | HIGH |
|
||||
| Using `run_in_background=false` | CRITICAL |
|
||||
| Subagent running `git checkout` on a PR branch | CRITICAL |
|
||||
| Posting comment without `[sisyphus-bot]` prefix | CRITICAL |
|
||||
| Merging a PR that doesn't meet ALL 6 conditions | CRITICAL |
|
||||
| Closing a bug issue (only comment, never close bugs) | HIGH |
|
||||
| Guessing at answers without codebase evidence | HIGH |
|
||||
| Not recording results via TaskCreate/TaskUpdate | HIGH |
|
||||
|
||||
---
|
||||
|
||||
## QUICK START
|
||||
|
||||
When invoked:
|
||||
|
||||
1. `TaskCreate` for the overall triage job
|
||||
2. Fetch all open issues + PRs via gh CLI (paginate if needed)
|
||||
3. Classify each item (ISSUE_QUESTION, ISSUE_BUG, ISSUE_FEATURE, PR_BUGFIX, etc.)
|
||||
4. For EACH item: `TaskCreate` + `task(category="free", run_in_background=true, load_skills=[], prompt=...)`
|
||||
5. Poll `background_output()` — stream results as they arrive
|
||||
6. `TaskUpdate` each task with the subagent's findings
|
||||
7. Produce final summary report
|
||||
|
||||
@@ -1,407 +0,0 @@
|
||||
---
|
||||
name: pre-publish-review
|
||||
description: "Nuclear-grade 16-agent pre-publish release gate. Runs /get-unpublished-changes to detect all changes since last npm release, spawns up to 10 ultrabrain agents for deep per-change analysis, invokes /review-work (5 agents) for holistic review, and 1 oracle for overall release synthesis. Use before EVERY npm publish. Triggers: 'pre-publish review', 'review before publish', 'release review', 'pre-release review', 'ready to publish?', 'can I publish?', 'pre-publish', 'safe to publish', 'publishing review', 'pre-publish check'."
|
||||
---
|
||||
|
||||
# Pre-Publish Review — 16-Agent Release Gate
|
||||
|
||||
Three-layer review before publishing to npm. Every layer covers a different angle — together they catch what no single reviewer could.
|
||||
|
||||
| Layer | Agents | Type | What They Check |
|
||||
|-------|--------|------|-----------------|
|
||||
| Per-Change Deep Dive | up to 10 | ultrabrain | Each logical change group individually — correctness, edge cases, pattern adherence |
|
||||
| Holistic Review | 5 | review-work | Goal compliance, QA execution, code quality, security, context mining across full changeset |
|
||||
| Release Synthesis | 1 | oracle | Overall release readiness, version bump, breaking changes, deployment risk |
|
||||
|
||||
---
|
||||
|
||||
## Phase 0: Detect Unpublished Changes
|
||||
|
||||
Run `/get-unpublished-changes` FIRST. This is the single source of truth for what changed.
|
||||
|
||||
```
|
||||
skill(name="get-unpublished-changes")
|
||||
```
|
||||
|
||||
This command automatically:
|
||||
- Detects published npm version vs local version
|
||||
- Lists all commits since last release
|
||||
- Reads actual diffs (not just commit messages) to describe REAL changes
|
||||
- Groups changes by type (feat/fix/refactor/docs) with scope
|
||||
- Identifies breaking changes
|
||||
- Recommends version bump (patch/minor/major)
|
||||
|
||||
**Save the full output** — it feeds directly into Phase 1 grouping and all agent prompts.
|
||||
|
||||
Then capture raw data needed by agent prompts:
|
||||
|
||||
```bash
|
||||
# Extract versions (already in /get-unpublished-changes output)
|
||||
PUBLISHED=$(npm view oh-my-opencode version 2>/dev/null || echo "not published")
|
||||
LOCAL=$(node -p "require('./package.json').version" 2>/dev/null || echo "unknown")
|
||||
|
||||
# Raw data for agents (diffs, file lists)
|
||||
COMMITS=$(git log "v${PUBLISHED}"..HEAD --oneline 2>/dev/null || echo "no commits")
|
||||
COMMIT_COUNT=$(echo "$COMMITS" | wc -l | tr -d ' ')
|
||||
DIFF_STAT=$(git diff "v${PUBLISHED}"..HEAD --stat 2>/dev/null || echo "no diff")
|
||||
CHANGED_FILES=$(git diff --name-only "v${PUBLISHED}"..HEAD 2>/dev/null || echo "none")
|
||||
FILE_COUNT=$(echo "$CHANGED_FILES" | wc -l | tr -d ' ')
|
||||
```
|
||||
|
||||
If `PUBLISHED` is "not published", this is a first release — use the full git history instead.
|
||||
---
|
||||
|
||||
## Phase 1: Parse Changes into Groups
|
||||
|
||||
Use the `/get-unpublished-changes` output as the starting point — it already groups by scope and type.
|
||||
|
||||
**Grouping strategy:**
|
||||
1. Start from the `/get-unpublished-changes` analysis which already categorizes by feat/fix/refactor/docs with scope
|
||||
2. Further split by **module/area** — changes touching the same module or feature area belong together
|
||||
3. Target **up to 10 groups**. If fewer than 10 commits, each commit is its own group. If more than 10 logical areas, merge the smallest groups.
|
||||
4. For each group, extract:
|
||||
- **Group name**: Short descriptive label (e.g., "agent-model-resolution", "hook-system-refactor")
|
||||
- **Commits**: List of commit hashes and messages
|
||||
- **Files**: Changed files in this group
|
||||
- **Diff**: The relevant portion of the full diff (`git diff v${PUBLISHED}..HEAD -- {group files}`)
|
||||
|
||||
---
|
||||
|
||||
## Phase 2: Spawn All Agents
|
||||
|
||||
Launch ALL agents in a single turn. Every agent uses `run_in_background=true`. No sequential launches.
|
||||
|
||||
### Layer 1: Ultrabrain Per-Change Analysis (up to 10)
|
||||
|
||||
For each change group, spawn one ultrabrain agent. Each gets only its portion of the diff — not the full changeset.
|
||||
|
||||
```
|
||||
task(
|
||||
category="ultrabrain",
|
||||
run_in_background=true,
|
||||
load_skills=[],
|
||||
description="Deep analysis: {GROUP_NAME}",
|
||||
prompt="""
|
||||
<review_type>PER-CHANGE DEEP ANALYSIS</review_type>
|
||||
<change_group>{GROUP_NAME}</change_group>
|
||||
|
||||
<project>oh-my-opencode (npm package)</project>
|
||||
<published_version>{PUBLISHED}</published_version>
|
||||
<target_version>{LOCAL}</target_version>
|
||||
|
||||
<commits>
|
||||
{GROUP_COMMITS — hash and message for each commit in this group}
|
||||
</commits>
|
||||
|
||||
<changed_files>
|
||||
{GROUP_FILES — files changed in this group}
|
||||
</changed_files>
|
||||
|
||||
<diff>
|
||||
{GROUP_DIFF — only the diff for this group's files}
|
||||
</diff>
|
||||
|
||||
<file_contents>
|
||||
{Read and include full content of each changed file in this group}
|
||||
</file_contents>
|
||||
|
||||
You are reviewing a specific subset of changes heading into an npm release. Focus exclusively on THIS change group. Other groups are reviewed by parallel agents.
|
||||
|
||||
ANALYSIS CHECKLIST:
|
||||
|
||||
1. **Intent Clarity**: What is this change trying to do? Is the intent clear from the code and commit messages? If you have to guess, that's a finding.
|
||||
|
||||
2. **Correctness**: Trace through the logic for 3+ scenarios. Does the code actually do what it claims? Off-by-one errors, null handling, async edge cases, resource cleanup.
|
||||
|
||||
3. **Breaking Changes**: Does this change alter any public API, config format, CLI behavior, or hook contract? If yes, is it backward compatible? Would existing users be surprised?
|
||||
|
||||
4. **Pattern Adherence**: Does the new code follow the established patterns visible in the existing file contents? New patterns where old ones exist = finding.
|
||||
|
||||
5. **Edge Cases**: What inputs or conditions would break this? Empty arrays, undefined values, concurrent calls, very large inputs, missing config fields.
|
||||
|
||||
6. **Error Handling**: Are errors properly caught and propagated? No empty catch blocks? No swallowed promises?
|
||||
|
||||
7. **Type Safety**: Any `as any`, `@ts-ignore`, `@ts-expect-error`? Loose typing where strict is possible?
|
||||
|
||||
8. **Test Coverage**: Are the behavioral changes covered by tests? Are the tests meaningful or just coverage padding?
|
||||
|
||||
9. **Side Effects**: Could this change break something in a different module? Check imports and exports — who depends on what changed?
|
||||
|
||||
10. **Release Risk**: On a scale of SAFE / CAUTION / RISKY — how confident are you this change won't cause issues in production?
|
||||
|
||||
OUTPUT FORMAT:
|
||||
<group_name>{GROUP_NAME}</group_name>
|
||||
<verdict>PASS or FAIL</verdict>
|
||||
<risk>SAFE / CAUTION / RISKY</risk>
|
||||
<summary>2-3 sentence assessment of this change group</summary>
|
||||
<has_breaking_changes>YES or NO</has_breaking_changes>
|
||||
<breaking_change_details>If YES, describe what breaks and for whom</breaking_change_details>
|
||||
<findings>
|
||||
For each finding:
|
||||
- [CRITICAL/MAJOR/MINOR] Category: Description
|
||||
- File: path (line range)
|
||||
- Evidence: specific code reference
|
||||
- Suggestion: how to fix
|
||||
</findings>
|
||||
<blocking_issues>Issues that MUST be fixed before publish. Empty if PASS.</blocking_issues>
|
||||
""")
|
||||
```
|
||||
|
||||
### Layer 2: Holistic Review via /review-work (5 agents)
|
||||
|
||||
Spawn a sub-agent that loads the `/review-work` skill. The review-work skill internally launches 5 parallel agents: Oracle (goal verification), unspecified-high (QA execution), Oracle (code quality), Oracle (security), unspecified-high (context mining). All 5 must pass for the review to pass.
|
||||
|
||||
```
|
||||
task(
|
||||
category="unspecified-high",
|
||||
run_in_background=true,
|
||||
load_skills=["review-work"],
|
||||
description="Run /review-work on all unpublished changes",
|
||||
prompt="""
|
||||
Run /review-work on the unpublished changes between v{PUBLISHED} and HEAD.
|
||||
|
||||
GOAL: Review all changes heading into npm publish of oh-my-opencode. These changes span {COMMIT_COUNT} commits across {FILE_COUNT} files.
|
||||
|
||||
CONSTRAINTS:
|
||||
- This is a plugin published to npm — public API stability matters
|
||||
- TypeScript strict mode, Bun runtime
|
||||
- No `as any`, `@ts-ignore`, `@ts-expect-error`
|
||||
- Factory pattern (createXXX) for tools, hooks, agents
|
||||
- kebab-case files, barrel exports, no catch-all files
|
||||
|
||||
BACKGROUND: Pre-publish review of oh-my-opencode, an OpenCode plugin with 1268 TypeScript files, 160k LOC. Changes since v{PUBLISHED} are about to be published.
|
||||
|
||||
The diff base is: git diff v{PUBLISHED}..HEAD
|
||||
|
||||
Follow the /review-work skill flow exactly — launch all 5 review agents and collect results. Do NOT skip any of the 5 agents.
|
||||
""")
|
||||
```
|
||||
|
||||
### Layer 3: Oracle Release Synthesis (1 agent)
|
||||
|
||||
The oracle gets the full picture — all commits, full diff stat, and changed file list. It provides the final release readiness assessment.
|
||||
|
||||
```
|
||||
task(
|
||||
subagent_type="oracle",
|
||||
run_in_background=true,
|
||||
load_skills=[],
|
||||
description="Oracle: overall release synthesis and version bump recommendation",
|
||||
prompt="""
|
||||
<review_type>RELEASE SYNTHESIS — OVERALL ASSESSMENT</review_type>
|
||||
|
||||
<project>oh-my-opencode (npm package)</project>
|
||||
<published_version>{PUBLISHED}</published_version>
|
||||
<local_version>{LOCAL}</local_version>
|
||||
|
||||
<all_commits>
|
||||
{ALL COMMITS since published version — hash, message, author, date}
|
||||
</all_commits>
|
||||
|
||||
<diff_stat>
|
||||
{DIFF_STAT — files changed, insertions, deletions}
|
||||
</diff_stat>
|
||||
|
||||
<changed_files>
|
||||
{CHANGED_FILES — full list of modified file paths}
|
||||
</changed_files>
|
||||
|
||||
<full_diff>
|
||||
{FULL_DIFF — the complete git diff between published version and HEAD}
|
||||
</full_diff>
|
||||
|
||||
<file_contents>
|
||||
{Read and include full content of KEY changed files — focus on public API surfaces, config schemas, agent definitions, hook registrations, tool registrations}
|
||||
</file_contents>
|
||||
|
||||
You are the final gate before an npm publish. 10 ultrabrain agents are reviewing individual changes and 5 review-work agents are doing holistic review. Your job is the bird's-eye view that those focused reviews might miss.
|
||||
|
||||
SYNTHESIS CHECKLIST:
|
||||
|
||||
1. **Release Coherence**: Do these changes tell a coherent story? Or is this a grab-bag of unrelated changes that should be split into multiple releases?
|
||||
|
||||
2. **Version Bump**: Based on semver:
|
||||
- PATCH: Bug fixes only, no behavior changes
|
||||
- MINOR: New features, backward-compatible changes
|
||||
- MAJOR: Breaking changes to public API, config format, or behavior
|
||||
Recommend the correct bump with specific justification.
|
||||
|
||||
3. **Breaking Changes Audit**: Exhaustively list every change that could break existing users. Check:
|
||||
- Config schema changes (new required fields, removed fields, renamed fields)
|
||||
- Agent behavior changes (different prompts, different model routing)
|
||||
- Hook contract changes (new parameters, removed hooks, renamed hooks)
|
||||
- Tool interface changes (new required params, different return types)
|
||||
- CLI changes (new commands, changed flags, different output)
|
||||
- Skill format changes (SKILL.md schema changes)
|
||||
|
||||
4. **Migration Requirements**: If there are breaking changes, what migration steps do users need? Is there auto-migration in place?
|
||||
|
||||
5. **Dependency Changes**: New dependencies added? Dependencies removed? Version bumps? Any supply chain risk?
|
||||
|
||||
6. **Changelog Draft**: Write a draft changelog entry grouped by:
|
||||
- feat: New features
|
||||
- fix: Bug fixes
|
||||
- refactor: Internal changes (no user impact)
|
||||
- breaking: Breaking changes with migration instructions
|
||||
- docs: Documentation changes
|
||||
|
||||
7. **Deployment Risk Assessment**:
|
||||
- SAFE: Routine changes, well-tested, low risk
|
||||
- CAUTION: Significant changes but manageable risk
|
||||
- RISKY: Large surface area changes, insufficient testing, or breaking changes without migration
|
||||
- BLOCK: Critical issues found, do NOT publish
|
||||
|
||||
8. **Post-Publish Monitoring**: What should be monitored after publish? Error rates, specific features, user feedback channels.
|
||||
|
||||
OUTPUT FORMAT:
|
||||
<verdict>SAFE / CAUTION / RISKY / BLOCK</verdict>
|
||||
<recommended_version_bump>PATCH / MINOR / MAJOR</recommended_version_bump>
|
||||
<version_bump_justification>Why this bump level</version_bump_justification>
|
||||
<release_coherence>Assessment of whether changes belong in one release</release_coherence>
|
||||
<breaking_changes>
|
||||
Exhaustive list, or "None" if none.
|
||||
For each:
|
||||
- What changed
|
||||
- Who is affected
|
||||
- Migration steps
|
||||
</breaking_changes>
|
||||
<changelog_draft>
|
||||
Ready-to-use changelog entry
|
||||
</changelog_draft>
|
||||
<deployment_risk>
|
||||
Overall risk assessment with specific concerns
|
||||
</deployment_risk>
|
||||
<monitoring_recommendations>
|
||||
What to watch after publish
|
||||
</monitoring_recommendations>
|
||||
<blocking_issues>Issues that MUST be fixed before publish. Empty if SAFE.</blocking_issues>
|
||||
""")
|
||||
```
|
||||
|
||||
---
|
||||
|
||||
## Phase 3: Collect Results
|
||||
|
||||
As agents complete (system notifications), collect via `background_output(task_id="...")`.
|
||||
|
||||
Track completion in a table:
|
||||
|
||||
| # | Agent | Type | Status | Verdict |
|
||||
|---|-------|------|--------|---------|
|
||||
| 1-10 | Ultrabrain: {group_name} | ultrabrain | pending | — |
|
||||
| 11 | Review-Work Coordinator | unspecified-high | pending | — |
|
||||
| 12 | Release Synthesis Oracle | oracle | pending | — |
|
||||
|
||||
Do NOT deliver the final report until ALL agents have completed.
|
||||
|
||||
---
|
||||
|
||||
## Phase 4: Final Verdict
|
||||
|
||||
<verdict_logic>
|
||||
|
||||
**BLOCK** if:
|
||||
- Oracle verdict is BLOCK
|
||||
- Any ultrabrain found CRITICAL blocking issues
|
||||
- Review-work failed on any MAIN agent
|
||||
|
||||
**RISKY** if:
|
||||
- Oracle verdict is RISKY
|
||||
- Multiple ultrabrains returned CAUTION or FAIL
|
||||
- Review-work passed but with significant findings
|
||||
|
||||
**CAUTION** if:
|
||||
- Oracle verdict is CAUTION
|
||||
- A few ultrabrains flagged minor issues
|
||||
- Review-work passed cleanly
|
||||
|
||||
**SAFE** if:
|
||||
- Oracle verdict is SAFE
|
||||
- All ultrabrains passed
|
||||
- Review-work passed
|
||||
|
||||
</verdict_logic>
|
||||
|
||||
Compile the final report:
|
||||
|
||||
```markdown
|
||||
# Pre-Publish Review — oh-my-opencode
|
||||
|
||||
## Release: v{PUBLISHED} -> v{LOCAL}
|
||||
**Commits:** {COMMIT_COUNT} | **Files Changed:** {FILE_COUNT} | **Agents:** {AGENT_COUNT}
|
||||
|
||||
---
|
||||
|
||||
## Overall Verdict: SAFE / CAUTION / RISKY / BLOCK
|
||||
|
||||
## Recommended Version Bump: PATCH / MINOR / MAJOR
|
||||
{Justification from Oracle}
|
||||
|
||||
---
|
||||
|
||||
## Per-Change Analysis (Ultrabrains)
|
||||
|
||||
| # | Change Group | Verdict | Risk | Breaking? | Blocking Issues |
|
||||
|---|-------------|---------|------|-----------|-----------------|
|
||||
| 1 | {name} | PASS/FAIL | SAFE/CAUTION/RISKY | YES/NO | {count or "none"} |
|
||||
| ... | ... | ... | ... | ... | ... |
|
||||
|
||||
### Blocking Issues from Per-Change Analysis
|
||||
{Aggregated from all ultrabrains — deduplicated}
|
||||
|
||||
---
|
||||
|
||||
## Holistic Review (Review-Work)
|
||||
|
||||
| # | Review Area | Verdict | Confidence |
|
||||
|---|------------|---------|------------|
|
||||
| 1 | Goal & Constraint Verification | PASS/FAIL | HIGH/MED/LOW |
|
||||
| 2 | QA Execution | PASS/FAIL | HIGH/MED/LOW |
|
||||
| 3 | Code Quality | PASS/FAIL | HIGH/MED/LOW |
|
||||
| 4 | Security | PASS/FAIL | Severity |
|
||||
| 5 | Context Mining | PASS/FAIL | HIGH/MED/LOW |
|
||||
|
||||
### Blocking Issues from Holistic Review
|
||||
{Aggregated from review-work}
|
||||
|
||||
---
|
||||
|
||||
## Release Synthesis (Oracle)
|
||||
|
||||
### Breaking Changes
|
||||
{From Oracle — exhaustive list or "None"}
|
||||
|
||||
### Changelog Draft
|
||||
{From Oracle — ready to use}
|
||||
|
||||
### Deployment Risk
|
||||
{From Oracle — specific concerns}
|
||||
|
||||
### Post-Publish Monitoring
|
||||
{From Oracle — what to watch}
|
||||
|
||||
---
|
||||
|
||||
## All Blocking Issues (Prioritized)
|
||||
{Deduplicated, merged from all three layers, ordered by severity}
|
||||
|
||||
## Recommendations
|
||||
{If BLOCK/RISKY: exactly what to fix, in priority order}
|
||||
{If CAUTION: suggestions worth considering before publish}
|
||||
{If SAFE: non-blocking improvements for future}
|
||||
```
|
||||
|
||||
---
|
||||
|
||||
## Anti-Patterns
|
||||
|
||||
| Violation | Severity |
|
||||
|-----------|----------|
|
||||
| Publishing without waiting for all agents | **CRITICAL** |
|
||||
| Spawning ultrabrains sequentially instead of in parallel | CRITICAL |
|
||||
| Using `run_in_background=false` for any agent | CRITICAL |
|
||||
| Skipping the Oracle synthesis | HIGH |
|
||||
| Not reading file contents for Oracle (it cannot read files) | HIGH |
|
||||
| Grouping all changes into 1-2 ultrabrains instead of distributing | HIGH |
|
||||
| Delivering verdict before all agents complete | HIGH |
|
||||
| Not including diff in ultrabrain prompts | MAJOR |
|
||||
@@ -1,76 +0,0 @@
|
||||
{
|
||||
"skill_name": "work-with-pr",
|
||||
"evals": [
|
||||
{
|
||||
"id": 1,
|
||||
"prompt": "I need to add a `max_background_agents` config option to oh-my-opencode that limits how many background agents can run simultaneously. It should be in the plugin config schema with a default of 5. Add validation and make sure the background manager respects it. Create a PR for this.",
|
||||
"expected_output": "Agent creates worktree, implements config option with schema validation, adds tests, creates PR, iterates through verification gates until merged",
|
||||
"files": [],
|
||||
"assertions": [
|
||||
{"id": "worktree-isolation", "text": "Plan uses git worktree in a sibling directory (not main working directory)"},
|
||||
{"id": "branch-from-dev", "text": "Branch is created from origin/dev (not master/main)"},
|
||||
{"id": "atomic-commits", "text": "Plan specifies multiple atomic commits for multi-file changes"},
|
||||
{"id": "local-validation", "text": "Runs bun run typecheck, bun test, and bun run build before pushing"},
|
||||
{"id": "pr-targets-dev", "text": "PR is created targeting dev branch (not master)"},
|
||||
{"id": "three-gates", "text": "Verification loop includes all 3 gates: CI, review-work, and Cubic"},
|
||||
{"id": "gate-ordering", "text": "Gates are checked in order: CI first, then review-work, then Cubic"},
|
||||
{"id": "cubic-check-method", "text": "Cubic check uses gh api to check cubic-dev-ai[bot] reviews for 'No issues found'"},
|
||||
{"id": "worktree-cleanup", "text": "Plan includes worktree cleanup after merge"},
|
||||
{"id": "real-file-references", "text": "Code changes reference actual files in the codebase (config schema, background manager)"}
|
||||
]
|
||||
},
|
||||
{
|
||||
"id": 2,
|
||||
"prompt": "The atlas hook has a bug where it crashes when boulder.json is missing the worktree_path field. Fix it and land the fix as a PR. Make sure CI passes.",
|
||||
"expected_output": "Agent creates worktree for the fix branch, adds null check and test for missing worktree_path, creates PR, iterates verification loop",
|
||||
"files": [],
|
||||
"assertions": [
|
||||
{"id": "worktree-isolation", "text": "Plan uses git worktree in a sibling directory"},
|
||||
{"id": "minimal-fix", "text": "Fix is minimal — adds null check, doesn't refactor unrelated code"},
|
||||
{"id": "test-added", "text": "Test case added for the missing worktree_path scenario"},
|
||||
{"id": "three-gates", "text": "Verification loop includes all 3 gates: CI, review-work, Cubic"},
|
||||
{"id": "real-atlas-files", "text": "References actual atlas hook files in src/hooks/atlas/"},
|
||||
{"id": "fix-branch-naming", "text": "Branch name follows fix/ prefix convention"}
|
||||
]
|
||||
},
|
||||
{
|
||||
"id": 3,
|
||||
"prompt": "Refactor src/tools/delegate-task/constants.ts to split DEFAULT_CATEGORIES and CATEGORY_MODEL_REQUIREMENTS into separate files. Keep backward compatibility with the barrel export. Make a PR.",
|
||||
"expected_output": "Agent creates worktree, splits file with atomic commits, ensures imports still work via barrel, creates PR, runs through all gates",
|
||||
"files": [],
|
||||
"assertions": [
|
||||
{"id": "worktree-isolation", "text": "Plan uses git worktree in a sibling directory"},
|
||||
{"id": "multiple-atomic-commits", "text": "Uses 2+ commits for the multi-file refactor"},
|
||||
{"id": "barrel-export", "text": "Maintains backward compatibility via barrel re-export in constants.ts or index.ts"},
|
||||
{"id": "three-gates", "text": "Verification loop includes all 3 gates"},
|
||||
{"id": "real-constants-file", "text": "References actual src/tools/delegate-task/constants.ts file and its exports"}
|
||||
]
|
||||
},
|
||||
{
|
||||
"id": 4,
|
||||
"prompt": "implement issue #100 - we need to add a new built-in MCP for arxiv paper search. just the basic search endpoint, nothing fancy. pr it",
|
||||
"expected_output": "Agent creates worktree, implements arxiv MCP following existing MCP patterns (websearch, context7, grep_app), creates PR with proper template, verification loop runs",
|
||||
"files": [],
|
||||
"assertions": [
|
||||
{"id": "worktree-isolation", "text": "Plan uses git worktree in a sibling directory"},
|
||||
{"id": "follows-mcp-pattern", "text": "New MCP follows existing pattern from src/mcp/ (websearch, context7, grep_app)"},
|
||||
{"id": "three-gates", "text": "Verification loop includes all 3 gates"},
|
||||
{"id": "pr-targets-dev", "text": "PR targets dev branch"},
|
||||
{"id": "local-validation", "text": "Runs local checks before pushing"}
|
||||
]
|
||||
},
|
||||
{
|
||||
"id": 5,
|
||||
"prompt": "The comment-checker hook is too aggressive - it's flagging legitimate comments that happen to contain 'Note:' as AI slop. Relax the regex pattern and add test cases for the false positives. Work on a separate branch and make a PR.",
|
||||
"expected_output": "Agent creates worktree, fixes regex, adds specific test cases for false positive scenarios, creates PR, all three gates pass",
|
||||
"files": [],
|
||||
"assertions": [
|
||||
{"id": "worktree-isolation", "text": "Plan uses git worktree in a sibling directory"},
|
||||
{"id": "real-comment-checker-files", "text": "References actual comment-checker hook files in the codebase"},
|
||||
{"id": "regression-tests", "text": "Adds test cases specifically for 'Note:' false positive scenarios"},
|
||||
{"id": "three-gates", "text": "Verification loop includes all 3 gates"},
|
||||
{"id": "minimal-change", "text": "Only modifies regex and adds tests — no unrelated changes"}
|
||||
]
|
||||
}
|
||||
]
|
||||
}
|
||||
@@ -1,138 +0,0 @@
|
||||
{
|
||||
"skill_name": "work-with-pr",
|
||||
"iteration": 1,
|
||||
"summary": {
|
||||
"with_skill": {
|
||||
"pass_rate": 0.968,
|
||||
"mean_duration_seconds": 340.2,
|
||||
"stddev_duration_seconds": 169.3
|
||||
},
|
||||
"without_skill": {
|
||||
"pass_rate": 0.516,
|
||||
"mean_duration_seconds": 303.0,
|
||||
"stddev_duration_seconds": 77.8
|
||||
},
|
||||
"delta": {
|
||||
"pass_rate": 0.452,
|
||||
"mean_duration_seconds": 37.2,
|
||||
"stddev_duration_seconds": 91.5
|
||||
}
|
||||
},
|
||||
"evals": [
|
||||
{
|
||||
"eval_name": "happy-path-feature-config-option",
|
||||
"with_skill": {
|
||||
"pass_rate": 1.0,
|
||||
"passed": 10,
|
||||
"total": 10,
|
||||
"duration_seconds": 292,
|
||||
"failed_assertions": []
|
||||
},
|
||||
"without_skill": {
|
||||
"pass_rate": 0.4,
|
||||
"passed": 4,
|
||||
"total": 10,
|
||||
"duration_seconds": 365,
|
||||
"failed_assertions": [
|
||||
{"assertion": "Plan uses git worktree in a sibling directory", "reason": "Uses git checkout -b, no worktree isolation"},
|
||||
{"assertion": "Plan specifies multiple atomic commits for multi-file changes", "reason": "Steps listed sequentially but no atomic commit strategy mentioned"},
|
||||
{"assertion": "Verification loop includes all 3 gates: CI, review-work, and Cubic", "reason": "Only mentions CI pipeline in step 6. No review-work or Cubic."},
|
||||
{"assertion": "Gates are checked in order: CI first, then review-work, then Cubic", "reason": "No gate ordering - only CI mentioned"},
|
||||
{"assertion": "Cubic check uses gh api to check cubic-dev-ai[bot] reviews", "reason": "No mention of Cubic at all"},
|
||||
{"assertion": "Plan includes worktree cleanup after merge", "reason": "No worktree used, no cleanup needed"}
|
||||
]
|
||||
}
|
||||
},
|
||||
{
|
||||
"eval_name": "bugfix-atlas-null-check",
|
||||
"with_skill": {
|
||||
"pass_rate": 1.0,
|
||||
"passed": 6,
|
||||
"total": 6,
|
||||
"duration_seconds": 506,
|
||||
"failed_assertions": []
|
||||
},
|
||||
"without_skill": {
|
||||
"pass_rate": 0.667,
|
||||
"passed": 4,
|
||||
"total": 6,
|
||||
"duration_seconds": 325,
|
||||
"failed_assertions": [
|
||||
{"assertion": "Plan uses git worktree in a sibling directory", "reason": "No worktree. Steps go directly to creating branch and modifying files."},
|
||||
{"assertion": "Verification loop includes all 3 gates", "reason": "Only mentions CI pipeline (step 5). No review-work or Cubic."}
|
||||
]
|
||||
}
|
||||
},
|
||||
{
|
||||
"eval_name": "refactor-split-constants",
|
||||
"with_skill": {
|
||||
"pass_rate": 1.0,
|
||||
"passed": 5,
|
||||
"total": 5,
|
||||
"duration_seconds": 181,
|
||||
"failed_assertions": []
|
||||
},
|
||||
"without_skill": {
|
||||
"pass_rate": 0.4,
|
||||
"passed": 2,
|
||||
"total": 5,
|
||||
"duration_seconds": 229,
|
||||
"failed_assertions": [
|
||||
{"assertion": "Plan uses git worktree in a sibling directory", "reason": "git checkout -b only, no worktree"},
|
||||
{"assertion": "Uses 2+ commits for the multi-file refactor", "reason": "Single atomic commit: 'refactor: split delegate-task constants and category model requirements'"},
|
||||
{"assertion": "Verification loop includes all 3 gates", "reason": "Only mentions typecheck/test/build. No review-work or Cubic."}
|
||||
]
|
||||
}
|
||||
},
|
||||
{
|
||||
"eval_name": "new-mcp-arxiv-casual",
|
||||
"with_skill": {
|
||||
"pass_rate": 1.0,
|
||||
"passed": 5,
|
||||
"total": 5,
|
||||
"duration_seconds": 152,
|
||||
"failed_assertions": []
|
||||
},
|
||||
"without_skill": {
|
||||
"pass_rate": 0.6,
|
||||
"passed": 3,
|
||||
"total": 5,
|
||||
"duration_seconds": 197,
|
||||
"failed_assertions": [
|
||||
{"assertion": "Verification loop includes all 3 gates", "reason": "Only mentions bun test/typecheck/build. No review-work or Cubic."}
|
||||
]
|
||||
}
|
||||
},
|
||||
{
|
||||
"eval_name": "regex-fix-false-positive",
|
||||
"with_skill": {
|
||||
"pass_rate": 0.8,
|
||||
"passed": 4,
|
||||
"total": 5,
|
||||
"duration_seconds": 570,
|
||||
"failed_assertions": [
|
||||
{"assertion": "Only modifies regex and adds tests — no unrelated changes", "reason": "Also proposes config schema change (exclude_patterns) and Go binary update — goes beyond minimal fix"}
|
||||
]
|
||||
},
|
||||
"without_skill": {
|
||||
"pass_rate": 0.6,
|
||||
"passed": 3,
|
||||
"total": 5,
|
||||
"duration_seconds": 399,
|
||||
"failed_assertions": [
|
||||
{"assertion": "Plan uses git worktree in a sibling directory", "reason": "git checkout -b, no worktree"},
|
||||
{"assertion": "Verification loop includes all 3 gates", "reason": "Only bun test and typecheck. No review-work or Cubic."}
|
||||
]
|
||||
}
|
||||
}
|
||||
],
|
||||
"analyst_observations": [
|
||||
"Three-gates assertion (CI + review-work + Cubic) is the strongest discriminator: 5/5 with-skill vs 0/5 without-skill. Without the skill, agents never know about Cubic or review-work gates.",
|
||||
"Worktree isolation is nearly as discriminating (5/5 vs 1/5). One without-skill run (eval-4) independently chose worktree, suggesting some agents already know worktree patterns, but the skill makes it consistent.",
|
||||
"The skill's only failure (eval-5 minimal-change) reveals a potential over-engineering tendency: the skill-guided agent proposed config schema changes and Go binary updates for what should have been a minimal regex fix. Consider adding explicit guidance for fix-type tasks to stay minimal.",
|
||||
"Duration tradeoff: with-skill is 12% slower on average (340s vs 303s), driven mainly by eval-2 (bugfix) and eval-5 (regex fix) where the skill's thorough verification planning adds overhead. For eval-1 and eval-3-4, with-skill was actually faster.",
|
||||
"Without-skill duration has lower variance (stddev 78s vs 169s), suggesting the skill introduces more variable execution paths depending on task complexity.",
|
||||
"Non-discriminating assertions: 'References actual files', 'PR targets dev', 'Runs local checks' — these pass regardless of skill. They validate baseline agent competence, not skill value. Consider removing or downweighting in future iterations.",
|
||||
"Atomic commits assertion discriminates moderately (2/2 with-skill tested vs 0/2 without-skill tested). Without the skill, agents default to single commits even for multi-file refactors."
|
||||
]
|
||||
}
|
||||
@@ -1,42 +0,0 @@
|
||||
# Benchmark: work-with-pr (Iteration 1)
|
||||
|
||||
## Summary
|
||||
|
||||
| Metric | With Skill | Without Skill | Delta |
|
||||
|--------|-----------|---------------|-------|
|
||||
| Pass Rate | 96.8% (30/31) | 51.6% (16/31) | +45.2% |
|
||||
| Mean Duration | 340.2s | 303.0s | +37.2s |
|
||||
| Duration Stddev | 169.3s | 77.8s | +91.5s |
|
||||
|
||||
## Per-Eval Breakdown
|
||||
|
||||
| Eval | With Skill | Without Skill | Delta |
|
||||
|------|-----------|---------------|-------|
|
||||
| happy-path-feature-config-option | 100% (10/10) | 40% (4/10) | +60% |
|
||||
| bugfix-atlas-null-check | 100% (6/6) | 67% (4/6) | +33% |
|
||||
| refactor-split-constants | 100% (5/5) | 40% (2/5) | +60% |
|
||||
| new-mcp-arxiv-casual | 100% (5/5) | 60% (3/5) | +40% |
|
||||
| regex-fix-false-positive | 80% (4/5) | 60% (3/5) | +20% |
|
||||
|
||||
## Key Discriminators
|
||||
|
||||
- **three-gates** (CI + review-work + Cubic): 5/5 vs 0/5 — strongest signal
|
||||
- **worktree-isolation**: 5/5 vs 1/5
|
||||
- **atomic-commits**: 2/2 vs 0/2
|
||||
- **cubic-check-method**: 1/1 vs 0/1
|
||||
|
||||
## Non-Discriminating Assertions
|
||||
|
||||
- References actual files: passes in both conditions
|
||||
- PR targets dev: passes in both conditions
|
||||
- Runs local checks before pushing: passes in both conditions
|
||||
|
||||
## Only With-Skill Failure
|
||||
|
||||
- **eval-5 minimal-change**: Skill-guided agent proposed config schema changes and Go binary update for a minimal regex fix. The skill may encourage over-engineering in fix scenarios.
|
||||
|
||||
## Analyst Notes
|
||||
|
||||
- The skill adds most value for procedural knowledge (verification gates, worktree workflow) that agents cannot infer from codebase alone.
|
||||
- Duration cost is modest (+12%) and acceptable given the +45% pass rate improvement.
|
||||
- Consider adding explicit "fix-type tasks: stay minimal" guidance in iteration 2.
|
||||
@@ -1,57 +0,0 @@
|
||||
{
|
||||
"eval_id": 1,
|
||||
"eval_name": "happy-path-feature-config-option",
|
||||
"prompt": "I need to add a `max_background_agents` config option to oh-my-opencode that limits how many background agents can run simultaneously. It should be in the plugin config schema with a default of 5. Add validation and make sure the background manager respects it. Create a PR for this.",
|
||||
"assertions": [
|
||||
{
|
||||
"id": "worktree-isolation",
|
||||
"text": "Plan uses git worktree in a sibling directory (not main working directory)",
|
||||
"type": "manual"
|
||||
},
|
||||
{
|
||||
"id": "branch-from-dev",
|
||||
"text": "Branch is created from origin/dev (not master/main)",
|
||||
"type": "manual"
|
||||
},
|
||||
{
|
||||
"id": "atomic-commits",
|
||||
"text": "Plan specifies multiple atomic commits for multi-file changes",
|
||||
"type": "manual"
|
||||
},
|
||||
{
|
||||
"id": "local-validation",
|
||||
"text": "Runs bun run typecheck, bun test, and bun run build before pushing",
|
||||
"type": "manual"
|
||||
},
|
||||
{
|
||||
"id": "pr-targets-dev",
|
||||
"text": "PR is created targeting dev branch (not master)",
|
||||
"type": "manual"
|
||||
},
|
||||
{
|
||||
"id": "three-gates",
|
||||
"text": "Verification loop includes all 3 gates: CI, review-work, and Cubic",
|
||||
"type": "manual"
|
||||
},
|
||||
{
|
||||
"id": "gate-ordering",
|
||||
"text": "Gates are checked in order: CI first, then review-work, then Cubic",
|
||||
"type": "manual"
|
||||
},
|
||||
{
|
||||
"id": "cubic-check-method",
|
||||
"text": "Cubic check uses gh api to check cubic-dev-ai[bot] reviews for 'No issues found'",
|
||||
"type": "manual"
|
||||
},
|
||||
{
|
||||
"id": "worktree-cleanup",
|
||||
"text": "Plan includes worktree cleanup after merge",
|
||||
"type": "manual"
|
||||
},
|
||||
{
|
||||
"id": "real-file-references",
|
||||
"text": "Code changes reference actual files in the codebase (config schema, background manager)",
|
||||
"type": "manual"
|
||||
}
|
||||
]
|
||||
}
|
||||
@@ -1,15 +0,0 @@
|
||||
{
|
||||
"run_id": "eval-1-with_skill",
|
||||
"expectations": [
|
||||
{"text": "Plan uses git worktree in a sibling directory", "passed": true, "evidence": "Uses ../omo-wt/feat-max-background-agents"},
|
||||
{"text": "Branch is created from origin/dev", "passed": true, "evidence": "git checkout dev && git pull origin dev, then branch"},
|
||||
{"text": "Plan specifies multiple atomic commits for multi-file changes", "passed": true, "evidence": "2 commits: schema+tests, then concurrency+manager"},
|
||||
{"text": "Runs bun run typecheck, bun test, and bun run build before pushing", "passed": true, "evidence": "Explicit pre-push section with all 3 commands"},
|
||||
{"text": "PR is created targeting dev branch", "passed": true, "evidence": "--base dev in gh pr create"},
|
||||
{"text": "Verification loop includes all 3 gates: CI, review-work, and Cubic", "passed": true, "evidence": "Gate A (CI), Gate B (review-work 5 agents), Gate C (Cubic)"},
|
||||
{"text": "Gates are checked in order: CI first, then review-work, then Cubic", "passed": true, "evidence": "Explicit ordering in verify loop pseudocode"},
|
||||
{"text": "Cubic check uses gh api to check cubic-dev-ai[bot] reviews", "passed": true, "evidence": "Mentions cubic-dev-ai[bot] and 'No issues found' signal"},
|
||||
{"text": "Plan includes worktree cleanup after merge", "passed": true, "evidence": "Phase 4: git worktree remove ../omo-wt/feat-max-background-agents"},
|
||||
{"text": "Code changes reference actual files in the codebase", "passed": true, "evidence": "References src/config/schema/background-task.ts, src/features/background-agent/concurrency.ts, manager.ts"}
|
||||
]
|
||||
}
|
||||
@@ -1,454 +0,0 @@
|
||||
# Code Changes: `max_background_agents` Config Option
|
||||
|
||||
## 1. `src/config/schema/background-task.ts` — Add schema field
|
||||
|
||||
```typescript
|
||||
import { z } from "zod"
|
||||
|
||||
export const BackgroundTaskConfigSchema = z.object({
|
||||
defaultConcurrency: z.number().min(1).optional(),
|
||||
providerConcurrency: z.record(z.string(), z.number().min(0)).optional(),
|
||||
modelConcurrency: z.record(z.string(), z.number().min(0)).optional(),
|
||||
maxDepth: z.number().int().min(1).optional(),
|
||||
maxDescendants: z.number().int().min(1).optional(),
|
||||
/** Maximum number of background agents that can run simultaneously across all models/providers (default: 5, minimum: 1) */
|
||||
maxBackgroundAgents: z.number().int().min(1).optional(),
|
||||
/** Stale timeout in milliseconds - interrupt tasks with no activity for this duration (default: 180000 = 3 minutes, minimum: 60000 = 1 minute) */
|
||||
staleTimeoutMs: z.number().min(60000).optional(),
|
||||
/** Timeout for tasks that never received any progress update, falling back to startedAt (default: 1800000 = 30 minutes, minimum: 60000 = 1 minute) */
|
||||
messageStalenessTimeoutMs: z.number().min(60000).optional(),
|
||||
syncPollTimeoutMs: z.number().min(60000).optional(),
|
||||
})
|
||||
|
||||
export type BackgroundTaskConfig = z.infer<typeof BackgroundTaskConfigSchema>
|
||||
```
|
||||
|
||||
**Rationale:** Follows exact same pattern as `maxDepth` and `maxDescendants` — `z.number().int().min(1).optional()`. The field is optional; runtime default of 5 is applied in `ConcurrencyManager`. No barrel export changes needed since `src/config/schema.ts` already does `export * from "./schema/background-task"` and the type is inferred.
|
||||
|
||||
---
|
||||
|
||||
## 2. `src/config/schema/background-task.test.ts` — Add validation tests
|
||||
|
||||
Append after the existing `syncPollTimeoutMs` describe block (before the closing `})`):
|
||||
|
||||
```typescript
|
||||
describe("maxBackgroundAgents", () => {
|
||||
describe("#given valid maxBackgroundAgents (10)", () => {
|
||||
test("#when parsed #then returns correct value", () => {
|
||||
const result = BackgroundTaskConfigSchema.parse({ maxBackgroundAgents: 10 })
|
||||
|
||||
expect(result.maxBackgroundAgents).toBe(10)
|
||||
})
|
||||
})
|
||||
|
||||
describe("#given maxBackgroundAgents of 1 (minimum)", () => {
|
||||
test("#when parsed #then returns correct value", () => {
|
||||
const result = BackgroundTaskConfigSchema.parse({ maxBackgroundAgents: 1 })
|
||||
|
||||
expect(result.maxBackgroundAgents).toBe(1)
|
||||
})
|
||||
})
|
||||
|
||||
describe("#given maxBackgroundAgents below minimum (0)", () => {
|
||||
test("#when parsed #then throws ZodError", () => {
|
||||
let thrownError: unknown
|
||||
|
||||
try {
|
||||
BackgroundTaskConfigSchema.parse({ maxBackgroundAgents: 0 })
|
||||
} catch (error) {
|
||||
thrownError = error
|
||||
}
|
||||
|
||||
expect(thrownError).toBeInstanceOf(ZodError)
|
||||
})
|
||||
})
|
||||
|
||||
describe("#given maxBackgroundAgents not provided", () => {
|
||||
test("#when parsed #then field is undefined", () => {
|
||||
const result = BackgroundTaskConfigSchema.parse({})
|
||||
|
||||
expect(result.maxBackgroundAgents).toBeUndefined()
|
||||
})
|
||||
})
|
||||
|
||||
describe('#given maxBackgroundAgents is non-integer (2.5)', () => {
|
||||
test("#when parsed #then throws ZodError", () => {
|
||||
let thrownError: unknown
|
||||
|
||||
try {
|
||||
BackgroundTaskConfigSchema.parse({ maxBackgroundAgents: 2.5 })
|
||||
} catch (error) {
|
||||
thrownError = error
|
||||
}
|
||||
|
||||
expect(thrownError).toBeInstanceOf(ZodError)
|
||||
})
|
||||
})
|
||||
})
|
||||
```
|
||||
|
||||
**Rationale:** Follows exact test pattern from `maxDepth`, `maxDescendants`, and `syncPollTimeoutMs` tests. Uses `#given`/`#when`/`#then` nested describe style. Tests valid, minimum boundary, below minimum, not provided, and non-integer cases.
|
||||
|
||||
---
|
||||
|
||||
## 3. `src/features/background-agent/concurrency.ts` — Add global agent limit
|
||||
|
||||
```typescript
|
||||
import type { BackgroundTaskConfig } from "../../config/schema"
|
||||
|
||||
const DEFAULT_MAX_BACKGROUND_AGENTS = 5
|
||||
|
||||
/**
|
||||
* Queue entry with settled-flag pattern to prevent double-resolution.
|
||||
*
|
||||
* The settled flag ensures that cancelWaiters() doesn't reject
|
||||
* an entry that was already resolved by release().
|
||||
*/
|
||||
interface QueueEntry {
|
||||
resolve: () => void
|
||||
rawReject: (error: Error) => void
|
||||
settled: boolean
|
||||
}
|
||||
|
||||
export class ConcurrencyManager {
|
||||
private config?: BackgroundTaskConfig
|
||||
private counts: Map<string, number> = new Map()
|
||||
private queues: Map<string, QueueEntry[]> = new Map()
|
||||
private globalRunningCount = 0
|
||||
|
||||
constructor(config?: BackgroundTaskConfig) {
|
||||
this.config = config
|
||||
}
|
||||
|
||||
getMaxBackgroundAgents(): number {
|
||||
return this.config?.maxBackgroundAgents ?? DEFAULT_MAX_BACKGROUND_AGENTS
|
||||
}
|
||||
|
||||
getGlobalRunningCount(): number {
|
||||
return this.globalRunningCount
|
||||
}
|
||||
|
||||
canSpawnGlobally(): boolean {
|
||||
return this.globalRunningCount < this.getMaxBackgroundAgents()
|
||||
}
|
||||
|
||||
acquireGlobal(): void {
|
||||
this.globalRunningCount++
|
||||
}
|
||||
|
||||
releaseGlobal(): void {
|
||||
if (this.globalRunningCount > 0) {
|
||||
this.globalRunningCount--
|
||||
}
|
||||
}
|
||||
|
||||
getConcurrencyLimit(model: string): number {
|
||||
// ... existing implementation unchanged ...
|
||||
}
|
||||
|
||||
async acquire(model: string): Promise<void> {
|
||||
// ... existing implementation unchanged ...
|
||||
}
|
||||
|
||||
release(model: string): void {
|
||||
// ... existing implementation unchanged ...
|
||||
}
|
||||
|
||||
cancelWaiters(model: string): void {
|
||||
// ... existing implementation unchanged ...
|
||||
}
|
||||
|
||||
clear(): void {
|
||||
for (const [model] of this.queues) {
|
||||
this.cancelWaiters(model)
|
||||
}
|
||||
this.counts.clear()
|
||||
this.queues.clear()
|
||||
this.globalRunningCount = 0
|
||||
}
|
||||
|
||||
getCount(model: string): number {
|
||||
return this.counts.get(model) ?? 0
|
||||
}
|
||||
|
||||
getQueueLength(model: string): number {
|
||||
return this.queues.get(model)?.length ?? 0
|
||||
}
|
||||
}
|
||||
```
|
||||
|
||||
**Key changes:**
|
||||
- Add `DEFAULT_MAX_BACKGROUND_AGENTS = 5` constant
|
||||
- Add `globalRunningCount` private field
|
||||
- Add `getMaxBackgroundAgents()`, `getGlobalRunningCount()`, `canSpawnGlobally()`, `acquireGlobal()`, `releaseGlobal()` methods
|
||||
- `clear()` resets `globalRunningCount` to 0
|
||||
- All existing per-model methods remain unchanged
|
||||
|
||||
---
|
||||
|
||||
## 4. `src/features/background-agent/concurrency.test.ts` — Add global limit tests
|
||||
|
||||
Append new describe block:
|
||||
|
||||
```typescript
|
||||
describe("ConcurrencyManager global background agent limit", () => {
|
||||
test("should default max background agents to 5 when no config", () => {
|
||||
// given
|
||||
const manager = new ConcurrencyManager()
|
||||
|
||||
// when
|
||||
const max = manager.getMaxBackgroundAgents()
|
||||
|
||||
// then
|
||||
expect(max).toBe(5)
|
||||
})
|
||||
|
||||
test("should use configured maxBackgroundAgents", () => {
|
||||
// given
|
||||
const config: BackgroundTaskConfig = { maxBackgroundAgents: 10 }
|
||||
const manager = new ConcurrencyManager(config)
|
||||
|
||||
// when
|
||||
const max = manager.getMaxBackgroundAgents()
|
||||
|
||||
// then
|
||||
expect(max).toBe(10)
|
||||
})
|
||||
|
||||
test("should allow spawning when under global limit", () => {
|
||||
// given
|
||||
const config: BackgroundTaskConfig = { maxBackgroundAgents: 2 }
|
||||
const manager = new ConcurrencyManager(config)
|
||||
|
||||
// when
|
||||
manager.acquireGlobal()
|
||||
|
||||
// then
|
||||
expect(manager.canSpawnGlobally()).toBe(true)
|
||||
expect(manager.getGlobalRunningCount()).toBe(1)
|
||||
})
|
||||
|
||||
test("should block spawning when at global limit", () => {
|
||||
// given
|
||||
const config: BackgroundTaskConfig = { maxBackgroundAgents: 2 }
|
||||
const manager = new ConcurrencyManager(config)
|
||||
|
||||
// when
|
||||
manager.acquireGlobal()
|
||||
manager.acquireGlobal()
|
||||
|
||||
// then
|
||||
expect(manager.canSpawnGlobally()).toBe(false)
|
||||
expect(manager.getGlobalRunningCount()).toBe(2)
|
||||
})
|
||||
|
||||
test("should allow spawning again after release", () => {
|
||||
// given
|
||||
const config: BackgroundTaskConfig = { maxBackgroundAgents: 1 }
|
||||
const manager = new ConcurrencyManager(config)
|
||||
manager.acquireGlobal()
|
||||
|
||||
// when
|
||||
manager.releaseGlobal()
|
||||
|
||||
// then
|
||||
expect(manager.canSpawnGlobally()).toBe(true)
|
||||
expect(manager.getGlobalRunningCount()).toBe(0)
|
||||
})
|
||||
|
||||
test("should not go below zero on extra release", () => {
|
||||
// given
|
||||
const manager = new ConcurrencyManager()
|
||||
|
||||
// when
|
||||
manager.releaseGlobal()
|
||||
|
||||
// then
|
||||
expect(manager.getGlobalRunningCount()).toBe(0)
|
||||
})
|
||||
|
||||
test("should reset global count on clear", () => {
|
||||
// given
|
||||
const config: BackgroundTaskConfig = { maxBackgroundAgents: 5 }
|
||||
const manager = new ConcurrencyManager(config)
|
||||
manager.acquireGlobal()
|
||||
manager.acquireGlobal()
|
||||
manager.acquireGlobal()
|
||||
|
||||
// when
|
||||
manager.clear()
|
||||
|
||||
// then
|
||||
expect(manager.getGlobalRunningCount()).toBe(0)
|
||||
})
|
||||
})
|
||||
```
|
||||
|
||||
---
|
||||
|
||||
## 5. `src/features/background-agent/manager.ts` — Enforce global limit
|
||||
|
||||
### In `launch()` method — add check before task creation (after `reserveSubagentSpawn`):
|
||||
|
||||
```typescript
|
||||
async launch(input: LaunchInput): Promise<BackgroundTask> {
|
||||
// ... existing logging ...
|
||||
|
||||
if (!input.agent || input.agent.trim() === "") {
|
||||
throw new Error("Agent parameter is required")
|
||||
}
|
||||
|
||||
// Check global background agent limit before spawn guard
|
||||
if (!this.concurrencyManager.canSpawnGlobally()) {
|
||||
const max = this.concurrencyManager.getMaxBackgroundAgents()
|
||||
const current = this.concurrencyManager.getGlobalRunningCount()
|
||||
throw new Error(
|
||||
`Background agent spawn blocked: ${current} agents running, max is ${max}. Wait for existing tasks to complete or increase background_task.maxBackgroundAgents.`
|
||||
)
|
||||
}
|
||||
|
||||
const spawnReservation = await this.reserveSubagentSpawn(input.parentSessionID)
|
||||
|
||||
try {
|
||||
// ... existing code ...
|
||||
|
||||
// After task creation, before queueing:
|
||||
this.concurrencyManager.acquireGlobal()
|
||||
|
||||
// ... rest of existing code ...
|
||||
} catch (error) {
|
||||
spawnReservation.rollback()
|
||||
throw error
|
||||
}
|
||||
}
|
||||
```
|
||||
|
||||
### In `trackTask()` method — add global check:
|
||||
|
||||
```typescript
|
||||
async trackTask(input: { ... }): Promise<BackgroundTask> {
|
||||
const existingTask = this.tasks.get(input.taskId)
|
||||
if (existingTask) {
|
||||
// ... existing re-registration logic unchanged ...
|
||||
return existingTask
|
||||
}
|
||||
|
||||
// Check global limit for new external tasks
|
||||
if (!this.concurrencyManager.canSpawnGlobally()) {
|
||||
const max = this.concurrencyManager.getMaxBackgroundAgents()
|
||||
const current = this.concurrencyManager.getGlobalRunningCount()
|
||||
throw new Error(
|
||||
`Background agent spawn blocked: ${current} agents running, max is ${max}. Wait for existing tasks to complete or increase background_task.maxBackgroundAgents.`
|
||||
)
|
||||
}
|
||||
|
||||
// ... existing task creation ...
|
||||
this.concurrencyManager.acquireGlobal()
|
||||
|
||||
// ... rest unchanged ...
|
||||
}
|
||||
```
|
||||
|
||||
### In `tryCompleteTask()` — release global slot:
|
||||
|
||||
```typescript
|
||||
private async tryCompleteTask(task: BackgroundTask, source: string): Promise<boolean> {
|
||||
if (task.status !== "running") {
|
||||
// ... existing guard ...
|
||||
return false
|
||||
}
|
||||
|
||||
task.status = "completed"
|
||||
task.completedAt = new Date()
|
||||
// ... existing history record ...
|
||||
|
||||
removeTaskToastTracking(task.id)
|
||||
|
||||
// Release per-model concurrency
|
||||
if (task.concurrencyKey) {
|
||||
this.concurrencyManager.release(task.concurrencyKey)
|
||||
task.concurrencyKey = undefined
|
||||
}
|
||||
|
||||
// Release global slot
|
||||
this.concurrencyManager.releaseGlobal()
|
||||
|
||||
// ... rest unchanged ...
|
||||
}
|
||||
```
|
||||
|
||||
### In `cancelTask()` — release global slot:
|
||||
|
||||
```typescript
|
||||
async cancelTask(taskId: string, options?: { ... }): Promise<boolean> {
|
||||
// ... existing code up to concurrency release ...
|
||||
|
||||
if (task.concurrencyKey) {
|
||||
this.concurrencyManager.release(task.concurrencyKey)
|
||||
task.concurrencyKey = undefined
|
||||
}
|
||||
|
||||
// Release global slot (only for running tasks, pending never acquired)
|
||||
if (task.status !== "pending") {
|
||||
this.concurrencyManager.releaseGlobal()
|
||||
}
|
||||
|
||||
// ... rest unchanged ...
|
||||
}
|
||||
```
|
||||
|
||||
### In `handleEvent()` session.error handler — release global slot:
|
||||
|
||||
```typescript
|
||||
if (event.type === "session.error") {
|
||||
// ... existing error handling ...
|
||||
|
||||
task.status = "error"
|
||||
// ...
|
||||
|
||||
if (task.concurrencyKey) {
|
||||
this.concurrencyManager.release(task.concurrencyKey)
|
||||
task.concurrencyKey = undefined
|
||||
}
|
||||
|
||||
// Release global slot
|
||||
this.concurrencyManager.releaseGlobal()
|
||||
|
||||
// ... rest unchanged ...
|
||||
}
|
||||
```
|
||||
|
||||
### In prompt error handler inside `startTask()` — release global slot:
|
||||
|
||||
```typescript
|
||||
promptWithModelSuggestionRetry(this.client, { ... }).catch((error) => {
|
||||
// ... existing error handling ...
|
||||
if (existingTask) {
|
||||
existingTask.status = "interrupt"
|
||||
// ...
|
||||
if (existingTask.concurrencyKey) {
|
||||
this.concurrencyManager.release(existingTask.concurrencyKey)
|
||||
existingTask.concurrencyKey = undefined
|
||||
}
|
||||
|
||||
// Release global slot
|
||||
this.concurrencyManager.releaseGlobal()
|
||||
|
||||
// ... rest unchanged ...
|
||||
}
|
||||
})
|
||||
```
|
||||
|
||||
---
|
||||
|
||||
## Summary of Changes
|
||||
|
||||
| File | Lines Added | Lines Modified |
|
||||
|------|-------------|----------------|
|
||||
| `src/config/schema/background-task.ts` | 2 | 0 |
|
||||
| `src/config/schema/background-task.test.ts` | ~50 | 0 |
|
||||
| `src/features/background-agent/concurrency.ts` | ~25 | 1 (`clear()`) |
|
||||
| `src/features/background-agent/concurrency.test.ts` | ~70 | 0 |
|
||||
| `src/features/background-agent/manager.ts` | ~20 | 0 |
|
||||
|
||||
Total: ~167 lines added, 1 line modified across 5 files.
|
||||
@@ -1,136 +0,0 @@
|
||||
# Execution Plan: `max_background_agents` Config Option
|
||||
|
||||
## Phase 0: Setup — Branch + Worktree
|
||||
|
||||
1. **Create branch** from `dev`:
|
||||
```bash
|
||||
git checkout dev && git pull origin dev
|
||||
git checkout -b feat/max-background-agents
|
||||
```
|
||||
|
||||
2. **Create worktree** in sibling directory:
|
||||
```bash
|
||||
mkdir -p ../omo-wt
|
||||
git worktree add ../omo-wt/feat-max-background-agents feat/max-background-agents
|
||||
```
|
||||
|
||||
3. **All subsequent work** happens in `../omo-wt/feat-max-background-agents/`, never in the main worktree.
|
||||
|
||||
---
|
||||
|
||||
## Phase 1: Implement — Atomic Commits
|
||||
|
||||
### Commit 1: Add `max_background_agents` to config schema
|
||||
|
||||
**Files changed:**
|
||||
- `src/config/schema/background-task.ts` — Add `maxBackgroundAgents` field to `BackgroundTaskConfigSchema`
|
||||
- `src/config/schema/background-task.test.ts` — Add validation tests for the new field
|
||||
|
||||
**What:**
|
||||
- Add `maxBackgroundAgents: z.number().int().min(1).optional()` to `BackgroundTaskConfigSchema`
|
||||
- Default value handled at runtime (5), not in schema (all schema fields are optional per convention)
|
||||
- Add given/when/then tests: valid value, below minimum, not provided, non-number
|
||||
|
||||
### Commit 2: Enforce limit in BackgroundManager + ConcurrencyManager
|
||||
|
||||
**Files changed:**
|
||||
- `src/features/background-agent/concurrency.ts` — Add global agent count tracking + `getGlobalRunningCount()` + `canSpawnGlobally()`
|
||||
- `src/features/background-agent/concurrency.test.ts` — Tests for global limit enforcement
|
||||
- `src/features/background-agent/manager.ts` — Check global limit before `launch()` and `trackTask()`
|
||||
|
||||
**What:**
|
||||
- `ConcurrencyManager` already manages per-model concurrency. Add a separate global counter:
|
||||
- `private globalRunningCount: number = 0`
|
||||
- `private maxBackgroundAgents: number` (from config, default 5)
|
||||
- `acquireGlobal()` / `releaseGlobal()` methods
|
||||
- `getGlobalRunningCount()` for observability
|
||||
- `BackgroundManager.launch()` checks `concurrencyManager.canSpawnGlobally()` before creating task
|
||||
- `BackgroundManager.trackTask()` also checks global limit
|
||||
- On task completion/cancellation/error, call `releaseGlobal()`
|
||||
- Throw descriptive error when limit hit: `"Background agent spawn blocked: ${current} agents running, max is ${max}. Wait for existing tasks to complete or increase background_task.maxBackgroundAgents."`
|
||||
|
||||
### Local Validation
|
||||
|
||||
```bash
|
||||
bun run typecheck
|
||||
bun test src/config/schema/background-task.test.ts
|
||||
bun test src/features/background-agent/concurrency.test.ts
|
||||
bun run build
|
||||
```
|
||||
|
||||
---
|
||||
|
||||
## Phase 2: PR Creation
|
||||
|
||||
1. **Push branch:**
|
||||
```bash
|
||||
git push -u origin feat/max-background-agents
|
||||
```
|
||||
|
||||
2. **Create PR** targeting `dev`:
|
||||
```bash
|
||||
gh pr create \
|
||||
--base dev \
|
||||
--title "feat: add max_background_agents config to limit concurrent background agents" \
|
||||
--body-file /tmp/pull-request-max-background-agents-$(date +%s).md
|
||||
```
|
||||
|
||||
---
|
||||
|
||||
## Phase 3: Verify Loop
|
||||
|
||||
### Gate A: CI
|
||||
- Wait for `ci.yml` workflow to complete
|
||||
- Check: `gh pr checks <PR_NUMBER> --watch`
|
||||
- If fails: read logs, fix, push, re-check
|
||||
|
||||
### Gate B: review-work (5 agents)
|
||||
- Run `/review-work` skill which launches 5 parallel background sub-agents:
|
||||
1. Oracle — goal/constraint verification
|
||||
2. Oracle — code quality
|
||||
3. Oracle — security
|
||||
4. Hephaestus — hands-on QA execution
|
||||
5. Hephaestus — context mining from GitHub/git
|
||||
- All 5 must pass. If any fails, fix and re-push.
|
||||
|
||||
### Gate C: Cubic (cubic-dev-ai[bot])
|
||||
- Wait for Cubic bot review on PR
|
||||
- Must say "No issues found"
|
||||
- If issues found: address feedback, push, re-check
|
||||
|
||||
### Loop
|
||||
```
|
||||
while (!allGatesPass) {
|
||||
if (CI fails) → fix → push → continue
|
||||
if (review-work fails) → fix → push → continue
|
||||
if (Cubic has issues) → fix → push → continue
|
||||
}
|
||||
```
|
||||
|
||||
---
|
||||
|
||||
## Phase 4: Merge + Cleanup
|
||||
|
||||
1. **Squash merge:**
|
||||
```bash
|
||||
gh pr merge <PR_NUMBER> --squash --delete-branch
|
||||
```
|
||||
|
||||
2. **Remove worktree:**
|
||||
```bash
|
||||
git worktree remove ../omo-wt/feat-max-background-agents
|
||||
```
|
||||
|
||||
---
|
||||
|
||||
## File Impact Summary
|
||||
|
||||
| File | Change Type |
|
||||
|------|-------------|
|
||||
| `src/config/schema/background-task.ts` | Modified — add schema field |
|
||||
| `src/config/schema/background-task.test.ts` | Modified — add validation tests |
|
||||
| `src/features/background-agent/concurrency.ts` | Modified — add global limit tracking |
|
||||
| `src/features/background-agent/concurrency.test.ts` | Modified — add global limit tests |
|
||||
| `src/features/background-agent/manager.ts` | Modified — enforce global limit in launch/trackTask |
|
||||
|
||||
5 files changed across 2 atomic commits. No new files created (follows existing patterns).
|
||||
@@ -1,47 +0,0 @@
|
||||
# PR Description
|
||||
|
||||
**Title:** `feat: add max_background_agents config to limit concurrent background agents`
|
||||
|
||||
**Base:** `dev`
|
||||
|
||||
---
|
||||
|
||||
## Summary
|
||||
|
||||
- Add `maxBackgroundAgents` field to `BackgroundTaskConfigSchema` (default: 5, min: 1) to cap total simultaneous background agents across all models/providers
|
||||
- Enforce the global limit in `BackgroundManager.launch()` and `trackTask()` with descriptive error messages when the limit is hit
|
||||
- Release global slots on task completion, cancellation, error, and interrupt to prevent slot leaks
|
||||
|
||||
## Motivation
|
||||
|
||||
The existing concurrency system in `ConcurrencyManager` limits agents **per model/provider** (e.g., 5 concurrent `anthropic/claude-opus-4-6` tasks). However, there is no **global** cap across all models. A user running tasks across multiple providers could spawn an unbounded number of background agents, exhausting system resources.
|
||||
|
||||
`max_background_agents` provides a single knob to limit total concurrent background agents regardless of which model they use.
|
||||
|
||||
## Config Usage
|
||||
|
||||
```jsonc
|
||||
// .opencode/oh-my-opencode.jsonc
|
||||
{
|
||||
"background_task": {
|
||||
"maxBackgroundAgents": 10 // default: 5, min: 1
|
||||
}
|
||||
}
|
||||
```
|
||||
|
||||
## Changes
|
||||
|
||||
| File | What |
|
||||
|------|------|
|
||||
| `src/config/schema/background-task.ts` | Add `maxBackgroundAgents` schema field |
|
||||
| `src/config/schema/background-task.test.ts` | Validation tests (valid, boundary, invalid) |
|
||||
| `src/features/background-agent/concurrency.ts` | Global counter + `canSpawnGlobally()` / `acquireGlobal()` / `releaseGlobal()` |
|
||||
| `src/features/background-agent/concurrency.test.ts` | Global limit unit tests |
|
||||
| `src/features/background-agent/manager.ts` | Enforce global limit in `launch()`, `trackTask()`; release in completion/cancel/error paths |
|
||||
|
||||
## Testing
|
||||
|
||||
- `bun test src/config/schema/background-task.test.ts` — schema validation
|
||||
- `bun test src/features/background-agent/concurrency.test.ts` — global limit enforcement
|
||||
- `bun run typecheck` — clean
|
||||
- `bun run build` — clean
|
||||
@@ -1,163 +0,0 @@
|
||||
# Verification Strategy
|
||||
|
||||
## Pre-Push Local Validation
|
||||
|
||||
Before every push, run all three checks sequentially:
|
||||
|
||||
```bash
|
||||
bun run typecheck && bun test && bun run build
|
||||
```
|
||||
|
||||
Specific test files to watch:
|
||||
```bash
|
||||
bun test src/config/schema/background-task.test.ts
|
||||
bun test src/features/background-agent/concurrency.test.ts
|
||||
```
|
||||
|
||||
---
|
||||
|
||||
## Gate A: CI (`ci.yml`)
|
||||
|
||||
### What CI runs
|
||||
1. **Tests (split):** mock-heavy tests run in isolation (separate `bun test` processes), rest in batch
|
||||
2. **Typecheck:** `bun run typecheck` (tsc --noEmit)
|
||||
3. **Build:** `bun run build` (ESM + declarations + schema)
|
||||
4. **Schema auto-commit:** if generated schema changed, CI commits it
|
||||
|
||||
### How to monitor
|
||||
```bash
|
||||
gh pr checks <PR_NUMBER> --watch
|
||||
```
|
||||
|
||||
### Common failure scenarios and fixes
|
||||
|
||||
| Failure | Likely Cause | Fix |
|
||||
|---------|-------------|-----|
|
||||
| Typecheck error | New field not matching existing type imports | Verify `BackgroundTaskConfig` type is auto-inferred from schema, no manual type updates needed |
|
||||
| Test failure | Test assertion wrong or missing import | Fix test, re-push |
|
||||
| Build failure | Import cycle or missing export | Check barrel exports in `src/config/schema.ts` (already re-exports via `export *`) |
|
||||
| Schema auto-commit | Generated JSON schema changed | Pull the auto-commit, rebase if needed |
|
||||
|
||||
### Recovery
|
||||
```bash
|
||||
# Read CI logs
|
||||
gh run view <RUN_ID> --log-failed
|
||||
|
||||
# Fix, commit, push
|
||||
git add -A && git commit -m "fix: address CI failure" && git push
|
||||
```
|
||||
|
||||
---
|
||||
|
||||
## Gate B: review-work (5 parallel agents)
|
||||
|
||||
### What it checks
|
||||
Run `/review-work` which launches 5 background sub-agents:
|
||||
|
||||
| Agent | Role | What it checks for this PR |
|
||||
|-------|------|---------------------------|
|
||||
| Oracle (goal) | Goal/constraint verification | Does `maxBackgroundAgents` actually limit agents? Is default 5? Is min 1? |
|
||||
| Oracle (quality) | Code quality | Follows existing patterns? No catch-all files? Under 200 LOC? given/when/then tests? |
|
||||
| Oracle (security) | Security review | No injection vectors, no unsafe defaults, proper input validation via Zod |
|
||||
| Hephaestus (QA) | Hands-on QA execution | Actually runs tests, checks typecheck, verifies build |
|
||||
| Hephaestus (context) | Context mining | Checks git history, related issues, ensures no duplicate/conflicting PRs |
|
||||
|
||||
### Pass criteria
|
||||
All 5 agents must pass. Any single failure blocks.
|
||||
|
||||
### Common failure scenarios and fixes
|
||||
|
||||
| Agent | Likely Issue | Fix |
|
||||
|-------|-------------|-----|
|
||||
| Oracle (goal) | Global limit not enforced in all exit paths (completion, cancel, error, interrupt) | Audit every status transition in `manager.ts` that should call `releaseGlobal()` |
|
||||
| Oracle (quality) | Test style not matching given/when/then | Restructure tests with `#given`/`#when`/`#then` describe nesting |
|
||||
| Oracle (quality) | File exceeds 200 LOC | `concurrency.ts` is 137 LOC + ~25 new = ~162 LOC, safe. `manager.ts` is already large but we're adding ~20 lines to existing methods, not creating new responsibility |
|
||||
| Oracle (security) | Integer overflow or negative values | Zod `.int().min(1)` handles this at config parse time |
|
||||
| Hephaestus (QA) | Test actually fails when run | Run tests locally first, fix before push |
|
||||
|
||||
### Recovery
|
||||
```bash
|
||||
# Review agent output
|
||||
background_output(task_id="<review-work-task-id>")
|
||||
|
||||
# Fix identified issues
|
||||
# ... edit files ...
|
||||
git add -A && git commit -m "fix: address review-work feedback" && git push
|
||||
```
|
||||
|
||||
---
|
||||
|
||||
## Gate C: Cubic (`cubic-dev-ai[bot]`)
|
||||
|
||||
### What it checks
|
||||
Cubic is an automated code review bot that analyzes the PR diff. It must respond with "No issues found" for the gate to pass.
|
||||
|
||||
### Common failure scenarios and fixes
|
||||
|
||||
| Issue | Likely Cause | Fix |
|
||||
|-------|-------------|-----|
|
||||
| "Missing error handling" | `releaseGlobal()` not called in some error path | Add `releaseGlobal()` to the missed path |
|
||||
| "Inconsistent naming" | Field name doesn't match convention | Use `maxBackgroundAgents` (camelCase in schema, `max_background_agents` in JSONC config) |
|
||||
| "Missing documentation" | No JSDoc on new public methods | Add JSDoc comments to `canSpawnGlobally()`, `acquireGlobal()`, `releaseGlobal()`, `getMaxBackgroundAgents()` |
|
||||
| "Test coverage gap" | Missing edge case test | Add the specific test case Cubic identifies |
|
||||
|
||||
### Recovery
|
||||
```bash
|
||||
# Read Cubic's review
|
||||
gh api repos/code-yeongyu/oh-my-openagent/pulls/<PR_NUMBER>/reviews
|
||||
|
||||
# Address each comment
|
||||
# ... edit files ...
|
||||
git add -A && git commit -m "fix: address Cubic review feedback" && git push
|
||||
```
|
||||
|
||||
---
|
||||
|
||||
## Verification Loop Pseudocode
|
||||
|
||||
```
|
||||
iteration = 0
|
||||
while true:
|
||||
iteration++
|
||||
log("Verification iteration ${iteration}")
|
||||
|
||||
# Gate A: CI (cheapest, check first)
|
||||
push_and_wait_for_ci()
|
||||
if ci_failed:
|
||||
read_ci_logs()
|
||||
fix_and_commit()
|
||||
continue
|
||||
|
||||
# Gate B: review-work (5 agents, more expensive)
|
||||
run_review_work()
|
||||
if any_agent_failed:
|
||||
read_agent_feedback()
|
||||
fix_and_commit()
|
||||
continue
|
||||
|
||||
# Gate C: Cubic (external bot, wait for it)
|
||||
wait_for_cubic_review()
|
||||
if cubic_has_issues:
|
||||
read_cubic_comments()
|
||||
fix_and_commit()
|
||||
continue
|
||||
|
||||
# All gates passed
|
||||
break
|
||||
|
||||
# Merge
|
||||
gh pr merge <PR_NUMBER> --squash --delete-branch
|
||||
```
|
||||
|
||||
No iteration cap. Loop continues until all three gates pass simultaneously in a single iteration.
|
||||
|
||||
---
|
||||
|
||||
## Risk Assessment
|
||||
|
||||
| Risk | Probability | Mitigation |
|
||||
|------|------------|------------|
|
||||
| Slot leak (global count never decremented) | Medium | Audit every exit path: `tryCompleteTask`, `cancelTask`, `handleEvent(session.error)`, `startTask` prompt error, `resume` prompt error |
|
||||
| Race condition on global count | Low | `globalRunningCount` is synchronous (single-threaded JS), no async gap between check and increment in `launch()` |
|
||||
| Breaking existing behavior | Low | Default is 5, same as existing per-model default. Users with <5 total agents see no change |
|
||||
| `manager.ts` exceeding 200 LOC | Already exceeded | File is already ~1500 LOC (exempt due to being a core orchestration class with many methods). Our changes add ~20 lines to existing methods, not a new responsibility |
|
||||
@@ -1 +0,0 @@
|
||||
{"total_tokens": null, "duration_ms": 292000, "total_duration_seconds": 292}
|
||||
@@ -1,15 +0,0 @@
|
||||
{
|
||||
"run_id": "eval-1-without_skill",
|
||||
"expectations": [
|
||||
{"text": "Plan uses git worktree in a sibling directory", "passed": false, "evidence": "Uses git checkout -b, no worktree isolation"},
|
||||
{"text": "Branch is created from origin/dev", "passed": true, "evidence": "git checkout -b feat/max-background-agents dev"},
|
||||
{"text": "Plan specifies multiple atomic commits for multi-file changes", "passed": false, "evidence": "Steps listed sequentially but no atomic commit strategy mentioned"},
|
||||
{"text": "Runs bun run typecheck, bun test, and bun run build before pushing", "passed": true, "evidence": "Step 6 runs typecheck and tests, Step 8 implies push after verification"},
|
||||
{"text": "PR is created targeting dev branch", "passed": true, "evidence": "Step 8 mentions creating PR"},
|
||||
{"text": "Verification loop includes all 3 gates: CI, review-work, and Cubic", "passed": false, "evidence": "Only mentions CI pipeline in step 6. No review-work or Cubic."},
|
||||
{"text": "Gates are checked in order: CI first, then review-work, then Cubic", "passed": false, "evidence": "No gate ordering - only CI mentioned"},
|
||||
{"text": "Cubic check uses gh api to check cubic-dev-ai[bot] reviews", "passed": false, "evidence": "No mention of Cubic at all"},
|
||||
{"text": "Plan includes worktree cleanup after merge", "passed": false, "evidence": "No worktree used, no cleanup needed"},
|
||||
{"text": "Code changes reference actual files in the codebase", "passed": true, "evidence": "References actual files with detailed design decisions"}
|
||||
]
|
||||
}
|
||||
@@ -1,615 +0,0 @@
|
||||
# Code Changes: `max_background_agents` Config Option
|
||||
|
||||
## 1. Schema Change
|
||||
|
||||
**File:** `src/config/schema/background-task.ts`
|
||||
|
||||
```typescript
|
||||
import { z } from "zod"
|
||||
|
||||
export const BackgroundTaskConfigSchema = z.object({
|
||||
defaultConcurrency: z.number().min(1).optional(),
|
||||
providerConcurrency: z.record(z.string(), z.number().min(0)).optional(),
|
||||
modelConcurrency: z.record(z.string(), z.number().min(0)).optional(),
|
||||
maxDepth: z.number().int().min(1).optional(),
|
||||
maxDescendants: z.number().int().min(1).optional(),
|
||||
/** Maximum number of background agents that can run simultaneously across all models/providers (default: no global limit, only per-model limits apply) */
|
||||
maxBackgroundAgents: z.number().int().min(1).optional(),
|
||||
/** Stale timeout in milliseconds - interrupt tasks with no activity for this duration (default: 180000 = 3 minutes, minimum: 60000 = 1 minute) */
|
||||
staleTimeoutMs: z.number().min(60000).optional(),
|
||||
/** Timeout for tasks that never received any progress update, falling back to startedAt (default: 1800000 = 30 minutes, minimum: 60000 = 1 minute) */
|
||||
messageStalenessTimeoutMs: z.number().min(60000).optional(),
|
||||
syncPollTimeoutMs: z.number().min(60000).optional(),
|
||||
})
|
||||
|
||||
export type BackgroundTaskConfig = z.infer<typeof BackgroundTaskConfigSchema>
|
||||
```
|
||||
|
||||
**What changed:** Added `maxBackgroundAgents` field after `maxDescendants` (grouped with other limit fields). Uses `z.number().int().min(1).optional()` matching the pattern of `maxDepth` and `maxDescendants`.
|
||||
|
||||
---
|
||||
|
||||
## 2. ConcurrencyManager Changes
|
||||
|
||||
**File:** `src/features/background-agent/concurrency.ts`
|
||||
|
||||
```typescript
|
||||
import type { BackgroundTaskConfig } from "../../config/schema"
|
||||
|
||||
/**
|
||||
* Queue entry with settled-flag pattern to prevent double-resolution.
|
||||
*
|
||||
* The settled flag ensures that cancelWaiters() doesn't reject
|
||||
* an entry that was already resolved by release().
|
||||
*/
|
||||
interface QueueEntry {
|
||||
resolve: () => void
|
||||
rawReject: (error: Error) => void
|
||||
settled: boolean
|
||||
}
|
||||
|
||||
export class ConcurrencyManager {
|
||||
private config?: BackgroundTaskConfig
|
||||
private counts: Map<string, number> = new Map()
|
||||
private queues: Map<string, QueueEntry[]> = new Map()
|
||||
private globalCount = 0
|
||||
private globalQueue: QueueEntry[] = []
|
||||
|
||||
constructor(config?: BackgroundTaskConfig) {
|
||||
this.config = config
|
||||
}
|
||||
|
||||
getGlobalLimit(): number {
|
||||
const limit = this.config?.maxBackgroundAgents
|
||||
if (limit === undefined) {
|
||||
return Infinity
|
||||
}
|
||||
return limit
|
||||
}
|
||||
|
||||
getConcurrencyLimit(model: string): number {
|
||||
const modelLimit = this.config?.modelConcurrency?.[model]
|
||||
if (modelLimit !== undefined) {
|
||||
return modelLimit === 0 ? Infinity : modelLimit
|
||||
}
|
||||
const provider = model.split('/')[0]
|
||||
const providerLimit = this.config?.providerConcurrency?.[provider]
|
||||
if (providerLimit !== undefined) {
|
||||
return providerLimit === 0 ? Infinity : providerLimit
|
||||
}
|
||||
const defaultLimit = this.config?.defaultConcurrency
|
||||
if (defaultLimit !== undefined) {
|
||||
return defaultLimit === 0 ? Infinity : defaultLimit
|
||||
}
|
||||
return 5
|
||||
}
|
||||
|
||||
async acquire(model: string): Promise<void> {
|
||||
const perModelLimit = this.getConcurrencyLimit(model)
|
||||
const globalLimit = this.getGlobalLimit()
|
||||
|
||||
// Fast path: both limits have capacity
|
||||
if (perModelLimit === Infinity && globalLimit === Infinity) {
|
||||
return
|
||||
}
|
||||
|
||||
const currentPerModel = this.counts.get(model) ?? 0
|
||||
|
||||
if (currentPerModel < perModelLimit && this.globalCount < globalLimit) {
|
||||
this.counts.set(model, currentPerModel + 1)
|
||||
this.globalCount++
|
||||
return
|
||||
}
|
||||
|
||||
return new Promise<void>((resolve, reject) => {
|
||||
const entry: QueueEntry = {
|
||||
resolve: () => {
|
||||
if (entry.settled) return
|
||||
entry.settled = true
|
||||
resolve()
|
||||
},
|
||||
rawReject: reject,
|
||||
settled: false,
|
||||
}
|
||||
|
||||
// Queue on whichever limit is blocking
|
||||
if (currentPerModel >= perModelLimit) {
|
||||
const queue = this.queues.get(model) ?? []
|
||||
queue.push(entry)
|
||||
this.queues.set(model, queue)
|
||||
} else {
|
||||
this.globalQueue.push(entry)
|
||||
}
|
||||
})
|
||||
}
|
||||
|
||||
release(model: string): void {
|
||||
const perModelLimit = this.getConcurrencyLimit(model)
|
||||
const globalLimit = this.getGlobalLimit()
|
||||
|
||||
if (perModelLimit === Infinity && globalLimit === Infinity) {
|
||||
return
|
||||
}
|
||||
|
||||
// Try per-model handoff first
|
||||
const queue = this.queues.get(model)
|
||||
while (queue && queue.length > 0) {
|
||||
const next = queue.shift()!
|
||||
if (!next.settled) {
|
||||
// Hand off the slot to this waiter (counts stay the same)
|
||||
next.resolve()
|
||||
return
|
||||
}
|
||||
}
|
||||
|
||||
// No per-model handoff - decrement per-model count
|
||||
const current = this.counts.get(model) ?? 0
|
||||
if (current > 0) {
|
||||
this.counts.set(model, current - 1)
|
||||
}
|
||||
|
||||
// Try global handoff
|
||||
while (this.globalQueue.length > 0) {
|
||||
const next = this.globalQueue.shift()!
|
||||
if (!next.settled) {
|
||||
// Hand off the global slot - but the waiter still needs a per-model slot
|
||||
// Since they were queued on global, their per-model had capacity
|
||||
// Re-acquire per-model count for them
|
||||
const waiterModel = this.findModelForGlobalWaiter()
|
||||
if (waiterModel) {
|
||||
const waiterCount = this.counts.get(waiterModel) ?? 0
|
||||
this.counts.set(waiterModel, waiterCount + 1)
|
||||
}
|
||||
next.resolve()
|
||||
return
|
||||
}
|
||||
}
|
||||
|
||||
// No handoff occurred - decrement global count
|
||||
if (this.globalCount > 0) {
|
||||
this.globalCount--
|
||||
}
|
||||
}
|
||||
|
||||
/**
|
||||
* Cancel all waiting acquires for a model. Used during cleanup.
|
||||
*/
|
||||
cancelWaiters(model: string): void {
|
||||
const queue = this.queues.get(model)
|
||||
if (queue) {
|
||||
for (const entry of queue) {
|
||||
if (!entry.settled) {
|
||||
entry.settled = true
|
||||
entry.rawReject(new Error(`Concurrency queue cancelled for model: ${model}`))
|
||||
}
|
||||
}
|
||||
this.queues.delete(model)
|
||||
}
|
||||
}
|
||||
|
||||
/**
|
||||
* Clear all state. Used during manager cleanup/shutdown.
|
||||
* Cancels all pending waiters.
|
||||
*/
|
||||
clear(): void {
|
||||
for (const [model] of this.queues) {
|
||||
this.cancelWaiters(model)
|
||||
}
|
||||
// Cancel global queue waiters
|
||||
for (const entry of this.globalQueue) {
|
||||
if (!entry.settled) {
|
||||
entry.settled = true
|
||||
entry.rawReject(new Error("Concurrency queue cancelled: manager shutdown"))
|
||||
}
|
||||
}
|
||||
this.globalQueue = []
|
||||
this.globalCount = 0
|
||||
this.counts.clear()
|
||||
this.queues.clear()
|
||||
}
|
||||
|
||||
/**
|
||||
* Get current count for a model (for testing/debugging)
|
||||
*/
|
||||
getCount(model: string): number {
|
||||
return this.counts.get(model) ?? 0
|
||||
}
|
||||
|
||||
/**
|
||||
* Get queue length for a model (for testing/debugging)
|
||||
*/
|
||||
getQueueLength(model: string): number {
|
||||
return this.queues.get(model)?.length ?? 0
|
||||
}
|
||||
|
||||
/**
|
||||
* Get current global count across all models (for testing/debugging)
|
||||
*/
|
||||
getGlobalCount(): number {
|
||||
return this.globalCount
|
||||
}
|
||||
|
||||
/**
|
||||
* Get global queue length (for testing/debugging)
|
||||
*/
|
||||
getGlobalQueueLength(): number {
|
||||
return this.globalQueue.length
|
||||
}
|
||||
}
|
||||
```
|
||||
|
||||
**What changed:**
|
||||
- Added `globalCount` field to track total active agents across all keys
|
||||
- Added `globalQueue` for tasks waiting on the global limit
|
||||
- Added `getGlobalLimit()` method to read `maxBackgroundAgents` from config
|
||||
- Modified `acquire()` to check both per-model AND global limits
|
||||
- Modified `release()` to handle global queue handoff and decrement global count
|
||||
- Modified `clear()` to reset global state
|
||||
- Added `getGlobalCount()` and `getGlobalQueueLength()` for testing
|
||||
|
||||
**Important design note:** The `release()` implementation above is a simplified version. In practice, the global queue handoff is tricky because we need to know which model the global waiter was trying to acquire for. A cleaner approach would be to store the model key in the QueueEntry. Let me refine:
|
||||
|
||||
### Refined approach (simpler, more correct)
|
||||
|
||||
Instead of a separate global queue, a simpler approach is to check the global limit inside `acquire()` and use a single queue per model. When global capacity frees up on `release()`, we try to drain any model's queue:
|
||||
|
||||
```typescript
|
||||
async acquire(model: string): Promise<void> {
|
||||
const perModelLimit = this.getConcurrencyLimit(model)
|
||||
const globalLimit = this.getGlobalLimit()
|
||||
|
||||
if (perModelLimit === Infinity && globalLimit === Infinity) {
|
||||
return
|
||||
}
|
||||
|
||||
const currentPerModel = this.counts.get(model) ?? 0
|
||||
|
||||
if (currentPerModel < perModelLimit && this.globalCount < globalLimit) {
|
||||
this.counts.set(model, currentPerModel + 1)
|
||||
if (globalLimit !== Infinity) {
|
||||
this.globalCount++
|
||||
}
|
||||
return
|
||||
}
|
||||
|
||||
return new Promise<void>((resolve, reject) => {
|
||||
const queue = this.queues.get(model) ?? []
|
||||
|
||||
const entry: QueueEntry = {
|
||||
resolve: () => {
|
||||
if (entry.settled) return
|
||||
entry.settled = true
|
||||
resolve()
|
||||
},
|
||||
rawReject: reject,
|
||||
settled: false,
|
||||
}
|
||||
|
||||
queue.push(entry)
|
||||
this.queues.set(model, queue)
|
||||
})
|
||||
}
|
||||
|
||||
release(model: string): void {
|
||||
const perModelLimit = this.getConcurrencyLimit(model)
|
||||
const globalLimit = this.getGlobalLimit()
|
||||
|
||||
if (perModelLimit === Infinity && globalLimit === Infinity) {
|
||||
return
|
||||
}
|
||||
|
||||
// Try per-model handoff first (same model queue)
|
||||
const queue = this.queues.get(model)
|
||||
while (queue && queue.length > 0) {
|
||||
const next = queue.shift()!
|
||||
if (!next.settled) {
|
||||
// Hand off the slot to this waiter (per-model and global counts stay the same)
|
||||
next.resolve()
|
||||
return
|
||||
}
|
||||
}
|
||||
|
||||
// No per-model handoff - decrement per-model count
|
||||
const current = this.counts.get(model) ?? 0
|
||||
if (current > 0) {
|
||||
this.counts.set(model, current - 1)
|
||||
}
|
||||
|
||||
// Decrement global count
|
||||
if (globalLimit !== Infinity && this.globalCount > 0) {
|
||||
this.globalCount--
|
||||
}
|
||||
|
||||
// Try to drain any other model's queue that was blocked by global limit
|
||||
if (globalLimit !== Infinity) {
|
||||
this.tryDrainGlobalWaiters()
|
||||
}
|
||||
}
|
||||
|
||||
private tryDrainGlobalWaiters(): void {
|
||||
const globalLimit = this.getGlobalLimit()
|
||||
if (this.globalCount >= globalLimit) return
|
||||
|
||||
for (const [model, queue] of this.queues) {
|
||||
const perModelLimit = this.getConcurrencyLimit(model)
|
||||
const currentPerModel = this.counts.get(model) ?? 0
|
||||
|
||||
if (currentPerModel >= perModelLimit) continue
|
||||
|
||||
while (queue.length > 0 && this.globalCount < globalLimit && currentPerModel < perModelLimit) {
|
||||
const next = queue.shift()!
|
||||
if (!next.settled) {
|
||||
this.counts.set(model, (this.counts.get(model) ?? 0) + 1)
|
||||
this.globalCount++
|
||||
next.resolve()
|
||||
return
|
||||
}
|
||||
}
|
||||
}
|
||||
}
|
||||
```
|
||||
|
||||
This refined approach keeps all waiters in per-model queues (no separate global queue), and on release, tries to drain waiters from any model queue that was blocked by the global limit.
|
||||
|
||||
---
|
||||
|
||||
## 3. Schema Test Changes
|
||||
|
||||
**File:** `src/config/schema/background-task.test.ts`
|
||||
|
||||
Add after the `syncPollTimeoutMs` describe block:
|
||||
|
||||
```typescript
|
||||
describe("maxBackgroundAgents", () => {
|
||||
describe("#given valid maxBackgroundAgents (10)", () => {
|
||||
test("#when parsed #then returns correct value", () => {
|
||||
const result = BackgroundTaskConfigSchema.parse({ maxBackgroundAgents: 10 })
|
||||
|
||||
expect(result.maxBackgroundAgents).toBe(10)
|
||||
})
|
||||
})
|
||||
|
||||
describe("#given maxBackgroundAgents of 1 (minimum)", () => {
|
||||
test("#when parsed #then returns correct value", () => {
|
||||
const result = BackgroundTaskConfigSchema.parse({ maxBackgroundAgents: 1 })
|
||||
|
||||
expect(result.maxBackgroundAgents).toBe(1)
|
||||
})
|
||||
})
|
||||
|
||||
describe("#given maxBackgroundAgents below minimum (0)", () => {
|
||||
test("#when parsed #then throws ZodError", () => {
|
||||
let thrownError: unknown
|
||||
|
||||
try {
|
||||
BackgroundTaskConfigSchema.parse({ maxBackgroundAgents: 0 })
|
||||
} catch (error) {
|
||||
thrownError = error
|
||||
}
|
||||
|
||||
expect(thrownError).toBeInstanceOf(ZodError)
|
||||
})
|
||||
})
|
||||
|
||||
describe("#given maxBackgroundAgents is negative (-1)", () => {
|
||||
test("#when parsed #then throws ZodError", () => {
|
||||
let thrownError: unknown
|
||||
|
||||
try {
|
||||
BackgroundTaskConfigSchema.parse({ maxBackgroundAgents: -1 })
|
||||
} catch (error) {
|
||||
thrownError = error
|
||||
}
|
||||
|
||||
expect(thrownError).toBeInstanceOf(ZodError)
|
||||
})
|
||||
})
|
||||
|
||||
describe("#given maxBackgroundAgents is non-integer (2.5)", () => {
|
||||
test("#when parsed #then throws ZodError", () => {
|
||||
let thrownError: unknown
|
||||
|
||||
try {
|
||||
BackgroundTaskConfigSchema.parse({ maxBackgroundAgents: 2.5 })
|
||||
} catch (error) {
|
||||
thrownError = error
|
||||
}
|
||||
|
||||
expect(thrownError).toBeInstanceOf(ZodError)
|
||||
})
|
||||
})
|
||||
|
||||
describe("#given maxBackgroundAgents not provided", () => {
|
||||
test("#when parsed #then field is undefined", () => {
|
||||
const result = BackgroundTaskConfigSchema.parse({})
|
||||
|
||||
expect(result.maxBackgroundAgents).toBeUndefined()
|
||||
})
|
||||
})
|
||||
})
|
||||
```
|
||||
|
||||
---
|
||||
|
||||
## 4. ConcurrencyManager Test Changes
|
||||
|
||||
**File:** `src/features/background-agent/concurrency.test.ts`
|
||||
|
||||
Add new describe block:
|
||||
|
||||
```typescript
|
||||
describe("ConcurrencyManager.globalLimit (maxBackgroundAgents)", () => {
|
||||
test("should return Infinity when maxBackgroundAgents is not set", () => {
|
||||
// given
|
||||
const manager = new ConcurrencyManager()
|
||||
|
||||
// when
|
||||
const limit = manager.getGlobalLimit()
|
||||
|
||||
// then
|
||||
expect(limit).toBe(Infinity)
|
||||
})
|
||||
|
||||
test("should return configured maxBackgroundAgents", () => {
|
||||
// given
|
||||
const config: BackgroundTaskConfig = { maxBackgroundAgents: 3 }
|
||||
const manager = new ConcurrencyManager(config)
|
||||
|
||||
// when
|
||||
const limit = manager.getGlobalLimit()
|
||||
|
||||
// then
|
||||
expect(limit).toBe(3)
|
||||
})
|
||||
|
||||
test("should enforce global limit across different models", async () => {
|
||||
// given
|
||||
const config: BackgroundTaskConfig = {
|
||||
maxBackgroundAgents: 2,
|
||||
defaultConcurrency: 5,
|
||||
}
|
||||
const manager = new ConcurrencyManager(config)
|
||||
await manager.acquire("model-a")
|
||||
await manager.acquire("model-b")
|
||||
|
||||
// when
|
||||
let resolved = false
|
||||
const waitPromise = manager.acquire("model-c").then(() => { resolved = true })
|
||||
await Promise.resolve()
|
||||
|
||||
// then - should be blocked by global limit even though per-model has capacity
|
||||
expect(resolved).toBe(false)
|
||||
expect(manager.getGlobalCount()).toBe(2)
|
||||
|
||||
// cleanup
|
||||
manager.release("model-a")
|
||||
await waitPromise
|
||||
expect(resolved).toBe(true)
|
||||
})
|
||||
|
||||
test("should allow tasks when global limit not reached", async () => {
|
||||
// given
|
||||
const config: BackgroundTaskConfig = {
|
||||
maxBackgroundAgents: 3,
|
||||
defaultConcurrency: 5,
|
||||
}
|
||||
const manager = new ConcurrencyManager(config)
|
||||
|
||||
// when
|
||||
await manager.acquire("model-a")
|
||||
await manager.acquire("model-b")
|
||||
await manager.acquire("model-c")
|
||||
|
||||
// then
|
||||
expect(manager.getGlobalCount()).toBe(3)
|
||||
expect(manager.getCount("model-a")).toBe(1)
|
||||
expect(manager.getCount("model-b")).toBe(1)
|
||||
expect(manager.getCount("model-c")).toBe(1)
|
||||
})
|
||||
|
||||
test("should respect both per-model and global limits", async () => {
|
||||
// given - per-model limit of 1, global limit of 3
|
||||
const config: BackgroundTaskConfig = {
|
||||
maxBackgroundAgents: 3,
|
||||
defaultConcurrency: 1,
|
||||
}
|
||||
const manager = new ConcurrencyManager(config)
|
||||
await manager.acquire("model-a")
|
||||
|
||||
// when - try second acquire on same model
|
||||
let resolved = false
|
||||
const waitPromise = manager.acquire("model-a").then(() => { resolved = true })
|
||||
await Promise.resolve()
|
||||
|
||||
// then - blocked by per-model limit, not global
|
||||
expect(resolved).toBe(false)
|
||||
expect(manager.getGlobalCount()).toBe(1)
|
||||
|
||||
// cleanup
|
||||
manager.release("model-a")
|
||||
await waitPromise
|
||||
})
|
||||
|
||||
test("should release global slot and unblock waiting tasks", async () => {
|
||||
// given
|
||||
const config: BackgroundTaskConfig = {
|
||||
maxBackgroundAgents: 1,
|
||||
defaultConcurrency: 5,
|
||||
}
|
||||
const manager = new ConcurrencyManager(config)
|
||||
await manager.acquire("model-a")
|
||||
|
||||
// when
|
||||
let resolved = false
|
||||
const waitPromise = manager.acquire("model-b").then(() => { resolved = true })
|
||||
await Promise.resolve()
|
||||
expect(resolved).toBe(false)
|
||||
|
||||
manager.release("model-a")
|
||||
await waitPromise
|
||||
|
||||
// then
|
||||
expect(resolved).toBe(true)
|
||||
expect(manager.getGlobalCount()).toBe(1)
|
||||
expect(manager.getCount("model-a")).toBe(0)
|
||||
expect(manager.getCount("model-b")).toBe(1)
|
||||
})
|
||||
|
||||
test("should not enforce global limit when not configured", async () => {
|
||||
// given - no maxBackgroundAgents set
|
||||
const config: BackgroundTaskConfig = { defaultConcurrency: 5 }
|
||||
const manager = new ConcurrencyManager(config)
|
||||
|
||||
// when - acquire many across different models
|
||||
await manager.acquire("model-a")
|
||||
await manager.acquire("model-b")
|
||||
await manager.acquire("model-c")
|
||||
await manager.acquire("model-d")
|
||||
await manager.acquire("model-e")
|
||||
await manager.acquire("model-f")
|
||||
|
||||
// then - all should succeed (no global limit)
|
||||
expect(manager.getCount("model-a")).toBe(1)
|
||||
expect(manager.getCount("model-f")).toBe(1)
|
||||
})
|
||||
|
||||
test("should reset global count on clear", async () => {
|
||||
// given
|
||||
const config: BackgroundTaskConfig = { maxBackgroundAgents: 5 }
|
||||
const manager = new ConcurrencyManager(config)
|
||||
await manager.acquire("model-a")
|
||||
await manager.acquire("model-b")
|
||||
|
||||
// when
|
||||
manager.clear()
|
||||
|
||||
// then
|
||||
expect(manager.getGlobalCount()).toBe(0)
|
||||
})
|
||||
})
|
||||
```
|
||||
|
||||
---
|
||||
|
||||
## Config Usage Example
|
||||
|
||||
User's `.opencode/oh-my-opencode.jsonc`:
|
||||
|
||||
```jsonc
|
||||
{
|
||||
"background_task": {
|
||||
// Global limit: max 5 background agents total
|
||||
"maxBackgroundAgents": 5,
|
||||
// Per-model limits still apply independently
|
||||
"defaultConcurrency": 3,
|
||||
"providerConcurrency": {
|
||||
"anthropic": 2
|
||||
}
|
||||
}
|
||||
}
|
||||
```
|
||||
|
||||
With this config:
|
||||
- Max 5 background agents running simultaneously across all models
|
||||
- Max 3 per model (default), max 2 for any Anthropic model
|
||||
- If 2 Anthropic + 3 OpenAI agents are running (5 total), no more can start regardless of per-model capacity
|
||||
@@ -1,99 +0,0 @@
|
||||
# Execution Plan: Add `max_background_agents` Config Option
|
||||
|
||||
## Overview
|
||||
|
||||
Add a `max_background_agents` config option to oh-my-opencode that limits total simultaneous background agents across all models/providers. Currently, concurrency is only limited per-model/provider key (default 5 per key). This new option adds a **global ceiling** on total running background agents.
|
||||
|
||||
## Step-by-Step Plan
|
||||
|
||||
### Step 1: Create feature branch
|
||||
|
||||
```bash
|
||||
git checkout -b feat/max-background-agents dev
|
||||
```
|
||||
|
||||
### Step 2: Add `max_background_agents` to BackgroundTaskConfigSchema
|
||||
|
||||
**File:** `src/config/schema/background-task.ts`
|
||||
|
||||
- Add `maxBackgroundAgents` field to the Zod schema with `z.number().int().min(1).optional()`
|
||||
- This follows the existing pattern of `maxDepth` and `maxDescendants` (integer, min 1, optional)
|
||||
- The field name uses camelCase to match existing schema fields (`defaultConcurrency`, `maxDepth`, `maxDescendants`)
|
||||
- No `.default()` needed since the hardcoded fallback of 5 lives in `ConcurrencyManager`
|
||||
|
||||
### Step 3: Modify `ConcurrencyManager` to enforce global limit
|
||||
|
||||
**File:** `src/features/background-agent/concurrency.ts`
|
||||
|
||||
- Add a `globalCount` field tracking total active agents across all keys
|
||||
- Modify `acquire()` to check global count against `maxBackgroundAgents` before granting a slot
|
||||
- Modify `release()` to decrement global count
|
||||
- Modify `clear()` to reset global count
|
||||
- Add `getGlobalCount()` for testing/debugging (follows existing `getCount()`/`getQueueLength()` pattern)
|
||||
|
||||
The global limit check happens **in addition to** the per-model limit. Both must have capacity for a task to proceed.
|
||||
|
||||
### Step 4: Add tests for the new config schema field
|
||||
|
||||
**File:** `src/config/schema/background-task.test.ts`
|
||||
|
||||
- Add test cases following the existing given/when/then pattern with nested describes
|
||||
- Test valid value, below-minimum value, undefined (not provided), non-number type
|
||||
|
||||
### Step 5: Add tests for ConcurrencyManager global limit
|
||||
|
||||
**File:** `src/features/background-agent/concurrency.test.ts`
|
||||
|
||||
- Test that global limit is enforced across different model keys
|
||||
- Test that tasks queue when global limit reached even if per-model limit has capacity
|
||||
- Test that releasing a slot from one model allows a queued task from another model to proceed
|
||||
- Test default behavior (5) when no config provided
|
||||
- Test interaction between global and per-model limits
|
||||
|
||||
### Step 6: Run typecheck and tests
|
||||
|
||||
```bash
|
||||
bun run typecheck
|
||||
bun test src/config/schema/background-task.test.ts
|
||||
bun test src/features/background-agent/concurrency.test.ts
|
||||
```
|
||||
|
||||
### Step 7: Verify LSP diagnostics clean
|
||||
|
||||
Check `src/config/schema/background-task.ts` and `src/features/background-agent/concurrency.ts` for errors.
|
||||
|
||||
### Step 8: Create PR
|
||||
|
||||
- Push branch to remote
|
||||
- Create PR with structured description via `gh pr create`
|
||||
|
||||
## Files Modified (4 files)
|
||||
|
||||
| File | Change |
|
||||
|------|--------|
|
||||
| `src/config/schema/background-task.ts` | Add `maxBackgroundAgents` field |
|
||||
| `src/features/background-agent/concurrency.ts` | Add global count tracking + enforcement |
|
||||
| `src/config/schema/background-task.test.ts` | Add schema validation tests |
|
||||
| `src/features/background-agent/concurrency.test.ts` | Add global limit enforcement tests |
|
||||
|
||||
## Files NOT Modified (intentional)
|
||||
|
||||
| File | Reason |
|
||||
|------|--------|
|
||||
| `src/config/schema/oh-my-opencode-config.ts` | No change needed - `BackgroundTaskConfigSchema` is already composed into root schema via `background_task` field |
|
||||
| `src/create-managers.ts` | No change needed - `pluginConfig.background_task` already passed to `BackgroundManager` constructor |
|
||||
| `src/features/background-agent/manager.ts` | No change needed - already passes config to `ConcurrencyManager` |
|
||||
| `src/plugin-config.ts` | No change needed - `background_task` is a simple object field, uses default override merge |
|
||||
| `src/config/schema.ts` | No change needed - barrel already exports `BackgroundTaskConfigSchema` |
|
||||
|
||||
## Design Decisions
|
||||
|
||||
1. **Field name `maxBackgroundAgents`** - camelCase to match existing schema fields (`maxDepth`, `maxDescendants`, `defaultConcurrency`). The user-facing JSONC config key is also camelCase per existing convention in `background_task` section.
|
||||
|
||||
2. **Global limit vs per-model limit** - The global limit is a ceiling across ALL concurrency keys. Per-model limits still apply independently. A task needs both a per-model slot AND a global slot to proceed.
|
||||
|
||||
3. **Default of 5** - Matches the existing hardcoded default in `getConcurrencyLimit()`. When `maxBackgroundAgents` is not set, no global limit is enforced (only per-model limits apply), preserving backward compatibility.
|
||||
|
||||
4. **Queue behavior** - When global limit is reached, tasks wait in the same FIFO queue mechanism. The global check happens inside `acquire()` before the per-model check.
|
||||
|
||||
5. **0 means Infinity** - Following the existing pattern where `defaultConcurrency: 0` means unlimited, `maxBackgroundAgents: 0` would also mean no global limit.
|
||||
@@ -1,50 +0,0 @@
|
||||
# PR Description
|
||||
|
||||
**Title:** feat: add `maxBackgroundAgents` config to limit total simultaneous background agents
|
||||
|
||||
**Body:**
|
||||
|
||||
## Summary
|
||||
|
||||
- Add `maxBackgroundAgents` field to `BackgroundTaskConfigSchema` that enforces a global ceiling on total running background agents across all models/providers
|
||||
- Modify `ConcurrencyManager` to track global count and enforce the limit alongside existing per-model limits
|
||||
- Add schema validation tests and concurrency enforcement tests
|
||||
|
||||
## Motivation
|
||||
|
||||
Currently, concurrency is only limited per model/provider key (default 5 per key). On resource-constrained machines or when using many different models, the total number of background agents can grow unbounded (5 per model x N models). This config option lets users set a hard ceiling.
|
||||
|
||||
## Changes
|
||||
|
||||
### Schema (`src/config/schema/background-task.ts`)
|
||||
- Added `maxBackgroundAgents: z.number().int().min(1).optional()` to `BackgroundTaskConfigSchema`
|
||||
- Grouped with existing limit fields (`maxDepth`, `maxDescendants`)
|
||||
|
||||
### ConcurrencyManager (`src/features/background-agent/concurrency.ts`)
|
||||
- Added `globalCount` tracking total active agents across all concurrency keys
|
||||
- Added `getGlobalLimit()` reading `maxBackgroundAgents` from config (defaults to `Infinity` = no global limit)
|
||||
- Modified `acquire()` to check both per-model AND global capacity
|
||||
- Modified `release()` to decrement global count and drain cross-model waiters blocked by global limit
|
||||
- Modified `clear()` to reset global state
|
||||
- Added `getGlobalCount()` / `getGlobalQueueLength()` for testing
|
||||
|
||||
### Tests
|
||||
- `src/config/schema/background-task.test.ts`: 6 test cases for schema validation (valid, min boundary, below min, negative, non-integer, undefined)
|
||||
- `src/features/background-agent/concurrency.test.ts`: 8 test cases for global limit enforcement (cross-model blocking, release unblocking, per-model vs global interaction, no-config default, clear reset)
|
||||
|
||||
## Config Example
|
||||
|
||||
```jsonc
|
||||
{
|
||||
"background_task": {
|
||||
"maxBackgroundAgents": 5,
|
||||
"defaultConcurrency": 3
|
||||
}
|
||||
}
|
||||
```
|
||||
|
||||
## Backward Compatibility
|
||||
|
||||
- When `maxBackgroundAgents` is not set (default), no global limit is enforced - behavior is identical to before
|
||||
- Existing `defaultConcurrency`, `providerConcurrency`, and `modelConcurrency` continue to work unchanged
|
||||
- No config migration needed
|
||||
@@ -1,111 +0,0 @@
|
||||
# Verification Strategy
|
||||
|
||||
## 1. Static Analysis
|
||||
|
||||
### TypeScript Typecheck
|
||||
```bash
|
||||
bun run typecheck
|
||||
```
|
||||
- Verify no type errors introduced
|
||||
- `BackgroundTaskConfig` type is inferred from Zod schema, so adding the field automatically updates the type
|
||||
- All existing consumers of `BackgroundTaskConfig` remain compatible (new field is optional)
|
||||
|
||||
### LSP Diagnostics
|
||||
Check changed files for errors:
|
||||
- `src/config/schema/background-task.ts`
|
||||
- `src/features/background-agent/concurrency.ts`
|
||||
- `src/config/schema/background-task.test.ts`
|
||||
- `src/features/background-agent/concurrency.test.ts`
|
||||
|
||||
## 2. Unit Tests
|
||||
|
||||
### Schema Validation Tests
|
||||
```bash
|
||||
bun test src/config/schema/background-task.test.ts
|
||||
```
|
||||
|
||||
| Test Case | Input | Expected |
|
||||
|-----------|-------|----------|
|
||||
| Valid value (10) | `{ maxBackgroundAgents: 10 }` | Parses to `10` |
|
||||
| Minimum boundary (1) | `{ maxBackgroundAgents: 1 }` | Parses to `1` |
|
||||
| Below minimum (0) | `{ maxBackgroundAgents: 0 }` | Throws `ZodError` |
|
||||
| Negative (-1) | `{ maxBackgroundAgents: -1 }` | Throws `ZodError` |
|
||||
| Non-integer (2.5) | `{ maxBackgroundAgents: 2.5 }` | Throws `ZodError` |
|
||||
| Not provided | `{}` | Field is `undefined` |
|
||||
|
||||
### ConcurrencyManager Tests
|
||||
```bash
|
||||
bun test src/features/background-agent/concurrency.test.ts
|
||||
```
|
||||
|
||||
| Test Case | Setup | Expected |
|
||||
|-----------|-------|----------|
|
||||
| No config = no global limit | No `maxBackgroundAgents` | `getGlobalLimit()` returns `Infinity` |
|
||||
| Config respected | `maxBackgroundAgents: 3` | `getGlobalLimit()` returns `3` |
|
||||
| Cross-model blocking | Global limit 2, acquire model-a + model-b, try model-c | model-c blocks |
|
||||
| Under-limit allows | Global limit 3, acquire 3 different models | All succeed |
|
||||
| Per-model + global interaction | Per-model 1, global 3, acquire model-a twice | Blocked by per-model, not global |
|
||||
| Release unblocks | Global limit 1, acquire model-a, queue model-b, release model-a | model-b proceeds |
|
||||
| No global limit = no enforcement | No config, acquire 6 different models | All succeed |
|
||||
| Clear resets global count | Acquire 2, clear | `getGlobalCount()` is 0 |
|
||||
|
||||
### Existing Test Regression
|
||||
```bash
|
||||
bun test src/features/background-agent/concurrency.test.ts
|
||||
bun test src/config/schema/background-task.test.ts
|
||||
bun test src/config/schema.test.ts
|
||||
```
|
||||
All existing tests must continue to pass unchanged.
|
||||
|
||||
## 3. Integration Verification
|
||||
|
||||
### Config Loading Path
|
||||
Verify the config flows correctly through the system:
|
||||
|
||||
1. **Schema → Type**: `BackgroundTaskConfig` type auto-includes `maxBackgroundAgents` via `z.infer`
|
||||
2. **Config file → Schema**: `loadConfigFromPath()` in `plugin-config.ts` uses `OhMyOpenCodeConfigSchema.safeParse()` which includes `BackgroundTaskConfigSchema`
|
||||
3. **Config → Manager**: `create-managers.ts` passes `pluginConfig.background_task` to `BackgroundManager` constructor
|
||||
4. **Manager → ConcurrencyManager**: `BackgroundManager` constructor passes config to `new ConcurrencyManager(config)`
|
||||
5. **ConcurrencyManager → Enforcement**: `acquire()` reads `config.maxBackgroundAgents` via `getGlobalLimit()`
|
||||
|
||||
No changes needed in steps 2-4 since the field is optional and the existing plumbing passes the entire `BackgroundTaskConfig` object.
|
||||
|
||||
### Manual Config Test
|
||||
Create a test config to verify parsing:
|
||||
```bash
|
||||
echo '{ "background_task": { "maxBackgroundAgents": 3 } }' | bun -e "
|
||||
const { BackgroundTaskConfigSchema } = require('./src/config/schema/background-task');
|
||||
const result = BackgroundTaskConfigSchema.safeParse(JSON.parse(require('fs').readFileSync('/dev/stdin', 'utf-8')).background_task);
|
||||
console.log(result.success, result.data);
|
||||
"
|
||||
```
|
||||
|
||||
## 4. Build Verification
|
||||
|
||||
```bash
|
||||
bun run build
|
||||
```
|
||||
- Verify build succeeds
|
||||
- Schema JSON output includes the new field (if applicable)
|
||||
|
||||
## 5. Edge Cases to Verify
|
||||
|
||||
| Edge Case | Expected Behavior |
|
||||
|-----------|-------------------|
|
||||
| `maxBackgroundAgents` not set | No global limit enforced (backward compatible) |
|
||||
| `maxBackgroundAgents: 1` | Only 1 background agent at a time across all models |
|
||||
| `maxBackgroundAgents` > sum of all per-model limits | Global limit never triggers (per-model limits are tighter) |
|
||||
| Per-model limit tighter than global | Per-model limit blocks first |
|
||||
| Global limit tighter than per-model | Global limit blocks first |
|
||||
| Release from one model unblocks different model | Global slot freed, different model's waiter proceeds |
|
||||
| Manager shutdown with global waiters | `clear()` rejects all waiters and resets global count |
|
||||
| Concurrent acquire/release | No race conditions (single-threaded JS event loop) |
|
||||
|
||||
## 6. CI Pipeline
|
||||
|
||||
The existing CI workflow (`ci.yml`) will run:
|
||||
- `bun run typecheck` - type checking
|
||||
- `bun test` - all tests including new ones
|
||||
- `bun run build` - build verification
|
||||
|
||||
No CI changes needed.
|
||||
@@ -1 +0,0 @@
|
||||
{"total_tokens": null, "duration_ms": 365000, "total_duration_seconds": 365}
|
||||
@@ -1,37 +0,0 @@
|
||||
{
|
||||
"eval_id": 2,
|
||||
"eval_name": "bugfix-atlas-null-check",
|
||||
"prompt": "The atlas hook has a bug where it crashes when boulder.json is missing the worktree_path field. Fix it and land the fix as a PR. Make sure CI passes.",
|
||||
"assertions": [
|
||||
{
|
||||
"id": "worktree-isolation",
|
||||
"text": "Plan uses git worktree in a sibling directory",
|
||||
"type": "manual"
|
||||
},
|
||||
{
|
||||
"id": "minimal-fix",
|
||||
"text": "Fix is minimal — adds null check, doesn't refactor unrelated code",
|
||||
"type": "manual"
|
||||
},
|
||||
{
|
||||
"id": "test-added",
|
||||
"text": "Test case added for the missing worktree_path scenario",
|
||||
"type": "manual"
|
||||
},
|
||||
{
|
||||
"id": "three-gates",
|
||||
"text": "Verification loop includes all 3 gates: CI, review-work, Cubic",
|
||||
"type": "manual"
|
||||
},
|
||||
{
|
||||
"id": "real-atlas-files",
|
||||
"text": "References actual atlas hook files in src/hooks/atlas/",
|
||||
"type": "manual"
|
||||
},
|
||||
{
|
||||
"id": "fix-branch-naming",
|
||||
"text": "Branch name follows fix/ prefix convention",
|
||||
"type": "manual"
|
||||
}
|
||||
]
|
||||
}
|
||||
@@ -1,11 +0,0 @@
|
||||
{
|
||||
"run_id": "eval-2-with_skill",
|
||||
"expectations": [
|
||||
{"text": "Plan uses git worktree in a sibling directory", "passed": true, "evidence": "../omo-wt/fix-atlas-worktree-path-crash"},
|
||||
{"text": "Fix is minimal — adds null check, doesn't refactor unrelated code", "passed": true, "evidence": "3 targeted changes: readBoulderState sanitization, idle-event guard, tests"},
|
||||
{"text": "Test case added for the missing worktree_path scenario", "passed": true, "evidence": "Tests for missing and null worktree_path"},
|
||||
{"text": "Verification loop includes all 3 gates", "passed": true, "evidence": "Gate A (CI), Gate B (review-work), Gate C (Cubic)"},
|
||||
{"text": "References actual atlas hook files", "passed": true, "evidence": "src/hooks/atlas/idle-event.ts, src/features/boulder-state/storage.ts"},
|
||||
{"text": "Branch name follows fix/ prefix convention", "passed": true, "evidence": "fix/atlas-worktree-path-crash"}
|
||||
]
|
||||
}
|
||||
@@ -1,205 +0,0 @@
|
||||
# Code Changes
|
||||
|
||||
## File 1: `src/features/boulder-state/storage.ts`
|
||||
|
||||
**Change**: Add `worktree_path` sanitization in `readBoulderState()`
|
||||
|
||||
```typescript
|
||||
// BEFORE (lines 29-32):
|
||||
if (!Array.isArray(parsed.session_ids)) {
|
||||
parsed.session_ids = []
|
||||
}
|
||||
return parsed as BoulderState
|
||||
|
||||
// AFTER:
|
||||
if (!Array.isArray(parsed.session_ids)) {
|
||||
parsed.session_ids = []
|
||||
}
|
||||
if (parsed.worktree_path !== undefined && typeof parsed.worktree_path !== "string") {
|
||||
parsed.worktree_path = undefined
|
||||
}
|
||||
return parsed as BoulderState
|
||||
```
|
||||
|
||||
**Rationale**: `readBoulderState` casts raw `JSON.parse()` output as `BoulderState` without validating individual fields. When boulder.json has `"worktree_path": null` (valid JSON from manual edits, corrupted state, or external tools), the runtime type is `null` but TypeScript type says `string | undefined`. This sanitization ensures downstream code always gets the correct type.
|
||||
|
||||
---
|
||||
|
||||
## File 2: `src/hooks/atlas/idle-event.ts`
|
||||
|
||||
**Change**: Add defensive string type guard before passing `worktree_path` to continuation functions.
|
||||
|
||||
```typescript
|
||||
// BEFORE (lines 83-88 in scheduleRetry):
|
||||
await injectContinuation({
|
||||
ctx,
|
||||
sessionID,
|
||||
sessionState,
|
||||
options,
|
||||
planName: currentBoulder.plan_name,
|
||||
progress: currentProgress,
|
||||
agent: currentBoulder.agent,
|
||||
worktreePath: currentBoulder.worktree_path,
|
||||
})
|
||||
|
||||
// AFTER:
|
||||
await injectContinuation({
|
||||
ctx,
|
||||
sessionID,
|
||||
sessionState,
|
||||
options,
|
||||
planName: currentBoulder.plan_name,
|
||||
progress: currentProgress,
|
||||
agent: currentBoulder.agent,
|
||||
worktreePath: typeof currentBoulder.worktree_path === "string" ? currentBoulder.worktree_path : undefined,
|
||||
})
|
||||
```
|
||||
|
||||
```typescript
|
||||
// BEFORE (lines 184-188 in handleAtlasSessionIdle):
|
||||
await injectContinuation({
|
||||
ctx,
|
||||
sessionID,
|
||||
sessionState,
|
||||
options,
|
||||
planName: boulderState.plan_name,
|
||||
progress,
|
||||
agent: boulderState.agent,
|
||||
worktreePath: boulderState.worktree_path,
|
||||
})
|
||||
|
||||
// AFTER:
|
||||
await injectContinuation({
|
||||
ctx,
|
||||
sessionID,
|
||||
sessionState,
|
||||
options,
|
||||
planName: boulderState.plan_name,
|
||||
progress,
|
||||
agent: boulderState.agent,
|
||||
worktreePath: typeof boulderState.worktree_path === "string" ? boulderState.worktree_path : undefined,
|
||||
})
|
||||
```
|
||||
|
||||
**Rationale**: Belt-and-suspenders defense. Even though `readBoulderState` now sanitizes, direct `writeBoulderState` calls elsewhere could still produce invalid state. The `typeof` check is zero-cost and prevents any possibility of `null` or non-string values leaking through.
|
||||
|
||||
---
|
||||
|
||||
## File 3: `src/hooks/atlas/index.test.ts`
|
||||
|
||||
**Change**: Add test cases for missing `worktree_path` scenarios within the existing `session.idle handler` describe block.
|
||||
|
||||
```typescript
|
||||
test("should inject continuation when boulder.json has no worktree_path field", async () => {
|
||||
// given - boulder state WITHOUT worktree_path
|
||||
const planPath = join(TEST_DIR, "test-plan.md")
|
||||
writeFileSync(planPath, "# Plan\n- [ ] Task 1\n- [x] Task 2")
|
||||
|
||||
const state: BoulderState = {
|
||||
active_plan: planPath,
|
||||
started_at: "2026-01-02T10:00:00Z",
|
||||
session_ids: [MAIN_SESSION_ID],
|
||||
plan_name: "test-plan",
|
||||
}
|
||||
writeBoulderState(TEST_DIR, state)
|
||||
|
||||
const readState = readBoulderState(TEST_DIR)
|
||||
expect(readState?.worktree_path).toBeUndefined()
|
||||
|
||||
const mockInput = createMockPluginInput()
|
||||
const hook = createAtlasHook(mockInput)
|
||||
|
||||
// when
|
||||
await hook.handler({
|
||||
event: {
|
||||
type: "session.idle",
|
||||
properties: { sessionID: MAIN_SESSION_ID },
|
||||
},
|
||||
})
|
||||
|
||||
// then - continuation injected, no worktree context in prompt
|
||||
expect(mockInput._promptMock).toHaveBeenCalled()
|
||||
const callArgs = mockInput._promptMock.mock.calls[0][0]
|
||||
expect(callArgs.body.parts[0].text).not.toContain("[Worktree:")
|
||||
expect(callArgs.body.parts[0].text).toContain("1 remaining")
|
||||
})
|
||||
|
||||
test("should handle boulder.json with worktree_path: null without crashing", async () => {
|
||||
// given - manually write boulder.json with worktree_path: null (corrupted state)
|
||||
const planPath = join(TEST_DIR, "test-plan.md")
|
||||
writeFileSync(planPath, "# Plan\n- [ ] Task 1\n- [x] Task 2")
|
||||
|
||||
const boulderPath = join(SISYPHUS_DIR, "boulder.json")
|
||||
writeFileSync(boulderPath, JSON.stringify({
|
||||
active_plan: planPath,
|
||||
started_at: "2026-01-02T10:00:00Z",
|
||||
session_ids: [MAIN_SESSION_ID],
|
||||
plan_name: "test-plan",
|
||||
worktree_path: null,
|
||||
}, null, 2))
|
||||
|
||||
const mockInput = createMockPluginInput()
|
||||
const hook = createAtlasHook(mockInput)
|
||||
|
||||
// when
|
||||
await hook.handler({
|
||||
event: {
|
||||
type: "session.idle",
|
||||
properties: { sessionID: MAIN_SESSION_ID },
|
||||
},
|
||||
})
|
||||
|
||||
// then - should inject continuation without crash, no "[Worktree: null]"
|
||||
expect(mockInput._promptMock).toHaveBeenCalled()
|
||||
const callArgs = mockInput._promptMock.mock.calls[0][0]
|
||||
expect(callArgs.body.parts[0].text).not.toContain("[Worktree: null]")
|
||||
expect(callArgs.body.parts[0].text).not.toContain("[Worktree: undefined]")
|
||||
})
|
||||
```
|
||||
|
||||
---
|
||||
|
||||
## File 4: `src/features/boulder-state/storage.test.ts` (addition to existing)
|
||||
|
||||
**Change**: Add `readBoulderState` sanitization test.
|
||||
|
||||
```typescript
|
||||
describe("#given boulder.json with worktree_path: null", () => {
|
||||
test("#then readBoulderState should sanitize null to undefined", () => {
|
||||
// given
|
||||
const boulderPath = join(TEST_DIR, ".sisyphus", "boulder.json")
|
||||
writeFileSync(boulderPath, JSON.stringify({
|
||||
active_plan: "/path/to/plan.md",
|
||||
started_at: "2026-01-02T10:00:00Z",
|
||||
session_ids: ["session-1"],
|
||||
plan_name: "test-plan",
|
||||
worktree_path: null,
|
||||
}, null, 2))
|
||||
|
||||
// when
|
||||
const state = readBoulderState(TEST_DIR)
|
||||
|
||||
// then
|
||||
expect(state).not.toBeNull()
|
||||
expect(state!.worktree_path).toBeUndefined()
|
||||
})
|
||||
|
||||
test("#then readBoulderState should preserve valid worktree_path string", () => {
|
||||
// given
|
||||
const boulderPath = join(TEST_DIR, ".sisyphus", "boulder.json")
|
||||
writeFileSync(boulderPath, JSON.stringify({
|
||||
active_plan: "/path/to/plan.md",
|
||||
started_at: "2026-01-02T10:00:00Z",
|
||||
session_ids: ["session-1"],
|
||||
plan_name: "test-plan",
|
||||
worktree_path: "/valid/worktree/path",
|
||||
}, null, 2))
|
||||
|
||||
// when
|
||||
const state = readBoulderState(TEST_DIR)
|
||||
|
||||
// then
|
||||
expect(state?.worktree_path).toBe("/valid/worktree/path")
|
||||
})
|
||||
})
|
||||
```
|
||||
@@ -1,78 +0,0 @@
|
||||
# Execution Plan — Fix atlas hook crash on missing worktree_path
|
||||
|
||||
## Phase 0: Setup
|
||||
|
||||
1. **Create worktree from origin/dev**:
|
||||
```bash
|
||||
git fetch origin dev
|
||||
git worktree add ../omo-wt/fix-atlas-worktree-path-crash origin/dev
|
||||
```
|
||||
2. **Create feature branch**:
|
||||
```bash
|
||||
cd ../omo-wt/fix-atlas-worktree-path-crash
|
||||
git checkout -b fix/atlas-worktree-path-crash
|
||||
```
|
||||
|
||||
## Phase 1: Implement
|
||||
|
||||
### Step 1: Fix `readBoulderState()` in `src/features/boulder-state/storage.ts`
|
||||
- Add `worktree_path` sanitization after JSON parse
|
||||
- Ensure `worktree_path` is `string | undefined`, never `null` or other types
|
||||
- This is the root cause: raw `JSON.parse` + `as BoulderState` cast allows type violations at runtime
|
||||
|
||||
### Step 2: Add defensive guard in `src/hooks/atlas/idle-event.ts`
|
||||
- Before passing `boulderState.worktree_path` to `injectContinuation`, validate it's a string
|
||||
- Apply same guard in the `scheduleRetry` callback (line 86)
|
||||
- Ensures even if `readBoulderState` is bypassed, the idle handler won't crash
|
||||
|
||||
### Step 3: Add test coverage in `src/hooks/atlas/index.test.ts`
|
||||
- Add test: boulder.json without `worktree_path` field → session.idle works
|
||||
- Add test: boulder.json with `worktree_path: null` → session.idle works (no `[Worktree: null]` in prompt)
|
||||
- Add test: `readBoulderState` sanitizes `null` worktree_path to `undefined`
|
||||
- Follow existing given/when/then test pattern
|
||||
|
||||
### Step 4: Local validation
|
||||
```bash
|
||||
bun run typecheck
|
||||
bun test src/hooks/atlas/
|
||||
bun test src/features/boulder-state/
|
||||
bun run build
|
||||
```
|
||||
|
||||
### Step 5: Atomic commit
|
||||
```bash
|
||||
git add src/features/boulder-state/storage.ts src/hooks/atlas/idle-event.ts src/hooks/atlas/index.test.ts
|
||||
git commit -m "fix(atlas): prevent crash when boulder.json missing worktree_path field
|
||||
|
||||
readBoulderState() performs unsafe cast of parsed JSON as BoulderState.
|
||||
When worktree_path is absent or null in boulder.json, downstream code
|
||||
in idle-event.ts could receive null where string|undefined is expected.
|
||||
|
||||
- Sanitize worktree_path in readBoulderState (reject non-string values)
|
||||
- Add defensive typeof check in idle-event before passing to continuation
|
||||
- Add test coverage for missing and null worktree_path scenarios"
|
||||
```
|
||||
|
||||
## Phase 2: PR Creation
|
||||
|
||||
```bash
|
||||
git push -u origin fix/atlas-worktree-path-crash
|
||||
gh pr create \
|
||||
--base dev \
|
||||
--title "fix(atlas): prevent crash when boulder.json missing worktree_path" \
|
||||
--body-file /tmp/pull-request-atlas-worktree-fix.md
|
||||
```
|
||||
|
||||
## Phase 3: Verify Loop
|
||||
|
||||
- **Gate A (CI)**: `gh pr checks --watch` — wait for all checks green
|
||||
- **Gate B (review-work)**: Run 5-agent review (Oracle goal, Oracle quality, Oracle security, QA execution, context mining)
|
||||
- **Gate C (Cubic)**: Wait for cubic-dev-ai[bot] to respond "No issues found"
|
||||
- On any failure: fix-commit-push, re-enter verify loop
|
||||
|
||||
## Phase 4: Merge
|
||||
|
||||
```bash
|
||||
gh pr merge --squash --delete-branch
|
||||
git worktree remove ../omo-wt/fix-atlas-worktree-path-crash
|
||||
```
|
||||
@@ -1,42 +0,0 @@
|
||||
# PR Title
|
||||
|
||||
```
|
||||
fix(atlas): prevent crash when boulder.json missing worktree_path
|
||||
```
|
||||
|
||||
# PR Body
|
||||
|
||||
## Summary
|
||||
|
||||
- Fix runtime type violation in atlas hook when `boulder.json` lacks `worktree_path` field
|
||||
- Add `worktree_path` sanitization in `readBoulderState()` to reject non-string values (e.g., `null` from manual edits)
|
||||
- Add defensive `typeof` guards in `idle-event.ts` before passing worktree path to continuation injection
|
||||
- Add test coverage for missing and null `worktree_path` scenarios
|
||||
|
||||
## Problem
|
||||
|
||||
`readBoulderState()` in `src/features/boulder-state/storage.ts` casts raw `JSON.parse()` output directly as `BoulderState` via `return parsed as BoulderState`. This bypasses TypeScript's type system entirely at runtime.
|
||||
|
||||
When `boulder.json` is missing the `worktree_path` field (common for boulders created before worktree support was added, or created without `--worktree` flag), `boulderState.worktree_path` is `undefined` which is handled correctly. However, when boulder.json has `"worktree_path": null` (possible from manual edits, external tooling, or corrupted state), the runtime type becomes `null` which violates the TypeScript type `string | undefined`.
|
||||
|
||||
This `null` value propagates through:
|
||||
1. `idle-event.ts:handleAtlasSessionIdle()` → `injectContinuation()` → `injectBoulderContinuation()`
|
||||
2. `idle-event.ts:scheduleRetry()` callback → same chain
|
||||
|
||||
While the `boulder-continuation-injector.ts` handles falsy values via `worktreePath ? ... : ""`, the type mismatch can cause subtle downstream issues and violates the contract of the `BoulderState` interface.
|
||||
|
||||
## Changes
|
||||
|
||||
| File | Change |
|
||||
|------|--------|
|
||||
| `src/features/boulder-state/storage.ts` | Sanitize `worktree_path` in `readBoulderState()` — reject non-string values |
|
||||
| `src/hooks/atlas/idle-event.ts` | Add `typeof` guards before passing worktree_path to continuation (2 call sites) |
|
||||
| `src/hooks/atlas/index.test.ts` | Add 2 tests: missing worktree_path + null worktree_path in session.idle |
|
||||
| `src/features/boulder-state/storage.test.ts` | Add 2 tests: sanitization of null + preservation of valid string |
|
||||
|
||||
## Testing
|
||||
|
||||
- `bun test src/hooks/atlas/` — all existing + new tests pass
|
||||
- `bun test src/features/boulder-state/` — all existing + new tests pass
|
||||
- `bun run typecheck` — clean
|
||||
- `bun run build` — clean
|
||||
@@ -1,87 +0,0 @@
|
||||
# Verification Strategy
|
||||
|
||||
## Gate A: CI (`gh pr checks --watch`)
|
||||
|
||||
### What CI runs (from `ci.yml`)
|
||||
1. **Tests (split)**: Mock-heavy tests in isolation + batch tests
|
||||
2. **Typecheck**: `bun run typecheck` (tsc --noEmit)
|
||||
3. **Build**: `bun run build` (ESM + declarations + schema)
|
||||
|
||||
### Pre-push local validation
|
||||
Before pushing, run the exact CI steps locally to catch failures early:
|
||||
|
||||
```bash
|
||||
# Targeted test runs first (fast feedback)
|
||||
bun test src/features/boulder-state/storage.test.ts
|
||||
bun test src/hooks/atlas/index.test.ts
|
||||
|
||||
# Full test suite
|
||||
bun test
|
||||
|
||||
# Type check
|
||||
bun run typecheck
|
||||
|
||||
# Build
|
||||
bun run build
|
||||
```
|
||||
|
||||
### Failure handling
|
||||
- **Test failure**: Read test output, fix code, create new commit (never amend pushed commits), push
|
||||
- **Typecheck failure**: Run `lsp_diagnostics` on changed files, fix type errors, commit, push
|
||||
- **Build failure**: Check build output for missing exports or circular deps, fix, commit, push
|
||||
|
||||
After each fix-commit-push: `gh pr checks --watch` to re-enter gate
|
||||
|
||||
## Gate B: review-work (5-agent review)
|
||||
|
||||
### The 5 parallel agents
|
||||
1. **Oracle (goal/constraint verification)**: Checks the fix matches the stated problem — `worktree_path` crash resolved, no scope creep
|
||||
2. **Oracle (code quality)**: Validates code follows existing patterns — factory pattern, given/when/then tests, < 200 LOC, no catch-all files
|
||||
3. **Oracle (security)**: Ensures no new security issues — JSON parse injection, path traversal in worktree_path
|
||||
4. **QA agent (hands-on execution)**: Actually runs the tests, checks `lsp_diagnostics` on changed files, verifies the fix in action
|
||||
5. **Context mining agent**: Checks GitHub issues, git history, related PRs for context alignment
|
||||
|
||||
### Expected focus areas for this PR
|
||||
- Oracle (goal): Does the sanitization in `readBoulderState` actually prevent the crash? Is the `typeof` guard necessary or redundant?
|
||||
- Oracle (quality): Are the new tests following the given/when/then pattern? Do they use the same mock setup as existing tests?
|
||||
- Oracle (security): Is the `worktree_path` value ever used in path operations without sanitization? (Answer: no, it's only used in template strings)
|
||||
- QA: Run `bun test src/hooks/atlas/index.test.ts` — does the null worktree_path test actually trigger the bug before fix?
|
||||
|
||||
### Failure handling
|
||||
- Each oracle produces a PASS/FAIL verdict with specific issues
|
||||
- On FAIL: read the specific issue, fix in the worktree, commit, push, re-run review-work
|
||||
- All 5 agents must PASS
|
||||
|
||||
## Gate C: Cubic (`cubic-dev-ai[bot]`)
|
||||
|
||||
### What Cubic checks
|
||||
- Automated code review bot that analyzes the PR diff
|
||||
- Looks for: type safety issues, missing error handling, test coverage gaps, anti-patterns
|
||||
|
||||
### Expected result
|
||||
- "No issues found" for this small, focused fix
|
||||
- 3 files changed (storage.ts, idle-event.ts, index.test.ts) + 1 test file
|
||||
|
||||
### Failure handling
|
||||
- If Cubic flags an issue: evaluate if it's a real concern or false positive
|
||||
- Real concern: fix, commit, push
|
||||
- False positive: comment explaining why the flagged pattern is intentional
|
||||
- Wait for Cubic to re-review after push
|
||||
|
||||
## Post-verification: Merge
|
||||
|
||||
Once all 3 gates pass:
|
||||
```bash
|
||||
gh pr merge --squash --delete-branch
|
||||
git worktree remove ../omo-wt/fix-atlas-worktree-path-crash
|
||||
```
|
||||
|
||||
On merge failure (conflicts):
|
||||
```bash
|
||||
cd ../omo-wt/fix-atlas-worktree-path-crash
|
||||
git fetch origin dev
|
||||
git rebase origin/dev
|
||||
# Resolve conflicts if any
|
||||
git push --force-with-lease
|
||||
# Re-enter verify loop from Gate A
|
||||
```
|
||||
@@ -1 +0,0 @@
|
||||
{"total_tokens": null, "duration_ms": 506000, "total_duration_seconds": 506}
|
||||
@@ -1,11 +0,0 @@
|
||||
{
|
||||
"run_id": "eval-2-without_skill",
|
||||
"expectations": [
|
||||
{"text": "Plan uses git worktree in a sibling directory", "passed": false, "evidence": "No worktree. Steps go directly to creating branch and modifying files."},
|
||||
{"text": "Fix is minimal — adds null check, doesn't refactor unrelated code", "passed": true, "evidence": "Focused fix though also adds try/catch in setTimeout (reasonable secondary fix)"},
|
||||
{"text": "Test case added for the missing worktree_path scenario", "passed": true, "evidence": "Detailed test plan for missing/null/malformed boulder.json"},
|
||||
{"text": "Verification loop includes all 3 gates", "passed": false, "evidence": "Only mentions CI pipeline (step 5). No review-work or Cubic."},
|
||||
{"text": "References actual atlas hook files", "passed": true, "evidence": "References idle-event.ts, storage.ts with line numbers"},
|
||||
{"text": "Branch name follows fix/ prefix convention", "passed": true, "evidence": "fix/atlas-hook-missing-worktree-path"}
|
||||
]
|
||||
}
|
||||
@@ -1,334 +0,0 @@
|
||||
# Code Changes: Fix Atlas Hook Crash on Missing worktree_path
|
||||
|
||||
## Change 1: Harden `readBoulderState()` validation
|
||||
|
||||
**File:** `src/features/boulder-state/storage.ts`
|
||||
|
||||
### Before (lines 16-36):
|
||||
```typescript
|
||||
export function readBoulderState(directory: string): BoulderState | null {
|
||||
const filePath = getBoulderFilePath(directory)
|
||||
|
||||
if (!existsSync(filePath)) {
|
||||
return null
|
||||
}
|
||||
|
||||
try {
|
||||
const content = readFileSync(filePath, "utf-8")
|
||||
const parsed = JSON.parse(content)
|
||||
if (!parsed || typeof parsed !== "object" || Array.isArray(parsed)) {
|
||||
return null
|
||||
}
|
||||
if (!Array.isArray(parsed.session_ids)) {
|
||||
parsed.session_ids = []
|
||||
}
|
||||
return parsed as BoulderState
|
||||
} catch {
|
||||
return null
|
||||
}
|
||||
}
|
||||
```
|
||||
|
||||
### After:
|
||||
```typescript
|
||||
export function readBoulderState(directory: string): BoulderState | null {
|
||||
const filePath = getBoulderFilePath(directory)
|
||||
|
||||
if (!existsSync(filePath)) {
|
||||
return null
|
||||
}
|
||||
|
||||
try {
|
||||
const content = readFileSync(filePath, "utf-8")
|
||||
const parsed = JSON.parse(content)
|
||||
if (!parsed || typeof parsed !== "object" || Array.isArray(parsed)) {
|
||||
return null
|
||||
}
|
||||
if (typeof parsed.active_plan !== "string" || typeof parsed.plan_name !== "string") {
|
||||
return null
|
||||
}
|
||||
if (!Array.isArray(parsed.session_ids)) {
|
||||
parsed.session_ids = []
|
||||
}
|
||||
if (parsed.worktree_path !== undefined && typeof parsed.worktree_path !== "string") {
|
||||
delete parsed.worktree_path
|
||||
}
|
||||
return parsed as BoulderState
|
||||
} catch {
|
||||
return null
|
||||
}
|
||||
}
|
||||
```
|
||||
|
||||
**Rationale:** Validates that required fields (`active_plan`, `plan_name`) are strings. Strips `worktree_path` if it's present but not a string (e.g., `null`, number). This prevents downstream crashes from `existsSync(undefined)` and ensures type safety at the boundary.
|
||||
|
||||
---
|
||||
|
||||
## Change 2: Add try/catch in setTimeout retry callback
|
||||
|
||||
**File:** `src/hooks/atlas/idle-event.ts`
|
||||
|
||||
### Before (lines 62-88):
|
||||
```typescript
|
||||
sessionState.pendingRetryTimer = setTimeout(async () => {
|
||||
sessionState.pendingRetryTimer = undefined
|
||||
|
||||
if (sessionState.promptFailureCount >= 2) return
|
||||
if (sessionState.waitingForFinalWaveApproval) return
|
||||
|
||||
const currentBoulder = readBoulderState(ctx.directory)
|
||||
if (!currentBoulder) return
|
||||
if (!currentBoulder.session_ids?.includes(sessionID)) return
|
||||
|
||||
const currentProgress = getPlanProgress(currentBoulder.active_plan)
|
||||
if (currentProgress.isComplete) return
|
||||
if (options?.isContinuationStopped?.(sessionID)) return
|
||||
if (options?.shouldSkipContinuation?.(sessionID)) return
|
||||
if (hasRunningBackgroundTasks(sessionID, options)) return
|
||||
|
||||
await injectContinuation({
|
||||
ctx,
|
||||
sessionID,
|
||||
sessionState,
|
||||
options,
|
||||
planName: currentBoulder.plan_name,
|
||||
progress: currentProgress,
|
||||
agent: currentBoulder.agent,
|
||||
worktreePath: currentBoulder.worktree_path,
|
||||
})
|
||||
}, RETRY_DELAY_MS)
|
||||
```
|
||||
|
||||
### After:
|
||||
```typescript
|
||||
sessionState.pendingRetryTimer = setTimeout(async () => {
|
||||
sessionState.pendingRetryTimer = undefined
|
||||
|
||||
try {
|
||||
if (sessionState.promptFailureCount >= 2) return
|
||||
if (sessionState.waitingForFinalWaveApproval) return
|
||||
|
||||
const currentBoulder = readBoulderState(ctx.directory)
|
||||
if (!currentBoulder) return
|
||||
if (!currentBoulder.session_ids?.includes(sessionID)) return
|
||||
|
||||
const currentProgress = getPlanProgress(currentBoulder.active_plan)
|
||||
if (currentProgress.isComplete) return
|
||||
if (options?.isContinuationStopped?.(sessionID)) return
|
||||
if (options?.shouldSkipContinuation?.(sessionID)) return
|
||||
if (hasRunningBackgroundTasks(sessionID, options)) return
|
||||
|
||||
await injectContinuation({
|
||||
ctx,
|
||||
sessionID,
|
||||
sessionState,
|
||||
options,
|
||||
planName: currentBoulder.plan_name,
|
||||
progress: currentProgress,
|
||||
agent: currentBoulder.agent,
|
||||
worktreePath: currentBoulder.worktree_path,
|
||||
})
|
||||
} catch (error) {
|
||||
log(`[${HOOK_NAME}] Retry continuation failed`, { sessionID, error: String(error) })
|
||||
}
|
||||
}, RETRY_DELAY_MS)
|
||||
```
|
||||
|
||||
**Rationale:** The async callback in setTimeout creates a floating promise. Without try/catch, any error becomes an unhandled rejection that can crash the process. This is the critical safety net even after the `readBoulderState` fix.
|
||||
|
||||
---
|
||||
|
||||
## Change 3: Defensive guard in `getPlanProgress`
|
||||
|
||||
**File:** `src/features/boulder-state/storage.ts`
|
||||
|
||||
### Before (lines 115-118):
|
||||
```typescript
|
||||
export function getPlanProgress(planPath: string): PlanProgress {
|
||||
if (!existsSync(planPath)) {
|
||||
return { total: 0, completed: 0, isComplete: true }
|
||||
}
|
||||
```
|
||||
|
||||
### After:
|
||||
```typescript
|
||||
export function getPlanProgress(planPath: string): PlanProgress {
|
||||
if (typeof planPath !== "string" || !existsSync(planPath)) {
|
||||
return { total: 0, completed: 0, isComplete: true }
|
||||
}
|
||||
```
|
||||
|
||||
**Rationale:** Defense-in-depth. Even though `readBoulderState` now validates `active_plan`, the `getPlanProgress` function is a public API that could be called from other paths with invalid input. A `typeof` check before `existsSync` prevents the TypeError from `existsSync(undefined)`.
|
||||
|
||||
---
|
||||
|
||||
## Change 4: New tests
|
||||
|
||||
### File: `src/features/boulder-state/storage.test.ts` (additions)
|
||||
|
||||
```typescript
|
||||
test("should return null when active_plan is missing", () => {
|
||||
// given - boulder.json without active_plan
|
||||
const boulderFile = join(SISYPHUS_DIR, "boulder.json")
|
||||
writeFileSync(boulderFile, JSON.stringify({
|
||||
started_at: "2026-01-01T00:00:00Z",
|
||||
session_ids: ["ses-1"],
|
||||
plan_name: "plan",
|
||||
}))
|
||||
|
||||
// when
|
||||
const result = readBoulderState(TEST_DIR)
|
||||
|
||||
// then
|
||||
expect(result).toBeNull()
|
||||
})
|
||||
|
||||
test("should return null when plan_name is missing", () => {
|
||||
// given - boulder.json without plan_name
|
||||
const boulderFile = join(SISYPHUS_DIR, "boulder.json")
|
||||
writeFileSync(boulderFile, JSON.stringify({
|
||||
active_plan: "/path/to/plan.md",
|
||||
started_at: "2026-01-01T00:00:00Z",
|
||||
session_ids: ["ses-1"],
|
||||
}))
|
||||
|
||||
// when
|
||||
const result = readBoulderState(TEST_DIR)
|
||||
|
||||
// then
|
||||
expect(result).toBeNull()
|
||||
})
|
||||
|
||||
test("should strip non-string worktree_path from boulder state", () => {
|
||||
// given - boulder.json with worktree_path set to null
|
||||
const boulderFile = join(SISYPHUS_DIR, "boulder.json")
|
||||
writeFileSync(boulderFile, JSON.stringify({
|
||||
active_plan: "/path/to/plan.md",
|
||||
started_at: "2026-01-01T00:00:00Z",
|
||||
session_ids: ["ses-1"],
|
||||
plan_name: "plan",
|
||||
worktree_path: null,
|
||||
}))
|
||||
|
||||
// when
|
||||
const result = readBoulderState(TEST_DIR)
|
||||
|
||||
// then
|
||||
expect(result).not.toBeNull()
|
||||
expect(result!.worktree_path).toBeUndefined()
|
||||
})
|
||||
|
||||
test("should preserve valid worktree_path string", () => {
|
||||
// given - boulder.json with valid worktree_path
|
||||
const boulderFile = join(SISYPHUS_DIR, "boulder.json")
|
||||
writeFileSync(boulderFile, JSON.stringify({
|
||||
active_plan: "/path/to/plan.md",
|
||||
started_at: "2026-01-01T00:00:00Z",
|
||||
session_ids: ["ses-1"],
|
||||
plan_name: "plan",
|
||||
worktree_path: "/valid/worktree/path",
|
||||
}))
|
||||
|
||||
// when
|
||||
const result = readBoulderState(TEST_DIR)
|
||||
|
||||
// then
|
||||
expect(result).not.toBeNull()
|
||||
expect(result!.worktree_path).toBe("/valid/worktree/path")
|
||||
})
|
||||
```
|
||||
|
||||
### File: `src/features/boulder-state/storage.test.ts` (getPlanProgress additions)
|
||||
|
||||
```typescript
|
||||
test("should handle undefined planPath without crashing", () => {
|
||||
// given - undefined as planPath (from malformed boulder state)
|
||||
|
||||
// when
|
||||
const progress = getPlanProgress(undefined as unknown as string)
|
||||
|
||||
// then
|
||||
expect(progress.total).toBe(0)
|
||||
expect(progress.isComplete).toBe(true)
|
||||
})
|
||||
```
|
||||
|
||||
### File: `src/hooks/atlas/index.test.ts` (additions to session.idle section)
|
||||
|
||||
```typescript
|
||||
test("should handle boulder state without worktree_path gracefully", async () => {
|
||||
// given - boulder state with incomplete plan, no worktree_path
|
||||
const planPath = join(TEST_DIR, "test-plan.md")
|
||||
writeFileSync(planPath, "# Plan\n- [ ] Task 1\n- [x] Task 2")
|
||||
|
||||
const state: BoulderState = {
|
||||
active_plan: planPath,
|
||||
started_at: "2026-01-02T10:00:00Z",
|
||||
session_ids: [MAIN_SESSION_ID],
|
||||
plan_name: "test-plan",
|
||||
// worktree_path intentionally omitted
|
||||
}
|
||||
writeBoulderState(TEST_DIR, state)
|
||||
|
||||
const mockInput = createMockPluginInput()
|
||||
const hook = createAtlasHook(mockInput)
|
||||
|
||||
// when
|
||||
await hook.handler({
|
||||
event: {
|
||||
type: "session.idle",
|
||||
properties: { sessionID: MAIN_SESSION_ID },
|
||||
},
|
||||
})
|
||||
|
||||
// then - should call prompt without crashing, continuation should not contain worktree context
|
||||
expect(mockInput._promptMock).toHaveBeenCalled()
|
||||
const callArgs = mockInput._promptMock.mock.calls[0][0]
|
||||
expect(callArgs.body.parts[0].text).toContain("incomplete tasks")
|
||||
expect(callArgs.body.parts[0].text).not.toContain("[Worktree:")
|
||||
})
|
||||
|
||||
test("should include worktree context when worktree_path is present in boulder state", async () => {
|
||||
// given - boulder state with worktree_path
|
||||
const planPath = join(TEST_DIR, "test-plan.md")
|
||||
writeFileSync(planPath, "# Plan\n- [ ] Task 1")
|
||||
|
||||
const state: BoulderState = {
|
||||
active_plan: planPath,
|
||||
started_at: "2026-01-02T10:00:00Z",
|
||||
session_ids: [MAIN_SESSION_ID],
|
||||
plan_name: "test-plan",
|
||||
worktree_path: "/some/worktree/path",
|
||||
}
|
||||
writeBoulderState(TEST_DIR, state)
|
||||
|
||||
const mockInput = createMockPluginInput()
|
||||
const hook = createAtlasHook(mockInput)
|
||||
|
||||
// when
|
||||
await hook.handler({
|
||||
event: {
|
||||
type: "session.idle",
|
||||
properties: { sessionID: MAIN_SESSION_ID },
|
||||
},
|
||||
})
|
||||
|
||||
// then - should include worktree context in continuation prompt
|
||||
expect(mockInput._promptMock).toHaveBeenCalled()
|
||||
const callArgs = mockInput._promptMock.mock.calls[0][0]
|
||||
expect(callArgs.body.parts[0].text).toContain("[Worktree: /some/worktree/path]")
|
||||
})
|
||||
```
|
||||
|
||||
---
|
||||
|
||||
## Summary of Changes
|
||||
|
||||
| File | Change | Lines Modified |
|
||||
|------|--------|---------------|
|
||||
| `src/features/boulder-state/storage.ts` | Validate required fields + sanitize worktree_path + guard getPlanProgress | ~8 lines added |
|
||||
| `src/hooks/atlas/idle-event.ts` | try/catch around setTimeout async callback | ~4 lines added |
|
||||
| `src/features/boulder-state/storage.test.ts` | 5 new tests for validation | ~60 lines added |
|
||||
| `src/hooks/atlas/index.test.ts` | 2 new tests for worktree_path handling | ~50 lines added |
|
||||
|
||||
Total: ~4 production lines changed, ~8 defensive lines added, ~110 test lines added.
|
||||
@@ -1,86 +0,0 @@
|
||||
# Execution Plan: Fix Atlas Hook Crash on Missing worktree_path
|
||||
|
||||
## Bug Analysis
|
||||
|
||||
### Root Cause
|
||||
|
||||
`readBoulderState()` in `src/features/boulder-state/storage.ts` performs minimal validation when parsing `boulder.json`:
|
||||
|
||||
```typescript
|
||||
const parsed = JSON.parse(content)
|
||||
if (!parsed || typeof parsed !== "object" || Array.isArray(parsed)) return null
|
||||
if (!Array.isArray(parsed.session_ids)) parsed.session_ids = []
|
||||
return parsed as BoulderState // <-- unsafe cast, no field validation
|
||||
```
|
||||
|
||||
It validates `session_ids` but NOT `active_plan`, `plan_name`, or `worktree_path`. This means a malformed `boulder.json` (e.g., `{}` or missing key fields) passes through and downstream code crashes.
|
||||
|
||||
### Crash Path
|
||||
|
||||
1. `boulder.json` is written without required fields (manual edit, corruption, partial write)
|
||||
2. `readBoulderState()` returns it as `BoulderState` with `active_plan: undefined`
|
||||
3. Multiple call sites pass `boulderState.active_plan` to `getPlanProgress(planPath: string)`:
|
||||
- `src/hooks/atlas/idle-event.ts:72` (inside `setTimeout` callback - unhandled rejection!)
|
||||
- `src/hooks/atlas/resolve-active-boulder-session.ts:21`
|
||||
- `src/hooks/atlas/tool-execute-after.ts:74`
|
||||
4. `getPlanProgress()` calls `existsSync(undefined)` which throws: `TypeError: The "path" argument must be of type string`
|
||||
|
||||
### worktree_path-Specific Issues
|
||||
|
||||
When `worktree_path` field is missing from `boulder.json`:
|
||||
- The `idle-event.ts` `scheduleRetry` setTimeout callback (lines 62-88) has NO try/catch. An unhandled promise rejection from the async callback crashes the process.
|
||||
- `readBoulderState()` returns `worktree_path: undefined` which itself is handled in `boulder-continuation-injector.ts` (line 42 uses truthiness check), but the surrounding code in the setTimeout lacks error protection.
|
||||
|
||||
### Secondary Issue: Unhandled Promise in setTimeout
|
||||
|
||||
In `idle-event.ts` lines 62-88:
|
||||
```typescript
|
||||
sessionState.pendingRetryTimer = setTimeout(async () => {
|
||||
// ... no try/catch wrapper
|
||||
const currentBoulder = readBoulderState(ctx.directory)
|
||||
const currentProgress = getPlanProgress(currentBoulder.active_plan) // CRASH if active_plan undefined
|
||||
// ...
|
||||
}, RETRY_DELAY_MS)
|
||||
```
|
||||
|
||||
The async callback creates a floating promise. Any thrown error becomes an unhandled rejection.
|
||||
|
||||
---
|
||||
|
||||
## Step-by-Step Plan
|
||||
|
||||
### Step 1: Harden `readBoulderState()` validation
|
||||
**File:** `src/features/boulder-state/storage.ts`
|
||||
|
||||
- After the `session_ids` fix, add validation for `active_plan` and `plan_name` (required fields)
|
||||
- Validate `worktree_path` is either `undefined` or a string (not `null`, not a number)
|
||||
- Return `null` for boulder states with missing required fields
|
||||
|
||||
### Step 2: Add try/catch in setTimeout callback
|
||||
**File:** `src/hooks/atlas/idle-event.ts`
|
||||
|
||||
- Wrap the `setTimeout` async callback body in try/catch
|
||||
- Log errors with the atlas hook logger
|
||||
|
||||
### Step 3: Add defensive guard in `getPlanProgress`
|
||||
**File:** `src/features/boulder-state/storage.ts`
|
||||
|
||||
- Add early return for non-string `planPath` argument
|
||||
|
||||
### Step 4: Add tests
|
||||
**Files:**
|
||||
- `src/features/boulder-state/storage.test.ts` - test missing/malformed fields
|
||||
- `src/hooks/atlas/index.test.ts` - test atlas hook with boulder missing worktree_path
|
||||
|
||||
### Step 5: Run CI checks
|
||||
```bash
|
||||
bun run typecheck
|
||||
bun test src/features/boulder-state/storage.test.ts
|
||||
bun test src/hooks/atlas/index.test.ts
|
||||
bun test # full suite
|
||||
```
|
||||
|
||||
### Step 6: Create PR
|
||||
- Branch: `fix/atlas-hook-missing-worktree-path`
|
||||
- Target: `dev`
|
||||
- Run CI and verify passes
|
||||
@@ -1,23 +0,0 @@
|
||||
## Summary
|
||||
|
||||
- Fix crash in atlas hook when `boulder.json` is missing `worktree_path` (or other required fields) by hardening `readBoulderState()` validation
|
||||
- Wrap the unprotected `setTimeout` retry callback in `idle-event.ts` with try/catch to prevent unhandled promise rejections
|
||||
- Add defensive type guard in `getPlanProgress()` to prevent `existsSync(undefined)` TypeError
|
||||
|
||||
## Context
|
||||
|
||||
When `boulder.json` is malformed or manually edited to omit fields, `readBoulderState()` returns an object cast as `BoulderState` without validating required fields. Downstream callers like `getPlanProgress(boulderState.active_plan)` then pass `undefined` to `existsSync()`, which throws a TypeError. This crash is especially dangerous in the `setTimeout` retry callback in `idle-event.ts`, where the error becomes an unhandled promise rejection.
|
||||
|
||||
## Changes
|
||||
|
||||
### `src/features/boulder-state/storage.ts`
|
||||
- `readBoulderState()`: Validate `active_plan` and `plan_name` are strings (return `null` if not)
|
||||
- `readBoulderState()`: Strip `worktree_path` if present but not a string type
|
||||
- `getPlanProgress()`: Add `typeof planPath !== "string"` guard before `existsSync`
|
||||
|
||||
### `src/hooks/atlas/idle-event.ts`
|
||||
- Wrap `scheduleRetry` setTimeout async callback body in try/catch
|
||||
|
||||
### Tests
|
||||
- `src/features/boulder-state/storage.test.ts`: 5 new tests for missing/malformed fields
|
||||
- `src/hooks/atlas/index.test.ts`: 2 new tests for worktree_path presence/absence in continuation prompt
|
||||
@@ -1,119 +0,0 @@
|
||||
# Verification Strategy
|
||||
|
||||
## 1. Unit Tests (Direct Verification)
|
||||
|
||||
### boulder-state storage tests
|
||||
```bash
|
||||
bun test src/features/boulder-state/storage.test.ts
|
||||
```
|
||||
|
||||
Verify:
|
||||
- `readBoulderState()` returns `null` when `active_plan` missing
|
||||
- `readBoulderState()` returns `null` when `plan_name` missing
|
||||
- `readBoulderState()` strips non-string `worktree_path` (e.g., `null`)
|
||||
- `readBoulderState()` preserves valid string `worktree_path`
|
||||
- `getPlanProgress(undefined)` returns safe default without crashing
|
||||
- Existing tests still pass (session_ids defaults, empty object, etc.)
|
||||
|
||||
### atlas hook tests
|
||||
```bash
|
||||
bun test src/hooks/atlas/index.test.ts
|
||||
```
|
||||
|
||||
Verify:
|
||||
- session.idle handler works with boulder state missing `worktree_path` (no crash, prompt injected)
|
||||
- session.idle handler includes `[Worktree: ...]` context when `worktree_path` IS present
|
||||
- All 30+ existing tests still pass
|
||||
|
||||
### atlas idle-event lineage tests
|
||||
```bash
|
||||
bun test src/hooks/atlas/idle-event-lineage.test.ts
|
||||
```
|
||||
|
||||
Verify existing lineage tests unaffected.
|
||||
|
||||
### start-work hook tests
|
||||
```bash
|
||||
bun test src/hooks/start-work/index.test.ts
|
||||
```
|
||||
|
||||
Verify worktree-related start-work tests still pass (these create boulder states with/without `worktree_path`).
|
||||
|
||||
## 2. Type Safety
|
||||
|
||||
```bash
|
||||
bun run typecheck
|
||||
```
|
||||
|
||||
Verify zero new TypeScript errors. The changes are purely additive runtime guards that align with existing types (`worktree_path?: string`).
|
||||
|
||||
## 3. LSP Diagnostics on Changed Files
|
||||
|
||||
```
|
||||
lsp_diagnostics on:
|
||||
- src/features/boulder-state/storage.ts
|
||||
- src/hooks/atlas/idle-event.ts
|
||||
```
|
||||
|
||||
Verify zero errors/warnings.
|
||||
|
||||
## 4. Full Test Suite
|
||||
|
||||
```bash
|
||||
bun test
|
||||
```
|
||||
|
||||
Verify no regressions across the entire codebase.
|
||||
|
||||
## 5. Build
|
||||
|
||||
```bash
|
||||
bun run build
|
||||
```
|
||||
|
||||
Verify build succeeds.
|
||||
|
||||
## 6. Manual Smoke Test (Reproduction)
|
||||
|
||||
To manually verify the fix:
|
||||
|
||||
```bash
|
||||
# Create a malformed boulder.json (missing worktree_path)
|
||||
mkdir -p .sisyphus
|
||||
echo '{"active_plan": ".sisyphus/plans/test.md", "plan_name": "test", "session_ids": ["ses-1"]}' > .sisyphus/boulder.json
|
||||
|
||||
# Create a plan file
|
||||
mkdir -p .sisyphus/plans
|
||||
echo '# Plan\n- [ ] Task 1' > .sisyphus/plans/test.md
|
||||
|
||||
# Start opencode - atlas hook should NOT crash when session.idle fires
|
||||
# Verify /tmp/oh-my-opencode.log shows normal continuation behavior
|
||||
```
|
||||
|
||||
Also test the extreme case:
|
||||
```bash
|
||||
# boulder.json with no required fields
|
||||
echo '{}' > .sisyphus/boulder.json
|
||||
|
||||
# After fix: readBoulderState returns null, atlas hook gracefully skips
|
||||
```
|
||||
|
||||
## 7. CI Pipeline
|
||||
|
||||
After pushing the branch, verify:
|
||||
- `ci.yml` workflow passes: tests (split: mock-heavy isolated + batch), typecheck, build
|
||||
- No new lint warnings
|
||||
|
||||
## 8. Edge Cases Covered
|
||||
|
||||
| Scenario | Expected Behavior |
|
||||
|----------|-------------------|
|
||||
| `boulder.json` = `{}` | `readBoulderState` returns `null` |
|
||||
| `boulder.json` missing `active_plan` | `readBoulderState` returns `null` |
|
||||
| `boulder.json` missing `plan_name` | `readBoulderState` returns `null` |
|
||||
| `boulder.json` has `worktree_path: null` | Field stripped, returned as `undefined` |
|
||||
| `boulder.json` has `worktree_path: 42` | Field stripped, returned as `undefined` |
|
||||
| `boulder.json` has no `worktree_path` | Works normally, no crash |
|
||||
| `boulder.json` has valid `worktree_path` | Preserved, included in continuation prompt |
|
||||
| setTimeout retry with corrupted boulder.json | Error caught and logged, no process crash |
|
||||
| `getPlanProgress(undefined)` | Returns `{ total: 0, completed: 0, isComplete: true }` |
|
||||
@@ -1 +0,0 @@
|
||||
{"total_tokens": null, "duration_ms": 325000, "total_duration_seconds": 325}
|
||||
@@ -1,32 +0,0 @@
|
||||
{
|
||||
"eval_id": 3,
|
||||
"eval_name": "refactor-split-constants",
|
||||
"prompt": "Refactor src/tools/delegate-task/constants.ts to split DEFAULT_CATEGORIES and CATEGORY_MODEL_REQUIREMENTS into separate files. Keep backward compatibility with the barrel export. Make a PR.",
|
||||
"assertions": [
|
||||
{
|
||||
"id": "worktree-isolation",
|
||||
"text": "Plan uses git worktree in a sibling directory",
|
||||
"type": "manual"
|
||||
},
|
||||
{
|
||||
"id": "multiple-atomic-commits",
|
||||
"text": "Uses 2+ commits for the multi-file refactor",
|
||||
"type": "manual"
|
||||
},
|
||||
{
|
||||
"id": "barrel-export",
|
||||
"text": "Maintains backward compatibility via barrel re-export in constants.ts or index.ts",
|
||||
"type": "manual"
|
||||
},
|
||||
{
|
||||
"id": "three-gates",
|
||||
"text": "Verification loop includes all 3 gates",
|
||||
"type": "manual"
|
||||
},
|
||||
{
|
||||
"id": "real-constants-file",
|
||||
"text": "References actual src/tools/delegate-task/constants.ts file and its exports",
|
||||
"type": "manual"
|
||||
}
|
||||
]
|
||||
}
|
||||
@@ -1,10 +0,0 @@
|
||||
{
|
||||
"run_id": "eval-3-with_skill",
|
||||
"expectations": [
|
||||
{"text": "Plan uses git worktree in a sibling directory", "passed": true, "evidence": "../omo-wt/refactor-delegate-task-constants"},
|
||||
{"text": "Uses 2+ commits for the multi-file refactor", "passed": true, "evidence": "Commit 1: category defaults+appends, Commit 2: plan agent prompt+names"},
|
||||
{"text": "Maintains backward compatibility via barrel re-export", "passed": true, "evidence": "constants.ts converted to re-export from 4 new files, full import map verified"},
|
||||
{"text": "Verification loop includes all 3 gates", "passed": true, "evidence": "Gate A (CI), Gate B (review-work), Gate C (Cubic)"},
|
||||
{"text": "References actual src/tools/delegate-task/constants.ts", "passed": true, "evidence": "654 lines analyzed, 4 responsibilities identified, full external+internal import map"}
|
||||
]
|
||||
}
|
||||
@@ -1,221 +0,0 @@
|
||||
# Code Changes
|
||||
|
||||
## New File: `src/tools/delegate-task/default-categories.ts`
|
||||
|
||||
```typescript
|
||||
import type { CategoryConfig } from "../../config/schema"
|
||||
|
||||
export const DEFAULT_CATEGORIES: Record<string, CategoryConfig> = {
|
||||
"visual-engineering": { model: "google/gemini-3.1-pro", variant: "high" },
|
||||
ultrabrain: { model: "openai/gpt-5.4", variant: "xhigh" },
|
||||
deep: { model: "openai/gpt-5.3-codex", variant: "medium" },
|
||||
artistry: { model: "google/gemini-3.1-pro", variant: "high" },
|
||||
quick: { model: "anthropic/claude-haiku-4-5" },
|
||||
"unspecified-low": { model: "anthropic/claude-sonnet-4-6" },
|
||||
"unspecified-high": { model: "anthropic/claude-opus-4-6", variant: "max" },
|
||||
writing: { model: "kimi-for-coding/k2p5" },
|
||||
}
|
||||
|
||||
export const CATEGORY_DESCRIPTIONS: Record<string, string> = {
|
||||
"visual-engineering": "Frontend, UI/UX, design, styling, animation",
|
||||
ultrabrain: "Use ONLY for genuinely hard, logic-heavy tasks. Give clear goals only, not step-by-step instructions.",
|
||||
deep: "Goal-oriented autonomous problem-solving. Thorough research before action. For hairy problems requiring deep understanding.",
|
||||
artistry: "Complex problem-solving with unconventional, creative approaches - beyond standard patterns",
|
||||
quick: "Trivial tasks - single file changes, typo fixes, simple modifications",
|
||||
"unspecified-low": "Tasks that don't fit other categories, low effort required",
|
||||
"unspecified-high": "Tasks that don't fit other categories, high effort required",
|
||||
writing: "Documentation, prose, technical writing",
|
||||
}
|
||||
```
|
||||
|
||||
## New File: `src/tools/delegate-task/category-prompt-appends.ts`
|
||||
|
||||
```typescript
|
||||
export const VISUAL_CATEGORY_PROMPT_APPEND = `<Category_Context>
|
||||
You are working on VISUAL/UI tasks.
|
||||
...
|
||||
</Category_Context>`
|
||||
// (exact content from lines 8-95 of constants.ts)
|
||||
|
||||
export const ULTRABRAIN_CATEGORY_PROMPT_APPEND = `<Category_Context>
|
||||
...
|
||||
</Category_Context>`
|
||||
// (exact content from lines 97-117)
|
||||
|
||||
export const ARTISTRY_CATEGORY_PROMPT_APPEND = `<Category_Context>
|
||||
...
|
||||
</Category_Context>`
|
||||
// (exact content from lines 119-134)
|
||||
|
||||
export const QUICK_CATEGORY_PROMPT_APPEND = `<Category_Context>
|
||||
...
|
||||
</Caller_Warning>`
|
||||
// (exact content from lines 136-186)
|
||||
|
||||
export const UNSPECIFIED_LOW_CATEGORY_PROMPT_APPEND = `<Category_Context>
|
||||
...
|
||||
</Caller_Warning>`
|
||||
// (exact content from lines 188-209)
|
||||
|
||||
export const UNSPECIFIED_HIGH_CATEGORY_PROMPT_APPEND = `<Category_Context>
|
||||
...
|
||||
</Category_Context>`
|
||||
// (exact content from lines 211-224)
|
||||
|
||||
export const WRITING_CATEGORY_PROMPT_APPEND = `<Category_Context>
|
||||
...
|
||||
</Category_Context>`
|
||||
// (exact content from lines 226-250)
|
||||
|
||||
export const DEEP_CATEGORY_PROMPT_APPEND = `<Category_Context>
|
||||
...
|
||||
</Category_Context>`
|
||||
// (exact content from lines 252-281)
|
||||
|
||||
export const CATEGORY_PROMPT_APPENDS: Record<string, string> = {
|
||||
"visual-engineering": VISUAL_CATEGORY_PROMPT_APPEND,
|
||||
ultrabrain: ULTRABRAIN_CATEGORY_PROMPT_APPEND,
|
||||
deep: DEEP_CATEGORY_PROMPT_APPEND,
|
||||
artistry: ARTISTRY_CATEGORY_PROMPT_APPEND,
|
||||
quick: QUICK_CATEGORY_PROMPT_APPEND,
|
||||
"unspecified-low": UNSPECIFIED_LOW_CATEGORY_PROMPT_APPEND,
|
||||
"unspecified-high": UNSPECIFIED_HIGH_CATEGORY_PROMPT_APPEND,
|
||||
writing: WRITING_CATEGORY_PROMPT_APPEND,
|
||||
}
|
||||
```
|
||||
|
||||
## New File: `src/tools/delegate-task/plan-agent-prompt.ts`
|
||||
|
||||
```typescript
|
||||
import type {
|
||||
AvailableCategory,
|
||||
AvailableSkill,
|
||||
} from "../../agents/dynamic-agent-prompt-builder"
|
||||
import { truncateDescription } from "../../shared/truncate-description"
|
||||
|
||||
/**
|
||||
* System prompt prepended to plan agent invocations.
|
||||
* Instructs the plan agent to first gather context via explore/librarian agents,
|
||||
* then summarize user requirements and clarify uncertainties before proceeding.
|
||||
* Also MANDATES dependency graphs, parallel execution analysis, and category+skill recommendations.
|
||||
*/
|
||||
export const PLAN_AGENT_SYSTEM_PREPEND_STATIC_BEFORE_SKILLS = `<system>
|
||||
...
|
||||
</CRITICAL_REQUIREMENT_DEPENDENCY_PARALLEL_EXECUTION_CATEGORY_SKILLS>
|
||||
`
|
||||
// (exact content from lines 324-430)
|
||||
|
||||
export const PLAN_AGENT_SYSTEM_PREPEND_STATIC_AFTER_SKILLS = `### REQUIRED OUTPUT FORMAT
|
||||
...
|
||||
`
|
||||
// (exact content from lines 432-569)
|
||||
|
||||
function renderPlanAgentCategoryRows(categories: AvailableCategory[]): string[] {
|
||||
const sorted = [...categories].sort((a, b) => a.name.localeCompare(b.name))
|
||||
return sorted.map((category) => {
|
||||
const bestFor = category.description || category.name
|
||||
const model = category.model || ""
|
||||
return `| \`${category.name}\` | ${bestFor} | ${model} |`
|
||||
})
|
||||
}
|
||||
|
||||
function renderPlanAgentSkillRows(skills: AvailableSkill[]): string[] {
|
||||
const sorted = [...skills].sort((a, b) => a.name.localeCompare(b.name))
|
||||
return sorted.map((skill) => {
|
||||
const domain = truncateDescription(skill.description).trim() || skill.name
|
||||
return `| \`${skill.name}\` | ${domain} |`
|
||||
})
|
||||
}
|
||||
|
||||
export function buildPlanAgentSkillsSection(
|
||||
categories: AvailableCategory[] = [],
|
||||
skills: AvailableSkill[] = []
|
||||
): string {
|
||||
const categoryRows = renderPlanAgentCategoryRows(categories)
|
||||
const skillRows = renderPlanAgentSkillRows(skills)
|
||||
|
||||
return `### AVAILABLE CATEGORIES
|
||||
|
||||
| Category | Best For | Model |
|
||||
|----------|----------|-------|
|
||||
${categoryRows.join("\n")}
|
||||
|
||||
### AVAILABLE SKILLS (ALWAYS EVALUATE ALL)
|
||||
|
||||
Skills inject specialized expertise into the delegated agent.
|
||||
YOU MUST evaluate EVERY skill and justify inclusions/omissions.
|
||||
|
||||
| Skill | Domain |
|
||||
|-------|--------|
|
||||
${skillRows.join("\n")}`
|
||||
}
|
||||
|
||||
export function buildPlanAgentSystemPrepend(
|
||||
categories: AvailableCategory[] = [],
|
||||
skills: AvailableSkill[] = []
|
||||
): string {
|
||||
return [
|
||||
PLAN_AGENT_SYSTEM_PREPEND_STATIC_BEFORE_SKILLS,
|
||||
buildPlanAgentSkillsSection(categories, skills),
|
||||
PLAN_AGENT_SYSTEM_PREPEND_STATIC_AFTER_SKILLS,
|
||||
].join("\n\n")
|
||||
}
|
||||
```
|
||||
|
||||
## New File: `src/tools/delegate-task/plan-agent-names.ts`
|
||||
|
||||
```typescript
|
||||
/**
|
||||
* List of agent names that should be treated as plan agents (receive plan system prompt).
|
||||
* Case-insensitive matching is used.
|
||||
*/
|
||||
export const PLAN_AGENT_NAMES = ["plan"]
|
||||
|
||||
/**
|
||||
* Check if the given agent name is a plan agent (receives plan system prompt).
|
||||
*/
|
||||
export function isPlanAgent(agentName: string | undefined): boolean {
|
||||
if (!agentName) return false
|
||||
const lowerName = agentName.toLowerCase().trim()
|
||||
return PLAN_AGENT_NAMES.some(name => lowerName === name || lowerName.includes(name))
|
||||
}
|
||||
|
||||
/**
|
||||
* Plan family: plan + prometheus. Shares mutual delegation blocking and task tool permission.
|
||||
* Does NOT share system prompt (only isPlanAgent controls that).
|
||||
*/
|
||||
export const PLAN_FAMILY_NAMES = ["plan", "prometheus"]
|
||||
|
||||
/**
|
||||
* Check if the given agent belongs to the plan family (blocking + task permission).
|
||||
*/
|
||||
export function isPlanFamily(category: string): boolean
|
||||
export function isPlanFamily(category: string | undefined): boolean
|
||||
export function isPlanFamily(category: string | undefined): boolean {
|
||||
if (!category) return false
|
||||
const lowerCategory = category.toLowerCase().trim()
|
||||
return PLAN_FAMILY_NAMES.some(
|
||||
(name) => lowerCategory === name || lowerCategory.includes(name)
|
||||
)
|
||||
}
|
||||
```
|
||||
|
||||
## Modified File: `src/tools/delegate-task/constants.ts`
|
||||
|
||||
```typescript
|
||||
export * from "./default-categories"
|
||||
export * from "./category-prompt-appends"
|
||||
export * from "./plan-agent-prompt"
|
||||
export * from "./plan-agent-names"
|
||||
```
|
||||
|
||||
## Unchanged: `src/tools/delegate-task/index.ts`
|
||||
|
||||
```typescript
|
||||
export { createDelegateTask, resolveCategoryConfig, buildSystemContent, buildTaskPrompt } from "./tools"
|
||||
export type { DelegateTaskToolOptions, SyncSessionCreatedEvent, BuildSystemContentInput } from "./tools"
|
||||
export type * from "./types"
|
||||
export * from "./constants"
|
||||
```
|
||||
|
||||
No changes needed. `export * from "./constants"` transitively re-exports everything from the 4 new files.
|
||||
@@ -1,104 +0,0 @@
|
||||
# Execution Plan: Split delegate-task/constants.ts
|
||||
|
||||
## Phase 0: Setup
|
||||
|
||||
```bash
|
||||
git fetch origin dev
|
||||
git worktree add ../omo-wt/refactor-delegate-task-constants origin/dev -b refactor/split-delegate-task-constants
|
||||
cd ../omo-wt/refactor-delegate-task-constants
|
||||
```
|
||||
|
||||
## Phase 1: Implement
|
||||
|
||||
### Analysis
|
||||
|
||||
`src/tools/delegate-task/constants.ts` is 654 lines with 4 distinct responsibilities:
|
||||
|
||||
1. **Category defaults** (lines 285-316): `DEFAULT_CATEGORIES`, `CATEGORY_DESCRIPTIONS`
|
||||
2. **Category prompt appends** (lines 8-305): 8 `*_CATEGORY_PROMPT_APPEND` string constants + `CATEGORY_PROMPT_APPENDS` record
|
||||
3. **Plan agent prompts** (lines 318-620): `PLAN_AGENT_SYSTEM_PREPEND_*`, builder functions
|
||||
4. **Plan agent names** (lines 626-654): `PLAN_AGENT_NAMES`, `isPlanAgent`, `PLAN_FAMILY_NAMES`, `isPlanFamily`
|
||||
|
||||
Note: `CATEGORY_MODEL_REQUIREMENTS` is already in `src/shared/model-requirements.ts`. No move needed.
|
||||
|
||||
### New Files
|
||||
|
||||
| File | Responsibility | ~LOC |
|
||||
|------|---------------|------|
|
||||
| `default-categories.ts` | `DEFAULT_CATEGORIES`, `CATEGORY_DESCRIPTIONS` | ~40 |
|
||||
| `category-prompt-appends.ts` | 8 prompt append constants + `CATEGORY_PROMPT_APPENDS` record | ~300 (exempt: prompt text) |
|
||||
| `plan-agent-prompt.ts` | Plan agent system prompt constants + builder functions | ~250 (exempt: prompt text) |
|
||||
| `plan-agent-names.ts` | `PLAN_AGENT_NAMES`, `isPlanAgent`, `PLAN_FAMILY_NAMES`, `isPlanFamily` | ~30 |
|
||||
| `constants.ts` (updated) | Re-exports from all 4 files (backward compat) | ~5 |
|
||||
|
||||
### Commit 1: Extract category defaults and prompt appends
|
||||
|
||||
**Files changed**: 3 new + 1 modified
|
||||
- Create `src/tools/delegate-task/default-categories.ts`
|
||||
- Create `src/tools/delegate-task/category-prompt-appends.ts`
|
||||
- Modify `src/tools/delegate-task/constants.ts` (remove extracted code, add re-exports)
|
||||
|
||||
### Commit 2: Extract plan agent prompt and names
|
||||
|
||||
**Files changed**: 2 new + 1 modified
|
||||
- Create `src/tools/delegate-task/plan-agent-prompt.ts`
|
||||
- Create `src/tools/delegate-task/plan-agent-names.ts`
|
||||
- Modify `src/tools/delegate-task/constants.ts` (final: re-exports only)
|
||||
|
||||
### Local Validation
|
||||
|
||||
```bash
|
||||
bun run typecheck
|
||||
bun test src/tools/delegate-task/
|
||||
bun run build
|
||||
```
|
||||
|
||||
## Phase 2: PR Creation
|
||||
|
||||
```bash
|
||||
git push -u origin refactor/split-delegate-task-constants
|
||||
gh pr create --base dev --title "refactor(delegate-task): split constants.ts into focused modules" --body-file /tmp/pr-body.md
|
||||
```
|
||||
|
||||
## Phase 3: Verify Loop
|
||||
|
||||
- **Gate A**: `gh pr checks --watch`
|
||||
- **Gate B**: `/review-work` (5-agent review)
|
||||
- **Gate C**: Wait for cubic-dev-ai[bot] "No issues found"
|
||||
|
||||
## Phase 4: Merge
|
||||
|
||||
```bash
|
||||
gh pr merge --squash --delete-branch
|
||||
git worktree remove ../omo-wt/refactor-delegate-task-constants
|
||||
```
|
||||
|
||||
## Import Update Strategy
|
||||
|
||||
No import updates needed. Backward compatibility preserved through:
|
||||
1. `constants.ts` re-exports everything from the 4 new files
|
||||
2. `index.ts` already does `export * from "./constants"` (unchanged)
|
||||
3. All external consumers import from `"../tools/delegate-task/constants"` or `"./constants"` -- both still work
|
||||
|
||||
### External Import Map (Verified -- NO CHANGES NEEDED)
|
||||
|
||||
| Consumer | Imports | Source Path |
|
||||
|----------|---------|-------------|
|
||||
| `src/agents/atlas/prompt-section-builder.ts` | `CATEGORY_DESCRIPTIONS` | `../../tools/delegate-task/constants` |
|
||||
| `src/agents/builtin-agents.ts` | `CATEGORY_DESCRIPTIONS` | `../tools/delegate-task/constants` |
|
||||
| `src/plugin/available-categories.ts` | `CATEGORY_DESCRIPTIONS` | `../tools/delegate-task/constants` |
|
||||
| `src/plugin-handlers/category-config-resolver.ts` | `DEFAULT_CATEGORIES` | `../tools/delegate-task/constants` |
|
||||
| `src/shared/merge-categories.ts` | `DEFAULT_CATEGORIES` | `../tools/delegate-task/constants` |
|
||||
| `src/shared/merge-categories.test.ts` | `DEFAULT_CATEGORIES` | `../tools/delegate-task/constants` |
|
||||
|
||||
### Internal Import Map (Within delegate-task/ -- NO CHANGES NEEDED)
|
||||
|
||||
| Consumer | Imports |
|
||||
|----------|---------|
|
||||
| `categories.ts` | `DEFAULT_CATEGORIES`, `CATEGORY_PROMPT_APPENDS` |
|
||||
| `tools.ts` | `CATEGORY_DESCRIPTIONS` |
|
||||
| `prompt-builder.ts` | `buildPlanAgentSystemPrepend`, `isPlanAgent` |
|
||||
| `subagent-resolver.ts` | `isPlanFamily` |
|
||||
| `sync-continuation.ts` | `isPlanFamily` |
|
||||
| `sync-prompt-sender.ts` | `isPlanFamily` |
|
||||
| `tools.test.ts` | `DEFAULT_CATEGORIES`, `CATEGORY_PROMPT_APPENDS`, `CATEGORY_DESCRIPTIONS`, `isPlanAgent`, `PLAN_AGENT_NAMES`, `isPlanFamily`, `PLAN_FAMILY_NAMES` |
|
||||
@@ -1,41 +0,0 @@
|
||||
# PR Title
|
||||
|
||||
```
|
||||
refactor(delegate-task): split constants.ts into focused modules
|
||||
```
|
||||
|
||||
# PR Body
|
||||
|
||||
## Summary
|
||||
|
||||
- Split the 654-line `src/tools/delegate-task/constants.ts` into 4 single-responsibility modules: `default-categories.ts`, `category-prompt-appends.ts`, `plan-agent-prompt.ts`, `plan-agent-names.ts`
|
||||
- `constants.ts` becomes a pure re-export barrel, preserving all existing import paths (`from "./constants"` and `from "./delegate-task"`)
|
||||
- Zero import changes across the codebase (6 external + 7 internal consumers verified)
|
||||
|
||||
## Motivation
|
||||
|
||||
`constants.ts` at 654 lines violates the project's 200 LOC soft limit (`modular-code-enforcement.md` rule) and bundles 4 unrelated responsibilities: category model configs, category prompt text, plan agent prompts, and plan agent name utilities.
|
||||
|
||||
## Changes
|
||||
|
||||
| New File | Responsibility | LOC |
|
||||
|----------|---------------|-----|
|
||||
| `default-categories.ts` | `DEFAULT_CATEGORIES`, `CATEGORY_DESCRIPTIONS` | ~25 |
|
||||
| `category-prompt-appends.ts` | 8 `*_PROMPT_APPEND` constants + `CATEGORY_PROMPT_APPENDS` record | ~300 (prompt-exempt) |
|
||||
| `plan-agent-prompt.ts` | Plan system prompt constants + `buildPlanAgentSystemPrepend()` | ~250 (prompt-exempt) |
|
||||
| `plan-agent-names.ts` | `PLAN_AGENT_NAMES`, `isPlanAgent`, `PLAN_FAMILY_NAMES`, `isPlanFamily` | ~30 |
|
||||
| `constants.ts` (updated) | 4-line re-export barrel | 4 |
|
||||
|
||||
## Backward Compatibility
|
||||
|
||||
All 13 consumers continue importing from `"./constants"` or `"../tools/delegate-task/constants"` with zero changes. The re-export chain: new modules -> `constants.ts` -> `index.ts` -> external consumers.
|
||||
|
||||
## Note on CATEGORY_MODEL_REQUIREMENTS
|
||||
|
||||
`CATEGORY_MODEL_REQUIREMENTS` already lives in `src/shared/model-requirements.ts`. No move needed. The AGENTS.md reference to it being in `constants.ts` is outdated.
|
||||
|
||||
## Testing
|
||||
|
||||
- `bun run typecheck` passes
|
||||
- `bun test src/tools/delegate-task/` passes (all existing tests untouched)
|
||||
- `bun run build` succeeds
|
||||
@@ -1,84 +0,0 @@
|
||||
# Verification Strategy
|
||||
|
||||
## Gate A: CI (Blocking)
|
||||
|
||||
```bash
|
||||
gh pr checks --watch
|
||||
```
|
||||
|
||||
**Expected CI jobs** (from `ci.yml`):
|
||||
1. **Tests (split)**: mock-heavy isolated + batch `bun test`
|
||||
2. **Typecheck**: `bun run typecheck` (tsc --noEmit)
|
||||
3. **Build**: `bun run build`
|
||||
4. **Schema auto-commit**: If schema changes detected
|
||||
|
||||
**Likely failure points**: None. This is a pure refactor with re-exports. No runtime behavior changes.
|
||||
|
||||
**If CI fails**:
|
||||
- Typecheck error: Missing re-export or import cycle. Fix in the new modules, amend commit.
|
||||
- Test error: `tools.test.ts` imports all symbols from `"./constants"`. Re-export barrel must be complete.
|
||||
|
||||
## Gate B: review-work (5-Agent Review)
|
||||
|
||||
Invoke after CI passes:
|
||||
|
||||
```
|
||||
/review-work
|
||||
```
|
||||
|
||||
**5 parallel agents**:
|
||||
1. **Oracle (goal/constraint)**: Verify backward compat claim. Check all 13 import paths resolve.
|
||||
2. **Oracle (code quality)**: Verify single-responsibility per file, LOC limits, no catch-all violations.
|
||||
3. **Oracle (security)**: No security implications in this refactor.
|
||||
4. **QA (hands-on execution)**: Run `bun test src/tools/delegate-task/` and verify all pass.
|
||||
5. **Context miner**: Check no related open issues/PRs conflict.
|
||||
|
||||
**Expected verdict**: Pass. Pure structural refactor with no behavioral changes.
|
||||
|
||||
## Gate C: Cubic (External Bot)
|
||||
|
||||
Wait for `cubic-dev-ai[bot]` to post "No issues found" on the PR.
|
||||
|
||||
**If Cubic flags issues**: Likely false positives on "large number of new files". Address in PR comments if needed.
|
||||
|
||||
## Pre-Gate Local Validation (Before Push)
|
||||
|
||||
```bash
|
||||
# In worktree
|
||||
bun run typecheck
|
||||
bun test src/tools/delegate-task/
|
||||
bun run build
|
||||
|
||||
# Verify re-exports are complete
|
||||
bun -e "import * as c from './src/tools/delegate-task/constants'; console.log(Object.keys(c).sort().join('\n'))"
|
||||
```
|
||||
|
||||
Expected exports from constants.ts (13 total):
|
||||
- `ARTISTRY_CATEGORY_PROMPT_APPEND`
|
||||
- `CATEGORY_DESCRIPTIONS`
|
||||
- `CATEGORY_PROMPT_APPENDS`
|
||||
- `DEFAULT_CATEGORIES`
|
||||
- `DEEP_CATEGORY_PROMPT_APPEND`
|
||||
- `PLAN_AGENT_NAMES`
|
||||
- `PLAN_AGENT_SYSTEM_PREPEND_STATIC_AFTER_SKILLS`
|
||||
- `PLAN_AGENT_SYSTEM_PREPEND_STATIC_BEFORE_SKILLS`
|
||||
- `PLAN_FAMILY_NAMES`
|
||||
- `QUICK_CATEGORY_PROMPT_APPEND`
|
||||
- `ULTRABRAIN_CATEGORY_PROMPT_APPEND`
|
||||
- `UNSPECIFIED_HIGH_CATEGORY_PROMPT_APPEND`
|
||||
- `UNSPECIFIED_LOW_CATEGORY_PROMPT_APPEND`
|
||||
- `VISUAL_CATEGORY_PROMPT_APPEND`
|
||||
- `WRITING_CATEGORY_PROMPT_APPEND`
|
||||
- `buildPlanAgentSkillsSection`
|
||||
- `buildPlanAgentSystemPrepend`
|
||||
- `isPlanAgent`
|
||||
- `isPlanFamily`
|
||||
|
||||
## Merge Strategy
|
||||
|
||||
```bash
|
||||
gh pr merge --squash --delete-branch
|
||||
git worktree remove ../omo-wt/refactor-delegate-task-constants
|
||||
```
|
||||
|
||||
Squash merge collapses the 2 atomic commits into 1 clean commit on dev.
|
||||
@@ -1 +0,0 @@
|
||||
{"total_tokens": null, "duration_ms": 181000, "total_duration_seconds": 181}
|
||||
@@ -1,10 +0,0 @@
|
||||
{
|
||||
"run_id": "eval-3-without_skill",
|
||||
"expectations": [
|
||||
{"text": "Plan uses git worktree in a sibling directory", "passed": false, "evidence": "git checkout -b only, no worktree"},
|
||||
{"text": "Uses 2+ commits for the multi-file refactor", "passed": false, "evidence": "Single atomic commit: 'refactor: split delegate-task constants and category model requirements'"},
|
||||
{"text": "Maintains backward compatibility via barrel re-export", "passed": true, "evidence": "Re-exports from new files, zero consumer changes"},
|
||||
{"text": "Verification loop includes all 3 gates", "passed": false, "evidence": "Only mentions typecheck/test/build. No review-work or Cubic."},
|
||||
{"text": "References actual src/tools/delegate-task/constants.ts", "passed": true, "evidence": "654 lines, detailed responsibility breakdown, full import maps"}
|
||||
]
|
||||
}
|
||||
@@ -1,342 +0,0 @@
|
||||
# Code Changes
|
||||
|
||||
## 1. NEW: `src/tools/delegate-task/default-categories.ts`
|
||||
|
||||
```typescript
|
||||
import type { CategoryConfig } from "../../config/schema"
|
||||
|
||||
export const DEFAULT_CATEGORIES: Record<string, CategoryConfig> = {
|
||||
"visual-engineering": { model: "google/gemini-3.1-pro", variant: "high" },
|
||||
ultrabrain: { model: "openai/gpt-5.4", variant: "xhigh" },
|
||||
deep: { model: "openai/gpt-5.3-codex", variant: "medium" },
|
||||
artistry: { model: "google/gemini-3.1-pro", variant: "high" },
|
||||
quick: { model: "anthropic/claude-haiku-4-5" },
|
||||
"unspecified-low": { model: "anthropic/claude-sonnet-4-6" },
|
||||
"unspecified-high": { model: "anthropic/claude-opus-4-6", variant: "max" },
|
||||
writing: { model: "kimi-for-coding/k2p5" },
|
||||
}
|
||||
```
|
||||
|
||||
## 2. NEW: `src/tools/delegate-task/category-descriptions.ts`
|
||||
|
||||
```typescript
|
||||
export const CATEGORY_DESCRIPTIONS: Record<string, string> = {
|
||||
"visual-engineering": "Frontend, UI/UX, design, styling, animation",
|
||||
ultrabrain: "Use ONLY for genuinely hard, logic-heavy tasks. Give clear goals only, not step-by-step instructions.",
|
||||
deep: "Goal-oriented autonomous problem-solving. Thorough research before action. For hairy problems requiring deep understanding.",
|
||||
artistry: "Complex problem-solving with unconventional, creative approaches - beyond standard patterns",
|
||||
quick: "Trivial tasks - single file changes, typo fixes, simple modifications",
|
||||
"unspecified-low": "Tasks that don't fit other categories, low effort required",
|
||||
"unspecified-high": "Tasks that don't fit other categories, high effort required",
|
||||
writing: "Documentation, prose, technical writing",
|
||||
}
|
||||
```
|
||||
|
||||
## 3. NEW: `src/tools/delegate-task/category-prompt-appends.ts`
|
||||
|
||||
```typescript
|
||||
export const VISUAL_CATEGORY_PROMPT_APPEND = `<Category_Context>
|
||||
You are working on VISUAL/UI tasks.
|
||||
...
|
||||
</Category_Context>`
|
||||
|
||||
export const ULTRABRAIN_CATEGORY_PROMPT_APPEND = `<Category_Context>
|
||||
You are working on DEEP LOGICAL REASONING / COMPLEX ARCHITECTURE tasks.
|
||||
...
|
||||
</Category_Context>`
|
||||
|
||||
export const ARTISTRY_CATEGORY_PROMPT_APPEND = `<Category_Context>
|
||||
You are working on HIGHLY CREATIVE / ARTISTIC tasks.
|
||||
...
|
||||
</Category_Context>`
|
||||
|
||||
export const QUICK_CATEGORY_PROMPT_APPEND = `<Category_Context>
|
||||
You are working on SMALL / QUICK tasks.
|
||||
...
|
||||
</Caller_Warning>`
|
||||
|
||||
export const UNSPECIFIED_LOW_CATEGORY_PROMPT_APPEND = `<Category_Context>
|
||||
You are working on tasks that don't fit specific categories but require moderate effort.
|
||||
...
|
||||
</Caller_Warning>`
|
||||
|
||||
export const UNSPECIFIED_HIGH_CATEGORY_PROMPT_APPEND = `<Category_Context>
|
||||
You are working on tasks that don't fit specific categories but require substantial effort.
|
||||
...
|
||||
</Category_Context>`
|
||||
|
||||
export const WRITING_CATEGORY_PROMPT_APPEND = `<Category_Context>
|
||||
You are working on WRITING / PROSE tasks.
|
||||
...
|
||||
</Category_Context>`
|
||||
|
||||
export const DEEP_CATEGORY_PROMPT_APPEND = `<Category_Context>
|
||||
You are working on GOAL-ORIENTED AUTONOMOUS tasks.
|
||||
...
|
||||
</Category_Context>`
|
||||
|
||||
export const CATEGORY_PROMPT_APPENDS: Record<string, string> = {
|
||||
"visual-engineering": VISUAL_CATEGORY_PROMPT_APPEND,
|
||||
ultrabrain: ULTRABRAIN_CATEGORY_PROMPT_APPEND,
|
||||
deep: DEEP_CATEGORY_PROMPT_APPEND,
|
||||
artistry: ARTISTRY_CATEGORY_PROMPT_APPEND,
|
||||
quick: QUICK_CATEGORY_PROMPT_APPEND,
|
||||
"unspecified-low": UNSPECIFIED_LOW_CATEGORY_PROMPT_APPEND,
|
||||
"unspecified-high": UNSPECIFIED_HIGH_CATEGORY_PROMPT_APPEND,
|
||||
writing: WRITING_CATEGORY_PROMPT_APPEND,
|
||||
}
|
||||
```
|
||||
|
||||
> Note: Each `*_CATEGORY_PROMPT_APPEND` contains the full template string from the original. Abbreviated with `...` here for readability. The actual code would contain the complete unmodified prompt text.
|
||||
|
||||
## 4. NEW: `src/tools/delegate-task/plan-agent-prompt.ts`
|
||||
|
||||
```typescript
|
||||
import type {
|
||||
AvailableCategory,
|
||||
AvailableSkill,
|
||||
} from "../../agents/dynamic-agent-prompt-builder"
|
||||
import { truncateDescription } from "../../shared/truncate-description"
|
||||
|
||||
export const PLAN_AGENT_SYSTEM_PREPEND_STATIC_BEFORE_SKILLS = `<system>
|
||||
BEFORE you begin planning, you MUST first understand the user's request deeply.
|
||||
...
|
||||
</CRITICAL_REQUIREMENT_DEPENDENCY_PARALLEL_EXECUTION_CATEGORY_SKILLS>
|
||||
|
||||
<FINAL_OUTPUT_FOR_CALLER>
|
||||
...
|
||||
</FINAL_OUTPUT_FOR_CALLER>
|
||||
|
||||
`
|
||||
|
||||
export const PLAN_AGENT_SYSTEM_PREPEND_STATIC_AFTER_SKILLS = `### REQUIRED OUTPUT FORMAT
|
||||
...
|
||||
`
|
||||
|
||||
function renderPlanAgentCategoryRows(categories: AvailableCategory[]): string[] {
|
||||
const sorted = [...categories].sort((a, b) => a.name.localeCompare(b.name))
|
||||
return sorted.map((category) => {
|
||||
const bestFor = category.description || category.name
|
||||
const model = category.model || ""
|
||||
return `| \`${category.name}\` | ${bestFor} | ${model} |`
|
||||
})
|
||||
}
|
||||
|
||||
function renderPlanAgentSkillRows(skills: AvailableSkill[]): string[] {
|
||||
const sorted = [...skills].sort((a, b) => a.name.localeCompare(b.name))
|
||||
return sorted.map((skill) => {
|
||||
const domain = truncateDescription(skill.description).trim() || skill.name
|
||||
return `| \`${skill.name}\` | ${domain} |`
|
||||
})
|
||||
}
|
||||
|
||||
export function buildPlanAgentSkillsSection(
|
||||
categories: AvailableCategory[] = [],
|
||||
skills: AvailableSkill[] = []
|
||||
): string {
|
||||
const categoryRows = renderPlanAgentCategoryRows(categories)
|
||||
const skillRows = renderPlanAgentSkillRows(skills)
|
||||
|
||||
return `### AVAILABLE CATEGORIES
|
||||
|
||||
| Category | Best For | Model |
|
||||
|----------|----------|-------|
|
||||
${categoryRows.join("\n")}
|
||||
|
||||
### AVAILABLE SKILLS (ALWAYS EVALUATE ALL)
|
||||
|
||||
Skills inject specialized expertise into the delegated agent.
|
||||
YOU MUST evaluate EVERY skill and justify inclusions/omissions.
|
||||
|
||||
| Skill | Domain |
|
||||
|-------|--------|
|
||||
${skillRows.join("\n")}`
|
||||
}
|
||||
|
||||
export function buildPlanAgentSystemPrepend(
|
||||
categories: AvailableCategory[] = [],
|
||||
skills: AvailableSkill[] = []
|
||||
): string {
|
||||
return [
|
||||
PLAN_AGENT_SYSTEM_PREPEND_STATIC_BEFORE_SKILLS,
|
||||
buildPlanAgentSkillsSection(categories, skills),
|
||||
PLAN_AGENT_SYSTEM_PREPEND_STATIC_AFTER_SKILLS,
|
||||
].join("\n\n")
|
||||
}
|
||||
```
|
||||
|
||||
> Note: Template strings abbreviated with `...`. Full unmodified content in the actual file.
|
||||
|
||||
## 5. NEW: `src/tools/delegate-task/plan-agent-identity.ts`
|
||||
|
||||
```typescript
|
||||
/**
|
||||
* List of agent names that should be treated as plan agents (receive plan system prompt).
|
||||
* Case-insensitive matching is used.
|
||||
*/
|
||||
export const PLAN_AGENT_NAMES = ["plan"]
|
||||
|
||||
/**
|
||||
* Check if the given agent name is a plan agent (receives plan system prompt).
|
||||
*/
|
||||
export function isPlanAgent(agentName: string | undefined): boolean {
|
||||
if (!agentName) return false
|
||||
const lowerName = agentName.toLowerCase().trim()
|
||||
return PLAN_AGENT_NAMES.some(name => lowerName === name || lowerName.includes(name))
|
||||
}
|
||||
|
||||
/**
|
||||
* Plan family: plan + prometheus. Shares mutual delegation blocking and task tool permission.
|
||||
* Does NOT share system prompt (only isPlanAgent controls that).
|
||||
*/
|
||||
export const PLAN_FAMILY_NAMES = ["plan", "prometheus"]
|
||||
|
||||
/**
|
||||
* Check if the given agent belongs to the plan family (blocking + task permission).
|
||||
*/
|
||||
export function isPlanFamily(category: string): boolean
|
||||
export function isPlanFamily(category: string | undefined): boolean
|
||||
export function isPlanFamily(category: string | undefined): boolean {
|
||||
if (!category) return false
|
||||
const lowerCategory = category.toLowerCase().trim()
|
||||
return PLAN_FAMILY_NAMES.some(
|
||||
(name) => lowerCategory === name || lowerCategory.includes(name)
|
||||
)
|
||||
}
|
||||
```
|
||||
|
||||
## 6. MODIFIED: `src/tools/delegate-task/constants.ts` (barrel re-export)
|
||||
|
||||
```typescript
|
||||
export { DEFAULT_CATEGORIES } from "./default-categories"
|
||||
export { CATEGORY_DESCRIPTIONS } from "./category-descriptions"
|
||||
export {
|
||||
VISUAL_CATEGORY_PROMPT_APPEND,
|
||||
ULTRABRAIN_CATEGORY_PROMPT_APPEND,
|
||||
ARTISTRY_CATEGORY_PROMPT_APPEND,
|
||||
QUICK_CATEGORY_PROMPT_APPEND,
|
||||
UNSPECIFIED_LOW_CATEGORY_PROMPT_APPEND,
|
||||
UNSPECIFIED_HIGH_CATEGORY_PROMPT_APPEND,
|
||||
WRITING_CATEGORY_PROMPT_APPEND,
|
||||
DEEP_CATEGORY_PROMPT_APPEND,
|
||||
CATEGORY_PROMPT_APPENDS,
|
||||
} from "./category-prompt-appends"
|
||||
export {
|
||||
PLAN_AGENT_SYSTEM_PREPEND_STATIC_BEFORE_SKILLS,
|
||||
PLAN_AGENT_SYSTEM_PREPEND_STATIC_AFTER_SKILLS,
|
||||
buildPlanAgentSkillsSection,
|
||||
buildPlanAgentSystemPrepend,
|
||||
} from "./plan-agent-prompt"
|
||||
export {
|
||||
PLAN_AGENT_NAMES,
|
||||
isPlanAgent,
|
||||
PLAN_FAMILY_NAMES,
|
||||
isPlanFamily,
|
||||
} from "./plan-agent-identity"
|
||||
```
|
||||
|
||||
## 7. NEW: `src/shared/category-model-requirements.ts`
|
||||
|
||||
```typescript
|
||||
import type { ModelRequirement } from "./model-requirements"
|
||||
|
||||
export const CATEGORY_MODEL_REQUIREMENTS: Record<string, ModelRequirement> = {
|
||||
"visual-engineering": {
|
||||
fallbackChain: [
|
||||
{
|
||||
providers: ["google", "github-copilot", "opencode"],
|
||||
model: "gemini-3.1-pro",
|
||||
variant: "high",
|
||||
},
|
||||
{ providers: ["zai-coding-plan", "opencode"], model: "glm-5" },
|
||||
{
|
||||
providers: ["anthropic", "github-copilot", "opencode"],
|
||||
model: "claude-opus-4-6",
|
||||
variant: "max",
|
||||
},
|
||||
{ providers: ["opencode-go"], model: "glm-5" },
|
||||
{ providers: ["kimi-for-coding"], model: "k2p5" },
|
||||
],
|
||||
},
|
||||
ultrabrain: {
|
||||
fallbackChain: [
|
||||
// ... full content from original
|
||||
],
|
||||
},
|
||||
deep: {
|
||||
fallbackChain: [
|
||||
// ... full content from original
|
||||
],
|
||||
requiresModel: "gpt-5.3-codex",
|
||||
},
|
||||
artistry: {
|
||||
fallbackChain: [
|
||||
// ... full content from original
|
||||
],
|
||||
requiresModel: "gemini-3.1-pro",
|
||||
},
|
||||
quick: {
|
||||
fallbackChain: [
|
||||
// ... full content from original
|
||||
],
|
||||
},
|
||||
"unspecified-low": {
|
||||
fallbackChain: [
|
||||
// ... full content from original
|
||||
],
|
||||
},
|
||||
"unspecified-high": {
|
||||
fallbackChain: [
|
||||
// ... full content from original
|
||||
],
|
||||
},
|
||||
writing: {
|
||||
fallbackChain: [
|
||||
// ... full content from original
|
||||
],
|
||||
},
|
||||
}
|
||||
```
|
||||
|
||||
> Note: Each category's `fallbackChain` contains the exact same entries as the original `model-requirements.ts`. Abbreviated here.
|
||||
|
||||
## 8. MODIFIED: `src/shared/model-requirements.ts`
|
||||
|
||||
**Remove** `CATEGORY_MODEL_REQUIREMENTS` from the file body. **Add** re-export at the end:
|
||||
|
||||
```typescript
|
||||
export type FallbackEntry = {
|
||||
providers: string[];
|
||||
model: string;
|
||||
variant?: string;
|
||||
};
|
||||
|
||||
export type ModelRequirement = {
|
||||
fallbackChain: FallbackEntry[];
|
||||
variant?: string;
|
||||
requiresModel?: string;
|
||||
requiresAnyModel?: boolean;
|
||||
requiresProvider?: string[];
|
||||
};
|
||||
|
||||
export const AGENT_MODEL_REQUIREMENTS: Record<string, ModelRequirement> = {
|
||||
// ... unchanged, full agent entries stay here
|
||||
};
|
||||
|
||||
export { CATEGORY_MODEL_REQUIREMENTS } from "./category-model-requirements"
|
||||
```
|
||||
|
||||
## Summary of Changes
|
||||
|
||||
| File | Lines Before | Lines After | Action |
|
||||
|------|-------------|-------------|--------|
|
||||
| `constants.ts` | 654 | ~25 | Rewrite as barrel re-export |
|
||||
| `default-categories.ts` | - | ~15 | **NEW** |
|
||||
| `category-descriptions.ts` | - | ~12 | **NEW** |
|
||||
| `category-prompt-appends.ts` | - | ~280 | **NEW** (mostly exempt prompt text) |
|
||||
| `plan-agent-prompt.ts` | - | ~270 | **NEW** (mostly exempt prompt text) |
|
||||
| `plan-agent-identity.ts` | - | ~35 | **NEW** |
|
||||
| `model-requirements.ts` | 311 | ~165 | Remove CATEGORY_MODEL_REQUIREMENTS |
|
||||
| `category-model-requirements.ts` | - | ~150 | **NEW** |
|
||||
|
||||
**Zero consumer files modified.** Backward compatibility maintained through barrel re-exports.
|
||||
@@ -1,131 +0,0 @@
|
||||
# Execution Plan: Refactor constants.ts
|
||||
|
||||
## Context
|
||||
|
||||
`src/tools/delegate-task/constants.ts` is **654 lines** with 6 distinct responsibilities. Violates the 200 LOC modular-code-enforcement rule. `CATEGORY_MODEL_REQUIREMENTS` is actually in `src/shared/model-requirements.ts` (311 lines, also violating 200 LOC), not in `constants.ts`.
|
||||
|
||||
## Pre-Flight Analysis
|
||||
|
||||
### Current `constants.ts` responsibilities:
|
||||
1. **Category prompt appends** (8 template strings, ~274 LOC prompt text)
|
||||
2. **DEFAULT_CATEGORIES** (Record<string, CategoryConfig>, ~10 LOC)
|
||||
3. **CATEGORY_PROMPT_APPENDS** (map of category->prompt, ~10 LOC)
|
||||
4. **CATEGORY_DESCRIPTIONS** (map of category->description, ~10 LOC)
|
||||
5. **Plan agent prompts** (2 template strings + 4 builder functions, ~250 LOC prompt text)
|
||||
6. **Plan agent identity utils** (`isPlanAgent`, `isPlanFamily`, ~30 LOC)
|
||||
|
||||
### Current `model-requirements.ts` responsibilities:
|
||||
1. Types (`FallbackEntry`, `ModelRequirement`)
|
||||
2. `AGENT_MODEL_REQUIREMENTS` (~146 LOC)
|
||||
3. `CATEGORY_MODEL_REQUIREMENTS` (~148 LOC)
|
||||
|
||||
### Import dependency map for `constants.ts`:
|
||||
|
||||
**Internal consumers (within delegate-task/):**
|
||||
| File | Imports |
|
||||
|------|---------|
|
||||
| `categories.ts` | `DEFAULT_CATEGORIES`, `CATEGORY_PROMPT_APPENDS` |
|
||||
| `tools.ts` | `CATEGORY_DESCRIPTIONS` |
|
||||
| `tools.test.ts` | `DEFAULT_CATEGORIES`, `CATEGORY_PROMPT_APPENDS`, `CATEGORY_DESCRIPTIONS`, `isPlanAgent`, `PLAN_AGENT_NAMES`, `isPlanFamily`, `PLAN_FAMILY_NAMES` |
|
||||
| `prompt-builder.ts` | `buildPlanAgentSystemPrepend`, `isPlanAgent` |
|
||||
| `subagent-resolver.ts` | `isPlanFamily` |
|
||||
| `sync-continuation.ts` | `isPlanFamily` |
|
||||
| `sync-prompt-sender.ts` | `isPlanFamily` |
|
||||
| `index.ts` | `export * from "./constants"` (barrel) |
|
||||
|
||||
**External consumers (import from `"../../tools/delegate-task/constants"`):**
|
||||
| File | Imports |
|
||||
|------|---------|
|
||||
| `agents/atlas/prompt-section-builder.ts` | `CATEGORY_DESCRIPTIONS` |
|
||||
| `agents/builtin-agents.ts` | `CATEGORY_DESCRIPTIONS` |
|
||||
| `plugin/available-categories.ts` | `CATEGORY_DESCRIPTIONS` |
|
||||
| `plugin-handlers/category-config-resolver.ts` | `DEFAULT_CATEGORIES` |
|
||||
| `shared/merge-categories.ts` | `DEFAULT_CATEGORIES` |
|
||||
| `shared/merge-categories.test.ts` | `DEFAULT_CATEGORIES` |
|
||||
|
||||
**External consumers of `CATEGORY_MODEL_REQUIREMENTS`:**
|
||||
| File | Import path |
|
||||
|------|-------------|
|
||||
| `tools/delegate-task/categories.ts` | `../../shared/model-requirements` |
|
||||
|
||||
## Step-by-Step Execution
|
||||
|
||||
### Step 1: Create branch
|
||||
```bash
|
||||
git checkout -b refactor/split-category-constants dev
|
||||
```
|
||||
|
||||
### Step 2: Split `constants.ts` into 5 focused files
|
||||
|
||||
#### 2a. Create `default-categories.ts`
|
||||
- Move `DEFAULT_CATEGORIES` record
|
||||
- Import `CategoryConfig` type from config schema
|
||||
- ~15 LOC
|
||||
|
||||
#### 2b. Create `category-descriptions.ts`
|
||||
- Move `CATEGORY_DESCRIPTIONS` record
|
||||
- No dependencies
|
||||
- ~12 LOC
|
||||
|
||||
#### 2c. Create `category-prompt-appends.ts`
|
||||
- Move all 8 `*_CATEGORY_PROMPT_APPEND` template string constants
|
||||
- Move `CATEGORY_PROMPT_APPENDS` mapping record
|
||||
- No dependencies (all self-contained template strings)
|
||||
- ~280 LOC (mostly prompt text, exempt from 200 LOC per modular-code-enforcement)
|
||||
|
||||
#### 2d. Create `plan-agent-prompt.ts`
|
||||
- Move `PLAN_AGENT_SYSTEM_PREPEND_STATIC_BEFORE_SKILLS`
|
||||
- Move `PLAN_AGENT_SYSTEM_PREPEND_STATIC_AFTER_SKILLS`
|
||||
- Move `renderPlanAgentCategoryRows()`, `renderPlanAgentSkillRows()`
|
||||
- Move `buildPlanAgentSkillsSection()`, `buildPlanAgentSystemPrepend()`
|
||||
- Imports: `AvailableCategory`, `AvailableSkill` from agents, `truncateDescription` from shared
|
||||
- ~270 LOC (mostly prompt text, exempt)
|
||||
|
||||
#### 2e. Create `plan-agent-identity.ts`
|
||||
- Move `PLAN_AGENT_NAMES`, `isPlanAgent()`
|
||||
- Move `PLAN_FAMILY_NAMES`, `isPlanFamily()`
|
||||
- No dependencies
|
||||
- ~35 LOC
|
||||
|
||||
### Step 3: Convert `constants.ts` to barrel re-export file
|
||||
Replace entire contents with re-exports from the 5 new files. This maintains 100% backward compatibility for all existing importers.
|
||||
|
||||
### Step 4: Split `model-requirements.ts`
|
||||
|
||||
#### 4a. Create `src/shared/category-model-requirements.ts`
|
||||
- Move `CATEGORY_MODEL_REQUIREMENTS` record
|
||||
- Import `ModelRequirement` type from `./model-requirements`
|
||||
- ~150 LOC
|
||||
|
||||
#### 4b. Update `model-requirements.ts`
|
||||
- Remove `CATEGORY_MODEL_REQUIREMENTS`
|
||||
- Add re-export: `export { CATEGORY_MODEL_REQUIREMENTS } from "./category-model-requirements"`
|
||||
- Keep types (`FallbackEntry`, `ModelRequirement`) and `AGENT_MODEL_REQUIREMENTS`
|
||||
- ~165 LOC (now under 200)
|
||||
|
||||
### Step 5: Verify no import breakage
|
||||
- Run `bun run typecheck` to confirm all imports resolve
|
||||
- Run `bun test` to confirm no behavioral regressions
|
||||
- Run `bun run build` to confirm build succeeds
|
||||
|
||||
### Step 6: Verify LSP diagnostics clean
|
||||
- Check `lsp_diagnostics` on all new and modified files
|
||||
|
||||
### Step 7: Commit and create PR
|
||||
- Single atomic commit: `refactor: split delegate-task constants and category model requirements into focused modules`
|
||||
- Create PR with description
|
||||
|
||||
## Files Modified
|
||||
|
||||
| File | Action |
|
||||
|------|--------|
|
||||
| `src/tools/delegate-task/constants.ts` | Rewrite as barrel re-export |
|
||||
| `src/tools/delegate-task/default-categories.ts` | **NEW** |
|
||||
| `src/tools/delegate-task/category-descriptions.ts` | **NEW** |
|
||||
| `src/tools/delegate-task/category-prompt-appends.ts` | **NEW** |
|
||||
| `src/tools/delegate-task/plan-agent-prompt.ts` | **NEW** |
|
||||
| `src/tools/delegate-task/plan-agent-identity.ts` | **NEW** |
|
||||
| `src/shared/model-requirements.ts` | Remove CATEGORY_MODEL_REQUIREMENTS, add re-export |
|
||||
| `src/shared/category-model-requirements.ts` | **NEW** |
|
||||
|
||||
**Zero changes to any consumer files.** All existing imports work via barrel re-exports.
|
||||
@@ -1,39 +0,0 @@
|
||||
## Summary
|
||||
|
||||
- Split `src/tools/delegate-task/constants.ts` (654 LOC, 6 responsibilities) into 5 focused modules: `default-categories.ts`, `category-descriptions.ts`, `category-prompt-appends.ts`, `plan-agent-prompt.ts`, `plan-agent-identity.ts`
|
||||
- Extract `CATEGORY_MODEL_REQUIREMENTS` from `src/shared/model-requirements.ts` (311 LOC) into `category-model-requirements.ts`, bringing both files under the 200 LOC limit
|
||||
- Convert original files to barrel re-exports for 100% backward compatibility (zero consumer changes)
|
||||
|
||||
## Motivation
|
||||
|
||||
Both files violate the project's 200 LOC modular-code-enforcement rule. `constants.ts` mixed 6 unrelated responsibilities (category configs, prompt templates, plan agent builders, identity utils). `model-requirements.ts` mixed agent and category model requirements.
|
||||
|
||||
## Changes
|
||||
|
||||
### `src/tools/delegate-task/`
|
||||
| New File | Responsibility |
|
||||
|----------|---------------|
|
||||
| `default-categories.ts` | `DEFAULT_CATEGORIES` record |
|
||||
| `category-descriptions.ts` | `CATEGORY_DESCRIPTIONS` record |
|
||||
| `category-prompt-appends.ts` | 8 prompt template constants + `CATEGORY_PROMPT_APPENDS` map |
|
||||
| `plan-agent-prompt.ts` | Plan agent system prompts + builder functions |
|
||||
| `plan-agent-identity.ts` | `isPlanAgent`, `isPlanFamily` + name lists |
|
||||
|
||||
`constants.ts` is now a barrel re-export file (~25 LOC).
|
||||
|
||||
### `src/shared/`
|
||||
| New File | Responsibility |
|
||||
|----------|---------------|
|
||||
| `category-model-requirements.ts` | `CATEGORY_MODEL_REQUIREMENTS` record |
|
||||
|
||||
`model-requirements.ts` retains types + `AGENT_MODEL_REQUIREMENTS` and re-exports `CATEGORY_MODEL_REQUIREMENTS`.
|
||||
|
||||
## Backward Compatibility
|
||||
|
||||
All existing import paths (`from "./constants"`, `from "../../tools/delegate-task/constants"`, `from "../../shared/model-requirements"`) continue to work unchanged. Zero consumer files modified.
|
||||
|
||||
## Testing
|
||||
|
||||
- `bun run typecheck` passes
|
||||
- `bun test` passes (existing `tools.test.ts` validates all re-exported symbols)
|
||||
- `bun run build` succeeds
|
||||
@@ -1,128 +0,0 @@
|
||||
# Verification Strategy
|
||||
|
||||
## 1. Type Safety
|
||||
|
||||
### 1a. LSP diagnostics on all new files
|
||||
```
|
||||
lsp_diagnostics("src/tools/delegate-task/default-categories.ts")
|
||||
lsp_diagnostics("src/tools/delegate-task/category-descriptions.ts")
|
||||
lsp_diagnostics("src/tools/delegate-task/category-prompt-appends.ts")
|
||||
lsp_diagnostics("src/tools/delegate-task/plan-agent-prompt.ts")
|
||||
lsp_diagnostics("src/tools/delegate-task/plan-agent-identity.ts")
|
||||
lsp_diagnostics("src/shared/category-model-requirements.ts")
|
||||
```
|
||||
|
||||
### 1b. LSP diagnostics on modified files
|
||||
```
|
||||
lsp_diagnostics("src/tools/delegate-task/constants.ts")
|
||||
lsp_diagnostics("src/shared/model-requirements.ts")
|
||||
```
|
||||
|
||||
### 1c. Full typecheck
|
||||
```bash
|
||||
bun run typecheck
|
||||
```
|
||||
Expected: 0 errors. This confirms all 14 consumer files (8 internal + 6 external) resolve their imports correctly through the barrel re-exports.
|
||||
|
||||
## 2. Behavioral Regression
|
||||
|
||||
### 2a. Existing test suite
|
||||
```bash
|
||||
bun test src/tools/delegate-task/tools.test.ts
|
||||
```
|
||||
This test file imports `DEFAULT_CATEGORIES`, `CATEGORY_PROMPT_APPENDS`, `CATEGORY_DESCRIPTIONS`, `isPlanAgent`, `PLAN_AGENT_NAMES`, `isPlanFamily`, `PLAN_FAMILY_NAMES` from `./constants`. If the barrel re-export is correct, all these tests pass unchanged.
|
||||
|
||||
### 2b. Category resolver tests
|
||||
```bash
|
||||
bun test src/tools/delegate-task/category-resolver.test.ts
|
||||
```
|
||||
This exercises `resolveCategoryConfig()` which imports `DEFAULT_CATEGORIES` and `CATEGORY_PROMPT_APPENDS` from `./constants` and `CATEGORY_MODEL_REQUIREMENTS` from `../../shared/model-requirements`.
|
||||
|
||||
### 2c. Model selection tests
|
||||
```bash
|
||||
bun test src/tools/delegate-task/model-selection.test.ts
|
||||
```
|
||||
|
||||
### 2d. Merge categories tests
|
||||
```bash
|
||||
bun test src/shared/merge-categories.test.ts
|
||||
```
|
||||
Imports `DEFAULT_CATEGORIES` from `../tools/delegate-task/constants` (external path).
|
||||
|
||||
### 2e. Full test suite
|
||||
```bash
|
||||
bun test
|
||||
```
|
||||
|
||||
## 3. Build Verification
|
||||
|
||||
```bash
|
||||
bun run build
|
||||
```
|
||||
Confirms ESM bundle + declarations emit correctly with the new file structure.
|
||||
|
||||
## 4. Export Completeness Verification
|
||||
|
||||
### 4a. Verify `constants.ts` re-exports match original exports
|
||||
Cross-check that every symbol previously exported from `constants.ts` is still exported. The original file exported these symbols:
|
||||
- `VISUAL_CATEGORY_PROMPT_APPEND`
|
||||
- `ULTRABRAIN_CATEGORY_PROMPT_APPEND`
|
||||
- `ARTISTRY_CATEGORY_PROMPT_APPEND`
|
||||
- `QUICK_CATEGORY_PROMPT_APPEND`
|
||||
- `UNSPECIFIED_LOW_CATEGORY_PROMPT_APPEND`
|
||||
- `UNSPECIFIED_HIGH_CATEGORY_PROMPT_APPEND`
|
||||
- `WRITING_CATEGORY_PROMPT_APPEND`
|
||||
- `DEEP_CATEGORY_PROMPT_APPEND`
|
||||
- `DEFAULT_CATEGORIES`
|
||||
- `CATEGORY_PROMPT_APPENDS`
|
||||
- `CATEGORY_DESCRIPTIONS`
|
||||
- `PLAN_AGENT_SYSTEM_PREPEND_STATIC_BEFORE_SKILLS`
|
||||
- `PLAN_AGENT_SYSTEM_PREPEND_STATIC_AFTER_SKILLS`
|
||||
- `buildPlanAgentSkillsSection`
|
||||
- `buildPlanAgentSystemPrepend`
|
||||
- `PLAN_AGENT_NAMES`
|
||||
- `isPlanAgent`
|
||||
- `PLAN_FAMILY_NAMES`
|
||||
- `isPlanFamily`
|
||||
|
||||
All 19 must be re-exported from the barrel.
|
||||
|
||||
### 4b. Verify `model-requirements.ts` re-exports match original exports
|
||||
Original exports: `FallbackEntry`, `ModelRequirement`, `AGENT_MODEL_REQUIREMENTS`, `CATEGORY_MODEL_REQUIREMENTS`. All 4 must still be available.
|
||||
|
||||
## 5. LOC Compliance Check
|
||||
|
||||
Verify each new file is under 200 LOC (excluding prompt template text per modular-code-enforcement rule):
|
||||
|
||||
| File | Expected Total LOC | Non-prompt LOC | Compliant? |
|
||||
|------|-------------------|----------------|------------|
|
||||
| `default-categories.ts` | ~15 | ~15 | Yes |
|
||||
| `category-descriptions.ts` | ~12 | ~12 | Yes |
|
||||
| `category-prompt-appends.ts` | ~280 | ~15 | Yes (prompt exempt) |
|
||||
| `plan-agent-prompt.ts` | ~270 | ~40 | Yes (prompt exempt) |
|
||||
| `plan-agent-identity.ts` | ~35 | ~35 | Yes |
|
||||
| `category-model-requirements.ts` | ~150 | ~150 | Yes |
|
||||
| `model-requirements.ts` (after) | ~165 | ~165 | Yes |
|
||||
| `constants.ts` (after) | ~25 | ~25 | Yes |
|
||||
|
||||
## 6. Consumer Impact Matrix
|
||||
|
||||
Verify zero consumer files need changes:
|
||||
|
||||
| Consumer File | Import Path | Should Still Work? |
|
||||
|--------------|-------------|-------------------|
|
||||
| `delegate-task/categories.ts` | `./constants` | Yes (barrel) |
|
||||
| `delegate-task/tools.ts` | `./constants` | Yes (barrel) |
|
||||
| `delegate-task/tools.test.ts` | `./constants` | Yes (barrel) |
|
||||
| `delegate-task/prompt-builder.ts` | `./constants` | Yes (barrel) |
|
||||
| `delegate-task/subagent-resolver.ts` | `./constants` | Yes (barrel) |
|
||||
| `delegate-task/sync-continuation.ts` | `./constants` | Yes (barrel) |
|
||||
| `delegate-task/sync-prompt-sender.ts` | `./constants` | Yes (barrel) |
|
||||
| `delegate-task/index.ts` | `./constants` | Yes (barrel) |
|
||||
| `agents/atlas/prompt-section-builder.ts` | `../../tools/delegate-task/constants` | Yes (barrel) |
|
||||
| `agents/builtin-agents.ts` | `../tools/delegate-task/constants` | Yes (barrel) |
|
||||
| `plugin/available-categories.ts` | `../tools/delegate-task/constants` | Yes (barrel) |
|
||||
| `plugin-handlers/category-config-resolver.ts` | `../tools/delegate-task/constants` | Yes (barrel) |
|
||||
| `shared/merge-categories.ts` | `../tools/delegate-task/constants` | Yes (barrel) |
|
||||
| `shared/merge-categories.test.ts` | `../tools/delegate-task/constants` | Yes (barrel) |
|
||||
| `delegate-task/categories.ts` | `../../shared/model-requirements` | Yes (re-export) |
|
||||
@@ -1 +0,0 @@
|
||||
{"total_tokens": null, "duration_ms": 229000, "total_duration_seconds": 229}
|
||||
@@ -1,32 +0,0 @@
|
||||
{
|
||||
"eval_id": 4,
|
||||
"eval_name": "new-mcp-arxiv-casual",
|
||||
"prompt": "implement issue #100 - we need to add a new built-in MCP for arxiv paper search. just the basic search endpoint, nothing fancy. pr it",
|
||||
"assertions": [
|
||||
{
|
||||
"id": "worktree-isolation",
|
||||
"text": "Plan uses git worktree in a sibling directory",
|
||||
"type": "manual"
|
||||
},
|
||||
{
|
||||
"id": "follows-mcp-pattern",
|
||||
"text": "New MCP follows existing pattern from src/mcp/ (websearch, context7, grep_app)",
|
||||
"type": "manual"
|
||||
},
|
||||
{
|
||||
"id": "three-gates",
|
||||
"text": "Verification loop includes all 3 gates",
|
||||
"type": "manual"
|
||||
},
|
||||
{
|
||||
"id": "pr-targets-dev",
|
||||
"text": "PR targets dev branch",
|
||||
"type": "manual"
|
||||
},
|
||||
{
|
||||
"id": "local-validation",
|
||||
"text": "Runs local checks before pushing",
|
||||
"type": "manual"
|
||||
}
|
||||
]
|
||||
}
|
||||
@@ -1,10 +0,0 @@
|
||||
{
|
||||
"run_id": "eval-4-with_skill",
|
||||
"expectations": [
|
||||
{"text": "Plan uses git worktree in a sibling directory", "passed": true, "evidence": "../omo-wt/feat/arxiv-mcp"},
|
||||
{"text": "New MCP follows existing pattern from src/mcp/", "passed": true, "evidence": "Follows context7.ts and grep-app.ts static export pattern"},
|
||||
{"text": "Verification loop includes all 3 gates", "passed": true, "evidence": "Gate A (CI), Gate B (review-work 5 agents), Gate C (Cubic)"},
|
||||
{"text": "PR targets dev branch", "passed": true, "evidence": "--base dev"},
|
||||
{"text": "Runs local checks before pushing", "passed": true, "evidence": "bun run typecheck, bun test src/mcp/, bun run build"}
|
||||
]
|
||||
}
|
||||
@@ -1,143 +0,0 @@
|
||||
# Code Changes: Issue #100 - Built-in arXiv MCP
|
||||
|
||||
## 1. NEW FILE: `src/mcp/arxiv.ts`
|
||||
|
||||
```typescript
|
||||
export const arxiv = {
|
||||
type: "remote" as const,
|
||||
url: "https://mcp.arxiv.org",
|
||||
enabled: true,
|
||||
oauth: false as const,
|
||||
}
|
||||
```
|
||||
|
||||
Pattern: identical to `grep-app.ts` (static export, no auth, no config factory needed).
|
||||
|
||||
## 2. MODIFY: `src/mcp/types.ts`
|
||||
|
||||
```typescript
|
||||
import { z } from "zod"
|
||||
|
||||
export const McpNameSchema = z.enum(["websearch", "context7", "grep_app", "arxiv"])
|
||||
|
||||
export type McpName = z.infer<typeof McpNameSchema>
|
||||
|
||||
export const AnyMcpNameSchema = z.string().min(1)
|
||||
|
||||
export type AnyMcpName = z.infer<typeof AnyMcpNameSchema>
|
||||
```
|
||||
|
||||
Change: add `"arxiv"` to `McpNameSchema` enum.
|
||||
|
||||
## 3. MODIFY: `src/mcp/index.ts`
|
||||
|
||||
```typescript
|
||||
import { createWebsearchConfig } from "./websearch"
|
||||
import { context7 } from "./context7"
|
||||
import { grep_app } from "./grep-app"
|
||||
import { arxiv } from "./arxiv"
|
||||
import type { OhMyOpenCodeConfig } from "../config/schema"
|
||||
|
||||
export { McpNameSchema, type McpName } from "./types"
|
||||
|
||||
type RemoteMcpConfig = {
|
||||
type: "remote"
|
||||
url: string
|
||||
enabled: boolean
|
||||
headers?: Record<string, string>
|
||||
oauth?: false
|
||||
}
|
||||
|
||||
export function createBuiltinMcps(disabledMcps: string[] = [], config?: OhMyOpenCodeConfig) {
|
||||
const mcps: Record<string, RemoteMcpConfig> = {}
|
||||
|
||||
if (!disabledMcps.includes("websearch")) {
|
||||
mcps.websearch = createWebsearchConfig(config?.websearch)
|
||||
}
|
||||
|
||||
if (!disabledMcps.includes("context7")) {
|
||||
mcps.context7 = context7
|
||||
}
|
||||
|
||||
if (!disabledMcps.includes("grep_app")) {
|
||||
mcps.grep_app = grep_app
|
||||
}
|
||||
|
||||
if (!disabledMcps.includes("arxiv")) {
|
||||
mcps.arxiv = arxiv
|
||||
}
|
||||
|
||||
return mcps
|
||||
}
|
||||
```
|
||||
|
||||
Changes: import `arxiv`, add conditional block.
|
||||
|
||||
## 4. NEW FILE: `src/mcp/arxiv.test.ts`
|
||||
|
||||
```typescript
|
||||
import { describe, expect, test } from "bun:test"
|
||||
import { arxiv } from "./arxiv"
|
||||
|
||||
describe("arxiv MCP configuration", () => {
|
||||
test("should have correct remote config shape", () => {
|
||||
// given
|
||||
// arxiv is a static export
|
||||
|
||||
// when
|
||||
const config = arxiv
|
||||
|
||||
// then
|
||||
expect(config.type).toBe("remote")
|
||||
expect(config.url).toBe("https://mcp.arxiv.org")
|
||||
expect(config.enabled).toBe(true)
|
||||
expect(config.oauth).toBe(false)
|
||||
})
|
||||
})
|
||||
```
|
||||
|
||||
## 5. MODIFY: `src/mcp/index.test.ts`
|
||||
|
||||
Changes needed:
|
||||
- Test "should return all MCPs when disabled_mcps is empty": add `expect(result).toHaveProperty("arxiv")`, change length to 4
|
||||
- Test "should filter out all built-in MCPs when all disabled": add `"arxiv"` to disabledMcps array, add `expect(result).not.toHaveProperty("arxiv")`
|
||||
- Test "should handle empty disabled_mcps by default": add `expect(result).toHaveProperty("arxiv")`, change length to 4
|
||||
- Test "should only filter built-in MCPs, ignoring unknown names": add `expect(result).toHaveProperty("arxiv")`, change length to 4
|
||||
|
||||
New test to add:
|
||||
|
||||
```typescript
|
||||
test("should filter out arxiv when disabled", () => {
|
||||
// given
|
||||
const disabledMcps = ["arxiv"]
|
||||
|
||||
// when
|
||||
const result = createBuiltinMcps(disabledMcps)
|
||||
|
||||
// then
|
||||
expect(result).toHaveProperty("websearch")
|
||||
expect(result).toHaveProperty("context7")
|
||||
expect(result).toHaveProperty("grep_app")
|
||||
expect(result).not.toHaveProperty("arxiv")
|
||||
expect(Object.keys(result)).toHaveLength(3)
|
||||
})
|
||||
```
|
||||
|
||||
## 6. MODIFY: `src/mcp/AGENTS.md`
|
||||
|
||||
Add row to built-in MCPs table:
|
||||
|
||||
```
|
||||
| **arxiv** | `mcp.arxiv.org` | None | arXiv paper search |
|
||||
```
|
||||
|
||||
## Files touched summary
|
||||
|
||||
| File | Action |
|
||||
|------|--------|
|
||||
| `src/mcp/arxiv.ts` | NEW |
|
||||
| `src/mcp/arxiv.test.ts` | NEW |
|
||||
| `src/mcp/types.ts` | MODIFY (add enum value) |
|
||||
| `src/mcp/index.ts` | MODIFY (import + conditional block) |
|
||||
| `src/mcp/index.test.ts` | MODIFY (update counts + new test) |
|
||||
| `src/mcp/AGENTS.md` | MODIFY (add table row) |
|
||||
@@ -1,82 +0,0 @@
|
||||
# Execution Plan: Issue #100 - Built-in arXiv MCP
|
||||
|
||||
## Phase 0: Setup
|
||||
|
||||
1. `git fetch origin dev`
|
||||
2. `git worktree add ../omo-wt/feat/arxiv-mcp origin/dev`
|
||||
3. `cd ../omo-wt/feat/arxiv-mcp`
|
||||
4. `git checkout -b feat/arxiv-mcp`
|
||||
|
||||
## Phase 1: Implement
|
||||
|
||||
### Step 1: Create `src/mcp/arxiv.ts`
|
||||
- Follow static export pattern (same as `context7.ts` and `grep-app.ts`)
|
||||
- arXiv API is public, no auth needed
|
||||
- URL: `https://mcp.arxiv.org` (hypothetical remote MCP endpoint)
|
||||
- If no remote MCP exists for arXiv, this would need to be a stdio MCP or a custom HTTP wrapper. For this plan, we assume a remote MCP endpoint pattern consistent with existing built-ins.
|
||||
|
||||
### Step 2: Update `src/mcp/types.ts`
|
||||
- Add `"arxiv"` to `McpNameSchema` enum: `z.enum(["websearch", "context7", "grep_app", "arxiv"])`
|
||||
|
||||
### Step 3: Update `src/mcp/index.ts`
|
||||
- Import `arxiv` from `"./arxiv"`
|
||||
- Add conditional block in `createBuiltinMcps()`:
|
||||
```typescript
|
||||
if (!disabledMcps.includes("arxiv")) {
|
||||
mcps.arxiv = arxiv
|
||||
}
|
||||
```
|
||||
|
||||
### Step 4: Create `src/mcp/arxiv.test.ts`
|
||||
- Test arXiv config shape (type, url, enabled, oauth)
|
||||
- Follow pattern from existing tests (given/when/then)
|
||||
|
||||
### Step 5: Update `src/mcp/index.test.ts`
|
||||
- Update expected MCP count from 3 to 4
|
||||
- Add `"arxiv"` to `toHaveProperty` checks
|
||||
- Add `"arxiv"` to the "all disabled" test case
|
||||
|
||||
### Step 6: Update `src/mcp/AGENTS.md`
|
||||
- Add arxiv row to the built-in MCPs table
|
||||
|
||||
### Step 7: Local validation
|
||||
- `bun run typecheck`
|
||||
- `bun test src/mcp/`
|
||||
- `bun run build`
|
||||
|
||||
### Atomic commits (in order):
|
||||
1. `feat(mcp): add arxiv paper search built-in MCP` - arxiv.ts + types.ts update
|
||||
2. `test(mcp): add arxiv MCP tests` - arxiv.test.ts + index.test.ts updates
|
||||
3. `docs(mcp): update AGENTS.md with arxiv MCP` - AGENTS.md update
|
||||
|
||||
## Phase 2: PR Creation
|
||||
|
||||
1. `git push -u origin feat/arxiv-mcp`
|
||||
2. `gh pr create --base dev --title "feat(mcp): add built-in arXiv paper search MCP" --body-file /tmp/pull-request-arxiv-mcp-*.md`
|
||||
|
||||
## Phase 3: Verify Loop
|
||||
|
||||
### Gate A: CI
|
||||
- Wait for `ci.yml` workflow (tests, typecheck, build)
|
||||
- `gh run watch` or poll `gh pr checks`
|
||||
|
||||
### Gate B: review-work
|
||||
- Run `/review-work` skill (5-agent parallel review)
|
||||
- All 5 agents must pass: Oracle (goal), Oracle (code quality), Oracle (security), QA execution, context mining
|
||||
|
||||
### Gate C: Cubic
|
||||
- Wait for cubic-dev-ai[bot] automated review
|
||||
- Must show "No issues found"
|
||||
- If issues found, fix and re-push
|
||||
|
||||
### Failure handling:
|
||||
- Gate A fail: fix locally, amend or new commit, re-push
|
||||
- Gate B fail: address review-work findings, new commit
|
||||
- Gate C fail: address Cubic findings, new commit
|
||||
- Re-enter verify loop from Gate A
|
||||
|
||||
## Phase 4: Merge
|
||||
|
||||
1. `gh pr merge --squash --delete-branch`
|
||||
2. `git worktree remove ../omo-wt/feat/arxiv-mcp`
|
||||
3. `git branch -D feat/arxiv-mcp` (if not auto-deleted)
|
||||
@@ -1,51 +0,0 @@
|
||||
# PR: feat(mcp): add built-in arXiv paper search MCP
|
||||
|
||||
## Title
|
||||
|
||||
`feat(mcp): add built-in arXiv paper search MCP`
|
||||
|
||||
## Body
|
||||
|
||||
```markdown
|
||||
## Summary
|
||||
|
||||
Closes #100
|
||||
|
||||
- Add `arxiv` as 4th built-in remote MCP for arXiv paper search
|
||||
- Follows existing static export pattern (same as `grep_app`, `context7`)
|
||||
- No auth required, disableable via `disabled_mcps: ["arxiv"]`
|
||||
|
||||
## Changes
|
||||
|
||||
- `src/mcp/arxiv.ts` - new MCP config (static export, remote type)
|
||||
- `src/mcp/types.ts` - add `"arxiv"` to `McpNameSchema` enum
|
||||
- `src/mcp/index.ts` - register arxiv in `createBuiltinMcps()`
|
||||
- `src/mcp/arxiv.test.ts` - config shape tests
|
||||
- `src/mcp/index.test.ts` - update counts, add disable test
|
||||
- `src/mcp/AGENTS.md` - document new MCP
|
||||
|
||||
## Usage
|
||||
|
||||
Enabled by default. Disable with:
|
||||
|
||||
```jsonc
|
||||
// .opencode/oh-my-opencode.jsonc
|
||||
{
|
||||
"disabled_mcps": ["arxiv"]
|
||||
}
|
||||
```
|
||||
|
||||
## Validation
|
||||
|
||||
- [x] `bun run typecheck` passes
|
||||
- [x] `bun test src/mcp/` passes
|
||||
- [x] `bun run build` passes
|
||||
```
|
||||
|
||||
## Labels
|
||||
|
||||
`enhancement`, `mcp`
|
||||
|
||||
## Base branch
|
||||
|
||||
`dev`
|
||||
@@ -1,69 +0,0 @@
|
||||
# Verification Strategy: Issue #100 - arXiv MCP
|
||||
|
||||
## Gate A: CI (`ci.yml`)
|
||||
|
||||
### What runs
|
||||
- `bun test` (split: mock-heavy isolated + batch) - must include new `arxiv.test.ts` and updated `index.test.ts`
|
||||
- `bun run typecheck` - validates `McpNameSchema` enum change propagates correctly
|
||||
- `bun run build` - ensures no build regressions
|
||||
|
||||
### How to monitor
|
||||
```bash
|
||||
gh pr checks <pr-number> --watch
|
||||
```
|
||||
|
||||
### Failure scenarios
|
||||
| Failure | Likely cause | Fix |
|
||||
|---------|-------------|-----|
|
||||
| Type error in `types.ts` | Enum value not matching downstream consumers | Check all `McpName` usages via `lsp_find_references` |
|
||||
| Test count mismatch in `index.test.ts` | Forgot to update `toHaveLength()` from 3 to 4 | Update all length assertions |
|
||||
| Build failure | Import path or barrel export issue | Verify `src/mcp/index.ts` exports are clean |
|
||||
|
||||
### Retry
|
||||
Fix locally in worktree, new commit, `git push`.
|
||||
|
||||
## Gate B: review-work (5-agent)
|
||||
|
||||
### Agents and focus areas
|
||||
| Agent | What it checks for this PR |
|
||||
|-------|--------------------------|
|
||||
| Oracle (goal) | Does arxiv MCP satisfy issue #100 requirements? |
|
||||
| Oracle (code quality) | Follows `grep-app.ts` pattern? No SRP violations? < 200 LOC? |
|
||||
| Oracle (security) | No credentials hardcoded, no auth bypass |
|
||||
| QA (execution) | Run tests, verify disable mechanism works |
|
||||
| Context (mining) | Check issue #100 for any missed requirements |
|
||||
|
||||
### Pass criteria
|
||||
All 5 must pass. Any single failure blocks.
|
||||
|
||||
### Failure handling
|
||||
- Read each agent's report
|
||||
- Address findings with new atomic commits
|
||||
- Re-run full verify loop from Gate A
|
||||
|
||||
## Gate C: Cubic (`cubic-dev-ai[bot]`)
|
||||
|
||||
### Expected review scope
|
||||
- Config shape consistency across MCPs
|
||||
- Test coverage for new MCP
|
||||
- Schema type safety
|
||||
|
||||
### Pass criteria
|
||||
Comment from `cubic-dev-ai[bot]` containing "No issues found".
|
||||
|
||||
### Failure handling
|
||||
- Read Cubic's specific findings
|
||||
- Fix with new commit
|
||||
- Re-push, re-enter Gate A
|
||||
|
||||
## Pre-merge checklist
|
||||
- [ ] Gate A: CI green
|
||||
- [ ] Gate B: All 5 review-work agents pass
|
||||
- [ ] Gate C: Cubic "No issues found"
|
||||
- [ ] No unresolved review comments
|
||||
- [ ] PR has at least 1 approval (if required by branch protection)
|
||||
|
||||
## Post-merge
|
||||
1. `gh pr merge --squash --delete-branch`
|
||||
2. `git worktree remove ../omo-wt/feat/arxiv-mcp`
|
||||
3. Verify merge commit on `dev` branch
|
||||
@@ -1 +0,0 @@
|
||||
{"total_tokens": null, "duration_ms": 152000, "total_duration_seconds": 152}
|
||||
@@ -1,10 +0,0 @@
|
||||
{
|
||||
"run_id": "eval-4-without_skill",
|
||||
"expectations": [
|
||||
{"text": "Plan uses git worktree in a sibling directory", "passed": true, "evidence": "git worktree add ../omo-arxiv-mcp dev — agent independently chose worktree"},
|
||||
{"text": "New MCP follows existing pattern from src/mcp/", "passed": true, "evidence": "Follows grep-app.ts pattern"},
|
||||
{"text": "Verification loop includes all 3 gates", "passed": false, "evidence": "Only mentions bun test/typecheck/build. No review-work or Cubic."},
|
||||
{"text": "PR targets dev branch", "passed": true, "evidence": "--base dev"},
|
||||
{"text": "Runs local checks before pushing", "passed": true, "evidence": "bun test src/mcp/, bun run typecheck, bun run build"}
|
||||
]
|
||||
}
|
||||
@@ -1,252 +0,0 @@
|
||||
# Code Changes: Built-in arXiv MCP
|
||||
|
||||
## 1. NEW FILE: `src/mcp/arxiv.ts`
|
||||
|
||||
```typescript
|
||||
export const arxiv = {
|
||||
type: "remote" as const,
|
||||
url: "https://mcp.arxiv.org",
|
||||
enabled: true,
|
||||
oauth: false as const,
|
||||
}
|
||||
```
|
||||
|
||||
> **Note:** The URL `https://mcp.arxiv.org` is a placeholder. The actual endpoint needs to be verified. If no hosted arXiv MCP exists, alternatives include community-hosted servers or a self-hosted wrapper around the arXiv REST API (`export.arxiv.org/api/query`). This would be the single blocker requiring resolution before merging.
|
||||
|
||||
Pattern followed: `grep-app.ts` (static export, no auth, no config factory needed since arXiv API is public).
|
||||
|
||||
---
|
||||
|
||||
## 2. MODIFY: `src/mcp/types.ts`
|
||||
|
||||
```diff
|
||||
import { z } from "zod"
|
||||
|
||||
-export const McpNameSchema = z.enum(["websearch", "context7", "grep_app"])
|
||||
+export const McpNameSchema = z.enum(["websearch", "context7", "grep_app", "arxiv"])
|
||||
|
||||
export type McpName = z.infer<typeof McpNameSchema>
|
||||
|
||||
export const AnyMcpNameSchema = z.string().min(1)
|
||||
|
||||
export type AnyMcpName = z.infer<typeof AnyMcpNameSchema>
|
||||
```
|
||||
|
||||
---
|
||||
|
||||
## 3. MODIFY: `src/mcp/index.ts`
|
||||
|
||||
```diff
|
||||
import { createWebsearchConfig } from "./websearch"
|
||||
import { context7 } from "./context7"
|
||||
import { grep_app } from "./grep-app"
|
||||
+import { arxiv } from "./arxiv"
|
||||
import type { OhMyOpenCodeConfig } from "../config/schema"
|
||||
|
||||
-export { McpNameSchema, type McpName } from "./types"
|
||||
+export { McpNameSchema, type McpName } from "./types"
|
||||
|
||||
type RemoteMcpConfig = {
|
||||
type: "remote"
|
||||
url: string
|
||||
enabled: boolean
|
||||
headers?: Record<string, string>
|
||||
oauth?: false
|
||||
}
|
||||
|
||||
export function createBuiltinMcps(disabledMcps: string[] = [], config?: OhMyOpenCodeConfig) {
|
||||
const mcps: Record<string, RemoteMcpConfig> = {}
|
||||
|
||||
if (!disabledMcps.includes("websearch")) {
|
||||
mcps.websearch = createWebsearchConfig(config?.websearch)
|
||||
}
|
||||
|
||||
if (!disabledMcps.includes("context7")) {
|
||||
mcps.context7 = context7
|
||||
}
|
||||
|
||||
if (!disabledMcps.includes("grep_app")) {
|
||||
mcps.grep_app = grep_app
|
||||
}
|
||||
|
||||
+ if (!disabledMcps.includes("arxiv")) {
|
||||
+ mcps.arxiv = arxiv
|
||||
+ }
|
||||
+
|
||||
return mcps
|
||||
}
|
||||
```
|
||||
|
||||
---
|
||||
|
||||
## 4. MODIFY: `src/mcp/index.test.ts`
|
||||
|
||||
Changes needed in existing tests (count 3 → 4) plus one new test:
|
||||
|
||||
```diff
|
||||
describe("createBuiltinMcps", () => {
|
||||
test("should return all MCPs when disabled_mcps is empty", () => {
|
||||
// given
|
||||
const disabledMcps: string[] = []
|
||||
|
||||
// when
|
||||
const result = createBuiltinMcps(disabledMcps)
|
||||
|
||||
// then
|
||||
expect(result).toHaveProperty("websearch")
|
||||
expect(result).toHaveProperty("context7")
|
||||
expect(result).toHaveProperty("grep_app")
|
||||
- expect(Object.keys(result)).toHaveLength(3)
|
||||
+ expect(result).toHaveProperty("arxiv")
|
||||
+ expect(Object.keys(result)).toHaveLength(4)
|
||||
})
|
||||
|
||||
test("should filter out disabled built-in MCPs", () => {
|
||||
// given
|
||||
const disabledMcps = ["context7"]
|
||||
|
||||
// when
|
||||
const result = createBuiltinMcps(disabledMcps)
|
||||
|
||||
// then
|
||||
expect(result).toHaveProperty("websearch")
|
||||
expect(result).not.toHaveProperty("context7")
|
||||
expect(result).toHaveProperty("grep_app")
|
||||
- expect(Object.keys(result)).toHaveLength(2)
|
||||
+ expect(result).toHaveProperty("arxiv")
|
||||
+ expect(Object.keys(result)).toHaveLength(3)
|
||||
})
|
||||
|
||||
test("should filter out all built-in MCPs when all disabled", () => {
|
||||
// given
|
||||
- const disabledMcps = ["websearch", "context7", "grep_app"]
|
||||
+ const disabledMcps = ["websearch", "context7", "grep_app", "arxiv"]
|
||||
|
||||
// when
|
||||
const result = createBuiltinMcps(disabledMcps)
|
||||
|
||||
// then
|
||||
expect(result).not.toHaveProperty("websearch")
|
||||
expect(result).not.toHaveProperty("context7")
|
||||
expect(result).not.toHaveProperty("grep_app")
|
||||
+ expect(result).not.toHaveProperty("arxiv")
|
||||
expect(Object.keys(result)).toHaveLength(0)
|
||||
})
|
||||
|
||||
test("should ignore custom MCP names in disabled_mcps", () => {
|
||||
// given
|
||||
const disabledMcps = ["context7", "playwright", "custom"]
|
||||
|
||||
// when
|
||||
const result = createBuiltinMcps(disabledMcps)
|
||||
|
||||
// then
|
||||
expect(result).toHaveProperty("websearch")
|
||||
expect(result).not.toHaveProperty("context7")
|
||||
expect(result).toHaveProperty("grep_app")
|
||||
- expect(Object.keys(result)).toHaveLength(2)
|
||||
+ expect(result).toHaveProperty("arxiv")
|
||||
+ expect(Object.keys(result)).toHaveLength(3)
|
||||
})
|
||||
|
||||
test("should handle empty disabled_mcps by default", () => {
|
||||
// given
|
||||
// when
|
||||
const result = createBuiltinMcps()
|
||||
|
||||
// then
|
||||
expect(result).toHaveProperty("websearch")
|
||||
expect(result).toHaveProperty("context7")
|
||||
expect(result).toHaveProperty("grep_app")
|
||||
- expect(Object.keys(result)).toHaveLength(3)
|
||||
+ expect(result).toHaveProperty("arxiv")
|
||||
+ expect(Object.keys(result)).toHaveLength(4)
|
||||
})
|
||||
|
||||
test("should only filter built-in MCPs, ignoring unknown names", () => {
|
||||
// given
|
||||
const disabledMcps = ["playwright", "sqlite", "unknown-mcp"]
|
||||
|
||||
// when
|
||||
const result = createBuiltinMcps(disabledMcps)
|
||||
|
||||
// then
|
||||
expect(result).toHaveProperty("websearch")
|
||||
expect(result).toHaveProperty("context7")
|
||||
expect(result).toHaveProperty("grep_app")
|
||||
- expect(Object.keys(result)).toHaveLength(3)
|
||||
+ expect(result).toHaveProperty("arxiv")
|
||||
+ expect(Object.keys(result)).toHaveLength(4)
|
||||
})
|
||||
|
||||
+ test("should filter out arxiv when disabled", () => {
|
||||
+ // given
|
||||
+ const disabledMcps = ["arxiv"]
|
||||
+
|
||||
+ // when
|
||||
+ const result = createBuiltinMcps(disabledMcps)
|
||||
+
|
||||
+ // then
|
||||
+ expect(result).toHaveProperty("websearch")
|
||||
+ expect(result).toHaveProperty("context7")
|
||||
+ expect(result).toHaveProperty("grep_app")
|
||||
+ expect(result).not.toHaveProperty("arxiv")
|
||||
+ expect(Object.keys(result)).toHaveLength(3)
|
||||
+ })
|
||||
+
|
||||
// ... existing tavily test unchanged
|
||||
})
|
||||
```
|
||||
|
||||
---
|
||||
|
||||
## 5. MODIFY: `src/mcp/AGENTS.md`
|
||||
|
||||
```diff
|
||||
-# src/mcp/ — 3 Built-in Remote MCPs
|
||||
+# src/mcp/ — 4 Built-in Remote MCPs
|
||||
|
||||
**Generated:** 2026-03-06
|
||||
|
||||
## OVERVIEW
|
||||
|
||||
-Tier 1 of the three-tier MCP system. 3 remote HTTP MCPs created via `createBuiltinMcps(disabledMcps, config)`.
|
||||
+Tier 1 of the three-tier MCP system. 4 remote HTTP MCPs created via `createBuiltinMcps(disabledMcps, config)`.
|
||||
|
||||
## BUILT-IN MCPs
|
||||
|
||||
| Name | URL | Env Vars | Tools |
|
||||
|------|-----|----------|-------|
|
||||
| **websearch** | `mcp.exa.ai` (default) or `mcp.tavily.com` | `EXA_API_KEY` (optional), `TAVILY_API_KEY` (if tavily) | Web search |
|
||||
| **context7** | `mcp.context7.com/mcp` | `CONTEXT7_API_KEY` (optional) | Library documentation |
|
||||
| **grep_app** | `mcp.grep.app` | None | GitHub code search |
|
||||
+| **arxiv** | `mcp.arxiv.org` | None | arXiv paper search |
|
||||
|
||||
...
|
||||
|
||||
## FILES
|
||||
|
||||
| File | Purpose |
|
||||
|------|---------|
|
||||
| `index.ts` | `createBuiltinMcps()` factory |
|
||||
-| `types.ts` | `McpNameSchema`: "websearch" \| "context7" \| "grep_app" |
|
||||
+| `types.ts` | `McpNameSchema`: "websearch" \| "context7" \| "grep_app" \| "arxiv" |
|
||||
| `websearch.ts` | Exa/Tavily provider with config |
|
||||
| `context7.ts` | Context7 with optional auth header |
|
||||
| `grep-app.ts` | Grep.app (no auth) |
|
||||
+| `arxiv.ts` | arXiv paper search (no auth) |
|
||||
```
|
||||
|
||||
---
|
||||
|
||||
## Summary of Touched Files
|
||||
|
||||
| File | Lines Changed | Type |
|
||||
|------|--------------|------|
|
||||
| `src/mcp/arxiv.ts` | +6 (new) | Create |
|
||||
| `src/mcp/types.ts` | 1 line modified | Modify |
|
||||
| `src/mcp/index.ts` | +5 (import + block) | Modify |
|
||||
| `src/mcp/index.test.ts` | ~20 lines (count fixes + new test) | Modify |
|
||||
| `src/mcp/AGENTS.md` | ~6 lines | Modify |
|
||||
|
||||
Total: ~37 lines added/modified across 5 files. Minimal, surgical change.
|
||||
@@ -1,83 +0,0 @@
|
||||
# Execution Plan: Add Built-in arXiv MCP (Issue #100)
|
||||
|
||||
## Pre-Implementation
|
||||
|
||||
1. **Create worktree + branch**
|
||||
```bash
|
||||
git worktree add ../omo-arxiv-mcp dev
|
||||
cd ../omo-arxiv-mcp
|
||||
git checkout -b feat/arxiv-mcp
|
||||
```
|
||||
|
||||
2. **Verify arXiv MCP endpoint exists**
|
||||
- The arXiv API is public (`export.arxiv.org/api/query`) but has no native MCP endpoint
|
||||
- Need to identify a hosted remote MCP server for arXiv (e.g., community-maintained or self-hosted)
|
||||
- If no hosted endpoint exists, consider alternatives: (a) use a community-hosted one from the MCP registry, (b) flag this in the PR and propose a follow-up for hosting
|
||||
- For this plan, assume a remote MCP endpoint at a URL like `https://mcp.arxiv.org` or a third-party equivalent
|
||||
|
||||
## Implementation Steps (4 files to modify, 2 files to create)
|
||||
|
||||
### Step 1: Create `src/mcp/arxiv.ts`
|
||||
- Follow the `grep-app.ts` pattern (simplest: static export, no auth, no config)
|
||||
- arXiv API is public, so no API key needed
|
||||
- Export a `const arxiv` with `type: "remote"`, `url`, `enabled: true`, `oauth: false`
|
||||
|
||||
### Step 2: Update `src/mcp/types.ts`
|
||||
- Add `"arxiv"` to the `McpNameSchema` z.enum array
|
||||
- This makes it a recognized built-in MCP name
|
||||
|
||||
### Step 3: Update `src/mcp/index.ts`
|
||||
- Import `arxiv` from `"./arxiv"`
|
||||
- Add the `if (!disabledMcps.includes("arxiv"))` block inside `createBuiltinMcps()`
|
||||
- Place it after `grep_app` block (alphabetical among new additions, or last)
|
||||
|
||||
### Step 4: Update `src/mcp/index.test.ts`
|
||||
- Update test "should return all MCPs when disabled_mcps is empty" to expect 4 MCPs instead of 3
|
||||
- Update test "should filter out all built-in MCPs when all disabled" to include "arxiv" in the disabled list and expect it not present
|
||||
- Update test "should handle empty disabled_mcps by default" to expect 4 MCPs
|
||||
- Update test "should only filter built-in MCPs, ignoring unknown names" to expect 4 MCPs
|
||||
- Add new test: "should filter out arxiv when disabled"
|
||||
|
||||
### Step 5: Create `src/mcp/arxiv.test.ts` (optional, only if factory pattern used)
|
||||
- If using static export (like grep-app), no separate test file needed
|
||||
- If using factory with config, add tests following `websearch.test.ts` pattern
|
||||
|
||||
### Step 6: Update `src/mcp/AGENTS.md`
|
||||
- Add arxiv to the built-in MCPs table
|
||||
- Update "3 Built-in Remote MCPs" to "4 Built-in Remote MCPs"
|
||||
- Add arxiv to the FILES table
|
||||
|
||||
## Post-Implementation
|
||||
|
||||
### Verification
|
||||
```bash
|
||||
bun test src/mcp/ # Run MCP tests
|
||||
bun run typecheck # Verify no type errors
|
||||
bun run build # Verify build passes
|
||||
```
|
||||
|
||||
### PR Creation
|
||||
```bash
|
||||
git add src/mcp/arxiv.ts src/mcp/types.ts src/mcp/index.ts src/mcp/index.test.ts src/mcp/AGENTS.md
|
||||
git commit -m "feat(mcp): add built-in arxiv paper search MCP"
|
||||
git push -u origin feat/arxiv-mcp
|
||||
gh pr create --title "feat(mcp): add built-in arxiv paper search MCP" --body-file /tmp/pull-request-arxiv-mcp-....md --base dev
|
||||
```
|
||||
|
||||
## Risk Assessment
|
||||
|
||||
| Risk | Likelihood | Mitigation |
|
||||
|------|-----------|------------|
|
||||
| No hosted arXiv MCP endpoint exists | Medium | Research MCP registries; worst case, create a minimal hosted wrapper or use a community server |
|
||||
| Existing tests break due to MCP count change | Low | Update hardcoded count assertions from 3 to 4 |
|
||||
| Config schema needs updates | None | `disabled_mcps` uses `AnyMcpNameSchema` (any string), not `McpNameSchema`, so no schema change needed for disable functionality |
|
||||
|
||||
## Files Changed Summary
|
||||
|
||||
| File | Action | Description |
|
||||
|------|--------|-------------|
|
||||
| `src/mcp/arxiv.ts` | Create | Static remote MCP config export |
|
||||
| `src/mcp/types.ts` | Modify | Add "arxiv" to McpNameSchema enum |
|
||||
| `src/mcp/index.ts` | Modify | Import + register in createBuiltinMcps() |
|
||||
| `src/mcp/index.test.ts` | Modify | Update count assertions, add arxiv-specific test |
|
||||
| `src/mcp/AGENTS.md` | Modify | Update docs to reflect 4 MCPs |
|
||||
@@ -1,33 +0,0 @@
|
||||
## Summary
|
||||
|
||||
- Add `arxiv` as a 4th built-in remote MCP for arXiv paper search
|
||||
- Follows the `grep-app.ts` pattern: static export, no auth required (arXiv API is public)
|
||||
- Fully integrated with `disabled_mcps` config and `McpNameSchema` validation
|
||||
|
||||
## Changes
|
||||
|
||||
| File | Change |
|
||||
|------|--------|
|
||||
| `src/mcp/arxiv.ts` | New remote MCP config pointing to arXiv MCP endpoint |
|
||||
| `src/mcp/types.ts` | Add `"arxiv"` to `McpNameSchema` enum |
|
||||
| `src/mcp/index.ts` | Import + register arxiv in `createBuiltinMcps()` |
|
||||
| `src/mcp/index.test.ts` | Update count assertions (3 → 4), add arxiv disable test |
|
||||
| `src/mcp/AGENTS.md` | Update docs to reflect 4 built-in MCPs |
|
||||
|
||||
## How to Test
|
||||
|
||||
```bash
|
||||
bun test src/mcp/
|
||||
```
|
||||
|
||||
## How to Disable
|
||||
|
||||
```jsonc
|
||||
// Method 1: disabled_mcps
|
||||
{ "disabled_mcps": ["arxiv"] }
|
||||
|
||||
// Method 2: enabled flag
|
||||
{ "mcp": { "arxiv": { "enabled": false } } }
|
||||
```
|
||||
|
||||
Closes #100
|
||||
@@ -1,101 +0,0 @@
|
||||
# Verification Strategy: arXiv MCP
|
||||
|
||||
## 1. Type Safety
|
||||
|
||||
```bash
|
||||
bun run typecheck
|
||||
```
|
||||
|
||||
Verify:
|
||||
- `McpNameSchema` type union includes `"arxiv"`
|
||||
- `arxiv` export in `arxiv.ts` matches `RemoteMcpConfig` shape
|
||||
- Import in `index.ts` resolves correctly
|
||||
- No new type errors introduced
|
||||
|
||||
## 2. Unit Tests
|
||||
|
||||
```bash
|
||||
bun test src/mcp/
|
||||
```
|
||||
|
||||
### Existing test updates verified:
|
||||
- `index.test.ts`: All 7 existing tests pass with updated count (3 → 4)
|
||||
- `websearch.test.ts`: Unchanged, still passes (no side effects)
|
||||
|
||||
### New test coverage:
|
||||
- `index.test.ts`: New test "should filter out arxiv when disabled" passes
|
||||
- Arxiv appears in all "all MCPs" assertions
|
||||
- Arxiv excluded when in `disabled_mcps`
|
||||
|
||||
## 3. Build Verification
|
||||
|
||||
```bash
|
||||
bun run build
|
||||
```
|
||||
|
||||
Verify:
|
||||
- ESM bundle includes `arxiv.ts` module
|
||||
- Type declarations emitted for `arxiv` export
|
||||
- No build errors
|
||||
|
||||
## 4. Integration Check
|
||||
|
||||
### Config disable path
|
||||
- Add `"arxiv"` to `disabled_mcps` in test config → verify MCP excluded from `createBuiltinMcps()` output
|
||||
- This is already covered by the unit test, but can be manually verified:
|
||||
|
||||
```typescript
|
||||
import { createBuiltinMcps } from "./src/mcp"
|
||||
const withArxiv = createBuiltinMcps([])
|
||||
console.log(Object.keys(withArxiv)) // ["websearch", "context7", "grep_app", "arxiv"]
|
||||
|
||||
const withoutArxiv = createBuiltinMcps(["arxiv"])
|
||||
console.log(Object.keys(withoutArxiv)) // ["websearch", "context7", "grep_app"]
|
||||
```
|
||||
|
||||
### MCP config handler path
|
||||
- `mcp-config-handler.ts` calls `createBuiltinMcps()` and merges results
|
||||
- No changes needed there; arxiv automatically included in the merge
|
||||
- Verify by checking `applyMcpConfig()` output includes arxiv when not disabled
|
||||
|
||||
## 5. LSP Diagnostics
|
||||
|
||||
```bash
|
||||
# Run on all changed files
|
||||
```
|
||||
|
||||
Check `lsp_diagnostics` on:
|
||||
- `src/mcp/arxiv.ts`
|
||||
- `src/mcp/types.ts`
|
||||
- `src/mcp/index.ts`
|
||||
- `src/mcp/index.test.ts`
|
||||
|
||||
All must return 0 errors.
|
||||
|
||||
## 6. Endpoint Verification (Manual / Pre-merge)
|
||||
|
||||
**Critical:** Before merging, verify the arXiv MCP endpoint URL is actually reachable:
|
||||
|
||||
```bash
|
||||
curl -s -o /dev/null -w "%{http_code}" https://mcp.arxiv.org
|
||||
```
|
||||
|
||||
If the endpoint doesn't exist or returns non-2xx, the MCP will silently fail at runtime (MCP framework handles connection errors gracefully). This is acceptable for a built-in MCP but should be documented.
|
||||
|
||||
## 7. Regression Check
|
||||
|
||||
Verify no existing functionality is broken:
|
||||
- `bun test` (full suite) passes
|
||||
- Existing 3 MCPs (websearch, context7, grep_app) still work
|
||||
- `disabled_mcps` config still works for all MCPs
|
||||
- `mcp-config-handler.test.ts` passes (if it has count-based assertions, update them)
|
||||
|
||||
## Checklist
|
||||
|
||||
- [ ] `bun run typecheck` passes
|
||||
- [ ] `bun test src/mcp/` passes (all tests green)
|
||||
- [ ] `bun run build` succeeds
|
||||
- [ ] `lsp_diagnostics` clean on all 4 changed files
|
||||
- [ ] arXiv MCP endpoint URL verified reachable
|
||||
- [ ] No hardcoded MCP count assertions broken elsewhere in codebase
|
||||
- [ ] AGENTS.md updated to reflect 4 MCPs
|
||||
@@ -1 +0,0 @@
|
||||
{"total_tokens": null, "duration_ms": 197000, "total_duration_seconds": 197}
|
||||
@@ -1,32 +0,0 @@
|
||||
{
|
||||
"eval_id": 5,
|
||||
"eval_name": "regex-fix-false-positive",
|
||||
"prompt": "The comment-checker hook is too aggressive - it's flagging legitimate comments that happen to contain 'Note:' as AI slop. Relax the regex pattern and add test cases for the false positives. Work on a separate branch and make a PR.",
|
||||
"assertions": [
|
||||
{
|
||||
"id": "worktree-isolation",
|
||||
"text": "Plan uses git worktree in a sibling directory",
|
||||
"type": "manual"
|
||||
},
|
||||
{
|
||||
"id": "real-comment-checker-files",
|
||||
"text": "References actual comment-checker hook files in the codebase",
|
||||
"type": "manual"
|
||||
},
|
||||
{
|
||||
"id": "regression-tests",
|
||||
"text": "Adds test cases specifically for 'Note:' false positive scenarios",
|
||||
"type": "manual"
|
||||
},
|
||||
{
|
||||
"id": "three-gates",
|
||||
"text": "Verification loop includes all 3 gates",
|
||||
"type": "manual"
|
||||
},
|
||||
{
|
||||
"id": "minimal-change",
|
||||
"text": "Only modifies regex and adds tests — no unrelated changes",
|
||||
"type": "manual"
|
||||
}
|
||||
]
|
||||
}
|
||||
@@ -1,10 +0,0 @@
|
||||
{
|
||||
"run_id": "eval-5-with_skill",
|
||||
"expectations": [
|
||||
{"text": "Plan uses git worktree in a sibling directory", "passed": true, "evidence": "../omo-wt/fix/comment-checker-note-false-positive"},
|
||||
{"text": "References actual comment-checker hook files", "passed": true, "evidence": "Found Go binary, extracted 24 regex patterns, references cli.ts, cli-runner.ts, hook.ts"},
|
||||
{"text": "Adds test cases for Note: false positive scenarios", "passed": true, "evidence": "Commit 3 dedicated to false positive test cases"},
|
||||
{"text": "Verification loop includes all 3 gates", "passed": true, "evidence": "Gate A (CI), Gate B (review-work 5 agents), Gate C (Cubic)"},
|
||||
{"text": "Only modifies regex and adds tests — no unrelated changes", "passed": false, "evidence": "Also proposes config schema change (exclude_patterns) and Go binary update — goes beyond minimal fix"}
|
||||
]
|
||||
}
|
||||
@@ -1,387 +0,0 @@
|
||||
# Code Changes
|
||||
|
||||
## File 1: `src/config/schema/comment-checker.ts`
|
||||
|
||||
### Before
|
||||
```typescript
|
||||
import { z } from "zod"
|
||||
|
||||
export const CommentCheckerConfigSchema = z.object({
|
||||
/** Custom prompt to replace the default warning message. Use {{comments}} placeholder for detected comments XML. */
|
||||
custom_prompt: z.string().optional(),
|
||||
})
|
||||
|
||||
export type CommentCheckerConfig = z.infer<typeof CommentCheckerConfigSchema>
|
||||
```
|
||||
|
||||
### After
|
||||
```typescript
|
||||
import { z } from "zod"
|
||||
|
||||
export const CommentCheckerConfigSchema = z.object({
|
||||
/** Custom prompt to replace the default warning message. Use {{comments}} placeholder for detected comments XML. */
|
||||
custom_prompt: z.string().optional(),
|
||||
/** Regex patterns to exclude from comment detection (e.g. ["^Note:", "^TODO:"]). Case-insensitive. */
|
||||
exclude_patterns: z.array(z.string()).optional(),
|
||||
})
|
||||
|
||||
export type CommentCheckerConfig = z.infer<typeof CommentCheckerConfigSchema>
|
||||
```
|
||||
|
||||
---
|
||||
|
||||
## File 2: `src/hooks/comment-checker/cli.ts`
|
||||
|
||||
### Change: `runCommentChecker` function (line 151)
|
||||
|
||||
Add `excludePatterns` parameter and pass `--exclude-pattern` flags to the binary.
|
||||
|
||||
### Before (line 151)
|
||||
```typescript
|
||||
export async function runCommentChecker(input: HookInput, cliPath?: string, customPrompt?: string): Promise<CheckResult> {
|
||||
const binaryPath = cliPath ?? resolvedCliPath ?? getCommentCheckerPathSync()
|
||||
// ...
|
||||
try {
|
||||
const args = [binaryPath, "check"]
|
||||
if (customPrompt) {
|
||||
args.push("--prompt", customPrompt)
|
||||
}
|
||||
```
|
||||
|
||||
### After
|
||||
```typescript
|
||||
export async function runCommentChecker(
|
||||
input: HookInput,
|
||||
cliPath?: string,
|
||||
customPrompt?: string,
|
||||
excludePatterns?: string[],
|
||||
): Promise<CheckResult> {
|
||||
const binaryPath = cliPath ?? resolvedCliPath ?? getCommentCheckerPathSync()
|
||||
// ...
|
||||
try {
|
||||
const args = [binaryPath, "check"]
|
||||
if (customPrompt) {
|
||||
args.push("--prompt", customPrompt)
|
||||
}
|
||||
if (excludePatterns) {
|
||||
for (const pattern of excludePatterns) {
|
||||
args.push("--exclude-pattern", pattern)
|
||||
}
|
||||
}
|
||||
```
|
||||
|
||||
---
|
||||
|
||||
## File 3: `src/hooks/comment-checker/cli-runner.ts`
|
||||
|
||||
### Change: `processWithCli` function (line 43)
|
||||
|
||||
Add `excludePatterns` parameter threading.
|
||||
|
||||
### Before (line 43-79)
|
||||
```typescript
|
||||
export async function processWithCli(
|
||||
input: { tool: string; sessionID: string; callID: string },
|
||||
pendingCall: PendingCall,
|
||||
output: { output: string },
|
||||
cliPath: string,
|
||||
customPrompt: string | undefined,
|
||||
debugLog: (...args: unknown[]) => void,
|
||||
): Promise<void> {
|
||||
await withCommentCheckerLock(async () => {
|
||||
// ...
|
||||
const result = await runCommentChecker(hookInput, cliPath, customPrompt)
|
||||
```
|
||||
|
||||
### After
|
||||
```typescript
|
||||
export async function processWithCli(
|
||||
input: { tool: string; sessionID: string; callID: string },
|
||||
pendingCall: PendingCall,
|
||||
output: { output: string },
|
||||
cliPath: string,
|
||||
customPrompt: string | undefined,
|
||||
debugLog: (...args: unknown[]) => void,
|
||||
excludePatterns?: string[],
|
||||
): Promise<void> {
|
||||
await withCommentCheckerLock(async () => {
|
||||
// ...
|
||||
const result = await runCommentChecker(hookInput, cliPath, customPrompt, excludePatterns)
|
||||
```
|
||||
|
||||
### Change: `processApplyPatchEditsWithCli` function (line 87)
|
||||
|
||||
Same pattern - thread `excludePatterns` through.
|
||||
|
||||
### Before (line 87-120)
|
||||
```typescript
|
||||
export async function processApplyPatchEditsWithCli(
|
||||
sessionID: string,
|
||||
edits: ApplyPatchEdit[],
|
||||
output: { output: string },
|
||||
cliPath: string,
|
||||
customPrompt: string | undefined,
|
||||
debugLog: (...args: unknown[]) => void,
|
||||
): Promise<void> {
|
||||
// ...
|
||||
const result = await runCommentChecker(hookInput, cliPath, customPrompt)
|
||||
```
|
||||
|
||||
### After
|
||||
```typescript
|
||||
export async function processApplyPatchEditsWithCli(
|
||||
sessionID: string,
|
||||
edits: ApplyPatchEdit[],
|
||||
output: { output: string },
|
||||
cliPath: string,
|
||||
customPrompt: string | undefined,
|
||||
debugLog: (...args: unknown[]) => void,
|
||||
excludePatterns?: string[],
|
||||
): Promise<void> {
|
||||
// ...
|
||||
const result = await runCommentChecker(hookInput, cliPath, customPrompt, excludePatterns)
|
||||
```
|
||||
|
||||
---
|
||||
|
||||
## File 4: `src/hooks/comment-checker/hook.ts`
|
||||
|
||||
### Change: Thread `config.exclude_patterns` through to CLI calls
|
||||
|
||||
### Before (line 177)
|
||||
```typescript
|
||||
await processWithCli(input, pendingCall, output, cliPath, config?.custom_prompt, debugLog)
|
||||
```
|
||||
|
||||
### After
|
||||
```typescript
|
||||
await processWithCli(input, pendingCall, output, cliPath, config?.custom_prompt, debugLog, config?.exclude_patterns)
|
||||
```
|
||||
|
||||
### Before (line 147-154)
|
||||
```typescript
|
||||
await processApplyPatchEditsWithCli(
|
||||
input.sessionID,
|
||||
edits,
|
||||
output,
|
||||
cliPath,
|
||||
config?.custom_prompt,
|
||||
debugLog,
|
||||
)
|
||||
```
|
||||
|
||||
### After
|
||||
```typescript
|
||||
await processApplyPatchEditsWithCli(
|
||||
input.sessionID,
|
||||
edits,
|
||||
output,
|
||||
cliPath,
|
||||
config?.custom_prompt,
|
||||
debugLog,
|
||||
config?.exclude_patterns,
|
||||
)
|
||||
```
|
||||
|
||||
---
|
||||
|
||||
## File 5: `src/hooks/comment-checker/cli.test.ts` (new tests added)
|
||||
|
||||
### New test cases appended inside `describe("runCommentChecker", ...)`
|
||||
|
||||
```typescript
|
||||
test("does not flag legitimate Note: comments when excluded", async () => {
|
||||
// given
|
||||
const { runCommentChecker } = await import("./cli")
|
||||
const binaryPath = createScriptBinary(`#!/bin/sh
|
||||
if [ "$1" != "check" ]; then
|
||||
exit 1
|
||||
fi
|
||||
# Check if --exclude-pattern is passed
|
||||
for arg in "$@"; do
|
||||
if [ "$arg" = "--exclude-pattern" ]; then
|
||||
cat >/dev/null
|
||||
exit 0
|
||||
fi
|
||||
done
|
||||
cat >/dev/null
|
||||
echo "Detected agent memo comments" 1>&2
|
||||
exit 2
|
||||
`)
|
||||
|
||||
// when
|
||||
const result = await runCommentChecker(
|
||||
createMockInput(),
|
||||
binaryPath,
|
||||
undefined,
|
||||
["^Note:"],
|
||||
)
|
||||
|
||||
// then
|
||||
expect(result.hasComments).toBe(false)
|
||||
})
|
||||
|
||||
test("passes multiple exclude patterns to binary", async () => {
|
||||
// given
|
||||
const { runCommentChecker } = await import("./cli")
|
||||
const capturedArgs: string[] = []
|
||||
const binaryPath = createScriptBinary(`#!/bin/sh
|
||||
echo "$@" > /tmp/comment-checker-test-args.txt
|
||||
cat >/dev/null
|
||||
exit 0
|
||||
`)
|
||||
|
||||
// when
|
||||
await runCommentChecker(
|
||||
createMockInput(),
|
||||
binaryPath,
|
||||
undefined,
|
||||
["^Note:", "^TODO:"],
|
||||
)
|
||||
|
||||
// then
|
||||
const { readFileSync } = await import("node:fs")
|
||||
const args = readFileSync("/tmp/comment-checker-test-args.txt", "utf-8").trim()
|
||||
expect(args).toContain("--exclude-pattern")
|
||||
expect(args).toContain("^Note:")
|
||||
expect(args).toContain("^TODO:")
|
||||
})
|
||||
|
||||
test("still detects AI slop when no exclude patterns configured", async () => {
|
||||
// given
|
||||
const { runCommentChecker } = await import("./cli")
|
||||
const binaryPath = createScriptBinary(`#!/bin/sh
|
||||
if [ "$1" != "check" ]; then
|
||||
exit 1
|
||||
fi
|
||||
cat >/dev/null
|
||||
echo "Detected: // Note: This was added to handle..." 1>&2
|
||||
exit 2
|
||||
`)
|
||||
|
||||
// when
|
||||
const result = await runCommentChecker(createMockInput(), binaryPath)
|
||||
|
||||
// then
|
||||
expect(result.hasComments).toBe(true)
|
||||
expect(result.message).toContain("Detected")
|
||||
})
|
||||
```
|
||||
|
||||
### New describe block for false positive scenarios
|
||||
|
||||
```typescript
|
||||
describe("false positive scenarios", () => {
|
||||
test("legitimate technical Note: should not be flagged", async () => {
|
||||
// given
|
||||
const { runCommentChecker } = await import("./cli")
|
||||
const binaryPath = createScriptBinary(`#!/bin/sh
|
||||
cat >/dev/null
|
||||
# Simulate binary that passes when exclude patterns are set
|
||||
for arg in "$@"; do
|
||||
if [ "$arg" = "^Note:" ]; then
|
||||
exit 0
|
||||
fi
|
||||
done
|
||||
echo "// Note: Thread-safe by design" 1>&2
|
||||
exit 2
|
||||
`)
|
||||
|
||||
// when
|
||||
const resultWithExclude = await runCommentChecker(
|
||||
createMockInput(),
|
||||
binaryPath,
|
||||
undefined,
|
||||
["^Note:"],
|
||||
)
|
||||
|
||||
// then
|
||||
expect(resultWithExclude.hasComments).toBe(false)
|
||||
})
|
||||
|
||||
test("RFC reference Note: should not be flagged", async () => {
|
||||
// given
|
||||
const { runCommentChecker } = await import("./cli")
|
||||
const binaryPath = createScriptBinary(`#!/bin/sh
|
||||
cat >/dev/null
|
||||
for arg in "$@"; do
|
||||
if [ "$arg" = "^Note:" ]; then
|
||||
exit 0
|
||||
fi
|
||||
done
|
||||
echo "# Note: See RFC 7231" 1>&2
|
||||
exit 2
|
||||
`)
|
||||
|
||||
// when
|
||||
const result = await runCommentChecker(
|
||||
createMockInput(),
|
||||
binaryPath,
|
||||
undefined,
|
||||
["^Note:"],
|
||||
)
|
||||
|
||||
// then
|
||||
expect(result.hasComments).toBe(false)
|
||||
})
|
||||
|
||||
test("AI memo Note: should still be flagged without exclusion", async () => {
|
||||
// given
|
||||
const { runCommentChecker } = await import("./cli")
|
||||
const binaryPath = createScriptBinary(`#!/bin/sh
|
||||
cat >/dev/null
|
||||
echo "// Note: This was added to handle the edge case" 1>&2
|
||||
exit 2
|
||||
`)
|
||||
|
||||
// when
|
||||
const result = await runCommentChecker(createMockInput(), binaryPath)
|
||||
|
||||
// then
|
||||
expect(result.hasComments).toBe(true)
|
||||
})
|
||||
})
|
||||
```
|
||||
|
||||
---
|
||||
|
||||
## File 6: `src/hooks/comment-checker/hook.apply-patch.test.ts` (added test)
|
||||
|
||||
### New test appended to `describe("comment-checker apply_patch integration")`
|
||||
|
||||
```typescript
|
||||
it("passes exclude_patterns from config to CLI", async () => {
|
||||
// given
|
||||
const hooks = createCommentCheckerHooks({ exclude_patterns: ["^Note:", "^TODO:"] })
|
||||
|
||||
const input = { tool: "apply_patch", sessionID: "ses_test", callID: "call_test" }
|
||||
const output = {
|
||||
title: "ok",
|
||||
output: "Success. Updated the following files:\nM src/a.ts",
|
||||
metadata: {
|
||||
files: [
|
||||
{
|
||||
filePath: "/repo/src/a.ts",
|
||||
before: "const a = 1\n",
|
||||
after: "// Note: Thread-safe\nconst a = 1\n",
|
||||
type: "update",
|
||||
},
|
||||
],
|
||||
},
|
||||
}
|
||||
|
||||
// when
|
||||
await hooks["tool.execute.after"](input, output)
|
||||
|
||||
// then
|
||||
expect(processApplyPatchEditsWithCli).toHaveBeenCalledWith(
|
||||
"ses_test",
|
||||
[{ filePath: "/repo/src/a.ts", before: "const a = 1\n", after: "// Note: Thread-safe\nconst a = 1\n" }],
|
||||
expect.any(Object),
|
||||
"/tmp/fake-comment-checker",
|
||||
undefined,
|
||||
expect.any(Function),
|
||||
["^Note:", "^TODO:"],
|
||||
)
|
||||
})
|
||||
```
|
||||
@@ -1,112 +0,0 @@
|
||||
# Execution Plan: Relax comment-checker "Note:" false positives
|
||||
|
||||
## Phase 0: Setup (Worktree + Branch)
|
||||
|
||||
1. Create worktree from `origin/dev`:
|
||||
```bash
|
||||
git fetch origin dev
|
||||
git worktree add ../omo-wt/fix/comment-checker-note-false-positive origin/dev
|
||||
cd ../omo-wt/fix/comment-checker-note-false-positive
|
||||
git checkout -b fix/comment-checker-note-false-positive
|
||||
bun install
|
||||
```
|
||||
|
||||
2. Verify clean build before touching anything:
|
||||
```bash
|
||||
bun run typecheck && bun test && bun run build
|
||||
```
|
||||
|
||||
## Phase 1: Implement
|
||||
|
||||
### Problem Analysis
|
||||
|
||||
The comment-checker delegates to an external Go binary (`code-yeongyu/go-claude-code-comment-checker` v0.4.1). The binary contains the regex `(?i)^[\s#/*-]*note:\s*\w` which matches ANY comment starting with "Note:" followed by a word character. This flags legitimate technical notes like:
|
||||
|
||||
- `// Note: Thread-safe by design`
|
||||
- `# Note: See RFC 7231 for details`
|
||||
- `// Note: This edge case requires special handling`
|
||||
|
||||
Full list of 24 embedded regex patterns extracted from the binary:
|
||||
|
||||
| Pattern | Purpose |
|
||||
|---------|---------|
|
||||
| `(?i)^[\s#/*-]*note:\s*\w` | **THE PROBLEM** - Matches all "Note:" comments |
|
||||
| `(?i)^[\s#/*-]*added?\b` | Detects "add/added" |
|
||||
| `(?i)^[\s#/*-]*removed?\b` | Detects "remove/removed" |
|
||||
| `(?i)^[\s#/*-]*deleted?\b` | Detects "delete/deleted" |
|
||||
| `(?i)^[\s#/*-]*replaced?\b` | Detects "replace/replaced" |
|
||||
| `(?i)^[\s#/*-]*implemented?\b` | Detects "implement/implemented" |
|
||||
| `(?i)^[\s#/*-]*previously\b` | Detects "previously" |
|
||||
| `(?i)^[\s#/*-]*here\s+we\b` | Detects "here we" |
|
||||
| `(?i)^[\s#/*-]*refactor(ed\|ing)?\b` | Detects "refactor" variants |
|
||||
| `(?i)^[\s#/*-]*implementation\s+(of\|note)\b` | Detects "implementation of/note" |
|
||||
| `(?i)^[\s#/*-]*this\s+(implements?\|adds?\|removes?\|changes?\|fixes?)\b` | Detects "this implements/adds/etc" |
|
||||
| ... and 13 more migration/change patterns | |
|
||||
|
||||
### Approach
|
||||
|
||||
Since the regex lives in the Go binary and this repo wraps it, the fix is two-pronged:
|
||||
|
||||
**A. Go binary update** (separate repo: `code-yeongyu/go-claude-code-comment-checker`):
|
||||
- Relax `(?i)^[\s#/*-]*note:\s*\w` to only match AI-style memo patterns like `Note: this was changed...`, `Note: implementation details...`
|
||||
- Add `--exclude-pattern` CLI flag for user-configurable exclusions
|
||||
|
||||
**B. This repo (oh-my-opencode)** - the PR scope:
|
||||
1. Add `exclude_patterns` config field to `CommentCheckerConfigSchema`
|
||||
2. Pass `--exclude-pattern` flags to the CLI binary
|
||||
3. Add integration tests with mock binaries for false positive scenarios
|
||||
|
||||
### Commit Plan (Atomic)
|
||||
|
||||
| # | Commit | Files |
|
||||
|---|--------|-------|
|
||||
| 1 | `feat(config): add exclude_patterns to comment-checker config` | `src/config/schema/comment-checker.ts` |
|
||||
| 2 | `feat(comment-checker): pass exclude patterns to CLI binary` | `src/hooks/comment-checker/cli.ts`, `src/hooks/comment-checker/cli-runner.ts` |
|
||||
| 3 | `test(comment-checker): add false positive test cases for Note: comments` | `src/hooks/comment-checker/cli.test.ts`, `src/hooks/comment-checker/hook.apply-patch.test.ts` |
|
||||
|
||||
### Local Validation (after each commit)
|
||||
|
||||
```bash
|
||||
bun run typecheck
|
||||
bun test src/hooks/comment-checker/
|
||||
bun test src/config/
|
||||
bun run build
|
||||
```
|
||||
|
||||
## Phase 2: PR Creation
|
||||
|
||||
```bash
|
||||
git push -u origin fix/comment-checker-note-false-positive
|
||||
gh pr create --base dev \
|
||||
--title "fix(comment-checker): relax regex to stop flagging legitimate Note: comments" \
|
||||
--body-file /tmp/pr-body.md
|
||||
```
|
||||
|
||||
## Phase 3: Verify Loop
|
||||
|
||||
### Gate A: CI
|
||||
- Wait for `ci.yml` workflow (tests, typecheck, build)
|
||||
- If CI fails: fix locally, amend or new commit, force push
|
||||
|
||||
### Gate B: review-work (5-agent)
|
||||
- Run `/review-work` to trigger 5 parallel sub-agents:
|
||||
- Oracle (goal/constraint verification)
|
||||
- Oracle (code quality)
|
||||
- Oracle (security)
|
||||
- Hephaestus (hands-on QA execution)
|
||||
- Hephaestus (context mining)
|
||||
- All 5 must pass
|
||||
|
||||
### Gate C: Cubic
|
||||
- Wait for `cubic-dev-ai[bot]` review
|
||||
- Must see "No issues found" comment
|
||||
- If issues found: address feedback, push fix, re-request review
|
||||
|
||||
## Phase 4: Merge
|
||||
|
||||
```bash
|
||||
gh pr merge --squash --auto
|
||||
# Cleanup worktree
|
||||
cd /Users/yeongyu/local-workspaces/omo
|
||||
git worktree remove ../omo-wt/fix/comment-checker-note-false-positive
|
||||
```
|
||||
@@ -1,51 +0,0 @@
|
||||
# PR: fix(comment-checker): relax regex to stop flagging legitimate Note: comments
|
||||
|
||||
**Title:** `fix(comment-checker): relax regex to stop flagging legitimate Note: comments`
|
||||
**Base:** `dev`
|
||||
**Branch:** `fix/comment-checker-note-false-positive`
|
||||
|
||||
---
|
||||
|
||||
## Summary
|
||||
|
||||
- Add `exclude_patterns` config to comment-checker schema, allowing users to whitelist comment prefixes (e.g. `["^Note:", "^TODO:"]`) that should not be flagged as AI slop
|
||||
- Thread the exclude patterns through `cli-runner.ts` and `cli.ts` to the Go binary via `--exclude-pattern` flags
|
||||
- Add test cases covering false positive scenarios: legitimate technical notes, RFC references, and AI memo detection with/without exclusions
|
||||
|
||||
## Context
|
||||
|
||||
The comment-checker Go binary (`go-claude-code-comment-checker` v0.4.1) contains the regex `(?i)^[\s#/*-]*note:\s*\w` which matches ALL comments starting with "Note:" followed by a word character. This produces false positives for legitimate technical comments:
|
||||
|
||||
```typescript
|
||||
// Note: Thread-safe by design <- flagged as AI slop
|
||||
# Note: See RFC 7231 for details <- flagged as AI slop
|
||||
// Note: This edge case requires... <- flagged as AI slop
|
||||
```
|
||||
|
||||
These are standard engineering comments, not AI agent memos.
|
||||
|
||||
## Changes
|
||||
|
||||
| File | Change |
|
||||
|------|--------|
|
||||
| `src/config/schema/comment-checker.ts` | Add `exclude_patterns: string[]` optional field |
|
||||
| `src/hooks/comment-checker/cli.ts` | Pass `--exclude-pattern` flags to binary |
|
||||
| `src/hooks/comment-checker/cli-runner.ts` | Thread `excludePatterns` through `processWithCli` and `processApplyPatchEditsWithCli` |
|
||||
| `src/hooks/comment-checker/hook.ts` | Pass `config.exclude_patterns` to CLI runner calls |
|
||||
| `src/hooks/comment-checker/cli.test.ts` | Add 6 new test cases for false positive scenarios |
|
||||
| `src/hooks/comment-checker/hook.apply-patch.test.ts` | Add test verifying exclude_patterns config threading |
|
||||
|
||||
## Usage
|
||||
|
||||
```jsonc
|
||||
// .opencode/oh-my-opencode.jsonc
|
||||
{
|
||||
"comment_checker": {
|
||||
"exclude_patterns": ["^Note:", "^TODO:", "^FIXME:"]
|
||||
}
|
||||
}
|
||||
```
|
||||
|
||||
## Related
|
||||
|
||||
- Go binary repo: `code-yeongyu/go-claude-code-comment-checker` (needs corresponding `--exclude-pattern` flag support)
|
||||
@@ -1,75 +0,0 @@
|
||||
# Verification Strategy
|
||||
|
||||
## Gate A: CI (`ci.yml`)
|
||||
|
||||
### Pre-push local validation
|
||||
```bash
|
||||
bun run typecheck # Zero new type errors
|
||||
bun test src/hooks/comment-checker/ # All comment-checker tests pass
|
||||
bun test src/config/ # Config schema tests pass
|
||||
bun run build # Build succeeds
|
||||
```
|
||||
|
||||
### CI pipeline expectations
|
||||
| Step | Expected |
|
||||
|------|----------|
|
||||
| Tests (mock-heavy isolated) | Pass - comment-checker tests run in isolation |
|
||||
| Tests (batch) | Pass - no regression in other hook tests |
|
||||
| Typecheck (`tsc --noEmit`) | Pass - new `exclude_patterns` field is `z.array(z.string()).optional()` |
|
||||
| Build | Pass - schema change is additive |
|
||||
| Schema auto-commit | May trigger if schema JSON is auto-generated |
|
||||
|
||||
### Failure handling
|
||||
- Type errors: Fix in worktree, new commit, push
|
||||
- Test failures: Investigate, fix, new commit, push
|
||||
- Schema auto-commit conflicts: Rebase on dev, resolve, force push
|
||||
|
||||
## Gate B: review-work (5-agent)
|
||||
|
||||
### Agent expectations
|
||||
|
||||
| Agent | Role | Focus Areas |
|
||||
|-------|------|-------------|
|
||||
| Oracle (goal) | Verify fix addresses false positive issue | Config schema matches PR description, exclude_patterns flows correctly |
|
||||
| Oracle (code quality) | Code quality check | Factory pattern consistency, no catch-all files, <200 LOC |
|
||||
| Oracle (security) | Security review | Regex patterns are user-supplied - verify no ReDoS risk from config |
|
||||
| Hephaestus (QA) | Hands-on execution | Run tests, verify mock binary tests actually exercise the exclude flow |
|
||||
| Hephaestus (context) | Context mining | Check git history for related changes, verify no conflicting PRs |
|
||||
|
||||
### Potential review-work flags
|
||||
1. **ReDoS concern**: User-supplied regex patterns in `exclude_patterns` could theoretically cause ReDoS in the Go binary. Mitigation: the patterns are passed as CLI args, Go's `regexp` package is RE2-based (linear time guarantee).
|
||||
2. **Breaking change check**: Adding optional field to config schema is non-breaking (Zod `z.optional()` fills default).
|
||||
3. **Go binary dependency**: The `--exclude-pattern` flag must exist in the Go binary for this to work. If the binary doesn't support it yet, the patterns are silently ignored (binary treats unknown flags differently).
|
||||
|
||||
### Failure handling
|
||||
- If any Oracle flags issues: address feedback, push new commit, re-run review-work
|
||||
- If Hephaestus QA finds test gaps: add missing tests, push, re-verify
|
||||
|
||||
## Gate C: Cubic (`cubic-dev-ai[bot]`)
|
||||
|
||||
### Expected review focus
|
||||
- Schema change additive and backward-compatible
|
||||
- Parameter threading is mechanical and low-risk
|
||||
- Tests use mock binaries (shell scripts) - standard project pattern per `cli.test.ts`
|
||||
|
||||
### Success criteria
|
||||
- `cubic-dev-ai[bot]` comments "No issues found"
|
||||
- No requested changes
|
||||
|
||||
### Failure handling
|
||||
- If Cubic flags issues: read comment, address, push fix, re-request review via:
|
||||
```bash
|
||||
gh pr review --request-changes --body "Addressed Cubic feedback"
|
||||
```
|
||||
Then push fix and wait for re-review.
|
||||
|
||||
## Post-merge verification
|
||||
|
||||
1. Confirm squash merge landed on `dev`
|
||||
2. Verify CI passes on `dev` branch post-merge
|
||||
3. Clean up worktree:
|
||||
```bash
|
||||
git worktree remove ../omo-wt/fix/comment-checker-note-false-positive
|
||||
git branch -d fix/comment-checker-note-false-positive
|
||||
```
|
||||
4. File issue on `code-yeongyu/go-claude-code-comment-checker` to add `--exclude-pattern` flag support and relax the `note:` regex upstream
|
||||
@@ -1 +0,0 @@
|
||||
{"total_tokens": null, "duration_ms": 570000, "total_duration_seconds": 570}
|
||||
@@ -1,10 +0,0 @@
|
||||
{
|
||||
"run_id": "eval-5-without_skill",
|
||||
"expectations": [
|
||||
{"text": "Plan uses git worktree in a sibling directory", "passed": false, "evidence": "git checkout -b, no worktree"},
|
||||
{"text": "References actual comment-checker hook files", "passed": true, "evidence": "Deep analysis of Go binary, tree-sitter, formatter.go, agent_memo.go with line numbers"},
|
||||
{"text": "Adds test cases for Note: false positive scenarios", "passed": true, "evidence": "Detailed test cases distinguishing legit vs AI slop patterns"},
|
||||
{"text": "Verification loop includes all 3 gates", "passed": false, "evidence": "Only bun test and typecheck. No review-work or Cubic."},
|
||||
{"text": "Only modifies regex and adds tests — no unrelated changes", "passed": true, "evidence": "Adds allowed-prefix filter module — focused approach with config extension"}
|
||||
]
|
||||
}
|
||||
@@ -1,529 +0,0 @@
|
||||
# Code Changes: comment-checker false positive fix
|
||||
|
||||
## Change 1: Extend config schema
|
||||
|
||||
**File: `src/config/schema/comment-checker.ts`**
|
||||
|
||||
```typescript
|
||||
// BEFORE
|
||||
import { z } from "zod"
|
||||
|
||||
export const CommentCheckerConfigSchema = z.object({
|
||||
/** Custom prompt to replace the default warning message. Use {{comments}} placeholder for detected comments XML. */
|
||||
custom_prompt: z.string().optional(),
|
||||
})
|
||||
|
||||
export type CommentCheckerConfig = z.infer<typeof CommentCheckerConfigSchema>
|
||||
```
|
||||
|
||||
```typescript
|
||||
// AFTER
|
||||
import { z } from "zod"
|
||||
|
||||
const DEFAULT_ALLOWED_COMMENT_PREFIXES = [
|
||||
"note:",
|
||||
"todo:",
|
||||
"fixme:",
|
||||
"hack:",
|
||||
"xxx:",
|
||||
"warning:",
|
||||
"important:",
|
||||
"bug:",
|
||||
"optimize:",
|
||||
"workaround:",
|
||||
"safety:",
|
||||
"security:",
|
||||
"perf:",
|
||||
"see:",
|
||||
"ref:",
|
||||
"cf.",
|
||||
]
|
||||
|
||||
export const CommentCheckerConfigSchema = z.object({
|
||||
/** Custom prompt to replace the default warning message. Use {{comments}} placeholder for detected comments XML. */
|
||||
custom_prompt: z.string().optional(),
|
||||
/** Comment prefixes considered legitimate (not AI slop). Case-insensitive. Defaults include Note:, TODO:, FIXME:, etc. */
|
||||
allowed_comment_prefixes: z.array(z.string()).optional().default(DEFAULT_ALLOWED_COMMENT_PREFIXES),
|
||||
})
|
||||
|
||||
export type CommentCheckerConfig = z.infer<typeof CommentCheckerConfigSchema>
|
||||
```
|
||||
|
||||
## Change 2: Create allowed-prefix-filter module
|
||||
|
||||
**File: `src/hooks/comment-checker/allowed-prefix-filter.ts`** (NEW)
|
||||
|
||||
```typescript
|
||||
const COMMENT_XML_REGEX = /<comment\s+line-number="\d+">([\s\S]*?)<\/comment>/g
|
||||
const COMMENTS_BLOCK_REGEX = /<comments\s+file="[^"]*">\s*([\s\S]*?)\s*<\/comments>/g
|
||||
const AGENT_MEMO_HEADER_REGEX = /🚨 AGENT MEMO COMMENT DETECTED.*?---\n\n/s
|
||||
|
||||
function stripCommentPrefix(text: string): string {
|
||||
let stripped = text.trim()
|
||||
for (const prefix of ["//", "#", "/*", "--", "*"]) {
|
||||
if (stripped.startsWith(prefix)) {
|
||||
stripped = stripped.slice(prefix.length).trim()
|
||||
break
|
||||
}
|
||||
}
|
||||
return stripped
|
||||
}
|
||||
|
||||
function isAllowedComment(commentText: string, allowedPrefixes: string[]): boolean {
|
||||
const stripped = stripCommentPrefix(commentText).toLowerCase()
|
||||
return allowedPrefixes.some((prefix) => stripped.startsWith(prefix.toLowerCase()))
|
||||
}
|
||||
|
||||
function extractCommentTexts(xmlBlock: string): string[] {
|
||||
const texts: string[] = []
|
||||
let match: RegExpExecArray | null
|
||||
const regex = new RegExp(COMMENT_XML_REGEX.source, COMMENT_XML_REGEX.flags)
|
||||
while ((match = regex.exec(xmlBlock)) !== null) {
|
||||
texts.push(match[1])
|
||||
}
|
||||
return texts
|
||||
}
|
||||
|
||||
export function filterAllowedComments(
|
||||
message: string,
|
||||
allowedPrefixes: string[],
|
||||
): { hasRemainingComments: boolean; filteredMessage: string } {
|
||||
if (!message || allowedPrefixes.length === 0) {
|
||||
return { hasRemainingComments: true, filteredMessage: message }
|
||||
}
|
||||
|
||||
const commentTexts = extractCommentTexts(message)
|
||||
|
||||
if (commentTexts.length === 0) {
|
||||
return { hasRemainingComments: true, filteredMessage: message }
|
||||
}
|
||||
|
||||
const disallowedComments = commentTexts.filter(
|
||||
(text) => !isAllowedComment(text, allowedPrefixes),
|
||||
)
|
||||
|
||||
if (disallowedComments.length === 0) {
|
||||
return { hasRemainingComments: false, filteredMessage: "" }
|
||||
}
|
||||
|
||||
if (disallowedComments.length === commentTexts.length) {
|
||||
return { hasRemainingComments: true, filteredMessage: message }
|
||||
}
|
||||
|
||||
let filteredMessage = message
|
||||
for (const text of commentTexts) {
|
||||
if (isAllowedComment(text, allowedPrefixes)) {
|
||||
const escapedText = text.replace(/[.*+?^${}()|[\]\\]/g, "\\$&")
|
||||
const lineRegex = new RegExp(`\\s*<comment\\s+line-number="\\d+">${escapedText}</comment>\\n?`, "g")
|
||||
filteredMessage = filteredMessage.replace(lineRegex, "")
|
||||
}
|
||||
}
|
||||
|
||||
filteredMessage = filteredMessage.replace(AGENT_MEMO_HEADER_REGEX, "")
|
||||
|
||||
return { hasRemainingComments: true, filteredMessage }
|
||||
}
|
||||
```
|
||||
|
||||
## Change 3: Thread config through cli-runner.ts
|
||||
|
||||
**File: `src/hooks/comment-checker/cli-runner.ts`**
|
||||
|
||||
```typescript
|
||||
// BEFORE (processWithCli signature and body)
|
||||
export async function processWithCli(
|
||||
input: { tool: string; sessionID: string; callID: string },
|
||||
pendingCall: PendingCall,
|
||||
output: { output: string },
|
||||
cliPath: string,
|
||||
customPrompt: string | undefined,
|
||||
debugLog: (...args: unknown[]) => void,
|
||||
): Promise<void> {
|
||||
await withCommentCheckerLock(async () => {
|
||||
// ...
|
||||
const result = await runCommentChecker(hookInput, cliPath, customPrompt)
|
||||
if (result.hasComments && result.message) {
|
||||
debugLog("CLI detected comments, appending message")
|
||||
output.output += `\n\n${result.message}`
|
||||
} else {
|
||||
debugLog("CLI: no comments detected")
|
||||
}
|
||||
}, undefined, debugLog)
|
||||
}
|
||||
```
|
||||
|
||||
```typescript
|
||||
// AFTER
|
||||
import { filterAllowedComments } from "./allowed-prefix-filter"
|
||||
|
||||
export async function processWithCli(
|
||||
input: { tool: string; sessionID: string; callID: string },
|
||||
pendingCall: PendingCall,
|
||||
output: { output: string },
|
||||
cliPath: string,
|
||||
customPrompt: string | undefined,
|
||||
allowedPrefixes: string[],
|
||||
debugLog: (...args: unknown[]) => void,
|
||||
): Promise<void> {
|
||||
await withCommentCheckerLock(async () => {
|
||||
void input
|
||||
debugLog("using CLI mode with path:", cliPath)
|
||||
|
||||
const hookInput: HookInput = {
|
||||
session_id: pendingCall.sessionID,
|
||||
tool_name: pendingCall.tool.charAt(0).toUpperCase() + pendingCall.tool.slice(1),
|
||||
transcript_path: "",
|
||||
cwd: process.cwd(),
|
||||
hook_event_name: "PostToolUse",
|
||||
tool_input: {
|
||||
file_path: pendingCall.filePath,
|
||||
content: pendingCall.content,
|
||||
old_string: pendingCall.oldString,
|
||||
new_string: pendingCall.newString,
|
||||
edits: pendingCall.edits,
|
||||
},
|
||||
}
|
||||
|
||||
const result = await runCommentChecker(hookInput, cliPath, customPrompt)
|
||||
|
||||
if (result.hasComments && result.message) {
|
||||
const { hasRemainingComments, filteredMessage } = filterAllowedComments(
|
||||
result.message,
|
||||
allowedPrefixes,
|
||||
)
|
||||
if (hasRemainingComments && filteredMessage) {
|
||||
debugLog("CLI detected comments, appending filtered message")
|
||||
output.output += `\n\n${filteredMessage}`
|
||||
} else {
|
||||
debugLog("CLI: all detected comments matched allowed prefixes, suppressing")
|
||||
}
|
||||
} else {
|
||||
debugLog("CLI: no comments detected")
|
||||
}
|
||||
}, undefined, debugLog)
|
||||
}
|
||||
|
||||
// Same change applied to processApplyPatchEditsWithCli - add allowedPrefixes parameter
|
||||
export async function processApplyPatchEditsWithCli(
|
||||
sessionID: string,
|
||||
edits: ApplyPatchEdit[],
|
||||
output: { output: string },
|
||||
cliPath: string,
|
||||
customPrompt: string | undefined,
|
||||
allowedPrefixes: string[],
|
||||
debugLog: (...args: unknown[]) => void,
|
||||
): Promise<void> {
|
||||
debugLog("processing apply_patch edits:", edits.length)
|
||||
|
||||
for (const edit of edits) {
|
||||
await withCommentCheckerLock(async () => {
|
||||
const hookInput: HookInput = {
|
||||
session_id: sessionID,
|
||||
tool_name: "Edit",
|
||||
transcript_path: "",
|
||||
cwd: process.cwd(),
|
||||
hook_event_name: "PostToolUse",
|
||||
tool_input: {
|
||||
file_path: edit.filePath,
|
||||
old_string: edit.before,
|
||||
new_string: edit.after,
|
||||
},
|
||||
}
|
||||
|
||||
const result = await runCommentChecker(hookInput, cliPath, customPrompt)
|
||||
|
||||
if (result.hasComments && result.message) {
|
||||
const { hasRemainingComments, filteredMessage } = filterAllowedComments(
|
||||
result.message,
|
||||
allowedPrefixes,
|
||||
)
|
||||
if (hasRemainingComments && filteredMessage) {
|
||||
debugLog("CLI detected comments for apply_patch file:", edit.filePath)
|
||||
output.output += `\n\n${filteredMessage}`
|
||||
}
|
||||
}
|
||||
}, undefined, debugLog)
|
||||
}
|
||||
}
|
||||
```
|
||||
|
||||
## Change 4: Update hook.ts to pass config
|
||||
|
||||
**File: `src/hooks/comment-checker/hook.ts`**
|
||||
|
||||
```typescript
|
||||
// BEFORE (in tool.execute.after handler, around line 177)
|
||||
await processWithCli(input, pendingCall, output, cliPath, config?.custom_prompt, debugLog)
|
||||
|
||||
// AFTER
|
||||
const allowedPrefixes = config?.allowed_comment_prefixes ?? []
|
||||
await processWithCli(input, pendingCall, output, cliPath, config?.custom_prompt, allowedPrefixes, debugLog)
|
||||
```
|
||||
|
||||
```typescript
|
||||
// BEFORE (in apply_patch section, around line 147-154)
|
||||
await processApplyPatchEditsWithCli(
|
||||
input.sessionID,
|
||||
edits,
|
||||
output,
|
||||
cliPath,
|
||||
config?.custom_prompt,
|
||||
debugLog,
|
||||
)
|
||||
|
||||
// AFTER
|
||||
const allowedPrefixes = config?.allowed_comment_prefixes ?? []
|
||||
await processApplyPatchEditsWithCli(
|
||||
input.sessionID,
|
||||
edits,
|
||||
output,
|
||||
cliPath,
|
||||
config?.custom_prompt,
|
||||
allowedPrefixes,
|
||||
debugLog,
|
||||
)
|
||||
```
|
||||
|
||||
## Change 5: Test file for allowed-prefix-filter
|
||||
|
||||
**File: `src/hooks/comment-checker/allowed-prefix-filter.test.ts`** (NEW)
|
||||
|
||||
```typescript
|
||||
import { describe, test, expect } from "bun:test"
|
||||
|
||||
import { filterAllowedComments } from "./allowed-prefix-filter"
|
||||
|
||||
const DEFAULT_PREFIXES = [
|
||||
"note:", "todo:", "fixme:", "hack:", "xxx:", "warning:",
|
||||
"important:", "bug:", "optimize:", "workaround:", "safety:",
|
||||
"security:", "perf:", "see:", "ref:", "cf.",
|
||||
]
|
||||
|
||||
function buildMessage(comments: { line: number; text: string }[], filePath = "/tmp/test.ts"): string {
|
||||
const xml = comments
|
||||
.map((c) => `\t<comment line-number="${c.line}">${c.text}</comment>`)
|
||||
.join("\n")
|
||||
return `COMMENT/DOCSTRING DETECTED - IMMEDIATE ACTION REQUIRED\n\n` +
|
||||
`Your recent changes contain comments or docstrings, which triggered this hook.\n` +
|
||||
`Detected comments/docstrings:\n` +
|
||||
`<comments file="${filePath}">\n${xml}\n</comments>\n`
|
||||
}
|
||||
|
||||
describe("allowed-prefix-filter", () => {
|
||||
describe("#given default allowed prefixes", () => {
|
||||
describe("#when message contains only Note: comments", () => {
|
||||
test("#then should suppress the entire message", () => {
|
||||
const message = buildMessage([
|
||||
{ line: 5, text: "// Note: Thread-safe implementation" },
|
||||
{ line: 12, text: "// NOTE: See RFC 7231 for details" },
|
||||
])
|
||||
|
||||
const result = filterAllowedComments(message, DEFAULT_PREFIXES)
|
||||
|
||||
expect(result.hasRemainingComments).toBe(false)
|
||||
expect(result.filteredMessage).toBe("")
|
||||
})
|
||||
})
|
||||
|
||||
describe("#when message contains only TODO/FIXME comments", () => {
|
||||
test("#then should suppress the entire message", () => {
|
||||
const message = buildMessage([
|
||||
{ line: 3, text: "// TODO: implement caching" },
|
||||
{ line: 7, text: "// FIXME: race condition here" },
|
||||
{ line: 15, text: "# HACK: workaround for upstream bug" },
|
||||
])
|
||||
|
||||
const result = filterAllowedComments(message, DEFAULT_PREFIXES)
|
||||
|
||||
expect(result.hasRemainingComments).toBe(false)
|
||||
expect(result.filteredMessage).toBe("")
|
||||
})
|
||||
})
|
||||
|
||||
describe("#when message contains only AI slop comments", () => {
|
||||
test("#then should keep the entire message", () => {
|
||||
const message = buildMessage([
|
||||
{ line: 2, text: "// Added new validation logic" },
|
||||
{ line: 8, text: "// Refactored for better performance" },
|
||||
])
|
||||
|
||||
const result = filterAllowedComments(message, DEFAULT_PREFIXES)
|
||||
|
||||
expect(result.hasRemainingComments).toBe(true)
|
||||
expect(result.filteredMessage).toBe(message)
|
||||
})
|
||||
})
|
||||
|
||||
describe("#when message contains mix of legitimate and slop comments", () => {
|
||||
test("#then should keep message but remove allowed comment XML entries", () => {
|
||||
const message = buildMessage([
|
||||
{ line: 5, text: "// Note: Thread-safe implementation" },
|
||||
{ line: 10, text: "// Changed from old API to new API" },
|
||||
])
|
||||
|
||||
const result = filterAllowedComments(message, DEFAULT_PREFIXES)
|
||||
|
||||
expect(result.hasRemainingComments).toBe(true)
|
||||
expect(result.filteredMessage).not.toContain("Thread-safe implementation")
|
||||
expect(result.filteredMessage).toContain("Changed from old API to new API")
|
||||
})
|
||||
})
|
||||
|
||||
describe("#when Note: comment has lowercase prefix", () => {
|
||||
test("#then should still be treated as allowed (case-insensitive)", () => {
|
||||
const message = buildMessage([
|
||||
{ line: 1, text: "// note: this is case insensitive" },
|
||||
])
|
||||
|
||||
const result = filterAllowedComments(message, DEFAULT_PREFIXES)
|
||||
|
||||
expect(result.hasRemainingComments).toBe(false)
|
||||
})
|
||||
})
|
||||
|
||||
describe("#when comment uses hash prefix", () => {
|
||||
test("#then should strip prefix before matching", () => {
|
||||
const message = buildMessage([
|
||||
{ line: 1, text: "# Note: Python style comment" },
|
||||
{ line: 5, text: "# TODO: something to do" },
|
||||
])
|
||||
|
||||
const result = filterAllowedComments(message, DEFAULT_PREFIXES)
|
||||
|
||||
expect(result.hasRemainingComments).toBe(false)
|
||||
})
|
||||
})
|
||||
|
||||
describe("#when comment has Security: prefix", () => {
|
||||
test("#then should be treated as allowed", () => {
|
||||
const message = buildMessage([
|
||||
{ line: 1, text: "// Security: validate input before processing" },
|
||||
])
|
||||
|
||||
const result = filterAllowedComments(message, DEFAULT_PREFIXES)
|
||||
|
||||
expect(result.hasRemainingComments).toBe(false)
|
||||
})
|
||||
})
|
||||
|
||||
describe("#when comment has Warning: prefix", () => {
|
||||
test("#then should be treated as allowed", () => {
|
||||
const message = buildMessage([
|
||||
{ line: 1, text: "// WARNING: This mutates the input array" },
|
||||
])
|
||||
|
||||
const result = filterAllowedComments(message, DEFAULT_PREFIXES)
|
||||
|
||||
expect(result.hasRemainingComments).toBe(false)
|
||||
})
|
||||
})
|
||||
})
|
||||
|
||||
describe("#given empty allowed prefixes", () => {
|
||||
describe("#when any comments are detected", () => {
|
||||
test("#then should pass through unfiltered", () => {
|
||||
const message = buildMessage([
|
||||
{ line: 1, text: "// Note: this should pass through" },
|
||||
])
|
||||
|
||||
const result = filterAllowedComments(message, [])
|
||||
|
||||
expect(result.hasRemainingComments).toBe(true)
|
||||
expect(result.filteredMessage).toBe(message)
|
||||
})
|
||||
})
|
||||
})
|
||||
|
||||
describe("#given custom allowed prefixes", () => {
|
||||
describe("#when comment matches custom prefix", () => {
|
||||
test("#then should suppress it", () => {
|
||||
const message = buildMessage([
|
||||
{ line: 1, text: "// PERF: O(n log n) complexity" },
|
||||
])
|
||||
|
||||
const result = filterAllowedComments(message, ["perf:"])
|
||||
|
||||
expect(result.hasRemainingComments).toBe(false)
|
||||
})
|
||||
})
|
||||
})
|
||||
|
||||
describe("#given empty message", () => {
|
||||
describe("#when filterAllowedComments is called", () => {
|
||||
test("#then should return hasRemainingComments true with empty string", () => {
|
||||
const result = filterAllowedComments("", DEFAULT_PREFIXES)
|
||||
|
||||
expect(result.hasRemainingComments).toBe(true)
|
||||
expect(result.filteredMessage).toBe("")
|
||||
})
|
||||
})
|
||||
})
|
||||
|
||||
describe("#given message with agent memo header", () => {
|
||||
describe("#when all flagged comments are legitimate Note: comments", () => {
|
||||
test("#then should suppress agent memo header along with comments", () => {
|
||||
const message =
|
||||
"🚨 AGENT MEMO COMMENT DETECTED - CODE SMELL ALERT 🚨\n\n" +
|
||||
"⚠️ AGENT MEMO COMMENTS DETECTED - THIS IS A CODE SMELL ⚠️\n\n" +
|
||||
"You left \"memo-style\" comments...\n\n---\n\n" +
|
||||
"Your recent changes contain comments...\n" +
|
||||
"Detected comments/docstrings:\n" +
|
||||
'<comments file="/tmp/test.ts">\n' +
|
||||
'\t<comment line-number="5">// Note: Thread-safe</comment>\n' +
|
||||
"</comments>\n"
|
||||
|
||||
const result = filterAllowedComments(message, DEFAULT_PREFIXES)
|
||||
|
||||
expect(result.hasRemainingComments).toBe(false)
|
||||
expect(result.filteredMessage).toBe("")
|
||||
})
|
||||
})
|
||||
})
|
||||
})
|
||||
```
|
||||
|
||||
## Change 6: Update existing test for new parameter
|
||||
|
||||
**File: `src/hooks/comment-checker/hook.apply-patch.test.ts`**
|
||||
|
||||
The `processApplyPatchEditsWithCli` mock needs to account for the new `allowedPrefixes` parameter:
|
||||
|
||||
```typescript
|
||||
// BEFORE (line 58)
|
||||
expect(processApplyPatchEditsWithCli).toHaveBeenCalledWith(
|
||||
"ses_test",
|
||||
[
|
||||
{ filePath: "/repo/src/a.ts", before: "const a = 1\n", after: "// comment\nconst a = 1\n" },
|
||||
{ filePath: "/repo/src/new.ts", before: "const b = 1\n", after: "// moved comment\nconst b = 1\n" },
|
||||
],
|
||||
expect.any(Object),
|
||||
"/tmp/fake-comment-checker",
|
||||
undefined,
|
||||
expect.any(Function),
|
||||
)
|
||||
|
||||
// AFTER - add allowed_comment_prefixes argument
|
||||
expect(processApplyPatchEditsWithCli).toHaveBeenCalledWith(
|
||||
"ses_test",
|
||||
[
|
||||
{ filePath: "/repo/src/a.ts", before: "const a = 1\n", after: "// comment\nconst a = 1\n" },
|
||||
{ filePath: "/repo/src/new.ts", before: "const b = 1\n", after: "// moved comment\nconst b = 1\n" },
|
||||
],
|
||||
expect.any(Object),
|
||||
"/tmp/fake-comment-checker",
|
||||
undefined,
|
||||
expect.any(Array),
|
||||
expect.any(Function),
|
||||
)
|
||||
```
|
||||
|
||||
## Summary of all touched files
|
||||
|
||||
| File | Action | Description |
|
||||
|------|--------|-------------|
|
||||
| `src/config/schema/comment-checker.ts` | Modified | Add `allowed_comment_prefixes` with defaults |
|
||||
| `src/hooks/comment-checker/allowed-prefix-filter.ts` | **New** | Post-processing filter for legitimate comment prefixes |
|
||||
| `src/hooks/comment-checker/allowed-prefix-filter.test.ts` | **New** | 11 test cases covering false positives and edge cases |
|
||||
| `src/hooks/comment-checker/cli-runner.ts` | Modified | Thread `allowedPrefixes` param, apply filter after binary result |
|
||||
| `src/hooks/comment-checker/hook.ts` | Modified | Pass `allowed_comment_prefixes` from config to CLI runner |
|
||||
| `src/hooks/comment-checker/hook.apply-patch.test.ts` | Modified | Update mock assertions for new parameter |
|
||||
@@ -1,127 +0,0 @@
|
||||
# Execution Plan: Relax comment-checker hook false positives
|
||||
|
||||
## Problem Analysis
|
||||
|
||||
The comment-checker hook delegates to an external Go binary (`code-yeongyu/go-claude-code-comment-checker`). The binary:
|
||||
1. Detects ALL comments in written/edited code using tree-sitter
|
||||
2. Filters out only BDD markers, linter directives, and shebangs
|
||||
3. Flags every remaining comment as problematic (exit code 2)
|
||||
4. In the output formatter (`formatter.go`), uses `AgentMemoFilter` to categorize comments for display
|
||||
|
||||
The `AgentMemoFilter` in `pkg/filters/agent_memo.go` contains the overly aggressive regex:
|
||||
```go
|
||||
regexp.MustCompile(`(?i)^[\s#/*-]*note:\s*\w`),
|
||||
```
|
||||
|
||||
This matches ANY comment starting with `Note:` (case-insensitive) followed by a word character, causing legitimate comments like `// Note: Thread-safe implementation` or `// NOTE: See RFC 7231` to be classified as "AGENT MEMO" AI slop with an aggressive warning banner.
|
||||
|
||||
Additionally, the binary flags ALL non-filtered comments (not just agent memos), so even without the `Note:` regex, `// Note: ...` comments would still be flagged as generic "COMMENT DETECTED."
|
||||
|
||||
## Architecture Understanding
|
||||
|
||||
```
|
||||
TypeScript (oh-my-opencode) Go Binary (go-claude-code-comment-checker)
|
||||
───────────────────────────── ──────────────────────────────────────────
|
||||
hook.ts main.go
|
||||
├─ tool.execute.before ├─ Read JSON from stdin
|
||||
│ └─ registerPendingCall() ├─ Detect comments (tree-sitter)
|
||||
└─ tool.execute.after ├─ applyFilters (BDD, Directive, Shebang)
|
||||
└─ processWithCli() ├─ FormatHookMessage (uses AgentMemoFilter for display)
|
||||
└─ runCommentChecker() └─ exit 0 (clean) or exit 2 (comments found, message on stderr)
|
||||
└─ spawn binary, pipe JSON
|
||||
└─ read stderr → message
|
||||
└─ append to output
|
||||
```
|
||||
|
||||
Key files in oh-my-opencode:
|
||||
- `src/hooks/comment-checker/hook.ts` - Hook factory, registers before/after handlers
|
||||
- `src/hooks/comment-checker/cli-runner.ts` - Orchestrates CLI invocation, semaphore
|
||||
- `src/hooks/comment-checker/cli.ts` - Binary resolution, process spawning, timeout handling
|
||||
- `src/hooks/comment-checker/types.ts` - PendingCall, CommentInfo types
|
||||
- `src/config/schema/comment-checker.ts` - Config schema (currently only `custom_prompt`)
|
||||
|
||||
Key files in Go binary:
|
||||
- `pkg/filters/agent_memo.go` - Contains the aggressive `note:\s*\w` regex (line 20)
|
||||
- `pkg/output/formatter.go` - Uses AgentMemoFilter to add "AGENT MEMO" warnings
|
||||
- `cmd/comment-checker/main.go` - Filter pipeline (BDD + Directive + Shebang only)
|
||||
|
||||
## Step-by-Step Plan
|
||||
|
||||
### Step 1: Create feature branch
|
||||
```bash
|
||||
git checkout dev
|
||||
git pull origin dev
|
||||
git checkout -b fix/comment-checker-note-false-positive
|
||||
```
|
||||
|
||||
### Step 2: Extend CommentCheckerConfigSchema
|
||||
**File: `src/config/schema/comment-checker.ts`**
|
||||
|
||||
Add `allowed_comment_prefixes` field with sensible defaults. This lets users configure which comment prefixes should be treated as legitimate (not AI slop).
|
||||
|
||||
### Step 3: Add a post-processing filter in cli-runner.ts
|
||||
**File: `src/hooks/comment-checker/cli-runner.ts`**
|
||||
|
||||
After the Go binary returns its result, parse the stderr message to identify and suppress comments that match allowed prefixes. The binary's output contains XML like:
|
||||
```xml
|
||||
<comments file="/path/to/file.ts">
|
||||
<comment line-number="5">// Note: Thread-safe</comment>
|
||||
</comments>
|
||||
```
|
||||
|
||||
Add a function `filterAllowedComments()` that:
|
||||
1. Extracts `<comment>` elements from the message
|
||||
2. Checks if the comment text matches any allowed prefix pattern
|
||||
3. If ALL flagged comments match allowed patterns, suppress the entire warning
|
||||
4. If some comments are legitimate and some aren't, rebuild the message without the legitimate ones
|
||||
|
||||
### Step 4: Create dedicated filter module
|
||||
**File: `src/hooks/comment-checker/allowed-prefix-filter.ts`** (new)
|
||||
|
||||
Extract the filtering logic into its own module per the 200 LOC / single-responsibility rule.
|
||||
|
||||
### Step 5: Pass allowed_comment_prefixes through the hook chain
|
||||
**File: `src/hooks/comment-checker/hook.ts`**
|
||||
|
||||
Thread the `allowed_comment_prefixes` config from `createCommentCheckerHooks()` down to `processWithCli()` and `processApplyPatchEditsWithCli()`.
|
||||
|
||||
### Step 6: Add test cases
|
||||
**File: `src/hooks/comment-checker/allowed-prefix-filter.test.ts`** (new)
|
||||
|
||||
Test cases covering:
|
||||
- `// Note: Thread-safe implementation` - should NOT be flagged (false positive)
|
||||
- `// NOTE: See RFC 7231 for details` - should NOT be flagged
|
||||
- `// Note: changed from X to Y` - SHOULD still be flagged (genuine AI slop)
|
||||
- `// TODO: implement caching` - should NOT be flagged
|
||||
- `// FIXME: race condition` - should NOT be flagged
|
||||
- `// HACK: workaround for upstream bug` - should NOT be flagged
|
||||
- `// Added new validation logic` - SHOULD be flagged
|
||||
- Custom allowed patterns from config
|
||||
|
||||
**File: `src/hooks/comment-checker/cli-runner.test.ts`** (new or extend cli.test.ts)
|
||||
|
||||
Integration-level tests for the post-processing pipeline.
|
||||
|
||||
### Step 7: Verify
|
||||
```bash
|
||||
bun test src/hooks/comment-checker/
|
||||
bun run typecheck
|
||||
```
|
||||
|
||||
### Step 8: Commit and push
|
||||
```bash
|
||||
git add -A
|
||||
git commit -m "fix(comment-checker): add allowed-prefix filter to reduce false positives on Note: comments"
|
||||
git push -u origin fix/comment-checker-note-false-positive
|
||||
```
|
||||
|
||||
### Step 9: Create PR
|
||||
```bash
|
||||
gh pr create --title "fix(comment-checker): reduce false positives for legitimate Note: comments" --body-file /tmp/pr-body.md --base dev
|
||||
```
|
||||
|
||||
### Step 10 (Follow-up): Upstream Go binary fix
|
||||
File an issue or PR on `code-yeongyu/go-claude-code-comment-checker` to:
|
||||
1. Relax `(?i)^[\s#/*-]*note:\s*\w` to be more specific (e.g., `note:\s*(changed|modified|updated|added|removed|implemented|refactored)`)
|
||||
2. Add a dedicated `LegitimateCommentFilter` to the filter pipeline in `main.go`
|
||||
3. Support `--allow-prefix` CLI flag for external configuration
|
||||
@@ -1,42 +0,0 @@
|
||||
## Summary
|
||||
|
||||
- Add `allowed_comment_prefixes` config to `CommentCheckerConfigSchema` with sensible defaults (Note:, TODO:, FIXME:, HACK:, WARNING:, etc.)
|
||||
- Add post-processing filter in `allowed-prefix-filter.ts` that suppresses false positives from the Go binary's output before appending to tool output
|
||||
- Add 11 test cases covering false positive scenarios (Note:, TODO:, FIXME:, case-insensitivity, mixed comments, agent memo header suppression)
|
||||
|
||||
## Problem
|
||||
|
||||
The comment-checker hook's upstream Go binary (`go-claude-code-comment-checker`) flags ALL non-filtered comments as problematic. Its `AgentMemoFilter` regex `(?i)^[\s#/*-]*note:\s*\w` classifies any `Note:` comment as AI-generated "agent memo" slop, triggering an aggressive warning banner.
|
||||
|
||||
This causes false positives for legitimate, widely-used comment patterns:
|
||||
```typescript
|
||||
// Note: Thread-safe implementation required due to concurrent access
|
||||
// NOTE: See RFC 7231 section 6.5.4 for 404 semantics
|
||||
// Note: This timeout matches the upstream service SLA
|
||||
```
|
||||
|
||||
These are standard engineering documentation patterns, not AI slop.
|
||||
|
||||
## Solution
|
||||
|
||||
Rather than waiting for an upstream binary fix, this PR adds a configurable **post-processing filter** on the TypeScript side:
|
||||
|
||||
1. **Config**: `comment_checker.allowed_comment_prefixes` - array of case-insensitive prefixes (defaults: `note:`, `todo:`, `fixme:`, `hack:`, `warning:`, `important:`, `bug:`, etc.)
|
||||
2. **Filter**: After the Go binary returns flagged comments, `filterAllowedComments()` parses the XML output and suppresses comments matching allowed prefixes
|
||||
3. **Behavior**: If ALL flagged comments are legitimate → suppress entire warning. If mixed → remove only the legitimate entries from the XML, keep the warning for actual slop.
|
||||
|
||||
Users can customize via config:
|
||||
```jsonc
|
||||
{
|
||||
"comment_checker": {
|
||||
"allowed_comment_prefixes": ["note:", "todo:", "fixme:", "custom-prefix:"]
|
||||
}
|
||||
}
|
||||
```
|
||||
|
||||
## Test Plan
|
||||
|
||||
- 11 new test cases in `allowed-prefix-filter.test.ts`
|
||||
- Updated assertion in `hook.apply-patch.test.ts` for new parameter
|
||||
- `bun test src/hooks/comment-checker/` passes
|
||||
- `bun run typecheck` clean
|
||||
@@ -1,120 +0,0 @@
|
||||
# Verification Strategy
|
||||
|
||||
## 1. Unit Tests
|
||||
|
||||
### New test file: `allowed-prefix-filter.test.ts`
|
||||
Run: `bun test src/hooks/comment-checker/allowed-prefix-filter.test.ts`
|
||||
|
||||
| # | Scenario | Input | Expected |
|
||||
|---|----------|-------|----------|
|
||||
| 1 | Only Note: comments (default prefixes) | `// Note: Thread-safe`, `// NOTE: See RFC` | `hasRemainingComments: false`, empty message |
|
||||
| 2 | Only TODO/FIXME/HACK (default prefixes) | `// TODO: impl`, `// FIXME: race`, `# HACK: workaround` | Suppressed |
|
||||
| 3 | Only AI slop comments | `// Added validation`, `// Refactored for perf` | Full message preserved |
|
||||
| 4 | Mixed legitimate + slop | `// Note: Thread-safe`, `// Changed from old to new` | Message kept, Note: entry removed from XML |
|
||||
| 5 | Case-insensitive Note: | `// note: lowercase test` | Suppressed |
|
||||
| 6 | Hash-prefixed comments | `# Note: Python`, `# TODO: something` | Suppressed (prefix stripped before matching) |
|
||||
| 7 | Security: prefix | `// Security: validate input` | Suppressed |
|
||||
| 8 | Warning: prefix | `// WARNING: mutates input` | Suppressed |
|
||||
| 9 | Empty allowed prefixes | `// Note: should pass through` | Full message preserved (no filtering) |
|
||||
| 10 | Custom prefix | `// PERF: O(n log n)` with `["perf:"]` | Suppressed |
|
||||
| 11 | Agent memo header + Note: | Full agent memo banner + `// Note: Thread-safe` | Entire message suppressed including banner |
|
||||
|
||||
### Existing test: `hook.apply-patch.test.ts`
|
||||
Run: `bun test src/hooks/comment-checker/hook.apply-patch.test.ts`
|
||||
|
||||
Verify the updated mock assertion accepts the new `allowedPrefixes` array parameter.
|
||||
|
||||
### Existing test: `cli.test.ts`
|
||||
Run: `bun test src/hooks/comment-checker/cli.test.ts`
|
||||
|
||||
Verify no regressions in binary spawning, timeout, and semaphore logic.
|
||||
|
||||
## 2. Type Checking
|
||||
|
||||
```bash
|
||||
bun run typecheck
|
||||
```
|
||||
|
||||
Verify:
|
||||
- `CommentCheckerConfigSchema` change propagates correctly to `CommentCheckerConfig` type
|
||||
- All call sites in `hook.ts` and `cli-runner.ts` pass the new parameter
|
||||
- `filterAllowedComments` return type matches usage in `cli-runner.ts`
|
||||
- No new type errors introduced
|
||||
|
||||
## 3. LSP Diagnostics
|
||||
|
||||
```bash
|
||||
# Check all changed files for errors
|
||||
lsp_diagnostics src/config/schema/comment-checker.ts
|
||||
lsp_diagnostics src/hooks/comment-checker/allowed-prefix-filter.ts
|
||||
lsp_diagnostics src/hooks/comment-checker/cli-runner.ts
|
||||
lsp_diagnostics src/hooks/comment-checker/hook.ts
|
||||
lsp_diagnostics src/hooks/comment-checker/allowed-prefix-filter.test.ts
|
||||
```
|
||||
|
||||
## 4. Full Test Suite
|
||||
|
||||
```bash
|
||||
bun test src/hooks/comment-checker/
|
||||
```
|
||||
|
||||
All 4 test files should pass:
|
||||
- `cli.test.ts` (existing - no regressions)
|
||||
- `pending-calls.test.ts` (existing - no regressions)
|
||||
- `hook.apply-patch.test.ts` (modified assertion)
|
||||
- `allowed-prefix-filter.test.ts` (new - all 11 cases)
|
||||
|
||||
## 5. Build Verification
|
||||
|
||||
```bash
|
||||
bun run build
|
||||
```
|
||||
|
||||
Ensure the new module is properly bundled and exported.
|
||||
|
||||
## 6. Integration Verification (Manual)
|
||||
|
||||
If binary is available locally:
|
||||
|
||||
```bash
|
||||
# Test with a file containing Note: comment
|
||||
echo '{"session_id":"test","tool_name":"Write","transcript_path":"","cwd":"/tmp","hook_event_name":"PostToolUse","tool_input":{"file_path":"/tmp/test.ts","content":"// Note: Thread-safe implementation\nconst x = 1"}}' | ~/.cache/oh-my-opencode/bin/comment-checker check
|
||||
echo "Exit code: $?"
|
||||
```
|
||||
|
||||
Expected: Binary returns exit 2 (comment detected), but the TypeScript post-filter should suppress it.
|
||||
|
||||
## 7. Config Validation
|
||||
|
||||
Test that config changes work:
|
||||
|
||||
```jsonc
|
||||
// .opencode/oh-my-opencode.jsonc
|
||||
{
|
||||
"comment_checker": {
|
||||
// Override: only allow Note: and TODO:
|
||||
"allowed_comment_prefixes": ["note:", "todo:"]
|
||||
}
|
||||
}
|
||||
```
|
||||
|
||||
Verify Zod schema accepts the config and defaults are applied when field is omitted.
|
||||
|
||||
## 8. Regression Checks
|
||||
|
||||
Verify the following still work correctly:
|
||||
- AI slop comments (`// Added new feature`, `// Refactored for performance`) are still flagged
|
||||
- BDD comments (`// given`, `// when`, `// then`) are still allowed (binary-side filter)
|
||||
- Linter directives (`// eslint-disable`, `// @ts-ignore`) are still allowed (binary-side filter)
|
||||
- Shebangs (`#!/usr/bin/env node`) are still allowed (binary-side filter)
|
||||
- `custom_prompt` config still works
|
||||
- Semaphore prevents concurrent comment-checker runs
|
||||
- Timeout handling (30s) still works
|
||||
|
||||
## 9. Edge Cases to Watch
|
||||
|
||||
- Empty message from binary (exit code 0) - filter should be no-op
|
||||
- Binary not available - hook gracefully degrades (existing behavior)
|
||||
- Message with no `<comment>` XML elements - filter passes through
|
||||
- Very long messages with many comments - regex performance
|
||||
- Comments containing XML-special characters (`<`, `>`, `&`) in text
|
||||
@@ -1 +0,0 @@
|
||||
{"total_tokens": null, "duration_ms": 399000, "total_duration_seconds": 399}
|
||||
File diff suppressed because one or more lines are too long
@@ -1,360 +0,0 @@
|
||||
---
|
||||
name: work-with-pr
|
||||
description: "Full PR lifecycle: git worktree → implement → atomic commits → PR creation → verification loop (CI + review-work + Cubic approval) → merge. Keeps iterating until ALL gates pass and PR is merged. Worktree auto-cleanup after merge. Use whenever implementation work needs to land as a PR. Triggers: 'create a PR', 'implement and PR', 'work on this and make a PR', 'implement issue', 'land this as a PR', 'work-with-pr', 'PR workflow', 'implement end to end', even when user just says 'implement X' if the context implies PR delivery."
|
||||
---
|
||||
|
||||
# Work With PR — Full PR Lifecycle
|
||||
|
||||
You are executing a complete PR lifecycle: from isolated worktree setup through implementation, PR creation, and an unbounded verification loop until the PR is merged. The loop has three gates — CI, review-work, and Cubic — and you keep fixing and pushing until all three pass simultaneously.
|
||||
|
||||
<architecture>
|
||||
|
||||
```
|
||||
Phase 0: Setup → Branch + worktree in sibling directory
|
||||
Phase 1: Implement → Do the work, atomic commits
|
||||
Phase 2: PR Creation → Push, create PR targeting dev
|
||||
Phase 3: Verify Loop → Unbounded iteration until ALL gates pass:
|
||||
├─ Gate A: CI → gh pr checks (bun test, typecheck, build)
|
||||
├─ Gate B: review-work → 5-agent parallel review
|
||||
└─ Gate C: Cubic → cubic-dev-ai[bot] "No issues found"
|
||||
Phase 4: Merge → Squash merge, worktree cleanup
|
||||
```
|
||||
|
||||
</architecture>
|
||||
|
||||
---
|
||||
|
||||
## Phase 0: Setup
|
||||
|
||||
Create an isolated worktree so the user's main working directory stays clean. This matters because the user may have uncommitted work, and checking out a branch would destroy it.
|
||||
|
||||
<setup>
|
||||
|
||||
### 1. Resolve repository context
|
||||
|
||||
```bash
|
||||
REPO=$(gh repo view --json nameWithOwner -q .nameWithOwner)
|
||||
REPO_NAME=$(basename "$PWD")
|
||||
BASE_BRANCH="dev" # CI blocks PRs to master
|
||||
```
|
||||
|
||||
### 2. Create branch
|
||||
|
||||
If user provides a branch name, use it. Otherwise, derive from the task:
|
||||
|
||||
```bash
|
||||
# Auto-generate: feature/short-description or fix/short-description
|
||||
BRANCH_NAME="feature/$(echo "$TASK_SUMMARY" | tr '[:upper:] ' '[:lower:]-' | head -c 50)"
|
||||
git fetch origin "$BASE_BRANCH"
|
||||
git branch "$BRANCH_NAME" "origin/$BASE_BRANCH"
|
||||
```
|
||||
|
||||
### 3. Create worktree
|
||||
|
||||
Place worktrees as siblings to the repo — not inside it. This avoids git nested repo issues and keeps the working tree clean.
|
||||
|
||||
```bash
|
||||
WORKTREE_PATH="../${REPO_NAME}-wt/${BRANCH_NAME}"
|
||||
mkdir -p "$(dirname "$WORKTREE_PATH")"
|
||||
git worktree add "$WORKTREE_PATH" "$BRANCH_NAME"
|
||||
```
|
||||
|
||||
### 4. Set working context
|
||||
|
||||
All subsequent work happens inside the worktree. Install dependencies if needed:
|
||||
|
||||
```bash
|
||||
cd "$WORKTREE_PATH"
|
||||
# If bun project:
|
||||
[ -f "bun.lock" ] && bun install
|
||||
```
|
||||
|
||||
</setup>
|
||||
|
||||
---
|
||||
|
||||
## Phase 1: Implement
|
||||
|
||||
Do the actual implementation work inside the worktree. The agent using this skill does the work directly — no subagent delegation for the implementation itself.
|
||||
|
||||
**Scope discipline**: For bug fixes, stay minimal. Fix the bug, add a test for it, done. Do not refactor surrounding code, add config options, or "improve" things that aren't broken. The verification loop will catch regressions — trust the process.
|
||||
|
||||
<implementation>
|
||||
|
||||
### Commit strategy
|
||||
|
||||
Use the git-master skill's atomic commit principles. The reason for atomic commits: if CI fails on one change, you can isolate and fix it without unwinding everything.
|
||||
|
||||
```
|
||||
3+ files changed → 2+ commits minimum
|
||||
5+ files changed → 3+ commits minimum
|
||||
10+ files changed → 5+ commits minimum
|
||||
```
|
||||
|
||||
Each commit should pair implementation with its tests. Load `git-master` skill when committing:
|
||||
|
||||
```
|
||||
task(category="quick", load_skills=["git-master"], prompt="Commit the changes atomically following git-master conventions. Repository is at {WORKTREE_PATH}.")
|
||||
```
|
||||
|
||||
### Pre-push local validation
|
||||
|
||||
Before pushing, run the same checks CI will run. Catching failures locally saves a full CI round-trip (~3-5 min):
|
||||
|
||||
```bash
|
||||
bun run typecheck
|
||||
bun test
|
||||
bun run build
|
||||
```
|
||||
|
||||
Fix any failures before pushing. Each fix-commit cycle should be atomic.
|
||||
|
||||
</implementation>
|
||||
|
||||
---
|
||||
|
||||
## Phase 2: PR Creation
|
||||
|
||||
<pr_creation>
|
||||
|
||||
### Push and create PR
|
||||
|
||||
```bash
|
||||
git push -u origin "$BRANCH_NAME"
|
||||
```
|
||||
|
||||
Create the PR using the project's template structure:
|
||||
|
||||
```bash
|
||||
gh pr create \
|
||||
--base "$BASE_BRANCH" \
|
||||
--head "$BRANCH_NAME" \
|
||||
--title "$PR_TITLE" \
|
||||
--body "$(cat <<'EOF'
|
||||
## Summary
|
||||
[1-3 sentences describing what this PR does and why]
|
||||
|
||||
## Changes
|
||||
[Bullet list of key changes]
|
||||
|
||||
## Testing
|
||||
- `bun run typecheck` ✅
|
||||
- `bun test` ✅
|
||||
- `bun run build` ✅
|
||||
|
||||
## Related Issues
|
||||
[Link to issue if applicable]
|
||||
EOF
|
||||
)"
|
||||
```
|
||||
|
||||
Capture the PR number:
|
||||
|
||||
```bash
|
||||
PR_NUMBER=$(gh pr view --json number -q .number)
|
||||
```
|
||||
|
||||
</pr_creation>
|
||||
|
||||
---
|
||||
|
||||
## Phase 3: Verification Loop
|
||||
|
||||
This is the core of the skill. Three gates must ALL pass for the PR to be ready. The loop has no iteration cap — keep going until done. Gate ordering is intentional: CI is cheapest/fastest, review-work is most thorough, Cubic is external and asynchronous.
|
||||
|
||||
<verify_loop>
|
||||
|
||||
```
|
||||
while true:
|
||||
1. Wait for CI → Gate A
|
||||
2. If CI fails → read logs, fix, commit, push, continue
|
||||
3. Run review-work → Gate B
|
||||
4. If review fails → fix blocking issues, commit, push, continue
|
||||
5. Check Cubic → Gate C
|
||||
6. If Cubic has issues → fix issues, commit, push, continue
|
||||
7. All three pass → break
|
||||
```
|
||||
|
||||
### Gate A: CI Checks
|
||||
|
||||
CI is the fastest feedback loop. Wait for it to complete, then parse results.
|
||||
|
||||
```bash
|
||||
# Wait for checks to start (GitHub needs a moment after push)
|
||||
# Then watch for completion
|
||||
gh pr checks "$PR_NUMBER" --watch --fail-fast
|
||||
```
|
||||
|
||||
**On failure**: Get the failed run logs to understand what broke:
|
||||
|
||||
```bash
|
||||
# Find the failed run
|
||||
RUN_ID=$(gh run list --branch "$BRANCH_NAME" --status failure --json databaseId --jq '.[0].databaseId')
|
||||
|
||||
# Get failed job logs
|
||||
gh run view "$RUN_ID" --log-failed
|
||||
```
|
||||
|
||||
Read the logs, fix the issue, commit atomically, push, and re-enter the loop.
|
||||
|
||||
### Gate B: review-work
|
||||
|
||||
The review-work skill launches 5 parallel sub-agents (goal verification, QA, code quality, security, context mining). All 5 must pass.
|
||||
|
||||
Invoke review-work after CI passes — there's no point reviewing code that doesn't build:
|
||||
|
||||
```
|
||||
task(
|
||||
category="unspecified-high",
|
||||
load_skills=["review-work"],
|
||||
run_in_background=false,
|
||||
description="Post-implementation review of PR changes",
|
||||
prompt="Review the implementation work on branch {BRANCH_NAME}. The worktree is at {WORKTREE_PATH}. Goal: {ORIGINAL_GOAL}. Constraints: {CONSTRAINTS}. Run command: bun run dev (or as appropriate)."
|
||||
)
|
||||
```
|
||||
|
||||
**On failure**: review-work reports blocking issues with specific files and line numbers. Fix each blocking issue, commit, push, and re-enter the loop from Gate A (since code changed, CI must re-run).
|
||||
|
||||
### Gate C: Cubic Approval
|
||||
|
||||
Cubic (`cubic-dev-ai[bot]`) is an automated review bot that comments on PRs. It does NOT use GitHub's APPROVED review state — instead it posts comments with issue counts and confidence scores.
|
||||
|
||||
**Approval signal**: The latest Cubic comment contains `**No issues found**` and confidence `**5/5**`.
|
||||
|
||||
**Issue signal**: The comment lists issues with file-level detail.
|
||||
|
||||
```bash
|
||||
# Get the latest Cubic review
|
||||
CUBIC_REVIEW=$(gh api "repos/${REPO}/pulls/${PR_NUMBER}/reviews" \
|
||||
--jq '[.[] | select(.user.login == "cubic-dev-ai[bot]")] | last | .body')
|
||||
|
||||
# Check if approved
|
||||
if echo "$CUBIC_REVIEW" | grep -q "No issues found"; then
|
||||
echo "Cubic: APPROVED"
|
||||
else
|
||||
echo "Cubic: ISSUES FOUND"
|
||||
echo "$CUBIC_REVIEW"
|
||||
fi
|
||||
```
|
||||
|
||||
**On issues**: Cubic's review body contains structured issue descriptions. Parse them, determine which are valid (some may be false positives), fix the valid ones, commit, push, re-enter from Gate A.
|
||||
|
||||
Cubic reviews are triggered automatically on PR updates. After pushing a fix, wait for the new review to appear before checking again. Use `gh api` polling with a conditional loop:
|
||||
|
||||
```bash
|
||||
# Wait for new Cubic review after push
|
||||
PUSH_TIME=$(date -u +%Y-%m-%dT%H:%M:%SZ)
|
||||
while true; do
|
||||
LATEST_REVIEW_TIME=$(gh api "repos/${REPO}/pulls/${PR_NUMBER}/reviews" \
|
||||
--jq '[.[] | select(.user.login == "cubic-dev-ai[bot]")] | last | .submitted_at')
|
||||
if [[ "$LATEST_REVIEW_TIME" > "$PUSH_TIME" ]]; then
|
||||
break
|
||||
fi
|
||||
# Use gh api call itself as the delay mechanism — each call takes ~1-2s
|
||||
# For longer waits, use: timeout 30 gh pr checks "$PR_NUMBER" --watch 2>/dev/null || true
|
||||
done
|
||||
```
|
||||
|
||||
### Iteration discipline
|
||||
|
||||
Each iteration through the loop:
|
||||
1. Fix ONLY the issues identified by the failing gate
|
||||
2. Commit atomically (one logical fix per commit)
|
||||
3. Push
|
||||
4. Re-enter from Gate A (code changed → full re-verification)
|
||||
|
||||
Avoid the temptation to "improve" unrelated code during fix iterations. Scope creep in the fix loop makes debugging harder and can introduce new failures.
|
||||
|
||||
</verify_loop>
|
||||
|
||||
---
|
||||
|
||||
## Phase 4: Merge & Cleanup
|
||||
|
||||
Once all three gates pass:
|
||||
|
||||
<merge_cleanup>
|
||||
|
||||
### Merge the PR
|
||||
|
||||
```bash
|
||||
# Squash merge to keep history clean
|
||||
gh pr merge "$PR_NUMBER" --squash --delete-branch
|
||||
```
|
||||
|
||||
### Sync .sisyphus state back to main repo
|
||||
|
||||
Before removing the worktree, copy `.sisyphus/` state back. When `.sisyphus/` is gitignored, files written there during worktree execution are not committed or merged — they would be lost on worktree removal.
|
||||
|
||||
```bash
|
||||
# Sync .sisyphus state from worktree to main repo (preserves task state, plans, notepads)
|
||||
if [ -d "$WORKTREE_PATH/.sisyphus" ]; then
|
||||
mkdir -p "$ORIGINAL_DIR/.sisyphus"
|
||||
cp -r "$WORKTREE_PATH/.sisyphus/"* "$ORIGINAL_DIR/.sisyphus/" 2>/dev/null || true
|
||||
fi
|
||||
```
|
||||
|
||||
### Clean up the worktree
|
||||
|
||||
The worktree served its purpose — remove it to avoid disk bloat:
|
||||
|
||||
```bash
|
||||
cd "$ORIGINAL_DIR" # Return to original working directory
|
||||
git worktree remove "$WORKTREE_PATH"
|
||||
# Prune any stale worktree references
|
||||
git worktree prune
|
||||
```
|
||||
|
||||
### Report completion
|
||||
|
||||
Summarize what happened:
|
||||
|
||||
```
|
||||
## PR Merged ✅
|
||||
|
||||
- **PR**: #{PR_NUMBER} — {PR_TITLE}
|
||||
- **Branch**: {BRANCH_NAME} → {BASE_BRANCH}
|
||||
- **Iterations**: {N} verification loops
|
||||
- **Gates passed**: CI ✅ | review-work ✅ | Cubic ✅
|
||||
- **Worktree**: cleaned up
|
||||
```
|
||||
|
||||
</merge_cleanup>
|
||||
|
||||
---
|
||||
|
||||
## Failure Recovery
|
||||
|
||||
<failure_recovery>
|
||||
|
||||
If you hit an unrecoverable error (e.g., merge conflict with base branch, infrastructure failure):
|
||||
|
||||
1. **Do NOT delete the worktree** — the user may want to inspect or continue manually
|
||||
2. Report what happened, what was attempted, and where things stand
|
||||
3. Include the worktree path so the user can resume
|
||||
|
||||
For merge conflicts:
|
||||
|
||||
```bash
|
||||
cd "$WORKTREE_PATH"
|
||||
git fetch origin "$BASE_BRANCH"
|
||||
git rebase "origin/$BASE_BRANCH"
|
||||
# Resolve conflicts, then continue the loop
|
||||
```
|
||||
|
||||
</failure_recovery>
|
||||
|
||||
---
|
||||
|
||||
## Anti-Patterns
|
||||
|
||||
| Violation | Why it fails | Severity |
|
||||
|-----------|-------------|----------|
|
||||
| Working in main worktree instead of isolated worktree | Pollutes user's working directory, may destroy uncommitted work | CRITICAL |
|
||||
| Pushing directly to dev/master | Bypasses review entirely | CRITICAL |
|
||||
| Skipping CI gate after code changes | review-work and Cubic may pass on stale code | CRITICAL |
|
||||
| Fixing unrelated code during verification loop | Scope creep causes new failures | HIGH |
|
||||
| Deleting worktree on failure | User loses ability to inspect/resume | HIGH |
|
||||
| Ignoring Cubic false positives without justification | Cubic issues should be evaluated, not blindly dismissed | MEDIUM |
|
||||
| Giant single commits | Harder to isolate failures, violates git-master principles | MEDIUM |
|
||||
| Not running local checks before push | Wastes CI time on obvious failures | MEDIUM |
|
||||
44
AGENTS.md
44
AGENTS.md
@@ -1,10 +1,10 @@
|
||||
# oh-my-opencode — O P E N C O D E Plugin
|
||||
# oh-my-opencode — OpenCode Plugin
|
||||
|
||||
**Generated:** 2026-03-06 | **Commit:** 7fe44024 | **Branch:** dev
|
||||
**Generated:** 2026-03-02 | **Commit:** 1c2caa09 | **Branch:** dev
|
||||
|
||||
## OVERVIEW
|
||||
|
||||
OpenCode plugin (npm: `oh-my-opencode`) that extends Claude Code (OpenCode fork) with multi-agent orchestration, 48 lifecycle hooks, 26 tools, skill/command/MCP systems, and Claude Code compatibility. 1268 TypeScript files, 160k LOC.
|
||||
OpenCode plugin (npm: `oh-my-opencode`) that extends Claude Code (OpenCode fork) with multi-agent orchestration, 46 lifecycle hooks, 26 tools, skill/command/MCP systems, and Claude Code compatibility. 1243 TypeScript files, 155k LOC.
|
||||
|
||||
## STRUCTURE
|
||||
|
||||
@@ -14,14 +14,14 @@ oh-my-opencode/
|
||||
│ ├── index.ts # Plugin entry: loadConfig → createManagers → createTools → createHooks → createPluginInterface
|
||||
│ ├── plugin-config.ts # JSONC multi-level config: user → project → defaults (Zod v4)
|
||||
│ ├── agents/ # 11 agents (Sisyphus, Hephaestus, Oracle, Librarian, Explore, Atlas, Prometheus, Metis, Momus, Multimodal-Looker, Sisyphus-Junior)
|
||||
│ ├── hooks/ # 48 lifecycle hooks across dedicated modules and standalone files
|
||||
│ ├── hooks/ # 46 hooks across 45 directories + 11 standalone files
|
||||
│ ├── tools/ # 26 tools across 15 directories
|
||||
│ ├── features/ # 19 feature modules (background-agent, skill-loader, tmux, MCP-OAuth, etc.)
|
||||
│ ├── shared/ # 95+ utility files in 13 categories
|
||||
│ ├── config/ # Zod v4 schema system (24 files)
|
||||
│ ├── cli/ # CLI: install, run, doctor, mcp-oauth (Commander.js)
|
||||
│ ├── mcp/ # 3 built-in remote MCPs (websearch, context7, grep_app)
|
||||
│ ├── plugin/ # 8 OpenCode hook handlers + 48 hook composition
|
||||
│ ├── plugin/ # 8 OpenCode hook handlers + 46 hook composition
|
||||
│ └── plugin-handlers/ # 6-phase config loading pipeline
|
||||
├── packages/ # Monorepo: cli-runner, 12 platform binaries
|
||||
└── local-ignore/ # Dev-only test fixtures
|
||||
@@ -34,7 +34,7 @@ OhMyOpenCodePlugin(ctx)
|
||||
├─→ loadPluginConfig() # JSONC parse → project/user merge → Zod validate → migrate
|
||||
├─→ createManagers() # TmuxSessionManager, BackgroundManager, SkillMcpManager, ConfigHandler
|
||||
├─→ createTools() # SkillContext + AvailableCategories + ToolRegistry (26 tools)
|
||||
├─→ createHooks() # 3-tier: Core(39) + Continuation(7) + Skill(2) = 48 hooks
|
||||
├─→ createHooks() # 3-tier: Core(37) + Continuation(7) + Skill(2) = 46 hooks
|
||||
└─→ createPluginInterface() # 8 OpenCode hook handlers → PluginInterface
|
||||
```
|
||||
|
||||
@@ -46,7 +46,6 @@ OhMyOpenCodePlugin(ctx)
|
||||
| `tool` | 26 registered tools |
|
||||
| `chat.message` | First-message variant, session setup, keyword detection |
|
||||
| `chat.params` | Anthropic effort level adjustment |
|
||||
| `chat.headers` | Copilot x-initiator header injection |
|
||||
| `event` | Session lifecycle (created, deleted, idle, error) |
|
||||
| `tool.execute.before` | Pre-tool hooks (file guard, label truncator, rules injector) |
|
||||
| `tool.execute.after` | Post-tool hooks (output truncation, metadata store) |
|
||||
@@ -74,12 +73,6 @@ OhMyOpenCodePlugin(ctx)
|
||||
Project (.opencode/oh-my-opencode.jsonc) → User (~/.config/opencode/oh-my-opencode.jsonc) → Defaults
|
||||
```
|
||||
|
||||
- `agents`, `categories`, `claude_code`: deep merged recursively
|
||||
- `disabled_*` arrays: Set union (concatenated + deduplicated)
|
||||
- All other fields: override replaces base value
|
||||
- Zod `safeParse()` fills defaults for omitted fields
|
||||
- `migrateConfigFile()` transforms legacy keys automatically
|
||||
|
||||
Fields: agents (14 overridable, 21 fields each), categories (8 built-in + custom), disabled_* arrays (agents, hooks, mcps, skills, commands, tools), 19 feature-specific configs.
|
||||
|
||||
## THREE-TIER MCP SYSTEM
|
||||
@@ -92,19 +85,15 @@ Fields: agents (14 overridable, 21 fields each), categories (8 built-in + custom
|
||||
|
||||
## CONVENTIONS
|
||||
|
||||
- **Runtime**: Bun only — never use npm/yarn
|
||||
- **TypeScript**: strict mode, ESNext, bundler moduleResolution, `bun-types` (never `@types/node`)
|
||||
- **Test pattern**: Bun test (`bun:test`), co-located `*.test.ts`, given/when/then style (nested describe with `#given`/`#when`/`#then` prefixes)
|
||||
- **CI test split**: mock-heavy tests run in isolation (separate `bun test` processes), rest in batch
|
||||
- **Factory pattern**: `createXXX()` for all tools, hooks, agents
|
||||
- **Hook tiers**: Session (23) → Tool-Guard (12) → Transform (4) → Continuation (7) → Skill (2)
|
||||
- **Hook tiers**: Session (23) → Tool-Guard (10) → Transform (4) → Continuation (7) → Skill (2)
|
||||
- **Agent modes**: `primary` (respects UI model) vs `subagent` (own fallback chain) vs `all`
|
||||
- **Model resolution**: 4-step: override → category-default → provider-fallback → system-default
|
||||
- **Model resolution**: 3-step: override → category-default → provider-fallback → system-default
|
||||
- **Config format**: JSONC with comments, Zod v4 validation, snake_case keys
|
||||
- **File naming**: kebab-case for all files/directories
|
||||
- **Module structure**: index.ts barrel exports, no catch-all files (utils.ts, helpers.ts banned), 200 LOC soft limit
|
||||
- **Imports**: relative within module, barrel imports across modules (`import { log } from "./shared"`)
|
||||
- **No path aliases**: no `@/` — relative imports only
|
||||
|
||||
## ANTI-PATTERNS
|
||||
|
||||
@@ -112,21 +101,16 @@ Fields: agents (14 overridable, 21 fields each), categories (8 built-in + custom
|
||||
- Never suppress lint/type errors
|
||||
- Never add emojis to code/comments unless user explicitly asks
|
||||
- Never commit unless explicitly requested
|
||||
- Never run `bun publish` directly — use GitHub Actions
|
||||
- Never modify `package.json` version locally
|
||||
- Test: given/when/then — never use Arrange-Act-Assert comments
|
||||
- Comments: avoid AI-generated comment patterns (enforced by comment-checker hook)
|
||||
- Never create catch-all files (`utils.ts`, `helpers.ts`, `service.ts`)
|
||||
- Empty catch blocks `catch(e) {}` — always handle errors
|
||||
- Never use em dashes (—), en dashes (–), or AI filler phrases in generated content
|
||||
- index.ts is entry point ONLY — never dump business logic there
|
||||
|
||||
## COMMANDS
|
||||
|
||||
```bash
|
||||
bun test # Bun test suite
|
||||
bun run build # Build plugin (ESM + declarations + schema)
|
||||
bun run build:all # Build + platform binaries
|
||||
bun run typecheck # tsc --noEmit
|
||||
bunx oh-my-opencode install # Interactive setup
|
||||
bunx oh-my-opencode doctor # Health diagnostics
|
||||
@@ -137,12 +121,10 @@ bunx oh-my-opencode run # Non-interactive session
|
||||
|
||||
| Workflow | Trigger | Purpose |
|
||||
|----------|---------|---------|
|
||||
| ci.yml | push/PR to master/dev | Tests (split: mock-heavy isolated + batch), typecheck, build, schema auto-commit |
|
||||
| publish.yml | manual dispatch | Version bump, npm publish, platform binaries, GitHub release, merge to master |
|
||||
| publish-platform.yml | called by publish | 12 platform binaries via bun compile (darwin/linux/windows) |
|
||||
| sisyphus-agent.yml | @mention / dispatch | AI agent handles issues/PRs |
|
||||
| cla.yml | issue_comment/PR | CLA assistant for contributors |
|
||||
| lint-workflows.yml | push to .github/ | actionlint + shellcheck on workflow files |
|
||||
| ci.yml | push/PR | Tests (split: mock-heavy isolated + batch), typecheck, build, schema auto-commit |
|
||||
| publish.yml | manual | Version bump, npm publish, platform binaries, GitHub release, merge to dev |
|
||||
| publish-platform.yml | called | 12 platform binaries via bun compile (darwin/linux/windows) |
|
||||
| sisyphus-agent.yml | @mention | AI agent handles issues/PRs |
|
||||
|
||||
## NOTES
|
||||
|
||||
@@ -153,5 +135,3 @@ bunx oh-my-opencode run # Non-interactive session
|
||||
- Config migration runs automatically on legacy keys (agent names, hook names, model versions)
|
||||
- Build: bun build (ESM) + tsc --emitDeclarationOnly, externals: @ast-grep/napi
|
||||
- Test setup: `test-setup.ts` preloaded via bunfig.toml, mock-heavy tests run in isolation in CI
|
||||
- 98 barrel export files (index.ts) establish module boundaries
|
||||
- Architecture rules enforced via `.sisyphus/rules/modular-code-enforcement.md`
|
||||
|
||||
@@ -31,7 +31,6 @@ Be respectful, inclusive, and constructive. We're all here to make better tools
|
||||
**English is the primary language for all communications in this repository.**
|
||||
|
||||
This includes:
|
||||
|
||||
- Issues and bug reports
|
||||
- Pull requests and code reviews
|
||||
- Documentation and comments
|
||||
@@ -46,7 +45,6 @@ This includes:
|
||||
### Need Help with English?
|
||||
|
||||
If English isn't your first language, don't worry! We value your contributions regardless of perfect grammar. You can:
|
||||
|
||||
- Use translation tools to help compose messages
|
||||
- Ask for help from other community members
|
||||
- Focus on clear, simple communication rather than perfect prose
|
||||
@@ -63,8 +61,8 @@ If English isn't your first language, don't worry! We value your contributions r
|
||||
|
||||
```bash
|
||||
# Clone the repository
|
||||
git clone https://github.com/code-yeongyu/oh-my-openagent.git
|
||||
cd oh-my-openagent
|
||||
git clone https://github.com/code-yeongyu/oh-my-opencode.git
|
||||
cd oh-my-opencode
|
||||
|
||||
# Install dependencies (bun only - never use npm/yarn)
|
||||
bun install
|
||||
@@ -78,24 +76,25 @@ bun run build
|
||||
After making changes, you can test your local build in OpenCode:
|
||||
|
||||
1. **Build the project**:
|
||||
|
||||
```bash
|
||||
bun run build
|
||||
```
|
||||
|
||||
2. **Update your OpenCode config** (`~/.config/opencode/opencode.json` or `opencode.jsonc`):
|
||||
|
||||
```json
|
||||
{
|
||||
"plugin": ["file:///absolute/path/to/oh-my-opencode/dist/index.js"]
|
||||
"plugin": [
|
||||
"file:///absolute/path/to/oh-my-opencode/dist/index.js"
|
||||
]
|
||||
}
|
||||
```
|
||||
|
||||
|
||||
For example, if your project is at `/Users/yourname/projects/oh-my-opencode`:
|
||||
|
||||
```json
|
||||
{
|
||||
"plugin": ["file:///Users/yourname/projects/oh-my-opencode/dist/index.js"]
|
||||
"plugin": [
|
||||
"file:///Users/yourname/projects/oh-my-opencode/dist/index.js"
|
||||
]
|
||||
}
|
||||
```
|
||||
|
||||
@@ -113,7 +112,7 @@ oh-my-opencode/
|
||||
│ ├── index.ts # Plugin entry (OhMyOpenCodePlugin)
|
||||
│ ├── plugin-config.ts # JSONC multi-level config (Zod v4)
|
||||
│ ├── agents/ # 11 agents (Sisyphus, Hephaestus, Oracle, Librarian, Explore, Atlas, Prometheus, Metis, Momus, Multimodal-Looker, Sisyphus-Junior)
|
||||
│ ├── hooks/ # Lifecycle hooks for orchestration, recovery, UX, and context management
|
||||
│ ├── hooks/ # 44 lifecycle hooks across 39 directories
|
||||
│ ├── tools/ # 26 tools across 15 directories
|
||||
│ ├── mcp/ # 3 built-in remote MCPs (websearch, context7, grep_app)
|
||||
│ ├── features/ # 19 feature modules (background-agent, skill-loader, tmux, MCP-OAuth, etc.)
|
||||
@@ -137,11 +136,8 @@ bun run typecheck
|
||||
# Full build (ESM + TypeScript declarations + JSON schema)
|
||||
bun run build
|
||||
|
||||
# Clean build output
|
||||
bun run clean
|
||||
|
||||
# Rebuild from scratch
|
||||
bun run clean && bun run build
|
||||
# Clean build output and rebuild
|
||||
bun run rebuild
|
||||
|
||||
# Build schema only (after modifying src/config/schema.ts)
|
||||
bun run build:schema
|
||||
@@ -149,18 +145,17 @@ bun run build:schema
|
||||
|
||||
### Code Style & Conventions
|
||||
|
||||
| Convention | Rule |
|
||||
| ---------------- | ------------------------------------------------------------------------- |
|
||||
| Package Manager | **Bun only** (`bun run`, `bun build`, `bunx`) |
|
||||
| Types | Use `bun-types`, not `@types/node` |
|
||||
| Directory Naming | kebab-case (`ast-grep/`, `claude-code-hooks/`) |
|
||||
| File Operations | Never use bash commands (mkdir/touch/rm) for file creation in code |
|
||||
| Tool Structure | Each tool: `index.ts`, `types.ts`, `constants.ts`, `tools.ts`, `utils.ts` |
|
||||
| Hook Pattern | `createXXXHook(input: PluginInput)` function naming |
|
||||
| Exports | Barrel pattern (`export * from "./module"` in index.ts) |
|
||||
| Convention | Rule |
|
||||
|------------|------|
|
||||
| Package Manager | **Bun only** (`bun run`, `bun build`, `bunx`) |
|
||||
| Types | Use `bun-types`, not `@types/node` |
|
||||
| Directory Naming | kebab-case (`ast-grep/`, `claude-code-hooks/`) |
|
||||
| File Operations | Never use bash commands (mkdir/touch/rm) for file creation in code |
|
||||
| Tool Structure | Each tool: `index.ts`, `types.ts`, `constants.ts`, `tools.ts`, `utils.ts` |
|
||||
| Hook Pattern | `createXXXHook(input: PluginInput)` function naming |
|
||||
| Exports | Barrel pattern (`export * from "./module"` in index.ts) |
|
||||
|
||||
**Anti-Patterns (Do Not Do)**:
|
||||
|
||||
- Using npm/yarn instead of bun
|
||||
- Using `@types/node` instead of `bun-types`
|
||||
- Suppressing TypeScript errors with `as any`, `@ts-ignore`, `@ts-expect-error`
|
||||
@@ -184,7 +179,7 @@ import type { AgentConfig } from "./types";
|
||||
|
||||
export const myAgent: AgentConfig = {
|
||||
name: "my-agent",
|
||||
model: "anthropic/claude-opus-4-6",
|
||||
model: "anthropic/claude-sonnet-4-6",
|
||||
description: "Description of what this agent does",
|
||||
prompt: `Your agent's system prompt here`,
|
||||
temperature: 0.1,
|
||||
|
||||
122
FIX-BLOCKS.md
122
FIX-BLOCKS.md
@@ -1,122 +0,0 @@
|
||||
# Pre-Publish BLOCK Issues: Fix ALL Before Release
|
||||
|
||||
Two independent pre-publish reviews (Opus 4.6 + GPT-5.4) both concluded **BLOCK -- do not publish**. You must fix ALL blocking issues below using UltraBrain parallel agents. Work TDD-style: write/update tests first, then fix, verify tests pass.
|
||||
|
||||
## Strategy
|
||||
|
||||
Use ultrawork (ulw) to spawn UltraBrain agents in parallel. Each UB agent gets a non-overlapping scope. After all agents complete, run bun test to verify everything passes. Commit atomically per fix group.
|
||||
|
||||
---
|
||||
|
||||
## CRITICAL BLOCKERS (must fix -- 6 items)
|
||||
|
||||
### C1: Hashline Backward Compatibility
|
||||
**Problem:** Strict whitespace hashing in hashline changes LINE#ID values for indented lines. Breaks existing anchors in cached/persisted edit operations.
|
||||
**Fix:** Add a compatibility shim -- when lookup by new hash fails, fall back to legacy hash (without strict whitespace). Or version the hash format.
|
||||
**Files:** Look for hashline-related files in src/tools/ or src/shared/
|
||||
|
||||
### C2: OpenAI-Only Model Catalog Broken with OpenCode-Go
|
||||
**Problem:** isOpenAiOnlyAvailability() does not exclude availability.opencodeGo. When OpenCode-Go is present, OpenAI-only detection is wrong -- models get misrouted.
|
||||
**Fix:** Add !availability.opencodeGo check to isOpenAiOnlyAvailability().
|
||||
**Files:** Model/provider system files -- search for isOpenAiOnlyAvailability
|
||||
|
||||
### C3: CLI/Runtime Model Table Divergence
|
||||
**Problem:** Model tables disagree between CLI install-time and runtime:
|
||||
- ultrabrain: gpt-5.3-codex in CLI vs gpt-5.4 in runtime
|
||||
- atlas: claude-sonnet-4-5 in CLI vs claude-sonnet-4-6 in runtime
|
||||
- unspecified-high also diverges
|
||||
**Fix:** Reconcile all model tables. Pick the correct model for each and make CLI + runtime match.
|
||||
**Files:** Search for model table definitions, agent configs, CLI model references
|
||||
|
||||
### C4: atlas/metis/sisyphus-junior Missing OpenAI Fallbacks
|
||||
**Problem:** These agents can resolve to opencode/glm-4.7-free or undefined in OpenAI-only environments. No valid OpenAI fallback paths exist.
|
||||
**Fix:** Add valid OpenAI model fallback paths for all agents that need them.
|
||||
**Files:** Agent config/model resolution code
|
||||
|
||||
### C5: model_fallback Default Mismatch
|
||||
**Problem:** Schema and docs say model_fallback defaults to false, but runtime treats unset as true. Silent behavior change for all users.
|
||||
**Fix:** Align -- either update schema/docs to say true, or fix runtime to default to false. Check what the intended behavior is from git history.
|
||||
**Files:** Schema definition, runtime config loading
|
||||
|
||||
### C6: background_output Default Changed
|
||||
**Problem:** background_output now defaults to full_session=true. Old callers get different output format without code changes.
|
||||
**Fix:** Either document this change clearly, or restore old default and make full_session opt-in.
|
||||
**Files:** Background output handling code
|
||||
|
||||
---
|
||||
|
||||
## HIGH PRIORITY (strongly recommended -- 4 items)
|
||||
|
||||
### H1: Runtime Fallback session-status-handler Race
|
||||
**Problem:** When fallback model is already pending, the handler cannot advance the chain on subsequent cooldown events.
|
||||
**Fix:** Allow override like message-update-handler does.
|
||||
**Files:** Search for session-status-handler, message-update-handler
|
||||
|
||||
### H2: Atlas Final-Wave Approval Gate Logic
|
||||
**Problem:** Approval gate logic does not match real Prometheus plan structure (nested checkboxes, parallel execution). Trigger logic is wrong.
|
||||
**Fix:** Update to handle real plan structures.
|
||||
**Files:** Atlas agent code, approval gate logic
|
||||
|
||||
### H3: delegate-task-english-directive Dead Code
|
||||
**Problem:** Not dispatched from tool-execute-before.ts + wrong hook signature. Either wire properly or remove entirely.
|
||||
**Fix:** Remove if not needed (cleaner). If needed, fix dispatch + signature.
|
||||
**Files:** src/hooks/, tool-execute-before.ts
|
||||
|
||||
### H4: Auto-Slash-Command Session-Lifetime Dedup
|
||||
**Problem:** Dedup uses session lifetime, suppressing legitimate repeated identical commands.
|
||||
**Fix:** Change to short TTL (e.g., 30 seconds) instead of session lifetime.
|
||||
**Files:** Slash command handling code
|
||||
|
||||
---
|
||||
|
||||
## ADDITIONAL BLOCKERS FROM GPT-5.4 REVIEW
|
||||
|
||||
### G1: Package Identity Split-Brain
|
||||
**Problem:** Installer writes oh-my-openagent but doctor, auto-update, version lookup, publish workflow still reference oh-my-opencode. Half-migrated state.
|
||||
**Fix:** Audit ALL references to package name. Either complete the migration consistently or revert to single name for this release.
|
||||
**Files:** Installer, doctor, auto-update, version lookup, publish workflow -- grep for both package names
|
||||
|
||||
### G2: OpenCode-Go --opencode-go Value Validation
|
||||
**Problem:** No validation for --opencode-go CLI value. No detection of existing OpenCode-Go installations.
|
||||
**Fix:** Add value validation + existing install detection.
|
||||
**Files:** CLI option handling code
|
||||
|
||||
### G3: Skill/Hook Reference Errors
|
||||
**Problem:**
|
||||
- work-with-pr references non-existent git tool category
|
||||
- github-triage references TaskCreate/TaskUpdate which are not real tool names
|
||||
**Fix:** Fix tool references to use actual tool names.
|
||||
**Files:** Skill definition files in .opencode/skills/
|
||||
|
||||
### G4: Stale Context-Limit Cache
|
||||
**Problem:** Shared context-limit resolver caches provider config. When config changes, stale removed limits persist and corrupt compaction/truncation decisions.
|
||||
**Fix:** Add cache invalidation when provider config changes, or make the resolver stateless.
|
||||
**Files:** Context-limit resolver, compaction code
|
||||
|
||||
### G5: disabled_hooks Schema vs Runtime Contract Mismatch
|
||||
**Problem:** Schema is strict (rejects unknown hook names) but runtime is permissive (ignores unknown). Contract disagreement.
|
||||
**Fix:** Align -- either make both strict or both permissive.
|
||||
**Files:** Hook schema definition, runtime hook loading
|
||||
|
||||
---
|
||||
|
||||
## EXECUTION INSTRUCTIONS
|
||||
|
||||
1. Spawn UltraBrain agents to fix these in parallel -- group by file proximity:
|
||||
- UB-1: C1 (hashline) + H4 (slash-command dedup)
|
||||
- UB-2: C2 + C3 + C4 (model/provider system) + G2
|
||||
- UB-3: C5 + C6 (config defaults) + G5
|
||||
- UB-4: H1 + H2 (runtime handlers + Atlas gate)
|
||||
- UB-5: H3 + G3 (dead code + skill references)
|
||||
- UB-6: G1 (package identity -- full audit)
|
||||
- UB-7: G4 (context-limit cache)
|
||||
|
||||
2. Each UB agent MUST:
|
||||
- Write or update tests FIRST (TDD)
|
||||
- Implement the fix
|
||||
- Run bun test on affected test files
|
||||
- Commit with descriptive message
|
||||
|
||||
3. After all UB agents complete, run full bun test to verify no regressions.
|
||||
|
||||
ulw
|
||||
45
README.ja.md
45
README.ja.md
@@ -1,20 +1,3 @@
|
||||
> [!WARNING]
|
||||
> **一時的なお知らせ(今週): メンテナー対応遅延のお知らせ**
|
||||
>
|
||||
> コアメンテナーのQが負傷したため、今週は Issue/PR への返信とリリースが遅れる可能性があります。
|
||||
> ご理解とご支援に感謝します。
|
||||
|
||||
> [!TIP]
|
||||
> **Building in Public**
|
||||
>
|
||||
> メンテナーが Jobdori を使い、oh-my-opencode をリアルタイムで開発・メンテナンスしています。Jobdori は OpenClaw をベースに大幅カスタマイズされた AI アシスタントです。
|
||||
> すべての機能開発、修正、Issue トリアージを Discord でライブでご覧いただけます。
|
||||
>
|
||||
> [](https://discord.gg/PUwSMR9XNk)
|
||||
>
|
||||
> [**→ #building-in-public で確認する**](https://discord.gg/PUwSMR9XNk)
|
||||
|
||||
|
||||
> [!NOTE]
|
||||
>
|
||||
> [](https://sisyphuslabs.ai)
|
||||
@@ -32,9 +15,9 @@
|
||||
|
||||
<div align="center">
|
||||
|
||||
[](https://github.com/code-yeongyu/oh-my-openagent#oh-my-opencode)
|
||||
[](https://github.com/code-yeongyu/oh-my-opencode#oh-my-opencode)
|
||||
|
||||
[](https://github.com/code-yeongyu/oh-my-openagent#oh-my-opencode)
|
||||
[](https://github.com/code-yeongyu/oh-my-opencode#oh-my-opencode)
|
||||
|
||||
</div>
|
||||
|
||||
@@ -44,14 +27,14 @@
|
||||
|
||||
<div align="center">
|
||||
|
||||
[](https://github.com/code-yeongyu/oh-my-openagent/releases)
|
||||
[](https://github.com/code-yeongyu/oh-my-opencode/releases)
|
||||
[](https://www.npmjs.com/package/oh-my-opencode)
|
||||
[](https://github.com/code-yeongyu/oh-my-openagent/graphs/contributors)
|
||||
[](https://github.com/code-yeongyu/oh-my-openagent/network/members)
|
||||
[](https://github.com/code-yeongyu/oh-my-openagent/stargazers)
|
||||
[](https://github.com/code-yeongyu/oh-my-openagent/issues)
|
||||
[](https://github.com/code-yeongyu/oh-my-openagent/blob/dev/LICENSE.md)
|
||||
[](https://deepwiki.com/code-yeongyu/oh-my-openagent)
|
||||
[](https://github.com/code-yeongyu/oh-my-opencode/graphs/contributors)
|
||||
[](https://github.com/code-yeongyu/oh-my-opencode/network/members)
|
||||
[](https://github.com/code-yeongyu/oh-my-opencode/stargazers)
|
||||
[](https://github.com/code-yeongyu/oh-my-opencode/issues)
|
||||
[](https://github.com/code-yeongyu/oh-my-opencode/blob/dev/LICENSE.md)
|
||||
[](https://deepwiki.com/code-yeongyu/oh-my-opencode)
|
||||
|
||||
[English](README.md) | [한국어](README.ko.md) | [日本語](README.ja.md) | [简体中文](README.zh-cn.md)
|
||||
|
||||
@@ -102,7 +85,7 @@ OmOをインストールして、`ultrawork`とタイプしてください。狂
|
||||
|
||||
```
|
||||
Install and configure oh-my-opencode by following the instructions here:
|
||||
https://raw.githubusercontent.com/code-yeongyu/oh-my-openagent/refs/heads/dev/docs/guide/installation.md
|
||||
https://raw.githubusercontent.com/code-yeongyu/oh-my-opencode/refs/heads/dev/docs/guide/installation.md
|
||||
```
|
||||
|
||||
もしくは[インストールガイド](docs/guide/installation.md)を直接読んでもいいですが、マジでエージェントにやらせてください。人間は設定で必ずタイポします。
|
||||
@@ -112,7 +95,7 @@ https://raw.githubusercontent.com/code-yeongyu/oh-my-openagent/refs/heads/dev/do
|
||||
インストールガイドを取得して、それに従ってください:
|
||||
|
||||
```bash
|
||||
curl -s https://raw.githubusercontent.com/code-yeongyu/oh-my-openagent/refs/heads/dev/docs/guide/installation.md
|
||||
curl -s https://raw.githubusercontent.com/code-yeongyu/oh-my-opencode/refs/heads/dev/docs/guide/installation.md
|
||||
```
|
||||
|
||||
---
|
||||
@@ -122,7 +105,7 @@ curl -s https://raw.githubusercontent.com/code-yeongyu/oh-my-openagent/refs/head
|
||||
ドキュメントを読む時代は終わりました。このテキストをエージェントに貼り付けるだけです:
|
||||
|
||||
```
|
||||
Read this and tell me why it's not just another boilerplate: https://raw.githubusercontent.com/code-yeongyu/oh-my-openagent/refs/heads/dev/README.md
|
||||
Read this and tell me why it's not just another boilerplate: https://raw.githubusercontent.com/code-yeongyu/oh-my-opencode/refs/heads/dev/README.md
|
||||
```
|
||||
|
||||
## ハイライト
|
||||
@@ -168,7 +151,7 @@ Read this and tell me why it's not just another boilerplate: https://raw.githubu
|
||||
|
||||
**Sisyphus** (`claude-opus-4-6` / **`kimi-k2.5`** / **`glm-5`**) はあなたのメインのオーケストレーターです。計画を立て、専門家に委任し、攻撃的な並列実行でタスクを完了まで推進します。途中で投げ出すことはありません。
|
||||
|
||||
**Hephaestus** (`gpt-5.4`) はあなたの自律的なディープワーカーです。レシピではなく、目標を与えてください。手取り足取り教えなくても、コードベースを探索し、パターンを研究し、端から端まで実行します。*正当なる職人 (The Legitimate Craftsman).*
|
||||
**Hephaestus** (`gpt-5.3-codex`) はあなたの自律的なディープワーカーです。レシピではなく、目標を与えてください。手取り足取り教えなくても、コードベースを探索し、パターンを研究し、端から端まで実行します。*正当なる職人 (The Legitimate Craftsman).*
|
||||
|
||||
**Prometheus** (`claude-opus-4-6` / **`kimi-k2.5`** / **`glm-5`**) はあなたの戦略プランナーです。インタビューモードで動作し、コードに触れる前に質問をしてスコープを特定し、詳細な計画を構築します。
|
||||
|
||||
@@ -176,7 +159,7 @@ Read this and tell me why it's not just another boilerplate: https://raw.githubu
|
||||
|
||||
> Anthropicが[私たちのせいでOpenCodeをブロックしました。](https://x.com/thdxr/status/2010149530486911014) だからこそHephaestusは「正当なる職人 (The Legitimate Craftsman)」と呼ばれているのです。皮肉を込めています。
|
||||
>
|
||||
> Opusで最もよく動きますが、Kimi K2.5 + GPT-5.4の組み合わせだけでも、バニラのClaude Codeを軽く凌駕します。設定は一切不要です。
|
||||
> Opusで最もよく動きますが、Kimi K2.5 + GPT-5.3 Codexの組み合わせだけでも、バニラのClaude Codeを軽く凌駕します。設定は一切不要です。
|
||||
|
||||
### エージェントの<E38388><E381AE>ーケストレーション
|
||||
|
||||
|
||||
45
README.ko.md
45
README.ko.md
@@ -1,20 +1,3 @@
|
||||
> [!WARNING]
|
||||
> **임시 공지 (이번 주): 메인테이너 대응 지연 안내**
|
||||
>
|
||||
> 핵심 메인테이너 Q가 부상을 입어, 이번 주에는 이슈/PR 응답 및 릴리스가 지연될 수 있습니다.
|
||||
> 양해와 응원에 감사드립니다.
|
||||
|
||||
> [!TIP]
|
||||
> **Building in Public**
|
||||
>
|
||||
> 메인테이너가 Jobdori를 통해 oh-my-opencode를 실시간으로 개발하고 있습니다. Jobdori는 OpenClaw를 기반으로 대폭 커스터마이징된 AI 어시스턴트입니다.
|
||||
> 모든 기능 개발, 버그 수정, 이슈 트리아지를 Discord에서 실시간으로 확인하세요.
|
||||
>
|
||||
> [](https://discord.gg/PUwSMR9XNk)
|
||||
>
|
||||
> [**→ #building-in-public에서 확인하기**](https://discord.gg/PUwSMR9XNk)
|
||||
|
||||
|
||||
> [!TIP]
|
||||
> 저희와 함께 하세요!
|
||||
>
|
||||
@@ -27,9 +10,9 @@
|
||||
|
||||
<div align="center">
|
||||
|
||||
[](https://github.com/code-yeongyu/oh-my-openagent#oh-my-opencode)
|
||||
[](https://github.com/code-yeongyu/oh-my-opencode#oh-my-opencode)
|
||||
|
||||
[](https://github.com/code-yeongyu/oh-my-openagent#oh-my-opencode)
|
||||
[](https://github.com/code-yeongyu/oh-my-opencode#oh-my-opencode)
|
||||
|
||||
</div>
|
||||
|
||||
@@ -39,14 +22,14 @@
|
||||
|
||||
<div align="center">
|
||||
|
||||
[](https://github.com/code-yeongyu/oh-my-openagent/releases)
|
||||
[](https://github.com/code-yeongyu/oh-my-opencode/releases)
|
||||
[](https://www.npmjs.com/package/oh-my-opencode)
|
||||
[](https://github.com/code-yeongyu/oh-my-openagent/graphs/contributors)
|
||||
[](https://github.com/code-yeongyu/oh-my-openagent/network/members)
|
||||
[](https://github.com/code-yeongyu/oh-my-openagent/stargazers)
|
||||
[](https://github.com/code-yeongyu/oh-my-openagent/issues)
|
||||
[](https://github.com/code-yeongyu/oh-my-openagent/blob/dev/LICENSE.md)
|
||||
[](https://deepwiki.com/code-yeongyu/oh-my-openagent)
|
||||
[](https://github.com/code-yeongyu/oh-my-opencode/graphs/contributors)
|
||||
[](https://github.com/code-yeongyu/oh-my-opencode/network/members)
|
||||
[](https://github.com/code-yeongyu/oh-my-opencode/stargazers)
|
||||
[](https://github.com/code-yeongyu/oh-my-opencode/issues)
|
||||
[](https://github.com/code-yeongyu/oh-my-opencode/blob/dev/LICENSE.md)
|
||||
[](https://deepwiki.com/code-yeongyu/oh-my-opencode)
|
||||
|
||||
[English](README.md) | [한국어](README.ko.md) | [日本語](README.ja.md) | [简体中文](README.zh-cn.md)
|
||||
|
||||
@@ -96,7 +79,7 @@ OmO 설치하고. `ultrawork` 치세요. 끝.
|
||||
|
||||
```
|
||||
Install and configure oh-my-opencode by following the instructions here:
|
||||
https://raw.githubusercontent.com/code-yeongyu/oh-my-openagent/refs/heads/dev/docs/guide/installation.md
|
||||
https://raw.githubusercontent.com/code-yeongyu/oh-my-opencode/refs/heads/dev/docs/guide/installation.md
|
||||
```
|
||||
|
||||
아니면 [설치 가이드](docs/guide/installation.md)를 직접 읽으셔도 되지만, 진심으로 그냥 에이전트한테 시키세요. 사람은 설정하다 꼭 오타 냅니다.
|
||||
@@ -106,7 +89,7 @@ https://raw.githubusercontent.com/code-yeongyu/oh-my-openagent/refs/heads/dev/do
|
||||
설치 가이드를 가져와서 따라 하세요:
|
||||
|
||||
```bash
|
||||
curl -s https://raw.githubusercontent.com/code-yeongyu/oh-my-openagent/refs/heads/dev/docs/guide/installation.md
|
||||
curl -s https://raw.githubusercontent.com/code-yeongyu/oh-my-opencode/refs/heads/dev/docs/guide/installation.md
|
||||
```
|
||||
|
||||
---
|
||||
@@ -116,7 +99,7 @@ curl -s https://raw.githubusercontent.com/code-yeongyu/oh-my-openagent/refs/head
|
||||
문서 읽는 시대는 지났습니다. 그냥 이 텍스트를 에이전트한테 붙여넣으세요:
|
||||
|
||||
```
|
||||
Read this and tell me why it's not just another boilerplate: https://raw.githubusercontent.com/code-yeongyu/oh-my-openagent/refs/heads/dev/README.md
|
||||
Read this and tell me why it's not just another boilerplate: https://raw.githubusercontent.com/code-yeongyu/oh-my-opencode/refs/heads/dev/README.md
|
||||
```
|
||||
|
||||
## 핵심 기능
|
||||
@@ -162,7 +145,7 @@ Read this and tell me why it's not just another boilerplate: https://raw.githubu
|
||||
|
||||
**Sisyphus** (`claude-opus-4-6` / **`kimi-k2.5`** / **`glm-5`**)는 당신의 메인 오케스트레이터입니다. 공격적인 병렬 실행으로 계획을 세우고, 전문가들에게 위임하며, 완료될 때까지 밀어붙입니다. 중간에 포기하는 법이 없습니다.
|
||||
|
||||
**Hephaestus** (`gpt-5.4`)는 당신의 자율 딥 워커입니다. 레시피가 아니라 목표를 주세요. 베이비시터 없이 알아서 코드베이스를 탐색하고, 패턴을 연구하며, 끝에서 끝까지 전부 해냅니다. *진정한 장인(The Legitimate Craftsman).*
|
||||
**Hephaestus** (`gpt-5.3-codex`)는 당신의 자율 딥 워커입니다. 레시피가 아니라 목표를 주세요. 베이비시터 없이 알아서 코드베이스를 탐색하고, 패턴을 연구하며, 끝에서 끝까지 전부 해냅니다. *진정한 장인(The Legitimate Craftsman).*
|
||||
|
||||
**Prometheus** (`claude-opus-4-6` / **`kimi-k2.5`** / **`glm-5`**)는 당신의 전략 플래너입니다. 인터뷰 모드로 작동합니다. 코드 한 줄 만지기 전에 질문을 던져 스코프를 파악하고 상세한 계획부터 세웁니다.
|
||||
|
||||
@@ -170,7 +153,7 @@ Read this and tell me why it's not just another boilerplate: https://raw.githubu
|
||||
|
||||
> Anthropic이 [우리 때문에 OpenCode를 막아버렸습니다.](https://x.com/thdxr/status/2010149530486911014) 그래서 Hephaestus의 별명이 "진정한 장인(The Legitimate Craftsman)"인 겁니다. (어디서 많이 들어본 이름이죠?) 아이러니를 노렸습니다.
|
||||
>
|
||||
> Opus에서 제일 잘 돌아가긴 하지만, Kimi K2.5 + GPT-5.4 조합만으로도 바닐라 Claude Code는 가볍게 바릅니다. 설정도 필요 없습니다.
|
||||
> Opus에서 제일 잘 돌아가긴 하지만, Kimi K2.5 + GPT-5.3 Codex 조합만으로도 바닐라 Claude Code는 가볍게 바릅니다. 설정도 필요 없습니다.
|
||||
|
||||
### 에이전트 오케스트레이션
|
||||
|
||||
|
||||
62
README.md
62
README.md
@@ -1,13 +1,3 @@
|
||||
> [!TIP]
|
||||
> **Building in Public**
|
||||
>
|
||||
> The maintainer builds and maintains oh-my-opencode in real-time with Jobdori, an AI assistant built on a heavily customized fork of OpenClaw.
|
||||
> Every feature, every fix, every issue triage — live in our Discord.
|
||||
>
|
||||
> [](https://discord.gg/PUwSMR9XNk)
|
||||
>
|
||||
> [**→ Watch it happen in #building-in-public**](https://discord.gg/PUwSMR9XNk)
|
||||
|
||||
> [!NOTE]
|
||||
>
|
||||
> [](https://sisyphuslabs.ai)
|
||||
@@ -25,9 +15,9 @@
|
||||
|
||||
<div align="center">
|
||||
|
||||
[](https://github.com/code-yeongyu/oh-my-openagent#oh-my-opencode)
|
||||
[](https://github.com/code-yeongyu/oh-my-opencode#oh-my-opencode)
|
||||
|
||||
[](https://github.com/code-yeongyu/oh-my-openagent#oh-my-opencode)
|
||||
[](https://github.com/code-yeongyu/oh-my-opencode#oh-my-opencode)
|
||||
|
||||
|
||||
</div>
|
||||
@@ -40,14 +30,14 @@
|
||||
|
||||
<div align="center">
|
||||
|
||||
[](https://github.com/code-yeongyu/oh-my-openagent/releases)
|
||||
[](https://www.npmjs.com/package/oh-my-opencode)
|
||||
[](https://github.com/code-yeongyu/oh-my-openagent/graphs/contributors)
|
||||
[](https://github.com/code-yeongyu/oh-my-openagent/network/members)
|
||||
[](https://github.com/code-yeongyu/oh-my-openagent/stargazers)
|
||||
[](https://github.com/code-yeongyu/oh-my-openagent/issues)
|
||||
[](https://github.com/code-yeongyu/oh-my-openagent/blob/dev/LICENSE.md)
|
||||
[](https://deepwiki.com/code-yeongyu/oh-my-openagent)
|
||||
[](https://github.com/code-yeongyu/oh-my-opencode/releases)
|
||||
[](https://www.npmjs.com/package/oh-my-opencode)
|
||||
[](https://github.com/code-yeongyu/oh-my-opencode/graphs/contributors)
|
||||
[](https://github.com/code-yeongyu/oh-my-opencode/network/members)
|
||||
[](https://github.com/code-yeongyu/oh-my-opencode/stargazers)
|
||||
[](https://github.com/code-yeongyu/oh-my-opencode/issues)
|
||||
[](https://github.com/code-yeongyu/oh-my-opencode/blob/dev/LICENSE.md)
|
||||
[](https://deepwiki.com/code-yeongyu/oh-my-opencode)
|
||||
|
||||
[English](README.md) | [한국어](README.ko.md) | [日本語](README.ja.md) | [简体中文](README.zh-cn.md)
|
||||
|
||||
@@ -98,7 +88,7 @@ Copy and paste this prompt to your LLM agent (Claude Code, AmpCode, Cursor, etc.
|
||||
|
||||
```
|
||||
Install and configure oh-my-opencode by following the instructions here:
|
||||
https://raw.githubusercontent.com/code-yeongyu/oh-my-openagent/refs/heads/dev/docs/guide/installation.md
|
||||
https://raw.githubusercontent.com/code-yeongyu/oh-my-opencode/refs/heads/dev/docs/guide/installation.md
|
||||
```
|
||||
|
||||
Or read the [Installation Guide](docs/guide/installation.md), but seriously, let an agent do it. Humans fat-finger configs.
|
||||
@@ -108,11 +98,9 @@ Or read the [Installation Guide](docs/guide/installation.md), but seriously, let
|
||||
Fetch the installation guide and follow it:
|
||||
|
||||
```bash
|
||||
curl -s https://raw.githubusercontent.com/code-yeongyu/oh-my-openagent/refs/heads/dev/docs/guide/installation.md
|
||||
curl -s https://raw.githubusercontent.com/code-yeongyu/oh-my-opencode/refs/heads/dev/docs/guide/installation.md
|
||||
```
|
||||
|
||||
**Note**: Use the published package and binary name `oh-my-opencode`. Inside `opencode.json`, the compatibility layer now prefers the plugin entry `oh-my-openagent`, while legacy `oh-my-opencode` entries still load with a warning. Plugin config files still commonly use `oh-my-opencode.json` or `oh-my-opencode.jsonc`, and both legacy and renamed basenames are recognized during the transition.
|
||||
|
||||
---
|
||||
|
||||
## Skip This README
|
||||
@@ -120,7 +108,7 @@ curl -s https://raw.githubusercontent.com/code-yeongyu/oh-my-openagent/refs/head
|
||||
We're past the era of reading docs. Just paste this into your agent:
|
||||
|
||||
```
|
||||
Read this and tell me why it's not just another boilerplate: https://raw.githubusercontent.com/code-yeongyu/oh-my-openagent/refs/heads/dev/README.md
|
||||
Read this and tell me why it's not just another boilerplate: https://raw.githubusercontent.com/code-yeongyu/oh-my-opencode/refs/heads/dev/README.md
|
||||
```
|
||||
|
||||
## Highlights
|
||||
@@ -166,7 +154,7 @@ Even only with following subscriptions, ultrawork will work well (this project i
|
||||
|
||||
**Sisyphus** (`claude-opus-4-6` / **`kimi-k2.5`** / **`glm-5`** ) is your main orchestrator. He plans, delegates to specialists, and drives tasks to completion with aggressive parallel execution. He does not stop halfway.
|
||||
|
||||
**Hephaestus** (`gpt-5.4`) is your autonomous deep worker. Give him a goal, not a recipe. He explores the codebase, researches patterns, and executes end-to-end without hand-holding. *The Legitimate Craftsman.*
|
||||
**Hephaestus** (`gpt-5.3-codex`) is your autonomous deep worker. Give him a goal, not a recipe. He explores the codebase, researches patterns, and executes end-to-end without hand-holding. *The Legitimate Craftsman.*
|
||||
|
||||
**Prometheus** (`claude-opus-4-6` / **`kimi-k2.5`** / **`glm-5`** ) is your strategic planner. Interview mode: it questions, identifies scope, and builds a detailed plan before a single line of code is touched.
|
||||
|
||||
@@ -174,7 +162,7 @@ Every agent is tuned to its model's specific strengths. No manual model-juggling
|
||||
|
||||
> Anthropic [blocked OpenCode because of us.](https://x.com/thdxr/status/2010149530486911014) That's why Hephaestus is called "The Legitimate Craftsman." The irony is intentional.
|
||||
>
|
||||
> We run best on Opus, but Kimi K2.5 + GPT-5.4 already beats vanilla Claude Code. Zero config needed.
|
||||
> We run best on Opus, but Kimi K2.5 + GPT-5.3 Codex already beats vanilla Claude Code. Zero config needed.
|
||||
|
||||
### Agent Orchestration
|
||||
|
||||
@@ -187,7 +175,7 @@ When Sisyphus delegates to a subagent, it doesn't pick a model. It picks a **cat
|
||||
| `quick` | Single-file changes, typos |
|
||||
| `ultrabrain` | Hard logic, architecture decisions |
|
||||
|
||||
Agent says what kind of work. Harness picks the right model. `ultrabrain` now routes to GPT-5.4 xhigh by default. You touch nothing.
|
||||
Agent says what kind of work. Harness picks the right model. You touch nothing.
|
||||
|
||||
### Claude Code Compatibility
|
||||
|
||||
@@ -275,11 +263,11 @@ To remove oh-my-opencode:
|
||||
|
||||
1. **Remove the plugin from your OpenCode config**
|
||||
|
||||
Edit `~/.config/opencode/opencode.json` (or `opencode.jsonc`) and remove either `"oh-my-openagent"` or the legacy `"oh-my-opencode"` entry from the `plugin` array:
|
||||
Edit `~/.config/opencode/opencode.json` (or `opencode.jsonc`) and remove `"oh-my-opencode"` from the `plugin` array:
|
||||
|
||||
```bash
|
||||
# Using jq
|
||||
jq '.plugin = [.plugin[] | select(. != "oh-my-openagent" and . != "oh-my-opencode")]' \
|
||||
jq '.plugin = [.plugin[] | select(. != "oh-my-opencode")]' \
|
||||
~/.config/opencode/opencode.json > /tmp/oc.json && \
|
||||
mv /tmp/oc.json ~/.config/opencode/opencode.json
|
||||
```
|
||||
@@ -287,13 +275,11 @@ To remove oh-my-opencode:
|
||||
2. **Remove configuration files (optional)**
|
||||
|
||||
```bash
|
||||
# Remove plugin config files recognized during the compatibility window
|
||||
rm -f ~/.config/opencode/oh-my-openagent.jsonc ~/.config/opencode/oh-my-openagent.json \
|
||||
~/.config/opencode/oh-my-opencode.jsonc ~/.config/opencode/oh-my-opencode.json
|
||||
# Remove user config
|
||||
rm -f ~/.config/opencode/oh-my-opencode.json ~/.config/opencode/oh-my-opencode.jsonc
|
||||
|
||||
# Remove project config (if exists)
|
||||
rm -f .opencode/oh-my-openagent.jsonc .opencode/oh-my-openagent.json \
|
||||
.opencode/oh-my-opencode.jsonc .opencode/oh-my-opencode.json
|
||||
rm -f .opencode/oh-my-opencode.json .opencode/oh-my-opencode.jsonc
|
||||
```
|
||||
|
||||
3. **Verify removal**
|
||||
@@ -319,10 +305,6 @@ See full [Features Documentation](docs/reference/features.md).
|
||||
- **Built-in MCPs**: websearch (Exa), context7 (docs), grep_app (GitHub search)
|
||||
- **Session Tools**: List, read, search, and analyze session history
|
||||
- **Productivity Features**: Ralph Loop, Todo Enforcer, Comment Checker, Think Mode, and more
|
||||
- **Doctor Command**: Built-in diagnostics (`bunx oh-my-opencode doctor`) verify plugin registration, config, models, and environment
|
||||
- **Model Fallbacks**: `fallback_models` can mix plain model strings with per-fallback object settings in the same array
|
||||
- **File Prompts**: Load prompts from files with `file://` support in agent configurations
|
||||
- **Session Recovery**: Automatic recovery from session errors, context window limits, and API failures
|
||||
- **Model Setup**: Agent-model matching is built into the [Installation Guide](docs/guide/installation.md#step-5-understand-your-model-setup)
|
||||
|
||||
## Configuration
|
||||
@@ -332,7 +314,7 @@ Opinionated defaults, adjustable if you insist.
|
||||
See [Configuration Documentation](docs/reference/configuration.md).
|
||||
|
||||
**Quick Overview:**
|
||||
- **Config Locations**: The compatibility layer recognizes both `oh-my-openagent.json[c]` and legacy `oh-my-opencode.json[c]` plugin config files. Existing installs still commonly use the legacy basename.
|
||||
- **Config Locations**: `.opencode/oh-my-opencode.jsonc` or `.opencode/oh-my-opencode.json` (project), `~/.config/opencode/oh-my-opencode.jsonc` or `~/.config/opencode/oh-my-opencode.json` (user)
|
||||
- **JSONC Support**: Comments and trailing commas supported
|
||||
- **Agents**: Override models, temperatures, prompts, and permissions for any agent
|
||||
- **Built-in Skills**: `playwright` (browser automation), `git-master` (atomic commits)
|
||||
|
||||
33
README.ru.md
33
README.ru.md
@@ -1,20 +1,3 @@
|
||||
> [!WARNING]
|
||||
> **Временное уведомление (на этой неделе): сниженная доступность мейнтейнера**
|
||||
>
|
||||
> Ключевой мейнтейнер Q получил травму, поэтому на этой неделе ответы по issue/PR и релизы могут задерживаться.
|
||||
> Спасибо за терпение и поддержку.
|
||||
|
||||
> [!TIP]
|
||||
> **Building in Public**
|
||||
>
|
||||
> Мейнтейнер разрабатывает и поддерживает oh-my-opencode в режиме реального времени с помощью Jobdori — ИИ-ассистента на базе глубоко кастомизированной версии OpenClaw.
|
||||
> Каждая фича, каждый фикс, каждый триаж issue — в прямом эфире в нашем Discord.
|
||||
>
|
||||
> [](https://discord.gg/PUwSMR9XNk)
|
||||
>
|
||||
> [**→ Смотрите в #building-in-public**](https://discord.gg/PUwSMR9XNk)
|
||||
|
||||
|
||||
> [!NOTE]
|
||||
>
|
||||
> [](https://sisyphuslabs.ai)
|
||||
@@ -30,9 +13,9 @@
|
||||
|
||||
<!-- <CENTERED SECTION FOR GITHUB DISPLAY> --> <div align="center">
|
||||
|
||||
[](https://github.com/code-yeongyu/oh-my-openagent#oh-my-opencode)
|
||||
[](https://github.com/code-yeongyu/oh-my-opencode#oh-my-opencode)
|
||||
|
||||
[](https://github.com/code-yeongyu/oh-my-openagent#oh-my-opencode)
|
||||
[](https://github.com/code-yeongyu/oh-my-opencode#oh-my-opencode)
|
||||
|
||||
</div>
|
||||
|
||||
@@ -42,7 +25,7 @@
|
||||
|
||||
<div align="center">
|
||||
|
||||
[](https://github.com/code-yeongyu/oh-my-openagent/releases) [](https://www.npmjs.com/package/oh-my-opencode) [](https://github.com/code-yeongyu/oh-my-openagent/graphs/contributors) [](https://github.com/code-yeongyu/oh-my-openagent/network/members) [](https://github.com/code-yeongyu/oh-my-openagent/stargazers) [](https://github.com/code-yeongyu/oh-my-openagent/issues) [](https://github.com/code-yeongyu/oh-my-openagent/blob/master/LICENSE.md) [](https://deepwiki.com/code-yeongyu/oh-my-openagent)
|
||||
[](https://github.com/code-yeongyu/oh-my-opencode/releases) [](https://www.npmjs.com/package/oh-my-opencode) [](https://github.com/code-yeongyu/oh-my-opencode/graphs/contributors) [](https://github.com/code-yeongyu/oh-my-opencode/network/members) [](https://github.com/code-yeongyu/oh-my-opencode/stargazers) [](https://github.com/code-yeongyu/oh-my-opencode/issues) [](https://github.com/code-yeongyu/oh-my-opencode/blob/master/LICENSE.md) [](https://deepwiki.com/code-yeongyu/oh-my-opencode)
|
||||
|
||||
English | 한국어 | 日本語 | 简体中文 | Русский
|
||||
|
||||
@@ -88,7 +71,7 @@ English | 한국어 | 日本語 | 简体中文 | Русский
|
||||
|
||||
```
|
||||
Install and configure oh-my-opencode by following the instructions here:
|
||||
https://raw.githubusercontent.com/code-yeongyu/oh-my-openagent/refs/heads/dev/docs/guide/installation.md
|
||||
https://raw.githubusercontent.com/code-yeongyu/oh-my-opencode/refs/heads/master/docs/guide/installation.md
|
||||
```
|
||||
|
||||
Или прочитайте руководство по установке, но серьёзно — пусть агент сделает это за вас. Люди ошибаются в конфигах.
|
||||
@@ -98,7 +81,7 @@ https://raw.githubusercontent.com/code-yeongyu/oh-my-openagent/refs/heads/dev/do
|
||||
Загрузите руководство по установке и следуйте ему:
|
||||
|
||||
```bash
|
||||
curl -s https://raw.githubusercontent.com/code-yeongyu/oh-my-openagent/refs/heads/dev/docs/guide/installation.md
|
||||
curl -s https://raw.githubusercontent.com/code-yeongyu/oh-my-opencode/refs/heads/master/docs/guide/installation.md
|
||||
```
|
||||
|
||||
------
|
||||
@@ -108,7 +91,7 @@ curl -s https://raw.githubusercontent.com/code-yeongyu/oh-my-openagent/refs/head
|
||||
Мы вышли за пределы эпохи чтения документации. Просто вставьте это в своего агента:
|
||||
|
||||
```
|
||||
Read this and tell me why it's not just another boilerplate: https://raw.githubusercontent.com/code-yeongyu/oh-my-openagent/refs/heads/dev/README.md
|
||||
Read this and tell me why it's not just another boilerplate: https://raw.githubusercontent.com/code-yeongyu/oh-my-opencode/refs/heads/dev/README.md
|
||||
```
|
||||
|
||||
## Ключевые возможности
|
||||
@@ -152,7 +135,7 @@ Read this and tell me why it's not just another boilerplate: https://raw.githubu
|
||||
|
||||
**Sisyphus** (`claude-opus-4-6` / **`kimi-k2.5`** / **`glm-5`**) — главный оркестратор. Он планирует, делегирует задачи специалистам и доводит их до завершения с агрессивным параллельным выполнением. Он не останавливается на полпути.
|
||||
|
||||
**Hephaestus** (`gpt-5.4`) — автономный глубокий исполнитель. Дайте ему цель, а не рецепт. Он исследует кодовую базу, изучает паттерны и выполняет задачи сквозным образом без лишних подсказок. *Законный Мастер.*
|
||||
**Hephaestus** (`gpt-5.3-codex`) — автономный глубокий исполнитель. Дайте ему цель, а не рецепт. Он исследует кодовую базу, изучает паттерны и выполняет задачи сквозным образом без лишних подсказок. *Законный Мастер.*
|
||||
|
||||
**Prometheus** (`claude-opus-4-6` / **`kimi-k2.5`** / **`glm-5`**) — стратегический планировщик. Режим интервью: задаёт вопросы, определяет объём работ и формирует детальный план до того, как написана хотя бы одна строка кода.
|
||||
|
||||
@@ -160,7 +143,7 @@ Read this and tell me why it's not just another boilerplate: https://raw.githubu
|
||||
|
||||
> Anthropic [заблокировал OpenCode из-за нас.](https://x.com/thdxr/status/2010149530486911014) Именно поэтому Hephaestus зовётся «Законным Мастером». Ирония намеренная.
|
||||
>
|
||||
> Мы работаем лучше всего на Opus, но Kimi K2.5 + GPT-5.4 уже превосходят ванильный Claude Code. Никакой настройки не требуется.
|
||||
> Мы работаем лучше всего на Opus, но Kimi K2.5 + GPT-5.3 Codex уже превосходят ванильный Claude Code. Никакой настройки не требуется.
|
||||
|
||||
### Оркестрация агентов
|
||||
|
||||
|
||||
@@ -1,20 +1,3 @@
|
||||
> [!WARNING]
|
||||
> **临时通知(本周):维护者响应延迟说明**
|
||||
>
|
||||
> 核心维护者 Q 因受伤,本周 issue/PR 回复和发布可能会延迟。
|
||||
> 感谢你的耐心与支持。
|
||||
|
||||
> [!TIP]
|
||||
> **Building in Public**
|
||||
>
|
||||
> 维护者正在使用 Jobdori 实时开发和维护 oh-my-opencode。Jobdori 是基于 OpenClaw 深度定制的 AI 助手。
|
||||
> 每个功能开发、每次修复、每次 Issue 分类,都在 Discord 上实时进行。
|
||||
>
|
||||
> [](https://discord.gg/PUwSMR9XNk)
|
||||
>
|
||||
> [**→ 在 #building-in-public 频道中查看**](https://discord.gg/PUwSMR9XNk)
|
||||
|
||||
|
||||
> [!NOTE]
|
||||
>
|
||||
> [](https://sisyphuslabs.ai)
|
||||
@@ -32,9 +15,9 @@
|
||||
|
||||
<div align="center">
|
||||
|
||||
[](https://github.com/code-yeongyu/oh-my-openagent#oh-my-opencode)
|
||||
[](https://github.com/code-yeongyu/oh-my-opencode#oh-my-opencode)
|
||||
|
||||
[](https://github.com/code-yeongyu/oh-my-openagent#oh-my-opencode)
|
||||
[](https://github.com/code-yeongyu/oh-my-opencode#oh-my-opencode)
|
||||
|
||||
</div>
|
||||
|
||||
@@ -44,14 +27,14 @@
|
||||
|
||||
<div align="center">
|
||||
|
||||
[](https://github.com/code-yeongyu/oh-my-openagent/releases)
|
||||
[](https://github.com/code-yeongyu/oh-my-opencode/releases)
|
||||
[](https://www.npmjs.com/package/oh-my-opencode)
|
||||
[](https://github.com/code-yeongyu/oh-my-openagent/graphs/contributors)
|
||||
[](https://github.com/code-yeongyu/oh-my-openagent/network/members)
|
||||
[](https://github.com/code-yeongyu/oh-my-openagent/stargazers)
|
||||
[](https://github.com/code-yeongyu/oh-my-openagent/issues)
|
||||
[](https://github.com/code-yeongyu/oh-my-openagent/blob/dev/LICENSE.md)
|
||||
[](https://deepwiki.com/code-yeongyu/oh-my-openagent)
|
||||
[](https://github.com/code-yeongyu/oh-my-opencode/graphs/contributors)
|
||||
[](https://github.com/code-yeongyu/oh-my-opencode/network/members)
|
||||
[](https://github.com/code-yeongyu/oh-my-opencode/stargazers)
|
||||
[](https://github.com/code-yeongyu/oh-my-opencode/issues)
|
||||
[](https://github.com/code-yeongyu/oh-my-opencode/blob/dev/LICENSE.md)
|
||||
[](https://deepwiki.com/code-yeongyu/oh-my-opencode)
|
||||
|
||||
[English](README.md) | [한국어](README.ko.md) | [日本語](README.ja.md) | [简体中文](README.zh-cn.md)
|
||||
|
||||
@@ -103,7 +86,7 @@
|
||||
|
||||
```
|
||||
Install and configure oh-my-opencode by following the instructions here:
|
||||
https://raw.githubusercontent.com/code-yeongyu/oh-my-openagent/refs/heads/dev/docs/guide/installation.md
|
||||
https://raw.githubusercontent.com/code-yeongyu/oh-my-opencode/refs/heads/dev/docs/guide/installation.md
|
||||
```
|
||||
|
||||
或者你可以直接去读 [安装指南](docs/guide/installation.md),但说真的,让 Agent 去干吧。人类配环境总是容易敲错字母。
|
||||
@@ -113,7 +96,7 @@ https://raw.githubusercontent.com/code-yeongyu/oh-my-openagent/refs/heads/dev/do
|
||||
获取安装指南并照做:
|
||||
|
||||
```bash
|
||||
curl -s https://raw.githubusercontent.com/code-yeongyu/oh-my-openagent/refs/heads/dev/docs/guide/installation.md
|
||||
curl -s https://raw.githubusercontent.com/code-yeongyu/oh-my-opencode/refs/heads/dev/docs/guide/installation.md
|
||||
```
|
||||
|
||||
---
|
||||
@@ -123,7 +106,7 @@ curl -s https://raw.githubusercontent.com/code-yeongyu/oh-my-openagent/refs/head
|
||||
读文档的时代已经过去了。直接把下面这行发给你的 Agent:
|
||||
|
||||
```
|
||||
Read this and tell me why it's not just another boilerplate: https://raw.githubusercontent.com/code-yeongyu/oh-my-openagent/refs/heads/dev/README.md
|
||||
Read this and tell me why it's not just another boilerplate: https://raw.githubusercontent.com/code-yeongyu/oh-my-opencode/refs/heads/dev/README.md
|
||||
```
|
||||
|
||||
## 核心亮点
|
||||
@@ -169,7 +152,7 @@ Read this and tell me why it's not just another boilerplate: https://raw.githubu
|
||||
|
||||
**Sisyphus** (`claude-opus-4-6` / **`kimi-k2.5`** / **`glm-5`**) 是你的主指挥官。他负责制定计划、分配任务给专家团队,并以极其激进的并行策略推动任务直至完成。他从不半途而废。
|
||||
|
||||
**Hephaestus** (`gpt-5.4`) 是你的自主深度工作者。你只需要给他目标,不要给他具体做法。他会自动探索代码库模式,从头到尾独立执行任务,绝不会中途要你当保姆。*名副其实的正牌工匠。*
|
||||
**Hephaestus** (`gpt-5.3-codex`) 是你的自主深度工作者。你只需要给他目标,不要给他具体做法。他会自动探索代码库模式,从头到尾独立执行任务,绝不会中途要你当保姆。*名副其实的正牌工匠。*
|
||||
|
||||
**Prometheus** (`claude-opus-4-6` / **`kimi-k2.5`** / **`glm-5`**) 是你的战略规划师。他通过访谈模式,在动一行代码之前,先通过提问确定范围并构建详尽的执行计划。
|
||||
|
||||
@@ -177,7 +160,7 @@ Read this and tell me why it's not just another boilerplate: https://raw.githubu
|
||||
|
||||
> Anthropic [因为我们屏蔽了 OpenCode](https://x.com/thdxr/status/2010149530486911014)。这就是为什么我们将 Hephaestus 命名为“正牌工匠 (The Legitimate Craftsman)”。这是一个故意的讽刺。
|
||||
>
|
||||
> 我们在 Opus 上运行得最好,但仅仅使用 Kimi K2.5 + GPT-5.4 就足以碾压原版的 Claude Code。完全不需要配置。
|
||||
> 我们在 Opus 上运行得最好,但仅仅使用 Kimi K2.5 + GPT-5.3 Codex 就足以碾压原版的 Claude Code。完全不需要配置。
|
||||
|
||||
### 智能体调度机制
|
||||
|
||||
|
||||
File diff suppressed because it is too large
Load Diff
62
benchmarks/bun.lock
Normal file
62
benchmarks/bun.lock
Normal file
@@ -0,0 +1,62 @@
|
||||
{
|
||||
"lockfileVersion": 1,
|
||||
"configVersion": 1,
|
||||
"workspaces": {
|
||||
"": {
|
||||
"name": "hashline-edit-benchmark",
|
||||
"dependencies": {
|
||||
"@ai-sdk/openai": "^1.3.0",
|
||||
"@friendliai/ai-provider": "^1.0.9",
|
||||
"ai": "^6.0.94",
|
||||
"zod": "^4.1.0",
|
||||
},
|
||||
},
|
||||
},
|
||||
"packages": {
|
||||
"@ai-sdk/gateway": ["@ai-sdk/gateway@3.0.55", "", { "dependencies": { "@ai-sdk/provider": "3.0.8", "@ai-sdk/provider-utils": "4.0.15", "@vercel/oidc": "3.1.0" }, "peerDependencies": { "zod": "^3.25.76 || ^4.1.8" } }, "sha512-7xMeTJnCjwRwXKVCiv4Ly4qzWvDuW3+W1WIV0X1EFu6W83d4mEhV9bFArto10MeTw40ewuDjrbrZd21mXKohkw=="],
|
||||
|
||||
"@ai-sdk/openai": ["@ai-sdk/openai@1.3.24", "", { "dependencies": { "@ai-sdk/provider": "1.1.3", "@ai-sdk/provider-utils": "2.2.8" }, "peerDependencies": { "zod": "^3.0.0" } }, "sha512-GYXnGJTHRTZc4gJMSmFRgEQudjqd4PUN0ZjQhPwOAYH1yOAvQoG/Ikqs+HyISRbLPCrhbZnPKCNHuRU4OfpW0Q=="],
|
||||
|
||||
"@ai-sdk/openai-compatible": ["@ai-sdk/openai-compatible@2.0.30", "", { "dependencies": { "@ai-sdk/provider": "3.0.8", "@ai-sdk/provider-utils": "4.0.15" }, "peerDependencies": { "zod": "^3.25.76 || ^4.1.8" } }, "sha512-iTjumHf1/u4NhjXYFn/aONM2GId3/o7J1Lp5ql8FCbgIMyRwrmanR5xy1S3aaVkfTscuDvLTzWiy1mAbGzK3nQ=="],
|
||||
|
||||
"@ai-sdk/provider": ["@ai-sdk/provider@1.1.3", "", { "dependencies": { "json-schema": "^0.4.0" } }, "sha512-qZMxYJ0qqX/RfnuIaab+zp8UAeJn/ygXXAffR5I4N0n1IrvA6qBsjc8hXLmBiMV2zoXlifkacF7sEFnYnjBcqg=="],
|
||||
|
||||
"@ai-sdk/provider-utils": ["@ai-sdk/provider-utils@2.2.8", "", { "dependencies": { "@ai-sdk/provider": "1.1.3", "nanoid": "^3.3.8", "secure-json-parse": "^2.7.0" }, "peerDependencies": { "zod": "^3.23.8" } }, "sha512-fqhG+4sCVv8x7nFzYnFo19ryhAa3w096Kmc3hWxMQfW/TubPOmt3A6tYZhl4mUfQWWQMsuSkLrtjlWuXBVSGQA=="],
|
||||
|
||||
"@friendliai/ai-provider": ["@friendliai/ai-provider@1.1.4", "", { "dependencies": { "@ai-sdk/openai-compatible": "2.0.30", "@ai-sdk/provider": "3.0.8", "@ai-sdk/provider-utils": "4.0.15" }, "peerDependencies": { "zod": "^3.25.76 || ^4.1.12" } }, "sha512-9TU4B1QFqPhbkONjI5afCF7Ox4jOqtGg1xw8mA9QHZdtlEbZxU+mBNvMPlI5pU5kPoN6s7wkXmFmxpID+own1A=="],
|
||||
|
||||
"@opentelemetry/api": ["@opentelemetry/api@1.9.0", "", {}, "sha512-3giAOQvZiH5F9bMlMiv8+GSPMeqg0dbaeo58/0SlA9sxSqZhnUtxzX9/2FzyhS9sWQf5S0GJE0AKBrFqjpeYcg=="],
|
||||
|
||||
"@standard-schema/spec": ["@standard-schema/spec@1.1.0", "", {}, "sha512-l2aFy5jALhniG5HgqrD6jXLi/rUWrKvqN/qJx6yoJsgKhblVd+iqqU4RCXavm/jPityDo5TCvKMnpjKnOriy0w=="],
|
||||
|
||||
"@vercel/oidc": ["@vercel/oidc@3.1.0", "", {}, "sha512-Fw28YZpRnA3cAHHDlkt7xQHiJ0fcL+NRcIqsocZQUSmbzeIKRpwttJjik5ZGanXP+vlA4SbTg+AbA3bP363l+w=="],
|
||||
|
||||
"ai": ["ai@6.0.101", "", { "dependencies": { "@ai-sdk/gateway": "3.0.55", "@ai-sdk/provider": "3.0.8", "@ai-sdk/provider-utils": "4.0.15", "@opentelemetry/api": "1.9.0" }, "peerDependencies": { "zod": "^3.25.76 || ^4.1.8" } }, "sha512-Ur/NgbgOp1rdhyDiKDk6EOpSgd1g5ADlbcD1cjQJtQsnmhEngz3Rf8nK5JetDh0vnbLy2aEBpaQeL+zvLRWuaA=="],
|
||||
|
||||
"eventsource-parser": ["eventsource-parser@3.0.6", "", {}, "sha512-Vo1ab+QXPzZ4tCa8SwIHJFaSzy4R6SHf7BY79rFBDf0idraZWAkYrDjDj8uWaSm3S2TK+hJ7/t1CEmZ7jXw+pg=="],
|
||||
|
||||
"json-schema": ["json-schema@0.4.0", "", {}, "sha512-es94M3nTIfsEPisRafak+HDLfHXnKBhV3vU5eqPcS3flIWqcxJWgXHXiey3YrpaNsanY5ei1VoYEbOzijuq9BA=="],
|
||||
|
||||
"nanoid": ["nanoid@3.3.11", "", { "bin": { "nanoid": "bin/nanoid.cjs" } }, "sha512-N8SpfPUnUp1bK+PMYW8qSWdl9U+wwNWI4QKxOYDy9JAro3WMX7p2OeVRF9v+347pnakNevPmiHhNmZ2HbFA76w=="],
|
||||
|
||||
"secure-json-parse": ["secure-json-parse@2.7.0", "", {}, "sha512-6aU+Rwsezw7VR8/nyvKTx8QpWH9FrcYiXXlqC4z5d5XQBDRqtbfsRjnwGyqbi3gddNtWHuEk9OANUotL26qKUw=="],
|
||||
|
||||
"zod": ["zod@4.3.6", "", {}, "sha512-rftlrkhHZOcjDwkGlnUtZZkvaPHCsDATp4pGpuOOMDaTdDDXF91wuVDJoWoPsKX/3YPQ5fHuF3STjcYyKr+Qhg=="],
|
||||
|
||||
"@ai-sdk/gateway/@ai-sdk/provider": ["@ai-sdk/provider@3.0.8", "", { "dependencies": { "json-schema": "^0.4.0" } }, "sha512-oGMAgGoQdBXbZqNG0Ze56CHjDZ1IDYOwGYxYjO5KLSlz5HiNQ9udIXsPZ61VWaHGZ5XW/jyjmr6t2xz2jGVwbQ=="],
|
||||
|
||||
"@ai-sdk/gateway/@ai-sdk/provider-utils": ["@ai-sdk/provider-utils@4.0.15", "", { "dependencies": { "@ai-sdk/provider": "3.0.8", "@standard-schema/spec": "^1.1.0", "eventsource-parser": "^3.0.6" }, "peerDependencies": { "zod": "^3.25.76 || ^4.1.8" } }, "sha512-8XiKWbemmCbvNN0CLR9u3PQiet4gtEVIrX4zzLxnCj06AwsEDJwJVBbKrEI4t6qE8XRSIvU2irka0dcpziKW6w=="],
|
||||
|
||||
"@ai-sdk/openai-compatible/@ai-sdk/provider": ["@ai-sdk/provider@3.0.8", "", { "dependencies": { "json-schema": "^0.4.0" } }, "sha512-oGMAgGoQdBXbZqNG0Ze56CHjDZ1IDYOwGYxYjO5KLSlz5HiNQ9udIXsPZ61VWaHGZ5XW/jyjmr6t2xz2jGVwbQ=="],
|
||||
|
||||
"@ai-sdk/openai-compatible/@ai-sdk/provider-utils": ["@ai-sdk/provider-utils@4.0.15", "", { "dependencies": { "@ai-sdk/provider": "3.0.8", "@standard-schema/spec": "^1.1.0", "eventsource-parser": "^3.0.6" }, "peerDependencies": { "zod": "^3.25.76 || ^4.1.8" } }, "sha512-8XiKWbemmCbvNN0CLR9u3PQiet4gtEVIrX4zzLxnCj06AwsEDJwJVBbKrEI4t6qE8XRSIvU2irka0dcpziKW6w=="],
|
||||
|
||||
"@friendliai/ai-provider/@ai-sdk/provider": ["@ai-sdk/provider@3.0.8", "", { "dependencies": { "json-schema": "^0.4.0" } }, "sha512-oGMAgGoQdBXbZqNG0Ze56CHjDZ1IDYOwGYxYjO5KLSlz5HiNQ9udIXsPZ61VWaHGZ5XW/jyjmr6t2xz2jGVwbQ=="],
|
||||
|
||||
"@friendliai/ai-provider/@ai-sdk/provider-utils": ["@ai-sdk/provider-utils@4.0.15", "", { "dependencies": { "@ai-sdk/provider": "3.0.8", "@standard-schema/spec": "^1.1.0", "eventsource-parser": "^3.0.6" }, "peerDependencies": { "zod": "^3.25.76 || ^4.1.8" } }, "sha512-8XiKWbemmCbvNN0CLR9u3PQiet4gtEVIrX4zzLxnCj06AwsEDJwJVBbKrEI4t6qE8XRSIvU2irka0dcpziKW6w=="],
|
||||
|
||||
"ai/@ai-sdk/provider": ["@ai-sdk/provider@3.0.8", "", { "dependencies": { "json-schema": "^0.4.0" } }, "sha512-oGMAgGoQdBXbZqNG0Ze56CHjDZ1IDYOwGYxYjO5KLSlz5HiNQ9udIXsPZ61VWaHGZ5XW/jyjmr6t2xz2jGVwbQ=="],
|
||||
|
||||
"ai/@ai-sdk/provider-utils": ["@ai-sdk/provider-utils@4.0.15", "", { "dependencies": { "@ai-sdk/provider": "3.0.8", "@standard-schema/spec": "^1.1.0", "eventsource-parser": "^3.0.6" }, "peerDependencies": { "zod": "^3.25.76 || ^4.1.8" } }, "sha512-8XiKWbemmCbvNN0CLR9u3PQiet4gtEVIrX4zzLxnCj06AwsEDJwJVBbKrEI4t6qE8XRSIvU2irka0dcpziKW6w=="],
|
||||
}
|
||||
}
|
||||
@@ -3,17 +3,16 @@ import { readFile, writeFile, mkdir } from "node:fs/promises"
|
||||
import { join, dirname } from "node:path"
|
||||
import { stepCountIs, streamText, type CoreMessage } from "ai"
|
||||
import { tool } from "ai"
|
||||
import { createOpenAICompatible } from "@ai-sdk/openai-compatible"
|
||||
import { createFriendli } from "@friendliai/ai-provider"
|
||||
import { z } from "zod"
|
||||
import { formatHashLines } from "../../src/tools/hashline-edit/hash-computation"
|
||||
import { normalizeHashlineEdits } from "../../src/tools/hashline-edit/normalize-edits"
|
||||
import { applyHashlineEditsWithReport } from "../../src/tools/hashline-edit/edit-operations"
|
||||
import { canonicalizeFileText, restoreFileText } from "../../src/tools/hashline-edit/file-text-canonicalization"
|
||||
import { HASHLINE_EDIT_DESCRIPTION } from "../../src/tools/hashline-edit/tool-description"
|
||||
import { formatHashLines } from "../src/tools/hashline-edit/hash-computation"
|
||||
import { normalizeHashlineEdits } from "../src/tools/hashline-edit/normalize-edits"
|
||||
import { applyHashlineEditsWithReport } from "../src/tools/hashline-edit/edit-operations"
|
||||
import { canonicalizeFileText, restoreFileText } from "../src/tools/hashline-edit/file-text-canonicalization"
|
||||
|
||||
const DEFAULT_MODEL = "minimax-m2.5-free"
|
||||
const DEFAULT_MODEL = "MiniMaxAI/MiniMax-M2.5"
|
||||
const MAX_STEPS = 50
|
||||
const sessionId = `hashline-${Date.now()}-${Math.random().toString(36).slice(2, 8)}`
|
||||
const sessionId = `bench-${Date.now()}-${Math.random().toString(36).slice(2, 8)}`
|
||||
|
||||
const emit = (event: Record<string, unknown>) =>
|
||||
console.log(JSON.stringify({ sessionId, timestamp: new Date().toISOString(), ...event }))
|
||||
@@ -34,7 +33,7 @@ function parseArgs(): { prompt: string; modelId: string } {
|
||||
// --no-translate, --think consumed silently
|
||||
}
|
||||
if (!prompt) {
|
||||
console.error("Usage: bun run tests/hashline/headless.ts -p <prompt> [-m <model>]")
|
||||
console.error("Usage: bun run benchmarks/headless.ts -p <prompt> [-m <model>]")
|
||||
process.exit(1)
|
||||
}
|
||||
return { prompt, modelId }
|
||||
@@ -58,7 +57,7 @@ const readFileTool = tool({
|
||||
})
|
||||
|
||||
const editFileTool = tool({
|
||||
description: HASHLINE_EDIT_DESCRIPTION,
|
||||
description: "Edit a file using hashline anchors (LINE#ID format)",
|
||||
inputSchema: z.object({
|
||||
path: z.string(),
|
||||
edits: z.array(
|
||||
@@ -117,12 +116,8 @@ const editFileTool = tool({
|
||||
async function run() {
|
||||
const { prompt, modelId } = parseArgs()
|
||||
|
||||
const provider = createOpenAICompatible({
|
||||
name: "hashline-test",
|
||||
baseURL: process.env.HASHLINE_TEST_BASE_URL ?? "https://quotio.mengmota.com/v1",
|
||||
apiKey: process.env.HASHLINE_TEST_API_KEY ?? "quotio-local-60A613FE-DB74-40FF-923E-A14151951E5D",
|
||||
})
|
||||
const model = provider.chatModel(modelId)
|
||||
const friendli = createFriendli({ apiKey: process.env.FRIENDLI_TOKEN! })
|
||||
const model = friendli(modelId)
|
||||
const tools = { read_file: readFileTool, edit_file: editFileTool }
|
||||
|
||||
emit({ type: "user", content: prompt })
|
||||
@@ -130,8 +125,7 @@ async function run() {
|
||||
const messages: CoreMessage[] = [{ role: "user", content: prompt }]
|
||||
const system =
|
||||
"You are a code editing assistant. Use read_file to read files and edit_file to edit them. " +
|
||||
"Always read a file before editing it to get fresh LINE#ID anchors.\n\n" +
|
||||
"edit_file tool description:\n" + HASHLINE_EDIT_DESCRIPTION
|
||||
"Always read a file before editing it to get fresh LINE#ID anchors."
|
||||
|
||||
for (let step = 0; step < MAX_STEPS; step++) {
|
||||
const stream = streamText({
|
||||
@@ -167,7 +161,6 @@ async function run() {
|
||||
...(isError ? { error: output } : {}),
|
||||
})
|
||||
break
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
@@ -198,4 +191,3 @@ run()
|
||||
const elapsed = ((Date.now() - startTime) / 1000).toFixed(2)
|
||||
console.error(`[headless] Completed in ${elapsed}s`)
|
||||
})
|
||||
|
||||
19
benchmarks/package.json
Normal file
19
benchmarks/package.json
Normal file
@@ -0,0 +1,19 @@
|
||||
{
|
||||
"name": "hashline-edit-benchmark",
|
||||
"version": "0.1.0",
|
||||
"private": true,
|
||||
"type": "module",
|
||||
"description": "Hashline edit tool benchmark using Vercel AI SDK with FriendliAI provider",
|
||||
"scripts": {
|
||||
"bench:basic": "bun run test-edit-ops.ts",
|
||||
"bench:edge": "bun run test-edge-cases.ts",
|
||||
"bench:multi": "bun run test-multi-model.ts",
|
||||
"bench:all": "bun run bench:basic && bun run bench:edge"
|
||||
},
|
||||
"dependencies": {
|
||||
"ai": "^6.0.94",
|
||||
"@ai-sdk/openai": "^1.3.0",
|
||||
"@friendliai/ai-provider": "^1.0.9",
|
||||
"zod": "^4.1.0"
|
||||
}
|
||||
}
|
||||
@@ -14,7 +14,10 @@ import { resolve } from "node:path";
|
||||
|
||||
// ── Models ────────────────────────────────────────────────────
|
||||
const MODELS = [
|
||||
{ id: "minimax-m2.5-free", short: "M2.5-Free" },
|
||||
{ id: "MiniMaxAI/MiniMax-M2.5", short: "M2.5" },
|
||||
// { id: "MiniMaxAI/MiniMax-M2.1", short: "M2.1" }, // masked: slow + timeout-prone
|
||||
// { id: "zai-org/GLM-5", short: "GLM-5" }, // masked: API 503
|
||||
{ id: "zai-org/GLM-4.7", short: "GLM-4.7" },
|
||||
];
|
||||
|
||||
// ── CLI args ──────────────────────────────────────────────────
|
||||
@@ -71,19 +71,9 @@ function getSignalExitCode(signal) {
|
||||
return 128 + (signalCodeByName[signal] ?? 1);
|
||||
}
|
||||
|
||||
function getPackageBaseName() {
|
||||
try {
|
||||
const packageJson = JSON.parse(readFileSync(new URL("../package.json", import.meta.url), "utf8"));
|
||||
return packageJson.name || "oh-my-opencode";
|
||||
} catch {
|
||||
return "oh-my-opencode";
|
||||
}
|
||||
}
|
||||
|
||||
function main() {
|
||||
const { platform, arch } = process;
|
||||
const libcFamily = getLibcFamily();
|
||||
const packageBaseName = getPackageBaseName();
|
||||
const avx2Supported = supportsAvx2();
|
||||
|
||||
let packageCandidates;
|
||||
@@ -93,7 +83,6 @@ function main() {
|
||||
arch,
|
||||
libcFamily,
|
||||
preferBaseline: avx2Supported === false,
|
||||
packageBaseName,
|
||||
});
|
||||
} catch (error) {
|
||||
console.error(`\noh-my-opencode: ${error.message}\n`);
|
||||
|
||||
@@ -3,11 +3,11 @@
|
||||
|
||||
/**
|
||||
* Get the platform-specific package name
|
||||
* @param {{ platform: string, arch: string, libcFamily?: string | null, packageBaseName?: string }} options
|
||||
* @param {{ platform: string, arch: string, libcFamily?: string | null }} options
|
||||
* @returns {string} Package name like "oh-my-opencode-darwin-arm64"
|
||||
* @throws {Error} If libc cannot be detected on Linux
|
||||
*/
|
||||
export function getPlatformPackage({ platform, arch, libcFamily, packageBaseName = "oh-my-opencode" }) {
|
||||
export function getPlatformPackage({ platform, arch, libcFamily }) {
|
||||
let suffix = "";
|
||||
if (platform === "linux") {
|
||||
if (libcFamily === null || libcFamily === undefined) {
|
||||
@@ -23,13 +23,13 @@ export function getPlatformPackage({ platform, arch, libcFamily, packageBaseName
|
||||
|
||||
// Map platform names: win32 -> windows (for package name)
|
||||
const os = platform === "win32" ? "windows" : platform;
|
||||
return `${packageBaseName}-${os}-${arch}${suffix}`;
|
||||
return `oh-my-opencode-${os}-${arch}${suffix}`;
|
||||
}
|
||||
|
||||
/** @param {{ platform: string, arch: string, libcFamily?: string | null, preferBaseline?: boolean, packageBaseName?: string }} options */
|
||||
export function getPlatformPackageCandidates({ platform, arch, libcFamily, preferBaseline = false, packageBaseName = "oh-my-opencode" }) {
|
||||
const primaryPackage = getPlatformPackage({ platform, arch, libcFamily, packageBaseName });
|
||||
const baselinePackage = getBaselinePlatformPackage({ platform, arch, libcFamily, packageBaseName });
|
||||
/** @param {{ platform: string, arch: string, libcFamily?: string | null, preferBaseline?: boolean }} options */
|
||||
export function getPlatformPackageCandidates({ platform, arch, libcFamily, preferBaseline = false }) {
|
||||
const primaryPackage = getPlatformPackage({ platform, arch, libcFamily });
|
||||
const baselinePackage = getBaselinePlatformPackage({ platform, arch, libcFamily });
|
||||
|
||||
if (!baselinePackage) {
|
||||
return [primaryPackage];
|
||||
@@ -38,18 +38,18 @@ export function getPlatformPackageCandidates({ platform, arch, libcFamily, prefe
|
||||
return preferBaseline ? [baselinePackage, primaryPackage] : [primaryPackage, baselinePackage];
|
||||
}
|
||||
|
||||
/** @param {{ platform: string, arch: string, libcFamily?: string | null, packageBaseName?: string }} options */
|
||||
function getBaselinePlatformPackage({ platform, arch, libcFamily, packageBaseName = "oh-my-opencode" }) {
|
||||
/** @param {{ platform: string, arch: string, libcFamily?: string | null }} options */
|
||||
function getBaselinePlatformPackage({ platform, arch, libcFamily }) {
|
||||
if (arch !== "x64") {
|
||||
return null;
|
||||
}
|
||||
|
||||
if (platform === "darwin") {
|
||||
return `${packageBaseName}-darwin-x64-baseline`;
|
||||
return "oh-my-opencode-darwin-x64-baseline";
|
||||
}
|
||||
|
||||
if (platform === "win32") {
|
||||
return `${packageBaseName}-windows-x64-baseline`;
|
||||
return "oh-my-opencode-windows-x64-baseline";
|
||||
}
|
||||
|
||||
if (platform === "linux") {
|
||||
@@ -61,10 +61,10 @@ function getBaselinePlatformPackage({ platform, arch, libcFamily, packageBaseNam
|
||||
}
|
||||
|
||||
if (libcFamily === "musl") {
|
||||
return `${packageBaseName}-linux-x64-musl-baseline`;
|
||||
return "oh-my-opencode-linux-x64-musl-baseline";
|
||||
}
|
||||
|
||||
return `${packageBaseName}-linux-x64-baseline`;
|
||||
return "oh-my-opencode-linux-x64-baseline";
|
||||
}
|
||||
|
||||
return null;
|
||||
|
||||
@@ -190,21 +190,6 @@ describe("getPlatformPackageCandidates", () => {
|
||||
]);
|
||||
});
|
||||
|
||||
|
||||
|
||||
test("supports renamed package family via packageBaseName override", () => {
|
||||
// #given Linux x64 with glibc and renamed package base
|
||||
const input = { platform: "linux", arch: "x64", libcFamily: "glibc", packageBaseName: "oh-my-openagent" };
|
||||
|
||||
// #when getting package candidates
|
||||
const result = getPlatformPackageCandidates(input);
|
||||
|
||||
// #then returns renamed package family candidates
|
||||
expect(result).toEqual([
|
||||
"oh-my-openagent-linux-x64",
|
||||
"oh-my-openagent-linux-x64-baseline",
|
||||
]);
|
||||
});
|
||||
test("returns only one candidate for ARM64", () => {
|
||||
// #given non-x64 platform
|
||||
const input = { platform: "linux", arch: "arm64", libcFamily: "glibc" };
|
||||
|
||||
98
bun.lock
98
bun.lock
@@ -5,13 +5,13 @@
|
||||
"": {
|
||||
"name": "oh-my-opencode",
|
||||
"dependencies": {
|
||||
"@ast-grep/cli": "^0.41.1",
|
||||
"@ast-grep/napi": "^0.41.1",
|
||||
"@ast-grep/cli": "^0.40.0",
|
||||
"@ast-grep/napi": "^0.40.0",
|
||||
"@clack/prompts": "^0.11.0",
|
||||
"@code-yeongyu/comment-checker": "^0.7.0",
|
||||
"@modelcontextprotocol/sdk": "^1.25.2",
|
||||
"@opencode-ai/plugin": "^1.2.24",
|
||||
"@opencode-ai/sdk": "^1.2.24",
|
||||
"@opencode-ai/plugin": "^1.2.16",
|
||||
"@opencode-ai/sdk": "^1.2.17",
|
||||
"commander": "^14.0.2",
|
||||
"detect-libc": "^2.0.0",
|
||||
"diff": "^8.0.3",
|
||||
@@ -25,21 +25,21 @@
|
||||
"devDependencies": {
|
||||
"@types/js-yaml": "^4.0.9",
|
||||
"@types/picomatch": "^3.0.2",
|
||||
"bun-types": "1.3.10",
|
||||
"bun-types": "1.3.6",
|
||||
"typescript": "^5.7.3",
|
||||
},
|
||||
"optionalDependencies": {
|
||||
"oh-my-opencode-darwin-arm64": "3.11.0",
|
||||
"oh-my-opencode-darwin-x64": "3.11.0",
|
||||
"oh-my-opencode-darwin-x64-baseline": "3.11.0",
|
||||
"oh-my-opencode-linux-arm64": "3.11.0",
|
||||
"oh-my-opencode-linux-arm64-musl": "3.11.0",
|
||||
"oh-my-opencode-linux-x64": "3.11.0",
|
||||
"oh-my-opencode-linux-x64-baseline": "3.11.0",
|
||||
"oh-my-opencode-linux-x64-musl": "3.11.0",
|
||||
"oh-my-opencode-linux-x64-musl-baseline": "3.11.0",
|
||||
"oh-my-opencode-windows-x64": "3.11.0",
|
||||
"oh-my-opencode-windows-x64-baseline": "3.11.0",
|
||||
"oh-my-opencode-darwin-arm64": "3.10.0",
|
||||
"oh-my-opencode-darwin-x64": "3.10.0",
|
||||
"oh-my-opencode-darwin-x64-baseline": "3.10.0",
|
||||
"oh-my-opencode-linux-arm64": "3.10.0",
|
||||
"oh-my-opencode-linux-arm64-musl": "3.10.0",
|
||||
"oh-my-opencode-linux-x64": "3.10.0",
|
||||
"oh-my-opencode-linux-x64-baseline": "3.10.0",
|
||||
"oh-my-opencode-linux-x64-musl": "3.10.0",
|
||||
"oh-my-opencode-linux-x64-musl-baseline": "3.10.0",
|
||||
"oh-my-opencode-windows-x64": "3.10.0",
|
||||
"oh-my-opencode-windows-x64-baseline": "3.10.0",
|
||||
},
|
||||
},
|
||||
},
|
||||
@@ -49,44 +49,44 @@
|
||||
"@code-yeongyu/comment-checker",
|
||||
],
|
||||
"overrides": {
|
||||
"@opencode-ai/sdk": "^1.2.24",
|
||||
"@opencode-ai/sdk": "^1.2.17",
|
||||
},
|
||||
"packages": {
|
||||
"@ast-grep/cli": ["@ast-grep/cli@0.41.1", "", { "dependencies": { "detect-libc": "2.1.2" }, "optionalDependencies": { "@ast-grep/cli-darwin-arm64": "0.41.1", "@ast-grep/cli-darwin-x64": "0.41.1", "@ast-grep/cli-linux-arm64-gnu": "0.41.1", "@ast-grep/cli-linux-x64-gnu": "0.41.1", "@ast-grep/cli-win32-arm64-msvc": "0.41.1", "@ast-grep/cli-win32-ia32-msvc": "0.41.1", "@ast-grep/cli-win32-x64-msvc": "0.41.1" }, "bin": { "sg": "sg", "ast-grep": "ast-grep" } }, "sha512-6oSuzF1Ra0d9jdcmflRIR1DHcicI7TYVxaaV/hajV51J49r6C+1BA2H9G+e47lH4sDEXUS9KWLNGNvXa/Gqs5A=="],
|
||||
"@ast-grep/cli": ["@ast-grep/cli@0.40.5", "", { "dependencies": { "detect-libc": "2.1.2" }, "optionalDependencies": { "@ast-grep/cli-darwin-arm64": "0.40.5", "@ast-grep/cli-darwin-x64": "0.40.5", "@ast-grep/cli-linux-arm64-gnu": "0.40.5", "@ast-grep/cli-linux-x64-gnu": "0.40.5", "@ast-grep/cli-win32-arm64-msvc": "0.40.5", "@ast-grep/cli-win32-ia32-msvc": "0.40.5", "@ast-grep/cli-win32-x64-msvc": "0.40.5" }, "bin": { "sg": "sg", "ast-grep": "ast-grep" } }, "sha512-yVXL7Gz0WIHerQLf+MVaVSkhIhidtWReG5akNVr/JS9OVCVkSdz7gWm7H8jVv2M9OO1tauuG76K3UaRGBPu5lQ=="],
|
||||
|
||||
"@ast-grep/cli-darwin-arm64": ["@ast-grep/cli-darwin-arm64@0.41.1", "", { "os": "darwin", "cpu": "arm64" }, "sha512-30lrXtyDB+16WS89Bk8sufA5TVUczyQye4PoIYLxZr+PRbPW7thpxHwBwGWL6QvPvUtlElrCe4seA1CEwFxeFA=="],
|
||||
"@ast-grep/cli-darwin-arm64": ["@ast-grep/cli-darwin-arm64@0.40.5", "", { "os": "darwin", "cpu": "arm64" }, "sha512-T9CzwJ1GqQhnANdsu6c7iT1akpvTVMK+AZrxnhIPv33Ze5hrXUUkqan+j4wUAukRJDqU7u94EhXLSLD+5tcJ8g=="],
|
||||
|
||||
"@ast-grep/cli-darwin-x64": ["@ast-grep/cli-darwin-x64@0.41.1", "", { "os": "darwin", "cpu": "x64" }, "sha512-jRft57aWRgqYgLXooWxS9Nx5mb5JJ/KQIwEqacWkcmDZEdEui7oG50//6y4/vU5WRcS1n6oB2Vs7WBvTh3/Ypg=="],
|
||||
"@ast-grep/cli-darwin-x64": ["@ast-grep/cli-darwin-x64@0.40.5", "", { "os": "darwin", "cpu": "x64" }, "sha512-ez9b2zKvXU8f4ghhjlqYvbx6tWCKJTuVlNVqDDfjqwwhGeiTYfnzMlSVat4ElYRMd21gLtXZIMy055v2f21Ztg=="],
|
||||
|
||||
"@ast-grep/cli-linux-arm64-gnu": ["@ast-grep/cli-linux-arm64-gnu@0.41.1", "", { "os": "linux", "cpu": "arm64" }, "sha512-1XUL+8u+Xs1FoM2W6F4v8pRa2aQQcp5CZXBG8uy9n8FhwsQtrhBclJ2Vr9g/zzswHQT1293mnP5TOk1wlYZq6w=="],
|
||||
"@ast-grep/cli-linux-arm64-gnu": ["@ast-grep/cli-linux-arm64-gnu@0.40.5", "", { "os": "linux", "cpu": "arm64" }, "sha512-VXa2L1IEYD66AMb0GuG7VlMMbPmEGoJUySWDcwSZo/D9neiry3MJ41LQR5oTG2HyhIPBsf9umrXnmuRq66BviA=="],
|
||||
|
||||
"@ast-grep/cli-linux-x64-gnu": ["@ast-grep/cli-linux-x64-gnu@0.41.1", "", { "os": "linux", "cpu": "x64" }, "sha512-oSsbXzbcl4hnRAw7b1bTFZapx9s+O8ToJJKI44oJAb7xKIG3Rubn2IMBOFvMvjjWEEax8PpS2IocgdB8nUAcbA=="],
|
||||
"@ast-grep/cli-linux-x64-gnu": ["@ast-grep/cli-linux-x64-gnu@0.40.5", "", { "os": "linux", "cpu": "x64" }, "sha512-GQC5162eIOWXR2eQQ6Knzg7/8Trp5E1ODJkaErf0IubdQrZBGqj5AAcQPcWgPbbnmktjIp0H4NraPpOJ9eJ22A=="],
|
||||
|
||||
"@ast-grep/cli-win32-arm64-msvc": ["@ast-grep/cli-win32-arm64-msvc@0.41.1", "", { "os": "win32", "cpu": "arm64" }, "sha512-jTMNqjXnQUhInMB1X06sxWZJv/6pd4/iYSyk8RR5kdulnuNzoGEB9KYbm6ojxktPtMfZpb+7eShQLqqy/dG6Ag=="],
|
||||
"@ast-grep/cli-win32-arm64-msvc": ["@ast-grep/cli-win32-arm64-msvc@0.40.5", "", { "os": "win32", "cpu": "arm64" }, "sha512-YiZdnQZsSlXQTMsZJop/Ux9MmUGfuRvC2x/UbFgrt5OBSYxND+yoiMc0WcA3WG+wU+tt4ZkB5HUea3r/IkOLYA=="],
|
||||
|
||||
"@ast-grep/cli-win32-ia32-msvc": ["@ast-grep/cli-win32-ia32-msvc@0.41.1", "", { "os": "win32", "cpu": "ia32" }, "sha512-mCTyr6/KQneKk0iYaWup4ywW5buNcFqL6TrJVfU0tkd38fu/RtJ5zywr978vVvFxsY+urRU0qkrmtQqXQNwDFA=="],
|
||||
"@ast-grep/cli-win32-ia32-msvc": ["@ast-grep/cli-win32-ia32-msvc@0.40.5", "", { "os": "win32", "cpu": "ia32" }, "sha512-MHkCxCITVTr8sY9CcVqNKbfUzMa3Hc6IilGXad0Clnw2vNmPfWqSky+hU/UTerr5YHWwWfAVURH7ANZgirtx0Q=="],
|
||||
|
||||
"@ast-grep/cli-win32-x64-msvc": ["@ast-grep/cli-win32-x64-msvc@0.41.1", "", { "os": "win32", "cpu": "x64" }, "sha512-AUbR67UKWsfgyy3SWQq258ZB0xSlaAe15Gl5hPu5tbUu4HTt6rKrUCTEEubYgbNdPPZWtxjobjFjMsDTWfnrug=="],
|
||||
"@ast-grep/cli-win32-x64-msvc": ["@ast-grep/cli-win32-x64-msvc@0.40.5", "", { "os": "win32", "cpu": "x64" }, "sha512-/MJ5un7yxlClaaxou9eYl+Kr2xr/yTtYtTq5aLBWjPWA6dmmJ1nAJgx5zKHVuplFXFBrFDQk3paEgAETMTGcrA=="],
|
||||
|
||||
"@ast-grep/napi": ["@ast-grep/napi@0.41.1", "", { "optionalDependencies": { "@ast-grep/napi-darwin-arm64": "0.41.1", "@ast-grep/napi-darwin-x64": "0.41.1", "@ast-grep/napi-linux-arm64-gnu": "0.41.1", "@ast-grep/napi-linux-arm64-musl": "0.41.1", "@ast-grep/napi-linux-x64-gnu": "0.41.1", "@ast-grep/napi-linux-x64-musl": "0.41.1", "@ast-grep/napi-win32-arm64-msvc": "0.41.1", "@ast-grep/napi-win32-ia32-msvc": "0.41.1", "@ast-grep/napi-win32-x64-msvc": "0.41.1" } }, "sha512-OYQVWBbb43af2lTSCayMS7wsZ20nl+fw6LGVl/5zSuHTZRNfANknKLk3wMA4y7RIaAiIwrldAmI6GNZeIDRTkQ=="],
|
||||
"@ast-grep/napi": ["@ast-grep/napi@0.40.5", "", { "optionalDependencies": { "@ast-grep/napi-darwin-arm64": "0.40.5", "@ast-grep/napi-darwin-x64": "0.40.5", "@ast-grep/napi-linux-arm64-gnu": "0.40.5", "@ast-grep/napi-linux-arm64-musl": "0.40.5", "@ast-grep/napi-linux-x64-gnu": "0.40.5", "@ast-grep/napi-linux-x64-musl": "0.40.5", "@ast-grep/napi-win32-arm64-msvc": "0.40.5", "@ast-grep/napi-win32-ia32-msvc": "0.40.5", "@ast-grep/napi-win32-x64-msvc": "0.40.5" } }, "sha512-hJA62OeBKUQT68DD2gDyhOqJxZxycqg8wLxbqjgqSzYttCMSDL9tiAQ9abgekBYNHudbJosm9sWOEbmCDfpX2A=="],
|
||||
|
||||
"@ast-grep/napi-darwin-arm64": ["@ast-grep/napi-darwin-arm64@0.41.1", "", { "os": "darwin", "cpu": "arm64" }, "sha512-sZHwg/oD6YB2y4VD8ZMeMHBq/ONil+mx+bB61YAiGQB+8UCMSFxJupvtNICB/BnIFqcPCVz/jCaSdbASLrbXQQ=="],
|
||||
"@ast-grep/napi-darwin-arm64": ["@ast-grep/napi-darwin-arm64@0.40.5", "", { "os": "darwin", "cpu": "arm64" }, "sha512-2F072fGN0WTq7KI3okuEnkGJVEHLbi56Bw1H6NAMf7j2mJJeQWsRyGOMcyNnUXZDeNdvoMH0OB2a5wwUegY/nQ=="],
|
||||
|
||||
"@ast-grep/napi-darwin-x64": ["@ast-grep/napi-darwin-x64@0.41.1", "", { "os": "darwin", "cpu": "x64" }, "sha512-SL9hGB8sKvPnLUcigiDQrhohL7N4ujy1+t885kGcBkMXR73JT05OpPmvw0AWmg8l2iH1e5uNK/ZjnV/lSkynxQ=="],
|
||||
"@ast-grep/napi-darwin-x64": ["@ast-grep/napi-darwin-x64@0.40.5", "", { "os": "darwin", "cpu": "x64" }, "sha512-dJMidHZhhxuLBYNi6/FKI812jQ7wcFPSKkVPwviez2D+KvYagapUMAV/4dJ7FCORfguVk8Y0jpPAlYmWRT5nvA=="],
|
||||
|
||||
"@ast-grep/napi-linux-arm64-gnu": ["@ast-grep/napi-linux-arm64-gnu@0.41.1", "", { "os": "linux", "cpu": "arm64" }, "sha512-mkNQpkm1jvnIdeRMnEWZ4Q0gNGApoNTMAoJRVmY11CkA4C/vIdNIjxj7UB61xV42Ng/A7Fw8mQUQuFos0lAKPQ=="],
|
||||
"@ast-grep/napi-linux-arm64-gnu": ["@ast-grep/napi-linux-arm64-gnu@0.40.5", "", { "os": "linux", "cpu": "arm64" }, "sha512-nBRCbyoS87uqkaw4Oyfe5VO+SRm2B+0g0T8ME69Qry9ShMf41a2bTdpcQx9e8scZPogq+CTwDHo3THyBV71l9w=="],
|
||||
|
||||
"@ast-grep/napi-linux-arm64-musl": ["@ast-grep/napi-linux-arm64-musl@0.41.1", "", { "os": "linux", "cpu": "arm64" }, "sha512-0G3cHyc+8A945aLie55bLZ+oaEBer0EFlyP/GlwRAx4nn5vGBct1hVTxSexWJ6AxnnRNPlN0mvswVwXiE7H7gA=="],
|
||||
"@ast-grep/napi-linux-arm64-musl": ["@ast-grep/napi-linux-arm64-musl@0.40.5", "", { "os": "linux", "cpu": "arm64" }, "sha512-/qKsmds5FMoaEj6FdNzepbmLMtlFuBLdrAn9GIWCqOIcVcYvM1Nka8+mncfeXB/MFZKOrzQsQdPTWqrrQzXLrA=="],
|
||||
|
||||
"@ast-grep/napi-linux-x64-gnu": ["@ast-grep/napi-linux-x64-gnu@0.41.1", "", { "os": "linux", "cpu": "x64" }, "sha512-+aNiCik3iTMtUrMp1k2yIMjby1U64EydTH1qotlx+fh8YvwrwwxZWct7NlurY3MILgT/WONSxhHKmL5NsbB4dw=="],
|
||||
"@ast-grep/napi-linux-x64-gnu": ["@ast-grep/napi-linux-x64-gnu@0.40.5", "", { "os": "linux", "cpu": "x64" }, "sha512-DP4oDbq7f/1A2hRTFLhJfDFR6aI5mRWdEfKfHzRItmlKsR9WlcEl1qDJs/zX9R2EEtIDsSKRzuJNfJllY3/W8Q=="],
|
||||
|
||||
"@ast-grep/napi-linux-x64-musl": ["@ast-grep/napi-linux-x64-musl@0.41.1", "", { "os": "linux", "cpu": "x64" }, "sha512-rBrZSx5za3OliYcJcUrbLct+1+8oxh8ZEjYPiLCybe4FhspNKGM952g8a4sjgRuwbKS9BstYO9Fz+wthFnaFUQ=="],
|
||||
"@ast-grep/napi-linux-x64-musl": ["@ast-grep/napi-linux-x64-musl@0.40.5", "", { "os": "linux", "cpu": "x64" }, "sha512-BRZUvVBPUNpWPo6Ns8chXVzxHPY+k9gpsubGTHy92Q26ecZULd/dTkWWdnvfhRqttsSQ9Pe/XQdi5+hDQ6RYcg=="],
|
||||
|
||||
"@ast-grep/napi-win32-arm64-msvc": ["@ast-grep/napi-win32-arm64-msvc@0.41.1", "", { "os": "win32", "cpu": "arm64" }, "sha512-uNRHM3a1qFN0SECJDCEDVy1b0N75JNhJE2O/2BhDkDo0qM8kEewf9jRtG1fwpgZbMK2KoKvMHU/KQ73fWN44Zw=="],
|
||||
"@ast-grep/napi-win32-arm64-msvc": ["@ast-grep/napi-win32-arm64-msvc@0.40.5", "", { "os": "win32", "cpu": "arm64" }, "sha512-y95zSEwc7vhxmcrcH0GnK4ZHEBQrmrszRBNQovzaciF9GUqEcCACNLoBesn4V47IaOp4fYgD2/EhGRTIBFb2Ug=="],
|
||||
|
||||
"@ast-grep/napi-win32-ia32-msvc": ["@ast-grep/napi-win32-ia32-msvc@0.41.1", "", { "os": "win32", "cpu": "ia32" }, "sha512-uNPQwGUBGIbCX+WhEIfYJf/VrS7o5+vJvT4MVEHI8aVJnpjcFsLrFI0hIv044OXxnleOo2HUvEmjOrub//at/Q=="],
|
||||
"@ast-grep/napi-win32-ia32-msvc": ["@ast-grep/napi-win32-ia32-msvc@0.40.5", "", { "os": "win32", "cpu": "ia32" }, "sha512-K/u8De62iUnFCzVUs7FBdTZ2Jrgc5/DLHqjpup66KxZ7GIM9/HGME/O8aSoPkpcAeCD4TiTZ11C1i5p5H98hTg=="],
|
||||
|
||||
"@ast-grep/napi-win32-x64-msvc": ["@ast-grep/napi-win32-x64-msvc@0.41.1", "", { "os": "win32", "cpu": "x64" }, "sha512-xFp68OCUEmWYcqoreZFaf2xwMhm/22Qf6bR2Qyn8WNVY9RF4m4+k5K+7Wn+n9xy0vHUPhtFd1So/SvuaqLHEoA=="],
|
||||
"@ast-grep/napi-win32-x64-msvc": ["@ast-grep/napi-win32-x64-msvc@0.40.5", "", { "os": "win32", "cpu": "x64" }, "sha512-dqm5zg/o4Nh4VOQPEpMS23ot8HVd22gG0eg01t4CFcZeuzyuSgBlOL3N7xLbz3iH2sVkk7keuBwAzOIpTqziNQ=="],
|
||||
|
||||
"@clack/core": ["@clack/core@0.5.0", "", { "dependencies": { "picocolors": "^1.0.0", "sisteransi": "^1.0.5" } }, "sha512-p3y0FIOwaYRUPRcMO7+dlmLh8PSRcrjuTndsiA0WAFbWES0mLZlrjVoBRZ9DzkPFJZG6KGkJmoEAY0ZcVWTkow=="],
|
||||
|
||||
@@ -98,9 +98,9 @@
|
||||
|
||||
"@modelcontextprotocol/sdk": ["@modelcontextprotocol/sdk@1.27.1", "", { "dependencies": { "@hono/node-server": "^1.19.9", "ajv": "^8.17.1", "ajv-formats": "^3.0.1", "content-type": "^1.0.5", "cors": "^2.8.5", "cross-spawn": "^7.0.5", "eventsource": "^3.0.2", "eventsource-parser": "^3.0.0", "express": "^5.2.1", "express-rate-limit": "^8.2.1", "hono": "^4.11.4", "jose": "^6.1.3", "json-schema-typed": "^8.0.2", "pkce-challenge": "^5.0.0", "raw-body": "^3.0.0", "zod": "^3.25 || ^4.0", "zod-to-json-schema": "^3.25.1" }, "peerDependencies": { "@cfworker/json-schema": "^4.1.1" }, "optionalPeers": ["@cfworker/json-schema"] }, "sha512-sr6GbP+4edBwFndLbM60gf07z0FQ79gaExpnsjMGePXqFcSSb7t6iscpjk9DhFhwd+mTEQrzNafGP8/iGGFYaA=="],
|
||||
|
||||
"@opencode-ai/plugin": ["@opencode-ai/plugin@1.2.24", "", { "dependencies": { "@opencode-ai/sdk": "1.2.24", "zod": "4.1.8" } }, "sha512-B3hw415D+2w6AtdRdvKWkuQVT0LXDWTdnAZhZC6gbd+UHh5O5DMmnZTe/YM8yK8ZZO9Dvo5rnV78TdDDYunJiw=="],
|
||||
"@opencode-ai/plugin": ["@opencode-ai/plugin@1.2.16", "", { "dependencies": { "@opencode-ai/sdk": "1.2.16", "zod": "4.1.8" } }, "sha512-9Kb7BQIC2P3oKCvI8K3thP5YP0vE7yLvcmBmgyACUIqc3e5UL6U+4umLpTvgQa2eQdjxtOXznuGTNwgcGMHUHg=="],
|
||||
|
||||
"@opencode-ai/sdk": ["@opencode-ai/sdk@1.2.24", "", {}, "sha512-MQamFkRl4B/3d6oIRLNpkYR2fcwet1V/ffKyOKJXWjtP/CT9PDJMtLpu6olVHjXKQi8zMNltwuMhv1QsNtRlZg=="],
|
||||
"@opencode-ai/sdk": ["@opencode-ai/sdk@1.2.17", "", {}, "sha512-HdeLeyJ2/Yl/NBHqw9pGFBnkIXuf0Id1kX1GMXDcnZwbJROUJ6TtrW/wLngTYW478E4CCm1jwknjxxmDuxzVMQ=="],
|
||||
|
||||
"@types/js-yaml": ["@types/js-yaml@4.0.9", "", {}, "sha512-k4MGaQl5TGo/iipqb2UDG2UwjXziSWkh0uysQelTlJpX1qGlpUZYm8PnO4DxG1qBomtJUdYJ6qR6xdIah10JLg=="],
|
||||
|
||||
@@ -118,7 +118,7 @@
|
||||
|
||||
"body-parser": ["body-parser@2.2.2", "", { "dependencies": { "bytes": "^3.1.2", "content-type": "^1.0.5", "debug": "^4.4.3", "http-errors": "^2.0.0", "iconv-lite": "^0.7.0", "on-finished": "^2.4.1", "qs": "^6.14.1", "raw-body": "^3.0.1", "type-is": "^2.0.1" } }, "sha512-oP5VkATKlNwcgvxi0vM0p/D3n2C3EReYVX+DNYs5TjZFn/oQt2j+4sVJtSMr18pdRr8wjTcBl6LoV+FUwzPmNA=="],
|
||||
|
||||
"bun-types": ["bun-types@1.3.10", "", { "dependencies": { "@types/node": "*" } }, "sha512-tcpfCCl6XWo6nCVnpcVrxQ+9AYN1iqMIzgrSKYMB/fjLtV2eyAVEg7AxQJuCq/26R6HpKWykQXuSOq/21RYcbg=="],
|
||||
"bun-types": ["bun-types@1.3.6", "", { "dependencies": { "@types/node": "*" } }, "sha512-OlFwHcnNV99r//9v5IIOgQ9Uk37gZqrNMCcqEaExdkVq3Avwqok1bJFmvGMCkCE0FqzdY8VMOZpfpR3lwI+CsQ=="],
|
||||
|
||||
"bytes": ["bytes@3.1.2", "", {}, "sha512-/Nf7TyzTx6S3yRJObOAV7956r8cr2+Oj8AC5dt8wSP3BQAoeX58NoHyCU8P8zGkNXStjTSi6fzO6F0pBdcYbEg=="],
|
||||
|
||||
@@ -238,27 +238,27 @@
|
||||
|
||||
"object-inspect": ["object-inspect@1.13.4", "", {}, "sha512-W67iLl4J2EXEGTbfeHCffrjDfitvLANg0UlX3wFUUSTx92KXRFegMHUVgSqE+wvhAbi4WqjGg9czysTV2Epbew=="],
|
||||
|
||||
"oh-my-opencode-darwin-arm64": ["oh-my-opencode-darwin-arm64@3.11.0", "", { "os": "darwin", "cpu": "arm64", "bin": { "oh-my-opencode": "bin/oh-my-opencode" } }, "sha512-TLMCq1HXU1BOp3KWdcITQqT3TQcycAxvdYELMzY/17HUVHjvJiaLjyrbmw0VlgBjoRZOlmsedK+o59y7WRM40Q=="],
|
||||
"oh-my-opencode-darwin-arm64": ["oh-my-opencode-darwin-arm64@3.10.0", "", { "os": "darwin", "cpu": "arm64", "bin": { "oh-my-opencode": "bin/oh-my-opencode" } }, "sha512-KQ1Nva4eU03WIaQI8BiEgizYJAeddUIaC8dmks0Ug/2EkH6VyNj41+shI58HFGN9Jlg9Fd6MxpOW92S3JUHjOw=="],
|
||||
|
||||
"oh-my-opencode-darwin-x64": ["oh-my-opencode-darwin-x64@3.11.0", "", { "os": "darwin", "cpu": "x64", "bin": { "oh-my-opencode": "bin/oh-my-opencode" } }, "sha512-szKfyAYbI3Mp6rqxHxcHhAE8noxIzBbpfvKX0acyMB/KRqUCtgTe13aic5tz/W/Agp9NU1PVasyqjJjAtE73JA=="],
|
||||
"oh-my-opencode-darwin-x64": ["oh-my-opencode-darwin-x64@3.10.0", "", { "os": "darwin", "cpu": "x64", "bin": { "oh-my-opencode": "bin/oh-my-opencode" } }, "sha512-PydZ6wKyLZzikSZA3Q89zKZwFyg0Ouqd/S6zDsf1zzpUWT1t5EcpBtYFwuscD7L4hdkIEFm8wxnnBkz5i6BEiA=="],
|
||||
|
||||
"oh-my-opencode-darwin-x64-baseline": ["oh-my-opencode-darwin-x64-baseline@3.11.0", "", { "os": "darwin", "cpu": "x64", "bin": { "oh-my-opencode": "bin/oh-my-opencode" } }, "sha512-QZ+2LCcXK6NPopYSxFCHrYAqLccN+jMQ0YrQI+QBlsajLSsnSqfv6W3Vaxv95iLWhGey3v2oGu5OUgdW9fjy9w=="],
|
||||
"oh-my-opencode-darwin-x64-baseline": ["oh-my-opencode-darwin-x64-baseline@3.10.0", "", { "os": "darwin", "cpu": "x64", "bin": { "oh-my-opencode": "bin/oh-my-opencode" } }, "sha512-yOaVd0E1qspT2xP/BMJaJ/rpFTwkOh9U/SAk6uOuxHld6dZGI9e2Oq8F3pSD16xHnnpaz4VzadtT6HkvPdtBYg=="],
|
||||
|
||||
"oh-my-opencode-linux-arm64": ["oh-my-opencode-linux-arm64@3.11.0", "", { "os": "linux", "cpu": "arm64", "bin": { "oh-my-opencode": "bin/oh-my-opencode" } }, "sha512-NZMbNG+kJ0FTS4u5xhuBUjJ2K2Tds8sETbdq1VPT52rd+mIbVVSbugfppagEh9wbNqXqJY1HwQ/+4Q+NoGGXhQ=="],
|
||||
"oh-my-opencode-linux-arm64": ["oh-my-opencode-linux-arm64@3.10.0", "", { "os": "linux", "cpu": "arm64", "bin": { "oh-my-opencode": "bin/oh-my-opencode" } }, "sha512-pLzcPMuzBb1tpVgqMilv7QdsE2xTMLCWT3b807mzjt0302fZTfm6emwymCG25RamHdq7+mI2B0rN7hjvbymFog=="],
|
||||
|
||||
"oh-my-opencode-linux-arm64-musl": ["oh-my-opencode-linux-arm64-musl@3.11.0", "", { "os": "linux", "cpu": "arm64", "bin": { "oh-my-opencode": "bin/oh-my-opencode" } }, "sha512-f0GO63uAwzBisotiMneA7Pi2xPXUxvdX5QRC6z4X2xoB8F7/jT+2+dY8J03eM+YJVAwQWR/74hm5HFSenqMeIA=="],
|
||||
"oh-my-opencode-linux-arm64-musl": ["oh-my-opencode-linux-arm64-musl@3.10.0", "", { "os": "linux", "cpu": "arm64", "bin": { "oh-my-opencode": "bin/oh-my-opencode" } }, "sha512-ca61zr+X8q0ipO2x72qU+4R6Dsr168OM9aXI6xDHbrr0l3XZlRO8xuwQidch1vE5QRv2/IJT10KjAFInCERDug=="],
|
||||
|
||||
"oh-my-opencode-linux-x64": ["oh-my-opencode-linux-x64@3.11.0", "", { "os": "linux", "cpu": "x64", "bin": { "oh-my-opencode": "bin/oh-my-opencode" } }, "sha512-OzIgo26t1EbooHwzmli+4aemO6YqXEhJTBth8L688K1CI/xF567G3+uJemZ9U7NI+miHJRoKHcidNnaAi7bgGQ=="],
|
||||
"oh-my-opencode-linux-x64": ["oh-my-opencode-linux-x64@3.10.0", "", { "os": "linux", "cpu": "x64", "bin": { "oh-my-opencode": "bin/oh-my-opencode" } }, "sha512-m0Ys8Vnl8jUNRE5/aIseNOF1H57/W77xh3vkyBVfnjzHwQdEUWZz3IdoHaEWIFgIP2+fsNXRHqpx7Pbtuhxo6Q=="],
|
||||
|
||||
"oh-my-opencode-linux-x64-baseline": ["oh-my-opencode-linux-x64-baseline@3.11.0", "", { "os": "linux", "cpu": "x64", "bin": { "oh-my-opencode": "bin/oh-my-opencode" } }, "sha512-ac7TfBli+gaHVu4aBtP2ADWzetrFZOs+h1K39KsR6MOhDZBl+B6B1S47U+BXGWtUKIRYm4uUo578XdnmsDanoA=="],
|
||||
"oh-my-opencode-linux-x64-baseline": ["oh-my-opencode-linux-x64-baseline@3.10.0", "", { "os": "linux", "cpu": "x64", "bin": { "oh-my-opencode": "bin/oh-my-opencode" } }, "sha512-a6OhfqMXhOTq1On8YHRRlVsNtMx84kgNAnStk/sY1Dw0kXU68QK4tWXVF+wNdiRG3egeM2SvjhJ5RhWlr3CCNQ=="],
|
||||
|
||||
"oh-my-opencode-linux-x64-musl": ["oh-my-opencode-linux-x64-musl@3.11.0", "", { "os": "linux", "cpu": "x64", "bin": { "oh-my-opencode": "bin/oh-my-opencode" } }, "sha512-OvOsPNuvZQug4tGjbcpbvh67tud1K84A3Qskt9S7BHBIvMH129iV/2GGyr6aca8gwvd5T+X05H/s5mnPG6jkBQ=="],
|
||||
"oh-my-opencode-linux-x64-musl": ["oh-my-opencode-linux-x64-musl@3.10.0", "", { "os": "linux", "cpu": "x64", "bin": { "oh-my-opencode": "bin/oh-my-opencode" } }, "sha512-lZkoEWwmrlVoZKewHNslUmQ2D6eWi1YqsoZMTd3qRj8V4XI6TDZHxg86hw4oxZ/EnKO4un+r83tb09JAAb1nNQ=="],
|
||||
|
||||
"oh-my-opencode-linux-x64-musl-baseline": ["oh-my-opencode-linux-x64-musl-baseline@3.11.0", "", { "os": "linux", "cpu": "x64", "bin": { "oh-my-opencode": "bin/oh-my-opencode" } }, "sha512-fSsyVAFMoOljD+zqRO6lG3f9ka1YRLMp6rNSsPWkLEKKIyEdw1J0GcmA/48VI1NgtnEgKqS3Ft87tees1woyBw=="],
|
||||
"oh-my-opencode-linux-x64-musl-baseline": ["oh-my-opencode-linux-x64-musl-baseline@3.10.0", "", { "os": "linux", "cpu": "x64", "bin": { "oh-my-opencode": "bin/oh-my-opencode" } }, "sha512-UqArUpatMuen8+hZhMSbScaSmJlcwkEtf/IzDN1iYO0CttvhyYMUmm3el/1gWTAcaGNDFNkGmTli5WNYhnm2lA=="],
|
||||
|
||||
"oh-my-opencode-windows-x64": ["oh-my-opencode-windows-x64@3.11.0", "", { "os": "win32", "cpu": "x64", "bin": { "oh-my-opencode": "bin/oh-my-opencode.exe" } }, "sha512-k9F3/9r3pFnUVJW36+zF06znUdUzcnJp+BdvDcaJrcuuM516ECwCH0yY5WbDTFFydFBQBkPBJX9DwU8dmc4kHA=="],
|
||||
"oh-my-opencode-windows-x64": ["oh-my-opencode-windows-x64@3.10.0", "", { "os": "win32", "cpu": "x64", "bin": { "oh-my-opencode": "bin/oh-my-opencode.exe" } }, "sha512-BivOu1+Yty9N6VSmNzmxROZqjQKu3ImWjooKZDfczvYLDQmZV104QcOKV6bmdOCpHrqQ7cvdbygmeiJeRoYShg=="],
|
||||
|
||||
"oh-my-opencode-windows-x64-baseline": ["oh-my-opencode-windows-x64-baseline@3.11.0", "", { "os": "win32", "cpu": "x64", "bin": { "oh-my-opencode": "bin/oh-my-opencode.exe" } }, "sha512-mRRcCHC43TLUuIkDs0ASAUGo3DpMIkSeIPDdtBrh1eJZyVulJRGBoniIk/+Y+RJwtsUoC+lUX/auQelzJsMpbQ=="],
|
||||
"oh-my-opencode-windows-x64-baseline": ["oh-my-opencode-windows-x64-baseline@3.10.0", "", { "os": "win32", "cpu": "x64", "bin": { "oh-my-opencode": "bin/oh-my-opencode.exe" } }, "sha512-BBv+dNPuh9LEuqXUJLXNsvi3vL30zS1qcJuzlq/s8rYHry+VvEVXCRcMm5Vo0CVna8bUZf5U8MDkGDHOAiTeEw=="],
|
||||
|
||||
"on-finished": ["on-finished@2.4.1", "", { "dependencies": { "ee-first": "1.1.1" } }, "sha512-oVlzkg3ENAhCk2zdv7IJwd/QUD4z2RxRwpkcGY8psCVcCYZNq4wYnVWALHM+brtuJjePWiYF/ClmuDr8Ch5+kg=="],
|
||||
|
||||
|
||||
Some files were not shown because too many files have changed in this diff Show More
Reference in New Issue
Block a user