openwolf 1.0.0

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.
Files changed (112) hide show
  1. package/LICENSE +663 -0
  2. package/README.md +232 -0
  3. package/dist/bin/openwolf.js +10 -0
  4. package/dist/bin/openwolf.js.map +1 -0
  5. package/dist/dashboard/assets/AISuggestions-DzE-DQkR.js +1 -0
  6. package/dist/dashboard/assets/ActivityTimeline-DGVjujnt.js +1 -0
  7. package/dist/dashboard/assets/AnatomyBrowser-S-2rmYtw.js +1 -0
  8. package/dist/dashboard/assets/BugLog-CG2zDHJc.js +1 -0
  9. package/dist/dashboard/assets/CerebrumViewer-Dlgoy69U.js +1 -0
  10. package/dist/dashboard/assets/CronStatus-DxUF1iW_.js +1 -0
  11. package/dist/dashboard/assets/DesignQC-BGXn_aq8.js +1 -0
  12. package/dist/dashboard/assets/MemoryViewer-CGqkTyvQ.js +1 -0
  13. package/dist/dashboard/assets/ProjectOverview-DlFhu69i.js +1 -0
  14. package/dist/dashboard/assets/TokenUsage-DDsQiVIq.js +68 -0
  15. package/dist/dashboard/assets/index-CzK9GUjV.css +1 -0
  16. package/dist/dashboard/assets/index-PYeNGjkN.js +52 -0
  17. package/dist/dashboard/index.html +16 -0
  18. package/dist/hooks/post-read.js +68 -0
  19. package/dist/hooks/post-write.js +502 -0
  20. package/dist/hooks/pre-read.js +79 -0
  21. package/dist/hooks/pre-write.js +120 -0
  22. package/dist/hooks/session-start.js +76 -0
  23. package/dist/hooks/shared.js +613 -0
  24. package/dist/hooks/stop.js +146 -0
  25. package/dist/src/buglog/bug-matcher.js +3 -0
  26. package/dist/src/buglog/bug-matcher.js.map +1 -0
  27. package/dist/src/buglog/bug-tracker.js +81 -0
  28. package/dist/src/buglog/bug-tracker.js.map +1 -0
  29. package/dist/src/cli/bug-cmd.js +28 -0
  30. package/dist/src/cli/bug-cmd.js.map +1 -0
  31. package/dist/src/cli/cron-cmd.js +106 -0
  32. package/dist/src/cli/cron-cmd.js.map +1 -0
  33. package/dist/src/cli/daemon-cmd.js +177 -0
  34. package/dist/src/cli/daemon-cmd.js.map +1 -0
  35. package/dist/src/cli/dashboard.js +84 -0
  36. package/dist/src/cli/dashboard.js.map +1 -0
  37. package/dist/src/cli/designqc-cmd.js +31 -0
  38. package/dist/src/cli/designqc-cmd.js.map +1 -0
  39. package/dist/src/cli/index.js +149 -0
  40. package/dist/src/cli/index.js.map +1 -0
  41. package/dist/src/cli/init.js +506 -0
  42. package/dist/src/cli/init.js.map +1 -0
  43. package/dist/src/cli/registry.js +93 -0
  44. package/dist/src/cli/registry.js.map +1 -0
  45. package/dist/src/cli/scan.js +39 -0
  46. package/dist/src/cli/scan.js.map +1 -0
  47. package/dist/src/cli/status.js +85 -0
  48. package/dist/src/cli/status.js.map +1 -0
  49. package/dist/src/cli/update.js +414 -0
  50. package/dist/src/cli/update.js.map +1 -0
  51. package/dist/src/daemon/cron-engine.js +300 -0
  52. package/dist/src/daemon/cron-engine.js.map +1 -0
  53. package/dist/src/daemon/file-watcher.js +53 -0
  54. package/dist/src/daemon/file-watcher.js.map +1 -0
  55. package/dist/src/daemon/health.js +23 -0
  56. package/dist/src/daemon/health.js.map +1 -0
  57. package/dist/src/daemon/wolf-daemon.js +294 -0
  58. package/dist/src/daemon/wolf-daemon.js.map +1 -0
  59. package/dist/src/designqc/designqc-capture.js +235 -0
  60. package/dist/src/designqc/designqc-capture.js.map +1 -0
  61. package/dist/src/designqc/designqc-engine.js +141 -0
  62. package/dist/src/designqc/designqc-engine.js.map +1 -0
  63. package/dist/src/designqc/designqc-types.js +5 -0
  64. package/dist/src/designqc/designqc-types.js.map +1 -0
  65. package/dist/src/hooks/post-read.js +69 -0
  66. package/dist/src/hooks/post-read.js.map +1 -0
  67. package/dist/src/hooks/post-write.js +503 -0
  68. package/dist/src/hooks/post-write.js.map +1 -0
  69. package/dist/src/hooks/pre-read.js +80 -0
  70. package/dist/src/hooks/pre-read.js.map +1 -0
  71. package/dist/src/hooks/pre-write.js +121 -0
  72. package/dist/src/hooks/pre-write.js.map +1 -0
  73. package/dist/src/hooks/session-start.js +77 -0
  74. package/dist/src/hooks/session-start.js.map +1 -0
  75. package/dist/src/hooks/shared.js +614 -0
  76. package/dist/src/hooks/shared.js.map +1 -0
  77. package/dist/src/hooks/stop.js +147 -0
  78. package/dist/src/hooks/stop.js.map +1 -0
  79. package/dist/src/scanner/anatomy-scanner.js +260 -0
  80. package/dist/src/scanner/anatomy-scanner.js.map +1 -0
  81. package/dist/src/scanner/description-extractor.js +1007 -0
  82. package/dist/src/scanner/description-extractor.js.map +1 -0
  83. package/dist/src/scanner/project-root.js +42 -0
  84. package/dist/src/scanner/project-root.js.map +1 -0
  85. package/dist/src/tracker/token-estimator.js +20 -0
  86. package/dist/src/tracker/token-estimator.js.map +1 -0
  87. package/dist/src/tracker/token-ledger.js +45 -0
  88. package/dist/src/tracker/token-ledger.js.map +1 -0
  89. package/dist/src/tracker/waste-detector.js +101 -0
  90. package/dist/src/tracker/waste-detector.js.map +1 -0
  91. package/dist/src/utils/fs-safe.js +74 -0
  92. package/dist/src/utils/fs-safe.js.map +1 -0
  93. package/dist/src/utils/logger.js +48 -0
  94. package/dist/src/utils/logger.js.map +1 -0
  95. package/dist/src/utils/paths.js +23 -0
  96. package/dist/src/utils/paths.js.map +1 -0
  97. package/dist/src/utils/platform.js +14 -0
  98. package/dist/src/utils/platform.js.map +1 -0
  99. package/package.json +77 -0
  100. package/src/templates/OPENWOLF.md +135 -0
  101. package/src/templates/anatomy.md +5 -0
  102. package/src/templates/buglog.json +4 -0
  103. package/src/templates/cerebrum.md +22 -0
  104. package/src/templates/claude-md-snippet.md +5 -0
  105. package/src/templates/claude-rules-openwolf.md +15 -0
  106. package/src/templates/config.json +73 -0
  107. package/src/templates/cron-manifest.json +97 -0
  108. package/src/templates/cron-state.json +7 -0
  109. package/src/templates/identity.md +9 -0
  110. package/src/templates/memory.md +4 -0
  111. package/src/templates/reframe-frameworks.md +597 -0
  112. package/src/templates/token-ledger.json +21 -0
