altalandi 0.4.0 → 0.6.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.
package/skill/SKILL.md CHANGED
@@ -1,117 +1,112 @@
1
- ---
2
- name: altalandi
3
- description: >-
4
- Turn English or stiff, translated or AI-written Icelandic into natural native
5
- Icelandic through the Altalandi API, with a meaning check and a diff of every
6
- change. Use when the user mentions Altalandi, or asks for text in proper,
7
- natural, correct or native Icelandic ("á góðri íslensku", "á réttri íslensku",
8
- "láttu þetta hljóma eðlilega á íslensku", "translate this into proper
9
- Icelandic"), including website copy, UI strings, emails and documents meant for
10
- Icelandic readers. Not for incidental Icelandic in conversation.
11
- ---
12
-
13
- # Altalandi: native Icelandic, with a meaning check
14
-
15
- Altalandi rewrites English or stiff/AI-translated Icelandic into Icelandic that
16
- reads as if a native wrote it. It checks that the meaning survived (numbers,
17
- dates, names, negation, obligations and a back-translation) and returns every
18
- change with a reason. Each call is paid from the user's Altalandi credit.
19
-
20
- ## 1. Make sure this computer is connected (once)
21
-
22
- Everything goes through the `altalandi` CLI, which finds the user's key by itself.
23
- If a call prints `Not logged in` (exit code 2), connect the computer:
24
-
25
- 1. Run `npx -y altalandi@latest login` **in the background** (it waits up to 10
26
- minutes for the user).
27
- 2. Read its output as soon as it appears. It prints a link
28
- (`https://altalandi.is/tengja?kodi=XXXX-XXXX`) and a code, and opens the
29
- browser. Show the user the link and the code, and tell them to sign in or
30
- create an account (every account gets 2,000 free words a day, and new accounts 500 kr. of trial credit) and click
31
- **Tengja**.
32
- 3. Wait for the command to finish. `✓ Tengt sem <username>` means done. Then
33
- continue with the task.
34
-
35
- Never ask the user to paste an API key into the chat. If they have one and
36
- prefer it, they can set `ALTALANDI_API_KEY` themselves.
37
-
38
- ## 2. Refine text
39
-
40
- Write the text to a UTF-8 temporary file and pass the file. Never put the text on
41
- the command line: quotes, `$`, backticks and Icelandic characters break shell
42
- quoting.
43
-
44
- ```bash
45
- npx -y altalandi@latest --json --file /tmp/altalandi-in.txt
46
- ```
47
-
48
- Options: `--domain general|marketing|data-analysis|childrens-fiction`,
49
- `--register formal|neutral|warm`. Pick `marketing` for website and product copy,
50
- `formal` for official or legal text, `warm` for friendly customer messages.
51
-
52
- One call per coherent text (a page section, an email, one UI string). For many
53
- strings, run them one by one or at most 4 at a time, and keep keys, placeholders
54
- (`{name}`, `%s`), HTML and code exactly as they were: send only the human text.
55
-
56
- ## 3. Read the result correctly
57
-
58
- | Exit code | Meaning | What to do |
59
- |---|---|---|
60
- | 0 | done and verified | use `output`, show the diffs |
61
- | 3 | meaning not verified: JSON still printed | read the table below; don't present it as verified |
62
- | 4 | out of credit (`402 insufficient_balance`) | stop; tell the user to add credit at https://altalandi.is/portal. Don't retry |
63
- | 2 | not logged in / no input | step 1 |
64
- | 1 | other error (network, 429 usage limit) | on 429 wait for the time given and retry once; otherwise report it |
65
-
66
- For Icelandic input, one of three things happened. Tell them apart before using `output`:
67
-
68
- | Outcome | How to recognise it |
69
- |---|---|
70
- | **Rewritten and verified** | `output` differs from the input, `meaningPreserved: true`, `rejectionReason` empty |
71
- | **Rewrite refused, original returned** | `rewriteAttempted: true` and `rejectionReason` set (`MEANING DRIFT`, `HARD INVARIANT LOST`, `UNVERIFIED`, `CANDIDATE VETO`) |
72
- | **Already fine** | `rewriteAttempted: false` |
73
-
74
- - `meaningPreserved` alone is not enough: a vetoed rewrite returns the original with
75
- `meaningPreserved: true`. Check `rewriteAttempted` and `rejectionReason`.
76
- - `meaningPreserved: null` means unverified, not safe. For English input the
77
- translation still comes back; say it is unverified.
78
- - When the original comes back, say so. Don't claim Altalandi improved it.
79
- - Always show what changed. Never silently replace the user's text. Apply changes
80
- to files only after showing them, unless the user asked for that directly.
81
-
82
- ## 4. Show the before and after
83
-
84
- After every call, show the user this, in the chat, before anything else:
85
-
86
- ```text
87
- Fyrir: <the text you sent, or its first lines if long>
88
- Eftir: <output>
89
- Breytingar:
90
- 1. − <before> → + <after> (<reason>)
91
- ...
92
- <the verdict: rewritten and verified / refused, original returned / no change needed / unverified>
93
- ```
94
-
95
- For a long text, show the first few changes and say how many there were in all.
96
- For a quick look in a terminal, `--diff` prints the same block (coloured) on stderr.
97
-
98
- **Reports (optional).** When the user wants a record, add `--report` (or they set
99
- `ALTALANDI_REPORT=1`): the CLI writes `./altalandi-reports/altalandi-<time>-<id>.md`
100
- with the input, the output, every change with its reason and layer, warnings and
101
- the verdict. Tell the user the path it prints (`Skýrsla: …`). Reports contain the
102
- text, so don't write them unless asked or the setting is on. The MCP tool takes
103
- `report: true` for the same thing.
104
- - `quality.nativenessScore` is a hint, not a verdict. It has been confidently wrong
105
- in both directions; never use it to override a refusal.
106
-
107
- ## 5. Good to know
108
-
109
- - Altalandi rewrites for natural Icelandic. If the user only wants spelling and
110
- grammar fixed and every other word left alone, tell them it may rephrase, and
111
- review the diffs with them.
112
- - `npx -y altalandi@latest whoami` shows the connected account and its credit.
113
- - Leave code, identifiers, legal quotations and anything that must stay verbatim
114
- out of the text you send.
115
- - Don't use `--fast` for text people will read: it skips the meaning check.
116
- - Text is processed and discarded, not stored or used for training.
117
- - Docs for integrating the API into an app: https://altalandi.is/agents.md
1
+ ---
2
+ name: altalandi
3
+ description: >-
4
+ Turn English or stiff, translated or AI-written Icelandic into natural native
5
+ Icelandic through the Altalandi API, with a meaning check and a diff of every
6
+ change. Use when the user mentions Altalandi, or asks for text in proper,
7
+ natural, correct or native Icelandic ("á góðri íslensku", "á réttri íslensku",
8
+ "láttu þetta hljóma eðlilega á íslensku", "translate this into proper
9
+ Icelandic"), including website copy, UI strings, emails and documents meant for
10
+ Icelandic readers. Not for incidental Icelandic in conversation.
11
+ ---
12
+
13
+ # Altalandi: native Icelandic, with a meaning check
14
+
15
+ Altalandi rewrites English or stiff Icelandic so it reads as if a native wrote
16
+ it, checks that the meaning held, and lists every change with its reason. Each
17
+ call is paid from the user's free daily units or their credit.
18
+
19
+ **Follow this procedure exactly, every time.** The user must always see the same
20
+ thing: the verdict, the text before and after, each change with its reason, what
21
+ the call cost and what is left. Do not improvise scripts, parse the JSON
22
+ yourself or summarise the result in your own words.
23
+
24
+ ## The procedure
25
+
26
+ 1. **Save the text** to a UTF-8 temporary file, e.g. `altalandi-in.txt` in the
27
+ system temp folder. Never put the text on the command line.
28
+ 2. **Run one command** and wait for it to finish:
29
+
30
+ ```bash
31
+ npx -y altalandi@latest --review --file <temp>/altalandi-in.txt --out <temp>/altalandi-out.txt
32
+ ```
33
+
34
+ Add `--domain marketing` for website and product copy, `--register formal`
35
+ for official text, `--register warm` for friendly customer messages.
36
+ 3. **Paste its stdout into your reply exactly as printed**, as the first thing in
37
+ your reply. It is Markdown: a verdict line, **Fyrir**, **Eftir**,
38
+ **Breytingar** (each change and its reason), **Kostnaður** (cost of this call,
39
+ balance and free units left) and the request id. Do not shorten, reorder,
40
+ translate or reword it.
41
+ 4. **Then act on the exit code:**
42
+
43
+ | Exit | What happened | What you do |
44
+ |---|---|---|
45
+ | 0 | rewritten and verified, or no change needed | the result is in `altalandi-out.txt`. If the user asked you to update a file, apply it from there; otherwise ask whether to apply it |
46
+ | 3 | the rewrite was refused or the meaning could not be verified | keep the user's original text. Say in one sentence that Altalandi left it unchanged and why (the block says why). Do not apply anything |
47
+ | 4 | out of credit | stop. The block shows the balance and the link to add credit. Do not retry |
48
+ | 2 | not logged in | connect (below), then run step 2 again |
49
+ | 1 | other error (network, too many calls) | the block says what happened. For "too many calls", wait a minute and retry once |
50
+
51
+ 5. **Stop there.** After the block and the action, at most one or two sentences
52
+ of your own.
53
+
54
+ ## Rules
55
+
56
+ - **Never hand-edit the Icelandic and present it as Altalandi's.** If you think
57
+ something should still change, say so separately under a heading such as
58
+ "Mín tillaga (ekki yfirfarin af Altalandi)", or ask before running it again.
59
+ - **One call per coherent text** (a page section, an email, one UI string). For
60
+ a few strings, run them one by one, at most 4 at a time, and paste each block.
61
+ Keep keys, placeholders (`{name}`, `%s`), HTML and code out of the text you send.
62
+ For a whole folder, i18n catalog or website, use the folder run below instead.
63
+ - **Product names and coined words** the meaning check cannot recognise can make
64
+ it refuse a rewrite (exit 3, "ekki tókst að staðfesta"). That is the safe
65
+ result: keep the original and tell the user.
66
+ - **A long text** is shortened in the block; the whole result is in
67
+ `altalandi-out.txt`. Use `--report` when the user wants a full record: it
68
+ writes `./altalandi-reports/altalandi-<time>-<id>.md`, and the block shows
69
+ its path. Reports contain the text, so write them only when asked.
70
+ - **Don't use `--fast`** for text people will read: it skips the meaning check.
71
+ - If the user only wants spelling fixed and every other word kept, tell them
72
+ Altalandi may rephrase, and go through the changes with them.
73
+ - Free use (the free daily units) is kept by Altalandi, with personal data
74
+ scrubbed, to improve the service; paid use is kept only with consent. Add
75
+ `--no-store` when the user asks that their text not be kept, or when it is
76
+ confidential.
77
+
78
+ ## A whole folder, i18n catalog or website
79
+
80
+ One command refines every `.md`, `.txt`, `.html` and `.json` file in a folder,
81
+ or a web page, or a site. It keeps code, URLs, placeholders, tags and JSON keys
82
+ byte for byte, never writes to the input, and writes only changes whose meaning
83
+ check passed.
84
+
85
+ 1. **Estimate first:** `npx -y altalandi@latest <folder or URL> --dry-run` (add
86
+ `--site` for a whole site). Show the user the estimate it prints: files,
87
+ passages, characters, units and the price if paid from credit.
88
+ 2. **Only when the user agrees,** run the same command with `--yes` in place of
89
+ `--dry-run`. The result goes to `<folder>-is` unless they name a place
90
+ (`--out <path>`).
91
+ 3. **Show the summary it prints and the report's path.** Exit 0: done. Exit 2:
92
+ done, but some passages kept their original text; the report lists them and
93
+ why. Exit 4: out of credit; the finished files are written, and the same
94
+ command finishes the rest after a top-up.
95
+
96
+ ## Connect this computer (once)
97
+
98
+ Only when a call exits with 2 (`Not logged in`):
99
+
100
+ 1. Run `npx -y altalandi@latest login` **in the background**. It waits up to 10
101
+ minutes.
102
+ 2. As soon as it prints a link (`https://altalandi.is/tengja?kodi=XXXX-XXXX`) and
103
+ a code, show both to the user. Tell them to sign in or create an account
104
+ (2,000 free units a day, and new accounts get 500 kr. of trial credit) and
105
+ click **Tengja**.
106
+ 3. When it prints `✓ Tengt sem <username>`, run step 2 of the procedure again.
107
+
108
+ Never ask the user for an API key, and do not tell them to set
109
+ `ALTALANDI_API_KEY`. `npx -y altalandi@latest whoami` shows the account, the
110
+ balance and the free units at any time.
111
+
112
+ Docs for building the API into an app: https://altalandi.is/agents.md
package/update.mjs CHANGED
@@ -166,7 +166,9 @@ function npmGlobalRoot() {
166
166
  });
167
167
  }
168
168
 
169
- async function ask(question, { input = process.stdin, output = process.stderr } = {}) {
169
+ /** A y/N question on stderr; only y/yes (or j/já) is a yes. Shared with the
170
+ * folder and site runs, which ask before sending anything. */
171
+ export async function ask(question, { input = process.stdin, output = process.stderr } = {}) {
170
172
  const rl = createInterface({ input, output });
171
173
  try {
172
174
  const answer = (await rl.question(`${question} [y/N] `)).trim().toLowerCase();