oh-my-opencode 2.8.3 → 2.9.1
This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
- package/README.ja.md +20 -5
- package/README.ko.md +17 -6
- package/README.md +20 -6
- package/README.zh-cn.md +20 -5
- package/dist/agents/document-writer.d.ts +2 -0
- package/dist/agents/explore.d.ts +2 -0
- package/dist/agents/frontend-ui-ux-engineer.d.ts +2 -0
- package/dist/agents/index.d.ts +1 -0
- package/dist/agents/librarian.d.ts +2 -0
- package/dist/agents/multimodal-looker.d.ts +2 -0
- package/dist/agents/oracle.d.ts +2 -0
- package/dist/agents/sisyphus-prompt-builder.d.ts +25 -0
- package/dist/agents/sisyphus.d.ts +2 -1
- package/dist/agents/types.d.ts +39 -0
- package/dist/cli/index.js +31 -65
- package/dist/config/schema.d.ts +9 -3
- package/dist/features/builtin-commands/templates/init-deep.d.ts +1 -1
- package/dist/hooks/anthropic-context-window-limit-recovery/index.d.ts +1 -1
- package/dist/hooks/anthropic-context-window-limit-recovery/types.d.ts +0 -9
- package/dist/index.js +724 -688
- package/dist/shared/index.d.ts +1 -0
- package/dist/shared/migration.d.ts +11 -0
- package/dist/shared/migration.test.d.ts +1 -0
- package/dist/tools/session-manager/constants.d.ts +1 -0
- package/dist/tools/session-manager/storage.d.ts +5 -1
- package/dist/tools/session-manager/types.d.ts +18 -0
- package/package.json +1 -1
|
@@ -1 +1 @@
|
|
|
1
|
-
export declare const INIT_DEEP_TEMPLATE = "# Initialize Deep Knowledge Base\n\nGenerate comprehensive AGENTS.md files across project hierarchy. Combines root-level project knowledge (gen-knowledge) with complexity-based subdirectory documentation (gen-knowledge-deep).\n\n## Usage\n\n```\n/init-deep # Analyze and generate hierarchical AGENTS.md\n/init-deep --create-new # Force create from scratch (ignore existing)\n/init-deep --max-depth=2 # Limit to N directory levels (default: 3)\n```\n\n---\n\n## Core Principles\n\n- **Telegraphic Style**: Sacrifice grammar for concision (\"Project uses React\" \u2192 \"React 18\")\n- **Predict-then-Compare**: Predict standard \u2192 find actual \u2192 document ONLY deviations\n- **Hierarchy Aware**: Parent covers general, children cover specific\n- **No Redundancy**: Child AGENTS.md NEVER repeats parent content\n- **LSP-First**: Use LSP tools for accurate code intelligence when available (semantic > text search)\n\n---\n\n## Process\n\n<critical>\n**MANDATORY: TodoWrite for ALL phases. Mark in_progress \u2192 completed in real-time.**\n</critical>\n\n### Phase 0: Initialize\n\n```\nTodoWrite([\n { id: \"p1-analysis\", content: \"Parallel project structure & complexity analysis\", status: \"pending\", priority: \"high\" },\n { id: \"p2-scoring\", content: \"Score directories, determine AGENTS.md locations\", status: \"pending\", priority: \"high\" },\n { id: \"p3-root\", content: \"Generate root AGENTS.md with Predict-then-Compare\", status: \"pending\", priority: \"high\" },\n { id: \"p4-subdirs\", content: \"Generate subdirectory AGENTS.md files in parallel\", status: \"pending\", priority: \"high\" },\n { id: \"p5-review\", content: \"Review, deduplicate, validate all files\", status: \"pending\", priority: \"medium\" }\n])\n```\n\n---\n\n## Phase 1: Parallel Project Analysis\n\n**Mark \"p1-analysis\" as in_progress.**\n\nLaunch **ALL tasks simultaneously**:\n\n<parallel-tasks>\n\n### Structural Analysis (bash - run in parallel)\n```bash\n# Task A: Directory depth analysis\nfind . -type d -not -path '*/\\.*' -not -path '*/node_modules/*' -not -path '*/venv/*' -not -path '*/__pycache__/*' -not -path '*/dist/*' -not -path '*/build/*' | awk -F/ '{print NF-1}' | sort -n | uniq -c\n\n# Task B: File count per directory \nfind . -type f -not -path '*/\\.*' -not -path '*/node_modules/*' -not -path '*/venv/*' -not -path '*/__pycache__/*' | sed 's|/[^/]*$||' | sort | uniq -c | sort -rn | head -30\n\n# Task C: Code concentration\nfind . -type f \\( -name \"*.py\" -o -name \"*.ts\" -o -name \"*.tsx\" -o -name \"*.js\" -o -name \"*.jsx\" -o -name \"*.go\" -o -name \"*.rs\" -o -name \"*.java\" \\) -not -path '*/node_modules/*' -not -path '*/venv/*' | sed 's|/[^/]*$||' | sort | uniq -c | sort -rn | head -20\n\n# Task D: Existing knowledge files\nfind . -type f \\( -name \"AGENTS.md\" -o -name \"CLAUDE.md\" \\) -not -path '*/node_modules/*' 2>/dev/null\n```\n\n### Context Gathering (Explore agents - background_task in parallel)\n\n```\nbackground_task(agent=\"explore\", prompt=\"Project structure: PREDICT standard {lang} patterns \u2192 FIND package.json/pyproject.toml/go.mod \u2192 REPORT deviations only\")\n\nbackground_task(agent=\"explore\", prompt=\"Entry points: PREDICT typical (main.py, index.ts) \u2192 FIND actual \u2192 REPORT non-standard organization\")\n\nbackground_task(agent=\"explore\", prompt=\"Conventions: FIND .cursor/rules, .cursorrules, eslintrc, pyproject.toml \u2192 REPORT project-specific rules DIFFERENT from defaults\")\n\nbackground_task(agent=\"explore\", prompt=\"Anti-patterns: FIND comments with 'DO NOT', 'NEVER', 'ALWAYS', 'LEGACY', 'DEPRECATED' \u2192 REPORT forbidden patterns\")\n\nbackground_task(agent=\"explore\", prompt=\"Build/CI: FIND .github/workflows, Makefile, justfile \u2192 REPORT non-standard build/deploy patterns\")\n\nbackground_task(agent=\"explore\", prompt=\"Test patterns: FIND pytest.ini, jest.config, test structure \u2192 REPORT unique testing conventions\")\n```\n\n### Code Intelligence Analysis (LSP tools - run in parallel)\n\nLSP provides semantic understanding beyond text search. Use for accurate code mapping.\n\n```\n# Step 1: Check LSP availability\nlsp_servers() # Verify language server is available\n\n# Step 2: Analyze entry point files (run in parallel)\n# Find entry points first, then analyze each with lsp_document_symbols\nlsp_document_symbols(filePath=\"src/index.ts\") # Main entry\nlsp_document_symbols(filePath=\"src/main.py\") # Python entry\nlsp_document_symbols(filePath=\"cmd/main.go\") # Go entry\n\n# Step 3: Discover key symbols across workspace (run in parallel)\nlsp_workspace_symbols(filePath=\".\", query=\"class\") # All classes\nlsp_workspace_symbols(filePath=\".\", query=\"interface\") # All interfaces\nlsp_workspace_symbols(filePath=\".\", query=\"function\") # Top-level functions\nlsp_workspace_symbols(filePath=\".\", query=\"type\") # Type definitions\n\n# Step 4: Analyze symbol centrality (for top 5-10 key symbols)\n# High reference count = central/important concept\nlsp_find_references(filePath=\"src/index.ts\", line=X, character=Y) # Main export\n```\n\n#### LSP Analysis Output Format\n\n```\nCODE_INTELLIGENCE = {\n entry_points: [\n { file: \"src/index.ts\", exports: [\"Plugin\", \"createHook\"], symbol_count: 12 }\n ],\n key_symbols: [\n { name: \"Plugin\", type: \"class\", file: \"src/index.ts\", refs: 45, role: \"Central orchestrator\" },\n { name: \"createHook\", type: \"function\", file: \"src/utils.ts\", refs: 23, role: \"Hook factory\" }\n ],\n module_boundaries: [\n { dir: \"src/hooks\", exports: 21, imports_from: [\"shared/\"] },\n { dir: \"src/tools\", exports: 15, imports_from: [\"shared/\", \"hooks/\"] }\n ]\n}\n```\n\n<critical>\n**LSP Fallback**: If LSP unavailable (no server installed), skip this section and rely on explore agents + AST-grep patterns.\n</critical>\n\n</parallel-tasks>\n\n**Collect all results. Mark \"p1-analysis\" as completed.**\n\n---\n\n## Phase 2: Complexity Scoring & Location Decision\n\n**Mark \"p2-scoring\" as in_progress.**\n\n### Scoring Matrix\n\n| Factor | Weight | Threshold | Source |\n|--------|--------|-----------|--------|\n| File count | 3x | >20 files = high | bash |\n| Subdirectory count | 2x | >5 subdirs = high | bash |\n| Code file ratio | 2x | >70% code = high | bash |\n| Unique patterns | 1x | Has own config | explore |\n| Module boundary | 2x | Has __init__.py/index.ts | bash |\n| **Symbol density** | 2x | >30 symbols = high | LSP |\n| **Export count** | 2x | >10 exports = high | LSP |\n| **Reference centrality** | 3x | Symbols with >20 refs | LSP |\n\n<lsp-scoring>\n**LSP-Enhanced Scoring** (if available):\n\n```\nFor each directory in candidates:\n symbols = lsp_document_symbols(dir/index.ts or dir/__init__.py)\n \n symbol_score = len(symbols) > 30 ? 6 : len(symbols) > 15 ? 3 : 0\n export_score = count(exported symbols) > 10 ? 4 : 0\n \n # Check if this module is central (many things depend on it)\n for each exported symbol:\n refs = lsp_find_references(symbol)\n if refs > 20: centrality_score += 3\n \n total_score += symbol_score + export_score + centrality_score\n```\n</lsp-scoring>\n\n### Decision Rules\n\n| Score | Action |\n|-------|--------|\n| **Root (.)** | ALWAYS create AGENTS.md |\n| **High (>15)** | Create dedicated AGENTS.md |\n| **Medium (8-15)** | Create if distinct domain |\n| **Low (<8)** | Skip, parent sufficient |\n\n### Output Format\n\n```\nAGENTS_LOCATIONS = [\n { path: \".\", type: \"root\" },\n { path: \"src/api\", score: 18, reason: \"high complexity, 45 files\" },\n { path: \"src/hooks\", score: 12, reason: \"distinct domain, unique patterns\" },\n]\n```\n\n**Mark \"p2-scoring\" as completed.**\n\n---\n\n## Phase 3: Generate Root AGENTS.md\n\n**Mark \"p3-root\" as in_progress.**\n\nRoot AGENTS.md gets **full treatment** with Predict-then-Compare synthesis.\n\n### Required Sections\n\n```markdown\n# PROJECT KNOWLEDGE BASE\n\n**Generated:** {TIMESTAMP}\n**Commit:** {SHORT_SHA}\n**Branch:** {BRANCH}\n\n## OVERVIEW\n\n{1-2 sentences: what project does, core tech stack}\n\n## STRUCTURE\n\n\\`\\`\\`\n{project-root}/\n\u251C\u2500\u2500 {dir}/ # {non-obvious purpose only}\n\u2514\u2500\u2500 {entry} # entry point\n\\`\\`\\`\n\n## WHERE TO LOOK\n\n| Task | Location | Notes |\n|------|----------|-------|\n| Add feature X | \\`src/x/\\` | {pattern hint} |\n\n## CODE MAP\n\n{Generated from LSP analysis - shows key symbols and their relationships}\n\n| Symbol | Type | Location | Refs | Role |\n|--------|------|----------|------|------|\n| {MainClass} | Class | \\`src/index.ts\\` | {N} | {Central orchestrator} |\n| {createX} | Function | \\`src/utils.ts\\` | {N} | {Factory pattern} |\n| {Config} | Interface | \\`src/types.ts\\` | {N} | {Configuration contract} |\n\n### Module Dependencies\n\n\\`\\`\\`\n{entry} \u2500\u2500imports\u2500\u2500> {core/}\n \u2502 \u2502\n \u2514\u2500\u2500imports\u2500\u2500> {utils/} <\u2500\u2500imports\u2500\u2500 {features/}\n\\`\\`\\`\n\n<code-map-note>\n**Skip CODE MAP if**: LSP unavailable OR project too small (<10 files) OR no clear module boundaries.\n</code-map-note>\n\n## CONVENTIONS\n\n{ONLY deviations from standard - skip generic advice}\n\n- **{rule}**: {specific detail}\n\n## ANTI-PATTERNS (THIS PROJECT)\n\n{Things explicitly forbidden HERE}\n\n- **{pattern}**: {why} \u2192 {alternative}\n\n## UNIQUE STYLES\n\n{Project-specific coding styles}\n\n- **{style}**: {how different}\n\n## COMMANDS\n\n\\`\\`\\`bash\n{dev-command}\n{test-command}\n{build-command}\n\\`\\`\\`\n\n## NOTES\n\n{Gotchas, non-obvious info}\n```\n\n### Quality Gates\n\n- [ ] Size: 50-150 lines\n- [ ] No generic advice (\"write clean code\")\n- [ ] No obvious info (\"tests/ has tests\")\n- [ ] Every item is project-specific\n\n**Mark \"p3-root\" as completed.**\n\n---\n\n## Phase 4: Generate Subdirectory AGENTS.md\n\n**Mark \"p4-subdirs\" as in_progress.**\n\nFor each location in AGENTS_LOCATIONS (except root), launch **parallel document-writer agents**:\n\n```typescript\nfor (const loc of AGENTS_LOCATIONS.filter(l => l.path !== \".\")) {\n background_task({\n agent: \"document-writer\",\n prompt: \\`\n Generate AGENTS.md for: ${loc.path}\n \n CONTEXT:\n - Complexity reason: ${loc.reason}\n - Parent AGENTS.md: ./AGENTS.md (already covers project overview)\n \n CRITICAL RULES:\n 1. Focus ONLY on this directory's specific context\n 2. NEVER repeat parent AGENTS.md content\n 3. Shorter is better - 30-80 lines max\n 4. Telegraphic style - sacrifice grammar\n \n REQUIRED SECTIONS:\n - OVERVIEW (1 line: what this directory does)\n - STRUCTURE (only if >5 subdirs)\n - WHERE TO LOOK (directory-specific tasks)\n - CONVENTIONS (only if DIFFERENT from root)\n - ANTI-PATTERNS (directory-specific only)\n \n OUTPUT: Write to ${loc.path}/AGENTS.md\n \\`\n })\n}\n```\n\n**Wait for all agents. Mark \"p4-subdirs\" as completed.**\n\n---\n\n## Phase 5: Review & Deduplicate\n\n**Mark \"p5-review\" as in_progress.**\n\n### Validation Checklist\n\nFor EACH generated AGENTS.md:\n\n| Check | Action if Fail |\n|-------|----------------|\n| Contains generic advice | REMOVE the line |\n| Repeats parent content | REMOVE the line |\n| Missing required section | ADD it |\n| Over 150 lines (root) / 80 lines (subdir) | TRIM |\n| Verbose explanations | REWRITE telegraphic |\n\n### Cross-Reference Validation\n\n```\nFor each child AGENTS.md:\n For each line in child:\n If similar line exists in parent:\n REMOVE from child (parent already covers)\n```\n\n**Mark \"p5-review\" as completed.**\n\n---\n\n## Final Report\n\n```\n=== init-deep Complete ===\n\nFiles Generated:\n \u2713 ./AGENTS.md (root, {N} lines)\n \u2713 ./src/hooks/AGENTS.md ({N} lines)\n \u2713 ./src/tools/AGENTS.md ({N} lines)\n\nDirectories Analyzed: {N}\nAGENTS.md Created: {N}\nTotal Lines: {N}\n\nHierarchy:\n ./AGENTS.md\n \u251C\u2500\u2500 src/hooks/AGENTS.md\n \u2514\u2500\u2500 src/tools/AGENTS.md\n```\n\n---\n\n## Anti-Patterns for THIS Command\n\n- **Over-documenting**: Not every directory needs AGENTS.md\n- **Redundancy**: Child must NOT repeat parent\n- **Generic content**: Remove anything that applies to ALL projects\n- **Sequential execution**: MUST use parallel agents\n- **Deep nesting**: Rarely need AGENTS.md at depth 4+\n- **Verbose style**: \"This directory contains...\" \u2192 just list it\n- **Ignoring LSP**: If LSP available, USE IT - semantic analysis > text grep\n- **LSP without fallback**: Always have explore agent backup if LSP unavailable\n- **Over-referencing**: Don't trace refs for EVERY symbol - focus on exports only";
|
|
1
|
+
export declare const INIT_DEEP_TEMPLATE = "# /init-deep\n\nGenerate hierarchical AGENTS.md files. Root + complexity-scored subdirectories.\n\n## Usage\n\n```\n/init-deep # Update mode: modify existing + create new where warranted\n/init-deep --create-new # Read existing \u2192 remove all \u2192 regenerate from scratch\n/init-deep --max-depth=2 # Limit directory depth (default: 3)\n```\n\n---\n\n## Workflow (High-Level)\n\n1. **Discovery + Analysis** (concurrent)\n - Fire background explore agents immediately\n - Main session: bash structure + LSP codemap + read existing AGENTS.md\n2. **Score & Decide** - Determine AGENTS.md locations from merged findings\n3. **Generate** - Root first, then subdirs in parallel\n4. **Review** - Deduplicate, trim, validate\n\n<critical>\n**TodoWrite ALL phases. Mark in_progress \u2192 completed in real-time.**\n```\nTodoWrite([\n { id: \"discovery\", content: \"Fire explore agents + LSP codemap + read existing\", status: \"pending\", priority: \"high\" },\n { id: \"scoring\", content: \"Score directories, determine locations\", status: \"pending\", priority: \"high\" },\n { id: \"generate\", content: \"Generate AGENTS.md files (root + subdirs)\", status: \"pending\", priority: \"high\" },\n { id: \"review\", content: \"Deduplicate, validate, trim\", status: \"pending\", priority: \"medium\" }\n])\n```\n</critical>\n\n---\n\n## Phase 1: Discovery + Analysis (Concurrent)\n\n**Mark \"discovery\" as in_progress.**\n\n### Fire Background Explore Agents IMMEDIATELY\n\nDon't wait\u2014these run async while main session works.\n\n```\n// Fire all at once, collect results later\nbackground_task(agent=\"explore\", prompt=\"Project structure: PREDICT standard patterns for detected language \u2192 REPORT deviations only\")\nbackground_task(agent=\"explore\", prompt=\"Entry points: FIND main files \u2192 REPORT non-standard organization\")\nbackground_task(agent=\"explore\", prompt=\"Conventions: FIND config files (.eslintrc, pyproject.toml, .editorconfig) \u2192 REPORT project-specific rules\")\nbackground_task(agent=\"explore\", prompt=\"Anti-patterns: FIND 'DO NOT', 'NEVER', 'ALWAYS', 'DEPRECATED' comments \u2192 LIST forbidden patterns\")\nbackground_task(agent=\"explore\", prompt=\"Build/CI: FIND .github/workflows, Makefile \u2192 REPORT non-standard patterns\")\nbackground_task(agent=\"explore\", prompt=\"Test patterns: FIND test configs, test structure \u2192 REPORT unique conventions\")\n```\n\n<dynamic-agents>\n**DYNAMIC AGENT SPAWNING**: After bash analysis, spawn ADDITIONAL explore agents based on project scale:\n\n| Factor | Threshold | Additional Agents |\n|--------|-----------|-------------------|\n| **Total files** | >100 | +1 per 100 files |\n| **Total lines** | >10k | +1 per 10k lines |\n| **Directory depth** | \u22654 | +2 for deep exploration |\n| **Large files (>500 lines)** | >10 files | +1 for complexity hotspots |\n| **Monorepo** | detected | +1 per package/workspace |\n| **Multiple languages** | >1 | +1 per language |\n\n```bash\n# Measure project scale first\ntotal_files=$(find . -type f -not -path '*/node_modules/*' -not -path '*/.git/*' | wc -l)\ntotal_lines=$(find . -type f \\( -name \"*.ts\" -o -name \"*.py\" -o -name \"*.go\" \\) -not -path '*/node_modules/*' -exec wc -l {} + 2>/dev/null | tail -1 | awk '{print $1}')\nlarge_files=$(find . -type f \\( -name \"*.ts\" -o -name \"*.py\" \\) -not -path '*/node_modules/*' -exec wc -l {} + 2>/dev/null | awk '$1 > 500 {count++} END {print count+0}')\nmax_depth=$(find . -type d -not -path '*/node_modules/*' -not -path '*/.git/*' | awk -F/ '{print NF}' | sort -rn | head -1)\n```\n\nExample spawning:\n```\n// 500 files, 50k lines, depth 6, 15 large files \u2192 spawn 5+5+2+1 = 13 additional agents\nbackground_task(agent=\"explore\", prompt=\"Large file analysis: FIND files >500 lines, REPORT complexity hotspots\")\nbackground_task(agent=\"explore\", prompt=\"Deep modules at depth 4+: FIND hidden patterns, internal conventions\")\nbackground_task(agent=\"explore\", prompt=\"Cross-cutting concerns: FIND shared utilities across directories\")\n// ... more based on calculation\n```\n</dynamic-agents>\n\n### Main Session: Concurrent Analysis\n\n**While background agents run**, main session does:\n\n#### 1. Bash Structural Analysis\n```bash\n# Directory depth + file counts\nfind . -type d -not -path '*/\\.*' -not -path '*/node_modules/*' -not -path '*/venv/*' -not -path '*/dist/*' -not -path '*/build/*' | awk -F/ '{print NF-1}' | sort -n | uniq -c\n\n# Files per directory (top 30)\nfind . -type f -not -path '*/\\.*' -not -path '*/node_modules/*' | sed 's|/[^/]*$||' | sort | uniq -c | sort -rn | head -30\n\n# Code concentration by extension\nfind . -type f \\( -name \"*.py\" -o -name \"*.ts\" -o -name \"*.tsx\" -o -name \"*.js\" -o -name \"*.go\" -o -name \"*.rs\" \\) -not -path '*/node_modules/*' | sed 's|/[^/]*$||' | sort | uniq -c | sort -rn | head -20\n\n# Existing AGENTS.md / CLAUDE.md\nfind . -type f \\( -name \"AGENTS.md\" -o -name \"CLAUDE.md\" \\) -not -path '*/node_modules/*' 2>/dev/null\n```\n\n#### 2. Read Existing AGENTS.md\n```\nFor each existing file found:\n Read(filePath=file)\n Extract: key insights, conventions, anti-patterns\n Store in EXISTING_AGENTS map\n```\n\nIf `--create-new`: Read all existing first (preserve context) \u2192 then delete all \u2192 regenerate.\n\n#### 3. LSP Codemap (if available)\n```\nlsp_servers() # Check availability\n\n# Entry points (parallel)\nlsp_document_symbols(filePath=\"src/index.ts\")\nlsp_document_symbols(filePath=\"main.py\")\n\n# Key symbols (parallel)\nlsp_workspace_symbols(filePath=\".\", query=\"class\")\nlsp_workspace_symbols(filePath=\".\", query=\"interface\")\nlsp_workspace_symbols(filePath=\".\", query=\"function\")\n\n# Centrality for top exports\nlsp_find_references(filePath=\"...\", line=X, character=Y)\n```\n\n**LSP Fallback**: If unavailable, rely on explore agents + AST-grep.\n\n### Collect Background Results\n\n```\n// After main session analysis done, collect all task results\nfor each task_id: background_output(task_id=\"...\")\n```\n\n**Merge: bash + LSP + existing + explore findings. Mark \"discovery\" as completed.**\n\n---\n\n## Phase 2: Scoring & Location Decision\n\n**Mark \"scoring\" as in_progress.**\n\n### Scoring Matrix\n\n| Factor | Weight | High Threshold | Source |\n|--------|--------|----------------|--------|\n| File count | 3x | >20 | bash |\n| Subdir count | 2x | >5 | bash |\n| Code ratio | 2x | >70% | bash |\n| Unique patterns | 1x | Has own config | explore |\n| Module boundary | 2x | Has index.ts/__init__.py | bash |\n| Symbol density | 2x | >30 symbols | LSP |\n| Export count | 2x | >10 exports | LSP |\n| Reference centrality | 3x | >20 refs | LSP |\n\n### Decision Rules\n\n| Score | Action |\n|-------|--------|\n| **Root (.)** | ALWAYS create |\n| **>15** | Create AGENTS.md |\n| **8-15** | Create if distinct domain |\n| **<8** | Skip (parent covers) |\n\n### Output\n```\nAGENTS_LOCATIONS = [\n { path: \".\", type: \"root\" },\n { path: \"src/hooks\", score: 18, reason: \"high complexity\" },\n { path: \"src/api\", score: 12, reason: \"distinct domain\" }\n]\n```\n\n**Mark \"scoring\" as completed.**\n\n---\n\n## Phase 3: Generate AGENTS.md\n\n**Mark \"generate\" as in_progress.**\n\n### Root AGENTS.md (Full Treatment)\n\n```markdown\n# PROJECT KNOWLEDGE BASE\n\n**Generated:** {TIMESTAMP}\n**Commit:** {SHORT_SHA}\n**Branch:** {BRANCH}\n\n## OVERVIEW\n{1-2 sentences: what + core stack}\n\n## STRUCTURE\n\\`\\`\\`\n{root}/\n\u251C\u2500\u2500 {dir}/ # {non-obvious purpose only}\n\u2514\u2500\u2500 {entry}\n\\`\\`\\`\n\n## WHERE TO LOOK\n| Task | Location | Notes |\n|------|----------|-------|\n\n## CODE MAP\n{From LSP - skip if unavailable or project <10 files}\n\n| Symbol | Type | Location | Refs | Role |\n|--------|------|----------|------|------|\n\n## CONVENTIONS\n{ONLY deviations from standard}\n\n## ANTI-PATTERNS (THIS PROJECT)\n{Explicitly forbidden here}\n\n## UNIQUE STYLES\n{Project-specific}\n\n## COMMANDS\n\\`\\`\\`bash\n{dev/test/build}\n\\`\\`\\`\n\n## NOTES\n{Gotchas}\n```\n\n**Quality gates**: 50-150 lines, no generic advice, no obvious info.\n\n### Subdirectory AGENTS.md (Parallel)\n\nLaunch document-writer agents for each location:\n\n```\nfor loc in AGENTS_LOCATIONS (except root):\n background_task(agent=\"document-writer\", prompt=\\`\n Generate AGENTS.md for: ${loc.path}\n - Reason: ${loc.reason}\n - 30-80 lines max\n - NEVER repeat parent content\n - Sections: OVERVIEW (1 line), STRUCTURE (if >5 subdirs), WHERE TO LOOK, CONVENTIONS (if different), ANTI-PATTERNS\n \\`)\n```\n\n**Wait for all. Mark \"generate\" as completed.**\n\n---\n\n## Phase 4: Review & Deduplicate\n\n**Mark \"review\" as in_progress.**\n\nFor each generated file:\n- Remove generic advice\n- Remove parent duplicates\n- Trim to size limits\n- Verify telegraphic style\n\n**Mark \"review\" as completed.**\n\n---\n\n## Final Report\n\n```\n=== init-deep Complete ===\n\nMode: {update | create-new}\n\nFiles:\n \u2713 ./AGENTS.md (root, {N} lines)\n \u2713 ./src/hooks/AGENTS.md ({N} lines)\n\nDirs Analyzed: {N}\nAGENTS.md Created: {N}\nAGENTS.md Updated: {N}\n\nHierarchy:\n ./AGENTS.md\n \u2514\u2500\u2500 src/hooks/AGENTS.md\n```\n\n---\n\n## Anti-Patterns\n\n- **Static agent count**: MUST vary agents based on project size/depth\n- **Sequential execution**: MUST parallel (explore + LSP concurrent)\n- **Ignoring existing**: ALWAYS read existing first, even with --create-new\n- **Over-documenting**: Not every dir needs AGENTS.md\n- **Redundancy**: Child never repeats parent\n- **Generic content**: Remove anything that applies to ALL projects\n- **Verbose style**: Telegraphic or die";
|
|
@@ -12,6 +12,6 @@ export declare function createAnthropicContextWindowLimitRecoveryHook(ctx: Plugi
|
|
|
12
12
|
};
|
|
13
13
|
}) => Promise<void>;
|
|
14
14
|
};
|
|
15
|
-
export type { AutoCompactState, DcpState,
|
|
15
|
+
export type { AutoCompactState, DcpState, ParsedTokenLimitError, TruncateState } from "./types";
|
|
16
16
|
export { parseAnthropicTokenLimitError } from "./parser";
|
|
17
17
|
export { executeCompact, getLastAssistant } from "./executor";
|
|
@@ -11,10 +11,6 @@ export interface RetryState {
|
|
|
11
11
|
attempt: number;
|
|
12
12
|
lastAttemptTime: number;
|
|
13
13
|
}
|
|
14
|
-
export interface FallbackState {
|
|
15
|
-
revertAttempt: number;
|
|
16
|
-
lastRevertedMessageID?: string;
|
|
17
|
-
}
|
|
18
14
|
export interface TruncateState {
|
|
19
15
|
truncateAttempt: number;
|
|
20
16
|
lastTruncatedPartId?: string;
|
|
@@ -27,7 +23,6 @@ export interface AutoCompactState {
|
|
|
27
23
|
pendingCompact: Set<string>;
|
|
28
24
|
errorDataBySession: Map<string, ParsedTokenLimitError>;
|
|
29
25
|
retryStateBySession: Map<string, RetryState>;
|
|
30
|
-
fallbackStateBySession: Map<string, FallbackState>;
|
|
31
26
|
truncateStateBySession: Map<string, TruncateState>;
|
|
32
27
|
dcpStateBySession: Map<string, DcpState>;
|
|
33
28
|
emptyContentAttemptBySession: Map<string, number>;
|
|
@@ -39,10 +34,6 @@ export declare const RETRY_CONFIG: {
|
|
|
39
34
|
readonly backoffFactor: 2;
|
|
40
35
|
readonly maxDelayMs: 30000;
|
|
41
36
|
};
|
|
42
|
-
export declare const FALLBACK_CONFIG: {
|
|
43
|
-
readonly maxRevertAttempts: 3;
|
|
44
|
-
readonly minMessagesRequired: 2;
|
|
45
|
-
};
|
|
46
37
|
export declare const TRUNCATE_CONFIG: {
|
|
47
38
|
readonly maxTruncateAttempts: 20;
|
|
48
39
|
readonly minOutputSizeToTruncate: 500;
|