kraken-code 1.1.3 → 1.2.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.
@@ -0,0 +1,68 @@
1
+ # Kraken Code Architecture
2
+
3
+ Kraken Code is structured as a plugin that augments OpenCode with orchestration, hooks, tooling, and a unified learning system.
4
+
5
+ ## High-Level Components
6
+
7
+ ```
8
+ src/
9
+ ├── agents/ # Sea-themed agents with focused roles
10
+ ├── features/
11
+ │ ├── memory/ # Unified learning system (experience store, knowledge graph)
12
+ │ ├── mcp/ # Built-in MCP servers (websearch, context7, grep_app)
13
+ │ ├── background-agent/ # Background task orchestration
14
+ │ ├── skill-mcp-manager/ # Skill-defined MCP servers
15
+ │ └── command-loader/ # Built-in command loader
16
+ ├── hooks/ # Lifecycle hooks for OpenCode integration
17
+ ├── tools/ # CLI-style tools exposed to OpenCode
18
+ ├── config/ # Zod schemas + config manager
19
+ └── storage/ # Session transcripts and todo persistence
20
+ ```
21
+
22
+ ## Unified Learning System
23
+
24
+ The learning subsystem is designed to replace the legacy Kratos memory integration with a cohesive, on-disk learning store.
25
+
26
+ ### Core Stores
27
+
28
+ - **Experience Store**: Captures decisions, outcomes, and context from real sessions.
29
+ - **Knowledge Graph**: Nodes and edges for structured knowledge and references.
30
+ - **Pattern Detection**: Tracks recurring signals and confidence levels.
31
+ - **Spaced Repetition**: Schedules reviews of important knowledge nodes.
32
+ - **State Machines**: Tracks multi-step workflows and learning loops.
33
+
34
+ ### Persistence Model
35
+
36
+ All learning data is stored in `~/.kraken/learning/learning-state.json` (configurable). The system loads once at startup and auto-saves on changes when enabled.
37
+
38
+ ### Tooling Integration
39
+
40
+ Learning tools are exposed via `learning_*` commands and can be triggered from OpenCode:
41
+
42
+ - `learning_add_experience`, `learning_search_experiences`
43
+ - `learning_add_knowledge_node`, `learning_search_knowledge_nodes`, `learning_link_knowledge_nodes`
44
+ - `learning_record_pattern`, `learning_list_patterns`
45
+ - `learning_get_review_queue`, `learning_review_node`
46
+ - `learning_create_state_machine`, `learning_list_state_machines`
47
+
48
+ ## Hook Lifecycle
49
+
50
+ Hooks are used to intercept OpenCode lifecycle events (`tool.execute.before`, `tool.execute.after`, etc.) and provide:
51
+
52
+ - Mode activation (Blitzkrieg, Analyze, Ultrathink)
53
+ - Context injection
54
+ - Error recovery
55
+ - Session storage
56
+ - Learning initialization
57
+
58
+ ## Configuration Flow
59
+
60
+ 1. `~/.config/opencode/kraken-code.json` is parsed by the config manager.
61
+ 2. Zod schemas validate and normalize values.
62
+ 3. Hook/config loaders consume validated config for runtime behavior.
63
+
64
+ ## Extensibility
65
+
66
+ - Add new tools under `src/tools/`
67
+ - Add new hooks under `src/hooks/`
68
+ - Extend learning by adding new store helpers in `src/features/memory/`
@@ -0,0 +1,85 @@
1
+ # Blitzkrieg Mode
2
+
3
+ Blitzkrieg Mode is an aggressive test-driven development workflow built into Kraken Code.
4
+
5
+ ## Activation
6
+
7
+ Simply include "blitz" or "blz" in your request:
8
+ - "Use blitz to implement auth system"
9
+ - "Enable blz mode for this feature"
10
+ - "Refactor with blitzkrieg standards"
11
+
12
+ ## Features
13
+
14
+ ### Test Plan Enforcement
15
+ - Required before complex features
16
+ - Minimum test cases specified
17
+ - Coverage thresholds defined
18
+
19
+ ### TDD Workflow
20
+ - Tests written before implementation
21
+ - No code without tests
22
+ - Refactoring allowed
23
+
24
+ ### Evidence Verification
25
+ - Test execution evidence required
26
+ - Assertion count verified
27
+ - Edge cases checked
28
+
29
+ ### Planner Constraints
30
+ - Test step required in plans
31
+ - Verification step required
32
+ - Complexity limits enforced
33
+
34
+ ## Common Workflow
35
+
36
+ 1. **Plan**: Create test plan for feature
37
+ 2. **Write Tests**: Implement test cases first
38
+ 3. **Implement**: Write production code
39
+ 4. **Verify**: Run tests and show evidence
40
+ 5. **Refine**: Add edge cases until coverage goal met
41
+
42
+ ## Test Plan Template
43
+
44
+ For complex features, create a test plan:
45
+
46
+ ```typescript
47
+ {
48
+ feature: "Feature name",
49
+ testCases: [
50
+ { description: "Happy path", category: "happy-path" },
51
+ { description: "Error case", category: "error-path" },
52
+ { description: "Edge case", category: "edge-case" }
53
+ ],
54
+ coverageTarget: 80
55
+ }
56
+ ```
57
+
58
+ ## Evidence Requirements
59
+
60
+ When asked for evidence, provide:
61
+ - Test execution log
62
+ - Number of assertions passed/failed
63
+ - Edge cases covered
64
+ - Coverage percentage (if available)
65
+
66
+ ## Configuration
67
+
68
+ Blitzkrieg mode is **enabled by default** (opt-out). Configure in `~/.config/opencode/opencode.json`:
69
+
70
+ ```json
71
+ {
72
+ "blitzkrieg": {
73
+ "enabled": true,
74
+ "testPlan": {
75
+ "requiredBeforeImplementation": true,
76
+ "minTestCases": 3,
77
+ "coverageThresholdPercent": 80
78
+ },
79
+ "tddWorkflow": {
80
+ "enforceWriteTestFirst": true,
81
+ "forbidCodeWithoutTest": true
82
+ }
83
+ }
84
+ }
85
+ ```
@@ -0,0 +1,74 @@
1
+ # Kraken Code Examples
2
+
3
+ ## Learning Tools
4
+
5
+ ### Capture an Experience
6
+
7
+ ```bash
8
+ learning_add_experience --summary "Switched cache strategy" \
9
+ --details "Moved from LRU to segmented cache to handle bursty traffic." \
10
+ --tags ["performance", "caching"] \
11
+ --outcome "Reduced 99p latency by 12%" \
12
+ --confidence 0.8
13
+ ```
14
+
15
+ ### Create Knowledge Nodes
16
+
17
+ ```bash
18
+ learning_add_knowledge_node --title "Cache segmentation" \
19
+ --content "Segment cache into hot/warm buckets to reduce churn." \
20
+ --type "decision" \
21
+ --tags ["performance", "design"]
22
+ ```
23
+
24
+ ### Link Knowledge Nodes
25
+
26
+ ```bash
27
+ learning_link_knowledge_nodes --sourceId node_123 --targetId node_456 \
28
+ --relation "depends_on" --strength 0.7
29
+ ```
30
+
31
+ ### Record a Pattern
32
+
33
+ ```bash
34
+ learning_record_pattern --name "cache-churn" \
35
+ --description "Cache churn increases once traffic exceeds 1k rps." \
36
+ --triggers ["cache", "traffic"]
37
+ ```
38
+
39
+ ### Review Queue
40
+
41
+ ```bash
42
+ learning_get_review_queue --dueBefore "2025-01-01T00:00:00.000Z"
43
+ ```
44
+
45
+ ### Log a Review
46
+
47
+ ```bash
48
+ learning_review_node --nodeId node_123 --quality 4
49
+ ```
50
+
51
+ ### State Machines
52
+
53
+ ```bash
54
+ learning_create_state_machine --name "Release Checklist" \
55
+ --states ["planned", "in-progress", "verified", "released"] \
56
+ --transitions '[{"from":"planned","to":"in-progress","event":"start"},{"from":"in-progress","to":"verified","event":"qa"},{"from":"verified","to":"released","event":"ship"}]' \
57
+ --initialState "planned"
58
+ ```
59
+
60
+ ## Configuration Example
61
+
62
+ ```json
63
+ {
64
+ "learning": {
65
+ "enabled": true,
66
+ "storagePath": "~/.kraken/learning",
67
+ "experienceStore": { "enabled": true, "maxEntries": 2000 },
68
+ "knowledgeGraph": { "enabled": true, "maxNodes": 5000 },
69
+ "patternDetection": { "enabled": true, "minConfidence": 0.6 },
70
+ "spacedRepetition": { "enabled": true, "initialIntervalDays": 1 },
71
+ "stateMachines": { "enabled": true }
72
+ }
73
+ }
74
+ ```
package/docs/FAQ.md ADDED
@@ -0,0 +1,21 @@
1
+ # Frequently Asked Questions
2
+
3
+ ## What replaced the Kratos memory integration?
4
+
5
+ Kraken Code now uses a unified learning system that stores experiences, knowledge graph nodes, patterns, and spaced repetition schedules in a single on-disk store.
6
+
7
+ ## Where is learning data stored?
8
+
9
+ By default at `~/.kraken/learning/learning-state.json`. You can change the path via the `learning.storagePath` setting.
10
+
11
+ ## Can I disable parts of the learning system?
12
+
13
+ Yes. Each learning component has its own `enabled` flag (`experienceStore`, `knowledgeGraph`, `patternDetection`, `spacedRepetition`, `stateMachines`).
14
+
15
+ ## How do I migrate from the old memory config?
16
+
17
+ If you already had a `memory` block in your config, Kraken Code will still read its `enabled`, `autoSave`, and `storagePath` values as defaults for the new learning config. Updating to the new `learning` block is recommended.
18
+
19
+ ## Does the learning system work without MCP?
20
+
21
+ Yes. The learning tools are built-in and do not depend on external MCP servers.
@@ -0,0 +1,45 @@
1
+ # Skills Guide
2
+
3
+ Skills in Kraken Code use natural language to guide the AI for specific tasks.
4
+
5
+ ## Available Skills
6
+
7
+ ### Memory Skills
8
+ - **Remember**: Store important information in the unified learning system
9
+ - **Recall**: Retrieve stored memories
10
+
11
+ ### Session Skills
12
+ - **Summary**: Generate session summaries
13
+
14
+ ### Project Skills
15
+ - **Bootstrap**: Initialize new projects with patterns
16
+ - **Init**: Set up project structure
17
+
18
+ ### Git Skills
19
+ - **GitHub Integration**: Manage PRs and issues
20
+ - **Import Pattern**: Apply code patterns
21
+
22
+ ### Testing Skills
23
+ - **Coverage**: Analyze and improve test coverage
24
+
25
+ ### Code Skills
26
+ - **Code Analyzer**: Analyze code structure
27
+ - **Code Simplifier**: Simplify complex code
28
+ - **Video Generator**: Create documentation videos
29
+ - **Blitzkrieg**: Aggressive TDD workflow
30
+
31
+ ## Using Skills
32
+
33
+ Simply describe what you want in natural language:
34
+ - "Remember that JWT expiration policy"
35
+ - "Recall authentication patterns"
36
+ - "Generate a session summary"
37
+ - "Create tests for the auth module"
38
+
39
+ The AI will automatically select and apply the appropriate skill.
40
+
41
+ ## Skill Auto-Loading
42
+
43
+ Skills are automatically loaded from:
44
+ - `~/.config/opencode/skill/` - User's custom skills
45
+ - `~/.config/opencode/kraken-code/templates/skills/` - Built-in skills
@@ -0,0 +1,29 @@
1
+ # Troubleshooting
2
+
3
+ ## Learning data not updating
4
+
5
+ 1. Confirm `learning.enabled` is `true`.
6
+ 2. Ensure the storage path is writable.
7
+ 3. Check that `learning.autoSave` is not disabled.
8
+
9
+ If changes still do not persist, delete `~/.kraken/learning/learning-state.json` to reset the store.
10
+
11
+ ## Learning tools return empty results
12
+
13
+ - Verify that `kraken-code init --full` created the `learning` section.
14
+ - Add at least one experience or knowledge node and retry.
15
+
16
+ ## Configuration errors
17
+
18
+ If Kraken Code fails to load configuration:
19
+
20
+ 1. Validate JSON syntax in `~/.config/opencode/kraken-code.json`.
21
+ 2. Ensure `learning` keys use the expected types (booleans, numbers, strings).
22
+ 3. Remove deprecated keys such as `kratos`.
23
+
24
+ ## Hooks not firing
25
+
26
+ Hooks may be disabled by configuration or external OpenCode settings:
27
+
28
+ - Check `claudeCodeCompatibility.toggles.hooks` if present.
29
+ - Ensure OpenCode is not running in a restricted mode that disables plugin hooks.
package/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "kraken-code",
3
- "version": "1.1.3",
3
+ "version": "1.2.0",
4
4
  "description": "Kraken Code - Transforms OpenCode into an autonomous, high-density development environment",
