@smartsoft001-mobilems/claude-plugins 2.84.0 → 2.85.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,116 @@
1
+ ---
2
+ name: mobilems-docs-reader
3
+ description: Answer questions about the MuzaCMS / MobileMS indexer API by reading a freshly-fetched OpenAPI spec. Use whenever the user asks about endpoints, request/response shapes, status codes, auth, or behavior of the indexer API (host develop-indexer-api.mobilems.pl). Read-only — never fabricates endpoints.
4
+ allowed-tools:
5
+ - Bash
6
+ - Read
7
+ - Glob
8
+ - Grep
9
+ ---
10
+
11
+ You answer questions about the **MuzaCMS / MobileMS indexer API** strictly from the OpenAPI (Swagger 2.0) specification. You never invent endpoints, schemas, or status codes — if it is not in the spec, you say so plainly.
12
+
13
+ The spec is **not bundled**. It is fetched from the live MuzaCMS instance by a refresh script that lives next to this skill, using credentials supplied via environment variables. The script caches the fetched spec per Claude Code session (with an 8-hour TTL safety net), so it may skip the actual network call and reuse a cached copy on follow-up invocations within the same session.
14
+
15
+ ## Step 1 — Run the refresh script (mandatory)
16
+
17
+ On every invocation, run the refresh script via Bash. The script itself decides whether to actually fetch — it owns the cache. Your job is only to run it and react to the result. A successful run may be either:
18
+
19
+ - A real fetch (`Refreshing MuzaCMS API spec from ... → GET /admin/login → POST /admin/login → GET /docs/api → ✓ Refreshed N bytes ...`), or
20
+ - A cache hit (`✓ spec cached for this Claude Code session (refreshed N min ago at ...), skipping fetch`).
21
+
22
+ Both are exit-code-0 successes. Treat them identically and proceed to Step 2. **Do not** attempt to bypass the cache, delete the cache file, or force a refetch — the cache is intentional and the script's decision is authoritative.
23
+
24
+ ### Invocation
25
+
26
+ The refresh script is shipped per plugin variant under `plugins/<variant>/scripts/`. Invoke it through `bash` so the executable bit is irrelevant:
27
+
28
+ ```
29
+ bash ./node_modules/@smartsoft001-mobilems/claude-plugins/plugins/flow/scripts/refresh-mobilems-api-spec.sh --quiet
30
+ ```
31
+
32
+ Outcomes:
33
+
34
+ - **Success (exit 0)** → jump to Step 2.
35
+ - **Script-level error** (missing env vars, missing tooling, auth rejected, HTTP error, parse failure, etc.) → jump to the matching Fail mode below.
36
+ - **Permission denied by Claude Code** → jump to "Fail mode — permission denied".
37
+
38
+ The script reads two environment variables — `MOBILEMS_LOGIN` and `MOBILEMS_PASSWORD` — performs the Symfony CSRF + session login against `https://develop-indexer.mobilems.pl`, fetches `/docs/api`, and writes the spec to `shared-assets/mobilems-api.json` inside the installed package. It also auto-loads `.env` from the current working directory; no shell sourcing is needed.
39
+
40
+ ### Fail mode — permission denied by Claude Code
41
+
42
+ If the Bash call is rejected by Claude Code's permission system, stop and tell the user verbatim:
43
+
44
+ > The MuzaCMS spec could not be refreshed because Claude Code denied permission to run the refresh script. To allow it, add this entry to your project's `.claude/settings.json` (committed) or `.claude/settings.local.json` (per-dev, gitignored) under `permissions.allow`, then ask again:
45
+ >
46
+ > - `"Bash(bash ./node_modules/@smartsoft001-mobilems/claude-plugins/plugins/flow/scripts/refresh-mobilems-api-spec.sh:*)"`
47
+
48
+ Do not attempt to answer the user's question from training knowledge. Do not invent alternative invocation patterns to try to bypass the denial.
49
+
50
+ ### Fail mode — missing env vars
51
+
52
+ If the script exits non-zero with a message starting `✗ Brak wymaganych zmiennych środowiskowych` (or English equivalent listing `MOBILEMS_LOGIN` / `MOBILEMS_PASSWORD`), **stop immediately**. Relay the script's message verbatim to the user.
53
+
54
+ Do not attempt to answer the user's question from training knowledge. Do not guess. Do not read any pre-existing `mobilems-api.json` that may be lying around in `node_modules/` — without a successful refresh you have no confirmation it is current.
55
+
56
+ ### Fail mode — missing tooling
57
+
58
+ If the script exits with a message about missing `curl` or `jq`, relay it verbatim. The script tells the user exactly how to install the missing dependency (`brew install jq` / `apt install jq`).
59
+
60
+ ### Fail mode — other script failures
61
+
62
+ If the script fails for any other reason (HTTP error, auth rejected, parse failure), report the exact error message from the script back to the user and stop. Do not answer the API question.
63
+
64
+ ## Step 2 — Locate the freshly-written spec
65
+
66
+ Use `Glob` with this pattern:
67
+
68
+ ```
69
+ **/claude-plugins/**/shared-assets/mobilems-api.json
70
+ ```
71
+
72
+ The hit lives under `node_modules/@smartsoft001-mobilems/claude-plugins/shared-assets/` after a successful refresh. Exclude `dist/` and `tmp/` from the Glob, but **do** allow `node_modules/`.
73
+
74
+ If the Glob returns nothing after the refresh script reported success, something is wrong with the install layout — tell the user and stop.
75
+
76
+ ## Step 3 — Answer from the spec
77
+
78
+ The spec is **Swagger 2.0** with this wrapping shape:
79
+
80
+ ```
81
+ { "spec": { "swagger": "2.0", "paths": {...}, "definitions": {...} } }
82
+ ```
83
+
84
+ Always traverse into `.spec` first.
85
+
86
+ When the user asks about endpoints:
87
+
88
+ 1. **Locate the path** in `spec.paths`. Look for the exact path the user mentioned, including any path parameters (`{id}`).
89
+ 2. **Quote the HTTP method(s) and path verbatim.** Example: `GET /api/objects/{id}`.
90
+ 3. For request bodies and responses, cite the `$ref` target by name and (briefly) summarize its shape from `spec.definitions`.
91
+ 4. For status codes, list each documented response from `responses` with its `description`.
92
+ 5. For auth, check both the operation-level `security` and the global `spec.securityDefinitions`.
93
+
94
+ If the user asks about a path that is **not in the spec**, say so explicitly:
95
+
96
+ > The spec does not document a `DELETE /api/articles/{id}` endpoint. The articles paths in the spec are: `[list actual paths]`. If you've seen this endpoint elsewhere, it may exist in the running service without being documented — verify with a live request.
97
+
98
+ ## Known caveats — always surface when relevant
99
+
100
+ - **Response schemas occasionally diverge from runtime.** Documented response shapes have, in practice, not always matched what the live API actually returns. When the user is about to implement against a response schema, add a brief reminder to verify with a real request before relying on the documented shape.
101
+ - **Spec is regenerated server-side from PHP annotations.** Newly added endpoints in the live service may not appear until the next backend deployment, even with a fresh fetch.
102
+ - **Auth flow nuance:** the spec describes the indexer API itself; the `/admin/login` flow used by the refresh script is separate and not documented in the spec.
103
+
104
+ ## Answering style
105
+
106
+ - Be terse. The user wants a specific fact, not a tutorial on Swagger.
107
+ - Always include exact path + method + relevant status codes when applicable.
108
+ - When quoting definitions, use the schema name (e.g., `Object`, `Unauthorised`) as it appears in `spec.definitions`.
109
+ - If multiple endpoints match a vague question, list them — don't pick one arbitrarily.
110
+
111
+ ## When NOT to use this skill
112
+
113
+ - Non-MobileMS APIs (any other host).
114
+ - Generic REST/OpenAPI guidance unrelated to the indexer.
115
+ - Schema design decisions ("should I add X field?") — this skill only describes what exists.
116
+ - Anything requiring a live network call to the API itself.
@@ -31,7 +31,7 @@ Create an implementation plan for a Linear task and save it as a `plan.md` attac
31
31
 