@@ -0,0 +1,135 @@
1
+ # OpenWolf Operating Protocol
2
+
3
+ You are working in an OpenWolf-managed project. These rules apply every turn.
4
+
5
+ ## File Navigation
6
+
7
+ 1. Check `.wolf/anatomy.md` BEFORE reading any file. It has a 2-3 line description and token estimate for every file in the project.
8
+ 2. If the description in anatomy.md is sufficient for your task, do NOT read the full file.
9
+ 3. If a file is not in anatomy.md, search with Grep/Glob, then update anatomy.md with the new entry.
10
+
11
+ ## Code Generation
12
+
13
+ 1. Before generating code, read `.wolf/cerebrum.md` and respect every entry.
14
+ 2. Check the `## Do-Not-Repeat` section — these are past mistakes that must not recur.
15
+ 3. Follow all conventions in `## Key Learnings` and `## User Preferences`.
16
+
17
+ ## After Actions
18
+
19
+ 1. After every significant action, append a one-line entry to `.wolf/memory.md`:
20
+ `| HH:MM | description | file(s) | outcome | ~tokens |`
21
+ 2. After creating, deleting, or renaming files: update `.wolf/anatomy.md`.
22
+
23
+ ## Cerebrum Learning (MANDATORY — every session)
24
+
25
+ OpenWolf's value comes from learning across sessions. You MUST update `.wolf/cerebrum.md` whenever you learn something useful. This is not optional.
26
+
27
+ **Update `## User Preferences` when the user:**
28
+ - Corrects your approach ("no, do it this way instead")
29
+ - Expresses a style preference (naming, structure, formatting)
30
+ - Shows a preferred workflow or tool choice
31
+ - Rejects a suggestion — record what they preferred instead
32
+ - Asks for more/less detail, verbosity, explanation
33
+
34
+ **Update `## Key Learnings` when you discover:**
35
+ - A project convention not obvious from the code (e.g., "tests go in __tests__/ not test/")
36
+ - A framework-specific pattern this project uses
37
+ - An API behavior that surprised you
38
+ - A dependency quirk or version constraint
39
+ - How modules connect or data flows through the system
40
+
41
+ **Update `## Do-Not-Repeat` (with date) when:**
42
+ - The user corrects a mistake you made
43
+ - You try something that fails and find the right approach
44
+ - You discover a gotcha that would trip up a fresh session
45
+
46
+ **Update `## Decision Log` when:**
47
+ - A significant architectural or technical choice is made
48
+ - The user explains why they chose approach A over B
49
+ - A trade-off is explicitly discussed
50
+
51
+ **The bar is LOW.** If in doubt, add it. A cerebrum entry that's slightly redundant costs nothing. A missing entry means the next session repeats the same discovery process.
52
+
53
+ ## Bug Logging (MANDATORY)
54
+
55
+ **Log a bug to `.wolf/buglog.json` whenever ANY of these happen:**
56
+ - The user reports an error, bug, or problem
57
+ - A test fails or a command produces an error
58
+ - You fix something that was broken
59
+ - You edit a file more than twice to get it right
60
+ - An import, module, or dependency is missing or wrong
61
+ - A runtime error, type error, or syntax error occurs
62
+ - A build or lint command fails
63
+ - A feature doesn't work as expected
64
+ - You change error handling, try/catch blocks, or validation logic
65
+ - The user says something "doesn't work", "is broken", or "shows wrong X"
66
+
67
+ **Before fixing:** Read `.wolf/buglog.json` first — the fix may already be known.
68
+
69
+ **After fixing:** ALWAYS append to `.wolf/buglog.json` with this structure:
70
+ ```json
71
+ {
72
+ "id": "bug-NNN",
73
+ "timestamp": "ISO date",
74
+ "error_message": "exact error or user complaint",
75
+ "file": "file that was fixed",
76
+ "root_cause": "why it broke",
77
+ "fix": "what you changed to fix it",
78
+ "tags": ["relevant", "keywords"],
79
+ "related_bugs": [],
80
+ "occurrences": 1,
81
+ "last_seen": "ISO date"
82
+ }
83
+ ```
84
+
85
+ **The threshold is LOW.** When in doubt, log it. A false positive in the bug log costs nothing. A missed bug means repeating the same mistake later.
86
+
87
+ ## Token Discipline
88
+
89
+ - Never re-read a file already read this session unless it was modified since.
90
+ - Prefer anatomy.md descriptions over full file reads when possible.
91
+ - Prefer targeted Grep over full file reads when searching for specific code.
92
+ - If appending to a file, do not read the entire file first.
93
+
94
+ ## Design QC
95
+
96
+ When the user asks you to check, evaluate, or improve the design/UI of their app:
97
+
98
+ 1. Run `openwolf designqc` via Bash to capture screenshots.
99
+ - The command auto-detects a running dev server, or starts one from package.json if needed
100
+ - Use `--url <url>` only if auto-detection fails
101
+ - The command saves compressed JPEG screenshots to `.wolf/designqc-captures/`
102
+ - Full pages are captured as sectioned viewport-height images (top, section2, ..., bottom)
103
+ 2. Read the captured screenshot images from `.wolf/designqc-captures/` using the Read tool.
104
+ 3. Evaluate the design against modern standards (Shadcn UI, Tailwind, clean React patterns):
105
+ - Spacing and whitespace consistency
106
+ - Typography hierarchy and readability
107
+ - Color contrast and accessibility (WCAG)
108
+ - Visual hierarchy and focal points
109
+ - Component consistency
110
+ - Whether the design looks "dull" or "white-coded" (generic, no personality)
111
+ 4. Provide specific, actionable feedback with fix suggestions.
112
+ 5. If the user approves, implement the fixes directly in their code.
113
+ 6. After fixes, re-run `openwolf designqc` to capture new screenshots and verify improvement.
114
+
115
+ **Token awareness:** Each screenshot costs ~2500 tokens. The command compresses images (JPEG quality 70, max width 1200px) to minimize cost. For large apps, use `--routes / /specific-page` to limit captures.
116
+
117
+ ## Reframe — UI Framework Selection
118
+
119
+ When the user asks to change, pick, migrate, or "reframe" their project's UI framework:
120
+
121
+ 1. Read `.wolf/reframe-frameworks.md` for the full framework knowledge base.
122
+ 2. Ask the user the decision questions from the file (current stack, priority, Tailwind usage, theme preference, app type). Stop early once the choice narrows to 1-2 options.
123
+ 3. Present a recommendation with reasoning based on the comparison matrix.
124
+ 4. Once the user confirms, use the selected framework's prompt from the file — **adapted to the actual project** using `.wolf/anatomy.md` for real file paths, routes, and components.
125
+ 5. Execute the migration: install dependencies, update config, refactor components.
126
+ 6. After migration, run `openwolf designqc` to verify the new look.
127
+
128
+ **Do NOT read the entire reframe-frameworks.md into context upfront.** Read the decision questions and comparison matrix first (~50 lines). Only read the specific framework's prompt section after the user chooses.
129
+
130
+ ## Session End
131
+
132
+ Before ending or when asked to wrap up:
133
+
134
+ 1. Write a session summary to `.wolf/memory.md`.
135
+ 2. Review the session: did you learn anything? Did the user correct you? Did you fix a bug? If yes, update `.wolf/cerebrum.md` and/or `.wolf/buglog.json`.
@@ -0,0 +1,5 @@
1
+ # anatomy.md
2
+
3
+ > Project structure index. Auto-maintained by OpenWolf hooks and daemon.
4
+ > Run `openwolf scan` to generate, or wait for the first Claude Code session.
5
+ > Status: Pending initial scan
@@ -0,0 +1,4 @@
1
+ {
2
+ "version": 1,
3
+ "bugs": []
4
+ }
@@ -0,0 +1,22 @@
1
+ # Cerebrum
2
+
3
+ > OpenWolf's learning memory. Updated automatically as the AI learns from interactions.
4
+ > Do not edit manually unless correcting an error.
5
+ > Last updated: —
6
+
7
+ ## User Preferences
8
+
9
+ <!-- How the user likes things done. Code style, tools, patterns, communication. -->
10
+
11
+ ## Key Learnings
12
+
13
+ <!-- Project-specific conventions discovered during development. -->
14
+
15
+ ## Do-Not-Repeat
16
+
17
+ <!-- Mistakes made and corrected. Each entry prevents the same mistake recurring. -->
18
+ <!-- Format: [YYYY-MM-DD] Description of what went wrong and what to do instead. -->
19
+
20
+ ## Decision Log
21
+
22
+ <!-- Significant technical decisions with rationale. Why X was chosen over Y. -->
@@ -0,0 +1,5 @@
1
+ # OpenWolf
2
+
3
+ @.wolf/OPENWOLF.md
4
+
5
+ This project uses OpenWolf for context management. Read and follow .wolf/OPENWOLF.md every session. Check .wolf/cerebrum.md before generating code. Check .wolf/anatomy.md before reading files.
@@ -0,0 +1,15 @@
1
+ ---
2
+ description: OpenWolf protocol enforcement — active on all files
3
+ globs: **/*
4
+ ---
5
+
6
+ - Check .wolf/anatomy.md before reading any project file
7
+ - Check .wolf/cerebrum.md Do-Not-Repeat list before generating code
8
+ - After writing or editing files, update .wolf/anatomy.md and append to .wolf/memory.md
9
+ - After receiving a user correction, update .wolf/cerebrum.md immediately (Preferences, Learnings, or Do-Not-Repeat)
10
+ - LEARN from every interaction: if you discover a convention, user preference, or project pattern, add it to .wolf/cerebrum.md. Low threshold — when in doubt, log it.
11
+ - BEFORE fixing any bug or error: read .wolf/buglog.json for known fixes
12
+ - AFTER fixing any bug, error, failed test, failed build, or user-reported problem: ALWAYS log to .wolf/buglog.json with error_message, root_cause, fix, and tags
13
+ - If you edit a file more than twice in a session, that likely indicates a bug — log it to .wolf/buglog.json
14
+ - When the user asks to check/evaluate UI design: run `openwolf designqc` to capture screenshots, then read them from .wolf/designqc-captures/
15
+ - When the user asks to change/pick/migrate UI framework: read .wolf/reframe-frameworks.md, ask decision questions, recommend a framework, then execute with the framework's prompt
@@ -0,0 +1,73 @@
1
+ {
2
+ "version": 1,
3
+ "openwolf": {
4
+ "enabled": true,
5
+ "anatomy": {
6
+ "auto_scan_on_init": true,
7
+ "rescan_interval_hours": 6,
8
+ "max_description_length": 100,
9
+ "max_files": 500,
10
+ "exclude_patterns": [
11
+ "node_modules",
12
+ ".git",
13
+ "dist",
14
+ "build",
15
+ ".wolf",
16
+ ".next",
17
+ ".nuxt",
18
+ "coverage",
19
+ "__pycache__",
20
+ ".cache",
21
+ "target",
22
+ ".vscode",
23
+ ".idea",
24
+ ".turbo",
25
+ ".vercel",
26
+ ".netlify",
27
+ ".output",
28
+ "*.min.js",
29
+ "*.min.css"
30
+ ]
31
+ },
32
+ "token_audit": {
33
+ "enabled": true,
34
+ "report_frequency": "weekly",
35
+ "waste_threshold_percent": 15,
36
+ "chars_per_token_code": 3.5,
37
+ "chars_per_token_prose": 4.0
38
+ },
39
+ "cron": {
40
+ "enabled": true,
41
+ "max_retry_attempts": 3,
42
+ "dead_letter_enabled": true,
43
+ "heartbeat_interval_minutes": 30,
44
+ "use_claude_p": true,
45
+ "api_key_env": null
46
+ },
47
+ "memory": {
48
+ "consolidation_after_days": 7,
49
+ "max_entries_before_consolidation": 200
50
+ },
51
+ "cerebrum": {
52
+ "max_tokens": 2000,
53
+ "reflection_frequency": "weekly"
54
+ },
55
+ "daemon": {
56
+ "port": 18790,
57
+ "log_level": "info"
58
+ },
59
+ "dashboard": {
60
+ "enabled": true,
61
+ "port": 18791
62
+ },
63
+ "designqc": {
64
+ "enabled": true,
65
+ "viewports": [
66
+ { "name": "desktop", "width": 1440, "height": 900 },
67
+ { "name": "mobile", "width": 375, "height": 812 }
68
+ ],
69
+ "max_screenshots": 6,
70
+ "chrome_path": null
71
+ }
72
+ }
73
+ }
@@ -0,0 +1,97 @@
1
+ {
2
+ "version": 1,
3
+ "tasks": [
4
+ {
5
+ "id": "anatomy-rescan",
6
+ "name": "Full anatomy rescan",
7
+ "schedule": "0 */6 * * *",
8
+ "description": "Re-scans project filesystem and reconciles anatomy.md",
9
+ "action": { "type": "scan_project" },
10
+ "retry": {
11
+ "max_attempts": 3,
12
+ "backoff": "exponential",
13
+ "base_delay_seconds": 30
14
+ },
15
+ "failsafe": {
16
+ "on_failure": "log_and_continue",
17
+ "alert_after_consecutive_failures": 2,
18
+ "dead_letter": true
19
+ },
20
+ "enabled": true
21
+ },
22
+ {
23
+ "id": "memory-consolidation",
24
+ "name": "Consolidate old memory",
25
+ "schedule": "0 2 * * *",
26
+ "description": "Compress memory.md entries older than 7 days",
27
+ "action": {
28
+ "type": "consolidate_memory",
29
+ "params": { "older_than_days": 7 }
30
+ },
31
+ "retry": {
32
+ "max_attempts": 2,
33
+ "backoff": "exponential",
34
+ "base_delay_seconds": 60
35
+ },
36
+ "failsafe": {
37
+ "on_failure": "skip_and_retry_next_cycle",
38
+ "dead_letter": false
39
+ },
40
+ "enabled": true
41
+ },
42
+ {
43
+ "id": "token-audit",
44
+ "name": "Token audit report",
45
+ "schedule": "0 0 * * 1",
46
+ "description": "Weekly waste pattern detection",
47
+ "action": { "type": "generate_token_report" },
48
+ "retry": {
49
+ "max_attempts": 2,
50
+ "backoff": "linear",
51
+ "base_delay_seconds": 60
52
+ },
53
+ "failsafe": { "on_failure": "log_and_continue", "dead_letter": true },
54
+ "enabled": true
55
+ },
56
+ {
57
+ "id": "cerebrum-reflection",
58
+ "name": "Cerebrum reflection",
59
+ "schedule": "0 3 * * 0",
60
+ "description": "Weekly AI review of cerebrum.md — prune stale entries, consolidate duplicates",
61
+ "action": {
62
+ "type": "ai_task",
63
+ "params": {
64
+ "prompt": "Review this cerebrum.md. Remove duplicate preferences (keep newer). Remove Do-Not-Repeat entries older than 90 days if no longer relevant. Consolidate Key Learnings that overlap. Keep the file under 2000 tokens. Return the cleaned file content only.",
65
+ "context_files": [".wolf/cerebrum.md"]
66
+ }
67
+ },
68
+ "retry": {
69
+ "max_attempts": 1,
70
+ "backoff": "none",
71
+ "base_delay_seconds": 0
72
+ },
73
+ "failsafe": { "on_failure": "log_and_continue", "dead_letter": false },
74
+ "enabled": true
75
+ },
76
+ {
77
+ "id": "project-suggestions",
78
+ "name": "AI suggestions",
79
+ "schedule": "0 4 * * 1",
80
+ "description": "Weekly AI analysis with project improvement suggestions",
81
+ "action": {
82
+ "type": "ai_task",
83
+ "params": {
84
+ "prompt": "Based on the recent memory entries and current project structure, provide: 1) Key achievements this week, 2) Code improvements to consider, 3) Logical next tasks, 4) Technical debt or risks. Be specific and actionable. Return as JSON: {achievements:[], improvements:[], next_tasks:[], risks:[]}",
85
+ "context_files": [".wolf/memory.md", ".wolf/anatomy.md"]
86
+ }
87
+ },
88
+ "retry": {
89
+ "max_attempts": 1,
90
+ "backoff": "none",
91
+ "base_delay_seconds": 0
92
+ },
93
+ "failsafe": { "on_failure": "log_and_continue", "dead_letter": false },
94
+ "enabled": true
95
+ }
96
+ ]
97
+ }
@@ -0,0 +1,7 @@
1
+ {
2
+ "last_heartbeat": null,
3
+ "engine_status": "initialized",
4
+ "execution_log": [],
5
+ "dead_letter_queue": [],
6
+ "upcoming": []
7
+ }
@@ -0,0 +1,9 @@
1
+ # Identity
2
+
3
+ - **Name:** Wolf
4
+ - **Role:** AI development assistant for this project
5
+ - **Tone:** Direct, concise, technically precise
6
+ - **Constraints:**
7
+ - Never modify .env or secret files without explicit user confirmation
8
+ - Never delete files without explicit user confirmation
9
+ - Always explain why before making architectural changes
@@ -0,0 +1,4 @@
1
+ # Memory
2
+
3
+ > Chronological action log. Hooks and AI append to this file automatically.
4
+ > Old sessions are consolidated by the daemon weekly.