5
5
  "type": "module",
6
6
  "main": "dist/index.js",
@@ -10,7 +10,13 @@
10
10
  "kraken-code": "./dist/cli/index.js"
11
11
  },
12
12
  "files": [
13
- "dist"
13
+ "dist",
14
+ "scripts/install-curl.sh",
15
+ "assets",
16
+ "docs",
17
+ "README.md",
18
+ "LICENSE",
19
+ "CHANGELOG.md"
14
20
  ],
15
21
  "exports": {
16
22
  ".": {
@@ -21,13 +27,17 @@
21
27
  "types": "./dist/google-auth.d.ts",
22
28
  "import": "./dist/google-auth.js"
23
29
  },
24
- "./schema.json": "./dist/kraken-code.schema.json"
30
+ "./schema.json": "./dist/kraken-code.schema.json",
31
+ "./package.json": "./package.json"
25
32
  },
26
33
  "scripts": {
27
- "build": "bun build src/index.ts src/google-auth.ts --outdir dist --target node --format esm --external @opencode-ai/plugin --external @opencode-ai/sdk --external zod && bun build src/cli/index.ts --outdir dist/cli --target bun --format esm --packages external && bun run build:schema",
34
+ "build": "bun run build:plugin && bun run build:cli && bun run build:schema",
35
+ "build:plugin": "bun build src/index.ts src/google-auth.ts --outdir dist --target node --format esm --external @opencode-ai/plugin --external @opencode-ai/sdk --external zod --minify",
36
+ "build:cli": "bun build src/cli/index.ts --outdir dist/cli --target bun --format esm --packages external --minify",
28
37
  "build:schema": "bun run script/build-schema.ts && mkdir -p dist && cp assets/kraken-code.schema.json dist/kraken-code.schema.json",
29
- "clean": "rm -rf dist",
30
- "prepublishOnly": "bun run clean && bun run build",
38
+ "build:binary": "bun build --compile src/cli/index.ts --outfile bin/kraken-code",
39
+ "clean": "rm -rf dist bin",
40
+ "prepublishOnly": "bun run clean && bun run build && bun run typecheck",
31
41
  "typecheck": "tsc --noEmit",
32
42
  "lint": "eslint src/**/*.ts",
33
43
  "lint:fix": "eslint src/**/*.ts --fix",
@@ -36,7 +46,12 @@
36
46
  "test": "bun test",
37
47
  "test:watch": "bun test --watch",
38
48
  "install:curl": "bash scripts/install-curl.sh",
39
- "postinstall": "kraken-code init --minimal"
49
+ "agent:docs": "npx skill-compiler compile",
50
+ "agent:docs:watch": "npx skill-compiler watch",
51
+ "agent:docs:check": "npx skill-compiler compile --check",
52
+ "agent:docs:suggest": "npx skill-compiler suggest",
53
+ "agent:docs:sync": "npx skill-compiler sync",
54
+ "postinstall": "npx skill-compiler compile --silent"
40
55
  },
