-
Notifications
You must be signed in to change notification settings - Fork 0
0.5.6 Beta #7
New issue
Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.
Already on GitHub? Sign in to your account
base: main
Are you sure you want to change the base?
0.5.6 Beta #7
Changes from all commits
ad02feb
2ec87f0
a9256d2
d4de4a2
bc5ec72
File filter
Filter by extension
Conversations
Jump to
Diff view
Diff view
There are no files selected for viewing
| Original file line number | Diff line number | Diff line change |
|---|---|---|
| @@ -0,0 +1,16 @@ | ||
| { | ||
| "hooks": { | ||
| "SessionStart": [ | ||
| { | ||
| "matcher": "startup|clear|compact", | ||
| "hooks": [ | ||
| { | ||
| "type": "command", | ||
| "command": "\"${CLAUDE_PLUGIN_ROOT}/hooks/run-hook.cmd\" session-start", | ||
| "async": false | ||
| } | ||
| ] | ||
| } | ||
| ] | ||
| } | ||
| } |
| Original file line number | Diff line number | Diff line change |
|---|---|---|
| @@ -0,0 +1,46 @@ | ||
| : << 'CMDBLOCK' | ||
| @echo off | ||
| REM Cross-platform polyglot wrapper for hook scripts. | ||
| REM On Windows: cmd.exe runs the batch portion, which finds and calls bash. | ||
| REM On Unix: the shell interprets this as a script (: is a no-op in bash). | ||
| REM | ||
| REM Hook scripts use extensionless filenames (e.g. "session-start" not | ||
| REM "session-start.sh") so Claude Code's Windows auto-detection -- which | ||
| REM prepends "bash" to any command containing .sh -- doesn't interfere. | ||
| REM | ||
| REM Usage: run-hook.cmd <script-name> [args...] | ||
|
|
||
| if "%~1"=="" ( | ||
| echo run-hook.cmd: missing script name >&2 | ||
| exit /b 1 | ||
| ) | ||
|
|
||
| set "HOOK_DIR=%~dp0" | ||
|
|
||
| REM Try Git for Windows bash in standard locations | ||
| if exist "C:\Program Files\Git\bin\bash.exe" ( | ||
| "C:\Program Files\Git\bin\bash.exe" "%HOOK_DIR%%~1" %2 %3 %4 %5 %6 %7 %8 %9 | ||
| exit /b %ERRORLEVEL% | ||
| ) | ||
| if exist "C:\Program Files (x86)\Git\bin\bash.exe" ( | ||
| "C:\Program Files (x86)\Git\bin\bash.exe" "%HOOK_DIR%%~1" %2 %3 %4 %5 %6 %7 %8 %9 | ||
| exit /b %ERRORLEVEL% | ||
| ) | ||
|
|
||
| REM Try bash on PATH (e.g. user-installed Git Bash, MSYS2, Cygwin) | ||
| where bash >nul 2>nul | ||
| if %ERRORLEVEL% equ 0 ( | ||
| bash "%HOOK_DIR%%~1" %2 %3 %4 %5 %6 %7 %8 %9 | ||
| exit /b %ERRORLEVEL% | ||
| ) | ||
|
|
||
| REM No bash found - exit silently rather than error | ||
| REM (plugin still works, just without SessionStart context injection) | ||
| exit /b 0 | ||
| CMDBLOCK | ||
|
|
||
| # Unix: run the named script directly | ||
| SCRIPT_DIR="$(cd "$(dirname "$0")" && pwd)" | ||
| SCRIPT_NAME="$1" | ||
| shift | ||
| exec bash "${SCRIPT_DIR}/${SCRIPT_NAME}" "$@" | ||
| Original file line number | Diff line number | Diff line change |
|---|---|---|
| @@ -0,0 +1,45 @@ | ||
| #!/usr/bin/env bash | ||
| # SessionStart hook for CortexLink plugin | ||
|
|
||
| set -euo pipefail | ||
|
|
||
| SCRIPT_DIR="$(cd "$(dirname "$0")" && pwd)" | ||
| PLUGIN_ROOT="$(cd "${SCRIPT_DIR}/.." && pwd)" | ||
|
|
||
| # Read orchestration skill — the CortexLink meta skill | ||
| orchestration_content=$(cat "${PLUGIN_ROOT}/skills/orchestration/SKILL.md" 2>&1 || echo "Error reading orchestration skill") | ||
|
|
||
| # Escape string for JSON embedding. | ||
| # Each ${s//old/new} is a single C-level pass — fast and heredoc-safe. | ||
| escape_for_json() { | ||
| local s="$1" | ||
| s="${s//\\/\\\\}" | ||
| s="${s//\"/\\\"}" | ||
| s="${s//$'\n'/\\n}" | ||
| s="${s//$'\r'/\\r}" | ||
| s="${s//$'\t'/\\t}" | ||
| printf '%s' "$s" | ||
| } | ||
|
|
||
| orchestration_escaped=$(escape_for_json "$orchestration_content") | ||
|
|
||
| peer_direction="PEER DIRECTION RULES (apply these every time you delegate):\n- If you are Claude Code (Claude): GitHub tasks → Copilot CLI. Isolated code/analysis tasks → Claude CLI (last resort only — prefer native tools first).\n- If you are Copilot CLI: code tasks, analysis, and refactors → Claude CLI.\n- ONE agent per subtask. Never route the same subtask to more than one agent.\n- Always use bash with -p flag (programmatic mode). Never open an interactive terminal session.\n- Violating any of these rules violates the spirit of CortexLink." | ||
|
|
||
| session_context="<EXTREMELY_IMPORTANT>\nYou have CortexLink — a cross-agent workflow plugin.\n\nBelow is your orchestration skill. It defines when and how to delegate tasks across CLI agents (Copilot CLI, Claude CLI). Follow it whenever multi-agent delegation could apply.\n\n${orchestration_escaped}\n\n${peer_direction}\n</EXTREMELY_IMPORTANT>" | ||
|
|
||
|
Comment on lines
+10
to
+29
There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. Session context injection is incomplete after protocol split. Line 10 only loads Proposed fix-# Read orchestration skill — the CortexLink meta skill
-orchestration_content=$(cat "${PLUGIN_ROOT}/skills/orchestration/SKILL.md" 2>&1 || echo "Error reading orchestration skill")
+read_required_file() {
+ local path="$1"
+ if [ ! -r "$path" ]; then
+ printf 'session-start: required file missing or unreadable: %s\n' "$path" >&2
+ exit 1
+ fi
+ cat "$path"
+}
+
+# Read orchestration skill + extracted required references
+orchestration_content="$(read_required_file "${PLUGIN_ROOT}/skills/orchestration/SKILL.md")"
+delegation_template_content="$(read_required_file "${PLUGIN_ROOT}/skills/orchestration/references/delegation-template.md")"
+report_format_content="$(read_required_file "${PLUGIN_ROOT}/skills/orchestration/references/report-format.md")"
+
+combined_orchestration_context="${orchestration_content}
+
+## Reference: Delegation Template
+${delegation_template_content}
+
+## Reference: Report Format
+${report_format_content}"
-orchestration_escaped=$(escape_for_json "$orchestration_content")
+orchestration_escaped=$(escape_for_json "$combined_orchestration_context")🤖 Prompt for AI Agents |
||
| # Platform detection: emit the field consumed by the current platform only. | ||
| # Claude Code and Copilot CLI both set CLAUDE_PLUGIN_ROOT (shared plugin architecture). | ||
| # Cursor IDE sets CURSOR_PLUGIN_ROOT (not a supported CortexLink platform — kept as fallback). | ||
| # Emitting both fields would cause double injection in Claude Code. | ||
| # | ||
| # Uses printf instead of heredoc to avoid a bash 5.3+ bug where heredoc | ||
| # variable expansion hangs when content exceeds ~512 bytes. | ||
| if [ -n "${CURSOR_PLUGIN_ROOT:-}" ]; then | ||
| printf '{\n "additional_context": "%s"\n}\n' "$session_context" | ||
| elif [ -n "${CLAUDE_PLUGIN_ROOT:-}" ]; then | ||
| printf '{\n "hookSpecificOutput": {\n "hookEventName": "SessionStart",\n "additionalContext": "%s"\n }\n}\n' "$session_context" | ||
| else | ||
| printf '{\n "additional_context": "%s"\n}\n' "$session_context" | ||
| fi | ||
|
|
||
| exit 0 | ||
| Original file line number | Diff line number | Diff line change | ||||||||||||||
|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|
| @@ -1,13 +1,17 @@ | ||||||||||||||||
| --- | ||||||||||||||||
| name: claude-cli | ||||||||||||||||
| description: Behavioral reference for Claude CLI. Use when delegating general code tasks, analysis, or tasks requiring Anthropic-native reasoning via `claude -p`. | ||||||||||||||||
|
|
||||||||||||||||
| description: This skill should be used when delegating general code tasks — explanations, refactors, fixes, analysis — via `claude -p`. Also use when context isolation or a specific Anthropic model is needed for the subtask. | ||||||||||||||||
| user-invocable: false | ||||||||||||||||
| --- | ||||||||||||||||
|
|
||||||||||||||||
| # Claude CLI Agent | ||||||||||||||||
|
|
||||||||||||||||
| ## When to Use | ||||||||||||||||
|
|
||||||||||||||||
| ⛔ If the host is **Claude Code**: use Claude CLI only when you specifically need context isolation or a different Anthropic model AND native tools (Task tool, inline work) are insufficient. Claude Code → Claude CLI is last resort. Prefer Copilot CLI for GitHub tasks; prefer Claude Code's native Task tool for general code tasks. | ||||||||||||||||
|
|
||||||||||||||||
| --- | ||||||||||||||||
|
|
||||||||||||||||
| **Use Claude CLI for:** | ||||||||||||||||
| - General code tasks — explanations, refactors, fixes, analysis | ||||||||||||||||
| - Tasks needing Anthropic-specific models (Sonnet, Opus, Haiku) | ||||||||||||||||
|
|
@@ -66,39 +70,65 @@ Shell access (`Bash(...)`) is a separate, deliberate decision. Use `--disallowed | |||||||||||||||
|
|
||||||||||||||||
| Use short aliases (`sonnet`, `opus`) for the latest version, or full IDs (e.g. `claude-sonnet-4-6`) to pin a specific model. | ||||||||||||||||
|
|
||||||||||||||||
| ## Working Directory | ||||||||||||||||
|
|
||||||||||||||||
| Claude CLI is sandboxed to its working directory — the same restriction as Copilot CLI. | ||||||||||||||||
|
|
||||||||||||||||
| ⛔ **Always invoke from the repo root.** Use `--cwd` or `cd` before invoking. | ||||||||||||||||
|
|
||||||||||||||||
| ```bash | ||||||||||||||||
| claude -p "..." --cwd $(git rev-parse --show-toplevel) --output-format text ... | ||||||||||||||||
| ``` | ||||||||||||||||
|
|
||||||||||||||||
| ## Invocation Patterns | ||||||||||||||||
|
|
||||||||||||||||
| Always include `--append-system-prompt` with the CortexLink agent context below. This teaches the agent the report format and self-verify protocol via the system prompt — separate from the task prompt. | ||||||||||||||||
|
|
||||||||||||||||
| ``` | ||||||||||||||||
| CORTEXLINK_AGENT_CONTEXT="You are operating as a CortexLink agent. Your output is consumed directly by a control center. Execute the task, verify your own work (Execute → Verify → fix if needed → Report), then return ONLY this structured report — plain text labels, no bold, no headers:\nSTATUS: ✅ Verified / ⚠️ Partial / ❌ Failed\nSUMMARY: <1-2 sentences>\nSTEPS:\n - <step>\nFILES: <changed files or none>\nISSUES: <notes or none>\nMax 150 words. Never mark ✅ without actually checking. For analysis tasks, ✅ = completed the analysis even if you cannot run the code." | ||||||||||||||||
| ``` | ||||||||||||||||
|
Comment on lines
+87
to
+89
There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. Add a language tag to the fenced context block. Line 87 starts an unlabeled fenced block (MD040). Proposed fix-```
+```text
CORTEXLINK_AGENT_CONTEXT="You are operating as a CortexLink agent. Your output is consumed directly by a control center. Execute the task, verify your own work (Execute → Verify → fix if needed → Report), then return ONLY this structured report — plain text labels, no bold, no headers:\nSTATUS: ✅ Verified / ⚠️ Partial / ❌ Failed\nSUMMARY: <1-2 sentences>\nSTEPS:\n - <step>\nFILES: <changed files or none>\nISSUES: <notes or none>\nMax 150 words. Never mark ✅ without actually checking. For analysis tasks, ✅ = completed the analysis even if you cannot run the code."Verify each finding against the current code and only fix it if needed. In |
||||||||||||||||
|
|
||||||||||||||||
| **Read-only delegation (question, analysis):** | ||||||||||||||||
| ```bash | ||||||||||||||||
| claude -p "[delegation prompt]" --output-format text \ | ||||||||||||||||
| --cwd $(git rev-parse --show-toplevel) \ | ||||||||||||||||
| --allowedTools "Read" --model claude-haiku-4-5 \ | ||||||||||||||||
| --no-session-persistence --max-turns 3 | ||||||||||||||||
| --no-session-persistence --max-turns 3 \ | ||||||||||||||||
| --append-system-prompt "$CORTEXLINK_AGENT_CONTEXT" | ||||||||||||||||
| ``` | ||||||||||||||||
|
|
||||||||||||||||
| **Write delegation (fix, implement):** | ||||||||||||||||
| ```bash | ||||||||||||||||
| claude -p "[delegation prompt]" --output-format text \ | ||||||||||||||||
| --cwd $(git rev-parse --show-toplevel) \ | ||||||||||||||||
| --allowedTools "Read" "Edit" "Write" \ | ||||||||||||||||
| --no-session-persistence | ||||||||||||||||
| --no-session-persistence \ | ||||||||||||||||
| --append-system-prompt "$CORTEXLINK_AGENT_CONTEXT" | ||||||||||||||||
| ``` | ||||||||||||||||
|
|
||||||||||||||||
| **Write delegation + shell (runs commands):** | ||||||||||||||||
| ```bash | ||||||||||||||||
| claude -p "[delegation prompt]" --output-format text \ | ||||||||||||||||
| --allowedTools "Read" "Edit" "Bash(git *)" \ | ||||||||||||||||
| --no-session-persistence | ||||||||||||||||
| --cwd $(git rev-parse --show-toplevel) \ | ||||||||||||||||
| --allowedTools "Read" "Edit" "Write" "Bash(git *)" \ | ||||||||||||||||
| --no-session-persistence \ | ||||||||||||||||
| --append-system-prompt "$CORTEXLINK_AGENT_CONTEXT" | ||||||||||||||||
| ``` | ||||||||||||||||
|
|
||||||||||||||||
| **Planning / analysis only (no writes):** | ||||||||||||||||
| ```bash | ||||||||||||||||
| claude -p "[delegation prompt]" --output-format text \ | ||||||||||||||||
| --permission-mode plan --no-session-persistence --max-turns 5 | ||||||||||||||||
| --cwd $(git rev-parse --show-toplevel) \ | ||||||||||||||||
| --permission-mode plan --no-session-persistence --max-turns 5 \ | ||||||||||||||||
| --append-system-prompt "$CORTEXLINK_AGENT_CONTEXT" | ||||||||||||||||
| ``` | ||||||||||||||||
|
|
||||||||||||||||
| **Piped input:** | ||||||||||||||||
| ```bash | ||||||||||||||||
| cat file.ts | claude -p "[delegation prompt]" --output-format text \ | ||||||||||||||||
| --allowedTools "Read" --no-session-persistence | ||||||||||||||||
| --cwd $(git rev-parse --show-toplevel) \ | ||||||||||||||||
| --allowedTools "Read" --no-session-persistence \ | ||||||||||||||||
| --append-system-prompt "$CORTEXLINK_AGENT_CONTEXT" | ||||||||||||||||
| ``` | ||||||||||||||||
|
|
||||||||||||||||
| ## Delegation Prompt | ||||||||||||||||
|
|
@@ -116,7 +146,9 @@ Follow the template from `skills/orchestration/SKILL.md`. Include the structured | |||||||||||||||
|
|
||||||||||||||||
| The agent's stdout is its report. Capture it directly: | ||||||||||||||||
| ```bash | ||||||||||||||||
| REPORT=$(claude -p "[prompt]" --output-format text --allowedTools "Read" --no-session-persistence 2>/dev/null) | ||||||||||||||||
| REPORT=$(claude -p "[prompt]" --output-format text \ | ||||||||||||||||
| --cwd $(git rev-parse --show-toplevel) \ | ||||||||||||||||
| --allowedTools "Read" --no-session-persistence 2>/dev/null) | ||||||||||||||||
|
Comment on lines
+149
to
+151
There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more.
Line 149 captures output without Proposed fix REPORT=$(claude -p "[prompt]" --output-format text \
--cwd $(git rev-parse --show-toplevel) \
- --allowedTools "Read" --no-session-persistence 2>/dev/null)
+ --allowedTools "Read" --no-session-persistence \
+ --append-system-prompt "$CORTEXLINK_AGENT_CONTEXT" 2>/dev/null)📝 Committable suggestion
Suggested change
🤖 Prompt for AI Agents |
||||||||||||||||
| ``` | ||||||||||||||||
|
|
||||||||||||||||
| Read STATUS first. If ⚠️ or ❌, read ISSUES before deciding next action. | ||||||||||||||||
|
|
@@ -126,8 +158,8 @@ Read STATUS first. If ⚠️ or ❌, read ISSUES before deciding next action. | |||||||||||||||
| | | Copilot CLI | Claude CLI | | ||||||||||||||||
| |--|-------------|------------| | ||||||||||||||||
| | Tool permissions | `--allow-tool='write, read'` | `--allowedTools "Read" "Edit"` | | ||||||||||||||||
| | Silence | `-s` | `--output-format text` | | ||||||||||||||||
| | Prevent questions | `--no-ask-user` | implied by `-p` | | ||||||||||||||||
| | Working directory | `cd $(git rev-parse --show-toplevel) &&` | `--cwd PATH` | | ||||||||||||||||
| | Model flag | `--model=claude-haiku-4.5` | `--model claude-haiku-4-5` | | ||||||||||||||||
|
|
||||||||||||||||
| ## Error Handling | ||||||||||||||||
|
|
||||||||||||||||
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Unix line endings (LF) may cause batch script failures on Windows.
The static analysis correctly identifies that this file uses LF line endings. Windows batch parser can malfunction with LF-only line endings, particularly around GOTO/CALL labels and the 512-byte boundary bug. Since this is a polyglot file designed to run on Windows, it should use CRLF line endings.
🔧 Recommended fix
Configure the file to use CRLF line endings. Add to
.gitattributes:+hooks/run-hook.cmd text eol=crlfOr convert manually:
🧰 Tools
🪛 Blinter (1.0.112)
[error] 40-40: Unreachable code after EXIT or GOTO. Explanation: Code after EXIT or GOTO statements will never execute. Recommendation: Remove unreachable code or restructure script logic. Context: Code after EXIT on line 39 will never execute
(E008)
[error] 1-1: Unix line endings detected. Explanation: Batch file uses Unix line endings (LF-only) which can cause GOTO/CALL label parsing failures and script malfunction due to Windows batch parser 512-byte boundary bugs. Recommendation: Convert file to Windows line endings (CRLF). Use tools like dos2unix, notepad++, or configure git with 'git config core.autocrlf true'. Context: File uses Unix line endings (LF-only) - 46 LF sequences found
(E018)
🤖 Prompt for AI Agents