Skip to content

Commit c0bdf6b

Browse files
avivturcursoragent
andauthored
Update i18n-memsource skill for ocp-plugin-i18n-scripts 1.0.2 (#2422)
* Update i18n-memsource skill for ocp-plugin-i18n-scripts 1.0.2 - Document memsource CLI path and MEMSOURCE_TOKEN auth flow - Remove language alias symlink workarounds (fixed upstream) - Remove branch name / workaround (fixed upstream) - Update state with Sprint 2 upload from May 17 Resolves: None Signed-off-by: Aviv Turgeman <aturgema@redhat.com> Co-authored-by: Cursor <cursoragent@cursor.com> * Address review comments - Replace hardcoded memsource CLI path with portable discovery - Remove 2>/dev/null from auth login to surface errors - Add token validation after login Resolves: None Signed-off-by: Aviv Turgeman <aturgema@redhat.com> Co-authored-by: Cursor <cursoragent@cursor.com> --------- Signed-off-by: Aviv Turgeman <aturgema@redhat.com> Co-authored-by: Cursor <cursoragent@cursor.com>
1 parent 28fb7d9 commit c0bdf6b

2 files changed

Lines changed: 64 additions & 20 deletions

File tree

.cursor/skills/i18n-memsource/SKILL.md

Lines changed: 59 additions & 16 deletions
Original file line numberDiff line numberDiff line change
@@ -13,15 +13,52 @@ Read `.cursor/skills/i18n-memsource/state.json` for current sprint, version, and
1313

1414
## Prerequisites
1515

16-
Before running any Memsource commands, always authenticate first:
16+
### Memsource CLI
17+
18+
The `memsource` CLI is a Python package (`memsource-cli`) installed via pip3. It
19+
may not be on the default PATH. Locate and export it:
20+
21+
```bash
22+
MEMSOURCE_BIN=$(python3 -c "import shutil; print(shutil.which('memsource') or '')")
23+
if [ -z "$MEMSOURCE_BIN" ]; then
24+
MEMSOURCE_BIN=$(find "$HOME/Library/Python" -name memsource -type f 2>/dev/null | head -1)
25+
fi
26+
export PATH="$(dirname "$MEMSOURCE_BIN"):$PATH"
27+
```
28+
29+
### Authentication
30+
31+
Credentials are stored in `~/.memsourcerc` (exports `MEMSOURCE_USERNAME` and
32+
`MEMSOURCE_PASSWORD`). The CLI also accepts a token via the `MEMSOURCE_TOKEN`
33+
environment variable.
34+
35+
**Important:** The `memsource auth login` command returns a token but does not
36+
persist it for child processes (like those spawned by `npm run`). To make auth
37+
work inside npm scripts, you must capture the token and export it as
38+
`MEMSOURCE_TOKEN`:
1739

1840
```bash
1941
source ~/.memsourcerc
42+
export MEMSOURCE_TOKEN=$(memsource auth login \
43+
--user-name "$MEMSOURCE_USERNAME" \
44+
--password "$MEMSOURCE_PASSWORD" \
45+
-f json \
46+
| python3 -c "import sys,json; print(json.load(sys.stdin)['token'])")
47+
48+
if [ -z "$MEMSOURCE_TOKEN" ]; then
49+
echo "ERROR: Memsource authentication failed. Check ~/.memsourcerc credentials."
50+
return 1
51+
fi
2052
```
2153

22-
Run this in the Shell tool at the start of every action. Do not ask the user to do it.
54+
Run this **once** at the start of every action. All subsequent `memsource` and
55+
`npm run memsource-*` commands in the same shell session will inherit the token.
56+
Do not ask the user to authenticate manually.
57+
58+
### Config
2359

24-
Also read `i18n-scripts.config.json` from the project root for plugin config (languages, plugin name, etc).
60+
Read `i18n-scripts.config.json` from the project root for plugin config
61+
(languages, plugin name, language aliases, etc).
2562

2663
---
2764

@@ -58,11 +95,9 @@ Read these files:
5895

5996
### Step 3: Authenticate
6097

61-
```bash
62-
source ~/.memsourcerc
63-
```
98+
Run the full authentication sequence from Prerequisites (export PATH, source
99+
credentials, capture MEMSOURCE_TOKEN). Verify with:
64100

65-
Verify authentication works:
66101
```bash
67102
memsource auth whoami
68103
```
@@ -84,6 +119,9 @@ rm -rf po-files
84119
npm run export-pos
85120
```
86121

122+
The script resolves `languageAliases` from `i18n-scripts.config.json` automatically
123+
(e.g. `zh-cn` maps to locale directory `zh/`). Fixed in `ocp-plugin-i18n-scripts@1.0.2`.
124+
87125
### Step 6: Validate PO files
88126

89127
For each language directory in `po-files/`, check the PO file:
@@ -122,11 +160,17 @@ Ask for explicit approval before proceeding. Use the AskQuestion tool:
122160

123161
### Step 8: Upload to Memsource
124162

163+
Run the upload (MEMSOURCE_TOKEN must be exported from Step 3):
164+
125165
```bash
126166
npm run memsource-upload -- -v VERSION -s SPRINT
127167
```
128168

129-
Capture the output. The script prints the PROJECT_ID. Extract it from the `memsource project create` output line.
169+
The script handles branch names with `/` and resolves language aliases
170+
automatically (fixed in `ocp-plugin-i18n-scripts@1.0.2`).
171+
172+
Capture the output. The script prints the PROJECT_ID in JSON. Extract the `uid`
173+
field from the `memsource project create` output.
130174

131175
If the upload fails (auth error, network error), report the error and suggest fixes.
132176

@@ -185,9 +229,8 @@ Read `.cursor/skills/i18n-memsource/state.json` for `lastProjectId`. Show it to
185229

186230
### Step 2: Authenticate
187231

188-
```bash
189-
source ~/.memsourcerc
190-
```
232+
Run the full authentication sequence from Prerequisites (export PATH, source
233+
credentials, capture MEMSOURCE_TOKEN).
191234

192235
### Step 3: Check translation status
193236

@@ -249,10 +292,8 @@ Trigger: user says "translation status", "memsource status", "check translations
249292

250293
1. Read `.cursor/skills/i18n-memsource/state.json` for `lastProjectId`
251294
2. Ask user to confirm or provide a different PROJECT_ID
252-
3. Authenticate:
253-
```bash
254-
source ~/.memsourcerc
255-
```
295+
3. Authenticate using the full sequence from Prerequisites (export PATH, source
296+
credentials, capture MEMSOURCE_TOKEN).
256297
4. For each language in `i18n-scripts.config.json`, query:
257298
```bash
258299
memsource job list --project-id PROJECT_ID --target-lang LANG -f json -c uid,status,targetLang
@@ -274,7 +315,9 @@ Trigger: user says "translation status", "memsource status", "check translations
274315

275316
## Important Notes
276317

277-
- Always run `source ~/.memsourcerc` before any `memsource` CLI command. Do this silently.
318+
- **CLI path:** The `memsource` binary is installed via pip3 and may not be on PATH. Use the discovery snippet from Prerequisites to locate it.
319+
- **Auth token:** Use `MEMSOURCE_TOKEN` env var (captured from `memsource auth login`) so child processes (npm scripts) inherit auth. Do not rely on `memsource auth login` alone -- the token is not persisted to disk.
320+
- **Language aliases and branch names:** Both are handled automatically since `ocp-plugin-i18n-scripts@1.0.2`. No symlinks or branch switching needed.
278321
- The `npm run memsource-upload` and `npm run memsource-download` scripts use the `ocp-plugin-i18n-scripts` npm package CLI commands under the hood.
279322
- PO files are temporary artifacts in `po-files/` -- they're cleaned up after upload.
280323
- The `memsource-download` script auto-commits. The PR creation is a separate step.
Lines changed: 5 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -1,9 +1,10 @@
11
{
22
"version": "2.12",
3-
"sprint": 1,
4-
"lastProjectId": "28wosG55nMVH8VwafbqC13",
5-
"memsourceProjectUrl": "https://cloud.memsource.com/web/project2/show/28wosG55nMVH8VwafbqC13",
3+
"sprint": 2,
4+
"lastProjectId": "xNCkdYqlrFbPdd3B1ruWB5",
5+
"memsourceProjectUrl": "https://cloud.memsource.com/web/project2/show/xNCkdYqlrFbPdd3B1ruWB5",
66
"history": [
7-
{ "sprint": 1, "version": "2.12", "projectId": "28wosG55nMVH8VwafbqC13", "date": "2026-03-05" }
7+
{ "sprint": 1, "version": "2.12", "projectId": "28wosG55nMVH8VwafbqC13", "date": "2026-03-05" },
8+
{ "sprint": 2, "version": "2.12", "projectId": "xNCkdYqlrFbPdd3B1ruWB5", "date": "2026-05-17" }
89
]
910
}

0 commit comments

Comments
 (0)