@h1r-ai/croche 0.5.0 → 0.5.1

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.
Files changed (35) hide show
  1. package/README.md +21 -13
  2. package/dist/core-bindgen.js +18 -18
  3. package/dist/core-runtime.d.ts +1 -1
  4. package/dist/core-runtime.js +1 -1
  5. package/dist/core-wasm-bytes.d.ts +3 -3
  6. package/dist/core-wasm-bytes.js +3 -3
  7. package/dist/project-types.d.ts +2 -2
  8. package/dist/types.d.ts +5 -7
  9. package/docs/CODING-AGENT.md +11 -7
  10. package/docs/SKILL.md +307 -265
  11. package/docs/skills/croche/agents/openai.yaml +4 -0
  12. package/docs/skills/croche/references/agents.md +78 -0
  13. package/docs/skills/croche/references/first-turn.md +74 -0
  14. package/docs/skills/croche/references/tools.md +43 -0
  15. package/docs/skills/croche-cli/SKILL.md +158 -0
  16. package/docs/skills/croche-cli/agents/openai.yaml +4 -0
  17. package/docs/skills/croche-cli/references/powershell.md +47 -0
  18. package/docs/skills/croche-config/SKILL.md +152 -0
  19. package/docs/skills/croche-config/agents/openai.yaml +4 -0
  20. package/docs/skills/croche-config/references/models.md +12 -0
  21. package/docs/skills/croche-platforms/SKILL.md +55 -0
  22. package/docs/skills/croche-platforms/agents/openai.yaml +4 -0
  23. package/docs/skills/croche-platforms/references/android.md +185 -0
  24. package/docs/skills/croche-platforms/references/ios.md +165 -0
  25. package/docs/skills/croche-platforms/references/react-native.md +50 -0
  26. package/docs/skills/croche-platforms/references/web-backend.md +58 -0
  27. package/docs/skills/croche-troubleshoot/SKILL.md +72 -0
  28. package/docs/skills/croche-troubleshoot/agents/openai.yaml +4 -0
  29. package/docs/skills/croche-troubleshoot/references/recovery.md +31 -0
  30. package/package.json +1 -1
  31. package/src/core-bindgen.ts +18 -18
  32. package/src/core-runtime.ts +1 -1
  33. package/src/core-wasm-bytes.ts +3 -3
  34. package/src/project-types.ts +2 -2
  35. package/src/types.ts +5 -7
