@answerlayer/cli 0.1.14 → 0.1.15

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
@@ -106,18 +106,17 @@ answerlayer local quickstart
106
106
  Quickstart asks for confirmation before it changes local state, then initializes
107
107
  and starts the supported public-image runtime, authenticates the CLI, installs
108
108
  the deterministic demo, and verifies the provider-free demo query. If no model
109
- provider is configured, it stops with a safe handoff:
110
-
111
- ```bash
112
- answerlayer local provider set anthropic
113
- answerlayer local quickstart
114
- ```
115
-
116
- The provider command must be run privately in the user's own terminal. The
117
- resumed quickstart verifies the provider and runs one real model-backed inquiry
118
- against the demo. Successful inquiry details are retained in the local runtime
119
- state, so repeating quickstart reuses the verified session instead of creating
120
- duplicate demo resources or inquiry sessions.
109
+ provider is configured during an interactive run, quickstart offers to collect
110
+ the Anthropic key through a hidden terminal prompt, verifies it, and continues
111
+ directly to one real model-backed inquiry. The key is never accepted as a
112
+ command argument or printed to output. Successful inquiry details are retained
113
+ in the local runtime state, so repeating quickstart reuses the verified session
114
+ instead of creating duplicate demo resources or inquiry sessions.
115
+
116
+ The provider step can be declined and resumed later by rerunning the same
117
+ `answerlayer local quickstart` command. Noninteractive `--json` runs never ask
118
+ for secret input and instead return a credential-free `provider-required`
119
+ handoff for an agent to report.
121
120
 
122
121
  For agent automation after the user has explicitly approved starting
123
122
  containers, use `answerlayer local quickstart --yes --json`. Progress is written
package/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "@answerlayer/cli",
3
- "version": "0.1.14",
3
+ "version": "0.1.15",
4
4
  "description": "Open-source command line client for the AnswerLayer API.",
5
5
  "type": "module",
6
6
  "bin": {
@@ -32,13 +32,15 @@ already available in the Codex skills directory.
32
32
 
33
33
  2. Explain that quickstart may pull an image, start Docker containers, create a
34
34
  persistent local volume, and install synthetic demo data. Get explicit user
35
- confirmation, then run:
35
+ confirmation. For an agent-controlled, noninteractive run, use:
36
36
 
37
37
  ```bash
38
38
  answerlayer local quickstart --yes --json
39
39
  ```
40
40
 
41
- Never pass `--yes` before the user approves. This checks Docker, pulls and
41
+ Never pass `--yes` before the user approves. For a human directly using a
42
+ terminal, use `answerlayer local quickstart` instead so the CLI can offer
43
+ its own hidden provider-key prompt. Quickstart checks Docker, pulls and
42
44
  pins the supported public image, starts Postgres, runs migrations, creates the local
43
45
  identity and scoped key, verifies it, and configures the CLI. It also seeds a
44
46
  versioned synthetic retail demo in a separate database, registers a
@@ -50,17 +52,23 @@ already available in the Codex skills directory.
50
52
  only when the user explicitly wants an empty instance. Progress appears on
51
53
  stderr; parse the single credential-free JSON object on stdout.
52
54
 
53
- 3. If the JSON status is `provider-required`, report that the provider-free demo
54
- succeeded and hand provider setup back to the user. Ask them to run this
55
+ 3. For a human-led setup, run `answerlayer local quickstart` interactively. If
56
+ no provider is configured, the same command offers a hidden Anthropic-key
57
+ prompt, verifies the credential, and continues to the model-backed answer
58
+ without requiring a second command. Never ask the user to paste the key into
59
+ chat.
60
+
61
+ If an agent's noninteractive JSON run returns `provider-required`, report
62
+ that the provider-free demo succeeded and ask the user to resume quickstart
55
63
  privately in their own terminal:
56
64
 
57
65
  ```bash
58
- answerlayer local provider set anthropic
66
+ answerlayer local quickstart
59
67
  ```
60
68
 
61
- Never ask the user to paste the key into chat, never pass it as an argument,
62
- and do not read a credential file. After the user confirms setup completed,
63
- resume the same idempotent workflow without another state-change approval:
69
+ Never pass the key as an argument and do not read a credential file. After
70
+ the user confirms setup completed, inspect the same idempotent workflow
71
+ without another state-change approval:
64
72
 
65
73
  ```bash
66
74
  answerlayer local quickstart --yes --json
package/src/local.js CHANGED
@@ -109,9 +109,14 @@ async function localQuickstart(parsed, io) {
109
109
  }, progressIo);
110
110
  const { runtime, baseUrl, demo } = started;
111
111
  const provider = resolveLocalProvider("anthropic");
112
- const configured = Boolean(readEnvironment(runtime.envPath)[provider.environmentName]);
112
+ let configured = Boolean(readEnvironment(runtime.envPath)[provider.environmentName]);
113
113
  let providerStatus;
114
114
 
115
+ if (!configured && await confirmQuickstartProvider(parsed, io, provider)) {
116
+ await localProviderSet(parsed, io, provider, "set");
117
+ configured = true;
118
+ }
119
+
115
120
  if (!configured) {
116
121
  providerStatus = providerResult(provider, false, "ready", { verified: false, errorCode: "not-configured" });
117
122
  const result = quickstartResult(runtime, demo, providerStatus, {
@@ -804,6 +809,20 @@ async function confirmQuickstart(parsed, io) {
804
809
  }
805
810
  }
806
811
 
812
+ async function confirmQuickstartProvider(parsed, io, provider) {
813
+ if (parsed.flags.json) return false;
814
+ const prompt = `Configure ${provider.label} now to run a model-backed answer? [Y/n] `;
815
+ if (io.confirmProvider) return Boolean(await io.confirmProvider(prompt));
816
+ if (!io.stdin?.isTTY) return false;
817
+ const terminal = createInterface({ input: io.stdin, output: io.stderr });
818
+ try {
819
+ const answer = await terminal.question(prompt);
820
+ return !/^(?:n|no)$/i.test(answer.trim());
821
+ } finally {
822
+ terminal.close();
823
+ }
824
+ }
825
+
807
826
  async function runQuickstartInquiry(baseUrl, connectionId, io) {
808
827
  const config = readConfig(io.env);
809
828
  if (config.baseUrl !== baseUrl || !config.apiKey) {
@@ -896,8 +915,7 @@ function printQuickstart(result, parsed, io) {
896
915
  write(io.stdout, `Demo: ${result.demo.status} (${result.demo.version})\n`);
897
916
  if (result.status === "provider-required") {
898
917
  write(io.stdout, "A model provider is required for natural-language inquiry.\n");
899
- write(io.stdout, "Enter the credential privately in your terminal: answerlayer local provider set anthropic\n");
900
- write(io.stdout, "Then resume with: answerlayer local quickstart\n");
918
+ write(io.stdout, "Rerun answerlayer local quickstart in your terminal when ready; it will prompt for the credential without displaying it.\n");
901
919
  return;
902
920
  }
903
921
  if (result.status === "provider-verification-failed") {