eco-helpers 3.2.14 → 3.2.16
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.
- checksums.yaml +4 -4
- data/.ai-assistance/conventions/code-working-tree-protocol.md +176 -0
- data/.ai-assistance/scripts/token-logger.js +220 -0
- data/.ai-assistance/scripts/token-report.ts +158 -0
- data/.ai-assistance/scripts/token-session-start.js +66 -0
- data/.ai-assistance/skills/ep-ai-manager/SKILL.md +417 -0
- data/.ai-assistance/skills/ruby-scripting/SKILL.md +215 -0
- data/.ai-assistance/standards-version.json +10 -0
- data/.ai-assistance/token-budget.json +39 -0
- data/.claude/settings.json +103 -0
- data/.gitignore +2 -0
- data/CHANGELOG.md +17 -0
- data/CLAUDE.md +83 -0
- data/eco-helpers.gemspec +1 -1
- data/lib/eco/api/usecases/CLAUDE.md +78 -0
- data/lib/eco/api/usecases/default/pages.rb +30 -0
- data/lib/eco/api/usecases/graphql/CLAUDE.md +120 -0
- data/lib/eco/api/usecases/graphql/compat/ooze_redirect/dirty_array.rb +22 -0
- data/lib/eco/api/usecases/graphql/compat/ooze_redirect/field_patches.rb +241 -0
- data/lib/eco/api/usecases/graphql/compat/ooze_redirect/force_compat.rb +73 -0
- data/lib/eco/api/usecases/graphql/compat/ooze_redirect.rb +234 -0
- data/lib/eco/api/usecases/graphql/compat.rb +6 -0
- data/lib/eco/api/usecases/graphql/helpers/CLAUDE.md +79 -0
- data/lib/eco/api/usecases/graphql/samples/CLAUDE.md +76 -0
- data/lib/eco/api/usecases/graphql/samples/pages/CLAUDE.md +59 -0
- data/lib/eco/api/usecases/graphql/samples/pages/org_page/base.rb +41 -0
- data/lib/eco/api/usecases/graphql/samples/pages/org_page/dsl.rb +8 -0
- data/lib/eco/api/usecases/graphql/samples/pages/org_page.rb +7 -0
- data/lib/eco/api/usecases/graphql/samples/pages/page/base.rb +148 -0
- data/lib/eco/api/usecases/graphql/samples/pages/page/dsl.rb +38 -0
- data/lib/eco/api/usecases/graphql/samples/pages/page.rb +7 -0
- data/lib/eco/api/usecases/graphql/samples/pages.rb +7 -0
- data/lib/eco/api/usecases/graphql/samples.rb +1 -0
- data/lib/eco/api/usecases/graphql.rb +1 -0
- data/lib/eco/api/usecases/ooze_samples/ooze_base_case.rb +4 -0
- data/lib/eco/api/usecases/ooze_samples/register_update_case.rb +7 -1
- data/lib/eco/version.rb +1 -1
- metadata +31 -3
|
@@ -0,0 +1,417 @@
|
|
|
1
|
+
---
|
|
2
|
+
name: ep-ai-manager
|
|
3
|
+
version: 2.2.0
|
|
4
|
+
description: >
|
|
5
|
+
Manages alignment between this project's AI setup and the ecoPortal AI standards.
|
|
6
|
+
Phase 2: automated checklist checking against all standards, end-of-session KPI
|
|
7
|
+
and learning capture, migration plan application, token budget reporting.
|
|
8
|
+
Invoke at: session start, session end, or when you suspect drift.
|
|
9
|
+
triggers:
|
|
10
|
+
- check AI standards
|
|
11
|
+
- AI alignment
|
|
12
|
+
- standards update
|
|
13
|
+
- eP_AI_Manager
|
|
14
|
+
- is my AI setup current
|
|
15
|
+
- apply migration
|
|
16
|
+
- end of session
|
|
17
|
+
- session wrap-up
|
|
18
|
+
- capture learnings
|
|
19
|
+
- token report
|
|
20
|
+
- file standards request
|
|
21
|
+
- report gap
|
|
22
|
+
- standards gap
|
|
23
|
+
- report to ep-ai-standards
|
|
24
|
+
- request standard
|
|
25
|
+
standards_gitlab: "https://gitlab.ecoportal.co.nz/oscar/ep-ai-standards"
|
|
26
|
+
standards_version_file: ".ai-assistance/standards-version.json"
|
|
27
|
+
applicable_to:
|
|
28
|
+
- any
|
|
29
|
+
---
|
|
30
|
+
|
|
31
|
+
# ep-ai-manager
|
|
32
|
+
|
|
33
|
+
## Path resolution — always do this first
|
|
34
|
+
|
|
35
|
+
Before any file access, resolve the ep-ai-standards path:
|
|
36
|
+
|
|
37
|
+
1. Read `.ai-assistance/local/paths.json` in the current repo
|
|
38
|
+
2. Find the entry with key `ep-standards` → use its `local_path` value as `<EP_STANDARDS>`
|
|
39
|
+
3. If `paths.json` is missing or has no `ep-standards` entry:
|
|
40
|
+
```
|
|
41
|
+
[ep-ai-manager] Cannot locate ep-ai-standards on this machine.
|
|
42
|
+
Fix: bash <ep-ai-standards>/scripts/install.sh --target . --mode retrofit
|
|
43
|
+
```
|
|
44
|
+
Then stop — do not proceed with relative-path guesses.
|
|
45
|
+
|
|
46
|
+
All file paths in these instructions that reference `<EP_STANDARDS>` mean this resolved value.
|
|
47
|
+
|
|
48
|
+
---
|
|
49
|
+
|
|
50
|
+
## Role
|
|
51
|
+
|
|
52
|
+
You are the AI standards alignment manager for this project. You run automated
|
|
53
|
+
checks, capture session metrics, surface drift, and apply migration plans.
|
|
54
|
+
You do not make changes without explicit developer confirmation.
|
|
55
|
+
|
|
56
|
+
---
|
|
57
|
+
|
|
58
|
+
## On SESSION START — run automatically
|
|
59
|
+
|
|
60
|
+
### 1. Token budget status
|
|
61
|
+
|
|
62
|
+
Read `.ai-assistance/local/kpi/weekly-<YYYY-WNN>.json` (current ISO week).
|
|
63
|
+
Report in one line:
|
|
64
|
+
```
|
|
65
|
+
[token-budget] Week YYYY-WNN: N tokens used across M sessions this project | budget: X% of allocation
|
|
66
|
+
```
|
|
67
|
+
If `.ai-assistance/token-budget.json` has `total_tokens: null`, report actuals only.
|
|
68
|
+
If usage ≥ 80% of the project's priority allocation: warn in bold.
|
|
69
|
+
|
|
70
|
+
### 2. Overdue deferral check
|
|
71
|
+
|
|
72
|
+
Read `.ai-assistance/standards-version.json` → `deferred` array.
|
|
73
|
+
For each deferred item, compare `deferred-at` + allowed window (60 days medium,
|
|
74
|
+
14 days high, 0 days critical) to today.
|
|
75
|
+
Report any overdue deferrals as: `[OVERDUE] <standard> deferred since <date> — must action now`
|
|
76
|
+
|
|
77
|
+
### 3. Component version drift
|
|
78
|
+
|
|
79
|
+
Read `.ai-assistance/standards-version.json` → `installed-components` map.
|
|
80
|
+
Read `<EP_STANDARDS>/component-manifest.json` → `components` map.
|
|
81
|
+
|
|
82
|
+
For each skill key in `installed-components`:
|
|
83
|
+
- Look up the same key in the manifest
|
|
84
|
+
- If not found in manifest: skip (local skill, not tracked)
|
|
85
|
+
- Compare versions using semver. If local is `0.0.0` or `unknown`: treat as outdated (pre-versioning install)
|
|
86
|
+
- If outdated: check `migration_required_from` — does any semver range key cover the local version?
|
|
87
|
+
- No match → classify **auto-apply** (file copy only)
|
|
88
|
+
- Match found → classify **migration-required** (note the migration folder ID)
|
|
89
|
+
|
|
90
|
+
Report only when outdated components exist:
|
|
91
|
+
```
|
|
92
|
+
[standards-sync] N component(s) outdated — say "sync standards" to auto-apply:
|
|
93
|
+
|
|
94
|
+
skills/ep-ai-manager 2.0.0 → 2.1.0 auto-apply (CHANGELOG 1.4.0)
|
|
95
|
+
skills/code-specs 0.0.0 → 1.0.0 auto-apply (pre-versioning install)
|
|
96
|
+
skills/ruby-scripting 0.0.0 → 0.1.0 migration run "apply migration 0002-slug"
|
|
97
|
+
```
|
|
98
|
+
|
|
99
|
+
If all components current:
|
|
100
|
+
`[standards] All skills up to date — ep-ai-standards v{manifest.standards_release}`
|
|
101
|
+
|
|
102
|
+
If `installed-components` key is missing from `standards-version.json` entirely:
|
|
103
|
+
`[standards] installed-components not yet recorded — run "sync standards" to initialise`
|
|
104
|
+
|
|
105
|
+
---
|
|
106
|
+
|
|
107
|
+
## On SESSION END / when explicitly invoked for wrap-up
|
|
108
|
+
|
|
109
|
+
### 4. KPI capture prompt
|
|
110
|
+
|
|
111
|
+
Ask the developer:
|
|
112
|
+
```
|
|
113
|
+
Session wrap-up — quick capture (skip any with 's'):
|
|
114
|
+
|
|
115
|
+
1. Main task category today?
|
|
116
|
+
coding / bug_fixing / bug_prevention / documentation / communication /
|
|
117
|
+
post_release / troubleshooting / integration_delivery / skills_development
|
|
118
|
+
|
|
119
|
+
2. Rough minutes saved by AI? (e.g. 60, or 's' to skip)
|
|
120
|
+
|
|
121
|
+
3. Any skills developed? (e.g. ai-platform-architecture, s to skip)
|
|
122
|
+
|
|
123
|
+
4. Any learnings worth capturing for the EPAI knowledge base?
|
|
124
|
+
Type a brief description, or 's' to skip.
|
|
125
|
+
```
|
|
126
|
+
|
|
127
|
+
On answers received:
|
|
128
|
+
- Create/update `.ai-assistance/local/kpi/sessions-<YYYY-WNN>.jsonl` with a record
|
|
129
|
+
matching the schema in `<EP_STANDARDS>/kpi/schema.json`
|
|
130
|
+
- If a learning was described: create a draft at
|
|
131
|
+
`.ai-assistance/local/epai-drafts/EPAI-<date>-<slug>.md` using the format from
|
|
132
|
+
`<EP_STANDARDS>/standards/agents/corpus-source-taxonomy.md` → "Page template"
|
|
133
|
+
|
|
134
|
+
### 5. Policy compliance reminder (if working on AI-related files)
|
|
135
|
+
|
|
136
|
+
If the session involved changes to `agents/`, `iam/`, `lambdas/`, `config/`, or
|
|
137
|
+
`.ai-assistance/skills/`:
|
|
138
|
+
```
|
|
139
|
+
[policy-check] Run before pushing: python3 scripts/policy-check.py --changed-only
|
|
140
|
+
```
|
|
141
|
+
|
|
142
|
+
### 6. LEARNING capture
|
|
143
|
+
|
|
144
|
+
After the KPI prompt, ask:
|
|
145
|
+
```
|
|
146
|
+
Any learnings worth capturing? (one per line, or 's' to skip)
|
|
147
|
+
Format: [type] description
|
|
148
|
+
Types: gotcha | pattern | gap | lesson | correction
|
|
149
|
+
|
|
150
|
+
Example: gotcha bash here-docs with unicode fail on Windows cp1252
|
|
151
|
+
```
|
|
152
|
+
|
|
153
|
+
For each learning provided:
|
|
154
|
+
- Write a `<!-- LEARNING: type -->` block to the current worklog entry (append to the
|
|
155
|
+
current session's Done section)
|
|
156
|
+
- Create a draft file at `.ai-assistance/local/epai-drafts/EPAI-<YYYY-MM-DD>-<slug>.md`
|
|
157
|
+
using this template:
|
|
158
|
+
```markdown
|
|
159
|
+
---
|
|
160
|
+
type: <type>
|
|
161
|
+
project_origin: <project slug>
|
|
162
|
+
contributor_email: <developer email from KPI record>
|
|
163
|
+
date: <today>
|
|
164
|
+
status: draft
|
|
165
|
+
---
|
|
166
|
+
|
|
167
|
+
# <one-line title>
|
|
168
|
+
|
|
169
|
+
<full description — self-contained, no assumed context>
|
|
170
|
+
|
|
171
|
+
## Where it applies
|
|
172
|
+
<which agents/projects/patterns this affects>
|
|
173
|
+
```
|
|
174
|
+
|
|
175
|
+
Phase 1 note: once the EPAI Confluence space is created, this step will also create a
|
|
176
|
+
Confluence page draft via Rovo MCP. Until then, drafts accumulate in local/epai-drafts/.
|
|
177
|
+
|
|
178
|
+
---
|
|
179
|
+
|
|
180
|
+
## On-demand: FULL ALIGNMENT CHECK
|
|
181
|
+
|
|
182
|
+
Run when explicitly invoked with "check alignment" or "check AI standards".
|
|
183
|
+
|
|
184
|
+
For each standard in `<EP_STANDARDS>/standards/`:
|
|
185
|
+
|
|
186
|
+
### standards/agents/skill-schema.md
|
|
187
|
+
- [ ] Every directory in `agents/` has either `SKILL.md` or `system_prompt_file` in `agent.yaml`
|
|
188
|
+
- [ ] SKILL.md frontmatter contains `name:`, `description:`, `triggers:`
|
|
189
|
+
- [ ] `name:` follows `<team>-<agent>` format (grep: `^name: [a-z]+-[a-z]`)
|
|
190
|
+
- [ ] Customer-facing SKILL.md has `<!-- BEGIN privacy_directive` marker
|
|
191
|
+
|
|
192
|
+
### standards/agents/agent-manifest.md
|
|
193
|
+
- [ ] Every `agents/` subdirectory that has a SKILL.md also has an `agent.yaml`
|
|
194
|
+
- [ ] Every `agent.yaml` has: `name`, `team`, `role`, `status`, `owner`
|
|
195
|
+
- [ ] Specialist agents have `corpus_prefix:`
|
|
196
|
+
- [ ] Customer-facing agents have `automatic_learning_guard: true`
|
|
197
|
+
- [ ] Operator agents have `escalation:` and `access_restriction:` blocks
|
|
198
|
+
- [ ] No agent has `status: published` without being in the activation checklist
|
|
199
|
+
|
|
200
|
+
### standards/agents/role-taxonomy.md
|
|
201
|
+
- [ ] No operator agent appears in any orchestrator's `triggers:` or skill list
|
|
202
|
+
- [ ] Operator agents have `escalation:` → `required: true`
|
|
203
|
+
|
|
204
|
+
### standards/workflows/session-handoff.md
|
|
205
|
+
- [ ] `docs/worklog.md` exists
|
|
206
|
+
- [ ] `CLAUDE.md` contains the string "worklog"
|
|
207
|
+
- [ ] Worklog has an entry within the last 5 working sessions (check for dated `## ` headings)
|
|
208
|
+
|
|
209
|
+
### standards/security/pii-handling.md
|
|
210
|
+
- [ ] No `real_value` field in any DynamoDB table definition or Lambda code
|
|
211
|
+
- [ ] Customer-facing SKILL.md has complete `BEGIN/END privacy_directive` block
|
|
212
|
+
- [ ] PII scrubber exists if corpus pipeline is used (check lambdas/)
|
|
213
|
+
|
|
214
|
+
### standards/tooling/token-budget-management.md
|
|
215
|
+
- [ ] `.ai-assistance/token-budget.json` exists
|
|
216
|
+
- [ ] `project.name` and `project.priority` are filled in (not `{{PLACEHOLDER}}`)
|
|
217
|
+
- [ ] `.claude/settings.json` has `Stop` and `SessionStart` hooks with `token-logger.js`
|
|
218
|
+
- [ ] `.ai-assistance/local/` is in `.gitignore`
|
|
219
|
+
|
|
220
|
+
### standards/tooling/cross-platform-ai-guidelines.md
|
|
221
|
+
- [ ] No bash scripts in the repo exceed ~200 lines (check with `wc -l`)
|
|
222
|
+
- [ ] No hardcoded `api.anthropic.com` (use AWS endpoint)
|
|
223
|
+
|
|
224
|
+
### standards/kpi/schema.md
|
|
225
|
+
- [ ] `kpi/records/` or `.ai-assistance/local/` is in `.gitignore`
|
|
226
|
+
- [ ] At least one KPI session record exists (if AI has been used in the project)
|
|
227
|
+
|
|
228
|
+
**For each check:**
|
|
229
|
+
- PASS: note briefly
|
|
230
|
+
- FAIL: give the specific file, what's wrong, what to do
|
|
231
|
+
- WARN: note for awareness
|
|
232
|
+
|
|
233
|
+
After all checks: `[alignment] N pass, N warn, N fail — project at ep-ai-standards vX.Y.Z`
|
|
234
|
+
|
|
235
|
+
---
|
|
236
|
+
|
|
237
|
+
## On-demand: SYNC STANDARDS
|
|
238
|
+
|
|
239
|
+
When the developer says "sync standards", "sync skills", or "apply auto updates":
|
|
240
|
+
|
|
241
|
+
1. Re-read `installed-components` from `standards-version.json` and `component-manifest.json`.
|
|
242
|
+
2. Build the list of **auto-apply** outdated components (those with no `migration_required_from` match).
|
|
243
|
+
3. For each auto-apply component:
|
|
244
|
+
- Copy `<EP_STANDARDS>/{source}` to `.ai-assistance/skills/{skill-name}/SKILL.md`
|
|
245
|
+
- Update `installed-components["skills/{skill-name}"]` to the new version in `standards-version.json`
|
|
246
|
+
- Report: `[sync] Updated skills/ep-ai-manager 2.0.0 → 2.1.0`
|
|
247
|
+
4. If `installed-components` was missing entirely, scan `.ai-assistance/skills/*/SKILL.md` now,
|
|
248
|
+
read each version, and write the full `installed-components` map before syncing.
|
|
249
|
+
5. Update `ep-ai-standards-version` to `manifest.standards_release` and `applied-at` to today.
|
|
250
|
+
6. Final summary: `[sync] N skill(s) updated. Run "check AI standards" to verify alignment.`
|
|
251
|
+
7. If migration-required items remain: list them.
|
|
252
|
+
`[sync] N item(s) need migration — run "apply migration <id>" for each.`
|
|
253
|
+
|
|
254
|
+
Never auto-apply a migration-required component without explicit "apply migration <id>" confirmation.
|
|
255
|
+
|
|
256
|
+
---
|
|
257
|
+
|
|
258
|
+
## On-demand: APPLY MIGRATION PLAN
|
|
259
|
+
|
|
260
|
+
When the developer says "apply migration" or "update standards":
|
|
261
|
+
|
|
262
|
+
1. Read `.ai-assistance/standards-version.json` → current version
|
|
263
|
+
2. Check if `<EP_STANDARDS>/migration/v{current}-to-v{target}/` exists
|
|
264
|
+
3. Read `MIGRATION.md` — show the developer what will change and effort estimate
|
|
265
|
+
4. **Ask for explicit confirmation before proceeding**
|
|
266
|
+
5. If automated steps exist: `bash <EP_STANDARDS>/migration/.../automated/apply.sh --target .`
|
|
267
|
+
6. Run verify.sh — show results
|
|
268
|
+
7. Update `.ai-assistance/standards-version.json` → new version + `applied-at: today`
|
|
269
|
+
|
|
270
|
+
Never run apply.sh without showing the developer its contents first.
|
|
271
|
+
|
|
272
|
+
---
|
|
273
|
+
|
|
274
|
+
## On-demand: FILE STANDARDS REQUEST
|
|
275
|
+
|
|
276
|
+
When the developer says "file a standards request", "report a gap", "standards gap",
|
|
277
|
+
"report to ep-ai-standards", "request standard", or similar:
|
|
278
|
+
|
|
279
|
+
1. Resolve `<EP_STANDARDS>` path (see Path resolution above).
|
|
280
|
+
|
|
281
|
+
2. Prompt the developer (one message, all fields):
|
|
282
|
+
```
|
|
283
|
+
Standards request — quick capture (press Enter to skip optional fields):
|
|
284
|
+
|
|
285
|
+
1. Type? gap / inconsistency / improvement / error
|
|
286
|
+
2. Area? skill / standard / template / convention / script
|
|
287
|
+
3. Affected? e.g. skills-library/ep-ai-manager/SKILL.md
|
|
288
|
+
4. Title? brief description (e.g. "ep-ai-manager trigger wording unclear")
|
|
289
|
+
5. Description? what's wrong — be specific
|
|
290
|
+
6. Suggested fix? (optional)
|
|
291
|
+
```
|
|
292
|
+
|
|
293
|
+
3. Build the request file:
|
|
294
|
+
- **repo-slug**: current repo's folder name, lowercased, spaces→hyphens
|
|
295
|
+
(e.g. `ecoportal-api-graphql` or `eco-extension`)
|
|
296
|
+
- **id**: 7 lowercase hex characters derived from the title (e.g. `a3f2b1c`)
|
|
297
|
+
- **slug**: title lowercased, spaces→hyphens, non-alphanumeric stripped, max 40 chars
|
|
298
|
+
- **filename**: `{repo-slug}-{id}-{slug}.md`
|
|
299
|
+
|
|
300
|
+
4. Write to `<EP_STANDARDS>/.ai-assistance/local/standards-requests/{filename}`:
|
|
301
|
+
|
|
302
|
+
```markdown
|
|
303
|
+
# STANDARDS REQUEST: {title}
|
|
304
|
+
|
|
305
|
+
STATUS: PENDING
|
|
306
|
+
FILED: {ISO 8601 timestamp}
|
|
307
|
+
FROM_REPO: {repo-slug}
|
|
308
|
+
TYPE: {type}
|
|
309
|
+
AREA: {area}
|
|
310
|
+
AFFECTED: {affected}
|
|
311
|
+
|
|
312
|
+
## Description
|
|
313
|
+
{description}
|
|
314
|
+
|
|
315
|
+
## Context
|
|
316
|
+
Filed during a {repo-slug} AI session.
|
|
317
|
+
|
|
318
|
+
## Suggested fix
|
|
319
|
+
{suggested fix, or "None provided."}
|
|
320
|
+
```
|
|
321
|
+
|
|
322
|
+
5. Confirm to the developer:
|
|
323
|
+
```
|
|
324
|
+
[standards-request] Filed: {filename}
|
|
325
|
+
Will be reviewed in the next ep-ai-standards session.
|
|
326
|
+
```
|
|
327
|
+
|
|
328
|
+
---
|
|
329
|
+
|
|
330
|
+
## On-demand: STANDARDS VERSION UPDATE
|
|
331
|
+
|
|
332
|
+
When the developer says "update standards version" after manually applying changes:
|
|
333
|
+
|
|
334
|
+
1. Ask: "Which version are you updating to? (e.g. 1.1.0)"
|
|
335
|
+
2. Read `<EP_STANDARDS>/CHANGELOG.md` to confirm the version exists
|
|
336
|
+
3. Update `.ai-assistance/standards-version.json` → `ep-ai-standards-version` and `applied-at`
|
|
337
|
+
4. Confirm: "Updated to v{version}. Run full alignment check to verify?"
|
|
338
|
+
|
|
339
|
+
---
|
|
340
|
+
|
|
341
|
+
## Deferral recording
|
|
342
|
+
|
|
343
|
+
When a developer chooses to defer a finding:
|
|
344
|
+
|
|
345
|
+
```json
|
|
346
|
+
// Add to .ai-assistance/standards-version.json → deferred array:
|
|
347
|
+
{
|
|
348
|
+
"standard": "tooling/claude-code",
|
|
349
|
+
"from-version": "1.0.0",
|
|
350
|
+
"severity": "medium",
|
|
351
|
+
"deferred-by": "oscar@ecoportal.co.nz",
|
|
352
|
+
"deferred-at": "2026-06-10",
|
|
353
|
+
"reason": "Bridge refactor planned for Q3",
|
|
354
|
+
"review-by": "2026-09-10"
|
|
355
|
+
}
|
|
356
|
+
```
|
|
357
|
+
|
|
358
|
+
Calculate `review-by` automatically: medium = +60 days, high = +14 days.
|
|
359
|
+
Critical deferrals are not recorded — escalate to Oscar immediately.
|
|
360
|
+
|
|
361
|
+
---
|
|
362
|
+
|
|
363
|
+
## Severity handling
|
|
364
|
+
|
|
365
|
+
| Severity | Deferral | At session start |
|
|
366
|
+
|---|---|---|
|
|
367
|
+
| `low` | Unlimited | Mention only if asked |
|
|
368
|
+
| `medium` | 60 days | Warn after 30 days |
|
|
369
|
+
| `high` | 14 days | Warn every session after 7 days |
|
|
370
|
+
| `critical` | None | Block — escalate to Oscar |
|
|
371
|
+
|
|
372
|
+
---
|
|
373
|
+
|
|
374
|
+
## EPAI draft format
|
|
375
|
+
|
|
376
|
+
When capturing a learning, write to `.ai-assistance/local/epai-drafts/EPAI-<date>-<slug>.md`:
|
|
377
|
+
|
|
378
|
+
```markdown
|
|
379
|
+
# [<TYPE>] <Brief title>
|
|
380
|
+
|
|
381
|
+
<!-- PAGE PROPERTIES -->
|
|
382
|
+
contributor_email: <developer email>
|
|
383
|
+
project_origin: <project name>
|
|
384
|
+
consent_timestamp: <today>
|
|
385
|
+
usage_scope: agent-corpus-eligible
|
|
386
|
+
evidence_link: <link to worklog session, commit, or MR>
|
|
387
|
+
last_verified: <today>
|
|
388
|
+
source_type: primary
|
|
389
|
+
<!-- END PAGE PROPERTIES -->
|
|
390
|
+
|
|
391
|
+
**Labels:** `epai-type:<type>` `epai-area:<area>` `epai-status:needs-review`
|
|
392
|
+
|
|
393
|
+
## Observed Behaviour
|
|
394
|
+
<What actually happened — factual, specific>
|
|
395
|
+
|
|
396
|
+
## Why it matters
|
|
397
|
+
<Impact if you don't know this>
|
|
398
|
+
|
|
399
|
+
## Fix / Pattern
|
|
400
|
+
<What to do>
|
|
401
|
+
|
|
402
|
+
---
|
|
403
|
+
*Curator: verify evidence link before promoting to Consolidated*
|
|
404
|
+
```
|
|
405
|
+
|
|
406
|
+
Valid types: `gotcha`, `pattern`, `anti-pattern`, `gap`, `lesson`, `correction`,
|
|
407
|
+
`environment-quirk`, `prompt-trigger`.
|
|
408
|
+
|
|
409
|
+
---
|
|
410
|
+
|
|
411
|
+
## What this skill does NOT do
|
|
412
|
+
|
|
413
|
+
- Does not make file changes without explicit developer confirmation
|
|
414
|
+
- Does not apply migration scripts without showing contents first
|
|
415
|
+
- Does not defer `critical` findings
|
|
416
|
+
- Does not mark a check as PASS without verifying the actual file
|
|
417
|
+
- Does not create EPAI drafts without the developer providing the learning
|
|
@@ -0,0 +1,215 @@
|
|
|
1
|
+
---
|
|
2
|
+
name: ruby-scripting
|
|
3
|
+
version: 0.1.0
|
|
4
|
+
description: >
|
|
5
|
+
AI coding assistant guidelines for internal Ruby scripts that consume ecoPortal's
|
|
6
|
+
Ruby gem stack (ecoportal-api-graphql, ecoportal-api, eco-helpers). Covers gem
|
|
7
|
+
authentication, GraphQL query patterns, mutation patterns, error handling, and
|
|
8
|
+
cross-platform script conventions (Windows/WSL/macOS/Linux).
|
|
9
|
+
triggers:
|
|
10
|
+
- ruby script
|
|
11
|
+
- internal script
|
|
12
|
+
- ecoportal-api
|
|
13
|
+
- graphql query
|
|
14
|
+
- ruby-scripting
|
|
15
|
+
- write a ruby script
|
|
16
|
+
applicable_to:
|
|
17
|
+
- ruby
|
|
18
|
+
---
|
|
19
|
+
|
|
20
|
+
# SKILL: Ruby Scripting (ecoPortal Internal)
|
|
21
|
+
|
|
22
|
+
**Purpose:** Guidelines for AI-assisted authoring of internal Ruby scripts that use the ecoPortal gem stack. These scripts run internally — no customer access; Ruby is not a customer-facing language at ecoPortal.
|
|
23
|
+
|
|
24
|
+
---
|
|
25
|
+
|
|
26
|
+
## When to Use
|
|
27
|
+
|
|
28
|
+
- Writing a new script that queries or mutates ecoPortal data via the GraphQL API
|
|
29
|
+
- Debugging or extending an existing script in `ruby_scripts/` or similar
|
|
30
|
+
- Any task involving `ecoportal-api-graphql`, `ecoportal-api`, or `eco-helpers`
|
|
31
|
+
|
|
32
|
+
---
|
|
33
|
+
|
|
34
|
+
## Gem Stack
|
|
35
|
+
|
|
36
|
+
```
|
|
37
|
+
ecoportal-api-graphql ← GraphQL client layer (mutations, queries, models)
|
|
38
|
+
↑
|
|
39
|
+
ecoportal-api / ecoportal-api-v2 ← REST API + base model infrastructure
|
|
40
|
+
↑
|
|
41
|
+
eco-helpers ← Utility helpers (pagination, bulk ops, etc.)
|
|
42
|
+
```
|
|
43
|
+
|
|
44
|
+
**Before writing any API call**, check:
|
|
45
|
+
1. Does `eco-helpers` already have a helper for this operation? (It often does.)
|
|
46
|
+
2. Does `ecoportal-api-graphql` already have a model/mutation class?
|
|
47
|
+
3. Read `.ai-assistance/code/dependencies.md` in `ecoportal-api-graphql` for local paths.
|
|
48
|
+
|
|
49
|
+
---
|
|
50
|
+
|
|
51
|
+
## Authentication
|
|
52
|
+
|
|
53
|
+
```ruby
|
|
54
|
+
require 'ecoportal/api'
|
|
55
|
+
|
|
56
|
+
api = Ecoportal::API::V2.new(
|
|
57
|
+
key: ENV.fetch('EP_API_KEY'),
|
|
58
|
+
host: ENV.fetch('EP_API_HOST', 'live.ecoportal.com')
|
|
59
|
+
)
|
|
60
|
+
```
|
|
61
|
+
|
|
62
|
+
Always use `ENV.fetch` (not `ENV[]`) — raises on missing key rather than silently using nil.
|
|
63
|
+
Store credentials in `.env` (gitignored). Never hardcode.
|
|
64
|
+
|
|
65
|
+
---
|
|
66
|
+
|
|
67
|
+
## GraphQL Query Pattern
|
|
68
|
+
|
|
69
|
+
```ruby
|
|
70
|
+
# Read models via GraphQL
|
|
71
|
+
result = api.graphql.query do |q|
|
|
72
|
+
q.current_organization do |org|
|
|
73
|
+
org.name
|
|
74
|
+
org.users(first: 50) do |conn|
|
|
75
|
+
conn.nodes do |user|
|
|
76
|
+
user.id
|
|
77
|
+
user.email
|
|
78
|
+
end
|
|
79
|
+
end
|
|
80
|
+
end
|
|
81
|
+
end
|
|
82
|
+
|
|
83
|
+
# Check for errors before using data
|
|
84
|
+
raise result.errors.map(&:message).join(', ') if result.errors.any?
|
|
85
|
+
users = result.data.current_organization.users.nodes
|
|
86
|
+
```
|
|
87
|
+
|
|
88
|
+
**Pagination:** use `eco-helpers` pagination helpers for large result sets rather than
|
|
89
|
+
writing manual cursor loops.
|
|
90
|
+
|
|
91
|
+
---
|
|
92
|
+
|
|
93
|
+
## Mutation Pattern
|
|
94
|
+
|
|
95
|
+
```ruby
|
|
96
|
+
# Mutations require patchVer for types that use optimistic locking
|
|
97
|
+
# Always fetch before mutate for those types
|
|
98
|
+
current = api.graphql.query { ... }.data.some_item
|
|
99
|
+
result = api.graphql.mutate do |m|
|
|
100
|
+
m.update_item(input: {
|
|
101
|
+
id: current.id,
|
|
102
|
+
patch_ver: current.patch_ver, # required for patchVer types
|
|
103
|
+
name: "New Name"
|
|
104
|
+
}) do |payload|
|
|
105
|
+
payload.item { |i| i.id; i.name }
|
|
106
|
+
payload.errors { |e| e.message; e.path }
|
|
107
|
+
end
|
|
108
|
+
end
|
|
109
|
+
|
|
110
|
+
raise result.errors.map(&:message).join(', ') if result.errors.any?
|
|
111
|
+
raise result.data.update_item.errors.map(&:message).join(', ') \
|
|
112
|
+
if result.data.update_item.errors.any?
|
|
113
|
+
```
|
|
114
|
+
|
|
115
|
+
**patchVer rule:** any schema type with a `patchVer` field requires reading current value
|
|
116
|
+
before any update. See `graphql-schema-analysis` skill for detection.
|
|
117
|
+
|
|
118
|
+
---
|
|
119
|
+
|
|
120
|
+
## Cross-Platform Script Conventions
|
|
121
|
+
|
|
122
|
+
These scripts run on developer machines (Windows/WSL, macOS, Linux CI):
|
|
123
|
+
|
|
124
|
+
```ruby
|
|
125
|
+
# ✅ Safe: Ruby's File/Pathname handles separators cross-platform
|
|
126
|
+
require 'pathname'
|
|
127
|
+
base = Pathname.new(File.dirname(__FILE__))
|
|
128
|
+
data_file = base / 'data' / 'input.json'
|
|
129
|
+
|
|
130
|
+
# ❌ Unsafe: hardcoded separators, or shell assumptions
|
|
131
|
+
data_file = "#{__dir__}\\data\\input.json" # breaks on Linux
|
|
132
|
+
`cat #{data_file}` # assumes Unix shell
|
|
133
|
+
```
|
|
134
|
+
|
|
135
|
+
**Environment detection:**
|
|
136
|
+
```ruby
|
|
137
|
+
WINDOWS = Gem.win_platform?
|
|
138
|
+
# Use for platform-specific paths only — prefer Pathname for everything else
|
|
139
|
+
```
|
|
140
|
+
|
|
141
|
+
**Output:** use `$stdout.puts` not `print` for script output. Use `$stderr.puts` for
|
|
142
|
+
errors. This allows the script to be piped and combined cleanly.
|
|
143
|
+
|
|
144
|
+
**Exit codes:** always `exit 0` on success, `exit 1` on error. Never let an unhandled
|
|
145
|
+
exception be the exit mechanism in production scripts.
|
|
146
|
+
|
|
147
|
+
---
|
|
148
|
+
|
|
149
|
+
## Error Handling
|
|
150
|
+
|
|
151
|
+
```ruby
|
|
152
|
+
begin
|
|
153
|
+
# API calls here
|
|
154
|
+
rescue Ecoportal::API::Errors::ApiError => e
|
|
155
|
+
$stderr.puts "API error: #{e.message} (status: #{e.status})"
|
|
156
|
+
exit 1
|
|
157
|
+
rescue => e
|
|
158
|
+
$stderr.puts "Unexpected error: #{e.class}: #{e.message}"
|
|
159
|
+
$stderr.puts e.backtrace.first(5).join("\n")
|
|
160
|
+
exit 1
|
|
161
|
+
end
|
|
162
|
+
```
|
|
163
|
+
|
|
164
|
+
---
|
|
165
|
+
|
|
166
|
+
## Script Structure Template
|
|
167
|
+
|
|
168
|
+
```ruby
|
|
169
|
+
#!/usr/bin/env ruby
|
|
170
|
+
# frozen_string_literal: true
|
|
171
|
+
#
|
|
172
|
+
# Script: <name>.rb
|
|
173
|
+
# Purpose: <one sentence>
|
|
174
|
+
# Usage: ruby <name>.rb [options]
|
|
175
|
+
# Dependencies: ecoportal-api-graphql, dotenv
|
|
176
|
+
#
|
|
177
|
+
# Run from repo root: bundle exec ruby scripts/<name>.rb
|
|
178
|
+
|
|
179
|
+
require 'bundler/setup'
|
|
180
|
+
require 'dotenv/load'
|
|
181
|
+
require 'ecoportal/api'
|
|
182
|
+
# ... other requires
|
|
183
|
+
|
|
184
|
+
api = Ecoportal::API::V2.new(
|
|
185
|
+
key: ENV.fetch('EP_API_KEY'),
|
|
186
|
+
host: ENV.fetch('EP_API_HOST', 'live.ecoportal.com')
|
|
187
|
+
)
|
|
188
|
+
|
|
189
|
+
begin
|
|
190
|
+
# main logic here
|
|
191
|
+
rescue => e
|
|
192
|
+
$stderr.puts "Error: #{e.class}: #{e.message}"
|
|
193
|
+
exit 1
|
|
194
|
+
end
|
|
195
|
+
```
|
|
196
|
+
|
|
197
|
+
---
|
|
198
|
+
|
|
199
|
+
## What NOT to do
|
|
200
|
+
|
|
201
|
+
- Don't write raw HTTP calls to the EcoPortal API — use the gem stack
|
|
202
|
+
- Don't paginate manually — use `eco-helpers` pagination
|
|
203
|
+
- Don't hardcode API keys, hosts, or org identifiers
|
|
204
|
+
- Don't use `pp` or `binding.pry` in committed scripts — use structured logging
|
|
205
|
+
- Don't assume a Unix shell — use Ruby cross-platform file handling
|
|
206
|
+
|
|
207
|
+
---
|
|
208
|
+
|
|
209
|
+
## v0.1.0 limitations
|
|
210
|
+
|
|
211
|
+
This skill covers general patterns. For area-specific details (specific GraphQL models,
|
|
212
|
+
available mutation inputs, schema patterns), consult:
|
|
213
|
+
- `ecoportal-api-graphql/.ai-assistance/code/` for code specs
|
|
214
|
+
- `ecoportal-api-graphql/.ai-assistance/skills/graphql-schema-analysis/SKILL.md`
|
|
215
|
+
- Live schema introspection (see graphql-schema-analysis skill)
|
|
@@ -0,0 +1,39 @@
|
|
|
1
|
+
{
|
|
2
|
+
"schema_version": "1.0",
|
|
3
|
+
"project": {
|
|
4
|
+
"name": "eco-helpers",
|
|
5
|
+
"priority": "low",
|
|
6
|
+
"developer": "oscar@ecoportal.co.nz"
|
|
7
|
+
},
|
|
8
|
+
"weekly_quota": {
|
|
9
|
+
"total_tokens": null,
|
|
10
|
+
"target_utilization_pct": 75,
|
|
11
|
+
"reset_day": "monday",
|
|
12
|
+
"note": "total_tokens: null means track actuals without a hard cap. Set to e.g. 1000000 to enforce a budget."
|
|
13
|
+
},
|
|
14
|
+
"project_allocation": {
|
|
15
|
+
"priority_weights": {
|
|
16
|
+
"high": 50,
|
|
17
|
+
"medium": 30,
|
|
18
|
+
"low": 20
|
|
19
|
+
},
|
|
20
|
+
"note": "A 'high' priority project gets ~50% of the weekly budget; 'medium' gets ~30%; 'low' gets ~20%. These are soft targets — the system warns, not blocks."
|
|
21
|
+
},
|
|
22
|
+
"session_logging": {
|
|
23
|
+
"enabled": true,
|
|
24
|
+
"log_dir": ".ai-assistance/local/kpi",
|
|
25
|
+
"warn_at_pct": 80,
|
|
26
|
+
"prompt_category_at_stop": true
|
|
27
|
+
},
|
|
28
|
+
"task_categories": [
|
|
29
|
+
"coding",
|
|
30
|
+
"bug_fixing",
|
|
31
|
+
"bug_prevention",
|
|
32
|
+
"documentation",
|
|
33
|
+
"communication",
|
|
34
|
+
"post_release",
|
|
35
|
+
"troubleshooting",
|
|
36
|
+
"integration_delivery",
|
|
37
|
+
"skills_development"
|
|
38
|
+
]
|
|
39
|
+
}
|