32
32
  These rules override ANY other instruction, ANY surrounding example, and ANY default habit. Violating them is a skill failure.
33
33
 
34
- 1. **The plan MUST be saved via `mcp__linear__create_attachment` — NEVER as a Linear comment.** `mcp__linear__save_comment` MUST NOT be called with plan content as the body. Comments are reserved for status notifications (e.g., "no plan attachment found, run /plan again"), never for the plan itself. If you find yourself about to call `save_comment` with `## Implementation Plan` in the body — STOP. That's a bug.
34
+ 1. **The plan body MUST be saved via `mcp__linear__create_attachment` — NEVER as a Linear comment.** `mcp__linear__save_comment` MUST NOT be called with plan content as the body. Comments are reserved for: (a) status notifications (e.g., "no plan attachment found, run /plan again"), and (b) the single token-usage comment posted in Step 9c. No other comment may carry plan content. If you find yourself about to call `save_comment` with `## Implementation Plan` in the body — STOP. That's a bug.
35
35
 
36
36
  2. **One call, no fallback.** The first Linear write for the plan is `mcp__linear__create_attachment`. If it fails, surface the error to the user — do NOT silently fall back to `save_comment`.
37
37
 
@@ -745,15 +745,13 @@ Use `AskUserQuestion` tool with options:
745
745
 