41
56
  "keywords": [
42
57
  "opencode",
@@ -70,14 +85,10 @@
70
85
  },
71
86
  "homepage": "https://github.com/leviathofnoesia/kraken-code#readme",
72
87
  "dependencies": {
73
- "@ast-grep/cli": "^0.40.0",
74
- "@ast-grep/napi": "^0.40.0",
75
88
  "@clack/core": "^0.5.0",
76
89
  "@clack/prompts": "^1.0.0-alpha.9",
77
90
  "@modelcontextprotocol/sdk": "^1.25.1",
78
91
  "@openauthjs/openauth": "^0.4.3",
79
- "@opencode-ai/plugin": "^1.1.1",
80
- "@opencode-ai/sdk": "^1.1.1",
81
92
  "commander": "^14.0.2",
82
93
  "glob": "^11.0.0",
83
94
  "hono": "^4.10.4",
@@ -89,6 +100,14 @@
89
100
  "xdg-basedir": "^5.1.0",
90
101
  "zod": "4.1.8"
91
102
  },
103
+ "optionalDependencies": {
104
+ "@ast-grep/cli": "^0.40.0",
105
+ "@ast-grep/napi": "^0.40.0"
106
+ },
107
+ "peerDependencies": {
108
+ "@opencode-ai/plugin": "^1.1.0",
109
+ "@opencode-ai/sdk": "^1.1.0"
110
+ },
92
111
  "devDependencies": {
93
112
  "@types/js-yaml": "^4.0.9",
94
113
  "@types/picomatch": "^3.0.2",
@@ -99,6 +118,7 @@
99
118
  "eslint-config-prettier": "^9.0.0",
100
119
  "eslint-plugin-prettier": "^5.0.0",
101
120
  "prettier": "^3.0.0",
121
+ "skill-compiler": "latest",
102
122
  "typescript": "^5.9.3",
103
123
  "typescript-language-server": "^5.1.3"
104
124
  },
