toga-ai 1.0.2 → 1.0.5
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/.claude/settings.json +21 -21
- package/agents/framework-pattern-checker.md +52 -46
- package/agents/harness-optimizer.md +68 -94
- package/agents/knowledge-writer.md +48 -40
- package/agents/php-build-resolver.md +49 -30
- package/agents/php-reviewer.md +56 -34
- package/agents/planner.md +62 -58
- package/agents/session-capture.md +59 -81
- package/agents/sql-reviewer.md +28 -42
- package/package.json +1 -1
- package/scripts/hooks/block-destructive.js +7 -0
- package/scripts/hooks/guard-index.js +7 -0
- package/scripts/hooks/remind-php-lint.js +11 -0
- package/scripts/hooks/remind-php-review.js +6 -0
- package/scripts/hooks/scope-counter.js +12 -0
- package/scripts/install.js +80 -46
- package/skills/code-review/SKILL.md +51 -100
- package/skills/kickoff/SKILL.md +30 -0
package/.claude/settings.json
CHANGED
|
@@ -1,23 +1,12 @@
|
|
|
1
1
|
{
|
|
2
2
|
"hooks": {
|
|
3
|
-
"SessionStart": [
|
|
4
|
-
{
|
|
5
|
-
"hooks": [
|
|
6
|
-
{
|
|
7
|
-
"type": "command",
|
|
8
|
-
"command": "node \"${CLAUDE_PLUGIN_ROOT:-$(git rev-parse --show-toplevel 2>/dev/null || pwd)}/scripts/hooks/session-start.js\"",
|
|
9
|
-
"timeout": 5000
|
|
10
|
-
}
|
|
11
|
-
]
|
|
12
|
-
}
|
|
13
|
-
],
|
|
14
3
|
"PreToolUse": [
|
|
15
4
|
{
|
|
16
5
|
"matcher": "Bash",
|
|
17
6
|
"hooks": [
|
|
18
7
|
{
|
|
19
8
|
"type": "command",
|
|
20
|
-
"command": "
|
|
9
|
+
"command": "node \".claude/hooks/toga/block-destructive.js\"",
|
|
21
10
|
"timeout": 3000
|
|
22
11
|
}
|
|
23
12
|
]
|
|
@@ -27,7 +16,7 @@
|
|
|
27
16
|
"hooks": [
|
|
28
17
|
{
|
|
29
18
|
"type": "command",
|
|
30
|
-
"command": "
|
|
19
|
+
"command": "node \".claude/hooks/toga/guard-index.js\"",
|
|
31
20
|
"timeout": 3000
|
|
32
21
|
}
|
|
33
22
|
]
|
|
@@ -39,7 +28,7 @@
|
|
|
39
28
|
"hooks": [
|
|
40
29
|
{
|
|
41
30
|
"type": "command",
|
|
42
|
-
"command": "node \"
|
|
31
|
+
"command": "node \".claude/hooks/toga/post-edit-validate.js\"",
|
|
43
32
|
"timeout": 15000
|
|
44
33
|
}
|
|
45
34
|
]
|
|
@@ -49,7 +38,7 @@
|
|
|
49
38
|
"hooks": [
|
|
50
39
|
{
|
|
51
40
|
"type": "command",
|
|
52
|
-
"command": "
|
|
41
|
+
"command": "node \".claude/hooks/toga/remind-php-review.js\"",
|
|
53
42
|
"timeout": 3000
|
|
54
43
|
}
|
|
55
44
|
]
|
|
@@ -59,18 +48,29 @@
|
|
|
59
48
|
"hooks": [
|
|
60
49
|
{
|
|
61
50
|
"type": "command",
|
|
62
|
-
"command": "
|
|
51
|
+
"command": "node \".claude/hooks/toga/scope-counter.js\"",
|
|
63
52
|
"timeout": 3000
|
|
64
53
|
}
|
|
65
54
|
]
|
|
66
55
|
}
|
|
67
56
|
],
|
|
57
|
+
"SessionStart": [
|
|
58
|
+
{
|
|
59
|
+
"hooks": [
|
|
60
|
+
{
|
|
61
|
+
"type": "command",
|
|
62
|
+
"command": "node \".claude/hooks/toga/session-start.js\"",
|
|
63
|
+
"timeout": 5000
|
|
64
|
+
}
|
|
65
|
+
]
|
|
66
|
+
}
|
|
67
|
+
],
|
|
68
68
|
"Stop": [
|
|
69
69
|
{
|
|
70
70
|
"hooks": [
|
|
71
71
|
{
|
|
72
72
|
"type": "command",
|
|
73
|
-
"command": "node \"
|
|
73
|
+
"command": "node \".claude/hooks/toga/session-end.js\"",
|
|
74
74
|
"timeout": 5000
|
|
75
75
|
}
|
|
76
76
|
]
|
|
@@ -79,7 +79,7 @@
|
|
|
79
79
|
"hooks": [
|
|
80
80
|
{
|
|
81
81
|
"type": "command",
|
|
82
|
-
"command": "node \"
|
|
82
|
+
"command": "node \".claude/hooks/toga/evaluate-session.js\"",
|
|
83
83
|
"timeout": 5000
|
|
84
84
|
}
|
|
85
85
|
]
|
|
@@ -88,7 +88,7 @@
|
|
|
88
88
|
"hooks": [
|
|
89
89
|
{
|
|
90
90
|
"type": "command",
|
|
91
|
-
"command": "
|
|
91
|
+
"command": "node \".claude/hooks/toga/remind-php-lint.js\"",
|
|
92
92
|
"timeout": 3000
|
|
93
93
|
}
|
|
94
94
|
]
|
|
@@ -97,11 +97,11 @@
|
|
|
97
97
|
},
|
|
98
98
|
"permissions": {
|
|
99
99
|
"allow": [
|
|
100
|
-
"Bash(node knowledge.js *)",
|
|
100
|
+
"Bash(node .claude/knowledge.js *)",
|
|
101
|
+
"Bash(node .claude/hooks/toga/*.js)",
|
|
101
102
|
"Bash(node sync-skills.js *)",
|
|
102
103
|
"Bash(node scripts/harness.js *)",
|
|
103
104
|
"Bash(node scripts/install.js *)",
|
|
104
|
-
"Bash(node scripts/hooks/*.js)",
|
|
105
105
|
"Bash(php -l *)",
|
|
106
106
|
"Bash(git status)",
|
|
107
107
|
"Bash(git diff *)",
|
|
@@ -1,67 +1,73 @@
|
|
|
1
1
|
---
|
|
2
2
|
name: framework-pattern-checker
|
|
3
|
-
description:
|
|
4
|
-
model:
|
|
3
|
+
description: TOGA framework pattern validator — fires when a new PHP class is created. Detects which framework (1.0 App_ or 2.0 _underscore) and validates class naming, extension hierarchy, method conventions, and dispatch patterns. TOGA-specific specialist.
|
|
4
|
+
model: sonnet
|
|
5
5
|
tools: Read, Grep, Glob, Bash
|
|
6
6
|
---
|
|
7
7
|
|
|
8
|
-
# Framework Pattern Checker
|
|
8
|
+
# TOGA Framework Pattern Checker
|
|
9
9
|
|
|
10
|
-
|
|
10
|
+
Validates that new PHP classes follow the correct naming, inheritance, and structural conventions for TOGA Technology's two PHP frameworks.
|
|
11
11
|
|
|
12
|
-
##
|
|
13
|
-
- "check framework patterns"
|
|
14
|
-
- "does this follow conventions?"
|
|
15
|
-
- "validate my new class"
|
|
16
|
-
- "is this the right way to do X in 1.0/2.0?"
|
|
12
|
+
## When to run
|
|
17
13
|
|
|
18
|
-
|
|
14
|
+
- A new PHP file is created
|
|
15
|
+
- A class is renamed or its namespace changes
|
|
16
|
+
- A new method is added to a worker or controller
|
|
19
17
|
|
|
20
|
-
|
|
21
|
-
- File under `C:\WWW\1.0` or class starts with `App_` → **Framework 1.0**
|
|
22
|
-
- File under `C:\WWW\2.0` or class starts with `_` → **Framework 2.0**
|
|
23
|
-
- If still ambiguous: check `knowledge/registry.json` by repo name.
|
|
18
|
+
## Step 1 — Identify framework
|
|
24
19
|
|
|
25
|
-
|
|
26
|
-
|
|
27
|
-
|
|
28
|
-
|
|
29
|
-
- No direct model instantiation in controllers — must use the registry or factory: `App_Registry::get('ModelName')` or equivalent.
|
|
30
|
-
- Method names follow `camelCase`. No `snake_case` public methods.
|
|
31
|
-
- Class file is named to match the class: `App_Controller_Orders` → `Orders.php` under `controllers/`.
|
|
32
|
-
- Check `knowledge/1.0/apps/<repo>/architecture.md` for repo-specific patterns before flagging.
|
|
20
|
+
Read the new file:
|
|
21
|
+
- Class starts with `App_` → Framework 1.0 — standards: `.claude/knowledge/1.0/standards/backend-php.md`
|
|
22
|
+
- Class starts with `_` → Framework 2.0 — standards: `.claude/knowledge/2.0/standards/backend-php.md`
|
|
23
|
+
- Neither prefix → ask which framework before proceeding
|
|
33
24
|
|
|
34
|
-
|
|
35
|
-
- All framework classes use leading underscore: `_Controller`, `_Model`, `_Worker`, `_Api`.
|
|
36
|
-
- Workers must extend `_Worker` and implement a `run()` method.
|
|
37
|
-
- Workers must NOT be called directly from controllers or other workers — dispatch via queue.
|
|
38
|
-
- Controllers extend `_Controller`.
|
|
39
|
-
- For `api2` repo: every action method must return an array with keys `success`, `data`, `errors` — never a raw string or bare array.
|
|
40
|
-
- `dependsOn` in `registry.json` means shared base classes exist — check `knowledge/2.0/apps/<shared-repo>/architecture.md` before adding new methods to inherited classes.
|
|
25
|
+
Check `.claude/knowledge/registry.json` to confirm the repo's registered framework matches.
|
|
41
26
|
|
|
42
|
-
|
|
43
|
-
- No `eval()` usage.
|
|
44
|
-
- No direct `$_GET`/`$_POST` access without validation wrapper.
|
|
45
|
-
- No raw string SQL (`"SELECT * FROM users WHERE id = " . $id`).
|
|
27
|
+
## Step 2 — Load standards
|
|
46
28
|
|
|
47
|
-
|
|
29
|
+
Read the framework standards file. Pull out: required naming, required parent class, required methods, forbidden patterns.
|
|
48
30
|
|
|
49
|
-
##
|
|
31
|
+
## Step 3 — Validate
|
|
50
32
|
|
|
33
|
+
**Framework 1.0 (App_) checklist:**
|
|
34
|
+
- Class name starts with `App_` — CRITICAL if not
|
|
35
|
+
- Controller extends `App_Controller` — CRITICAL if not
|
|
36
|
+
- Model extends `App_Model` — CRITICAL if not
|
|
37
|
+
- No `new App_*` inside the class — WARNING (use `App_Registry::get('ClassName')`)
|
|
38
|
+
- Public methods in `camelCase` — WARNING if not
|
|
39
|
+
- File name matches class name exactly — CRITICAL if not
|
|
40
|
+
|
|
41
|
+
**Framework 2.0 (_underscore) checklist:**
|
|
42
|
+
- Worker class starts with `_Worker_` — CRITICAL if not
|
|
43
|
+
- Worker extends `_Worker` — CRITICAL if not
|
|
44
|
+
- Worker has `public function run(): void` — CRITICAL if missing
|
|
45
|
+
- No direct `$worker->run()` call in other files — CRITICAL (use `_Queue::dispatch()`)
|
|
46
|
+
- Controller starts with `_Controller_` — CRITICAL if not
|
|
47
|
+
- api2 actions return `{success, data, errors}` envelope — CRITICAL if not
|
|
48
|
+
- DB access via `_Db::` only — WARNING if raw PDO in controllers/workers
|
|
49
|
+
|
|
50
|
+
## Step 4 — Check knowledge base for repo-specific rules
|
|
51
|
+
|
|
52
|
+
```
|
|
53
|
+
node .claude/knowledge.js search --repo=<repo> --q=class pattern convention
|
|
51
54
|
```
|
|
52
|
-
## Framework Pattern Check — <filename>
|
|
53
|
-
Framework: 1.0 (App_) | 2.0 (_underscore)
|
|
54
55
|
|
|
55
|
-
|
|
56
|
-
[line 14] Class 'OrderProcessor' missing App_ prefix — should be 'App_Model_OrderProcessor'
|
|
57
|
-
[line 47] Direct model instantiation: `new App_Model_User()` — use App_Registry::get('User')
|
|
56
|
+
Apply any repo-specific overrides found.
|
|
58
57
|
|
|
59
|
-
|
|
60
|
-
✓ Controller extends App_Controller
|
|
61
|
-
✓ No direct SQL string concatenation found
|
|
62
|
-
✓ No eval() usage
|
|
58
|
+
## Output
|
|
63
59
|
|
|
64
|
-
|
|
60
|
+
Pass: `✓ Framework pattern check passed — <ClassName> follows all Framework <X> conventions.`
|
|
61
|
+
|
|
62
|
+
Fail:
|
|
65
63
|
```
|
|
64
|
+
## Framework Pattern Violations — <filename>
|
|
65
|
+
Framework: <1.0 (App_) | 2.0 (_underscore)>
|
|
66
|
+
|
|
67
|
+
CRITICAL (will cause runtime failures):
|
|
68
|
+
- Line 1: Class `OrderProcessor` must start with `_Worker_` → rename to `_Worker_OrderProcessor`
|
|
69
|
+
- Line 8: Missing `run()` method — _Worker subclasses must implement run(): void
|
|
66
70
|
|
|
67
|
-
|
|
71
|
+
WARNING:
|
|
72
|
+
- Line 45: Raw `new _Db()` — use `_Db::select()` static method
|
|
73
|
+
```
|
|
@@ -1,102 +1,76 @@
|
|
|
1
1
|
---
|
|
2
2
|
name: harness-optimizer
|
|
3
|
-
description:
|
|
3
|
+
description: TOGA harness health auditor — scores the current .claude/ setup across skills, agents, rules, hooks, knowledge base, and ECC integration. Produces a prioritized fix list with auto-fix offers. Fires inside /harness-audit skill.
|
|
4
4
|
model: sonnet
|
|
5
|
-
tools: Read, Grep, Glob
|
|
5
|
+
tools: Read, Bash, Grep, Glob
|
|
6
6
|
---
|
|
7
7
|
|
|
8
|
-
# Harness Optimizer
|
|
9
|
-
|
|
10
|
-
Audits the TOGA Team Knowledge System harness and scores its completeness and health from 0 to 100. Runs actual validation commands when available. Reports concisely: score, what's working, what's missing, and the three changes that would have the highest impact.
|
|
11
|
-
|
|
12
|
-
## Trigger phrases
|
|
13
|
-
- "audit the harness"
|
|
14
|
-
- "how healthy is the harness?"
|
|
15
|
-
- "harness score"
|
|
16
|
-
- "/harness-audit"
|
|
17
|
-
- "what should I improve in the harness?"
|
|
18
|
-
|
|
19
|
-
## Behavior
|
|
20
|
-
|
|
21
|
-
1. **Run existing audit tooling** (if available):
|
|
22
|
-
- `node knowledge.js validate` — knowledge base integrity
|
|
23
|
-
- `node scripts/harness.js audit` — harness-level checks
|
|
24
|
-
- Note the output and exit codes.
|
|
25
|
-
|
|
26
|
-
2. **Check hooks coverage** (25 points):
|
|
27
|
-
- Read `.claude/settings.json`.
|
|
28
|
-
- Check for `SessionStart` hook → context priming (5 pts)
|
|
29
|
-
- Check for `PreToolUse` hooks → dangerous command protection (5 pts)
|
|
30
|
-
- Check for `PostToolUse` hooks → validation after writes (5 pts)
|
|
31
|
-
- Check for `Stop` hooks → session-end reminders (5 pts)
|
|
32
|
-
- Each hook that has a real implementation (not just an echo) = full points. (5 pts total for quality)
|
|
33
|
-
|
|
34
|
-
3. **Check rules completeness** (20 points):
|
|
35
|
-
- `rules/common/coding-style.md` exists (4 pts)
|
|
36
|
-
- `rules/common/security.md` exists (4 pts)
|
|
37
|
-
- `rules/common/git-workflow.md` exists (4 pts)
|
|
38
|
-
- `rules/php/app-framework.md` exists (4 pts)
|
|
39
|
-
- `rules/php/underscore-framework.md` exists (4 pts)
|
|
40
|
-
|
|
41
|
-
4. **Check agent coverage** (20 points):
|
|
42
|
-
- `agents/php-reviewer.md` exists (4 pts)
|
|
43
|
-
- `agents/planner.md` exists (4 pts)
|
|
44
|
-
- `agents/sql-reviewer.md` exists (4 pts)
|
|
45
|
-
- `agents/knowledge-writer.md` exists (4 pts)
|
|
46
|
-
- `agents/harness-optimizer.md` (self) exists (4 pts)
|
|
47
|
-
|
|
48
|
-
5. **Check skills completeness** (20 points):
|
|
49
|
-
- `skills/kickoff/SKILL.md` (4 pts)
|
|
50
|
-
- `skills/capture/SKILL.md` (4 pts)
|
|
51
|
-
- `skills/session-save/SKILL.md` (4 pts)
|
|
52
|
-
- `skills/session-resume/SKILL.md` (4 pts)
|
|
53
|
-
- `skills/php-patterns/SKILL.md` OR `skills/code-review/SKILL.md` (4 pts)
|
|
54
|
-
|
|
55
|
-
6. **Check knowledge base** (15 points):
|
|
56
|
-
- `knowledge/CONVENTIONS.md` exists (3 pts)
|
|
57
|
-
- `knowledge/registry.json` exists and is valid JSON (3 pts)
|
|
58
|
-
- At least one architecture.md per registered repo (3 pts)
|
|
59
|
-
- No validation errors from `node knowledge.js validate` (3 pts)
|
|
60
|
-
- INDEX.md files are present for all app directories (3 pts)
|
|
61
|
-
|
|
62
|
-
7. **Identify top 3 improvements**: Rank missing items by impact × ease. Prioritize:
|
|
63
|
-
- Security rules (highest impact if missing)
|
|
64
|
-
- Hooks that validate/protect (high impact)
|
|
65
|
-
- Agent coverage for the team's core workflow (php-reviewer, planner)
|
|
66
|
-
|
|
67
|
-
## Output format
|
|
8
|
+
# TOGA Harness Optimizer
|
|
68
9
|
|
|
10
|
+
Audits the health of the TOGA Claude Code setup and produces a scored, actionable improvement plan.
|
|
11
|
+
|
|
12
|
+
## Step 1 — Inventory
|
|
13
|
+
|
|
14
|
+
```sh
|
|
15
|
+
ls .claude/skills/ # expected: 9 skills
|
|
16
|
+
ls .claude/agents/toga/ # expected: 8 agents
|
|
17
|
+
ls .claude/rules/toga/ # expected: 6+ rule files
|
|
18
|
+
ls .claude/hooks/toga/ # expected: 9 hook scripts
|
|
19
|
+
node .claude/knowledge.js validate
|
|
20
|
+
```
|
|
21
|
+
|
|
22
|
+
Check `.claude/settings.json` to confirm all 9 hooks are wired.
|
|
23
|
+
|
|
24
|
+
## Step 2 — Score across 6 dimensions (0–100 each)
|
|
25
|
+
|
|
26
|
+
**Skills completeness (weight 20):** Expected: kickoff, capture, code-review, php-patterns, session-save, session-resume, harness-audit, sync-team-skills, create-elastic-beanstalk. All 9 = 100, score proportionally.
|
|
27
|
+
|
|
28
|
+
**Agents completeness (weight 20):** Expected: php-reviewer, sql-reviewer, framework-pattern-checker, php-build-resolver, planner, knowledge-writer, session-capture, harness-optimizer. All 8 = 100.
|
|
29
|
+
|
|
30
|
+
**Hooks health (weight 25):** Run each hook script. Exit 0 = healthy.
|
|
31
|
+
```sh
|
|
32
|
+
node .claude/hooks/toga/session-start.js
|
|
33
|
+
node .claude/hooks/toga/session-end.js
|
|
34
|
+
node .claude/hooks/toga/evaluate-session.js
|
|
35
|
+
node .claude/hooks/toga/post-edit-validate.js
|
|
36
|
+
```
|
|
37
|
+
All 9 present and healthy = 100. Deduct 15 points per broken hook.
|
|
38
|
+
|
|
39
|
+
**Knowledge base health (weight 25):** `node .claude/knowledge.js validate` → zero ERRORs = 100. Any ERROR = 50 max. Coverage: core architecture doc (+20), repo architecture doc (+20), standards doc (+20), feature doc (+20), INDEX.md current (+20).
|
|
40
|
+
|
|
41
|
+
**Rules completeness (weight 5):** Expected: coding-style, git-workflow, security, testing, app-framework, underscore-framework. All 6 = 100.
|
|
42
|
+
|
|
43
|
+
**ECC integration (weight 5):** Check `~/.claude/plugins/marketplaces/ecc/` exists. ECC detected AND TOGA agents reference ecc: subagents = 100. ECC not installed = 0 with recommendation.
|
|
44
|
+
|
|
45
|
+
## Step 3 — Compute score
|
|
46
|
+
|
|
47
|
+
```
|
|
48
|
+
Score = (skills×0.20) + (agents×0.20) + (hooks×0.25) + (knowledge×0.25) + (rules×0.05) + (ecc×0.05)
|
|
69
49
|
```
|
|
70
|
-
|
|
71
|
-
|
|
72
|
-
|
|
73
|
-
|
|
74
|
-
|
|
75
|
-
|
|
76
|
-
|
|
77
|
-
|
|
78
|
-
|
|
79
|
-
|
|
80
|
-
|
|
81
|
-
|
|
82
|
-
|
|
83
|
-
|
|
84
|
-
|
|
85
|
-
|
|
86
|
-
|
|
87
|
-
|
|
88
|
-
|
|
89
|
-
|
|
90
|
-
|
|
91
|
-
|
|
92
|
-
Security rules are always-loaded context — they prevent the most expensive bugs.
|
|
93
|
-
Add 5 rule files: common/security.md, common/coding-style.md, common/git-workflow.md,
|
|
94
|
-
php/app-framework.md, php/underscore-framework.md.
|
|
95
|
-
|
|
96
|
-
2. **Add PreToolUse hook for rm -rf / DROP TABLE** (+5 pts, prevents data loss)
|
|
97
|
-
Single hook entry in settings.json blocks the two most destructive accidental commands.
|
|
98
|
-
Run: add matcher `Bash` with command grep for `rm -rf` or `DROP TABLE`.
|
|
99
|
-
|
|
100
|
-
3. **Add skills/php-patterns/SKILL.md** (+4 pts)
|
|
101
|
-
The team's most frequent task is PHP feature work. A patterns skill accelerates every session.
|
|
50
|
+
|
|
51
|
+
## Step 4 — Produce prioritized fix list
|
|
52
|
+
|
|
53
|
+
```
|
|
54
|
+
## TOGA Harness Audit — <date>
|
|
55
|
+
Score: <N>/100
|
|
56
|
+
|
|
57
|
+
| Dimension | Score | Max | Status |
|
|
58
|
+
|---|---|---|---|
|
|
59
|
+
| Hooks health | 60 | 25 | 2 hooks broken |
|
|
60
|
+
| Knowledge | 40 | 25 | 1 ERROR in validate |
|
|
61
|
+
| Skills | 20 | 20 | all present |
|
|
62
|
+
| Agents | 20 | 20 | all present |
|
|
63
|
+
| Rules | 5 | 5 | all present |
|
|
64
|
+
| ECC | 0 | 5 | not detected |
|
|
65
|
+
|
|
66
|
+
**Overall: 72/100**
|
|
67
|
+
|
|
68
|
+
### Priority Fixes (by score impact)
|
|
69
|
+
1. [HOOKS -15pts] post-edit-validate.js exits with error → `npx toga-ai` to reinstall
|
|
70
|
+
2. [KNOWLEDGE -10pts] validate ERROR in worker2/architecture.md → fix frontmatter
|
|
71
|
+
3. [ECC +5pts] Install ECC for 200+ specialist agents → `claude plugin add ecc`
|
|
102
72
|
```
|
|
73
|
+
|
|
74
|
+
## Step 5 — Offer to auto-fix
|
|
75
|
+
|
|
76
|
+
For each fix that can be automated, offer to apply it immediately.
|
|
@@ -1,62 +1,70 @@
|
|
|
1
1
|
---
|
|
2
2
|
name: knowledge-writer
|
|
3
|
-
description:
|
|
3
|
+
description: TOGA knowledge base writer — creates and updates docs in .claude/knowledge/ with correct frontmatter, validates against CONVENTIONS.md, and runs the integrity check. Fires when documenting a feature, decision, or pattern. TOGA-specific specialist.
|
|
4
4
|
model: sonnet
|
|
5
|
-
tools: Read,
|
|
5
|
+
tools: Read, Write, Edit, Bash, Grep, Glob
|
|
6
6
|
---
|
|
7
7
|
|
|
8
|
-
# Knowledge Writer
|
|
8
|
+
# TOGA Knowledge Writer
|
|
9
9
|
|
|
10
|
-
|
|
10
|
+
Creates and updates knowledge base documents with perfect frontmatter. Never hand-edits — always validates after writing.
|
|
11
11
|
|
|
12
|
-
##
|
|
13
|
-
- "write a knowledge doc for <feature>"
|
|
14
|
-
- "document this architecture decision"
|
|
15
|
-
- "add this to the knowledge base"
|
|
16
|
-
- "create a feature doc for <repo>"
|
|
17
|
-
- "update knowledge for <repo>/<feature>"
|
|
12
|
+
## Step 1 — Read CONVENTIONS.md first
|
|
18
13
|
|
|
19
|
-
|
|
14
|
+
Always read `.claude/knowledge/CONVENTIONS.md`. It is the contract — frontmatter schema, document types, path rules, integrity requirements. Do not write without it.
|
|
20
15
|
|
|
21
|
-
|
|
16
|
+
## Step 2 — Determine doc type and location
|
|
22
17
|
|
|
23
|
-
|
|
24
|
-
|
|
25
|
-
|
|
26
|
-
|
|
27
|
-
|
|
28
|
-
|
|
29
|
-
|
|
18
|
+
| What to document | Type | Location |
|
|
19
|
+
|---|---|---|
|
|
20
|
+
| How a repo/framework works | `architecture` | `knowledge/<fw>/apps/<repo>/architecture.md` |
|
|
21
|
+
| A discrete feature | `feature` | `knowledge/<fw>/apps/<repo>/features/<slug>.md` |
|
|
22
|
+
| A client customization | `client-feature` | `knowledge/clients/<client>/features/<slug>.md` |
|
|
23
|
+
| A client business process | `workflow` | `knowledge/clients/<client>/workflows/<slug>.md` |
|
|
24
|
+
| A coding standard | `standard` | `knowledge/<fw>/standards/<slug>.md` |
|
|
30
25
|
|
|
31
|
-
|
|
32
|
-
- Feature/architecture for 1.0 app: `knowledge/1.0/apps/<repo>/features/<slug>.md` or `knowledge/1.0/apps/<repo>/architecture.md`
|
|
33
|
-
- Feature/architecture for 2.0 app: `knowledge/2.0/apps/<repo>/features/<slug>.md` or `knowledge/2.0/apps/<repo>/architecture.md`
|
|
34
|
-
- Standards: `knowledge/1.0/standards/<slug>.md` or `knowledge/2.0/standards/<slug>.md`
|
|
35
|
-
- Client docs: `knowledge/clients/<client>/<type>/<slug>.md`
|
|
36
|
-
- Never create files outside of `knowledge/` unless explicitly asked.
|
|
26
|
+
`architecture` and `standard` types are ELEVATED — warn the developer and confirm before writing.
|
|
37
27
|
|
|
38
|
-
|
|
28
|
+
## Step 3 — Gather required frontmatter
|
|
39
29
|
|
|
40
|
-
|
|
30
|
+
Check `.claude/knowledge/registry.json` for canonical `project` and `framework`. Required fields:
|
|
31
|
+
```yaml
|
|
32
|
+
title: <human-readable title>
|
|
33
|
+
framework: "<1.0 | 2.0>"
|
|
34
|
+
repo: <repo-name from registry>
|
|
35
|
+
project: <project-name from registry>
|
|
36
|
+
client: <client-slug | "shared">
|
|
37
|
+
type: <feature | architecture | standard | client-feature | workflow>
|
|
38
|
+
status: active
|
|
39
|
+
updated: <today's date YYYY-MM-DD>
|
|
40
|
+
owners: [<git-username>]
|
|
41
|
+
files:
|
|
42
|
+
- <actual source file this doc covers>
|
|
43
|
+
related: []
|
|
44
|
+
```
|
|
45
|
+
|
|
46
|
+
The `files:` list is mandatory for feature docs — ask the developer which files the feature touches.
|
|
41
47
|
|
|
42
|
-
|
|
48
|
+
## Step 4 — CREATE vs UPDATE
|
|
43
49
|
|
|
44
|
-
|
|
50
|
+
Search first: `node .claude/knowledge.js search --repo=<repo> --q=<keywords>`
|
|
51
|
+
- Match exists → UPDATE (show diff before writing)
|
|
52
|
+
- No match → CREATE (show full doc before writing)
|
|
45
53
|
|
|
46
|
-
|
|
54
|
+
## Step 5 — Write the doc
|
|
47
55
|
|
|
48
|
-
|
|
56
|
+
Structure: YAML frontmatter → one-paragraph overview → main content → code examples (correct framework prefix).
|
|
49
57
|
|
|
58
|
+
## Step 6 — Validate and re-index
|
|
59
|
+
|
|
60
|
+
Always run after writing:
|
|
61
|
+
```sh
|
|
62
|
+
node .claude/knowledge.js validate
|
|
63
|
+
node .claude/knowledge.js index
|
|
50
64
|
```
|
|
51
|
-
## Knowledge Document Written
|
|
52
65
|
|
|
53
|
-
|
|
54
|
-
**Type:** feature
|
|
55
|
-
**Status:** draft
|
|
66
|
+
If `validate` outputs any ERROR: fix immediately. Never report success with a broken knowledge base.
|
|
56
67
|
|
|
57
|
-
|
|
58
|
-
WARNING: Link to knowledge/2.0/apps/api2/features/order-api.md — file not yet created
|
|
59
|
-
WARNING: status is 'draft' — set to 'active' when reviewed
|
|
68
|
+
## Step 7 — Confirm
|
|
60
69
|
|
|
61
|
-
|
|
62
|
-
```
|
|
70
|
+
Report what was created/updated, whether it's ready for `/capture` to push, and flag any related docs that should be reviewed.
|
|
@@ -1,51 +1,70 @@
|
|
|
1
1
|
---
|
|
2
2
|
name: php-build-resolver
|
|
3
|
-
description:
|
|
4
|
-
model:
|
|
5
|
-
tools: Read, Grep, Glob, Bash
|
|
3
|
+
description: TOGA PHP build and runtime error resolver — uses ecc:build-error-resolver as the diagnostic engine, layered with TOGA framework context (App_ class resolution, _Worker dispatch errors, _Db connection issues, worker queue failures).
|
|
4
|
+
model: sonnet
|
|
5
|
+
tools: Read, Grep, Glob, Bash, Agent
|
|
6
6
|
---
|
|
7
7
|
|
|
8
|
-
# PHP Build Resolver
|
|
8
|
+
# TOGA PHP Build Resolver
|
|
9
9
|
|
|
10
|
-
|
|
10
|
+
Diagnoses and fixes PHP fatal errors, parse errors, class-not-found errors, and worker dispatch failures. Uses ECC's build resolver for standard PHP errors, with TOGA-specific error patterns added on top.
|
|
11
11
|
|
|
12
|
-
##
|
|
13
|
-
- "PHP fatal error"
|
|
14
|
-
- "parse error in <file>"
|
|
15
|
-
- "Call to undefined function/method"
|
|
16
|
-
- "Class not found"
|
|
17
|
-
- "fix the build error"
|
|
18
|
-
- "PHP is broken"
|
|
12
|
+
## Step 1 — Classify the error
|
|
19
13
|
|
|
20
|
-
|
|
14
|
+
| Error type | Resolver |
|
|
15
|
+
|---|---|
|
|
16
|
+
| PHP Parse/Syntax error | ECC build-error-resolver then TOGA overlay |
|
|
17
|
+
| Class not found / autoload failure | TOGA-specific (framework autoloading) |
|
|
18
|
+
| Worker dispatch / queue failure | TOGA-specific (_Queue patterns) |
|
|
19
|
+
| DB connection / query error | TOGA-specific (_Db / App_Db patterns) |
|
|
20
|
+
| Generic fatal error | ECC build-error-resolver then TOGA overlay |
|
|
21
21
|
|
|
22
|
-
|
|
23
|
-
- `Parse error: syntax error, unexpected token` → syntax fix in that file at that line.
|
|
24
|
-
- `Fatal error: Class '...' not found` → check `composer.json` autoload and `require`/`use` statements.
|
|
25
|
-
- `Fatal error: Call to undefined function` → check if function exists in the loaded files; check `composer.json` for missing package.
|
|
26
|
-
- `Fatal error: Allowed memory size exhausted` → identify the loop or query causing runaway allocation.
|
|
27
|
-
- `Fatal error: Maximum execution time exceeded` → identify unbounded loop or slow query.
|
|
22
|
+
## Step 2 — TOGA-specific error patterns (check first)
|
|
28
23
|
|
|
29
|
-
2.
|
|
24
|
+
**Framework 2.0 class not found:**
|
|
25
|
+
- `Class '_Worker_Foo' not found` → File must be at `src/Workers/Foo.php`, class named exactly `_Worker_Foo`, registered in worker registry (check `config/workers.php`)
|
|
26
|
+
- `Class '_Db' not found` → Autoloader not initialized — check bootstrap/init sequence
|
|
30
27
|
|
|
31
|
-
|
|
28
|
+
**Framework 1.0 class not found:**
|
|
29
|
+
- `Class 'App_Foo' not found` → File must be at `App/Foo.php` relative to app root; check `App_Registry` is loaded before use
|
|
32
30
|
|
|
33
|
-
|
|
31
|
+
**Worker dispatch failures:**
|
|
32
|
+
- `_Queue::dispatch()` fails silently → Check SQS credentials, verify queue name matches config
|
|
33
|
+
- Worker `run()` never called → Check worker is registered with exact class name
|
|
34
34
|
|
|
35
|
-
|
|
35
|
+
**DB errors:**
|
|
36
|
+
- `_Db: connection failed` → Check `DB_HOST`, `DB_USER`, `DB_PASS`, `DB_NAME` env vars
|
|
37
|
+
- `_Db::select() argument 2` type error → Condition must be array, not string
|
|
36
38
|
|
|
37
|
-
|
|
39
|
+
## Step 3 — Delegate standard PHP errors to ECC
|
|
38
40
|
|
|
39
|
-
|
|
41
|
+
For parse errors, type errors, namespace issues, spawn `ecc:build-error-resolver` with this context:
|
|
40
42
|
|
|
41
43
|
```
|
|
42
|
-
|
|
44
|
+
TOGA CONTEXT:
|
|
45
|
+
- PHP project using custom frameworks (App_ prefix = 1.0, _ prefix = 2.0)
|
|
46
|
+
- Class autoloading is custom — do not suggest composer dump-autoload
|
|
47
|
+
- DB layer is _Db or App_Db (not PDO directly, not Eloquent)
|
|
48
|
+
- Worker execution via _Queue::dispatch() (not direct instantiation)
|
|
49
|
+
Error output: [paste error here]
|
|
50
|
+
```
|
|
51
|
+
|
|
52
|
+
## Step 4 — Output
|
|
53
|
+
|
|
54
|
+
```
|
|
55
|
+
## Build Error Resolution — <error type>
|
|
56
|
+
Framework: <1.0 | 2.0>
|
|
57
|
+
|
|
58
|
+
**Root cause:** <one-sentence diagnosis>
|
|
59
|
+
**File:** <path>:<line>
|
|
43
60
|
|
|
44
|
-
**
|
|
61
|
+
**Current code:**
|
|
62
|
+
[broken code]
|
|
45
63
|
|
|
46
|
-
**
|
|
64
|
+
**Fixed code:**
|
|
65
|
+
[corrected code]
|
|
47
66
|
|
|
48
|
-
**
|
|
67
|
+
**Why this works:** <explanation in TOGA framework context>
|
|
49
68
|
|
|
50
|
-
**
|
|
69
|
+
**Verify with:** `php -l <filename>` then restart the worker/server
|
|
51
70
|
```
|