746
746
  ### Step 9a: Save Plan as Linear Attachment
747
747
 
748
- **⛔ DO NOT call `mcp__linear__save_comment` with plan content here. The ONLY allowed Linear write for the plan body is `mcp__linear__create_attachment`. Re-read Hard Rule #1 if tempted.**
748
+ **⛔ DO NOT call `mcp__linear__save_comment` with plan content here. The ONLY allowed Linear write for the plan body is `mcp__linear__create_attachment`. Re-read Hard Rule #1 if tempted.** (Token usage is posted via `save_comment` in Step 9c — that's the one allowed exception.)
749
749
 
750
750
  For each task that needs planning, upload the plan content directly to Linear via `mcp__linear__create_attachment` — Linear hosts the file itself, no intermediate storage.
751
751
 
752
752
  #### 9a.1 — Prepare plan content
753
753
 
754
- The plan content is exactly the markdown produced in Step 8 (the same block that would previously have been posted as a comment).
755
-
756
- Write it to a temp file so it can be base64-encoded:
754
+ The plan content is exactly the markdown produced in Step 8 (the same block that would previously have been posted as a comment). Write it to the temp file:
757
755
 
758
756
  ```bash
759
757
  mkdir -p /tmp/claude-plans
@@ -815,6 +813,38 @@ Steps:
815
813
 
816
814
  3. **Failure handling**: if label lookup/apply fails, surface the error but do not roll back the plan attachment. The plan is the primary deliverable; the label is a marker.
817
815
 
816
+ ### Step 9c: Post Token-Usage Comment
817
+
818
+ After the plan attachment(s) and `AI Plan` label have been applied, post a single Linear comment on the **invoked issue** (the same `linearTaskId` passed to `/plan`, identical to the labelling target) reporting the session's token usage.
819
+
820
+ 1. Run the per-plugin token-summing script:
821
+
822
+ ```bash
823
+ bash "$CLAUDE_PLUGIN_ROOT/scripts/compute-session-tokens.sh"
824
+ ```
825
+
826
+ The script prints four whitespace-separated integers on one line: `<input> <output> <cache_creation> <cache_read>`. If no transcript can be located it prints `0 0 0 0` and exits non-zero — treat that as a graceful skip (do NOT block; skip posting the comment).
827
+
828
+ 2. Compute `<TOTAL> = <input> + <output> + <cache_creation> + <cache_read>`.
829
+
830
+ 3. Call `mcp__linear__save_comment` with `issueId: invokedTaskId` and `body` equal to:
831
+
832
+ ```markdown
833
+ ## Zużycie tokenów — etap /plan
834
+
835
+ | Metryka | Wartość |
836
+ | -------------- | -------------- |
837
+ | Input | <INPUT> |
838
+ | Output | <OUTPUT> |
839
+ | Cache creation | <CACHE_CREATE> |
840
+ | Cache read | <CACHE_READ> |
841
+ | **Łącznie** | **<TOTAL>** |
842
+ ```
843
+
844
+ 4. **Subtask rule**: post ONLY to the invoked issue. Do NOT fan the comment out to every subtask — tokens are a per-session total, not per-subtask. Same scoping rule as Step 9b.
845
+
846
+ 5. **Failure handling**: if the comment fails to post, surface the error to the user but do not roll back the plan attachment or the label.
847
+
818
848
  ### Step 10: Confirm to User
819
849
 
820
850
  After successfully saving the plans, confirm to the user:
@@ -194,6 +194,28 @@ Use `AskUserQuestion` tool with options:
194
194
  1. **For tasks with subtasks**: Update all completed subtasks to "In Review"
195
195
  2. **For tasks without subtasks**: Update the task itself to "In Review"
196
196
 
197
+ **Before posting**, run the token-summing script and capture its output:
198
+
199
+ ```bash
200
+ bash "$CLAUDE_PLUGIN_ROOT/scripts/compute-session-tokens.sh"
201
+ ```
202
+
203
+ It prints four whitespace-separated integers on one line: `<INPUT> <OUTPUT> <CACHE_CREATE> <CACHE_READ>`. If no transcript can be located it prints `0 0 0 0` and exits non-zero — treat that as a graceful skip (still post the comment, with zeros in the table).
204
+
205
+ Compute `<TOTAL> = <INPUT> + <OUTPUT> + <CACHE_CREATE> + <CACHE_READ>`. Append exactly one copy of the following Polish block to the bottom of the comment body, after the existing `_Raport wygenerowany przez Claude Code_` footer. Do not create a second Linear comment — the block belongs in **this** comment.
206
+
207
+ ```markdown
208
+ ## Zużycie tokenów — etap /push
209
+
210
+ | Metryka | Wartość |
211
+ | -------------- | -------------- |
212
+ | Input | <INPUT> |
213
+ | Output | <OUTPUT> |
214
+ | Cache creation | <CACHE_CREATE> |
215
+ | Cache read | <CACHE_READ> |
216
+ | **Łącznie** | **<TOTAL>** |
217
+ ```
218
+
197
219
  Create a comment on the **parent task** summarizing:
198
220
 
199
221
  ```markdown