@@ -0,0 +1,78 @@
1
+ # Messages, agents and memory
2
+
3
+ Use only for the relevant SDK task. The examples use an already-open `croche` project.
4
+
5
+ ## Messages and UI
6
+
7
+ `const agent = await croche.agent()` opens the default agent. `agent.request(input)` waits
8
+ for the result and its final messages. `agent.send(input)` returns a receipt, not a reply.
9
+ For streaming, subscribe once and render messages by their IDs:
10
+
11
+ ```ts
12
+ const subscription = agent.subscribe({ onEvent(event) {
13
+ // App UI functions, not Croche APIs. Delta text is provisional; end text is authoritative.
14
+ if (event.type === 'message.delta') appendText(event.id, event.text);
15
+ if (event.type === 'message.end') finishMessage(event.id, event.text, event.status);
16
+ } });
17
+ await agent.send({ id: messageId, text: userText });
18
+ // On UI teardown: subscription.close(); on app-session teardown: await croche.close();
19
+ ```
20
+
21
+ A subscription replays the latest stored messages (`initialMessages`, default 50) before its
22
+ `snapshot`, without another model request; `history({ limit, before? })` asks that open
23
+ subscription for an older `page`. One subscription per agent: a second `subscribe` on the same
24
+ agent replaces the first, which receives a final `{ type: 'replaced' }` event. Do not
25
+ render a send receipt as an assistant message. Check final statuses and preserve input IDs
26
+ across delivery retries. A new ID is a new attempt and can produce another app action.
27
+
28
+ ## Multiple conversations
29
+
30
+ Declare named agents in `config.agents`, for example
31
+ `{ helper: { instructions: 'Help with this app.' } }`, then `await croche.agent('helper')`.
32
+ Use `croche.agent('helper', { instance: 'save-2' })` for a named conversation or
33
+ `{ fresh: true }` for a new one. Keep instances tied to the current app user.
34
+ `agent.setTools(names)` filters available tools; `agent.setTools(null)` removes the filter.
35
+ `agent.setMode(name)` selects a configured mode; `agent.setMode(null)` leaves it.
36
+
37
+ ## App-visible memories
38
+
39
+ The app can read or remove AI-written memories, not set keyed facts:
40
+
41
+ - `await agent.memory.list()` is the current list; use memory IDs, not invented keys.
42
+ - `await agent.memory.export()` exports memory data for a user-requested export.
43
+ - `await agent.memory.delete(id)` removes an item and its earlier versions.
44
+ - `await agent.memory.clear()` removes all memory items.
45
+ - `await agent.memory.enabled(false)` disables memory; `true` enables it again.
46
+ - `agent.memory.onChanged(callback)` signals that the UI should re-read `list()`; it is a hint,
47
+ not a complete event log. Awaiting the read works for both TS and RN.
48
+
49
+ Deleting memories does not erase conversation history. Use `agent.clearHistory()` only for
50
+ an explicitly requested conversation reset. Never promise that clearing one surface deletes
51
+ all user data. Exported conversations and memories are private user data; do not paste them
52
+ into a bug report. For `memory_store_too_old`, use `croche-troubleshoot` before touching storage.
53
+
54
+ ## Optional app state and images
55
+
56
+ Most turns contain only a user message. `context` is optional app state, kept apart from
57
+ that message. It costs tokens each time it is included and is useful when the request needs
58
+ app state: a command or button acting on app data, or after that state changed. An image
59
+ can share the input when needed. Without context, an input carries only the message;
60
+ earlier states stay as sent until older turns are folded. Tools check current app data,
61
+ not an old snapshot. This optional photo path combines state and inputs in **one** request.
62
+ The input shape is either top-level `text`/`images` or an `inputs` stack, not both:
63
+
64
+ ```ts
65
+ const result = await agent.request({
66
+ id: crypto.randomUUID(),
67
+ context: { todos: currentTodos },
68
+ inputs: [{ kind: 'user', text: 'Add these items.',
69
+ images: [{ data: photoBase64, mime: 'image/jpeg',
70
+ alt: 'Photo of a handwritten shopping list', resolution: 'high' }] }],
71
+ });
72
+ ```
73
+
74
+ Use base64 with its MIME type (PNG, JPEG, WebP or GIF); at most four images per message,
75
+ 3 MB each and 6 MB total. With `request`, set resolution on each image, not in request
76
+ options. Choose an image-capable model; otherwise the request fails with
77
+ `images_unsupported`. A useful `alt` describes the image when its bytes are no longer in
78
+ the active conversation. See the [Models page](https://docs.croche.ai/models.md).
@@ -0,0 +1,74 @@
1
+ # Node: one real reply
2
+
3
+ Use for a Node script or the first local check before adding UI. Node.js 22+ on macOS/Linux;
4
+ Windows verification pending. SDK 0.5.1 is published on npm; a real first turn on the user’s
5
+ platform still needs verification. With installation permission, install the published SDK:
6
+
7
+ ```sh
8
+ npm install @h1r-ai/croche
9
+ ```
10
+
11
+ The user completes only signup, one account key and user-run `croche login`. You obtain the
12
+ public project key from CLI project creation and use the `debug-keys create` command to write the SDK debug key
13
+ into `.env` without exposing it. TODO verify that CLI workflow against the released version.
14
+ Insert the **public** project key into the placeholder below; do not open or print `.env`.
15
+ Do not use the account `CROCHE_ACCOUNT_KEY` as an SDK option. Ignore `croche-state/` as private
16
+ app data and verify `.env` is ignored; preserve existing ignore rules.
17
+
18
+ Save as `first-turn.mjs`:
19
+
20
+ ```js
21
+ import { randomUUID } from 'node:crypto';
22
+ import { Croche } from '@h1r-ai/croche';
23
+ import { FileStorage } from '@h1r-ai/croche/node';
24
+
25
+ if (!process.env.CROCHE_DEBUG_KEY) throw new Error('Load the private CLI-created env file.');
26
+ const croche = await Croche.open({
27
+ projectKey: '<public project key returned by CLI>',
28
+ debugKey: process.env.CROCHE_DEBUG_KEY,
29
+ user: 'local-demo-user', // replace with your authenticated app user's stable ID
30
+ storage: new FileStorage('./croche-state'),
31
+ config: { model: 'deepseek/deepseek-v4.1-flash', instructions: 'You are a friendly guide. Reply in one or two sentences.' },
32
+ });
33
+ try {
34
+ const agent = await croche.agent();
35
+ const result = await agent.request({ id: randomUUID(), text: 'Hello! What can you do?' });
36
+ const reply = result.messages.at(-1);
37
+ if (result.status !== 'answered' || reply?.status !== 'completed' || !reply.text?.trim()) {
38
+ console.error('First turn did not complete:', result.status, reply?.error?.code ?? 'no_reply');
39
+ process.exitCode = 1;
40
+ } else {
41
+ console.log(reply.text);
42
+ }
43
+ } finally {
44
+ await croche.close();
45
+ }
46
+ ```
47
+
48
+ **Node does not load `.env` automatically.** Plain `node first-turn.mjs` leaves `debugKey`
49
+ unset unless the process already has that variable. A successful CLI login does not populate it.
50
+ Check syntax first, then use the real env-file loader for one authorized live turn:
51
+
52
+ ```sh
53
+ node --check first-turn.mjs
54
+ node --env-file=.env first-turn.mjs
55
+ ```
56
+
57
+ `--env-file` exists in Node 20.6+; Croche still requires Node 22+. The project's existing dotenv
58
+ setup is an alternative only if it loads the chosen file before `Croche.open`; do not install
59
+ another loader without permission. For another entry point, use `node --env-file=.env app.mjs`.
60
+ Use the selected file path if it differs. The missing-key guard fails locally before opening;
61
+ check presence, never the value. Node loads the file directly without printing it. Do not source
62
+ it or paste it into chat. A completed, nonempty reply is the check; neither a successful open
63
+ nor a queued receipt proves the model answered. Report error codes without dumping options,
64
+ environment variables, or whole error objects that may contain private data.
65
+
66
+ For a persistence check, reopen with the same options and subscribe instead of sending another
67
+ message. The subscription replays the latest stored messages (`initialMessages`, default 50)
68
+ before its `snapshot` event; confirm the earlier reply's `message.end` is among them, then close
69
+ the subscription and the project. `history()` is not this check: it returns nothing, needs an
70
+ open subscription, and only delivers an older `page` event to it. In an app, substitute authenticated user IDs, give each
71
+ user isolated durable storage, and reuse the open project rather than opening per message.
72
+
73
+ If a Studio draft already exists, it may replace this sample's config after a sync and next
74
+ open. Read `croche-config` before trying to debug an apparent instruction mismatch.
@@ -0,0 +1,43 @@
1
+ # App actions
2
+
3
+ Use when implementing a tool, not for a text-only first turn. Put serializable declarations
4
+ in `config.tools` and executable handlers in `handlers`, indexed by the tool's name.
5
+
6
+ ```ts
7
+ import type { ToolDeclaration, ToolHandler } from '@h1r-ai/croche';
8
+
9
+ const inventory: ToolDeclaration = {
10
+ name: 'inventory',
11
+ summary: 'The player inventory.',
12
+ commands: [{
13
+ key: 'inventory_list', name: 'list', reads: true,
14
+ summary: 'List the items this player owns when asked about their inventory.',
15
+ }],
16
+ };
17
+ // app.inventoryFor is your app function, not a Croche API.
18
+ const inventoryHandler: ToolHandler = async ({ key }, context) => {
19
+ if (key !== 'inventory_list') return { status: 'rejected', reason: 'Unknown action.' };
20
+ return { items: await app.inventoryFor(context.user) };
21
+ };
22
+ // In Croche.open: config: { instructions, tools: [inventory] },
23
+ // handlers: { inventory: inventoryHandler }
24
+ ```
25
+
26
+ - Use a globally unique command `key` (for example `inventory_list`). Group related commands;
27
+ flags support `type`, `enum`, `required`, `minimum`, `maximum`, and `list`.
28
+ - Mark every read-only command `reads: true`. Its summary should explain when to use it.
29
+ - For mutations, say **when the user must request the action** in the command summary or
30
+ `toolGuide`. Enforce authorization, allowed values and current app state in the handler;
31
+ the description is not an access-control boundary.
32
+ - For a purchase, deletion or other action needing consent, use the app's confirmation UI.
33
+ Return `{ status: 'waiting_for_approval' }` while waiting; only execute after real approval.
34
+ Croche does not supply a `confirm` declaration field. Do not invent one.
35
+ - Return structured expected rejections (reason and next step). A thrown handler error ends
36
+ the turn; do not report a successful change when nothing changed.
37
+ - Keep authoritative balances/inventory in the app. Pass bounded current app state as input
38
+ `context`, and deduplicate business operations in app code; a new model request is not a
39
+ guarantee that an earlier effect did not happen.
40
+ - Studio drafts must include **every tool the app uses**. Omitting a declaration removes the
41
+ agent's access at the next open; a declaration without a registered handler is not delivered.
42
+
43
+ Verify one safe read/action and one denial against app state, not just the assistant's words.
@@ -0,0 +1,158 @@
1
+ ---
2
+ name: croche-cli
3
+ description: Use the Croche CLI to create an app project and private debug-key file, inspect account/project metadata, edit a draft config, or attach the local debugger. Trigger on croche terminal commands or CLI setup, including PowerShell. Not for writing SDK app code or approving Studio-only actions.
4
+ ---
5
+
6
+ # Croche CLI
7
+
8
+ Do the permitted CLI work and explain the next user action. Node.js 22+ on macOS/Linux;
9
+ Windows verification pending. Check `croche --help` and installed version before relying on
10
+ a command. CLI 0.5.1 is published on npm; platform and login verification remain separate.
11
+ With installation permission:
12
+
13
+ ```sh
14
+ npm install -g @h1r-ai/croche-cli
15
+ croche --help
16
+ ```
17
+
18
+ The package is `@h1r-ai/croche-cli`; its executable is `croche`.
19
+
20
+ ## Capture command output before it reaches the transcript
21
+
22
+ The CLI operations below may return credential prefixes. Use a capturing subprocess or shell
23
+ variable, parse the JSON privately, and output only required non-key fields (success, account ID,
24
+ project ID, destination path). Never echo raw JSON, stderr, `.credential.prefix` or `.debug_key.prefix`.
25
+ For a key presence check, emit only its variable name and presence/length; never masked substrings.
26
+ A successful user login is a signal to re-check now, not reuse an earlier failed check.
27
+
28
+ For a POSIX Node host, this identity check captures both streams and emits only a boolean:
29
+
30
+ ```js
31
+ import { spawnSync } from 'node:child_process';
32
+ const check = spawnSync('croche', ['auth', 'whoami', '--json'], {
33
+ encoding: 'utf8', stdio: ['ignore', 'pipe', 'pipe'],
34
+ });
35
+ let authenticated = false;
36
+ try { authenticated = check.status === 0 && JSON.parse(check.stdout).ok === true; }
37
+ catch { /* Report only the safe status, never raw output. */ }
38
+ console.log(JSON.stringify({ authenticated }));
39
+ process.exitCode = authenticated ? 0 : 1;
40
+ ```
41
+
42
+ Use the same capture-and-allowlist pattern for project/debug-key commands. Do not print a
43
+ subprocess exception containing captured output. Use the PowerShell reference for that shell;
44
+ this example is not a Windows execution claim.
45
+
46
+ ## Authenticate without collecting a secret
47
+
48
+ After installing the CLI, if the account is not already configured, make the same **one combined
49
+ request** as `croche`: sign up in Studio, create one account key (`dk_`) under **Account → Account
50
+ keys** (under **Personal**), then run **`croche login` themselves in any private terminal on the
51
+ same machine and OS account**, entering the key only at its hidden prompt (PowerShell that refuses
52
+ `croche` because scripts are disabled: the human first runs `Set-ExecutionPolicy -Scope CurrentUser RemoteSigned` once). For an empty app repo,
53
+ combine missing app purpose with that request. If neither the request nor repo reveals the platform,
54
+ add web/Node, React Native, Swift/iOS or Kotlin/Android to that same question. A known
55
+ platform already answers that choice. In an existing app, infer its purpose. Do not add a separate credential or project-choice questionnaire. Ask for completion,
56
+ not the key. The account key is different from the SDK debug key (`cdt_`).
57
+
58
+ **Never run login as the agent**, feed a key to its stdin, put one in argv, or open stored
59
+ credentials into the transcript. The user runs login; no shell export or agent restart is required.
60
+ TODO verify: the login/logout/identity contract against the matching released CLI:
61
+
62
+ - `croche login` validates the key before storing it and prints the account. Non-TTY login can
63
+ read stdin but never argv; that is for user-controlled private automation, not agent collection.
64
+ - Storage is in the OS config directory: XDG on Linux, `~/Library/Application Support` on macOS,
65
+ `%APPDATA%` on Windows; POSIX file mode **0600**, Windows user-only ACL. Windows is unverified.
66
+ - `croche auth whoami --json` returns account and credential metadata. Capture JSON privately;
67
+ emit only success, account ID and optionally source (`env` or `stored`), never raw output.
68
+ Do not print any part of a key, including prefixes/suffixes or masked previews.
69
+ Use it to verify the intended account; do not repeat private profile details unnecessarily.
70
+ - User-run `croche logout` removes stored credentials, not any environment value. For CI only,
71
+ secret-manager-provided `CROCHE_ACCOUNT_KEY` takes precedence over stored login. Do not print
72
+ its value or introduce an export as another onboarding step.
73
+
74
+ If login is unavailable, report a release blocker, not a guessed `npx` form or a secret-printing
75
+ workaround. An agent on another machine/container has a separate credential context; never copy
76
+ keys through chat to connect it. Then run `croche projects list --json`; reuse a project only
77
+ when the app clearly identifies it. Otherwise create an app-specific project in the requested
78
+ setup instead of asking the user to fetch/select keys. A **project ID** is not a public project key.
79
+
80
+ ## Create the app setup without exposing the debug key
81
+
82
+ After the user completes signup, developer-key creation and `croche login`, do the rest:
83
+
84
+ ```sh
85
+ croche projects create --name "My app" --json
86
+ croche debug-keys create --project PROJECT_ID --json
87
+ ```
88
+
89
+ Use the returned project ID and public project key; do not ask the user to retrieve them.
90
+ Before writing a secret, check that the chosen env-file path is not already tracked by Git;
91
+ never run a broad diff that could expose its contents. Project creation returns `data.project.id`
92
+ and `data.project.public_key` with `--json`. Reuse an existing intended project when appropriate
93
+ and keep account identity out of unnecessary reports.
94
+
95
+ **Candidate commands — TODO verify** against the matching published CLI:
96
+
97
+ - `croche debug-keys create --project PROJECT_ID --json` writes `CROCHE_DEBUG_KEY` (`cdt_`)
98
+ to `./.env`. Use only `data.debug_key.id` and `data.env_file` from privately captured
99
+ JSON result, **never a secret or prefix**. Do not treat this SDK credential as the CLI account key.
100
+ - `--env-file PATH` selects another file in an existing directory. A new file is **0600** on
101
+ POSIX; an existing file preserves its permissions and warns if too permissive. Check/fix
102
+ permissions without printing contents. Windows protection is unverified. The destination
103
+ is added to `.gitignore` in a Git repo, including custom paths; verify it is not tracked.
104
+ - An existing nonempty value is refused without `--force`. Preserve the existing file and
105
+ ask before replacing that credential; do not force, clear or retry creation automatically.
106
+ - `croche debug-keys list --project PROJECT_ID --json` returns `data.debug_keys` metadata.
107
+ - `croche debug-keys revoke --project PROJECT_ID KEY_ID --json` revokes the selected ID;
108
+ `data.debug_key` is the result metadata. Revoke only that explicitly authorized key, not
109
+ other keys or every key in the project. Check the installed help matches this candidate.
110
+
111
+ Never use `--print`: that is a human-only private-terminal option.
112
+ Do not use an older CLI's secret output as a workaround. If creation times out, inspect safe
113
+ metadata before retrying; do not assume it failed. Load the file directly into the app process,
114
+ for example `node --env-file=.env first-turn.mjs`, without exposing it in chat or shell output.
115
+
116
+ ## Common work
117
+
118
+ | Task | Command (replace `PROJECT_ID` locally) |
119
+ | --- | --- |
120
+ | Project details | `croche projects get PROJECT_ID --json` |
121
+ | Usage and remaining allowance | `croche projects usage PROJECT_ID --period week --json` |
122
+ | Recent reported operations | `croche projects operations PROJECT_ID --limit 20 --json` |
123
+ | Debug-key metadata | `croche debug-keys list --project PROJECT_ID --json` |
124
+ | Server-key metadata | `croche keys server list PROJECT_ID --json` |
125
+ | App verification settings | `croche attestation get PROJECT_ID --json` |
126
+ | Draft to a local file | `croche config get --project PROJECT_ID -o draft.json` |
127
+ | Save requested draft edits | `croche config save draft.json --project PROJECT_ID --note "Update instructions"` |
128
+ | Draft and released versions | `croche config list --project PROJECT_ID` |
129
+
130
+ For config edits, load `croche-config` if installed: drafts replace the entire config and
131
+ reach development installs. Read the draft before editing; preserve its other fields. On
132
+ `draft_conflict`, get the current draft into a **different file**, reconcile with the user's
133
+ edit, and save deliberately. Do not force an empty base or blindly retry. The human reviews
134
+ cards and diff at **Build → AI config → Running config**, chooses **Release…**, and types the
135
+ project name to approve. Production installs apply the release on their next open after sync.
136
+ Studio is not a draft editor.
137
+
138
+ Debug-key creation/list/revoke use the candidate CLI flow above. Guide the user to Studio for
139
+ account developer-key or server-key administration, app verification, budgets, project
140
+ pause/archive or production release. A `dk_` credential does not authorize bypassing human-only approval.
141
+
142
+ ## Debug the app already running
143
+
144
+ `croche debug` lists running apps for the user to choose. For an agent/noninteractive session,
145
+ use `croche debug runtimes --json`, then `croche debug connect --runtime-id RUNTIME_ID` after
146
+ selecting the intended app. No account key is needed for this local debugger path. Keep the
147
+ printed viewer/pairing link private. Do not attach an unrelated app, expose the local viewer
148
+ publicly, or send/reset user conversations merely to obtain a trace.
149
+
150
+ ## Read results correctly
151
+
152
+ `--json` gives `{ok:true,data}` or `{ok:false,error:{code,message,details?}}`.
153
+ Exit classes: **0** success, **1** remote failure, **2** usage/configuration,
154
+ **3** authentication/authorization, **4** transport/timeout. A timeout is not proof a write failed.
155
+ Stop on errors; consult `croche-troubleshoot` if available. Report only necessary, redacted data.
156
+
157
+ For PowerShell encoding, exit handling and quoting, read
158
+ [powershell.md](references/powershell.md). Do not replace an unverified command with a guess.
@@ -0,0 +1,4 @@
1
+ interface:
2
+ display_name: "Croche CLI"
3
+ short_description: "Inspect projects and edit Croche drafts"
4
+ default_prompt: "Use $croche-cli to inspect my project and guide any required Studio steps."
@@ -0,0 +1,47 @@
1
+ # PowerShell syntax (Windows verification pending)
2
+
3
+ Use when the user's terminal is PowerShell. These forms are guidance; do not report Windows
4
+ support or a successful Windows run without executing there.
5
+
6
+ Call plain `croche` in PowerShell. If PowerShell refuses it because running scripts is disabled
7
+ (npm's `croche.ps1`), the human runs **`Set-ExecutionPolicy -Scope CurrentUser RemoteSigned`**
8
+ once, as part of the login request; you never change the execution policy yourself. After you
9
+ install the CLI, the user runs **`croche login`** in their private terminal; you never run it or see their key. No
10
+ PowerShell environment assignment is needed for onboarding. Login remains pending verification.
11
+
12
+ Capture authentication output without displaying prefixes; report only a boolean:
13
+
14
+ ```powershell
15
+ $raw = croche auth whoami --json 2>$null
16
+ $exit = $LASTEXITCODE
17
+ $authenticated = $false
18
+ try { $authenticated = ($exit -eq 0 -and ($raw | ConvertFrom-Json).ok -eq $true) }
19
+ catch { $authenticated = $false }
20
+ @{ authenticated = $authenticated } | ConvertTo-Json -Compress
21
+ ```
22
+
23
+ Do not echo `$raw`. After the human says done, re-check now and continue to the first authorized
24
+ live turn in the same turn; do not stop on a stale missing-file result. For private key files,
25
+ check presence/length only, never prefixes/suffixes or masked substrings.
26
+
27
+ ```powershell
28
+ [Console]::OutputEncoding = [Text.UTF8Encoding]::new()
29
+ $result = croche projects list --json | ConvertFrom-Json
30
+ if ($LASTEXITCODE -ne 0) { throw "Croche failed; inspect the redacted error code." }
31
+ # Inspect only necessary project fields, not secrets or unrelated account details.
32
+ $result.data.projects | Select-Object id, name
33
+ ```
34
+
35
+ - Use `$LASTEXITCODE`, not just `$?`, for the native command's exit class.
36
+ - Windows PowerShell 5.1 has no `&&`; run a command then check `$LASTEXITCODE`.
37
+ - CLI text/JSON input files must be UTF-8. In Windows PowerShell 5.1, use
38
+ `Set-Content -Path draft.json -Value $json -Encoding UTF8`; `>` / `Out-File` default to
39
+ UTF-16 there and cause `unsupported_encoding`. Preserve the entire fetched draft when editing.
40
+ - Single quotes are literal; double quotes expand variables. Quote paths containing spaces.
41
+ - Prefer a supported file option over free-text command arguments containing embedded quotes
42
+ or shell metacharacters. For local runtime commands with `--text-file`, write UTF-8 and pass
43
+ the path; check that subcommand's help first. Do not invent a file option for another command.
44
+
45
+ Do not run POSIX inline assignments (`KEY=value command`), `export`, or Bash heredocs in
46
+ PowerShell. If the environment cannot run the command, prepare files and ask the user to run
47
+ the check; ask only for a redacted error code and exit status, never their environment dump.
@@ -0,0 +1,152 @@
1
+ ---
2
+ name: croche-config
3
+ description: Edit or diagnose Croche project config, model selection, Studio drafts and releases, app tool declarations, or language selection. Use when instructions differ after restart, a draft removes tools, or user locale selects the wrong config. Not for CLI installation or unrelated app localization.
4
+ ---
5
+
6
+ # App configuration
7
+
8
+ Work on the app-visible config, not service implementation. Determine whether the requested
9
+ change is bundled app config, a development draft, or a production release before editing.
10
+ Use `Croche.open({ config, handlers, ... })` for project configuration.
11
+
12
+ ## Choose a model in app config
13
+
14
+ **Your app can choose the model.** Set `model` inside the `config` passed to `Croche.open`,
15
+ not as a top-level open option:
16
+
17
+ ```ts
18
+ const config = {
19
+ model: 'deepseek/deepseek-v4.1-flash',
20
+ instructions: 'You are a friendly guide. Keep replies brief.',
21
+ };
22
+ // Use this as the config option in your existing Croche.open call.
23
+ ```
24
+
25
+ | Scope | Config field |
26
+ | --- | --- |
27
+ | Project | `config.model` |
28
+ | Project language | `config.languages.<tag>.model` |
29
+ | Agent | `config.agents.<agentId>.model` |
30
+ | Agent language | `config.agents.<agentId>.languages.<tag>.model` |
31
+
32
+ For the selected agent and language, later applicable levels override earlier ones in that
33
+ order: project → project language → agent → agent language. Omitting `model` at one level
34
+ inherits the preceding applicable value. Modes do not declare `model`.
35
+
36
+ ## Recommended models
37
+
38
+ | Model | When to use it | USD / 1M tokens (input / output) | Latency in the comparison below |
39
+ | --- | --- | --- | --- |
40
+ | `deepseek/deepseek-v4.1-flash` | Recommended default for text + images and low-latency chat | $0.2002 / $0.9856 | Median **0.9 s**, p90 **1.6 s**; observed **~$0.00013/turn** |
41
+ | `openai/gpt-6-luna` | Text + image alternative; fallback subject to the reasoning limits below | $0.1114 / $0.5571 | Not measured in this comparison |
42
+ | `deepseek/deepseek-v4-flash-0731` | Text-only apps seeking cheaper output than V4.1; not for image input | $0.1773 / $0.6584 | Not measured in this comparison |
43
+ | `xiaomi/mimo-v2.6-flash` | Low token cost, but only background or latency-tolerant work | $0.14 / $0.29 | Median **11.2 s**, p90 **23.5 s**, max **54 s** |
44
+ | `anthropic/claude-opus-5.5` | Work/productivity where quality justifies higher cost; not recommended for entertainment/chat companions | $4.5455 / $22.7273 | Not measured in this comparison |
45
+ | `openai/gpt-6.1-sol` | Work/document agents that accept higher cost for quality; not recommended for entertainment/chat companions | $2.2286 / $11.1429 | Not measured in this comparison |
46
+
47
+ Prices are estimates from the Studio catalog's **2026-10-05** snapshot, in USD per million
48
+ input/output tokens, not a fixed per-turn charge. MiMo has the lowest output price in this
49
+ shortlist, but the lowest token price is not the fastest response.
50
+
51
+ Latency and observed turn cost above come from **one 32-turn Croche Chat comparison on
52
+ 2026-10-13**, not a service guarantee or a general benchmark. Prompt size, output length and
53
+ workload affect both time and cost. Measure your app; do not extrapolate those timings to the
54
+ models marked unmeasured.
55
+
56
+ Set **project-level `config.model` explicitly**. Infer image use from the requested feature or
57
+ existing code; do not add a setup question when that is clear. Preserve the user's explicit
58
+ model choice. Do not use the text-only option for an app that sends images.
59
+
60
+ The default when no applicable config level sets `model` is
61
+ **`deepseek/deepseek-v4.1-flash`**, with **`openai/gpt-6-luna`** as fallback.
62
+ That fallback applies only when `reasoning` is **`default` or `off`**. With `low`, `medium`,
63
+ or `high`, the fallback is dropped; do not promise an automatic switch to the alternative.
64
+
65
+ This default is live. Set `config.model` explicitly when your app needs a particular model.
66
+ Listing an alternative is not a guarantee that every explicit model choice automatically
67
+ falls back to it. Public SDK package availability remains a separate release check.
68
+
69
+ Read the online [Models page](https://docs.croche.ai/models.md) for recommendations and the
70
+ [documentation index](https://docs.croche.ai/llms.txt) to discover other public pages. The
71
+ [full allowed list](references/models.md) is included offline and is also available in Studio.
72
+ Do not invent a model name or say model choice is unavailable.
73
+
74
+ ## Rules that prevent broken apps
75
+
76
+ - A Studio AI config, draft or release, **replaces the app's code config as a whole**. It does
77
+ not merge with the bundled config. Preserve instructions, tools, agents and other app fields.
78
+ - A downloaded config applies at the **next open after a sync**, never in the active session.
79
+ Restarting once before the download finishes can still use the old config; allow sync and
80
+ reopen again. Do not promise that saving a draft changes an already-open agent.
81
+ - Drafts reach only installs using a **debug key (`debugKey`)**. Every debug key
82
+ follows drafts by default; there is **no toggle** to enable this.
83
+ - A config declaring a tool the app does not register is **not delivered**. Keep declaration
84
+ names and app handler registration consistent; handlers stay in code.
85
+ - **A draft must include every tool the app uses, or the agent loses those tools at next open.**
86
+ Export/read the whole current draft before an edit, not just the instructions field.
87
+ - `CrocheRuntime.create` never uses Studio config; only `Croche.open` does. Do not suggest
88
+ switching a draft to fix a low-level single-agent integration.
89
+
90
+ ## Agent authors; human reviews in Studio
91
+
92
+ Studio is not a draft editor. Make a requested config edit through the CLI, not an imaginary
93
+ Draft tab or Save draft button. Get the current draft before editing so save checks its base:
94
+
95
+ ```sh
96
+ croche config get --project PROJECT_ID --output croche.config.json
97
+ # Edit croche.config.json, preserving the complete config and every required tool.
98
+ croche config save croche.config.json --project PROJECT_ID
99
+ ```
100
+
101
+ Preserve the full project document. If no draft exists, prepare `schema: 2` with the complete
102
+ app config in `config`, not the returned `null`. On a conflict, keep the local edit, fetch the
103
+ latest draft separately and reconcile; do not force an empty base or blindly overwrite.
104
+ Saving affects debug-key apps, not production: every debug key follows drafts. Verify all tool
105
+ handlers, allow sync and reopen; the change applies on the **next open after sync**, never
106
+ mid-session. Test the behavior and check **Monitoring → Logs**.
107
+
108
+ For production, the **human** opens **Build → AI config → Running config**, reviews the draft's
109
+ readable cards and diff against the released config, and chooses **Release…**. The human types
110
+ the project name and chooses **Approve and publish**. Production installs apply the released
111
+ config on their next open after sync; release alone does not prove application. Never release,
112
+ roll back or change spending limits as a side effect of a draft edit.
113
+
114
+ App-code reports may say **“Running config reports are not available yet.”** Do not promise
115
+ those reports: draft review and release remain available below. Missing reports do not prove
116
+ app health or which config is currently effective.
117
+
118
+ ## Language: the user, not the config author
119
+
120
+ `language` passed to `Croche.open` is **the user's language**, a BCP-47 tag. It selects the
121
+ matching translated config branch, `config.languages.<tag>`: exact tag first, then primary
122
+ subtag. If none matches, the base config is used **as is**. An English-only config still serves
123
+ a Korean user.
124
+
125
+ `config.defaultLanguage` is the language the **base config is written in** (default `en`),
126
+ not the user's language and not a fallback language assigned to the user. It belongs at the
127
+ project config root, not among the `Croche.open` host options or inside an agent override.
128
+
129
+ When the app passes no `language`, SDKs use the device/browser locale: browser
130
+ `navigator.language`; automatic RN/Swift/Kotlin device locale is targeted for **0.5.1**.
131
+ TODO verify mobile 0.5.1 behavior before relying on it. On earlier RN versions, pass the app's
132
+ known user locale explicitly. On a Node backend, pass the authenticated user's app locale;
133
+ the server has no browser/device locale for that person.
134
+
135
+ The model is **not told this language value**. It replies in the language the user writes
136
+ unless instructions say otherwise. Selecting a config branch neither translates app data nor
137
+ forces the reply language. Do not set `defaultLanguage` from each user's preference.
138
+
139
+ ```ts
140
+ const config = {
141
+ model: 'deepseek/deepseek-v4.1-flash',
142
+ defaultLanguage: 'en',
143
+ instructions: 'You are a friendly guide.',
144
+ languages: { ko: { instructions: 'You are a friendly guide for our Korean edition.' } },
145
+ };
146
+ // In Croche.open: { ...hostOptions, language: 'ko-KR', config }
147
+ // ko-KR selects ko here. With no ko branch, the English base stays unchanged.
148
+ ```
149
+
150
+ Keep translations limited to fields whose content actually differs; do not duplicate a whole
151
+ config for every locale without need. Whole Studio-config replacement is a separate rule from
152
+ choosing a language branch within that config.
@@ -0,0 +1,4 @@
1
+ interface:
2
+ display_name: "Croche Config"
3
+ short_description: "Edit app config and select user language"
4
+ default_prompt: "Use $croche-config to review my draft, tools, and user-language selection."
@@ -0,0 +1,12 @@
1
+ # Allowed model IDs
2
+
3
+ Use an exact ID below for the `model` field in a Croche project config. These are the IDs
4
+ supported by the current SDK candidate; public package availability remains pending verification.
5
+
6
+ {{ALLOWED_MODEL_IDS}}
7
+
8
+ A model ID outside this list is not a supported app config choice. Match the list to the SDK
9
+ version you actually ship; do not invent IDs or infer input support from another product's catalog.
10
+ For recommendations, config levels and default/fallback behavior, read
11
+ [the config skill](../SKILL.md) or the online [Models page](https://docs.croche.ai/models.md).
12
+ The [documentation index](https://docs.croche.ai/llms.txt) lists every public Markdown page.
@@ -0,0 +1,55 @@
1
+ ---
2
+ name: croche-platforms
3
+ description: Set up Croche for React Native, a web backend, or native Swift/Kotlin. Use for platform imports, storage, development versus server credentials, mobile locale, and native release readiness. Not for ordinary Node first-turn setup or generic platform development without Croche.
4
+ ---
5
+
6
+ # Choose the correct platform integration
7
+
8
+ Preserve the user's target platform. Explain what is ready and what needs verification rather
9
+ than silently converting their app to another platform. Croche runs the model for the app;
10
+ use the usage and limits shown in Studio, not a separate model-service setup.
11
+
12
+ | Target | Path | Read when needed |
13
+ | --- | --- | --- |
14
+ | Local Node check | `@h1r-ai/croche`, durable `FileStorage`, SDK debug key | Core `croche` skill |
15
+ | React Native | `Croche` from `@h1r-ai/croche-react-native`, SDK-managed storage | [react-native.md](references/react-native.md) |
16
+ | Web (local and production) | `Croche` on the app's Node backend, server key stays there | [web-backend.md](references/web-backend.md) |
17
+ | iOS · Swift | SPM, exact **0.5.1**, `Croche.open` | [ios.md](references/ios.md) |
18
+ | Android · Kotlin | Maven, exact **0.5.1**, `Croche.open` | [android.md](references/android.md) |
19
+
20
+ Node.js 22+ on macOS/Linux; Windows verification pending. PowerShell syntax does not establish
21
+ Windows support. SDK 0.5.1 is published on npm; verify the installed version and platform behavior.
22
+ Node and RN do not automatically load the CLI-created `.env`: Node needs `--env-file` or an
23
+ existing dotenv loader, web secrets stay server-side only, and RN needs debug-only build config
24
+ with no secret in release artifacts. Read the matching reference above before the first turn.
25
+ For account CLI login and shell syntax, use `croche-cli` if installed; a `dk_` key is
26
+ never an app credential.
27
+
28
+ ## Language option on every platform
29
+
30
+ `language` is the **user's BCP-47 language**, selecting a translated `config.languages` branch.
31
+ No match uses the base as written in `config.defaultLanguage`; it does not force a reply
32
+ language. Omitted language uses browser `navigator.language`; RN/Swift/Kotlin automatic device
33
+ locale is targeted for 0.5.1 (TODO verify). Pass the known user locale explicitly on earlier RN
34
+ or a Node backend. The model replies to the user's language unless instructions say otherwise.
35
+ Use `croche-config` for the complete selection and next-open rules.
36
+
37
+ ## Native gate
38
+
39
+ **Native Swift and Kotlin SDKs exist.** Their shared **project/agent `Croche.open` API** is
40
+ coming in **0.5.1**. Do not describe a pending API/release as nonexistent SDKs.
41
+ Candidate installation and `Croche.open` first-turn examples are in [ios.md](references/ios.md)
42
+ and [android.md](references/android.md). For a native request, read the matching reference,
43
+ prepare the integration and check exact 0.5.1 availability. TODO verify: package resolution,
44
+ simulator/emulator first turn and release credential exclusion. Do not substitute the native
45
+ 0.5.0 single-agent API or claim the candidate was run. Use git-ignored `.xcconfig` (iOS) or
46
+ `local.properties` (Android), wired only into Debug and excluded from Release at build time.
47
+ If a native release is unavailable, report that blocker; offer TypeScript/React Native for a
48
+ new hackathon app, but never rewrite an existing native app into a different stack unasked.
49
+
50
+ ## Verify the actual target
51
+
52
+ Build and run on the selected simulator/emulator/backend; note its SDK version and OS.
53
+ Check one completed reply and persistence, and inspect a release bundle/config to ensure it
54
+ does not contain development or CLI credentials. Production app verification is configured
55
+ by the user at **Settings → App verification**; a simulator check does not verify a device release.
@@ -0,0 +1,4 @@
1
+ interface:
2
+ display_name: "Croche Platforms"
3
+ short_description: "Set up Croche on mobile or web backends"
4
+ default_prompt: "Use $croche-platforms to choose and verify the integration for my app platform."