@answerlayer/cli 0.3.4 → 0.3.6
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 +14 -0
- package/package.json +1 -1
- package/skills/answerlayer/SKILL.md +7 -3
- package/skills/answerlayer-pipeline-refresh/SKILL.md +146 -0
- package/src/cli.js +43 -6
package/README.md
CHANGED
|
@@ -224,6 +224,7 @@ answerlayer pipelines runs start <pipeline-id> --wait --json
|
|
|
224
224
|
answerlayer pipelines runs start <pipeline-id> \
|
|
225
225
|
--dataset agep --dataset agepxbplp \
|
|
226
226
|
--idempotency-key census-2021-backfill --wait --json
|
|
227
|
+
answerlayer pipelines runs list <pipeline-id> --json
|
|
227
228
|
answerlayer pipelines runs get <pipeline-id> <run-id> --json
|
|
228
229
|
answerlayer pipelines runs retry <pipeline-id> <run-id> \
|
|
229
230
|
--idempotency-key census-2021-retry-1 --wait --json
|
|
@@ -286,6 +287,19 @@ This installs to `~/.codex/skills/answerlayer` by default. Use `--path` for a
|
|
|
286
287
|
different skill directory; an existing skill is never replaced unless you pass
|
|
287
288
|
`--force`.
|
|
288
289
|
|
|
290
|
+
Install the focused operator skill for adding new source data to an existing
|
|
291
|
+
API pipeline dataset with:
|
|
292
|
+
|
|
293
|
+
```bash
|
|
294
|
+
answerlayer skills install pipeline-refresh
|
|
295
|
+
```
|
|
296
|
+
|
|
297
|
+
This installs to `~/.codex/skills/answerlayer-pipeline-refresh`. It guides an
|
|
298
|
+
agent through selecting the existing pipeline and dataset scope, confirming the
|
|
299
|
+
production run, using an upstream event as the idempotency key, and verifying
|
|
300
|
+
publication and metadata synchronization without changing the promoted
|
|
301
|
+
revision.
|
|
302
|
+
|
|
289
303
|
The recommended path is one command:
|
|
290
304
|
|
|
291
305
|
```bash
|
package/package.json
CHANGED
|
@@ -96,9 +96,13 @@ This workflow is for Docker Compose development only. Do not run
|
|
|
96
96
|
Pick the command once per session and reuse it. Run:
|
|
97
97
|
|
|
98
98
|
```bash
|
|
99
|
-
command -v answerlayer.js >/dev/null
|
|
100
|
-
|
|
101
|
-
|
|
99
|
+
if command -v answerlayer.js >/dev/null; then
|
|
100
|
+
echo answerlayer.js
|
|
101
|
+
elif command -v answerlayer >/dev/null; then
|
|
102
|
+
echo answerlayer
|
|
103
|
+
else
|
|
104
|
+
echo "npx -y @answerlayer/cli"
|
|
105
|
+
fi
|
|
102
106
|
```
|
|
103
107
|
|
|
104
108
|
- `answerlayer.js` — ships with this plugin and is on your PATH (works offline).
|
|
@@ -0,0 +1,146 @@
|
|
|
1
|
+
---
|
|
2
|
+
name: answerlayer-pipeline-refresh
|
|
3
|
+
description: Add new source data to an existing AnswerLayer dataset by running its promoted API pipeline revision. Use for one-time or event-driven dataset refreshes, targeted dataset runs, safe run recovery, or verifying publication and metadata synchronization. Do not use to design a new pipeline package, change extraction logic or schemas, or insert arbitrary rows directly.
|
|
4
|
+
---
|
|
5
|
+
|
|
6
|
+
# AnswerLayer Pipeline Refresh
|
|
7
|
+
|
|
8
|
+
Refresh an existing dataset by running its already-promoted API pipeline
|
|
9
|
+
revision. In this workflow, "add new data" means extracting the current source
|
|
10
|
+
state and publishing the pipeline's governed output; it is not an arbitrary
|
|
11
|
+
row-insert command.
|
|
12
|
+
|
|
13
|
+
## Guardrails
|
|
14
|
+
|
|
15
|
+
- Read freely, but get explicit confirmation immediately before starting,
|
|
16
|
+
retrying, or cancelling a production run.
|
|
17
|
+
- Do not enable a disabled pipeline, promote or roll back a revision, change a
|
|
18
|
+
schedule, or modify package configuration unless the user separately asks.
|
|
19
|
+
- Never place source credentials, API tokens, certificates, or CA material in
|
|
20
|
+
a package, revision configuration, command output, or chat.
|
|
21
|
+
- Stop if the requested dataset is absent from the active revision's resolved
|
|
22
|
+
catalogue. A pipeline developer must update, validate, and promote a package
|
|
23
|
+
revision when extraction logic or schema changes.
|
|
24
|
+
|
|
25
|
+
## 1. Resolve and authenticate the CLI
|
|
26
|
+
|
|
27
|
+
Use the first installed command:
|
|
28
|
+
|
|
29
|
+
```bash
|
|
30
|
+
if command -v answerlayer.js >/dev/null; then
|
|
31
|
+
echo answerlayer.js
|
|
32
|
+
elif command -v answerlayer >/dev/null; then
|
|
33
|
+
echo answerlayer
|
|
34
|
+
else
|
|
35
|
+
echo "npx -y @answerlayer/cli"
|
|
36
|
+
fi
|
|
37
|
+
```
|
|
38
|
+
|
|
39
|
+
Reuse that command as `AL`. Verify authentication without printing the key:
|
|
40
|
+
|
|
41
|
+
```bash
|
|
42
|
+
AL auth me --json
|
|
43
|
+
```
|
|
44
|
+
|
|
45
|
+
The API key needs `api_pipeline:read` to inspect pipelines and runs and
|
|
46
|
+
`api_pipeline:execute` to start or control a run. A `--wait` workflow needs both.
|
|
47
|
+
|
|
48
|
+
## 2. Identify the existing pipeline and scope
|
|
49
|
+
|
|
50
|
+
Inspect before changing state:
|
|
51
|
+
|
|
52
|
+
```bash
|
|
53
|
+
AL pipelines list --json
|
|
54
|
+
AL pipelines get <pipeline-id> --json
|
|
55
|
+
AL pipelines revisions get <pipeline-id> <active-revision-id> --json
|
|
56
|
+
AL pipelines runs list <pipeline-id> --json
|
|
57
|
+
```
|
|
58
|
+
|
|
59
|
+
Confirm the installation base URL, pipeline ID and name, active revision,
|
|
60
|
+
pipeline status, exact requested dataset identifiers, and upstream source event
|
|
61
|
+
or release. If another run is active, inspect it instead of starting a second
|
|
62
|
+
one.
|
|
63
|
+
|
|
64
|
+
Omitting `--dataset` refreshes every dataset selected by the active package.
|
|
65
|
+
Use repeated `--dataset <identifier>` options for a targeted refresh. Dataset
|
|
66
|
+
scope is fail-closed: an unknown identifier must fail rather than silently run
|
|
67
|
+
a different dataset.
|
|
68
|
+
|
|
69
|
+
## 3. Prepare a safe run
|
|
70
|
+
|
|
71
|
+
Derive a stable idempotency key from the upstream event, release, or version,
|
|
72
|
+
for example `remplan-community-release-42`. Reuse exactly the same key after a
|
|
73
|
+
timeout or lost response. Use a new key only for a genuinely new source event.
|
|
74
|
+
|
|
75
|
+
Immediately before execution, show the user:
|
|
76
|
+
|
|
77
|
+
- AnswerLayer base URL;
|
|
78
|
+
- pipeline name, ID, and active revision;
|
|
79
|
+
- all datasets or the exact targeted dataset list; and
|
|
80
|
+
- the proposed idempotency key.
|
|
81
|
+
|
|
82
|
+
Get explicit confirmation, then run either the full refresh:
|
|
83
|
+
|
|
84
|
+
```bash
|
|
85
|
+
AL pipelines runs start <pipeline-id> \
|
|
86
|
+
--idempotency-key <source-event-id> \
|
|
87
|
+
--wait \
|
|
88
|
+
--json
|
|
89
|
+
```
|
|
90
|
+
|
|
91
|
+
or the targeted refresh:
|
|
92
|
+
|
|
93
|
+
```bash
|
|
94
|
+
AL pipelines runs start <pipeline-id> \
|
|
95
|
+
--dataset <dataset-identifier> \
|
|
96
|
+
--idempotency-key <source-event-id> \
|
|
97
|
+
--wait \
|
|
98
|
+
--json
|
|
99
|
+
```
|
|
100
|
+
|
|
101
|
+
Capture the returned run ID. If starting or polling returns a transient server
|
|
102
|
+
error, do not create a replacement run. Inspect the captured run, or repeat the
|
|
103
|
+
start request with the same idempotency key:
|
|
104
|
+
|
|
105
|
+
```bash
|
|
106
|
+
AL pipelines runs get <pipeline-id> <run-id> --json
|
|
107
|
+
```
|
|
108
|
+
|
|
109
|
+
A `409` can mean a run is already active, the pipeline is disabled or archived,
|
|
110
|
+
or no active revision exists. Report the state and stop; do not repair it
|
|
111
|
+
without separate authorization.
|
|
112
|
+
|
|
113
|
+
## 4. Verify publication and metadata
|
|
114
|
+
|
|
115
|
+
Verify the terminal run response, including:
|
|
116
|
+
|
|
117
|
+
- `status` and active stage;
|
|
118
|
+
- `revision_id`, requested scope, and `resolved_scope`;
|
|
119
|
+
- completed and failed work;
|
|
120
|
+
- row and byte totals; and
|
|
121
|
+
- output locations and redacted failure evidence.
|
|
122
|
+
|
|
123
|
+
Publication and metadata synchronization are separate. `--wait` waits for the
|
|
124
|
+
publish run. Also inspect `metadata_sync_status`. For unchanged table schemas,
|
|
125
|
+
publication success is normally the completion signal. If tables or columns
|
|
126
|
+
changed, wait for `metadata_sync_status: succeeded` before claiming the new
|
|
127
|
+
schema is discoverable through inquiry.
|
|
128
|
+
|
|
129
|
+
If publication succeeded but metadata synchronization failed, report that the
|
|
130
|
+
data is durable and only discovery is delayed. Ask before retrying metadata
|
|
131
|
+
synchronization through the API or AnswerLayer UI; do not rerun extraction.
|
|
132
|
+
|
|
133
|
+
## 5. Recover a failed publish run
|
|
134
|
+
|
|
135
|
+
Summarize completed and failed work and the redacted error. After explicit
|
|
136
|
+
confirmation, retry the terminal run with a new retry-specific idempotency key:
|
|
137
|
+
|
|
138
|
+
```bash
|
|
139
|
+
AL pipelines runs retry <pipeline-id> <run-id> \
|
|
140
|
+
--idempotency-key <source-event-id>-retry-1 \
|
|
141
|
+
--wait \
|
|
142
|
+
--json
|
|
143
|
+
```
|
|
144
|
+
|
|
145
|
+
The retry preserves the original revision and dataset scope and resumes from
|
|
146
|
+
its durable checkpoint, skipping outputs already published by that run.
|
package/src/cli.js
CHANGED
|
@@ -96,12 +96,38 @@ function installSkill(command, parsed, io) {
|
|
|
96
96
|
throw usage("Expected `answerlayer skills install`");
|
|
97
97
|
}
|
|
98
98
|
|
|
99
|
+
const requestedSkill = parsed.positionals[2] || "answerlayer";
|
|
100
|
+
const skill = {
|
|
101
|
+
answerlayer: {
|
|
102
|
+
directory: "answerlayer",
|
|
103
|
+
targetName: "answerlayer",
|
|
104
|
+
label: "AnswerLayer",
|
|
105
|
+
},
|
|
106
|
+
"pipeline-refresh": {
|
|
107
|
+
directory: "answerlayer-pipeline-refresh",
|
|
108
|
+
targetName: "answerlayer-pipeline-refresh",
|
|
109
|
+
label: "AnswerLayer pipeline refresh",
|
|
110
|
+
},
|
|
111
|
+
"answerlayer-pipeline-refresh": {
|
|
112
|
+
directory: "answerlayer-pipeline-refresh",
|
|
113
|
+
targetName: "answerlayer-pipeline-refresh",
|
|
114
|
+
label: "AnswerLayer pipeline refresh",
|
|
115
|
+
},
|
|
116
|
+
}[requestedSkill];
|
|
117
|
+
|
|
118
|
+
if (!skill || parsed.positionals.length > 3) {
|
|
119
|
+
throw usage(
|
|
120
|
+
"Unknown skill. Choose `answerlayer` (default) or `pipeline-refresh`.",
|
|
121
|
+
);
|
|
122
|
+
}
|
|
123
|
+
|
|
99
124
|
const source = path.resolve(
|
|
100
125
|
path.dirname(fileURLToPath(import.meta.url)),
|
|
101
|
-
|
|
126
|
+
`../skills/${skill.directory}`,
|
|
102
127
|
);
|
|
103
128
|
const codexHome = io.env.CODEX_HOME || path.join(os.homedir(), ".codex");
|
|
104
|
-
const target = firstValue(parsed.flags.path)
|
|
129
|
+
const target = firstValue(parsed.flags.path)
|
|
130
|
+
|| path.join(codexHome, "skills", skill.targetName);
|
|
105
131
|
|
|
106
132
|
if (fs.existsSync(target) && !parsed.flags.force) {
|
|
107
133
|
throw usage(
|
|
@@ -111,7 +137,7 @@ function installSkill(command, parsed, io) {
|
|
|
111
137
|
|
|
112
138
|
fs.mkdirSync(path.dirname(target), { recursive: true, mode: 0o700 });
|
|
113
139
|
fs.cpSync(source, target, { recursive: true, force: true });
|
|
114
|
-
write(io.stdout, `Installed
|
|
140
|
+
write(io.stdout, `Installed ${skill.label} skill to ${target}\n`);
|
|
115
141
|
}
|
|
116
142
|
|
|
117
143
|
async function initialize(parsed, io) {
|
|
@@ -380,6 +406,17 @@ async function handlePipelineRuns(client, base, positionals, parsed, io) {
|
|
|
380
406
|
const pipelineId = requirePositional(positionals, 1, "pipeline id");
|
|
381
407
|
const pipelinePath = `${base}/${encodeURIComponent(pipelineId)}`;
|
|
382
408
|
|
|
409
|
+
if (action === "list") {
|
|
410
|
+
return requestAndPrint(client, "GET", `${pipelinePath}/runs`, parsed, io, {
|
|
411
|
+
query: dropUndefined({
|
|
412
|
+
limit: parseInteger(firstValue(parsed.flags.limit), undefined),
|
|
413
|
+
offset: parseInteger(firstValue(parsed.flags.offset), undefined),
|
|
414
|
+
status: firstValue(parsed.flags.status),
|
|
415
|
+
trigger: firstValue(parsed.flags.trigger),
|
|
416
|
+
}),
|
|
417
|
+
});
|
|
418
|
+
}
|
|
419
|
+
|
|
383
420
|
if (action === "start" || action === "run") {
|
|
384
421
|
const body = await readData(parsed.flags, io, {
|
|
385
422
|
datasets: optionalCsvOrRepeated(parsed.flags.dataset),
|
|
@@ -1287,7 +1324,7 @@ async function handleOptimization(client, command, positionals, parsed, io) {
|
|
|
1287
1324
|
) ?? 10,
|
|
1288
1325
|
max_targeted_evals: parseBoundedInteger(
|
|
1289
1326
|
firstValue(parsed.flags.maxTargetedEvals), "max-targeted-evals", 0, 25,
|
|
1290
|
-
) ??
|
|
1327
|
+
) ?? 10,
|
|
1291
1328
|
},
|
|
1292
1329
|
objectives: {
|
|
1293
1330
|
minimum_score_improvement: numberFlag(parsed.flags.minImprovement, 0.5),
|
|
@@ -2500,7 +2537,7 @@ function helpText() {
|
|
|
2500
2537
|
return `AnswerLayer CLI
|
|
2501
2538
|
|
|
2502
2539
|
Usage:
|
|
2503
|
-
answerlayer skills install [--path <directory>] [--force]
|
|
2540
|
+
answerlayer skills install [answerlayer|pipeline-refresh] [--path <directory>] [--force]
|
|
2504
2541
|
answerlayer local init [--image <image>] [--port <port>]
|
|
2505
2542
|
answerlayer local start [--no-demo]
|
|
2506
2543
|
answerlayer local status|logs|stop
|
|
@@ -2520,7 +2557,7 @@ Core:
|
|
|
2520
2557
|
answerlayer api-keys list|create|revoke
|
|
2521
2558
|
answerlayer pipelines list|create|get|update|enable|disable|archive
|
|
2522
2559
|
answerlayer pipelines revisions list|get|push|validate|connection-test|probe|promote|diff|rollback <pipeline-id> [revision-id]
|
|
2523
|
-
answerlayer pipelines runs start|get|retry|cancel <pipeline-id> [run-id]
|
|
2560
|
+
answerlayer pipelines runs list|start|get|retry|cancel <pipeline-id> [run-id]
|
|
2524
2561
|
answerlayer pipelines schedule get|set|update|pause|resume|delete <pipeline-id>
|
|
2525
2562
|
answerlayer connections supported|list|get|create|update|delete|schema|test
|
|
2526
2563
|
answerlayer metadata structure|tables|columns|pii-summary|pii-settings|detect-pii
|