@moda-ai/cli 1.31.3 → 1.32.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/README.md CHANGED
@@ -132,24 +132,88 @@ codes, event schema) for agents.
132
132
 
133
133
  ## Prompt Management
134
134
 
135
- Prompt management is code-first. Keep prompts in `prompts/**/*.prompt.md` or
136
- `prompts/**/*.prompt.json`, sync them with the CLI, and render them through the
137
- SDK so LLM spans include prompt metadata.
138
-
139
- JSON definitions can provide `content`, `systemPrompt`, or `messages`. Existing
140
- files with a nonempty text `template` also work: the CLI uses it as content when
141
- none of those fields supplies usable text. Sync preserves placeholders and
142
- leaves the source file unchanged; empty definitions still produce an error.
135
+ Prompt management is code-first. Keep existing files and inline definitions in
136
+ place. The CLI resolves selected sources without importing or executing your app.
137
+ Existing `prompts/**/*.prompt.md` and `prompts/**/*.prompt.json` projects continue
138
+ to work unchanged.
143
139
 
144
140
  ```bash
145
- moda prompts init
146
- moda prompts status
141
+ # Discover prompt sources and preview the sync without saving local state.
142
+ moda prompts sync --dry-run
143
+ # Run prompt-specific discovery, upload verified definitions, and save mappings.
147
144
  moda prompts sync
145
+ # Optionally investigate unresolved sources with an installed coding agent.
146
+ moda prompts sync --analyst=claude
147
+ # Sync only configured sources, without discovery.
148
+ moda prompts sync --no-analyze
149
+ ```
150
+
151
+ Every sync reuses the prompt-specific harness analyzer. The default is a bounded,
152
+ deterministic local scan with no agent calls. Successful sync saves newly verified
153
+ mappings in `.moda/prompts.yml`; existing keys and legacy prompt-file metadata are
154
+ preserved. Explicit negative `prompt_paths` patterns also exclude new discoveries.
155
+ Analysis diagnostics and partial coverage are returned in the sync result. A dry
156
+ run performs deterministic discovery without changing the manifest or lockfile.
157
+ `--watch` starts with analysis and then watches mapped definitions; re-run sync to
158
+ look for newly added sources that do not affect an existing mapping.
159
+
160
+ For unresolved candidates, select `--analyst=claude`, `codex`, or `cursor` on sync.
161
+ The CLI launches a bounded investigation through the installed coding-agent CLI.
162
+ It accepts source selectors, then reads and validates the source itself; agent
163
+ text never becomes registered prompt content. `--assist=none` disables assistance.
164
+ You can still run `harness analyze --experimental --concern=prompts` separately
165
+ and import its report with `prompts init --from-harness=<report>`.
166
+ Discovery reports partial coverage explicitly; finding some prompts does not
167
+ prove that every model call is covered.
168
+
169
+ You can also configure `.moda/prompts.yml` directly:
170
+
171
+ ```yaml
172
+ version: 2
173
+ prompt_paths:
174
+ - instructions/**/*.txt
175
+ - '!instructions/archive/**'
176
+ sources:
177
+ - key: support.system
178
+ path: src/agent.ts
179
+ selector:
180
+ symbol: SYSTEM_PROMPT
181
+ - key: support.policy
182
+ path: config/agents.yaml
183
+ selector:
184
+ pointer: /support/prompt
185
+ - key: support.build
186
+ path: src/prompt.py
187
+ selector:
188
+ symbol: build_prompt
189
+ kind: builder
190
+ dependencies:
191
+ - path: config/policy.txt
148
192
  ```
149
193
 
150
- `status` and `diff` are read-only. `sync` uploads changed versions and writes
151
- `.moda/prompts.lock.json`. `promote` moves a remote `dev`, `staging`, or `prod`
152
- label.
194
+ Selectors support named TypeScript/JavaScript/Python definitions and JSON Pointer
195
+ selection in JSON/YAML. Python resolution requires `python3`; the helper parses
196
+ ASTs without importing customer modules. Static literals and supported constant
197
+ compositions become text or messages. Templates retain placeholders. Functions,
198
+ unsupported expressions, and runtime composition remain builder definitions with
199
+ source/dependency fingerprints and explicit incomplete coverage. Builders and
200
+ templates cannot be replayed as plain prompt text; execute the application's
201
+ builder and attribute the resulting model call to its registry version.
202
+
203
+ JSON definitions accept `content`, `systemPrompt`, or `messages`, with `template`
204
+ as a fallback when none supplies usable text. Explicit mappings are required for
205
+ ambiguous definitions. Exact file paths and globs are honored; duplicate keys,
206
+ missing selectors, unsafe paths, and malformed manifests fail before upload.
207
+
208
+ `status` and `diff` are read-only. `sync` uploads changed versions and atomically
209
+ writes `.moda/prompts.lock.json` only after validating the response and rechecking
210
+ local sources. A failed sync preserves the prior lock. Removing a tracked source
211
+ requires `--allow-untrack`; this removes its local lock entry, not remote versions.
212
+ `promote` moves a remote `dev`, `staging`, or `prod` label.
213
+
214
+ Use the lock entry's `{ key, promptId, versionId }` to attribute runtime calls.
215
+ Actual rendered messages belong in traces; request data should not produce a new
216
+ registry definition on each call. Plain renderable definitions can use the SDK:
153
217
 
154
218
  ```typescript
155
219
  const rendered = Moda.prompt("support.triage").render({