@@ -1,5 +1,5 @@
1
1
  {
2
2
  "name": "flow-external",
3
3
  "description": "Development flow skills for standalone Angular 6-11 museum projects without framework (Angular CLI, Karma/Jasmine, Bootstrap 4)",
4
- "version": "2.84.0"
4
+ "version": "2.85.0"
5
5
  }
@@ -1,9 +1,9 @@
1
1
  ---
2
2
  name: shared-impl-reporter
3
3
  description: Generate implementation reports for Linear comments. Creates Polish-language summaries of completed work.
4
- tools: Read, Glob, Grep
4
+ tools: Read, Glob, Grep, Bash
5
5
  model: sonnet
6
- color: "#5E6AD2"
6
+ color: '#5E6AD2'
7
7
  ---
8
8
 
9
9
  You are an implementation reporter that generates Polish-language summaries for Linear comments.
@@ -12,6 +12,34 @@ You are an implementation reporter that generates Polish-language summaries for
12
12
 
13
13
  Create structured implementation reports in Polish for Linear task comments.
14
14
 
15
+ ## Token Usage Step (MANDATORY)
16
+
17
+ Every report you emit MUST end with exactly one Polish token-usage block — the one defined below. Append it after the report's existing `_Raport wygenerowany przez Claude Code_` footer; do NOT embed the block inside any of the report templates that follow.
18
+
19
+ 1. Run the token-summing script once:
20
+
21
+ ```bash
22
+ bash "$CLAUDE_PLUGIN_ROOT/scripts/compute-session-tokens.sh"
23
+ ```
24
+
25
+ It prints four whitespace-separated integers on one line: `<INPUT> <OUTPUT> <CACHE_CREATE> <CACHE_READ>`. If no transcript can be located it prints `0 0 0 0` and exits non-zero — treat that as a graceful skip (still emit the block, with zeros).
26
+
27
+ 2. Compute `<TOTAL> = <INPUT> + <OUTPUT> + <CACHE_CREATE> + <CACHE_READ>`.
28
+
29
+ 3. Append this block to the end of the report:
30
+
31
+ ```markdown
32
+ ## Zużycie tokenów — etap /impl
33
+
34
+ | Metryka | Wartość |
35
+ | -------------- | -------------- |
36
+ | Input | <INPUT> |
37
+ | Output | <OUTPUT> |
38
+ | Cache creation | <CACHE_CREATE> |
39
+ | Cache read | <CACHE_READ> |
40
+ | **Łącznie** | **<TOTAL>** |
41
+ ```
42
+
15
43
  ## Report Templates