@@ -0,0 +1,111 @@
1
+ #!/bin/bash
2
+
3
+ set -e
4
+
5
+ VERSION="5.0.0"
6
+ PACKAGE_NAME="kraken-code"
7
+ REGISTRY_URL="https://registry.npmjs.org"
8
+ OPENCODE_DIR="$HOME/.config/opencode"
9
+ PLUGINS_DIR="$OPENCODE_DIR/plugins"
10
+
11
+ echo "======================================"
12
+ echo "Kraken Code v${VERSION} Installer"
13
+ echo "======================================"
14
+ echo ""
15
+
16
+ # Check if curl is available
17
+ if ! command -v curl &> /dev/null; then
18
+ echo "Error: curl is required but not installed"
19
+ echo "Install curl from https://curl.se/download.html"
20
+ exit 1
21
+ fi
22
+
23
+ # Check if tar is available
24
+ if ! command -v tar &> /dev/null; then
25
+ echo "Error: tar is required but not installed"
26
+ exit 1
27
+ fi
28
+
29
+ # Create plugin directory
30
+ echo "Creating plugin directory..."
31
+ mkdir -p "$PLUGINS_DIR"
32
+
33
+ # Download package
34
+ echo "Downloading Kraken Code v${VERSION}..."
35
+ TEMP_TGZ=$(mktemp)
36
+ DOWNLOAD_URL="${REGISTRY_URL}/${PACKAGE_NAME}/-/${PACKAGE_NAME}-${VERSION}.tgz"
37
+
38
+ if curl -fsSL --max-time 60 -o "$TEMP_TGZ" "$DOWNLOAD_URL"; then
39
+ echo "Download complete"
40
+ else
41
+ echo "Error: Failed to download Kraken Code"
42
+ echo "URL: $DOWNLOAD_URL"
43
+ rm -f "$TEMP_TGZ"
44
+ exit 1
45
+ fi
46
+
47
+ # Extract package
48
+ echo "Extracting package..."
49
+ cd "$PLUGINS_DIR"
50
+
51
+ if tar -xzf "$TEMP_TGZ"; then
52
+ echo "Extraction complete"
53
+ else
54
+ echo "Error: Failed to extract package"
55
+ rm -f "$TEMP_TGZ"
56
+ exit 1
57
+ fi
58
+
59
+ # Verify installation
60
+ PACKAGE_DIR="${PLUGINS_DIR}/package"
61
+ if [ ! -d "$PACKAGE_DIR" ]; then
62
+ echo "Error: Package directory not found after extraction"
63
+ rm -f "$TEMP_TGZ"
64
+ exit 1
65
+ fi
66
+
67
+ # Clean up
68
+ rm -f "$TEMP_TGZ"
69
+
70
+ # Get kraken-code CLI path
71
+ KRAKEN_CLI="$PACKAGE_DIR/dist/cli/index.js"
72
+
73
+ # Initialize Kraken Code configuration
74
+ if [ -f "$KRAKEN_CLI" ]; then
75
+ echo ""
76
+ echo "Initializing Kraken Code configuration..."
77
+ bun run "$KRAKEN_CLI" init --minimal
78
+ if [ $? -eq 0 ]; then
79
+ echo ""
80
+ echo "✓ Kraken Code initialized successfully!"
81
+ else
82
+ echo ""
83
+ echo "⚠️ Initialization failed. Run manually: kraken-code init --minimal"
84
+ fi
85
+ else
86
+ echo ""
87
+ echo "⚠️ CLI not found. Run manually: kraken-code init --minimal"
88
+ fi
89
+
90
+ # Get actual package name (might be scoped)
91
+ ACTUAL_PACKAGE_NAME=$(ls "$PLUGINS_DIR" | grep -v "^package$" | head -1)
92
+
93
+ if [ -z "$ACTUAL_PACKAGE_NAME" ]; then
94
+ ACTUAL_PACKAGE_NAME="package"
95
+ fi
96
+
97
+ # Success message
98
+ echo ""
99
+ echo "======================================"
100
+ echo "Installation Complete!"
101
+ echo "======================================"
102
+ echo ""
103
+ echo "Kraken Code v${VERSION} installed to: $PLUGINS_DIR/$ACTUAL_PACKAGE_NAME"
104
+ echo ""
105
+ echo "Next Steps:"
106
+ echo "1. Restart OpenCode to load plugin"
107
+ echo "2. Use 'blitz' or 'blz' to activate Blitzkrieg Mode"
108
+ echo "3. Run: kraken-code --help for more options"
109
+ echo ""
110
+ echo "Documentation: https://github.com/leviathofnoesia/kraken-code"
111
+ echo ""