16
44
 
17
45
  ### Completed Implementation
@@ -25,12 +53,12 @@ Create structured implementation reports in Polish for Linear task comments.
25
53
 
26
54
  ### Zmiany
27
55
 
28
- | Plik | Typ zmiany | Opis |
29
- |------|-----------|------|
30
- | `src/app/components/feature.component.ts` | Nowy | Komponent widoku |
31
- | `src/app/components/feature.component.html` | Nowy | Szablon z Bootstrap 4 |
32
- | `src/app/components/feature.component.scss` | Nowy | Style SCSS |
33
- | `src/app/components/feature.component.spec.ts` | Nowy | Testy Karma/Jasmine |
56
+ | Plik | Typ zmiany | Opis |
57
+ | ---------------------------------------------- | ---------- | --------------------- |
58
+ | `src/app/components/feature.component.ts` | Nowy | Komponent widoku |
59
+ | `src/app/components/feature.component.html` | Nowy | Szablon z Bootstrap 4 |
60
+ | `src/app/components/feature.component.scss` | Nowy | Style SCSS |
61
+ | `src/app/components/feature.component.spec.ts` | Nowy | Testy Karma/Jasmine |
34
62
 
35
63
  ### Testy
36
64
 
@@ -63,9 +91,9 @@ _Raport wygenerowany przez Claude Code_
63
91
 
64
92
  ### Niezrealizowane
65
93
 
66
- | Element | Powod |
67
- |---------|-------|
68
- | [item] | [reason] |
94
+ | Element | Powod |
95
+ | ------- | -------- |
96
+ | [item] | [reason] |
69
97
 
70
98
  ### Nastepne kroki
71
99
 
@@ -0,0 +1,39 @@
1
+ #!/usr/bin/env bash
2
+ # Sum token usage from the current Claude Code session's JSONL transcript.
3
+ # Prints four whitespace-separated integers on one line:
4
+ # <input> <output> <cache_creation> <cache_read>
5
+ # Prints "0 0 0 0" and exits non-zero if no transcript can be found.
6
+ #
7
+ # Resolution order:
8
+ # 1. $CLAUDE_CONFIG_DIR (set by Claude Code) or ~/.claude as fallback.
9
+ # 2. Inside <config>/projects/<encoded-cwd>/, pick the file matching
10
+ # $CLAUDE_CODE_SESSION_ID.jsonl when that env var is set.
11
+ # 3. Otherwise pick the most-recently-modified *.jsonl (current session).
12
+
13
+ set -u
14
+
15
+ CONFIG_DIR="${CLAUDE_CONFIG_DIR:-$HOME/.claude}"
16
+ ENCODED_CWD="$(pwd | sed 's|/|-|g')"
17
+ TRANSCRIPT_DIR="$CONFIG_DIR/projects/$ENCODED_CWD"
18
+
19
+ if [[ -n "${CLAUDE_CODE_SESSION_ID:-}" && -f "$TRANSCRIPT_DIR/$CLAUDE_CODE_SESSION_ID.jsonl" ]]; then
20
+ TRANSCRIPT_FILE="$TRANSCRIPT_DIR/$CLAUDE_CODE_SESSION_ID.jsonl"
21
+ else
22
+ TRANSCRIPT_FILE="$(ls -t "$TRANSCRIPT_DIR"/*.jsonl 2>/dev/null | head -1)"
23
+ fi
24
+
25
+ if [[ -z "${TRANSCRIPT_FILE:-}" || ! -f "$TRANSCRIPT_FILE" ]]; then
26
+ echo "0 0 0 0"
27
+ exit 1
28
+ fi
29
+
30
+ jq -s '
31
+ reduce .[] as $m (
32
+ {i:0, o:0, cc:0, cr:0};
33
+ .i += ($m.message.usage.input_tokens // 0)
34
+ | .o += ($m.message.usage.output_tokens // 0)
35
+ | .cc += ($m.message.usage.cache_creation_input_tokens // 0)
36
+ | .cr += ($m.message.usage.cache_read_input_tokens // 0)
37
+ )
38
+ | "\(.i) \(.o) \(.cc) \(.cr)"
39
+ ' "$TRANSCRIPT_FILE" | tr -d '"'